@jinn-network/client 0.1.7 → 0.1.8-canary.09a3b2f6
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 +67 -1
- package/dist/adapters/mech/adapter.d.ts +39 -2
- package/dist/adapters/mech/adapter.js +178 -20
- package/dist/adapters/mech/adapter.js.map +1 -1
- package/dist/adapters/mech/contracts.d.ts +22 -1
- package/dist/adapters/mech/contracts.js +96 -52
- package/dist/adapters/mech/contracts.js.map +1 -1
- package/dist/adapters/mech/safe-revert.d.ts +4 -0
- package/dist/adapters/mech/safe-revert.js +5 -1
- package/dist/adapters/mech/safe-revert.js.map +1 -1
- package/dist/adapters/mech/safe.d.ts +1 -1
- package/dist/adapters/mech/safe.js +10 -4
- package/dist/adapters/mech/safe.js.map +1 -1
- package/dist/adapters/mech/types.d.ts +6 -1
- package/dist/adapters/mech/types.js.map +1 -1
- package/dist/agent/operator-claude.js +8 -0
- package/dist/agent/operator-claude.js.map +1 -1
- package/dist/api/activity-events-endpoint.d.ts +14 -0
- package/dist/api/activity-events-endpoint.js +59 -0
- package/dist/api/activity-events-endpoint.js.map +1 -0
- package/dist/api/bootstrap-endpoint.d.ts +1 -2
- package/dist/api/bootstrap-endpoint.js +42 -24
- package/dist/api/bootstrap-endpoint.js.map +1 -1
- package/dist/api/codex-doctor-endpoint.d.ts +22 -5
- package/dist/api/codex-doctor-endpoint.js +136 -17
- package/dist/api/codex-doctor-endpoint.js.map +1 -1
- package/dist/api/debug-report-endpoint.d.ts +27 -0
- package/dist/api/debug-report-endpoint.js +157 -0
- package/dist/api/debug-report-endpoint.js.map +1 -0
- package/dist/api/discovery-endpoint.d.ts +1 -0
- package/dist/api/discovery-endpoint.js +24 -0
- package/dist/api/discovery-endpoint.js.map +1 -1
- package/dist/api/fleet-build.d.ts +1 -7
- package/dist/api/fleet-build.js +0 -7
- package/dist/api/fleet-build.js.map +1 -1
- package/dist/api/gather-status.d.ts +39 -0
- package/dist/api/gather-status.js +181 -84
- package/dist/api/gather-status.js.map +1 -1
- package/dist/api/hermes-doctor-endpoint.d.ts +15 -7
- package/dist/api/hermes-doctor-endpoint.js +56 -19
- package/dist/api/hermes-doctor-endpoint.js.map +1 -1
- package/dist/api/launcher-status.d.ts +4 -2
- package/dist/api/launcher-status.js +11 -10
- package/dist/api/launcher-status.js.map +1 -1
- package/dist/api/launcher-tasks.d.ts +1 -1
- package/dist/api/launcher-tasks.js +12 -8
- package/dist/api/launcher-tasks.js.map +1 -1
- package/dist/api/loop-completion-build.d.ts +79 -0
- package/dist/api/loop-completion-build.js +155 -0
- package/dist/api/loop-completion-build.js.map +1 -0
- package/dist/api/operator-artifacts-endpoint.js +73 -6
- package/dist/api/operator-artifacts-endpoint.js.map +1 -1
- package/dist/api/portfolio-v0-build.d.ts +7 -1
- package/dist/api/portfolio-v0-build.js +6 -2
- package/dist/api/portfolio-v0-build.js.map +1 -1
- package/dist/api/prediction-v1-build.d.ts +6 -0
- package/dist/api/prediction-v1-build.js +3 -1
- package/dist/api/prediction-v1-build.js.map +1 -1
- package/dist/api/server.d.ts +17 -0
- package/dist/api/server.js +40 -1
- package/dist/api/server.js.map +1 -1
- package/dist/api/setup-endpoints.d.ts +13 -9
- package/dist/api/setup-endpoints.js +50 -173
- package/dist/api/setup-endpoints.js.map +1 -1
- package/dist/api/solvernets-endpoints.js +33 -63
- package/dist/api/solvernets-endpoints.js.map +1 -1
- package/dist/api/status-build.d.ts +140 -17
- package/dist/api/status-build.js +47 -34
- package/dist/api/status-build.js.map +1 -1
- package/dist/api/status-harness-rollup.d.ts +35 -0
- package/dist/api/status-harness-rollup.js +45 -0
- package/dist/api/status-harness-rollup.js.map +1 -0
- package/dist/api/status-rollup-build.d.ts +0 -4
- package/dist/api/status-rollup-build.js +0 -4
- package/dist/api/status-rollup-build.js.map +1 -1
- package/dist/api/task-runs-build.d.ts +8 -0
- package/dist/api/task-runs-build.js +5 -1
- package/dist/api/task-runs-build.js.map +1 -1
- package/dist/build-info.json +4 -4
- package/dist/build-meta.json +1 -1
- package/dist/captures/live-publisher.js +24 -4
- package/dist/captures/live-publisher.js.map +1 -1
- package/dist/captures/publish.d.ts +1 -1
- package/dist/chain-read-errors.d.ts +12 -0
- package/dist/chain-read-errors.js +26 -1
- package/dist/chain-read-errors.js.map +1 -1
- package/dist/cli/commands/codedigest-revert-check.d.ts +33 -0
- package/dist/cli/commands/codedigest-revert-check.js +253 -0
- package/dist/cli/commands/codedigest-revert-check.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +3 -0
- package/dist/cli/commands/doctor.js +35 -0
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/eval.d.ts +76 -0
- package/dist/cli/commands/eval.js +401 -0
- package/dist/cli/commands/eval.js.map +1 -0
- package/dist/cli/commands/rewards.d.ts +2 -0
- package/dist/cli/commands/rewards.js +27 -0
- package/dist/cli/commands/rewards.js.map +1 -1
- package/dist/cli/commands/solver-nets.d.ts +1 -0
- package/dist/cli/commands/solver-nets.js +245 -22
- package/dist/cli/commands/solver-nets.js.map +1 -1
- package/dist/cli/commands/solver-plugins-block.d.ts +33 -0
- package/dist/cli/commands/solver-plugins-block.js +118 -0
- package/dist/cli/commands/solver-plugins-block.js.map +1 -0
- package/dist/cli/commands/solver-plugins-feedback.d.ts +72 -0
- package/dist/cli/commands/solver-plugins-feedback.js +262 -0
- package/dist/cli/commands/solver-plugins-feedback.js.map +1 -0
- package/dist/cli/commands/solver-plugins-read.d.ts +54 -0
- package/dist/cli/commands/solver-plugins-read.js +259 -0
- package/dist/cli/commands/solver-plugins-read.js.map +1 -0
- package/dist/cli/commands/solver-plugins.d.ts +35 -0
- package/dist/cli/commands/solver-plugins.js +399 -2
- package/dist/cli/commands/solver-plugins.js.map +1 -1
- package/dist/cli/commands/status.js +0 -1
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/tasks.js +15 -2
- package/dist/cli/commands/tasks.js.map +1 -1
- package/dist/cli/index.js +4 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/task-native-readiness.d.ts +7 -0
- package/dist/cli/task-native-readiness.js +7 -5
- package/dist/cli/task-native-readiness.js.map +1 -1
- package/dist/config.d.ts +206 -232
- package/dist/config.js +289 -107
- package/dist/config.js.map +1 -1
- package/dist/daemon/ai-units-gate.d.ts +54 -0
- package/dist/daemon/ai-units-gate.js +83 -0
- package/dist/daemon/ai-units-gate.js.map +1 -0
- package/dist/daemon/creator.js +13 -0
- package/dist/daemon/creator.js.map +1 -1
- package/dist/daemon/daemon.d.ts +10 -0
- package/dist/daemon/daemon.js +205 -30
- package/dist/daemon/daemon.js.map +1 -1
- package/dist/daemon/eviction-loop.d.ts +7 -0
- package/dist/daemon/eviction-loop.js +16 -0
- package/dist/daemon/eviction-loop.js.map +1 -1
- package/dist/daemon/gate-logger.d.ts +9 -0
- package/dist/daemon/gate-logger.js +2 -0
- package/dist/daemon/gate-logger.js.map +1 -0
- package/dist/daemon/jinn-claim-loop.js +22 -4
- package/dist/daemon/jinn-claim-loop.js.map +1 -1
- package/dist/daemon/readiness-gate.d.ts +1 -4
- package/dist/daemon/readiness-gate.js.map +1 -1
- package/dist/daemon/spend-cap-gate.d.ts +40 -0
- package/dist/daemon/spend-cap-gate.js +46 -0
- package/dist/daemon/spend-cap-gate.js.map +1 -0
- package/dist/dashboard/assets/index-3quVQqik.js +167 -0
- package/dist/dashboard/assets/index-BVAWkLwY.css +1 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/discovery/http.d.ts +7 -0
- package/dist/discovery/http.js +567 -24
- package/dist/discovery/http.js.map +1 -1
- package/dist/discovery/onchain.js +197 -5
- package/dist/discovery/onchain.js.map +1 -1
- package/dist/discovery/types.d.ts +235 -0
- package/dist/discovery/types.js +40 -0
- package/dist/discovery/types.js.map +1 -1
- package/dist/discovery/with-fallback.js +41 -0
- package/dist/discovery/with-fallback.js.map +1 -1
- package/dist/earning/bootstrap.d.ts +31 -3
- package/dist/earning/bootstrap.js +94 -22
- package/dist/earning/bootstrap.js.map +1 -1
- package/dist/earning/faucet.d.ts +1 -1
- package/dist/earning/faucet.js +2 -2
- package/dist/earning/faucet.js.map +1 -1
- package/dist/earning/safe-adapter.js +34 -11
- package/dist/earning/safe-adapter.js.map +1 -1
- package/dist/earning/types.d.ts +6 -6
- package/dist/earning/viem-clients.d.ts +11 -4
- package/dist/earning/viem-clients.js +14 -5
- package/dist/earning/viem-clients.js.map +1 -1
- package/dist/erc8004/identity.d.ts +19 -3
- package/dist/erc8004/identity.js +38 -11
- package/dist/erc8004/identity.js.map +1 -1
- package/dist/erc8004/index.d.ts +1 -1
- package/dist/erc8004/index.js.map +1 -1
- package/dist/eval/eval-harness-run.d.ts +63 -0
- package/dist/eval/eval-harness-run.js +123 -0
- package/dist/eval/eval-harness-run.js.map +1 -0
- package/dist/eval/orchestrator.d.ts +163 -0
- package/dist/eval/orchestrator.js +232 -0
- package/dist/eval/orchestrator.js.map +1 -0
- package/dist/eval/paired.d.ts +68 -0
- package/dist/eval/paired.js +93 -0
- package/dist/eval/paired.js.map +1 -0
- package/dist/eval/resolve-slate-tasks.d.ts +35 -0
- package/dist/eval/resolve-slate-tasks.js +56 -0
- package/dist/eval/resolve-slate-tasks.js.map +1 -0
- package/dist/eval/screen-discovery.d.ts +22 -0
- package/dist/eval/screen-discovery.js +71 -0
- package/dist/eval/screen-discovery.js.map +1 -0
- package/dist/eval/screen-progress.d.ts +41 -0
- package/dist/eval/screen-progress.js +60 -0
- package/dist/eval/screen-progress.js.map +1 -0
- package/dist/eval/screen-runner.d.ts +30 -0
- package/dist/eval/screen-runner.js +289 -0
- package/dist/eval/screen-runner.js.map +1 -0
- package/dist/eval/screen.d.ts +107 -0
- package/dist/eval/screen.js +159 -0
- package/dist/eval/screen.js.map +1 -0
- package/dist/eval/slope.d.ts +29 -0
- package/dist/eval/slope.js +46 -0
- package/dist/eval/slope.js.map +1 -0
- package/dist/eval/train-sequence.d.ts +35 -0
- package/dist/eval/train-sequence.js +59 -0
- package/dist/eval/train-sequence.js.map +1 -0
- package/dist/eval/wilson.d.ts +45 -0
- package/dist/eval/wilson.js +48 -0
- package/dist/eval/wilson.js.map +1 -0
- package/dist/events/types.d.ts +2 -2
- package/dist/harnesses/cost-estimates.d.ts +10 -31
- package/dist/harnesses/cost-estimates.js +11 -43
- package/dist/harnesses/cost-estimates.js.map +1 -1
- package/dist/harnesses/engine/canonical-json.js +5 -3
- package/dist/harnesses/engine/canonical-json.js.map +1 -1
- package/dist/harnesses/engine/engine.d.ts +37 -4
- package/dist/harnesses/engine/engine.js +151 -20
- package/dist/harnesses/engine/engine.js.map +1 -1
- package/dist/harnesses/engine/persistence.d.ts +38 -4
- package/dist/harnesses/engine/persistence.js +71 -6
- package/dist/harnesses/engine/persistence.js.map +1 -1
- package/dist/harnesses/engine/state.d.ts +9 -0
- package/dist/harnesses/engine/state.js +23 -10
- package/dist/harnesses/engine/state.js.map +1 -1
- package/dist/harnesses/impls/hermes-agent/adapter.d.ts +2 -0
- package/dist/harnesses/impls/hermes-agent/adapter.js +8 -5
- package/dist/harnesses/impls/hermes-agent/adapter.js.map +1 -1
- package/dist/harnesses/impls/hermes-agent/bootstrap.d.ts +1 -0
- package/dist/harnesses/impls/hermes-agent/bootstrap.js +10 -3
- package/dist/harnesses/impls/hermes-agent/bootstrap.js.map +1 -1
- package/dist/harnesses/impls/hermes-agent/config-builder.d.ts +1 -1
- package/dist/harnesses/impls/hermes-agent/config-builder.js +4 -2
- package/dist/harnesses/impls/hermes-agent/config-builder.js.map +1 -1
- package/dist/harnesses/impls/hermes-agent/harness.d.ts +31 -3
- package/dist/harnesses/impls/hermes-agent/harness.js +84 -7
- package/dist/harnesses/impls/hermes-agent/harness.js.map +1 -1
- package/dist/harnesses/impls/hermes-agent/prompt.d.ts +6 -6
- package/dist/harnesses/impls/hermes-agent/prompt.js +6 -6
- package/dist/harnesses/impls/index.d.ts +2 -0
- package/dist/harnesses/impls/index.js +2 -0
- package/dist/harnesses/impls/index.js.map +1 -1
- package/dist/harnesses/impls/learner/adapters/claude-code.d.ts +17 -0
- package/dist/harnesses/impls/learner/adapters/claude-code.js +118 -14
- package/dist/harnesses/impls/learner/adapters/claude-code.js.map +1 -1
- package/dist/harnesses/impls/learner/adapters/codex-code.d.ts +9 -0
- package/dist/harnesses/impls/learner/adapters/codex-code.js +30 -8
- package/dist/harnesses/impls/learner/adapters/codex-code.js.map +1 -1
- package/dist/harnesses/impls/learner/harness.d.ts +41 -1
- package/dist/harnesses/impls/learner/harness.js +78 -4
- package/dist/harnesses/impls/learner/harness.js.map +1 -1
- package/dist/harnesses/impls/learner/harvest.d.ts +3 -1
- package/dist/harnesses/impls/learner/harvest.js +30 -6
- package/dist/harnesses/impls/learner/harvest.js.map +1 -1
- package/dist/harnesses/impls/learner/plugin-path.js +1 -0
- package/dist/harnesses/impls/learner/plugin-path.js.map +1 -1
- package/dist/harnesses/impls/learner/restoration-patch.d.ts +2 -2
- package/dist/harnesses/impls/learner/restoration-patch.js +25 -6
- package/dist/harnesses/impls/learner/restoration-patch.js.map +1 -1
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.js +21 -1
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.js.map +1 -1
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/harness.js +3 -1
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/harness.js.map +1 -1
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.d.ts +74 -5
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.js +103 -32
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.js.map +1 -1
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/index.d.ts +2 -2
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/index.js +3 -1
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/index.js.map +1 -1
- package/dist/harnesses/readiness-registry.d.ts +7 -0
- package/dist/harnesses/readiness-registry.js +9 -0
- package/dist/harnesses/readiness-registry.js.map +1 -1
- package/dist/harnesses/types.d.ts +14 -0
- package/dist/learner/revert-decision.d.ts +74 -0
- package/dist/learner/revert-decision.js +73 -0
- package/dist/learner/revert-decision.js.map +1 -0
- package/dist/learner/revert-stats.d.ts +38 -0
- package/dist/learner/revert-stats.js +86 -0
- package/dist/learner/revert-stats.js.map +1 -0
- package/dist/local-provider-url.d.ts +3 -0
- package/dist/local-provider-url.js +28 -0
- package/dist/local-provider-url.js.map +1 -0
- package/dist/main.js +199 -104
- package/dist/main.js.map +1 -1
- package/dist/mcp/get-codedigest-reward.d.ts +13 -0
- package/dist/mcp/get-codedigest-reward.js +23 -0
- package/dist/mcp/get-codedigest-reward.js.map +1 -0
- package/dist/mcp/server.js +23 -0
- package/dist/mcp/server.js.map +1 -1
- package/dist/observability/debug-report-assemble.d.ts +43 -0
- package/dist/observability/debug-report-assemble.js +80 -0
- package/dist/observability/debug-report-assemble.js.map +1 -0
- package/dist/observability/emit-event.d.ts +9 -2
- package/dist/observability/emit-event.js +36 -2
- package/dist/observability/emit-event.js.map +1 -1
- package/dist/observability/file-logger.d.ts +69 -0
- package/dist/observability/file-logger.js +177 -0
- package/dist/observability/file-logger.js.map +1 -0
- package/dist/observability/redact-secrets.d.ts +65 -0
- package/dist/observability/redact-secrets.js +300 -0
- package/dist/observability/redact-secrets.js.map +1 -0
- package/dist/observability/tar.d.ts +30 -0
- package/dist/observability/tar.js +102 -0
- package/dist/observability/tar.js.map +1 -0
- package/dist/plugins/learner/.claude-plugin/plugin.json +1 -1
- package/dist/plugins/learner/.codex-plugin/plugin.json +1 -1
- package/dist/plugins/learner/hooks/session-start +30 -1
- package/dist/plugins/learner/skills/learn/consolidator-prompt.md +22 -1
- package/dist/plugins/learner/skills/learn/promoter-prompt.md +72 -1
- package/dist/preflight/deployment-readiness.d.ts +147 -0
- package/dist/preflight/deployment-readiness.js +366 -0
- package/dist/preflight/deployment-readiness.js.map +1 -0
- package/dist/preflight/pidfile-liveness.d.ts +50 -0
- package/dist/preflight/pidfile-liveness.js +117 -0
- package/dist/preflight/pidfile-liveness.js.map +1 -0
- package/dist/preflight/rpc-network.d.ts +40 -0
- package/dist/preflight/rpc-network.js +67 -1
- package/dist/preflight/rpc-network.js.map +1 -1
- package/dist/rpc/transport.d.ts +145 -0
- package/dist/rpc/transport.js +319 -0
- package/dist/rpc/transport.js.map +1 -0
- package/dist/scripts/donation-consumption-acceptance.js +7 -28
- package/dist/scripts/donation-consumption-acceptance.js.map +1 -1
- package/dist/scripts/swe-rebench-v2-pytest-missing.json +16 -0
- package/dist/solver-nets/prediction-operator-ux.d.ts +1 -2
- package/dist/solver-nets/prediction-operator-ux.js +56 -53
- package/dist/solver-nets/prediction-operator-ux.js.map +1 -1
- package/dist/solver-nets/registry.d.ts +19 -1
- package/dist/solver-nets/registry.js +37 -24
- package/dist/solver-nets/registry.js.map +1 -1
- package/dist/solver-types/_swe-rebench-v2-held-out-slate.d.ts +76 -0
- package/dist/solver-types/_swe-rebench-v2-held-out-slate.js +156 -0
- package/dist/solver-types/_swe-rebench-v2-held-out-slate.js.map +1 -0
- package/dist/solver-types/_swe-rebench-v2-pool-recovery.d.ts +81 -0
- package/dist/solver-types/_swe-rebench-v2-pool-recovery.js +116 -0
- package/dist/solver-types/_swe-rebench-v2-pool-recovery.js.map +1 -0
- package/dist/solver-types/_swe-rebench-v2-pool.d.ts +9 -2
- package/dist/solver-types/_swe-rebench-v2-pool.js +15 -20
- package/dist/solver-types/_swe-rebench-v2-pool.js.map +1 -1
- package/dist/solver-types/_swe-rebench-v2-state.d.ts +24 -0
- package/dist/solver-types/_swe-rebench-v2-state.js +33 -0
- package/dist/solver-types/_swe-rebench-v2-state.js.map +1 -1
- package/dist/solver-types/_swe-rebench-v2-validated-pool.d.ts +116 -2
- package/dist/solver-types/_swe-rebench-v2-validated-pool.js +296 -21
- package/dist/solver-types/_swe-rebench-v2-validated-pool.js.map +1 -1
- package/dist/solver-types/slates/held-out-slate.swe-rebench-v2.v1.json +20 -0
- package/dist/solver-types/slates/held-out-slate.swe-rebench-v2.v2.json +19 -0
- package/dist/solver-types/slates/held-out-slate.swe-rebench-v2.v2.screening-report.json +628 -0
- package/dist/solver-types/solver-type.d.ts +8 -0
- package/dist/solver-types/swe-rebench-v2-auto.d.ts +20 -11
- package/dist/solver-types/swe-rebench-v2-auto.js +64 -19
- package/dist/solver-types/swe-rebench-v2-auto.js.map +1 -1
- package/dist/solver-types/swe-rebench-v2.d.ts +10 -2
- package/dist/solver-types/swe-rebench-v2.js +233 -13
- package/dist/solver-types/swe-rebench-v2.js.map +1 -1
- package/dist/solvernets/daemon-init.d.ts +1 -1
- package/dist/solvernets/daemon-init.js +19 -4
- package/dist/solvernets/daemon-init.js.map +1 -1
- package/dist/solvernets/launched-record-dispatcher.d.ts +7 -0
- package/dist/solvernets/launched-record-dispatcher.js +10 -4
- package/dist/solvernets/launched-record-dispatcher.js.map +1 -1
- package/dist/solvernets/registry-client-erc8004.js +40 -37
- package/dist/solvernets/registry-client-erc8004.js.map +1 -1
- package/dist/solvernets/registry-client.d.ts +6 -0
- package/dist/solvernets/store.d.ts +2 -2
- package/dist/solvernets/store.js +7 -2
- package/dist/solvernets/store.js.map +1 -1
- package/dist/spend/ai-units-config.d.ts +49 -0
- package/dist/spend/ai-units-config.js +34 -0
- package/dist/spend/ai-units-config.js.map +1 -0
- package/dist/spend/ai-units.d.ts +140 -0
- package/dist/spend/ai-units.js +229 -0
- package/dist/spend/ai-units.js.map +1 -0
- package/dist/spend/cost-surface-status.d.ts +12 -0
- package/dist/spend/cost-surface-status.js +24 -0
- package/dist/spend/cost-surface-status.js.map +1 -0
- package/dist/spend/credential.d.ts +39 -0
- package/dist/spend/credential.js +71 -0
- package/dist/spend/credential.js.map +1 -0
- package/dist/spend/daemon-config.d.ts +13 -0
- package/dist/spend/daemon-config.js +24 -0
- package/dist/spend/daemon-config.js.map +1 -0
- package/dist/spend/pricing.d.ts +16 -0
- package/dist/spend/pricing.js +26 -0
- package/dist/spend/pricing.js.map +1 -0
- package/dist/spend/record.d.ts +13 -0
- package/dist/spend/record.js +43 -0
- package/dist/spend/record.js.map +1 -0
- package/dist/spend/usage.d.ts +27 -0
- package/dist/spend/usage.js +113 -0
- package/dist/spend/usage.js.map +1 -0
- package/dist/store/store.d.ts +187 -0
- package/dist/store/store.js +467 -4
- package/dist/store/store.js.map +1 -1
- package/dist/trajectory/transcript-parsers/codex-session.d.ts +12 -6
- package/dist/trajectory/transcript-parsers/codex-session.js +114 -13
- package/dist/trajectory/transcript-parsers/codex-session.js.map +1 -1
- package/dist/trajectory/transcript-parsers/types.d.ts +8 -8
- package/dist/trajectory/transcript-session-dirs.d.ts +18 -0
- package/dist/trajectory/transcript-session-dirs.js +85 -0
- package/dist/trajectory/transcript-session-dirs.js.map +1 -0
- package/dist/trajectory/transcript-watcher.d.ts +20 -1
- package/dist/trajectory/transcript-watcher.js +108 -32
- package/dist/trajectory/transcript-watcher.js.map +1 -1
- package/dist/tx-retry.d.ts +25 -0
- package/dist/tx-retry.js +95 -7
- package/dist/tx-retry.js.map +1 -1
- package/dist/types/payloads/portfolio-v0.d.ts +3 -3
- package/dist/types/payloads/prediction-apy-v0.d.ts +3 -3
- package/dist/types/payloads/prediction-v0.d.ts +12 -12
- package/dist/vendor/@jinn-network/sdk/dist/payloads/swe-rebench-v2.d.ts +108 -1
- package/dist/vendor/@jinn-network/sdk/dist/payloads/swe-rebench-v2.js +25 -1
- package/dist/vendor/@jinn-network/sdk/dist/solvernets/swe-rebench-v2-held-out-slate.d.ts +65 -0
- package/dist/vendor/@jinn-network/sdk/dist/solvernets/swe-rebench-v2-held-out-slate.js +123 -0
- package/dist/vendor/@jinn-network/sdk/dist/solvernets/swe-rebench-v2.d.ts +2 -2
- package/dist/vendor/@jinn-network/sdk/dist/solvernets/swe-rebench-v2.js +1 -1
- package/dist/vendor/@jinn-network/sdk/package.json +4 -0
- package/docker-compose.yml +3 -2
- package/package.json +30 -18
- package/plugins/learner/.claude-plugin/plugin.json +1 -1
- package/plugins/learner/.codex-plugin/plugin.json +1 -1
- package/plugins/learner/hooks/session-start +30 -1
- package/plugins/learner/skills/learn/consolidator-prompt.md +22 -1
- package/plugins/learner/skills/learn/promoter-prompt.md +72 -1
- package/plugins/swe-rebench-v2-diffmin/README.md +10 -9
- package/plugins/swe-rebench-v2-diffmin/jinn.plugin.json +1 -1
- package/plugins/swe-rebench-v2-diffmin/skills/diffmin/SKILL.md +15 -10
- package/plugins/swe-rebench-v2-diffmin/skills/test-map/SKILL.md +10 -12
- package/plugins/swe-rebench-v2-runtime/.claude-plugin/plugin.json +1 -1
- package/plugins/swe-rebench-v2-runtime/.codex-plugin/plugin.json +3 -3
- package/plugins/swe-rebench-v2-runtime/README.md +6 -6
- package/plugins/swe-rebench-v2-runtime/hooks/hooks.json +16 -0
- package/plugins/swe-rebench-v2-runtime/hooks/session-start +74 -0
- package/plugins/swe-rebench-v2-runtime/jinn.plugin.json +2 -3
- package/plugins/swe-rebench-v2-runtime/skills/task/SKILL.md +81 -0
- package/dist/dashboard/assets/index-BUlE8F3Y.js +0 -330
- package/dist/dashboard/assets/index-blqc7eqq.css +0 -32
- package/plugins/swe-rebench-v2-runtime/skills/orient/SKILL.md +0 -29
- package/plugins/swe-rebench-v2-runtime/skills/plan/SKILL.md +0 -53
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI-units calibration — the universal cost language for the M1
|
|
3
|
+
* cost-protection throttle (issue #815).
|
|
4
|
+
*
|
|
5
|
+
* One "AI unit" is the marginal USD cost of one task on the
|
|
6
|
+
* GPT-5.4-mini Codex-Plus baseline, scaled so that **100 units = 10% of a
|
|
7
|
+
* 6-hour-block-equivalent USD spend on that baseline**. Every other
|
|
8
|
+
* harness/model converts its USD cost-per-task through the same peg
|
|
9
|
+
* (`USD / GPT_5_4_MINI_USD_PER_BLOCK * 100`).
|
|
10
|
+
*
|
|
11
|
+
* Why a unit-of-account rather than raw USD: the ceiling is the same
|
|
12
|
+
* **100 units per 6h block** for every harness/model, so an operator on
|
|
13
|
+
* Haiku 4.5 (~1 unit/task) gets ~100 tasks per block, while an operator
|
|
14
|
+
* on Opus 4.7 (~50 units/task) gets ~2 tasks per block. The peg keeps the
|
|
15
|
+
* ceiling readable and ties it to the milestone framing of "~10% of a
|
|
16
|
+
* baseline AI subscription's weekly cap" (#605).
|
|
17
|
+
*
|
|
18
|
+
* The cap is layered with the existing per-credential USD `spendCaps`
|
|
19
|
+
* spend-cap gate from PR #345/#346 — both gates run; the more
|
|
20
|
+
* conservative one wins. This module owns the AI-units side only.
|
|
21
|
+
*
|
|
22
|
+
* Issue #1004: the gate's comparison now runs in **USD** (actual harvested
|
|
23
|
+
* spend vs a USD ceiling), not projected AI units. The peg below survives
|
|
24
|
+
* as the calibration constant deriving that USD ceiling and as the
|
|
25
|
+
* presentation-layer conversion for the legacy unit fields the SPA still
|
|
26
|
+
* reads. For subscription credentials the USD ceiling is a *proxy* budget —
|
|
27
|
+
* it bounds Jinn-attributable model cost, not the provider's plan quota.
|
|
28
|
+
*/
|
|
29
|
+
import { estimateModelCost } from '../harnesses/cost-estimates.js';
|
|
30
|
+
import { CLAUDE_CODE_HARNESS, CODEX_HARNESS, HERMES_AGENT_HARNESS, canonicalHarnessName, } from '../harnesses/names.js';
|
|
31
|
+
/**
|
|
32
|
+
* Calibration peg: the USD cost of one GPT-5.4-mini Codex-Plus 6h block.
|
|
33
|
+
* Derived from a typical Codex Plus 6h block on GPT-5.4-mini: ~10 tasks at
|
|
34
|
+
* ~$0.0525/task (50k input × $0.00025/1k + 20k output × $0.002/1k) → ~$0.5.
|
|
35
|
+
*
|
|
36
|
+
* Conservative — biases toward over-warning rather than under-warning so
|
|
37
|
+
* the ceiling pauses early rather than late.
|
|
38
|
+
*
|
|
39
|
+
* Issue #1004: demoted to a calibration constant — it derives
|
|
40
|
+
* {@link REFERENCE_CEILING_USD_MICROS} and converts the legacy unit fields
|
|
41
|
+
* for presentation, but no longer appears in the gate's comparison. Kept
|
|
42
|
+
* exported because the SPA's `HarnessFootprintPanel.tsx` imports it (#1006).
|
|
43
|
+
*/
|
|
44
|
+
export const GPT_5_4_MINI_USD_PER_BLOCK = 0.5;
|
|
45
|
+
/**
|
|
46
|
+
* The default reference ceiling — 100 AI units per 6h UTC-aligned block,
|
|
47
|
+
* with a weekly safety net at 28 × that (one block × 28 blocks/week).
|
|
48
|
+
*
|
|
49
|
+
* Override at runtime with `JINN_AI_UNITS_CEILING_OVERRIDE` (see
|
|
50
|
+
* `resolveReferenceCeiling`). Set as `<units>` for a per-block override
|
|
51
|
+
* (weekly auto-scales to 28×) or `<block>:<week>` for both explicitly.
|
|
52
|
+
*/
|
|
53
|
+
export const REFERENCE_CEILING = {
|
|
54
|
+
units_per_block: 100,
|
|
55
|
+
units_per_week: 100 * 28,
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* USD-micros ceiling (issue #1004). The gate now compares **actual USD
|
|
59
|
+
* spend** against this ceiling rather than projected AI units. Derived
|
|
60
|
+
* directly from {@link REFERENCE_CEILING} through the GPT-5.4-mini peg:
|
|
61
|
+
* usd_micros = units / 100 * GPT_5_4_MINI_USD_PER_BLOCK * 1_000_000.
|
|
62
|
+
* Default 100 units/block => $0.50/block (500_000 micros); 2800 units/week
|
|
63
|
+
* => $14/week (14_000_000 micros). Calibration is preserved; only the
|
|
64
|
+
* comparison unit changed. For subscription credentials this USD budget is
|
|
65
|
+
* a *proxy* — it bounds Jinn-attributable model cost, not the provider's
|
|
66
|
+
* plan quota directly.
|
|
67
|
+
*/
|
|
68
|
+
export const REFERENCE_CEILING_USD_MICROS = {
|
|
69
|
+
usd_micros_per_block: unitsToUsdMicros(REFERENCE_CEILING.units_per_block),
|
|
70
|
+
usd_micros_per_week: unitsToUsdMicros(REFERENCE_CEILING.units_per_week),
|
|
71
|
+
};
|
|
72
|
+
/** Convert an AI-unit count to USD micros through the GPT-5.4-mini peg. */
|
|
73
|
+
function unitsToUsdMicros(units) {
|
|
74
|
+
return Math.round((units / 100) * GPT_5_4_MINI_USD_PER_BLOCK * 1_000_000);
|
|
75
|
+
}
|
|
76
|
+
/** 6h block in milliseconds — UTC blocks start at 00:00 / 06:00 / 12:00 / 18:00. */
|
|
77
|
+
const SIX_HOUR_BLOCK_MS = 6 * 60 * 60 * 1_000;
|
|
78
|
+
/** 7 days in milliseconds — UTC-aligned. */
|
|
79
|
+
const SEVEN_DAY_MS = 7 * 24 * 60 * 60 * 1_000;
|
|
80
|
+
/**
|
|
81
|
+
* Project the AI-unit cost of one task for a harness/model combination.
|
|
82
|
+
*
|
|
83
|
+
* The AI-units cap meters every paid-LLM harness by model cost,
|
|
84
|
+
* regardless of whether the operator routes through a subscription
|
|
85
|
+
* (`*:subscription`) or a raw API key (`*:api-key`). Subscription
|
|
86
|
+
* quota is finite — the cap exists exactly to bound how much of it a
|
|
87
|
+
* node will burn on Jinn (the spec's "operators commit to a 48h
|
|
88
|
+
* burn-in knowing exactly what their node will consume" — issue #901
|
|
89
|
+
* corrected the #815 implementer's "subscription = 0 units" shortcut).
|
|
90
|
+
*
|
|
91
|
+
* - Returns `0` for harnesses that make no marginal LLM call
|
|
92
|
+
* (prediction harnesses, evaluators, unknown harnesses).
|
|
93
|
+
* - Returns `null` when the harness IS a paid-LLM harness but the
|
|
94
|
+
* model is unknown to the cost table — the caller treats that as
|
|
95
|
+
* "no projection available" and the gate fails *open* with a warn.
|
|
96
|
+
* - Otherwise returns `cost.usd / GPT_5_4_MINI_USD_PER_BLOCK * 100`.
|
|
97
|
+
*
|
|
98
|
+
* `credentialId` is the env-resolved auth path. It does NOT change
|
|
99
|
+
* the projection (the model costs the same regardless of auth path);
|
|
100
|
+
* it only labels the accounting bucket. The parameter remains for
|
|
101
|
+
* call-site clarity and future-proofing.
|
|
102
|
+
*/
|
|
103
|
+
export function projectAiUnits(harness, model, _credentialId) {
|
|
104
|
+
if (!harness)
|
|
105
|
+
return null;
|
|
106
|
+
const canonical = canonicalHarnessName(harness);
|
|
107
|
+
const isPaidLlmHarness = canonical === CLAUDE_CODE_HARNESS ||
|
|
108
|
+
canonical === CODEX_HARNESS ||
|
|
109
|
+
canonical === HERMES_AGENT_HARNESS;
|
|
110
|
+
if (!isPaidLlmHarness)
|
|
111
|
+
return 0;
|
|
112
|
+
if (!model)
|
|
113
|
+
return null;
|
|
114
|
+
const cost = estimateModelCost(model);
|
|
115
|
+
if (!cost)
|
|
116
|
+
return null;
|
|
117
|
+
return (cost.usd / GPT_5_4_MINI_USD_PER_BLOCK) * 100;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Project the per-task cost of one harness/model combination in USD micros
|
|
121
|
+
* (issue #1004). This is the in-flight debit the gate books for a claim
|
|
122
|
+
* before its actual cost is harvested. Same harness classification as
|
|
123
|
+
* {@link projectAiUnits}:
|
|
124
|
+
* - `0` for harnesses that make no marginal LLM call,
|
|
125
|
+
* - `null` when a paid-LLM harness's model is unknown to the cost table
|
|
126
|
+
* (gate fails open with a warn),
|
|
127
|
+
* - otherwise `round(estimateModelCost(model).usd * 1_000_000)`.
|
|
128
|
+
*
|
|
129
|
+
* `_credentialId` does not change the projection (the model costs the same
|
|
130
|
+
* regardless of auth path); it labels the accounting bucket only.
|
|
131
|
+
*/
|
|
132
|
+
export function projectTaskUsdMicros(harness, model, _credentialId) {
|
|
133
|
+
if (!harness)
|
|
134
|
+
return null;
|
|
135
|
+
const canonical = canonicalHarnessName(harness);
|
|
136
|
+
const isPaidLlmHarness = canonical === CLAUDE_CODE_HARNESS ||
|
|
137
|
+
canonical === CODEX_HARNESS ||
|
|
138
|
+
canonical === HERMES_AGENT_HARNESS;
|
|
139
|
+
if (!isPaidLlmHarness)
|
|
140
|
+
return 0;
|
|
141
|
+
if (!model)
|
|
142
|
+
return null;
|
|
143
|
+
const cost = estimateModelCost(model);
|
|
144
|
+
if (!cost)
|
|
145
|
+
return null;
|
|
146
|
+
return Math.round(cost.usd * 1_000_000);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Resolve the active ceiling from env. CI / tests override the baked-in
|
|
150
|
+
* 100 units via `JINN_AI_UNITS_CEILING_OVERRIDE`. Accepts:
|
|
151
|
+
*
|
|
152
|
+
* - `"<n>"` — sets `units_per_block = n`; weekly auto-scales to `n * 28`.
|
|
153
|
+
* - `"<block>:<week>"` — sets both explicitly.
|
|
154
|
+
*
|
|
155
|
+
* Falls back to the baked-in `REFERENCE_CEILING` on a missing or
|
|
156
|
+
* malformed value (env-typo must not silently disable the gate).
|
|
157
|
+
*/
|
|
158
|
+
export function resolveReferenceCeiling(env) {
|
|
159
|
+
const raw = env['JINN_AI_UNITS_CEILING_OVERRIDE'];
|
|
160
|
+
if (raw == null || raw.trim() === '') {
|
|
161
|
+
return { units_per_block: REFERENCE_CEILING.units_per_block, units_per_week: REFERENCE_CEILING.units_per_week };
|
|
162
|
+
}
|
|
163
|
+
const trimmed = raw.trim();
|
|
164
|
+
if (trimmed.includes(':')) {
|
|
165
|
+
const [a, b] = trimmed.split(':', 2);
|
|
166
|
+
const block = Number(a);
|
|
167
|
+
const week = Number(b);
|
|
168
|
+
if (Number.isFinite(block) && block > 0 && Number.isFinite(week) && week > 0) {
|
|
169
|
+
return { units_per_block: block, units_per_week: week };
|
|
170
|
+
}
|
|
171
|
+
warnMalformedOverride(raw);
|
|
172
|
+
return { units_per_block: REFERENCE_CEILING.units_per_block, units_per_week: REFERENCE_CEILING.units_per_week };
|
|
173
|
+
}
|
|
174
|
+
const block = Number(trimmed);
|
|
175
|
+
if (Number.isFinite(block) && block > 0) {
|
|
176
|
+
return { units_per_block: block, units_per_week: block * 28 };
|
|
177
|
+
}
|
|
178
|
+
warnMalformedOverride(raw);
|
|
179
|
+
return { units_per_block: REFERENCE_CEILING.units_per_block, units_per_week: REFERENCE_CEILING.units_per_week };
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Resolve the active USD-micros ceiling from env (issue #1004). Reuses
|
|
183
|
+
* {@link resolveReferenceCeiling} so the `JINN_AI_UNITS_CEILING_OVERRIDE`
|
|
184
|
+
* parsing (integer or `<block>:<week>`, malformed-warn, default fallback)
|
|
185
|
+
* lives in one place, then converts both bounds through the peg.
|
|
186
|
+
*/
|
|
187
|
+
export function resolveReferenceCeilingUsdMicros(env) {
|
|
188
|
+
const units = resolveReferenceCeiling(env);
|
|
189
|
+
return {
|
|
190
|
+
usd_micros_per_block: unitsToUsdMicros(units.units_per_block),
|
|
191
|
+
usd_micros_per_week: unitsToUsdMicros(units.units_per_week),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function warnMalformedOverride(raw) {
|
|
195
|
+
// One-time warn per resolve call — the function is only invoked at
|
|
196
|
+
// startup, so a module-level memo is unnecessary. Surfaces the operator's
|
|
197
|
+
// typo instead of silently falling back to the baked-in default.
|
|
198
|
+
console.warn(`[ai-units] warn: JINN_AI_UNITS_CEILING_OVERRIDE="${raw}" is malformed — ` +
|
|
199
|
+
`using default ${REFERENCE_CEILING.units_per_block}/${REFERENCE_CEILING.units_per_week} per (block, week)`);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Start of the 6h UTC-aligned block containing `now`. Blocks begin at
|
|
203
|
+
* 00:00, 06:00, 12:00, 18:00 UTC; `blockStartUtc(t)` returns the most
|
|
204
|
+
* recent such instant ≤ t. Used to bound the "units this block" sum.
|
|
205
|
+
*/
|
|
206
|
+
function blockStartUtc(now) {
|
|
207
|
+
const startOfDay = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate());
|
|
208
|
+
const sinceDayStart = now.getTime() - startOfDay;
|
|
209
|
+
// Cap at 3 — 4 blocks per day (indices 0..3); defensive against
|
|
210
|
+
// millisecond rounding pushing the floor over 4 at day boundaries.
|
|
211
|
+
const blocksIn = Math.min(Math.floor(sinceDayStart / SIX_HOUR_BLOCK_MS), 3);
|
|
212
|
+
return new Date(startOfDay + blocksIn * SIX_HOUR_BLOCK_MS);
|
|
213
|
+
}
|
|
214
|
+
/** Start of the next 6h UTC-aligned block after `now`. */
|
|
215
|
+
export function blockResetsAtUtc(now) {
|
|
216
|
+
return new Date(blockStartUtc(now).getTime() + SIX_HOUR_BLOCK_MS);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Stable id for a 6h block — used to dedupe `ai_units_cap_reached`
|
|
220
|
+
* activity events to one-per-(credential, block).
|
|
221
|
+
*/
|
|
222
|
+
export function blockIdUtc(now) {
|
|
223
|
+
return blockStartUtc(now).toISOString();
|
|
224
|
+
}
|
|
225
|
+
/** Reset instant for the 7-day window — `now + (boundary - elapsed)`. We use rolling 7d here. */
|
|
226
|
+
export function weekResetsAtUtc(now) {
|
|
227
|
+
return new Date(now.getTime() + SEVEN_DAY_MS);
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=ai-units.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-units.js","sourceRoot":"","sources":["../../src/spend/ai-units.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAE9C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAA0E;IACtG,eAAe,EAAE,GAAG;IACpB,cAAc,EAAE,GAAG,GAAG,EAAE;CACzB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAGrC;IACF,oBAAoB,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,eAAe,CAAC;IACzE,mBAAmB,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,cAAc,CAAC;CACxE,CAAC;AAEF,2EAA2E;AA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AAU,CAAC;IACjD,gEAAgE;IAChE,mEAAmE;IACnE,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,GAAG,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5E,OAAO,IAAI,IAAI,CAAC,UAAU,GAAG,QAAQ,GAAG,iBAAiB,CAAC,CAAC;AAC7D,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,gBAAgB,CAAC,GAAS;IACxC,OAAO,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,GAAG,iBAAiB,CAAC,CAAC;AACpE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,GAAS;IAClC,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;AAC1C,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,eAAe,CAAC,GAAS;IACvC,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,YAAY,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type CredentialId } from './credential.js';
|
|
2
|
+
export interface CostSurfaceHarnessStatus {
|
|
3
|
+
credentialId: CredentialId | null;
|
|
4
|
+
usesPaidApiKey: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface CostSurfaceStatus {
|
|
7
|
+
harnesses: Record<string, CostSurfaceHarnessStatus>;
|
|
8
|
+
}
|
|
9
|
+
export declare function credentialUsesPaidApiKey(credentialId: CredentialId | null): boolean;
|
|
10
|
+
export declare function buildCostSurfaceStatus(env: NodeJS.ProcessEnv,
|
|
11
|
+
/** Optional home dir override for the disk-OAuth probe — tests only. */
|
|
12
|
+
homeDirOverride?: string): CostSurfaceStatus;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CLAUDE_CODE_HARNESS, CODEX_HARNESS, HERMES_AGENT_HARNESS, } from '../harnesses/names.js';
|
|
2
|
+
import { resolveCredentialId } from './credential.js';
|
|
3
|
+
const COST_SURFACE_HARNESSES = [
|
|
4
|
+
CLAUDE_CODE_HARNESS,
|
|
5
|
+
CODEX_HARNESS,
|
|
6
|
+
HERMES_AGENT_HARNESS,
|
|
7
|
+
];
|
|
8
|
+
export function credentialUsesPaidApiKey(credentialId) {
|
|
9
|
+
return credentialId !== null && credentialId.endsWith(':api-key');
|
|
10
|
+
}
|
|
11
|
+
export function buildCostSurfaceStatus(env,
|
|
12
|
+
/** Optional home dir override for the disk-OAuth probe — tests only. */
|
|
13
|
+
homeDirOverride) {
|
|
14
|
+
const harnesses = {};
|
|
15
|
+
for (const harness of COST_SURFACE_HARNESSES) {
|
|
16
|
+
const credentialId = resolveCredentialId(harness, env, homeDirOverride);
|
|
17
|
+
harnesses[harness] = {
|
|
18
|
+
credentialId,
|
|
19
|
+
usesPaidApiKey: credentialUsesPaidApiKey(credentialId),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return { harnesses };
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=cost-surface-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost-surface-status.js","sourceRoot":"","sources":["../../src/spend/cost-surface-status.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAqB,MAAM,iBAAiB,CAAC;AAEzE,MAAM,sBAAsB,GAAG;IAC7B,mBAAmB;IACnB,aAAa;IACb,oBAAoB;CACZ,CAAC;AAWX,MAAM,UAAU,wBAAwB,CAAC,YAAiC;IACxE,OAAO,YAAY,KAAK,IAAI,IAAI,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,GAAsB;AACtB,wEAAwE;AACxE,eAAwB;IAExB,MAAM,SAAS,GAA6C,EAAE,CAAC;IAC/D,KAAK,MAAM,OAAO,IAAI,sBAAsB,EAAE,CAAC;QAC7C,MAAM,YAAY,GAAG,mBAAmB,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,CAAC,CAAC;QACxE,SAAS,CAAC,OAAO,CAAC,GAAG;YACnB,YAAY;YACZ,cAAc,EAAE,wBAAwB,CAAC,YAAY,CAAC;SACvD,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** A credential identity. Format: `{provider}:{authMethod}`, e.g. `anthropic:api-key`. Never empty. */
|
|
2
|
+
export type CredentialId = string;
|
|
3
|
+
/**
|
|
4
|
+
* Does this operator have Claude Code installed and authed via OAuth?
|
|
5
|
+
*
|
|
6
|
+
* The `claude` CLI keeps its OAuth token in the OS keyring on macOS, in
|
|
7
|
+
* platform-equivalent stores elsewhere, and writes per-user state under
|
|
8
|
+
* `~/.claude/`. The cheapest cross-platform "operator has an active
|
|
9
|
+
* Claude Code Pro subscription set up" probe is "does `~/.claude/`
|
|
10
|
+
* exist?" — it's created by `claude` on first run and persists.
|
|
11
|
+
*
|
|
12
|
+
* Injectable for tests via `homeDirOverride`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function hasClaudeCodeOnDisk(homeDirOverride?: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Does this operator have Codex CLI installed and authed?
|
|
17
|
+
*
|
|
18
|
+
* Codex CLI writes its OAuth to `~/.codex/auth.json`. Presence is the
|
|
19
|
+
* subscription signal.
|
|
20
|
+
*/
|
|
21
|
+
export declare function hasCodexOnDisk(homeDirOverride?: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Resolve which authentication credential a harness will bill against.
|
|
24
|
+
*
|
|
25
|
+
* Precedence per provider (preserved from PR #345 / #474):
|
|
26
|
+
* 1. subscription token env var (`*:subscription`) — most explicit
|
|
27
|
+
* subscription marker; the operator has deliberately set it
|
|
28
|
+
* 2. raw-API-key env var (`*:api-key`) — explicit api-key
|
|
29
|
+
* 3. on-disk OAuth (`*:subscription`) — the typical operator who
|
|
30
|
+
* installed `claude` / `codex` CLI and never set an env var
|
|
31
|
+
* 4. null — no credential resolved
|
|
32
|
+
*
|
|
33
|
+
* Returns null when the harness makes no paid LLM call (e.g. prediction
|
|
34
|
+
* harnesses) or no credential is recognisable. Issue #901: disk
|
|
35
|
+
* detection added so stock subscription installs get a credential and
|
|
36
|
+
* the AI-units gate engages by default; precedence above kept stable so
|
|
37
|
+
* the cost-surface UI from #345 / #474 still reads the same.
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveCredentialId(harness: string | undefined, env: NodeJS.ProcessEnv, homeDirOverride?: string): CredentialId | null;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { CLAUDE_CODE_HARNESS, CODEX_HARNESS, HERMES_AGENT_HARNESS, canonicalHarnessName, } from '../harnesses/names.js';
|
|
5
|
+
/**
|
|
6
|
+
* Does this operator have Claude Code installed and authed via OAuth?
|
|
7
|
+
*
|
|
8
|
+
* The `claude` CLI keeps its OAuth token in the OS keyring on macOS, in
|
|
9
|
+
* platform-equivalent stores elsewhere, and writes per-user state under
|
|
10
|
+
* `~/.claude/`. The cheapest cross-platform "operator has an active
|
|
11
|
+
* Claude Code Pro subscription set up" probe is "does `~/.claude/`
|
|
12
|
+
* exist?" — it's created by `claude` on first run and persists.
|
|
13
|
+
*
|
|
14
|
+
* Injectable for tests via `homeDirOverride`.
|
|
15
|
+
*/
|
|
16
|
+
export function hasClaudeCodeOnDisk(homeDirOverride) {
|
|
17
|
+
return existsSync(join(homeDirOverride ?? homedir(), '.claude'));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Does this operator have Codex CLI installed and authed?
|
|
21
|
+
*
|
|
22
|
+
* Codex CLI writes its OAuth to `~/.codex/auth.json`. Presence is the
|
|
23
|
+
* subscription signal.
|
|
24
|
+
*/
|
|
25
|
+
export function hasCodexOnDisk(homeDirOverride) {
|
|
26
|
+
return existsSync(join(homeDirOverride ?? homedir(), '.codex', 'auth.json'));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Resolve which authentication credential a harness will bill against.
|
|
30
|
+
*
|
|
31
|
+
* Precedence per provider (preserved from PR #345 / #474):
|
|
32
|
+
* 1. subscription token env var (`*:subscription`) — most explicit
|
|
33
|
+
* subscription marker; the operator has deliberately set it
|
|
34
|
+
* 2. raw-API-key env var (`*:api-key`) — explicit api-key
|
|
35
|
+
* 3. on-disk OAuth (`*:subscription`) — the typical operator who
|
|
36
|
+
* installed `claude` / `codex` CLI and never set an env var
|
|
37
|
+
* 4. null — no credential resolved
|
|
38
|
+
*
|
|
39
|
+
* Returns null when the harness makes no paid LLM call (e.g. prediction
|
|
40
|
+
* harnesses) or no credential is recognisable. Issue #901: disk
|
|
41
|
+
* detection added so stock subscription installs get a credential and
|
|
42
|
+
* the AI-units gate engages by default; precedence above kept stable so
|
|
43
|
+
* the cost-surface UI from #345 / #474 still reads the same.
|
|
44
|
+
*/
|
|
45
|
+
export function resolveCredentialId(harness, env, homeDirOverride) {
|
|
46
|
+
if (!harness)
|
|
47
|
+
return null;
|
|
48
|
+
switch (canonicalHarnessName(harness)) {
|
|
49
|
+
case CLAUDE_CODE_HARNESS:
|
|
50
|
+
if (env['CLAUDE_CODE_OAUTH_TOKEN'])
|
|
51
|
+
return 'anthropic:subscription';
|
|
52
|
+
if (env['ANTHROPIC_API_KEY'])
|
|
53
|
+
return 'anthropic:api-key';
|
|
54
|
+
if (hasClaudeCodeOnDisk(homeDirOverride))
|
|
55
|
+
return 'anthropic:subscription';
|
|
56
|
+
return null;
|
|
57
|
+
case CODEX_HARNESS:
|
|
58
|
+
if (env['OPENAI_API_KEY'])
|
|
59
|
+
return 'openai:api-key';
|
|
60
|
+
if (hasCodexOnDisk(homeDirOverride))
|
|
61
|
+
return 'openai:subscription';
|
|
62
|
+
return null;
|
|
63
|
+
case HERMES_AGENT_HARNESS: {
|
|
64
|
+
const provider = (env['JINN_HERMES_PROVIDER'] ?? 'hermes').trim().toLowerCase();
|
|
65
|
+
return `${provider}:api-key`;
|
|
66
|
+
}
|
|
67
|
+
default:
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=credential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential.js","sourceRoot":"","sources":["../../src/spend/credential.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAK/B;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CAAC,eAAwB;IAC1D,OAAO,UAAU,CAAC,IAAI,CAAC,eAAe,IAAI,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;AACnE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,eAAwB;IACrD,OAAO,UAAU,CAAC,IAAI,CAAC,eAAe,IAAI,OAAO,EAAE,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;AAC/E,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAA2B,EAC3B,GAAsB,EACtB,eAAwB;IAExB,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1B,QAAQ,oBAAoB,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,KAAK,mBAAmB;YACtB,IAAI,GAAG,CAAC,yBAAyB,CAAC;gBAAE,OAAO,wBAAwB,CAAC;YACpE,IAAI,GAAG,CAAC,mBAAmB,CAAC;gBAAE,OAAO,mBAAmB,CAAC;YACzD,IAAI,mBAAmB,CAAC,eAAe,CAAC;gBAAE,OAAO,wBAAwB,CAAC;YAC1E,OAAO,IAAI,CAAC;QACd,KAAK,aAAa;YAChB,IAAI,GAAG,CAAC,gBAAgB,CAAC;gBAAE,OAAO,gBAAgB,CAAC;YACnD,IAAI,cAAc,CAAC,eAAe,CAAC;gBAAE,OAAO,qBAAqB,CAAC;YAClE,OAAO,IAAI,CAAC;QACd,KAAK,oBAAoB,CAAC,CAAC,CAAC;YAC1B,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,sBAAsB,CAAC,IAAI,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;YAChF,OAAO,GAAG,QAAQ,UAAU,CAAC;QAC/B,CAAC;QACD;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JinnConfig } from '../config.js';
|
|
2
|
+
import { type CredentialId } from './credential.js';
|
|
3
|
+
export interface SpendCapDaemonConfig {
|
|
4
|
+
/** credentialId -> USD/day cap. */
|
|
5
|
+
caps: Record<CredentialId, number>;
|
|
6
|
+
/** manifest CID -> the credential its harness bills against. */
|
|
7
|
+
manifestCredentials: Record<string, CredentialId>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Assemble the daemon's spend-cap config from operator config + env. Returns
|
|
11
|
+
* undefined when no credential ends up with a cap (the gate then stays off).
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildSpendCapConfig(config: Pick<JinnConfig, 'joinedSolverNets' | 'spendCaps'>, env: NodeJS.ProcessEnv): SpendCapDaemonConfig | undefined;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { resolveCredentialId } from './credential.js';
|
|
2
|
+
/**
|
|
3
|
+
* Assemble the daemon's spend-cap config from operator config + env. Returns
|
|
4
|
+
* undefined when no credential ends up with a cap (the gate then stays off).
|
|
5
|
+
*/
|
|
6
|
+
export function buildSpendCapConfig(config, env) {
|
|
7
|
+
const blanketRaw = env['JINN_SPEND_CAP_USD'];
|
|
8
|
+
const blanketNum = blanketRaw != null && blanketRaw.trim() !== '' ? Number(blanketRaw) : NaN;
|
|
9
|
+
const blanket = Number.isFinite(blanketNum) && blanketNum > 0 ? blanketNum : undefined;
|
|
10
|
+
const manifestCredentials = {};
|
|
11
|
+
for (const [manifestCid, entry] of Object.entries(config.joinedSolverNets ?? {})) {
|
|
12
|
+
const credentialId = resolveCredentialId(entry.harness, env);
|
|
13
|
+
if (credentialId)
|
|
14
|
+
manifestCredentials[manifestCid] = credentialId;
|
|
15
|
+
}
|
|
16
|
+
const caps = {};
|
|
17
|
+
for (const credentialId of new Set(Object.values(manifestCredentials))) {
|
|
18
|
+
const cap = config.spendCaps?.[credentialId] ?? blanket;
|
|
19
|
+
if (cap != null)
|
|
20
|
+
caps[credentialId] = cap;
|
|
21
|
+
}
|
|
22
|
+
return Object.keys(caps).length > 0 ? { caps, manifestCredentials } : undefined;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=daemon-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemon-config.js","sourceRoot":"","sources":["../../src/spend/daemon-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAqB,MAAM,iBAAiB,CAAC;AASzE;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAA0D,EAC1D,GAAsB;IAEtB,MAAM,UAAU,GAAG,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAC7C,MAAM,UAAU,GAAG,UAAU,IAAI,IAAI,IAAI,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC7F,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;IAEvF,MAAM,mBAAmB,GAAiC,EAAE,CAAC;IAC7D,KAAK,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,IAAI,EAAE,CAAC,EAAE,CAAC;QACjF,MAAM,YAAY,GAAG,mBAAmB,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC7D,IAAI,YAAY;YAAE,mBAAmB,CAAC,WAAW,CAAC,GAAG,YAAY,CAAC;IACpE,CAAC;IAED,MAAM,IAAI,GAAiC,EAAE,CAAC;IAC9C,KAAK,MAAM,YAAY,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC;QACvE,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC;QACxD,IAAI,GAAG,IAAI,IAAI;YAAE,IAAI,CAAC,YAAY,CAAC,GAAG,GAAG,CAAC;IAC5C,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Price a token count in USD for the given model. Returns null when the model
|
|
3
|
+
* is unknown to the catalog (caller falls back to a heuristic).
|
|
4
|
+
*
|
|
5
|
+
* Uses the tokenlens bundled, offline model catalog (models.dev snapshot).
|
|
6
|
+
* The `tokenlens` re-export of `getTokenCosts` accepts an object with
|
|
7
|
+
* `{ modelId, usage }` and injects the default catalog automatically.
|
|
8
|
+
*
|
|
9
|
+
* Note: tokenlens's bundled catalog may lag current model IDs (e.g.
|
|
10
|
+
* `claude-haiku-4-5-20251001` is absent in v1.3.1 and returns null);
|
|
11
|
+
* callers must handle null gracefully.
|
|
12
|
+
*/
|
|
13
|
+
export declare function priceTokens(modelId: string, tokens: {
|
|
14
|
+
inputTokens: number;
|
|
15
|
+
outputTokens: number;
|
|
16
|
+
}): number | null;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getTokenCosts } from 'tokenlens';
|
|
2
|
+
/**
|
|
3
|
+
* Price a token count in USD for the given model. Returns null when the model
|
|
4
|
+
* is unknown to the catalog (caller falls back to a heuristic).
|
|
5
|
+
*
|
|
6
|
+
* Uses the tokenlens bundled, offline model catalog (models.dev snapshot).
|
|
7
|
+
* The `tokenlens` re-export of `getTokenCosts` accepts an object with
|
|
8
|
+
* `{ modelId, usage }` and injects the default catalog automatically.
|
|
9
|
+
*
|
|
10
|
+
* Note: tokenlens's bundled catalog may lag current model IDs (e.g.
|
|
11
|
+
* `claude-haiku-4-5-20251001` is absent in v1.3.1 and returns null);
|
|
12
|
+
* callers must handle null gracefully.
|
|
13
|
+
*/
|
|
14
|
+
export function priceTokens(modelId, tokens) {
|
|
15
|
+
try {
|
|
16
|
+
const costs = getTokenCosts({
|
|
17
|
+
modelId,
|
|
18
|
+
usage: { prompt_tokens: tokens.inputTokens, completion_tokens: tokens.outputTokens },
|
|
19
|
+
});
|
|
20
|
+
return typeof costs?.totalUSD === 'number' ? costs.totalUSD : null;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=pricing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing.js","sourceRoot":"","sources":["../../src/spend/pricing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,WAAW,CACzB,OAAe,EACf,MAAqD;IAErD,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,aAAa,CAAC;YAC1B,OAAO;YACP,KAAK,EAAE,EAAE,aAAa,EAAE,MAAM,CAAC,WAAW,EAAE,iBAAiB,EAAE,MAAM,CAAC,YAAY,EAAE;SACrF,CAAC,CAAC;QACH,OAAO,OAAO,KAAK,EAAE,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;IACrE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Store } from '../store/store.js';
|
|
2
|
+
/**
|
|
3
|
+
* Record the cost of one finished harness run as a `task_cost` activity row.
|
|
4
|
+
* Called once per harness run (at the POST_SNAPSHOT transition). Best-effort:
|
|
5
|
+
* never throws — a parse failure must not break task execution.
|
|
6
|
+
*/
|
|
7
|
+
export declare function recordTaskCost(store: Store, args: {
|
|
8
|
+
requestId: string;
|
|
9
|
+
harness: string;
|
|
10
|
+
model: string | undefined;
|
|
11
|
+
workingDir: string;
|
|
12
|
+
solverType: string | null;
|
|
13
|
+
}, env?: NodeJS.ProcessEnv): void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { resolveCredentialId } from './credential.js';
|
|
2
|
+
import { harvestHarnessUsage } from './usage.js';
|
|
3
|
+
/**
|
|
4
|
+
* Record the cost of one finished harness run as a `task_cost` activity row.
|
|
5
|
+
* Called once per harness run (at the POST_SNAPSHOT transition). Best-effort:
|
|
6
|
+
* never throws — a parse failure must not break task execution.
|
|
7
|
+
*/
|
|
8
|
+
export function recordTaskCost(store, args, env = process.env) {
|
|
9
|
+
try {
|
|
10
|
+
const credentialId = resolveCredentialId(args.harness, env);
|
|
11
|
+
if (!credentialId)
|
|
12
|
+
return;
|
|
13
|
+
const usage = harvestHarnessUsage(args.harness, args.workingDir, args.model);
|
|
14
|
+
const actualCostUsdMicros = Math.round(usage.costUsd * 1_000_000);
|
|
15
|
+
store.recordActivityEvent({
|
|
16
|
+
ts: new Date().toISOString(),
|
|
17
|
+
kind: 'task_cost',
|
|
18
|
+
requestId: args.requestId,
|
|
19
|
+
solverType: args.solverType,
|
|
20
|
+
credentialId,
|
|
21
|
+
costUsdMicros: actualCostUsdMicros,
|
|
22
|
+
model: usage.model,
|
|
23
|
+
detail: usage.estimated ? 'estimated' : 'observed',
|
|
24
|
+
});
|
|
25
|
+
// Issue #1004: fill actual_cost_usd_micros on the per-request claimed
|
|
26
|
+
// row + set claim_status='delivered'. The gate's accumulator reads this
|
|
27
|
+
// column (COALESCE actual, estimated) so the delivered actual replaces
|
|
28
|
+
// the claim-time estimate in the running total. For subscription
|
|
29
|
+
// credentials the resulting USD figure is a *proxy* budget — it bounds
|
|
30
|
+
// Jinn-attributable model cost, not the provider's plan quota directly.
|
|
31
|
+
// `usage.estimated` is carried through (AC4) so a telemetry-less harness
|
|
32
|
+
// such as Hermes, whose actual cost is itself a heuristic, is not
|
|
33
|
+
// presented as metered by the gate. ai_units stays as captured at claim
|
|
34
|
+
// time (legacy unit surface, #1006). Idempotent: no-op when no claimed
|
|
35
|
+
// row exists for this request id.
|
|
36
|
+
store.finalizeClaimDelivered(args.requestId, actualCostUsdMicros, usage.estimated);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
console.warn(`[spend] failed to record task cost for ${args.requestId}: ` +
|
|
40
|
+
`${err instanceof Error ? err.message : String(err)}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../src/spend/record.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM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G,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CACxD,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** USD attributed to a task whose model has no known price. */
|
|
2
|
+
export declare const UNKNOWN_MODEL_FALLBACK_USD = 1;
|
|
3
|
+
export interface HarnessUsage {
|
|
4
|
+
model: string;
|
|
5
|
+
costUsd: number;
|
|
6
|
+
/** true = derived from an a-priori heuristic; false = from observed usage. */
|
|
7
|
+
estimated: boolean;
|
|
8
|
+
inputTokens?: number;
|
|
9
|
+
outputTokens?: number;
|
|
10
|
+
}
|
|
11
|
+
/** Parse Claude Code `--output-format stream-json` output for the terminal result. */
|
|
12
|
+
export declare function parseClaudeCodeUsage(stdoutJsonl: string): {
|
|
13
|
+
costUsd: number;
|
|
14
|
+
inputTokens?: number;
|
|
15
|
+
outputTokens?: number;
|
|
16
|
+
} | null;
|
|
17
|
+
/** Parse Codex `--json` output for the last turn.completed token usage. */
|
|
18
|
+
export declare function parseCodexUsage(stdoutJsonl: string): {
|
|
19
|
+
inputTokens: number;
|
|
20
|
+
outputTokens: number;
|
|
21
|
+
} | null;
|
|
22
|
+
/**
|
|
23
|
+
* Determine the USD cost of a finished harness run. Reads the harness's own
|
|
24
|
+
* output file for observed usage; falls back to a heuristic on any failure.
|
|
25
|
+
* Always returns a HarnessUsage — never throws.
|
|
26
|
+
*/
|
|
27
|
+
export declare function harvestHarnessUsage(harness: string, workingDir: string, model: string | undefined): HarnessUsage;
|