zk-agent-cli 0.1.0-beta.9 → 0.1.0-rc.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 (3) hide show
  1. package/README.md +127 -173
  2. package/dist/index.js +1460 -154
  3. package/package.json +4 -2
package/README.md CHANGED
@@ -1,33 +1,11 @@
1
1
  # zk-agent-cli
2
2
 
3
- `zk-agent-cli` is the packaged `zk-agent-cli` command surface for zkSync Era
4
- and zkSync Sepolia.
3
+ `zk-agent-cli` is the packaged terminal CLI for the zk-agent operator path on
4
+ zkSync Era and zkSync Sepolia.
5
5
 
6
- Current strengths:
6
+ This file is the canonical operator manual for CLI users.
7
7
 
8
- - local-first wallet/session storage
9
- - `next`-first operator guidance
10
- - relay-backed approval and reapproval
11
- - workflow orchestration for send, swap, bridge, deposit, and withdraw
12
- - machine-readable JSON output for agent callers
13
-
14
- ## Public Entry Points
15
-
16
- Choose the entrypoint that matches the environment.
17
-
18
- If you are installing this repository into a compatible agent harness instead
19
- of using the CLI directly, prefer the repo skill surface:
20
-
21
- ```bash
22
- npx skills add https://github.com/AgiWeb3/zk-agent-cli
23
- ```
24
-
25
- This repo currently ships a repository skill bundle for compatible harnesses.
26
- The repository root now also ships a native ChatGPT/Codex plugin manifest at
27
- `.codex-plugin/plugin.json`, but that plugin source belongs to the repository
28
- surface rather than this published npm tarball.
29
-
30
- For direct terminal use, install the packaged CLI:
8
+ ## Install
31
9
 
32
10
  One-shot execution:
33
11
 
@@ -42,24 +20,22 @@ npm install -g zk-agent-cli
42
20
  zk-agent --help
43
21
  ```
44
22
 
45
- The package also ships the secondary binary name:
23
+ The package also ships the alias:
46
24
 
47
25
  ```bash
48
26
  zksync-agent --help
49
27
  ```
50
28
 
51
- ## Prerequisites
29
+ ## Defaults and prerequisites
52
30
 
53
- - Node.js `>=24` for either `npx zk-agent-cli ...` or global install.
54
- Older Node versions may still start the CLI, but the current package is not
55
- supported there and npm will emit `EBADENGINE` warnings.
56
- - The default local approval path expects the connector UI to be reachable at
57
- `http://localhost:4444`. Override it with
58
- `zk-agent setup --connector-url <url>` when needed.
59
- - The CLI auto-loads `.env` from the current working directory.
31
+ - Node.js `>=24`
32
+ - the default chain is `zksync-sepolia`
33
+ - the default local approval callback is `http://localhost:4444`
34
+ - the CLI auto-loads `.env` from the current working directory
60
35
 
61
- You do not need a custom `.env` just to run `setup`, `next`, or create a local
62
- wallet request. You usually do need one for live chain reads or broadcasts.
36
+ You do not need a custom `.env` just to run `setup`, `next`, `doctor`, or
37
+ create a wallet request. You usually do need RPC values for live reads or
38
+ broadcasts.
63
39
 
64
40
  Most relevant environment variables:
65
41
 
@@ -70,18 +46,9 @@ ZK_AGENT_TOKEN_DIRECTORY_ROOT=
70
46
  ZK_AGENT_STORAGE_DIR=
71
47
  ```
72
48
 
73
- Use:
74
-
75
- - `ZKSYNC_SEPOLIA_RPC_URL` for explicit zkSync Sepolia reads/broadcasts
76
- - `ETHEREUM_SEPOLIA_RPC_URL` for L1 deposit/bridge follow-up flows on Sepolia
77
- - `ZK_AGENT_TOKEN_DIRECTORY_ROOT` when you want local token-directory symbol
78
- resolution
79
- - `ZK_AGENT_STORAGE_DIR` only when you need to override the default local
80
- storage path
49
+ ## Fastest verified path
81
50
 
82
- ## Shortest Path
83
-
84
- Fresh setup:
51
+ Use this path unless the task explicitly needs a lower-level command:
85
52
 
86
53
  ```bash
87
54
  zk-agent setup
@@ -91,218 +58,205 @@ zk-agent next
91
58
  zk-agent workflow pay --wallet main --to <address> --amount <amount>
92
59
  ```
93
60
 
94
- If the browser is not colocated with the terminal, keep the same flow but
95
- replace the wallet-creation step with:
61
+ Interpretation:
62
+
63
+ - `setup` writes local defaults
64
+ - `next` gives the shortest valid follow-up step
65
+ - `wallet create --await-local` is the preferred local approval path
66
+ - `workflow pay` is the flagship zkSync-native AA native-send path
67
+
68
+ If readiness is unclear before you choose a fix, use:
96
69
 
97
70
  ```bash
98
- zk-agent relay inspect --relay-url <relay-url>
99
- zk-agent wallet create --relay-url <relay-url> --wait-relay --prompt-code
100
- zk-agent next
71
+ zk-agent doctor
101
72
  ```
102
73
 
103
- If a wallet already exists, inspect the blocker first. Use `wallet reapprove`
104
- when approval is missing or expired, then return to `zk-agent next`. Use
105
- `wallet signer attach` when approval is still present but the local execution
106
- signer is missing:
74
+ ## Existing wallet recovery
75
+
76
+ If the wallet already exists and approval is missing or expired:
107
77
 
108
78
  ```bash
109
79
  zk-agent wallet reapprove --name main --await-local
110
80
  zk-agent next
111
- zk-agent wallet signer attach --name main --private-key <hex>
112
- zk-agent next
113
81
  ```
114
82
 
115
- Only fund when the CLI says funding is actually required:
83
+ If approval is still present but the local execution signer is missing:
116
84
 
117
85
  ```bash
118
- zk-agent workflow fund --wallet main --amount <amount> --execute
86
+ zk-agent wallet signer attach --name main --private-key <hex>
87
+ zk-agent next
119
88
  ```
120
89
 
121
- Current flagship AA native-pay path:
90
+ Use these inspection commands when the blocker is wallet-specific:
122
91
 
123
92
  ```bash
124
- zk-agent workflow pay --wallet main --to <address> --amount <amount>
125
- zk-agent workflow pay --wallet main --to <address> --amount <amount> --paymaster-mode sponsored
93
+ zk-agent wallet status --name main
94
+ zk-agent wallet next --name main
126
95
  ```
127
96
 
128
- Use a `sed-lite` wallet for the default AA acceptance path. Keep
129
- `daily-spend-limit` for profile-specific policy experiments, not as the main
130
- operator baseline.
97
+ ## Remote approval
131
98
 
132
- `workflow pay` fixes the workflow intent to `send-native`, persists a
133
- checkpoint, executes immediately when ready, reopens a missing writable session
134
- through the intent-scoped approval path, and defaults to the validated
135
- approval-based paymaster mode unless you override it.
136
- When that approval-based path still needs a fee-token candidate, recover with
137
- `zk-agent tokens --chain zksync-sepolia --role paymaster-fee-token` and
138
- `zk-agent resolve-token --chain zksync-sepolia --symbol <symbol> --role paymaster-fee-token`.
99
+ Use the relay-backed path only when the browser is not colocated with the
100
+ terminal:
139
101
 
140
- ## Discovery Path
102
+ ```bash
103
+ zk-agent relay inspect --relay-url <relay-url>
104
+ zk-agent wallet create --relay-url <relay-url> --wait-relay --prompt-code
105
+ zk-agent next
106
+ ```
141
107
 
142
- Use the discovery surfaces in this order when a workflow or direct command
143
- needs token context:
108
+ For an existing wallet:
144
109
 
145
- - `zk-agent assets --wallet main` for the preferred single-chain asset view
146
- - `zk-agent tokens --wallet main --owned` for the narrower owned ERC-20 subset
147
- - `zk-agent tokens --chain zksync-sepolia` and
148
- `zk-agent resolve-token --chain zksync-sepolia --symbol USDC` for
149
- symbol-first discovery before choosing an explicit token address
150
- - `zk-agent tokens --chain zksync-sepolia --role paymaster-fee-token` and
151
- `zk-agent resolve-token --chain zksync-sepolia --symbol <symbol> --role paymaster-fee-token`
152
- for approval-based paymaster fee-token discovery on the flagship pay path
153
- - `zk-agent defaults` for the machine-readable registry/defaults catalog:
154
- tracked token roles, paymaster metadata, source order, and validated/fallback
155
- route metadata
110
+ ```bash
111
+ zk-agent wallet reapprove --name main --relay-url <relay-url> --wait-relay --prompt-code
112
+ zk-agent next
113
+ ```
156
114
 
157
- ## Direct Command Escape Hatches
115
+ If the relay is self-hosted through the built-in server:
158
116
 
159
- Use the guided workflow layer first, but the lower-level direct commands now
160
- keep the same symbol/discovery contract:
117
+ ```bash
118
+ zk-agent relay serve --public-origin https://relay.example.com
119
+ ```
161
120
 
162
- - `zk-agent send-token --wallet main --symbol USDC --to <address> --amount <amount>`
163
- - `zk-agent swap --wallet main --token-in-symbol USDC --token-out-symbol ETH --amount-in <amount>`
164
- - `zk-agent fund --wallet main --symbol USDC --amount <amount>`
165
- - `zk-agent deposit --wallet main --symbol USDC --amount <amount>`
166
- - `zk-agent withdraw --wallet main --symbol USDC --amount <amount>`
121
+ Use `relay inspect` before sending users to a share link. It exposes hosted
122
+ readiness, URL shape, persistence mode, and the exact create/reapprove follow-up
123
+ path.
167
124
 
168
- Current direct-command behavior:
125
+ For the supported hosted operating contract, use
126
+ [`docs/16-hosted-approval-operated-baseline.md`](../../docs/16-hosted-approval-operated-baseline.md).
169
127
 
170
- - `send-token`, `fund`, `deposit`, and `withdraw` accept symbol-first token
171
- resolution when the local registry can resolve the active chain token
172
- - `swap` follows the current registry-backed validated route by default when
173
- `--protocol` is omitted
174
- - `bridge` can reuse the tracked default destination route when one is already
175
- known for the current wallet chain
128
+ ## Funding and execution
176
129
 
177
- ## Local Agent Identity
130
+ Only fund when the CLI tells you funding is required:
178
131
 
179
- The local operator profile is optional. It helps agent harnesses and operators
180
- persist stable metadata, but wallet approval and workflow execution do not
181
- depend on it.
132
+ ```bash
133
+ zk-agent workflow fund --wallet main
134
+ zk-agent workflow fund --wallet main --amount <amount> --execute
135
+ ```
182
136
 
183
- Use:
137
+ Flagship 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> --broadcast
142
+ ```
184
143
 
185
- - `zk-agent agent status`
186
- - `zk-agent agent set --name "<operator-name>" --wallet main`
187
- - `zk-agent agent show`
144
+ Keep `sed-lite` as the default AA baseline. Use `daily-spend-limit` only when
145
+ you intentionally need that narrower policy profile.
188
146
 
189
- ## Remote Approval
147
+ ## Operator suite
190
148
 
191
- Shortest relay-backed path in one terminal process:
149
+ Use:
192
150
 
193
151
  ```bash
194
- zk-agent relay inspect --relay-url <relay-url>
195
- zk-agent wallet create --relay-url <relay-url> --wait-relay --prompt-code
152
+ zk-agent suite
196
153
  ```
197
154
 
198
- If the wallet already exists and approval metadata needs to be refreshed, use:
155
+ when you want the flagship path plus the current post-flagship surfaces in one
156
+ place.
199
157
 
200
- ```bash
201
- zk-agent wallet reapprove --name main --relay-url <relay-url> --wait-relay --prompt-code
202
- ```
158
+ Current suite shape:
203
159
 
204
- Treat that hosted path as the fallback when the browser is not colocated with
205
- the terminal; keep the local `--await-local` path as the default baseline.
160
+ - flagship pay:
161
+ `zk-agent workflow pay --wallet main --to <address> --amount <amount>`
162
+ - discovery/defaults:
163
+ `zk-agent assets --wallet main`
164
+ `zk-agent defaults`
165
+ `zk-agent resolve-token --chain zksync-sepolia --symbol USDC`
166
+ - funding readiness:
167
+ `zk-agent workflow fund --wallet main`
168
+ - paymaster readiness:
169
+ `zk-agent workflow pay --wallet main --to <address> --amount <amount> --paymaster-mode approval-based`
170
+ `zk-agent tokens --chain zksync-sepolia --role paymaster-fee-token`
206
171
 
207
- If approval is still present and only the local execution signer is missing,
208
- repair that locally instead of forcing a new approval round-trip:
172
+ ## Discovery and direct commands
209
173
 
210
- ```bash
211
- zk-agent wallet signer attach --name main --private-key <hex>
212
- zk-agent next
213
- ```
174
+ Preferred discovery order:
214
175
 
215
- Local relay prototype path:
176
+ - `zk-agent assets --wallet main`
177
+ - `zk-agent tokens --wallet main --owned`
178
+ - `zk-agent defaults`
179
+ - `zk-agent resolve-token --chain zksync-sepolia --symbol <symbol>`
216
180
 
217
- ```bash
218
- zk-agent relay serve --public-origin https://relay.example.com
219
- zk-agent wallet create --relay-url <relay-url>
220
- zk-agent wallet request approve --request-id <id> --relay-url <relay-url> --code <code> --wait
221
- ```
181
+ Use the direct commands when you intentionally want to bypass the workflow
182
+ layer:
222
183
 
223
- The built-in relay is a local file-backed prototype. It is useful for operator
224
- testing, not a production hosted relay service. When it sits behind a tunnel or
225
- reverse proxy, pass `--public-origin` so the emitted share/status URLs point at
226
- the externally reachable hosted URL instead of the local bind address. The
227
- published package now also ships the bundled connector UI build used by
228
- `relay serve`, so hosted share-link approval no longer depends on a separate
229
- source checkout just to serve the UI. `relay inspect` now also reports
230
- `stateBackend`, `deploymentScope`, and `sameHostRestartPersists` so the
231
- single-host local-filesystem constraint is explicit before you rely on a hosted
232
- URL.
184
+ - `zk-agent send-token --wallet main --symbol USDC --to <address> --amount <amount>`
185
+ - `zk-agent swap --wallet main --token-in-symbol USDC --token-out-symbol ETH --amount-in <amount>`
186
+ - `zk-agent fund --wallet main --symbol USDC --amount <amount>`
187
+ - `zk-agent deposit --wallet main --symbol USDC --amount <amount>`
188
+ - `zk-agent withdraw --wallet main --symbol USDC --amount <amount>`
233
189
 
234
- ## Local Storage
190
+ ## Local storage
235
191
 
236
- By default the CLI stores config, wallets, requests, and workflow checkpoints
237
- under:
192
+ By default the CLI stores local state under:
238
193
 
239
194
  ```text
240
195
  ~/.zk-agent/
241
196
  ```
242
197
 
243
- Common files created by the default path:
198
+ Common files:
244
199
 
245
200
  - `config.json`
246
201
  - `wallets/*.json`
247
202
  - `requests/*.json`
248
203
  - `workflows/*.json`
249
204
 
250
- ## Smart-Account Profiles
205
+ ## Smart-account profiles
206
+
207
+ The packaged CLI includes built-in profile artifacts for:
251
208
 
252
- The published package ships built-in profile artifacts for the first-party
253
- smart-account presets:
209
+ - `sed-lite`
210
+ - `daily-spend-limit`
211
+
212
+ Inspect them with:
254
213
 
255
214
  ```bash
256
215
  zk-agent wallet smart-account profiles --json
257
216
  ```
258
217
 
259
- That means the packaged CLI can use:
260
-
261
- - `zk-agent wallet smart-account predict --profile sed-lite`
262
- - `zk-agent wallet smart-account deploy --profile sed-lite`
263
- - the same built-in path for `daily-spend-limit`
218
+ Use the packaged path for:
264
219
 
265
- Current boundary:
266
-
267
- - built-in profiles work from the packaged CLI
268
- - custom profile artifacts still use `--artifact <json|@file>`
269
- - `ZK_AGENT_ACCOUNT_PROFILES_ROOT` is now only a source-checkout override for
270
- development or custom runtime layouts
220
+ ```bash
221
+ zk-agent wallet smart-account predict --profile sed-lite
222
+ zk-agent wallet smart-account deploy --profile sed-lite
223
+ ```
271
224
 
272
- ## Common Failures
225
+ ## Common failures
273
226
 
274
227
  Connector callback never arrives:
275
228
 
276
229
  - verify the connector URL saved by `zk-agent setup`
277
- - if local callback is not possible in your environment, switch to the relay
278
- path with `zk-agent relay serve` plus `wallet create|reapprove --relay-url`
230
+ - if local callback is impossible in the current environment, switch to the
231
+ relay-backed path
279
232
 
280
233
  CLI says the wallet is missing a writable session:
281
234
 
235
+ - run `zk-agent doctor --wallet <wallet>`
282
236
  - inspect `zk-agent wallet status --name <wallet>`
283
- - if approval is missing, run `zk-agent wallet reapprove --name <wallet> --await-local`
284
- - if approval is present but the local signer is missing, run
285
- `zk-agent wallet signer attach --name <wallet> --private-key <hex>`
286
- - then rerun `zk-agent next` or the blocked workflow command
237
+ - reapprove when approval is missing
238
+ - attach the signer when approval is present but local write readiness is not
287
239
 
288
240
  Workflow stops on funding:
289
241
 
290
242
  - do not guess the route
291
243
  - run the exact `workflow fund` command suggested by the CLI
292
244
 
293
- Relay / `--await-local` flows fail in a locked-down environment:
245
+ Locked-down environment blocks local callback or relay binding:
294
246
 
295
- - those flows need a process that can bind `127.0.0.1`
296
- - rerun from a normal host shell or use the relay/manual approval path
247
+ - rerun from a normal host shell
248
+ - or use a relay/manual approval path that matches the environment
297
249
 
298
- ## Command Help
250
+ ## Command help
299
251
 
300
- For the canonical command surfaces:
252
+ Use:
301
253
 
302
254
  ```bash
303
255
  zk-agent --help
256
+ zk-agent doctor --help
304
257
  zk-agent wallet --help
305
258
  zk-agent workflow --help
259
+ zk-agent suite --help
306
260
  ```
307
261
 
308
262
  ## License