@aomi-labs/react 0.1.0 → 0.2.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/dist/index.d.ts DELETED
@@ -1,208 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as react from 'react';
3
- import { ReactNode, SetStateAction } from 'react';
4
- import { ThreadMessageLike } from '@assistant-ui/react';
5
- import { ClassValue } from 'clsx';
6
-
7
- interface SessionMessage {
8
- sender?: string;
9
- content?: string;
10
- timestamp?: string;
11
- is_streaming?: boolean;
12
- tool_stream?: [string, string] | {
13
- topic?: unknown;
14
- content?: unknown;
15
- } | null;
16
- }
17
- interface SessionResponsePayload {
18
- messages?: SessionMessage[] | null;
19
- system_events?: unknown[] | null;
20
- title?: string | null;
21
- is_processing?: boolean;
22
- session_exists?: boolean;
23
- session_id?: string;
24
- pending_wallet_tx?: string | null;
25
- }
26
- type BackendSessionResponse = SessionResponsePayload;
27
- interface SystemResponsePayload {
28
- res?: SessionMessage | null;
29
- }
30
- interface BackendThreadMetadata {
31
- session_id: string;
32
- title: string;
33
- is_archived?: boolean;
34
- created_at?: string;
35
- updated_at?: string;
36
- last_active_at?: string;
37
- }
38
- interface CreateThreadResponse {
39
- session_id: string;
40
- title?: string;
41
- }
42
- type SystemUpdate = {
43
- type: "TitleChanged";
44
- data: {
45
- session_id: string;
46
- new_title: string;
47
- };
48
- };
49
- type SystemUpdateNotification = {
50
- type: "event_available";
51
- session_id: string;
52
- event_id: number;
53
- event_type: string;
54
- };
55
- type SystemEvent = Record<string, unknown> & {
56
- type: string;
57
- session_id: string;
58
- event_id: number;
59
- };
60
-
61
- declare class BackendApi {
62
- private readonly backendUrl;
63
- private connectionStatus;
64
- private eventSource;
65
- private updatesEventSources;
66
- constructor(backendUrl: string);
67
- fetchState(sessionId: string, options?: {
68
- signal?: AbortSignal;
69
- }): Promise<SessionResponsePayload>;
70
- postChatMessage(sessionId: string, message: string, publicKey?: string): Promise<SessionResponsePayload>;
71
- postSystemMessage(sessionId: string, message: string): Promise<SystemResponsePayload>;
72
- postInterrupt(sessionId: string): Promise<SessionResponsePayload>;
73
- disconnectSSE(): void;
74
- setConnectionStatus(on: boolean): void;
75
- connectSSE(sessionId: string, publicKey?: string): Promise<void>;
76
- private handleConnectionError;
77
- private subscribeToUpdatesInternal;
78
- subscribeToUpdates(sessionId: string, onUpdate: (update: SystemUpdateNotification) => void, onError?: (error: unknown) => void): () => void;
79
- fetchThreads(publicKey: string): Promise<BackendThreadMetadata[]>;
80
- createThread(publicKey?: string, title?: string): Promise<CreateThreadResponse>;
81
- archiveThread(sessionId: string): Promise<void>;
82
- unarchiveThread(sessionId: string): Promise<void>;
83
- deleteThread(sessionId: string): Promise<void>;
84
- renameThread(sessionId: string, newTitle: string): Promise<void>;
85
- fetchEventsAfter(sessionId: string, afterId?: number, limit?: number): Promise<SystemEvent[]>;
86
- subscribeToUpdatesWithNotification(sessionId: string, onUpdate: (update: SystemUpdateNotification) => void, onError?: (error: unknown) => void): () => void;
87
- }
88
-
89
- type WalletButtonState = {
90
- address?: string;
91
- chainId?: number;
92
- isConnected: boolean;
93
- ensName?: string;
94
- };
95
- type WalletFooterProps = {
96
- wallet: WalletButtonState;
97
- setWallet: (data: Partial<WalletButtonState>) => void;
98
- };
99
- type WalletTxRequestPayload = {
100
- to: string;
101
- value: string;
102
- data: string;
103
- gas?: string | null;
104
- gas_limit?: string | null;
105
- description?: string;
106
- topic?: string;
107
- timestamp?: string;
108
- };
109
- type WalletTxRequestContext = {
110
- sessionId: string;
111
- threadId: string;
112
- publicKey?: string;
113
- };
114
- type WalletTxRequestHandler = (request: WalletTxRequestPayload, context: WalletTxRequestContext) => Promise<string>;
115
- type Eip1193Provider = {
116
- request: (args: {
117
- method: string;
118
- params?: unknown[];
119
- }) => Promise<unknown>;
120
- };
121
- declare const getNetworkName: (chainId: number | string | undefined) => string;
122
- declare const formatAddress: (addr?: string) => string;
123
- declare function normalizeWalletError(error: unknown): {
124
- rejected: boolean;
125
- message: string;
126
- };
127
- declare function toHexQuantity(value: string): string;
128
- declare function pickInjectedProvider(publicKey?: string): Promise<Eip1193Provider | undefined>;
129
- type WalletSystemMessageEmitterProps = {
130
- wallet: WalletButtonState;
131
- };
132
- declare function WalletSystemMessageEmitter({ wallet, }: WalletSystemMessageEmitterProps): null;
133
-
134
- type AomiRuntimeProviderProps = {
135
- children: ReactNode;
136
- backendUrl?: string;
137
- publicKey?: string;
138
- onWalletTxRequest?: WalletTxRequestHandler;
139
- };
140
- declare function AomiRuntimeProvider({ children, backendUrl, publicKey, onWalletTxRequest, }: Readonly<AomiRuntimeProviderProps>): react_jsx_runtime.JSX.Element;
141
- declare function AomiRuntimeProviderWithNotifications(props: Readonly<AomiRuntimeProviderProps>): react_jsx_runtime.JSX.Element;
142
-
143
- type RuntimeActions = {
144
- sendSystemMessage: (message: string) => Promise<void>;
145
- };
146
- declare const RuntimeActionsProvider: react.Provider<RuntimeActions | undefined>;
147
- declare function useRuntimeActions(): RuntimeActions;
148
-
149
- type ThreadStatus = "regular" | "archived" | "pending";
150
- type ThreadMetadata = {
151
- title: string;
152
- status: ThreadStatus;
153
- lastActiveAt?: string | number;
154
- };
155
-
156
- type ThreadContext$1 = {
157
- currentThreadId: string;
158
- setCurrentThreadId: (id: string) => void;
159
- threadViewKey: number;
160
- bumpThreadViewKey: () => void;
161
- threads: Map<string, ThreadMessageLike[]>;
162
- setThreads: (updater: SetStateAction<Map<string, ThreadMessageLike[]>>) => void;
163
- threadMetadata: Map<string, ThreadMetadata>;
164
- setThreadMetadata: (updater: SetStateAction<Map<string, ThreadMetadata>>) => void;
165
- threadCnt: number;
166
- setThreadCnt: (updater: SetStateAction<number>) => void;
167
- getThreadMessages: (threadId: string) => ThreadMessageLike[];
168
- setThreadMessages: (threadId: string, messages: ThreadMessageLike[]) => void;
169
- getThreadMetadata: (threadId: string) => ThreadMetadata | undefined;
170
- updateThreadMetadata: (threadId: string, updates: Partial<ThreadMetadata>) => void;
171
- };
172
-
173
- type ThreadContext = ThreadContext$1;
174
- type ThreadContextProviderProps = {
175
- children: ReactNode;
176
- initialThreadId?: string;
177
- };
178
- declare function useThreadContext(): ThreadContext;
179
- declare function ThreadContextProvider({ children, initialThreadId, }: ThreadContextProviderProps): react_jsx_runtime.JSX.Element;
180
- declare function useCurrentThreadMessages(): ThreadMessageLike[];
181
- declare function useCurrentThreadMetadata(): ThreadMetadata | undefined;
182
-
183
- declare function toInboundMessage(msg: SessionMessage): ThreadMessageLike | null;
184
- declare function toInboundSystem(msg: SessionMessage): ThreadMessageLike | null;
185
-
186
- declare function cn(...inputs: ClassValue[]): string;
187
-
188
- type NotificationType = "error" | "notice" | "success";
189
- type NotificationIconType = "error" | "success" | "notice" | "wallet" | "transaction" | "network" | "warning";
190
- type Notification = {
191
- id: string;
192
- type: NotificationType;
193
- title: string;
194
- message: string;
195
- iconType?: NotificationIconType;
196
- duration?: number;
197
- };
198
- type NotificationContextValue = {
199
- showNotification: (notification: Omit<Notification, "id">) => void;
200
- notifications: Notification[];
201
- dismissNotification: (id: string) => void;
202
- };
203
- declare function useNotification(): NotificationContextValue;
204
- declare function NotificationProvider({ children }: {
205
- children: ReactNode;
206
- }): react_jsx_runtime.JSX.Element;
207
-
208
- export { AomiRuntimeProvider, type AomiRuntimeProviderProps, AomiRuntimeProviderWithNotifications, BackendApi, type BackendSessionResponse, type BackendThreadMetadata, type CreateThreadResponse, type Eip1193Provider, type Notification, type NotificationIconType, NotificationProvider, type NotificationType, RuntimeActionsProvider, type SessionMessage, type SessionResponsePayload, type SystemEvent, type SystemResponsePayload, type SystemUpdate, type SystemUpdateNotification, ThreadContextProvider, type ThreadMetadata, type ThreadStatus, type WalletButtonState, type WalletFooterProps, WalletSystemMessageEmitter, type WalletTxRequestContext, type WalletTxRequestHandler, type WalletTxRequestPayload, cn, toInboundSystem as constructSystemMessage, toInboundMessage as constructThreadMessage, formatAddress, getNetworkName, normalizeWalletError, pickInjectedProvider, toHexQuantity, useCurrentThreadMessages, useCurrentThreadMetadata, useNotification, useRuntimeActions, useThreadContext };