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
@@ -194,7 +194,7 @@ export class GoalContinuationCoordinator {
194
194
  return this.settleDiscardedRegistration(registration);
195
195
  }
196
196
  if (registration.checkpoint &&
197
- !this.deps.goalManager.matchesActive(sessionId, registration.checkpoint)) {
197
+ !this.matchesExecutionCheckpoint(sessionId, turnId, registration.checkpoint, controlLease)) {
198
198
  return this.settleDiscardedRegistration(registration);
199
199
  }
200
200
  return this.enqueueTurn(outcome, controlLease, registration);
@@ -205,6 +205,14 @@ export class GoalContinuationCoordinator {
205
205
  ? this.deps.durability.settleCurrentExecution(registration.lane.sessionId, registration.turnId)
206
206
  : Promise.resolve();
207
207
  }
208
+ gateEventWait(sessionId) {
209
+ const lane = this.lanes.get(sessionId);
210
+ if (!lane)
211
+ return;
212
+ lane.intent = undefined;
213
+ this.clearWaitingTimer(lane);
214
+ this.abortEvaluation(lane, 'Explicit event wait registered');
215
+ }
208
216
  /** Revoke the current lane while allowing later turns in the same session. */
209
217
  invalidateSession(sessionId) {
210
218
  const lane = this.lanes.get(sessionId);
@@ -232,7 +240,7 @@ export class GoalContinuationCoordinator {
232
240
  if (this.disposed) {
233
241
  return { kind: 'unavailable', reason: 'Goal continuation is disposed.' };
234
242
  }
235
- if (!this.deps.goalManager.matchesActive(sessionId, current.checkpoint) ||
243
+ if (!this.matchesExecutionCheckpoint(sessionId, turnId, current.checkpoint, current.controlLease) ||
236
244
  !this.deps.goalManager.matchesControlLease(sessionId, current.controlLease)) {
237
245
  return { kind: 'unavailable', reason: 'Durable Goal execution no longer owns the Goal.' };
238
246
  }
@@ -265,7 +273,7 @@ export class GoalContinuationCoordinator {
265
273
  * at each door.
266
274
  */
267
275
  restoreDrive(lane, goal, controlLease, evaluation) {
268
- if (!isDrivingGoal(goal))
276
+ if (!isDrivingGoal(goal) || this.deps.eventWait?.isGated(lane.sessionId))
269
277
  return;
270
278
  lane.intent = { checkpoint: goalCheckpoint(goal), controlLease, evaluation };
271
279
  this.scheduleDrain(lane);
@@ -304,13 +312,16 @@ export class GoalContinuationCoordinator {
304
312
  return;
305
313
  }
306
314
  const lane = this.laneFor(sessionId);
307
- if (lane.intent || lane.turns.size > 0)
315
+ if (lane.turns.size > 0)
316
+ return;
317
+ if (lane.intent && (!pending.eventWait || !lane.intent.eventWait))
308
318
  return;
309
319
  lane.intent = {
310
320
  checkpoint: pending.checkpoint,
311
321
  controlLease: pending.controlLease,
312
322
  ...(pending.triggeringTurnId ? { triggeringTurnId: pending.triggeringTurnId } : {}),
313
323
  recoveredPrompt: pending.prompt,
324
+ ...(pending.eventWait ? { eventWait: pending.eventWait } : {}),
314
325
  evaluation: {
315
326
  met: false,
316
327
  impossible: false,
@@ -476,7 +487,9 @@ export class GoalContinuationCoordinator {
476
487
  await this.processQueuedTurn(lane, item);
477
488
  }
478
489
  catch (error) {
479
- this.pauseCurrentGoal(lane, `Goal continuation coordinator failed: ${errorMessage(error)}`);
490
+ if (this.deps.goalManager.matchesControlLease(lane.sessionId, item.controlLease)) {
491
+ this.pauseCurrentGoal(lane, `Goal continuation coordinator failed: ${errorMessage(error)}`);
492
+ }
480
493
  }
481
494
  finally {
482
495
  if (lane.processing === item)
@@ -512,11 +525,25 @@ export class GoalContinuationCoordinator {
512
525
  }
513
526
  }
514
527
  }
528
+ matchesExecutionCheckpoint(sessionId, turnId, checkpoint, controlLease) {
529
+ return (this.deps.goalManager.matchesActive(sessionId, checkpoint) ||
530
+ this.deps.eventWait?.ownsSource(sessionId, turnId, controlLease) === true);
531
+ }
515
532
  async processQueuedTurn(lane, item) {
516
533
  if (!this.deps.goalManager.matchesControlLease(lane.sessionId, item.controlLease)) {
517
534
  return;
518
535
  }
519
- if (item.checkpoint && !this.deps.goalManager.matchesActive(lane.sessionId, item.checkpoint)) {
536
+ if (item.checkpoint &&
537
+ !this.matchesExecutionCheckpoint(lane.sessionId, item.turnId, item.checkpoint, item.controlLease)) {
538
+ return;
539
+ }
540
+ if (this.deps.eventWait?.isGated(lane.sessionId)) {
541
+ if (item.outcome.kind === 'completed') {
542
+ await this.deps.eventWait.settleCompleted(lane.sessionId, item.turnId, item.controlLease);
543
+ }
544
+ else {
545
+ this.pauseCurrentGoal(lane, turnFailureReason(item.outcome));
546
+ }
520
547
  return;
521
548
  }
522
549
  if (sameGoalControlLease(lane.intent?.controlLease, item.controlLease)) {
@@ -539,13 +566,23 @@ export class GoalContinuationCoordinator {
539
566
  }
540
567
  await this.processCompletion(lane, item.controlLease, goal, item.turnId);
541
568
  }
569
+ commitGoalMutation(operation) {
570
+ return this.deps.mutateGoal ? this.deps.mutateGoal(operation) : operation(this.deps.durability);
571
+ }
542
572
  async processCompletion(lane, controlLease, initialGoal, turnId) {
543
573
  let goal = initialGoal;
544
- if (goal.status === 'waiting') {
545
- const woken = this.deps.goalManager.wakeWaiting(lane.sessionId, goalCheckpoint(goal));
546
- if (!woken)
574
+ await this.commitGoalMutation(async () => {
575
+ if (this.deps.eventWait?.isGated(lane.sessionId))
547
576
  return;
548
- goal = woken;
577
+ if (goal.status === 'waiting') {
578
+ const woken = this.deps.goalManager.wakeWaiting(lane.sessionId, goalCheckpoint(goal));
579
+ if (woken)
580
+ goal = woken;
581
+ }
582
+ });
583
+ if (this.deps.eventWait?.isGated(lane.sessionId)) {
584
+ await this.deps.eventWait.settleCompleted(lane.sessionId, turnId, controlLease);
585
+ return;
549
586
  }
550
587
  if (goal.status !== 'active')
551
588
  return;
@@ -555,98 +592,120 @@ export class GoalContinuationCoordinator {
555
592
  context = await this.deps.getRecentContext(lane.sessionId);
556
593
  }
557
594
  catch (error) {
558
- this.pauseAtCheckpoint(lane, checkpoint, `Unable to read Goal evaluation context: ${errorMessage(error)}`);
595
+ await this.commitGoalMutation(async () => this.pauseAtCheckpoint(lane, checkpoint, `Unable to read Goal evaluation context: ${errorMessage(error)}`));
559
596
  return;
560
597
  }
561
- if (!this.isCurrent(lane) || !this.deps.goalManager.matchesActive(lane.sessionId, checkpoint)) {
598
+ // Ordinary evaluator settlement uses this context read's usage snapshot.
599
+ // Explicit waits instead read persisted usage at the completed Turn boundary.
600
+ const tokensNow = this.deps.getTokenCount?.(lane.sessionId);
601
+ const evaluationAbort = new AbortController();
602
+ let evaluationTask;
603
+ let gated = false;
604
+ await this.commitGoalMutation(async () => {
605
+ if (!this.isCurrent(lane) || !this.deps.goalManager.matchesActive(lane.sessionId, checkpoint))
606
+ return;
607
+ if (this.deps.eventWait?.isGated(lane.sessionId)) {
608
+ gated = true;
609
+ return;
610
+ }
611
+ lane.evaluationAbort = evaluationAbort;
612
+ evaluationTask = evaluateGoal(this.deps.evaluator, goal.condition, context, lane.sessionId, evaluationAbort.signal);
613
+ });
614
+ if (!evaluationTask) {
615
+ if (gated)
616
+ await this.deps.eventWait.settleCompleted(lane.sessionId, turnId, controlLease);
562
617
  return;
563
618
  }
564
- const evaluationAbort = new AbortController();
565
- lane.evaluationAbort = evaluationAbort;
566
619
  let evaluation;
567
620
  try {
568
- evaluation = await evaluateGoal(this.deps.evaluator, goal.condition, context, lane.sessionId, evaluationAbort.signal);
621
+ evaluation = await evaluationTask;
569
622
  }
570
623
  finally {
571
624
  if (lane.evaluationAbort === evaluationAbort)
572
625
  lane.evaluationAbort = undefined;
573
626
  }
574
- if (!this.isCurrent(lane) || !this.deps.goalManager.matchesActive(lane.sessionId, checkpoint)) {
575
- return;
576
- }
577
- const tokensNow = this.deps.getTokenCount?.(lane.sessionId);
578
- const settlementBase = {
579
- checkpoint,
580
- reason: evaluation.reason,
581
- };
582
- let settled;
583
- if (evaluation.met || evaluation.impossible) {
584
- settled = this.deps.goalManager.settleTurn(lane.sessionId, {
585
- ...settlementBase,
586
- verdict: evaluation.met ? 'achieved' : 'impossible',
587
- });
588
- }
589
- else if (evaluation.waiting) {
590
- settled = this.deps.goalManager.settleTurn(lane.sessionId, {
591
- ...settlementBase,
592
- verdict: 'continue',
593
- waiting: true,
594
- ...(tokensNow !== undefined ? { tokensNow } : {}),
595
- });
596
- }
597
- else {
598
- settled = this.deps.goalManager.settleTurn(lane.sessionId, {
599
- ...settlementBase,
600
- verdict: 'continue',
601
- ...(!evaluation.evaluatorFailed ? { madeProgress: evaluation.progress } : {}),
602
- ...(tokensNow !== undefined ? { tokensNow } : {}),
603
- });
604
- }
605
- if (!settled)
606
- return;
607
- if (settled.status === 'achieved' || settled.status === 'impossible') {
608
- lane.intent = undefined;
609
- this.resetWaitingBackoff(lane);
610
- this.taskGatePolicy.record({
611
- sessionId: lane.sessionId,
612
- turnId,
613
- goalId: goal.id,
614
- decision: 'evaluator_terminal',
615
- taskKeys: [],
627
+ await this.commitGoalMutation(async (durability) => {
628
+ if (!this.isCurrent(lane) || !this.deps.goalManager.matchesActive(lane.sessionId, checkpoint))
629
+ return;
630
+ if (this.deps.eventWait?.isGated(lane.sessionId)) {
631
+ gated = true;
632
+ return;
633
+ }
634
+ const settlementBase = {
635
+ checkpoint,
636
+ reason: evaluation.reason,
637
+ };
638
+ let settled;
639
+ if (evaluation.met || evaluation.impossible) {
640
+ settled = this.deps.goalManager.settleTurn(lane.sessionId, {
641
+ ...settlementBase,
642
+ verdict: evaluation.met ? 'achieved' : 'impossible',
643
+ });
644
+ }
645
+ else if (evaluation.waiting) {
646
+ settled = this.deps.goalManager.settleTurn(lane.sessionId, {
647
+ ...settlementBase,
648
+ verdict: 'continue',
649
+ waiting: true,
650
+ ...(tokensNow !== undefined ? { tokensNow } : {}),
651
+ });
652
+ }
653
+ else {
654
+ settled = this.deps.goalManager.settleTurn(lane.sessionId, {
655
+ ...settlementBase,
656
+ verdict: 'continue',
657
+ ...(!evaluation.evaluatorFailed ? { madeProgress: evaluation.progress } : {}),
658
+ ...(tokensNow !== undefined ? { tokensNow } : {}),
659
+ });
660
+ }
661
+ if (!settled)
662
+ return;
663
+ if (settled.status === 'achieved' || settled.status === 'impossible') {
664
+ lane.intent = undefined;
665
+ this.resetWaitingBackoff(lane);
666
+ this.taskGatePolicy.record({
667
+ sessionId: lane.sessionId,
668
+ turnId,
669
+ goalId: goal.id,
670
+ decision: 'evaluator_terminal',
671
+ taskKeys: [],
672
+ });
673
+ return;
674
+ }
675
+ if (settled.status !== 'active' && settled.status !== 'waiting') {
676
+ lane.intent = undefined;
677
+ this.resetWaitingBackoff(lane);
678
+ const taskKeys = await this.taskGatePolicy.listActionable(lane.sessionId);
679
+ this.taskGatePolicy.record({
680
+ sessionId: lane.sessionId,
681
+ turnId,
682
+ goalId: goal.id,
683
+ decision: 'goal_stopped',
684
+ taskKeys,
685
+ });
686
+ return;
687
+ }
688
+ lane.intent = {
689
+ checkpoint: goalCheckpoint(settled),
690
+ controlLease,
691
+ triggeringTurnId: turnId,
692
+ evaluation,
693
+ };
694
+ const pendingPrompt = truncateGoalText(buildContinuationPrompt(settled, evaluation, undefined), GOAL_PENDING_PROMPT_TEXT_LIMIT);
695
+ await durability.recordPendingContinuation({
696
+ checkpoint: lane.intent.checkpoint,
697
+ controlLease,
698
+ prompt: pendingPrompt,
699
+ triggeringTurnId: turnId,
616
700
  });
617
- return;
618
- }
619
- if (settled.status !== 'active' && settled.status !== 'waiting') {
620
- lane.intent = undefined;
701
+ if (settled.status === 'waiting') {
702
+ lane.consecutiveWaits++;
703
+ return;
704
+ }
621
705
  this.resetWaitingBackoff(lane);
622
- const taskKeys = await this.taskGatePolicy.listActionable(lane.sessionId);
623
- this.taskGatePolicy.record({
624
- sessionId: lane.sessionId,
625
- turnId,
626
- goalId: goal.id,
627
- decision: 'goal_stopped',
628
- taskKeys,
629
- });
630
- return;
631
- }
632
- lane.intent = {
633
- checkpoint: goalCheckpoint(settled),
634
- controlLease,
635
- triggeringTurnId: turnId,
636
- evaluation,
637
- };
638
- const pendingPrompt = truncateGoalText(buildContinuationPrompt(settled, evaluation, undefined), GOAL_PENDING_PROMPT_TEXT_LIMIT);
639
- await this.deps.durability.recordPendingContinuation({
640
- checkpoint: lane.intent.checkpoint,
641
- controlLease,
642
- prompt: pendingPrompt,
643
- triggeringTurnId: turnId,
644
706
  });
645
- if (settled.status === 'waiting') {
646
- lane.consecutiveWaits++;
647
- return;
648
- }
649
- this.resetWaitingBackoff(lane);
707
+ if (gated)
708
+ await this.deps.eventWait.settleCompleted(lane.sessionId, turnId, controlLease);
650
709
  }
651
710
  async tryAdmitIntent(lane, intent) {
652
711
  if (this.handoffHeld ||
@@ -655,6 +714,11 @@ export class GoalContinuationCoordinator {
655
714
  lane.intent !== intent) {
656
715
  return;
657
716
  }
717
+ if (this.deps.eventWait?.isGated(lane.sessionId) && !intent.eventWait) {
718
+ lane.intent = undefined;
719
+ this.clearWaitingTimer(lane);
720
+ return;
721
+ }
658
722
  if (!this.ownedGoal(lane, intent)) {
659
723
  lane.intent = undefined;
660
724
  return;
@@ -671,10 +735,12 @@ export class GoalContinuationCoordinator {
671
735
  lane.intent = undefined;
672
736
  return;
673
737
  }
674
- const prompt = intent.recoveredPrompt
675
- ? attachTaskReminder(intent.recoveredPrompt, taskPlan.reminder)
676
- : buildContinuationPrompt(goal, intent.evaluation, taskPlan.reminder);
677
- const admission = this.deps.admitTurn(lane.sessionId, prompt, intent.checkpoint, intent.controlLease);
738
+ const prompt = intent.eventWait && intent.recoveredPrompt
739
+ ? intent.recoveredPrompt
740
+ : intent.recoveredPrompt
741
+ ? attachTaskReminder(intent.recoveredPrompt, taskPlan.reminder)
742
+ : buildContinuationPrompt(goal, intent.evaluation, taskPlan.reminder);
743
+ const admission = this.deps.admitTurn(lane.sessionId, prompt, intent.checkpoint, intent.controlLease, intent.eventWait);
678
744
  if (admission.kind === 'busy') {
679
745
  this.watchBusyLane(lane, admission.whenIdle);
680
746
  return;
@@ -692,11 +758,12 @@ export class GoalContinuationCoordinator {
692
758
  controlLease: intent.controlLease,
693
759
  };
694
760
  lane.turns.set(admission.turnId, registration);
695
- await this.deps.durability.recordCurrentExecution({
696
- execution: admission.execution,
697
- checkpoint: intent.checkpoint,
698
- controlLease: intent.controlLease,
699
- });
761
+ if (!intent.eventWait)
762
+ await this.deps.durability.recordCurrentExecution({
763
+ execution: admission.execution,
764
+ checkpoint: intent.checkpoint,
765
+ controlLease: intent.controlLease,
766
+ });
700
767
  let completion;
701
768
  try {
702
769
  completion = admission.start();
@@ -710,6 +777,12 @@ export class GoalContinuationCoordinator {
710
777
  return;
711
778
  }
712
779
  void completion.then((outcome) => {
780
+ if (outcome.kind === 'deferred') {
781
+ // No Root was admitted. The durable event outbox owns the retry;
782
+ // authorization waiting must not settle or charge a work Turn.
783
+ this.consumeTurnRegistration(registration);
784
+ return;
785
+ }
713
786
  void this.settleRegisteredTurn(registration, outcome).catch(() => undefined);
714
787
  }, (error) => {
715
788
  void this.settleRegisteredTurn(registration, {
@@ -750,7 +823,11 @@ export class GoalContinuationCoordinator {
750
823
  return this.deps.goalManager.get(lane.sessionId);
751
824
  }
752
825
  scheduleWaitingRetry(lane, goal) {
753
- if (this.handoffHeld || !this.isCurrent(lane) || lane.waitingTimer || !lane.intent)
826
+ if (this.handoffHeld ||
827
+ !this.isCurrent(lane) ||
828
+ lane.waitingTimer ||
829
+ !lane.intent ||
830
+ this.deps.eventWait?.isGated(lane.sessionId))
754
831
  return;
755
832
  if (!this.deps.goalManager.matches(lane.sessionId, lane.intent.checkpoint)) {
756
833
  lane.intent = undefined;
@@ -761,25 +838,26 @@ export class GoalContinuationCoordinator {
761
838
  const delayMs = waitBackoffMs(lane.consecutiveWaits);
762
839
  const handle = this.scheduler.setTimeout(() => {
763
840
  lane.waitingTimer = undefined;
764
- if (!this.isCurrent(lane))
765
- return;
766
- if (lane.queue.length > 0) {
767
- this.scheduleDrain(lane);
768
- return;
769
- }
770
- const woken = this.deps.goalManager.wakeWaiting(lane.sessionId, checkpoint);
771
- if (!woken || !lane.intent)
772
- return;
773
- lane.intent = { ...lane.intent, checkpoint: goalCheckpoint(woken) };
774
- void this.deps.durability
775
- .recordPendingContinuation({
776
- checkpoint: lane.intent.checkpoint,
777
- controlLease: lane.intent.controlLease,
778
- prompt: lane.intent.recoveredPrompt ??
779
- buildContinuationPrompt(woken, lane.intent.evaluation, undefined),
780
- ...(lane.intent.triggeringTurnId
781
- ? { triggeringTurnId: lane.intent.triggeringTurnId }
782
- : {}),
841
+ void this.commitGoalMutation(async (durability) => {
842
+ if (!this.isCurrent(lane) || this.deps.eventWait?.isGated(lane.sessionId))
843
+ return;
844
+ if (lane.queue.length > 0) {
845
+ this.scheduleDrain(lane);
846
+ return;
847
+ }
848
+ const woken = this.deps.goalManager.wakeWaiting(lane.sessionId, checkpoint);
849
+ if (!woken || !lane.intent)
850
+ return;
851
+ lane.intent = { ...lane.intent, checkpoint: goalCheckpoint(woken) };
852
+ await durability.recordPendingContinuation({
853
+ checkpoint: lane.intent.checkpoint,
854
+ controlLease: lane.intent.controlLease,
855
+ prompt: lane.intent.recoveredPrompt ??
856
+ buildContinuationPrompt(woken, lane.intent.evaluation, undefined),
857
+ ...(lane.intent.triggeringTurnId
858
+ ? { triggeringTurnId: lane.intent.triggeringTurnId }
859
+ : {}),
860
+ });
783
861
  })
784
862
  .then(() => this.deps.durability.flush(lane.sessionId))
785
863
  .then(() => this.scheduleDrain(lane))
@@ -184,6 +184,14 @@ export class GoalManager {
184
184
  controlLease: Object.freeze({ ...controlLease }),
185
185
  });
186
186
  }
187
+ adoptAuthority(goal, controlLease) {
188
+ if (goal.id !== controlLease.goalId)
189
+ throw new Error('Invalid Goal authority');
190
+ this.goals.set(goal.sessionId, {
191
+ state: Object.freeze({ ...goal }),
192
+ controlLease: Object.freeze({ ...controlLease }),
193
+ });
194
+ }
187
195
  matchesControlLease(sessionId, lease) {
188
196
  return sameGoalControlLease(this.goals.get(sessionId)?.controlLease, lease);
189
197
  }
@@ -214,9 +214,8 @@ export function canReplayHistoryCompactCheckpointForModel(checkpoint, connection
214
214
  }
215
215
  /** Whether this model's configured compactor can roll forward from this checkpoint value. */
216
216
  export function canContinueHistoryCompactCheckpointForModel(checkpoint, connection, connectionId, modelId) {
217
- if (isTextHistoryCompactCheckpoint(checkpoint)) {
218
- return connection.providerType !== 'openai-codex';
219
- }
217
+ // Portable text is ordinary model context for both replay and compaction.
218
+ // Only opaque provider state needs a matching route.
220
219
  return canReplayHistoryCompactCheckpointForModel(checkpoint, connection, connectionId, modelId);
221
220
  }
222
221
  export function historyCompactCheckpointToRuntimeEvent(checkpoint) {
@@ -330,6 +329,27 @@ export function canReplaceHistoryCompactCheckpoint(current, candidate) {
330
329
  (!current.source || sameHistoryCompactSourceCoverage(current.source, candidate.source)));
331
330
  }
332
331
  export function matchHistoryCompactCheckpointPrefix(checkpoint, events) {
332
+ const match = matchHistoryCompactCheckpointPrefixExactly(checkpoint, events);
333
+ if (match.reason === undefined ||
334
+ match.reason === 'invalid_checkpoint' ||
335
+ checkpoint.source?.policyVersion !== 'maka.compactable_runtime_event_projection.v3')
336
+ return match;
337
+ // v3 checkpoints written before #6263 did not count encrypted-only thinking.
338
+ // Locate that sealed boundary by identity, then verify the historical source
339
+ // exactly. Never trim the successor tail using the historical event count.
340
+ const throughIndex = events.findIndex((event) => event.id === checkpoint.coverage.through.runtimeEventId);
341
+ if (throughIndex < 0)
342
+ return match;
343
+ const prefix = events.slice(0, throughIndex + 1);
344
+ const historical = prefix.filter((event) => event.content?.kind !== 'thinking' || event.content.text.length > 0);
345
+ if (historical.length === prefix.length)
346
+ return match;
347
+ const historicalMatch = matchHistoryCompactCheckpointPrefixExactly(checkpoint, historical);
348
+ return historicalMatch.reason === undefined
349
+ ? { ...historicalMatch, successorRuntimeEvents: events.slice(throughIndex + 1) }
350
+ : match;
351
+ }
352
+ function matchHistoryCompactCheckpointPrefixExactly(checkpoint, events) {
333
353
  if (!validateHistoryCompactCheckpointShape(checkpoint)) {
334
354
  return {
335
355
  coveredEventCount: 0,
@@ -543,7 +563,17 @@ function effectiveDigestEvent(event) {
543
563
  }
544
564
  /** True when the event carries model-visible content the compact projection counts. */
545
565
  export function isHistoryCompactContentEvent(event) {
546
- return event.modelVisibility !== 'hidden' && estimateRuntimeEventChars(event) > 0;
566
+ if (event.modelVisibility === 'hidden')
567
+ return false;
568
+ // A Responses reasoning item can carry only encrypted content. Text sizing
569
+ // does not decide whether that payload exists; route admission still runs
570
+ // when the compacted history is materialized for the selected model.
571
+ if (event.content?.kind === 'thinking') {
572
+ const openai = event.content.providerOptions?.openai;
573
+ if (nonEmpty(openai?.itemId) && nonEmpty(openai?.reasoningEncryptedContent))
574
+ return true;
575
+ }
576
+ return estimateRuntimeEventChars(event) > 0;
547
577
  }
548
578
  function validHistoryCompactProviderState(value) {
549
579
  if (!value || typeof value !== 'object')
@@ -180,6 +180,13 @@ export async function planHistoryCompaction(input) {
180
180
  if (!boundary.ok || !hasSafeCoverage)
181
181
  return noSafeSpan();
182
182
  const coveredRuntimeEvents = input.orderedEvents.slice(0, boundary.coveredCount);
183
+ // The live context is reattached after a fold. Summarizing just that
184
+ // metadata and the pinned user anchor cannot free useful history.
185
+ if (phase === 'mid_turn' &&
186
+ !coveredRuntimeEvents.some((event) => event.id !== input.headAnchor?.runtimeEventId &&
187
+ !(event.content?.kind === 'text' && event.content.runtimeContextName !== undefined))) {
188
+ return noSafeSpan();
189
+ }
183
190
  const tailRuntimeEvents = input.orderedEvents.slice(boundary.coveredCount);
184
191
  // One transition view per pass: the same loaded snapshot judges the
185
192
  // previous checkpoint's currency and produces the effective view the
@@ -95,7 +95,6 @@ export function buildMemoryExtractionTriggerTools(input) {
95
95
  description: 'Use only when the user explicitly asks you to remember long-term information. It stores the requested memory and returns exactly what was saved.',
96
96
  parameters: noArguments,
97
97
  executionSemantics: 'exclusive_step',
98
- recoveryMode: 'idempotent',
99
98
  impl: async (_args, context) => {
100
99
  const gate = await input.capabilities.gate();
101
100
  if (!gate.allowed)
@@ -117,7 +116,6 @@ export function buildMemoryExtractionTriggerTools(input) {
117
116
  name: MEMORY_EXTRACT_TOOL_NAME,
118
117
  description: 'Use when the conversation contains durable long-term information worth preserving and the user did not explicitly ask to remember it. The extraction runs after this turn.',
119
118
  parameters: noArguments,
120
- recoveryMode: 'idempotent',
121
119
  impl: async (_args, context) => {
122
120
  const gate = await input.capabilities.gate();
123
121
  if (!gate.allowed)
@@ -337,12 +337,13 @@ function claudeThinkingOptions(modelId, level) {
337
337
  * those paths an omitted parameter already means no extended thinking, while
338
338
  * the lowest effort would switch adaptive thinking on. That holds for Claude,
339
339
  * not for every Anthropic Messages route: Kimi's K3 and kimi-for-coding think
340
- * by default when no level is sent.
340
+ * by default when no level is sent. K3 can declare an explicit `none` effort;
341
+ * when it does, the provider builder maps `'off'` to disabled thinking.
341
342
  *
342
- * Everywhere else a dropped `'off'` omits the effort parameter, and the
343
- * provider then runs its default reasoning (medium on GPT-5, GPT-6 and o3,
344
- * dynamic on Gemini 3). So this returns the model's lowest declared level
345
- * instead, which the wire builders send explicitly.
343
+ * When a model declares effort levels but no `none`, a dropped `'off'` omits
344
+ * the effort parameter and the provider runs its default reasoning (medium on
345
+ * GPT-5, GPT-6 and o3, dynamic on Gemini 3). So this returns the model's
346
+ * lowest declared level instead, which the wire builders send explicitly.
346
347
  */
347
348
  export function leastReasoningThinkingLevel(connection, modelId, runtime = resolveModelRuntime(connection, modelId)) {
348
349
  const variants = thinkingVariantsForConnection(connection, modelId);
@@ -376,8 +377,18 @@ function buildThinkingProviderOptions(connection, modelId, thinkingLevel, runtim
376
377
  }
377
378
  return buildFamilyWire(connection, modelId, level, thinkingOptions, runtime);
378
379
  case 'kimi-coding-plan': {
379
- if (!level || level === 'off' || level === 'on')
380
+ if (!level || level === 'on')
380
381
  return {};
382
+ if (level === 'off') {
383
+ // A refreshed Kimi Code catalog may declare `none`. Omitting the
384
+ // control leaves K3 at its default reasoning level, so send the
385
+ // provider's explicit disabled-thinking wire when that choice exists.
386
+ if (!thinkingOptions?.efforts?.includes('none'))
387
+ return {};
388
+ return runtime.wire === 'openai-chat'
389
+ ? { kimiCodingPlan: { reasoningEffort: 'none' } }
390
+ : { anthropic: { thinking: { type: 'disabled' } } };
391
+ }
381
392
  if (runtime.wire === 'openai-chat') {
382
393
  // The kimiCodingPlan provider-options namespace is the
383
394
  // openai-compatible adapter name; ai-sdk resolves its camelCase
@@ -418,6 +429,15 @@ function buildThinkingProviderOptions(connection, modelId, thinkingLevel, runtim
418
429
  if (level === 'off' && thinkingOptions?.offBehavior === 'anthropic-thinking-disabled') {
419
430
  reasoning = { thinking: { type: 'disabled' } };
420
431
  }
432
+ else if ((connection.providerType === 'MiniMax' || connection.providerType === 'MiniMax-cn') &&
433
+ (modelId === 'MiniMax-M3.1-Flash' || (modelId === 'MiniMax-M3' && level === 'on'))) {
434
+ reasoning = {
435
+ thinking: { type: 'adaptive' },
436
+ ...(modelId === 'MiniMax-M3.1-Flash'
437
+ ? { effort: level && level !== 'off' && level !== 'on' ? level : 'max' }
438
+ : {}),
439
+ };
440
+ }
421
441
  else if (summarizedThinking) {
422
442
  reasoning = summarizedThinking;
423
443
  }
@@ -550,9 +550,10 @@ function toModelInfo(model) {
550
550
  assertOptionalArray(model.input_modalities, 'model input_modalities');
551
551
  assertOptionalArray(model.output_modalities, 'model output_modalities');
552
552
  assertOptionalArray(model.tags, 'model tags');
553
+ assertOptionalArray(model.supported_features, 'model supported_features');
553
554
  const providers = providerObjectArray(model.providers, 'model providers');
554
555
  const contextWindow = providerTokenLimit(model.context_length) ?? providerTokenLimit(model.context_window);
555
- const maxOutputTokens = providerTokenLimit(model.max_tokens);
556
+ const maxOutputTokens = providerTokenLimit(model.max_output_length) ?? providerTokenLimit(model.max_tokens);
556
557
  const capabilities = {};
557
558
  if (model.input_modalities?.includes('image'))
558
559
  capabilities.vision = true;
@@ -568,6 +569,9 @@ function toModelInfo(model) {
568
569
  capabilities.reasoning = true;
569
570
  if (model.tags?.includes('tool-use'))
570
571
  capabilities.functionCalling = true;
572
+ if (model.supported_features) {
573
+ capabilities.functionCalling = model.supported_features.includes('tools');
574
+ }
571
575
  // `output_modalities` was validated above and then dropped, so a relay that
572
576
  // advertised an image-only model handed back a row indistinguishable from a
573
577
  // chat model's. Declared output that names modalities but not text is the
@@ -593,6 +597,9 @@ function toModelInfo(model) {
593
597
  ...(model.display_name || model.name ? { displayName: model.display_name ?? model.name } : {}),
594
598
  ...(contextWindow === undefined ? {} : { contextWindow }),
595
599
  ...(maxOutputTokens === undefined ? {} : { maxOutputTokens }),
600
+ ...(model.supported_features
601
+ ? { structuredOutput: model.supported_features.includes('structured_outputs') }
602
+ : {}),
596
603
  ...(Object.keys(capabilities).length ? { capabilities } : {}),
597
604
  };
598
605
  }