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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (418) hide show
  1. package/DISCLAIMER-WIP +1 -1
  2. package/LICENSE +15 -11
  3. package/README.md +173 -1
  4. package/README.zh-CN.md +156 -0
  5. package/THIRD_PARTY_NOTICES.txt +12 -12
  6. package/dist/cli-core.js +1 -0
  7. package/dist/pi-goal.js +13 -0
  8. package/dist/pi-tui-runner.js +44 -1
  9. package/dist/run-command-core.js +256 -48
  10. package/dist/run-session-command.js +534 -0
  11. package/dist/run-session-result.js +38 -0
  12. package/dist/run-turn-outcome.js +174 -0
  13. package/dist/runtime-host-cli.js +32 -17
  14. package/dist/runtime-host-run-command.js +53 -165
  15. package/dist/runtime-host-run-mcp.js +3 -0
  16. package/dist/runtime-host-session-channel.js +3 -1
  17. package/dist/runtime-host-session-driver.js +5 -0
  18. package/dist/runtime-host-setup-command.js +114 -7
  19. package/dist/tui-copy-catalog.js +24 -0
  20. package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
  21. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/docs/docs/api/Client.md +2 -0
  22. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/core/connect.js +10 -4
  23. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/core/symbols.js +1 -0
  24. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/agent.js +6 -2
  25. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client-h1.js +0 -2
  26. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client-h2.js +0 -4
  27. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client.js +3 -2
  28. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/dispatcher-base.js +12 -0
  29. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/cache-handler.js +48 -0
  30. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/deduplication-handler.js +57 -13
  31. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/redirect-handler.js +8 -1
  32. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/interceptor/decompress.js +15 -5
  33. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/index.js +3 -1
  34. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/parse.js +138 -137
  35. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/util.js +21 -2
  36. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/eventsource/eventsource-stream.js +90 -9
  37. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/eventsource/eventsource.js +4 -1
  38. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/fetch/index.js +3 -3
  39. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/infra/index.js +14 -0
  40. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
  41. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/websocket/receiver.js +13 -0
  42. package/node_modules/@ai-sdk/provider-utils/node_modules/undici/package.json +1 -1
  43. package/node_modules/@maka/acp-executor-plugin/dist/acp-catalog-store.js +87 -0
  44. package/node_modules/@maka/acp-executor-plugin/dist/acp-catalog.js +98 -21
  45. package/node_modules/@maka/acp-executor-plugin/dist/index.js +90 -14
  46. package/node_modules/@maka/acp-executor-plugin/dist/plugin.mjs +3997 -56
  47. package/node_modules/@maka/core/dist/assistant-turn-ids.js +34 -0
  48. package/node_modules/@maka/core/dist/bot-chat-settings.js +10 -1
  49. package/node_modules/@maka/core/dist/event-wait-delivery.js +67 -0
  50. package/node_modules/@maka/core/dist/event-wait.js +75 -10
  51. package/node_modules/@maka/core/dist/executor-catalog.js +3 -1
  52. package/node_modules/@maka/core/dist/goal.js +54 -2
  53. package/node_modules/@maka/core/dist/model-catalog.js +19 -1
  54. package/node_modules/@maka/core/dist/model-metadata.generated.js +4 -14
  55. package/node_modules/@maka/core/dist/model-metadata.js +42 -1
  56. package/node_modules/@maka/core/dist/models-dev-projection.js +32 -1
  57. package/node_modules/@maka/core/dist/provider-registry.js +16 -2
  58. package/node_modules/@maka/core/dist/runtime-event-store.js +0 -1
  59. package/node_modules/@maka/core/dist/runtime-event.js +24 -2
  60. package/node_modules/@maka/core/dist/runtime-invocation.js +10 -0
  61. package/node_modules/@maka/core/dist/session-checkin.js +31 -0
  62. package/node_modules/@maka/core/dist/tool-ledger-scanner.js +1 -9
  63. package/node_modules/@maka/core/dist/tool-recovery-bundle.js +1 -14
  64. package/node_modules/@maka/core/dist/turn-origin.js +14 -2
  65. package/node_modules/@maka/core/dist/usage-stats/types.js +1 -0
  66. package/node_modules/@maka/core/package.json +3 -0
  67. package/node_modules/@maka/eval/node_modules/undici/README.md +25 -3
  68. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
  69. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Client.md +11 -6
  70. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
  71. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Errors.md +76 -1
  72. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
  73. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
  74. package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
  75. package/node_modules/@maka/eval/node_modules/undici/docs/docs/index.md +12 -12
  76. package/node_modules/@maka/eval/node_modules/undici/docs/docs/type-map.json +66 -66
  77. package/node_modules/@maka/eval/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
  78. package/node_modules/@maka/eval/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
  79. package/node_modules/@maka/eval/node_modules/undici/lib/core/connect.js +10 -4
  80. package/node_modules/@maka/eval/node_modules/undici/lib/core/constants.js +12 -1
  81. package/node_modules/@maka/eval/node_modules/undici/lib/core/errors.js +38 -1
  82. package/node_modules/@maka/eval/node_modules/undici/lib/core/request.js +16 -1
  83. package/node_modules/@maka/eval/node_modules/undici/lib/core/symbols.js +2 -0
  84. package/node_modules/@maka/eval/node_modules/undici/lib/core/util.js +26 -1
  85. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/agent.js +6 -2
  86. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
  87. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
  88. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client.js +4 -1
  89. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
  90. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
  91. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
  92. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
  93. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/pool.js +11 -8
  94. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
  95. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
  96. package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
  97. package/node_modules/@maka/eval/node_modules/undici/lib/handler/cache-handler.js +153 -15
  98. package/node_modules/@maka/eval/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
  99. package/node_modules/@maka/eval/node_modules/undici/lib/handler/redirect-handler.js +28 -8
  100. package/node_modules/@maka/eval/node_modules/undici/lib/handler/retry-handler.js +44 -11
  101. package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/cache.js +11 -3
  102. package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/decompress.js +22 -9
  103. package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/dns.js +11 -0
  104. package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/response-error.js +72 -28
  105. package/node_modules/@maka/eval/node_modules/undici/lib/milo/LICENSE.md +7 -0
  106. package/node_modules/@maka/eval/node_modules/undici/lib/milo/no-simd.js +1002 -0
  107. package/node_modules/@maka/eval/node_modules/undici/lib/milo/simd.js +1002 -0
  108. package/node_modules/@maka/eval/node_modules/undici/lib/mock/mock-agent.js +11 -0
  109. package/node_modules/@maka/eval/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
  110. package/node_modules/@maka/eval/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
  111. package/node_modules/@maka/eval/node_modules/undici/lib/util/cache.js +11 -5
  112. package/node_modules/@maka/eval/node_modules/undici/lib/web/cookies/util.js +19 -2
  113. package/node_modules/@maka/eval/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
  114. package/node_modules/@maka/eval/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
  115. package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/body.js +47 -38
  116. package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
  117. package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/headers.js +2 -2
  118. package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/index.js +8 -4
  119. package/node_modules/@maka/eval/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
  120. package/node_modules/@maka/eval/node_modules/undici/lib/web/websocket/receiver.js +25 -4
  121. package/node_modules/@maka/eval/node_modules/undici/package.json +9 -7
  122. package/node_modules/@maka/mcp/package.json +1 -1
  123. package/node_modules/@maka/runtime/dist/agent-run.js +5 -1
  124. package/node_modules/@maka/runtime/dist/agent-swarm-status-tool.js +0 -1
  125. package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +29 -15
  126. package/node_modules/@maka/runtime/dist/ai-sdk-message-projection.js +10 -1
  127. package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +125 -131
  128. package/node_modules/@maka/runtime/dist/bots/bot-registry.js +19 -3
  129. package/node_modules/@maka/runtime/dist/bots/feishu-bridge.js +178 -6
  130. package/node_modules/@maka/runtime/dist/bots/wechat-bridge.js +163 -9
  131. package/node_modules/@maka/runtime/dist/context-budget-policy.js +9 -2
  132. package/node_modules/@maka/runtime/dist/event-wait-tool.js +69 -0
  133. package/node_modules/@maka/runtime/dist/goal-continuation.js +195 -117
  134. package/node_modules/@maka/runtime/dist/goal-state.js +8 -0
  135. package/node_modules/@maka/runtime/dist/history-compact-checkpoint.js +34 -4
  136. package/node_modules/@maka/runtime/dist/history-compaction.js +7 -0
  137. package/node_modules/@maka/runtime/dist/memory-extraction.js +0 -2
  138. package/node_modules/@maka/runtime/dist/model-factory.js +26 -6
  139. package/node_modules/@maka/runtime/dist/model-fetcher.js +8 -1
  140. package/node_modules/@maka/runtime/dist/model-history.js +16 -3
  141. package/node_modules/@maka/runtime/dist/openai-codex-history-compactor.js +15 -5
  142. package/node_modules/@maka/runtime/dist/plan-tools.js +0 -3
  143. package/node_modules/@maka/runtime/dist/plugin-executor-backend.js +49 -2
  144. package/node_modules/@maka/runtime/dist/plugin-executor-service.js +12 -3
  145. package/node_modules/@maka/runtime/dist/provider-error-classification.js +2 -0
  146. package/node_modules/@maka/runtime/dist/recovery-resolver.js +2 -1
  147. package/node_modules/@maka/runtime/dist/runtime-context.js +53 -0
  148. package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +3 -0
  149. package/node_modules/@maka/runtime/dist/sandbox-boundary-path.js +79 -2
  150. package/node_modules/@maka/runtime/dist/session-checkin.js +331 -0
  151. package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +7 -0
  152. package/node_modules/@maka/runtime/dist/session-manager.js +5 -1
  153. package/node_modules/@maka/runtime/dist/shell-run-manager.js +34 -0
  154. package/node_modules/@maka/runtime/dist/stream-graph-supervisor-tools.js +0 -3
  155. package/node_modules/@maka/runtime/dist/telemetry/builtin-pricing.js +21 -2
  156. package/node_modules/@maka/runtime/dist/tool-runtime.js +11 -2
  157. package/node_modules/@maka/runtime/dist/workers/filesystem-worker.mjs +50 -1
  158. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/docs/docs/api/Client.md +2 -0
  159. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/core/connect.js +10 -4
  160. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/core/symbols.js +1 -0
  161. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/agent.js +6 -2
  162. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client-h1.js +0 -2
  163. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client-h2.js +0 -4
  164. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client.js +3 -2
  165. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/dispatcher-base.js +12 -0
  166. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/cache-handler.js +48 -0
  167. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/deduplication-handler.js +57 -13
  168. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/redirect-handler.js +8 -1
  169. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/interceptor/decompress.js +15 -5
  170. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/index.js +3 -1
  171. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/parse.js +138 -137
  172. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/util.js +21 -2
  173. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/eventsource/eventsource-stream.js +90 -9
  174. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/eventsource/eventsource.js +4 -1
  175. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/fetch/index.js +3 -3
  176. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/infra/index.js +14 -0
  177. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
  178. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/websocket/receiver.js +13 -0
  179. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/package.json +1 -1
  180. package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/package.json +1 -1
  181. package/node_modules/@maka/runtime/node_modules/undici/README.md +25 -3
  182. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
  183. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Client.md +11 -6
  184. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
  185. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Errors.md +76 -1
  186. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
  187. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
  188. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
  189. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/index.md +12 -12
  190. package/node_modules/@maka/runtime/node_modules/undici/docs/docs/type-map.json +66 -66
  191. package/node_modules/@maka/runtime/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
  192. package/node_modules/@maka/runtime/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
  193. package/node_modules/@maka/runtime/node_modules/undici/lib/core/connect.js +10 -4
  194. package/node_modules/@maka/runtime/node_modules/undici/lib/core/constants.js +12 -1
  195. package/node_modules/@maka/runtime/node_modules/undici/lib/core/errors.js +38 -1
  196. package/node_modules/@maka/runtime/node_modules/undici/lib/core/request.js +16 -1
  197. package/node_modules/@maka/runtime/node_modules/undici/lib/core/symbols.js +2 -0
  198. package/node_modules/@maka/runtime/node_modules/undici/lib/core/util.js +26 -1
  199. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/agent.js +6 -2
  200. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
  201. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
  202. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client.js +4 -1
  203. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
  204. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
  205. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
  206. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
  207. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/pool.js +11 -8
  208. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
  209. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
  210. package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
  211. package/node_modules/@maka/runtime/node_modules/undici/lib/handler/cache-handler.js +153 -15
  212. package/node_modules/@maka/runtime/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
  213. package/node_modules/@maka/runtime/node_modules/undici/lib/handler/redirect-handler.js +28 -8
  214. package/node_modules/@maka/runtime/node_modules/undici/lib/handler/retry-handler.js +44 -11
  215. package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/cache.js +11 -3
  216. package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/decompress.js +22 -9
  217. package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/dns.js +11 -0
  218. package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/response-error.js +72 -28
  219. package/node_modules/@maka/runtime/node_modules/undici/lib/milo/LICENSE.md +7 -0
  220. package/node_modules/@maka/runtime/node_modules/undici/lib/milo/no-simd.js +1002 -0
  221. package/node_modules/@maka/runtime/node_modules/undici/lib/milo/simd.js +1002 -0
  222. package/node_modules/@maka/runtime/node_modules/undici/lib/mock/mock-agent.js +11 -0
  223. package/node_modules/@maka/runtime/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
  224. package/node_modules/@maka/runtime/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
  225. package/node_modules/@maka/runtime/node_modules/undici/lib/util/cache.js +11 -5
  226. package/node_modules/@maka/runtime/node_modules/undici/lib/web/cookies/util.js +19 -2
  227. package/node_modules/@maka/runtime/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
  228. package/node_modules/@maka/runtime/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
  229. package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/body.js +47 -38
  230. package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
  231. package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/headers.js +2 -2
  232. package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/index.js +8 -4
  233. package/node_modules/@maka/runtime/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
  234. package/node_modules/@maka/runtime/node_modules/undici/lib/web/websocket/receiver.js +25 -4
  235. package/node_modules/@maka/runtime/node_modules/undici/package.json +9 -7
  236. package/node_modules/@maka/runtime/package.json +3 -0
  237. package/node_modules/@maka/runtime-host/dist/assistant/bot/bridge.js +8 -0
  238. package/node_modules/@maka/runtime-host/dist/assistant/bot/capabilities.js +1 -0
  239. package/node_modules/@maka/runtime-host/dist/assistant/bot/controller.js +92 -22
  240. package/node_modules/@maka/runtime-host/dist/assistant/bot/host.js +11 -2
  241. package/node_modules/@maka/runtime-host/dist/assistant/bot/store.js +71 -2
  242. package/node_modules/@maka/runtime-host/dist/assistant/bot/turn-ids.js +38 -0
  243. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/assistant.js +7 -0
  244. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/controller.js +193 -32
  245. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/discovery-capabilities.js +69 -0
  246. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/host.js +15 -28
  247. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/notebook.js +286 -0
  248. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/prompt.js +31 -6
  249. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/store.js +18 -1
  250. package/node_modules/@maka/runtime-host/dist/assistant/memory-network/controller.js +203 -71
  251. package/node_modules/@maka/runtime-host/dist/assistant/memory-network/host.js +21 -5
  252. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition-observer.js +94 -0
  253. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition-store.js +253 -0
  254. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition.js +133 -0
  255. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/controller.js +27 -14
  256. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/delegation.js +37 -5
  257. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/delivery.js +1 -1
  258. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/host.js +16 -2
  259. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/matter.js +13 -0
  260. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/prompt.js +7 -5
  261. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/review.js +68 -14
  262. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/settlement-context.js +126 -0
  263. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/store.js +92 -6
  264. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/tools.js +93 -23
  265. package/node_modules/@maka/runtime-host/dist/assistant/service.js +72 -16
  266. package/node_modules/@maka/runtime-host/dist/client/host-profile.js +30 -1
  267. package/node_modules/@maka/runtime-host/dist/client/ssh-operator-activation.js +9 -2
  268. package/node_modules/@maka/runtime-host/dist/protocol/goal.js +119 -1
  269. package/node_modules/@maka/runtime-host/dist/protocol/index.js +10 -3
  270. package/node_modules/@maka/runtime-host/dist/protocol/operations.js +8 -1
  271. package/node_modules/@maka/runtime-host/dist/protocol/personal-assistant.js +1 -0
  272. package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +7 -1
  273. package/node_modules/@maka/runtime-host/dist/protocol/session-checkin.js +133 -0
  274. package/node_modules/@maka/runtime-host/dist/server/agent-settings-tools.js +0 -1
  275. package/node_modules/@maka/runtime-host/dist/server/canonical-session-projection.js +3 -2
  276. package/node_modules/@maka/runtime-host/dist/server/event-wait-manager.js +151 -20
  277. package/node_modules/@maka/runtime-host/dist/server/event-wait-observation-store.js +19 -0
  278. package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +127 -11
  279. package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +47 -3
  280. package/node_modules/@maka/runtime-host/dist/server/execution-model-composition.js +11 -0
  281. package/node_modules/@maka/runtime-host/dist/server/external-session-coordinator.js +5 -2
  282. package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +343 -53
  283. package/node_modules/@maka/runtime-host/dist/server/goal-event-waits.js +457 -0
  284. package/node_modules/@maka/runtime-host/dist/server/goal-execution-coordinator.js +23 -6
  285. package/node_modules/@maka/runtime-host/dist/server/goal-projection.js +24 -3
  286. package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +5 -1
  287. package/node_modules/@maka/runtime-host/dist/server/index.js +2 -0
  288. package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +44 -2
  289. package/node_modules/@maka/runtime-host/dist/server/personal-assistant-workspace.js +78 -0
  290. package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +8 -0
  291. package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +73 -3
  292. package/node_modules/@maka/runtime-host/dist/server/session-checkin.js +257 -0
  293. package/node_modules/@maka/runtime-host/dist/server/session-checkpoint-coordinator.js +282 -0
  294. package/node_modules/@maka/runtime-host/dist/server/session-checkpoint-publication.js +250 -0
  295. package/node_modules/@maka/runtime-host/dist/server/shell-run-event-wait-access.js +166 -0
  296. package/node_modules/@maka/runtime-host/dist/server/shell-run-event-wait-adapter.js +59 -0
  297. package/node_modules/@maka/runtime-host/dist/server/skill-catalog-repository.js +4 -2
  298. package/node_modules/@maka/storage/dist/agent-run-store-contract.js +14 -3
  299. package/node_modules/@maka/storage/dist/agent-run-store.js +10 -0
  300. package/node_modules/@maka/storage/dist/codex-session-adapter.js +20 -3
  301. package/node_modules/@maka/storage/dist/context-offload-snapshot.js +2 -1
  302. package/node_modules/@maka/storage/dist/event-wait-authority.js +18 -1
  303. package/node_modules/@maka/storage/dist/event-wait-bridge.js +336 -0
  304. package/node_modules/@maka/storage/dist/execution-stores.js +39 -1
  305. package/node_modules/@maka/storage/dist/external-session-images.js +131 -0
  306. package/node_modules/@maka/storage/dist/external-session-importer.js +12 -2
  307. package/node_modules/@maka/storage/dist/goal-authority.js +2 -0
  308. package/node_modules/@maka/storage/dist/local-execution-persistence.js +27 -1
  309. package/node_modules/@maka/storage/dist/operational-state-store.js +1 -1
  310. package/node_modules/@maka/storage/dist/production-session-snapshot.js +14 -6
  311. package/node_modules/@maka/storage/dist/runtime-event-persistence.js +1 -0
  312. package/node_modules/@maka/storage/dist/session-bundle-policy.js +116 -16
  313. package/node_modules/@maka/storage/dist/session-checkpoint-publication-store.js +204 -0
  314. package/node_modules/@maka/storage/dist/session-store.js +37 -8
  315. package/node_modules/@maka/storage/dist/snapshot-operation-gate.js +65 -0
  316. package/node_modules/@maka/storage/dist/sqlite-context-offload-schema.js +3 -3
  317. package/node_modules/@maka/storage/dist/sqlite-context-offload-store.js +4 -2
  318. package/node_modules/@maka/storage/dist/sqlite-event-wait-authority.js +81 -8
  319. package/node_modules/@maka/storage/dist/sqlite-event-wait-bridge.js +94 -0
  320. package/node_modules/@maka/storage/dist/sqlite-reclamation-checkpoint.js +37 -0
  321. package/node_modules/@maka/storage/dist/sqlite-runtime-schema.js +7 -8
  322. package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +38 -162
  323. package/node_modules/@maka/storage/dist/sqlite-workflow-schema.js +7 -4
  324. package/node_modules/@maka/storage/dist/tool-commit-validation.js +1 -1
  325. package/node_modules/@maka/storage/package.json +4 -0
  326. package/node_modules/@modelcontextprotocol/client/dist/index-B-4n9P0J.d.mts.map +1 -0
  327. package/node_modules/@modelcontextprotocol/client/dist/index-J2FaQ-KY.d.cts.map +1 -0
  328. package/node_modules/@modelcontextprotocol/client/dist/index.cjs +76 -22
  329. package/node_modules/@modelcontextprotocol/client/dist/index.d.cts.map +1 -1
  330. package/node_modules/@modelcontextprotocol/client/dist/index.d.mts.map +1 -1
  331. package/node_modules/@modelcontextprotocol/client/dist/index.mjs +76 -22
  332. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.cjs +1 -1
  333. package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.mjs +1 -1
  334. package/node_modules/@modelcontextprotocol/client/dist/{src-oZBjf3U1.cjs → src-DpAS0jfg.cjs} +105 -8
  335. package/node_modules/@modelcontextprotocol/client/dist/{src-xKF0PJN-.mjs → src-WCy6ifGf.mjs} +88 -9
  336. package/node_modules/@modelcontextprotocol/client/dist/stdio.cjs +1 -1
  337. package/node_modules/@modelcontextprotocol/client/dist/stdio.mjs +1 -1
  338. package/node_modules/@modelcontextprotocol/client/node_modules/@modelcontextprotocol/core/package.json +2 -2
  339. package/node_modules/@modelcontextprotocol/client/package.json +5 -5
  340. package/node_modules/fast-uri/.github/workflows/release.yml +35 -0
  341. package/node_modules/fast-uri/README.md +8 -0
  342. package/node_modules/fast-uri/index.js +98 -18
  343. package/node_modules/fast-uri/lib/utils.js +52 -0
  344. package/node_modules/fast-uri/package.json +1 -1
  345. package/node_modules/follow-redirects/index.js +10 -1
  346. package/node_modules/follow-redirects/package.json +1 -1
  347. package/node_modules/ip-address/README.md +104 -104
  348. package/node_modules/ip-address/dist/ipv4.js +7 -0
  349. package/node_modules/ip-address/dist/ipv6.js +7 -4
  350. package/node_modules/ip-address/dist/v6/constants.js +3 -0
  351. package/node_modules/ip-address/package.json +2 -1
  352. package/node_modules/undici/README.md +25 -3
  353. package/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
  354. package/node_modules/undici/docs/docs/api/Client.md +11 -6
  355. package/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
  356. package/node_modules/undici/docs/docs/api/Errors.md +76 -1
  357. package/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
  358. package/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
  359. package/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
  360. package/node_modules/undici/docs/docs/index.md +12 -12
  361. package/node_modules/undici/docs/docs/type-map.json +66 -66
  362. package/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
  363. package/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
  364. package/node_modules/undici/lib/core/connect.js +10 -4
  365. package/node_modules/undici/lib/core/constants.js +12 -1
  366. package/node_modules/undici/lib/core/errors.js +38 -1
  367. package/node_modules/undici/lib/core/request.js +16 -1
  368. package/node_modules/undici/lib/core/symbols.js +2 -0
  369. package/node_modules/undici/lib/core/util.js +26 -1
  370. package/node_modules/undici/lib/dispatcher/agent.js +6 -2
  371. package/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
  372. package/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
  373. package/node_modules/undici/lib/dispatcher/client.js +4 -1
  374. package/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
  375. package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
  376. package/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
  377. package/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
  378. package/node_modules/undici/lib/dispatcher/pool.js +11 -8
  379. package/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
  380. package/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
  381. package/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
  382. package/node_modules/undici/lib/handler/cache-handler.js +153 -15
  383. package/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
  384. package/node_modules/undici/lib/handler/redirect-handler.js +28 -8
  385. package/node_modules/undici/lib/handler/retry-handler.js +44 -11
  386. package/node_modules/undici/lib/interceptor/cache.js +11 -3
  387. package/node_modules/undici/lib/interceptor/decompress.js +22 -9
  388. package/node_modules/undici/lib/interceptor/dns.js +11 -0
  389. package/node_modules/undici/lib/interceptor/response-error.js +72 -28
  390. package/node_modules/undici/lib/milo/LICENSE.md +7 -0
  391. package/node_modules/undici/lib/milo/no-simd.js +1002 -0
  392. package/node_modules/undici/lib/milo/simd.js +1002 -0
  393. package/node_modules/undici/lib/mock/mock-agent.js +11 -0
  394. package/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
  395. package/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
  396. package/node_modules/undici/lib/util/cache.js +11 -5
  397. package/node_modules/undici/lib/web/cookies/util.js +19 -2
  398. package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
  399. package/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
  400. package/node_modules/undici/lib/web/fetch/body.js +47 -38
  401. package/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
  402. package/node_modules/undici/lib/web/fetch/headers.js +2 -2
  403. package/node_modules/undici/lib/web/fetch/index.js +8 -4
  404. package/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
  405. package/node_modules/undici/lib/web/websocket/receiver.js +25 -4
  406. package/node_modules/undici/package.json +9 -7
  407. package/node_modules/zod/package.json +1 -1
  408. package/node_modules/zod/v4/core/compile.cjs +8 -0
  409. package/node_modules/zod/v4/core/compile.js +8 -0
  410. package/node_modules/zod/v4/core/schemas.cjs +30 -0
  411. package/node_modules/zod/v4/core/schemas.js +30 -0
  412. package/node_modules/zod/v4/core/util.cjs +15 -0
  413. package/node_modules/zod/v4/core/util.js +14 -0
  414. package/node_modules/zod/v4/core/versions.cjs +1 -1
  415. package/node_modules/zod/v4/core/versions.js +1 -1
  416. package/package.json +2 -2
  417. package/node_modules/@modelcontextprotocol/client/dist/index-D_CiY-T3.d.cts.map +0 -1
  418. package/node_modules/@modelcontextprotocol/client/dist/index-D_QDtbiv.d.mts.map +0 -1
@@ -0,0 +1,166 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ import { validateToolLedgerEventLane } from '@maka/core/tool-ledger-scanner';
20
+ import { canonicalToolArgsHash } from '@maka/core/tool-args-identity';
21
+ import { parseShellRunResourceRef } from '@maka/runtime/shell-run-contract';
22
+ export const SHELL_RUN_WAIT_SOURCE = Object.freeze({
23
+ providerId: 'shell_run',
24
+ resourceType: 'background_task',
25
+ conditionType: 'terminal',
26
+ conditionVersion: 1,
27
+ });
28
+ export function validateShellRunWait(wait) {
29
+ const target = parseShellRunResourceRef(wait.resource.resourceId);
30
+ if (!target ||
31
+ wait.resource.providerId !== SHELL_RUN_WAIT_SOURCE.providerId ||
32
+ wait.resource.resourceType !== SHELL_RUN_WAIT_SOURCE.resourceType ||
33
+ wait.resource.connectionId !== null ||
34
+ wait.condition.typeId !== SHELL_RUN_WAIT_SOURCE.conditionType ||
35
+ wait.condition.version !== 1 ||
36
+ Object.keys(wait.condition.parameters).length !== 0)
37
+ throw new TypeError('Unsupported background task condition');
38
+ return target.shellRunId;
39
+ }
40
+ /** Reads the same Host's stores. Neither a reference nor the wait is an access credential. */
41
+ export class ShellRunEventWaitAccess {
42
+ shellRuns;
43
+ events;
44
+ constructor(shellRuns, events) {
45
+ this.shellRuns = shellRuns;
46
+ this.events = events;
47
+ }
48
+ async authorize(wait, signal) {
49
+ const result = await this.read(wait, signal);
50
+ return result.kind === 'allowed' ? { kind: 'allowed', context: null } : result;
51
+ }
52
+ async read(wait, signal) {
53
+ const taskId = validateShellRunWait(wait);
54
+ signal.throwIfAborted();
55
+ let task;
56
+ try {
57
+ task = await this.shellRuns.readShellRun(wait.sessionId, taskId);
58
+ }
59
+ catch (error) {
60
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
61
+ return { kind: 'revoked', reason: 'shell_run_missing' };
62
+ throw error;
63
+ }
64
+ if (task.sessionId !== wait.sessionId || task.shellRunId !== taskId || !task.sourceRunId)
65
+ return { kind: 'revoked', reason: 'shell_run_identity_invalid' };
66
+ if (task.visibility === 'user')
67
+ return { kind: 'revoked', reason: 'shell_run_access_revoked' };
68
+ const invocation = await this.events.readRunInvocation(wait.sessionId, task.sourceRunId);
69
+ if (!invocation ||
70
+ invocation.turnId !== task.sourceTurnId ||
71
+ invocation.opening.route.provenance !== 'runtime' ||
72
+ invocation.opening.route.backendKind !== 'ai-sdk')
73
+ return { kind: 'revoked', reason: 'shell_run_provenance_invalid' };
74
+ const proof = await this.events.readToolProvenanceEvents(wait.sessionId, task.sourceRunId, task.sourceToolCallId, { maxRecords: 8, maxBytes: 2 * 1024 * 1024 });
75
+ signal.throwIfAborted();
76
+ if (proof.status !== 'complete')
77
+ return { kind: 'revoked', reason: 'shell_run_provenance_unavailable' };
78
+ const facts = proof.records;
79
+ const calls = facts.filter((e) => e.content?.kind === 'function_call');
80
+ const dispatches = facts.filter((e) => e.actions?.toolDispatch);
81
+ const outcomes = facts.filter((e) => e.content?.kind === 'function_response');
82
+ const call = calls[0]?.content, dispatch = dispatches[0]?.actions?.toolDispatch, outcome = outcomes[0]?.content;
83
+ if (calls.length !== 1 ||
84
+ dispatches.length !== 1 ||
85
+ outcomes.length !== 1 ||
86
+ call?.kind !== 'function_call' ||
87
+ outcome?.kind !== 'function_response' ||
88
+ !dispatch ||
89
+ facts.some((e) => !validateToolLedgerEventLane(e).ok ||
90
+ e.partial ||
91
+ e.sessionId !== wait.sessionId ||
92
+ e.runId !== task.sourceRunId ||
93
+ e.turnId !== task.sourceTurnId ||
94
+ e.invocationId !== invocation.invocationId) ||
95
+ call.id !== task.sourceToolCallId ||
96
+ outcome.id !== call.id ||
97
+ dispatch.providerToolCallId !== call.id ||
98
+ call.name !== 'Bash' ||
99
+ outcome.name !== 'Bash' ||
100
+ dispatch.toolName !== 'Bash' ||
101
+ call.providerExecuted === true ||
102
+ outcome.providerExecuted === true ||
103
+ dispatch.protocol !== 't1_after_preflight_v1' ||
104
+ dispatch.canonicalArgsHash !== canonicalToolArgsHash('Bash', call.args) ||
105
+ outcomes[0]?.refs?.operationId !== dispatch.operationId ||
106
+ facts.indexOf(calls[0]) >= facts.indexOf(dispatches[0]) ||
107
+ facts.indexOf(dispatches[0]) >= facts.indexOf(outcomes[0]) ||
108
+ !isBackgroundCall(call.args) ||
109
+ !isTaskResult(outcome.result, wait.resource.resourceId))
110
+ return { kind: 'revoked', reason: 'shell_run_provenance_invalid' };
111
+ // Proof reads may suspend. Recheck the live resource binding after them;
112
+ // a registration-time snapshot cannot authorize a later admission.
113
+ let current;
114
+ try {
115
+ current = await this.shellRuns.readShellRun(wait.sessionId, taskId);
116
+ }
117
+ catch (error) {
118
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
119
+ return { kind: 'revoked', reason: 'shell_run_missing' };
120
+ throw error;
121
+ }
122
+ signal.throwIfAborted();
123
+ if (current.visibility === 'user')
124
+ return { kind: 'revoked', reason: 'shell_run_access_revoked' };
125
+ if (current.sessionId !== task.sessionId ||
126
+ current.shellRunId !== task.shellRunId ||
127
+ current.sourceRunId !== task.sourceRunId ||
128
+ current.sourceTurnId !== task.sourceTurnId ||
129
+ current.sourceToolCallId !== task.sourceToolCallId ||
130
+ current.startedAt !== task.startedAt)
131
+ return { kind: 'revoked', reason: 'shell_run_identity_invalid' };
132
+ task = current;
133
+ // Canonical immutable T2 retains the original outcome even after its model
134
+ // projection is archived/pruned. Never authorize from a placeholder or UI row.
135
+ const { sessionId, shellRunId, sourceRunId, sourceTurnId, sourceToolCallId, startedAt, status, completedAt, exitCode, failureMessage, } = task;
136
+ return {
137
+ kind: 'allowed',
138
+ fact: {
139
+ sessionId,
140
+ shellRunId,
141
+ sourceRunId,
142
+ sourceTurnId,
143
+ sourceToolCallId,
144
+ startedAt,
145
+ status,
146
+ ...(completedAt === undefined ? {} : { completedAt }),
147
+ ...(exitCode === undefined ? {} : { exitCode }),
148
+ ...(failureMessage === undefined ? {} : { failureMessage }),
149
+ },
150
+ };
151
+ }
152
+ }
153
+ function isBackgroundCall(value) {
154
+ return (typeof value === 'object' &&
155
+ value !== null &&
156
+ 'run_in_background' in value &&
157
+ value.run_in_background === true);
158
+ }
159
+ function isTaskResult(value, ref) {
160
+ return (typeof value === 'object' &&
161
+ value !== null &&
162
+ 'kind' in value &&
163
+ value.kind === 'shell_run' &&
164
+ 'ref' in value &&
165
+ value.ref === ref);
166
+ }
@@ -0,0 +1,59 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ import { createHash } from 'node:crypto';
20
+ import { isTerminalShellRunStatus } from '@maka/core/shell-run';
21
+ import { SHELL_RUN_WAIT_SOURCE, validateShellRunWait, } from './shell-run-event-wait-access.js';
22
+ export class ShellRunEventWaitAdapter {
23
+ access;
24
+ manager;
25
+ providerId = SHELL_RUN_WAIT_SOURCE.providerId;
26
+ resourceType = SHELL_RUN_WAIT_SOURCE.resourceType;
27
+ conditionType = SHELL_RUN_WAIT_SOURCE.conditionType;
28
+ conditionVersion = SHELL_RUN_WAIT_SOURCE.conditionVersion;
29
+ reconciliation = 'snapshot';
30
+ constructor(access, manager) {
31
+ this.access = access;
32
+ this.manager = manager;
33
+ }
34
+ validate(wait) {
35
+ validateShellRunWait(wait);
36
+ }
37
+ async read(input) {
38
+ const result = await this.access.read(input.wait, input.signal);
39
+ // The next access check cancels and pauses on confirmed revocation. A read
40
+ // racing that check must not fabricate a terminal outcome in the meantime.
41
+ if (result.kind === 'revoked')
42
+ return { kind: 'unknown', reason: result.reason };
43
+ const fact = result.fact;
44
+ if (!isTerminalShellRunStatus(fact.status))
45
+ return { kind: 'pending' };
46
+ const digest = createHash('sha256').update(JSON.stringify(fact)).digest('hex');
47
+ const receiptKey = `shell-run/terminal-v1/${fact.shellRunId}/${digest}`;
48
+ return {
49
+ kind: fact.status === 'orphaned' ? 'source_unavailable' : 'satisfied',
50
+ receiptKey,
51
+ eventKey: receiptKey,
52
+ evidenceRefs: [input.wait.resource.resourceId],
53
+ };
54
+ }
55
+ async subscribe(input, changed) {
56
+ this.validate(input.wait);
57
+ return this.manager.subscribeChanges(input.wait.sessionId, input.wait.resource.resourceId, input.signal, changed);
58
+ }
59
+ }
@@ -225,6 +225,7 @@ export class SkillCatalogRepository {
225
225
  const publicationNamespace = await readPublicationNamespace(root);
226
226
  return buildSnapshot({
227
227
  projectRoot,
228
+ workspaceSkillDirectory: join(root, 'skills'),
228
229
  scan,
229
230
  managedSourcesRoot: this.#managedSourcesRoot,
230
231
  publicationNamespace,
@@ -601,7 +602,7 @@ async function buildSnapshot(input) {
601
602
  publicationNamespace: input.publicationNamespace,
602
603
  effectiveMigration,
603
604
  }));
604
- const model = freezeModelSnapshot(revision, input.projectRoot, input.scan, effectiveMigration);
605
+ const model = freezeModelSnapshot(revision, input.projectRoot, input.workspaceSkillDirectory, input.scan, effectiveMigration);
605
606
  return Object.freeze({
606
607
  revision,
607
608
  projectRoot: input.projectRoot,
@@ -965,7 +966,7 @@ function canonicalRevisionFacts(input) {
965
966
  },
966
967
  };
967
968
  }
968
- function freezeModelSnapshot(revision, projectRoot, scan, migration) {
969
+ function freezeModelSnapshot(revision, projectRoot, workspaceSkillDirectory, scan, migration) {
969
970
  const inventory = scan.inventory.filter(hasDurableSkillIdentity).map((skill) => {
970
971
  const preference = migration === null ? undefined : getSkillRuntimePreference(migration, skill);
971
972
  const enabled = preference?.enabled ?? skill.enabled;
@@ -987,6 +988,7 @@ function freezeModelSnapshot(revision, projectRoot, scan, migration) {
987
988
  return Object.freeze({
988
989
  revision,
989
990
  projectRoot,
991
+ workspaceSkillDirectory,
990
992
  inventory: Object.freeze(inventory),
991
993
  diagnostics: Object.freeze(diagnostics),
992
994
  discoveryDiagnostics: Object.freeze(discoveryDiagnostics),
@@ -27,6 +27,7 @@ import { MAX_ATTACHMENT_BYTES, MAX_ATTACHMENT_COUNT } from '@maka/core/attachmen
27
27
  import { LATEST_CONTEXT_PROJECTION_TYPE, supersedesLatestContext, } from '@maka/core/agent-run';
28
28
  import { encodeCanonicalRuntimeEvent } from '@maka/core/canonical-runtime-event';
29
29
  import { isOrchestrationMode, isTurnOrchestrationSource, } from '@maka/core/orchestration';
30
+ import { decodeEventWaitProvenance } from '@maka/core/event-wait-delivery';
30
31
  import { validateGenericToolLedgerAppend } from '@maka/core/tool-ledger-scanner';
31
32
  export const SAFE_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;
32
33
  export const ROOT_TURN_ADMISSION_SCHEMA_VERSION = 1;
@@ -211,7 +212,7 @@ export function assertNoReservedToolLedgerFact(event) {
211
212
  if (validation.ok)
212
213
  return;
213
214
  if (validation.code === 'reserved_recovery_fact') {
214
- throw new Error('Tool recovery facts require the atomic recovery bundle writer');
215
+ throw new Error('Historical tool recovery facts are read-only');
215
216
  }
216
217
  if (validation.code === 'reserved_tool_boundary_fact') {
217
218
  throw new Error('Durable tool facts require the atomic tool boundary writer');
@@ -768,12 +769,22 @@ export function normalizeRootExecutionDescriptor(value) {
768
769
  return Object.freeze({ kind: 'legacy_automation', automationId: value.automationId });
769
770
  }
770
771
  if (value.kind === 'goal') {
771
- if (!hasExactKeys(value, ['kind', 'goalId']) ||
772
+ if (!hasExactKeys(value, [
773
+ 'kind',
774
+ 'goalId',
775
+ ...(value.eventWait === undefined ? [] : ['eventWait']),
776
+ ]) ||
772
777
  typeof value.goalId !== 'string' ||
773
778
  !isSafeId(value.goalId)) {
774
779
  throw new Error('Invalid root execution descriptor');
775
780
  }
776
- return Object.freeze({ kind: 'goal', goalId: value.goalId });
781
+ return Object.freeze({
782
+ kind: 'goal',
783
+ goalId: value.goalId,
784
+ ...(value.eventWait === undefined
785
+ ? {}
786
+ : { eventWait: decodeEventWaitProvenance(value.eventWait) }),
787
+ });
777
788
  }
778
789
  if (value.kind === 'agent_graph_supervisor_wake') {
779
790
  if (!hasExactKeys(value, ['kind', 'graphId', 'wakeId', 'attemptId']) ||
@@ -16,6 +16,8 @@
16
16
  * specific language governing permissions and limitations
17
17
  * under the License.
18
18
  */
19
+ import { admitGoalWait } from './event-wait-bridge.js';
20
+ import { readBridgeGoal, readBridgeWait, writeBridgeSnapshot, assertBridgeSession, } from './sqlite-event-wait-bridge.js';
19
21
  import { resolve } from 'node:path';
20
22
  import { isDeepStrictEqual } from 'node:util';
21
23
  import { decodeAgentRunEvent, decodeRuntimeEvent } from './execution-record-codec.js';
@@ -283,6 +285,14 @@ class SqliteAgentRunStore {
283
285
  throw new Error(`Root source message identity belongs to both ${String(proof.turn_id)} and ${admission.turnId}`);
284
286
  }
285
287
  }
288
+ if (admission.execution.kind === 'goal' && admission.execution.eventWait) {
289
+ const db = this.#lease.database;
290
+ assertBridgeSession(db, admission.sessionId);
291
+ const wait = readBridgeWait(db, admission.sessionId, admission.execution.eventWait.waitId);
292
+ if (!wait)
293
+ throw new Error('Event wait missing at admission');
294
+ writeBridgeSnapshot(db, admitGoalWait(admission, readBridgeGoal(db, admission.sessionId), wait));
295
+ }
286
296
  this.#lease.database
287
297
  .prepare(`
288
298
  INSERT INTO core_root_turn_admissions(
@@ -338,6 +338,7 @@ class CodexRolloutConverter {
338
338
  fallbackCwd;
339
339
  limits;
340
340
  messages = [];
341
+ sourceImages = [];
341
342
  failedTurnIds = new Set();
342
343
  activeTurnId;
343
344
  activeTurnIsExplicit = false;
@@ -420,11 +421,26 @@ class CodexRolloutConverter {
420
421
  if (text.length === 0)
421
422
  return;
422
423
  this.firstUserText ??= text;
424
+ const id = stringField(item, 'client_id') ??
425
+ stringField(item, 'id') ??
426
+ generatedCodexId(this.expectedSessionId, 'user', record.line);
427
+ if (Array.isArray(item?.content)) {
428
+ for (const part of item.content) {
429
+ const image = asRecord(part);
430
+ if (stringField(image, 'type')?.toLowerCase() !== 'local_image')
431
+ continue;
432
+ const path = stringField(image, 'path') ?? '';
433
+ // Source descriptors share the converted-output budget with messages.
434
+ this.convertedBytes += Buffer.byteLength(JSON.stringify({ messageId: id, path }));
435
+ if (this.convertedBytes > this.limits.maxConvertedBytes) {
436
+ throw new ExternalSessionLimitError('converted_bytes', this.limits.maxConvertedBytes, 'Codex image references exceed the converted Session limit');
437
+ }
438
+ this.sourceImages.push({ messageId: id, path });
439
+ }
440
+ }
423
441
  this.append({
424
442
  type: 'user',
425
- id: stringField(item, 'client_id') ??
426
- stringField(item, 'id') ??
427
- generatedCodexId(this.expectedSessionId, 'user', record.line),
443
+ id,
428
444
  turnId: this.ensureTurnId(record.line),
429
445
  ts: this.timestampFor(record),
430
446
  ...codexUserContent(text),
@@ -630,6 +646,7 @@ class CodexRolloutConverter {
630
646
  sourceSessionId: this.expectedSessionId,
631
647
  metadata: { name, cwd: this.metaCwd || this.fallbackCwd },
632
648
  messages: this.messages,
649
+ ...(this.sourceImages.length > 0 ? { sourceImages: this.sourceImages } : {}),
633
650
  };
634
651
  }
635
652
  timestampFor(record) {
@@ -23,7 +23,7 @@ import { dirname, join, resolve } from 'node:path';
23
23
  import { backup, DatabaseSync } from 'node:sqlite';
24
24
  import { isCanonicalStorageRef } from '@maka/core/events';
25
25
  import { discoverMarkedStorageRoot, resolveStorageRoot, runWithStorageRootLease, tryAcquireInteractiveRootOwner, } from './root-authority.js';
26
- import { migrateSqliteContextOffloadDatabase, SQLITE_CONTEXT_OFFLOAD_SCHEMA_VERSION, } from './sqlite-context-offload-schema.js';
26
+ import { migrateSqliteContextOffloadDatabase, SQLITE_CONTEXT_OFFLOAD_SCHEMA_VERSION, validateSqliteContextOffloadSchema, } from './sqlite-context-offload-schema.js';
27
27
  import { CONTEXT_OFFLOAD_DATABASE_NAME, CONTEXT_OFFLOAD_VALUES_DIRECTORY_NAME, } from './sqlite-context-offload-store.js';
28
28
  import { syncDirectoryChain, syncFile } from './stable-storage.js';
29
29
  import { SQLITE_SESSION_MESSAGE_CHUNK_MARKER } from './sqlite-session-metadata-schema.js';
@@ -187,6 +187,7 @@ export async function validateContextSnapshot(root, sessionIds) {
187
187
  if (context.prepare('PRAGMA user_version').get()?.user_version !==
188
188
  SQLITE_CONTEXT_OFFLOAD_SCHEMA_VERSION)
189
189
  throw new Error('Unsupported context snapshot schema');
190
+ validateSqliteContextOffloadSchema(context);
190
191
  if (context.prepare('PRAGMA integrity_check').get()?.integrity_check !== 'ok' ||
191
192
  context.prepare('PRAGMA foreign_key_check').get())
192
193
  throw new Error('Invalid context snapshot database');
@@ -43,6 +43,9 @@ export async function openInteractiveEventWaitAuthorityForWrite(lease, repositor
43
43
  'reserveSourceDispatch',
44
44
  'completeSourceDispatch',
45
45
  'commit',
46
+ 'registerGoalWait',
47
+ 'settleGoalWait',
48
+ 'queueGoalWait',
46
49
  'close',
47
50
  ].some((k) => typeof Reflect.get(repository, k) !== 'function')) {
48
51
  throw new TypeError('Execution persistence requires an eventWaitStore');
@@ -125,6 +128,18 @@ export async function openInteractiveEventWaitAuthorityForWrite(lease, repositor
125
128
  const normalized = normalizeEventWaitCommit(input);
126
129
  return run(() => repository.commit(normalized));
127
130
  },
131
+ registerGoalWait: (input) => {
132
+ const captured = structuredClone(input);
133
+ return run(() => repository.registerGoalWait(captured));
134
+ },
135
+ settleGoalWait: (input) => {
136
+ const captured = structuredClone(input);
137
+ return run(() => repository.settleGoalWait(captured));
138
+ },
139
+ queueGoalWait: (input) => {
140
+ const captured = structuredClone(input);
141
+ return run(() => repository.queueGoalWait(captured));
142
+ },
128
143
  close: () => (closeTask ??= (async () => {
129
144
  closed = true;
130
145
  writers.delete(writer);
@@ -215,7 +230,9 @@ export function normalizeEventWaitCommit(input) {
215
230
  };
216
231
  }
217
232
  export function validateEventWaitStatusPage(input) {
218
- exactInput(input, ['status', 'limit'], ['afterWaitId']);
233
+ exactInput(input, ['status', 'limit'], ['afterWaitId', 'deliveryOutstanding']);
234
+ if (input.deliveryOutstanding !== undefined && input.deliveryOutstanding !== true)
235
+ throw new TypeError('Invalid delivery filter');
219
236
  if (!['waiting', 'resolved', 'expired', 'cancelled'].includes(input.status))
220
237
  throw new TypeError('Invalid event wait status');
221
238
  validateEventWaitPage({