@aomi-labs/react 0.3.16 → 0.3.18
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/index.cjs +475 -88
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -7
- package/dist/index.d.ts +22 -7
- package/dist/index.js +480 -92
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AomiClient, SessionOptions, Session, UserState, WalletRequest, WalletRequestResult, AomiSimulateResponse } from '@aomi-labs/client';
|
|
2
|
-
export { AomiChatResponse, AomiClient, AomiClientOptions, AomiCreateThreadResponse, AomiInterruptResponse, AomiMessage, AomiSSEEvent, AomiStateResponse, AomiSystemEvent, AomiSystemResponse, AomiThread, DISABLED_PROVIDER_STATE, MAX_AUTO_FEE_WEI, NativeWalletExecutionPolicy, NativeWalletSponsorship, SponsorshipPaymasterServiceContext, UserState, WalletCapabilities, WalletEip712Payload, WalletRequest, WalletRequestResult, WalletTxPayload, aaModeFromExecutionKind, appendFeeCallToPayload, buildFeeAAWalletCall, executeWalletCalls, hydrateTxPayloadFromUserState, normalizeSimulatedFee, parseChainId, toAAWalletCall, toAAWalletCalls, toViemSignTypedDataArgs } from '@aomi-labs/client';
|
|
1
|
+
import { AomiClientOptions, AomiClient, SessionOptions, Session, UserState, WalletRequest, WalletRequestResult, AomiSimulateResponse } from '@aomi-labs/client';
|
|
2
|
+
export { AomiChatResponse, AomiClient, AomiClientOptions, AomiCreateThreadResponse, AomiInterruptResponse, AomiMessage, AomiSSEEvent, AomiStateResponse, AomiSystemEvent, AomiSystemResponse, AomiThread, DISABLED_PROVIDER_STATE, MAX_AUTO_FEE_WEI, NativeWalletExecutionPolicy, NativeWalletSponsorship, SponsorshipPaymasterServiceContext, UserState, WalletCapabilities, WalletEip712Payload, WalletRequest, WalletRequestKind, WalletRequestResult, WalletSolanaSignPayload, WalletTxPayload, aaModeFromExecutionKind, appendFeeCallToPayload, buildFeeAAWalletCall, executeWalletCalls, hydrateTxPayloadFromUserState, normalizeSimulatedFee, parseChainId, toAAWalletCall, toAAWalletCalls, toViemSignTypedDataArgs } from '@aomi-labs/client';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { ReactNode, SetStateAction } from 'react';
|
|
5
5
|
import { ThreadMessageLike } from '@assistant-ui/react';
|
|
@@ -8,8 +8,9 @@ import { ClassValue } from 'clsx';
|
|
|
8
8
|
type AomiRuntimeProviderProps = {
|
|
9
9
|
children: ReactNode;
|
|
10
10
|
backendUrl?: string;
|
|
11
|
+
clientOptions?: Omit<AomiClientOptions, "baseUrl">;
|
|
11
12
|
};
|
|
12
|
-
declare function AomiRuntimeProvider({ children, backendUrl, }: Readonly<AomiRuntimeProviderProps>): react_jsx_runtime.JSX.Element;
|
|
13
|
+
declare function AomiRuntimeProvider({ children, backendUrl, clientOptions, }: Readonly<AomiRuntimeProviderProps>): react_jsx_runtime.JSX.Element;
|
|
13
14
|
|
|
14
15
|
declare class SessionManager {
|
|
15
16
|
private readonly clientFactory;
|
|
@@ -17,8 +18,10 @@ declare class SessionManager {
|
|
|
17
18
|
constructor(clientFactory: () => AomiClient);
|
|
18
19
|
getOrCreate(threadId: string, opts: Omit<SessionOptions, "sessionId">): Session;
|
|
19
20
|
get(threadId: string): Session | undefined;
|
|
21
|
+
get size(): number;
|
|
20
22
|
forEach(callback: (session: Session, threadId: string) => void): void;
|
|
21
23
|
close(threadId: string): void;
|
|
24
|
+
closeIdleExcept(activeThreadId: string, onBeforeClose?: (threadId: string) => void): string[];
|
|
22
25
|
closeAll(): void;
|
|
23
26
|
}
|
|
24
27
|
|
|
@@ -45,6 +48,7 @@ type ThreadContext = {
|
|
|
45
48
|
setThreadMessages: (threadId: string, messages: ThreadMessageLike[]) => void;
|
|
46
49
|
getThreadMetadata: (threadId: string) => ThreadMetadata | undefined;
|
|
47
50
|
updateThreadMetadata: (threadId: string, updates: Partial<ThreadMetadata>) => void;
|
|
51
|
+
resetToDefault: () => void;
|
|
48
52
|
};
|
|
49
53
|
type ThreadContextProviderProps = {
|
|
50
54
|
children: ReactNode;
|
|
@@ -141,20 +145,31 @@ type NotificationContextProviderProps = {
|
|
|
141
145
|
};
|
|
142
146
|
declare function NotificationContextProvider({ children, }: NotificationContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
143
147
|
|
|
144
|
-
type WalletRequestKind = "transaction" | "eip712_sign";
|
|
145
148
|
type WalletRequestStatus = "pending" | "processing";
|
|
146
149
|
type WalletHandlerConfig = {
|
|
147
150
|
/** Get the ClientSession for the current thread. */
|
|
148
151
|
getSession: () => Session | undefined;
|
|
149
152
|
};
|
|
150
153
|
type WalletHandlerApi = {
|
|
151
|
-
/**
|
|
154
|
+
/**
|
|
155
|
+
* All queued wallet requests across every supported kind: EVM txs
|
|
156
|
+
* (`kind: "transaction"`), EIP-712 signs (`kind: "eip712_sign"`), and
|
|
157
|
+
* Solana signs (`kind: "solana_sign"`). Consumers should narrow on
|
|
158
|
+
* `request.kind` before reading `request.payload` — the discriminated
|
|
159
|
+
* union auto-narrows the payload type.
|
|
160
|
+
*/
|
|
152
161
|
pendingRequests: WalletRequest[];
|
|
153
162
|
/** Replace pending requests with the session's authoritative snapshot. */
|
|
154
163
|
setRequests: (requests: WalletRequest[]) => void;
|
|
155
164
|
/** Mark a request as in-flight so it is not replayed while awaiting backend ack. */
|
|
156
165
|
startRequest: (id: string) => void;
|
|
157
|
-
/**
|
|
166
|
+
/**
|
|
167
|
+
* Complete a request successfully — sends the response wire event to
|
|
168
|
+
* the backend via ClientSession. The `result.kind` discriminator must
|
|
169
|
+
* match the originating request's kind (e.g. `{ kind: "solana_sign",
|
|
170
|
+
* signedTx: "..." }` for a Solana request); ClientSession runtime-checks
|
|
171
|
+
* this and throws on mismatch.
|
|
172
|
+
*/
|
|
158
173
|
resolveRequest: (id: string, result: WalletRequestResult) => Promise<void>;
|
|
159
174
|
/** Fail a request — sends error to backend via ClientSession */
|
|
160
175
|
rejectRequest: (id: string, error?: string) => Promise<void>;
|
|
@@ -426,4 +441,4 @@ type ControlContextProviderProps = {
|
|
|
426
441
|
};
|
|
427
442
|
declare function ControlContextProvider({ children, aomiClient, sessionId, publicKey, getThreadMetadata, updateThreadMetadata, }: ControlContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
428
443
|
|
|
429
|
-
export { type AomiRuntimeApi, AomiRuntimeProvider, type AomiRuntimeProviderProps, type ChainInfo, type ControlContextApi, ControlContextProvider, type ControlContextProviderProps, type ControlState, type EventContext, EventContextProvider, type EventContextProviderProps, type EventSubscriber, type InboundEvent, type ModelSelectionMode, type Notification$1 as Notification, type NotificationApi, NotificationContextProvider, type NotificationContextProviderProps, type NotificationContextApi as NotificationContextValue, type NotificationHandlerConfig, type NotificationType, RuntimeUserStateProvider, type SSEStatus, SUPPORTED_CHAINS, type NotificationData as ShowNotificationParams, type StoredModelPreference, type StoredProviderKey, type ThreadContext, ThreadContextProvider, type ThreadControlState, type ThreadMetadata, type UserConfig, UserContextProvider, type WalletHandlerApi, type WalletHandlerConfig, type
|
|
444
|
+
export { type AomiRuntimeApi, AomiRuntimeProvider, type AomiRuntimeProviderProps, type ChainInfo, type ControlContextApi, ControlContextProvider, type ControlContextProviderProps, type ControlState, type EventContext, EventContextProvider, type EventContextProviderProps, type EventSubscriber, type InboundEvent, type ModelSelectionMode, type Notification$1 as Notification, type NotificationApi, NotificationContextProvider, type NotificationContextProviderProps, type NotificationContextApi as NotificationContextValue, type NotificationHandlerConfig, type NotificationType, RuntimeUserStateProvider, type SSEStatus, SUPPORTED_CHAINS, type NotificationData as ShowNotificationParams, type StoredModelPreference, type StoredProviderKey, type ThreadContext, ThreadContextProvider, type ThreadControlState, type ThreadMetadata, type UserConfig, UserContextProvider, type WalletHandlerApi, type WalletHandlerConfig, type WalletRequestStatus, cn, formatAddress, getChainInfo, getNetworkName, initThreadControl, resolveAutoModel, useAomiRuntime, useControl, useCurrentThreadMessages, useCurrentThreadMetadata, useEventContext, useNotification, useNotificationHandler, useThreadContext, useUser, useWalletHandler };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AomiClient, SessionOptions, Session, UserState, WalletRequest, WalletRequestResult, AomiSimulateResponse } from '@aomi-labs/client';
|
|
2
|
-
export { AomiChatResponse, AomiClient, AomiClientOptions, AomiCreateThreadResponse, AomiInterruptResponse, AomiMessage, AomiSSEEvent, AomiStateResponse, AomiSystemEvent, AomiSystemResponse, AomiThread, DISABLED_PROVIDER_STATE, MAX_AUTO_FEE_WEI, NativeWalletExecutionPolicy, NativeWalletSponsorship, SponsorshipPaymasterServiceContext, UserState, WalletCapabilities, WalletEip712Payload, WalletRequest, WalletRequestResult, WalletTxPayload, aaModeFromExecutionKind, appendFeeCallToPayload, buildFeeAAWalletCall, executeWalletCalls, hydrateTxPayloadFromUserState, normalizeSimulatedFee, parseChainId, toAAWalletCall, toAAWalletCalls, toViemSignTypedDataArgs } from '@aomi-labs/client';
|
|
1
|
+
import { AomiClientOptions, AomiClient, SessionOptions, Session, UserState, WalletRequest, WalletRequestResult, AomiSimulateResponse } from '@aomi-labs/client';
|
|
2
|
+
export { AomiChatResponse, AomiClient, AomiClientOptions, AomiCreateThreadResponse, AomiInterruptResponse, AomiMessage, AomiSSEEvent, AomiStateResponse, AomiSystemEvent, AomiSystemResponse, AomiThread, DISABLED_PROVIDER_STATE, MAX_AUTO_FEE_WEI, NativeWalletExecutionPolicy, NativeWalletSponsorship, SponsorshipPaymasterServiceContext, UserState, WalletCapabilities, WalletEip712Payload, WalletRequest, WalletRequestKind, WalletRequestResult, WalletSolanaSignPayload, WalletTxPayload, aaModeFromExecutionKind, appendFeeCallToPayload, buildFeeAAWalletCall, executeWalletCalls, hydrateTxPayloadFromUserState, normalizeSimulatedFee, parseChainId, toAAWalletCall, toAAWalletCalls, toViemSignTypedDataArgs } from '@aomi-labs/client';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { ReactNode, SetStateAction } from 'react';
|
|
5
5
|
import { ThreadMessageLike } from '@assistant-ui/react';
|
|
@@ -8,8 +8,9 @@ import { ClassValue } from 'clsx';
|
|
|
8
8
|
type AomiRuntimeProviderProps = {
|
|
9
9
|
children: ReactNode;
|
|
10
10
|
backendUrl?: string;
|
|
11
|
+
clientOptions?: Omit<AomiClientOptions, "baseUrl">;
|
|
11
12
|
};
|
|
12
|
-
declare function AomiRuntimeProvider({ children, backendUrl, }: Readonly<AomiRuntimeProviderProps>): react_jsx_runtime.JSX.Element;
|
|
13
|
+
declare function AomiRuntimeProvider({ children, backendUrl, clientOptions, }: Readonly<AomiRuntimeProviderProps>): react_jsx_runtime.JSX.Element;
|
|
13
14
|
|
|
14
15
|
declare class SessionManager {
|
|
15
16
|
private readonly clientFactory;
|
|
@@ -17,8 +18,10 @@ declare class SessionManager {
|
|
|
17
18
|
constructor(clientFactory: () => AomiClient);
|
|
18
19
|
getOrCreate(threadId: string, opts: Omit<SessionOptions, "sessionId">): Session;
|
|
19
20
|
get(threadId: string): Session | undefined;
|
|
21
|
+
get size(): number;
|
|
20
22
|
forEach(callback: (session: Session, threadId: string) => void): void;
|
|
21
23
|
close(threadId: string): void;
|
|
24
|
+
closeIdleExcept(activeThreadId: string, onBeforeClose?: (threadId: string) => void): string[];
|
|
22
25
|
closeAll(): void;
|
|
23
26
|
}
|
|
24
27
|
|
|
@@ -45,6 +48,7 @@ type ThreadContext = {
|
|
|
45
48
|
setThreadMessages: (threadId: string, messages: ThreadMessageLike[]) => void;
|
|
46
49
|
getThreadMetadata: (threadId: string) => ThreadMetadata | undefined;
|
|
47
50
|
updateThreadMetadata: (threadId: string, updates: Partial<ThreadMetadata>) => void;
|
|
51
|
+
resetToDefault: () => void;
|
|
48
52
|
};
|
|
49
53
|
type ThreadContextProviderProps = {
|
|
50
54
|
children: ReactNode;
|
|
@@ -141,20 +145,31 @@ type NotificationContextProviderProps = {
|
|
|
141
145
|
};
|
|
142
146
|
declare function NotificationContextProvider({ children, }: NotificationContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
143
147
|
|
|
144
|
-
type WalletRequestKind = "transaction" | "eip712_sign";
|
|
145
148
|
type WalletRequestStatus = "pending" | "processing";
|
|
146
149
|
type WalletHandlerConfig = {
|
|
147
150
|
/** Get the ClientSession for the current thread. */
|
|
148
151
|
getSession: () => Session | undefined;
|
|
149
152
|
};
|
|
150
153
|
type WalletHandlerApi = {
|
|
151
|
-
/**
|
|
154
|
+
/**
|
|
155
|
+
* All queued wallet requests across every supported kind: EVM txs
|
|
156
|
+
* (`kind: "transaction"`), EIP-712 signs (`kind: "eip712_sign"`), and
|
|
157
|
+
* Solana signs (`kind: "solana_sign"`). Consumers should narrow on
|
|
158
|
+
* `request.kind` before reading `request.payload` — the discriminated
|
|
159
|
+
* union auto-narrows the payload type.
|
|
160
|
+
*/
|
|
152
161
|
pendingRequests: WalletRequest[];
|
|
153
162
|
/** Replace pending requests with the session's authoritative snapshot. */
|
|
154
163
|
setRequests: (requests: WalletRequest[]) => void;
|
|
155
164
|
/** Mark a request as in-flight so it is not replayed while awaiting backend ack. */
|
|
156
165
|
startRequest: (id: string) => void;
|
|
157
|
-
/**
|
|
166
|
+
/**
|
|
167
|
+
* Complete a request successfully — sends the response wire event to
|
|
168
|
+
* the backend via ClientSession. The `result.kind` discriminator must
|
|
169
|
+
* match the originating request's kind (e.g. `{ kind: "solana_sign",
|
|
170
|
+
* signedTx: "..." }` for a Solana request); ClientSession runtime-checks
|
|
171
|
+
* this and throws on mismatch.
|
|
172
|
+
*/
|
|
158
173
|
resolveRequest: (id: string, result: WalletRequestResult) => Promise<void>;
|
|
159
174
|
/** Fail a request — sends error to backend via ClientSession */
|
|
160
175
|
rejectRequest: (id: string, error?: string) => Promise<void>;
|
|
@@ -426,4 +441,4 @@ type ControlContextProviderProps = {
|
|
|
426
441
|
};
|
|
427
442
|
declare function ControlContextProvider({ children, aomiClient, sessionId, publicKey, getThreadMetadata, updateThreadMetadata, }: ControlContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
428
443
|
|
|
429
|
-
export { type AomiRuntimeApi, AomiRuntimeProvider, type AomiRuntimeProviderProps, type ChainInfo, type ControlContextApi, ControlContextProvider, type ControlContextProviderProps, type ControlState, type EventContext, EventContextProvider, type EventContextProviderProps, type EventSubscriber, type InboundEvent, type ModelSelectionMode, type Notification$1 as Notification, type NotificationApi, NotificationContextProvider, type NotificationContextProviderProps, type NotificationContextApi as NotificationContextValue, type NotificationHandlerConfig, type NotificationType, RuntimeUserStateProvider, type SSEStatus, SUPPORTED_CHAINS, type NotificationData as ShowNotificationParams, type StoredModelPreference, type StoredProviderKey, type ThreadContext, ThreadContextProvider, type ThreadControlState, type ThreadMetadata, type UserConfig, UserContextProvider, type WalletHandlerApi, type WalletHandlerConfig, type
|
|
444
|
+
export { type AomiRuntimeApi, AomiRuntimeProvider, type AomiRuntimeProviderProps, type ChainInfo, type ControlContextApi, ControlContextProvider, type ControlContextProviderProps, type ControlState, type EventContext, EventContextProvider, type EventContextProviderProps, type EventSubscriber, type InboundEvent, type ModelSelectionMode, type Notification$1 as Notification, type NotificationApi, NotificationContextProvider, type NotificationContextProviderProps, type NotificationContextApi as NotificationContextValue, type NotificationHandlerConfig, type NotificationType, RuntimeUserStateProvider, type SSEStatus, SUPPORTED_CHAINS, type NotificationData as ShowNotificationParams, type StoredModelPreference, type StoredProviderKey, type ThreadContext, ThreadContextProvider, type ThreadControlState, type ThreadMetadata, type UserConfig, UserContextProvider, type WalletHandlerApi, type WalletHandlerConfig, type WalletRequestStatus, cn, formatAddress, getChainInfo, getNetworkName, initThreadControl, resolveAutoModel, useAomiRuntime, useControl, useCurrentThreadMessages, useCurrentThreadMetadata, useEventContext, useNotification, useNotificationHandler, useThreadContext, useUser, useWalletHandler };
|