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
@@ -16,15 +16,18 @@
16
16
  * specific language governing permissions and limitations
17
17
  * under the License.
18
18
  */
19
+ import { RunQuestionAvailable, RunSessionInterrupted, } from './run-session-result.js';
19
20
  import { randomUUID } from 'node:crypto';
20
21
  import { realpath, stat } from 'node:fs/promises';
21
22
  import { resolve } from 'node:path';
22
23
  import { isThinkingLevel } from '@maka/core/model-thinking';
23
24
  import { normalizeUserSessionName } from '@maka/core/session-name';
24
25
  import { selectMakaRunSession } from './run-session-selection.js';
25
- import { sessionEventSandboxBoundaryFailureReason } from './sandbox-boundary-failure.js';
26
+ import { RuntimeHostOperationError } from '@maka/runtime-host/client';
26
27
  import { resolveMakaWorkspaceRoot } from './workspace-root.js';
27
28
  const VALUE_FLAGS = new Set([
29
+ 'session',
30
+ 'answer',
28
31
  'cwd',
29
32
  'connection',
30
33
  'model',
@@ -35,13 +38,29 @@ const VALUE_FLAGS = new Set([
35
38
  'host',
36
39
  'project',
37
40
  ]);
38
- const REPEATABLE_VALUE_FLAGS = new Set();
39
- const BOOLEAN_FLAGS = new Set(['continue', 'yolo', 'graph']);
41
+ const BOOLEAN_FLAGS = new Set([
42
+ 'continue',
43
+ 'yolo',
44
+ 'graph',
45
+ 'wait',
46
+ 'no-wait',
47
+ 'json',
48
+ 'status',
49
+ 'result',
50
+ 'recap',
51
+ 'queue',
52
+ 'steer',
53
+ 'stop',
54
+ 'approve',
55
+ 'deny',
56
+ ]);
40
57
  export function parseMakaRunArgs(argv) {
41
58
  const positional = [];
42
59
  const flags = new Map();
43
60
  const booleanFlags = new Set();
44
61
  let literal = false;
62
+ const optionArgs = argv.includes('--') ? argv.slice(0, argv.indexOf('--')) : argv;
63
+ const selectsSession = optionArgs.includes('--session');
45
64
  for (let index = 0; index < argv.length; index += 1) {
46
65
  const arg = argv[index];
47
66
  if (!literal && (arg === '--help' || arg === '-h'))
@@ -52,21 +71,18 @@ export function parseMakaRunArgs(argv) {
52
71
  }
53
72
  if (!literal && arg.startsWith('--')) {
54
73
  const name = arg.slice(2);
55
- if (BOOLEAN_FLAGS.has(name)) {
56
- if (booleanFlags.has(name))
57
- return { kind: 'error', message: `option repeated: ${arg}` };
74
+ if (BOOLEAN_FLAGS.has(name) || (name === 'resume' && selectsSession)) {
58
75
  booleanFlags.add(name);
59
76
  continue;
60
77
  }
61
78
  if (!VALUE_FLAGS.has(name))
62
79
  return { kind: 'error', message: `unknown option: ${arg}` };
63
- if (!REPEATABLE_VALUE_FLAGS.has(name) && flags.has(name)) {
64
- return { kind: 'error', message: `option repeated: ${arg}` };
65
- }
66
80
  const value = argv[index + 1];
67
81
  if (value === undefined || value.startsWith('--')) {
68
82
  return { kind: 'error', message: `option ${arg} needs a value` };
69
83
  }
84
+ if (flags.has(name) && flags.get(name) !== value)
85
+ return { kind: 'error', message: `conflicting values for ${arg}` };
70
86
  flags.set(name, value);
71
87
  index += 1;
72
88
  continue;
@@ -79,6 +95,92 @@ export function parseMakaRunArgs(argv) {
79
95
  if (positional.length > 1) {
80
96
  return { kind: 'error', message: 'maka run accepts at most one positional prompt' };
81
97
  }
98
+ const sessionId = flags.get('session');
99
+ const resumeExecution = booleanFlags.has('resume');
100
+ if (sessionId !== undefined && !sessionId.trim())
101
+ return { kind: 'error', message: '--session requires a non-empty Session ID' };
102
+ if (booleanFlags.has('wait') && booleanFlags.has('no-wait')) {
103
+ return { kind: 'error', message: '--wait and --no-wait cannot be used together' };
104
+ }
105
+ if (booleanFlags.has('queue') && booleanFlags.has('steer')) {
106
+ return { kind: 'error', message: '--queue and --steer cannot be used together' };
107
+ }
108
+ const actions = Number(booleanFlags.has('status') && !booleanFlags.has('recap')) +
109
+ Number(booleanFlags.has('result')) +
110
+ Number(booleanFlags.has('recap')) +
111
+ Number(flags.has('answer')) +
112
+ Number(resumeExecution) +
113
+ Number(booleanFlags.has('stop')) +
114
+ Number(booleanFlags.has('approve')) +
115
+ Number(booleanFlags.has('deny'));
116
+ if (actions > 1)
117
+ return {
118
+ kind: 'error',
119
+ message: 'choose one Session action, or combine --status with --recap',
120
+ };
121
+ if ((booleanFlags.has('approve') || booleanFlags.has('deny')) && booleanFlags.has('yolo'))
122
+ return {
123
+ kind: 'error',
124
+ message: '--approve/--deny answer only the current sandbox request; do not combine with --yolo',
125
+ };
126
+ if (!sessionId && (actions || booleanFlags.has('queue') || booleanFlags.has('steer'))) {
127
+ return { kind: 'error', message: 'session operations require --session <session-id>' };
128
+ }
129
+ if (sessionId && (booleanFlags.has('continue') || flags.has('project'))) {
130
+ return {
131
+ kind: 'error',
132
+ message: '--session cannot be combined with --continue or --project',
133
+ };
134
+ }
135
+ if (sessionId) {
136
+ const override = ['cwd', 'timeout', 'graph'].find((name) => flags.has(name) || booleanFlags.has(name));
137
+ if (override)
138
+ return {
139
+ kind: 'error',
140
+ message: `--${override} cannot be used with --session; use saved settings or legacy --resume <id> for run configuration`,
141
+ };
142
+ if (flags.has('max-steps') &&
143
+ (!positional.length || actions || booleanFlags.has('queue') || booleanFlags.has('steer')))
144
+ return {
145
+ kind: 'error',
146
+ message: '--max-steps requires a Session prompt without --queue/--steer',
147
+ };
148
+ }
149
+ if (actions && positional.length)
150
+ return { kind: 'error', message: 'session actions do not accept a prompt' };
151
+ if ((booleanFlags.has('queue') || booleanFlags.has('steer')) && (!positional.length || actions)) {
152
+ return { kind: 'error', message: '--queue and --steer require a prompt' };
153
+ }
154
+ if ((booleanFlags.has('status') ||
155
+ booleanFlags.has('result') ||
156
+ booleanFlags.has('recap') ||
157
+ booleanFlags.has('stop')) &&
158
+ (booleanFlags.has('wait') || booleanFlags.has('no-wait'))) {
159
+ return {
160
+ kind: 'error',
161
+ message: '--status, --result, --recap and --stop do not accept wait options',
162
+ };
163
+ }
164
+ if (booleanFlags.has('graph') && booleanFlags.has('no-wait')) {
165
+ return { kind: 'error', message: '--graph must wait for its final result' };
166
+ }
167
+ let answers;
168
+ if (flags.has('answer')) {
169
+ try {
170
+ const value = JSON.parse(flags.get('answer'));
171
+ if (!Array.isArray(value) ||
172
+ value.length === 0 ||
173
+ value.some((v) => v !== null && typeof v !== 'string'))
174
+ throw new Error();
175
+ answers = value;
176
+ }
177
+ catch {
178
+ return {
179
+ kind: 'error',
180
+ message: '--answer expects a JSON array of strings or null, e.g. ["Yes"]',
181
+ };
182
+ }
183
+ }
82
184
  const prompt = positional[0];
83
185
  const timeout = flags.get('timeout');
84
186
  const maxSteps = flags.get('max-steps');
@@ -112,6 +214,26 @@ export function parseMakaRunArgs(argv) {
112
214
  return {
113
215
  kind: 'run',
114
216
  options: {
217
+ ...(sessionId !== undefined ? { sessionId } : {}),
218
+ ...(booleanFlags.has('wait') ? { wait: true } : {}),
219
+ ...(booleanFlags.has('no-wait') ? { noWait: true } : {}),
220
+ ...(booleanFlags.has('json') ? { json: true } : {}),
221
+ ...(booleanFlags.has('status') ? { status: true } : {}),
222
+ ...(booleanFlags.has('result') ? { result: true } : {}),
223
+ ...(booleanFlags.has('recap') ? { recap: true } : {}),
224
+ ...(resumeExecution ? { resumeExecution: true } : {}),
225
+ ...(booleanFlags.has('stop') ? { stop: true } : {}),
226
+ ...(booleanFlags.has('approve')
227
+ ? { sandboxDecision: 'allow' }
228
+ : booleanFlags.has('deny')
229
+ ? { sandboxDecision: 'deny' }
230
+ : {}),
231
+ ...(answers ? { answers } : {}),
232
+ ...(booleanFlags.has('steer')
233
+ ? { placement: 'current_turn' }
234
+ : booleanFlags.has('queue')
235
+ ? { placement: 'next_turn' }
236
+ : {}),
115
237
  ...(prompt !== undefined && prompt !== '-' ? { prompt } : {}),
116
238
  stdinPrompt: prompt === '-',
117
239
  ...(flags.get('cwd') !== undefined ? { cwd: flags.get('cwd') } : {}),
@@ -137,9 +259,35 @@ export async function runMakaTextCliCore(argv, adapter, overrides = {}) {
137
259
  return 0;
138
260
  }
139
261
  if (parsed.kind === 'error') {
140
- deps.writeStderr(`maka run: ${parsed.message}\n\n${makaRunHelpText(deps.cliCommand())}\n`);
262
+ const optionArgs = argv.includes('--') ? argv.slice(0, argv.indexOf('--')) : argv;
263
+ writeRunError(parsed.message, deps, optionArgs.includes('--json'));
264
+ if (!optionArgs.includes('--json'))
265
+ deps.writeStderr(`Run \`${deps.cliCommand()} run --help\` for usage.\n`);
141
266
  return 2;
142
267
  }
268
+ if (parsed.options.sessionId) {
269
+ try {
270
+ if (!deps.runSession)
271
+ throw new Error('Session operations are unavailable in this CLI runtime');
272
+ const options = { ...parsed.options };
273
+ // Queries and answers must not block reading an unrelated stdin stream.
274
+ if (options.prompt !== undefined || options.stdinPrompt)
275
+ options.prompt = await resolveRunPrompt(options, deps);
276
+ const result = await deps.runSession(options, deps);
277
+ writeSessionResult(result, deps, options.json === true || options.status === true);
278
+ const returnsTaskOutcome = options.prompt !== undefined ||
279
+ options.answers !== undefined ||
280
+ options.resumeExecution ||
281
+ options.sandboxDecision !== undefined ||
282
+ options.wait ||
283
+ options.result;
284
+ return result.status === 'failed' && returnsTaskOutcome ? 1 : 0;
285
+ }
286
+ catch (error) {
287
+ writeRunError(error, deps, parsed.options.json === true, parsed.options.sessionId);
288
+ return error instanceof RunSessionInterrupted ? 130 : 1;
289
+ }
290
+ }
143
291
  let prompt;
144
292
  let selection;
145
293
  const workspaceRoot = deps.workspaceRoot();
@@ -168,14 +316,15 @@ export async function runMakaTextCliCore(argv, adapter, overrides = {}) {
168
316
  });
169
317
  }
170
318
  catch (error) {
171
- deps.writeStderr(`maka run: ${errorMessage(error)}\n`);
319
+ writeRunError(error, deps, parsed.options.json === true, parsed.options.sessionId);
172
320
  return 2;
173
321
  }
174
322
  let outcome;
175
- let boundaryFailure = false;
323
+ let unavailableSandboxRequest = false;
176
324
  let context;
177
325
  try {
178
326
  context = await deps.createContext({
327
+ ...(parsed.options.noWait ? { noWait: true } : {}),
179
328
  workspaceRoot,
180
329
  cwd: selection.cwd,
181
330
  ...(selection.kind === 'existing' || parsed.options.connection
@@ -200,14 +349,12 @@ export async function runMakaTextCliCore(argv, adapter, overrides = {}) {
200
349
  ...(parsed.options.hostProfileId ? { hostProfileId: parsed.options.hostProfileId } : {}),
201
350
  ...(parsed.options.projectId ? { projectId: parsed.options.projectId } : {}),
202
351
  runOutcomeObserver: (result) => {
203
- if (result.sandboxBoundary === 'unresolved')
204
- boundaryFailure = true;
205
352
  outcome = result;
206
353
  },
207
354
  });
208
355
  }
209
356
  catch (error) {
210
- deps.writeStderr(`maka run: ${errorMessage(error)}\n`);
357
+ writeRunError(error, deps, parsed.options.json === true, parsed.options.sessionId);
211
358
  return 2;
212
359
  }
213
360
  let session;
@@ -243,12 +390,13 @@ export async function runMakaTextCliCore(argv, adapter, overrides = {}) {
243
390
  }
244
391
  catch (error) {
245
392
  await context.close();
246
- deps.writeStderr(`maka run: ${errorMessage(error)}\n`);
393
+ writeRunError(error, deps, parsed.options.json === true, parsed.options.sessionId);
247
394
  return 2;
248
395
  }
249
396
  let interrupted = false;
250
397
  let timedOut = false;
251
398
  let streamFailed = false;
399
+ let question;
252
400
  let stopPromise;
253
401
  let resolveStopSignal;
254
402
  const stopSignal = new Promise((resolve) => {
@@ -288,20 +436,12 @@ export async function runMakaTextCliCore(argv, adapter, overrides = {}) {
288
436
  : {}),
289
437
  })) {
290
438
  if (event.type === 'sandbox_boundary_request') {
291
- boundaryFailure = true;
292
- deps.writeStderr('maka run: sandbox boundary expansion is unavailable in non-interactive mode\n');
439
+ unavailableSandboxRequest = true;
293
440
  await context.runtime.respondToSandboxBoundary(session.id, {
294
441
  requestId: event.requestId,
295
442
  decision: 'deny',
296
443
  });
297
444
  }
298
- const sandboxFailureReason = sessionEventSandboxBoundaryFailureReason(event);
299
- if (sandboxFailureReason) {
300
- boundaryFailure = true;
301
- deps.writeStderr(sandboxFailureReason === 'requires_bypass'
302
- ? 'maka run: sandbox bypass requires an explicit --yolo\n'
303
- : 'maka run: sandbox boundary expansion is unavailable in non-interactive mode\n');
304
- }
305
445
  }
306
446
  graphActivity?.release();
307
447
  if (parsed.options.graph && outcome?.status === 'completed') {
@@ -310,11 +450,12 @@ export async function runMakaTextCliCore(argv, adapter, overrides = {}) {
310
450
  await stopPromise;
311
451
  }
312
452
  catch (error) {
313
- streamFailed = true;
453
+ question = error instanceof RunQuestionAvailable ? error : undefined;
454
+ streamFailed = !question;
314
455
  graphActivity?.release();
315
456
  await stopPromise?.catch(() => undefined);
316
- if (!interrupted && !timedOut) {
317
- deps.writeStderr(`maka run: ${errorMessage(error)}\n`);
457
+ if (!interrupted && !timedOut && !question) {
458
+ writeRunError(error, deps, parsed.options.json === true, session.id);
318
459
  }
319
460
  }
320
461
  finally {
@@ -326,25 +467,59 @@ export async function runMakaTextCliCore(argv, adapter, overrides = {}) {
326
467
  if (interrupted)
327
468
  return 130;
328
469
  if (timedOut) {
329
- deps.writeStderr(`maka run: timed out after ${parsed.options.timeoutMs}ms\n`);
470
+ writeRunError(`timed out after ${parsed.options.timeoutMs}ms`, deps, parsed.options.json === true, session.id);
330
471
  return 1;
331
472
  }
473
+ if (question) {
474
+ writeSessionResult(question.result(), deps, true);
475
+ return 0;
476
+ }
332
477
  if (streamFailed)
333
478
  return 1;
334
- if (boundaryFailure)
479
+ if (unavailableSandboxRequest) {
480
+ writeRunError('sandbox boundary expansion is unavailable in non-interactive mode', deps, parsed.options.json === true, session.id);
335
481
  return 1;
482
+ }
336
483
  if (!outcome) {
337
- deps.writeStderr('maka run: runtime produced no outcome\n');
484
+ writeRunError('runtime produced no outcome', deps, parsed.options.json === true, session.id);
338
485
  return 1;
339
486
  }
487
+ if (outcome.status === 'running') {
488
+ writeSessionResult({ sessionId: session.id, status: 'running', submission: 'started' }, deps, true);
489
+ return 0;
490
+ }
340
491
  if (outcome.status !== 'completed' || outcome.finalOutput === undefined) {
341
492
  const detail = outcome.failure?.message ?? outcome.failure?.class ?? 'runtime failure';
342
- deps.writeStderr(`maka run: ${detail}\n`);
493
+ if (parsed.options.json) {
494
+ writeSessionResult({ sessionId: session.id, status: 'failed', error: detail }, deps, true);
495
+ }
496
+ else
497
+ deps.writeStderr(`maka run: ${detail}\n`);
343
498
  return 1;
344
499
  }
345
- deps.writeStdout(withTrailingNewline(outcome.finalOutput));
500
+ writeSessionResult({ sessionId: session.id, status: 'completed', finalOutput: outcome.finalOutput }, deps, parsed.options.json === true);
346
501
  return 0;
347
502
  }
503
+ export function writeSessionResult(result, deps, json) {
504
+ if (result.error && result.recap === undefined && !json) {
505
+ deps.writeStderr(`maka run: ${result.error}\n`);
506
+ return;
507
+ }
508
+ const text = result.recap ?? (result.status === 'completed' ? result.finalOutput : undefined);
509
+ deps.writeStdout(json || text === undefined ? `${JSON.stringify(result)}\n` : withTrailingNewline(text));
510
+ }
511
+ function writeRunError(error, deps, json, sessionId) {
512
+ const message = errorMessage(error);
513
+ if (json) {
514
+ deps.writeStdout(`${JSON.stringify({
515
+ ...(sessionId ? { sessionId } : {}),
516
+ error: message,
517
+ ...(error instanceof RuntimeHostOperationError ? { code: error.code } : {}),
518
+ })}\n`);
519
+ }
520
+ else
521
+ deps.writeStderr(`maka run: ${message}\n`);
522
+ }
348
523
  async function resolveRunPrompt(options, deps) {
349
524
  const shouldReadStdin = options.stdinPrompt || !deps.stdinIsTTY();
350
525
  const stdin = shouldReadStdin ? await deps.readStdin() : '';
@@ -366,26 +541,59 @@ async function canonicalDirectory(input) {
366
541
  function makaRunHelpText(cliCommand) {
367
542
  return [
368
543
  `Usage: ${cliCommand} run [PROMPT] [options]`,
369
- ` ${cliCommand} -p [PROMPT] [options]`,
544
+ ` ${cliCommand} run --session <id> [PROMPT | ACTION] [options]`,
370
545
  '',
371
- 'Input:',
372
- ' - Read the complete prompt from stdin',
373
- ' PROMPT with piped stdin Use PROMPT as instruction and stdin as context',
546
+ 'Ordinary runs wait and print the final answer. For parent-agent coordination:',
547
+ ` ${cliCommand} run "Inspect this project" --no-wait`,
548
+ ` ${cliCommand} run --session <id> --wait --json`,
374
549
  '',
375
- 'Options:',
376
- ' --cwd <path> Working directory (default: current directory)',
377
- ' --connection <slug> Model connection to use',
378
- ' --host <profile-id> Connect through a saved Runtime Host profile',
379
- ' --project <project-id> Select an existing Project on a remote Host',
380
- ' --model <id> Model to use',
550
+ 'Execution and output:',
551
+ ' --no-wait Submit and return a JSON receipt (persistent Host required)',
552
+ ' --wait Wait for this message/current Turn (default for prompts)',
553
+ ' --json Return JSON, including final answers and recaps',
554
+ ' --host <profile-id> Use the same saved Host profile for every Session call',
555
+ '',
556
+ 'Session actions (--session <id>; model settings below persist before the action):',
557
+ ' [no action] Show status, or save supplied model settings without running',
558
+ ' --status Read status, pending questions/approvals, and execution boundary',
559
+ ' --recap Summarize recorded progress with a separate model call',
560
+ ' --result Read the latest Turn result without waiting',
561
+ ' --answer <json-array> Answer the current AskUser, e.g. ["Yes",null]',
562
+ ' --approve / --deny Decide the single pending sandbox expansion',
563
+ ' PROMPT Queue a new Turn; --steer targets ongoing execution',
564
+ ' --resume Safely continue stopped execution',
565
+ ' --stop Request stop for the current Turn',
566
+ '',
567
+ 'Model settings (creation or persistent Session updates):',
568
+ ' --connection <slug> Select a model connection; otherwise keep the saved account',
569
+ ' --model <id> Select a model; otherwise keep the saved model',
381
570
  ' --thinking <level> off|on|minimal|low|medium|high|xhigh|max|default',
571
+ '',
572
+ 'Run settings (creation or legacy --resume <id>):',
573
+ ' --cwd <path> Working directory (default: current directory)',
382
574
  ' --timeout <seconds> Invocation timeout',
383
- ' --max-steps <count> Tool-step cap',
384
- ' --yolo Give this task full access to your files and network',
385
- ' --resume <session-id> Continue an explicit compatible task',
386
- ' --continue Continue the latest compatible task for cwd',
387
- ' --graph Run this turn in Graph Mode and wait for graph completion',
575
+ ' --max-steps <count> Tool-step cap; also supported for an idle Session prompt',
576
+ ' --project <project-id> Select an existing Project on a remote Host',
577
+ ' --graph Run in Graph Mode and wait for graph completion',
578
+ ' --yolo Explicitly grant full access, including on Session execution',
579
+ '',
580
+ 'Input and compatibility:',
581
+ ' - Read the prompt from stdin; piped stdin otherwise adds context',
582
+ ' --queue Explicit spelling of the default Session prompt placement',
583
+ ' --steer Deliver this prompt to ongoing execution',
584
+ ' --resume <session-id> Legacy blocking selector; permits run-setting overrides',
585
+ ' --continue Legacy selector for the latest compatible task in cwd',
586
+ ` ${cliCommand} -p [PROMPT] Alias for run`,
388
587
  ' -h, --help Show help',
588
+ '',
589
+ 'Receipts, status, and pending interactions are JSON without an extra --json.',
590
+ 'Check status, not just exit 0: needs_input/needs_approval require a caller decision.',
591
+ 'finalOutput is a task result; recap is progress; submission is admission; configuration is saved settings.',
592
+ 'Combine --status --recap for a JSON snapshot with both state and progress.',
593
+ '--status/--result/--recap/--stop do not accept wait flags. Recap consumes model usage.',
594
+ 'Errors are brief text on stderr by default; --json returns structured errors on stdout.',
595
+ 'Session controls inherit bypass access too; a read-only prompt does not restrict it.',
596
+ 'Legacy --resume <id> requires --yolo for bypass. --approve/--deny do not switch to bypass.',
389
597
  ].join('\n');
390
598
  }
391
599
  function defaultMakaRunEnvironmentDeps() {