@aomi-labs/react 0.3.0 → 0.3.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/README.md +142 -0
- package/dist/index.cjs +179 -616
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -171
- package/dist/index.d.ts +28 -171
- package/dist/index.js +182 -610
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,93 +1,15 @@
|
|
|
1
|
+
import { WalletTxPayload, WalletEip712Payload, AomiSystemEvent, AomiClient } from '@aomi-labs/client';
|
|
2
|
+
export { AomiChatResponse, AomiClient, AomiClientOptions, AomiCreateThreadResponse, AomiInterruptResponse, AomiMessage, AomiSSEEvent, AomiStateResponse, AomiSystemEvent, AomiSystemResponse, AomiThread, WalletEip712Payload, WalletTxPayload, toViemSignTypedDataArgs } 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 */
|
|
@@ -248,26 +123,6 @@ type NotificationContextProviderProps = {
|
|
|
248
123
|
declare function NotificationContextProvider({ children, }: NotificationContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
249
124
|
|
|
250
125
|
type WalletRequestKind = "transaction" | "eip712_sign";
|
|
251
|
-
type WalletTxPayload = {
|
|
252
|
-
to: string;
|
|
253
|
-
value?: string;
|
|
254
|
-
data?: string;
|
|
255
|
-
chainId?: number;
|
|
256
|
-
};
|
|
257
|
-
type WalletEip712Payload = {
|
|
258
|
-
typed_data?: {
|
|
259
|
-
domain?: {
|
|
260
|
-
chainId?: number | string;
|
|
261
|
-
};
|
|
262
|
-
types?: Record<string, Array<{
|
|
263
|
-
name: string;
|
|
264
|
-
type: string;
|
|
265
|
-
}>>;
|
|
266
|
-
primaryType?: string;
|
|
267
|
-
message?: Record<string, unknown>;
|
|
268
|
-
};
|
|
269
|
-
description?: string;
|
|
270
|
-
};
|
|
271
126
|
type WalletRequestStatus = "pending" | "processing";
|
|
272
127
|
type WalletRequest = {
|
|
273
128
|
id: string;
|
|
@@ -398,17 +253,17 @@ type EventContext = {
|
|
|
398
253
|
/** Send an outbound event to backend immediately */
|
|
399
254
|
sendOutboundSystem: (event: Omit<OutboundEvent, "timestamp">) => Promise<void>;
|
|
400
255
|
/** Dispatch system events from HTTP polling into the event buffer */
|
|
401
|
-
dispatchInboundSystem: (sessionId: string, events:
|
|
256
|
+
dispatchInboundSystem: (sessionId: string, events: AomiSystemEvent[]) => void;
|
|
402
257
|
/** Current SSE connection status */
|
|
403
258
|
sseStatus: SSEStatus;
|
|
404
259
|
};
|
|
405
260
|
declare function useEventContext(): EventContext;
|
|
406
261
|
type EventContextProviderProps = {
|
|
407
262
|
children: ReactNode;
|
|
408
|
-
|
|
263
|
+
aomiClient: AomiClient;
|
|
409
264
|
sessionId: string;
|
|
410
265
|
};
|
|
411
|
-
declare function EventContextProvider({ children,
|
|
266
|
+
declare function EventContextProvider({ children, aomiClient, sessionId, }: EventContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
412
267
|
|
|
413
268
|
type Notification = {
|
|
414
269
|
id: string;
|
|
@@ -465,28 +320,30 @@ type ControlState = {
|
|
|
465
320
|
apiKey: string | null;
|
|
466
321
|
/** Available models fetched from backend */
|
|
467
322
|
availableModels: string[];
|
|
468
|
-
/** Authorized
|
|
469
|
-
|
|
323
|
+
/** Authorized apps fetched from backend */
|
|
324
|
+
authorizedApps: string[];
|
|
470
325
|
/** Default model (first from availableModels) */
|
|
471
326
|
defaultModel: string | null;
|
|
472
|
-
/** Default
|
|
473
|
-
|
|
327
|
+
/** Default app (from authorizedApps) */
|
|
328
|
+
defaultApp: string | null;
|
|
474
329
|
};
|
|
475
330
|
type ControlContextApi = {
|
|
476
|
-
/** Global state (apiKey, available models/
|
|
331
|
+
/** Global state (apiKey, available models/apps) */
|
|
477
332
|
state: ControlState;
|
|
478
333
|
/** Update global state (apiKey only) */
|
|
479
334
|
setApiKey: (apiKey: string | null) => void;
|
|
480
335
|
/** Fetch available models from backend */
|
|
481
336
|
getAvailableModels: () => Promise<string[]>;
|
|
482
|
-
/** Fetch authorized
|
|
483
|
-
|
|
337
|
+
/** Fetch authorized apps from backend */
|
|
338
|
+
getAuthorizedApps: () => Promise<string[]>;
|
|
484
339
|
/** Get current thread's control state */
|
|
485
340
|
getCurrentThreadControl: () => ThreadControlState;
|
|
341
|
+
/** Get the current thread's effective app after auth fallback */
|
|
342
|
+
getCurrentThreadApp: () => string;
|
|
486
343
|
/** Select a model for the current thread (updates metadata + calls backend) */
|
|
487
344
|
onModelSelect: (model: string) => Promise<void>;
|
|
488
|
-
/** Select
|
|
489
|
-
|
|
345
|
+
/** Select an app for the current thread (updates metadata only) */
|
|
346
|
+
onAppSelect: (app: string) => void;
|
|
490
347
|
/** Whether the current thread is processing (disables control switching) */
|
|
491
348
|
isProcessing: boolean;
|
|
492
349
|
/** Mark control state as synced (called after chat starts) */
|
|
@@ -495,16 +352,16 @@ type ControlContextApi = {
|
|
|
495
352
|
getControlState: () => ControlState;
|
|
496
353
|
/** Subscribe to global state changes */
|
|
497
354
|
onControlStateChange: (callback: (state: ControlState) => void) => () => void;
|
|
498
|
-
/** @deprecated Use getCurrentThreadControl().
|
|
355
|
+
/** @deprecated Use getCurrentThreadControl().app instead */
|
|
499
356
|
setState: (updates: Partial<{
|
|
500
|
-
|
|
357
|
+
app: string | null;
|
|
501
358
|
apiKey: string | null;
|
|
502
359
|
}>) => void;
|
|
503
360
|
};
|
|
504
361
|
declare function useControl(): ControlContextApi;
|
|
505
362
|
type ControlContextProviderProps = {
|
|
506
363
|
children: ReactNode;
|
|
507
|
-
|
|
364
|
+
aomiClient: AomiClient;
|
|
508
365
|
sessionId: string;
|
|
509
366
|
publicKey?: string;
|
|
510
367
|
/** Get metadata for a thread */
|
|
@@ -512,6 +369,6 @@ type ControlContextProviderProps = {
|
|
|
512
369
|
/** Update metadata for a thread */
|
|
513
370
|
updateThreadMetadata: (threadId: string, updates: Partial<ThreadMetadata>) => void;
|
|
514
371
|
};
|
|
515
|
-
declare function ControlContextProvider({ children,
|
|
372
|
+
declare function ControlContextProvider({ children, aomiClient, sessionId, publicKey, getThreadMetadata, updateThreadMetadata, }: ControlContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
516
373
|
|
|
517
|
-
export { type
|
|
374
|
+
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 WalletHandlerApi, type WalletHandlerConfig, type WalletRequest, type WalletRequestKind, type WalletRequestResult, type WalletRequestStatus, 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 { WalletTxPayload, WalletEip712Payload, AomiSystemEvent, AomiClient } from '@aomi-labs/client';
|
|
2
|
+
export { AomiChatResponse, AomiClient, AomiClientOptions, AomiCreateThreadResponse, AomiInterruptResponse, AomiMessage, AomiSSEEvent, AomiStateResponse, AomiSystemEvent, AomiSystemResponse, AomiThread, WalletEip712Payload, WalletTxPayload, toViemSignTypedDataArgs } 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 */
|
|
@@ -248,26 +123,6 @@ type NotificationContextProviderProps = {
|
|
|
248
123
|
declare function NotificationContextProvider({ children, }: NotificationContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
249
124
|
|
|
250
125
|
type WalletRequestKind = "transaction" | "eip712_sign";
|
|
251
|
-
type WalletTxPayload = {
|
|
252
|
-
to: string;
|
|
253
|
-
value?: string;
|
|
254
|
-
data?: string;
|
|
255
|
-
chainId?: number;
|
|
256
|
-
};
|
|
257
|
-
type WalletEip712Payload = {
|
|
258
|
-
typed_data?: {
|
|
259
|
-
domain?: {
|
|
260
|
-
chainId?: number | string;
|
|
261
|
-
};
|
|
262
|
-
types?: Record<string, Array<{
|
|
263
|
-
name: string;
|
|
264
|
-
type: string;
|
|
265
|
-
}>>;
|
|
266
|
-
primaryType?: string;
|
|
267
|
-
message?: Record<string, unknown>;
|
|
268
|
-
};
|
|
269
|
-
description?: string;
|
|
270
|
-
};
|
|
271
126
|
type WalletRequestStatus = "pending" | "processing";
|
|
272
127
|
type WalletRequest = {
|
|
273
128
|
id: string;
|
|
@@ -398,17 +253,17 @@ type EventContext = {
|
|
|
398
253
|
/** Send an outbound event to backend immediately */
|
|
399
254
|
sendOutboundSystem: (event: Omit<OutboundEvent, "timestamp">) => Promise<void>;
|
|
400
255
|
/** Dispatch system events from HTTP polling into the event buffer */
|
|
401
|
-
dispatchInboundSystem: (sessionId: string, events:
|
|
256
|
+
dispatchInboundSystem: (sessionId: string, events: AomiSystemEvent[]) => void;
|
|
402
257
|
/** Current SSE connection status */
|
|
403
258
|
sseStatus: SSEStatus;
|
|
404
259
|
};
|
|
405
260
|
declare function useEventContext(): EventContext;
|
|
406
261
|
type EventContextProviderProps = {
|
|
407
262
|
children: ReactNode;
|
|
408
|
-
|
|
263
|
+
aomiClient: AomiClient;
|
|
409
264
|
sessionId: string;
|
|
410
265
|
};
|
|
411
|
-
declare function EventContextProvider({ children,
|
|
266
|
+
declare function EventContextProvider({ children, aomiClient, sessionId, }: EventContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
412
267
|
|
|
413
268
|
type Notification = {
|
|
414
269
|
id: string;
|
|
@@ -465,28 +320,30 @@ type ControlState = {
|
|
|
465
320
|
apiKey: string | null;
|
|
466
321
|
/** Available models fetched from backend */
|
|
467
322
|
availableModels: string[];
|
|
468
|
-
/** Authorized
|
|
469
|
-
|
|
323
|
+
/** Authorized apps fetched from backend */
|
|
324
|
+
authorizedApps: string[];
|
|
470
325
|
/** Default model (first from availableModels) */
|
|
471
326
|
defaultModel: string | null;
|
|
472
|
-
/** Default
|
|
473
|
-
|
|
327
|
+
/** Default app (from authorizedApps) */
|
|
328
|
+
defaultApp: string | null;
|
|
474
329
|
};
|
|
475
330
|
type ControlContextApi = {
|
|
476
|
-
/** Global state (apiKey, available models/
|
|
331
|
+
/** Global state (apiKey, available models/apps) */
|
|
477
332
|
state: ControlState;
|
|
478
333
|
/** Update global state (apiKey only) */
|
|
479
334
|
setApiKey: (apiKey: string | null) => void;
|
|
480
335
|
/** Fetch available models from backend */
|
|
481
336
|
getAvailableModels: () => Promise<string[]>;
|
|
482
|
-
/** Fetch authorized
|
|
483
|
-
|
|
337
|
+
/** Fetch authorized apps from backend */
|
|
338
|
+
getAuthorizedApps: () => Promise<string[]>;
|
|
484
339
|
/** Get current thread's control state */
|
|
485
340
|
getCurrentThreadControl: () => ThreadControlState;
|
|
341
|
+
/** Get the current thread's effective app after auth fallback */
|
|
342
|
+
getCurrentThreadApp: () => string;
|
|
486
343
|
/** Select a model for the current thread (updates metadata + calls backend) */
|
|
487
344
|
onModelSelect: (model: string) => Promise<void>;
|
|
488
|
-
/** Select
|
|
489
|
-
|
|
345
|
+
/** Select an app for the current thread (updates metadata only) */
|
|
346
|
+
onAppSelect: (app: string) => void;
|
|
490
347
|
/** Whether the current thread is processing (disables control switching) */
|
|
491
348
|
isProcessing: boolean;
|
|
492
349
|
/** Mark control state as synced (called after chat starts) */
|
|
@@ -495,16 +352,16 @@ type ControlContextApi = {
|
|
|
495
352
|
getControlState: () => ControlState;
|
|
496
353
|
/** Subscribe to global state changes */
|
|
497
354
|
onControlStateChange: (callback: (state: ControlState) => void) => () => void;
|
|
498
|
-
/** @deprecated Use getCurrentThreadControl().
|
|
355
|
+
/** @deprecated Use getCurrentThreadControl().app instead */
|
|
499
356
|
setState: (updates: Partial<{
|
|
500
|
-
|
|
357
|
+
app: string | null;
|
|
501
358
|
apiKey: string | null;
|
|
502
359
|
}>) => void;
|
|
503
360
|
};
|
|
504
361
|
declare function useControl(): ControlContextApi;
|
|
505
362
|
type ControlContextProviderProps = {
|
|
506
363
|
children: ReactNode;
|
|
507
|
-
|
|
364
|
+
aomiClient: AomiClient;
|
|
508
365
|
sessionId: string;
|
|
509
366
|
publicKey?: string;
|
|
510
367
|
/** Get metadata for a thread */
|
|
@@ -512,6 +369,6 @@ type ControlContextProviderProps = {
|
|
|
512
369
|
/** Update metadata for a thread */
|
|
513
370
|
updateThreadMetadata: (threadId: string, updates: Partial<ThreadMetadata>) => void;
|
|
514
371
|
};
|
|
515
|
-
declare function ControlContextProvider({ children,
|
|
372
|
+
declare function ControlContextProvider({ children, aomiClient, sessionId, publicKey, getThreadMetadata, updateThreadMetadata, }: ControlContextProviderProps): react_jsx_runtime.JSX.Element;
|
|
516
373
|
|
|
517
|
-
export { type
|
|
374
|
+
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 WalletHandlerApi, type WalletHandlerConfig, type WalletRequest, type WalletRequestKind, type WalletRequestResult, type WalletRequestStatus, cn, formatAddress, getChainInfo, getNetworkName, initThreadControl, useAomiRuntime, useControl, useCurrentThreadMessages, useCurrentThreadMetadata, useEventContext, useNotification, useNotificationHandler, useThreadContext, useUser, useWalletHandler };
|