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
@@ -62,7 +62,14 @@ export const RUNTIME_HOST_REGISTRATION_SCHEMA_VERSION = 1;
62
62
  export const RUNTIME_HOST_PROTOCOL_VERSION = 0;
63
63
  // Increment when the same protocol version no longer guarantees safe Client-Host
64
64
  // interoperability. Mismatches are rejected before domain commands are admitted.
65
- export const RUNTIME_HOST_COMPATIBILITY_EPOCH = 149;
65
+ export const RUNTIME_HOST_COMPATIBILITY_EPOCH = 154;
66
+ // 154: External Session import results distinguish committed Sessions from typed source limits.
67
+ // 153: Sessions may select plugin executors and Plugin Platform queries expose them.
68
+ // 152: Assistant completions and transcript rows preserve interrupted responses.
69
+ // 151: WorkHub selects and delegates through a durable Host Form interaction.
70
+ // 150: Message admission accepts an empty-text Message that carries a quote or
71
+ // an attachment (#4804). Peers older than this epoch reject that frame at
72
+ // admission, so the pair must refuse each other at the handshake.
66
73
  // 149: Connection model overrides retain disabled identities and separate capacity
67
74
  // from compaction. Catalog entries carry overrides; clients do not rebuild them.
68
75
  // 148: Model catalog entries include image support before a user override.
@@ -19,7 +19,7 @@
19
19
  import { invalidProtocolFrame } from './errors.js';
20
20
  import { assertExactKeys, requireCount, requireEntityId, requireExactRecord, requireId, requireRecord, requireShapedRecord, requireUtf8String, } from './codec.js';
21
21
  import { defineOperation } from './operation-spec.js';
22
- import { decodeMessageContent, decodeMessageAdmissionContent, decodeSkillIds, decodeTurnOrchestration, decodeTurnSnapshot, TURN_MESSAGE_TEXT_MAX_BYTES, } from './turn.js';
22
+ import { decodeMessageAdmissionContent, decodeSkillIds, decodeTurnOrchestration, decodeTurnSnapshot, TURN_MESSAGE_TEXT_MAX_BYTES, } from './turn.js';
23
23
  import { decodeSkillInvocationResult } from '@maka/core/skill-invocation';
24
24
  export const MESSAGE_QUEUE_MAX_ENTRIES = 64;
25
25
  export const MESSAGE_QUEUE_PROJECTION_MAX_BYTES = 52 * 1024;
@@ -432,7 +432,7 @@ function decodeMessageQueueEntrySnapshot(value) {
432
432
  const base = {
433
433
  entryId: requireEntityId(record.entryId, 'entryId'),
434
434
  messageId: requireEntityId(record.messageId, 'messageId'),
435
- content: decodeMessageContent(record.content),
435
+ content: decodeMessageAdmissionContent(record.content),
436
436
  placement: requireMessagePlacement(record.placement),
437
437
  };
438
438
  if (record.state === 'queued' || record.state === 'retracted') {
@@ -222,6 +222,7 @@ export const REMOTE_OWNER_OPERATION_GRANTS = Object.freeze([
222
222
  'web-search.execute',
223
223
  'workhub.coordination.answer',
224
224
  'workhub.coordination.actFromTurn',
225
+ 'workhub.coordination.selectAndDelegate',
225
226
  'workhub.coordination.candidates',
226
227
  'workhub.coordination.configureModel',
227
228
  'workhub.coordination.query',
@@ -108,7 +108,7 @@ export const PLUGIN_PLATFORM_OPERATION_SPECS = {
108
108
  };
109
109
  function decodePluginPlatformQueryInput(value) {
110
110
  const input = requireShapedRecord(value, 'Plugin Platform query input', ['view'], ['rootId', 'cursor', 'limit']);
111
- if (!['status', 'packages', 'entries', 'tools', 'commands', 'failures'].includes(input.view)) {
111
+ if (!['status', 'packages', 'entries', 'tools', 'commands', 'executors', 'failures'].includes(input.view)) {
112
112
  throw invalidProtocolFrame('Invalid Plugin Platform query view');
113
113
  }
114
114
  const view = input.view;
@@ -125,8 +125,12 @@ function decodePluginPlatformQueryInput(value) {
125
125
  (input.rootId !== undefined || cursor !== undefined || limit !== undefined)) {
126
126
  throw invalidProtocolFrame('Plugin Platform status query does not accept paging');
127
127
  }
128
- if (input.rootId !== undefined && view !== 'entries' && view !== 'tools' && view !== 'commands') {
129
- throw invalidProtocolFrame('Plugin root identity is only valid for Entry, Tool, and Command queries');
128
+ if (input.rootId !== undefined &&
129
+ view !== 'entries' &&
130
+ view !== 'tools' &&
131
+ view !== 'commands' &&
132
+ view !== 'executors') {
133
+ throw invalidProtocolFrame('Plugin root identity is only valid for Entry, Tool, Command, and Executor queries');
130
134
  }
131
135
  let rootId;
132
136
  if (input.rootId !== undefined) {
@@ -190,7 +194,7 @@ function decodePluginPlatformQueryResult(value) {
190
194
  ]);
191
195
  if (!Array.isArray(output.items) ||
192
196
  output.items.length > 64 ||
193
- !['packages', 'entries', 'tools', 'commands', 'failures'].includes(view)) {
197
+ !['packages', 'entries', 'tools', 'commands', 'executors', 'failures'].includes(view)) {
194
198
  throw invalidProtocolFrame('Invalid Plugin Platform page');
195
199
  }
196
200
  const nextCursor = output.nextCursor === null
@@ -205,7 +209,9 @@ function decodePluginPlatformQueryResult(value) {
205
209
  ? { view, items: output.items.map(decodeToolInspection), nextCursor }
206
210
  : view === 'commands'
207
211
  ? { view, items: output.items.map(decodeCommandInspection), nextCursor }
208
- : { view: 'failures', items: output.items.map(decodePlatformFailure), nextCursor };
212
+ : view === 'executors'
213
+ ? { view, items: output.items.map(decodeExecutorInspection), nextCursor }
214
+ : { view: 'failures', items: output.items.map(decodePlatformFailure), nextCursor };
209
215
  }
210
216
  requireEncodedByteLimit(decoded, 'Plugin Platform query result', PLUGIN_PLATFORM_QUERY_RESULT_MAX_BYTES);
211
217
  return decoded;
@@ -233,6 +239,37 @@ function decodeCommandInspection(value) {
233
239
  aliases: item.aliases.map((alias) => requireString(alias, 'Plugin Command alias', 128)),
234
240
  };
235
241
  }
242
+ function decodeExecutorInspection(value) {
243
+ const item = requireExactRecord(value, 'Plugin Executor inspection', [
244
+ 'entryId',
245
+ 'scopeId',
246
+ 'extensionId',
247
+ 'generation',
248
+ 'id',
249
+ 'displayName',
250
+ 'capabilities',
251
+ ]);
252
+ const capabilities = requireExactRecord(item.capabilities, 'Plugin Executor capabilities', [
253
+ 'thinking',
254
+ 'toolActivity',
255
+ ]);
256
+ if (typeof capabilities.thinking !== 'boolean' ||
257
+ typeof capabilities.toolActivity !== 'boolean') {
258
+ throw invalidProtocolFrame('Invalid Plugin Executor capabilities');
259
+ }
260
+ return {
261
+ entryId: requireId(item.entryId, 'Plugin Entry identity'),
262
+ scopeId: requireString(item.scopeId, 'Plugin scope identity', 256),
263
+ extensionId: requireId(item.extensionId, 'Plugin package identity'),
264
+ generation: requireCount(item.generation, 'Plugin generation'),
265
+ id: requireString(item.id, 'Plugin Executor id', 128),
266
+ displayName: requireString(item.displayName, 'Plugin Executor display name', 256),
267
+ capabilities: {
268
+ thinking: capabilities.thinking,
269
+ toolActivity: capabilities.toolActivity,
270
+ },
271
+ };
272
+ }
236
273
  function decodePlatformFailure(value) {
237
274
  const failure = requireShapedRecord(value, 'Plugin Platform failure', ['diagnostic'], ['entryId', 'extensionId']);
238
275
  if (failure.entryId === undefined && failure.extensionId === undefined) {
@@ -22,6 +22,7 @@ import { isPermissionMode } from '@maka/core/permission';
22
22
  import { isSessionStartMode } from '@maka/core/session-start-mode';
23
23
  import { isSessionBlockedReason, isSessionToolProfile, } from '@maka/core/session';
24
24
  import { isThinkingLevel } from '@maka/core/model-thinking';
25
+ import { isExecutorId } from '@maka/core/executor-id';
25
26
  import { assertAllowedKeys, requireCount, requireEncodedByteLimit, requireEntityId, requireExactRecord, requireRecord, requireShapedRecord, requireUtf8String, } from './codec.js';
26
27
  import { invalidProtocolFrame } from './errors.js';
27
28
  import { defineHostPathOperation, defineOperation } from './operation-spec.js';
@@ -92,6 +93,7 @@ const PROJECTION_FIELDS = [
92
93
  'revisionOfTurnId',
93
94
  'revisionIndex',
94
95
  'revisionState',
96
+ 'executorId',
95
97
  'thinkingLevel',
96
98
  'lastReadMessageId',
97
99
  'liveRunState',
@@ -243,23 +245,33 @@ export function decodeSessionCatalogQueryInput(value) {
243
245
  throw invalidProtocolFrame('Invalid Session catalog query kind');
244
246
  }
245
247
  export function decodeSessionCreateInput(value) {
246
- const input = requireShapedRecord(value, 'Session create input', ['sessionId', 'workspace', 'modelTarget'], [
248
+ const input = requireShapedRecord(value, 'Session create input', ['sessionId', 'workspace'], [
247
249
  'mode',
248
250
  'name',
249
251
  'labels',
252
+ 'modelTarget',
253
+ 'executorId',
250
254
  'thinkingLevel',
251
255
  'toolProfile',
252
256
  'permissionMode',
253
257
  'collaborationMode',
254
258
  'orchestrationMode',
255
259
  ]);
260
+ const executorId = Object.hasOwn(input, 'executorId')
261
+ ? executorIdValue(input.executorId)
262
+ : undefined;
263
+ const target = Object.hasOwn(input, 'modelTarget') ? modelTarget(input.modelTarget) : undefined;
264
+ if ((executorId === undefined) === (target === undefined)) {
265
+ throw invalidProtocolFrame('Session creation requires exactly one model target or executor id');
266
+ }
256
267
  return {
257
268
  sessionId: requireEntityId(input.sessionId, 'sessionId'),
258
269
  workspace: decodeWorkspaceTarget(input.workspace),
259
270
  ...(Object.hasOwn(input, 'mode') ? { mode: sessionStartMode(input.mode) } : {}),
260
271
  ...(Object.hasOwn(input, 'name') ? { name: sessionName(input.name) } : {}),
261
272
  ...(Object.hasOwn(input, 'labels') ? { labels: labels(input.labels) } : {}),
262
- modelTarget: modelTarget(input.modelTarget),
273
+ ...(target ? { modelTarget: target } : {}),
274
+ ...(executorId ? { executorId } : {}),
263
275
  ...(Object.hasOwn(input, 'thinkingLevel')
264
276
  ? { thinkingLevel: thinkingLevel(input.thinkingLevel) }
265
277
  : {}),
@@ -465,6 +477,7 @@ export function decodeSessionCatalogProjection(value) {
465
477
  ...optionalRevisionIndex(record),
466
478
  ...optionalRevisionState(record),
467
479
  backend: backend(record.backend),
480
+ ...optionalExecutorId(record),
468
481
  llmConnectionId: record.llmConnectionId === null
469
482
  ? null
470
483
  : requireEntityId(record.llmConnectionId, 'Session Connection id'),
@@ -476,6 +489,9 @@ export function decodeSessionCatalogProjection(value) {
476
489
  collaborationMode: collaborationMode(record.collaborationMode),
477
490
  orchestrationMode: orchestrationMode(record.orchestrationMode),
478
491
  };
492
+ if ((projection.backend === 'plugin-executor') !== (projection.executorId !== undefined)) {
493
+ throw invalidProtocolFrame('Session executor identity does not match its backend');
494
+ }
479
495
  requireEncodedByteLimit(projection, 'Session catalog projection', SESSION_CATALOG_RESULT_MAX_BYTES);
480
496
  return projection;
481
497
  }
@@ -631,11 +647,23 @@ function optionalThinkingLevel(record) {
631
647
  // header's durable backend, and rows written by builds that shipped
632
648
  // FakeBackend still hold it (#3211).
633
649
  function backend(value) {
634
- if (value !== 'ai-sdk' && value !== 'fake') {
650
+ if (value !== 'ai-sdk' && value !== 'plugin-executor' && value !== 'fake') {
635
651
  throw invalidProtocolFrame('Invalid Session backend');
636
652
  }
637
653
  return value;
638
654
  }
655
+ function executorIdValue(value) {
656
+ const id = requireUtf8String(value, 'Executor id', 128);
657
+ if (!isExecutorId(id)) {
658
+ throw invalidProtocolFrame('Invalid Executor id');
659
+ }
660
+ return id;
661
+ }
662
+ function optionalExecutorId(record) {
663
+ if (record.executorId === undefined)
664
+ return {};
665
+ return { executorId: executorIdValue(record.executorId) };
666
+ }
639
667
  function thinkingLevel(value) {
640
668
  if (!isThinkingLevel(value))
641
669
  throw invalidProtocolFrame('Invalid Session thinking level');
@@ -24,7 +24,7 @@ import { decodeSessionStatus } from './session-status.js';
24
24
  import { decodeSessionInteractionProjection, } from './interaction.js';
25
25
  import { decodeSessionMessageQueueProjection, } from './message.js';
26
26
  import { defineOperation } from './operation-spec.js';
27
- import { decodeMessageContent, decodeTurnSnapshot, } from './turn.js';
27
+ import { decodeMessageAdmissionContent, decodeTurnSnapshot, } from './turn.js';
28
28
  import { decodeGoalProjection } from './goal.js';
29
29
  import { decodeRuntimeResourceRef } from './runtime-resource.js';
30
30
  import { decodeSessionTranscriptBootstrap, SESSION_TRANSCRIPT_BOOTSTRAP_MAX_BYTES, } from './session-transcript.js';
@@ -452,6 +452,7 @@ function decodeAssistantDelta(value) {
452
452
  'text',
453
453
  'reset',
454
454
  'complete',
455
+ 'interrupted',
455
456
  ]);
456
457
  assertRequiredKeys(record, 'Session assistant delta', [
457
458
  'kind',
@@ -467,6 +468,10 @@ function decodeAssistantDelta(value) {
467
468
  if (record.complete !== undefined && record.complete !== true) {
468
469
  throw invalidProtocolFrame('Invalid Session assistant delta completion');
469
470
  }
471
+ if (record.interrupted !== undefined &&
472
+ (record.interrupted !== true || record.complete !== true)) {
473
+ throw invalidProtocolFrame('Interrupted assistant delta must be complete');
474
+ }
470
475
  if (record.reset !== undefined && record.reset !== true) {
471
476
  throw invalidProtocolFrame('Invalid Session assistant delta reset');
472
477
  }
@@ -487,6 +492,7 @@ function decodeAssistantDelta(value) {
487
492
  : requireUtf8BoundedString(record.text, 'Session assistant delta text', SESSION_LIVE_DELTA_MAX_BYTES),
488
493
  ...(record.reset === true ? { reset: true } : {}),
489
494
  ...(record.complete === true ? { complete: true } : {}),
495
+ ...(record.interrupted === true ? { interrupted: true } : {}),
490
496
  };
491
497
  }
492
498
  function decodeSessionFrameEvent(value) {
@@ -510,7 +516,7 @@ function decodeSessionSteeringEvent(record) {
510
516
  turnId: requireEntityId(record.turnId, 'turnId'),
511
517
  ts: requireCount(record.ts, 'Session steering event timestamp'),
512
518
  messageId: requireEntityId(record.messageId, 'messageId'),
513
- content: decodeMessageContent(record.content),
519
+ content: decodeMessageAdmissionContent(record.content),
514
520
  };
515
521
  }
516
522
  function decodeSessionToolEvent(value) {
@@ -17,7 +17,7 @@
17
17
  * under the License.
18
18
  */
19
19
  import { MAX_ATTACHMENT_BYTES, MAX_ATTACHMENT_COUNT } from '@maka/core/attachments';
20
- import { decodeMessageContent as decodeCanonicalMessageContent, DIRECTORY_REFERENCE_MAX_COUNT, isCanonicalAttachmentRef, } from '@maka/core/events';
20
+ import { decodeMessageContent as decodeCanonicalMessageContent, DIRECTORY_REFERENCE_MAX_COUNT, hasMeaningfulMessageContent, isCanonicalAttachmentRef, } from '@maka/core/events';
21
21
  import { isOrchestrationMode, isTurnOrchestrationSource, } from '@maka/core/orchestration';
22
22
  import { decodeSkillInvocationResult, } from '@maka/core/skill-invocation';
23
23
  import { invalidProtocolFrame } from './errors.js';
@@ -268,7 +268,15 @@ export function decodeMessageContent(value, allowEmptyText = false) {
268
268
  }
269
269
  /** Client-authored Messages cannot claim Host-owned Session context references. */
270
270
  export function decodeMessageAdmissionContent(value, allowEmptyText = false) {
271
- const content = decodeMessageContent(value, allowEmptyText);
271
+ // Structure first with text emptiness unconstrained, then apply the
272
+ // shared meaningful-content predicate: a quote or an attachment carries
273
+ // the turn by itself, so empty inline text is admissible when either is
274
+ // present (#4804). A truly contentless Message still throws, with the
275
+ // same frame error the text-length rule produced.
276
+ const content = decodeMessageContent(value, true);
277
+ if (!allowEmptyText && !hasMeaningfulMessageContent(content)) {
278
+ throw invalidProtocolFrame('Invalid Message text');
279
+ }
272
280
  if (content.attachments?.some((attachment) => attachment.ref.kind === 'session_context')) {
273
281
  throw invalidProtocolFrame('Session context references are Host-owned');
274
282
  }
@@ -112,6 +112,20 @@ export const WORKHUB_COORDINATION_OPERATION_SPECS = {
112
112
  decodeInput: decodeWorkHubCoordinationCandidatesInput,
113
113
  decodeOutput: decodeWorkHubCoordinationCandidatesResult,
114
114
  }),
115
+ 'workhub.coordination.selectAndDelegate': defineOperation({
116
+ mode: 'command',
117
+ availability: 'ready',
118
+ errors: [...TURN_ERRORS, 'candidate_set_stale'],
119
+ decodeInput: decodeWorkHubCoordinationSelectAndDelegateInput,
120
+ decodeOutput: (value) => {
121
+ const result = requireShapedRecord(value, 'WorkHub selection result', ['kind'], ['result']);
122
+ if (result.kind === 'cancelled' && result.result === undefined)
123
+ return { kind: 'cancelled' };
124
+ if (result.kind === 'delegated')
125
+ return { kind: 'delegated', result: decodeWorkHubCoordinationActResult(result.result) };
126
+ throw invalidProtocolFrame('Invalid WorkHub selection result');
127
+ },
128
+ }),
115
129
  'workhub.coordination.actFromTurn': defineOperation({
116
130
  mode: 'command',
117
131
  availability: 'ready',
@@ -169,6 +183,30 @@ export function decodeWorkHubCoordinationCandidatesResult(value) {
169
183
  candidates: result.candidates.map(decodeWorkHubCoordinationCandidate),
170
184
  };
171
185
  }
186
+ export function decodeWorkHubCoordinationSelectAndDelegateInput(value) {
187
+ const input = requireExactRecord(value, 'WorkHub selection input', [
188
+ 'turnId',
189
+ 'actionId',
190
+ 'candidateSetId',
191
+ 'candidateRefs',
192
+ 'delegationText',
193
+ ]);
194
+ if (!Array.isArray(input.candidateRefs) ||
195
+ input.candidateRefs.length < 1 ||
196
+ input.candidateRefs.length > WORKHUB_COORDINATION_CANDIDATE_MAX_ITEMS) {
197
+ throw invalidProtocolFrame('Invalid WorkHub selection candidates');
198
+ }
199
+ const candidateRefs = input.candidateRefs.map((ref) => requireEntityId(ref, 'WorkHub candidate reference'));
200
+ if (new Set(candidateRefs).size !== candidateRefs.length)
201
+ throw invalidProtocolFrame('Duplicate WorkHub selection candidates');
202
+ return {
203
+ turnId: requireEntityId(input.turnId, 'WorkHub Coordination Turn id'),
204
+ actionId: requireEntityId(input.actionId, 'WorkHub action id'),
205
+ candidateSetId: requireUtf8String(input.candidateSetId, 'WorkHub candidate set', 256),
206
+ candidateRefs,
207
+ delegationText: requireUtf8String(input.delegationText, 'WorkHub delegation text', WORKHUB_COORDINATION_TEXT_MAX_BYTES),
208
+ };
209
+ }
172
210
  export function decodeWorkHubCoordinationActFromTurnInput(value) {
173
211
  const input = requireShapedRecord(value, 'WorkHub active Turn action input', ['turnId', 'actionId', 'proposal'], ['candidateSetId', 'create', 'newWorkDefaults', 'delegationText']);
174
212
  const fields = decodeWorkHubCoordinationActionFields(input);
@@ -43,6 +43,7 @@ export function bindHostChildAgentBackend(authority, parentSessionId) {
43
43
  },
44
44
  agentProfile: input.agentProfile,
45
45
  ...(input.subagentId ? { subagentId: input.subagentId } : {}),
46
+ ...(input.executorId ? { executorId: input.executorId } : {}),
46
47
  prompt: input.prompt,
47
48
  ...(input.swarm ? { swarm: input.swarm } : {}),
48
49
  abortSignal: input.abortSignal,
@@ -22,7 +22,7 @@ import { isAbsolute, resolve } from 'node:path';
22
22
  import { MAX_ATTACHMENT_BYTES } from '@maka/core/attachments';
23
23
  import { createToolResultArchiveCapability, } from '@maka/runtime/tool-result-archive-capability';
24
24
  import { isPathInside } from '@maka/runtime/path-containment';
25
- import { createLedgerArchivePreparer, createLedgerArchiveResourceReader, createLedgerToolResultArchiveReader, } from '@maka/runtime/ledger-tool-result-archive-reader';
25
+ import { createLedgerArchivePreparer, createLedgerArchiveResourceReader, } from '@maka/runtime/ledger-tool-result-archive-reader';
26
26
  export function createHostExecutionArtifactServices(input) {
27
27
  const runWrite = async (operation) => {
28
28
  try {
@@ -61,9 +61,6 @@ export function createHostExecutionArtifactServices(input) {
61
61
  const prepareLedger = input.archiveEvidence
62
62
  ? createLedgerArchivePreparer(input.archiveEvidence)
63
63
  : undefined;
64
- const readLedger = input.archiveEvidence
65
- ? createLedgerToolResultArchiveReader(input.archiveEvidence)
66
- : undefined;
67
64
  const readLedgerResource = input.archiveEvidence
68
65
  ? createLedgerArchiveResourceReader(input.archiveEvidence)
69
66
  : undefined;
@@ -102,12 +99,9 @@ export function createHostExecutionArtifactServices(input) {
102
99
  },
103
100
  toolResultArchive: createToolResultArchiveCapability({
104
101
  archiveToolResult: prepareLedgerForCommit,
105
- readToolResultArchive: (event) => event.rewriteVersion === 2
106
- ? (readLedger?.(event) ?? { ok: false, reason: 'read_failed' })
107
- : readArchive(input.artifacts, event),
108
- readArchivedToolResultResource: (event) => event.storage === 'ledger'
102
+ readArchivedToolResultResource: (event) => event.storage === 'ledger' || event.storage === 'event'
109
103
  ? (readLedgerResource?.(event) ?? { ok: false, reason: 'read_failed' })
110
- : readArchive(input.artifacts, event),
104
+ : { ok: false, reason: 'read_failed' },
111
105
  }),
112
106
  };
113
107
  return Object.freeze(services);
@@ -166,24 +160,3 @@ async function readBoundedSourceFile(cwd, sourcePath) {
166
160
  function contentBytes(content) {
167
161
  return typeof content === 'string' ? Buffer.byteLength(content, 'utf8') : content.byteLength;
168
162
  }
169
- async function readArchive(artifacts, event) {
170
- const entry = await artifacts.getInSession(event.sessionId, event.artifactId);
171
- const record = entry.record;
172
- if (!record)
173
- return { ok: false, reason: 'not_found' };
174
- if (record.source !== 'tool_result_archive')
175
- return { ok: false, reason: 'source_mismatch' };
176
- if (record.sizeBytes !== event.originalBytes)
177
- return { ok: false, reason: 'size_mismatch' };
178
- const read = await artifacts.readTextInSession(event.sessionId, event.artifactId, {
179
- maxBytes: event.maxBytes ?? event.originalBytes,
180
- });
181
- if (!read.ok)
182
- return read;
183
- if (sha256(read.text) !== event.bodySha256)
184
- return { ok: false, reason: 'corrupt' };
185
- return { ok: true, serializedResult: read.text };
186
- }
187
- function sha256(text) {
188
- return createHash('sha256').update(text).digest('hex');
189
- }
@@ -51,6 +51,8 @@ import { PluginAttachmentService } from '@maka/runtime/plugin-attachment-service
51
51
  import { PluginApprovalService } from '@maka/runtime/plugin-approval-service';
52
52
  import { PluginFilesystemService } from '@maka/runtime/plugin-fs-service';
53
53
  import { PluginLlmService } from '@maka/runtime/plugin-llm-service';
54
+ import { PluginExecutorBackend } from '@maka/runtime/plugin-executor-backend';
55
+ import { PluginExecutorService } from '@maka/runtime/plugin-executor-service';
54
56
  import { PluginShellService } from '@maka/runtime/plugin-shell-service';
55
57
  import { PluginUserQuestionService } from '@maka/runtime/plugin-user-question-service';
56
58
  import { PluginWebService } from '@maka/runtime/plugin-web-service';
@@ -153,6 +155,7 @@ import { HostWorkHubCoordinationCoordinator } from './workhub-coordination-coord
153
155
  import { WorkHubActionEffectFailure, workHubResumedTurnId, } from './workhub-coordination-action-gate.js';
154
156
  import { createHostWebSearchService, createHostWebSearchToolFromService, resolveHostTavilyWebSearchReadiness, shouldResolveHostTavilyWebSearchReadiness, } from './web-search-tool.js';
155
157
  import { createHostWebFetchService, createHostWebFetchToolFromService } from './web-fetch-tool.js';
158
+ import { buildBackgroundTaskHealthTool } from '@maka/runtime/background-task-health-tool';
156
159
  import { createHostExecutionArtifactServices } from './execution-artifacts.js';
157
160
  import { openToolResultArchiveEvidenceReader } from '@maka/storage/tool-result-archive-evidence';
158
161
  import { createRuntimeHostWorkspaceExecutionComposition, RuntimeHostWorkspaceExecutionError, } from './workspace-execution-composition.js';
@@ -198,6 +201,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
198
201
  let goalExecutions;
199
202
  let pluginPlatform;
200
203
  let manager;
204
+ let invalidatePluginExecutorBackends = () => undefined;
201
205
  let modelMetadataRefresh;
202
206
  let archiveEvidence;
203
207
  try {
@@ -208,6 +212,11 @@ export async function createExecutionRuntimeHostComposition(context, options = {
208
212
  new PluginUserQuestionService(pluginRoot, pluginAgents);
209
213
  const pluginFilesystem = new PluginFilesystemService(pluginRoot, pluginAgents);
210
214
  const pluginLlm = new PluginLlmService(pluginRoot, pluginAgents);
215
+ const pluginExecutors = new PluginExecutorService(pluginRoot, {
216
+ // Retirement aborts its generation before backend disposal begins, so the
217
+ // terminal event preserves executor-retired instead of looking like Stop.
218
+ onChanged: () => queueMicrotask(invalidatePluginExecutorBackends),
219
+ });
211
220
  const pluginShellEnv = new PluginShellEnvService(pluginRoot);
212
221
  const pluginShell = new PluginShellService(pluginRoot, pluginAgents, pluginShellEnv);
213
222
  const pluginWeb = new PluginWebService(pluginRoot, pluginAgents);
@@ -231,6 +240,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
231
240
  tools: pluginTools,
232
241
  systemPrompt: pluginSystemPrompt,
233
242
  commands: pluginCommands,
243
+ executors: pluginExecutors,
234
244
  });
235
245
  const pluginPlatformCoordinator = new HostPluginPlatformCoordinator(pluginPlatform);
236
246
  const openedProjectCatalog = storage.projectCatalog;
@@ -457,6 +467,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
457
467
  const webFetchService = createHostWebFetchService({
458
468
  policy: runtimePolicyStores.operations,
459
469
  });
470
+ const backgroundTaskHealthTool = buildBackgroundTaskHealthTool(runtimeResources, webFetchService);
460
471
  pluginWeb.bindRuntime({
461
472
  search: ({ query, limit, abortSignal }) => webSearchService.search({ query, limit, ...(abortSignal ? { abortSignal } : {}) }),
462
473
  fetch: (input) => webFetchService.fetch(input),
@@ -479,6 +490,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
479
490
  const childHostTools = [
480
491
  createHostWebSearchToolFromService(webSearchService),
481
492
  createHostWebFetchToolFromService(webFetchService),
493
+ backgroundTaskHealthTool,
482
494
  ...runtimePolicy.modelTools,
483
495
  ];
484
496
  const hostTools = [...childHostTools, ...historyTools];
@@ -751,6 +763,23 @@ export async function createExecutionRuntimeHostComposition(context, options = {
751
763
  backends.register('ai-sdk', dependencies.primaryBackendFactory ?? {
752
764
  prepare: (backendContext) => prepareHostAiSdkBackend(hostAiSdkBackendInput(backendContext)),
753
765
  });
766
+ backends.register('plugin-executor', {
767
+ prepare: async (backendContext) => {
768
+ const executorId = backendContext.header.executorId;
769
+ if (!executorId)
770
+ throw new Error('Plugin executor Session is missing its executor id');
771
+ const binding = pluginExecutors.bind(backendContext.sessionId, executorId);
772
+ return {
773
+ providerStateIdentity: binding.providerStateIdentity,
774
+ build: (factoryContext) => new PluginExecutorBackend({
775
+ sessionId: factoryContext.sessionId,
776
+ cwd: factoryContext.header.cwd,
777
+ ...(factoryContext.systemPrompt ? { instructions: factoryContext.systemPrompt } : {}),
778
+ binding,
779
+ }),
780
+ };
781
+ },
782
+ });
754
783
  const runtimeAuthority = {
755
784
  bindRun: (identity) => messages.bindRun(identity),
756
785
  executeRoot: (input) => executeHostedExecutionToSettlement(requireRootCoordinator(rootCoordinator), input),
@@ -793,6 +822,8 @@ export async function createExecutionRuntimeHostComposition(context, options = {
793
822
  };
794
823
  resolveAvailableToolNames = async (sessionId) => {
795
824
  const header = await stores.sessionStore.readHeaderSnapshot(sessionId);
825
+ if (header.backend === 'plugin-executor')
826
+ return [];
796
827
  if (header.subagentRuntime) {
797
828
  if (!header.subagentParent) {
798
829
  throw new Error('Subagent runtime snapshot requires a linked child session');
@@ -970,6 +1001,12 @@ export async function createExecutionRuntimeHostComposition(context, options = {
970
1001
  toolBoundaryProtocol: stores.runtimeEventStore.toolBoundaryProtocol,
971
1002
  backends,
972
1003
  subagentCatalog,
1004
+ assertChildExecutorAvailable: (parentSessionId, executorId) => {
1005
+ const identity = pluginExecutors.identity(parentSessionId, executorId);
1006
+ if (identity.scopeId !== 'profile') {
1007
+ throw new Error(`Session-scoped executor cannot be inherited by a child Session: ${executorId}`);
1008
+ }
1009
+ },
973
1010
  newId: randomUUID,
974
1011
  now: Date.now,
975
1012
  safeBoundaryResumeEnabled: process.env.MAKA_RUNTIME_SAFE_BOUNDARY_RESUME === '1',
@@ -1052,6 +1089,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
1052
1089
  const registerBackendInvalidation = () => {
1053
1090
  observeBackendInvalidation(requireSessionManager(manager).refreshIdleBackends());
1054
1091
  };
1092
+ invalidatePluginExecutorBackends = registerBackendInvalidation;
1055
1093
  const registerConfigurationMutation = () => {
1056
1094
  hostChanges.publishConfiguration();
1057
1095
  registerBackendInvalidation();
@@ -1263,6 +1301,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
1263
1301
  return new Promise((resolve, reject) => {
1264
1302
  void spawn({
1265
1303
  agentProfile: options.agentProfile ?? 'implementation',
1304
+ ...(options.executorId ? { executorId: options.executorId } : {}),
1266
1305
  prompt: options.prompt,
1267
1306
  ...(options.signal ? { abortSignal: options.signal } : {}),
1268
1307
  onReady: (ready) => resolve({
@@ -1512,12 +1551,16 @@ export async function createExecutionRuntimeHostComposition(context, options = {
1512
1551
  continuity: continuityCoordinator,
1513
1552
  workspaceResolver,
1514
1553
  requestDrain: context.requestDrain,
1554
+ assertExecutorAvailable: (sessionId, executorId) => {
1555
+ pluginExecutors.identity(sessionId, executorId);
1556
+ },
1515
1557
  ...(context.sessionAccessAuthority
1516
1558
  ? { sessionAccessAuthority: context.sessionAccessAuthority }
1517
1559
  : {}),
1518
1560
  });
1519
1561
  workHubCoordination = new HostWorkHubCoordinationCoordinator({
1520
1562
  routingModel: dependencies.workHubRoutingModel,
1563
+ requestForm: (input) => interactions.requestForm(input),
1521
1564
  configureModel: (input) => sessionCatalog.configureWorkHubModel(input),
1522
1565
  transitionConfiguration: (input) => requireSessionManager(manager).transitionSessionConfiguration(WORKHUB_COORDINATION_SESSION_ID, input),
1523
1566
  stateRoot: context.owner.capability.canonicalPath,
@@ -1658,14 +1701,18 @@ export async function createExecutionRuntimeHostComposition(context, options = {
1658
1701
  sessionId: input.targetSessionId,
1659
1702
  workspace: input.create.workspace,
1660
1703
  name: input.create.title,
1661
- modelTarget: input.create.defaults?.model
1662
- ? {
1663
- kind: 'explicit',
1664
- connectionId: input.create.defaults.model.llmConnectionId,
1665
- connectionSlug: input.create.defaults.model.llmConnectionSlug,
1666
- model: input.create.defaults.model.model,
1667
- }
1668
- : { kind: 'default' },
1704
+ ...(input.create.defaults?.executorId
1705
+ ? { executorId: input.create.defaults.executorId }
1706
+ : {
1707
+ modelTarget: input.create.defaults?.model
1708
+ ? {
1709
+ kind: 'explicit',
1710
+ connectionId: input.create.defaults.model.llmConnectionId,
1711
+ connectionSlug: input.create.defaults.model.llmConnectionSlug,
1712
+ model: input.create.defaults.model.model,
1713
+ }
1714
+ : { kind: 'default' },
1715
+ }),
1669
1716
  ...(input.create.defaults?.permissionMode
1670
1717
  ? { permissionMode: input.create.defaults.permissionMode }
1671
1718
  : {}),
@@ -1689,6 +1736,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
1689
1736
  });
1690
1737
  const persisted = durable ??
1691
1738
  (await sessionAdmission.runMany([WORKHUB_COORDINATION_SESSION_ID, input.targetSessionId], async (lease) => {
1739
+ await input.validateFreshTarget?.();
1692
1740
  const rootState = coordinator.readRootState(input.targetSessionId);
1693
1741
  if (!create && rootState.kind === 'reserved') {
1694
1742
  throw new WorkHubActionEffectFailure('session_busy', 'A target root Turn is being admitted');
@@ -17,6 +17,7 @@
17
17
  * under the License.
18
18
  */
19
19
  import { JsonArrayPageBudget } from './json-array-page-budget.js';
20
+ import { ExternalSessionLimitError, } from '@maka/core/external-session';
20
21
  import { ExternalSessionImporter } from '@maka/storage/external-sessions';
21
22
  import { EXTERNAL_SESSION_CWD_MAX_BYTES, EXTERNAL_SESSION_IMPORTED_SESSION_IDS_MAX_ITEMS, EXTERNAL_SESSION_NAME_MAX_BYTES, EXTERNAL_SESSION_PAGE_MAX_ITEMS, EXTERNAL_SESSION_RESULT_MAX_BYTES, EXTERNAL_SESSION_SOURCE_MAX_ITEMS, EXTERNAL_SESSION_SOURCE_SESSION_ID_MAX_BYTES, } from '../protocol/index.js';
22
23
  import { projectSessionCatalogRecord, SessionOperationFailure, NoUsableImportModelError, } from './session-catalog-coordinator.js';
@@ -198,6 +199,15 @@ export class HostExternalSessionCoordinator {
198
199
  }
199
200
  catch (error) {
200
201
  if (!commitAttempted) {
202
+ if (error instanceof ExternalSessionLimitError) {
203
+ return {
204
+ ok: true,
205
+ result: {
206
+ kind: 'source_limit_exceeded',
207
+ limit: { kind: error.limit.kind, max: error.limit.max },
208
+ },
209
+ };
210
+ }
201
211
  return importFailure(isSourceSessionNotFound(error) ? 'not_found' : 'source_unreadable', isSourceSessionNotFound(error)
202
212
  ? 'External Session does not exist'
203
213
  : 'External Session could not be read or converted');
@@ -218,7 +228,10 @@ export class HostExternalSessionCoordinator {
218
228
  }
219
229
  try {
220
230
  const record = await this.#sessions.readCatalogRecord(header.id);
221
- return { ok: true, result: { session: projectSessionCatalogRecord(record) } };
231
+ return {
232
+ ok: true,
233
+ result: { kind: 'imported', session: projectSessionCatalogRecord(record) },
234
+ };
222
235
  }
223
236
  catch {
224
237
  this.#requestDrain();