@jinn-network/client 0.1.6 → 0.1.7-canary.08ebd916
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/CHANGELOG.md +33 -0
- package/README.md +67 -1
- package/deployments/deployment-jinn-mvi-l1-sepolia-fast.json +23 -4
- package/deployments/deployment-jinn-mvi-l1-sepolia.json +23 -4
- package/deployments/deployment-jinn-mvi-l2-baseSepolia.json +5 -4
- package/dist/adapters/mech/adapter.d.ts +38 -2
- package/dist/adapters/mech/adapter.js +269 -62
- package/dist/adapters/mech/adapter.js.map +1 -1
- package/dist/adapters/mech/contracts.d.ts +17 -4
- package/dist/adapters/mech/contracts.js +8 -2
- package/dist/adapters/mech/contracts.js.map +1 -1
- package/dist/adapters/mech/safe-revert.d.ts +20 -0
- package/dist/adapters/mech/safe-revert.js +12 -4
- package/dist/adapters/mech/safe-revert.js.map +1 -1
- package/dist/adapters/mech/safe.d.ts +6 -2
- package/dist/adapters/mech/safe.js +32 -11
- 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/adapters/mech/verdict-code.d.ts +1 -0
- package/dist/adapters/mech/verdict-code.js +18 -0
- package/dist/adapters/mech/verdict-code.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/admin-endpoint.d.ts +15 -3
- package/dist/api/admin-endpoint.js +24 -2
- package/dist/api/admin-endpoint.js.map +1 -1
- package/dist/api/bootstrap-endpoint.d.ts +1 -2
- package/dist/api/bootstrap-endpoint.js +85 -18
- package/dist/api/bootstrap-endpoint.js.map +1 -1
- package/dist/api/codex-doctor-endpoint.d.ts +90 -0
- package/dist/api/codex-doctor-endpoint.js +296 -0
- package/dist/api/codex-doctor-endpoint.js.map +1 -0
- package/dist/api/discovery-endpoint.d.ts +1 -0
- package/dist/api/discovery-endpoint.js +26 -0
- package/dist/api/discovery-endpoint.js.map +1 -1
- package/dist/api/fleet-build.d.ts +1 -0
- package/dist/api/fleet-build.js +2 -1
- package/dist/api/fleet-build.js.map +1 -1
- package/dist/api/gather-status.d.ts +37 -0
- package/dist/api/gather-status.js +572 -19
- package/dist/api/gather-status.js.map +1 -1
- package/dist/api/hermes-doctor-endpoint.d.ts +128 -3
- package/dist/api/hermes-doctor-endpoint.js +265 -22
- package/dist/api/hermes-doctor-endpoint.js.map +1 -1
- package/dist/api/launcher-status.d.ts +25 -17
- package/dist/api/launcher-status.js +13 -11
- 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 +10 -0
- package/dist/api/portfolio-v0-build.js +24 -5
- package/dist/api/portfolio-v0-build.js.map +1 -1
- package/dist/api/prediction-v1-build.d.ts +10 -0
- package/dist/api/prediction-v1-build.js +7 -1
- package/dist/api/prediction-v1-build.js.map +1 -1
- package/dist/api/server.d.ts +31 -1
- package/dist/api/server.js +95 -2
- package/dist/api/server.js.map +1 -1
- package/dist/api/setup-endpoints.d.ts +16 -0
- package/dist/api/setup-endpoints.js +89 -135
- package/dist/api/setup-endpoints.js.map +1 -1
- package/dist/api/setup-retry-endpoint.d.ts +19 -0
- package/dist/api/setup-retry-endpoint.js +32 -0
- package/dist/api/setup-retry-endpoint.js.map +1 -0
- package/dist/api/solvernets-endpoints.d.ts +8 -0
- package/dist/api/solvernets-endpoints.js +99 -60
- package/dist/api/solvernets-endpoints.js.map +1 -1
- package/dist/api/status-build.d.ts +168 -2
- package/dist/api/status-build.js +116 -27
- 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-run-routing.d.ts +7 -0
- package/dist/api/task-run-routing.js +12 -0
- package/dist/api/task-run-routing.js.map +1 -0
- package/dist/api/task-runs-build.d.ts +21 -0
- package/dist/api/task-runs-build.js +14 -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 +10 -0
- package/dist/chain-read-errors.js +15 -0
- package/dist/chain-read-errors.js.map +1 -1
- package/dist/cli/commands/auth.js +1 -1
- package/dist/cli/commands/auth.js.map +1 -1
- package/dist/cli/commands/create.js +3 -2
- package/dist/cli/commands/create.js.map +1 -1
- package/dist/cli/commands/doctor.d.ts +2 -0
- package/dist/cli/commands/doctor.js +2 -0
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/rewards.js +11 -7
- package/dist/cli/commands/rewards.js.map +1 -1
- package/dist/cli/commands/solver-nets.js +101 -15
- 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 +1 -1
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/tasks.js +101 -11
- package/dist/cli/commands/tasks.js.map +1 -1
- package/dist/cli/commands/update.d.ts +10 -0
- package/dist/cli/commands/update.js +36 -0
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/introspection-context.js +5 -0
- package/dist/cli/introspection-context.js.map +1 -1
- package/dist/cli/task-native-readiness.d.ts +10 -1
- package/dist/cli/task-native-readiness.js +30 -6
- package/dist/cli/task-native-readiness.js.map +1 -1
- package/dist/config.d.ts +273 -235
- package/dist/config.js +305 -114
- package/dist/config.js.map +1 -1
- package/dist/daemon/checkpoint-loop.d.ts +48 -0
- package/dist/daemon/checkpoint-loop.js +76 -0
- package/dist/daemon/checkpoint-loop.js.map +1 -0
- package/dist/daemon/creator.d.ts +1 -1
- package/dist/daemon/creator.js +7 -3
- package/dist/daemon/creator.js.map +1 -1
- package/dist/daemon/daemon.d.ts +22 -0
- package/dist/daemon/daemon.js +156 -23
- package/dist/daemon/daemon.js.map +1 -1
- package/dist/daemon/eviction-loop.d.ts +40 -0
- package/dist/daemon/eviction-loop.js +67 -0
- package/dist/daemon/eviction-loop.js.map +1 -0
- 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-wiring.d.ts +33 -0
- package/dist/daemon/jinn-claim-loop-wiring.js +40 -0
- package/dist/daemon/jinn-claim-loop-wiring.js.map +1 -0
- package/dist/daemon/jinn-claim-loop.d.ts +24 -17
- package/dist/daemon/jinn-claim-loop.js +77 -23
- 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/skip-log-dedup.d.ts +69 -0
- package/dist/daemon/skip-log-dedup.js +106 -0
- package/dist/daemon/skip-log-dedup.js.map +1 -0
- 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-C4huIsUW.css +32 -0
- package/dist/dashboard/assets/index-DkTglWXU.js +345 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/discovery/factory.d.ts +17 -5
- package/dist/discovery/factory.js +46 -18
- package/dist/discovery/factory.js.map +1 -1
- package/dist/discovery/http.js +216 -3
- package/dist/discovery/http.js.map +1 -1
- package/dist/discovery/onchain.d.ts +5 -0
- package/dist/discovery/onchain.js +418 -15
- package/dist/discovery/onchain.js.map +1 -1
- package/dist/discovery/types.d.ts +75 -1
- package/dist/discovery/types.js +8 -10
- package/dist/discovery/types.js.map +1 -1
- package/dist/discovery/with-fallback.d.ts +7 -0
- package/dist/discovery/with-fallback.js +20 -0
- package/dist/discovery/with-fallback.js.map +1 -1
- package/dist/earning/bootstrap.d.ts +100 -4
- package/dist/earning/bootstrap.js +221 -74
- package/dist/earning/bootstrap.js.map +1 -1
- package/dist/earning/contracts.d.ts +14 -0
- package/dist/earning/contracts.js +17 -5
- package/dist/earning/contracts.js.map +1 -1
- package/dist/earning/funding-plan.js +27 -18
- package/dist/earning/funding-plan.js.map +1 -1
- package/dist/earning/jinn-rewards.d.ts +46 -0
- package/dist/earning/jinn-rewards.js +32 -0
- package/dist/earning/jinn-rewards.js.map +1 -1
- package/dist/earning/safe-adapter.d.ts +2 -0
- package/dist/earning/safe-adapter.js +37 -11
- package/dist/earning/safe-adapter.js.map +1 -1
- package/dist/earning/store.d.ts +8 -0
- package/dist/earning/store.js.map +1 -1
- package/dist/earning/testnet-setup-migration.d.ts +12 -0
- package/dist/earning/testnet-setup-migration.js +27 -1
- package/dist/earning/testnet-setup-migration.js.map +1 -1
- package/dist/earning/types.d.ts +21 -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 +21 -6
- 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/erc8004/reputation.d.ts +8 -0
- package/dist/erc8004/reputation.js +22 -3
- package/dist/erc8004/reputation.js.map +1 -1
- package/dist/events/types.d.ts +2 -2
- package/dist/harnesses/cost-estimates.d.ts +145 -0
- package/dist/harnesses/cost-estimates.js +297 -0
- package/dist/harnesses/cost-estimates.js.map +1 -0
- package/dist/harnesses/engine/engine.d.ts +78 -0
- package/dist/harnesses/engine/engine.js +153 -11
- package/dist/harnesses/engine/engine.js.map +1 -1
- package/dist/harnesses/engine/persistence.d.ts +51 -1
- package/dist/harnesses/engine/persistence.js +118 -5
- package/dist/harnesses/engine/persistence.js.map +1 -1
- package/dist/harnesses/engine/work-dir-reaper.d.ts +65 -0
- package/dist/harnesses/engine/work-dir-reaper.js +100 -0
- package/dist/harnesses/engine/work-dir-reaper.js.map +1 -0
- package/dist/harnesses/impls/hermes-agent/adapter.js +40 -0
- package/dist/harnesses/impls/hermes-agent/adapter.js.map +1 -1
- package/dist/harnesses/impls/hermes-agent/bootstrap.d.ts +20 -0
- package/dist/harnesses/impls/hermes-agent/bootstrap.js +40 -6
- package/dist/harnesses/impls/hermes-agent/bootstrap.js.map +1 -1
- package/dist/harnesses/impls/hermes-agent/harness.d.ts +59 -1
- package/dist/harnesses/impls/hermes-agent/harness.js +104 -0
- 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 +7 -0
- package/dist/harnesses/impls/index.js +16 -1
- package/dist/harnesses/impls/index.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 +38 -4
- package/dist/harnesses/impls/learner/harness.js +96 -2
- package/dist/harnesses/impls/learner/harness.js.map +1 -1
- package/dist/harnesses/impls/learner/harvest.d.ts +1 -1
- package/dist/harnesses/impls/learner/harvest.js +23 -5
- package/dist/harnesses/impls/learner/harvest.js.map +1 -1
- package/dist/harnesses/impls/learner/plugin-path.d.ts +0 -13
- package/dist/harnesses/impls/learner/plugin-path.js +35 -15
- 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/learner/types.d.ts +11 -0
- package/dist/harnesses/impls/stub.d.ts +58 -0
- package/dist/harnesses/impls/stub.js +89 -0
- package/dist/harnesses/impls/stub.js.map +1 -0
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.d.ts +69 -50
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.js +178 -93
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/eval-runner.js.map +1 -1
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/harness.d.ts +12 -1
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/harness.js +121 -7
- 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 +88 -4
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/hf-fetcher.js +143 -22
- 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 +6 -0
- package/dist/harnesses/impls/swe-rebench-v2-evaluator/index.js +1 -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 +18 -1
- package/dist/harnesses/readiness-registry.js.map +1 -1
- package/dist/main.js +419 -111
- package/dist/main.js.map +1 -1
- package/dist/observability/emit-event.d.ts +3 -2
- package/dist/observability/emit-event.js +22 -1
- package/dist/observability/emit-event.js.map +1 -1
- package/dist/operator-errors.d.ts +7 -0
- package/dist/operator-errors.js +13 -1
- package/dist/operator-errors.js.map +1 -1
- package/dist/plugins/learner/.claude-plugin/plugin.json +9 -0
- package/dist/plugins/learner/.codex-plugin/plugin.json +39 -0
- package/dist/plugins/learner/AGENTS.md +40 -0
- package/dist/plugins/learner/CLAUDE.md +33 -0
- package/dist/plugins/learner/README.md +59 -0
- package/dist/plugins/learner/hooks/hooks.json +16 -0
- package/dist/plugins/learner/hooks/session-start +38 -0
- package/dist/plugins/learner/skills/learn/SKILL.md +412 -0
- package/dist/plugins/learner/skills/learn/analyst-prompt.md +68 -0
- package/dist/plugins/learner/skills/learn/consolidator-prompt.md +94 -0
- package/dist/plugins/learner/skills/learn/explorer-prompt.md +53 -0
- package/dist/plugins/learner/skills/learn/planner-prompt.md +87 -0
- package/dist/plugins/learner/skills/learn/promoter-prompt.md +113 -0
- package/dist/plugins/learner/skills/learn/step-worker-prompt.md +47 -0
- package/dist/plugins/learner/skills/learn/strategist-prompt.md +85 -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/restart-daemon.d.ts +90 -0
- package/dist/restart-daemon.js +95 -0
- package/dist/restart-daemon.js.map +1 -0
- 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/setup/halt-mode.d.ts +14 -0
- package/dist/setup/halt-mode.js +17 -0
- package/dist/setup/halt-mode.js.map +1 -0
- package/dist/solver-nets/prediction-operator-ux.d.ts +1 -2
- package/dist/solver-nets/prediction-operator-ux.js +90 -47
- package/dist/solver-nets/prediction-operator-ux.js.map +1 -1
- package/dist/solver-nets/registry.d.ts +20 -1
- package/dist/solver-nets/registry.js +38 -25
- package/dist/solver-nets/registry.js.map +1 -1
- package/dist/solver-types/_swe-rebench-v2-pool-cache.d.ts +58 -0
- package/dist/solver-types/_swe-rebench-v2-pool-cache.js +87 -0
- package/dist/solver-types/_swe-rebench-v2-pool-cache.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-substrate.d.ts +1 -0
- package/dist/solver-types/_swe-rebench-v2-substrate.js +10 -0
- package/dist/solver-types/_swe-rebench-v2-substrate.js.map +1 -1
- package/dist/solver-types/_swe-rebench-v2-validated-pool.d.ts +94 -1
- package/dist/solver-types/_swe-rebench-v2-validated-pool.js +305 -39
- package/dist/solver-types/_swe-rebench-v2-validated-pool.js.map +1 -1
- package/dist/solver-types/swe-rebench-v2-auto.d.ts +22 -7
- package/dist/solver-types/swe-rebench-v2-auto.js +57 -20
- package/dist/solver-types/swe-rebench-v2-auto.js.map +1 -1
- package/dist/solver-types/swe-rebench-v2.d.ts +18 -2
- package/dist/solver-types/swe-rebench-v2.js +310 -94
- package/dist/solver-types/swe-rebench-v2.js.map +1 -1
- package/dist/solvernets/daemon-init.d.ts +10 -2
- package/dist/solvernets/daemon-init.js +22 -2
- 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 +44 -7
- package/dist/solvernets/launched-record-dispatcher.js.map +1 -1
- package/dist/solvernets/store.d.ts +5 -0
- package/dist/solvernets/store.js +1 -0
- package/dist/solvernets/store.js.map +1 -1
- package/dist/spend/credential.d.ts +8 -0
- package/dist/spend/credential.js +30 -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 +30 -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 +61 -0
- package/dist/store/store.js +302 -7
- package/dist/store/store.js.map +1 -1
- package/dist/tasks/sources.d.ts +18 -1
- package/dist/tasks/sources.js +33 -5
- package/dist/tasks/sources.js.map +1 -1
- package/dist/trajectory/transcript-parsers/types.d.ts +8 -8
- package/dist/tx-retry.d.ts +166 -19
- package/dist/tx-retry.js +310 -32
- package/dist/tx-retry.js.map +1 -1
- package/dist/types/payloads/prediction-apy-v0.d.ts +5 -5
- package/dist/types/payloads/prediction-v0.d.ts +5 -5
- package/dist/types/task-document.d.ts +392 -0
- package/dist/types/task-document.js +10 -0
- package/dist/types/task-document.js.map +1 -1
- package/dist/types/task.d.ts +28 -0
- package/dist/util/extract-tx-hash.d.ts +14 -0
- package/dist/util/extract-tx-hash.js +19 -0
- package/dist/util/extract-tx-hash.js.map +1 -0
- package/dist/vendor/@jinn-network/sdk/dist/contracts.js +1 -1
- package/dist/vendor/@jinn-network/sdk/dist/solvernets/manifest-schema.d.ts +3 -0
- package/dist/vendor/@jinn-network/sdk/dist/solvernets/manifest-schema.js +1 -0
- package/package.json +36 -13
- 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 +69 -0
- package/dist/dashboard/assets/index-DOlzFN8a.css +0 -32
- package/dist/dashboard/assets/index-NkZ7CTAT.js +0 -140
- package/plugins/swe-rebench-v2-runtime/skills/orient/SKILL.md +0 -29
- package/plugins/swe-rebench-v2-runtime/skills/plan/SKILL.md +0 -53
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Best-effort status collection for GET /v1/status (RPC + earning store + SQLite).
|
|
3
3
|
*/
|
|
4
|
-
import { createPublicClient, http } from 'viem';
|
|
4
|
+
import { createPublicClient, getAddress, http, parseAbiItem } from 'viem';
|
|
5
5
|
import { existsSync, readFileSync } from 'node:fs';
|
|
6
6
|
import { join } from 'node:path';
|
|
7
7
|
import { base, baseSepolia } from 'viem/chains';
|
|
8
|
+
import { isOverSpendCap } from '../daemon/spend-cap-gate.js';
|
|
8
9
|
import { FleetStateStore } from '../earning/store.js';
|
|
9
|
-
import { getChainConfig } from '../earning/contracts.js';
|
|
10
|
+
import { DEFAULT_TESTNET_ARTIFACTS, getChainConfig, loadJinnMviConfig, } from '../earning/contracts.js';
|
|
11
|
+
import { createJinnL1PublicClient } from '../earning/viem-clients.js';
|
|
10
12
|
import { stage1MinMasterEth } from '../earning/bootstrap.js';
|
|
11
13
|
import { JINN_STAKING_ABI } from '../earning/jinn-rewards.js';
|
|
12
14
|
import { displayFleetServiceIndex } from '../earning/fleet-display-index.js';
|
|
13
|
-
import { assembleStatusV1, resolveMasterDailyEstimateWei, } from './status-build.js';
|
|
15
|
+
import { assembleStatusV1, pendingTjinnStatus, TJINN_PUBLIC_INVALID_SAFE_ERROR, TJINN_PUBLIC_PARTIAL_ERROR, TJINN_PUBLIC_READ_ERROR, resolveMasterDailyEstimateWei, } from './status-build.js';
|
|
14
16
|
import { listStolasClaimTargets } from '../earning/stolas-claim.js';
|
|
15
17
|
import { gatherPortfolioV0Status, DEFAULT_ENGINE_WORKING_DIR_ROOT, } from './portfolio-v0-build.js';
|
|
16
18
|
import { gatherPredictionV1Status, } from './prediction-v1-build.js';
|
|
17
19
|
import { gatherTaskRunsStatus } from './task-runs-build.js';
|
|
18
20
|
import { buildPredictionOperatorStatus, } from '../solver-nets/prediction-operator-ux.js';
|
|
21
|
+
import { findJoinedByName, rolesFromJoinedConfig, solverTypeFromJoinedContract, } from '../solver-nets/registry.js';
|
|
22
|
+
import { buildHarnessRollup } from './status-harness-rollup.js';
|
|
19
23
|
const ERC20_BALANCE_OF_ABI = [
|
|
20
24
|
{
|
|
21
25
|
type: 'function',
|
|
@@ -25,6 +29,81 @@ const ERC20_BALANCE_OF_ABI = [
|
|
|
25
29
|
outputs: [{ name: '', type: 'uint256' }],
|
|
26
30
|
},
|
|
27
31
|
];
|
|
32
|
+
const JINN_DISTRIBUTOR_CLAIMED_ABI = [
|
|
33
|
+
{
|
|
34
|
+
type: 'function',
|
|
35
|
+
name: 'totalClaimedOperator',
|
|
36
|
+
stateMutability: 'view',
|
|
37
|
+
inputs: [{ name: 'serviceId', type: 'uint256' }],
|
|
38
|
+
outputs: [{ name: '', type: 'uint256' }],
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
/**
|
|
42
|
+
* `Claimed` event item for `getLogs({ event, args })`. Matches the
|
|
43
|
+
* Solidity signature in
|
|
44
|
+
* `contracts/src/jinn/distribution/JinnDistributor.sol` so the operator
|
|
45
|
+
* 24h-minted sum can be computed without a separate indexer.
|
|
46
|
+
*/
|
|
47
|
+
const JINN_DISTRIBUTOR_CLAIMED_EVENT = parseAbiItem('event Claimed(uint256 indexed serviceId, address indexed multisig, uint256 operatorMinted, uint256 daoMinted, uint256 totalEntitledOperator, uint256 totalEntitledDao)');
|
|
48
|
+
const TJINN_BALANCE_CACHE_TTL_MS = 30_000;
|
|
49
|
+
const TJINN_BALANCE_TIMEOUT_MS = 6_000;
|
|
50
|
+
/**
|
|
51
|
+
* Approximate Sepolia blocks per 24 hours. The chain produces a block every
|
|
52
|
+
* ~12s; 86_400 / 12 = 7_200. We pad to 7_500 to absorb the occasional
|
|
53
|
+
* slower block and keep the window comfortably within the common 10k-block
|
|
54
|
+
* `eth_getLogs` cap.
|
|
55
|
+
*/
|
|
56
|
+
const SEPOLIA_BLOCKS_PER_24H = 7500n;
|
|
57
|
+
/**
|
|
58
|
+
* tJINN token address + chain id resolved from the bundled JINN MVI L1
|
|
59
|
+
* deployment artifact — the single source of truth. Used only when the caller
|
|
60
|
+
* (`main.ts`) does not thread explicit values through `StatusGatherConfig`
|
|
61
|
+
* (e.g. test callers, sqlite-only introspection without config). Lazy + cached
|
|
62
|
+
* so the artifact read happens at most once per process.
|
|
63
|
+
*/
|
|
64
|
+
let cachedTjinnArtifactIdentity;
|
|
65
|
+
function defaultTjinnIdentity() {
|
|
66
|
+
if (!cachedTjinnArtifactIdentity) {
|
|
67
|
+
let tokenAddress;
|
|
68
|
+
let chainId;
|
|
69
|
+
try {
|
|
70
|
+
const mvi = loadJinnMviConfig({ l1ArtifactPath: DEFAULT_TESTNET_ARTIFACTS.jinnMviL1 });
|
|
71
|
+
tokenAddress = mvi.jinn;
|
|
72
|
+
chainId = mvi.l1ChainId;
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// Fall through to the hard defaults below if the artifact is unreadable.
|
|
76
|
+
}
|
|
77
|
+
cachedTjinnArtifactIdentity = {
|
|
78
|
+
tokenAddress: tokenAddress ?? '0x0bc0B2f733bF4229FD58Baaac5ebFEf2AEc83C4A',
|
|
79
|
+
chainId: chainId ?? 11155111,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return cachedTjinnArtifactIdentity;
|
|
83
|
+
}
|
|
84
|
+
function resolveTjinnIdentity(status) {
|
|
85
|
+
const fallback = defaultTjinnIdentity();
|
|
86
|
+
return {
|
|
87
|
+
tokenAddress: status?.tjinnTokenAddress ?? fallback.tokenAddress,
|
|
88
|
+
chainId: status?.tjinnChainId ?? fallback.chainId,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/** Fill a fresh errors Map with `TJINN_PUBLIC_READ_ERROR` for every key. */
|
|
92
|
+
function errorsForAllKeys(keys) {
|
|
93
|
+
const errors = new Map();
|
|
94
|
+
for (const key of keys) {
|
|
95
|
+
errors.set(key, TJINN_PUBLIC_READ_ERROR);
|
|
96
|
+
}
|
|
97
|
+
return errors;
|
|
98
|
+
}
|
|
99
|
+
function errorsForAllServiceIds(serviceIds) {
|
|
100
|
+
const errors = new Map();
|
|
101
|
+
for (const serviceId of serviceIds) {
|
|
102
|
+
errors.set(serviceId, TJINN_PUBLIC_READ_ERROR);
|
|
103
|
+
}
|
|
104
|
+
return errors;
|
|
105
|
+
}
|
|
106
|
+
const tjinnBalanceCache = new Map();
|
|
28
107
|
function readDaemonRuntime(earningDir) {
|
|
29
108
|
if (!earningDir)
|
|
30
109
|
return undefined;
|
|
@@ -45,6 +124,23 @@ function readDaemonRuntime(earningDir) {
|
|
|
45
124
|
}
|
|
46
125
|
}
|
|
47
126
|
const predictionOperatorStatusCache = new WeakMap();
|
|
127
|
+
/**
|
|
128
|
+
* Module-scoped first-seen-evicted tracker for the suppression window (issue #651).
|
|
129
|
+
*
|
|
130
|
+
* Key: `${chain}:${serviceId}`. Value: epoch ms when this gatherer first
|
|
131
|
+
* observed `getStakingState === 2` for the service. Cleared as soon as the
|
|
132
|
+
* service is no longer reported evicted, so a successful auto-restake (or a
|
|
133
|
+
* manual one) immediately resets the window.
|
|
134
|
+
*
|
|
135
|
+
* Lives at module scope intentionally: gather-status is invoked on every
|
|
136
|
+
* status read and we need state to persist across reads. The daemon is
|
|
137
|
+
* single-process; no cross-instance coordination required.
|
|
138
|
+
*/
|
|
139
|
+
const evictionFirstSeenMs = new Map();
|
|
140
|
+
/** Test-only: clear the first-seen-evicted tracker. Do not call from production code. */
|
|
141
|
+
export function __resetEvictionFirstSeenForTests() {
|
|
142
|
+
evictionFirstSeenMs.clear();
|
|
143
|
+
}
|
|
48
144
|
/**
|
|
49
145
|
* Drop any cached prediction operator status for `config`.
|
|
50
146
|
*
|
|
@@ -62,6 +158,24 @@ export function invalidatePredictionOperatorStatusCache(config) {
|
|
|
62
158
|
function chainKey(network) {
|
|
63
159
|
return network === 'testnet' ? 'base-sepolia' : 'base';
|
|
64
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Derive the SolverNet name to use for the prediction operator diagnostic.
|
|
163
|
+
*
|
|
164
|
+
* Priority: (1) first joined entry's `name` field, (2) first joined entry's
|
|
165
|
+
* manifestCid, (3) fallback `'prediction'`.
|
|
166
|
+
*
|
|
167
|
+
* Post-issue-#421 the legacy `solverNets` config block has been retired; the
|
|
168
|
+
* operator's participation choices live in `joinedSolverNets` keyed by
|
|
169
|
+
* manifestCid.
|
|
170
|
+
*/
|
|
171
|
+
function derivePredictionSolverNetName(config) {
|
|
172
|
+
const joinedEntries = Object.entries(config.joinedSolverNets ?? {});
|
|
173
|
+
if (joinedEntries.length > 0) {
|
|
174
|
+
const [cid, entry] = joinedEntries[0];
|
|
175
|
+
return entry.name ?? cid;
|
|
176
|
+
}
|
|
177
|
+
return 'prediction';
|
|
178
|
+
}
|
|
65
179
|
function predictionOperatorCacheKey(configPath, name) {
|
|
66
180
|
return `${configPath}\0${name}`;
|
|
67
181
|
}
|
|
@@ -77,41 +191,42 @@ async function getCachedPredictionOperatorStatus(config, configPath, name) {
|
|
|
77
191
|
// gather-status only runs inside a live daemon; the operator-status
|
|
78
192
|
// surface should reflect that (Issue #86 §1: drop the vacuous
|
|
79
193
|
// "start the daemon" copy when the daemon is already running).
|
|
80
|
-
cached = buildPredictionOperatorStatus({ config, configPath,
|
|
194
|
+
cached = buildPredictionOperatorStatus({ config, configPath, daemonRunning: true })
|
|
81
195
|
.catch((error) => predictionOperatorUnavailable(config, configPath, name, errorMessage(error)));
|
|
82
196
|
byKey.set(key, cached);
|
|
83
197
|
}
|
|
84
198
|
return cached;
|
|
85
199
|
}
|
|
86
200
|
function predictionOperatorUnavailable(config, configPath, name, message) {
|
|
87
|
-
|
|
201
|
+
// Resolve the matching joined entry by display name (or manifestCid) so
|
|
202
|
+
// the diagnostic can still surface the operator's configured roles when
|
|
203
|
+
// possible.
|
|
204
|
+
const joined = findJoinedByName(config.joinedSolverNets, name);
|
|
88
205
|
const diagnostic = {
|
|
89
206
|
code: 'prediction_operator_status_unavailable',
|
|
90
207
|
severity: 'error',
|
|
91
208
|
message,
|
|
92
209
|
nextAction: {
|
|
93
|
-
description: 'Inspect Prediction SolverNet configuration and restart the daemon after fixing it.',
|
|
94
|
-
|
|
210
|
+
description: 'Inspect Prediction SolverNet configuration via Operator > SolverNets and restart the daemon after fixing it.',
|
|
211
|
+
url: '/operator#solvernets',
|
|
95
212
|
},
|
|
96
213
|
};
|
|
97
214
|
// Roles are best-effort: an unavailable status path means the daemon
|
|
98
|
-
// could not load the SolverNet, so we surface whatever the operator
|
|
99
|
-
//
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
? rawRoles.filter((r) => r === 'solving' || r === 'evaluating')
|
|
103
|
-
: [];
|
|
215
|
+
// could not load the SolverNet, so we surface whatever the operator
|
|
216
|
+
// joined.
|
|
217
|
+
const netRoles = joined ? rolesFromJoinedConfig(joined) : [];
|
|
218
|
+
const solverType = (joined && solverTypeFromJoinedContract(joined)) ?? 'prediction.v1';
|
|
104
219
|
return {
|
|
105
220
|
kind: 'prediction.v1.operatorStatus',
|
|
106
221
|
ok: false,
|
|
107
222
|
configPath,
|
|
108
223
|
solverNet: {
|
|
109
224
|
name,
|
|
110
|
-
enabled:
|
|
111
|
-
solverType
|
|
225
|
+
enabled: joined ? netRoles.length > 0 : false,
|
|
226
|
+
solverType,
|
|
112
227
|
roles: netRoles,
|
|
113
|
-
harness:
|
|
114
|
-
taskGeneratorEnabled:
|
|
228
|
+
harness: joined?.harness,
|
|
229
|
+
taskGeneratorEnabled: false,
|
|
115
230
|
},
|
|
116
231
|
runtimePlugins: [],
|
|
117
232
|
diagnostics: [diagnostic],
|
|
@@ -163,6 +278,8 @@ function predictionV1Unavailable(operator, operatorError) {
|
|
|
163
278
|
solutions: 0,
|
|
164
279
|
verdicts: 0,
|
|
165
280
|
failed: 0,
|
|
281
|
+
settledFailed: 0,
|
|
282
|
+
localErrors: 0,
|
|
166
283
|
},
|
|
167
284
|
latest: {
|
|
168
285
|
taskAt: null,
|
|
@@ -177,6 +294,158 @@ function predictionV1Unavailable(operator, operatorError) {
|
|
|
177
294
|
function errorMessage(error) {
|
|
178
295
|
return error instanceof Error ? error.message : String(error);
|
|
179
296
|
}
|
|
297
|
+
function tJinnBalanceCacheKey(ethereumRpcUrl, distributorAddress, safeKeys, serviceIds) {
|
|
298
|
+
return [
|
|
299
|
+
ethereumRpcUrl,
|
|
300
|
+
distributorAddress ?? '',
|
|
301
|
+
[...safeKeys].sort().join(','),
|
|
302
|
+
[...serviceIds].sort((a, b) => a - b).join(','),
|
|
303
|
+
].join('\0');
|
|
304
|
+
}
|
|
305
|
+
function timeoutError(message) {
|
|
306
|
+
const error = new Error(message);
|
|
307
|
+
error.name = 'TimeoutError';
|
|
308
|
+
return error;
|
|
309
|
+
}
|
|
310
|
+
function withTimeout(promise, timeoutMs, message) {
|
|
311
|
+
return new Promise((resolve, reject) => {
|
|
312
|
+
const timer = setTimeout(() => reject(timeoutError(message)), timeoutMs);
|
|
313
|
+
promise
|
|
314
|
+
.then(resolve, reject)
|
|
315
|
+
.finally(() => clearTimeout(timer));
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
async function readTjinnBalances(ethereumRpcUrl, tokenAddress, distributorAddress, expectedChainId, safeToAddress, serviceIds) {
|
|
319
|
+
const safeEntries = [...safeToAddress.entries()];
|
|
320
|
+
const client = createJinnL1PublicClient(ethereumRpcUrl, 'sepolia');
|
|
321
|
+
const chainId = await client.getChainId();
|
|
322
|
+
const balances = new Map();
|
|
323
|
+
const operatorClaimedByService = new Map();
|
|
324
|
+
const operatorMintedLast24hByService = new Map();
|
|
325
|
+
if (chainId !== expectedChainId) {
|
|
326
|
+
return {
|
|
327
|
+
chainId,
|
|
328
|
+
balances,
|
|
329
|
+
operatorClaimedByService,
|
|
330
|
+
operatorMintedLast24hByService,
|
|
331
|
+
errors: errorsForAllKeys(safeToAddress.keys()),
|
|
332
|
+
claimedErrors: errorsForAllServiceIds(serviceIds),
|
|
333
|
+
claimedLast24hError: TJINN_PUBLIC_READ_ERROR,
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
const errors = new Map();
|
|
337
|
+
// Single multicall3 round-trip (Sepolia has multicall3). `allowFailure: true`
|
|
338
|
+
// preserves the per-Safe partial-failure handling — a failed entry yields a
|
|
339
|
+
// `{ status: 'failure' }` result rather than rejecting the whole batch.
|
|
340
|
+
const results = await client.multicall({
|
|
341
|
+
allowFailure: true,
|
|
342
|
+
contracts: safeEntries.map(([, safeAddress]) => ({
|
|
343
|
+
address: tokenAddress,
|
|
344
|
+
abi: ERC20_BALANCE_OF_ABI,
|
|
345
|
+
functionName: 'balanceOf',
|
|
346
|
+
args: [safeAddress],
|
|
347
|
+
})),
|
|
348
|
+
});
|
|
349
|
+
for (let i = 0; i < results.length; i++) {
|
|
350
|
+
const result = results[i];
|
|
351
|
+
const key = safeEntries[i]?.[0];
|
|
352
|
+
if (!key)
|
|
353
|
+
continue;
|
|
354
|
+
if (result.status === 'success') {
|
|
355
|
+
balances.set(key, result.result.toString());
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
errors.set(key, TJINN_PUBLIC_READ_ERROR);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
const claimedErrors = new Map();
|
|
362
|
+
if (distributorAddress && serviceIds.length > 0) {
|
|
363
|
+
const claimedResults = await client.multicall({
|
|
364
|
+
allowFailure: true,
|
|
365
|
+
contracts: serviceIds.map((serviceId) => ({
|
|
366
|
+
address: distributorAddress,
|
|
367
|
+
abi: JINN_DISTRIBUTOR_CLAIMED_ABI,
|
|
368
|
+
functionName: 'totalClaimedOperator',
|
|
369
|
+
args: [BigInt(serviceId)],
|
|
370
|
+
})),
|
|
371
|
+
});
|
|
372
|
+
for (let i = 0; i < claimedResults.length; i++) {
|
|
373
|
+
const serviceId = serviceIds[i];
|
|
374
|
+
if (serviceId === undefined)
|
|
375
|
+
continue;
|
|
376
|
+
const result = claimedResults[i];
|
|
377
|
+
if (result.status === 'success') {
|
|
378
|
+
operatorClaimedByService.set(serviceId, result.result.toString());
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
claimedErrors.set(serviceId, TJINN_PUBLIC_READ_ERROR);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
let claimedLast24hError = null;
|
|
386
|
+
if (distributorAddress && serviceIds.length > 0) {
|
|
387
|
+
try {
|
|
388
|
+
const latest = await client.getBlockNumber();
|
|
389
|
+
const fromBlock = latest > SEPOLIA_BLOCKS_PER_24H ? latest - SEPOLIA_BLOCKS_PER_24H : 0n;
|
|
390
|
+
const logs = await client.getLogs({
|
|
391
|
+
address: distributorAddress,
|
|
392
|
+
event: JINN_DISTRIBUTOR_CLAIMED_EVENT,
|
|
393
|
+
args: { serviceId: serviceIds.map((id) => BigInt(id)) },
|
|
394
|
+
fromBlock,
|
|
395
|
+
toBlock: latest,
|
|
396
|
+
});
|
|
397
|
+
const sums = new Map();
|
|
398
|
+
for (const log of logs) {
|
|
399
|
+
const args = log.args;
|
|
400
|
+
if (args.serviceId === undefined || args.operatorMinted === undefined)
|
|
401
|
+
continue;
|
|
402
|
+
const id = Number(args.serviceId);
|
|
403
|
+
sums.set(id, (sums.get(id) ?? 0n) + args.operatorMinted);
|
|
404
|
+
}
|
|
405
|
+
for (const serviceId of serviceIds) {
|
|
406
|
+
operatorMintedLast24hByService.set(serviceId, (sums.get(serviceId) ?? 0n).toString());
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
catch {
|
|
410
|
+
claimedLast24hError = TJINN_PUBLIC_READ_ERROR;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return {
|
|
414
|
+
chainId,
|
|
415
|
+
balances,
|
|
416
|
+
operatorClaimedByService,
|
|
417
|
+
operatorMintedLast24hByService,
|
|
418
|
+
errors,
|
|
419
|
+
claimedErrors,
|
|
420
|
+
claimedLast24hError,
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
async function getCachedTjinnBalances(ethereumRpcUrl, tokenAddress, distributorAddress, expectedChainId, safeToAddress, serviceIds) {
|
|
424
|
+
const safeKeys = [...safeToAddress.keys()].sort();
|
|
425
|
+
const sortedServiceIds = [...serviceIds].sort((a, b) => a - b);
|
|
426
|
+
const cacheKey = tJinnBalanceCacheKey(ethereumRpcUrl, distributorAddress, safeKeys, sortedServiceIds);
|
|
427
|
+
const now = Date.now();
|
|
428
|
+
const cached = tjinnBalanceCache.get(cacheKey);
|
|
429
|
+
if (cached && cached.expiresAt > now) {
|
|
430
|
+
return cached.promise;
|
|
431
|
+
}
|
|
432
|
+
const promise = withTimeout(readTjinnBalances(ethereumRpcUrl, tokenAddress, distributorAddress, expectedChainId, safeToAddress, sortedServiceIds), TJINN_BALANCE_TIMEOUT_MS, 'tJINN balance collection timed out').catch(() => {
|
|
433
|
+
return {
|
|
434
|
+
chainId: expectedChainId,
|
|
435
|
+
balances: new Map(),
|
|
436
|
+
operatorClaimedByService: new Map(),
|
|
437
|
+
operatorMintedLast24hByService: new Map(),
|
|
438
|
+
errors: errorsForAllKeys(safeKeys),
|
|
439
|
+
claimedErrors: errorsForAllServiceIds(sortedServiceIds),
|
|
440
|
+
claimedLast24hError: TJINN_PUBLIC_READ_ERROR,
|
|
441
|
+
};
|
|
442
|
+
});
|
|
443
|
+
tjinnBalanceCache.set(cacheKey, {
|
|
444
|
+
expiresAt: now + TJINN_BALANCE_CACHE_TTL_MS,
|
|
445
|
+
promise,
|
|
446
|
+
});
|
|
447
|
+
return promise;
|
|
448
|
+
}
|
|
180
449
|
async function sumPendingStakingRewards(rpcUrl, network, fleet) {
|
|
181
450
|
const targets = listStolasClaimTargets(fleet.services);
|
|
182
451
|
if (targets.length === 0) {
|
|
@@ -228,6 +497,158 @@ async function sumPendingStakingRewards(rpcUrl, network, fleet) {
|
|
|
228
497
|
return { error: e instanceof Error ? e.message : String(e) };
|
|
229
498
|
}
|
|
230
499
|
}
|
|
500
|
+
/**
|
|
501
|
+
* Resolve the public error string for a tJINN status with at least one error.
|
|
502
|
+
*
|
|
503
|
+
* Flattened from a 3-deep nested ternary into guard clauses:
|
|
504
|
+
* - partial success (some balances read) → PARTIAL
|
|
505
|
+
* - only invalid-Safe errors → INVALID_SAFE
|
|
506
|
+
* - otherwise (RPC read failures) → READ_ERROR
|
|
507
|
+
*
|
|
508
|
+
* Caller must only invoke this when `hasInvalidSafe || hasReadError` is true.
|
|
509
|
+
*/
|
|
510
|
+
function tjinnPublicError(opts) {
|
|
511
|
+
if (opts.hasAnyBalance)
|
|
512
|
+
return TJINN_PUBLIC_PARTIAL_ERROR;
|
|
513
|
+
if (opts.hasInvalidSafe && !opts.hasReadError)
|
|
514
|
+
return TJINN_PUBLIC_INVALID_SAFE_ERROR;
|
|
515
|
+
return TJINN_PUBLIC_READ_ERROR;
|
|
516
|
+
}
|
|
517
|
+
async function gatherTjinnStatus(ethereumRpcUrl, tokenAddress, distributorAddress, chainId, fleet) {
|
|
518
|
+
if (!fleet) {
|
|
519
|
+
return pendingTjinnStatus(tokenAddress, chainId);
|
|
520
|
+
}
|
|
521
|
+
const services = [];
|
|
522
|
+
const safeToAddress = new Map();
|
|
523
|
+
const serviceIds = new Set();
|
|
524
|
+
for (const svc of fleet.services) {
|
|
525
|
+
const index = displayFleetServiceIndex(svc);
|
|
526
|
+
const serviceId = svc.service_id ?? null;
|
|
527
|
+
if (serviceId !== null) {
|
|
528
|
+
serviceIds.add(serviceId);
|
|
529
|
+
}
|
|
530
|
+
const safeAddress = svc.safe_address;
|
|
531
|
+
if (!safeAddress) {
|
|
532
|
+
services.push({
|
|
533
|
+
index,
|
|
534
|
+
serviceId,
|
|
535
|
+
safeAddress: null,
|
|
536
|
+
balanceWei: null,
|
|
537
|
+
operatorClaimedWei: null,
|
|
538
|
+
state: 'pending',
|
|
539
|
+
error: null,
|
|
540
|
+
});
|
|
541
|
+
continue;
|
|
542
|
+
}
|
|
543
|
+
try {
|
|
544
|
+
const checksum = getAddress(safeAddress);
|
|
545
|
+
const key = checksum.toLowerCase();
|
|
546
|
+
services.push({
|
|
547
|
+
index,
|
|
548
|
+
serviceId,
|
|
549
|
+
safeAddress: checksum,
|
|
550
|
+
balanceWei: null,
|
|
551
|
+
operatorClaimedWei: null,
|
|
552
|
+
state: 'pending',
|
|
553
|
+
error: null,
|
|
554
|
+
});
|
|
555
|
+
safeToAddress.set(key, checksum);
|
|
556
|
+
}
|
|
557
|
+
catch {
|
|
558
|
+
services.push({
|
|
559
|
+
index,
|
|
560
|
+
serviceId,
|
|
561
|
+
safeAddress,
|
|
562
|
+
balanceWei: null,
|
|
563
|
+
operatorClaimedWei: null,
|
|
564
|
+
state: 'error',
|
|
565
|
+
error: TJINN_PUBLIC_INVALID_SAFE_ERROR,
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
const safeCount = safeToAddress.size;
|
|
570
|
+
if (safeCount === 0) {
|
|
571
|
+
const invalid = services.find((svc) => svc.state === 'error')?.error;
|
|
572
|
+
return pendingTjinnStatus(tokenAddress, chainId, {
|
|
573
|
+
state: invalid ? 'error' : 'pending',
|
|
574
|
+
safeCount,
|
|
575
|
+
services,
|
|
576
|
+
error: invalid ?? null,
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
if (!ethereumRpcUrl) {
|
|
580
|
+
return pendingTjinnStatus(tokenAddress, chainId, { safeCount, services });
|
|
581
|
+
}
|
|
582
|
+
const snapshot = await getCachedTjinnBalances(ethereumRpcUrl, tokenAddress, distributorAddress, chainId, safeToAddress, [...serviceIds]);
|
|
583
|
+
let total = 0n;
|
|
584
|
+
for (const balance of snapshot.balances.values()) {
|
|
585
|
+
total += BigInt(balance);
|
|
586
|
+
}
|
|
587
|
+
const allClaimedReadsAvailable = !!distributorAddress &&
|
|
588
|
+
serviceIds.size > 0 &&
|
|
589
|
+
snapshot.claimedErrors.size === 0 &&
|
|
590
|
+
[...serviceIds].every((serviceId) => snapshot.operatorClaimedByService.has(serviceId));
|
|
591
|
+
let operatorClaimedWei = null;
|
|
592
|
+
if (allClaimedReadsAvailable) {
|
|
593
|
+
let claimedTotal = 0n;
|
|
594
|
+
for (const serviceId of serviceIds) {
|
|
595
|
+
claimedTotal += BigInt(snapshot.operatorClaimedByService.get(serviceId) ?? '0');
|
|
596
|
+
}
|
|
597
|
+
operatorClaimedWei = claimedTotal.toString();
|
|
598
|
+
}
|
|
599
|
+
// 24h-window sum: null when the log query errored or there are no services.
|
|
600
|
+
let operatorMintedLast24hWei = null;
|
|
601
|
+
if (!!distributorAddress &&
|
|
602
|
+
serviceIds.size > 0 &&
|
|
603
|
+
snapshot.claimedLast24hError === null) {
|
|
604
|
+
let last24hTotal = 0n;
|
|
605
|
+
for (const serviceId of serviceIds) {
|
|
606
|
+
last24hTotal += BigInt(snapshot.operatorMintedLast24hByService.get(serviceId) ?? '0');
|
|
607
|
+
}
|
|
608
|
+
operatorMintedLast24hWei = last24hTotal.toString();
|
|
609
|
+
}
|
|
610
|
+
const hasInvalidSafe = services.some((svc) => svc.error === TJINN_PUBLIC_INVALID_SAFE_ERROR);
|
|
611
|
+
const hasReadError = snapshot.errors.size > 0;
|
|
612
|
+
const hasAnyError = hasInvalidSafe || hasReadError;
|
|
613
|
+
const hasAnyBalance = snapshot.balances.size > 0;
|
|
614
|
+
const publicError = hasAnyError
|
|
615
|
+
? tjinnPublicError({ hasInvalidSafe, hasReadError, hasAnyBalance })
|
|
616
|
+
: null;
|
|
617
|
+
return pendingTjinnStatus(tokenAddress, snapshot.chainId, {
|
|
618
|
+
state: hasAnyError ? 'error' : 'ready',
|
|
619
|
+
safeBalanceWei: hasAnyBalance ? total.toString() : null,
|
|
620
|
+
operatorClaimedWei,
|
|
621
|
+
operatorMintedLast24hWei,
|
|
622
|
+
safeCount,
|
|
623
|
+
services: services.map((svc) => {
|
|
624
|
+
const operatorClaimedForService = svc.serviceId !== null
|
|
625
|
+
? (snapshot.operatorClaimedByService.get(svc.serviceId) ?? null)
|
|
626
|
+
: null;
|
|
627
|
+
if (!svc.safeAddress)
|
|
628
|
+
return { ...svc, operatorClaimedWei: operatorClaimedForService };
|
|
629
|
+
if (svc.state === 'error')
|
|
630
|
+
return { ...svc, operatorClaimedWei: operatorClaimedForService };
|
|
631
|
+
const key = svc.safeAddress.toLowerCase();
|
|
632
|
+
const balance = snapshot.balances.get(key);
|
|
633
|
+
if (balance !== undefined) {
|
|
634
|
+
return {
|
|
635
|
+
...svc,
|
|
636
|
+
state: 'ready',
|
|
637
|
+
balanceWei: balance,
|
|
638
|
+
operatorClaimedWei: operatorClaimedForService,
|
|
639
|
+
error: null,
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
return {
|
|
643
|
+
...svc,
|
|
644
|
+
state: 'error',
|
|
645
|
+
operatorClaimedWei: operatorClaimedForService,
|
|
646
|
+
error: snapshot.errors.get(key) ?? TJINN_PUBLIC_READ_ERROR,
|
|
647
|
+
};
|
|
648
|
+
}),
|
|
649
|
+
error: publicError,
|
|
650
|
+
});
|
|
651
|
+
}
|
|
231
652
|
function hasUsefulCacheValues(entry, isAgentRole) {
|
|
232
653
|
if (isAgentRole)
|
|
233
654
|
return entry.nativeWei != null;
|
|
@@ -350,6 +771,7 @@ export async function gatherGatheredStatusRaw(store, status) {
|
|
|
350
771
|
}));
|
|
351
772
|
const lastRewardClaimTickAt = store.getConfigValue('last_reward_claim_tick_at');
|
|
352
773
|
const daily = resolveMasterDailyEstimateWei(status?.masterEthDailyEstimateWei, status?.pollIntervalMs ?? 5000);
|
|
774
|
+
const tjinnIdentity = resolveTjinnIdentity(status);
|
|
353
775
|
// portfolio.v0 lifecycle data — best-effort, never throws
|
|
354
776
|
let portfolioV0;
|
|
355
777
|
try {
|
|
@@ -365,11 +787,23 @@ export async function gatherGatheredStatusRaw(store, status) {
|
|
|
365
787
|
catch {
|
|
366
788
|
taskRuns = undefined;
|
|
367
789
|
}
|
|
790
|
+
let harnessRollup;
|
|
791
|
+
try {
|
|
792
|
+
const hr = status?.harnessReadiness?.();
|
|
793
|
+
if (hr) {
|
|
794
|
+
harnessRollup = buildHarnessRollup(hr.snapshot, hr.joinedHarnessesByCid);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
catch {
|
|
798
|
+
// Best-effort: leave harnessRollup unset so assembleStatusV1 falls
|
|
799
|
+
// through to the default-ready posture.
|
|
800
|
+
}
|
|
368
801
|
let predictionOperator = null;
|
|
369
802
|
let predictionOperatorError;
|
|
370
803
|
if (status?.config) {
|
|
371
804
|
try {
|
|
372
|
-
const
|
|
805
|
+
const solverNetName = derivePredictionSolverNetName(status.config);
|
|
806
|
+
const raw = await getCachedPredictionOperatorStatus(status.config, status.configPath ?? '<default>', solverNetName);
|
|
373
807
|
predictionOperator = narrowOperatorStatusForApi(raw);
|
|
374
808
|
}
|
|
375
809
|
catch (error) {
|
|
@@ -410,6 +844,10 @@ export async function gatherGatheredStatusRaw(store, status) {
|
|
|
410
844
|
serviceBalances: {},
|
|
411
845
|
pendingByService: {},
|
|
412
846
|
claimedByService: store.getClaimedRewardsByService(),
|
|
847
|
+
tjinnTokenAddress: tjinnIdentity.tokenAddress,
|
|
848
|
+
tjinnChainId: tjinnIdentity.chainId,
|
|
849
|
+
tjinnDistributorAddress: status?.tjinnDistributorAddress,
|
|
850
|
+
harnessRollup,
|
|
413
851
|
};
|
|
414
852
|
if (!status) {
|
|
415
853
|
return { ...baseRaw, hintsScope: 'sqlite_only' };
|
|
@@ -424,6 +862,11 @@ export async function gatherGatheredStatusRaw(store, status) {
|
|
|
424
862
|
testnetMechDeploymentPath: status.testnetMechDeploymentPath,
|
|
425
863
|
testnetStolasDeploymentPath: status.testnetStolasDeploymentPath,
|
|
426
864
|
});
|
|
865
|
+
// Start the Sepolia tJINN read up front so it overlaps the Base-RPC fan-out
|
|
866
|
+
// below for free. `gatherTjinnStatus` is internally error-safe (it catches
|
|
867
|
+
// and returns a snapshot), so the promise never rejects — it is awaited at
|
|
868
|
+
// the point its result is assigned to `raw.tJinn`.
|
|
869
|
+
const tJinnPromise = gatherTjinnStatus(status.network === 'testnet' ? status.config?.ethereumRpcUrl : undefined, tjinnIdentity.tokenAddress, status.tjinnDistributorAddress, tjinnIdentity.chainId, fleet);
|
|
427
870
|
const raw = {
|
|
428
871
|
...baseRaw,
|
|
429
872
|
fleet,
|
|
@@ -453,6 +896,18 @@ export async function gatherGatheredStatusRaw(store, status) {
|
|
|
453
896
|
},
|
|
454
897
|
rewardClaimIntervalMs: status.rewardClaimIntervalMs,
|
|
455
898
|
};
|
|
899
|
+
// Auto-restake gating (issue #651). Must mirror main.ts:~2520-2523 — when
|
|
900
|
+
// that predicate changes (evictionCheckIntervalMs > 0 && stakingMode ===
|
|
901
|
+
// 'standard' && !!CHAIN_CONFIG.distributorAddress), this one must change
|
|
902
|
+
// too. `stOlasDistributorAddress` is the same on-chain artifact threaded
|
|
903
|
+
// through `StatusGatherConfig`; do NOT substitute `tjinnDistributorAddress`
|
|
904
|
+
// (different contract on a different chain).
|
|
905
|
+
const evictionIntervalMs = status.config?.evictionCheckIntervalMs ?? 0;
|
|
906
|
+
raw.evictionCheckIntervalMs = evictionIntervalMs;
|
|
907
|
+
raw.autoRestakeEnabled =
|
|
908
|
+
evictionIntervalMs > 0 &&
|
|
909
|
+
status.config?.stakingMode === 'standard' &&
|
|
910
|
+
!!status.stOlasDistributorAddress;
|
|
456
911
|
const viemChain = status.network === 'testnet' ? baseSepolia : base;
|
|
457
912
|
const client = createPublicClient({
|
|
458
913
|
chain: viemChain,
|
|
@@ -503,6 +958,87 @@ export async function gatherGatheredStatusRaw(store, status) {
|
|
|
503
958
|
else {
|
|
504
959
|
raw.pendingRewardsError = pr.error;
|
|
505
960
|
}
|
|
961
|
+
// Eviction state + inactivity — best-effort; never blocks the rest of status assembly.
|
|
962
|
+
try {
|
|
963
|
+
const evictedByServiceIndex = {};
|
|
964
|
+
const inactivityByServiceIndex = {};
|
|
965
|
+
await Promise.all(fleet.services.map(async (svc) => {
|
|
966
|
+
const serviceId = svc.service_id;
|
|
967
|
+
const stakingProxy = svc.staking_address;
|
|
968
|
+
if (!serviceId || !stakingProxy)
|
|
969
|
+
return;
|
|
970
|
+
const di = displayFleetServiceIndex(svc);
|
|
971
|
+
try {
|
|
972
|
+
const [state, info] = await Promise.all([
|
|
973
|
+
client.readContract({
|
|
974
|
+
address: stakingProxy,
|
|
975
|
+
abi: JINN_STAKING_ABI,
|
|
976
|
+
functionName: 'getStakingState',
|
|
977
|
+
args: [BigInt(serviceId)],
|
|
978
|
+
}),
|
|
979
|
+
client.readContract({
|
|
980
|
+
address: stakingProxy,
|
|
981
|
+
abi: JINN_STAKING_ABI,
|
|
982
|
+
functionName: 'getServiceInfo',
|
|
983
|
+
args: [BigInt(serviceId)],
|
|
984
|
+
}).catch(() => null),
|
|
985
|
+
]);
|
|
986
|
+
// getStakingState returns uint8; 2 = Evicted enum value
|
|
987
|
+
evictedByServiceIndex[di] = Number(state) === 2;
|
|
988
|
+
// getServiceInfo returns a struct — inactivity is seconds of accumulated inactivity
|
|
989
|
+
if (info != null) {
|
|
990
|
+
const inactivity = info.inactivity;
|
|
991
|
+
if (typeof inactivity === 'bigint') {
|
|
992
|
+
inactivityByServiceIndex[di] = Number(inactivity);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
catch {
|
|
997
|
+
// Transient RPC errors: skip silently; evicted defaults to false
|
|
998
|
+
}
|
|
999
|
+
}));
|
|
1000
|
+
raw.evictedByServiceIndex = evictedByServiceIndex;
|
|
1001
|
+
raw.inactivityByServiceIndex = inactivityByServiceIndex;
|
|
1002
|
+
// First-seen tracker for the suppression window (issue #651).
|
|
1003
|
+
// Key by `${chain}:${serviceId}` to survive multi-chain fleet layouts.
|
|
1004
|
+
const nowMs = Date.now();
|
|
1005
|
+
const chainKey = fleet.chain;
|
|
1006
|
+
const evictedSinceByServiceIndex = {};
|
|
1007
|
+
for (const svc of fleet.services) {
|
|
1008
|
+
const di = displayFleetServiceIndex(svc);
|
|
1009
|
+
const sid = svc.service_id;
|
|
1010
|
+
if (sid == null)
|
|
1011
|
+
continue;
|
|
1012
|
+
const key = `${chainKey}:${sid}`;
|
|
1013
|
+
// Three-way: `true` → start/preserve window; `false` → clear it;
|
|
1014
|
+
// `undefined` (read failed) → leave prior state untouched so a
|
|
1015
|
+
// transient RPC flap does not reset the suppression window
|
|
1016
|
+
// (issue #651 review Finding B).
|
|
1017
|
+
if (evictedByServiceIndex[di] === true) {
|
|
1018
|
+
let firstSeen = evictionFirstSeenMs.get(key);
|
|
1019
|
+
if (firstSeen === undefined) {
|
|
1020
|
+
firstSeen = nowMs;
|
|
1021
|
+
evictionFirstSeenMs.set(key, firstSeen);
|
|
1022
|
+
}
|
|
1023
|
+
evictedSinceByServiceIndex[di] = new Date(firstSeen).toISOString();
|
|
1024
|
+
}
|
|
1025
|
+
else if (evictedByServiceIndex[di] === false) {
|
|
1026
|
+
evictionFirstSeenMs.delete(key);
|
|
1027
|
+
}
|
|
1028
|
+
else {
|
|
1029
|
+
// Read failed — preserve any prior `evictedSince` so the next
|
|
1030
|
+
// successful read does not bump the timestamp.
|
|
1031
|
+
const firstSeen = evictionFirstSeenMs.get(key);
|
|
1032
|
+
if (firstSeen !== undefined) {
|
|
1033
|
+
evictedSinceByServiceIndex[di] = new Date(firstSeen).toISOString();
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
raw.evictedSinceByServiceIndex = evictedSinceByServiceIndex;
|
|
1038
|
+
}
|
|
1039
|
+
catch {
|
|
1040
|
+
// Non-fatal: staking state reads should not prevent status from returning
|
|
1041
|
+
}
|
|
506
1042
|
}
|
|
507
1043
|
if (fleet) {
|
|
508
1044
|
const per = {};
|
|
@@ -520,10 +1056,27 @@ export async function gatherGatheredStatusRaw(store, status) {
|
|
|
520
1056
|
raw.serviceBalanceErrors = bal.errorsByDisplay;
|
|
521
1057
|
}
|
|
522
1058
|
}
|
|
1059
|
+
// The tJINN read started up front (overlapping the Base-RPC fan-out). It is
|
|
1060
|
+
// awaited here, as late as possible — after ALL other awaited Base-chain work
|
|
1061
|
+
// — so the up-to-4s tJINN timeout never serializes the Base fan-out behind it.
|
|
1062
|
+
// `gatherTjinnStatus` is internally error-safe, so a plain await is safe.
|
|
1063
|
+
raw.tJinn = await tJinnPromise;
|
|
523
1064
|
return raw;
|
|
524
1065
|
}
|
|
525
1066
|
export async function gatherStatusForApi(store, status) {
|
|
526
1067
|
const raw = await gatherGatheredStatusRaw(store, status);
|
|
527
|
-
|
|
1068
|
+
const body = assembleStatusV1(raw);
|
|
1069
|
+
const caps = status?.spendCaps;
|
|
1070
|
+
if (caps && Object.keys(caps).length > 0) {
|
|
1071
|
+
const now = new Date();
|
|
1072
|
+
const resetsAt = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() + 1)).toISOString();
|
|
1073
|
+
body.spend = {
|
|
1074
|
+
credentials: Object.entries(caps).map(([credentialId, capUsd]) => {
|
|
1075
|
+
const spentTodayUsd = store.spentTodayMicros(credentialId, now) / 1_000_000;
|
|
1076
|
+
return { credentialId, capUsd, spentTodayUsd, paused: isOverSpendCap(spentTodayUsd, capUsd), resetsAt };
|
|
1077
|
+
}),
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1080
|
+
return body;
|
|
528
1081
|
}
|
|
529
1082
|
//# sourceMappingURL=gather-status.js.map
|