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,8 +16,10 @@
16
16
  * specific language governing permissions and limitations
17
17
  * under the License.
18
18
  */
19
+ import { conditionInput, normalizeCondition, } from './condition.js';
19
20
  import { z } from 'zod';
20
21
  import { MatterReviewInvalidated } from './review.js';
22
+ import { isPendingActivationTurnId } from './matter.js';
21
23
  export function buildMatterTools(deps) {
22
24
  const own = (ctx) => {
23
25
  deps.authorize?.(ctx);
@@ -35,10 +37,42 @@ export function buildMatterTools(deps) {
35
37
  kind: z.literal('at'),
36
38
  at: z.number().describe('Future absolute Unix milliseconds'),
37
39
  });
40
+ const progressSummary = z
41
+ .string()
42
+ .trim()
43
+ .min(1)
44
+ .refine((value) => Array.from(value).length <= 30, 'Progress summary must be at most 30 characters')
45
+ .describe('用不超过30字概括当前进展,供用户在任务列表查看。由你概括,不要截断正文。');
38
46
  return [
47
+ {
48
+ name: 'MatterConditionTest',
49
+ discovery: 'direct',
50
+ description: 'Test and save a read-only JavaScript condition checker against real data. Inspect the returned result and fix/retest until it matches the intended condition. Testing does not register a wait. Pass checkerId to MatterSettle wait with an absolute fallback time in wakes. Code/parameters are immutable for that ID; changed code must be tested again. Background checks use the same read-only capabilities and current source permissions, without a model. A trigger, repeated failure or fallback time wakes this task once.',
51
+ parameters: conditionInput,
52
+ categoryHint: 'file_write',
53
+ executionSemantics: 'exclusive_step',
54
+ impl: async (input, ctx) => {
55
+ const o = own(ctx);
56
+ deps.store.assertActive(o.id, o.activationId);
57
+ if (!deps.testCondition)
58
+ throw new Error('Condition execution is unavailable');
59
+ const definition = normalizeCondition(input);
60
+ const result = await deps.testCondition(definition, ctx);
61
+ ctx.abortSignal.throwIfAborted();
62
+ deps.store.assertActive(o.id, o.activationId);
63
+ const saved = deps.store.conditions.saveTest(o.id, definition, result);
64
+ return {
65
+ checkerId: saved.id,
66
+ testedAt: saved.testedAt,
67
+ result: saved.result,
68
+ waiting: false,
69
+ };
70
+ },
71
+ },
39
72
  {
40
73
  name: 'MatterRead',
41
- description: 'Refresh file paths, revision and current time. This writes observation state and may bind a queued activation; it is not read-only. Read request.md, state.md and inbox.json with MatterReadFile; their contents are not returned here. Call alone.',
74
+ discovery: 'direct',
75
+ description: 'Refresh file paths, revision and current time. This writes observation state and may bind a queued activation; it is not read-only. Use only when you need task files/history; not required before settlement. Call alone.',
42
76
  parameters: z.object({
43
77
  activationId: z
44
78
  .string()
@@ -54,17 +88,24 @@ export function buildMatterTools(deps) {
54
88
  m &&
55
89
  m.activation &&
56
90
  m.activation.id === input.activationId &&
57
- m.activation.turnId.startsWith('pending:'))
91
+ isPendingActivationTurnId(m.activation.turnId))
58
92
  deps.store.bindTurn(m.id, input.activationId, ctx.turnId);
59
93
  const o = own(ctx);
60
94
  deps.store.observe(o.id, o.activationId);
61
- return deps.store.workspace(o.id, o.activationId);
95
+ const snapshot = deps.store.get(o.id);
96
+ return {
97
+ ...deps.store.workspace(o.id, o.activationId),
98
+ request: snapshot.matter.request,
99
+ note: snapshot.matter.stateText,
100
+ events: snapshot.events,
101
+ };
62
102
  },
63
103
  },
64
104
  {
65
105
  name: 'MatterCheckpoint',
66
106
  description: 'Save current working state after meaningful progress. Does not end this run or change the user objective.',
67
107
  parameters: z.object({
108
+ progressSummary,
68
109
  expectedRevision: z.number().int().positive(),
69
110
  stateFile: z
70
111
  .string()
@@ -74,21 +115,33 @@ export function buildMatterTools(deps) {
74
115
  executionSemantics: 'exclusive_step',
75
116
  impl: (input, ctx) => {
76
117
  const o = own(ctx);
77
- const result = deps.store.checkpoint(o.id, o.activationId, input.expectedRevision, deps.store.readDraft(o.id, o.activationId, input.stateFile), operation(ctx));
118
+ const result = deps.store.checkpoint(o.id, o.activationId, input.expectedRevision, deps.store.readDraft(o.id, o.activationId, input.stateFile), operation(ctx), input.progressSummary);
78
119
  deps.changed();
79
120
  return deps.store.workspace(result.id, o.activationId);
80
121
  },
81
122
  },
82
123
  {
83
124
  name: 'MatterSettle',
84
- description: 'Commit state and finish this activation: continue immediately, wait for a specific external condition, or complete the original objective. No business tools may execute after success.',
125
+ discovery: 'direct',
126
+ description: 'Submit your result directly (optional note, no draft file required) and finish this activation: continue immediately, wait for a specific external condition, or complete the original objective. Continue commits without model review; wait and complete are reviewed for premature exit or missed requirements, not for reprinting historical evidence. No business tools may execute after success.',
85
127
  parameters: z.object({
86
- expectedRevision: z.number().int().positive(),
87
- stateFile: z
128
+ note: z
88
129
  .string()
89
- .describe('Absolute path to this activation’s draft.md, edited with MatterWriteFile before submitting'),
130
+ .max(24000)
131
+ .optional()
132
+ .describe('Optional working note to retain for future activations. Omit to keep the previous note; no draft file is needed.'),
133
+ progressSummary,
90
134
  disposition: z.enum(['continue', 'wait', 'complete']),
91
135
  wakes: z.array(wake).max(10).optional(),
136
+ condition: z
137
+ .object({
138
+ checkerId: z
139
+ .string()
140
+ .describe('ID returned by a successful MatterConditionTest in this task'),
141
+ intervalMs: z.number().int().min(1000).max(86400000).default(60000),
142
+ })
143
+ .optional()
144
+ .describe('Optional tested condition for wait. wakes must still include an absolute fallback time; the first trigger or fallback wins. Testing alone does not wait.'),
92
145
  waitingFor: z
93
146
  .string()
94
147
  .trim()
@@ -96,18 +149,11 @@ export function buildMatterTools(deps) {
96
149
  .max(1000)
97
150
  .optional()
98
151
  .describe('For wait only: the concrete condition that prevents useful work now. A wake time is only when to check it.'),
99
- reason: z.string().min(1).max(2000),
100
152
  summary: z
101
153
  .string()
102
154
  .min(1)
103
155
  .max(4000)
104
- .describe('What this activation actually did and found. The host appends this to history with a timestamp.'),
105
- next: z
106
- .string()
107
- .min(1)
108
- .max(2000)
109
- .optional()
110
- .describe('Possible next actions, based on the current judgment; future activations must reassess them.'),
156
+ .describe('What you did and found, and why continuing, waiting or completing is appropriate. The host saves this with a timestamp.'),
111
157
  update: z
112
158
  .string()
113
159
  .max(2000)
@@ -118,13 +164,37 @@ export function buildMatterTools(deps) {
118
164
  executionSemantics: 'exclusive_step',
119
165
  impl: async (input, ctx) => {
120
166
  const o = own(ctx);
121
- const { stateFile, ...commit } = input;
122
- const submission = {
123
- ...commit,
124
- stateText: deps.store.readDraft(o.id, o.activationId, stateFile),
125
- };
126
167
  try {
127
- const review = deps.store.beginReview(o.id, o.activationId, submission, operation(ctx), stateFile);
168
+ const { note, ...commit } = input;
169
+ const previous = deps.store.submittedInput(operation(ctx));
170
+ let revision;
171
+ let state;
172
+ if (previous) {
173
+ revision = previous.expectedRevision;
174
+ state = previous.stateText;
175
+ }
176
+ else {
177
+ const delivered = await deps.deliveredInput?.(ctx);
178
+ if (!delivered || delivered.activationId !== o.activationId)
179
+ throw new MatterReviewInvalidated();
180
+ const m = deps.store.adoptDeliveredInput(o.id, o.activationId, delivered.basis, delivered.eventCursor);
181
+ revision = m.revision;
182
+ state = m.stateText;
183
+ }
184
+ const submission = {
185
+ ...commit,
186
+ expectedRevision: revision,
187
+ stateText: note ?? state,
188
+ reason: commit.summary.slice(0, 2000),
189
+ };
190
+ deps.store.saveSubmission(operation(ctx), submission);
191
+ if (submission.disposition === 'continue') {
192
+ ctx.abortSignal.throwIfAborted();
193
+ const result = deps.store.settle(o.id, o.activationId, submission, operation(ctx));
194
+ deps.changed();
195
+ return deps.store.workspace(result.id, o.activationId);
196
+ }
197
+ const review = deps.store.beginReview(o.id, o.activationId, submission, operation(ctx));
128
198
  const verdict = review.committed ? review.verdict : await deps.review(review);
129
199
  ctx.abortSignal.throwIfAborted();
130
200
  if (!review.verdict)
@@ -158,7 +228,7 @@ export function buildMatterTools(deps) {
158
228
  },
159
229
  {
160
230
  name: 'MatterWriteFile',
161
- description: 'Write the entire draft.md file for this activation. This edits a working file only; publish it with MatterCheckpoint or MatterSettle. Other matter files are host-owned.',
231
+ description: 'Optional legacy draft editor for this activation. Publish this file with MatterCheckpoint. MatterSettle accepts an inline note instead and does not read the draft. Other matter files are host-owned.',
162
232
  parameters: z.object({ path: z.string(), content: z.string() }),
163
233
  categoryHint: 'file_write',
164
234
  executionSemantics: 'exclusive_step',
@@ -30,7 +30,28 @@ class AssistantRuntime {
30
30
  directory;
31
31
  dependencies;
32
32
  tools = [];
33
+ internalTools = [];
34
+ toolFilters = [];
33
35
  bot = new AssistantBotBridge();
36
+ backgroundSessions = [];
37
+ sessionAccess = [];
38
+ hasSessionAccess(sessionId) {
39
+ return (this.bot.isConversation(sessionId) ||
40
+ this.bot.isWorker(sessionId) ||
41
+ this.backgroundSessions.some((read) => read().includes(sessionId)) ||
42
+ this.sessionAccess.some((allows) => allows(sessionId)));
43
+ }
44
+ /**
45
+ * The only visibility policy. Catalogs and execution both use it, so a tool hidden
46
+ * from a Session cannot run in that Session either.
47
+ */
48
+ visibleTools(sessionId, tools) {
49
+ const nativeNames = new Set(this.tools.map((tool) => tool.name));
50
+ const allowed = this.hasSessionAccess(sessionId)
51
+ ? tools
52
+ : tools.filter((tool) => !nativeNames.has(tool.name));
53
+ return this.toolFilters.reduce((current, filter) => filter(sessionId, current), allowed);
54
+ }
34
55
  sections = [];
35
56
  contexts = [];
36
57
  checks = [];
@@ -53,18 +74,19 @@ class AssistantRuntime {
53
74
  if (this.initialized)
54
75
  throw Error('Personal assistant already initialized');
55
76
  const settings = await this.loadSettings(legacy, entries);
56
- const backgroundSessions = [];
57
77
  const services = {
58
78
  bot: this.bot,
59
- backgroundSessions: { register: (read) => backgroundSessions.push(read) },
79
+ backgroundSessions: { register: (read) => this.backgroundSessions.push(read) },
60
80
  ...this.dependencies,
61
81
  onClose: (dispose) => this.disposers.push(dispose),
62
82
  onStart: (start) => this.starters.push(start),
63
83
  tools: {
84
+ filter: (filter) => this.toolFilters.push(filter),
85
+ registerSessionAccess: (allows) => this.sessionAccess.push(allows),
64
86
  register: (tool) => {
65
87
  if (this.tools.some((t) => t.name === tool.name))
66
88
  throw Error(`Duplicate assistant tool: ${tool.name}`);
67
- this.tools.push({
89
+ const internalTool = {
68
90
  ...tool,
69
91
  impl: (input, call) => {
70
92
  if (this.closing)
@@ -84,9 +106,26 @@ class AssistantRuntime {
84
106
  return this.dependencies.agents.withInvocation(scoped, () => tool.impl(input, scoped));
85
107
  });
86
108
  },
109
+ };
110
+ this.internalTools.push(internalTool);
111
+ this.tools.push({
112
+ ...internalTool,
113
+ impl: (input, call) => {
114
+ if (this.closing)
115
+ throw Error('Personal assistant is shutting down');
116
+ if (!this.hasSessionAccess(call.sessionId))
117
+ throw Error('Personal assistant tools are unavailable in this session');
118
+ if (!this.visibleTools(call.sessionId, [tool]).length)
119
+ throw Error('Personal assistant tool is unavailable in this session');
120
+ return internalTool.impl(input, call);
121
+ },
87
122
  });
88
123
  },
89
- resolve: (sessionId) => sessionId ? this.dependencies.resolveTools(sessionId, this.tools) : { tools: this.tools },
124
+ // Only Host module APIs use this resolver. They retain the caller's source
125
+ // permissions (e.g. ordinary-chat original links) without exposing model tools.
126
+ resolve: (sessionId) => sessionId
127
+ ? this.dependencies.resolveTools(sessionId, this.internalTools)
128
+ : { tools: this.internalTools },
90
129
  },
91
130
  systemPrompt: {
92
131
  section: (value) => this.sections.push(value),
@@ -114,7 +153,7 @@ class AssistantRuntime {
114
153
  ])
115
154
  await initialize(services, settings[name].directory, settings[name].config);
116
155
  await this.dependencies.markBackgroundSessions([
117
- ...new Set(backgroundSessions.flatMap((read) => read())),
156
+ ...new Set(this.backgroundSessions.flatMap((read) => read())),
118
157
  ]);
119
158
  this.initialized = true;
120
159
  }
@@ -275,7 +314,7 @@ class AssistantRuntime {
275
314
  return settings;
276
315
  }
277
316
  }
278
- /** Host-owned opt-in. Disabled Hosts do not load modules, open their databases or start timers. */
317
+ /** Host-owned enablement, on by default. Disabled Hosts do not load modules, open their databases or start timers. */
279
318
  export class PersonalAssistantService {
280
319
  directory;
281
320
  dependencies;
@@ -288,6 +327,7 @@ export class PersonalAssistantService {
288
327
  transition = Promise.resolve();
289
328
  shutdown;
290
329
  stoppingError;
330
+ initializationError;
291
331
  constructor(directory, dependencies) {
292
332
  this.directory = directory;
293
333
  this.dependencies = dependencies;
@@ -303,19 +343,26 @@ export class PersonalAssistantService {
303
343
  throw Error('Personal assistant already initialized');
304
344
  this.legacy = legacy;
305
345
  this.entries = entries;
306
- let enabled = false;
307
346
  try {
308
- const saved = JSON.parse(await readFile(join(this.directory, 'enablement.json'), 'utf8'));
309
- if (typeof saved.enabled !== 'boolean')
310
- throw Error('Invalid personal assistant enablement');
311
- enabled = saved.enabled;
347
+ let enabled = true;
348
+ try {
349
+ const saved = JSON.parse(await readFile(join(this.directory, 'enablement.json'), 'utf8'));
350
+ if (typeof saved.enabled !== 'boolean')
351
+ throw Error('Invalid personal assistant enablement');
352
+ enabled = saved.enabled;
353
+ }
354
+ catch (error) {
355
+ if (error.code !== 'ENOENT')
356
+ throw error;
357
+ }
358
+ if (enabled)
359
+ this.runtime = await this.initialize();
312
360
  }
313
361
  catch (error) {
314
- if (error.code !== 'ENOENT')
315
- throw error;
362
+ // Optional assistant recovery must not prevent ordinary Host sessions from starting.
363
+ // Keep persisted preferences/data intact so Settings can retry after repair.
364
+ this.initializationError = error instanceof Error ? error.message : String(error);
316
365
  }
317
- if (enabled)
318
- this.runtime = await this.initialize();
319
366
  this.recovered = true;
320
367
  }
321
368
  async initialize() {
@@ -348,7 +395,10 @@ export class PersonalAssistantService {
348
395
  if (!this.started || this.draining)
349
396
  throw Error('Personal assistant is not ready');
350
397
  if (method === 'assistant.enablement')
351
- return { enabled: this.enabled };
398
+ return {
399
+ enabled: this.enabled,
400
+ ...(this.initializationError ? { error: this.initializationError } : {}),
401
+ };
352
402
  if (method === 'assistant.set-enabled') {
353
403
  if (!input ||
354
404
  typeof input !== 'object' ||
@@ -375,6 +425,7 @@ export class PersonalAssistantService {
375
425
  throw Error('Personal assistant is shutting down');
376
426
  this.runtime = runtime;
377
427
  runtime.start();
428
+ this.initializationError = undefined;
378
429
  }
379
430
  catch (error) {
380
431
  this.runtime = undefined;
@@ -415,6 +466,11 @@ export class PersonalAssistantService {
415
466
  hasInboxMessage(sessionId, id) {
416
467
  return this.enabled && this.runtime.bot.hasUserMessage(sessionId, id);
417
468
  }
469
+ filterTools(sessionId, tools) {
470
+ if (!this.enabled)
471
+ return tools;
472
+ return this.runtime.visibleTools(sessionId, tools);
473
+ }
418
474
  toolCeiling(sessionId) {
419
475
  return this.enabled && this.runtime.bot.isWorker(sessionId)
420
476
  ? this.runtime.tools.filter((tool) => BOT_TOOLS.has(tool.name))
@@ -60,7 +60,14 @@ export function sameResolvedRuntimeHostProfileTarget(left, right) {
60
60
  if (left.profile.kind === 'local' || right.profile.kind === 'local')
61
61
  return true;
62
62
  if (left.profile.kind === 'environment' || right.profile.kind === 'environment') {
63
- return profileTargetBinding(left.profile) === profileTargetBinding(right.profile);
63
+ if (left.profile.kind !== 'environment' || right.profile.kind !== 'environment')
64
+ return false;
65
+ const a = left.profile.operator;
66
+ const b = right.profile.operator;
67
+ return (sameEnvironmentRuntimeHostDeployment(left.profile, right.profile) &&
68
+ (a.kind === 'node' && b.kind === 'node'
69
+ ? a.modulePath === b.modulePath
70
+ : operatorTargetBinding(a) === operatorTargetBinding(b)));
64
71
  }
65
72
  return (left.profile.id === right.profile.id &&
66
73
  profileCredentialBinding(left.profile) === profileCredentialBinding(right.profile) &&
@@ -746,6 +753,28 @@ class FileRuntimeHostProfileCatalog {
746
753
  return { rebound: true, document: next };
747
754
  });
748
755
  }
756
+ updateEnvironmentOperatorIfCurrent(expected, operator) {
757
+ const source = decodeEnvironmentRuntimeHostProfile(expected);
758
+ const replacement = decodeRuntimeHostPosixOperatorCommand(operator);
759
+ if (source.operator.kind !== 'node' ||
760
+ replacement.kind !== 'node' ||
761
+ source.operator.modulePath !== replacement.modulePath)
762
+ throw new Error('WSL recovery must retain its operator module');
763
+ return this.#exclusive(async () => {
764
+ const current = await this.#readSnapshot();
765
+ const profile = current.profiles.find((p) => p.id === source.id && p.kind === 'environment');
766
+ if (!profile ||
767
+ !sameEnvironmentRuntimeHostDeployment(profile, source) ||
768
+ operatorTargetBinding(profile.operator) !== operatorTargetBinding(source.operator))
769
+ return false;
770
+ const updated = decodeEnvironmentRuntimeHostProfile({ ...profile, operator: replacement });
771
+ await writeProfileDocument(this.path, decodeRuntimeHostProfileDocument({
772
+ schemaVersion: PROFILE_SCHEMA_VERSION,
773
+ profiles: current.profiles.map((p) => (p.id === profile.id ? updated : p)),
774
+ }));
775
+ return true;
776
+ });
777
+ }
749
778
  updateRemoteProfileIfCurrent(target, update) {
750
779
  const expectedProfile = decodeRemoteRuntimeHostProfile(target.profile);
751
780
  const expectedIncarnationId = requireProfileIncarnationId(target.profileIncarnationId);
@@ -96,23 +96,30 @@ export function runtimeHostSshOperatorRemoteCommand(operator, args, environment
96
96
  if (operator.kind !== 'node')
97
97
  throw new Error('Windows Runtime Host operator must use Node');
98
98
  const payload = Buffer.from(JSON.stringify({
99
- ...invocation,
99
+ executable: invocation.executable,
100
+ // ProcessStartInfo bypasses Windows PowerShell 5.1's lossy native argument
101
+ // binder. Encode the argv using the Windows C runtime quoting rules.
102
+ argumentLine: invocation.args.map(quoteWindowsArgument).join(' '),
100
103
  environment,
101
104
  modulePath: operator.modulePath,
102
105
  deploymentRoot: win32.dirname(operator.modulePath),
103
106
  missingOperatorIsSuccess: options.missingOperatorIsSuccess === true,
104
107
  }), 'utf8').toString('base64');
105
108
  const script = [
109
+ `$ProgressPreference='SilentlyContinue'`,
106
110
  `$p=[Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('${payload}'))|ConvertFrom-Json`,
107
111
  `if($p.missingOperatorIsSuccess -and -not (Test-Path -LiteralPath $p.modulePath -PathType Leaf)){if(-not (Test-Path -LiteralPath $p.deploymentRoot)){exit 0}else{exit 1}}`,
108
112
  `foreach($e in $p.environment.psobject.Properties){[Environment]::SetEnvironmentVariable($e.Name,[string]$e.Value,'Process')}`,
109
113
  `$code=1`,
110
- `try{& ([string]$p.executable) @($p.args|ForEach-Object {[string]$_});$code=if($null -eq $LASTEXITCODE){1}else{$LASTEXITCODE}}catch{$code=1}`,
114
+ `try{$start=New-Object System.Diagnostics.ProcessStartInfo;$start.FileName=[string]$p.executable;$start.Arguments=[string]$p.argumentLine;$start.UseShellExecute=$false;$child=[System.Diagnostics.Process]::Start($start);try{$child.WaitForExit();$code=$child.ExitCode}finally{$child.Dispose()}}catch{$code=1}`,
111
115
  `exit $code`,
112
116
  ].join(';');
113
117
  const encoded = Buffer.from(script, 'utf16le').toString('base64');
114
118
  return `powershell.exe -NoLogo -NoProfile -NonInteractive -EncodedCommand ${encoded}`;
115
119
  }
120
+ function quoteWindowsArgument(value) {
121
+ return `"${value.replace(/(\\*)"/gu, '$1$1\\"').replace(/(\\+)$/u, '$1$1')}"`;
122
+ }
116
123
  async function waitForActivation(child, input, timeoutMs) {
117
124
  let stdout = Buffer.alloc(0);
118
125
  let overflow = false;
@@ -20,7 +20,12 @@ import { GOAL_CONDITION_TEXT_LIMIT, GOAL_MAX_ITERATIONS_LIMIT, GOAL_REASON_TEXT_
20
20
  import { requireCount, requireEncodedByteLimit, requireEntityId, requireExactRecord, requireUtf8String, } from './codec.js';
21
21
  import { invalidProtocolFrame } from './errors.js';
22
22
  import { defineOperation } from './operation-spec.js';
23
- export const GOAL_RESULT_MAX_BYTES = 8 * 1024;
23
+ export const GOAL_RESULT_MAX_BYTES = 16 * 1024;
24
+ /** Display bounds; canonical ShellRun references fit in full. */
25
+ export const GOAL_EVENT_WAIT_SUMMARY_LIMITS = Object.freeze({
26
+ resourceIdBytes: 512,
27
+ reasonCodeBytes: 128,
28
+ });
24
29
  const QUERY_ERRORS = [
25
30
  'host_not_ready',
26
31
  'host_draining',
@@ -31,6 +36,17 @@ const QUERY_ERRORS = [
31
36
  const CONTROL_ERRORS = [...QUERY_ERRORS, 'session_archived', 'operation_conflict'];
32
37
  const ARM_ERRORS = CONTROL_ERRORS;
33
38
  export const GOAL_OPERATION_SPECS = {
39
+ 'goal.event-wait.cancel': defineOperation({
40
+ mode: 'control',
41
+ availability: 'ready',
42
+ errors: CONTROL_ERRORS,
43
+ decodeInput: decodeGoalEventWaitCancelInput,
44
+ decodeOutput: decodeGoalEventWaitCancelResult,
45
+ assertOutputForInput(input, output) {
46
+ if (input.sessionId !== output.sessionId)
47
+ throw invalidProtocolFrame('Wait cancellation belongs to another Session');
48
+ },
49
+ }),
34
50
  'goal.query': defineOperation({
35
51
  mode: 'query',
36
52
  availability: 'ready',
@@ -85,6 +101,7 @@ export function decodeGoalProjection(value) {
85
101
  'lastReason',
86
102
  'achievedAt',
87
103
  'pausedAt',
104
+ 'eventWait',
88
105
  ]);
89
106
  const condition = requireUtf8String(record.condition, 'Goal condition', GOAL_CONDITION_TEXT_LIMIT.utf8Bytes);
90
107
  if (condition.length > GOAL_CONDITION_TEXT_LIMIT.codeUnits) {
@@ -107,6 +124,7 @@ export function decodeGoalProjection(value) {
107
124
  lastReason,
108
125
  achievedAt: requireNullableCount(record.achievedAt, 'Goal achievedAt'),
109
126
  pausedAt: requireNullableCount(record.pausedAt, 'Goal pausedAt'),
127
+ eventWait: record.eventWait === null ? null : decodeGoalEventWaitProjection(record.eventWait),
110
128
  };
111
129
  }
112
130
  function decodeGoalQueryInput(value) {
@@ -220,3 +238,103 @@ function requireNullableCount(value, label) {
220
238
  return null;
221
239
  return requireCount(value, label);
222
240
  }
241
+ export function decodeGoalEventWaitProjection(value) {
242
+ const r = requireExactRecord(value, 'Goal event wait', [
243
+ 'waitId',
244
+ 'controlGeneration',
245
+ 'waitRevision',
246
+ 'resource',
247
+ 'reason',
248
+ 'deadlineAt',
249
+ 'phase',
250
+ 'observation',
251
+ 'outcome',
252
+ ]);
253
+ const resource = requireExactRecord(r.resource, 'Wait resource', [
254
+ 'providerId',
255
+ 'resourceType',
256
+ 'resourceId',
257
+ ]);
258
+ if (r.phase !== 'observing' && r.phase !== 'awaiting_admission')
259
+ throw invalidProtocolFrame('Invalid wait phase');
260
+ if (r.outcome !== null &&
261
+ r.outcome !== 'satisfied' &&
262
+ r.outcome !== 'invalidated' &&
263
+ r.outcome !== 'source_unavailable' &&
264
+ r.outcome !== 'expired')
265
+ throw invalidProtocolFrame('Invalid wait outcome');
266
+ let observation = null;
267
+ if (r.observation !== null) {
268
+ const o = requireExactRecord(r.observation, 'Wait observation', [
269
+ 'state',
270
+ 'lastObservedAt',
271
+ 'reasonCode',
272
+ ]);
273
+ if (o.state !== 'checking' && o.state !== 'pending' && o.state !== 'unknown')
274
+ throw invalidProtocolFrame('Invalid observation state');
275
+ observation = {
276
+ state: o.state,
277
+ lastObservedAt: requireNullableCount(o.lastObservedAt, 'Observation time'),
278
+ reasonCode: o.reasonCode === null
279
+ ? null
280
+ : requireUtf8String(o.reasonCode, 'Observation reason', GOAL_EVENT_WAIT_SUMMARY_LIMITS.reasonCodeBytes),
281
+ };
282
+ }
283
+ if ((r.phase === 'observing' && (observation === null || r.outcome !== null)) ||
284
+ (r.phase === 'awaiting_admission' && (observation !== null || r.outcome === null)))
285
+ throw invalidProtocolFrame('Inconsistent wait phase');
286
+ const reason = requireNullableGoalReason(r.reason);
287
+ if (reason === null)
288
+ throw invalidProtocolFrame('Invalid wait reason');
289
+ return {
290
+ waitId: requireEntityId(r.waitId, 'waitId'),
291
+ controlGeneration: requireCount(r.controlGeneration, 'Control generation'),
292
+ waitRevision: requireCount(r.waitRevision, 'Wait revision'),
293
+ resource: {
294
+ providerId: requireWaitTypeId(resource.providerId, 'Wait provider'),
295
+ resourceType: requireWaitTypeId(resource.resourceType, 'Wait resource type'),
296
+ resourceId: requireUtf8String(resource.resourceId, 'Wait reference', GOAL_EVENT_WAIT_SUMMARY_LIMITS.resourceIdBytes),
297
+ },
298
+ reason,
299
+ deadlineAt: requireCount(r.deadlineAt, 'Wait deadline'),
300
+ phase: r.phase,
301
+ observation,
302
+ outcome: r.outcome,
303
+ };
304
+ }
305
+ function decodeGoalEventWaitCancelInput(value) {
306
+ const r = requireExactRecord(value, 'Wait cancellation', [
307
+ 'sessionId',
308
+ 'goalId',
309
+ 'controlGeneration',
310
+ 'waitId',
311
+ 'expectedGoalRevision',
312
+ ]);
313
+ return {
314
+ sessionId: requireEntityId(r.sessionId, 'sessionId'),
315
+ goalId: requireEntityId(r.goalId, 'goalId'),
316
+ waitId: requireEntityId(r.waitId, 'waitId'),
317
+ controlGeneration: requireCount(r.controlGeneration, 'Control generation'),
318
+ expectedGoalRevision: requireCount(r.expectedGoalRevision, 'Goal revision'),
319
+ };
320
+ }
321
+ function decodeGoalEventWaitCancelResult(value) {
322
+ requireEncodedByteLimit(value, 'Wait cancellation result', GOAL_RESULT_MAX_BYTES);
323
+ const r = requireExactRecord(value, 'Wait cancellation result', ['sessionId', 'outcome', 'goal']);
324
+ if (r.outcome !== 'cancelled' &&
325
+ r.outcome !== 'already_cancelled' &&
326
+ r.outcome !== 'already_admitted' &&
327
+ r.outcome !== 'conflict')
328
+ throw invalidProtocolFrame('Invalid cancellation outcome');
329
+ const sessionId = requireEntityId(r.sessionId, 'sessionId');
330
+ const goal = r.goal === null ? null : decodeGoalProjection(r.goal);
331
+ if (goal && goal.sessionId !== sessionId)
332
+ throw invalidProtocolFrame('Wait cancellation Goal belongs to another Session');
333
+ return { sessionId, outcome: r.outcome, goal };
334
+ }
335
+ function requireWaitTypeId(value, label) {
336
+ const id = requireUtf8String(value, label, 128);
337
+ if (!/^[A-Za-z0-9_.-]{1,128}$/.test(id))
338
+ throw invalidProtocolFrame(`Invalid ${label}`);
339
+ return id;
340
+ }
@@ -68,13 +68,20 @@ export const RUNTIME_HOST_REGISTRATION_SCHEMA_VERSION = 1;
68
68
  export const RUNTIME_HOST_PROTOCOL_VERSION = 0;
69
69
  // Increment when the same protocol version no longer guarantees safe Client-Host
70
70
  // interoperability. Mismatches are rejected before domain commands are admitted.
71
+ // Re-check against main before merging; sibling PRs may use the same next epoch.
72
+ export const RUNTIME_HOST_COMPATIBILITY_EPOCH = 229;
73
+ // 229: Session check-in proposes cards for unfinished work across Sessions.
74
+ // 228: Executor catalog queries support per-agent filtering and process-free inventory.
75
+ // Older peers reject the executorId and listOnly fields in the strict query decoder.
76
+ // 227: Goal projections carry eventWait and support goal.event-wait.cancel.
77
+ // Older peers cannot decode the wait summary or cancel a specific wait.
78
+ // 226: assistant.allocate-workspace allocates a Host-owned fallback for projectless assistants.
79
+ // 225: Goal successor transcript origins carry typed event-wait provenance.
80
+ // Older peers reject the additional field in the strict stored-message decoder.
71
81
  // 224: Assistant conversation admission supports Inbox receipts without a model Turn,
72
82
  // inbox execution-query resolutions, external connector provenance and message summaries.
73
83
  // Existing bot turn.start producers also carry strict external_connector provenance.
74
84
  // Also adds assistant.avatar/assistant.avatar-image and the bot block on assistant.binding.
75
- // 223 is used by the distinct protocol changes in open PRs #6115 and #6091;
76
- // re-check against main at merge time (the protocol epoch gate remains authoritative).
77
- export const RUNTIME_HOST_COMPATIBILITY_EPOCH = 224;
78
85
  // 222: Built-in personal assistant operations and the Host-owned default-off
79
86
  // master switch require matching Client and Host support.
80
87
  // 221: Epoch-220 peers do not support `artifact.image.resolve` or its image