@absol-labs/agent 0.10.0 → 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 +107 -23
- 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/commands/claim.d.ts.map +1 -1
- package/dist/cli/commands/claim.js +20 -4
- package/dist/cli/commands/claim.js.map +1 -1
- package/dist/cli/commands/close.d.ts.map +1 -1
- package/dist/cli/commands/close.js +16 -4
- package/dist/cli/commands/close.js.map +1 -1
- package/dist/cli/commands/invoke.d.ts.map +1 -1
- package/dist/cli/commands/invoke.js +1 -0
- package/dist/cli/commands/invoke.js.map +1 -1
- package/dist/cli/commands/open.d.ts.map +1 -1
- package/dist/cli/commands/open.js +63 -11
- package/dist/cli/commands/open.js.map +1 -1
- package/dist/cli/commands/reclaim-unverified.d.ts.map +1 -1
- package/dist/cli/commands/reclaim-unverified.js +12 -4
- package/dist/cli/commands/reclaim-unverified.js.map +1 -1
- package/dist/cli/commands/reclaim.d.ts.map +1 -1
- package/dist/cli/commands/reclaim.js +16 -5
- package/dist/cli/commands/reclaim.js.map +1 -1
- package/dist/cli/commands/streams.js +1 -1
- package/dist/cli/commands/streams.js.map +1 -1
- package/dist/cli/deps.d.ts +53 -7
- package/dist/cli/deps.d.ts.map +1 -1
- package/dist/cli/deps.js +65 -15
- package/dist/cli/deps.js.map +1 -1
- 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/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/wallet.d.ts +108 -39
- package/dist/cli/wallet.d.ts.map +1 -1
- package/dist/cli/wallet.js +108 -43
- package/dist/cli/wallet.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/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/server.d.ts +49 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +513 -24
- 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/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 +12 -8
- package/docs/cli.md +158 -22
- package/docs/mcp-hosted.md +4 -3
- package/docs/mcp-reference.md +175 -0
- package/docs/quickstart.md +18 -4
- package/docs/threat-model.md +4 -3
- package/docs/x402.md +648 -0
- package/package.json +18 -7
- package/src/capability/invocation-capability.ts +17 -1
- package/src/cli/commands/claim.ts +30 -4
- package/src/cli/commands/close.ts +20 -4
- package/src/cli/commands/invoke.ts +1 -0
- package/src/cli/commands/open.ts +76 -10
- package/src/cli/commands/reclaim-unverified.ts +16 -4
- package/src/cli/commands/reclaim.ts +22 -5
- package/src/cli/commands/streams.ts +1 -1
- package/src/cli/deps.ts +115 -24
- package/src/cli/privy.ts +396 -0
- package/src/cli/spend-policy.ts +139 -0
- package/src/cli/wallet.ts +188 -57
- package/src/gateway/caller-auth-gateway.ts +77 -6
- package/src/gateway/http-server.ts +280 -6
- package/src/gateway/x402-mode.ts +350 -0
- package/src/index.ts +40 -5
- package/src/mandates/env.ts +3 -2
- package/src/mcp/server.ts +681 -29
- package/src/mcp/service-invoker.ts +285 -0
- 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
package/README.md
CHANGED
|
@@ -11,8 +11,12 @@ honestly scoped, is what this package makes an agent able to enforce, never
|
|
|
11
11
|
It builds on [`@absol-labs/sdk`](https://github.com/Absol-Labs/metrik-sdk), which speaks
|
|
12
12
|
to the on-chain metered escrow. This layer wraps that client in the guardrails and
|
|
13
13
|
integration surfaces an agent actually needs: owner-signed spend mandates that gate every
|
|
14
|
-
fund move,
|
|
15
|
-
|
|
14
|
+
fund move, a Metrik-native `402` challenge flow that turns a payment challenge into a verified
|
|
15
|
+
stream, **a spec-compliant x402 facilitator that refuses to settle payment for a service its
|
|
16
|
+
own oracle says is not delivering** (read [`docs/x402.md`](./docs/x402.md) — the two `402`
|
|
17
|
+
flows are different and only one of them is x402), an MCP server that exposes
|
|
18
|
+
hire/monitor/reclaim as agent tools,
|
|
19
|
+
adapters for the major agent frameworks,
|
|
16
20
|
Reclaim consumer zkTLS for buyer-side delivery proofs, and non-custodial Coinbase CDP/Privy
|
|
17
21
|
wallets so Metrik never holds a key.
|
|
18
22
|
|
|
@@ -53,15 +57,52 @@ and hard-stops on denial; `MandateDecision` returns a machine-readable reason. B
|
|
|
53
57
|
actions (close, reclaim) verify only the signature — never expiry or caps — so a lapsed
|
|
54
58
|
mandate can never strand the buyer's own funds in escrow.
|
|
55
59
|
|
|
56
|
-
**The
|
|
57
|
-
into a real on-chain stream open instead of a one-shot payment. The agent
|
|
58
|
-
verified-streaming requirement, signs a payload bound to its mandate, and the
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
**
|
|
60
|
+
**The Metrik `402` challenge flow** (`VerifiedStreamFacilitator`) turns an HTTP `402`
|
|
61
|
+
challenge into a real on-chain stream open instead of a one-shot payment. The agent
|
|
62
|
+
receives a verified-streaming requirement, signs a payload bound to its mandate, and the
|
|
63
|
+
stream is opened through the SDK.
|
|
64
|
+
|
|
65
|
+
> **This is Metrik's own `402` flow, not the x402 protocol.** It uses its own scheme
|
|
66
|
+
> string (`streamproof-verified-stream`), its own challenge and payload shapes, and its
|
|
67
|
+
> own `X-METRIK-PAYMENT` header. It does **not** speak the x402 wire format and will
|
|
68
|
+
> **not** interoperate with `x402-fetch`, `x402-axios`, `x402-express`, or any standard
|
|
69
|
+
> x402 client or facilitator. For that, see the separate facilitator below.
|
|
70
|
+
|
|
71
|
+
**The x402 verified-delivery facilitator** (`metrik-x402-facilitator`) is the other,
|
|
72
|
+
genuinely-x402 half. It implements the standard facilitator interface — `POST /verify`,
|
|
73
|
+
`POST /settle`, `GET /supported` — for the standard `exact` scheme, and then asks one
|
|
74
|
+
question no other facilitator can: **is this service currently passing Metrik's delivery
|
|
75
|
+
checks?** If the oracle says it is failing, `/verify` answers `isValid: false` and `/settle`
|
|
76
|
+
broadcasts nothing. Standard headers, standard schemes, `x402-fetch` works untouched, no
|
|
77
|
+
contract change.
|
|
78
|
+
|
|
79
|
+
The seller-side gateway has a matching opt-in mode: a request with no Metrik capability gets
|
|
80
|
+
a real x402 `402` carrying `PaymentRequirements` whose `payTo` is derived from the
|
|
81
|
+
operator-signed listing, so an agent holding only `x402-fetch` can pay per call.
|
|
82
|
+
|
|
83
|
+
`POST /settle` makes the operator's relayer sign and pay gas, so it is fenced: an **asset
|
|
84
|
+
allowlist** (default the chain's USDC) so the relayer can never be induced to call a
|
|
85
|
+
caller-chosen contract, a **bearer token** (`METRIK_X402_FACILITATOR_TOKEN`, required at
|
|
86
|
+
startup), a **settlement scope** limiting gas spend to resources Metrik tracks, and
|
|
87
|
+
network/non-zero-amount checks. `/verify` and `/supported` stay public.
|
|
88
|
+
|
|
89
|
+
> This is **weaker buyer protection than a stream, and deliberately so.** An `exact`
|
|
90
|
+
> payment holds nothing in escrow: the gate can PREVENT a payment to a failing service, it
|
|
91
|
+
> can **never** recover one that already went through. Only the stream path makes unearned
|
|
92
|
+
> money recoverable. [`docs/x402.md`](./docs/x402.md) has the full account, the
|
|
93
|
+
> 90-second freshness window and the reasoning behind it, and what is still unproven.
|
|
94
|
+
>
|
|
95
|
+
> **Settlement has never broadcast a transaction from this repo.** `/settle` is implemented
|
|
96
|
+
> end to end and delegates to the real `x402` `settle()`, but running it needs a relayer
|
|
97
|
+
> wallet funded with gas that does not exist yet. The server refuses to start without a
|
|
98
|
+
> relayer key unless `METRIK_X402_ALLOW_VERIFY_ONLY=true` is set explicitly.
|
|
99
|
+
|
|
100
|
+
**The MCP server** exposes `discover_services`, `hire_verified_service`, `invoke_service`,
|
|
62
101
|
`check_stream_status`, `reclaim_unspent`, `list_streams`, and — when Reclaim credentials are
|
|
63
|
-
configured — `prove_https_response`, so
|
|
64
|
-
|
|
102
|
+
configured — `prove_https_response`, so an MCP-native agent can discover a service, pay for
|
|
103
|
+
it, **call it**, and recover what it did not spend without leaving the tool surface. It reads
|
|
104
|
+
settlement config from the environment and never accepts a raw key as a tool argument. Full
|
|
105
|
+
reference: [`docs/mcp-reference.md`](./docs/mcp-reference.md).
|
|
65
106
|
|
|
66
107
|
**Framework adapters** put the same mandate-gated client behind AgentKit, ElizaOS,
|
|
67
108
|
LangChain, and CrewAI, each importable from its own subpath.
|
|
@@ -206,15 +247,15 @@ See [`scripts/e2e-hire.ts`](./scripts/e2e-hire.ts) for the full journey (create/
|
|
|
206
247
|
hire → invoke → settle) run against real Base Sepolia infrastructure: `pnpm e2e:hire` (needs real CDP
|
|
207
248
|
creds — see `.env.example`).
|
|
208
249
|
|
|
209
|
-
### Hire via
|
|
250
|
+
### Hire via the Metrik `402` flow: challenge → signed payload → open stream
|
|
210
251
|
|
|
211
252
|
```ts
|
|
212
253
|
import {
|
|
213
|
-
|
|
214
|
-
|
|
254
|
+
VerifiedStreamFacilitator,
|
|
255
|
+
encodeStreamPayloadHeader,
|
|
215
256
|
} from "@absol-labs/agent";
|
|
216
257
|
|
|
217
|
-
const facilitator = new
|
|
258
|
+
const facilitator = new VerifiedStreamFacilitator({
|
|
218
259
|
sdkConfig, // @absol-labs/sdk StreamProofClientConfig (chain, transport, account, escrow, usdc)
|
|
219
260
|
});
|
|
220
261
|
|
|
@@ -228,12 +269,17 @@ const challenge = facilitator.challenge({
|
|
|
228
269
|
maxBudgetUsdc: 2_000_000n,
|
|
229
270
|
});
|
|
230
271
|
|
|
231
|
-
const header =
|
|
272
|
+
const header = encodeStreamPayloadHeader({ challenge, signedMandate });
|
|
232
273
|
const { streamId } = await facilitator.open(header); // mandate-gated, opens on-chain
|
|
233
274
|
```
|
|
234
275
|
|
|
235
|
-
The scheme name is exported as `
|
|
236
|
-
`
|
|
276
|
+
The scheme name is exported as `METRIK_STREAM_SCHEME`; `parseStreamChallengeJson`,
|
|
277
|
+
`parseStreamPayloadHeader`, and `encodeStreamPayloadHeader` handle the wire format on both
|
|
278
|
+
sides, and the payload travels under `METRIK_PAYMENT_HEADER` (`x-metrik-payment`) — never
|
|
279
|
+
under x402's `X-PAYMENT` (the gateway's separate x402 mode uses that header, because there
|
|
280
|
+
it really is x402; a request carrying both is refused with `400 ambiguous-payment-mode`).
|
|
281
|
+
This wire format is Metrik's own; see [`docs/x402.md`](./docs/x402.md). The older `X402*`
|
|
282
|
+
identifiers still work as deprecated aliases, but the names above are canonical.
|
|
237
283
|
|
|
238
284
|
### The CLI
|
|
239
285
|
|
|
@@ -250,12 +296,38 @@ metrik watch <streamId> --interval 15
|
|
|
250
296
|
metrik invoke <streamId> --method POST --path /transform --body '{"text":"hi"}'
|
|
251
297
|
metrik close <streamId>
|
|
252
298
|
metrik reclaim <streamId>
|
|
299
|
+
metrik claim <streamId> # operator: redeem what verified
|
|
300
|
+
metrik reclaim-unverified <streamId> --forfeit-unclaimed # buyer escape hatch
|
|
253
301
|
metrik mcp --print-config
|
|
254
302
|
```
|
|
255
303
|
|
|
256
304
|
- **Testnet only.** The CLI refuses any chain outside Base Sepolia (`84532`), and
|
|
257
305
|
re-reads the chain id the RPC endpoint actually serves before it signs anything.
|
|
258
306
|
There is no override flag.
|
|
307
|
+
- **The meter runs on verified availability, not on your calls.** A stream is a
|
|
308
|
+
per-second rental of an endpoint that keeps proving it is alive — not per-request
|
|
309
|
+
billing. You are charged for the seconds that verified whether or not you invoked
|
|
310
|
+
once or a thousand times, and a failed interval advances the clock and pays nothing.
|
|
311
|
+
- **`metrik claim` is the seller's side** of the `operator claimable` figure `status`
|
|
312
|
+
has always printed. It is operator-gated on-chain, so a wallet that is not the
|
|
313
|
+
stream's operator is refused before anything is broadcast rather than paying gas to
|
|
314
|
+
learn it.
|
|
315
|
+
- **`metrik reclaim-unverified` is the no-proof escape hatch.** Every other route to a
|
|
316
|
+
buyer's money needs a Merkle proof from the oracle, so it is only as available as the
|
|
317
|
+
oracle is; this one needs no proof, no quorum and no guardian. It costs the operator
|
|
318
|
+
everything they verifiably earned but had not yet claimed on-chain — permanently, and
|
|
319
|
+
paid to the buyer — so it is its own command behind a mandatory `--forfeit-unclaimed`,
|
|
320
|
+
never a flag on `reclaim`. It unlocks at `expiresAt + escapeGraceSeconds`, gated on
|
|
321
|
+
**`expiresAt` and never on `closedAt`**: closing a 24h stream after ten minutes does
|
|
322
|
+
not bring the hatch forward.
|
|
323
|
+
- **`status` may report `pending final checkpoint`** after a stream stops, instead of a
|
|
324
|
+
reclaimable figure. That is correct: until a checkpoint covers the stop time, any
|
|
325
|
+
number would be one you cannot actually obtain.
|
|
326
|
+
- **`discover` and `status` disclose verifier overlap.** When a listing's operator is
|
|
327
|
+
also one of the escrow's oracle signers, both say so — the party being paid is among
|
|
328
|
+
the parties attesting that delivery happened. On the current testnet deployment this
|
|
329
|
+
fires on every live listing, because the team seeds its own supply so the marketplace
|
|
330
|
+
is testable. SLA text in a listing is seller-authored and labelled unverified.
|
|
259
331
|
- **`open --dry-run` needs no wallet at all.** It broadcasts nothing, so it prints the
|
|
260
332
|
intended call (and says which parts it could not produce without a key) rather than
|
|
261
333
|
demanding one. `invoke` does need the key even though it broadcasts nothing: it signs
|
|
@@ -294,8 +366,15 @@ is also importable (`@absol-labs/agent/cli`) if you want to embed it.
|
|
|
294
366
|
|
|
295
367
|
### Run the MCP server
|
|
296
368
|
|
|
297
|
-
|
|
298
|
-
asks for a raw key in
|
|
369
|
+
Two transports — stdio for local dev, Streamable HTTP for hosting — over the same tool set.
|
|
370
|
+
Either reads its settlement config from the environment; neither ever asks for a raw key in
|
|
371
|
+
a tool argument.
|
|
372
|
+
|
|
373
|
+
**What the agent is buying is TIME, not calls.** `hire_verified_service` starts a per-second
|
|
374
|
+
meter on verified availability; `invoke_service` costs nothing extra, and not calling costs
|
|
375
|
+
the same as calling. Only `reclaim_unspent` stops the clock, and nothing pushes money back on
|
|
376
|
+
its own. Every tool that opens, reads, or ends a stream says so in its own description, which
|
|
377
|
+
is what an agent actually reads.
|
|
299
378
|
|
|
300
379
|
```bash
|
|
301
380
|
metrik-mcp # installed, or: npx --package @absol-labs/agent metrik-mcp
|
|
@@ -317,7 +396,7 @@ import {
|
|
|
317
396
|
} from "@absol-labs/agent";
|
|
318
397
|
|
|
319
398
|
console.log(METRIK_MCP_TOOLS.map((t) => t.name));
|
|
320
|
-
// discover_services, hire_verified_service, check_stream_status,
|
|
399
|
+
// discover_services, hire_verified_service, invoke_service, check_stream_status,
|
|
321
400
|
// reclaim_unspent, list_streams, prove_https_response
|
|
322
401
|
|
|
323
402
|
await startVerifiedStreamMcpServerStdio(); // reads process.env, connects stdio
|
|
@@ -480,7 +559,7 @@ services use output-probe verification until that protocol support exists.
|
|
|
480
559
|
`ReclaimConsumerProofService` (and `createReclaimConsumerProofServiceFromEnv`) generate a
|
|
481
560
|
Reclaim-backed proof of the exact HTTPS response the agent consumed, verified locally
|
|
482
561
|
against the declared URL, method, body, match, and redaction policy before it is trusted.
|
|
483
|
-
`
|
|
562
|
+
`VerifiedStreamFacilitator.proveConsumedHttpsResponse()` binds that proof to the same
|
|
484
563
|
buyer/mandate context that opened the stream. When credentials require private headers or
|
|
485
564
|
cookies, use the programmatic service or the facilitator directly rather than the MCP tool,
|
|
486
565
|
so secrets never pass through model-visible tool arguments. Treat the result as an L2
|
|
@@ -520,8 +599,12 @@ pnpm test
|
|
|
520
599
|
pnpm build
|
|
521
600
|
```
|
|
522
601
|
|
|
523
|
-
The x402 facilitator, zkTLS proof path,
|
|
524
|
-
adapters are all real and tested in-repo.
|
|
602
|
+
The Metrik `402` challenge flow, the x402 verified-delivery facilitator, zkTLS proof path,
|
|
603
|
+
signed-mandate engine, MCP server, and framework adapters are all real and tested in-repo.
|
|
604
|
+
The x402 suite drives the published `x402-fetch` client through a full 402 -> pay -> retry
|
|
605
|
+
cycle against the gateway and asserts the same valid payment is refused when the oracle
|
|
606
|
+
reports the service as failing; only the payer's on-chain balance and the broadcast are
|
|
607
|
+
fixtures, and nothing is ever broadcast. The `*.int.test.ts` integration suites deploy the
|
|
525
608
|
hardened `StreamEscrow` on a throwaway `anvil` node and self-skip when `anvil` is not on
|
|
526
609
|
`PATH`, so default CI stays green. A full hire → stream → settle walkthrough lives in
|
|
527
610
|
[`examples/hire-stream-settle.ts`](examples/hire-stream-settle.ts).
|
|
@@ -532,3 +615,4 @@ hardened `StreamEscrow` on a throwaway `anvil` node and self-skip when `anvil` i
|
|
|
532
615
|
- Docs: [metrik.live](https://metrik.live) · App: [app.metrik.live](https://app.metrik.live)
|
|
533
616
|
- SDK: [`@absol-labs/sdk`](https://github.com/Absol-Labs/metrik-sdk)
|
|
534
617
|
- Quickstart: [`docs/quickstart.md`](./docs/quickstart.md) · Design + narrative: [`docs/agent-layer.md`](./docs/agent-layer.md) · Security review: [`docs/threat-model.md`](./docs/threat-model.md)
|
|
618
|
+
- Metrik and x402 — the facilitator, the delivery gate, and what is still unproven: [`docs/x402.md`](./docs/x402.md)
|
|
@@ -20,7 +20,7 @@ export declare const invocationCapabilitySchema: z.ZodObject<{
|
|
|
20
20
|
expiry: z.ZodNumber;
|
|
21
21
|
}, "strip", z.ZodTypeAny, {
|
|
22
22
|
streamId: string;
|
|
23
|
-
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "
|
|
23
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
24
24
|
serviceRef: string;
|
|
25
25
|
nonce: string;
|
|
26
26
|
buyer: `0x${string}`;
|
|
@@ -28,7 +28,7 @@ export declare const invocationCapabilitySchema: z.ZodObject<{
|
|
|
28
28
|
expiry: number;
|
|
29
29
|
}, {
|
|
30
30
|
streamId: string;
|
|
31
|
-
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "
|
|
31
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
32
32
|
serviceRef: string;
|
|
33
33
|
nonce: string;
|
|
34
34
|
buyer: string;
|
|
@@ -56,7 +56,7 @@ export declare const signedInvocationCapabilitySchema: z.ZodObject<{
|
|
|
56
56
|
}, "strip", z.ZodTypeAny, {
|
|
57
57
|
signature: string;
|
|
58
58
|
streamId: string;
|
|
59
|
-
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "
|
|
59
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
60
60
|
serviceRef: string;
|
|
61
61
|
nonce: string;
|
|
62
62
|
buyer: `0x${string}`;
|
|
@@ -65,7 +65,7 @@ export declare const signedInvocationCapabilitySchema: z.ZodObject<{
|
|
|
65
65
|
}, {
|
|
66
66
|
signature: string;
|
|
67
67
|
streamId: string;
|
|
68
|
-
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "
|
|
68
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
69
69
|
serviceRef: string;
|
|
70
70
|
nonce: string;
|
|
71
71
|
buyer: string;
|
|
@@ -160,14 +160,26 @@ export declare function buildInvocationCapabilityTypedData(capability: Invocatio
|
|
|
160
160
|
streamId: Hex;
|
|
161
161
|
buyer: `0x${string}`;
|
|
162
162
|
serviceRef: Hex;
|
|
163
|
-
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "
|
|
163
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS";
|
|
164
164
|
pathHash: Hex;
|
|
165
165
|
nonce: Hex;
|
|
166
166
|
expiry: bigint;
|
|
167
167
|
};
|
|
168
168
|
};
|
|
169
|
+
/**
|
|
170
|
+
* The minimum an account must expose to sign a capability: its address, and
|
|
171
|
+
* EIP-712 signing.
|
|
172
|
+
*
|
|
173
|
+
* Deliberately narrower than viem's `LocalAccount`. Every wallet this package
|
|
174
|
+
* resolves signs typed data — a raw key, a CDP server account via `toAccount()`,
|
|
175
|
+
* a Privy embedded EOA — but only the raw-key one is a `LocalAccount` by TYPE.
|
|
176
|
+
* Demanding the full interface would have meant the MCP server could only ever
|
|
177
|
+
* invoke with a raw key, which is the wallet an MCP host is least likely to be
|
|
178
|
+
* configured with. Widening a parameter type breaks no existing caller.
|
|
179
|
+
*/
|
|
180
|
+
export type InvocationCapabilitySigner = Pick<LocalAccount, "address" | "signTypedData">;
|
|
169
181
|
/** Signs an `InvocationCapability` with the buyer's own wallet. */
|
|
170
|
-
export declare function signInvocationCapability(capability: InvocationCapability, domain: InvocationCapabilityDomainInput, account:
|
|
182
|
+
export declare function signInvocationCapability(capability: InvocationCapability, domain: InvocationCapabilityDomainInput, account: InvocationCapabilitySigner): Promise<Hex>;
|
|
171
183
|
/** Recovers the EIP-712 signer of a capability. Throws on a malformed signature. */
|
|
172
184
|
export declare function recoverInvocationCapabilitySigner(capability: InvocationCapability, domain: InvocationCapabilityDomainInput, signature: Hex): Promise<Address>;
|
|
173
185
|
/** Cryptographically random 32-byte single-use nonce. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invocation-capability.d.ts","sourceRoot":"","sources":["../../src/capability/invocation-capability.ts"],"names":[],"mappings":"AAEA,OAAO,EAOL,KAAK,OAAO,EACZ,KAAK,GAAG,EACR,KAAK,YAAY,EAClB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmCxB,+CAA+C;AAC/C,eAAO,MAAM,gBAAgB,yEAQ3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,0BAA0B;IACrC,iFAAiF;;IAEjF,wDAAwD;;IAExD,uEAAuE;;IAEvE,yDAAyD;;IAEzD,wEAAwE;;IAExE,oCAAoC;;IAEpC,kEAAkE;;;;;;;;;;;;;;;;;;EAElE,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,eAAO,MAAM,gCAAgC;IAjB3C,iFAAiF;;IAEjF,wDAAwD;;IAExD,uEAAuE;;IAEvE,yDAAyD;;IAEzD,wEAAwE;;IAExE,oCAAoC;;IAEpC,kEAAkE;;;;;;;;;;;;;;;;;;;;;;EAQhE,CAAC;AACL,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,gCAAgC,CACxC,CAAC;AAEF,mGAAmG;AACnG,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,kDAAkD;IAClD,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;CACrC;AAED,eAAO,MAAM,8BAA8B,EACzC,8BAAuC,CAAC;AAC1C,eAAO,MAAM,iCAAiC,EAAG,GAAY,CAAC;AAE9D,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;CAUhC,CAAC;AAEX,uFAAuF;AACvF,eAAO,MAAM,8BAA8B,KAAK,CAAC;AAEjD,iEAAiE;AACjE,eAAO,MAAM,sBAAsB,wBAAwB,CAAC;AAE5D,wBAAgB,sCAAsC,CACpD,MAAM,EAAE,+BAA+B;;;;;EAQxC;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAEpD;AAED,kGAAkG;AAClG,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAU5D;AAeD,wBAAgB,kCAAkC,CAChD,UAAU,EAAE,oBAAoB,EAChC,MAAM,EAAE,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAZR,GAAG;;oBAEC,GAAG;;kBAEP,GAAG;eACT,GAAG;;;EAe7B;AAED,mEAAmE;AACnE,wBAAsB,wBAAwB,CAC5C,UAAU,EAAE,oBAAoB,EAChC,MAAM,EAAE,+BAA+B,EACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"invocation-capability.d.ts","sourceRoot":"","sources":["../../src/capability/invocation-capability.ts"],"names":[],"mappings":"AAEA,OAAO,EAOL,KAAK,OAAO,EACZ,KAAK,GAAG,EACR,KAAK,YAAY,EAClB,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmCxB,+CAA+C;AAC/C,eAAO,MAAM,gBAAgB,yEAQ3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,0BAA0B;IACrC,iFAAiF;;IAEjF,wDAAwD;;IAExD,uEAAuE;;IAEvE,yDAAyD;;IAEzD,wEAAwE;;IAExE,oCAAoC;;IAEpC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H,MAAM,MAAM,0BAA0B,GAAG,IAAI,CAC3C,YAAY,EACZ,SAAS,GAAG,eAAe,CAC5B,CAAC;AAEF,mEAAmE;AACnE,wBAAsB,wBAAwB,CAC5C,UAAU,EAAE,oBAAoB,EAChC,MAAM,EAAE,+BAA+B,EACvC,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,GAAG,CAAC,CAGd;AAED,oFAAoF;AACpF,wBAAsB,iCAAiC,CACrD,UAAU,EAAE,oBAAoB,EAChC,MAAM,EAAE,+BAA+B,EACvC,SAAS,EAAE,GAAG,GACb,OAAO,CAAC,OAAO,CAAC,CAGlB;AAED,yDAAyD;AACzD,wBAAgB,uBAAuB,IAAI,GAAG,CAE7C;AAED,qBAAa,4BAA6B,SAAQ,KAAK;gBACzC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAIpE;AAED,gFAAgF;AAChF,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,0BAA0B,GACjC,MAAM,CAaR;AAED,gGAAgG;AAChG,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,GAClB,0BAA0B,CA2B5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invocation-capability.js","sourceRoot":"","sources":["../../src/capability/invocation-capability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EACL,UAAU,EACV,SAAS,EACT,KAAK,EACL,SAAS,EACT,uBAAuB,EACvB,aAAa,GAId,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,aAAa,GAAG,CAAC;KACpB,MAAM,EAAE;KACR,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,wBAAwB,CAAC,C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AAC,CAAC,IAAI,EAAE,CAAC;IACzD,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,GAAG,CAAC;IACb,CAAC;IACD,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1D,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,2BAA2B,CAAC,UAAgC;IACnE,MAAM,MAAM,GAAG,0BAA0B,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC5D,OAAO;QACL,QAAQ,EAAE,MAAM,CAAC,QAAe;QAChC,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC;QAC/B,UAAU,EAAE,MAAM,CAAC,UAAiB;QACpC,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,QAAQ,EAAE,MAAM,CAAC,QAAe;QAChC,KAAK,EAAE,MAAM,CAAC,KAAY;QAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;KAC9B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kCAAkC,CAChD,UAAgC,EAChC,MAAuC;IAEvC,OAAO;QACL,MAAM,EAAE,sCAAsC,CAAC,MAAM,CAAC;QACtD,KAAK,EAAE,6BAA6B;QACpC,WAAW,EAAE,sBAA+B;QAC5C,OAAO,EAAE,2BAA2B,CAAC,UAAU,CAAC;KACjD,CAAC;AACJ,CAAC;
|
|
1
|
+
{"version":3,"file":"invocation-capability.js","sourceRoot":"","sources":["../../src/capability/invocation-capability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EACL,UAAU,EACV,SAAS,EACT,KAAK,EACL,SAAS,EACT,uBAAuB,EACvB,aAAa,GAId,MAAM,MAAM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AAE,MAAM,CAAC,SAAS;KAC5B,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AACzD,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,sBAAsB,CACpC,WAAmB;IAEnB,IAAI,IAAY,CAAC;IACjB,IAAI,CAAC;QACH,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAChE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,4BAA4B,CACpC,oCAAoC,EACpC,EAAE,KAAK,EAAE,CACV,CAAC;IACJ,CAAC;IAED,IAAI,GAAY,CAAC;IACjB,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,4BAA4B,CAAC,kCAAkC,EAAE;YACzE,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAED,MAAM,MAAM,GAAG,gCAAgC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC/D,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,4BAA4B,CACpC,6BAA6B,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CACpD,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claim.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/claim.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"claim.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/claim.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAkB,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjE;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,EAAE,WAsG1B,CAAC"}
|
|
@@ -3,7 +3,8 @@ import { assertTestnetRpc, parseBytes32 } from "../config.js";
|
|
|
3
3
|
import { CliError, describeError, usageError } from "../errors.js";
|
|
4
4
|
import { signClaimMandate } from "../mandate.js";
|
|
5
5
|
import { assertCanPayGas } from "../preflight.js";
|
|
6
|
-
import {
|
|
6
|
+
import { writeClientOptions } from "../deps.js";
|
|
7
|
+
import { isPolicyEnforced, PRIVATE_KEY_ENV, resolveCliWallet, } from "../wallet.js";
|
|
7
8
|
/**
|
|
8
9
|
* The seller's side of the loop.
|
|
9
10
|
*
|
|
@@ -27,7 +28,19 @@ export const claimCommand = {
|
|
|
27
28
|
throw usageError("metrik claim requires a <streamId>");
|
|
28
29
|
}
|
|
29
30
|
const streamId = parseBytes32(streamIdArg, "<streamId>");
|
|
30
|
-
const
|
|
31
|
+
const wallet = await resolveCliWallet(env, {
|
|
32
|
+
note: out.note,
|
|
33
|
+
rpcUrl: config.rpcUrl,
|
|
34
|
+
});
|
|
35
|
+
const { account } = wallet;
|
|
36
|
+
if (isPolicyEnforced(wallet)) {
|
|
37
|
+
// Said plainly rather than discovered mid-command. `claim` is the
|
|
38
|
+
// OPERATOR's side, and a Privy broker policy allowlists the BUYER
|
|
39
|
+
// actions only (openStream, close, reclaim, reclaimUnverified, and a
|
|
40
|
+
// bounded USDC approval). That is a property of an operator using a
|
|
41
|
+
// buyer-scoped wallet, not a defect in this command.
|
|
42
|
+
out.note("warning: this wallet's broker policy allowlists buyer actions only, so it will refuse to sign an operator claim. Claim with the operator's own key.");
|
|
43
|
+
}
|
|
31
44
|
const read = deps.createReadClient(config);
|
|
32
45
|
await assertTestnetRpc(config, () => read.getChainId());
|
|
33
46
|
await assertCanPayGas(read, account.address);
|
|
@@ -60,10 +73,13 @@ export const claimCommand = {
|
|
|
60
73
|
hint: `everything checkpointed so far has already been claimed. See where it stands: metrik status ${streamId}`,
|
|
61
74
|
});
|
|
62
75
|
}
|
|
63
|
-
const write = deps.createWriteClient(config, account);
|
|
76
|
+
const write = deps.createWriteClient(config, account, writeClientOptions(wallet));
|
|
64
77
|
const result = await write.claimStream({
|
|
65
78
|
streamId,
|
|
66
|
-
|
|
79
|
+
// `null` for a policy-enforced wallet — see `../spend-policy.ts`.
|
|
80
|
+
signedMandate: isPolicyEnforced(wallet)
|
|
81
|
+
? null
|
|
82
|
+
: await signClaimMandate(account, config.chainId),
|
|
67
83
|
spentSoFarUsdc: 0n,
|
|
68
84
|
nowSeconds: deps.nowSeconds(),
|
|
69
85
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claim.js","sourceRoot":"","sources":["../../../src/cli/commands/claim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"claim.js","sourceRoot":"","sources":["../../../src/cli/commands/claim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EACL,gBAAgB,EAChB,eAAe,E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CAAC,MAAM,CAAC;gBACrC,CAAC,CAAC,IAAI;gBACN,CAAC,CAAC,MAAM,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC;YACnD,cAAc,EAAE,EAAE;YAClB,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE;SAC9B,CAAC,CAAC;QAEH,GAAG,CAAC,MAAM,CAAC;YACT,QAAQ;YACR,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,OAAO,EAAE,SAAS;YAClB,kBAAkB,EAAE,gBAAgB;SACrC,CAAC,CAAC;QACH,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACtB,GAAG,CAAC,KAAK,CAAC;YACR,CAAC,UAAU,EAAE,QAAQ,CAAC;YACtB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC;YACrB,CAAC,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC;YAC7B,CAAC,SAAS,EAAE,GAAG,UAAU,CAAC,SAAS,CAAC,wBAAwB,CAAC;SAC9D,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"close.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/close.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"close.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/close.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAkB,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjE,eAAO,MAAM,YAAY,EAAE,WA4D1B,CAAC"}
|
|
@@ -2,7 +2,8 @@ import { assertTestnetRpc, parseBytes32 } from "../config.js";
|
|
|
2
2
|
import { usageError } from "../errors.js";
|
|
3
3
|
import { signRecoveryMandate } from "../mandate.js";
|
|
4
4
|
import { assertCanPayGas } from "../preflight.js";
|
|
5
|
-
import {
|
|
5
|
+
import { writeClientOptions } from "../deps.js";
|
|
6
|
+
import { isPolicyEnforced, resolveCliWallet } from "../wallet.js";
|
|
6
7
|
export const closeCommand = {
|
|
7
8
|
name: "close",
|
|
8
9
|
summary: "Stop the clock on a stream so the unspent budget can be reclaimed",
|
|
@@ -16,12 +17,23 @@ export const closeCommand = {
|
|
|
16
17
|
throw usageError("metrik close requires a <streamId>");
|
|
17
18
|
}
|
|
18
19
|
const streamId = parseBytes32(streamIdArg, "<streamId>");
|
|
19
|
-
const
|
|
20
|
+
const wallet = await resolveCliWallet(env, {
|
|
21
|
+
note: out.note,
|
|
22
|
+
rpcUrl: config.rpcUrl,
|
|
23
|
+
});
|
|
24
|
+
const { account } = wallet;
|
|
20
25
|
const read = deps.createReadClient(config);
|
|
21
26
|
await assertTestnetRpc(config, () => read.getChainId());
|
|
22
27
|
await assertCanPayGas(read, account.address);
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
// A policy-enforced wallet signs no mandate of its own: this is a
|
|
29
|
+
// buyer-recovery action, the escrow gates it on the buyer address and the
|
|
30
|
+
// broker gates it again on `stream.buyer == wallet`. A locally self-signed
|
|
31
|
+
// placeholder would add nothing and the broker would refuse to sign it.
|
|
32
|
+
// See `../spend-policy.ts`.
|
|
33
|
+
const signedMandate = isPolicyEnforced(wallet)
|
|
34
|
+
? null
|
|
35
|
+
: await signRecoveryMandate(account, config.chainId);
|
|
36
|
+
const write = deps.createWriteClient(config, account, writeClientOptions(wallet));
|
|
25
37
|
const result = await write.closeStream({
|
|
26
38
|
streamId,
|
|
27
39
|
signedMandate,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"close.js","sourceRoot":"","sources":["../../../src/cli/commands/close.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,M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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/invoke.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAkB,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjE,eAAO,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"invoke.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/invoke.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAkB,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjE,eAAO,MAAM,aAAa,EAAE,WAkH3B,CAAC"}
|
|
@@ -42,6 +42,7 @@ export const invokeCommand = {
|
|
|
42
42
|
const { account } = await resolveCliWallet(env, {
|
|
43
43
|
purpose: "capability",
|
|
44
44
|
note: out.note,
|
|
45
|
+
rpcUrl: config.rpcUrl,
|
|
45
46
|
});
|
|
46
47
|
const read = deps.createReadClient(config);
|
|
47
48
|
// No transaction is signed here — but the capability is bound to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoke.js","sourceRoot":"","sources":["../../../src/cli/commands/invoke.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,GAEjB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,CAAC,MAAM,aAAa,GAAgB;IACxC,IAAI,EAAE,QAAQ;IACd,OAAO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AAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;YACnB,MAAM,UAAU,CAAC,wCAAwC,KAAK,IAAI,CAAC,CAAC;QACtE,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK;aAC5D,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;aACpB,IAAI,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,SAAS,CAAC,OAA+B,EAAE,IAAY;IAC9D,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAC9B,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,WAAW,EAAE,CAClD,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/open.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/open.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAkB,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjE,eAAO,MAAM,WAAW,EAAE,WAgUzB,CAAC"}
|
|
@@ -2,10 +2,12 @@ import { MandateDeniedError } from "../../sdk/client.js";
|
|
|
2
2
|
import { booleanFlag, requiredStringFlag, stringFlag } from "../args.js";
|
|
3
3
|
import { formatDuration, formatUsdc, parseAmountUnits, parseDurationSeconds, parseUsdcAmount, } from "../amounts.js";
|
|
4
4
|
import { assertTestnetRpc, parseBytes32 } from "../config.js";
|
|
5
|
+
import { writeClientOptions } from "../deps.js";
|
|
5
6
|
import { CliError, configError } from "../errors.js";
|
|
7
|
+
import { assertWithinOperatorCaps, assertWithinSpendPolicy, } from "../spend-policy.js";
|
|
6
8
|
import { cliMandateCaps, signCliMandate } from "../mandate.js";
|
|
7
9
|
import { assertCanFundStream, assertCanPayGas } from "../preflight.js";
|
|
8
|
-
import { optionalCliWallet, resolveCliWallet, PRIVATE_KEY_ENV, } from "../wallet.js";
|
|
10
|
+
import { isPolicyEnforced, optionalCliWallet, resolveCliWallet, PRIVATE_KEY_ENV, } from "../wallet.js";
|
|
9
11
|
import { resolveListing } from "../listings.js";
|
|
10
12
|
export const openCommand = {
|
|
11
13
|
name: "open",
|
|
@@ -44,8 +46,8 @@ export const openCommand = {
|
|
|
44
46
|
// the intended call and says which parts (allowance, simulation, mandate
|
|
45
47
|
// signature) could not be produced, rather than inventing them.
|
|
46
48
|
const wallet = dryRun
|
|
47
|
-
? await optionalCliWallet(env, { note: out.note })
|
|
48
|
-
: await resolveCliWallet(env, { note: out.note });
|
|
49
|
+
? await optionalCliWallet(env, { note: out.note, rpcUrl: config.rpcUrl })
|
|
50
|
+
: await resolveCliWallet(env, { note: out.note, rpcUrl: config.rpcUrl });
|
|
49
51
|
const account = wallet?.account ?? null;
|
|
50
52
|
const read = deps.createReadClient(config);
|
|
51
53
|
await assertTestnetRpc(config, () => read.getChainId());
|
|
@@ -64,14 +66,32 @@ export const openCommand = {
|
|
|
64
66
|
throw configError(`serviceRef ${serviceRef} is not in the registry and no --operator was given`, "run `metrik discover` to find a listed service, or pass --operator explicitly.");
|
|
65
67
|
}
|
|
66
68
|
const spend = { operator, budgetUsdc, ratePerSecondUsdc, durationSeconds };
|
|
67
|
-
const
|
|
69
|
+
const mandateCaps = cliMandateCaps(spend, env);
|
|
70
|
+
// A policy-enforced wallet (Privy) is capped by its broker, not by a
|
|
71
|
+
// mandate this process signs for itself. Read the REAL ceiling and hold it
|
|
72
|
+
// to that instead — see `../spend-policy.ts` for why that substitution is
|
|
73
|
+
// the stronger of the two, and why re-adding the self-signed mandate here
|
|
74
|
+
// would both weaken it and break the wallet outright.
|
|
75
|
+
const policy = wallet !== null && isPolicyEnforced(wallet)
|
|
76
|
+
? await wallet.readSpendPolicy()
|
|
77
|
+
: null;
|
|
78
|
+
if (policy !== null && !dryRun) {
|
|
79
|
+
assertWithinSpendPolicy(policy, spend);
|
|
80
|
+
// The operator's own standing ceiling still applies, and may be TIGHTER
|
|
81
|
+
// than the broker's. Enforced here because no mandate is signed to carry
|
|
82
|
+
// it — "policy-enforced" retires the self-signed mandate, not the caps
|
|
83
|
+
// the operator deliberately configured.
|
|
84
|
+
if (mandateCaps.source === "env") {
|
|
85
|
+
assertWithinOperatorCaps(mandateCaps.caps, spend);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const mandate = account === null || policy !== null
|
|
68
89
|
? null
|
|
69
90
|
: await signCliMandate(account, spend, {
|
|
70
91
|
chainId: config.chainId,
|
|
71
92
|
env,
|
|
72
93
|
});
|
|
73
|
-
const
|
|
74
|
-
const write = deps.createWriteClient(config, account);
|
|
94
|
+
const write = deps.createWriteClient(config, account, writeClientOptions(wallet));
|
|
75
95
|
const hire = {
|
|
76
96
|
operator,
|
|
77
97
|
serviceRef,
|
|
@@ -104,6 +124,17 @@ export const openCommand = {
|
|
|
104
124
|
durationSeconds,
|
|
105
125
|
mandateSource: mandateCaps.source,
|
|
106
126
|
mandateSigned: mandate !== null,
|
|
127
|
+
spendPolicy: policy === null
|
|
128
|
+
? null
|
|
129
|
+
: {
|
|
130
|
+
brokerUrl: policy.brokerUrl,
|
|
131
|
+
maxTotalUsdc: policy.maxTotalUsdc,
|
|
132
|
+
maxRatePerSecondUsdc: policy.maxRatePerSecondUsdc,
|
|
133
|
+
maxDurationSeconds: policy.maxDurationSeconds,
|
|
134
|
+
fits: budgetUsdc <= policy.maxTotalUsdc &&
|
|
135
|
+
ratePerSecondUsdc <= policy.maxRatePerSecondUsdc &&
|
|
136
|
+
durationSeconds <= policy.maxDurationSeconds,
|
|
137
|
+
},
|
|
107
138
|
to: preview.to,
|
|
108
139
|
data: preview.data,
|
|
109
140
|
chainId: preview.chainId,
|
|
@@ -139,10 +170,28 @@ export const openCommand = {
|
|
|
139
170
|
["duration", formatDuration(durationSeconds)],
|
|
140
171
|
[
|
|
141
172
|
"mandate",
|
|
142
|
-
mandate
|
|
143
|
-
? `
|
|
144
|
-
:
|
|
173
|
+
mandate !== null
|
|
174
|
+
? `self-signed, caps from ${mandateCaps.source}`
|
|
175
|
+
: policy !== null
|
|
176
|
+
? "not signed — this wallet's ceiling is enforced by its broker, which is stronger"
|
|
177
|
+
: `not signed (no wallet); caps would come from ${mandateCaps.source}`,
|
|
145
178
|
],
|
|
179
|
+
...(policy === null
|
|
180
|
+
? []
|
|
181
|
+
: [
|
|
182
|
+
[
|
|
183
|
+
"spend policy",
|
|
184
|
+
`${formatUsdc(policy.maxTotalUsdc)} total, ${policy.maxRatePerSecondUsdc} atomic/second, ${formatDuration(policy.maxDurationSeconds)} max — enforced by ${policy.brokerUrl}`,
|
|
185
|
+
],
|
|
186
|
+
[
|
|
187
|
+
"fits policy",
|
|
188
|
+
budgetUsdc <= policy.maxTotalUsdc &&
|
|
189
|
+
ratePerSecondUsdc <= policy.maxRatePerSecondUsdc &&
|
|
190
|
+
durationSeconds <= policy.maxDurationSeconds
|
|
191
|
+
? "yes"
|
|
192
|
+
: "NO — a real open would be refused before broadcasting",
|
|
193
|
+
],
|
|
194
|
+
]),
|
|
146
195
|
["escrow", preview.to],
|
|
147
196
|
[
|
|
148
197
|
"usdc balance",
|
|
@@ -175,7 +224,7 @@ export const openCommand = {
|
|
|
175
224
|
out.note(`opening a stream on chain ${config.chainId} for ${formatUsdc(budgetUsdc)} …`);
|
|
176
225
|
// Unreachable without a wallet: `resolveCliWallet` above throws when the
|
|
177
226
|
// command is not a dry run. The narrowing keeps that a type-level fact.
|
|
178
|
-
if (account === null
|
|
227
|
+
if (account === null) {
|
|
179
228
|
throw configError("this command signs a transaction and needs a wallet, and none was resolved");
|
|
180
229
|
}
|
|
181
230
|
let result;
|
|
@@ -186,7 +235,10 @@ export const openCommand = {
|
|
|
186
235
|
budgetUsdc,
|
|
187
236
|
ratePerSecondUsdc,
|
|
188
237
|
maxDurationSeconds: durationSeconds,
|
|
189
|
-
|
|
238
|
+
// `null` for a policy-enforced wallet: the ceiling was checked against
|
|
239
|
+
// the broker's own policy above, and the broker checks it again on the
|
|
240
|
+
// transaction it signs.
|
|
241
|
+
signedMandate: mandate === null ? null : mandate.signed,
|
|
190
242
|
spentSoFarUsdc: 0n,
|
|
191
243
|
nowSeconds: deps.nowSeconds(),
|
|
192
244
|
});
|