maka-agent 0.2.1-dev.91.20261018 → 0.2.2-dev.97.20261024
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DISCLAIMER-WIP +1 -1
- package/LICENSE +15 -11
- package/README.md +173 -1
- package/README.zh-CN.md +156 -0
- package/THIRD_PARTY_NOTICES.txt +12 -12
- package/dist/cli-core.js +1 -0
- package/dist/pi-goal.js +13 -0
- package/dist/pi-tui-runner.js +44 -1
- package/dist/run-command-core.js +256 -48
- package/dist/run-session-command.js +534 -0
- package/dist/run-session-result.js +38 -0
- package/dist/run-turn-outcome.js +174 -0
- package/dist/runtime-host-cli.js +32 -17
- package/dist/runtime-host-run-command.js +53 -165
- package/dist/runtime-host-run-mcp.js +3 -0
- package/dist/runtime-host-session-channel.js +3 -1
- package/dist/runtime-host-session-driver.js +5 -0
- package/dist/runtime-host-setup-command.js +114 -7
- 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/bot-chat-settings.js +10 -1
- package/node_modules/@maka/core/dist/event-wait-delivery.js +67 -0
- package/node_modules/@maka/core/dist/event-wait.js +75 -10
- package/node_modules/@maka/core/dist/executor-catalog.js +3 -1
- package/node_modules/@maka/core/dist/goal.js +54 -2
- 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-store.js +0 -1
- package/node_modules/@maka/core/dist/runtime-event.js +24 -2
- package/node_modules/@maka/core/dist/runtime-invocation.js +10 -0
- package/node_modules/@maka/core/dist/session-checkin.js +31 -0
- package/node_modules/@maka/core/dist/tool-ledger-scanner.js +1 -9
- package/node_modules/@maka/core/dist/tool-recovery-bundle.js +1 -14
- package/node_modules/@maka/core/dist/turn-origin.js +14 -2
- package/node_modules/@maka/core/dist/usage-stats/types.js +1 -0
- package/node_modules/@maka/core/package.json +3 -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/agent-run.js +5 -1
- package/node_modules/@maka/runtime/dist/agent-swarm-status-tool.js +0 -1
- package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +29 -15
- package/node_modules/@maka/runtime/dist/ai-sdk-message-projection.js +10 -1
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +125 -131
- package/node_modules/@maka/runtime/dist/bots/bot-registry.js +19 -3
- package/node_modules/@maka/runtime/dist/bots/feishu-bridge.js +178 -6
- package/node_modules/@maka/runtime/dist/bots/wechat-bridge.js +163 -9
- package/node_modules/@maka/runtime/dist/context-budget-policy.js +9 -2
- package/node_modules/@maka/runtime/dist/event-wait-tool.js +69 -0
- package/node_modules/@maka/runtime/dist/goal-continuation.js +195 -117
- package/node_modules/@maka/runtime/dist/goal-state.js +8 -0
- package/node_modules/@maka/runtime/dist/history-compact-checkpoint.js +34 -4
- package/node_modules/@maka/runtime/dist/history-compaction.js +7 -0
- package/node_modules/@maka/runtime/dist/memory-extraction.js +0 -2
- 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 +15 -5
- package/node_modules/@maka/runtime/dist/plan-tools.js +0 -3
- 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/provider-error-classification.js +2 -0
- package/node_modules/@maka/runtime/dist/recovery-resolver.js +2 -1
- 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/sandbox-boundary-path.js +79 -2
- 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/session-manager.js +5 -1
- package/node_modules/@maka/runtime/dist/shell-run-manager.js +34 -0
- package/node_modules/@maka/runtime/dist/stream-graph-supervisor-tools.js +0 -3
- package/node_modules/@maka/runtime/dist/telemetry/builtin-pricing.js +21 -2
- package/node_modules/@maka/runtime/dist/tool-runtime.js +11 -2
- 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 +3 -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 +92 -22
- 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 +203 -71
- package/node_modules/@maka/runtime-host/dist/assistant/memory-network/host.js +21 -5
- 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 +37 -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 +68 -14
- 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 +93 -23
- package/node_modules/@maka/runtime-host/dist/assistant/service.js +72 -16
- package/node_modules/@maka/runtime-host/dist/client/host-profile.js +30 -1
- package/node_modules/@maka/runtime-host/dist/client/ssh-operator-activation.js +9 -2
- package/node_modules/@maka/runtime-host/dist/protocol/goal.js +119 -1
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +10 -3
- 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/agent-settings-tools.js +0 -1
- 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 +151 -20
- 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 +127 -11
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +47 -3
- package/node_modules/@maka/runtime-host/dist/server/execution-model-composition.js +11 -0
- package/node_modules/@maka/runtime-host/dist/server/external-session-coordinator.js +5 -2
- package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +343 -53
- package/node_modules/@maka/runtime-host/dist/server/goal-event-waits.js +457 -0
- package/node_modules/@maka/runtime-host/dist/server/goal-execution-coordinator.js +23 -6
- package/node_modules/@maka/runtime-host/dist/server/goal-projection.js +24 -3
- package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +5 -1
- 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/root-turn-coordinator.js +8 -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/agent-run-store-contract.js +14 -3
- package/node_modules/@maka/storage/dist/agent-run-store.js +10 -0
- package/node_modules/@maka/storage/dist/codex-session-adapter.js +20 -3
- package/node_modules/@maka/storage/dist/context-offload-snapshot.js +2 -1
- package/node_modules/@maka/storage/dist/event-wait-authority.js +18 -1
- package/node_modules/@maka/storage/dist/event-wait-bridge.js +336 -0
- package/node_modules/@maka/storage/dist/execution-stores.js +39 -1
- package/node_modules/@maka/storage/dist/external-session-images.js +131 -0
- package/node_modules/@maka/storage/dist/external-session-importer.js +12 -2
- package/node_modules/@maka/storage/dist/goal-authority.js +2 -0
- package/node_modules/@maka/storage/dist/local-execution-persistence.js +27 -1
- package/node_modules/@maka/storage/dist/operational-state-store.js +1 -1
- 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 +116 -16
- package/node_modules/@maka/storage/dist/session-checkpoint-publication-store.js +204 -0
- package/node_modules/@maka/storage/dist/session-store.js +37 -8
- 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-event-wait-authority.js +81 -8
- package/node_modules/@maka/storage/dist/sqlite-event-wait-bridge.js +94 -0
- package/node_modules/@maka/storage/dist/sqlite-reclamation-checkpoint.js +37 -0
- package/node_modules/@maka/storage/dist/sqlite-runtime-schema.js +7 -8
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +38 -162
- package/node_modules/@maka/storage/dist/sqlite-workflow-schema.js +7 -4
- package/node_modules/@maka/storage/dist/tool-commit-validation.js +1 -1
- package/node_modules/@maka/storage/package.json +4 -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
|
@@ -80,7 +80,7 @@ export class MemoryController {
|
|
|
80
80
|
error: worker.lastError ?? null,
|
|
81
81
|
rangeId: work?.id ?? null,
|
|
82
82
|
coveredCursor: this.store.boundary(id),
|
|
83
|
-
nextCheckAt:
|
|
83
|
+
nextCheckAt: this.nextCheck(id),
|
|
84
84
|
};
|
|
85
85
|
});
|
|
86
86
|
const id = `memory:${runId}:${owner}`;
|
|
@@ -732,24 +732,57 @@ export class MemoryController {
|
|
|
732
732
|
throw result.reason;
|
|
733
733
|
return result.value;
|
|
734
734
|
}
|
|
735
|
-
|
|
736
|
-
|
|
735
|
+
schedule() {
|
|
736
|
+
const row = this.store.db
|
|
737
|
+
.prepare("SELECT value FROM memory_meta WHERE key='maintenance-schedule'")
|
|
738
|
+
.get();
|
|
739
|
+
if (row)
|
|
740
|
+
return JSON.parse(String(row.value));
|
|
741
|
+
// Adopt the earliest existing deadline once; future rounds use only this clock.
|
|
742
|
+
const due = this.store
|
|
743
|
+
.list()
|
|
744
|
+
.filter((x) => this.enabled(x.id))
|
|
745
|
+
.map((x) => this.store.worker(x.id)?.nextCheckAt)
|
|
746
|
+
.filter((x) => typeof x === 'number');
|
|
747
|
+
const schedule = {
|
|
748
|
+
intervalMs: this.config.intervalMs ?? 43200000,
|
|
749
|
+
nextCheckAt: due.length
|
|
750
|
+
? Math.min(...due)
|
|
751
|
+
: Date.now() + (this.config.intervalMs ?? 43200000),
|
|
752
|
+
};
|
|
753
|
+
this.saveSchedule(schedule);
|
|
754
|
+
return schedule;
|
|
755
|
+
}
|
|
756
|
+
scheduleInfo() {
|
|
757
|
+
const { intervalMs, nextCheckAt, retryAt } = this.schedule();
|
|
758
|
+
return { scope: 'global', intervalMs, nextCheckAt, retryAt: retryAt ?? null };
|
|
759
|
+
}
|
|
760
|
+
saveSchedule(value) {
|
|
761
|
+
this.store.db
|
|
762
|
+
.prepare("INSERT INTO memory_meta(key,value) VALUES('maintenance-schedule',?) ON CONFLICT(key) DO UPDATE SET value=excluded.value")
|
|
763
|
+
.run(JSON.stringify(value));
|
|
764
|
+
}
|
|
765
|
+
configureSchedule(intervalMs) {
|
|
766
|
+
this.assertOwner();
|
|
767
|
+
if (!Number.isSafeInteger(intervalMs) || intervalMs < 1 || intervalMs > 2147483647)
|
|
768
|
+
throw Error('Invalid intervalMs');
|
|
769
|
+
this.saveSchedule({ ...this.schedule(), intervalMs, nextCheckAt: Date.now() + intervalMs });
|
|
770
|
+
}
|
|
771
|
+
interval(_indexId) {
|
|
772
|
+
return this.schedule().intervalMs;
|
|
737
773
|
}
|
|
738
774
|
enabled(indexId) {
|
|
739
775
|
const w = this.store.worker(indexId);
|
|
740
776
|
return w?.protocol === 'cursor-v1' && w.maintenanceEnabled !== false && !w.continuationStopped;
|
|
741
777
|
}
|
|
742
778
|
nextCheck(indexId) {
|
|
743
|
-
|
|
744
|
-
return this.enabled(indexId)
|
|
745
|
-
? (w.nextCheckAt ?? (w.lastCheckedAt || w.lastSuccess || Date.now()) + this.interval(indexId))
|
|
746
|
-
: null;
|
|
779
|
+
return this.enabled(indexId) ? this.schedule().nextCheckAt : null;
|
|
747
780
|
}
|
|
748
781
|
retryState(indexId) {
|
|
749
782
|
const failures = (this.store.worker(indexId)?.failures ?? 0) + 1;
|
|
750
783
|
return {
|
|
751
784
|
failures,
|
|
752
|
-
|
|
785
|
+
retryAt: Date.now() +
|
|
753
786
|
Math.min(3600000, (this.config.retryMs ?? 60000) * 2 ** Math.min(failures - 1, 6)),
|
|
754
787
|
};
|
|
755
788
|
}
|
|
@@ -787,6 +820,7 @@ export class MemoryController {
|
|
|
787
820
|
startStatus: w?.startStatus ?? null,
|
|
788
821
|
continuationStopReason: w?.continuationStopReason ?? null,
|
|
789
822
|
retryFailures: w?.failures ?? 0,
|
|
823
|
+
scheduleScope: 'global',
|
|
790
824
|
intervalMs: this.interval(indexId),
|
|
791
825
|
nextCheckAt: this.nextCheck(indexId),
|
|
792
826
|
notice: (coveredCursor === null
|
|
@@ -802,7 +836,10 @@ export class MemoryController {
|
|
|
802
836
|
async control(indexId, action, intervalMs) {
|
|
803
837
|
if (action === 'stop') {
|
|
804
838
|
this.assertOwner();
|
|
805
|
-
const
|
|
839
|
+
const active = this.runs.get(indexId);
|
|
840
|
+
const members = active
|
|
841
|
+
? [...this.runs].filter(([, run]) => run === active).map(([id]) => id)
|
|
842
|
+
: (this.store.worker(indexId)?.groupIndexIds ?? [indexId]);
|
|
806
843
|
for (const id of members)
|
|
807
844
|
await this.control(id, 'pause');
|
|
808
845
|
const running = members.find((id) => this.runs.has(id));
|
|
@@ -819,15 +856,16 @@ export class MemoryController {
|
|
|
819
856
|
if (intervalMs !== undefined &&
|
|
820
857
|
(!Number.isSafeInteger(intervalMs) || intervalMs < 1 || intervalMs > 2147483647))
|
|
821
858
|
throw Error('Invalid intervalMs');
|
|
859
|
+
if (intervalMs !== undefined)
|
|
860
|
+
this.configureSchedule(intervalMs);
|
|
822
861
|
this.store.saveWorker(indexId, {
|
|
823
862
|
...w,
|
|
824
|
-
...(intervalMs === undefined ? {} : { intervalMs }),
|
|
825
863
|
...(action === 'pause'
|
|
826
864
|
? {
|
|
827
865
|
maintenanceEnabled: false,
|
|
828
866
|
continuationStopped: true,
|
|
829
867
|
continuationStopReason: 'Maintenance paused',
|
|
830
|
-
|
|
868
|
+
retryAt: null,
|
|
831
869
|
}
|
|
832
870
|
: {}),
|
|
833
871
|
...(action === 'resume'
|
|
@@ -837,9 +875,6 @@ export class MemoryController {
|
|
|
837
875
|
continuationStopReason: undefined,
|
|
838
876
|
}
|
|
839
877
|
: {}),
|
|
840
|
-
...(action !== 'pause'
|
|
841
|
-
? { nextCheckAt: Date.now() + (intervalMs ?? this.interval(indexId)) }
|
|
842
|
-
: {}),
|
|
843
878
|
});
|
|
844
879
|
}
|
|
845
880
|
summary(indexId, visible, running = this.runs.has(indexId)) {
|
|
@@ -879,6 +914,7 @@ export class MemoryController {
|
|
|
879
914
|
: null,
|
|
880
915
|
protocol: worker.protocol ?? 'legacy-paused',
|
|
881
916
|
enabled: this.enabled(indexId),
|
|
917
|
+
scheduleScope: 'global',
|
|
882
918
|
intervalMs: this.interval(indexId),
|
|
883
919
|
nextCheckAt: this.nextCheck(indexId),
|
|
884
920
|
lastCheckedAt: worker.lastCheckedAt ?? null,
|
|
@@ -907,7 +943,6 @@ export class MemoryController {
|
|
|
907
943
|
lastSuccess: 0,
|
|
908
944
|
protocol: 'cursor-v1',
|
|
909
945
|
maintenanceEnabled: true,
|
|
910
|
-
nextCheckAt: Date.now() + (this.config.intervalMs ?? 43200000),
|
|
911
946
|
latestCursor: this.store.work(indexId)?.to,
|
|
912
947
|
lastCheckedAt: this.store.checkedAt(this.store.work(indexId)?.to ?? null),
|
|
913
948
|
});
|
|
@@ -919,7 +954,7 @@ export class MemoryController {
|
|
|
919
954
|
return this.ctx.agents.withInvocation({
|
|
920
955
|
sessionId: w.ownerSessionId,
|
|
921
956
|
cwd: w.cwd,
|
|
922
|
-
turnId: `memory
|
|
957
|
+
turnId: `memory-${this.owner}`,
|
|
923
958
|
toolCallId: randomUUID(),
|
|
924
959
|
abortSignal: this.abort.signal,
|
|
925
960
|
}, fn);
|
|
@@ -954,35 +989,80 @@ export class MemoryController {
|
|
|
954
989
|
return this.ticking ?? Promise.resolve();
|
|
955
990
|
this.ticking = (async () => {
|
|
956
991
|
this.flushNotifications();
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
if (
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
992
|
+
const schedule = this.schedule();
|
|
993
|
+
if (this.runs.size)
|
|
994
|
+
return;
|
|
995
|
+
if (!schedule.remainingIds?.length) {
|
|
996
|
+
if (Date.now() < schedule.nextCheckAt)
|
|
997
|
+
return;
|
|
998
|
+
schedule.remainingIds = this.store
|
|
999
|
+
.list()
|
|
1000
|
+
.filter((index) => this.enabled(index.id) && this.store.worker(index.id)?.startStatus !== 'capacity')
|
|
1001
|
+
.map((index) => index.id);
|
|
1002
|
+
schedule.ranges = {};
|
|
1003
|
+
schedule.retryAt = null;
|
|
1004
|
+
schedule.nextCheckAt = Date.now() + schedule.intervalMs;
|
|
1005
|
+
this.saveSchedule(schedule);
|
|
1006
|
+
}
|
|
1007
|
+
const eligible = schedule.remainingIds.filter((id) => this.enabled(id));
|
|
1008
|
+
if (!eligible.length) {
|
|
1009
|
+
this.saveSchedule({ ...schedule, remainingIds: [], ranges: {}, retryAt: null });
|
|
1010
|
+
return;
|
|
1011
|
+
}
|
|
1012
|
+
// Permission/ownership boundaries remain separate; within one owner all
|
|
1013
|
+
// participating indexes are handed to one Agent, not one Agent per index.
|
|
1014
|
+
const owner = this.store.worker(eligible[0]).ownerSessionId;
|
|
1015
|
+
const selected = eligible.filter((id) => this.store.worker(id).ownerSessionId === owner);
|
|
1016
|
+
schedule.sessions ??= {};
|
|
1017
|
+
if (!schedule.sessions[owner]) {
|
|
1018
|
+
let agent;
|
|
1019
|
+
try {
|
|
1020
|
+
agent = await this.inOwner(selected[0], () => this.ctx.agents.create({
|
|
1021
|
+
background: true,
|
|
1022
|
+
name: 'Memory maintenance',
|
|
1023
|
+
labels: [ASSISTANT_BACKGROUND_SESSION_LABEL],
|
|
1024
|
+
}));
|
|
973
1025
|
}
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
1026
|
+
catch (error) {
|
|
1027
|
+
for (const id of selected)
|
|
1028
|
+
this.store.saveWorker(id, {
|
|
1029
|
+
...this.store.worker(id),
|
|
1030
|
+
lastError: String(error),
|
|
1031
|
+
...this.retryState(id),
|
|
1032
|
+
});
|
|
1033
|
+
this.finishScheduledMembers(selected);
|
|
1034
|
+
this.reportRun(selected, randomUUID());
|
|
1035
|
+
return;
|
|
1036
|
+
}
|
|
1037
|
+
schedule.sessions[owner] = agent.sessionId;
|
|
1038
|
+
this.store.db
|
|
1039
|
+
.prepare('INSERT OR IGNORE INTO memory_worker_sessions VALUES(?)')
|
|
1040
|
+
.run(agent.sessionId);
|
|
977
1041
|
}
|
|
1042
|
+
this.saveSchedule({ ...this.schedule(), sessions: schedule.sessions });
|
|
1043
|
+
this.launch(selected[0], true, selected, schedule.sessions[owner]);
|
|
978
1044
|
})().finally(() => {
|
|
979
1045
|
this.ticking = undefined;
|
|
980
1046
|
});
|
|
981
1047
|
return this.ticking;
|
|
982
1048
|
}
|
|
983
|
-
|
|
1049
|
+
finishScheduledMembers(ids) {
|
|
1050
|
+
const schedule = this.schedule();
|
|
1051
|
+
const attempted = new Set(ids);
|
|
1052
|
+
// Failure ends this attempt, not the shared clock. Retain each index's work
|
|
1053
|
+
// and checkpoint for the next round, without holding healthy indexes back.
|
|
1054
|
+
this.saveSchedule({
|
|
1055
|
+
...schedule,
|
|
1056
|
+
remainingIds: (schedule.remainingIds ?? []).filter((id) => !attempted.has(id)),
|
|
1057
|
+
retryAt: null,
|
|
1058
|
+
});
|
|
1059
|
+
for (const id of ids)
|
|
1060
|
+
this.store.saveWorker(id, { ...this.store.worker(id), retryAt: null });
|
|
1061
|
+
}
|
|
1062
|
+
launch(indexId, scheduled = false, scheduledMembers, sessionId) {
|
|
984
1063
|
this.assertOwner();
|
|
985
|
-
const members =
|
|
1064
|
+
const members = scheduledMembers ??
|
|
1065
|
+
this.store.worker(indexId)?.groupIndexIds ?? [indexId];
|
|
986
1066
|
// All members name the same job, even when a scheduled round excludes paused members.
|
|
987
1067
|
for (const id of members)
|
|
988
1068
|
if (this.runs.has(id))
|
|
@@ -1007,7 +1087,9 @@ export class MemoryController {
|
|
|
1007
1087
|
const cancellation = new AbortController();
|
|
1008
1088
|
const signal = AbortSignal.any([this.abort.signal, cancellation.signal]);
|
|
1009
1089
|
const run = Promise.resolve()
|
|
1010
|
-
.then(() => this.inOwner(indexId, () => selected.length > 1
|
|
1090
|
+
.then(() => this.inOwner(indexId, () => selected.length > 1 || scheduled
|
|
1091
|
+
? this.runGroup(selected, signal, scheduled, sessionId)
|
|
1092
|
+
: this.run(selected[0], signal)))
|
|
1011
1093
|
.catch((error) => {
|
|
1012
1094
|
for (const id of selected)
|
|
1013
1095
|
this.store.saveWorker(id, {
|
|
@@ -1025,11 +1107,13 @@ export class MemoryController {
|
|
|
1025
1107
|
if (cancellation.signal.aborted)
|
|
1026
1108
|
this.store.saveWorker(id, {
|
|
1027
1109
|
...this.store.worker(id),
|
|
1028
|
-
|
|
1110
|
+
retryAt: null,
|
|
1029
1111
|
lastError: null,
|
|
1030
1112
|
startStatus: 'stopped',
|
|
1031
1113
|
});
|
|
1032
1114
|
}
|
|
1115
|
+
if (scheduled)
|
|
1116
|
+
this.finishScheduledMembers(selected);
|
|
1033
1117
|
this.reportRun(selected, runId, cancellation.signal.aborted);
|
|
1034
1118
|
});
|
|
1035
1119
|
for (const id of selected) {
|
|
@@ -1069,7 +1153,6 @@ export class MemoryController {
|
|
|
1069
1153
|
ownerSessionId: call.sessionId,
|
|
1070
1154
|
cwd: call.cwd,
|
|
1071
1155
|
maintenanceEnabled: true,
|
|
1072
|
-
nextCheckAt: Date.now() + (this.config.intervalMs ?? 43200000),
|
|
1073
1156
|
...this.store.worker(id),
|
|
1074
1157
|
sessionId: agent.sessionId,
|
|
1075
1158
|
groupIndexIds: ids,
|
|
@@ -1079,37 +1162,71 @@ export class MemoryController {
|
|
|
1079
1162
|
timeContext() {
|
|
1080
1163
|
return `Current UTC: ${new Date().toISOString()}. Reevaluate the user's criterion against current time, including rolling windows, even when the source delta is empty. Read existing entries and revisit older originals as needed; remove or revise expired entries and links as required by the criterion. No full rescan or content rewrite is required when the index remains valid. Source cursor capture time is not the current time.`;
|
|
1081
1164
|
}
|
|
1082
|
-
async runGroup(ids, signal) {
|
|
1165
|
+
async runGroup(ids, signal, scheduled = false, sessionId) {
|
|
1083
1166
|
const resuming = ids.some((id) => {
|
|
1084
1167
|
const w = this.store.work(id);
|
|
1085
1168
|
return w && !w.completed;
|
|
1086
1169
|
});
|
|
1087
1170
|
const pending = [];
|
|
1171
|
+
const failed = new Set();
|
|
1088
1172
|
let agent;
|
|
1089
1173
|
try {
|
|
1174
|
+
const needsRange = ids.filter((id) => {
|
|
1175
|
+
const work = this.store.work(id);
|
|
1176
|
+
if (work && !work.completed)
|
|
1177
|
+
return false;
|
|
1178
|
+
return !(work?.completed && (scheduled ? this.schedule().ranges?.[id] === work.id : resuming));
|
|
1179
|
+
});
|
|
1180
|
+
const observations = new Map(needsRange.map((id, i) => [id, i]));
|
|
1181
|
+
const observed = await this.observeMany(needsRange);
|
|
1090
1182
|
for (const id of ids) {
|
|
1091
|
-
if (
|
|
1183
|
+
if (this.store.work(id)?.completed &&
|
|
1184
|
+
(scheduled ? this.schedule().ranges?.[id] === this.store.work(id)?.id : resuming))
|
|
1092
1185
|
continue;
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
id
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1186
|
+
try {
|
|
1187
|
+
const existing = this.store.work(id);
|
|
1188
|
+
const result = observations.has(id) ? observed[observations.get(id)] : undefined;
|
|
1189
|
+
if (result?.status === 'rejected')
|
|
1190
|
+
throw result.reason;
|
|
1191
|
+
if (result && this.store.worker(id)?.lastCheckError)
|
|
1192
|
+
throw Error(this.store.worker(id).lastCheckError);
|
|
1193
|
+
const cursor = this.store.cursor(existing && !existing.completed ? existing.to : this.store.worker(id).latestCursor);
|
|
1194
|
+
const visible = await this.indexVisible(id);
|
|
1195
|
+
const work = this.store.work(id);
|
|
1196
|
+
pending.push({
|
|
1197
|
+
id,
|
|
1198
|
+
work: work && !work.completed ? work : this.store.begin(id, cursor.id, visible),
|
|
1199
|
+
visible,
|
|
1200
|
+
});
|
|
1201
|
+
if (scheduled) {
|
|
1202
|
+
const schedule = this.schedule();
|
|
1203
|
+
this.saveSchedule({
|
|
1204
|
+
...schedule,
|
|
1205
|
+
ranges: { ...schedule.ranges, [id]: pending.at(-1).work.id },
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
this.store.saveWorker(id, {
|
|
1209
|
+
...this.store.worker(id),
|
|
1210
|
+
lastAttempt: Date.now(),
|
|
1211
|
+
lastError: null,
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
catch (error) {
|
|
1215
|
+
if (signal.aborted)
|
|
1216
|
+
throw error;
|
|
1217
|
+
failed.add(id);
|
|
1218
|
+
this.store.saveWorker(id, {
|
|
1219
|
+
...this.store.worker(id),
|
|
1220
|
+
lastAttempt: Date.now(),
|
|
1221
|
+
lastError: String(error),
|
|
1222
|
+
...this.retryState(id),
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1110
1225
|
}
|
|
1111
1226
|
if (pending.length) {
|
|
1112
|
-
agent = await this.ctx.agents.resume({
|
|
1227
|
+
agent = await this.ctx.agents.resume({
|
|
1228
|
+
sessionId: sessionId ?? this.store.worker(ids[0]).sessionId,
|
|
1229
|
+
});
|
|
1113
1230
|
for (;;) {
|
|
1114
1231
|
this.assertOwner();
|
|
1115
1232
|
const remaining = pending.filter((x) => !this.store.work(x.id)?.completed);
|
|
@@ -1118,7 +1235,7 @@ export class MemoryController {
|
|
|
1118
1235
|
await agent.whenIdle(signal);
|
|
1119
1236
|
signal.throwIfAborted();
|
|
1120
1237
|
const before = remaining.map((x) => this.store.latestCheckpoint(x.id, x.work.id, agent.sessionId)?.id ?? 0);
|
|
1121
|
-
const result = await agent.followup(`Organize these independent indexes in this one Session.
|
|
1238
|
+
const result = await agent.followup(`${ids.length === 1 ? `Organize index ${ids[0]}. ` : ''}Organize these independent indexes in this one Session. Decide which indexes need changes and whether to organize several together; choose the order and reuse reads. Valid unchanged indexes need only a checkpoint explaining that judgment. Preserve completed members. Each criterion and exact range must be finished separately; save incomplete progress with complete=false and continue. ${this.timeContext()}\n${JSON.stringify(remaining.map((x) => ({ indexId: x.id, number: this.store.worker(x.id).groupNumber, criterion: this.store.index(x.id).instructions, range: this.store.describe(x.work.from, x.work.to, x.visible), rangeId: x.work.id, notes: this.store.notes(x.id) })))}`);
|
|
1122
1239
|
if (!['turn_started', 'followup'].includes(result?.disposition))
|
|
1123
1240
|
throw Error('Host rejected group maintenance');
|
|
1124
1241
|
await agent.whenIdle(signal);
|
|
@@ -1139,7 +1256,7 @@ export class MemoryController {
|
|
|
1139
1256
|
throw Error('Group stopped without checkpoint; retry retained work');
|
|
1140
1257
|
}
|
|
1141
1258
|
}
|
|
1142
|
-
for (const id of ids)
|
|
1259
|
+
for (const id of ids.filter((id) => !failed.has(id)))
|
|
1143
1260
|
this.store.saveWorker(id, {
|
|
1144
1261
|
...this.store.worker(id),
|
|
1145
1262
|
lastSuccess: pending.some((x) => x.id === id)
|
|
@@ -1147,23 +1264,38 @@ export class MemoryController {
|
|
|
1147
1264
|
: this.store.worker(id).lastSuccess,
|
|
1148
1265
|
lastError: null,
|
|
1149
1266
|
failures: 0,
|
|
1150
|
-
|
|
1267
|
+
retryAt: null,
|
|
1151
1268
|
});
|
|
1152
1269
|
}
|
|
1153
1270
|
catch (error) {
|
|
1154
1271
|
if (signal.aborted)
|
|
1155
1272
|
await agent?.cancel().catch(() => { });
|
|
1156
|
-
for (const id of ids)
|
|
1273
|
+
for (const id of ids) {
|
|
1274
|
+
if (failed.has(id))
|
|
1275
|
+
continue;
|
|
1276
|
+
const work = this.store.work(id);
|
|
1277
|
+
const completed = work?.completed && pending.some((x) => x.id === id && x.work.id === work.id);
|
|
1157
1278
|
this.store.saveWorker(id, {
|
|
1158
1279
|
...this.store.worker(id),
|
|
1159
|
-
|
|
1160
|
-
|
|
1280
|
+
...(completed
|
|
1281
|
+
? { lastError: null, failures: 0, retryAt: null, lastSuccess: Date.now() }
|
|
1282
|
+
: { lastError: String(error), ...this.retryState(id) }),
|
|
1161
1283
|
});
|
|
1284
|
+
}
|
|
1162
1285
|
}
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1286
|
+
const members = await Promise.all(ids.map(async (id) => {
|
|
1287
|
+
try {
|
|
1288
|
+
return this.summary(id, await this.indexVisible(id), false);
|
|
1289
|
+
}
|
|
1290
|
+
catch (error) {
|
|
1291
|
+
// A member's access failure must not overwrite the other members' results.
|
|
1292
|
+
this.store.saveWorker(id, { ...this.store.worker(id), lastError: String(error) });
|
|
1293
|
+
return { indexId: id, status: 'failed', error: String(error) };
|
|
1294
|
+
}
|
|
1295
|
+
}));
|
|
1296
|
+
return scheduled && ids.length === 1
|
|
1297
|
+
? { ...members[0], backgroundFinished: true }
|
|
1298
|
+
: { members, backgroundFinished: true };
|
|
1167
1299
|
}
|
|
1168
1300
|
async wait(indexId, callerSignal) {
|
|
1169
1301
|
const run = this.maintain(indexId);
|
|
@@ -1247,7 +1379,7 @@ Range ID: ${work.id}. Update existing entries and links when new evidence change
|
|
|
1247
1379
|
lastSuccess: Date.now(),
|
|
1248
1380
|
lastError: undefined,
|
|
1249
1381
|
failures: 0,
|
|
1250
|
-
|
|
1382
|
+
retryAt: null,
|
|
1251
1383
|
});
|
|
1252
1384
|
}
|
|
1253
1385
|
catch (error) {
|
|
@@ -179,7 +179,7 @@ export async function initializeMemory(ctx, directory, config = {}) {
|
|
|
179
179
|
}
|
|
180
180
|
return results;
|
|
181
181
|
}, false, 'direct');
|
|
182
|
-
register('MemoryIndexCreate', 'Create an index from the user’s organizing requirements and a source-range cursor from MemoryRange. Starts a background organizing job by default; returns its identity and admission/progress, not a guarantee of completion. The index Agent chooses how to read and organize. New indexes
|
|
182
|
+
register('MemoryIndexCreate', 'Create an index from the user’s organizing requirements and a source-range cursor from MemoryRange. Starts a background organizing job by default; returns its identity and admission/progress, not a guarantee of completion. The index Agent chooses how to read and organize. New indexes join the shared maintenance schedule (12 hours by default). All participating indexes are maintained by one Agent per owner, which decides what needs changing; MemoryIndexControl configure changes the shared interval. Completion/failure feedback goes to the owning assistant. background=false waits for the result.', z.object({
|
|
183
183
|
name: z.string().min(1).max(160),
|
|
184
184
|
instructions: z.string().min(1).max(8000),
|
|
185
185
|
cursor: id,
|
|
@@ -210,7 +210,7 @@ export async function initializeMemory(ctx, directory, config = {}) {
|
|
|
210
210
|
}
|
|
211
211
|
return controller.wait(index.id, call.abortSignal);
|
|
212
212
|
}, true);
|
|
213
|
-
register('MemoryIndexCreateGroup', 'Create or continue several numbered indexes in one organizing job. Each index retains its own requirements, content and coverage; existing members use number/indexId. Returns member IDs and job admission; capacity rejection includes unstarted IDs for retry. Background by default. New indexes
|
|
213
|
+
register('MemoryIndexCreateGroup', 'Create or continue several numbered indexes in one organizing job. Each index retains its own requirements, content and coverage; existing members use number/indexId. Returns member IDs and job admission; capacity rejection includes unstarted IDs for retry. Background by default. New indexes join the shared maintenance schedule (12 hours by default). Completion/failure feedback goes to the owning assistant; one member completing does not complete the group.', z.object({
|
|
214
214
|
cursor: id,
|
|
215
215
|
indexes: z
|
|
216
216
|
.array(z.object({
|
|
@@ -294,18 +294,34 @@ export async function initializeMemory(ctx, directory, config = {}) {
|
|
|
294
294
|
}
|
|
295
295
|
return controller.wait(input.indexId, call.abortSignal);
|
|
296
296
|
}, true);
|
|
297
|
-
register('MemoryIndexControl', '
|
|
298
|
-
indexId: id,
|
|
297
|
+
register('MemoryIndexControl', 'Configure the GLOBAL index maintenance interval with action=configure and intervalMs (indexId optional); this affects all indexes and does not enable paused indexes. One shared timer hands participating indexes to one organizing Agent, which decides what needs updating or can be handled together. With indexId, pause excludes that index from future rounds but lets active work finish; resume rejoins the shared schedule without resetting its clock. stop requires indexId, cancels its active shared organizing job and disables maintenance for ALL indexes in that job (or its creation group if idle). Contents and checkpoints are preserved. Returns affected state; it does not create a separate follow-up or user reminder. Use MemoryIndexMaintain for one immediate round.', z.object({
|
|
298
|
+
indexId: id.optional(),
|
|
299
299
|
action: z.enum(['pause', 'resume', 'configure', 'stop']),
|
|
300
300
|
intervalMs: z.number().int().min(1).max(2147483647).optional(),
|
|
301
301
|
}), async (input, call) => {
|
|
302
|
+
if (!input.indexId) {
|
|
303
|
+
if (input.action !== 'configure' || input.intervalMs === undefined)
|
|
304
|
+
throw Error('Without indexId, use configure with intervalMs for the shared schedule');
|
|
305
|
+
for (const index of store.list())
|
|
306
|
+
store.assertIndexVisible(index.id, await visible(index.id));
|
|
307
|
+
controller.configureSchedule(input.intervalMs);
|
|
308
|
+
return {
|
|
309
|
+
schedule: controller.scheduleInfo(),
|
|
310
|
+
effect: { target: 'global_index_maintenance', action: 'configure' },
|
|
311
|
+
};
|
|
312
|
+
}
|
|
302
313
|
const allowed = await visible(input.indexId);
|
|
303
314
|
store.assertIndexVisible(input.indexId, allowed);
|
|
304
315
|
await controller.attach(input.indexId, call);
|
|
305
316
|
await controller.control(input.indexId, input.action, input.intervalMs);
|
|
306
317
|
return {
|
|
307
318
|
...controller.summary(input.indexId, allowed),
|
|
308
|
-
|
|
319
|
+
schedule: controller.scheduleInfo(),
|
|
320
|
+
effect: {
|
|
321
|
+
target: input.intervalMs !== undefined ? 'global_index_maintenance' : 'index_maintenance',
|
|
322
|
+
action: input.action,
|
|
323
|
+
indexId: input.indexId,
|
|
324
|
+
},
|
|
309
325
|
};
|
|
310
326
|
}, true);
|
|
311
327
|
register('MemoryIndexContent', 'Read index documents: key for one full document; keys for a batch; view=full for full texts across the index; default view=directory only lists ALL matching keys/titles/sizes, not document bodies. Optional query is case-insensitive literal search in keys and bodies. after/limit select document pages; maxChars optionally budgets full documents, never silently truncates a document. No limit means all matches. Navigate associated entries with MemoryIndexLinks; verify original evidence with MemoryOriginal. Automatically refreshes source observations before returning, updating freshness/knownPending; does not organize the index or advance coveredCursor.', z.object({
|
package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition-observer.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
import { createHash } from 'node:crypto';
|
|
20
|
+
import { EventWaitAdapterRegistry } from '../../server/event-wait-adapter.js';
|
|
21
|
+
import { HostEventWaitObserver } from '../../server/event-wait-manager.js';
|
|
22
|
+
import { conditionReader, runCondition } from './condition.js';
|
|
23
|
+
/** Observation never runs an Agent/model; it only executes an already tested read-only cell. */
|
|
24
|
+
export function createMatterObserver(ctx, store, owner, onError, options = {}) {
|
|
25
|
+
return new HostEventWaitObserver({
|
|
26
|
+
store: store.conditions.observationStore(owner),
|
|
27
|
+
policy: { maxLifetimeMs: 366 * 86400000, maxAttempts: 1_000_000, ...options.policy },
|
|
28
|
+
...(options.clock ? { clock: options.clock } : {}),
|
|
29
|
+
onError,
|
|
30
|
+
authorize: async (wait) => {
|
|
31
|
+
const m = store.get(wait.resource.resourceId).matter;
|
|
32
|
+
return m.conditionWaitId === wait.waitId && m.status === 'waiting' && !m.activation
|
|
33
|
+
? { kind: 'allowed', context: null }
|
|
34
|
+
: { kind: 'revoked', reason: 'matter_wait_superseded' };
|
|
35
|
+
},
|
|
36
|
+
adapters: new EventWaitAdapterRegistry([
|
|
37
|
+
{
|
|
38
|
+
providerId: 'matter',
|
|
39
|
+
resourceType: 'checker',
|
|
40
|
+
conditionType: 'code',
|
|
41
|
+
conditionVersion: 1,
|
|
42
|
+
reconciliation: 'snapshot',
|
|
43
|
+
validate(wait) {
|
|
44
|
+
store.conditions.checker(String(wait.condition.parameters.checkerId), wait.resource.resourceId);
|
|
45
|
+
},
|
|
46
|
+
async read({ wait, cursor, signal }) {
|
|
47
|
+
if ((wait.observation?.consecutiveErrors ?? 0) >= 3)
|
|
48
|
+
return {
|
|
49
|
+
kind: 'source_unavailable',
|
|
50
|
+
receiptKey: `checker-errors:${wait.waitId}`,
|
|
51
|
+
evidenceRefs: [
|
|
52
|
+
'Checker repeatedly failed or timed out. Retest its code and source permissions.',
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
const checker = store.conditions.checker(String(wait.condition.parameters.checkerId), wait.resource.resourceId);
|
|
56
|
+
const cwd = store.binding(wait.sessionId);
|
|
57
|
+
if (!cwd)
|
|
58
|
+
throw new Error('Matter session is unavailable');
|
|
59
|
+
const reader = options.reader?.(wait.sessionId) ??
|
|
60
|
+
conditionReader(ctx, {
|
|
61
|
+
sessionId: wait.sessionId,
|
|
62
|
+
cwd,
|
|
63
|
+
turnId: wait.sourceTurnId,
|
|
64
|
+
toolCallId: `condition:${wait.waitId}`,
|
|
65
|
+
});
|
|
66
|
+
try {
|
|
67
|
+
const result = await runCondition(checker.definition, cursor ? JSON.parse(cursor) : null, reader, signal);
|
|
68
|
+
signal.throwIfAborted();
|
|
69
|
+
if (result.status === 'pending')
|
|
70
|
+
return { kind: 'pending', cursor: JSON.stringify(result.checkpoint ?? {}) };
|
|
71
|
+
return {
|
|
72
|
+
kind: 'satisfied',
|
|
73
|
+
receiptKey: createHash('sha256').update(JSON.stringify(result)).digest('hex'),
|
|
74
|
+
evidenceRefs: [result.reason, ...result.evidence],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
signal.throwIfAborted();
|
|
79
|
+
// A broken checker wakes the owner for repair; it never pauses or completes the task.
|
|
80
|
+
if ((wait.observation?.consecutiveErrors ?? 0) >= 2)
|
|
81
|
+
return {
|
|
82
|
+
kind: 'source_unavailable',
|
|
83
|
+
receiptKey: `checker-errors:${wait.waitId}`,
|
|
84
|
+
evidenceRefs: [
|
|
85
|
+
'Checker failed repeatedly. Retest the checker and its source permissions before waiting again.',
|
|
86
|
+
],
|
|
87
|
+
};
|
|
88
|
+
return { kind: 'unknown', reason: 'checker_failed' };
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
]),
|
|
93
|
+
});
|
|
94
|
+
}
|