@markusylisiurunen/tau 0.3.81 → 0.3.83
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 +1 -3
- package/dist/core/agent/agent_runtime.js +6 -4
- package/dist/core/agent/agent_runtime.js.map +1 -1
- package/dist/core/cli.js +2 -2
- package/dist/core/cli.js.map +1 -1
- package/dist/core/code_mode/models.js +61 -22
- package/dist/core/code_mode/models.js.map +1 -1
- package/dist/core/commands/registry.js +0 -22
- package/dist/core/commands/registry.js.map +1 -1
- package/dist/core/history/cli.js +48 -0
- package/dist/core/history/cli.js.map +1 -1
- package/dist/core/history/history_manager.js +9 -3
- package/dist/core/history/history_manager.js.map +1 -1
- package/dist/core/history/local_history_store.js +9 -2
- package/dist/core/history/local_history_store.js.map +1 -1
- package/dist/core/history/remote_history_client.js +18 -3
- package/dist/core/history/remote_history_client.js.map +1 -1
- package/dist/core/models/openrouter.js +17 -5
- package/dist/core/models/openrouter.js.map +1 -1
- package/dist/core/models/openrouter_decisions.js +16 -1
- package/dist/core/models/openrouter_decisions.js.map +1 -1
- package/dist/core/runtime/chat_runtime.js +2 -13
- package/dist/core/runtime/chat_runtime.js.map +1 -1
- package/dist/core/static/tau_docs/client-tools.md +53 -53
- package/dist/core/static/tau_docs/config-reference.md +46 -43
- package/dist/core/static/tau_docs/configuration.md +40 -36
- package/dist/core/static/tau_docs/credentials.md +32 -31
- package/dist/core/static/tau_docs/getting-started.md +28 -28
- package/dist/core/static/tau_docs/history.md +114 -79
- package/dist/core/static/tau_docs/image-generation.md +20 -18
- package/dist/core/static/tau_docs/index.md +30 -31
- package/dist/core/static/tau_docs/manifest.json +1 -0
- package/dist/core/static/tau_docs/models.md +17 -17
- package/dist/core/static/tau_docs/node-sdk.md +69 -72
- package/dist/core/static/tau_docs/nook.md +75 -69
- package/dist/core/static/tau_docs/openrouter.md +28 -13
- package/dist/core/static/tau_docs/ownership-and-scope.md +21 -23
- package/dist/core/static/tau_docs/pdf-unpacking.md +6 -6
- package/dist/core/static/tau_docs/personas.md +29 -27
- package/dist/core/static/tau_docs/prompts-and-project-context.md +41 -39
- package/dist/core/static/tau_docs/remote-sessions.md +38 -38
- package/dist/core/static/tau_docs/sdk-diff-review.md +16 -12
- package/dist/core/static/tau_docs/security.md +72 -72
- package/dist/core/static/tau_docs/session-protocol-methods.md +46 -91
- package/dist/core/static/tau_docs/session-protocol.md +54 -54
- package/dist/core/static/tau_docs/sessions.md +97 -107
- package/dist/core/static/tau_docs/skills.md +25 -20
- package/dist/core/static/tau_docs/speech-generation.md +5 -5
- package/dist/core/static/tau_docs/subagents.md +42 -44
- package/dist/core/static/tau_docs/telegram-projects.md +142 -0
- package/dist/core/static/tau_docs/telegram.md +65 -182
- package/dist/core/static/tau_docs/tools.md +72 -91
- package/dist/core/static/tau_docs/troubleshooting.md +94 -149
- package/dist/core/static/tau_docs/tui.md +124 -81
- package/dist/core/telegram/adapter.js +1 -6
- package/dist/core/telegram/adapter.js.map +1 -1
- package/dist/core/tool/image_generate.js +5 -17
- package/dist/core/tool/image_generate.js.map +1 -1
- package/dist/core/tool/openrouter.js +21 -2
- package/dist/core/tool/openrouter.js.map +1 -1
- package/dist/core/tools/catalog.js +0 -11
- package/dist/core/tools/catalog.js.map +1 -1
- package/dist/core/tools/tool_names.js +0 -6
- package/dist/core/tools/tool_names.js.map +1 -1
- package/dist/core/utils/gemini_transcription.js +103 -28
- package/dist/core/utils/gemini_transcription.js.map +1 -1
- package/dist/core/utils/model_stream.js +17 -1
- package/dist/core/utils/model_stream.js.map +1 -1
- package/dist/core/utils/user_metadata.js +0 -14
- package/dist/core/utils/user_metadata.js.map +1 -1
- package/dist/core/version.js +2 -2
- package/dist/diff_tool/app/dist/assets/{angular-html-BbLgbIhq.js → angular-html-x29PkEoY.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{angular-ts-DXk17TRM.js → angular-ts-CsWCqoCf.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{apl-BsvksCXR.js → apl-CEvdc7jl.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{astro-DH775E4V.js → astro-Cgi6YxH2.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{blade-Ck99Rm59.js → blade-B0pr7Zx6.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{c-DJpHqu5J.js → c-DDVLgtVy.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{chapel-Owff0Csy.js → chapel-Bk9M7Jej.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{cobol-Cv2gZuhO.js → cobol-DyEvnPuC.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{coffee-Bji0YCf_.js → coffee-Di2-m3Jq.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{cpp-DTjA_yFF.js → cpp-CWpAaUgO.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{crystal-Dd00NOeb.js → crystal-CUker9Zt.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{css-D44TN1V6.js → css-D4XpBIiJ.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{edge-CVmGSi2m.js → edge-CVxhhF7L.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{elixir-B8Mq7no2.js → elixir-B_FS9APl.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{elm-CXS0I3Z2.js → elm-1KyefTkH.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{erb-B9oDKaUo.js → erb-CCgO9dRW.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{git-rebase-DT-YFebH.js → git-rebase-D0VYo_oY.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{glimmer-js-s0DXlNjq.js → glimmer-js-Ce07ngjZ.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{glimmer-ts-QgEB5S2z.js → glimmer-ts-BmOM4djO.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{glsl-NA0icwbY.js → glsl-D-jkLYJ8.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{graphql-0_dOlfV0.js → graphql-DZOwJE5e.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{hack-D-mr7l1l.js → hack-Cgvn19h8.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{haml-B0-oQmz7.js → haml-JTmDSYQl.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{handlebars-Yq9bXpWN.js → handlebars-CChh7Dy5.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{html-B8bMmdRK.js → html-BKgzx_cb.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{html-derivative-BpxSlQb_.js → html-derivative-CdFl0BmX.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{http-hS_53mxt.js → http-DZeL7KvH.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{hurl-B2ST1kwl.js → hurl-CqKevOlQ.js} +1 -1
- package/dist/diff_tool/app/dist/assets/index-BXyr8GCM.js +341 -0
- package/dist/diff_tool/app/dist/assets/{java-D4mj0lZJ.js → java-Sq3MCkId.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{javascript-wC7rrKiV.js → javascript-CHZB4Nse.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{jinja-DbQ3o87F.js → jinja-C4ucJVla.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{jison-CrE9FdvP.js → jison-D3mprebA.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{json-xjicDyWN.js → json-DgPfCYJ1.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{jsx-m28lXojQ.js → jsx-BG-Tx0cw.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{julia-19xkOmop.js → julia-B1GnFeUC.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{just-Cf7OorTr.js → just-_MZzo0MF.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{latex-DDb7GQOy.js → latex-DI0kqjQy.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{liquid-DHOuQ0rf.js → liquid-BtMAPeHl.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{lua-BGyIvonw.js → lua-CFxaP0To.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{marko-DB5OqI1C.js → marko-BIJocuFI.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{mdc-DTyNMupO.js → mdc-BAgrdjTH.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{nginx-DfF0fMYD.js → nginx-DE-3CsYn.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{nim-BbwsXuZD.js → nim-DOxeXLhb.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{org-BkOBBl1f.js → org-KTfP0tHA.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{perl-BTXTOl4K.js → perl-BH-NxpgK.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{php-DIMVQWiA.js → php-vuiVEXZK.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{pug-B_nrb4dJ.js → pug-VlIlTMUy.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{qml-1PXi8G8Z.js → qml-k6wTtGG-.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{r-CJrAkc2Z.js → r-Ccjcb2zh.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{razor-DgPUftNd.js → razor-BNhYgSCv.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{regexp-C2hS8XvL.js → regexp-C4LFejPu.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{rst-CDouhKnc.js → rst-DXLxI-UJ.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{ruby-CAjKW1uO.js → ruby-BPuL4jDV.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{sas-qAHkHLc1.js → sas-B3Yz8snb.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{scss-Bfx2Ydid.js → scss-B2AJ5vpk.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{shellscript-Bu76R8y2.js → shellscript-zyDexxnC.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{shellsession-BU8BL0oL.js → shellsession-C8b8xluk.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{soy-FRl8ozP-.js → soy-DKWe_XML.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{sql-BacQgsEs.js → sql-uEbz-Epf.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{stata-B9kkG-ET.js → stata-DieRPmHY.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{surrealql-qvETr7iY.js → surrealql-Dbk3Sp1P.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{svelte-B0z1MgHc.js → svelte-CjPbRmkM.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{templ-DTnPshKb.js → templ-Do_f5vc4.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{tex-Cosab9_H.js → tex-UjLP4qUm.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{ts-tags-DNYvLFUH.js → ts-tags-5L2FutA6.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{tsx-Dstq6j1a.js → tsx-B1pNtpUr.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{twig-BzqZdwaX.js → twig-O41Vg_IM.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{typescript-YOQ_oE25.js → typescript-Bj9uwnnJ.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{typst-DTffwfpc.js → typst-DsibO7oD.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{vue-D4OMj_C5.js → vue-DPhaEurv.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{vue-html-kT4WrHGK.js → vue-html-DDV9NSy1.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{vue-vine-CxeapeMO.js → vue-vine-Dh4jOifx.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{xml-DWVpuurg.js → xml-DtIulkQk.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{xsl-C0ciup5a.js → xsl-DoWtb58Z.js} +1 -1
- package/dist/diff_tool/app/dist/assets/{yaml-98Fvyfpc.js → yaml-CZC-l1Dg.js} +1 -1
- package/dist/diff_tool/app/dist/index.html +1 -1
- package/dist/history/worker/index.js +87 -83
- package/dist/history/worker/index.js.map +1 -1
- package/dist/host/local_session_host.js +24 -318
- package/dist/host/local_session_host.js.map +1 -1
- package/dist/host/session_host.js.map +1 -1
- package/dist/host/session_protocol_handler.js +0 -98
- package/dist/host/session_protocol_handler.js.map +1 -1
- package/dist/main.js +6 -7
- package/dist/main.js.map +1 -1
- package/dist/protocol/index.d.ts +1 -1
- package/dist/protocol/index.js.map +1 -1
- package/dist/protocol/session_protocol.d.ts +3 -28
- package/dist/protocol/session_protocol.js +1 -56
- package/dist/protocol/session_protocol.js.map +1 -1
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/session.js +0 -20
- package/dist/sdk/session.js.map +1 -1
- package/dist/sdk/types.d.ts +1 -7
- package/dist/store/session_snapshot_migrations.js +72 -1
- package/dist/store/session_snapshot_migrations.js.map +1 -1
- package/dist/tui/session_chat_controller.js +14 -30
- package/dist/tui/session_chat_controller.js.map +1 -1
- package/dist/tui/ui/footer.js +4 -9
- package/dist/tui/ui/footer.js.map +1 -1
- package/package.json +9 -9
- package/dist/core/session/goal.js +0 -54
- package/dist/core/session/goal.js.map +0 -1
- package/dist/core/tools/goal.js +0 -167
- package/dist/core/tools/goal.js.map +0 -1
- package/dist/diff_tool/app/dist/assets/index-CBT_sNIz.js +0 -340
- package/dist/nook/README.md +0 -123
|
@@ -4,12 +4,9 @@ import { resolvePromptTemplateWithBackend } from "../core/config/index.js";
|
|
|
4
4
|
import { assistantHistoryEntries, systemHistoryEntry, toolHistoryEntry, userHistoryEntry, } from "../core/history/transcript.js";
|
|
5
5
|
import { McpManager } from "../core/mcp/manager.js";
|
|
6
6
|
import { ChatRuntime } from "../core/runtime/chat_runtime.js";
|
|
7
|
-
import { formatSteeringUserMessage } from "../core/runtime/steering.js";
|
|
8
|
-
import { buildGoalContinuationText, prependGoalPolicy } from "../core/session/goal.js";
|
|
9
7
|
import { buildToolRunPresentation, TOOL_UI_FACET_VERSION } from "../core/tools/presentation.js";
|
|
10
8
|
import { appendUsageLogEntry, getUsageCostTotal, getUsageTotals, } from "../core/usage/logs.js";
|
|
11
9
|
import { filterProjectPathAutocompleteEntries, loadProjectPathAutocompleteEntriesWithBackend, } from "../core/utils/project_files.js";
|
|
12
|
-
import { hasGoalTurnMetadata } from "../core/utils/user_metadata.js";
|
|
13
10
|
import { applySessionProtocolDelta, createSessionProtocolDeltaMessage, createSessionProtocolEphemeralMessage, createSessionProtocolSubagentActivitiesMessage, projectSessionProtocolNoticePresentation, projectSessionProtocolSubagentActivity, SESSION_PROTOCOL_MAX_SUBAGENT_ACTIVITIES, } from "../protocol/session_protocol.js";
|
|
14
11
|
import { isIntermediateSystemMessage, } from "../protocol/system_message.js";
|
|
15
12
|
import { LEGACY_SESSION_MODEL_CONTEXT_KEY } from "../store/session_snapshot_migrations.js";
|
|
@@ -144,11 +141,6 @@ export class LocalSessionHost {
|
|
|
144
141
|
promptContext: runtimeContext.promptBootstrap.promptContext,
|
|
145
142
|
eventSink: async (event) => await hostedSession.enqueueRuntimeEvent(event),
|
|
146
143
|
subagentEventSink: async (event) => await hostedSession.recordSubagentEvent(event),
|
|
147
|
-
goalManager: {
|
|
148
|
-
getGoal: () => hostedSession.getGoal(),
|
|
149
|
-
createGoal: async (objective) => await hostedSession.createGoal(objective),
|
|
150
|
-
updateGoal: async (update) => await hostedSession.updateGoal(update),
|
|
151
|
-
},
|
|
152
144
|
history: this.history.query(this.historyRemote),
|
|
153
145
|
mcp: this.mcp,
|
|
154
146
|
initialPromptComposition: committedSnapshot
|
|
@@ -474,8 +466,6 @@ class LocalHostedSessionHandle {
|
|
|
474
466
|
disposePromise;
|
|
475
467
|
disposing = false;
|
|
476
468
|
costTotal = 0;
|
|
477
|
-
goal;
|
|
478
|
-
pendingGoalCommit;
|
|
479
469
|
forceNextSnapshotRevision;
|
|
480
470
|
projectionFailure;
|
|
481
471
|
disposed = false;
|
|
@@ -499,7 +489,6 @@ class LocalHostedSessionHandle {
|
|
|
499
489
|
this.persistedSnapshot = committedSnapshot
|
|
500
490
|
? cloneSessionProtocolSnapshot(committedSnapshot)
|
|
501
491
|
: undefined;
|
|
502
|
-
this.goal = structuredClone(committedSnapshot?.goal ?? null);
|
|
503
492
|
this.forceNextSnapshotRevision = forceNextSnapshotRevision;
|
|
504
493
|
this.restoreProtocolState(committedSnapshot);
|
|
505
494
|
this.committedSnapshot = committedSnapshot
|
|
@@ -510,8 +499,7 @@ class LocalHostedSessionHandle {
|
|
|
510
499
|
return this.runtime.isTurnRunning;
|
|
511
500
|
}
|
|
512
501
|
get canAcceptSteering() {
|
|
513
|
-
return
|
|
514
|
-
Boolean(this.activeLogicalTurn && this.goal?.status === "active"));
|
|
502
|
+
return this.runtime.isTurnRunning;
|
|
515
503
|
}
|
|
516
504
|
get sessionId() {
|
|
517
505
|
return this.session.sessionId;
|
|
@@ -546,105 +534,6 @@ class LocalHostedSessionHandle {
|
|
|
546
534
|
this.subagentActivitiesListeners.delete(handler);
|
|
547
535
|
};
|
|
548
536
|
}
|
|
549
|
-
getGoal() {
|
|
550
|
-
return structuredClone(this.goal);
|
|
551
|
-
}
|
|
552
|
-
async createGoal(objective) {
|
|
553
|
-
const goal = this.buildNewGoal(objective);
|
|
554
|
-
await this.setGoal(goal);
|
|
555
|
-
return structuredClone(goal);
|
|
556
|
-
}
|
|
557
|
-
async updateGoal(update) {
|
|
558
|
-
this.assertActive();
|
|
559
|
-
const current = this.goal;
|
|
560
|
-
if (!current) {
|
|
561
|
-
throw new Error("no goal exists");
|
|
562
|
-
}
|
|
563
|
-
if (update.objective !== undefined && update.status === "complete") {
|
|
564
|
-
throw new Error("goal objective cannot be updated while completing the goal");
|
|
565
|
-
}
|
|
566
|
-
if (update.status === "complete") {
|
|
567
|
-
await this.setGoal(null);
|
|
568
|
-
return null;
|
|
569
|
-
}
|
|
570
|
-
const objective = update.objective?.trim() ?? current.objective;
|
|
571
|
-
if (!objective) {
|
|
572
|
-
throw new Error("goal objective must not be empty");
|
|
573
|
-
}
|
|
574
|
-
const goal = {
|
|
575
|
-
objective,
|
|
576
|
-
status: update.status ?? current.status,
|
|
577
|
-
};
|
|
578
|
-
await this.setGoal(goal);
|
|
579
|
-
return structuredClone(goal);
|
|
580
|
-
}
|
|
581
|
-
async startGoal(objective) {
|
|
582
|
-
const goal = this.buildNewGoal(objective);
|
|
583
|
-
return await this.runLogicalTurn(async (logicalTurn) => {
|
|
584
|
-
await this.enqueueMutation(() => {
|
|
585
|
-
this.goal = goal;
|
|
586
|
-
this.pendingGoalCommit = goal;
|
|
587
|
-
});
|
|
588
|
-
try {
|
|
589
|
-
const { userHistoryEntryId } = await this.acceptTurn({
|
|
590
|
-
text: prependGoalPolicy(goal.objective, goal),
|
|
591
|
-
});
|
|
592
|
-
const turn = logicalTurn.cancellationRequested
|
|
593
|
-
? await this.cancelLogicalTurn()
|
|
594
|
-
: await this.runTurnNow(logicalTurn, userHistoryEntryId);
|
|
595
|
-
await this.settleTurn(userHistoryEntryId, turn);
|
|
596
|
-
return { userHistoryEntryId, turn };
|
|
597
|
-
}
|
|
598
|
-
catch (error) {
|
|
599
|
-
if (this.pendingGoalCommit === goal) {
|
|
600
|
-
await this.enqueueMutation(() => {
|
|
601
|
-
this.goal = null;
|
|
602
|
-
this.pendingGoalCommit = undefined;
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
else {
|
|
606
|
-
await this.blockActiveGoal().catch(() => undefined);
|
|
607
|
-
}
|
|
608
|
-
throw error;
|
|
609
|
-
}
|
|
610
|
-
});
|
|
611
|
-
}
|
|
612
|
-
async resumeGoal() {
|
|
613
|
-
this.assertActive();
|
|
614
|
-
if (this.goal?.status !== "blocked") {
|
|
615
|
-
throw new Error(this.goal ? "goal is already active" : "no goal exists");
|
|
616
|
-
}
|
|
617
|
-
const goal = { ...this.goal, status: "active" };
|
|
618
|
-
return await this.runLogicalTurn(async (logicalTurn) => {
|
|
619
|
-
await this.setGoal(goal);
|
|
620
|
-
try {
|
|
621
|
-
if (logicalTurn.cancellationRequested) {
|
|
622
|
-
await this.blockActiveGoal();
|
|
623
|
-
return { turn: abortedTurnOutcome() };
|
|
624
|
-
}
|
|
625
|
-
const { userHistoryEntryId } = await this.acceptTurn({
|
|
626
|
-
text: buildGoalContinuationText(goal),
|
|
627
|
-
});
|
|
628
|
-
const turn = logicalTurn.cancellationRequested
|
|
629
|
-
? await this.cancelLogicalTurn()
|
|
630
|
-
: await this.runTurnNow(logicalTurn, userHistoryEntryId);
|
|
631
|
-
await this.settleTurn(userHistoryEntryId, turn);
|
|
632
|
-
return { turn };
|
|
633
|
-
}
|
|
634
|
-
catch (error) {
|
|
635
|
-
await this.blockActiveGoal().catch(() => undefined);
|
|
636
|
-
throw error;
|
|
637
|
-
}
|
|
638
|
-
});
|
|
639
|
-
}
|
|
640
|
-
async clearGoal() {
|
|
641
|
-
this.assertActive();
|
|
642
|
-
if (!this.goal) {
|
|
643
|
-
throw new Error("no goal exists");
|
|
644
|
-
}
|
|
645
|
-
await this.setGoal(null);
|
|
646
|
-
return await this.snapshot();
|
|
647
|
-
}
|
|
648
537
|
async record(options) {
|
|
649
538
|
this.assertActive();
|
|
650
539
|
const historyEntryId = options.historyEntryId === undefined
|
|
@@ -726,9 +615,6 @@ class LocalHostedSessionHandle {
|
|
|
726
615
|
}
|
|
727
616
|
async retryTurn() {
|
|
728
617
|
const userMessage = this.session.rawHistoryEntries.findLast((entry) => entry.message.role === "user");
|
|
729
|
-
if (userMessage && hasGoalTurnMetadata(userMessage.message)) {
|
|
730
|
-
throw new SessionRetryUnavailableError("goal-controlled turns cannot be retried; resume a blocked goal or start a new goal");
|
|
731
|
-
}
|
|
732
618
|
if (!userMessage) {
|
|
733
619
|
throw new SessionRetryUnavailableError("no user turn is available to retry");
|
|
734
620
|
}
|
|
@@ -741,7 +627,6 @@ class LocalHostedSessionHandle {
|
|
|
741
627
|
}
|
|
742
628
|
const logicalTurn = {
|
|
743
629
|
cancellationRequested: false,
|
|
744
|
-
pendingSteering: [],
|
|
745
630
|
};
|
|
746
631
|
this.activeLogicalTurn = logicalTurn;
|
|
747
632
|
const run = execute(logicalTurn);
|
|
@@ -751,7 +636,6 @@ class LocalHostedSessionHandle {
|
|
|
751
636
|
}
|
|
752
637
|
finally {
|
|
753
638
|
if (this.activeTurnPromise === run) {
|
|
754
|
-
this.rejectBufferedLogicalSteering(logicalTurn, new Error("steering was not applied before the logical turn ended"));
|
|
755
639
|
this.activeTurnPromise = undefined;
|
|
756
640
|
this.activeLogicalTurn = undefined;
|
|
757
641
|
await this.enqueueSnapshotResetIfChanged("assistant-message");
|
|
@@ -765,58 +649,20 @@ class LocalHostedSessionHandle {
|
|
|
765
649
|
if (!rootUserMessage) {
|
|
766
650
|
throw new Error("cannot run a turn without a user message");
|
|
767
651
|
}
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
try {
|
|
775
|
-
while (logicalTurn.pendingSteering.length > 0) {
|
|
776
|
-
committedSteering.push(await this.commitBufferedLogicalSteering(logicalTurn));
|
|
777
|
-
}
|
|
778
|
-
if (logicalTurn.cancellationRequested) {
|
|
779
|
-
return await this.cancelLogicalTurn(committedSteering);
|
|
780
|
-
}
|
|
781
|
-
const result = await this.runtime.runTurn();
|
|
782
|
-
const terminalResult = result.terminalResult;
|
|
783
|
-
if (terminalResult.aborted && this.draftAssistantMessage) {
|
|
784
|
-
await this.interruptDraftAssistantMessage();
|
|
785
|
-
}
|
|
786
|
-
const initialOutcome = turnOutcomeFromResult(result, result.finalMessage);
|
|
787
|
-
const terminalOutcome = turnOutcomeFromResult(terminalResult, terminalResult.finalMessage);
|
|
788
|
-
await this.enqueueMutation(async () => {
|
|
789
|
-
if (this.goal?.status === "active") {
|
|
790
|
-
goalRootHistoryEntryId ??= rootUserMessage.id;
|
|
791
|
-
}
|
|
792
|
-
if (terminalOutcome.status !== "completed" && this.goal?.status === "active") {
|
|
793
|
-
this.goal = { ...this.goal, status: "blocked" };
|
|
794
|
-
}
|
|
795
|
-
await this.emitSnapshotResetIfChanged("assistant-message");
|
|
796
|
-
});
|
|
797
|
-
await this.resolveCommittedLogicalSteering(committedSteering, initialOutcome);
|
|
798
|
-
if (logicalTurn.cancellationRequested) {
|
|
799
|
-
return await this.cancelLogicalTurn();
|
|
800
|
-
}
|
|
801
|
-
if (terminalOutcome.status !== "completed" || this.goal?.status !== "active") {
|
|
802
|
-
return goalRootHistoryEntryId ? terminalOutcome : initialOutcome;
|
|
803
|
-
}
|
|
804
|
-
if (logicalTurn.pendingSteering.length > 0) {
|
|
805
|
-
continue;
|
|
806
|
-
}
|
|
807
|
-
await this.session.commitUserText(buildGoalContinuationText(this.goal));
|
|
808
|
-
}
|
|
809
|
-
catch (error) {
|
|
810
|
-
try {
|
|
811
|
-
const outcome = await this.cleanupFailedTurn(rootUserMessage.id, error);
|
|
812
|
-
await this.resolveCommittedLogicalSteering(committedSteering, outcome);
|
|
813
|
-
return outcome;
|
|
814
|
-
}
|
|
815
|
-
catch {
|
|
816
|
-
this.rejectCommittedLogicalSteering(committedSteering, error);
|
|
817
|
-
throw error;
|
|
818
|
-
}
|
|
652
|
+
if (logicalTurn.cancellationRequested)
|
|
653
|
+
return abortedTurnOutcome();
|
|
654
|
+
try {
|
|
655
|
+
const result = await this.runtime.runTurn();
|
|
656
|
+
if (result.terminalResult.aborted && this.draftAssistantMessage) {
|
|
657
|
+
await this.interruptDraftAssistantMessage();
|
|
819
658
|
}
|
|
659
|
+
await this.enqueueSnapshotResetIfChanged("assistant-message");
|
|
660
|
+
return logicalTurn.cancellationRequested
|
|
661
|
+
? abortedTurnOutcome()
|
|
662
|
+
: turnOutcomeFromResult(result, result.finalMessage);
|
|
663
|
+
}
|
|
664
|
+
catch (error) {
|
|
665
|
+
return await this.cleanupFailedTurn(rootUserMessage.id, error);
|
|
820
666
|
}
|
|
821
667
|
}
|
|
822
668
|
interruptTurn() {
|
|
@@ -869,29 +715,22 @@ class LocalHostedSessionHandle {
|
|
|
869
715
|
const turn = turnOutcomeFromResult(association.result, association.result.finalMessage);
|
|
870
716
|
await this.settleTurn(association.historyEntryId, turn);
|
|
871
717
|
return { userHistoryEntryId: association.historyEntryId, turn };
|
|
718
|
+
}, async (error) => {
|
|
719
|
+
const association = await submission.applied;
|
|
720
|
+
await this.settleTurn(association.historyEntryId, {
|
|
721
|
+
status: "failed",
|
|
722
|
+
stopReason: "error",
|
|
723
|
+
errorMessage: formatErrorDiagnostic(error),
|
|
724
|
+
});
|
|
725
|
+
throw error;
|
|
872
726
|
}),
|
|
873
727
|
};
|
|
874
728
|
}
|
|
875
|
-
|
|
876
|
-
if (!logicalTurn || this.goal?.status !== "active") {
|
|
877
|
-
throw new Error("cannot steer without an active turn");
|
|
878
|
-
}
|
|
879
|
-
return this.bufferLogicalSteering(logicalTurn, text);
|
|
729
|
+
throw new Error("cannot steer without an active turn");
|
|
880
730
|
}
|
|
881
731
|
cancelSteering() {
|
|
882
732
|
this.assertActive();
|
|
883
|
-
|
|
884
|
-
const logicalTurn = this.activeLogicalTurn;
|
|
885
|
-
if (!logicalTurn) {
|
|
886
|
-
return cancelled;
|
|
887
|
-
}
|
|
888
|
-
const buffered = logicalTurn.pendingSteering.splice(0);
|
|
889
|
-
const error = new Error("steering submission was cancelled");
|
|
890
|
-
for (const submission of buffered) {
|
|
891
|
-
submission.rejectApplied(error);
|
|
892
|
-
submission.rejectResult(error);
|
|
893
|
-
}
|
|
894
|
-
return [...cancelled, ...buffered.map(({ id, text }) => ({ id, text }))];
|
|
733
|
+
return this.runtime.cancelSteering();
|
|
895
734
|
}
|
|
896
735
|
async exec(options) {
|
|
897
736
|
return await this.runExec(options.execId, options.signal, async (signal) => {
|
|
@@ -1270,123 +1109,6 @@ class LocalHostedSessionHandle {
|
|
|
1270
1109
|
throw new AggregateError(errors, "failed to dispose hosted session");
|
|
1271
1110
|
}
|
|
1272
1111
|
}
|
|
1273
|
-
buildNewGoal(objective) {
|
|
1274
|
-
this.assertActive();
|
|
1275
|
-
if (this.goal) {
|
|
1276
|
-
throw new Error("a goal already exists; clear it before creating another");
|
|
1277
|
-
}
|
|
1278
|
-
const normalized = objective.trim();
|
|
1279
|
-
if (!normalized) {
|
|
1280
|
-
throw new Error("goal objective must not be empty");
|
|
1281
|
-
}
|
|
1282
|
-
return { objective: normalized, status: "active" };
|
|
1283
|
-
}
|
|
1284
|
-
async setGoal(goal) {
|
|
1285
|
-
await this.enqueueMutation(async () => {
|
|
1286
|
-
await this.emitPatch("goal", [{ type: "goal.set", goal: structuredClone(goal) }]);
|
|
1287
|
-
this.goal = structuredClone(goal);
|
|
1288
|
-
});
|
|
1289
|
-
}
|
|
1290
|
-
async blockActiveGoal() {
|
|
1291
|
-
if (this.goal?.status === "active") {
|
|
1292
|
-
await this.setGoal({ ...this.goal, status: "blocked" });
|
|
1293
|
-
}
|
|
1294
|
-
}
|
|
1295
|
-
bufferLogicalSteering(logicalTurn, text) {
|
|
1296
|
-
const normalized = text.trim();
|
|
1297
|
-
if (!normalized) {
|
|
1298
|
-
throw new Error("steering input must not be empty");
|
|
1299
|
-
}
|
|
1300
|
-
let resolveApplied;
|
|
1301
|
-
let rejectApplied;
|
|
1302
|
-
const applied = new Promise((resolve, reject) => {
|
|
1303
|
-
resolveApplied = resolve;
|
|
1304
|
-
rejectApplied = reject;
|
|
1305
|
-
});
|
|
1306
|
-
let resolveResult;
|
|
1307
|
-
let rejectResult;
|
|
1308
|
-
const result = new Promise((resolve, reject) => {
|
|
1309
|
-
resolveResult = resolve;
|
|
1310
|
-
rejectResult = reject;
|
|
1311
|
-
});
|
|
1312
|
-
const submission = {
|
|
1313
|
-
id: `logical-steering-${randomUUID()}`,
|
|
1314
|
-
text: normalized,
|
|
1315
|
-
applied,
|
|
1316
|
-
result,
|
|
1317
|
-
resolveApplied,
|
|
1318
|
-
resolveResult,
|
|
1319
|
-
rejectApplied,
|
|
1320
|
-
rejectResult,
|
|
1321
|
-
};
|
|
1322
|
-
logicalTurn.pendingSteering.push(submission);
|
|
1323
|
-
return { id: submission.id, applied, result };
|
|
1324
|
-
}
|
|
1325
|
-
async commitBufferedLogicalSteering(logicalTurn) {
|
|
1326
|
-
const submissions = logicalTurn.pendingSteering.splice(0);
|
|
1327
|
-
if (submissions.length === 0) {
|
|
1328
|
-
throw new Error("cannot commit empty logical steering");
|
|
1329
|
-
}
|
|
1330
|
-
try {
|
|
1331
|
-
const goal = this.goal;
|
|
1332
|
-
if (goal?.status !== "active") {
|
|
1333
|
-
throw new Error("cannot commit logical steering without an active goal");
|
|
1334
|
-
}
|
|
1335
|
-
const historyEntryId = this.createTurnHistoryEntryId();
|
|
1336
|
-
this.pendingAcceptedTurnHistoryEntryIds.add(historyEntryId);
|
|
1337
|
-
try {
|
|
1338
|
-
await this.session.commitUserText(prependGoalPolicy(formatSteeringUserMessage(submissions.map((submission) => submission.text)), goal), { historyEntryId });
|
|
1339
|
-
}
|
|
1340
|
-
finally {
|
|
1341
|
-
this.pendingAcceptedTurnHistoryEntryIds.delete(historyEntryId);
|
|
1342
|
-
}
|
|
1343
|
-
for (const submission of submissions) {
|
|
1344
|
-
submission.resolveApplied({ userHistoryEntryId: historyEntryId });
|
|
1345
|
-
}
|
|
1346
|
-
return { historyEntryId, submissions };
|
|
1347
|
-
}
|
|
1348
|
-
catch (error) {
|
|
1349
|
-
const steeringError = error instanceof Error ? error : new Error(String(error));
|
|
1350
|
-
for (const submission of submissions) {
|
|
1351
|
-
submission.rejectApplied(steeringError);
|
|
1352
|
-
submission.rejectResult(steeringError);
|
|
1353
|
-
}
|
|
1354
|
-
throw error;
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
|
-
async resolveCommittedLogicalSteering(committed, turn) {
|
|
1358
|
-
for (const { historyEntryId, submissions } of committed) {
|
|
1359
|
-
await this.settleTurn(historyEntryId, turn);
|
|
1360
|
-
for (const submission of submissions) {
|
|
1361
|
-
submission.resolveResult({ userHistoryEntryId: historyEntryId, turn });
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
rejectCommittedLogicalSteering(committed, error) {
|
|
1366
|
-
const steeringError = error instanceof Error ? error : new Error(String(error));
|
|
1367
|
-
for (const { submissions } of committed) {
|
|
1368
|
-
for (const submission of submissions) {
|
|
1369
|
-
submission.rejectResult(steeringError);
|
|
1370
|
-
}
|
|
1371
|
-
}
|
|
1372
|
-
}
|
|
1373
|
-
rejectBufferedLogicalSteering(logicalTurn, error) {
|
|
1374
|
-
for (const submission of logicalTurn.pendingSteering.splice(0)) {
|
|
1375
|
-
submission.rejectApplied(error);
|
|
1376
|
-
submission.rejectResult(error);
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
async cancelLogicalTurn(committedSteering = []) {
|
|
1380
|
-
const outcome = abortedTurnOutcome();
|
|
1381
|
-
await this.enqueueMutation(async () => {
|
|
1382
|
-
if (this.goal?.status === "active") {
|
|
1383
|
-
this.goal = { ...this.goal, status: "blocked" };
|
|
1384
|
-
}
|
|
1385
|
-
await this.emitSnapshotResetIfChanged("assistant-message");
|
|
1386
|
-
});
|
|
1387
|
-
await this.resolveCommittedLogicalSteering(committedSteering, outcome);
|
|
1388
|
-
return outcome;
|
|
1389
|
-
}
|
|
1390
1112
|
async commitSnapshot(options = {}) {
|
|
1391
1113
|
this.assertNotDisposed();
|
|
1392
1114
|
this.reconcileProjections(options);
|
|
@@ -1514,7 +1236,6 @@ class LocalHostedSessionHandle {
|
|
|
1514
1236
|
: {}),
|
|
1515
1237
|
},
|
|
1516
1238
|
lifecycle: this.activeTurnPromise || this.runtime.isTurnRunning ? "running" : "idle",
|
|
1517
|
-
goal: structuredClone(this.goal),
|
|
1518
1239
|
costTotal: this.costTotal,
|
|
1519
1240
|
settings: {
|
|
1520
1241
|
personaId: this.runtime.persona.id,
|
|
@@ -1695,7 +1416,6 @@ class LocalHostedSessionHandle {
|
|
|
1695
1416
|
return await mutation();
|
|
1696
1417
|
}
|
|
1697
1418
|
catch (error) {
|
|
1698
|
-
this.goal = structuredClone(this.committedSnapshot.goal);
|
|
1699
1419
|
this.restoreProtocolState(this.committedSnapshot);
|
|
1700
1420
|
throw error;
|
|
1701
1421
|
}
|
|
@@ -1934,7 +1654,6 @@ class LocalHostedSessionHandle {
|
|
|
1934
1654
|
return;
|
|
1935
1655
|
}
|
|
1936
1656
|
case "user_message": {
|
|
1937
|
-
const pendingGoal = this.pendingGoalCommit;
|
|
1938
1657
|
const acceptsTurn = this.pendingAcceptedTurnHistoryEntryIds.has(event.historyEntryId) ||
|
|
1939
1658
|
event.origin === "steering";
|
|
1940
1659
|
const turn = acceptsTurn
|
|
@@ -1949,9 +1668,6 @@ class LocalHostedSessionHandle {
|
|
|
1949
1668
|
const timelineItem = this.appendMessageTimelineItem(event.historyEntryId, event.message.timestamp);
|
|
1950
1669
|
await this.emitPatch("user-message", [
|
|
1951
1670
|
this.agentStateChange(),
|
|
1952
|
-
...(pendingGoal
|
|
1953
|
-
? [{ type: "goal.set", goal: structuredClone(pendingGoal) }]
|
|
1954
|
-
: []),
|
|
1955
1671
|
...(turn ? [{ type: "turn.set", turn }] : []),
|
|
1956
1672
|
{
|
|
1957
1673
|
type: "message.append",
|
|
@@ -1968,9 +1684,6 @@ class LocalHostedSessionHandle {
|
|
|
1968
1684
|
this.pendingAcceptedTurnHistoryEntryIds.delete(event.historyEntryId);
|
|
1969
1685
|
}
|
|
1970
1686
|
await this.recordHistoryFailure(this.history.append(this.sessionId, [userHistoryEntry(event.historyEntryId, event.message)], this.historyRemote));
|
|
1971
|
-
if (pendingGoal && this.pendingGoalCommit === pendingGoal) {
|
|
1972
|
-
this.pendingGoalCommit = undefined;
|
|
1973
|
-
}
|
|
1974
1687
|
return;
|
|
1975
1688
|
}
|
|
1976
1689
|
case "history_rewound": {
|
|
@@ -2497,9 +2210,6 @@ class LocalHostedSessionHandle {
|
|
|
2497
2210
|
reason: "runtime-error",
|
|
2498
2211
|
message: diagnostic,
|
|
2499
2212
|
});
|
|
2500
|
-
if (this.goal?.status === "active") {
|
|
2501
|
-
this.goal = { ...this.goal, status: "blocked" };
|
|
2502
|
-
}
|
|
2503
2213
|
const timestamp = Date.now();
|
|
2504
2214
|
for (const [id, tool] of this.tools) {
|
|
2505
2215
|
if (tool.status !== "queued" && tool.status !== "running") {
|
|
@@ -2639,10 +2349,6 @@ function normalizeRecoveredSnapshot(snapshot) {
|
|
|
2639
2349
|
};
|
|
2640
2350
|
}
|
|
2641
2351
|
}
|
|
2642
|
-
if (recovered.goal?.status === "active") {
|
|
2643
|
-
changed = true;
|
|
2644
|
-
recovered.goal.status = "blocked";
|
|
2645
|
-
}
|
|
2646
2352
|
if (Object.keys(recovered.agents).length > 0) {
|
|
2647
2353
|
changed = true;
|
|
2648
2354
|
recovered.agents = {};
|