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 @@ declare const InspectionOperationError_base: new <A extends Record<string, any>
|
|
|
6
6
|
} & Readonly<A>;
|
|
7
7
|
/** Typed browser-neutral failure from one fixed Inspection operation. */
|
|
8
8
|
export declare class InspectionOperationError extends InspectionOperationError_base<{
|
|
9
|
-
readonly code: "inspection-request-invalid" | "inspection-selection-missing" | "inspection-record-integrity-failure" | "inspection-operation-failed" | "inspection-result-invalid" | "evidence-budget-exceeded" | "restart-required";
|
|
9
|
+
readonly code: "inspection-request-invalid" | "inspection-selection-missing" | "inspection-record-integrity-failure" | "inspection-operation-failed" | "inspection-result-invalid" | "evidence-budget-exceeded" | "restart-required" | "current-target-unavailable";
|
|
10
10
|
readonly operation: InspectionOperationId;
|
|
11
11
|
readonly reason: string;
|
|
12
12
|
readonly identity?: {
|
|
@@ -6,7 +6,7 @@ declare const InspectionOperationError_base: new <A extends Record<string, any>
|
|
|
6
6
|
} & Readonly<A>;
|
|
7
7
|
/** Typed browser-neutral failure from one fixed Inspection operation. */
|
|
8
8
|
export declare class InspectionOperationError extends InspectionOperationError_base<{
|
|
9
|
-
readonly code: "inspection-request-invalid" | "inspection-selection-missing" | "inspection-record-integrity-failure" | "inspection-operation-failed" | "inspection-result-invalid" | "evidence-budget-exceeded" | "restart-required";
|
|
9
|
+
readonly code: "inspection-request-invalid" | "inspection-selection-missing" | "inspection-record-integrity-failure" | "inspection-operation-failed" | "inspection-result-invalid" | "evidence-budget-exceeded" | "restart-required" | "current-target-unavailable";
|
|
10
10
|
readonly operation: InspectionOperationId;
|
|
11
11
|
readonly reason: string;
|
|
12
12
|
readonly identity?: {
|
|
@@ -6,7 +6,7 @@ declare const InspectionOperationError_base: new <A extends Record<string, any>
|
|
|
6
6
|
} & Readonly<A>;
|
|
7
7
|
/** Typed browser-neutral failure from one fixed Inspection operation. */
|
|
8
8
|
export declare class InspectionOperationError extends InspectionOperationError_base<{
|
|
9
|
-
readonly code: "inspection-request-invalid" | "inspection-selection-missing" | "inspection-record-integrity-failure" | "inspection-operation-failed" | "inspection-result-invalid" | "evidence-budget-exceeded" | "restart-required";
|
|
9
|
+
readonly code: "inspection-request-invalid" | "inspection-selection-missing" | "inspection-record-integrity-failure" | "inspection-operation-failed" | "inspection-result-invalid" | "evidence-budget-exceeded" | "restart-required" | "current-target-unavailable";
|
|
10
10
|
readonly operation: InspectionOperationId;
|
|
11
11
|
readonly reason: string;
|
|
12
12
|
readonly identity?: {
|
|
@@ -5,6 +5,10 @@ exports.operationalInspectionSource = operationalInspectionSource;
|
|
|
5
5
|
exports.externalInspectionSource = externalInspectionSource;
|
|
6
6
|
exports.openInspectionSource = openInspectionSource;
|
|
7
7
|
exports.openHostOwnedInspectionSource = openHostOwnedInspectionSource;
|
|
8
|
+
// @concord-file ne-eval-inspection-source
|
|
9
|
+
// @concord-implements docs/feature/inspection/README.md
|
|
10
|
+
// @concord-implements docs/feature/inspection/architecture.md
|
|
11
|
+
// @concord-implements docs/feature/insight/README.md
|
|
8
12
|
const node_fs_1 = require("node:fs");
|
|
9
13
|
const node_path_1 = require("node:path");
|
|
10
14
|
const effect_1 = require("effect");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.js","sourceRoot":"","sources":["source.ts"],"names":[],"mappings":";;;AAwCA,kEAKC;AACD,4DAKC;AAMD,oDA2BC;AAED,sEAQC;AA9FD,qCAAqC;AACrC,yCAA6C;AAC7C,mCAAsC;AAEtC,0DAAoE;AACpE,oDAAuE;AACvE,wDAAqU;AACrU,0FAAuF;AASvF,MAAa,qBAAsB,SAAQ,aAAI,CAAC,WAAW,CAAC,uBAAuB,CAIjF;CACD;AALD,sDAKC;AACD,4EAA4E;AAC5E,MAAa,wBAAyB,SAAQ,aAAI,CAAC,WAAW,CAAC,0BAA0B,CAGvF;CACD;AAJD,4DAIC;AAYD,gFAAgF;AAChF,SAAgB,2BAA2B,CAAC,GAAW;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC;QACjB,IAAI,EAAE,gBAAyB;QAC/B,YAAY,EAAE,IAAA,mBAAO,EAAC,GAAG,EAAE,yBAAyB,CAAC;KACxD,CAAC,CAAC;AACP,CAAC;AACD,SAAgB,wBAAwB,CAAC,GAAW,EAAE,QAAg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E,EAAE,CAAC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC;QACtE,eAAe,EAAE,CAAC,SAAiB,EAAE,YAAoB,EAAE,QAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,oBAAoB,CAAC,SAAS,EAAE,YAAY,EAAE,QAAQ,CAAC;QAC/I,kBAAkB,EAAE,CAAC,YAAoB,EAAE,YAAoB,EAAE,QAAgB,EAAE,EAAE,CAAC,OAAO,CAAC,sBAAsB,CAAC,YAAY,EAAE,YAAY,EAAE,QAAQ,CAAC;KAC7J,CAAC,CAAC;AACP,CAAC;AACD,SAAS,WAAW,CAAC,KAAc;IAC/B,IAAI,KAAK,YAAY,kCAAsB,EAAE,CAAC;QAC1C,OAAO,IAAI,wBAAwB,CAAC;YAChC,IAAI,EAAE,qCAAqC;YAC3C,KAAK,EAAE,KAAK,CAAC,KAAK;SACrB,CAAC,CAAC;IACP,CAAC;IACD,OAAO,IAAI,qBAAqB,CAAC;QAC7B,IAAI,EAAE,2BAA2B;QACjC,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,iCAAiC;QAClF,KAAK;KACR,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { Data, Effect } from \"effect\";\nimport type * as Scope from \"effect/Scope\";\nimport { RecordIntegrityFailure } from \"../record/reader/errors.ts\";\nimport { EMPTY_PUBLICATION_CUTOFF_IDENTITY } from \"../run/protocol.ts\";\nimport { openHostOwnedRecordReadSession, acquireProjectRecordReadSession, RECORD_SQLITE_VALIDATION_DEADLINE_MS, type AttemptLocatorCandidates, type CollectionItemPage, type ContentChunkPage, type PinnedRecordReadSession, type SealedRunCore, type SealedRunCutoff, type SealedRunSummaryPage, } from \"../record/sqlite/index.ts\";\nimport { startExternalRecordImport } from \"../record/sqlite/external-record-import.ts\";\nimport type { ReadableRunResource } from \"../run/storage/types.ts\";\nexport type InspectionSource = {\n readonly kind: \"project-record\";\n readonly databasePath: string;\n} | {\n readonly kind: \"external-record\";\n readonly recordPath: string;\n};\nexport class InspectionSourceError extends Data.TaggedError(\"InspectionSourceError\")<{\n readonly code: \"inspection-source-invalid\";\n readonly reason: string;\n readonly cause?: unknown;\n}> {\n}\n/** Safe Inspection identity for a Record publication that is not closed. */\nexport class InspectionIntegrityError extends Data.TaggedError(\"InspectionIntegrityError\")<{\n readonly code: \"inspection-record-integrity-failure\";\n readonly runId: string;\n}> {\n}\n/** Browser-neutral fixed reader capability backed by one pinned Record generation. */\nexport interface InspectionFactSource {\n readonly kind: InspectionSource[\"kind\"];\n readonly cutoff: () => SealedRunCutoff;\n readonly readRunResource: (runId: string) => ReadableRunResource | undefined;\n readonly readSealedRunSummaryPage: (afterRunId?: string, pageSize?: number, expectedCutoffIdentity?: string) => SealedRunSummaryPage;\n readonly findAttemptLocatorCandidates: (locator: string, maximumCandidateRuns: number) => AttemptLocatorCandidates;\n readonly readSealedRunCore: (runId: string) => SealedRunCore | undefined;\n readonly readContentPage: (contentId: string, afterOrdinal: number, pageSize: number) => ContentChunkPage;\n readonly readCollectionPage: (attachmentId: string, afterOrdinal: number, pageSize: number) => CollectionItemPage;\n}\n/** Pure source selection; opening and validation happen only inside a Scope. */\nexport function operationalInspectionSource(cwd: string): InspectionSource {\n return Object.freeze({\n kind: \"project-record\" as const,\n databasePath: resolve(cwd, \".niceeval/record.sqlite\"),\n });\n}\nexport function externalInspectionSource(cwd: string, pathname: string): InspectionSource {\n return Object.freeze({\n kind: \"external-record\" as const,\n recordPath: resolve(cwd, pathname),\n });\n}\n/**\n * Acquires exactly one pinned Record reader. Every fixed operation in the\n * returned source sees the same generation, and Scope closes the session on\n * success, typed failure, defect, or interruption.\n */\nexport function openInspectionSource(source: InspectionSource): Effect.Effect<InspectionFactSource, InspectionSourceError | InspectionIntegrityError, Scope.Scope> {\n return Effect.gen(function* () {\n let session: PinnedRecordReadSession;\n if (source.kind === \"project-record\") {\n if (!existsSync(source.databasePath))\n return emptyOperationalFacts();\n session = yield* acquireProjectRecordReadSession(dirname(source.databasePath)).pipe(Effect.mapError(sourceError));\n }\n else {\n const importDeadline = Date.now() + RECORD_SQLITE_VALIDATION_DEADLINE_MS;\n const importer = yield* Effect.acquireRelease(Effect.try({\n try: () => startExternalRecordImport(source.recordPath, importDeadline),\n catch: (cause) => sourceError(cause),\n }), (handle) => Effect.promise(() => handle.close().catch(() => undefined)));\n const generation = yield* Effect.tryPromise({\n // Declaring the AbortSignal keeps this await interruptible. Scope then\n // terminates the Worker and removes its private generation.\n try: (_signal) => importer.result,\n catch: (cause) => sourceError(cause),\n });\n session = yield* Effect.acquireRelease(Effect.try({\n try: () => openHostOwnedRecordReadSession(generation.path),\n catch: (cause) => sourceError(cause),\n }), (opened) => Effect.sync(() => opened.close()));\n }\n return sessionFacts(session, source.kind);\n });\n}\n/** Opens one already-imported private generation without accepting a public path. */\nexport function openHostOwnedInspectionSource(recordPath: string): Effect.Effect<InspectionFactSource, InspectionSourceError | InspectionIntegrityError, Scope.Scope> {\n return Effect.gen(function* () {\n const session = yield* Effect.acquireRelease(Effect.try({\n try: () => openHostOwnedRecordReadSession(recordPath),\n catch: (cause) => sourceError(cause),\n }), (opened) => Effect.sync(() => opened.close()));\n return sessionFacts(session, \"external-record\");\n });\n}\nconst EMPTY_OPERATIONAL_CUTOFF = Object.freeze({\n identity: EMPTY_PUBLICATION_CUTOFF_IDENTITY,\n runCount: 0,\n});\nfunction emptyOperationalFacts(): InspectionFactSource {\n return Object.freeze({\n kind: \"project-record\" as const,\n cutoff: () => EMPTY_OPERATIONAL_CUTOFF,\n readRunResource: () => undefined,\n readSealedRunSummaryPage: (afterRunId = \"\", _pageSize = 100, expectedCutoffIdentity?: string) => {\n if (expectedCutoffIdentity !== undefined && expectedCutoffIdentity !== EMPTY_OPERATIONAL_CUTOFF.identity) {\n throw new InspectionSourceError({\n code: \"inspection-source-invalid\",\n reason: \"The empty operational publication cutoff changed; restart pagination.\",\n });\n }\n return Object.freeze({\n cutoff: EMPTY_OPERATIONAL_CUTOFF,\n afterRunId,\n summaries: Object.freeze([]),\n nextAfterRunId: null,\n });\n },\n findAttemptLocatorCandidates: (locator: string) => Object.freeze({\n locator,\n ambiguous: false,\n candidates: Object.freeze([]),\n }),\n readSealedRunCore: () => undefined,\n readContentPage: (contentId: string, afterOrdinal: number) => Object.freeze({\n contentId,\n afterOrdinal,\n chunks: Object.freeze([]),\n nextOrdinal: null,\n }),\n readCollectionPage: (attachmentId: string, afterOrdinal: number) => Object.freeze({\n attachmentId,\n afterOrdinal,\n items: Object.freeze([]),\n nextOrdinal: null,\n }),\n });\n}\nfunction sessionFacts(session: PinnedRecordReadSession, kind: InspectionSource[\"kind\"]): InspectionFactSource {\n let observedCutoff: SealedRunCutoff | undefined;\n const remember = (page: SealedRunSummaryPage): SealedRunSummaryPage => {\n if (observedCutoff !== undefined && observedCutoff.identity !== page.cutoff.identity) {\n throw new InspectionSourceError({\n code: \"inspection-source-invalid\",\n reason: \"Pinned Record session changed its sealed cutoff.\",\n });\n }\n observedCutoff = page.cutoff;\n return page;\n };\n const readPage = (afterRunId = \"\", pageSize = 100, expectedCutoffIdentity?: string): SealedRunSummaryPage => remember(session.readSealedRunSummaryPage(afterRunId, pageSize, expectedCutoffIdentity ?? observedCutoff?.identity));\n return Object.freeze({\n kind,\n cutoff: () => observedCutoff ?? readPage(\"\", 1).cutoff,\n readRunResource: (runId: string) => session.readRunResource(runId),\n readSealedRunSummaryPage: readPage,\n findAttemptLocatorCandidates: (locator: string, maximumCandidateRuns: number) => session.findAttemptLocatorCandidates(locator, maximumCandidateRuns),\n readSealedRunCore: (runId: string) => session.readSealedRunCore(runId),\n readContentPage: (contentId: string, afterOrdinal: number, pageSize: number) => session.readContentChunkPage(contentId, afterOrdinal, pageSize),\n readCollectionPage: (attachmentId: string, afterOrdinal: number, pageSize: number) => session.readCollectionItemPage(attachmentId, afterOrdinal, pageSize),\n });\n}\nfunction sourceError(cause: unknown): InspectionSourceError | InspectionIntegrityError {\n if (cause instanceof RecordIntegrityFailure) {\n return new InspectionIntegrityError({\n code: \"inspection-record-integrity-failure\",\n runId: cause.runId,\n });\n }\n return new InspectionSourceError({\n code: \"inspection-source-invalid\",\n reason: cause instanceof Error ? cause.message : \"Record source validation failed\",\n cause,\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"source.js","sourceRoot":"","sources":["source.ts"],"names":[],"mappings":";;;AA4CA,kEAKC;AACD,4DAKC;AAMD,oDA2BC;AAED,sEAQC;AAlGD,0CAA0C;AAC1C,wDAAwD;AACxD,8DAA8D;AAC9D,qDAAqD;AACrD,qCAAqC;AACrC,yCAA6C;AAC7C,mCAAsC;AAEtC,0DAAoE;AACpE,oDAAuE;AACvE,wDAAqU;AACrU,0FAAuF;AASvF,MAAa,qBAAsB,SAAQ,aAAI,CAAC,WAAW,CAAC,uBAAuB,CAIjF;CACD;AALD,sDAKC;AACD,4EAA4E;AAC5E,MAAa,wBAAyB,SAAQ,aAAI,CAAC,WAAW,CAAC,0BAA0B,CAGvF;CACD;AAJD,4DAIC;AAYD,gFAAgF;AAChF,SAAgB,2BAA2B,CAAC,GAAW;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC;QACjB,IAAI,EAAE,gBAAyB;QAC/B,YAAY,EAAE,IAAA,mBAAO,EAAC,GAAG,EAAE,yBAAyB,CAAC;KACxD,CAAC,CAAC;AACP,CAAC;AACD,SAAgB,wBAAwB,CAAC,GAAW,EAAE,QAAgB;IAClE,OAAO,MAAM,CAAC,MAAM,CAAC;QACjB,IAAI,EAAE,iBAA0B;QAChC,UAAU,EAAE,IAAA,mBAAO,EAAC,GAAG,EAAE,QAAQ,CAAC;KACrC,CAAC,CAAC;AACP,CAAC;AACD;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,MAAwB;IACzD,OAAO,eAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACvB,IAAI,OAAgC,CAAC;QACrC,I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AAsB,CAAC,YAAY,EAAE,YAAY,EAAE,QAAQ,CAAC;KAC7J,CAAC,CAAC;AACP,CAAC;AACD,SAAS,WAAW,CAAC,KAAc;IAC/B,IAAI,KAAK,YAAY,kCAAsB,EAAE,CAAC;QAC1C,OAAO,IAAI,wBAAwB,CAAC;YAChC,IAAI,EAAE,qCAAqC;YAC3C,KAAK,EAAE,KAAK,CAAC,KAAK;SACrB,CAAC,CAAC;IACP,CAAC;IACD,OAAO,IAAI,qBAAqB,CAAC;QAC7B,IAAI,EAAE,2BAA2B;QACjC,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,iCAAiC;QAClF,KAAK;KACR,CAAC,CAAC;AACP,CAAC","sourcesContent":["// @concord-file ne-eval-inspection-source\n// @concord-implements docs/feature/inspection/README.md\n// @concord-implements docs/feature/inspection/architecture.md\n// @concord-implements docs/feature/insight/README.md\nimport { existsSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport { Data, Effect } from \"effect\";\nimport type * as Scope from \"effect/Scope\";\nimport { RecordIntegrityFailure } from \"../record/reader/errors.ts\";\nimport { EMPTY_PUBLICATION_CUTOFF_IDENTITY } from \"../run/protocol.ts\";\nimport { openHostOwnedRecordReadSession, acquireProjectRecordReadSession, RECORD_SQLITE_VALIDATION_DEADLINE_MS, type AttemptLocatorCandidates, type CollectionItemPage, type ContentChunkPage, type PinnedRecordReadSession, type SealedRunCore, type SealedRunCutoff, type SealedRunSummaryPage, } from \"../record/sqlite/index.ts\";\nimport { startExternalRecordImport } from \"../record/sqlite/external-record-import.ts\";\nimport type { ReadableRunResource } from \"../run/storage/types.ts\";\nexport type InspectionSource = {\n readonly kind: \"project-record\";\n readonly databasePath: string;\n} | {\n readonly kind: \"external-record\";\n readonly recordPath: string;\n};\nexport class InspectionSourceError extends Data.TaggedError(\"InspectionSourceError\")<{\n readonly code: \"inspection-source-invalid\";\n readonly reason: string;\n readonly cause?: unknown;\n}> {\n}\n/** Safe Inspection identity for a Record publication that is not closed. */\nexport class InspectionIntegrityError extends Data.TaggedError(\"InspectionIntegrityError\")<{\n readonly code: \"inspection-record-integrity-failure\";\n readonly runId: string;\n}> {\n}\n/** Browser-neutral fixed reader capability backed by one pinned Record generation. */\nexport interface InspectionFactSource {\n readonly kind: InspectionSource[\"kind\"];\n readonly cutoff: () => SealedRunCutoff;\n readonly readRunResource: (runId: string) => ReadableRunResource | undefined;\n readonly readSealedRunSummaryPage: (afterRunId?: string, pageSize?: number, expectedCutoffIdentity?: string) => SealedRunSummaryPage;\n readonly findAttemptLocatorCandidates: (locator: string, maximumCandidateRuns: number) => AttemptLocatorCandidates;\n readonly readSealedRunCore: (runId: string) => SealedRunCore | undefined;\n readonly readContentPage: (contentId: string, afterOrdinal: number, pageSize: number) => ContentChunkPage;\n readonly readCollectionPage: (attachmentId: string, afterOrdinal: number, pageSize: number) => CollectionItemPage;\n}\n/** Pure source selection; opening and validation happen only inside a Scope. */\nexport function operationalInspectionSource(cwd: string): InspectionSource {\n return Object.freeze({\n kind: \"project-record\" as const,\n databasePath: resolve(cwd, \".niceeval/record.sqlite\"),\n });\n}\nexport function externalInspectionSource(cwd: string, pathname: string): InspectionSource {\n return Object.freeze({\n kind: \"external-record\" as const,\n recordPath: resolve(cwd, pathname),\n });\n}\n/**\n * Acquires exactly one pinned Record reader. Every fixed operation in the\n * returned source sees the same generation, and Scope closes the session on\n * success, typed failure, defect, or interruption.\n */\nexport function openInspectionSource(source: InspectionSource): Effect.Effect<InspectionFactSource, InspectionSourceError | InspectionIntegrityError, Scope.Scope> {\n return Effect.gen(function* () {\n let session: PinnedRecordReadSession;\n if (source.kind === \"project-record\") {\n if (!existsSync(source.databasePath))\n return emptyOperationalFacts();\n session = yield* acquireProjectRecordReadSession(dirname(source.databasePath)).pipe(Effect.mapError(sourceError));\n }\n else {\n const importDeadline = Date.now() + RECORD_SQLITE_VALIDATION_DEADLINE_MS;\n const importer = yield* Effect.acquireRelease(Effect.try({\n try: () => startExternalRecordImport(source.recordPath, importDeadline),\n catch: (cause) => sourceError(cause),\n }), (handle) => Effect.promise(() => handle.close().catch(() => undefined)));\n const generation = yield* Effect.tryPromise({\n // Declaring the AbortSignal keeps this await interruptible. Scope then\n // terminates the Worker and removes its private generation.\n try: (_signal) => importer.result,\n catch: (cause) => sourceError(cause),\n });\n session = yield* Effect.acquireRelease(Effect.try({\n try: () => openHostOwnedRecordReadSession(generation.path),\n catch: (cause) => sourceError(cause),\n }), (opened) => Effect.sync(() => opened.close()));\n }\n return sessionFacts(session, source.kind);\n });\n}\n/** Opens one already-imported private generation without accepting a public path. */\nexport function openHostOwnedInspectionSource(recordPath: string): Effect.Effect<InspectionFactSource, InspectionSourceError | InspectionIntegrityError, Scope.Scope> {\n return Effect.gen(function* () {\n const session = yield* Effect.acquireRelease(Effect.try({\n try: () => openHostOwnedRecordReadSession(recordPath),\n catch: (cause) => sourceError(cause),\n }), (opened) => Effect.sync(() => opened.close()));\n return sessionFacts(session, \"external-record\");\n });\n}\nconst EMPTY_OPERATIONAL_CUTOFF = Object.freeze({\n identity: EMPTY_PUBLICATION_CUTOFF_IDENTITY,\n runCount: 0,\n});\nfunction emptyOperationalFacts(): InspectionFactSource {\n return Object.freeze({\n kind: \"project-record\" as const,\n cutoff: () => EMPTY_OPERATIONAL_CUTOFF,\n readRunResource: () => undefined,\n readSealedRunSummaryPage: (afterRunId = \"\", _pageSize = 100, expectedCutoffIdentity?: string) => {\n if (expectedCutoffIdentity !== undefined && expectedCutoffIdentity !== EMPTY_OPERATIONAL_CUTOFF.identity) {\n throw new InspectionSourceError({\n code: \"inspection-source-invalid\",\n reason: \"The empty operational publication cutoff changed; restart pagination.\",\n });\n }\n return Object.freeze({\n cutoff: EMPTY_OPERATIONAL_CUTOFF,\n afterRunId,\n summaries: Object.freeze([]),\n nextAfterRunId: null,\n });\n },\n findAttemptLocatorCandidates: (locator: string) => Object.freeze({\n locator,\n ambiguous: false,\n candidates: Object.freeze([]),\n }),\n readSealedRunCore: () => undefined,\n readContentPage: (contentId: string, afterOrdinal: number) => Object.freeze({\n contentId,\n afterOrdinal,\n chunks: Object.freeze([]),\n nextOrdinal: null,\n }),\n readCollectionPage: (attachmentId: string, afterOrdinal: number) => Object.freeze({\n attachmentId,\n afterOrdinal,\n items: Object.freeze([]),\n nextOrdinal: null,\n }),\n });\n}\nfunction sessionFacts(session: PinnedRecordReadSession, kind: InspectionSource[\"kind\"]): InspectionFactSource {\n let observedCutoff: SealedRunCutoff | undefined;\n const remember = (page: SealedRunSummaryPage): SealedRunSummaryPage => {\n if (observedCutoff !== undefined && observedCutoff.identity !== page.cutoff.identity) {\n throw new InspectionSourceError({\n code: \"inspection-source-invalid\",\n reason: \"Pinned Record session changed its sealed cutoff.\",\n });\n }\n observedCutoff = page.cutoff;\n return page;\n };\n const readPage = (afterRunId = \"\", pageSize = 100, expectedCutoffIdentity?: string): SealedRunSummaryPage => remember(session.readSealedRunSummaryPage(afterRunId, pageSize, expectedCutoffIdentity ?? observedCutoff?.identity));\n return Object.freeze({\n kind,\n cutoff: () => observedCutoff ?? readPage(\"\", 1).cutoff,\n readRunResource: (runId: string) => session.readRunResource(runId),\n readSealedRunSummaryPage: readPage,\n findAttemptLocatorCandidates: (locator: string, maximumCandidateRuns: number) => session.findAttemptLocatorCandidates(locator, maximumCandidateRuns),\n readSealedRunCore: (runId: string) => session.readSealedRunCore(runId),\n readContentPage: (contentId: string, afterOrdinal: number, pageSize: number) => session.readContentChunkPage(contentId, afterOrdinal, pageSize),\n readCollectionPage: (attachmentId: string, afterOrdinal: number, pageSize: number) => session.readCollectionItemPage(attachmentId, afterOrdinal, pageSize),\n });\n}\nfunction sourceError(cause: unknown): InspectionSourceError | InspectionIntegrityError {\n if (cause instanceof RecordIntegrityFailure) {\n return new InspectionIntegrityError({\n code: \"inspection-record-integrity-failure\",\n runId: cause.runId,\n });\n }\n return new InspectionSourceError({\n code: \"inspection-source-invalid\",\n reason: cause instanceof Error ? cause.message : \"Record source validation failed\",\n cause,\n });\n}\n"]}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.projectAttemptSources = projectAttemptSources;
|
|
4
|
+
// @concord-file ne-eval-inspection-sources
|
|
5
|
+
// @concord-implements docs/feature/inspection/README.md
|
|
6
|
+
// @concord-implements docs/feature/inspection/architecture.md
|
|
4
7
|
const effect_1 = require("effect");
|
|
5
8
|
const protocol_ts_1 = require("../record/attachment/protocol.cjs");
|
|
6
9
|
const content_ts_1 = require("../record/attachment/content.cjs");
|
|
@@ -11,6 +14,8 @@ const limits_ts_1 = require("./limits.cjs");
|
|
|
11
14
|
const SOURCE_TEXT_BYTE_LIMIT = 256 * 1024;
|
|
12
15
|
const SOURCE_RESULT_HEADROOM = 1024;
|
|
13
16
|
const CONTENT_PAGE_SIZE = 64;
|
|
17
|
+
// @concord-code ne-eval-inspection-project-sources
|
|
18
|
+
// @concord-implements docs/feature/inspection/architecture.md
|
|
14
19
|
function projectAttemptSources(source, attachment, assertions) {
|
|
15
20
|
const assertionsRead = readAssertionSites(assertions);
|
|
16
21
|
let state = attachment === undefined ? "not-recorded" : "available";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sources.js","sourceRoot":"","sources":["sources.ts"],"names":[],"mappings":";;AA6CA,sDA+EC;AA5HD,mCAAgC;AAChC,kEAAmF;AACnF,gEAAqG;AACrG,4DAA2G;AAE3G,yCAA8F;AAC9F,yCAA8D;AAE9D,2CAA2D;AAG3D,MAAM,sBAAsB,GAAG,GAAG,GAAG,IAAI,CAAC;AAC1C,MAAM,sBAAsB,GAAG,IAAI,CAAC;AACpC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAgC7B,SAAgB,qBAAqB,CAAC,MAA4B,EAAE,UAA8C,EAAE,UAAoC;IACpJ,MAAM,cAAc,GAAG,kBAAkB,CAAC,UAAU,CAAC,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AC;IACpC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG;QACpC,OAAO,SAAS,CAAC;IACrB,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC/D,OAAO,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,UAAU,IAAI,OAAO,IAAI,UAAU;QAC7E,CAAC,CAAC,UAAU,CAAC,KAAK;QAClB,CAAC,CAAC,SAAS,CAAC;AACpB,CAAC;AACD,SAAS,YAAY,CAAC,KAAc,EAAE,GAAW;IAC7C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACvE,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACzD,CAAC;AACD,SAAS,SAAS,CAAC,KAAc;IAC7B,MAAM,MAAM,GAAG,IAAA,8BAAmB,EAAC,KAAK,CAAC,CAAC;IAC1C,IAAI,IAAA,iCAAsB,EAAC,MAAM,CAAC;QAC9B,MAAM,MAAM,CAAC;IACjB,OAAO,MAAwB,CAAC;AACpC,CAAC;AACD,SAAS,cAAc,CAAC,KAAc;IAClC,OAAO,IAAA,yBAAc,EAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACjD,CAAC","sourcesContent":["import { Result } from \"effect\";\nimport { hydrateRecordAttachmentCurrent, } from \"../record/attachment/protocol.ts\";\nimport { mintRecordContentHandle, type RecordContentHandle, } from \"../record/attachment/content.ts\";\nimport { NiceEvalCurrentRecordAttachments, NiceEvalRecordAttachments, } from \"../record/family/current.ts\";\nimport type { PersistedContentMetadata, SealedAttachmentMetadata, } from \"../record/sqlite/index.ts\";\nimport { closeInspectionJson, isInspectionCodecError, type InspectionJson } from \"./codec.ts\";\nimport { InspectionSha256, utf8ByteLength } from \"./bytes.ts\";\nimport type { InspectionAssertionsRead } from \"./facts.ts\";\nimport { INSPECTION_RESULT_BYTE_LIMIT } from \"./limits.ts\";\nimport type { InspectionFactSource } from \"./source.ts\";\nimport type { InspectionSourcesResult } from \"./results.ts\";\nconst SOURCE_TEXT_BYTE_LIMIT = 256 * 1024;\nconst SOURCE_RESULT_HEADROOM = 1024;\nconst CONTENT_PAGE_SIZE = 64;\nexport interface SourcesAttachmentInput {\n readonly physical: SealedAttachmentMetadata;\n readonly value: InspectionJson;\n}\ninterface HydratedSourceItem {\n readonly sourceItemId: string;\n readonly path: string;\n readonly byteLength: number;\n readonly sha256: string;\n readonly content: RecordContentHandle;\n}\ninterface BoundSourceItem {\n readonly item: HydratedSourceItem;\n readonly content: PersistedContentMetadata;\n}\ntype AttachmentReadState = \"available\" | \"not-recorded\" | \"invalid\";\ninterface AvailableAssertions {\n readonly state: \"available\";\n readonly sourceSites: Extract<InspectionAssertionsRead, {\n readonly state: \"available\";\n }>[\"value\"][\"sourceSites\"];\n}\ninterface UnavailableAssertions {\n readonly state: \"not-recorded\" | \"invalid\";\n}\ntype AssertionsRead = AvailableAssertions | UnavailableAssertions;\ntype HydratedAssertionSourceSite = AvailableAssertions[\"sourceSites\"][number];\ninterface SourcePosition {\n readonly line: number;\n readonly column: number;\n}\nexport function projectAttemptSources(source: InspectionFactSource, attachment: SourcesAttachmentInput | undefined, assertions: InspectionAssertionsRead): InspectionSourcesResult {\n const assertionsRead = readAssertionSites(assertions);\n let state: AttachmentReadState = attachment === undefined ? \"not-recorded\" : \"available\";\n let decoded: readonly BoundSourceItem[] = [];\n if (attachment !== undefined) {\n try {\n decoded = hydrateSourceItems(attachment);\n }\n catch {\n state = \"invalid\";\n }\n }\n const items: InspectionSourcesResult[\"items\"][number][] = [];\n const requestedPositions = assertionSourcePositions(assertionsRead);\n const verifiedSourcePositions = new Map<string, ReadonlySet<string>>();\n let projectedBytes = jsonByteLength(Object.freeze({\n state,\n items: Object.freeze([]),\n hasMore: decoded.length > 0,\n omittedItemCount: decoded.length,\n }));\n let acceptProjectedItems = true;\n try {\n for (const entry of state === \"available\" ? decoded : []) {\n const omitted = projectedSourceItem(entry, omittedContent(entry.content.byteLength));\n const omittedBytes = jsonByteLength(omitted) + (items.length === 0 ? 0 : 1);\n const includeItem = acceptProjectedItems &&\n projectedBytes + omittedBytes <= INSPECTION_RESULT_BYTE_LIMIT - SOURCE_RESULT_HEADROOM;\n if (!includeItem)\n acceptProjectedItems = false;\n let projected = omitted;\n const positions = requestedPositions.get(entry.item.sourceItemId) ?? Object.freeze([]);\n const verified = positions.length > 0 || includeItem && entry.content.byteLength <= SOURCE_TEXT_BYTE_LIMIT\n ? readVerifiedSource(source, entry.content, positions)\n : undefined;\n if (verified !== undefined) {\n verifiedSourcePositions.set(entry.item.sourceItemId, verified.displayablePositions);\n }\n if (verified?.text !== undefined) {\n const available = projectedSourceItem(entry, Object.freeze({\n state: \"available\" as const,\n text: verified.text,\n }));\n const availableBytes = jsonByteLength(available) + (items.length === 0 ? 0 : 1);\n if (projectedBytes + availableBytes <= INSPECTION_RESULT_BYTE_LIMIT - SOURCE_RESULT_HEADROOM) {\n projected = available;\n }\n }\n if (!includeItem)\n continue;\n const itemBytes = jsonByteLength(projected) + (items.length === 0 ? 0 : 1);\n items.push(projected);\n projectedBytes += itemBytes;\n }\n }\n catch {\n state = \"invalid\";\n decoded = Object.freeze([]);\n items.splice(0, items.length);\n verifiedSourcePositions.clear();\n }\n const sourceItems = new Map(decoded.map((entry) => [entry.item.sourceItemId, entry] as const));\n const sites = assertionsRead.state === \"available\"\n ? assertionsRead.sourceSites.map((site) => projectAssertionSourceSite(site, state, sourceItems, verifiedSourcePositions))\n : [];\n let projectedSiteCount = sites.length;\n let result = sourceResult(state, items, decoded.length, assertionResult(assertionsRead, sites, projectedSiteCount));\n while (jsonByteLength(result) > INSPECTION_RESULT_BYTE_LIMIT && items.length > 0) {\n items.pop();\n result = sourceResult(state, items, decoded.length, assertionResult(assertionsRead, sites, projectedSiteCount));\n }\n while (jsonByteLength(result) > INSPECTION_RESULT_BYTE_LIMIT && projectedSiteCount > 0) {\n projectedSiteCount -= 1;\n result = sourceResult(state, items, decoded.length, assertionResult(assertionsRead, sites, projectedSiteCount));\n }\n if (jsonByteLength(result) > INSPECTION_RESULT_BYTE_LIMIT) {\n throw new Error(\"Sources projection cannot fit its fixed result byte limit\");\n }\n return result;\n}\nfunction assertionSourcePositions(assertions: AssertionsRead): ReadonlyMap<string, readonly SourcePosition[]> {\n const output = new Map<string, SourcePosition[]>();\n if (assertions.state !== \"available\")\n return output;\n for (const site of assertions.sourceSites) {\n const sourceItemId = site.source.value.sourceItemId;\n const positions = output.get(sourceItemId) ?? [];\n positions.push(site.start, site.end);\n output.set(sourceItemId, positions);\n }\n return new Map([...output].map(([sourceItemId, positions]) => [\n sourceItemId,\n Object.freeze(positions),\n ] as const));\n}\nfunction readAssertionSites(input: InspectionAssertionsRead): AssertionsRead {\n if (input.state === \"available\") {\n return Object.freeze({\n state: \"available\" as const,\n sourceSites: input.value.sourceSites,\n });\n }\n return Object.freeze({\n state: input.state === \"not-recorded\" ? \"not-recorded\" as const : \"invalid\" as const,\n });\n}\nfunction projectAssertionSourceSite(site: HydratedAssertionSourceSite, sourceState: AttachmentReadState, sourceItems: ReadonlyMap<string, BoundSourceItem>, verifiedSourcePositions: ReadonlyMap<string, ReadonlySet<string>>): Extract<InspectionSourcesResult[\"assertions\"], {\n readonly state: \"available\";\n}>[\"sourceSites\"][number] {\n const anchor = site.source.value;\n const item = sourceState === \"available\" ? sourceItems.get(anchor.sourceItemId) : undefined;\n const source = item === undefined || item.item.sha256 !== anchor.sha256\n ? unmappedSource(\"source-snapshot-not-recorded\")\n : !positionsAreDisplayable(verifiedSourcePositions.get(anchor.sourceItemId), site.start, site.end)\n ? unmappedSource(\"position-unrepresentable\")\n : Object.freeze({\n state: \"mapped\" as const,\n sourceItemId: anchor.sourceItemId,\n sha256: anchor.sha256,\n });\n return Object.freeze({\n entryId: site.entryId,\n sourceOrder: site.sourceOrder,\n role: site.role,\n start: Object.freeze({ line: site.start.line, column: site.start.column }),\n end: Object.freeze({ line: site.end.line, column: site.end.column }),\n source,\n });\n}\nfunction assertionResult(assertions: AssertionsRead, sites: readonly Extract<InspectionSourcesResult[\"assertions\"], {\n readonly state: \"available\";\n}>[\"sourceSites\"][number][], projectedSiteCount: number): InspectionSourcesResult[\"assertions\"] {\n if (assertions.state !== \"available\") {\n return Object.freeze({\n state: assertions.state,\n sourceSites: Object.freeze([] as const),\n hasMoreSourceSites: false as const,\n omittedSourceSiteCount: 0 as const,\n });\n }\n return Object.freeze({\n state: \"available\" as const,\n sourceSites: Object.freeze(sites.slice(0, projectedSiteCount)),\n hasMoreSourceSites: projectedSiteCount < sites.length,\n omittedSourceSiteCount: sites.length - projectedSiteCount,\n });\n}\nfunction unmappedSource(reason: \"source-snapshot-not-recorded\" | \"position-unrepresentable\"): Extract<Extract<InspectionSourcesResult[\"assertions\"], {\n readonly state: \"available\";\n}>[\"sourceSites\"][number][\"source\"], {\n readonly state: \"unmapped\";\n}> {\n return Object.freeze({ state: \"unmapped\" as const, reason });\n}\nfunction positionsAreDisplayable(positions: ReadonlySet<string> | undefined, start: SourcePosition, end: SourcePosition): boolean {\n return positions?.has(positionKey(start)) === true && positions.has(positionKey(end));\n}\nfunction positionKey(position: SourcePosition): string {\n return `${position.line}:${position.column}`;\n}\nfunction hydrateSourceItems(attachment: SourcesAttachmentInput): readonly BoundSourceItem[] {\n if (attachment.physical.ownerKind !== \"run\" ||\n attachment.physical.family !== NiceEvalRecordAttachments.sources.family ||\n attachment.physical.familyRevision !== NiceEvalCurrentRecordAttachments.sources.revision) {\n throw new Error(\"Sources Attachment requires migration before Inspection\");\n }\n const byLogicalHandle = new Map(attachment.physical.contents.map((content) => [content.logicalHandle, content] as const));\n const byHydratedHandle = new WeakMap<object, PersistedContentMetadata>();\n const usedLogicalHandles = new Set<string>();\n const hydrated = hydrateRecordAttachmentCurrent(NiceEvalRecordAttachments.sources, attachment.value, {\n content: (token, declaration) => {\n const logicalHandle = exactMarker(token, \"$niceeval.record.content\");\n if (logicalHandle === undefined && !hasOwnMarker(token, \"$niceeval.record.content\")) {\n return Result.succeed(undefined);\n }\n const metadata = typeof logicalHandle === \"string\"\n ? byLogicalHandle.get(logicalHandle)\n : undefined;\n if (metadata === undefined || declaration.kind !== \"text\" ||\n declaration.maximumBytes !== undefined && metadata.byteLength > declaration.maximumBytes ||\n usedLogicalHandles.has(logicalHandle as string)) {\n return Result.fail({ code: \"current-content-bind-failed\" as const });\n }\n const handle = mintRecordContentHandle(\"text\");\n byHydratedHandle.set(handle, metadata);\n usedLogicalHandles.add(logicalHandle as string);\n return Result.succeed(handle);\n },\n reference: () => Result.succeed(undefined),\n });\n if (Result.isFailure(hydrated) || usedLogicalHandles.size !== attachment.physical.contents.length) {\n throw new Error(\"Sources Attachment content closure is invalid\");\n }\n const output: BoundSourceItem[] = [];\n for (const item of hydrated.success.items as readonly HydratedSourceItem[]) {\n const metadata = byHydratedHandle.get(item.content);\n if (metadata === undefined || metadata.byteLength !== item.byteLength || metadata.digest !== item.sha256) {\n throw new Error(\"Sources Attachment item does not match its sealed Content metadata\");\n }\n output.push(Object.freeze({ item, content: metadata }));\n }\n return Object.freeze(output);\n}\nfunction readVerifiedSource(source: InspectionFactSource, metadata: PersistedContentMetadata, positions: readonly SourcePosition[]): {\n readonly text?: string;\n readonly displayablePositions: ReadonlySet<string>;\n} {\n const digest = new InspectionSha256();\n const decoder = new TextDecoder(\"utf-8\", { fatal: true });\n const retainText = metadata.byteLength <= SOURCE_TEXT_BYTE_LIMIT;\n const text: string[] = [];\n const positionsByLine = new Map<number, Set<number>>();\n for (const position of positions) {\n const columns = positionsByLine.get(position.line) ?? new Set<number>();\n columns.add(position.column - 1);\n positionsByLine.set(position.line, columns);\n }\n const displayablePositions = new Set<string>();\n let offset = 0;\n let afterOrdinal = -1;\n let expectedOrdinal = 0;\n let observedChunks = 0;\n let line = 1;\n let column = 0;\n const markPosition = (byte: number | undefined): void => {\n const columns = positionsByLine.get(line);\n if (columns?.has(column) !== true)\n return;\n if (byte === undefined || byte === 0x0a || (byte & 192) !== 128) {\n displayablePositions.add(`${line}:${column + 1}`);\n }\n };\n while (true) {\n const page = source.readContentPage(metadata.contentId, afterOrdinal, CONTENT_PAGE_SIZE);\n if (page.contentId !== metadata.contentId || page.afterOrdinal !== afterOrdinal ||\n page.chunks.length === 0 && page.nextOrdinal !== null) {\n throw new Error(\"Sources Content page is invalid\");\n }\n for (const chunk of page.chunks) {\n if (chunk.ordinal !== expectedOrdinal || offset + chunk.bytes.byteLength > metadata.byteLength) {\n throw new Error(\"Sources Content chunk sequence is invalid\");\n }\n digest.update(chunk.bytes);\n const decoded = decoder.decode(chunk.bytes, { stream: true });\n if (retainText)\n text.push(decoded);\n for (const byte of chunk.bytes) {\n markPosition(byte);\n if (byte === 0x0a) {\n line += 1;\n column = 0;\n }\n else {\n column += 1;\n }\n }\n offset += chunk.bytes.byteLength;\n expectedOrdinal += 1;\n observedChunks += 1;\n }\n if (page.nextOrdinal === null)\n break;\n if (page.nextOrdinal !== expectedOrdinal - 1 || observedChunks > metadata.chunkCount) {\n throw new Error(\"Sources Content continuation is invalid\");\n }\n afterOrdinal = page.nextOrdinal;\n }\n const finalText = decoder.decode();\n if (retainText)\n text.push(finalText);\n markPosition(undefined);\n if (offset !== metadata.byteLength || observedChunks !== metadata.chunkCount ||\n digest.digestHex() !== metadata.digest) {\n throw new Error(\"Sources Content does not match its sealed metadata\");\n }\n return Object.freeze({\n ...(retainText ? { text: text.join(\"\") } : {}),\n displayablePositions,\n });\n}\nfunction projectedSourceItem(entry: BoundSourceItem, content: InspectionSourcesResult[\"items\"][number][\"content\"]): InspectionSourcesResult[\"items\"][number] {\n return Object.freeze({\n sourceItemId: entry.item.sourceItemId,\n path: entry.item.path,\n byteLength: entry.item.byteLength,\n sha256: entry.item.sha256,\n content,\n });\n}\nfunction omittedContent(byteLength: number): InspectionSourcesResult[\"items\"][number][\"content\"] {\n return Object.freeze({\n state: \"omitted\" as const,\n reason: \"inspection-result-byte-limit\" as const,\n byteLength,\n byteLimit: SOURCE_TEXT_BYTE_LIMIT,\n });\n}\nfunction sourceResult(state: AttachmentReadState, items: readonly InspectionSourcesResult[\"items\"][number][], total: number, assertions: InspectionSourcesResult[\"assertions\"]): InspectionSourcesResult {\n return Object.freeze({\n state,\n items: Object.freeze([...items]),\n hasMore: items.length < total,\n omittedItemCount: total - items.length,\n assertions,\n });\n}\nfunction exactMarker(value: unknown, key: string): unknown | undefined {\n if (typeof value !== \"object\" || value === null || Array.isArray(value))\n return undefined;\n const keys = Reflect.ownKeys(value);\n if (keys.length !== 1 || keys[0] !== key)\n return undefined;\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n return descriptor !== undefined && descriptor.enumerable && \"value\" in descriptor\n ? descriptor.value\n : undefined;\n}\nfunction hasOwnMarker(value: unknown, key: string): boolean {\n return typeof value === \"object\" && value !== null && !Array.isArray(value) &&\n Object.prototype.hasOwnProperty.call(value, key);\n}\nfunction closeJson(value: unknown): InspectionJson {\n const closed = closeInspectionJson(value);\n if (isInspectionCodecError(closed))\n throw closed;\n return closed as InspectionJson;\n}\nfunction jsonByteLength(value: unknown): number {\n return utf8ByteLength(JSON.stringify(value));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sources.js","sourceRoot":"","sources":["sources.ts"],"names":[],"mappings":";;AAkDA,sDA+EC;AAjID,2CAA2C;AAC3C,wDAAwD;AACxD,8DAA8D;AAC9D,mCAAgC;AAChC,kEAAmF;AACnF,gEAAqG;AACrG,4DAA2G;AAE3G,yCAA8F;AAC9F,yCAA8D;AAE9D,2CAA2D;AAG3D,MAAM,sBAAsB,GAAG,GAAG,GAAG,IAAI,CAAC;AAC1C,MAAM,sBAAsB,GAAG,IAAI,CAAC;AACpC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAgC7B,mDAAmD;AACnD,8DAA8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CAAC,OAAO,CAAC,KAAK,CAAC;QACnE,OAAO,SAAS,CAAC;IACrB,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACpC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG;QACpC,OAAO,SAAS,CAAC;IACrB,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC/D,OAAO,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,UAAU,IAAI,OAAO,IAAI,UAAU;QAC7E,CAAC,CAAC,UAAU,CAAC,KAAK;QAClB,CAAC,CAAC,SAAS,CAAC;AACpB,CAAC;AACD,SAAS,YAAY,CAAC,KAAc,EAAE,GAAW;IAC7C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACvE,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACzD,CAAC;AACD,SAAS,SAAS,CAAC,KAAc;IAC7B,MAAM,MAAM,GAAG,IAAA,8BAAmB,EAAC,KAAK,CAAC,CAAC;IAC1C,IAAI,IAAA,iCAAsB,EAAC,MAAM,CAAC;QAC9B,MAAM,MAAM,CAAC;IACjB,OAAO,MAAwB,CAAC;AACpC,CAAC;AACD,SAAS,cAAc,CAAC,KAAc;IAClC,OAAO,IAAA,yBAAc,EAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACjD,CAAC","sourcesContent":["// @concord-file ne-eval-inspection-sources\n// @concord-implements docs/feature/inspection/README.md\n// @concord-implements docs/feature/inspection/architecture.md\nimport { Result } from \"effect\";\nimport { hydrateRecordAttachmentCurrent, } from \"../record/attachment/protocol.ts\";\nimport { mintRecordContentHandle, type RecordContentHandle, } from \"../record/attachment/content.ts\";\nimport { NiceEvalCurrentRecordAttachments, NiceEvalRecordAttachments, } from \"../record/family/current.ts\";\nimport type { PersistedContentMetadata, SealedAttachmentMetadata, } from \"../record/sqlite/index.ts\";\nimport { closeInspectionJson, isInspectionCodecError, type InspectionJson } from \"./codec.ts\";\nimport { InspectionSha256, utf8ByteLength } from \"./bytes.ts\";\nimport type { InspectionAssertionsRead } from \"./facts.ts\";\nimport { INSPECTION_RESULT_BYTE_LIMIT } from \"./limits.ts\";\nimport type { InspectionFactSource } from \"./source.ts\";\nimport type { InspectionSourcesResult } from \"./results.ts\";\nconst SOURCE_TEXT_BYTE_LIMIT = 256 * 1024;\nconst SOURCE_RESULT_HEADROOM = 1024;\nconst CONTENT_PAGE_SIZE = 64;\nexport interface SourcesAttachmentInput {\n readonly physical: SealedAttachmentMetadata;\n readonly value: InspectionJson;\n}\ninterface HydratedSourceItem {\n readonly sourceItemId: string;\n readonly path: string;\n readonly byteLength: number;\n readonly sha256: string;\n readonly content: RecordContentHandle;\n}\ninterface BoundSourceItem {\n readonly item: HydratedSourceItem;\n readonly content: PersistedContentMetadata;\n}\ntype AttachmentReadState = \"available\" | \"not-recorded\" | \"invalid\";\ninterface AvailableAssertions {\n readonly state: \"available\";\n readonly sourceSites: Extract<InspectionAssertionsRead, {\n readonly state: \"available\";\n }>[\"value\"][\"sourceSites\"];\n}\ninterface UnavailableAssertions {\n readonly state: \"not-recorded\" | \"invalid\";\n}\ntype AssertionsRead = AvailableAssertions | UnavailableAssertions;\ntype HydratedAssertionSourceSite = AvailableAssertions[\"sourceSites\"][number];\ninterface SourcePosition {\n readonly line: number;\n readonly column: number;\n}\n// @concord-code ne-eval-inspection-project-sources\n// @concord-implements docs/feature/inspection/architecture.md\nexport function projectAttemptSources(source: InspectionFactSource, attachment: SourcesAttachmentInput | undefined, assertions: InspectionAssertionsRead): InspectionSourcesResult {\n const assertionsRead = readAssertionSites(assertions);\n let state: AttachmentReadState = attachment === undefined ? \"not-recorded\" : \"available\";\n let decoded: readonly BoundSourceItem[] = [];\n if (attachment !== undefined) {\n try {\n decoded = hydrateSourceItems(attachment);\n }\n catch {\n state = \"invalid\";\n }\n }\n const items: InspectionSourcesResult[\"items\"][number][] = [];\n const requestedPositions = assertionSourcePositions(assertionsRead);\n const verifiedSourcePositions = new Map<string, ReadonlySet<string>>();\n let projectedBytes = jsonByteLength(Object.freeze({\n state,\n items: Object.freeze([]),\n hasMore: decoded.length > 0,\n omittedItemCount: decoded.length,\n }));\n let acceptProjectedItems = true;\n try {\n for (const entry of state === \"available\" ? decoded : []) {\n const omitted = projectedSourceItem(entry, omittedContent(entry.content.byteLength));\n const omittedBytes = jsonByteLength(omitted) + (items.length === 0 ? 0 : 1);\n const includeItem = acceptProjectedItems &&\n projectedBytes + omittedBytes <= INSPECTION_RESULT_BYTE_LIMIT - SOURCE_RESULT_HEADROOM;\n if (!includeItem)\n acceptProjectedItems = false;\n let projected = omitted;\n const positions = requestedPositions.get(entry.item.sourceItemId) ?? Object.freeze([]);\n const verified = positions.length > 0 || includeItem && entry.content.byteLength <= SOURCE_TEXT_BYTE_LIMIT\n ? readVerifiedSource(source, entry.content, positions)\n : undefined;\n if (verified !== undefined) {\n verifiedSourcePositions.set(entry.item.sourceItemId, verified.displayablePositions);\n }\n if (verified?.text !== undefined) {\n const available = projectedSourceItem(entry, Object.freeze({\n state: \"available\" as const,\n text: verified.text,\n }));\n const availableBytes = jsonByteLength(available) + (items.length === 0 ? 0 : 1);\n if (projectedBytes + availableBytes <= INSPECTION_RESULT_BYTE_LIMIT - SOURCE_RESULT_HEADROOM) {\n projected = available;\n }\n }\n if (!includeItem)\n continue;\n const itemBytes = jsonByteLength(projected) + (items.length === 0 ? 0 : 1);\n items.push(projected);\n projectedBytes += itemBytes;\n }\n }\n catch {\n state = \"invalid\";\n decoded = Object.freeze([]);\n items.splice(0, items.length);\n verifiedSourcePositions.clear();\n }\n const sourceItems = new Map(decoded.map((entry) => [entry.item.sourceItemId, entry] as const));\n const sites = assertionsRead.state === \"available\"\n ? assertionsRead.sourceSites.map((site) => projectAssertionSourceSite(site, state, sourceItems, verifiedSourcePositions))\n : [];\n let projectedSiteCount = sites.length;\n let result = sourceResult(state, items, decoded.length, assertionResult(assertionsRead, sites, projectedSiteCount));\n while (jsonByteLength(result) > INSPECTION_RESULT_BYTE_LIMIT && items.length > 0) {\n items.pop();\n result = sourceResult(state, items, decoded.length, assertionResult(assertionsRead, sites, projectedSiteCount));\n }\n while (jsonByteLength(result) > INSPECTION_RESULT_BYTE_LIMIT && projectedSiteCount > 0) {\n projectedSiteCount -= 1;\n result = sourceResult(state, items, decoded.length, assertionResult(assertionsRead, sites, projectedSiteCount));\n }\n if (jsonByteLength(result) > INSPECTION_RESULT_BYTE_LIMIT) {\n throw new Error(\"Sources projection cannot fit its fixed result byte limit\");\n }\n return result;\n}\nfunction assertionSourcePositions(assertions: AssertionsRead): ReadonlyMap<string, readonly SourcePosition[]> {\n const output = new Map<string, SourcePosition[]>();\n if (assertions.state !== \"available\")\n return output;\n for (const site of assertions.sourceSites) {\n const sourceItemId = site.source.value.sourceItemId;\n const positions = output.get(sourceItemId) ?? [];\n positions.push(site.start, site.end);\n output.set(sourceItemId, positions);\n }\n return new Map([...output].map(([sourceItemId, positions]) => [\n sourceItemId,\n Object.freeze(positions),\n ] as const));\n}\nfunction readAssertionSites(input: InspectionAssertionsRead): AssertionsRead {\n if (input.state === \"available\") {\n return Object.freeze({\n state: \"available\" as const,\n sourceSites: input.value.sourceSites,\n });\n }\n return Object.freeze({\n state: input.state === \"not-recorded\" ? \"not-recorded\" as const : \"invalid\" as const,\n });\n}\nfunction projectAssertionSourceSite(site: HydratedAssertionSourceSite, sourceState: AttachmentReadState, sourceItems: ReadonlyMap<string, BoundSourceItem>, verifiedSourcePositions: ReadonlyMap<string, ReadonlySet<string>>): Extract<InspectionSourcesResult[\"assertions\"], {\n readonly state: \"available\";\n}>[\"sourceSites\"][number] {\n const anchor = site.source.value;\n const item = sourceState === \"available\" ? sourceItems.get(anchor.sourceItemId) : undefined;\n const source = item === undefined || item.item.sha256 !== anchor.sha256\n ? unmappedSource(\"source-snapshot-not-recorded\")\n : !positionsAreDisplayable(verifiedSourcePositions.get(anchor.sourceItemId), site.start, site.end)\n ? unmappedSource(\"position-unrepresentable\")\n : Object.freeze({\n state: \"mapped\" as const,\n sourceItemId: anchor.sourceItemId,\n sha256: anchor.sha256,\n });\n return Object.freeze({\n entryId: site.entryId,\n sourceOrder: site.sourceOrder,\n role: site.role,\n start: Object.freeze({ line: site.start.line, column: site.start.column }),\n end: Object.freeze({ line: site.end.line, column: site.end.column }),\n source,\n });\n}\nfunction assertionResult(assertions: AssertionsRead, sites: readonly Extract<InspectionSourcesResult[\"assertions\"], {\n readonly state: \"available\";\n}>[\"sourceSites\"][number][], projectedSiteCount: number): InspectionSourcesResult[\"assertions\"] {\n if (assertions.state !== \"available\") {\n return Object.freeze({\n state: assertions.state,\n sourceSites: Object.freeze([] as const),\n hasMoreSourceSites: false as const,\n omittedSourceSiteCount: 0 as const,\n });\n }\n return Object.freeze({\n state: \"available\" as const,\n sourceSites: Object.freeze(sites.slice(0, projectedSiteCount)),\n hasMoreSourceSites: projectedSiteCount < sites.length,\n omittedSourceSiteCount: sites.length - projectedSiteCount,\n });\n}\nfunction unmappedSource(reason: \"source-snapshot-not-recorded\" | \"position-unrepresentable\"): Extract<Extract<InspectionSourcesResult[\"assertions\"], {\n readonly state: \"available\";\n}>[\"sourceSites\"][number][\"source\"], {\n readonly state: \"unmapped\";\n}> {\n return Object.freeze({ state: \"unmapped\" as const, reason });\n}\nfunction positionsAreDisplayable(positions: ReadonlySet<string> | undefined, start: SourcePosition, end: SourcePosition): boolean {\n return positions?.has(positionKey(start)) === true && positions.has(positionKey(end));\n}\nfunction positionKey(position: SourcePosition): string {\n return `${position.line}:${position.column}`;\n}\nfunction hydrateSourceItems(attachment: SourcesAttachmentInput): readonly BoundSourceItem[] {\n if (attachment.physical.ownerKind !== \"run\" ||\n attachment.physical.family !== NiceEvalRecordAttachments.sources.family ||\n attachment.physical.familyRevision !== NiceEvalCurrentRecordAttachments.sources.revision) {\n throw new Error(\"Sources Attachment requires migration before Inspection\");\n }\n const byLogicalHandle = new Map(attachment.physical.contents.map((content) => [content.logicalHandle, content] as const));\n const byHydratedHandle = new WeakMap<object, PersistedContentMetadata>();\n const usedLogicalHandles = new Set<string>();\n const hydrated = hydrateRecordAttachmentCurrent(NiceEvalRecordAttachments.sources, attachment.value, {\n content: (token, declaration) => {\n const logicalHandle = exactMarker(token, \"$niceeval.record.content\");\n if (logicalHandle === undefined && !hasOwnMarker(token, \"$niceeval.record.content\")) {\n return Result.succeed(undefined);\n }\n const metadata = typeof logicalHandle === \"string\"\n ? byLogicalHandle.get(logicalHandle)\n : undefined;\n if (metadata === undefined || declaration.kind !== \"text\" ||\n declaration.maximumBytes !== undefined && metadata.byteLength > declaration.maximumBytes ||\n usedLogicalHandles.has(logicalHandle as string)) {\n return Result.fail({ code: \"current-content-bind-failed\" as const });\n }\n const handle = mintRecordContentHandle(\"text\");\n byHydratedHandle.set(handle, metadata);\n usedLogicalHandles.add(logicalHandle as string);\n return Result.succeed(handle);\n },\n reference: () => Result.succeed(undefined),\n });\n if (Result.isFailure(hydrated) || usedLogicalHandles.size !== attachment.physical.contents.length) {\n throw new Error(\"Sources Attachment content closure is invalid\");\n }\n const output: BoundSourceItem[] = [];\n for (const item of hydrated.success.items as readonly HydratedSourceItem[]) {\n const metadata = byHydratedHandle.get(item.content);\n if (metadata === undefined || metadata.byteLength !== item.byteLength || metadata.digest !== item.sha256) {\n throw new Error(\"Sources Attachment item does not match its sealed Content metadata\");\n }\n output.push(Object.freeze({ item, content: metadata }));\n }\n return Object.freeze(output);\n}\nfunction readVerifiedSource(source: InspectionFactSource, metadata: PersistedContentMetadata, positions: readonly SourcePosition[]): {\n readonly text?: string;\n readonly displayablePositions: ReadonlySet<string>;\n} {\n const digest = new InspectionSha256();\n const decoder = new TextDecoder(\"utf-8\", { fatal: true });\n const retainText = metadata.byteLength <= SOURCE_TEXT_BYTE_LIMIT;\n const text: string[] = [];\n const positionsByLine = new Map<number, Set<number>>();\n for (const position of positions) {\n const columns = positionsByLine.get(position.line) ?? new Set<number>();\n columns.add(position.column - 1);\n positionsByLine.set(position.line, columns);\n }\n const displayablePositions = new Set<string>();\n let offset = 0;\n let afterOrdinal = -1;\n let expectedOrdinal = 0;\n let observedChunks = 0;\n let line = 1;\n let column = 0;\n const markPosition = (byte: number | undefined): void => {\n const columns = positionsByLine.get(line);\n if (columns?.has(column) !== true)\n return;\n if (byte === undefined || byte === 0x0a || (byte & 192) !== 128) {\n displayablePositions.add(`${line}:${column + 1}`);\n }\n };\n while (true) {\n const page = source.readContentPage(metadata.contentId, afterOrdinal, CONTENT_PAGE_SIZE);\n if (page.contentId !== metadata.contentId || page.afterOrdinal !== afterOrdinal ||\n page.chunks.length === 0 && page.nextOrdinal !== null) {\n throw new Error(\"Sources Content page is invalid\");\n }\n for (const chunk of page.chunks) {\n if (chunk.ordinal !== expectedOrdinal || offset + chunk.bytes.byteLength > metadata.byteLength) {\n throw new Error(\"Sources Content chunk sequence is invalid\");\n }\n digest.update(chunk.bytes);\n const decoded = decoder.decode(chunk.bytes, { stream: true });\n if (retainText)\n text.push(decoded);\n for (const byte of chunk.bytes) {\n markPosition(byte);\n if (byte === 0x0a) {\n line += 1;\n column = 0;\n }\n else {\n column += 1;\n }\n }\n offset += chunk.bytes.byteLength;\n expectedOrdinal += 1;\n observedChunks += 1;\n }\n if (page.nextOrdinal === null)\n break;\n if (page.nextOrdinal !== expectedOrdinal - 1 || observedChunks > metadata.chunkCount) {\n throw new Error(\"Sources Content continuation is invalid\");\n }\n afterOrdinal = page.nextOrdinal;\n }\n const finalText = decoder.decode();\n if (retainText)\n text.push(finalText);\n markPosition(undefined);\n if (offset !== metadata.byteLength || observedChunks !== metadata.chunkCount ||\n digest.digestHex() !== metadata.digest) {\n throw new Error(\"Sources Content does not match its sealed metadata\");\n }\n return Object.freeze({\n ...(retainText ? { text: text.join(\"\") } : {}),\n displayablePositions,\n });\n}\nfunction projectedSourceItem(entry: BoundSourceItem, content: InspectionSourcesResult[\"items\"][number][\"content\"]): InspectionSourcesResult[\"items\"][number] {\n return Object.freeze({\n sourceItemId: entry.item.sourceItemId,\n path: entry.item.path,\n byteLength: entry.item.byteLength,\n sha256: entry.item.sha256,\n content,\n });\n}\nfunction omittedContent(byteLength: number): InspectionSourcesResult[\"items\"][number][\"content\"] {\n return Object.freeze({\n state: \"omitted\" as const,\n reason: \"inspection-result-byte-limit\" as const,\n byteLength,\n byteLimit: SOURCE_TEXT_BYTE_LIMIT,\n });\n}\nfunction sourceResult(state: AttachmentReadState, items: readonly InspectionSourcesResult[\"items\"][number][], total: number, assertions: InspectionSourcesResult[\"assertions\"]): InspectionSourcesResult {\n return Object.freeze({\n state,\n items: Object.freeze([...items]),\n hasMore: items.length < total,\n omittedItemCount: total - items.length,\n assertions,\n });\n}\nfunction exactMarker(value: unknown, key: string): unknown | undefined {\n if (typeof value !== \"object\" || value === null || Array.isArray(value))\n return undefined;\n const keys = Reflect.ownKeys(value);\n if (keys.length !== 1 || keys[0] !== key)\n return undefined;\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n return descriptor !== undefined && descriptor.enumerable && \"value\" in descriptor\n ? descriptor.value\n : undefined;\n}\nfunction hasOwnMarker(value: unknown, key: string): boolean {\n return typeof value === \"object\" && value !== null && !Array.isArray(value) &&\n Object.prototype.hasOwnProperty.call(value, key);\n}\nfunction closeJson(value: unknown): InspectionJson {\n const closed = closeInspectionJson(value);\n if (isInspectionCodecError(closed))\n throw closed;\n return closed as InspectionJson;\n}\nfunction jsonByteLength(value: unknown): number {\n return utf8ByteLength(JSON.stringify(value));\n}\n"]}
|
|
@@ -8,6 +8,11 @@ exports.projectAdapterUsageTokens = projectAdapterUsageTokens;
|
|
|
8
8
|
exports.unavailableInspectionUsageTotals = unavailableInspectionUsageTotals;
|
|
9
9
|
exports.combineInspectionUsageTotals = combineInspectionUsageTotals;
|
|
10
10
|
exports.projectAttemptTiming = projectAttemptTiming;
|
|
11
|
+
// @concord-file ne-eval-inspection-trace
|
|
12
|
+
// @concord-implements docs/feature/inspection/README.md
|
|
13
|
+
// @concord-implements docs/feature/insight/README.md
|
|
14
|
+
const adapter_usage_projection_ts_1 = require("../o11y/adapter-usage-projection.cjs");
|
|
15
|
+
const judge_usage_projection_ts_1 = require("../o11y/judge-usage-projection.cjs");
|
|
11
16
|
const effect_1 = require("effect");
|
|
12
17
|
const content_ts_1 = require("../record/attachment/content.cjs");
|
|
13
18
|
const protocol_ts_1 = require("../record/attachment/protocol.cjs");
|
|
@@ -36,6 +41,9 @@ const MAX_COMMAND_ARGUMENT_BYTES = 128;
|
|
|
36
41
|
const MAX_COMMAND_STREAM_TEXT_BYTES = 1024;
|
|
37
42
|
const MAX_DIAGNOSTIC_SUMMARY_BYTES = 256;
|
|
38
43
|
const MAX_DIAGNOSTIC_CAUSE_BYTES = 128;
|
|
44
|
+
// @concord-code ne-eval-inspection-project-trace
|
|
45
|
+
// @concord-implements docs/feature/inspection/README.md
|
|
46
|
+
// @concord-implements docs/feature/insight/README.md
|
|
39
47
|
function projectAttemptTrace(source, attachments, execution, executionFilters = {}) {
|
|
40
48
|
const agentTurns = readCurrentAttachment(current_ts_1.NiceEvalCurrentRecordAttachments.agentTurns, attachments.agentTurns);
|
|
41
49
|
const turnContexts = readCurrentAttachment(current_ts_1.NiceEvalCurrentRecordAttachments.turnContexts, attachments.turnContexts);
|
|
@@ -140,6 +148,7 @@ function projectAgentItemsAsExecution(source, attachment, agentTurns, state, req
|
|
|
140
148
|
...(request.traceId === undefined ? {} : { traceId: request.traceId }),
|
|
141
149
|
...(request.sourceId === undefined ? {} : { sourceId: request.sourceId }),
|
|
142
150
|
...(request.actorId === undefined ? {} : { actorId: request.actorId }),
|
|
151
|
+
...(request.eventType === undefined ? {} : { eventType: request.eventType }),
|
|
143
152
|
});
|
|
144
153
|
const continuationContext = Object.freeze({
|
|
145
154
|
source,
|
|
@@ -216,6 +225,8 @@ function projectAgentItemsAsExecution(source, attachment, agentTurns, state, req
|
|
|
216
225
|
const actorId = rawItem.kind === "message" ? rawItem.role : "assistant";
|
|
217
226
|
if (filters.actorId !== undefined && actorId !== filters.actorId)
|
|
218
227
|
continue;
|
|
228
|
+
if (filters.eventType !== undefined && `agent.${rawItem.kind}` !== filters.eventType)
|
|
229
|
+
continue;
|
|
219
230
|
totalMatching += 1;
|
|
220
231
|
if (ordinal <= resumeAfter) {
|
|
221
232
|
priorMatches += 1;
|
|
@@ -238,6 +249,7 @@ function projectAgentItemsAsExecution(source, attachment, agentTurns, state, req
|
|
|
238
249
|
links: Object.freeze([]),
|
|
239
250
|
evidence: Object.freeze([]),
|
|
240
251
|
scopeMemberships: Object.freeze([]),
|
|
252
|
+
display: Object.freeze({ state: "absent" }),
|
|
241
253
|
});
|
|
242
254
|
if ((0, bytes_ts_1.utf8ByteLength)(JSON.stringify([...retained.map(({ event: prior }) => prior), event])) >
|
|
243
255
|
schema_ts_2.ExecutionTraceRecordLimits.maximumOutlineBytes) {
|
|
@@ -254,7 +266,7 @@ function projectAgentItemsAsExecution(source, attachment, agentTurns, state, req
|
|
|
254
266
|
return Object.freeze({
|
|
255
267
|
state,
|
|
256
268
|
limitations,
|
|
257
|
-
traces: traceSelected
|
|
269
|
+
traces: traceSelected
|
|
258
270
|
? Object.freeze([Object.freeze({
|
|
259
271
|
kind: "trace-header",
|
|
260
272
|
traceId,
|
|
@@ -267,7 +279,7 @@ function projectAgentItemsAsExecution(source, attachment, agentTurns, state, req
|
|
|
267
279
|
limitations: [{ code: "legacy-source-state", message: "The Agent Turns source is partial." }],
|
|
268
280
|
}),
|
|
269
281
|
scopes: Object.freeze([]),
|
|
270
|
-
eventCount:
|
|
282
|
+
eventCount: totalSourceEvents,
|
|
271
283
|
})])
|
|
272
284
|
: Object.freeze([]),
|
|
273
285
|
events: Object.freeze(events),
|
|
@@ -716,10 +728,16 @@ function readCurrentAttachment(persistence, attachment) {
|
|
|
716
728
|
function invalidRead(issue) {
|
|
717
729
|
return Object.freeze({ state: "invalid", issues: Object.freeze([issue]) });
|
|
718
730
|
}
|
|
719
|
-
/**
|
|
720
|
-
function readAdapterUsageAttachment(attachment) {
|
|
721
|
-
if (attachment?.physical.familyRevision !== 1
|
|
722
|
-
|
|
731
|
+
/** Historical revisions are decoded independently, then projected without rewriting sealed bytes. */
|
|
732
|
+
function readAdapterUsageAttachment(attachment, models) {
|
|
733
|
+
if (attachment?.physical.familyRevision !== 1 && attachment?.physical.familyRevision !== 2 &&
|
|
734
|
+
attachment?.physical.familyRevision !== 3) {
|
|
735
|
+
const read = readCurrentAttachment(current_ts_1.NiceEvalCurrentRecordAttachments.adapterUsage, attachment);
|
|
736
|
+
if (read.state === "available" && read.value.calls.some((call) => call.modelSlot !== null &&
|
|
737
|
+
(models === undefined || !Object.hasOwn(models, call.modelSlot)))) {
|
|
738
|
+
return invalidRead("source-model-slot-invalid");
|
|
739
|
+
}
|
|
740
|
+
return read;
|
|
723
741
|
}
|
|
724
742
|
if (attachment.physical.ownerKind !== current_ts_1.NiceEvalCurrentRecordAttachments.adapterUsage.attachment.owner ||
|
|
725
743
|
attachment.physical.family !== current_ts_1.NiceEvalCurrentRecordAttachments.adapterUsage.attachment.family)
|
|
@@ -727,10 +745,29 @@ function readAdapterUsageAttachment(attachment) {
|
|
|
727
745
|
if (attachment.physical.contents.length !== 0 || attachment.physical.references.length !== 0) {
|
|
728
746
|
return invalidRead("source-closure-invalid");
|
|
729
747
|
}
|
|
730
|
-
|
|
731
|
-
if (
|
|
732
|
-
|
|
733
|
-
|
|
748
|
+
let projected;
|
|
749
|
+
if (attachment.physical.familyRevision === 1) {
|
|
750
|
+
const decoded = effect_1.Schema.decodeUnknownResult(schema_ts_1.AdapterUsageAttachmentRevision1Schema, core_ts_1.RecordExactParseOptions)(attachment.value);
|
|
751
|
+
if (effect_1.Result.isFailure(decoded))
|
|
752
|
+
return invalidRead("source-attachment-invalid");
|
|
753
|
+
projected = (0, schema_ts_1.projectAdapterUsageRevision1)(decoded.success);
|
|
754
|
+
}
|
|
755
|
+
else if (attachment.physical.familyRevision === 2) {
|
|
756
|
+
const decoded = effect_1.Schema.decodeUnknownResult(schema_ts_1.AdapterUsageAttachmentRevision2Schema, core_ts_1.RecordExactParseOptions)(attachment.value);
|
|
757
|
+
if (effect_1.Result.isFailure(decoded))
|
|
758
|
+
return invalidRead("source-attachment-invalid");
|
|
759
|
+
projected = (0, schema_ts_1.projectAdapterUsageRevision2)(decoded.success);
|
|
760
|
+
}
|
|
761
|
+
else {
|
|
762
|
+
const decoded = effect_1.Schema.decodeUnknownResult(schema_ts_1.AdapterUsageAttachmentSchema, core_ts_1.RecordExactParseOptions)(attachment.value);
|
|
763
|
+
if (effect_1.Result.isFailure(decoded))
|
|
764
|
+
return invalidRead("source-attachment-invalid");
|
|
765
|
+
projected = decoded.success;
|
|
766
|
+
if (projected.calls.some((call) => call.modelSlot !== null &&
|
|
767
|
+
(models === undefined || !Object.hasOwn(models, call.modelSlot)))) {
|
|
768
|
+
return invalidRead("source-model-slot-invalid");
|
|
769
|
+
}
|
|
770
|
+
}
|
|
734
771
|
if ((0, schema_ts_1.validateAdapterUsageAttachment)(projected).length > 0) {
|
|
735
772
|
return invalidRead("source-attachment-invalid");
|
|
736
773
|
}
|
|
@@ -1052,9 +1089,23 @@ function projectConversationItem(item, turnId, sessionId) {
|
|
|
1052
1089
|
}));
|
|
1053
1090
|
}
|
|
1054
1091
|
}
|
|
1055
|
-
function projectAttemptUsage(attachments) {
|
|
1092
|
+
function projectAttemptUsage(attachments, models = attachments.models) {
|
|
1093
|
+
const usage = projectApplicationUsage(attachments, models);
|
|
1094
|
+
const read = readCurrentAttachment(current_ts_1.NiceEvalCurrentRecordAttachments.judgeUsage, attachments.judgeUsage);
|
|
1095
|
+
const judgeUsage = read.state === "available" ? (0, judge_usage_projection_ts_1.projectJudgeUsage)(read.value)
|
|
1096
|
+
: read.state === "invalid" ? Object.freeze({ state: "invalid", reason: "judge-usage-source-invalid" })
|
|
1097
|
+
: Object.freeze({ state: "unavailable", reason: "judge-usage-not-recorded" });
|
|
1098
|
+
const applicationEmptyComplete = attachments.adapterUsage !== undefined &&
|
|
1099
|
+
usage.totals.requests.state === "available" && usage.totals.requests.value === 0 && usage.totals.costs?.totalCalls === 0;
|
|
1100
|
+
return Object.freeze({ ...usage, judgeUsage,
|
|
1101
|
+
totalCosts: (0, judge_usage_projection_ts_1.projectTotalUsageCosts)(usage.totals, judgeUsage, applicationEmptyComplete, attachments.adapterUsage === undefined || attachments.adapterUsage.physical.familyRevision === 4) });
|
|
1102
|
+
}
|
|
1103
|
+
function projectApplicationUsage(attachments, models) {
|
|
1056
1104
|
if (attachments.adapterUsage !== undefined) {
|
|
1057
|
-
const read = readAdapterUsageAttachment(attachments.adapterUsage);
|
|
1105
|
+
const read = readAdapterUsageAttachment(attachments.adapterUsage, models);
|
|
1106
|
+
const modelUsage = (0, adapter_usage_projection_ts_1.projectAdapterModelUsage)(read.state === "available" ? read.value : null, models, {
|
|
1107
|
+
basis: "recorded-calls", reason: read.state === "invalid" ? "source-invalid" : "usage-not-recorded",
|
|
1108
|
+
});
|
|
1058
1109
|
const empty = {
|
|
1059
1110
|
source: "adapter",
|
|
1060
1111
|
coverage: "recorded-calls",
|
|
@@ -1067,34 +1118,16 @@ function projectAttemptUsage(attachments) {
|
|
|
1067
1118
|
inputTokens: { state: "unavailable", value: null, observationCount: 0 },
|
|
1068
1119
|
outputTokens: { state: "unavailable", value: null, observationCount: 0 },
|
|
1069
1120
|
requests: { state: "unavailable", value: null, observationCount: 0 },
|
|
1070
|
-
costs: effectiveCostTotals([], "partial"),
|
|
1121
|
+
costs: (0, adapter_usage_projection_ts_1.effectiveCostTotals)([], "partial"),
|
|
1071
1122
|
}, hasMore: false, omittedObservationCount: 0,
|
|
1072
1123
|
};
|
|
1073
1124
|
if (read.state !== "available")
|
|
1074
1125
|
return {
|
|
1075
|
-
...empty,
|
|
1126
|
+
...empty, ...modelUsage,
|
|
1127
|
+
state: read.state, limitations: read.state === "invalid" ? read.issues.map((issue) => ({ issue })) : [],
|
|
1076
1128
|
};
|
|
1077
1129
|
const all = read.value.calls;
|
|
1078
|
-
const
|
|
1079
|
-
const calls = all.map((call) => {
|
|
1080
|
-
const receipt = receipts.get(call.callId);
|
|
1081
|
-
const effectiveCost = call.cost !== null
|
|
1082
|
-
? Object.freeze({
|
|
1083
|
-
amount: call.cost.amount,
|
|
1084
|
-
currency: call.cost.currency,
|
|
1085
|
-
source: call.cost.source,
|
|
1086
|
-
state: "complete",
|
|
1087
|
-
})
|
|
1088
|
-
: receipt === undefined
|
|
1089
|
-
? null
|
|
1090
|
-
: Object.freeze({
|
|
1091
|
-
amount: receipt.amount,
|
|
1092
|
-
currency: receipt.currency,
|
|
1093
|
-
source: receipt.source,
|
|
1094
|
-
state: receipt.state,
|
|
1095
|
-
});
|
|
1096
|
-
return Object.freeze({ ...call, effectiveCost });
|
|
1097
|
-
});
|
|
1130
|
+
const calls = (0, adapter_usage_projection_ts_1.effectiveUsageCalls)(read.value);
|
|
1098
1131
|
const numeric = (key) => {
|
|
1099
1132
|
const known = all.flatMap((call) => call[key] === null ? [] : [call[key]]);
|
|
1100
1133
|
const sum = known.reduce((total, value) => total + value, 0);
|
|
@@ -1113,8 +1146,10 @@ function projectAttemptUsage(attachments) {
|
|
|
1113
1146
|
[call.inputTokens, call.cacheReadTokens, call.cacheWriteTokens].every((value) => value !== null)));
|
|
1114
1147
|
const unknownCosts = calls.filter((call) => call.effectiveCost === null).length;
|
|
1115
1148
|
const partialCosts = calls.filter((call) => call.effectiveCost?.state === "partial").length;
|
|
1149
|
+
const costs = (0, adapter_usage_projection_ts_1.effectiveCostTotals)(calls, read.value.collection.state);
|
|
1116
1150
|
return {
|
|
1117
1151
|
...empty,
|
|
1152
|
+
...modelUsage,
|
|
1118
1153
|
state: complete ? "complete" : "partial",
|
|
1119
1154
|
limitations: [
|
|
1120
1155
|
...(complete ? [] : [{ issue: "Adapter usage describes only recorded calls; some quantities or terminal outcomes are unknown, or capture is incomplete." }]),
|
|
@@ -1126,69 +1161,32 @@ function projectAttemptUsage(attachments) {
|
|
|
1126
1161
|
totals: {
|
|
1127
1162
|
...empty.totals, inputTokens, outputTokens, inputTotalTokens: numeric("inputTotalTokens"),
|
|
1128
1163
|
requests: { state: read.value.collection.state === "complete" ? "available" : "partial", value: all.length, observationCount: all.length },
|
|
1129
|
-
costs
|
|
1164
|
+
costs,
|
|
1130
1165
|
},
|
|
1131
1166
|
hasMore: all.length > 128,
|
|
1132
1167
|
};
|
|
1133
1168
|
}
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
function effectiveCostTotals(calls, collectionState) {
|
|
1137
|
-
const known = calls.flatMap((call) => call.effectiveCost === null ? [] : [call.effectiveCost]);
|
|
1138
|
-
const kind = (values) => {
|
|
1139
|
-
const sources = new Set(values.map((value) => value.source.kind));
|
|
1140
|
-
return sources.size === 0 ? null : sources.size === 1 ? [...sources][0] : "mixed";
|
|
1141
|
-
};
|
|
1142
|
-
const grouped = new Map();
|
|
1143
|
-
for (const cost of known)
|
|
1144
|
-
grouped.set(cost.currency, [...(grouped.get(cost.currency) ?? []), cost]);
|
|
1145
|
-
const complete = collectionState === "complete" && known.length === calls.length &&
|
|
1146
|
-
known.every((cost) => cost.state === "complete");
|
|
1169
|
+
const read = readAgentTurns(attachments.agentTurns);
|
|
1170
|
+
const usage = projectUsage(read);
|
|
1147
1171
|
return Object.freeze({
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
.
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
value: values.reduce((total, value) => addCanonicalDecimal(total, value.amount), "0"),
|
|
1155
|
-
source: kind(values),
|
|
1156
|
-
coveredCalls: values.filter((value) => value.state === "complete").length,
|
|
1157
|
-
reportedCalls: values.filter((value) => value.source.kind === "reported").length,
|
|
1158
|
-
estimatedCalls: values.filter((value) => value.source.kind === "estimated").length,
|
|
1159
|
-
}))),
|
|
1160
|
-
totalCalls: calls.length,
|
|
1172
|
+
...usage,
|
|
1173
|
+
...(0, adapter_usage_projection_ts_1.projectAdapterModelUsage)(null, models, {
|
|
1174
|
+
basis: attachments.agentTurns === undefined ? "unavailable" : "reported-sends",
|
|
1175
|
+
reason: read.state === "invalid" ? "source-invalid" : attachments.agentTurns === undefined
|
|
1176
|
+
? "usage-not-recorded" : "physical-call-identity-not-recorded",
|
|
1177
|
+
}),
|
|
1161
1178
|
});
|
|
1162
1179
|
}
|
|
1163
|
-
function projectAdapterUsageTokens(attachment) {
|
|
1164
|
-
const read = readAdapterUsageAttachment(attachment);
|
|
1180
|
+
function projectAdapterUsageTokens(attachment, models) {
|
|
1181
|
+
const read = readAdapterUsageAttachment(attachment, models);
|
|
1165
1182
|
if (read.state !== "available") {
|
|
1166
1183
|
return Object.freeze({
|
|
1167
1184
|
value: null,
|
|
1168
1185
|
state: read.state === "invalid" ? "failed" : "unavailable",
|
|
1169
1186
|
});
|
|
1170
1187
|
}
|
|
1171
|
-
const
|
|
1172
|
-
|
|
1173
|
-
const knownInputBuckets = inputBuckets.filter((value) => value !== null);
|
|
1174
|
-
const input = call.inputTotalTokens ?? (knownInputBuckets.length === 0
|
|
1175
|
-
? null
|
|
1176
|
-
: knownInputBuckets.reduce((total, current) => total + current, 0));
|
|
1177
|
-
return [input, call.outputTokens].filter((value) => value !== null);
|
|
1178
|
-
});
|
|
1179
|
-
const total = values.reduce((sum, current) => sum + current, 0);
|
|
1180
|
-
if (!Number.isSafeInteger(total)) {
|
|
1181
|
-
return Object.freeze({ value: null, state: "failed" });
|
|
1182
|
-
}
|
|
1183
|
-
const value = values.length === 0 ? null : total;
|
|
1184
|
-
const complete = read.value.calls.length > 0 && read.value.collection.state === "complete" &&
|
|
1185
|
-
read.value.calls.every((call) => call.status !== "unknown" && call.outputTokens !== null &&
|
|
1186
|
-
(call.inputTotalTokens !== null ||
|
|
1187
|
-
[call.inputTokens, call.cacheReadTokens, call.cacheWriteTokens].every((value) => value !== null)));
|
|
1188
|
-
return Object.freeze({
|
|
1189
|
-
value,
|
|
1190
|
-
state: value === null ? "unavailable" : complete ? "available" : "partial",
|
|
1191
|
-
});
|
|
1188
|
+
const material = (0, adapter_usage_projection_ts_1.adapterTokenMaterial)(read.value, "totalTokens");
|
|
1189
|
+
return Object.freeze({ value: material.state === "unavailable" ? null : material.value, state: material.state === "exact" ? "available" : material.state === "lower-bound" ? "partial" : material.reason === "usage-exceeds-safe-integer" ? "failed" : "unavailable" });
|
|
1192
1190
|
}
|
|
1193
1191
|
function projectUsage(agentTurns) {
|
|
1194
1192
|
const sourceState = availability(agentTurns, USAGE_TARGETS);
|