maka-agent 0.2.0-dev.30.20260912 → 0.2.0-dev.32.20260914

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 (245) hide show
  1. package/THIRD_PARTY_NOTICES.txt +392 -0
  2. package/dist/acp/maka-acp-agent.js +8 -2
  3. package/dist/acp/prompt-content.js +225 -0
  4. package/dist/acp/session-event-mapper.js +103 -0
  5. package/dist/acp/session-registry.js +654 -17
  6. package/dist/acp/stdio-server.js +10 -1
  7. package/dist/cli-core.js +1 -1
  8. package/dist/pi-transcript-tools.js +3 -2
  9. package/dist/pi-transcript.js +15 -6
  10. package/dist/runtime-host-session-channel.js +63 -9
  11. package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
  12. package/node_modules/@maka/core/dist/agent-graph-schedule.js +15 -4
  13. package/node_modules/@maka/core/dist/artifacts.js +6 -0
  14. package/node_modules/@maka/core/dist/attachments.js +7 -2
  15. package/node_modules/@maka/core/dist/durable-tool-result-projection.js +3 -1
  16. package/node_modules/@maka/core/dist/events.js +21 -0
  17. package/node_modules/@maka/core/dist/executor-id.js +22 -0
  18. package/node_modules/@maka/core/dist/external-session.js +18 -0
  19. package/node_modules/@maka/core/dist/goal.js +44 -2
  20. package/node_modules/@maka/core/dist/model-call-usage-projection.js +0 -13
  21. package/node_modules/@maka/core/dist/permission.js +0 -1
  22. package/node_modules/@maka/core/dist/runtime-boundary.js +73 -29
  23. package/node_modules/@maka/core/dist/runtime-event.js +25 -6
  24. package/node_modules/@maka/core/dist/runtime-handoff.js +10 -2
  25. package/node_modules/@maka/core/dist/runtime-logical-execution.js +39 -14
  26. package/node_modules/@maka/core/dist/session-send-projection.js +6 -3
  27. package/node_modules/@maka/core/dist/session.js +8 -2
  28. package/node_modules/@maka/core/dist/shell-run-result.js +1 -0
  29. package/node_modules/@maka/core/dist/shell-run.js +4 -0
  30. package/node_modules/@maka/core/dist/tool-result-archive-evidence.js +3 -1
  31. package/node_modules/@maka/core/dist/tool-result-record-schema.js +2 -1
  32. package/node_modules/@maka/core/dist/unified-diff.js +33 -26
  33. package/node_modules/@maka/core/dist/work-board.js +94 -1
  34. package/node_modules/@maka/core/package.json +1 -0
  35. package/node_modules/@maka/eval/dist/fleet-simulation.js +270 -0
  36. package/node_modules/@maka/eval/dist/fleet-store.js +243 -0
  37. package/node_modules/@maka/eval/dist/fleet-worker.js +125 -0
  38. package/node_modules/@maka/eval/dist/fleet.js +329 -0
  39. package/node_modules/@maka/eval/dist/index.js +3 -0
  40. package/node_modules/@maka/runtime/dist/agent-run.js +2 -17
  41. package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +55 -180
  42. package/node_modules/@maka/runtime/dist/ai-sdk-message-projection.js +43 -26
  43. package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +271 -382
  44. package/node_modules/@maka/runtime/dist/background-task-health-tool.js +104 -0
  45. package/node_modules/@maka/runtime/dist/bash-model-output.js +7 -1
  46. package/node_modules/@maka/runtime/dist/bash-tail-buffer.js +13 -52
  47. package/node_modules/@maka/runtime/dist/builtin-tools.js +59 -111
  48. package/node_modules/@maka/runtime/dist/child-fd-input.js +3 -2
  49. package/node_modules/@maka/runtime/dist/context-budget-policy.js +1 -11
  50. package/node_modules/@maka/runtime/dist/context-budget.js +12 -1
  51. package/node_modules/@maka/runtime/dist/conversation-copy.js +104 -9
  52. package/node_modules/@maka/runtime/dist/filesystem-executor.js +10 -6
  53. package/node_modules/@maka/runtime/dist/filesystem-worker/client.js +77 -19
  54. package/node_modules/@maka/runtime/dist/filesystem-worker/launch-spec.js +66 -55
  55. package/node_modules/@maka/runtime/dist/filesystem-worker/operations.js +34 -97
  56. package/node_modules/@maka/runtime/dist/filesystem-worker/protocol.js +25 -10
  57. package/node_modules/@maka/runtime/dist/filesystem-worker/worker-entry.js +2 -0
  58. package/node_modules/@maka/runtime/dist/glob-search.js +74 -0
  59. package/node_modules/@maka/runtime/dist/goal-continuation.js +78 -8
  60. package/node_modules/@maka/runtime/dist/goal-state.js +7 -0
  61. package/node_modules/@maka/runtime/dist/grep-search.js +155 -0
  62. package/node_modules/@maka/runtime/dist/history-compaction.js +3 -1
  63. package/node_modules/@maka/runtime/dist/ledger-tool-result-archive-reader.js +84 -94
  64. package/node_modules/@maka/runtime/dist/local-web-fetch.js +1 -1
  65. package/node_modules/@maka/runtime/dist/model-adapter.js +62 -53
  66. package/node_modules/@maka/runtime/dist/model-history.js +26 -8
  67. package/node_modules/@maka/runtime/dist/pipe-tail-collector.js +6 -9
  68. package/node_modules/@maka/runtime/dist/plugin-executor-backend.js +311 -0
  69. package/node_modules/@maka/runtime/dist/plugin-executor-service.js +344 -0
  70. package/node_modules/@maka/runtime/dist/provider-error-classification.js +7 -1
  71. package/node_modules/@maka/runtime/dist/provider-request-telemetry.js +35 -8
  72. package/node_modules/@maka/runtime/dist/read-page.js +231 -0
  73. package/node_modules/@maka/runtime/dist/request-projection.js +2 -15
  74. package/node_modules/@maka/runtime/dist/ripgrep-executable.js +62 -0
  75. package/node_modules/@maka/runtime/dist/ripgrep-guidance.js +81 -0
  76. package/node_modules/@maka/runtime/dist/runtime-event-backfill.js +7 -1
  77. package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +188 -20
  78. package/node_modules/@maka/runtime/dist/runtime-invocation-route.js +49 -0
  79. package/node_modules/@maka/runtime/dist/runtime-kernel.js +72 -150
  80. package/node_modules/@maka/runtime/dist/runtime-read-model.js +2 -3
  81. package/node_modules/@maka/runtime/dist/sandbox/linux-profile-path.js +7 -1
  82. package/node_modules/@maka/runtime/dist/sandbox/linux-sandbox.js +20 -5
  83. package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +3 -0
  84. package/node_modules/@maka/runtime/dist/session-manager.js +106 -64
  85. package/node_modules/@maka/runtime/dist/session-recap.js +9 -5
  86. package/node_modules/@maka/runtime/dist/shell-exec.js +7 -25
  87. package/node_modules/@maka/runtime/dist/shell-run-manager.js +10 -4
  88. package/node_modules/@maka/runtime/dist/shell-run-tool-result.js +2 -1
  89. package/node_modules/@maka/runtime/dist/shell-tools.js +6 -12
  90. package/node_modules/@maka/runtime/dist/stream-graph-schedule-reconcile.js +1 -0
  91. package/node_modules/@maka/runtime/dist/stream-graph-supervisor-tools.js +26 -4
  92. package/node_modules/@maka/runtime/dist/subagent-tools.js +7 -0
  93. package/node_modules/@maka/runtime/dist/tool-availability.js +0 -1
  94. package/node_modules/@maka/runtime/dist/tool-output.js +1 -1
  95. package/node_modules/@maka/runtime/dist/tool-result-archive-capability.js +24 -36
  96. package/node_modules/@maka/runtime/dist/tool-result-archive-resource.js +32 -527
  97. package/node_modules/@maka/runtime/dist/tool-result-archive-transition.js +17 -119
  98. package/node_modules/@maka/runtime/dist/tool-result-archive.js +7 -25
  99. package/node_modules/@maka/runtime/dist/tool-runtime.js +52 -471
  100. package/node_modules/@maka/runtime/dist/workers/filesystem-worker.js +6933 -3681
  101. package/node_modules/@maka/runtime/dist/workspace-executor.js +20 -24
  102. package/node_modules/@maka/runtime/package.json +5 -0
  103. package/node_modules/@maka/runtime-host/dist/adapter/session-projector.js +7 -2
  104. package/node_modules/@maka/runtime-host/dist/client/host-handoff-copy.js +185 -191
  105. package/node_modules/@maka/runtime-host/dist/client/reconnecting-connection.js +3 -0
  106. package/node_modules/@maka/runtime-host/dist/client/session-catalog-summary.js +1 -0
  107. package/node_modules/@maka/runtime-host/dist/protocol/external-session.js +24 -3
  108. package/node_modules/@maka/runtime-host/dist/protocol/index.js +8 -1
  109. package/node_modules/@maka/runtime-host/dist/protocol/message.js +2 -2
  110. package/node_modules/@maka/runtime-host/dist/protocol/operations.js +1 -0
  111. package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +42 -5
  112. package/node_modules/@maka/runtime-host/dist/protocol/session-catalog.js +31 -3
  113. package/node_modules/@maka/runtime-host/dist/protocol/session-continuity.js +8 -2
  114. package/node_modules/@maka/runtime-host/dist/protocol/turn.js +10 -2
  115. package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +38 -0
  116. package/node_modules/@maka/runtime-host/dist/server/child-agent-composition.js +1 -0
  117. package/node_modules/@maka/runtime-host/dist/server/execution-artifacts.js +3 -30
  118. package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +56 -8
  119. package/node_modules/@maka/runtime-host/dist/server/external-session-coordinator.js +14 -1
  120. package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +81 -7
  121. package/node_modules/@maka/runtime-host/dist/server/host-session-availability.js +10 -2
  122. package/node_modules/@maka/runtime-host/dist/server/hosted-execution-tool-profile.js +13 -13
  123. package/node_modules/@maka/runtime-host/dist/server/interaction-coordinator.js +65 -0
  124. package/node_modules/@maka/runtime-host/dist/server/plugin-platform-coordinator.js +6 -0
  125. package/node_modules/@maka/runtime-host/dist/server/plugin-platform.js +6 -0
  126. package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +1 -0
  127. package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +56 -16
  128. package/node_modules/@maka/runtime-host/dist/server/session-continuity-coordinator.js +9 -5
  129. package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +4 -0
  130. package/node_modules/@maka/runtime-host/dist/server/session-transcript-reader.js +88 -72
  131. package/node_modules/@maka/runtime-host/dist/server/web-fetch-tool.js +37 -1
  132. package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +21 -4
  133. package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +145 -1
  134. package/node_modules/@maka/storage/dist/agent-run-store.js +5 -2
  135. package/node_modules/@maka/storage/dist/claude-code-session-adapter.js +450 -234
  136. package/node_modules/@maka/storage/dist/claude-code-transcript-lineage.js +106 -77
  137. package/node_modules/@maka/storage/dist/execution-stores.js +2 -1
  138. package/node_modules/@maka/storage/dist/legacy-run-header.js +2 -2
  139. package/node_modules/@maka/storage/dist/model-call-usage-sql.js +1 -1
  140. package/node_modules/@maka/storage/dist/runtime-transcript-query.js +27 -14
  141. package/node_modules/@maka/storage/dist/session-store.js +12 -2
  142. package/node_modules/@maka/storage/dist/sqlite-long-term-memory-store.js +86 -12
  143. package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +69 -3
  144. package/node_modules/@maka/storage/dist/work-board-store.js +40 -1
  145. package/node_modules/balanced-match/LICENSE.md +23 -0
  146. package/node_modules/balanced-match/README.md +57 -0
  147. package/node_modules/balanced-match/dist/commonjs/index.js +59 -0
  148. package/node_modules/balanced-match/dist/commonjs/package.json +3 -0
  149. package/node_modules/balanced-match/dist/esm/index.js +54 -0
  150. package/node_modules/balanced-match/dist/esm/package.json +3 -0
  151. package/node_modules/balanced-match/package.json +68 -0
  152. package/node_modules/brace-expansion/LICENSE +23 -0
  153. package/node_modules/brace-expansion/README.md +105 -0
  154. package/node_modules/brace-expansion/dist/commonjs/index.js +289 -0
  155. package/node_modules/brace-expansion/dist/commonjs/package.json +3 -0
  156. package/node_modules/brace-expansion/dist/esm/index.js +285 -0
  157. package/node_modules/brace-expansion/dist/esm/package.json +3 -0
  158. package/node_modules/brace-expansion/package.json +64 -0
  159. package/node_modules/glob/LICENSE.md +63 -0
  160. package/node_modules/glob/README.md +1203 -0
  161. package/node_modules/glob/dist/commonjs/glob.js +248 -0
  162. package/node_modules/glob/dist/commonjs/has-magic.js +27 -0
  163. package/node_modules/glob/dist/commonjs/ignore.js +119 -0
  164. package/node_modules/glob/dist/commonjs/index.js +68 -0
  165. package/node_modules/glob/dist/commonjs/index.min.js +4 -0
  166. package/node_modules/glob/dist/commonjs/package.json +3 -0
  167. package/node_modules/glob/dist/commonjs/pattern.js +223 -0
  168. package/node_modules/glob/dist/commonjs/processor.js +301 -0
  169. package/node_modules/glob/dist/commonjs/walker.js +387 -0
  170. package/node_modules/glob/dist/esm/glob.js +244 -0
  171. package/node_modules/glob/dist/esm/has-magic.js +23 -0
  172. package/node_modules/glob/dist/esm/ignore.js +115 -0
  173. package/node_modules/glob/dist/esm/index.js +55 -0
  174. package/node_modules/glob/dist/esm/index.min.js +4 -0
  175. package/node_modules/glob/dist/esm/package.json +3 -0
  176. package/node_modules/glob/dist/esm/pattern.js +219 -0
  177. package/node_modules/glob/dist/esm/processor.js +294 -0
  178. package/node_modules/glob/dist/esm/walker.js +381 -0
  179. package/node_modules/glob/package.json +98 -0
  180. package/node_modules/minimatch/LICENSE.md +55 -0
  181. package/node_modules/minimatch/README.md +528 -0
  182. package/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js +14 -0
  183. package/node_modules/minimatch/dist/commonjs/ast.js +845 -0
  184. package/node_modules/minimatch/dist/commonjs/brace-expressions.js +150 -0
  185. package/node_modules/minimatch/dist/commonjs/escape.js +30 -0
  186. package/node_modules/minimatch/dist/commonjs/index.js +1127 -0
  187. package/node_modules/minimatch/dist/commonjs/package.json +3 -0
  188. package/node_modules/minimatch/dist/commonjs/unescape.js +38 -0
  189. package/node_modules/minimatch/dist/esm/assert-valid-pattern.js +10 -0
  190. package/node_modules/minimatch/dist/esm/ast.js +841 -0
  191. package/node_modules/minimatch/dist/esm/brace-expressions.js +146 -0
  192. package/node_modules/minimatch/dist/esm/escape.js +26 -0
  193. package/node_modules/minimatch/dist/esm/index.js +1114 -0
  194. package/node_modules/minimatch/dist/esm/package.json +3 -0
  195. package/node_modules/minimatch/dist/esm/unescape.js +34 -0
  196. package/node_modules/minimatch/package.json +73 -0
  197. package/node_modules/minipass/LICENSE.md +55 -0
  198. package/node_modules/minipass/README.md +825 -0
  199. package/node_modules/minipass/dist/commonjs/index.js +1038 -0
  200. package/node_modules/minipass/dist/commonjs/package.json +3 -0
  201. package/node_modules/minipass/dist/esm/index.js +1020 -0
  202. package/node_modules/minipass/dist/esm/package.json +3 -0
  203. package/node_modules/minipass/package.json +77 -0
  204. package/node_modules/path-scurry/LICENSE.md +55 -0
  205. package/node_modules/path-scurry/README.md +636 -0
  206. package/node_modules/path-scurry/dist/commonjs/index.js +2018 -0
  207. package/node_modules/path-scurry/dist/commonjs/package.json +3 -0
  208. package/node_modules/path-scurry/dist/esm/index.js +1983 -0
  209. package/node_modules/path-scurry/dist/esm/package.json +3 -0
  210. package/node_modules/path-scurry/node_modules/lru-cache/LICENSE.md +55 -0
  211. package/node_modules/path-scurry/node_modules/lru-cache/README.md +469 -0
  212. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel.js +7 -0
  213. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/index.js +1726 -0
  214. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/index.min.js +2 -0
  215. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/perf.js +10 -0
  216. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/diagnostics-channel-cjs.d.cts.map +1 -0
  217. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/diagnostics-channel.js +7 -0
  218. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.js +1726 -0
  219. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.min.js +2 -0
  220. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel.js +9 -0
  221. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/index.js +1726 -0
  222. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/index.min.js +2 -0
  223. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/perf.js +10 -0
  224. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/package.json +3 -0
  225. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/perf.js +10 -0
  226. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.js +4 -0
  227. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/index.js +1722 -0
  228. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/index.min.js +2 -0
  229. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/perf.js +7 -0
  230. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/diagnostics-channel-esm.d.mts.map +1 -0
  231. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/diagnostics-channel.js +19 -0
  232. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.js +1722 -0
  233. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.min.js +2 -0
  234. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/diagnostics-channel.js +6 -0
  235. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/index.js +1722 -0
  236. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/index.min.js +2 -0
  237. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/perf.js +7 -0
  238. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/package.json +3 -0
  239. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/perf.js +7 -0
  240. package/node_modules/path-scurry/node_modules/lru-cache/package.json +154 -0
  241. package/node_modules/path-scurry/package.json +72 -0
  242. package/package.json +1 -1
  243. package/node_modules/@maka/runtime/dist/active-tool-result-prune.js +0 -248
  244. package/node_modules/@maka/runtime/dist/active-tool-result-working-set.js +0 -218
  245. package/node_modules/@maka/runtime/dist/archive-read-tool.js +0 -115
@@ -34,12 +34,13 @@
34
34
  import { isWorkHubActionReceipt } from './workhub-action-result.js';
35
35
  import { isModelRetryDecision } from './model-failure.js';
36
36
  import { isRuntimeHandoffPause, runtimeHandoffPause, } from './runtime-handoff.js';
37
- import { isMessageContent, normalizeMessageContent, } from './events.js';
37
+ import { hasMeaningfulMessageContent, isMessageContent, normalizeMessageContent, } from './events.js';
38
38
  import { INTERACTION_ID_MAX_BYTES, INTERACTION_TOOL_NAME_MAX_BYTES, decodeInteractionRequest, } from './interaction.js';
39
39
  import { isPermissionMode, } from './permission.js';
40
40
  import { isCollaborationMode } from './collaboration.js';
41
41
  import { isAgentSwarmAuthorizationSource, isEffectiveOrchestrationSource, isOrchestrationMode, } from './orchestration.js';
42
42
  import { isToolMode } from './tool-mode.js';
43
+ import { isExecutorId } from './executor-id.js';
43
44
  import { isRuntimeSystemNoteKind, } from './session.js';
44
45
  import { decodeTurnOrigin } from './turn-origin.js';
45
46
  import { defineObjectShape, hasExactShape, isFiniteNumber, isOptionalMember, isOptionalString, isRecord, isStringArray, } from './record-schema.js';
@@ -172,6 +173,7 @@ export function runtimeEventEnvelopeValueDomains() {
172
173
  const RUNTIME_EVENT_SHAPE = defineObjectShape()(['id', 'invocationId', 'runId', 'sessionId', 'turnId', 'ts', 'partial', 'role', 'author'], ['branch', 'origin', 'modelVisibility', 'status', 'content', 'actions', 'refs']);
173
174
  const TEXT_CONTENT_SHAPE = defineObjectShape()(['kind', 'text'], [
174
175
  'displayText',
176
+ 'interrupted',
175
177
  'origin',
176
178
  'attachments',
177
179
  'directoryReferences',
@@ -186,7 +188,15 @@ const FUNCTION_RESPONSE_CONTENT_SHAPE = defineObjectShape()(['kind', 'id', 'name
186
188
  const ERROR_CONTENT_SHAPE = defineObjectShape()(['kind', 'message'], ['code', 'reason', 'details', 'retry']);
187
189
  const SYSTEM_NOTE_CONTENT_SHAPE = defineObjectShape()(['kind', 'note'], ['data']);
188
190
  const INVOCATION_OPENED_CONTENT_SHAPE = defineObjectShape()(['kind', 'protocol', 'route', 'configuration', 'root', 'source'], ['lineage']);
189
- const INVOCATION_ROUTE_RUNTIME_SHAPE = defineObjectShape()(['provenance', 'backendKind', 'llmConnectionId', 'llmConnectionSlug', 'modelId'], ['providerStateIdentity']);
191
+ const INVOCATION_ROUTE_RUNTIME_MODEL_SHAPE = defineObjectShape()(['provenance', 'backendKind', 'llmConnectionId', 'llmConnectionSlug', 'modelId'], ['providerStateIdentity']);
192
+ const INVOCATION_ROUTE_RUNTIME_EXECUTOR_SHAPE = defineObjectShape()([
193
+ 'provenance',
194
+ 'backendKind',
195
+ 'executorId',
196
+ 'llmConnectionSlug',
197
+ 'modelId',
198
+ 'providerStateIdentity',
199
+ ], []);
190
200
  const INVOCATION_ROUTE_UNKNOWN_SHAPE = defineObjectShape()(['provenance', 'backendKind', 'llmConnectionSlug', 'modelId'], []);
191
201
  const INVOCATION_CONFIGURATION_SHAPE = defineObjectShape()([
192
202
  'cwd',
@@ -394,6 +404,7 @@ function isRuntimeEventContent(value) {
394
404
  if (!hasExactShape(value, TEXT_CONTENT_SHAPE) ||
395
405
  (value.origin !== undefined && !isTurnOrigin(value.origin)) ||
396
406
  (value.steering !== undefined && value.steering !== true) ||
407
+ (value.interrupted !== undefined && value.interrupted !== true) ||
397
408
  (value.providerOptions !== undefined && !isRecord(value.providerOptions))) {
398
409
  return false;
399
410
  }
@@ -481,14 +492,19 @@ function isRuntimeInvocationRoute(value) {
481
492
  return false;
482
493
  }
483
494
  if (value.provenance === 'runtime') {
484
- return (hasExactShape(value, INVOCATION_ROUTE_RUNTIME_SHAPE) &&
495
+ if (value.backendKind === 'plugin-executor') {
496
+ return (hasExactShape(value, INVOCATION_ROUTE_RUNTIME_EXECUTOR_SHAPE) &&
497
+ isExecutorId(value.executorId) &&
498
+ isSha256Digest(value.providerStateIdentity));
499
+ }
500
+ return (hasExactShape(value, INVOCATION_ROUTE_RUNTIME_MODEL_SHAPE) &&
485
501
  isNonEmptyString(value.llmConnectionId) &&
486
502
  (value.providerStateIdentity === undefined || isSha256Digest(value.providerStateIdentity)));
487
503
  }
488
504
  return value.provenance === 'unknown' && hasExactShape(value, INVOCATION_ROUTE_UNKNOWN_SHAPE);
489
505
  }
490
506
  function isPersistedBackendKind(value) {
491
- return value === 'ai-sdk' || value === 'fake';
507
+ return value === 'ai-sdk' || value === 'plugin-executor' || value === 'fake';
492
508
  }
493
509
  function isRuntimeInvocationConfiguration(value) {
494
510
  return (isRecord(value) &&
@@ -818,7 +834,10 @@ export function isPartialRuntimeEvent(event) {
818
834
  /**
819
835
  * True if the event carries content whose kind is eligible for model
820
836
  * history projection: text, thinking, function_call, or function_response.
821
- * Error-only content and pure action/refs events are NOT model-visible.
837
+ * A user-authored text event with structured context (quotes or attachments)
838
+ * is model-visible even when the inline text is empty — the structured part
839
+ * is what carries the turn (#4804). Error-only content and pure action/refs
840
+ * events are NOT model-visible.
822
841
  *
823
842
  * This is a content-kind check only. Callers still apply `partial`
824
843
  * filtering (partial chunks are never replayed into the next model call).
@@ -831,7 +850,7 @@ export function runtimeEventHasModelVisibleContent(event) {
831
850
  return false;
832
851
  switch (content.kind) {
833
852
  case 'text':
834
- return content.text.length > 0;
853
+ return hasMeaningfulMessageContent(content);
835
854
  case 'thinking':
836
855
  case 'function_call':
837
856
  case 'function_response':
@@ -69,15 +69,23 @@ export function runtimeHandoffPause(event) {
69
69
  }
70
70
  /** Verify against source facts, not the proposed claim's description of them. */
71
71
  export function assertHandoffClaimSource(claim, prefix) {
72
- const last = prefix.events.at(-1);
72
+ const first = prefix.protocol === 'immutable_runtime_prefix_v1' ? prefix.events[0] : prefix.firstEvent;
73
+ const last = prefix.protocol === 'immutable_runtime_prefix_v1' ? prefix.events.at(-1) : prefix.lastEvent;
73
74
  const pause = last && runtimeHandoffPause(last);
74
75
  const source = claim.targetOpening.source;
76
+ const claimedPrefix = claim.boundary.segments.at(-1);
77
+ if (!claimedPrefix ||
78
+ claimedPrefix.prefixDigest !== prefix.prefixDigest ||
79
+ stableJsonStringify(claimedPrefix.identity) !== stableJsonStringify(prefix.identity) ||
80
+ stableJsonStringify(claimedPrefix.position) !== stableJsonStringify(prefix.position)) {
81
+ throw new Error('Handoff claim does not preserve the sealed source prefix');
82
+ }
75
83
  if (source.kind !== 'handoff') {
76
84
  if (pause)
77
85
  throw new Error('A handoff pause is reserved for its authorized successor');
78
86
  return;
79
87
  }
80
- const opening = prefix.events[0]?.content;
88
+ const opening = first?.content;
81
89
  if (!pause ||
82
90
  opening?.kind !== 'invocation_opened' ||
83
91
  prefix.identity.sessionId !== claim.target.sessionId ||
@@ -20,7 +20,8 @@ import { continuationStartEventMatchesClaim, createRuntimeBoundaryCursor, invoca
20
20
  import { readRunInvocation, } from './runtime-event-store.js';
21
21
  import { assertHandoffClaimSource, runtimeHandoffPause, } from './runtime-handoff.js';
22
22
  /** All logical snapshot and command routing paths share these edge checks. */
23
- export async function readLogicalRuntimeExecution(store, identity, knownRoot) {
23
+ export async function readLogicalRuntimeExecution(store, identity, knownRoot, options) {
24
+ const membership = options?.mode === 'membership';
24
25
  const root = knownRoot ?? (await readRunInvocation(store, identity.sessionId, identity.runId));
25
26
  if (!root)
26
27
  return undefined;
@@ -37,17 +38,25 @@ export async function readLogicalRuntimeExecution(store, identity, knownRoot) {
37
38
  if (seen.has(tip.runId) || seen.size >= 64)
38
39
  throw new Error('Invalid logical execution handoff lineage');
39
40
  seen.add(tip.runId);
40
- const events = await store.readImmutableRuntimeEvents(identity.sessionId, tip.runId);
41
- const last = events.at(-1);
41
+ const events = membership
42
+ ? undefined
43
+ : await store.readImmutableRuntimeEvents(identity.sessionId, tip.runId);
44
+ const last = membership ? tip.terminalEvent : events?.at(-1);
42
45
  const pause = last && runtimeHandoffPause(last);
43
46
  if (!pause)
44
- return { root, tip, events, runIds: [...seen] };
47
+ return logicalExecutionResult(root, tip, [...seen], events);
45
48
  if (pause.rootRunId !== root.runId)
46
49
  throw new Error('Handoff seal changes the logical root');
47
- const prefix = await store.readImmutableRuntimePrefix({
48
- sessionId: identity.sessionId,
49
- runId: tip.runId,
50
- });
50
+ const prefix = membership
51
+ ? await store.readImmutableRuntimePrefixProof({
52
+ sessionId: identity.sessionId,
53
+ runId: tip.runId,
54
+ })
55
+ : await store.readImmutableRuntimePrefix({
56
+ sessionId: identity.sessionId,
57
+ runId: tip.runId,
58
+ });
59
+ const segment = runtimePrefixSegment(prefix);
51
60
  if (prefix.position.lastEventId !== last.id)
52
61
  throw new Error('Handoff source changed after its seal');
53
62
  if (!segments) {
@@ -59,9 +68,9 @@ export async function readLogicalRuntimeExecution(store, identity, knownRoot) {
59
68
  throw new Error('Handoff requires authenticated source lineage');
60
69
  const initial = await store.readContinuationClaimStateByBoundary(source.boundaryDigest);
61
70
  if (!initial ||
62
- initial.startEventId !== prefix.events[0]?.id ||
71
+ initial.startEventId !== prefixFirstEvent(prefix).id ||
63
72
  !invocationMatchesClaimTarget(root, initial.claim) ||
64
- !continuationStartEventMatchesClaim(prefix.events[0], initial.claim, initial.startKind)) {
73
+ !continuationStartEventMatchesClaim(prefixFirstEvent(prefix), initial.claim, initial.startKind)) {
65
74
  throw new Error('Handoff root continuation is not authenticated');
66
75
  }
67
76
  segments = [...initial.claim.boundary.segments];
@@ -69,7 +78,7 @@ export async function readLogicalRuntimeExecution(store, identity, knownRoot) {
69
78
  else
70
79
  segments = [];
71
80
  }
72
- segments.push(runtimePrefixSegment(prefix));
81
+ segments.push(segment);
73
82
  const boundary = createRuntimeBoundaryCursor(segments);
74
83
  let state = await store.readContinuationClaimStateByBoundary(boundary.manifestDigest);
75
84
  const next = await readRunInvocation(store, identity.sessionId, pause.successorRunId);
@@ -81,15 +90,21 @@ export async function readLogicalRuntimeExecution(store, identity, knownRoot) {
81
90
  if (!state) {
82
91
  if (next)
83
92
  throw new Error('Handoff successor opened without its continuation claim');
84
- return { root, tip, events, runIds: [...seen], pendingHandoff: pause };
93
+ return logicalExecutionResult(root, tip, [...seen], events, pause);
85
94
  }
86
95
  assertHandoffClaimSource(state.claim, prefix);
87
96
  if (!next) {
88
97
  if (state.startEventId)
89
98
  throw new Error('Handoff successor opening is missing');
90
- return { root, tip, events, runIds: [...seen], pendingHandoff: pause };
99
+ return logicalExecutionResult(root, tip, [...seen], events, pause);
91
100
  }
92
- const first = (await store.readImmutableRuntimeEvents(identity.sessionId, next.runId))[0];
101
+ const first = membership
102
+ ? prefixFirstEvent(await store.readImmutableRuntimePrefixProof({
103
+ sessionId: identity.sessionId,
104
+ runId: next.runId,
105
+ upToEventSeq: 1,
106
+ }))
107
+ : (await store.readImmutableRuntimeEvents(identity.sessionId, next.runId))[0];
93
108
  if (state.startEventId !== first?.id ||
94
109
  !invocationMatchesClaimTarget(next, state.claim) ||
95
110
  !continuationStartEventMatchesClaim(first, state.claim, state.startKind)) {
@@ -98,6 +113,16 @@ export async function readLogicalRuntimeExecution(store, identity, knownRoot) {
98
113
  tip = next;
99
114
  }
100
115
  }
116
+ function prefixFirstEvent(prefix) {
117
+ const first = prefix.protocol === 'immutable_runtime_prefix_v1' ? prefix.events[0] : prefix.firstEvent;
118
+ if (!first)
119
+ throw new Error('immutable RuntimeEvent prefix is empty');
120
+ return first;
121
+ }
122
+ function logicalExecutionResult(root, tip, runIds, events, pendingHandoff) {
123
+ const result = { root, tip, runIds, ...(pendingHandoff ? { pendingHandoff } : {}) };
124
+ return events ? { ...result, events } : result;
125
+ }
101
126
  /** Resolve a durable physical proof back to its root, then authenticate membership. */
102
127
  export async function readLogicalRuntimeExecutionForRun(store, identity) {
103
128
  const run = await readRunInvocation(store, identity.sessionId, identity.runId);
@@ -26,11 +26,12 @@
26
26
  * whether that exact target looks usable for presentation and readiness checks.
27
27
  *
28
28
  * The compatibility rules are:
29
- * 1. The session's own connection must pass `isConnectionReady` with
29
+ * 1. Plugin executor Sessions do not depend on Maka model connections.
30
+ * 2. The session's own connection must pass `isConnectionReady` with
30
31
  * the sticky session model.
31
- * 2. Legacy Sessions without an immutable connection id are blocked until
32
+ * 3. Legacy Sessions without an immutable connection id are blocked until
32
33
  * the user explicitly selects an account.
33
- * 3. A missing id, slug mismatch, or unusable exact connection is blocked.
34
+ * 4. A missing id, slug mismatch, or unusable exact connection is blocked.
34
35
  *
35
36
  * `lastTestStatus` deliberately plays no part here (E4): telemetry about
36
37
  * a past credential test must not gate send, so it must not gate the
@@ -71,6 +72,8 @@ function sessionOwnConnectionBlockReason(session, ownConnection, hasSecret) {
71
72
  return verdict.ready ? undefined : verdict.reason;
72
73
  }
73
74
  function ownConnectionBlockReason(session, connections, hasSecret) {
75
+ if (session.backend === 'plugin-executor')
76
+ return undefined;
74
77
  if (session.backend === 'fake')
75
78
  return 'fake_backend';
76
79
  if (!session.llmConnectionId)
@@ -17,6 +17,7 @@
17
17
  * under the License.
18
18
  */
19
19
  import { isWorkHubActionReceipt } from './workhub-action-result.js';
20
+ import { isExecutorId } from './executor-id.js';
20
21
  import { MODEL_FAILURE_MESSAGE_MAX_BYTES, isModelRetryDecision, } from './model-failure.js';
21
22
  import { decodeMessageContent, TOOL_ACTIVITY_KINDS, } from './events.js';
22
23
  import { isPermissionMode, isToolCategory, } from './permission.js';
@@ -290,10 +291,14 @@ export const WORKHUB_COORDINATION_REPLACEMENT_SCHEMA_VERSION = 2;
290
291
  export const WORKHUB_COORDINATION_STOP_SCHEMA_VERSION = 3;
291
292
  export function isWorkHubCreateDefaults(value) {
292
293
  if (!isRecord(value) ||
293
- Object.keys(value).some((key) => key !== 'model' && key !== 'permissionMode'))
294
+ Object.keys(value).some((key) => key !== 'executorId' && key !== 'model' && key !== 'permissionMode'))
294
295
  return false;
295
296
  if (value.permissionMode !== undefined && !isPermissionMode(value.permissionMode))
296
297
  return false;
298
+ if (value.executorId !== undefined && !isExecutorId(value.executorId))
299
+ return false;
300
+ if (value.executorId !== undefined && value.model !== undefined)
301
+ return false;
297
302
  if (value.model === undefined)
298
303
  return true;
299
304
  const model = value.model;
@@ -349,7 +354,7 @@ const USER_MESSAGE_SHAPE = defineObjectShape()(['type', 'id', 'turnId', 'ts', 't
349
354
  'coordinationActionId',
350
355
  'origin',
351
356
  ]);
352
- const ASSISTANT_MESSAGE_SHAPE = defineObjectShape()(['type', 'id', 'turnId', 'ts', 'text', 'modelId'], ['thinking', 'contentOrder', 'providerOptions']);
357
+ const ASSISTANT_MESSAGE_SHAPE = defineObjectShape()(['type', 'id', 'turnId', 'ts', 'text', 'modelId'], ['thinking', 'contentOrder', 'providerOptions', 'interrupted']);
353
358
  const TOOL_CALL_MESSAGE_SHAPE = defineObjectShape()(['type', 'id', 'turnId', 'ts', 'toolName', 'args'], [
354
359
  'activityKind',
355
360
  'displayName',
@@ -567,6 +572,7 @@ function decodeMessage(value, decodeToolResultContent) {
567
572
  hasMessageEnvelope(message, true) &&
568
573
  typeof message.text === 'string' &&
569
574
  typeof message.modelId === 'string' &&
575
+ (message.interrupted === undefined || message.interrupted === true) &&
570
576
  (message.providerOptions === undefined || isRecord(message.providerOptions)) &&
571
577
  (message.thinking === undefined || isAssistantThinking(message.thinking)) &&
572
578
  (message.contentOrder === undefined ||
@@ -67,6 +67,7 @@ export class ShellRunUpdateBuffer {
67
67
  }
68
68
  const CURRENT_TERMINAL_RESULT_SHAPE = defineObjectShape()(['kind', 'cwd', 'cmd', 'status', 'output'], ['exitCode', 'failureMessage', 'sandboxDenial']);
69
69
  const CURRENT_SHELL_RUN_RESULT_SHAPE = defineObjectShape()(['kind', 'ref', 'mode', 'status', 'cwd', 'cmd', 'startedAt', 'updatedAt', 'revision'], [
70
+ 'pid',
70
71
  'completedAt',
71
72
  'exitCode',
72
73
  'failureMessage',
@@ -162,6 +162,7 @@ export function isValidShellRunState(value) {
162
162
  const SHELL_RUN_SESSION_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;
163
163
  const SHELL_RUN_PATCH_KEYS = new Set([
164
164
  'status',
165
+ 'pid',
165
166
  'exitCode',
166
167
  'failureMessage',
167
168
  'updatedAt',
@@ -179,6 +180,7 @@ const SHELL_RUN_RECORD_KEYS = new Set([
179
180
  'cwd',
180
181
  'command',
181
182
  'status',
183
+ 'pid',
182
184
  'startedAt',
183
185
  'updatedAt',
184
186
  'completedAt',
@@ -227,6 +229,7 @@ export function normalizeShellRunRecord(value, sessionId, shellRunId) {
227
229
  record.sessionId === sessionId &&
228
230
  record.shellRunId === shellRunId &&
229
231
  isShellRunStatus(record.status) &&
232
+ (record.pid === undefined || isPositiveInteger(record.pid)) &&
230
233
  isFiniteNumber(record.startedAt) &&
231
234
  isFiniteNumber(record.updatedAt) &&
232
235
  isPositiveInteger(record.revision) &&
@@ -349,6 +352,7 @@ function isShellRunSandboxEscalation(value, execution) {
349
352
  }
350
353
  function canonicalShellRunRecord(record) {
351
354
  return {
355
+ ...(record.pid !== undefined ? { pid: record.pid } : {}),
352
356
  shellRunId: record.shellRunId,
353
357
  sessionId: record.sessionId,
354
358
  ...(record.sourceRunId !== undefined ? { sourceRunId: record.sourceRunId } : {}),
@@ -16,5 +16,7 @@
16
16
  * specific language governing permissions and limitations
17
17
  * under the License.
18
18
  */
19
+ import { DURABLE_TOOL_RESULT_PROJECTION_MAX_BYTES } from './durable-tool-result-projection.js';
19
20
  export const TOOL_RESULT_ARCHIVE_EVIDENCE_MAX_TRANSITIONS = 64;
20
- export const TOOL_RESULT_ARCHIVE_EVIDENCE_MAX_BYTES = 2 * 1024 * 1024;
21
+ // Include event identity and transition overhead around the stored projection.
22
+ export const TOOL_RESULT_ARCHIVE_EVIDENCE_MAX_BYTES = DURABLE_TOOL_RESULT_PROJECTION_MAX_BYTES + 128 * 1024;
@@ -162,7 +162,8 @@ function isNonShellToolResultContent(value) {
162
162
  isFiniteNumber(value.originalEstimatedTokens) &&
163
163
  isFiniteNumber(value.originalBytes) &&
164
164
  isFiniteNumber(value.rewriteVersion) &&
165
- (value.reason === 'stale_tool_result_pruned_before_compact' ||
165
+ (value.reason === 'tool_result_pruned' ||
166
+ value.reason === 'stale_tool_result_pruned_before_compact' ||
166
167
  value.reason === 'active_current_turn_tool_result_pruned_before_next_step'));
167
168
  case 'image':
168
169
  return (hasExactShape(value, IMAGE_SHAPE) &&
@@ -26,39 +26,57 @@ const HUNK_HEADER = /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;
26
26
  * structure — degrades to unnumbered meta rows.
27
27
  */
28
28
  export function parseUnifiedDiffRows(diff) {
29
- const lines = diff.split('\n');
30
- // A trailing newline terminates the diff rather than starting an empty row.
31
- if (lines.length > 1 && lines[lines.length - 1] === '')
32
- lines.pop();
33
29
  const rows = [];
30
+ scanUnifiedDiff(diff, rows);
31
+ return rows;
32
+ }
33
+ /** Green `+N` / red `-N` counts, without materializing display rows or body text. */
34
+ export function countDiffLineStats(diff) {
35
+ return scanUnifiedDiff(diff);
36
+ }
37
+ /**
38
+ * One structural scan for both consumers. The optional output array keeps
39
+ * display objects and body substrings out of the count-only path.
40
+ */
41
+ function scanUnifiedDiff(diff, rows) {
42
+ let additions = 0;
43
+ let deletions = 0;
34
44
  let oldLine = 0;
35
45
  let newLine = 0;
36
46
  let remainingOld = 0;
37
47
  let remainingNew = 0;
38
48
  let inHunk = false;
39
- for (const line of lines) {
49
+ let offset = 0;
50
+ // Visit an empty input once, but do not invent a row after a trailing newline.
51
+ do {
52
+ const start = offset;
53
+ const newline = diff.indexOf('\n', start);
54
+ const end = newline === -1 ? diff.length : newline;
55
+ offset = end + 1;
40
56
  if (inHunk && remainingOld + remainingNew > 0) {
41
- const marker = line.charAt(0);
57
+ const marker = diff.charAt(start);
42
58
  if (marker === '\\') {
43
59
  // `` annotates the previous row without
44
60
  // consuming a line on either side.
45
- rows.push({ kind: 'meta', text: line });
61
+ rows?.push({ kind: 'meta', text: diff.slice(start, end) });
46
62
  continue;
47
63
  }
48
64
  if (marker === '-') {
49
- rows.push({ kind: 'del', text: line, oldLine });
65
+ rows?.push({ kind: 'del', text: diff.slice(start, end), oldLine });
66
+ deletions += 1;
50
67
  oldLine += 1;
51
68
  remainingOld -= 1;
52
69
  continue;
53
70
  }
54
71
  if (marker === '+') {
55
- rows.push({ kind: 'add', text: line, newLine });
72
+ rows?.push({ kind: 'add', text: diff.slice(start, end), newLine });
73
+ additions += 1;
56
74
  newLine += 1;
57
75
  remainingNew -= 1;
58
76
  continue;
59
77
  }
60
78
  // ' ' context, and the bare empty line some generators emit for one.
61
- rows.push({ kind: 'ctx', text: line, oldLine, newLine });
79
+ rows?.push({ kind: 'ctx', text: diff.slice(start, end), oldLine, newLine });
62
80
  oldLine += 1;
63
81
  newLine += 1;
64
82
  remainingOld -= 1;
@@ -66,6 +84,7 @@ export function parseUnifiedDiffRows(diff) {
66
84
  continue;
67
85
  }
68
86
  inHunk = false;
87
+ const line = diff.slice(start, end);
69
88
  const hunk = HUNK_HEADER.exec(line);
70
89
  if (hunk) {
71
90
  oldLine = Number(hunk[1]);
@@ -73,29 +92,17 @@ export function parseUnifiedDiffRows(diff) {
73
92
  remainingOld = hunk[2] === undefined ? 1 : Number(hunk[2]);
74
93
  remainingNew = hunk[4] === undefined ? 1 : Number(hunk[4]);
75
94
  inHunk = true;
76
- rows.push({ kind: 'hunk', text: line });
95
+ rows?.push({ kind: 'hunk', text: line });
77
96
  continue;
78
97
  }
79
98
  if (line.startsWith('diff ')) {
80
- rows.push({ kind: 'meta', text: line });
99
+ rows?.push({ kind: 'meta', text: line });
81
100
  continue;
82
101
  }
83
102
  if (line.startsWith('--- ') || line.startsWith('+++ ') || line.startsWith('index ')) {
84
103
  continue;
85
104
  }
86
- rows.push({ kind: 'meta', text: line });
87
- }
88
- return rows;
89
- }
90
- /** Green `+N` / red `-N` counts, from the structural parse. */
91
- export function countDiffLineStats(diff) {
92
- let additions = 0;
93
- let deletions = 0;
94
- for (const row of parseUnifiedDiffRows(diff)) {
95
- if (row.kind === 'add')
96
- additions += 1;
97
- else if (row.kind === 'del')
98
- deletions += 1;
99
- }
105
+ rows?.push({ kind: 'meta', text: line });
106
+ } while (offset < diff.length);
100
107
  return { additions, deletions };
101
108
  }
@@ -32,9 +32,18 @@ export const WORK_BOARD_ID_MAX_CHARS = 64;
32
32
  export const WORK_BOARD_SESSION_ID_MAX_CHARS = 160;
33
33
  export const WORK_BOARD_MESSAGE_ID_MAX_CHARS = 256;
34
34
  export const WORK_BOARD_PROJECT_ID_MAX_CHARS = 160;
35
+ export const WORK_BOARD_HOST_ID_MAX_CHARS = 160;
36
+ export const WORK_BOARD_PROFILE_ID_MAX_CHARS = 160;
35
37
  export const WORK_BOARD_DEFAULT_PAGE_SIZE = 50;
36
38
  export const WORK_BOARD_PAGE_SIZE_MAX = 100;
37
39
  export const WORK_BOARD_CURSOR_MAX_CHARS = 1024;
40
+ /**
41
+ * Single-link contract: a project-scoped item owns at most one started
42
+ * Session at a time. Linking a freshly started Session replaces any previous
43
+ * link, keeping `linkedSessions` bounded instead of growing on repeated
44
+ * starts. Read paths stay tolerant of legacy arrays with more entries.
45
+ */
46
+ export const WORK_BOARD_MAX_LINKED_SESSIONS = 1;
38
47
  export const WORK_BOARD_ITEM_STATES = ['todo', 'in_progress', 'done'];
39
48
  const WORK_BOARD_SCOPE_INBOX_SHAPE = defineObjectShape()(['kind'], []);
40
49
  const WORK_BOARD_SCOPE_PROJECT_SHAPE = defineObjectShape()(['kind', 'projectId'], []);
@@ -55,7 +64,7 @@ const WORK_BOARD_ITEM_SHAPE = defineObjectShape()([
55
64
  'createdAt',
56
65
  'updatedAt',
57
66
  'archived',
58
- ], ['notes', 'archivedAt']);
67
+ ], ['notes', 'archivedAt', 'linkedSessions']);
59
68
  const WORK_BOARD_CREATE_INPUT_SHAPE = defineObjectShape()(['scope', 'title', 'creator', 'provenance'], ['notes']);
60
69
  const WORK_BOARD_UPDATE_INPUT_SHAPE = defineObjectShape()([], ['title', 'notes', 'scope', 'state']);
61
70
  const WORK_BOARD_LIST_QUERY_SHAPE = defineObjectShape()([], ['scope', 'projectIds', 'includeArchived', 'limit', 'cursor']);
@@ -236,6 +245,87 @@ export function normalizeCreateWorkBoardItemInput(input) {
236
245
  },
237
246
  };
238
247
  }
248
+ const WORK_BOARD_LINKED_SESSION_SHAPE = defineObjectShape()(['profileId', 'hostId', 'sessionId', 'linkedAt'], []);
249
+ export function normalizeWorkBoardLinkedSession(input) {
250
+ if (!isRecord(input) || !hasExactShape(input, WORK_BOARD_LINKED_SESSION_SHAPE)) {
251
+ return fail('Work Board linked Session reference is invalid');
252
+ }
253
+ const profileId = normalizeIdString(input.profileId, {
254
+ field: 'linkedSessions.profileId',
255
+ max: WORK_BOARD_PROFILE_ID_MAX_CHARS,
256
+ });
257
+ if (!profileId.ok)
258
+ return profileId;
259
+ const hostId = normalizeIdString(input.hostId, {
260
+ field: 'linkedSessions.hostId',
261
+ max: WORK_BOARD_HOST_ID_MAX_CHARS,
262
+ });
263
+ if (!hostId.ok)
264
+ return hostId;
265
+ const sessionId = normalizeIdString(input.sessionId, {
266
+ field: 'linkedSessions.sessionId',
267
+ max: WORK_BOARD_SESSION_ID_MAX_CHARS,
268
+ });
269
+ if (!sessionId.ok)
270
+ return sessionId;
271
+ const linkedAt = asSafeInteger(input.linkedAt);
272
+ if (linkedAt === null || linkedAt < 0)
273
+ return fail('linkedAt must be a non-negative integer');
274
+ return {
275
+ ok: true,
276
+ value: {
277
+ profileId: profileId.value,
278
+ hostId: hostId.value,
279
+ sessionId: sessionId.value,
280
+ linkedAt,
281
+ },
282
+ };
283
+ }
284
+ export function normalizeWorkBoardLinkedSessions(input) {
285
+ if (input === undefined)
286
+ return { ok: true, value: [] };
287
+ if (!Array.isArray(input))
288
+ return fail('linkedSessions must be an array');
289
+ const result = [];
290
+ const seen = new Set();
291
+ for (const entry of input) {
292
+ const normalized = normalizeWorkBoardLinkedSession(entry);
293
+ if (!normalized.ok)
294
+ return normalized;
295
+ const key = `${normalized.value.profileId}\u0000${normalized.value.hostId}\u0000${normalized.value.sessionId}`;
296
+ if (seen.has(key))
297
+ return fail('linkedSessions contains duplicates');
298
+ seen.add(key);
299
+ result.push(normalized.value);
300
+ }
301
+ if (result.length > WORK_BOARD_MAX_LINKED_SESSIONS) {
302
+ return fail(`linkedSessions must hold at most ${WORK_BOARD_MAX_LINKED_SESSIONS} entry (single-link contract)`);
303
+ }
304
+ return { ok: true, value: result };
305
+ }
306
+ /**
307
+ * Lenient read path for stored items: drop malformed or duplicate link entries
308
+ * instead of failing the whole item, so one corrupt reference cannot hide an
309
+ * otherwise valid board item. The strict {@link normalizeWorkBoardLinkedSessions}
310
+ * guard remains on the write path.
311
+ */
312
+ function tolerantWorkBoardLinkedSessions(value) {
313
+ if (!Array.isArray(value))
314
+ return [];
315
+ const result = [];
316
+ const seen = new Set();
317
+ for (const entry of value) {
318
+ const normalized = normalizeWorkBoardLinkedSession(entry);
319
+ if (!normalized.ok)
320
+ continue;
321
+ const key = `${normalized.value.profileId}\u0000${normalized.value.hostId}\u0000${normalized.value.sessionId}`;
322
+ if (seen.has(key))
323
+ continue;
324
+ seen.add(key);
325
+ result.push(normalized.value);
326
+ }
327
+ return result;
328
+ }
239
329
  export function normalizeUpdateWorkBoardItemInput(input) {
240
330
  if (!isRecord(input))
241
331
  return fail('Work Board update must be an object');
@@ -395,6 +485,7 @@ export function decodeWorkBoardItem(value) {
395
485
  const provenance = normalizeWorkBoardProvenance(value.provenance);
396
486
  if (!provenance.ok)
397
487
  return null;
488
+ const linkedSessions = tolerantWorkBoardLinkedSessions(value.linkedSessions);
398
489
  const createdAt = asSafeInteger(value.createdAt);
399
490
  const updatedAt = asSafeInteger(value.updatedAt);
400
491
  if (createdAt === null || updatedAt === null)
@@ -418,6 +509,7 @@ export function decodeWorkBoardItem(value) {
418
509
  archivedAt,
419
510
  creator: creator.value,
420
511
  provenance: provenance.value,
512
+ linkedSessions,
421
513
  createdAt,
422
514
  updatedAt,
423
515
  };
@@ -435,6 +527,7 @@ export function decodeWorkBoardItem(value) {
435
527
  archived: false,
436
528
  creator: creator.value,
437
529
  provenance: provenance.value,
530
+ linkedSessions,
438
531
  createdAt,
439
532
  updatedAt,
440
533
  };
@@ -6,6 +6,7 @@
6
6
  "type": "module",
7
7
  "sideEffects": false,
8
8
  "exports": {
9
+ "./executor-id": "./dist/executor-id.js",
9
10
  "./durable-tool-result-projection": "./dist/durable-tool-result-projection.js",
10
11
  "./model-projection-transition": "./dist/model-projection-transition.js",
11
12
  "./canonical-runtime-event": "./dist/canonical-runtime-event.js",