@aomi-labs/client 0.1.22 → 0.1.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aomi-labs/client",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "description": "Platform-agnostic TypeScript client for the Aomi backend API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -31,6 +31,7 @@
31
31
  "@getpara/aa-alchemy": "2.21.0",
32
32
  "@getpara/aa-pimlico": "2.21.0",
33
33
  "citty": "^0.2.2",
34
+ "permissionless": "^0.3.5",
34
35
  "viem": "^2.47.11"
35
36
  },
36
37
  "scripts": {
package/skills/README.md CHANGED
@@ -6,7 +6,7 @@ Agent skills for interacting with the [Aomi](https://aomi.dev) on-chain AI trans
6
6
 
7
7
  | Skill | Description |
8
8
  |-------|-------------|
9
- | [aomi-app-builder](aomi-app-builder/SKILL.md) | Build Aomi apps and plugins from APIs, specs, SDK docs, runtime interfaces, and product requirements |
9
+ | [aomi-build](aomi-build/SKILL.md) | Build Aomi apps and plugins from APIs, specs, SDK docs, runtime interfaces, and product requirements |
10
10
  | [aomi-transact](aomi-transact/SKILL.md) | Build and execute EVM transactions through a conversational AI agent via the `aomi` CLI |
11
11
 
12
12
  ## Installation
@@ -33,7 +33,7 @@ npm install -g viem
33
33
 
34
34
  Once installed, ask your agent:
35
35
 
36
- - "What's the price of ETH?"
36
+ - "Use aomi: What's the price of ETH?"
37
37
  - "Swap 1 ETH for USDC on Uniswap"
38
38
  - "Send 0.1 ETH to vitalik.eth"
39
39
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- name: aomi-app-builder
2
+ name: aomi-build
3
3
  description: >
4
4
  Use when the user wants to build, scaffold, or update an Aomi app/plugin from
5
5
  API docs, OpenAPI or Swagger specs, SDK docs, repository examples, endpoint
@@ -15,7 +15,7 @@ metadata:
15
15
  version: "0.1"
16
16
  ---
17
17
 
18
- # Aomi App Builder
18
+ # Aomi Build
19
19
 
20
20
  Use this skill for tasks like:
21
21
 
@@ -0,0 +1,4 @@
1
+ interface:
2
+ display_name: "Aomi Build"
3
+ short_description: "Build Aomi apps from APIs and specs"
4
+ default_prompt: "Use $aomi-build to turn this API, OpenAPI spec, or product brief into an Aomi SDK app/plugin with a clean tool surface, preamble, and validation plan."
@@ -8,6 +8,7 @@ description: >
8
8
  review, AA-first signing with mode fallback, persistent AA configuration,
9
9
  session controls, and per-session secret ingestion.
10
10
  compatibility: "Requires @aomi-labs/client (`npm install -g @aomi-labs/client`). CLI executable is `aomi`. Requires viem for signing (`npm install viem`). Use AOMI_APP / --app, AOMI_MODEL / --model, AOMI_CHAIN_ID / --chain, CHAIN_RPC_URL / --rpc-url, `aomi secret add` for session secret ingestion, and AOMI_STATE_DIR for local session storage."
11
+
11
12
  license: MIT
12
13
  allowed-tools: Bash
13
14
  metadata:
@@ -25,7 +26,8 @@ backend. Local session data lives under `AOMI_STATE_DIR` or `~/.aomi`.
25
26
 
26
27
  - The user wants to chat with the Aomi agent from the terminal.
27
28
  - The user wants balances, prices, routes, quotes, or transaction status.
28
- - The user wants to build, confirm, sign, or broadcast wallet requests.
29
+ - The user wants to build, simulate, confirm, sign, or broadcast wallet requests.
30
+ - The user wants to simulate a batch of pending transactions before signing.
29
31
  - The user wants to inspect or switch apps, models, chains, or sessions.
30
32
  - The user wants to inject API keys or other backend secrets for the current session.
31
33
  - The user wants to configure or inspect Account Abstraction settings.
@@ -198,6 +200,87 @@ aomi tx sign tx-1 --eoa --private-key 0xYourPrivateKey --rpc-url https://eth.lla
198
200
  aomi tx sign tx-1 --aa-provider pimlico --aa-mode 4337 --private-key 0xYourPrivateKey
199
201
  ```
200
202
 
203
+ ### Batch Simulation
204
+
205
+ Use `aomi simulate` to dry-run pending transactions before signing. Simulation
206
+ runs each tx sequentially on a forked chain so state-dependent flows (approve →
207
+ swap) are validated as a batch — the swap sees the approve's state changes.
208
+
209
+ ```bash
210
+ # Simulate a single pending tx
211
+ aomi simulate tx-1
212
+
213
+ # Simulate a multi-step batch in order (approve then swap)
214
+ aomi simulate tx-1 tx-2
215
+ ```
216
+
217
+ The response includes per-step success/failure, revert reasons, and gas usage:
218
+
219
+ ```
220
+ Simulation result:
221
+ Batch success: true
222
+ Stateful: true
223
+ Total gas: 147821
224
+
225
+ Step 1 — approve USDC
226
+ success: true
227
+ gas_used: 46000
228
+
229
+ Step 2 — swap on Uniswap
230
+ success: true
231
+ gas_used: 101821
232
+ ```
233
+
234
+ When to simulate:
235
+
236
+ - **Always simulate multi-step flows** (approve → swap, approve → deposit, etc.) before signing. These are state-dependent — the second tx will revert if submitted independently.
237
+ - **Optional for single independent txs** like a simple ETH transfer or a standalone swap with no prior approval needed.
238
+ - If simulation fails at step N, read the revert reason before retrying. Common causes: insufficient balance, expired quote/timestamp, wrong calldata. Do not blindly re-sign after a simulation failure.
239
+
240
+ When not to simulate:
241
+
242
+ - Read-only operations (balances, prices, quotes).
243
+ - If there are no pending transactions (`aomi tx` shows nothing).
244
+
245
+ Simulation and signing workflow:
246
+
247
+ ```bash
248
+ # 1. Build the request
249
+ aomi chat "approve and swap 100 USDC for ETH on Uniswap" \
250
+ --public-key 0xYourAddress --chain 1
251
+
252
+ # 2. Check what got queued
253
+ aomi tx
254
+
255
+ # 3. Simulate the batch
256
+ aomi simulate tx-1 tx-2
257
+
258
+ # 4. If simulation succeeds, sign
259
+ aomi sign tx-1 tx-2 --private-key 0xYourPrivateKey --rpc-url https://eth.llamarpc.com
260
+
261
+ # 5. Verify
262
+ aomi tx
263
+ ```
264
+
265
+ ### Account Abstraction
266
+
267
+ AA is the preferred signing path when the user wants smart-account behavior,
268
+ gas sponsorship, or the CLI's automated fallback handling.
269
+
270
+ Use AA when:
271
+
272
+ - The user wants the most hands-off signing flow and is fine with the CLI trying AA before EOA.
273
+ - The user wants sponsored or user-funded smart-account execution through Alchemy or Pimlico.
274
+ - The user explicitly asks for `4337` or `7702` account-abstraction mode.
275
+
276
+ How to choose:
277
+
278
+ - `aomi sign` with no AA flags: try AA first, then fall back to EOA automatically if AA is unavailable.
279
+ - `aomi sign --aa`: require AA only. Use this when the user does not want an EOA fallback.
280
+ - `aomi sign --eoa`: bypass AA entirely and sign directly with the wallet key.
281
+ - `aomi sign --aa-provider alchemy|pimlico`: force a specific AA provider.
282
+ - `aomi sign --aa-mode 4337|7702`: force the execution mode when the user wants a specific AA path.
283
+
201
284
  More signing notes:
202
285
 
203
286
  - `aomi tx sign` handles both transaction requests and EIP-712 typed data signatures.
@@ -285,6 +368,19 @@ aomi secret add NAME=value [NAME=value ...]
285
368
  - `aomi secret clear` removes all configured secrets for the active session.
286
369
  - `aomi secret add` ingests one or more NAME=value secrets.
287
370
 
371
+ ### Batch Simulation
372
+
373
+ ```bash
374
+ aomi simulate <tx-id> [<tx-id> ...]
375
+ ```
376
+
377
+ - Runs pending transactions sequentially on a forked chain (Anvil snapshot/revert).
378
+ - Each tx sees state changes from previous txs — validates state-dependent flows like approve → swap.
379
+ - Returns per-step success/failure, revert reasons, and `gas_used`.
380
+ - Returns `total_gas` for the entire batch.
381
+ - No on-chain state is modified — the fork is reverted after simulation.
382
+ - Requires pending transactions to exist in the session (`aomi tx` to check).
383
+
288
384
  ### App And Model Commands
289
385
 
290
386
  ```bash
@@ -402,8 +498,8 @@ Priority chain for AA resolution: **flag > env var > `~/.aomi/aa.json` > default
402
498
 
403
499
  | Provider | Flag | Env Var | Persistent Config | Notes |
404
500
  | -------- | ----------------------- | ----------------- | ------------------------- | -------------------------------- |
405
- | Alchemy | `--aa-provider alchemy` | `ALCHEMY_API_KEY` | `aomi aa set provider alchemy` | Supports sponsorship, 4337, 7702 |
406
- | Pimlico | `--aa-provider pimlico` | `PIMLICO_API_KEY` | `aomi aa set provider pimlico` | Supports 4337 and 7702 |
501
+ | Alchemy | `--aa-provider alchemy` | `ALCHEMY_API_KEY` | `aomi aa set provider alchemy` | 4337 (sponsored via gas policy), 7702 (EOA pays gas) |
502
+ | Pimlico | `--aa-provider pimlico` | `PIMLICO_API_KEY` | `aomi aa set provider pimlico` | 4337 (sponsored via dashboard policy). Direct private key supported. |
407
503
 
408
504
  Provider selection rules:
409
505
 
@@ -413,10 +509,12 @@ Provider selection rules:
413
509
 
414
510
  ### AA Modes
415
511
 
416
- | Mode | Flag | Meaning |
417
- | ------ | ---------------- | -------------------------------- |
418
- | `4337` | `--aa-mode 4337` | Bundler-based smart account flow |
419
- | `7702` | `--aa-mode 7702` | Delegated execution flow |
512
+ | Mode | Flag | Meaning | Gas |
513
+ | ------ | ---------------- | -------------------------------- | --- |
514
+ | `4337` | `--aa-mode 4337` | Bundler + paymaster UserOperation via smart account. Gas sponsored by paymaster. | Paymaster pays |
515
+ | `7702` | `--aa-mode 7702` | Native EIP-7702 type-4 transaction with delegation. EOA signs authorization + sends tx to self. | EOA pays |
516
+
517
+ Important: **7702 requires the signing EOA to have native gas tokens** (ETH, MATIC, etc.). There is no paymaster/sponsorship for 7702. Use 4337 for gasless execution.
420
518
 
421
519
  ### Default Chain Modes
422
520
 
@@ -430,7 +528,9 @@ Provider selection rules:
430
528
 
431
529
  ### Sponsorship
432
530
 
433
- Alchemy sponsorship is optional.
531
+ Sponsorship is available for **4337 mode only**. 7702 does not support sponsorship.
532
+
533
+ **Alchemy** (optional gas policy):
434
534
 
435
535
  ```bash
436
536
  export ALCHEMY_API_KEY=your-key
@@ -447,6 +547,15 @@ aomi aa set policy your-policy-id
447
547
  aomi tx sign tx-1
448
548
  ```
449
549
 
550
+ **Pimlico** (sponsorship via dashboard policy):
551
+
552
+ ```bash
553
+ export PIMLICO_API_KEY=your-key
554
+ aomi tx sign tx-1 --aa-provider pimlico --aa-mode 4337
555
+ ```
556
+
557
+ Pimlico sponsorship is configured on the Pimlico dashboard (sponsorship policies). The API key automatically picks up the active policy — no separate policy ID env var needed.
558
+
450
559
  ### Supported Chains
451
560
 
452
561
  | Chain | ID |
@@ -499,9 +608,9 @@ Environment variables override persistent config (`~/.aomi/aa.json`).
499
608
 
500
609
  | Env Var | Purpose |
501
610
  | ------------------------ | ----------------------------------- |
502
- | `ALCHEMY_API_KEY` | Enables Alchemy AA |
503
- | `ALCHEMY_GAS_POLICY_ID` | Optional Alchemy sponsorship policy |
504
- | `PIMLICO_API_KEY` | Enables Pimlico AA |
611
+ | `ALCHEMY_API_KEY` | Enables Alchemy AA (4337 + 7702) |
612
+ | `ALCHEMY_GAS_POLICY_ID` | Optional Alchemy sponsorship policy (4337 only) |
613
+ | `PIMLICO_API_KEY` | Enables Pimlico AA (4337 sponsored) |
505
614
 
506
615
  `ALCHEMY_API_KEY` can also be used to construct chain-specific signing RPCs:
507
616
 
@@ -569,6 +678,28 @@ aomi tx list
569
678
  aomi session log
570
679
  ```
571
680
 
681
+ ### Approve + Swap With Simulation
682
+
683
+ ```bash
684
+ # 1. Build a multi-step request
685
+ aomi chat "approve and swap 500 USDC for ETH on Uniswap" \
686
+ --public-key 0xYourAddress --chain 1
687
+
688
+ # 2. Check queued requests
689
+ aomi tx
690
+
691
+ # 3. Simulate the batch — approve then swap
692
+ aomi simulate tx-1 tx-2
693
+
694
+ # 4. If simulation passes, sign the batch
695
+ aomi sign tx-1 tx-2 \
696
+ --private-key 0xYourPrivateKey \
697
+ --rpc-url https://eth.llamarpc.com
698
+
699
+ # 5. Verify
700
+ aomi tx
701
+ ```
702
+
572
703
  ### Explicit EOA Flow
573
704
 
574
705
  ```bash
@@ -669,3 +800,5 @@ aomi session close
669
800
  - If `ALCHEMY_API_KEY` is set, construct the correct chain-specific Alchemy RPC before falling back to random public endpoints.
670
801
  - If one or two public RPCs fail for the same chain, stop rotating through random endpoints and ask the user for a proper RPC URL for that chain.
671
802
  - Use `aomi aa test --chain <id>` to validate AA setup for a specific chain before signing.
803
+ - If `aomi simulate` fails with a revert, read the revert reason. Common causes: expired quote or timestamp (re-chat to get a fresh quote), insufficient token balance, or missing prior approval. Do not sign transactions that failed simulation without understanding why.
804
+ - If `aomi simulate` returns `stateful: false`, the backend could not fork the chain — simulation ran each tx independently via `eth_call`, so state-dependent flows (approve → swap) may show false negatives. Retry or check that the backend's Anvil instance is running.
@@ -1,4 +0,0 @@
1
- interface:
2
- display_name: "Aomi App Builder"
3
- short_description: "Build Aomi apps from APIs and specs"
4
- default_prompt: "Use $aomi-app-builder to turn this API, OpenAPI spec, or product brief into an Aomi SDK app/plugin with a clean tool surface, preamble, and validation plan."