@aomi-labs/client 0.1.15 → 0.1.17

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
@@ -126,6 +126,7 @@ npx @aomi-labs/client chat "swap 1 ETH" --verbose # stream tool calls + r
126
126
  npx @aomi-labs/client app list # list available apps
127
127
  npx @aomi-labs/client model list # list available models
128
128
  npx @aomi-labs/client model set claude-sonnet-4 # switch the current session model
129
+ npx @aomi-labs/client session new # create a fresh active session
129
130
  npx @aomi-labs/client secret list # list configured secret handles
130
131
  npx @aomi-labs/client --secret ALCHEMY_API_KEY=... # ingest a secret for the active session
131
132
  npx @aomi-labs/client log # show full conversation history
@@ -149,6 +150,31 @@ npx @aomi-labs/client chat "send 0 ETH to myself" \
149
150
  The address is persisted in the state file, so subsequent commands in the same
150
151
  session don't need it again.
151
152
 
153
+ ### Chain selection
154
+
155
+ Use `--chain <id>` for the current command when the task is chain-specific:
156
+
157
+ ```bash
158
+ $ npx @aomi-labs/client chat "swap 1 POL for USDC on Polygon" --chain 137
159
+ ```
160
+
161
+ Use `AOMI_CHAIN_ID` when several consecutive commands should share the same
162
+ chain context.
163
+
164
+ ### Fresh sessions
165
+
166
+ Use `--new-session` when you want a command to start a fresh backend/local
167
+ session instead of reusing the currently active one:
168
+
169
+ ```bash
170
+ $ npx @aomi-labs/client chat "show my balances" --new-session
171
+ $ npx @aomi-labs/client --secret ALCHEMY_API_KEY=... --new-session
172
+ $ npx @aomi-labs/client session new
173
+ ```
174
+
175
+ This is useful when starting a new operator flow or a new external chat thread
176
+ and you do not want stale session state to bleed into the next run.
177
+
152
178
  ### Model selection
153
179
 
154
180
  The CLI can discover and switch backend models for the active session:
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.15",
25
+ version: "0.1.17",
26
26
  description: "Platform-agnostic TypeScript client for the Aomi backend API",
27
27
  type: "module",
28
28
  main: "./dist/index.cjs",
@@ -139,6 +139,12 @@ function parseSecret(value, secrets) {
139
139
  secrets[value.slice(0, eqIdx)] = value.slice(eqIdx + 1);
140
140
  }
141
141
  }
142
+ function normalizePrivateKey(value) {
143
+ if (value === void 0) return void 0;
144
+ const trimmed = value.trim();
145
+ if (!trimmed) return void 0;
146
+ return trimmed.startsWith("0x") ? trimmed : `0x${trimmed}`;
147
+ }
142
148
  function parseArgs(argv) {
143
149
  const raw = argv.slice(2);
144
150
  const command = raw[0] && !raw[0].startsWith("-") ? raw[0] : void 0;
@@ -200,8 +206,11 @@ function getConfig(parsed) {
200
206
  apiKey: (_e = parsed.flags["api-key"]) != null ? _e : process.env.AOMI_API_KEY,
201
207
  app: (_g = (_f = parsed.flags["app"]) != null ? _f : process.env.AOMI_APP) != null ? _g : "default",
202
208
  model: (_h = parsed.flags["model"]) != null ? _h : process.env.AOMI_MODEL,
209
+ freshSession: parsed.flags["new-session"] === "true",
203
210
  publicKey: (_i = parsed.flags["public-key"]) != null ? _i : process.env.AOMI_PUBLIC_KEY,
204
- privateKey: (_j = parsed.flags["private-key"]) != null ? _j : process.env.PRIVATE_KEY,
211
+ privateKey: normalizePrivateKey(
212
+ (_j = parsed.flags["private-key"]) != null ? _j : process.env.PRIVATE_KEY
213
+ ),
205
214
  chainRpcUrl: (_k = parsed.flags["rpc-url"]) != null ? _k : process.env.CHAIN_RPC_URL,
206
215
  chain: parseChainId((_l = parsed.flags["chain"]) != null ? _l : process.env.AOMI_CHAIN_ID),
207
216
  secrets: parsed.secrets,
@@ -278,6 +287,7 @@ function readStoredSession(path) {
278
287
  const fallbackLocalId = (_a3 = parseSessionFileLocalId(basename(path))) != null ? _a3 : 0;
279
288
  return {
280
289
  sessionId: parsed.sessionId,
290
+ clientId: parsed.clientId,
281
291
  baseUrl: parsed.baseUrl,
282
292
  app: parsed.app,
283
293
  model: parsed.model,
@@ -286,6 +296,7 @@ function readStoredSession(path) {
286
296
  chainId: parsed.chainId,
287
297
  pendingTxs: parsed.pendingTxs,
288
298
  signedTxs: parsed.signedTxs,
299
+ secretHandles: parsed.secretHandles,
289
300
  localId: typeof parsed.localId === "number" && parsed.localId > 0 ? parsed.localId : fallbackLocalId,
290
301
  createdAt: typeof parsed.createdAt === "number" && parsed.createdAt > 0 ? parsed.createdAt : Date.now(),
291
302
  updatedAt: typeof parsed.updatedAt === "number" && parsed.updatedAt > 0 ? parsed.updatedAt : Date.now()
@@ -1148,6 +1159,30 @@ var AomiClient = class {
1148
1159
  }
1149
1160
  };
1150
1161
 
1162
+ // src/types.ts
1163
+ var CLIENT_TYPE_TS_CLI = "ts_cli";
1164
+ function addUserStateExt(userState, key, value) {
1165
+ const currentExt = userState["ext"];
1166
+ const extRecord = typeof currentExt === "object" && currentExt !== null && !Array.isArray(currentExt) ? currentExt : {};
1167
+ return __spreadProps(__spreadValues({}, userState), {
1168
+ ext: __spreadProps(__spreadValues({}, extRecord), {
1169
+ [key]: value
1170
+ })
1171
+ });
1172
+ }
1173
+ function isInlineCall(event) {
1174
+ return "InlineCall" in event;
1175
+ }
1176
+ function isSystemNotice(event) {
1177
+ return "SystemNotice" in event;
1178
+ }
1179
+ function isSystemError(event) {
1180
+ return "SystemError" in event;
1181
+ }
1182
+ function isAsyncCallback(event) {
1183
+ return "AsyncCallback" in event;
1184
+ }
1185
+
1151
1186
  // src/event-emitter.ts
1152
1187
  var TypedEventEmitter = class {
1153
1188
  constructor() {
@@ -1220,20 +1255,6 @@ var TypedEventEmitter = class {
1220
1255
  }
1221
1256
  };
1222
1257
 
1223
- // src/types.ts
1224
- function isInlineCall(event) {
1225
- return "InlineCall" in event;
1226
- }
1227
- function isSystemNotice(event) {
1228
- return "SystemNotice" in event;
1229
- }
1230
- function isSystemError(event) {
1231
- return "SystemError" in event;
1232
- }
1233
- function isAsyncCallback(event) {
1234
- return "AsyncCallback" in event;
1235
- }
1236
-
1237
1258
  // src/event-unwrap.ts
1238
1259
  function unwrapSystemEvent(event) {
1239
1260
  var _a3;
@@ -1391,7 +1412,7 @@ function isSubsetMatch(expected, actual) {
1391
1412
  }
1392
1413
  var ClientSession = class extends TypedEventEmitter {
1393
1414
  constructor(clientOrOptions, sessionOptions) {
1394
- var _a3, _b, _c;
1415
+ var _a3, _b, _c, _d, _e;
1395
1416
  super();
1396
1417
  // Internal state
1397
1418
  this.pollTimer = null;
@@ -1408,8 +1429,9 @@ var ClientSession = class extends TypedEventEmitter {
1408
1429
  this.app = (_b = sessionOptions == null ? void 0 : sessionOptions.app) != null ? _b : "default";
1409
1430
  this.publicKey = sessionOptions == null ? void 0 : sessionOptions.publicKey;
1410
1431
  this.apiKey = sessionOptions == null ? void 0 : sessionOptions.apiKey;
1411
- this.userState = sessionOptions == null ? void 0 : sessionOptions.userState;
1412
- this.pollIntervalMs = (_c = sessionOptions == null ? void 0 : sessionOptions.pollIntervalMs) != null ? _c : 500;
1432
+ this.userState = (sessionOptions == null ? void 0 : sessionOptions.clientType) ? addUserStateExt((_c = sessionOptions == null ? void 0 : sessionOptions.userState) != null ? _c : {}, "client_type", sessionOptions.clientType) : sessionOptions == null ? void 0 : sessionOptions.userState;
1433
+ this.clientId = (_d = sessionOptions == null ? void 0 : sessionOptions.clientId) != null ? _d : crypto.randomUUID();
1434
+ this.pollIntervalMs = (_e = sessionOptions == null ? void 0 : sessionOptions.pollIntervalMs) != null ? _e : 500;
1413
1435
  this.logger = sessionOptions == null ? void 0 : sessionOptions.logger;
1414
1436
  this.unsubscribeSSE = this.client.subscribeSSE(
1415
1437
  this.sessionId,
@@ -1434,7 +1456,8 @@ var ClientSession = class extends TypedEventEmitter {
1434
1456
  app: this.app,
1435
1457
  publicKey: this.publicKey,
1436
1458
  apiKey: this.apiKey,
1437
- userState: this.userState
1459
+ userState: this.userState,
1460
+ clientId: this.clientId
1438
1461
  });
1439
1462
  this.assertUserStateAligned(response.user_state);
1440
1463
  this.applyState(response);
@@ -1458,7 +1481,8 @@ var ClientSession = class extends TypedEventEmitter {
1458
1481
  app: this.app,
1459
1482
  publicKey: this.publicKey,
1460
1483
  apiKey: this.apiKey,
1461
- userState: this.userState
1484
+ userState: this.userState,
1485
+ clientId: this.clientId
1462
1486
  });
1463
1487
  this.assertUserStateAligned(response.user_state);
1464
1488
  this.applyState(response);
@@ -1580,6 +1604,10 @@ var ClientSession = class extends TypedEventEmitter {
1580
1604
  this.publicKey = address;
1581
1605
  }
1582
1606
  }
1607
+ setClientType(clientType) {
1608
+ var _a3;
1609
+ this.resolveUserState(addUserStateExt((_a3 = this.userState) != null ? _a3 : {}, "client_type", clientType));
1610
+ }
1583
1611
  addExtValue(key, value) {
1584
1612
  var _a3;
1585
1613
  const current = (_a3 = this.userState) != null ? _a3 : {};
@@ -1609,7 +1637,7 @@ var ClientSession = class extends TypedEventEmitter {
1609
1637
  }
1610
1638
  async syncUserState() {
1611
1639
  this.assertOpen();
1612
- const state = await this.client.fetchState(this.sessionId, this.userState);
1640
+ const state = await this.client.fetchState(this.sessionId, this.userState, this.clientId);
1613
1641
  this.assertUserStateAligned(state.user_state);
1614
1642
  this.applyState(state);
1615
1643
  return state;
@@ -1639,7 +1667,8 @@ var ClientSession = class extends TypedEventEmitter {
1639
1667
  try {
1640
1668
  const state = await this.client.fetchState(
1641
1669
  this.sessionId,
1642
- this.userState
1670
+ this.userState,
1671
+ this.clientId
1643
1672
  );
1644
1673
  if (!this.pollTimer) return;
1645
1674
  this.assertUserStateAligned(state.user_state);
@@ -1760,9 +1789,6 @@ var ClientSession = class extends TypedEventEmitter {
1760
1789
 
1761
1790
  // src/cli/user-state.ts
1762
1791
  function buildCliUserState(publicKey, chainId) {
1763
- if (publicKey === void 0 && chainId === void 0) {
1764
- return void 0;
1765
- }
1766
1792
  const userState = {};
1767
1793
  if (publicKey !== void 0) {
1768
1794
  userState.address = publicKey;
@@ -1771,23 +1797,33 @@ function buildCliUserState(publicKey, chainId) {
1771
1797
  if (chainId !== void 0) {
1772
1798
  userState.chainId = chainId;
1773
1799
  }
1774
- return userState;
1800
+ return addUserStateExt(userState, "client_type", CLIENT_TYPE_TS_CLI);
1775
1801
  }
1776
1802
 
1777
1803
  // src/cli/context.ts
1778
- function getOrCreateSession(runtime) {
1804
+ function buildSessionState(runtime) {
1779
1805
  const { config } = runtime;
1780
- let state = readState();
1806
+ return {
1807
+ sessionId: crypto.randomUUID(),
1808
+ baseUrl: config.baseUrl,
1809
+ app: config.app,
1810
+ model: config.model,
1811
+ apiKey: config.apiKey,
1812
+ publicKey: config.publicKey,
1813
+ chainId: config.chain,
1814
+ clientId: crypto.randomUUID()
1815
+ };
1816
+ }
1817
+ function createFreshSessionState(runtime) {
1818
+ const state = buildSessionState(runtime);
1819
+ writeState(state);
1820
+ return state;
1821
+ }
1822
+ function getOrCreateSession(runtime, options = {}) {
1823
+ const { config } = runtime;
1824
+ let state = options.fresh || config.freshSession ? createFreshSessionState(runtime) : readState();
1781
1825
  if (!state) {
1782
- state = {
1783
- sessionId: crypto.randomUUID(),
1784
- baseUrl: config.baseUrl,
1785
- app: config.app,
1786
- apiKey: config.apiKey,
1787
- publicKey: config.publicKey,
1788
- chainId: config.chain
1789
- };
1790
- writeState(state);
1826
+ state = createFreshSessionState(runtime);
1791
1827
  } else {
1792
1828
  let changed = false;
1793
1829
  if (config.baseUrl !== state.baseUrl) {
@@ -1810,21 +1846,23 @@ function getOrCreateSession(runtime) {
1810
1846
  state.chainId = config.chain;
1811
1847
  changed = true;
1812
1848
  }
1849
+ if (!state.clientId) {
1850
+ state.clientId = crypto.randomUUID();
1851
+ changed = true;
1852
+ }
1813
1853
  if (changed) writeState(state);
1814
1854
  }
1815
1855
  const session = new ClientSession(
1816
1856
  { baseUrl: state.baseUrl, apiKey: state.apiKey },
1817
1857
  {
1818
1858
  sessionId: state.sessionId,
1859
+ clientId: state.clientId,
1819
1860
  app: state.app,
1820
1861
  apiKey: state.apiKey,
1821
1862
  publicKey: state.publicKey
1822
1863
  }
1823
1864
  );
1824
- const userState = buildCliUserState(state.publicKey, state.chainId);
1825
- if (userState) {
1826
- session.resolveUserState(userState);
1827
- }
1865
+ session.resolveUserState(buildCliUserState(state.publicKey, state.chainId));
1828
1866
  return { session, state };
1829
1867
  }
1830
1868
  function createControlClient(runtime) {
@@ -1967,13 +2005,13 @@ async function chatCommand(runtime) {
1967
2005
  fatal("Usage: aomi chat <message>");
1968
2006
  }
1969
2007
  const verbose = runtime.parsed.flags["verbose"] === "true" || runtime.parsed.flags["v"] === "true";
1970
- const { session, state } = getOrCreateSession(runtime);
2008
+ const { session, state } = getOrCreateSession(runtime, {
2009
+ fresh: runtime.config.freshSession
2010
+ });
1971
2011
  try {
2012
+ await ingestSecretsIfPresent(runtime, state, session.client);
1972
2013
  await applyRequestedModelIfPresent(runtime, session, state);
1973
- const userState = buildCliUserState(state.publicKey, state.chainId);
1974
- if (userState) {
1975
- session.resolveUserState(userState);
1976
- }
2014
+ session.resolveUserState(buildCliUserState(state.publicKey, state.chainId));
1977
2015
  const capturedRequests = [];
1978
2016
  let printedAgentCount = 0;
1979
2017
  const seenToolResults = /* @__PURE__ */ new Set();
@@ -2360,7 +2398,7 @@ async function statusCommand(runtime) {
2360
2398
  }
2361
2399
  const { session, state } = getOrCreateSession(runtime);
2362
2400
  try {
2363
- const apiState = await session.client.fetchState(state.sessionId);
2401
+ const apiState = await session.client.fetchState(state.sessionId, void 0, state.clientId);
2364
2402
  console.log(
2365
2403
  JSON.stringify(
2366
2404
  {
@@ -2640,7 +2678,7 @@ async function logCommand(runtime) {
2640
2678
  }
2641
2679
  const { session, state } = getOrCreateSession(runtime);
2642
2680
  try {
2643
- const apiState = await session.client.fetchState(state.sessionId);
2681
+ const apiState = await session.client.fetchState(state.sessionId, void 0, state.clientId);
2644
2682
  const messages = (_a3 = apiState.messages) != null ? _a3 : [];
2645
2683
  const pendingTxs = (_b = state.pendingTxs) != null ? _b : [];
2646
2684
  const signedTxs = (_c = state.signedTxs) != null ? _c : [];
@@ -2722,7 +2760,9 @@ async function ingestSecretsCommand(runtime) {
2722
2760
  if (secretEntries.length === 0) {
2723
2761
  fatal("Usage: aomi --secret NAME=value [NAME=value ...]");
2724
2762
  }
2725
- const { session, state } = getOrCreateSession(runtime);
2763
+ const { session, state } = getOrCreateSession(runtime, {
2764
+ fresh: runtime.config.freshSession
2765
+ });
2726
2766
  try {
2727
2767
  const handles = await ingestSecretsIfPresent(
2728
2768
  runtime,
@@ -2767,6 +2807,11 @@ async function secretCommand(runtime) {
2767
2807
  if (subcommand === "clear") {
2768
2808
  const { session, state } = getOrCreateSession(runtime);
2769
2809
  try {
2810
+ if (!state.clientId) {
2811
+ console.log("No secrets configured.");
2812
+ printDataFileLocation();
2813
+ return;
2814
+ }
2770
2815
  await session.client.clearSecrets(state.clientId);
2771
2816
  state.secretHandles = {};
2772
2817
  writeState(state);
@@ -2788,7 +2833,7 @@ async function fetchRemoteSessionStats(record) {
2788
2833
  apiKey: record.state.apiKey
2789
2834
  });
2790
2835
  try {
2791
- const apiState = await client.fetchState(record.sessionId);
2836
+ const apiState = await client.fetchState(record.sessionId, void 0, record.state.clientId);
2792
2837
  const messages = (_a3 = apiState.messages) != null ? _a3 : [];
2793
2838
  return {
2794
2839
  topic: (_b = apiState.title) != null ? _b : "Untitled Session",
@@ -2850,6 +2895,12 @@ async function sessionsCommand(_runtime) {
2850
2895
  async function sessionCommand(runtime) {
2851
2896
  const subcommand = runtime.parsed.positional[0];
2852
2897
  const selector = runtime.parsed.positional[1];
2898
+ if (subcommand === "new") {
2899
+ const state = createFreshSessionState(runtime);
2900
+ console.log(`Active session set to ${state.sessionId} (new).`);
2901
+ printDataFileLocation();
2902
+ return;
2903
+ }
2853
2904
  if (subcommand === "resume") {
2854
2905
  if (!selector) {
2855
2906
  fatal("Usage: aomi session resume <session-id|session-N|N>");
@@ -2885,7 +2936,7 @@ async function sessionCommand(runtime) {
2885
2936
  return;
2886
2937
  }
2887
2938
  fatal(
2888
- "Usage: aomi session list\n aomi session resume <session-id|session-N|N>\n aomi session delete <session-id|session-N|N>"
2939
+ "Usage: aomi session list\n aomi session new\n aomi session resume <session-id|session-N|N>\n aomi session delete <session-id|session-N|N>"
2889
2940
  );
2890
2941
  }
2891
2942
 
@@ -3490,10 +3541,7 @@ function createSessionFromState(state) {
3490
3541
  publicKey: state.publicKey
3491
3542
  }
3492
3543
  );
3493
- const userState = buildCliUserState(state.publicKey, state.chainId);
3494
- if (userState) {
3495
- session.resolveUserState(userState);
3496
- }
3544
+ session.resolveUserState(buildCliUserState(state.publicKey, state.chainId));
3497
3545
  return session;
3498
3546
  }
3499
3547
  async function persistResolvedSignerState(session, state, address, chainId) {
@@ -3820,6 +3868,7 @@ Usage:
3820
3868
  aomi model set <rig> Set the active model for the current session
3821
3869
  aomi chain list List supported chains
3822
3870
  aomi session list List local sessions with metadata
3871
+ aomi session new Start a fresh local/backend session and make it active
3823
3872
  aomi session resume <id>
3824
3873
  Resume a local session (session-id or session-N)
3825
3874
  aomi session delete <id>
@@ -3840,6 +3889,8 @@ Options:
3840
3889
  --api-key <key> API key for non-default apps
3841
3890
  --app <name> App (default: "default")
3842
3891
  --model <rig> Set the active model for this session
3892
+ --new-session Create a fresh active session for this command
3893
+ --chain <id> Active chain for chat/session context
3843
3894
  --public-key <addr> Wallet address (so the agent knows your wallet)
3844
3895
  --private-key <key> Hex private key for signing
3845
3896
  --rpc-url <url> RPC URL for transaction submission
@@ -3867,6 +3918,7 @@ Environment (overridden by flags):
3867
3918
  AOMI_API_KEY API key
3868
3919
  AOMI_APP App
3869
3920
  AOMI_MODEL Model rig
3921
+ AOMI_CHAIN_ID Active chain for chat/session context
3870
3922
  AOMI_PUBLIC_KEY Wallet address
3871
3923
  AOMI_AA_PROVIDER AA provider: alchemy | pimlico
3872
3924
  AOMI_AA_MODE AA mode: 4337 | 7702
package/dist/index.cjs CHANGED
@@ -48,10 +48,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
48
48
  var index_exports = {};
49
49
  __export(index_exports, {
50
50
  AomiClient: () => AomiClient,
51
+ CLIENT_TYPE_TS_CLI: () => CLIENT_TYPE_TS_CLI,
52
+ CLIENT_TYPE_WEB_UI: () => CLIENT_TYPE_WEB_UI,
51
53
  DEFAULT_AA_CONFIG: () => DEFAULT_AA_CONFIG,
52
54
  Session: () => ClientSession,
53
55
  TypedEventEmitter: () => TypedEventEmitter,
54
56
  adaptSmartAccount: () => adaptSmartAccount,
57
+ addUserStateExt: () => addUserStateExt,
55
58
  buildAAExecutionPlan: () => buildAAExecutionPlan,
56
59
  createAAProviderState: () => createAAProviderState,
57
60
  createAlchemyAAProvider: () => createAlchemyAAProvider,
@@ -615,6 +618,17 @@ var AomiClient = class {
615
618
  };
616
619
 
617
620
  // src/types.ts
621
+ var CLIENT_TYPE_TS_CLI = "ts_cli";
622
+ var CLIENT_TYPE_WEB_UI = "web_ui";
623
+ function addUserStateExt(userState, key, value) {
624
+ const currentExt = userState["ext"];
625
+ const extRecord = typeof currentExt === "object" && currentExt !== null && !Array.isArray(currentExt) ? currentExt : {};
626
+ return __spreadProps(__spreadValues({}, userState), {
627
+ ext: __spreadProps(__spreadValues({}, extRecord), {
628
+ [key]: value
629
+ })
630
+ });
631
+ }
618
632
  function isInlineCall(event) {
619
633
  return "InlineCall" in event;
620
634
  }
@@ -857,7 +871,7 @@ function isSubsetMatch(expected, actual) {
857
871
  }
858
872
  var ClientSession = class extends TypedEventEmitter {
859
873
  constructor(clientOrOptions, sessionOptions) {
860
- var _a, _b, _c;
874
+ var _a, _b, _c, _d, _e;
861
875
  super();
862
876
  // Internal state
863
877
  this.pollTimer = null;
@@ -874,8 +888,9 @@ var ClientSession = class extends TypedEventEmitter {
874
888
  this.app = (_b = sessionOptions == null ? void 0 : sessionOptions.app) != null ? _b : "default";
875
889
  this.publicKey = sessionOptions == null ? void 0 : sessionOptions.publicKey;
876
890
  this.apiKey = sessionOptions == null ? void 0 : sessionOptions.apiKey;
877
- this.userState = sessionOptions == null ? void 0 : sessionOptions.userState;
878
- this.pollIntervalMs = (_c = sessionOptions == null ? void 0 : sessionOptions.pollIntervalMs) != null ? _c : 500;
891
+ this.userState = (sessionOptions == null ? void 0 : sessionOptions.clientType) ? addUserStateExt((_c = sessionOptions == null ? void 0 : sessionOptions.userState) != null ? _c : {}, "client_type", sessionOptions.clientType) : sessionOptions == null ? void 0 : sessionOptions.userState;
892
+ this.clientId = (_d = sessionOptions == null ? void 0 : sessionOptions.clientId) != null ? _d : crypto.randomUUID();
893
+ this.pollIntervalMs = (_e = sessionOptions == null ? void 0 : sessionOptions.pollIntervalMs) != null ? _e : 500;
879
894
  this.logger = sessionOptions == null ? void 0 : sessionOptions.logger;
880
895
  this.unsubscribeSSE = this.client.subscribeSSE(
881
896
  this.sessionId,
@@ -900,7 +915,8 @@ var ClientSession = class extends TypedEventEmitter {
900
915
  app: this.app,
901
916
  publicKey: this.publicKey,
902
917
  apiKey: this.apiKey,
903
- userState: this.userState
918
+ userState: this.userState,
919
+ clientId: this.clientId
904
920
  });
905
921
  this.assertUserStateAligned(response.user_state);
906
922
  this.applyState(response);
@@ -924,7 +940,8 @@ var ClientSession = class extends TypedEventEmitter {
924
940
  app: this.app,
925
941
  publicKey: this.publicKey,
926
942
  apiKey: this.apiKey,
927
- userState: this.userState
943
+ userState: this.userState,
944
+ clientId: this.clientId
928
945
  });
929
946
  this.assertUserStateAligned(response.user_state);
930
947
  this.applyState(response);
@@ -1046,6 +1063,10 @@ var ClientSession = class extends TypedEventEmitter {
1046
1063
  this.publicKey = address;
1047
1064
  }
1048
1065
  }
1066
+ setClientType(clientType) {
1067
+ var _a;
1068
+ this.resolveUserState(addUserStateExt((_a = this.userState) != null ? _a : {}, "client_type", clientType));
1069
+ }
1049
1070
  addExtValue(key, value) {
1050
1071
  var _a;
1051
1072
  const current = (_a = this.userState) != null ? _a : {};
@@ -1075,7 +1096,7 @@ var ClientSession = class extends TypedEventEmitter {
1075
1096
  }
1076
1097
  async syncUserState() {
1077
1098
  this.assertOpen();
1078
- const state = await this.client.fetchState(this.sessionId, this.userState);
1099
+ const state = await this.client.fetchState(this.sessionId, this.userState, this.clientId);
1079
1100
  this.assertUserStateAligned(state.user_state);
1080
1101
  this.applyState(state);
1081
1102
  return state;
@@ -1105,7 +1126,8 @@ var ClientSession = class extends TypedEventEmitter {
1105
1126
  try {
1106
1127
  const state = await this.client.fetchState(
1107
1128
  this.sessionId,
1108
- this.userState
1129
+ this.userState,
1130
+ this.clientId
1109
1131
  );
1110
1132
  if (!this.pollTimer) return;
1111
1133
  this.assertUserStateAligned(state.user_state);
@@ -2029,10 +2051,13 @@ async function createPimlicoAAState(options) {
2029
2051
  // Annotate the CommonJS export names for ESM import in node:
2030
2052
  0 && (module.exports = {
2031
2053
  AomiClient,
2054
+ CLIENT_TYPE_TS_CLI,
2055
+ CLIENT_TYPE_WEB_UI,
2032
2056
  DEFAULT_AA_CONFIG,
2033
2057
  Session,
2034
2058
  TypedEventEmitter,
2035
2059
  adaptSmartAccount,
2060
+ addUserStateExt,
2036
2061
  buildAAExecutionPlan,
2037
2062
  createAAProviderState,
2038
2063
  createAlchemyAAProvider,