@aomi-labs/react 0.3.0 → 0.3.1
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/README.md +142 -0
- package/dist/index.cjs +199 -607
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -151
- package/dist/index.d.ts +26 -151
- package/dist/index.js +200 -601
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,93 +1,15 @@
|
|
|
1
|
+
import { AomiSystemEvent, AomiClient } from '@aomi-labs/client';
|
|
2
|
+
export { AomiChatResponse, AomiClient, AomiClientOptions, AomiCreateThreadResponse, AomiInterruptResponse, AomiMessage, AomiSSEEvent, AomiStateResponse, AomiSystemEvent, AomiSystemResponse, AomiThread } from '@aomi-labs/client';
|
|
1
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
4
|
import { ReactNode, SetStateAction } from 'react';
|
|
3
5
|
import { ThreadMessageLike } from '@assistant-ui/react';
|
|
4
6
|
import { ClassValue } from 'clsx';
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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>;
|
|
8
|
+
type AomiRuntimeProviderProps = {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
backendUrl?: string;
|
|
90
11
|
};
|
|
12
|
+
declare function AomiRuntimeProvider({ children, backendUrl, }: Readonly<AomiRuntimeProviderProps>): react_jsx_runtime.JSX.Element;
|
|
91
13
|
|
|
92
14
|
type UserState = {
|
|
93
15
|
address?: string;
|
|
@@ -105,53 +27,6 @@ declare function UserContextProvider({ children }: {
|
|
|
105
27
|
children: ReactNode;
|
|
106
28
|
}): react_jsx_runtime.JSX.Element;
|
|
107
29
|
|
|
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, userState?: UserState): 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
30
|
type ThreadContext = {
|
|
156
31
|
currentThreadId: string;
|
|
157
32
|
setCurrentThreadId: (id: string) => void;
|
|
@@ -181,8 +56,8 @@ type ThreadStatus = "regular" | "archived";
|
|
|
181
56
|
type ThreadControlState = {
|
|
182
57
|
/** Selected model for this thread (human-readable label) */
|
|
183
58
|
model: string | null;
|
|
184
|
-
/** Selected
|
|
185
|
-
|
|
59
|
+
/** Selected app for this thread */
|
|
60
|
+
app: string | null;
|
|
186
61
|
/** Whether control state has changed but chat hasn't started yet */
|
|
187
62
|
controlDirty: boolean;
|
|
188
63
|
/** Whether this thread is currently processing (assistant generating) */
|
|
@@ -192,7 +67,7 @@ type ThreadMetadata = {
|
|
|
192
67
|
title: string;
|
|
193
68
|
status: ThreadStatus;
|
|
194
69
|
lastActiveAt?: string | number;
|
|
195
|
-
/** Per-thread control state (model,
|
|
70
|
+
/** Per-thread control state (model, app selection) */
|
|
196
71
|
control: ThreadControlState;
|
|
197
72
|
};
|
|
198
73
|
/** Create default control state for a new thread */
|
|
@@ -398,17 +273,17 @@ type EventContext = {
|
|
|
398
273
|
/** Send an outbound event to backend immediately */
|
|
399
274
|
sendOutboundSystem: (event: Omit<OutboundEvent, "timestamp">) => Promise<void>;
|
|
400
275
|
/** Dispatch system events from HTTP polling into the event buffer */
|
|
401
|
-
dispatchInboundSystem: (sessionId: string, events:
|
|
276
|
+
dispatchInboundSystem: (sessionId: string, events: AomiSystemEvent[]) => void;
|
|
402
277
|
/** Current SSE connection status */
|
|
403
278
|
sseStatus: SSEStatus;
|
|
404
279
|
};
|
|
405
280
|
declare function useEventContext(): EventContext;
|
|
406
281
|
type EventContextProviderProps = {
|
|
407
282
|
children: ReactNode;
|
|
408
|
-
|
|
283
|
+
aomiClient: AomiClient;
|
|
409
284
|
sessionId: string;
|
|
410
285
|
};
|
|
411
|
-
declare function EventContextProvider({ children,
|
|
286
|
+
declare function EventContextProvider({ children, aomiClient, sessionId, }: EventContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
412
287
|
|
|
413
288
|
type Notification = {
|
|
414
289
|
id: string;
|
|
@@ -465,28 +340,28 @@ type ControlState = {
|
|
|
465
340
|
apiKey: string | null;
|
|
466
341
|
/** Available models fetched from backend */
|
|
467
342
|
availableModels: string[];
|
|
468
|
-
/** Authorized
|
|
469
|
-
|
|
343
|
+
/** Authorized apps fetched from backend */
|
|
344
|
+
authorizedApps: string[];
|
|
470
345
|
/** Default model (first from availableModels) */
|
|
471
346
|
defaultModel: string | null;
|
|
472
|
-
/** Default
|
|
473
|
-
|
|
347
|
+
/** Default app (from authorizedApps) */
|
|
348
|
+
defaultApp: string | null;
|
|
474
349
|
};
|
|
475
350
|
type ControlContextApi = {
|
|
476
|
-
/** Global state (apiKey, available models/
|
|
351
|
+
/** Global state (apiKey, available models/apps) */
|
|
477
352
|
state: ControlState;
|
|
478
353
|
/** Update global state (apiKey only) */
|
|
479
354
|
setApiKey: (apiKey: string | null) => void;
|
|
480
355
|
/** Fetch available models from backend */
|
|
481
356
|
getAvailableModels: () => Promise<string[]>;
|
|
482
|
-
/** Fetch authorized
|
|
483
|
-
|
|
357
|
+
/** Fetch authorized apps from backend */
|
|
358
|
+
getAuthorizedApps: () => Promise<string[]>;
|
|
484
359
|
/** Get current thread's control state */
|
|
485
360
|
getCurrentThreadControl: () => ThreadControlState;
|
|
486
361
|
/** Select a model for the current thread (updates metadata + calls backend) */
|
|
487
362
|
onModelSelect: (model: string) => Promise<void>;
|
|
488
|
-
/** Select
|
|
489
|
-
|
|
363
|
+
/** Select an app for the current thread (updates metadata only) */
|
|
364
|
+
onAppSelect: (app: string) => void;
|
|
490
365
|
/** Whether the current thread is processing (disables control switching) */
|
|
491
366
|
isProcessing: boolean;
|
|
492
367
|
/** Mark control state as synced (called after chat starts) */
|
|
@@ -495,16 +370,16 @@ type ControlContextApi = {
|
|
|
495
370
|
getControlState: () => ControlState;
|
|
496
371
|
/** Subscribe to global state changes */
|
|
497
372
|
onControlStateChange: (callback: (state: ControlState) => void) => () => void;
|
|
498
|
-
/** @deprecated Use getCurrentThreadControl().
|
|
373
|
+
/** @deprecated Use getCurrentThreadControl().app instead */
|
|
499
374
|
setState: (updates: Partial<{
|
|
500
|
-
|
|
375
|
+
app: string | null;
|
|
501
376
|
apiKey: string | null;
|
|
502
377
|
}>) => void;
|
|
503
378
|
};
|
|
504
379
|
declare function useControl(): ControlContextApi;
|
|
505
380
|
type ControlContextProviderProps = {
|
|
506
381
|
children: ReactNode;
|
|
507
|
-
|
|
382
|
+
aomiClient: AomiClient;
|
|
508
383
|
sessionId: string;
|
|
509
384
|
publicKey?: string;
|
|
510
385
|
/** Get metadata for a thread */
|
|
@@ -512,6 +387,6 @@ type ControlContextProviderProps = {
|
|
|
512
387
|
/** Update metadata for a thread */
|
|
513
388
|
updateThreadMetadata: (threadId: string, updates: Partial<ThreadMetadata>) => void;
|
|
514
389
|
};
|
|
515
|
-
declare function ControlContextProvider({ children,
|
|
390
|
+
declare function ControlContextProvider({ children, aomiClient, sessionId, publicKey, getThreadMetadata, updateThreadMetadata, }: ControlContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
516
391
|
|
|
517
|
-
export { type
|
|
392
|
+
export { type AomiRuntimeApi, AomiRuntimeProvider, type AomiRuntimeProviderProps, type ChainInfo, type ControlContextApi, ControlContextProvider, type ControlContextProviderProps, type ControlState, type EventBuffer, 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, type OutboundEvent, type SSEStatus, SUPPORTED_CHAINS, type NotificationData as ShowNotificationParams, type ThreadContext, ThreadContextProvider, type ThreadControlState, type ThreadMetadata, type UserConfig, UserContextProvider, type UserState, type WalletBuffer, type WalletEip712Payload, type WalletHandlerApi, type WalletHandlerConfig, type WalletRequest, type WalletRequestKind, type WalletRequestResult, type WalletRequestStatus, type WalletTxPayload, cn, formatAddress, getChainInfo, getNetworkName, initThreadControl, useAomiRuntime, useControl, useCurrentThreadMessages, useCurrentThreadMetadata, useEventContext, useNotification, useNotificationHandler, useThreadContext, useUser, useWalletHandler };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,93 +1,15 @@
|
|
|
1
|
+
import { AomiSystemEvent, AomiClient } from '@aomi-labs/client';
|
|
2
|
+
export { AomiChatResponse, AomiClient, AomiClientOptions, AomiCreateThreadResponse, AomiInterruptResponse, AomiMessage, AomiSSEEvent, AomiStateResponse, AomiSystemEvent, AomiSystemResponse, AomiThread } from '@aomi-labs/client';
|
|
1
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
4
|
import { ReactNode, SetStateAction } from 'react';
|
|
3
5
|
import { ThreadMessageLike } from '@assistant-ui/react';
|
|
4
6
|
import { ClassValue } from 'clsx';
|
|
5
7
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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>;
|
|
8
|
+
type AomiRuntimeProviderProps = {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
backendUrl?: string;
|
|
90
11
|
};
|
|
12
|
+
declare function AomiRuntimeProvider({ children, backendUrl, }: Readonly<AomiRuntimeProviderProps>): react_jsx_runtime.JSX.Element;
|
|
91
13
|
|
|
92
14
|
type UserState = {
|
|
93
15
|
address?: string;
|
|
@@ -105,53 +27,6 @@ declare function UserContextProvider({ children }: {
|
|
|
105
27
|
children: ReactNode;
|
|
106
28
|
}): react_jsx_runtime.JSX.Element;
|
|
107
29
|
|
|
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, userState?: UserState): 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
30
|
type ThreadContext = {
|
|
156
31
|
currentThreadId: string;
|
|
157
32
|
setCurrentThreadId: (id: string) => void;
|
|
@@ -181,8 +56,8 @@ type ThreadStatus = "regular" | "archived";
|
|
|
181
56
|
type ThreadControlState = {
|
|
182
57
|
/** Selected model for this thread (human-readable label) */
|
|
183
58
|
model: string | null;
|
|
184
|
-
/** Selected
|
|
185
|
-
|
|
59
|
+
/** Selected app for this thread */
|
|
60
|
+
app: string | null;
|
|
186
61
|
/** Whether control state has changed but chat hasn't started yet */
|
|
187
62
|
controlDirty: boolean;
|
|
188
63
|
/** Whether this thread is currently processing (assistant generating) */
|
|
@@ -192,7 +67,7 @@ type ThreadMetadata = {
|
|
|
192
67
|
title: string;
|
|
193
68
|
status: ThreadStatus;
|
|
194
69
|
lastActiveAt?: string | number;
|
|
195
|
-
/** Per-thread control state (model,
|
|
70
|
+
/** Per-thread control state (model, app selection) */
|
|
196
71
|
control: ThreadControlState;
|
|
197
72
|
};
|
|
198
73
|
/** Create default control state for a new thread */
|
|
@@ -398,17 +273,17 @@ type EventContext = {
|
|
|
398
273
|
/** Send an outbound event to backend immediately */
|
|
399
274
|
sendOutboundSystem: (event: Omit<OutboundEvent, "timestamp">) => Promise<void>;
|
|
400
275
|
/** Dispatch system events from HTTP polling into the event buffer */
|
|
401
|
-
dispatchInboundSystem: (sessionId: string, events:
|
|
276
|
+
dispatchInboundSystem: (sessionId: string, events: AomiSystemEvent[]) => void;
|
|
402
277
|
/** Current SSE connection status */
|
|
403
278
|
sseStatus: SSEStatus;
|
|
404
279
|
};
|
|
405
280
|
declare function useEventContext(): EventContext;
|
|
406
281
|
type EventContextProviderProps = {
|
|
407
282
|
children: ReactNode;
|
|
408
|
-
|
|
283
|
+
aomiClient: AomiClient;
|
|
409
284
|
sessionId: string;
|
|
410
285
|
};
|
|
411
|
-
declare function EventContextProvider({ children,
|
|
286
|
+
declare function EventContextProvider({ children, aomiClient, sessionId, }: EventContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
412
287
|
|
|
413
288
|
type Notification = {
|
|
414
289
|
id: string;
|
|
@@ -465,28 +340,28 @@ type ControlState = {
|
|
|
465
340
|
apiKey: string | null;
|
|
466
341
|
/** Available models fetched from backend */
|
|
467
342
|
availableModels: string[];
|
|
468
|
-
/** Authorized
|
|
469
|
-
|
|
343
|
+
/** Authorized apps fetched from backend */
|
|
344
|
+
authorizedApps: string[];
|
|
470
345
|
/** Default model (first from availableModels) */
|
|
471
346
|
defaultModel: string | null;
|
|
472
|
-
/** Default
|
|
473
|
-
|
|
347
|
+
/** Default app (from authorizedApps) */
|
|
348
|
+
defaultApp: string | null;
|
|
474
349
|
};
|
|
475
350
|
type ControlContextApi = {
|
|
476
|
-
/** Global state (apiKey, available models/
|
|
351
|
+
/** Global state (apiKey, available models/apps) */
|
|
477
352
|
state: ControlState;
|
|
478
353
|
/** Update global state (apiKey only) */
|
|
479
354
|
setApiKey: (apiKey: string | null) => void;
|
|
480
355
|
/** Fetch available models from backend */
|
|
481
356
|
getAvailableModels: () => Promise<string[]>;
|
|
482
|
-
/** Fetch authorized
|
|
483
|
-
|
|
357
|
+
/** Fetch authorized apps from backend */
|
|
358
|
+
getAuthorizedApps: () => Promise<string[]>;
|
|
484
359
|
/** Get current thread's control state */
|
|
485
360
|
getCurrentThreadControl: () => ThreadControlState;
|
|
486
361
|
/** Select a model for the current thread (updates metadata + calls backend) */
|
|
487
362
|
onModelSelect: (model: string) => Promise<void>;
|
|
488
|
-
/** Select
|
|
489
|
-
|
|
363
|
+
/** Select an app for the current thread (updates metadata only) */
|
|
364
|
+
onAppSelect: (app: string) => void;
|
|
490
365
|
/** Whether the current thread is processing (disables control switching) */
|
|
491
366
|
isProcessing: boolean;
|
|
492
367
|
/** Mark control state as synced (called after chat starts) */
|
|
@@ -495,16 +370,16 @@ type ControlContextApi = {
|
|
|
495
370
|
getControlState: () => ControlState;
|
|
496
371
|
/** Subscribe to global state changes */
|
|
497
372
|
onControlStateChange: (callback: (state: ControlState) => void) => () => void;
|
|
498
|
-
/** @deprecated Use getCurrentThreadControl().
|
|
373
|
+
/** @deprecated Use getCurrentThreadControl().app instead */
|
|
499
374
|
setState: (updates: Partial<{
|
|
500
|
-
|
|
375
|
+
app: string | null;
|
|
501
376
|
apiKey: string | null;
|
|
502
377
|
}>) => void;
|
|
503
378
|
};
|
|
504
379
|
declare function useControl(): ControlContextApi;
|
|
505
380
|
type ControlContextProviderProps = {
|
|
506
381
|
children: ReactNode;
|
|
507
|
-
|
|
382
|
+
aomiClient: AomiClient;
|
|
508
383
|
sessionId: string;
|
|
509
384
|
publicKey?: string;
|
|
510
385
|
/** Get metadata for a thread */
|
|
@@ -512,6 +387,6 @@ type ControlContextProviderProps = {
|
|
|
512
387
|
/** Update metadata for a thread */
|
|
513
388
|
updateThreadMetadata: (threadId: string, updates: Partial<ThreadMetadata>) => void;
|
|
514
389
|
};
|
|
515
|
-
declare function ControlContextProvider({ children,
|
|
390
|
+
declare function ControlContextProvider({ children, aomiClient, sessionId, publicKey, getThreadMetadata, updateThreadMetadata, }: ControlContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
516
391
|
|
|
517
|
-
export { type
|
|
392
|
+
export { type AomiRuntimeApi, AomiRuntimeProvider, type AomiRuntimeProviderProps, type ChainInfo, type ControlContextApi, ControlContextProvider, type ControlContextProviderProps, type ControlState, type EventBuffer, 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, type OutboundEvent, type SSEStatus, SUPPORTED_CHAINS, type NotificationData as ShowNotificationParams, type ThreadContext, ThreadContextProvider, type ThreadControlState, type ThreadMetadata, type UserConfig, UserContextProvider, type UserState, type WalletBuffer, type WalletEip712Payload, type WalletHandlerApi, type WalletHandlerConfig, type WalletRequest, type WalletRequestKind, type WalletRequestResult, type WalletRequestStatus, type WalletTxPayload, cn, formatAddress, getChainInfo, getNetworkName, initThreadControl, useAomiRuntime, useControl, useCurrentThreadMessages, useCurrentThreadMetadata, useEventContext, useNotification, useNotificationHandler, useThreadContext, useUser, useWalletHandler };
|