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,19 @@
|
|
|
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
|
+
export {};
|
|
@@ -16,8 +16,10 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
+
import { readMatterRuntimeEvents } from '../assistant/proactive-matters/settlement-context.js';
|
|
19
20
|
import { markAssistantBackgroundSessions } from '../assistant/background-sessions.js';
|
|
20
21
|
import { PersonalAssistantService, ASSISTANT_LEGACY_PACKAGES } from '../assistant/service.js';
|
|
22
|
+
import { assistantInputTurnId, legacyAssistantInputTurnId } from '../assistant/bot/turn-ids.js';
|
|
21
23
|
import { createAssistantMessageReader } from './session-transcript-reader.js';
|
|
22
24
|
import { createImageFileReader } from '@maka/runtime/image-file-reader';
|
|
23
25
|
import { ChatImageDeliveryService } from './chat-image-delivery.js';
|
|
@@ -60,6 +62,9 @@ import { RuntimeReadModel } from '@maka/runtime/runtime-read-model';
|
|
|
60
62
|
import { renderAgentSwarmSupervisorWake, shouldWakeAgentSwarmSupervisor, } from '@maka/runtime/agent-swarm-status-tool';
|
|
61
63
|
import { SessionActivityRegistry } from '@maka/runtime/goal-turn-lifecycle';
|
|
62
64
|
import { ShellRunProcessManager } from '@maka/runtime/shell-run-manager';
|
|
65
|
+
import { ShellRunEventWaitAccess } from './shell-run-event-wait-access.js';
|
|
66
|
+
import { ShellRunEventWaitAdapter } from './shell-run-event-wait-adapter.js';
|
|
67
|
+
import { EventWaitAdapterRegistry } from './event-wait-adapter.js';
|
|
63
68
|
import { resolveShellPlan, resolveTurnShellPlan, validateShellPreference, } from '@maka/runtime/shell-detect';
|
|
64
69
|
import { Context } from '@maka/runtime/plugin-kernel';
|
|
65
70
|
import { PluginAgentService } from '@maka/runtime/plugin-agent-service';
|
|
@@ -109,12 +114,13 @@ import { HostConnectionEffectCoordinator } from './connection-effect-coordinator
|
|
|
109
114
|
import { HostChangeFeed } from './host-change-feed.js';
|
|
110
115
|
import { HostConfigurationCoordinator } from './configuration-coordinator.js';
|
|
111
116
|
import { HostPromptSuggestionCoordinator, supportsPromptSuggestion } from './prompt-suggestion.js';
|
|
117
|
+
import { checkinSessionState, HostSessionCheckinCoordinator, listCheckinCatalogSessions, } from './session-checkin.js';
|
|
112
118
|
import { HostContextCoordinator } from './context-coordinator.js';
|
|
113
119
|
import { HostClientCapabilityCoordinator } from './client-capability-coordinator.js';
|
|
114
120
|
import { HostDailyReviewCoordinator } from './daily-review-coordinator.js';
|
|
115
121
|
import { prepareHostAiSdkBackend } from './execution-model-composition.js';
|
|
116
122
|
import { createInteractiveRunComposer, createInteractiveRunComposerFactory, routeInteractiveRunToolSurface, } from './interactive-run-composer.js';
|
|
117
|
-
import { createHostGoalEvaluator, createHostDailyReviewModel, createHostMemoryExtractionModel, createHostPluginModel, createHostSessionEffectModel, createHostPromptSuggestionModel, } from './execution-model-authority.js';
|
|
123
|
+
import { createHostGoalEvaluator, createHostDailyReviewModel, createHostMemoryExtractionModel, createHostPluginModel, createHostSessionEffectModel, createHostPromptSuggestionModel, createHostCheckinModel, resolveDefaultModelHeader, } from './execution-model-authority.js';
|
|
118
124
|
import { HostExecutionInspectCoordinator } from './execution-inspect-coordinator.js';
|
|
119
125
|
import { HostExternalSessionCoordinator } from './external-session-coordinator.js';
|
|
120
126
|
import { boundedFailureDiagnostic } from './failure-diagnostic.js';
|
|
@@ -143,6 +149,7 @@ import { join } from 'node:path';
|
|
|
143
149
|
import { toRuntimePolicyProxy } from './runtime-policy-proxy.js';
|
|
144
150
|
import { AcpSetupError } from './acp/connection.js';
|
|
145
151
|
import { installAntigravity } from './acp/antigravity-install.js';
|
|
152
|
+
import { ANTIGRAVITY_ACP_EXECUTOR_ID } from '@maka/antigravity-acp-plugin';
|
|
146
153
|
import { createProxiedFetchTransport } from '@maka/runtime/network/scoped-fetch-transport';
|
|
147
154
|
import { HostExternalAgentSetupCoordinator } from './external-agent-setup-coordinator.js';
|
|
148
155
|
import { HostOAuthCoordinator } from './oauth-coordinator.js';
|
|
@@ -163,6 +170,7 @@ import { startHostModelMetadataRefresh } from './model-metadata-refresh.js';
|
|
|
163
170
|
import { HostRuntimeResourceCoordinator } from './runtime-resource-coordinator.js';
|
|
164
171
|
import { SessionAdmissionGate } from './session-admission-gate.js';
|
|
165
172
|
import { workHubResultOrigin } from './workhub-result-coordinator.js';
|
|
173
|
+
import { HostPersonalAssistantWorkspace } from './personal-assistant-workspace.js';
|
|
166
174
|
import { HostSessionCatalogCoordinator } from './session-catalog-coordinator.js';
|
|
167
175
|
import { SessionBackgroundActivityProjection } from './session-background-activity.js';
|
|
168
176
|
import { SessionInteractionActivityProjection } from './session-interaction-activity.js';
|
|
@@ -171,6 +179,7 @@ import { HostSessionRetirementCoordinator } from './session-retirement-coordinat
|
|
|
171
179
|
import { HostStorageMaintenance } from './storage-maintenance.js';
|
|
172
180
|
import { HostStorageUsageCoordinator } from './storage-usage-coordinator.js';
|
|
173
181
|
import { HostArchiveRetentionCoordinator } from './archive-retention-coordinator.js';
|
|
182
|
+
import { createHostSessionCheckpointPublication, } from './session-checkpoint-publication.js';
|
|
174
183
|
import { HostSessionRevisionCoordinator } from './session-revision-coordinator.js';
|
|
175
184
|
import { HostSessionEffectCoordinator } from './session-effect-coordinator.js';
|
|
176
185
|
import { SessionContinuityCoordinator } from './session-continuity-coordinator.js';
|
|
@@ -226,6 +235,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
226
235
|
let graphClient;
|
|
227
236
|
let sessionEffects;
|
|
228
237
|
let promptSuggestions;
|
|
238
|
+
let checkins;
|
|
229
239
|
let memoryExtraction;
|
|
230
240
|
let imageDelivery;
|
|
231
241
|
let unsubscribeTranscriptChanges;
|
|
@@ -240,6 +250,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
240
250
|
let invalidatePluginExecutorBackends = () => undefined;
|
|
241
251
|
let modelMetadataRefresh;
|
|
242
252
|
let archiveEvidence;
|
|
253
|
+
let sessionCheckpoints;
|
|
243
254
|
try {
|
|
244
255
|
const pluginRoot = new Context();
|
|
245
256
|
const pluginAgents = new PluginAgentService(pluginRoot);
|
|
@@ -295,9 +306,20 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
295
306
|
...(header.executorConfig ? { configuration: header.executorConfig } : {}),
|
|
296
307
|
});
|
|
297
308
|
}
|
|
298
|
-
return pluginExecutors.catalog({
|
|
309
|
+
return pluginExecutors.catalog({
|
|
310
|
+
cwd: input.cwd,
|
|
311
|
+
refresh: input.refresh,
|
|
312
|
+
executorId: input.executorId,
|
|
313
|
+
listOnly: input.listOnly,
|
|
314
|
+
});
|
|
299
315
|
});
|
|
300
316
|
const personalAssistant = (assistant = new PersonalAssistantService(join(context.owner.controlDirectory, 'personal-assistant'), {
|
|
317
|
+
prepareBotWake: async (ownerId, workerId) => {
|
|
318
|
+
if (await interactions.hasPendingSession(workerId))
|
|
319
|
+
return 'deferred';
|
|
320
|
+
return sessionCatalog.synchronizeAssistantBotModel(ownerId, workerId);
|
|
321
|
+
},
|
|
322
|
+
allocateWorkspace: () => assistantWorkspace.allocate(),
|
|
301
323
|
stopSessions: async () => {
|
|
302
324
|
if (!rootCoordinator)
|
|
303
325
|
return;
|
|
@@ -344,6 +366,9 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
344
366
|
});
|
|
345
367
|
},
|
|
346
368
|
markBackgroundSessions: (ids) => markAssistantBackgroundSessions(stores.sessionStore, ids),
|
|
369
|
+
readRuntimeEvents: async (sessionId, runId) => runId
|
|
370
|
+
? readMatterRuntimeEvents(stores.runtimeEventStore, sessionId, runId)
|
|
371
|
+
: (await stores.runtimeEventStore.readSessionRuntimeEventEntries(sessionId)).map((entry) => entry.event),
|
|
347
372
|
agents: pluginAgents,
|
|
348
373
|
llm: pluginLlm,
|
|
349
374
|
sessionQuery: pluginSessionQuery,
|
|
@@ -879,13 +904,15 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
879
904
|
continuity = new SessionContinuityCoordinator(context.hostEpoch, (sessionId) => canonicalProjectionReader.read(sessionId), sessionAdmission, context.requestDrain, transcriptReader, async (sessionId, attention) => {
|
|
880
905
|
if (attention) {
|
|
881
906
|
try {
|
|
882
|
-
|
|
907
|
+
const header = await stores.sessionStore.readHeaderSnapshot(sessionId);
|
|
908
|
+
if (header.labels?.includes(ASSISTANT_BACKGROUND_SESSION_LABEL) ||
|
|
909
|
+
(await runtimePolicyStores.runtimePolicy.getSnapshot()).policy.privacy.incognitoActive) {
|
|
883
910
|
attention = undefined;
|
|
884
911
|
}
|
|
885
912
|
}
|
|
886
913
|
catch (error) {
|
|
887
914
|
attention = undefined;
|
|
888
|
-
console.warn('[runtime-host] Could not read notification
|
|
915
|
+
console.warn('[runtime-host] Could not read notification policy', error);
|
|
889
916
|
}
|
|
890
917
|
}
|
|
891
918
|
hostChanges.publishSessionCatalog(sessionId, attention);
|
|
@@ -927,6 +954,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
927
954
|
let domainModuleDrainBegun = false;
|
|
928
955
|
const beginDrain = () => {
|
|
929
956
|
draining = true;
|
|
957
|
+
sessionCheckpoints?.beginDrain();
|
|
930
958
|
if (!domainModules || domainModuleDrainBegun)
|
|
931
959
|
return;
|
|
932
960
|
domainModuleDrainBegun = true;
|
|
@@ -1022,19 +1050,24 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1022
1050
|
...(scheduledTaskTool ? { scheduledTaskTool } : {}),
|
|
1023
1051
|
planStore,
|
|
1024
1052
|
goalTools: requireGoal(goal).tools,
|
|
1053
|
+
eventWaitAvailable: () => backendContext.header.toolMode !== 'code_mode' &&
|
|
1054
|
+
['active', 'waiting'].includes(requireGoal(goal).manager.get(backendContext.sessionId)?.status ?? ''),
|
|
1025
1055
|
builtinTools,
|
|
1026
1056
|
hostTools,
|
|
1027
1057
|
resolveToolCeiling: (sessionId) => personalAssistant.toolCeiling(sessionId),
|
|
1028
1058
|
resolveRootTools: async (sessionId) => {
|
|
1029
1059
|
await assertAssistantSessionEnabled(sessionId);
|
|
1030
1060
|
return [
|
|
1031
|
-
...personalAssistant.tools,
|
|
1061
|
+
...personalAssistant.filterTools(sessionId, personalAssistant.tools),
|
|
1032
1062
|
...(sessionId === WORKHUB_COORDINATION_SESSION_ID && workHubResults && workHubInspection
|
|
1033
1063
|
? [workHubResults.tool, workHubInspection]
|
|
1034
1064
|
: await requireGraphCoordinator(graphCoordinator).toolsForSession(sessionId)),
|
|
1035
1065
|
];
|
|
1036
1066
|
},
|
|
1037
|
-
resolvePluginTools: (sessionId, coreTools) =>
|
|
1067
|
+
resolvePluginTools: (sessionId, coreTools) => {
|
|
1068
|
+
const resolved = pluginTools.resolveContributions(sessionId, coreTools);
|
|
1069
|
+
return { ...resolved, tools: personalAssistant.filterTools(sessionId, resolved.tools) };
|
|
1070
|
+
},
|
|
1038
1071
|
resolvePluginSystemPrompt: async (sessionId, promptContext, baseText) => {
|
|
1039
1072
|
const assembly = await pluginSystemPrompt.assemble({
|
|
1040
1073
|
sessionId,
|
|
@@ -1190,7 +1223,10 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1190
1223
|
const [graphTools, planState] = await Promise.all([
|
|
1191
1224
|
(sessionId === WORKHUB_COORDINATION_SESSION_ID && workHubResults && workHubInspection
|
|
1192
1225
|
? Promise.resolve([workHubResults.tool, workHubInspection])
|
|
1193
|
-
: requireGraphCoordinator(graphCoordinator).toolsForSession(sessionId)).then((tools) => [
|
|
1226
|
+
: requireGraphCoordinator(graphCoordinator).toolsForSession(sessionId)).then((tools) => [
|
|
1227
|
+
...personalAssistant.filterTools(sessionId, personalAssistant.tools),
|
|
1228
|
+
...tools,
|
|
1229
|
+
]),
|
|
1194
1230
|
planStore.readState(sessionId),
|
|
1195
1231
|
]);
|
|
1196
1232
|
const { runtimePolicy, surface } = await resolveInteractiveToolSurface({
|
|
@@ -1524,7 +1560,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1524
1560
|
context.requestDrain();
|
|
1525
1561
|
},
|
|
1526
1562
|
onSucceeded: () => {
|
|
1527
|
-
pluginExecutors.invalidateCatalog();
|
|
1563
|
+
pluginExecutors.invalidateCatalog(ANTIGRAVITY_ACP_EXECUTOR_ID);
|
|
1528
1564
|
hostChanges.publishConfiguration();
|
|
1529
1565
|
},
|
|
1530
1566
|
capabilities: clientCapabilities,
|
|
@@ -1621,6 +1657,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1621
1657
|
};
|
|
1622
1658
|
const pluginSessionSummary = (session) => Object.freeze({
|
|
1623
1659
|
id: session.id,
|
|
1660
|
+
isArchived: session.isArchived,
|
|
1624
1661
|
...(session.name ? { title: session.name } : {}),
|
|
1625
1662
|
...(session.cwd ? { cwd: session.cwd } : {}),
|
|
1626
1663
|
...(session.labels?.length ? { labels: session.labels } : {}),
|
|
@@ -1976,8 +2013,14 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
1976
2013
|
matchesActive: (sessionId, checkpoint, controlLease) => requireGoal(goal).matchesActive(sessionId, checkpoint, controlLease),
|
|
1977
2014
|
});
|
|
1978
2015
|
goalExecutions = goalExecutionCoordinator;
|
|
2016
|
+
const shellRunWaitAccess = new ShellRunEventWaitAccess(openedShellRunStore, stores.runtimeEventStore);
|
|
1979
2017
|
goal = new HostGoalCoordinator({
|
|
1980
|
-
|
|
2018
|
+
eventWaitSources: dependencies.eventWaitSources ?? {
|
|
2019
|
+
adapters: new EventWaitAdapterRegistry([
|
|
2020
|
+
new ShellRunEventWaitAdapter(shellRunWaitAccess, shellRuns),
|
|
2021
|
+
]),
|
|
2022
|
+
authorize: (wait, signal) => shellRunWaitAccess.authorize(wait, signal),
|
|
2023
|
+
},
|
|
1981
2024
|
store: openedGoalStore,
|
|
1982
2025
|
stores,
|
|
1983
2026
|
readSessionContext: async (sessionId) => {
|
|
@@ -2033,7 +2076,8 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
2033
2076
|
});
|
|
2034
2077
|
async function applyRuntimePolicyMutationEffects() {
|
|
2035
2078
|
try {
|
|
2036
|
-
|
|
2079
|
+
// Reconciliation replaces only changed agent configurations. Unrelated
|
|
2080
|
+
// policy edits must not discard every provider's persistent catalog.
|
|
2037
2081
|
await builtinExternalAgentPlugins.reconcile();
|
|
2038
2082
|
await requireMemory(memory).refreshAfterPolicyMutation();
|
|
2039
2083
|
}
|
|
@@ -2097,6 +2141,46 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
2097
2141
|
? { sessionAccessAuthority: context.sessionAccessAuthority }
|
|
2098
2142
|
: {}),
|
|
2099
2143
|
});
|
|
2144
|
+
const sessionCheckins = new HostSessionCheckinCoordinator({
|
|
2145
|
+
allowed: async () => !(await runtimePolicyStores.runtimePolicy.getSnapshot()).policy.privacy.incognitoActive,
|
|
2146
|
+
listSessions: (context) => listCheckinCatalogSessions((input) => sessionCatalog.handlers['session.catalog.query'](input, context)),
|
|
2147
|
+
readSession: async (session) => {
|
|
2148
|
+
// The Todo read takes the Session's admission itself, so it cannot run inside this one.
|
|
2149
|
+
const todos = (await sessionTodo.read(session.id)).items;
|
|
2150
|
+
return sessionAdmission.run(session.id, async () => {
|
|
2151
|
+
const canonical = await canonicalProjectionReader.read(session.id);
|
|
2152
|
+
if (!canonical || canonical.session.isArchived)
|
|
2153
|
+
return undefined;
|
|
2154
|
+
await requireSessionManager(manager).ensureTranscriptLedgerForRead(session.id);
|
|
2155
|
+
const view = await recapReadModel.getSessionView(session.id);
|
|
2156
|
+
return checkinSessionState({
|
|
2157
|
+
session,
|
|
2158
|
+
canonical,
|
|
2159
|
+
todos,
|
|
2160
|
+
messages: view.messages,
|
|
2161
|
+
turns: view.turns,
|
|
2162
|
+
});
|
|
2163
|
+
});
|
|
2164
|
+
},
|
|
2165
|
+
readModelTarget: () => resolveDefaultModelHeader(runtimePolicyStores),
|
|
2166
|
+
generate: createHostCheckinModel({
|
|
2167
|
+
runtimePolicy: runtimePolicyStores,
|
|
2168
|
+
oauthCredentials,
|
|
2169
|
+
usage: openedUsageStores,
|
|
2170
|
+
requestDrain: context.requestDrain,
|
|
2171
|
+
}),
|
|
2172
|
+
});
|
|
2173
|
+
checkins = sessionCheckins;
|
|
2174
|
+
const assistantWorkspace = new HostPersonalAssistantWorkspace({
|
|
2175
|
+
stateRoot: context.owner.capability.canonicalPath,
|
|
2176
|
+
...(options.assistantHomeDirectory ? { homeDirectory: options.assistantHomeDirectory } : {}),
|
|
2177
|
+
projects: openedProjectCatalog,
|
|
2178
|
+
membership: projectMembership,
|
|
2179
|
+
projectChanged: () => hostChanges.publishProjectCatalog(),
|
|
2180
|
+
preflightSessionCreation: async () => {
|
|
2181
|
+
await sessionCatalog.resolveDefaultCreateTarget();
|
|
2182
|
+
},
|
|
2183
|
+
});
|
|
2100
2184
|
const workHubTargetExecution = new HostWorkHubTargetExecutionAuthority({
|
|
2101
2185
|
readSession: (sessionId) => stores.sessionStore.readHeaderRecordSnapshot(sessionId),
|
|
2102
2186
|
runtimePolicy: {
|
|
@@ -2610,6 +2694,15 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
2610
2694
|
catalog: stores.sessionStore,
|
|
2611
2695
|
retirement: sessionRetirement,
|
|
2612
2696
|
});
|
|
2697
|
+
sessionCheckpoints = await createHostSessionCheckpointPublication({
|
|
2698
|
+
context,
|
|
2699
|
+
stores,
|
|
2700
|
+
admission: sessionAdmission,
|
|
2701
|
+
manager: requireSessionManager(manager),
|
|
2702
|
+
shellRuns: openedShellRunStore,
|
|
2703
|
+
isSessionIdle: (sessionId) => rootRecoveryCompleted && !draining && coordinator.isSessionExecutionIdle(sessionId),
|
|
2704
|
+
options: dependencies.checkpointPublication,
|
|
2705
|
+
});
|
|
2613
2706
|
const storageMaintenance = new HostStorageMaintenance({
|
|
2614
2707
|
artifacts: openedArtifactStore,
|
|
2615
2708
|
contextOffload: openedContextOffloadStore,
|
|
@@ -2843,7 +2936,9 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
2843
2936
|
return result;
|
|
2844
2937
|
// Canonical receipts remain queryable even while the feature is disabled.
|
|
2845
2938
|
const visible = new Set((await stores.sessionStore.readMessagesSnapshot(input.sessionId))
|
|
2846
|
-
.filter((row) => row.type === 'user' &&
|
|
2939
|
+
.filter((row) => row.type === 'user' &&
|
|
2940
|
+
(row.turnId === assistantInputTurnId(row.id) ||
|
|
2941
|
+
row.turnId === legacyAssistantInputTurnId(row.id)))
|
|
2847
2942
|
.map((row) => row.id));
|
|
2848
2943
|
return {
|
|
2849
2944
|
ok: true,
|
|
@@ -2908,6 +3003,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
2908
3003
|
interactions.handlers,
|
|
2909
3004
|
sessionEffectCoordinator.handlers,
|
|
2910
3005
|
promptSuggestionCoordinator.handlers,
|
|
3006
|
+
sessionCheckins.handlers,
|
|
2911
3007
|
continuityCoordinator.handlers,
|
|
2912
3008
|
runtimeResources.handlers,
|
|
2913
3009
|
contextOperations.handlers,
|
|
@@ -2938,6 +3034,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
2938
3034
|
() => interactions.beginDrain(),
|
|
2939
3035
|
() => sessionEffects?.beginDrain(),
|
|
2940
3036
|
() => promptSuggestions?.beginDrain(),
|
|
3037
|
+
() => checkins?.beginDrain(),
|
|
2941
3038
|
],
|
|
2942
3039
|
close: [
|
|
2943
3040
|
async () => {
|
|
@@ -2953,6 +3050,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
2953
3050
|
() => workspaceExecution?.close(),
|
|
2954
3051
|
() => sessionEffects?.close(),
|
|
2955
3052
|
() => promptSuggestions?.close(),
|
|
3053
|
+
() => checkins?.close(),
|
|
2956
3054
|
() => messages.close(),
|
|
2957
3055
|
() => interactions.close(),
|
|
2958
3056
|
() => turnAccessRequests?.close(),
|
|
@@ -3022,6 +3120,12 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
3022
3120
|
catch (error) {
|
|
3023
3121
|
errors.push(error);
|
|
3024
3122
|
}
|
|
3123
|
+
try {
|
|
3124
|
+
await sessionCheckpoints?.close();
|
|
3125
|
+
}
|
|
3126
|
+
catch (error) {
|
|
3127
|
+
errors.push(error);
|
|
3128
|
+
}
|
|
3025
3129
|
try {
|
|
3026
3130
|
await closeRuntimeHostDomainModules(domainModules);
|
|
3027
3131
|
}
|
|
@@ -3044,6 +3148,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
3044
3148
|
};
|
|
3045
3149
|
return {
|
|
3046
3150
|
handlers,
|
|
3151
|
+
sessionCheckpoints,
|
|
3047
3152
|
moduleIds: Object.freeze(domainModules.map(({ id }) => id)),
|
|
3048
3153
|
workspaceExecution: requireWorkspaceExecution(workspaceExecution),
|
|
3049
3154
|
plugins: pluginPlatform,
|
|
@@ -3128,6 +3233,12 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
3128
3233
|
}
|
|
3129
3234
|
catch (error) {
|
|
3130
3235
|
const errors = [error];
|
|
3236
|
+
try {
|
|
3237
|
+
await sessionCheckpoints?.close();
|
|
3238
|
+
}
|
|
3239
|
+
catch (closeError) {
|
|
3240
|
+
errors.push(closeError);
|
|
3241
|
+
}
|
|
3131
3242
|
archiveEvidence?.close();
|
|
3132
3243
|
try {
|
|
3133
3244
|
await modelMetadataRefresh?.close();
|
|
@@ -3153,6 +3264,7 @@ export async function createExecutionRuntimeHostComposition(context, options = {
|
|
|
3153
3264
|
try {
|
|
3154
3265
|
await sessionEffects?.close();
|
|
3155
3266
|
await promptSuggestions?.close();
|
|
3267
|
+
await checkins?.close();
|
|
3156
3268
|
}
|
|
3157
3269
|
catch (closeError) {
|
|
3158
3270
|
errors.push(closeError);
|
|
@@ -215,6 +215,43 @@ export function createHostPromptSuggestionModel(input) {
|
|
|
215
215
|
return result.finishReason === 'length' ? undefined : result.text;
|
|
216
216
|
};
|
|
217
217
|
}
|
|
218
|
+
const CHECKIN_MAX_OUTPUT_TOKENS = 2_048;
|
|
219
|
+
const CHECKIN_REASONING_MAX_OUTPUT_TOKENS = 8_192;
|
|
220
|
+
/**
|
|
221
|
+
* Creates the root-scoped check-in call. It reads many Sessions, so it runs on
|
|
222
|
+
* the user's default model (resolved by the coordinator before any read)
|
|
223
|
+
* rather than borrowing any one Session's.
|
|
224
|
+
*/
|
|
225
|
+
export function createHostCheckinModel(input) {
|
|
226
|
+
const authority = createAuxiliaryModelCallAuthority(input);
|
|
227
|
+
return async ({ target, prompt, abortSignal, }) => {
|
|
228
|
+
try {
|
|
229
|
+
const callId = authority.newId();
|
|
230
|
+
const result = await runHostAuxiliaryModelCall(authority, {
|
|
231
|
+
transportContextId: callId,
|
|
232
|
+
header: target,
|
|
233
|
+
callKind: 'session_checkin',
|
|
234
|
+
callId: `session_checkin_${callId}`,
|
|
235
|
+
abortSignal,
|
|
236
|
+
reasoning: 'least',
|
|
237
|
+
buildRequest: (_target, thinkingLevel) => ({
|
|
238
|
+
prompt,
|
|
239
|
+
maxOutputTokens: thinkingLevel === 'off'
|
|
240
|
+
? CHECKIN_MAX_OUTPUT_TOKENS
|
|
241
|
+
: CHECKIN_REASONING_MAX_OUTPUT_TOKENS,
|
|
242
|
+
maxRetries: 0,
|
|
243
|
+
}),
|
|
244
|
+
});
|
|
245
|
+
return result.finishReason === 'length'
|
|
246
|
+
? { ok: false, errorClass: 'invalid_response' }
|
|
247
|
+
: { ok: true, text: result.text };
|
|
248
|
+
}
|
|
249
|
+
catch (error) {
|
|
250
|
+
const errorClass = auxiliaryModelErrorClass(error, abortSignal);
|
|
251
|
+
return { ok: false, errorClass: errorClass === 'persistence' ? 'unknown' : errorClass };
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
}
|
|
218
255
|
/** Creates tool-free Session title and recap calls on canonical Host model authority. */
|
|
219
256
|
export function createHostSessionEffectModel(input) {
|
|
220
257
|
const authority = createAuxiliaryModelCallAuthority(input);
|
|
@@ -649,14 +686,21 @@ async function resolveDailyReviewHeader(runtimePolicy, modelKey) {
|
|
|
649
686
|
thinkingLevel: 'off',
|
|
650
687
|
};
|
|
651
688
|
}
|
|
689
|
+
const header = await resolveDefaultModelHeader(runtimePolicy);
|
|
690
|
+
if (!header) {
|
|
691
|
+
throw new AuxiliaryModelCallConfigurationError('Daily Review has no canonical default model target');
|
|
692
|
+
}
|
|
693
|
+
return header;
|
|
694
|
+
}
|
|
695
|
+
/** The connection and model the user chose as default, or undefined when none is set. */
|
|
696
|
+
export async function resolveDefaultModelHeader(runtimePolicy) {
|
|
652
697
|
const catalog = await runtimePolicy.connectionCatalog.getSnapshot();
|
|
653
698
|
const target = catalog.defaultTarget;
|
|
654
699
|
const connection = target
|
|
655
700
|
? catalog.connections.find((candidate) => candidate.connectionId === target.connectionId)
|
|
656
701
|
: undefined;
|
|
657
|
-
if (!target || !connection)
|
|
658
|
-
|
|
659
|
-
}
|
|
702
|
+
if (!target || !connection)
|
|
703
|
+
return undefined;
|
|
660
704
|
return {
|
|
661
705
|
llmConnectionId: connection.connectionId,
|
|
662
706
|
llmConnectionSlug: connection.slug,
|
|
@@ -25,6 +25,8 @@ import { buildGoalTools } from '@maka/runtime/goal-tools';
|
|
|
25
25
|
import { isSessionNotFoundError } from '@maka/storage/execution-stores';
|
|
26
26
|
import { authenticateInteractiveGoalAuthorityWriter, } from '@maka/storage/goal-authority';
|
|
27
27
|
import { projectGoalState } from './goal-projection.js';
|
|
28
|
+
import { GOAL_EVENT_WAIT_SUMMARY_LIMITS, } from '../protocol/goal.js';
|
|
29
|
+
import { truncateUtf8 } from '@maka/core/diagnostic-log';
|
|
28
30
|
import { waitForHostedExecutionTerminal } from './hosted-execution-wait.js';
|
|
29
31
|
import { goalTurnOutcomeFromHostedExecution } from './goal-execution-coordinator.js';
|
|
30
32
|
import { buildGoalEvaluationContext } from './goal-evaluation-context.js';
|
|
@@ -34,6 +36,7 @@ export class HostGoalCoordinator {
|
|
|
34
36
|
'goal.query': (input) => this.#query(input.sessionId),
|
|
35
37
|
'goal.arm': (input) => this.#arm(input),
|
|
36
38
|
'goal.control': (input) => this.#control(input),
|
|
39
|
+
'goal.event-wait.cancel': (input) => this.#cancelEventWait(input),
|
|
37
40
|
};
|
|
38
41
|
manager;
|
|
39
42
|
continuation;
|
|
@@ -139,6 +142,7 @@ export class HostGoalCoordinator {
|
|
|
139
142
|
agentRunStore: options.stores.agentRunStore,
|
|
140
143
|
},
|
|
141
144
|
authority: (sessionId) => this.#authorityBySession.get(sessionId),
|
|
145
|
+
changed: this.#onProjectionChanged,
|
|
142
146
|
mutate: (sessionId, operation) => this.#mutateWait(sessionId, operation),
|
|
143
147
|
settleAdditional: (sessionId, tokensNow, controlLease) => this.#mutateGoal(async () => {
|
|
144
148
|
const goal = this.manager.get(sessionId);
|
|
@@ -158,8 +162,9 @@ export class HostGoalCoordinator {
|
|
|
158
162
|
gate: (sessionId) => this.continuation.gateEventWait(sessionId),
|
|
159
163
|
canRegister: (sessionId, turnId) => this.continuation.mutationStanding(sessionId, turnId).kind === 'held',
|
|
160
164
|
deliver: (pending) => this.continuation.recoverPendingContinuation(pending),
|
|
161
|
-
pause: (sessionId, reason, controlLease) => this.#mutateGoal(async () => {
|
|
162
|
-
if (!this.manager.matchesControlLease(sessionId, controlLease)
|
|
165
|
+
pause: (sessionId, reason, controlLease, waitId) => this.#mutateGoal(async () => {
|
|
166
|
+
if (!this.manager.matchesControlLease(sessionId, controlLease) ||
|
|
167
|
+
this.#authorityBySession.get(sessionId)?.record.activeEventWait?.waitId !== waitId)
|
|
163
168
|
return;
|
|
164
169
|
this.manager.pause(sessionId, { reason });
|
|
165
170
|
this.continuation.invalidateSession(sessionId);
|
|
@@ -245,8 +250,125 @@ export class HostGoalCoordinator {
|
|
|
245
250
|
await this.eventWaitBridge?.start();
|
|
246
251
|
}
|
|
247
252
|
readProjection(sessionId) {
|
|
253
|
+
// Canonical/query callers hold the Session lane. Do not wait for the
|
|
254
|
+
// mutation lane here: a committed wait write can have a delayed receipt
|
|
255
|
+
// while Root admission must still publish and start. #project rechecks the
|
|
256
|
+
// adopted binding after I/O and excludes durably admitted/suppressed waits.
|
|
257
|
+
return this.#project(sessionId);
|
|
258
|
+
}
|
|
259
|
+
async #project(sessionId) {
|
|
260
|
+
const authority = this.#authorityBySession.get(sessionId);
|
|
261
|
+
const gate = authority?.record.activeEventWait;
|
|
262
|
+
const wait = gate && this.#stores.eventWaitStore
|
|
263
|
+
? await this.#stores.eventWaitStore.read({ sessionId, waitId: gate.waitId })
|
|
264
|
+
: undefined;
|
|
248
265
|
const goal = this.manager.get(sessionId);
|
|
249
|
-
|
|
266
|
+
if (!goal)
|
|
267
|
+
return null;
|
|
268
|
+
const projection = projectGoalState(goal);
|
|
269
|
+
const current = this.#authorityBySession.get(sessionId);
|
|
270
|
+
if (!wait ||
|
|
271
|
+
!gate ||
|
|
272
|
+
!current ||
|
|
273
|
+
current.record.activeEventWait?.waitId !== gate.waitId ||
|
|
274
|
+
!sameGoalControlLease(current.record.controlLease, wait.record.goalControlLease) ||
|
|
275
|
+
!this.manager.matchesControlLease(sessionId, wait.record.goalControlLease) ||
|
|
276
|
+
wait.record.delivery ||
|
|
277
|
+
wait.record.status === 'cancelled' ||
|
|
278
|
+
!['active', 'waiting'].includes(goal.status))
|
|
279
|
+
return projection;
|
|
280
|
+
const r = wait.record, observation = r.observation;
|
|
281
|
+
// Checking is an attempt reservation, not a new source fact. Its retained
|
|
282
|
+
// checkpoint describes the last completed observation until this read settles.
|
|
283
|
+
const observationOutcome = observation?.outcome === 'checking' && observation.lastObservedAt !== null
|
|
284
|
+
? observation.consecutiveErrors > 0
|
|
285
|
+
? 'unknown'
|
|
286
|
+
: 'pending'
|
|
287
|
+
: observation?.outcome;
|
|
288
|
+
return {
|
|
289
|
+
...projection,
|
|
290
|
+
eventWait: {
|
|
291
|
+
waitId: r.waitId,
|
|
292
|
+
controlGeneration: r.goalControlLease.generation,
|
|
293
|
+
waitRevision: wait.authorityRevision,
|
|
294
|
+
resource: {
|
|
295
|
+
providerId: r.resource.providerId,
|
|
296
|
+
resourceType: r.resource.resourceType,
|
|
297
|
+
resourceId: truncateUtf8(r.resource.resourceId, GOAL_EVENT_WAIT_SUMMARY_LIMITS.resourceIdBytes, '…'),
|
|
298
|
+
},
|
|
299
|
+
reason: gate.reason,
|
|
300
|
+
deadlineAt: r.deadlineAt,
|
|
301
|
+
phase: r.status === 'waiting' ? 'observing' : 'awaiting_admission',
|
|
302
|
+
observation: r.status !== 'waiting'
|
|
303
|
+
? null
|
|
304
|
+
: {
|
|
305
|
+
state: observationOutcome === 'unknown'
|
|
306
|
+
? 'unknown'
|
|
307
|
+
: observationOutcome === 'pending'
|
|
308
|
+
? 'pending'
|
|
309
|
+
: 'checking',
|
|
310
|
+
lastObservedAt: observation?.lastObservedAt ?? null,
|
|
311
|
+
reasonCode: observation?.reason
|
|
312
|
+
? truncateUtf8(observation.reason, GOAL_EVENT_WAIT_SUMMARY_LIMITS.reasonCodeBytes, '…')
|
|
313
|
+
: null,
|
|
314
|
+
},
|
|
315
|
+
outcome: r.status === 'resolved'
|
|
316
|
+
? r.resolution.outcome
|
|
317
|
+
: r.status === 'expired'
|
|
318
|
+
? 'expired'
|
|
319
|
+
: null,
|
|
320
|
+
},
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
#cancelEventWait(input) {
|
|
324
|
+
return this.#sessionAdmission.run(input.sessionId, () => this.#mutateGoal(async () => {
|
|
325
|
+
if (this.#draining)
|
|
326
|
+
return hostDraining();
|
|
327
|
+
let header;
|
|
328
|
+
try {
|
|
329
|
+
header = await this.#stores.sessionStore.readHeaderSnapshot(input.sessionId);
|
|
330
|
+
}
|
|
331
|
+
catch (error) {
|
|
332
|
+
if (isSessionNotFoundError(error))
|
|
333
|
+
return notFound('Session does not exist');
|
|
334
|
+
throw error;
|
|
335
|
+
}
|
|
336
|
+
if (header.isArchived)
|
|
337
|
+
return sessionArchived('Archived Session cannot cancel a wait');
|
|
338
|
+
const wait = await this.#stores.eventWaitStore?.read({
|
|
339
|
+
sessionId: input.sessionId,
|
|
340
|
+
waitId: input.waitId,
|
|
341
|
+
});
|
|
342
|
+
const current = this.#authorityBySession.get(input.sessionId)?.record;
|
|
343
|
+
let outcome = 'conflict';
|
|
344
|
+
if (wait?.record.goalControlLease.goalId === input.goalId &&
|
|
345
|
+
wait.record.goalControlLease.generation === input.controlGeneration) {
|
|
346
|
+
if (wait.record.delivery?.kind === 'admitted')
|
|
347
|
+
outcome = 'already_admitted';
|
|
348
|
+
else if (wait.record.status === 'cancelled' ||
|
|
349
|
+
wait.record.delivery?.kind === 'suppressed')
|
|
350
|
+
outcome = 'already_cancelled';
|
|
351
|
+
else if (current?.activeEventWait?.waitId === input.waitId &&
|
|
352
|
+
current.goal.id === input.goalId &&
|
|
353
|
+
current.controlLease.generation === input.controlGeneration &&
|
|
354
|
+
current.goal.revision === input.expectedGoalRevision) {
|
|
355
|
+
this.manager.pause(input.sessionId, {
|
|
356
|
+
reason: 'Event wait cancelled. The background task keeps running.',
|
|
357
|
+
});
|
|
358
|
+
this.continuation.invalidateSession(input.sessionId);
|
|
359
|
+
await this.#flushGoalPersistence();
|
|
360
|
+
outcome = 'cancelled';
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return {
|
|
364
|
+
ok: true,
|
|
365
|
+
result: {
|
|
366
|
+
sessionId: input.sessionId,
|
|
367
|
+
outcome,
|
|
368
|
+
goal: await this.#project(input.sessionId),
|
|
369
|
+
},
|
|
370
|
+
};
|
|
371
|
+
}));
|
|
250
372
|
}
|
|
251
373
|
beginObservedTurn(sessionId, turnId) {
|
|
252
374
|
return this.continuation.beginObservedTurn(sessionId, turnId);
|
|
@@ -391,7 +513,7 @@ export class HostGoalCoordinator {
|
|
|
391
513
|
}
|
|
392
514
|
return {
|
|
393
515
|
ok: true,
|
|
394
|
-
result: { sessionId, goal: this.readProjection(sessionId) },
|
|
516
|
+
result: { sessionId, goal: await this.readProjection(sessionId) },
|
|
395
517
|
};
|
|
396
518
|
});
|
|
397
519
|
}
|