@jinn-network/client 0.1.6 → 0.1.7-canary.0a586ca9
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 +57 -2
- package/dist/adapters/mech/adapter.js +366 -63
- package/dist/adapters/mech/adapter.js.map +1 -1
- package/dist/adapters/mech/contracts.d.ts +17 -4
- package/dist/adapters/mech/contracts.js +19 -4
- 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 +24 -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 +7 -0
- package/dist/api/setup-endpoints.js +67 -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 +100 -105
- package/dist/api/solvernets-endpoints.js.map +1 -1
- package/dist/api/status-build.d.ts +167 -2
- package/dist/api/status-build.js +118 -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 +22 -0
- package/dist/chain-read-errors.js +41 -1
- 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/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/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.d.ts +1 -0
- package/dist/cli/commands/solver-nets.js +179 -16
- 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/index.js +2 -0
- package/dist/cli/index.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 +287 -235
- package/dist/config.js +318 -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 +20 -3
- package/dist/daemon/creator.js.map +1 -1
- package/dist/daemon/daemon.d.ts +22 -0
- package/dist/daemon/daemon.js +174 -31
- 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-BNs_ewI6.js +345 -0
- package/dist/dashboard/assets/index-C4huIsUW.css +32 -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 +469 -3
- package/dist/discovery/http.js.map +1 -1
- package/dist/discovery/onchain.d.ts +5 -0
- package/dist/discovery/onchain.js +448 -18
- package/dist/discovery/onchain.js.map +1 -1
- package/dist/discovery/types.d.ts +174 -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 +37 -0
- package/dist/discovery/with-fallback.js.map +1 -1
- package/dist/earning/bootstrap.d.ts +100 -4
- package/dist/earning/bootstrap.js +239 -76
- 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 +124 -0
- package/dist/harnesses/cost-estimates.js +265 -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 +44 -8
- 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 +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 +47 -4
- package/dist/harnesses/impls/learner/harness.js +105 -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 +199 -94
- 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/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 +470 -142
- 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/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 +111 -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 +184 -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/pidfile-liveness.d.ts +44 -0
- package/dist/preflight/pidfile-liveness.js +103 -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/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/scripts/swe-rebench-v2-pytest-missing.json +16 -0
- 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-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-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 +145 -2
- package/dist/solver-types/_swe-rebench-v2-validated-pool.js +482 -44
- package/dist/solver-types/_swe-rebench-v2-validated-pool.js.map +1 -1
- package/dist/solver-types/swe-rebench-v2-auto.d.ts +38 -14
- package/dist/solver-types/swe-rebench-v2-auto.js +87 -28
- package/dist/solver-types/swe-rebench-v2-auto.js.map +1 -1
- package/dist/solver-types/swe-rebench-v2.d.ts +19 -2
- package/dist/solver-types/swe-rebench-v2.js +351 -96
- 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 +41 -7
- 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 +7 -2
- package/dist/solvernets/store.js +1 -0
- package/dist/solvernets/store.js.map +1 -1
- package/dist/spend/cost-surface-status.d.ts +10 -0
- package/dist/spend/cost-surface-status.js +22 -0
- package/dist/spend/cost-surface-status.js.map +1 -0
- 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/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 +98 -32
- package/dist/trajectory/transcript-watcher.js.map +1 -1
- 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/portfolio-v0.d.ts +3 -3
- package/dist/types/payloads/prediction-apy-v0.d.ts +8 -8
- package/dist/types/payloads/prediction-v0.d.ts +17 -17
- 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 +37 -13
- 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 +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,5 +1,6 @@
|
|
|
1
|
-
import { createPublicClient, http } from 'viem';
|
|
1
|
+
import { createPublicClient, http, HttpRequestError } from 'viem';
|
|
2
2
|
import { base, baseSepolia } from 'viem/chains';
|
|
3
|
+
import { describeFallbackChain, maskRpcHost } from '../rpc/transport.js';
|
|
3
4
|
export function expectedChainIdForNetwork(network) {
|
|
4
5
|
return network === 'testnet' ? 84532 : 8453;
|
|
5
6
|
}
|
|
@@ -118,4 +119,69 @@ export function rpcNetworkFailureHint(result) {
|
|
|
118
119
|
}
|
|
119
120
|
return 'Set rpcUrl to a Base mainnet endpoint such as https://mainnet.base.org, or set BASE_RPC_URL.';
|
|
120
121
|
}
|
|
122
|
+
function classifyProbeError(host, err) {
|
|
123
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
124
|
+
if (err instanceof HttpRequestError && typeof err.status === 'number') {
|
|
125
|
+
return { ok: false, host, code: err.status, message };
|
|
126
|
+
}
|
|
127
|
+
// viem wraps HTTP errors inside other shapes; walk the cause chain.
|
|
128
|
+
let cur = err?.cause;
|
|
129
|
+
while (cur) {
|
|
130
|
+
if (cur instanceof HttpRequestError && typeof cur.status === 'number') {
|
|
131
|
+
return { ok: false, host, code: cur.status, message };
|
|
132
|
+
}
|
|
133
|
+
cur = cur.cause;
|
|
134
|
+
}
|
|
135
|
+
return { ok: false, host, reason: 'unreachable', message };
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Probe each URL in a fallback chain with a per-slot `eth_blockNumber` call.
|
|
139
|
+
* Records ok/latency or a structured failure (HTTP status / unreachable).
|
|
140
|
+
*
|
|
141
|
+
* The probe is **log-only** — it never throws on per-slot failures. Startup
|
|
142
|
+
* gating remains the job of {@link checkRpcNetwork}, which fails loud on
|
|
143
|
+
* chain-id mismatch.
|
|
144
|
+
*
|
|
145
|
+
* Per AC9 (issue #592): emits one log line per slot
|
|
146
|
+
* `[rpc] <layer> <host> ok latency=Nms`
|
|
147
|
+
* `[rpc] <layer> <host> warn <http-status>` (e.g. 429, 503)
|
|
148
|
+
* `[rpc] <layer> <host> warn unreachable: <message>`
|
|
149
|
+
*/
|
|
150
|
+
export async function probeFallbackChain(urls, network, layer, options = {}) {
|
|
151
|
+
const log = options.log ?? ((m) => process.stderr.write(`${m}\n`));
|
|
152
|
+
// Chain is informational only — eth_blockNumber doesn't depend on chain
|
|
153
|
+
// identity. Both L1 and L2 layers reuse the same Base/Base-Sepolia pair
|
|
154
|
+
// since this is just used to satisfy viem's typing.
|
|
155
|
+
const chain = network === 'testnet' ? baseSepolia : base;
|
|
156
|
+
const results = [];
|
|
157
|
+
for (const url of urls) {
|
|
158
|
+
const host = maskRpcHost(url);
|
|
159
|
+
const client = createPublicClient({ chain, transport: http(url, { retryCount: 0 }) });
|
|
160
|
+
const t0 = performance.now();
|
|
161
|
+
try {
|
|
162
|
+
await client.getBlockNumber();
|
|
163
|
+
const latencyMs = Math.max(0, Math.round(performance.now() - t0));
|
|
164
|
+
log(`[rpc] ${layer} ${host} ok latency=${latencyMs}ms`);
|
|
165
|
+
results.push({ ok: true, host, latencyMs });
|
|
166
|
+
}
|
|
167
|
+
catch (err) {
|
|
168
|
+
const failure = classifyProbeError(host, err);
|
|
169
|
+
if (failure.code !== undefined) {
|
|
170
|
+
log(`[rpc] ${layer} ${host} warn ${failure.code}`);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
log(`[rpc] ${layer} ${host} warn unreachable: ${failure.message.split('\n')[0]}`);
|
|
174
|
+
}
|
|
175
|
+
results.push(failure);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return results;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Boot-log summary line for a fallback chain, formatted per AC7:
|
|
182
|
+
* `[rpc] L2 transport: fallback chain (N providers) — primary=<host>`
|
|
183
|
+
*/
|
|
184
|
+
export function summarizeFallbackChain(layer, urls) {
|
|
185
|
+
return `[rpc] ${layer} transport: ${describeFallbackChain(urls)}`;
|
|
186
|
+
}
|
|
121
187
|
//# sourceMappingURL=rpc-network.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-network.js","sourceRoot":"","sources":["../../src/preflight/rpc-network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"rpc-network.js","sourceRoot":"","sources":["../../src/preflight/rpc-network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AA8BzE,MAAM,UAAU,yBAAyB,CAAC,OAA2B;IACnE,OAAO,OAAO,KAAK,SAAS,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,EAAE,CAAC;QAC7B,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,cAAc,EAAE,CAAC;YAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;YAClE,GAAG,CAAC,SAAS,KAAK,IAAI,IAAI,eAAe,SAAS,IAAI,CAAC,CAAC;YACxD,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;QAC9C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,GAAG,kBAAkB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAC9C,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBAC/B,GAAG,CAAC,SAAS,KAAK,IAAI,IAAI,SAAS,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;YACrD,CAAC;iBAAM,CAAC;gBACN,GAAG,CAAC,SAAS,KAAK,IAAI,IAAI,sBAAsB,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YACpF,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAiB,EAAE,IAAuB;IAC/E,OAAO,SAAS,KAAK,eAAe,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-process respawn helper for operator-triggered daemon restarts.
|
|
3
|
+
*
|
|
4
|
+
* Issue #289 added respawn-instead-of-exit so the operator panel survives a
|
|
5
|
+
* restart click. Issue #561 fixed the follow-on bug: the original respawn
|
|
6
|
+
* spawned the child *before* the parent had released its server sockets, so
|
|
7
|
+
* the child raced into `.listen(7332)` while the parent still held the port
|
|
8
|
+
* and died with EADDRINUSE / exitCode 11. The fix is `preSpawnCleanup` — an
|
|
9
|
+
* async hook the caller uses to close API + OTLP receivers before the child
|
|
10
|
+
* is spawned. With cleanup in place the port is free synchronously and the
|
|
11
|
+
* child binds on first try; without it (older callers, tests) the helper
|
|
12
|
+
* behaves as before.
|
|
13
|
+
*
|
|
14
|
+
* Every restart-required config change funnels through the same handler:
|
|
15
|
+
*
|
|
16
|
+
* - POST /v1/setup/network — RPC URL change
|
|
17
|
+
* - POST /v1/setup/change-password — keystore password rotation
|
|
18
|
+
* - POST /v1/setup/solvernets/:name — SolverNet enable/disable
|
|
19
|
+
* - POST /v1/operator/join/:cid — SolverNet join
|
|
20
|
+
*
|
|
21
|
+
* Headless gate: `JINN_NO_UI=1` (already the established headless flag in
|
|
22
|
+
* main.ts) skips the respawn — operators running `jinn run --no-ui` from a
|
|
23
|
+
* supervisor / systemd unit / docker entrypoint want the supervisor to
|
|
24
|
+
* decide whether to restart, not the daemon.
|
|
25
|
+
*
|
|
26
|
+
* The helper is split out from main.ts so it's unit-testable without
|
|
27
|
+
* touching the entry-point bootstrap path.
|
|
28
|
+
*/
|
|
29
|
+
import { spawn } from 'node:child_process';
|
|
30
|
+
/**
|
|
31
|
+
* Options for `requestDaemonRestart`. All optional in production; the helper
|
|
32
|
+
* defaults to `process` / `node:child_process`. Tests inject doubles.
|
|
33
|
+
*/
|
|
34
|
+
export interface RequestDaemonRestartOptions {
|
|
35
|
+
/** Defaults to `process.env`. */
|
|
36
|
+
env?: NodeJS.ProcessEnv;
|
|
37
|
+
/** Defaults to `process.argv` (`[node, scriptPath, ...args]`). */
|
|
38
|
+
argv?: readonly string[];
|
|
39
|
+
/** Defaults to `process.execPath` (the node binary). */
|
|
40
|
+
execPath?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Defaults to `node:child_process.spawn`. Injected for tests so we can
|
|
43
|
+
* assert what was spawned without actually forking node.
|
|
44
|
+
*/
|
|
45
|
+
spawnFn?: typeof spawn;
|
|
46
|
+
/** Defaults to `(code) => process.exit(code)`. Injected for tests. */
|
|
47
|
+
exitFn?: (code: number) => void;
|
|
48
|
+
/** Defaults to `console.log`. Injected for tests to capture output. */
|
|
49
|
+
log?: (message: string) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Delay (ms) between spawning the child and exiting the parent. Gives the
|
|
52
|
+
* child a moment to bind the API port before the parent vacates it.
|
|
53
|
+
* Defaults to 250ms per the issue body. Tests can pass 0 for synchrony.
|
|
54
|
+
*/
|
|
55
|
+
exitDelayMs?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Bypass the headless gate. The operator-dashboard Restart button passes
|
|
58
|
+
* this — when the operator clicks Restart, they explicitly want the
|
|
59
|
+
* daemon to come back, even under a supervisor. Supervisor-driven
|
|
60
|
+
* restart flows (MCP tools, signals) leave this `false` so the
|
|
61
|
+
* supervisor stays in charge.
|
|
62
|
+
*/
|
|
63
|
+
forceRespawn?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Optional async hook run *before* the replacement child is spawned. The
|
|
66
|
+
* caller uses this to close listening sockets the child will need to
|
|
67
|
+
* bind — API server (7332) and OTLP receiver (4317/4318) — so the child
|
|
68
|
+
* doesn't lose an EADDRINUSE race with the parent. Errors are caught and
|
|
69
|
+
* logged; the respawn still proceeds because leaving the operator
|
|
70
|
+
* stranded is worse than a noisy close. Skipped in headless mode.
|
|
71
|
+
*/
|
|
72
|
+
preSpawnCleanup?: () => Promise<void>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Pure predicate: true when the current env is headless and respawn should
|
|
76
|
+
* be skipped. Exposed so callers and tests can share the same check.
|
|
77
|
+
*/
|
|
78
|
+
export declare function isHeadless(env?: NodeJS.ProcessEnv): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Handle an operator-triggered restart request.
|
|
81
|
+
*
|
|
82
|
+
* - In **interactive** mode (default), spawn a detached child that re-runs
|
|
83
|
+
* the current node invocation, then exit after a short delay so the child
|
|
84
|
+
* can bind the API port.
|
|
85
|
+
* - In **headless** mode (`JINN_NO_UI=1`), exit without respawning. The
|
|
86
|
+
* supervisor is responsible for relaunching the daemon if it wants to.
|
|
87
|
+
*
|
|
88
|
+
* Returns the action taken (for tests). Production callers ignore the return.
|
|
89
|
+
*/
|
|
90
|
+
export declare function requestDaemonRestart(opts?: RequestDaemonRestartOptions): Promise<'respawned' | 'headless-exit'>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-process respawn helper for operator-triggered daemon restarts.
|
|
3
|
+
*
|
|
4
|
+
* Issue #289 added respawn-instead-of-exit so the operator panel survives a
|
|
5
|
+
* restart click. Issue #561 fixed the follow-on bug: the original respawn
|
|
6
|
+
* spawned the child *before* the parent had released its server sockets, so
|
|
7
|
+
* the child raced into `.listen(7332)` while the parent still held the port
|
|
8
|
+
* and died with EADDRINUSE / exitCode 11. The fix is `preSpawnCleanup` — an
|
|
9
|
+
* async hook the caller uses to close API + OTLP receivers before the child
|
|
10
|
+
* is spawned. With cleanup in place the port is free synchronously and the
|
|
11
|
+
* child binds on first try; without it (older callers, tests) the helper
|
|
12
|
+
* behaves as before.
|
|
13
|
+
*
|
|
14
|
+
* Every restart-required config change funnels through the same handler:
|
|
15
|
+
*
|
|
16
|
+
* - POST /v1/setup/network — RPC URL change
|
|
17
|
+
* - POST /v1/setup/change-password — keystore password rotation
|
|
18
|
+
* - POST /v1/setup/solvernets/:name — SolverNet enable/disable
|
|
19
|
+
* - POST /v1/operator/join/:cid — SolverNet join
|
|
20
|
+
*
|
|
21
|
+
* Headless gate: `JINN_NO_UI=1` (already the established headless flag in
|
|
22
|
+
* main.ts) skips the respawn — operators running `jinn run --no-ui` from a
|
|
23
|
+
* supervisor / systemd unit / docker entrypoint want the supervisor to
|
|
24
|
+
* decide whether to restart, not the daemon.
|
|
25
|
+
*
|
|
26
|
+
* The helper is split out from main.ts so it's unit-testable without
|
|
27
|
+
* touching the entry-point bootstrap path.
|
|
28
|
+
*/
|
|
29
|
+
import { spawn } from 'node:child_process';
|
|
30
|
+
/**
|
|
31
|
+
* Pure predicate: true when the current env is headless and respawn should
|
|
32
|
+
* be skipped. Exposed so callers and tests can share the same check.
|
|
33
|
+
*/
|
|
34
|
+
export function isHeadless(env = process.env) {
|
|
35
|
+
return env['JINN_NO_UI'] === '1';
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Handle an operator-triggered restart request.
|
|
39
|
+
*
|
|
40
|
+
* - In **interactive** mode (default), spawn a detached child that re-runs
|
|
41
|
+
* the current node invocation, then exit after a short delay so the child
|
|
42
|
+
* can bind the API port.
|
|
43
|
+
* - In **headless** mode (`JINN_NO_UI=1`), exit without respawning. The
|
|
44
|
+
* supervisor is responsible for relaunching the daemon if it wants to.
|
|
45
|
+
*
|
|
46
|
+
* Returns the action taken (for tests). Production callers ignore the return.
|
|
47
|
+
*/
|
|
48
|
+
export async function requestDaemonRestart(opts = {}) {
|
|
49
|
+
const env = opts.env ?? process.env;
|
|
50
|
+
const argv = opts.argv ?? process.argv;
|
|
51
|
+
const execPath = opts.execPath ?? process.execPath;
|
|
52
|
+
const spawnFn = opts.spawnFn ?? spawn;
|
|
53
|
+
const exitFn = opts.exitFn ?? ((code) => process.exit(code));
|
|
54
|
+
const log = opts.log ?? ((message) => console.log(message));
|
|
55
|
+
const exitDelayMs = opts.exitDelayMs ?? 250;
|
|
56
|
+
if (isHeadless(env) && !opts.forceRespawn) {
|
|
57
|
+
log('[main] Restart requested via operator MCP, but JINN_NO_UI=1 — exiting without respawn (let the supervisor decide).');
|
|
58
|
+
exitFn(0);
|
|
59
|
+
return 'headless-exit';
|
|
60
|
+
}
|
|
61
|
+
log('[main] Restart requested via operator MCP. Spawning replacement and exiting...');
|
|
62
|
+
// jinn-mono #561: release server sockets BEFORE the child spawns. Without
|
|
63
|
+
// this, the child loses an EADDRINUSE race on 7332 (and OTLP 4317/4318)
|
|
64
|
+
// and dies with exitCode 11 before it can take over.
|
|
65
|
+
if (opts.preSpawnCleanup) {
|
|
66
|
+
try {
|
|
67
|
+
await opts.preSpawnCleanup();
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
log(`[main] preSpawnCleanup error (proceeding with respawn anyway): ${err instanceof Error ? err.message : String(err)}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// argv[0] is the node binary; argv[1..] are the script + flags. The child
|
|
74
|
+
// re-runs the same script with the same flags, under the same node binary.
|
|
75
|
+
const childArgs = argv.slice(1);
|
|
76
|
+
const spawnOptions = {
|
|
77
|
+
detached: true,
|
|
78
|
+
stdio: 'inherit',
|
|
79
|
+
env,
|
|
80
|
+
};
|
|
81
|
+
const child = spawnFn(execPath, childArgs, spawnOptions);
|
|
82
|
+
// Detach so the parent can exit without taking the child with it.
|
|
83
|
+
child.unref();
|
|
84
|
+
// With preSpawnCleanup the port is already free; the small delay is kept
|
|
85
|
+
// as a paranoid belt-and-suspenders against any kernel-level lingering on
|
|
86
|
+
// SO_LINGER-disabled sockets. Tests pass 0.
|
|
87
|
+
if (exitDelayMs <= 0) {
|
|
88
|
+
exitFn(0);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
setTimeout(() => exitFn(0), exitDelayMs);
|
|
92
|
+
}
|
|
93
|
+
return 'respawned';
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=restart-daemon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restart-daemon.js","sourceRoot":"","sources":["../src/restart-daemon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AA+C9D;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,MAAyB,OAAO,CAAC,GA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G,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CACjD,EAAE,CACH,CAAC;QACJ,CAAC;IACH,CAAC;IAED,0EAA0E;IAC1E,2EAA2E;IAC3E,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,YAAY,GAAiB;QACjC,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,SAAS;QAChB,GAAG;KACJ,CAAC;IACF,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;IACzD,kEAAkE;IAClE,KAAK,CAAC,KAAK,EAAE,CAAC;IAEd,yEAAyE;IACzE,0EAA0E;IAC1E,4CAA4C;IAC5C,IAAI,WAAW,IAAI,CAAC,EAAE,CAAC;QACrB,MAAM,CAAC,CAAC,CAAC,CAAC;IACZ,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPC transport helper — builds a viem `fallback()` transport from a single
|
|
3
|
+
* URL, an array of URLs, or a comma-separated string. The substrate for issue
|
|
4
|
+
* #592 (multi-RPC fallback chain across daemon / relayer / indexer / CI).
|
|
5
|
+
*
|
|
6
|
+
* Design:
|
|
7
|
+
* - `parseRpcUrls` normalises `string | readonly string[]` to a deduplicated
|
|
8
|
+
* non-empty array, splits comma-strings, trims, drops empties, and caps the
|
|
9
|
+
* chain at {@link MAX_RPC_CHAIN_LENGTH} providers (extras are dropped with a
|
|
10
|
+
* warning). Throws when no URLs remain.
|
|
11
|
+
* - `buildFallbackTransport` wraps `http(url)` per slot inside viem's
|
|
12
|
+
* `fallback([...], { rank: false, retryCount: 0 })`. `rank: false` is
|
|
13
|
+
* explicit — the issue's "Tenderly stays in slot 3" constraint requires
|
|
14
|
+
* order preservation (no latency-based reshuffling). `retryCount: 0` keeps
|
|
15
|
+
* the helper from doubling retries on top of the existing
|
|
16
|
+
* `withRecoverableRetry` wrapper used by callers like the mech adapter.
|
|
17
|
+
* - On exhausted fall-through the helper rejects with `AllRpcsFailedError`,
|
|
18
|
+
* which carries a structured `providers: readonly string[]` list of masked
|
|
19
|
+
* hosts so callers and tests can assert on it.
|
|
20
|
+
* - `describeFallbackChain` formats the canonical AC7 boot-log summary line:
|
|
21
|
+
* `fallback chain (N providers) — primary=<host>`.
|
|
22
|
+
*
|
|
23
|
+
* Do not conflate with `discovery.fallbackToOnchain` — that's a separate layer
|
|
24
|
+
* at the read-API level (Ponder → eth_getLogs floor). This helper sits beneath
|
|
25
|
+
* both layers at the JSON-RPC transport level.
|
|
26
|
+
*/
|
|
27
|
+
import { type FallbackTransport, type Transport } from 'viem';
|
|
28
|
+
/**
|
|
29
|
+
* Hard cap on the number of providers in a single fallback chain. Four covers
|
|
30
|
+
* the "operator paid primary + public publicnode + public sepolia.base.org +
|
|
31
|
+
* Tenderly slot-3" shape from the issue; beyond that the boot probe takes too
|
|
32
|
+
* long and slot 5+ is almost always copy-paste noise.
|
|
33
|
+
*/
|
|
34
|
+
export declare const MAX_RPC_CHAIN_LENGTH = 4;
|
|
35
|
+
export interface ParseRpcUrlsOptions {
|
|
36
|
+
/** Logger used to emit the "capped" warning. Defaults to `console.error`. */
|
|
37
|
+
log?: (message: string) => void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Normalise `string | readonly string[]` into a non-empty, deduplicated,
|
|
41
|
+
* capped list of RPC URLs. Comma-separated strings are split (operator
|
|
42
|
+
* convention, see `peers` in `config.ts`). Duplicates are removed before the
|
|
43
|
+
* cap is applied so the effective chain length matches operator intent (an
|
|
44
|
+
* operator who prepends their paid primary to the existing fallback list
|
|
45
|
+
* shouldn't burn a slot on the duplicate).
|
|
46
|
+
*
|
|
47
|
+
* @throws if the input yields zero non-empty URLs.
|
|
48
|
+
*/
|
|
49
|
+
export declare function parseRpcUrls(input: string | readonly string[], options?: ParseRpcUrlsOptions): string[];
|
|
50
|
+
/**
|
|
51
|
+
* Error thrown when every provider in a fallback chain has failed. Carries
|
|
52
|
+
* the masked host list so callers can surface a useful operator-facing message
|
|
53
|
+
* without leaking secret query strings (api-key paths).
|
|
54
|
+
*/
|
|
55
|
+
export declare class AllRpcsFailedError extends Error {
|
|
56
|
+
readonly providers: readonly string[];
|
|
57
|
+
readonly cause?: unknown;
|
|
58
|
+
constructor(providers: readonly string[], cause?: unknown);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Detect errors that viem's `fallback()` short-circuits on (via its
|
|
62
|
+
* `shouldThrow(err)` fast-exit) — `ExecutionRevertedError`,
|
|
63
|
+
* `TransactionRejectedRpcError`, `UserRejectedRequestError`,
|
|
64
|
+
* `WalletConnectSessionSettlementError`, and CAIP user-rejected (code
|
|
65
|
+
* `5000`). These are EVM- or wallet-level signals, NOT transport-level
|
|
66
|
+
* failures, so they must propagate unchanged. Wrapping them as
|
|
67
|
+
* `AllRpcsFailedError` would give the operator-app a false-positive
|
|
68
|
+
* "all RPCs failed" message when the actual problem is e.g. a contract
|
|
69
|
+
* revert on a view function.
|
|
70
|
+
*
|
|
71
|
+
* Mirrors viem's own predicate at
|
|
72
|
+
* `node_modules/viem/clients/transports/fallback.ts` (`shouldThrow`),
|
|
73
|
+
* dispatching by **numeric JSON-RPC code** (the path that catches real
|
|
74
|
+
* `RpcRequestError` instances coming out of the HTTP transport) plus the
|
|
75
|
+
* `ExecutionRevertedError.nodeMessage` regex (the path that catches reverts
|
|
76
|
+
* surfaced as plain `Error` with no numeric code). The cause-chain walk by
|
|
77
|
+
* class `name` remains as a third path for wallet-provider stacks that
|
|
78
|
+
* deliver proper class instances (and for already-normalised errors after
|
|
79
|
+
* viem's `buildRequest` re-wrap pass).
|
|
80
|
+
*/
|
|
81
|
+
export declare function isViemShouldThrowError(err: unknown): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Mask an RPC URL down to its hostname for display / error reporting. Drops
|
|
84
|
+
* the path so api-key segments in the URL don't leak into logs.
|
|
85
|
+
*/
|
|
86
|
+
export declare function maskRpcHost(url: string): string;
|
|
87
|
+
export interface BuildFallbackTransportOptions {
|
|
88
|
+
/**
|
|
89
|
+
* Set to `true` to let viem rank providers by latency. Default `false` —
|
|
90
|
+
* order matters for operator-configured paid primaries and the
|
|
91
|
+
* "Tenderly stays in slot 3" constraint from the issue.
|
|
92
|
+
*/
|
|
93
|
+
rank?: boolean;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Build a viem fallback transport over the given URLs. Returns a callable
|
|
97
|
+
* transport suitable for `createPublicClient({ transport })`.
|
|
98
|
+
*
|
|
99
|
+
* Errors that exhaust the chain are wrapped in `AllRpcsFailedError`.
|
|
100
|
+
*/
|
|
101
|
+
export declare function buildFallbackTransport(urls: readonly string[], options?: BuildFallbackTransportOptions): FallbackTransport;
|
|
102
|
+
export declare namespace buildFallbackTransport {
|
|
103
|
+
var buildFromTransports: (transports: readonly Transport[], urls: readonly string[], options?: BuildFallbackTransportOptions) => FallbackTransport;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Boot-log summary line for a fallback chain. Matches the canonical AC7
|
|
107
|
+
* format: `fallback chain (N providers) — primary=<host>`.
|
|
108
|
+
*/
|
|
109
|
+
export declare function describeFallbackChain(urls: readonly string[]): string;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPC transport helper — builds a viem `fallback()` transport from a single
|
|
3
|
+
* URL, an array of URLs, or a comma-separated string. The substrate for issue
|
|
4
|
+
* #592 (multi-RPC fallback chain across daemon / relayer / indexer / CI).
|
|
5
|
+
*
|
|
6
|
+
* Design:
|
|
7
|
+
* - `parseRpcUrls` normalises `string | readonly string[]` to a deduplicated
|
|
8
|
+
* non-empty array, splits comma-strings, trims, drops empties, and caps the
|
|
9
|
+
* chain at {@link MAX_RPC_CHAIN_LENGTH} providers (extras are dropped with a
|
|
10
|
+
* warning). Throws when no URLs remain.
|
|
11
|
+
* - `buildFallbackTransport` wraps `http(url)` per slot inside viem's
|
|
12
|
+
* `fallback([...], { rank: false, retryCount: 0 })`. `rank: false` is
|
|
13
|
+
* explicit — the issue's "Tenderly stays in slot 3" constraint requires
|
|
14
|
+
* order preservation (no latency-based reshuffling). `retryCount: 0` keeps
|
|
15
|
+
* the helper from doubling retries on top of the existing
|
|
16
|
+
* `withRecoverableRetry` wrapper used by callers like the mech adapter.
|
|
17
|
+
* - On exhausted fall-through the helper rejects with `AllRpcsFailedError`,
|
|
18
|
+
* which carries a structured `providers: readonly string[]` list of masked
|
|
19
|
+
* hosts so callers and tests can assert on it.
|
|
20
|
+
* - `describeFallbackChain` formats the canonical AC7 boot-log summary line:
|
|
21
|
+
* `fallback chain (N providers) — primary=<host>`.
|
|
22
|
+
*
|
|
23
|
+
* Do not conflate with `discovery.fallbackToOnchain` — that's a separate layer
|
|
24
|
+
* at the read-API level (Ponder → eth_getLogs floor). This helper sits beneath
|
|
25
|
+
* both layers at the JSON-RPC transport level.
|
|
26
|
+
*/
|
|
27
|
+
import { ExecutionRevertedError, fallback, http, TransactionRejectedRpcError, UserRejectedRequestError, } from 'viem';
|
|
28
|
+
/**
|
|
29
|
+
* Hard cap on the number of providers in a single fallback chain. Four covers
|
|
30
|
+
* the "operator paid primary + public publicnode + public sepolia.base.org +
|
|
31
|
+
* Tenderly slot-3" shape from the issue; beyond that the boot probe takes too
|
|
32
|
+
* long and slot 5+ is almost always copy-paste noise.
|
|
33
|
+
*/
|
|
34
|
+
export const MAX_RPC_CHAIN_LENGTH = 4;
|
|
35
|
+
/**
|
|
36
|
+
* Normalise `string | readonly string[]` into a non-empty, deduplicated,
|
|
37
|
+
* capped list of RPC URLs. Comma-separated strings are split (operator
|
|
38
|
+
* convention, see `peers` in `config.ts`). Duplicates are removed before the
|
|
39
|
+
* cap is applied so the effective chain length matches operator intent (an
|
|
40
|
+
* operator who prepends their paid primary to the existing fallback list
|
|
41
|
+
* shouldn't burn a slot on the duplicate).
|
|
42
|
+
*
|
|
43
|
+
* @throws if the input yields zero non-empty URLs.
|
|
44
|
+
*/
|
|
45
|
+
export function parseRpcUrls(input, options = {}) {
|
|
46
|
+
const log = options.log ?? ((m) => process.stderr.write(`${m}\n`));
|
|
47
|
+
const raw = typeof input === 'string' ? input.split(',') : [...input];
|
|
48
|
+
const cleaned = raw.map((u) => u.trim()).filter((u) => u.length > 0);
|
|
49
|
+
if (cleaned.length === 0) {
|
|
50
|
+
throw new Error('parseRpcUrls: at least one RPC URL is required');
|
|
51
|
+
}
|
|
52
|
+
// Dedup before applying the cap so repeated URLs (easy to introduce when an
|
|
53
|
+
// operator prepends a paid primary that already exists in the fallback list)
|
|
54
|
+
// don't burn slots of the 4-slot chain. `Set` preserves first-seen insertion
|
|
55
|
+
// order, which matches the "primary stays in slot 0" constraint.
|
|
56
|
+
const deduped = [...new Set(cleaned)];
|
|
57
|
+
if (deduped.length > MAX_RPC_CHAIN_LENGTH) {
|
|
58
|
+
log(`[rpc] capped fallback chain to ${MAX_RPC_CHAIN_LENGTH} providers ` +
|
|
59
|
+
`(dropped ${deduped.length - MAX_RPC_CHAIN_LENGTH} extra slots)`);
|
|
60
|
+
return deduped.slice(0, MAX_RPC_CHAIN_LENGTH);
|
|
61
|
+
}
|
|
62
|
+
return deduped;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Error thrown when every provider in a fallback chain has failed. Carries
|
|
66
|
+
* the masked host list so callers can surface a useful operator-facing message
|
|
67
|
+
* without leaking secret query strings (api-key paths).
|
|
68
|
+
*/
|
|
69
|
+
export class AllRpcsFailedError extends Error {
|
|
70
|
+
providers;
|
|
71
|
+
cause;
|
|
72
|
+
constructor(providers, cause) {
|
|
73
|
+
super(`All RPC providers in the fallback chain failed (providers=${providers.join(', ')})`);
|
|
74
|
+
this.name = 'AllRpcsFailedError';
|
|
75
|
+
this.providers = providers;
|
|
76
|
+
this.cause = cause;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Detect errors that viem's `fallback()` short-circuits on (via its
|
|
81
|
+
* `shouldThrow(err)` fast-exit) — `ExecutionRevertedError`,
|
|
82
|
+
* `TransactionRejectedRpcError`, `UserRejectedRequestError`,
|
|
83
|
+
* `WalletConnectSessionSettlementError`, and CAIP user-rejected (code
|
|
84
|
+
* `5000`). These are EVM- or wallet-level signals, NOT transport-level
|
|
85
|
+
* failures, so they must propagate unchanged. Wrapping them as
|
|
86
|
+
* `AllRpcsFailedError` would give the operator-app a false-positive
|
|
87
|
+
* "all RPCs failed" message when the actual problem is e.g. a contract
|
|
88
|
+
* revert on a view function.
|
|
89
|
+
*
|
|
90
|
+
* Mirrors viem's own predicate at
|
|
91
|
+
* `node_modules/viem/clients/transports/fallback.ts` (`shouldThrow`),
|
|
92
|
+
* dispatching by **numeric JSON-RPC code** (the path that catches real
|
|
93
|
+
* `RpcRequestError` instances coming out of the HTTP transport) plus the
|
|
94
|
+
* `ExecutionRevertedError.nodeMessage` regex (the path that catches reverts
|
|
95
|
+
* surfaced as plain `Error` with no numeric code). The cause-chain walk by
|
|
96
|
+
* class `name` remains as a third path for wallet-provider stacks that
|
|
97
|
+
* deliver proper class instances (and for already-normalised errors after
|
|
98
|
+
* viem's `buildRequest` re-wrap pass).
|
|
99
|
+
*/
|
|
100
|
+
export function isViemShouldThrowError(err) {
|
|
101
|
+
// 1. Code-based dispatch — matches what viem's own `shouldThrow` does,
|
|
102
|
+
// so a raw `RpcRequestError { code: 3 | -32003 | 4001 | 7000 | 5000 }`
|
|
103
|
+
// from the HTTP transport is caught here regardless of class name.
|
|
104
|
+
// Codes are pulled from the viem error classes (no magic numbers) where
|
|
105
|
+
// available; 7000 and 5000 are inline because
|
|
106
|
+
// `WalletConnectSessionSettlementError` is not re-exported from the
|
|
107
|
+
// top-level `viem` package and 5000 is the CAIP user-rejected code
|
|
108
|
+
// viem hard-codes alongside it.
|
|
109
|
+
if (err instanceof Error && 'code' in err && typeof err.code === 'number') {
|
|
110
|
+
const code = err.code;
|
|
111
|
+
if (code === ExecutionRevertedError.code || // 3 — contract revert
|
|
112
|
+
code === TransactionRejectedRpcError.code || // -32003 — tx rejected
|
|
113
|
+
code === UserRejectedRequestError.code || // 4001 — user-rejected
|
|
114
|
+
code === 7000 || // WalletConnectSessionSettlementError
|
|
115
|
+
code === 5000 // CAIP user-rejected
|
|
116
|
+
)
|
|
117
|
+
return true;
|
|
118
|
+
// 2. nodeMessage regex — catches reverts that arrive as a plain `Error`
|
|
119
|
+
// (no numeric code, no recognised class name). Viem's own
|
|
120
|
+
// `shouldThrow` runs this check too.
|
|
121
|
+
if (ExecutionRevertedError.nodeMessage.test(err.message))
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
// 3. Cause-chain walk — viem wraps low-level RPC errors in higher-level
|
|
125
|
+
// error classes (e.g. `ContractFunctionExecutionError` →
|
|
126
|
+
// `RpcRequestError` → `ExecutionRevertedError`), and wallet providers
|
|
127
|
+
// can deliver proper class instances directly. Walk with cycle
|
|
128
|
+
// detection so a self-referential `.cause` cannot infinite-loop.
|
|
129
|
+
const seen = new Set();
|
|
130
|
+
let cursor = err;
|
|
131
|
+
while (cursor instanceof Error && !seen.has(cursor)) {
|
|
132
|
+
seen.add(cursor);
|
|
133
|
+
if (cursor.name === 'ExecutionRevertedError')
|
|
134
|
+
return true;
|
|
135
|
+
if (cursor.name === 'TransactionRejectedRpcError')
|
|
136
|
+
return true;
|
|
137
|
+
if (cursor.name === 'UserRejectedRequestError')
|
|
138
|
+
return true;
|
|
139
|
+
if (cursor.name === 'WalletConnectSessionSettlementError')
|
|
140
|
+
return true;
|
|
141
|
+
cursor = cursor.cause;
|
|
142
|
+
}
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Mask an RPC URL down to its hostname for display / error reporting. Drops
|
|
147
|
+
* the path so api-key segments in the URL don't leak into logs.
|
|
148
|
+
*/
|
|
149
|
+
export function maskRpcHost(url) {
|
|
150
|
+
try {
|
|
151
|
+
const parsed = new URL(url);
|
|
152
|
+
return parsed.hostname || '(unknown host)';
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
return '(invalid rpc url)';
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Build a viem fallback transport over the given URLs. Returns a callable
|
|
160
|
+
* transport suitable for `createPublicClient({ transport })`.
|
|
161
|
+
*
|
|
162
|
+
* Errors that exhaust the chain are wrapped in `AllRpcsFailedError`.
|
|
163
|
+
*/
|
|
164
|
+
export function buildFallbackTransport(urls, options = {}) {
|
|
165
|
+
const transports = urls.map((url) => http(url));
|
|
166
|
+
return buildFallbackTransport.buildFromTransports(transports, urls, options);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Internal helper exposed for tests: build a fallback transport from
|
|
170
|
+
* pre-constructed viem transports (e.g. `custom()` mocks) so tests can drive
|
|
171
|
+
* each slot deterministically without an actual HTTP fetch.
|
|
172
|
+
*/
|
|
173
|
+
buildFallbackTransport.buildFromTransports = function buildFromTransports(transports, urls, options = {}) {
|
|
174
|
+
const maskedProviders = urls.map(maskRpcHost);
|
|
175
|
+
const inner = fallback(transports, {
|
|
176
|
+
rank: options.rank ?? false,
|
|
177
|
+
retryCount: 0,
|
|
178
|
+
});
|
|
179
|
+
// Wrap the transport so that the final exhausted-chain rejection surfaces
|
|
180
|
+
// as our structured `AllRpcsFailedError` (carrying the masked host list).
|
|
181
|
+
// We do the wrap at the transport-factory level rather than swapping the
|
|
182
|
+
// returned function's `request` so the FallbackTransport's typed shape
|
|
183
|
+
// (`onResponse`, `transports`, etc.) is preserved.
|
|
184
|
+
const wrapped = ((config) => {
|
|
185
|
+
const t = inner(config);
|
|
186
|
+
const originalRequest = t.request.bind(t);
|
|
187
|
+
t.request = (async (args) => {
|
|
188
|
+
try {
|
|
189
|
+
return await originalRequest(args);
|
|
190
|
+
}
|
|
191
|
+
catch (err) {
|
|
192
|
+
// viem's fallback() short-circuits on shouldThrow-class errors
|
|
193
|
+
// (contract revert, user-rejected, CAIP 5000) — those are
|
|
194
|
+
// EVM/wallet-level, not transport-level failures. Propagate them
|
|
195
|
+
// unchanged so callers (and the operator-app's `rpc_all_failed`
|
|
196
|
+
// state message) don't misread a single-slot revert as an
|
|
197
|
+
// exhausted-chain outage.
|
|
198
|
+
if (isViemShouldThrowError(err))
|
|
199
|
+
throw err;
|
|
200
|
+
// Otherwise: viem doesn't expose a distinct "all transports failed"
|
|
201
|
+
// error class — when fallback exhausts the chain it throws the last
|
|
202
|
+
// underlying error. Wrap so the caller gets a stable structural
|
|
203
|
+
// error carrying the masked provider list.
|
|
204
|
+
throw new AllRpcsFailedError(maskedProviders, err);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
return t;
|
|
208
|
+
});
|
|
209
|
+
return wrapped;
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Boot-log summary line for a fallback chain. Matches the canonical AC7
|
|
213
|
+
* format: `fallback chain (N providers) — primary=<host>`.
|
|
214
|
+
*/
|
|
215
|
+
export function describeFallbackChain(urls) {
|
|
216
|
+
if (urls.length === 0)
|
|
217
|
+
return 'fallback chain (0 providers)';
|
|
218
|
+
return `fallback chain (${urls.length} providers) — primary=${maskRpcHost(urls[0])}`;
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/rpc/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EACL,sBAAsB,EACtB,QAAQ,EACR,IAAI,EACJ,2BAA2B,EAC3B,wBAAwB,GAGzB,MAAM,MAAM,CAAC;AAEd;;;;;GAKG;AACH,MAAM,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