@aomi-labs/react 0.2.0 → 0.2.2
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 +755 -330
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +88 -2
- package/dist/index.d.ts +88 -2
- package/dist/index.js +768 -339
- package/dist/index.js.map +1 -1
- package/package.json +12 -2
package/dist/index.d.cts
CHANGED
|
@@ -110,7 +110,7 @@ declare class BackendApi {
|
|
|
110
110
|
private sseSubscriber;
|
|
111
111
|
constructor(backendUrl: string);
|
|
112
112
|
fetchState(sessionId: string, userState?: UserState): Promise<ApiStateResponse>;
|
|
113
|
-
postChatMessage(sessionId: string, message: string, publicKey?: string): Promise<ApiChatResponse>;
|
|
113
|
+
postChatMessage(sessionId: string, message: string, namespace: string, publicKey?: string, apiKey?: string): Promise<ApiChatResponse>;
|
|
114
114
|
postSystemMessage(sessionId: string, message: string): Promise<ApiSystemResponse>;
|
|
115
115
|
postInterrupt(sessionId: string): Promise<ApiInterruptResponse>;
|
|
116
116
|
/**
|
|
@@ -127,6 +127,23 @@ declare class BackendApi {
|
|
|
127
127
|
deleteThread(sessionId: string): Promise<void>;
|
|
128
128
|
renameThread(sessionId: string, newTitle: string): Promise<void>;
|
|
129
129
|
getSystemEvents(sessionId: string, count?: number): Promise<ApiSystemEvent[]>;
|
|
130
|
+
/**
|
|
131
|
+
* Get allowed namespaces for the current request context.
|
|
132
|
+
*/
|
|
133
|
+
getNamespaces(sessionId: string, publicKey?: string, apiKey?: string): Promise<string[]>;
|
|
134
|
+
/**
|
|
135
|
+
* Get available models.
|
|
136
|
+
*/
|
|
137
|
+
getModels(sessionId: string): Promise<string[]>;
|
|
138
|
+
/**
|
|
139
|
+
* Set the model selection for a session.
|
|
140
|
+
*/
|
|
141
|
+
setModel(sessionId: string, rig: string, namespace?: string, apiKey?: string): Promise<{
|
|
142
|
+
success: boolean;
|
|
143
|
+
rig: string;
|
|
144
|
+
baml: string;
|
|
145
|
+
created: boolean;
|
|
146
|
+
}>;
|
|
130
147
|
}
|
|
131
148
|
|
|
132
149
|
type AomiRuntimeProviderProps = {
|
|
@@ -161,11 +178,25 @@ declare function useCurrentThreadMessages(): ThreadMessageLike[];
|
|
|
161
178
|
declare function useCurrentThreadMetadata(): ThreadMetadata | undefined;
|
|
162
179
|
|
|
163
180
|
type ThreadStatus = "regular" | "archived" | "pending";
|
|
181
|
+
type ThreadControlState = {
|
|
182
|
+
/** Selected model for this thread (human-readable label) */
|
|
183
|
+
model: string | null;
|
|
184
|
+
/** Selected namespace for this thread */
|
|
185
|
+
namespace: string | null;
|
|
186
|
+
/** Whether control state has changed but chat hasn't started yet */
|
|
187
|
+
controlDirty: boolean;
|
|
188
|
+
/** Whether this thread is currently processing (assistant generating) */
|
|
189
|
+
isProcessing: boolean;
|
|
190
|
+
};
|
|
164
191
|
type ThreadMetadata = {
|
|
165
192
|
title: string;
|
|
166
193
|
status: ThreadStatus;
|
|
167
194
|
lastActiveAt?: string | number;
|
|
195
|
+
/** Per-thread control state (model, namespace selection) */
|
|
196
|
+
control: ThreadControlState;
|
|
168
197
|
};
|
|
198
|
+
/** Create default control state for a new thread */
|
|
199
|
+
declare function initThreadControl(): ThreadControlState;
|
|
169
200
|
|
|
170
201
|
type InboundEvent = {
|
|
171
202
|
type: string;
|
|
@@ -382,4 +413,59 @@ type UserConfig = {
|
|
|
382
413
|
declare const getNetworkName: (chainId: number | string | undefined) => string;
|
|
383
414
|
declare const formatAddress: (addr?: string) => string;
|
|
384
415
|
|
|
385
|
-
|
|
416
|
+
/** Global control state (shared across all threads) */
|
|
417
|
+
type ControlState = {
|
|
418
|
+
/** API key for authenticated requests */
|
|
419
|
+
apiKey: string | null;
|
|
420
|
+
/** Available models fetched from backend */
|
|
421
|
+
availableModels: string[];
|
|
422
|
+
/** Authorized namespaces fetched from backend */
|
|
423
|
+
authorizedNamespaces: string[];
|
|
424
|
+
/** Default model (first from availableModels) */
|
|
425
|
+
defaultModel: string | null;
|
|
426
|
+
/** Default namespace (from authorizedNamespaces) */
|
|
427
|
+
defaultNamespace: string | null;
|
|
428
|
+
};
|
|
429
|
+
type ControlContextApi = {
|
|
430
|
+
/** Global state (apiKey, available models/namespaces) */
|
|
431
|
+
state: ControlState;
|
|
432
|
+
/** Update global state (apiKey only) */
|
|
433
|
+
setApiKey: (apiKey: string | null) => void;
|
|
434
|
+
/** Fetch available models from backend */
|
|
435
|
+
getAvailableModels: () => Promise<string[]>;
|
|
436
|
+
/** Fetch authorized namespaces from backend */
|
|
437
|
+
getAuthorizedNamespaces: () => Promise<string[]>;
|
|
438
|
+
/** Get current thread's control state */
|
|
439
|
+
getCurrentThreadControl: () => ThreadControlState;
|
|
440
|
+
/** Select a model for the current thread (updates metadata + calls backend) */
|
|
441
|
+
onModelSelect: (model: string) => Promise<void>;
|
|
442
|
+
/** Select a namespace for the current thread (updates metadata only) */
|
|
443
|
+
onNamespaceSelect: (namespace: string) => void;
|
|
444
|
+
/** Whether the current thread is processing (disables control switching) */
|
|
445
|
+
isProcessing: boolean;
|
|
446
|
+
/** Mark control state as synced (called after chat starts) */
|
|
447
|
+
markControlSynced: () => void;
|
|
448
|
+
/** Get global control state */
|
|
449
|
+
getControlState: () => ControlState;
|
|
450
|
+
/** Subscribe to global state changes */
|
|
451
|
+
onControlStateChange: (callback: (state: ControlState) => void) => () => void;
|
|
452
|
+
/** @deprecated Use getCurrentThreadControl().namespace instead */
|
|
453
|
+
setState: (updates: Partial<{
|
|
454
|
+
namespace: string | null;
|
|
455
|
+
apiKey: string | null;
|
|
456
|
+
}>) => void;
|
|
457
|
+
};
|
|
458
|
+
declare function useControl(): ControlContextApi;
|
|
459
|
+
type ControlContextProviderProps = {
|
|
460
|
+
children: ReactNode;
|
|
461
|
+
backendApi: BackendApi;
|
|
462
|
+
sessionId: string;
|
|
463
|
+
publicKey?: string;
|
|
464
|
+
/** Get metadata for a thread */
|
|
465
|
+
getThreadMetadata: (threadId: string) => ThreadMetadata | undefined;
|
|
466
|
+
/** Update metadata for a thread */
|
|
467
|
+
updateThreadMetadata: (threadId: string, updates: Partial<ThreadMetadata>) => void;
|
|
468
|
+
};
|
|
469
|
+
declare function ControlContextProvider({ children, backendApi, sessionId, publicKey, getThreadMetadata, updateThreadMetadata, }: ControlContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
470
|
+
|
|
471
|
+
export { type AomiMessage, type AomiRuntimeApi, AomiRuntimeProvider, type AomiRuntimeProviderProps, type ApiChatResponse, type ApiCreateThreadResponse, type ApiInterruptResponse, type ApiSSEEvent, type ApiStateResponse, type ApiSystemEvent, type ApiSystemResponse, type ApiThread, BackendApi, type ControlContextApi, ControlContextProvider, type ControlContextProviderProps, type ControlState, type EventBuffer, type EventContext, EventContextProvider, type EventContextProviderProps, type EventSubscriber, type Notification as HandlerNotification, type InboundEvent, type Notification$1 as Notification, type NotificationApi, NotificationContextProvider, type NotificationContextProviderProps, type NotificationContextApi as NotificationContextValue, type NotificationHandlerConfig, type NotificationType, type OutboundEvent, type SSEStatus, type NotificationData as ShowNotificationParams, type ThreadContext, ThreadContextProvider, type ThreadControlState, type ThreadMetadata, type UserConfig, UserContextProvider, type UserState, type UserState as WalletButtonState, type WalletConnectionStatus, type WalletHanderApi, type WalletHandlerConfig, type WalletTxComplete, type WalletTxRequest, cn, formatAddress, getNetworkName, initThreadControl, useAomiRuntime, useControl, useCurrentThreadMessages, useCurrentThreadMetadata, useEventContext, useNotification, useNotificationHandler, useThreadContext, useUser, useWalletHandler };
|
package/dist/index.d.ts
CHANGED
|
@@ -110,7 +110,7 @@ declare class BackendApi {
|
|
|
110
110
|
private sseSubscriber;
|
|
111
111
|
constructor(backendUrl: string);
|
|
112
112
|
fetchState(sessionId: string, userState?: UserState): Promise<ApiStateResponse>;
|
|
113
|
-
postChatMessage(sessionId: string, message: string, publicKey?: string): Promise<ApiChatResponse>;
|
|
113
|
+
postChatMessage(sessionId: string, message: string, namespace: string, publicKey?: string, apiKey?: string): Promise<ApiChatResponse>;
|
|
114
114
|
postSystemMessage(sessionId: string, message: string): Promise<ApiSystemResponse>;
|
|
115
115
|
postInterrupt(sessionId: string): Promise<ApiInterruptResponse>;
|
|
116
116
|
/**
|
|
@@ -127,6 +127,23 @@ declare class BackendApi {
|
|
|
127
127
|
deleteThread(sessionId: string): Promise<void>;
|
|
128
128
|
renameThread(sessionId: string, newTitle: string): Promise<void>;
|
|
129
129
|
getSystemEvents(sessionId: string, count?: number): Promise<ApiSystemEvent[]>;
|
|
130
|
+
/**
|
|
131
|
+
* Get allowed namespaces for the current request context.
|
|
132
|
+
*/
|
|
133
|
+
getNamespaces(sessionId: string, publicKey?: string, apiKey?: string): Promise<string[]>;
|
|
134
|
+
/**
|
|
135
|
+
* Get available models.
|
|
136
|
+
*/
|
|
137
|
+
getModels(sessionId: string): Promise<string[]>;
|
|
138
|
+
/**
|
|
139
|
+
* Set the model selection for a session.
|
|
140
|
+
*/
|
|
141
|
+
setModel(sessionId: string, rig: string, namespace?: string, apiKey?: string): Promise<{
|
|
142
|
+
success: boolean;
|
|
143
|
+
rig: string;
|
|
144
|
+
baml: string;
|
|
145
|
+
created: boolean;
|
|
146
|
+
}>;
|
|
130
147
|
}
|
|
131
148
|
|
|
132
149
|
type AomiRuntimeProviderProps = {
|
|
@@ -161,11 +178,25 @@ declare function useCurrentThreadMessages(): ThreadMessageLike[];
|
|
|
161
178
|
declare function useCurrentThreadMetadata(): ThreadMetadata | undefined;
|
|
162
179
|
|
|
163
180
|
type ThreadStatus = "regular" | "archived" | "pending";
|
|
181
|
+
type ThreadControlState = {
|
|
182
|
+
/** Selected model for this thread (human-readable label) */
|
|
183
|
+
model: string | null;
|
|
184
|
+
/** Selected namespace for this thread */
|
|
185
|
+
namespace: string | null;
|
|
186
|
+
/** Whether control state has changed but chat hasn't started yet */
|
|
187
|
+
controlDirty: boolean;
|
|
188
|
+
/** Whether this thread is currently processing (assistant generating) */
|
|
189
|
+
isProcessing: boolean;
|
|
190
|
+
};
|
|
164
191
|
type ThreadMetadata = {
|
|
165
192
|
title: string;
|
|
166
193
|
status: ThreadStatus;
|
|
167
194
|
lastActiveAt?: string | number;
|
|
195
|
+
/** Per-thread control state (model, namespace selection) */
|
|
196
|
+
control: ThreadControlState;
|
|
168
197
|
};
|
|
198
|
+
/** Create default control state for a new thread */
|
|
199
|
+
declare function initThreadControl(): ThreadControlState;
|
|
169
200
|
|
|
170
201
|
type InboundEvent = {
|
|
171
202
|
type: string;
|
|
@@ -382,4 +413,59 @@ type UserConfig = {
|
|
|
382
413
|
declare const getNetworkName: (chainId: number | string | undefined) => string;
|
|
383
414
|
declare const formatAddress: (addr?: string) => string;
|
|
384
415
|
|
|
385
|
-
|
|
416
|
+
/** Global control state (shared across all threads) */
|
|
417
|
+
type ControlState = {
|
|
418
|
+
/** API key for authenticated requests */
|
|
419
|
+
apiKey: string | null;
|
|
420
|
+
/** Available models fetched from backend */
|
|
421
|
+
availableModels: string[];
|
|
422
|
+
/** Authorized namespaces fetched from backend */
|
|
423
|
+
authorizedNamespaces: string[];
|
|
424
|
+
/** Default model (first from availableModels) */
|
|
425
|
+
defaultModel: string | null;
|
|
426
|
+
/** Default namespace (from authorizedNamespaces) */
|
|
427
|
+
defaultNamespace: string | null;
|
|
428
|
+
};
|
|
429
|
+
type ControlContextApi = {
|
|
430
|
+
/** Global state (apiKey, available models/namespaces) */
|
|
431
|
+
state: ControlState;
|
|
432
|
+
/** Update global state (apiKey only) */
|
|
433
|
+
setApiKey: (apiKey: string | null) => void;
|
|
434
|
+
/** Fetch available models from backend */
|
|
435
|
+
getAvailableModels: () => Promise<string[]>;
|
|
436
|
+
/** Fetch authorized namespaces from backend */
|
|
437
|
+
getAuthorizedNamespaces: () => Promise<string[]>;
|
|
438
|
+
/** Get current thread's control state */
|
|
439
|
+
getCurrentThreadControl: () => ThreadControlState;
|
|
440
|
+
/** Select a model for the current thread (updates metadata + calls backend) */
|
|
441
|
+
onModelSelect: (model: string) => Promise<void>;
|
|
442
|
+
/** Select a namespace for the current thread (updates metadata only) */
|
|
443
|
+
onNamespaceSelect: (namespace: string) => void;
|
|
444
|
+
/** Whether the current thread is processing (disables control switching) */
|
|
445
|
+
isProcessing: boolean;
|
|
446
|
+
/** Mark control state as synced (called after chat starts) */
|
|
447
|
+
markControlSynced: () => void;
|
|
448
|
+
/** Get global control state */
|
|
449
|
+
getControlState: () => ControlState;
|
|
450
|
+
/** Subscribe to global state changes */
|
|
451
|
+
onControlStateChange: (callback: (state: ControlState) => void) => () => void;
|
|
452
|
+
/** @deprecated Use getCurrentThreadControl().namespace instead */
|
|
453
|
+
setState: (updates: Partial<{
|
|
454
|
+
namespace: string | null;
|
|
455
|
+
apiKey: string | null;
|
|
456
|
+
}>) => void;
|
|
457
|
+
};
|
|
458
|
+
declare function useControl(): ControlContextApi;
|
|
459
|
+
type ControlContextProviderProps = {
|
|
460
|
+
children: ReactNode;
|
|
461
|
+
backendApi: BackendApi;
|
|
462
|
+
sessionId: string;
|
|
463
|
+
publicKey?: string;
|
|
464
|
+
/** Get metadata for a thread */
|
|
465
|
+
getThreadMetadata: (threadId: string) => ThreadMetadata | undefined;
|
|
466
|
+
/** Update metadata for a thread */
|
|
467
|
+
updateThreadMetadata: (threadId: string, updates: Partial<ThreadMetadata>) => void;
|
|
468
|
+
};
|
|
469
|
+
declare function ControlContextProvider({ children, backendApi, sessionId, publicKey, getThreadMetadata, updateThreadMetadata, }: ControlContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
470
|
+
|
|
471
|
+
export { type AomiMessage, type AomiRuntimeApi, AomiRuntimeProvider, type AomiRuntimeProviderProps, type ApiChatResponse, type ApiCreateThreadResponse, type ApiInterruptResponse, type ApiSSEEvent, type ApiStateResponse, type ApiSystemEvent, type ApiSystemResponse, type ApiThread, BackendApi, type ControlContextApi, ControlContextProvider, type ControlContextProviderProps, type ControlState, type EventBuffer, type EventContext, EventContextProvider, type EventContextProviderProps, type EventSubscriber, type Notification as HandlerNotification, type InboundEvent, type Notification$1 as Notification, type NotificationApi, NotificationContextProvider, type NotificationContextProviderProps, type NotificationContextApi as NotificationContextValue, type NotificationHandlerConfig, type NotificationType, type OutboundEvent, type SSEStatus, type NotificationData as ShowNotificationParams, type ThreadContext, ThreadContextProvider, type ThreadControlState, type ThreadMetadata, type UserConfig, UserContextProvider, type UserState, type UserState as WalletButtonState, type WalletConnectionStatus, type WalletHanderApi, type WalletHandlerConfig, type WalletTxComplete, type WalletTxRequest, cn, formatAddress, getNetworkName, initThreadControl, useAomiRuntime, useControl, useCurrentThreadMessages, useCurrentThreadMetadata, useEventContext, useNotification, useNotificationHandler, useThreadContext, useUser, useWalletHandler };
|