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
|
@@ -52,6 +52,19 @@ function collectASequenceOfCodePointsFast (char, input, position) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
const ASCII_WHITESPACE_REPLACE_REGEX = /[\u0009\u000A\u000C\u000D\u0020]/g // eslint-disable-line no-control-regex
|
|
55
|
+
const nonASCIIRegex = /[^\x00-\x7F]/ // eslint-disable-line no-control-regex
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param {string} str
|
|
59
|
+
* @returns {string}
|
|
60
|
+
*
|
|
61
|
+
* @see https://infra.spec.whatwg.org/#ascii-lowercase
|
|
62
|
+
*/
|
|
63
|
+
function asciiLowercase (str) {
|
|
64
|
+
return nonASCIIRegex.test(str)
|
|
65
|
+
? str.replace(/[A-Z]+/g, (upper) => upper.toLowerCase())
|
|
66
|
+
: str.toLowerCase()
|
|
67
|
+
}
|
|
55
68
|
|
|
56
69
|
/**
|
|
57
70
|
* @param {string} data
|
|
@@ -216,6 +229,7 @@ function serializeJavascriptValueToJSONString (value) {
|
|
|
216
229
|
}
|
|
217
230
|
|
|
218
231
|
module.exports = {
|
|
232
|
+
asciiLowercase,
|
|
219
233
|
collectASequenceOfCodePoints,
|
|
220
234
|
collectASequenceOfCodePointsFast,
|
|
221
235
|
forgivingBase64,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const assert = require('node:assert')
|
|
4
4
|
const { runtimeFeatures } = require('../../util/runtime-features.js')
|
|
5
|
+
const { asciiLowercase } = require('../infra/index.js')
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @typedef {object} Metadata
|
|
@@ -66,14 +67,12 @@ const getSRIHashAlgorithmIndex = /** @type {GetSRIHashAlgorithmIndex} */ (Map.pr
|
|
|
66
67
|
|
|
67
68
|
/**
|
|
68
69
|
* @typedef IsValidSRIHashAlgorithm
|
|
70
|
+
* @see https://w3c.github.io/webappsec-subresource-integrity/#valid-sri-hash-algorithm-token
|
|
69
71
|
* @type {(algorithm: string) => algorithm is SRIHashAlgorithm}
|
|
70
72
|
* @param {*} algorithm
|
|
71
73
|
* @returns {algorithm is SRIHashAlgorithm}
|
|
72
74
|
*/
|
|
73
|
-
|
|
74
|
-
const isValidSRIHashAlgorithm = /** @type {IsValidSRIHashAlgorithm} */ (
|
|
75
|
-
Map.prototype.has.bind(validSRIHashAlgorithmTokenSet)
|
|
76
|
-
)
|
|
75
|
+
const isValidSRIHashAlgorithm = (algorithm) => validSRIHashAlgorithmTokenSet.has(asciiLowercase(algorithm))
|
|
77
76
|
|
|
78
77
|
/**
|
|
79
78
|
* @param {Uint8Array} bytes
|
|
@@ -229,7 +228,8 @@ function parseMetadata (metadata) {
|
|
|
229
228
|
// 8. Let metadata be the ordered map
|
|
230
229
|
// «["alg" → algorithm, "val" → base64-value]».
|
|
231
230
|
const metadata = {
|
|
232
|
-
|
|
231
|
+
// Possible spec bug?
|
|
232
|
+
alg: asciiLowercase(algorithm),
|
|
233
233
|
val: base64Value
|
|
234
234
|
}
|
|
235
235
|
|
package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/websocket/receiver.js
CHANGED
|
@@ -244,6 +244,19 @@ class ByteParser extends Writable {
|
|
|
244
244
|
if (isControlFrame(this.#info.opcode)) {
|
|
245
245
|
this.#loop = this.parseControlFrame(body)
|
|
246
246
|
this.#state = parserStates.INFO
|
|
247
|
+
|
|
248
|
+
// If the automatic PONG/CLOSE reply filled the socket's write buffer,
|
|
249
|
+
// stop parsing and resume on drain so a PING flood cannot grow the
|
|
250
|
+
// outbound queue without bound.
|
|
251
|
+
if (this.#loop && this.#handler.socket.writableNeedDrain) {
|
|
252
|
+
this.#loop = false
|
|
253
|
+
this.#handler.socket.once('drain', () => {
|
|
254
|
+
if (this.destroyed) return
|
|
255
|
+
this.#loop = true
|
|
256
|
+
this.run(callback)
|
|
257
|
+
})
|
|
258
|
+
return
|
|
259
|
+
}
|
|
247
260
|
} else {
|
|
248
261
|
if (!this.#info.compressed) {
|
|
249
262
|
if (!this.writeFragments(body)) {
|
|
@@ -0,0 +1,87 @@
|
|
|
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 { constants } from 'node:fs';
|
|
21
|
+
import { access, realpath, stat } from 'node:fs/promises';
|
|
22
|
+
import { normalizeCatalogEntry } from '@maka/core/executor-catalog';
|
|
23
|
+
// Covers both the stored shape and the semantics of the derived catalog.
|
|
24
|
+
// Bump when AcpExecutor.#catalogEntry, catalog normalization, or any adapter's
|
|
25
|
+
// displayName/describeModels changes persisted labels, groups, provider types,
|
|
26
|
+
// defaults, or capabilities. Configuration and executable fingerprints cannot
|
|
27
|
+
// detect those code-only changes. A mismatch forces one neutral discovery.
|
|
28
|
+
const CATALOG_SNAPSHOT_VERSION = 2;
|
|
29
|
+
export function createAcpCatalogStore(persistence, executorId, config, launch) {
|
|
30
|
+
// Persist only a digest, never configuration values or credentials. Do not
|
|
31
|
+
// fingerprint the inherited process environment: it includes per-launch
|
|
32
|
+
// values and would make an otherwise unchanged restart miss the cache.
|
|
33
|
+
const configuration = JSON.stringify({
|
|
34
|
+
executorId,
|
|
35
|
+
config,
|
|
36
|
+
executable: launch.executable,
|
|
37
|
+
requiredExecutables: launch.requiredExecutables,
|
|
38
|
+
args: launch.args,
|
|
39
|
+
cwd: launch.cwd,
|
|
40
|
+
initialConfig: launch.initialConfig,
|
|
41
|
+
platform: process.platform,
|
|
42
|
+
arch: process.arch,
|
|
43
|
+
}, (_key, value) => value && typeof value === 'object' && !Array.isArray(value)
|
|
44
|
+
? Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)))
|
|
45
|
+
: value);
|
|
46
|
+
const fingerprint = async () => {
|
|
47
|
+
const files = await Promise.all([launch.executable, ...(launch.requiredExecutables ?? [])].map(async (path) => {
|
|
48
|
+
const resolved = await realpath(path);
|
|
49
|
+
await access(resolved, constants.X_OK);
|
|
50
|
+
const file = await stat(resolved);
|
|
51
|
+
if (!file.isFile())
|
|
52
|
+
throw new Error('ACP executable is not a file');
|
|
53
|
+
return { path: resolved, size: file.size, mtime: file.mtimeMs, ctime: file.ctimeMs };
|
|
54
|
+
}));
|
|
55
|
+
// Check current metadata when loading or persisting a neutral probe, not on cached reads.
|
|
56
|
+
return createHash('sha256').update(configuration).update(JSON.stringify(files)).digest('hex');
|
|
57
|
+
};
|
|
58
|
+
const { storage, key } = persistence;
|
|
59
|
+
return {
|
|
60
|
+
async load() {
|
|
61
|
+
const value = (await storage.get(key)).value;
|
|
62
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
63
|
+
return;
|
|
64
|
+
const record = value;
|
|
65
|
+
// Version 1 could contain project-specific Session models. Re-probe once
|
|
66
|
+
// rather than allowing those candidates to survive an upgrade indefinitely.
|
|
67
|
+
if (record.version !== CATALOG_SNAPSHOT_VERSION || record.binding !== (await fingerprint()))
|
|
68
|
+
return;
|
|
69
|
+
const entry = normalizeCatalogEntry(record.entry, executorId);
|
|
70
|
+
return entry.readiness === 'ready' ? entry : undefined;
|
|
71
|
+
},
|
|
72
|
+
async save(entry) {
|
|
73
|
+
if (!entry) {
|
|
74
|
+
await storage.delete(key);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const normalized = normalizeCatalogEntry(entry, executorId);
|
|
78
|
+
if (normalized.readiness !== 'ready')
|
|
79
|
+
return;
|
|
80
|
+
await storage.set(key, {
|
|
81
|
+
version: CATALOG_SNAPSHOT_VERSION,
|
|
82
|
+
binding: await fingerprint(),
|
|
83
|
+
entry: normalized,
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -16,37 +16,49 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
-
const CATALOG_TTL_MS = 60_000;
|
|
20
19
|
const PROBE_TIMEOUT_MS = 30_000;
|
|
21
|
-
|
|
20
|
+
const RETRY_COOLDOWN_MS = 60_000;
|
|
21
|
+
/** Public candidates come only from neutral discovery; task capabilities remain Session-owned. */
|
|
22
22
|
export class AcpCatalog {
|
|
23
23
|
admission;
|
|
24
24
|
probe;
|
|
25
25
|
unavailable;
|
|
26
|
+
drain;
|
|
27
|
+
store;
|
|
26
28
|
#cached;
|
|
27
29
|
#pending;
|
|
28
30
|
#tail;
|
|
29
|
-
#operations = new Set();
|
|
30
31
|
#revision = 0;
|
|
31
32
|
#disposed = false;
|
|
32
|
-
|
|
33
|
+
#hydration;
|
|
34
|
+
#writes = Promise.resolve();
|
|
35
|
+
#failure;
|
|
36
|
+
constructor(admission, probe, unavailable, drain = async () => { }, store) {
|
|
33
37
|
this.admission = admission;
|
|
34
38
|
this.probe = probe;
|
|
35
39
|
this.unavailable = unavailable;
|
|
40
|
+
this.drain = drain;
|
|
41
|
+
this.store = store;
|
|
36
42
|
}
|
|
37
43
|
async get(signal, refresh = false) {
|
|
38
44
|
signal.throwIfAborted();
|
|
39
45
|
if (this.#disposed)
|
|
40
46
|
return this.unavailable();
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
await waitForSignal(this.#hydrate(), signal);
|
|
48
|
+
if (refresh) {
|
|
49
|
+
this.#cancelProbe();
|
|
50
|
+
this.#failure = undefined;
|
|
51
|
+
}
|
|
52
|
+
let force = refresh;
|
|
43
53
|
while (true) {
|
|
44
54
|
signal.throwIfAborted();
|
|
45
55
|
if (this.#disposed)
|
|
46
56
|
return this.unavailable();
|
|
47
57
|
const cached = this.#cached;
|
|
48
|
-
if (cached &&
|
|
49
|
-
return cached
|
|
58
|
+
if (cached && !force)
|
|
59
|
+
return this.#failure ? { ...cached, refreshFailed: true } : cached;
|
|
60
|
+
if (!force && this.#failure && Date.now() < this.#failure.retryAt)
|
|
61
|
+
return this.#failure.entry;
|
|
50
62
|
const pending = this.#ensureProbe();
|
|
51
63
|
const result = await waitForSignal(pending.promise, signal);
|
|
52
64
|
signal.throwIfAborted();
|
|
@@ -54,11 +66,41 @@ export class AcpCatalog {
|
|
|
54
66
|
return this.unavailable();
|
|
55
67
|
// An invalidation need not have another caller to start its replacement.
|
|
56
68
|
// Only superseded revisions retry; genuine failures remain terminal.
|
|
57
|
-
if (pending.revision !== this.#revision)
|
|
69
|
+
if (pending.revision !== this.#revision) {
|
|
70
|
+
force = !!this.#pending;
|
|
58
71
|
continue;
|
|
72
|
+
}
|
|
59
73
|
return result;
|
|
60
74
|
}
|
|
61
75
|
}
|
|
76
|
+
#hydrate() {
|
|
77
|
+
if (!this.#hydration) {
|
|
78
|
+
const revision = this.#revision;
|
|
79
|
+
this.#hydration = (async () => {
|
|
80
|
+
const entry = await this.store?.load();
|
|
81
|
+
if (revision !== this.#revision || !entry)
|
|
82
|
+
return;
|
|
83
|
+
this.#cached = entry;
|
|
84
|
+
})().catch(() => {
|
|
85
|
+
// An optional cache must not prevent fresh discovery.
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return this.#hydration;
|
|
89
|
+
}
|
|
90
|
+
#save(entry) {
|
|
91
|
+
if (!this.store)
|
|
92
|
+
return;
|
|
93
|
+
const snapshot = entry ? structuredClone(entry) : undefined;
|
|
94
|
+
// Serialize writes and invalidation so a slow old write cannot resurrect a
|
|
95
|
+
// deleted snapshot. Every successful probe refreshes the executable binding.
|
|
96
|
+
this.#writes = this.#writes
|
|
97
|
+
.then(async () => {
|
|
98
|
+
await this.store.save(snapshot);
|
|
99
|
+
})
|
|
100
|
+
.catch(() => {
|
|
101
|
+
// Keep the in-memory catalog usable; a later refresh can retry.
|
|
102
|
+
});
|
|
103
|
+
}
|
|
62
104
|
#ensureProbe() {
|
|
63
105
|
if (!this.#pending) {
|
|
64
106
|
const revision = this.#revision;
|
|
@@ -70,28 +112,38 @@ export class AcpCatalog {
|
|
|
70
112
|
// A refresh must drain the superseded process before starting its replacement.
|
|
71
113
|
await previous;
|
|
72
114
|
startup.throwIfAborted();
|
|
115
|
+
// Failed cleanup may still own the previous permit. Retry it before
|
|
116
|
+
// acquiring another permit, including when the budget is only one.
|
|
117
|
+
await this.drain();
|
|
118
|
+
startup.throwIfAborted();
|
|
73
119
|
const permit = await this.admission.acquire(startup);
|
|
120
|
+
let retained = false;
|
|
74
121
|
let entry;
|
|
75
122
|
try {
|
|
76
123
|
startup.throwIfAborted();
|
|
77
|
-
|
|
78
|
-
|
|
124
|
+
entry = await this.probe(startup, (until) => {
|
|
125
|
+
retained = true;
|
|
126
|
+
void until.then(() => permit.release(), () => permit.release());
|
|
127
|
+
});
|
|
79
128
|
}
|
|
80
129
|
finally {
|
|
81
|
-
|
|
130
|
+
if (!retained)
|
|
131
|
+
permit.release();
|
|
82
132
|
}
|
|
83
|
-
if (
|
|
133
|
+
if (controller.signal.aborted || revision !== this.#revision || this.#disposed)
|
|
84
134
|
return this.unavailable();
|
|
85
|
-
if (
|
|
86
|
-
this.#
|
|
87
|
-
return entry;
|
|
135
|
+
if (startup.aborted)
|
|
136
|
+
return this.#acceptProbe(this.unavailable());
|
|
137
|
+
return this.#acceptProbe(entry);
|
|
88
138
|
}
|
|
89
139
|
catch {
|
|
140
|
+
// A real timeout is retryable; cancellation/supersession is not a failure.
|
|
141
|
+
if (!controller.signal.aborted && revision === this.#revision && !this.#disposed)
|
|
142
|
+
return this.#acceptProbe(this.unavailable());
|
|
90
143
|
return this.unavailable();
|
|
91
144
|
}
|
|
92
145
|
};
|
|
93
146
|
const promise = run().finally(() => {
|
|
94
|
-
this.#operations.delete(promise);
|
|
95
147
|
if (this.#pending?.promise === promise)
|
|
96
148
|
this.#pending = undefined;
|
|
97
149
|
if (this.#tail === promise)
|
|
@@ -99,20 +151,45 @@ export class AcpCatalog {
|
|
|
99
151
|
});
|
|
100
152
|
this.#pending = { revision, controller, promise };
|
|
101
153
|
this.#tail = promise;
|
|
102
|
-
this.#operations.add(promise);
|
|
103
154
|
}
|
|
104
155
|
return this.#pending;
|
|
105
156
|
}
|
|
157
|
+
#acceptProbe(entry) {
|
|
158
|
+
if (entry.readiness === 'ready') {
|
|
159
|
+
this.#failure = undefined;
|
|
160
|
+
this.#cached = entry;
|
|
161
|
+
this.#save(entry);
|
|
162
|
+
return entry;
|
|
163
|
+
}
|
|
164
|
+
if (entry.readiness === 'authentication_required') {
|
|
165
|
+
// A known account failure must not expose the previous account's choices.
|
|
166
|
+
this.#cached = undefined;
|
|
167
|
+
this.#hydration = Promise.resolve();
|
|
168
|
+
this.#save(undefined);
|
|
169
|
+
}
|
|
170
|
+
this.#failure = { entry, retryAt: Date.now() + RETRY_COOLDOWN_MS };
|
|
171
|
+
return this.#cached ? { ...this.#cached, refreshFailed: true } : entry;
|
|
172
|
+
}
|
|
106
173
|
invalidate() {
|
|
107
|
-
this.#revision++;
|
|
108
174
|
this.#cached = undefined;
|
|
175
|
+
this.#failure = undefined;
|
|
176
|
+
this.#cancelProbe();
|
|
177
|
+
this.#hydration = Promise.resolve();
|
|
178
|
+
this.#save(undefined);
|
|
179
|
+
}
|
|
180
|
+
#cancelProbe() {
|
|
181
|
+
this.#revision++;
|
|
109
182
|
this.#pending?.controller.abort(new Error('ACP catalog invalidated'));
|
|
110
183
|
this.#pending = undefined;
|
|
111
184
|
}
|
|
112
185
|
async dispose() {
|
|
113
186
|
this.#disposed = true;
|
|
114
|
-
this
|
|
115
|
-
|
|
187
|
+
this.#cancelProbe();
|
|
188
|
+
// Each replacement awaits its predecessor, including cancelled probes.
|
|
189
|
+
await this.#tail;
|
|
190
|
+
await this.#hydration;
|
|
191
|
+
await this.#writes;
|
|
192
|
+
this.#cached = undefined;
|
|
116
193
|
}
|
|
117
194
|
}
|
|
118
195
|
/** A caller can stop waiting without cancelling a probe shared by other drafts. */
|
|
@@ -22,6 +22,7 @@ import { access, mkdir, mkdtemp, realpath, rm, stat } from 'node:fs/promises';
|
|
|
22
22
|
import { tmpdir } from 'node:os';
|
|
23
23
|
import { AdmissionLimiter } from '@maka/runtime/admission-limiter';
|
|
24
24
|
import { AcpCatalog } from './acp-catalog.js';
|
|
25
|
+
import { createAcpCatalogStore } from './acp-catalog-store.js';
|
|
25
26
|
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
26
27
|
import { methods, } from '@agentclientprotocol/sdk';
|
|
27
28
|
import { pluginIdentity } from '@maka/runtime/plugin-runtime';
|
|
@@ -40,7 +41,9 @@ export class AcpExecutor {
|
|
|
40
41
|
#createConnection;
|
|
41
42
|
#state;
|
|
42
43
|
#sessions = new Map();
|
|
44
|
+
#catalogProbe;
|
|
43
45
|
#disposed = false;
|
|
46
|
+
#disposal;
|
|
44
47
|
#catalog;
|
|
45
48
|
#withCatalogDirectory;
|
|
46
49
|
#temporaryDirectory;
|
|
@@ -67,17 +70,51 @@ export class AcpExecutor {
|
|
|
67
70
|
await rm(directory, { recursive: true, force: true });
|
|
68
71
|
}
|
|
69
72
|
});
|
|
70
|
-
this.#catalog = new AcpCatalog(options.catalogAdmission ?? new AdmissionLimiter(1), (signal) => this.#probeCatalog(signal), () => this.#catalogEntry('unavailable'))
|
|
73
|
+
this.#catalog = new AcpCatalog(options.catalogAdmission ?? new AdmissionLimiter(1), (signal, holdAdmission) => this.#probeCatalog(signal, holdAdmission), () => this.#catalogEntry('unavailable'), () => this.#drainCatalogProbe(), options.catalogPersistence
|
|
74
|
+
? createAcpCatalogStore(options.catalogPersistence, this.id, config, this.#configured.launch)
|
|
75
|
+
: undefined);
|
|
71
76
|
}
|
|
72
77
|
async discover(input) {
|
|
73
78
|
// The generic Host query still supplies its target cwd. ACP draft candidates
|
|
74
79
|
// belong to this configured executor, and never initialize the user's workspace.
|
|
75
80
|
return await this.#catalog.get(input.signal, input.refresh);
|
|
76
81
|
}
|
|
77
|
-
async #probeCatalog(signal) {
|
|
78
|
-
|
|
82
|
+
async #probeCatalog(signal, holdAdmission) {
|
|
83
|
+
let resolveResult;
|
|
84
|
+
let rejectResult;
|
|
85
|
+
const result = new Promise((resolve, reject) => {
|
|
86
|
+
resolveResult = resolve;
|
|
87
|
+
rejectResult = reject;
|
|
88
|
+
});
|
|
89
|
+
let releaseDirectory;
|
|
90
|
+
const released = new Promise((resolve) => {
|
|
91
|
+
releaseDirectory = resolve;
|
|
92
|
+
});
|
|
93
|
+
const probe = { directory: Promise.resolve(), releaseDirectory };
|
|
94
|
+
this.#catalogProbe = probe;
|
|
95
|
+
// Report a cleanup failure to discovery while retaining the directory lease
|
|
96
|
+
// and admission permit until a refresh or shutdown successfully retries it.
|
|
97
|
+
probe.directory = this.#withCatalogDirectory(signal, async (directory) => {
|
|
98
|
+
try {
|
|
99
|
+
resolveResult(await this.#readCatalog(probe, directory, signal));
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
rejectResult(error);
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
await released;
|
|
106
|
+
}
|
|
107
|
+
}).finally(() => {
|
|
108
|
+
if (this.#catalogProbe === probe && !probe.session?.owner)
|
|
109
|
+
this.#catalogProbe = undefined;
|
|
110
|
+
});
|
|
111
|
+
holdAdmission(probe.directory);
|
|
112
|
+
void probe.directory.catch(rejectResult);
|
|
113
|
+
const entry = await result;
|
|
114
|
+
await probe.directory;
|
|
115
|
+
return entry;
|
|
79
116
|
}
|
|
80
|
-
async #readCatalog(directory, signal) {
|
|
117
|
+
async #readCatalog(probe, directory, signal) {
|
|
81
118
|
let session;
|
|
82
119
|
try {
|
|
83
120
|
signal.throwIfAborted();
|
|
@@ -87,6 +124,7 @@ export class AcpExecutor {
|
|
|
87
124
|
configOptions: [],
|
|
88
125
|
lost: false,
|
|
89
126
|
};
|
|
127
|
+
probe.session = session;
|
|
90
128
|
await this.#initialize(session, signal, true);
|
|
91
129
|
return this.#catalogEntry('ready', session.configOptions);
|
|
92
130
|
}
|
|
@@ -96,9 +134,22 @@ export class AcpExecutor {
|
|
|
96
134
|
finally {
|
|
97
135
|
// The directory lease outlives process cleanup, including failure cleanup.
|
|
98
136
|
if (session)
|
|
99
|
-
await
|
|
137
|
+
await this.#lose(session);
|
|
138
|
+
probe.releaseDirectory();
|
|
100
139
|
}
|
|
101
140
|
}
|
|
141
|
+
async #drainCatalogProbe() {
|
|
142
|
+
// AcpCatalog serializes probes and drains any retained owner before replacement.
|
|
143
|
+
const probe = this.#catalogProbe;
|
|
144
|
+
if (!probe)
|
|
145
|
+
return;
|
|
146
|
+
if (probe.session)
|
|
147
|
+
await this.#lose(probe.session);
|
|
148
|
+
probe.releaseDirectory();
|
|
149
|
+
await probe.directory;
|
|
150
|
+
if (this.#catalogProbe === probe)
|
|
151
|
+
this.#catalogProbe = undefined;
|
|
152
|
+
}
|
|
102
153
|
invalidateCatalog() {
|
|
103
154
|
this.#catalog.invalidate();
|
|
104
155
|
}
|
|
@@ -308,18 +359,32 @@ export class AcpExecutor {
|
|
|
308
359
|
await this.#lose(session);
|
|
309
360
|
}
|
|
310
361
|
async dispose() {
|
|
311
|
-
if (this.#
|
|
312
|
-
return;
|
|
362
|
+
if (this.#disposal)
|
|
363
|
+
return await this.#disposal;
|
|
313
364
|
this.#disposed = true;
|
|
365
|
+
this.#disposal = this.#dispose().catch((error) => {
|
|
366
|
+
this.#disposal = undefined;
|
|
367
|
+
throw error;
|
|
368
|
+
});
|
|
369
|
+
await this.#disposal;
|
|
370
|
+
}
|
|
371
|
+
async #dispose() {
|
|
314
372
|
await this.#catalog.dispose();
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
373
|
+
const settlements = await Promise.allSettled([
|
|
374
|
+
...[...this.#sessions.values()].map(async (session) => {
|
|
375
|
+
await this.#lose(session);
|
|
376
|
+
if (this.#sessions.get(session.conversationKey) === session)
|
|
377
|
+
this.#sessions.delete(session.conversationKey);
|
|
378
|
+
}),
|
|
379
|
+
this.#drainCatalogProbe(),
|
|
380
|
+
]);
|
|
318
381
|
const failures = settlements.flatMap((settlement) => settlement.status === 'rejected' ? [settlement.reason] : []);
|
|
319
382
|
if (failures.length)
|
|
320
383
|
throw new AggregateError(failures, 'ACP process cleanup failed');
|
|
321
384
|
}
|
|
322
385
|
async #session(request) {
|
|
386
|
+
if (this.#disposed)
|
|
387
|
+
throw new AcpRuntimeError('ACP executor is unavailable', 'acp_unavailable');
|
|
323
388
|
const cwd = resolve(request.cwd);
|
|
324
389
|
const existing = this.#sessions.get(request.conversationKey);
|
|
325
390
|
if (existing) {
|
|
@@ -331,7 +396,9 @@ export class AcpExecutor {
|
|
|
331
396
|
throw new AcpRuntimeError('ACP Session is busy', 'acp_busy');
|
|
332
397
|
if (!existing.record)
|
|
333
398
|
throw new AcpRuntimeError('ACP conversation is history-only because its external process was lost', 'acp_history_only');
|
|
334
|
-
await existing
|
|
399
|
+
await this.#lose(existing);
|
|
400
|
+
if (this.#disposed)
|
|
401
|
+
throw new AcpRuntimeError('ACP executor is unavailable', 'acp_unavailable');
|
|
335
402
|
if (this.#sessions.get(request.conversationKey) !== existing)
|
|
336
403
|
return this.#session(request);
|
|
337
404
|
this.#sessions.delete(request.conversationKey);
|
|
@@ -394,6 +461,9 @@ export class AcpExecutor {
|
|
|
394
461
|
throw new AcpRuntimeError('ACP Agent installation changed', 'acp_restore_identity_changed');
|
|
395
462
|
const executable = await checkedExecutable(launch.executable);
|
|
396
463
|
await Promise.all((launch.requiredExecutables ?? []).map(checkedExecutable));
|
|
464
|
+
// Closing may have started while startup was reading state or checking binaries.
|
|
465
|
+
if (this.#disposed || session.lost)
|
|
466
|
+
throw new AcpRuntimeError('ACP executor is unavailable', 'acp_unavailable');
|
|
397
467
|
const owner = this.#createConnection({
|
|
398
468
|
...launch,
|
|
399
469
|
executable,
|
|
@@ -848,18 +918,23 @@ export class AcpExecutor {
|
|
|
848
918
|
throw new Error('Unknown ACP Session');
|
|
849
919
|
}
|
|
850
920
|
async #lose(session) {
|
|
921
|
+
session.lost = true;
|
|
922
|
+
session.connection = undefined;
|
|
851
923
|
if (!session.loss) {
|
|
852
|
-
session.
|
|
853
|
-
|
|
924
|
+
session.loss = this.#disposeSession(session).catch((error) => {
|
|
925
|
+
// Keep the owner until cleanup succeeds, and let a later caller retry failures.
|
|
926
|
+
session.loss = undefined;
|
|
927
|
+
throw error;
|
|
928
|
+
});
|
|
854
929
|
}
|
|
855
930
|
await session.loss;
|
|
856
931
|
}
|
|
857
932
|
async #disposeSession(session) {
|
|
858
933
|
const owner = session.owner;
|
|
859
|
-
session.owner = undefined;
|
|
860
934
|
session.connection = undefined;
|
|
861
935
|
if (owner)
|
|
862
936
|
await owner.dispose();
|
|
937
|
+
session.owner = undefined;
|
|
863
938
|
}
|
|
864
939
|
}
|
|
865
940
|
function currentAcpModel(options) {
|
|
@@ -913,6 +988,7 @@ export class AcpRuntimeService {
|
|
|
913
988
|
const provider = new AcpExecutor(adapter, config, {
|
|
914
989
|
state: pluginStateStore(storage, adapter.id),
|
|
915
990
|
catalogAdmission: this.#catalogAdmission,
|
|
991
|
+
catalogPersistence: { storage, key: `${directoryKey}/snapshot` },
|
|
916
992
|
withCatalogDirectory: (signal, use) => storage.withScratchDirectory(directoryKey, signal, use),
|
|
917
993
|
});
|
|
918
994
|
consumer.effect(() => () => provider.dispose(), `acp.dispose(${JSON.stringify(adapter.id)})`);
|