fix: reuse resolver for agent rpc launch

This commit is contained in:
Peter Steinberger
2025-12-07 05:34:25 +01:00
parent 3d89999a06
commit 4645f512d1
4 changed files with 100 additions and 79 deletions

View File

@@ -91,15 +91,21 @@ final class ClawdisXPCService: NSObject, ClawdisXPCProtocol {
thinking: String?,
session: String) async -> (ok: Bool, text: String?, error: String?)
{
let projectRoot = await MainActor.run { RelayProcessManager.shared.projectRootPath() }
let projectRoot = CommandResolver.projectRootPath()
var command = CommandResolver.clawdisCommand(subcommand: "agent")
command += ["--message", message, "--json"]
if !session.isEmpty { command += ["--to", session] }
if let thinking { command += ["--thinking", thinking] }
let process = Process()
process.executableURL = URL(fileURLWithPath: "/usr/bin/env")
var args = ["pnpm", "clawdis", "agent", "--message", message, "--json"]
if !session.isEmpty { args += ["--to", session] }
if let thinking { args += ["--thinking", thinking] }
process.arguments = args
process.executableURL = URL(fileURLWithPath: command.first ?? "/usr/bin/env")
process.arguments = Array(command.dropFirst())
process.currentDirectoryURL = URL(fileURLWithPath: projectRoot)
var env = ProcessInfo.processInfo.environment
env["PATH"] = CommandResolver.preferredPaths().joined(separator: ":")
process.environment = env
let outPipe = Pipe()
let errPipe = Pipe()
process.standardOutput = outPipe