@markusylisiurunen/tau 0.3.107 → 0.3.109

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.
Files changed (87) hide show
  1. package/README.md +1 -1
  2. package/dist/core/cli.js +5 -3
  3. package/dist/core/cli.js.map +1 -1
  4. package/dist/core/code_mode/agents.js +1 -1
  5. package/dist/core/history/agent_history_recorder.js +75 -45
  6. package/dist/core/history/agent_history_recorder.js.map +1 -1
  7. package/dist/core/history/cli.js +89 -0
  8. package/dist/core/history/cli.js.map +1 -1
  9. package/dist/core/history/export.js +105 -0
  10. package/dist/core/history/export.js.map +1 -0
  11. package/dist/core/history/history_manager.js +15 -0
  12. package/dist/core/history/history_manager.js.map +1 -1
  13. package/dist/core/history/local_history_store.js +3 -2
  14. package/dist/core/history/local_history_store.js.map +1 -1
  15. package/dist/core/history/recorder.js +69 -0
  16. package/dist/core/history/recorder.js.map +1 -0
  17. package/dist/core/history/remote_history_client.js +5 -61
  18. package/dist/core/history/remote_history_client.js.map +1 -1
  19. package/dist/core/history/schema.js +63 -0
  20. package/dist/core/history/schema.js.map +1 -0
  21. package/dist/core/history/transcript.js +0 -12
  22. package/dist/core/history/transcript.js.map +1 -1
  23. package/dist/core/models/catalog.js +7 -0
  24. package/dist/core/models/catalog.js.map +1 -1
  25. package/dist/core/models/openrouter.js +1 -1
  26. package/dist/core/models/supplemental_models.js +78 -0
  27. package/dist/core/models/supplemental_models.js.map +1 -0
  28. package/dist/core/modes/run.js +125 -0
  29. package/dist/core/modes/run.js.map +1 -0
  30. package/dist/core/personas.js +18 -18
  31. package/dist/core/personas.js.map +1 -1
  32. package/dist/core/static/code_mode/history/documentation.md +1 -1
  33. package/dist/core/static/tau_docs/configuration.md +3 -3
  34. package/dist/core/static/tau_docs/getting-started.md +3 -3
  35. package/dist/core/static/tau_docs/history.md +7 -3
  36. package/dist/core/static/tau_docs/how-tau-works.md +1 -0
  37. package/dist/core/static/tau_docs/models-and-credentials.md +1 -1
  38. package/dist/core/static/tau_docs/openrouter.md +1 -1
  39. package/dist/core/static/tau_docs/session-protocol.md +5 -5
  40. package/dist/core/static/tau_docs/sessions.md +12 -0
  41. package/dist/core/static/tau_docs/subagents.md +2 -2
  42. package/dist/core/static/tau_docs/telegram.md +1 -1
  43. package/dist/core/subagents/claude_code_protocol.js +31 -0
  44. package/dist/core/subagents/claude_code_protocol.js.map +1 -1
  45. package/dist/core/subagents/claude_code_runner.js +87 -9
  46. package/dist/core/subagents/claude_code_runner.js.map +1 -1
  47. package/dist/core/subagents/claude_code_runner.mjs +92 -78
  48. package/dist/core/subagents/claude_code_runtime.js +18 -3
  49. package/dist/core/subagents/claude_code_runtime.js.map +1 -1
  50. package/dist/core/subagents/native_subagent_runtime.js +6 -1
  51. package/dist/core/subagents/native_subagent_runtime.js.map +1 -1
  52. package/dist/core/subagents/runtime.js +1 -0
  53. package/dist/core/subagents/runtime.js.map +1 -1
  54. package/dist/core/subagents/trace.js +10 -0
  55. package/dist/core/subagents/trace.js.map +1 -1
  56. package/dist/core/version.js +1 -1
  57. package/dist/diff_tool/app/dist/assets/{core-C8H11wfm.js → core-DRa8IVp0.js} +1 -1
  58. package/dist/diff_tool/app/dist/assets/engine-oniguruma-ClLSZAPL.js +1 -0
  59. package/dist/diff_tool/app/dist/assets/{highlights-cE22-a3y.js → highlights-DUKV0NfW.js} +1 -1
  60. package/dist/diff_tool/app/dist/assets/{index-CBMkrdCu.js → index-lQSBHdfy.js} +8 -8
  61. package/dist/diff_tool/app/dist/assets/langs-BV5gRW8c.js +1 -0
  62. package/dist/diff_tool/app/dist/assets/{shiki-vGFSB_wG.js → shiki-DpFNWE1w.js} +2 -2
  63. package/dist/diff_tool/app/dist/assets/{stream-tokenizer-oD1fJWpE.js → stream-tokenizer-Ju4sb3HF.js} +1 -1
  64. package/dist/diff_tool/app/dist/assets/{themes-CEjjT94e.js → themes-0umwNBVp.js} +2 -2
  65. package/dist/diff_tool/app/dist/index.html +1 -1
  66. package/dist/history/worker/index.js +5 -2
  67. package/dist/history/worker/index.js.map +1 -1
  68. package/dist/host/local_session_host.js +118 -32
  69. package/dist/host/local_session_host.js.map +1 -1
  70. package/dist/host/session_protocol_handler.js +24 -2
  71. package/dist/host/session_protocol_handler.js.map +1 -1
  72. package/dist/main.js +37 -3
  73. package/dist/main.js.map +1 -1
  74. package/dist/protocol/session_protocol.d.ts +2 -1
  75. package/dist/protocol/session_protocol.js +2 -1
  76. package/dist/protocol/session_protocol.js.map +1 -1
  77. package/dist/sdk/local_client.js +1 -0
  78. package/dist/sdk/local_client.js.map +1 -1
  79. package/dist/sdk/types.d.ts +1 -0
  80. package/dist/store/file_session_store.js +47 -2
  81. package/dist/store/file_session_store.js.map +1 -1
  82. package/dist/store/memory_session_store.js +9 -0
  83. package/dist/store/memory_session_store.js.map +1 -1
  84. package/dist/store/session_store.js.map +1 -1
  85. package/package.json +9 -9
  86. package/dist/diff_tool/app/dist/assets/engine-oniguruma-wS7L8vWH.js +0 -1
  87. package/dist/diff_tool/app/dist/assets/langs-jT2mm32y.js +0 -1
@@ -3,6 +3,7 @@ import { resolve } from "node:path";
3
3
  import { isDeepStrictEqual } from "node:util";
4
4
  import { resolvePromptTemplateWithBackend } from "../core/config/index.js";
5
5
  import { AgentHistoryRecorder } from "../core/history/agent_history_recorder.js";
6
+ import { HistoryRecorder } from "../core/history/recorder.js";
6
7
  import { McpManager } from "../core/mcp/manager.js";
7
8
  import { resolvePersonaSelection } from "../core/persona_selection.js";
8
9
  import { ChatRuntime } from "../core/runtime/chat_runtime.js";
@@ -27,6 +28,7 @@ export class LocalSessionHost {
27
28
  retention = new Map();
28
29
  sessionRecoveryPromises = new Map();
29
30
  store;
31
+ sessionLeases = new Map();
30
32
  history;
31
33
  historyRemote;
32
34
  onShutdown;
@@ -60,7 +62,10 @@ export class LocalSessionHost {
60
62
  throw new Error("local session host is shut down");
61
63
  }
62
64
  let hostedSession;
65
+ const sessionId = randomUUID();
66
+ let lease;
63
67
  try {
68
+ lease = await this.acquireSessionLease(sessionId);
64
69
  const result = await executionEnvironment
65
70
  .getToolExecutionBackend()
66
71
  .runNodeScript('process.stdout.write(require("node:os").hostname())', [], {
@@ -89,12 +94,13 @@ export class LocalSessionHost {
89
94
  machine: result.stdout.trim(),
90
95
  cwd: executionEnvironment.snapshot().cwd,
91
96
  });
92
- hostedSession = await this.createLocalSessionHandle(executionEnvironment, undefined, {
97
+ hostedSession = await this.createLocalSessionHandle(sessionId, lease, executionEnvironment, undefined, {
93
98
  ...input,
94
99
  attributes,
95
100
  });
96
101
  }
97
102
  catch (error) {
103
+ await lease?.release();
98
104
  if (!this.sessionsHasExecutionEnvironment(executionEnvironment)) {
99
105
  await executionEnvironment.dispose();
100
106
  }
@@ -107,11 +113,11 @@ export class LocalSessionHost {
107
113
  }
108
114
  return this.retainSession(hostedSession);
109
115
  }
110
- async createRecoveredSession(snapshot, executionEnvironment) {
116
+ async createRecoveredSession(snapshot, executionEnvironment, lease) {
111
117
  let hostedSession;
112
118
  try {
113
119
  const recovered = normalizeRecoveredSnapshot(snapshot);
114
- hostedSession = await this.createLocalSessionHandle(executionEnvironment, recovered.snapshot, undefined, recovered.changed);
120
+ hostedSession = await this.createLocalSessionHandle(snapshot.sessionId, lease, executionEnvironment, recovered.snapshot, undefined, recovered.changed);
115
121
  const agentRecovery = hostedSession.runtime.restoreState({
116
122
  agentId: recovered.snapshot.sessionId,
117
123
  revision: recovered.snapshot.agentState.revision,
@@ -145,7 +151,7 @@ export class LocalSessionHost {
145
151
  throw error;
146
152
  }
147
153
  }
148
- async createLocalSessionHandle(executionEnvironment, committedSnapshot, createParams, forceNextSnapshotRevision = false) {
154
+ async createLocalSessionHandle(sessionId, lease, executionEnvironment, committedSnapshot, createParams, forceNextSnapshotRevision = false) {
149
155
  const remoteCatalog = this.sessionOptions.getRemoteModelCatalog();
150
156
  const bootstrap = await this.resolveSessionBootstrap(executionEnvironment, remoteCatalog, committedSnapshot !== undefined);
151
157
  if (committedSnapshot) {
@@ -170,11 +176,10 @@ export class LocalSessionHost {
170
176
  }
171
177
  : { status: "unavailable", reason: "remote-execution" };
172
178
  const catalog = createContentCatalogSnapshot(bootstrap, mcpState);
173
- return this.createLocalSessionHandleFromRuntimeContext(executionEnvironment, runtimeContext, bootstrap, catalog, mcp, remoteCatalog, committedSnapshot, createParams, forceNextSnapshotRevision);
179
+ return this.createLocalSessionHandleFromRuntimeContext(sessionId, lease, executionEnvironment, runtimeContext, bootstrap, catalog, mcp, remoteCatalog, committedSnapshot, createParams, forceNextSnapshotRevision);
174
180
  }
175
- async createLocalSessionHandleFromRuntimeContext(executionEnvironment, runtimeContext, bootstrap, catalog, mcp, remoteCatalog, committedSnapshot, createParams, forceNextSnapshotRevision = false) {
181
+ async createLocalSessionHandleFromRuntimeContext(sessionId, lease, executionEnvironment, runtimeContext, bootstrap, catalog, mcp, remoteCatalog, committedSnapshot, createParams, forceNextSnapshotRevision = false) {
176
182
  let hostedSession;
177
- const sessionId = committedSnapshot?.sessionId ?? randomUUID();
178
183
  const createdAt = committedSnapshot?.createdAt ?? this.sessionOptions.environment.now();
179
184
  const attributes = committedSnapshot?.attributes ?? createParams?.attributes;
180
185
  if (!attributes) {
@@ -200,7 +205,7 @@ export class LocalSessionHost {
200
205
  subagentEventSink: async (event) => await hostedSession.recordSubagentEvent(event),
201
206
  history: this.history.query(this.historyRemote),
202
207
  openSubagentHistory: (child) => {
203
- const recorder = new AgentHistoryRecorder(this.history.openSession({
208
+ const recorder = new HistoryRecorder(this.history.openSession({
204
209
  sessionId: child.sessionId,
205
210
  parentSessionId: child.parentSessionId,
206
211
  attributes: { ...attributes, cwd: child.workingDirectory },
@@ -226,7 +231,7 @@ export class LocalSessionHost {
226
231
  ? createParams.autoCompactThresholdTokens
227
232
  : (bootstrap.initialAutoCompactThresholdTokens ?? null));
228
233
  const historyWriter = this.history.openSession({ sessionId, attributes, createdAt }, this.historyRemote);
229
- hostedSession = new LocalHostedSessionHandle(runtime, runtimeContext.promptBootstrap, catalog, mcp, bootstrap, remoteCatalog, this.sessionOptions.getRemoteModelCatalog, this.sessionOptions.includeAgentContext, executionEnvironment, this.store, new AgentHistoryRecorder(historyWriter), attributes, createdAt, committedSnapshot, forceNextSnapshotRevision, this.sessionOptions.recordUsage ?? appendUsageLogEntry, (session, error) => {
234
+ hostedSession = new LocalHostedSessionHandle(runtime, runtimeContext.promptBootstrap, catalog, mcp, bootstrap, remoteCatalog, this.sessionOptions.getRemoteModelCatalog, this.sessionOptions.includeAgentContext, executionEnvironment, this.store, new AgentHistoryRecorder(historyWriter), attributes, createdAt, committedSnapshot, forceNextSnapshotRevision, this.sessionOptions.recordUsage ?? appendUsageLogEntry, lease, (session, error) => {
230
235
  if (error)
231
236
  this.disposalFailures.set(session.sessionId, error);
232
237
  this.sessions.delete(session);
@@ -235,6 +240,37 @@ export class LocalSessionHost {
235
240
  this.sessions.add(hostedSession);
236
241
  return hostedSession;
237
242
  }
243
+ async acquireSessionLease(sessionId) {
244
+ let lease = this.sessionLeases.get(sessionId);
245
+ if (lease?.settlement) {
246
+ await lease.settlement;
247
+ lease = undefined;
248
+ }
249
+ if (lease) {
250
+ lease.references += 1;
251
+ }
252
+ else {
253
+ lease = { release: await this.store.acquireSession(sessionId), references: 1 };
254
+ this.sessionLeases.set(sessionId, lease);
255
+ }
256
+ const owned = lease;
257
+ let released = false;
258
+ return {
259
+ release: async () => {
260
+ if (released)
261
+ return;
262
+ released = true;
263
+ if (--owned.references > 0)
264
+ return;
265
+ owned.settlement = (async () => {
266
+ await this.history.settleSession(sessionId);
267
+ await owned.release();
268
+ this.sessionLeases.delete(sessionId);
269
+ })();
270
+ await owned.settlement;
271
+ },
272
+ };
273
+ }
238
274
  async resolveSessionBootstrap(executionEnvironment, remoteCatalog, recovering) {
239
275
  const resolver = this.sessionOptions.resolveSessionBootstrap;
240
276
  if (!resolver) {
@@ -300,6 +336,9 @@ export class LocalSessionHost {
300
336
  }
301
337
  }
302
338
  async recoverSession(sessionId) {
339
+ await Promise.all([...this.sessionEvictions]
340
+ .filter(([session]) => session.sessionId === sessionId)
341
+ .map(([, eviction]) => eviction));
303
342
  await this.refreshStore();
304
343
  if (this.shuttingDown) {
305
344
  return undefined;
@@ -308,21 +347,31 @@ export class LocalSessionHost {
308
347
  if (liveSession) {
309
348
  return liveSession;
310
349
  }
311
- const snapshot = await this.store.loadSession(sessionId);
312
- if (!snapshot || !this.canRestoreSnapshot(snapshot)) {
313
- return undefined;
314
- }
315
- const executionEnvironment = await this.sessionOptions.executionEnvironmentResolver.restore(snapshot.executionEnvironment);
316
- if (this.shuttingDown) {
317
- await this.disposeRecoveredEnvironment(sessionId, executionEnvironment);
318
- return undefined;
350
+ const lease = await this.acquireSessionLease(sessionId);
351
+ try {
352
+ const snapshot = await this.store.loadSession(sessionId);
353
+ if (!snapshot || !this.canRestoreSnapshot(snapshot)) {
354
+ await lease.release();
355
+ return undefined;
356
+ }
357
+ const executionEnvironment = await this.sessionOptions.executionEnvironmentResolver.restore(snapshot.executionEnvironment);
358
+ if (this.shuttingDown) {
359
+ await this.disposeRecoveredEnvironment(sessionId, executionEnvironment);
360
+ await lease.release();
361
+ return undefined;
362
+ }
363
+ const restoredLiveSession = this.findLiveSession(sessionId);
364
+ if (restoredLiveSession) {
365
+ await this.disposeRecoveredEnvironment(sessionId, executionEnvironment);
366
+ await lease.release();
367
+ return restoredLiveSession;
368
+ }
369
+ return await this.createRecoveredSession(snapshot, executionEnvironment, lease);
319
370
  }
320
- const restoredLiveSession = this.findLiveSession(sessionId);
321
- if (restoredLiveSession) {
322
- await this.disposeRecoveredEnvironment(sessionId, executionEnvironment);
323
- return restoredLiveSession;
371
+ catch (error) {
372
+ await lease.release();
373
+ throw error;
324
374
  }
325
- return await this.createRecoveredSession(snapshot, executionEnvironment);
326
375
  }
327
376
  canRestoreSnapshot(snapshot) {
328
377
  return this.sessionOptions.executionEnvironmentResolver.canRestore(snapshot.executionEnvironment);
@@ -570,6 +619,7 @@ class LocalHostedSessionHandle {
570
619
  attributes;
571
620
  createdAt;
572
621
  recordUsage;
622
+ lease;
573
623
  removeFromHost;
574
624
  session;
575
625
  committedSnapshot;
@@ -605,6 +655,7 @@ class LocalHostedSessionHandle {
605
655
  notificationWakeScheduled = false;
606
656
  activeTurnPromise;
607
657
  activeLogicalTurn;
658
+ cancelledAcceptedTurns = new Set();
608
659
  disposePromise;
609
660
  disposing = false;
610
661
  costTotal = 0;
@@ -612,7 +663,7 @@ class LocalHostedSessionHandle {
612
663
  forceNextSnapshotRevision;
613
664
  projectionFailure;
614
665
  disposed = false;
615
- constructor(runtime, promptBootstrap, catalog, mcp, bootstrap, remoteCatalog, getLatestRemoteModelCatalog, includeAgentContext, executionEnvironment, store, historyRecorder, attributes, createdAt, committedSnapshot, forceNextSnapshotRevision, recordUsage, removeFromHost) {
666
+ constructor(runtime, promptBootstrap, catalog, mcp, bootstrap, remoteCatalog, getLatestRemoteModelCatalog, includeAgentContext, executionEnvironment, store, historyRecorder, attributes, createdAt, committedSnapshot, forceNextSnapshotRevision, recordUsage, lease, removeFromHost) {
616
667
  this.runtime = runtime;
617
668
  this.promptBootstrap = promptBootstrap;
618
669
  this.catalog = catalog;
@@ -627,6 +678,7 @@ class LocalHostedSessionHandle {
627
678
  this.attributes = attributes;
628
679
  this.createdAt = createdAt;
629
680
  this.recordUsage = recordUsage;
681
+ this.lease = lease;
630
682
  this.removeFromHost = removeFromHost;
631
683
  this.session = runtime;
632
684
  this.unsubscribeNotifications =
@@ -817,8 +869,10 @@ class LocalHostedSessionHandle {
817
869
  await this.session.commitUserText(options.text, { historyEntryId: userHistoryEntryId });
818
870
  return { snapshot: await this.snapshot(), userHistoryEntryId };
819
871
  }
820
- finally {
872
+ catch (error) {
821
873
  this.pendingAcceptedTurnHistoryEntryIds.delete(userHistoryEntryId);
874
+ this.cancelledAcceptedTurns.delete(userHistoryEntryId);
875
+ throw error;
822
876
  }
823
877
  }
824
878
  createTurnHistoryEntryId(preferredId) {
@@ -847,8 +901,15 @@ class LocalHostedSessionHandle {
847
901
  if (acceptedTurn.state === "settled") {
848
902
  throw new Error(`turn '${userHistoryEntryId}' was already settled`);
849
903
  }
850
- const turn = await this.runLogicalTurn((logicalTurn) => this.runAndSettleTurn(logicalTurn, userHistoryEntryId, { notificationTurn: false }));
851
- return { userHistoryEntryId, turn };
904
+ this.pendingAcceptedTurnHistoryEntryIds.delete(userHistoryEntryId);
905
+ const cancelled = this.cancelledAcceptedTurns.delete(userHistoryEntryId);
906
+ return await this.runLogicalTurn(async (logicalTurn) => {
907
+ logicalTurn.cancellationRequested = cancelled;
908
+ const turn = await this.runAndSettleTurn(logicalTurn, userHistoryEntryId, {
909
+ notificationTurn: false,
910
+ });
911
+ return { userHistoryEntryId, turn, response: logicalTurn.response };
912
+ });
852
913
  }
853
914
  async runAndSettleTurn(logicalTurn, userHistoryEntryId, { notificationTurn }) {
854
915
  const outcome = notificationTurn
@@ -903,6 +964,7 @@ class LocalHostedSessionHandle {
903
964
  }
904
965
  const logicalTurn = {
905
966
  cancellationRequested: false,
967
+ response: "",
906
968
  };
907
969
  this.activeLogicalTurn = logicalTurn;
908
970
  const run = execute(logicalTurn);
@@ -961,21 +1023,29 @@ class LocalHostedSessionHandle {
961
1023
  }
962
1024
  interruptTurn() {
963
1025
  this.assertActive();
1026
+ for (const id of this.pendingAcceptedTurnHistoryEntryIds)
1027
+ this.cancelledAcceptedTurns.add(id);
964
1028
  const logicalTurn = this.activeLogicalTurn;
965
1029
  if (logicalTurn) {
966
1030
  logicalTurn.cancellationRequested = true;
967
1031
  }
968
- const interrupted = this.runtime.interruptTurn() || Boolean(logicalTurn);
1032
+ const interrupted = this.runtime.interruptTurn() ||
1033
+ Boolean(logicalTurn) ||
1034
+ this.pendingAcceptedTurnHistoryEntryIds.size > 0;
969
1035
  if (interrupted)
970
1036
  this.notificationWakePaused = true;
971
1037
  return interrupted;
972
1038
  }
973
1039
  interruptActiveWork() {
1040
+ for (const id of this.pendingAcceptedTurnHistoryEntryIds)
1041
+ this.cancelledAcceptedTurns.add(id);
974
1042
  const logicalTurn = this.activeLogicalTurn;
975
1043
  if (logicalTurn) {
976
1044
  logicalTurn.cancellationRequested = true;
977
1045
  }
978
- const interruptedTurn = this.runtime.interruptTurn() || Boolean(logicalTurn);
1046
+ const interruptedTurn = this.runtime.interruptTurn() ||
1047
+ Boolean(logicalTurn) ||
1048
+ this.pendingAcceptedTurnHistoryEntryIds.size > 0;
979
1049
  // Only stopping the main agent pauses automatic turns, not cancelling side work.
980
1050
  if (interruptedTurn)
981
1051
  this.notificationWakePaused = true;
@@ -1015,7 +1085,14 @@ class LocalHostedSessionHandle {
1015
1085
  result: submission.result.then(async (association) => {
1016
1086
  const turn = turnOutcomeFromResult(association.result, association.result.finalMessage);
1017
1087
  await this.settleTurn(association.historyEntryId, turn);
1018
- return { userHistoryEntryId: association.historyEntryId, turn };
1088
+ return {
1089
+ userHistoryEntryId: association.historyEntryId,
1090
+ turn,
1091
+ response: association.result.finalMessage?.content
1092
+ .filter((block) => block.type === "text")
1093
+ .map((block) => block.text)
1094
+ .join("") ?? "",
1095
+ };
1019
1096
  }, async (error) => {
1020
1097
  const association = await submission.applied;
1021
1098
  await this.settleTurn(association.historyEntryId, {
@@ -1462,6 +1539,12 @@ class LocalHostedSessionHandle {
1462
1539
  catch (error) {
1463
1540
  errors.push(error);
1464
1541
  }
1542
+ try {
1543
+ await this.lease.release();
1544
+ }
1545
+ catch (error) {
1546
+ errors.push(error);
1547
+ }
1465
1548
  const error = errors.length > 0
1466
1549
  ? new AggregateError(errors, "failed to dispose hosted session")
1467
1550
  : undefined;
@@ -2073,9 +2156,6 @@ class LocalHostedSessionHandle {
2073
2156
  },
2074
2157
  { type: "timeline.append", item: structuredClone(timelineItem) },
2075
2158
  ], { persist: true });
2076
- if (turn) {
2077
- this.pendingAcceptedTurnHistoryEntryIds.delete(event.historyEntryId);
2078
- }
2079
2159
  return;
2080
2160
  }
2081
2161
  case "history_rewound": {
@@ -2090,6 +2170,12 @@ class LocalHostedSessionHandle {
2090
2170
  return;
2091
2171
  }
2092
2172
  case "assistant_final": {
2173
+ if (this.activeLogicalTurn) {
2174
+ this.activeLogicalTurn.response = event.message.content
2175
+ .filter((block) => block.type === "text")
2176
+ .map((block) => block.text)
2177
+ .join("");
2178
+ }
2093
2179
  this.draftAssistantMessage = undefined;
2094
2180
  const messageState = event.message.stopReason === "aborted" ? "interrupted" : "committed";
2095
2181
  if (messageState === "committed") {