@aomi-labs/client 0.1.14 → 0.1.15

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 (2) hide show
  1. package/dist/cli.js +116 -7
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -22,7 +22,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
22
  // package.json
23
23
  var package_default = {
24
24
  name: "@aomi-labs/client",
25
- version: "0.1.14",
25
+ version: "0.1.15",
26
26
  description: "Platform-agnostic TypeScript client for the Aomi backend API",
27
27
  type: "module",
28
28
  main: "./dist/index.cjs",
@@ -133,22 +133,38 @@ function parseAAMode(value) {
133
133
  }
134
134
  fatal("Unsupported AA mode. Use `4337` or `7702`.");
135
135
  }
136
+ function parseSecret(value, secrets) {
137
+ const eqIdx = value.indexOf("=");
138
+ if (eqIdx > 0) {
139
+ secrets[value.slice(0, eqIdx)] = value.slice(eqIdx + 1);
140
+ }
141
+ }
136
142
  function parseArgs(argv) {
137
143
  const raw = argv.slice(2);
138
144
  const command = raw[0] && !raw[0].startsWith("-") ? raw[0] : void 0;
139
145
  const rest = command ? raw.slice(1) : raw;
140
146
  const positional = [];
141
147
  const flags = {};
148
+ const secrets = {};
142
149
  for (let i = 0; i < rest.length; i++) {
143
150
  const arg = rest[i];
144
151
  if (arg.startsWith("--") && arg.includes("=")) {
145
152
  const [key, ...val] = arg.slice(2).split("=");
146
- flags[key] = val.join("=");
153
+ const value = val.join("=");
154
+ if (key === "secret") {
155
+ parseSecret(value, secrets);
156
+ } else {
157
+ flags[key] = value;
158
+ }
147
159
  } else if (arg.startsWith("--")) {
148
160
  const key = arg.slice(2);
149
161
  const next = rest[i + 1];
150
162
  if (next && !next.startsWith("-")) {
151
- flags[key] = next;
163
+ if (key === "secret") {
164
+ parseSecret(next, secrets);
165
+ } else {
166
+ flags[key] = next;
167
+ }
152
168
  i++;
153
169
  } else {
154
170
  flags[key] = "true";
@@ -159,7 +175,7 @@ function parseArgs(argv) {
159
175
  positional.push(arg);
160
176
  }
161
177
  }
162
- return { command, positional, flags };
178
+ return { command, positional, flags, secrets };
163
179
  }
164
180
  function getConfig(parsed) {
165
181
  var _a3, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
@@ -188,6 +204,7 @@ function getConfig(parsed) {
188
204
  privateKey: (_j = parsed.flags["private-key"]) != null ? _j : process.env.PRIVATE_KEY,
189
205
  chainRpcUrl: (_k = parsed.flags["rpc-url"]) != null ? _k : process.env.CHAIN_RPC_URL,
190
206
  chain: parseChainId((_l = parsed.flags["chain"]) != null ? _l : process.env.AOMI_CHAIN_ID),
207
+ secrets: parsed.secrets,
191
208
  execution,
192
209
  aaProvider,
193
210
  aaMode
@@ -238,6 +255,7 @@ function toSessionFilePath(localId) {
238
255
  function toCliSessionState(stored) {
239
256
  return {
240
257
  sessionId: stored.sessionId,
258
+ clientId: stored.clientId,
241
259
  baseUrl: stored.baseUrl,
242
260
  app: stored.app,
243
261
  model: stored.model,
@@ -245,7 +263,8 @@ function toCliSessionState(stored) {
245
263
  publicKey: stored.publicKey,
246
264
  chainId: stored.chainId,
247
265
  pendingTxs: stored.pendingTxs,
248
- signedTxs: stored.signedTxs
266
+ signedTxs: stored.signedTxs,
267
+ secretHandles: stored.secretHandles
249
268
  };
250
269
  }
251
270
  function readStoredSession(path) {
@@ -1822,6 +1841,22 @@ async function applyModelSelection(session, state, model) {
1822
1841
  state.model = model;
1823
1842
  writeState(state);
1824
1843
  }
1844
+ async function ingestSecretsIfPresent(runtime, state, client) {
1845
+ var _a3;
1846
+ const secrets = runtime.config.secrets;
1847
+ if (Object.keys(secrets).length === 0) return {};
1848
+ if (!state.clientId) {
1849
+ state.clientId = crypto.randomUUID();
1850
+ writeState(state);
1851
+ }
1852
+ const response = await client.ingestSecrets(
1853
+ state.clientId,
1854
+ secrets
1855
+ );
1856
+ state.secretHandles = __spreadValues(__spreadValues({}, (_a3 = state.secretHandles) != null ? _a3 : {}), response.handles);
1857
+ writeState(state);
1858
+ return response.handles;
1859
+ }
1825
1860
  async function applyRequestedModelIfPresent(runtime, session, state) {
1826
1861
  const requestedModel = runtime.config.model;
1827
1862
  if (!requestedModel || requestedModel === state.model) {
@@ -2681,6 +2716,70 @@ function closeCommand(runtime) {
2681
2716
  console.log("Session closed");
2682
2717
  }
2683
2718
 
2719
+ // src/cli/commands/secrets.ts
2720
+ async function ingestSecretsCommand(runtime) {
2721
+ const secretEntries = Object.entries(runtime.config.secrets);
2722
+ if (secretEntries.length === 0) {
2723
+ fatal("Usage: aomi --secret NAME=value [NAME=value ...]");
2724
+ }
2725
+ const { session, state } = getOrCreateSession(runtime);
2726
+ try {
2727
+ const handles = await ingestSecretsIfPresent(
2728
+ runtime,
2729
+ state,
2730
+ session.client
2731
+ );
2732
+ const names = Object.keys(handles).sort();
2733
+ console.log(
2734
+ `Configured ${names.length} secret${names.length === 1 ? "" : "s"} for session ${state.sessionId}.`
2735
+ );
2736
+ for (const name of names) {
2737
+ console.log(`${name} ${handles[name]}`);
2738
+ }
2739
+ printDataFileLocation();
2740
+ } finally {
2741
+ session.close();
2742
+ }
2743
+ }
2744
+ async function secretCommand(runtime) {
2745
+ var _a3;
2746
+ const subcommand = runtime.parsed.positional[0];
2747
+ if (!subcommand || subcommand === "list") {
2748
+ const state = readState();
2749
+ if (!state) {
2750
+ console.log("No active session");
2751
+ printDataFileLocation();
2752
+ return;
2753
+ }
2754
+ const secretHandles = (_a3 = state.secretHandles) != null ? _a3 : {};
2755
+ const names = Object.keys(secretHandles).sort();
2756
+ if (names.length === 0) {
2757
+ console.log("No secrets configured.");
2758
+ printDataFileLocation();
2759
+ return;
2760
+ }
2761
+ for (const name of names) {
2762
+ console.log(`${name} ${secretHandles[name]}`);
2763
+ }
2764
+ printDataFileLocation();
2765
+ return;
2766
+ }
2767
+ if (subcommand === "clear") {
2768
+ const { session, state } = getOrCreateSession(runtime);
2769
+ try {
2770
+ await session.client.clearSecrets(state.clientId);
2771
+ state.secretHandles = {};
2772
+ writeState(state);
2773
+ console.log("Cleared all secrets for the active session.");
2774
+ printDataFileLocation();
2775
+ } finally {
2776
+ session.close();
2777
+ }
2778
+ return;
2779
+ }
2780
+ fatal("Usage: aomi secret list\n aomi secret clear");
2781
+ }
2782
+
2684
2783
  // src/cli/commands/sessions.ts
2685
2784
  async function fetchRemoteSessionStats(record) {
2686
2785
  var _a3, _b;
@@ -3729,6 +3828,8 @@ Usage:
3729
3828
  aomi tx List pending and signed transactions
3730
3829
  aomi sign <tx-id> [<tx-id> ...] [--eoa | --aa] [--aa-provider <name>] [--aa-mode <mode>]
3731
3830
  Sign and submit a pending transaction
3831
+ aomi secret list List configured secrets for the active session
3832
+ aomi secret clear Clear all secrets for the active session
3732
3833
  aomi status Show current session state
3733
3834
  aomi events List system events
3734
3835
  aomi close Close the current session
@@ -3742,6 +3843,7 @@ Options:
3742
3843
  --public-key <addr> Wallet address (so the agent knows your wallet)
3743
3844
  --private-key <key> Hex private key for signing
3744
3845
  --rpc-url <url> RPC URL for transaction submission
3846
+ --secret NAME=value Ingest a secret (repeatable, e.g. --secret X_API_KEY=abc)
3745
3847
  --verbose, -v Show tool calls and streaming output (for chat)
3746
3848
  --version, -V Print the installed CLI version
3747
3849
 
@@ -3777,8 +3879,9 @@ Environment (overridden by flags):
3777
3879
  `.trim());
3778
3880
  }
3779
3881
  async function main(runtime) {
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;
3882
+ var _a3, _b, _c;
3883
+ const hasSecrets = Object.keys(runtime.parsed.secrets).length > 0;
3884
+ const command = (_c = (_b = (_a3 = runtime.parsed.command) != null ? _a3 : hasSecrets ? "ingest-secrets" : void 0) != null ? _b : runtime.parsed.flags["version"] || runtime.parsed.flags["V"] ? "version" : void 0) != null ? _c : runtime.parsed.flags["help"] || runtime.parsed.flags["h"] ? "help" : void 0;
3782
3885
  switch (command) {
3783
3886
  case "chat":
3784
3887
  await chatCommand(runtime);
@@ -3810,6 +3913,12 @@ async function main(runtime) {
3810
3913
  case "events":
3811
3914
  await eventsCommand(runtime);
3812
3915
  break;
3916
+ case "secret":
3917
+ await secretCommand(runtime);
3918
+ break;
3919
+ case "ingest-secrets":
3920
+ await ingestSecretsCommand(runtime);
3921
+ break;
3813
3922
  case "close":
3814
3923
  closeCommand(runtime);
3815
3924
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aomi-labs/client",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "Platform-agnostic TypeScript client for the Aomi backend API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",