maka-agent 0.2.0-dev.23.20260906 → 0.2.0-dev.25.20260908

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 (215) hide show
  1. package/README.md +38 -19
  2. package/README.zh-CN.md +34 -19
  3. package/dist/acp/maka-acp-agent.js +2 -1
  4. package/dist/acp/session-configuration.js +143 -0
  5. package/dist/acp/session-registry.js +90 -4
  6. package/dist/cli-core.js +2 -0
  7. package/dist/pi-transcript-tools.js +6 -0
  8. package/dist/pi-transcript.js +5 -12
  9. package/dist/pi-tui-layout.js +56 -10
  10. package/dist/pi-tui-pickers.js +102 -1
  11. package/dist/pi-tui-runner.js +230 -46
  12. package/dist/pi-tui-todo.js +221 -0
  13. package/dist/pi-tui-transcript-viewer.js +134 -7
  14. package/dist/runtime-host-cli-context.js +224 -78
  15. package/dist/runtime-host-cli-installation.js +8 -2
  16. package/dist/runtime-host-cli.js +31 -1
  17. package/dist/runtime-host-handoff-surface.js +106 -0
  18. package/dist/runtime-host-installed-update-bootstrap.js +13 -0
  19. package/dist/runtime-host-installed-update-coordinator.js +33 -0
  20. package/dist/runtime-host-lifecycle-transaction.js +9 -1
  21. package/dist/runtime-host-local-handoff.js +48 -5
  22. package/dist/runtime-host-local-managed-activation.js +84 -0
  23. package/dist/runtime-host-local-source-retirement.js +18 -2
  24. package/dist/runtime-host-managed-lifecycle-manager.js +1 -0
  25. package/dist/runtime-host-operator-retirement.js +50 -0
  26. package/dist/runtime-host-service-manager.js +3 -3
  27. package/dist/runtime-host-session-channel.js +13 -0
  28. package/dist/runtime-host-session-driver.js +46 -26
  29. package/dist/runtime-host-session-update.js +62 -0
  30. package/dist/runtime-host-tui-command.js +38 -73
  31. package/dist/runtime-host-tui-context.js +1 -0
  32. package/dist/runtime-host-tui-owner.js +226 -0
  33. package/dist/tui-copy-catalog.js +219 -6
  34. package/dist/tui-host-owner-copy.js +24 -0
  35. package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
  36. package/node_modules/@maka/core/dist/agent-run.js +1 -0
  37. package/node_modules/@maka/core/dist/attachments.js +3 -0
  38. package/node_modules/@maka/core/dist/canonical-json.js +27 -0
  39. package/node_modules/@maka/core/dist/canonical-runtime-event.js +3 -1
  40. package/node_modules/@maka/core/dist/capabilities.js +35 -0
  41. package/node_modules/@maka/core/dist/computer-use.js +0 -1
  42. package/node_modules/@maka/core/dist/display-redaction.js +18 -0
  43. package/node_modules/@maka/core/dist/llm-connections.js +13 -0
  44. package/node_modules/@maka/core/dist/model-call-attempt.js +2 -0
  45. package/node_modules/@maka/core/dist/model-failure.js +40 -0
  46. package/node_modules/@maka/core/dist/model-metadata.generated.js +4 -4
  47. package/node_modules/@maka/core/dist/model-metadata.js +7 -3
  48. package/node_modules/@maka/core/dist/model-web-search.js +5 -4
  49. package/node_modules/@maka/core/dist/provider-registry.js +45 -4
  50. package/node_modules/@maka/core/dist/record-schema.js +9 -2
  51. package/node_modules/@maka/core/dist/redaction.js +35 -0
  52. package/node_modules/@maka/core/dist/run-composition.js +77 -2
  53. package/node_modules/@maka/core/dist/runtime-boundary.js +31 -11
  54. package/node_modules/@maka/core/dist/runtime-event.js +37 -6
  55. package/node_modules/@maka/core/dist/runtime-handoff.js +98 -0
  56. package/node_modules/@maka/core/dist/runtime-invocation.js +1 -1
  57. package/node_modules/@maka/core/dist/runtime-logical-execution.js +112 -0
  58. package/node_modules/@maka/core/dist/session.js +84 -56
  59. package/node_modules/@maka/core/dist/slash-command-catalog.js +3 -0
  60. package/node_modules/@maka/core/dist/tool-result-archive-evidence.js +20 -0
  61. package/node_modules/@maka/core/dist/tool-result-record-schema.js +2 -1
  62. package/node_modules/@maka/core/dist/usage-record-schema.js +26 -35
  63. package/node_modules/@maka/core/package.json +5 -0
  64. package/node_modules/@maka/eval/dist/experiment-directory.js +4 -13
  65. package/node_modules/@maka/mcp/dist/index.js +131 -1
  66. package/node_modules/@maka/runtime/dist/agent-run-inspect.js +0 -13
  67. package/node_modules/@maka/runtime/dist/agent-run.js +351 -105
  68. package/node_modules/@maka/runtime/dist/ai-sdk-backend.js +29 -13
  69. package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +109 -34
  70. package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +184 -183
  71. package/node_modules/@maka/runtime/dist/archive-read-tool.js +2 -2
  72. package/node_modules/@maka/runtime/dist/context-budget-helpers.js +0 -16
  73. package/node_modules/@maka/runtime/dist/context-budget.js +14 -9
  74. package/node_modules/@maka/runtime/dist/conversation-copy.js +158 -15
  75. package/node_modules/@maka/runtime/dist/github-copilot-oauth-enrollment.js +3 -3
  76. package/node_modules/@maka/runtime/dist/goal-continuation.js +36 -4
  77. package/node_modules/@maka/runtime/dist/history-compact-checkpoint.js +18 -9
  78. package/node_modules/@maka/runtime/dist/history-compact-summarizer.js +30 -22
  79. package/node_modules/@maka/runtime/dist/history-compaction.js +29 -4
  80. package/node_modules/@maka/runtime/dist/ledger-tool-result-archive-reader.js +174 -0
  81. package/node_modules/@maka/runtime/dist/mcp-tools.js +7 -2
  82. package/node_modules/@maka/runtime/dist/message-authority.js +9 -0
  83. package/node_modules/@maka/runtime/dist/model-adapter.js +19 -98
  84. package/node_modules/@maka/runtime/dist/model-factory.js +19 -81
  85. package/node_modules/@maka/runtime/dist/model-fetcher.js +49 -2
  86. package/node_modules/@maka/runtime/dist/model-history.js +0 -112
  87. package/node_modules/@maka/runtime/dist/model-runtime.js +85 -111
  88. package/node_modules/@maka/runtime/dist/native-web-search-tool.js +2 -1
  89. package/node_modules/@maka/runtime/dist/openai-codex-history-compactor.js +2 -2
  90. package/node_modules/@maka/runtime/dist/opencode-session-header.js +4 -2
  91. package/node_modules/@maka/runtime/dist/plugin-runtime.js +20 -10
  92. package/node_modules/@maka/runtime/dist/plugin-tool-service.js +205 -0
  93. package/node_modules/@maka/runtime/dist/provider-error-classification.js +84 -123
  94. package/node_modules/@maka/runtime/dist/provider-request-telemetry.js +76 -109
  95. package/node_modules/@maka/runtime/dist/request-shape.js +23 -0
  96. package/node_modules/@maka/runtime/dist/run-handoff-gate.js +97 -0
  97. package/node_modules/@maka/runtime/dist/runtime-event-backfill.js +83 -55
  98. package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +121 -159
  99. package/node_modules/@maka/runtime/dist/runtime-kernel.js +157 -112
  100. package/node_modules/@maka/runtime/dist/runtime-ledger-repair.js +160 -79
  101. package/node_modules/@maka/runtime/dist/runtime-read-model.js +30 -89
  102. package/node_modules/@maka/runtime/dist/runtime-resume.js +80 -4
  103. package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +5 -0
  104. package/node_modules/@maka/runtime/dist/session-manager.js +171 -288
  105. package/node_modules/@maka/runtime/dist/session-projection-helpers.js +0 -27
  106. package/node_modules/@maka/runtime/dist/stream-graph-coordinator.js +21 -0
  107. package/node_modules/@maka/runtime/dist/stream-graph-supervisor-tools.js +0 -5
  108. package/node_modules/@maka/runtime/dist/subscription-model-fetch.js +3 -4
  109. package/node_modules/@maka/runtime/dist/test-connection.js +16 -17
  110. package/node_modules/@maka/runtime/dist/tool-activation-identity.js +41 -0
  111. package/node_modules/@maka/runtime/dist/tool-availability.js +11 -1
  112. package/node_modules/@maka/runtime/dist/tool-result-archive-encoding.js +38 -0
  113. package/node_modules/@maka/runtime/dist/tool-result-archive-resource.js +63 -1
  114. package/node_modules/@maka/runtime/dist/tool-result-archive-transition.js +42 -12
  115. package/node_modules/@maka/runtime/dist/tool-result-archive.js +27 -4
  116. package/node_modules/@maka/runtime/dist/tool-runtime.js +3 -61
  117. package/node_modules/@maka/runtime/package.json +2 -0
  118. package/node_modules/@maka/runtime-host/dist/adapter/session-projector.js +35 -0
  119. package/node_modules/@maka/runtime-host/dist/client/connect-or-spawn.js +9 -1
  120. package/node_modules/@maka/runtime-host/dist/client/connection.js +3 -0
  121. package/node_modules/@maka/runtime-host/dist/client/host-handoff-copy.js +179 -0
  122. package/node_modules/@maka/runtime-host/dist/client/host-handoff.js +275 -0
  123. package/node_modules/@maka/runtime-host/dist/client/host-retirement.js +26 -5
  124. package/node_modules/@maka/runtime-host/dist/client/index.js +2 -0
  125. package/node_modules/@maka/runtime-host/dist/client/launcher.js +3 -0
  126. package/node_modules/@maka/runtime-host/dist/client/remote-compatibility-error.js +2 -0
  127. package/node_modules/@maka/runtime-host/dist/client/session-subscription.js +46 -5
  128. package/node_modules/@maka/runtime-host/dist/control/endpoint.js +1 -3
  129. package/node_modules/@maka/runtime-host/dist/node-error.js +22 -0
  130. package/node_modules/@maka/runtime-host/dist/operator/index.js +2 -1
  131. package/node_modules/@maka/runtime-host/dist/operator/managed-deployment.js +1 -3
  132. package/node_modules/@maka/runtime-host/dist/operator/retirement-cancellation.js +20 -0
  133. package/node_modules/@maka/runtime-host/dist/peer-mesh/limits.js +0 -1
  134. package/node_modules/@maka/runtime-host/dist/peer-mesh/model.js +1 -1
  135. package/node_modules/@maka/runtime-host/dist/peer-reachability/publisher.js +1 -3
  136. package/node_modules/@maka/runtime-host/dist/protocol/host-status.js +21 -12
  137. package/node_modules/@maka/runtime-host/dist/protocol/index.js +29 -1
  138. package/node_modules/@maka/runtime-host/dist/protocol/operations.js +1 -0
  139. package/node_modules/@maka/runtime-host/dist/protocol/plan.js +1 -0
  140. package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +27 -5
  141. package/node_modules/@maka/runtime-host/dist/protocol/project-catalog.js +2 -2
  142. package/node_modules/@maka/runtime-host/dist/protocol/session-continuity.js +40 -20
  143. package/node_modules/@maka/runtime-host/dist/protocol/session-transcript.js +0 -5
  144. package/node_modules/@maka/runtime-host/dist/protocol/session-turns.js +29 -58
  145. package/node_modules/@maka/runtime-host/dist/protocol/turn.js +11 -1
  146. package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +31 -2
  147. package/node_modules/@maka/runtime-host/dist/server/access-credential-store.js +1 -0
  148. package/node_modules/@maka/runtime-host/dist/server/agent-graph-coordinator.js +0 -3
  149. package/node_modules/@maka/runtime-host/dist/server/canonical-turn-snapshot.js +19 -4
  150. package/node_modules/@maka/runtime-host/dist/server/connection-session.js +7 -6
  151. package/node_modules/@maka/runtime-host/dist/server/execution-artifacts.js +32 -32
  152. package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +144 -33
  153. package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +5 -5
  154. package/node_modules/@maka/runtime-host/dist/server/execution-model-composition.js +45 -16
  155. package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +40 -1
  156. package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +96 -17
  157. package/node_modules/@maka/runtime-host/dist/server/host-residency-registry.js +13 -7
  158. package/node_modules/@maka/runtime-host/dist/server/hosted-execution-admission-registry.js +3 -1
  159. package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +124 -62
  160. package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +47 -22
  161. package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +76 -6
  162. package/node_modules/@maka/runtime-host/dist/server/plugin-platform-coordinator.js +6 -0
  163. package/node_modules/@maka/runtime-host/dist/server/plugin-platform.js +6 -0
  164. package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +325 -73
  165. package/node_modules/@maka/runtime-host/dist/server/scheduled-task-coordinator.js +37 -2
  166. package/node_modules/@maka/runtime-host/dist/server/serial-outbound-writer.js +45 -3
  167. package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +50 -7
  168. package/node_modules/@maka/runtime-host/dist/server/session-continuity-coordinator.js +87 -25
  169. package/node_modules/@maka/runtime-host/dist/server/session-retirement-coordinator.js +5 -2
  170. package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +12 -55
  171. package/node_modules/@maka/runtime-host/dist/server/session-sidecar-purge.js +1 -16
  172. package/node_modules/@maka/runtime-host/dist/server/session-transcript-pager.js +0 -1
  173. package/node_modules/@maka/runtime-host/dist/server/session-transcript-reader.js +460 -70
  174. package/node_modules/@maka/runtime-host/dist/server/shared-session-transcript.js +1 -1
  175. package/node_modules/@maka/runtime-host/dist/server/storage-maintenance.js +109 -0
  176. package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +20 -2
  177. package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +13 -4
  178. package/node_modules/@maka/runtime-host/dist/server/workhub-message-attachments.js +46 -0
  179. package/node_modules/@maka/storage/dist/artifact-store.js +21 -10
  180. package/node_modules/@maka/storage/dist/artifact-stores.js +1 -1
  181. package/node_modules/@maka/storage/dist/claude-code-session-adapter.js +0 -5
  182. package/node_modules/@maka/storage/dist/codex-session-adapter.js +284 -198
  183. package/node_modules/@maka/storage/dist/context-offload-snapshot.js +325 -0
  184. package/node_modules/@maka/storage/dist/execution-stores.js +9 -7
  185. package/node_modules/@maka/storage/dist/file-session-repository.js +1012 -0
  186. package/node_modules/@maka/storage/dist/git-exec.js +61 -0
  187. package/node_modules/@maka/storage/dist/git-worktree-child-executor.js +8 -35
  188. package/node_modules/@maka/storage/dist/goal-authority.js +2 -2
  189. package/node_modules/@maka/storage/dist/interaction-store.js +2 -2
  190. package/node_modules/@maka/storage/dist/opencode-session-adapter.js +0 -4
  191. package/node_modules/@maka/storage/dist/operational-state-backup.js +9 -5
  192. package/node_modules/@maka/storage/dist/project-catalog.js +2 -23
  193. package/node_modules/@maka/storage/dist/runtime-event-invariants.js +2 -2
  194. package/node_modules/@maka/storage/dist/runtime-event-persistence.js +1 -0
  195. package/node_modules/@maka/storage/dist/runtime-policy/connection-catalog-document.js +8 -3
  196. package/node_modules/@maka/storage/dist/runtime-transcript-query.js +308 -0
  197. package/node_modules/@maka/storage/dist/scheduled-task-store.js +249 -283
  198. package/node_modules/@maka/storage/dist/session-bundle-manifest.js +5 -17
  199. package/node_modules/@maka/storage/dist/session-bundle-policy.js +26 -5
  200. package/node_modules/@maka/storage/dist/session-copy-cleanup.js +2 -1
  201. package/node_modules/@maka/storage/dist/session-message-projection.js +15 -0
  202. package/node_modules/@maka/storage/dist/session-repository.js +767 -0
  203. package/node_modules/@maka/storage/dist/session-store.js +25 -99
  204. package/node_modules/@maka/storage/dist/sqlite-artifact-metadata.js +10 -3
  205. package/node_modules/@maka/storage/dist/sqlite-context-offload-store.js +24 -8
  206. package/node_modules/@maka/storage/dist/sqlite-core-execution-schema.js +7 -1
  207. package/node_modules/@maka/storage/dist/sqlite-runtime-schema.js +44 -1
  208. package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +130 -27
  209. package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +109 -892
  210. package/node_modules/@maka/storage/dist/storage-id.js +28 -0
  211. package/node_modules/@maka/storage/dist/tool-result-archive-evidence.js +138 -0
  212. package/node_modules/@maka/storage/dist/workspace-identity.js +2 -15
  213. package/node_modules/@maka/storage/dist/workspace-version-authority-internal.js +1 -8
  214. package/node_modules/@maka/storage/package.json +2 -0
  215. package/package.json +1 -1
@@ -142,6 +142,7 @@ export class ToolRuntime {
142
142
  this.turnId = input.turnId;
143
143
  this.hostedInteraction = hosted;
144
144
  this.readExecutionBoundary = input.readExecutionBoundary;
145
+ this.sandboxBoundaryDenied = input.inheritedSandboxBoundaryDenied === true;
145
146
  }
146
147
  async endTurn(reason = 'completed') {
147
148
  const turnId = this.turnId;
@@ -165,6 +166,7 @@ export class ToolRuntime {
165
166
  sessionId: this.input.sessionId,
166
167
  requestId,
167
168
  decision: 'deny',
169
+ closureReason: reason === 'aborted' ? 'turn_stopped' : 'turn_terminal',
168
170
  });
169
171
  }));
170
172
  for (const result of results) {
@@ -490,17 +492,6 @@ export class ToolRuntime {
490
492
  isError: true,
491
493
  }, this.input.sessionId) ?? DURABLE_TOOL_RESULT_PROJECTION_FAILURE;
492
494
  const durableOutcome = await durableAttempt?.commitOutcome(content, true, modelProjection);
493
- const msg = {
494
- type: 'tool_result',
495
- id: this.input.newId(),
496
- turnId,
497
- ts: this.input.now(),
498
- toolUseId,
499
- isError: true,
500
- content,
501
- ...activityIdentity,
502
- };
503
- await this.input.appendMessage(msg);
504
495
  queue.push({
505
496
  type: 'tool_result',
506
497
  id: durableOutcome?.id ?? this.input.newId(),
@@ -667,30 +658,6 @@ export class ToolRuntime {
667
658
  queue.push(event);
668
659
  callEventPublished = true;
669
660
  };
670
- const callMsg = {
671
- type: 'tool_call',
672
- id: toolUseId,
673
- turnId,
674
- ts: now,
675
- toolName: tool.name,
676
- ...activityIdentity,
677
- ...(tool.activityKind ? { activityKind: tool.activityKind } : {}),
678
- ...(tool.displayName ? { displayName: tool.displayName } : {}),
679
- args: structuredClone(persistedArgs),
680
- ...(ctx.providerOptions !== undefined
681
- ? { providerOptions: structuredClone(ctx.providerOptions) }
682
- : {}),
683
- // Persist the same step id the tool_start event carries so the UI
684
- // timeline and post-restart backfill can pair this call with its step.
685
- ...(stepId !== undefined ? { stepId } : {}),
686
- };
687
- let callMessageAppended = false;
688
- const appendCallMessage = async () => {
689
- if (callMessageAppended)
690
- return;
691
- await this.input.appendMessage(callMsg);
692
- callMessageAppended = true;
693
- };
694
661
  const emitToolStartedTrace = () => {
695
662
  trace?.emit('tool', 'tool_started', 'Tool execution started', {
696
663
  toolUseId,
@@ -704,7 +671,6 @@ export class ToolRuntime {
704
671
  * through here so the pair can never be split across lanes again.
705
672
  */
706
673
  const refuseBeforeDispatch = async (text, sandboxFailure) => {
707
- await appendCallMessage();
708
674
  publishCallEvent(buildCallEvent('preflight'));
709
675
  emitToolStartedTrace();
710
676
  await this.writeSyntheticToolResult(toolUseId, turnId, tool.name, text, queue, undefined, sandboxFailure, undefined, activityIdentity);
@@ -976,7 +942,6 @@ export class ToolRuntime {
976
942
  await disposeManagedMutationAdmission(managedMutationAdmission);
977
943
  throw error;
978
944
  }
979
- await appendCallMessage();
980
945
  publishCallEvent(buildCallEvent('dispatch'));
981
946
  emitToolStartedTrace();
982
947
  if (durableAttempt) {
@@ -1225,18 +1190,6 @@ export class ToolRuntime {
1225
1190
  commandHash: denialKey,
1226
1191
  });
1227
1192
  }
1228
- const resultMsg = {
1229
- type: 'tool_result',
1230
- id: this.input.newId(),
1231
- turnId,
1232
- ts: this.input.now(),
1233
- toolUseId,
1234
- isError: toolResultStatus !== 'success',
1235
- content,
1236
- durationMs,
1237
- ...activityIdentity,
1238
- };
1239
- await this.input.appendMessage(resultMsg);
1240
1193
  queue.push({
1241
1194
  type: 'tool_result',
1242
1195
  id: durableOutcome?.id ?? this.input.newId(),
@@ -1345,18 +1298,6 @@ export class ToolRuntime {
1345
1298
  const projected = this.projectToolResult(tool, turnId, toolUseId, executionArgs, terminalResult);
1346
1299
  const modelProjection = isPromiseLike(projected) ? await projected : projected;
1347
1300
  const durableOutcome = await durableAttempt?.commitOutcome(terminalFailure.content, true, modelProjection, durationMs);
1348
- const resultMsg = {
1349
- type: 'tool_result',
1350
- id: this.input.newId(),
1351
- turnId,
1352
- ts: this.input.now(),
1353
- toolUseId,
1354
- isError: true,
1355
- content: terminalFailure.content,
1356
- durationMs,
1357
- ...activityIdentity,
1358
- };
1359
- await this.input.appendMessage(resultMsg);
1360
1301
  queue.push({
1361
1302
  type: 'tool_result',
1362
1303
  id: durableOutcome?.id ?? this.input.newId(),
@@ -2134,6 +2075,7 @@ export class ToolRuntime {
2134
2075
  sessionId: this.input.sessionId,
2135
2076
  requestId,
2136
2077
  decision: 'deny',
2078
+ closureReason: 'turn_stopped',
2137
2079
  }).then(() => undefined));
2138
2080
  }
2139
2081
  };
@@ -78,6 +78,7 @@
78
78
  "./plugin-composition-loader": "./dist/plugin-composition-loader.js",
79
79
  "./plugin-kernel": "./dist/plugin-kernel.js",
80
80
  "./plugin-runtime": "./dist/plugin-runtime.js",
81
+ "./plugin-tool-service": "./dist/plugin-tool-service.js",
81
82
  "./process-tree-terminator": "./dist/process-tree-terminator.js",
82
83
  "./provider-request-telemetry": "./dist/provider-request-telemetry.js",
83
84
  "./request-customization-fetch": "./dist/request-customization-fetch.js",
@@ -106,6 +107,7 @@
106
107
  "./tool-availability": "./dist/tool-availability.js",
107
108
  "./tool-free-model-call": "./dist/tool-free-model-call.js",
108
109
  "./tool-result-archive": "./dist/tool-result-archive.js",
110
+ "./ledger-tool-result-archive-reader": "./dist/ledger-tool-result-archive-reader.js",
109
111
  "./tool-result-archive-capability": "./dist/tool-result-archive-capability.js",
110
112
  "./tool-result-archive-resource": "./dist/tool-result-archive-resource.js",
111
113
  "./tool-runtime": "./dist/tool-runtime.js",
@@ -102,6 +102,11 @@ export class RuntimeHostSessionProjector {
102
102
  }
103
103
  if (isRuntimeHostTerminalTurn(root))
104
104
  return events;
105
+ // Re-derive the running compaction row on reconnect / restart: the Host keeps
106
+ // the compaction Turn alive, so a reconnecting client learns of it here.
107
+ if (root.rootExecutionKind === 'context_compact') {
108
+ events.push(contextCompactionStartedEvent(root, this.#now()));
109
+ }
105
110
  let seededAssistantText = false;
106
111
  if (includeAssistantText) {
107
112
  for (const accumulator of this.#accumulators.values()) {
@@ -362,6 +367,18 @@ export class RuntimeHostSessionProjector {
362
367
  }
363
368
  if (startedTurn)
364
369
  this.#accumulators.clear();
370
+ // Emit the presentation-only compaction-started event when the root Turn
371
+ // FIRST becomes a `context_compact` run, not only when the runId changes.
372
+ // The real lifecycle is `admitted (no rootExecutionKind) → running/
373
+ // context_compact` at the SAME runId, so gating on startedTurn would miss
374
+ // the live transition and only surface the row on reconnect via seedActive.
375
+ const rootIsCompaction = !!root && !isRuntimeHostTerminalTurn(root) && root.rootExecutionKind === 'context_compact';
376
+ const previousWasCompaction = !!previousRoot &&
377
+ !isRuntimeHostTerminalTurn(previousRoot) &&
378
+ previousRoot.rootExecutionKind === 'context_compact';
379
+ if (root && rootIsCompaction && !previousWasCompaction) {
380
+ events.push(contextCompactionStartedEvent(root, this.#now()));
381
+ }
365
382
  const retry = liveProviderRetryEvent(previousRoot, root, this.#now());
366
383
  if (retry)
367
384
  events.push(retry);
@@ -399,6 +416,10 @@ export class RuntimeHostSessionProjector {
399
416
  turnId: root.turnId,
400
417
  ts: this.#now(),
401
418
  stopReason: 'end_turn',
419
+ // Forward the typed compaction outcome already carried by the canonical
420
+ // Turn snapshot so the renderer can settle the running toast and show the
421
+ // terminal state. This projects an existing snapshot field (no turn-state
422
+ // persistence), so checkpointId stays a string.
402
423
  ...(root.contextCompactionOutcome
403
424
  ? { contextCompactionOutcome: root.contextCompactionOutcome }
404
425
  : {}),
@@ -456,6 +477,20 @@ function projectMessageRetractionEvents(previous, next, ts) {
456
477
  outcome: 'retracted',
457
478
  }));
458
479
  }
480
+ /**
481
+ * Presentation-only event that drives the renderer's live "compacting" row.
482
+ * Emitted on both the live transition (`accept`) and reconnect (`seedActive`)
483
+ * with a deterministic id keyed on the run, so a reconnect re-emits it
484
+ * idempotently.
485
+ */
486
+ function contextCompactionStartedEvent(turn, now) {
487
+ return {
488
+ type: 'context_compaction_started',
489
+ id: `host-compaction-started:${turn.runId}`,
490
+ turnId: turn.turnId,
491
+ ts: now,
492
+ };
493
+ }
459
494
  export function projectRuntimeHostInteractionRequest(interaction, now) {
460
495
  const base = {
461
496
  id: `host-interaction:${interaction.interactionId}:${interaction.revision}`,
@@ -248,7 +248,15 @@ export async function connectOrSpawnRuntimeHostWithDependencies(input, dependenc
248
248
  }
249
249
  const managedLaunchRejection = runtimeHostManagedLaunchRejection(managedDeployment, managedLaunchClaim, 'on_demand');
250
250
  if (managedLaunchRejection !== undefined) {
251
- return { kind: 'failed', reason: managedLaunchRejection };
251
+ // A managed endpoint that accepted a connection but did not answer
252
+ // is temporarily unavailable, not evidence that the client needs a
253
+ // new operator. Keep reconnecting without ever launching a replacement.
254
+ return {
255
+ kind: 'failed',
256
+ reason: managedLaunchRejection === 'managed_root_requires_operator' && sawUnresponsiveEndpoint
257
+ ? 'host_unresponsive'
258
+ : managedLaunchRejection,
259
+ };
252
260
  }
253
261
  try {
254
262
  const remaining = deadline - performance.now();
@@ -79,6 +79,7 @@ export class RuntimeHostRequestInterruptedError extends Error {
79
79
  }
80
80
  }
81
81
  class RuntimeHostConnectionImpl {
82
+ cooperativeHandoff;
82
83
  rootId;
83
84
  hostEpoch;
84
85
  connectionId;
@@ -122,6 +123,7 @@ class RuntimeHostConnectionImpl {
122
123
  this.hostEpoch = accepted.hostEpoch;
123
124
  this.connectionId = accepted.connectionId;
124
125
  this.selectedProtocol = accepted.selectedProtocol;
126
+ this.cooperativeHandoff = accepted.cooperativeHandoff;
125
127
  this.compositionId = accepted.compositionId;
126
128
  this.compositionRevision = accepted.compositionRevision;
127
129
  this.#getPeerPath = options?.getPeerPath ?? (() => options?.peerPath);
@@ -944,6 +946,7 @@ async function exchangeRuntimeHostHandshake(input) {
944
946
  const helloProtocol = input.helloProtocol ?? input.protocol;
945
947
  const hello = {
946
948
  kind: 'hello',
949
+ activitySnapshotVersion: 2,
947
950
  clientInstanceId: input.clientInstanceId,
948
951
  surface: 'desktop',
949
952
  protocolMin: helloProtocol.min,
@@ -0,0 +1,179 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ /** Shared consequence-oriented copy, not a second lifecycle policy. */
20
+ export function formatHostHandoff(view, locale) {
21
+ const zh = locale !== 'en';
22
+ const tw = locale === 'zh-TW';
23
+ const titles = tw
24
+ ? {
25
+ busy: '背景服務仍在使用中',
26
+ activity_unknown: '需要確認是否停止背景服務',
27
+ operator_required: '背景服務需要手動更新',
28
+ repair_required: '背景服務需要修復',
29
+ retry_required: '暫時無法完成交接',
30
+ }
31
+ : zh
32
+ ? {
33
+ busy: '后台服务仍在使用中',
34
+ activity_unknown: '需要确认是否停止后台服务',
35
+ operator_required: '后台服务需要手动更新',
36
+ repair_required: '后台服务需要修复',
37
+ retry_required: '暂时无法完成交接',
38
+ }
39
+ : {
40
+ busy: 'Your background service is still in use',
41
+ activity_unknown: 'Confirm before stopping the service',
42
+ operator_required: 'The background service needs a manual update',
43
+ repair_required: 'Your background service needs repair',
44
+ retry_required: 'The handoff could not finish yet',
45
+ };
46
+ const descriptions = tw
47
+ ? {
48
+ busy: '其他連線或正在執行的工作阻止了自動交接。停止並繼續可能中斷這些工作。',
49
+ activity_unknown: '背景服務與目前用戶端不相容,且無法確認有哪些工作仍在執行。停止並繼續會重新啟動服務,可能中斷其他視窗或裝置上的工作。',
50
+ operator_required: `目前無法從這裡更新背景服務。請透過 ${view.target.name} 上管理此服務的應用程式或命令更新,再重試。`,
51
+ repair_required: '上次啟動或交接未能完成。可以安全重試;若仍失敗,請複製診斷資訊。',
52
+ retry_required: '服務狀態發生了變化,或交接尚未完成。可以安全重試,不會預設中斷工作。',
53
+ }
54
+ : zh
55
+ ? {
56
+ busy: '其它连接或正在执行的工作阻止了自动交接。停止并继续可能中断这些工作。',
57
+ activity_unknown: '后台服务与当前客户端不兼容,且无法确认有哪些工作仍在运行。停止并继续会重新启动服务,可能中断其他窗口或设备上的工作。',
58
+ operator_required: `目前无法从这里更新后台服务。请通过 ${view.target.name} 上管理此服务的应用或命令更新,然后重试。`,
59
+ repair_required: '上次启动或交接未能完成。可以安全重试;若仍失败,请复制诊断信息。',
60
+ retry_required: '服务状态发生了变化,或交接尚未完成。可以安全重试,不会默认中断工作。',
61
+ }
62
+ : {
63
+ busy: 'Other connections or work in progress prevent an automatic handoff. Stopping the service may interrupt that work.',
64
+ activity_unknown: 'The background service is incompatible with this client, and its active work is unknown. Stop and continue restarts it and may interrupt work in other windows or devices.',
65
+ operator_required: `This client cannot update the background service here. Use its managing app or operator command on ${view.target.name}, then retry.`,
66
+ repair_required: 'The last startup or handoff did not finish. Retry safely, or copy diagnostics if it still fails.',
67
+ retry_required: 'The service changed or the handoff has not finished. A safe retry will not interrupt work by default.',
68
+ };
69
+ if (view.recoveryBlocker && view.reason === 'operator_required') {
70
+ const guidance = zh
71
+ ? tw
72
+ ? {
73
+ managed: '此背景服務由已安裝的管理程式維護。請在服務的管理應用程式中更新,再回到這裡重試。',
74
+ owner: '此背景服務屬於另一個 Maka 安裝。請使用管理它的 Maka 安裝更新,再重試。',
75
+ installation: '這次啟動使用暫存安裝,無法接管現有背景服務。請使用已安裝的 Maka 更新服務,再重試。',
76
+ identity: '無法確認舊背景服務的處理程序身分,因此不能安全停止它。請關閉啟動它的 Maka 或透過其管理程式停止服務,再重試。',
77
+ }
78
+ : {
79
+ managed: '此后台服务由已安装的管理程序维护。请在服务的管理应用中更新,再回到这里重试。',
80
+ owner: '此后台服务属于另一个 Maka 安装。请使用管理它的 Maka 安装更新,然后重试。',
81
+ installation: '本次启动使用临时安装,无法接管现有后台服务。请使用已安装的 Maka 更新服务,然后重试。',
82
+ identity: '无法确认旧后台服务的进程身份,因此不能安全停止它。请关闭启动它的 Maka 或通过其管理程序停止服务,然后重试。',
83
+ }
84
+ : {
85
+ managed: 'An installed operator manages this background service. Update it through its managing app, then return here and retry.',
86
+ owner: 'Another Maka installation owns this background service. Update it using that installation, then retry.',
87
+ installation: 'This temporary installation cannot take over the existing background service. Update it using an installed Maka, then retry.',
88
+ identity: 'The old background process could not be identified safely. Close the Maka instance that started it or stop it through its operator, then retry.',
89
+ };
90
+ descriptions.operator_required = guidance[view.recoveryBlocker];
91
+ }
92
+ const activity = view.activity;
93
+ const facts = activity
94
+ ? tw
95
+ ? `${activity.connections} 個連線 · ${activity.activeOperations} 個進行中的操作`
96
+ : zh
97
+ ? `${activity.connections} 个连接 · ${activity.activeOperations} 个进行中的操作`
98
+ : `${activity.connections} connections · ${activity.activeOperations} operations in progress`
99
+ : '';
100
+ const waiting = view.mayExitNaturally
101
+ ? tw
102
+ ? 'Maka 會持續檢查,並在可以安全繼續時自動繼續。'
103
+ : zh
104
+ ? 'Maka 会持续检查,并在可以安全继续时自动继续。'
105
+ : 'Maka keeps checking and continues automatically when it is safe.'
106
+ : tw
107
+ ? 'Maka 會持續檢查。若狀態沒有改變,等待或重試不會解決此問題。'
108
+ : zh
109
+ ? 'Maka 会持续检查。若状态没有变化,等待或重试不会解决此问题。'
110
+ : 'Maka keeps checking. Waiting or retrying will not resolve this unless the service state changes.';
111
+ const repairNotice = view.operation === 'repair'
112
+ ? tw
113
+ ? '修復將使用目前應用程式配套的版本,可能替換現有服務版本。'
114
+ : zh
115
+ ? '修复将使用当前应用配套的版本,可能替换现有服务版本。'
116
+ : 'Repair uses the version supplied with this app and may replace the installed service version.'
117
+ : '';
118
+ const labels = tw
119
+ ? {
120
+ cancel: '取消',
121
+ retry: '安全重試',
122
+ interrupt: view.operation === 'repair' ? '中斷並修復' : '停止並繼續',
123
+ }
124
+ : zh
125
+ ? {
126
+ cancel: '取消',
127
+ retry: '安全重试',
128
+ interrupt: view.operation === 'repair' ? '中断并修复' : '停止并继续',
129
+ }
130
+ : {
131
+ cancel: 'Cancel',
132
+ retry: 'Retry safely',
133
+ interrupt: view.operation === 'repair' ? 'Interrupt and repair' : 'Stop and continue',
134
+ };
135
+ const phases = tw
136
+ ? {
137
+ checking: '正在檢查服務',
138
+ staging: '正在準備更新',
139
+ pausing: '正在等待安全暫停點',
140
+ retiring: '正在停止舊服務',
141
+ replacing: '正在替換服務',
142
+ verifying: '正在確認工作區已就緒',
143
+ }
144
+ : zh
145
+ ? {
146
+ checking: '正在检查服务',
147
+ staging: '正在准备更新',
148
+ pausing: '正在等待安全暂停点',
149
+ retiring: '正在停止旧服务',
150
+ replacing: '正在替换服务',
151
+ verifying: '正在确认工作区已就绪',
152
+ }
153
+ : {
154
+ checking: 'Checking the service',
155
+ staging: 'Preparing the update',
156
+ pausing: 'Waiting for a safe pause point',
157
+ retiring: 'Stopping the previous service',
158
+ replacing: 'Replacing the service',
159
+ verifying: 'Verifying your workspace is ready',
160
+ };
161
+ return {
162
+ title: view.state === 'progress'
163
+ ? tw
164
+ ? '正在繼續開啟工作區'
165
+ : zh
166
+ ? '正在继续打开工作区'
167
+ : 'Continuing to your workspace'
168
+ : titles[view.reason],
169
+ description: view.state === 'progress' ? phases[view.phase ?? 'checking'] : descriptions[view.reason],
170
+ detail: view.state === 'progress'
171
+ ? tw
172
+ ? '正在完成交接或安全收尾,請稍候。'
173
+ : zh
174
+ ? '正在完成交接或安全收尾,请稍候。'
175
+ : 'Finishing the handoff or its safe recovery. Please wait.'
176
+ : [facts, waiting, repairNotice, view.operatorStep].filter(Boolean).join('\n'),
177
+ actions: view.actions.map((action) => ({ action, label: labels[action] })),
178
+ };
179
+ }