@absol-labs/agent 0.8.0 → 0.9.1

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.
Files changed (66) hide show
  1. package/dist/discovery/registry.d.ts +110 -305
  2. package/dist/discovery/registry.d.ts.map +1 -1
  3. package/dist/discovery/registry.js +141 -318
  4. package/dist/discovery/registry.js.map +1 -1
  5. package/dist/frameworks/agentkit.d.ts.map +1 -1
  6. package/dist/frameworks/agentkit.js +31 -10
  7. package/dist/frameworks/agentkit.js.map +1 -1
  8. package/dist/frameworks/eliza.d.ts.map +1 -1
  9. package/dist/frameworks/eliza.js +14 -3
  10. package/dist/frameworks/eliza.js.map +1 -1
  11. package/dist/frameworks/langchain.d.ts.map +1 -1
  12. package/dist/frameworks/langchain.js +14 -3
  13. package/dist/frameworks/langchain.js.map +1 -1
  14. package/dist/index.d.ts +2 -2
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +2 -2
  17. package/dist/index.js.map +1 -1
  18. package/dist/mcp/server.d.ts.map +1 -1
  19. package/dist/mcp/server.js +26 -5
  20. package/dist/mcp/server.js.map +1 -1
  21. package/dist/sdk/client.d.ts +19 -2
  22. package/dist/sdk/client.d.ts.map +1 -1
  23. package/dist/sdk/client.js +18 -2
  24. package/dist/sdk/client.js.map +1 -1
  25. package/dist/wallet/cdp-sdk.d.ts +23 -0
  26. package/dist/wallet/cdp-sdk.d.ts.map +1 -0
  27. package/dist/wallet/cdp-sdk.js +27 -0
  28. package/dist/wallet/cdp-sdk.js.map +1 -0
  29. package/dist/wallet/provider.d.ts +1 -1
  30. package/dist/wallet/provider.d.ts.map +1 -1
  31. package/dist/wallet/provider.js +8 -3
  32. package/dist/wallet/provider.js.map +1 -1
  33. package/dist/zktls/reclaim-js-sdk.d.ts +24 -0
  34. package/dist/zktls/reclaim-js-sdk.d.ts.map +1 -0
  35. package/dist/zktls/reclaim-js-sdk.js +29 -0
  36. package/dist/zktls/reclaim-js-sdk.js.map +1 -0
  37. package/dist/zktls/reclaim.d.ts +14 -2
  38. package/dist/zktls/reclaim.d.ts.map +1 -1
  39. package/dist/zktls/reclaim.js +29 -6
  40. package/dist/zktls/reclaim.js.map +1 -1
  41. package/dist/zktls/t2-delivery-proof.d.ts +8 -1
  42. package/dist/zktls/t2-delivery-proof.d.ts.map +1 -1
  43. package/dist/zktls/t2-delivery-proof.js +22 -6
  44. package/dist/zktls/t2-delivery-proof.js.map +1 -1
  45. package/docs/agent-layer.md +150 -0
  46. package/docs/autonomous-privy-wallet.md +133 -0
  47. package/docs/crewai.md +70 -0
  48. package/docs/eliza.md +109 -0
  49. package/docs/langchain.md +63 -0
  50. package/docs/mcp-hosted.md +137 -0
  51. package/docs/privy-embedded-wallet.md +102 -0
  52. package/docs/quickstart.md +370 -0
  53. package/docs/threat-model.md +160 -0
  54. package/package.json +19 -6
  55. package/src/discovery/registry.ts +242 -414
  56. package/src/frameworks/agentkit.ts +32 -8
  57. package/src/frameworks/eliza.ts +14 -3
  58. package/src/frameworks/langchain.ts +14 -3
  59. package/src/index.ts +7 -0
  60. package/src/mcp/server.ts +26 -5
  61. package/src/sdk/client.ts +38 -3
  62. package/src/wallet/cdp-sdk.ts +33 -0
  63. package/src/wallet/provider.ts +16 -9
  64. package/src/zktls/reclaim-js-sdk.ts +50 -0
  65. package/src/zktls/reclaim.ts +57 -23
  66. package/src/zktls/t2-delivery-proof.ts +28 -10
@@ -0,0 +1,160 @@
1
+ # Agent Threat Model
2
+
3
+ This document is the agent-layer security review for Phase 2. It covers the
4
+ autonomous spend surface in `streamproof-agent` and maps each threat to the
5
+ current mitigation, code path, and test coverage.
6
+
7
+ It complements the cross-repo rules in
8
+ [`Absol-Labs/.github/CONTRIBUTING.md`](../../streamproof-dotgithub/CONTRIBUTING.md)
9
+ and the per-repo security pass in [`AGENTS.md`](../AGENTS.md). The same
10
+ non-negotiables apply here:
11
+
12
+ - no fake green paths
13
+ - no secrets in git or logs
14
+ - fail-closed autonomous spend
15
+ - explicit signing only through the configured account or wallet
16
+
17
+ ## Scope
18
+
19
+ In scope:
20
+
21
+ - signed spend mandates in [`src/mandates/mandate.ts`](../src/mandates/mandate.ts)
22
+ - the mandate-gated SDK wrapper in [`src/sdk/client.ts`](../src/sdk/client.ts)
23
+ - x402 verified-stream opens in [`src/x402/facilitator.ts`](../src/x402/facilitator.ts)
24
+ - MCP fund-moving tools in [`src/mcp/server.ts`](../src/mcp/server.ts)
25
+ - zkTLS consumer delivery proofs in [`src/zktls/reclaim.ts`](../src/zktls/reclaim.ts)
26
+ - wallet custody in [`src/wallet/provider.ts`](../src/wallet/provider.ts)
27
+
28
+ Out of scope:
29
+
30
+ - oracle correctness
31
+ - escrow correctness
32
+ - decentralized verifier / slashing / dispute work
33
+
34
+ ## Threat Map
35
+
36
+ | Threat | Why it matters | Current mitigation | Test / evidence | Residual risk |
37
+ | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
38
+ | Runaway spend | A prompt or tool call opens streams beyond the owner's intent. | Every autonomous fund-moving path calls `checkMandate()` before the SDK can write: `openVerifiedStream()`, `claimStream()`, `closeStream()`, `reclaimStream()`, MCP `hire_verified_service`, and MCP `reclaim_unspent`. Mandates cap per-stream, cumulative spend, rate, duration, and operator. Denial is a hard stop. | [`test/mandate.test.ts`](../test/mandate.test.ts), [`test/sdk-client.test.ts`](../test/sdk-client.test.ts), [`test/mcp.test.ts`](../test/mcp.test.ts), [`test/x402.int.test.ts`](../test/x402.int.test.ts) | `spentSoFarUsdc` and revocation data are resolver inputs. If an integrator provides stale values, the agent still fails closed on signature/expiry/operator checks, but cumulative-cap freshness depends on the integrator's state source. |
39
+ | Mandate bypass | A caller skips the mandate layer and reaches the SDK write path directly from the agent layer. | The agent wrapper no longer exposes ungated autonomous write helpers. Existing-stream actions re-read the stream and authorize against the actual operator before `claim`, `close`, or `reclaim`. MCP also prechecks before dispatch. | [`src/sdk/client.ts`](../src/sdk/client.ts), [`test/sdk-client.test.ts`](../test/sdk-client.test.ts), [`test/mcp.test.ts`](../test/mcp.test.ts) | A caller can still use `@absol-labs/sdk` directly outside this repo. That is expected; this document only claims the agent layer itself is mandate-gated. |
40
+ | Key exposure | The agent leaks a private key through logs, env parsing, tool args, or local persistence. | No MCP tool accepts a raw key. Wallet selection is explicit: injected viem account, CDP Server Wallet v2, or an authenticated Privy embedded EOA provider. CDP/Privy paths remote-sign and never export private keys into Metrik code. `.env.example` contains names only. | [`src/wallet/provider.ts`](../src/wallet/provider.ts), [`test/wallet.test.ts`](../test/wallet.test.ts), [`test/privy-wallet.test.ts`](../test/privy-wallet.test.ts), [`README.md`](../README.md) | Injected-key mode is still as safe as the caller's own host. Privy authentication/session revocation remains the host/provider's responsibility. |
41
+ | Prompt-injection-driven spend | A hostile response or tool output tries to coerce the agent into paying a different operator or budget. | Structured inputs are validated, x402 settlement targets must match the configured chain/escrow, and any spend still must satisfy the owner's signed mandate. | [`src/x402/facilitator.ts`](../src/x402/facilitator.ts), [`test/x402.test.ts`](../test/x402.test.ts), [`test/sdk-client.test.ts`](../test/sdk-client.test.ts) | Prompt injection can still trigger tool invocation attempts. The safety claim is not "the prompt cannot be attacked"; it is "the attack cannot exceed the mandate or redirect settlement silently." |
42
+ | Mandate replay | A previously valid signed mandate is replayed after revocation or outside the intended lifetime. | Mandates are EIP-712 signed over `mandateId`, `owner`, `chainId`, `issuedAt`, expiry, and policy hashes. `checkMandate()` verifies signature, revocation, expiry, then policy. Integrators can revoke by `mandateId` and track cumulative spend. | [`src/mandates/mandate.ts`](../src/mandates/mandate.ts), [`test/mandate.test.ts`](../test/mandate.test.ts), [`test/mcp.test.ts`](../test/mcp.test.ts) | Replay protection is only as strong as revocation and cumulative-spend state freshness. The signed payload itself is bound to one chain and one owner, but revocation is local state today. |
43
+ | False or weak delivery evidence | A consumer submits a proof that is validly signed by the zkTLS system but not bound to the intended request or stream context. | The Reclaim adapter re-verifies every proof locally against the exact URL/method/body/match/redaction spec supplied by the caller, and binds the proof context to buyer/stream metadata before returning it. MCP only exposes the public-request subset so secrets do not leak through tool arguments. | [`src/zktls/reclaim.ts`](../src/zktls/reclaim.ts), [`src/x402/facilitator.ts`](../src/x402/facilitator.ts), [`src/mcp/server.ts`](../src/mcp/server.ts), [`test/reclaim.test.ts`](../test/reclaim.test.ts), [`test/x402.test.ts`](../test/x402.test.ts), [`test/mcp.test.ts`](../test/mcp.test.ts) | L2 is still consumer-supplied evidence. A malicious consumer can withhold proofs, and settlement must still treat L1/oracle evidence as authoritative on failure, ambiguity, and expiry. |
44
+
45
+ ## Fund-Moving Paths
46
+
47
+ These are the autonomous fund-moving paths in the current agent layer:
48
+
49
+ 1. `VerifiedStreamAgentClient.openVerifiedStream()`
50
+ 2. `VerifiedStreamAgentClient.claimStream()`
51
+ 3. `VerifiedStreamAgentClient.closeStream()`
52
+ 4. `VerifiedStreamAgentClient.reclaimStream()`
53
+ 5. MCP `hire_verified_service`
54
+ 6. MCP `reclaim_unspent`
55
+ 7. x402 `open()` via `VerifiedStreamX402Facilitator`
56
+
57
+ All of them now pass a signed mandate check before the SDK can send a write.
58
+
59
+ Read-only paths are not mandate-gated:
60
+
61
+ - `getStreamStatus()`
62
+ - MCP `check_stream_status`
63
+ - MCP `list_streams`
64
+ - MCP `prove_https_response`
65
+
66
+ ## Key Custody Options
67
+
68
+ ### Injected caller account
69
+
70
+ - Source: `METRIK_AGENT_PRIVATE_KEY`
71
+ - Trust model: the caller hosts the signer locally.
72
+ - Safety properties:
73
+ - the agent layer does not request the key through tool args
74
+ - the key is not logged or written to disk by agent code
75
+ - every autonomous write still needs a valid signed mandate
76
+
77
+ ### Coinbase CDP Server Wallet v2
78
+
79
+ - Source: `CDP_API_KEY_ID`, `CDP_API_KEY_SECRET`, `CDP_WALLET_SECRET`
80
+ - Trust model: Coinbase holds signing material inside its remote signing boundary.
81
+ - Safety properties:
82
+ - Metrik only receives a signing-capable account object
83
+ - the private key is never exported into this repo
84
+ - the same mandate checks apply before any autonomous write
85
+
86
+ ### Privy embedded user-owned EOA
87
+
88
+ - Source: an authenticated Privy EIP-1193 wallet provider supplied by the host application
89
+ - Trust model: the user owns/authenticates the embedded EOA through Privy; the agent package
90
+ sees only the provider and public wallet address
91
+ - Safety properties:
92
+ - no Privy app secret or wallet key is accepted by the adapter
93
+ - chain and account identity are checked before construction and before each signature
94
+ - every autonomous write still requires the signed Metrik spend mandate
95
+ - Headless boundary:
96
+ - the user attaches a Privy additional signer under a non-empty provider policy
97
+ - the broker stores only a hash of the short-lived agent token and rechecks a signed
98
+ Metrik mandate, decoded calldata, stream ownership/state, expiry, and revocation
99
+ - the first successful write requests provider gas sponsorship; later writes do not
100
+ - Limitations: ERC-4337/EIP-1271 smart accounts are not supported
101
+
102
+ ### Autonomous agent-owned Privy EOA
103
+
104
+ - Source: a P-256 key generated by the agent process and persisted only through
105
+ an injected secure store or the host OS credential manager
106
+ - Trust model: the agent owns the authorization key; the broker owns only the
107
+ Privy app credentials and wallet identifier
108
+ - Safety properties:
109
+ - provisioning sends the broker a public SPKI key and proof-of-possession,
110
+ never the PKCS8 private key
111
+ - a fixed approved Metrik policy is required when the broker creates the EOA
112
+ - provisioning fails closed on a credential store that does not survive a host
113
+ reboot (process memory, or the Linux kernel keyring the OS keyring silently
114
+ falls back to when no Secret Service provider answers), because losing the
115
+ owner key makes any funds the wallet holds permanently unspendable
116
+ - every write uses prepare → local P-256 signature → one-time execute; the
117
+ broker verifies the exact canonical Privy request before forwarding it
118
+ - nonce/public-key binding, short proof/request expiry, strict P-256 parsing,
119
+ idempotency, and restricted Metrik calldata prevent replay and arbitrary RPC
120
+ - Limitations: the broker must provide persistent idempotency/replay storage and
121
+ a real Privy integration. This path does not claim smart-account/EIP-1271 or
122
+ gas sponsorship support. A failed secure store is a hard stop; plaintext
123
+ persistence is intentionally unsupported.
124
+
125
+ ### CDP-owned smart account + paymaster limits
126
+
127
+ - Source: optional smart-account provisioning in the wallet layer plus SDK
128
+ `gasAbstraction`
129
+ - Trust model: the owner signer controls a smart account, and the bundler/paymaster
130
+ can impose additional sponsorship policy.
131
+ - Safety properties:
132
+ - approvals remain bounded to the requested stream budget
133
+ - the SDK exposes a policy hook for session/per-merchant limits
134
+ - paymaster allowlists can restrict sponsored targets such as the escrow and
135
+ EntryPoint
136
+
137
+ ### Session keys
138
+
139
+ `PrivySessionBroker` issues a random, short-lived bearer credential after verifying the
140
+ user's Privy access token, embedded-wallet ownership, and owner-signed Metrik mandate.
141
+ The credential never contains a wallet key. `createPrivySessionProvider` turns it into a
142
+ restricted EIP-1193 boundary for an external agent; revocation and expiry fail closed.
143
+
144
+ ## Security Pass Alignment
145
+
146
+ The current implementation satisfies the agent-layer security pass this way:
147
+
148
+ - Every autonomous fund-moving path calls `checkMandate()` before the SDK write.
149
+ - No private key is silently held, logged, or embedded; signing is explicit via
150
+ the configured injected signer or CDP signer.
151
+ - Budget, rate, duration, and operator limits are enforced in code, not
152
+ merely documented.
153
+ - Secrets stay in env / repo-secret surfaces; `.env.example` is names only.
154
+
155
+ ## Residual Risks
156
+
157
+ - Revocation and cumulative-spend state are still local/integrator-provided.
158
+ - CDP and paymaster trust are external dependencies.
159
+ - zkTLS proofs depend on Reclaim as an external attestation system.
160
+ - L2 remains supplemental evidence; it must not override L1 failure or ambiguity.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absol-labs/agent",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
4
4
  "description": "Metrik agent layer: x402 verified-streaming payments, an MCP server, framework tools, and spend mandates so AI agents can hire and pay verified services safely.",
5
5
  "license": "MIT",
6
6
  "author": "Absol Labs",
@@ -47,6 +47,7 @@
47
47
  "sideEffects": false,
48
48
  "files": [
49
49
  "dist",
50
+ "docs",
50
51
  "src"
51
52
  ],
52
53
  "repository": {
@@ -66,38 +67,50 @@
66
67
  "pnpm": "9.15.x"
67
68
  },
68
69
  "dependencies": {
69
- "@absol-labs/sdk": "^0.7.0",
70
+ "@absol-labs/sdk": "^0.9.0",
70
71
  "@absol-labs/shared": "^0.12.1",
71
- "@coinbase/cdp-sdk": "^1.51.2",
72
72
  "@modelcontextprotocol/sdk": "^1.29.0",
73
73
  "@napi-rs/keyring": "1.3.0",
74
74
  "@privy-io/node": "0.33.0",
75
- "@reclaimprotocol/js-sdk": "^5.6.0",
76
- "@reclaimprotocol/zk-fetch": "^1.0.0",
77
75
  "reflect-metadata": "^0.2.2",
78
76
  "viem": "^2.21.0",
79
77
  "zod": "^3.24.0"
80
78
  },
81
79
  "peerDependencies": {
82
80
  "@coinbase/agentkit": "^0.10.4",
81
+ "@coinbase/cdp-sdk": "^1.51.2",
83
82
  "@elizaos/core": "^1.7.2",
84
- "@langchain/core": "^1.2.0"
83
+ "@langchain/core": "^1.2.0",
84
+ "@reclaimprotocol/js-sdk": "^5.6.0",
85
+ "@reclaimprotocol/zk-fetch": "^1.0.0"
85
86
  },
86
87
  "peerDependenciesMeta": {
87
88
  "@coinbase/agentkit": {
88
89
  "optional": true
89
90
  },
91
+ "@coinbase/cdp-sdk": {
92
+ "optional": true
93
+ },
90
94
  "@elizaos/core": {
91
95
  "optional": true
92
96
  },
93
97
  "@langchain/core": {
94
98
  "optional": true
99
+ },
100
+ "@reclaimprotocol/js-sdk": {
101
+ "optional": true
102
+ },
103
+ "@reclaimprotocol/zk-fetch": {
104
+ "optional": true
95
105
  }
96
106
  },
97
107
  "devDependencies": {
98
108
  "@coinbase/agentkit": "^0.10.4",
109
+ "@coinbase/cdp-sdk": "^1.51.2",
99
110
  "@elizaos/core": "^1.7.2",
100
111
  "@langchain/core": "^1.2.0",
112
+ "@reclaimprotocol/js-sdk": "^5.6.0",
113
+ "@reclaimprotocol/zk-fetch": "^1.0.0",
101
114
  "@swc/core": "^1.10.0",
102
115
  "@types/node": "^20.17.0",
103
116
  "prettier": "^3.4.0",