maka-agent 0.2.2-dev.92.20261019 → 0.2.2-dev.98.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.
- package/LICENSE +7 -7
- package/README.md +78 -18
- package/README.zh-CN.md +73 -15
- package/THIRD_PARTY_NOTICES.txt +12 -12
- package/dist/pi-goal.js +13 -0
- package/dist/pi-tui-runner.js +44 -1
- package/dist/run-command-core.js +111 -70
- package/dist/run-session-command.js +91 -15
- package/dist/run-turn-outcome.js +2 -33
- package/dist/runtime-host-session-channel.js +3 -1
- package/dist/runtime-host-session-driver.js +5 -0
- package/dist/tui-copy-catalog.js +24 -0
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/docs/docs/api/Client.md +2 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/core/symbols.js +1 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client-h1.js +0 -2
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client-h2.js +0 -4
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client.js +3 -2
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/dispatcher-base.js +12 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/cache-handler.js +48 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/deduplication-handler.js +57 -13
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/redirect-handler.js +8 -1
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/interceptor/decompress.js +15 -5
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/index.js +3 -1
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/parse.js +138 -137
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/util.js +21 -2
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/eventsource/eventsource-stream.js +90 -9
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/eventsource/eventsource.js +4 -1
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/fetch/index.js +3 -3
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/infra/index.js +14 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/websocket/receiver.js +13 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/package.json +1 -1
- package/node_modules/@maka/acp-executor-plugin/dist/acp-catalog-store.js +87 -0
- package/node_modules/@maka/acp-executor-plugin/dist/acp-catalog.js +98 -21
- package/node_modules/@maka/acp-executor-plugin/dist/index.js +90 -14
- package/node_modules/@maka/acp-executor-plugin/dist/plugin.mjs +3997 -56
- package/node_modules/@maka/core/dist/assistant-turn-ids.js +34 -0
- package/node_modules/@maka/core/dist/event-wait.js +28 -10
- package/node_modules/@maka/core/dist/executor-catalog.js +3 -1
- package/node_modules/@maka/core/dist/model-catalog.js +19 -1
- package/node_modules/@maka/core/dist/model-metadata.generated.js +4 -14
- package/node_modules/@maka/core/dist/model-metadata.js +42 -1
- package/node_modules/@maka/core/dist/models-dev-projection.js +32 -1
- package/node_modules/@maka/core/dist/provider-registry.js +16 -2
- package/node_modules/@maka/core/dist/runtime-event.js +8 -0
- package/node_modules/@maka/core/dist/session-checkin.js +31 -0
- package/node_modules/@maka/core/dist/usage-stats/types.js +1 -0
- package/node_modules/@maka/core/package.json +2 -0
- package/node_modules/@maka/eval/node_modules/undici/README.md +25 -3
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Client.md +11 -6
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Errors.md +76 -1
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/index.md +12 -12
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/type-map.json +66 -66
- package/node_modules/@maka/eval/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
- package/node_modules/@maka/eval/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
- package/node_modules/@maka/eval/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/@maka/eval/node_modules/undici/lib/core/constants.js +12 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/core/errors.js +38 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/core/request.js +16 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/core/symbols.js +2 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/core/util.js +26 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client.js +4 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/pool.js +11 -8
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
- package/node_modules/@maka/eval/node_modules/undici/lib/handler/cache-handler.js +153 -15
- package/node_modules/@maka/eval/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
- package/node_modules/@maka/eval/node_modules/undici/lib/handler/redirect-handler.js +28 -8
- package/node_modules/@maka/eval/node_modules/undici/lib/handler/retry-handler.js +44 -11
- package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/cache.js +11 -3
- package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/decompress.js +22 -9
- package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/dns.js +11 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/response-error.js +72 -28
- package/node_modules/@maka/eval/node_modules/undici/lib/milo/LICENSE.md +7 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/milo/no-simd.js +1002 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/milo/simd.js +1002 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/mock/mock-agent.js +11 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/util/cache.js +11 -5
- package/node_modules/@maka/eval/node_modules/undici/lib/web/cookies/util.js +19 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
- package/node_modules/@maka/eval/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/body.js +47 -38
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/headers.js +2 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/index.js +8 -4
- package/node_modules/@maka/eval/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/@maka/eval/node_modules/undici/lib/web/websocket/receiver.js +25 -4
- package/node_modules/@maka/eval/node_modules/undici/package.json +9 -7
- package/node_modules/@maka/mcp/package.json +1 -1
- package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +22 -9
- package/node_modules/@maka/runtime/dist/ai-sdk-message-projection.js +10 -1
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +101 -127
- package/node_modules/@maka/runtime/dist/event-wait-tool.js +2 -2
- package/node_modules/@maka/runtime/dist/history-compact-checkpoint.js +32 -1
- package/node_modules/@maka/runtime/dist/history-compaction.js +7 -0
- package/node_modules/@maka/runtime/dist/model-factory.js +26 -6
- package/node_modules/@maka/runtime/dist/model-fetcher.js +8 -1
- package/node_modules/@maka/runtime/dist/model-history.js +16 -3
- package/node_modules/@maka/runtime/dist/openai-codex-history-compactor.js +7 -2
- package/node_modules/@maka/runtime/dist/plugin-executor-backend.js +49 -2
- package/node_modules/@maka/runtime/dist/plugin-executor-service.js +12 -3
- package/node_modules/@maka/runtime/dist/runtime-context.js +53 -0
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +3 -0
- package/node_modules/@maka/runtime/dist/session-checkin.js +331 -0
- package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +7 -0
- package/node_modules/@maka/runtime/dist/shell-run-manager.js +34 -0
- package/node_modules/@maka/runtime/dist/telemetry/builtin-pricing.js +21 -2
- package/node_modules/@maka/runtime/dist/tool-runtime.js +8 -0
- package/node_modules/@maka/runtime/dist/workers/filesystem-worker.mjs +50 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/docs/docs/api/Client.md +2 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/core/symbols.js +1 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client-h1.js +0 -2
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client-h2.js +0 -4
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client.js +3 -2
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/dispatcher-base.js +12 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/cache-handler.js +48 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/deduplication-handler.js +57 -13
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/redirect-handler.js +8 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/interceptor/decompress.js +15 -5
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/index.js +3 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/parse.js +138 -137
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/util.js +21 -2
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/eventsource/eventsource-stream.js +90 -9
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/eventsource/eventsource.js +4 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/fetch/index.js +3 -3
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/infra/index.js +14 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/websocket/receiver.js +13 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/package.json +1 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/package.json +1 -1
- package/node_modules/@maka/runtime/node_modules/undici/README.md +25 -3
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Client.md +11 -6
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Errors.md +76 -1
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/index.md +12 -12
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/type-map.json +66 -66
- package/node_modules/@maka/runtime/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
- package/node_modules/@maka/runtime/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/constants.js +12 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/errors.js +38 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/request.js +16 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/symbols.js +2 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/util.js +26 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client.js +4 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/pool.js +11 -8
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
- package/node_modules/@maka/runtime/node_modules/undici/lib/handler/cache-handler.js +153 -15
- package/node_modules/@maka/runtime/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
- package/node_modules/@maka/runtime/node_modules/undici/lib/handler/redirect-handler.js +28 -8
- package/node_modules/@maka/runtime/node_modules/undici/lib/handler/retry-handler.js +44 -11
- package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/cache.js +11 -3
- package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/decompress.js +22 -9
- package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/dns.js +11 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/response-error.js +72 -28
- package/node_modules/@maka/runtime/node_modules/undici/lib/milo/LICENSE.md +7 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/milo/no-simd.js +1002 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/milo/simd.js +1002 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/mock/mock-agent.js +11 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/util/cache.js +11 -5
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/cookies/util.js +19 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/body.js +47 -38
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/headers.js +2 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/index.js +8 -4
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/websocket/receiver.js +25 -4
- package/node_modules/@maka/runtime/node_modules/undici/package.json +9 -7
- package/node_modules/@maka/runtime/package.json +2 -0
- package/node_modules/@maka/runtime-host/dist/assistant/bot/bridge.js +8 -0
- package/node_modules/@maka/runtime-host/dist/assistant/bot/capabilities.js +1 -0
- package/node_modules/@maka/runtime-host/dist/assistant/bot/controller.js +64 -13
- package/node_modules/@maka/runtime-host/dist/assistant/bot/host.js +11 -2
- package/node_modules/@maka/runtime-host/dist/assistant/bot/store.js +71 -2
- package/node_modules/@maka/runtime-host/dist/assistant/bot/turn-ids.js +38 -0
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/assistant.js +7 -0
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/controller.js +193 -32
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/discovery-capabilities.js +69 -0
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/host.js +15 -28
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/notebook.js +286 -0
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/prompt.js +31 -6
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/store.js +18 -1
- package/node_modules/@maka/runtime-host/dist/assistant/memory-network/controller.js +1 -1
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition-observer.js +94 -0
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition-store.js +253 -0
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition.js +133 -0
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/controller.js +27 -14
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/delegation.js +35 -5
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/delivery.js +1 -1
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/host.js +16 -2
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/matter.js +13 -0
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/prompt.js +7 -5
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/review.js +1 -1
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/settlement-context.js +126 -0
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/store.js +92 -6
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/tools.js +87 -23
- package/node_modules/@maka/runtime-host/dist/assistant/service.js +49 -5
- package/node_modules/@maka/runtime-host/dist/protocol/goal.js +119 -1
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +7 -1
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +8 -1
- package/node_modules/@maka/runtime-host/dist/protocol/personal-assistant.js +1 -0
- package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +7 -1
- package/node_modules/@maka/runtime-host/dist/protocol/session-checkin.js +133 -0
- package/node_modules/@maka/runtime-host/dist/server/canonical-session-projection.js +3 -2
- package/node_modules/@maka/runtime-host/dist/server/event-wait-manager.js +63 -12
- package/node_modules/@maka/runtime-host/dist/server/event-wait-observation-store.js +19 -0
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +123 -11
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +47 -3
- package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +126 -4
- package/node_modules/@maka/runtime-host/dist/server/goal-event-waits.js +58 -19
- package/node_modules/@maka/runtime-host/dist/server/goal-projection.js +24 -3
- package/node_modules/@maka/runtime-host/dist/server/index.js +2 -0
- package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +44 -2
- package/node_modules/@maka/runtime-host/dist/server/personal-assistant-workspace.js +78 -0
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +73 -3
- package/node_modules/@maka/runtime-host/dist/server/session-checkin.js +257 -0
- package/node_modules/@maka/runtime-host/dist/server/session-checkpoint-coordinator.js +282 -0
- package/node_modules/@maka/runtime-host/dist/server/session-checkpoint-publication.js +250 -0
- package/node_modules/@maka/runtime-host/dist/server/shell-run-event-wait-access.js +166 -0
- package/node_modules/@maka/runtime-host/dist/server/shell-run-event-wait-adapter.js +59 -0
- package/node_modules/@maka/runtime-host/dist/server/skill-catalog-repository.js +4 -2
- package/node_modules/@maka/storage/dist/context-offload-snapshot.js +2 -1
- package/node_modules/@maka/storage/dist/execution-stores.js +36 -1
- package/node_modules/@maka/storage/dist/local-execution-persistence.js +26 -0
- package/node_modules/@maka/storage/dist/production-session-snapshot.js +14 -6
- package/node_modules/@maka/storage/dist/runtime-event-persistence.js +1 -0
- package/node_modules/@maka/storage/dist/session-bundle-policy.js +86 -16
- package/node_modules/@maka/storage/dist/session-checkpoint-publication-store.js +204 -0
- package/node_modules/@maka/storage/dist/snapshot-operation-gate.js +65 -0
- package/node_modules/@maka/storage/dist/sqlite-context-offload-schema.js +3 -3
- package/node_modules/@maka/storage/dist/sqlite-context-offload-store.js +4 -2
- package/node_modules/@maka/storage/dist/sqlite-reclamation-checkpoint.js +37 -0
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +31 -0
- package/node_modules/@maka/storage/package.json +3 -0
- package/node_modules/@modelcontextprotocol/client/dist/index-B-4n9P0J.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/index-J2FaQ-KY.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/index.cjs +76 -22
- package/node_modules/@modelcontextprotocol/client/dist/index.d.cts.map +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/index.d.mts.map +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/index.mjs +76 -22
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.cjs +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.mjs +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/{src-oZBjf3U1.cjs → src-DpAS0jfg.cjs} +105 -8
- package/node_modules/@modelcontextprotocol/client/dist/{src-xKF0PJN-.mjs → src-WCy6ifGf.mjs} +88 -9
- package/node_modules/@modelcontextprotocol/client/dist/stdio.cjs +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/stdio.mjs +1 -1
- package/node_modules/@modelcontextprotocol/client/node_modules/@modelcontextprotocol/core/package.json +2 -2
- package/node_modules/@modelcontextprotocol/client/package.json +5 -5
- package/node_modules/fast-uri/.github/workflows/release.yml +35 -0
- package/node_modules/fast-uri/README.md +8 -0
- package/node_modules/fast-uri/index.js +98 -18
- package/node_modules/fast-uri/lib/utils.js +52 -0
- package/node_modules/fast-uri/package.json +1 -1
- package/node_modules/follow-redirects/index.js +10 -1
- package/node_modules/follow-redirects/package.json +1 -1
- package/node_modules/ip-address/README.md +104 -104
- package/node_modules/ip-address/dist/ipv4.js +7 -0
- package/node_modules/ip-address/dist/ipv6.js +7 -4
- package/node_modules/ip-address/dist/v6/constants.js +3 -0
- package/node_modules/ip-address/package.json +2 -1
- package/node_modules/undici/README.md +25 -3
- package/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
- package/node_modules/undici/docs/docs/api/Client.md +11 -6
- package/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
- package/node_modules/undici/docs/docs/api/Errors.md +76 -1
- package/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
- package/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
- package/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
- package/node_modules/undici/docs/docs/index.md +12 -12
- package/node_modules/undici/docs/docs/type-map.json +66 -66
- package/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
- package/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
- package/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/undici/lib/core/constants.js +12 -1
- package/node_modules/undici/lib/core/errors.js +38 -1
- package/node_modules/undici/lib/core/request.js +16 -1
- package/node_modules/undici/lib/core/symbols.js +2 -0
- package/node_modules/undici/lib/core/util.js +26 -1
- package/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
- package/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
- package/node_modules/undici/lib/dispatcher/client.js +4 -1
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
- package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
- package/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
- package/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
- package/node_modules/undici/lib/dispatcher/pool.js +11 -8
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
- package/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
- package/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
- package/node_modules/undici/lib/handler/cache-handler.js +153 -15
- package/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
- package/node_modules/undici/lib/handler/redirect-handler.js +28 -8
- package/node_modules/undici/lib/handler/retry-handler.js +44 -11
- package/node_modules/undici/lib/interceptor/cache.js +11 -3
- package/node_modules/undici/lib/interceptor/decompress.js +22 -9
- package/node_modules/undici/lib/interceptor/dns.js +11 -0
- package/node_modules/undici/lib/interceptor/response-error.js +72 -28
- package/node_modules/undici/lib/milo/LICENSE.md +7 -0
- package/node_modules/undici/lib/milo/no-simd.js +1002 -0
- package/node_modules/undici/lib/milo/simd.js +1002 -0
- package/node_modules/undici/lib/mock/mock-agent.js +11 -0
- package/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
- package/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
- package/node_modules/undici/lib/util/cache.js +11 -5
- package/node_modules/undici/lib/web/cookies/util.js +19 -2
- package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
- package/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
- package/node_modules/undici/lib/web/fetch/body.js +47 -38
- package/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
- package/node_modules/undici/lib/web/fetch/headers.js +2 -2
- package/node_modules/undici/lib/web/fetch/index.js +8 -4
- package/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/undici/lib/web/websocket/receiver.js +25 -4
- package/node_modules/undici/package.json +9 -7
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/zod/v4/core/versions.js +1 -1
- package/package.json +2 -2
- package/node_modules/@modelcontextprotocol/client/dist/index-D_CiY-T3.d.cts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/index-D_QDtbiv.d.mts.map +0 -1
|
@@ -0,0 +1,250 @@
|
|
|
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 { mkdir, realpath, rm } from 'node:fs/promises';
|
|
20
|
+
import { basename, dirname, isAbsolute, join, relative, sep } from 'node:path';
|
|
21
|
+
import { SessionConfigurationTransitionError } from '@maka/runtime/session-manager';
|
|
22
|
+
import { openFileSessionRepository } from '@maka/storage/file-session-repository';
|
|
23
|
+
import { openSessionCheckpointPublicationStore } from '@maka/storage/session-checkpoint-publication-store';
|
|
24
|
+
import { acquireProcessLifetimeOwner } from '@maka/storage/process-lifetime-owner';
|
|
25
|
+
import { runWithStorageRootLease } from '@maka/storage/root-authority';
|
|
26
|
+
import { assertSessionBundleLimits, } from '@maka/storage/session-bundle-contract';
|
|
27
|
+
import { createProductionSessionSnapshotService } from '@maka/storage/production-session-snapshot';
|
|
28
|
+
import { createFileSessionSnapshotStagingCleanupAuthority, } from '@maka/storage/quiescent-session-snapshot';
|
|
29
|
+
import { HostCheckpointError, HostSessionCheckpointCoordinator, } from './session-checkpoint-coordinator.js';
|
|
30
|
+
/** Trusted service capability; no protocol endpoint or model tool is added by PR2. */
|
|
31
|
+
export async function createHostSessionCheckpointPublication(input) {
|
|
32
|
+
const { context, stores, options } = input;
|
|
33
|
+
if (!options)
|
|
34
|
+
return unavailable('Checkpoint publication is not configured');
|
|
35
|
+
if (!stores.snapshot)
|
|
36
|
+
return unavailable('Selected execution persistence does not support checkpoints');
|
|
37
|
+
if (!options.workspace || typeof options.workspace.runExclusive !== 'function') {
|
|
38
|
+
return unavailable('A trusted workspace snapshot authority is required');
|
|
39
|
+
}
|
|
40
|
+
if (process.platform === 'win32' && !options.privateStagingRootAuthority) {
|
|
41
|
+
return unavailable('Checkpoint staging requires a Windows ACL verification authority');
|
|
42
|
+
}
|
|
43
|
+
assertSessionBundleLimits(options.limits);
|
|
44
|
+
// Freeze caller policy at composition, not midway through a publication.
|
|
45
|
+
const limits = Object.freeze({ ...options.limits });
|
|
46
|
+
let owner;
|
|
47
|
+
try {
|
|
48
|
+
if (!options.directory || !isAbsolute(options.directory)) {
|
|
49
|
+
throw new Error('Checkpoint directory must be an explicit absolute durable path');
|
|
50
|
+
}
|
|
51
|
+
const root = await canonicalPlannedDirectory(options.directory);
|
|
52
|
+
for (const source of [context.owner.capability.canonicalPath, context.owner.controlDirectory]) {
|
|
53
|
+
assertDisjoint(root, await canonicalPlannedDirectory(source));
|
|
54
|
+
}
|
|
55
|
+
const stagingParent = join(root, 'staging');
|
|
56
|
+
const cleanupStateRoot = join(root, 'cleanup');
|
|
57
|
+
const bundlesRoot = join(root, 'bundles');
|
|
58
|
+
await Promise.all([stagingParent, cleanupStateRoot, bundlesRoot].map((path) => mkdir(path, { recursive: true, mode: 0o700 })));
|
|
59
|
+
const cleanupOwner = await acquireProcessLifetimeOwner(cleanupStateRoot);
|
|
60
|
+
owner = cleanupOwner;
|
|
61
|
+
// Validate durable Root binding before recovering anything owned by an earlier process.
|
|
62
|
+
const journal = await openSessionCheckpointPublicationStore({
|
|
63
|
+
directory: join(root, 'operations'),
|
|
64
|
+
rootId: context.owner.lease.rootId,
|
|
65
|
+
});
|
|
66
|
+
// Recover crashed owners before exposing publication, even when this Host
|
|
67
|
+
// never captures again or only replays an already committed receipt.
|
|
68
|
+
const recovery = await createFileSessionSnapshotStagingCleanupAuthority({
|
|
69
|
+
cleanupStateRoot,
|
|
70
|
+
stagingParent,
|
|
71
|
+
processLifetimeOwner: cleanupOwner,
|
|
72
|
+
privateStagingRootAuthority: options.privateStagingRootAuthority,
|
|
73
|
+
}).recover();
|
|
74
|
+
if (recovery.failed.length > 0) {
|
|
75
|
+
throw new AggregateError(recovery.failed.map(({ error }) => error), 'Checkpoint staging recovery failed');
|
|
76
|
+
}
|
|
77
|
+
const repository = await openFileSessionRepository({ storageRoot: join(root, 'repository') });
|
|
78
|
+
const coordinator = new HostSessionCheckpointCoordinator({
|
|
79
|
+
journal,
|
|
80
|
+
repository,
|
|
81
|
+
objects: repository.objectStore,
|
|
82
|
+
runAuthorized: (operation) => runWithStorageRootLease(context.owner.lease, 'interactive', 'write', async () => {
|
|
83
|
+
const residency = context.acquireResidency('session-checkpoint');
|
|
84
|
+
try {
|
|
85
|
+
return await operation();
|
|
86
|
+
}
|
|
87
|
+
finally {
|
|
88
|
+
residency.release();
|
|
89
|
+
}
|
|
90
|
+
}),
|
|
91
|
+
cleanupBundle: async (commitId) => {
|
|
92
|
+
// This UUID was validated in the journal; never remove a caller path.
|
|
93
|
+
if (!/^[0-9a-f-]{36}$/u.test(commitId))
|
|
94
|
+
throw new Error('Invalid checkpoint bundle identity');
|
|
95
|
+
await rm(join(bundlesRoot, `${commitId}.tar.zst`), { force: true });
|
|
96
|
+
},
|
|
97
|
+
capture: async (request) => {
|
|
98
|
+
const sessionId = request.binding.makaSessionId;
|
|
99
|
+
const header = await stores.sessionStore.readHeader(sessionId);
|
|
100
|
+
if (!header.cwd)
|
|
101
|
+
throw new HostCheckpointError('unsupported', 'Session has no snapshot-capable workspace');
|
|
102
|
+
const workspaceRoot = await realpath(header.cwd);
|
|
103
|
+
assertDisjoint(root, workspaceRoot);
|
|
104
|
+
let statePreparer;
|
|
105
|
+
const service = await createProductionSessionSnapshotService({
|
|
106
|
+
session: {
|
|
107
|
+
makaSessionId: sessionId,
|
|
108
|
+
cloudSessionId: request.binding.repositorySessionId,
|
|
109
|
+
},
|
|
110
|
+
sourceRoots: [context.owner.capability.canonicalPath],
|
|
111
|
+
state: {
|
|
112
|
+
prepareState: (stateInput) => {
|
|
113
|
+
if (!statePreparer)
|
|
114
|
+
throw new Error('Snapshot state requested outside its provider boundary');
|
|
115
|
+
return statePreparer.prepareState(stateInput);
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
workspaceRoot,
|
|
119
|
+
stagingParent,
|
|
120
|
+
cleanupStateRoot,
|
|
121
|
+
processLifetimeOwner: cleanupOwner,
|
|
122
|
+
limits,
|
|
123
|
+
privateStagingRootAuthority: options.privateStagingRootAuthority,
|
|
124
|
+
confirmationAuthority: options.confirmationAuthority,
|
|
125
|
+
quiescence: {
|
|
126
|
+
runQuiescent: (snapshotInput, operation) => input.admission.run(sessionId, async () => {
|
|
127
|
+
snapshotInput.cancellation.signal.throwIfAborted();
|
|
128
|
+
try {
|
|
129
|
+
return await input.manager.runSessionSubtreeQuiescentMutation(sessionId, async (sessionIds) => {
|
|
130
|
+
if (sessionIds.length !== 1)
|
|
131
|
+
throw new HostCheckpointError('unsupported', 'Linked Session snapshot closure is not supported yet');
|
|
132
|
+
return stores.snapshot.runExclusive(async (state) => {
|
|
133
|
+
snapshotInput.cancellation.signal.throwIfAborted();
|
|
134
|
+
const current = await stores.sessionStore.readHeaderSnapshot(sessionId);
|
|
135
|
+
if (!current.cwd || (await realpath(current.cwd)) !== workspaceRoot) {
|
|
136
|
+
throw new HostCheckpointError('conflict', 'Session workspace changed before capture');
|
|
137
|
+
}
|
|
138
|
+
if (current.role !== undefined ||
|
|
139
|
+
current.subagentParent ||
|
|
140
|
+
current.conversationCopy?.state === 'preparing') {
|
|
141
|
+
throw new HostCheckpointError('unsupported', 'Session kind is not supported for checkpoint publication');
|
|
142
|
+
}
|
|
143
|
+
const [pending, operations, approvals, boundaries, shells, sessions] = await Promise.all([
|
|
144
|
+
stores.sessionStore.listMessageAdmissions(sessionId),
|
|
145
|
+
stores.runtimeEventStore.listUnsettledToolOperations(sessionId),
|
|
146
|
+
stores.interactionStore.listPending({ sessionId }),
|
|
147
|
+
stores.sessionStore.listPendingSandboxBoundaryRequests(sessionId),
|
|
148
|
+
input.shellRuns.listSessionShellRuns(sessionId),
|
|
149
|
+
stores.sessionStore.listForRecovery(),
|
|
150
|
+
]);
|
|
151
|
+
if (!input.isSessionIdle(sessionId) ||
|
|
152
|
+
pending.length ||
|
|
153
|
+
operations.length ||
|
|
154
|
+
approvals.length ||
|
|
155
|
+
boundaries.length ||
|
|
156
|
+
shells.some((shell) => shell.status === 'starting' ||
|
|
157
|
+
shell.status === 'running' ||
|
|
158
|
+
shell.status === 'orphaned')) {
|
|
159
|
+
throw new HostCheckpointError('busy', 'Session has pending execution or external work');
|
|
160
|
+
}
|
|
161
|
+
for (const other of sessions) {
|
|
162
|
+
if (other.id !== sessionId &&
|
|
163
|
+
other.cwd &&
|
|
164
|
+
(await realpath(other.cwd).catch(() => undefined)) === workspaceRoot) {
|
|
165
|
+
throw new HostCheckpointError('unsupported', 'Shared workspaces require a multi-Session snapshot boundary');
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return options.workspace.runExclusive({ sessionId, workspaceRoot, cancellation: snapshotInput.cancellation }, async () => {
|
|
169
|
+
snapshotInput.cancellation.signal.throwIfAborted();
|
|
170
|
+
statePreparer = state;
|
|
171
|
+
try {
|
|
172
|
+
return await operation();
|
|
173
|
+
}
|
|
174
|
+
finally {
|
|
175
|
+
statePreparer = undefined;
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
if (error instanceof SessionConfigurationTransitionError &&
|
|
183
|
+
error.code === 'session_busy') {
|
|
184
|
+
throw new HostCheckpointError('busy', 'Session has an active Runtime execution', { cause: error });
|
|
185
|
+
}
|
|
186
|
+
throw error;
|
|
187
|
+
}
|
|
188
|
+
}),
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
return service.pack({
|
|
192
|
+
destination: join(bundlesRoot, `${request.commitId}.tar.zst`),
|
|
193
|
+
confirmationGrantId: request.confirmationGrantId,
|
|
194
|
+
signal: request.signal,
|
|
195
|
+
deadlineAt: request.deadlineAt,
|
|
196
|
+
});
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
let close;
|
|
200
|
+
return {
|
|
201
|
+
publish: (request) => coordinator.publish(request),
|
|
202
|
+
beginDrain: () => coordinator.beginDrain(),
|
|
203
|
+
close: () => (close ??= (async () => {
|
|
204
|
+
await coordinator.close();
|
|
205
|
+
await cleanupOwner.close();
|
|
206
|
+
})()),
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
await owner?.close();
|
|
211
|
+
// Optional checkpoint metadata must not prevent live-state recovery. Fail
|
|
212
|
+
// this capability closed and retain the cause for the trusted caller.
|
|
213
|
+
return unavailable('Checkpoint publication initialization failed', 'publication_failed', error);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// Resolve existing ancestors too: an apparently separate path through a symlink
|
|
217
|
+
// must not place checkpoint state inside the live Root or disposable control tree.
|
|
218
|
+
async function canonicalPlannedDirectory(path) {
|
|
219
|
+
try {
|
|
220
|
+
return await realpath(path);
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
if (error.code !== 'ENOENT' || dirname(path) === path)
|
|
224
|
+
throw error;
|
|
225
|
+
return join(await canonicalPlannedDirectory(dirname(path)), basename(path));
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
function assertDisjoint(left, right) {
|
|
229
|
+
const contains = (parent, child) => {
|
|
230
|
+
const path = relative(parent, child);
|
|
231
|
+
return path === '' || (!isAbsolute(path) && path !== '..' && !path.startsWith(`..${sep}`));
|
|
232
|
+
};
|
|
233
|
+
if (contains(left, right) || contains(right, left)) {
|
|
234
|
+
throw new Error('Checkpoint directory must not overlap live state, control or workspace roots');
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
function unavailable(message, code = 'unsupported', cause) {
|
|
238
|
+
let closed = false;
|
|
239
|
+
return {
|
|
240
|
+
publish: async () => {
|
|
241
|
+
throw new HostCheckpointError(closed ? 'closed' : code, message, { cause });
|
|
242
|
+
},
|
|
243
|
+
beginDrain: () => {
|
|
244
|
+
closed = true;
|
|
245
|
+
},
|
|
246
|
+
close: async () => {
|
|
247
|
+
closed = true;
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
}
|
|
@@ -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),
|
|
@@ -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');
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
19
|
import { openInteractiveEventWaitAuthorityForWrite, } from './event-wait-authority.js';
|
|
20
|
+
import { SnapshotOperationGate } from './snapshot-operation-gate.js';
|
|
20
21
|
import { createSqliteAgentRunStore, } from './agent-run-store.js';
|
|
21
22
|
import { createSessionStore } from './session-store.js';
|
|
22
23
|
import { assertStorageRootLease, assertStorageRootLeaseActive, runWithStorageRootLease, StorageRootAuthorityError, } from './root-authority.js';
|
|
@@ -102,6 +103,7 @@ async function createExecutionStoresForWrite(lease, provider) {
|
|
|
102
103
|
let closed = false;
|
|
103
104
|
let closeTask;
|
|
104
105
|
const active = new Set();
|
|
106
|
+
const snapshotGate = new SnapshotOperationGate();
|
|
105
107
|
const subscriptions = new Set();
|
|
106
108
|
const run = (operation) => {
|
|
107
109
|
if (closed)
|
|
@@ -109,7 +111,7 @@ async function createExecutionStoresForWrite(lease, provider) {
|
|
|
109
111
|
const pending = runWithStorageRootLease(lease, kind, 'write', () => {
|
|
110
112
|
if (closed)
|
|
111
113
|
throw invalidExecutionStores(kind, 'write');
|
|
112
|
-
return operation
|
|
114
|
+
return snapshotGate.run(operation);
|
|
113
115
|
});
|
|
114
116
|
active.add(pending);
|
|
115
117
|
void pending.finally(() => active.delete(pending)).catch(() => undefined);
|
|
@@ -279,6 +281,37 @@ async function createExecutionStoresForWrite(lease, provider) {
|
|
|
279
281
|
close: () => { },
|
|
280
282
|
});
|
|
281
283
|
const stores = {
|
|
284
|
+
...(persistence.createSnapshotStatePreparer
|
|
285
|
+
? {
|
|
286
|
+
snapshot: Object.freeze({
|
|
287
|
+
runExclusive(operation) {
|
|
288
|
+
if (closed)
|
|
289
|
+
return Promise.reject(invalidExecutionStores(kind, 'write'));
|
|
290
|
+
const pending = snapshotGate.exclusive(() => runWithStorageRootLease(lease, kind, 'write', async () => {
|
|
291
|
+
if (closed)
|
|
292
|
+
throw invalidExecutionStores(kind, 'write');
|
|
293
|
+
const state = persistence.createSnapshotStatePreparer(lease);
|
|
294
|
+
let scopeActive = true;
|
|
295
|
+
try {
|
|
296
|
+
return await operation({
|
|
297
|
+
prepareState: (input) => {
|
|
298
|
+
if (!scopeActive || closed)
|
|
299
|
+
return Promise.reject(invalidExecutionStores(kind, 'write'));
|
|
300
|
+
return state.prepareState(input);
|
|
301
|
+
},
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
finally {
|
|
305
|
+
scopeActive = false;
|
|
306
|
+
}
|
|
307
|
+
}));
|
|
308
|
+
active.add(pending);
|
|
309
|
+
void pending.finally(() => active.delete(pending)).catch(() => { });
|
|
310
|
+
return pending;
|
|
311
|
+
},
|
|
312
|
+
}),
|
|
313
|
+
}
|
|
314
|
+
: {}),
|
|
282
315
|
interactionStore,
|
|
283
316
|
graphControlStore,
|
|
284
317
|
goalStore,
|
|
@@ -410,6 +443,7 @@ async function createExecutionStoresForWrite(lease, provider) {
|
|
|
410
443
|
}
|
|
411
444
|
: {}),
|
|
412
445
|
scanRuntimeEvents: (sessionId, runId, budget, visit) => run(() => runtimeEventStore.scanRuntimeEvents(sessionId, runId, budget, visit)),
|
|
446
|
+
readToolProvenanceEvents: (sessionId, runId, toolCallId, budget) => run(() => runtimeEventStore.readToolProvenanceEvents(sessionId, runId, toolCallId, budget)),
|
|
413
447
|
readRuntimeEventsBounded: (sessionId, runId, budget) => run(() => runtimeEventStore.readRuntimeEventsBounded(sessionId, runId, budget)),
|
|
414
448
|
readImmutableRuntimeEvents: (sessionId, runId) => run(() => runtimeEventStore.readImmutableRuntimeEvents(sessionId, runId)),
|
|
415
449
|
readRecoveryMessageEvents: (input) => run(() => runtimeEventStore.readRecoveryMessageEvents(input)),
|
|
@@ -527,6 +561,7 @@ async function openExecutionStoresForRead(lease, kind, extension) {
|
|
|
527
561
|
readSessionRuntimeSnapshot: (sessionId) => run(() => runtimeEventStore.readSessionRuntimeSnapshot(sessionId)),
|
|
528
562
|
}
|
|
529
563
|
: {}),
|
|
564
|
+
readToolProvenanceEvents: (sessionId, runId, toolCallId, budget) => run(() => runtimeEventStore.readToolProvenanceEvents(sessionId, runId, toolCallId, budget)),
|
|
530
565
|
readRuntimeEventsBounded: (sessionId, runId, budget) => run(() => runtimeEventStore.readRuntimeEventsBounded(sessionId, runId, budget)),
|
|
531
566
|
readImmutableRuntimeEvents: (sessionId, runId) => run(() => runtimeEventStore.readImmutableRuntimeEvents(sessionId, runId)),
|
|
532
567
|
listSessionInvocations: (sessionId) => run(() => runtimeEventStore.listSessionInvocations(sessionId)),
|
|
@@ -24,6 +24,9 @@ import { createAgentGraphControlStore } from './agent-graph-control-store.js';
|
|
|
24
24
|
import { createSqliteEventWaitAuthority } from './sqlite-event-wait-authority.js';
|
|
25
25
|
import { createSqliteGoalAuthority } from './goal-authority.js';
|
|
26
26
|
import { createSqliteInteractionStore } from './interaction-store.js';
|
|
27
|
+
import { exportSessionBundleState } from './session-bundle-policy.js';
|
|
28
|
+
import { createSessionSnapshotStateIdentity } from './production-session-snapshot.js';
|
|
29
|
+
import { runWithStorageRootLease } from './root-authority.js';
|
|
27
30
|
export const localExecutionPersistenceProvider = Object.freeze({
|
|
28
31
|
async open({ canonicalPath }) {
|
|
29
32
|
const closes = [];
|
|
@@ -60,6 +63,29 @@ export const localExecutionPersistenceProvider = Object.freeze({
|
|
|
60
63
|
closes.push(() => interactionStore.close());
|
|
61
64
|
await Promise.all([sessionStore.ready(), agentRunStore.ready?.(), interactionStore.ready()]);
|
|
62
65
|
return {
|
|
66
|
+
createSnapshotStatePreparer(lease) {
|
|
67
|
+
if (lease.canonicalPath !== canonicalPath)
|
|
68
|
+
throw new Error('Snapshot lease belongs to another backend');
|
|
69
|
+
return {
|
|
70
|
+
async prepareState(input) {
|
|
71
|
+
input.cancellation.signal.throwIfAborted();
|
|
72
|
+
// Lock order: execution fence -> Artifact writer -> context values.
|
|
73
|
+
// The exporter holds the Artifact lock until both databases and
|
|
74
|
+
// their payloads are private. GC/publication uses these same locks.
|
|
75
|
+
await runWithStorageRootLease(lease, 'interactive', 'write', () => exportSessionBundleState({
|
|
76
|
+
stateRoot: canonicalPath,
|
|
77
|
+
configRoot: canonicalPath,
|
|
78
|
+
allowShared: true,
|
|
79
|
+
destinationRoot: input.destinationRoot,
|
|
80
|
+
sessionId: input.makaSessionId,
|
|
81
|
+
requireQuiescent: true,
|
|
82
|
+
lease,
|
|
83
|
+
}));
|
|
84
|
+
input.cancellation.signal.throwIfAborted();
|
|
85
|
+
return createSessionSnapshotStateIdentity(input.makaSessionId);
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
},
|
|
63
89
|
sessionStore,
|
|
64
90
|
agentRunStore,
|
|
65
91
|
runtimeEventStore: runtime.runtimeEventStore,
|