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
|
@@ -16,6 +16,7 @@ const DEFAULT_MAX_BUFFER_SIZE = 5 * 1024 * 1024
|
|
|
16
16
|
* @property {number} bufferedBytes
|
|
17
17
|
* @property {object | null} pendingTrailers
|
|
18
18
|
* @property {boolean} done
|
|
19
|
+
* @property {boolean} [pendingStart] onRequestStart deferred until the primary request's context is known
|
|
19
20
|
*/
|
|
20
21
|
|
|
21
22
|
/**
|
|
@@ -30,6 +31,20 @@ class DeduplicationHandler {
|
|
|
30
31
|
*/
|
|
31
32
|
#primaryHandler
|
|
32
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Whether the primary request has started (onRequestStart received). Until
|
|
36
|
+
* then the request context is unknown and cannot be given to waiting handlers.
|
|
37
|
+
* @type {boolean}
|
|
38
|
+
*/
|
|
39
|
+
#requestStarted = false
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The primary request context, replayed to waiting handlers so they observe
|
|
43
|
+
* the same redirect history as the primary.
|
|
44
|
+
* @type {any}
|
|
45
|
+
*/
|
|
46
|
+
#context = null
|
|
47
|
+
|
|
33
48
|
/**
|
|
34
49
|
* @type {WaitingHandler[]}
|
|
35
50
|
*/
|
|
@@ -112,20 +127,30 @@ class DeduplicationHandler {
|
|
|
112
127
|
const waitingController = waitingHandler.controller
|
|
113
128
|
|
|
114
129
|
try {
|
|
115
|
-
|
|
130
|
+
if (this.#requestStarted) {
|
|
131
|
+
// The primary request has started, so its context (including the
|
|
132
|
+
// redirect history) is known and can be delivered immediately.
|
|
133
|
+
handler.onRequestStart?.(waitingController, this.#context)
|
|
116
134
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
135
|
+
if (waitingController.aborted) {
|
|
136
|
+
waitingHandler.done = true
|
|
137
|
+
return true
|
|
138
|
+
}
|
|
121
139
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
140
|
+
if (this.#responseStarted) {
|
|
141
|
+
handler.onResponseStart?.(
|
|
142
|
+
waitingController,
|
|
143
|
+
this.#statusCode,
|
|
144
|
+
this.#headers,
|
|
145
|
+
this.#statusMessage
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
} else {
|
|
149
|
+
// The primary request has not started yet. Defer onRequestStart until
|
|
150
|
+
// its context is known, so the waiting handler observes the same
|
|
151
|
+
// redirect history as the primary (a cache handler relies on it to
|
|
152
|
+
// reject cross-origin redirect responses).
|
|
153
|
+
waitingHandler.pendingStart = true
|
|
129
154
|
}
|
|
130
155
|
} catch {
|
|
131
156
|
// Ignore errors from waiting handlers
|
|
@@ -146,6 +171,24 @@ class DeduplicationHandler {
|
|
|
146
171
|
*/
|
|
147
172
|
onRequestStart (controller, context) {
|
|
148
173
|
this.#controller = controller
|
|
174
|
+
if (!this.#requestStarted) {
|
|
175
|
+
this.#requestStarted = true
|
|
176
|
+
this.#context = context
|
|
177
|
+
// Deliver the now-known context to handlers that joined before the
|
|
178
|
+
// primary request started.
|
|
179
|
+
for (const waitingHandler of this.#waitingHandlers) {
|
|
180
|
+
if (waitingHandler.pendingStart && !waitingHandler.done && !waitingHandler.controller.aborted) {
|
|
181
|
+
waitingHandler.pendingStart = false
|
|
182
|
+
try {
|
|
183
|
+
waitingHandler.handler.onRequestStart?.(waitingHandler.controller, context)
|
|
184
|
+
} catch {
|
|
185
|
+
// Ignore errors from waiting handlers
|
|
186
|
+
waitingHandler.done = true
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
this.#pruneDoneWaitingHandlers()
|
|
191
|
+
}
|
|
149
192
|
this.#primaryHandler.onRequestStart?.(controller, context)
|
|
150
193
|
}
|
|
151
194
|
|
|
@@ -251,40 +294,41 @@ class DeduplicationHandler {
|
|
|
251
294
|
return
|
|
252
295
|
}
|
|
253
296
|
|
|
254
|
-
// Remove the entry before callbacks can synchronously dispatch a retry.
|
|
255
|
-
this.#cleanup()
|
|
256
|
-
this.#primaryHandler.onResponseEnd?.(controller, trailers)
|
|
257
|
-
// A throwing end callback must still be handled by onResponseError.
|
|
258
297
|
this.#completed = true
|
|
298
|
+
// Remove the completed request before callbacks can redispatch into this
|
|
299
|
+
// interceptor. Cleanup must not depend on downstream handlers succeeding.
|
|
300
|
+
this.#cleanup()
|
|
259
301
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
302
|
+
try {
|
|
303
|
+
this.#primaryHandler.onResponseEnd?.(controller, trailers)
|
|
304
|
+
} catch (err) {
|
|
305
|
+
// Completion callbacks may throw to initiate a retry. The transport's
|
|
306
|
+
// error callback would be ignored now that this handler is completed.
|
|
307
|
+
this.#primaryHandler.onResponseError?.(controller, err)
|
|
308
|
+
} finally {
|
|
309
|
+
for (const waitingHandler of this.#waitingHandlers) {
|
|
310
|
+
if (waitingHandler.done || waitingHandler.controller.aborted) {
|
|
311
|
+
waitingHandler.done = true
|
|
312
|
+
continue
|
|
313
|
+
}
|
|
265
314
|
|
|
266
|
-
|
|
315
|
+
this.#flushWaitingHandler(waitingHandler)
|
|
267
316
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
317
|
+
if (waitingHandler.done || waitingHandler.controller.aborted) {
|
|
318
|
+
waitingHandler.done = true
|
|
319
|
+
continue
|
|
320
|
+
}
|
|
272
321
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
322
|
+
if (waitingHandler.controller.paused) {
|
|
323
|
+
waitingHandler.pendingTrailers = trailers
|
|
324
|
+
continue
|
|
325
|
+
}
|
|
277
326
|
|
|
278
|
-
|
|
279
|
-
waitingHandler.handler.onResponseEnd?.(waitingHandler.controller, trailers)
|
|
280
|
-
} catch (err) {
|
|
281
|
-
this.#errorWaitingHandler(waitingHandler, err)
|
|
327
|
+
this.#endWaitingHandler(waitingHandler, trailers)
|
|
282
328
|
}
|
|
283
329
|
|
|
284
|
-
|
|
330
|
+
this.#pruneDoneWaitingHandlers()
|
|
285
331
|
}
|
|
286
|
-
|
|
287
|
-
this.#pruneDoneWaitingHandlers()
|
|
288
332
|
}
|
|
289
333
|
|
|
290
334
|
/**
|
|
@@ -300,13 +344,15 @@ class DeduplicationHandler {
|
|
|
300
344
|
this.#completed = true
|
|
301
345
|
this.#cleanup()
|
|
302
346
|
|
|
303
|
-
|
|
347
|
+
try {
|
|
348
|
+
this.#primaryHandler.onResponseError?.(controller, err)
|
|
349
|
+
} finally {
|
|
350
|
+
for (const waitingHandler of this.#waitingHandlers) {
|
|
351
|
+
this.#errorWaitingHandler(waitingHandler, err)
|
|
352
|
+
}
|
|
304
353
|
|
|
305
|
-
|
|
306
|
-
this.#errorWaitingHandler(waitingHandler, err)
|
|
354
|
+
this.#waitingHandlers = []
|
|
307
355
|
}
|
|
308
|
-
|
|
309
|
-
this.#waitingHandlers = []
|
|
310
356
|
}
|
|
311
357
|
|
|
312
358
|
#cleanup () {
|
|
@@ -327,7 +373,8 @@ class DeduplicationHandler {
|
|
|
327
373
|
bufferedChunks: [],
|
|
328
374
|
bufferedBytes: 0,
|
|
329
375
|
pendingTrailers: null,
|
|
330
|
-
done: false
|
|
376
|
+
done: false,
|
|
377
|
+
pendingStart: false
|
|
331
378
|
}
|
|
332
379
|
|
|
333
380
|
const state = {
|
|
@@ -352,14 +399,7 @@ class DeduplicationHandler {
|
|
|
352
399
|
!state.paused &&
|
|
353
400
|
!state.aborted
|
|
354
401
|
) {
|
|
355
|
-
|
|
356
|
-
waitingHandler.handler.onResponseEnd?.(waitingHandler.controller, waitingHandler.pendingTrailers)
|
|
357
|
-
} catch (err) {
|
|
358
|
-
this.#errorWaitingHandler(waitingHandler, err)
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
waitingHandler.pendingTrailers = null
|
|
362
|
-
waitingHandler.done = true
|
|
402
|
+
this.#endWaitingHandler(waitingHandler, waitingHandler.pendingTrailers)
|
|
363
403
|
}
|
|
364
404
|
|
|
365
405
|
this.#pruneDoneWaitingHandlers()
|
|
@@ -448,6 +488,27 @@ class DeduplicationHandler {
|
|
|
448
488
|
}
|
|
449
489
|
}
|
|
450
490
|
|
|
491
|
+
/**
|
|
492
|
+
* @param {WaitingHandler} waitingHandler
|
|
493
|
+
* @param {object} trailers
|
|
494
|
+
*/
|
|
495
|
+
#endWaitingHandler (waitingHandler, trailers) {
|
|
496
|
+
waitingHandler.done = true
|
|
497
|
+
waitingHandler.pendingTrailers = null
|
|
498
|
+
|
|
499
|
+
try {
|
|
500
|
+
waitingHandler.handler.onResponseEnd?.(waitingHandler.controller, trailers)
|
|
501
|
+
} catch (err) {
|
|
502
|
+
// This is a response failure, not a consumer abort. Aborting the waiting
|
|
503
|
+
// controller here would prevent downstream handlers from retrying.
|
|
504
|
+
try {
|
|
505
|
+
waitingHandler.handler.onResponseError?.(waitingHandler.controller, err)
|
|
506
|
+
} catch {
|
|
507
|
+
// An error callback must not prevent other waiting handlers completing.
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
451
512
|
/**
|
|
452
513
|
* @param {WaitingHandler} waitingHandler
|
|
453
514
|
* @param {Error} err
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const util = require('../core/util')
|
|
4
4
|
const assert = require('node:assert')
|
|
5
|
-
const { InvalidArgumentError } = require('../core/errors')
|
|
6
|
-
const { kRequestOrigin } = require('../core/symbols')
|
|
5
|
+
const { InvalidArgumentError, MaxRedirectsError } = require('../core/errors')
|
|
6
|
+
const { kRequestOrigin, kRedirectCacheControl } = require('../core/symbols')
|
|
7
7
|
|
|
8
8
|
const redirectableStatusCodes = [300, 301, 302, 303, 307, 308]
|
|
9
9
|
|
|
@@ -38,6 +38,15 @@ class RedirectHandler {
|
|
|
38
38
|
this.maxRedirections = maxRedirections
|
|
39
39
|
this.handler = handler
|
|
40
40
|
this.history = []
|
|
41
|
+
// `cache-control` of each intermediate (suppressed) redirect hop. An outer
|
|
42
|
+
// cache uses it to preserve a hop's storage policy (e.g. `no-store`) that
|
|
43
|
+
// would otherwise be lost because the hop's response is not forwarded. It
|
|
44
|
+
// travels as a non-enumerable property of the history array so it reaches
|
|
45
|
+
// the cache without becoming part of the public request/response context.
|
|
46
|
+
Object.defineProperty(this.history, kRedirectCacheControl, {
|
|
47
|
+
value: [],
|
|
48
|
+
enumerable: false
|
|
49
|
+
})
|
|
41
50
|
}
|
|
42
51
|
|
|
43
52
|
onRequestStart (controller, context) {
|
|
@@ -62,10 +71,6 @@ class RedirectHandler {
|
|
|
62
71
|
return
|
|
63
72
|
}
|
|
64
73
|
|
|
65
|
-
if (this.opts.throwOnMaxRedirect && this.history.length >= this.maxRedirections) {
|
|
66
|
-
throw new Error('max redirects')
|
|
67
|
-
}
|
|
68
|
-
|
|
69
74
|
let removeContentHeaders = statusCode === 303
|
|
70
75
|
|
|
71
76
|
// https://tools.ietf.org/html/rfc7231#section-6.4.2
|
|
@@ -91,9 +96,19 @@ class RedirectHandler {
|
|
|
91
96
|
this.opts.body = null
|
|
92
97
|
}
|
|
93
98
|
|
|
94
|
-
this.location =
|
|
99
|
+
this.location = util.isDisturbed(this.opts.body) || redirectableStatusCodes.indexOf(statusCode) === -1
|
|
95
100
|
? null
|
|
96
|
-
: headers.location
|
|
101
|
+
: headers.location || null
|
|
102
|
+
|
|
103
|
+
// Only a redirect that would otherwise be followed counts against the
|
|
104
|
+
// limit. The final response after exactly maxRedirections redirects, or a
|
|
105
|
+
// 3xx without a Location header, is delivered as usual.
|
|
106
|
+
if (this.location && this.history.length >= this.maxRedirections) {
|
|
107
|
+
if (this.opts.throwOnMaxRedirect) {
|
|
108
|
+
throw new MaxRedirectsError()
|
|
109
|
+
}
|
|
110
|
+
this.location = null
|
|
111
|
+
}
|
|
97
112
|
|
|
98
113
|
const requestOrigin = this.opts[kRequestOrigin] === undefined
|
|
99
114
|
? this.opts.origin
|
|
@@ -108,6 +123,11 @@ class RedirectHandler {
|
|
|
108
123
|
return
|
|
109
124
|
}
|
|
110
125
|
|
|
126
|
+
// This hop's response is suppressed (only its Location is used). Record its
|
|
127
|
+
// cache-control so an outer cache can honor a restrictive policy that would
|
|
128
|
+
// otherwise be lost when the final response is stored.
|
|
129
|
+
this.history[kRedirectCacheControl].push(headers['cache-control'])
|
|
130
|
+
|
|
111
131
|
const baseUrl = requestOrigin
|
|
112
132
|
? new URL(this.opts.path, requestOrigin)
|
|
113
133
|
: undefined
|
|
@@ -4,6 +4,7 @@ const assert = require('node:assert')
|
|
|
4
4
|
const { kRetryHandlerDefaultRetry } = require('../core/symbols')
|
|
5
5
|
const { RequestRetryError, RequestAbortedError } = require('../core/errors')
|
|
6
6
|
const {
|
|
7
|
+
hasSafeIterator,
|
|
7
8
|
isDisturbed,
|
|
8
9
|
parseRangeHeader,
|
|
9
10
|
wrapRequestBody
|
|
@@ -554,19 +555,9 @@ class RetryHandler {
|
|
|
554
555
|
|
|
555
556
|
retry () {
|
|
556
557
|
if (this.start !== 0) {
|
|
557
|
-
const headers = { range: `bytes=${this.start}-${this.end ?? ''}` }
|
|
558
|
-
|
|
559
|
-
// Weak etag check - weak etags will make comparison algorithms never match
|
|
560
|
-
if (this.etag != null) {
|
|
561
|
-
headers['if-match'] = this.etag
|
|
562
|
-
}
|
|
563
|
-
|
|
564
558
|
this.opts = {
|
|
565
559
|
...this.opts,
|
|
566
|
-
headers: {
|
|
567
|
-
...this.opts.headers,
|
|
568
|
-
...headers
|
|
569
|
-
}
|
|
560
|
+
headers: buildResumeHeaders(this.opts.headers, `bytes=${this.start}-${this.end ?? ''}`, this.etag)
|
|
570
561
|
}
|
|
571
562
|
}
|
|
572
563
|
|
|
@@ -650,4 +641,46 @@ class RetryHandler {
|
|
|
650
641
|
}
|
|
651
642
|
}
|
|
652
643
|
|
|
644
|
+
function isReplacedHeader (key, etag) {
|
|
645
|
+
const name = key.toLowerCase()
|
|
646
|
+
return name === 'range' || (etag != null && name === 'if-match')
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
function buildResumeHeaders (headers, range, etag) {
|
|
650
|
+
if (Array.isArray(headers) || (headers && typeof headers === 'object' && hasSafeIterator(headers))) {
|
|
651
|
+
const ret = []
|
|
652
|
+
if (Array.isArray(headers)) {
|
|
653
|
+
for (let i = 0; i < headers.length; i += 2) {
|
|
654
|
+
if (!isReplacedHeader(headers[i], etag)) {
|
|
655
|
+
ret.push(headers[i], headers[i + 1])
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
} else {
|
|
659
|
+
for (const [key, value] of headers) {
|
|
660
|
+
if (!isReplacedHeader(key, etag)) {
|
|
661
|
+
ret.push(key, value)
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
ret.push('range', range)
|
|
666
|
+
// Weak etag check - weak etags will make comparison algorithms never match
|
|
667
|
+
if (etag != null) {
|
|
668
|
+
ret.push('if-match', etag)
|
|
669
|
+
}
|
|
670
|
+
return ret
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
const ret = {}
|
|
674
|
+
for (const key in headers) {
|
|
675
|
+
if (Object.hasOwn(headers, key) && !isReplacedHeader(key, etag)) {
|
|
676
|
+
ret[key] = headers[key]
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
ret.range = range
|
|
680
|
+
if (etag != null) {
|
|
681
|
+
ret['if-match'] = etag
|
|
682
|
+
}
|
|
683
|
+
return ret
|
|
684
|
+
}
|
|
685
|
+
|
|
653
686
|
module.exports = RetryHandler
|
|
@@ -210,7 +210,10 @@ function makeRevalidationHeaders (opts, result) {
|
|
|
210
210
|
*/
|
|
211
211
|
function isStale (result, cacheControlDirectives, cacheType) {
|
|
212
212
|
const now = Date.now()
|
|
213
|
-
|
|
213
|
+
// A zero freshness lifetime (e.g. max-age=0 with a validator) is never fresh,
|
|
214
|
+
// even when reused within the same millisecond or after a clock step back.
|
|
215
|
+
// https://www.rfc-editor.org/rfc/rfc9111.html#section-4.2
|
|
216
|
+
if (now > result.staleAt || result.staleAt <= result.cachedAt) {
|
|
214
217
|
// Response is stale
|
|
215
218
|
if (!staleResponseRequiresRevalidation(result, cacheType) && cacheControlDirectives?.['max-stale']) {
|
|
216
219
|
// There's a threshold where we can serve stale responses, let's see if
|
|
@@ -331,6 +334,7 @@ function sendCachedValue (handler, opts, result, age, context, isStale) {
|
|
|
331
334
|
assert(!stream.readableDidRead, 'stream should not be readableDidRead')
|
|
332
335
|
|
|
333
336
|
let aborted = false
|
|
337
|
+
let abortReason = null
|
|
334
338
|
|
|
335
339
|
const controller = {
|
|
336
340
|
rawHeaders: [],
|
|
@@ -348,11 +352,15 @@ function sendCachedValue (handler, opts, result, age, context, isStale) {
|
|
|
348
352
|
return aborted
|
|
349
353
|
},
|
|
350
354
|
get reason () {
|
|
351
|
-
return
|
|
355
|
+
return abortReason
|
|
352
356
|
},
|
|
353
357
|
abort (reason) {
|
|
358
|
+
if (aborted) {
|
|
359
|
+
return
|
|
360
|
+
}
|
|
354
361
|
aborted = true
|
|
355
|
-
|
|
362
|
+
abortReason = reason ?? new AbortError()
|
|
363
|
+
stream.destroy(abortReason)
|
|
356
364
|
}
|
|
357
365
|
}
|
|
358
366
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { createInflate, createGunzip, createBrotliDecompress, createZstdDecompress } = require('node:zlib')
|
|
3
|
+
const { createInflate, createGunzip, createBrotliDecompress, createZstdDecompress, constants } = require('node:zlib')
|
|
4
4
|
const { pipeline, Transform: TransformStream } = require('node:stream')
|
|
5
5
|
const { InvalidArgumentError, ResponseExceededMaxSizeError } = require('../core/errors')
|
|
6
6
|
const DecoratorHandler = require('../handler/decorator-handler')
|
|
@@ -63,6 +63,10 @@ class DecompressController {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
// `compress` and `x-compress` are deliberately absent. RFC 9110 section
|
|
67
|
+
// 8.4.1.1 defines them as the UNIX compress (LZW) format, which zlib cannot
|
|
68
|
+
// read, so inflating them turns a readable response into a Z_DATA_ERROR.
|
|
69
|
+
// fetch() leaves them alone, and so does this interceptor.
|
|
66
70
|
/** @type {Record<string, () => DecompressorStream>} */
|
|
67
71
|
const supportedEncodings = {
|
|
68
72
|
__proto__: null,
|
|
@@ -70,9 +74,8 @@ const supportedEncodings = {
|
|
|
70
74
|
'x-gzip': createGunzip,
|
|
71
75
|
br: createBrotliDecompress,
|
|
72
76
|
deflate: createInflate,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
zstd: createZstdDecompress
|
|
77
|
+
// https://www.rfc-editor.org/rfc/rfc9659.html#section-3
|
|
78
|
+
zstd: createZstdDecompress.bind(null, { params: { [constants.ZSTD_d_windowLogMax]: 23 } })
|
|
76
79
|
}
|
|
77
80
|
|
|
78
81
|
const defaultSkipStatusCodes = /** @type {const} */ ([204, 304])
|
|
@@ -220,9 +223,14 @@ class DecompressHandler extends DecoratorHandler {
|
|
|
220
223
|
this.#decompressedSize = decompressedSize
|
|
221
224
|
}
|
|
222
225
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
this.#controller.
|
|
226
|
+
try {
|
|
227
|
+
const result = super.onResponseData(this.#controller, chunk)
|
|
228
|
+
if (result === false && !this.#controller.paused) {
|
|
229
|
+
this.#controller.pause()
|
|
230
|
+
}
|
|
231
|
+
} catch (err) {
|
|
232
|
+
this.#fail(err)
|
|
233
|
+
return
|
|
226
234
|
}
|
|
227
235
|
}
|
|
228
236
|
} while (this.#drainRequested && !this.#terminated && !this.#controller.paused)
|
|
@@ -239,9 +247,14 @@ class DecompressHandler extends DecoratorHandler {
|
|
|
239
247
|
return
|
|
240
248
|
}
|
|
241
249
|
|
|
242
|
-
this.#terminated = true
|
|
243
250
|
this.#cleanupDecompressors()
|
|
244
|
-
|
|
251
|
+
try {
|
|
252
|
+
super.onResponseEnd(this.#controller, this.#trailers)
|
|
253
|
+
} catch (err) {
|
|
254
|
+
this.#fail(err)
|
|
255
|
+
return
|
|
256
|
+
}
|
|
257
|
+
this.#terminated = true
|
|
245
258
|
}
|
|
246
259
|
|
|
247
260
|
#onDecompressionEnd () {
|
|
@@ -190,6 +190,16 @@ class DNSInstance {
|
|
|
190
190
|
newOpts.affinity
|
|
191
191
|
)
|
|
192
192
|
|
|
193
|
+
// The lookup succeeded, but nothing it returned is usable here: with
|
|
194
|
+
// dualStack disabled and an affinity set, records of the other family
|
|
195
|
+
// cannot be picked. Running the lookup again would return the same
|
|
196
|
+
// records, so report it the way an empty result is reported.
|
|
197
|
+
if (ip == null) {
|
|
198
|
+
this.storage.delete(origin.hostname)
|
|
199
|
+
cb(new InformationalError('No DNS entries found'))
|
|
200
|
+
return
|
|
201
|
+
}
|
|
202
|
+
|
|
193
203
|
let port
|
|
194
204
|
if (typeof ip.port === 'number') {
|
|
195
205
|
port = `:${ip.port}`
|
|
@@ -346,6 +356,7 @@ class DNSInstance {
|
|
|
346
356
|
// We delete expired records
|
|
347
357
|
// It is possible that they have different TTL, so we manage them individually
|
|
348
358
|
family.ips.splice(position, 1)
|
|
359
|
+
return this.pickFamily(origin, ipFamily)
|
|
349
360
|
}
|
|
350
361
|
|
|
351
362
|
return ip
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
// const { parseHeaders } = require('../core/util')
|
|
4
4
|
const DecoratorHandler = require('../handler/decorator-handler')
|
|
5
|
-
const { ResponseError } = require('../core/errors')
|
|
5
|
+
const { InvalidArgumentError, ResponseError } = require('../core/errors')
|
|
6
|
+
|
|
7
|
+
const defaultMaxSize = 1024 * 1024
|
|
6
8
|
|
|
7
9
|
class ResponseErrorHandler extends DecoratorHandler {
|
|
8
10
|
#statusCode
|
|
@@ -10,9 +12,13 @@ class ResponseErrorHandler extends DecoratorHandler {
|
|
|
10
12
|
#decoder
|
|
11
13
|
#headers
|
|
12
14
|
#body
|
|
15
|
+
#bodySize
|
|
16
|
+
#bodyTruncated
|
|
17
|
+
#maxSize
|
|
13
18
|
|
|
14
|
-
constructor (
|
|
19
|
+
constructor ({ maxSize }, { handler }) {
|
|
15
20
|
super(handler)
|
|
21
|
+
this.#maxSize = maxSize
|
|
16
22
|
}
|
|
17
23
|
|
|
18
24
|
#checkContentType (contentType) {
|
|
@@ -25,6 +31,8 @@ class ResponseErrorHandler extends DecoratorHandler {
|
|
|
25
31
|
this.#decoder = null
|
|
26
32
|
this.#headers = null
|
|
27
33
|
this.#body = ''
|
|
34
|
+
this.#bodySize = 0
|
|
35
|
+
this.#bodyTruncated = false
|
|
28
36
|
|
|
29
37
|
return super.onRequestStart(controller, context)
|
|
30
38
|
}
|
|
@@ -43,39 +51,69 @@ class ResponseErrorHandler extends DecoratorHandler {
|
|
|
43
51
|
}
|
|
44
52
|
}
|
|
45
53
|
|
|
54
|
+
#createResponseError () {
|
|
55
|
+
this.#body += this.#decoder?.decode(undefined, { stream: false }) ?? ''
|
|
56
|
+
this.#decoder = null
|
|
57
|
+
|
|
58
|
+
if (!this.#bodyTruncated && this.#checkContentType('application/json')) {
|
|
59
|
+
try {
|
|
60
|
+
this.#body = JSON.parse(this.#body)
|
|
61
|
+
} catch {
|
|
62
|
+
// Do nothing...
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let err
|
|
67
|
+
const stackTraceLimit = Error.stackTraceLimit
|
|
68
|
+
Error.stackTraceLimit = 0
|
|
69
|
+
try {
|
|
70
|
+
err = new ResponseError('Response Error', this.#statusCode, {
|
|
71
|
+
body: this.#body,
|
|
72
|
+
bodyTruncated: this.#bodyTruncated,
|
|
73
|
+
headers: this.#headers
|
|
74
|
+
})
|
|
75
|
+
} finally {
|
|
76
|
+
Error.stackTraceLimit = stackTraceLimit
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return err
|
|
80
|
+
}
|
|
81
|
+
|
|
46
82
|
onResponseData (controller, chunk) {
|
|
47
83
|
if (this.#statusCode < 400) {
|
|
48
84
|
return super.onResponseData(controller, chunk)
|
|
49
85
|
}
|
|
50
86
|
|
|
51
|
-
|
|
87
|
+
if (this.#decoder == null) {
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (this.#maxSize === 0) {
|
|
92
|
+
this.#body += this.#decoder.decode(chunk, { stream: true })
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const remaining = this.#maxSize - this.#bodySize
|
|
97
|
+
|
|
98
|
+
if (chunk.length <= remaining) {
|
|
99
|
+
this.#bodySize += chunk.length
|
|
100
|
+
this.#body += this.#decoder.decode(chunk, { stream: true })
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (remaining > 0) {
|
|
105
|
+
this.#body += this.#decoder.decode(chunk.subarray(0, remaining), { stream: true })
|
|
106
|
+
this.#bodySize = this.#maxSize
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
this.#bodyTruncated = true
|
|
110
|
+
this.#body += this.#decoder.decode(undefined, { stream: false })
|
|
111
|
+
this.#decoder = null
|
|
52
112
|
}
|
|
53
113
|
|
|
54
114
|
onResponseEnd (controller, trailers) {
|
|
55
115
|
if (this.#statusCode >= 400) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (this.#checkContentType('application/json')) {
|
|
59
|
-
try {
|
|
60
|
-
this.#body = JSON.parse(this.#body)
|
|
61
|
-
} catch {
|
|
62
|
-
// Do nothing...
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
let err
|
|
67
|
-
const stackTraceLimit = Error.stackTraceLimit
|
|
68
|
-
Error.stackTraceLimit = 0
|
|
69
|
-
try {
|
|
70
|
-
err = new ResponseError('Response Error', this.#statusCode, {
|
|
71
|
-
body: this.#body,
|
|
72
|
-
headers: this.#headers
|
|
73
|
-
})
|
|
74
|
-
} finally {
|
|
75
|
-
Error.stackTraceLimit = stackTraceLimit
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
super.onResponseError(controller, err)
|
|
116
|
+
super.onResponseError(controller, this.#createResponseError())
|
|
79
117
|
} else {
|
|
80
118
|
super.onResponseEnd(controller, trailers)
|
|
81
119
|
}
|
|
@@ -86,10 +124,16 @@ class ResponseErrorHandler extends DecoratorHandler {
|
|
|
86
124
|
}
|
|
87
125
|
}
|
|
88
126
|
|
|
89
|
-
module.exports = () => {
|
|
127
|
+
module.exports = (opts = {}) => {
|
|
128
|
+
const { maxSize = defaultMaxSize } = opts
|
|
129
|
+
|
|
130
|
+
if (!Number.isSafeInteger(maxSize) || maxSize < 0) {
|
|
131
|
+
throw new InvalidArgumentError('maxSize must be a non-negative integer')
|
|
132
|
+
}
|
|
133
|
+
|
|
90
134
|
return (dispatch) => {
|
|
91
135
|
return function Intercept (opts, handler) {
|
|
92
|
-
return dispatch(opts, new ResponseErrorHandler(
|
|
136
|
+
return dispatch(opts, new ResponseErrorHandler({ maxSize }, { handler }))
|
|
93
137
|
}
|
|
94
138
|
}
|
|
95
139
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023, and above Paolo Insogna, NearForm and other contributors
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|