@markusylisiurunen/tau 0.3.60 → 0.3.62
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/core/config/schema.js.map +1 -1
- package/dist/core/diff_review/bridge.js +1 -0
- package/dist/core/diff_review/bridge.js.map +1 -1
- package/dist/core/diff_review/protocol.js +4 -2
- package/dist/core/diff_review/protocol.js.map +1 -1
- package/dist/core/diff_review/review_instructions.js +2 -1
- package/dist/core/diff_review/review_instructions.js.map +1 -1
- package/dist/core/diff_review/tool.js +1 -1
- package/dist/core/diff_review/tool.js.map +1 -1
- package/dist/core/session/compaction.js +8 -7
- package/dist/core/session/compaction.js.map +1 -1
- package/dist/core/static/tau_docs/configuration.md +1 -1
- package/dist/core/static/tau_docs/index.md +1 -0
- package/dist/core/static/tau_docs/manifest.json +1 -0
- package/dist/core/static/tau_docs/node-sdk.md +8 -0
- package/dist/core/static/tau_docs/sdk-diff-review.md +79 -0
- package/dist/core/static/tau_docs/session-protocol-methods.md +4 -2
- package/dist/core/static/tau_docs/telegram.md +21 -22
- package/dist/core/static/tau_docs/troubleshooting.md +1 -1
- package/dist/core/static/tau_docs/tui.md +2 -0
- package/dist/core/telegram/config.js +20 -2
- package/dist/core/telegram/config.js.map +1 -1
- package/dist/core/telegram/workspace.js +3 -39
- package/dist/core/telegram/workspace.js.map +1 -1
- package/dist/core/version.js +1 -1
- package/dist/diff_tool/app/dist/assets/{angular-html-DoxI_och.js → angular-html-CNdMT1sj.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{angular-ts-C7CUd-D2.js → angular-ts-ByZ1I9zp.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{apl-7dieYM-l.js → apl-DTw4IZcL.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{astro-Czj3O4jM.js → astro-Cuihy-h6.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{blade-ClS0E2cC.js → blade-BRcWKIxm.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{c-BKvTh-Jt.js → c-CZrnSPrO.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{chapel-qvFrfwEr.js → chapel-BJWGSECM.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{cobol-B0vsaB-J.js → cobol-BtqNzZtm.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{coffee-BUlcrU75.js → coffee-DV53y0PJ.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{cpp-CKqEgX1l.js → cpp-Bn3c6Y8W.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{crystal-FCqSmIJ_.js → crystal-4DKOWvUP.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{css-zZvYFJFc.js → css-DRAuUHHc.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{edge-BKlbCo1f.js → edge-CvBIkt32.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{elixir-B2gSxtgZ.js → elixir-WxLR57iz.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{elm-DFEdzPJz.js → elm-C8UfKkLs.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{erb-DSgn8fHS.js → erb-DDaRKv4Z.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{git-rebase-CcgDECQr.js → git-rebase-BfBjC640.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{glimmer-js-Dwxi4cX2.js → glimmer-js-5QdPyQJP.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{glimmer-ts-BnJVER8W.js → glimmer-ts-Te0TMSCC.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{glsl-z7_gU-HN.js → glsl-D4tyKssQ.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{graphql-Dt7V-d3L.js → graphql-J0IcMfkN.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{hack-jVkr6EC8.js → hack-BcEFuXu_.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{haml-BF7cRiOF.js → haml-SbspNdjx.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{handlebars-DAhNxR3E.js → handlebars-DH3a4U2h.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{html-B7QW5YvU.js → html-CBno8dbY.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{html-derivative-B-vyaE-N.js → html-derivative-COFLhWU9.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{http-Drkl04RP.js → http-2GnhhV3-.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{hurl-7gTFrvcN.js → hurl-BIPzVQmD.js} +1 -1
- package/dist/diff_tool/app/dist/assets/index-Cb0TCxCI.js +1550 -0
- package/dist/diff_tool/app/dist/assets/index-esno8y5b.css +1 -0
- package/dist/diff_tool/app/dist/assets/{java-ZmvXuvs3.js → java-bZo_LLEv.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{javascript-C-OECu_Z.js → javascript-7XNFOfdJ.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{jinja-hvkV87CG.js → jinja-Yuf1yufJ.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{jison-eJBDxKI8.js → jison-DD2vLLcq.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{json-BPQU2w0u.js → json-CVOsPviK.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{jsx-C19s5MOj.js → jsx-BYrWYIX0.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{julia-CYISvCwi.js → julia-BZ_A4I5C.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{just-5omBg5pB.js → just-D8W5QT1p.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{latex-B_L85F2z.js → latex-BSsqyYVM.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{liquid-BxbaQPPS.js → liquid-CD5oivgr.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{lua-DQA0z-44.js → lua-BnXOnOdP.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{marko-Dj5RV8IH.js → marko-CjeqsSvM.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{mdc-CoHI6VJN.js → mdc-Bk-o_FzD.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{nginx-COnrY-gb.js → nginx-CU9exOaI.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{nim-Ccfp0p1j.js → nim-C4eS-_Qo.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{org-RForNsWm.js → org-gZKEwUlv.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{perl-DhHRsiUu.js → perl-d_jthyH-.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{php-BlxKhJek.js → php-Cldhvias.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{pug-o9YxnGzH.js → pug-1Im3v9J7.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{qml-Dzf494vL.js → qml-Bugdf4FS.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{r-Dp0OUrF6.js → r-DNz8aXhA.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{razor-gylahu-m.js → razor-CyO91A7-.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{regexp-C0rsDjCm.js → regexp-7IVcp_0b.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{rst-D-DRAFtq.js → rst-CPC6Rcsf.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{ruby-BnY40vXq.js → ruby-CIw26EG-.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{sas-BaSo_s7i.js → sas-CXXipNue.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{scss-BX5R-Yyw.js → scss-Cb8mUz_m.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{shellscript-CpRFVBRj.js → shellscript-8Dfk6ni5.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{shellsession-BGRUDtms.js → shellsession-BBb6xY52.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{soy-C2WL9FSb.js → soy-_rneSfGo.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{sql-CGmNnOfz.js → sql-CmdLYztO.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{stata-CDamV3Uz.js → stata-DmJpPQHj.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{surrealql-BqI4o6tP.js → surrealql-D1R_-CBd.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{svelte-DPaOUioa.js → svelte-CKPrzNdA.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{templ-aqrZIEoc.js → templ-C0Eqag1M.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{tex-Bjjtfacp.js → tex-IrZiFLxJ.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{ts-tags-BGFnsvdQ.js → ts-tags-09-sH-my.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{tsx-C_rOxPqZ.js → tsx-CSPybM8Z.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{twig-DYqVwCOf.js → twig-C17vnjiX.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{typescript-CppQYc7K.js → typescript-CvHNDrui.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{typst-KIbA0FZG.js → typst-Ct_9rHAw.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{vue-iOYoJEJi.js → vue-A0j7pYML.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{vue-html-DcZpMui9.js → vue-html-DiVQf4vL.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{vue-vine-C6v6c0Lr.js → vue-vine-CBf6VIg0.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{xml-zR0RltJO.js → xml-BvQnnFTL.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{xsl-B9pBLsIV.js → xsl-Dj-x_YCW.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{yaml-sicIihvu.js → yaml-D6eQJHya.js} +1 -1
- package/dist/diff_tool/app/dist/index.html +2 -2
- package/dist/diff_tool/http_server.js +335 -56
- package/dist/diff_tool/http_server.js.map +1 -1
- package/dist/diff_tool/index.js.map +1 -1
- package/dist/diff_tool/review_prompts.js +168 -28
- package/dist/diff_tool/review_prompts.js.map +1 -1
- package/dist/diff_tool/review_state.js +213 -69
- package/dist/diff_tool/review_state.js.map +1 -1
- package/dist/diff_tool/review_state_persistence.js +282 -0
- package/dist/diff_tool/review_state_persistence.js.map +1 -0
- package/dist/diff_tool/shared_types.js +12 -0
- package/dist/diff_tool/shared_types.js.map +1 -1
- package/dist/host/hosted_ephemeral_agent_session.js +14 -2
- package/dist/host/hosted_ephemeral_agent_session.js.map +1 -1
- package/dist/host/local_session_host.js +67 -59
- package/dist/host/local_session_host.js.map +1 -1
- package/dist/host/session_protocol_handler.js +2 -0
- package/dist/host/session_protocol_handler.js.map +1 -1
- package/dist/protocol/session_protocol.d.ts +2 -0
- package/dist/protocol/session_protocol.js +9 -2
- package/dist/protocol/session_protocol.js.map +1 -1
- package/dist/sdk/diff_review.d.ts +40 -0
- package/dist/sdk/diff_review.js +112 -0
- package/dist/sdk/diff_review.js.map +1 -0
- package/dist/sdk/index.d.ts +2 -1
- package/dist/sdk/index.js +1 -0
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/session.js +2 -0
- package/dist/sdk/session.js.map +1 -1
- package/dist/sdk/session_tool_execution_backend.d.ts +16 -0
- package/dist/sdk/session_tool_execution_backend.js +157 -0
- package/dist/sdk/session_tool_execution_backend.js.map +1 -0
- package/dist/sdk/types.d.ts +5 -2
- package/dist/tui/session_chat_controller.js +1 -0
- package/dist/tui/session_chat_controller.js.map +1 -1
- package/dist/tui/session_tool_execution_backend.js +1 -156
- package/dist/tui/session_tool_execution_backend.js.map +1 -1
- package/package.json +6 -6
- package/dist/diff_tool/app/dist/assets/index-Az_6lupE.css +0 -1
- package/dist/diff_tool/app/dist/assets/index-C9CiIimI.js +0 -1550
|
@@ -85,9 +85,7 @@ export class LocalSessionHost {
|
|
|
85
85
|
? { usageCheckpoint: { ...recovered.snapshot.agentState.usageCheckpoint } }
|
|
86
86
|
: {}),
|
|
87
87
|
});
|
|
88
|
-
|
|
89
|
-
await hostedSession.persistRecoveredAgentState(agentRecovery);
|
|
90
|
-
}
|
|
88
|
+
await hostedSession.reconcileRecoveredState(agentRecovery);
|
|
91
89
|
return hostedSession;
|
|
92
90
|
}
|
|
93
91
|
catch (error) {
|
|
@@ -415,6 +413,7 @@ class LocalHostedSessionHandle {
|
|
|
415
413
|
goal;
|
|
416
414
|
pendingGoalCommit;
|
|
417
415
|
forceNextSnapshotRevision;
|
|
416
|
+
projectionFailure;
|
|
418
417
|
disposed = false;
|
|
419
418
|
constructor(runtime, promptBootstrap, catalog, bootstrap, remoteCatalog, getLatestRemoteModelCatalog, includeAgentContext, executionEnvironment, store, history, historyRemote, attributes, createdAt, committedSnapshot, forceNextSnapshotRevision, recordUsage, removeFromHost = () => { }) {
|
|
420
419
|
this.runtime = runtime;
|
|
@@ -433,15 +432,15 @@ class LocalHostedSessionHandle {
|
|
|
433
432
|
this.recordUsage = recordUsage;
|
|
434
433
|
this.removeFromHost = removeFromHost;
|
|
435
434
|
this.session = runtime;
|
|
436
|
-
this.committedSnapshot = committedSnapshot
|
|
437
|
-
? cloneSessionProtocolSnapshot(committedSnapshot)
|
|
438
|
-
: undefined;
|
|
439
435
|
this.persistedSnapshot = committedSnapshot
|
|
440
436
|
? cloneSessionProtocolSnapshot(committedSnapshot)
|
|
441
437
|
: undefined;
|
|
442
438
|
this.goal = structuredClone(committedSnapshot?.goal ?? null);
|
|
443
439
|
this.forceNextSnapshotRevision = forceNextSnapshotRevision;
|
|
444
440
|
this.restoreProtocolState(committedSnapshot);
|
|
441
|
+
this.committedSnapshot = committedSnapshot
|
|
442
|
+
? cloneSessionProtocolSnapshot(committedSnapshot)
|
|
443
|
+
: { ...this.buildSnapshotDraft(), revision: 1 };
|
|
445
444
|
}
|
|
446
445
|
getRemoteModelCatalog() {
|
|
447
446
|
return this.remoteCatalog;
|
|
@@ -869,15 +868,12 @@ class LocalHostedSessionHandle {
|
|
|
869
868
|
}
|
|
870
869
|
async setReasoning(reasoning) {
|
|
871
870
|
this.assertActive();
|
|
872
|
-
return await this.
|
|
873
|
-
const fromRevision = this.committedSnapshot
|
|
871
|
+
return await this.enqueueConfigurationMutation(async () => {
|
|
872
|
+
const fromRevision = this.committedSnapshot.revision;
|
|
874
873
|
this.runtime.setReasoning(reasoning);
|
|
875
874
|
this.bootstrap.persona.settings.reasoning = reasoning;
|
|
876
875
|
const snapshot = await this.commitSnapshot();
|
|
877
|
-
if (
|
|
878
|
-
this.emitSnapshotReset("configuration", snapshot);
|
|
879
|
-
}
|
|
880
|
-
else if (snapshot.revision !== fromRevision) {
|
|
876
|
+
if (snapshot.revision !== fromRevision) {
|
|
881
877
|
this.emitDelta(createSessionProtocolDeltaMessage({
|
|
882
878
|
sessionId: snapshot.sessionId,
|
|
883
879
|
fromRevision,
|
|
@@ -908,7 +904,7 @@ class LocalHostedSessionHandle {
|
|
|
908
904
|
includeAgentContext: this.includeAgentContext,
|
|
909
905
|
agentContextFiles: runtimeConfig.config.agentContextFiles ?? [],
|
|
910
906
|
});
|
|
911
|
-
return await this.
|
|
907
|
+
return await this.enqueueConfigurationMutation(async () => {
|
|
912
908
|
this.runtime.setRuntimeConfig(runtimeConfig.config, runtimeConfig.bootstrap.modelResolver.resolveModel);
|
|
913
909
|
this.runtime.updatePromptContext(runtimeContext.promptBootstrap.promptContext);
|
|
914
910
|
this.runtime.setPersona(selectedPersona, {
|
|
@@ -945,7 +941,7 @@ class LocalHostedSessionHandle {
|
|
|
945
941
|
includeAgentContext: this.includeAgentContext,
|
|
946
942
|
agentContextFiles: runtimeConfig.config.agentContextFiles ?? [],
|
|
947
943
|
});
|
|
948
|
-
return await this.
|
|
944
|
+
return await this.enqueueConfigurationMutation(async () => {
|
|
949
945
|
this.runtime.setRuntimeConfig(runtimeConfig.config, runtimeConfig.bootstrap.modelResolver.resolveModel);
|
|
950
946
|
this.runtime.updatePromptContext(runtimeContext.promptBootstrap.promptContext);
|
|
951
947
|
this.runtime.setPersona(nextPersona, {
|
|
@@ -1019,7 +1015,7 @@ class LocalHostedSessionHandle {
|
|
|
1019
1015
|
return await this.pathAutocompleteLoad;
|
|
1020
1016
|
}
|
|
1021
1017
|
async compact(options) {
|
|
1022
|
-
return await this.runMaintenance(async (signal) => {
|
|
1018
|
+
return await this.runAgentStateMutation(() => this.runMaintenance(async (signal) => {
|
|
1023
1019
|
const result = await this.session.compact({
|
|
1024
1020
|
mode: options.mode === "summary-only" ? "only-summary" : "with-last-assistant",
|
|
1025
1021
|
...(options.guidance !== undefined ? { guidance: options.guidance } : {}),
|
|
@@ -1031,7 +1027,7 @@ class LocalHostedSessionHandle {
|
|
|
1031
1027
|
compactionMessage: result.compactionMessage,
|
|
1032
1028
|
includedLastAssistant: result.includedLastAssistant,
|
|
1033
1029
|
};
|
|
1034
|
-
});
|
|
1030
|
+
}));
|
|
1035
1031
|
}
|
|
1036
1032
|
async runMaintenance(operation) {
|
|
1037
1033
|
this.assertActive();
|
|
@@ -1077,14 +1073,16 @@ class LocalHostedSessionHandle {
|
|
|
1077
1073
|
if (!this.timeline.items.some((item) => item.type === "message" && item.messageId === historyEntryId)) {
|
|
1078
1074
|
throw new Error("rewind failed");
|
|
1079
1075
|
}
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1076
|
+
return await this.runAgentStateMutation(async () => {
|
|
1077
|
+
const result = await this.session.rewindToHistoryEntryId(historyEntryId);
|
|
1078
|
+
if (!result) {
|
|
1079
|
+
throw new Error("rewind failed");
|
|
1080
|
+
}
|
|
1081
|
+
return {
|
|
1082
|
+
snapshot: await this.snapshot(),
|
|
1083
|
+
...result,
|
|
1084
|
+
};
|
|
1085
|
+
});
|
|
1088
1086
|
}
|
|
1089
1087
|
async interruptSubagent(subagentId) {
|
|
1090
1088
|
this.assertActive();
|
|
@@ -1104,6 +1102,7 @@ class LocalHostedSessionHandle {
|
|
|
1104
1102
|
executionEnvironment: this.executionEnvironment,
|
|
1105
1103
|
instructions: options.instructions,
|
|
1106
1104
|
tools: options.tools,
|
|
1105
|
+
reasoning: options.reasoning ?? this.runtime.agent.spec.attribution.reasoningEffort,
|
|
1107
1106
|
recordUsage: this.recordUsage,
|
|
1108
1107
|
emitUpdate: (threadId, update) => {
|
|
1109
1108
|
this.emitEphemeral(createSessionProtocolEphemeralMessage({
|
|
@@ -1139,11 +1138,9 @@ class LocalHostedSessionHandle {
|
|
|
1139
1138
|
}
|
|
1140
1139
|
async snapshot() {
|
|
1141
1140
|
this.assertActive();
|
|
1142
|
-
return await this.enqueueMutation(
|
|
1143
|
-
? await this.commitProjectedSnapshot()
|
|
1144
|
-
: await this.commitSnapshot());
|
|
1141
|
+
return await this.enqueueMutation(() => this.commitProjectedSnapshot());
|
|
1145
1142
|
}
|
|
1146
|
-
async
|
|
1143
|
+
async reconcileRecoveredState(recovery) {
|
|
1147
1144
|
this.assertActive();
|
|
1148
1145
|
await this.enqueueMutation(async () => {
|
|
1149
1146
|
const recoveredTools = [];
|
|
@@ -1347,7 +1344,7 @@ class LocalHostedSessionHandle {
|
|
|
1347
1344
|
if (options.removeMissingAgents) {
|
|
1348
1345
|
this.removeMissingSubagentActivities();
|
|
1349
1346
|
}
|
|
1350
|
-
return cloneSessionProtocolSnapshot(this.committedSnapshot
|
|
1347
|
+
return cloneSessionProtocolSnapshot(this.committedSnapshot);
|
|
1351
1348
|
}
|
|
1352
1349
|
await this.store.commitSessionSnapshot(snapshot, {
|
|
1353
1350
|
expectedRevision: this.persistedSnapshot?.revision ?? 0,
|
|
@@ -1361,11 +1358,7 @@ class LocalHostedSessionHandle {
|
|
|
1361
1358
|
}
|
|
1362
1359
|
async commitProjectedSnapshot() {
|
|
1363
1360
|
this.assertNotDisposed();
|
|
1364
|
-
const
|
|
1365
|
-
if (!current) {
|
|
1366
|
-
return await this.commitSnapshot();
|
|
1367
|
-
}
|
|
1368
|
-
const snapshot = cloneSessionProtocolSnapshot(current);
|
|
1361
|
+
const snapshot = cloneSessionProtocolSnapshot(this.committedSnapshot);
|
|
1369
1362
|
if (this.persistedSnapshot && isDeepStrictEqual(this.persistedSnapshot, snapshot)) {
|
|
1370
1363
|
return snapshot;
|
|
1371
1364
|
}
|
|
@@ -1378,9 +1371,6 @@ class LocalHostedSessionHandle {
|
|
|
1378
1371
|
async commitSnapshotPatch(cause, changes) {
|
|
1379
1372
|
this.assertNotDisposed();
|
|
1380
1373
|
const current = this.committedSnapshot;
|
|
1381
|
-
if (!current) {
|
|
1382
|
-
throw new Error("cannot persist a session patch without a committed snapshot");
|
|
1383
|
-
}
|
|
1384
1374
|
const delta = createSessionProtocolDeltaMessage({
|
|
1385
1375
|
sessionId: current.sessionId,
|
|
1386
1376
|
fromRevision: current.revision,
|
|
@@ -1613,38 +1603,67 @@ class LocalHostedSessionHandle {
|
|
|
1613
1603
|
}
|
|
1614
1604
|
}
|
|
1615
1605
|
}
|
|
1606
|
+
async enqueueConfigurationMutation(mutation) {
|
|
1607
|
+
try {
|
|
1608
|
+
return await this.enqueueMutation(mutation);
|
|
1609
|
+
}
|
|
1610
|
+
catch (error) {
|
|
1611
|
+
this.invalidateProjection(error);
|
|
1612
|
+
throw error;
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
async runAgentStateMutation(mutation) {
|
|
1616
|
+
const runtimeState = this.runtime.snapshot();
|
|
1617
|
+
try {
|
|
1618
|
+
return await mutation();
|
|
1619
|
+
}
|
|
1620
|
+
catch (error) {
|
|
1621
|
+
if (!isDeepStrictEqual(this.runtime.snapshot(), runtimeState)) {
|
|
1622
|
+
this.invalidateProjection(error);
|
|
1623
|
+
}
|
|
1624
|
+
throw error;
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1616
1627
|
enqueueMutation(mutation) {
|
|
1617
1628
|
const result = this.mutationQueue
|
|
1618
1629
|
.catch(() => undefined)
|
|
1619
1630
|
.then(async () => {
|
|
1631
|
+
this.assertProjectionValid();
|
|
1620
1632
|
try {
|
|
1621
1633
|
return await mutation();
|
|
1622
1634
|
}
|
|
1623
1635
|
catch (error) {
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
this.restoreProtocolState(this.committedSnapshot);
|
|
1627
|
-
}
|
|
1636
|
+
this.goal = structuredClone(this.committedSnapshot.goal);
|
|
1637
|
+
this.restoreProtocolState(this.committedSnapshot);
|
|
1628
1638
|
throw error;
|
|
1629
1639
|
}
|
|
1630
1640
|
});
|
|
1631
1641
|
this.mutationQueue = result.then(() => undefined, () => undefined);
|
|
1632
1642
|
return result;
|
|
1633
1643
|
}
|
|
1644
|
+
invalidateProjection(error) {
|
|
1645
|
+
this.projectionFailure ??= new Error("session state is inconsistent after a failed mutation", {
|
|
1646
|
+
cause: error,
|
|
1647
|
+
});
|
|
1648
|
+
}
|
|
1649
|
+
assertProjectionValid() {
|
|
1650
|
+
if (this.projectionFailure) {
|
|
1651
|
+
throw this.projectionFailure;
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1634
1654
|
assertActive() {
|
|
1635
1655
|
if (this.disposing || this.disposed) {
|
|
1636
1656
|
throw new Error(`session is shut down: ${this.sessionId}`);
|
|
1637
1657
|
}
|
|
1658
|
+
this.assertProjectionValid();
|
|
1638
1659
|
}
|
|
1639
1660
|
assertNotDisposed() {
|
|
1640
1661
|
if (this.disposed) {
|
|
1641
1662
|
throw new Error(`session is shut down: ${this.sessionId}`);
|
|
1642
1663
|
}
|
|
1664
|
+
this.assertProjectionValid();
|
|
1643
1665
|
}
|
|
1644
1666
|
nextSnapshotRevision(next) {
|
|
1645
|
-
if (!this.committedSnapshot) {
|
|
1646
|
-
return 1;
|
|
1647
|
-
}
|
|
1648
1667
|
if (this.forceNextSnapshotRevision) {
|
|
1649
1668
|
this.forceNextSnapshotRevision = false;
|
|
1650
1669
|
return this.committedSnapshot.revision + 1;
|
|
@@ -1688,7 +1707,7 @@ class LocalHostedSessionHandle {
|
|
|
1688
1707
|
]);
|
|
1689
1708
|
}
|
|
1690
1709
|
async appendToolHistory(tool, resultHistoryEntryId, result) {
|
|
1691
|
-
const callMessage = this.committedSnapshot
|
|
1710
|
+
const callMessage = this.committedSnapshot.messages.find((message) => message.id === tool.call.messageId);
|
|
1692
1711
|
const call = callMessage?.message.role === "assistant"
|
|
1693
1712
|
? callMessage.message.content[tool.call.contentIndex]
|
|
1694
1713
|
: undefined;
|
|
@@ -1928,7 +1947,7 @@ class LocalHostedSessionHandle {
|
|
|
1928
1947
|
message: event.message,
|
|
1929
1948
|
},
|
|
1930
1949
|
},
|
|
1931
|
-
...(this.committedSnapshot
|
|
1950
|
+
...(this.committedSnapshot.lifecycle !== lifecycle
|
|
1932
1951
|
? [{ type: "lifecycle.set", lifecycle }]
|
|
1933
1952
|
: []),
|
|
1934
1953
|
...toolChanges,
|
|
@@ -2295,17 +2314,6 @@ class LocalHostedSessionHandle {
|
|
|
2295
2314
|
if (changes.length === 0) {
|
|
2296
2315
|
return;
|
|
2297
2316
|
}
|
|
2298
|
-
if (!this.committedSnapshot) {
|
|
2299
|
-
if (options.persist === false) {
|
|
2300
|
-
const snapshot = { ...this.buildSnapshotDraft(), revision: 1 };
|
|
2301
|
-
this.committedSnapshot = snapshot;
|
|
2302
|
-
this.emitSnapshotReset(cause, snapshot);
|
|
2303
|
-
return;
|
|
2304
|
-
}
|
|
2305
|
-
const snapshot = await this.commitSnapshot();
|
|
2306
|
-
this.emitSnapshotReset(cause, snapshot);
|
|
2307
|
-
return;
|
|
2308
|
-
}
|
|
2309
2317
|
if (options.persist !== false) {
|
|
2310
2318
|
this.emitDelta(await this.commitSnapshotPatch(cause, changes));
|
|
2311
2319
|
return;
|
|
@@ -2333,7 +2341,7 @@ class LocalHostedSessionHandle {
|
|
|
2333
2341
|
await this.enqueueMutation(() => this.emitSnapshotResetIfChanged(cause));
|
|
2334
2342
|
}
|
|
2335
2343
|
async emitSnapshotResetIfChanged(cause) {
|
|
2336
|
-
const previousRevision = this.committedSnapshot
|
|
2344
|
+
const previousRevision = this.committedSnapshot.revision;
|
|
2337
2345
|
const snapshot = await this.commitSnapshot();
|
|
2338
2346
|
if (snapshot.revision !== previousRevision) {
|
|
2339
2347
|
this.emitSnapshotReset(cause, snapshot);
|
|
@@ -2399,7 +2407,7 @@ class LocalHostedSessionHandle {
|
|
|
2399
2407
|
return;
|
|
2400
2408
|
}
|
|
2401
2409
|
const interruptedMessage = createInterruptedAssistantMessage(draft, this.runtime.persona.model);
|
|
2402
|
-
await this.session.commitInterruptedAssistant(interruptedMessage, draft.id);
|
|
2410
|
+
await this.runAgentStateMutation(() => this.session.commitInterruptedAssistant(interruptedMessage, draft.id));
|
|
2403
2411
|
}
|
|
2404
2412
|
async cleanupFailedTurn(rootHistoryEntryId, error) {
|
|
2405
2413
|
if (this.draftAssistantMessage) {
|