zk-agent-cli 0.1.0-beta.1 → 0.1.0-beta.11

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 (31) hide show
  1. package/README.md +169 -14
  2. package/dist/builtin-account-profiles/artifacts/daily-spend-limit/Account.json +693 -0
  3. package/dist/builtin-account-profiles/artifacts/sed-lite/Account.json +970 -0
  4. package/dist/builtin-account-profiles/artifacts/sed-lite/EOAValidator.json +50 -0
  5. package/dist/builtin-account-profiles/artifacts/sed-lite/NativePerTxLimitHook.json +267 -0
  6. package/dist/builtin-account-profiles/artifacts/sed-lite/TargetAllowlistHook.json +346 -0
  7. package/dist/builtin-account-profiles/artifacts/sed-lite/TargetSelectorAllowlistHook.json +643 -0
  8. package/dist/builtin-account-profiles/contracts/daily-spend-limit/AAFactory.sol +28 -0
  9. package/dist/builtin-account-profiles/contracts/daily-spend-limit/Account.sol +179 -0
  10. package/dist/builtin-account-profiles/contracts/daily-spend-limit/SpendLimit.sol +85 -0
  11. package/dist/builtin-account-profiles/contracts/sed-lite/Account.sol +230 -0
  12. package/dist/builtin-account-profiles/contracts/sed-lite/Auth.sol +16 -0
  13. package/dist/builtin-account-profiles/contracts/sed-lite/BootloaderAuth.sol +11 -0
  14. package/dist/builtin-account-profiles/contracts/sed-lite/EOAValidator.sol +23 -0
  15. package/dist/builtin-account-profiles/contracts/sed-lite/IValidationHook.sol +20 -0
  16. package/dist/builtin-account-profiles/contracts/sed-lite/IValidator.sol +11 -0
  17. package/dist/builtin-account-profiles/contracts/sed-lite/ModuleAuth.sol +11 -0
  18. package/dist/builtin-account-profiles/contracts/sed-lite/ModuleManager.sol +46 -0
  19. package/dist/builtin-account-profiles/contracts/sed-lite/NativePerTxLimitHook.sol +67 -0
  20. package/dist/builtin-account-profiles/contracts/sed-lite/OwnerManager.sol +25 -0
  21. package/dist/builtin-account-profiles/contracts/sed-lite/SelfAuth.sol +9 -0
  22. package/dist/builtin-account-profiles/contracts/sed-lite/TargetAllowlistHook.sol +110 -0
  23. package/dist/builtin-account-profiles/contracts/sed-lite/TargetSelectorAllowlistHook.sol +263 -0
  24. package/dist/builtin-account-profiles/contracts/sed-lite/ValidationHookManager.sol +76 -0
  25. package/dist/builtin-account-profiles/contracts/sed-lite/ValidatorManager.sol +31 -0
  26. package/dist/builtin-account-profiles/package.json +5 -0
  27. package/dist/connector-ui/assets/index-B7BdrG9K.js +40 -0
  28. package/dist/connector-ui/assets/index-BnFLonFL.css +1 -0
  29. package/dist/connector-ui/index.html +13 -0
  30. package/dist/index.js +3444 -501
  31. package/package.json +5 -2
package/README.md CHANGED
@@ -3,6 +3,10 @@
3
3
  `zk-agent-cli` is the packaged `zk-agent-cli` command surface for zkSync Era
4
4
  and zkSync Sepolia.
5
5
 
6
+ This README is the canonical operator manual for the packaged CLI. If you want
7
+ repo architecture, contributor state, or project planning context, use the root
8
+ repository docs instead of this package manual.
9
+
6
10
  Current strengths:
7
11
 
8
12
  - local-first wallet/session storage
@@ -11,7 +15,23 @@ Current strengths:
11
15
  - workflow orchestration for send, swap, bridge, deposit, and withdraw
12
16
  - machine-readable JSON output for agent callers
13
17
 
14
- ## Install
18
+ ## Public Entry Points
19
+
20
+ Choose the entrypoint that matches the environment.
21
+
22
+ If you are installing this repository into a compatible agent harness instead
23
+ of using the CLI directly, prefer the repo skill surface:
24
+
25
+ ```bash
26
+ npx skills add https://github.com/AgiWeb3/zk-agent-cli
27
+ ```
28
+
29
+ This repo currently ships a repository skill bundle for compatible harnesses.
30
+ The repository root now also ships a native ChatGPT/Codex plugin manifest at
31
+ `.codex-plugin/plugin.json`, but that plugin source belongs to the repository
32
+ surface rather than this published npm tarball.
33
+
34
+ For direct terminal use, install the packaged CLI:
15
35
 
16
36
  One-shot execution:
17
37
 
@@ -34,7 +54,9 @@ zksync-agent --help
34
54
 
35
55
  ## Prerequisites
36
56
 
37
- - Node.js `>=24` if you install globally.
57
+ - Node.js `>=24` for either `npx zk-agent-cli ...` or global install.
58
+ Older Node versions may still start the CLI, but the current package is not
59
+ supported there and npm will emit `EBADENGINE` warnings.
38
60
  - The default local approval path expects the connector UI to be reachable at
39
61
  `http://localhost:4444`. Override it with
40
62
  `zk-agent setup --connector-url <url>` when needed.
@@ -63,6 +85,13 @@ Use:
63
85
 
64
86
  ## Shortest Path
65
87
 
88
+ Current validated first-run baseline:
89
+
90
+ - `setup` defaults to `zksync-sepolia`
91
+ - the local approval path expects the connector UI at `http://localhost:4444`
92
+ - override `--default-chain` or `--connector-url` only when you intentionally
93
+ target another chain or connector deployment
94
+
66
95
  Fresh setup:
67
96
 
68
97
  ```bash
@@ -70,14 +99,33 @@ zk-agent setup
70
99
  zk-agent next
71
100
  zk-agent wallet create --await-local
72
101
  zk-agent next
73
- zk-agent workflow auto --wallet main --intent <intent> [goal flags] --create-checkpoint --execute-when-ready
102
+ zk-agent workflow pay --wallet main --to <address> --amount <amount>
74
103
  ```
75
104
 
76
- If a wallet already exists and only the writable session is stale, use:
105
+ If the browser is not colocated with the terminal, keep the same flow but
106
+ replace the wallet-creation step with:
107
+
108
+ ```bash
109
+ zk-agent relay inspect --relay-url <relay-url>
110
+ zk-agent wallet create --relay-url <relay-url> --wait-relay --prompt-code
111
+ zk-agent next
112
+ ```
113
+
114
+ If local setup or wallet readiness is unclear, start with `zk-agent doctor`.
115
+ It inspects saved config, wallet approval metadata, and local signer state
116
+ without live RPC reads, and `--relay-url` only makes the remote fallback
117
+ commands concrete.
118
+
119
+ If a wallet already exists, inspect the blocker first. Use `wallet reapprove`
120
+ when approval is missing or expired, then return to `zk-agent next`. Use
121
+ `wallet signer attach` when approval is still present but the local execution
122
+ signer is missing:
77
123
 
78
124
  ```bash
79
125
  zk-agent wallet reapprove --name main --await-local
80
126
  zk-agent next
127
+ zk-agent wallet signer attach --name main --private-key <hex>
128
+ zk-agent next
81
129
  ```
82
130
 
83
131
  Only fund when the CLI says funding is actually required:
@@ -86,25 +134,120 @@ Only fund when the CLI says funding is actually required:
86
134
  zk-agent workflow fund --wallet main --amount <amount> --execute
87
135
  ```
88
136
 
137
+ Current flagship AA native-pay path:
138
+
139
+ ```bash
140
+ zk-agent workflow pay --wallet main --to <address> --amount <amount>
141
+ zk-agent workflow pay --wallet main --to <address> --amount <amount> --paymaster-mode sponsored
142
+ ```
143
+
144
+ Use a `sed-lite` wallet for the default AA acceptance path. Keep
145
+ `daily-spend-limit` for profile-specific policy experiments, not as the main
146
+ operator baseline.
147
+
148
+ `workflow pay` fixes the workflow intent to `send-native`, persists a
149
+ checkpoint, executes immediately when ready, reopens a missing writable session
150
+ through the intent-scoped approval path, and defaults to the validated
151
+ approval-based paymaster mode unless you override it.
152
+ When that approval-based path still needs a fee-token candidate, recover with
153
+ `zk-agent tokens --chain zksync-sepolia --role paymaster-fee-token` and
154
+ `zk-agent resolve-token --chain zksync-sepolia --symbol <symbol> --role paymaster-fee-token`.
155
+
156
+ ## Discovery Path
157
+
158
+ Use the discovery surfaces in this order when a workflow or direct command
159
+ needs token context:
160
+
161
+ - `zk-agent assets --wallet main` for the preferred single-chain asset view
162
+ - `zk-agent tokens --wallet main --owned` for the narrower owned ERC-20 subset
163
+ - `zk-agent tokens --chain zksync-sepolia` and
164
+ `zk-agent resolve-token --chain zksync-sepolia --symbol USDC` for
165
+ symbol-first discovery before choosing an explicit token address
166
+ - `zk-agent tokens --chain zksync-sepolia --role paymaster-fee-token` and
167
+ `zk-agent resolve-token --chain zksync-sepolia --symbol <symbol> --role paymaster-fee-token`
168
+ for approval-based paymaster fee-token discovery on the flagship pay path
169
+ - `zk-agent defaults` for the machine-readable registry/defaults catalog:
170
+ tracked token roles, paymaster metadata, source order, and validated/fallback
171
+ route metadata
172
+
173
+ ## Direct Command Escape Hatches
174
+
175
+ Use the guided workflow layer first, but the lower-level direct commands now
176
+ keep the same symbol/discovery contract:
177
+
178
+ - `zk-agent send-token --wallet main --symbol USDC --to <address> --amount <amount>`
179
+ - `zk-agent swap --wallet main --token-in-symbol USDC --token-out-symbol ETH --amount-in <amount>`
180
+ - `zk-agent fund --wallet main --symbol USDC --amount <amount>`
181
+ - `zk-agent deposit --wallet main --symbol USDC --amount <amount>`
182
+ - `zk-agent withdraw --wallet main --symbol USDC --amount <amount>`
183
+
184
+ Current direct-command behavior:
185
+
186
+ - `send-token`, `fund`, `deposit`, and `withdraw` accept symbol-first token
187
+ resolution when the local registry can resolve the active chain token
188
+ - `swap` follows the current registry-backed validated route by default when
189
+ `--protocol` is omitted
190
+ - `bridge` can reuse the tracked default destination route when one is already
191
+ known for the current wallet chain
192
+
193
+ ## Local Agent Identity
194
+
195
+ The local operator profile is optional. It helps agent harnesses and operators
196
+ persist stable metadata, but wallet approval and workflow execution do not
197
+ depend on it.
198
+
199
+ Use:
200
+
201
+ - `zk-agent agent status`
202
+ - `zk-agent agent set --name "<operator-name>" --wallet main`
203
+ - `zk-agent agent show`
204
+
89
205
  ## Remote Approval
90
206
 
91
- Shortest relay-backed path in one command:
207
+ Shortest relay-backed path in one terminal process:
92
208
 
93
209
  ```bash
210
+ zk-agent relay inspect --relay-url <relay-url>
94
211
  zk-agent wallet create --relay-url <relay-url> --wait-relay --prompt-code
212
+ ```
213
+
214
+ If the wallet already exists and approval metadata needs to be refreshed, use:
215
+
216
+ ```bash
95
217
  zk-agent wallet reapprove --name main --relay-url <relay-url> --wait-relay --prompt-code
96
218
  ```
97
219
 
220
+ Treat that hosted path as the fallback when the browser is not colocated with
221
+ the terminal; keep the local `--await-local` path as the default baseline.
222
+
223
+ If approval is still present and only the local execution signer is missing,
224
+ repair that locally instead of forcing a new approval round-trip:
225
+
226
+ ```bash
227
+ zk-agent wallet signer attach --name main --private-key <hex>
228
+ zk-agent next
229
+ ```
230
+
98
231
  Local relay prototype path:
99
232
 
100
233
  ```bash
101
- zk-agent relay serve
234
+ zk-agent relay serve --public-origin https://relay.example.com
102
235
  zk-agent wallet create --relay-url <relay-url>
103
236
  zk-agent wallet request approve --request-id <id> --relay-url <relay-url> --code <code> --wait
104
237
  ```
105
238
 
106
239
  The built-in relay is a local file-backed prototype. It is useful for operator
107
- testing, not a production hosted relay service.
240
+ testing, not a production hosted relay service. When it sits behind a tunnel or
241
+ reverse proxy, pass `--public-origin` so the emitted share/status URLs point at
242
+ the externally reachable hosted URL instead of the local bind address. The
243
+ published package now also ships the bundled connector UI build used by
244
+ `relay serve`, so hosted share-link approval no longer depends on a separate
245
+ source checkout just to serve the UI. `relay inspect` now also reports
246
+ `stateBackend`, `deploymentScope`, and `sameHostRestartPersists` so the
247
+ single-host local-filesystem constraint is explicit before you rely on a hosted
248
+ URL. For the current supported hosted operating contract and the remaining
249
+ `beta -> rc` blocker on this path, see
250
+ [`docs/16-hosted-approval-operated-baseline.md`](../../docs/16-hosted-approval-operated-baseline.md).
108
251
 
109
252
  ## Local Storage
110
253
 
@@ -120,22 +263,29 @@ Common files created by the default path:
120
263
  - `config.json`
121
264
  - `wallets/*.json`
122
265
  - `requests/*.json`
123
- - `workflow-checkpoints/*.json`
266
+ - `workflows/*.json`
124
267
 
125
268
  ## Smart-Account Profiles
126
269
 
127
- The published package can inspect built-in profiles:
270
+ The published package ships built-in profile artifacts for the first-party
271
+ smart-account presets:
128
272
 
129
273
  ```bash
130
274
  zk-agent wallet smart-account profiles --json
131
275
  ```
132
276
 
277
+ That means the packaged CLI can use:
278
+
279
+ - `zk-agent wallet smart-account predict --profile sed-lite`
280
+ - `zk-agent wallet smart-account deploy --profile sed-lite`
281
+ - the same built-in path for `daily-spend-limit`
282
+
133
283
  Current boundary:
134
284
 
135
- - profile inspection works from the packaged CLI
136
- - built-in profile deploys still require
137
- `ZK_AGENT_ACCOUNT_PROFILES_ROOT=<checked-out account-profiles package dir>`
138
- because the npm tarball does not ship the EraVM profile artifacts
285
+ - built-in profiles work from the packaged CLI
286
+ - custom profile artifacts still use `--artifact <json|@file>`
287
+ - `ZK_AGENT_ACCOUNT_PROFILES_ROOT` is now only a source-checkout override for
288
+ development or custom runtime layouts
139
289
 
140
290
  ## Common Failures
141
291
 
@@ -147,7 +297,11 @@ Connector callback never arrives:
147
297
 
148
298
  CLI says the wallet is missing a writable session:
149
299
 
150
- - run `zk-agent wallet reapprove --name <wallet> --await-local`
300
+ - if the blocker is unclear, run `zk-agent doctor --wallet <wallet>` first
301
+ - inspect `zk-agent wallet status --name <wallet>`
302
+ - if approval is missing, run `zk-agent wallet reapprove --name <wallet> --await-local`
303
+ - if approval is present but the local signer is missing, run
304
+ `zk-agent wallet signer attach --name <wallet> --private-key <hex>`
151
305
  - then rerun `zk-agent next` or the blocked workflow command
152
306
 
153
307
  Workflow stops on funding:
@@ -166,6 +320,7 @@ For the canonical command surfaces:
166
320
 
167
321
  ```bash
168
322
  zk-agent --help
323
+ zk-agent doctor --help
169
324
  zk-agent wallet --help
170
325
  zk-agent workflow --help
171
326
  ```