acpx 0.6.1 → 0.8.0
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/README.md +8 -2
- package/dist/{cli-Ddxpnz9X.js → cli-BGYGVo3b.js} +35 -10
- package/dist/cli-BGYGVo3b.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +204 -19
- package/dist/cli.js.map +1 -1
- package/dist/{client-2fTFutRH.d.ts → client-FzXPdgP7.d.ts} +10 -4
- package/dist/client-FzXPdgP7.d.ts.map +1 -0
- package/dist/{flags-yXzUm7Aq.js → flags-D706STfk.js} +46 -6
- package/dist/flags-D706STfk.js.map +1 -0
- package/dist/{flows-CDsfbaA2.js → flows-hcjHmU7P.js} +117 -11
- package/dist/flows-hcjHmU7P.js.map +1 -0
- package/dist/flows.d.ts +19 -3
- package/dist/flows.d.ts.map +1 -1
- package/dist/flows.js +2 -2
- package/dist/{prompt-turn-BY5SwU1F.js → live-checkpoint-B9ctAuqV.js} +1335 -82
- package/dist/live-checkpoint-B9ctAuqV.js.map +1 -0
- package/dist/output-BL9XRWzS.js +3712 -0
- package/dist/output-BL9XRWzS.js.map +1 -0
- package/dist/runtime.d.ts +32 -6
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +169 -32
- package/dist/runtime.js.map +1 -1
- package/dist/{types-CVBeQyi3.d.ts → session-options-BJyG6zEH.d.ts} +56 -3
- package/dist/session-options-BJyG6zEH.d.ts.map +1 -0
- package/package.json +27 -25
- package/skills/acpx/SKILL.md +200 -9
- package/dist/cli-Ddxpnz9X.js.map +0 -1
- package/dist/client-2fTFutRH.d.ts.map +0 -1
- package/dist/flags-yXzUm7Aq.js.map +0 -1
- package/dist/flows-CDsfbaA2.js.map +0 -1
- package/dist/ipc-BruTG5Fb.js +0 -1241
- package/dist/ipc-BruTG5Fb.js.map +0 -1
- package/dist/jsonrpc-DSxh2w5R.js +0 -68
- package/dist/jsonrpc-DSxh2w5R.js.map +0 -1
- package/dist/output-DmHvT8vm.js +0 -807
- package/dist/output-DmHvT8vm.js.map +0 -1
- package/dist/perf-metrics-C2pXfxvR.js +0 -598
- package/dist/perf-metrics-C2pXfxvR.js.map +0 -1
- package/dist/prompt-turn-BY5SwU1F.js.map +0 -1
- package/dist/render-yqwtaOX4.js +0 -172
- package/dist/render-yqwtaOX4.js.map +0 -1
- package/dist/rolldown-runtime-CiIaOW0V.js +0 -13
- package/dist/session-BwgaPK8-.js +0 -1526
- package/dist/session-BwgaPK8-.js.map +0 -1
- package/dist/session-options-pCbHn_n7.d.ts +0 -13
- package/dist/session-options-pCbHn_n7.d.ts.map +0 -1
- package/dist/types-CVBeQyi3.d.ts.map +0 -1
package/dist/runtime.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { t as AcpClient } from "./client-
|
|
1
|
+
import { a as AcpPermissionRequest, c as NonInteractivePermissionPolicy, f as SessionRecord, i as AcpPermissionDecision, l as PermissionMode, n as SystemPromptOption, s as McpServer$1, t as SessionAgentOptions } from "./session-options-BJyG6zEH.js";
|
|
2
|
+
import { t as AcpClient } from "./client-FzXPdgP7.js";
|
|
3
3
|
import fs from "node:fs";
|
|
4
|
+
import { ToolCallContent, ToolCallLocation, ToolKind } from "@agentclientprotocol/sdk";
|
|
4
5
|
|
|
5
6
|
//#region src/agent-registry.d.ts
|
|
6
7
|
declare const DEFAULT_AGENT_NAME = "codex";
|
|
@@ -25,6 +26,15 @@ type AcpRuntimeEnsureInput = {
|
|
|
25
26
|
mode: AcpRuntimeSessionMode;
|
|
26
27
|
resumeSessionId?: string;
|
|
27
28
|
cwd?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Per-session agent options applied when a fresh ACP session is created.
|
|
31
|
+
* Threaded into `_meta.systemPrompt` (and `_meta.claudeCode.options.*`)
|
|
32
|
+
* on the underlying `session/new` request, and persisted onto the new
|
|
33
|
+
* record. Ignored when an existing persistent session is reused — system
|
|
34
|
+
* prompts are fixed at `newSession` time, so changing them requires a
|
|
35
|
+
* different sessionKey or closing the prior record first.
|
|
36
|
+
*/
|
|
37
|
+
sessionOptions?: SessionAgentOptions;
|
|
28
38
|
};
|
|
29
39
|
type AcpRuntimeTurnAttachment = {
|
|
30
40
|
mediaType: string;
|
|
@@ -43,11 +53,16 @@ type AcpRuntimeCapabilities = {
|
|
|
43
53
|
controls: AcpRuntimeControl[];
|
|
44
54
|
configOptionKeys?: string[];
|
|
45
55
|
};
|
|
56
|
+
type AcpRuntimeSessionModels = {
|
|
57
|
+
currentModelId?: string;
|
|
58
|
+
availableModelIds: string[];
|
|
59
|
+
};
|
|
46
60
|
type AcpRuntimeStatus = {
|
|
47
61
|
summary?: string;
|
|
48
62
|
acpxRecordId?: string;
|
|
49
63
|
backendSessionId?: string;
|
|
50
64
|
agentSessionId?: string;
|
|
65
|
+
models?: AcpRuntimeSessionModels;
|
|
51
66
|
details?: Record<string, unknown>;
|
|
52
67
|
};
|
|
53
68
|
type AcpRuntimeDoctorReport = {
|
|
@@ -75,6 +90,11 @@ type AcpRuntimeEvent = {
|
|
|
75
90
|
toolCallId?: string;
|
|
76
91
|
status?: string;
|
|
77
92
|
title?: string;
|
|
93
|
+
kind?: ToolKind;
|
|
94
|
+
locations?: ToolCallLocation[];
|
|
95
|
+
rawInput?: unknown;
|
|
96
|
+
rawOutput?: unknown;
|
|
97
|
+
content?: ToolCallContent[];
|
|
78
98
|
}
|
|
79
99
|
/**
|
|
80
100
|
* Compatibility terminal event emitted by runTurn(...). startTurn(...).events
|
|
@@ -92,11 +112,13 @@ type AcpRuntimeEvent = {
|
|
|
92
112
|
type: "error";
|
|
93
113
|
message: string;
|
|
94
114
|
code?: string;
|
|
115
|
+
detailCode?: string;
|
|
95
116
|
retryable?: boolean;
|
|
96
117
|
};
|
|
97
118
|
type AcpRuntimeTurnResultError = {
|
|
98
119
|
message: string;
|
|
99
120
|
code?: string;
|
|
121
|
+
detailCode?: string;
|
|
100
122
|
retryable?: boolean;
|
|
101
123
|
};
|
|
102
124
|
type AcpRuntimeTurnResult = {
|
|
@@ -169,12 +191,15 @@ type AcpRuntimeOptions = {
|
|
|
169
191
|
cwd: string;
|
|
170
192
|
sessionStore: AcpSessionStore;
|
|
171
193
|
agentRegistry: AcpAgentRegistry;
|
|
172
|
-
mcpServers?: McpServer[];
|
|
194
|
+
mcpServers?: McpServer$1[];
|
|
173
195
|
permissionMode: PermissionMode;
|
|
174
196
|
nonInteractivePermissions?: NonInteractivePermissionPolicy;
|
|
175
197
|
timeoutMs?: number;
|
|
176
198
|
probeAgent?: string;
|
|
177
199
|
verbose?: boolean;
|
|
200
|
+
onPermissionRequest?: (req: AcpPermissionRequest, ctx: {
|
|
201
|
+
signal: AbortSignal;
|
|
202
|
+
}) => Promise<AcpPermissionDecision | undefined>;
|
|
178
203
|
};
|
|
179
204
|
type AcpFileSessionStoreOptions = {
|
|
180
205
|
stateDir: string;
|
|
@@ -203,6 +228,7 @@ declare class AcpRuntimeManager {
|
|
|
203
228
|
mode: "persistent" | "oneshot";
|
|
204
229
|
cwd?: string;
|
|
205
230
|
resumeSessionId?: string;
|
|
231
|
+
sessionOptions?: SessionAgentOptions;
|
|
206
232
|
}): Promise<SessionRecord>;
|
|
207
233
|
startTurn(input: {
|
|
208
234
|
handle: AcpRuntimeHandle;
|
|
@@ -307,9 +333,9 @@ declare class AcpxRuntime implements AcpxRuntimeLike {
|
|
|
307
333
|
}): Promise<void>;
|
|
308
334
|
};
|
|
309
335
|
runTurn(input: AcpRuntimeTurnInput): AsyncIterable<AcpRuntimeEvent>;
|
|
310
|
-
getCapabilities(
|
|
336
|
+
getCapabilities(input?: {
|
|
311
337
|
handle?: AcpRuntimeHandle;
|
|
312
|
-
}): AcpRuntimeCapabilities
|
|
338
|
+
}): Promise<AcpRuntimeCapabilities>;
|
|
313
339
|
getStatus(input: {
|
|
314
340
|
handle: AcpRuntimeHandle;
|
|
315
341
|
signal?: AbortSignal;
|
|
@@ -342,5 +368,5 @@ declare function createRuntimeStore(options: {
|
|
|
342
368
|
stateDir: string;
|
|
343
369
|
}): AcpSessionStore;
|
|
344
370
|
//#endregion
|
|
345
|
-
export { ACPX_BACKEND_ID, type AcpAgentRegistry, type AcpFileSessionStoreOptions, type AcpRuntime, type AcpRuntimeCapabilities, type AcpRuntimeDoctorReport, type AcpRuntimeEnsureInput, AcpRuntimeError, type AcpRuntimeErrorCode, type AcpRuntimeEvent, type AcpRuntimeHandle, type AcpRuntimeOptions, type AcpRuntimePromptMode, type AcpRuntimeSessionMode, type AcpRuntimeStatus, type AcpRuntimeTurn, type AcpRuntimeTurnAttachment, type AcpRuntimeTurnInput, type AcpRuntimeTurnResult, type AcpRuntimeTurnResultError, type AcpSessionRecord, type AcpSessionStore, type AcpSessionUpdateTag, AcpxRuntime, DEFAULT_AGENT_NAME, createAcpRuntime, createAgentRegistry, createFileSessionStore, createRuntimeStore, decodeAcpxRuntimeHandleState, encodeAcpxRuntimeHandleState, isAcpRuntimeError };
|
|
371
|
+
export { ACPX_BACKEND_ID, type AcpAgentRegistry, type AcpFileSessionStoreOptions, type AcpPermissionDecision, type AcpPermissionRequest, type AcpRuntime, type AcpRuntimeCapabilities, type AcpRuntimeDoctorReport, type AcpRuntimeEnsureInput, AcpRuntimeError, type AcpRuntimeErrorCode, type AcpRuntimeEvent, type AcpRuntimeHandle, type AcpRuntimeOptions, type AcpRuntimePromptMode, type AcpRuntimeSessionMode, type AcpRuntimeSessionModels, type AcpRuntimeStatus, type AcpRuntimeTurn, type AcpRuntimeTurnAttachment, type AcpRuntimeTurnInput, type AcpRuntimeTurnResult, type AcpRuntimeTurnResultError, type AcpSessionRecord, type AcpSessionStore, type AcpSessionUpdateTag, AcpxRuntime, DEFAULT_AGENT_NAME, type SessionAgentOptions, type SystemPromptOption, createAcpRuntime, createAgentRegistry, createFileSessionStore, createRuntimeStore, decodeAcpxRuntimeHandleState, encodeAcpxRuntimeHandleState, isAcpRuntimeError };
|
|
346
372
|
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","names":[],"sources":["../src/agent-registry.ts","../src/runtime/public/contract.ts","../src/runtime/engine/manager.ts","../src/runtime/public/file-session-store.ts","../src/runtime/public/errors.ts","../src/runtime/public/shared.ts","../src/runtime/public/handle-state.ts","../src/runtime.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","names":[],"sources":["../src/agent-registry.ts","../src/runtime/public/contract.ts","../src/runtime/engine/manager.ts","../src/runtime/public/file-session-store.ts","../src/runtime/public/errors.ts","../src/runtime/public/shared.ts","../src/runtime/public/handle-state.ts","../src/runtime.ts"],"mappings":";;;;;;cAgFa,kBAAA;;;KCjED,oBAAA;AAAA,KAEA,qBAAA;AAAA,KAEA,mBAAA;AAAA,KAaA,iBAAA;AAAA,KAEA,gBAAA;EACV,UAAA;EACA,OAAA;EACA,kBAAA;EACA,GAAA;EACA,YAAA;EACA,gBAAA;EACA,cAAA;AAAA;AAAA,KAGU,qBAAA;EACV,UAAA;EACA,KAAA;EACA,IAAA,EAAM,qBAAA;EACN,eAAA;EACA,GAAA;EA9BU;;;;AAAmB;AAa/B;;;EA0BE,cAAA,GAAiB,mBAAmB;AAAA;AAAA,KAG1B,wBAAA;EACV,SAAA;EACA,IAAI;AAAA;AAAA,KAGM,mBAAA;EACV,MAAA,EAAQ,gBAAA;EACR,IAAA;EACA,WAAA,GAAc,wBAAA;EACd,IAAA,EAAM,oBAAA;EACN,SAAA;EACA,SAAA;EACA,MAAA,GAAS,WAAA;AAAA;AAAA,KAGC,sBAAA;EACV,QAAA,EAAU,iBAAiB;EAC3B,gBAAA;AAAA;AAAA,KAGU,uBAAA;EACV,cAAA;EACA,iBAAiB;AAAA;AAAA,KAGP,gBAAA;EACV,OAAA;EACA,YAAA;EACA,gBAAA;EACA,cAAA;EACA,MAAA,GAAS,uB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AA,IAAiB,OAAA;;MAGZ,MAAA;IAAA,IAAiB,OAAA;EAAA;EAMxC,OAAA,CAAQ,KAAA,EAAO,mBAAA,GAAsB,aAAA,CAAc,eAAA;EAepD,eAAA,CAAgB,KAAA;IAAU,MAAA,GAAS,gBAAA;EAAA,IAAqB,OAAA,CAAQ,sBAAA;EAyBhE,SAAA,CAAU,KAAA;IACd,MAAA,EAAQ,gBAAA;IACR,MAAA,GAAS,WAAA;EAAA,IACP,OAAA,CAAQ,gBAAA;EAMN,OAAA,CAAQ,KAAA;IAAS,MAAA,EAAQ,gBAAA;IAAkB,IAAA;EAAA,IAAiB,OAAA;EAM5D,eAAA,CAAgB,KAAA;IACpB,MAAA,EAAQ,gBAAA;IACR,GAAA;IACA,KAAA;EAAA,IACE,OAAA;EAME,MAAA,CAAO,KAAA;IAAS,MAAA,EAAQ,gBAAA;IAAkB,MAAA;EAAA,IAAoB,OAAA;EAM9D,KAAA,CAAM,KAAA;IACV,MAAA,EAAQ,gBAAA;IACR,MAAA;IACA,sBAAA;EAAA,IACE,OAAA;EAAA,QAQU,UAAA;EAAA,QAeA,QAAA;EAAA,QAIN,oBAAA;EAAA,QAcA,kBAAA;AAAA;AAAA,iBA+BM,gBAAA,CAAiB,OAAA,EAAS,iBAAA,GAAoB,WAAW;AAAA,iBAIzD,kBAAA,CAAmB,OAAA;EAAW,QAAA;AAAA,IAAqB,eAAe"}
|
package/dist/runtime.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { I as parseSessionRecord, J as withTimeout, Q as resolveAgentCommand, R as defaultSessionEventLog, S as AcpClient, U as assertPersistedKeyPolicy, W as serializeSessionRecordForDisk, X as listBuiltInAgents, Y as DEFAULT_AGENT_NAME, _ as createSessionConversation, a as connectAndLoadSession, b as recordSessionUpdate, c as reconcileAgentSessionId, d as setDesiredConfigOption, f as setDesiredModeId, g as cloneSessionConversation, h as cloneSessionAcpxState, n as withConnectedSession, o as applyConversation, s as applyLifecycleSnapshotToRecord, t as runPromptTurn, v as recordClientOperation, x as trimConversationForRuntime, y as recordPromptSubmission } from "./prompt-turn-BY5SwU1F.js";
|
|
1
|
+
import { Dt as isAcpResourceNotFoundError, E as AcpClient, Et as extractAcpError, K as defaultSessionEventLog, S as trimConversationForRuntime, Tt as normalizeOutputError, W as parseSessionRecord, Z as assertPersistedKeyPolicy, _ as cloneSessionConversation, _t as withTimeout, a as applyConversation, b as recordPromptSubmission, c as applyRequestedModelIfAdvertised, d as setDesiredConfigOption, f as setDesiredModeId, g as cloneSessionAcpxState, h as applyConfigOptionsToRecord, i as connectAndLoadSession, m as syncAdvertisedModelState, n as runPromptTurn, o as applyLifecycleSnapshotToRecord, ot as serializeSessionRecordForDisk, pt as textPrompt, r as withConnectedSession, s as reconcileAgentSessionId, t as LiveSessionCheckpoint, u as setCurrentModelId, v as createSessionConversation, vt as DEFAULT_AGENT_NAME, w as persistSessionOptions, x as recordSessionUpdate, xt as resolveAgentCommand, y as recordClientOperation, yt as listBuiltInAgents } from "./live-checkpoint-B9ctAuqV.js";
|
|
3
2
|
import path from "node:path";
|
|
4
3
|
import fs from "node:fs/promises";
|
|
5
4
|
import { randomUUID } from "node:crypto";
|
|
@@ -37,6 +36,7 @@ function deriveAgentFromSessionKey(sessionKey, fallbackAgent) {
|
|
|
37
36
|
}
|
|
38
37
|
//#endregion
|
|
39
38
|
//#region src/runtime/public/events.ts
|
|
39
|
+
const TOOL_OUTPUT_SUMMARY_MAX_CHARS = 500;
|
|
40
40
|
function safeParseJsonObject(line) {
|
|
41
41
|
try {
|
|
42
42
|
const parsed = JSON.parse(line);
|
|
@@ -169,18 +169,73 @@ function summarizeToolInput(rawInput) {
|
|
|
169
169
|
"search"
|
|
170
170
|
]);
|
|
171
171
|
}
|
|
172
|
+
function truncateToolSummary(value) {
|
|
173
|
+
if (value.length <= TOOL_OUTPUT_SUMMARY_MAX_CHARS) return value;
|
|
174
|
+
return `${value.slice(0, TOOL_OUTPUT_SUMMARY_MAX_CHARS - 1)}…`;
|
|
175
|
+
}
|
|
176
|
+
function readToolContentText(value) {
|
|
177
|
+
const record = isRecord(value) ? value : void 0;
|
|
178
|
+
if (!record) return;
|
|
179
|
+
if (record.type === "content") return readToolContentText(record.content);
|
|
180
|
+
if (record.type === "text") return asString(record.text);
|
|
181
|
+
if (record.type === "resource_link") return asOptionalString(record.title) || asOptionalString(record.name) || asOptionalString(record.uri);
|
|
182
|
+
if (record.type === "resource") {
|
|
183
|
+
const resource = isRecord(record.resource) ? record.resource : void 0;
|
|
184
|
+
return asString(resource?.text) || asOptionalString(resource?.uri);
|
|
185
|
+
}
|
|
186
|
+
if (record.type === "diff") return `diff ${asOptionalString(record.path) || "file"}`;
|
|
187
|
+
if (record.type === "terminal") {
|
|
188
|
+
const terminalId = asOptionalString(record.terminalId) || asOptionalString(record.id);
|
|
189
|
+
return terminalId ? `[terminal] ${terminalId}` : "[terminal]";
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
function summarizeToolContent(content) {
|
|
193
|
+
if (!Array.isArray(content)) return;
|
|
194
|
+
const fragments = content.map((entry) => readToolContentText(entry)?.trim()).filter((entry) => Boolean(entry));
|
|
195
|
+
if (fragments.length === 0) return;
|
|
196
|
+
return truncateToolSummary([...new Set(fragments)].join("\n"));
|
|
197
|
+
}
|
|
198
|
+
function summarizeToolOutput(rawOutput) {
|
|
199
|
+
if (rawOutput == null) return;
|
|
200
|
+
if (typeof rawOutput === "string" || typeof rawOutput === "number" || typeof rawOutput === "boolean") return truncateToolSummary(String(rawOutput));
|
|
201
|
+
const record = isRecord(rawOutput) ? rawOutput : void 0;
|
|
202
|
+
if (!record) return;
|
|
203
|
+
return truncateToolSummary(readFirstString(record, [
|
|
204
|
+
"text",
|
|
205
|
+
"message",
|
|
206
|
+
"error",
|
|
207
|
+
"stdout",
|
|
208
|
+
"stderr",
|
|
209
|
+
"content"
|
|
210
|
+
]) ?? "") || void 0;
|
|
211
|
+
}
|
|
212
|
+
function shouldForwardArray(value) {
|
|
213
|
+
return Array.isArray(value);
|
|
214
|
+
}
|
|
215
|
+
function readToolKind(value) {
|
|
216
|
+
const kind = asOptionalString(value);
|
|
217
|
+
if (kind === "read" || kind === "edit" || kind === "delete" || kind === "move" || kind === "search" || kind === "execute" || kind === "fetch" || kind === "think" || kind === "other") return kind;
|
|
218
|
+
}
|
|
172
219
|
function createToolCallEvent(params) {
|
|
173
220
|
const title = asTrimmedString(params.payload.title) || "tool call";
|
|
174
221
|
const status = asTrimmedString(params.payload.status);
|
|
175
222
|
const inputSummary = summarizeToolInput(params.payload.rawInput);
|
|
223
|
+
const outputSummary = summarizeToolContent(params.payload.content) ?? summarizeToolOutput(params.payload.rawOutput);
|
|
176
224
|
const toolCallId = asOptionalString(params.payload.toolCallId);
|
|
225
|
+
const kind = readToolKind(params.payload.kind);
|
|
177
226
|
const summaryText = status ? `${title} (${status})` : title;
|
|
227
|
+
const detailSummary = params.tag === "tool_call_update" ? outputSummary ?? inputSummary : inputSummary ?? outputSummary;
|
|
178
228
|
return {
|
|
179
229
|
type: "tool_call",
|
|
180
|
-
text:
|
|
230
|
+
text: detailSummary ? `${summaryText}: ${detailSummary}` : summaryText,
|
|
181
231
|
tag: params.tag,
|
|
182
232
|
...toolCallId ? { toolCallId } : {},
|
|
183
233
|
...status ? { status } : {},
|
|
234
|
+
...kind ? { kind } : {},
|
|
235
|
+
...shouldForwardArray(params.payload.locations) ? { locations: params.payload.locations } : {},
|
|
236
|
+
...Object.prototype.hasOwnProperty.call(params.payload, "rawInput") ? { rawInput: params.payload.rawInput } : {},
|
|
237
|
+
...Object.prototype.hasOwnProperty.call(params.payload, "rawOutput") ? { rawOutput: params.payload.rawOutput } : {},
|
|
238
|
+
...shouldForwardArray(params.payload.content) ? { content: params.payload.content } : {},
|
|
184
239
|
title
|
|
185
240
|
};
|
|
186
241
|
}
|
|
@@ -302,12 +357,6 @@ function createDeferred() {
|
|
|
302
357
|
reject
|
|
303
358
|
};
|
|
304
359
|
}
|
|
305
|
-
function applyConfigOptionsToRecord(record, configOptions) {
|
|
306
|
-
if (!configOptions) return;
|
|
307
|
-
const acpxState = cloneSessionAcpxState(record.acpx) ?? {};
|
|
308
|
-
acpxState.config_options = structuredClone(configOptions);
|
|
309
|
-
record.acpx = acpxState;
|
|
310
|
-
}
|
|
311
360
|
var AsyncEventQueue = class {
|
|
312
361
|
items = [];
|
|
313
362
|
waits = [];
|
|
@@ -404,6 +453,7 @@ function legacyTerminalEventFromTurnResult(result) {
|
|
|
404
453
|
type: "error",
|
|
405
454
|
message: result.error.message,
|
|
406
455
|
...result.error.code ? { code: result.error.code } : {},
|
|
456
|
+
...result.error.detailCode ? { detailCode: result.error.detailCode } : {},
|
|
407
457
|
...result.error.retryable === void 0 ? {} : { retryable: result.error.retryable }
|
|
408
458
|
};
|
|
409
459
|
return {
|
|
@@ -420,7 +470,35 @@ function statusSummary(record) {
|
|
|
420
470
|
record.closed ? "closed" : "open"
|
|
421
471
|
].filter(Boolean).join(" ");
|
|
422
472
|
}
|
|
473
|
+
function buildModelsField(record) {
|
|
474
|
+
const available = record.acpx?.available_models;
|
|
475
|
+
const currentModelId = record.acpx?.current_model_id;
|
|
476
|
+
if (!available || available.length === 0) return currentModelId === void 0 ? {} : { models: {
|
|
477
|
+
currentModelId,
|
|
478
|
+
availableModelIds: []
|
|
479
|
+
} };
|
|
480
|
+
return { models: {
|
|
481
|
+
...currentModelId !== void 0 ? { currentModelId } : {},
|
|
482
|
+
availableModelIds: [...available]
|
|
483
|
+
} };
|
|
484
|
+
}
|
|
485
|
+
function advertisedConfigOptionIds(record) {
|
|
486
|
+
const configOptions = record.acpx?.config_options;
|
|
487
|
+
if (!configOptions) return;
|
|
488
|
+
return new Set(configOptions.map((option) => option.id).filter((id) => typeof id === "string" && id.trim().length > 0));
|
|
489
|
+
}
|
|
490
|
+
function resolveSupportedConfigOptionId(record, configId) {
|
|
491
|
+
const advertisedIds = advertisedConfigOptionIds(record);
|
|
492
|
+
if (!advertisedIds) return configId;
|
|
493
|
+
if (advertisedIds.has(configId)) return configId;
|
|
494
|
+
if (configId === "thinking" && advertisedIds.has("effort")) return "effort";
|
|
495
|
+
const supported = [...advertisedIds].toSorted();
|
|
496
|
+
const supportedText = supported.length > 0 ? supported.join(", ") : "none";
|
|
497
|
+
throw new AcpRuntimeError("ACP_BACKEND_UNSUPPORTED_CONTROL", `ACP session ${record.acpxRecordId} does not advertise config option '${configId}'. Supported config options: ${supportedText}.`);
|
|
498
|
+
}
|
|
423
499
|
var AcpRuntimeManager = class {
|
|
500
|
+
options;
|
|
501
|
+
deps;
|
|
424
502
|
activeControllers = /* @__PURE__ */ new Map();
|
|
425
503
|
pendingPersistentClients = /* @__PURE__ */ new Map();
|
|
426
504
|
closingActiveRecords = /* @__PURE__ */ new Set();
|
|
@@ -494,6 +572,7 @@ var AcpRuntimeManager = class {
|
|
|
494
572
|
mcpServers: [...this.options.mcpServers ?? []],
|
|
495
573
|
permissionMode: this.options.permissionMode,
|
|
496
574
|
nonInteractivePermissions: this.options.nonInteractivePermissions,
|
|
575
|
+
onPermissionRequest: this.options.onPermissionRequest,
|
|
497
576
|
verbose: this.options.verbose,
|
|
498
577
|
timeoutMs: this.options.timeoutMs,
|
|
499
578
|
resumePolicy: resumePolicyForSessionMode(sessionMode),
|
|
@@ -525,21 +604,26 @@ var AcpRuntimeManager = class {
|
|
|
525
604
|
mcpServers: [...this.options.mcpServers ?? []],
|
|
526
605
|
permissionMode: this.options.permissionMode,
|
|
527
606
|
nonInteractivePermissions: this.options.nonInteractivePermissions,
|
|
528
|
-
|
|
607
|
+
onPermissionRequest: this.options.onPermissionRequest,
|
|
608
|
+
verbose: this.options.verbose,
|
|
609
|
+
sessionOptions: input.sessionOptions
|
|
529
610
|
});
|
|
530
611
|
let keepClientOpen = false;
|
|
531
612
|
try {
|
|
532
613
|
await client.start();
|
|
533
614
|
let sessionId;
|
|
534
615
|
let agentSessionId;
|
|
616
|
+
let sessionResult;
|
|
535
617
|
if (input.resumeSessionId) {
|
|
536
618
|
const loaded = await client.loadSession(input.resumeSessionId, cwd);
|
|
537
619
|
sessionId = input.resumeSessionId;
|
|
538
620
|
agentSessionId = loaded.agentSessionId;
|
|
621
|
+
sessionResult = loaded;
|
|
539
622
|
} else {
|
|
540
623
|
const created = await client.createSession(cwd);
|
|
541
624
|
sessionId = created.sessionId;
|
|
542
625
|
agentSessionId = created.agentSessionId;
|
|
626
|
+
sessionResult = created;
|
|
543
627
|
}
|
|
544
628
|
const record = createInitialRecord({
|
|
545
629
|
recordId: createRecordId(input.sessionKey, input.mode),
|
|
@@ -552,7 +636,19 @@ var AcpRuntimeManager = class {
|
|
|
552
636
|
this.closingActiveRecords.delete(record.acpxRecordId);
|
|
553
637
|
record.protocolVersion = client.initializeResult?.protocolVersion;
|
|
554
638
|
record.agentCapabilities = client.initializeResult?.agentCapabilities;
|
|
639
|
+
applyConfigOptionsToRecord(record, sessionResult);
|
|
640
|
+
const requestedModelApplied = await applyRequestedModelIfAdvertised({
|
|
641
|
+
client,
|
|
642
|
+
sessionId,
|
|
643
|
+
requestedModel: input.sessionOptions?.model,
|
|
644
|
+
models: sessionResult.models,
|
|
645
|
+
agentCommand,
|
|
646
|
+
timeoutMs: this.options.timeoutMs
|
|
647
|
+
});
|
|
648
|
+
syncAdvertisedModelState(record, sessionResult.models);
|
|
649
|
+
if (requestedModelApplied) setCurrentModelId(record, input.sessionOptions?.model);
|
|
555
650
|
applyLifecycleSnapshotToRecord(record, client.getAgentLifecycleSnapshot());
|
|
651
|
+
persistSessionOptions(record, input.sessionOptions);
|
|
556
652
|
await this.options.sessionStore.save(record);
|
|
557
653
|
if (input.mode === "persistent") {
|
|
558
654
|
const previousClient = this.pendingPersistentClients.get(record.acpxRecordId);
|
|
@@ -617,6 +713,7 @@ var AcpRuntimeManager = class {
|
|
|
617
713
|
let record = null;
|
|
618
714
|
let conversation = null;
|
|
619
715
|
let acpxState;
|
|
716
|
+
let liveCheckpoint;
|
|
620
717
|
let client = null;
|
|
621
718
|
try {
|
|
622
719
|
record = await this.requireRecord(input.handle.acpxRecordId ?? input.handle.sessionKey);
|
|
@@ -637,11 +734,19 @@ var AcpRuntimeManager = class {
|
|
|
637
734
|
mcpServers: [...this.options.mcpServers ?? []],
|
|
638
735
|
permissionMode: this.options.permissionMode,
|
|
639
736
|
nonInteractivePermissions: this.options.nonInteractivePermissions,
|
|
737
|
+
onPermissionRequest: this.options.onPermissionRequest,
|
|
640
738
|
verbose: this.options.verbose
|
|
641
739
|
});
|
|
642
740
|
const runtimeClient = client;
|
|
643
741
|
const runtimeConversation = conversation;
|
|
644
742
|
const runtimeRecord = record;
|
|
743
|
+
liveCheckpoint = new LiveSessionCheckpoint({ save: async () => {
|
|
744
|
+
runtimeRecord.lastUsedAt = isoNow();
|
|
745
|
+
runtimeRecord.acpx = acpxState;
|
|
746
|
+
applyConversation(runtimeRecord, runtimeConversation);
|
|
747
|
+
await this.refreshClosedState(runtimeRecord);
|
|
748
|
+
await this.options.sessionStore.save(runtimeRecord);
|
|
749
|
+
} });
|
|
645
750
|
let activeSessionId = record.acpSessionId;
|
|
646
751
|
const applyPendingCancel = async () => {
|
|
647
752
|
if (!pendingCancel || !runtimeClient.hasActivePrompt()) return false;
|
|
@@ -669,26 +774,36 @@ var AcpRuntimeManager = class {
|
|
|
669
774
|
await runtimeClient.setSessionModel(activeSessionId, modelId);
|
|
670
775
|
},
|
|
671
776
|
setSessionConfigOption: async (configId, value) => {
|
|
777
|
+
return (await activeController.setResolvedSessionConfigOption(configId, value)).response;
|
|
778
|
+
},
|
|
779
|
+
setResolvedSessionConfigOption: async (configId, value) => {
|
|
672
780
|
if (!runtimeClient.hasActivePrompt()) await sessionReady.promise;
|
|
673
|
-
const
|
|
781
|
+
const resolvedConfigId = resolveSupportedConfigOptionId({
|
|
782
|
+
...runtimeRecord,
|
|
783
|
+
acpx: acpxState ?? void 0
|
|
784
|
+
}, configId);
|
|
785
|
+
const response = await runtimeClient.setSessionConfigOption(activeSessionId, resolvedConfigId, value);
|
|
674
786
|
if (response?.configOptions) {
|
|
675
787
|
const nextState = cloneSessionAcpxState(acpxState) ?? {};
|
|
676
788
|
nextState.config_options = structuredClone(response.configOptions);
|
|
677
789
|
acpxState = nextState;
|
|
678
790
|
}
|
|
679
|
-
if (
|
|
791
|
+
if (resolvedConfigId === "mode") {
|
|
680
792
|
const nextState = cloneSessionAcpxState(acpxState) ?? {};
|
|
681
793
|
nextState.desired_mode_id = value;
|
|
682
794
|
acpxState = nextState;
|
|
683
|
-
} else if (
|
|
795
|
+
} else if (resolvedConfigId !== "model") {
|
|
684
796
|
const nextState = cloneSessionAcpxState(acpxState) ?? {};
|
|
685
797
|
nextState.desired_config_options = {
|
|
686
798
|
...nextState.desired_config_options,
|
|
687
|
-
[
|
|
799
|
+
[resolvedConfigId]: value
|
|
688
800
|
};
|
|
689
801
|
acpxState = nextState;
|
|
690
802
|
}
|
|
691
|
-
return
|
|
803
|
+
return {
|
|
804
|
+
configId: resolvedConfigId,
|
|
805
|
+
response
|
|
806
|
+
};
|
|
692
807
|
}
|
|
693
808
|
};
|
|
694
809
|
const emitParsed = (payload) => {
|
|
@@ -702,6 +817,7 @@ var AcpRuntimeManager = class {
|
|
|
702
817
|
onSessionUpdate: (notification) => {
|
|
703
818
|
acpxState = recordSessionUpdate(runtimeConversation, acpxState, notification);
|
|
704
819
|
trimConversationForRuntime(runtimeConversation);
|
|
820
|
+
liveCheckpoint?.request();
|
|
705
821
|
emitParsed({
|
|
706
822
|
jsonrpc: "2.0",
|
|
707
823
|
method: "session/update",
|
|
@@ -711,6 +827,7 @@ var AcpRuntimeManager = class {
|
|
|
711
827
|
onClientOperation: (operation) => {
|
|
712
828
|
acpxState = recordClientOperation(runtimeConversation, acpxState, operation);
|
|
713
829
|
trimConversationForRuntime(runtimeConversation);
|
|
830
|
+
liveCheckpoint?.request();
|
|
714
831
|
emitParsed({
|
|
715
832
|
type: "client_operation",
|
|
716
833
|
...operation
|
|
@@ -727,9 +844,8 @@ var AcpRuntimeManager = class {
|
|
|
727
844
|
resumePolicy: resumePolicyForSessionMode(input.sessionMode),
|
|
728
845
|
timeoutMs: this.options.timeoutMs,
|
|
729
846
|
activeController,
|
|
730
|
-
onClientAvailable: (
|
|
731
|
-
activeController
|
|
732
|
-
this.activeControllers.set(runtimeRecord.acpxRecordId, controller);
|
|
847
|
+
onClientAvailable: () => {
|
|
848
|
+
if (activeController) this.activeControllers.set(runtimeRecord.acpxRecordId, activeController);
|
|
733
849
|
},
|
|
734
850
|
onConnectedRecord: (connectedRecord) => {
|
|
735
851
|
connectedRecord.lastPromptAt = isoNow();
|
|
@@ -738,12 +854,14 @@ var AcpRuntimeManager = class {
|
|
|
738
854
|
activeSessionId = sessionIdValue;
|
|
739
855
|
}
|
|
740
856
|
});
|
|
857
|
+
acpxState = cloneSessionAcpxState(runtimeRecord.acpx);
|
|
741
858
|
sessionReady.resolve();
|
|
742
859
|
runtimeRecord.lastRequestId = input.requestId;
|
|
743
860
|
runtimeRecord.lastPromptAt = isoNow();
|
|
744
861
|
runtimeRecord.closed = false;
|
|
745
862
|
runtimeRecord.closedAt = void 0;
|
|
746
863
|
runtimeRecord.lastUsedAt = isoNow();
|
|
864
|
+
await liveCheckpoint.checkpoint();
|
|
747
865
|
if (resumed || loadError) emitParsed({
|
|
748
866
|
type: "status",
|
|
749
867
|
text: loadError ? `load fallback: ${loadError}` : "session resumed"
|
|
@@ -785,6 +903,7 @@ var AcpRuntimeManager = class {
|
|
|
785
903
|
error: {
|
|
786
904
|
message: normalized.message,
|
|
787
905
|
...normalized.code ? { code: normalized.code } : {},
|
|
906
|
+
...normalized.detailCode ? { detailCode: normalized.detailCode } : {},
|
|
788
907
|
...normalized.retryable !== void 0 ? { retryable: normalized.retryable } : {}
|
|
789
908
|
}
|
|
790
909
|
});
|
|
@@ -798,6 +917,7 @@ var AcpRuntimeManager = class {
|
|
|
798
917
|
record.acpx = acpxState;
|
|
799
918
|
applyConversation(record, conversation);
|
|
800
919
|
record.lastUsedAt = isoNow();
|
|
920
|
+
await liveCheckpoint?.flush().catch(() => {});
|
|
801
921
|
const closed = await this.refreshClosedState(record);
|
|
802
922
|
await this.options.sessionStore.save(record).catch(() => {});
|
|
803
923
|
if (!closed && client) pooled = await this.retainPersistentClientAfterTurn({
|
|
@@ -837,6 +957,7 @@ var AcpRuntimeManager = class {
|
|
|
837
957
|
acpxRecordId: record.acpxRecordId,
|
|
838
958
|
backendSessionId: record.acpSessionId,
|
|
839
959
|
agentSessionId: record.agentSessionId,
|
|
960
|
+
...buildModelsField(record),
|
|
840
961
|
details: {
|
|
841
962
|
cwd: record.cwd,
|
|
842
963
|
lastUsedAt: record.lastUsedAt,
|
|
@@ -859,18 +980,21 @@ var AcpRuntimeManager = class {
|
|
|
859
980
|
async setConfigOption(handle, key, value, sessionMode = "persistent") {
|
|
860
981
|
const record = await this.requireRecord(handle.acpxRecordId ?? handle.sessionKey);
|
|
861
982
|
const controller = this.activeControllers.get(record.acpxRecordId);
|
|
862
|
-
let targetRecord = record;
|
|
863
983
|
if (controller) {
|
|
864
|
-
const response = await controller.
|
|
865
|
-
applyConfigOptionsToRecord(
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
984
|
+
const { configId, response } = await controller.setResolvedSessionConfigOption(key, value);
|
|
985
|
+
applyConfigOptionsToRecord(record, response);
|
|
986
|
+
if (configId === "mode") setDesiredModeId(record, value);
|
|
987
|
+
else setDesiredConfigOption(record, configId, value);
|
|
988
|
+
await this.options.sessionStore.save(record);
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
const result = await this.withRuntimeControlSession(record, sessionMode, async ({ client, sessionId, record: connectedRecord }) => {
|
|
992
|
+
const configId = resolveSupportedConfigOptionId(connectedRecord, key);
|
|
993
|
+
applyConfigOptionsToRecord(connectedRecord, await client.setSessionConfigOption(sessionId, configId, value));
|
|
994
|
+
if (configId === "mode") setDesiredModeId(connectedRecord, value);
|
|
995
|
+
else setDesiredConfigOption(connectedRecord, configId, value);
|
|
996
|
+
});
|
|
997
|
+
await this.options.sessionStore.save(result.record);
|
|
874
998
|
}
|
|
875
999
|
async cancel(handle) {
|
|
876
1000
|
await this.activeControllers.get(handle.acpxRecordId ?? handle.sessionKey)?.requestCancelActivePrompt();
|
|
@@ -898,6 +1022,7 @@ var AcpRuntimeManager = class {
|
|
|
898
1022
|
mcpServers: [...this.options.mcpServers ?? []],
|
|
899
1023
|
permissionMode: this.options.permissionMode,
|
|
900
1024
|
nonInteractivePermissions: this.options.nonInteractivePermissions,
|
|
1025
|
+
onPermissionRequest: this.options.onPermissionRequest,
|
|
901
1026
|
verbose: this.options.verbose
|
|
902
1027
|
});
|
|
903
1028
|
try {
|
|
@@ -924,6 +1049,7 @@ function safeSessionId(sessionId) {
|
|
|
924
1049
|
return encodeURIComponent(sessionId);
|
|
925
1050
|
}
|
|
926
1051
|
var FileSessionStore = class {
|
|
1052
|
+
stateDir;
|
|
927
1053
|
constructor(stateDir) {
|
|
928
1054
|
this.stateDir = stateDir;
|
|
929
1055
|
}
|
|
@@ -1085,6 +1211,8 @@ function createAgentRegistry(params) {
|
|
|
1085
1211
|
};
|
|
1086
1212
|
}
|
|
1087
1213
|
var AcpxRuntime = class {
|
|
1214
|
+
options;
|
|
1215
|
+
testOptions;
|
|
1088
1216
|
healthy = false;
|
|
1089
1217
|
manager = null;
|
|
1090
1218
|
managerPromise = null;
|
|
@@ -1119,7 +1247,8 @@ var AcpxRuntime = class {
|
|
|
1119
1247
|
agent,
|
|
1120
1248
|
mode: input.mode,
|
|
1121
1249
|
cwd: input.cwd ?? this.options.cwd,
|
|
1122
|
-
resumeSessionId: input.resumeSessionId
|
|
1250
|
+
resumeSessionId: input.resumeSessionId,
|
|
1251
|
+
sessionOptions: input.sessionOptions
|
|
1123
1252
|
});
|
|
1124
1253
|
const handle = {
|
|
1125
1254
|
sessionKey: input.sessionKey,
|
|
@@ -1182,8 +1311,16 @@ var AcpxRuntime = class {
|
|
|
1182
1311
|
signal: input.signal
|
|
1183
1312
|
});
|
|
1184
1313
|
}
|
|
1185
|
-
getCapabilities(
|
|
1186
|
-
return ACPX_CAPABILITIES;
|
|
1314
|
+
async getCapabilities(input) {
|
|
1315
|
+
if (!input?.handle) return ACPX_CAPABILITIES;
|
|
1316
|
+
const { handle } = this.resolveManagerHandle(input.handle);
|
|
1317
|
+
const record = await this.options.sessionStore.load(handle.acpxRecordId ?? handle.sessionKey);
|
|
1318
|
+
if (!record?.acpx?.config_options) return ACPX_CAPABILITIES;
|
|
1319
|
+
const configOptionKeys = Array.from(new Set(record.acpx.config_options.map((option) => option.id).filter((id) => typeof id === "string" && id.trim().length > 0)));
|
|
1320
|
+
return {
|
|
1321
|
+
...ACPX_CAPABILITIES,
|
|
1322
|
+
...configOptionKeys.length > 0 ? { configOptionKeys } : {}
|
|
1323
|
+
};
|
|
1187
1324
|
}
|
|
1188
1325
|
async getStatus(input) {
|
|
1189
1326
|
const { handle } = this.resolveManagerHandle(input.handle);
|