acpx 0.10.0 → 0.11.1
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 +25 -19
- package/dist/{cli-8dP_TqBp.js → cli-D4XUKXcD.js} +5 -5
- package/dist/{cli-8dP_TqBp.js.map → cli-D4XUKXcD.js.map} +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +429 -88
- package/dist/cli.js.map +1 -1
- package/dist/{client-C4iJBO0j.d.ts → client-DIlpCkHw.d.ts} +38 -5
- package/dist/client-DIlpCkHw.d.ts.map +1 -0
- package/dist/{flags--2oX_ubW.js → flags-Dvgmpq_l.js} +5 -5
- package/dist/flags-Dvgmpq_l.js.map +1 -0
- package/dist/{flows-e4umXVbY.js → flows-Cvsc-_AW.js} +4 -3
- package/dist/flows-Cvsc-_AW.js.map +1 -0
- package/dist/flows.d.ts +1 -1
- package/dist/flows.d.ts.map +1 -1
- package/dist/flows.js +1 -1
- package/dist/{live-checkpoint-CuFft_Nd.js → live-checkpoint-BWkYxMeS.js} +848 -207
- package/dist/live-checkpoint-BWkYxMeS.js.map +1 -0
- package/dist/{output-Di77Yugq.js → output-BEv_BB7T.js} +359 -141
- package/dist/output-BEv_BB7T.js.map +1 -0
- package/dist/runtime.d.ts +71 -5
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +192 -35
- package/dist/runtime.js.map +1 -1
- package/dist/{session-options-Bh1bIqQ2.d.ts → session-options-jkYbBxGE.d.ts} +27 -2
- package/dist/session-options-jkYbBxGE.d.ts.map +1 -0
- package/package.json +21 -20
- package/skills/acpx/SKILL.md +58 -3
- package/dist/client-C4iJBO0j.d.ts.map +0 -1
- package/dist/flags--2oX_ubW.js.map +0 -1
- package/dist/flows-e4umXVbY.js.map +0 -1
- package/dist/live-checkpoint-CuFft_Nd.js.map +0 -1
- package/dist/output-Di77Yugq.js.map +0 -1
- package/dist/session-options-Bh1bIqQ2.d.ts.map +0 -1
package/dist/runtime.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
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-jkYbBxGE.js";
|
|
2
|
+
import { a as RequestedModelUnsupportedErrorCode, i as RequestedModelUnsupportedError, n as REQUESTED_MODEL_UNSUPPORTED_ERROR_CODE, o as RequestedModelUnsupportedReason, r as REQUESTED_MODEL_UNSUPPORTED_REASONS, s as isRequestedModelUnsupportedError, t as AcpClient } from "./client-DIlpCkHw.js";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import { ToolCallContent, ToolCallLocation, ToolKind } from "@agentclientprotocol/sdk";
|
|
5
5
|
|
|
@@ -61,12 +61,64 @@ type AcpRuntimeSessionModels = {
|
|
|
61
61
|
currentModelId?: string;
|
|
62
62
|
availableModelIds: string[];
|
|
63
63
|
};
|
|
64
|
+
/**
|
|
65
|
+
* Cumulative session cost as reported by the agent. Mirrors ACP's
|
|
66
|
+
* `Cost`, but both fields are optional here because not every adapter
|
|
67
|
+
* populates them on every event.
|
|
68
|
+
*/
|
|
69
|
+
type AcpRuntimeUsageCost = {
|
|
70
|
+
amount?: number;
|
|
71
|
+
currency?: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Per-turn token breakdown. Sourced from `UsageUpdate._meta.usage` on
|
|
75
|
+
* adapters that populate it (Claude Code today; Codex and others may
|
|
76
|
+
* omit it). All fields optional — consumers should treat missing
|
|
77
|
+
* fields as "unknown", not "zero".
|
|
78
|
+
*/
|
|
79
|
+
type AcpRuntimeUsageBreakdown = {
|
|
80
|
+
inputTokens?: number;
|
|
81
|
+
outputTokens?: number;
|
|
82
|
+
cachedReadTokens?: number;
|
|
83
|
+
cachedWriteTokens?: number;
|
|
84
|
+
thoughtTokens?: number;
|
|
85
|
+
totalTokens?: number;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Agent-advertised slash command. The runtime only surfaces enough to
|
|
89
|
+
* drive a picker UI ("does the agent advertise /compact?"). The full
|
|
90
|
+
* `AvailableCommandInput` schema from ACP is intentionally not plumbed
|
|
91
|
+
* through.
|
|
92
|
+
*/
|
|
93
|
+
type AcpRuntimeAvailableCommand = {
|
|
94
|
+
name: string;
|
|
95
|
+
description?: string; /** True/false when ACP advertised whether this command has an input schema. */
|
|
96
|
+
hasInput?: boolean;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Session-level usage roll-up surfaced through `getStatus()`. The
|
|
100
|
+
* reducer persists the breakdowns onto the session record; this type
|
|
101
|
+
* exposes them on the runtime contract.
|
|
102
|
+
*/
|
|
103
|
+
type AcpRuntimeSessionUsage = {
|
|
104
|
+
cumulative?: AcpRuntimeUsageBreakdown; /** Cumulative session cost when the agent reported it. */
|
|
105
|
+
cost?: AcpRuntimeUsageCost; /** Keyed by user-message id, matching the persisted reducer state. */
|
|
106
|
+
perRequest?: Record<string, AcpRuntimeUsageBreakdown>;
|
|
107
|
+
};
|
|
64
108
|
type AcpRuntimeStatus = {
|
|
65
109
|
summary?: string;
|
|
66
110
|
acpxRecordId?: string;
|
|
67
111
|
backendSessionId?: string;
|
|
68
112
|
agentSessionId?: string;
|
|
69
|
-
models?: AcpRuntimeSessionModels;
|
|
113
|
+
models?: AcpRuntimeSessionModels; /** Token usage and cost from the persisted session record. */
|
|
114
|
+
usage?: AcpRuntimeSessionUsage;
|
|
115
|
+
/**
|
|
116
|
+
* Commands the agent advertised via `available_commands_update`.
|
|
117
|
+
* Sourced from the persisted record — older session files only
|
|
118
|
+
* preserve `name`, so `description` and `hasInput` may be undefined
|
|
119
|
+
* even when a more recent live event would have carried both.
|
|
120
|
+
*/
|
|
121
|
+
availableCommands?: AcpRuntimeAvailableCommand[];
|
|
70
122
|
details?: Record<string, unknown>;
|
|
71
123
|
};
|
|
72
124
|
type AcpRuntimeDoctorReport = {
|
|
@@ -86,7 +138,21 @@ type AcpRuntimeEvent = {
|
|
|
86
138
|
text: string;
|
|
87
139
|
tag?: AcpSessionUpdateTag;
|
|
88
140
|
used?: number;
|
|
89
|
-
size?: number;
|
|
141
|
+
size?: number; /** Populated on `usage_update` events when the agent reported a cost. */
|
|
142
|
+
cost?: AcpRuntimeUsageCost;
|
|
143
|
+
/**
|
|
144
|
+
* Populated on `usage_update` events when the agent attached a
|
|
145
|
+
* per-turn breakdown via `_meta.usage` (Claude Code does this; not
|
|
146
|
+
* every adapter does).
|
|
147
|
+
*/
|
|
148
|
+
breakdown?: AcpRuntimeUsageBreakdown;
|
|
149
|
+
/**
|
|
150
|
+
* Populated on `available_commands_update` events. The list is a
|
|
151
|
+
* normalized view of the wire payload — names, descriptions, and
|
|
152
|
+
* a `hasInput` flag derived from whether the agent advertised a
|
|
153
|
+
* non-null `input` schema.
|
|
154
|
+
*/
|
|
155
|
+
availableCommands?: AcpRuntimeAvailableCommand[];
|
|
90
156
|
} | {
|
|
91
157
|
type: "tool_call";
|
|
92
158
|
text: string;
|
|
@@ -396,5 +462,5 @@ declare function createRuntimeStore(options: {
|
|
|
396
462
|
stateDir: string;
|
|
397
463
|
}): AcpSessionStore;
|
|
398
464
|
//#endregion
|
|
399
|
-
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 };
|
|
465
|
+
export { ACPX_BACKEND_ID, type AcpAgentRegistry, type AcpFileSessionStoreOptions, type AcpPermissionDecision, type AcpPermissionRequest, type AcpRuntime, type AcpRuntimeAvailableCommand, type AcpRuntimeCapabilities, type AcpRuntimeDoctorReport, type AcpRuntimeEnsureInput, AcpRuntimeError, type AcpRuntimeErrorCode, type AcpRuntimeEvent, type AcpRuntimeHandle, type AcpRuntimeOptions, type AcpRuntimePromptMode, type AcpRuntimeSessionMode, type AcpRuntimeSessionModels, type AcpRuntimeSessionUsage, type AcpRuntimeStatus, type AcpRuntimeTurn, type AcpRuntimeTurnAttachment, type AcpRuntimeTurnInput, type AcpRuntimeTurnResult, type AcpRuntimeTurnResultError, type AcpRuntimeUsageBreakdown, type AcpRuntimeUsageCost, type AcpSessionRecord, type AcpSessionStore, type AcpSessionUpdateTag, AcpxRuntime, DEFAULT_AGENT_NAME, REQUESTED_MODEL_UNSUPPORTED_ERROR_CODE, REQUESTED_MODEL_UNSUPPORTED_REASONS, RequestedModelUnsupportedError, type RequestedModelUnsupportedErrorCode, type RequestedModelUnsupportedReason, type SessionAgentOptions, type SystemPromptOption, createAcpRuntime, createAgentRegistry, createFileSessionStore, createRuntimeStore, decodeAcpxRuntimeHandleState, encodeAcpxRuntimeHandleState, isAcpRuntimeError, isRequestedModelUnsupportedError };
|
|
400
466
|
//# 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":";;;;;;cAmFa,kBAAA;;;KCpED,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;EA3BgB;;;;EAgC1B,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;;AA7BmB;AAGtC;;;KAkCY,mBAAA;EACV,MAAA;EACA,QAAQ;AAAA;;;;;;;KASE,wBAAA;EACV,WAAA;EACA,YAAA;EACA,gBAAA;EACA,iBAAA;EACA,aAAA;EACA,WAAA;AAAA;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BAAA;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,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as REQUESTED_MODEL_UNSUPPORTED_ERROR_CODE, At as listBuiltInAgents, D as applyLifecycleSnapshotToRecord, E as applyConversation, F as modelStateFromConfigOptions, It as normalizeOutputError, Lt as extractAcpError, M as RequestedModelUnsupportedError, Mt as resolveAgentCommand, O as reconcileAgentSessionId, Ot as withTimeout, P as isRequestedModelUnsupportedError, Rt as isAcpResourceNotFoundError, S as advertisedModelState, T as sessionOptionsFromRecord, Z as assertPersistedKeyPolicy, _ as createSessionConversation, a as applyRequestedModelIfAdvertised, b as recordSessionUpdate, c as setCurrentModelId, d as setDesiredModelId, f as syncAdvertisedModelState, g as cloneSessionConversation, h as cloneSessionAcpxState, i as connectAndLoadSession, j as REQUESTED_MODEL_UNSUPPORTED_REASONS, k as AcpClient, kt as DEFAULT_AGENT_NAME, l as setDesiredConfigOption, m as applyConfigOptionsToState, n as runPromptTurn, o as currentModelIdFromSetModelResponse, ot as parseSessionRecord, p as applyConfigOptionsToRecord, r as withConnectedSession, s as clearDesiredConfigOption, st as serializeSessionRecordForDisk, t as LiveSessionCheckpoint, u as setDesiredModeId, ut as defaultSessionEventLog, v as recordClientOperation, w as persistSessionOptions, wt as textPrompt, x as trimConversationForRuntime, y as recordPromptSubmission } from "./live-checkpoint-BWkYxMeS.js";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import fs from "node:fs/promises";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
@@ -234,7 +234,7 @@ function readToolKind(value) {
|
|
|
234
234
|
const kind = asOptionalString(value);
|
|
235
235
|
return kind && TOOL_KINDS.has(kind) ? kind : void 0;
|
|
236
236
|
}
|
|
237
|
-
const TOOL_KINDS = new Set([
|
|
237
|
+
const TOOL_KINDS = /* @__PURE__ */ new Set([
|
|
238
238
|
"read",
|
|
239
239
|
"edit",
|
|
240
240
|
"delete",
|
|
@@ -325,7 +325,7 @@ const PROMPT_EVENT_PARSERS = {
|
|
|
325
325
|
tag: "agent_thought_chunk"
|
|
326
326
|
}),
|
|
327
327
|
usage_update: usageUpdateEvent,
|
|
328
|
-
available_commands_update:
|
|
328
|
+
available_commands_update: availableCommandsUpdateEvent,
|
|
329
329
|
current_mode_update: (payload) => statusUpdateEvent("current_mode_update", payload),
|
|
330
330
|
config_option_update: (payload) => statusUpdateEvent("config_option_update", payload),
|
|
331
331
|
session_info_update: (payload) => statusUpdateEvent("session_info_update", payload),
|
|
@@ -341,14 +341,88 @@ function promptEventParser(type) {
|
|
|
341
341
|
function usageUpdateEvent(payload) {
|
|
342
342
|
const used = asOptionalFiniteNumber(payload.used);
|
|
343
343
|
const size = asOptionalFiniteNumber(payload.size);
|
|
344
|
+
const meta = isRecord(payload._meta) ? payload._meta : void 0;
|
|
345
|
+
return buildUsageUpdateEvent({
|
|
346
|
+
used,
|
|
347
|
+
size,
|
|
348
|
+
cost: normalizeUsageCost(payload.cost),
|
|
349
|
+
breakdown: normalizeUsageBreakdown(meta?.usage)
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
function buildUsageUpdateEvent(parts) {
|
|
353
|
+
const { used, size, cost, breakdown } = parts;
|
|
344
354
|
return {
|
|
345
355
|
type: "status",
|
|
346
356
|
text: used != null && size != null ? `usage updated: ${used}/${size}` : "usage updated",
|
|
347
357
|
tag: "usage_update",
|
|
348
358
|
...used != null ? { used } : {},
|
|
349
|
-
...size != null ? { size } : {}
|
|
359
|
+
...size != null ? { size } : {},
|
|
360
|
+
...cost ? { cost } : {},
|
|
361
|
+
...breakdown ? { breakdown } : {}
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
function availableCommandsUpdateEvent(payload) {
|
|
365
|
+
const raw = Array.isArray(payload.availableCommands) ? payload.availableCommands : [];
|
|
366
|
+
const availableCommands = [];
|
|
367
|
+
for (const entry of raw) {
|
|
368
|
+
if (!isRecord(entry)) continue;
|
|
369
|
+
const name = asTrimmedString(entry.name);
|
|
370
|
+
if (!name) continue;
|
|
371
|
+
const description = asTrimmedString(entry.description);
|
|
372
|
+
availableCommands.push({
|
|
373
|
+
name,
|
|
374
|
+
...description ? { description } : {},
|
|
375
|
+
hasInput: entry.input != null
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
return {
|
|
379
|
+
type: "status",
|
|
380
|
+
text: availableCommands.length > 0 ? `available commands updated (${availableCommands.length})` : "available commands updated",
|
|
381
|
+
tag: "available_commands_update",
|
|
382
|
+
availableCommands
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
function normalizeUsageCost(value) {
|
|
386
|
+
if (!isRecord(value)) return;
|
|
387
|
+
const amount = asOptionalFiniteNumber(value.amount);
|
|
388
|
+
const currency = asTrimmedString(value.currency);
|
|
389
|
+
if (amount == null && !currency) return;
|
|
390
|
+
return {
|
|
391
|
+
...amount != null ? { amount } : {},
|
|
392
|
+
...currency ? { currency } : {}
|
|
350
393
|
};
|
|
351
394
|
}
|
|
395
|
+
const USAGE_BREAKDOWN_FIELDS = [
|
|
396
|
+
["inputTokens", ["inputTokens", "input_tokens"]],
|
|
397
|
+
["outputTokens", ["outputTokens", "output_tokens"]],
|
|
398
|
+
["cachedReadTokens", [
|
|
399
|
+
"cachedReadTokens",
|
|
400
|
+
"cacheReadInputTokens",
|
|
401
|
+
"cache_read_input_tokens"
|
|
402
|
+
]],
|
|
403
|
+
["cachedWriteTokens", [
|
|
404
|
+
"cachedWriteTokens",
|
|
405
|
+
"cacheCreationInputTokens",
|
|
406
|
+
"cache_creation_input_tokens"
|
|
407
|
+
]],
|
|
408
|
+
["thoughtTokens", ["thoughtTokens", "thought_tokens"]],
|
|
409
|
+
["totalTokens", ["totalTokens", "total_tokens"]]
|
|
410
|
+
];
|
|
411
|
+
function normalizeUsageBreakdown(value) {
|
|
412
|
+
if (!isRecord(value)) return;
|
|
413
|
+
const breakdown = {};
|
|
414
|
+
for (const [key, aliases] of USAGE_BREAKDOWN_FIELDS) {
|
|
415
|
+
const v = firstFiniteNumber(value, aliases);
|
|
416
|
+
if (v != null) breakdown[key] = v;
|
|
417
|
+
}
|
|
418
|
+
return Object.keys(breakdown).length > 0 ? breakdown : void 0;
|
|
419
|
+
}
|
|
420
|
+
function firstFiniteNumber(record, keys) {
|
|
421
|
+
for (const key of keys) {
|
|
422
|
+
const value = asOptionalFiniteNumber(record[key]);
|
|
423
|
+
if (value != null) return value;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
352
426
|
function statusUpdateEvent(tag, payload) {
|
|
353
427
|
const text = resolveStatusTextForTag({
|
|
354
428
|
tag,
|
|
@@ -540,6 +614,62 @@ function buildModelsField(record) {
|
|
|
540
614
|
availableModelIds: [...available]
|
|
541
615
|
} };
|
|
542
616
|
}
|
|
617
|
+
function tokenUsageToBreakdown(usage) {
|
|
618
|
+
if (!usage) return;
|
|
619
|
+
const breakdown = {};
|
|
620
|
+
assignUsageBreakdownField(breakdown, "inputTokens", usage.input_tokens);
|
|
621
|
+
assignUsageBreakdownField(breakdown, "outputTokens", usage.output_tokens);
|
|
622
|
+
assignUsageBreakdownField(breakdown, "cachedReadTokens", usage.cache_read_input_tokens);
|
|
623
|
+
assignUsageBreakdownField(breakdown, "cachedWriteTokens", usage.cache_creation_input_tokens);
|
|
624
|
+
assignUsageBreakdownField(breakdown, "thoughtTokens", usage.thought_tokens);
|
|
625
|
+
assignUsageBreakdownField(breakdown, "totalTokens", usage.total_tokens);
|
|
626
|
+
return Object.keys(breakdown).length > 0 ? breakdown : void 0;
|
|
627
|
+
}
|
|
628
|
+
function assignUsageBreakdownField(breakdown, key, value) {
|
|
629
|
+
if (value !== void 0) breakdown[key] = value;
|
|
630
|
+
}
|
|
631
|
+
function buildUsageField(record) {
|
|
632
|
+
const cumulative = tokenUsageToBreakdown(record.cumulative_token_usage);
|
|
633
|
+
const perRequestEntries = Object.entries(record.request_token_usage ?? {}).map(([id, value]) => [id, tokenUsageToBreakdown(value)]).filter((entry) => entry[1] !== void 0);
|
|
634
|
+
const perRequest = perRequestEntries.length > 0 ? Object.fromEntries(perRequestEntries) : void 0;
|
|
635
|
+
const cost = record.cumulative_cost;
|
|
636
|
+
const usage = {
|
|
637
|
+
...cumulative ? { cumulative } : {},
|
|
638
|
+
...cost ? { cost } : {},
|
|
639
|
+
...perRequest ? { perRequest } : {}
|
|
640
|
+
};
|
|
641
|
+
return Object.keys(usage).length > 0 ? { usage } : {};
|
|
642
|
+
}
|
|
643
|
+
function buildAvailableCommandsField(record) {
|
|
644
|
+
const commands = record.acpx?.available_commands;
|
|
645
|
+
if (!commands || commands.length === 0) return {};
|
|
646
|
+
const availableCommands = commands.map((command) => runtimeAvailableCommand(command)).filter((command) => command !== void 0);
|
|
647
|
+
return availableCommands.length > 0 ? { availableCommands } : {};
|
|
648
|
+
}
|
|
649
|
+
function runtimeAvailableCommand(command) {
|
|
650
|
+
if (typeof command === "string") {
|
|
651
|
+
const name = command.trim();
|
|
652
|
+
return name ? { name } : void 0;
|
|
653
|
+
}
|
|
654
|
+
const record = commandRecord(command);
|
|
655
|
+
if (!record) return;
|
|
656
|
+
const name = trimmedField(record.name);
|
|
657
|
+
if (!name) return;
|
|
658
|
+
const runtimeCommand = { name };
|
|
659
|
+
const description = trimmedField(record.description);
|
|
660
|
+
if (description) runtimeCommand.description = description;
|
|
661
|
+
if (typeof record.has_input === "boolean") runtimeCommand.hasInput = record.has_input;
|
|
662
|
+
return runtimeCommand;
|
|
663
|
+
}
|
|
664
|
+
function commandRecord(value) {
|
|
665
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
666
|
+
return value;
|
|
667
|
+
}
|
|
668
|
+
function trimmedField(value) {
|
|
669
|
+
if (typeof value !== "string") return;
|
|
670
|
+
const trimmed = value.trim();
|
|
671
|
+
return trimmed ? trimmed : void 0;
|
|
672
|
+
}
|
|
543
673
|
function advertisedConfigOptionIds(record) {
|
|
544
674
|
const configOptions = record.acpx?.config_options;
|
|
545
675
|
if (!configOptions) return;
|
|
@@ -554,6 +684,30 @@ function resolveSupportedConfigOptionId(record, configId) {
|
|
|
554
684
|
const supportedText = supported.length > 0 ? supported.join(", ") : "none";
|
|
555
685
|
throw new AcpRuntimeError("ACP_BACKEND_UNSUPPORTED_CONTROL", `ACP session ${record.acpxRecordId} does not advertise config option '${configId}'. Supported config options: ${supportedText}.`);
|
|
556
686
|
}
|
|
687
|
+
function applyConfigOptionResponseToTurn(turn, response) {
|
|
688
|
+
if (!response?.configOptions) return;
|
|
689
|
+
turn.acpxState = applyConfigOptionsToState(turn.acpxState, response.configOptions);
|
|
690
|
+
}
|
|
691
|
+
function applyDesiredConfigOptionToTurn(turn, configId, value) {
|
|
692
|
+
const nextState = cloneSessionAcpxState(turn.acpxState) ?? {};
|
|
693
|
+
if (configId === modelStateFromConfigOptions(nextState.config_options)?.configId) {
|
|
694
|
+
nextState.session_options = {
|
|
695
|
+
...nextState.session_options,
|
|
696
|
+
model: value
|
|
697
|
+
};
|
|
698
|
+
clearDesiredConfigOption(nextState, configId);
|
|
699
|
+
} else if (configId === "mode") nextState.desired_mode_id = value;
|
|
700
|
+
else nextState.desired_config_options = {
|
|
701
|
+
...nextState.desired_config_options,
|
|
702
|
+
[configId]: value
|
|
703
|
+
};
|
|
704
|
+
turn.acpxState = nextState;
|
|
705
|
+
}
|
|
706
|
+
function applyDesiredConfigOptionToRecord(record, configId, value) {
|
|
707
|
+
if (configId === modelStateFromConfigOptions(record.acpx?.config_options)?.configId) setDesiredModelId(record, value, configId);
|
|
708
|
+
else if (configId === "mode") setDesiredModeId(record, value);
|
|
709
|
+
else setDesiredConfigOption(record, configId, value);
|
|
710
|
+
}
|
|
557
711
|
async function createOrLoadRuntimeSession(client, resumeSessionId, cwd) {
|
|
558
712
|
if (resumeSessionId) {
|
|
559
713
|
if (client.supportsResumeSession()) {
|
|
@@ -722,7 +876,7 @@ var AcpRuntimeManager = class {
|
|
|
722
876
|
record.protocolVersion = client.initializeResult?.protocolVersion;
|
|
723
877
|
record.agentCapabilities = client.initializeResult?.agentCapabilities;
|
|
724
878
|
applyConfigOptionsToRecord(record, session.sessionResult);
|
|
725
|
-
const
|
|
879
|
+
const modelApplication = await applyRequestedModelIfAdvertised({
|
|
726
880
|
client,
|
|
727
881
|
sessionId: session.sessionId,
|
|
728
882
|
requestedModel: input.sessionOptions?.model,
|
|
@@ -730,8 +884,9 @@ var AcpRuntimeManager = class {
|
|
|
730
884
|
agentCommand,
|
|
731
885
|
timeoutMs: this.options.timeoutMs
|
|
732
886
|
});
|
|
733
|
-
|
|
734
|
-
|
|
887
|
+
applyConfigOptionsToRecord(record, modelApplication.response);
|
|
888
|
+
syncAdvertisedModelState(record, modelApplication.response ? modelStateFromConfigOptions(modelApplication.response.configOptions) : session.sessionResult.models);
|
|
889
|
+
if (modelApplication.applied) setCurrentModelId(record, currentModelIdFromSetModelResponse(modelApplication.response, input.sessionOptions?.model));
|
|
735
890
|
applyLifecycleSnapshotToRecord(record, client.getAgentLifecycleSnapshot());
|
|
736
891
|
persistSessionOptions(record, input.sessionOptions);
|
|
737
892
|
await this.options.sessionStore.save(record);
|
|
@@ -879,7 +1034,8 @@ var AcpRuntimeManager = class {
|
|
|
879
1034
|
permissionMode: this.options.permissionMode,
|
|
880
1035
|
nonInteractivePermissions: this.options.nonInteractivePermissions,
|
|
881
1036
|
onPermissionRequest: this.options.onPermissionRequest,
|
|
882
|
-
verbose: this.options.verbose
|
|
1037
|
+
verbose: this.options.verbose,
|
|
1038
|
+
sessionOptions: sessionOptionsFromRecord(record)
|
|
883
1039
|
});
|
|
884
1040
|
}
|
|
885
1041
|
createRuntimeTurnCheckpoint(record, conversation, readAcpxState) {
|
|
@@ -904,7 +1060,18 @@ var AcpRuntimeManager = class {
|
|
|
904
1060
|
},
|
|
905
1061
|
setSessionModel: async (modelId) => {
|
|
906
1062
|
await this.waitForRuntimeControlSession(task, turn);
|
|
907
|
-
|
|
1063
|
+
const models = advertisedModelState(turn.acpxState);
|
|
1064
|
+
const response = await turn.client.setSessionModel(turn.activeSessionId, modelId, models);
|
|
1065
|
+
applyConfigOptionResponseToTurn(turn, response);
|
|
1066
|
+
const nextState = cloneSessionAcpxState(turn.acpxState) ?? {};
|
|
1067
|
+
nextState.session_options = {
|
|
1068
|
+
...nextState.session_options,
|
|
1069
|
+
model: modelId
|
|
1070
|
+
};
|
|
1071
|
+
nextState.current_model_id = currentModelIdFromSetModelResponse(response, modelId);
|
|
1072
|
+
clearDesiredConfigOption(nextState, models?.configId);
|
|
1073
|
+
turn.acpxState = nextState;
|
|
1074
|
+
return response;
|
|
908
1075
|
},
|
|
909
1076
|
setSessionConfigOption: async (configId, value) => {
|
|
910
1077
|
return (await task.state.activeController.setResolvedSessionConfigOption(configId, value)).response;
|
|
@@ -936,25 +1103,8 @@ var AcpRuntimeManager = class {
|
|
|
936
1103
|
};
|
|
937
1104
|
}
|
|
938
1105
|
applyRuntimeConfigOptionState(turn, configId, value, response) {
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
nextState.config_options = structuredClone(response.configOptions);
|
|
942
|
-
turn.acpxState = nextState;
|
|
943
|
-
}
|
|
944
|
-
if (configId === "mode") {
|
|
945
|
-
const nextState = cloneSessionAcpxState(turn.acpxState) ?? {};
|
|
946
|
-
nextState.desired_mode_id = value;
|
|
947
|
-
turn.acpxState = nextState;
|
|
948
|
-
return;
|
|
949
|
-
}
|
|
950
|
-
if (configId !== "model") {
|
|
951
|
-
const nextState = cloneSessionAcpxState(turn.acpxState) ?? {};
|
|
952
|
-
nextState.desired_config_options = {
|
|
953
|
-
...nextState.desired_config_options,
|
|
954
|
-
[configId]: value
|
|
955
|
-
};
|
|
956
|
-
turn.acpxState = nextState;
|
|
957
|
-
}
|
|
1106
|
+
applyConfigOptionResponseToTurn(turn, response);
|
|
1107
|
+
applyDesiredConfigOptionToTurn(turn, configId, value);
|
|
958
1108
|
}
|
|
959
1109
|
installRuntimeTurnEventHandlers(task, turn) {
|
|
960
1110
|
turn.client.setEventHandlers({
|
|
@@ -1106,6 +1256,8 @@ var AcpRuntimeManager = class {
|
|
|
1106
1256
|
backendSessionId: record.acpSessionId,
|
|
1107
1257
|
agentSessionId: record.agentSessionId,
|
|
1108
1258
|
...buildModelsField(record),
|
|
1259
|
+
...buildUsageField(record),
|
|
1260
|
+
...buildAvailableCommandsField(record),
|
|
1109
1261
|
details: {
|
|
1110
1262
|
cwd: record.cwd,
|
|
1111
1263
|
lastUsedAt: record.lastUsedAt,
|
|
@@ -1131,16 +1283,14 @@ var AcpRuntimeManager = class {
|
|
|
1131
1283
|
if (controller) {
|
|
1132
1284
|
const { configId, response } = await controller.setResolvedSessionConfigOption(key, value);
|
|
1133
1285
|
applyConfigOptionsToRecord(record, response);
|
|
1134
|
-
|
|
1135
|
-
else setDesiredConfigOption(record, configId, value);
|
|
1286
|
+
applyDesiredConfigOptionToRecord(record, configId, value);
|
|
1136
1287
|
await this.options.sessionStore.save(record);
|
|
1137
1288
|
return;
|
|
1138
1289
|
}
|
|
1139
1290
|
const result = await this.withRuntimeControlSession(record, sessionMode, async ({ client, sessionId, record: connectedRecord }) => {
|
|
1140
1291
|
const configId = resolveSupportedConfigOptionId(connectedRecord, key);
|
|
1141
1292
|
applyConfigOptionsToRecord(connectedRecord, await client.setSessionConfigOption(sessionId, configId, value));
|
|
1142
|
-
|
|
1143
|
-
else setDesiredConfigOption(connectedRecord, configId, value);
|
|
1293
|
+
applyDesiredConfigOptionToRecord(connectedRecord, configId, value);
|
|
1144
1294
|
});
|
|
1145
1295
|
await this.options.sessionStore.save(result.record);
|
|
1146
1296
|
}
|
|
@@ -1212,13 +1362,20 @@ var FileSessionStore = class {
|
|
|
1212
1362
|
}
|
|
1213
1363
|
async load(sessionId) {
|
|
1214
1364
|
await this.ensureDir();
|
|
1365
|
+
let payload;
|
|
1215
1366
|
try {
|
|
1216
|
-
|
|
1217
|
-
return parseSessionRecord(JSON.parse(payload)) ?? void 0;
|
|
1367
|
+
payload = await fs.readFile(this.filePath(sessionId), "utf8");
|
|
1218
1368
|
} catch (error) {
|
|
1219
1369
|
if (error.code === "ENOENT") return;
|
|
1220
1370
|
throw error;
|
|
1221
1371
|
}
|
|
1372
|
+
let parsed;
|
|
1373
|
+
try {
|
|
1374
|
+
parsed = JSON.parse(payload);
|
|
1375
|
+
} catch {
|
|
1376
|
+
return;
|
|
1377
|
+
}
|
|
1378
|
+
return parseSessionRecord(parsed) ?? void 0;
|
|
1222
1379
|
}
|
|
1223
1380
|
async save(record) {
|
|
1224
1381
|
await this.ensureDir();
|
|
@@ -1545,6 +1702,6 @@ function createRuntimeStore(options) {
|
|
|
1545
1702
|
return createFileSessionStore(options);
|
|
1546
1703
|
}
|
|
1547
1704
|
//#endregion
|
|
1548
|
-
export { ACPX_BACKEND_ID, AcpRuntimeError, AcpxRuntime, DEFAULT_AGENT_NAME, createAcpRuntime, createAgentRegistry, createFileSessionStore, createRuntimeStore, decodeAcpxRuntimeHandleState, encodeAcpxRuntimeHandleState, isAcpRuntimeError };
|
|
1705
|
+
export { ACPX_BACKEND_ID, AcpRuntimeError, AcpxRuntime, DEFAULT_AGENT_NAME, REQUESTED_MODEL_UNSUPPORTED_ERROR_CODE, REQUESTED_MODEL_UNSUPPORTED_REASONS, RequestedModelUnsupportedError, createAcpRuntime, createAgentRegistry, createFileSessionStore, createRuntimeStore, decodeAcpxRuntimeHandleState, encodeAcpxRuntimeHandleState, isAcpRuntimeError, isRequestedModelUnsupportedError };
|
|
1549
1706
|
|
|
1550
1707
|
//# sourceMappingURL=runtime.js.map
|