voratiq 0.1.0-beta.2 → 0.1.0-beta.21
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/README.md +41 -29
- package/dist/agents/launch/chat.d.ts +23 -0
- package/dist/agents/launch/chat.js +44 -0
- package/dist/agents/launch/environment.d.ts +8 -0
- package/dist/{commands/run/agents/workspace-prep.js → agents/launch/environment.js} +5 -27
- package/dist/agents/launch/prompt.d.ts +6 -0
- package/dist/agents/launch/prompt.js +12 -0
- package/dist/agents/launch/provider-state.d.ts +39 -0
- package/dist/agents/launch/provider-state.js +103 -0
- package/dist/agents/runtime/auth.d.ts +27 -0
- package/dist/agents/runtime/auth.js +72 -0
- package/dist/agents/runtime/chat.d.ts +5 -0
- package/dist/agents/runtime/chat.js +7 -0
- package/dist/agents/runtime/errors.d.ts +27 -0
- package/dist/agents/runtime/errors.js +51 -0
- package/dist/{commands/run/agents → agents/runtime}/failures.d.ts +0 -1
- package/dist/agents/runtime/failures.js +136 -0
- package/dist/agents/runtime/harness.d.ts +2 -0
- package/dist/agents/runtime/harness.js +119 -0
- package/dist/{commands/run/agents/sandbox-launcher.d.ts → agents/runtime/launcher.d.ts} +18 -6
- package/dist/{commands/run/agents/sandbox-launcher.js → agents/runtime/launcher.js} +17 -39
- package/dist/{commands/run/agents/workspace-prep.d.ts → agents/runtime/manifest.d.ts} +6 -6
- package/dist/agents/runtime/manifest.js +34 -0
- package/dist/agents/runtime/policy.d.ts +32 -0
- package/dist/agents/runtime/policy.js +240 -0
- package/dist/agents/runtime/registry.d.ts +4 -0
- package/dist/agents/runtime/registry.js +54 -0
- package/dist/{commands/run → agents/runtime}/sandbox.d.ts +8 -2
- package/dist/{commands/run → agents/runtime}/sandbox.js +28 -67
- package/dist/agents/runtime/shim/run-agent-shim.d.ts +1 -0
- package/dist/agents/runtime/shim/run-agent-shim.js +276 -0
- package/dist/agents/runtime/types.d.ts +91 -0
- package/dist/{commands/run/agents → agents/runtime}/watchdog.d.ts +4 -3
- package/dist/{commands/run/agents → agents/runtime}/watchdog.js +155 -26
- package/dist/auth/providers/codex.js +7 -2
- package/dist/auth/providers/gemini.js +14 -6
- package/dist/auth/providers/types.d.ts +1 -0
- package/dist/auth/providers/utils.d.ts +0 -1
- package/dist/auth/providers/utils.js +1 -49
- package/dist/bin.js +369 -71
- package/dist/cli/apply.d.ts +4 -0
- package/dist/cli/apply.js +28 -9
- package/dist/cli/auto.d.ts +32 -0
- package/dist/cli/auto.js +232 -0
- package/dist/cli/contract.d.ts +328 -0
- package/dist/cli/contract.js +480 -0
- package/dist/cli/errors.d.ts +3 -0
- package/dist/cli/errors.js +21 -3
- package/dist/cli/init.d.ts +5 -0
- package/dist/cli/init.js +34 -6
- package/dist/cli/list.d.ts +6 -4
- package/dist/cli/list.js +39 -16
- package/dist/cli/mcp.d.ts +2 -0
- package/dist/cli/mcp.js +16 -0
- package/dist/cli/message.d.ts +28 -0
- package/dist/cli/message.js +147 -0
- package/dist/cli/operator-envelope.d.ts +180 -0
- package/dist/cli/operator-envelope.js +425 -0
- package/dist/cli/output.d.ts +15 -1
- package/dist/cli/output.js +153 -5
- package/dist/cli/prune.d.ts +7 -3
- package/dist/cli/prune.js +57 -12
- package/dist/cli/reduce.d.ts +29 -0
- package/dist/cli/reduce.js +211 -0
- package/dist/cli/root-launcher.d.ts +4 -0
- package/dist/cli/root-launcher.js +15 -0
- package/dist/cli/run.d.ts +27 -1
- package/dist/cli/run.js +108 -16
- package/dist/cli/spec.d.ts +31 -0
- package/dist/cli/spec.js +180 -0
- package/dist/cli/verify.d.ts +35 -0
- package/dist/cli/verify.js +297 -0
- package/dist/commands/apply/command.d.ts +2 -0
- package/dist/commands/apply/command.js +145 -6
- package/dist/commands/apply/errors.d.ts +43 -4
- package/dist/commands/apply/errors.js +100 -22
- package/dist/commands/apply/types.d.ts +2 -1
- package/dist/commands/auto/command.d.ts +145 -0
- package/dist/commands/auto/command.js +433 -0
- package/dist/commands/auto/errors.d.ts +19 -0
- package/dist/commands/auto/errors.js +19 -0
- package/dist/commands/auto/validation.d.ts +14 -0
- package/dist/commands/auto/validation.js +90 -0
- package/dist/commands/fetch.d.ts +2 -2
- package/dist/commands/fetch.js +4 -4
- package/dist/commands/init/agents.d.ts +2 -1
- package/dist/commands/init/agents.js +66 -63
- package/dist/commands/init/command.js +300 -16
- package/dist/commands/init/types.d.ts +18 -7
- package/dist/commands/interactive/lifecycle.d.ts +15 -0
- package/dist/commands/interactive/lifecycle.js +141 -0
- package/dist/commands/list/command.d.ts +10 -3
- package/dist/commands/list/command.js +597 -40
- package/dist/commands/message/command.d.ts +23 -0
- package/dist/commands/message/command.js +215 -0
- package/dist/commands/message/errors.d.ts +9 -0
- package/dist/commands/message/errors.js +20 -0
- package/dist/commands/message/lifecycle.d.ts +14 -0
- package/dist/commands/message/lifecycle.js +128 -0
- package/dist/commands/prune/command.d.ts +2 -1
- package/dist/commands/prune/command.js +61 -10
- package/dist/commands/prune/errors.d.ts +1 -1
- package/dist/commands/prune/errors.js +5 -5
- package/dist/commands/prune/types.d.ts +21 -0
- package/dist/commands/reduce/command.d.ts +26 -0
- package/dist/commands/reduce/command.js +145 -0
- package/dist/commands/reduce/errors.d.ts +17 -0
- package/dist/commands/reduce/errors.js +32 -0
- package/dist/commands/reduce/targets.d.ts +11 -0
- package/dist/commands/reduce/targets.js +271 -0
- package/dist/commands/root-launcher/command.d.ts +31 -0
- package/dist/commands/root-launcher/command.js +233 -0
- package/dist/commands/run/command.d.ts +6 -1
- package/dist/commands/run/command.js +70 -40
- package/dist/commands/run/lifecycle.d.ts +7 -5
- package/dist/commands/run/lifecycle.js +45 -23
- package/dist/commands/run/record-init.d.ts +4 -1
- package/dist/commands/run/record-init.js +5 -2
- package/dist/commands/run/shim/run-agent-shim.d.ts +2 -1
- package/dist/commands/run/shim/run-agent-shim.js +4 -219
- package/dist/commands/run/validation.d.ts +2 -3
- package/dist/commands/run/validation.js +54 -25
- package/dist/commands/shared/max-parallel.d.ts +5 -0
- package/dist/commands/shared/max-parallel.js +15 -0
- package/dist/commands/shared/preview.d.ts +10 -0
- package/dist/commands/shared/preview.js +60 -0
- package/dist/commands/shared/resolve-reduction-competitors.d.ts +15 -0
- package/dist/commands/shared/resolve-reduction-competitors.js +13 -0
- package/dist/commands/shared/resolve-stage-competitors.d.ts +19 -0
- package/dist/commands/shared/resolve-stage-competitors.js +171 -0
- package/dist/commands/shared/session-id.d.ts +1 -0
- package/dist/commands/shared/session-id.js +1 -0
- package/dist/commands/spec/command.d.ts +22 -0
- package/dist/commands/spec/command.js +330 -0
- package/dist/commands/spec/errors.d.ts +11 -0
- package/dist/commands/spec/errors.js +23 -0
- package/dist/commands/verify/agents.d.ts +8 -0
- package/dist/commands/verify/agents.js +29 -0
- package/dist/commands/verify/command.d.ts +23 -0
- package/dist/commands/verify/command.js +168 -0
- package/dist/commands/verify/lifecycle.d.ts +14 -0
- package/dist/commands/verify/lifecycle.js +229 -0
- package/dist/commands/verify/max-parallel.d.ts +7 -0
- package/dist/commands/verify/max-parallel.js +15 -0
- package/dist/commands/verify/targets.d.ts +18 -0
- package/dist/commands/verify/targets.js +420 -0
- package/dist/competition/command-adapter.d.ts +35 -0
- package/dist/competition/command-adapter.js +20 -0
- package/dist/competition/core.d.ts +41 -0
- package/dist/competition/core.js +181 -0
- package/dist/competition/shared/extra-context.d.ts +14 -0
- package/dist/competition/shared/extra-context.js +100 -0
- package/dist/competition/shared/preflight.d.ts +11 -0
- package/dist/competition/shared/preflight.js +39 -0
- package/dist/competition/shared/prompt-helpers.d.ts +16 -0
- package/dist/competition/shared/prompt-helpers.js +27 -0
- package/dist/competition/shared/prune.d.ts +1 -0
- package/dist/competition/shared/prune.js +4 -0
- package/dist/competition/shared/sandbox-policy.d.ts +9 -0
- package/dist/competition/shared/sandbox-policy.js +7 -0
- package/dist/competition/shared/teardown.d.ts +36 -0
- package/dist/competition/shared/teardown.js +101 -0
- package/dist/configs/agents/defaults.d.ts +31 -2
- package/dist/configs/agents/defaults.js +346 -30
- package/dist/configs/agents/errors.js +14 -11
- package/dist/configs/agents/loader.d.ts +11 -1
- package/dist/configs/agents/loader.js +71 -4
- package/dist/configs/agents/types.js +2 -2
- package/dist/configs/environment/detect.js +9 -4
- package/dist/configs/environment/errors.js +4 -4
- package/dist/configs/environment/loader.d.ts +1 -1
- package/dist/configs/environment/loader.js +3 -3
- package/dist/configs/orchestration/bootstrap.d.ts +16 -0
- package/dist/configs/orchestration/bootstrap.js +122 -0
- package/dist/configs/orchestration/errors.d.ts +15 -0
- package/dist/configs/orchestration/errors.js +28 -0
- package/dist/configs/orchestration/loader.d.ts +9 -0
- package/dist/configs/orchestration/loader.js +148 -0
- package/dist/configs/orchestration/types.d.ts +102 -0
- package/dist/configs/orchestration/types.js +65 -0
- package/dist/configs/sandbox/defaults.js +14 -4
- package/dist/configs/sandbox/errors.d.ts +1 -1
- package/dist/configs/sandbox/errors.js +1 -1
- package/dist/configs/sandbox/loader.js +6 -4
- package/dist/configs/sandbox/schemas.js +4 -2
- package/dist/configs/settings/loader.d.ts +7 -0
- package/dist/configs/settings/loader.js +81 -0
- package/dist/configs/settings/types.d.ts +47 -0
- package/dist/configs/settings/types.js +23 -0
- package/dist/configs/verification/errors.d.ts +11 -0
- package/dist/configs/verification/errors.js +21 -0
- package/dist/configs/verification/loader.d.ts +8 -0
- package/dist/configs/verification/loader.js +43 -0
- package/dist/configs/verification/methods.d.ts +35 -0
- package/dist/configs/verification/methods.js +41 -0
- package/dist/configs/verification/programmatic-defaults.d.ts +10 -0
- package/dist/configs/verification/programmatic-defaults.js +42 -0
- package/dist/configs/verification/programmatic-detect.d.ts +10 -0
- package/dist/configs/{evals/detect.js → verification/programmatic-detect.js} +22 -33
- package/dist/configs/verification/types.d.ts +49 -0
- package/dist/configs/verification/types.js +45 -0
- package/dist/contracts/list.d.ts +207 -0
- package/dist/contracts/list.js +154 -0
- package/dist/domain/interactive/model/types.d.ts +104 -0
- package/dist/domain/interactive/model/types.js +83 -0
- package/dist/domain/interactive/persistence/adapter.d.ts +39 -0
- package/dist/domain/interactive/persistence/adapter.js +144 -0
- package/dist/domain/interactive/prompt.d.ts +3 -0
- package/dist/domain/interactive/prompt.js +7 -0
- package/dist/domain/message/competition/adapter.d.ts +36 -0
- package/dist/domain/message/competition/adapter.js +197 -0
- package/dist/domain/message/competition/prompt.d.ts +8 -0
- package/dist/domain/message/competition/prompt.js +29 -0
- package/dist/domain/message/model/mutators.d.ts +17 -0
- package/dist/domain/message/model/mutators.js +107 -0
- package/dist/domain/message/model/types.d.ts +100 -0
- package/dist/domain/message/model/types.js +87 -0
- package/dist/domain/message/persistence/adapter.d.ts +43 -0
- package/dist/domain/message/persistence/adapter.js +124 -0
- package/dist/domain/reduce/competition/adapter.d.ts +42 -0
- package/dist/domain/reduce/competition/adapter.js +826 -0
- package/dist/domain/reduce/competition/output-validation.d.ts +4 -0
- package/dist/domain/reduce/competition/output-validation.js +18 -0
- package/dist/domain/reduce/competition/prompt.d.ts +10 -0
- package/dist/domain/reduce/competition/prompt.js +96 -0
- package/dist/domain/reduce/competition/reduction.d.ts +9 -0
- package/dist/domain/reduce/competition/reduction.js +32 -0
- package/dist/domain/reduce/model/types.d.ts +122 -0
- package/dist/domain/reduce/model/types.js +84 -0
- package/dist/domain/reduce/persistence/adapter.d.ts +43 -0
- package/dist/domain/reduce/persistence/adapter.js +126 -0
- package/dist/domain/run/competition/adapter.d.ts +30 -0
- package/dist/domain/run/competition/adapter.js +39 -0
- package/dist/domain/run/competition/agent-execution.d.ts +20 -0
- package/dist/domain/run/competition/agent-execution.js +45 -0
- package/dist/domain/run/competition/agent-preparation.d.ts +12 -0
- package/dist/domain/run/competition/agent-preparation.js +24 -0
- package/dist/domain/run/competition/agents/artifacts.d.ts +17 -0
- package/dist/domain/run/competition/agents/artifacts.js +173 -0
- package/dist/{commands/run → domain/run/competition}/agents/lifecycle.d.ts +3 -3
- package/dist/{commands/run → domain/run/competition}/agents/lifecycle.js +84 -64
- package/dist/domain/run/competition/agents/post-processing.d.ts +12 -0
- package/dist/domain/run/competition/agents/post-processing.js +4 -0
- package/dist/domain/run/competition/agents/preparation.js +64 -0
- package/dist/{commands/run → domain/run/competition}/agents/run-context.d.ts +9 -16
- package/dist/{commands/run → domain/run/competition}/agents/run-context.js +22 -70
- package/dist/{commands/run → domain/run/competition}/agents/types.d.ts +10 -13
- package/dist/domain/run/competition/agents/workspace.d.ts +21 -0
- package/dist/domain/run/competition/agents/workspace.js +47 -0
- package/dist/{commands/run → domain/run/competition}/errors.d.ts +8 -1
- package/dist/{commands/run → domain/run/competition}/errors.js +39 -9
- package/dist/{commands/run → domain/run/competition}/phases.d.ts +1 -2
- package/dist/domain/run/competition/phases.js +1 -0
- package/dist/domain/run/competition/prompt.d.ts +7 -0
- package/dist/domain/run/competition/prompt.js +27 -0
- package/dist/{commands/run → domain/run/competition}/reports.d.ts +5 -3
- package/dist/{commands/run → domain/run/competition}/reports.js +7 -19
- package/dist/domain/run/competition/termination-state.d.ts +4 -0
- package/dist/domain/run/competition/termination-state.js +12 -0
- package/dist/{records → domain/run/model}/enhanced.d.ts +6 -7
- package/dist/{records → domain/run/model}/enhanced.js +11 -11
- package/dist/{records → domain/run/model}/errors.d.ts +1 -1
- package/dist/{records → domain/run/model}/errors.js +5 -5
- package/dist/{records → domain/run/model}/mutators.d.ts +4 -3
- package/dist/{records → domain/run/model}/mutators.js +58 -36
- package/dist/domain/run/model/types.d.ts +376 -0
- package/dist/domain/run/model/types.js +192 -0
- package/dist/{records/persistence.d.ts → domain/run/persistence/adapter.d.ts} +9 -3
- package/dist/domain/run/persistence/adapter.js +340 -0
- package/dist/domain/run/persistence/error-mapping.d.ts +2 -0
- package/dist/domain/run/persistence/error-mapping.js +17 -0
- package/dist/domain/shared/lifecycle.d.ts +54 -0
- package/dist/domain/shared/lifecycle.js +165 -0
- package/dist/domain/shared/token-usage.d.ts +21 -0
- package/dist/domain/shared/token-usage.js +38 -0
- package/dist/domain/spec/competition/adapter.d.ts +31 -0
- package/dist/domain/spec/competition/adapter.js +196 -0
- package/dist/domain/spec/competition/prompt.d.ts +11 -0
- package/dist/domain/spec/competition/prompt.js +44 -0
- package/dist/domain/spec/model/output.d.ts +13 -0
- package/dist/domain/spec/model/output.js +36 -0
- package/dist/domain/spec/model/types.d.ts +98 -0
- package/dist/domain/spec/model/types.js +84 -0
- package/dist/domain/spec/persistence/adapter.d.ts +51 -0
- package/dist/domain/spec/persistence/adapter.js +140 -0
- package/dist/domain/verify/blinding/aliases.d.ts +7 -0
- package/dist/domain/verify/blinding/aliases.js +23 -0
- package/dist/domain/verify/competition/adapter.d.ts +54 -0
- package/dist/domain/verify/competition/adapter.js +444 -0
- package/dist/domain/verify/competition/artifacts.d.ts +6 -0
- package/dist/domain/verify/competition/artifacts.js +7 -0
- package/dist/domain/verify/competition/blinding.d.ts +24 -0
- package/dist/domain/verify/competition/blinding.js +109 -0
- package/dist/domain/verify/competition/finalize.d.ts +11 -0
- package/dist/domain/verify/competition/finalize.js +65 -0
- package/dist/domain/verify/competition/programmatic.d.ts +15 -0
- package/dist/domain/verify/competition/programmatic.js +352 -0
- package/dist/domain/verify/competition/prompt.d.ts +19 -0
- package/dist/domain/verify/competition/prompt.js +63 -0
- package/dist/domain/verify/competition/rubric.d.ts +23 -0
- package/dist/domain/verify/competition/rubric.js +77 -0
- package/dist/domain/verify/competition/shared-layout.d.ts +121 -0
- package/dist/domain/verify/competition/shared-layout.js +365 -0
- package/dist/domain/verify/competition/target.d.ts +47 -0
- package/dist/domain/verify/competition/target.js +1 -0
- package/dist/domain/verify/model/mutators.d.ts +16 -0
- package/dist/domain/verify/model/mutators.js +126 -0
- package/dist/domain/verify/model/types.d.ts +408 -0
- package/dist/domain/verify/model/types.js +289 -0
- package/dist/domain/verify/persistence/adapter.d.ts +43 -0
- package/dist/domain/verify/persistence/adapter.js +126 -0
- package/dist/domain/verify/programmatic/runner.d.ts +22 -0
- package/dist/domain/verify/programmatic/runner.js +209 -0
- package/dist/domain/verify/rubric-result.d.ts +28 -0
- package/dist/domain/verify/rubric-result.js +121 -0
- package/dist/extra-context/contract.d.ts +17 -0
- package/dist/extra-context/contract.js +60 -0
- package/dist/interactive/index.d.ts +2 -0
- package/dist/interactive/index.js +1 -0
- package/dist/interactive/providers/launch.d.ts +23 -0
- package/dist/interactive/providers/launch.js +203 -0
- package/dist/interactive/providers/mcp.d.ts +13 -0
- package/dist/interactive/providers/mcp.js +547 -0
- package/dist/interactive/providers/shared.d.ts +2 -0
- package/dist/interactive/providers/shared.js +1 -0
- package/dist/interactive/providers.d.ts +3 -0
- package/dist/interactive/providers.js +3 -0
- package/dist/interactive/records.d.ts +2 -0
- package/dist/interactive/records.js +1 -0
- package/dist/interactive/substrate.d.ts +21 -0
- package/dist/interactive/substrate.js +522 -0
- package/dist/interactive/types.d.ts +101 -0
- package/dist/interactive/types.js +1 -0
- package/dist/mcp/server.d.ts +88 -0
- package/dist/mcp/server.js +790 -0
- package/dist/persistence/error-mapping.d.ts +19 -0
- package/dist/persistence/error-mapping.js +44 -0
- package/dist/persistence/errors.d.ts +26 -0
- package/dist/persistence/errors.js +49 -0
- package/dist/persistence/extra-context.d.ts +9 -0
- package/dist/persistence/extra-context.js +60 -0
- package/dist/{records → persistence}/history-lock.js +2 -2
- package/dist/persistence/record-path-schema.d.ts +3 -0
- package/dist/persistence/record-path-schema.js +16 -0
- package/dist/persistence/session-store.d.ts +92 -0
- package/dist/persistence/session-store.js +412 -0
- package/dist/policy/auto.d.ts +13 -0
- package/dist/policy/auto.js +22 -0
- package/dist/policy/index.d.ts +5 -0
- package/dist/policy/index.js +5 -0
- package/dist/policy/resolution.d.ts +6 -0
- package/dist/policy/resolution.js +23 -0
- package/dist/policy/result.d.ts +53 -0
- package/dist/policy/result.js +15 -0
- package/dist/policy/selector.d.ts +11 -0
- package/dist/policy/selector.js +57 -0
- package/dist/policy/verification.d.ts +77 -0
- package/dist/policy/verification.js +365 -0
- package/dist/policy/verifier-selection.d.ts +13 -0
- package/dist/policy/verifier-selection.js +78 -0
- package/dist/preflight/branch.d.ts +9 -0
- package/dist/preflight/branch.js +48 -0
- package/dist/preflight/errors.d.ts +3 -0
- package/dist/preflight/errors.js +10 -3
- package/dist/preflight/index.d.ts +13 -0
- package/dist/preflight/index.js +43 -8
- package/dist/render/interactions/confirmation.js +4 -2
- package/dist/render/transcripts/apply.js +9 -10
- package/dist/render/transcripts/auto.d.ts +27 -0
- package/dist/render/transcripts/auto.js +21 -0
- package/dist/render/transcripts/init.d.ts +4 -15
- package/dist/render/transcripts/init.js +71 -72
- package/dist/render/transcripts/list.d.ts +10 -1
- package/dist/render/transcripts/list.js +121 -15
- package/dist/render/transcripts/message.d.ts +72 -0
- package/dist/render/transcripts/message.js +362 -0
- package/dist/render/transcripts/prune.d.ts +7 -2
- package/dist/render/transcripts/prune.js +64 -17
- package/dist/render/transcripts/reduce.d.ts +74 -0
- package/dist/render/transcripts/reduce.js +395 -0
- package/dist/render/transcripts/root-launcher.d.ts +19 -0
- package/dist/render/transcripts/root-launcher.js +40 -0
- package/dist/render/transcripts/run.d.ts +35 -6
- package/dist/render/transcripts/run.js +241 -165
- package/dist/render/transcripts/shared.d.ts +2 -0
- package/dist/render/transcripts/shared.js +11 -4
- package/dist/render/transcripts/spec.d.ts +74 -0
- package/dist/render/transcripts/spec.js +394 -0
- package/dist/render/transcripts/stage-progress.d.ts +22 -0
- package/dist/render/transcripts/stage-progress.js +6 -0
- package/dist/render/transcripts/update-check.d.ts +2 -0
- package/dist/render/transcripts/update-check.js +22 -0
- package/dist/render/transcripts/verify.d.ts +74 -0
- package/dist/render/transcripts/verify.js +409 -0
- package/dist/render/utils/agents.d.ts +10 -9
- package/dist/render/utils/agents.js +30 -82
- package/dist/render/utils/badges.d.ts +3 -20
- package/dist/render/utils/badges.js +3 -36
- package/dist/render/utils/duration.d.ts +12 -0
- package/dist/render/utils/duration.js +37 -0
- package/dist/render/utils/interactive-frame.d.ts +6 -0
- package/dist/render/utils/interactive-frame.js +38 -0
- package/dist/render/utils/records.js +4 -4
- package/dist/render/utils/runs.d.ts +3 -9
- package/dist/render/utils/runs.js +16 -48
- package/dist/render/utils/stage-output.d.ts +20 -0
- package/dist/render/utils/stage-output.js +44 -0
- package/dist/render/utils/timezone.d.ts +2 -0
- package/dist/render/utils/timezone.js +42 -0
- package/dist/render/utils/transcript-shell.d.ts +66 -0
- package/dist/render/utils/transcript-shell.js +155 -0
- package/dist/render/utils/transcript.d.ts +7 -1
- package/dist/render/utils/transcript.js +12 -2
- package/dist/render/utils/wrap.d.ts +1 -0
- package/dist/render/utils/wrap.js +20 -0
- package/dist/status/colors.d.ts +2 -3
- package/dist/status/colors.js +3 -3
- package/dist/status/index.d.ts +108 -8
- package/dist/status/index.js +164 -5
- package/dist/update-check/checker.d.ts +24 -0
- package/dist/update-check/checker.js +130 -0
- package/dist/update-check/prompt.d.ts +25 -0
- package/dist/update-check/prompt.js +62 -0
- package/dist/update-check/semver.d.ts +17 -0
- package/dist/update-check/semver.js +36 -0
- package/dist/update-check/state-path.d.ts +8 -0
- package/dist/update-check/state-path.js +18 -0
- package/dist/utils/binaries.js +14 -8
- package/dist/utils/errors.d.ts +3 -1
- package/dist/utils/errors.js +3 -1
- package/dist/utils/git.d.ts +10 -0
- package/dist/utils/git.js +15 -3
- package/dist/utils/output.d.ts +5 -1
- package/dist/utils/output.js +4 -2
- package/dist/utils/process.d.ts +2 -1
- package/dist/utils/process.js +7 -3
- package/dist/utils/session-id.d.ts +1 -0
- package/dist/utils/session-id.js +22 -0
- package/dist/utils/slug.d.ts +2 -0
- package/dist/utils/slug.js +15 -0
- package/dist/utils/voratiq-cli-target.d.ts +9 -0
- package/dist/utils/voratiq-cli-target.js +58 -0
- package/dist/workspace/agents.d.ts +13 -16
- package/dist/workspace/agents.js +22 -147
- package/dist/workspace/chat/artifacts.d.ts +9 -0
- package/dist/workspace/chat/artifacts.js +82 -12
- package/dist/workspace/chat/native-usage.d.ts +13 -0
- package/dist/workspace/chat/native-usage.js +60 -0
- package/dist/workspace/chat/sources.d.ts +9 -5
- package/dist/workspace/chat/sources.js +89 -23
- package/dist/workspace/chat/token-usage-result.d.ts +23 -0
- package/dist/workspace/chat/token-usage-result.js +7 -0
- package/dist/workspace/chat/usage-extractor.d.ts +30 -0
- package/dist/workspace/chat/usage-extractor.js +461 -0
- package/dist/workspace/chat/usage-mappings.d.ts +20 -0
- package/dist/workspace/chat/usage-mappings.js +136 -0
- package/dist/workspace/credential-guard.js +1 -1
- package/dist/workspace/dependencies.js +4 -4
- package/dist/workspace/errors.d.ts +5 -0
- package/dist/workspace/errors.js +13 -3
- package/dist/workspace/layout.d.ts +17 -6
- package/dist/workspace/layout.js +51 -32
- package/dist/workspace/promotion.d.ts +32 -0
- package/dist/workspace/promotion.js +34 -0
- package/dist/workspace/prune.d.ts +1 -1
- package/dist/workspace/run.d.ts +1 -3
- package/dist/workspace/run.js +6 -15
- package/dist/workspace/setup.d.ts +8 -0
- package/dist/workspace/setup.js +359 -56
- package/dist/workspace/shim.js +1 -1
- package/dist/workspace/structure.d.ts +91 -26
- package/dist/workspace/structure.js +227 -43
- package/dist/workspace/templates.d.ts +9 -3
- package/dist/workspace/templates.js +26 -15
- package/dist/workspace/verification-defaults.d.ts +12 -0
- package/dist/workspace/verification-defaults.js +1017 -0
- package/package.json +30 -24
- package/dist/cli/review.d.ts +0 -12
- package/dist/cli/review.js +0 -33
- package/dist/commands/errors.d.ts +0 -4
- package/dist/commands/errors.js +0 -7
- package/dist/commands/init/evals.d.ts +0 -4
- package/dist/commands/init/evals.js +0 -219
- package/dist/commands/review/command.d.ts +0 -10
- package/dist/commands/review/command.js +0 -26
- package/dist/commands/run/agent-execution.d.ts +0 -19
- package/dist/commands/run/agent-execution.js +0 -63
- package/dist/commands/run/agents/auth-stage.d.ts +0 -23
- package/dist/commands/run/agents/auth-stage.js +0 -108
- package/dist/commands/run/agents/chat-preserver.d.ts +0 -9
- package/dist/commands/run/agents/chat-preserver.js +0 -35
- package/dist/commands/run/agents/eval-runner.d.ts +0 -19
- package/dist/commands/run/agents/eval-runner.js +0 -27
- package/dist/commands/run/agents/failures.js +0 -32
- package/dist/commands/run/agents/preparation.js +0 -123
- package/dist/commands/run/agents.d.ts +0 -14
- package/dist/commands/run/agents.js +0 -47
- package/dist/commands/run/prompts.d.ts +0 -4
- package/dist/commands/run/prompts.js +0 -16
- package/dist/commands/run/sandbox-registry.d.ts +0 -4
- package/dist/commands/run/sandbox-registry.js +0 -54
- package/dist/configs/evals/defaults.d.ts +0 -8
- package/dist/configs/evals/defaults.js +0 -28
- package/dist/configs/evals/detect.d.ts +0 -10
- package/dist/configs/evals/errors.d.ts +0 -16
- package/dist/configs/evals/errors.js +0 -29
- package/dist/configs/evals/loader.d.ts +0 -9
- package/dist/configs/evals/loader.js +0 -46
- package/dist/configs/evals/types.d.ts +0 -42
- package/dist/configs/evals/types.js +0 -74
- package/dist/evals/runner.d.ts +0 -16
- package/dist/evals/runner.js +0 -132
- package/dist/records/persistence.js +0 -469
- package/dist/records/types.d.ts +0 -255
- package/dist/records/types.js +0 -160
- package/dist/render/transcripts/review.d.ts +0 -2
- package/dist/render/transcripts/review.js +0 -36
- /package/dist/{commands/run → agents/runtime}/shim/agent-manifest.d.ts +0 -0
- /package/dist/{commands/run → agents/runtime}/shim/agent-manifest.js +0 -0
- /package/dist/{commands/run → agents/runtime/shim}/argv.d.ts +0 -0
- /package/dist/{commands/run → agents/runtime/shim}/argv.js +0 -0
- /package/dist/{commands/run/agents → agents/runtime}/types.js +0 -0
- /package/dist/{commands/run → domain/run/competition}/agents/preparation.d.ts +0 -0
- /package/dist/{commands/run/phases.js → domain/run/competition/agents/types.js} +0 -0
- /package/dist/{commands/run → domain/run/model}/id.d.ts +0 -0
- /package/dist/{commands/run → domain/run/model}/id.js +0 -0
- /package/dist/{records → persistence}/history-lock.d.ts +0 -0
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { isMissing } from "../../utils/fs.js";
|
|
3
|
+
import { extractObservedProviderNativeUsage, PROVIDER_USAGE_SHAPE_MAPPINGS, } from "./usage-mappings.js";
|
|
4
|
+
export async function extractChatUsageFromArtifact(options) {
|
|
5
|
+
const { artifactPath, format, modelId, providerId } = options;
|
|
6
|
+
let content;
|
|
7
|
+
try {
|
|
8
|
+
content = await readFile(artifactPath, "utf8");
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
if (isMissing(error)) {
|
|
12
|
+
return buildUnavailableResult({
|
|
13
|
+
reason: "missing",
|
|
14
|
+
artifactPath,
|
|
15
|
+
format,
|
|
16
|
+
providerId,
|
|
17
|
+
modelId,
|
|
18
|
+
message: "Chat usage artifact was not found.",
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return buildUnavailableResult({
|
|
22
|
+
reason: "malformed",
|
|
23
|
+
artifactPath,
|
|
24
|
+
format,
|
|
25
|
+
providerId,
|
|
26
|
+
modelId,
|
|
27
|
+
message: `Chat usage artifact could not be read: ${String(error)}`,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
const providerShape = PROVIDER_USAGE_SHAPE_MAPPINGS[providerId];
|
|
31
|
+
if (!providerShape) {
|
|
32
|
+
return buildUnavailableResult({
|
|
33
|
+
reason: "unsupported_provider",
|
|
34
|
+
artifactPath,
|
|
35
|
+
format,
|
|
36
|
+
providerId,
|
|
37
|
+
modelId,
|
|
38
|
+
message: `Usage extraction is not implemented for provider \`${providerId}\` yet.`,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
if (format !== providerShape.artifactFormat) {
|
|
42
|
+
const providerLabel = formatProviderLabel(providerId);
|
|
43
|
+
return buildUnavailableResult({
|
|
44
|
+
reason: "unsupported_provider",
|
|
45
|
+
artifactPath,
|
|
46
|
+
format,
|
|
47
|
+
providerId,
|
|
48
|
+
modelId,
|
|
49
|
+
message: `${providerLabel} usage extraction expects a ${providerShape.artifactFormat} artifact, received \`${format}\`.`,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
switch (providerId) {
|
|
53
|
+
case "claude":
|
|
54
|
+
return extractClaudeChatUsageFromJsonl({
|
|
55
|
+
artifactPath,
|
|
56
|
+
content,
|
|
57
|
+
modelId,
|
|
58
|
+
});
|
|
59
|
+
case "codex":
|
|
60
|
+
return extractCodexChatUsageFromJsonl({
|
|
61
|
+
artifactPath,
|
|
62
|
+
content,
|
|
63
|
+
modelId,
|
|
64
|
+
});
|
|
65
|
+
case "gemini":
|
|
66
|
+
return extractGeminiChatUsageFromJson({
|
|
67
|
+
artifactPath,
|
|
68
|
+
content,
|
|
69
|
+
modelId,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export function extractCodexChatUsageFromJsonl(options) {
|
|
74
|
+
const { artifactPath, content, modelId } = options;
|
|
75
|
+
const tokenCountEvents = [];
|
|
76
|
+
const lines = content.split(/\r?\n/u);
|
|
77
|
+
for (const [index, rawLine] of lines.entries()) {
|
|
78
|
+
const trimmed = rawLine.trim();
|
|
79
|
+
if (trimmed.length === 0) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
let parsedLine;
|
|
83
|
+
try {
|
|
84
|
+
parsedLine = JSON.parse(trimmed);
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
return {
|
|
88
|
+
status: "unavailable",
|
|
89
|
+
reason: "malformed",
|
|
90
|
+
provider: "codex",
|
|
91
|
+
artifactPath,
|
|
92
|
+
format: "jsonl",
|
|
93
|
+
modelId,
|
|
94
|
+
message: `Invalid JSONL at line ${index + 1}: ${error instanceof Error ? error.message : String(error)}`,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const tokenCountEvent = parseCodexTokenCountEvent(parsedLine);
|
|
98
|
+
if (tokenCountEvent) {
|
|
99
|
+
tokenCountEvents.push(tokenCountEvent);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (tokenCountEvents.length === 0) {
|
|
103
|
+
return buildUnavailableResult({
|
|
104
|
+
reason: "missing",
|
|
105
|
+
artifactPath,
|
|
106
|
+
format: "jsonl",
|
|
107
|
+
providerId: "codex",
|
|
108
|
+
modelId,
|
|
109
|
+
message: "No Codex token_count usage events were found in chat.jsonl.",
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
const latestTokenCountEvent = tokenCountEvents.at(-1);
|
|
113
|
+
if (!latestTokenCountEvent) {
|
|
114
|
+
return buildUnavailableResult({
|
|
115
|
+
reason: "missing",
|
|
116
|
+
artifactPath,
|
|
117
|
+
format: "jsonl",
|
|
118
|
+
providerId: "codex",
|
|
119
|
+
modelId,
|
|
120
|
+
message: "No Codex token_count usage events were found in chat.jsonl.",
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
const totalTokenUsage = asRecord(latestTokenCountEvent.info.total_token_usage);
|
|
124
|
+
if (!totalTokenUsage) {
|
|
125
|
+
return buildUnavailableResult({
|
|
126
|
+
reason: "malformed",
|
|
127
|
+
artifactPath,
|
|
128
|
+
format: "jsonl",
|
|
129
|
+
providerId: "codex",
|
|
130
|
+
modelId,
|
|
131
|
+
message: "Codex token_count event is missing info.total_token_usage.",
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
const usage = extractObservedProviderNativeUsage({
|
|
135
|
+
providerId: "codex",
|
|
136
|
+
usagePayload: totalTokenUsage,
|
|
137
|
+
});
|
|
138
|
+
if (!usage) {
|
|
139
|
+
return buildUnavailableResult({
|
|
140
|
+
reason: "malformed",
|
|
141
|
+
artifactPath,
|
|
142
|
+
format: "jsonl",
|
|
143
|
+
providerId: "codex",
|
|
144
|
+
modelId,
|
|
145
|
+
message: "Codex token_count event did not contain any valid token usage fields.",
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
status: "available",
|
|
150
|
+
provider: "codex",
|
|
151
|
+
artifactPath,
|
|
152
|
+
format: "jsonl",
|
|
153
|
+
modelId,
|
|
154
|
+
tokenUsage: usage,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
export function extractClaudeChatUsageFromJsonl(options) {
|
|
158
|
+
const { artifactPath, content, modelId } = options;
|
|
159
|
+
const usageMessages = [];
|
|
160
|
+
const lines = content.split(/\r?\n/u);
|
|
161
|
+
for (const [index, rawLine] of lines.entries()) {
|
|
162
|
+
const trimmed = rawLine.trim();
|
|
163
|
+
if (trimmed.length === 0) {
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
let parsedLine;
|
|
167
|
+
try {
|
|
168
|
+
parsedLine = JSON.parse(trimmed);
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
return buildUnavailableResult({
|
|
172
|
+
reason: "malformed",
|
|
173
|
+
artifactPath,
|
|
174
|
+
format: "jsonl",
|
|
175
|
+
providerId: "claude",
|
|
176
|
+
modelId,
|
|
177
|
+
message: `Invalid JSONL at line ${index + 1}: ${error instanceof Error ? error.message : String(error)}`,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
const usageMessage = parseClaudeUsageMessage(parsedLine, index + 1);
|
|
181
|
+
if (usageMessage) {
|
|
182
|
+
usageMessages.push(usageMessage);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (usageMessages.length === 0) {
|
|
186
|
+
return buildUnavailableResult({
|
|
187
|
+
reason: "missing",
|
|
188
|
+
artifactPath,
|
|
189
|
+
format: "jsonl",
|
|
190
|
+
providerId: "claude",
|
|
191
|
+
modelId,
|
|
192
|
+
message: "No Claude message.usage payloads were found in chat.jsonl.",
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
const normalizedUsage = [];
|
|
196
|
+
for (const usageMessage of usageMessages) {
|
|
197
|
+
const usageRecord = asRecord(usageMessage.usage);
|
|
198
|
+
if (!usageRecord) {
|
|
199
|
+
return buildUnavailableResult({
|
|
200
|
+
reason: "malformed",
|
|
201
|
+
artifactPath,
|
|
202
|
+
format: "jsonl",
|
|
203
|
+
providerId: "claude",
|
|
204
|
+
modelId,
|
|
205
|
+
message: `Claude message.usage at line ${usageMessage.lineNumber} is not an object.`,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
const usage = extractObservedProviderNativeUsage({
|
|
209
|
+
providerId: "claude",
|
|
210
|
+
usagePayload: usageRecord,
|
|
211
|
+
});
|
|
212
|
+
if (!usage) {
|
|
213
|
+
return buildUnavailableResult({
|
|
214
|
+
reason: "malformed",
|
|
215
|
+
artifactPath,
|
|
216
|
+
format: "jsonl",
|
|
217
|
+
providerId: "claude",
|
|
218
|
+
modelId,
|
|
219
|
+
message: `Claude message.usage at line ${usageMessage.lineNumber} did not contain any valid token usage fields.`,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
normalizedUsage.push(usage);
|
|
223
|
+
}
|
|
224
|
+
const usage = sumExtractedUsage("claude", normalizedUsage);
|
|
225
|
+
if (!usage) {
|
|
226
|
+
return buildUnavailableResult({
|
|
227
|
+
reason: "malformed",
|
|
228
|
+
artifactPath,
|
|
229
|
+
format: "jsonl",
|
|
230
|
+
providerId: "claude",
|
|
231
|
+
modelId,
|
|
232
|
+
message: "Claude message.usage payloads did not contain any valid token usage fields.",
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
status: "available",
|
|
237
|
+
provider: "claude",
|
|
238
|
+
artifactPath,
|
|
239
|
+
format: "jsonl",
|
|
240
|
+
modelId,
|
|
241
|
+
tokenUsage: usage,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
export function extractGeminiChatUsageFromJson(options) {
|
|
245
|
+
const { artifactPath, content, modelId } = options;
|
|
246
|
+
let parsedRoot;
|
|
247
|
+
try {
|
|
248
|
+
parsedRoot = JSON.parse(content);
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
return buildUnavailableResult({
|
|
252
|
+
reason: "malformed",
|
|
253
|
+
artifactPath,
|
|
254
|
+
format: "json",
|
|
255
|
+
providerId: "gemini",
|
|
256
|
+
modelId,
|
|
257
|
+
message: `Invalid JSON: ${error instanceof Error ? error.message : String(error)}`,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
const root = asRecord(parsedRoot);
|
|
261
|
+
if (!root) {
|
|
262
|
+
return buildUnavailableResult({
|
|
263
|
+
reason: "malformed",
|
|
264
|
+
artifactPath,
|
|
265
|
+
format: "json",
|
|
266
|
+
providerId: "gemini",
|
|
267
|
+
modelId,
|
|
268
|
+
message: "Gemini chat artifact must be a JSON object.",
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
const tokensPayloads = parseGeminiTokensPayloads(root);
|
|
272
|
+
if (tokensPayloads.length === 0) {
|
|
273
|
+
return buildUnavailableResult({
|
|
274
|
+
reason: "missing",
|
|
275
|
+
artifactPath,
|
|
276
|
+
format: "json",
|
|
277
|
+
providerId: "gemini",
|
|
278
|
+
modelId,
|
|
279
|
+
message: "No Gemini tokens payloads were found in chat.json.",
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
const normalizedUsage = [];
|
|
283
|
+
for (const tokensPayload of tokensPayloads) {
|
|
284
|
+
const tokensRecord = asRecord(tokensPayload.tokens);
|
|
285
|
+
if (!tokensRecord) {
|
|
286
|
+
return buildUnavailableResult({
|
|
287
|
+
reason: "malformed",
|
|
288
|
+
artifactPath,
|
|
289
|
+
format: "json",
|
|
290
|
+
providerId: "gemini",
|
|
291
|
+
modelId,
|
|
292
|
+
message: `Gemini ${tokensPayload.location} is not an object.`,
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
const usage = extractObservedProviderNativeUsage({
|
|
296
|
+
providerId: "gemini",
|
|
297
|
+
usagePayload: tokensRecord,
|
|
298
|
+
});
|
|
299
|
+
if (!usage) {
|
|
300
|
+
return buildUnavailableResult({
|
|
301
|
+
reason: "malformed",
|
|
302
|
+
artifactPath,
|
|
303
|
+
format: "json",
|
|
304
|
+
providerId: "gemini",
|
|
305
|
+
modelId,
|
|
306
|
+
message: `Gemini ${tokensPayload.location} did not contain any valid token usage fields.`,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
normalizedUsage.push(usage);
|
|
310
|
+
}
|
|
311
|
+
const usage = sumExtractedUsage("gemini", normalizedUsage);
|
|
312
|
+
if (!usage) {
|
|
313
|
+
return buildUnavailableResult({
|
|
314
|
+
reason: "malformed",
|
|
315
|
+
artifactPath,
|
|
316
|
+
format: "json",
|
|
317
|
+
providerId: "gemini",
|
|
318
|
+
modelId,
|
|
319
|
+
message: "Gemini tokens payloads did not contain any valid token usage fields.",
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
return {
|
|
323
|
+
status: "available",
|
|
324
|
+
provider: "gemini",
|
|
325
|
+
artifactPath,
|
|
326
|
+
format: "json",
|
|
327
|
+
modelId,
|
|
328
|
+
tokenUsage: usage,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
function buildUnavailableResult(options) {
|
|
332
|
+
const { reason, artifactPath, format, providerId, modelId, message } = options;
|
|
333
|
+
return {
|
|
334
|
+
status: "unavailable",
|
|
335
|
+
reason,
|
|
336
|
+
provider: providerId,
|
|
337
|
+
artifactPath,
|
|
338
|
+
format,
|
|
339
|
+
modelId,
|
|
340
|
+
message,
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
function parseCodexTokenCountEvent(value) {
|
|
344
|
+
const root = asRecord(value);
|
|
345
|
+
const eventMsg = parseCodexEnvelope(root);
|
|
346
|
+
if (eventMsg) {
|
|
347
|
+
const info = asRecord(eventMsg.info);
|
|
348
|
+
if (info) {
|
|
349
|
+
return { info };
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
const legacyEventMsg = asRecord(root?.event_msg);
|
|
353
|
+
if (legacyEventMsg?.type !== "token_count") {
|
|
354
|
+
return undefined;
|
|
355
|
+
}
|
|
356
|
+
const info = asRecord(legacyEventMsg.info);
|
|
357
|
+
if (!info) {
|
|
358
|
+
return undefined;
|
|
359
|
+
}
|
|
360
|
+
return { info };
|
|
361
|
+
}
|
|
362
|
+
function parseCodexEnvelope(root) {
|
|
363
|
+
if (root?.type !== "event_msg") {
|
|
364
|
+
return undefined;
|
|
365
|
+
}
|
|
366
|
+
const payload = asRecord(root.payload);
|
|
367
|
+
if (payload?.type !== "token_count") {
|
|
368
|
+
return undefined;
|
|
369
|
+
}
|
|
370
|
+
return payload;
|
|
371
|
+
}
|
|
372
|
+
function parseClaudeUsageMessage(value, lineNumber) {
|
|
373
|
+
const root = asRecord(value);
|
|
374
|
+
const message = asRecord(root?.message);
|
|
375
|
+
if (!message || !("usage" in message)) {
|
|
376
|
+
return undefined;
|
|
377
|
+
}
|
|
378
|
+
return {
|
|
379
|
+
lineNumber,
|
|
380
|
+
usage: message.usage,
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
function parseGeminiTokensPayloads(root) {
|
|
384
|
+
const tokensPayloads = [];
|
|
385
|
+
if ("tokens" in root) {
|
|
386
|
+
tokensPayloads.push({
|
|
387
|
+
location: "tokens",
|
|
388
|
+
tokens: root.tokens,
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
if ("transcripts" in root) {
|
|
392
|
+
if (!Array.isArray(root.transcripts)) {
|
|
393
|
+
return [{ location: "transcripts", tokens: undefined }];
|
|
394
|
+
}
|
|
395
|
+
for (const [index, transcript] of root.transcripts.entries()) {
|
|
396
|
+
const transcriptRecord = asRecord(transcript);
|
|
397
|
+
const payload = asRecord(transcriptRecord?.payload);
|
|
398
|
+
if (!payload) {
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
if ("tokens" in payload) {
|
|
402
|
+
tokensPayloads.push({
|
|
403
|
+
location: `transcripts[${index}].payload.tokens`,
|
|
404
|
+
tokens: payload.tokens,
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
if (!Array.isArray(payload.messages)) {
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
for (const [messageIndex, message] of payload.messages.entries()) {
|
|
411
|
+
const messageRecord = asRecord(message);
|
|
412
|
+
if (!messageRecord || !("tokens" in messageRecord)) {
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
tokensPayloads.push({
|
|
416
|
+
location: `transcripts[${index}].payload.messages[${messageIndex}].tokens`,
|
|
417
|
+
tokens: messageRecord.tokens,
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return tokensPayloads;
|
|
423
|
+
}
|
|
424
|
+
function formatProviderLabel(providerId) {
|
|
425
|
+
switch (providerId) {
|
|
426
|
+
case "claude":
|
|
427
|
+
return "Claude";
|
|
428
|
+
case "codex":
|
|
429
|
+
return "Codex";
|
|
430
|
+
case "gemini":
|
|
431
|
+
return "Gemini";
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
function asRecord(value) {
|
|
435
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
436
|
+
return undefined;
|
|
437
|
+
}
|
|
438
|
+
return value;
|
|
439
|
+
}
|
|
440
|
+
function sumExtractedUsage(providerId, usages) {
|
|
441
|
+
if (usages.length === 0) {
|
|
442
|
+
return undefined;
|
|
443
|
+
}
|
|
444
|
+
const totals = {};
|
|
445
|
+
const fieldMappings = PROVIDER_USAGE_SHAPE_MAPPINGS[providerId].billingRelevantFields;
|
|
446
|
+
for (const fieldMapping of fieldMappings) {
|
|
447
|
+
for (const usage of usages) {
|
|
448
|
+
const usageRecord = asRecord(usage);
|
|
449
|
+
const value = usageRecord?.[fieldMapping.usageFieldPath];
|
|
450
|
+
if (typeof value !== "number") {
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
totals[fieldMapping.usageFieldPath] =
|
|
454
|
+
(totals[fieldMapping.usageFieldPath] ?? 0) + value;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return extractObservedProviderNativeUsage({
|
|
458
|
+
providerId,
|
|
459
|
+
usagePayload: totals,
|
|
460
|
+
});
|
|
461
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ChatUsageProviderId, type ExtractedTokenUsage } from "../../domain/run/model/types.js";
|
|
2
|
+
import type { ChatArtifactFormat } from "./types.js";
|
|
3
|
+
export interface ProviderUsageFieldMapping {
|
|
4
|
+
artifactFieldPath: string;
|
|
5
|
+
usageFieldPath: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ProviderUsageShapeMapping {
|
|
8
|
+
providerId: ChatUsageProviderId;
|
|
9
|
+
artifactFormat: ChatArtifactFormat;
|
|
10
|
+
artifactShape: string;
|
|
11
|
+
usageRootPath: string;
|
|
12
|
+
billingRelevantFields: readonly ProviderUsageFieldMapping[];
|
|
13
|
+
}
|
|
14
|
+
export declare const PROVIDER_USAGE_SHAPE_MAPPINGS: Record<ChatUsageProviderId, ProviderUsageShapeMapping>;
|
|
15
|
+
interface ExtractObservedProviderNativeUsageOptions {
|
|
16
|
+
providerId: ChatUsageProviderId;
|
|
17
|
+
usagePayload: unknown;
|
|
18
|
+
}
|
|
19
|
+
export declare function extractObservedProviderNativeUsage(options: ExtractObservedProviderNativeUsageOptions): ExtractedTokenUsage | undefined;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { extractedTokenUsageSchemaByProvider, } from "../../domain/run/model/types.js";
|
|
2
|
+
export const PROVIDER_USAGE_SHAPE_MAPPINGS = {
|
|
3
|
+
claude: {
|
|
4
|
+
providerId: "claude",
|
|
5
|
+
artifactFormat: "jsonl",
|
|
6
|
+
artifactShape: "message.usage",
|
|
7
|
+
usageRootPath: "usage",
|
|
8
|
+
billingRelevantFields: [
|
|
9
|
+
{
|
|
10
|
+
artifactFieldPath: "usage.input_tokens",
|
|
11
|
+
usageFieldPath: "input_tokens",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
artifactFieldPath: "usage.output_tokens",
|
|
15
|
+
usageFieldPath: "output_tokens",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
artifactFieldPath: "usage.cache_read_input_tokens",
|
|
19
|
+
usageFieldPath: "cache_read_input_tokens",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
artifactFieldPath: "usage.cache_creation_input_tokens",
|
|
23
|
+
usageFieldPath: "cache_creation_input_tokens",
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
codex: {
|
|
28
|
+
providerId: "codex",
|
|
29
|
+
artifactFormat: "jsonl",
|
|
30
|
+
artifactShape: "event_msg(type=token_count).info.total_token_usage",
|
|
31
|
+
usageRootPath: "event_msg.info.total_token_usage",
|
|
32
|
+
billingRelevantFields: [
|
|
33
|
+
{
|
|
34
|
+
artifactFieldPath: "event_msg.info.total_token_usage.input_tokens",
|
|
35
|
+
usageFieldPath: "input_tokens",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
artifactFieldPath: "event_msg.info.total_token_usage.cached_input_tokens",
|
|
39
|
+
usageFieldPath: "cached_input_tokens",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
artifactFieldPath: "event_msg.info.total_token_usage.output_tokens",
|
|
43
|
+
usageFieldPath: "output_tokens",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
artifactFieldPath: "event_msg.info.total_token_usage.reasoning_output_tokens",
|
|
47
|
+
usageFieldPath: "reasoning_output_tokens",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
artifactFieldPath: "event_msg.info.total_token_usage.total_tokens",
|
|
51
|
+
usageFieldPath: "total_tokens",
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
gemini: {
|
|
56
|
+
providerId: "gemini",
|
|
57
|
+
artifactFormat: "json",
|
|
58
|
+
artifactShape: "transcript.tokens",
|
|
59
|
+
usageRootPath: "tokens",
|
|
60
|
+
billingRelevantFields: [
|
|
61
|
+
{
|
|
62
|
+
artifactFieldPath: "tokens.input",
|
|
63
|
+
usageFieldPath: "input",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
artifactFieldPath: "tokens.output",
|
|
67
|
+
usageFieldPath: "output",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
artifactFieldPath: "tokens.cached",
|
|
71
|
+
usageFieldPath: "cached",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
artifactFieldPath: "tokens.thoughts",
|
|
75
|
+
usageFieldPath: "thoughts",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
artifactFieldPath: "tokens.tool",
|
|
79
|
+
usageFieldPath: "tool",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
artifactFieldPath: "tokens.total",
|
|
83
|
+
usageFieldPath: "total",
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
export function extractObservedProviderNativeUsage(options) {
|
|
89
|
+
const mapping = PROVIDER_USAGE_SHAPE_MAPPINGS[options.providerId];
|
|
90
|
+
const usageRecord = asRecord(options.usagePayload);
|
|
91
|
+
if (!usageRecord) {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
const nativeUsage = {};
|
|
95
|
+
for (const fieldMapping of mapping.billingRelevantFields) {
|
|
96
|
+
const value = getPathValue(usageRecord, fieldMapping.usageFieldPath);
|
|
97
|
+
const tokenCount = normalizeTokenCount(value);
|
|
98
|
+
if (tokenCount !== undefined) {
|
|
99
|
+
nativeUsage[fieldMapping.usageFieldPath] = tokenCount;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (Object.keys(nativeUsage).length === 0) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
const parsed = extractedTokenUsageSchemaByProvider[options.providerId].safeParse(nativeUsage);
|
|
106
|
+
if (!parsed.success) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
return parsed.data;
|
|
110
|
+
}
|
|
111
|
+
function asRecord(value) {
|
|
112
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
return value;
|
|
116
|
+
}
|
|
117
|
+
function getPathValue(record, path) {
|
|
118
|
+
let current = record;
|
|
119
|
+
for (const segment of path.split(".")) {
|
|
120
|
+
const currentRecord = asRecord(current);
|
|
121
|
+
if (!currentRecord || !(segment in currentRecord)) {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
current = currentRecord[segment];
|
|
125
|
+
}
|
|
126
|
+
return current;
|
|
127
|
+
}
|
|
128
|
+
function normalizeTokenCount(value) {
|
|
129
|
+
if (typeof value !== "number" ||
|
|
130
|
+
!Number.isFinite(value) ||
|
|
131
|
+
!Number.isInteger(value) ||
|
|
132
|
+
value < 0) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
return value;
|
|
136
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readdir } from "node:fs/promises";
|
|
2
2
|
import { join, relative } from "node:path";
|
|
3
|
-
import { AgentProcessError } from "../
|
|
3
|
+
import { AgentProcessError } from "../domain/run/competition/errors.js";
|
|
4
4
|
const FORBIDDEN_SEGMENTS = new Set([".gemini", ".codex", ".claude"]);
|
|
5
5
|
export async function enforceCredentialExclusion(options) {
|
|
6
6
|
const { workspacePath, diffContent } = options;
|
|
@@ -22,7 +22,7 @@ export class WorkspaceDependencyCleanupError extends Error {
|
|
|
22
22
|
const REPO_BOUNDARY_DESCRIPTION = "the repository root";
|
|
23
23
|
const WORKSPACE_BOUNDARY_DESCRIPTION = "the workspace directory";
|
|
24
24
|
function formatEnvironmentPathRuntimeError(context, detail) {
|
|
25
|
-
return `Invalid
|
|
25
|
+
return `Invalid \`${context.key}\` path \`${context.value}\`: ${detail}.`;
|
|
26
26
|
}
|
|
27
27
|
function assertRepoRelativeEnvironmentPath(context) {
|
|
28
28
|
const value = context.value;
|
|
@@ -43,7 +43,7 @@ function guardResolvedPath(context, root, resolvedPath, boundaryDescription) {
|
|
|
43
43
|
return assertPathWithinRoot(root, resolvedPath);
|
|
44
44
|
}
|
|
45
45
|
catch {
|
|
46
|
-
throw new WorkspaceSetupError(formatEnvironmentPathRuntimeError(context, `resolved path
|
|
46
|
+
throw new WorkspaceSetupError(formatEnvironmentPathRuntimeError(context, `resolved path \`${resolvedPath}\` escapes ${boundaryDescription} (\`${root}\`).`));
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
function createNodeContext(index, value) {
|
|
@@ -85,7 +85,7 @@ async function ensureNodeDependencies(root, workspacePath, environment) {
|
|
|
85
85
|
assertRepoRelativeEnvironmentPath(context);
|
|
86
86
|
const repoDependencyPath = guardResolvedPath(context, root, resolvePath(root, relativeRoot), REPO_BOUNDARY_DESCRIPTION);
|
|
87
87
|
if (!(await pathExists(repoDependencyPath))) {
|
|
88
|
-
throw new WorkspaceSetupError(formatEnvironmentPathRuntimeError(context, `expected directory at
|
|
88
|
+
throw new WorkspaceSetupError(formatEnvironmentPathRuntimeError(context, `expected directory at \`${repoDependencyPath}\` but it does not exist.`));
|
|
89
89
|
}
|
|
90
90
|
const workspaceDependencyPath = guardResolvedPath(context, workspacePath, resolvePath(workspacePath, relativeRoot), WORKSPACE_BOUNDARY_DESCRIPTION);
|
|
91
91
|
await ensureDirectoryLink(repoDependencyPath, workspaceDependencyPath, {
|
|
@@ -104,7 +104,7 @@ async function ensurePythonEnvironment(root, workspacePath, environment) {
|
|
|
104
104
|
assertRepoRelativeEnvironmentPath(context);
|
|
105
105
|
const repoPythonPath = guardResolvedPath(context, root, resolvePath(root, pythonPath), REPO_BOUNDARY_DESCRIPTION);
|
|
106
106
|
if (!(await pathExists(repoPythonPath))) {
|
|
107
|
-
throw new WorkspaceSetupError(formatEnvironmentPathRuntimeError(context, `expected directory at
|
|
107
|
+
throw new WorkspaceSetupError(formatEnvironmentPathRuntimeError(context, `expected directory at \`${repoPythonPath}\` but it does not exist.`));
|
|
108
108
|
}
|
|
109
109
|
const workspacePythonPath = guardResolvedPath(context, workspacePath, resolvePath(workspacePath, ".venv"), WORKSPACE_BOUNDARY_DESCRIPTION);
|
|
110
110
|
await ensureDirectoryLink(repoPythonPath, workspacePythonPath, {
|
|
@@ -6,6 +6,11 @@ export declare class WorkspaceMissingEntryError extends WorkspaceError {
|
|
|
6
6
|
readonly entryPath: string;
|
|
7
7
|
constructor(entryPath: string);
|
|
8
8
|
}
|
|
9
|
+
export declare class WorkspaceWrongTypeEntryError extends WorkspaceError {
|
|
10
|
+
readonly entryPath: string;
|
|
11
|
+
readonly expectedType: "file" | "directory";
|
|
12
|
+
constructor(entryPath: string, expectedType: "file" | "directory");
|
|
13
|
+
}
|
|
9
14
|
export declare class WorkspaceNotInitializedError extends WorkspaceError {
|
|
10
15
|
readonly missingEntries: readonly string[];
|
|
11
16
|
constructor(missingEntries: readonly string[]);
|