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
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { ReadableAdapterUsageAttachment, AdapterUsageCall, AdapterCallPriceReceipt } from "../record/family/adapter-usage/schema.cjs";
|
|
2
|
+
import type { NumericMaterial } from "../assertions/match.cjs";
|
|
3
|
+
import type { ResolvedModelSlots } from "../model-slots.cjs";
|
|
4
|
+
export interface EffectiveCallCost {
|
|
5
|
+
readonly amount: string;
|
|
6
|
+
readonly currency: string;
|
|
7
|
+
readonly source: {
|
|
8
|
+
readonly kind: "reported" | "estimated";
|
|
9
|
+
readonly id: string;
|
|
10
|
+
};
|
|
11
|
+
readonly state: "complete" | "partial";
|
|
12
|
+
}
|
|
13
|
+
export type EffectiveUsageCall = AdapterUsageCall & {
|
|
14
|
+
readonly effectiveCost: EffectiveCallCost | null;
|
|
15
|
+
};
|
|
16
|
+
export declare function effectiveUsageCalls(usage: ReadableAdapterUsageAttachment): readonly EffectiveUsageCall[];
|
|
17
|
+
export declare function effectiveCostTotals(calls: readonly {
|
|
18
|
+
readonly effectiveCost: EffectiveCallCost | null;
|
|
19
|
+
}[], collectionState: "complete" | "partial"): Readonly<{
|
|
20
|
+
state: "complete" | "partial" | "unavailable";
|
|
21
|
+
source: "reported" | "estimated" | "mixed" | null;
|
|
22
|
+
values: readonly Readonly<{
|
|
23
|
+
currency: string;
|
|
24
|
+
value: string;
|
|
25
|
+
source: "reported" | "estimated" | "mixed";
|
|
26
|
+
coveredCalls: number;
|
|
27
|
+
reportedCalls: number;
|
|
28
|
+
estimatedCalls: number;
|
|
29
|
+
}>[];
|
|
30
|
+
totalCalls: number;
|
|
31
|
+
}>;
|
|
32
|
+
export declare function adapterTokenMaterial(usage: ReadableAdapterUsageAttachment, metric: "inputTokens" | "inputTotalTokens" | "outputTokens" | "cacheReadTokens" | "cacheWriteTokens" | "totalTokens"): NumericMaterial;
|
|
33
|
+
export declare function adapterInspectionTokenTotal(usage: ReadableAdapterUsageAttachment, metric: "inputTotalTokens" | "outputTokens" | "totalTokens"): Readonly<{
|
|
34
|
+
state: "partial" | "available" | "unavailable";
|
|
35
|
+
value: number | null;
|
|
36
|
+
observationCount: number;
|
|
37
|
+
}>;
|
|
38
|
+
/** Tuple order is stable across hosts, with missing identities before strings. */
|
|
39
|
+
export declare function compareAdapterModelGroups(left: Pick<AdapterUsageCall, "modelSlot" | "provider" | "model">, right: Pick<AdapterUsageCall, "modelSlot" | "provider" | "model">): number;
|
|
40
|
+
/** Configuration counts and grouped statistics both consume the complete sealed ledger. */
|
|
41
|
+
export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAttachment | null, models: ResolvedModelSlots | undefined, unavailable?: {
|
|
42
|
+
readonly basis: "recorded-calls" | "reported-sends" | "unavailable";
|
|
43
|
+
readonly reason: "source-invalid" | "usage-not-recorded" | "physical-call-identity-not-recorded";
|
|
44
|
+
}): Readonly<{
|
|
45
|
+
configuredModels: Readonly<{
|
|
46
|
+
state: "not-recorded";
|
|
47
|
+
}> | Readonly<{
|
|
48
|
+
state: "available";
|
|
49
|
+
bindings: readonly Readonly<{
|
|
50
|
+
recordedCalls: number | null;
|
|
51
|
+
model: string | null;
|
|
52
|
+
reasoningEffort: string | null;
|
|
53
|
+
modelSlot: string;
|
|
54
|
+
}>[];
|
|
55
|
+
}>;
|
|
56
|
+
modelGroups: Readonly<{
|
|
57
|
+
groups: readonly [];
|
|
58
|
+
totalGroupCount: null;
|
|
59
|
+
groupsTruncated: false;
|
|
60
|
+
omittedGroupCount: 0;
|
|
61
|
+
basis: "recorded-calls" | "reported-sends" | "unavailable";
|
|
62
|
+
reason: "source-invalid" | "usage-not-recorded" | "physical-call-identity-not-recorded";
|
|
63
|
+
state: "unavailable";
|
|
64
|
+
}>;
|
|
65
|
+
}> | Readonly<{
|
|
66
|
+
configuredModels: Readonly<{
|
|
67
|
+
state: "not-recorded";
|
|
68
|
+
}> | Readonly<{
|
|
69
|
+
state: "available";
|
|
70
|
+
bindings: readonly Readonly<{
|
|
71
|
+
recordedCalls: number | null;
|
|
72
|
+
model: string | null;
|
|
73
|
+
reasoningEffort: string | null;
|
|
74
|
+
modelSlot: string;
|
|
75
|
+
}>[];
|
|
76
|
+
}>;
|
|
77
|
+
modelGroups: Readonly<{
|
|
78
|
+
state: "available";
|
|
79
|
+
basis: "recorded-calls";
|
|
80
|
+
groups: readonly Readonly<{
|
|
81
|
+
modelSlot: string | null;
|
|
82
|
+
provider: string | null;
|
|
83
|
+
model: string | null;
|
|
84
|
+
recordedCalls: number;
|
|
85
|
+
tokens: Readonly<{
|
|
86
|
+
inputTotalTokens: Readonly<{
|
|
87
|
+
state: "partial" | "available" | "unavailable";
|
|
88
|
+
value: number | null;
|
|
89
|
+
observationCount: number;
|
|
90
|
+
}>;
|
|
91
|
+
outputTokens: Readonly<{
|
|
92
|
+
state: "partial" | "available" | "unavailable";
|
|
93
|
+
value: number | null;
|
|
94
|
+
observationCount: number;
|
|
95
|
+
}>;
|
|
96
|
+
totalTokens: Readonly<{
|
|
97
|
+
state: "partial" | "available" | "unavailable";
|
|
98
|
+
value: number | null;
|
|
99
|
+
observationCount: number;
|
|
100
|
+
}>;
|
|
101
|
+
}>;
|
|
102
|
+
costs: Readonly<{
|
|
103
|
+
state: "complete" | "partial" | "unavailable";
|
|
104
|
+
source: "reported" | "estimated" | "mixed" | null;
|
|
105
|
+
values: readonly Readonly<{
|
|
106
|
+
currency: string;
|
|
107
|
+
value: string;
|
|
108
|
+
source: "reported" | "estimated" | "mixed";
|
|
109
|
+
coveredCalls: number;
|
|
110
|
+
reportedCalls: number;
|
|
111
|
+
estimatedCalls: number;
|
|
112
|
+
}>[];
|
|
113
|
+
totalCalls: number;
|
|
114
|
+
}>;
|
|
115
|
+
}>[];
|
|
116
|
+
totalGroupCount: number;
|
|
117
|
+
groupsTruncated: boolean;
|
|
118
|
+
omittedGroupCount: number;
|
|
119
|
+
}>;
|
|
120
|
+
}>;
|
|
121
|
+
export interface AdapterAttemptUsageSnapshot {
|
|
122
|
+
readonly source: "adapter";
|
|
123
|
+
readonly scope: "recorded-calls";
|
|
124
|
+
readonly cut: "call-time";
|
|
125
|
+
readonly collection: ReadableAdapterUsageAttachment["collection"];
|
|
126
|
+
readonly calls: readonly EffectiveUsageCall[];
|
|
127
|
+
readonly priceReceipts: readonly AdapterCallPriceReceipt[];
|
|
128
|
+
readonly inputTokens: NumericMaterial;
|
|
129
|
+
readonly inputTotalTokens: NumericMaterial;
|
|
130
|
+
readonly outputTokens: NumericMaterial;
|
|
131
|
+
readonly cacheReadTokens: NumericMaterial;
|
|
132
|
+
readonly cacheWriteTokens: NumericMaterial;
|
|
133
|
+
readonly totalTokens: NumericMaterial;
|
|
134
|
+
readonly costs: ReturnType<typeof effectiveCostTotals>;
|
|
135
|
+
}
|
|
136
|
+
export type AttemptUsageSnapshot = AdapterAttemptUsageSnapshot | {
|
|
137
|
+
readonly source: "unavailable";
|
|
138
|
+
readonly reason: "usage-owner-not-bound";
|
|
139
|
+
};
|
|
140
|
+
export declare function projectAdapterUsageSnapshot(usage: ReadableAdapterUsageAttachment): AdapterAttemptUsageSnapshot;
|
|
141
|
+
export declare function compareCanonicalDecimal(left: string, right: string): -1 | 0 | 1;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { ReadableAdapterUsageAttachment, AdapterUsageCall, AdapterCallPriceReceipt } from "../record/family/adapter-usage/schema.mjs";
|
|
2
|
+
import type { NumericMaterial } from "../assertions/match.mjs";
|
|
3
|
+
import type { ResolvedModelSlots } from "../model-slots.mjs";
|
|
4
|
+
export interface EffectiveCallCost {
|
|
5
|
+
readonly amount: string;
|
|
6
|
+
readonly currency: string;
|
|
7
|
+
readonly source: {
|
|
8
|
+
readonly kind: "reported" | "estimated";
|
|
9
|
+
readonly id: string;
|
|
10
|
+
};
|
|
11
|
+
readonly state: "complete" | "partial";
|
|
12
|
+
}
|
|
13
|
+
export type EffectiveUsageCall = AdapterUsageCall & {
|
|
14
|
+
readonly effectiveCost: EffectiveCallCost | null;
|
|
15
|
+
};
|
|
16
|
+
export declare function effectiveUsageCalls(usage: ReadableAdapterUsageAttachment): readonly EffectiveUsageCall[];
|
|
17
|
+
export declare function effectiveCostTotals(calls: readonly {
|
|
18
|
+
readonly effectiveCost: EffectiveCallCost | null;
|
|
19
|
+
}[], collectionState: "complete" | "partial"): Readonly<{
|
|
20
|
+
state: "complete" | "partial" | "unavailable";
|
|
21
|
+
source: "reported" | "estimated" | "mixed" | null;
|
|
22
|
+
values: readonly Readonly<{
|
|
23
|
+
currency: string;
|
|
24
|
+
value: string;
|
|
25
|
+
source: "reported" | "estimated" | "mixed";
|
|
26
|
+
coveredCalls: number;
|
|
27
|
+
reportedCalls: number;
|
|
28
|
+
estimatedCalls: number;
|
|
29
|
+
}>[];
|
|
30
|
+
totalCalls: number;
|
|
31
|
+
}>;
|
|
32
|
+
export declare function adapterTokenMaterial(usage: ReadableAdapterUsageAttachment, metric: "inputTokens" | "inputTotalTokens" | "outputTokens" | "cacheReadTokens" | "cacheWriteTokens" | "totalTokens"): NumericMaterial;
|
|
33
|
+
export declare function adapterInspectionTokenTotal(usage: ReadableAdapterUsageAttachment, metric: "inputTotalTokens" | "outputTokens" | "totalTokens"): Readonly<{
|
|
34
|
+
state: "partial" | "available" | "unavailable";
|
|
35
|
+
value: number | null;
|
|
36
|
+
observationCount: number;
|
|
37
|
+
}>;
|
|
38
|
+
/** Tuple order is stable across hosts, with missing identities before strings. */
|
|
39
|
+
export declare function compareAdapterModelGroups(left: Pick<AdapterUsageCall, "modelSlot" | "provider" | "model">, right: Pick<AdapterUsageCall, "modelSlot" | "provider" | "model">): number;
|
|
40
|
+
/** Configuration counts and grouped statistics both consume the complete sealed ledger. */
|
|
41
|
+
export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAttachment | null, models: ResolvedModelSlots | undefined, unavailable?: {
|
|
42
|
+
readonly basis: "recorded-calls" | "reported-sends" | "unavailable";
|
|
43
|
+
readonly reason: "source-invalid" | "usage-not-recorded" | "physical-call-identity-not-recorded";
|
|
44
|
+
}): Readonly<{
|
|
45
|
+
configuredModels: Readonly<{
|
|
46
|
+
state: "not-recorded";
|
|
47
|
+
}> | Readonly<{
|
|
48
|
+
state: "available";
|
|
49
|
+
bindings: readonly Readonly<{
|
|
50
|
+
recordedCalls: number | null;
|
|
51
|
+
model: string | null;
|
|
52
|
+
reasoningEffort: string | null;
|
|
53
|
+
modelSlot: string;
|
|
54
|
+
}>[];
|
|
55
|
+
}>;
|
|
56
|
+
modelGroups: Readonly<{
|
|
57
|
+
groups: readonly [];
|
|
58
|
+
totalGroupCount: null;
|
|
59
|
+
groupsTruncated: false;
|
|
60
|
+
omittedGroupCount: 0;
|
|
61
|
+
basis: "recorded-calls" | "reported-sends" | "unavailable";
|
|
62
|
+
reason: "source-invalid" | "usage-not-recorded" | "physical-call-identity-not-recorded";
|
|
63
|
+
state: "unavailable";
|
|
64
|
+
}>;
|
|
65
|
+
}> | Readonly<{
|
|
66
|
+
configuredModels: Readonly<{
|
|
67
|
+
state: "not-recorded";
|
|
68
|
+
}> | Readonly<{
|
|
69
|
+
state: "available";
|
|
70
|
+
bindings: readonly Readonly<{
|
|
71
|
+
recordedCalls: number | null;
|
|
72
|
+
model: string | null;
|
|
73
|
+
reasoningEffort: string | null;
|
|
74
|
+
modelSlot: string;
|
|
75
|
+
}>[];
|
|
76
|
+
}>;
|
|
77
|
+
modelGroups: Readonly<{
|
|
78
|
+
state: "available";
|
|
79
|
+
basis: "recorded-calls";
|
|
80
|
+
groups: readonly Readonly<{
|
|
81
|
+
modelSlot: string | null;
|
|
82
|
+
provider: string | null;
|
|
83
|
+
model: string | null;
|
|
84
|
+
recordedCalls: number;
|
|
85
|
+
tokens: Readonly<{
|
|
86
|
+
inputTotalTokens: Readonly<{
|
|
87
|
+
state: "partial" | "available" | "unavailable";
|
|
88
|
+
value: number | null;
|
|
89
|
+
observationCount: number;
|
|
90
|
+
}>;
|
|
91
|
+
outputTokens: Readonly<{
|
|
92
|
+
state: "partial" | "available" | "unavailable";
|
|
93
|
+
value: number | null;
|
|
94
|
+
observationCount: number;
|
|
95
|
+
}>;
|
|
96
|
+
totalTokens: Readonly<{
|
|
97
|
+
state: "partial" | "available" | "unavailable";
|
|
98
|
+
value: number | null;
|
|
99
|
+
observationCount: number;
|
|
100
|
+
}>;
|
|
101
|
+
}>;
|
|
102
|
+
costs: Readonly<{
|
|
103
|
+
state: "complete" | "partial" | "unavailable";
|
|
104
|
+
source: "reported" | "estimated" | "mixed" | null;
|
|
105
|
+
values: readonly Readonly<{
|
|
106
|
+
currency: string;
|
|
107
|
+
value: string;
|
|
108
|
+
source: "reported" | "estimated" | "mixed";
|
|
109
|
+
coveredCalls: number;
|
|
110
|
+
reportedCalls: number;
|
|
111
|
+
estimatedCalls: number;
|
|
112
|
+
}>[];
|
|
113
|
+
totalCalls: number;
|
|
114
|
+
}>;
|
|
115
|
+
}>[];
|
|
116
|
+
totalGroupCount: number;
|
|
117
|
+
groupsTruncated: boolean;
|
|
118
|
+
omittedGroupCount: number;
|
|
119
|
+
}>;
|
|
120
|
+
}>;
|
|
121
|
+
export interface AdapterAttemptUsageSnapshot {
|
|
122
|
+
readonly source: "adapter";
|
|
123
|
+
readonly scope: "recorded-calls";
|
|
124
|
+
readonly cut: "call-time";
|
|
125
|
+
readonly collection: ReadableAdapterUsageAttachment["collection"];
|
|
126
|
+
readonly calls: readonly EffectiveUsageCall[];
|
|
127
|
+
readonly priceReceipts: readonly AdapterCallPriceReceipt[];
|
|
128
|
+
readonly inputTokens: NumericMaterial;
|
|
129
|
+
readonly inputTotalTokens: NumericMaterial;
|
|
130
|
+
readonly outputTokens: NumericMaterial;
|
|
131
|
+
readonly cacheReadTokens: NumericMaterial;
|
|
132
|
+
readonly cacheWriteTokens: NumericMaterial;
|
|
133
|
+
readonly totalTokens: NumericMaterial;
|
|
134
|
+
readonly costs: ReturnType<typeof effectiveCostTotals>;
|
|
135
|
+
}
|
|
136
|
+
export type AttemptUsageSnapshot = AdapterAttemptUsageSnapshot | {
|
|
137
|
+
readonly source: "unavailable";
|
|
138
|
+
readonly reason: "usage-owner-not-bound";
|
|
139
|
+
};
|
|
140
|
+
export declare function projectAdapterUsageSnapshot(usage: ReadableAdapterUsageAttachment): AdapterAttemptUsageSnapshot;
|
|
141
|
+
export declare function compareCanonicalDecimal(left: string, right: string): -1 | 0 | 1;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { ReadableAdapterUsageAttachment, AdapterUsageCall, AdapterCallPriceReceipt } from "../record/family/adapter-usage/schema.js";
|
|
2
|
+
import type { NumericMaterial } from "../assertions/match.js";
|
|
3
|
+
import type { ResolvedModelSlots } from "../model-slots.js";
|
|
4
|
+
export interface EffectiveCallCost {
|
|
5
|
+
readonly amount: string;
|
|
6
|
+
readonly currency: string;
|
|
7
|
+
readonly source: {
|
|
8
|
+
readonly kind: "reported" | "estimated";
|
|
9
|
+
readonly id: string;
|
|
10
|
+
};
|
|
11
|
+
readonly state: "complete" | "partial";
|
|
12
|
+
}
|
|
13
|
+
export type EffectiveUsageCall = AdapterUsageCall & {
|
|
14
|
+
readonly effectiveCost: EffectiveCallCost | null;
|
|
15
|
+
};
|
|
16
|
+
export declare function effectiveUsageCalls(usage: ReadableAdapterUsageAttachment): readonly EffectiveUsageCall[];
|
|
17
|
+
export declare function effectiveCostTotals(calls: readonly {
|
|
18
|
+
readonly effectiveCost: EffectiveCallCost | null;
|
|
19
|
+
}[], collectionState: "complete" | "partial"): Readonly<{
|
|
20
|
+
state: "complete" | "partial" | "unavailable";
|
|
21
|
+
source: "reported" | "estimated" | "mixed" | null;
|
|
22
|
+
values: readonly Readonly<{
|
|
23
|
+
currency: string;
|
|
24
|
+
value: string;
|
|
25
|
+
source: "reported" | "estimated" | "mixed";
|
|
26
|
+
coveredCalls: number;
|
|
27
|
+
reportedCalls: number;
|
|
28
|
+
estimatedCalls: number;
|
|
29
|
+
}>[];
|
|
30
|
+
totalCalls: number;
|
|
31
|
+
}>;
|
|
32
|
+
export declare function adapterTokenMaterial(usage: ReadableAdapterUsageAttachment, metric: "inputTokens" | "inputTotalTokens" | "outputTokens" | "cacheReadTokens" | "cacheWriteTokens" | "totalTokens"): NumericMaterial;
|
|
33
|
+
export declare function adapterInspectionTokenTotal(usage: ReadableAdapterUsageAttachment, metric: "inputTotalTokens" | "outputTokens" | "totalTokens"): Readonly<{
|
|
34
|
+
state: "partial" | "available" | "unavailable";
|
|
35
|
+
value: number | null;
|
|
36
|
+
observationCount: number;
|
|
37
|
+
}>;
|
|
38
|
+
/** Tuple order is stable across hosts, with missing identities before strings. */
|
|
39
|
+
export declare function compareAdapterModelGroups(left: Pick<AdapterUsageCall, "modelSlot" | "provider" | "model">, right: Pick<AdapterUsageCall, "modelSlot" | "provider" | "model">): number;
|
|
40
|
+
/** Configuration counts and grouped statistics both consume the complete sealed ledger. */
|
|
41
|
+
export declare function projectAdapterModelUsage(usage: ReadableAdapterUsageAttachment | null, models: ResolvedModelSlots | undefined, unavailable?: {
|
|
42
|
+
readonly basis: "recorded-calls" | "reported-sends" | "unavailable";
|
|
43
|
+
readonly reason: "source-invalid" | "usage-not-recorded" | "physical-call-identity-not-recorded";
|
|
44
|
+
}): Readonly<{
|
|
45
|
+
configuredModels: Readonly<{
|
|
46
|
+
state: "not-recorded";
|
|
47
|
+
}> | Readonly<{
|
|
48
|
+
state: "available";
|
|
49
|
+
bindings: readonly Readonly<{
|
|
50
|
+
recordedCalls: number | null;
|
|
51
|
+
model: string | null;
|
|
52
|
+
reasoningEffort: string | null;
|
|
53
|
+
modelSlot: string;
|
|
54
|
+
}>[];
|
|
55
|
+
}>;
|
|
56
|
+
modelGroups: Readonly<{
|
|
57
|
+
groups: readonly [];
|
|
58
|
+
totalGroupCount: null;
|
|
59
|
+
groupsTruncated: false;
|
|
60
|
+
omittedGroupCount: 0;
|
|
61
|
+
basis: "recorded-calls" | "reported-sends" | "unavailable";
|
|
62
|
+
reason: "source-invalid" | "usage-not-recorded" | "physical-call-identity-not-recorded";
|
|
63
|
+
state: "unavailable";
|
|
64
|
+
}>;
|
|
65
|
+
}> | Readonly<{
|
|
66
|
+
configuredModels: Readonly<{
|
|
67
|
+
state: "not-recorded";
|
|
68
|
+
}> | Readonly<{
|
|
69
|
+
state: "available";
|
|
70
|
+
bindings: readonly Readonly<{
|
|
71
|
+
recordedCalls: number | null;
|
|
72
|
+
model: string | null;
|
|
73
|
+
reasoningEffort: string | null;
|
|
74
|
+
modelSlot: string;
|
|
75
|
+
}>[];
|
|
76
|
+
}>;
|
|
77
|
+
modelGroups: Readonly<{
|
|
78
|
+
state: "available";
|
|
79
|
+
basis: "recorded-calls";
|
|
80
|
+
groups: readonly Readonly<{
|
|
81
|
+
modelSlot: string | null;
|
|
82
|
+
provider: string | null;
|
|
83
|
+
model: string | null;
|
|
84
|
+
recordedCalls: number;
|
|
85
|
+
tokens: Readonly<{
|
|
86
|
+
inputTotalTokens: Readonly<{
|
|
87
|
+
state: "partial" | "available" | "unavailable";
|
|
88
|
+
value: number | null;
|
|
89
|
+
observationCount: number;
|
|
90
|
+
}>;
|
|
91
|
+
outputTokens: Readonly<{
|
|
92
|
+
state: "partial" | "available" | "unavailable";
|
|
93
|
+
value: number | null;
|
|
94
|
+
observationCount: number;
|
|
95
|
+
}>;
|
|
96
|
+
totalTokens: Readonly<{
|
|
97
|
+
state: "partial" | "available" | "unavailable";
|
|
98
|
+
value: number | null;
|
|
99
|
+
observationCount: number;
|
|
100
|
+
}>;
|
|
101
|
+
}>;
|
|
102
|
+
costs: Readonly<{
|
|
103
|
+
state: "complete" | "partial" | "unavailable";
|
|
104
|
+
source: "reported" | "estimated" | "mixed" | null;
|
|
105
|
+
values: readonly Readonly<{
|
|
106
|
+
currency: string;
|
|
107
|
+
value: string;
|
|
108
|
+
source: "reported" | "estimated" | "mixed";
|
|
109
|
+
coveredCalls: number;
|
|
110
|
+
reportedCalls: number;
|
|
111
|
+
estimatedCalls: number;
|
|
112
|
+
}>[];
|
|
113
|
+
totalCalls: number;
|
|
114
|
+
}>;
|
|
115
|
+
}>[];
|
|
116
|
+
totalGroupCount: number;
|
|
117
|
+
groupsTruncated: boolean;
|
|
118
|
+
omittedGroupCount: number;
|
|
119
|
+
}>;
|
|
120
|
+
}>;
|
|
121
|
+
export interface AdapterAttemptUsageSnapshot {
|
|
122
|
+
readonly source: "adapter";
|
|
123
|
+
readonly scope: "recorded-calls";
|
|
124
|
+
readonly cut: "call-time";
|
|
125
|
+
readonly collection: ReadableAdapterUsageAttachment["collection"];
|
|
126
|
+
readonly calls: readonly EffectiveUsageCall[];
|
|
127
|
+
readonly priceReceipts: readonly AdapterCallPriceReceipt[];
|
|
128
|
+
readonly inputTokens: NumericMaterial;
|
|
129
|
+
readonly inputTotalTokens: NumericMaterial;
|
|
130
|
+
readonly outputTokens: NumericMaterial;
|
|
131
|
+
readonly cacheReadTokens: NumericMaterial;
|
|
132
|
+
readonly cacheWriteTokens: NumericMaterial;
|
|
133
|
+
readonly totalTokens: NumericMaterial;
|
|
134
|
+
readonly costs: ReturnType<typeof effectiveCostTotals>;
|
|
135
|
+
}
|
|
136
|
+
export type AttemptUsageSnapshot = AdapterAttemptUsageSnapshot | {
|
|
137
|
+
readonly source: "unavailable";
|
|
138
|
+
readonly reason: "usage-owner-not-bound";
|
|
139
|
+
};
|
|
140
|
+
export declare function projectAdapterUsageSnapshot(usage: ReadableAdapterUsageAttachment): AdapterAttemptUsageSnapshot;
|
|
141
|
+
export declare function compareCanonicalDecimal(left: string, right: string): -1 | 0 | 1;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createRequire as __niceevalCreateRequire } from "node:module";
|
|
2
|
+
const __niceevalRequire = __niceevalCreateRequire(import.meta.url);
|
|
3
|
+
const __niceevalCanonical = __niceevalRequire("./adapter-usage-projection.cjs");
|
|
4
|
+
const __niceevalExport0 = __niceevalCanonical["adapterInspectionTokenTotal"];
|
|
5
|
+
export { __niceevalExport0 as adapterInspectionTokenTotal };
|
|
6
|
+
const __niceevalExport1 = __niceevalCanonical["adapterTokenMaterial"];
|
|
7
|
+
export { __niceevalExport1 as adapterTokenMaterial };
|
|
8
|
+
const __niceevalExport2 = __niceevalCanonical["compareAdapterModelGroups"];
|
|
9
|
+
export { __niceevalExport2 as compareAdapterModelGroups };
|
|
10
|
+
const __niceevalExport3 = __niceevalCanonical["compareCanonicalDecimal"];
|
|
11
|
+
export { __niceevalExport3 as compareCanonicalDecimal };
|
|
12
|
+
const __niceevalExport4 = __niceevalCanonical["effectiveCostTotals"];
|
|
13
|
+
export { __niceevalExport4 as effectiveCostTotals };
|
|
14
|
+
const __niceevalExport5 = __niceevalCanonical["effectiveUsageCalls"];
|
|
15
|
+
export { __niceevalExport5 as effectiveUsageCalls };
|
|
16
|
+
const __niceevalExport6 = __niceevalCanonical["projectAdapterModelUsage"];
|
|
17
|
+
export { __niceevalExport6 as projectAdapterModelUsage };
|
|
18
|
+
const __niceevalExport7 = __niceevalCanonical["projectAdapterUsageSnapshot"];
|
|
19
|
+
export { __niceevalExport7 as projectAdapterUsageSnapshot };
|
|
20
|
+
//# sourceMappingURL=adapter-usage-projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter-usage-projection.js","sources":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.projectAdapterEvalUsage = projectAdapterEvalUsage;
|
|
4
|
+
exports.projectAgentEvalUsage = projectAgentEvalUsage;
|
|
5
|
+
const pricing_ts_1 = require("../record/family/adapter-usage/pricing.cjs");
|
|
6
|
+
const adapter_usage_projection_ts_1 = require("./adapter-usage-projection.cjs");
|
|
7
|
+
function contributionCosts(calls, complete) {
|
|
8
|
+
const totals = (0, adapter_usage_projection_ts_1.effectiveCostTotals)(calls, complete ? "complete" : "partial");
|
|
9
|
+
return Object.freeze({
|
|
10
|
+
state: totals.state,
|
|
11
|
+
values: Object.freeze(totals.values.map((value) => Object.freeze({
|
|
12
|
+
currency: value.currency,
|
|
13
|
+
value: value.value,
|
|
14
|
+
source: value.source,
|
|
15
|
+
coveredContributions: value.coveredCalls,
|
|
16
|
+
reportedContributions: value.reportedCalls,
|
|
17
|
+
estimatedContributions: value.estimatedCalls,
|
|
18
|
+
}))),
|
|
19
|
+
totalContributions: totals.totalCalls,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function projectAdapterEvalUsage(usage) {
|
|
23
|
+
return Object.freeze({
|
|
24
|
+
source: "adapter",
|
|
25
|
+
scope: "attempt",
|
|
26
|
+
basis: "recorded-calls",
|
|
27
|
+
cut: "call-time",
|
|
28
|
+
inputTokens: (0, adapter_usage_projection_ts_1.adapterTokenMaterial)(usage, "inputTokens"),
|
|
29
|
+
inputTotalTokens: (0, adapter_usage_projection_ts_1.adapterTokenMaterial)(usage, "inputTotalTokens"),
|
|
30
|
+
outputTokens: (0, adapter_usage_projection_ts_1.adapterTokenMaterial)(usage, "outputTokens"),
|
|
31
|
+
cacheReadTokens: (0, adapter_usage_projection_ts_1.adapterTokenMaterial)(usage, "cacheReadTokens"),
|
|
32
|
+
cacheWriteTokens: (0, adapter_usage_projection_ts_1.adapterTokenMaterial)(usage, "cacheWriteTokens"),
|
|
33
|
+
totalTokens: (0, adapter_usage_projection_ts_1.adapterTokenMaterial)(usage, "totalTokens"),
|
|
34
|
+
costs: contributionCosts((0, adapter_usage_projection_ts_1.effectiveUsageCalls)(usage), usage.collection.state === "complete"),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function tokenBuckets(contribution, metric) {
|
|
38
|
+
// Some producers have an independent total. Missing totals retain the mutually exclusive bucket fallback.
|
|
39
|
+
const usage = contribution.usage;
|
|
40
|
+
if (contribution.state === "pending" || usage === null)
|
|
41
|
+
return [undefined];
|
|
42
|
+
const input = usage.inputTotalTokens !== undefined
|
|
43
|
+
? [usage.inputTotalTokens]
|
|
44
|
+
: [usage.inputTokens, usage.cacheReadTokens, usage.cacheCreationTokens];
|
|
45
|
+
switch (metric) {
|
|
46
|
+
case "inputTotalTokens": return input;
|
|
47
|
+
case "totalTokens": return [...input, usage.outputTokens];
|
|
48
|
+
case "cacheWriteTokens": return [usage.cacheCreationTokens];
|
|
49
|
+
default: return [usage[metric]];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function agentTokenMaterial(contributions, metric, scope) {
|
|
53
|
+
const provenance = Object.freeze({ source: "agent", scope, unit: "tokens", cut: "call-time" });
|
|
54
|
+
let value = 0;
|
|
55
|
+
let observed = false;
|
|
56
|
+
let complete = contributions.length > 0;
|
|
57
|
+
for (const contribution of contributions) {
|
|
58
|
+
if (contribution.state !== "terminal" || contribution.coverage.status !== "complete")
|
|
59
|
+
complete = false;
|
|
60
|
+
for (const bucket of tokenBuckets(contribution, metric)) {
|
|
61
|
+
if (bucket === undefined) {
|
|
62
|
+
complete = false;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (!Number.isSafeInteger(bucket) || bucket < 0) {
|
|
66
|
+
return Object.freeze({ state: "unavailable", reason: "usage-invalid-token-value", provenance });
|
|
67
|
+
}
|
|
68
|
+
value += bucket;
|
|
69
|
+
observed = true;
|
|
70
|
+
if (!Number.isSafeInteger(value)) {
|
|
71
|
+
return Object.freeze({ state: "unavailable", reason: "usage-exceeds-safe-integer", provenance });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return Object.freeze(!observed
|
|
76
|
+
? { state: "unavailable", reason: "usage-not-reported", provenance }
|
|
77
|
+
: { state: complete ? "exact" : "lower-bound", value, provenance });
|
|
78
|
+
}
|
|
79
|
+
function agentCost(contribution, pricing) {
|
|
80
|
+
const usage = contribution.usage;
|
|
81
|
+
if (contribution.state === "pending" || usage === null)
|
|
82
|
+
return null;
|
|
83
|
+
const coverageComplete = contribution.coverage.status === "complete";
|
|
84
|
+
if (usage.costUSD !== undefined) {
|
|
85
|
+
const amount = (0, pricing_ts_1.canonicalDecimalFromNumber)(usage.costUSD);
|
|
86
|
+
return amount === undefined ? null : Object.freeze({
|
|
87
|
+
amount, currency: "USD", source: Object.freeze({ kind: "reported", id: "agent-send" }),
|
|
88
|
+
state: coverageComplete ? "complete" : "partial",
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
const model = contribution.model;
|
|
92
|
+
if (model === null || pricing === undefined)
|
|
93
|
+
return null;
|
|
94
|
+
const wildcard = model.includes("/") ? `${model.slice(0, model.indexOf("/"))}/*` : undefined;
|
|
95
|
+
const profile = Object.hasOwn(pricing, model) ? pricing[model]
|
|
96
|
+
: wildcard !== undefined && Object.hasOwn(pricing, wildcard) ? pricing[wildcard] : undefined;
|
|
97
|
+
if (profile === undefined || profile.currency !== undefined && profile.currency !== "USD" ||
|
|
98
|
+
profile.basis !== undefined && profile.basis !== "catalog-reference")
|
|
99
|
+
return null;
|
|
100
|
+
const buckets = [
|
|
101
|
+
[usage.inputTokens, profile.inputPerMTok],
|
|
102
|
+
[usage.outputTokens, profile.outputPerMTok],
|
|
103
|
+
[usage.cacheReadTokens, profile.cacheReadPerMTok],
|
|
104
|
+
[usage.cacheCreationTokens, profile.cacheWritePerMTok],
|
|
105
|
+
];
|
|
106
|
+
const charges = [];
|
|
107
|
+
let complete = coverageComplete;
|
|
108
|
+
for (const [tokens, price] of buckets) {
|
|
109
|
+
if (tokens === undefined || !Number.isSafeInteger(tokens) || tokens < 0) {
|
|
110
|
+
complete = false;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (tokens === 0) {
|
|
114
|
+
charges.push("0");
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const rate = price === undefined ? undefined : (0, pricing_ts_1.canonicalDecimalFromNumber)(price);
|
|
118
|
+
if (rate === undefined) {
|
|
119
|
+
complete = false;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
charges.push((0, pricing_ts_1.multiplyCanonicalDecimalPerMillion)(rate, tokens));
|
|
123
|
+
}
|
|
124
|
+
return charges.length === 0 ? null : Object.freeze({
|
|
125
|
+
amount: (0, pricing_ts_1.addCanonicalDecimals)(charges),
|
|
126
|
+
currency: "USD",
|
|
127
|
+
source: Object.freeze({ kind: "estimated", id: profile.source?.id ?? "niceeval.config.pricing" }),
|
|
128
|
+
state: complete ? "complete" : "partial",
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/** The receiver selects scope membership before calling this pure projection. */
|
|
132
|
+
function projectAgentEvalUsage(input) {
|
|
133
|
+
return Object.freeze({
|
|
134
|
+
source: "agent",
|
|
135
|
+
scope: input.scope,
|
|
136
|
+
basis: "reported-sends",
|
|
137
|
+
cut: "call-time",
|
|
138
|
+
inputTokens: agentTokenMaterial(input.contributions, "inputTokens", input.scope),
|
|
139
|
+
inputTotalTokens: agentTokenMaterial(input.contributions, "inputTotalTokens", input.scope),
|
|
140
|
+
outputTokens: agentTokenMaterial(input.contributions, "outputTokens", input.scope),
|
|
141
|
+
cacheReadTokens: agentTokenMaterial(input.contributions, "cacheReadTokens", input.scope),
|
|
142
|
+
cacheWriteTokens: agentTokenMaterial(input.contributions, "cacheWriteTokens", input.scope),
|
|
143
|
+
totalTokens: agentTokenMaterial(input.contributions, "totalTokens", input.scope),
|
|
144
|
+
costs: contributionCosts(input.contributions.map((contribution) => ({
|
|
145
|
+
effectiveCost: agentCost(contribution, input.pricing),
|
|
146
|
+
})), input.contributions.every((contribution) => contribution.state === "terminal" && contribution.coverage.status === "complete")),
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=eval-usage.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eval-usage.js","sourceRoot":"","sources":["eval-usage.ts"],"names":[],"mappings":";;AA2DA,0DAcC;AAkGD,sDAoBC;AA3LD,0EAAkJ;AAClJ,+EAAwI;AAqCxI,SAAS,iBAAiB,CAAC,KAExB,EAAE,QAAiB;IAClB,MAAM,MAAM,GAAG,IAAA,iDAAmB,EAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC7E,OAAO,MAAM,CAAC,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC,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AK,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,KAAK,UAAU,IAAI,YAAY,CAAC,QAAQ,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC;KACtI,CAAC,CAAC;AACP,CAAC","sourcesContent":["import type { NumericMaterial } from \"../assertions/match.ts\";\nimport type { ResolvedEvidenceCoverage } from \"../assertions/coverage.ts\";\nimport type { PriceOverride, Usage } from \"../types.ts\";\nimport type { ReadableAdapterUsageAttachment } from \"../record/family/adapter-usage/schema.ts\";\nimport { addCanonicalDecimals, canonicalDecimalFromNumber, multiplyCanonicalDecimalPerMillion, } from \"../record/family/adapter-usage/pricing.ts\";\nimport { adapterTokenMaterial, effectiveCostTotals, effectiveUsageCalls, type EffectiveCallCost, } from \"./adapter-usage-projection.ts\";\n/** Internal source-owned shape; package-root exposure belongs to the author facade. */\nexport interface EvalUsage {\n readonly source: \"agent\" | \"adapter\" | \"unavailable\";\n readonly scope: \"turn\" | \"session\" | \"attempt\";\n readonly basis: \"reported-sends\" | \"recorded-calls\" | \"unbound\";\n readonly cut: \"call-time\";\n readonly inputTokens: NumericMaterial;\n readonly inputTotalTokens: NumericMaterial;\n readonly outputTokens: NumericMaterial;\n readonly cacheReadTokens: NumericMaterial;\n readonly cacheWriteTokens: NumericMaterial;\n readonly totalTokens: NumericMaterial;\n readonly costs: {\n readonly state: \"complete\" | \"partial\" | \"unavailable\";\n readonly values: readonly {\n readonly currency: string;\n readonly value: string;\n readonly source: \"reported\" | \"estimated\" | \"mixed\";\n readonly coveredContributions: number;\n readonly reportedContributions: number;\n readonly estimatedContributions: number;\n }[];\n readonly totalContributions: number;\n };\n}\nexport interface AgentUsageContribution {\n readonly sessionScopeId: string;\n readonly turnId: string;\n readonly sendAttempt: number;\n readonly state: \"pending\" | \"terminal\";\n readonly outcome: \"completed\" | \"failed\" | \"interrupted\" | null;\n readonly model: string | null;\n readonly usage: Readonly<Usage> | null;\n readonly coverage: ResolvedEvidenceCoverage[\"usage\"];\n}\ntype TokenMetric = \"inputTokens\" | \"inputTotalTokens\" | \"outputTokens\" | \"cacheReadTokens\" | \"cacheWriteTokens\" | \"totalTokens\";\nfunction contributionCosts(calls: readonly {\n readonly effectiveCost: EffectiveCallCost | null;\n}[], complete: boolean): EvalUsage[\"costs\"] {\n const totals = effectiveCostTotals(calls, complete ? \"complete\" : \"partial\");\n return Object.freeze({\n state: totals.state,\n values: Object.freeze(totals.values.map((value) => Object.freeze({\n currency: value.currency,\n value: value.value,\n source: value.source,\n coveredContributions: value.coveredCalls,\n reportedContributions: value.reportedCalls,\n estimatedContributions: value.estimatedCalls,\n }))),\n totalContributions: totals.totalCalls,\n });\n}\nexport function projectAdapterEvalUsage(usage: ReadableAdapterUsageAttachment): EvalUsage {\n return Object.freeze({\n source: \"adapter\",\n scope: \"attempt\",\n basis: \"recorded-calls\",\n cut: \"call-time\",\n inputTokens: adapterTokenMaterial(usage, \"inputTokens\"),\n inputTotalTokens: adapterTokenMaterial(usage, \"inputTotalTokens\"),\n outputTokens: adapterTokenMaterial(usage, \"outputTokens\"),\n cacheReadTokens: adapterTokenMaterial(usage, \"cacheReadTokens\"),\n cacheWriteTokens: adapterTokenMaterial(usage, \"cacheWriteTokens\"),\n totalTokens: adapterTokenMaterial(usage, \"totalTokens\"),\n costs: contributionCosts(effectiveUsageCalls(usage), usage.collection.state === \"complete\"),\n });\n}\nfunction tokenBuckets(contribution: AgentUsageContribution, metric: TokenMetric): readonly (number | undefined)[] {\n // Some producers have an independent total. Missing totals retain the mutually exclusive bucket fallback.\n const usage: (Readonly<Usage> & {\n readonly inputTotalTokens?: number;\n }) | null = contribution.usage;\n if (contribution.state === \"pending\" || usage === null)\n return [undefined];\n const input = usage.inputTotalTokens !== undefined\n ? [usage.inputTotalTokens]\n : [usage.inputTokens, usage.cacheReadTokens, usage.cacheCreationTokens];\n switch (metric) {\n case \"inputTotalTokens\": return input;\n case \"totalTokens\": return [...input, usage.outputTokens];\n case \"cacheWriteTokens\": return [usage.cacheCreationTokens];\n default: return [usage[metric]];\n }\n}\nfunction agentTokenMaterial(contributions: readonly AgentUsageContribution[], metric: TokenMetric, scope: EvalUsage[\"scope\"]): NumericMaterial {\n const provenance = Object.freeze({ source: \"agent\", scope, unit: \"tokens\", cut: \"call-time\" });\n let value = 0;\n let observed = false;\n let complete = contributions.length > 0;\n for (const contribution of contributions) {\n if (contribution.state !== \"terminal\" || contribution.coverage.status !== \"complete\")\n complete = false;\n for (const bucket of tokenBuckets(contribution, metric)) {\n if (bucket === undefined) {\n complete = false;\n continue;\n }\n if (!Number.isSafeInteger(bucket) || bucket < 0) {\n return Object.freeze({ state: \"unavailable\", reason: \"usage-invalid-token-value\", provenance });\n }\n value += bucket;\n observed = true;\n if (!Number.isSafeInteger(value)) {\n return Object.freeze({ state: \"unavailable\", reason: \"usage-exceeds-safe-integer\", provenance });\n }\n }\n }\n return Object.freeze(!observed\n ? { state: \"unavailable\", reason: \"usage-not-reported\", provenance }\n : { state: complete ? \"exact\" : \"lower-bound\", value, provenance });\n}\nfunction agentCost(contribution: AgentUsageContribution, pricing: Record<string, PriceOverride> | undefined): EffectiveCallCost | null {\n const usage = contribution.usage;\n if (contribution.state === \"pending\" || usage === null)\n return null;\n const coverageComplete = contribution.coverage.status === \"complete\";\n if (usage.costUSD !== undefined) {\n const amount = canonicalDecimalFromNumber(usage.costUSD);\n return amount === undefined ? null : Object.freeze({\n amount, currency: \"USD\", source: Object.freeze({ kind: \"reported\", id: \"agent-send\" }),\n state: coverageComplete ? \"complete\" : \"partial\",\n });\n }\n const model = contribution.model;\n if (model === null || pricing === undefined)\n return null;\n const wildcard = model.includes(\"/\") ? `${model.slice(0, model.indexOf(\"/\"))}/*` : undefined;\n const profile = Object.hasOwn(pricing, model) ? pricing[model]\n : wildcard !== undefined && Object.hasOwn(pricing, wildcard) ? pricing[wildcard] : undefined;\n if (profile === undefined || profile.currency !== undefined && profile.currency !== \"USD\" ||\n profile.basis !== undefined && profile.basis !== \"catalog-reference\")\n return null;\n const buckets = [\n [usage.inputTokens, profile.inputPerMTok],\n [usage.outputTokens, profile.outputPerMTok],\n [usage.cacheReadTokens, profile.cacheReadPerMTok],\n [usage.cacheCreationTokens, profile.cacheWritePerMTok],\n ] as const;\n const charges: string[] = [];\n let complete = coverageComplete;\n for (const [tokens, price] of buckets) {\n if (tokens === undefined || !Number.isSafeInteger(tokens) || tokens < 0) {\n complete = false;\n continue;\n }\n if (tokens === 0) {\n charges.push(\"0\");\n continue;\n }\n const rate = price === undefined ? undefined : canonicalDecimalFromNumber(price);\n if (rate === undefined) {\n complete = false;\n continue;\n }\n charges.push(multiplyCanonicalDecimalPerMillion(rate, tokens));\n }\n return charges.length === 0 ? null : Object.freeze({\n amount: addCanonicalDecimals(charges),\n currency: \"USD\",\n source: Object.freeze({ kind: \"estimated\", id: profile.source?.id ?? \"niceeval.config.pricing\" }),\n state: complete ? \"complete\" : \"partial\",\n });\n}\n/** The receiver selects scope membership before calling this pure projection. */\nexport function projectAgentEvalUsage(input: {\n contributions: readonly AgentUsageContribution[];\n scope: \"turn\" | \"session\" | \"attempt\";\n pricing?: Record<string, PriceOverride>;\n}): EvalUsage {\n return Object.freeze({\n source: \"agent\",\n scope: input.scope,\n basis: \"reported-sends\",\n cut: \"call-time\",\n inputTokens: agentTokenMaterial(input.contributions, \"inputTokens\", input.scope),\n inputTotalTokens: agentTokenMaterial(input.contributions, \"inputTotalTokens\", input.scope),\n outputTokens: agentTokenMaterial(input.contributions, \"outputTokens\", input.scope),\n cacheReadTokens: agentTokenMaterial(input.contributions, \"cacheReadTokens\", input.scope),\n cacheWriteTokens: agentTokenMaterial(input.contributions, \"cacheWriteTokens\", input.scope),\n totalTokens: agentTokenMaterial(input.contributions, \"totalTokens\", input.scope),\n costs: contributionCosts(input.contributions.map((contribution) => ({\n effectiveCost: agentCost(contribution, input.pricing),\n })), input.contributions.every((contribution) => contribution.state === \"terminal\" && contribution.coverage.status === \"complete\")),\n });\n}\n"]}
|