@axiom-lattice/react-sdk 1.0.11

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.
@@ -0,0 +1,287 @@
1
+ import { Message, MessageChunk } from '@axiom-lattice/protocols';
2
+ export * from '@axiom-lattice/protocols';
3
+ import { ReactNode } from 'react';
4
+ import * as react_jsx_runtime from 'react/jsx-runtime';
5
+ import { Client } from '@axiom-lattice/client-sdk';
6
+
7
+ /**
8
+ * Types for the Axiom Lattice React SDK
9
+ */
10
+
11
+ /**
12
+ * Client configuration
13
+ */
14
+ interface ClientConfig {
15
+ baseURL: string;
16
+ apiKey: string;
17
+ assistantId: string;
18
+ transport: "sse" | "ws";
19
+ timeout?: number;
20
+ headers?: Record<string, string>;
21
+ }
22
+ /**
23
+ * Props for the AxiomLatticeProvider component
24
+ */
25
+ interface AxiomLatticeProviderProps {
26
+ /**
27
+ * Configuration for the client
28
+ */
29
+ config: ClientConfig;
30
+ /**
31
+ * Children components
32
+ */
33
+ children: ReactNode;
34
+ }
35
+ /**
36
+ * Thread interface
37
+ */
38
+ interface Thread {
39
+ id: string;
40
+ metadata?: Record<string, any>;
41
+ createdAt: string;
42
+ }
43
+ /**
44
+ * Chat response interface
45
+ */
46
+ interface ChatResponse {
47
+ message: {
48
+ role: "assistant";
49
+ content: string;
50
+ id: string;
51
+ };
52
+ traceId: string;
53
+ }
54
+ /**
55
+ * Agent state interface
56
+ */
57
+ interface AgentState {
58
+ values: {
59
+ messages: Message[];
60
+ [key: string]: any;
61
+ };
62
+ tasks: Array<{
63
+ interrupts: Array<{
64
+ value: any;
65
+ }>;
66
+ }>;
67
+ }
68
+ /**
69
+ * Chat hook state
70
+ */
71
+ interface ChatState {
72
+ /**
73
+ * Array of messages in the chat
74
+ */
75
+ messages: Message[];
76
+ /**
77
+ * Whether a message is currently being sent
78
+ */
79
+ isLoading: boolean;
80
+ /**
81
+ * Error that occurred during sending a message
82
+ */
83
+ error: Error | null;
84
+ /**
85
+ * Current streaming message (if any)
86
+ */
87
+ streamingMessage: MessageChunk | null;
88
+ }
89
+ /**
90
+ * Chat hook options
91
+ */
92
+ interface UseChatOptions {
93
+ /**
94
+ * Whether to use streaming for messages
95
+ */
96
+ streaming?: boolean;
97
+ /**
98
+ * Initial messages to populate the chat with
99
+ */
100
+ initialMessages?: Message[];
101
+ }
102
+ /**
103
+ * Thread hook state
104
+ */
105
+ interface ThreadState {
106
+ /**
107
+ * Array of threads
108
+ */
109
+ threads: Thread[];
110
+ /**
111
+ * Currently selected thread
112
+ */
113
+ currentThread: Thread | null;
114
+ /**
115
+ * Whether threads are being loaded
116
+ */
117
+ isLoading: boolean;
118
+ /**
119
+ * Error that occurred during thread operations
120
+ */
121
+ error: Error | null;
122
+ }
123
+ /**
124
+ * Agent state hook options
125
+ */
126
+ interface UseAgentStateOptions {
127
+ /**
128
+ * Polling interval in milliseconds
129
+ */
130
+ pollingInterval?: number;
131
+ /**
132
+ * Whether to automatically start polling
133
+ */
134
+ autoStart?: boolean;
135
+ }
136
+ /**
137
+ * Agent state hook return value
138
+ */
139
+ interface UseAgentStateReturn {
140
+ /**
141
+ * Current agent state
142
+ */
143
+ agentState: AgentState | null;
144
+ /**
145
+ * Whether the agent state is loading
146
+ */
147
+ isLoading: boolean;
148
+ /**
149
+ * Error that occurred during fetching agent state
150
+ */
151
+ error: Error | null;
152
+ /**
153
+ * Start polling for agent state
154
+ */
155
+ startPolling: () => void;
156
+ /**
157
+ * Stop polling for agent state
158
+ */
159
+ stopPolling: () => void;
160
+ /**
161
+ * Refresh agent state manually
162
+ */
163
+ refresh: () => Promise<void>;
164
+ }
165
+ /**
166
+ * Stream event handler options
167
+ */
168
+ interface StreamEventHandlerOptions {
169
+ /**
170
+ * Handler for text events
171
+ */
172
+ onText?: (text: string) => void;
173
+ /**
174
+ * Handler for thinking events
175
+ */
176
+ onThinking?: (data: any) => void;
177
+ /**
178
+ * Handler for tool call events
179
+ */
180
+ onToolCall?: (toolCall: any) => void;
181
+ /**
182
+ * Handler for error events
183
+ */
184
+ onError?: (error: Error) => void;
185
+ /**
186
+ * Handler for completion events
187
+ */
188
+ onComplete?: (response: ChatResponse) => void;
189
+ }
190
+
191
+ /**
192
+ * Hook for managing chat interactions with an agent
193
+ *
194
+ * This hook provides functionality for:
195
+ * - Sending messages to an agent
196
+ * - Receiving streaming and non-streaming responses
197
+ * - Loading message history
198
+ * - Managing the chat state
199
+ *
200
+ * @param threadId - Thread ID to use for chat
201
+ * @param options - Chat options
202
+ * @returns Chat state and operations
203
+ */
204
+ declare function useChat(threadId: string | null, options?: UseChatOptions): ChatState & {
205
+ sendMessage: (data: {
206
+ input?: {
207
+ message: string;
208
+ files?: {
209
+ name: string;
210
+ id: string;
211
+ }[];
212
+ };
213
+ command?: {
214
+ resume?: {
215
+ action: string;
216
+ data: Record<string, any> & {
217
+ config?: {
218
+ thread_id?: string;
219
+ work_log_id?: string;
220
+ };
221
+ };
222
+ message: string;
223
+ };
224
+ update?: any;
225
+ send?: {
226
+ node: string;
227
+ input: any;
228
+ };
229
+ };
230
+ streaming?: boolean;
231
+ }) => Promise<void>;
232
+ stopStreaming: () => void;
233
+ loadMessages: (limit?: number) => Promise<void>;
234
+ clearMessages: () => void;
235
+ };
236
+
237
+ /**
238
+ * Interface for thread creation options
239
+ */
240
+ interface CreateThreadOptions {
241
+ metadata?: Record<string, any>;
242
+ }
243
+ /**
244
+ * Hook for managing threads
245
+ * @returns Thread state and operations
246
+ */
247
+ declare function useThread(): ThreadState & {
248
+ createThread: (options?: CreateThreadOptions) => Promise<string>;
249
+ getThread: (threadId: string) => Promise<Thread>;
250
+ listThreads: (limit?: number, offset?: number) => Promise<void>;
251
+ deleteThread: (threadId: string) => Promise<void>;
252
+ selectThread: (threadId: string) => Promise<void>;
253
+ };
254
+
255
+ /**
256
+ * Hook for monitoring agent state
257
+ * @param threadId - Thread ID to monitor
258
+ * @param options - Agent state options
259
+ * @returns Agent state and control functions
260
+ */
261
+ declare function useAgentState(threadId: string | null, options?: UseAgentStateOptions): UseAgentStateReturn;
262
+
263
+ /**
264
+ * Hook for fetching agent graph visualization
265
+ * @returns Graph state and operations
266
+ */
267
+ declare function useAgentGraph(): {
268
+ graphImage: string | null;
269
+ isLoading: boolean;
270
+ error: Error | null;
271
+ fetchGraph: () => Promise<void>;
272
+ };
273
+
274
+ /**
275
+ * Provider component for the Axiom Lattice client
276
+ * @param props - Provider props
277
+ * @returns Provider component
278
+ */
279
+ declare function AxiomLatticeProvider({ config, children, }: AxiomLatticeProviderProps): react_jsx_runtime.JSX.Element;
280
+ /**
281
+ * Hook to access the Axiom Lattice client
282
+ * @returns The Axiom Lattice client
283
+ * @throws Error if used outside of AxiomLatticeProvider
284
+ */
285
+ declare function useAxiomLattice(): Client;
286
+
287
+ export { type AgentState, AxiomLatticeProvider, type AxiomLatticeProviderProps, type ChatResponse, type ChatState, type ClientConfig, type StreamEventHandlerOptions, type Thread, type ThreadState, type UseAgentStateOptions, type UseAgentStateReturn, type UseChatOptions, useAgentGraph, useAgentState, useAxiomLattice, useChat, useThread };
@@ -0,0 +1,287 @@
1
+ import { Message, MessageChunk } from '@axiom-lattice/protocols';
2
+ export * from '@axiom-lattice/protocols';
3
+ import { ReactNode } from 'react';
4
+ import * as react_jsx_runtime from 'react/jsx-runtime';
5
+ import { Client } from '@axiom-lattice/client-sdk';
6
+
7
+ /**
8
+ * Types for the Axiom Lattice React SDK
9
+ */
10
+
11
+ /**
12
+ * Client configuration
13
+ */
14
+ interface ClientConfig {
15
+ baseURL: string;
16
+ apiKey: string;
17
+ assistantId: string;
18
+ transport: "sse" | "ws";
19
+ timeout?: number;
20
+ headers?: Record<string, string>;
21
+ }
22
+ /**
23
+ * Props for the AxiomLatticeProvider component
24
+ */
25
+ interface AxiomLatticeProviderProps {
26
+ /**
27
+ * Configuration for the client
28
+ */
29
+ config: ClientConfig;
30
+ /**
31
+ * Children components
32
+ */
33
+ children: ReactNode;
34
+ }
35
+ /**
36
+ * Thread interface
37
+ */
38
+ interface Thread {
39
+ id: string;
40
+ metadata?: Record<string, any>;
41
+ createdAt: string;
42
+ }
43
+ /**
44
+ * Chat response interface
45
+ */
46
+ interface ChatResponse {
47
+ message: {
48
+ role: "assistant";
49
+ content: string;
50
+ id: string;
51
+ };
52
+ traceId: string;
53
+ }
54
+ /**
55
+ * Agent state interface
56
+ */
57
+ interface AgentState {
58
+ values: {
59
+ messages: Message[];
60
+ [key: string]: any;
61
+ };
62
+ tasks: Array<{
63
+ interrupts: Array<{
64
+ value: any;
65
+ }>;
66
+ }>;
67
+ }
68
+ /**
69
+ * Chat hook state
70
+ */
71
+ interface ChatState {
72
+ /**
73
+ * Array of messages in the chat
74
+ */
75
+ messages: Message[];
76
+ /**
77
+ * Whether a message is currently being sent
78
+ */
79
+ isLoading: boolean;
80
+ /**
81
+ * Error that occurred during sending a message
82
+ */
83
+ error: Error | null;
84
+ /**
85
+ * Current streaming message (if any)
86
+ */
87
+ streamingMessage: MessageChunk | null;
88
+ }
89
+ /**
90
+ * Chat hook options
91
+ */
92
+ interface UseChatOptions {
93
+ /**
94
+ * Whether to use streaming for messages
95
+ */
96
+ streaming?: boolean;
97
+ /**
98
+ * Initial messages to populate the chat with
99
+ */
100
+ initialMessages?: Message[];
101
+ }
102
+ /**
103
+ * Thread hook state
104
+ */
105
+ interface ThreadState {
106
+ /**
107
+ * Array of threads
108
+ */
109
+ threads: Thread[];
110
+ /**
111
+ * Currently selected thread
112
+ */
113
+ currentThread: Thread | null;
114
+ /**
115
+ * Whether threads are being loaded
116
+ */
117
+ isLoading: boolean;
118
+ /**
119
+ * Error that occurred during thread operations
120
+ */
121
+ error: Error | null;
122
+ }
123
+ /**
124
+ * Agent state hook options
125
+ */
126
+ interface UseAgentStateOptions {
127
+ /**
128
+ * Polling interval in milliseconds
129
+ */
130
+ pollingInterval?: number;
131
+ /**
132
+ * Whether to automatically start polling
133
+ */
134
+ autoStart?: boolean;
135
+ }
136
+ /**
137
+ * Agent state hook return value
138
+ */
139
+ interface UseAgentStateReturn {
140
+ /**
141
+ * Current agent state
142
+ */
143
+ agentState: AgentState | null;
144
+ /**
145
+ * Whether the agent state is loading
146
+ */
147
+ isLoading: boolean;
148
+ /**
149
+ * Error that occurred during fetching agent state
150
+ */
151
+ error: Error | null;
152
+ /**
153
+ * Start polling for agent state
154
+ */
155
+ startPolling: () => void;
156
+ /**
157
+ * Stop polling for agent state
158
+ */
159
+ stopPolling: () => void;
160
+ /**
161
+ * Refresh agent state manually
162
+ */
163
+ refresh: () => Promise<void>;
164
+ }
165
+ /**
166
+ * Stream event handler options
167
+ */
168
+ interface StreamEventHandlerOptions {
169
+ /**
170
+ * Handler for text events
171
+ */
172
+ onText?: (text: string) => void;
173
+ /**
174
+ * Handler for thinking events
175
+ */
176
+ onThinking?: (data: any) => void;
177
+ /**
178
+ * Handler for tool call events
179
+ */
180
+ onToolCall?: (toolCall: any) => void;
181
+ /**
182
+ * Handler for error events
183
+ */
184
+ onError?: (error: Error) => void;
185
+ /**
186
+ * Handler for completion events
187
+ */
188
+ onComplete?: (response: ChatResponse) => void;
189
+ }
190
+
191
+ /**
192
+ * Hook for managing chat interactions with an agent
193
+ *
194
+ * This hook provides functionality for:
195
+ * - Sending messages to an agent
196
+ * - Receiving streaming and non-streaming responses
197
+ * - Loading message history
198
+ * - Managing the chat state
199
+ *
200
+ * @param threadId - Thread ID to use for chat
201
+ * @param options - Chat options
202
+ * @returns Chat state and operations
203
+ */
204
+ declare function useChat(threadId: string | null, options?: UseChatOptions): ChatState & {
205
+ sendMessage: (data: {
206
+ input?: {
207
+ message: string;
208
+ files?: {
209
+ name: string;
210
+ id: string;
211
+ }[];
212
+ };
213
+ command?: {
214
+ resume?: {
215
+ action: string;
216
+ data: Record<string, any> & {
217
+ config?: {
218
+ thread_id?: string;
219
+ work_log_id?: string;
220
+ };
221
+ };
222
+ message: string;
223
+ };
224
+ update?: any;
225
+ send?: {
226
+ node: string;
227
+ input: any;
228
+ };
229
+ };
230
+ streaming?: boolean;
231
+ }) => Promise<void>;
232
+ stopStreaming: () => void;
233
+ loadMessages: (limit?: number) => Promise<void>;
234
+ clearMessages: () => void;
235
+ };
236
+
237
+ /**
238
+ * Interface for thread creation options
239
+ */
240
+ interface CreateThreadOptions {
241
+ metadata?: Record<string, any>;
242
+ }
243
+ /**
244
+ * Hook for managing threads
245
+ * @returns Thread state and operations
246
+ */
247
+ declare function useThread(): ThreadState & {
248
+ createThread: (options?: CreateThreadOptions) => Promise<string>;
249
+ getThread: (threadId: string) => Promise<Thread>;
250
+ listThreads: (limit?: number, offset?: number) => Promise<void>;
251
+ deleteThread: (threadId: string) => Promise<void>;
252
+ selectThread: (threadId: string) => Promise<void>;
253
+ };
254
+
255
+ /**
256
+ * Hook for monitoring agent state
257
+ * @param threadId - Thread ID to monitor
258
+ * @param options - Agent state options
259
+ * @returns Agent state and control functions
260
+ */
261
+ declare function useAgentState(threadId: string | null, options?: UseAgentStateOptions): UseAgentStateReturn;
262
+
263
+ /**
264
+ * Hook for fetching agent graph visualization
265
+ * @returns Graph state and operations
266
+ */
267
+ declare function useAgentGraph(): {
268
+ graphImage: string | null;
269
+ isLoading: boolean;
270
+ error: Error | null;
271
+ fetchGraph: () => Promise<void>;
272
+ };
273
+
274
+ /**
275
+ * Provider component for the Axiom Lattice client
276
+ * @param props - Provider props
277
+ * @returns Provider component
278
+ */
279
+ declare function AxiomLatticeProvider({ config, children, }: AxiomLatticeProviderProps): react_jsx_runtime.JSX.Element;
280
+ /**
281
+ * Hook to access the Axiom Lattice client
282
+ * @returns The Axiom Lattice client
283
+ * @throws Error if used outside of AxiomLatticeProvider
284
+ */
285
+ declare function useAxiomLattice(): Client;
286
+
287
+ export { type AgentState, AxiomLatticeProvider, type AxiomLatticeProviderProps, type ChatResponse, type ChatState, type ClientConfig, type StreamEventHandlerOptions, type Thread, type ThreadState, type UseAgentStateOptions, type UseAgentStateReturn, type UseChatOptions, useAgentGraph, useAgentState, useAxiomLattice, useChat, useThread };