@absol-labs/agent 0.9.1 → 0.11.0
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/README.md +184 -26
- package/dist/capability/invocation-capability.d.ts +18 -6
- package/dist/capability/invocation-capability.d.ts.map +1 -1
- package/dist/capability/invocation-capability.js.map +1 -1
- package/dist/cli/amounts.d.ts +26 -0
- package/dist/cli/amounts.d.ts.map +1 -0
- package/dist/cli/amounts.js +71 -0
- package/dist/cli/amounts.js.map +1 -0
- package/dist/cli/args.d.ts +32 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +119 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/attesters.d.ts +51 -0
- package/dist/cli/attesters.d.ts.map +1 -0
- package/dist/cli/attesters.js +58 -0
- package/dist/cli/attesters.js.map +1 -0
- package/dist/cli/bin.d.ts +3 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +5 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/commands/claim.d.ts +13 -0
- package/dist/cli/commands/claim.d.ts.map +1 -0
- package/dist/cli/commands/claim.js +102 -0
- package/dist/cli/commands/claim.js.map +1 -0
- package/dist/cli/commands/close.d.ts +3 -0
- package/dist/cli/commands/close.d.ts.map +1 -0
- package/dist/cli/commands/close.js +55 -0
- package/dist/cli/commands/close.js.map +1 -0
- package/dist/cli/commands/discover.d.ts +3 -0
- package/dist/cli/commands/discover.d.ts.map +1 -0
- package/dist/cli/commands/discover.js +183 -0
- package/dist/cli/commands/discover.js.map +1 -0
- package/dist/cli/commands/invoke.d.ts +3 -0
- package/dist/cli/commands/invoke.d.ts.map +1 -0
- package/dist/cli/commands/invoke.js +142 -0
- package/dist/cli/commands/invoke.js.map +1 -0
- package/dist/cli/commands/mcp.d.ts +3 -0
- package/dist/cli/commands/mcp.d.ts.map +1 -0
- package/dist/cli/commands/mcp.js +113 -0
- package/dist/cli/commands/mcp.js.map +1 -0
- package/dist/cli/commands/open.d.ts +3 -0
- package/dist/cli/commands/open.d.ts.map +1 -0
- package/dist/cli/commands/open.js +331 -0
- package/dist/cli/commands/open.js.map +1 -0
- package/dist/cli/commands/reclaim-unverified.d.ts +3 -0
- package/dist/cli/commands/reclaim-unverified.d.ts.map +1 -0
- package/dist/cli/commands/reclaim-unverified.js +172 -0
- package/dist/cli/commands/reclaim-unverified.js.map +1 -0
- package/dist/cli/commands/reclaim.d.ts +33 -0
- package/dist/cli/commands/reclaim.d.ts.map +1 -0
- package/dist/cli/commands/reclaim.js +308 -0
- package/dist/cli/commands/reclaim.js.map +1 -0
- package/dist/cli/commands/status.d.ts +3 -0
- package/dist/cli/commands/status.d.ts.map +1 -0
- package/dist/cli/commands/status.js +43 -0
- package/dist/cli/commands/status.js.map +1 -0
- package/dist/cli/commands/streams.d.ts +3 -0
- package/dist/cli/commands/streams.d.ts.map +1 -0
- package/dist/cli/commands/streams.js +257 -0
- package/dist/cli/commands/streams.js.map +1 -0
- package/dist/cli/commands/watch.d.ts +3 -0
- package/dist/cli/commands/watch.d.ts.map +1 -0
- package/dist/cli/commands/watch.js +55 -0
- package/dist/cli/commands/watch.js.map +1 -0
- package/dist/cli/config.d.ts +61 -0
- package/dist/cli/config.d.ts.map +1 -0
- package/dist/cli/config.js +140 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/context.d.ts +29 -0
- package/dist/cli/context.d.ts.map +1 -0
- package/dist/cli/context.js +2 -0
- package/dist/cli/context.js.map +1 -0
- package/dist/cli/deps.d.ts +191 -0
- package/dist/cli/deps.d.ts.map +1 -0
- package/dist/cli/deps.js +277 -0
- package/dist/cli/deps.js.map +1 -0
- package/dist/cli/descriptor.d.ts +61 -0
- package/dist/cli/descriptor.d.ts.map +1 -0
- package/dist/cli/descriptor.js +78 -0
- package/dist/cli/descriptor.js.map +1 -0
- package/dist/cli/errors.d.ts +48 -0
- package/dist/cli/errors.d.ts.map +1 -0
- package/dist/cli/errors.js +129 -0
- package/dist/cli/errors.js.map +1 -0
- package/dist/cli/escape-hatch.d.ts +50 -0
- package/dist/cli/escape-hatch.d.ts.map +1 -0
- package/dist/cli/escape-hatch.js +45 -0
- package/dist/cli/escape-hatch.js.map +1 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +7 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/listings.d.ts +15 -0
- package/dist/cli/listings.d.ts.map +1 -0
- package/dist/cli/listings.js +56 -0
- package/dist/cli/listings.js.map +1 -0
- package/dist/cli/mandate.d.ts +66 -0
- package/dist/cli/mandate.d.ts.map +1 -0
- package/dist/cli/mandate.js +61 -0
- package/dist/cli/mandate.js.map +1 -0
- package/dist/cli/output.d.ts +33 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +34 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/cli/preflight.d.ts +38 -0
- package/dist/cli/preflight.d.ts.map +1 -0
- package/dist/cli/preflight.js +72 -0
- package/dist/cli/preflight.js.map +1 -0
- package/dist/cli/privy.d.ts +83 -0
- package/dist/cli/privy.d.ts.map +1 -0
- package/dist/cli/privy.js +230 -0
- package/dist/cli/privy.js.map +1 -0
- package/dist/cli/progress.d.ts +36 -0
- package/dist/cli/progress.d.ts.map +1 -0
- package/dist/cli/progress.js +40 -0
- package/dist/cli/progress.js.map +1 -0
- package/dist/cli/run.d.ts +25 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +173 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/cli/scan-range.d.ts +55 -0
- package/dist/cli/scan-range.d.ts.map +1 -0
- package/dist/cli/scan-range.js +57 -0
- package/dist/cli/scan-range.js.map +1 -0
- package/dist/cli/spend-policy.d.ts +60 -0
- package/dist/cli/spend-policy.d.ts.map +1 -0
- package/dist/cli/spend-policy.js +65 -0
- package/dist/cli/spend-policy.js.map +1 -0
- package/dist/cli/status.d.ts +90 -0
- package/dist/cli/status.d.ts.map +1 -0
- package/dist/cli/status.js +252 -0
- package/dist/cli/status.js.map +1 -0
- package/dist/cli/timeout.d.ts +30 -0
- package/dist/cli/timeout.d.ts.map +1 -0
- package/dist/cli/timeout.js +55 -0
- package/dist/cli/timeout.js.map +1 -0
- package/dist/cli/version.d.ts +12 -0
- package/dist/cli/version.d.ts.map +1 -0
- package/dist/cli/version.js +22 -0
- package/dist/cli/version.js.map +1 -0
- package/dist/cli/wallet.d.ts +164 -0
- package/dist/cli/wallet.d.ts.map +1 -0
- package/dist/cli/wallet.js +234 -0
- package/dist/cli/wallet.js.map +1 -0
- package/dist/frameworks/crewai.d.ts +10 -0
- package/dist/frameworks/crewai.d.ts.map +1 -1
- package/dist/frameworks/crewai.js +12 -2
- package/dist/frameworks/crewai.js.map +1 -1
- package/dist/gateway/caller-auth-gateway.d.ts +38 -3
- package/dist/gateway/caller-auth-gateway.d.ts.map +1 -1
- package/dist/gateway/caller-auth-gateway.js +25 -1
- package/dist/gateway/caller-auth-gateway.js.map +1 -1
- package/dist/gateway/http-server.d.ts +53 -0
- package/dist/gateway/http-server.d.ts.map +1 -1
- package/dist/gateway/http-server.js +189 -4
- package/dist/gateway/http-server.js.map +1 -1
- package/dist/gateway/server-entry.d.ts +1 -0
- package/dist/gateway/server-entry.js +1 -0
- package/dist/gateway/server-entry.js.map +1 -1
- package/dist/gateway/x402-mode.d.ts +123 -0
- package/dist/gateway/x402-mode.d.ts.map +1 -0
- package/dist/gateway/x402-mode.js +212 -0
- package/dist/gateway/x402-mode.js.map +1 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/mandates/env.d.ts +3 -2
- package/dist/mandates/env.d.ts.map +1 -1
- package/dist/mandates/env.js +3 -2
- package/dist/mandates/env.js.map +1 -1
- package/dist/mcp/http-server.d.ts +1 -0
- package/dist/mcp/http-server.js +1 -0
- package/dist/mcp/http-server.js.map +1 -1
- package/dist/mcp/server.d.ts +49 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +533 -25
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/service-invoker.d.ts +97 -0
- package/dist/mcp/service-invoker.d.ts.map +1 -0
- package/dist/mcp/service-invoker.js +167 -0
- package/dist/mcp/service-invoker.js.map +1 -0
- package/dist/mcp/stdio.d.ts +1 -0
- package/dist/mcp/stdio.js +1 -0
- package/dist/mcp/stdio.js.map +1 -1
- package/dist/sdk/client.d.ts +25 -1
- package/dist/sdk/client.d.ts.map +1 -1
- package/dist/sdk/client.js +20 -1
- package/dist/sdk/client.js.map +1 -1
- package/dist/sdk/invoke.d.ts +19 -4
- package/dist/sdk/invoke.d.ts.map +1 -1
- package/dist/sdk/invoke.js +69 -5
- package/dist/sdk/invoke.js.map +1 -1
- package/dist/x402/delivery-oracle.d.ts +108 -0
- package/dist/x402/delivery-oracle.d.ts.map +1 -0
- package/dist/x402/delivery-oracle.js +174 -0
- package/dist/x402/delivery-oracle.js.map +1 -0
- package/dist/x402/facilitator-server-entry.d.ts +3 -0
- package/dist/x402/facilitator-server-entry.d.ts.map +1 -0
- package/dist/x402/facilitator-server-entry.js +27 -0
- package/dist/x402/facilitator-server-entry.js.map +1 -0
- package/dist/x402/facilitator-server.d.ts +73 -0
- package/dist/x402/facilitator-server.d.ts.map +1 -0
- package/dist/x402/facilitator-server.js +305 -0
- package/dist/x402/facilitator-server.js.map +1 -0
- package/dist/x402/facilitator.d.ts +69 -17
- package/dist/x402/facilitator.d.ts.map +1 -1
- package/dist/x402/facilitator.js +76 -33
- package/dist/x402/facilitator.js.map +1 -1
- package/dist/x402/payment-requirements.d.ts +106 -0
- package/dist/x402/payment-requirements.d.ts.map +1 -0
- package/dist/x402/payment-requirements.js +138 -0
- package/dist/x402/payment-requirements.js.map +1 -0
- package/dist/x402/relayer.d.ts +41 -0
- package/dist/x402/relayer.d.ts.map +1 -0
- package/dist/x402/relayer.js +64 -0
- package/dist/x402/relayer.js.map +1 -0
- package/dist/x402/resource-index.d.ts +75 -0
- package/dist/x402/resource-index.d.ts.map +1 -0
- package/dist/x402/resource-index.js +126 -0
- package/dist/x402/resource-index.js.map +1 -0
- package/dist/x402/verified-delivery-facilitator.d.ts +285 -0
- package/dist/x402/verified-delivery-facilitator.d.ts.map +1 -0
- package/dist/x402/verified-delivery-facilitator.js +423 -0
- package/dist/x402/verified-delivery-facilitator.js.map +1 -0
- package/dist/zktls/t2-delivery-proof.d.ts +6 -6
- package/docs/agent-layer.md +14 -9
- package/docs/cli.md +705 -0
- package/docs/crewai.md +6 -2
- package/docs/eliza.md +6 -1
- package/docs/mcp-hosted.md +7 -5
- package/docs/mcp-reference.md +175 -0
- package/docs/quickstart.md +36 -9
- package/docs/threat-model.md +4 -3
- package/docs/x402.md +648 -0
- package/package.json +33 -10
- package/src/capability/invocation-capability.ts +17 -1
- package/src/cli/amounts.ts +102 -0
- package/src/cli/args.ts +150 -0
- package/src/cli/attesters.ts +86 -0
- package/src/cli/bin.ts +5 -0
- package/src/cli/commands/claim.ts +126 -0
- package/src/cli/commands/close.ts +69 -0
- package/src/cli/commands/discover.ts +228 -0
- package/src/cli/commands/invoke.ts +178 -0
- package/src/cli/commands/mcp.ts +135 -0
- package/src/cli/commands/open.ts +397 -0
- package/src/cli/commands/reclaim-unverified.ts +218 -0
- package/src/cli/commands/reclaim.ts +377 -0
- package/src/cli/commands/status.ts +56 -0
- package/src/cli/commands/streams.ts +344 -0
- package/src/cli/commands/watch.ts +70 -0
- package/src/cli/config.ts +208 -0
- package/src/cli/context.ts +30 -0
- package/src/cli/deps.ts +528 -0
- package/src/cli/descriptor.ts +133 -0
- package/src/cli/errors.ts +162 -0
- package/src/cli/escape-hatch.ts +92 -0
- package/src/cli/index.ts +27 -0
- package/src/cli/listings.ts +77 -0
- package/src/cli/mandate.ts +126 -0
- package/src/cli/output.ts +63 -0
- package/src/cli/preflight.ts +88 -0
- package/src/cli/privy.ts +396 -0
- package/src/cli/progress.ts +75 -0
- package/src/cli/run.ts +209 -0
- package/src/cli/scan-range.ts +76 -0
- package/src/cli/spend-policy.ts +139 -0
- package/src/cli/status.ts +381 -0
- package/src/cli/timeout.ts +64 -0
- package/src/cli/version.ts +21 -0
- package/src/cli/wallet.ts +372 -0
- package/src/frameworks/crewai.ts +13 -2
- package/src/gateway/caller-auth-gateway.ts +77 -6
- package/src/gateway/http-server.ts +280 -6
- package/src/gateway/server-entry.ts +1 -0
- package/src/gateway/x402-mode.ts +350 -0
- package/src/index.ts +40 -5
- package/src/mandates/env.ts +3 -2
- package/src/mcp/http-server.ts +1 -0
- package/src/mcp/server.ts +706 -30
- package/src/mcp/service-invoker.ts +285 -0
- package/src/mcp/stdio.ts +1 -0
- package/src/sdk/client.ts +33 -1
- package/src/sdk/invoke.ts +90 -12
- package/src/x402/delivery-oracle.ts +285 -0
- package/src/x402/facilitator-server-entry.ts +35 -0
- package/src/x402/facilitator-server.ts +445 -0
- package/src/x402/facilitator.ts +125 -46
- package/src/x402/payment-requirements.ts +231 -0
- package/src/x402/relayer.ts +122 -0
- package/src/x402/resource-index.ts +228 -0
- package/src/x402/verified-delivery-facilitator.ts +744 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeout.js","sourceRoot":"","sources":["../../src/cli/timeout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AAEtC;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC;AACrC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC;AAEjC;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,SAA2B,EAC3B,KAAa,EACb,YAAoB,eAAe;IAEnC,IAAI,KAAgD,CAAC;IACrD,MAAM,OAAO,GAAG,SAAS,EAAE,CAAC;IAC5B,6EAA6E;IAC7E,+DAA+D;IAC/D,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACxB,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC;YACxB,OAAO;YACP,IAAI,OAAO,CAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE;gBACtC,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;oBACtB,MAAM,CACJ,IAAI,QAAQ,CACV,GAAG,KAAK,0BAA0B,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EACjE;wBACE,QAAQ,EAAE,CAAC;wBACX,IAAI,EAAE,yGAAyG;qBAChH,CACF,CACF,CAAC;gBACJ,CAAC,EAAE,SAAS,CAAC,CAAC;gBACd,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;YAClB,CAAC,CAAC;SACH,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,IAAI,KAAK,KAAK,SAAS;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The published version of this package, read from its own manifest.
|
|
3
|
+
*
|
|
4
|
+
* Kept in its own module because both the runner (`--version`) and the MCP
|
|
5
|
+
* config printer need it, and the printer is a command the runner imports — so
|
|
6
|
+
* reading it from `run.ts` would be a cycle.
|
|
7
|
+
*
|
|
8
|
+
* Falls back rather than throwing: a CLI that cannot state its version should
|
|
9
|
+
* still run.
|
|
10
|
+
*/
|
|
11
|
+
export declare function packageVersion(): string;
|
|
12
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/cli/version.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAQvC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
/**
|
|
3
|
+
* The published version of this package, read from its own manifest.
|
|
4
|
+
*
|
|
5
|
+
* Kept in its own module because both the runner (`--version`) and the MCP
|
|
6
|
+
* config printer need it, and the printer is a command the runner imports — so
|
|
7
|
+
* reading it from `run.ts` would be a cycle.
|
|
8
|
+
*
|
|
9
|
+
* Falls back rather than throwing: a CLI that cannot state its version should
|
|
10
|
+
* still run.
|
|
11
|
+
*/
|
|
12
|
+
export function packageVersion() {
|
|
13
|
+
try {
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
15
|
+
const manifest = require("../../package.json");
|
|
16
|
+
return manifest.version ?? "0.0.0";
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return "0.0.0";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/cli/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc;IAC5B,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/C,MAAM,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAyB,CAAC;QACvE,OAAO,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type { Account, LocalAccount, Transport } from "viem";
|
|
2
|
+
import type { AutonomousWalletCredentialStore } from "../wallet/autonomous-wallet.js";
|
|
3
|
+
import { type PrivyCliWalletSource, type PrivySpendPolicy } from "./privy.js";
|
|
4
|
+
/**
|
|
5
|
+
* The ONLY place the CLI resolves a signing wallet.
|
|
6
|
+
*
|
|
7
|
+
* There is deliberately NO `--private-key` flag, and no flag for any other
|
|
8
|
+
* credential. A secret passed on the command line lands in shell history, in
|
|
9
|
+
* `ps` output, and in any CI log that echoes the command; an environment
|
|
10
|
+
* variable does none of those. Secrets are also never echoed back: commands
|
|
11
|
+
* print the derived ADDRESS only.
|
|
12
|
+
*
|
|
13
|
+
* ## Resolution order (first match wins, checked in this order)
|
|
14
|
+
*
|
|
15
|
+
* 1. `METRIK_AGENT_PRIVATE_KEY` — a raw Base Sepolia test key.
|
|
16
|
+
* 2. The `CDP_*` / `METRIK_AGENT_CDP_*` quartet — a Coinbase CDP Server Wallet
|
|
17
|
+
* v2 account, resolved through this package's own `resolveAgentWallet()`.
|
|
18
|
+
* 3. The `METRIK_AGENT_PRIVY_*` variables — a Privy wallet reached through a
|
|
19
|
+
* broker, either agent-owned (`METRIK_AGENT_PRIVY_WALLET_KEY`) or a
|
|
20
|
+
* user-owned broker session. See `./privy.ts`.
|
|
21
|
+
*
|
|
22
|
+
* The first two match `parseAgentWalletEnv()` (the MCP server's resolution), so
|
|
23
|
+
* one environment configures those surfaces the same way. The order is FIXED
|
|
24
|
+
* rather than "whichever is configured", because an environment carrying two is
|
|
25
|
+
* ambiguous about which address funds the stream — and that ambiguity is a
|
|
26
|
+
* fund-moving one. When more than one is present the earlier entry wins and
|
|
27
|
+
* `resolveCliWallet` says so on stderr rather than silently picking.
|
|
28
|
+
*
|
|
29
|
+
* ## What is different about Privy
|
|
30
|
+
*
|
|
31
|
+
* A private key and a CDP account both sign LOCALLY: `privateKeyToAccount()`
|
|
32
|
+
* and `toAccount(cdpServerAccount)` are viem local accounts, so they drop
|
|
33
|
+
* straight into the CLI's `http(rpcUrl)` transport with no other change.
|
|
34
|
+
*
|
|
35
|
+
* Privy does not. Its account is a JSON-RPC account with no `signTransaction`:
|
|
36
|
+
* it signs and broadcasts by sending `eth_sendTransaction` /
|
|
37
|
+
* `eth_signTypedData_v4` to a provider, so the wallet client's TRANSPORT must
|
|
38
|
+
* be that provider rather than a plain RPC. That is what {@link CliWallet.transport}
|
|
39
|
+
* carries, and the only reason this file knows Privy exists. The signer check
|
|
40
|
+
* below is therefore about CAPABILITY, not about locality: it refuses an
|
|
41
|
+
* account that genuinely cannot sign, and refuses a non-local account only on
|
|
42
|
+
* the paths that broadcast through `--rpc-url`.
|
|
43
|
+
*
|
|
44
|
+
* See `docs/cli.md` § Wallet.
|
|
45
|
+
*/
|
|
46
|
+
export declare const PRIVATE_KEY_ENV = "METRIK_AGENT_PRIVATE_KEY";
|
|
47
|
+
/** Every environment variable the CDP path reads. Named in errors, never printed. */
|
|
48
|
+
export declare const CDP_ENV_VARS: readonly ["CDP_API_KEY_ID", "CDP_API_KEY_SECRET", "CDP_WALLET_SECRET", "METRIK_AGENT_CDP_OWNER_NAME"];
|
|
49
|
+
export { PRIVY_ENV_VARS, PRIVY_SESSION_ENV_VARS, PRIVY_WALLET_KEY_ENV, } from "./privy.js";
|
|
50
|
+
/**
|
|
51
|
+
* What the key is for, in the words of the command that needs it. `invoke`
|
|
52
|
+
* signs an EIP-712 invocation capability and broadcasts NOTHING; telling its
|
|
53
|
+
* caller "this command signs a transaction" was simply false.
|
|
54
|
+
*/
|
|
55
|
+
export type KeyPurpose = "transaction" | "capability";
|
|
56
|
+
/** Which environment configured the signer, for output and for error text. */
|
|
57
|
+
export type CliWalletSource = "private-key" | "cdp" | PrivyCliWalletSource;
|
|
58
|
+
/**
|
|
59
|
+
* An account every CLI signing path can actually use.
|
|
60
|
+
*
|
|
61
|
+
* `signTypedData` is required rather than optional because it is the one
|
|
62
|
+
* capability EVERY path needs: fund-moving commands self-sign an EIP-712
|
|
63
|
+
* `SpendMandate`, and `invoke` signs an EIP-712 `InvocationCapability`. An
|
|
64
|
+
* account without it type-checks as a viem `Account` and then fails at the
|
|
65
|
+
* first signature with a `TypeError`.
|
|
66
|
+
*/
|
|
67
|
+
export type CliSignerAccount = Account & Pick<LocalAccount, "signTypedData">;
|
|
68
|
+
export interface CliWallet {
|
|
69
|
+
readonly source: CliWalletSource;
|
|
70
|
+
readonly account: CliSignerAccount;
|
|
71
|
+
/**
|
|
72
|
+
* The transport fund-moving commands must broadcast through, when the wallet
|
|
73
|
+
* REQUIRES one. `undefined` means "a plain `http(--rpc-url)` is correct" —
|
|
74
|
+
* true for a local signer, false for Privy, whose provider IS the transport.
|
|
75
|
+
*/
|
|
76
|
+
readonly transport?: Transport;
|
|
77
|
+
/** One line naming the signer's origin. Safe to print: no secret in it. */
|
|
78
|
+
readonly description: string;
|
|
79
|
+
/**
|
|
80
|
+
* Set when this wallet's spend ceiling is enforced where the CLI cannot reach
|
|
81
|
+
* it — i.e. by a Privy broker policy, not by a locally self-signed mandate.
|
|
82
|
+
*
|
|
83
|
+
* Its presence is the signal that the CLI should NOT self-sign a
|
|
84
|
+
* `SpendMandate` for this wallet, and should read and enforce the real
|
|
85
|
+
* ceiling instead. See `./spend-policy.ts` for why that substitution is
|
|
86
|
+
* strictly stronger than the mandate it replaces, and why re-adding the
|
|
87
|
+
* mandate "for consistency" would be a regression.
|
|
88
|
+
*/
|
|
89
|
+
readonly readSpendPolicy?: () => Promise<PrivySpendPolicy>;
|
|
90
|
+
}
|
|
91
|
+
export interface ResolveCliWalletOptions {
|
|
92
|
+
readonly purpose?: KeyPurpose;
|
|
93
|
+
/**
|
|
94
|
+
* `--rpc-url`. Only the Privy paths use it at resolution time: their provider
|
|
95
|
+
* serves the wallet client's READS as well as its writes, so without this a
|
|
96
|
+
* Privy command would read from a different endpoint than `--rpc-url` names.
|
|
97
|
+
*/
|
|
98
|
+
readonly rpcUrl?: string;
|
|
99
|
+
readonly note?: (line: string) => void;
|
|
100
|
+
/**
|
|
101
|
+
* Test seam, same role as `ResolveAgentWalletOptions.createCdpClient`: the
|
|
102
|
+
* credential store an agent-owned Privy wallet is read from. Unset in every
|
|
103
|
+
* real run, where the store is selected from the environment.
|
|
104
|
+
*/
|
|
105
|
+
readonly store?: AutonomousWalletCredentialStore;
|
|
106
|
+
/** Test seam: the `fetch` the Privy broker is reached through. */
|
|
107
|
+
readonly fetchImpl?: typeof fetch;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Resolves the signing wallet, or throws an actionable configuration error.
|
|
111
|
+
*
|
|
112
|
+
* `note` receives one line when the environment is ambiguous (more than one
|
|
113
|
+
* wallet source configured). It is optional so `resolveCliWallet` stays usable
|
|
114
|
+
* from a context with no printer; commands always pass `out.note`.
|
|
115
|
+
*/
|
|
116
|
+
export declare function resolveCliWallet(env: NodeJS.ProcessEnv, options?: ResolveCliWalletOptions): Promise<CliWallet>;
|
|
117
|
+
/** True for both Privy shapes, which reach their key through a broker. */
|
|
118
|
+
export declare function isPrivyWalletSource(source: CliWalletSource): source is PrivyCliWalletSource;
|
|
119
|
+
/**
|
|
120
|
+
* Whether this wallet's ceiling is enforced somewhere the CLI cannot reach.
|
|
121
|
+
*
|
|
122
|
+
* The one question every fund-moving command asks before deciding whether to
|
|
123
|
+
* self-sign a `SpendMandate`. See `./spend-policy.ts`.
|
|
124
|
+
*/
|
|
125
|
+
export declare function isPolicyEnforced(wallet: CliWallet): wallet is CliWallet & {
|
|
126
|
+
readonly readSpendPolicy: () => Promise<PrivySpendPolicy>;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* The same resolution, but "nothing configured" is not an error. Used by
|
|
130
|
+
* look-before-you-leap paths (`open --dry-run`, `streams --address`) that
|
|
131
|
+
* broadcast nothing and must therefore work for someone who does not yet have a
|
|
132
|
+
* funded wallet — which is exactly who a dry run is for.
|
|
133
|
+
*
|
|
134
|
+
* A wallet that is PARTIALLY configured is still an error here: "you set three
|
|
135
|
+
* of the four CDP variables" and "you configured no wallet" are different
|
|
136
|
+
* facts, and rendering the first as the second sends the reader looking in the
|
|
137
|
+
* wrong place. The same rule applies to a partial Privy setup.
|
|
138
|
+
*/
|
|
139
|
+
export declare function optionalCliWallet(env: NodeJS.ProcessEnv, options?: Omit<ResolveCliWalletOptions, "purpose">): Promise<CliWallet | null>;
|
|
140
|
+
/**
|
|
141
|
+
* The raw `METRIK_AGENT_PRIVATE_KEY` read, kept separate so the wallet-source
|
|
142
|
+
* precedence above reads as one list rather than as nested conditionals.
|
|
143
|
+
*/
|
|
144
|
+
export declare function optionalCliAccount(env: NodeJS.ProcessEnv): LocalAccount | null;
|
|
145
|
+
/**
|
|
146
|
+
* Refuses an account that genuinely cannot sign — and nothing else.
|
|
147
|
+
*
|
|
148
|
+
* Two distinct capabilities are checked, because two distinct things fail:
|
|
149
|
+
*
|
|
150
|
+
* - `signTypedData` is needed by EVERY command. Fund-moving commands self-sign
|
|
151
|
+
* an EIP-712 `SpendMandate`; `invoke` signs an EIP-712
|
|
152
|
+
* `InvocationCapability`. Without it the run dies at the first signature
|
|
153
|
+
* with a `TypeError` from inside viem.
|
|
154
|
+
* - A LOCAL account is needed only where the CLI broadcasts through
|
|
155
|
+
* `http(--rpc-url)`, which cannot sign. A Privy account is deliberately NOT
|
|
156
|
+
* local: its provider is the transport and performs `eth_sendTransaction`
|
|
157
|
+
* itself, so demanding locality there would reject a wallet that works.
|
|
158
|
+
*
|
|
159
|
+
* The earlier version of this guard collapsed both into "must be local", which
|
|
160
|
+
* is why Privy was refused. Deleting the guard outright was not the fix: it
|
|
161
|
+
* exists so a broken wallet fails here, named, instead of deep inside viem.
|
|
162
|
+
*/
|
|
163
|
+
export declare function assertCliSigner(account: Account, source: CliWalletSource): CliSignerAccount;
|
|
164
|
+
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/cli/wallet.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAE7D,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AAGt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AAC,EAAE,OAAO,KAAK,CAAC;CACnC;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,SAAS,CAAC,CASpB;AAED,0EAA0E;AAC1E,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,eAAe,GACtB,MAAM,IAAI,oBAAoB,CAEhC;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,IAAI,SAAS,GAAG;IACzE,QAAQ,CAAC,eAAe,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC3D,CAEA;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,OAAO,GAAE,IAAI,CAAC,uBAAuB,EAAE,SAAS,CAAM,GACrD,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CA6C3B;AAuDD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,CAAC,UAAU,GACrB,YAAY,GAAG,IAAI,CASrB;AAWD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,eAAe,GACtB,gBAAgB,CAclB"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
2
|
+
import { resolveAgentWallet } from "../wallet/provider.js";
|
|
3
|
+
import { configError } from "./errors.js";
|
|
4
|
+
import { PRIVY_ENV_VARS, PRIVY_SESSION_ENV_VARS, PRIVY_WALLET_KEY_ENV, resolvePrivyCliWallet, } from "./privy.js";
|
|
5
|
+
/**
|
|
6
|
+
* The ONLY place the CLI resolves a signing wallet.
|
|
7
|
+
*
|
|
8
|
+
* There is deliberately NO `--private-key` flag, and no flag for any other
|
|
9
|
+
* credential. A secret passed on the command line lands in shell history, in
|
|
10
|
+
* `ps` output, and in any CI log that echoes the command; an environment
|
|
11
|
+
* variable does none of those. Secrets are also never echoed back: commands
|
|
12
|
+
* print the derived ADDRESS only.
|
|
13
|
+
*
|
|
14
|
+
* ## Resolution order (first match wins, checked in this order)
|
|
15
|
+
*
|
|
16
|
+
* 1. `METRIK_AGENT_PRIVATE_KEY` — a raw Base Sepolia test key.
|
|
17
|
+
* 2. The `CDP_*` / `METRIK_AGENT_CDP_*` quartet — a Coinbase CDP Server Wallet
|
|
18
|
+
* v2 account, resolved through this package's own `resolveAgentWallet()`.
|
|
19
|
+
* 3. The `METRIK_AGENT_PRIVY_*` variables — a Privy wallet reached through a
|
|
20
|
+
* broker, either agent-owned (`METRIK_AGENT_PRIVY_WALLET_KEY`) or a
|
|
21
|
+
* user-owned broker session. See `./privy.ts`.
|
|
22
|
+
*
|
|
23
|
+
* The first two match `parseAgentWalletEnv()` (the MCP server's resolution), so
|
|
24
|
+
* one environment configures those surfaces the same way. The order is FIXED
|
|
25
|
+
* rather than "whichever is configured", because an environment carrying two is
|
|
26
|
+
* ambiguous about which address funds the stream — and that ambiguity is a
|
|
27
|
+
* fund-moving one. When more than one is present the earlier entry wins and
|
|
28
|
+
* `resolveCliWallet` says so on stderr rather than silently picking.
|
|
29
|
+
*
|
|
30
|
+
* ## What is different about Privy
|
|
31
|
+
*
|
|
32
|
+
* A private key and a CDP account both sign LOCALLY: `privateKeyToAccount()`
|
|
33
|
+
* and `toAccount(cdpServerAccount)` are viem local accounts, so they drop
|
|
34
|
+
* straight into the CLI's `http(rpcUrl)` transport with no other change.
|
|
35
|
+
*
|
|
36
|
+
* Privy does not. Its account is a JSON-RPC account with no `signTransaction`:
|
|
37
|
+
* it signs and broadcasts by sending `eth_sendTransaction` /
|
|
38
|
+
* `eth_signTypedData_v4` to a provider, so the wallet client's TRANSPORT must
|
|
39
|
+
* be that provider rather than a plain RPC. That is what {@link CliWallet.transport}
|
|
40
|
+
* carries, and the only reason this file knows Privy exists. The signer check
|
|
41
|
+
* below is therefore about CAPABILITY, not about locality: it refuses an
|
|
42
|
+
* account that genuinely cannot sign, and refuses a non-local account only on
|
|
43
|
+
* the paths that broadcast through `--rpc-url`.
|
|
44
|
+
*
|
|
45
|
+
* See `docs/cli.md` § Wallet.
|
|
46
|
+
*/
|
|
47
|
+
export const PRIVATE_KEY_ENV = "METRIK_AGENT_PRIVATE_KEY";
|
|
48
|
+
/** Every environment variable the CDP path reads. Named in errors, never printed. */
|
|
49
|
+
export const CDP_ENV_VARS = [
|
|
50
|
+
"CDP_API_KEY_ID",
|
|
51
|
+
"CDP_API_KEY_SECRET",
|
|
52
|
+
"CDP_WALLET_SECRET",
|
|
53
|
+
"METRIK_AGENT_CDP_OWNER_NAME",
|
|
54
|
+
];
|
|
55
|
+
export { PRIVY_ENV_VARS, PRIVY_SESSION_ENV_VARS, PRIVY_WALLET_KEY_ENV, } from "./privy.js";
|
|
56
|
+
const PURPOSE_TEXT = {
|
|
57
|
+
transaction: "signs a transaction",
|
|
58
|
+
capability: "signs an off-chain EIP-712 invocation capability (no transaction is broadcast)",
|
|
59
|
+
};
|
|
60
|
+
const WALLET_HINT = `export ${PRIVATE_KEY_ENV}=0x… (a funded Base Sepolia test key), configure a Coinbase CDP wallet with ` +
|
|
61
|
+
`${CDP_ENV_VARS.join(", ")}, or configure a Privy wallet with ${PRIVY_WALLET_KEY_ENV} (agent-owned) or ` +
|
|
62
|
+
`${PRIVY_SESSION_ENV_VARS.join(", ")} (broker session). All are read from the environment only — never pass a credential as a command-line flag.`;
|
|
63
|
+
/**
|
|
64
|
+
* Resolves the signing wallet, or throws an actionable configuration error.
|
|
65
|
+
*
|
|
66
|
+
* `note` receives one line when the environment is ambiguous (more than one
|
|
67
|
+
* wallet source configured). It is optional so `resolveCliWallet` stays usable
|
|
68
|
+
* from a context with no printer; commands always pass `out.note`.
|
|
69
|
+
*/
|
|
70
|
+
export async function resolveCliWallet(env, options = {}) {
|
|
71
|
+
const wallet = await optionalCliWallet(env, options);
|
|
72
|
+
if (wallet === null) {
|
|
73
|
+
throw configError(`this command ${PURPOSE_TEXT[options.purpose ?? "transaction"]} and needs a wallet: none of ${PRIVATE_KEY_ENV}, the CDP variables or the Privy variables are set`, WALLET_HINT);
|
|
74
|
+
}
|
|
75
|
+
return wallet;
|
|
76
|
+
}
|
|
77
|
+
/** True for both Privy shapes, which reach their key through a broker. */
|
|
78
|
+
export function isPrivyWalletSource(source) {
|
|
79
|
+
return source === "privy-autonomous" || source === "privy-session";
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Whether this wallet's ceiling is enforced somewhere the CLI cannot reach.
|
|
83
|
+
*
|
|
84
|
+
* The one question every fund-moving command asks before deciding whether to
|
|
85
|
+
* self-sign a `SpendMandate`. See `./spend-policy.ts`.
|
|
86
|
+
*/
|
|
87
|
+
export function isPolicyEnforced(wallet) {
|
|
88
|
+
return wallet.readSpendPolicy !== undefined;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The same resolution, but "nothing configured" is not an error. Used by
|
|
92
|
+
* look-before-you-leap paths (`open --dry-run`, `streams --address`) that
|
|
93
|
+
* broadcast nothing and must therefore work for someone who does not yet have a
|
|
94
|
+
* funded wallet — which is exactly who a dry run is for.
|
|
95
|
+
*
|
|
96
|
+
* A wallet that is PARTIALLY configured is still an error here: "you set three
|
|
97
|
+
* of the four CDP variables" and "you configured no wallet" are different
|
|
98
|
+
* facts, and rendering the first as the second sends the reader looking in the
|
|
99
|
+
* wrong place. The same rule applies to a partial Privy setup.
|
|
100
|
+
*/
|
|
101
|
+
export async function optionalCliWallet(env, options = {}) {
|
|
102
|
+
const privateKeyAccount = optionalCliAccount(env);
|
|
103
|
+
const cdpConfigured = CDP_ENV_VARS.some((name) => isSet(env[name]));
|
|
104
|
+
const privyConfigured = PRIVY_ENV_VARS.some((name) => isSet(env[name]));
|
|
105
|
+
if (privateKeyAccount !== null) {
|
|
106
|
+
const shadowed = [
|
|
107
|
+
...(cdpConfigured ? ["CDP"] : []),
|
|
108
|
+
...(privyConfigured ? ["Privy"] : []),
|
|
109
|
+
];
|
|
110
|
+
if (shadowed.length > 0) {
|
|
111
|
+
options.note?.(`warning: both ${PRIVATE_KEY_ENV} and ${shadowed.join(" and ")} wallet variables are set; using ${PRIVATE_KEY_ENV} (${privateKeyAccount.address}). Unset it to sign with the ${shadowed[0]} wallet.`);
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
source: "private-key",
|
|
115
|
+
account: privateKeyAccount,
|
|
116
|
+
description: `${privateKeyAccount.address} (from ${PRIVATE_KEY_ENV})`,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
if (cdpConfigured) {
|
|
120
|
+
if (privyConfigured) {
|
|
121
|
+
options.note?.("warning: both CDP and Privy wallet variables are set; using the CDP wallet. Unset the CDP variables to sign with the Privy wallet.");
|
|
122
|
+
}
|
|
123
|
+
return await resolveCdpWallet(env);
|
|
124
|
+
}
|
|
125
|
+
if (!privyConfigured)
|
|
126
|
+
return null;
|
|
127
|
+
const privy = await resolvePrivyCliWallet(env, options);
|
|
128
|
+
// Unreachable: `privyConfigured` is exactly the condition under which
|
|
129
|
+
// `resolvePrivyCliWallet` returns non-null or throws. Kept so a future change
|
|
130
|
+
// to either predicate fails loudly here rather than as a null deref.
|
|
131
|
+
if (privy === null)
|
|
132
|
+
return null;
|
|
133
|
+
return {
|
|
134
|
+
source: privy.source,
|
|
135
|
+
account: assertCliSigner(privy.account, privy.source),
|
|
136
|
+
transport: privy.transport,
|
|
137
|
+
description: privy.description,
|
|
138
|
+
readSpendPolicy: privy.readSpendPolicy,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
async function resolveCdpWallet(env) {
|
|
142
|
+
const missing = CDP_ENV_VARS.filter((name) => !isSet(env[name]));
|
|
143
|
+
if (missing.length > 0) {
|
|
144
|
+
throw configError(`the CDP wallet is partially configured: ${missing.join(", ")} ${missing.length === 1 ? "is" : "are"} not set`, `a CDP wallet needs all of ${CDP_ENV_VARS.join(", ")}. Set the missing one${missing.length === 1 ? "" : "s"}, or unset the others and use ${PRIVATE_KEY_ENV} instead.`);
|
|
145
|
+
}
|
|
146
|
+
// A CDP SMART account is an ERC-4337 contract account at a DIFFERENT address
|
|
147
|
+
// from its owner EOA, and it is reached through a bundler — which this CLI
|
|
148
|
+
// does not route to: every command broadcasts through `http(--rpc-url)`. So a
|
|
149
|
+
// smart-account environment would silently sign and spend from the OWNER,
|
|
150
|
+
// while the user funded the smart account. Refuse instead.
|
|
151
|
+
if (isSet(env.METRIK_AGENT_CDP_SMART_ACCOUNT_NAME) ||
|
|
152
|
+
isTruthy(env.METRIK_AGENT_CDP_CREATE_SMART_ACCOUNT)) {
|
|
153
|
+
throw configError("the CLI cannot sign from a CDP smart account: METRIK_AGENT_CDP_CREATE_SMART_ACCOUNT / METRIK_AGENT_CDP_SMART_ACCOUNT_NAME is set", "a CDP smart account is an ERC-4337 account at a different address from its owner, reached through a bundler; this CLI broadcasts through --rpc-url and would spend from the OWNER address instead. Unset those two variables to use the owner account directly, or use the SDK's account-abstraction path.");
|
|
154
|
+
}
|
|
155
|
+
const ownerName = env.METRIK_AGENT_CDP_OWNER_NAME;
|
|
156
|
+
let account;
|
|
157
|
+
try {
|
|
158
|
+
const resolved = await resolveAgentWallet({
|
|
159
|
+
cdp: {
|
|
160
|
+
apiKeyId: env.CDP_API_KEY_ID,
|
|
161
|
+
apiKeySecret: env.CDP_API_KEY_SECRET,
|
|
162
|
+
walletSecret: env.CDP_WALLET_SECRET,
|
|
163
|
+
ownerName,
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
account = resolved.account;
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
// Reaching CDP is a network call against an authenticated API, so this is
|
|
170
|
+
// where a wrong key, a revoked key or an outage surfaces. Say which wallet
|
|
171
|
+
// failed; the underlying message carries the rest.
|
|
172
|
+
throw configError(`could not resolve the CDP wallet "${ownerName}"`, `check ${CDP_ENV_VARS.join(", ")}, and that '@coinbase/cdp-sdk' (an optional peer dependency) is installed. Underlying error: ${error instanceof Error ? error.message : String(error)}`);
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
source: "cdp",
|
|
176
|
+
account: assertCliSigner(account, "cdp"),
|
|
177
|
+
description: `${account.address} (CDP account "${ownerName}")`,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* The raw `METRIK_AGENT_PRIVATE_KEY` read, kept separate so the wallet-source
|
|
182
|
+
* precedence above reads as one list rather than as nested conditionals.
|
|
183
|
+
*/
|
|
184
|
+
export function optionalCliAccount(env) {
|
|
185
|
+
const raw = env[PRIVATE_KEY_ENV];
|
|
186
|
+
if (raw === undefined || raw.length === 0)
|
|
187
|
+
return null;
|
|
188
|
+
if (!/^0x[0-9a-fA-F]{64}$/.test(raw)) {
|
|
189
|
+
throw configError(`${PRIVATE_KEY_ENV} must be a 0x-prefixed 32-byte hex private key`);
|
|
190
|
+
}
|
|
191
|
+
return privateKeyToAccount(raw);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Whether this wallet source broadcasts through the CLI's own
|
|
195
|
+
* `http(--rpc-url)` transport, and therefore needs an account that can produce
|
|
196
|
+
* a signed raw transaction by itself.
|
|
197
|
+
*/
|
|
198
|
+
function broadcastsLocally(source) {
|
|
199
|
+
return source === "private-key" || source === "cdp";
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Refuses an account that genuinely cannot sign — and nothing else.
|
|
203
|
+
*
|
|
204
|
+
* Two distinct capabilities are checked, because two distinct things fail:
|
|
205
|
+
*
|
|
206
|
+
* - `signTypedData` is needed by EVERY command. Fund-moving commands self-sign
|
|
207
|
+
* an EIP-712 `SpendMandate`; `invoke` signs an EIP-712
|
|
208
|
+
* `InvocationCapability`. Without it the run dies at the first signature
|
|
209
|
+
* with a `TypeError` from inside viem.
|
|
210
|
+
* - A LOCAL account is needed only where the CLI broadcasts through
|
|
211
|
+
* `http(--rpc-url)`, which cannot sign. A Privy account is deliberately NOT
|
|
212
|
+
* local: its provider is the transport and performs `eth_sendTransaction`
|
|
213
|
+
* itself, so demanding locality there would reject a wallet that works.
|
|
214
|
+
*
|
|
215
|
+
* The earlier version of this guard collapsed both into "must be local", which
|
|
216
|
+
* is why Privy was refused. Deleting the guard outright was not the fix: it
|
|
217
|
+
* exists so a broken wallet fails here, named, instead of deep inside viem.
|
|
218
|
+
*/
|
|
219
|
+
export function assertCliSigner(account, source) {
|
|
220
|
+
if (typeof account.signTypedData !== "function") {
|
|
221
|
+
throw configError(`the ${source} wallet (${account.address}) cannot sign EIP-712 typed data`, "every command signs typed data: fund-moving commands self-sign a spend mandate, and `invoke` signs an invocation capability.");
|
|
222
|
+
}
|
|
223
|
+
if (broadcastsLocally(source) && account.type !== "local") {
|
|
224
|
+
throw configError(`the ${source} wallet returned a ${account.type} account, which cannot sign locally`, "this wallet source broadcasts through --rpc-url, which cannot sign, so it needs a local signer.");
|
|
225
|
+
}
|
|
226
|
+
return account;
|
|
227
|
+
}
|
|
228
|
+
function isSet(value) {
|
|
229
|
+
return value !== undefined && value.length > 0;
|
|
230
|
+
}
|
|
231
|
+
function isTruthy(value) {
|
|
232
|
+
return value === "true" || value === "1";
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/cli/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAIpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,GAGtB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;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AAC;IACD,OAAO,mBAAmB,CAAC,GAAoB,CAAC,CAAC;AACnD,CAAC;AAED;;;;GAIG;AACH,SAAS,iBAAiB,CAAC,MAAuB;IAChD,OAAO,MAAM,KAAK,aAAa,IAAI,MAAM,KAAK,KAAK,CAAC;AACtD,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAgB,EAChB,MAAuB;IAEvB,IAAI,OAAO,OAAO,CAAC,aAAa,KAAK,UAAU,EAAE,CAAC;QAChD,MAAM,WAAW,CACf,OAAO,MAAM,YAAY,OAAO,CAAC,OAAO,kCAAkC,EAC1E,8HAA8H,CAC/H,CAAC;IACJ,CAAC;IACD,IAAI,iBAAiB,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC1D,MAAM,WAAW,CACf,OAAO,MAAM,sBAAsB,OAAO,CAAC,IAAI,qCAAqC,EACpF,iGAAiG,CAClG,CAAC;IACJ,CAAC;IACD,OAAO,OAA2B,CAAC;AACrC,CAAC;AAED,SAAS,KAAK,CAAC,KAAyB;IACtC,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AACjD,CAAC;AAED,SAAS,QAAQ,CAAC,KAAyB;IACzC,OAAO,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,GAAG,CAAC;AAC3C,CAAC"}
|
|
@@ -14,6 +14,16 @@ export interface CrewAiVerifiedStreamMcpConfigOptions {
|
|
|
14
14
|
readonly allowedToolNames?: readonly string[];
|
|
15
15
|
readonly cacheToolsList?: boolean;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* The default launcher: the `metrik-mcp` bin this package ships.
|
|
19
|
+
*
|
|
20
|
+
* It used to be `pnpm mcp:stdio`, which only resolves INSIDE this repository —
|
|
21
|
+
* a CrewAI user who installed `@absol-labs/agent` from npm got a config that
|
|
22
|
+
* could never start. `metrik-mcp` is on `PATH` wherever the package is
|
|
23
|
+
* installed (npm/pnpm link it into `node_modules/.bin`), and `npx` resolves it
|
|
24
|
+
* with no install at all.
|
|
25
|
+
*/
|
|
26
|
+
export declare const CREWAI_DEFAULT_MCP_COMMAND = "metrik-mcp";
|
|
17
27
|
export declare function createCrewAiVerifiedStreamMcpConfig(options?: CrewAiVerifiedStreamMcpConfigOptions): CrewAiVerifiedStreamMcpConfig;
|
|
18
28
|
export declare function renderCrewAiVerifiedStreamPythonExample(options?: CrewAiVerifiedStreamMcpConfigOptions): string;
|
|
19
29
|
//# sourceMappingURL=crewai.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crewai.d.ts","sourceRoot":"","sources":["../../src/frameworks/crewai.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iCAAiC,mHAMpC,CAAC;AAEX,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC/C,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,oCAAoC;IACnD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9C,QAAQ,CAAC,cAAc,CAAC,EAAE,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@ export const CREWAI_VERIFIED_STREAM_TOOL_NAMES = [
|
|
|
5
5
|
"reclaim_unspent",
|
|
6
6
|
"list_streams",
|
|
7
7
|
];
|
|
8
|
+
/**
|
|
9
|
+
* The default launcher: the `metrik-mcp` bin this package ships.
|
|
10
|
+
*
|
|
11
|
+
* It used to be `pnpm mcp:stdio`, which only resolves INSIDE this repository —
|
|
12
|
+
* a CrewAI user who installed `@absol-labs/agent` from npm got a config that
|
|
13
|
+
* could never start. `metrik-mcp` is on `PATH` wherever the package is
|
|
14
|
+
* installed (npm/pnpm link it into `node_modules/.bin`), and `npx` resolves it
|
|
15
|
+
* with no install at all.
|
|
16
|
+
*/
|
|
17
|
+
export const CREWAI_DEFAULT_MCP_COMMAND = "metrik-mcp";
|
|
8
18
|
export function createCrewAiVerifiedStreamMcpConfig(options = {}) {
|
|
9
19
|
return {
|
|
10
20
|
transport: "stdio",
|
|
11
|
-
command: options.command ??
|
|
12
|
-
args: options.args ?? [
|
|
21
|
+
command: options.command ?? CREWAI_DEFAULT_MCP_COMMAND,
|
|
22
|
+
args: options.args ?? [],
|
|
13
23
|
env: options.env ?? {},
|
|
14
24
|
allowedToolNames: options.allowedToolNames ?? CREWAI_VERIFIED_STREAM_TOOL_NAMES,
|
|
15
25
|
cacheToolsList: options.cacheToolsList ?? true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crewai.js","sourceRoot":"","sources":["../../src/frameworks/crewai.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAC/C,mBAAmB;IACnB,uBAAuB;IACvB,qBAAqB;IACrB,iBAAiB;IACjB,cAAc;CACN,CAAC;AAmBX,MAAM,UAAU,mCAAmC,CACjD,UAAgD,EAAE;IAElD,OAAO;QACL,SAAS,EAAE,OAAO;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"crewai.js","sourceRoot":"","sources":["../../src/frameworks/crewai.ts"],"names":[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QACtD,YAAY,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG;QAC5C,WAAW;QACX,UAAU;QACV,QAAQ;QACR,4CAA4C;QAC5C,8BAA8B;QAC9B,SAAS;QACT,WAAW;QACX,QAAQ;QACR,wBAAwB,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,GAAG;QACnE,GAAG;QACH,EAAE;QACF,sBAAsB;QACtB,oCAAoC;QACpC,qFAAqF;QACrF,2EAA2E;QAC3E,wBAAwB;QACxB,GAAG;QACH,EAAE;QACF,cAAc;QACd,6GAA6G;QAC7G,6EAA6E;QAC7E,wBAAwB;QACxB,GAAG;QACH,EAAE;QACF,iDAAiD;QACjD,yBAAyB;QACzB,eAAe;QACf,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAyB;IACjD,MAAM,QAAQ,GAAG,MAAM;SACpB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC;SAChD,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,OAAO,IAAI,QAAQ,GAAG,CAAC;AACzB,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAa;IACvC,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type Address, type Hex } from "viem";
|
|
2
|
+
import { type AcceptedX402Payment, type GatewayX402Mode } from "./x402-mode.js";
|
|
3
|
+
import type { X402PaymentRequiredBody } from "../x402/payment-requirements.js";
|
|
2
4
|
import { type SignedInvocationCapability } from "../capability/invocation-capability.js";
|
|
3
5
|
/**
|
|
4
6
|
* Seller-side caller-auth gateway (metrik-agent#63, impl of #62 part 1/2).
|
|
@@ -43,7 +45,21 @@ import { type SignedInvocationCapability } from "../capability/invocation-capabi
|
|
|
43
45
|
* direction here: negative, never positive.
|
|
44
46
|
*/
|
|
45
47
|
/** Machine-readable, closed set of rejection reasons - every failure mode is distinct. */
|
|
46
|
-
export type CallerAuthDenialReason = "missing-capability-header" | "malformed-capability-header" | "capability-expired" | "invalid-signature" | "method-mismatch" | "path-mismatch" | "service-ref-mismatch" | "nonce-replayed" | "stream-not-found" | "buyer-mismatch" | "stream-not-active" | "stream-expired" | "stream-not-funded" | "stream-state-stale"
|
|
48
|
+
export type CallerAuthDenialReason = "missing-capability-header" | "malformed-capability-header" | "capability-expired" | "invalid-signature" | "method-mismatch" | "path-mismatch" | "service-ref-mismatch" | "nonce-replayed" | "stream-not-found" | "buyer-mismatch" | "stream-not-active" | "stream-expired" | "stream-not-funded" | "stream-state-stale"
|
|
49
|
+
/**
|
|
50
|
+
* No Metrik capability, and x402 mode is enabled: the caller may pay per call
|
|
51
|
+
* instead. Carries an x402 `402` body in
|
|
52
|
+
* {@link CallerAuthDecision.x402PaymentRequired}. Emitted ONLY when
|
|
53
|
+
* {@link CallerAuthGatewayConfig.x402} is configured — without it, a missing
|
|
54
|
+
* capability is still `missing-capability-header` / `403`, unchanged.
|
|
55
|
+
*/
|
|
56
|
+
| "x402-payment-required"
|
|
57
|
+
/**
|
|
58
|
+
* The request carried BOTH a Metrik capability and an `X-PAYMENT` header.
|
|
59
|
+
* Refused rather than guessed: serving it would charge the caller through one
|
|
60
|
+
* path while they believe they paid through the other.
|
|
61
|
+
*/
|
|
62
|
+
| "ambiguous-payment-mode";
|
|
47
63
|
/**
|
|
48
64
|
* Default freshness bound for on-chain stream state, in seconds. Base blocks
|
|
49
65
|
* are ~2s, so a healthy endpoint is a few seconds stale at most; this is a
|
|
@@ -57,11 +73,22 @@ export interface CallerAuthDecision {
|
|
|
57
73
|
readonly authorized: boolean;
|
|
58
74
|
readonly reason?: CallerAuthDenialReason;
|
|
59
75
|
/** Set only when `authorized === false`. */
|
|
60
|
-
readonly httpStatus?: 402 | 403;
|
|
61
|
-
/** Set only when `authorized === true
|
|
76
|
+
readonly httpStatus?: 400 | 402 | 403;
|
|
77
|
+
/** Set only when `authorized === true` via the Metrik stream path. */
|
|
62
78
|
readonly stream?: GatewayStreamView;
|
|
63
79
|
/** The decoded (but not necessarily valid) capability, when one was present. */
|
|
64
80
|
readonly capability?: SignedInvocationCapability;
|
|
81
|
+
/**
|
|
82
|
+
* The x402 `402` body to return verbatim. Set only with
|
|
83
|
+
* `reason === "x402-payment-required"`.
|
|
84
|
+
*/
|
|
85
|
+
readonly x402PaymentRequired?: X402PaymentRequiredBody;
|
|
86
|
+
/**
|
|
87
|
+
* A verified x402 payment. Set only when `authorized === true` via the x402
|
|
88
|
+
* path. The caller MUST settle it (see `./x402-mode.ts`) — verification alone
|
|
89
|
+
* moves no money.
|
|
90
|
+
*/
|
|
91
|
+
readonly x402Payment?: AcceptedX402Payment;
|
|
65
92
|
}
|
|
66
93
|
/** The minimal on-chain stream fields the gateway needs to authorize a call. */
|
|
67
94
|
export interface GatewayStreamView {
|
|
@@ -178,6 +205,13 @@ export interface CallerAuthGatewayConfig {
|
|
|
178
205
|
readonly nonceCache?: NonceReplayCache;
|
|
179
206
|
/** Injectable clock (unix seconds), for tests. */
|
|
180
207
|
readonly now?: () => number;
|
|
208
|
+
/**
|
|
209
|
+
* Optional standard-x402 mode. When set, a request with NO Metrik capability
|
|
210
|
+
* gets a real x402 `402` challenge instead of a `403`, so a caller holding
|
|
211
|
+
* only `x402-fetch` can pay per call. Leaving it unset preserves today's
|
|
212
|
+
* behaviour byte for byte.
|
|
213
|
+
*/
|
|
214
|
+
readonly x402?: GatewayX402Mode;
|
|
181
215
|
}
|
|
182
216
|
export interface CallerAuthRequestInput {
|
|
183
217
|
/** Lower-cased-lookup-safe header map (e.g. Node's `IncomingMessage.headers`). */
|
|
@@ -201,6 +235,7 @@ export declare class CallerAuthGateway {
|
|
|
201
235
|
private readonly domain;
|
|
202
236
|
private readonly serviceRefs;
|
|
203
237
|
private readonly now;
|
|
238
|
+
private readonly x402;
|
|
204
239
|
constructor(config: CallerAuthGatewayConfig);
|
|
205
240
|
authorize(request: CallerAuthRequestInput): Promise<CallerAuthDecision>;
|
|
206
241
|
/** Returns the denial reason this single view produces, or `undefined` if it authorizes. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"caller-auth-gateway.d.ts","sourceRoot":"","sources":["../../src/gateway/caller-auth-gateway.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhE,OAAO,EAOL,KAAK,0BAA0B,EAChC,MAAM,wCAAwC,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,0FAA0F;AAC1F,MAAM,MAAM,sBAAsB,GAC9B,2BAA2B,GAC3B,6BAA6B,GAC7B,oBAAoB,GACpB,mBAAmB,GACnB,iBAAiB,GACjB,eAAe,GACf,sBAAsB,GACtB,gBAAgB,GAChB,kBAAkB,GAClB,gBAAgB,GAChB,mBAAmB,GACnB,gBAAgB,GAChB,mBAAmB,GACnB,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"caller-auth-gateway.d.ts","sourceRoot":"","sources":["../../src/gateway/caller-auth-gateway.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhE,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAOL,KAAK,0BAA0B,EAChC,MAAM,wCAAwC,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,0FAA0F;AAC1F,MAAM,MAAM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