@aomi-labs/react 0.2.1 → 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 +2562 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +471 -0
- package/dist/index.d.ts +471 -0
- package/dist/index.js +2552 -0
- package/dist/index.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode, SetStateAction } from 'react';
|
|
3
|
+
import { ThreadMessageLike } from '@assistant-ui/react';
|
|
4
|
+
import { ClassValue } from 'clsx';
|
|
5
|
+
|
|
6
|
+
interface AomiMessage {
|
|
7
|
+
sender?: "user" | "agent" | "system" | string;
|
|
8
|
+
content?: string;
|
|
9
|
+
timestamp?: string;
|
|
10
|
+
is_streaming?: boolean;
|
|
11
|
+
tool_result?: [string, string] | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* GET /api/state
|
|
15
|
+
* Fetches current session state including messages and processing status
|
|
16
|
+
*/
|
|
17
|
+
interface ApiStateResponse {
|
|
18
|
+
messages?: AomiMessage[] | null;
|
|
19
|
+
system_events?: ApiSystemEvent[] | null;
|
|
20
|
+
title?: string | null;
|
|
21
|
+
is_processing?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* POST /api/chat
|
|
25
|
+
* Sends a chat message and returns updated session state
|
|
26
|
+
*/
|
|
27
|
+
interface ApiChatResponse {
|
|
28
|
+
messages?: AomiMessage[] | null;
|
|
29
|
+
system_events?: ApiSystemEvent[] | null;
|
|
30
|
+
title?: string | null;
|
|
31
|
+
is_processing?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* POST /api/system
|
|
35
|
+
* Sends a system message and returns the response message
|
|
36
|
+
*/
|
|
37
|
+
interface ApiSystemResponse {
|
|
38
|
+
res?: AomiMessage | null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* POST /api/interrupt
|
|
42
|
+
* Interrupts current processing and returns updated session state
|
|
43
|
+
*/
|
|
44
|
+
type ApiInterruptResponse = ApiChatResponse;
|
|
45
|
+
/**
|
|
46
|
+
* GET /api/sessions
|
|
47
|
+
* Returns array of ApiThread
|
|
48
|
+
*/
|
|
49
|
+
interface ApiThread {
|
|
50
|
+
session_id: string;
|
|
51
|
+
title: string;
|
|
52
|
+
is_archived?: boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* POST /api/sessions
|
|
56
|
+
* Creates a new thread/session
|
|
57
|
+
*/
|
|
58
|
+
interface ApiCreateThreadResponse {
|
|
59
|
+
session_id: string;
|
|
60
|
+
title?: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Base SSE event - all events have session_id and type
|
|
64
|
+
*/
|
|
65
|
+
type ApiSSEEvent = {
|
|
66
|
+
type: "title_changed" | "tool_update" | "tool_complete" | "system_notice" | string;
|
|
67
|
+
session_id: string;
|
|
68
|
+
new_title?: string;
|
|
69
|
+
[key: string]: unknown;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Backend SystemEvent enum serializes as tagged JSON:
|
|
73
|
+
* - InlineCall: {"InlineCall": {"type": "wallet_tx_request", "payload": {...}}}
|
|
74
|
+
* - SystemNotice: {"SystemNotice": "message"}
|
|
75
|
+
* - SystemError: {"SystemError": "message"}
|
|
76
|
+
* - AsyncCallback: {"AsyncCallback": {...}} (not sent over HTTP)
|
|
77
|
+
*/
|
|
78
|
+
type ApiSystemEvent = {
|
|
79
|
+
InlineCall: {
|
|
80
|
+
type: string;
|
|
81
|
+
payload?: unknown;
|
|
82
|
+
[key: string]: unknown;
|
|
83
|
+
};
|
|
84
|
+
} | {
|
|
85
|
+
SystemNotice: string;
|
|
86
|
+
} | {
|
|
87
|
+
SystemError: string;
|
|
88
|
+
} | {
|
|
89
|
+
AsyncCallback: Record<string, unknown>;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
type UserState = {
|
|
93
|
+
address?: string;
|
|
94
|
+
chainId?: number;
|
|
95
|
+
isConnected: boolean;
|
|
96
|
+
ensName?: string;
|
|
97
|
+
};
|
|
98
|
+
declare function useUser(): {
|
|
99
|
+
user: UserState;
|
|
100
|
+
setUser: (data: Partial<UserState>) => void;
|
|
101
|
+
getUserState: () => UserState;
|
|
102
|
+
onUserStateChange: (callback: (user: UserState) => void) => () => void;
|
|
103
|
+
};
|
|
104
|
+
declare function UserContextProvider({ children }: {
|
|
105
|
+
children: ReactNode;
|
|
106
|
+
}): react_jsx_runtime.JSX.Element;
|
|
107
|
+
|
|
108
|
+
declare class BackendApi {
|
|
109
|
+
private readonly backendUrl;
|
|
110
|
+
private sseSubscriber;
|
|
111
|
+
constructor(backendUrl: string);
|
|
112
|
+
fetchState(sessionId: string, userState?: UserState): Promise<ApiStateResponse>;
|
|
113
|
+
postChatMessage(sessionId: string, message: string, namespace: string, publicKey?: string, apiKey?: string): Promise<ApiChatResponse>;
|
|
114
|
+
postSystemMessage(sessionId: string, message: string): Promise<ApiSystemResponse>;
|
|
115
|
+
postInterrupt(sessionId: string): Promise<ApiInterruptResponse>;
|
|
116
|
+
/**
|
|
117
|
+
* Subscribe to SSE updates for a session.
|
|
118
|
+
* Uses fetch streaming and reconnects on disconnects.
|
|
119
|
+
* Returns an unsubscribe function.
|
|
120
|
+
*/
|
|
121
|
+
subscribeSSE(sessionId: string, onUpdate: (event: ApiSSEEvent) => void, onError?: (error: unknown) => void): () => void;
|
|
122
|
+
fetchThreads(publicKey: string): Promise<ApiThread[]>;
|
|
123
|
+
fetchThread(sessionId: string): Promise<ApiThread>;
|
|
124
|
+
createThread(threadId: string, publicKey?: string): Promise<ApiCreateThreadResponse>;
|
|
125
|
+
archiveThread(sessionId: string): Promise<void>;
|
|
126
|
+
unarchiveThread(sessionId: string): Promise<void>;
|
|
127
|
+
deleteThread(sessionId: string): Promise<void>;
|
|
128
|
+
renameThread(sessionId: string, newTitle: string): Promise<void>;
|
|
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
|
+
}>;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
type AomiRuntimeProviderProps = {
|
|
150
|
+
children: ReactNode;
|
|
151
|
+
backendUrl?: string;
|
|
152
|
+
};
|
|
153
|
+
declare function AomiRuntimeProvider({ children, backendUrl, }: Readonly<AomiRuntimeProviderProps>): react_jsx_runtime.JSX.Element;
|
|
154
|
+
|
|
155
|
+
type ThreadContext = {
|
|
156
|
+
currentThreadId: string;
|
|
157
|
+
setCurrentThreadId: (id: string) => void;
|
|
158
|
+
threadViewKey: number;
|
|
159
|
+
bumpThreadViewKey: () => void;
|
|
160
|
+
allThreads: Map<string, ThreadMessageLike[]>;
|
|
161
|
+
setThreads: (updater: SetStateAction<Map<string, ThreadMessageLike[]>>) => void;
|
|
162
|
+
allThreadsMetadata: Map<string, ThreadMetadata>;
|
|
163
|
+
setThreadMetadata: (updater: SetStateAction<Map<string, ThreadMetadata>>) => void;
|
|
164
|
+
threadCnt: number;
|
|
165
|
+
setThreadCnt: (updater: SetStateAction<number>) => void;
|
|
166
|
+
getThreadMessages: (threadId: string) => ThreadMessageLike[];
|
|
167
|
+
setThreadMessages: (threadId: string, messages: ThreadMessageLike[]) => void;
|
|
168
|
+
getThreadMetadata: (threadId: string) => ThreadMetadata | undefined;
|
|
169
|
+
updateThreadMetadata: (threadId: string, updates: Partial<ThreadMetadata>) => void;
|
|
170
|
+
};
|
|
171
|
+
type ThreadContextProviderProps = {
|
|
172
|
+
children: ReactNode;
|
|
173
|
+
initialThreadId?: string;
|
|
174
|
+
};
|
|
175
|
+
declare function useThreadContext(): ThreadContext;
|
|
176
|
+
declare function ThreadContextProvider({ children, initialThreadId, }: ThreadContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
177
|
+
declare function useCurrentThreadMessages(): ThreadMessageLike[];
|
|
178
|
+
declare function useCurrentThreadMetadata(): ThreadMetadata | undefined;
|
|
179
|
+
|
|
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
|
+
};
|
|
191
|
+
type ThreadMetadata = {
|
|
192
|
+
title: string;
|
|
193
|
+
status: ThreadStatus;
|
|
194
|
+
lastActiveAt?: string | number;
|
|
195
|
+
/** Per-thread control state (model, namespace selection) */
|
|
196
|
+
control: ThreadControlState;
|
|
197
|
+
};
|
|
198
|
+
/** Create default control state for a new thread */
|
|
199
|
+
declare function initThreadControl(): ThreadControlState;
|
|
200
|
+
|
|
201
|
+
type InboundEvent = {
|
|
202
|
+
type: string;
|
|
203
|
+
sessionId: string;
|
|
204
|
+
payload?: unknown;
|
|
205
|
+
status: "pending" | "fetched";
|
|
206
|
+
timestamp: number;
|
|
207
|
+
};
|
|
208
|
+
type OutboundEvent = {
|
|
209
|
+
type: string;
|
|
210
|
+
sessionId: string;
|
|
211
|
+
payload: unknown;
|
|
212
|
+
timestamp: number;
|
|
213
|
+
};
|
|
214
|
+
type SSEStatus = "connected" | "connecting" | "disconnected";
|
|
215
|
+
type EventSubscriber = (event: InboundEvent) => void;
|
|
216
|
+
type EventBuffer = {
|
|
217
|
+
inboundQueue: InboundEvent[];
|
|
218
|
+
outboundQueue: OutboundEvent[];
|
|
219
|
+
sseStatus: SSEStatus;
|
|
220
|
+
lastEventId: string | null;
|
|
221
|
+
subscribers: Map<string, Set<EventSubscriber>>;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
type NotificationType = "notice" | "success" | "error" | "wallet";
|
|
225
|
+
type Notification$1 = {
|
|
226
|
+
id: string;
|
|
227
|
+
type: NotificationType;
|
|
228
|
+
title: string;
|
|
229
|
+
message?: string;
|
|
230
|
+
duration?: number;
|
|
231
|
+
timestamp: number;
|
|
232
|
+
};
|
|
233
|
+
type NotificationData = Omit<Notification$1, "id" | "timestamp">;
|
|
234
|
+
type NotificationContextApi = {
|
|
235
|
+
/** All active notifications */
|
|
236
|
+
notifications: Notification$1[];
|
|
237
|
+
/** Show a new notification */
|
|
238
|
+
showNotification: (params: NotificationData) => string;
|
|
239
|
+
/** Dismiss a notification by ID */
|
|
240
|
+
dismissNotification: (id: string) => void;
|
|
241
|
+
/** Clear all notifications */
|
|
242
|
+
clearAll: () => void;
|
|
243
|
+
};
|
|
244
|
+
declare function useNotification(): NotificationContextApi;
|
|
245
|
+
type NotificationContextProviderProps = {
|
|
246
|
+
children: ReactNode;
|
|
247
|
+
};
|
|
248
|
+
declare function NotificationContextProvider({ children, }: NotificationContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
249
|
+
|
|
250
|
+
type AomiRuntimeApi = {
|
|
251
|
+
/** Current user state (wallet connection, address, chain, etc.) */
|
|
252
|
+
user: UserState;
|
|
253
|
+
/** Get current user state synchronously (useful in callbacks) */
|
|
254
|
+
getUserState: () => UserState;
|
|
255
|
+
/** Update user state (partial updates merged with existing state) */
|
|
256
|
+
setUser: (data: Partial<UserState>) => void;
|
|
257
|
+
/** Subscribe to user state changes. Returns unsubscribe function. */
|
|
258
|
+
onUserStateChange: (callback: (user: UserState) => void) => () => void;
|
|
259
|
+
/** ID of the currently active thread */
|
|
260
|
+
currentThreadId: string;
|
|
261
|
+
/** Key that changes when thread view should remount (use for React key prop) */
|
|
262
|
+
threadViewKey: number;
|
|
263
|
+
/** Metadata for all threads (title, status, lastActiveAt) */
|
|
264
|
+
threadMetadata: Map<string, ThreadMetadata>;
|
|
265
|
+
/** Get metadata for a specific thread */
|
|
266
|
+
getThreadMetadata: (threadId: string) => ThreadMetadata | undefined;
|
|
267
|
+
/** Create a new thread and return its ID */
|
|
268
|
+
createThread: () => Promise<string>;
|
|
269
|
+
/** Delete a thread by ID */
|
|
270
|
+
deleteThread: (threadId: string) => Promise<void>;
|
|
271
|
+
/** Rename a thread */
|
|
272
|
+
renameThread: (threadId: string, title: string) => Promise<void>;
|
|
273
|
+
/** Archive a thread */
|
|
274
|
+
archiveThread: (threadId: string) => Promise<void>;
|
|
275
|
+
/** Switch to a thread. If thread doesn't exist, creates a new one. */
|
|
276
|
+
selectThread: (threadId: string) => void;
|
|
277
|
+
/** Whether the assistant is currently generating a response */
|
|
278
|
+
isRunning: boolean;
|
|
279
|
+
/** Get messages for a thread (defaults to currentThreadId) */
|
|
280
|
+
getMessages: (threadId?: string) => ThreadMessageLike[];
|
|
281
|
+
/** Send a message to the current thread */
|
|
282
|
+
sendMessage: (text: string) => Promise<void>;
|
|
283
|
+
/** Cancel the current generation */
|
|
284
|
+
cancelGeneration: () => void;
|
|
285
|
+
/** All active notifications */
|
|
286
|
+
notifications: Notification$1[];
|
|
287
|
+
/** Show a notification. Returns the notification ID. */
|
|
288
|
+
showNotification: (params: NotificationData) => string;
|
|
289
|
+
/** Dismiss a notification by ID */
|
|
290
|
+
dismissNotification: (id: string) => void;
|
|
291
|
+
/** Clear all notifications */
|
|
292
|
+
clearAllNotifications: () => void;
|
|
293
|
+
/** Subscribe to inbound events by type. Returns unsubscribe function. */
|
|
294
|
+
subscribe: (type: string, callback: EventSubscriber) => () => void;
|
|
295
|
+
/** Send a system command to the backend */
|
|
296
|
+
sendSystemCommand: (event: Omit<OutboundEvent, "timestamp">) => void;
|
|
297
|
+
/** Current SSE connection status */
|
|
298
|
+
sseStatus: SSEStatus;
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* Unified hook that provides access to all Aomi runtime APIs.
|
|
302
|
+
*
|
|
303
|
+
* This is the primary way to interact with the Aomi runtime from consumer code.
|
|
304
|
+
* It combines user, thread, chat, notification, and event APIs into a single interface.
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* ```tsx
|
|
308
|
+
* function MyComponent() {
|
|
309
|
+
* const aomi = useAomiRuntime();
|
|
310
|
+
*
|
|
311
|
+
* // User API
|
|
312
|
+
* const { user, setUser } = aomi;
|
|
313
|
+
*
|
|
314
|
+
* // Thread API
|
|
315
|
+
* const { currentThreadId, createThread, selectThread } = aomi;
|
|
316
|
+
*
|
|
317
|
+
* // Chat API
|
|
318
|
+
* const { isRunning, sendMessage, cancelGeneration } = aomi;
|
|
319
|
+
*
|
|
320
|
+
* // Notification API
|
|
321
|
+
* const { showNotification } = aomi;
|
|
322
|
+
*
|
|
323
|
+
* // Event API
|
|
324
|
+
* const { subscribe, sendSystemCommand } = aomi;
|
|
325
|
+
* }
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
declare function useAomiRuntime(): AomiRuntimeApi;
|
|
329
|
+
|
|
330
|
+
type EventContext = {
|
|
331
|
+
/** Subscribe to inbound events by type. Returns unsubscribe function. */
|
|
332
|
+
subscribe: (type: string, callback: EventSubscriber) => () => void;
|
|
333
|
+
/** Send an outbound event to backend immediately */
|
|
334
|
+
sendOutboundSystem: (event: Omit<OutboundEvent, "timestamp">) => void;
|
|
335
|
+
/** Dispatch system events from HTTP polling into the event buffer */
|
|
336
|
+
dispatchInboundSystem: (sessionId: string, events: ApiSystemEvent[]) => void;
|
|
337
|
+
/** Current SSE connection status */
|
|
338
|
+
sseStatus: SSEStatus;
|
|
339
|
+
};
|
|
340
|
+
declare function useEventContext(): EventContext;
|
|
341
|
+
type EventContextProviderProps = {
|
|
342
|
+
children: ReactNode;
|
|
343
|
+
backendApi: BackendApi;
|
|
344
|
+
sessionId: string;
|
|
345
|
+
};
|
|
346
|
+
declare function EventContextProvider({ children, backendApi, sessionId, }: EventContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
347
|
+
|
|
348
|
+
type WalletTxRequest = {
|
|
349
|
+
to: string;
|
|
350
|
+
value?: string;
|
|
351
|
+
data?: string;
|
|
352
|
+
chainId?: number;
|
|
353
|
+
};
|
|
354
|
+
type WalletTxComplete = {
|
|
355
|
+
txHash: string;
|
|
356
|
+
status: "success" | "failed";
|
|
357
|
+
amount?: string;
|
|
358
|
+
token?: string;
|
|
359
|
+
};
|
|
360
|
+
type WalletConnectionStatus = "connected" | "disconnected";
|
|
361
|
+
type WalletHandlerConfig = {
|
|
362
|
+
sessionId: string;
|
|
363
|
+
onTxRequest?: (request: WalletTxRequest) => void;
|
|
364
|
+
};
|
|
365
|
+
type WalletHanderApi = {
|
|
366
|
+
/** Send transaction completion event to backend */
|
|
367
|
+
sendTxComplete: (tx: WalletTxComplete) => void;
|
|
368
|
+
/** Send wallet connection status change and update user state */
|
|
369
|
+
sendConnectionChange: (status: WalletConnectionStatus, address?: string, chainId?: number) => void;
|
|
370
|
+
/** Pending transaction requests from AI */
|
|
371
|
+
pendingTxRequests: WalletTxRequest[];
|
|
372
|
+
/** Clear a pending request after handling */
|
|
373
|
+
clearTxRequest: (index: number) => void;
|
|
374
|
+
};
|
|
375
|
+
declare function useWalletHandler({ sessionId, onTxRequest, }: WalletHandlerConfig): WalletHanderApi;
|
|
376
|
+
|
|
377
|
+
type Notification = {
|
|
378
|
+
id: string;
|
|
379
|
+
type: string;
|
|
380
|
+
title: string;
|
|
381
|
+
body?: unknown;
|
|
382
|
+
handled: boolean;
|
|
383
|
+
timestamp: number;
|
|
384
|
+
sessionId: string;
|
|
385
|
+
};
|
|
386
|
+
type NotificationHandlerConfig = {
|
|
387
|
+
/** Callback when new notification arrives */
|
|
388
|
+
onNotification?: (notification: Notification) => void;
|
|
389
|
+
};
|
|
390
|
+
type NotificationApi = {
|
|
391
|
+
/** All notifications */
|
|
392
|
+
notifications: Notification[];
|
|
393
|
+
/** Unhandled count */
|
|
394
|
+
unhandledCount: number;
|
|
395
|
+
/** Mark notification as handled */
|
|
396
|
+
markDone: (id: string) => void;
|
|
397
|
+
};
|
|
398
|
+
declare function useNotificationHandler({ onNotification, }?: NotificationHandlerConfig): NotificationApi;
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Utility function to merge Tailwind CSS classes with conflict resolution.
|
|
402
|
+
* Combines clsx for conditional classes and tailwind-merge for deduplication.
|
|
403
|
+
*/
|
|
404
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
405
|
+
/**
|
|
406
|
+
* User configuration props for footer components.
|
|
407
|
+
* Provides user state and setter from UserContext.
|
|
408
|
+
*/
|
|
409
|
+
type UserConfig = {
|
|
410
|
+
user: UserState;
|
|
411
|
+
setUser: (data: Partial<UserState>) => void;
|
|
412
|
+
};
|
|
413
|
+
declare const getNetworkName: (chainId: number | string | undefined) => string;
|
|
414
|
+
declare const formatAddress: (addr?: string) => string;
|
|
415
|
+
|
|
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 };
|