maka-agent 0.2.1-dev.91.20261018 → 0.2.2-dev.97.20261024

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 (418) hide show
  1. package/DISCLAIMER-WIP +1 -1
  2. package/LICENSE +15 -11
  3. package/README.md +173 -1
  4. package/README.zh-CN.md +156 -0
  5. package/THIRD_PARTY_NOTICES.txt +12 -12
  6. package/dist/cli-core.js +1 -0
  7. package/dist/pi-goal.js +13 -0
  8. package/dist/pi-tui-runner.js +44 -1
  9. package/dist/run-command-core.js +256 -48
  10. package/dist/run-session-command.js +534 -0
  11. package/dist/run-session-result.js +38 -0
  12. package/dist/run-turn-outcome.js +174 -0
  13. package/dist/runtime-host-cli.js +32 -17
  14. package/dist/runtime-host-run-command.js +53 -165
  15. package/dist/runtime-host-run-mcp.js +3 -0
  16. package/dist/runtime-host-session-channel.js +3 -1
  17. package/dist/runtime-host-session-driver.js +5 -0
  18. package/dist/runtime-host-setup-command.js +114 -7
  19. package/dist/tui-copy-catalog.js +24 -0
  20. package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
  21. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/docs/docs/api/Client.md +2 -0
  22. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/core/connect.js +10 -4
  23. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/core/symbols.js +1 -0
  24. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/agent.js +6 -2
  25. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client-h1.js +0 -2
  26. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client-h2.js +0 -4
  27. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client.js +3 -2
  28. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/dispatcher-base.js +12 -0
  29. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/cache-handler.js +48 -0
  30. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/deduplication-handler.js +57 -13
  31. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/redirect-handler.js +8 -1
  32. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/interceptor/decompress.js +15 -5
  33. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/index.js +3 -1
  34. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/parse.js +138 -137
  35. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/util.js +21 -2
  36. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/eventsource/eventsource-stream.js +90 -9
  37. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/eventsource/eventsource.js +4 -1
  38. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/fetch/index.js +3 -3
  39. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/infra/index.js +14 -0
  40. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
  41. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/websocket/receiver.js +13 -0
  42. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/package.json +1 -1
  43. package/node_modules/@maka/acp-executor-plugin/dist/acp-catalog-store.js +87 -0
  44. package/node_modules/@maka/acp-executor-plugin/dist/acp-catalog.js +98 -21
  45. package/node_modules/@maka/acp-executor-plugin/dist/index.js +90 -14
  46. package/node_modules/@maka/acp-executor-plugin/dist/plugin.mjs +3997 -56
  47. package/node_modules/@maka/core/dist/assistant-turn-ids.js +34 -0
  48. package/node_modules/@maka/core/dist/bot-chat-settings.js +10 -1
  49. package/node_modules/@maka/core/dist/event-wait-delivery.js +67 -0
  50. package/node_modules/@maka/core/dist/event-wait.js +75 -10
  51. package/node_modules/@maka/core/dist/executor-catalog.js +3 -1
  52. package/node_modules/@maka/core/dist/goal.js +54 -2
  53. package/node_modules/@maka/core/dist/model-catalog.js +19 -1
  54. package/node_modules/@maka/core/dist/model-metadata.generated.js +4 -14
  55. package/node_modules/@maka/core/dist/model-metadata.js +42 -1
  56. package/node_modules/@maka/core/dist/models-dev-projection.js +32 -1
  57. package/node_modules/@maka/core/dist/provider-registry.js +16 -2
  58. package/node_modules/@maka/core/dist/runtime-event-store.js +0 -1
  59. package/node_modules/@maka/core/dist/runtime-event.js +24 -2
  60. package/node_modules/@maka/core/dist/runtime-invocation.js +10 -0
  61. package/node_modules/@maka/core/dist/session-checkin.js +31 -0
  62. package/node_modules/@maka/core/dist/tool-ledger-scanner.js +1 -9
  63. package/node_modules/@maka/core/dist/tool-recovery-bundle.js +1 -14
  64. package/node_modules/@maka/core/dist/turn-origin.js +14 -2
  65. package/node_modules/@maka/core/dist/usage-stats/types.js +1 -0
  66. package/node_modules/@maka/core/package.json +3 -0
  67. package/node_modules/@maka/eval/node_modules/undici/README.md +25 -3
  68. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
  69. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Client.md +11 -6
  70. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
  71. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Errors.md +76 -1
  72. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
  73. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
  74. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
  75. package/node_modules/@maka/eval/node_modules/undici/docs/docs/index.md +12 -12
  76. package/node_modules/@maka/eval/node_modules/undici/docs/docs/type-map.json +66 -66
  77. package/node_modules/@maka/eval/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
  78. package/node_modules/@maka/eval/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
  79. package/node_modules/@maka/eval/node_modules/undici/lib/core/connect.js +10 -4
  80. package/node_modules/@maka/eval/node_modules/undici/lib/core/constants.js +12 -1
  81. package/node_modules/@maka/eval/node_modules/undici/lib/core/errors.js +38 -1
  82. package/node_modules/@maka/eval/node_modules/undici/lib/core/request.js +16 -1
  83. package/node_modules/@maka/eval/node_modules/undici/lib/core/symbols.js +2 -0
  84. package/node_modules/@maka/eval/node_modules/undici/lib/core/util.js +26 -1
  85. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/agent.js +6 -2
  86. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
  87. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
  88. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client.js +4 -1
  89. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
  90. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
  91. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
  92. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
  93. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/pool.js +11 -8
  94. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
  95. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
  96. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
  97. package/node_modules/@maka/eval/node_modules/undici/lib/handler/cache-handler.js +153 -15
  98. package/node_modules/@maka/eval/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
  99. package/node_modules/@maka/eval/node_modules/undici/lib/handler/redirect-handler.js +28 -8
  100. package/node_modules/@maka/eval/node_modules/undici/lib/handler/retry-handler.js +44 -11
  101. package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/cache.js +11 -3
  102. package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/decompress.js +22 -9
  103. package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/dns.js +11 -0
  104. package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/response-error.js +72 -28
  105. package/node_modules/@maka/eval/node_modules/undici/lib/milo/LICENSE.md +7 -0
  106. package/node_modules/@maka/eval/node_modules/undici/lib/milo/no-simd.js +1002 -0
  107. package/node_modules/@maka/eval/node_modules/undici/lib/milo/simd.js +1002 -0
  108. package/node_modules/@maka/eval/node_modules/undici/lib/mock/mock-agent.js +11 -0
  109. package/node_modules/@maka/eval/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
  110. package/node_modules/@maka/eval/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
  111. package/node_modules/@maka/eval/node_modules/undici/lib/util/cache.js +11 -5
  112. package/node_modules/@maka/eval/node_modules/undici/lib/web/cookies/util.js +19 -2
  113. package/node_modules/@maka/eval/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
  114. package/node_modules/@maka/eval/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
  115. package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/body.js +47 -38
  116. package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
  117. package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/headers.js +2 -2
  118. package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/index.js +8 -4
  119. package/node_modules/@maka/eval/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
  120. package/node_modules/@maka/eval/node_modules/undici/lib/web/websocket/receiver.js +25 -4
  121. package/node_modules/@maka/eval/node_modules/undici/package.json +9 -7
  122. package/node_modules/@maka/mcp/package.json +1 -1
  123. package/node_modules/@maka/runtime/dist/agent-run.js +5 -1
  124. package/node_modules/@maka/runtime/dist/agent-swarm-status-tool.js +0 -1
  125. package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +29 -15
  126. package/node_modules/@maka/runtime/dist/ai-sdk-message-projection.js +10 -1
  127. package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +125 -131
  128. package/node_modules/@maka/runtime/dist/bots/bot-registry.js +19 -3
  129. package/node_modules/@maka/runtime/dist/bots/feishu-bridge.js +178 -6
  130. package/node_modules/@maka/runtime/dist/bots/wechat-bridge.js +163 -9
  131. package/node_modules/@maka/runtime/dist/context-budget-policy.js +9 -2
  132. package/node_modules/@maka/runtime/dist/event-wait-tool.js +69 -0
  133. package/node_modules/@maka/runtime/dist/goal-continuation.js +195 -117
  134. package/node_modules/@maka/runtime/dist/goal-state.js +8 -0
  135. package/node_modules/@maka/runtime/dist/history-compact-checkpoint.js +34 -4
  136. package/node_modules/@maka/runtime/dist/history-compaction.js +7 -0
  137. package/node_modules/@maka/runtime/dist/memory-extraction.js +0 -2
  138. package/node_modules/@maka/runtime/dist/model-factory.js +26 -6
  139. package/node_modules/@maka/runtime/dist/model-fetcher.js +8 -1
  140. package/node_modules/@maka/runtime/dist/model-history.js +16 -3
  141. package/node_modules/@maka/runtime/dist/openai-codex-history-compactor.js +15 -5
  142. package/node_modules/@maka/runtime/dist/plan-tools.js +0 -3
  143. package/node_modules/@maka/runtime/dist/plugin-executor-backend.js +49 -2
  144. package/node_modules/@maka/runtime/dist/plugin-executor-service.js +12 -3
  145. package/node_modules/@maka/runtime/dist/provider-error-classification.js +2 -0
  146. package/node_modules/@maka/runtime/dist/recovery-resolver.js +2 -1
  147. package/node_modules/@maka/runtime/dist/runtime-context.js +53 -0
  148. package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +3 -0
  149. package/node_modules/@maka/runtime/dist/sandbox-boundary-path.js +79 -2
  150. package/node_modules/@maka/runtime/dist/session-checkin.js +331 -0
  151. package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +7 -0
  152. package/node_modules/@maka/runtime/dist/session-manager.js +5 -1
  153. package/node_modules/@maka/runtime/dist/shell-run-manager.js +34 -0
  154. package/node_modules/@maka/runtime/dist/stream-graph-supervisor-tools.js +0 -3
  155. package/node_modules/@maka/runtime/dist/telemetry/builtin-pricing.js +21 -2
  156. package/node_modules/@maka/runtime/dist/tool-runtime.js +11 -2
  157. package/node_modules/@maka/runtime/dist/workers/filesystem-worker.mjs +50 -1
  158. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/docs/docs/api/Client.md +2 -0
  159. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/core/connect.js +10 -4
  160. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/core/symbols.js +1 -0
  161. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/agent.js +6 -2
  162. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client-h1.js +0 -2
  163. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client-h2.js +0 -4
  164. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client.js +3 -2
  165. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/dispatcher-base.js +12 -0
  166. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/cache-handler.js +48 -0
  167. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/deduplication-handler.js +57 -13
  168. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/redirect-handler.js +8 -1
  169. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/interceptor/decompress.js +15 -5
  170. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/index.js +3 -1
  171. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/parse.js +138 -137
  172. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/util.js +21 -2
  173. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/eventsource/eventsource-stream.js +90 -9
  174. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/eventsource/eventsource.js +4 -1
  175. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/fetch/index.js +3 -3
  176. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/infra/index.js +14 -0
  177. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
  178. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/websocket/receiver.js +13 -0
  179. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/package.json +1 -1
  180. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/package.json +1 -1
  181. package/node_modules/@maka/runtime/node_modules/undici/README.md +25 -3
  182. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
  183. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Client.md +11 -6
  184. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
  185. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Errors.md +76 -1
  186. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
  187. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
  188. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
  189. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/index.md +12 -12
  190. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/type-map.json +66 -66
  191. package/node_modules/@maka/runtime/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
  192. package/node_modules/@maka/runtime/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
  193. package/node_modules/@maka/runtime/node_modules/undici/lib/core/connect.js +10 -4
  194. package/node_modules/@maka/runtime/node_modules/undici/lib/core/constants.js +12 -1
  195. package/node_modules/@maka/runtime/node_modules/undici/lib/core/errors.js +38 -1
  196. package/node_modules/@maka/runtime/node_modules/undici/lib/core/request.js +16 -1
  197. package/node_modules/@maka/runtime/node_modules/undici/lib/core/symbols.js +2 -0
  198. package/node_modules/@maka/runtime/node_modules/undici/lib/core/util.js +26 -1
  199. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/agent.js +6 -2
  200. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
  201. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
  202. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client.js +4 -1
  203. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
  204. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
  205. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
  206. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
  207. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/pool.js +11 -8
  208. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
  209. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
  210. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
  211. package/node_modules/@maka/runtime/node_modules/undici/lib/handler/cache-handler.js +153 -15
  212. package/node_modules/@maka/runtime/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
  213. package/node_modules/@maka/runtime/node_modules/undici/lib/handler/redirect-handler.js +28 -8
  214. package/node_modules/@maka/runtime/node_modules/undici/lib/handler/retry-handler.js +44 -11
  215. package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/cache.js +11 -3
  216. package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/decompress.js +22 -9
  217. package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/dns.js +11 -0
  218. package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/response-error.js +72 -28
  219. package/node_modules/@maka/runtime/node_modules/undici/lib/milo/LICENSE.md +7 -0
  220. package/node_modules/@maka/runtime/node_modules/undici/lib/milo/no-simd.js +1002 -0
  221. package/node_modules/@maka/runtime/node_modules/undici/lib/milo/simd.js +1002 -0
  222. package/node_modules/@maka/runtime/node_modules/undici/lib/mock/mock-agent.js +11 -0
  223. package/node_modules/@maka/runtime/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
  224. package/node_modules/@maka/runtime/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
  225. package/node_modules/@maka/runtime/node_modules/undici/lib/util/cache.js +11 -5
  226. package/node_modules/@maka/runtime/node_modules/undici/lib/web/cookies/util.js +19 -2
  227. package/node_modules/@maka/runtime/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
  228. package/node_modules/@maka/runtime/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
  229. package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/body.js +47 -38
  230. package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
  231. package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/headers.js +2 -2
  232. package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/index.js +8 -4
  233. package/node_modules/@maka/runtime/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
  234. package/node_modules/@maka/runtime/node_modules/undici/lib/web/websocket/receiver.js +25 -4
  235. package/node_modules/@maka/runtime/node_modules/undici/package.json +9 -7
  236. package/node_modules/@maka/runtime/package.json +3 -0
  237. package/node_modules/@maka/runtime-host/dist/assistant/bot/bridge.js +8 -0
  238. package/node_modules/@maka/runtime-host/dist/assistant/bot/capabilities.js +1 -0
  239. package/node_modules/@maka/runtime-host/dist/assistant/bot/controller.js +92 -22
  240. package/node_modules/@maka/runtime-host/dist/assistant/bot/host.js +11 -2
  241. package/node_modules/@maka/runtime-host/dist/assistant/bot/store.js +71 -2
  242. package/node_modules/@maka/runtime-host/dist/assistant/bot/turn-ids.js +38 -0
  243. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/assistant.js +7 -0
  244. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/controller.js +193 -32
  245. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/discovery-capabilities.js +69 -0
  246. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/host.js +15 -28
  247. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/notebook.js +286 -0
  248. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/prompt.js +31 -6
  249. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/store.js +18 -1
  250. package/node_modules/@maka/runtime-host/dist/assistant/memory-network/controller.js +203 -71
  251. package/node_modules/@maka/runtime-host/dist/assistant/memory-network/host.js +21 -5
  252. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition-observer.js +94 -0
  253. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition-store.js +253 -0
  254. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition.js +133 -0
  255. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/controller.js +27 -14
  256. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/delegation.js +37 -5
  257. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/delivery.js +1 -1
  258. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/host.js +16 -2
  259. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/matter.js +13 -0
  260. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/prompt.js +7 -5
  261. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/review.js +68 -14
  262. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/settlement-context.js +126 -0
  263. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/store.js +92 -6
  264. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/tools.js +93 -23
  265. package/node_modules/@maka/runtime-host/dist/assistant/service.js +72 -16
  266. package/node_modules/@maka/runtime-host/dist/client/host-profile.js +30 -1
  267. package/node_modules/@maka/runtime-host/dist/client/ssh-operator-activation.js +9 -2
  268. package/node_modules/@maka/runtime-host/dist/protocol/goal.js +119 -1
  269. package/node_modules/@maka/runtime-host/dist/protocol/index.js +10 -3
  270. package/node_modules/@maka/runtime-host/dist/protocol/operations.js +8 -1
  271. package/node_modules/@maka/runtime-host/dist/protocol/personal-assistant.js +1 -0
  272. package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +7 -1
  273. package/node_modules/@maka/runtime-host/dist/protocol/session-checkin.js +133 -0
  274. package/node_modules/@maka/runtime-host/dist/server/agent-settings-tools.js +0 -1
  275. package/node_modules/@maka/runtime-host/dist/server/canonical-session-projection.js +3 -2
  276. package/node_modules/@maka/runtime-host/dist/server/event-wait-manager.js +151 -20
  277. package/node_modules/@maka/runtime-host/dist/server/event-wait-observation-store.js +19 -0
  278. package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +127 -11
  279. package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +47 -3
  280. package/node_modules/@maka/runtime-host/dist/server/execution-model-composition.js +11 -0
  281. package/node_modules/@maka/runtime-host/dist/server/external-session-coordinator.js +5 -2
  282. package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +343 -53
  283. package/node_modules/@maka/runtime-host/dist/server/goal-event-waits.js +457 -0
  284. package/node_modules/@maka/runtime-host/dist/server/goal-execution-coordinator.js +23 -6
  285. package/node_modules/@maka/runtime-host/dist/server/goal-projection.js +24 -3
  286. package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +5 -1
  287. package/node_modules/@maka/runtime-host/dist/server/index.js +2 -0
  288. package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +44 -2
  289. package/node_modules/@maka/runtime-host/dist/server/personal-assistant-workspace.js +78 -0
  290. package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +8 -0
  291. package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +73 -3
  292. package/node_modules/@maka/runtime-host/dist/server/session-checkin.js +257 -0
  293. package/node_modules/@maka/runtime-host/dist/server/session-checkpoint-coordinator.js +282 -0
  294. package/node_modules/@maka/runtime-host/dist/server/session-checkpoint-publication.js +250 -0
  295. package/node_modules/@maka/runtime-host/dist/server/shell-run-event-wait-access.js +166 -0
  296. package/node_modules/@maka/runtime-host/dist/server/shell-run-event-wait-adapter.js +59 -0
  297. package/node_modules/@maka/runtime-host/dist/server/skill-catalog-repository.js +4 -2
  298. package/node_modules/@maka/storage/dist/agent-run-store-contract.js +14 -3
  299. package/node_modules/@maka/storage/dist/agent-run-store.js +10 -0
  300. package/node_modules/@maka/storage/dist/codex-session-adapter.js +20 -3
  301. package/node_modules/@maka/storage/dist/context-offload-snapshot.js +2 -1
  302. package/node_modules/@maka/storage/dist/event-wait-authority.js +18 -1
  303. package/node_modules/@maka/storage/dist/event-wait-bridge.js +336 -0
  304. package/node_modules/@maka/storage/dist/execution-stores.js +39 -1
  305. package/node_modules/@maka/storage/dist/external-session-images.js +131 -0
  306. package/node_modules/@maka/storage/dist/external-session-importer.js +12 -2
  307. package/node_modules/@maka/storage/dist/goal-authority.js +2 -0
  308. package/node_modules/@maka/storage/dist/local-execution-persistence.js +27 -1
  309. package/node_modules/@maka/storage/dist/operational-state-store.js +1 -1
  310. package/node_modules/@maka/storage/dist/production-session-snapshot.js +14 -6
  311. package/node_modules/@maka/storage/dist/runtime-event-persistence.js +1 -0
  312. package/node_modules/@maka/storage/dist/session-bundle-policy.js +116 -16
  313. package/node_modules/@maka/storage/dist/session-checkpoint-publication-store.js +204 -0
  314. package/node_modules/@maka/storage/dist/session-store.js +37 -8
  315. package/node_modules/@maka/storage/dist/snapshot-operation-gate.js +65 -0
  316. package/node_modules/@maka/storage/dist/sqlite-context-offload-schema.js +3 -3
  317. package/node_modules/@maka/storage/dist/sqlite-context-offload-store.js +4 -2
  318. package/node_modules/@maka/storage/dist/sqlite-event-wait-authority.js +81 -8
  319. package/node_modules/@maka/storage/dist/sqlite-event-wait-bridge.js +94 -0
  320. package/node_modules/@maka/storage/dist/sqlite-reclamation-checkpoint.js +37 -0
  321. package/node_modules/@maka/storage/dist/sqlite-runtime-schema.js +7 -8
  322. package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +38 -162
  323. package/node_modules/@maka/storage/dist/sqlite-workflow-schema.js +7 -4
  324. package/node_modules/@maka/storage/dist/tool-commit-validation.js +1 -1
  325. package/node_modules/@maka/storage/package.json +4 -0
  326. package/node_modules/@modelcontextprotocol/client/dist/index-B-4n9P0J.d.mts.map +1 -0
  327. package/node_modules/@modelcontextprotocol/client/dist/index-J2FaQ-KY.d.cts.map +1 -0
  328. package/node_modules/@modelcontextprotocol/client/dist/index.cjs +76 -22
  329. package/node_modules/@modelcontextprotocol/client/dist/index.d.cts.map +1 -1
  330. package/node_modules/@modelcontextprotocol/client/dist/index.d.mts.map +1 -1
  331. package/node_modules/@modelcontextprotocol/client/dist/index.mjs +76 -22
  332. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.cjs +1 -1
  333. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.mjs +1 -1
  334. package/node_modules/@modelcontextprotocol/client/dist/{src-oZBjf3U1.cjs → src-DpAS0jfg.cjs} +105 -8
  335. package/node_modules/@modelcontextprotocol/client/dist/{src-xKF0PJN-.mjs → src-WCy6ifGf.mjs} +88 -9
  336. package/node_modules/@modelcontextprotocol/client/dist/stdio.cjs +1 -1
  337. package/node_modules/@modelcontextprotocol/client/dist/stdio.mjs +1 -1
  338. package/node_modules/@modelcontextprotocol/client/node_modules/@modelcontextprotocol/core/package.json +2 -2
  339. package/node_modules/@modelcontextprotocol/client/package.json +5 -5
  340. package/node_modules/fast-uri/.github/workflows/release.yml +35 -0
  341. package/node_modules/fast-uri/README.md +8 -0
  342. package/node_modules/fast-uri/index.js +98 -18
  343. package/node_modules/fast-uri/lib/utils.js +52 -0
  344. package/node_modules/fast-uri/package.json +1 -1
  345. package/node_modules/follow-redirects/index.js +10 -1
  346. package/node_modules/follow-redirects/package.json +1 -1
  347. package/node_modules/ip-address/README.md +104 -104
  348. package/node_modules/ip-address/dist/ipv4.js +7 -0
  349. package/node_modules/ip-address/dist/ipv6.js +7 -4
  350. package/node_modules/ip-address/dist/v6/constants.js +3 -0
  351. package/node_modules/ip-address/package.json +2 -1
  352. package/node_modules/undici/README.md +25 -3
  353. package/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
  354. package/node_modules/undici/docs/docs/api/Client.md +11 -6
  355. package/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
  356. package/node_modules/undici/docs/docs/api/Errors.md +76 -1
  357. package/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
  358. package/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
  359. package/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
  360. package/node_modules/undici/docs/docs/index.md +12 -12
  361. package/node_modules/undici/docs/docs/type-map.json +66 -66
  362. package/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
  363. package/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
  364. package/node_modules/undici/lib/core/connect.js +10 -4
  365. package/node_modules/undici/lib/core/constants.js +12 -1
  366. package/node_modules/undici/lib/core/errors.js +38 -1
  367. package/node_modules/undici/lib/core/request.js +16 -1
  368. package/node_modules/undici/lib/core/symbols.js +2 -0
  369. package/node_modules/undici/lib/core/util.js +26 -1
  370. package/node_modules/undici/lib/dispatcher/agent.js +6 -2
  371. package/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
  372. package/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
  373. package/node_modules/undici/lib/dispatcher/client.js +4 -1
  374. package/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
  375. package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
  376. package/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
  377. package/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
  378. package/node_modules/undici/lib/dispatcher/pool.js +11 -8
  379. package/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
  380. package/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
  381. package/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
  382. package/node_modules/undici/lib/handler/cache-handler.js +153 -15
  383. package/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
  384. package/node_modules/undici/lib/handler/redirect-handler.js +28 -8
  385. package/node_modules/undici/lib/handler/retry-handler.js +44 -11
  386. package/node_modules/undici/lib/interceptor/cache.js +11 -3
  387. package/node_modules/undici/lib/interceptor/decompress.js +22 -9
  388. package/node_modules/undici/lib/interceptor/dns.js +11 -0
  389. package/node_modules/undici/lib/interceptor/response-error.js +72 -28
  390. package/node_modules/undici/lib/milo/LICENSE.md +7 -0
  391. package/node_modules/undici/lib/milo/no-simd.js +1002 -0
  392. package/node_modules/undici/lib/milo/simd.js +1002 -0
  393. package/node_modules/undici/lib/mock/mock-agent.js +11 -0
  394. package/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
  395. package/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
  396. package/node_modules/undici/lib/util/cache.js +11 -5
  397. package/node_modules/undici/lib/web/cookies/util.js +19 -2
  398. package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
  399. package/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
  400. package/node_modules/undici/lib/web/fetch/body.js +47 -38
  401. package/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
  402. package/node_modules/undici/lib/web/fetch/headers.js +2 -2
  403. package/node_modules/undici/lib/web/fetch/index.js +8 -4
  404. package/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
  405. package/node_modules/undici/lib/web/websocket/receiver.js +25 -4
  406. package/node_modules/undici/package.json +9 -7
  407. package/node_modules/zod/package.json +1 -1
  408. package/node_modules/zod/v4/core/compile.cjs +8 -0
  409. package/node_modules/zod/v4/core/compile.js +8 -0
  410. package/node_modules/zod/v4/core/schemas.cjs +30 -0
  411. package/node_modules/zod/v4/core/schemas.js +30 -0
  412. package/node_modules/zod/v4/core/util.cjs +15 -0
  413. package/node_modules/zod/v4/core/util.js +14 -0
  414. package/node_modules/zod/v4/core/versions.cjs +1 -1
  415. package/node_modules/zod/v4/core/versions.js +1 -1
  416. package/package.json +2 -2
  417. package/node_modules/@modelcontextprotocol/client/dist/index-D_CiY-T3.d.cts.map +0 -1
  418. package/node_modules/@modelcontextprotocol/client/dist/index-D_QDtbiv.d.mts.map +0 -1
@@ -0,0 +1,174 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ import { failureClassFromCompleteStopReason } from '@maka/core/events';
20
+ export class TurnOutcomeClassifier {
21
+ #outcomeId;
22
+ #unresolvedSandboxFailures = new Set();
23
+ #finalOutput;
24
+ #finalOutputFromLive = false;
25
+ #terminal;
26
+ constructor(outcomeId) {
27
+ this.#outcomeId = outcomeId;
28
+ }
29
+ accept(observation) {
30
+ switch (observation?.kind) {
31
+ case undefined:
32
+ return;
33
+ case 'output':
34
+ // A subscriber is delivered in Host order, so the stream's last answer
35
+ // is the Turn's last answer. A transcript read stops wherever the Host
36
+ // had committed, so it can supply an answer the stream never carried
37
+ // but can never overrule one it did.
38
+ if (observation.source === 'stored' && this.#finalOutputFromLive)
39
+ return;
40
+ this.#finalOutput = observation.text;
41
+ this.#finalOutputFromLive = observation.source === 'live';
42
+ return;
43
+ case 'terminal':
44
+ if (observation.update === 'replace' || this.#terminal === undefined) {
45
+ this.#terminal = observation;
46
+ }
47
+ return;
48
+ case 'tool_result': {
49
+ if (observation.outcome === 'sandbox_failure') {
50
+ this.#unresolvedSandboxFailures.add(observation.toolUseId);
51
+ }
52
+ return;
53
+ }
54
+ }
55
+ }
56
+ outcome(incomplete) {
57
+ const terminal = this.#terminal;
58
+ if (!terminal && incomplete === 'pending')
59
+ return undefined;
60
+ const completed = terminal?.status === 'completed';
61
+ const sandboxBoundary = this.#unresolvedSandboxFailures.size > 0 ? 'unresolved' : 'none';
62
+ const failure = terminal?.status === 'failed'
63
+ ? terminal.failure
64
+ : {
65
+ class: 'missing_terminal_event',
66
+ message: 'Turn ended unexpectedly',
67
+ };
68
+ return {
69
+ outcomeId: this.#outcomeId,
70
+ status: completed ? 'completed' : 'failed',
71
+ ...(completed && this.#finalOutput !== undefined ? { finalOutput: this.#finalOutput } : {}),
72
+ ...(!completed ? { failure } : {}),
73
+ sandboxBoundary,
74
+ };
75
+ }
76
+ }
77
+ export function observationFromSessionEvent(event) {
78
+ if (event.type === 'text_complete' && event.text.trim().length > 0) {
79
+ return { kind: 'output', text: event.text, source: 'live' };
80
+ }
81
+ if (event.type === 'error') {
82
+ return {
83
+ kind: 'terminal',
84
+ update: 'replace',
85
+ status: 'failed',
86
+ failure: { class: event.reason ?? event.code ?? 'runtime_error', message: event.message },
87
+ };
88
+ }
89
+ if (event.type === 'abort') {
90
+ return {
91
+ kind: 'terminal',
92
+ update: 'replace',
93
+ status: 'failed',
94
+ failure: { class: 'aborted', message: 'Turn was cancelled' },
95
+ };
96
+ }
97
+ if (event.type === 'complete') {
98
+ return observationFromCompleteEvent(event);
99
+ }
100
+ return event.type === 'tool_result' ? observationFromToolResult(event) : undefined;
101
+ }
102
+ function observationFromStoredMessage(message) {
103
+ if (message.type === 'assistant' && message.text.trim().length > 0) {
104
+ return { kind: 'output', text: message.text, source: 'stored' };
105
+ }
106
+ if (message.type === 'turn_state' && message.status === 'completed') {
107
+ return { kind: 'terminal', update: 'replace', status: 'completed' };
108
+ }
109
+ if (message.type === 'turn_state' && message.status === 'aborted') {
110
+ return {
111
+ kind: 'terminal',
112
+ update: 'replace',
113
+ status: 'failed',
114
+ failure: { class: 'aborted', message: 'Turn was cancelled' },
115
+ };
116
+ }
117
+ if (message.type === 'turn_state' && message.status === 'failed') {
118
+ return {
119
+ kind: 'terminal',
120
+ update: 'replace',
121
+ status: 'failed',
122
+ failure: {
123
+ class: message.errorClass ?? 'runtime_error',
124
+ message: message.failureMessage ?? message.errorClass ?? 'Turn failed',
125
+ },
126
+ };
127
+ }
128
+ return message.type === 'tool_result' ? observationFromToolResult(message) : undefined;
129
+ }
130
+ function observationFromCompleteEvent(event) {
131
+ if (event.stopReason === 'user_stop') {
132
+ return {
133
+ kind: 'terminal',
134
+ update: 'if_unset',
135
+ status: 'failed',
136
+ failure: { class: 'aborted', message: 'Turn was cancelled' },
137
+ };
138
+ }
139
+ const failureClass = failureClassFromCompleteStopReason(event.stopReason);
140
+ return failureClass
141
+ ? {
142
+ kind: 'terminal',
143
+ update: 'if_unset',
144
+ status: 'failed',
145
+ failure: { class: failureClass },
146
+ }
147
+ : { kind: 'terminal', update: 'if_unset', status: 'completed' };
148
+ }
149
+ function observationFromToolResult(result) {
150
+ if (result.isError && result.content.kind === 'text' && result.content.sandboxFailure) {
151
+ return {
152
+ kind: 'tool_result',
153
+ toolUseId: result.toolUseId,
154
+ outcome: 'sandbox_failure',
155
+ };
156
+ }
157
+ return result.isError
158
+ ? undefined
159
+ : { kind: 'tool_result', toolUseId: result.toolUseId, outcome: 'success' };
160
+ }
161
+ export function outcomeFromStoredTurn(messages, turnId) {
162
+ return classifierFromStoredTurn(messages, turnId, turnId).outcome('pending');
163
+ }
164
+ export function classifierFromStoredTurn(messages, turnId, outcomeId) {
165
+ const classifier = new TurnOutcomeClassifier(outcomeId);
166
+ acceptStoredTurn(classifier, messages, turnId);
167
+ return classifier;
168
+ }
169
+ export function acceptStoredTurn(classifier, messages, turnId) {
170
+ for (const message of messages) {
171
+ if (message.turnId === turnId)
172
+ classifier.accept(observationFromStoredMessage(message));
173
+ }
174
+ }
@@ -19,7 +19,7 @@
19
19
  import { isAbsolute } from 'node:path';
20
20
  import { isProductReleaseVersion, isSha512PackageIntegrity, } from '@maka/runtime-host/operator/update-package-evidence';
21
21
  import { createRuntimeHostLegacyPosixOperatorCommand, decodeRuntimeHostPosixOperatorCommand, decodeRuntimeHostWebRtcStunPolicy, } from '@maka/runtime-host/operator';
22
- import { canonicalProjectDirectoryRootSpec, isCanonicalRuntimeHostWebSocketPath, PROJECT_DIRECTORY_MAX_ROOTS, projectDirectoryPosixRootSpecValid, projectDirectoryRootSpecValid, } from '@maka/runtime-host/protocol';
22
+ import { canonicalProjectDirectoryRootSpec, isCanonicalRuntimeHostWebSocketPath, PROJECT_DIRECTORY_MAX_ROOTS, projectDirectoryRootSpecValid, } from '@maka/runtime-host/protocol';
23
23
  import { hasEphemeralRuntimeHostPeerPort } from './runtime-host-peer-artifact.js';
24
24
  import { installedUpdateHelpText, isRuntimeHostHelpTopic, runtimeHostCommandHelpText, runtimeHostHelpText, } from './runtime-host-help.js';
25
25
  export function parseRuntimeHostCommand(argv, cliCommand = 'maka') {
@@ -372,12 +372,26 @@ function parseSetupCommand(argv) {
372
372
  let repairRootAfterRemount = false;
373
373
  let updateExisting = false;
374
374
  let reuseExistingEnvironment = false;
375
+ let expectedOperator;
375
376
  let allowInterruptActiveTasks = false;
376
377
  let clientDataRoot;
377
378
  let enableDirectPeer = false;
378
379
  const coordinationRelays = [];
379
380
  const options = parseManagedServiceOptions(argv, {
380
381
  valueOptions: {
382
+ '--expected-operator-json': (value) => {
383
+ if (expectedOperator)
384
+ return error('Duplicate --expected-operator-json');
385
+ try {
386
+ const operator = decodeRuntimeHostPosixOperatorCommand(JSON.parse(value));
387
+ if (operator.kind !== 'node')
388
+ return error('Expected a POSIX Node operator');
389
+ expectedOperator = operator;
390
+ }
391
+ catch {
392
+ return error('--expected-operator-json must contain a POSIX Node operator');
393
+ }
394
+ },
381
395
  '--client-data-root': (value) => {
382
396
  if (clientDataRoot !== undefined)
383
397
  return error('Duplicate --client-data-root');
@@ -447,6 +461,10 @@ function parseSetupCommand(argv) {
447
461
  });
448
462
  if ('kind' in options)
449
463
  return options;
464
+ if ((options.managedRootId !== undefined || expectedOperator !== undefined) &&
465
+ (!reuseExistingEnvironment || !options.managedRootId || !expectedOperator)) {
466
+ return error('Node recovery requires --reuse-existing-environment, --managed-root-id, and --expected-operator-json');
467
+ }
450
468
  if (reuseExistingEnvironment &&
451
469
  (lifecycle !== 'on_demand' ||
452
470
  updateExisting ||
@@ -480,6 +498,9 @@ function parseSetupCommand(argv) {
480
498
  ...(repairRootAfterRemount ? { repairRootAfterRemount: true } : {}),
481
499
  ...(updateExisting ? { updateExisting: true } : {}),
482
500
  ...(reuseExistingEnvironment ? { reuseExistingEnvironment: true } : {}),
501
+ ...(expectedOperator
502
+ ? { expectedExisting: { rootId: options.managedRootId, operator: expectedOperator } }
503
+ : {}),
483
504
  ...(allowInterruptActiveTasks ? { allowInterruptActiveTasks: true } : {}),
484
505
  ...(clientDataRoot ? { clientDataRoot } : {}),
485
506
  ...(enableDirectPeer ? { directPeer: { coordinationRelays } } : {}),
@@ -1187,9 +1208,7 @@ function parseManagedServiceOptions(argv, input = {}) {
1187
1208
  return error('--project-root cannot be combined with --no-project-roots');
1188
1209
  }
1189
1210
  projectDirectoryPolicySpecified = true;
1190
- const root = argument === '--project-root'
1191
- ? parseProjectRoot(parsed, 'posix')
1192
- : parseProjectRootJson(parsed, 'posix');
1211
+ const root = argument === '--project-root' ? parseProjectRoot(parsed) : parseProjectRootJson(parsed);
1193
1212
  if ('kind' in root)
1194
1213
  return root;
1195
1214
  if (projectDirectoryRoots.length >= PROJECT_DIRECTORY_MAX_ROOTS) {
@@ -1717,9 +1736,7 @@ function parseServeCommand(argv) {
1717
1736
  const parsed = optionValue(argv, index, argument);
1718
1737
  if (typeof parsed !== 'string')
1719
1738
  return parsed;
1720
- const root = argument === '--project-root'
1721
- ? parseProjectRoot(parsed, 'native')
1722
- : parseProjectRootJson(parsed, 'native');
1739
+ const root = argument === '--project-root' ? parseProjectRoot(parsed) : parseProjectRootJson(parsed);
1723
1740
  if ('kind' in root)
1724
1741
  return root;
1725
1742
  if (projectDirectoryRoots.length >= PROJECT_DIRECTORY_MAX_ROOTS) {
@@ -1906,7 +1923,7 @@ function parseServeCommand(argv) {
1906
1923
  }),
1907
1924
  };
1908
1925
  }
1909
- function parseProjectRoot(value, pathKind) {
1926
+ function parseProjectRoot(value) {
1910
1927
  const separator = value.indexOf('=');
1911
1928
  if (separator <= 0 || separator === value.length - 1) {
1912
1929
  return error('--project-root must use <label>=<absolute-path>');
@@ -1915,12 +1932,12 @@ function parseProjectRoot(value, pathKind) {
1915
1932
  label: value.slice(0, separator),
1916
1933
  path: value.slice(separator + 1),
1917
1934
  });
1918
- if (!projectRootValid(root, pathKind)) {
1919
- return error(`--project-root must use a valid label and absolute ${pathKind === 'posix' ? 'POSIX' : 'Host'} path`);
1935
+ if (!projectRootValid(root)) {
1936
+ return error(`--project-root must use a valid label and absolute Host path`);
1920
1937
  }
1921
1938
  return root;
1922
1939
  }
1923
- function parseProjectRootJson(value, pathKind) {
1940
+ function parseProjectRootJson(value) {
1924
1941
  let parsed;
1925
1942
  try {
1926
1943
  parsed = JSON.parse(value);
@@ -1941,15 +1958,13 @@ function parseProjectRootJson(value, pathKind) {
1941
1958
  label: root.label,
1942
1959
  path: root.path,
1943
1960
  });
1944
- if (!projectRootValid(canonical, pathKind)) {
1945
- return error(`--project-root-json must use a valid label and absolute ${pathKind === 'posix' ? 'POSIX' : 'Host'} path`);
1961
+ if (!projectRootValid(canonical)) {
1962
+ return error(`--project-root-json must use a valid label and absolute Host path`);
1946
1963
  }
1947
1964
  return canonical;
1948
1965
  }
1949
- function projectRootValid(root, pathKind) {
1950
- return pathKind === 'posix'
1951
- ? projectDirectoryPosixRootSpecValid(root)
1952
- : projectDirectoryRootSpecValid(root) && isAbsolute(root.path);
1966
+ function projectRootValid(root) {
1967
+ return projectDirectoryRootSpecValid(root) && isAbsolute(root.path);
1953
1968
  }
1954
1969
  function parseAccessCommand(argv) {
1955
1970
  const action = argv[0];
@@ -16,16 +16,19 @@
16
16
  * specific language governing permissions and limitations
17
17
  * under the License.
18
18
  */
19
- import { failureClassFromCompleteStopReason } from '@maka/core/events';
20
19
  import { findProjectByIdentity } from '@maka/core/project';
21
20
  import { projectSessionCatalogSummary, readRuntimeHostSessions, readRuntimeHostProjects, RuntimeHostOperationError, isRuntimeHostReconnectingConnection, } from '@maka/runtime-host/client';
22
21
  import { runtimeHostProfileUsesHostWorkspace } from '@maka/runtime-host/profile-kind';
23
22
  import { runMakaTextCliCore, } from './run-command-core.js';
24
- import { connectRuntimeHostCli, resolveRuntimeHostCliTarget, } from './runtime-host-cli-context.js';
23
+ import { connectRuntimeHostCli, connectRuntimeHostCliConnection, resolveRuntimeHostCliTarget, } from './runtime-host-cli-context.js';
25
24
  import { createRuntimeHostMakaSessionDriver, } from './runtime-host-session-driver.js';
26
25
  import { RuntimeHostRunMcp } from './runtime-host-run-mcp.js';
27
26
  import { formatRuntimeHostCliTaskBlockers, isRuntimeHostCliTaskBlocked, readRuntimeHostCliTaskReadiness, } from './runtime-host-task-readiness.js';
28
27
  import { resolveMakaClientDataRoot } from './workspace-root.js';
28
+ import { TurnOutcomeClassifier, observationFromSessionEvent, outcomeFromStoredTurn, acceptStoredTurn, } from './run-turn-outcome.js';
29
+ import { RunQuestionAvailable } from './run-session-result.js';
30
+ import { isTemporaryNpxInstallation } from './runtime-host-cli-installation.js';
31
+ import { runMakaSessionCommand } from './run-session-command.js';
29
32
  const GRAPH_POLL_INTERVAL_MS = 25;
30
33
  export async function runRuntimeHostTextCli(argv, overrides = {}, commandOverrides = {}, options = {
31
34
  cliCommand: 'maka',
@@ -39,6 +42,19 @@ export async function runRuntimeHostTextCli(argv, overrides = {}, commandOverrid
39
42
  };
40
43
  try {
41
44
  return await commandDeps.run(argv, {
45
+ runSession: async (sessionOptions, env) => {
46
+ const context = await connectRuntimeHostCliConnection({
47
+ rootPath: env.workspaceRoot(),
48
+ ...(sessionOptions.hostProfileId ? { profileId: sessionOptions.hostProfileId } : {}),
49
+ clientDataRoot: options.clientDataRoot,
50
+ });
51
+ try {
52
+ return await runMakaSessionCommand(context.connection, sessionOptions, env, context.profile.kind !== 'local' || !(await isTemporaryNpxInstallation()));
53
+ }
54
+ finally {
55
+ await context.close();
56
+ }
57
+ },
42
58
  listSessions: async (rootPath, hostProfileId) => runtimeHostSessionSummaries(await readRuntimeHostSessions((await connect(rootPath, hostProfileId)).connection)),
43
59
  createContext: async (input) => {
44
60
  const context = await connect(input.workspaceRoot, input.hostProfileId);
@@ -87,7 +103,7 @@ export function createRuntimeHostRunContext(connection, catalog, input, override
87
103
  ...(input.projectId ? { workspace: { kind: 'project', projectId: input.projectId } } : {}),
88
104
  ...(mcp ? { prepareSession: (sessionId) => mcp.prepare(sessionId) } : {}),
89
105
  });
90
- const runtime = new RuntimeHostRunRuntime(connection, driver, mcp, input.runOutcomeObserver, input.enableAgentGraph === true, input.sessionCwdOverride, input.maxSteps);
106
+ const runtime = new RuntimeHostRunRuntime(connection, driver, mcp, input.runOutcomeObserver, input.enableAgentGraph === true, input.sessionCwdOverride, input.maxSteps, input.noWait === true, input.allowDetach !== false);
91
107
  return {
92
108
  runtime,
93
109
  target: { connection: { slug: target.connection.slug }, model: target.model },
@@ -130,7 +146,10 @@ async function prepareRuntimeHostRunInput(connection, catalog, profile, input, c
130
146
  if (isRuntimeHostCliTaskBlocked(snapshot)) {
131
147
  throw new Error(`Task is not ready:\n${formatRuntimeHostCliTaskBlockers(snapshot, cliCommand)}`);
132
148
  }
133
- return preparedInput;
149
+ return {
150
+ ...preparedInput,
151
+ allowDetach: runtimeHostProfileUsesHostWorkspace(profile.kind) || !(await isTemporaryNpxInstallation()),
152
+ };
134
153
  }
135
154
  class RuntimeHostRunRuntime {
136
155
  #connection;
@@ -140,6 +159,8 @@ class RuntimeHostRunRuntime {
140
159
  #graphEnabled;
141
160
  #sessionCwdOverride;
142
161
  #maxSteps;
162
+ #noWait;
163
+ #allowDetach;
143
164
  #unsubscribeTranscriptReplacements;
144
165
  #sessionId;
145
166
  #activeTurn;
@@ -149,7 +170,7 @@ class RuntimeHostRunRuntime {
149
170
  #graphAdmissionTurnIds = new Set();
150
171
  #latestTranscriptReplacement;
151
172
  #graphTerminalWaiters = new Map();
152
- constructor(connection, driver, mcp, observer, graphEnabled, sessionCwdOverride, maxSteps) {
173
+ constructor(connection, driver, mcp, observer, graphEnabled, sessionCwdOverride, maxSteps, noWait = false, allowDetach = true) {
153
174
  this.#connection = connection;
154
175
  this.#driver = driver;
155
176
  this.#mcp = mcp;
@@ -157,7 +178,9 @@ class RuntimeHostRunRuntime {
157
178
  this.#graphEnabled = graphEnabled;
158
179
  this.#sessionCwdOverride = sessionCwdOverride;
159
180
  this.#maxSteps = maxSteps;
160
- this.#interactions = new NonInteractiveInteractionController(driver, (pending) => this.#stopForInteraction(pending));
181
+ this.#noWait = noWait;
182
+ this.#allowDetach = allowDetach;
183
+ this.#interactions = new NonInteractiveInteractionController(driver, (pending) => this.#stopForInteraction(pending), () => this.#allowDetach && !this.#graphEnabled && !this.#mcp?.ownsServers, () => this.#noWait);
161
184
  this.#unsubscribeTranscriptReplacements = driver.subscribeTranscriptReplacements((sessionId, turnId, messages) => {
162
185
  this.#acceptRootTranscript(sessionId, turnId, messages);
163
186
  this.#acceptGraphTranscript(messages);
@@ -177,6 +200,10 @@ class RuntimeHostRunRuntime {
177
200
  await this.#mcp?.ready();
178
201
  if (this.#stopRequested)
179
202
  throw new Error('Turn was cancelled before start');
203
+ if (this.#noWait && !this.#allowDetach)
204
+ throw new Error('--no-wait requires a persistent installation; temporary npx invocations may own the Host lifetime');
205
+ if (this.#noWait && this.#mcp?.ownsServers)
206
+ throw new Error('--no-wait cannot detach client-owned MCP servers; use the blocking run path');
180
207
  if (input.turnOrchestration?.mode === 'graph') {
181
208
  this.#graphAdmissionTurnIds = graphSupervisorTurnIds(await this.#driver.readMessages());
182
209
  }
@@ -331,6 +358,14 @@ class RuntimeHostRunRuntime {
331
358
  this.#sessionId = sessionId;
332
359
  }
333
360
  async *#observeTurn(turn, active) {
361
+ if (this.#noWait) {
362
+ await this.#observer?.({
363
+ outcomeId: active.runId,
364
+ status: 'running',
365
+ sandboxBoundary: 'none',
366
+ });
367
+ return;
368
+ }
334
369
  const events = turn.events[Symbol.asyncIterator]();
335
370
  for (;;) {
336
371
  const next = await this.#interactions.race(events.next());
@@ -441,150 +476,6 @@ class RuntimeHostRunRuntime {
441
476
  function runtimeHostSessionSummaries(items) {
442
477
  return items.flatMap((item) => ('kind' in item ? [] : [projectSessionCatalogSummary(item)]));
443
478
  }
444
- class TurnOutcomeClassifier {
445
- #outcomeId;
446
- #unresolvedSandboxFailures = new Set();
447
- #finalOutput;
448
- #finalOutputFromLive = false;
449
- #terminal;
450
- constructor(outcomeId) {
451
- this.#outcomeId = outcomeId;
452
- }
453
- accept(observation) {
454
- switch (observation?.kind) {
455
- case undefined:
456
- return;
457
- case 'output':
458
- // A subscriber is delivered in Host order, so the stream's last answer
459
- // is the Turn's last answer. A transcript read stops wherever the Host
460
- // had committed, so it can supply an answer the stream never carried
461
- // but can never overrule one it did.
462
- if (observation.source === 'stored' && this.#finalOutputFromLive)
463
- return;
464
- this.#finalOutput = observation.text;
465
- this.#finalOutputFromLive = observation.source === 'live';
466
- return;
467
- case 'terminal':
468
- if (observation.update === 'replace' || this.#terminal === undefined) {
469
- this.#terminal = observation;
470
- }
471
- return;
472
- case 'tool_result': {
473
- if (observation.outcome === 'sandbox_failure') {
474
- this.#unresolvedSandboxFailures.add(observation.toolUseId);
475
- }
476
- // No clearing path: `maka run` denies every widening request, so the
477
- // boundary cannot move mid-Turn and a later success cannot prove that
478
- // a blocked call recovered. The failure stays unresolved to the end.
479
- return;
480
- }
481
- }
482
- }
483
- outcome(incomplete) {
484
- const terminal = this.#terminal;
485
- if (!terminal && incomplete === 'pending')
486
- return undefined;
487
- const completed = terminal?.status === 'completed';
488
- const sandboxBoundary = this.#unresolvedSandboxFailures.size > 0 ? 'unresolved' : 'none';
489
- const failure = terminal?.status === 'failed'
490
- ? terminal.failure
491
- : {
492
- class: 'missing_terminal_event',
493
- message: 'Turn ended unexpectedly',
494
- };
495
- return {
496
- outcomeId: this.#outcomeId,
497
- status: completed ? 'completed' : 'failed',
498
- ...(completed && this.#finalOutput !== undefined ? { finalOutput: this.#finalOutput } : {}),
499
- ...(!completed ? { failure } : {}),
500
- sandboxBoundary,
501
- };
502
- }
503
- }
504
- function observationFromSessionEvent(event) {
505
- if (event.type === 'text_complete' && event.text.trim().length > 0) {
506
- return { kind: 'output', text: event.text, source: 'live' };
507
- }
508
- if (event.type === 'error') {
509
- return {
510
- kind: 'terminal',
511
- update: 'replace',
512
- status: 'failed',
513
- failure: { class: event.reason ?? event.code ?? 'runtime_error', message: event.message },
514
- };
515
- }
516
- if (event.type === 'abort') {
517
- return {
518
- kind: 'terminal',
519
- update: 'replace',
520
- status: 'failed',
521
- failure: { class: 'aborted', message: 'Turn was cancelled' },
522
- };
523
- }
524
- if (event.type === 'complete') {
525
- return observationFromCompleteEvent(event);
526
- }
527
- return event.type === 'tool_result' ? observationFromToolResult(event) : undefined;
528
- }
529
- function observationFromStoredMessage(message) {
530
- if (message.type === 'assistant' && message.text.trim().length > 0) {
531
- return { kind: 'output', text: message.text, source: 'stored' };
532
- }
533
- if (message.type === 'turn_state' && message.status === 'completed') {
534
- return { kind: 'terminal', update: 'replace', status: 'completed' };
535
- }
536
- if (message.type === 'turn_state' && message.status === 'aborted') {
537
- return {
538
- kind: 'terminal',
539
- update: 'replace',
540
- status: 'failed',
541
- failure: { class: 'aborted', message: 'Turn was cancelled' },
542
- };
543
- }
544
- if (message.type === 'turn_state' && message.status === 'failed') {
545
- return {
546
- kind: 'terminal',
547
- update: 'replace',
548
- status: 'failed',
549
- failure: {
550
- class: message.errorClass ?? 'runtime_error',
551
- message: 'Agent Graph final Turn failed',
552
- },
553
- };
554
- }
555
- return message.type === 'tool_result' ? observationFromToolResult(message) : undefined;
556
- }
557
- function observationFromCompleteEvent(event) {
558
- if (event.stopReason === 'user_stop') {
559
- return {
560
- kind: 'terminal',
561
- update: 'if_unset',
562
- status: 'failed',
563
- failure: { class: 'aborted', message: 'Turn was cancelled' },
564
- };
565
- }
566
- const failureClass = failureClassFromCompleteStopReason(event.stopReason);
567
- return failureClass
568
- ? {
569
- kind: 'terminal',
570
- update: 'if_unset',
571
- status: 'failed',
572
- failure: { class: failureClass },
573
- }
574
- : { kind: 'terminal', update: 'if_unset', status: 'completed' };
575
- }
576
- function observationFromToolResult(result) {
577
- if (result.isError && result.content.kind === 'text' && result.content.sandboxFailure) {
578
- return {
579
- kind: 'tool_result',
580
- toolUseId: result.toolUseId,
581
- outcome: 'sandbox_failure',
582
- };
583
- }
584
- return result.isError
585
- ? undefined
586
- : { kind: 'tool_result', toolUseId: result.toolUseId, outcome: 'success' };
587
- }
588
479
  function graphSupervisorTurnIds(messages) {
589
480
  return new Set(messages.flatMap((message) => message.type === 'user' && message.origin?.kind === 'agent_graph' ? [message.turnId] : []));
590
481
  }
@@ -595,31 +486,21 @@ function lastNewGraphSupervisorTurnId(messages, admissionTurnIds) {
595
486
  message.origin?.kind === 'agent_graph' &&
596
487
  !admissionTurnIds.has(message.turnId))?.turnId;
597
488
  }
598
- function outcomeFromStoredTurn(messages, turnId) {
599
- return classifierFromStoredTurn(messages, turnId, turnId).outcome('pending');
600
- }
601
- function classifierFromStoredTurn(messages, turnId, outcomeId) {
602
- const classifier = new TurnOutcomeClassifier(outcomeId);
603
- acceptStoredTurn(classifier, messages, turnId);
604
- return classifier;
605
- }
606
- function acceptStoredTurn(classifier, messages, turnId) {
607
- for (const message of messages) {
608
- if (message.turnId === turnId)
609
- classifier.accept(observationFromStoredMessage(message));
610
- }
611
- }
612
489
  class NonInteractiveInteractionController {
613
490
  #driver;
614
491
  #stop;
492
+ #canReturnQuestion;
493
+ #detached;
615
494
  #handled = new Set();
616
495
  #tasks = new Set();
617
496
  #unsubscribe;
618
497
  #failure;
619
498
  #failureWaiters = new Set();
620
- constructor(driver, stop) {
499
+ constructor(driver, stop, canReturnQuestion, detached) {
621
500
  this.#driver = driver;
622
501
  this.#stop = stop;
502
+ this.#canReturnQuestion = canReturnQuestion;
503
+ this.#detached = detached;
623
504
  this.#unsubscribe = driver.subscribePendingInteractions((pending) => this.#accept(pending));
624
505
  }
625
506
  race(operation) {
@@ -648,6 +529,10 @@ class NonInteractiveInteractionController {
648
529
  this.#unsubscribe();
649
530
  }
650
531
  #accept(pending) {
532
+ // Admission can publish interactions before its response arrives. A detached
533
+ // launcher never decides or stops them; later Session commands own handoff.
534
+ if (this.#detached())
535
+ return;
651
536
  if (this.#handled.has(pending.interactionId))
652
537
  return;
653
538
  this.#handled.add(pending.interactionId);
@@ -665,6 +550,9 @@ class NonInteractiveInteractionController {
665
550
  });
666
551
  return;
667
552
  }
553
+ if (pending.request.kind === 'question' && this.#canReturnQuestion()) {
554
+ throw new RunQuestionAvailable(pending);
555
+ }
668
556
  await this.#stop(pending);
669
557
  throw new Error(pending.request.kind === 'question'
670
558
  ? 'interactive user questions are unavailable in non-interactive mode'
@@ -139,6 +139,9 @@ export class RuntimeHostRunMcp {
139
139
  throw new Error(`Session MCP server(s) unavailable: ${unavailable.join(', ')}`);
140
140
  }
141
141
  }
142
+ get ownsServers() {
143
+ return this.#enabledServerIds.length > 0;
144
+ }
142
145
  close() {
143
146
  this.#closeTask ??= this.#close(true);
144
147
  return this.#closeTask;
@@ -1005,5 +1005,7 @@ function runChannelOperation(operation, signal, discard) {
1005
1005
  function sameGoalProjection(a, b) {
1006
1006
  if (a === null || b === null)
1007
1007
  return a === b;
1008
- return a.goalId === b.goalId && a.revision === b.revision;
1008
+ return (a.goalId === b.goalId &&
1009
+ a.revision === b.revision &&
1010
+ JSON.stringify(a.eventWait) === JSON.stringify(b.eventWait));
1009
1011
  }
@@ -996,6 +996,11 @@ class RuntimeHostMakaSessionDriverImpl {
996
996
  this.#todoChangeListeners.add(listener);
997
997
  return () => this.#todoChangeListeners.delete(listener);
998
998
  }
999
+ async cancelGoalEventWait(input) {
1000
+ if (input.sessionId !== this.#sessionId)
1001
+ throw new Error('Wait belongs to another Session');
1002
+ return this.#request('goal.event-wait.cancel', input);
1003
+ }
999
1004
  async controlGoal(action) {
1000
1005
  const sessionId = this.#sessionId;
1001
1006
  if (!sessionId)