acpx 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{cli-CLRrs6eQ.js → cli-ChWsO-bb.js} +4 -4
- package/dist/{cli-CLRrs6eQ.js.map → cli-ChWsO-bb.js.map} +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +11 -12
- package/dist/cli.js.map +1 -1
- package/dist/{client-DLTWuu4w.d.ts → client-D-4_aZf2.d.ts} +7 -2
- package/dist/client-D-4_aZf2.d.ts.map +1 -0
- package/dist/{flags-BmubjvOw.js → flags-ceSqz2T6.js} +4 -4
- package/dist/{flags-BmubjvOw.js.map → flags-ceSqz2T6.js.map} +1 -1
- package/dist/{flows-CR7xCmkR.js → flows-_KmnuUXd.js} +5 -5
- package/dist/{flows-CR7xCmkR.js.map → flows-_KmnuUXd.js.map} +1 -1
- package/dist/flows.d.ts +1 -1
- package/dist/flows.js +1 -1
- package/dist/{ipc-DN6M4Ui9.js → ipc-BM335WFg.js} +3 -3
- package/dist/{ipc-DN6M4Ui9.js.map → ipc-BM335WFg.js.map} +1 -1
- package/dist/{jsonrpc-M3y-qzy8.js → jsonrpc-DSxh2w5R.js} +1 -1
- package/dist/{jsonrpc-M3y-qzy8.js.map → jsonrpc-DSxh2w5R.js.map} +1 -1
- package/dist/{output-Di0M9Et8.js → output-C4QhjpM6.js} +2 -2
- package/dist/{output-Di0M9Et8.js.map → output-C4QhjpM6.js.map} +1 -1
- package/dist/{perf-metrics-D9QC81lB.js → perf-metrics-D0um6IR6.js} +22 -2
- package/dist/perf-metrics-D0um6IR6.js.map +1 -0
- package/dist/{prompt-turn-Bt8T3SRR.js → prompt-turn-CXMtXBl-.js} +266 -28
- package/dist/prompt-turn-CXMtXBl-.js.map +1 -0
- package/dist/{render-BL5ynRkN.js → render-Br-kVPK_.js} +3 -3
- package/dist/{render-BL5ynRkN.js.map → render-Br-kVPK_.js.map} +1 -1
- package/dist/runtime.d.ts +9 -3
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +45 -5
- package/dist/runtime.js.map +1 -1
- package/dist/{session-BbN0SBgf.js → session-BtwAKtJ3.js} +5 -5
- package/dist/{session-BbN0SBgf.js.map → session-BtwAKtJ3.js.map} +1 -1
- package/dist/{types-DXxLBQc3.d.ts → types-yxf-gcOE.d.ts} +2 -1
- package/dist/{types-DXxLBQc3.d.ts.map → types-yxf-gcOE.d.ts.map} +1 -1
- package/package.json +1 -1
- package/dist/agent-registry-DGw0-3Tc.js +0 -54
- package/dist/agent-registry-DGw0-3Tc.js.map +0 -1
- package/dist/client-DLTWuu4w.d.ts.map +0 -1
- package/dist/perf-metrics-D9QC81lB.js.map +0 -1
- package/dist/prompt-turn-Bt8T3SRR.js.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as isSessionUpdateNotification } from "./jsonrpc-
|
|
1
|
+
import { B as PermissionPromptUnavailableError, C as isAcpResourceNotFoundError, F as AuthPolicyError, G as SessionNotFoundError, I as ClaudeAcpSessionCreateTimeoutError, K as SessionResolutionError, L as CopilotAcpUnsupportedError, M as AgentDisconnectedError, N as AgentSpawnError, P as AgentStartupError, R as GeminiAcpStartupTimeoutError, S as extractAcpError, U as SessionModeReplayError, W as SessionModelReplayError, g as textPrompt, i as measurePerf, j as SESSION_RECORD_SCHEMA, l as extractRuntimeSessionId, q as SessionResumeRequiredError, r as incrementPerfCounter, u as normalizeRuntimeSessionId, v as formatErrorMessage, y as isAcpQueryClosedBeforeResponseError, z as PermissionDeniedError } from "./perf-metrics-D0um6IR6.js";
|
|
2
|
+
import { r as isSessionUpdateNotification } from "./jsonrpc-DSxh2w5R.js";
|
|
3
3
|
import fs, { statSync } from "node:fs";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
4
5
|
import path from "node:path";
|
|
5
6
|
import fs$1 from "node:fs/promises";
|
|
6
7
|
import os from "node:os";
|
|
@@ -9,6 +10,159 @@ import { Readable, Writable } from "node:stream";
|
|
|
9
10
|
import { ClientSideConnection, PROTOCOL_VERSION } from "@agentclientprotocol/sdk";
|
|
10
11
|
import readline from "node:readline/promises";
|
|
11
12
|
import { randomUUID } from "node:crypto";
|
|
13
|
+
//#region src/agent-registry.ts
|
|
14
|
+
const ACP_ADAPTER_PACKAGE_RANGES = {
|
|
15
|
+
pi: "^0.0.22",
|
|
16
|
+
codex: "^0.11.1",
|
|
17
|
+
claude: "^0.25.0"
|
|
18
|
+
};
|
|
19
|
+
const AGENT_REGISTRY = {
|
|
20
|
+
pi: `npx pi-acp@${ACP_ADAPTER_PACKAGE_RANGES.pi}`,
|
|
21
|
+
openclaw: "openclaw acp",
|
|
22
|
+
codex: `npx @zed-industries/codex-acp@${ACP_ADAPTER_PACKAGE_RANGES.codex}`,
|
|
23
|
+
claude: `npx -y @agentclientprotocol/claude-agent-acp@${ACP_ADAPTER_PACKAGE_RANGES.claude}`,
|
|
24
|
+
gemini: "gemini --acp",
|
|
25
|
+
cursor: "cursor-agent acp",
|
|
26
|
+
copilot: "copilot --acp --stdio",
|
|
27
|
+
droid: "droid exec --output-format acp",
|
|
28
|
+
iflow: "iflow --experimental-acp",
|
|
29
|
+
kilocode: "npx -y @kilocode/cli acp",
|
|
30
|
+
kimi: "kimi acp",
|
|
31
|
+
kiro: "kiro-cli-chat acp",
|
|
32
|
+
opencode: "npx -y opencode-ai acp",
|
|
33
|
+
qoder: "qodercli --acp",
|
|
34
|
+
qwen: "qwen --acp",
|
|
35
|
+
trae: "traecli acp serve"
|
|
36
|
+
};
|
|
37
|
+
const BUILT_IN_AGENT_PACKAGES = {
|
|
38
|
+
codex: {
|
|
39
|
+
packageName: "@zed-industries/codex-acp",
|
|
40
|
+
packageRange: ACP_ADAPTER_PACKAGE_RANGES.codex,
|
|
41
|
+
preferredBinName: "codex-acp",
|
|
42
|
+
fallbackCommand: AGENT_REGISTRY.codex,
|
|
43
|
+
legacyFallbackCommands: []
|
|
44
|
+
},
|
|
45
|
+
claude: {
|
|
46
|
+
packageName: "@agentclientprotocol/claude-agent-acp",
|
|
47
|
+
packageRange: ACP_ADAPTER_PACKAGE_RANGES.claude,
|
|
48
|
+
preferredBinName: "claude-agent-acp",
|
|
49
|
+
fallbackCommand: AGENT_REGISTRY.claude,
|
|
50
|
+
legacyFallbackCommands: [`npm exec @agentclientprotocol/claude-agent-acp@${ACP_ADAPTER_PACKAGE_RANGES.claude}`]
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const AGENT_ALIASES = {
|
|
54
|
+
"factory-droid": "droid",
|
|
55
|
+
factorydroid: "droid"
|
|
56
|
+
};
|
|
57
|
+
const DEFAULT_AGENT_NAME = "codex";
|
|
58
|
+
function normalizeAgentName$1(value) {
|
|
59
|
+
return value.trim().toLowerCase();
|
|
60
|
+
}
|
|
61
|
+
function mergeAgentRegistry(overrides) {
|
|
62
|
+
if (!overrides) return { ...AGENT_REGISTRY };
|
|
63
|
+
const merged = { ...AGENT_REGISTRY };
|
|
64
|
+
for (const [name, command] of Object.entries(overrides)) {
|
|
65
|
+
const normalized = normalizeAgentName$1(name);
|
|
66
|
+
if (!normalized || !command.trim()) continue;
|
|
67
|
+
merged[normalized] = command.trim();
|
|
68
|
+
}
|
|
69
|
+
return merged;
|
|
70
|
+
}
|
|
71
|
+
function resolveAgentCommand(agentName, overrides) {
|
|
72
|
+
const normalized = normalizeAgentName$1(agentName);
|
|
73
|
+
const registry = mergeAgentRegistry(overrides);
|
|
74
|
+
return registry[normalized] ?? registry[AGENT_ALIASES[normalized] ?? normalized] ?? agentName;
|
|
75
|
+
}
|
|
76
|
+
function findBuiltInAgentPackage(agentCommand) {
|
|
77
|
+
const normalized = agentCommand.trim();
|
|
78
|
+
return Object.values(BUILT_IN_AGENT_PACKAGES).find((spec) => spec.fallbackCommand === normalized || spec.legacyFallbackCommands?.includes(normalized));
|
|
79
|
+
}
|
|
80
|
+
function defaultResolvePackageRoot(packageName) {
|
|
81
|
+
const segments = packageName.split("/");
|
|
82
|
+
let cursor = path.dirname(fileURLToPath(import.meta.url));
|
|
83
|
+
while (true) {
|
|
84
|
+
const candidateRoot = path.join(cursor, "node_modules", ...segments);
|
|
85
|
+
const manifestPath = path.join(candidateRoot, "package.json");
|
|
86
|
+
if (fs.existsSync(manifestPath)) try {
|
|
87
|
+
if (JSON.parse(fs.readFileSync(manifestPath, "utf8")).name === packageName) return candidateRoot;
|
|
88
|
+
} catch {}
|
|
89
|
+
const parent = path.dirname(cursor);
|
|
90
|
+
if (parent === cursor) throw new Error(`Built-in agent package not found: ${packageName}`);
|
|
91
|
+
cursor = parent;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function resolvePackageBin(spec, manifest) {
|
|
95
|
+
if (typeof manifest.bin === "string") return manifest.bin;
|
|
96
|
+
if (!manifest.bin || typeof manifest.bin !== "object") return;
|
|
97
|
+
return manifest.bin[spec.preferredBinName] ?? (Object.keys(manifest.bin).length === 1 ? Object.values(manifest.bin)[0] : void 0);
|
|
98
|
+
}
|
|
99
|
+
function defaultResolveNpmCliPath(execPath) {
|
|
100
|
+
const candidate = path.resolve(path.dirname(execPath), "..", "lib", "node_modules", "npm", "bin", "npm-cli.js");
|
|
101
|
+
if (!fs.existsSync(candidate)) throw new Error(`npm CLI not found for execPath: ${execPath}`);
|
|
102
|
+
return candidate;
|
|
103
|
+
}
|
|
104
|
+
function resolveInstalledBuiltInAgentLaunch(agentCommand, options = {}) {
|
|
105
|
+
const spec = findBuiltInAgentPackage(agentCommand);
|
|
106
|
+
if (!spec) return;
|
|
107
|
+
const readFileSync = options.readFileSync ?? fs.readFileSync;
|
|
108
|
+
const existsSync = options.existsSync ?? fs.existsSync;
|
|
109
|
+
const resolvePackageRoot = options.resolvePackageRoot ?? defaultResolvePackageRoot;
|
|
110
|
+
try {
|
|
111
|
+
const packageRoot = resolvePackageRoot(spec.packageName);
|
|
112
|
+
const manifest = JSON.parse(readFileSync(path.join(packageRoot, "package.json"), "utf8"));
|
|
113
|
+
if (manifest.name !== spec.packageName) return;
|
|
114
|
+
const relativeBinPath = resolvePackageBin(spec, manifest);
|
|
115
|
+
if (!relativeBinPath) return;
|
|
116
|
+
const binPath = path.resolve(packageRoot, relativeBinPath);
|
|
117
|
+
if (!existsSync(binPath)) return;
|
|
118
|
+
return {
|
|
119
|
+
source: "installed",
|
|
120
|
+
command: process.execPath,
|
|
121
|
+
args: [binPath],
|
|
122
|
+
packageName: spec.packageName,
|
|
123
|
+
packageRange: spec.packageRange,
|
|
124
|
+
packageVersion: manifest.version,
|
|
125
|
+
binPath
|
|
126
|
+
};
|
|
127
|
+
} catch {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function resolvePackageExecBuiltInAgentLaunch(agentCommand, options = {}) {
|
|
132
|
+
const spec = findBuiltInAgentPackage(agentCommand);
|
|
133
|
+
if (!spec) return;
|
|
134
|
+
const existsSync = options.existsSync ?? fs.existsSync;
|
|
135
|
+
const execPath = options.execPath ?? process.execPath;
|
|
136
|
+
const resolveNpmCliPath = options.resolveNpmCliPath ?? defaultResolveNpmCliPath;
|
|
137
|
+
try {
|
|
138
|
+
const npmCliPath = resolveNpmCliPath(execPath);
|
|
139
|
+
if (!existsSync(npmCliPath)) return;
|
|
140
|
+
return {
|
|
141
|
+
source: "package-exec",
|
|
142
|
+
command: execPath,
|
|
143
|
+
args: [
|
|
144
|
+
npmCliPath,
|
|
145
|
+
"exec",
|
|
146
|
+
"--yes",
|
|
147
|
+
`--package=${spec.packageName}@${spec.packageRange}`,
|
|
148
|
+
"--",
|
|
149
|
+
spec.preferredBinName
|
|
150
|
+
],
|
|
151
|
+
packageName: spec.packageName,
|
|
152
|
+
packageRange: spec.packageRange,
|
|
153
|
+
npmCliPath
|
|
154
|
+
};
|
|
155
|
+
} catch {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function resolveBuiltInAgentLaunch(agentCommand, options = {}) {
|
|
160
|
+
return resolveInstalledBuiltInAgentLaunch(agentCommand, options) ?? resolvePackageExecBuiltInAgentLaunch(agentCommand, options);
|
|
161
|
+
}
|
|
162
|
+
function listBuiltInAgents(overrides) {
|
|
163
|
+
return Object.keys(mergeAgentRegistry(overrides));
|
|
164
|
+
}
|
|
165
|
+
//#endregion
|
|
12
166
|
//#region src/async-control.ts
|
|
13
167
|
var TimeoutError = class extends Error {
|
|
14
168
|
constructor(timeoutMs) {
|
|
@@ -323,6 +477,7 @@ function parseAcpxState(raw) {
|
|
|
323
477
|
const record = asRecord$3(raw);
|
|
324
478
|
if (!record) return;
|
|
325
479
|
const state = {};
|
|
480
|
+
if (record.reset_on_next_ensure === true) state.reset_on_next_ensure = true;
|
|
326
481
|
if (typeof record.current_mode_id === "string") state.current_mode_id = record.current_mode_id;
|
|
327
482
|
if (typeof record.desired_mode_id === "string") state.desired_mode_id = record.desired_mode_id;
|
|
328
483
|
if (typeof record.current_model_id === "string") state.current_model_id = record.current_model_id;
|
|
@@ -1663,6 +1818,7 @@ const REPLAY_DRAIN_TIMEOUT_MS = 5e3;
|
|
|
1663
1818
|
const DRAIN_POLL_INTERVAL_MS = 20;
|
|
1664
1819
|
const AGENT_CLOSE_TERM_GRACE_MS = 1500;
|
|
1665
1820
|
const AGENT_CLOSE_KILL_GRACE_MS = 1e3;
|
|
1821
|
+
const STARTUP_STDERR_MAX_CHARS = 8192;
|
|
1666
1822
|
function shouldSuppressSdkConsoleError(args) {
|
|
1667
1823
|
if (args.length === 0) return false;
|
|
1668
1824
|
return typeof args[0] === "string" && args[0] === "Error handling request";
|
|
@@ -1798,6 +1954,9 @@ var AcpClient = class {
|
|
|
1798
1954
|
supportsLoadSession() {
|
|
1799
1955
|
return Boolean(this.initResult?.agentCapabilities?.loadSession);
|
|
1800
1956
|
}
|
|
1957
|
+
supportsCloseSession() {
|
|
1958
|
+
return Boolean(this.initResult?.agentCapabilities?.sessionCapabilities?.close);
|
|
1959
|
+
}
|
|
1801
1960
|
setEventHandlers(handlers) {
|
|
1802
1961
|
this.eventHandlers = { ...handlers };
|
|
1803
1962
|
}
|
|
@@ -1825,13 +1984,18 @@ var AcpClient = class {
|
|
|
1825
1984
|
async start() {
|
|
1826
1985
|
if (this.connection && this.agent && isChildProcessRunning(this.agent)) return;
|
|
1827
1986
|
if (this.connection || this.agent) await this.close();
|
|
1828
|
-
const
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
if (
|
|
1834
|
-
|
|
1987
|
+
const configuredCommand = splitCommandLine(this.options.agentCommand);
|
|
1988
|
+
const resolvedBuiltInLaunch = resolveBuiltInAgentLaunch(this.options.agentCommand);
|
|
1989
|
+
const spawnCommand = resolvedBuiltInLaunch?.command ?? configuredCommand.command;
|
|
1990
|
+
let args = resolvedBuiltInLaunch?.args ?? configuredCommand.args;
|
|
1991
|
+
args = await resolveGeminiCommandArgs(spawnCommand, args);
|
|
1992
|
+
if (isQoderAcpCommand(spawnCommand, args)) args = buildQoderAcpCommandArgs(args, this.options);
|
|
1993
|
+
if (resolvedBuiltInLaunch?.source === "installed") this.log(`spawning installed built-in agent ${resolvedBuiltInLaunch.packageName}${resolvedBuiltInLaunch.packageVersion ? `@${resolvedBuiltInLaunch.packageVersion}` : ""} via ${spawnCommand} ${args.join(" ")}`);
|
|
1994
|
+
else if (resolvedBuiltInLaunch?.source === "package-exec") this.log(`spawning built-in agent ${resolvedBuiltInLaunch.packageName}@${resolvedBuiltInLaunch.packageRange} via current Node package exec bridge ${spawnCommand} ${args.join(" ")}`);
|
|
1995
|
+
else this.log(`spawning agent: ${spawnCommand} ${args.join(" ")}`);
|
|
1996
|
+
const geminiAcp = isGeminiAcpCommand(spawnCommand, args);
|
|
1997
|
+
if (isCopilotAcpCommand(spawnCommand, args)) await ensureCopilotAcpSupport(spawnCommand);
|
|
1998
|
+
const spawnedChild = spawn(spawnCommand, args, buildSpawnCommandOptions(spawnCommand, buildAgentSpawnOptions(this.options.cwd, this.options.authCredentials)));
|
|
1835
1999
|
try {
|
|
1836
2000
|
await waitForSpawn$1(spawnedChild);
|
|
1837
2001
|
} catch (error) {
|
|
@@ -1843,7 +2007,9 @@ var AcpClient = class {
|
|
|
1843
2007
|
this.lastAgentExit = void 0;
|
|
1844
2008
|
this.lastKnownPid = child.pid ?? void 0;
|
|
1845
2009
|
this.attachAgentLifecycleObservers(child);
|
|
2010
|
+
const startupStderr = [];
|
|
1846
2011
|
child.stderr.on("data", (chunk) => {
|
|
2012
|
+
this.captureStartupStderr(startupStderr, chunk);
|
|
1847
2013
|
if (!this.options.verbose) return;
|
|
1848
2014
|
process.stderr.write(chunk);
|
|
1849
2015
|
});
|
|
@@ -1881,30 +2047,38 @@ var AcpClient = class {
|
|
|
1881
2047
|
connection.signal.addEventListener("abort", () => {
|
|
1882
2048
|
this.recordAgentExit("connection_close", child.exitCode ?? null, child.signalCode ?? null);
|
|
1883
2049
|
}, { once: true });
|
|
2050
|
+
const startupFailure = this.createStartupFailureWatcher(child, startupStderr);
|
|
1884
2051
|
try {
|
|
1885
|
-
const
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
2052
|
+
const initResult = await Promise.race([(async () => {
|
|
2053
|
+
const initializePromise = connection.initialize({
|
|
2054
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
2055
|
+
clientCapabilities: {
|
|
2056
|
+
fs: {
|
|
2057
|
+
readTextFile: true,
|
|
2058
|
+
writeTextFile: true
|
|
2059
|
+
},
|
|
2060
|
+
terminal: true
|
|
1891
2061
|
},
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
2062
|
+
clientInfo: {
|
|
2063
|
+
name: "acpx",
|
|
2064
|
+
version: "0.1.0"
|
|
2065
|
+
}
|
|
2066
|
+
});
|
|
2067
|
+
const initialized = geminiAcp ? await withTimeout(initializePromise, resolveGeminiAcpStartupTimeoutMs()) : await initializePromise;
|
|
2068
|
+
await this.authenticateIfRequired(connection, initialized.authMethods ?? []);
|
|
2069
|
+
return initialized;
|
|
2070
|
+
})(), startupFailure.promise]);
|
|
2071
|
+
startupFailure.dispose();
|
|
1901
2072
|
this.connection = connection;
|
|
1902
2073
|
this.agent = child;
|
|
1903
2074
|
this.initResult = initResult;
|
|
1904
2075
|
this.log(`initialized protocol version ${initResult.protocolVersion}`);
|
|
1905
2076
|
} catch (error) {
|
|
1906
|
-
|
|
1907
|
-
|
|
2077
|
+
startupFailure.dispose();
|
|
2078
|
+
try {
|
|
2079
|
+
child.kill();
|
|
2080
|
+
} catch {}
|
|
2081
|
+
if (geminiAcp && error instanceof TimeoutError) throw new GeminiAcpStartupTimeoutError(await buildGeminiAcpStartupTimeoutMessage(spawnCommand), {
|
|
1908
2082
|
cause: error,
|
|
1909
2083
|
retryable: true
|
|
1910
2084
|
});
|
|
@@ -2079,6 +2253,11 @@ var AcpClient = class {
|
|
|
2079
2253
|
this.cancellingSessionIds.add(sessionId);
|
|
2080
2254
|
await this.runConnectionRequest(() => connection.cancel({ sessionId }));
|
|
2081
2255
|
}
|
|
2256
|
+
async closeSession(sessionId) {
|
|
2257
|
+
const connection = this.getConnection();
|
|
2258
|
+
await this.runConnectionRequest(() => connection.unstable_closeSession({ sessionId }));
|
|
2259
|
+
if (this.loadedSessionId === sessionId) this.loadedSessionId = void 0;
|
|
2260
|
+
}
|
|
2082
2261
|
async requestCancelActivePrompt() {
|
|
2083
2262
|
const active = this.activePrompt;
|
|
2084
2263
|
if (!active) return false;
|
|
@@ -2164,6 +2343,65 @@ var AcpClient = class {
|
|
|
2164
2343
|
if (!this.options.verbose) return;
|
|
2165
2344
|
process.stderr.write(`[acpx] ${message}\n`);
|
|
2166
2345
|
}
|
|
2346
|
+
captureStartupStderr(target, chunk) {
|
|
2347
|
+
const text = typeof chunk === "string" ? chunk : chunk.toString("utf8");
|
|
2348
|
+
if (text.length === 0) return;
|
|
2349
|
+
target.push(text);
|
|
2350
|
+
if (target.join("").length - STARTUP_STDERR_MAX_CHARS <= 0) return;
|
|
2351
|
+
const joined = target.join("");
|
|
2352
|
+
target.splice(0, target.length, joined.slice(-STARTUP_STDERR_MAX_CHARS));
|
|
2353
|
+
}
|
|
2354
|
+
summarizeStartupStderr(target) {
|
|
2355
|
+
const joined = target.join("").trim();
|
|
2356
|
+
if (!joined) return;
|
|
2357
|
+
return joined.replace(/\s+/gu, " ").trim().slice(0, STARTUP_STDERR_MAX_CHARS);
|
|
2358
|
+
}
|
|
2359
|
+
createStartupFailureWatcher(child, startupStderr) {
|
|
2360
|
+
let settled = false;
|
|
2361
|
+
let rejectPromise;
|
|
2362
|
+
const cleanup = () => {
|
|
2363
|
+
child.off("error", onError);
|
|
2364
|
+
child.off("exit", onExit);
|
|
2365
|
+
child.off("close", onClose);
|
|
2366
|
+
};
|
|
2367
|
+
const finish = (error) => {
|
|
2368
|
+
if (settled) return;
|
|
2369
|
+
settled = true;
|
|
2370
|
+
cleanup();
|
|
2371
|
+
if (error) rejectPromise(error);
|
|
2372
|
+
};
|
|
2373
|
+
const createError = (params) => new AgentStartupError({
|
|
2374
|
+
agentCommand: this.options.agentCommand,
|
|
2375
|
+
exitCode: params?.exitCode ?? child.exitCode ?? null,
|
|
2376
|
+
signal: params?.signal ?? child.signalCode ?? null,
|
|
2377
|
+
stderrSummary: this.summarizeStartupStderr(startupStderr),
|
|
2378
|
+
cause: params?.cause
|
|
2379
|
+
});
|
|
2380
|
+
const onError = (error) => {
|
|
2381
|
+
finish(createError({ cause: error }));
|
|
2382
|
+
};
|
|
2383
|
+
const onExit = (exitCode, signal) => {
|
|
2384
|
+
finish(createError({
|
|
2385
|
+
exitCode,
|
|
2386
|
+
signal
|
|
2387
|
+
}));
|
|
2388
|
+
};
|
|
2389
|
+
const onClose = (exitCode, signal) => {
|
|
2390
|
+
finish(createError({
|
|
2391
|
+
exitCode,
|
|
2392
|
+
signal
|
|
2393
|
+
}));
|
|
2394
|
+
};
|
|
2395
|
+
return {
|
|
2396
|
+
promise: new Promise((_resolve, reject) => {
|
|
2397
|
+
rejectPromise = reject;
|
|
2398
|
+
child.once("error", onError);
|
|
2399
|
+
child.once("exit", onExit);
|
|
2400
|
+
child.once("close", onClose);
|
|
2401
|
+
}),
|
|
2402
|
+
dispose: () => finish()
|
|
2403
|
+
};
|
|
2404
|
+
}
|
|
2167
2405
|
selectAuthMethod(methods) {
|
|
2168
2406
|
for (const method of methods) {
|
|
2169
2407
|
const envCredential = readEnvCredential(method.id);
|
|
@@ -3118,6 +3356,6 @@ async function runPromptTurn(params) {
|
|
|
3118
3356
|
}
|
|
3119
3357
|
}
|
|
3120
3358
|
//#endregion
|
|
3121
|
-
export { resolveSessionRecord as A, serializeSessionRecordForDisk as B, findGitRepositoryRoot as C, listSessions as D, isoNow$2 as E, sessionBaseDir$1 as F, TimeoutError as H, sessionEventActivePath as I, sessionEventLockPath as L, parseSessionRecord as M, DEFAULT_EVENT_SEGMENT_MAX_BYTES as N, listSessionsForAgent as O, defaultSessionEventLog as P, sessionEventSegmentPath as R, absolutePath as S, findSessionByDirectoryWalk as T, withInterrupt as U, InterruptedError as V, withTimeout as W, recordSessionUpdate as _, applyConversation as a, permissionModeSatisfies as b, setCurrentModelId as c, syncAdvertisedModelState as d, cloneSessionAcpxState as f, recordPromptSubmission as g, recordClientOperation as h, connectAndLoadSession as i, writeSessionRecord as j, normalizeName as k, setDesiredModeId as l, createSessionConversation as m, withConnectedSession as n, applyLifecycleSnapshotToRecord as o, cloneSessionConversation as p, sessionOptionsFromRecord as r, reconcileAgentSessionId as s, runPromptTurn as t, setDesiredModelId as u, trimConversationForRuntime as v, findSession as w, DEFAULT_HISTORY_LIMIT as x, AcpClient as y, assertPersistedKeyPolicy as z };
|
|
3359
|
+
export { resolveSessionRecord as A, serializeSessionRecordForDisk as B, findGitRepositoryRoot as C, listSessions as D, isoNow$2 as E, sessionBaseDir$1 as F, DEFAULT_AGENT_NAME as G, TimeoutError as H, sessionEventActivePath as I, resolveAgentCommand as J, listBuiltInAgents as K, sessionEventLockPath as L, parseSessionRecord as M, DEFAULT_EVENT_SEGMENT_MAX_BYTES as N, listSessionsForAgent as O, defaultSessionEventLog as P, sessionEventSegmentPath as R, absolutePath as S, findSessionByDirectoryWalk as T, withInterrupt as U, InterruptedError as V, withTimeout as W, recordSessionUpdate as _, applyConversation as a, permissionModeSatisfies as b, setCurrentModelId as c, syncAdvertisedModelState as d, cloneSessionAcpxState as f, recordPromptSubmission as g, recordClientOperation as h, connectAndLoadSession as i, writeSessionRecord as j, normalizeName as k, setDesiredModeId as l, createSessionConversation as m, withConnectedSession as n, applyLifecycleSnapshotToRecord as o, cloneSessionConversation as p, normalizeAgentName$1 as q, sessionOptionsFromRecord as r, reconcileAgentSessionId as s, runPromptTurn as t, setDesiredModelId as u, trimConversationForRuntime as v, findSession as w, DEFAULT_HISTORY_LIMIT as x, AcpClient as y, assertPersistedKeyPolicy as z };
|
|
3122
3360
|
|
|
3123
|
-
//# sourceMappingURL=prompt-turn-
|
|
3361
|
+
//# sourceMappingURL=prompt-turn-CXMtXBl-.js.map
|