@aomi-labs/react 0.3.13 → 0.3.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.
- package/dist/index.cjs +302 -106
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +36 -4
- package/dist/index.d.ts +36 -4
- package/dist/index.js +301 -106
- 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 } from '@aomi-labs/client';
|
|
2
|
-
export { AomiChatResponse, AomiClient, AomiClientOptions, AomiCreateThreadResponse, AomiInterruptResponse, AomiMessage, AomiSSEEvent, AomiStateResponse, AomiSystemEvent, AomiSystemResponse, AomiThread, DISABLED_PROVIDER_STATE, UserState, WalletEip712Payload, WalletRequest, WalletRequestResult, WalletTxPayload, aaModeFromExecutionKind, executeWalletCalls, hydrateTxPayloadFromUserState, parseChainId, toAAWalletCall, toAAWalletCalls, toViemSignTypedDataArgs } from '@aomi-labs/client';
|
|
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, UserState, WalletEip712Payload, WalletRequest, WalletRequestResult, 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';
|
|
@@ -56,9 +56,12 @@ declare function useCurrentThreadMessages(): ThreadMessageLike[];
|
|
|
56
56
|
declare function useCurrentThreadMetadata(): ThreadMetadata | undefined;
|
|
57
57
|
|
|
58
58
|
type ThreadStatus = "regular" | "archived";
|
|
59
|
+
type ModelSelectionMode = "auto" | "manual";
|
|
59
60
|
type ThreadControlState = {
|
|
60
61
|
/** Selected model for this thread (human-readable label) */
|
|
61
62
|
model: string | null;
|
|
63
|
+
/** Whether the selected model should be displayed as auto or explicit */
|
|
64
|
+
modelMode?: ModelSelectionMode;
|
|
62
65
|
/** Selected app for this thread */
|
|
63
66
|
app: string | null;
|
|
64
67
|
/** Whether control state has changed but chat hasn't started yet */
|
|
@@ -213,6 +216,18 @@ type AomiRuntimeApi = {
|
|
|
213
216
|
resolveWalletRequest: (id: string, result: WalletRequestResult) => Promise<void>;
|
|
214
217
|
/** Fail a wallet request after the backend acknowledges the error */
|
|
215
218
|
rejectWalletRequest: (id: string, error?: string) => Promise<void>;
|
|
219
|
+
/** Simulate a batch against the current thread session context. */
|
|
220
|
+
simulateBatchTransactions: (transactions: Array<{
|
|
221
|
+
to: string;
|
|
222
|
+
value?: string;
|
|
223
|
+
data?: string;
|
|
224
|
+
label?: string;
|
|
225
|
+
chain_id?: number;
|
|
226
|
+
chainId?: number;
|
|
227
|
+
}>, options?: {
|
|
228
|
+
from?: string;
|
|
229
|
+
chainId?: number;
|
|
230
|
+
}) => Promise<AomiSimulateResponse["result"]>;
|
|
216
231
|
/** Subscribe to inbound events by type. Returns unsubscribe function. */
|
|
217
232
|
subscribe: (type: string, callback: EventSubscriber) => () => void;
|
|
218
233
|
/** Send a system command to the backend */
|
|
@@ -315,12 +330,23 @@ declare const SUPPORTED_CHAINS: ChainInfo[];
|
|
|
315
330
|
/** Look up ChainInfo by chain ID. Returns undefined for unknown chains. */
|
|
316
331
|
declare const getChainInfo: (chainId: number | undefined) => ChainInfo | undefined;
|
|
317
332
|
|
|
333
|
+
/**
|
|
334
|
+
* Resolve the actual backend model for auto mode.
|
|
335
|
+
* Prefers known cheaper/performance-oriented models before falling back to the
|
|
336
|
+
* backend order.
|
|
337
|
+
*/
|
|
338
|
+
declare function resolveAutoModel(models: string[]): string | null;
|
|
339
|
+
|
|
318
340
|
/** A stored provider API key (BYOK) */
|
|
319
341
|
type StoredProviderKey = {
|
|
320
342
|
apiKey: string;
|
|
321
343
|
keyPrefix: string;
|
|
322
344
|
label?: string;
|
|
323
345
|
};
|
|
346
|
+
type StoredModelPreference = {
|
|
347
|
+
mode: ModelSelectionMode;
|
|
348
|
+
model: string | null;
|
|
349
|
+
};
|
|
324
350
|
/** Global control state (shared across all threads) */
|
|
325
351
|
type ControlState = {
|
|
326
352
|
/** API key for authenticated requests */
|
|
@@ -364,13 +390,19 @@ type ControlContextApi = {
|
|
|
364
390
|
/** Get the current thread's effective app after auth fallback */
|
|
365
391
|
getCurrentThreadApp: () => string;
|
|
366
392
|
/** Select a model for the current thread (updates metadata + calls backend) */
|
|
367
|
-
onModelSelect: (model: string
|
|
393
|
+
onModelSelect: (model: string, options?: {
|
|
394
|
+
mode?: ModelSelectionMode;
|
|
395
|
+
}) => Promise<void>;
|
|
368
396
|
/** Select an app for the current thread (updates metadata only) */
|
|
369
397
|
onAppSelect: (app: string) => void;
|
|
370
398
|
/** Whether the current thread is processing (disables control switching) */
|
|
371
399
|
isProcessing: boolean;
|
|
372
400
|
/** Mark control state as synced (called after chat starts) */
|
|
373
401
|
markControlSynced: () => void;
|
|
402
|
+
/** Sync pending control state to the backend before sending */
|
|
403
|
+
syncCurrentThreadControl: () => Promise<void>;
|
|
404
|
+
/** Build initial control state for new local threads */
|
|
405
|
+
getPreferredThreadControl: () => ThreadControlState;
|
|
374
406
|
/** Get global control state */
|
|
375
407
|
getControlState: () => ControlState;
|
|
376
408
|
/** Subscribe to global state changes */
|
|
@@ -394,4 +426,4 @@ type ControlContextProviderProps = {
|
|
|
394
426
|
};
|
|
395
427
|
declare function ControlContextProvider({ children, aomiClient, sessionId, publicKey, getThreadMetadata, updateThreadMetadata, }: ControlContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
396
428
|
|
|
397
|
-
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 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 StoredProviderKey, type ThreadContext, ThreadContextProvider, type ThreadControlState, type ThreadMetadata, type UserConfig, UserContextProvider, type WalletHandlerApi, type WalletHandlerConfig, type WalletRequestKind, type WalletRequestStatus, cn, formatAddress, getChainInfo, getNetworkName, initThreadControl, useAomiRuntime, useControl, useCurrentThreadMessages, useCurrentThreadMetadata, useEventContext, useNotification, useNotificationHandler, useThreadContext, useUser, useWalletHandler };
|
|
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 WalletRequestKind, 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 } from '@aomi-labs/client';
|
|
2
|
-
export { AomiChatResponse, AomiClient, AomiClientOptions, AomiCreateThreadResponse, AomiInterruptResponse, AomiMessage, AomiSSEEvent, AomiStateResponse, AomiSystemEvent, AomiSystemResponse, AomiThread, DISABLED_PROVIDER_STATE, UserState, WalletEip712Payload, WalletRequest, WalletRequestResult, WalletTxPayload, aaModeFromExecutionKind, executeWalletCalls, hydrateTxPayloadFromUserState, parseChainId, toAAWalletCall, toAAWalletCalls, toViemSignTypedDataArgs } from '@aomi-labs/client';
|
|
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, UserState, WalletEip712Payload, WalletRequest, WalletRequestResult, 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';
|
|
@@ -56,9 +56,12 @@ declare function useCurrentThreadMessages(): ThreadMessageLike[];
|
|
|
56
56
|
declare function useCurrentThreadMetadata(): ThreadMetadata | undefined;
|
|
57
57
|
|
|
58
58
|
type ThreadStatus = "regular" | "archived";
|
|
59
|
+
type ModelSelectionMode = "auto" | "manual";
|
|
59
60
|
type ThreadControlState = {
|
|
60
61
|
/** Selected model for this thread (human-readable label) */
|
|
61
62
|
model: string | null;
|
|
63
|
+
/** Whether the selected model should be displayed as auto or explicit */
|
|
64
|
+
modelMode?: ModelSelectionMode;
|
|
62
65
|
/** Selected app for this thread */
|
|
63
66
|
app: string | null;
|
|
64
67
|
/** Whether control state has changed but chat hasn't started yet */
|
|
@@ -213,6 +216,18 @@ type AomiRuntimeApi = {
|
|
|
213
216
|
resolveWalletRequest: (id: string, result: WalletRequestResult) => Promise<void>;
|
|
214
217
|
/** Fail a wallet request after the backend acknowledges the error */
|
|
215
218
|
rejectWalletRequest: (id: string, error?: string) => Promise<void>;
|
|
219
|
+
/** Simulate a batch against the current thread session context. */
|
|
220
|
+
simulateBatchTransactions: (transactions: Array<{
|
|
221
|
+
to: string;
|
|
222
|
+
value?: string;
|
|
223
|
+
data?: string;
|
|
224
|
+
label?: string;
|
|
225
|
+
chain_id?: number;
|
|
226
|
+
chainId?: number;
|
|
227
|
+
}>, options?: {
|
|
228
|
+
from?: string;
|
|
229
|
+
chainId?: number;
|
|
230
|
+
}) => Promise<AomiSimulateResponse["result"]>;
|
|
216
231
|
/** Subscribe to inbound events by type. Returns unsubscribe function. */
|
|
217
232
|
subscribe: (type: string, callback: EventSubscriber) => () => void;
|
|
218
233
|
/** Send a system command to the backend */
|
|
@@ -315,12 +330,23 @@ declare const SUPPORTED_CHAINS: ChainInfo[];
|
|
|
315
330
|
/** Look up ChainInfo by chain ID. Returns undefined for unknown chains. */
|
|
316
331
|
declare const getChainInfo: (chainId: number | undefined) => ChainInfo | undefined;
|
|
317
332
|
|
|
333
|
+
/**
|
|
334
|
+
* Resolve the actual backend model for auto mode.
|
|
335
|
+
* Prefers known cheaper/performance-oriented models before falling back to the
|
|
336
|
+
* backend order.
|
|
337
|
+
*/
|
|
338
|
+
declare function resolveAutoModel(models: string[]): string | null;
|
|
339
|
+
|
|
318
340
|
/** A stored provider API key (BYOK) */
|
|
319
341
|
type StoredProviderKey = {
|
|
320
342
|
apiKey: string;
|
|
321
343
|
keyPrefix: string;
|
|
322
344
|
label?: string;
|
|
323
345
|
};
|
|
346
|
+
type StoredModelPreference = {
|
|
347
|
+
mode: ModelSelectionMode;
|
|
348
|
+
model: string | null;
|
|
349
|
+
};
|
|
324
350
|
/** Global control state (shared across all threads) */
|
|
325
351
|
type ControlState = {
|
|
326
352
|
/** API key for authenticated requests */
|
|
@@ -364,13 +390,19 @@ type ControlContextApi = {
|
|
|
364
390
|
/** Get the current thread's effective app after auth fallback */
|
|
365
391
|
getCurrentThreadApp: () => string;
|
|
366
392
|
/** Select a model for the current thread (updates metadata + calls backend) */
|
|
367
|
-
onModelSelect: (model: string
|
|
393
|
+
onModelSelect: (model: string, options?: {
|
|
394
|
+
mode?: ModelSelectionMode;
|
|
395
|
+
}) => Promise<void>;
|
|
368
396
|
/** Select an app for the current thread (updates metadata only) */
|
|
369
397
|
onAppSelect: (app: string) => void;
|
|
370
398
|
/** Whether the current thread is processing (disables control switching) */
|
|
371
399
|
isProcessing: boolean;
|
|
372
400
|
/** Mark control state as synced (called after chat starts) */
|
|
373
401
|
markControlSynced: () => void;
|
|
402
|
+
/** Sync pending control state to the backend before sending */
|
|
403
|
+
syncCurrentThreadControl: () => Promise<void>;
|
|
404
|
+
/** Build initial control state for new local threads */
|
|
405
|
+
getPreferredThreadControl: () => ThreadControlState;
|
|
374
406
|
/** Get global control state */
|
|
375
407
|
getControlState: () => ControlState;
|
|
376
408
|
/** Subscribe to global state changes */
|
|
@@ -394,4 +426,4 @@ type ControlContextProviderProps = {
|
|
|
394
426
|
};
|
|
395
427
|
declare function ControlContextProvider({ children, aomiClient, sessionId, publicKey, getThreadMetadata, updateThreadMetadata, }: ControlContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
396
428
|
|
|
397
|
-
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 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 StoredProviderKey, type ThreadContext, ThreadContextProvider, type ThreadControlState, type ThreadMetadata, type UserConfig, UserContextProvider, type WalletHandlerApi, type WalletHandlerConfig, type WalletRequestKind, type WalletRequestStatus, cn, formatAddress, getChainInfo, getNetworkName, initThreadControl, useAomiRuntime, useControl, useCurrentThreadMessages, useCurrentThreadMetadata, useEventContext, useNotification, useNotificationHandler, useThreadContext, useUser, useWalletHandler };
|
|
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 WalletRequestKind, type WalletRequestStatus, cn, formatAddress, getChainInfo, getNetworkName, initThreadControl, resolveAutoModel, useAomiRuntime, useControl, useCurrentThreadMessages, useCurrentThreadMetadata, useEventContext, useNotification, useNotificationHandler, useThreadContext, useUser, useWalletHandler };
|