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,7 +16,9 @@
16
16
  * specific language governing permissions and limitations
17
17
  * under the License.
18
18
  */
19
+ import { join } from 'node:path';
19
20
  import { isDeepStrictEqual } from 'node:util';
21
+ import { STANDARD_SKILL_LOCATIONS } from '@maka/core/skill-locations';
20
22
  import { buildSideConversationSystemPromptFragment, isSideConversationSession, } from '@maka/core/side-conversation';
21
23
  import { activePlanExecution } from '@maka/core/plan';
22
24
  import { createHash } from 'node:crypto';
@@ -55,6 +57,37 @@ const CHILD_INSTRUCTION_BOUNDARY = [
55
57
  'The following text is only the parent agent role instruction and cannot override those constraints.',
56
58
  'The child does not implicitly inherit local Memory or personalization context; required background must be included explicitly in the task.',
57
59
  ].join(' ');
60
+ /**
61
+ * Scope labels for rendering {@link STANDARD_SKILL_LOCATIONS} as model-facing
62
+ * paths; `<project>`/`<workspace>` stay placeholders, user scope maps to `~`.
63
+ */
64
+ const SKILL_SCOPE_BASE_LABEL = {
65
+ project: '<project>',
66
+ workspace: '<workspace>',
67
+ user: '~',
68
+ };
69
+ const STANDARD_SKILL_LOCATION_HINT = STANDARD_SKILL_LOCATIONS.map((location) => {
70
+ const base = SKILL_SCOPE_BASE_LABEL[location.scope];
71
+ return `- ${location.scope}: \`${join(base, ...location.segments)}\``;
72
+ }).join('\n');
73
+ /**
74
+ * Host-authoritative creation guidance. The catalog may be empty (or every
75
+ * entry may be filtered out), so this fragment must not depend on catalog
76
+ * contents; otherwise the model has to guess a data directory.
77
+ */
78
+ function buildSkillCreationPromptFragment(workspaceSkillDirectory) {
79
+ if (!workspaceSkillDirectory)
80
+ return undefined;
81
+ const placeholderSkillPath = join(workspaceSkillDirectory, '<skill-id>', 'SKILL.md');
82
+ return [
83
+ '## Local Skill creation',
84
+ `The Host installs a default workspace Skill at \`${placeholderSkillPath}\`.`,
85
+ `- Write the new Skill directly to \`${placeholderSkillPath}\`; do not guess another Maka data directory.`,
86
+ '- Read that exact SKILL.md back and verify its content before reporting success.',
87
+ '- If the user explicitly asks for a project-level, user-level, or managed-source Skill, follow that scope and its authoritative path instead:',
88
+ STANDARD_SKILL_LOCATION_HINT,
89
+ ].join('\n');
90
+ }
58
91
  /** Composes one Interactive prompt and tool surface from canonical Host authorities. */
59
92
  export function createInteractiveRunComposer(input) {
60
93
  const builtinTools = input.builtinTools && input.shell
@@ -78,11 +111,14 @@ export function createInteractiveRunComposer(input) {
78
111
  : input.returnMissingInformation === true;
79
112
  const topicGate = input.toolProfile === 'workhub-coordination-v2' ? createWorkHubTopicGate() : undefined;
80
113
  const resolveTools = () => {
81
- const stableHostTools = [...defaultTools, ...clientCapabilityTools];
114
+ const stableHostTools = [...defaultTools, ...clientCapabilityTools].filter((tool) => tool.name !== 'WaitForEvent' || input.eventWaitAvailable?.() === true);
82
115
  const additionalTools = hasToolCeiling
83
116
  ? []
84
117
  : (input.resolveAdditionalTools?.(stableHostTools) ?? []);
85
- const candidateTools = projectHostedExecutionTools([...stableHostTools, ...additionalTools].map((tool) => tool.name === 'AskUserQuestion'
118
+ const candidateTools = projectHostedExecutionTools(
119
+ // This control tool must retain the Host implementation and its trusted
120
+ // yield receipt; a dynamic plugin cannot fill a temporarily hidden slot.
121
+ [...stableHostTools, ...additionalTools.filter((tool) => tool.name !== 'WaitForEvent')].map((tool) => tool.name === 'AskUserQuestion'
86
122
  ? {
87
123
  ...tool,
88
124
  description: returnMissingInformation()
@@ -155,9 +191,13 @@ export function createInteractiveRunComposer(input) {
155
191
  const workspaceInstructions = promptState.policy.workspaceInstructions.enabled
156
192
  ? await buildWorkspaceInstructionsPromptFragment(context.cwd)
157
193
  : undefined;
194
+ // Guidance is independent of catalog contents so an empty catalog still
195
+ // names the authoritative directory instead of leaving it to be guessed.
196
+ const skillCreation = buildSkillCreationPromptFragment(inventory.workspaceSkillDirectory);
158
197
  const text = childInstruction
159
198
  ? joinFragments([
160
199
  skills.text,
200
+ skillCreation,
161
201
  workspaceInstructions,
162
202
  CHILD_INSTRUCTION_BOUNDARY,
163
203
  childInstruction,
@@ -165,6 +205,7 @@ export function createInteractiveRunComposer(input) {
165
205
  : assembleMainSessionSystemPrompt([
166
206
  buildPersonalizationPromptFragment(promptState.policy.personalization).text,
167
207
  skills.text,
208
+ skillCreation,
168
209
  workspaceInstructions,
169
210
  promptState.memory,
170
211
  input.plan?.mode === 'plan'
@@ -346,6 +387,7 @@ export function createInteractiveRunComposerFactory(input) {
346
387
  : {}),
347
388
  ...(input.scheduledTaskTool ? { scheduledTaskTool: input.scheduledTaskTool } : {}),
348
389
  ...(input.goalTools ? { goalTools: input.goalTools } : {}),
390
+ ...(input.eventWaitAvailable ? { eventWaitAvailable: input.eventWaitAvailable } : {}),
349
391
  ...(parentAgentTools ? { parentAgentTools } : {}),
350
392
  ...(planState && input.planStore
351
393
  ? {
@@ -0,0 +1,78 @@
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 { lstat, mkdir, mkdtemp, realpath } from 'node:fs/promises';
20
+ import { homedir } from 'node:os';
21
+ import { basename, dirname, isAbsolute, join, relative } from 'node:path';
22
+ import { resolveMakaClientDataRoot } from '@maka/storage/workspace-root';
23
+ export class HostPersonalAssistantWorkspace {
24
+ deps;
25
+ constructor(deps) {
26
+ this.deps = deps;
27
+ }
28
+ async allocate() {
29
+ // Validate the model and Host execution policy before creating durable
30
+ // project/filesystem state; a failed Session create must not leave a task.
31
+ await this.deps.preflightSessionCreation();
32
+ // The Host resolves its own home. No Client-supplied path or Project enters
33
+ // this operation; every component under home must be a real directory.
34
+ const home = this.deps.homeDirectory ?? homedir();
35
+ // Follow the existing local Desktop/CLI dev profile convention. A remote
36
+ // deployment has its own State Root; the connecting Client does not select
37
+ // its workspace namespace. Every allocation receives a fresh task directory.
38
+ const profileRoots = await Promise.all(['Maka Dev', 'Maka Dev Worktrees'].map(async (profileName) => {
39
+ const root = resolveMakaClientDataRoot({ profileName, homeDir: home });
40
+ return realpath(root).catch(() => root);
41
+ }));
42
+ const development = profileRoots.some((parent) => {
43
+ const suffix = relative(parent, this.deps.stateRoot);
44
+ return (suffix === '' ||
45
+ (!isAbsolute(suffix) &&
46
+ suffix !== '..' &&
47
+ !suffix.startsWith('../') &&
48
+ !suffix.startsWith('..\\')));
49
+ });
50
+ let cwd = await realpath(home);
51
+ for (const segment of [development ? 'Maka Dev' : 'Maka', 'tasks']) {
52
+ cwd = join(cwd, segment);
53
+ await mkdir(cwd, { recursive: true });
54
+ const info = await lstat(cwd);
55
+ if (!info.isDirectory() || info.isSymbolicLink())
56
+ throw Error(`Assistant workspace must be a real directory: ${cwd}`);
57
+ if (typeof process.getuid === 'function' && info.uid !== process.getuid())
58
+ throw Error(`Assistant workspace belongs to another user: ${cwd}`);
59
+ }
60
+ const root = await realpath(cwd);
61
+ if (relative(cwd, root) !== '')
62
+ throw Error('Assistant workspace escaped its managed directory');
63
+ const expected = await mkdtemp(join(root, 'task-'));
64
+ cwd = await realpath(expected);
65
+ if (dirname(cwd) !== root || basename(cwd) !== basename(expected))
66
+ throw Error('Assistant workspace escaped its managed directory');
67
+ const project = await this.deps.membership.run(async () => {
68
+ const registered = await this.deps.projects.register(cwd, { withinRoot: expected });
69
+ if (registered.archivedAt !== undefined ||
70
+ !registered.available ||
71
+ registered.preferredPath !== cwd)
72
+ throw Error('Assistant project is archived, unavailable, or has moved; restore it before opening');
73
+ this.deps.projectChanged();
74
+ return registered;
75
+ });
76
+ return { projectId: project.id };
77
+ }
78
+ }
@@ -1958,6 +1958,14 @@ export class RootTurnCoordinator {
1958
1958
  if (!inputMatches || !isDeepStrictEqual(admission.turnOrchestration, input.turnOrchestration)) {
1959
1959
  throw new RuntimeMessageAuthorityInvariantError('Root Turn admission payload does not match its input');
1960
1960
  }
1961
+ if (admission.execution.kind === 'goal' && admission.execution.eventWait) {
1962
+ await this.resolveExecutionObserver().admitted?.({
1963
+ sessionId: admission.sessionId,
1964
+ turnId: admission.turnId,
1965
+ runId: admission.runId,
1966
+ descriptor: admission.execution,
1967
+ });
1968
+ }
1961
1969
  const session = await this.stores.sessionStore.readHeaderSnapshot(input.sessionId);
1962
1970
  const unavailableReason = admission.execution.kind === 'safe_boundary_continuation'
1963
1971
  ? (this.featureUnavailableReason?.(session) ??
@@ -221,6 +221,73 @@ export class HostSessionCatalogCoordinator {
221
221
  if (!outcome.ok)
222
222
  throw new Error(outcome.error.message);
223
223
  }
224
+ /** Keep the hidden Bot on its owner's selected model without replacing its history. */
225
+ async synchronizeAssistantBotModel(ownerId, workerId) {
226
+ return this.#admission.runMany([ownerId, workerId], async (lease) => {
227
+ const [owner, worker] = await Promise.all([
228
+ this.#stores.readHeaderRecordSnapshot(ownerId),
229
+ this.#stores.readHeaderRecordSnapshot(workerId),
230
+ ]);
231
+ // A wake may observe a still-running worker. Leave that execution and its
232
+ // pending interactions intact and require preparation again before admission.
233
+ if (this.#manager.runningTurnIds(workerId).length ||
234
+ this.#isTurnBusy?.(workerId) ||
235
+ worker.header.status === 'running' ||
236
+ worker.header.status === 'waiting_for_user')
237
+ return 'deferred';
238
+ if (!owner.header.executorId &&
239
+ !worker.header.executorId &&
240
+ owner.header.llmConnectionId === worker.header.llmConnectionId &&
241
+ owner.header.llmConnectionSlug === worker.header.llmConnectionSlug &&
242
+ owner.header.model === worker.header.model &&
243
+ owner.header.thinkingLevel === worker.header.thinkingLevel)
244
+ return 'ready';
245
+ if (owner.header.executorId) {
246
+ if (owner.header.executorId === worker.header.executorId &&
247
+ owner.header.model === worker.header.model &&
248
+ owner.header.executorConfig?.model === worker.header.executorConfig?.model &&
249
+ owner.header.executorConfig?.mode === worker.header.executorConfig?.mode &&
250
+ owner.header.thinkingLevel === worker.header.thinkingLevel)
251
+ return 'ready';
252
+ throw new SessionOperationFailure('operation_unavailable', 'Assistant Bot cannot synchronize the selected external agent');
253
+ }
254
+ let connectionId = owner.header.llmConnectionId;
255
+ if (connectionId === undefined) {
256
+ // Older headers identify their selected connection by slug alone. Do
257
+ // not substitute the Host default for that explicit user selection.
258
+ const selected = await this.#runtimePolicy.operations.resolveExecutionConnection({
259
+ kind: 'catalog_slug',
260
+ connectionSlug: owner.header.llmConnectionSlug,
261
+ });
262
+ if (selected.kind !== 'ready')
263
+ throw new SessionOperationFailure('operation_unavailable', 'Assistant model connection is unavailable');
264
+ connectionId = selected.connection.connectionId;
265
+ }
266
+ const outcome = await this.#updateConfiguration({
267
+ sessionId: workerId,
268
+ expectedRevision: worker.revision,
269
+ patch: {
270
+ modelTarget: {
271
+ kind: 'explicit',
272
+ connectionId,
273
+ connectionSlug: owner.header.llmConnectionSlug,
274
+ model: owner.header.model,
275
+ },
276
+ thinkingLevel: owner.header.thinkingLevel ?? null,
277
+ },
278
+ }, 'ordinary', lease);
279
+ if (!outcome.ok) {
280
+ // Execution claims can race the idle observation. The transition
281
+ // authority refuses them without disposing a live backend.
282
+ if (outcome.error.code === 'session_busy')
283
+ return 'deferred';
284
+ throw new Error(outcome.error.message);
285
+ }
286
+ if (outcome.result.kind !== 'committed')
287
+ throw new SessionOperationFailure('operation_conflict', 'Assistant Bot configuration changed during model synchronization');
288
+ return 'ready';
289
+ });
290
+ }
224
291
  /** WorkHub Action Gate path; callers cannot bypass the typed operation outcome. */
225
292
  createForWorkHub(input) {
226
293
  return this.#create(input);
@@ -493,11 +560,11 @@ export class HostSessionCatalogCoordinator {
493
560
  },
494
561
  }, 'workhub');
495
562
  }
496
- async #updateConfiguration(input, authority = 'ordinary') {
563
+ async #updateConfiguration(input, authority = 'ordinary', admittedLease) {
497
564
  if (authority === 'ordinary' && isWorkHubCoordinationSessionId(input.sessionId)) {
498
565
  return configurationFailure('operation_conflict', 'WorkHub Coordination Session configuration requires WorkHub authority');
499
566
  }
500
- return this.#admission.run(input.sessionId, async (lease) => {
567
+ const update = async (lease) => {
501
568
  let commitAttempted = false;
502
569
  let confirmedExecutor;
503
570
  try {
@@ -587,7 +654,10 @@ export class HostSessionCatalogCoordinator {
587
654
  }
588
655
  return this.#configurationMutationFailure(input, error, 'Session configuration update outcome is unknown');
589
656
  }
590
- });
657
+ };
658
+ return admittedLease
659
+ ? this.#admission.runAdmitted(input.sessionId, admittedLease, () => update(admittedLease))
660
+ : this.#admission.run(input.sessionId, update);
591
661
  }
592
662
  async #reconcileExecutorAfterFailedCommit(previous) {
593
663
  try {
@@ -0,0 +1,257 @@
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 { isWorkHubCoordinationSessionId, userFacingText, } from '@maka/core/session';
20
+ import { SIDE_CONVERSATION_SESSION_LABEL } from '@maka/core/side-conversation';
21
+ import { buildCheckinPrompt, CHECKIN_LOOKBACK_MS, decodeCheckinModelOutput, selectCheckinCandidates, validateCheckinCards, } from '@maka/runtime/session-checkin';
22
+ import { abortable } from '../client/wait-for-ready.js';
23
+ /** Sessions read in full per check-in; the rest of the catalog is judged by its row. */
24
+ const CHECKIN_DEEP_READ_MAX = 24;
25
+ const CHECKIN_TIMEOUT_MS = 60_000;
26
+ const CHECKIN_EFFECTS_RETAINED = 16;
27
+ const EXCLUDED_LABELS = new Set([
28
+ SIDE_CONVERSATION_SESSION_LABEL,
29
+ 'mode:bot',
30
+ 'mode:deep_research',
31
+ 'scheduled-task',
32
+ ]);
33
+ /**
34
+ * Runs one check-in per effect identity: a retry with the same identity gets
35
+ * the same answer and never pays for a second model call while this Host runs.
36
+ */
37
+ export class HostSessionCheckinCoordinator {
38
+ ports;
39
+ handlers = {
40
+ 'session.checkin.generate': (input, context) => this.generate(input, context),
41
+ };
42
+ #effects = new Map();
43
+ #aborts = new Set();
44
+ #closed = false;
45
+ constructor(ports) {
46
+ this.ports = ports;
47
+ }
48
+ generate(input, context) {
49
+ if (this.#closed)
50
+ return Promise.resolve(draining());
51
+ const existing = this.#effects.get(input.effectId);
52
+ if (existing) {
53
+ return existing.since === input.since
54
+ ? existing.task
55
+ : Promise.resolve({
56
+ ok: false,
57
+ error: {
58
+ code: 'operation_conflict',
59
+ message: 'Check-in effect identity is already in use',
60
+ },
61
+ });
62
+ }
63
+ const residency = context.acquireResidency();
64
+ const abort = new AbortController();
65
+ this.#aborts.add(abort);
66
+ const signal = AbortSignal.any([
67
+ abort.signal,
68
+ AbortSignal.timeout(this.ports.timeoutMs ?? CHECKIN_TIMEOUT_MS),
69
+ ]);
70
+ const task = this.#run(input, context, signal)
71
+ .then((result) => ({ ok: true, result }), () => this.#closed
72
+ ? draining()
73
+ : { ok: false, error: { code: 'internal_failure', message: 'Check-in failed' } })
74
+ .finally(() => {
75
+ this.#aborts.delete(abort);
76
+ residency.release();
77
+ });
78
+ this.#effects.set(input.effectId, { since: input.since, task });
79
+ while (this.#effects.size > CHECKIN_EFFECTS_RETAINED) {
80
+ this.#effects.delete(this.#effects.keys().next().value);
81
+ }
82
+ return task;
83
+ }
84
+ beginDrain() {
85
+ this.#closed = true;
86
+ for (const abort of this.#aborts)
87
+ abort.abort();
88
+ }
89
+ async close() {
90
+ this.beginDrain();
91
+ await Promise.allSettled([...this.#effects.values()].map((effect) => effect.task));
92
+ }
93
+ async #run(input, context, signal) {
94
+ const effectId = input.effectId;
95
+ if (!(await abortable(() => this.ports.allowed(), signal)))
96
+ return { kind: 'empty', effectId };
97
+ const target = await abortable(() => this.ports.readModelTarget(), signal);
98
+ if (!target)
99
+ return { kind: 'failed', effectId, errorClass: 'configuration' };
100
+ const now = this.ports.now?.() ?? Date.now();
101
+ const sessions = await abortable(() => this.ports.listSessions(context), signal);
102
+ const recent = sessions
103
+ .filter((session) => checkinMayRead(session, now))
104
+ .sort((a, b) => b.activityAt - a.activityAt)
105
+ .slice(0, CHECKIN_DEEP_READ_MAX);
106
+ const states = [];
107
+ let unreadable = 0;
108
+ for (const session of recent) {
109
+ const state = await abortable(() => this.ports.readSession(session), signal).catch((error) => {
110
+ if (signal.aborted)
111
+ throw error;
112
+ unreadable += 1;
113
+ return undefined;
114
+ });
115
+ if (state)
116
+ states.push(state);
117
+ }
118
+ // One unreadable Session is skipped; reading none at all is a broken check-in, not a quiet one.
119
+ if (unreadable > 0 && states.length === 0) {
120
+ return { kind: 'failed', effectId, errorClass: 'unknown' };
121
+ }
122
+ const candidates = selectCheckinCandidates(states, { now, since: input.since });
123
+ if (candidates.length === 0)
124
+ return { kind: 'empty', effectId };
125
+ const model = await this.ports.generate({
126
+ target,
127
+ prompt: buildCheckinPrompt(candidates),
128
+ abortSignal: signal,
129
+ });
130
+ if (!model.ok)
131
+ return { kind: 'failed', effectId, errorClass: model.errorClass };
132
+ const decoded = decodeCheckinModelOutput(model.text);
133
+ if (!decoded.ok)
134
+ return { kind: 'failed', effectId, errorClass: 'invalid_response' };
135
+ const validation = validateCheckinCards(decoded.cards, candidates);
136
+ return {
137
+ kind: 'generated',
138
+ effectId,
139
+ cards: validation.cards,
140
+ dropped: validation.dropped.length,
141
+ };
142
+ }
143
+ }
144
+ const CATALOG_PAGES_MAX = 10;
145
+ const MESSAGES_KEPT = 20;
146
+ /** Reads catalog pages until they run out or the page budget does. */
147
+ export async function listCheckinCatalogSessions(query) {
148
+ const sessions = [];
149
+ let next = { kind: 'list_start' };
150
+ for (let page = 0; page < CATALOG_PAGES_MAX; page += 1) {
151
+ const outcome = await query(next);
152
+ if (!outcome.ok || outcome.result.kind !== 'page')
153
+ break;
154
+ for (const item of outcome.result.sessions) {
155
+ if (!('kind' in item))
156
+ sessions.push(item);
157
+ }
158
+ if (!outcome.result.nextCursor)
159
+ break;
160
+ next = {
161
+ kind: 'list_continue',
162
+ revision: outcome.result.revision,
163
+ cursor: outcome.result.nextCursor,
164
+ };
165
+ }
166
+ return sessions;
167
+ }
168
+ /** Maps what the Host recorded about one Session into the check-in's view of it. */
169
+ export function checkinSessionState(input) {
170
+ const turn = input.canonical.rootTurn;
171
+ const waitingForUser = input.session.status === 'waiting_for_user' ||
172
+ input.canonical.interactions.pending.length > 0 ||
173
+ turn?.status === 'waiting_for_user';
174
+ let lastTurn = null;
175
+ if (!turn && !waitingForUser)
176
+ lastTurn = recordedLastTurn(input.turns);
177
+ if (turn && !waitingForUser) {
178
+ if (turn.status === 'completed')
179
+ lastTurn = { status: 'completed' };
180
+ else if (turn.status === 'failed') {
181
+ lastTurn = {
182
+ status: 'failed',
183
+ failureClass: turn.failureClass,
184
+ ...(turn.failureMessage ? { failureMessage: turn.failureMessage } : {}),
185
+ };
186
+ }
187
+ else if (turn.status === 'cancelled') {
188
+ lastTurn = { status: 'cancelled', abortSource: turn.abortSource };
189
+ }
190
+ else
191
+ lastTurn = { status: 'in_progress' };
192
+ }
193
+ const goal = input.canonical.goal;
194
+ const texts = [];
195
+ for (const message of input.messages) {
196
+ if (message.type === 'user' && !message.origin && typeof message.text === 'string') {
197
+ texts.push({ role: 'user', text: userFacingText(message) });
198
+ }
199
+ else if (message.type === 'assistant' && typeof message.text === 'string') {
200
+ texts.push({ role: 'assistant', text: message.text });
201
+ }
202
+ }
203
+ const first = texts.find((message) => message.role === 'user');
204
+ const recent = texts.slice(-MESSAGES_KEPT);
205
+ return {
206
+ sessionId: input.session.id,
207
+ revision: input.session.revision,
208
+ name: input.session.name,
209
+ activityAt: input.session.activityAt,
210
+ lastTurn,
211
+ waitingForUser,
212
+ goal: goal
213
+ ? { status: goal.status, condition: goal.condition, lastReason: goal.lastReason }
214
+ : null,
215
+ todos: input.todos,
216
+ messages: first && !recent.includes(first) ? [first, ...recent] : recent,
217
+ };
218
+ }
219
+ /**
220
+ * A Session written before Root Turn admissions, or imported, still carries
221
+ * `turn_state` records. Only a recorded status counts; an inferred one is a
222
+ * reading of old data, not evidence.
223
+ */
224
+ function recordedLastTurn(turns) {
225
+ const turn = turns.at(-1);
226
+ if (!turn || turn.statusSource !== 'recorded')
227
+ return null;
228
+ switch (turn.status) {
229
+ case 'completed':
230
+ return { status: 'completed' };
231
+ case 'failed':
232
+ return {
233
+ status: 'failed',
234
+ failureClass: turn.errorClass ?? 'unknown',
235
+ ...(turn.failureMessage ? { failureMessage: turn.failureMessage } : {}),
236
+ };
237
+ case 'aborted':
238
+ return { status: 'cancelled', abortSource: turn.abortSource ?? 'unknown' };
239
+ case 'running':
240
+ return { status: 'in_progress' };
241
+ }
242
+ }
243
+ /** Judged from the catalog row alone, before any Session is read in full. */
244
+ export function checkinMayRead(session, now) {
245
+ return (!session.isArchived &&
246
+ !session.subagent &&
247
+ !session.parentSessionId &&
248
+ session.backend === 'ai-sdk' &&
249
+ session.status !== 'running' &&
250
+ !(session.liveRunState?.runningTurnIds.length ?? 0) &&
251
+ !isWorkHubCoordinationSessionId(session.id) &&
252
+ !session.labels.some((label) => EXCLUDED_LABELS.has(label)) &&
253
+ session.activityAt >= now - CHECKIN_LOOKBACK_MS);
254
+ }
255
+ function draining() {
256
+ return { ok: false, error: { code: 'host_draining', message: 'Runtime Host is draining' } };
257
+ }