maka-agent 0.2.2-dev.92.20261019 → 0.2.2-dev.97.20261024
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -7
- package/README.md +78 -18
- package/README.zh-CN.md +73 -15
- package/THIRD_PARTY_NOTICES.txt +12 -12
- package/dist/pi-goal.js +13 -0
- package/dist/pi-tui-runner.js +44 -1
- package/dist/run-command-core.js +111 -70
- package/dist/run-session-command.js +91 -15
- package/dist/run-turn-outcome.js +2 -33
- package/dist/runtime-host-session-channel.js +3 -1
- package/dist/runtime-host-session-driver.js +5 -0
- package/dist/tui-copy-catalog.js +24 -0
- package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/docs/docs/api/Client.md +2 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/core/symbols.js +1 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client-h1.js +0 -2
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client-h2.js +0 -4
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/client.js +3 -2
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/dispatcher/dispatcher-base.js +12 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/cache-handler.js +48 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/deduplication-handler.js +57 -13
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/handler/redirect-handler.js +8 -1
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/interceptor/decompress.js +15 -5
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/index.js +3 -1
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/parse.js +138 -137
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/cookies/util.js +21 -2
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/eventsource/eventsource-stream.js +90 -9
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/eventsource/eventsource.js +4 -1
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/fetch/index.js +3 -3
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/infra/index.js +14 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/lib/web/websocket/receiver.js +13 -0
- package/node_modules/@ai-sdk/provider-utils/node_modules/undici/package.json +1 -1
- package/node_modules/@maka/acp-executor-plugin/dist/acp-catalog-store.js +87 -0
- package/node_modules/@maka/acp-executor-plugin/dist/acp-catalog.js +98 -21
- package/node_modules/@maka/acp-executor-plugin/dist/index.js +90 -14
- package/node_modules/@maka/acp-executor-plugin/dist/plugin.mjs +3997 -56
- package/node_modules/@maka/core/dist/assistant-turn-ids.js +34 -0
- package/node_modules/@maka/core/dist/event-wait.js +28 -10
- package/node_modules/@maka/core/dist/executor-catalog.js +3 -1
- package/node_modules/@maka/core/dist/model-catalog.js +19 -1
- package/node_modules/@maka/core/dist/model-metadata.generated.js +4 -14
- package/node_modules/@maka/core/dist/model-metadata.js +42 -1
- package/node_modules/@maka/core/dist/models-dev-projection.js +32 -1
- package/node_modules/@maka/core/dist/provider-registry.js +16 -2
- package/node_modules/@maka/core/dist/runtime-event.js +8 -0
- package/node_modules/@maka/core/dist/session-checkin.js +31 -0
- package/node_modules/@maka/core/dist/usage-stats/types.js +1 -0
- package/node_modules/@maka/core/package.json +2 -0
- package/node_modules/@maka/eval/node_modules/undici/README.md +25 -3
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Client.md +11 -6
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Errors.md +76 -1
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/index.md +12 -12
- package/node_modules/@maka/eval/node_modules/undici/docs/docs/type-map.json +66 -66
- package/node_modules/@maka/eval/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
- package/node_modules/@maka/eval/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
- package/node_modules/@maka/eval/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/@maka/eval/node_modules/undici/lib/core/constants.js +12 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/core/errors.js +38 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/core/request.js +16 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/core/symbols.js +2 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/core/util.js +26 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/client.js +4 -1
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/pool.js +11 -8
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
- package/node_modules/@maka/eval/node_modules/undici/lib/handler/cache-handler.js +153 -15
- package/node_modules/@maka/eval/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
- package/node_modules/@maka/eval/node_modules/undici/lib/handler/redirect-handler.js +28 -8
- package/node_modules/@maka/eval/node_modules/undici/lib/handler/retry-handler.js +44 -11
- package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/cache.js +11 -3
- package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/decompress.js +22 -9
- package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/dns.js +11 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/interceptor/response-error.js +72 -28
- package/node_modules/@maka/eval/node_modules/undici/lib/milo/LICENSE.md +7 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/milo/no-simd.js +1002 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/milo/simd.js +1002 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/mock/mock-agent.js +11 -0
- package/node_modules/@maka/eval/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/util/cache.js +11 -5
- package/node_modules/@maka/eval/node_modules/undici/lib/web/cookies/util.js +19 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
- package/node_modules/@maka/eval/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/body.js +47 -38
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/headers.js +2 -2
- package/node_modules/@maka/eval/node_modules/undici/lib/web/fetch/index.js +8 -4
- package/node_modules/@maka/eval/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/@maka/eval/node_modules/undici/lib/web/websocket/receiver.js +25 -4
- package/node_modules/@maka/eval/node_modules/undici/package.json +9 -7
- package/node_modules/@maka/mcp/package.json +1 -1
- package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +22 -9
- package/node_modules/@maka/runtime/dist/ai-sdk-message-projection.js +10 -1
- package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +101 -127
- package/node_modules/@maka/runtime/dist/event-wait-tool.js +2 -2
- package/node_modules/@maka/runtime/dist/history-compact-checkpoint.js +32 -1
- package/node_modules/@maka/runtime/dist/history-compaction.js +7 -0
- package/node_modules/@maka/runtime/dist/model-factory.js +26 -6
- package/node_modules/@maka/runtime/dist/model-fetcher.js +8 -1
- package/node_modules/@maka/runtime/dist/model-history.js +16 -3
- package/node_modules/@maka/runtime/dist/openai-codex-history-compactor.js +7 -2
- package/node_modules/@maka/runtime/dist/plugin-executor-backend.js +49 -2
- package/node_modules/@maka/runtime/dist/plugin-executor-service.js +12 -3
- package/node_modules/@maka/runtime/dist/runtime-context.js +53 -0
- package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +3 -0
- package/node_modules/@maka/runtime/dist/session-checkin.js +331 -0
- package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +7 -0
- package/node_modules/@maka/runtime/dist/shell-run-manager.js +34 -0
- package/node_modules/@maka/runtime/dist/telemetry/builtin-pricing.js +21 -2
- package/node_modules/@maka/runtime/dist/tool-runtime.js +8 -0
- package/node_modules/@maka/runtime/dist/workers/filesystem-worker.mjs +50 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/docs/docs/api/Client.md +2 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/core/symbols.js +1 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client-h1.js +0 -2
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client-h2.js +0 -4
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/client.js +3 -2
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/dispatcher/dispatcher-base.js +12 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/cache-handler.js +48 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/deduplication-handler.js +57 -13
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/handler/redirect-handler.js +8 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/interceptor/decompress.js +15 -5
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/index.js +3 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/parse.js +138 -137
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/cookies/util.js +21 -2
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/eventsource/eventsource-stream.js +90 -9
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/eventsource/eventsource.js +4 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/fetch/index.js +3 -3
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/infra/index.js +14 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/lib/web/websocket/receiver.js +13 -0
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/node_modules/undici/package.json +1 -1
- package/node_modules/@maka/runtime/node_modules/@slack/socket-mode/package.json +1 -1
- package/node_modules/@maka/runtime/node_modules/undici/README.md +25 -3
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Client.md +11 -6
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Errors.md +76 -1
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/index.md +12 -12
- package/node_modules/@maka/runtime/node_modules/undici/docs/docs/type-map.json +66 -66
- package/node_modules/@maka/runtime/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
- package/node_modules/@maka/runtime/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/constants.js +12 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/errors.js +38 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/request.js +16 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/symbols.js +2 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/core/util.js +26 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/client.js +4 -1
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/pool.js +11 -8
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
- package/node_modules/@maka/runtime/node_modules/undici/lib/handler/cache-handler.js +153 -15
- package/node_modules/@maka/runtime/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
- package/node_modules/@maka/runtime/node_modules/undici/lib/handler/redirect-handler.js +28 -8
- package/node_modules/@maka/runtime/node_modules/undici/lib/handler/retry-handler.js +44 -11
- package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/cache.js +11 -3
- package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/decompress.js +22 -9
- package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/dns.js +11 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/interceptor/response-error.js +72 -28
- package/node_modules/@maka/runtime/node_modules/undici/lib/milo/LICENSE.md +7 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/milo/no-simd.js +1002 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/milo/simd.js +1002 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/mock/mock-agent.js +11 -0
- package/node_modules/@maka/runtime/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/util/cache.js +11 -5
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/cookies/util.js +19 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/body.js +47 -38
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/headers.js +2 -2
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/fetch/index.js +8 -4
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/@maka/runtime/node_modules/undici/lib/web/websocket/receiver.js +25 -4
- package/node_modules/@maka/runtime/node_modules/undici/package.json +9 -7
- package/node_modules/@maka/runtime/package.json +2 -0
- package/node_modules/@maka/runtime-host/dist/assistant/bot/bridge.js +8 -0
- package/node_modules/@maka/runtime-host/dist/assistant/bot/capabilities.js +1 -0
- package/node_modules/@maka/runtime-host/dist/assistant/bot/controller.js +64 -13
- package/node_modules/@maka/runtime-host/dist/assistant/bot/host.js +11 -2
- package/node_modules/@maka/runtime-host/dist/assistant/bot/store.js +71 -2
- package/node_modules/@maka/runtime-host/dist/assistant/bot/turn-ids.js +38 -0
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/assistant.js +7 -0
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/controller.js +193 -32
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/discovery-capabilities.js +69 -0
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/host.js +15 -28
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/notebook.js +286 -0
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/prompt.js +31 -6
- package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/store.js +18 -1
- package/node_modules/@maka/runtime-host/dist/assistant/memory-network/controller.js +1 -1
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition-observer.js +94 -0
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition-store.js +253 -0
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/condition.js +133 -0
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/controller.js +27 -14
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/delegation.js +35 -5
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/delivery.js +1 -1
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/host.js +16 -2
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/matter.js +13 -0
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/prompt.js +7 -5
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/review.js +1 -1
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/settlement-context.js +126 -0
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/store.js +92 -6
- package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/tools.js +87 -23
- package/node_modules/@maka/runtime-host/dist/assistant/service.js +49 -5
- package/node_modules/@maka/runtime-host/dist/protocol/goal.js +119 -1
- package/node_modules/@maka/runtime-host/dist/protocol/index.js +7 -1
- package/node_modules/@maka/runtime-host/dist/protocol/operations.js +8 -1
- package/node_modules/@maka/runtime-host/dist/protocol/personal-assistant.js +1 -0
- package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +7 -1
- package/node_modules/@maka/runtime-host/dist/protocol/session-checkin.js +133 -0
- package/node_modules/@maka/runtime-host/dist/server/canonical-session-projection.js +3 -2
- package/node_modules/@maka/runtime-host/dist/server/event-wait-manager.js +63 -12
- package/node_modules/@maka/runtime-host/dist/server/event-wait-observation-store.js +19 -0
- package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +123 -11
- package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +47 -3
- package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +126 -4
- package/node_modules/@maka/runtime-host/dist/server/goal-event-waits.js +58 -19
- package/node_modules/@maka/runtime-host/dist/server/goal-projection.js +24 -3
- package/node_modules/@maka/runtime-host/dist/server/index.js +2 -0
- package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +44 -2
- package/node_modules/@maka/runtime-host/dist/server/personal-assistant-workspace.js +78 -0
- package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +73 -3
- package/node_modules/@maka/runtime-host/dist/server/session-checkin.js +257 -0
- package/node_modules/@maka/runtime-host/dist/server/session-checkpoint-coordinator.js +282 -0
- package/node_modules/@maka/runtime-host/dist/server/session-checkpoint-publication.js +250 -0
- package/node_modules/@maka/runtime-host/dist/server/shell-run-event-wait-access.js +166 -0
- package/node_modules/@maka/runtime-host/dist/server/shell-run-event-wait-adapter.js +59 -0
- package/node_modules/@maka/runtime-host/dist/server/skill-catalog-repository.js +4 -2
- package/node_modules/@maka/storage/dist/context-offload-snapshot.js +2 -1
- package/node_modules/@maka/storage/dist/execution-stores.js +36 -1
- package/node_modules/@maka/storage/dist/local-execution-persistence.js +26 -0
- package/node_modules/@maka/storage/dist/production-session-snapshot.js +14 -6
- package/node_modules/@maka/storage/dist/runtime-event-persistence.js +1 -0
- package/node_modules/@maka/storage/dist/session-bundle-policy.js +86 -16
- package/node_modules/@maka/storage/dist/session-checkpoint-publication-store.js +204 -0
- package/node_modules/@maka/storage/dist/snapshot-operation-gate.js +65 -0
- package/node_modules/@maka/storage/dist/sqlite-context-offload-schema.js +3 -3
- package/node_modules/@maka/storage/dist/sqlite-context-offload-store.js +4 -2
- package/node_modules/@maka/storage/dist/sqlite-reclamation-checkpoint.js +37 -0
- package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +31 -0
- package/node_modules/@maka/storage/package.json +3 -0
- package/node_modules/@modelcontextprotocol/client/dist/index-B-4n9P0J.d.mts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/index-J2FaQ-KY.d.cts.map +1 -0
- package/node_modules/@modelcontextprotocol/client/dist/index.cjs +76 -22
- package/node_modules/@modelcontextprotocol/client/dist/index.d.cts.map +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/index.d.mts.map +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/index.mjs +76 -22
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.cjs +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/shimsWorkerd.mjs +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/{src-oZBjf3U1.cjs → src-DpAS0jfg.cjs} +105 -8
- package/node_modules/@modelcontextprotocol/client/dist/{src-xKF0PJN-.mjs → src-WCy6ifGf.mjs} +88 -9
- package/node_modules/@modelcontextprotocol/client/dist/stdio.cjs +1 -1
- package/node_modules/@modelcontextprotocol/client/dist/stdio.mjs +1 -1
- package/node_modules/@modelcontextprotocol/client/node_modules/@modelcontextprotocol/core/package.json +2 -2
- package/node_modules/@modelcontextprotocol/client/package.json +5 -5
- package/node_modules/fast-uri/.github/workflows/release.yml +35 -0
- package/node_modules/fast-uri/README.md +8 -0
- package/node_modules/fast-uri/index.js +98 -18
- package/node_modules/fast-uri/lib/utils.js +52 -0
- package/node_modules/fast-uri/package.json +1 -1
- package/node_modules/follow-redirects/index.js +10 -1
- package/node_modules/follow-redirects/package.json +1 -1
- package/node_modules/ip-address/README.md +104 -104
- package/node_modules/ip-address/dist/ipv4.js +7 -0
- package/node_modules/ip-address/dist/ipv6.js +7 -4
- package/node_modules/ip-address/dist/v6/constants.js +3 -0
- package/node_modules/ip-address/package.json +2 -1
- package/node_modules/undici/README.md +25 -3
- package/node_modules/undici/docs/docs/api/CacheStore.md +24 -9
- package/node_modules/undici/docs/docs/api/Client.md +11 -6
- package/node_modules/undici/docs/docs/api/Dispatcher.md +3 -0
- package/node_modules/undici/docs/docs/api/Errors.md +76 -1
- package/node_modules/undici/docs/docs/api/H2CClient.md +3 -2
- package/node_modules/undici/docs/docs/api/Interceptors.md +28 -8
- package/node_modules/undici/docs/docs/api/RedirectHandler.md +13 -10
- package/node_modules/undici/docs/docs/index.md +12 -12
- package/node_modules/undici/docs/docs/type-map.json +66 -66
- package/node_modules/undici/lib/cache/memory-cache-store.js +48 -13
- package/node_modules/undici/lib/cache/sqlite-cache-store.js +83 -5
- package/node_modules/undici/lib/core/connect.js +10 -4
- package/node_modules/undici/lib/core/constants.js +12 -1
- package/node_modules/undici/lib/core/errors.js +38 -1
- package/node_modules/undici/lib/core/request.js +16 -1
- package/node_modules/undici/lib/core/symbols.js +2 -0
- package/node_modules/undici/lib/core/util.js +26 -1
- package/node_modules/undici/lib/dispatcher/agent.js +6 -2
- package/node_modules/undici/lib/dispatcher/client-h1.js +116 -80
- package/node_modules/undici/lib/dispatcher/client-h2.js +124 -17
- package/node_modules/undici/lib/dispatcher/client.js +4 -1
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +3 -2
- package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +20 -3
- package/node_modules/undici/lib/dispatcher/parser-h1.js +1064 -0
- package/node_modules/undici/lib/dispatcher/pool-base.js +85 -31
- package/node_modules/undici/lib/dispatcher/pool.js +11 -8
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +18 -8
- package/node_modules/undici/lib/dispatcher/retry-agent.js +10 -0
- package/node_modules/undici/lib/dispatcher/round-robin-pool.js +15 -5
- package/node_modules/undici/lib/handler/cache-handler.js +153 -15
- package/node_modules/undici/lib/handler/deduplication-handler.js +112 -51
- package/node_modules/undici/lib/handler/redirect-handler.js +28 -8
- package/node_modules/undici/lib/handler/retry-handler.js +44 -11
- package/node_modules/undici/lib/interceptor/cache.js +11 -3
- package/node_modules/undici/lib/interceptor/decompress.js +22 -9
- package/node_modules/undici/lib/interceptor/dns.js +11 -0
- package/node_modules/undici/lib/interceptor/response-error.js +72 -28
- package/node_modules/undici/lib/milo/LICENSE.md +7 -0
- package/node_modules/undici/lib/milo/no-simd.js +1002 -0
- package/node_modules/undici/lib/milo/simd.js +1002 -0
- package/node_modules/undici/lib/mock/mock-agent.js +11 -0
- package/node_modules/undici/lib/mock/snapshot-recorder.js +3 -2
- package/node_modules/undici/lib/mock/snapshot-utils.js +3 -2
- package/node_modules/undici/lib/util/cache.js +11 -5
- package/node_modules/undici/lib/web/cookies/util.js +19 -2
- package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +69 -15
- package/node_modules/undici/lib/web/eventsource/eventsource.js +25 -2
- package/node_modules/undici/lib/web/fetch/body.js +47 -38
- package/node_modules/undici/lib/web/fetch/formdata-parser.js +12 -4
- package/node_modules/undici/lib/web/fetch/headers.js +2 -2
- package/node_modules/undici/lib/web/fetch/index.js +8 -4
- package/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +5 -5
- package/node_modules/undici/lib/web/websocket/receiver.js +25 -4
- package/node_modules/undici/package.json +9 -7
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/zod/v4/core/versions.js +1 -1
- package/package.json +2 -2
- package/node_modules/@modelcontextprotocol/client/dist/index-D_CiY-T3.d.cts.map +0 -1
- package/node_modules/@modelcontextprotocol/client/dist/index-D_QDtbiv.d.mts.map +0 -1
|
@@ -116,8 +116,8 @@ added: v1.0.0
|
|
|
116
116
|
* `maxConcurrentStreams` {number} _Deprecated: use h2Options.useH2c instead_ The maximum number of concurrent HTTP/2
|
|
117
117
|
streams for a single session. Once h2 is negotiated this — not `pipelining`,
|
|
118
118
|
which is HTTP/1.1 only — is the ceiling used to dispatch in-flight requests.
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
The server's `SETTINGS_MAX_CONCURRENT_STREAMS` can lower this limit, but
|
|
120
|
+
not raise it. **Default:** `100`.
|
|
121
121
|
* `connectionWindowSize` {number} _Deprecated: use h2Options.connectionWindowSize instead_ The HTTP/2 connection-level flow-control
|
|
122
122
|
window size set via `ClientHttp2Session.setLocalWindowSize()`. Must be a
|
|
123
123
|
positive integer. **Default:** `524288`.
|
|
@@ -130,8 +130,8 @@ added: v1.0.0
|
|
|
130
130
|
* `maxConcurrentStreams` {number} The maximum number of concurrent HTTP/2
|
|
131
131
|
streams for a single session. Once h2 is negotiated this — not `pipelining`,
|
|
132
132
|
which is HTTP/1.1 only — is the ceiling used to dispatch in-flight requests.
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
The server's `SETTINGS_MAX_CONCURRENT_STREAMS` can lower this limit, but
|
|
134
|
+
not raise it. **Default:** `100`.
|
|
135
135
|
* `connectionWindowSize` {number} The HTTP/2 connection-level flow-control
|
|
136
136
|
window size set via `ClientHttp2Session.setLocalWindowSize()`. Must be a
|
|
137
137
|
positive integer. **Default:** `524288`.
|
|
@@ -148,8 +148,13 @@ added: v1.0.0
|
|
|
148
148
|
payloads, and decompressed (`permessage-deflate`) messages. Set to `0` to
|
|
149
149
|
disable the limit. **Default:** `134217728`.
|
|
150
150
|
* `eventSource` {Object} (optional) EventSource-specific configuration.
|
|
151
|
-
* `maxEventSize` {number} The maximum
|
|
152
|
-
|
|
151
|
+
* `maxEventSize` {number} The maximum total bytes of data and metadata
|
|
152
|
+
field values retained for a pending EventSource event. Each unfinished
|
|
153
|
+
line is separately limited to this value plus seven syntax bytes, before
|
|
154
|
+
its line ending arrives. The number of `data:` lines per event and input
|
|
155
|
+
chunks buffered for an unfinished line are each limited to
|
|
156
|
+
`min(131072, max(1024, floor(maxEventSize / 128)))` to bound object overhead.
|
|
157
|
+
Set to `0` to disable these limits.
|
|
153
158
|
**Default:** `buffer.kStringMaxLength`.
|
|
154
159
|
* Returns: {Client}
|
|
155
160
|
|
|
@@ -209,6 +209,9 @@ added: v4.0.0
|
|
|
209
209
|
* `path` {string} The request path.
|
|
210
210
|
* `method` {string} The HTTP method, e.g. `'GET'` or `'POST'`.
|
|
211
211
|
* `body` {string|Buffer|Uint8Array|Readable|FormData|null} The request body.
|
|
212
|
+
Undici's network clients require a `FormData` body created by the same
|
|
213
|
+
undici package instance. A body from another source, including Node.js's
|
|
214
|
+
built-in `FormData`, is rejected with an `InvalidArgumentError`.
|
|
212
215
|
**Default:** `null`.
|
|
213
216
|
* `headers` {UndiciHeaders} Request headers. **Default:** `null`.
|
|
214
217
|
* `query` {Object} Query string parameters embedded into the request URL. Both
|
|
@@ -18,7 +18,7 @@ if (err instanceof errors.ConnectTimeoutError) {
|
|
|
18
18
|
}
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
All errors, except [`HTTPParserError`][]
|
|
21
|
+
All errors, except [`HTTPParserError`][] and `WebAssemblyNotSupportedError`, extend [`UndiciError`][]. Each error
|
|
22
22
|
carries a stable `code` string (for example `UND_ERR_CONNECT_TIMEOUT`) and a
|
|
23
23
|
`name`.
|
|
24
24
|
|
|
@@ -32,6 +32,37 @@ if (err.code === 'UND_ERR_CONNECT_TIMEOUT') {
|
|
|
32
32
|
}
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
+
## Timeout-related errors
|
|
36
|
+
|
|
37
|
+
The timeout errors below are controlled by dispatcher/client options:
|
|
38
|
+
|
|
39
|
+
| Error code | When it is thrown | Related option |
|
|
40
|
+
| ---------- | ----------------- | -------------- |
|
|
41
|
+
| `UND_ERR_CONNECT_TIMEOUT` | A connection could not be established before the connection timeout elapsed. | [`connect.timeout`](Client.md) |
|
|
42
|
+
| `UND_ERR_HEADERS_TIMEOUT` | The full response headers were not received before the headers timeout elapsed. | [`headersTimeout`](Client.md) |
|
|
43
|
+
| `UND_ERR_BODY_TIMEOUT` | While reading the response body, no new data arrived before the body timeout elapsed. | [`bodyTimeout`](Client.md) |
|
|
44
|
+
| `UND_ERR_SOCKET` | A generic socket-level failure happened. | Inspect `error.socket` for connection details. |
|
|
45
|
+
|
|
46
|
+
### Configuring timeouts for `fetch`
|
|
47
|
+
|
|
48
|
+
If you are using `fetch` (including Node.js built-in `fetch`), configure timeouts
|
|
49
|
+
through the global dispatcher:
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
import { Agent, setGlobalDispatcher, fetch } from 'undici'
|
|
53
|
+
|
|
54
|
+
setGlobalDispatcher(new Agent({
|
|
55
|
+
connect: { timeout: 10_000 }, // connection phase
|
|
56
|
+
headersTimeout: 15_000, // wait for response headers
|
|
57
|
+
bodyTimeout: 30_000 // wait between response body chunks
|
|
58
|
+
}))
|
|
59
|
+
|
|
60
|
+
await fetch('https://example.com/data')
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
You can inspect timeout error codes from `error.code` or (for wrapped fetch
|
|
64
|
+
errors) from `error.cause?.code`.
|
|
65
|
+
|
|
35
66
|
## Class: `UndiciError`
|
|
36
67
|
|
|
37
68
|
<!-- YAML
|
|
@@ -52,6 +83,35 @@ on a well-known symbol rather than the prototype chain.
|
|
|
52
83
|
* `name` {string} Always `'UndiciError'`.
|
|
53
84
|
* `code` {string} Always `'UND_ERR'`.
|
|
54
85
|
|
|
86
|
+
## Class: `WebAssemblyNotSupportedError`
|
|
87
|
+
|
|
88
|
+
* Extends: {Error}
|
|
89
|
+
|
|
90
|
+
WebAssembly is unavailable when Undici initializes its HTTP/1 parser. Undici does
|
|
91
|
+
not provide an alternative parser for environments without WebAssembly, including
|
|
92
|
+
Node.js configurations where `--jitless` disables it. The check is performed when
|
|
93
|
+
the parser is needed, not when importing Undici or accessing `fetch`.
|
|
94
|
+
|
|
95
|
+
* `name` {string} Always `'Error'`.
|
|
96
|
+
* `code` {string} Always `'ERR_WEBASSEMBLY_NOT_SUPPORTED'`.
|
|
97
|
+
* `message` {string} By default `'WebAssembly is not supported in this environment, but is required for HTTP/1 parsing'`.
|
|
98
|
+
|
|
99
|
+
Client and dispatcher requests report this error directly. `fetch` rejects with
|
|
100
|
+
a `TypeError` whose `cause` is this error:
|
|
101
|
+
|
|
102
|
+
```js
|
|
103
|
+
try {
|
|
104
|
+
await fetch('http://localhost:3000')
|
|
105
|
+
} catch (error) {
|
|
106
|
+
if (error.cause?.code === 'ERR_WEBASSEMBLY_NOT_SUPPORTED') {
|
|
107
|
+
// HTTP/1 parsing requires WebAssembly in this environment.
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
`Headers`, `FormData`, `Request`, `Response`, and other operations that do not need
|
|
113
|
+
the HTTP/1 parser remain usable without WebAssembly.
|
|
114
|
+
|
|
55
115
|
## Class: `ConnectTimeoutError`
|
|
56
116
|
|
|
57
117
|
<!-- YAML
|
|
@@ -436,6 +496,7 @@ The response returned an error status code. This is raised, for example, when th
|
|
|
436
496
|
* `code` {string} Always `'UND_ERR_RESPONSE'`.
|
|
437
497
|
* `statusCode` {number} The HTTP status code of the response.
|
|
438
498
|
* `body` {Object|string|null} The response body.
|
|
499
|
+
* `bodyTruncated` {boolean} Whether `body` was truncated by a configured limit.
|
|
439
500
|
* `headers` {Object|string[]|null} The response headers.
|
|
440
501
|
|
|
441
502
|
### `new ResponseError(message, code, options)`
|
|
@@ -445,6 +506,7 @@ The response returned an error status code. This is raised, for example, when th
|
|
|
445
506
|
* `options` {Object}
|
|
446
507
|
* `headers` {Object|string[]|null} The response headers. (optional)
|
|
447
508
|
* `body` {Object|string|null} The response body. (optional)
|
|
509
|
+
* `bodyTruncated` {boolean} Whether `body` was truncated. **Default:** `false`.
|
|
448
510
|
|
|
449
511
|
## Class: `ProxyConnectionError`
|
|
450
512
|
|
|
@@ -512,6 +574,19 @@ The maximum number of allowed origins has been reached.
|
|
|
512
574
|
* `name` {string} Always `'MaxOriginsReachedError'`.
|
|
513
575
|
* `code` {string} Always `'UND_ERR_MAX_ORIGINS_REACHED'`.
|
|
514
576
|
|
|
577
|
+
## Class: `MaxRedirectsError`
|
|
578
|
+
|
|
579
|
+
<!-- YAML
|
|
580
|
+
added: v8.12.0
|
|
581
|
+
-->
|
|
582
|
+
|
|
583
|
+
* Extends: {UndiciError}
|
|
584
|
+
|
|
585
|
+
The maximum number of redirects has been reached.
|
|
586
|
+
|
|
587
|
+
* `name` {string} Always `'MaxRedirectsError'`.
|
|
588
|
+
* `code` {string} Always `'UND_ERR_REDIRECT_MAX'`.
|
|
589
|
+
|
|
515
590
|
## Class: `Socks5ProxyError`
|
|
516
591
|
|
|
517
592
|
<!-- YAML
|
|
@@ -55,8 +55,9 @@ added: v7.7.0
|
|
|
55
55
|
hostname, and port. Only the `http:` protocol is supported.
|
|
56
56
|
* `options` {H2CClientOptions} (optional)
|
|
57
57
|
* `maxConcurrentStreams` {number} The maximum number of concurrent HTTP/2
|
|
58
|
-
streams for the session.
|
|
59
|
-
|
|
58
|
+
streams for the session. The server's `SETTINGS_MAX_CONCURRENT_STREAMS` can
|
|
59
|
+
lower this limit, but not raise it. Must be a positive integer.
|
|
60
|
+
**Default:** `100`.
|
|
60
61
|
* `pipelining` {number} The number of concurrent requests multiplexed over the
|
|
61
62
|
single connection. For an `H2CClient` this is aliased to
|
|
62
63
|
`maxConcurrentStreams` and may not exceed it. Must be a positive integer.
|
|
@@ -163,9 +163,10 @@ Follows HTTP redirects (3xx responses) automatically.
|
|
|
163
163
|
* `maxRedirections` {number} Maximum number of redirects to follow. Passing
|
|
164
164
|
`0` disables redirect following entirely. **Default:** `undefined`
|
|
165
165
|
(inherits from the per-request `maxRedirections` option).
|
|
166
|
-
* `throwOnMaxRedirect` {boolean} When `true`, throws an error
|
|
167
|
-
redirect
|
|
168
|
-
|
|
166
|
+
* `throwOnMaxRedirect` {boolean} When `true`, throws an error when a
|
|
167
|
+
redirect would be followed but the redirect limit has been reached, instead
|
|
168
|
+
of returning that redirect response. A non-redirect response after exactly
|
|
169
|
+
`maxRedirections` redirects is returned normally. **Default:** `false`.
|
|
169
170
|
* `stripHeadersOnRedirect` {string[]} List of header names to remove from
|
|
170
171
|
the request when following any redirect. **Default:** `[]`.
|
|
171
172
|
* `stripHeadersOnCrossOriginRedirect` {string[]} List of header names to
|
|
@@ -198,7 +199,10 @@ const agent = new Agent().compose(
|
|
|
198
199
|
## `interceptors.decompress([opts])`
|
|
199
200
|
|
|
200
201
|
Automatically decompresses response bodies encoded with `gzip`, `x-gzip`,
|
|
201
|
-
`br` (Brotli), `deflate`,
|
|
202
|
+
`br` (Brotli), `deflate`, or `zstd`. Any other coding, including `compress`
|
|
203
|
+
and `x-compress`, is left untouched, matching `fetch()`. As required by
|
|
204
|
+
[RFC 9659](https://www.rfc-editor.org/rfc/rfc9659.html), a `zstd` frame that
|
|
205
|
+
requires a window size larger than 8 MB fails to decode.
|
|
202
206
|
|
|
203
207
|
> **Experimental:** This interceptor is experimental and subject to change.
|
|
204
208
|
> A one-time `ExperimentalWarning` is emitted on first use.
|
|
@@ -244,8 +248,11 @@ The error body is automatically decoded for `application/json` and
|
|
|
244
248
|
|
|
245
249
|
**Parameters**
|
|
246
250
|
|
|
247
|
-
* `opts` {Object} (optional)
|
|
248
|
-
|
|
251
|
+
* `opts` {Object} (optional)
|
|
252
|
+
* `maxSize` {number} Maximum number of response body bytes to include in the
|
|
253
|
+
error. If the body exceeds this limit, the resulting `ResponseError`
|
|
254
|
+
contains the retained prefix with `bodyTruncated` set to `true`. Set to `0`
|
|
255
|
+
to disable the limit. **Default:** `1048576` (1 MiB).
|
|
249
256
|
|
|
250
257
|
**Returns:** {Dispatcher.DispatcherComposeInterceptor}
|
|
251
258
|
|
|
@@ -334,8 +341,21 @@ backing store.
|
|
|
334
341
|
|
|
335
342
|
**Parameters**
|
|
336
343
|
|
|
337
|
-
* `opts` {
|
|
338
|
-
|
|
344
|
+
* `opts` {Object} (optional)
|
|
345
|
+
* `store` {CacheStore} The store that cached responses are kept in. See
|
|
346
|
+
[`CacheStore`](./CacheStore.md). **Default:** a new `MemoryCacheStore`.
|
|
347
|
+
* `methods` {string[]} The HTTP methods to cache. Only safe methods are
|
|
348
|
+
allowed (`GET`, `HEAD`, `OPTIONS`, `TRACE`) and at least one is required.
|
|
349
|
+
**Default:** `['GET']`.
|
|
350
|
+
* `cacheByDefault` {number} RFC 9111 allows caching responses that are not
|
|
351
|
+
explicitly marked as cacheable or not cacheable. Set this to cache such
|
|
352
|
+
responses. **Default:** `undefined`.
|
|
353
|
+
* `type` {string} Whether the cache is `'shared'` or `'private'`, which
|
|
354
|
+
decides how directives such as `s-maxage` and `private` are applied.
|
|
355
|
+
**Default:** `'shared'`.
|
|
356
|
+
* `origins` {(string|RegExp)[]} Only requests to these origins are cached.
|
|
357
|
+
Strings are compared case-insensitively. **Default:** `undefined` (all
|
|
358
|
+
origins are cached).
|
|
339
359
|
|
|
340
360
|
**Returns:** {Dispatcher.DispatcherComposeInterceptor}
|
|
341
361
|
|
|
@@ -57,9 +57,10 @@ added: v4.0.0
|
|
|
57
57
|
* `opts` {DispatchOptions} The dispatch options for the request. In addition to
|
|
58
58
|
the standard dispatch options, the following redirect-specific fields are
|
|
59
59
|
recognized:
|
|
60
|
-
* `throwOnMaxRedirect` {boolean} When `true`, an error is thrown
|
|
61
|
-
`maxRedirections`
|
|
62
|
-
|
|
60
|
+
* `throwOnMaxRedirect` {boolean} When `true`, an error is thrown when a
|
|
61
|
+
redirect would be followed but `maxRedirections` has been reached, instead of
|
|
62
|
+
returning that redirect response. A non-redirect response after exactly
|
|
63
|
+
`maxRedirections` redirects is returned normally. **Default:** `false`.
|
|
63
64
|
* `stripHeadersOnRedirect` {string[]} Header names to remove from the request on
|
|
64
65
|
every redirect hop. **Default:** `null`.
|
|
65
66
|
* `stripHeadersOnCrossOriginRedirect` {string[]} Additional header names to
|
|
@@ -165,13 +166,15 @@ added: v7.0.0
|
|
|
165
166
|
* `statusMessage` {string} The HTTP status message.
|
|
166
167
|
|
|
167
168
|
Inspects the response headers to decide whether to follow a redirect. When the
|
|
168
|
-
status code is redirectable, the
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
169
|
+
status code is redirectable, the response has a `Location` header, the
|
|
170
|
+
`maxRedirections` limit has not been reached, and the request body has not been
|
|
171
|
+
consumed, the `location` property is set, the method and headers are adjusted
|
|
172
|
+
for the next hop, and the response is not forwarded. Otherwise the event is
|
|
173
|
+
forwarded to the wrapped `handler`.
|
|
174
|
+
|
|
175
|
+
Throws when `throwOnMaxRedirect` is `true` and a redirect that would otherwise be
|
|
176
|
+
followed arrives after `maxRedirections` redirects have already been followed,
|
|
177
|
+
and throws an [`InvalidArgumentError`][] if a
|
|
175
178
|
redirect loop is detected (for example when a [`Client`][] or [`Pool`][] is used
|
|
176
179
|
for a cross-origin redirect; use an [`Agent`][] instead).
|
|
177
180
|
|
|
@@ -13,7 +13,7 @@ It is also a Stranger Things reference.
|
|
|
13
13
|
|
|
14
14
|
Have a question about using Undici? Open a [Q&A Discussion](https://github.com/nodejs/undici/discussions/new) or join our official OpenJS [Slack](https://openjs-foundation.slack.com/archives/C01QF9Q31QD) channel.
|
|
15
15
|
|
|
16
|
-
Looking to contribute? Start by reading the [contributing guide](
|
|
16
|
+
Looking to contribute? Start by reading the [contributing guide](https://github.com/nodejs/undici/blob/main/CONTRIBUTING.md)
|
|
17
17
|
|
|
18
18
|
## Install
|
|
19
19
|
|
|
@@ -417,7 +417,7 @@ For more information about their behavior, please reference the body mixin from
|
|
|
417
417
|
|
|
418
418
|
## Common API Methods
|
|
419
419
|
|
|
420
|
-
This section documents our most commonly used API methods. Additional APIs are documented in their own files within the [
|
|
420
|
+
This section documents our most commonly used API methods. Additional APIs are documented in their own files within the [`api`](./api/) folder and are accessible via the navigation list on the left side of the docs site.
|
|
421
421
|
|
|
422
422
|
For the top-level APIs below, the `url` argument supplies the request origin and
|
|
423
423
|
path. Do not pass `origin` or `path` in the second `options` argument. The linked
|
|
@@ -427,19 +427,19 @@ lower-level APIs that do not receive a separate `url` argument.
|
|
|
427
427
|
### `undici.request([url, options])`
|
|
428
428
|
|
|
429
429
|
* `url` {string|URL|UrlObject}
|
|
430
|
-
* `options` {RequestOptions} See [`RequestOptions`](./
|
|
430
|
+
* `options` {RequestOptions} See [`RequestOptions`](./api/Dispatcher.md#parameter-requestoptions).
|
|
431
431
|
* `dispatcher` {Dispatcher} **Default:** [getGlobalDispatcher](#undicigetglobaldispatcher).
|
|
432
432
|
* `method` {string} **Default:** `PUT` if `options.body`, otherwise `GET`.
|
|
433
433
|
* Returns: {Promise} A promise with the result of the `Dispatcher.request` method.
|
|
434
434
|
|
|
435
435
|
Calls `options.dispatcher.request(options)`.
|
|
436
436
|
|
|
437
|
-
See [Dispatcher.request](./
|
|
437
|
+
See [Dispatcher.request](./api/Dispatcher.md#dispatcherrequestoptions-callback) for more details, and [request examples](https://github.com/nodejs/undici/blob/main/docs/examples/README.md) for examples.
|
|
438
438
|
|
|
439
439
|
### `undici.stream([url, options, ]factory)`
|
|
440
440
|
|
|
441
441
|
* `url` {string|URL|UrlObject}
|
|
442
|
-
* `options` {StreamOptions} See [`StreamOptions`](./
|
|
442
|
+
* `options` {StreamOptions} See [`StreamOptions`](./api/Dispatcher.md#parameter-streamoptions).
|
|
443
443
|
* `dispatcher` {Dispatcher} **Default:** [getGlobalDispatcher](#undicigetglobaldispatcher).
|
|
444
444
|
* `method` {string} **Default:** `PUT` if `options.body`, otherwise `GET`.
|
|
445
445
|
* `factory` {Function} `Dispatcher.stream.factory`.
|
|
@@ -447,12 +447,12 @@ See [Dispatcher.request](./docs/docs/api/Dispatcher.md#dispatcherrequestoptions-
|
|
|
447
447
|
|
|
448
448
|
Calls `options.dispatcher.stream(options, factory)`.
|
|
449
449
|
|
|
450
|
-
See [Dispatcher.stream](./
|
|
450
|
+
See [Dispatcher.stream](./api/Dispatcher.md#dispatcherstreamoptions-factory-callback) for more details.
|
|
451
451
|
|
|
452
452
|
### `undici.pipeline([url, options, ]handler)`
|
|
453
453
|
|
|
454
454
|
* `url` {string|URL|UrlObject}
|
|
455
|
-
* `options` {PipelineOptions} See [`PipelineOptions`](./
|
|
455
|
+
* `options` {PipelineOptions} See [`PipelineOptions`](./api/Dispatcher.md#parameter-pipelineoptions).
|
|
456
456
|
* `dispatcher` {Dispatcher} **Default:** [getGlobalDispatcher](#undicigetglobaldispatcher).
|
|
457
457
|
* `method` {string} **Default:** `PUT` if `options.body`, otherwise `GET`.
|
|
458
458
|
* `handler` {Function} `Dispatcher.pipeline.handler`.
|
|
@@ -460,21 +460,21 @@ See [Dispatcher.stream](./docs/docs/api/Dispatcher.md#dispatcherstreamoptions-fa
|
|
|
460
460
|
|
|
461
461
|
Calls `options.dispatch.pipeline(options, handler)`.
|
|
462
462
|
|
|
463
|
-
See [Dispatcher.pipeline](./
|
|
463
|
+
See [Dispatcher.pipeline](./api/Dispatcher.md#dispatcherpipelineoptions-handler) for more details.
|
|
464
464
|
|
|
465
465
|
### `undici.connect([url, options])`
|
|
466
466
|
|
|
467
467
|
Starts two-way communications with the requested resource using [HTTP CONNECT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/CONNECT).
|
|
468
468
|
|
|
469
469
|
* `url` {string|URL|UrlObject}
|
|
470
|
-
* `options` {ConnectOptions} See [`ConnectOptions`](./
|
|
470
|
+
* `options` {ConnectOptions} See [`ConnectOptions`](./api/Dispatcher.md#parameter-connectoptions).
|
|
471
471
|
* `dispatcher` {Dispatcher} **Default:** [getGlobalDispatcher](#undicigetglobaldispatcher).
|
|
472
472
|
* `callback` {Function} (optional) — `(err, data) => void`.
|
|
473
473
|
* Returns: {Promise} A promise with the result of the `Dispatcher.connect` method.
|
|
474
474
|
|
|
475
475
|
Calls `options.dispatch.connect(options)`.
|
|
476
476
|
|
|
477
|
-
See [Dispatcher.connect](./
|
|
477
|
+
See [Dispatcher.connect](./api/Dispatcher.md#dispatcherconnectoptions-callback) for more details.
|
|
478
478
|
|
|
479
479
|
### `undici.fetch(input[, init])`
|
|
480
480
|
|
|
@@ -647,14 +647,14 @@ Undici limits the number of `Content-Encoding` layers in a response to **5** to
|
|
|
647
647
|
Upgrade to a different protocol. See [MDN - HTTP - Protocol upgrade mechanism](https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism) for more details.
|
|
648
648
|
|
|
649
649
|
* `url` {string|URL|UrlObject}
|
|
650
|
-
* `options` {UpgradeOptions} See [`UpgradeOptions`](./
|
|
650
|
+
* `options` {UpgradeOptions} See [`UpgradeOptions`](./api/Dispatcher.md#parameter-upgradeoptions).
|
|
651
651
|
* `dispatcher` {Dispatcher} **Default:** [getGlobalDispatcher](#undicigetglobaldispatcher).
|
|
652
652
|
* `callback` {Function} (optional) — `(error, data) => void`.
|
|
653
653
|
* Returns: {Promise} A promise with the result of the `Dispatcher.upgrade` method.
|
|
654
654
|
|
|
655
655
|
Calls `options.dispatcher.upgrade(options)`.
|
|
656
656
|
|
|
657
|
-
See [Dispatcher.upgrade](./
|
|
657
|
+
See [Dispatcher.upgrade](./api/Dispatcher.md#dispatcherupgradeoptions-callback) for more details.
|
|
658
658
|
|
|
659
659
|
### `undici.setGlobalDispatcher(dispatcher)`
|
|
660
660
|
|
|
@@ -1,79 +1,79 @@
|
|
|
1
1
|
{
|
|
2
|
-
"AbortError": "/api/Errors.
|
|
3
|
-
"Agent": "/api/Agent.
|
|
4
|
-
"AgentDispatchOptions": "/api/Agent.
|
|
5
|
-
"AgentOptions": "/api/Agent.
|
|
6
|
-
"BalancedPool": "/api/BalancedPool.
|
|
7
|
-
"BalancedPoolOptions": "/api/BalancedPool.
|
|
8
|
-
"BodyMixin": "/api/Fetch.
|
|
2
|
+
"AbortError": "/api/Errors.html#class-aborterror",
|
|
3
|
+
"Agent": "/api/Agent.html#class-agent",
|
|
4
|
+
"AgentDispatchOptions": "/api/Agent.html#agentdispatchoptions-handler",
|
|
5
|
+
"AgentOptions": "/api/Agent.html#new-agentoptions",
|
|
6
|
+
"BalancedPool": "/api/BalancedPool.html#class-balancedpool",
|
|
7
|
+
"BalancedPoolOptions": "/api/BalancedPool.html#parameter-balancedpooloptions",
|
|
8
|
+
"BodyMixin": "/api/Fetch.html#new-formdata",
|
|
9
9
|
"Buffer": "https://nodejs.org/api/buffer.html#class-buffer",
|
|
10
|
-
"BuildOptions": "/api/Connector.
|
|
11
|
-
"CacheKey": "/api/CacheStore.
|
|
12
|
-
"CacheStore": "/api/CacheStore.
|
|
13
|
-
"CacheValue": "/api/CacheStore.
|
|
14
|
-
"ClientDestroyedError": "/api/Errors.
|
|
15
|
-
"ClientOptions": "/api/Client.
|
|
16
|
-
"ClientStats": "/api/ClientStats.
|
|
17
|
-
"ConnectOptions": "/api/Dispatcher.
|
|
18
|
-
"Cookie": "/api/Cookies.
|
|
19
|
-
"DispatchController": "/api/Dispatcher.
|
|
20
|
-
"DispatchHandler": "/api/Dispatcher.
|
|
21
|
-
"DispatchOptions": "/api/Dispatcher.
|
|
22
|
-
"Dispatcher": "/api/Dispatcher.
|
|
10
|
+
"BuildOptions": "/api/Connector.html#buildconnectoroptions",
|
|
11
|
+
"CacheKey": "/api/CacheStore.html#cachekey",
|
|
12
|
+
"CacheStore": "/api/CacheStore.html#new-memorycachestoreoptions",
|
|
13
|
+
"CacheValue": "/api/CacheStore.html#cachevalue",
|
|
14
|
+
"ClientDestroyedError": "/api/Errors.html#class-clientdestroyederror",
|
|
15
|
+
"ClientOptions": "/api/Client.html#new-clienturl-options",
|
|
16
|
+
"ClientStats": "/api/ClientStats.html#class-clientstats",
|
|
17
|
+
"ConnectOptions": "/api/Dispatcher.html#class-dispatcher",
|
|
18
|
+
"Cookie": "/api/Cookies.html#cookie",
|
|
19
|
+
"DispatchController": "/api/Dispatcher.html#class-dispatcher",
|
|
20
|
+
"DispatchHandler": "/api/Dispatcher.html#class-dispatcher",
|
|
21
|
+
"DispatchOptions": "/api/Dispatcher.html#class-dispatcher",
|
|
22
|
+
"Dispatcher": "/api/Dispatcher.html#class-dispatcher",
|
|
23
23
|
"Duplex": "https://nodejs.org/api/stream.html#class-streamduplex",
|
|
24
|
-
"EnvHttpProxyAgent": "/api/EnvHttpProxyAgent.
|
|
25
|
-
"EnvHttpProxyAgentOptions": "/api/EnvHttpProxyAgent.
|
|
24
|
+
"EnvHttpProxyAgent": "/api/EnvHttpProxyAgent.html#class-envhttpproxyagent",
|
|
25
|
+
"EnvHttpProxyAgentOptions": "/api/EnvHttpProxyAgent.html#new-envhttpproxyagentoptions",
|
|
26
26
|
"EventEmitter": "https://nodejs.org/api/events.html#class-eventemitter",
|
|
27
|
-
"GetResult": "/api/CacheStore.
|
|
28
|
-
"H2CClientOptions": "/api/H2CClient.
|
|
27
|
+
"GetResult": "/api/CacheStore.html#getresult",
|
|
28
|
+
"H2CClientOptions": "/api/H2CClient.html#new-h2cclienturl-options",
|
|
29
29
|
"HeadersInit": "https://developer.mozilla.org/docs/Web/API/Headers/Headers",
|
|
30
|
-
"InvalidArgumentError": "/api/Errors.
|
|
30
|
+
"InvalidArgumentError": "/api/Errors.html#class-invalidargumenterror",
|
|
31
31
|
"Iterable": "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Iteration_protocols",
|
|
32
|
-
"MaxOriginsReachedError": "/api/Errors.
|
|
33
|
-
"MockAgent": "/api/MockAgent.
|
|
34
|
-
"MockAgentOptions": "/api/MockAgent.
|
|
35
|
-
"MockCallHistory": "/api/MockCallHistory.
|
|
36
|
-
"MockCallHistoryLog": "/api/MockCallHistoryLog.
|
|
37
|
-
"MockClient": "/api/MockClient.
|
|
38
|
-
"MockClientOptions": "/api/MockClient.
|
|
39
|
-
"MockInterceptor": "/api/MockPool.
|
|
40
|
-
"MockInterceptor.Options": "/api/MockPool.
|
|
41
|
-
"MockPool": "/api/MockPool.
|
|
42
|
-
"MockPoolInterceptOptions": "/api/MockPool.
|
|
43
|
-
"MockPoolOptions": "/api/MockPool.
|
|
44
|
-
"MockResponseOptions": "/api/MockPool.
|
|
45
|
-
"MockScope": "/api/MockPool.
|
|
46
|
-
"PendingInterceptor": "/api/MockAgent.
|
|
47
|
-
"PipelineOptions": "/api/Dispatcher.
|
|
48
|
-
"Pool": "/api/Pool.
|
|
49
|
-
"PoolOptions": "/api/Pool.
|
|
50
|
-
"PoolStats": "/api/PoolStats.
|
|
51
|
-
"ProxyAgent": "/api/ProxyAgent.
|
|
52
|
-
"ProxyAgentOptions": "/api/ProxyAgent.
|
|
32
|
+
"MaxOriginsReachedError": "/api/Errors.html#class-maxoriginsreachederror",
|
|
33
|
+
"MockAgent": "/api/MockAgent.html#class-mockagent",
|
|
34
|
+
"MockAgentOptions": "/api/MockAgent.html#parameter-mockagentoptions",
|
|
35
|
+
"MockCallHistory": "/api/MockCallHistory.html#class-mockcallhistory",
|
|
36
|
+
"MockCallHistoryLog": "/api/MockCallHistoryLog.html#class-mockcallhistorylog",
|
|
37
|
+
"MockClient": "/api/MockClient.html#class-mockclient",
|
|
38
|
+
"MockClientOptions": "/api/MockClient.html#parameter-mockclientoptions",
|
|
39
|
+
"MockInterceptor": "/api/MockPool.html#return-mockinterceptor",
|
|
40
|
+
"MockInterceptor.Options": "/api/MockPool.html#parameter-mockpoolinterceptoptions",
|
|
41
|
+
"MockPool": "/api/MockPool.html#class-mockpool",
|
|
42
|
+
"MockPoolInterceptOptions": "/api/MockPool.html#parameter-mockpoolinterceptoptions",
|
|
43
|
+
"MockPoolOptions": "/api/MockPool.html#parameter-mockpooloptions",
|
|
44
|
+
"MockResponseOptions": "/api/MockPool.html#parameter-mockresponseoptions",
|
|
45
|
+
"MockScope": "/api/MockPool.html#return-mockscope",
|
|
46
|
+
"PendingInterceptor": "/api/MockAgent.html#new-mockagentoptions",
|
|
47
|
+
"PipelineOptions": "/api/Dispatcher.html#class-dispatcher",
|
|
48
|
+
"Pool": "/api/Pool.html#class-pool",
|
|
49
|
+
"PoolOptions": "/api/Pool.html#new-poolurl-options",
|
|
50
|
+
"PoolStats": "/api/PoolStats.html#class-poolstats",
|
|
51
|
+
"ProxyAgent": "/api/ProxyAgent.html#class-proxyagent",
|
|
52
|
+
"ProxyAgentOptions": "/api/ProxyAgent.html#new-proxyagentoptions",
|
|
53
53
|
"Readable": "https://nodejs.org/api/stream.html#class-streamreadable",
|
|
54
54
|
"Record": "https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type",
|
|
55
|
-
"RequestInit": "/api/Fetch.
|
|
56
|
-
"RequestOptions": "/api/Dispatcher.
|
|
57
|
-
"ResponseInit": "/api/Fetch.
|
|
58
|
-
"RetryContext": "/api/RetryHandler.
|
|
59
|
-
"RetryHandler": "/api/RetryHandler.
|
|
60
|
-
"RetryHandlers": "/api/RetryHandler.
|
|
61
|
-
"RetryOptions": "/api/RetryHandler.
|
|
62
|
-
"RetryState": "/api/RetryHandler.
|
|
63
|
-
"RoundRobinPoolOptions": "/api/RoundRobinPool.
|
|
64
|
-
"SnapshotRecorder": "/api/SnapshotAgent.
|
|
55
|
+
"RequestInit": "/api/Fetch.html#new-formdata",
|
|
56
|
+
"RequestOptions": "/api/Dispatcher.html#class-dispatcher",
|
|
57
|
+
"ResponseInit": "/api/Fetch.html#new-formdata",
|
|
58
|
+
"RetryContext": "/api/RetryHandler.html#retrycontext",
|
|
59
|
+
"RetryHandler": "/api/RetryHandler.html#class-retryhandler",
|
|
60
|
+
"RetryHandlers": "/api/RetryHandler.html#parameter-retryhandlers",
|
|
61
|
+
"RetryOptions": "/api/RetryHandler.html#retryoptions",
|
|
62
|
+
"RetryState": "/api/RetryHandler.html#retrystate",
|
|
63
|
+
"RoundRobinPoolOptions": "/api/RoundRobinPool.html#parameter-roundrobinpooloptions",
|
|
64
|
+
"SnapshotRecorder": "/api/SnapshotAgent.html#new-snapshotagentoptions",
|
|
65
65
|
"Socket": "https://nodejs.org/api/net.html#class-netsocket",
|
|
66
|
-
"SocketInfo": "/api/Errors.
|
|
67
|
-
"StreamOptions": "/api/Dispatcher.
|
|
66
|
+
"SocketInfo": "/api/Errors.html#new-requestretryerrormessage-code-options",
|
|
67
|
+
"StreamOptions": "/api/Dispatcher.html#class-dispatcher",
|
|
68
68
|
"TLSSocket": "https://nodejs.org/api/tls.html#class-tlstlssocket",
|
|
69
|
-
"UndiciError": "/api/Errors.
|
|
70
|
-
"UndiciHeaders": "/api/Dispatcher.
|
|
71
|
-
"UpgradeOptions": "/api/Dispatcher.
|
|
72
|
-
"UrlObject": "/index.
|
|
73
|
-
"WebSocketInit": "/api/WebSocket.
|
|
74
|
-
"WebSocketStreamOptions": "/api/WebSocket.
|
|
69
|
+
"UndiciError": "/api/Errors.html#class-undicierror",
|
|
70
|
+
"UndiciHeaders": "/api/Dispatcher.html#class-dispatcher",
|
|
71
|
+
"UpgradeOptions": "/api/Dispatcher.html#class-dispatcher",
|
|
72
|
+
"UrlObject": "/index.html#urlobject",
|
|
73
|
+
"WebSocketInit": "/api/WebSocket.html#new-websocketurl-protocols",
|
|
74
|
+
"WebSocketStreamOptions": "/api/WebSocket.html#new-websocketurl-protocols",
|
|
75
75
|
"Writable": "https://nodejs.org/api/stream.html#class-streamwritable",
|
|
76
|
-
"buildConnector.BuildOptions": "/api/Connector.
|
|
76
|
+
"buildConnector.BuildOptions": "/api/Connector.html#buildconnectoroptions",
|
|
77
77
|
"net.Socket": "https://nodejs.org/api/net.html#class-netsocket",
|
|
78
78
|
"stream.Readable": "https://nodejs.org/api/stream.html#class-streamreadable"
|
|
79
|
-
}
|
|
79
|
+
}
|
|
@@ -100,6 +100,11 @@ class MemoryCacheStore extends EventEmitter {
|
|
|
100
100
|
|
|
101
101
|
const entry = entries ? findEntry(key, entries, now) : null
|
|
102
102
|
|
|
103
|
+
if (entry != null) {
|
|
104
|
+
this.#entries.delete(topLevelKey)
|
|
105
|
+
this.#entries.set(topLevelKey, entries)
|
|
106
|
+
}
|
|
107
|
+
|
|
103
108
|
return entry == null
|
|
104
109
|
? undefined
|
|
105
110
|
: {
|
|
@@ -148,11 +153,13 @@ class MemoryCacheStore extends EventEmitter {
|
|
|
148
153
|
},
|
|
149
154
|
final (callback) {
|
|
150
155
|
let entries = store.#entries.get(topLevelKey)
|
|
151
|
-
if (
|
|
156
|
+
if (entries) {
|
|
157
|
+
store.#entries.delete(topLevelKey)
|
|
158
|
+
} else {
|
|
152
159
|
entries = []
|
|
153
|
-
store.#entries.set(topLevelKey, entries)
|
|
154
160
|
}
|
|
155
|
-
|
|
161
|
+
store.#entries.set(topLevelKey, entries)
|
|
162
|
+
const previousEntry = findEntry(key, entries, -Infinity)
|
|
156
163
|
if (previousEntry) {
|
|
157
164
|
const index = entries.indexOf(previousEntry)
|
|
158
165
|
entries.splice(index, 1, entry)
|
|
@@ -177,16 +184,7 @@ class MemoryCacheStore extends EventEmitter {
|
|
|
177
184
|
store.#hasEmittedMaxSizeEvent = true
|
|
178
185
|
}
|
|
179
186
|
|
|
180
|
-
|
|
181
|
-
for (const [key, entries] of store.#entries) {
|
|
182
|
-
for (const entry of entries.splice(0, Math.ceil(entries.length / 2))) {
|
|
183
|
-
store.#size -= entry.size
|
|
184
|
-
store.#count -= 1
|
|
185
|
-
}
|
|
186
|
-
if (entries.length === 0) {
|
|
187
|
-
store.#entries.delete(key)
|
|
188
|
-
}
|
|
189
|
-
}
|
|
187
|
+
store.#evict(entry)
|
|
190
188
|
|
|
191
189
|
// Reset the event flag after eviction
|
|
192
190
|
if (store.#size < store.#maxSize && store.#count < store.#maxCount) {
|
|
@@ -199,6 +197,43 @@ class MemoryCacheStore extends EventEmitter {
|
|
|
199
197
|
})
|
|
200
198
|
}
|
|
201
199
|
|
|
200
|
+
#evict (keep) {
|
|
201
|
+
const targetSize = this.#maxSize / 2
|
|
202
|
+
const targetCount = this.#maxCount / 2
|
|
203
|
+
|
|
204
|
+
for (const [key, entries] of this.#entries) {
|
|
205
|
+
for (let i = 0; i < entries.length && (this.#size > targetSize || this.#count > targetCount);) {
|
|
206
|
+
const entry = entries[i]
|
|
207
|
+
if (entry === keep) {
|
|
208
|
+
i++
|
|
209
|
+
continue
|
|
210
|
+
}
|
|
211
|
+
entries.splice(i, 1)
|
|
212
|
+
this.#size -= entry.size
|
|
213
|
+
this.#count -= 1
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (entries.length === 0) {
|
|
217
|
+
this.#entries.delete(key)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (this.#size <= targetSize && this.#count <= targetCount) {
|
|
221
|
+
return
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (this.#size > this.#maxSize || this.#count > this.#maxCount) {
|
|
226
|
+
const topLevelKey = `${keep.origin}:${keep.path}`
|
|
227
|
+
const entries = this.#entries.get(topLevelKey)
|
|
228
|
+
entries.splice(entries.indexOf(keep), 1)
|
|
229
|
+
this.#size -= keep.size
|
|
230
|
+
this.#count -= 1
|
|
231
|
+
if (entries.length === 0) {
|
|
232
|
+
this.#entries.delete(topLevelKey)
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
202
237
|
/**
|
|
203
238
|
* @param {CacheKey} key
|
|
204
239
|
*/
|