@metalntwx/metal-agent 0.2.0 → 0.3.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 CHANGED
@@ -25,7 +25,8 @@ endpoints) and the `*USDZ` address come from `@metalntwx/metal-pay`, and
25
25
  `networks.json` holds its demo payee URL and, on testnet, its faucet and
26
26
  explorer URLs.
27
27
  `METAL_RPC_URL` and `METAL_FAUCET_URL` override those defaults, and
28
- `--rpc-url` and `--faucet-url` override both.
28
+ `--rpc-url` and `--faucet-url` override both; `METAL_FACILITATOR_URL` and
29
+ `--facilitator-url` do the same for `mandate pull`.
29
30
 
30
31
  On testnet, `pay` and `fund` need no RPC. `status`, `account create` and
31
32
  every `mandate` command but `credential create` need an endpoint of your
@@ -93,34 +94,34 @@ metal-agent mandate revoke --credential ./wider.json --key <owner key file> --ne
93
94
  ```
94
95
 
95
96
  `credential create` writes the limits into a credential file, a Verifiable
96
- Intent mandate, and the agent's keys beside it: its mandate key in
97
- `mandate.agent-key.json`, and in `mandate.gas-key.json` the key that pays
98
- for its pulls. `--agent-key <file>` names a mandate key the agent already
99
- has instead, with its gas key beside that. The keys that sign the
100
- credential are the owner's: they live beside the owner's key file, created
97
+ Intent mandate, and beside it the mandate key the agent signs with:
98
+ `mandate.key.json` for `mandate.json`. `--mandate-key-file <file>` names a
99
+ mandate key that exists instead, as a replacement does. The keys
100
+ that sign the credential are the owner's: they live beside the owner's key file, created
101
101
  on first use (`owner-key.issuer.json`, with its public half in
102
102
  `owner-key.issuer.public.json`), unless `--issuer-key` names their file.
103
103
  `--description` says what the mandate is for, and `--payee` takes a name
104
104
  and a website after the address. Every other command takes
105
- that credential file: the owner's account, the mandate's reference, its
106
- terms and the agent's key files derive from it. Amounts are in `*USDZ`, to the cent; a
105
+ that credential file: the owner's account, the mandate's id and its
106
+ terms derive from it. Amounts are in `*USDZ`, to the cent; a
107
107
  mandate lasts 30 days unless `--expires-in` says otherwise, and its budget
108
108
  never resets.
109
109
 
110
- `account create --out <owner key file>` writes the owner's key and names the
111
- owner's Metal account, a smart account that key controls with threshold one,
112
- which the owner's first `bind` creates on chain; `--key <file>` uses a key
113
- that exists. Fund the account and name it as the credential's `--principal`.
110
+ `account create --out <owner key file>` writes the owner's key and creates the
111
+ owner's Metal account on chain, a smart account that key controls with
112
+ threshold one; `--key <file>` uses a key that exists. The owner's key pays the
113
+ gas, and one that holds none is funded first. Fund the account and name it as
114
+ the credential's `--principal`; `bind` refuses an address with no account.
114
115
  The account factory is the one `@metalntwx/metal-pay` names for the network;
115
116
  on a devnet `just deploy` deploys it there, and `--factory <address>` names
116
117
  another. `@metalntwx/metal-pay` names the testnet's.
117
118
 
118
- `bind`, `replace` and `revoke` execute self-calls through the account's weighted
119
- quorum. `--key` names the gas sponsor and defaults as the sole signer; repeat
120
- `--signer-key <file>` to supply the EOA signers of an existing multisig instead.
121
- The SDK's `authorizeMandateCall` accepts a quorum-signing callback for mixed
122
- keys and passkeys. Keep owner keys outside the agent's reach: quorum-approved
123
- transfers remain independent of mandates. `replace` revokes the mandate
119
+ `bind`, `replace` and `revoke` are signed by the account's owners, as many as
120
+ its threshold needs. `--key` names the gas sponsor and defaults as the sole
121
+ signer; repeat `--signer-key <file>` to supply the owners' keys of an account
122
+ with several instead. The SDK's `authorizeMandateCall` accepts a signing
123
+ callback for mixed keys and passkeys. Keep owner keys outside the agent's
124
+ reach: an owner key moves the account's funds outside any mandate's limits. `replace` revokes the mandate
124
125
  `--replaces` names and carries its spend into the new one; `renew` binds the
125
126
  new one and revokes the old in one batch, starting its spend at nothing, which
126
127
  is how a budget starts over.
@@ -132,25 +133,28 @@ account's immutable clone code against the factory's current
132
133
  implementation, and checks successful token-transfer receipts.
133
134
 
134
135
  `pay --mandate <credential>` pays from the owner's account, signed by the
135
- agent's mandate key, and takes neither `--key` nor `--max`. A payment
136
+ mandate key beside the credential, or the one `--mandate-key-file` names.
137
+ It takes neither `--key` nor `--max`. A payment
136
138
  outside the mandate is refused and moves nothing, usually with a
137
139
  `mandate_*` reason: `payment refused: mandate_cap_exceeded (…)`. `pay` prints the
138
140
  payment's `nonce` as soon as it signs; the facilitator's
139
141
  `/settlements?payTo=<payee>` lists a settled payment by an id ending in it.
140
142
 
141
143
  `mandate pull` pays an address the mandate allows directly, with no seller:
142
- the agent's mandate key signs, and the `--key` account, the agent's gas key
143
- by default, submits the transaction and pays its gas, so fund it with a
144
- little `*USDZ`. A pull the mandate refuses when checked is not sent: it reports the
145
- reason and exits 1. `--record-refusal` sends it, so the refusal is recorded
146
- on chain in a transaction that succeeds and moves nothing. A pull prints
147
- `transaction <hash>` as soon as it is sent; if its receipt never arrives,
148
- check that transaction with `metal-agent status <hash>` before pulling again.
144
+ the agent's mandate key signs, and the facilitator submits the transaction
145
+ and pays its gas; `--key` names a funded key to submit it instead. A pull
146
+ the mandate refuses when checked is not sent: it reports the reason and
147
+ exits 1. With `--key`, `--record-refusal` sends it, so the refusal is
148
+ recorded on chain in a transaction that succeeds and moves nothing. The
149
+ outcome is read from the chain: `paid`, `refused`, `held` when the payee's
150
+ receive policy sends it to escrow, or `pending`. A pending pull is kept in
151
+ the directory beside the credential, `mandate.pulls` for `mandate.json`, and
152
+ running the same command again sends that same pull, which pays at most once.
149
153
 
150
154
  `mandate verify` checks the mandate and every payment under it from the
151
155
  chain alone, through any RPC endpoint: the binding on the owner's account,
152
156
  the credential against it and under its issuer, and each payment and
153
- refusal as the agent key's own signed per-payment mandate, rebuilt from its
157
+ refusal as the mandate key's own signed per-payment mandate, rebuilt from its
154
158
  transaction. Anyone holding the credential and the issuer's public file,
155
159
  passed as `--issuer`, can run it; `--tx <hash>`
156
160
  verifies one transaction, with `--signed-offer <text>` the offer the agent
package/dist/chain.js CHANGED
@@ -22,7 +22,7 @@ export function resolveSettings(network, file, flags, env) {
22
22
  const faucetUrl = flags.faucetUrl ?? env["METAL_FAUCET_URL"] ?? file.faucetUrl;
23
23
  return {
24
24
  ...(rpcUrl !== undefined && { rpcUrl }),
25
- facilitatorUrl: env["METAL_FACILITATOR_URL"] ?? network.facilitatorUrl,
25
+ facilitatorUrl: flags.facilitatorUrl ?? env["METAL_FACILITATOR_URL"] ?? network.facilitatorUrl,
26
26
  demoPayeeUrl: env["METAL_DEMO_PAYEE_URL"] ?? file.demoPayeeUrl,
27
27
  ...(faucetUrl !== undefined && { faucetUrl }),
28
28
  ...(file.explorerUrl !== undefined && { explorerUrl: file.explorerUrl }),