acpx 0.13.1 → 0.13.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-_7Sei6dD.js → cli-DJT3MRRI.js} +6 -5
- package/dist/{cli-_7Sei6dD.js.map → cli-DJT3MRRI.js.map} +1 -1
- package/dist/cli.js +20 -13
- package/dist/cli.js.map +1 -1
- package/dist/{flags-Ds6FzmHG.js → flags-CM2rAdBo.js} +3 -3
- package/dist/{flags-Ds6FzmHG.js.map → flags-CM2rAdBo.js.map} +1 -1
- package/dist/{flows-fzH0GKYF.js → flows-BiRKgCnW.js} +4 -4
- package/dist/{flows-fzH0GKYF.js.map → flows-BiRKgCnW.js.map} +1 -1
- package/dist/flows.js +1 -1
- package/dist/{live-checkpoint-BSIrfgVo.js → live-checkpoint-Gw2oGjhe.js} +102 -68
- package/dist/{live-checkpoint-BSIrfgVo.js.map → live-checkpoint-Gw2oGjhe.js.map} +1 -1
- package/dist/{output-BZQE0gI1.js → output-DiPPprGk.js} +35 -118
- package/dist/output-DiPPprGk.js.map +1 -0
- package/dist/runtime.d.ts +5 -8
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +51 -104
- package/dist/runtime.js.map +1 -1
- package/package.json +15 -15
- package/skills/acpx/SKILL.md +5 -1
- package/dist/output-BZQE0gI1.js.map +0 -1
package/dist/runtime.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as SessionRecord, a as AcpElicitationHandler, c as AcpElicitationResponse, f as McpServer$1, h as PermissionPolicy, i as AcpElicitationContext, l as AcpPermissionDecision, m as PermissionMode, n as SystemPromptOption, o as AcpElicitationMode, p as NonInteractivePermissionPolicy, s as AcpElicitationRequest, t as SessionAgentOptions, u as AcpPermissionRequest } from "./session-options-DwRDODlr.js";
|
|
2
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-CxNllqui.js";
|
|
3
3
|
import fs from "node:fs";
|
|
4
|
-
import { ToolCallContent, ToolCallLocation, ToolKind } from "@agentclientprotocol/sdk";
|
|
4
|
+
import { SetSessionConfigOptionResponse, ToolCallContent, ToolCallLocation, ToolKind } from "@agentclientprotocol/sdk";
|
|
5
5
|
//#region src/agent-registry.d.ts
|
|
6
6
|
declare const DEFAULT_AGENT_NAME = "codex";
|
|
7
7
|
//#endregion
|
|
@@ -276,7 +276,7 @@ interface AcpRuntime {
|
|
|
276
276
|
handle: AcpRuntimeHandle;
|
|
277
277
|
key: string;
|
|
278
278
|
value: string;
|
|
279
|
-
}): Promise<void>;
|
|
279
|
+
}): Promise<SetSessionConfigOptionResponse | void>;
|
|
280
280
|
doctor?(): Promise<AcpRuntimeDoctorReport>;
|
|
281
281
|
cancel(input: {
|
|
282
282
|
handle: AcpRuntimeHandle;
|
|
@@ -356,7 +356,6 @@ declare class AcpRuntimeManager {
|
|
|
356
356
|
private canRetainPersistentSessionOwner;
|
|
357
357
|
private withRuntimeControlSession;
|
|
358
358
|
private refreshOwnedRecordLifecycle;
|
|
359
|
-
private finishBufferedOwnerControl;
|
|
360
359
|
ensureSession(input: RuntimeEnsureInput): Promise<SessionRecord>;
|
|
361
360
|
private withEnsureSessionLock;
|
|
362
361
|
private withManagerLock;
|
|
@@ -366,7 +365,7 @@ declare class AcpRuntimeManager {
|
|
|
366
365
|
private reuseRuntimeSession;
|
|
367
366
|
private closeConflictingPersistentSession;
|
|
368
367
|
private createOwnedRuntimeSession;
|
|
369
|
-
private
|
|
368
|
+
private prepareInitialRuntimeRecord;
|
|
370
369
|
private retainInitializedSessionOwner;
|
|
371
370
|
startTurn(input: {
|
|
372
371
|
handle: AcpRuntimeHandle;
|
|
@@ -396,10 +395,8 @@ declare class AcpRuntimeManager {
|
|
|
396
395
|
private waitForRuntimeControlSession;
|
|
397
396
|
private requestRuntimeTurnCancel;
|
|
398
397
|
private setRuntimeResolvedSessionConfigOption;
|
|
399
|
-
private applyRuntimeConfigOptionState;
|
|
400
398
|
private emitRuntimeTurnEvent;
|
|
401
399
|
private connectRuntimeTurn;
|
|
402
|
-
private drainRuntimeConnectionUpdates;
|
|
403
400
|
private connectRuntimeTurnClient;
|
|
404
401
|
private publishRuntimeTurnController;
|
|
405
402
|
private resolveRuntimeTurnReady;
|
|
@@ -427,7 +424,7 @@ declare class AcpRuntimeManager {
|
|
|
427
424
|
getStatus(handle: AcpRuntimeHandle): Promise<AcpRuntimeStatus>;
|
|
428
425
|
setMode(handle: AcpRuntimeHandle, mode: string, sessionMode?: "persistent" | "oneshot"): Promise<void>;
|
|
429
426
|
private setModeWithOwnership;
|
|
430
|
-
setConfigOption(handle: AcpRuntimeHandle, key: string, value: string, sessionMode?: "persistent" | "oneshot"): Promise<
|
|
427
|
+
setConfigOption(handle: AcpRuntimeHandle, key: string, value: string, sessionMode?: "persistent" | "oneshot"): Promise<SetSessionConfigOptionResponse>;
|
|
431
428
|
private setConfigOptionWithOwnership;
|
|
432
429
|
cancel(handle: AcpRuntimeHandle): Promise<void>;
|
|
433
430
|
close(handle: AcpRuntimeHandle, options?: {
|
|
@@ -532,7 +529,7 @@ declare class AcpxRuntime implements AcpxRuntimeLike {
|
|
|
532
529
|
handle: AcpRuntimeHandle;
|
|
533
530
|
key: string;
|
|
534
531
|
value: string;
|
|
535
|
-
}): Promise<
|
|
532
|
+
}): Promise<SetSessionConfigOptionResponse>;
|
|
536
533
|
cancel(input: {
|
|
537
534
|
handle: AcpRuntimeHandle;
|
|
538
535
|
reason?: string;
|
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":";;;;;cAkHa;;;
|
|
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":";;;;;cAkHa;;;KClFD;KAEA;KAEA;KAaA;KAEA;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA,MAAM;EACN;EACA;;;;;;;;;EASA,iBAAiB;;KAGP;;;;;EAKV;EACA;;KAGU;EACV,QAAQ;EACR;EACA,cAAc;EACd,MAAM;EACN;EACA;EACA,SAAS;;EAET,gBAAgB;;KAGN;EACV,UAAU;EACV;;KAGU;EACV;EACA;;;;;;;KAQU;EACV;EACA;;;;;;;KAQU;EACV;EACA;EACA;EACA;EACA;EACA;;;;;;;;KASU;EACV;EACA;;EAEA;;;;;;;KAQU;EACV,aAAa;;EAEb,OAAO;;EAEP,aAAa,eAAe;;KAGlB;EACV;EACA;EACA;EACA;EACA,SAAS;;EAET,QAAQ;;;;;;;EAOR,oBAAoB;EACpB,UAAU;;KAGA;EACV;EACA;EACA;EACA;EACA;;;;;;KAOU;EACV;EACA;EACA;;KAGU;EAEN;EACA;EACA;EACA,MAAM;;;;;;;;;EASN;;;;;;;;;;EAUA,OAAO;;EAGP;EACA;EACA,MAAM;EACN;EACA;;EAEA,OAAO;;;;;;EAMP,YAAY;;;;;;;EAOZ,oBAAoB;;EAGpB;EACA;EACA,MAAM;EACN;EACA;EACA;EACA,OAAO;EACP,YAAY;EACZ;EACA;EACA,UAAU;;;;;;;EAOV;EACA;;;;;;;EAOA;EACA;EACA;EACA;EACA;;KAGM;EACV;EACA;EACA;EACA;;KAGU;EAEN;EACA;;EAGA;EACA;;EAGA;EACA,OAAO;;UAGI;WACN;;WAEA,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QAAiB;IAGd,YAAA;MAAE;QAAiB;;EAMxC,QAAQ,OAAO,sBAAsB,cAAc;EAgBpD,gBAAgB;IAAU,SAAS;MAAqB,QAAQ;EAyBhE,UAAU;IACd,QAAQ;IACR,SAAS;MACP,QAAQ;EAMN,QAAQ;IAAS,QAAQ;IAAkB;MAAiB;EAM5D,gBAAgB;IACpB,QAAQ;IACR;IACA;MACE,QAAQ;EAMN,OAAO;IAAS,QAAQ;IAAkB;MAAoB;EAM9D,MAAM;IACV,QAAQ;IACR;IACA;MACE;UAQU;UAeA;UAIN;UAcA;;iBA+BM,iBAAiB,SAAS,oBAAoB;iBAI9C,mBAAmB;EAAW;IAAqB"}
|
package/dist/runtime.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as RequestedModelUnsupportedError, At as DEFAULT_AGENT_NAME, Bt as extractAcpError, C as sessionOptionsFromRecord, D as AcpClient, E as reconcileAgentSessionId, Ft as resolveCanonicalAgentName, M as modelStateFromConfigOptions, Mt as normalizeAgentName, N as normalizeAgentCommandInput, Nt as resolveAgentArgv, O as REQUESTED_MODEL_UNSUPPORTED_ERROR_CODE, Pt as resolveAgentCommand, Q as assertPersistedKeyPolicy, S as persistSessionOptions, T as applyLifecycleSnapshotToRecord, Tt as textPrompt, Vt as isAcpResourceNotFoundError, Z as createAtomicWriteTempPath, _ as recordPromptSubmission, a as applyConfigOptionSelection, b as advertisedModelState, c as applyRequestedModelIfAdvertised, ct as serializeSessionRecordForDisk, d as setDesiredModeId, dt as defaultSessionEventLog, f as syncAdvertisedModelState, g as recordClientOperation, h as createSessionConversation, i as connectAndLoadSession, j as isRequestedModelUnsupportedError, jt as listBuiltInAgents, k as REQUESTED_MODEL_UNSUPPORTED_REASONS, kt as withTimeout, l as currentModelIdFromSetModelResponse, m as cloneSessionConversation, n as runPromptTurn, o as applyConfigOptionsToRecord, p as cloneSessionAcpxState, r as withConnectedSession, s as applyModelSelection, st as parseSessionRecord, t as LiveSessionCheckpoint, u as setCurrentModelId, v as recordSessionUpdate, w as applyConversation, y as trimConversationForRuntime, zt as normalizeOutputError } from "./live-checkpoint-Gw2oGjhe.js";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import fs from "node:fs/promises";
|
|
4
4
|
import { randomUUID } from "node:crypto";
|
|
@@ -221,7 +221,7 @@ function summarizeToolInput(rawInput) {
|
|
|
221
221
|
}
|
|
222
222
|
function truncateToolSummary(value) {
|
|
223
223
|
if (value.length <= TOOL_OUTPUT_SUMMARY_MAX_CHARS) return value;
|
|
224
|
-
return `${value.slice(0,
|
|
224
|
+
return `${value.slice(0, 499)}…`;
|
|
225
225
|
}
|
|
226
226
|
function readToolContentText(value) {
|
|
227
227
|
const record = isRecord(value) ? value : void 0;
|
|
@@ -749,30 +749,6 @@ function resolveSupportedConfigOptionId(record, configId) {
|
|
|
749
749
|
const supportedText = supported.length > 0 ? supported.join(", ") : "none";
|
|
750
750
|
throw new AcpRuntimeError("ACP_BACKEND_UNSUPPORTED_CONTROL", `ACP session ${record.acpxRecordId} does not advertise config option '${configId}'. Supported config options: ${supportedText}.`);
|
|
751
751
|
}
|
|
752
|
-
function applyConfigOptionResponseToTurn(turn, response) {
|
|
753
|
-
if (!response?.configOptions) return;
|
|
754
|
-
turn.acpxState = applyConfigOptionsToState(turn.acpxState, response.configOptions);
|
|
755
|
-
}
|
|
756
|
-
function applyDesiredConfigOptionToTurn(turn, configId, value) {
|
|
757
|
-
const nextState = cloneSessionAcpxState(turn.acpxState) ?? {};
|
|
758
|
-
if (configId === modelStateFromConfigOptions(nextState.config_options)?.configId) {
|
|
759
|
-
nextState.session_options = {
|
|
760
|
-
...nextState.session_options,
|
|
761
|
-
model: value
|
|
762
|
-
};
|
|
763
|
-
clearDesiredConfigOption(nextState, configId);
|
|
764
|
-
} else if (configId === "mode") nextState.desired_mode_id = value;
|
|
765
|
-
else nextState.desired_config_options = {
|
|
766
|
-
...nextState.desired_config_options,
|
|
767
|
-
[configId]: value
|
|
768
|
-
};
|
|
769
|
-
turn.acpxState = nextState;
|
|
770
|
-
}
|
|
771
|
-
function applyDesiredConfigOptionToRecord(record, configId, value) {
|
|
772
|
-
if (configId === modelStateFromConfigOptions(record.acpx?.config_options)?.configId) setDesiredModelId(record, value, configId);
|
|
773
|
-
else if (configId === "mode") setDesiredModeId(record, value);
|
|
774
|
-
else setDesiredConfigOption(record, configId, value);
|
|
775
|
-
}
|
|
776
752
|
async function createOrLoadRuntimeSession(client, resumeSessionId, cwd) {
|
|
777
753
|
if (resumeSessionId) {
|
|
778
754
|
if (client.supportsResumeSession()) {
|
|
@@ -830,18 +806,11 @@ var AcpRuntimeManager = class {
|
|
|
830
806
|
const active = owner.activeTurn;
|
|
831
807
|
if (active) {
|
|
832
808
|
const { task, turn } = active;
|
|
833
|
-
if (turn.
|
|
834
|
-
turn.
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
method: "session/update",
|
|
838
|
-
params: notification
|
|
839
|
-
});
|
|
840
|
-
return;
|
|
841
|
-
}
|
|
842
|
-
turn.acpxState = recordSessionUpdate(turn.conversation, turn.acpxState, notification);
|
|
809
|
+
if (turn.connected) {
|
|
810
|
+
turn.acpxState = recordSessionUpdate(turn.conversation, turn.acpxState, notification);
|
|
811
|
+
turn.liveCheckpoint.request();
|
|
812
|
+
} else turn.record.acpx = recordSessionUpdate(turn.conversation, turn.record.acpx, notification);
|
|
843
813
|
trimConversationForRuntime(turn.conversation);
|
|
844
|
-
turn.liveCheckpoint.request();
|
|
845
814
|
this.emitRuntimeTurnEvent(task, {
|
|
846
815
|
jsonrpc: "2.0",
|
|
847
816
|
method: "session/update",
|
|
@@ -858,7 +827,7 @@ var AcpRuntimeManager = class {
|
|
|
858
827
|
owner.pendingSessionUpdates.push(notification);
|
|
859
828
|
return;
|
|
860
829
|
}
|
|
861
|
-
projection.
|
|
830
|
+
projection.record.acpx = recordSessionUpdate(projection.conversation, projection.record.acpx, notification);
|
|
862
831
|
trimConversationForRuntime(projection.conversation);
|
|
863
832
|
projection.checkpoint.request();
|
|
864
833
|
}
|
|
@@ -866,30 +835,30 @@ var AcpRuntimeManager = class {
|
|
|
866
835
|
const active = owner.activeTurn;
|
|
867
836
|
if (!active) return;
|
|
868
837
|
const { task, turn } = active;
|
|
869
|
-
|
|
838
|
+
if (turn.connected) {
|
|
839
|
+
turn.acpxState = recordClientOperation(turn.conversation, turn.acpxState, operation);
|
|
840
|
+
turn.liveCheckpoint.request();
|
|
841
|
+
} else turn.record.acpx = recordClientOperation(turn.conversation, turn.record.acpx, operation);
|
|
870
842
|
trimConversationForRuntime(turn.conversation);
|
|
871
|
-
turn.liveCheckpoint.request();
|
|
872
843
|
this.emitRuntimeTurnEvent(task, {
|
|
873
844
|
type: "client_operation",
|
|
874
845
|
...operation
|
|
875
846
|
});
|
|
876
847
|
}
|
|
877
|
-
attachIdleProjection(owner, record, conversation = cloneSessionConversation(record), acpxState =
|
|
878
|
-
|
|
879
|
-
projection = {
|
|
848
|
+
attachIdleProjection(owner, record, conversation = cloneSessionConversation(record), acpxState = record.acpx) {
|
|
849
|
+
record.acpx = acpxState;
|
|
850
|
+
owner.projection = {
|
|
880
851
|
record,
|
|
881
852
|
conversation,
|
|
882
|
-
acpxState,
|
|
883
853
|
checkpoint: new LiveSessionCheckpoint({ save: async () => {
|
|
854
|
+
if (!owner.recordId) return;
|
|
884
855
|
record.lastUsedAt = isoNow();
|
|
885
|
-
record
|
|
886
|
-
applyConversation(record, projection.conversation);
|
|
856
|
+
applyConversation(record, conversation);
|
|
887
857
|
applyLifecycleSnapshotToRecord(record, owner.client.getAgentLifecycleSnapshot());
|
|
888
858
|
await this.refreshClosedState(record);
|
|
889
859
|
await this.options.sessionStore.save(record);
|
|
890
860
|
} })
|
|
891
861
|
};
|
|
892
|
-
owner.projection = projection;
|
|
893
862
|
owner.activeTurn = void 0;
|
|
894
863
|
this.drainPendingSessionUpdates(owner);
|
|
895
864
|
}
|
|
@@ -961,11 +930,10 @@ var AcpRuntimeManager = class {
|
|
|
961
930
|
canRetainPersistentSessionOwner(owner, record) {
|
|
962
931
|
return owner.mode === "persistent" && !record.closed && !(owner.client.hasUnresolvedPrompt?.() ?? false) && owner.client.hasReusableSession(record.acpSessionId);
|
|
963
932
|
}
|
|
964
|
-
async withRuntimeControlSession(record, sessionMode, run) {
|
|
933
|
+
async withRuntimeControlSession(record, sessionMode, run, replacingConfigOption) {
|
|
965
934
|
const owner = await this.readRetainedSessionOwner(record, { consume: false });
|
|
966
935
|
if (owner) {
|
|
967
936
|
const ownedRecord = owner.projection?.record ?? record;
|
|
968
|
-
owner.bufferSessionUpdates = true;
|
|
969
937
|
try {
|
|
970
938
|
const value = await run({
|
|
971
939
|
client: owner.client,
|
|
@@ -978,7 +946,7 @@ var AcpRuntimeManager = class {
|
|
|
978
946
|
record: ownedRecord
|
|
979
947
|
};
|
|
980
948
|
} finally {
|
|
981
|
-
await this.
|
|
949
|
+
await this.flushSessionOwner(owner);
|
|
982
950
|
}
|
|
983
951
|
}
|
|
984
952
|
const result = await withConnectedSession({
|
|
@@ -995,6 +963,7 @@ var AcpRuntimeManager = class {
|
|
|
995
963
|
verbose: this.options.verbose,
|
|
996
964
|
timeoutMs: this.options.timeoutMs,
|
|
997
965
|
resumePolicy: resumePolicyForSessionMode(sessionMode),
|
|
966
|
+
replacingConfigOption,
|
|
998
967
|
run
|
|
999
968
|
});
|
|
1000
969
|
return {
|
|
@@ -1010,17 +979,6 @@ var AcpRuntimeManager = class {
|
|
|
1010
979
|
record.agentCapabilities = owner.client.initializeResult?.agentCapabilities;
|
|
1011
980
|
applyLifecycleSnapshotToRecord(record, owner.client.getAgentLifecycleSnapshot());
|
|
1012
981
|
}
|
|
1013
|
-
async finishBufferedOwnerControl(owner, record) {
|
|
1014
|
-
const projection = owner.projection;
|
|
1015
|
-
if (projection) projection.acpxState = cloneSessionAcpxState(record.acpx);
|
|
1016
|
-
owner.bufferSessionUpdates = false;
|
|
1017
|
-
this.drainPendingSessionUpdates(owner);
|
|
1018
|
-
if (projection) {
|
|
1019
|
-
record.acpx = projection.acpxState;
|
|
1020
|
-
applyConversation(record, projection.conversation);
|
|
1021
|
-
await projection.checkpoint.flush();
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
982
|
async ensureSession(input) {
|
|
1025
983
|
return await this.withEnsureSessionLock(input, async () => this.ensureSessionWithOwnership(input));
|
|
1026
984
|
}
|
|
@@ -1116,27 +1074,28 @@ var AcpRuntimeManager = class {
|
|
|
1116
1074
|
try {
|
|
1117
1075
|
await client.start();
|
|
1118
1076
|
const session = await createOrLoadRuntimeSession(client, input.resumeSessionId, cwd);
|
|
1119
|
-
const record = await this.
|
|
1077
|
+
const record = await this.prepareInitialRuntimeRecord({
|
|
1120
1078
|
input,
|
|
1121
1079
|
client,
|
|
1080
|
+
owner,
|
|
1122
1081
|
agentCommand,
|
|
1123
1082
|
agentArgv,
|
|
1124
1083
|
cwd,
|
|
1125
1084
|
session
|
|
1126
1085
|
});
|
|
1127
|
-
this.attachIdleProjection(owner, record);
|
|
1128
1086
|
await this.retainInitializedSessionOwner(owner, record);
|
|
1129
1087
|
retained = true;
|
|
1130
1088
|
return record;
|
|
1131
1089
|
} finally {
|
|
1132
1090
|
if (!retained) {
|
|
1091
|
+
owner.recordId = void 0;
|
|
1133
1092
|
client.clearEventHandlers();
|
|
1134
1093
|
await client.close();
|
|
1135
1094
|
}
|
|
1136
1095
|
}
|
|
1137
1096
|
}
|
|
1138
|
-
async
|
|
1139
|
-
const { input, client, agentCommand, agentArgv, cwd, session } = params;
|
|
1097
|
+
async prepareInitialRuntimeRecord(params) {
|
|
1098
|
+
const { input, client, owner, agentCommand, agentArgv, cwd, session } = params;
|
|
1140
1099
|
const record = createInitialRecord({
|
|
1141
1100
|
recordId: createRecordId(input.sessionKey, input.mode),
|
|
1142
1101
|
sessionName: input.sessionKey,
|
|
@@ -1149,6 +1108,7 @@ var AcpRuntimeManager = class {
|
|
|
1149
1108
|
this.closingActiveRecords.delete(record.acpxRecordId);
|
|
1150
1109
|
record.protocolVersion = client.initializeResult?.protocolVersion;
|
|
1151
1110
|
record.agentCapabilities = client.initializeResult?.agentCapabilities;
|
|
1111
|
+
this.attachIdleProjection(owner, record);
|
|
1152
1112
|
applyConfigOptionsToRecord(record, session.sessionResult);
|
|
1153
1113
|
const modelApplication = await applyRequestedModelIfAdvertised({
|
|
1154
1114
|
client,
|
|
@@ -1163,11 +1123,11 @@ var AcpRuntimeManager = class {
|
|
|
1163
1123
|
if (modelApplication.applied) setCurrentModelId(record, currentModelIdFromSetModelResponse(modelApplication.response, input.sessionOptions?.model));
|
|
1164
1124
|
applyLifecycleSnapshotToRecord(record, client.getAgentLifecycleSnapshot());
|
|
1165
1125
|
persistSessionOptions(record, input.sessionOptions);
|
|
1166
|
-
await this.options.sessionStore.save(record);
|
|
1167
1126
|
return record;
|
|
1168
1127
|
}
|
|
1169
1128
|
async retainInitializedSessionOwner(owner, record) {
|
|
1170
1129
|
owner.recordId = record.acpxRecordId;
|
|
1130
|
+
await owner.projection?.checkpoint.checkpoint();
|
|
1171
1131
|
const previousOwner = this.retainedSessionOwners.get(record.acpxRecordId);
|
|
1172
1132
|
this.retainedSessionOwners.set(record.acpxRecordId, owner);
|
|
1173
1133
|
if (owner.mode === "oneshot") this.pendingOneShotRecordIds.set(owner.sessionKey, record.acpxRecordId);
|
|
@@ -1326,7 +1286,7 @@ var AcpRuntimeManager = class {
|
|
|
1326
1286
|
acpxState,
|
|
1327
1287
|
client,
|
|
1328
1288
|
owner,
|
|
1329
|
-
|
|
1289
|
+
connected: retainedOwner !== void 0,
|
|
1330
1290
|
promptMessageId
|
|
1331
1291
|
});
|
|
1332
1292
|
this.activateRuntimeTurn(task, turn);
|
|
@@ -1387,7 +1347,7 @@ var AcpRuntimeManager = class {
|
|
|
1387
1347
|
});
|
|
1388
1348
|
}
|
|
1389
1349
|
createRunningRuntimeTurn(input) {
|
|
1390
|
-
const { record, conversation, acpxState, client, owner,
|
|
1350
|
+
const { record, conversation, acpxState, client, owner, connected, promptMessageId } = input;
|
|
1391
1351
|
const turn = {
|
|
1392
1352
|
record,
|
|
1393
1353
|
conversation,
|
|
@@ -1395,8 +1355,7 @@ var AcpRuntimeManager = class {
|
|
|
1395
1355
|
liveCheckpoint: this.createRuntimeTurnCheckpoint(record, conversation, () => turn.acpxState),
|
|
1396
1356
|
client,
|
|
1397
1357
|
owner,
|
|
1398
|
-
|
|
1399
|
-
connectionUpdates: pendingClient ? void 0 : [],
|
|
1358
|
+
connected,
|
|
1400
1359
|
promptMessageId,
|
|
1401
1360
|
activeSessionId: record.acpSessionId
|
|
1402
1361
|
};
|
|
@@ -1455,15 +1414,7 @@ var AcpRuntimeManager = class {
|
|
|
1455
1414
|
await this.waitForRuntimeControlSession(task, turn);
|
|
1456
1415
|
const models = advertisedModelState(turn.acpxState);
|
|
1457
1416
|
const response = await turn.client.setSessionModel(turn.activeSessionId, modelId, models);
|
|
1458
|
-
|
|
1459
|
-
const nextState = cloneSessionAcpxState(turn.acpxState) ?? {};
|
|
1460
|
-
nextState.session_options = {
|
|
1461
|
-
...nextState.session_options,
|
|
1462
|
-
model: modelId
|
|
1463
|
-
};
|
|
1464
|
-
nextState.current_model_id = currentModelIdFromSetModelResponse(response, modelId);
|
|
1465
|
-
clearDesiredConfigOption(nextState, models?.configId);
|
|
1466
|
-
turn.acpxState = nextState;
|
|
1417
|
+
turn.acpxState = applyModelSelection(turn.acpxState, modelId, response);
|
|
1467
1418
|
return response;
|
|
1468
1419
|
},
|
|
1469
1420
|
setSessionConfigOption: async (configId, value) => {
|
|
@@ -1488,38 +1439,29 @@ var AcpRuntimeManager = class {
|
|
|
1488
1439
|
...turn.record,
|
|
1489
1440
|
acpx: turn.acpxState ?? void 0
|
|
1490
1441
|
}, configId);
|
|
1442
|
+
const modelConfigId = advertisedModelState(turn.acpxState)?.configId;
|
|
1491
1443
|
const response = await turn.client.setSessionConfigOption(turn.activeSessionId, resolvedConfigId, value);
|
|
1492
|
-
|
|
1444
|
+
turn.acpxState = applyConfigOptionSelection(turn.acpxState, resolvedConfigId, value, response, modelConfigId);
|
|
1493
1445
|
return {
|
|
1494
1446
|
configId: resolvedConfigId,
|
|
1495
1447
|
response
|
|
1496
1448
|
};
|
|
1497
1449
|
}
|
|
1498
|
-
applyRuntimeConfigOptionState(turn, configId, value, response) {
|
|
1499
|
-
applyConfigOptionResponseToTurn(turn, response);
|
|
1500
|
-
applyDesiredConfigOptionToTurn(turn, configId, value);
|
|
1501
|
-
}
|
|
1502
1450
|
emitRuntimeTurnEvent(task, payload) {
|
|
1503
1451
|
const parsed = parsePromptEventLine(JSON.stringify(payload));
|
|
1504
1452
|
if (!parsed) return;
|
|
1505
1453
|
task.queue.push(parsed);
|
|
1506
1454
|
}
|
|
1507
1455
|
async connectRuntimeTurn(task, turn) {
|
|
1508
|
-
|
|
1456
|
+
if (turn.connected) return {
|
|
1509
1457
|
sessionId: turn.record.acpSessionId,
|
|
1510
1458
|
resumed: false,
|
|
1511
1459
|
loadError: void 0
|
|
1512
|
-
}
|
|
1513
|
-
this.
|
|
1514
|
-
return loaded;
|
|
1515
|
-
}
|
|
1516
|
-
drainRuntimeConnectionUpdates(turn) {
|
|
1517
|
-
if (!turn.connectionUpdates) return;
|
|
1460
|
+
};
|
|
1461
|
+
const loaded = await this.connectRuntimeTurnClient(task, turn);
|
|
1518
1462
|
turn.acpxState = cloneSessionAcpxState(turn.record.acpx);
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
trimConversationForRuntime(turn.conversation);
|
|
1522
|
-
turn.liveCheckpoint.request();
|
|
1463
|
+
turn.connected = true;
|
|
1464
|
+
return loaded;
|
|
1523
1465
|
}
|
|
1524
1466
|
async connectRuntimeTurnClient(task, turn) {
|
|
1525
1467
|
return await connectAndLoadSession({
|
|
@@ -1629,7 +1571,7 @@ var AcpRuntimeManager = class {
|
|
|
1629
1571
|
task.queue.close();
|
|
1630
1572
|
}
|
|
1631
1573
|
async finalizeRuntimeTurnRecord(turn) {
|
|
1632
|
-
|
|
1574
|
+
if (!turn.connected) turn.acpxState = cloneSessionAcpxState(turn.record.acpx);
|
|
1633
1575
|
applyLifecycleSnapshotToRecord(turn.record, turn.client.getAgentLifecycleSnapshot());
|
|
1634
1576
|
turn.record.acpx = turn.acpxState;
|
|
1635
1577
|
applyConversation(turn.record, turn.conversation);
|
|
@@ -1637,7 +1579,7 @@ var AcpRuntimeManager = class {
|
|
|
1637
1579
|
await turn.liveCheckpoint.flush();
|
|
1638
1580
|
const closed = await this.refreshClosedState(turn.record);
|
|
1639
1581
|
await this.options.sessionStore.save(turn.record);
|
|
1640
|
-
if (closed) return false;
|
|
1582
|
+
if (closed || !turn.connected) return false;
|
|
1641
1583
|
return await this.retainPersistentSessionOwnerAfterTurn({
|
|
1642
1584
|
record: turn.record,
|
|
1643
1585
|
owner: turn.owner,
|
|
@@ -1688,24 +1630,29 @@ var AcpRuntimeManager = class {
|
|
|
1688
1630
|
}
|
|
1689
1631
|
async setConfigOption(handle, key, value, sessionMode = "persistent") {
|
|
1690
1632
|
const recordId = handle.acpxRecordId ?? handle.sessionKey;
|
|
1691
|
-
await this.withManagerLock(this.runtimeOperationLocks, recordId, async () => this.setConfigOptionWithOwnership(handle, key, value, sessionMode));
|
|
1633
|
+
return await this.withManagerLock(this.runtimeOperationLocks, recordId, async () => this.setConfigOptionWithOwnership(handle, key, value, sessionMode));
|
|
1692
1634
|
}
|
|
1693
1635
|
async setConfigOptionWithOwnership(handle, key, value, sessionMode) {
|
|
1694
1636
|
const record = await this.requireRecord(handle.acpxRecordId ?? handle.sessionKey);
|
|
1695
1637
|
const controller = this.activeControllers.get(record.acpxRecordId);
|
|
1696
1638
|
if (controller) {
|
|
1697
1639
|
const { configId, response } = await controller.setResolvedSessionConfigOption(key, value);
|
|
1698
|
-
|
|
1699
|
-
applyDesiredConfigOptionToRecord(record, configId, value);
|
|
1640
|
+
record.acpx = applyConfigOptionSelection(record.acpx, configId, value, response);
|
|
1700
1641
|
await this.options.sessionStore.save(record);
|
|
1701
|
-
return;
|
|
1642
|
+
return response;
|
|
1702
1643
|
}
|
|
1703
1644
|
const result = await this.withRuntimeControlSession(record, sessionMode, async ({ client, sessionId, record: connectedRecord }) => {
|
|
1704
1645
|
const configId = resolveSupportedConfigOptionId(connectedRecord, key);
|
|
1705
|
-
|
|
1706
|
-
|
|
1646
|
+
const modelConfigId = advertisedModelState(connectedRecord.acpx)?.configId;
|
|
1647
|
+
const response = await client.setSessionConfigOption(sessionId, configId, value);
|
|
1648
|
+
connectedRecord.acpx = applyConfigOptionSelection(connectedRecord.acpx, configId, value, response, modelConfigId);
|
|
1649
|
+
return response;
|
|
1650
|
+
}, {
|
|
1651
|
+
key,
|
|
1652
|
+
resolve: (connectedRecord) => resolveSupportedConfigOptionId(connectedRecord, key)
|
|
1707
1653
|
});
|
|
1708
1654
|
await this.options.sessionStore.save(result.record);
|
|
1655
|
+
return result.value;
|
|
1709
1656
|
}
|
|
1710
1657
|
async cancel(handle) {
|
|
1711
1658
|
await this.activeControllers.get(handle.acpxRecordId ?? handle.sessionKey)?.requestCancelActivePrompt();
|
|
@@ -2117,7 +2064,7 @@ var AcpxRuntime = class {
|
|
|
2117
2064
|
}
|
|
2118
2065
|
async setConfigOption(input) {
|
|
2119
2066
|
const { handle, state } = this.resolveManagerHandle(input.handle);
|
|
2120
|
-
await (await this.getManager()).setConfigOption(handle, input.key, input.value, state.mode);
|
|
2067
|
+
return await (await this.getManager()).setConfigOption(handle, input.key, input.value, state.mode);
|
|
2121
2068
|
}
|
|
2122
2069
|
async cancel(input) {
|
|
2123
2070
|
const { handle } = this.resolveManagerHandle(input.handle);
|