@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
|
@@ -7,13 +7,17 @@
|
|
|
7
7
|
* Transition method bodies are stubs; subsequent tasks fill them in.
|
|
8
8
|
*/
|
|
9
9
|
import { join } from 'node:path';
|
|
10
|
+
import { randomUUID } from 'node:crypto';
|
|
10
11
|
import { IntentPersistence } from './persistence.js';
|
|
11
12
|
import { IntentState, MissingEvidenceHashError } from './state.js';
|
|
12
13
|
import { executeTwoLayerClaim, releaseClaimedNotStarted, } from './claim.js';
|
|
13
|
-
import { provisionWorkingDir, provisionImplStateDir, walkArtifacts, uploadArtifacts,
|
|
14
|
-
import {
|
|
14
|
+
import { provisionWorkingDir, provisionImplStateDir, walkArtifacts, uploadArtifacts, } from './packaging.js';
|
|
15
|
+
import { assembleAndSignEnvelope, } from './envelope-assembly.js';
|
|
15
16
|
import { deliverAndClaim, } from './delivery.js';
|
|
16
17
|
import { SkippableError } from '../types.js';
|
|
18
|
+
import { submitEvaluatorFeedback } from '../../erc8004/index.js';
|
|
19
|
+
import { TrajectoryCollector, emitTrajectory } from '../../trajectory/index.js';
|
|
20
|
+
import { buildInfo } from '../../build-info.js';
|
|
17
21
|
// ── Sentinel error ────────────────────────────────────────────────────────────
|
|
18
22
|
export class NotImplementedError extends Error {
|
|
19
23
|
transitionName;
|
|
@@ -26,29 +30,45 @@ export class NotImplementedError extends Error {
|
|
|
26
30
|
// ── RestorationEngine ─────────────────────────────────────────────────────────
|
|
27
31
|
export class RestorationEngine {
|
|
28
32
|
persistence;
|
|
29
|
-
registry;
|
|
30
33
|
paths;
|
|
31
34
|
claimDeps;
|
|
32
35
|
packagingDeps;
|
|
33
|
-
|
|
36
|
+
envelopeDeps;
|
|
34
37
|
deliveryDeps;
|
|
35
38
|
implRegistry;
|
|
36
|
-
|
|
39
|
+
identityPublisher;
|
|
40
|
+
reputationFeedback;
|
|
41
|
+
operatorConfig;
|
|
42
|
+
/** Local SQLite-backed store; used to emit `restoration-result` /
|
|
43
|
+
* `evaluation-verdict` artifact rows when a cycle completes via a
|
|
44
|
+
* deterministic impl (the legacy claude/MCP path writes them itself). */
|
|
45
|
+
store;
|
|
37
46
|
// Transient storage for impl output between runImpl and pack transitions.
|
|
38
47
|
// Keyed by requestId; cleared after successful pack.
|
|
39
48
|
implOutputs = new Map();
|
|
49
|
+
// Transient storage for trajectory collectors produced in runImpl.
|
|
50
|
+
// emitTrajectory is deferred to pack() so that artifact spans can be added
|
|
51
|
+
// before the trajectory is finalised and uploaded (Task 16 bidirectional linkage).
|
|
52
|
+
// Keyed by requestId; cleared after successful pack.
|
|
53
|
+
// Protected (not private) to allow test subclasses to inject collectors.
|
|
54
|
+
trajectoryCollectors = new Map();
|
|
55
|
+
// Transient storage for trajectory CID+sha256 refs produced by runImpl.
|
|
56
|
+
// Keyed by requestId; cleared after successful pack.
|
|
57
|
+
trajectoryRefs = new Map();
|
|
40
58
|
/** Set by stop(); causes runTickLoop to exit at the next iteration. */
|
|
41
59
|
stopped = false;
|
|
42
60
|
constructor(opts) {
|
|
43
61
|
this.persistence = new IntentPersistence(opts.store.db);
|
|
44
|
-
this.
|
|
62
|
+
this.store = opts.store;
|
|
45
63
|
this.paths = opts.paths;
|
|
46
64
|
this.claimDeps = opts.claimDeps;
|
|
47
65
|
this.packagingDeps = opts.packagingDeps;
|
|
48
|
-
this.
|
|
66
|
+
this.envelopeDeps = opts.envelopeDeps;
|
|
49
67
|
this.deliveryDeps = opts.deliveryDeps;
|
|
50
68
|
this.implRegistry = opts.implRegistry;
|
|
51
|
-
this.
|
|
69
|
+
this.identityPublisher = opts.identityPublisher;
|
|
70
|
+
this.reputationFeedback = opts.reputationFeedback;
|
|
71
|
+
this.operatorConfig = opts.operatorConfig;
|
|
52
72
|
}
|
|
53
73
|
// ── Public API ──────────────────────────────────────────────────────────────
|
|
54
74
|
/**
|
|
@@ -254,7 +274,10 @@ export class RestorationEngine {
|
|
|
254
274
|
throw new Error(reason);
|
|
255
275
|
}
|
|
256
276
|
if (impl.isReady) {
|
|
257
|
-
const status = await impl.isReady(
|
|
277
|
+
const status = await impl.isReady({
|
|
278
|
+
kind: intent.specKind,
|
|
279
|
+
type: intent.intentType ?? 'restoration',
|
|
280
|
+
});
|
|
258
281
|
if (!status.ready) {
|
|
259
282
|
const reason = `impl '${impl.name}' not ready: ${status.reason ?? 'unknown'}${status.nextStep?.cli ? ` — run \`${status.nextStep.cli}\`` : ''}`;
|
|
260
283
|
this.persistence.markFailed(intent.requestId, reason);
|
|
@@ -326,22 +349,25 @@ export class RestorationEngine {
|
|
|
326
349
|
async takePreSnapshot(intent) {
|
|
327
350
|
const workingDir = join(this.paths.workingDirRoot, intent.requestId);
|
|
328
351
|
// Resolve the impl via registry so implStateDir matches the path runImpl uses
|
|
329
|
-
// (join(implStateDirRoot, impl.name)). Falls back to specKind then 'default'
|
|
352
|
+
// (join(implStateDirRoot, impl.name, kind)). Falls back to specKind then 'default'
|
|
330
353
|
// when no impl is registered — legacy path preserved for health-check intents.
|
|
331
354
|
const resolvedImpl = intent.specKind
|
|
332
355
|
? this.implRegistry?.findFor({ kind: intent.specKind, type: intent.intentType ?? 'restoration' }) ?? null
|
|
333
356
|
: null;
|
|
334
357
|
const implStateName = intent.implName ?? resolvedImpl?.name ?? intent.specKind ?? 'default';
|
|
335
|
-
const
|
|
336
|
-
|
|
358
|
+
const kindSeg = (intent.specKind ?? '').replace(/[.:]/g, '_');
|
|
359
|
+
const implStateDir = kindSeg
|
|
360
|
+
? join(this.paths.implStateDirRoot, implStateName, kindSeg)
|
|
361
|
+
: join(this.paths.implStateDirRoot, implStateName);
|
|
362
|
+
// Prefer the persisted full RestorationJob; fall back to a stub for legacy
|
|
337
363
|
// (pre-migration) rows so the engine still works for health-check intents.
|
|
338
|
-
const
|
|
364
|
+
const restorationJob = intent.restorationJob ?? {
|
|
339
365
|
id: intent.requestId,
|
|
340
366
|
description: '',
|
|
341
367
|
...(intent.specKind ? { spec: { kind: intent.specKind } } : {}),
|
|
342
368
|
window: { startTs: intent.windowStartTs, endTs: intent.windowEndTs },
|
|
343
369
|
};
|
|
344
|
-
provisionWorkingDir(workingDir,
|
|
370
|
+
provisionWorkingDir(workingDir, restorationJob);
|
|
345
371
|
provisionImplStateDir(implStateDir);
|
|
346
372
|
// takePreSnapshot transitions directly to RUNNING with the snapshot payload
|
|
347
373
|
// and workingDir/implStateDir paths set. We cannot transition
|
|
@@ -374,14 +400,22 @@ export class RestorationEngine {
|
|
|
374
400
|
throw new NotImplementedError('runImpl');
|
|
375
401
|
}
|
|
376
402
|
const workingDir = intent.workingDir ?? join(this.paths.workingDirRoot, intent.requestId);
|
|
377
|
-
const
|
|
403
|
+
const kindSeg = specKind.replace(/[.:]/g, '_');
|
|
404
|
+
const implStateDir = intent.implStateDir ?? (kindSeg
|
|
405
|
+
? join(this.paths.implStateDirRoot, impl.name, kindSeg)
|
|
406
|
+
: join(this.paths.implStateDirRoot, impl.name));
|
|
378
407
|
const windowEndTs = intent.windowEndTs;
|
|
379
408
|
const abort = new AbortController();
|
|
380
409
|
const msUntilEndTs = () => Math.max(0, windowEndTs - Date.now());
|
|
381
410
|
const endTimer = setTimeout(() => abort.abort(), msUntilEndTs());
|
|
411
|
+
// Create a trajectory collector for this run.
|
|
412
|
+
const trajectory = new TrajectoryCollector({
|
|
413
|
+
intentCid: intent.intentCid ?? '',
|
|
414
|
+
runId: randomUUID(),
|
|
415
|
+
});
|
|
382
416
|
try {
|
|
383
417
|
const ctx = {
|
|
384
|
-
intent: (intent.
|
|
418
|
+
intent: (intent.restorationJob ?? {
|
|
385
419
|
id: intent.requestId,
|
|
386
420
|
description: '',
|
|
387
421
|
...(intent.specKind ? { spec: { kind: intent.specKind } } : {}),
|
|
@@ -395,6 +429,7 @@ export class RestorationEngine {
|
|
|
395
429
|
},
|
|
396
430
|
abort: abort.signal,
|
|
397
431
|
msUntilEndTs,
|
|
432
|
+
trajectory,
|
|
398
433
|
};
|
|
399
434
|
let output;
|
|
400
435
|
try {
|
|
@@ -424,6 +459,12 @@ export class RestorationEngine {
|
|
|
424
459
|
}
|
|
425
460
|
}
|
|
426
461
|
this.implOutputs.set(intent.requestId, output);
|
|
462
|
+
// Store the trajectory collector so pack() can:
|
|
463
|
+
// 1. pass it to uploadArtifacts (artifact.emit spans + producedBy metadata)
|
|
464
|
+
// 2. call emitTrajectory AFTER artifact upload so spans are included
|
|
465
|
+
// 3. backfill trajectoryCid on artifacts before envelope assembly
|
|
466
|
+
// emitTrajectory is intentionally deferred to pack() (Task 16).
|
|
467
|
+
this.trajectoryCollectors.set(intent.requestId, trajectory);
|
|
427
468
|
// Persist impl output BEFORE the state transition so that a crash after
|
|
428
469
|
// the transition (RUNNING → POST_SNAPSHOT) but before pack() runs will
|
|
429
470
|
// find the serialised output in the DB on restart. pack() will hydrate the
|
|
@@ -448,9 +489,9 @@ export class RestorationEngine {
|
|
|
448
489
|
}
|
|
449
490
|
/**
|
|
450
491
|
* PACKAGING transition: walk workingDir, upload artifacts, assemble + sign
|
|
451
|
-
*
|
|
492
|
+
* envelope, upload envelope, persist envelope CID + artifact CIDs.
|
|
452
493
|
*
|
|
453
|
-
* Requires packagingDeps +
|
|
494
|
+
* Requires packagingDeps + envelopeDeps. When absent, falls back to
|
|
454
495
|
* NotImplementedError.
|
|
455
496
|
*/
|
|
456
497
|
async pack(intent) {
|
|
@@ -468,61 +509,148 @@ export class RestorationEngine {
|
|
|
468
509
|
console.warn(`[restorer-engine] ${intent.requestId}: failed to hydrate implOutputsJson: ${err instanceof Error ? err.message : err}`);
|
|
469
510
|
}
|
|
470
511
|
}
|
|
471
|
-
if (!this.packagingDeps || !this.
|
|
512
|
+
if (!this.packagingDeps || !this.envelopeDeps) {
|
|
472
513
|
throw new NotImplementedError('pack');
|
|
473
514
|
}
|
|
474
515
|
const workingDir = intent.workingDir ?? join(this.paths.workingDirRoot, intent.requestId);
|
|
475
516
|
const implOutput = this.implOutputs.get(intent.requestId);
|
|
476
517
|
const implArtifacts = implOutput?.artifacts ?? [];
|
|
477
|
-
// 1. Walk + upload artifacts (NO registration yet — manifest CID not known)
|
|
518
|
+
// 1. Walk + upload artifacts (NO registration yet — manifest CID not known).
|
|
519
|
+
// Pass the trajectory collector (if present) so uploadArtifacts can emit
|
|
520
|
+
// jinn.artifact.emit spans and attach producedBy back-refs (Task 16 forward
|
|
521
|
+
// linkage). emitTrajectory is called AFTER upload so artifact spans are included.
|
|
522
|
+
const collector = this.trajectoryCollectors.get(intent.requestId);
|
|
523
|
+
const packagingDepsWithReq = {
|
|
524
|
+
...this.packagingDeps,
|
|
525
|
+
requestId: intent.requestId,
|
|
526
|
+
...(collector ? { collector } : {}),
|
|
527
|
+
};
|
|
478
528
|
const rawArtifacts = await walkArtifacts(workingDir, implArtifacts);
|
|
479
|
-
const uploadedArtifacts = await uploadArtifacts(rawArtifacts,
|
|
529
|
+
const uploadedArtifacts = await uploadArtifacts(rawArtifacts, packagingDepsWithReq);
|
|
530
|
+
// 1b. Emit trajectory to IPFS now that all artifact spans have been added.
|
|
531
|
+
// Non-fatal — envelope assembly continues with envelope.trajectory = null if upload fails.
|
|
532
|
+
let trajectoryRef = this.trajectoryRefs.get(intent.requestId) ?? null;
|
|
533
|
+
if (!trajectoryRef && collector && this.envelopeDeps) {
|
|
534
|
+
try {
|
|
535
|
+
const { privateKeyToAccount } = await import('viem/accounts');
|
|
536
|
+
const account = privateKeyToAccount(this.envelopeDeps.agentEoaPrivateKey);
|
|
537
|
+
const { cid, sha256 } = await emitTrajectory({
|
|
538
|
+
collector,
|
|
539
|
+
runId: collector.runId,
|
|
540
|
+
signerPrivateKey: this.envelopeDeps.agentEoaPrivateKey,
|
|
541
|
+
signerAddress: account.address,
|
|
542
|
+
ipfsRegistryUrl: this.envelopeDeps.ipfsRegistryUrl,
|
|
543
|
+
});
|
|
544
|
+
trajectoryRef = { cid, sha256 };
|
|
545
|
+
console.log(`[restorer-engine] ${intent.requestId}: trajectory emitted cid=${cid}`);
|
|
546
|
+
}
|
|
547
|
+
catch (err) {
|
|
548
|
+
console.warn(`[restorer-engine] ${intent.requestId}: trajectory emit failed (non-fatal):`, err instanceof Error ? err.message : err);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
this.trajectoryRefs.set(intent.requestId, trajectoryRef);
|
|
552
|
+
// 1c. Backward linkage: backfill trajectoryCid on all artifacts that have a
|
|
553
|
+
// producedBy back-ref. This must happen BEFORE assembleAndSignEnvelope so the
|
|
554
|
+
// signed envelope carries the complete reference (Task 16).
|
|
555
|
+
if (trajectoryRef) {
|
|
556
|
+
const trajectoryCid = trajectoryRef.cid;
|
|
557
|
+
for (const art of uploadedArtifacts) {
|
|
558
|
+
const pb = art.metadata?.['producedBy'];
|
|
559
|
+
if (pb != null && typeof pb === 'object' && 'spanId' in pb) {
|
|
560
|
+
pb['trajectoryCid'] = trajectoryCid;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
480
564
|
// Map to Artifact shape (strip localPath)
|
|
481
565
|
const artifacts = uploadedArtifacts.map(({ localPath: _localPath, ...art }) => art);
|
|
482
566
|
// 2. Derive agentEoa from private key
|
|
483
567
|
const { privateKeyToAccount } = await import('viem/accounts');
|
|
484
|
-
const account = privateKeyToAccount(this.
|
|
568
|
+
const account = privateKeyToAccount(this.envelopeDeps.agentEoaPrivateKey);
|
|
485
569
|
const agentEoa = account.address;
|
|
486
|
-
// Safe multisig address — sourced from
|
|
570
|
+
// Safe multisig address — sourced from envelopeDeps (preferred) or deliveryDeps.
|
|
487
571
|
// Hard throw if absent: falling back to agentEoa would produce a
|
|
488
|
-
// protocol-invalid
|
|
489
|
-
const safeAddress = this.
|
|
572
|
+
// protocol-invalid envelope (safeAddress MUST differ from agentEoa, §5.1).
|
|
573
|
+
const safeAddress = this.envelopeDeps.safeAddress ?? this.deliveryDeps?.safeAddress;
|
|
490
574
|
if (!safeAddress) {
|
|
491
|
-
throw new Error('pack: safeAddress not configured in
|
|
575
|
+
throw new Error('pack: safeAddress not configured in envelopeDeps or deliveryDeps');
|
|
492
576
|
}
|
|
493
|
-
// 3.
|
|
494
|
-
const provenance = {
|
|
495
|
-
intentCid: intent.intentCid,
|
|
496
|
-
onchainCreationTx: intent.onchainCreationTx,
|
|
497
|
-
onchainCreationBlock: intent.onchainCreationBlock,
|
|
498
|
-
requestId: intent.requestId,
|
|
499
|
-
safeAddress,
|
|
500
|
-
agentEoa,
|
|
501
|
-
windowStartTs: intent.windowStartTs,
|
|
502
|
-
windowEndTs: intent.windowEndTs,
|
|
503
|
-
};
|
|
577
|
+
// 3. Build envelope payload from impl output (kind-typed, wrapped into payload field)
|
|
504
578
|
const preSnapshotPayload = intent.preSnapshotPayload;
|
|
505
579
|
const postSnapshotPayload = intent.postSnapshotPayload;
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
580
|
+
// The specKind drives payload schema selection. Fall back to 'legacy.v0'
|
|
581
|
+
// for intents without a spec.kind (legacy health-check / daemon-loop-test
|
|
582
|
+
// intents that use the legacy-claude impl). The legacy.v0 kind accepts any
|
|
583
|
+
// Record payload so validatePayload does not reject the output.
|
|
584
|
+
const specKind = intent.specKind ?? 'legacy.v0';
|
|
585
|
+
// Derive role from intent type. Evaluator intents produce 'verdict' envelopes;
|
|
586
|
+
// all other intents produce 'restoration' envelopes.
|
|
587
|
+
const isEvaluation = intent.intentType === 'evaluation';
|
|
588
|
+
const role = isEvaluation ? 'verdict' : 'restoration';
|
|
589
|
+
let envelopePayload;
|
|
590
|
+
if (isEvaluation) {
|
|
591
|
+
// ── Verdict envelope payload ──────────────────────────────────────────────
|
|
592
|
+
// The evaluator impl populates verdictPayload on RestorationOutput with a
|
|
593
|
+
// PortfolioV0VerdictPayload-shaped object. Engine passes it through to the
|
|
594
|
+
// envelope assembler, which runs validatePayload('portfolio.v0', 'verdict', ...).
|
|
595
|
+
//
|
|
596
|
+
// If verdictPayload is absent (impl bug / crash recovery), fall back to a
|
|
597
|
+
// minimal INDETERMINATE stub so the envelope assembly does not silently succeed
|
|
598
|
+
// with a wrong shape — validatePayload will catch schema mismatches.
|
|
599
|
+
//
|
|
600
|
+
// verificationOfRestoration: stubbed — Plan D will connect the real SDK.
|
|
601
|
+
// restorationEnvelope.sha256: placeholder — Plan D wires real sha256 derivation.
|
|
602
|
+
const verdictPayload = implOutput?.verdictPayload;
|
|
603
|
+
if (!verdictPayload) {
|
|
604
|
+
throw new Error(`pack: evaluator impl for ${intent.requestId} did not produce verdictPayload on RestorationOutput; ` +
|
|
605
|
+
`ensure the impl populates output.verdictPayload`);
|
|
606
|
+
}
|
|
607
|
+
// If the (stub) verificationOfRestoration reports 'invalid', downgrade verdict
|
|
608
|
+
// to REJECTED per scope §3.3. For V1 the stub always returns 'valid', so this
|
|
609
|
+
// path does not fire in practice — Plan D makes it real.
|
|
610
|
+
const verif = verdictPayload['verificationOfRestoration'];
|
|
611
|
+
if (verif?.overall === 'invalid') {
|
|
612
|
+
// Override verdict to REJECTED; preserve the rest of the payload.
|
|
613
|
+
envelopePayload = {
|
|
614
|
+
...verdictPayload,
|
|
615
|
+
verdict: 'REJECTED',
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
else {
|
|
619
|
+
envelopePayload = verdictPayload;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
else if (implOutput?.restorationPayload) {
|
|
623
|
+
// ── Non-portfolio restoration envelope payload ────────────────────────────
|
|
624
|
+
// Impls for kinds with a non-portfolio payload schema (e.g. prediction.v0)
|
|
625
|
+
// declare their own fully-formed payload. Engine passes it through directly
|
|
626
|
+
// so validatePayload() can check it against the per-kind schema.
|
|
627
|
+
envelopePayload = implOutput.restorationPayload;
|
|
628
|
+
}
|
|
629
|
+
else {
|
|
630
|
+
// ── Portfolio restoration envelope payload (legacy / portfolio.v0) ─────────
|
|
631
|
+
envelopePayload = {
|
|
632
|
+
preSnapshot: {
|
|
633
|
+
capturedAt: intent.preSnapshotCapturedAt ?? Date.now(),
|
|
634
|
+
hlTime: preSnapshotPayload?.hlTime ?? 0,
|
|
635
|
+
// Double-fallback: first tries the structured .payload field (normal shape),
|
|
636
|
+
// then falls back to the whole payload object (handles takePreSnapshot's
|
|
637
|
+
// synthetic shape where the snapshot IS the top-level object, not nested).
|
|
638
|
+
payload: preSnapshotPayload?.payload ?? preSnapshotPayload ?? {},
|
|
639
|
+
},
|
|
640
|
+
postSnapshot: {
|
|
641
|
+
capturedAt: intent.postSnapshotCapturedAt ?? Date.now(),
|
|
642
|
+
hlTime: postSnapshotPayload?.hlTime ?? 0,
|
|
643
|
+
// Same double-fallback as above.
|
|
644
|
+
payload: postSnapshotPayload?.payload ?? postSnapshotPayload ?? {},
|
|
645
|
+
},
|
|
646
|
+
fills: intent.fillsPayload ?? [],
|
|
647
|
+
gating: intent.gatingClaim ?? {},
|
|
648
|
+
...(intent.informationalClaim != null
|
|
649
|
+
? { informational: intent.informationalClaim }
|
|
650
|
+
: {}),
|
|
651
|
+
...(implOutput?.rationale != null ? { rationale: implOutput.rationale } : {}),
|
|
652
|
+
};
|
|
653
|
+
}
|
|
526
654
|
// 4. Persist generatedAt once (first pack); reuse on retry for CID determinism.
|
|
527
655
|
const generatedAt = intent.manifestGeneratedAt ?? Date.now();
|
|
528
656
|
if (!intent.manifestGeneratedAt) {
|
|
@@ -530,54 +658,77 @@ export class RestorationEngine {
|
|
|
530
658
|
// transition still gets the same generatedAt on the next attempt.
|
|
531
659
|
this.persistence.setManifestGeneratedAt(intent.requestId, generatedAt);
|
|
532
660
|
}
|
|
533
|
-
|
|
534
|
-
//
|
|
535
|
-
|
|
536
|
-
//
|
|
537
|
-
|
|
538
|
-
//
|
|
539
|
-
//
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
.
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
661
|
+
// 5. Assemble + sign envelope → envelope CID now known.
|
|
662
|
+
// trajectoryRef was computed in step 1b above (emitted after artifact upload).
|
|
663
|
+
// Per the post-gating-fix schema, trajectory references carry sha256 + access
|
|
664
|
+
// (the operator HTTP endpoint that serves the bytes). Phase 3 (jinn-mono-vy37.1.3)
|
|
665
|
+
// sources this from the engine's operatorConfig; absent operatorConfig (e.g. test
|
|
666
|
+
// fixtures) falls back to packagingDeps.operatorEndpoint, then to a localhost
|
|
667
|
+
// sentinel so suites that don't exercise the publish path still pack cleanly.
|
|
668
|
+
const operatorEndpointForTraj = this.operatorConfig?.publicEndpoint
|
|
669
|
+
?? this.packagingDeps?.operatorEndpoint
|
|
670
|
+
?? 'http://localhost:7331';
|
|
671
|
+
const envelopeTrajectory = trajectoryRef
|
|
672
|
+
? {
|
|
673
|
+
sha256: trajectoryRef.sha256,
|
|
674
|
+
access: { endpoint: operatorEndpointForTraj, priceUsdc: '0' },
|
|
675
|
+
}
|
|
676
|
+
: null;
|
|
677
|
+
// evidenceTier reflects the on-chain commitment state at the time of signing.
|
|
678
|
+
// For the V2 claim flow, claimDelivery will write an evidenceHash on-chain,
|
|
679
|
+
// so the envelope should be declared 'committed'. For V1 or unknown flows,
|
|
680
|
+
// 'self-signed' is accurate (no on-chain hash commitment).
|
|
681
|
+
const evidenceTier = this.deliveryDeps?.claimDeliveryVariant === 'v2' ? 'committed' : 'self-signed';
|
|
682
|
+
const envelopeInputs = {
|
|
683
|
+
kind: specKind,
|
|
684
|
+
role,
|
|
685
|
+
intent: {
|
|
686
|
+
cid: intent.intentCid,
|
|
687
|
+
onchainCreationTx: intent.onchainCreationTx,
|
|
688
|
+
onchainCreationBlock: intent.onchainCreationBlock,
|
|
689
|
+
requestId: intent.requestId,
|
|
690
|
+
},
|
|
691
|
+
participant: { safeAddress, agentEoa },
|
|
692
|
+
window: { startTs: intent.windowStartTs, endTs: intent.windowEndTs },
|
|
693
|
+
executor: {
|
|
694
|
+
implName: intent.implName ?? specKind,
|
|
695
|
+
// buildInfo resolves to real values in production builds; falls back to
|
|
696
|
+
// clearly-labelled placeholders ('dev' / 'sha256:dev-build') when running
|
|
697
|
+
// via tsx without a prior `yarn build` (dev mode).
|
|
698
|
+
implVersion: buildInfo.implVersion,
|
|
699
|
+
clientGitSha: buildInfo.clientGitSha,
|
|
700
|
+
codeDigest: buildInfo.codeDigest,
|
|
701
|
+
signingKey: { kind: 'agent-eoa', pubkey: agentEoa },
|
|
702
|
+
},
|
|
703
|
+
evidenceTier,
|
|
704
|
+
trajectory: envelopeTrajectory,
|
|
705
|
+
artifacts,
|
|
706
|
+
payload: envelopePayload,
|
|
707
|
+
generatedAt,
|
|
708
|
+
};
|
|
709
|
+
const { envelopeCid, envelopeHash } = await assembleAndSignEnvelope(envelopeInputs, this.envelopeDeps);
|
|
710
|
+
const manifestCid = envelopeCid;
|
|
711
|
+
const signatureHash = envelopeHash;
|
|
712
|
+
// 6. ERC-8004 IdentityRegistry per-execution `setMetadata` fires in
|
|
713
|
+
// deliver() AFTER claimDelivery succeeds. 'committed' must mean
|
|
714
|
+
// "observable on-chain evidenceHash exists" — publishing before claim
|
|
715
|
+
// would lie during failures. The evidenceHash (signatureHash) is
|
|
716
|
+
// persisted to DELIVERING state below and reused by deliver().
|
|
717
|
+
// Operator-rooted entity model: docs/superpowers/specs/2026-04-27-erc-8004-entity-model-design.md.
|
|
718
|
+
// 7. Build artifact sha256 map for persistence.
|
|
719
|
+
// Post-gating-fix (spec §1): artifacts no longer have IPFS CIDs — bytes
|
|
720
|
+
// live in served_artifacts keyed by sha256. We reuse the legacy
|
|
721
|
+
// `artifactCids` persistence column (key: localPath) but populate it with
|
|
722
|
+
// sha256 hashes so downstream readers still get a stable identifier.
|
|
578
723
|
const artifactCids = {};
|
|
579
724
|
for (const art of uploadedArtifacts) {
|
|
580
|
-
artifactCids[art.localPath] = art.
|
|
725
|
+
artifactCids[art.localPath] = art.sha256;
|
|
726
|
+
}
|
|
727
|
+
// Backfill envelope_cid (manifestCid) on every served_artifacts row so
|
|
728
|
+
// the operator can answer manifest-rooted lookups later. Done after the
|
|
729
|
+
// manifest CID is known.
|
|
730
|
+
for (const art of uploadedArtifacts) {
|
|
731
|
+
this.store.setServedArtifactEnvelopeCid(art.sha256, manifestCid);
|
|
581
732
|
}
|
|
582
733
|
// 8. Persist DELIVERING with manifest CID + artifact CIDs + evidence hash.
|
|
583
734
|
// evidenceHash gets its own dedicated column (not stashed in informationalClaim).
|
|
@@ -587,8 +738,10 @@ export class RestorationEngine {
|
|
|
587
738
|
evidenceHash: signatureHash,
|
|
588
739
|
});
|
|
589
740
|
console.log(`[restorer-engine] ${intent.requestId} PACKAGING → DELIVERING manifestCid=${manifestCid}`);
|
|
590
|
-
// Clean up
|
|
741
|
+
// Clean up transient state (no longer needed after DELIVERING)
|
|
591
742
|
this.implOutputs.delete(intent.requestId);
|
|
743
|
+
this.trajectoryCollectors.delete(intent.requestId);
|
|
744
|
+
this.trajectoryRefs.delete(intent.requestId);
|
|
592
745
|
}
|
|
593
746
|
/**
|
|
594
747
|
* DELIVERING transition: call mech.deliverToMarketplace + JinnRouter.claimDelivery.
|
|
@@ -627,6 +780,234 @@ export class RestorationEngine {
|
|
|
627
780
|
deliveryTxHash,
|
|
628
781
|
});
|
|
629
782
|
console.log(`[restorer-engine] ${requestId} DELIVERING → COMPLETE deliveryTx=${deliveryTxHash} claimTx=${claimTxHash}`);
|
|
783
|
+
// Emit a SQLite artifact row so consumers (release acceptance gate, search
|
|
784
|
+
// API) see this cycle alongside legacy-claude / MCP-emitted rows. The
|
|
785
|
+
// legacy claude path writes via the MCP `submit_restoration_result` tool;
|
|
786
|
+
// deterministic impls (prediction-v0-baseline, prediction-v0-evaluator,
|
|
787
|
+
// …) don't go through MCP, so the engine emits on their behalf here.
|
|
788
|
+
// Idempotent: skips when a row for this requestId+tag already exists
|
|
789
|
+
// (legacy path may have already inserted).
|
|
790
|
+
this.emitCycleArtifact(intent, manifestCid, evidenceHash);
|
|
791
|
+
// ── ERC-8004 setMetadata — fires AFTER claimDelivery succeeds ────────────
|
|
792
|
+
//
|
|
793
|
+
// Moved here from pack() per PR#37 review2 must-fix #2. 'committed' means
|
|
794
|
+
// "observable on-chain evidenceHash exists" — publishing before claim would
|
|
795
|
+
// lie during failures. evidenceHash comes from intent (persisted in
|
|
796
|
+
// DELIVERING state by pack()); idempotent on retry (setMetadata is a pure
|
|
797
|
+
// key-value write; re-running with the same payload is safe).
|
|
798
|
+
//
|
|
799
|
+
// Restoration-only for now. Evaluator setMetadata lands with jinn-mono-2ff.
|
|
800
|
+
if (this.identityPublisher) {
|
|
801
|
+
const intentTypeRaw = intent.intentType ?? 'restoration';
|
|
802
|
+
if (intentTypeRaw === 'restoration') {
|
|
803
|
+
const signatureHash = evidenceHash;
|
|
804
|
+
// v0 tier rule: with an evidenceHash on chain we declare `committed` (tier=1);
|
|
805
|
+
// higher tiers (`attested`, `proved`) come later when TEE work lands.
|
|
806
|
+
const tier = signatureHash ? 1 : 0;
|
|
807
|
+
const setMetadataPayload = {
|
|
808
|
+
version: 1,
|
|
809
|
+
tier,
|
|
810
|
+
manifestHash: signatureHash ?? '0x',
|
|
811
|
+
attestationQuoteCid: '0x',
|
|
812
|
+
sourceMeasurement: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
813
|
+
};
|
|
814
|
+
try {
|
|
815
|
+
const pubTxHash = await this.identityPublisher.publishContent({
|
|
816
|
+
kind: 'envelope',
|
|
817
|
+
cid: manifestCid,
|
|
818
|
+
payload: setMetadataPayload,
|
|
819
|
+
});
|
|
820
|
+
console.log(`[restorer-engine] ${requestId}: setMetadata envelope:${manifestCid} tx=${pubTxHash}`);
|
|
821
|
+
}
|
|
822
|
+
catch (err) {
|
|
823
|
+
console.warn(`[restorer-engine] ${requestId}: setMetadata envelope publish failed (non-fatal): ${err instanceof Error ? err.message : err}`);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
// ── Reputation feedback hook (jinn-mono-yg4) ─────────────────────────────
|
|
828
|
+
//
|
|
829
|
+
// Evaluator-only path: after `claimDelivery` settles the verdict, fire
|
|
830
|
+
// `ReputationRegistry.giveFeedback(restorerAgentId, ...)` so the
|
|
831
|
+
// restorer's agent NFT accrues a rating (DR §4.3).
|
|
832
|
+
//
|
|
833
|
+
// Best-effort: any failure inside the hook is logged but does not
|
|
834
|
+
// change the COMPLETE state. claimDelivery is already authoritative.
|
|
835
|
+
if (intent.intentType === 'evaluation' && this.reputationFeedback) {
|
|
836
|
+
await this._maybePostEvaluatorFeedback(intent).catch((err) => {
|
|
837
|
+
console.warn(`[restorer-engine] ${requestId}: reputation feedback hook errored unexpectedly (non-fatal): ${err instanceof Error ? err.message : err}`);
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
* Post evaluator feedback on the restorer's agent NFT.
|
|
843
|
+
*
|
|
844
|
+
* Pulls the verdict from the persisted gating claim (the evaluator impl
|
|
845
|
+
* writes `{ verdict, score, scoreBasis, ... }` into `output.gating`),
|
|
846
|
+
* resolves the restorer's `agentId` via the configured subgraph
|
|
847
|
+
* resolver, and submits a single `ReputationRegistry.giveFeedback` tx.
|
|
848
|
+
*
|
|
849
|
+
* Skipped silently when:
|
|
850
|
+
* - No `reputationFeedback` deps wired.
|
|
851
|
+
* - `gatingClaim` doesn't carry a verdict (impl shape mismatch — log and
|
|
852
|
+
* return).
|
|
853
|
+
* - The parent restorer's manifest hash isn't reachable from the
|
|
854
|
+
* persisted state (legacy intents that pre-date evidenceHash
|
|
855
|
+
* threading — log and return).
|
|
856
|
+
* - `resolveAgentId` returns null (subgraph not indexed yet, or no
|
|
857
|
+
* subgraph URL configured at all — log and return).
|
|
858
|
+
*
|
|
859
|
+
* The mapping policy (PASS / FAIL / REJECTED / INDETERMINATE → score) lives
|
|
860
|
+
* inside `submitEvaluatorFeedback` / `mapVerdictToScore` in the
|
|
861
|
+
* feedback-hook module; we just hand it the verdict.
|
|
862
|
+
*/
|
|
863
|
+
/**
|
|
864
|
+
* Insert a SQLite `artifacts` row for a successfully delivered cycle so the
|
|
865
|
+
* release acceptance gate (and the search API) can observe completion via
|
|
866
|
+
* the same surface as the legacy claude / MCP path.
|
|
867
|
+
*
|
|
868
|
+
* The legacy `legacy-claude` impl writes via the MCP `submit_restoration_result`
|
|
869
|
+
* tool when Claude reports success; deterministic impls don't go through MCP.
|
|
870
|
+
* This emitter closes that gap by writing the row from the engine when the
|
|
871
|
+
* cycle hits COMPLETE.
|
|
872
|
+
*
|
|
873
|
+
* Idempotent: if a row already exists for (requestId, tag) — e.g. the legacy
|
|
874
|
+
* MCP path got there first — we leave it alone.
|
|
875
|
+
*/
|
|
876
|
+
emitCycleArtifact(intent, manifestCid, evidenceHash) {
|
|
877
|
+
const desiredStateId = intent.restorationJob?.id;
|
|
878
|
+
if (!desiredStateId) {
|
|
879
|
+
// Pre-migration intent rows had no desired_state_payload; the legacy
|
|
880
|
+
// path is the only thing that can emit artifacts for them, and it
|
|
881
|
+
// does so via MCP. Skip rather than synthesise an id.
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
884
|
+
const intentType = intent.intentType ?? 'restoration';
|
|
885
|
+
const tag = intentType === 'evaluation' ? 'evaluation-verdict' : 'restoration-result';
|
|
886
|
+
const existing = this.store.getArtifactByRequestId(intent.requestId, tag);
|
|
887
|
+
if (existing)
|
|
888
|
+
return;
|
|
889
|
+
this.store.insertArtifact({
|
|
890
|
+
id: randomUUID(),
|
|
891
|
+
desiredStateId,
|
|
892
|
+
requestId: intent.requestId,
|
|
893
|
+
title: `${tag}: ${intent.specKind ?? 'cycle'} (${intent.implName ?? 'engine'})`,
|
|
894
|
+
content: JSON.stringify({
|
|
895
|
+
manifestCid,
|
|
896
|
+
evidenceHash: evidenceHash ?? null,
|
|
897
|
+
implName: intent.implName,
|
|
898
|
+
}),
|
|
899
|
+
tags: [tag, 'success'],
|
|
900
|
+
outcome: 'SUCCESS',
|
|
901
|
+
});
|
|
902
|
+
}
|
|
903
|
+
async _maybePostEvaluatorFeedback(intent) {
|
|
904
|
+
if (!this.reputationFeedback)
|
|
905
|
+
return;
|
|
906
|
+
const gating = intent.gatingClaim;
|
|
907
|
+
const verdictRaw = gating?.['verdict'];
|
|
908
|
+
if (verdictRaw !== 'PASS' &&
|
|
909
|
+
verdictRaw !== 'FAIL' &&
|
|
910
|
+
verdictRaw !== 'REJECTED' &&
|
|
911
|
+
verdictRaw !== 'INDETERMINATE') {
|
|
912
|
+
console.warn(`[restorer-engine] ${intent.requestId}: reputation feedback skipped — gatingClaim has no recognised verdict (got=${String(verdictRaw)})`);
|
|
913
|
+
return;
|
|
914
|
+
}
|
|
915
|
+
const verdict = verdictRaw;
|
|
916
|
+
// Pull the parent restorer's manifest evidence from the inlined eval
|
|
917
|
+
// payload. The evaluator impl receives the restorer's signed manifest
|
|
918
|
+
// JSON via `intent.context.restorationResult` (see
|
|
919
|
+
// `MechAdapter.tryCreateEvaluationJob`). Its `signature.hash` is
|
|
920
|
+
// exactly what the restorer committed via `claimDelivery(evidenceHash)`.
|
|
921
|
+
const parent = this._extractRestorerManifestRef(intent);
|
|
922
|
+
if (!parent) {
|
|
923
|
+
console.warn(`[restorer-engine] ${intent.requestId}: reputation feedback skipped — could not extract restorer manifest hash from inlined evaluation payload`);
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
926
|
+
let resolved;
|
|
927
|
+
try {
|
|
928
|
+
resolved = await this.reputationFeedback.resolveAgentId(parent.evidenceHash);
|
|
929
|
+
}
|
|
930
|
+
catch (err) {
|
|
931
|
+
console.warn(`[restorer-engine] ${intent.requestId}: reputation feedback resolver threw (non-fatal): ${err instanceof Error ? err.message : err}`);
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
if (!resolved) {
|
|
935
|
+
console.log(`[restorer-engine] ${intent.requestId}: reputation feedback skipped — no agentId resolved for restorer manifestHash=${parent.evidenceHash} (subgraph not indexed yet, or no envelope published)`);
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
// CID resolution priority: subgraph row's `manifestCid` (cheapest, the
|
|
939
|
+
// operator already published an envelope under it), else the inlined
|
|
940
|
+
// CID hint when present, else fall back to the bare hash. The subgraph
|
|
941
|
+
// parses `manifest:<cid>` to a `manifestRef` regardless.
|
|
942
|
+
const manifestCid = resolved.manifestCid ?? parent.manifestCid ?? '';
|
|
943
|
+
// The intent kind is the same `spec.kind` used by the restoration —
|
|
944
|
+
// `intent.specKind` is "portfolio.v0" both for the restoration and its
|
|
945
|
+
// evaluation. Tag1 is indexed on the on-chain event, so cheap to filter.
|
|
946
|
+
const kind = intent.specKind ?? undefined;
|
|
947
|
+
const verdictArg = kind ? { verdict, kind } : { verdict };
|
|
948
|
+
let outcome;
|
|
949
|
+
try {
|
|
950
|
+
outcome = await submitEvaluatorFeedback({
|
|
951
|
+
registry: this.reputationFeedback.client,
|
|
952
|
+
ref: {
|
|
953
|
+
restorerAgentId: resolved.agentId,
|
|
954
|
+
restorerManifestCid: manifestCid,
|
|
955
|
+
restorerEvidenceHash: parent.evidenceHash,
|
|
956
|
+
},
|
|
957
|
+
verdict: verdictArg,
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
catch (err) {
|
|
961
|
+
// submitEvaluatorFeedback already swallows known reverts, but a
|
|
962
|
+
// truly unexpected throw still must not propagate past delivery.
|
|
963
|
+
console.warn(`[restorer-engine] ${intent.requestId}: reputation feedback unexpected throw (non-fatal): ${err instanceof Error ? err.message : err}`);
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
console.log(`[restorer-engine] ${intent.requestId}: reputation feedback ${outcome.kind} verdict=${verdict} restorerAgentId=${resolved.agentId.toString()}`);
|
|
967
|
+
}
|
|
968
|
+
/**
|
|
969
|
+
* Extract the restorer's `evidenceHash` (and best-effort `manifestCid`)
|
|
970
|
+
* from the persisted evaluation intent.
|
|
971
|
+
*
|
|
972
|
+
* The evaluator's `intent.context.restorationResult` holds the restorer's
|
|
973
|
+
* full signed manifest JSON inlined as a string (per
|
|
974
|
+
* `MechAdapter.tryCreateEvaluationJob`). We parse it and pull the
|
|
975
|
+
* `signature.hash`, which is exactly the on-chain `evidenceHash`.
|
|
976
|
+
*
|
|
977
|
+
* The CID is not always inlined — the manifest carries its own
|
|
978
|
+
* `intent.cid` field (the *original intent* CID), not its self-CID. We
|
|
979
|
+
* therefore return `manifestCid: null` here and rely on the subgraph
|
|
980
|
+
* resolver to surface the published manifest CID. Returns `null` when
|
|
981
|
+
* the inlined payload is missing or malformed.
|
|
982
|
+
*/
|
|
983
|
+
_extractRestorerManifestRef(intent) {
|
|
984
|
+
const ds = intent.restorationJob;
|
|
985
|
+
const inlined = ds?.context?.['restorationResult'];
|
|
986
|
+
if (typeof inlined !== 'string' || inlined.length === 0) {
|
|
987
|
+
return null;
|
|
988
|
+
}
|
|
989
|
+
let parsed;
|
|
990
|
+
try {
|
|
991
|
+
parsed = JSON.parse(inlined);
|
|
992
|
+
}
|
|
993
|
+
catch {
|
|
994
|
+
return null;
|
|
995
|
+
}
|
|
996
|
+
if (typeof parsed !== 'object' || parsed === null) {
|
|
997
|
+
return null;
|
|
998
|
+
}
|
|
999
|
+
const sig = parsed['signature'];
|
|
1000
|
+
if (typeof sig !== 'object' || sig === null) {
|
|
1001
|
+
return null;
|
|
1002
|
+
}
|
|
1003
|
+
const hashRaw = sig['hash'];
|
|
1004
|
+
if (typeof hashRaw !== 'string' || !/^0x[0-9a-fA-F]{64}$/.test(hashRaw)) {
|
|
1005
|
+
return null;
|
|
1006
|
+
}
|
|
1007
|
+
return {
|
|
1008
|
+
evidenceHash: hashRaw,
|
|
1009
|
+
manifestCid: null,
|
|
1010
|
+
};
|
|
630
1011
|
}
|
|
631
1012
|
// ── Internal helpers ────────────────────────────────────────────────────────
|
|
632
1013
|
/**
|