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
@@ -16,6 +16,7 @@
16
16
  * specific language governing permissions and limitations
17
17
  * under the License.
18
18
  */
19
+ import { agentRunCompositionFromEvents } from '@maka/core/agent-run';
19
20
  import { decodeRuntimeBoundaryCursor, } from '@maka/core/runtime-boundary';
20
21
  import { isTerminalRuntimeEvent, } from '@maka/core/runtime-event';
21
22
  import { isDeepStrictEqual } from 'node:util';
@@ -23,7 +24,7 @@ import { resolveEffectiveOrchestration, } from '@maka/core/orchestration';
23
24
  import { AgentRun, ContinuationStartCommitError, } from './agent-run.js';
24
25
  import { createSessionEventMapMemory, isLiveBackendSessionEvent, mapSessionEventToRuntimeEvent, } from './session-event-runtime-mapper.js';
25
26
  import { cloneAndFreezeRuntimeSnapshot } from './runtime-snapshot.js';
26
- import { buildStatusPatch, buildTurnStateMessage, normalizeStopSessionSource, turnHasRetainedOutput as messagesHaveRetainedOutput, } from './session-projection-helpers.js';
27
+ import { buildStatusPatch, normalizeStopSessionSource } from './session-projection-helpers.js';
27
28
  import { buildToolsForAgentDefinition } from './agent-catalog.js';
28
29
  import { loadModelProjectionTransitionsFromRunLedger } from './model-projection-transition-ledger.js';
29
30
  import { HistoryCompactCheckpointCoordinator, } from './history-compact-checkpoint-coordinator.js';
@@ -35,6 +36,8 @@ import { matchingTerminalRuntimeEvents, terminalRunStatusFromRuntimeEvent, } fro
35
36
  import { RuntimeMessageAuthorityInvariantError, } from './message-authority.js';
36
37
  import { RuntimeInteractionFailStopError, RuntimeInteractionInvariantError, bindRuntimeInteractionRun, isHostedInteractionRequestEvent, isHostedInteractionSettlementAckEvent, isShutdownCancelledInteractionAdmission, } from './interaction-authority.js';
37
38
  import { DeliveryAckQueue, isDeliveryAckQueueClosed } from './delivery-ack-queue.js';
39
+ import { runtimeHandoffPause } from '@maka/core/runtime-handoff';
40
+ import { preserveHandoffOpening } from './runtime-resume.js';
38
41
  export class SessionQuiescentMutationBusyError extends Error {
39
42
  sessionIds;
40
43
  name = 'SessionQuiescentMutationBusyError';
@@ -275,7 +278,7 @@ export class RuntimeKernel {
275
278
  await this.enterExecutionClaim(execution);
276
279
  const header = await this.deps.store.readHeader(sessionId);
277
280
  let workspaceIdentity;
278
- if (this.deps.safeBoundaryResumeEnabled === true && this.deps.inspectContinuationSafety) {
281
+ if (this.deps.inspectContinuationSafety) {
279
282
  try {
280
283
  workspaceIdentity = (await this.deps.inspectContinuationSafety(sessionId))
281
284
  .workspaceIdentity;
@@ -292,7 +295,6 @@ export class RuntimeKernel {
292
295
  runId: options.runId,
293
296
  userMessageId: options.userMessageId,
294
297
  durability: options.durability,
295
- store: this.deps.store,
296
298
  runStore: this.deps.runStore,
297
299
  runtimeEventStore: this.deps.runtimeEventStore,
298
300
  ...(this.deps.toolBoundaryProtocol
@@ -310,7 +312,7 @@ export class RuntimeKernel {
310
312
  unregisterRun: (active, activeRun) => this.unregisterParentRun(active, activeRun),
311
313
  updateHeader: (targetSessionId, patch) => this.updateHeader(targetSessionId, patch),
312
314
  updateStatus: (targetSessionId, status, blockedReason, ts) => this.updateStatus(targetSessionId, status, blockedReason, ts),
313
- appendTurnState: (targetSessionId, turnId, status, lineage, options) => this.appendTurnState(targetSessionId, turnId, status, lineage, options),
315
+ ...this.messageProjectionHook(),
314
316
  },
315
317
  });
316
318
  if (options.admitTurn && (await options.admitTurn()) === 'cancelled') {
@@ -382,15 +384,28 @@ export class RuntimeKernel {
382
384
  const sourceEvents = await revalidateContinuationBoundary(continuationAuthority, continuation, admissionRoute);
383
385
  assertContinuationSourceUnchanged(continuation, sourceRun, sourceEvents);
384
386
  await this.revalidateContinuationSafety(continuation);
387
+ if (!this.deps.store.hasExplicitSandboxBoundaryDenial) {
388
+ throw new Error('Continuation requires authoritative sandbox boundary decision lookup');
389
+ }
390
+ const inheritedSandboxBoundaryDenied = await this.deps.store.hasExplicitSandboxBoundaryDenial(continuation.boundary.segments.map((segment) => segment.identity));
391
+ const handoffSourceComposition = continuation.handoffRootRunId !== undefined
392
+ ? agentRunCompositionFromEvents(await this.deps.runStore.readEvents(continuation.sessionId, sourceRun.runId))
393
+ : undefined;
394
+ if (continuation.handoffRootRunId !== undefined && !handoffSourceComposition) {
395
+ throw new RuntimeContinuationRevalidationError('source_identity_changed', 'Cooperative handoff source has no durable Run Composition');
396
+ }
385
397
  const userInput = {
386
398
  turnId: continuation.turnId,
387
399
  text: '',
388
- parentTurnId: continuation.sourceTurnId,
400
+ ...(continuation.handoffRootRunId === undefined
401
+ ? { parentTurnId: continuation.sourceTurnId }
402
+ : {}),
389
403
  };
390
404
  const effectiveOrchestration = effectiveOrchestrationForRun(sourceRun, header);
391
405
  const effectiveToolMode = effectiveToolModeForRun(sourceRun);
392
406
  const claimedAt = this.deps.now();
393
407
  const targetOpening = continuationTargetOpeningForExecution({
408
+ sourceOpening: sourceRun.opening,
394
409
  continuation,
395
410
  sessionHeader: header,
396
411
  userInput,
@@ -407,7 +422,7 @@ export class RuntimeKernel {
407
422
  await this.deps.continuationFailpoint?.('after_continuation_claim_committed');
408
423
  const existingClaim = sessionRuns.find((candidate) => {
409
424
  const source = candidate.opening.source;
410
- return (source.kind === 'continuation' &&
425
+ return (source.kind !== 'fresh' &&
411
426
  source.sourceRunId === continuation.sourceRunId &&
412
427
  source.sourceRuntimeEventHighWater === continuation.sourceRuntimeEventHighWater);
413
428
  });
@@ -423,10 +438,11 @@ export class RuntimeKernel {
423
438
  sessionId: continuation.sessionId,
424
439
  header,
425
440
  userInput,
426
- runLineage: { parentRunId: continuation.sourceRunId },
441
+ runLineage: continuation.handoffRootRunId !== undefined
442
+ ? sourceRun.opening.lineage
443
+ : { parentRunId: continuation.sourceRunId },
427
444
  runId: continuation.runId,
428
445
  invocationId: continuation.invocationId,
429
- store: this.deps.store,
430
446
  runStore: this.deps.runStore,
431
447
  runtimeEventStore: this.deps.runtimeEventStore,
432
448
  ...(continuationToolBoundaryProtocol
@@ -440,6 +456,9 @@ export class RuntimeKernel {
440
456
  // against the opening it computes, so every continuation proves the claim
441
457
  // still authorises the run about to execute.
442
458
  claimedOpening: claim.targetOpening,
459
+ ...(continuation.handoffRootRunId !== undefined
460
+ ? { handoffSourceOpening: sourceRun.opening, handoffSourceComposition }
461
+ : {}),
443
462
  claimedOpenedAt: claimedAt,
444
463
  effectiveToolMode,
445
464
  continuationFailpoint: this.deps.continuationFailpoint,
@@ -501,7 +520,7 @@ export class RuntimeKernel {
501
520
  unregisterRun: (active, activeRun) => this.unregisterParentRun(active, activeRun),
502
521
  updateHeader: (targetSessionId, patch) => this.updateHeader(targetSessionId, patch),
503
522
  updateStatus: (targetSessionId, status, blockedReason, ts) => this.updateStatus(targetSessionId, status, blockedReason, ts),
504
- appendTurnState: (targetSessionId, turnId, status, lineage, options) => this.appendTurnState(targetSessionId, turnId, status, lineage, options),
523
+ ...this.messageProjectionHook(),
505
524
  },
506
525
  });
507
526
  this.attachExecutionClaim(execution, run);
@@ -509,7 +528,7 @@ export class RuntimeKernel {
509
528
  sessionId: continuation.sessionId,
510
529
  turnId: continuation.turnId,
511
530
  runId: continuation.runId,
512
- }, options.onRunStarted, () => this.revalidateContinuationSafety(continuation));
531
+ }, options, () => this.revalidateContinuationSafety(continuation), inheritedSandboxBoundaryDenied);
513
532
  }
514
533
  async *compactSession(sessionId, input = {}) {
515
534
  const execution = this.takeExecutionClaim(sessionId);
@@ -550,7 +569,6 @@ export class RuntimeKernel {
550
569
  userInput: { turnId, text: '' },
551
570
  rootExecutionKind: 'context_compact',
552
571
  ...(input.hostedRoot ? { runId: input.hostedRoot.runId } : {}),
553
- store: this.deps.store,
554
572
  runStore: this.deps.runStore,
555
573
  runtimeEventStore: this.deps.runtimeEventStore,
556
574
  ...(this.deps.toolBoundaryProtocol
@@ -568,7 +586,7 @@ export class RuntimeKernel {
568
586
  unregisterRun: (active, activeRun) => this.unregisterParentRun(active, activeRun),
569
587
  updateHeader: (targetSessionId, patch) => this.updateHeader(targetSessionId, patch),
570
588
  updateStatus: (targetSessionId, status, blockedReason, ts) => this.updateStatus(targetSessionId, status, blockedReason, ts),
571
- appendTurnState: (targetSessionId, nextTurnId, status, lineage, options) => this.appendTurnState(targetSessionId, nextTurnId, status, lineage, options),
589
+ ...this.messageProjectionHook(),
572
590
  },
573
591
  });
574
592
  this.attachExecutionClaim(execution, run);
@@ -593,6 +611,7 @@ export class RuntimeKernel {
593
611
  await this.finalizeFailedRunStart(owners, run, execution, error);
594
612
  return;
595
613
  }
614
+ let notedTerminal = false;
596
615
  try {
597
616
  if (run.isStopped())
598
617
  return;
@@ -631,22 +650,25 @@ export class RuntimeKernel {
631
650
  runId: run.runId,
632
651
  turnId: run.turnId,
633
652
  });
653
+ // Ahead of the usage row, because the ledger seals on its terminal fact:
654
+ // a note queued behind one this compaction may already own would be
655
+ // refused, and the reader would never learn the summary was skipped.
656
+ if (result.outcome.kind === 'failed') {
657
+ await run.recordSystemNote('context_compaction_failed_open').catch(() => { });
658
+ notedTerminal = true;
659
+ }
660
+ else if (result.outcome.kind === 'compacted') {
661
+ // Explicit compaction runs on its own turn and never enters the
662
+ // send-flow note block, so the "compacted" note is written here. The
663
+ // next user send passively replays this standalone checkpoint, which
664
+ // `shouldAppendContextCompactedNote` suppresses, so there is no
665
+ // duplicate.
666
+ await run.recordSystemNote('context_compacted').catch(() => { });
667
+ notedTerminal = true;
668
+ }
634
669
  await run.acceptMappedEvent(tokenUsageEvent, mapSessionEventToRuntimeEvent(tokenUsageEvent, eventContext), { requireTerminalWrite: true });
635
670
  if (run.isStopped())
636
671
  return;
637
- await run.recordStoredSessionEvent(tokenUsageEvent);
638
- if (run.isStopped())
639
- return;
640
- if (result.outcome.kind === 'failed') {
641
- const note = {
642
- type: 'system_note',
643
- id: this.deps.newId(),
644
- turnId: run.turnId,
645
- ts: this.deps.now(),
646
- kind: 'context_compaction_failed_open',
647
- };
648
- await this.deps.store.appendMessage(sessionId, note).catch(() => { });
649
- }
650
672
  yield tokenUsageEvent;
651
673
  if (run.isStopped())
652
674
  return;
@@ -656,6 +678,13 @@ export class RuntimeKernel {
656
678
  yield completeEvent;
657
679
  }
658
680
  catch (error) {
681
+ // A thrown compaction still owns a fail-open note — but not when the throw
682
+ // is a stop, which must leave no row. The note goes ahead of the failure
683
+ // because the ledger seals on its terminal fact; the internal compaction
684
+ // Turn has no user timeline for a failure banner.
685
+ if (!notedTerminal && !run.isStopped()) {
686
+ await run.recordSystemNote('context_compaction_failed_open').catch(() => { });
687
+ }
659
688
  await run.recordFailure(error);
660
689
  throw error;
661
690
  }
@@ -709,14 +738,6 @@ export class RuntimeKernel {
709
738
  }
710
739
  const interactionRun = owners.interactionRun;
711
740
  const messageOwner = owners.messageOwner;
712
- let pullSteering;
713
- let ackSteering;
714
- let nackSteering;
715
- if (messageOwner) {
716
- pullSteering = () => messageOwner?.pull() ?? [];
717
- ackSteering = (leaseIds) => messageOwner?.ack(leaseIds);
718
- nackSteering = (leaseIds) => messageOwner?.nack(leaseIds);
719
- }
720
741
  const stopBackend = this.stopBackendFor(begin.backend);
721
742
  const eventContext = this.runtimeEventMapContext({
722
743
  sessionId,
@@ -730,6 +751,7 @@ export class RuntimeKernel {
730
751
  backend: begin.backend,
731
752
  stopBackend,
732
753
  beforeDispatch: () => this.assertRunCanDispatch(run, begin.backend),
754
+ hasCommittedHandoff: () => run.hasCommittedHandoff(),
733
755
  ...(interactionRun ? { hostedInteraction: interactionRun } : {}),
734
756
  abortSignal: abortController.signal,
735
757
  eventContext,
@@ -738,9 +760,8 @@ export class RuntimeKernel {
738
760
  runId: run.runId,
739
761
  ...begin.backendInput,
740
762
  headAnchorRuntimeEvent: begin.initialRuntimeEvent,
741
- ...(pullSteering ? { pullSteering } : {}),
742
- ...(ackSteering ? { ackSteering } : {}),
743
- ...(nackSteering ? { nackSteering } : {}),
763
+ handoffBoundary: (signal, remainingSteps) => run.reachHandoffBoundary(signal, remainingSteps),
764
+ ...runtimeSteeringInput(owners.messageOwner),
744
765
  },
745
766
  onSessionEvent: async (sessionEvent, runtimeEvent) => {
746
767
  this.assertInteractionPublication(interactionRun, sessionEvent);
@@ -822,7 +843,7 @@ export class RuntimeKernel {
822
843
  }
823
844
  }
824
845
  }
825
- async *runAgentContinuation(continuation, admissionRoute, run, execution, messageOwner, onRunStarted, revalidateSafety) {
846
+ async *runAgentContinuation(continuation, admissionRoute, run, execution, messageOwner, options = {}, revalidateSafety, inheritedSandboxBoundaryDenied = false) {
826
847
  const sessionEvents = new DeliveryAckQueue();
827
848
  const { abortController, release: releaseExecutionAbort } = this.inheritExecutionAbort(execution);
828
849
  let flowDone = false;
@@ -845,7 +866,15 @@ export class RuntimeKernel {
845
866
  });
846
867
  return started;
847
868
  });
848
- await onRunStarted?.();
869
+ await options.onRunStarted?.();
870
+ const stop = options.stopBeforeDispatch?.();
871
+ if (stop) {
872
+ run.stop(stop.source, stop.workHubActionId);
873
+ releaseExecutionAbort();
874
+ await owners.finalize();
875
+ owners.releaseMessage();
876
+ return;
877
+ }
849
878
  }
850
879
  catch (error) {
851
880
  releaseExecutionAbort();
@@ -869,6 +898,7 @@ export class RuntimeKernel {
869
898
  })(),
870
899
  ...(run.toolBoundaryProtocol ? { toolBoundaryProtocol: run.toolBoundaryProtocol } : {}),
871
900
  });
901
+ continuationMetadata.sandboxBoundaryDenied = inheritedSandboxBoundaryDenied;
872
902
  }
873
903
  catch (error) {
874
904
  releaseExecutionAbort();
@@ -889,6 +919,19 @@ export class RuntimeKernel {
889
919
  backend: begin.backend,
890
920
  stopBackend,
891
921
  beforeDispatch: () => this.assertRunCanDispatch(run, begin.backend),
922
+ ...(continuation.handoffRootRunId !== undefined
923
+ ? {
924
+ prepareBeforeDispatch: async () => {
925
+ this.assertRunCanDispatch(run, begin.backend);
926
+ if (!begin.backend.prepareRunComposition) {
927
+ throw new Error('Backend does not support cooperative handoff composition preparation');
928
+ }
929
+ await begin.backend.prepareRunComposition({ runId: run.runId, turnId: run.turnId });
930
+ run.assertRunCompositionCommitted();
931
+ },
932
+ }
933
+ : {}),
934
+ hasCommittedHandoff: () => run.hasCommittedHandoff(),
892
935
  ...(interactionRun ? { hostedInteraction: interactionRun } : {}),
893
936
  abortSignal: abortController.signal,
894
937
  eventContext,
@@ -902,6 +945,21 @@ export class RuntimeKernel {
902
945
  runtimeContext: continuation.runtimeContext,
903
946
  runtimeContextInvocations: admissionRoute.invocations,
904
947
  continuation: continuationMetadata,
948
+ ...runtimeSteeringInput(owners.messageOwner),
949
+ ...(continuation.handoffRootRunId !== undefined
950
+ ? {
951
+ maxSteps: continuation.handoffRemainingSteps,
952
+ // The original user anchor remains in the authenticated replay;
953
+ // a physical successor must not invent another user message.
954
+ headAnchorRuntimeEvent: continuation.runtimeContext.find((event) => event.runId === continuation.handoffRootRunId &&
955
+ event.turnId === continuation.turnId &&
956
+ event.role === 'user' &&
957
+ (event.author === 'user' || event.author === 'host') &&
958
+ event.content?.kind === 'text' &&
959
+ event.content.steering !== true),
960
+ }
961
+ : {}),
962
+ handoffBoundary: (signal, remainingSteps) => run.reachHandoffBoundary(signal, remainingSteps),
905
963
  },
906
964
  onSessionEvent: async (sessionEvent, runtimeEvent) => {
907
965
  this.assertInteractionPublication(interactionRun, sessionEvent);
@@ -1103,6 +1161,9 @@ export class RuntimeKernel {
1103
1161
  let terminalAccepted = false;
1104
1162
  let errorSeen = false;
1105
1163
  try {
1164
+ if (input.prepareBeforeDispatch)
1165
+ await input.prepareBeforeDispatch();
1166
+ // Keep the final stop/admission check synchronous with backend.send.
1106
1167
  input.beforeDispatch();
1107
1168
  for await (const sessionEvent of input.backend.send({
1108
1169
  ...backendInput,
@@ -1118,7 +1179,7 @@ export class RuntimeKernel {
1118
1179
  if (terminalSeen)
1119
1180
  terminalAccepted = true;
1120
1181
  }
1121
- if (!terminalSeen) {
1182
+ if (!terminalSeen && !input.hasCommittedHandoff?.()) {
1122
1183
  for (const sessionEvent of this.missingTerminalSessionEvents(input.eventContext.turnId, !errorSeen)) {
1123
1184
  const runtimeEvent = mapSessionEventToRuntimeEvent(sessionEvent, input.eventContext, memory);
1124
1185
  await input.onSessionEvent(sessionEvent, runtimeEvent);
@@ -1239,14 +1300,6 @@ export class RuntimeKernel {
1239
1300
  delivery: { kind: 'pending' },
1240
1301
  };
1241
1302
  const needsRun = !target.runs.has(run.runId);
1242
- const projection = needsRun && run.isSessionInline() && !operation.turnProjections.has(run.runId)
1243
- ? {
1244
- id: this.deps.newId(),
1245
- turnId: run.turnId,
1246
- lineage: run.lineage,
1247
- projected: false,
1248
- }
1249
- : undefined;
1250
1303
  if (!existingOperation)
1251
1304
  this.stopOperations.set(sessionId, operation);
1252
1305
  if (!existingTarget) {
@@ -1261,8 +1314,6 @@ export class RuntimeKernel {
1261
1314
  sessionInline: run.isSessionInline(),
1262
1315
  stopCompleted: false,
1263
1316
  });
1264
- if (projection)
1265
- operation.turnProjections.set(run.runId, projection);
1266
1317
  }
1267
1318
  return operation;
1268
1319
  }
@@ -1273,15 +1324,6 @@ export class RuntimeKernel {
1273
1324
  abortSource,
1274
1325
  ts,
1275
1326
  statusProjected: false,
1276
- turnProjections: new Map(),
1277
- abortNote: {
1278
- type: 'system_note',
1279
- id: this.deps.newId(),
1280
- ts,
1281
- kind: 'abort',
1282
- ...(abortSource ? { data: { source: abortSource } } : {}),
1283
- },
1284
- abortNoteProjected: false,
1285
1327
  targets: new Map(),
1286
1328
  queue: Promise.resolve(),
1287
1329
  };
@@ -1346,29 +1388,11 @@ export class RuntimeKernel {
1346
1388
  await this.updateStatus(sessionId, 'aborted', undefined, operation.ts);
1347
1389
  operation.statusProjected = true;
1348
1390
  }
1349
- for (const projection of operation.turnProjections.values()) {
1350
- if (projection.projected)
1351
- continue;
1352
- projection.message ??= buildTurnStateMessage({
1353
- id: projection.id,
1354
- turnId: projection.turnId,
1355
- ts: operation.ts,
1356
- status: 'aborted',
1357
- lineage: projection.lineage,
1358
- ...(operation.abortSource ? { abortSource: operation.abortSource } : {}),
1359
- partialOutputRetained: await this.turnHasRetainedOutput(sessionId, projection.turnId),
1360
- });
1361
- await this.appendStopProjection(sessionId, projection.message);
1362
- projection.projected = true;
1363
- }
1364
- if (!operation.abortNoteProjected) {
1365
- await this.appendStopProjection(sessionId, operation.abortNote);
1366
- operation.abortNoteProjected = true;
1367
- }
1368
- // The Session projection above now reads as aborted. The ledger has to say
1369
- // the same thing before this stop reports success: a Run left non-terminal
1370
- // here stays that way, because the stream that would have finalized it is
1371
- // exactly the one the stop could not wake.
1391
+ // The ledger has to say this turn was aborted before the stop reports
1392
+ // success: a Run left non-terminal here stays that way, because the stream
1393
+ // that would have finalized it is exactly the one the stop could not wake.
1394
+ // Nothing else records the abort — the transcript reads it back off this
1395
+ // terminal fact.
1372
1396
  //
1373
1397
  // Without a Host interaction authority, Runtime owns terminal settlement.
1374
1398
  // A Hosted Run's terminal fact belongs to the Host, which also parks
@@ -1390,8 +1414,6 @@ export class RuntimeKernel {
1390
1414
  target.stopCompleted = true;
1391
1415
  }
1392
1416
  const completed = operation.statusProjected &&
1393
- operation.abortNoteProjected &&
1394
- [...operation.turnProjections.values()].every((projection) => projection.projected) &&
1395
1417
  [...operation.targets.values()].every((target) => target.delivery.kind !== 'pending' &&
1396
1418
  [...target.runs.values()].every((run) => run.stopCompleted));
1397
1419
  if (completed && this.stopOperations.get(sessionId) === operation) {
@@ -1404,16 +1426,6 @@ export class RuntimeKernel {
1404
1426
  }
1405
1427
  failures.throwIfAny(`Stop cleanup failed for session ${sessionId}`);
1406
1428
  }
1407
- async appendStopProjection(sessionId, message) {
1408
- const existing = (await this.deps.store.readMessages(sessionId)).find((candidate) => candidate.id === message.id);
1409
- if (existing) {
1410
- if (!isDeepStrictEqual(existing, message)) {
1411
- throw new Error(`stop projection ${message.id} conflicts with an existing message`);
1412
- }
1413
- return;
1414
- }
1415
- await this.deps.store.appendMessage(sessionId, message);
1416
- }
1417
1429
  async respondToSandboxBoundary(sessionId, response) {
1418
1430
  const key = interactionOwnerKey(sessionId, response.requestId);
1419
1431
  const owner = this.interactionRequestOwners.get(key);
@@ -1462,6 +1474,16 @@ export class RuntimeKernel {
1462
1474
  return run !== undefined && (turnId === undefined || run.turnId === turnId);
1463
1475
  });
1464
1476
  }
1477
+ requestRunHandoff(sessionId, runId, pause, signal) {
1478
+ if (!this.deps.inspectContinuationSafety)
1479
+ return undefined;
1480
+ for (const active of this.backendGenerationsFor(sessionId)) {
1481
+ const run = active.activeRuns.get(runId);
1482
+ if (run)
1483
+ return run.requestHandoff(pause, signal);
1484
+ }
1485
+ return undefined;
1486
+ }
1465
1487
  updateCachedHeader(sessionId, header) {
1466
1488
  const active = this.active.get(sessionId);
1467
1489
  if (active)
@@ -1656,6 +1678,7 @@ export class RuntimeKernel {
1656
1678
  recordRunTrace: (event) => {
1657
1679
  runFor(event.turnId)?.recordRunTrace(event);
1658
1680
  },
1681
+ recordSystemNote: (kind, turnId, data) => runFor(turnId)?.recordSystemNote(kind, data) ?? Promise.resolve(),
1659
1682
  ...(this.deps.runStore
1660
1683
  ? {
1661
1684
  // Resolved by runId rather than turnId: the canonical record names
@@ -1671,6 +1694,13 @@ export class RuntimeKernel {
1671
1694
  }
1672
1695
  return run.recordRunComposition(snapshot);
1673
1696
  },
1697
+ recordRequestComposition: (runId, snapshot) => {
1698
+ const run = this.active.get(sessionId)?.activeRuns.get(runId);
1699
+ if (!run) {
1700
+ return Promise.reject(new Error('No active AgentRun for Request Composition'));
1701
+ }
1702
+ return run.recordRequestComposition(snapshot);
1703
+ },
1674
1704
  loadHistoryCompactCheckpoint: () => this.historyCompactCoordinator.load(sessionId),
1675
1705
  recordHistoryCompactCheckpoint: (checkpoint, turnId) => this.historyCompactCoordinator.record(sessionId, checkpoint, runFor(turnId)),
1676
1706
  loadModelProjectionTransitions: async () => loadModelProjectionTransitionsFromRunLedger(this.deps.runStore, sessionId, await this.sessionRunIds(sessionId)),
@@ -2010,22 +2040,17 @@ export class RuntimeKernel {
2010
2040
  this.updateCachedHeader(sessionId, next);
2011
2041
  return next;
2012
2042
  }
2013
- async appendTurnState(sessionId, turnId, status, lineage = {}, options = {}) {
2014
- const ts = options.ts ?? this.deps.now();
2015
- await this.deps.store.appendMessage(sessionId, buildTurnStateMessage({
2016
- id: options.id ?? this.deps.newId(),
2017
- turnId,
2018
- ts,
2019
- status,
2020
- lineage,
2021
- ...(options.abortSource ? { abortSource: options.abortSource } : {}),
2022
- ...(options.errorClass !== undefined ? { errorClass: options.errorClass } : {}),
2023
- partialOutputRetained: await this.turnHasRetainedOutput(sessionId, turnId),
2024
- }));
2025
- }
2026
- async turnHasRetainedOutput(sessionId, turnId) {
2027
- const messages = await this.deps.store.readMessages(sessionId).catch(() => []);
2028
- return messagesHaveRetainedOutput(messages, turnId);
2043
+ /** Present only when the store keeps a Session catalog to project into. */
2044
+ messageProjectionHook() {
2045
+ const commit = this.deps.store.commitMessageCatalogProjection;
2046
+ if (!commit)
2047
+ return {};
2048
+ return {
2049
+ commitMessageProjection: async (sessionId, message) => {
2050
+ await commit.call(this.deps.store, sessionId, message);
2051
+ this.updateCachedHeader(sessionId, await this.deps.store.readHeader(sessionId));
2052
+ },
2053
+ };
2029
2054
  }
2030
2055
  }
2031
2056
  function requireRuntimeContinuationAuthority(store) {
@@ -2127,7 +2152,7 @@ function continuationTargetOpeningForExecution(input) {
2127
2152
  ...(userInput.agentId ? { agentId: userInput.agentId } : {}),
2128
2153
  ...(userInput.agentName ? { agentName: userInput.agentName } : {}),
2129
2154
  };
2130
- return {
2155
+ const opening = {
2131
2156
  kind: 'invocation_opened',
2132
2157
  protocol: 'invocation_opened_v1',
2133
2158
  route: sessionHeader.llmConnectionId === undefined
@@ -2171,6 +2196,7 @@ function continuationTargetOpeningForExecution(input) {
2171
2196
  },
2172
2197
  lineage,
2173
2198
  };
2199
+ return preserveHandoffOpening(continuation, opening, input.sourceOpening);
2174
2200
  }
2175
2201
  function consumeAdmittedRuntimeContinuation(input) {
2176
2202
  const { continuation } = input;
@@ -2247,7 +2273,9 @@ function assertRuntimeContinuationEnvelope(continuation) {
2247
2273
  }
2248
2274
  if (continuation.invocationId === continuation.sourceInvocationId ||
2249
2275
  continuation.runId === continuation.sourceRunId ||
2250
- continuation.turnId === continuation.sourceTurnId) {
2276
+ (continuation.handoffRootRunId === undefined
2277
+ ? continuation.turnId === continuation.sourceTurnId
2278
+ : continuation.turnId !== continuation.sourceTurnId)) {
2251
2279
  throw new Error('Runtime continuation must use fresh invocation, run, and turn identities');
2252
2280
  }
2253
2281
  }
@@ -2258,8 +2286,16 @@ function assertContinuationSourceUnchanged(continuation, sourceRun, sourceEvents
2258
2286
  throw new RuntimeContinuationRevalidationError('source_identity_changed', 'Runtime continuation source run identity changed after planning');
2259
2287
  }
2260
2288
  const terminalEvents = matchingTerminalRuntimeEvents(sourceRun, sourceEvents);
2289
+ const pause = terminalEvents.length === 1 ? runtimeHandoffPause(terminalEvents[0]) : undefined;
2261
2290
  if (terminalEvents.length !== 1 ||
2262
- terminalRunStatusFromRuntimeEvent(terminalEvents[0]) === undefined) {
2291
+ (continuation.handoffRootRunId === undefined
2292
+ ? Boolean(pause) || terminalRunStatusFromRuntimeEvent(terminalEvents[0]) === undefined
2293
+ : !pause ||
2294
+ pause.rootRunId !== continuation.handoffRootRunId ||
2295
+ pause.successorRunId !== continuation.runId ||
2296
+ pause.successorInvocationId !== continuation.invocationId ||
2297
+ pause.claimId !== continuation.claimId ||
2298
+ pause.remainingSteps !== continuation.handoffRemainingSteps)) {
2263
2299
  throw new RuntimeContinuationRevalidationError('source_terminal_changed', 'Runtime continuation source is no longer terminal');
2264
2300
  }
2265
2301
  if (sourceEvents.length !== continuation.sourceRuntimeEventHighWater) {
@@ -2319,6 +2355,15 @@ function deepFreezeContinuationValue(value) {
2319
2355
  }
2320
2356
  return Object.freeze(value);
2321
2357
  }
2358
+ function runtimeSteeringInput(owner) {
2359
+ return owner
2360
+ ? {
2361
+ pullSteering: () => owner.pull(),
2362
+ ackSteering: (ids) => owner.ack(ids),
2363
+ nackSteering: (ids) => owner.nack(ids),
2364
+ }
2365
+ : {};
2366
+ }
2322
2367
  class RuntimeRunOwnerScope {
2323
2368
  run;
2324
2369
  callbacks;