@jinn-network/client 0.1.7 → 0.1.8-canary.0a152013
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 +19 -1
- package/dist/adapters/mech/adapter.js +130 -14
- package/dist/adapters/mech/adapter.js.map +1 -1
- package/dist/adapters/mech/contracts.d.ts +22 -1
- package/dist/adapters/mech/contracts.js +34 -24
- package/dist/adapters/mech/contracts.js.map +1 -1
- package/dist/adapters/mech/safe.d.ts +1 -1
- package/dist/adapters/mech/safe.js +5 -3
- 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/gather-status.d.ts +33 -0
- package/dist/api/gather-status.js +211 -26
- 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/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 +0 -9
- package/dist/api/setup-endpoints.js +11 -153
- package/dist/api/setup-endpoints.js.map +1 -1
- package/dist/api/solvernets-endpoints.js +30 -63
- package/dist/api/solvernets-endpoints.js.map +1 -1
- package/dist/api/status-build.d.ts +115 -2
- package/dist/api/status-build.js +47 -11
- 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/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 +249 -0
- package/dist/cli/commands/codedigest-revert-check.js.map +1 -0
- package/dist/cli/commands/eval.d.ts +76 -0
- package/dist/cli/commands/eval.js +391 -0
- package/dist/cli/commands/eval.js.map +1 -0
- package/dist/cli/commands/solver-nets.d.ts +1 -0
- package/dist/cli/commands/solver-nets.js +177 -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/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 +199 -232
- package/dist/config.js +268 -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 +82 -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 +203 -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-CldYENtT.js +359 -0
- package/dist/dashboard/assets/index-CzKxvMcU.css +32 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/discovery/http.js +411 -2
- package/dist/discovery/http.js.map +1 -1
- package/dist/discovery/onchain.js +123 -5
- package/dist/discovery/onchain.js.map +1 -1
- package/dist/discovery/types.d.ts +202 -0
- package/dist/discovery/types.js +40 -0
- package/dist/discovery/types.js.map +1 -1
- package/dist/discovery/with-fallback.js +34 -0
- package/dist/discovery/with-fallback.js.map +1 -1
- package/dist/earning/bootstrap.d.ts +25 -3
- package/dist/earning/bootstrap.js +69 -15
- package/dist/earning/bootstrap.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 +146 -0
- package/dist/eval/orchestrator.js +221 -0
- package/dist/eval/orchestrator.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/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 +138 -17
- package/dist/harnesses/engine/engine.js.map +1 -1
- package/dist/harnesses/engine/persistence.d.ts +21 -4
- package/dist/harnesses/engine/persistence.js +43 -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/bootstrap.js +4 -2
- 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 +14 -0
- package/dist/harnesses/impls/hermes-agent/harness.js +16 -2
- 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/learner/adapters/claude-code.d.ts +17 -0
- package/dist/harnesses/impls/learner/adapters/claude-code.js +113 -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 +24 -0
- package/dist/harnesses/impls/learner/harness.js +33 -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/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/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/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/learner/revert-decision.d.ts +59 -0
- package/dist/learner/revert-decision.js +53 -0
- package/dist/learner/revert-decision.js.map +1 -0
- package/dist/learner/revert-stats.d.ts +24 -0
- package/dist/learner/revert-stats.js +44 -0
- package/dist/learner/revert-stats.js.map +1 -0
- package/dist/main.js +178 -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/hooks/session-start +18 -1
- package/dist/plugins/learner/skills/learn/consolidator-prompt.md +18 -1
- package/dist/plugins/learner/skills/learn/promoter-prompt.md +72 -1
- 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 +109 -0
- package/dist/rpc/transport.js +220 -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 +64 -0
- package/dist/solver-types/_swe-rebench-v2-held-out-slate.js +139 -0
- package/dist/solver-types/_swe-rebench-v2-held-out-slate.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 +15 -0
- package/dist/solver-types/_swe-rebench-v2-state.js +19 -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/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 +8 -2
- package/dist/solver-types/swe-rebench-v2.js +151 -12
- 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 +4 -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 +11 -0
- package/dist/solvernets/registry-client-erc8004.js.map +1 -1
- 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 +39 -0
- package/dist/spend/ai-units-config.js +28 -0
- package/dist/spend/ai-units-config.js.map +1 -0
- package/dist/spend/ai-units.d.ts +89 -0
- package/dist/spend/ai-units.js +156 -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 +36 -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 +144 -0
- package/dist/store/store.js +396 -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/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/package.json +4 -0
- package/package.json +21 -12
- package/plugins/learner/hooks/session-start +18 -1
- package/plugins/learner/skills/learn/consolidator-prompt.md +18 -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/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,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,36 @@
|
|
|
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 #815: fill actual_cost_usd_micros on the per-request claimed
|
|
26
|
+
// row + set claim_status='delivered'. ai_units stays as captured at
|
|
27
|
+
// claim time (estimates are the gate input, never recomputed).
|
|
28
|
+
// Idempotent: no-op when no claimed row exists for this request id.
|
|
29
|
+
store.finalizeClaimDelivered(args.requestId, actualCostUsdMicros);
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
console.warn(`[spend] failed to record task cost for ${args.requestId}: ` +
|
|
33
|
+
`${err instanceof Error ? err.message : String(err)}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# 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,YAAY,CAAC;AAEjD;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAY,EACZ,IAMC,EACD,MAAyB,OAAO,CAAC,GAAG;IAEpC,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,mBAAmB,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC5D,IAAI,CAAC,YAAY;YAAE,OAAO;QAC1B,MAAM,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7E,MAAM,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC;QAClE,KAAK,CAAC,mBAAmB,CAAC;YACxB,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YAC5B,IAAI,EAAE,WAAW;YACjB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,YAAY;YACZ,aAAa,EAAE,mBAAmB;YAClC,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU;SACnD,CAAC,CAAC;QACH,qEAAqE;QACrE,oEAAoE;QACpE,+DAA+D;QAC/D,oEAAoE;QACpE,KAAK,CAAC,sBAAsB,CAAC,IAAI,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IACpE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CACV,0CAA0C,IAAI,CAAC,SAAS,IAAI;YAC1D,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,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;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { CLAUDE_CODE_HARNESS, CODEX_HARNESS, canonicalHarnessName } from '../harnesses/names.js';
|
|
4
|
+
import { estimateModelCost } from '../harnesses/cost-estimates.js';
|
|
5
|
+
import { priceTokens } from './pricing.js';
|
|
6
|
+
/** USD attributed to a task whose model has no known price. */
|
|
7
|
+
export const UNKNOWN_MODEL_FALLBACK_USD = 1.0;
|
|
8
|
+
/** Parse Claude Code `--output-format stream-json` output for the terminal result. */
|
|
9
|
+
export function parseClaudeCodeUsage(stdoutJsonl) {
|
|
10
|
+
let result = null;
|
|
11
|
+
for (const line of stdoutJsonl.split('\n')) {
|
|
12
|
+
const trimmed = line.trim();
|
|
13
|
+
if (!trimmed)
|
|
14
|
+
continue;
|
|
15
|
+
let obj;
|
|
16
|
+
try {
|
|
17
|
+
obj = JSON.parse(trimmed);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (obj['type'] === 'result' && typeof obj['total_cost_usd'] === 'number') {
|
|
23
|
+
const usage = obj['usage'];
|
|
24
|
+
result = {
|
|
25
|
+
costUsd: obj['total_cost_usd'],
|
|
26
|
+
inputTokens: typeof usage?.['input_tokens'] === 'number' ? usage['input_tokens'] : undefined,
|
|
27
|
+
outputTokens: typeof usage?.['output_tokens'] === 'number' ? usage['output_tokens'] : undefined,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
/** Parse Codex `--json` output for the last turn.completed token usage. */
|
|
34
|
+
export function parseCodexUsage(stdoutJsonl) {
|
|
35
|
+
let result = null;
|
|
36
|
+
for (const line of stdoutJsonl.split('\n')) {
|
|
37
|
+
const trimmed = line.trim();
|
|
38
|
+
if (!trimmed)
|
|
39
|
+
continue;
|
|
40
|
+
let obj;
|
|
41
|
+
try {
|
|
42
|
+
obj = JSON.parse(trimmed);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (obj['type'] === 'turn.completed' && obj['usage']) {
|
|
48
|
+
const usage = obj['usage'];
|
|
49
|
+
const inT = usage['input_tokens'];
|
|
50
|
+
const outT = usage['output_tokens'];
|
|
51
|
+
if (typeof inT === 'number' && typeof outT === 'number') {
|
|
52
|
+
result = { inputTokens: inT, outputTokens: outT };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
function heuristicUsage(model) {
|
|
59
|
+
const est = model ? estimateModelCost(model) : null;
|
|
60
|
+
return {
|
|
61
|
+
model: model ?? 'unknown',
|
|
62
|
+
costUsd: est?.usd ?? UNKNOWN_MODEL_FALLBACK_USD,
|
|
63
|
+
estimated: true,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Determine the USD cost of a finished harness run. Reads the harness's own
|
|
68
|
+
* output file for observed usage; falls back to a heuristic on any failure.
|
|
69
|
+
* Always returns a HarnessUsage — never throws.
|
|
70
|
+
*/
|
|
71
|
+
export function harvestHarnessUsage(harness, workingDir, model) {
|
|
72
|
+
try {
|
|
73
|
+
const canonical = canonicalHarnessName(harness);
|
|
74
|
+
if (canonical === CLAUDE_CODE_HARNESS) {
|
|
75
|
+
const raw = readFileSync(join(workingDir, '.claude-code', 'stdout.jsonl'), 'utf8');
|
|
76
|
+
const parsed = parseClaudeCodeUsage(raw);
|
|
77
|
+
if (parsed) {
|
|
78
|
+
return {
|
|
79
|
+
model: model ?? 'unknown',
|
|
80
|
+
costUsd: parsed.costUsd,
|
|
81
|
+
estimated: false,
|
|
82
|
+
inputTokens: parsed.inputTokens,
|
|
83
|
+
outputTokens: parsed.outputTokens,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return heuristicUsage(model);
|
|
87
|
+
}
|
|
88
|
+
if (canonical === CODEX_HARNESS) {
|
|
89
|
+
const raw = readFileSync(join(workingDir, '.codex-code', 'stdout.jsonl'), 'utf8');
|
|
90
|
+
const parsed = parseCodexUsage(raw);
|
|
91
|
+
// When there is no model id, parsed token counts cannot be priced —
|
|
92
|
+
// discard them and fall back to the heuristic (per spec).
|
|
93
|
+
if (parsed && model) {
|
|
94
|
+
const usd = priceTokens(model, parsed);
|
|
95
|
+
if (usd != null) {
|
|
96
|
+
return {
|
|
97
|
+
model,
|
|
98
|
+
costUsd: usd,
|
|
99
|
+
estimated: false,
|
|
100
|
+
inputTokens: parsed.inputTokens,
|
|
101
|
+
outputTokens: parsed.outputTokens,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return heuristicUsage(model);
|
|
106
|
+
}
|
|
107
|
+
return heuristicUsage(model);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return heuristicUsage(model);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/spend/usage.ts"],"names":[],"mappings":"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"}
|
package/dist/store/store.d.ts
CHANGED
|
@@ -10,6 +10,17 @@ export interface ActivityEventInput {
|
|
|
10
10
|
solverType?: string | null;
|
|
11
11
|
outcome?: string | null;
|
|
12
12
|
detail?: string | null;
|
|
13
|
+
credentialId?: string | null;
|
|
14
|
+
costUsdMicros?: number | null;
|
|
15
|
+
model?: string | null;
|
|
16
|
+
/** Projected AI units debited at claim time (issue #815). Estimates are the gate input; never recomputed. */
|
|
17
|
+
aiUnits?: number | null;
|
|
18
|
+
/** Lifecycle stamp on the per-request row: 'claimed' | 'claim_failed' | 'delivered'. */
|
|
19
|
+
claimStatus?: string | null;
|
|
20
|
+
/** USD estimate captured at claim time (micros). Distinct from `actualCostUsdMicros` filled on completion. */
|
|
21
|
+
estimatedCostUsdMicros?: number | null;
|
|
22
|
+
/** USD actually billed (micros) — filled by the completion path; null until then. */
|
|
23
|
+
actualCostUsdMicros?: number | null;
|
|
13
24
|
}
|
|
14
25
|
export interface ActivityEventRow {
|
|
15
26
|
id: number;
|
|
@@ -21,6 +32,13 @@ export interface ActivityEventRow {
|
|
|
21
32
|
solverType: string | null;
|
|
22
33
|
outcome: string | null;
|
|
23
34
|
detail: string | null;
|
|
35
|
+
credentialId: string | null;
|
|
36
|
+
costUsdMicros: number | null;
|
|
37
|
+
model: string | null;
|
|
38
|
+
aiUnits: number | null;
|
|
39
|
+
claimStatus: string | null;
|
|
40
|
+
estimatedCostUsdMicros: number | null;
|
|
41
|
+
actualCostUsdMicros: number | null;
|
|
24
42
|
}
|
|
25
43
|
export interface RewardClaimInput {
|
|
26
44
|
ts: string;
|
|
@@ -148,6 +166,22 @@ export interface NetworkArtifactMetadataRow {
|
|
|
148
166
|
lastUsedAt: string;
|
|
149
167
|
peerCatalogId: string | null;
|
|
150
168
|
}
|
|
169
|
+
export interface Erc8004AnchorInput {
|
|
170
|
+
envelopeId: string;
|
|
171
|
+
envelopeCid: string;
|
|
172
|
+
contentKind: string;
|
|
173
|
+
metadataKey: string;
|
|
174
|
+
agentId: string;
|
|
175
|
+
chainId: number;
|
|
176
|
+
identityRegistryAddress: string;
|
|
177
|
+
txHash: string;
|
|
178
|
+
blockNumber: number | null;
|
|
179
|
+
payloadHex: string;
|
|
180
|
+
anchoredAt: number;
|
|
181
|
+
}
|
|
182
|
+
export interface Erc8004AnchorRow extends Erc8004AnchorInput {
|
|
183
|
+
id: number;
|
|
184
|
+
}
|
|
151
185
|
export type TaskPostingPolicyType = 'once_per_safe' | 'once_per_bucket' | 'interval';
|
|
152
186
|
type LauncherTaskProjectionState = 'open' | 'claims-in-flight' | 'fully-claimed' | 'settled' | 'failed';
|
|
153
187
|
export interface TaskPostRecord {
|
|
@@ -185,6 +219,8 @@ export declare class Store {
|
|
|
185
219
|
private ensureTaskPostsTaskCoordinatorColumns;
|
|
186
220
|
/** Older local DBs may have the projection table from before Task grouping fields landed. */
|
|
187
221
|
private ensureEnvelopeProjectionColumns;
|
|
222
|
+
/** Older local DBs predate the per-credential spend-ledger columns on activity_events. */
|
|
223
|
+
private ensureActivityEventCostColumns;
|
|
188
224
|
/**
|
|
189
225
|
* Task-native startup ignores the retired request-first `restoration_intents`
|
|
190
226
|
* table. Keep a one-time local marker when old in-flight rows are present so
|
|
@@ -194,6 +230,14 @@ export declare class Store {
|
|
|
194
230
|
/** Idempotent: older DBs before idx_reward_claims_tx may lack the unique index. */
|
|
195
231
|
private ensureRewardClaimsTxIndex;
|
|
196
232
|
recordOwnActivity(requestId: string, role: 'created' | 'claimed' | 'delivered' | 'evaluated'): void;
|
|
233
|
+
/**
|
|
234
|
+
* Membership-only variant of `recordOwnActivity`: writes the
|
|
235
|
+
* `own_activity` row but does NOT emit a generic `activity_events`
|
|
236
|
+
* row. Used by paths that emit their own enriched activity event
|
|
237
|
+
* (e.g. issue #815's claim path attaches credentialId / aiUnits /
|
|
238
|
+
* estimatedCostUsdMicros / claimStatus to the row).
|
|
239
|
+
*/
|
|
240
|
+
markOwnActivity(requestId: string, role: 'created' | 'claimed' | 'delivered' | 'evaluated'): void;
|
|
197
241
|
isOwnActivity(requestId: string): boolean;
|
|
198
242
|
setShutdownState(state: 'clean' | 'running'): void;
|
|
199
243
|
getShutdownState(): string | null;
|
|
@@ -279,8 +323,63 @@ export declare class Store {
|
|
|
279
323
|
since?: string;
|
|
280
324
|
cursor?: string;
|
|
281
325
|
}): ActivityEventRow[];
|
|
326
|
+
/**
|
|
327
|
+
* Total cost in micro-dollars recorded against a credential since the most
|
|
328
|
+
* recent UTC midnight. Backs the daily spend cap.
|
|
329
|
+
*/
|
|
330
|
+
spentTodayMicros(credentialId: string, now?: Date): number;
|
|
331
|
+
/**
|
|
332
|
+
* Sum of `ai_units` for a credential within the current 6h UTC-aligned
|
|
333
|
+
* block (00:00 / 06:00 / 12:00 / 18:00 boundaries). Reads only rows whose
|
|
334
|
+
* `claim_status = 'claimed'` or `'delivered'` so failed-claim rows
|
|
335
|
+
* (`ai_units = 0`, `claim_status = 'claim_failed'`) don't muddy the sum
|
|
336
|
+
* even though their contribution is already zero.
|
|
337
|
+
*
|
|
338
|
+
* Issue #815. Backs the per-block AI-units ceiling gate.
|
|
339
|
+
*/
|
|
340
|
+
aiUnitsThisBlock(credentialId: string, now?: Date): number;
|
|
341
|
+
/**
|
|
342
|
+
* Sum of `ai_units` for a credential within the trailing 7-day rolling
|
|
343
|
+
* window from `now`. Backs the per-week AI-units safety-net ceiling.
|
|
344
|
+
* Issue #815.
|
|
345
|
+
*/
|
|
346
|
+
aiUnitsThisWeek(credentialId: string, now?: Date): number;
|
|
347
|
+
/**
|
|
348
|
+
* True iff an `ai_units_cap_reached` row exists for the given
|
|
349
|
+
* (credentialId, window, blockId). Used by the daemon to hydrate the
|
|
350
|
+
* AI-units gate's in-memory pause memo across restarts so the
|
|
351
|
+
* "exactly one event per (credential, window, block-id)" guarantee
|
|
352
|
+
* holds across process boundaries (issue #815, finding 1).
|
|
353
|
+
*
|
|
354
|
+
* Lookup is by `credential_id` + `kind` + the `[block=...][window=...]`
|
|
355
|
+
* markers that `daemon.ts` embeds in the row's `detail` string.
|
|
356
|
+
*/
|
|
357
|
+
hasAiUnitsCapReachedFor(credentialId: string, window: 'block' | 'week', blockId: string): boolean;
|
|
358
|
+
/**
|
|
359
|
+
* Mark the per-request `claimed` row as `delivered` and record
|
|
360
|
+
* `actual_cost_usd_micros`. The `ai_units` projection captured at
|
|
361
|
+
* claim time is intentionally NOT recomputed — the issue spec says
|
|
362
|
+
* "estimates are the gate input, never recomputed". Idempotent: a
|
|
363
|
+
* no-op when no `claimed` row exists.
|
|
364
|
+
*/
|
|
365
|
+
finalizeClaimDelivered(requestId: string, actualCostUsdMicros: number): void;
|
|
282
366
|
/** Newer events first, then ascending id for `jinn logs --follow` (oldest in batch printed first in caller). */
|
|
283
367
|
getActivityEventsAfterId(afterId: number, limit: number): ActivityEventRow[];
|
|
368
|
+
/**
|
|
369
|
+
* Filtered, id-cursored page of activity events for the dedicated Events
|
|
370
|
+
* page. Newest-first.
|
|
371
|
+
*
|
|
372
|
+
* Cursors on `id` rather than `ts` so startup/shutdown rows with null
|
|
373
|
+
* timestamps remain reachable.
|
|
374
|
+
*/
|
|
375
|
+
getActivityEventsPage(opts?: {
|
|
376
|
+
kinds?: string[];
|
|
377
|
+
outcome?: string;
|
|
378
|
+
requestId?: string;
|
|
379
|
+
beforeId?: number;
|
|
380
|
+
limit?: number;
|
|
381
|
+
}): ActivityEventRow[];
|
|
382
|
+
getActivityEventById(id: number): ActivityEventRow | null;
|
|
284
383
|
getActivityCountsByKind(): Record<string, number>;
|
|
285
384
|
getLastEventAtForService(serviceIndex: number): string | null;
|
|
286
385
|
getActivityCountsForService(serviceIndex: number): Record<string, number>;
|
|
@@ -398,6 +497,51 @@ export declare class Store {
|
|
|
398
497
|
}>;
|
|
399
498
|
saveEnvelopeProjection(projection: EnvelopeProjection): void;
|
|
400
499
|
queryEnvelopeProjections(query?: EnvelopeProjectionQuery): EnvelopeProjection[];
|
|
500
|
+
saveErc8004Anchor(input: Erc8004AnchorInput): void;
|
|
501
|
+
listErc8004AnchorsByEnvelopeCids(envelopeCids: readonly string[]): Erc8004AnchorRow[];
|
|
502
|
+
/**
|
|
503
|
+
* Upsert one held-out eval result (issue #818). PK is
|
|
504
|
+
* `(checkpoint_cid, slate_version, instance_id)` so a re-run overwrites.
|
|
505
|
+
* `passed` is null for `unscorable` rows.
|
|
506
|
+
*/
|
|
507
|
+
recordEvalResult(args: EvalResultRecord): void;
|
|
508
|
+
/**
|
|
509
|
+
* Aggregate the eval results for a (checkpoint, slate version):
|
|
510
|
+
* `scorable` = rows with `unscorable = 0`; `passed` = scorable rows with
|
|
511
|
+
* `passed = 1`. Unscorable rows are counted separately and never enter the
|
|
512
|
+
* denominator. A checkpoint with no rows yields all-zero (the orchestrator
|
|
513
|
+
* reads this to detect a not-yet-evaluated parent).
|
|
514
|
+
*/
|
|
515
|
+
getEvalAggregate(checkpoint_cid: string, slate_version: string): EvalAggregate;
|
|
516
|
+
/**
|
|
517
|
+
* Distinct `slate_hash` values recorded for a (checkpoint, slate version).
|
|
518
|
+
* The eval orchestrator reads this to detect slate-content drift under a
|
|
519
|
+
* stable version label — the held-out exam is only an honest before/after
|
|
520
|
+
* when the parent and child were scored on the SAME slate content (defeating
|
|
521
|
+
* confounder #1, task-selection). Empty when the checkpoint has no rows.
|
|
522
|
+
*/
|
|
523
|
+
getEvalSlateHashes(checkpoint_cid: string, slate_version: string): string[];
|
|
524
|
+
/** Per-task eval results for a (checkpoint, slate version), ordered by instance_id. */
|
|
525
|
+
getEvalResults(checkpoint_cid: string, slate_version: string): EvalResultRow[];
|
|
401
526
|
close(): void;
|
|
402
527
|
}
|
|
528
|
+
export interface EvalResultRecord {
|
|
529
|
+
checkpoint_cid: string;
|
|
530
|
+
slate_hash: string;
|
|
531
|
+
slate_version: string;
|
|
532
|
+
instance_id: string;
|
|
533
|
+
/** Pass/fail; ignored (stored NULL) when `unscorable` is true. */
|
|
534
|
+
passed: boolean | null;
|
|
535
|
+
unscorable: boolean;
|
|
536
|
+
code_digest: string;
|
|
537
|
+
run_at_ms: number;
|
|
538
|
+
test_log_excerpt?: string | null;
|
|
539
|
+
}
|
|
540
|
+
/** A persisted eval result read back from the store (same shape as the record written). */
|
|
541
|
+
export type EvalResultRow = EvalResultRecord;
|
|
542
|
+
export interface EvalAggregate {
|
|
543
|
+
passed: number;
|
|
544
|
+
scorable: number;
|
|
545
|
+
unscorable: number;
|
|
546
|
+
}
|
|
403
547
|
export {};
|