niceeval 0.15.1-canary.76 → 0.16.1
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/INDEX.md +45 -40
- package/dist/adapter-execution-trace.cjs.map +1 -1
- package/dist/adapter-execution-trace.d.cts +26 -0
- package/dist/adapter-execution-trace.d.mts +26 -0
- package/dist/adapter-execution-trace.d.ts +26 -0
- package/dist/adapter-usage.cjs.map +1 -1
- package/dist/adapter-usage.d.cts +9 -0
- package/dist/adapter-usage.d.mts +9 -0
- package/dist/adapter-usage.d.ts +9 -0
- package/dist/adapter.cjs +19 -4
- package/dist/adapter.cjs.map +1 -1
- package/dist/adapter.d.cts +37 -12
- package/dist/adapter.d.mts +37 -12
- package/dist/adapter.d.ts +37 -12
- package/dist/agents/ai-sdk.cjs +3 -0
- package/dist/agents/ai-sdk.cjs.map +1 -1
- package/dist/agents/bub.cjs +3 -0
- package/dist/agents/bub.cjs.map +1 -1
- package/dist/agents/claude-code-native.cjs +28 -2
- package/dist/agents/claude-code-native.cjs.map +1 -1
- package/dist/agents/claude-code.cjs +3 -0
- package/dist/agents/claude-code.cjs.map +1 -1
- package/dist/agents/codex.cjs +3 -0
- package/dist/agents/codex.cjs.map +1 -1
- package/dist/agents/coding-cli-versions.cjs +9 -10
- package/dist/agents/coding-cli-versions.cjs.map +1 -1
- package/dist/agents/coding-cli-versions.d.cts +1 -1
- package/dist/agents/coding-cli-versions.d.mts +1 -1
- package/dist/agents/coding-cli-versions.d.ts +1 -1
- package/dist/agents/deepseek-harness.cjs +3 -0
- package/dist/agents/deepseek-harness.cjs.map +1 -1
- package/dist/agents/hermes.cjs +3 -0
- package/dist/agents/hermes.cjs.map +1 -1
- package/dist/agents/index.cjs.map +1 -1
- package/dist/agents/index.d.cts +3 -2
- package/dist/agents/index.d.mts +3 -2
- package/dist/agents/index.d.ts +3 -2
- package/dist/agents/omp.cjs +3 -0
- package/dist/agents/omp.cjs.map +1 -1
- package/dist/agents/openai-compat.cjs +6 -0
- package/dist/agents/openai-compat.cjs.map +1 -1
- package/dist/agents/openclaw.cjs +3 -0
- package/dist/agents/openclaw.cjs.map +1 -1
- package/dist/agents/opencode.cjs +3 -0
- package/dist/agents/opencode.cjs.map +1 -1
- package/dist/agents/sdk-streams.cjs +9 -0
- package/dist/agents/sdk-streams.cjs.map +1 -1
- package/dist/agents/ui-message-stream.cjs +3 -0
- package/dist/agents/ui-message-stream.cjs.map +1 -1
- package/dist/assertions/api.cjs.map +1 -1
- package/dist/assertions/api.d.cts +27 -5
- package/dist/assertions/api.d.mts +27 -5
- package/dist/assertions/api.d.ts +27 -5
- package/dist/assertions/collection.cjs +6 -0
- package/dist/assertions/collection.cjs.map +1 -1
- package/dist/assertions/collection.d.cts +4 -2
- package/dist/assertions/collection.d.mts +4 -2
- package/dist/assertions/collection.d.ts +4 -2
- package/dist/assertions/collection.js +12 -8
- package/dist/assertions/context-match.cjs +70 -0
- package/dist/assertions/context-match.cjs.map +1 -0
- package/dist/assertions/context-match.d.cts +107 -0
- package/dist/assertions/context-match.d.mts +107 -0
- package/dist/assertions/context-match.d.ts +107 -0
- package/dist/assertions/context-match.js +12 -0
- package/dist/assertions/context-match.js.map +1 -0
- package/dist/assertions/full-content.cjs +109 -0
- package/dist/assertions/full-content.cjs.map +1 -0
- package/dist/assertions/full-content.d.cts +6 -0
- package/dist/assertions/full-content.d.mts +6 -0
- package/dist/assertions/full-content.d.ts +6 -0
- package/dist/assertions/full-content.js +12 -0
- package/dist/assertions/full-content.js.map +1 -0
- package/dist/assertions/judge-presets.cjs +2 -34
- package/dist/assertions/judge-presets.cjs.map +1 -1
- package/dist/assertions/judge-presets.d.cts +6 -9
- package/dist/assertions/judge-presets.d.mts +6 -9
- package/dist/assertions/judge-presets.d.ts +6 -9
- package/dist/assertions/judge-presets.js +8 -8
- package/dist/assertions/judge.cjs +107 -29
- package/dist/assertions/judge.cjs.map +1 -1
- package/dist/assertions/judge.d.cts +2 -0
- package/dist/assertions/judge.d.mts +2 -0
- package/dist/assertions/judge.d.ts +2 -0
- package/dist/assertions/match.cjs +244 -5
- package/dist/assertions/match.cjs.map +1 -1
- package/dist/assertions/match.d.cts +43 -3
- package/dist/assertions/match.d.mts +43 -3
- package/dist/assertions/match.d.ts +43 -3
- package/dist/assertions/match.js +88 -78
- package/dist/assertions/material.cjs +520 -0
- package/dist/assertions/material.cjs.map +1 -0
- package/dist/assertions/material.d.cts +56 -0
- package/dist/assertions/material.d.mts +56 -0
- package/dist/assertions/material.d.ts +56 -0
- package/dist/assertions/material.js +20 -0
- package/dist/assertions/material.js.map +1 -0
- package/dist/assertions/record/attachment.cjs +5 -2
- package/dist/assertions/record/attachment.cjs.map +1 -1
- package/dist/assertions/record/codec.cjs +2 -1
- package/dist/assertions/record/codec.cjs.map +1 -1
- package/dist/assertions/record/model.cjs.map +1 -1
- package/dist/assertions/record/model.d.cts +6 -1
- package/dist/assertions/record/model.d.mts +6 -1
- package/dist/assertions/record/model.d.ts +6 -1
- package/dist/assertions/runtime.cjs +207 -14
- package/dist/assertions/runtime.cjs.map +1 -1
- package/dist/assertions/runtime.d.cts +9 -0
- package/dist/assertions/runtime.d.mts +9 -0
- package/dist/assertions/runtime.d.ts +9 -0
- package/dist/assertions/runtime.js +14 -8
- package/dist/assertions/score-match-audit.cjs +18 -8
- package/dist/assertions/score-match-audit.cjs.map +1 -1
- package/dist/assertions/score-match-gateway.cjs +83 -25
- package/dist/assertions/score-match-gateway.cjs.map +1 -1
- package/dist/assertions/score-match-gateway.d.cts +2 -0
- package/dist/assertions/score-match-gateway.d.mts +2 -0
- package/dist/assertions/score-match-gateway.d.ts +2 -0
- package/dist/assertions/value-composition.test-d.cjs +77 -0
- package/dist/assertions/value-composition.test-d.cjs.map +1 -0
- package/dist/assertions/value-composition.test-d.d.cts +1 -0
- package/dist/assertions/value-composition.test-d.d.mts +1 -0
- package/dist/assertions/value-composition.test-d.d.ts +1 -0
- package/dist/assertions/value-composition.test-d.js +4 -0
- package/dist/assertions/value-composition.test-d.js.map +1 -0
- package/dist/context/assert-first.cjs +207 -213
- package/dist/context/assert-first.cjs.map +1 -1
- package/dist/context/assert-first.d.cts +49 -23
- package/dist/context/assert-first.d.mts +49 -23
- package/dist/context/assert-first.d.ts +49 -23
- package/dist/context/session.cjs +111 -9
- package/dist/context/session.cjs.map +1 -1
- package/dist/context/session.d.cts +18 -0
- package/dist/context/session.d.mts +18 -0
- package/dist/context/session.d.ts +18 -0
- package/dist/define.cjs +17 -1
- package/dist/define.cjs.map +1 -1
- package/dist/eval/cli/contribution.cjs +2 -0
- package/dist/eval/cli/contribution.cjs.map +1 -1
- package/dist/eval/host/index.cjs +2 -0
- package/dist/eval/host/index.cjs.map +1 -1
- package/dist/eval/record/evaluation.cjs +3 -0
- package/dist/eval/record/evaluation.cjs.map +1 -1
- package/dist/eval/record/membership-provenance.d.cts +15 -15
- package/dist/eval/record/membership-provenance.d.mts +15 -15
- package/dist/eval/record/membership-provenance.d.ts +15 -15
- package/dist/eval/record/score.cjs +7 -0
- package/dist/eval/record/score.cjs.map +1 -1
- package/dist/eval/record/sealed-assertion.cjs +3 -0
- package/dist/eval/record/sealed-assertion.cjs.map +1 -1
- package/dist/eval/record/verdict.cjs +7 -0
- package/dist/eval/record/verdict.cjs.map +1 -1
- package/dist/expect/index.cjs +8 -2
- package/dist/expect/index.cjs.map +1 -1
- package/dist/expect/index.d.cts +9 -4
- package/dist/expect/index.d.mts +9 -4
- package/dist/expect/index.d.ts +9 -4
- package/dist/expect/index.js +72 -62
- package/dist/expect/index.mjs +72 -62
- package/dist/experiment/host/cli/contribution.cjs +37 -23
- package/dist/experiment/host/cli/contribution.cjs.map +1 -1
- package/dist/experiment/host/cli/contribution.d.cts +9 -1
- package/dist/experiment/host/cli/contribution.d.mts +9 -1
- package/dist/experiment/host/cli/contribution.d.ts +9 -1
- package/dist/experiment/host/current.cjs +74 -0
- package/dist/experiment/host/current.cjs.map +1 -0
- package/dist/experiment/host/current.d.cts +33 -0
- package/dist/experiment/host/current.d.mts +33 -0
- package/dist/experiment/host/current.d.ts +33 -0
- package/dist/experiment/host/current.js +10 -0
- package/dist/experiment/host/current.js.map +1 -0
- package/dist/experiment/host/index.cjs +17 -174
- package/dist/experiment/host/index.cjs.map +1 -1
- package/dist/experiment/host/index.d.cts +8 -54
- package/dist/experiment/host/index.d.mts +8 -54
- package/dist/experiment/host/index.d.ts +8 -54
- package/dist/experiment/host/operations.cjs +33 -10
- package/dist/experiment/host/operations.cjs.map +1 -1
- package/dist/experiment/host/operations.d.cts +29 -1
- package/dist/experiment/host/operations.d.mts +29 -1
- package/dist/experiment/host/operations.d.ts +29 -1
- package/dist/experiment/host/operations.js +6 -4
- package/dist/experiment/host/requirements.cjs +3 -0
- package/dist/experiment/host/requirements.cjs.map +1 -0
- package/dist/experiment/host/requirements.d.cts +3 -0
- package/dist/experiment/host/requirements.d.mts +3 -0
- package/dist/experiment/host/requirements.d.ts +3 -0
- package/dist/experiment/host/requirements.js +4 -0
- package/dist/experiment/host/requirements.js.map +1 -0
- package/dist/experiment/host/runtime.cjs +179 -0
- package/dist/experiment/host/runtime.cjs.map +1 -0
- package/dist/experiment/host/runtime.d.cts +79 -0
- package/dist/experiment/host/runtime.d.mts +79 -0
- package/dist/experiment/host/runtime.d.ts +79 -0
- package/dist/experiment/host/runtime.js +6 -0
- package/dist/experiment/host/runtime.js.map +1 -0
- package/dist/experiment/host/types.cjs.map +1 -1
- package/dist/experiment/host/types.d.cts +17 -16
- package/dist/experiment/host/types.d.mts +17 -16
- package/dist/experiment/host/types.d.ts +17 -16
- package/dist/fresh-import.cjs +2 -1
- package/dist/fresh-import.cjs.map +1 -1
- package/dist/index.cjs +4 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -6
- package/dist/index.d.mts +12 -6
- package/dist/index.d.ts +12 -6
- package/dist/index.js +32 -30
- package/dist/index.mjs +32 -30
- package/dist/inspection/artifacts.cjs +83 -54
- package/dist/inspection/artifacts.cjs.map +1 -1
- package/dist/inspection/artifacts.d.cts +8 -0
- package/dist/inspection/artifacts.d.mts +8 -0
- package/dist/inspection/artifacts.d.ts +8 -0
- package/dist/inspection/artifacts.js +2 -0
- package/dist/inspection/assertions.cjs +4 -1
- package/dist/inspection/assertions.cjs.map +1 -1
- package/dist/inspection/cli/contribution.cjs +27 -4
- package/dist/inspection/cli/contribution.cjs.map +1 -1
- package/dist/inspection/cli/contribution.d.cts +2 -1
- package/dist/inspection/cli/contribution.d.mts +2 -1
- package/dist/inspection/cli/contribution.d.ts +2 -1
- package/dist/inspection/execution-traces.cjs +114 -8
- package/dist/inspection/execution-traces.cjs.map +1 -1
- package/dist/inspection/execution-traces.d.cts +38 -0
- package/dist/inspection/execution-traces.d.mts +38 -0
- package/dist/inspection/execution-traces.d.ts +38 -0
- package/dist/inspection/facts.cjs +12 -0
- package/dist/inspection/facts.cjs.map +1 -1
- package/dist/inspection/limits.cjs +5 -1
- package/dist/inspection/limits.cjs.map +1 -1
- package/dist/inspection/limits.d.cts +4 -0
- package/dist/inspection/limits.d.mts +4 -0
- package/dist/inspection/limits.d.ts +4 -0
- package/dist/inspection/limits.js +6 -2
- package/dist/inspection/overview.cjs +74 -33
- package/dist/inspection/overview.cjs.map +1 -1
- package/dist/inspection/overview.d.cts +19 -1
- package/dist/inspection/overview.d.mts +19 -1
- package/dist/inspection/overview.d.ts +19 -1
- package/dist/inspection/overview.js +4 -2
- package/dist/inspection/project-input.cjs +9 -0
- package/dist/inspection/project-input.cjs.map +1 -0
- package/dist/inspection/project-input.d.cts +20 -0
- package/dist/inspection/project-input.d.mts +20 -0
- package/dist/inspection/project-input.d.ts +20 -0
- package/dist/inspection/project-input.js +8 -0
- package/dist/inspection/project-input.js.map +1 -0
- package/dist/inspection/project-result.cjs +60 -0
- package/dist/inspection/project-result.cjs.map +1 -0
- package/dist/inspection/project-result.d.cts +1264 -0
- package/dist/inspection/project-result.d.mts +1264 -0
- package/dist/inspection/project-result.d.ts +1264 -0
- package/dist/inspection/project-result.js +10 -0
- package/dist/inspection/project-result.js.map +1 -0
- package/dist/inspection/project-source.cjs +109 -0
- package/dist/inspection/project-source.cjs.map +1 -0
- package/dist/inspection/project-source.d.cts +10 -0
- package/dist/inspection/project-source.d.mts +10 -0
- package/dist/inspection/project-source.d.ts +10 -0
- package/dist/inspection/project-source.js +6 -0
- package/dist/inspection/project-source.js.map +1 -0
- package/dist/inspection/project.cjs +100 -0
- package/dist/inspection/project.cjs.map +1 -0
- package/dist/inspection/project.d.cts +3 -0
- package/dist/inspection/project.d.mts +3 -0
- package/dist/inspection/project.d.ts +3 -0
- package/dist/inspection/project.js +6 -0
- package/dist/inspection/project.js.map +1 -0
- package/dist/inspection/protocol.cjs +19 -9
- package/dist/inspection/protocol.cjs.map +1 -1
- package/dist/inspection/protocol.d.cts +5506 -38189
- package/dist/inspection/protocol.d.mts +5506 -38189
- package/dist/inspection/protocol.d.ts +5506 -38189
- package/dist/inspection/public.mjs +896 -84
- package/dist/inspection/query.cjs +2 -0
- package/dist/inspection/query.cjs.map +1 -1
- package/dist/inspection/results.cjs +234 -29
- package/dist/inspection/results.cjs.map +1 -1
- package/dist/inspection/results.d.cts +870 -13
- package/dist/inspection/results.d.mts +870 -13
- package/dist/inspection/results.d.ts +870 -13
- package/dist/inspection/results.js +36 -34
- package/dist/inspection/select.cjs +126 -14
- package/dist/inspection/select.cjs.map +1 -1
- package/dist/inspection/select.d.cts +1 -1
- package/dist/inspection/select.d.mts +1 -1
- package/dist/inspection/select.d.ts +1 -1
- package/dist/inspection/source.cjs +4 -0
- package/dist/inspection/source.cjs.map +1 -1
- package/dist/inspection/sources.cjs +5 -0
- package/dist/inspection/sources.cjs.map +1 -1
- package/dist/inspection/trace.cjs +82 -84
- package/dist/inspection/trace.cjs.map +1 -1
- package/dist/inspection/trace.d.cts +7 -2
- package/dist/inspection/trace.d.mts +7 -2
- package/dist/inspection/trace.d.ts +7 -2
- package/dist/model-slots.cjs +35 -0
- package/dist/model-slots.cjs.map +1 -0
- package/dist/model-slots.d.cts +19 -0
- package/dist/model-slots.d.mts +19 -0
- package/dist/model-slots.d.ts +19 -0
- package/dist/model-slots.js +8 -0
- package/dist/model-slots.js.map +1 -0
- package/dist/o11y/adapter-call-price.cjs +4 -0
- package/dist/o11y/adapter-call-price.cjs.map +1 -1
- package/dist/o11y/adapter-call-price.d.cts +24 -0
- package/dist/o11y/adapter-call-price.d.mts +24 -0
- package/dist/o11y/adapter-call-price.d.ts +24 -0
- package/dist/o11y/adapter-call-price.js +6 -2
- package/dist/o11y/adapter-usage-projection.cjs +158 -0
- package/dist/o11y/adapter-usage-projection.cjs.map +1 -0
- package/dist/o11y/adapter-usage-projection.d.cts +141 -0
- package/dist/o11y/adapter-usage-projection.d.mts +141 -0
- package/dist/o11y/adapter-usage-projection.d.ts +141 -0
- package/dist/o11y/adapter-usage-projection.js +20 -0
- package/dist/o11y/adapter-usage-projection.js.map +1 -0
- package/dist/o11y/eval-usage.cjs +149 -0
- package/dist/o11y/eval-usage.cjs.map +1 -0
- package/dist/o11y/eval-usage.d.cts +46 -0
- package/dist/o11y/eval-usage.d.mts +46 -0
- package/dist/o11y/eval-usage.d.ts +46 -0
- package/dist/o11y/eval-usage.js +8 -0
- package/dist/o11y/eval-usage.js.map +1 -0
- package/dist/o11y/judge-call-price.cjs +62 -0
- package/dist/o11y/judge-call-price.cjs.map +1 -0
- package/dist/o11y/judge-call-price.d.cts +3 -0
- package/dist/o11y/judge-call-price.d.mts +3 -0
- package/dist/o11y/judge-call-price.d.ts +3 -0
- package/dist/o11y/judge-call-price.js +6 -0
- package/dist/o11y/judge-call-price.js.map +1 -0
- package/dist/o11y/judge-usage-projection.cjs +134 -0
- package/dist/o11y/judge-usage-projection.cjs.map +1 -0
- package/dist/o11y/judge-usage-projection.d.cts +18 -0
- package/dist/o11y/judge-usage-projection.d.mts +18 -0
- package/dist/o11y/judge-usage-projection.d.ts +18 -0
- package/dist/o11y/judge-usage-projection.js +20 -0
- package/dist/o11y/judge-usage-projection.js.map +1 -0
- package/dist/o11y/judge-usage-receipt.cjs +135 -0
- package/dist/o11y/judge-usage-receipt.cjs.map +1 -0
- package/dist/o11y/judge-usage-receipt.d.cts +5 -0
- package/dist/o11y/judge-usage-receipt.d.mts +5 -0
- package/dist/o11y/judge-usage-receipt.d.ts +5 -0
- package/dist/o11y/judge-usage-receipt.js +6 -0
- package/dist/o11y/judge-usage-receipt.js.map +1 -0
- package/dist/o11y/judge-usage.cjs +171 -0
- package/dist/o11y/judge-usage.cjs.map +1 -0
- package/dist/o11y/judge-usage.d.cts +35 -0
- package/dist/o11y/judge-usage.d.mts +35 -0
- package/dist/o11y/judge-usage.d.ts +35 -0
- package/dist/o11y/judge-usage.js +6 -0
- package/dist/o11y/judge-usage.js.map +1 -0
- package/dist/plugin/contracts.cjs +2 -0
- package/dist/plugin/contracts.cjs.map +1 -1
- package/dist/plugin/link.cjs +7 -0
- package/dist/plugin/link.cjs.map +1 -1
- package/dist/record/attachment/protocol.cjs +8 -6
- package/dist/record/attachment/protocol.cjs.map +1 -1
- package/dist/record/attachment/protocol.d.cts +10 -0
- package/dist/record/attachment/protocol.d.mts +10 -0
- package/dist/record/attachment/protocol.d.ts +10 -0
- package/dist/record/attachment/protocol.js +38 -36
- package/dist/record/codec/seal-manifest.d.cts +3 -3
- package/dist/record/codec/seal-manifest.d.mts +3 -3
- package/dist/record/codec/seal-manifest.d.ts +3 -3
- package/dist/record/family/adapter-usage/definition.d.cts +1 -0
- package/dist/record/family/adapter-usage/definition.d.mts +1 -0
- package/dist/record/family/adapter-usage/definition.d.ts +1 -0
- package/dist/record/family/adapter-usage/persistence.cjs +1 -1
- package/dist/record/family/adapter-usage/persistence.cjs.map +1 -1
- package/dist/record/family/adapter-usage/persistence.d.cts +2 -1
- package/dist/record/family/adapter-usage/persistence.d.mts +2 -1
- package/dist/record/family/adapter-usage/persistence.d.ts +2 -1
- package/dist/record/family/adapter-usage/schema.cjs +21 -2
- package/dist/record/family/adapter-usage/schema.cjs.map +1 -1
- package/dist/record/family/adapter-usage/schema.d.cts +85 -0
- package/dist/record/family/adapter-usage/schema.d.mts +85 -0
- package/dist/record/family/adapter-usage/schema.d.ts +85 -0
- package/dist/record/family/adapter-usage/schema.js +18 -12
- package/dist/record/family/catalog.cjs +31 -27
- package/dist/record/family/catalog.cjs.map +1 -1
- package/dist/record/family/catalog.d.cts +94 -3
- package/dist/record/family/catalog.d.mts +94 -3
- package/dist/record/family/catalog.d.ts +94 -3
- package/dist/record/family/current.cjs +45 -42
- package/dist/record/family/current.cjs.map +1 -1
- package/dist/record/family/current.d.cts +240 -1
- package/dist/record/family/current.d.mts +240 -1
- package/dist/record/family/current.d.ts +240 -1
- package/dist/record/family/execution-traces/definition.d.cts +26 -0
- package/dist/record/family/execution-traces/definition.d.mts +26 -0
- package/dist/record/family/execution-traces/definition.d.ts +26 -0
- package/dist/record/family/execution-traces/definition.js +20 -14
- package/dist/record/family/execution-traces/schema.cjs +57 -1
- package/dist/record/family/execution-traces/schema.cjs.map +1 -1
- package/dist/record/family/execution-traces/schema.d.cts +114 -0
- package/dist/record/family/execution-traces/schema.d.mts +114 -0
- package/dist/record/family/execution-traces/schema.d.ts +114 -0
- package/dist/record/family/execution-traces/schema.js +18 -12
- package/dist/record/family/judge-usage/definition.cjs +12 -0
- package/dist/record/family/judge-usage/definition.cjs.map +1 -0
- package/dist/record/family/judge-usage/definition.d.cts +91 -0
- package/dist/record/family/judge-usage/definition.d.mts +91 -0
- package/dist/record/family/judge-usage/definition.d.ts +91 -0
- package/dist/record/family/judge-usage/definition.js +6 -0
- package/dist/record/family/judge-usage/definition.js.map +1 -0
- package/dist/record/family/judge-usage/persistence.cjs +10 -0
- package/dist/record/family/judge-usage/persistence.cjs.map +1 -0
- package/dist/record/family/judge-usage/persistence.d.cts +91 -0
- package/dist/record/family/judge-usage/persistence.d.mts +91 -0
- package/dist/record/family/judge-usage/persistence.d.ts +91 -0
- package/dist/record/family/judge-usage/persistence.js +6 -0
- package/dist/record/family/judge-usage/persistence.js.map +1 -0
- package/dist/record/family/judge-usage/schema.cjs +307 -0
- package/dist/record/family/judge-usage/schema.cjs.map +1 -0
- package/dist/record/family/judge-usage/schema.d.cts +351 -0
- package/dist/record/family/judge-usage/schema.d.mts +351 -0
- package/dist/record/family/judge-usage/schema.d.ts +351 -0
- package/dist/record/family/judge-usage/schema.js +18 -0
- package/dist/record/family/judge-usage/schema.js.map +1 -0
- package/dist/record/host/sqlite-host.cjs +55 -9
- package/dist/record/host/sqlite-host.cjs.map +1 -1
- package/dist/record/host/types.cjs.map +1 -1
- package/dist/record/host/types.d.cts +7 -0
- package/dist/record/host/types.d.mts +7 -0
- package/dist/record/host/types.d.ts +7 -0
- package/dist/record/model/run-context.cjs +7 -1
- package/dist/record/model/run-context.cjs.map +1 -1
- package/dist/record/model/run-context.d.cts +4 -0
- package/dist/record/model/run-context.d.mts +4 -0
- package/dist/record/model/run-context.d.ts +4 -0
- package/dist/record/model/seal-manifest.d.cts +1 -1
- package/dist/record/model/seal-manifest.d.mts +1 -1
- package/dist/record/model/seal-manifest.d.ts +1 -1
- package/dist/record/sqlite/client.cjs +18 -5
- package/dist/record/sqlite/client.cjs.map +1 -1
- package/dist/record/sqlite/client.d.cts +1 -1
- package/dist/record/sqlite/client.d.mts +1 -1
- package/dist/record/sqlite/client.d.ts +1 -1
- package/dist/record/sqlite/project-state-database.cjs +29 -8
- package/dist/record/sqlite/project-state-database.cjs.map +1 -1
- package/dist/run/host/runtime.cjs +4 -0
- package/dist/run/host/runtime.cjs.map +1 -1
- package/dist/run/storage/sqlite.cjs +20 -0
- package/dist/run/storage/sqlite.cjs.map +1 -1
- package/dist/runner/adapter-execution-trace.cjs +125 -2
- package/dist/runner/adapter-execution-trace.cjs.map +1 -1
- package/dist/runner/adapter-execution-trace.d.cts +1 -1
- package/dist/runner/adapter-execution-trace.d.mts +1 -1
- package/dist/runner/adapter-execution-trace.d.ts +1 -1
- package/dist/runner/adapter-usage.cjs +55 -7
- package/dist/runner/adapter-usage.cjs.map +1 -1
- package/dist/runner/adapter-usage.d.cts +9 -2
- package/dist/runner/adapter-usage.d.mts +9 -2
- package/dist/runner/adapter-usage.d.ts +9 -2
- package/dist/runner/adoption.cjs +9 -0
- package/dist/runner/adoption.cjs.map +1 -1
- package/dist/runner/attempt-cancellation.cjs +12 -0
- package/dist/runner/attempt-cancellation.cjs.map +1 -0
- package/dist/runner/attempt-cancellation.d.cts +6 -0
- package/dist/runner/attempt-cancellation.d.mts +6 -0
- package/dist/runner/attempt-cancellation.d.ts +6 -0
- package/dist/runner/attempt-cancellation.js +6 -0
- package/dist/runner/attempt-cancellation.js.map +1 -0
- package/dist/runner/attempt-resources.cjs +10 -4
- package/dist/runner/attempt-resources.cjs.map +1 -1
- package/dist/runner/attempt-resources.d.cts +2 -1
- package/dist/runner/attempt-resources.d.mts +2 -1
- package/dist/runner/attempt-resources.d.ts +2 -1
- package/dist/runner/attempt.cjs +1177 -1139
- package/dist/runner/attempt.cjs.map +1 -1
- package/dist/runner/config-identity.cjs +20 -1
- package/dist/runner/config-identity.cjs.map +1 -1
- package/dist/runner/config-identity.d.cts +5 -0
- package/dist/runner/config-identity.d.mts +5 -0
- package/dist/runner/config-identity.d.ts +5 -0
- package/dist/runner/discover.cjs +14 -0
- package/dist/runner/discover.cjs.map +1 -1
- package/dist/runner/discover.d.cts +3 -0
- package/dist/runner/discover.d.mts +3 -0
- package/dist/runner/discover.d.ts +3 -0
- package/dist/runner/feedback/human.cjs +9 -4
- package/dist/runner/feedback/human.cjs.map +1 -1
- package/dist/runner/fingerprint.cjs +1 -0
- package/dist/runner/fingerprint.cjs.map +1 -1
- package/dist/runner/judge-usage.cjs +18 -0
- package/dist/runner/judge-usage.cjs.map +1 -0
- package/dist/runner/judge-usage.d.cts +5 -0
- package/dist/runner/judge-usage.d.mts +5 -0
- package/dist/runner/judge-usage.d.ts +5 -0
- package/dist/runner/judge-usage.js +8 -0
- package/dist/runner/judge-usage.js.map +1 -0
- package/dist/runner/project-target.cjs.map +1 -1
- package/dist/runner/project-target.d.cts +2 -0
- package/dist/runner/project-target.d.mts +2 -0
- package/dist/runner/project-target.d.ts +2 -0
- package/dist/runner/record/planning.cjs +1 -0
- package/dist/runner/record/planning.cjs.map +1 -1
- package/dist/runner/record.cjs +4 -0
- package/dist/runner/record.cjs.map +1 -1
- package/dist/runner/reporters/braintrust.cjs +2 -0
- package/dist/runner/reporters/braintrust.cjs.map +1 -1
- package/dist/runner/reuse-diagnostics.cjs +9 -10
- package/dist/runner/reuse-diagnostics.cjs.map +1 -1
- package/dist/runner/reuse-diagnostics.d.cts +5 -6
- package/dist/runner/reuse-diagnostics.d.mts +5 -6
- package/dist/runner/reuse-diagnostics.d.ts +5 -6
- package/dist/runner/reuse-diagnostics.js +4 -4
- package/dist/runner/reuse-plan.cjs +100 -48
- package/dist/runner/reuse-plan.cjs.map +1 -1
- package/dist/runner/reuse-plan.d.cts +60 -3
- package/dist/runner/reuse-plan.d.mts +60 -3
- package/dist/runner/reuse-plan.d.ts +60 -3
- package/dist/runner/reuse-plan.js +14 -10
- package/dist/runner/run.cjs +8 -6
- package/dist/runner/run.cjs.map +1 -1
- package/dist/runner/session.cjs +1 -1
- package/dist/runner/session.cjs.map +1 -1
- package/dist/runner/session.d.cts +1 -1
- package/dist/runner/session.d.mts +1 -1
- package/dist/runner/session.d.ts +1 -1
- package/dist/runner/source-producer.cjs +3 -1
- package/dist/runner/source-producer.cjs.map +1 -1
- package/dist/runner/types.cjs.map +1 -1
- package/dist/runner/types.d.cts +26 -5
- package/dist/runner/types.d.mts +26 -5
- package/dist/runner/types.d.ts +26 -5
- package/dist/sandbox/action.cjs +3 -0
- package/dist/sandbox/action.cjs.map +1 -1
- package/dist/sandbox/commands.cjs +3 -0
- package/dist/sandbox/commands.cjs.map +1 -1
- package/dist/sandbox/compose.cjs +6 -0
- package/dist/sandbox/compose.cjs.map +1 -1
- package/dist/sandbox/docker-profile/registry.cjs +7 -0
- package/dist/sandbox/docker-profile/registry.cjs.map +1 -1
- package/dist/sandbox/docker-profile/runtime.cjs +3 -0
- package/dist/sandbox/docker-profile/runtime.cjs.map +1 -1
- package/dist/sandbox/docker-profile/schema.cjs +7 -0
- package/dist/sandbox/docker-profile/schema.cjs.map +1 -1
- package/dist/sandbox/incus.cjs +7 -0
- package/dist/sandbox/incus.cjs.map +1 -1
- package/dist/sandbox/layer.cjs +12 -0
- package/dist/sandbox/layer.cjs.map +1 -1
- package/dist/shared/adapter-cleanup.cjs +18 -0
- package/dist/shared/adapter-cleanup.cjs.map +1 -0
- package/dist/shared/adapter-cleanup.d.cts +4 -0
- package/dist/shared/adapter-cleanup.d.mts +4 -0
- package/dist/shared/adapter-cleanup.d.ts +4 -0
- package/dist/shared/adapter-cleanup.js +10 -0
- package/dist/shared/adapter-cleanup.js.map +1 -0
- package/dist/shared/attempt-lifecycle.cjs +3 -0
- package/dist/shared/attempt-lifecycle.cjs.map +1 -0
- package/dist/shared/attempt-lifecycle.d.cts +13 -0
- package/dist/shared/attempt-lifecycle.d.mts +13 -0
- package/dist/shared/attempt-lifecycle.d.ts +13 -0
- package/dist/shared/attempt-lifecycle.js +4 -0
- package/dist/shared/attempt-lifecycle.js.map +1 -0
- package/dist/show/contribution.cjs +52 -14
- package/dist/show/contribution.cjs.map +1 -1
- package/dist/show/contribution.d.cts +23 -1
- package/dist/show/contribution.d.mts +23 -1
- package/dist/show/contribution.d.ts +23 -1
- package/dist/show/model.cjs +8 -1
- package/dist/show/model.cjs.map +1 -1
- package/dist/show/model.d.cts +10 -1
- package/dist/show/model.d.mts +10 -1
- package/dist/show/model.d.ts +10 -1
- package/dist/show/render.cjs +287 -49
- package/dist/show/render.cjs.map +1 -1
- package/dist/show/render.d.cts +3 -0
- package/dist/show/render.d.mts +3 -0
- package/dist/show/render.d.ts +3 -0
- package/dist/sources/projector.cjs +3 -0
- package/dist/sources/projector.cjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/view/app-dist/.vite/manifest.json +2 -2
- package/dist/view/app-dist/assets/index-CmVoXbwG.js +63 -0
- package/dist/view/app-dist/assets/{quality-cost-scatter-CFB3wnkN.js → quality-cost-scatter-BuLISaH4.js} +1 -1
- package/dist/view/app-dist/index.html +1 -1
- package/dist/view/cli/contribution.cjs +54 -21
- package/dist/view/cli/contribution.cjs.map +1 -1
- package/dist/view/cli/contribution.d.cts +2 -1
- package/dist/view/cli/contribution.d.mts +2 -1
- package/dist/view/cli/contribution.d.ts +2 -1
- package/dist/view/function-runtime.mjs +13231 -11647
- package/dist/view/http-protocol.cjs +3 -0
- package/dist/view/http-protocol.cjs.map +1 -1
- package/dist/view/http-protocol.d.cts +8 -0
- package/dist/view/http-protocol.d.mts +8 -0
- package/dist/view/http-protocol.d.ts +8 -0
- package/dist/view/inspection-host.cjs +17 -1
- package/dist/view/inspection-host.cjs.map +1 -1
- package/dist/view/render.cjs +1 -0
- package/dist/view/render.cjs.map +1 -1
- package/dist/view/render.d.cts +2 -1
- package/dist/view/render.d.mts +2 -1
- package/dist/view/render.d.ts +2 -1
- package/dist/view/revision.cjs.map +1 -1
- package/dist/view/revision.d.cts +12 -0
- package/dist/view/revision.d.mts +12 -0
- package/dist/view/revision.d.ts +12 -0
- package/dist/view/server.cjs +10 -9
- package/dist/view/server.cjs.map +1 -1
- package/docs-site/zh/examples/ai-agent-application.mdx +1 -1
- package/docs-site/zh/explanation/adapter.mdx +2 -2
- package/docs-site/zh/explanation/assert.mdx +60 -24
- package/docs-site/zh/explanation/drive.mdx +1 -1
- package/docs-site/zh/explanation/evals.mdx +31 -29
- package/docs-site/zh/explanation/experiment.mdx +15 -15
- package/docs-site/zh/explanation/judge.mdx +23 -15
- package/docs-site/zh/explanation/overview.mdx +44 -21
- package/docs-site/zh/explanation/record.mdx +28 -13
- package/docs-site/zh/explanation/results-flow.mdx +37 -0
- package/docs-site/zh/explanation/runner.mdx +27 -6
- package/docs-site/zh/index.mdx +22 -115
- package/docs-site/zh/introduction.mdx +89 -61
- package/docs-site/zh/reference/cli.mdx +50 -26
- package/docs-site/zh/reference/define-agent.mdx +37 -5
- package/docs-site/zh/reference/define-eval.mdx +130 -29
- package/docs-site/zh/reference/define-experiment.mdx +251 -0
- package/docs-site/zh/reference/events.mdx +34 -30
- package/docs-site/zh/reference/expect.mdx +77 -2
- package/docs-site/zh/reference/official-adapters.mdx +2 -2
- package/docs-site/zh/troubleshooting/debug-sandbox.mdx +43 -24
- package/docs-site/zh/troubleshooting/debugging.mdx +65 -42
- package/docs-site/zh/troubleshooting/recover-after-kill.mdx +35 -28
- package/docs-site/zh/tutorials/accept-results.mdx +34 -24
- package/docs-site/zh/tutorials/agent-feedback-loop.mdx +74 -43
- package/docs-site/zh/tutorials/agent-onboarding.mdx +27 -20
- package/docs-site/zh/tutorials/authoring.mdx +138 -121
- package/docs-site/zh/tutorials/ci-integration.mdx +46 -22
- package/docs-site/zh/tutorials/compare-runs.mdx +40 -13
- package/docs-site/zh/tutorials/concurrency.mdx +66 -62
- package/docs-site/zh/tutorials/configuration.mdx +17 -17
- package/docs-site/zh/tutorials/connect-otel.mdx +48 -37
- package/docs-site/zh/tutorials/connect-your-agent.mdx +80 -173
- package/docs-site/zh/tutorials/control-run-cost.mdx +63 -12
- package/docs-site/zh/tutorials/criteria-files.mdx +28 -21
- package/docs-site/zh/tutorials/custom-application.mdx +75 -55
- package/docs-site/zh/tutorials/dataset-fanout.mdx +32 -22
- package/docs-site/zh/tutorials/debug-lifecycle-plan.mdx +38 -31
- package/docs-site/zh/tutorials/docker-in-docker.mdx +83 -89
- package/docs-site/zh/tutorials/eval-groups.mdx +70 -89
- package/docs-site/zh/tutorials/evaluation-kinds.mdx +12 -5
- package/docs-site/zh/tutorials/experiment-services.mdx +243 -0
- package/docs-site/zh/tutorials/fixtures.mdx +42 -26
- package/docs-site/zh/tutorials/handle-execution-failures.mdx +41 -19
- package/docs-site/zh/tutorials/install-custom-sandbox-agent.mdx +21 -16
- package/docs-site/zh/tutorials/niceeval-taste-application.mdx +394 -0
- package/docs-site/zh/tutorials/niceeval-taste.mdx +190 -0
- package/docs-site/zh/tutorials/nixos-managed-dind.mdx +51 -39
- package/docs-site/zh/tutorials/plugins.mdx +55 -31
- package/docs-site/zh/tutorials/prebuilt-sandbox.mdx +204 -0
- package/docs-site/zh/tutorials/quickstart.mdx +91 -47
- package/docs-site/zh/tutorials/reporters.mdx +45 -30
- package/docs-site/zh/tutorials/rerun-and-cache.mdx +39 -40
- package/docs-site/zh/tutorials/sandbox-agent.mdx +65 -40
- package/docs-site/zh/tutorials/sandbox-providers.mdx +104 -282
- package/docs-site/zh/tutorials/sandbox-reuse.mdx +65 -97
- package/docs-site/zh/tutorials/select-and-preview.mdx +25 -20
- package/docs-site/zh/tutorials/verify-judge.mdx +49 -26
- package/docs-site/zh/tutorials/viewing-results.mdx +130 -80
- package/docs-site/zh/tutorials/write-experiment.mdx +116 -298
- package/docs-site/zh/tutorials/write-send.mdx +53 -52
- package/node_modules/undici/docs/docs/api/Agent.md +8 -8
- package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +9 -6
- package/node_modules/undici/docs/docs/api/Errors.md +25 -0
- package/node_modules/undici/docs/docs/api/Interceptors.md +4 -3
- package/node_modules/undici/docs/docs/api/Pool.md +5 -6
- package/node_modules/undici/lib/api/readable.js +1 -2
- package/node_modules/undici/lib/core/request.js +23 -2
- package/node_modules/undici/lib/core/util.js +0 -39
- package/node_modules/undici/lib/dispatcher/client-h1.js +11 -4
- package/node_modules/undici/lib/dispatcher/client-h2.js +52 -8
- package/node_modules/undici/lib/dispatcher/client.js +1 -1
- package/node_modules/undici/lib/dispatcher/dispatcher1-wrapper.js +3 -2
- package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +21 -6
- package/node_modules/undici/lib/dispatcher/pool-base.js +63 -2
- package/node_modules/undici/lib/dispatcher/pool.js +90 -7
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +16 -3
- package/node_modules/undici/lib/handler/deduplication-handler.js +24 -11
- package/node_modules/undici/lib/handler/redirect-handler.js +5 -0
- package/node_modules/undici/lib/handler/retry-handler.js +72 -13
- package/node_modules/undici/lib/interceptor/cache.js +4 -1
- package/node_modules/undici/lib/interceptor/decompress.js +236 -69
- package/node_modules/undici/lib/web/cache/cache.js +17 -8
- package/node_modules/undici/lib/web/cache/cachestorage.js +11 -5
- package/node_modules/undici/lib/web/cookies/index.js +19 -7
- package/node_modules/undici/lib/web/cookies/util.js +3 -1
- package/node_modules/undici/lib/web/eventsource/eventsource.js +25 -1
- package/node_modules/undici/lib/web/fetch/body.js +22 -15
- package/node_modules/undici/lib/web/fetch/data-url.js +6 -6
- package/node_modules/undici/lib/web/fetch/formdata.js +30 -36
- package/node_modules/undici/lib/web/fetch/headers.js +34 -31
- package/node_modules/undici/lib/web/fetch/index.js +38 -14
- package/node_modules/undici/lib/web/fetch/request.js +74 -79
- package/node_modules/undici/lib/web/fetch/response.js +43 -44
- package/node_modules/undici/lib/web/fetch/util.js +7 -7
- package/node_modules/undici/lib/web/infra/index.js +16 -1
- package/node_modules/undici/lib/web/webidl/index.js +2 -14
- package/node_modules/undici/lib/web/websocket/events.js +43 -26
- package/node_modules/undici/lib/web/websocket/receiver.js +5 -0
- package/node_modules/undici/lib/web/websocket/stream/websocketerror.js +13 -10
- package/node_modules/undici/lib/web/websocket/websocket.js +44 -41
- package/node_modules/undici/package.json +1 -1
- package/node_modules/undici/types/diagnostics-channel.d.ts +2 -1
- package/node_modules/undici/types/interceptors.d.ts +1 -1
- package/node_modules/undici/types/webidl.d.ts +13 -7
- package/package.json +4 -4
- package/dist/view/app-dist/assets/index-DFzw1L97.js +0 -63
- package/docs-site/zh/tutorials/experiments.mdx +0 -101
|
@@ -5,6 +5,7 @@ const { pipeline } = require('node:stream')
|
|
|
5
5
|
const util = require('../core/util.js')
|
|
6
6
|
const {
|
|
7
7
|
RequestContentLengthMismatchError,
|
|
8
|
+
ResponseContentLengthMismatchError,
|
|
8
9
|
RequestAbortedError,
|
|
9
10
|
SocketError,
|
|
10
11
|
InformationalError,
|
|
@@ -193,6 +194,11 @@ function canReplayRequest (request) {
|
|
|
193
194
|
return body == null || util.isBuffer(body) || util.isBlobLike(body)
|
|
194
195
|
}
|
|
195
196
|
|
|
197
|
+
function hasResponseStarted (request) {
|
|
198
|
+
const state = request[kRequestStream]?.[kRequestStreamState]
|
|
199
|
+
return state?.responseReceived === true
|
|
200
|
+
}
|
|
201
|
+
|
|
196
202
|
// Count a GOAWAY refusal against the request's replay budget. A peer that
|
|
197
203
|
// refuses every connection must eventually surface an error to the caller
|
|
198
204
|
// rather than being retried forever. Kept separate from canReplayRequest so
|
|
@@ -406,7 +412,8 @@ function resumeH2 (client) {
|
|
|
406
412
|
const session = client[kHTTP2Session]
|
|
407
413
|
|
|
408
414
|
if (socket?.destroyed === false) {
|
|
409
|
-
|
|
415
|
+
// After an upgrade the queue is empty but its stream is still in use, so never unref while a stream is open.
|
|
416
|
+
if (session[kOpenStreams] === 0 && client[kSize] === 0) {
|
|
410
417
|
unrefH2Session(session)
|
|
411
418
|
} else {
|
|
412
419
|
refH2Session(session)
|
|
@@ -640,9 +647,12 @@ function onHttp2SessionGoAway (errorCode, lastStreamID) {
|
|
|
640
647
|
const request = client[kQueue][i]
|
|
641
648
|
|
|
642
649
|
if (request != null) {
|
|
650
|
+
// Read before detaching, which drops the stream state.
|
|
651
|
+
const responseStarted = hasResponseStarted(request)
|
|
652
|
+
|
|
643
653
|
streamsToClose.push(detachRequestStreamForClose(request))
|
|
644
654
|
|
|
645
|
-
if (canReplayRequest(request) && registerGoAwayRefusal(request)) {
|
|
655
|
+
if (!responseStarted && canReplayRequest(request) && registerGoAwayRefusal(request)) {
|
|
646
656
|
retriableRequests.push(request)
|
|
647
657
|
} else {
|
|
648
658
|
util.errorRequest(client, request, err)
|
|
@@ -770,10 +780,12 @@ function noop () {}
|
|
|
770
780
|
|
|
771
781
|
function closeStreamSession (stream) {
|
|
772
782
|
const session = stream[kHTTP2Session]
|
|
783
|
+
const client = session[kClient]
|
|
773
784
|
|
|
774
785
|
stream[kHTTP2Session] = null
|
|
775
786
|
session[kOpenStreams] -= 1
|
|
776
|
-
|
|
787
|
+
// A session that received GOAWAY does not need to stay ref'd for queued requests.
|
|
788
|
+
if (session[kOpenStreams] === 0 && (client[kSize] === 0 || session[kReceivedGoAway])) {
|
|
777
789
|
unrefH2Session(session)
|
|
778
790
|
setHttp2IdleTimeout(session)
|
|
779
791
|
}
|
|
@@ -931,9 +943,14 @@ function onUpgradeResponse (headers, _flags) {
|
|
|
931
943
|
const statusCode = headers[HTTP2_HEADER_STATUS]
|
|
932
944
|
delete headers[HTTP2_HEADER_STATUS]
|
|
933
945
|
|
|
934
|
-
|
|
946
|
+
try {
|
|
947
|
+
request.onRequestUpgrade(statusCode, headers, stream)
|
|
948
|
+
} catch (err) {
|
|
949
|
+
state.abort(err)
|
|
950
|
+
return
|
|
951
|
+
}
|
|
935
952
|
|
|
936
|
-
if (request.aborted
|
|
953
|
+
if (request.aborted) {
|
|
937
954
|
return
|
|
938
955
|
}
|
|
939
956
|
|
|
@@ -1033,6 +1050,7 @@ function writeH2 (client, request) {
|
|
|
1033
1050
|
headersTimeout,
|
|
1034
1051
|
bodyTimeout,
|
|
1035
1052
|
requestFinalized: false,
|
|
1053
|
+
responseContentLength: null,
|
|
1036
1054
|
responseReceived: false,
|
|
1037
1055
|
bodySent: false,
|
|
1038
1056
|
pendingEnd: false,
|
|
@@ -1328,12 +1346,17 @@ function onData (chunk) {
|
|
|
1328
1346
|
return
|
|
1329
1347
|
}
|
|
1330
1348
|
|
|
1331
|
-
const { request, maxResponseSize } = state
|
|
1349
|
+
const { request, maxResponseSize, responseContentLength } = state
|
|
1332
1350
|
|
|
1333
1351
|
if (request.aborted || request.completed) {
|
|
1334
1352
|
return
|
|
1335
1353
|
}
|
|
1336
1354
|
|
|
1355
|
+
if (responseContentLength != null && state.bytesRead + chunk.length > responseContentLength) {
|
|
1356
|
+
state.abort(new ResponseContentLengthMismatchError())
|
|
1357
|
+
return
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1337
1360
|
if (maxResponseSize > -1 && state.bytesRead + chunk.length > maxResponseSize) {
|
|
1338
1361
|
// Unlike HTTP/1.1, which destroys the socket because it cannot abandon one
|
|
1339
1362
|
// response without losing framing, resetting the offending stream leaves
|
|
@@ -1392,11 +1415,20 @@ function onResponse (headers) {
|
|
|
1392
1415
|
stream.end()
|
|
1393
1416
|
}
|
|
1394
1417
|
|
|
1395
|
-
const statusCode = headers[HTTP2_HEADER_STATUS]
|
|
1418
|
+
const statusCode = Number(headers[HTTP2_HEADER_STATUS])
|
|
1396
1419
|
delete headers[HTTP2_HEADER_STATUS]
|
|
1397
1420
|
request.onResponseStarted()
|
|
1398
1421
|
state.responseReceived = true
|
|
1399
1422
|
|
|
1423
|
+
// A Content-Length in HEAD and 304 responses describes the selected
|
|
1424
|
+
// representation rather than DATA on this stream. Successful CONNECT uses
|
|
1425
|
+
// the upgrade path above; all other final responses use Content-Length as
|
|
1426
|
+
// their DATA payload length.
|
|
1427
|
+
if (request.method !== 'HEAD' && statusCode !== 304) {
|
|
1428
|
+
const contentLength = headers[HTTP2_HEADER_CONTENT_LENGTH]
|
|
1429
|
+
state.responseContentLength = contentLength == null ? null : Number(contentLength)
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1400
1432
|
if (state.headersTimeout || state.bodyTimeout) {
|
|
1401
1433
|
stream.setTimeout(state.bodyTimeout)
|
|
1402
1434
|
}
|
|
@@ -1414,7 +1446,7 @@ function onResponse (headers) {
|
|
|
1414
1446
|
return
|
|
1415
1447
|
}
|
|
1416
1448
|
|
|
1417
|
-
if (request.onResponseStart(
|
|
1449
|
+
if (request.onResponseStart(statusCode, headers, stream.resume.bind(stream), '') === false) {
|
|
1418
1450
|
stream.pause()
|
|
1419
1451
|
}
|
|
1420
1452
|
|
|
@@ -1437,6 +1469,11 @@ function onEnd () {
|
|
|
1437
1469
|
// trailers on the state by now, so completing here still delivers them.
|
|
1438
1470
|
if (state.responseReceived) {
|
|
1439
1471
|
if (!request.aborted && !request.completed) {
|
|
1472
|
+
if (state.responseContentLength != null && state.bytesRead !== state.responseContentLength) {
|
|
1473
|
+
state.abort(new ResponseContentLengthMismatchError())
|
|
1474
|
+
return
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1440
1477
|
state.pendingEnd = true
|
|
1441
1478
|
|
|
1442
1479
|
// Complete on 'end': a blocked event loop can keep the stream's 'close'
|
|
@@ -1493,6 +1530,13 @@ function onError (err) {
|
|
|
1493
1530
|
|
|
1494
1531
|
stream.off('error', onError)
|
|
1495
1532
|
|
|
1533
|
+
// Node's HTTP/2 implementation can turn an incomplete Content-Length body
|
|
1534
|
+
// into a protocol stream error instead of emitting 'end'. Prefer the
|
|
1535
|
+
// content-length mismatch error when the received byte count proves it.
|
|
1536
|
+
if (state.responseContentLength != null && state.bytesRead !== state.responseContentLength) {
|
|
1537
|
+
err = new ResponseContentLengthMismatchError()
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1496
1540
|
if (typeof stream.rstCode === 'number' && stream.rstCode !== NGHTTP2_NO_ERROR) {
|
|
1497
1541
|
err.http2ErrorCode = stream.rstCode
|
|
1498
1542
|
}
|
|
@@ -238,7 +238,7 @@ class Client extends DispatcherBase {
|
|
|
238
238
|
throw new InvalidArgumentError('h2Options.settings.initialWindowSize must be a positive integer, greater than 0')
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
if (h2Options.maxConcurrentStreams != null && (!Number.isInteger(h2Options.
|
|
241
|
+
if (h2Options.maxConcurrentStreams != null && (!Number.isInteger(h2Options.maxConcurrentStreams) || h2Options.maxConcurrentStreams < 1)) {
|
|
242
242
|
throw new InvalidArgumentError('h2Options.maxConcurrentStreams must be a positive integer, greater than 0')
|
|
243
243
|
}
|
|
244
244
|
|
|
@@ -89,9 +89,10 @@ class Dispatcher1Wrapper extends Dispatcher {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
dispatch (opts, handler) {
|
|
92
|
-
// Legacy (v1) consumers do not support
|
|
92
|
+
// Legacy (v1) WebSocket consumers do not support falling back to HTTP/1.1
|
|
93
|
+
// when HTTP/2 Extended CONNECT is unavailable.
|
|
93
94
|
// See https://github.com/nodejs/undici/issues/4989
|
|
94
|
-
if (opts.allowH2 !== false) {
|
|
95
|
+
if (opts.upgrade && opts.allowH2 !== false) {
|
|
95
96
|
opts = { ...opts, allowH2: false }
|
|
96
97
|
}
|
|
97
98
|
|
|
@@ -94,17 +94,25 @@ class EnvHttpProxyAgent extends DispatcherBase {
|
|
|
94
94
|
if (this.#noProxyEntries.length === 0) {
|
|
95
95
|
return true // Always proxy if NO_PROXY is not set or empty.
|
|
96
96
|
}
|
|
97
|
-
if (this.#noProxyValue === '*') {
|
|
98
|
-
return false // Never proxy if wildcard is set.
|
|
99
|
-
}
|
|
100
97
|
|
|
101
98
|
for (let i = 0; i < this.#noProxyEntries.length; i++) {
|
|
102
99
|
const entry = this.#noProxyEntries[i]
|
|
100
|
+
// A bare `*` entry matches all hosts regardless of its position or the
|
|
101
|
+
// surrounding whitespace (e.g. ` * ` or `none.invalid,*`). If a port is
|
|
102
|
+
// attached (`*:80`) it only bypasses that port.
|
|
103
|
+
if (entry.hostname === '*') {
|
|
104
|
+
if (entry.port && entry.port !== port) {
|
|
105
|
+
continue
|
|
106
|
+
}
|
|
107
|
+
return false // Never proxy if a wildcard entry is present.
|
|
108
|
+
}
|
|
103
109
|
if (entry.port && entry.port !== port) {
|
|
104
110
|
continue // Skip if ports don't match.
|
|
105
111
|
}
|
|
106
|
-
// Don't proxy if the hostname is equal with the no_proxy host.
|
|
107
|
-
|
|
112
|
+
// Don't proxy if the hostname is equal with the no_proxy host. A
|
|
113
|
+
// `*.example.com` wildcard matches subdomains only, not the apex
|
|
114
|
+
// `example.com`, so exact matches are skipped for wildcard entries.
|
|
115
|
+
if (!entry.wildcard && hostname === entry.hostname) {
|
|
108
116
|
return false
|
|
109
117
|
}
|
|
110
118
|
// Don't proxy if the hostname is the subdomain of the no_proxy host.
|
|
@@ -149,10 +157,17 @@ class EnvHttpProxyAgent extends DispatcherBase {
|
|
|
149
157
|
port = parsed ? Number.parseInt(parsed[2], 10) : 0
|
|
150
158
|
}
|
|
151
159
|
|
|
160
|
+
// A leading `*` marks a subdomain wildcard (`*.example.com`), distinct
|
|
161
|
+
// from a plain or leading-dot suffix (`example.com` / `.example.com`)
|
|
162
|
+
// which also matches the apex. `*.example.com` must only match
|
|
163
|
+
// subdomains, never the apex `example.com` itself.
|
|
164
|
+
const wildcard = entry.charCodeAt(0) === 42 /* '*' */
|
|
165
|
+
|
|
152
166
|
noProxyEntries.push({
|
|
153
167
|
// strip leading dot or asterisk with dot, and any trailing dot
|
|
154
168
|
hostname: hostname.replace(/^\*?\./, '').replace(/^(.+)\.$/, '$1').toLowerCase(),
|
|
155
|
-
port
|
|
169
|
+
port,
|
|
170
|
+
wildcard
|
|
156
171
|
})
|
|
157
172
|
}
|
|
158
173
|
|
|
@@ -13,6 +13,9 @@ const kOnDrain = Symbol('onDrain')
|
|
|
13
13
|
const kOnConnect = Symbol('onConnect')
|
|
14
14
|
const kOnDisconnect = Symbol('onDisconnect')
|
|
15
15
|
const kOnConnectionError = Symbol('onConnectionError')
|
|
16
|
+
const kOnClientBusy = Symbol('on client busy')
|
|
17
|
+
const kOnClientDrain = Symbol('on client drain')
|
|
18
|
+
const kDrainQueue = Symbol('drain queue')
|
|
16
19
|
const kGetDispatcher = Symbol('get dispatcher')
|
|
17
20
|
const kHasDispatcher = Symbol('has dispatcher')
|
|
18
21
|
const kAddClient = Symbol('add client')
|
|
@@ -28,10 +31,15 @@ class PoolBase extends DispatcherBase {
|
|
|
28
31
|
[kNeedDrain] = false;
|
|
29
32
|
|
|
30
33
|
[kOnDrain] (client, origin, targets) {
|
|
31
|
-
|
|
34
|
+
if (client.closed || client.destroyed) {
|
|
35
|
+
return
|
|
36
|
+
}
|
|
32
37
|
|
|
38
|
+
const queue = this[kQueue]
|
|
33
39
|
let needDrain = false
|
|
34
40
|
|
|
41
|
+
this[kOnClientDrain](client)
|
|
42
|
+
|
|
35
43
|
while (!needDrain) {
|
|
36
44
|
const item = queue.shift()
|
|
37
45
|
if (!item) {
|
|
@@ -42,6 +50,9 @@ class PoolBase extends DispatcherBase {
|
|
|
42
50
|
}
|
|
43
51
|
|
|
44
52
|
client[kNeedDrain] = needDrain
|
|
53
|
+
if (needDrain) {
|
|
54
|
+
this[kOnClientBusy](client)
|
|
55
|
+
}
|
|
45
56
|
|
|
46
57
|
if (!needDrain && this[kNeedDrain]) {
|
|
47
58
|
this[kNeedDrain] = false
|
|
@@ -61,6 +72,52 @@ class PoolBase extends DispatcherBase {
|
|
|
61
72
|
}
|
|
62
73
|
}
|
|
63
74
|
|
|
75
|
+
[kOnClientBusy] () {}
|
|
76
|
+
|
|
77
|
+
[kOnClientDrain] () {}
|
|
78
|
+
|
|
79
|
+
[kDrainQueue] (origin, targets) {
|
|
80
|
+
const queue = this[kQueue]
|
|
81
|
+
let hasDispatcher = true
|
|
82
|
+
|
|
83
|
+
while (!queue.isEmpty()) {
|
|
84
|
+
const dispatcher = this[kGetDispatcher]()
|
|
85
|
+
if (!dispatcher) {
|
|
86
|
+
hasDispatcher = false
|
|
87
|
+
break
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const item = queue.shift()
|
|
91
|
+
this[kQueued]--
|
|
92
|
+
|
|
93
|
+
if (!dispatcher.dispatch(item.opts, item.handler)) {
|
|
94
|
+
dispatcher[kNeedDrain] = true
|
|
95
|
+
this[kOnClientBusy](dispatcher)
|
|
96
|
+
hasDispatcher = this[kHasDispatcher]()
|
|
97
|
+
if (!hasDispatcher) {
|
|
98
|
+
break
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (hasDispatcher && this[kNeedDrain]) {
|
|
104
|
+
this[kNeedDrain] = false
|
|
105
|
+
this.emit('drain', origin, [this, ...targets])
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (this[kClosedResolve] && queue.isEmpty()) {
|
|
109
|
+
const closeAll = []
|
|
110
|
+
for (let i = 0; i < this[kClients].length; i++) {
|
|
111
|
+
const client = this[kClients][i]
|
|
112
|
+
if (!client.destroyed) {
|
|
113
|
+
closeAll.push(client.close())
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return Promise.all(closeAll)
|
|
117
|
+
.then(this[kClosedResolve])
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
64
121
|
[kOnConnect] = (origin, targets) => {
|
|
65
122
|
this.emit('connect', origin, [this, ...targets])
|
|
66
123
|
};
|
|
@@ -163,6 +220,7 @@ class PoolBase extends DispatcherBase {
|
|
|
163
220
|
this[kQueued]++
|
|
164
221
|
} else if (!dispatcher.dispatch(opts, handler)) {
|
|
165
222
|
dispatcher[kNeedDrain] = true
|
|
223
|
+
this[kOnClientBusy](dispatcher)
|
|
166
224
|
this[kNeedDrain] = !this[kHasDispatcher]()
|
|
167
225
|
}
|
|
168
226
|
|
|
@@ -196,7 +254,7 @@ class PoolBase extends DispatcherBase {
|
|
|
196
254
|
|
|
197
255
|
if (this[kNeedDrain]) {
|
|
198
256
|
queueMicrotask(() => {
|
|
199
|
-
if (this[kNeedDrain]) {
|
|
257
|
+
if (this[kNeedDrain] && !client[kNeedDrain]) {
|
|
200
258
|
this[kOnDrain](client, client[kUrl], [client, this])
|
|
201
259
|
}
|
|
202
260
|
})
|
|
@@ -227,6 +285,9 @@ module.exports = {
|
|
|
227
285
|
kNeedDrain,
|
|
228
286
|
kAddClient,
|
|
229
287
|
kRemoveClient,
|
|
288
|
+
kDrainQueue,
|
|
289
|
+
kOnClientBusy,
|
|
290
|
+
kOnClientDrain,
|
|
230
291
|
kGetDispatcher,
|
|
231
292
|
kHasDispatcher
|
|
232
293
|
}
|
|
@@ -5,6 +5,9 @@ const {
|
|
|
5
5
|
kClients,
|
|
6
6
|
kNeedDrain,
|
|
7
7
|
kAddClient,
|
|
8
|
+
kDrainQueue,
|
|
9
|
+
kOnClientBusy,
|
|
10
|
+
kOnClientDrain,
|
|
8
11
|
kGetDispatcher,
|
|
9
12
|
kHasDispatcher,
|
|
10
13
|
kRemoveClient
|
|
@@ -14,17 +17,41 @@ const {
|
|
|
14
17
|
InvalidArgumentError
|
|
15
18
|
} = require('../core/errors')
|
|
16
19
|
const util = require('../core/util')
|
|
17
|
-
const { kUrl } = require('../core/symbols')
|
|
20
|
+
const { kConnecting, kHTTPContext, kUrl } = require('../core/symbols')
|
|
18
21
|
const buildConnector = require('../core/connect')
|
|
19
22
|
|
|
20
23
|
const kOptions = Symbol('options')
|
|
21
24
|
const kConnections = Symbol('connections')
|
|
22
25
|
const kFactory = Symbol('factory')
|
|
26
|
+
const kProtocol = Symbol('protocol')
|
|
27
|
+
const kProtocolProbe = Symbol('protocol probe')
|
|
23
28
|
|
|
24
29
|
function defaultFactory (origin, opts) {
|
|
25
30
|
return new Client(origin, opts)
|
|
26
31
|
}
|
|
27
32
|
|
|
33
|
+
function shouldCreateProtocolProbe (pool, dispatcher) {
|
|
34
|
+
return dispatcher instanceof Client &&
|
|
35
|
+
pool[kProtocol] !== 'h1' &&
|
|
36
|
+
(pool[kOptions].useH2c === true || (pool[kUrl].protocol === 'https:' && pool[kOptions].allowH2 !== false))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function createClient (pool) {
|
|
40
|
+
const dispatcher = pool[kFactory](pool[kUrl], pool[kOptions])
|
|
41
|
+
|
|
42
|
+
// HTTPS does not reveal whether the peer selected h1 or h2 until ALPN
|
|
43
|
+
// completes. While h2 is still possible, let one Client probe the protocol
|
|
44
|
+
// and keep later requests in the Pool queue instead of opening one TLS
|
|
45
|
+
// connection per request. A confirmed h1 connection disables this gate and
|
|
46
|
+
// restores the usual Pool fan-out.
|
|
47
|
+
if (shouldCreateProtocolProbe(pool, dispatcher)) {
|
|
48
|
+
pool[kProtocolProbe] = dispatcher
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
pool[kAddClient](dispatcher)
|
|
52
|
+
return dispatcher
|
|
53
|
+
}
|
|
54
|
+
|
|
28
55
|
class Pool extends PoolBase {
|
|
29
56
|
constructor (origin, {
|
|
30
57
|
connections,
|
|
@@ -72,6 +99,8 @@ class Pool extends PoolBase {
|
|
|
72
99
|
this[kUrl] = util.parseOrigin(origin)
|
|
73
100
|
this[kOptions] = { ...util.deepClone(options), connect, allowH2, useH2c, clientTtl, socketPath }
|
|
74
101
|
this[kFactory] = factory
|
|
102
|
+
this[kProtocol] = null
|
|
103
|
+
this[kProtocolProbe] = null
|
|
75
104
|
|
|
76
105
|
this.on('connect', (origin, targets) => {
|
|
77
106
|
if (clientTtl != null && clientTtl > 0) {
|
|
@@ -79,13 +108,42 @@ class Pool extends PoolBase {
|
|
|
79
108
|
Object.assign(target, { ttl: Date.now() })
|
|
80
109
|
}
|
|
81
110
|
}
|
|
111
|
+
|
|
112
|
+
const client = targets[targets.length - 1]
|
|
113
|
+
if (client instanceof Client) {
|
|
114
|
+
this[kProtocol] = client[kHTTPContext]?.version
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (client === this[kProtocolProbe]) {
|
|
118
|
+
// An h2 Client's drain event releases the requests accumulated during
|
|
119
|
+
// negotiation onto that Client. If ALPN selected h1, release the probe
|
|
120
|
+
// immediately and restore normal Pool fan-out instead.
|
|
121
|
+
if (this[kProtocol] !== 'h2') {
|
|
122
|
+
this[kProtocolProbe] = null
|
|
123
|
+
this[kDrainQueue](origin, targets.slice(1))
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
this.on('disconnect', (origin, targets) => {
|
|
129
|
+
if (targets.includes(this[kProtocolProbe])) {
|
|
130
|
+
this[kProtocolProbe] = null
|
|
131
|
+
this[kDrainQueue](origin, targets.slice(1))
|
|
132
|
+
}
|
|
82
133
|
})
|
|
83
134
|
|
|
84
|
-
this.on('connectionError', (origin, targets
|
|
135
|
+
this.on('connectionError', (origin, targets) => {
|
|
136
|
+
let resumeQueued = false
|
|
137
|
+
|
|
85
138
|
// If a connection error occurs, we remove the client from the pool,
|
|
86
139
|
// and emit a connectionError event. They will not be re-used.
|
|
87
140
|
// Fixes https://github.com/nodejs/undici/issues/3895
|
|
88
141
|
for (const target of targets) {
|
|
142
|
+
if (target === this[kProtocolProbe]) {
|
|
143
|
+
this[kProtocolProbe] = null
|
|
144
|
+
resumeQueued = true
|
|
145
|
+
}
|
|
146
|
+
|
|
89
147
|
// Do not use kRemoveClient here, as it will close the client,
|
|
90
148
|
// but the client cannot be closed in this state.
|
|
91
149
|
const idx = this[kClients].indexOf(target)
|
|
@@ -93,9 +151,29 @@ class Pool extends PoolBase {
|
|
|
93
151
|
this[kClients].splice(idx, 1)
|
|
94
152
|
}
|
|
95
153
|
}
|
|
154
|
+
|
|
155
|
+
if (resumeQueued) {
|
|
156
|
+
this[kDrainQueue](origin, targets.slice(1))
|
|
157
|
+
}
|
|
96
158
|
})
|
|
97
159
|
}
|
|
98
160
|
|
|
161
|
+
[kOnClientBusy] (client) {
|
|
162
|
+
if (
|
|
163
|
+
this[kProtocolProbe] === null &&
|
|
164
|
+
client[kConnecting] &&
|
|
165
|
+
shouldCreateProtocolProbe(this, client)
|
|
166
|
+
) {
|
|
167
|
+
this[kProtocolProbe] = client
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
[kOnClientDrain] (client) {
|
|
172
|
+
if (client === this[kProtocolProbe]) {
|
|
173
|
+
this[kProtocolProbe] = null
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
99
177
|
[kGetDispatcher] () {
|
|
100
178
|
const clientTtlOption = this[kOptions].clientTtl
|
|
101
179
|
for (let i = 0; i < this[kClients].length; i++) {
|
|
@@ -110,10 +188,12 @@ class Pool extends PoolBase {
|
|
|
110
188
|
}
|
|
111
189
|
}
|
|
112
190
|
|
|
191
|
+
if (this[kProtocolProbe] !== null) {
|
|
192
|
+
return
|
|
193
|
+
}
|
|
194
|
+
|
|
113
195
|
if (!this[kConnections] || this[kClients].length < this[kConnections]) {
|
|
114
|
-
|
|
115
|
-
this[kAddClient](dispatcher)
|
|
116
|
-
return dispatcher
|
|
196
|
+
return createClient(this)
|
|
117
197
|
}
|
|
118
198
|
}
|
|
119
199
|
|
|
@@ -130,9 +210,12 @@ class Pool extends PoolBase {
|
|
|
130
210
|
}
|
|
131
211
|
}
|
|
132
212
|
|
|
213
|
+
if (this[kProtocolProbe] !== null) {
|
|
214
|
+
return false
|
|
215
|
+
}
|
|
216
|
+
|
|
133
217
|
if (!this[kConnections] || this[kClients].length < this[kConnections]) {
|
|
134
|
-
|
|
135
|
-
this[kAddClient](dispatcher)
|
|
218
|
+
createClient(this)
|
|
136
219
|
return true
|
|
137
220
|
}
|
|
138
221
|
|
|
@@ -325,8 +325,8 @@ class ProxyAgent extends DispatcherBase {
|
|
|
325
325
|
}
|
|
326
326
|
|
|
327
327
|
/**
|
|
328
|
-
* @param {string[] | Record<string, string>} headers
|
|
329
|
-
* @returns {Record<string, string>}
|
|
328
|
+
* @param {string[] | Record<string, string> | Iterable<[string, string | string[] | undefined]>} headers
|
|
329
|
+
* @returns {Record<string, string | string[] | undefined>}
|
|
330
330
|
*/
|
|
331
331
|
function buildHeaders (headers) {
|
|
332
332
|
// When using undici.fetch, the headers list is stored
|
|
@@ -355,7 +355,20 @@ function buildHeaders (headers) {
|
|
|
355
355
|
const headersPair = {}
|
|
356
356
|
|
|
357
357
|
for (const [key, value] of headers) {
|
|
358
|
-
headersPair
|
|
358
|
+
if (!Object.hasOwn(headersPair, key)) {
|
|
359
|
+
headersPair[key] = value
|
|
360
|
+
continue
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
const previous = headersPair[key]
|
|
364
|
+
const values = []
|
|
365
|
+
if (previous !== undefined) {
|
|
366
|
+
values.push(...(Array.isArray(previous) ? previous : [previous]))
|
|
367
|
+
}
|
|
368
|
+
if (value !== undefined) {
|
|
369
|
+
values.push(...(Array.isArray(value) ? value : [value]))
|
|
370
|
+
}
|
|
371
|
+
headersPair[key] = values.length > 1 ? values : values[0]
|
|
359
372
|
}
|
|
360
373
|
|
|
361
374
|
return headersPair
|
|
@@ -251,8 +251,11 @@ class DeduplicationHandler {
|
|
|
251
251
|
return
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
-
|
|
254
|
+
// Remove the entry before callbacks can synchronously dispatch a retry.
|
|
255
|
+
this.#cleanup()
|
|
255
256
|
this.#primaryHandler.onResponseEnd?.(controller, trailers)
|
|
257
|
+
// A throwing end callback must still be handled by onResponseError.
|
|
258
|
+
this.#completed = true
|
|
256
259
|
|
|
257
260
|
for (const waitingHandler of this.#waitingHandlers) {
|
|
258
261
|
if (waitingHandler.done || waitingHandler.controller.aborted) {
|
|
@@ -267,22 +270,21 @@ class DeduplicationHandler {
|
|
|
267
270
|
continue
|
|
268
271
|
}
|
|
269
272
|
|
|
270
|
-
if (waitingHandler.controller.paused
|
|
273
|
+
if (waitingHandler.controller.paused) {
|
|
271
274
|
waitingHandler.pendingTrailers = trailers
|
|
272
275
|
continue
|
|
273
276
|
}
|
|
274
277
|
|
|
275
278
|
try {
|
|
276
279
|
waitingHandler.handler.onResponseEnd?.(waitingHandler.controller, trailers)
|
|
277
|
-
} catch {
|
|
278
|
-
|
|
280
|
+
} catch (err) {
|
|
281
|
+
this.#errorWaitingHandler(waitingHandler, err)
|
|
279
282
|
}
|
|
280
283
|
|
|
281
284
|
waitingHandler.done = true
|
|
282
285
|
}
|
|
283
286
|
|
|
284
287
|
this.#pruneDoneWaitingHandlers()
|
|
285
|
-
this.#onComplete?.()
|
|
286
288
|
}
|
|
287
289
|
|
|
288
290
|
/**
|
|
@@ -296,6 +298,7 @@ class DeduplicationHandler {
|
|
|
296
298
|
|
|
297
299
|
this.#aborted = true
|
|
298
300
|
this.#completed = true
|
|
301
|
+
this.#cleanup()
|
|
299
302
|
|
|
300
303
|
this.#primaryHandler.onResponseError?.(controller, err)
|
|
301
304
|
|
|
@@ -304,7 +307,12 @@ class DeduplicationHandler {
|
|
|
304
307
|
}
|
|
305
308
|
|
|
306
309
|
this.#waitingHandlers = []
|
|
307
|
-
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
#cleanup () {
|
|
313
|
+
const onComplete = this.#onComplete
|
|
314
|
+
this.#onComplete = null
|
|
315
|
+
onComplete?.()
|
|
308
316
|
}
|
|
309
317
|
|
|
310
318
|
/**
|
|
@@ -346,8 +354,8 @@ class DeduplicationHandler {
|
|
|
346
354
|
) {
|
|
347
355
|
try {
|
|
348
356
|
waitingHandler.handler.onResponseEnd?.(waitingHandler.controller, waitingHandler.pendingTrailers)
|
|
349
|
-
} catch {
|
|
350
|
-
|
|
357
|
+
} catch (err) {
|
|
358
|
+
this.#errorWaitingHandler(waitingHandler, err)
|
|
351
359
|
}
|
|
352
360
|
|
|
353
361
|
waitingHandler.pendingTrailers = null
|
|
@@ -405,7 +413,7 @@ class DeduplicationHandler {
|
|
|
405
413
|
|
|
406
414
|
if (waitingHandler.bufferedBytes > this.#maxBufferSize) {
|
|
407
415
|
const err = new RequestAbortedError(`Deduplicated waiting handler exceeded maxBufferSize (${this.#maxBufferSize} bytes) while paused`)
|
|
408
|
-
|
|
416
|
+
waitingHandler.controller.abort(err)
|
|
409
417
|
}
|
|
410
418
|
}
|
|
411
419
|
|
|
@@ -454,8 +462,13 @@ class DeduplicationHandler {
|
|
|
454
462
|
waitingHandler.bufferedChunks = []
|
|
455
463
|
waitingHandler.bufferedBytes = 0
|
|
456
464
|
|
|
457
|
-
//
|
|
458
|
-
|
|
465
|
+
// A response failure is not a consumer abort: retry handlers must be able
|
|
466
|
+
// to retry it just as they would a failure of the primary request.
|
|
467
|
+
try {
|
|
468
|
+
waitingHandler.handler.onResponseError?.(waitingHandler.controller, err)
|
|
469
|
+
} catch {
|
|
470
|
+
// Ignore errors from waiting handlers
|
|
471
|
+
}
|
|
459
472
|
}
|
|
460
473
|
|
|
461
474
|
#pruneDoneWaitingHandlers () {
|
|
@@ -57,6 +57,11 @@ class RedirectHandler {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
onResponseStart (controller, statusCode, headers, statusMessage) {
|
|
60
|
+
if (statusCode < 200) {
|
|
61
|
+
this.handler.onResponseStart?.(controller, statusCode, headers, statusMessage)
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
|
|
60
65
|
if (this.opts.throwOnMaxRedirect && this.history.length >= this.maxRedirections) {
|
|
61
66
|
throw new Error('max redirects')
|
|
62
67
|
}
|