@aomi-labs/client 0.1.12 → 0.1.14

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
@@ -63,30 +63,30 @@ new Session(clientOptions: AomiClientOptions, sessionOptions?: SessionOptions)
63
63
  new Session(client: AomiClient, sessionOptions?: SessionOptions)
64
64
  ```
65
65
 
66
- | Option | Default | Description |
67
- |--------|---------|-------------|
68
- | `sessionId` | `crypto.randomUUID()` | Thread/session ID |
69
- | `namespace` | `"default"` | Backend namespace |
70
- | `publicKey` | — | Wallet address |
71
- | `apiKey` | — | API key for private namespaces |
72
- | `userState` | — | Arbitrary user state sent with requests |
73
- | `pollIntervalMs` | `500` | Polling interval in ms |
74
- | `logger` | — | Pass `console` for debug output |
66
+ | Option | Default | Description |
67
+ | ---------------- | --------------------- | --------------------------------------- |
68
+ | `sessionId` | `crypto.randomUUID()` | Thread/session ID |
69
+ | `namespace` | `"default"` | Backend namespace |
70
+ | `publicKey` | — | Wallet address |
71
+ | `apiKey` | — | API key for private namespaces |
72
+ | `userState` | — | Arbitrary user state sent with requests |
73
+ | `pollIntervalMs` | `500` | Polling interval in ms |
74
+ | `logger` | — | Pass `console` for debug output |
75
75
 
76
76
  #### Methods
77
77
 
78
- | Method | Description |
79
- |--------|-------------|
80
- | `send(message)` | Send a message, wait for completion, return `{ messages, title }` |
81
- | `sendAsync(message)` | Send without waiting — poll in background, listen via events |
82
- | `resolve(id, result)` | Resolve a pending wallet request |
83
- | `reject(id, reason?)` | Reject a pending wallet request |
84
- | `interrupt()` | Cancel current processing |
85
- | `close()` | Stop polling, unsubscribe SSE, clean up |
86
- | `getMessages()` | Current messages |
87
- | `getTitle()` | Current session title |
88
- | `getPendingRequests()` | Pending wallet requests |
89
- | `getIsProcessing()` | Whether the agent is processing |
78
+ | Method | Description |
79
+ | ---------------------- | ----------------------------------------------------------------- |
80
+ | `send(message)` | Send a message, wait for completion, return `{ messages, title }` |
81
+ | `sendAsync(message)` | Send without waiting — poll in background, listen via events |
82
+ | `resolve(id, result)` | Resolve a pending wallet request |
83
+ | `reject(id, reason?)` | Reject a pending wallet request |
84
+ | `interrupt()` | Cancel current processing |
85
+ | `close()` | Stop polling, unsubscribe SSE, clean up |
86
+ | `getMessages()` | Current messages |
87
+ | `getTitle()` | Current session title |
88
+ | `getPendingRequests()` | Pending wallet requests |
89
+ | `getIsProcessing()` | Whether the agent is processing |
90
90
 
91
91
  #### Events
92
92
 
@@ -119,11 +119,15 @@ When installed globally or in a project, the executable name is `aomi`.
119
119
  For one-off usage, run commands via `npx @aomi-labs/client ...`.
120
120
 
121
121
  ```bash
122
+ npx @aomi-labs/client --version # print installed CLI version
122
123
  npx @aomi-labs/client chat "swap 1 ETH for USDC" # talk to the agent
123
124
  npx @aomi-labs/client chat "swap 1 ETH for USDC" --model claude-sonnet-4
124
125
  npx @aomi-labs/client chat "swap 1 ETH" --verbose # stream tool calls + responses live
125
- npx @aomi-labs/client models # list available models
126
+ npx @aomi-labs/client app list # list available apps
127
+ npx @aomi-labs/client model list # list available models
126
128
  npx @aomi-labs/client model set claude-sonnet-4 # switch the current session model
129
+ npx @aomi-labs/client secret list # list configured secret handles
130
+ npx @aomi-labs/client --secret ALCHEMY_API_KEY=... # ingest a secret for the active session
127
131
  npx @aomi-labs/client log # show full conversation history
128
132
  npx @aomi-labs/client tx # list pending + signed txs
129
133
  npx @aomi-labs/client sign tx-1 # sign a specific pending tx
@@ -150,7 +154,7 @@ session don't need it again.
150
154
  The CLI can discover and switch backend models for the active session:
151
155
 
152
156
  ```bash
153
- $ npx @aomi-labs/client models
157
+ $ npx @aomi-labs/client model list
154
158
  claude-sonnet-4
155
159
  gpt-5
156
160
 
@@ -164,6 +168,29 @@ $ npx @aomi-labs/client chat "hello" --model claude-sonnet-4
164
168
  successful backend update. `aomi chat --model ...` applies the requested model
165
169
  before sending the message and updates that persisted state as well.
166
170
 
171
+ ### Secret management
172
+
173
+ The CLI supports per-session secret ingestion. This lets the backend use opaque
174
+ handles instead of raw secret values:
175
+
176
+ ```bash
177
+ $ npx @aomi-labs/client --secret ALCHEMY_API_KEY=sk_live_123
178
+ Configured 1 secret for session 7f8a...
179
+ ALCHEMY_API_KEY $SECRET:ALCHEMY_API_KEY
180
+
181
+ $ npx @aomi-labs/client --secret ALCHEMY_API_KEY=sk_live_123 chat "simulate a swap on Base"
182
+ ```
183
+
184
+ You can inspect or clear the current session's secret handles:
185
+
186
+ ```bash
187
+ $ npx @aomi-labs/client secret list
188
+ ALCHEMY_API_KEY $SECRET:ALCHEMY_API_KEY
189
+
190
+ $ npx @aomi-labs/client secret clear
191
+ Cleared all secrets for the active session.
192
+ ```
193
+
167
194
  ### Transaction flow
168
195
 
169
196
  The backend builds transactions; the CLI persists and signs them:
@@ -252,17 +279,19 @@ $ npx @aomi-labs/client log
252
279
 
253
280
  All config can be passed as flags (which take priority over env vars):
254
281
 
255
- | Flag | Env Variable | Default | Description |
256
- |------|-------------|---------|-------------|
257
- | `--backend-url` | `AOMI_BASE_URL` | `https://api.aomi.dev` | Backend URL |
258
- | `--api-key` | `AOMI_API_KEY` | — | API key for non-default apps |
259
- | `--app` | `AOMI_APP` | `default` | App |
260
- | `--model` | `AOMI_MODEL` | — | Model rig to apply before chat |
261
- | `--public-key` | `AOMI_PUBLIC_KEY` | — | Wallet address (tells agent your wallet) |
262
- | `--private-key` | `PRIVATE_KEY` | — | Hex private key for `aomi sign` |
263
- | `--rpc-url` | `CHAIN_RPC_URL` | — | RPC URL for transaction submission |
264
- | `--chain` | `AOMI_CHAIN_ID` | `1` | Chain ID (1, 137, 42161, 8453, 10, 11155111) |
265
- | `--verbose`, `-v` | | | Stream tool calls and agent responses live |
282
+ | Flag | Env Variable | Default | Description |
283
+ | ----------------------- | ----------------- | ---------------------- | -------------------------------------------- |
284
+ | `--backend-url` | `AOMI_BASE_URL` | `https://api.aomi.dev` | Backend URL |
285
+ | `--api-key` | `AOMI_API_KEY` | — | API key for non-default apps |
286
+ | `--app` | `AOMI_APP` | `default` | App |
287
+ | `--model` | `AOMI_MODEL` | — | Model rig to apply before chat |
288
+ | `--secret <NAME=value>` | | — | Ingest secret values for the active session |
289
+ | `--public-key` | `AOMI_PUBLIC_KEY` | — | Wallet address (tells agent your wallet) |
290
+ | `--private-key` | `PRIVATE_KEY` | — | Hex private key for `aomi sign` |
291
+ | `--rpc-url` | `CHAIN_RPC_URL` | | RPC URL for transaction submission |
292
+ | `--chain` | `AOMI_CHAIN_ID` | `1` | Chain ID (1, 137, 42161, 8453, 10, 11155111) |
293
+ | `--verbose`, `-v` | — | — | Stream tool calls and agent responses live |
294
+ | `--version`, `-V` | — | — | Print the installed CLI version |
266
295
 
267
296
  ```bash
268
297
  # Use a custom backend
@@ -293,14 +322,16 @@ The CLI is **not** a long-running process — each command starts, runs, and
293
322
  exits. Conversation history lives on the backend. Between invocations, the CLI
294
323
  persists local state under `AOMI_STATE_DIR` or `~/.aomi` by default:
295
324
 
296
- | Field | Purpose |
297
- |-------|---------|
298
- | `sessionId` | Which conversation to continue |
299
- | `model` | Last successfully applied model for the session |
300
- | `publicKey` | Wallet address (from `--public-key`) |
301
- | `chainId` | Active chain ID (from `--chain`) |
302
- | `pendingTxs` | Unsigned transactions waiting for `aomi sign <id>` |
303
- | `signedTxs` | Completed transactions with hashes/signatures |
325
+ | Field | Purpose |
326
+ | --------------- | ------------------------------------------------------ |
327
+ | `sessionId` | Which conversation to continue |
328
+ | `clientId` | Stable client identity used for session secret handles |
329
+ | `model` | Last successfully applied model for the session |
330
+ | `publicKey` | Wallet address (from `--public-key`) |
331
+ | `chainId` | Active chain ID (from `--chain`) |
332
+ | `secretHandles` | Opaque handles returned for ingested secrets |
333
+ | `pendingTxs` | Unsigned transactions waiting for `aomi sign <id>` |
334
+ | `signedTxs` | Completed transactions with hashes/signatures |
304
335
 
305
336
  ```
306
337
  $ npx @aomi-labs/client chat "hello" # creates session, saves sessionId
package/dist/cli.js CHANGED
@@ -19,6 +19,46 @@ var __spreadValues = (a, b) => {
19
19
  };
20
20
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
21
 
22
+ // package.json
23
+ var package_default = {
24
+ name: "@aomi-labs/client",
25
+ version: "0.1.14",
26
+ description: "Platform-agnostic TypeScript client for the Aomi backend API",
27
+ type: "module",
28
+ main: "./dist/index.cjs",
29
+ module: "./dist/index.js",
30
+ types: "./dist/index.d.ts",
31
+ bin: {
32
+ aomi: "./dist/cli.js"
33
+ },
34
+ exports: {
35
+ ".": {
36
+ import: {
37
+ types: "./dist/index.d.ts",
38
+ default: "./dist/index.js"
39
+ },
40
+ require: {
41
+ types: "./dist/index.d.cts",
42
+ default: "./dist/index.cjs"
43
+ }
44
+ }
45
+ },
46
+ files: [
47
+ "dist",
48
+ "skills",
49
+ "README.md"
50
+ ],
51
+ scripts: {
52
+ build: "tsup",
53
+ "clean:dist": "rm -rf dist"
54
+ },
55
+ dependencies: {
56
+ "@getpara/aa-alchemy": "2.18.0",
57
+ "@getpara/aa-pimlico": "2.18.0",
58
+ viem: "^2.40.3"
59
+ }
60
+ };
61
+
22
62
  // src/cli/errors.ts
23
63
  var CliExit = class extends Error {
24
64
  constructor(code) {
@@ -95,7 +135,7 @@ function parseAAMode(value) {
95
135
  }
96
136
  function parseArgs(argv) {
97
137
  const raw = argv.slice(2);
98
- const command = raw[0] && !raw[0].startsWith("--") ? raw[0] : void 0;
138
+ const command = raw[0] && !raw[0].startsWith("-") ? raw[0] : void 0;
99
139
  const rest = command ? raw.slice(1) : raw;
100
140
  const positional = [];
101
141
  const flags = {};
@@ -792,9 +832,10 @@ var AomiClient = class {
792
832
  /**
793
833
  * Fetch current session state (messages, processing status, title).
794
834
  */
795
- async fetchState(sessionId, userState) {
835
+ async fetchState(sessionId, userState, clientId) {
796
836
  const url = buildApiUrl(this.baseUrl, "/api/state", {
797
- user_state: userState ? JSON.stringify(userState) : void 0
837
+ user_state: userState ? JSON.stringify(userState) : void 0,
838
+ client_id: clientId
798
839
  });
799
840
  const response = await fetch(url, {
800
841
  headers: withSessionHeader(sessionId)
@@ -818,6 +859,9 @@ var AomiClient = class {
818
859
  if (options == null ? void 0 : options.userState) {
819
860
  payload.user_state = JSON.stringify(options.userState);
820
861
  }
862
+ if (options == null ? void 0 : options.clientId) {
863
+ payload.client_id = options.clientId;
864
+ }
821
865
  return postState(
822
866
  this.baseUrl,
823
867
  "/api/chat",
@@ -849,6 +893,40 @@ var AomiClient = class {
849
893
  );
850
894
  }
851
895
  // ===========================================================================
896
+ // Secrets
897
+ // ===========================================================================
898
+ /**
899
+ * Ingest secrets for a client. Returns opaque `$SECRET:<name>` handles.
900
+ * Call this once at page load (or when secrets change) with a stable
901
+ * client_id for the browser tab. The same client_id should be passed
902
+ * to `sendMessage` / `fetchState` so sessions get associated.
903
+ */
904
+ async ingestSecrets(clientId, secrets) {
905
+ const url = joinApiPath(this.baseUrl, "/api/secrets");
906
+ const response = await fetch(url, {
907
+ method: "POST",
908
+ headers: { "Content-Type": "application/json" },
909
+ body: JSON.stringify({ client_id: clientId, secrets })
910
+ });
911
+ if (!response.ok) {
912
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
913
+ }
914
+ return await response.json();
915
+ }
916
+ /**
917
+ * Clear all secrets for a client (e.g. on page unload or logout).
918
+ */
919
+ async clearSecrets(clientId) {
920
+ const url = buildApiUrl(this.baseUrl, "/api/secrets", {
921
+ client_id: clientId
922
+ });
923
+ const response = await fetch(url, { method: "DELETE" });
924
+ if (!response.ok) {
925
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
926
+ }
927
+ return await response.json();
928
+ }
929
+ // ===========================================================================
852
930
  // SSE (Real-time Updates)
853
931
  // ===========================================================================
854
932
  /**
@@ -3627,6 +3705,7 @@ async function signCommand(runtime) {
3627
3705
  }
3628
3706
 
3629
3707
  // src/cli/main.ts
3708
+ var CLI_VERSION = package_default.version;
3630
3709
  function printUsage() {
3631
3710
  console.log(`
3632
3711
  aomi \u2014 CLI client for Aomi on-chain agent
@@ -3653,6 +3732,7 @@ Usage:
3653
3732
  aomi status Show current session state
3654
3733
  aomi events List system events
3655
3734
  aomi close Close the current session
3735
+ aomi --version Print the installed CLI version
3656
3736
 
3657
3737
  Options:
3658
3738
  --backend-url <url> Backend URL (default: https://api.aomi.dev)
@@ -3663,6 +3743,7 @@ Options:
3663
3743
  --private-key <key> Hex private key for signing
3664
3744
  --rpc-url <url> RPC URL for transaction submission
3665
3745
  --verbose, -v Show tool calls and streaming output (for chat)
3746
+ --version, -V Print the installed CLI version
3666
3747
 
3667
3748
  Sign options:
3668
3749
  aomi sign <tx-id> --eoa
@@ -3696,8 +3777,8 @@ Environment (overridden by flags):
3696
3777
  `.trim());
3697
3778
  }
3698
3779
  async function main(runtime) {
3699
- var _a3;
3700
- const command = (_a3 = runtime.parsed.command) != null ? _a3 : runtime.parsed.flags["help"] || runtime.parsed.flags["h"] ? "help" : void 0;
3780
+ var _a3, _b;
3781
+ const command = (_b = (_a3 = runtime.parsed.command) != null ? _a3 : runtime.parsed.flags["version"] || runtime.parsed.flags["V"] ? "version" : void 0) != null ? _b : runtime.parsed.flags["help"] || runtime.parsed.flags["h"] ? "help" : void 0;
3701
3782
  switch (command) {
3702
3783
  case "chat":
3703
3784
  await chatCommand(runtime);
@@ -3732,6 +3813,9 @@ async function main(runtime) {
3732
3813
  case "close":
3733
3814
  closeCommand(runtime);
3734
3815
  break;
3816
+ case "version":
3817
+ console.log(CLI_VERSION);
3818
+ break;
3735
3819
  case "help":
3736
3820
  printUsage();
3737
3821
  break;
package/dist/index.cjs CHANGED
@@ -317,9 +317,10 @@ var AomiClient = class {
317
317
  /**
318
318
  * Fetch current session state (messages, processing status, title).
319
319
  */
320
- async fetchState(sessionId, userState) {
320
+ async fetchState(sessionId, userState, clientId) {
321
321
  const url = buildApiUrl(this.baseUrl, "/api/state", {
322
- user_state: userState ? JSON.stringify(userState) : void 0
322
+ user_state: userState ? JSON.stringify(userState) : void 0,
323
+ client_id: clientId
323
324
  });
324
325
  const response = await fetch(url, {
325
326
  headers: withSessionHeader(sessionId)
@@ -343,6 +344,9 @@ var AomiClient = class {
343
344
  if (options == null ? void 0 : options.userState) {
344
345
  payload.user_state = JSON.stringify(options.userState);
345
346
  }
347
+ if (options == null ? void 0 : options.clientId) {
348
+ payload.client_id = options.clientId;
349
+ }
346
350
  return postState(
347
351
  this.baseUrl,
348
352
  "/api/chat",
@@ -374,6 +378,40 @@ var AomiClient = class {
374
378
  );
375
379
  }
376
380
  // ===========================================================================
381
+ // Secrets
382
+ // ===========================================================================
383
+ /**
384
+ * Ingest secrets for a client. Returns opaque `$SECRET:<name>` handles.
385
+ * Call this once at page load (or when secrets change) with a stable
386
+ * client_id for the browser tab. The same client_id should be passed
387
+ * to `sendMessage` / `fetchState` so sessions get associated.
388
+ */
389
+ async ingestSecrets(clientId, secrets) {
390
+ const url = joinApiPath(this.baseUrl, "/api/secrets");
391
+ const response = await fetch(url, {
392
+ method: "POST",
393
+ headers: { "Content-Type": "application/json" },
394
+ body: JSON.stringify({ client_id: clientId, secrets })
395
+ });
396
+ if (!response.ok) {
397
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
398
+ }
399
+ return await response.json();
400
+ }
401
+ /**
402
+ * Clear all secrets for a client (e.g. on page unload or logout).
403
+ */
404
+ async clearSecrets(clientId) {
405
+ const url = buildApiUrl(this.baseUrl, "/api/secrets", {
406
+ client_id: clientId
407
+ });
408
+ const response = await fetch(url, { method: "DELETE" });
409
+ if (!response.ok) {
410
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
411
+ }
412
+ return await response.json();
413
+ }
414
+ // ===========================================================================
377
415
  // SSE (Real-time Updates)
378
416
  // ===========================================================================
379
417
  /**