zk-agent-cli 0.1.0-rc.0 → 0.1.0-rc.2

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 +146 -206
  2. package/dist/index.js +521 -43
  3. package/package.json +5 -1
package/README.md CHANGED
@@ -1,37 +1,45 @@
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
- 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.
6
+ This is the canonical CLI operator manual.
9
7
 
10
- Current strengths:
11
-
12
- - local-first wallet/session storage
13
- - `next`-first operator guidance
14
- - relay-backed approval and reapproval
15
- - workflow orchestration for send, swap, bridge, deposit, and withdraw
16
- - machine-readable JSON output for agent callers
8
+ Use:
17
9
 
18
- ## Public Entry Points
10
+ - [`skills/QUICKSTART.md`](../../skills/QUICKSTART.md) for the shortest
11
+ verified path
12
+ - [`docs/15-codex-plugin-onboarding.md`](../../docs/15-codex-plugin-onboarding.md)
13
+ for the native Codex plugin/local marketplace path
19
14
 
20
- Choose the entrypoint that matches the environment.
15
+ ## One-minute path
21
16
 
22
- If you are installing this repository into a compatible agent harness instead
23
- of using the CLI directly, prefer the repo skill surface:
17
+ Use this path unless the task explicitly needs a lower-level command:
24
18
 
25
19
  ```bash
26
- npx skills add https://github.com/AgiWeb3/zk-agent-cli
20
+ zk-agent setup
21
+ zk-agent next
22
+ zk-agent wallet create --await-local
23
+ zk-agent next
24
+ zk-agent workflow pay --wallet main --to <address> --amount <amount>
25
+ zk-agent suite
27
26
  ```
28
27
 
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.
28
+ What each step is doing:
29
+
30
+ - `setup` writes local defaults
31
+ - `next` gives the shortest valid follow-up step
32
+ - `wallet create --await-local` is the preferred local approval path
33
+ - `workflow pay` is the flagship zkSync-native AA native-send path
34
+ - `suite` is the packaged surface
35
+
36
+ If readiness is unclear before you choose a fix, use:
37
+
38
+ ```bash
39
+ zk-agent doctor
40
+ ```
33
41
 
34
- For direct terminal use, install the packaged CLI:
42
+ ## Install
35
43
 
36
44
  One-shot execution:
37
45
 
@@ -46,24 +54,25 @@ npm install -g zk-agent-cli
46
54
  zk-agent --help
47
55
  ```
48
56
 
49
- The package also ships the secondary binary name:
57
+ The package also ships the alias:
50
58
 
51
59
  ```bash
52
60
  zksync-agent --help
53
61
  ```
54
62
 
55
- ## Prerequisites
63
+ The `npx skills add ...` path belongs to the repo skill bundle, not the
64
+ packaged CLI install surface.
56
65
 
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.
60
- - The default local approval path expects the connector UI to be reachable at
61
- `http://localhost:4444`. Override it with
62
- `zk-agent setup --connector-url <url>` when needed.
63
- - The CLI auto-loads `.env` from the current working directory.
66
+ ## Defaults
64
67
 
65
- You do not need a custom `.env` just to run `setup`, `next`, or create a local
66
- wallet request. You usually do need one for live chain reads or broadcasts.
68
+ - Node.js `>=24`
69
+ - the default chain is `zksync-sepolia`
70
+ - the default local approval callback is `http://localhost:4444`
71
+ - the CLI auto-loads `.env` from the current working directory
72
+
73
+ You do not need a custom `.env` just to run `setup`, `next`, `doctor`, or
74
+ create a wallet request. You usually do need RPC values for live reads or
75
+ broadcasts.
67
76
 
68
77
  Most relevant environment variables:
69
78
 
@@ -74,36 +83,33 @@ ZK_AGENT_TOKEN_DIRECTORY_ROOT=
74
83
  ZK_AGENT_STORAGE_DIR=
75
84
  ```
76
85
 
77
- Use:
86
+ ## Repair Paths
78
87
 
79
- - `ZKSYNC_SEPOLIA_RPC_URL` for explicit zkSync Sepolia reads/broadcasts
80
- - `ETHEREUM_SEPOLIA_RPC_URL` for L1 deposit/bridge follow-up flows on Sepolia
81
- - `ZK_AGENT_TOKEN_DIRECTORY_ROOT` when you want local token-directory symbol
82
- resolution
83
- - `ZK_AGENT_STORAGE_DIR` only when you need to override the default local
84
- storage path
88
+ If the wallet already exists and approval is missing or expired:
85
89
 
86
- ## Shortest Path
90
+ ```bash
91
+ zk-agent wallet reapprove --name main --await-local
92
+ zk-agent next
93
+ ```
87
94
 
88
- Current validated first-run baseline:
95
+ If approval is still present but the local execution signer is missing:
89
96
 
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
97
+ ```bash
98
+ zk-agent wallet signer attach --name main --private-key <hex>
99
+ zk-agent next
100
+ ```
94
101
 
95
- Fresh setup:
102
+ Use these inspection commands when the blocker is wallet-specific:
96
103
 
97
104
  ```bash
98
- zk-agent setup
99
- zk-agent next
100
- zk-agent wallet create --await-local
101
- zk-agent next
102
- zk-agent workflow pay --wallet main --to <address> --amount <amount>
105
+ zk-agent wallet status --name main
106
+ zk-agent wallet next --name main
103
107
  ```
104
108
 
105
- If the browser is not colocated with the terminal, keep the same flow but
106
- replace the wallet-creation step with:
109
+ ## Remote approval
110
+
111
+ Use the relay-backed path only when the browser is not colocated with the
112
+ terminal:
107
113
 
108
114
  ```bash
109
115
  zk-agent relay inspect --relay-url <relay-url>
@@ -111,218 +117,152 @@ zk-agent wallet create --relay-url <relay-url> --wait-relay --prompt-code
111
117
  zk-agent next
112
118
  ```
113
119
 
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:
120
+ For an existing wallet:
123
121
 
124
122
  ```bash
125
- zk-agent wallet reapprove --name main --await-local
126
- zk-agent next
127
- zk-agent wallet signer attach --name main --private-key <hex>
123
+ zk-agent wallet reapprove --name main --relay-url <relay-url> --wait-relay --prompt-code
128
124
  zk-agent next
129
125
  ```
130
126
 
131
- Only fund when the CLI says funding is actually required:
127
+ Current supportable product shape on this path:
128
+
129
+ - one externally reachable public origin
130
+ - one relay host with same-host file persistence
131
+ - one same-origin share-link + approval UI surface
132
+
133
+ Do not assume multi-host or load-balanced durability on the current relay
134
+ surface.
135
+
136
+ If the relay is self-hosted through the built-in server:
132
137
 
133
138
  ```bash
134
- zk-agent workflow fund --wallet main --amount <amount> --execute
139
+ zk-agent relay serve --public-origin https://relay.example.com
135
140
  ```
136
141
 
137
- Current flagship AA native-pay path:
142
+ Use `relay inspect` before sending users to a share link. It exposes hosted
143
+ readiness, URL shape, persistence mode, and the exact create/reapprove follow-up
144
+ path.
145
+
146
+ For the supported hosted operating contract, use
147
+ [`docs/16-hosted-approval-operated-baseline.md`](../../docs/16-hosted-approval-operated-baseline.md).
148
+
149
+ ## After Wallet Ready
150
+
151
+ Default flagship write path:
138
152
 
139
153
  ```bash
140
154
  zk-agent workflow pay --wallet main --to <address> --amount <amount>
141
- zk-agent workflow pay --wallet main --to <address> --amount <amount> --paymaster-mode sponsored
155
+ zk-agent workflow pay --wallet main --to <address> --amount <amount> --broadcast
142
156
  ```
143
157
 
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.
158
+ Keep `sed-lite` as the default AA baseline. Use `daily-spend-limit` only when
159
+ you intentionally need that narrower policy profile.
147
160
 
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`.
161
+ Default packaged surface:
155
162
 
156
- ## Discovery Path
163
+ ```bash
164
+ zk-agent suite
165
+ ```
157
166
 
158
- Use the discovery surfaces in this order when a workflow or direct command
159
- needs token context:
167
+ Use `suite` when the wallet is already ready and you want one packaged surface
168
+ for flagship pay, discovery/defaults, funding readiness, and approval-based
169
+ paymaster readiness.
160
170
 
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
171
+ Use `--wallet <name>` or `--chain <chain>` when the returned suite commands
172
+ should stay on a non-default wallet or chain.
172
173
 
173
- ## Direct Command Escape Hatches
174
+ Only fund when the CLI tells you funding is required:
174
175
 
175
- Use the guided workflow layer first, but the lower-level direct commands now
176
- keep the same symbol/discovery contract:
176
+ ```bash
177
+ zk-agent workflow fund --wallet main
178
+ zk-agent workflow fund --wallet main --amount <amount> --execute
179
+ ```
177
180
 
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>`
181
+ Do not guess the route. Use the exact funding command suggested by `next`,
182
+ `doctor`, `wallet status`, a blocked workflow, or `suite`.
183
183
 
184
- Current direct-command behavior:
184
+ ## Direct Paths
185
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
186
+ Prefer `suite` first when you want the packaged discovery/defaults/funding/
187
+ paymaster surface. Use the commands below only when you intentionally want a
188
+ narrower path.
192
189
 
193
- ## Local Agent Identity
190
+ Preferred discovery order:
194
191
 
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.
192
+ - `zk-agent assets --wallet main`
193
+ - `zk-agent tokens --wallet main --owned`
194
+ - `zk-agent defaults`
195
+ - `zk-agent resolve-token --chain zksync-sepolia --symbol <symbol>`
198
196
 
199
- Use:
197
+ Bypass examples:
200
198
 
201
- - `zk-agent agent status`
202
- - `zk-agent agent set --name "<operator-name>" --wallet main`
203
- - `zk-agent agent show`
199
+ - `zk-agent send-token --wallet main --symbol USDC --to <address> --amount <amount>`
200
+ - `zk-agent swap --wallet main --token-in-symbol USDC --token-out-symbol ETH --amount-in <amount>`
201
+ - `zk-agent fund --wallet main --symbol USDC --amount <amount>`
202
+ - `zk-agent deposit --wallet main --symbol USDC --amount <amount>`
203
+ - `zk-agent withdraw --wallet main --symbol USDC --amount <amount>`
204
204
 
205
- ## Remote Approval
205
+ ## Smart-account Profiles
206
206
 
207
- Shortest relay-backed path in one terminal process:
207
+ Built-in profiles:
208
208
 
209
- ```bash
210
- zk-agent relay inspect --relay-url <relay-url>
211
- zk-agent wallet create --relay-url <relay-url> --wait-relay --prompt-code
212
- ```
209
+ - `sed-lite`
210
+ - `daily-spend-limit`
213
211
 
214
- If the wallet already exists and approval metadata needs to be refreshed, use:
212
+ Inspect them with:
215
213
 
216
214
  ```bash
217
- zk-agent wallet reapprove --name main --relay-url <relay-url> --wait-relay --prompt-code
215
+ zk-agent wallet smart-account profiles --json
218
216
  ```
219
217
 
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:
218
+ Use the packaged path for:
225
219
 
226
220
  ```bash
227
- zk-agent wallet signer attach --name main --private-key <hex>
228
- zk-agent next
221
+ zk-agent wallet smart-account predict --profile sed-lite
222
+ zk-agent wallet smart-account deploy --profile sed-lite
229
223
  ```
230
224
 
231
- Local relay prototype path:
225
+ ## Common failures
232
226
 
233
- ```bash
234
- zk-agent relay serve --public-origin https://relay.example.com
235
- zk-agent wallet create --relay-url <relay-url>
236
- zk-agent wallet request approve --request-id <id> --relay-url <relay-url> --code <code> --wait
237
- ```
227
+ - connector callback never arrives:
228
+ verify the connector URL saved by `zk-agent setup`; if local callback is not
229
+ viable in the current environment, switch to the relay-backed path
230
+ - wallet is missing a writable session:
231
+ run `zk-agent doctor --wallet <wallet>`, then inspect
232
+ `zk-agent wallet status --name <wallet>`; reapprove when approval is missing,
233
+ attach the signer when approval is still present
234
+ - workflow stops on funding:
235
+ do not guess the route; run the exact `workflow fund` command suggested by
236
+ the CLI
237
+ - locked-down environment blocks local callback or relay binding:
238
+ rerun from a normal host shell or use the relay/manual approval path that
239
+ matches the environment
238
240
 
239
- The built-in relay is a local file-backed prototype. It is useful for operator
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).
241
+ ## Reference
251
242
 
252
- ## Local Storage
243
+ Local storage:
253
244
 
254
- By default the CLI stores config, wallets, requests, and workflow checkpoints
255
- under:
245
+ By default the CLI stores local state under:
256
246
 
257
247
  ```text
258
248
  ~/.zk-agent/
259
249
  ```
260
250
 
261
- Common files created by the default path:
251
+ Common files:
262
252
 
263
253
  - `config.json`
264
254
  - `wallets/*.json`
265
255
  - `requests/*.json`
266
256
  - `workflows/*.json`
267
257
 
268
- ## Smart-Account Profiles
269
-
270
- The published package ships built-in profile artifacts for the first-party
271
- smart-account presets:
272
-
273
- ```bash
274
- zk-agent wallet smart-account profiles --json
275
- ```
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
-
283
- Current boundary:
284
-
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
289
-
290
- ## Common Failures
291
-
292
- Connector callback never arrives:
293
-
294
- - verify the connector URL saved by `zk-agent setup`
295
- - if local callback is not possible in your environment, switch to the relay
296
- path with `zk-agent relay serve` plus `wallet create|reapprove --relay-url`
297
-
298
- CLI says the wallet is missing a writable session:
299
-
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>`
305
- - then rerun `zk-agent next` or the blocked workflow command
306
-
307
- Workflow stops on funding:
308
-
309
- - do not guess the route
310
- - run the exact `workflow fund` command suggested by the CLI
311
-
312
- Relay / `--await-local` flows fail in a locked-down environment:
313
-
314
- - those flows need a process that can bind `127.0.0.1`
315
- - rerun from a normal host shell or use the relay/manual approval path
316
-
317
- ## Command Help
318
-
319
- For the canonical command surfaces:
258
+ Help surfaces:
320
259
 
321
260
  ```bash
322
261
  zk-agent --help
323
262
  zk-agent doctor --help
324
263
  zk-agent wallet --help
325
264
  zk-agent workflow --help
265
+ zk-agent suite --help
326
266
  ```
327
267
 
328
268
  ## License