@jinn-network/client 0.1.1 → 0.1.2-canary.6237288d
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 +16 -0
- package/CONTRIBUTING.md +123 -0
- package/README.md +213 -37
- package/deployments/deployment-claim-registry-baseSepolia.json +13 -0
- package/deployments/deployment-jinn-testnet-faucet-baseSepolia-fast.json +15 -0
- package/dist/adapters/adapter.d.ts +7 -0
- package/dist/adapters/claim-registry/abi.d.ts +127 -0
- package/dist/adapters/claim-registry/abi.js +93 -0
- package/dist/adapters/claim-registry/abi.js.map +1 -0
- package/dist/adapters/claim-registry/client.d.ts +89 -0
- package/dist/adapters/claim-registry/client.js +205 -0
- package/dist/adapters/claim-registry/client.js.map +1 -0
- package/dist/adapters/mech/adapter.d.ts +5 -0
- package/dist/adapters/mech/adapter.js +211 -56
- package/dist/adapters/mech/adapter.js.map +1 -1
- package/dist/adapters/mech/contracts.d.ts +19 -1
- package/dist/adapters/mech/contracts.js +112 -8
- package/dist/adapters/mech/contracts.js.map +1 -1
- package/dist/adapters/mech/ipfs.d.ts +38 -5
- package/dist/adapters/mech/ipfs.js +174 -17
- package/dist/adapters/mech/ipfs.js.map +1 -1
- package/dist/adapters/mech/safe.js +8 -6
- package/dist/adapters/mech/safe.js.map +1 -1
- package/dist/adapters/mech/types.d.ts +22 -46
- package/dist/adapters/mech/types.js +16 -35
- package/dist/adapters/mech/types.js.map +1 -1
- package/dist/api/balance-build.js +3 -3
- package/dist/api/balance-build.js.map +1 -1
- package/dist/api/fleet-build.js +35 -40
- package/dist/api/fleet-build.js.map +1 -1
- package/dist/api/gather-status.d.ts +6 -0
- package/dist/api/gather-status.js +187 -4
- package/dist/api/gather-status.js.map +1 -1
- package/dist/api/history-build.d.ts +5 -1
- package/dist/api/history-build.js +51 -26
- package/dist/api/history-build.js.map +1 -1
- package/dist/api/portfolio-v0-build.d.ts +83 -0
- package/dist/api/portfolio-v0-build.js +143 -0
- package/dist/api/portfolio-v0-build.js.map +1 -0
- package/dist/api/portfolio-v0-doctor.d.ts +37 -0
- package/dist/api/portfolio-v0-doctor.js +123 -0
- package/dist/api/portfolio-v0-doctor.js.map +1 -0
- package/dist/api/rewards-build.js +30 -14
- package/dist/api/rewards-build.js.map +1 -1
- package/dist/api/status-build.d.ts +39 -6
- package/dist/api/status-build.js +3 -1
- package/dist/api/status-build.js.map +1 -1
- package/dist/api/status-rollup-build.d.ts +2 -0
- package/dist/api/status-rollup-build.js +30 -3
- package/dist/api/status-rollup-build.js.map +1 -1
- package/dist/bin/jinn-mcp.d.ts +0 -12
- package/dist/bin/jinn-mcp.js +5 -14
- package/dist/bin/jinn-mcp.js.map +1 -1
- package/dist/build-meta.json +1 -1
- package/dist/cli/commands/auth.js +137 -25
- package/dist/cli/commands/auth.js.map +1 -1
- package/dist/cli/commands/balance.js +8 -1
- package/dist/cli/commands/balance.js.map +1 -1
- package/dist/cli/commands/bootstrap.js +23 -0
- package/dist/cli/commands/bootstrap.js.map +1 -1
- package/dist/cli/commands/doctor.js +160 -14
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/fleet-scale.js +1 -0
- package/dist/cli/commands/fleet-scale.js.map +1 -1
- package/dist/cli/commands/fleet.js +10 -1
- package/dist/cli/commands/fleet.js.map +1 -1
- package/dist/cli/commands/fund-requirements.js +2 -0
- package/dist/cli/commands/fund-requirements.js.map +1 -1
- package/dist/cli/commands/history.js +25 -6
- package/dist/cli/commands/history.js.map +1 -1
- package/dist/cli/commands/intents.d.ts +17 -0
- package/dist/cli/commands/intents.js +489 -0
- package/dist/cli/commands/intents.js.map +1 -0
- package/dist/cli/commands/keys-backup.js +13 -11
- package/dist/cli/commands/keys-backup.js.map +1 -1
- package/dist/cli/commands/logs.js +35 -11
- package/dist/cli/commands/logs.js.map +1 -1
- package/dist/cli/commands/mcp.d.ts +3 -0
- package/dist/cli/commands/mcp.js +19 -0
- package/dist/cli/commands/mcp.js.map +1 -0
- package/dist/cli/commands/plugin-install.js +8 -4
- package/dist/cli/commands/plugin-install.js.map +1 -1
- package/dist/cli/commands/quickstart.js +99 -5
- package/dist/cli/commands/quickstart.js.map +1 -1
- package/dist/cli/commands/rewards.js +27 -1
- package/dist/cli/commands/rewards.js.map +1 -1
- package/dist/cli/commands/run.js +38 -0
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/status.js +11 -1
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/submit-intent.js +110 -44
- package/dist/cli/commands/submit-intent.js.map +1 -1
- package/dist/cli/commands/version.js +1 -0
- package/dist/cli/commands/version.js.map +1 -1
- package/dist/cli/deployment-digest.js +5 -0
- package/dist/cli/deployment-digest.js.map +1 -1
- package/dist/cli/execution-context.js +1 -0
- package/dist/cli/execution-context.js.map +1 -1
- package/dist/cli/index.js +4 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/intent-registry-access.d.ts +62 -0
- package/dist/cli/intent-registry-access.js +165 -0
- package/dist/cli/intent-registry-access.js.map +1 -0
- package/dist/cli/introspection-context.js +12 -8
- package/dist/cli/introspection-context.js.map +1 -1
- package/dist/cli/password.d.ts +21 -9
- package/dist/cli/password.js +45 -24
- package/dist/cli/password.js.map +1 -1
- package/dist/config.d.ts +137 -8
- package/dist/config.js +70 -12
- package/dist/config.js.map +1 -1
- package/dist/daemon/balance-topup-loop.js +32 -4
- package/dist/daemon/balance-topup-loop.js.map +1 -1
- package/dist/daemon/creator.d.ts +7 -4
- package/dist/daemon/creator.js +55 -26
- package/dist/daemon/creator.js.map +1 -1
- package/dist/daemon/daemon.d.ts +35 -3
- package/dist/daemon/daemon.js +99 -7
- package/dist/daemon/daemon.js.map +1 -1
- package/dist/daemon/delivery-watcher.d.ts +3 -1
- package/dist/daemon/delivery-watcher.js +19 -1
- package/dist/daemon/delivery-watcher.js.map +1 -1
- package/dist/daemon/reward-claim-loop.js +38 -1
- package/dist/daemon/reward-claim-loop.js.map +1 -1
- package/dist/dashboard/index.html +71 -496
- package/dist/discovery/registry.d.ts +54 -0
- package/dist/discovery/registry.js +73 -0
- package/dist/discovery/registry.js.map +1 -1
- package/dist/earning/bootstrap.d.ts +2 -1
- package/dist/earning/bootstrap.js +71 -33
- package/dist/earning/bootstrap.js.map +1 -1
- package/dist/earning/contracts.d.ts +10 -0
- package/dist/earning/contracts.js +24 -0
- package/dist/earning/contracts.js.map +1 -1
- package/dist/earning/jinn-rewards.d.ts +9 -0
- package/dist/earning/jinn-rewards.js +7 -0
- package/dist/earning/jinn-rewards.js.map +1 -1
- package/dist/earning/stolas-claim.d.ts +6 -0
- package/dist/earning/stolas-claim.js +7 -0
- package/dist/earning/stolas-claim.js.map +1 -1
- package/dist/intents/kinds/constants.d.ts +5 -0
- package/dist/intents/kinds/constants.js +6 -0
- package/dist/intents/kinds/constants.js.map +1 -0
- package/dist/intents/kinds/index.d.ts +28 -0
- package/dist/intents/kinds/index.js +50 -0
- package/dist/intents/kinds/index.js.map +1 -0
- package/dist/intents/kinds/portfolio-v0.d.ts +2 -0
- package/dist/intents/kinds/portfolio-v0.js +13 -0
- package/dist/intents/kinds/portfolio-v0.js.map +1 -0
- package/dist/intents/kinds/prediction-apy-v0.d.ts +3 -0
- package/dist/intents/kinds/prediction-apy-v0.js +21 -0
- package/dist/intents/kinds/prediction-apy-v0.js.map +1 -0
- package/dist/intents/kinds/prediction-v0.d.ts +3 -0
- package/dist/intents/kinds/prediction-v0.js +32 -0
- package/dist/intents/kinds/prediction-v0.js.map +1 -0
- package/dist/intents/kinds/spec-kind.d.ts +38 -0
- package/dist/intents/kinds/spec-kind.js +6 -0
- package/dist/intents/kinds/spec-kind.js.map +1 -0
- package/dist/intents/posting-service.d.ts +26 -0
- package/dist/intents/posting-service.js +218 -0
- package/dist/intents/posting-service.js.map +1 -0
- package/dist/intents/prediction-apy-v0-auto.d.ts +11 -0
- package/dist/intents/prediction-apy-v0-auto.js +46 -0
- package/dist/intents/prediction-apy-v0-auto.js.map +1 -0
- package/dist/intents/prediction-apy-v0-template.d.ts +8 -0
- package/dist/intents/prediction-apy-v0-template.js +22 -0
- package/dist/intents/prediction-apy-v0-template.js.map +1 -0
- package/dist/intents/prediction-v0-auto.d.ts +53 -0
- package/dist/intents/prediction-v0-auto.js +84 -0
- package/dist/intents/prediction-v0-auto.js.map +1 -0
- package/dist/intents/prediction-v0-template.d.ts +70 -0
- package/dist/intents/prediction-v0-template.js +145 -0
- package/dist/intents/prediction-v0-template.js.map +1 -0
- package/dist/intents/sources.d.ts +39 -0
- package/dist/intents/sources.js +42 -0
- package/dist/intents/sources.js.map +1 -0
- package/dist/main.js +175 -3
- package/dist/main.js.map +1 -1
- package/dist/mcp/operator-server.d.ts +1 -1
- package/dist/mcp/operator-server.js +1 -1
- package/dist/mcp/server.js +8 -4
- package/dist/mcp/server.js.map +1 -1
- package/dist/observability/emit-event.d.ts +12 -0
- package/dist/observability/emit-event.js +27 -0
- package/dist/observability/emit-event.js.map +1 -0
- package/dist/preflight/api-port.d.ts +13 -0
- package/dist/preflight/api-port.js +32 -0
- package/dist/preflight/api-port.js.map +1 -0
- package/dist/preflight/claude-auth.d.ts +12 -1
- package/dist/preflight/claude-auth.js +21 -3
- package/dist/preflight/claude-auth.js.map +1 -1
- package/dist/preflight/rpc-network.d.ts +44 -0
- package/dist/preflight/rpc-network.js +121 -0
- package/dist/preflight/rpc-network.js.map +1 -0
- package/dist/restorer/engine/canonical-json.d.ts +18 -0
- package/dist/restorer/engine/canonical-json.js +59 -0
- package/dist/restorer/engine/canonical-json.js.map +1 -0
- package/dist/restorer/engine/claim.d.ts +69 -0
- package/dist/restorer/engine/claim.js +104 -0
- package/dist/restorer/engine/claim.js.map +1 -0
- package/dist/restorer/engine/delivery.d.ts +52 -0
- package/dist/restorer/engine/delivery.js +63 -0
- package/dist/restorer/engine/delivery.js.map +1 -0
- package/dist/restorer/engine/engine.d.ts +213 -0
- package/dist/restorer/engine/engine.js +769 -0
- package/dist/restorer/engine/engine.js.map +1 -0
- package/dist/restorer/engine/manifest-assembly.d.ts +67 -0
- package/dist/restorer/engine/manifest-assembly.js +79 -0
- package/dist/restorer/engine/manifest-assembly.js.map +1 -0
- package/dist/restorer/engine/packaging.d.ts +87 -0
- package/dist/restorer/engine/packaging.js +350 -0
- package/dist/restorer/engine/packaging.js.map +1 -0
- package/dist/restorer/engine/persistence.d.ts +170 -0
- package/dist/restorer/engine/persistence.js +381 -0
- package/dist/restorer/engine/persistence.js.map +1 -0
- package/dist/restorer/engine/recovery.d.ts +22 -0
- package/dist/restorer/engine/recovery.js +24 -0
- package/dist/restorer/engine/recovery.js.map +1 -0
- package/dist/restorer/engine/registry.d.ts +62 -0
- package/dist/restorer/engine/registry.js +73 -0
- package/dist/restorer/engine/registry.js.map +1 -0
- package/dist/restorer/engine/signing.d.ts +30 -0
- package/dist/restorer/engine/signing.js +39 -0
- package/dist/restorer/engine/signing.js.map +1 -0
- package/dist/restorer/engine/state.d.ts +42 -0
- package/dist/restorer/engine/state.js +87 -0
- package/dist/restorer/engine/state.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.d.ts +64 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.js +96 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/api-wallet.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/index.d.ts +104 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/index.js +721 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/index.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.d.ts +137 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.js +865 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/mcp-tools.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.d.ts +74 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.js +74 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/safety-rails.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.d.ts +97 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.js +226 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-prediction/index.d.ts +44 -0
- package/dist/restorer/impls/claude-mcp-prediction/index.js +239 -0
- package/dist/restorer/impls/claude-mcp-prediction/index.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.d.ts +38 -0
- package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.js +135 -0
- package/dist/restorer/impls/claude-mcp-prediction/mcp-tools.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-prediction/prompt.d.ts +8 -0
- package/dist/restorer/impls/claude-mcp-prediction/prompt.js +54 -0
- package/dist/restorer/impls/claude-mcp-prediction/prompt.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.d.ts +36 -0
- package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.js +137 -0
- package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-prediction/types.d.ts +84 -0
- package/dist/restorer/impls/claude-mcp-prediction/types.js +6 -0
- package/dist/restorer/impls/claude-mcp-prediction/types.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-prediction-apy/index.d.ts +34 -0
- package/dist/restorer/impls/claude-mcp-prediction-apy/index.js +233 -0
- package/dist/restorer/impls/claude-mcp-prediction-apy/index.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-prediction-apy/mcp-tools.d.ts +18 -0
- package/dist/restorer/impls/claude-mcp-prediction-apy/mcp-tools.js +136 -0
- package/dist/restorer/impls/claude-mcp-prediction-apy/mcp-tools.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-prediction-apy/prompt.d.ts +7 -0
- package/dist/restorer/impls/claude-mcp-prediction-apy/prompt.js +46 -0
- package/dist/restorer/impls/claude-mcp-prediction-apy/prompt.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-prediction-apy/session-orchestrator.d.ts +27 -0
- package/dist/restorer/impls/claude-mcp-prediction-apy/session-orchestrator.js +128 -0
- package/dist/restorer/impls/claude-mcp-prediction-apy/session-orchestrator.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-prediction-apy/types.d.ts +64 -0
- package/dist/restorer/impls/claude-mcp-prediction-apy/types.js +6 -0
- package/dist/restorer/impls/claude-mcp-prediction-apy/types.js.map +1 -0
- package/dist/restorer/impls/evaluation-context.d.ts +16 -0
- package/dist/restorer/impls/evaluation-context.js +18 -0
- package/dist/restorer/impls/evaluation-context.js.map +1 -0
- package/dist/restorer/impls/index.d.ts +46 -0
- package/dist/restorer/impls/index.js +88 -0
- package/dist/restorer/impls/index.js.map +1 -0
- package/dist/restorer/impls/legacy-claude/index.d.ts +52 -0
- package/dist/restorer/impls/legacy-claude/index.js +140 -0
- package/dist/restorer/impls/legacy-claude/index.js.map +1 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.d.ts +68 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.js +117 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/canonical-metrics.js.map +1 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.d.ts +49 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.js +91 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/availability.js.map +1 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.d.ts +78 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.js +274 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/consistency.js.map +1 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.d.ts +23 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.js +49 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/eligibility.js.map +1 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.d.ts +25 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.js +44 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/integrity.js.map +1 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.d.ts +17 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.js +43 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/checks/spec.js.map +1 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/index.d.ts +44 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/index.js +440 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/index.js.map +1 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/score.d.ts +21 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/score.js +32 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/score.js.map +1 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/types.d.ts +34 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/types.js +8 -0
- package/dist/restorer/impls/portfolio-v0-evaluator/types.js.map +1 -0
- package/dist/restorer/impls/prediction-apy-v0-baseline/index.d.ts +40 -0
- package/dist/restorer/impls/prediction-apy-v0-baseline/index.js +107 -0
- package/dist/restorer/impls/prediction-apy-v0-baseline/index.js.map +1 -0
- package/dist/restorer/impls/prediction-apy-v0-baseline/strategy.d.ts +2 -0
- package/dist/restorer/impls/prediction-apy-v0-baseline/strategy.js +7 -0
- package/dist/restorer/impls/prediction-apy-v0-baseline/strategy.js.map +1 -0
- package/dist/restorer/impls/prediction-apy-v0-baseline/types.d.ts +4 -0
- package/dist/restorer/impls/prediction-apy-v0-baseline/types.js +2 -0
- package/dist/restorer/impls/prediction-apy-v0-baseline/types.js.map +1 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.d.ts +6 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.js +11 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/canonical-metrics.js.map +1 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/index.d.ts +42 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js +208 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js.map +1 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/parse-submission.d.ts +7 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/parse-submission.js +29 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/parse-submission.js.map +1 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/score.d.ts +9 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/score.js +20 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/score.js.map +1 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/types.d.ts +7 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/types.js +2 -0
- package/dist/restorer/impls/prediction-apy-v0-evaluator/types.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-baseline/index.d.ts +31 -0
- package/dist/restorer/impls/prediction-v0-baseline/index.js +100 -0
- package/dist/restorer/impls/prediction-v0-baseline/index.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-baseline/strategy.d.ts +8 -0
- package/dist/restorer/impls/prediction-v0-baseline/strategy.js +41 -0
- package/dist/restorer/impls/prediction-v0-baseline/strategy.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-baseline/types.d.ts +7 -0
- package/dist/restorer/impls/prediction-v0-baseline/types.js +2 -0
- package/dist/restorer/impls/prediction-v0-baseline/types.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.d.ts +20 -0
- package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.js +66 -0
- package/dist/restorer/impls/prediction-v0-evaluator/canonical-metrics.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.d.ts +9 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.js +23 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/availability.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.d.ts +3 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.js +13 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/eligibility.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.d.ts +13 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.js +111 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.d.ts +5 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.js +20 -0
- package/dist/restorer/impls/prediction-v0-evaluator/checks/spec.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-evaluator/index.d.ts +36 -0
- package/dist/restorer/impls/prediction-v0-evaluator/index.js +234 -0
- package/dist/restorer/impls/prediction-v0-evaluator/index.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-evaluator/score.d.ts +8 -0
- package/dist/restorer/impls/prediction-v0-evaluator/score.js +15 -0
- package/dist/restorer/impls/prediction-v0-evaluator/score.js.map +1 -0
- package/dist/restorer/impls/prediction-v0-evaluator/types.d.ts +7 -0
- package/dist/restorer/impls/prediction-v0-evaluator/types.js +2 -0
- package/dist/restorer/impls/prediction-v0-evaluator/types.js.map +1 -0
- package/dist/restorer/types.d.ts +194 -0
- package/dist/restorer/types.js +28 -0
- package/dist/restorer/types.js.map +1 -0
- package/dist/rpc-error-context.d.ts +10 -0
- package/dist/rpc-error-context.js +26 -0
- package/dist/rpc-error-context.js.map +1 -0
- package/dist/store/store.d.ts +101 -1
- package/dist/store/store.js +334 -4
- package/dist/store/store.js.map +1 -1
- package/dist/trajectory/schema.d.ts +510 -0
- package/dist/trajectory/schema.js +74 -0
- package/dist/trajectory/schema.js.map +1 -0
- package/dist/types/desired-state.d.ts +53 -0
- package/dist/types/desired-state.js +20 -0
- package/dist/types/desired-state.js.map +1 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/types/index.js +4 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/portfolio.d.ts +1000 -0
- package/dist/types/portfolio.js +168 -0
- package/dist/types/portfolio.js.map +1 -0
- package/dist/types/prediction-apy.d.ts +930 -0
- package/dist/types/prediction-apy.js +133 -0
- package/dist/types/prediction-apy.js.map +1 -0
- package/dist/types/prediction.d.ts +926 -0
- package/dist/types/prediction.js +141 -0
- package/dist/types/prediction.js.map +1 -0
- package/dist/venues/aave-v3/addresses.d.ts +6 -0
- package/dist/venues/aave-v3/addresses.js +19 -0
- package/dist/venues/aave-v3/addresses.js.map +1 -0
- package/dist/venues/aave-v3/client.d.ts +85 -0
- package/dist/venues/aave-v3/client.js +106 -0
- package/dist/venues/aave-v3/client.js.map +1 -0
- package/dist/venues/chainlink/client.d.ts +99 -0
- package/dist/venues/chainlink/client.js +130 -0
- package/dist/venues/chainlink/client.js.map +1 -0
- package/dist/venues/chainlink/feeds.d.ts +8 -0
- package/dist/venues/chainlink/feeds.js +9 -0
- package/dist/venues/chainlink/feeds.js.map +1 -0
- package/dist/venues/hyperliquid/account-value.d.ts +30 -0
- package/dist/venues/hyperliquid/account-value.js +30 -0
- package/dist/venues/hyperliquid/account-value.js.map +1 -0
- package/dist/venues/hyperliquid/client.d.ts +63 -0
- package/dist/venues/hyperliquid/client.js +135 -0
- package/dist/venues/hyperliquid/client.js.map +1 -0
- package/dist/venues/hyperliquid/grid.d.ts +36 -0
- package/dist/venues/hyperliquid/grid.js +61 -0
- package/dist/venues/hyperliquid/grid.js.map +1 -0
- package/dist/venues/hyperliquid/types.d.ts +81 -0
- package/dist/venues/hyperliquid/types.js +8 -0
- package/dist/venues/hyperliquid/types.js.map +1 -0
- package/dist/withdraw/run-withdraw-plan.js +2 -0
- package/dist/withdraw/run-withdraw-plan.js.map +1 -1
- package/docker-compose.yml +44 -0
- package/package.json +15 -3
- package/skills/jinn-operator/SKILL.md +85 -0
- package/dist/daemon/restorer.d.ts +0 -19
- package/dist/daemon/restorer.js +0 -82
- package/dist/daemon/restorer.js.map +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Store } from '../store/store.js';
|
|
2
|
+
export type LifecycleKind = 'intent_posted' | 'intent_registry_failed' | 'envelope_registry_failed' | 'request_claimed' | 'delivery_submitted' | 'evaluation_submitted' | 'reward_claimed' | 'balance_topup' | 'engine_transition' | 'tick_error' | 'startup' | 'shutdown';
|
|
3
|
+
export interface LifecycleEvent {
|
|
4
|
+
kind: LifecycleKind;
|
|
5
|
+
requestId?: string;
|
|
6
|
+
serviceIndex?: number;
|
|
7
|
+
txHash?: string;
|
|
8
|
+
specKind?: string;
|
|
9
|
+
outcome?: 'ok' | 'failed' | 'warn';
|
|
10
|
+
detail?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function emitEvent(store: Store, event: LifecycleEvent, component?: string): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function emitEvent(store, event, component = 'lifecycle') {
|
|
2
|
+
const ts = new Date().toISOString();
|
|
3
|
+
store.recordActivityEvent({
|
|
4
|
+
ts,
|
|
5
|
+
kind: event.kind,
|
|
6
|
+
requestId: event.requestId ?? null,
|
|
7
|
+
serviceIndex: event.serviceIndex ?? null,
|
|
8
|
+
txHash: event.txHash ?? null,
|
|
9
|
+
specKind: event.specKind ?? null,
|
|
10
|
+
outcome: event.outcome ?? null,
|
|
11
|
+
detail: event.detail ?? null,
|
|
12
|
+
});
|
|
13
|
+
const payload = {
|
|
14
|
+
ts,
|
|
15
|
+
level: event.outcome === 'failed' ? 'error' : event.outcome === 'warn' ? 'warn' : 'info',
|
|
16
|
+
component,
|
|
17
|
+
msg: event.detail ?? event.kind,
|
|
18
|
+
requestId: event.requestId ?? null,
|
|
19
|
+
txHash: event.txHash ?? null,
|
|
20
|
+
serviceIndex: event.serviceIndex ?? null,
|
|
21
|
+
specKind: event.specKind ?? null,
|
|
22
|
+
outcome: event.outcome ?? 'ok',
|
|
23
|
+
kind: event.kind,
|
|
24
|
+
};
|
|
25
|
+
process.stderr.write(`${JSON.stringify(payload)}\n`);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=emit-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit-event.js","sourceRoot":"","sources":["../../src/observability/emit-event.ts"],"names":[],"mappings":"AA0BA,MAAM,UAAU,SAAS,CACvB,KAAY,EACZ,KAAqB,EACrB,SAAS,GAAG,WAAW;IAEvB,MAAM,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACpC,KAAK,CAAC,mBAAmB,CAAC;QACxB,EAAE;QACF,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,IAAI;QAClC,YAAY,EAAE,KAAK,CAAC,YAAY,IAAI,IAAI;QACxC,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,IAAI;QAC5B,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,IAAI;QAChC,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,IAAI;QAC9B,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,IAAI;KAC7B,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG;QACd,EAAE;QACF,KAAK,EAAE,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;QACxF,SAAS;QACT,GAAG,EAAE,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI;QAC/B,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,IAAI;QAClC,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,IAAI;QAC5B,YAAY,EAAE,KAAK,CAAC,YAAY,IAAI,IAAI;QACxC,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,IAAI;QAChC,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,IAAI;QAC9B,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC;IACF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface ApiPortPreflightOk {
|
|
2
|
+
ok: true;
|
|
3
|
+
port: number;
|
|
4
|
+
}
|
|
5
|
+
export interface ApiPortPreflightFail {
|
|
6
|
+
ok: false;
|
|
7
|
+
port: number;
|
|
8
|
+
code?: string;
|
|
9
|
+
message: string;
|
|
10
|
+
}
|
|
11
|
+
export type ApiPortPreflightResult = ApiPortPreflightOk | ApiPortPreflightFail;
|
|
12
|
+
export declare function checkApiPortAvailable(port: number): Promise<ApiPortPreflightResult>;
|
|
13
|
+
export declare function apiPortFailureMessage(result: ApiPortPreflightFail): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createServer } from 'node:net';
|
|
2
|
+
export async function checkApiPortAvailable(port) {
|
|
3
|
+
return new Promise((resolve) => {
|
|
4
|
+
const server = createServer();
|
|
5
|
+
let settled = false;
|
|
6
|
+
const finish = (result) => {
|
|
7
|
+
if (settled)
|
|
8
|
+
return;
|
|
9
|
+
settled = true;
|
|
10
|
+
server.removeAllListeners();
|
|
11
|
+
resolve(result);
|
|
12
|
+
};
|
|
13
|
+
server.once('error', (error) => {
|
|
14
|
+
finish({
|
|
15
|
+
ok: false,
|
|
16
|
+
port,
|
|
17
|
+
code: error.code,
|
|
18
|
+
message: error.message,
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
server.listen({ port, host: '0.0.0.0', exclusive: true }, () => {
|
|
22
|
+
server.close(() => finish({ ok: true, port }));
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export function apiPortFailureMessage(result) {
|
|
27
|
+
if (result.code === 'EADDRINUSE') {
|
|
28
|
+
return `Port ${result.port} is already in use. Stop the other daemon or set JINN_API_PORT / apiPort to another port.`;
|
|
29
|
+
}
|
|
30
|
+
return `Port ${result.port} is not available: ${result.message}`;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=api-port.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-port.js","sourceRoot":"","sources":["../../src/preflight/api-port.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAgBxC,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,IAAY;IACtD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;QAC9B,IAAI,OAAO,GAAG,KAAK,CAAC;QAEpB,MAAM,MAAM,GAAG,CAAC,MAA8B,EAAE,EAAE;YAChD,IAAI,OAAO;gBAAE,OAAO;YACpB,OAAO,GAAG,IAAI,CAAC;YACf,MAAM,CAAC,kBAAkB,EAAE,CAAC;YAC5B,OAAO,CAAC,MAAM,CAAC,CAAC;QAClB,CAAC,CAAC;QAEF,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAA4B,EAAE,EAAE;YACpD,MAAM,CAAC;gBACL,EAAE,EAAE,KAAK;gBACT,IAAI;gBACJ,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,OAAO,EAAE,KAAK,CAAC,OAAO;aACvB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE;YAC7D,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAA4B;IAChE,IAAI,MAAM,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QACjC,OAAO,QAAQ,MAAM,CAAC,IAAI,2FAA2F,CAAC;IACxH,CAAC;IACD,OAAO,QAAQ,MAAM,CAAC,IAAI,sBAAsB,MAAM,CAAC,OAAO,EAAE,CAAC;AACnE,CAAC"}
|
|
@@ -6,11 +6,22 @@
|
|
|
6
6
|
* - 'docker-compose' — a docker-compose.yml with a jinn-daemon service lives in cwd
|
|
7
7
|
* - 'bare' — plain host environment (default)
|
|
8
8
|
*
|
|
9
|
-
* Priority:
|
|
9
|
+
* Priority:
|
|
10
|
+
* 1. JINN_RUNTIME_MODE env var (authoritative; CI/scripted operators)
|
|
11
|
+
* 2. `runtimeMode` field in the resolved config (persisted by `jinn auth`)
|
|
12
|
+
* 3. Filesystem heuristic (container → docker-compose → bare) as a last resort
|
|
13
|
+
*
|
|
14
|
+
* The filesystem path is a LAST RESORT because running from the `client/`
|
|
15
|
+
* checkout dir misdetects as docker-compose (the package's own compose file
|
|
16
|
+
* names `jinn-daemon`). Operators should set `runtimeMode` at `jinn auth`.
|
|
10
17
|
*/
|
|
11
18
|
export type AuthContext = 'container' | 'docker-compose' | 'bare';
|
|
12
19
|
export interface DetectContextOptions {
|
|
13
20
|
cwd: string;
|
|
21
|
+
/** Optional explicit mode, typically from `config.runtimeMode`. Highest priority. */
|
|
22
|
+
configuredMode?: AuthContext;
|
|
23
|
+
/** Optional env (default: process.env). Tests can inject a stub. */
|
|
24
|
+
env?: NodeJS.ProcessEnv;
|
|
14
25
|
/** Override the /.dockerenv existence check (for testing). */
|
|
15
26
|
dockerenvExists?: boolean;
|
|
16
27
|
/** Override the docker-compose.yml jinn-daemon check (for testing). */
|
|
@@ -6,7 +6,14 @@
|
|
|
6
6
|
* - 'docker-compose' — a docker-compose.yml with a jinn-daemon service lives in cwd
|
|
7
7
|
* - 'bare' — plain host environment (default)
|
|
8
8
|
*
|
|
9
|
-
* Priority:
|
|
9
|
+
* Priority:
|
|
10
|
+
* 1. JINN_RUNTIME_MODE env var (authoritative; CI/scripted operators)
|
|
11
|
+
* 2. `runtimeMode` field in the resolved config (persisted by `jinn auth`)
|
|
12
|
+
* 3. Filesystem heuristic (container → docker-compose → bare) as a last resort
|
|
13
|
+
*
|
|
14
|
+
* The filesystem path is a LAST RESORT because running from the `client/`
|
|
15
|
+
* checkout dir misdetects as docker-compose (the package's own compose file
|
|
16
|
+
* names `jinn-daemon`). Operators should set `runtimeMode` at `jinn auth`.
|
|
10
17
|
*/
|
|
11
18
|
import { existsSync, readFileSync } from 'node:fs';
|
|
12
19
|
import { spawnSync } from 'node:child_process';
|
|
@@ -21,13 +28,24 @@ import { join } from 'node:path';
|
|
|
21
28
|
*/
|
|
22
29
|
export function detectAuthContext(opts) {
|
|
23
30
|
const { cwd } = opts;
|
|
24
|
-
|
|
31
|
+
const env = opts.env ?? process.env;
|
|
32
|
+
// 1. JINN_RUNTIME_MODE env var (CI / scripted operators).
|
|
33
|
+
const envMode = env['JINN_RUNTIME_MODE'];
|
|
34
|
+
if (envMode === 'bare' || envMode === 'docker-compose' || envMode === 'container') {
|
|
35
|
+
return envMode;
|
|
36
|
+
}
|
|
37
|
+
// 2. Explicit config (persisted by `jinn auth`).
|
|
38
|
+
if (opts.configuredMode) {
|
|
39
|
+
return opts.configuredMode;
|
|
40
|
+
}
|
|
41
|
+
// 3. Filesystem heuristic — last resort. Flawed inside the client/ checkout dir
|
|
42
|
+
// because the package's own docker-compose.yml names jinn-daemon. Prefer
|
|
43
|
+
// setting runtimeMode explicitly.
|
|
25
44
|
const inContainer = opts.dockerenvExists !== undefined
|
|
26
45
|
? opts.dockerenvExists
|
|
27
46
|
: existsSync('/.dockerenv');
|
|
28
47
|
if (inContainer)
|
|
29
48
|
return 'container';
|
|
30
|
-
// Resolve compose service — injected override or parse the file.
|
|
31
49
|
const hasComposeService = opts.composeServiceExists !== undefined
|
|
32
50
|
? opts.composeServiceExists
|
|
33
51
|
: _composeHasJinnDaemon(cwd);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-auth.js","sourceRoot":"","sources":["../../src/preflight/claude-auth.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"claude-auth.js","sourceRoot":"","sources":["../../src/preflight/claude-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AA6CjC,8EAA8E;AAC9E,oBAAoB;AACpB,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAA0B;IAC1D,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IACrB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IAEpC,0DAA0D;IAC1D,MAAM,OAAO,GAAG,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACzC,IAAI,OAAO,KAAK,MAAM,IAAI,OAAO,KAAK,gBAAgB,IAAI,OAAO,KAAK,WAAW,EAAE,CAAC;QAClF,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,iDAAiD;IACjD,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,gFAAgF;IAChF,yEAAyE;IACzE,kCAAkC;IAClC,MAAM,WAAW,GACf,IAAI,CAAC,eAAe,KAAK,SAAS;QAChC,CAAC,CAAC,IAAI,CAAC,eAAe;QACtB,CAAC,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAEhC,IAAI,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L,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,EAAE;QAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,EAAE;KAC5B,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,oBAAoB;AACpB,8EAA8E;AAE9E;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAoB,EACpB,GAAW;IAEX,IAAI,OAAO,KAAK,gBAAgB,EAAE,CAAC;QACjC,OAAO;YACL,OAAO,EAAE,QAAQ;YACjB,IAAI,EAAE;gBACJ,SAAS;gBACT,IAAI;gBACJ,IAAI,CAAC,GAAG,EAAE,oBAAoB,CAAC;gBAC/B,KAAK;gBACL,MAAM;gBACN,KAAK;gBACL,WAAW;gBACX,cAAc;gBACd,QAAQ;gBACR,aAAa;gBACb,MAAM;gBACN,OAAO;aACR;SACF,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { JinnConfig } from '../config.js';
|
|
2
|
+
export type ExpectedRpcNetwork = 'mainnet' | 'testnet';
|
|
3
|
+
export interface RpcNetworkPreflightOk {
|
|
4
|
+
ok: true;
|
|
5
|
+
network: ExpectedRpcNetwork;
|
|
6
|
+
expectedChainId: number;
|
|
7
|
+
actualChainId: number;
|
|
8
|
+
rpcHost: string;
|
|
9
|
+
/**
|
|
10
|
+
* True when the RPC reports an Anvil/Hardhat default chain id that does not
|
|
11
|
+
* match the configured network, but the endpoint is on loopback — we only
|
|
12
|
+
* allow this for local dev to avoid misreading a remote 313/1337 as healthy.
|
|
13
|
+
*/
|
|
14
|
+
localDev?: true;
|
|
15
|
+
}
|
|
16
|
+
export interface RpcNetworkPreflightFail {
|
|
17
|
+
ok: false;
|
|
18
|
+
network: ExpectedRpcNetwork;
|
|
19
|
+
expectedChainId: number;
|
|
20
|
+
actualChainId?: number;
|
|
21
|
+
rpcHost: string;
|
|
22
|
+
reason: 'chain_mismatch' | 'unreachable';
|
|
23
|
+
message: string;
|
|
24
|
+
}
|
|
25
|
+
export type RpcNetworkPreflightResult = RpcNetworkPreflightOk | RpcNetworkPreflightFail;
|
|
26
|
+
export declare function expectedChainIdForNetwork(network: ExpectedRpcNetwork): number;
|
|
27
|
+
/**
|
|
28
|
+
* True when the RPC host is a loopback address. Remote endpoints that return
|
|
29
|
+
* Anvil/Hardhat chain ids are still treated as a mismatch.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isLoopbackRpcUrl(rpcUrl: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Used by tests: whether checkRpcNetwork would take the Anvil/Hardhat override path.
|
|
34
|
+
* Not used by production code beyond the equivalent inline check in {@link checkRpcNetwork}.
|
|
35
|
+
*/
|
|
36
|
+
export declare function evmLocalDevOverrideAcceptable(expectedChainId: number, actualChainId: number, rpcUrl: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* When {@link checkRpcNetwork} returns ok with `localDev: true`, log a single stderr line
|
|
39
|
+
* (also surfaced in `jinn doctor` detail) so run/bootstrap are not silent about the mismatch.
|
|
40
|
+
*/
|
|
41
|
+
export declare function logRpcLocalDevToStderr(r: RpcNetworkPreflightOk, write?: (m: string) => void): void;
|
|
42
|
+
export declare function rpcHostForDisplay(rpcUrl: string): string;
|
|
43
|
+
export declare function checkRpcNetwork(config: Pick<JinnConfig, 'network' | 'rpcUrl'>): Promise<RpcNetworkPreflightResult>;
|
|
44
|
+
export declare function rpcNetworkFailureHint(result: RpcNetworkPreflightFail): string;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { createPublicClient, http } from 'viem';
|
|
2
|
+
import { base, baseSepolia } from 'viem/chains';
|
|
3
|
+
export function expectedChainIdForNetwork(network) {
|
|
4
|
+
return network === 'testnet' ? 84532 : 8453;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Anvil / Hardhat default chain IDs. Fork workflows point `rpcUrl` at a local
|
|
8
|
+
* node without reconfiguring the chain; `eth_chainId` then reports these
|
|
9
|
+
* values instead of Base (8453 / 84532). We treat them as valid for preflight
|
|
10
|
+
* only for loopback RPCs so a misconfigured public URL cannot silently pass.
|
|
11
|
+
*/
|
|
12
|
+
const LOCAL_EVM_DEV_CHAIN_IDS = new Set([31337, 1337]);
|
|
13
|
+
/**
|
|
14
|
+
* True when the RPC host is a loopback address. Remote endpoints that return
|
|
15
|
+
* Anvil/Hardhat chain ids are still treated as a mismatch.
|
|
16
|
+
*/
|
|
17
|
+
export function isLoopbackRpcUrl(rpcUrl) {
|
|
18
|
+
try {
|
|
19
|
+
const h = new URL(rpcUrl).hostname;
|
|
20
|
+
return h === '127.0.0.1' || h === 'localhost' || h === '::1' || h === '[::1]';
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Used by tests: whether checkRpcNetwork would take the Anvil/Hardhat override path.
|
|
28
|
+
* Not used by production code beyond the equivalent inline check in {@link checkRpcNetwork}.
|
|
29
|
+
*/
|
|
30
|
+
export function evmLocalDevOverrideAcceptable(expectedChainId, actualChainId, rpcUrl) {
|
|
31
|
+
return (actualChainId !== expectedChainId &&
|
|
32
|
+
LOCAL_EVM_DEV_CHAIN_IDS.has(actualChainId) &&
|
|
33
|
+
isLoopbackRpcUrl(rpcUrl));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* When {@link checkRpcNetwork} returns ok with `localDev: true`, log a single stderr line
|
|
37
|
+
* (also surfaced in `jinn doctor` detail) so run/bootstrap are not silent about the mismatch.
|
|
38
|
+
*/
|
|
39
|
+
export function logRpcLocalDevToStderr(r, write = (m) => {
|
|
40
|
+
process.stderr.write(m.endsWith('\n') ? m : `${m}\n`);
|
|
41
|
+
}) {
|
|
42
|
+
if (!r.localDev)
|
|
43
|
+
return;
|
|
44
|
+
write(`[jinn] Local dev: ${r.rpcHost} has chainId ${r.actualChainId} (config expects Base ${r.network} id ` +
|
|
45
|
+
`${r.expectedChainId} from a live or forked-with-matching-id RPC). Continuing.\n`);
|
|
46
|
+
}
|
|
47
|
+
export function rpcHostForDisplay(rpcUrl) {
|
|
48
|
+
try {
|
|
49
|
+
const parsed = new URL(rpcUrl);
|
|
50
|
+
return parsed.host || parsed.hostname || '(unknown host)';
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return '(invalid rpc url)';
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function expectedChainForNetwork(network) {
|
|
57
|
+
return network === 'testnet' ? baseSepolia : base;
|
|
58
|
+
}
|
|
59
|
+
function errorMessage(error) {
|
|
60
|
+
if (error instanceof Error && error.message.trim())
|
|
61
|
+
return error.message;
|
|
62
|
+
return String(error);
|
|
63
|
+
}
|
|
64
|
+
export async function checkRpcNetwork(config) {
|
|
65
|
+
const expectedChainId = expectedChainIdForNetwork(config.network);
|
|
66
|
+
const rpcHost = rpcHostForDisplay(config.rpcUrl);
|
|
67
|
+
const client = createPublicClient({
|
|
68
|
+
chain: expectedChainForNetwork(config.network),
|
|
69
|
+
transport: http(config.rpcUrl),
|
|
70
|
+
});
|
|
71
|
+
let actualChainId;
|
|
72
|
+
try {
|
|
73
|
+
actualChainId = await client.getChainId();
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
return {
|
|
77
|
+
ok: false,
|
|
78
|
+
network: config.network,
|
|
79
|
+
expectedChainId,
|
|
80
|
+
rpcHost,
|
|
81
|
+
reason: 'unreachable',
|
|
82
|
+
message: `RPC preflight failed for ${config.network} via ${rpcHost}: ${errorMessage(error)}`,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
if (actualChainId !== expectedChainId) {
|
|
86
|
+
if (evmLocalDevOverrideAcceptable(expectedChainId, actualChainId, config.rpcUrl)) {
|
|
87
|
+
return {
|
|
88
|
+
ok: true,
|
|
89
|
+
network: config.network,
|
|
90
|
+
expectedChainId,
|
|
91
|
+
actualChainId,
|
|
92
|
+
rpcHost,
|
|
93
|
+
localDev: true,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
ok: false,
|
|
98
|
+
network: config.network,
|
|
99
|
+
expectedChainId,
|
|
100
|
+
actualChainId,
|
|
101
|
+
rpcHost,
|
|
102
|
+
reason: 'chain_mismatch',
|
|
103
|
+
message: `RPC chain mismatch for ${config.network}: expected chain ${expectedChainId}, ` +
|
|
104
|
+
`got ${actualChainId} from ${rpcHost}.`,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
ok: true,
|
|
109
|
+
network: config.network,
|
|
110
|
+
expectedChainId,
|
|
111
|
+
actualChainId,
|
|
112
|
+
rpcHost,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export function rpcNetworkFailureHint(result) {
|
|
116
|
+
if (result.network === 'testnet') {
|
|
117
|
+
return 'Set rpcUrl to a Base Sepolia endpoint such as https://sepolia.base.org, or set BASE_SEPOLIA_RPC_URL.';
|
|
118
|
+
}
|
|
119
|
+
return 'Set rpcUrl to a Base mainnet endpoint such as https://mainnet.base.org, or set BASE_RPC_URL.';
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=rpc-network.js.map
|
|
@@ -0,0 +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;AAChD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AA+BhD,MAAM,UAAU,yBAAyB,CAAC,OAA2B;IACnE,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9C,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AAe,EAAE,CAAC;QACtC,IAAI,6BAA6B,CAAC,eAAe,EAAE,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YACjF,OAAO;gBACL,EAAE,EAAE,IAAI;gBACR,OAAO,EAAE,MAAM,CAAC,OAAO;gBACvB,eAAe;gBACf,aAAa;gBACb,OAAO;gBACP,QAAQ,EAAE,IAAI;aACf,CAAC;QACJ,CAAC;QACD,OAAO;YACL,EAAE,EAAE,KAAK;YACT,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,eAAe;YACf,aAAa;YACb,OAAO;YACP,MAAM,EAAE,gBAAgB;YACxB,OAAO,EACL,0BAA0B,MAAM,CAAC,OAAO,oBAAoB,eAAe,IAAI;gBAC/E,OAAO,aAAa,SAAS,OAAO,GAAG;SAC1C,CAAC;IACJ,CAAC;IAED,OAAO;QACL,EAAE,EAAE,IAAI;QACR,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,eAAe;QACf,aAAa;QACb,OAAO;KACR,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAA+B;IACnE,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QACjC,OAAO,sGAAsG,CAAC;IAChH,CAAC;IACD,OAAO,8FAA8F,CAAC;AACxG,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical JSON serialisation — sorted keys, no whitespace.
|
|
3
|
+
*
|
|
4
|
+
* Used for manifest signing: produce a deterministic byte string that two
|
|
5
|
+
* independent parties can reproduce from the same object graph.
|
|
6
|
+
*
|
|
7
|
+
* Rules:
|
|
8
|
+
* - Object keys are sorted lexicographically (UTF-16 code-unit order, same as
|
|
9
|
+
* Array.prototype.sort() on strings — matches JSON.stringify key insertion
|
|
10
|
+
* order when we control insertion).
|
|
11
|
+
* - Arrays preserve element order.
|
|
12
|
+
* - Numbers: JS default toString (no special formatting).
|
|
13
|
+
* - null, boolean, string: standard JSON encoding.
|
|
14
|
+
* - undefined values in objects are dropped (same as JSON.stringify).
|
|
15
|
+
* - NaN and Infinity are not valid JSON; this function will produce "null" for
|
|
16
|
+
* those values, matching JSON.stringify behaviour.
|
|
17
|
+
*/
|
|
18
|
+
export declare function canonicalJson(value: unknown): string;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical JSON serialisation — sorted keys, no whitespace.
|
|
3
|
+
*
|
|
4
|
+
* Used for manifest signing: produce a deterministic byte string that two
|
|
5
|
+
* independent parties can reproduce from the same object graph.
|
|
6
|
+
*
|
|
7
|
+
* Rules:
|
|
8
|
+
* - Object keys are sorted lexicographically (UTF-16 code-unit order, same as
|
|
9
|
+
* Array.prototype.sort() on strings — matches JSON.stringify key insertion
|
|
10
|
+
* order when we control insertion).
|
|
11
|
+
* - Arrays preserve element order.
|
|
12
|
+
* - Numbers: JS default toString (no special formatting).
|
|
13
|
+
* - null, boolean, string: standard JSON encoding.
|
|
14
|
+
* - undefined values in objects are dropped (same as JSON.stringify).
|
|
15
|
+
* - NaN and Infinity are not valid JSON; this function will produce "null" for
|
|
16
|
+
* those values, matching JSON.stringify behaviour.
|
|
17
|
+
*/
|
|
18
|
+
export function canonicalJson(value) {
|
|
19
|
+
if (value === null)
|
|
20
|
+
return 'null';
|
|
21
|
+
if (value === undefined)
|
|
22
|
+
return 'null';
|
|
23
|
+
if (typeof value === 'boolean')
|
|
24
|
+
return value ? 'true' : 'false';
|
|
25
|
+
if (typeof value === 'number') {
|
|
26
|
+
// NaN / Infinity → null, matching JSON.stringify
|
|
27
|
+
if (!isFinite(value))
|
|
28
|
+
return 'null';
|
|
29
|
+
return String(value);
|
|
30
|
+
}
|
|
31
|
+
if (typeof value === 'string')
|
|
32
|
+
return JSON.stringify(value);
|
|
33
|
+
if (Array.isArray(value)) {
|
|
34
|
+
const items = value.map((v) => canonicalJson(v)).join(',');
|
|
35
|
+
return `[${items}]`;
|
|
36
|
+
}
|
|
37
|
+
if (typeof value === 'object') {
|
|
38
|
+
const obj = value;
|
|
39
|
+
const pairs = Object.keys(obj)
|
|
40
|
+
.sort()
|
|
41
|
+
.flatMap((key) => {
|
|
42
|
+
const v = obj[key];
|
|
43
|
+
if (v === undefined)
|
|
44
|
+
return []; // drop undefined (matches JSON.stringify)
|
|
45
|
+
return [`${JSON.stringify(key)}:${canonicalJson(v)}`];
|
|
46
|
+
});
|
|
47
|
+
return `{${pairs.join(',')}}`;
|
|
48
|
+
}
|
|
49
|
+
// Bigint: emit raw decimal digits WITHOUT quotes, matching RFC 8785 and other
|
|
50
|
+
// canonical-JSON libs. JSON.stringify would throw; converting through String()
|
|
51
|
+
// would produce a quoted "12345" instead of the unquoted integer 12345.
|
|
52
|
+
// We do NOT convert through Number() because bigints can exceed JS number precision.
|
|
53
|
+
if (typeof value === 'bigint')
|
|
54
|
+
return value.toString();
|
|
55
|
+
// Fallback: other exotic types — JSON.stringify would throw;
|
|
56
|
+
// we convert to string to avoid hard failures.
|
|
57
|
+
return JSON.stringify(String(value));
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=canonical-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonical-json.js","sourceRoot":"","sources":["../../../src/restorer/engine/canonical-json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAClC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IACvC,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;IAChE,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,iDAAiD;QACjD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,OAAO,MAAM,CAAC;QACpC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/**
|
|
2
|
+
* Two-layer claim orchestration for the restorer engine.
|
|
3
|
+
*
|
|
4
|
+
* §6.1, §9.1, §9.2 of spec/2026-04-17-portfolio-v0-design.md
|
|
5
|
+
*
|
|
6
|
+
* Layer 1: ClaimRegistry claim — Jinn's work-coordination contract.
|
|
7
|
+
* Layer 2: Marketplace priority claim — calls MechAdapter.claimRequest() to
|
|
8
|
+
* register the priority-mech exclusivity window (300 s responseTimeout).
|
|
9
|
+
*
|
|
10
|
+
* The ClaimRegistry claimTTL is owner-configured per-deployment and is not
|
|
11
|
+
* passed by the client.
|
|
12
|
+
*
|
|
13
|
+
* Recovery:
|
|
14
|
+
* On resume, ClaimRegistryClient.weAlreadyClaimed() is checked before any
|
|
15
|
+
* on-chain write. If we already hold the claim, the ClaimRegistry step is
|
|
16
|
+
* skipped entirely. The marketplace claim is re-attempted because it is
|
|
17
|
+
* stateless from the engine's perspective (MechAdapter is idempotent there).
|
|
18
|
+
*
|
|
19
|
+
* Failure modes:
|
|
20
|
+
* - ClaimRegistry claim fails → throw, no marketplace call, engine marks FAILED.
|
|
21
|
+
* - Marketplace claim fails → release ClaimRegistry claim, throw.
|
|
22
|
+
*/
|
|
23
|
+
import type { ClaimRegistryClient } from '../../adapters/claim-registry/client.js';
|
|
24
|
+
/**
|
|
25
|
+
* Minimal interface for the marketplace adapter's claim path.
|
|
26
|
+
* The full MechAdapter satisfies this; tests can inject a stub.
|
|
27
|
+
*/
|
|
28
|
+
export interface MarketplaceClaimer {
|
|
29
|
+
claimRequest(requestId: string): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Parameters describing a single intent's timing window.
|
|
33
|
+
* Extracted from PersistedIntent for testability (no DB dependency).
|
|
34
|
+
*/
|
|
35
|
+
export interface ClaimWindow {
|
|
36
|
+
requestId: string;
|
|
37
|
+
/** Window start timestamp in ms (epoch). Used for graceful release decision. */
|
|
38
|
+
windowStartTs: number;
|
|
39
|
+
}
|
|
40
|
+
/** Result of a successful two-layer claim. */
|
|
41
|
+
export interface ClaimResult {
|
|
42
|
+
/** True if the ClaimRegistry claim was freshly placed (false = pre-existing). */
|
|
43
|
+
registryClaimWasFresh: boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Execute the two-layer claim for a single intent.
|
|
47
|
+
*
|
|
48
|
+
* // Claim ordering: ClaimRegistry FIRST (cheap coordination lock), marketplace SECOND.
|
|
49
|
+
* // Spec §6.1 lists them in opposite order but doesn't enforce sequencing — registry-first
|
|
50
|
+
* // is preferred because: (a) ClaimRegistry revert is fast and signals "another restorer
|
|
51
|
+
* // is on it" cleanly; (b) marketplace claim is more expensive (Safe tx + actual gas);
|
|
52
|
+
* // (c) we release ClaimRegistry on marketplace failure to avoid leaking a stale claim.
|
|
53
|
+
*
|
|
54
|
+
* @param claimWindow - Timing data for the intent (requestId, windowStartTs).
|
|
55
|
+
* @param registryClient - ClaimRegistryClient for the deployed ClaimRegistry contract.
|
|
56
|
+
* @param marketplaceClaimer - Adapter whose claimRequest() performs the marketplace claim.
|
|
57
|
+
* @returns ClaimResult on success.
|
|
58
|
+
* @throws If either layer cannot be claimed (after graceful cleanup).
|
|
59
|
+
*/
|
|
60
|
+
export declare function executeTwoLayerClaim(claimWindow: ClaimWindow, registryClient: ClaimRegistryClient, marketplaceClaimer: MarketplaceClaimer): Promise<ClaimResult>;
|
|
61
|
+
/**
|
|
62
|
+
* Release the ClaimRegistry claim for an intent that was CLAIMED but whose
|
|
63
|
+
* work window has not yet started (windowStartTs not reached).
|
|
64
|
+
*
|
|
65
|
+
* Used during graceful engine shutdown. No-op if we don't hold the claim.
|
|
66
|
+
*
|
|
67
|
+
* @returns true if the claim was released, false if there was nothing to release.
|
|
68
|
+
*/
|
|
69
|
+
export declare function releaseClaimedNotStarted(claimWindow: ClaimWindow, registryClient: ClaimRegistryClient): Promise<boolean>;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Two-layer claim orchestration for the restorer engine.
|
|
3
|
+
*
|
|
4
|
+
* §6.1, §9.1, §9.2 of spec/2026-04-17-portfolio-v0-design.md
|
|
5
|
+
*
|
|
6
|
+
* Layer 1: ClaimRegistry claim — Jinn's work-coordination contract.
|
|
7
|
+
* Layer 2: Marketplace priority claim — calls MechAdapter.claimRequest() to
|
|
8
|
+
* register the priority-mech exclusivity window (300 s responseTimeout).
|
|
9
|
+
*
|
|
10
|
+
* The ClaimRegistry claimTTL is owner-configured per-deployment and is not
|
|
11
|
+
* passed by the client.
|
|
12
|
+
*
|
|
13
|
+
* Recovery:
|
|
14
|
+
* On resume, ClaimRegistryClient.weAlreadyClaimed() is checked before any
|
|
15
|
+
* on-chain write. If we already hold the claim, the ClaimRegistry step is
|
|
16
|
+
* skipped entirely. The marketplace claim is re-attempted because it is
|
|
17
|
+
* stateless from the engine's perspective (MechAdapter is idempotent there).
|
|
18
|
+
*
|
|
19
|
+
* Failure modes:
|
|
20
|
+
* - ClaimRegistry claim fails → throw, no marketplace call, engine marks FAILED.
|
|
21
|
+
* - Marketplace claim fails → release ClaimRegistry claim, throw.
|
|
22
|
+
*/
|
|
23
|
+
// ── Two-layer claim ───────────────────────────────────────────────────────────
|
|
24
|
+
/**
|
|
25
|
+
* Execute the two-layer claim for a single intent.
|
|
26
|
+
*
|
|
27
|
+
* // Claim ordering: ClaimRegistry FIRST (cheap coordination lock), marketplace SECOND.
|
|
28
|
+
* // Spec §6.1 lists them in opposite order but doesn't enforce sequencing — registry-first
|
|
29
|
+
* // is preferred because: (a) ClaimRegistry revert is fast and signals "another restorer
|
|
30
|
+
* // is on it" cleanly; (b) marketplace claim is more expensive (Safe tx + actual gas);
|
|
31
|
+
* // (c) we release ClaimRegistry on marketplace failure to avoid leaking a stale claim.
|
|
32
|
+
*
|
|
33
|
+
* @param claimWindow - Timing data for the intent (requestId, windowStartTs).
|
|
34
|
+
* @param registryClient - ClaimRegistryClient for the deployed ClaimRegistry contract.
|
|
35
|
+
* @param marketplaceClaimer - Adapter whose claimRequest() performs the marketplace claim.
|
|
36
|
+
* @returns ClaimResult on success.
|
|
37
|
+
* @throws If either layer cannot be claimed (after graceful cleanup).
|
|
38
|
+
*/
|
|
39
|
+
export async function executeTwoLayerClaim(claimWindow, registryClient, marketplaceClaimer) {
|
|
40
|
+
const requestIdHex = claimWindow.requestId;
|
|
41
|
+
// ── Layer 1: ClaimRegistry ────────────────────────────────────────────────
|
|
42
|
+
// Idempotency check: if we already hold the claim, skip the on-chain write.
|
|
43
|
+
const alreadyClaimed = await registryClient.weAlreadyClaimed(requestIdHex);
|
|
44
|
+
let registryClaimWasFresh = false;
|
|
45
|
+
if (!alreadyClaimed) {
|
|
46
|
+
const result = await registryClient.claimJob(requestIdHex);
|
|
47
|
+
if (!result.claimed) {
|
|
48
|
+
throw new Error(`[claim-orchestration] ClaimRegistry claim failed for ${claimWindow.requestId} — another operator may hold the claim`);
|
|
49
|
+
}
|
|
50
|
+
registryClaimWasFresh = true;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
console.log(`[claim-orchestration] ClaimRegistry: pre-existing claim found for ${claimWindow.requestId}, skipping re-claim`);
|
|
54
|
+
}
|
|
55
|
+
// ── Layer 2: Marketplace ──────────────────────────────────────────────────
|
|
56
|
+
try {
|
|
57
|
+
await marketplaceClaimer.claimRequest(claimWindow.requestId);
|
|
58
|
+
}
|
|
59
|
+
catch (marketplaceErr) {
|
|
60
|
+
// Marketplace claim failed — release the ClaimRegistry claim we just placed
|
|
61
|
+
// (only if we placed it fresh; pre-existing claims are not ours to release here)
|
|
62
|
+
// TODO(v0 trade-off): on the resume path (weAlreadyClaimed = true, registryClaimWasFresh = false)
|
|
63
|
+
// we do NOT release the ClaimRegistry claim here. Releasing on a transient marketplace failure
|
|
64
|
+
// would forfeit our coordination lock and let a competing restorer take it. The downside is that
|
|
65
|
+
// on a *persistent* failure the claim sits locked until TTL expiry (owner-configured per-deployment).
|
|
66
|
+
// Distinguishing transient vs. permanent failures is non-trivial; for v0 we accept the TTL wait.
|
|
67
|
+
// Future: inspect the marketplace error type and release only on permanent failures.
|
|
68
|
+
if (registryClaimWasFresh) {
|
|
69
|
+
try {
|
|
70
|
+
await registryClient.releaseClaim(requestIdHex);
|
|
71
|
+
console.log(`[claim-orchestration] released ClaimRegistry claim for ${claimWindow.requestId} after marketplace failure`);
|
|
72
|
+
}
|
|
73
|
+
catch (releaseErr) {
|
|
74
|
+
const releaseMsg = releaseErr instanceof Error ? releaseErr.message : String(releaseErr);
|
|
75
|
+
console.error(`[claim-orchestration] failed to release ClaimRegistry claim for ${claimWindow.requestId} after marketplace failure: ${releaseMsg}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
throw marketplaceErr;
|
|
79
|
+
}
|
|
80
|
+
return { registryClaimWasFresh };
|
|
81
|
+
}
|
|
82
|
+
// ── Graceful release ──────────────────────────────────────────────────────────
|
|
83
|
+
/**
|
|
84
|
+
* Release the ClaimRegistry claim for an intent that was CLAIMED but whose
|
|
85
|
+
* work window has not yet started (windowStartTs not reached).
|
|
86
|
+
*
|
|
87
|
+
* Used during graceful engine shutdown. No-op if we don't hold the claim.
|
|
88
|
+
*
|
|
89
|
+
* @returns true if the claim was released, false if there was nothing to release.
|
|
90
|
+
*/
|
|
91
|
+
export async function releaseClaimedNotStarted(claimWindow, registryClient) {
|
|
92
|
+
const requestIdHex = claimWindow.requestId;
|
|
93
|
+
// Only release if the work window hasn't started yet
|
|
94
|
+
if (Date.now() >= claimWindow.windowStartTs) {
|
|
95
|
+
console.log(`[claim-orchestration] NOT releasing claim for ${claimWindow.requestId} — window already started`);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
const released = await registryClient.releaseClaim(requestIdHex);
|
|
99
|
+
if (released) {
|
|
100
|
+
console.log(`[claim-orchestration] released ClaimRegistry claim for ${claimWindow.requestId} (graceful shutdown, before window start)`);
|
|
101
|
+
}
|
|
102
|
+
return released;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=cla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