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
|
@@ -6,7 +6,7 @@ description: "分七步编写 Adapter 的 send 函数:发送消息、续接会
|
|
|
6
6
|
|
|
7
7
|
import { TurnRoundtrip } from '/snippets/diagram-turn-roundtrip.jsx';
|
|
8
8
|
|
|
9
|
-
[Adapter](/zh/explanation/adapter) 定义了 `send` 的契约:接收 `TurnInput` 和 `AgentContext`,返回 `Turn`。本教程从发送一条消息开始,逐步加入完整接入所需的能力。每一步只增加少量代码,已有部分以 `// ……省略` 标出。步骤末尾列出新增数据支持的断言。完成任一步后,都可以把对应断言写进评估用例,重跑 `
|
|
9
|
+
[Adapter](/zh/explanation/adapter) 定义了 `send` 的契约:接收 `TurnInput` 和 `AgentContext`,返回 `Turn`。本教程从发送一条消息开始,逐步加入完整接入所需的能力。每一步只增加少量代码,已有部分以 `// ……省略` 标出。步骤末尾列出新增数据支持的断言。完成任一步后,都可以把对应断言写进评估用例,重跑 `pnpm exec niceeval exp`,再用 `pnpm exec niceeval show` 在终端查看结果,或用 `pnpm exec niceeval view` 在浏览器里检查多轮对话、用量、工具事件和待回答的请求。
|
|
10
10
|
|
|
11
11
|
五个贯穿全文的原则:
|
|
12
12
|
|
|
@@ -20,7 +20,7 @@ import { TurnRoundtrip } from '/snippets/diagram-turn-roundtrip.jsx';
|
|
|
20
20
|
|
|
21
21
|
## 确认应用接口形状
|
|
22
22
|
|
|
23
|
-
[NiceEval](https://niceeval.com/)
|
|
23
|
+
动手写 `send` 之前,先确认你的应用接口长什么样。[NiceEval](https://niceeval.com/) 不定义新的应用协议,内置转换器按下面几种常见的响应形状提供。认出你的接口属于哪一种,后面就能直接用对应的转换器,少写映射代码:
|
|
24
24
|
|
|
25
25
|
| 协议 | 定义方 | 说明 | 参考 |
|
|
26
26
|
|---|---|---|---|
|
|
@@ -32,7 +32,7 @@ import { TurnRoundtrip } from '/snippets/diagram-turn-roundtrip.jsx';
|
|
|
32
32
|
|
|
33
33
|
## 第一步:发一条消息,拿到回复
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
先让评估用例能发一条消息、拿到一条回复。这是所有断言的起点。最小的 `send` 只做三件事:把 `input.text` 发给应用的接口,把回复放进一条 `message` 事件,报告本轮 `status`:
|
|
36
36
|
|
|
37
37
|
```ts
|
|
38
38
|
// agents/chat-app.ts
|
|
@@ -63,7 +63,7 @@ export default defineAgent({
|
|
|
63
63
|
});
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
接口返回的响应能继续用、但缺了一部分信息时,用 `ctx.diagnostic` 留一条说明,不要把原始响应整个打印出来:
|
|
67
67
|
|
|
68
68
|
```ts
|
|
69
69
|
if (!res.requestId) {
|
|
@@ -75,7 +75,7 @@ if (!res.requestId) {
|
|
|
75
75
|
}
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
`progress`
|
|
78
|
+
`progress` 只在运行时显示,不保存。diagnostic 会随这个 Attempt 的结果一起保存,运行结束后在 Attempt 详情里能看到。HTTP 连接失败或响应无法解析时直接抛错。这个 Attempt 会被判为 `errored`,错误阶段显示为 `agent.run`,用 `pnpm exec niceeval show @<locator>` 可以看到完整错误正文。
|
|
79
79
|
|
|
80
80
|
**这一步支持**:`t.reply` 的直接值检查(`t.check(t.reply, includes(...))` 或 `pattern(...)`)、Judge 的全部对话材料,以及 Experiment 侧的**模型对比**。`ctx.model` 来自 Experiment 的 `model`。运行器原样传递,Adapter 只负责转发。接入等级见 [Tier](/zh/explanation/tier)。
|
|
81
81
|
|
|
@@ -83,14 +83,16 @@ if (!res.requestId) {
|
|
|
83
83
|
|
|
84
84
|
## 第二步:接上之前的消息
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
第一步的 `send` 每轮都开一场新对话,评估用例的第二次 `t.send` 接不上第一次。要测多轮对话,`send` 得记住之前说过什么。
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
运行器只保证一件事:**同一条会话线上的每次 `send` 拿到同一个 `ctx.session`,新会话线(评估用例的第一轮,或 `t.newSession()` 之后)拿到一个全新的。**
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
- **服务端记历史**(接口收一个会话 id:Responses 形的 `previous_response_id`、各 SDK 的原生 session / thread)→ `ctx.session.id` + `ctx.session.capture(id)`
|
|
90
|
+
怎么续接取决于应用接口:
|
|
92
91
|
|
|
93
|
-
|
|
92
|
+
- **客户端每轮发完整历史**(服务端不记状态,Chat Completions 形是典型):用 `createSessionSlot<TMsg[]>()` 声明一份 Adapter 私有的会话状态,再用 `ctx.session.get(...)` / `ctx.session.set(...)` 存取历史消息。
|
|
93
|
+
- **服务端记历史**(接口收一个会话 id,例如 Responses 形的 `previous_response_id`、各 SDK 的原生 session / thread):用 `ctx.session.id` 读取,用 `ctx.session.capture(id)` 写回。
|
|
94
|
+
|
|
95
|
+
本教程的接口是前一种:
|
|
94
96
|
|
|
95
97
|
```ts
|
|
96
98
|
// agents/chat-app.ts
|
|
@@ -105,7 +107,7 @@ export default defineAgent({
|
|
|
105
107
|
name: "chat-app",
|
|
106
108
|
evidenceCoverage: completeEvidenceCoverage,
|
|
107
109
|
async send(input, ctx) {
|
|
108
|
-
const history = ctx.session.get(historySlot) ?? []; // ←
|
|
110
|
+
const history = ctx.session.get(historySlot) ?? []; // ← 新会话线上还没有历史
|
|
109
111
|
const messages = [...history, { role: "user" as const, content: input.text }];
|
|
110
112
|
|
|
111
113
|
const res = await fetch(`${BASE_URL}/v1/chat/completions`, {
|
|
@@ -124,9 +126,9 @@ export default defineAgent({
|
|
|
124
126
|
});
|
|
125
127
|
```
|
|
126
128
|
|
|
127
|
-
|
|
129
|
+
这里不需要“第一轮”分支。新会话线上 `ctx.session.get(historySlot)` 返回 `undefined`,`?? []` 把它变成空历史,第一轮自然就是空历史加一条新消息。也不需要在 `defineAgent` 上声明额外能力:用了 `ctx.session`,多轮就能续上;不用,每轮各是一场新对话。
|
|
128
130
|
|
|
129
|
-
应用接口收会话 id
|
|
131
|
+
应用接口收会话 id 时,历史留在服务端,Adapter 只记住 id。`send` 里只改两处:
|
|
130
132
|
|
|
131
133
|
```ts
|
|
132
134
|
// send 里:
|
|
@@ -134,13 +136,13 @@ export default defineAgent({
|
|
|
134
136
|
// 返回里抓到 id 就写回 …… ctx.session.capture(res.id) ← 下一轮续接靠它
|
|
135
137
|
```
|
|
136
138
|
|
|
137
|
-
`capture`
|
|
139
|
+
`capture` 只在这条会话线还没记过 id 时生效。后端每轮重复回传 id,甚至因为分叉换了 id,都不会覆盖正在续接的会话。
|
|
138
140
|
|
|
139
|
-
**这一步支持**:多轮对话,以及 `t.newSession()`
|
|
141
|
+
**这一步支持**:多轮对话,以及 `t.newSession()` 的会话隔离。写一个两轮的评估用例,第二轮引用第一轮的内容。回复接不上时,先查请求里是否带上了历史或会话 id。
|
|
140
142
|
|
|
141
143
|
## 第三步:记录消费
|
|
142
144
|
|
|
143
|
-
|
|
145
|
+
答对了但多花十倍 token 的 Agent,不该和省着用的拿一样的分。要限制用量和费用,`send` 得把每轮的用量报上来。用量写在 `Turn` 的 `usage` 字段,和 `events`、`status` 并列。应用接口返回了用量就如实填上,运行器逐轮累加到会话线和这次运行。Chat Completions 形的返回自带 `usage`,照抄进来,`send` 的其余部分和第二步一样:
|
|
144
146
|
|
|
145
147
|
```ts
|
|
146
148
|
// ……transport 与会话同第二步,省略
|
|
@@ -154,21 +156,21 @@ export default defineAgent({
|
|
|
154
156
|
};
|
|
155
157
|
```
|
|
156
158
|
|
|
157
|
-
`Usage`
|
|
158
|
-
|
|
159
|
+
`Usage` 还有几个可选字段:`cacheReadTokens` / `cacheCreationTokens`、推理 token 数 `reasoningTokens`、请求次数 `requests`,以及 `costUSD`。每个字段只在接口真实提供时填。接口不返回用量,就整个不填 `usage`,其它断言不受影响。
|
|
160
|
+
|
|
161
|
+
`costUSD` 只填 Provider 或应用真实返回的美元费用。不要把上游估算、模型价目表或本地算出来的数写进去。
|
|
159
162
|
|
|
160
|
-
|
|
161
|
-
也不改变该计算;Experiment budget 与 `t.maxCost()` 使用这个 estimate。固定 Inspection operation 只读取 sealed Usage,绝不消费 Runner
|
|
162
|
-
estimate。
|
|
163
|
+
预算和 `t.maxCost()` 用的是另一个数:运行器根据 `model`、上报的 token 用量和价格表,自己算出 `estimatedCostUSD`。即使你填了 `costUSD`,这个估算也照常计算。价格表配置见 [`defineConfig` 参考](/zh/reference/define-config),预算用法见[控制运行成本](/zh/tutorials/control-run-cost)。
|
|
163
164
|
|
|
164
|
-
|
|
165
|
-
算得 `estimatedCostUSD: 0` 时,`0` 是合法 estimate,仍按上限规则求值。
|
|
165
|
+
价格表里找不到这个模型的价格时,运行器算不出估算,`t.maxCost()` 的结果是 `unavailable`,不会把缺失当成 `0`。你显式配置了零费率、算出 `estimatedCostUSD: 0` 时,`0` 是有效的估算,照常和上限比较。
|
|
166
166
|
|
|
167
|
-
**这一步支持**:`t.maxTokens()` / `t.maxCost()`
|
|
167
|
+
**这一步支持**:`t.maxTokens()` / `t.maxCost()` 断言,以及 `niceeval show --usage` 和 `niceeval view` 里的用量。`show` 里用量为空时,先查接口响应里有没有用量字段、`send` 有没有把它放进返回值。
|
|
168
168
|
|
|
169
169
|
## 第四步:把工具解析成事件
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
要断言 Agent 调了哪些工具、按什么顺序调,`send` 得把工具调用报上来。应用的返回里不只有回复文本,Chat Completions 形返回的 `tool_calls` 就记着这轮调过什么工具。
|
|
172
|
+
|
|
173
|
+
Adapter 最重要的工作就是**把接口的返回翻译成标准事件流**:这轮发生的每件事一个对象,按真实顺序放进 `Turn.events`。每个对象是下面几种类型之一,字段的实际取值见 [Adapter 页的一轮完整示例](/zh/explanation/adapter):
|
|
172
174
|
|
|
173
175
|
```ts
|
|
174
176
|
import type { CommandProjection } from "niceeval/adapter";
|
|
@@ -190,7 +192,7 @@ type StreamEvent =
|
|
|
190
192
|
| { type: "error"; message: string };
|
|
191
193
|
```
|
|
192
194
|
|
|
193
|
-
|
|
195
|
+
翻译就是一张“返回字段 → 事件”的对照。手写出来是这样,`send` 的其余部分和第二步一样:
|
|
194
196
|
|
|
195
197
|
```ts
|
|
196
198
|
// ……transport 与会话同第二步,usage 同第三步,省略
|
|
@@ -213,14 +215,14 @@ type StreamEvent =
|
|
|
213
215
|
return { events, status: "completed", usage };
|
|
214
216
|
```
|
|
215
217
|
|
|
216
|
-
|
|
218
|
+
这段循环通常不用你写。返回是标准形状时,官方转换器一行就能替代上面全部代码。`events`、`status`,连第三步手抄的 `usage` 都在它的返回值里,直接 `return`:
|
|
217
219
|
|
|
218
220
|
```ts
|
|
219
221
|
// ……transport 与会话同第二步,省略
|
|
220
222
|
return turnFromChatCompletion(res); // ← 上面那段映射加第三步的 usage,官方版
|
|
221
223
|
```
|
|
222
224
|
|
|
223
|
-
|
|
225
|
+
接口是别的形状时,换成对应的转换器:
|
|
224
226
|
|
|
225
227
|
| 接口响应形状 | 内置实现 | 需要编写的代码 |
|
|
226
228
|
|---|---|---|
|
|
@@ -232,31 +234,31 @@ type StreamEvent =
|
|
|
232
234
|
| 流式:逐 token / 逐参数增量 | 协议方官方 reducer。没有才用 `deltaStream({ toOps })` | 一张"帧类型 → 操作"映射表 |
|
|
233
235
|
| 只有最终答案 | 手写几条 events | 一条 `message` 起步(第一步就是这个档) |
|
|
234
236
|
|
|
235
|
-
|
|
237
|
+
内置转换器只看响应形状,不关心应用的业务协议。只有接口是增量流、协议方又没有现成 reducer 时,才需要自己写映射。映射只说明每一帧对应什么动作,拼接、配对和何时形成完整事件由 `deltaStream` 处理。
|
|
236
238
|
|
|
237
|
-
|
|
239
|
+
你返回哪种事件,评估用例就能写哪类断言:
|
|
238
240
|
|
|
239
|
-
|
|
|
241
|
+
| 你返回的事件 | 能写的断言 |
|
|
240
242
|
|---|---|
|
|
241
243
|
| `message` | `t.reply`、`t.check(turn.message, includes(...))` / `pattern(...)`、Judge 的对话材料 |
|
|
242
244
|
| tool `operation.started` / `operation.finished`(靠 `operationId` 配对) | `turn.calledTool()` / `turn.toolOrder()` / `turn.maxToolCalls()` / `turn.noFailedActions()`… |
|
|
243
245
|
| `input.requested`(配合 status `"waiting"`) | `t.check(turn.status, equals("waiting"))`、`t.requireInputRequest()`、`t.respond()`(第五步) |
|
|
244
246
|
| `thinking` / `compaction` / `error` | 报告与诊断;也可把原始 `events` 交给普通 `check(events, match)` |
|
|
245
247
|
|
|
246
|
-
Chat Completions
|
|
248
|
+
Chat Completions 响应**不保证列出全过程**。应用可能在服务端跑完工具循环,只返回最终答案。所以 `turnFromChatCompletion` 不声明事件完整:`calledTool` 这类“调用过”的断言可用,`notCalledTool` 这类“没调用过”的断言会提示证据不完整。Responses 协议要求 `output` 数组列出全过程,`turnFromResponses` 声明事件完整,“没调用过”的断言可信。这个差别来自两种接口本身的约定。
|
|
247
249
|
|
|
248
|
-
**这一步支持**:`turn.calledTool()`、`turn.toolOrder()`、`turn.maxToolCalls()`、`turn.noFailedActions()` 等工具断言。需要跨 Turn
|
|
250
|
+
**这一步支持**:`turn.calledTool()`、`turn.toolOrder()`、`turn.maxToolCalls()`、`turn.noFailedActions()` 等工具断言。需要跨 Turn 排序时,把调用对象从 `turn` 换成 `session`。跑完用 `pnpm exec niceeval show @<locator> --execution` 看这个 Attempt 的工具调用。工具没出现时,先查接口返回里有没有工具字段、映射有没有漏掉它。
|
|
249
251
|
|
|
250
252
|
## 第五步:HITL
|
|
251
253
|
|
|
252
|
-
|
|
254
|
+
应用会中途停下来等人,例如等工具审批或等用户补充信息。要测这类流程,`send` 要在两种轮次里各做一件事:
|
|
253
255
|
|
|
254
|
-
-
|
|
255
|
-
-
|
|
256
|
+
- **等待的那一轮**:返回 `status: "waiting"`,并为每个待回答的问题返回一条带稳定 `id` 的 `input.requested` 事件。`t.check(turn.status, equals("waiting"))` 和 `t.requireInputRequest()` 读的就是它,回答也靠这个 `id` 对上问题。
|
|
257
|
+
- **回答的那一轮**:评估用例里的 `t.respond(...)` 到 Adapter 这边是**又一次普通的 `send`**,还在同一条会话线上,拿到同一份状态。回答随 `input.responses` 到达,每条带 `requestId`,以及 `optionId` 或 `text`(形态见[不同回答的入参](/zh/explanation/adapter#不同回答的入参))。Adapter 先把回答交给应用,再接着取结果。被拒绝的工具调用,`operation.finished` 的 `status` 写 `"rejected"`,不写 `"failed"`。拒绝是人的决定,不是工具故障,`noFailedActions()` 不会把它算成失败。
|
|
256
258
|
|
|
257
|
-
|
|
259
|
+
等待时还没读完的东西,例如一条读到一半的 SSE 流,也存在 `ctx.session` 上。Adapter 用 `createSessionSlot<Pending>()` 声明一份私有状态,等待时 `ctx.session.set(...)` 存进去,回答轮开头 `ctx.session.take(...)` 取回。取出后它就被清掉,只能取一次。
|
|
258
260
|
|
|
259
|
-
HITL
|
|
261
|
+
HITL 几乎总发生在流式接口上,应用停在流的中间。所以这一步的示例换成一个用 SSE 透传原生事件的应用,它同时用上前面几步的全部内容(完整可跑版本见 [tier1 示例](https://github.com/CorrectRoadH/niceeval/tree/main/examples/zh/tier1)):
|
|
260
262
|
|
|
261
263
|
```ts
|
|
262
264
|
// agents/my-app.ts
|
|
@@ -312,16 +314,15 @@ export default defineAgent({
|
|
|
312
314
|
});
|
|
313
315
|
```
|
|
314
316
|
|
|
315
|
-
不需要 HITL
|
|
317
|
+
不需要 HITL 的接口,删掉和等待相关的三处(`Pending`、`pendingSlot`、开头的 `take` 分支),其余不变。等待、回答、继续执行的完整流程见 [HITL](/zh/explanation/hitl)。
|
|
316
318
|
|
|
317
|
-
**这一步支持**:`t.check(turn.status, equals("waiting"))`、`t.requireInputRequest()`、`t.respond()` / `t.respondAll()
|
|
318
|
-
被人拒绝的调用可用 `calledTool(toolMatch(..., { status: "rejected" }))` 精确断言。
|
|
319
|
+
**这一步支持**:`t.check(turn.status, equals("waiting"))`、`t.requireInputRequest()`、`t.respond()` / `t.respondAll()`。被拒绝的调用可以用 `calledTool(toolMatch(..., { status: "rejected" }))` 精确断言。`t.requireInputRequest()` 找不到请求时,先查等待的那一轮是否同时返回了 `status: "waiting"` 和 `input.requested` 事件。
|
|
319
320
|
|
|
320
321
|
## 第六步:接上 OTel trace
|
|
321
322
|
|
|
322
|
-
|
|
323
|
+
想在浏览器里看每一轮的模型调用和工具耗时,而应用已经有 OTel 埋点(标准 OTel HTTP 服务端埋点就够),就把它的 trace 接进来。接入分两部分:一部分在应用启动时配置,一次配好不再变;另一部分在 `send` 里,每轮都不同。
|
|
323
324
|
|
|
324
|
-
|
|
325
|
+
**接收地址在应用启动时配置,不经过 `send`。** [NiceEval](https://niceeval.com/) 的 OTLP 接收地址每次运行都一样。在 `niceeval.config.ts` 里固定接收端口,应用启动时把 OTel exporter 指向这个地址,之后跑多少次评估用例都不用改:
|
|
325
326
|
|
|
326
327
|
```ts
|
|
327
328
|
// niceeval.config.ts
|
|
@@ -336,7 +337,7 @@ export default defineConfig({
|
|
|
336
337
|
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318/v1/traces node server.js
|
|
337
338
|
```
|
|
338
339
|
|
|
339
|
-
|
|
340
|
+
**`send` 里传的是这一轮的 trace context,不是接收地址。** `ctx.telemetry.headers` 是运行器每轮新生成的 W3C `traceparent` 头。把它展开进请求头,应用这一轮产生的 span 就会挂到这一轮名下,并发跑多条评估用例也不会混。回到本教程的 chat-app,`send` 里只多一行:
|
|
340
341
|
|
|
341
342
|
```ts
|
|
342
343
|
const res = await fetch(`${BASE_URL}/v1/chat/completions`, {
|
|
@@ -345,13 +346,13 @@ OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318/v1/traces node server.js
|
|
|
345
346
|
}).then((r) => r.json());
|
|
346
347
|
```
|
|
347
348
|
|
|
348
|
-
`ctx.telemetry` 只在配置了 OTel
|
|
349
|
+
`ctx.telemetry` 只在配置了 OTel 接入时才有值。没配置时展开 `undefined` 也安全,这一行可以一直留着。不带这个头也能收到 span,但 NiceEval 只能按发送前后的时间判断 span 属于哪一轮,这个 Agent 的轮次会改成逐个执行。带上它,并发运行时 span 才能准确对上轮次。
|
|
349
350
|
|
|
350
|
-
**这一步支持**:`niceeval view`
|
|
351
|
+
**这一步支持**:`niceeval view` 中按轮显示的调用瀑布图,包括模型调用、工具执行、耗时和 token。断言仍然读取前几步返回的事件,span 只用于瀑布图。瀑布图为空或缺尾巴时怎么查,见 [OTel 接入](/zh/tutorials/connect-otel)。
|
|
351
352
|
|
|
352
353
|
## 第七步:透传 experiment 的 flags(A/B 对比)
|
|
353
354
|
|
|
354
|
-
|
|
355
|
+
要比较两版 prompt 或两种策略,应用先把它们做成可以切换的配置。Experiment 声明 `flags`,运行器每轮通过 `ctx.flags` 原样交给 `send`。Adapter 不解释这些值,只随请求转发,由应用按参数切换:
|
|
355
356
|
|
|
356
357
|
```ts
|
|
357
358
|
// ……send 其余部分同前,省略
|
|
@@ -374,19 +375,19 @@ export default defineExperiment({
|
|
|
374
375
|
});
|
|
375
376
|
```
|
|
376
377
|
|
|
377
|
-
两个
|
|
378
|
+
两个 Experiment 文件各声明一份 `flags`,用 `pnpm exec niceeval exp` 分别跑同一批评估用例,就是一组 A/B 对比。这属于 Tier 3 接入,需要应用配合暴露开关,投入与回报见 [Tier](/zh/explanation/tier)。`flags` 和 `model`、`attempts` 等其余字段见[编写实验](/zh/tutorials/write-experiment)。
|
|
378
379
|
|
|
379
|
-
|
|
380
|
+
**这一步支持**:同一批评估用例在不同变体下的成绩对比。两边都跑完后,用 `pnpm exec niceeval show --experiment <id> --experiment <id>` 在终端对比,或用 `pnpm exec niceeval view` 在浏览器里看。两边成绩几乎一样时,先确认应用真的读了请求里的 `flags`。
|
|
380
381
|
|
|
381
382
|
## 对照:五个 t API 到 send 的形态
|
|
382
383
|
|
|
383
|
-
|
|
384
|
+
七步写完,再看评估用例里驱动对话的五个 API。它们到 Adapter 这边都是同一个 `send` 收到不同字段,不需要实现第二个方法:
|
|
384
385
|
|
|
385
386
|
| 评估用例 API | Adapter 调用 | `send` 输入 |
|
|
386
387
|
|---|---|---|
|
|
387
388
|
| `t.send(text)` | 一次 `send` | `input.text`。`ctx.session` 是这条会话线的自有状态 |
|
|
388
389
|
| `t.sendFile(path, text?)` | 一次 `send` | 同上,外加 `input.files`(base64 的 `InputFile[]`)。按应用接口的方式放进请求体,不支持多模态就忽略 |
|
|
389
|
-
| `t.newSession()` | 不直接触发 `send` |
|
|
390
|
+
| `t.newSession()` | 不直接触发 `send` | 开第二条会话线。这条线上的第一次 `send` 拿到**全空的**状态,和整个评估用例的第一次 `send` 一样 |
|
|
390
391
|
| `t.respond(...answers)` | 一次**普通的** `send` | `input.text` = 回答文本。`input.responses` 逐请求一条 `{ requestId, optionId }`(自由文本回答则是 `{ requestId, text }`)。还是同一条线、同一份状态 |
|
|
391
392
|
| `t.respondAll(optionId)` | 一次**普通的** `send` | 同上,每条待处理请求各一条回答。`optionId` 已在评估用例侧对每条请求校验过存在,写错直接抛,不会静默传给应用 |
|
|
392
393
|
|
|
@@ -394,6 +395,6 @@ export default defineExperiment({
|
|
|
394
395
|
|
|
395
396
|
- [Adapter](/zh/explanation/adapter) — `send` 的输入、输出、三个接入等级和能力来源。
|
|
396
397
|
- [接入你的 Agent](/zh/tutorials/connect-your-agent) — 最小接入、参数传递与可选能力。
|
|
397
|
-
- [HITL](/zh/explanation/hitl) —
|
|
398
|
+
- [HITL](/zh/explanation/hitl) — 应用停下等人时的完整流程,以及评估用例和 Adapter 各自要做什么。
|
|
398
399
|
- [Drive](/zh/explanation/drive) — 评估用例侧的 `t.send()`、`t.newSession()` 与 HITL 用法。
|
|
399
400
|
- [Assert](/zh/explanation/assert) — 标准事件流驱动的完整断言词汇。
|
|
@@ -56,16 +56,16 @@ changes:
|
|
|
56
56
|
`Infinity`, no limit is enforced. Must be a number greater than `0`.
|
|
57
57
|
**Default:** `Infinity`.
|
|
58
58
|
|
|
59
|
-
`Agent` inherits all {PoolOptions} (and therefore all {ClientOptions}).
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
instances on separate sockets.
|
|
59
|
+
`Agent` inherits all {PoolOptions} (and therefore all {ClientOptions}). Each
|
|
60
|
+
origin gets a separate {Pool}, with `connections` acting as the maximum number
|
|
61
|
+
of clients that pool may create.
|
|
63
62
|
|
|
64
63
|
> [!NOTE]
|
|
65
|
-
>
|
|
66
|
-
>
|
|
67
|
-
>
|
|
68
|
-
>
|
|
64
|
+
> For an h2-capable HTTPS origin, the per-origin pool waits for the first TLS
|
|
65
|
+
> connection to finish ALPN negotiation. If the server selects h2, concurrent
|
|
66
|
+
> requests share that session up to `maxConcurrentStreams`. If it selects
|
|
67
|
+
> HTTP/1.1, normal connection fan-out resumes up to `connections`. See
|
|
68
|
+
> {PoolOptions} and {ClientOptions} for inherited options such as `allowH2`
|
|
69
69
|
> (default `true`) and `maxConcurrentStreams` (default `100`).
|
|
70
70
|
|
|
71
71
|
### `agent.closed`
|
|
@@ -120,7 +120,8 @@ diagnosticsChannel.channel('undici:request:bodySent').subscribe(({ request }) =>
|
|
|
120
120
|
added: v6.3.0
|
|
121
121
|
-->
|
|
122
122
|
|
|
123
|
-
Published after the response headers have been received.
|
|
123
|
+
Published after the response headers have been received. This includes a
|
|
124
|
+
successful CONNECT or protocol upgrade response.
|
|
124
125
|
|
|
125
126
|
* `message` {Object}
|
|
126
127
|
* `request` {Object} The same object published by
|
|
@@ -128,8 +129,9 @@ Published after the response headers have been received.
|
|
|
128
129
|
* `response` {Object} The response being received.
|
|
129
130
|
* `statusCode` {number} The HTTP status code.
|
|
130
131
|
* `statusText` {string} The HTTP status message.
|
|
131
|
-
* `headers` {Buffer[]}
|
|
132
|
-
alternating between header name and value.
|
|
132
|
+
* `headers` {Buffer[]|Object} HTTP/1.1 response headers are an array of
|
|
133
|
+
buffers alternating between header name and value. HTTP/2 response
|
|
134
|
+
headers are an object.
|
|
133
135
|
|
|
134
136
|
```mjs
|
|
135
137
|
import diagnosticsChannel from 'node:diagnostics_channel'
|
|
@@ -137,7 +139,7 @@ import diagnosticsChannel from 'node:diagnostics_channel'
|
|
|
137
139
|
diagnosticsChannel.channel('undici:request:headers').subscribe(({ request, response }) => {
|
|
138
140
|
console.log('statusCode', response.statusCode)
|
|
139
141
|
console.log(response.statusText)
|
|
140
|
-
console.log(response.headers
|
|
142
|
+
console.log(response.headers)
|
|
141
143
|
})
|
|
142
144
|
```
|
|
143
145
|
|
|
@@ -168,8 +170,9 @@ diagnosticsChannel.channel('undici:request:bodyChunkReceived').subscribe(({ requ
|
|
|
168
170
|
added: v6.3.0
|
|
169
171
|
-->
|
|
170
172
|
|
|
171
|
-
Published
|
|
172
|
-
the
|
|
173
|
+
Published once the response has fully completed. After an upgraded socket has
|
|
174
|
+
been passed to the request handler, this event is published with an empty
|
|
175
|
+
`trailers` array.
|
|
173
176
|
|
|
174
177
|
* `message` {Object}
|
|
175
178
|
* `request` {Object} The same object published by
|
|
@@ -446,6 +446,31 @@ The response returned an error status code. This is raised, for example, when th
|
|
|
446
446
|
* `headers` {Object|string[]|null} The response headers. (optional)
|
|
447
447
|
* `body` {Object|string|null} The response body. (optional)
|
|
448
448
|
|
|
449
|
+
## Class: `ProxyConnectionError`
|
|
450
|
+
|
|
451
|
+
<!-- YAML
|
|
452
|
+
added: v8.10.1
|
|
453
|
+
changes:
|
|
454
|
+
- version: v8.10.1
|
|
455
|
+
pr-url: https://github.com/nodejs/undici/pull/5707
|
|
456
|
+
description: Added to fail the request instead of retrying forever when the proxy connection is torn down.
|
|
457
|
+
-->
|
|
458
|
+
|
|
459
|
+
* Extends: {UndiciError}
|
|
460
|
+
|
|
461
|
+
A connection to the proxy failed in a way that cannot be recovered on the
|
|
462
|
+
same connection, so the request fails instead of being retried.
|
|
463
|
+
|
|
464
|
+
* `name` {string} Always `'ProxyConnectionError'`.
|
|
465
|
+
* `code` {string} Always `'UND_ERR_PRX_CONN'`.
|
|
466
|
+
* `cause` {Error} The underlying error that caused the proxy connection to fail.
|
|
467
|
+
|
|
468
|
+
### `new ProxyConnectionError(cause[, message[, options]])`
|
|
469
|
+
|
|
470
|
+
* `cause` {Error} The underlying error. (optional)
|
|
471
|
+
* `message` {string} The error message. (optional)
|
|
472
|
+
* `options` {Object} Additional `Error` options merged with `cause`. (optional)
|
|
473
|
+
|
|
449
474
|
## Class: `SecureProxyConnectionError`
|
|
450
475
|
|
|
451
476
|
<!-- YAML
|
|
@@ -210,9 +210,10 @@ Automatically decompresses response bodies encoded with `gzip`, `x-gzip`,
|
|
|
210
210
|
skipped. **Default:** `[204, 304]`.
|
|
211
211
|
* `skipErrorResponses` {boolean} When `true`, responses with a status code
|
|
212
212
|
>= 400 are not decompressed. **Default:** `true`.
|
|
213
|
-
* `maxSize` {number} Maximum decompressed response size in bytes
|
|
214
|
-
|
|
215
|
-
this limit.
|
|
213
|
+
* `maxSize` {number} Maximum decompressed response size in bytes for each
|
|
214
|
+
decompression stage. The request fails with a
|
|
215
|
+
`ResponseExceededMaxSizeError` if a stage exceeds this limit. Set to `0` to
|
|
216
|
+
disable the limit. **Default:** `0`.
|
|
216
217
|
|
|
217
218
|
**Returns:** {Dispatcher.DispatcherComposeInterceptor}
|
|
218
219
|
|
|
@@ -73,12 +73,11 @@ connector shared by every pooled client.
|
|
|
73
73
|
|
|
74
74
|
> [!NOTE]
|
|
75
75
|
> `Pool` inherits all {ClientOptions}, including `allowH2` and
|
|
76
|
-
> `maxConcurrentStreams`.
|
|
77
|
-
>
|
|
78
|
-
>
|
|
79
|
-
>
|
|
80
|
-
>
|
|
81
|
-
> `maxConcurrentStreams`.
|
|
76
|
+
> `maxConcurrentStreams`. For an h2-capable HTTPS origin, the pool waits for
|
|
77
|
+
> the first TLS connection to finish ALPN negotiation before opening more
|
|
78
|
+
> clients. If the server selects h2, concurrent requests share that session up
|
|
79
|
+
> to `maxConcurrentStreams`. If it selects HTTP/1.1, the pool resumes normal
|
|
80
|
+
> connection fan-out up to `connections`.
|
|
82
81
|
|
|
83
82
|
```mjs
|
|
84
83
|
import { Pool } from 'undici'
|
|
@@ -5,7 +5,6 @@ const { addAbortListener } = require('node:events')
|
|
|
5
5
|
const { Readable } = require('node:stream')
|
|
6
6
|
const { RequestAbortedError, NotSupportedError, InvalidArgumentError, AbortError } = require('../core/errors')
|
|
7
7
|
const util = require('../core/util')
|
|
8
|
-
const { ReadableStreamFrom } = require('../core/util')
|
|
9
8
|
|
|
10
9
|
const kConsume = Symbol('kConsume')
|
|
11
10
|
const kReading = Symbol('kReading')
|
|
@@ -246,7 +245,7 @@ class BodyReadable extends Readable {
|
|
|
246
245
|
*/
|
|
247
246
|
get body () {
|
|
248
247
|
if (!this[kBody]) {
|
|
249
|
-
this[kBody] =
|
|
248
|
+
this[kBody] = ReadableStream.from(this)
|
|
250
249
|
if (this[kConsume]) {
|
|
251
250
|
// TODO: Is this the best way to force a lock?
|
|
252
251
|
this[kBody].getReader() // Ensure stream is locked.
|
|
@@ -368,10 +368,22 @@ class Request {
|
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
-
|
|
371
|
+
/**
|
|
372
|
+
* @param {number} statusCode
|
|
373
|
+
* @param {Buffer[]|string[]|import('../../types/header.d.ts').IncomingHttpHeaders} headers
|
|
374
|
+
* @param {import('node:stream').Duplex} socket
|
|
375
|
+
* @param {string} [statusText]
|
|
376
|
+
*/
|
|
377
|
+
onRequestUpgrade (statusCode, headers, socket, statusText = '') {
|
|
378
|
+
this.onFinally()
|
|
379
|
+
|
|
372
380
|
assert(!this.aborted)
|
|
373
381
|
assert(!this.completed)
|
|
374
382
|
|
|
383
|
+
if (channels.headers.hasSubscribers) {
|
|
384
|
+
channels.headers.publish({ request: this, response: { statusCode, headers, statusText } })
|
|
385
|
+
}
|
|
386
|
+
|
|
375
387
|
const controller = this[kController]
|
|
376
388
|
if (controller) {
|
|
377
389
|
controller.rawHeaders = headers
|
|
@@ -379,7 +391,16 @@ class Request {
|
|
|
379
391
|
|
|
380
392
|
const parsedHeaders = Array.isArray(headers) ? parseHeaders(headers) : headers
|
|
381
393
|
|
|
382
|
-
|
|
394
|
+
const result = this[kHandler].onRequestUpgrade?.(controller, statusCode, parsedHeaders, socket)
|
|
395
|
+
|
|
396
|
+
if (!this.aborted) {
|
|
397
|
+
this.completed = true
|
|
398
|
+
if (channels.trailers.hasSubscribers) {
|
|
399
|
+
channels.trailers.publish({ request: this, trailers: [] })
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
return result
|
|
383
404
|
}
|
|
384
405
|
|
|
385
406
|
onResponseEnd (trailers) {
|
|
@@ -644,44 +644,6 @@ function getSocketInfo (socket) {
|
|
|
644
644
|
}
|
|
645
645
|
}
|
|
646
646
|
|
|
647
|
-
/**
|
|
648
|
-
* @param {Iterable} iterable
|
|
649
|
-
* @returns {ReadableStream}
|
|
650
|
-
*/
|
|
651
|
-
function ReadableStreamFrom (iterable) {
|
|
652
|
-
// We cannot use ReadableStream.from here because it does not return a byte stream.
|
|
653
|
-
|
|
654
|
-
let iterator
|
|
655
|
-
return new ReadableStream(
|
|
656
|
-
{
|
|
657
|
-
start () {
|
|
658
|
-
iterator = iterable[Symbol.asyncIterator]()
|
|
659
|
-
},
|
|
660
|
-
pull (controller) {
|
|
661
|
-
return iterator.next().then(({ done, value }) => {
|
|
662
|
-
if (done) {
|
|
663
|
-
return queueMicrotask(() => {
|
|
664
|
-
controller.close()
|
|
665
|
-
controller.byobRequest?.respond(0)
|
|
666
|
-
})
|
|
667
|
-
} else {
|
|
668
|
-
const buf = Buffer.isBuffer(value) ? value : Buffer.from(value)
|
|
669
|
-
if (buf.byteLength) {
|
|
670
|
-
return controller.enqueue(new Uint8Array(buf))
|
|
671
|
-
} else {
|
|
672
|
-
return this.pull(controller)
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
})
|
|
676
|
-
},
|
|
677
|
-
cancel () {
|
|
678
|
-
return iterator.return()
|
|
679
|
-
},
|
|
680
|
-
type: 'bytes'
|
|
681
|
-
}
|
|
682
|
-
)
|
|
683
|
-
}
|
|
684
|
-
|
|
685
647
|
/**
|
|
686
648
|
* The object should be a FormData instance and contains all the required
|
|
687
649
|
* methods.
|
|
@@ -1026,7 +988,6 @@ module.exports = {
|
|
|
1026
988
|
destroy,
|
|
1027
989
|
bodyLength,
|
|
1028
990
|
deepClone,
|
|
1029
|
-
ReadableStreamFrom,
|
|
1030
991
|
isBuffer,
|
|
1031
992
|
assertRequestHandler,
|
|
1032
993
|
getSocketInfo,
|
|
@@ -70,8 +70,14 @@ function lazyllhttp () {
|
|
|
70
70
|
|
|
71
71
|
let mod
|
|
72
72
|
|
|
73
|
-
// We disable wasm SIMD on
|
|
74
|
-
let useWasmSIMD =
|
|
73
|
+
// We disable wasm SIMD on older versions of Node.js on ppc64 that are broken on Power >=9 architectures.
|
|
74
|
+
let useWasmSIMD = true
|
|
75
|
+
if (process.arch === 'ppc64') {
|
|
76
|
+
const [major, minor] = process.versions.node.split('.').map(n => parseInt(n, 10))
|
|
77
|
+
if (major < 24 || (major === 24 && minor < 12)) {
|
|
78
|
+
useWasmSIMD = false
|
|
79
|
+
}
|
|
80
|
+
}
|
|
75
81
|
// The Env Variable UNDICI_NO_WASM_SIMD allows explicitly overriding the default behavior
|
|
76
82
|
if (process.env.UNDICI_NO_WASM_SIMD === '1') {
|
|
77
83
|
useWasmSIMD = false
|
|
@@ -561,7 +567,7 @@ class Parser {
|
|
|
561
567
|
* @param {Buffer} head
|
|
562
568
|
*/
|
|
563
569
|
onUpgrade (head) {
|
|
564
|
-
const { upgrade, client, socket, headers, statusCode } = this
|
|
570
|
+
const { upgrade, client, socket, headers, statusCode, statusText } = this
|
|
565
571
|
|
|
566
572
|
assert(upgrade)
|
|
567
573
|
assert(client[kSocket] === socket)
|
|
@@ -596,8 +602,9 @@ class Parser {
|
|
|
596
602
|
client.emit('disconnect', client[kUrl], [client], new InformationalError('upgrade'))
|
|
597
603
|
|
|
598
604
|
try {
|
|
599
|
-
request.onRequestUpgrade(statusCode, headers, socket)
|
|
605
|
+
request.onRequestUpgrade(statusCode, headers, socket, statusText)
|
|
600
606
|
} catch (err) {
|
|
607
|
+
util.errorRequest(client, request, err)
|
|
601
608
|
util.destroy(socket, err)
|
|
602
609
|
}
|
|
603
610
|
|