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
@@ -127,6 +127,18 @@ export function createFileSessionSnapshotWorkspacePreparer(options) {
127
127
  * unreconciled.
128
128
  */
129
129
  export async function createFileProductionSessionSnapshotService(options) {
130
+ // Retain the original adapter's stricter state/config layout contract.
131
+ await assertProductionRootsSeparate({
132
+ stateRoot: options.stateRoot,
133
+ configRoot: options.configRoot,
134
+ });
135
+ return createProductionSessionSnapshotService({
136
+ ...options,
137
+ sourceRoots: [options.stateRoot, options.configRoot],
138
+ state: createFileSessionSnapshotStatePreparer(options),
139
+ });
140
+ }
141
+ export async function createProductionSessionSnapshotService(options) {
130
142
  const session = requireProductionSessionSnapshotBinding(options.session);
131
143
  assertSessionBundleLimits(options.limits);
132
144
  const limits = Object.freeze({ ...options.limits });
@@ -138,17 +150,13 @@ export async function createFileProductionSessionSnapshotService(options) {
138
150
  });
139
151
  await stagingCleanup.recover();
140
152
  await assertProductionRootsSeparate({
141
- stateRoot: options.stateRoot,
142
- configRoot: options.configRoot,
153
+ ...Object.fromEntries(options.sourceRoots.map((root, index) => [`source${index}`, root])),
143
154
  workspaceRoot: options.workspaceRoot,
144
155
  stagingParent: stagingCleanup.stagingParent,
145
156
  cleanupStateRoot: options.cleanupStateRoot,
146
157
  });
147
158
  const stateBudgetsByStagingRoot = new Map();
148
- const fileStatePreparer = createFileSessionSnapshotStatePreparer({
149
- stateRoot: options.stateRoot,
150
- configRoot: options.configRoot,
151
- });
159
+ const fileStatePreparer = options.state;
152
160
  const state = {
153
161
  async prepareState(input) {
154
162
  const identity = await fileStatePreparer.prepareState(input);
@@ -47,6 +47,7 @@ export async function openRuntimeEventReadPersistence(input) {
47
47
  listSessionInvocationsPage: (sessionId, input) => store.listSessionInvocationsPage(sessionId, input),
48
48
  readInvocation: (sessionId, invocationId) => store.readInvocation(sessionId, invocationId),
49
49
  readRuntimeEvents: (sessionId, runId) => store.readRuntimeEvents(sessionId, runId),
50
+ readToolProvenanceEvents: (sessionId, runId, toolCallId, budget) => store.readToolProvenanceEvents(sessionId, runId, toolCallId, budget),
50
51
  readRuntimeEventsBounded: (sessionId, runId, budget) => store.readRuntimeEventsBounded(sessionId, runId, budget),
51
52
  readImmutableRuntimeEvents: (sessionId, runId) => store.readImmutableRuntimeEvents(sessionId, runId),
52
53
  readSessionRuntimeEvents: (sessionId) => store.readSessionRuntimeEvents(sessionId),
@@ -16,6 +16,7 @@
16
16
  * specific language governing permissions and limitations
17
17
  * under the License.
18
18
  */
19
+ import { decodeGoalAuthorityRecord } from '@maka/core/goal';
19
20
  import { copyFile, link, lstat, mkdir, open, readFile, readdir, realpath, rename, rm, unlink, writeFile, } from 'node:fs/promises';
20
21
  import { constants } from 'node:fs';
21
22
  import { randomUUID } from 'node:crypto';
@@ -43,7 +44,7 @@ async function withBundleArtifactWriterLock(stateRoot, lease, operation) {
43
44
  }
44
45
  import { runWithContextValueMutation } from './context-value-mutation-gate.js';
45
46
  import { withOfflineContextSnapshot, copyContextSnapshot, validateContextSnapshot, planContextSnapshotFiles, } from './context-offload-snapshot.js';
46
- import { CONTEXT_OFFLOAD_DATABASE_NAME, CONTEXT_OFFLOAD_VALUES_DIRECTORY_NAME, } from './sqlite-context-offload-store.js';
47
+ import { CONTEXT_OFFLOAD_DATABASE_NAME, CONTEXT_OFFLOAD_VALUES_DIRECTORY_NAME, SqliteContextOffloadStore, } from './sqlite-context-offload-store.js';
47
48
  import { acquireOperationalStateDatabase, inspectOperationalStateSchema, OPERATIONAL_STATE_DATABASE_NAME, OperationalStateMigrationBlockedError, } from './operational-state-store.js';
48
49
  import { TERMINAL_RUNTIME_EVENT_SQL } from './runtime-transcript-query.js';
49
50
  import { isSafeStorageId } from './storage-id.js';
@@ -168,7 +169,7 @@ export async function planSessionBundleExport(input) {
168
169
  };
169
170
  }
170
171
  export async function exportSessionBundleState(input) {
171
- return withOfflineContextSnapshot(input.stateRoot, (contextLocked) => withBundleArtifactWriterLock(input.stateRoot, input.lease, async (stateRoot) => {
172
+ return withOfflineContextSnapshot(input.stateRoot, (contextLocked) => withBundleArtifactWriterLock(input.stateRoot, input.lease, async (stateRoot) => runWithContextValueMutation(stateRoot, async () => {
172
173
  const destinationRoot = resolve(input.destinationRoot);
173
174
  await assertDestinationMissing(destinationRoot);
174
175
  const stagingRoot = `${destinationRoot}.${process.pid}.${randomUUID()}.tmp`;
@@ -182,7 +183,8 @@ export async function exportSessionBundleState(input) {
182
183
  await backupOperationalState(stateRoot, databasePath);
183
184
  const plan = await planSessionBundleExport({ ...input, stateRoot, databasePath });
184
185
  for (const entry of plan.entries) {
185
- if (entry.source === 'context_snapshot' || entry.source === 'filtered_runtime_sqlite') {
186
+ if (entry.source === 'context_snapshot' ||
187
+ entry.source === 'filtered_runtime_sqlite') {
186
188
  continue;
187
189
  }
188
190
  const destination = resolveInside(stagingRoot, entry.relativePath);
@@ -208,7 +210,7 @@ export async function exportSessionBundleState(input) {
208
210
  await rm(stagingRoot, { recursive: true, force: true }).catch(() => { });
209
211
  throw error;
210
212
  }
211
- }), input.lease ? { lease: input.lease } : {});
213
+ })), input.lease ? { lease: input.lease } : {});
212
214
  }
213
215
  /**
214
216
  * Take the private copy the whole export is derived from.
@@ -319,6 +321,20 @@ async function filterBackedUpDatabase(destinationPath, sessionIds, options) {
319
321
  for (const row of tables) {
320
322
  if (typeof row.name !== 'string' || PORTABLE_GLOBAL_TABLES.has(row.name))
321
323
  continue;
324
+ if (row.name === EVENT_WAIT_SOURCE_TABLE && !options.omitEventWaits) {
325
+ // A checkpoint must retain the source throttle/reservation constraining
326
+ // its waits, not merely their cursors. Select by Session explicitly so
327
+ // this is independent of SQLite's table iteration order. Unrelated
328
+ // sources are not part of this checkpoint's closure.
329
+ database
330
+ .prepare(`DELETE FROM ${EVENT_WAIT_SOURCE_TABLE} WHERE source_key NOT IN (
331
+ SELECT json_array(json_extract(record_json, '$.resource.providerId'),
332
+ json_extract(record_json, '$.resource.connectionId'))
333
+ FROM ${EVENT_WAIT_TABLE} WHERE session_id IN (${sessionIds.map(() => '?').join(', ')})
334
+ )`)
335
+ .run(...sessionIds);
336
+ continue;
337
+ }
322
338
  if (options.omitEventWaits && row.name === EVENT_WAIT_TABLE) {
323
339
  // Keep the schema while leaving root-owned wait authority behind.
324
340
  database.exec(`DELETE FROM ${quoteIdentifier(row.name)}`);
@@ -358,6 +374,8 @@ async function filterBackedUpDatabase(destinationPath, sessionIds, options) {
358
374
  database.exec(`DELETE FROM ${quoteIdentifier(row.name)}`);
359
375
  }
360
376
  }
377
+ if (options.omitEventWaits)
378
+ stripPortableGoalWaits(database);
361
379
  // Operational rows that describe a REQUEST rather than the conversation.
362
380
  // None of them reach the model, and in a real Session they are the large
363
381
  // majority of this table. The two record kinds that do decide what the
@@ -506,6 +524,7 @@ const LOCAL_SEQUENCE_COLUMNS = new Map([
506
524
  ['message_admissions', 'sequence'],
507
525
  ]);
508
526
  const EVENT_WAIT_TABLE = 'workflow_event_waits';
527
+ const EVENT_WAIT_SOURCE_TABLE = 'workflow_event_wait_source_cooldowns';
509
528
  const PORTABLE_GLOBAL_TABLES = new Set([
510
529
  'operational_schema_migrations',
511
530
  'session_metadata_schema',
@@ -762,17 +781,31 @@ export async function importSessionBundleState(input) {
762
781
  // a Session already visible whose bytes never arrived -- and which a
763
782
  // retry could not fix, because the ids are now taken.
764
783
  const artifacts = await copyBundleArtifacts(bundleStateRoot, stateRoot);
784
+ let contextRefs;
765
785
  try {
766
- const contextRefs = await mergeBundleContext(bundleStateRoot, stateRoot, contextLocked, sessionIds);
786
+ contextRefs = await mergeBundleContext(bundleStateRoot, stateRoot, contextLocked, sessionIds);
767
787
  const inserted = mergeBundleDatabase(lease, bundleDatabasePath);
768
788
  return { sessionIds: inserted, artifactFiles: artifacts.copied, contextRefs };
769
789
  }
770
790
  catch (error) {
771
- // Take back only what this attempt created. Anything already there
772
- // belongs to someone else, or to an earlier attempt that the next
773
- // one will recognise.
774
- for (const path of artifacts.created)
775
- await rm(path, { force: true }).catch(() => { });
791
+ // A failure after COMMIT (for example while detaching the bundle)
792
+ // must not remove bytes the published Session now references.
793
+ try {
794
+ const present = lease.database.prepare('SELECT 1 FROM session_metadata WHERE session_id = ?');
795
+ const unpublished = sessionIds.filter((id) => present.get(id) === undefined);
796
+ if (contextRefs !== undefined && contextRefs > 0) {
797
+ await releaseUnpublishedBundleContext(stateRoot, unpublished);
798
+ }
799
+ for (const path of artifacts.created) {
800
+ const artifactPath = relative(resolveInside(stateRoot, 'artifacts'), path);
801
+ if (unpublished.some((id) => isArtifactPathForSession(artifactPath, id))) {
802
+ await rm(path, { force: true }).catch(() => { });
803
+ }
804
+ }
805
+ }
806
+ catch {
807
+ // Preserve the import error if storage also refuses cleanup.
808
+ }
776
809
  throw error;
777
810
  }
778
811
  }
@@ -1007,7 +1040,8 @@ export function listSessionBundleMergeTables(target) {
1007
1040
  TRIGGER_MAINTAINED_TABLES.has(name) ||
1008
1041
  // Older bundles and snapshots can contain wait rows. Import is a
1009
1042
  // Session transfer, so it must independently refuse to copy them.
1010
- name === EVENT_WAIT_TABLE) {
1043
+ name === EVENT_WAIT_TABLE ||
1044
+ name === EVENT_WAIT_SOURCE_TABLE) {
1011
1045
  continue;
1012
1046
  }
1013
1047
  // Mirror the export's own classification instead of trusting that it
@@ -1050,6 +1084,7 @@ function mergeAttachedBundle(target) {
1050
1084
  WHERE is_archived = 1
1051
1085
  AND session_id IN (SELECT session_id FROM bundle.session_metadata)`)
1052
1086
  .run(Date.now());
1087
+ stripPortableGoalWaits(target, true);
1053
1088
  const violation = target.prepare('PRAGMA foreign_key_check').get();
1054
1089
  if (violation) {
1055
1090
  throw new SessionBundleImportError('conflict', 'Imported Sessions would leave dangling references');
@@ -1154,18 +1189,35 @@ async function mergeBundleContextDatabase(bundleContext, stateRoot, sessionIds)
1154
1189
  database.exec('BEGIN IMMEDIATE');
1155
1190
  try {
1156
1191
  database.exec('INSERT OR IGNORE INTO main.context_blobs SELECT * FROM bundle.context_blobs');
1192
+ // The payload files are already published. Adopt their representation
1193
+ // when the target still holds the same bytes inline after a v2 upgrade,
1194
+ // so retiring the last reference also collects the imported file.
1195
+ database.exec(`
1196
+ UPDATE main.context_blobs AS target
1197
+ SET storage_kind = 'managed_file', payload = source.payload
1198
+ FROM bundle.context_blobs AS source
1199
+ WHERE target.blob_id = source.blob_id
1200
+ AND target.storage_kind = 'inline'
1201
+ AND source.storage_kind = 'managed_file'
1202
+ `);
1157
1203
  // A retry re-inserts the same rows. Skipping an identical one is what
1158
1204
  // makes the second attempt work; skipping a DIFFERENT row that happens
1159
1205
  // to share an id would hide a real collision, so the two are separated.
1160
1206
  const colliding = database
1161
1207
  .prepare(`
1162
1208
  SELECT b.ref_id FROM bundle.context_refs b
1163
- JOIN main.context_refs m USING(ref_id)
1164
- WHERE m.session_id <> b.session_id OR m.blob_id <> b.blob_id
1209
+ JOIN main.context_refs m ON m.ref_id = b.ref_id OR (
1210
+ m.session_id = b.session_id AND m.owner_kind = b.owner_kind AND m.owner_id = b.owner_id
1211
+ )
1212
+ WHERE m.ref_id <> b.ref_id OR m.session_id <> b.session_id
1213
+ OR m.owner_kind <> b.owner_kind OR m.owner_id <> b.owner_id
1214
+ OR m.blob_id <> b.blob_id OR m.media_type <> b.media_type
1215
+ OR m.created_at <> b.created_at
1216
+ LIMIT 1
1165
1217
  `)
1166
- .all();
1167
- if (colliding.length > 0) {
1168
- throw new SessionBundleImportError('conflict', `Context reference already names different content: ${String(colliding[0]?.ref_id)}`);
1218
+ .get();
1219
+ if (colliding) {
1220
+ throw new SessionBundleImportError('conflict', `Context reference already names different content: ${colliding.ref_id}`);
1169
1221
  }
1170
1222
  database.exec('INSERT OR IGNORE INTO main.context_refs SELECT * FROM bundle.context_refs');
1171
1223
  // A blob the target already held may have been queued for collection
@@ -1219,6 +1271,28 @@ async function mergeBundleContextDatabase(bundleContext, stateRoot, sessionIds)
1219
1271
  }
1220
1272
  return countContextRefs(targetContext, sessionIds);
1221
1273
  }
1274
+ async function releaseUnpublishedBundleContext(stateRoot, sessionIds) {
1275
+ if (sessionIds.length === 0)
1276
+ return;
1277
+ await runWithContextValueMutation(stateRoot, async () => {
1278
+ // Reuse retirement's accounting and GC candidate updates. Retirement does
1279
+ // not add payloads, so it needs no write quota.
1280
+ const store = new SqliteContextOffloadStore(resolveInside(stateRoot, CONTEXT_OFFLOAD_DATABASE_NAME), {
1281
+ limits: {
1282
+ ownerMaxBytes: { read_image_snapshot: 0, tool_result_archive: 0 },
1283
+ sessionLogicalBytes: 0,
1284
+ workspacePhysicalBytes: 0,
1285
+ },
1286
+ });
1287
+ try {
1288
+ for (const sessionId of sessionIds)
1289
+ await store.retireSession(sessionId);
1290
+ }
1291
+ finally {
1292
+ store.close();
1293
+ }
1294
+ });
1295
+ }
1222
1296
  /**
1223
1297
  * Copy a managed-payload tree, structure and all.
1224
1298
  *
@@ -1372,3 +1446,29 @@ function countContextRefs(databasePath, sessionIds) {
1372
1446
  database.close();
1373
1447
  }
1374
1448
  }
1449
+ function stripPortableGoalWaits(database, importedOnly = false) {
1450
+ const scope = importedOnly
1451
+ ? 'AND session_id IN (SELECT session_id FROM bundle.session_metadata)'
1452
+ : '';
1453
+ for (const row of database
1454
+ .prepare(`SELECT session_id, record_json FROM workflow_goal_authority WHERE (json_type(record_json, '$.activeEventWait') IS NOT NULL OR json_type(record_json, '$.pendingContinuation.eventWait') IS NOT NULL) ${scope}`)
1455
+ .all()) {
1456
+ const old = decodeGoalAuthorityRecord(JSON.parse(String(row.record_json)));
1457
+ const { activeEventWait: _gate, ...base } = old;
1458
+ const record = decodeGoalAuthorityRecord({
1459
+ ...base,
1460
+ currentExecution: null,
1461
+ pendingContinuation: null,
1462
+ controlLease: { ...base.controlLease, generation: base.controlLease.generation + 1 },
1463
+ goal: {
1464
+ ...base.goal,
1465
+ revision: base.goal.revision + 1,
1466
+ status: 'paused',
1467
+ lastReason: 'Event waits do not transfer between State Roots.',
1468
+ },
1469
+ });
1470
+ database
1471
+ .prepare('UPDATE workflow_goal_authority SET authority_revision = authority_revision + 1, goal_revision = ?, status = ?, record_json = ? WHERE session_id = ?')
1472
+ .run(record.goal.revision, record.goal.status, JSON.stringify(record), row.session_id);
1473
+ }
1474
+ }
@@ -0,0 +1,204 @@
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, randomUUID } from 'node:crypto';
20
+ import { mkdir } from 'node:fs/promises';
21
+ import { join } from 'node:path';
22
+ import { writeAtomicFile } from './atomic-file-write.js';
23
+ import { readStableBoundedFile } from './stable-storage.js';
24
+ import { withProcessLifetimeFileUpdateLock } from './process-lifetime-file-update-lock.js';
25
+ import { createSessionCheckpointManifestV1, encodeSessionCheckpointManifestV1, SESSION_CHECKPOINT_MANIFEST_MEDIA_TYPE, } from './session-repository.js';
26
+ const MAX_DOCUMENT_BYTES = 4 * 1024 * 1024;
27
+ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u;
28
+ /**
29
+ * Host operation recovery facts, NOT a second checkpoint Head. The Repository
30
+ * remains the only authority for the current revision. Documents are bounded;
31
+ * receipts are never silently expired to make space.
32
+ */
33
+ export async function openSessionCheckpointPublicationStore(input) {
34
+ await mkdir(input.directory, { recursive: true, mode: 0o700 });
35
+ const authorityPath = join(input.directory, 'authority-v1.json');
36
+ const agentId = await withProcessLifetimeFileUpdateLock(authorityPath, async () => {
37
+ const existing = await readOptional(authorityPath);
38
+ if (existing !== undefined) {
39
+ if (!record(existing) ||
40
+ existing.schemaVersion !== 1 ||
41
+ existing.rootId !== input.rootId ||
42
+ !identifier(existing.agentId) ||
43
+ !UUID.test(existing.agentId))
44
+ throw invalid();
45
+ return existing.agentId;
46
+ }
47
+ const agentId = randomUUID();
48
+ await writeDocument(authorityPath, { schemaVersion: 1, rootId: input.rootId, agentId });
49
+ return agentId;
50
+ });
51
+ return {
52
+ async withSession(makaSessionId, operation) {
53
+ if (!identifier(makaSessionId))
54
+ throw new TypeError('Invalid checkpoint Session identity');
55
+ const key = createHash('sha256').update(makaSessionId).digest('hex');
56
+ const path = join(input.directory, `session-${key}.json`);
57
+ return withProcessLifetimeFileUpdateLock(path, async () => {
58
+ const existing = await readOptional(path);
59
+ const document = existing === undefined
60
+ ? {
61
+ schemaVersion: 1,
62
+ rootId: input.rootId,
63
+ binding: { makaSessionId, repositorySessionId: randomUUID(), agentId },
64
+ requests: [],
65
+ }
66
+ : decode(existing, input.rootId, makaSessionId, agentId);
67
+ const save = async () => {
68
+ decode(document, input.rootId, makaSessionId, agentId);
69
+ await writeDocument(path, document);
70
+ };
71
+ if (existing === undefined)
72
+ await save();
73
+ return operation(document, save);
74
+ });
75
+ },
76
+ };
77
+ }
78
+ function decode(value, rootId, sessionId, agentId) {
79
+ if (!record(value) ||
80
+ value.schemaVersion !== 1 ||
81
+ value.rootId !== rootId ||
82
+ !record(value.binding) ||
83
+ value.binding.makaSessionId !== sessionId ||
84
+ value.binding.agentId !== agentId ||
85
+ !identifier(value.binding.repositorySessionId) ||
86
+ !UUID.test(value.binding.repositorySessionId) ||
87
+ !Array.isArray(value.requests))
88
+ throw invalid();
89
+ const ids = new Set();
90
+ const commits = new Set();
91
+ let pending = 0;
92
+ for (const request of value.requests) {
93
+ if (!record(request) ||
94
+ !identifier(request.requestId) ||
95
+ !identifier(request.commitId) ||
96
+ !UUID.test(request.commitId) ||
97
+ ids.has(request.requestId) ||
98
+ commits.has(request.commitId) ||
99
+ !(request.expectedRevision === null || identifier(request.expectedRevision)) ||
100
+ !(request.snapshotCleanupPending === undefined || request.snapshotCleanupPending === true) ||
101
+ !(request.bundleCleanupPending === undefined || request.bundleCleanupPending === true) ||
102
+ !(request.confirmationGrantId === undefined || identifier(request.confirmationGrantId)))
103
+ throw invalid();
104
+ ids.add(request.requestId);
105
+ commits.add(request.commitId);
106
+ if (request.phase === 'capturing' || request.phase === 'aborted') {
107
+ if (request.checkpoint !== undefined || request.result !== undefined)
108
+ throw invalid();
109
+ if (request.phase === 'capturing')
110
+ pending++;
111
+ }
112
+ else if (request.phase === 'prepared' ||
113
+ request.phase === 'conflicted' ||
114
+ request.phase === 'committed') {
115
+ assertCheckpoint(request.checkpoint);
116
+ if (request.phase !== 'committed') {
117
+ if (request.phase === 'prepared')
118
+ pending++;
119
+ if (request.result !== undefined)
120
+ throw invalid();
121
+ }
122
+ else {
123
+ const result = request.result;
124
+ if (!record(result) ||
125
+ !record(result.ref) ||
126
+ result.ref.sessionId !== value.binding.repositorySessionId ||
127
+ !identifier(result.ref.revision) ||
128
+ result.agentId !== agentId ||
129
+ result.forkedFrom !== undefined ||
130
+ result.lastCommittedActivationId !== undefined)
131
+ throw invalid();
132
+ assertCheckpoint(result.checkpoint);
133
+ if (JSON.stringify(result.checkpoint) !== JSON.stringify(request.checkpoint))
134
+ throw invalid();
135
+ }
136
+ }
137
+ else
138
+ throw invalid();
139
+ }
140
+ if (pending > 1)
141
+ throw invalid();
142
+ return value;
143
+ }
144
+ function assertCheckpoint(value) {
145
+ try {
146
+ if (!record(value) ||
147
+ !record(value.value) ||
148
+ value.value.schemaVersion !== 1 ||
149
+ !record(value.manifest))
150
+ throw invalid();
151
+ const manifest = createSessionCheckpointManifestV1(value.value.compatibilityBundle);
152
+ const bytes = encodeSessionCheckpointManifestV1(manifest);
153
+ if (!identifier(value.manifest.objectRef) ||
154
+ value.manifest.mediaType !== SESSION_CHECKPOINT_MANIFEST_MEDIA_TYPE ||
155
+ value.manifest.bytes !== bytes.byteLength ||
156
+ value.manifest.digest !== `sha256:${createHash('sha256').update(bytes).digest('hex')}`)
157
+ throw invalid();
158
+ }
159
+ catch (cause) {
160
+ throw invalid(cause);
161
+ }
162
+ }
163
+ async function readOptional(path) {
164
+ try {
165
+ const bytes = await readStableBoundedFile({
166
+ path,
167
+ maxBytes: MAX_DOCUMENT_BYTES,
168
+ invalidFile: invalid,
169
+ });
170
+ return JSON.parse(bytes.toString('utf8'));
171
+ }
172
+ catch (error) {
173
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT')
174
+ return undefined;
175
+ throw error;
176
+ }
177
+ }
178
+ async function writeDocument(path, document) {
179
+ const bytes = `${JSON.stringify(document)}\n`;
180
+ // Reserve the duplicated checkpoint plus binding/revision envelope BEFORE
181
+ // admitting CAS. Otherwise a prepared record near the quota could commit a
182
+ // Head whose receipt can never fit, permanently blocking reconciliation.
183
+ const receiptReserve = record(document) && Array.isArray(document.requests)
184
+ ? document.requests.reduce((total, request) => total +
185
+ (record(request) && request.phase === 'prepared'
186
+ ? Buffer.byteLength(JSON.stringify(request.checkpoint)) + 8192
187
+ : 0), 0)
188
+ : 0;
189
+ if (Buffer.byteLength(bytes) + receiptReserve > MAX_DOCUMENT_BYTES)
190
+ throw new Error('Checkpoint publication journal quota exceeded');
191
+ await writeAtomicFile(path, bytes, { fileMode: 0o600 });
192
+ }
193
+ function record(value) {
194
+ return !!value && typeof value === 'object' && !Array.isArray(value);
195
+ }
196
+ function identifier(value) {
197
+ return (typeof value === 'string' &&
198
+ value.length > 0 &&
199
+ value.length <= 512 &&
200
+ !/[\u0000-\u001f]/u.test(value));
201
+ }
202
+ function invalid(cause) {
203
+ return new Error('Invalid checkpoint publication recovery record', cause === undefined ? undefined : { cause });
204
+ }
@@ -18,7 +18,7 @@
18
18
  */
19
19
  import { assertCoordinationIdentityPairing, buildSessionHeader, toSummary, } from './session-store-values.js';
20
20
  export { normalizeSessionHeader, decodePersistedSessionHeader, createUserMessage, } from './session-store-values.js';
21
- import { SessionMetadataVersionConflictError, EXTERNAL_SESSION_IMPORT_LOOKUP_MAX_SOURCE_IDS, EXTERNAL_SESSION_IMPORT_LOOKUP_MAX_RECENT_SESSION_IDS, } from './session-store-contract.js';
21
+ import { SessionMetadataVersionConflictError, EXTERNAL_SESSION_IMPORT_LOOKUP_MAX_SOURCE_IDS, EXTERNAL_SESSION_IMPORT_LOOKUP_MAX_RECENT_SESSION_IDS, isSessionNotFoundError, } from './session-store-contract.js';
22
22
  export { isSafeSessionId, assertSafeSessionId, SessionNotFoundError, isSessionNotFoundError, EXTERNAL_SESSION_IMPORT_LOOKUP_MAX_SOURCE_IDS, EXTERNAL_SESSION_IMPORT_LOOKUP_MAX_RECENT_SESSION_IDS, } from './session-store-contract.js';
23
23
  import { join } from 'node:path';
24
24
  import { createHash } from 'node:crypto';
@@ -62,19 +62,48 @@ class SqliteSessionStore {
62
62
  if (input.subagentSpawn) {
63
63
  throw new Error('Subagent spawn metadata requires createSubagent()');
64
64
  }
65
- const canonicalMessages = messages.map((message) => decodeCanonicalMessage(JSON.parse(JSON.stringify(message))));
66
65
  const header = {
67
66
  ...buildSessionHeader(this.workspaceRoot, input),
68
67
  externalOrigin,
69
68
  transcriptLedgerVersion: 0,
70
69
  };
71
- const catalogProjection = projectSessionCatalogMessages(canonicalMessages);
72
- options.onCommitStarted?.();
73
- const outcome = await this.metadata.importSession(header, canonicalMessages, catalogProjection);
74
- if (outcome !== 'imported') {
75
- throw new Error(`Generated Session id already exists: ${header.id}`);
70
+ let commitStarted = false;
71
+ try {
72
+ const preparedMessages = options.prepareMessages
73
+ ? await options.prepareMessages(header.id, messages)
74
+ : messages;
75
+ const canonicalMessages = preparedMessages.map((message) => decodeCanonicalMessage(JSON.parse(JSON.stringify(message))));
76
+ const catalogProjection = projectSessionCatalogMessages(canonicalMessages);
77
+ options.onCommitStarted?.();
78
+ commitStarted = true;
79
+ const outcome = await this.metadata.importSession(header, canonicalMessages, catalogProjection);
80
+ if (outcome !== 'imported') {
81
+ throw new Error(`Generated Session id already exists: ${header.id}`);
82
+ }
83
+ return (await this.metadata.read(header.id)).header;
84
+ }
85
+ catch (error) {
86
+ let uncommitted = !commitStarted;
87
+ if (commitStarted) {
88
+ try {
89
+ await this.metadata.read(header.id);
90
+ }
91
+ catch (readError) {
92
+ // An uncertain commit must retain its bytes for recovery. Only an
93
+ // authoritative absence makes the prepared artifacts safe to discard.
94
+ uncommitted = isSessionNotFoundError(readError);
95
+ }
96
+ }
97
+ if (uncommitted) {
98
+ try {
99
+ await options.discardPreparedMessages?.(header.id);
100
+ }
101
+ catch {
102
+ // Best-effort cleanup must not replace the original import failure.
103
+ }
104
+ }
105
+ throw error;
76
106
  }
77
- return (await this.metadata.read(header.id)).header;
78
107
  }
79
108
  async lookupExternalSessionImports(adapterId, sourceSessionIds, recentSessionIdLimit) {
80
109
  await this.ensureReady();
@@ -0,0 +1,65 @@
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 { AsyncLocalStorage } from 'node:async_hooks';
20
+ /** Normal operations remain concurrent; an explicit snapshot drains and fences them. */
21
+ export class SnapshotOperationGate {
22
+ #active = new Set();
23
+ #context = new AsyncLocalStorage();
24
+ #barrier;
25
+ run(operation) {
26
+ if (this.#context.getStore()?.active)
27
+ return operation();
28
+ const barrier = this.#barrier;
29
+ const task = barrier ? barrier.then(operation) : operation();
30
+ return this.#track(task);
31
+ }
32
+ exclusive(operation) {
33
+ if (this.#context.getStore()?.active) {
34
+ return Promise.reject(new Error('Cannot nest an execution snapshot boundary'));
35
+ }
36
+ // Register the barrier synchronously, before draining existing operations.
37
+ const previous = [...this.#active];
38
+ const precedingBarrier = this.#barrier;
39
+ let release;
40
+ const barrier = new Promise((resolve) => {
41
+ release = resolve;
42
+ });
43
+ this.#barrier = barrier;
44
+ const task = (async () => {
45
+ await precedingBarrier;
46
+ await Promise.allSettled(previous);
47
+ const context = { active: true };
48
+ try {
49
+ return await this.#context.run(context, operation);
50
+ }
51
+ finally {
52
+ context.active = false;
53
+ release();
54
+ if (this.#barrier === barrier)
55
+ this.#barrier = undefined;
56
+ }
57
+ })();
58
+ return this.#track(task);
59
+ }
60
+ #track(task) {
61
+ this.#active.add(task);
62
+ void task.finally(() => this.#active.delete(task)).catch(() => { });
63
+ return task;
64
+ }
65
+ }
@@ -222,7 +222,7 @@ export function migrateSqliteContextOffloadDatabase(db) {
222
222
  throw newerSchemaError(observedVersion);
223
223
  }
224
224
  if (observedVersion === SQLITE_CONTEXT_OFFLOAD_SCHEMA_VERSION) {
225
- validateSchema(db);
225
+ validateSqliteContextOffloadSchema(db);
226
226
  return;
227
227
  }
228
228
  db.exec('BEGIN IMMEDIATE');
@@ -248,7 +248,7 @@ export function migrateSqliteContextOffloadDatabase(db) {
248
248
  db.exec(`PRAGMA user_version = ${SQLITE_CONTEXT_OFFLOAD_SCHEMA_VERSION}`);
249
249
  current = SQLITE_CONTEXT_OFFLOAD_SCHEMA_VERSION;
250
250
  }
251
- validateSchema(db);
251
+ validateSqliteContextOffloadSchema(db);
252
252
  db.exec('COMMIT');
253
253
  }
254
254
  catch (error) {
@@ -264,7 +264,7 @@ export function readSqliteContextOffloadSchemaVersion(db) {
264
264
  }
265
265
  return value;
266
266
  }
267
- function validateSchema(db) {
267
+ export function validateSqliteContextOffloadSchema(db) {
268
268
  const autoVacuum = db.prepare('PRAGMA auto_vacuum').get();
269
269
  if (autoVacuum?.auto_vacuum !== 2) {
270
270
  throw new Error('Incomplete context-offload SQLite schema: incremental auto-vacuum required');