maka-agent 0.2.2-dev.92.20261019 → 0.2.2-dev.97.20261024
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -30,7 +30,28 @@ class AssistantRuntime {
|
|
|
30
30
|
directory;
|
|
31
31
|
dependencies;
|
|
32
32
|
tools = [];
|
|
33
|
+
internalTools = [];
|
|
34
|
+
toolFilters = [];
|
|
33
35
|
bot = new AssistantBotBridge();
|
|
36
|
+
backgroundSessions = [];
|
|
37
|
+
sessionAccess = [];
|
|
38
|
+
hasSessionAccess(sessionId) {
|
|
39
|
+
return (this.bot.isConversation(sessionId) ||
|
|
40
|
+
this.bot.isWorker(sessionId) ||
|
|
41
|
+
this.backgroundSessions.some((read) => read().includes(sessionId)) ||
|
|
42
|
+
this.sessionAccess.some((allows) => allows(sessionId)));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The only visibility policy. Catalogs and execution both use it, so a tool hidden
|
|
46
|
+
* from a Session cannot run in that Session either.
|
|
47
|
+
*/
|
|
48
|
+
visibleTools(sessionId, tools) {
|
|
49
|
+
const nativeNames = new Set(this.tools.map((tool) => tool.name));
|
|
50
|
+
const allowed = this.hasSessionAccess(sessionId)
|
|
51
|
+
? tools
|
|
52
|
+
: tools.filter((tool) => !nativeNames.has(tool.name));
|
|
53
|
+
return this.toolFilters.reduce((current, filter) => filter(sessionId, current), allowed);
|
|
54
|
+
}
|
|
34
55
|
sections = [];
|
|
35
56
|
contexts = [];
|
|
36
57
|
checks = [];
|
|
@@ -53,18 +74,19 @@ class AssistantRuntime {
|
|
|
53
74
|
if (this.initialized)
|
|
54
75
|
throw Error('Personal assistant already initialized');
|
|
55
76
|
const settings = await this.loadSettings(legacy, entries);
|
|
56
|
-
const backgroundSessions = [];
|
|
57
77
|
const services = {
|
|
58
78
|
bot: this.bot,
|
|
59
|
-
backgroundSessions: { register: (read) => backgroundSessions.push(read) },
|
|
79
|
+
backgroundSessions: { register: (read) => this.backgroundSessions.push(read) },
|
|
60
80
|
...this.dependencies,
|
|
61
81
|
onClose: (dispose) => this.disposers.push(dispose),
|
|
62
82
|
onStart: (start) => this.starters.push(start),
|
|
63
83
|
tools: {
|
|
84
|
+
filter: (filter) => this.toolFilters.push(filter),
|
|
85
|
+
registerSessionAccess: (allows) => this.sessionAccess.push(allows),
|
|
64
86
|
register: (tool) => {
|
|
65
87
|
if (this.tools.some((t) => t.name === tool.name))
|
|
66
88
|
throw Error(`Duplicate assistant tool: ${tool.name}`);
|
|
67
|
-
|
|
89
|
+
const internalTool = {
|
|
68
90
|
...tool,
|
|
69
91
|
impl: (input, call) => {
|
|
70
92
|
if (this.closing)
|
|
@@ -84,9 +106,26 @@ class AssistantRuntime {
|
|
|
84
106
|
return this.dependencies.agents.withInvocation(scoped, () => tool.impl(input, scoped));
|
|
85
107
|
});
|
|
86
108
|
},
|
|
109
|
+
};
|
|
110
|
+
this.internalTools.push(internalTool);
|
|
111
|
+
this.tools.push({
|
|
112
|
+
...internalTool,
|
|
113
|
+
impl: (input, call) => {
|
|
114
|
+
if (this.closing)
|
|
115
|
+
throw Error('Personal assistant is shutting down');
|
|
116
|
+
if (!this.hasSessionAccess(call.sessionId))
|
|
117
|
+
throw Error('Personal assistant tools are unavailable in this session');
|
|
118
|
+
if (!this.visibleTools(call.sessionId, [tool]).length)
|
|
119
|
+
throw Error('Personal assistant tool is unavailable in this session');
|
|
120
|
+
return internalTool.impl(input, call);
|
|
121
|
+
},
|
|
87
122
|
});
|
|
88
123
|
},
|
|
89
|
-
|
|
124
|
+
// Only Host module APIs use this resolver. They retain the caller's source
|
|
125
|
+
// permissions (e.g. ordinary-chat original links) without exposing model tools.
|
|
126
|
+
resolve: (sessionId) => sessionId
|
|
127
|
+
? this.dependencies.resolveTools(sessionId, this.internalTools)
|
|
128
|
+
: { tools: this.internalTools },
|
|
90
129
|
},
|
|
91
130
|
systemPrompt: {
|
|
92
131
|
section: (value) => this.sections.push(value),
|
|
@@ -114,7 +153,7 @@ class AssistantRuntime {
|
|
|
114
153
|
])
|
|
115
154
|
await initialize(services, settings[name].directory, settings[name].config);
|
|
116
155
|
await this.dependencies.markBackgroundSessions([
|
|
117
|
-
...new Set(backgroundSessions.flatMap((read) => read())),
|
|
156
|
+
...new Set(this.backgroundSessions.flatMap((read) => read())),
|
|
118
157
|
]);
|
|
119
158
|
this.initialized = true;
|
|
120
159
|
}
|
|
@@ -427,6 +466,11 @@ export class PersonalAssistantService {
|
|
|
427
466
|
hasInboxMessage(sessionId, id) {
|
|
428
467
|
return this.enabled && this.runtime.bot.hasUserMessage(sessionId, id);
|
|
429
468
|
}
|
|
469
|
+
filterTools(sessionId, tools) {
|
|
470
|
+
if (!this.enabled)
|
|
471
|
+
return tools;
|
|
472
|
+
return this.runtime.visibleTools(sessionId, tools);
|
|
473
|
+
}
|
|
430
474
|
toolCeiling(sessionId) {
|
|
431
475
|
return this.enabled && this.runtime.bot.isWorker(sessionId)
|
|
432
476
|
? this.runtime.tools.filter((tool) => BOT_TOOLS.has(tool.name))
|
|
@@ -20,7 +20,12 @@ import { GOAL_CONDITION_TEXT_LIMIT, GOAL_MAX_ITERATIONS_LIMIT, GOAL_REASON_TEXT_
|
|
|
20
20
|
import { requireCount, requireEncodedByteLimit, requireEntityId, requireExactRecord, requireUtf8String, } from './codec.js';
|
|
21
21
|
import { invalidProtocolFrame } from './errors.js';
|
|
22
22
|
import { defineOperation } from './operation-spec.js';
|
|
23
|
-
export const GOAL_RESULT_MAX_BYTES =
|
|
23
|
+
export const GOAL_RESULT_MAX_BYTES = 16 * 1024;
|
|
24
|
+
/** Display bounds; canonical ShellRun references fit in full. */
|
|
25
|
+
export const GOAL_EVENT_WAIT_SUMMARY_LIMITS = Object.freeze({
|
|
26
|
+
resourceIdBytes: 512,
|
|
27
|
+
reasonCodeBytes: 128,
|
|
28
|
+
});
|
|
24
29
|
const QUERY_ERRORS = [
|
|
25
30
|
'host_not_ready',
|
|
26
31
|
'host_draining',
|
|
@@ -31,6 +36,17 @@ const QUERY_ERRORS = [
|
|
|
31
36
|
const CONTROL_ERRORS = [...QUERY_ERRORS, 'session_archived', 'operation_conflict'];
|
|
32
37
|
const ARM_ERRORS = CONTROL_ERRORS;
|
|
33
38
|
export const GOAL_OPERATION_SPECS = {
|
|
39
|
+
'goal.event-wait.cancel': defineOperation({
|
|
40
|
+
mode: 'control',
|
|
41
|
+
availability: 'ready',
|
|
42
|
+
errors: CONTROL_ERRORS,
|
|
43
|
+
decodeInput: decodeGoalEventWaitCancelInput,
|
|
44
|
+
decodeOutput: decodeGoalEventWaitCancelResult,
|
|
45
|
+
assertOutputForInput(input, output) {
|
|
46
|
+
if (input.sessionId !== output.sessionId)
|
|
47
|
+
throw invalidProtocolFrame('Wait cancellation belongs to another Session');
|
|
48
|
+
},
|
|
49
|
+
}),
|
|
34
50
|
'goal.query': defineOperation({
|
|
35
51
|
mode: 'query',
|
|
36
52
|
availability: 'ready',
|
|
@@ -85,6 +101,7 @@ export function decodeGoalProjection(value) {
|
|
|
85
101
|
'lastReason',
|
|
86
102
|
'achievedAt',
|
|
87
103
|
'pausedAt',
|
|
104
|
+
'eventWait',
|
|
88
105
|
]);
|
|
89
106
|
const condition = requireUtf8String(record.condition, 'Goal condition', GOAL_CONDITION_TEXT_LIMIT.utf8Bytes);
|
|
90
107
|
if (condition.length > GOAL_CONDITION_TEXT_LIMIT.codeUnits) {
|
|
@@ -107,6 +124,7 @@ export function decodeGoalProjection(value) {
|
|
|
107
124
|
lastReason,
|
|
108
125
|
achievedAt: requireNullableCount(record.achievedAt, 'Goal achievedAt'),
|
|
109
126
|
pausedAt: requireNullableCount(record.pausedAt, 'Goal pausedAt'),
|
|
127
|
+
eventWait: record.eventWait === null ? null : decodeGoalEventWaitProjection(record.eventWait),
|
|
110
128
|
};
|
|
111
129
|
}
|
|
112
130
|
function decodeGoalQueryInput(value) {
|
|
@@ -220,3 +238,103 @@ function requireNullableCount(value, label) {
|
|
|
220
238
|
return null;
|
|
221
239
|
return requireCount(value, label);
|
|
222
240
|
}
|
|
241
|
+
export function decodeGoalEventWaitProjection(value) {
|
|
242
|
+
const r = requireExactRecord(value, 'Goal event wait', [
|
|
243
|
+
'waitId',
|
|
244
|
+
'controlGeneration',
|
|
245
|
+
'waitRevision',
|
|
246
|
+
'resource',
|
|
247
|
+
'reason',
|
|
248
|
+
'deadlineAt',
|
|
249
|
+
'phase',
|
|
250
|
+
'observation',
|
|
251
|
+
'outcome',
|
|
252
|
+
]);
|
|
253
|
+
const resource = requireExactRecord(r.resource, 'Wait resource', [
|
|
254
|
+
'providerId',
|
|
255
|
+
'resourceType',
|
|
256
|
+
'resourceId',
|
|
257
|
+
]);
|
|
258
|
+
if (r.phase !== 'observing' && r.phase !== 'awaiting_admission')
|
|
259
|
+
throw invalidProtocolFrame('Invalid wait phase');
|
|
260
|
+
if (r.outcome !== null &&
|
|
261
|
+
r.outcome !== 'satisfied' &&
|
|
262
|
+
r.outcome !== 'invalidated' &&
|
|
263
|
+
r.outcome !== 'source_unavailable' &&
|
|
264
|
+
r.outcome !== 'expired')
|
|
265
|
+
throw invalidProtocolFrame('Invalid wait outcome');
|
|
266
|
+
let observation = null;
|
|
267
|
+
if (r.observation !== null) {
|
|
268
|
+
const o = requireExactRecord(r.observation, 'Wait observation', [
|
|
269
|
+
'state',
|
|
270
|
+
'lastObservedAt',
|
|
271
|
+
'reasonCode',
|
|
272
|
+
]);
|
|
273
|
+
if (o.state !== 'checking' && o.state !== 'pending' && o.state !== 'unknown')
|
|
274
|
+
throw invalidProtocolFrame('Invalid observation state');
|
|
275
|
+
observation = {
|
|
276
|
+
state: o.state,
|
|
277
|
+
lastObservedAt: requireNullableCount(o.lastObservedAt, 'Observation time'),
|
|
278
|
+
reasonCode: o.reasonCode === null
|
|
279
|
+
? null
|
|
280
|
+
: requireUtf8String(o.reasonCode, 'Observation reason', GOAL_EVENT_WAIT_SUMMARY_LIMITS.reasonCodeBytes),
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
if ((r.phase === 'observing' && (observation === null || r.outcome !== null)) ||
|
|
284
|
+
(r.phase === 'awaiting_admission' && (observation !== null || r.outcome === null)))
|
|
285
|
+
throw invalidProtocolFrame('Inconsistent wait phase');
|
|
286
|
+
const reason = requireNullableGoalReason(r.reason);
|
|
287
|
+
if (reason === null)
|
|
288
|
+
throw invalidProtocolFrame('Invalid wait reason');
|
|
289
|
+
return {
|
|
290
|
+
waitId: requireEntityId(r.waitId, 'waitId'),
|
|
291
|
+
controlGeneration: requireCount(r.controlGeneration, 'Control generation'),
|
|
292
|
+
waitRevision: requireCount(r.waitRevision, 'Wait revision'),
|
|
293
|
+
resource: {
|
|
294
|
+
providerId: requireWaitTypeId(resource.providerId, 'Wait provider'),
|
|
295
|
+
resourceType: requireWaitTypeId(resource.resourceType, 'Wait resource type'),
|
|
296
|
+
resourceId: requireUtf8String(resource.resourceId, 'Wait reference', GOAL_EVENT_WAIT_SUMMARY_LIMITS.resourceIdBytes),
|
|
297
|
+
},
|
|
298
|
+
reason,
|
|
299
|
+
deadlineAt: requireCount(r.deadlineAt, 'Wait deadline'),
|
|
300
|
+
phase: r.phase,
|
|
301
|
+
observation,
|
|
302
|
+
outcome: r.outcome,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
function decodeGoalEventWaitCancelInput(value) {
|
|
306
|
+
const r = requireExactRecord(value, 'Wait cancellation', [
|
|
307
|
+
'sessionId',
|
|
308
|
+
'goalId',
|
|
309
|
+
'controlGeneration',
|
|
310
|
+
'waitId',
|
|
311
|
+
'expectedGoalRevision',
|
|
312
|
+
]);
|
|
313
|
+
return {
|
|
314
|
+
sessionId: requireEntityId(r.sessionId, 'sessionId'),
|
|
315
|
+
goalId: requireEntityId(r.goalId, 'goalId'),
|
|
316
|
+
waitId: requireEntityId(r.waitId, 'waitId'),
|
|
317
|
+
controlGeneration: requireCount(r.controlGeneration, 'Control generation'),
|
|
318
|
+
expectedGoalRevision: requireCount(r.expectedGoalRevision, 'Goal revision'),
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
function decodeGoalEventWaitCancelResult(value) {
|
|
322
|
+
requireEncodedByteLimit(value, 'Wait cancellation result', GOAL_RESULT_MAX_BYTES);
|
|
323
|
+
const r = requireExactRecord(value, 'Wait cancellation result', ['sessionId', 'outcome', 'goal']);
|
|
324
|
+
if (r.outcome !== 'cancelled' &&
|
|
325
|
+
r.outcome !== 'already_cancelled' &&
|
|
326
|
+
r.outcome !== 'already_admitted' &&
|
|
327
|
+
r.outcome !== 'conflict')
|
|
328
|
+
throw invalidProtocolFrame('Invalid cancellation outcome');
|
|
329
|
+
const sessionId = requireEntityId(r.sessionId, 'sessionId');
|
|
330
|
+
const goal = r.goal === null ? null : decodeGoalProjection(r.goal);
|
|
331
|
+
if (goal && goal.sessionId !== sessionId)
|
|
332
|
+
throw invalidProtocolFrame('Wait cancellation Goal belongs to another Session');
|
|
333
|
+
return { sessionId, outcome: r.outcome, goal };
|
|
334
|
+
}
|
|
335
|
+
function requireWaitTypeId(value, label) {
|
|
336
|
+
const id = requireUtf8String(value, label, 128);
|
|
337
|
+
if (!/^[A-Za-z0-9_.-]{1,128}$/.test(id))
|
|
338
|
+
throw invalidProtocolFrame(`Invalid ${label}`);
|
|
339
|
+
return id;
|
|
340
|
+
}
|
|
@@ -69,7 +69,13 @@ export const RUNTIME_HOST_PROTOCOL_VERSION = 0;
|
|
|
69
69
|
// Increment when the same protocol version no longer guarantees safe Client-Host
|
|
70
70
|
// interoperability. Mismatches are rejected before domain commands are admitted.
|
|
71
71
|
// Re-check against main before merging; sibling PRs may use the same next epoch.
|
|
72
|
-
export const RUNTIME_HOST_COMPATIBILITY_EPOCH =
|
|
72
|
+
export const RUNTIME_HOST_COMPATIBILITY_EPOCH = 229;
|
|
73
|
+
// 229: Session check-in proposes cards for unfinished work across Sessions.
|
|
74
|
+
// 228: Executor catalog queries support per-agent filtering and process-free inventory.
|
|
75
|
+
// Older peers reject the executorId and listOnly fields in the strict query decoder.
|
|
76
|
+
// 227: Goal projections carry eventWait and support goal.event-wait.cancel.
|
|
77
|
+
// Older peers cannot decode the wait summary or cancel a specific wait.
|
|
78
|
+
// 226: assistant.allocate-workspace allocates a Host-owned fallback for projectless assistants.
|
|
73
79
|
// 225: Goal successor transcript origins carry typed event-wait provenance.
|
|
74
80
|
// Older peers reject the additional field in the strict stored-message decoder.
|
|
75
81
|
// 224: Assistant conversation admission supports Inbox receipts without a model Turn,
|
|
@@ -57,6 +57,7 @@ import { SESSION_REVISION_OPERATION_SPECS } from './session-revision.js';
|
|
|
57
57
|
import { SESSION_BUNDLE_OPERATION_SPECS } from './session-bundle.js';
|
|
58
58
|
import { SESSION_RETIREMENT_OPERATION_SPECS } from './session-retirement.js';
|
|
59
59
|
import { PROMPT_SUGGESTION_OPERATION_SPECS } from './prompt-suggestions.js';
|
|
60
|
+
import { SESSION_CHECKIN_OPERATION_SPECS } from './session-checkin.js';
|
|
60
61
|
import { SESSION_EFFECT_OPERATION_SPECS } from './session-effects.js';
|
|
61
62
|
import { SKILL_CATALOG_OPERATION_SPECS } from './skill-catalog.js';
|
|
62
63
|
import { STORAGE_RETENTION_OPERATION_SPECS } from './storage-retention.js';
|
|
@@ -98,6 +99,7 @@ export * from './session-turns.js';
|
|
|
98
99
|
export * from './session-todo.js';
|
|
99
100
|
export * from './session-effects.js';
|
|
100
101
|
export * from './prompt-suggestions.js';
|
|
102
|
+
export * from './session-checkin.js';
|
|
101
103
|
export * from './skill-catalog.js';
|
|
102
104
|
export * from './storage-retention.js';
|
|
103
105
|
export * from './storage-usage.js';
|
|
@@ -105,7 +107,10 @@ export * from './usage-pricing.js';
|
|
|
105
107
|
export * from './web-search.js';
|
|
106
108
|
export * from './recall.js';
|
|
107
109
|
export * from './workspace.js';
|
|
108
|
-
export const HOST_OPERATION_SPECS = composeOperationSpecMaps(HOST_BOOTSTRAP_OPERATION_SPECS, HOST_RESOURCE_OPERATION_SPECS, PEER_MESH_OPERATION_SPECS, HOSTED_EXECUTION_OPERATION_SPECS, ACCESS_AUTHORITY_OPERATION_SPECS, SESSION_COLLABORATION_OPERATION_SPECS, AGENT_GRAPH_OPERATION_SPECS, GOAL_OPERATION_SPECS, TURN_OPERATION_SPECS, CONTEXT_OPERATION_SPECS, CONNECTION_EFFECT_OPERATION_SPECS, DAILY_REVIEW_OPERATION_SPECS, EXECUTION_INSPECT_OPERATION_SPECS, EXTERNAL_SESSION_OPERATION_SPECS, RUNTIME_POLICY_OPERATION_SPECS, RUNTIME_RESOURCE_OPERATION_SPECS, SCHEDULED_TASK_OPERATION_SPECS, PLAN_OPERATION_SPECS, PROJECT_CATALOG_OPERATION_SPECS, MESSAGE_OPERATION_SPECS, SESSION_TODO_OPERATION_SPECS, INTERACTION_OPERATION_SPECS, SESSION_CONTINUITY_OPERATION_SPECS, SESSION_TRANSCRIPT_OPERATION_SPECS, SESSION_TURNS_OPERATION_SPECS, SESSION_CATALOG_OPERATION_SPECS, SESSION_EFFECT_OPERATION_SPECS,
|
|
110
|
+
export const HOST_OPERATION_SPECS = composeOperationSpecMaps(HOST_BOOTSTRAP_OPERATION_SPECS, HOST_RESOURCE_OPERATION_SPECS, PEER_MESH_OPERATION_SPECS, HOSTED_EXECUTION_OPERATION_SPECS, ACCESS_AUTHORITY_OPERATION_SPECS, SESSION_COLLABORATION_OPERATION_SPECS, AGENT_GRAPH_OPERATION_SPECS, GOAL_OPERATION_SPECS, TURN_OPERATION_SPECS, CONTEXT_OPERATION_SPECS, CONNECTION_EFFECT_OPERATION_SPECS, DAILY_REVIEW_OPERATION_SPECS, EXECUTION_INSPECT_OPERATION_SPECS, EXTERNAL_SESSION_OPERATION_SPECS, RUNTIME_POLICY_OPERATION_SPECS, RUNTIME_RESOURCE_OPERATION_SPECS, SCHEDULED_TASK_OPERATION_SPECS, PLAN_OPERATION_SPECS, PROJECT_CATALOG_OPERATION_SPECS, MESSAGE_OPERATION_SPECS, SESSION_TODO_OPERATION_SPECS, INTERACTION_OPERATION_SPECS, SESSION_CONTINUITY_OPERATION_SPECS, SESSION_TRANSCRIPT_OPERATION_SPECS, SESSION_TURNS_OPERATION_SPECS, SESSION_CATALOG_OPERATION_SPECS, SESSION_EFFECT_OPERATION_SPECS,
|
|
111
|
+
// One argument for both: the disjoint-key check across every map passed here
|
|
112
|
+
// already sits at TypeScript's type instantiation depth limit.
|
|
113
|
+
{ ...PROMPT_SUGGESTION_OPERATION_SPECS, ...SESSION_CHECKIN_OPERATION_SPECS }, SESSION_REVISION_OPERATION_SPECS, SESSION_BUNDLE_OPERATION_SPECS, SESSION_RETIREMENT_OPERATION_SPECS, ARTIFACT_OPERATION_SPECS, SKILL_CATALOG_OPERATION_SPECS, USAGE_PRICING_OPERATION_SPECS, STORAGE_USAGE_OPERATION_SPECS, STORAGE_RETENTION_OPERATION_SPECS, composeOperationSpecMaps(MEMORY_OPERATION_SPECS, PERSONAL_ASSISTANT_OPERATION_SPECS), OAUTH_OPERATION_SPECS, EXTERNAL_AGENT_SETUP_OPERATION_SPECS, CLIENT_CAPABILITY_OPERATION_SPECS, WEB_SEARCH_OPERATION_SPECS, NETWORK_PROXY_OPERATION_SPECS, RECALL_OPERATION_SPECS, CONFIGURATION_OPERATION_SPECS, WORKHUB_COORDINATION_OPERATION_SPECS, PLUGIN_PLATFORM_OPERATION_SPECS);
|
|
109
114
|
// Remote credentials are fail-closed: adding a protocol operation does not
|
|
110
115
|
// grant it to remote owners until this policy is deliberately updated.
|
|
111
116
|
export const REMOTE_OWNER_OPERATION_GRANTS = Object.freeze([
|
|
@@ -152,6 +157,7 @@ export const REMOTE_OWNER_OPERATION_GRANTS = Object.freeze([
|
|
|
152
157
|
'external-session.source.query',
|
|
153
158
|
'goal.arm',
|
|
154
159
|
'goal.control',
|
|
160
|
+
'goal.event-wait.cancel',
|
|
155
161
|
'goal.query',
|
|
156
162
|
'host.diagnostics.query',
|
|
157
163
|
'host.resources.query',
|
|
@@ -197,6 +203,7 @@ export const REMOTE_OWNER_OPERATION_GRANTS = Object.freeze([
|
|
|
197
203
|
'scheduled-task.query',
|
|
198
204
|
'session.branch.create',
|
|
199
205
|
'session.catalog.query',
|
|
206
|
+
'session.checkin.generate',
|
|
200
207
|
'session.configuration.update',
|
|
201
208
|
'session.create',
|
|
202
209
|
'session.execution_boundary.query',
|
|
@@ -93,13 +93,19 @@ export const PLUGIN_PLATFORM_OPERATION_SPECS = {
|
|
|
93
93
|
decodeInput: (value) => {
|
|
94
94
|
const record = requireRecord(value, 'Executor query');
|
|
95
95
|
if (record.kind === 'catalog') {
|
|
96
|
-
const input = requireShapedRecord(record, 'Executor catalog', ['kind', 'cwd'], ['refresh']);
|
|
96
|
+
const input = requireShapedRecord(record, 'Executor catalog', ['kind', 'cwd'], ['refresh', 'executorId', 'listOnly']);
|
|
97
97
|
if (input.refresh !== undefined && typeof input.refresh !== 'boolean')
|
|
98
98
|
throw invalidProtocolFrame('Invalid executor refresh flag');
|
|
99
|
+
if (input.listOnly !== undefined && typeof input.listOnly !== 'boolean')
|
|
100
|
+
throw invalidProtocolFrame('Invalid executor inventory flag');
|
|
99
101
|
return {
|
|
100
102
|
kind: 'catalog',
|
|
101
103
|
cwd: requireString(input.cwd, 'cwd', 4096),
|
|
102
104
|
...(input.refresh ? { refresh: true } : {}),
|
|
105
|
+
...(input.executorId !== undefined
|
|
106
|
+
? { executorId: requireId(input.executorId, 'executorId') }
|
|
107
|
+
: {}),
|
|
108
|
+
...(input.listOnly ? { listOnly: true } : {}),
|
|
103
109
|
};
|
|
104
110
|
}
|
|
105
111
|
const input = requireExactRecord(record, 'Executor conversation', ['kind', 'sessionId']);
|
|
@@ -0,0 +1,133 @@
|
|
|
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 { CHECKIN_INSTRUCTION_MAX_CHARS, CHECKIN_MAX_CARDS, CHECKIN_QUOTE_MAX_CHARS, CHECKIN_TITLE_MAX_CHARS, isCheckinCardAction, isCheckinEvidenceSource, } from '@maka/core/session-checkin';
|
|
20
|
+
import { requireCount, requireEntityId, requireExactRecord, requireRecord, requireShapedRecord, } from './codec.js';
|
|
21
|
+
import { invalidProtocolFrame } from './errors.js';
|
|
22
|
+
import { defineOperation } from './operation-spec.js';
|
|
23
|
+
const SESSION_NAME_MAX_BYTES = 1024;
|
|
24
|
+
const SESSION_CHECKIN_FAILURE_CLASSES = [
|
|
25
|
+
'aborted',
|
|
26
|
+
'timeout',
|
|
27
|
+
'configuration',
|
|
28
|
+
'provider',
|
|
29
|
+
'invalid_response',
|
|
30
|
+
'unknown',
|
|
31
|
+
];
|
|
32
|
+
export const SESSION_CHECKIN_OPERATION_SPECS = {
|
|
33
|
+
'session.checkin.generate': defineOperation({
|
|
34
|
+
mode: 'command',
|
|
35
|
+
availability: 'ready',
|
|
36
|
+
errors: [
|
|
37
|
+
'host_not_ready',
|
|
38
|
+
'host_draining',
|
|
39
|
+
'operation_unavailable',
|
|
40
|
+
'operation_conflict',
|
|
41
|
+
'internal_failure',
|
|
42
|
+
],
|
|
43
|
+
decodeInput: decodeSessionCheckinGenerateInput,
|
|
44
|
+
decodeOutput: decodeSessionCheckinGenerateResult,
|
|
45
|
+
assertOutputForInput: (input, output) => {
|
|
46
|
+
if (input.effectId !== output.effectId) {
|
|
47
|
+
throw invalidProtocolFrame('Session check-in changed effect identity');
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
}),
|
|
51
|
+
};
|
|
52
|
+
export function decodeSessionCheckinGenerateInput(value) {
|
|
53
|
+
const input = requireExactRecord(value, 'Session check-in input', ['effectId', 'since']);
|
|
54
|
+
return {
|
|
55
|
+
effectId: requireEntityId(input.effectId, 'effectId'),
|
|
56
|
+
since: input.since === null ? null : requireCount(input.since, 'Session check-in since'),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export function decodeSessionCheckinGenerateResult(value) {
|
|
60
|
+
const result = requireRecord(value, 'Session check-in result');
|
|
61
|
+
if (result.kind === 'empty') {
|
|
62
|
+
const empty = requireExactRecord(result, 'Empty Session check-in', ['kind', 'effectId']);
|
|
63
|
+
return { kind: 'empty', effectId: requireEntityId(empty.effectId, 'effectId') };
|
|
64
|
+
}
|
|
65
|
+
if (result.kind === 'failed') {
|
|
66
|
+
const failed = requireExactRecord(result, 'Failed Session check-in', [
|
|
67
|
+
'kind',
|
|
68
|
+
'effectId',
|
|
69
|
+
'errorClass',
|
|
70
|
+
]);
|
|
71
|
+
if (!SESSION_CHECKIN_FAILURE_CLASSES.includes(failed.errorClass)) {
|
|
72
|
+
throw invalidProtocolFrame('Invalid Session check-in failure class');
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
kind: 'failed',
|
|
76
|
+
effectId: requireEntityId(failed.effectId, 'effectId'),
|
|
77
|
+
errorClass: failed.errorClass,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const generated = requireExactRecord(result, 'Generated Session check-in', [
|
|
81
|
+
'kind',
|
|
82
|
+
'effectId',
|
|
83
|
+
'cards',
|
|
84
|
+
'dropped',
|
|
85
|
+
]);
|
|
86
|
+
if (generated.kind !== 'generated')
|
|
87
|
+
throw invalidProtocolFrame('Invalid Session check-in kind');
|
|
88
|
+
if (!Array.isArray(generated.cards) || generated.cards.length > CHECKIN_MAX_CARDS) {
|
|
89
|
+
throw invalidProtocolFrame('Invalid Session check-in cards');
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
kind: 'generated',
|
|
93
|
+
effectId: requireEntityId(generated.effectId, 'effectId'),
|
|
94
|
+
cards: generated.cards.map(decodeCheckinCard),
|
|
95
|
+
dropped: requireCount(generated.dropped, 'Session check-in dropped count'),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function decodeCheckinCard(value) {
|
|
99
|
+
const card = requireShapedRecord(value, 'Session check-in card', ['sessionId', 'sessionRevision', 'sessionName', 'title', 'evidence', 'action'], ['instruction']);
|
|
100
|
+
const evidence = requireExactRecord(card.evidence, 'Session check-in evidence', [
|
|
101
|
+
'source',
|
|
102
|
+
'quote',
|
|
103
|
+
]);
|
|
104
|
+
if (!isCheckinCardAction(card.action) || !isCheckinEvidenceSource(evidence.source)) {
|
|
105
|
+
throw invalidProtocolFrame('Invalid Session check-in card');
|
|
106
|
+
}
|
|
107
|
+
if (typeof card.sessionName !== 'string' ||
|
|
108
|
+
Buffer.byteLength(card.sessionName) > SESSION_NAME_MAX_BYTES) {
|
|
109
|
+
throw invalidProtocolFrame('Invalid Session check-in Session name');
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
sessionId: requireEntityId(card.sessionId, 'sessionId'),
|
|
113
|
+
sessionRevision: requireCount(card.sessionRevision, 'Session check-in revision'),
|
|
114
|
+
sessionName: card.sessionName,
|
|
115
|
+
title: requireChars(card.title, 'Session check-in title', CHECKIN_TITLE_MAX_CHARS),
|
|
116
|
+
evidence: {
|
|
117
|
+
source: evidence.source,
|
|
118
|
+
quote: requireChars(evidence.quote, 'Session check-in quote', CHECKIN_QUOTE_MAX_CHARS),
|
|
119
|
+
},
|
|
120
|
+
action: card.action,
|
|
121
|
+
...(card.instruction !== undefined
|
|
122
|
+
? {
|
|
123
|
+
instruction: requireChars(card.instruction, 'Session check-in instruction', CHECKIN_INSTRUCTION_MAX_CHARS),
|
|
124
|
+
}
|
|
125
|
+
: {}),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function requireChars(value, label, maxChars) {
|
|
129
|
+
if (typeof value !== 'string' || !value.trim() || Array.from(value).length > maxChars) {
|
|
130
|
+
throw invalidProtocolFrame(`Invalid ${label}`);
|
|
131
|
+
}
|
|
132
|
+
return value;
|
|
133
|
+
}
|
|
@@ -60,9 +60,10 @@ export class CanonicalSessionProjectionReader {
|
|
|
60
60
|
rootTurn = await readCanonicalTurnSnapshot(this.#stores, durableAdmission);
|
|
61
61
|
}
|
|
62
62
|
const interactions = projectSessionInteractions(await this.#stores.interactionStore.listSessionPending(sessionId), await this.#stores.sessionStore.listPendingSandboxBoundaryRequests(sessionId));
|
|
63
|
-
//
|
|
63
|
+
// Keep the Session lane across the asynchronous Goal/wait read and the
|
|
64
|
+
// final queue projection; neither read can authorize a second admission.
|
|
65
|
+
const goal = await this.#readGoal(sessionId);
|
|
64
66
|
const queue = this.#messages.projection(sessionId);
|
|
65
|
-
const goal = this.#readGoal(sessionId);
|
|
66
67
|
const session = {
|
|
67
68
|
sessionId: header.id,
|
|
68
69
|
metadataRevision,
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
19
|
import { randomUUID } from 'node:crypto';
|
|
20
|
-
import { decodeEventWaitRecord, EVENT_WAIT_LIMITS, } from '@maka/core/event-wait';
|
|
20
|
+
import { decodeEventWaitRecord, decodeObservedEventWaitRecord, EVENT_WAIT_LIMITS, } from '@maka/core/event-wait';
|
|
21
21
|
import { authenticateInteractiveEventWaitAuthorityWriter, EVENT_WAIT_OBSERVATION_HINT_LIMIT, EVENT_WAIT_PAGE_LIMIT, eventWaitSourceKey, } from '@maka/storage/event-wait-authority';
|
|
22
22
|
import { StorageRootAuthorityError } from '@maka/storage/root-authority';
|
|
23
23
|
const systemClock = {
|
|
@@ -76,7 +76,7 @@ const addTime = (now, delay) => Math.min(Number.MAX_SAFE_INTEGER, now + delay);
|
|
|
76
76
|
* Ready candidates normally use durable observation age. Failed preparations get a bounded
|
|
77
77
|
* traversal by immutable ID, so neither failed writes nor cache capacity can pin selection.
|
|
78
78
|
*/
|
|
79
|
-
export class
|
|
79
|
+
export class HostEventWaitObserver {
|
|
80
80
|
#store;
|
|
81
81
|
#options;
|
|
82
82
|
#clock;
|
|
@@ -104,7 +104,7 @@ export class HostEventWaitManager {
|
|
|
104
104
|
#closed = false;
|
|
105
105
|
#ready = false;
|
|
106
106
|
constructor(options) {
|
|
107
|
-
this.#store =
|
|
107
|
+
this.#store = options.store;
|
|
108
108
|
this.#options = options;
|
|
109
109
|
this.#clock = options.clock ?? systemClock;
|
|
110
110
|
this.#policy = { ...DEFAULT_EVENT_WAIT_OBSERVATION_POLICY, ...options.policy };
|
|
@@ -113,7 +113,9 @@ export class HostEventWaitManager {
|
|
|
113
113
|
if (!Number.isFinite(value) || value < 0 || value > 1)
|
|
114
114
|
throw new TypeError('Invalid wait jitter');
|
|
115
115
|
}
|
|
116
|
-
else if (!Number.isSafeInteger(value) ||
|
|
116
|
+
else if (!Number.isSafeInteger(value) ||
|
|
117
|
+
value < 1 ||
|
|
118
|
+
(name !== 'maxLifetimeMs' && value > 2_147_483_647))
|
|
117
119
|
throw new TypeError(`Invalid wait policy: ${name}`);
|
|
118
120
|
}
|
|
119
121
|
if (this.#policy.pageSize > EVENT_WAIT_PAGE_LIMIT ||
|
|
@@ -127,9 +129,12 @@ export class HostEventWaitManager {
|
|
|
127
129
|
EVENT_WAIT_OBSERVATION_HINT_LIMIT)
|
|
128
130
|
throw new TypeError('Inconsistent event wait policy');
|
|
129
131
|
}
|
|
132
|
+
#decode(value) {
|
|
133
|
+
return (this.#options.decodeRecord ?? decodeObservedEventWaitRecord)(value);
|
|
134
|
+
}
|
|
130
135
|
/** Validates the supported template only; PR3 owns registration authorization and yield. */
|
|
131
136
|
validate(wait) {
|
|
132
|
-
const record =
|
|
137
|
+
const record = this.#decode(wait);
|
|
133
138
|
if (record.deadlineAt - record.createdAt > this.#policy.maxLifetimeMs)
|
|
134
139
|
throw new TypeError('Event wait exceeds maximum lifetime');
|
|
135
140
|
this.#options.adapters.validate(record);
|
|
@@ -417,7 +422,8 @@ export class HostEventWaitManager {
|
|
|
417
422
|
}
|
|
418
423
|
}
|
|
419
424
|
async #observe(snapshot, flight) {
|
|
420
|
-
|
|
425
|
+
const projectionBefore = snapshot.record;
|
|
426
|
+
let r = projectionBefore;
|
|
421
427
|
if (r.status !== 'waiting' || this.#closed)
|
|
422
428
|
return;
|
|
423
429
|
const cooldown = await this.#store.readSourceCooldown({
|
|
@@ -467,7 +473,9 @@ export class HostEventWaitManager {
|
|
|
467
473
|
outcome: 'checking',
|
|
468
474
|
cursor: previous?.cursor ?? null,
|
|
469
475
|
eventKey: previous?.eventKey ?? null,
|
|
470
|
-
|
|
476
|
+
// Reconnecting projections still need the last completed observation's
|
|
477
|
+
// diagnostic while this reservation's source request is in flight.
|
|
478
|
+
reason: previous?.reason ?? null,
|
|
471
479
|
};
|
|
472
480
|
const claim = await this.#commit(snapshot, { ...r, updatedAt: now, observation: reserved });
|
|
473
481
|
if (this.#closed || flight.controller.signal.aborted)
|
|
@@ -558,7 +566,10 @@ export class HostEventWaitManager {
|
|
|
558
566
|
!subscriptionPending &&
|
|
559
567
|
!this.#subscriptions.get(r.waitId)?.controller.signal.aborted)
|
|
560
568
|
this.#detach(r.waitId);
|
|
561
|
-
await this.#finish(snapshot, result, {
|
|
569
|
+
await this.#finish(snapshot, result, {
|
|
570
|
+
retryAfterUntil: flight.retryAfterUntil,
|
|
571
|
+
projectionBefore,
|
|
572
|
+
});
|
|
562
573
|
}
|
|
563
574
|
#validateAccess(access) {
|
|
564
575
|
if (!access || !['allowed', 'revoked', 'unknown'].includes(access.kind))
|
|
@@ -830,7 +841,7 @@ export class HostEventWaitManager {
|
|
|
830
841
|
eventKey: null,
|
|
831
842
|
reason: null,
|
|
832
843
|
};
|
|
833
|
-
|
|
844
|
+
this.#decode({
|
|
834
845
|
...r,
|
|
835
846
|
updatedAt: now,
|
|
836
847
|
observation: {
|
|
@@ -958,7 +969,7 @@ export class HostEventWaitManager {
|
|
|
958
969
|
},
|
|
959
970
|
};
|
|
960
971
|
}
|
|
961
|
-
const committed = await this.#commit(snapshot, record);
|
|
972
|
+
const committed = await this.#commit(snapshot, record, options.projectionBefore);
|
|
962
973
|
if (!committed || committed.record.status !== 'waiting')
|
|
963
974
|
this.#detach(r.waitId);
|
|
964
975
|
return committed;
|
|
@@ -1095,7 +1106,7 @@ export class HostEventWaitManager {
|
|
|
1095
1106
|
finishHandoff();
|
|
1096
1107
|
}
|
|
1097
1108
|
}
|
|
1098
|
-
async #commit(snapshot, record) {
|
|
1109
|
+
async #commit(snapshot, record, projectionBefore = snapshot.record) {
|
|
1099
1110
|
if (this.#closed)
|
|
1100
1111
|
return null;
|
|
1101
1112
|
const result = await this.#store.commit({
|
|
@@ -1103,7 +1114,23 @@ export class HostEventWaitManager {
|
|
|
1103
1114
|
expectedAuthorityRevision: snapshot.authorityRevision,
|
|
1104
1115
|
record,
|
|
1105
1116
|
});
|
|
1106
|
-
|
|
1117
|
+
if (result.kind !== 'committed')
|
|
1118
|
+
return null;
|
|
1119
|
+
const after = result.snapshot.record;
|
|
1120
|
+
// Compare durable semantics before the attempt, not its temporary checking
|
|
1121
|
+
// reservation. Cache eviction must not turn unchanged polling into activity.
|
|
1122
|
+
if ((after.status !== 'waiting' || after.observation?.outcome !== 'checking') &&
|
|
1123
|
+
(projectionBefore.status !== after.status ||
|
|
1124
|
+
projectionBefore.observation?.outcome !== after.observation?.outcome ||
|
|
1125
|
+
projectionBefore.observation?.reason !== after.observation?.reason)) {
|
|
1126
|
+
try {
|
|
1127
|
+
this.#options.onChanged?.(after);
|
|
1128
|
+
}
|
|
1129
|
+
catch {
|
|
1130
|
+
/* Projection hints are best effort. */
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
return result.snapshot;
|
|
1107
1134
|
}
|
|
1108
1135
|
async #expire(snapshot) {
|
|
1109
1136
|
if (this.#closed || snapshot.record.status !== 'waiting')
|
|
@@ -1264,3 +1291,27 @@ export class HostEventWaitManager {
|
|
|
1264
1291
|
return this.#close;
|
|
1265
1292
|
}
|
|
1266
1293
|
}
|
|
1294
|
+
export class HostEventWaitManager extends HostEventWaitObserver {
|
|
1295
|
+
checkSourceAccess(wait, signal, authorize) {
|
|
1296
|
+
return super.checkSourceAccess(wait, signal, (record, signal) => authorize(decodeEventWaitRecord(record), signal));
|
|
1297
|
+
}
|
|
1298
|
+
constructor(options) {
|
|
1299
|
+
const store = authenticateInteractiveEventWaitAuthorityWriter(options.store);
|
|
1300
|
+
super({
|
|
1301
|
+
...options,
|
|
1302
|
+
decodeRecord: decodeEventWaitRecord,
|
|
1303
|
+
authorize: (wait, signal) => options.authorize(decodeEventWaitRecord(wait), signal),
|
|
1304
|
+
onChanged: (wait) => options.onChanged?.(decodeEventWaitRecord(wait)),
|
|
1305
|
+
store: {
|
|
1306
|
+
read: (input) => store.read(input),
|
|
1307
|
+
listByStatus: (input) => store.listByStatus(input),
|
|
1308
|
+
listForObservation: (input) => store.listForObservation(input),
|
|
1309
|
+
readSourceCooldown: (input) => store.readSourceCooldown(input),
|
|
1310
|
+
extendSourceCooldown: (input) => store.extendSourceCooldown(input),
|
|
1311
|
+
reserveSourceDispatch: (input) => store.reserveSourceDispatch(input),
|
|
1312
|
+
completeSourceDispatch: (input) => store.completeSourceDispatch(input),
|
|
1313
|
+
commit: (input) => store.commit({ ...input, record: decodeEventWaitRecord(input.record) }),
|
|
1314
|
+
},
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
}
|