@jinn-network/client 0.1.2 → 0.1.3-canary.262e5cda
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 +20 -0
- package/CONTRIBUTING.md +8 -2
- package/README.md +38 -14
- package/deployments/deployment-jinn-mvi-l1-sepolia-fast.json +36 -0
- package/deployments/deployment-jinn-mvi-l1-sepolia.json +36 -0
- package/deployments/deployment-jinn-mvi-l2-baseSepolia.json +12 -0
- package/deployments/deployment-phase1b-mech-baseSepolia-fast.json +3 -3
- package/deployments/deployment-stolas-l2-baseSepolia-fast.json +1 -1
- package/dist/adapters/adapter.d.ts +2 -2
- package/dist/adapters/claim-registry/client.d.ts +9 -0
- package/dist/adapters/claim-registry/client.js +22 -2
- package/dist/adapters/claim-registry/client.js.map +1 -1
- package/dist/adapters/local/adapter.d.ts +2 -2
- package/dist/adapters/local/adapter.js +8 -8
- package/dist/adapters/local/adapter.js.map +1 -1
- package/dist/adapters/mech/adapter.d.ts +3 -4
- package/dist/adapters/mech/adapter.js +86 -50
- package/dist/adapters/mech/adapter.js.map +1 -1
- package/dist/adapters/mech/contracts.d.ts +6 -4
- package/dist/adapters/mech/contracts.js +118 -14
- package/dist/adapters/mech/contracts.js.map +1 -1
- package/dist/adapters/mech/ipfs.d.ts +61 -6
- package/dist/adapters/mech/ipfs.js +159 -26
- package/dist/adapters/mech/ipfs.js.map +1 -1
- package/dist/adapters/mech/safe-revert.d.ts +39 -0
- package/dist/adapters/mech/safe-revert.js +130 -0
- package/dist/adapters/mech/safe-revert.js.map +1 -0
- package/dist/adapters/mech/safe.js +47 -21
- package/dist/adapters/mech/safe.js.map +1 -1
- package/dist/adapters/mech/types.d.ts +8 -0
- package/dist/adapters/mech/types.js.map +1 -1
- package/dist/agent/agent-ws.d.ts +55 -0
- package/dist/agent/agent-ws.js +288 -0
- package/dist/agent/agent-ws.js.map +1 -0
- package/dist/agent/auto-mode-detect.d.ts +6 -0
- package/dist/agent/auto-mode-detect.js +44 -0
- package/dist/agent/auto-mode-detect.js.map +1 -0
- package/dist/agent/operator-claude.d.ts +22 -0
- package/dist/agent/operator-claude.js +130 -0
- package/dist/agent/operator-claude.js.map +1 -0
- package/dist/api/admin-endpoint.d.ts +12 -0
- package/dist/api/admin-endpoint.js +71 -0
- package/dist/api/admin-endpoint.js.map +1 -0
- package/dist/api/bootstrap-endpoint.d.ts +16 -0
- package/dist/api/bootstrap-endpoint.js +78 -0
- package/dist/api/bootstrap-endpoint.js.map +1 -0
- package/dist/api/events-endpoint.d.ts +9 -0
- package/dist/api/events-endpoint.js +46 -0
- package/dist/api/events-endpoint.js.map +1 -0
- package/dist/api/fleet-build.d.ts +1 -1
- package/dist/api/fleet-build.js +17 -8
- package/dist/api/fleet-build.js.map +1 -1
- package/dist/api/gather-status.js +5 -1
- package/dist/api/gather-status.js.map +1 -1
- package/dist/api/handshake.d.ts +17 -0
- package/dist/api/handshake.js +28 -0
- package/dist/api/handshake.js.map +1 -0
- package/dist/api/peers.js +20 -5
- package/dist/api/peers.js.map +1 -1
- package/dist/api/portfolio-v0-build.d.ts +6 -0
- package/dist/api/portfolio-v0-build.js +6 -1
- package/dist/api/portfolio-v0-build.js.map +1 -1
- package/dist/api/rewards-build.js +3 -8
- package/dist/api/rewards-build.js.map +1 -1
- package/dist/api/server.d.ts +54 -0
- package/dist/api/server.js +239 -13
- package/dist/api/server.js.map +1 -1
- package/dist/api/setup-endpoints.d.ts +34 -0
- package/dist/api/setup-endpoints.js +188 -0
- package/dist/api/setup-endpoints.js.map +1 -0
- package/dist/api/status-build.d.ts +9 -1
- package/dist/api/status-build.js +44 -9
- package/dist/api/status-build.js.map +1 -1
- package/dist/api/status-rollup-build.d.ts +46 -1
- package/dist/api/status-rollup-build.js +168 -5
- package/dist/api/status-rollup-build.js.map +1 -1
- package/dist/api/ui-token.d.ts +5 -0
- package/dist/api/ui-token.js +36 -0
- package/dist/api/ui-token.js.map +1 -0
- package/dist/build-info.d.ts +32 -0
- package/dist/build-info.js +69 -0
- package/dist/build-info.js.map +1 -0
- package/dist/build-info.json +6 -0
- package/dist/build-meta.json +1 -1
- package/dist/cli/command.d.ts +9 -0
- package/dist/cli/commands/balance.d.ts +7 -0
- package/dist/cli/commands/balance.js +38 -32
- package/dist/cli/commands/balance.js.map +1 -1
- package/dist/cli/commands/bootstrap.d.ts +13 -1
- package/dist/cli/commands/bootstrap.js +150 -132
- package/dist/cli/commands/bootstrap.js.map +1 -1
- package/dist/cli/commands/claim-rewards.js +14 -2
- package/dist/cli/commands/claim-rewards.js.map +1 -1
- package/dist/cli/commands/conformance.d.ts +12 -0
- package/dist/cli/commands/conformance.js +140 -0
- package/dist/cli/commands/conformance.js.map +1 -0
- package/dist/cli/commands/create.d.ts +36 -0
- package/dist/cli/commands/create.js +374 -0
- package/dist/cli/commands/create.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +34 -1
- package/dist/cli/commands/doctor.js +136 -121
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/fleet-scale.d.ts +19 -1
- package/dist/cli/commands/fleet-scale.js +379 -361
- package/dist/cli/commands/fleet-scale.js.map +1 -1
- package/dist/cli/commands/fleet.d.ts +7 -0
- package/dist/cli/commands/fleet.js +39 -33
- package/dist/cli/commands/fleet.js.map +1 -1
- package/dist/cli/commands/fund-requirements.d.ts +14 -1
- package/dist/cli/commands/fund-requirements.js +183 -174
- package/dist/cli/commands/fund-requirements.js.map +1 -1
- package/dist/cli/commands/history.d.ts +10 -1
- package/dist/cli/commands/history.js +66 -57
- package/dist/cli/commands/history.js.map +1 -1
- package/dist/cli/commands/impls.d.ts +18 -0
- package/dist/cli/commands/impls.js +208 -0
- package/dist/cli/commands/impls.js.map +1 -0
- package/dist/cli/commands/init.js +4 -1
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/intents.js +13 -9
- package/dist/cli/commands/intents.js.map +1 -1
- package/dist/cli/commands/logs.d.ts +6 -1
- package/dist/cli/commands/logs.js +77 -70
- package/dist/cli/commands/logs.js.map +1 -1
- package/dist/cli/commands/migrate-agent-id.d.ts +26 -0
- package/dist/cli/commands/migrate-agent-id.js +165 -0
- package/dist/cli/commands/migrate-agent-id.js.map +1 -0
- package/dist/cli/commands/plug-ins.d.ts +34 -0
- package/dist/cli/commands/plug-ins.js +282 -0
- package/dist/cli/commands/plug-ins.js.map +1 -0
- package/dist/cli/commands/plugin-install.d.ts +10 -0
- package/dist/cli/commands/plugin-install.js +226 -14
- package/dist/cli/commands/plugin-install.js.map +1 -1
- package/dist/cli/commands/rewards.d.ts +7 -0
- package/dist/cli/commands/rewards.js +46 -40
- package/dist/cli/commands/rewards.js.map +1 -1
- package/dist/cli/commands/run.d.ts +14 -1
- package/dist/cli/commands/run.js +232 -90
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/status.d.ts +10 -0
- package/dist/cli/commands/status.js +97 -34
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/submit-intent.js +33 -6
- package/dist/cli/commands/submit-intent.js.map +1 -1
- package/dist/cli/commands/ui.js +45 -0
- package/dist/cli/commands/ui.js.map +1 -0
- package/dist/cli/commands/update.d.ts +5 -0
- package/dist/cli/commands/update.js +102 -97
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/commands/version.js +3 -1
- package/dist/cli/commands/version.js.map +1 -1
- package/dist/cli/commands/withdraw.d.ts +21 -1
- package/dist/cli/commands/withdraw.js +175 -159
- package/dist/cli/commands/withdraw.js.map +1 -1
- package/dist/cli/execution-context.d.ts +1 -1
- package/dist/cli/execution-context.js +2 -1
- package/dist/cli/execution-context.js.map +1 -1
- package/dist/cli/help.js +7 -0
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.js +18 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/intent-registry-access.d.ts +33 -1
- package/dist/cli/intent-registry-access.js +40 -2
- package/dist/cli/intent-registry-access.js.map +1 -1
- package/dist/cli/open-browser.d.ts +1 -0
- package/dist/cli/open-browser.js +18 -0
- package/dist/cli/open-browser.js.map +1 -0
- package/dist/cli/password.d.ts +3 -3
- package/dist/cli/password.js +5 -5
- package/dist/cli/password.js.map +1 -1
- package/dist/config.d.ts +883 -11
- package/dist/config.js +435 -4
- package/dist/config.js.map +1 -1
- package/dist/conformance/checks/artifacts.d.ts +37 -0
- package/dist/conformance/checks/artifacts.js +110 -0
- package/dist/conformance/checks/artifacts.js.map +1 -0
- package/dist/conformance/checks/envelope-schema.d.ts +17 -0
- package/dist/conformance/checks/envelope-schema.js +36 -0
- package/dist/conformance/checks/envelope-schema.js.map +1 -0
- package/dist/conformance/checks/hash-signature.d.ts +26 -0
- package/dist/conformance/checks/hash-signature.js +70 -0
- package/dist/conformance/checks/hash-signature.js.map +1 -0
- package/dist/conformance/checks/payload.d.ts +19 -0
- package/dist/conformance/checks/payload.js +52 -0
- package/dist/conformance/checks/payload.js.map +1 -0
- package/dist/conformance/checks/secret-scrub.d.ts +33 -0
- package/dist/conformance/checks/secret-scrub.js +118 -0
- package/dist/conformance/checks/secret-scrub.js.map +1 -0
- package/dist/conformance/checks/source-runtime.d.ts +43 -0
- package/dist/conformance/checks/source-runtime.js +68 -0
- package/dist/conformance/checks/source-runtime.js.map +1 -0
- package/dist/conformance/checks/source-static.d.ts +61 -0
- package/dist/conformance/checks/source-static.js +311 -0
- package/dist/conformance/checks/source-static.js.map +1 -0
- package/dist/conformance/checks/trajectory-chain.d.ts +18 -0
- package/dist/conformance/checks/trajectory-chain.js +51 -0
- package/dist/conformance/checks/trajectory-chain.js.map +1 -0
- package/dist/conformance/checks/trajectory-profile.d.ts +17 -0
- package/dist/conformance/checks/trajectory-profile.js +51 -0
- package/dist/conformance/checks/trajectory-profile.js.map +1 -0
- package/dist/conformance/checks/trajectory-schema.d.ts +20 -0
- package/dist/conformance/checks/trajectory-schema.js +40 -0
- package/dist/conformance/checks/trajectory-schema.js.map +1 -0
- package/dist/conformance/checks/verdict.d.ts +44 -0
- package/dist/conformance/checks/verdict.js +122 -0
- package/dist/conformance/checks/verdict.js.map +1 -0
- package/dist/conformance/harness.d.ts +32 -0
- package/dist/conformance/harness.js +228 -0
- package/dist/conformance/harness.js.map +1 -0
- package/dist/conformance/types.d.ts +88 -0
- package/dist/conformance/types.js +31 -0
- package/dist/conformance/types.js.map +1 -0
- package/dist/corpus/acquire.d.ts +37 -0
- package/dist/corpus/acquire.js +155 -0
- package/dist/corpus/acquire.js.map +1 -0
- package/dist/corpus/cache.d.ts +14 -0
- package/dist/corpus/cache.js +18 -0
- package/dist/corpus/cache.js.map +1 -0
- package/dist/corpus/fetch.d.ts +9 -0
- package/dist/corpus/fetch.js +24 -0
- package/dist/corpus/fetch.js.map +1 -0
- package/dist/corpus/index.d.ts +16 -0
- package/dist/corpus/index.js +78 -0
- package/dist/corpus/index.js.map +1 -0
- package/dist/corpus/query.d.ts +17 -0
- package/dist/corpus/query.js +108 -0
- package/dist/corpus/query.js.map +1 -0
- package/dist/corpus/route-resolver.d.ts +16 -0
- package/dist/corpus/route-resolver.js +20 -0
- package/dist/corpus/route-resolver.js.map +1 -0
- package/dist/corpus/types.d.ts +107 -0
- package/dist/corpus/types.js +50 -0
- package/dist/corpus/types.js.map +1 -0
- package/dist/daemon/balance-topup-loop.js +2 -1
- package/dist/daemon/balance-topup-loop.js.map +1 -1
- package/dist/daemon/creator.d.ts +2 -2
- package/dist/daemon/creator.js +2 -2
- package/dist/daemon/creator.js.map +1 -1
- package/dist/daemon/daemon.d.ts +70 -15
- package/dist/daemon/daemon.js +159 -41
- package/dist/daemon/daemon.js.map +1 -1
- package/dist/daemon/delivery-watcher.js +31 -1
- package/dist/daemon/delivery-watcher.js.map +1 -1
- package/dist/daemon/jinn-claim-loop-canonical.d.ts +207 -0
- package/dist/daemon/jinn-claim-loop-canonical.js +296 -0
- package/dist/daemon/jinn-claim-loop-canonical.js.map +1 -0
- package/dist/daemon/jinn-claim-loop-mock.d.ts +61 -0
- package/dist/daemon/jinn-claim-loop-mock.js +122 -0
- package/dist/daemon/jinn-claim-loop-mock.js.map +1 -0
- package/dist/daemon/jinn-claim-loop.d.ts +123 -0
- package/dist/daemon/jinn-claim-loop.js +256 -0
- package/dist/daemon/jinn-claim-loop.js.map +1 -0
- package/dist/daemon/reward-claim-loop.d.ts +2 -0
- package/dist/daemon/reward-claim-loop.js +32 -27
- package/dist/daemon/reward-claim-loop.js.map +1 -1
- package/dist/dashboard/assets/index-Bxlk5qpa.js +68 -0
- package/dist/dashboard/assets/index-DQ3u_vP5.css +32 -0
- package/dist/dashboard/index.html +18 -74
- package/dist/earning/agent-wallet-binding.d.ts +133 -0
- package/dist/earning/agent-wallet-binding.js +202 -0
- package/dist/earning/agent-wallet-binding.js.map +1 -0
- package/dist/earning/bootstrap.d.ts +64 -0
- package/dist/earning/bootstrap.js +325 -32
- package/dist/earning/bootstrap.js.map +1 -1
- package/dist/earning/contracts.d.ts +323 -0
- package/dist/earning/contracts.js +276 -0
- package/dist/earning/contracts.js.map +1 -1
- package/dist/earning/funding-plan.d.ts +90 -0
- package/dist/earning/funding-plan.js +203 -0
- package/dist/earning/funding-plan.js.map +1 -0
- package/dist/earning/migrate-agent-id.d.ts +130 -0
- package/dist/earning/migrate-agent-id.js +257 -0
- package/dist/earning/migrate-agent-id.js.map +1 -0
- package/dist/earning/orphan-sweep.d.ts +14 -0
- package/dist/earning/orphan-sweep.js +63 -2
- package/dist/earning/orphan-sweep.js.map +1 -1
- package/dist/earning/reconcile.d.ts +2 -0
- package/dist/earning/reconcile.js +30 -0
- package/dist/earning/reconcile.js.map +1 -1
- package/dist/earning/stolas-claim.d.ts +86 -6
- package/dist/earning/stolas-claim.js +123 -9
- package/dist/earning/stolas-claim.js.map +1 -1
- package/dist/earning/store.d.ts +39 -0
- package/dist/earning/store.js +72 -1
- package/dist/earning/store.js.map +1 -1
- package/dist/earning/testnet-setup-migration.d.ts +32 -0
- package/dist/earning/testnet-setup-migration.js +214 -0
- package/dist/earning/testnet-setup-migration.js.map +1 -0
- package/dist/earning/types.d.ts +53 -9
- package/dist/earning/types.js +51 -2
- package/dist/earning/types.js.map +1 -1
- package/dist/earning/viem-clients.d.ts +20 -0
- package/dist/earning/viem-clients.js +32 -1
- package/dist/earning/viem-clients.js.map +1 -1
- package/dist/erc8004/abis.d.ts +381 -0
- package/dist/erc8004/abis.js +238 -0
- package/dist/erc8004/abis.js.map +1 -0
- package/dist/erc8004/addresses.d.ts +40 -0
- package/dist/erc8004/addresses.js +64 -0
- package/dist/erc8004/addresses.js.map +1 -0
- package/dist/erc8004/identity.d.ts +202 -0
- package/dist/erc8004/identity.js +305 -0
- package/dist/erc8004/identity.js.map +1 -0
- package/dist/erc8004/index.d.ts +13 -0
- package/dist/erc8004/index.js +20 -0
- package/dist/erc8004/index.js.map +1 -0
- package/dist/erc8004/reputation.d.ts +349 -0
- package/dist/erc8004/reputation.js +464 -0
- package/dist/erc8004/reputation.js.map +1 -0
- package/dist/erc8004/subgraph.d.ts +46 -0
- package/dist/erc8004/subgraph.js +37 -0
- package/dist/erc8004/subgraph.js.map +1 -0
- package/dist/erc8004/validation.d.ts +145 -0
- package/dist/erc8004/validation.js +219 -0
- package/dist/erc8004/validation.js.map +1 -0
- package/dist/errors/persisted-bootstrap-error.d.ts +4 -0
- package/dist/errors/persisted-bootstrap-error.js +50 -0
- package/dist/errors/persisted-bootstrap-error.js.map +1 -0
- package/dist/events/emitter.d.ts +12 -0
- package/dist/events/emitter.js +23 -0
- package/dist/events/emitter.js.map +1 -0
- package/dist/events/ring-buffer.d.ts +25 -0
- package/dist/events/ring-buffer.js +46 -0
- package/dist/events/ring-buffer.js.map +1 -0
- package/dist/events/types.d.ts +42 -0
- package/dist/events/types.js +28 -0
- package/dist/events/types.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/intents/kinds/index.d.ts +10 -0
- package/dist/intents/kinds/index.js +7 -0
- package/dist/intents/kinds/index.js.map +1 -1
- package/dist/intents/kinds/learner-loop-test.d.ts +2 -0
- package/dist/intents/kinds/learner-loop-test.js +39 -0
- package/dist/intents/kinds/learner-loop-test.js.map +1 -0
- package/dist/intents/kinds/prediction-apy-v0.js +5 -1
- package/dist/intents/kinds/prediction-apy-v0.js.map +1 -1
- package/dist/intents/kinds/prediction-v0.js +5 -0
- package/dist/intents/kinds/prediction-v0.js.map +1 -1
- package/dist/intents/kinds/spec-kind.d.ts +18 -1
- package/dist/intents/posting-service.d.ts +3 -5
- package/dist/intents/posting-service.js +16 -50
- package/dist/intents/posting-service.js.map +1 -1
- package/dist/intents/prediction-apy-v0-auto.d.ts +12 -2
- package/dist/intents/prediction-apy-v0-auto.js +27 -2
- package/dist/intents/prediction-apy-v0-auto.js.map +1 -1
- package/dist/intents/prediction-v0-auto.d.ts +14 -4
- package/dist/intents/prediction-v0-auto.js +29 -5
- package/dist/intents/prediction-v0-auto.js.map +1 -1
- package/dist/intents/signing.d.ts +13 -0
- package/dist/intents/signing.js +27 -0
- package/dist/intents/signing.js.map +1 -0
- package/dist/intents/sources.d.ts +12 -5
- package/dist/intents/sources.js +11 -11
- package/dist/intents/sources.js.map +1 -1
- package/dist/main.d.ts +5 -2
- package/dist/main.js +792 -66
- package/dist/main.js.map +1 -1
- package/dist/mcp/acquire-artifact.d.ts +39 -0
- package/dist/mcp/acquire-artifact.js +163 -0
- package/dist/mcp/acquire-artifact.js.map +1 -0
- package/dist/mcp/operator-server.d.ts +20 -3
- package/dist/mcp/operator-server.js +500 -25
- package/dist/mcp/operator-server.js.map +1 -1
- package/dist/mcp/search-artifacts.d.ts +31 -0
- package/dist/mcp/search-artifacts.js +40 -0
- package/dist/mcp/search-artifacts.js.map +1 -0
- package/dist/mcp/server.js +103 -58
- package/dist/mcp/server.js.map +1 -1
- package/dist/observability/emit-event.d.ts +1 -1
- package/dist/observability/emit-event.js.map +1 -1
- package/dist/operator-errors.js +4 -5
- package/dist/operator-errors.js.map +1 -1
- package/dist/preflight/claude-auth.d.ts +11 -11
- package/dist/preflight/claude-auth.js +18 -32
- package/dist/preflight/claude-auth.js.map +1 -1
- package/dist/restorer/capability/index.d.ts +82 -0
- package/dist/restorer/capability/index.js +12 -0
- package/dist/restorer/capability/index.js.map +1 -0
- package/dist/restorer/capability/scoped-rpc.d.ts +12 -0
- package/dist/restorer/capability/scoped-rpc.js +34 -0
- package/dist/restorer/capability/scoped-rpc.js.map +1 -0
- package/dist/restorer/capability/scoped-secrets.d.ts +8 -0
- package/dist/restorer/capability/scoped-secrets.js +10 -0
- package/dist/restorer/capability/scoped-secrets.js.map +1 -0
- package/dist/restorer/capability/scoped-signer.d.ts +46 -0
- package/dist/restorer/capability/scoped-signer.js +73 -0
- package/dist/restorer/capability/scoped-signer.js.map +1 -0
- package/dist/restorer/engine/canonical-json.d.ts +0 -17
- package/dist/restorer/engine/canonical-json.js +56 -49
- package/dist/restorer/engine/canonical-json.js.map +1 -1
- package/dist/restorer/engine/claim.js +8 -1
- package/dist/restorer/engine/claim.js.map +1 -1
- package/dist/restorer/engine/delivery.d.ts +2 -0
- package/dist/restorer/engine/delivery.js +2 -2
- package/dist/restorer/engine/delivery.js.map +1 -1
- package/dist/restorer/engine/engine.d.ts +143 -26
- package/dist/restorer/engine/engine.js +485 -104
- package/dist/restorer/engine/engine.js.map +1 -1
- package/dist/restorer/engine/envelope-assembly.d.ts +65 -0
- package/dist/restorer/engine/envelope-assembly.js +60 -0
- package/dist/restorer/engine/envelope-assembly.js.map +1 -0
- package/dist/restorer/engine/packaging.d.ts +30 -30
- package/dist/restorer/engine/packaging.js +73 -47
- package/dist/restorer/engine/packaging.js.map +1 -1
- package/dist/restorer/engine/persistence.d.ts +7 -7
- package/dist/restorer/engine/persistence.js +4 -4
- package/dist/restorer/engine/persistence.js.map +1 -1
- package/dist/restorer/engine/registry.d.ts +24 -13
- package/dist/restorer/engine/registry.js +16 -13
- package/dist/restorer/engine/registry.js.map +1 -1
- package/dist/restorer/engine/validate-manifest.d.ts +23 -0
- package/dist/restorer/engine/validate-manifest.js +49 -0
- package/dist/restorer/engine/validate-manifest.js.map +1 -0
- package/dist/restorer/engine/verification-stub.d.ts +18 -0
- package/dist/restorer/engine/verification-stub.js +18 -0
- package/dist/restorer/engine/verification-stub.js.map +1 -0
- package/dist/restorer/external-impls/index.d.ts +3 -0
- package/dist/restorer/external-impls/index.js +2 -0
- package/dist/restorer/external-impls/index.js.map +1 -0
- package/dist/restorer/external-impls/loader.d.ts +49 -0
- package/dist/restorer/external-impls/loader.js +138 -0
- package/dist/restorer/external-impls/loader.js.map +1 -0
- package/dist/restorer/external-impls/package-hash.d.ts +26 -0
- package/dist/restorer/external-impls/package-hash.js +102 -0
- package/dist/restorer/external-impls/package-hash.js.map +1 -0
- package/dist/restorer/external-impls/types.d.ts +42 -0
- package/dist/restorer/external-impls/types.js +10 -0
- package/dist/restorer/external-impls/types.js.map +1 -0
- package/dist/restorer/impls/claude-code-learner/adapters/claude-code.d.ts +38 -0
- package/dist/restorer/impls/claude-code-learner/adapters/claude-code.js +200 -0
- package/dist/restorer/impls/claude-code-learner/adapters/claude-code.js.map +1 -0
- package/dist/restorer/impls/claude-code-learner/harvest.d.ts +19 -0
- package/dist/restorer/impls/claude-code-learner/harvest.js +146 -0
- package/dist/restorer/impls/claude-code-learner/harvest.js.map +1 -0
- package/dist/restorer/impls/claude-code-learner/index.d.ts +15 -0
- package/dist/restorer/impls/claude-code-learner/index.js +14 -0
- package/dist/restorer/impls/claude-code-learner/index.js.map +1 -0
- package/dist/restorer/impls/claude-code-learner/mcp-config.d.ts +48 -0
- package/dist/restorer/impls/claude-code-learner/mcp-config.js +52 -0
- package/dist/restorer/impls/claude-code-learner/mcp-config.js.map +1 -0
- package/dist/restorer/impls/claude-code-learner/plugin-path.d.ts +14 -0
- package/dist/restorer/impls/claude-code-learner/plugin-path.js +30 -0
- package/dist/restorer/impls/claude-code-learner/plugin-path.js.map +1 -0
- package/dist/restorer/impls/claude-code-learner/restorer.d.ts +38 -0
- package/dist/restorer/impls/claude-code-learner/restorer.js +73 -0
- package/dist/restorer/impls/claude-code-learner/restorer.js.map +1 -0
- package/dist/restorer/impls/claude-code-learner/test-utils/fake-plugin-outputs.d.ts +19 -0
- package/dist/restorer/impls/claude-code-learner/test-utils/fake-plugin-outputs.js +111 -0
- package/dist/restorer/impls/claude-code-learner/test-utils/fake-plugin-outputs.js.map +1 -0
- package/dist/restorer/impls/claude-code-learner/test-utils/noop-adapter.d.ts +22 -0
- package/dist/restorer/impls/claude-code-learner/test-utils/noop-adapter.js +35 -0
- package/dist/restorer/impls/claude-code-learner/test-utils/noop-adapter.js.map +1 -0
- package/dist/restorer/impls/claude-code-learner/test-utils/synthetic-session.d.ts +20 -0
- package/dist/restorer/impls/claude-code-learner/test-utils/synthetic-session.js +34 -0
- package/dist/restorer/impls/claude-code-learner/test-utils/synthetic-session.js.map +1 -0
- package/dist/restorer/impls/claude-code-learner/types.d.ts +99 -0
- package/dist/restorer/impls/claude-code-learner/types.js +2 -0
- package/dist/restorer/impls/claude-code-learner/types.js.map +1 -0
- package/dist/restorer/impls/claude-code-learner/wrapper.d.ts +49 -0
- package/dist/restorer/impls/claude-code-learner/wrapper.js +144 -0
- package/dist/restorer/impls/claude-code-learner/wrapper.js.map +1 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/index.d.ts +2 -2
- package/dist/restorer/impls/claude-mcp-hyperliquid/index.js +2 -2
- package/dist/restorer/impls/claude-mcp-hyperliquid/index.js.map +1 -1
- package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.d.ts +7 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.js +38 -0
- package/dist/restorer/impls/claude-mcp-hyperliquid/session-orchestrator.js.map +1 -1
- package/dist/restorer/impls/claude-mcp-prediction/index.d.ts +2 -2
- package/dist/restorer/impls/claude-mcp-prediction/index.js +12 -2
- package/dist/restorer/impls/claude-mcp-prediction/index.js.map +1 -1
- package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.d.ts +9 -2
- package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.js +9 -125
- package/dist/restorer/impls/claude-mcp-prediction/session-orchestrator.js.map +1 -1
- package/dist/restorer/impls/claude-mcp-prediction-apy/index.d.ts +2 -2
- package/dist/restorer/impls/claude-mcp-prediction-apy/index.js +9 -2
- package/dist/restorer/impls/claude-mcp-prediction-apy/index.js.map +1 -1
- package/dist/restorer/impls/claude-mcp-prediction-apy/session-orchestrator.d.ts +10 -0
- package/dist/restorer/impls/claude-mcp-prediction-apy/session-orchestrator.js +10 -119
- package/dist/restorer/impls/claude-mcp-prediction-apy/session-orchestrator.js.map +1 -1
- package/dist/restorer/impls/claude-mcp-shared/single-session-orchestrator.d.ts +84 -0
- package/dist/restorer/impls/claude-mcp-shared/single-session-orchestrator.js +206 -0
- package/dist/restorer/impls/claude-mcp-shared/single-session-orchestrator.js.map +1 -0
- package/dist/restorer/impls/evaluation-context.d.ts +11 -4
- package/dist/restorer/impls/evaluation-context.js +9 -2
- package/dist/restorer/impls/evaluation-context.js.map +1 -1
- package/dist/restorer/impls/index.d.ts +46 -1
- package/dist/restorer/impls/index.js +38 -0
- package/dist/restorer/impls/index.js.map +1 -1
- package/dist/restorer/impls/legacy-claude/index.d.ts +13 -1
- package/dist/restorer/impls/legacy-claude/index.js +2 -0
- package/dist/restorer/impls/legacy-claude/index.js.map +1 -1
- package/dist/restorer/impls/portfolio-v0-evaluator/index.d.ts +4 -4
- package/dist/restorer/impls/portfolio-v0-evaluator/index.js +184 -55
- package/dist/restorer/impls/portfolio-v0-evaluator/index.js.map +1 -1
- package/dist/restorer/impls/prediction-apy-v0-baseline/index.d.ts +1 -1
- package/dist/restorer/impls/prediction-apy-v0-baseline/index.js +8 -1
- package/dist/restorer/impls/prediction-apy-v0-baseline/index.js.map +1 -1
- package/dist/restorer/impls/prediction-apy-v0-evaluator/index.d.ts +3 -3
- package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js +153 -15
- package/dist/restorer/impls/prediction-apy-v0-evaluator/index.js.map +1 -1
- package/dist/restorer/impls/prediction-apy-v0-evaluator/parse-submission.d.ts +14 -5
- package/dist/restorer/impls/prediction-apy-v0-evaluator/parse-submission.js +16 -23
- package/dist/restorer/impls/prediction-apy-v0-evaluator/parse-submission.js.map +1 -1
- package/dist/restorer/impls/prediction-v0-baseline/index.d.ts +1 -1
- package/dist/restorer/impls/prediction-v0-baseline/index.js +16 -7
- package/dist/restorer/impls/prediction-v0-baseline/index.js.map +1 -1
- package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.d.ts +5 -3
- package/dist/restorer/impls/prediction-v0-evaluator/checks/integrity.js.map +1 -1
- package/dist/restorer/impls/prediction-v0-evaluator/index.d.ts +2 -2
- package/dist/restorer/impls/prediction-v0-evaluator/index.js +175 -67
- package/dist/restorer/impls/prediction-v0-evaluator/index.js.map +1 -1
- package/dist/restorer/manifest/index.d.ts +3 -0
- package/dist/restorer/manifest/index.js +3 -0
- package/dist/restorer/manifest/index.js.map +1 -0
- package/dist/restorer/manifest/load.d.ts +7 -0
- package/dist/restorer/manifest/load.js +49 -0
- package/dist/restorer/manifest/load.js.map +1 -0
- package/dist/restorer/manifest/types.d.ts +75 -0
- package/dist/restorer/manifest/types.js +8 -0
- package/dist/restorer/manifest/types.js.map +1 -0
- package/dist/restorer/manifest/verify.d.ts +15 -0
- package/dist/restorer/manifest/verify.js +53 -0
- package/dist/restorer/manifest/verify.js.map +1 -0
- package/dist/restorer/plug-ins/index.d.ts +14 -0
- package/dist/restorer/plug-ins/index.js +11 -0
- package/dist/restorer/plug-ins/index.js.map +1 -0
- package/dist/restorer/plug-ins/loader.d.ts +27 -0
- package/dist/restorer/plug-ins/loader.js +101 -0
- package/dist/restorer/plug-ins/loader.js.map +1 -0
- package/dist/restorer/plug-ins/manifest.d.ts +7 -0
- package/dist/restorer/plug-ins/manifest.js +97 -0
- package/dist/restorer/plug-ins/manifest.js.map +1 -0
- package/dist/restorer/plug-ins/registry.d.ts +24 -0
- package/dist/restorer/plug-ins/registry.js +17 -0
- package/dist/restorer/plug-ins/registry.js.map +1 -0
- package/dist/restorer/plug-ins/serialise.d.ts +29 -0
- package/dist/restorer/plug-ins/serialise.js +29 -0
- package/dist/restorer/plug-ins/serialise.js.map +1 -0
- package/dist/restorer/plug-ins/types.d.ts +77 -0
- package/dist/restorer/plug-ins/types.js +10 -0
- package/dist/restorer/plug-ins/types.js.map +1 -0
- package/dist/restorer/types.d.ts +66 -11
- package/dist/restorer/types.js.map +1 -1
- package/dist/runner/claude.d.ts +3 -3
- package/dist/runner/claude.js +57 -21
- package/dist/runner/claude.js.map +1 -1
- package/dist/runner/runner.d.ts +29 -2
- package/dist/runner/simple.d.ts +2 -2
- package/dist/runner/simple.js +2 -2
- package/dist/runner/simple.js.map +1 -1
- package/dist/scripts/fix-node-pty.mjs +62 -0
- package/dist/setup-mode.d.ts +34 -0
- package/dist/setup-mode.js +49 -0
- package/dist/setup-mode.js.map +1 -0
- package/dist/store/store.d.ts +79 -3
- package/dist/store/store.js +189 -6
- package/dist/store/store.js.map +1 -1
- package/dist/templates/plug-in/hook/README.md.tmpl +24 -0
- package/dist/templates/plug-in/hook/gitignore.tmpl +3 -0
- package/dist/templates/plug-in/hook/hooks/event.sh.tmpl +15 -0
- package/dist/templates/plug-in/hook/jinn-plugin.json.tmpl +16 -0
- package/dist/templates/plug-in/hook/package.json.tmpl +14 -0
- package/dist/templates/plug-in/hook/test/manifest.test.ts.tmpl +21 -0
- package/dist/templates/plug-in/mcp-tool/README.md.tmpl +26 -0
- package/dist/templates/plug-in/mcp-tool/gitignore.tmpl +4 -0
- package/dist/templates/plug-in/mcp-tool/jinn-plugin.json.tmpl +16 -0
- package/dist/templates/plug-in/mcp-tool/package.json.tmpl +19 -0
- package/dist/templates/plug-in/mcp-tool/src/server.ts.tmpl +17 -0
- package/dist/templates/plug-in/mcp-tool/test/server.test.ts.tmpl +18 -0
- package/dist/templates/plug-in/memory-backend/README.md.tmpl +33 -0
- package/dist/templates/plug-in/memory-backend/gitignore.tmpl +4 -0
- package/dist/templates/plug-in/memory-backend/jinn-plugin.json.tmpl +16 -0
- package/dist/templates/plug-in/memory-backend/package.json.tmpl +19 -0
- package/dist/templates/plug-in/memory-backend/src/server.ts.tmpl +23 -0
- package/dist/templates/plug-in/memory-backend/test/server.test.ts.tmpl +17 -0
- package/dist/templates/plug-in/phase-agent-override/README.md.tmpl +30 -0
- package/dist/templates/plug-in/phase-agent-override/agents/agent.md.tmpl +26 -0
- package/dist/templates/plug-in/phase-agent-override/gitignore.tmpl +3 -0
- package/dist/templates/plug-in/phase-agent-override/jinn-plugin.json.tmpl +17 -0
- package/dist/templates/plug-in/phase-agent-override/package.json.tmpl +14 -0
- package/dist/templates/plug-in/phase-agent-override/test/manifest.test.ts.tmpl +24 -0
- package/dist/templates/plug-in/skill-bundle/.claude-plugin/plugin.json.tmpl +5 -0
- package/dist/templates/plug-in/skill-bundle/README.md.tmpl +28 -0
- package/dist/templates/plug-in/skill-bundle/gitignore.tmpl +3 -0
- package/dist/templates/plug-in/skill-bundle/jinn-plugin.json.tmpl +15 -0
- package/dist/templates/plug-in/skill-bundle/package.json.tmpl +14 -0
- package/dist/templates/plug-in/skill-bundle/skills/example/SKILL.md.tmpl +14 -0
- package/dist/templates/plug-in/skill-bundle/test/manifest.test.ts.tmpl +21 -0
- package/dist/templates/plug-in/topic-explorer/README.md.tmpl +24 -0
- package/dist/templates/plug-in/topic-explorer/agents/explorer.md.tmpl +26 -0
- package/dist/templates/plug-in/topic-explorer/gitignore.tmpl +3 -0
- package/dist/templates/plug-in/topic-explorer/jinn-plugin.json.tmpl +17 -0
- package/dist/templates/plug-in/topic-explorer/package.json.tmpl +14 -0
- package/dist/templates/plug-in/topic-explorer/test/manifest.test.ts.tmpl +22 -0
- package/dist/templates/restorer/alternative-harness/README.md.tmpl +44 -0
- package/dist/templates/restorer/alternative-harness/gitignore.tmpl +3 -0
- package/dist/templates/restorer/alternative-harness/jinn.manifest.json.tmpl +22 -0
- package/dist/templates/restorer/alternative-harness/package.json.tmpl +26 -0
- package/dist/templates/restorer/alternative-harness/src/coordinator.ts.tmpl +50 -0
- package/dist/templates/restorer/alternative-harness/src/harness.ts.tmpl +31 -0
- package/dist/templates/restorer/alternative-harness/src/index.ts.tmpl +44 -0
- package/dist/templates/restorer/alternative-harness/src/mock-harness.ts.tmpl +41 -0
- package/dist/templates/restorer/alternative-harness/src/phases/debrief.ts.tmpl +28 -0
- package/dist/templates/restorer/alternative-harness/src/phases/execute.ts.tmpl +33 -0
- package/dist/templates/restorer/alternative-harness/src/phases/improve.ts.tmpl +31 -0
- package/dist/templates/restorer/alternative-harness/src/phases/memory.ts.tmpl +31 -0
- package/dist/templates/restorer/alternative-harness/src/phases/orient.ts.tmpl +21 -0
- package/dist/templates/restorer/alternative-harness/src/phases/plan.ts.tmpl +25 -0
- package/dist/templates/restorer/alternative-harness/src/phases/strategize.ts.tmpl +29 -0
- package/dist/templates/restorer/alternative-harness/test/coordinator.test.ts.tmpl +52 -0
- package/dist/templates/restorer/alternative-harness/test/unit.test.ts.tmpl +54 -0
- package/dist/templates/restorer/alternative-harness/tsconfig.json.tmpl +16 -0
- package/dist/templates/restorer/evaluator/README.md.tmpl +36 -0
- package/dist/templates/restorer/evaluator/gitignore.tmpl +3 -0
- package/dist/templates/restorer/evaluator/jinn.manifest.json.tmpl +22 -0
- package/dist/templates/restorer/evaluator/package.json.tmpl +26 -0
- package/dist/templates/restorer/evaluator/src/index.ts.tmpl +35 -0
- package/dist/templates/restorer/evaluator/test/unit.test.ts.tmpl +48 -0
- package/dist/templates/restorer/evaluator/tsconfig.json.tmpl +16 -0
- package/dist/templates/restorer/forecaster/README.md.tmpl +25 -0
- package/dist/templates/restorer/forecaster/gitignore.tmpl +5 -0
- package/dist/templates/restorer/forecaster/jinn.manifest.json.tmpl +22 -0
- package/dist/templates/restorer/forecaster/package.json.tmpl +26 -0
- package/dist/templates/restorer/forecaster/src/index.ts.tmpl +33 -0
- package/dist/templates/restorer/forecaster/test/unit.test.ts.tmpl +41 -0
- package/dist/templates/restorer/forecaster/tsconfig.json.tmpl +16 -0
- package/dist/trajectory/collector.d.ts +49 -0
- package/dist/trajectory/collector.js +86 -0
- package/dist/trajectory/collector.js.map +1 -0
- package/dist/trajectory/emit.d.ts +27 -0
- package/dist/trajectory/emit.js +40 -0
- package/dist/trajectory/emit.js.map +1 -0
- package/dist/trajectory/hash-chain.d.ts +18 -0
- package/dist/trajectory/hash-chain.js +23 -0
- package/dist/trajectory/hash-chain.js.map +1 -0
- package/dist/trajectory/index.d.ts +22 -0
- package/dist/trajectory/index.js +23 -0
- package/dist/trajectory/index.js.map +1 -0
- package/dist/trajectory/schema.d.ts +14 -14
- package/dist/trajectory/secret-scrub.d.ts +32 -0
- package/dist/trajectory/secret-scrub.js +51 -0
- package/dist/trajectory/secret-scrub.js.map +1 -0
- package/dist/trajectory/span-profile.d.ts +27 -0
- package/dist/trajectory/span-profile.js +51 -0
- package/dist/trajectory/span-profile.js.map +1 -0
- package/dist/trajectory/wrappers/http.d.ts +37 -0
- package/dist/trajectory/wrappers/http.js +85 -0
- package/dist/trajectory/wrappers/http.js.map +1 -0
- package/dist/trajectory/wrappers/mcp.d.ts +17 -0
- package/dist/trajectory/wrappers/mcp.js +58 -0
- package/dist/trajectory/wrappers/mcp.js.map +1 -0
- package/dist/trajectory/wrappers/subprocess.d.ts +32 -0
- package/dist/trajectory/wrappers/subprocess.js +70 -0
- package/dist/trajectory/wrappers/subprocess.js.map +1 -0
- package/dist/tx-retry.js +23 -9
- package/dist/tx-retry.js.map +1 -1
- package/dist/types/desired-state.d.ts +211 -21
- package/dist/types/desired-state.js +26 -15
- package/dist/types/desired-state.js.map +1 -1
- package/dist/types/envelope.d.ts +1473 -0
- package/dist/types/envelope.js +114 -0
- package/dist/types/envelope.js.map +1 -0
- package/dist/types/index.d.ts +4 -4
- package/dist/types/index.js +4 -4
- package/dist/types/index.js.map +1 -1
- package/dist/types/intent.d.ts +276 -0
- package/dist/types/intent.js +74 -0
- package/dist/types/intent.js.map +1 -0
- package/dist/types/payloads/index.d.ts +11 -0
- package/dist/types/payloads/index.js +46 -0
- package/dist/types/payloads/index.js.map +1 -0
- package/dist/types/payloads/portfolio-v0.d.ts +481 -0
- package/dist/types/payloads/portfolio-v0.js +94 -0
- package/dist/types/payloads/portfolio-v0.js.map +1 -0
- package/dist/types/payloads/prediction-apy-v0.d.ts +231 -0
- package/dist/types/payloads/prediction-apy-v0.js +63 -0
- package/dist/types/payloads/prediction-apy-v0.js.map +1 -0
- package/dist/types/payloads/prediction-v0.d.ts +262 -0
- package/dist/types/payloads/prediction-v0.js +73 -0
- package/dist/types/payloads/prediction-v0.js.map +1 -0
- package/dist/types/portfolio.d.ts +23 -685
- package/dist/types/portfolio.js +16 -106
- package/dist/types/portfolio.js.map +1 -1
- package/dist/types/prediction-apy.d.ts +9 -344
- package/dist/types/prediction-apy.js +9 -65
- package/dist/types/prediction-apy.js.map +1 -1
- package/dist/types/prediction.d.ts +25 -396
- package/dist/types/prediction.js +5 -79
- package/dist/types/prediction.js.map +1 -1
- package/dist/types/window.d.ts +12 -0
- package/dist/types/window.js +6 -0
- package/dist/types/window.js.map +1 -0
- package/dist/util/path-safety.d.ts +22 -0
- package/dist/util/path-safety.js +29 -0
- package/dist/util/path-safety.js.map +1 -0
- package/dist/util/redact-rpc-urls.d.ts +5 -0
- package/dist/util/redact-rpc-urls.js +9 -0
- package/dist/util/redact-rpc-urls.js.map +1 -0
- package/dist/x402/acquire.d.ts +14 -3
- package/dist/x402/acquire.js +28 -11
- package/dist/x402/acquire.js.map +1 -1
- package/dist/x402/handler.d.ts +15 -3
- package/dist/x402/handler.js +67 -24
- package/dist/x402/handler.js.map +1 -1
- package/package.json +36 -11
- package/plugins/claude-code-learner/.claude-plugin/plugin.json +9 -0
- package/plugins/claude-code-learner/AGENTS.md +30 -0
- package/plugins/claude-code-learner/CLAUDE.md +31 -0
- package/plugins/claude-code-learner/README.md +58 -0
- package/plugins/claude-code-learner/agents/analyst.md +69 -0
- package/plugins/claude-code-learner/agents/consolidator.md +95 -0
- package/plugins/claude-code-learner/agents/explorer.md +54 -0
- package/plugins/claude-code-learner/agents/planner.md +88 -0
- package/plugins/claude-code-learner/agents/promoter.md +114 -0
- package/plugins/claude-code-learner/agents/step-worker.md +48 -0
- package/plugins/claude-code-learner/agents/strategist.md +86 -0
- package/plugins/claude-code-learner/hooks/hooks.json +16 -0
- package/plugins/claude-code-learner/hooks/session-start +49 -0
- package/plugins/claude-code-learner/skills/coordinator/SKILL.md +131 -0
- package/plugins/claude-code-learner/skills/debrief/SKILL.md +71 -0
- package/plugins/claude-code-learner/skills/execute/SKILL.md +91 -0
- package/plugins/claude-code-learner/skills/improve/SKILL.md +57 -0
- package/plugins/claude-code-learner/skills/memory-consolidation/SKILL.md +57 -0
- package/plugins/claude-code-learner/skills/orient/SKILL.md +82 -0
- package/plugins/claude-code-learner/skills/plan/SKILL.md +54 -0
- package/plugins/claude-code-learner/skills/strategize/SKILL.md +63 -0
- package/skills/jinn-operator/SKILL.md +84 -35
- package/templates/plug-in/hook/README.md.tmpl +24 -0
- package/templates/plug-in/hook/gitignore.tmpl +3 -0
- package/templates/plug-in/hook/hooks/event.sh.tmpl +15 -0
- package/templates/plug-in/hook/jinn-plugin.json.tmpl +16 -0
- package/templates/plug-in/hook/package.json.tmpl +14 -0
- package/templates/plug-in/hook/test/manifest.test.ts.tmpl +21 -0
- package/templates/plug-in/mcp-tool/README.md.tmpl +26 -0
- package/templates/plug-in/mcp-tool/gitignore.tmpl +4 -0
- package/templates/plug-in/mcp-tool/jinn-plugin.json.tmpl +16 -0
- package/templates/plug-in/mcp-tool/package.json.tmpl +19 -0
- package/templates/plug-in/mcp-tool/src/server.ts.tmpl +17 -0
- package/templates/plug-in/mcp-tool/test/server.test.ts.tmpl +18 -0
- package/templates/plug-in/memory-backend/README.md.tmpl +33 -0
- package/templates/plug-in/memory-backend/gitignore.tmpl +4 -0
- package/templates/plug-in/memory-backend/jinn-plugin.json.tmpl +16 -0
- package/templates/plug-in/memory-backend/package.json.tmpl +19 -0
- package/templates/plug-in/memory-backend/src/server.ts.tmpl +23 -0
- package/templates/plug-in/memory-backend/test/server.test.ts.tmpl +17 -0
- package/templates/plug-in/phase-agent-override/README.md.tmpl +30 -0
- package/templates/plug-in/phase-agent-override/agents/agent.md.tmpl +26 -0
- package/templates/plug-in/phase-agent-override/gitignore.tmpl +3 -0
- package/templates/plug-in/phase-agent-override/jinn-plugin.json.tmpl +17 -0
- package/templates/plug-in/phase-agent-override/package.json.tmpl +14 -0
- package/templates/plug-in/phase-agent-override/test/manifest.test.ts.tmpl +24 -0
- package/templates/plug-in/skill-bundle/.claude-plugin/plugin.json.tmpl +5 -0
- package/templates/plug-in/skill-bundle/README.md.tmpl +28 -0
- package/templates/plug-in/skill-bundle/gitignore.tmpl +3 -0
- package/templates/plug-in/skill-bundle/jinn-plugin.json.tmpl +15 -0
- package/templates/plug-in/skill-bundle/package.json.tmpl +14 -0
- package/templates/plug-in/skill-bundle/skills/example/SKILL.md.tmpl +14 -0
- package/templates/plug-in/skill-bundle/test/manifest.test.ts.tmpl +21 -0
- package/templates/plug-in/topic-explorer/README.md.tmpl +24 -0
- package/templates/plug-in/topic-explorer/agents/explorer.md.tmpl +26 -0
- package/templates/plug-in/topic-explorer/gitignore.tmpl +3 -0
- package/templates/plug-in/topic-explorer/jinn-plugin.json.tmpl +17 -0
- package/templates/plug-in/topic-explorer/package.json.tmpl +14 -0
- package/templates/plug-in/topic-explorer/test/manifest.test.ts.tmpl +22 -0
- package/templates/restorer/alternative-harness/README.md.tmpl +44 -0
- package/templates/restorer/alternative-harness/gitignore.tmpl +3 -0
- package/templates/restorer/alternative-harness/jinn.manifest.json.tmpl +22 -0
- package/templates/restorer/alternative-harness/package.json.tmpl +26 -0
- package/templates/restorer/alternative-harness/src/coordinator.ts.tmpl +50 -0
- package/templates/restorer/alternative-harness/src/harness.ts.tmpl +31 -0
- package/templates/restorer/alternative-harness/src/index.ts.tmpl +44 -0
- package/templates/restorer/alternative-harness/src/mock-harness.ts.tmpl +41 -0
- package/templates/restorer/alternative-harness/src/phases/debrief.ts.tmpl +28 -0
- package/templates/restorer/alternative-harness/src/phases/execute.ts.tmpl +33 -0
- package/templates/restorer/alternative-harness/src/phases/improve.ts.tmpl +31 -0
- package/templates/restorer/alternative-harness/src/phases/memory.ts.tmpl +31 -0
- package/templates/restorer/alternative-harness/src/phases/orient.ts.tmpl +21 -0
- package/templates/restorer/alternative-harness/src/phases/plan.ts.tmpl +25 -0
- package/templates/restorer/alternative-harness/src/phases/strategize.ts.tmpl +29 -0
- package/templates/restorer/alternative-harness/test/coordinator.test.ts.tmpl +52 -0
- package/templates/restorer/alternative-harness/test/unit.test.ts.tmpl +54 -0
- package/templates/restorer/alternative-harness/tsconfig.json.tmpl +16 -0
- package/templates/restorer/evaluator/README.md.tmpl +36 -0
- package/templates/restorer/evaluator/gitignore.tmpl +3 -0
- package/templates/restorer/evaluator/jinn.manifest.json.tmpl +22 -0
- package/templates/restorer/evaluator/package.json.tmpl +26 -0
- package/templates/restorer/evaluator/src/index.ts.tmpl +35 -0
- package/templates/restorer/evaluator/test/unit.test.ts.tmpl +48 -0
- package/templates/restorer/evaluator/tsconfig.json.tmpl +16 -0
- package/templates/restorer/forecaster/README.md.tmpl +25 -0
- package/templates/restorer/forecaster/gitignore.tmpl +5 -0
- package/templates/restorer/forecaster/jinn.manifest.json.tmpl +22 -0
- package/templates/restorer/forecaster/package.json.tmpl +26 -0
- package/templates/restorer/forecaster/src/index.ts.tmpl +33 -0
- package/templates/restorer/forecaster/test/unit.test.ts.tmpl +41 -0
- package/templates/restorer/forecaster/tsconfig.json.tmpl +16 -0
- package/dist/bin/jinn-mcp.d.ts +0 -2
- package/dist/bin/jinn-mcp.js +0 -10
- package/dist/bin/jinn-mcp.js.map +0 -1
- package/dist/cli/commands/quickstart.js +0 -330
- package/dist/cli/commands/quickstart.js.map +0 -1
- package/dist/discovery/registry.d.ts +0 -97
- package/dist/discovery/registry.js +0 -177
- package/dist/discovery/registry.js.map +0 -1
- package/dist/discovery/subgraph.d.ts +0 -37
- package/dist/discovery/subgraph.js +0 -87
- package/dist/discovery/subgraph.js.map +0 -1
- package/dist/restorer/engine/manifest-assembly.d.ts +0 -67
- package/dist/restorer/engine/manifest-assembly.js +0 -79
- package/dist/restorer/engine/manifest-assembly.js.map +0 -1
- /package/dist/cli/commands/{quickstart.d.ts → ui.d.ts} +0 -0
package/dist/main.js
CHANGED
|
@@ -10,63 +10,146 @@
|
|
|
10
10
|
* 2. Config file (~/.jinn-client/config.json or --config <path>)
|
|
11
11
|
* 3. Built-in defaults
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* Keystore password (used to encrypt the wallet at rest) resolves in this
|
|
14
|
+
* order: JINN_PASSWORD env var → ~/.jinn-client/keystore-password file →
|
|
15
|
+
* auto-generated random value (persisted mode 0600 to that same file). A
|
|
16
|
+
* brand-new operator can run `jinn run` with no env var and no input.
|
|
14
17
|
*
|
|
15
18
|
* Canonical operator command:
|
|
16
19
|
* jinn run
|
|
17
20
|
*/
|
|
18
21
|
import { config as dotenvConfig } from 'dotenv';
|
|
22
|
+
import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync as writeFileSyncMain } from 'node:fs';
|
|
23
|
+
import { homedir } from 'node:os';
|
|
24
|
+
import { randomBytes as cryptoRandomBytes } from 'node:crypto';
|
|
19
25
|
import { dirname, join } from 'node:path';
|
|
20
26
|
import { fileURLToPath } from 'node:url';
|
|
21
27
|
import { loadConfig, getConfigPathFromArgs } from './config.js';
|
|
22
|
-
import {
|
|
28
|
+
import { Store } from './store/store.js';
|
|
29
|
+
import { startApiServer } from './api/server.js';
|
|
30
|
+
import { ensureUiToken } from './api/ui-token.js';
|
|
31
|
+
import { attachAgentWs } from './agent/agent-ws.js';
|
|
32
|
+
import { createSetupModeController } from './setup-mode.js';
|
|
33
|
+
import { buildEnvelope, emitEnvelope } from './errors/envelope.js';
|
|
34
|
+
import { clearBootstrapError, persistBootstrapError, } from './errors/persisted-bootstrap-error.js';
|
|
35
|
+
import { emitStructured } from './events/emitter.js';
|
|
23
36
|
import { checkClaudeBinary } from './preflight/claude-binary.js';
|
|
24
37
|
import { emitClaudeBinaryPreflightFailure } from './preflight/claude-invocation-envelope.js';
|
|
25
38
|
import { detectAuthContext, probeClaudeAuth } from './preflight/claude-auth.js';
|
|
26
39
|
import { FleetBootstrapper } from './earning/bootstrap.js';
|
|
27
|
-
import { getChainConfig } from './earning/contracts.js';
|
|
40
|
+
import { DEFAULT_TESTNET_ARTIFACTS, applyChainGasOverrides, getChainConfig, loadJinnMviConfig } from './earning/contracts.js';
|
|
41
|
+
import { runLegacyAgentIdMigration } from './earning/migrate-agent-id.js';
|
|
28
42
|
import { FleetStateStore } from './earning/store.js';
|
|
43
|
+
import { isOperationalServiceStep, } from './earning/types.js';
|
|
29
44
|
import { decryptMnemonic, deriveMasterSigner, walletPrivateKeyAtIndex } from './earning/wallet.js';
|
|
30
45
|
import { MechAdapter } from './adapters/mech/adapter.js';
|
|
31
46
|
import { ClaudeRunner } from './runner/claude.js';
|
|
32
47
|
import { Daemon } from './daemon/daemon.js';
|
|
33
|
-
import { createJinnPublicClient, createJinnWalletClient } from './earning/viem-clients.js';
|
|
48
|
+
import { createJinnPublicClient, createJinnWalletClient, createJinnL1PublicClient, createJinnL1WalletClient } from './earning/viem-clients.js';
|
|
49
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
34
50
|
import { RestorerImplRegistry } from './restorer/engine/registry.js';
|
|
35
51
|
import { buildRestorerImpls } from './restorer/impls/index.js';
|
|
52
|
+
import { loadExternalImpl } from './restorer/external-impls/index.js';
|
|
36
53
|
import { ClaimRegistryClient } from './adapters/claim-registry/client.js';
|
|
37
54
|
import { createClients } from './adapters/mech/safe.js';
|
|
38
55
|
import { collectTestnetAutoIntentGenerators } from './intents/kinds/index.js';
|
|
56
|
+
import { createCorpus } from './corpus/index.js';
|
|
39
57
|
import { BASE_FEEDS } from './venues/chainlink/feeds.js';
|
|
40
58
|
import { GeneratedIntentSource, StaticConfiguredIntentSource } from './intents/sources.js';
|
|
41
59
|
import { checkRpcNetwork, logRpcLocalDevToStderr, rpcNetworkFailureHint } from './preflight/rpc-network.js';
|
|
42
60
|
import { apiPortFailureMessage, checkApiPortAvailable } from './preflight/api-port.js';
|
|
61
|
+
import { openBrowser } from './cli/open-browser.js';
|
|
43
62
|
dotenvConfig({ path: join(dirname(fileURLToPath(import.meta.url)), '..', '.env') });
|
|
44
|
-
// ── Password (env
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
63
|
+
// ── Password (env > file > auto-generated) ─────────────────────────────────
|
|
64
|
+
//
|
|
65
|
+
// Resolution order:
|
|
66
|
+
// 1. JINN_PASSWORD env var (explicit operator-set, never in config files)
|
|
67
|
+
// 2. ~/.jinn-client/keystore-password (file from a previous auto-gen)
|
|
68
|
+
// 3. Auto-generate a 32-byte hex string, persist mode 0600, and reuse next run
|
|
69
|
+
//
|
|
70
|
+
// Auto-generation matches what `jinn quickstart` used to do so a brand-new
|
|
71
|
+
// operator can run `jinn run` with no env var, no setup, no input. The
|
|
72
|
+
// known security trade-off is documented in client/src/cli/password.ts:
|
|
73
|
+
// plaintext on disk + encrypted keystore on the same disk only defends
|
|
74
|
+
// against casual snooping. Treat the wallet as hot until rotated.
|
|
75
|
+
function resolveOrGenerateKeystorePassword() {
|
|
76
|
+
const envPw = process.env['JINN_PASSWORD'];
|
|
77
|
+
if (envPw && envPw.length > 0) {
|
|
78
|
+
return { password: envPw, source: 'env' };
|
|
79
|
+
}
|
|
80
|
+
const home = process.env['HOME'] ?? homedir();
|
|
81
|
+
const pwFilePath = join(home, '.jinn-client', 'keystore-password');
|
|
82
|
+
if (existsSync(pwFilePath)) {
|
|
83
|
+
const fromDisk = readFileSync(pwFilePath, 'utf-8').trim();
|
|
84
|
+
if (fromDisk.length > 0) {
|
|
85
|
+
return { password: fromDisk, source: 'file', filePath: pwFilePath };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const generated = cryptoRandomBytes(32).toString('hex');
|
|
89
|
+
mkdirSync(dirname(pwFilePath), { recursive: true, mode: 0o700 });
|
|
90
|
+
writeFileSyncMain(pwFilePath, generated + '\n', { mode: 0o600 });
|
|
91
|
+
return { password: generated, source: 'generated', filePath: pwFilePath };
|
|
92
|
+
}
|
|
93
|
+
const passwordResolution = resolveOrGenerateKeystorePassword();
|
|
94
|
+
const PASSWORD = passwordResolution.password;
|
|
95
|
+
// Sub-commands (e.g. the embedded `init` invocation below) read JINN_PASSWORD
|
|
96
|
+
// from env. Mirror our resolved value so they don't have to redo this dance.
|
|
97
|
+
process.env['JINN_PASSWORD'] = PASSWORD;
|
|
98
|
+
if (passwordResolution.source === 'generated') {
|
|
99
|
+
console.log('━'.repeat(64));
|
|
100
|
+
console.log('A keystore password was auto-generated for you.');
|
|
101
|
+
console.log(` Stored at: ${passwordResolution.filePath}`);
|
|
102
|
+
console.log(' Mode 0600. Treat the wallet as hot until you rotate the password.');
|
|
103
|
+
console.log(' To rotate: JINN_NEW_PASSWORD=<new> jinn keys change-password');
|
|
104
|
+
console.log('━'.repeat(64));
|
|
105
|
+
}
|
|
54
106
|
// ── Load config ─────────────────────────────────────────────────────────────
|
|
55
|
-
const
|
|
107
|
+
const CONFIG_PATH = getConfigPathFromArgs();
|
|
108
|
+
const config = loadConfig(CONFIG_PATH);
|
|
56
109
|
const NETWORK_CHAIN = config.network === 'testnet' ? 'base-sepolia' : 'base';
|
|
57
|
-
const CHAIN_CONFIG = getChainConfig(NETWORK_CHAIN, {
|
|
110
|
+
const CHAIN_CONFIG = applyChainGasOverrides(getChainConfig(NETWORK_CHAIN, {
|
|
58
111
|
testnetL2DeploymentPath: config.testnetL2DeploymentPath,
|
|
59
112
|
testnetL2TokenDeploymentPath: config.testnetL2TokenDeploymentPath,
|
|
60
113
|
testnetMechDeploymentPath: config.testnetMechDeploymentPath,
|
|
61
114
|
testnetStolasDeploymentPath: config.testnetStolasDeploymentPath,
|
|
62
115
|
testnetClaimRegistryDeploymentPath: config.testnetClaimRegistryDeploymentPath,
|
|
116
|
+
}), {
|
|
117
|
+
minEoaGasWei: config.minEoaGasWei,
|
|
118
|
+
minSafeEthWei: config.minSafeEthWei,
|
|
119
|
+
});
|
|
120
|
+
const MESSENGER_MODE_EXPLICIT = process.env['JINN_MESSENGER_MODE'] !== undefined ||
|
|
121
|
+
configFileHasTopLevelKey(CONFIG_PATH, 'jinnMessengerMode');
|
|
122
|
+
const JINN_MVI_CONFIG = loadJinnMviConfig({
|
|
123
|
+
l1ArtifactPath: config.jinnMviL1DeploymentPath ??
|
|
124
|
+
(config.network === 'testnet' ? DEFAULT_TESTNET_ARTIFACTS.jinnMviL1 : undefined),
|
|
125
|
+
l2ArtifactPath: config.jinnMviL2DeploymentPath ??
|
|
126
|
+
(config.network === 'testnet' ? DEFAULT_TESTNET_ARTIFACTS.jinnMviL2 : undefined),
|
|
127
|
+
distributorAddress: config.jinnDistributorAddress,
|
|
128
|
+
messengerAddress: config.jinnMessengerAddress,
|
|
129
|
+
claimEmitterAddress: config.jinnClaimEmitterAddress,
|
|
130
|
+
messengerMode: MESSENGER_MODE_EXPLICIT ? config.jinnMessengerMode : undefined,
|
|
63
131
|
});
|
|
132
|
+
const JINN_CLAIM_MESSENGER_MODE = JINN_MVI_CONFIG.messengerMode ?? config.jinnMessengerMode;
|
|
64
133
|
const MARKETPLACE_ADDRESS = CHAIN_CONFIG.mechMarketplace;
|
|
65
134
|
const ROUTER_ADDRESS = (CHAIN_CONFIG.jinnRouter ?? '0xfFa7118A3D820cd4E820010837D65FAfF463181B');
|
|
135
|
+
function configFileHasTopLevelKey(configPath, key) {
|
|
136
|
+
const filePath = configPath ?? join(process.env['HOME'] ?? '', '.jinn-client', 'config.json');
|
|
137
|
+
if (!filePath || !existsSync(filePath))
|
|
138
|
+
return false;
|
|
139
|
+
try {
|
|
140
|
+
const raw = JSON.parse(readFileSync(filePath, 'utf8'));
|
|
141
|
+
return !!raw && typeof raw === 'object' && Object.prototype.hasOwnProperty.call(raw, key);
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
66
147
|
const STANDARD_SERVICE_PROGRESSION = [
|
|
67
148
|
'awaiting_stake',
|
|
68
149
|
'staked',
|
|
69
150
|
'mech_deployed',
|
|
151
|
+
'agent_registered',
|
|
152
|
+
'safe_binding_pending',
|
|
70
153
|
'complete',
|
|
71
154
|
];
|
|
72
155
|
const SELF_BOND_SERVICE_PROGRESSION = [
|
|
@@ -77,6 +160,8 @@ const SELF_BOND_SERVICE_PROGRESSION = [
|
|
|
77
160
|
'service_deployed',
|
|
78
161
|
'service_staked',
|
|
79
162
|
'mech_deployed',
|
|
163
|
+
'agent_registered',
|
|
164
|
+
'safe_binding_pending',
|
|
80
165
|
'complete',
|
|
81
166
|
];
|
|
82
167
|
/** §6.2 `bootstrap_incomplete` — `{ currentStep, nextStep }` from persisted fleet state. */
|
|
@@ -85,13 +170,14 @@ function bootstrapIncompleteSteps(state) {
|
|
|
85
170
|
? SELF_BOND_SERVICE_PROGRESSION
|
|
86
171
|
: STANDARD_SERVICE_PROGRESSION;
|
|
87
172
|
const byIndex = [...state.services].sort((a, b) => a.index - b.index);
|
|
88
|
-
const focus = byIndex.find(s => s.step
|
|
89
|
-
byIndex.find(s => s.step
|
|
173
|
+
const focus = byIndex.find(s => isOperationalServiceStep(s.step) && !s.safe_address) ??
|
|
174
|
+
byIndex.find(s => !isOperationalServiceStep(s.step)) ??
|
|
175
|
+
byIndex.find(s => s.step === 'safe_binding_pending') ??
|
|
90
176
|
byIndex[0];
|
|
91
177
|
if (!focus) {
|
|
92
178
|
return { currentStep: 'awaiting_service', nextStep: 'awaiting_stake' };
|
|
93
179
|
}
|
|
94
|
-
if (focus.step
|
|
180
|
+
if (isOperationalServiceStep(focus.step) && !focus.safe_address) {
|
|
95
181
|
return { currentStep: 'complete', nextStep: 'bootstrap' };
|
|
96
182
|
}
|
|
97
183
|
const i = progression.indexOf(focus.step);
|
|
@@ -106,6 +192,21 @@ function bootstrapIncompleteSteps(state) {
|
|
|
106
192
|
// ── Bootstrap ───────────────────────────────────────────────────────────────
|
|
107
193
|
async function bootstrap() {
|
|
108
194
|
console.log('[main] Running fleet bootstrap...');
|
|
195
|
+
// A fresh bootstrap attempt clears any stale error breadcrumb. If this run
|
|
196
|
+
// hits the same failure, it'll be re-persisted below; if it succeeds (or
|
|
197
|
+
// proceeds past the previously-failed step), the panel returns to a clean
|
|
198
|
+
// state on the next /v1/bootstrap poll.
|
|
199
|
+
clearBootstrapError(config.earningDir);
|
|
200
|
+
// Persist the envelope to disk before emitEnvelope's process.exit fires,
|
|
201
|
+
// so /v1/bootstrap can surface it to the panel after the daemon has
|
|
202
|
+
// exited (operator restart → panel reload → error visible).
|
|
203
|
+
function failBootstrap(input) {
|
|
204
|
+
const envelope = buildEnvelope(input);
|
|
205
|
+
persistBootstrapError(envelope, config.earningDir);
|
|
206
|
+
emitEnvelope(input);
|
|
207
|
+
// Unreachable in production (emitEnvelope exits); satisfies `never`.
|
|
208
|
+
throw new Error('unreachable');
|
|
209
|
+
}
|
|
109
210
|
const bootstrapper = new FleetBootstrapper({
|
|
110
211
|
earningDir: config.earningDir,
|
|
111
212
|
chain: NETWORK_CHAIN,
|
|
@@ -119,37 +220,160 @@ async function bootstrap() {
|
|
|
119
220
|
testnetClaimRegistryDeploymentPath: config.testnetClaimRegistryDeploymentPath,
|
|
120
221
|
debug: config.debug,
|
|
121
222
|
masterEthDailyEstimateWei: config.masterEthDailyEstimateWei,
|
|
223
|
+
minEoaGasWei: config.minEoaGasWei,
|
|
224
|
+
minSafeEthWei: config.minSafeEthWei,
|
|
122
225
|
pollIntervalMs: config.pollIntervalMs,
|
|
226
|
+
autoTestnetFaucet: process.env['JINN_AUTO_TESTNET_FAUCET'] === '1',
|
|
123
227
|
});
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
228
|
+
// Funding poll: stay up while waiting for the operator to fund the wallet.
|
|
229
|
+
// The setup-mode API server is already running; the panel renders the
|
|
230
|
+
// funding card and auto-advances when funds land. Daemon-side, we poll
|
|
231
|
+
// bootstrap on a 15s tick and only escalate (exit) if a non-funding error
|
|
232
|
+
// occurs or the configured timeout elapses. Each tick re-runs the full
|
|
233
|
+
// bootstrap state machine — completed steps are no-ops, so this is safe.
|
|
234
|
+
// Testnet faucet funding is panel-driven: bootstrap reports the funding gate,
|
|
235
|
+
// and the operator clicks the funding action before this loop can advance.
|
|
236
|
+
const FUNDING_POLL_INTERVAL_MS = 15_000;
|
|
237
|
+
const fundingTimeoutMs = (() => {
|
|
238
|
+
const raw = process.env['JINN_FUNDING_TIMEOUT_MS'];
|
|
239
|
+
if (!raw)
|
|
240
|
+
return Number.POSITIVE_INFINITY;
|
|
241
|
+
const n = Number.parseInt(raw, 10);
|
|
242
|
+
return Number.isFinite(n) && n > 0 ? n : Number.POSITIVE_INFINITY;
|
|
243
|
+
})();
|
|
244
|
+
emitProgress({
|
|
245
|
+
type: 'progress',
|
|
246
|
+
phase: 'bootstrap',
|
|
247
|
+
step: 'advance_state_machine',
|
|
248
|
+
estimatedWaitMs: 60_000,
|
|
249
|
+
});
|
|
250
|
+
const fundingStartedAt = Date.now();
|
|
251
|
+
let result;
|
|
252
|
+
let lastFundingMessage = '';
|
|
253
|
+
const fundingGatePath = join(config.earningDir, 'bootstrap-funding.json');
|
|
254
|
+
const persistFundingGate = (funding) => {
|
|
255
|
+
mkdirSync(config.earningDir, { recursive: true, mode: 0o700 });
|
|
256
|
+
writeFileSyncMain(fundingGatePath, `${JSON.stringify({
|
|
257
|
+
schemaVersion: 1,
|
|
258
|
+
generatedAt: new Date().toISOString(),
|
|
259
|
+
...funding,
|
|
260
|
+
}, null, 2)}\n`, { mode: 0o600 });
|
|
261
|
+
};
|
|
262
|
+
const clearFundingGate = () => {
|
|
263
|
+
try {
|
|
264
|
+
unlinkSync(fundingGatePath);
|
|
265
|
+
}
|
|
266
|
+
catch {
|
|
267
|
+
// best-effort: absent/stale funding gate should not affect bootstrap
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
// eslint-disable-next-line no-constant-condition
|
|
271
|
+
while (true) {
|
|
272
|
+
result = await bootstrapper.bootstrap(PASSWORD);
|
|
273
|
+
if (!result.funding) {
|
|
274
|
+
clearFundingGate();
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
persistFundingGate(result.funding);
|
|
278
|
+
// Emit a structured event so the panel's Visibility region shows the gate.
|
|
279
|
+
// Dedupe by message to avoid spamming the ring buffer on each poll.
|
|
280
|
+
const fundingMsg = result.message ?? 'awaiting funding';
|
|
281
|
+
if (fundingMsg !== lastFundingMessage) {
|
|
282
|
+
emitStructured({
|
|
283
|
+
kind: 'fleet',
|
|
284
|
+
message: fundingMsg,
|
|
285
|
+
details: {
|
|
286
|
+
phase: 'awaiting_funding',
|
|
287
|
+
role: 'master',
|
|
288
|
+
address: result.funding.master_address,
|
|
289
|
+
asset: 'native',
|
|
290
|
+
needWei: result.funding.eth_required,
|
|
291
|
+
haveWei: result.funding.eth_balance,
|
|
292
|
+
},
|
|
293
|
+
});
|
|
294
|
+
// Mirror the structured event to NDJSON progress for --json-progress
|
|
295
|
+
// consumers (CI, agents). Same dedup gate so we don't spam stdout.
|
|
296
|
+
emitProgress({
|
|
297
|
+
type: 'progress',
|
|
298
|
+
phase: 'bootstrap',
|
|
299
|
+
step: 'awaiting_funding',
|
|
300
|
+
blocking: true,
|
|
301
|
+
nextAction: 'Fund the address shown in addresses.fundingAddress, then wait for automatic retry.',
|
|
302
|
+
addresses: { fundingAddress: result.funding.master_address },
|
|
303
|
+
estimatedWaitMs: 1_800_000,
|
|
304
|
+
});
|
|
305
|
+
lastFundingMessage = fundingMsg;
|
|
306
|
+
}
|
|
307
|
+
const elapsed = Date.now() - fundingStartedAt;
|
|
308
|
+
if (elapsed >= fundingTimeoutMs) {
|
|
309
|
+
failBootstrap({
|
|
310
|
+
code: 'funding_required',
|
|
311
|
+
message: `${result.message} (timeout after ${Math.round(elapsed / 1000)}s)`,
|
|
312
|
+
hint: 'Fund the listed address and re-run this command.',
|
|
313
|
+
exampleCli: 'jinn fund-requirements --json',
|
|
314
|
+
details: {
|
|
315
|
+
role: 'master',
|
|
316
|
+
address: result.funding.master_address,
|
|
317
|
+
asset: 'native',
|
|
318
|
+
needWei: result.funding.eth_required,
|
|
319
|
+
haveWei: result.funding.eth_balance,
|
|
320
|
+
},
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
console.log(`[main] Awaiting funding... (${Math.round(elapsed / 1000)}s elapsed; ` +
|
|
324
|
+
`will retry in ${FUNDING_POLL_INTERVAL_MS / 1000}s)`);
|
|
325
|
+
await new Promise((r) => setTimeout(r, FUNDING_POLL_INTERVAL_MS));
|
|
139
326
|
}
|
|
140
327
|
if (!result.ok) {
|
|
141
|
-
|
|
328
|
+
failBootstrap({
|
|
142
329
|
code: 'fatal',
|
|
143
330
|
message: result.message,
|
|
144
331
|
hint: 'Bootstrap failed before the fleet reached a runnable state.',
|
|
145
332
|
details: { cause: result.message },
|
|
146
333
|
});
|
|
147
334
|
}
|
|
148
|
-
//
|
|
149
|
-
|
|
150
|
-
|
|
335
|
+
// Legacy migration (jinn-mono-jgp): backfill `agent_id` on `complete`
|
|
336
|
+
// services that pre-date j07. Idempotent + per-service failure-isolated;
|
|
337
|
+
// a failure here does not abort daemon startup, but we surface counts so
|
|
338
|
+
// operators notice. Disabled via `runLegacyMigrations: false` /
|
|
339
|
+
// JINN_RUN_LEGACY_MIGRATIONS=0 — operators can run `jinn migrate-agent-id`
|
|
340
|
+
// explicitly instead.
|
|
341
|
+
let state = result.fleet_state;
|
|
342
|
+
if (config.runLegacyMigrations) {
|
|
343
|
+
try {
|
|
344
|
+
const migration = await runLegacyAgentIdMigration({
|
|
345
|
+
earningDir: config.earningDir,
|
|
346
|
+
network: NETWORK_CHAIN,
|
|
347
|
+
rpcUrl: config.rpcUrl,
|
|
348
|
+
password: PASSWORD,
|
|
349
|
+
testnetL2DeploymentPath: config.testnetL2DeploymentPath,
|
|
350
|
+
testnetL2TokenDeploymentPath: config.testnetL2TokenDeploymentPath,
|
|
351
|
+
testnetMechDeploymentPath: config.testnetMechDeploymentPath,
|
|
352
|
+
testnetStolasDeploymentPath: config.testnetStolasDeploymentPath,
|
|
353
|
+
testnetClaimRegistryDeploymentPath: config.testnetClaimRegistryDeploymentPath,
|
|
354
|
+
});
|
|
355
|
+
if (migration.migrated.length > 0 || migration.failed.length > 0) {
|
|
356
|
+
console.log(`[main] Legacy agent_id migration: migrated=${migration.migrated.length} ` +
|
|
357
|
+
`skipped=${migration.skipped.length} failed=${migration.failed.length}`);
|
|
358
|
+
for (const f of migration.failed) {
|
|
359
|
+
console.log(`[main] service ${f.service.index} (agent ${f.service.agent_address}): ${f.error}`);
|
|
360
|
+
}
|
|
361
|
+
// Reload state so downstream wiring (agent_id, identityRegistry)
|
|
362
|
+
// sees the migrated rows.
|
|
363
|
+
state = await new FleetStateStore(config.earningDir).load(NETWORK_CHAIN);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
catch (err) {
|
|
367
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
368
|
+
console.error(`[main] Legacy agent_id migration failed (non-fatal): ${message}`);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
// Use the first operational service for the daemon. `safe_binding_pending`
|
|
372
|
+
// means staking/mech are live; only the ERC-8004 Safe→agent metadata bind
|
|
373
|
+
// is still retrying.
|
|
374
|
+
const firstComplete = state.services.find(s => isOperationalServiceStep(s.step));
|
|
151
375
|
if (!firstComplete || !firstComplete.safe_address) {
|
|
152
|
-
|
|
376
|
+
failBootstrap({
|
|
153
377
|
code: 'bootstrap_incomplete',
|
|
154
378
|
message: 'Bootstrap completed but no service is ready.',
|
|
155
379
|
hint: 'Re-run to continue the state machine toward a running fleet.',
|
|
@@ -163,7 +387,7 @@ async function bootstrap() {
|
|
|
163
387
|
const agentPrivateKey = walletPrivateKeyAtIndex(mnemonic, firstComplete.index);
|
|
164
388
|
console.log(`[main] Fleet bootstrap complete.`);
|
|
165
389
|
console.log(` Master: ${state.master_address}`);
|
|
166
|
-
console.log(` Services: ${state.services.filter(s => s.step
|
|
390
|
+
console.log(` Services: ${state.services.filter(s => isOperationalServiceStep(s.step)).length}/${config.targetServices}`);
|
|
167
391
|
console.log(` Active: service ${firstComplete.service_id} (agent ${firstComplete.agent_address})`);
|
|
168
392
|
if (firstComplete.mech_address) {
|
|
169
393
|
console.log(` Mech: ${firstComplete.mech_address}`);
|
|
@@ -172,14 +396,54 @@ async function bootstrap() {
|
|
|
172
396
|
masterAddress: state.master_address,
|
|
173
397
|
serviceIndex: firstComplete.index,
|
|
174
398
|
serviceId: firstComplete.service_id ?? null,
|
|
399
|
+
stakingAddress: firstComplete.staking_address ? firstComplete.staking_address : null,
|
|
175
400
|
agentPrivateKey: agentPrivateKey,
|
|
176
401
|
safeAddress: firstComplete.safe_address,
|
|
177
402
|
mechAddress: firstComplete.mech_address ? firstComplete.mech_address : undefined,
|
|
403
|
+
agentId: firstComplete.agent_id ?? null,
|
|
404
|
+
identityRegistryAddress: firstComplete.identity_registry_address
|
|
405
|
+
? firstComplete.identity_registry_address
|
|
406
|
+
: null,
|
|
178
407
|
};
|
|
179
408
|
}
|
|
180
409
|
// ── Main ────────────────────────────────────────────────────────────────────
|
|
410
|
+
/**
|
|
411
|
+
* --json-progress: emit NDJSON progress envelopes on stdout during long
|
|
412
|
+
* phases (init, bootstrap, daemon startup). The `jinn run --json-progress`
|
|
413
|
+
* flag flips JINN_JSON_PROGRESS=1 in run.ts before calling main(); when
|
|
414
|
+
* unset this is a no-op so tests / non-flag invocations stay silent on
|
|
415
|
+
* stdout.
|
|
416
|
+
*/
|
|
417
|
+
function progressEnabled() {
|
|
418
|
+
return process.env['JINN_JSON_PROGRESS'] === '1';
|
|
419
|
+
}
|
|
420
|
+
function emitProgress(envelope) {
|
|
421
|
+
if (progressEnabled()) {
|
|
422
|
+
process.stdout.write(JSON.stringify(envelope) + '\n');
|
|
423
|
+
}
|
|
424
|
+
}
|
|
181
425
|
export async function main() {
|
|
182
426
|
console.log(`[main] jinn-client starting on ${NETWORK_CHAIN}`);
|
|
427
|
+
// ── Daemon API bearer token (jinn-mono-pr64 hardening) ───────────────────
|
|
428
|
+
//
|
|
429
|
+
// Cost-mutating API routes (`POST /v1/artifacts/acquire`, `POST /artifacts`)
|
|
430
|
+
// require an `Authorization: Bearer <token>` header. Read from env when
|
|
431
|
+
// operators want a stable token (e.g. multi-process tools); otherwise
|
|
432
|
+
// generate a fresh one per daemon process. Logged only as an 8-char prefix.
|
|
433
|
+
// The token is forwarded to the MCP subprocess via `DAEMON_API_TOKEN` env
|
|
434
|
+
// so `acquire_artifact` and `submit_restoration_result` can authenticate
|
|
435
|
+
// their calls back to the daemon.
|
|
436
|
+
const envToken = process.env['DAEMON_API_TOKEN']?.trim();
|
|
437
|
+
const apiToken = envToken && envToken.length > 0
|
|
438
|
+
? envToken
|
|
439
|
+
: cryptoRandomBytes(32).toString('hex');
|
|
440
|
+
if (!envToken) {
|
|
441
|
+
console.log(`[main] Generated DAEMON_API_TOKEN (prefix=${apiToken.slice(0, 8)}...)`);
|
|
442
|
+
}
|
|
443
|
+
// The keystore-presence probe happens twice: once now (to decide initial
|
|
444
|
+
// setup-mode) and once after we run init below (to flip the controller).
|
|
445
|
+
const masterKeystorePath = join(config.earningDir, 'master_keystore.json');
|
|
446
|
+
const legacyKeystorePath = join(config.earningDir, 'agent_keystore.json');
|
|
183
447
|
const rpcPreflight = await checkRpcNetwork(config);
|
|
184
448
|
if (!rpcPreflight.ok) {
|
|
185
449
|
emitEnvelope({
|
|
@@ -214,7 +478,197 @@ export async function main() {
|
|
|
214
478
|
},
|
|
215
479
|
});
|
|
216
480
|
}
|
|
217
|
-
|
|
481
|
+
// ── Setup-mode API server ────────────────────────────────────────────────
|
|
482
|
+
// Start the operator-facing API early so the SPA can show bootstrap
|
|
483
|
+
// progress while we may still be waiting on funding. The daemon loops are
|
|
484
|
+
// gated until bootstrap completes — we just bring up the API + handshake +
|
|
485
|
+
// /v1/bootstrap + /v1/events + /v1/status here. The same Store instance is
|
|
486
|
+
// later passed into Daemon so we don't double-open the SQLite file.
|
|
487
|
+
const sharedStore = new Store(config.dbPath);
|
|
488
|
+
const earningStateStore = new FleetStateStore(config.earningDir);
|
|
489
|
+
const initialFleet = await earningStateStore.tryLoadExisting();
|
|
490
|
+
const initialServices = initialFleet?.services ?? [];
|
|
491
|
+
const initialAllComplete = initialServices.length > 0 && initialServices.every((s) => isOperationalServiceStep(s.step));
|
|
492
|
+
const setupController = createSetupModeController({
|
|
493
|
+
keystoreExists: existsSync(masterKeystorePath),
|
|
494
|
+
allComplete: initialAllComplete,
|
|
495
|
+
});
|
|
496
|
+
const uiToken = ensureUiToken();
|
|
497
|
+
const handshakeKey = cryptoRandomBytes(16).toString('hex');
|
|
498
|
+
const apiBindHost = process.env['JINN_API_BIND_HOST'] ?? '127.0.0.1';
|
|
499
|
+
let corpusForApi;
|
|
500
|
+
let setupApiServer;
|
|
501
|
+
try {
|
|
502
|
+
setupApiServer = await startApiServer({
|
|
503
|
+
port: config.apiPort,
|
|
504
|
+
store: sharedStore,
|
|
505
|
+
apiToken,
|
|
506
|
+
bindHost: apiBindHost,
|
|
507
|
+
corpus: config.subgraphUrl?.trim() ? () => corpusForApi : undefined,
|
|
508
|
+
ui: { token: uiToken, handshakeKey },
|
|
509
|
+
admin: {
|
|
510
|
+
onRestartRequested: () => {
|
|
511
|
+
console.log('[main] Restart requested via operator MCP. Exiting...');
|
|
512
|
+
process.exit(0);
|
|
513
|
+
},
|
|
514
|
+
},
|
|
515
|
+
bootstrap: { earningDir: config.earningDir },
|
|
516
|
+
setup: {
|
|
517
|
+
earningDir: config.earningDir,
|
|
518
|
+
chain: NETWORK_CHAIN,
|
|
519
|
+
rpcUrl: config.rpcUrl,
|
|
520
|
+
minEoaGasWei: (CHAIN_CONFIG.minEoaGasEth * 2n).toString(),
|
|
521
|
+
},
|
|
522
|
+
status: {
|
|
523
|
+
earningDir: config.earningDir,
|
|
524
|
+
rpcUrl: config.rpcUrl,
|
|
525
|
+
network: config.network,
|
|
526
|
+
pollIntervalMs: config.pollIntervalMs,
|
|
527
|
+
masterEthDailyEstimateWei: config.masterEthDailyEstimateWei,
|
|
528
|
+
rewardClaimIntervalMs: config.rewardClaimIntervalMs,
|
|
529
|
+
testnetL2DeploymentPath: config.testnetL2DeploymentPath,
|
|
530
|
+
testnetL2TokenDeploymentPath: config.testnetL2TokenDeploymentPath,
|
|
531
|
+
testnetMechDeploymentPath: config.testnetMechDeploymentPath,
|
|
532
|
+
testnetStolasDeploymentPath: config.testnetStolasDeploymentPath,
|
|
533
|
+
testnetClaimRegistryDeploymentPath: config.testnetClaimRegistryDeploymentPath,
|
|
534
|
+
engine: config.engine,
|
|
535
|
+
},
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
catch (error) {
|
|
539
|
+
sharedStore.close();
|
|
540
|
+
const err = error;
|
|
541
|
+
if (err?.code === 'EADDRINUSE') {
|
|
542
|
+
emitEnvelope({
|
|
543
|
+
code: 'invalid_invocation',
|
|
544
|
+
message: `Port ${config.apiPort} is already in use. Stop the other daemon or set JINN_API_PORT / apiPort to another port.`,
|
|
545
|
+
hint: 'Set JINN_API_PORT to a free port, or stop the process currently listening on the dashboard/API port.',
|
|
546
|
+
exampleCli: 'JINN_API_PORT=7332 jinn run',
|
|
547
|
+
details: {
|
|
548
|
+
field: 'apiPort',
|
|
549
|
+
port: config.apiPort,
|
|
550
|
+
reason: 'EADDRINUSE',
|
|
551
|
+
},
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
throw error;
|
|
555
|
+
}
|
|
556
|
+
process.env['JINN_UI_HANDSHAKE_URL'] =
|
|
557
|
+
`http://127.0.0.1:${setupApiServer.port}/?k=${handshakeKey}`;
|
|
558
|
+
// Auto-open the operator panel as soon as the setup-mode API is up so the
|
|
559
|
+
// operator can watch bootstrap progress (including the funding wait, which
|
|
560
|
+
// is the whole point of starting the API early). Suppressed by setting
|
|
561
|
+
// JINN_NO_UI=1 — `jinn run --no-ui` translates the flag into this env var.
|
|
562
|
+
if (process.env['JINN_NO_UI'] !== '1') {
|
|
563
|
+
openBrowser(process.env['JINN_UI_HANDSHAKE_URL']);
|
|
564
|
+
}
|
|
565
|
+
console.log(`[main] Setup-mode API up (mode=${setupController.mode()}). ` +
|
|
566
|
+
`Dashboard: http://127.0.0.1:${setupApiServer.port}`);
|
|
567
|
+
// ── Operator agent WebSocket bridge ──────────────────────────────────────
|
|
568
|
+
// Mount /api/agent/ws on the same HTTP server so the SPA's xterm.js panel
|
|
569
|
+
// can attach to a long-lived embedded `claude` subprocess. The embedded
|
|
570
|
+
// session reads MCP config we materialise to disk so it can reach the
|
|
571
|
+
// operator MCP server (`jinn mcp`) for tool calls.
|
|
572
|
+
const operatorMcpConfigPath = join(homedir(), '.jinn-client', 'operator-mcp-config.json');
|
|
573
|
+
try {
|
|
574
|
+
mkdirSync(dirname(operatorMcpConfigPath), { recursive: true });
|
|
575
|
+
writeFileSyncMain(operatorMcpConfigPath, JSON.stringify({
|
|
576
|
+
mcpServers: {
|
|
577
|
+
'jinn-operator': {
|
|
578
|
+
command: 'jinn',
|
|
579
|
+
args: ['mcp'],
|
|
580
|
+
},
|
|
581
|
+
},
|
|
582
|
+
}, null, 2));
|
|
583
|
+
}
|
|
584
|
+
catch (err) {
|
|
585
|
+
console.warn(`[main] Failed to write operator MCP config at ${operatorMcpConfigPath}: ` +
|
|
586
|
+
(err instanceof Error ? err.message : String(err)));
|
|
587
|
+
}
|
|
588
|
+
attachAgentWs({
|
|
589
|
+
httpServer: setupApiServer.server,
|
|
590
|
+
uiToken,
|
|
591
|
+
claudePath: config.claudePath ?? 'claude',
|
|
592
|
+
cwd: process.cwd(),
|
|
593
|
+
mcpConfigPath: operatorMcpConfigPath,
|
|
594
|
+
});
|
|
595
|
+
console.log(`[main] Agent WS bridge mounted at ws://127.0.0.1:${setupApiServer.port}/api/agent/ws`);
|
|
596
|
+
// ── Init-if-missing ──────────────────────────────────────────────────────
|
|
597
|
+
// If the keystore is missing but we have a password, run `jinn init` now so
|
|
598
|
+
// bootstrap has something to decrypt. Idempotent: init is a no-op when the
|
|
599
|
+
// keystore already exists. This makes `jinn run` work first-time on a fresh
|
|
600
|
+
// host. We run AFTER startApiServer so the operator's panel can already
|
|
601
|
+
// render the loading screen / setup steps while init does its work — the
|
|
602
|
+
// /v1/bootstrap endpoint reports `mode:'uninitialized'` until init writes
|
|
603
|
+
// earning_state.json, then the panel transitions on the next 3s poll.
|
|
604
|
+
if (!existsSync(masterKeystorePath) && !existsSync(legacyKeystorePath)) {
|
|
605
|
+
emitProgress({
|
|
606
|
+
type: 'progress',
|
|
607
|
+
phase: 'init',
|
|
608
|
+
step: 'creating_wallet',
|
|
609
|
+
estimatedWaitMs: 2000,
|
|
610
|
+
});
|
|
611
|
+
emitStructured({ kind: 'system', message: 'creating wallet keystore' });
|
|
612
|
+
console.log('[main] No keystore found — initializing wallet from password.');
|
|
613
|
+
const initCmd = (await import('./cli/commands/init.js')).default;
|
|
614
|
+
let initExitCode = 0;
|
|
615
|
+
await initCmd.run({
|
|
616
|
+
argv: ['--json'],
|
|
617
|
+
stdoutIsTty: false,
|
|
618
|
+
writer: { write: (_s) => true }, // discard init's structured output
|
|
619
|
+
exit: (code) => {
|
|
620
|
+
initExitCode = code;
|
|
621
|
+
},
|
|
622
|
+
env: { ...process.env, JINN_PASSWORD: PASSWORD },
|
|
623
|
+
});
|
|
624
|
+
if (initExitCode !== 0) {
|
|
625
|
+
console.error('[main] init failed; cannot continue.');
|
|
626
|
+
await setupApiServer.close().catch(() => undefined);
|
|
627
|
+
sharedStore.close();
|
|
628
|
+
process.exit(initExitCode);
|
|
629
|
+
}
|
|
630
|
+
emitStructured({ kind: 'system', message: 'wallet keystore ready' });
|
|
631
|
+
// Refresh the controller so the panel's loading screen knows the
|
|
632
|
+
// keystore is on disk and we're transitioning into bootstrap.
|
|
633
|
+
setupController.refresh({ keystoreExists: true, allComplete: false });
|
|
634
|
+
}
|
|
635
|
+
let bootstrapResult;
|
|
636
|
+
try {
|
|
637
|
+
bootstrapResult = await bootstrap();
|
|
638
|
+
}
|
|
639
|
+
catch (err) {
|
|
640
|
+
// If bootstrap throws (vs. emitEnvelope-exits), tear down the API we
|
|
641
|
+
// just started so we don't leave a dangling listener on the port.
|
|
642
|
+
await setupApiServer.close().catch(() => undefined);
|
|
643
|
+
sharedStore.close();
|
|
644
|
+
throw err;
|
|
645
|
+
}
|
|
646
|
+
// Bootstrap completed — flip the controller into 'running' so any waiters
|
|
647
|
+
// (future loops gated on this) unblock.
|
|
648
|
+
setupController.refresh({ keystoreExists: true, allComplete: true });
|
|
649
|
+
// ── --no-daemon: exit cleanly after bootstrap completes ──────────────────
|
|
650
|
+
// `jinn run --no-daemon` flips JINN_NO_DAEMON=1 in run.ts. Emit a JSON
|
|
651
|
+
// summary on stdout and exit 0 so CI / agent flows can stop after the
|
|
652
|
+
// bootstrap state machine reaches 'complete' without paying for the
|
|
653
|
+
// long-lived daemon.
|
|
654
|
+
// We close the setup-mode API server here because its listening socket
|
|
655
|
+
// would otherwise hold the event loop open and prevent process exit.
|
|
656
|
+
if (process.env['JINN_NO_DAEMON'] === '1') {
|
|
657
|
+
console.log('[main] --no-daemon: bootstrap complete, exiting before daemon loops.');
|
|
658
|
+
await setupApiServer.close().catch(() => undefined);
|
|
659
|
+
sharedStore.close();
|
|
660
|
+
const summary = {
|
|
661
|
+
schemaVersion: 1,
|
|
662
|
+
generatedAt: new Date().toISOString(),
|
|
663
|
+
verb: 'run',
|
|
664
|
+
status: 'ready',
|
|
665
|
+
masterAddress: bootstrapResult.masterAddress,
|
|
666
|
+
dashboardUrl: `http://127.0.0.1:${config.apiPort}`,
|
|
667
|
+
};
|
|
668
|
+
process.stdout.write(JSON.stringify(summary) + '\n');
|
|
669
|
+
process.exit(0);
|
|
670
|
+
}
|
|
671
|
+
const { agentPrivateKey, masterAddress, safeAddress, mechAddress, serviceIndex, serviceId, stakingAddress, agentId, identityRegistryAddress, } = bootstrapResult;
|
|
218
672
|
if (!mechAddress) {
|
|
219
673
|
emitEnvelope({
|
|
220
674
|
code: 'fatal',
|
|
@@ -227,19 +681,6 @@ export async function main() {
|
|
|
227
681
|
},
|
|
228
682
|
});
|
|
229
683
|
}
|
|
230
|
-
const adapter = new MechAdapter({
|
|
231
|
-
rpcUrl: config.rpcUrl,
|
|
232
|
-
mechMarketplaceAddress: MARKETPLACE_ADDRESS,
|
|
233
|
-
routerAddress: ROUTER_ADDRESS,
|
|
234
|
-
mechContractAddress: mechAddress,
|
|
235
|
-
safeAddress,
|
|
236
|
-
agentEoaPrivateKey: agentPrivateKey,
|
|
237
|
-
ipfsRegistryUrl: config.ipfsRegistryUrl,
|
|
238
|
-
ipfsGatewayUrl: config.ipfsGatewayUrl,
|
|
239
|
-
pollIntervalMs: config.pollIntervalMs,
|
|
240
|
-
chainId: config.network === 'testnet' ? 84532 : 8453,
|
|
241
|
-
routerClaimDeliveryVariant: CHAIN_CONFIG.routerClaimDeliveryVersion,
|
|
242
|
-
});
|
|
243
684
|
const preflight = await checkClaudeBinary(config.claudePath);
|
|
244
685
|
if (!preflight.ok) {
|
|
245
686
|
emitClaudeBinaryPreflightFailure(preflight.detail, config.claudePath);
|
|
@@ -268,26 +709,154 @@ export async function main() {
|
|
|
268
709
|
const masterAccount = deriveMasterSigner(mnemonicForMaster);
|
|
269
710
|
const publicClient = createJinnPublicClient(config.rpcUrl, NETWORK_CHAIN);
|
|
270
711
|
const masterWallet = createJinnWalletClient(config.rpcUrl, NETWORK_CHAIN, masterAccount);
|
|
712
|
+
const evictionRecovery = config.stakingMode === 'standard' &&
|
|
713
|
+
serviceId !== null &&
|
|
714
|
+
stakingAddress &&
|
|
715
|
+
CHAIN_CONFIG.distributorAddress
|
|
716
|
+
? {
|
|
717
|
+
serviceId,
|
|
718
|
+
stakingProxyAddress: stakingAddress,
|
|
719
|
+
distributorAddress: CHAIN_CONFIG.distributorAddress,
|
|
720
|
+
masterWalletClient: masterWallet,
|
|
721
|
+
}
|
|
722
|
+
: undefined;
|
|
723
|
+
const adapter = new MechAdapter({
|
|
724
|
+
rpcUrl: config.rpcUrl,
|
|
725
|
+
mechMarketplaceAddress: MARKETPLACE_ADDRESS,
|
|
726
|
+
routerAddress: ROUTER_ADDRESS,
|
|
727
|
+
mechContractAddress: mechAddress,
|
|
728
|
+
safeAddress,
|
|
729
|
+
agentEoaPrivateKey: agentPrivateKey,
|
|
730
|
+
ipfsRegistryUrl: config.ipfsRegistryUrl,
|
|
731
|
+
ipfsGatewayUrl: config.ipfsGatewayUrl,
|
|
732
|
+
pollIntervalMs: config.pollIntervalMs,
|
|
733
|
+
chainId: config.network === 'testnet' ? 84532 : 8453,
|
|
734
|
+
routerClaimDeliveryVariant: CHAIN_CONFIG.routerClaimDeliveryVersion,
|
|
735
|
+
evictionRecovery,
|
|
736
|
+
});
|
|
271
737
|
// ── RestorationEngine wiring ─────────────────────────────────────────────────
|
|
272
738
|
// Build agent viem clients (same creds as MechAdapter uses internally).
|
|
739
|
+
const viemChains = await import('viem/chains');
|
|
273
740
|
const agentChain = config.network === 'testnet'
|
|
274
|
-
?
|
|
275
|
-
:
|
|
741
|
+
? viemChains.baseSepolia
|
|
742
|
+
: viemChains.base;
|
|
743
|
+
const l1Chain = config.jinnL1Network === 'sepolia' ? viemChains.sepolia : viemChains.mainnet;
|
|
744
|
+
const agentChainContracts = agentChain.contracts;
|
|
745
|
+
const optimismPortalAddress = agentChainContracts?.portal?.[l1Chain.id]?.address;
|
|
746
|
+
const disputeGameFactoryAddress = agentChainContracts?.disputeGameFactory?.[l1Chain.id]?.address;
|
|
747
|
+
const l2ProofClient = config.l2ProofRpcUrl
|
|
748
|
+
? createJinnPublicClient(config.l2ProofRpcUrl, NETWORK_CHAIN)
|
|
749
|
+
: undefined;
|
|
276
750
|
const agentClients = createClients(config.rpcUrl, agentPrivateKey, agentChain);
|
|
751
|
+
// ── L1 (Sepolia / Ethereum mainnet) clients for cross-chain JINN claim loop ──
|
|
752
|
+
// Uses the agent EOA because MockMessenger.owner is the agent on testnet.
|
|
753
|
+
// Same key as L2; only the chain differs.
|
|
754
|
+
const l1ClientsForJinnClaim = JINN_MVI_CONFIG.distributor && config.ethereumRpcUrl
|
|
755
|
+
? {
|
|
756
|
+
public: createJinnL1PublicClient(config.ethereumRpcUrl, config.jinnL1Network),
|
|
757
|
+
wallet: createJinnL1WalletClient(config.ethereumRpcUrl, config.jinnL1Network, privateKeyToAccount(agentPrivateKey)),
|
|
758
|
+
}
|
|
759
|
+
: undefined;
|
|
760
|
+
if (l1ClientsForJinnClaim) {
|
|
761
|
+
console.log(`[main] JinnClaimLoop: enabled (mode=${JINN_CLAIM_MESSENGER_MODE}, ` +
|
|
762
|
+
`interval=${config.jinnClaimLoopIntervalMs}ms, distributor=${JINN_MVI_CONFIG.distributor}, ` +
|
|
763
|
+
`emitter=${JINN_MVI_CONFIG.claimEmitter})`);
|
|
764
|
+
}
|
|
765
|
+
else {
|
|
766
|
+
console.log(`[main] JinnClaimLoop: disabled (JinnDistributor artifact/override or JINN_ETHEREUM_RPC_URL not set)`);
|
|
767
|
+
}
|
|
277
768
|
// ── Impl registry ────────────────────────────────────────────────────────────
|
|
278
769
|
// Default-disable impls with external dependencies the operator must opt
|
|
279
770
|
// into (see cli/intent-registry-access.ts). The user's
|
|
280
771
|
// `config.restorers.disabled[]` fully overrides this default when present,
|
|
281
772
|
// so `jinn intents enable <kind>` persists the opt-in by writing to that
|
|
282
773
|
// list in ~/.jinn-client/config.json.
|
|
283
|
-
|
|
774
|
+
//
|
|
775
|
+
// wrapWith: defaults to 'claude-code-learner' so the learning envelope
|
|
776
|
+
// wraps every restoration kind out of the box (jinn-mono-0k2). Operators
|
|
777
|
+
// benchmarking or running raw specialist behaviour set
|
|
778
|
+
// `restorers.wrapWith: null` (or omit, when no other restorers config
|
|
779
|
+
// exists) to dispatch directly to specialists.
|
|
780
|
+
const { DEFAULT_DISABLED_IMPLS, DEFAULT_BY_KIND, DEFAULT_WRAP_WITH } = await import('./cli/intent-registry-access.js');
|
|
284
781
|
const implRegistry = new RestorerImplRegistry({
|
|
285
782
|
byKind: { ...DEFAULT_BY_KIND },
|
|
286
783
|
default: 'legacy-claude',
|
|
287
784
|
disabled: [...DEFAULT_DISABLED_IMPLS],
|
|
785
|
+
wrapWith: DEFAULT_WRAP_WITH,
|
|
288
786
|
...(config.restorers ?? {}),
|
|
289
787
|
});
|
|
788
|
+
// Load operator-supplied external restorer impls (Path 2 plug-in surface).
|
|
789
|
+
// Each entry in `config.restorers.externalImpls` is verified against
|
|
790
|
+
// `config.trustedImplSigners` before its factory is invoked. Failed loads
|
|
791
|
+
// are logged + skipped — they don't bring down the daemon.
|
|
792
|
+
const externalImpls = [];
|
|
793
|
+
const trustedSigners = config.trustedImplSigners ?? [];
|
|
794
|
+
const externalEntries = config.restorers?.externalImpls ?? [];
|
|
795
|
+
if (externalEntries.length > 0) {
|
|
796
|
+
for (const entry of externalEntries) {
|
|
797
|
+
const result = await loadExternalImpl({
|
|
798
|
+
entry: {
|
|
799
|
+
name: entry.name,
|
|
800
|
+
entry: entry.entry,
|
|
801
|
+
package: entry.package,
|
|
802
|
+
version: entry.version,
|
|
803
|
+
},
|
|
804
|
+
trustedSigners,
|
|
805
|
+
env: {
|
|
806
|
+
implName: entry.name,
|
|
807
|
+
implVersion: '0.0.0', // overridden by manifest validation below
|
|
808
|
+
network: config.network,
|
|
809
|
+
implStateDir: join(config.engine.implStateDirRoot, entry.name),
|
|
810
|
+
secrets: Object.freeze({}),
|
|
811
|
+
log: ({ level, msg, data }) => console.log(`[external-impl:${entry.name}] [${level}] ${msg}`, data ?? ''),
|
|
812
|
+
stub: false,
|
|
813
|
+
},
|
|
814
|
+
});
|
|
815
|
+
if (result.kind === 'ok') {
|
|
816
|
+
externalImpls.push(result.impl);
|
|
817
|
+
console.log(`[main] Loaded external impl: ${result.impl.name}@${result.impl.version}`);
|
|
818
|
+
}
|
|
819
|
+
else {
|
|
820
|
+
console.warn(`[main] Failed to load external impl ${entry.name}: ${result.reason}` +
|
|
821
|
+
(result.detail ? ` (${result.detail})` : ''));
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
// ── Path 1 plug-ins (claude-code-learner slot registry) ──────────────────────
|
|
826
|
+
// Load operator-installed Path 1 plug-ins from `config.learnerPlugIns[]`,
|
|
827
|
+
// assemble the in-memory slot registry, and serialise it for hand-off to
|
|
828
|
+
// the learner shim (which forwards via env to the spawned harness).
|
|
829
|
+
// See spec/2026-04-30-plug-in-surface.md §4.
|
|
830
|
+
let slotRegistryJson;
|
|
831
|
+
const learnerPlugIns = config.learnerPlugIns ?? [];
|
|
832
|
+
if (learnerPlugIns.length > 0) {
|
|
833
|
+
const { loadPlugIns, serialiseRegistry } = await import('./restorer/plug-ins/index.js');
|
|
834
|
+
// Read the bundled claude-code-learner version from its plugin.json.
|
|
835
|
+
// main.ts is at client/src/main.ts (src) or client/dist/main.js (compiled);
|
|
836
|
+
// probe both relative locations so the same code works in both contexts.
|
|
837
|
+
const __mainDir = dirname(fileURLToPath(import.meta.url));
|
|
838
|
+
const pluginJsonSrc = join(__mainDir, '../plugins/claude-code-learner/.claude-plugin/plugin.json');
|
|
839
|
+
const pluginJsonDist = join(__mainDir, '../../plugins/claude-code-learner/.claude-plugin/plugin.json');
|
|
840
|
+
const pluginJsonPath = existsSync(pluginJsonSrc) ? pluginJsonSrc : pluginJsonDist;
|
|
841
|
+
const learnerVersion = JSON.parse(readFileSync(pluginJsonPath, 'utf8')).version;
|
|
842
|
+
const result = await loadPlugIns({
|
|
843
|
+
entries: learnerPlugIns,
|
|
844
|
+
learnerVersion,
|
|
845
|
+
});
|
|
846
|
+
for (const w of result.warnings)
|
|
847
|
+
console.warn(`[plug-ins] ${w}`);
|
|
848
|
+
for (const e of result.errors)
|
|
849
|
+
console.error(`[plug-ins] ${e.plugInName}: ${e.reason}`);
|
|
850
|
+
slotRegistryJson = JSON.stringify(serialiseRegistry(result.registry, learnerVersion));
|
|
851
|
+
console.log(`[main] Loaded ${learnerPlugIns.length - result.errors.length}/${learnerPlugIns.length} Path 1 plug-in(s)`);
|
|
852
|
+
}
|
|
290
853
|
// legacy-claude: wraps ClaudeRunner; handles spec=undefined (health-check) intents
|
|
854
|
+
const corpusEnv = config.subgraphUrl?.trim()
|
|
855
|
+
? {
|
|
856
|
+
subgraphUrl: config.subgraphUrl,
|
|
857
|
+
ipfsGatewayUrl: config.ipfsGatewayUrl,
|
|
858
|
+
}
|
|
859
|
+
: undefined;
|
|
291
860
|
for (const impl of buildRestorerImpls({
|
|
292
861
|
rpcUrl: config.rpcUrl,
|
|
293
862
|
archiveRpcUrl: config.archiveRpcUrl,
|
|
@@ -298,18 +867,45 @@ export async function main() {
|
|
|
298
867
|
runner,
|
|
299
868
|
storePath: config.dbPath,
|
|
300
869
|
daemonApiUrl: `http://127.0.0.1:${config.apiPort}`,
|
|
870
|
+
daemonApiToken: apiToken,
|
|
301
871
|
implStateDirRoot: config.engine.implStateDirRoot,
|
|
872
|
+
externalImpls,
|
|
873
|
+
disabledNames: config.restorers?.disabled,
|
|
874
|
+
slotRegistryJson,
|
|
875
|
+
corpusEnv,
|
|
302
876
|
})) {
|
|
303
877
|
implRegistry.register(impl);
|
|
304
878
|
}
|
|
305
879
|
console.log(`[main] RestorerImplRegistry: ${implRegistry.list().map(i => i.name).join(', ')}`);
|
|
306
880
|
// ── Engine deps ───────────────────────────────────────────────────────────────
|
|
307
|
-
// Packaging deps:
|
|
881
|
+
// Packaging deps: artifact bytes are written to served_artifacts (operator-local
|
|
882
|
+
// SQLite) and served via the operator's HTTP server with x402 gating per
|
|
883
|
+
// spec/2026-04-30-phase-a-umbrella.md §1. IPFS only holds the manifest envelope.
|
|
884
|
+
// The `store` field is filled by Daemon (which owns the SQLite handle); here
|
|
885
|
+
// we just configure the endpoint + price defaults from `config.operator`
|
|
886
|
+
// (Phase 3, jinn-mono-vy37.1.3). Operators who don't declare an operator
|
|
887
|
+
// block fall back to the daemon's local API port so dev/test runs still work
|
|
888
|
+
// — but the resulting envelopes won't be reachable from outside the host.
|
|
889
|
+
const operatorPublicEndpoint = config.operator?.publicEndpoint ?? `http://localhost:${config.apiPort}`;
|
|
890
|
+
const operatorDefaultPrice = config.operator?.defaultPriceUsdc ?? '0';
|
|
891
|
+
const operatorPerTypePrice = config.operator?.perArtifactTypePrice ?? {};
|
|
892
|
+
if (!config.operator?.publicEndpoint) {
|
|
893
|
+
console.warn('[main] config.operator.publicEndpoint not set; defaulting to local API port. ' +
|
|
894
|
+
'External evaluators will not be able to fetch artifacts from this operator. ' +
|
|
895
|
+
'Set operator.publicEndpoint (or JINN_OPERATOR_PUBLIC_ENDPOINT) before going live.');
|
|
896
|
+
}
|
|
308
897
|
const packagingDeps = {
|
|
309
|
-
|
|
898
|
+
operatorEndpoint: operatorPublicEndpoint,
|
|
899
|
+
defaultPriceUsdc: operatorDefaultPrice,
|
|
900
|
+
perArtifactTypePrice: operatorPerTypePrice,
|
|
310
901
|
};
|
|
311
|
-
|
|
312
|
-
|
|
902
|
+
const operatorConfig = {
|
|
903
|
+
publicEndpoint: operatorPublicEndpoint,
|
|
904
|
+
defaultPriceUsdc: operatorDefaultPrice,
|
|
905
|
+
perArtifactTypePrice: operatorPerTypePrice,
|
|
906
|
+
};
|
|
907
|
+
// Envelope assembly deps: sign envelopes with agent EOA private key
|
|
908
|
+
const envelopeDeps = {
|
|
313
909
|
ipfsRegistryUrl: config.ipfsRegistryUrl,
|
|
314
910
|
agentEoaPrivateKey: agentPrivateKey,
|
|
315
911
|
safeAddress,
|
|
@@ -322,6 +918,7 @@ export async function main() {
|
|
|
322
918
|
mechContractAddress: mechAddress,
|
|
323
919
|
routerAddress: ROUTER_ADDRESS,
|
|
324
920
|
claimDeliveryVariant: CHAIN_CONFIG.routerClaimDeliveryVersion,
|
|
921
|
+
evictionRecovery,
|
|
325
922
|
};
|
|
326
923
|
// Claim deps: use the network default when bundled, with env override for
|
|
327
924
|
// emergency redeploys or custom test deployments.
|
|
@@ -340,13 +937,85 @@ export async function main() {
|
|
|
340
937
|
else {
|
|
341
938
|
console.log('[main] ClaimRegistry: not configured (claim step will use NotImplementedError fallback)');
|
|
342
939
|
}
|
|
940
|
+
// ── IdentityPublisher (jinn-mono-3zk) ───────────────────────────────────────
|
|
941
|
+
//
|
|
942
|
+
// When the bootstrap has minted an ERC-8004 IdentityRegistry NFT for the
|
|
943
|
+
// active service (agent_id non-null) AND we know the registry address, wire
|
|
944
|
+
// an IdentityPublisher so the engine anchors each envelope under the
|
|
945
|
+
// operator's agent NFT via setMetadata. Otherwise log a warning — publishing
|
|
946
|
+
// is disabled until bootstrap completes that step (jinn-mono-j07).
|
|
947
|
+
let identityPublisher;
|
|
948
|
+
if (agentId && identityRegistryAddress) {
|
|
949
|
+
const { IdentityPublisher } = await import('./erc8004/index.js');
|
|
950
|
+
identityPublisher = new IdentityPublisher({
|
|
951
|
+
identityRegistryAddress,
|
|
952
|
+
agentId: BigInt(agentId),
|
|
953
|
+
walletClient: agentClients.walletClient,
|
|
954
|
+
publicClient: agentClients.publicClient,
|
|
955
|
+
});
|
|
956
|
+
console.log(`[main] IdentityPublisher: agentId=${agentId} registry=${identityRegistryAddress}`);
|
|
957
|
+
}
|
|
958
|
+
else {
|
|
959
|
+
console.log('[main] IdentityPublisher: disabled (no agent_id on active service — re-run bootstrap to mint the operator agent NFT)');
|
|
960
|
+
}
|
|
961
|
+
// ── Reputation feedback hook (jinn-mono-yg4) ──────────────────────────────
|
|
962
|
+
//
|
|
963
|
+
// After the evaluator's claimDelivery succeeds, the engine fires
|
|
964
|
+
// `ReputationRegistry.giveFeedback(restorerAgentId, …)` so the restorer's
|
|
965
|
+
// agent NFT accrues a rating (DR §4.3). This requires:
|
|
966
|
+
//
|
|
967
|
+
// 1. A `ReputationRegistryClient` for the active chain. We use the
|
|
968
|
+
// canonical 0x8004… deployment; writes route through the operator's
|
|
969
|
+
// Safe so `msg.sender` matches the OLAS staking + 8004 IdentityRegistry
|
|
970
|
+
// identity.
|
|
971
|
+
// 2. An agentId resolver — looks up the restorer's agentId from the
|
|
972
|
+
// parent manifest's evidenceHash via the subgraph. When `subgraphUrl`
|
|
973
|
+
// is unconfigured the resolver returns null cleanly and the hook
|
|
974
|
+
// becomes a no-op (defensive: feedback is non-fatal).
|
|
975
|
+
//
|
|
976
|
+
// Skipped when the operator hasn't minted an agent NFT yet (matches the
|
|
977
|
+
// IdentityPublisher gating above).
|
|
978
|
+
let reputationFeedback;
|
|
979
|
+
if (agentId) {
|
|
980
|
+
const { getReputationRegistryAddress, ReputationRegistryClient } = await import('./erc8004/index.js');
|
|
981
|
+
const chainId = config.network === 'testnet' ? 84532 : 8453;
|
|
982
|
+
const reputationRegistryAddress = getReputationRegistryAddress(chainId);
|
|
983
|
+
if (reputationRegistryAddress) {
|
|
984
|
+
const reputationClient = new ReputationRegistryClient({
|
|
985
|
+
reputationRegistryAddress,
|
|
986
|
+
publicClient: agentClients.publicClient,
|
|
987
|
+
walletClient: agentClients.walletClient,
|
|
988
|
+
safeAddress,
|
|
989
|
+
});
|
|
990
|
+
const { resolveAgentIdForManifest } = await import('./erc8004/index.js');
|
|
991
|
+
const subgraphUrl = config.subgraphUrl;
|
|
992
|
+
reputationFeedback = {
|
|
993
|
+
client: reputationClient,
|
|
994
|
+
resolveAgentId: (manifestHash) => resolveAgentIdForManifest({ manifestHash, subgraphUrl }),
|
|
995
|
+
};
|
|
996
|
+
console.log(`[main] ReputationFeedback: registry=${reputationRegistryAddress}${subgraphUrl ? ` subgraph=${subgraphUrl}` : ' (no subgraph configured — resolver always null)'}`);
|
|
997
|
+
}
|
|
998
|
+
else {
|
|
999
|
+
console.log(`[main] ReputationFeedback: disabled (no canonical ReputationRegistry deployed on chainId=${chainId})`);
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
else {
|
|
1003
|
+
console.log('[main] ReputationFeedback: disabled (no agent_id on active service — same gating as IdentityPublisher)');
|
|
1004
|
+
}
|
|
343
1005
|
// ── Auto-intent generators (testnet only, opt-out via env) ─────────────────
|
|
344
1006
|
const autoIntentsDisabled = process.env['JINN_DISABLE_AUTO_INTENTS'] === '1';
|
|
1007
|
+
const { privateKeyToAccount: _pkToAccount } = await import('viem/accounts');
|
|
1008
|
+
const agentEoaAddress = _pkToAccount(agentPrivateKey).address;
|
|
345
1009
|
const { generators: autoIntentGenerators, logLines: autoIntentLogLines } = collectTestnetAutoIntentGenerators({
|
|
346
1010
|
network: config.network,
|
|
347
1011
|
rpcUrl: config.rpcUrl,
|
|
348
1012
|
autoIntentsDisabled,
|
|
349
1013
|
env: process.env,
|
|
1014
|
+
agentEoa: agentEoaAddress,
|
|
1015
|
+
safeAddress,
|
|
1016
|
+
agentPrivateKey,
|
|
1017
|
+
predictionV0WindowMs: config.predictionV0WindowMs,
|
|
1018
|
+
predictionV0ResolveGapMs: config.predictionV0ResolveGapMs,
|
|
350
1019
|
});
|
|
351
1020
|
for (const line of autoIntentLogLines) {
|
|
352
1021
|
console.log(line);
|
|
@@ -358,17 +1027,42 @@ export async function main() {
|
|
|
358
1027
|
new StaticConfiguredIntentSource(config.desiredStates),
|
|
359
1028
|
...autoIntentGenerators.map(({ kind, generator }) => new GeneratedIntentSource(`generated:${kind}`, generator)),
|
|
360
1029
|
];
|
|
1030
|
+
// ── Corpus (daemon-side, jinn-mono-vy37.1.6) ─────────────────────────────
|
|
1031
|
+
//
|
|
1032
|
+
// Built once per daemon lifetime; the agent EOA private key stays in this
|
|
1033
|
+
// process's memory and never crosses into the MCP subprocess. The MCP
|
|
1034
|
+
// tool `acquire_artifact` proxies to `POST /v1/artifacts/acquire` instead.
|
|
1035
|
+
// Disabled when subgraphUrl is unset — the API route is then absent and
|
|
1036
|
+
// MCP falls back to local-only behaviour with a warning.
|
|
1037
|
+
const corpusFactory = config.subgraphUrl?.trim()
|
|
1038
|
+
? (store) => (corpusForApi = createCorpus({
|
|
1039
|
+
subgraphUrl: config.subgraphUrl,
|
|
1040
|
+
ipfsGatewayUrl: config.ipfsGatewayUrl,
|
|
1041
|
+
store,
|
|
1042
|
+
signer: { privateKey: agentPrivateKey },
|
|
1043
|
+
selfSafeAddress: safeAddress,
|
|
1044
|
+
}))
|
|
1045
|
+
: undefined;
|
|
1046
|
+
if (!corpusFactory) {
|
|
1047
|
+
console.warn('[main] Corpus disabled (config.subgraphUrl not set); ' +
|
|
1048
|
+
'MCP acquire_artifact / search_artifacts network branches will be unavailable.');
|
|
1049
|
+
}
|
|
361
1050
|
const daemon = new Daemon({
|
|
362
1051
|
adapter,
|
|
363
1052
|
runner,
|
|
364
1053
|
intentSources,
|
|
365
1054
|
dbPath: config.dbPath,
|
|
1055
|
+
store: sharedStore,
|
|
1056
|
+
apiServer: setupApiServer,
|
|
366
1057
|
pollIntervalMs: config.pollIntervalMs,
|
|
367
1058
|
apiPort: config.apiPort,
|
|
1059
|
+
apiBindHost,
|
|
1060
|
+
apiToken,
|
|
368
1061
|
peers: config.peers.length > 0 ? config.peers : undefined,
|
|
369
1062
|
subgraphUrl: config.subgraphUrl,
|
|
370
1063
|
nodeEndpoint: config.nodeEndpoint,
|
|
371
1064
|
creatorSafeAddress: safeAddress,
|
|
1065
|
+
corpusFactory,
|
|
372
1066
|
status: {
|
|
373
1067
|
earningDir: config.earningDir,
|
|
374
1068
|
rpcUrl: config.rpcUrl,
|
|
@@ -393,19 +1087,41 @@ export async function main() {
|
|
|
393
1087
|
distributorAddress: CHAIN_CONFIG.distributorAddress,
|
|
394
1088
|
}
|
|
395
1089
|
: undefined,
|
|
1090
|
+
jinnClaim: l1ClientsForJinnClaim &&
|
|
1091
|
+
JINN_MVI_CONFIG.claimEmitter &&
|
|
1092
|
+
JINN_MVI_CONFIG.messenger &&
|
|
1093
|
+
JINN_MVI_CONFIG.distributor &&
|
|
1094
|
+
config.jinnClaimLoopIntervalMs > 0
|
|
1095
|
+
? {
|
|
1096
|
+
intervalMs: config.jinnClaimLoopIntervalMs,
|
|
1097
|
+
l2Client: agentClients.publicClient,
|
|
1098
|
+
l2ProofClient,
|
|
1099
|
+
l2Wallet: agentClients.walletClient,
|
|
1100
|
+
l1Client: l1ClientsForJinnClaim.public,
|
|
1101
|
+
l1Wallet: l1ClientsForJinnClaim.wallet,
|
|
1102
|
+
store: earningStore,
|
|
1103
|
+
chain: NETWORK_CHAIN,
|
|
1104
|
+
claimEmitterAddress: JINN_MVI_CONFIG.claimEmitter,
|
|
1105
|
+
distributorAddress: JINN_MVI_CONFIG.distributor,
|
|
1106
|
+
messengerAddress: JINN_MVI_CONFIG.messenger,
|
|
1107
|
+
messengerMode: JINN_CLAIM_MESSENGER_MODE,
|
|
1108
|
+
optimismPortalAddress,
|
|
1109
|
+
disputeGameFactoryAddress,
|
|
1110
|
+
}
|
|
1111
|
+
: undefined,
|
|
396
1112
|
restorationEngine: {
|
|
397
|
-
// TODO(jinn-mono-cy4): RestorationEngineOptions has redundant registry+implRegistry
|
|
398
|
-
// fields. Engine refactor should consolidate to one. Locked in this PR.
|
|
399
|
-
registry: implRegistry,
|
|
400
1113
|
paths: {
|
|
401
1114
|
workingDirRoot: config.engine.workingDirRoot,
|
|
402
1115
|
implStateDirRoot: config.engine.implStateDirRoot,
|
|
403
1116
|
},
|
|
404
1117
|
claimDeps,
|
|
405
1118
|
packagingDeps,
|
|
406
|
-
|
|
1119
|
+
envelopeDeps,
|
|
407
1120
|
deliveryDeps,
|
|
408
1121
|
implRegistry,
|
|
1122
|
+
identityPublisher,
|
|
1123
|
+
reputationFeedback,
|
|
1124
|
+
operatorConfig,
|
|
409
1125
|
},
|
|
410
1126
|
balanceTopup: config.balanceTopupIntervalMs > 0
|
|
411
1127
|
? {
|
|
@@ -421,10 +1137,14 @@ export async function main() {
|
|
|
421
1137
|
}
|
|
422
1138
|
: undefined,
|
|
423
1139
|
});
|
|
424
|
-
// Graceful shutdown
|
|
1140
|
+
// Graceful shutdown — Daemon doesn't own the API server or Store in this
|
|
1141
|
+
// flow (they were created in setup-mode before bootstrap), so we close
|
|
1142
|
+
// them explicitly after Daemon.stop() completes.
|
|
425
1143
|
const shutdown = async (signal) => {
|
|
426
1144
|
console.log(`\n[main] Received ${signal}, shutting down...`);
|
|
427
1145
|
await daemon.stop();
|
|
1146
|
+
await setupApiServer.close().catch(() => undefined);
|
|
1147
|
+
sharedStore.close();
|
|
428
1148
|
console.log('[main] Shutdown complete.');
|
|
429
1149
|
process.exit(0);
|
|
430
1150
|
};
|
|
@@ -443,6 +1163,12 @@ export async function main() {
|
|
|
443
1163
|
}
|
|
444
1164
|
};
|
|
445
1165
|
process.on('exit', removePidfile);
|
|
1166
|
+
emitProgress({
|
|
1167
|
+
type: 'progress',
|
|
1168
|
+
phase: 'daemon',
|
|
1169
|
+
step: 'starting',
|
|
1170
|
+
estimatedWaitMs: 5000,
|
|
1171
|
+
});
|
|
446
1172
|
try {
|
|
447
1173
|
await daemon.start();
|
|
448
1174
|
}
|