@aomi-labs/client 0.1.15 → 0.1.16
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/dist/cli.js +62 -42
- package/dist/index.cjs +32 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +29 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -5,6 +5,17 @@ import { Chain, Hex, TransactionReceipt } from 'viem';
|
|
|
5
5
|
* Typically wallet connection info, but can be any key-value data.
|
|
6
6
|
*/
|
|
7
7
|
type UserState = Record<string, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Known client surfaces that may want backend-specific UX strategies.
|
|
10
|
+
* Additional string values are allowed for forward compatibility.
|
|
11
|
+
*/
|
|
12
|
+
type AomiClientType = "ts_cli" | "web_ui" | (string & {});
|
|
13
|
+
declare const CLIENT_TYPE_TS_CLI: AomiClientType;
|
|
14
|
+
declare const CLIENT_TYPE_WEB_UI: AomiClientType;
|
|
15
|
+
/**
|
|
16
|
+
* Adds/updates an entry on `userState.ext` while keeping `ext` intentionally untyped.
|
|
17
|
+
*/
|
|
18
|
+
declare function addUserStateExt(userState: UserState, key: string, value: unknown): UserState;
|
|
8
19
|
/**
|
|
9
20
|
* Optional logger for debug output. Pass `console` or any compatible object.
|
|
10
21
|
*/
|
|
@@ -347,6 +358,10 @@ type SessionOptions = {
|
|
|
347
358
|
apiKey?: string;
|
|
348
359
|
/** User state to send with requests (wallet connection info, etc). */
|
|
349
360
|
userState?: UserState;
|
|
361
|
+
/** Optional client type hint forwarded to the backend via userState.ext.client_type. */
|
|
362
|
+
clientType?: AomiClientType;
|
|
363
|
+
/** Stable client ID used for secret-vault association. */
|
|
364
|
+
clientId?: string;
|
|
350
365
|
/** Polling interval in ms. Default: 500 */
|
|
351
366
|
pollIntervalMs?: number;
|
|
352
367
|
/** Logger for debug output. Pass `console` for verbose logging. */
|
|
@@ -403,6 +418,7 @@ declare class ClientSession extends TypedEventEmitter<SessionEventMap> {
|
|
|
403
418
|
private publicKey?;
|
|
404
419
|
private apiKey?;
|
|
405
420
|
private userState?;
|
|
421
|
+
private clientId;
|
|
406
422
|
private pollIntervalMs;
|
|
407
423
|
private logger?;
|
|
408
424
|
private pollTimer;
|
|
@@ -457,6 +473,7 @@ declare class ClientSession extends TypedEventEmitter<SessionEventMap> {
|
|
|
457
473
|
/** Whether the AI is currently processing. */
|
|
458
474
|
getIsProcessing(): boolean;
|
|
459
475
|
resolveUserState(userState: UserState): void;
|
|
476
|
+
setClientType(clientType: AomiClientType): void;
|
|
460
477
|
addExtValue(key: string, value: unknown): void;
|
|
461
478
|
removeExtValue(key: string): void;
|
|
462
479
|
resolveWallet(address: string, chainId?: number): void;
|
|
@@ -757,4 +774,4 @@ interface CreateAAProviderStateOptions {
|
|
|
757
774
|
*/
|
|
758
775
|
declare function createAAProviderState(options: CreateAAProviderStateOptions): Promise<AAProviderState>;
|
|
759
776
|
|
|
760
|
-
export { type AAChainConfig, type AAConfig, type AAExecutionMode, type AAExecutionPlan, type AALike, type AAProvider, type AAProviderQuery, type AAProviderState, type AASponsorshipMode, type AlchemyHookParams, type AlchemyResolveOptions, type AlchemyResolvedConfig, type AomiChatResponse, type AomiClearSecretsResponse, AomiClient, type AomiClientOptions, type AomiCreateThreadResponse, type AomiIngestSecretsResponse, type AomiInterruptResponse, type AomiMessage, type AomiSSEEvent, type AomiSSEEventType, type AomiStateResponse, type AomiSystemEvent, type AomiSystemResponse, type AomiThread, type CreateAAOwner, type CreateAAProviderStateOptions, type CreateAlchemyAAProviderOptions, type CreatePimlicoAAProviderOptions, DEFAULT_AA_CONFIG, type ExecuteWalletCallsParams, type Logger, type ParaSmartAccountLike, type PimlicoHookParams, type PimlicoResolveOptions, type PimlicoResolvedConfig, type SendCallsSyncArgs, type SendResult, ClientSession as Session, type SessionEventMap, type SessionOptions, type TransactionExecutionResult, TypedEventEmitter, type UnwrappedEvent, type UseAlchemyAAHook, type UsePimlicoAAHook, type UserState, type ViemSignTypedDataArgs, type WalletAtomicCapability, type WalletEip712Payload, type WalletExecutionCall, type WalletPrimitiveCall, type WalletRequest, type WalletRequestKind, type WalletRequestResult, type WalletTxPayload, adaptSmartAccount, buildAAExecutionPlan, createAAProviderState, createAlchemyAAProvider, createPimlicoAAProvider, executeWalletCalls, getAAChainConfig, getWalletExecutorReady, isAlchemySponsorshipLimitError, isAsyncCallback, isInlineCall, isProviderConfigured, isSystemError, isSystemNotice, normalizeEip712Payload, normalizeTxPayload, parseAAConfig, readEnv, resolveAlchemyConfig, resolveDefaultProvider, resolvePimlicoConfig, toViemSignTypedDataArgs, unwrapSystemEvent };
|
|
777
|
+
export { type AAChainConfig, type AAConfig, type AAExecutionMode, type AAExecutionPlan, type AALike, type AAProvider, type AAProviderQuery, type AAProviderState, type AASponsorshipMode, type AlchemyHookParams, type AlchemyResolveOptions, type AlchemyResolvedConfig, type AomiChatResponse, type AomiClearSecretsResponse, AomiClient, type AomiClientOptions, type AomiClientType, type AomiCreateThreadResponse, type AomiIngestSecretsResponse, type AomiInterruptResponse, type AomiMessage, type AomiSSEEvent, type AomiSSEEventType, type AomiStateResponse, type AomiSystemEvent, type AomiSystemResponse, type AomiThread, CLIENT_TYPE_TS_CLI, CLIENT_TYPE_WEB_UI, type CreateAAOwner, type CreateAAProviderStateOptions, type CreateAlchemyAAProviderOptions, type CreatePimlicoAAProviderOptions, DEFAULT_AA_CONFIG, type ExecuteWalletCallsParams, type Logger, type ParaSmartAccountLike, type PimlicoHookParams, type PimlicoResolveOptions, type PimlicoResolvedConfig, type SendCallsSyncArgs, type SendResult, ClientSession as Session, type SessionEventMap, type SessionOptions, type TransactionExecutionResult, TypedEventEmitter, type UnwrappedEvent, type UseAlchemyAAHook, type UsePimlicoAAHook, type UserState, type ViemSignTypedDataArgs, type WalletAtomicCapability, type WalletEip712Payload, type WalletExecutionCall, type WalletPrimitiveCall, type WalletRequest, type WalletRequestKind, type WalletRequestResult, type WalletTxPayload, adaptSmartAccount, addUserStateExt, buildAAExecutionPlan, createAAProviderState, createAlchemyAAProvider, createPimlicoAAProvider, executeWalletCalls, getAAChainConfig, getWalletExecutorReady, isAlchemySponsorshipLimitError, isAsyncCallback, isInlineCall, isProviderConfigured, isSystemError, isSystemNotice, normalizeEip712Payload, normalizeTxPayload, parseAAConfig, readEnv, resolveAlchemyConfig, resolveDefaultProvider, resolvePimlicoConfig, toViemSignTypedDataArgs, unwrapSystemEvent };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,17 @@ import { Chain, Hex, TransactionReceipt } from 'viem';
|
|
|
5
5
|
* Typically wallet connection info, but can be any key-value data.
|
|
6
6
|
*/
|
|
7
7
|
type UserState = Record<string, unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* Known client surfaces that may want backend-specific UX strategies.
|
|
10
|
+
* Additional string values are allowed for forward compatibility.
|
|
11
|
+
*/
|
|
12
|
+
type AomiClientType = "ts_cli" | "web_ui" | (string & {});
|
|
13
|
+
declare const CLIENT_TYPE_TS_CLI: AomiClientType;
|
|
14
|
+
declare const CLIENT_TYPE_WEB_UI: AomiClientType;
|
|
15
|
+
/**
|
|
16
|
+
* Adds/updates an entry on `userState.ext` while keeping `ext` intentionally untyped.
|
|
17
|
+
*/
|
|
18
|
+
declare function addUserStateExt(userState: UserState, key: string, value: unknown): UserState;
|
|
8
19
|
/**
|
|
9
20
|
* Optional logger for debug output. Pass `console` or any compatible object.
|
|
10
21
|
*/
|
|
@@ -347,6 +358,10 @@ type SessionOptions = {
|
|
|
347
358
|
apiKey?: string;
|
|
348
359
|
/** User state to send with requests (wallet connection info, etc). */
|
|
349
360
|
userState?: UserState;
|
|
361
|
+
/** Optional client type hint forwarded to the backend via userState.ext.client_type. */
|
|
362
|
+
clientType?: AomiClientType;
|
|
363
|
+
/** Stable client ID used for secret-vault association. */
|
|
364
|
+
clientId?: string;
|
|
350
365
|
/** Polling interval in ms. Default: 500 */
|
|
351
366
|
pollIntervalMs?: number;
|
|
352
367
|
/** Logger for debug output. Pass `console` for verbose logging. */
|
|
@@ -403,6 +418,7 @@ declare class ClientSession extends TypedEventEmitter<SessionEventMap> {
|
|
|
403
418
|
private publicKey?;
|
|
404
419
|
private apiKey?;
|
|
405
420
|
private userState?;
|
|
421
|
+
private clientId;
|
|
406
422
|
private pollIntervalMs;
|
|
407
423
|
private logger?;
|
|
408
424
|
private pollTimer;
|
|
@@ -457,6 +473,7 @@ declare class ClientSession extends TypedEventEmitter<SessionEventMap> {
|
|
|
457
473
|
/** Whether the AI is currently processing. */
|
|
458
474
|
getIsProcessing(): boolean;
|
|
459
475
|
resolveUserState(userState: UserState): void;
|
|
476
|
+
setClientType(clientType: AomiClientType): void;
|
|
460
477
|
addExtValue(key: string, value: unknown): void;
|
|
461
478
|
removeExtValue(key: string): void;
|
|
462
479
|
resolveWallet(address: string, chainId?: number): void;
|
|
@@ -757,4 +774,4 @@ interface CreateAAProviderStateOptions {
|
|
|
757
774
|
*/
|
|
758
775
|
declare function createAAProviderState(options: CreateAAProviderStateOptions): Promise<AAProviderState>;
|
|
759
776
|
|
|
760
|
-
export { type AAChainConfig, type AAConfig, type AAExecutionMode, type AAExecutionPlan, type AALike, type AAProvider, type AAProviderQuery, type AAProviderState, type AASponsorshipMode, type AlchemyHookParams, type AlchemyResolveOptions, type AlchemyResolvedConfig, type AomiChatResponse, type AomiClearSecretsResponse, AomiClient, type AomiClientOptions, type AomiCreateThreadResponse, type AomiIngestSecretsResponse, type AomiInterruptResponse, type AomiMessage, type AomiSSEEvent, type AomiSSEEventType, type AomiStateResponse, type AomiSystemEvent, type AomiSystemResponse, type AomiThread, type CreateAAOwner, type CreateAAProviderStateOptions, type CreateAlchemyAAProviderOptions, type CreatePimlicoAAProviderOptions, DEFAULT_AA_CONFIG, type ExecuteWalletCallsParams, type Logger, type ParaSmartAccountLike, type PimlicoHookParams, type PimlicoResolveOptions, type PimlicoResolvedConfig, type SendCallsSyncArgs, type SendResult, ClientSession as Session, type SessionEventMap, type SessionOptions, type TransactionExecutionResult, TypedEventEmitter, type UnwrappedEvent, type UseAlchemyAAHook, type UsePimlicoAAHook, type UserState, type ViemSignTypedDataArgs, type WalletAtomicCapability, type WalletEip712Payload, type WalletExecutionCall, type WalletPrimitiveCall, type WalletRequest, type WalletRequestKind, type WalletRequestResult, type WalletTxPayload, adaptSmartAccount, buildAAExecutionPlan, createAAProviderState, createAlchemyAAProvider, createPimlicoAAProvider, executeWalletCalls, getAAChainConfig, getWalletExecutorReady, isAlchemySponsorshipLimitError, isAsyncCallback, isInlineCall, isProviderConfigured, isSystemError, isSystemNotice, normalizeEip712Payload, normalizeTxPayload, parseAAConfig, readEnv, resolveAlchemyConfig, resolveDefaultProvider, resolvePimlicoConfig, toViemSignTypedDataArgs, unwrapSystemEvent };
|
|
777
|
+
export { type AAChainConfig, type AAConfig, type AAExecutionMode, type AAExecutionPlan, type AALike, type AAProvider, type AAProviderQuery, type AAProviderState, type AASponsorshipMode, type AlchemyHookParams, type AlchemyResolveOptions, type AlchemyResolvedConfig, type AomiChatResponse, type AomiClearSecretsResponse, AomiClient, type AomiClientOptions, type AomiClientType, type AomiCreateThreadResponse, type AomiIngestSecretsResponse, type AomiInterruptResponse, type AomiMessage, type AomiSSEEvent, type AomiSSEEventType, type AomiStateResponse, type AomiSystemEvent, type AomiSystemResponse, type AomiThread, CLIENT_TYPE_TS_CLI, CLIENT_TYPE_WEB_UI, type CreateAAOwner, type CreateAAProviderStateOptions, type CreateAlchemyAAProviderOptions, type CreatePimlicoAAProviderOptions, DEFAULT_AA_CONFIG, type ExecuteWalletCallsParams, type Logger, type ParaSmartAccountLike, type PimlicoHookParams, type PimlicoResolveOptions, type PimlicoResolvedConfig, type SendCallsSyncArgs, type SendResult, ClientSession as Session, type SessionEventMap, type SessionOptions, type TransactionExecutionResult, TypedEventEmitter, type UnwrappedEvent, type UseAlchemyAAHook, type UsePimlicoAAHook, type UserState, type ViemSignTypedDataArgs, type WalletAtomicCapability, type WalletEip712Payload, type WalletExecutionCall, type WalletPrimitiveCall, type WalletRequest, type WalletRequestKind, type WalletRequestResult, type WalletTxPayload, adaptSmartAccount, addUserStateExt, buildAAExecutionPlan, createAAProviderState, createAlchemyAAProvider, createPimlicoAAProvider, executeWalletCalls, getAAChainConfig, getWalletExecutorReady, isAlchemySponsorshipLimitError, isAsyncCallback, isInlineCall, isProviderConfigured, isSystemError, isSystemNotice, normalizeEip712Payload, normalizeTxPayload, parseAAConfig, readEnv, resolveAlchemyConfig, resolveDefaultProvider, resolvePimlicoConfig, toViemSignTypedDataArgs, unwrapSystemEvent };
|
package/dist/index.js
CHANGED
|
@@ -556,6 +556,17 @@ var AomiClient = class {
|
|
|
556
556
|
};
|
|
557
557
|
|
|
558
558
|
// src/types.ts
|
|
559
|
+
var CLIENT_TYPE_TS_CLI = "ts_cli";
|
|
560
|
+
var CLIENT_TYPE_WEB_UI = "web_ui";
|
|
561
|
+
function addUserStateExt(userState, key, value) {
|
|
562
|
+
const currentExt = userState["ext"];
|
|
563
|
+
const extRecord = typeof currentExt === "object" && currentExt !== null && !Array.isArray(currentExt) ? currentExt : {};
|
|
564
|
+
return __spreadProps(__spreadValues({}, userState), {
|
|
565
|
+
ext: __spreadProps(__spreadValues({}, extRecord), {
|
|
566
|
+
[key]: value
|
|
567
|
+
})
|
|
568
|
+
});
|
|
569
|
+
}
|
|
559
570
|
function isInlineCall(event) {
|
|
560
571
|
return "InlineCall" in event;
|
|
561
572
|
}
|
|
@@ -798,7 +809,7 @@ function isSubsetMatch(expected, actual) {
|
|
|
798
809
|
}
|
|
799
810
|
var ClientSession = class extends TypedEventEmitter {
|
|
800
811
|
constructor(clientOrOptions, sessionOptions) {
|
|
801
|
-
var _a, _b, _c;
|
|
812
|
+
var _a, _b, _c, _d, _e;
|
|
802
813
|
super();
|
|
803
814
|
// Internal state
|
|
804
815
|
this.pollTimer = null;
|
|
@@ -815,8 +826,9 @@ var ClientSession = class extends TypedEventEmitter {
|
|
|
815
826
|
this.app = (_b = sessionOptions == null ? void 0 : sessionOptions.app) != null ? _b : "default";
|
|
816
827
|
this.publicKey = sessionOptions == null ? void 0 : sessionOptions.publicKey;
|
|
817
828
|
this.apiKey = sessionOptions == null ? void 0 : sessionOptions.apiKey;
|
|
818
|
-
this.userState = sessionOptions == null ? void 0 : sessionOptions.userState;
|
|
819
|
-
this.
|
|
829
|
+
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;
|
|
830
|
+
this.clientId = (_d = sessionOptions == null ? void 0 : sessionOptions.clientId) != null ? _d : crypto.randomUUID();
|
|
831
|
+
this.pollIntervalMs = (_e = sessionOptions == null ? void 0 : sessionOptions.pollIntervalMs) != null ? _e : 500;
|
|
820
832
|
this.logger = sessionOptions == null ? void 0 : sessionOptions.logger;
|
|
821
833
|
this.unsubscribeSSE = this.client.subscribeSSE(
|
|
822
834
|
this.sessionId,
|
|
@@ -841,7 +853,8 @@ var ClientSession = class extends TypedEventEmitter {
|
|
|
841
853
|
app: this.app,
|
|
842
854
|
publicKey: this.publicKey,
|
|
843
855
|
apiKey: this.apiKey,
|
|
844
|
-
userState: this.userState
|
|
856
|
+
userState: this.userState,
|
|
857
|
+
clientId: this.clientId
|
|
845
858
|
});
|
|
846
859
|
this.assertUserStateAligned(response.user_state);
|
|
847
860
|
this.applyState(response);
|
|
@@ -865,7 +878,8 @@ var ClientSession = class extends TypedEventEmitter {
|
|
|
865
878
|
app: this.app,
|
|
866
879
|
publicKey: this.publicKey,
|
|
867
880
|
apiKey: this.apiKey,
|
|
868
|
-
userState: this.userState
|
|
881
|
+
userState: this.userState,
|
|
882
|
+
clientId: this.clientId
|
|
869
883
|
});
|
|
870
884
|
this.assertUserStateAligned(response.user_state);
|
|
871
885
|
this.applyState(response);
|
|
@@ -987,6 +1001,10 @@ var ClientSession = class extends TypedEventEmitter {
|
|
|
987
1001
|
this.publicKey = address;
|
|
988
1002
|
}
|
|
989
1003
|
}
|
|
1004
|
+
setClientType(clientType) {
|
|
1005
|
+
var _a;
|
|
1006
|
+
this.resolveUserState(addUserStateExt((_a = this.userState) != null ? _a : {}, "client_type", clientType));
|
|
1007
|
+
}
|
|
990
1008
|
addExtValue(key, value) {
|
|
991
1009
|
var _a;
|
|
992
1010
|
const current = (_a = this.userState) != null ? _a : {};
|
|
@@ -1016,7 +1034,7 @@ var ClientSession = class extends TypedEventEmitter {
|
|
|
1016
1034
|
}
|
|
1017
1035
|
async syncUserState() {
|
|
1018
1036
|
this.assertOpen();
|
|
1019
|
-
const state = await this.client.fetchState(this.sessionId, this.userState);
|
|
1037
|
+
const state = await this.client.fetchState(this.sessionId, this.userState, this.clientId);
|
|
1020
1038
|
this.assertUserStateAligned(state.user_state);
|
|
1021
1039
|
this.applyState(state);
|
|
1022
1040
|
return state;
|
|
@@ -1046,7 +1064,8 @@ var ClientSession = class extends TypedEventEmitter {
|
|
|
1046
1064
|
try {
|
|
1047
1065
|
const state = await this.client.fetchState(
|
|
1048
1066
|
this.sessionId,
|
|
1049
|
-
this.userState
|
|
1067
|
+
this.userState,
|
|
1068
|
+
this.clientId
|
|
1050
1069
|
);
|
|
1051
1070
|
if (!this.pollTimer) return;
|
|
1052
1071
|
this.assertUserStateAligned(state.user_state);
|
|
@@ -1969,10 +1988,13 @@ async function createPimlicoAAState(options) {
|
|
|
1969
1988
|
}
|
|
1970
1989
|
export {
|
|
1971
1990
|
AomiClient,
|
|
1991
|
+
CLIENT_TYPE_TS_CLI,
|
|
1992
|
+
CLIENT_TYPE_WEB_UI,
|
|
1972
1993
|
DEFAULT_AA_CONFIG,
|
|
1973
1994
|
ClientSession as Session,
|
|
1974
1995
|
TypedEventEmitter,
|
|
1975
1996
|
adaptSmartAccount,
|
|
1997
|
+
addUserStateExt,
|
|
1976
1998
|
buildAAExecutionPlan,
|
|
1977
1999
|
createAAProviderState,
|
|
1978
2000
|
createAlchemyAAProvider,
|