@axiom-lattice/react-sdk 1.0.20
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/LICENSE +201 -0
- package/README.md +356 -0
- package/dist/index.d.mts +287 -0
- package/dist/index.d.ts +287 -0
- package/dist/index.js +510 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +476 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +53 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
AxiomLatticeProvider: () => AxiomLatticeProvider,
|
|
25
|
+
useAgentGraph: () => useAgentGraph,
|
|
26
|
+
useAgentState: () => useAgentState,
|
|
27
|
+
useAxiomLattice: () => useAxiomLattice,
|
|
28
|
+
useChat: () => useChat,
|
|
29
|
+
useThread: () => useThread
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(index_exports);
|
|
32
|
+
|
|
33
|
+
// src/hooks/useChat.ts
|
|
34
|
+
var import_react2 = require("react");
|
|
35
|
+
|
|
36
|
+
// src/context.tsx
|
|
37
|
+
var import_react = require("react");
|
|
38
|
+
var import_client_sdk = require("@axiom-lattice/client-sdk");
|
|
39
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
40
|
+
var AxiomLatticeContext = (0, import_react.createContext)({
|
|
41
|
+
client: null
|
|
42
|
+
});
|
|
43
|
+
function AxiomLatticeProvider({
|
|
44
|
+
config,
|
|
45
|
+
children
|
|
46
|
+
}) {
|
|
47
|
+
const client = (0, import_react.useMemo)(
|
|
48
|
+
() => new import_client_sdk.Client(config),
|
|
49
|
+
[config.baseURL, config.apiKey, config.assistantId, config.transport]
|
|
50
|
+
);
|
|
51
|
+
(0, import_react.useMemo)(() => {
|
|
52
|
+
if (config.headers?.["x-tenant-id"]) {
|
|
53
|
+
client.setTenantId(config.headers["x-tenant-id"]);
|
|
54
|
+
}
|
|
55
|
+
}, [client, config.headers]);
|
|
56
|
+
const value = (0, import_react.useMemo)(() => ({ client }), [client]);
|
|
57
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AxiomLatticeContext.Provider, { value, children });
|
|
58
|
+
}
|
|
59
|
+
function useAxiomLattice() {
|
|
60
|
+
const context = (0, import_react.useContext)(AxiomLatticeContext);
|
|
61
|
+
if (!context.client) {
|
|
62
|
+
throw new Error(
|
|
63
|
+
"useAxiomLattice must be used within an AxiomLatticeProvider"
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
return context.client;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/hooks/useChat.ts
|
|
70
|
+
var import_client_sdk2 = require("@axiom-lattice/client-sdk");
|
|
71
|
+
function useChat(threadId, options = {}) {
|
|
72
|
+
const client = useAxiomLattice();
|
|
73
|
+
const [state, setState] = (0, import_react2.useState)({
|
|
74
|
+
messages: options.initialMessages || [],
|
|
75
|
+
isLoading: false,
|
|
76
|
+
error: null,
|
|
77
|
+
streamingMessage: null
|
|
78
|
+
});
|
|
79
|
+
const stopStreamingRef = (0, import_react2.useRef)(null);
|
|
80
|
+
const chunkMessageMerger = (0, import_react2.useRef)((0, import_client_sdk2.createSimpleMessageMerger)());
|
|
81
|
+
(0, import_react2.useEffect)(() => {
|
|
82
|
+
if (options.initialMessages && options.initialMessages.length > 0) {
|
|
83
|
+
chunkMessageMerger.current.initialMessages(options.initialMessages);
|
|
84
|
+
}
|
|
85
|
+
}, [options.initialMessages]);
|
|
86
|
+
const handleStreamEvent = (0, import_react2.useCallback)((chunk) => {
|
|
87
|
+
chunkMessageMerger.current.push(chunk);
|
|
88
|
+
const updatedMessages = chunkMessageMerger.current.getMessages();
|
|
89
|
+
setState((prev) => ({
|
|
90
|
+
...prev,
|
|
91
|
+
messages: updatedMessages,
|
|
92
|
+
isLoading: false,
|
|
93
|
+
streamingMessage: null
|
|
94
|
+
}));
|
|
95
|
+
}, []);
|
|
96
|
+
const sendMessage = (0, import_react2.useCallback)(
|
|
97
|
+
async (data) => {
|
|
98
|
+
if (!threadId) {
|
|
99
|
+
throw new Error("Thread ID is required to send messages");
|
|
100
|
+
}
|
|
101
|
+
if (stopStreamingRef.current) {
|
|
102
|
+
stopStreamingRef.current();
|
|
103
|
+
stopStreamingRef.current = null;
|
|
104
|
+
}
|
|
105
|
+
const { input, command, streaming = true } = data;
|
|
106
|
+
const { message, files } = input || {};
|
|
107
|
+
setState((prev) => ({
|
|
108
|
+
...prev,
|
|
109
|
+
isLoading: true,
|
|
110
|
+
error: null,
|
|
111
|
+
streamingMessage: null
|
|
112
|
+
}));
|
|
113
|
+
const userMessage = {
|
|
114
|
+
id: Date.now().toString(),
|
|
115
|
+
content: message || command?.resume?.message || "",
|
|
116
|
+
files,
|
|
117
|
+
role: "human"
|
|
118
|
+
};
|
|
119
|
+
chunkMessageMerger.current.push({
|
|
120
|
+
type: "human",
|
|
121
|
+
data: {
|
|
122
|
+
id: userMessage.id,
|
|
123
|
+
content: userMessage.content
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
setState((prev) => ({
|
|
127
|
+
...prev,
|
|
128
|
+
messages: chunkMessageMerger.current.getMessages()
|
|
129
|
+
}));
|
|
130
|
+
try {
|
|
131
|
+
if (options.streaming !== false && streaming !== false) {
|
|
132
|
+
const stopStreaming2 = client.chat.stream(
|
|
133
|
+
{
|
|
134
|
+
threadId,
|
|
135
|
+
messages: [userMessage]
|
|
136
|
+
// Cast to any to avoid type conflicts
|
|
137
|
+
},
|
|
138
|
+
(chunk) => handleStreamEvent(chunk),
|
|
139
|
+
() => {
|
|
140
|
+
stopStreamingRef.current = null;
|
|
141
|
+
},
|
|
142
|
+
(error) => {
|
|
143
|
+
setState((prev) => ({
|
|
144
|
+
...prev,
|
|
145
|
+
isLoading: false,
|
|
146
|
+
error,
|
|
147
|
+
streamingMessage: null
|
|
148
|
+
}));
|
|
149
|
+
stopStreamingRef.current = null;
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
stopStreamingRef.current = stopStreaming2;
|
|
153
|
+
} else {
|
|
154
|
+
const response = await client.chat.send({
|
|
155
|
+
threadId,
|
|
156
|
+
messages: [userMessage]
|
|
157
|
+
// Cast to any to avoid type conflicts
|
|
158
|
+
});
|
|
159
|
+
chunkMessageMerger.current.push({
|
|
160
|
+
type: "ai",
|
|
161
|
+
data: {
|
|
162
|
+
id: response.message.id || `assistant-${Date.now()}`,
|
|
163
|
+
content: response.message.content || ""
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
setState((prev) => ({
|
|
167
|
+
...prev,
|
|
168
|
+
messages: chunkMessageMerger.current.getMessages().map((msg) => ({
|
|
169
|
+
id: msg.id,
|
|
170
|
+
role: msg.role === "ai" ? "assistant" : msg.role === "human" ? "user" : msg.role === "system" ? "system" : "tool",
|
|
171
|
+
content: typeof msg.content === "string" ? msg.content : JSON.stringify(msg.content || ""),
|
|
172
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
173
|
+
})),
|
|
174
|
+
isLoading: false
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
} catch (error) {
|
|
178
|
+
setState((prev) => ({
|
|
179
|
+
...prev,
|
|
180
|
+
isLoading: false,
|
|
181
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
182
|
+
}));
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
[client, threadId, options.streaming, handleStreamEvent]
|
|
186
|
+
);
|
|
187
|
+
const stopStreaming = (0, import_react2.useCallback)(() => {
|
|
188
|
+
if (stopStreamingRef.current) {
|
|
189
|
+
stopStreamingRef.current();
|
|
190
|
+
stopStreamingRef.current = null;
|
|
191
|
+
const currentMessages = chunkMessageMerger.current.getMessages().map((msg) => ({
|
|
192
|
+
id: msg.id,
|
|
193
|
+
role: msg.role === "ai" ? "assistant" : msg.role === "human" ? "user" : msg.role === "system" ? "system" : "tool",
|
|
194
|
+
content: typeof msg.content === "string" ? msg.content : JSON.stringify(msg.content || ""),
|
|
195
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
196
|
+
}));
|
|
197
|
+
setState((prev) => ({
|
|
198
|
+
...prev,
|
|
199
|
+
messages: currentMessages,
|
|
200
|
+
isLoading: false,
|
|
201
|
+
streamingMessage: null
|
|
202
|
+
}));
|
|
203
|
+
}
|
|
204
|
+
}, []);
|
|
205
|
+
const loadMessages = (0, import_react2.useCallback)(
|
|
206
|
+
async (limit) => {
|
|
207
|
+
if (!threadId) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
211
|
+
try {
|
|
212
|
+
const fetchedMessages = await client.getMessages({
|
|
213
|
+
threadId,
|
|
214
|
+
limit
|
|
215
|
+
});
|
|
216
|
+
chunkMessageMerger.current.reset();
|
|
217
|
+
chunkMessageMerger.current.initialMessages(fetchedMessages);
|
|
218
|
+
setState((prev) => ({
|
|
219
|
+
...prev,
|
|
220
|
+
messages: fetchedMessages,
|
|
221
|
+
isLoading: false
|
|
222
|
+
}));
|
|
223
|
+
} catch (error) {
|
|
224
|
+
setState((prev) => ({
|
|
225
|
+
...prev,
|
|
226
|
+
isLoading: false,
|
|
227
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
228
|
+
}));
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
[client, threadId]
|
|
232
|
+
);
|
|
233
|
+
const clearMessages = (0, import_react2.useCallback)(() => {
|
|
234
|
+
chunkMessageMerger.current.reset();
|
|
235
|
+
setState((prev) => ({
|
|
236
|
+
...prev,
|
|
237
|
+
messages: [],
|
|
238
|
+
streamingMessage: null
|
|
239
|
+
}));
|
|
240
|
+
}, []);
|
|
241
|
+
(0, import_react2.useEffect)(() => {
|
|
242
|
+
if (threadId) {
|
|
243
|
+
loadMessages();
|
|
244
|
+
} else {
|
|
245
|
+
clearMessages();
|
|
246
|
+
}
|
|
247
|
+
return () => {
|
|
248
|
+
if (stopStreamingRef.current) {
|
|
249
|
+
stopStreamingRef.current();
|
|
250
|
+
stopStreamingRef.current = null;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
}, [threadId, loadMessages, clearMessages]);
|
|
254
|
+
return {
|
|
255
|
+
...state,
|
|
256
|
+
sendMessage,
|
|
257
|
+
stopStreaming,
|
|
258
|
+
loadMessages,
|
|
259
|
+
clearMessages
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// src/hooks/useThread.ts
|
|
264
|
+
var import_react3 = require("react");
|
|
265
|
+
function useThread() {
|
|
266
|
+
const client = useAxiomLattice();
|
|
267
|
+
const [state, setState] = (0, import_react3.useState)({
|
|
268
|
+
threads: [],
|
|
269
|
+
currentThread: null,
|
|
270
|
+
isLoading: false,
|
|
271
|
+
error: null
|
|
272
|
+
});
|
|
273
|
+
const createThread = (0, import_react3.useCallback)(
|
|
274
|
+
async (options = {}) => {
|
|
275
|
+
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
276
|
+
try {
|
|
277
|
+
const threadId = await client.createThread(options);
|
|
278
|
+
const thread = await client.getThread(threadId);
|
|
279
|
+
setState((prev) => ({
|
|
280
|
+
...prev,
|
|
281
|
+
threads: [...prev.threads, thread],
|
|
282
|
+
currentThread: thread,
|
|
283
|
+
isLoading: false
|
|
284
|
+
}));
|
|
285
|
+
return threadId;
|
|
286
|
+
} catch (error) {
|
|
287
|
+
setState((prev) => ({
|
|
288
|
+
...prev,
|
|
289
|
+
isLoading: false,
|
|
290
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
291
|
+
}));
|
|
292
|
+
throw error;
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
[client]
|
|
296
|
+
);
|
|
297
|
+
const getThread = (0, import_react3.useCallback)(
|
|
298
|
+
async (threadId) => {
|
|
299
|
+
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
300
|
+
try {
|
|
301
|
+
const thread = await client.getThread(threadId);
|
|
302
|
+
setState((prev) => ({
|
|
303
|
+
...prev,
|
|
304
|
+
isLoading: false
|
|
305
|
+
}));
|
|
306
|
+
return thread;
|
|
307
|
+
} catch (error) {
|
|
308
|
+
setState((prev) => ({
|
|
309
|
+
...prev,
|
|
310
|
+
isLoading: false,
|
|
311
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
312
|
+
}));
|
|
313
|
+
throw error;
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
[client]
|
|
317
|
+
);
|
|
318
|
+
const listThreads = (0, import_react3.useCallback)(
|
|
319
|
+
async (limit, offset) => {
|
|
320
|
+
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
321
|
+
try {
|
|
322
|
+
const threads = await client.listThreads({ limit, offset });
|
|
323
|
+
setState((prev) => ({
|
|
324
|
+
...prev,
|
|
325
|
+
threads,
|
|
326
|
+
isLoading: false
|
|
327
|
+
}));
|
|
328
|
+
} catch (error) {
|
|
329
|
+
setState((prev) => ({
|
|
330
|
+
...prev,
|
|
331
|
+
isLoading: false,
|
|
332
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
333
|
+
}));
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
[client]
|
|
337
|
+
);
|
|
338
|
+
const deleteThread = (0, import_react3.useCallback)(
|
|
339
|
+
async (threadId) => {
|
|
340
|
+
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
341
|
+
try {
|
|
342
|
+
await client.deleteThread(threadId);
|
|
343
|
+
setState((prev) => ({
|
|
344
|
+
...prev,
|
|
345
|
+
threads: prev.threads.filter((t) => t.id !== threadId),
|
|
346
|
+
currentThread: prev.currentThread?.id === threadId ? null : prev.currentThread,
|
|
347
|
+
isLoading: false
|
|
348
|
+
}));
|
|
349
|
+
} catch (error) {
|
|
350
|
+
setState((prev) => ({
|
|
351
|
+
...prev,
|
|
352
|
+
isLoading: false,
|
|
353
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
354
|
+
}));
|
|
355
|
+
throw error;
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
[client]
|
|
359
|
+
);
|
|
360
|
+
const selectThread = (0, import_react3.useCallback)(
|
|
361
|
+
async (threadId) => {
|
|
362
|
+
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
|
363
|
+
try {
|
|
364
|
+
const thread = await client.getThread(threadId);
|
|
365
|
+
setState((prev) => ({
|
|
366
|
+
...prev,
|
|
367
|
+
currentThread: thread,
|
|
368
|
+
isLoading: false
|
|
369
|
+
}));
|
|
370
|
+
} catch (error) {
|
|
371
|
+
setState((prev) => ({
|
|
372
|
+
...prev,
|
|
373
|
+
isLoading: false,
|
|
374
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
375
|
+
}));
|
|
376
|
+
throw error;
|
|
377
|
+
}
|
|
378
|
+
},
|
|
379
|
+
[client]
|
|
380
|
+
);
|
|
381
|
+
return {
|
|
382
|
+
...state,
|
|
383
|
+
createThread,
|
|
384
|
+
getThread,
|
|
385
|
+
listThreads,
|
|
386
|
+
deleteThread,
|
|
387
|
+
selectThread
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// src/hooks/useAgentState.ts
|
|
392
|
+
var import_react4 = require("react");
|
|
393
|
+
function useAgentState(threadId, options = {}) {
|
|
394
|
+
const client = useAxiomLattice();
|
|
395
|
+
const [agentState, setAgentState] = (0, import_react4.useState)(null);
|
|
396
|
+
const [isLoading, setIsLoading] = (0, import_react4.useState)(false);
|
|
397
|
+
const [error, setError] = (0, import_react4.useState)(null);
|
|
398
|
+
const pollingIntervalRef = (0, import_react4.useRef)(null);
|
|
399
|
+
const pollingTimeoutRef = (0, import_react4.useRef)(null);
|
|
400
|
+
const {
|
|
401
|
+
pollingInterval = 2e3,
|
|
402
|
+
// 2 seconds by default
|
|
403
|
+
autoStart = true
|
|
404
|
+
} = options;
|
|
405
|
+
const fetchAgentState = (0, import_react4.useCallback)(async () => {
|
|
406
|
+
if (!threadId) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
setIsLoading(true);
|
|
410
|
+
setError(null);
|
|
411
|
+
try {
|
|
412
|
+
const state = await client.getAgentState(threadId);
|
|
413
|
+
setAgentState(state);
|
|
414
|
+
} catch (err) {
|
|
415
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
416
|
+
} finally {
|
|
417
|
+
setIsLoading(false);
|
|
418
|
+
}
|
|
419
|
+
}, [client, threadId]);
|
|
420
|
+
const startPolling = (0, import_react4.useCallback)(() => {
|
|
421
|
+
if (!threadId) {
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
if (pollingTimeoutRef.current) {
|
|
425
|
+
clearTimeout(pollingTimeoutRef.current);
|
|
426
|
+
pollingTimeoutRef.current = null;
|
|
427
|
+
}
|
|
428
|
+
const pollingId = Date.now();
|
|
429
|
+
pollingIntervalRef.current = pollingId;
|
|
430
|
+
const poll = async () => {
|
|
431
|
+
if (pollingIntervalRef.current !== pollingId) {
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
await fetchAgentState();
|
|
435
|
+
if (pollingIntervalRef.current === pollingId) {
|
|
436
|
+
pollingTimeoutRef.current = setTimeout(poll, pollingInterval);
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
poll();
|
|
440
|
+
}, [threadId, pollingInterval, fetchAgentState]);
|
|
441
|
+
const stopPolling = (0, import_react4.useCallback)(() => {
|
|
442
|
+
pollingIntervalRef.current = null;
|
|
443
|
+
if (pollingTimeoutRef.current) {
|
|
444
|
+
clearTimeout(pollingTimeoutRef.current);
|
|
445
|
+
pollingTimeoutRef.current = null;
|
|
446
|
+
}
|
|
447
|
+
}, []);
|
|
448
|
+
const refresh = (0, import_react4.useCallback)(async () => {
|
|
449
|
+
await fetchAgentState();
|
|
450
|
+
}, [fetchAgentState]);
|
|
451
|
+
(0, import_react4.useEffect)(() => {
|
|
452
|
+
if (threadId && autoStart) {
|
|
453
|
+
startPolling();
|
|
454
|
+
} else {
|
|
455
|
+
stopPolling();
|
|
456
|
+
}
|
|
457
|
+
return () => {
|
|
458
|
+
stopPolling();
|
|
459
|
+
};
|
|
460
|
+
}, [threadId, autoStart, startPolling, stopPolling]);
|
|
461
|
+
return {
|
|
462
|
+
agentState,
|
|
463
|
+
isLoading,
|
|
464
|
+
error,
|
|
465
|
+
startPolling,
|
|
466
|
+
stopPolling,
|
|
467
|
+
refresh
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// src/hooks/useAgentGraph.ts
|
|
472
|
+
var import_react5 = require("react");
|
|
473
|
+
function useAgentGraph() {
|
|
474
|
+
const client = useAxiomLattice();
|
|
475
|
+
const [graphImage, setGraphImage] = (0, import_react5.useState)(null);
|
|
476
|
+
const [isLoading, setIsLoading] = (0, import_react5.useState)(false);
|
|
477
|
+
const [error, setError] = (0, import_react5.useState)(null);
|
|
478
|
+
const fetchGraph = (0, import_react5.useCallback)(async () => {
|
|
479
|
+
setIsLoading(true);
|
|
480
|
+
setError(null);
|
|
481
|
+
try {
|
|
482
|
+
const image = await client.getAgentGraph();
|
|
483
|
+
setGraphImage(image);
|
|
484
|
+
} catch (err) {
|
|
485
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
486
|
+
} finally {
|
|
487
|
+
setIsLoading(false);
|
|
488
|
+
}
|
|
489
|
+
}, [client]);
|
|
490
|
+
return {
|
|
491
|
+
graphImage,
|
|
492
|
+
isLoading,
|
|
493
|
+
error,
|
|
494
|
+
fetchGraph
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// src/index.ts
|
|
499
|
+
__reExport(index_exports, require("@axiom-lattice/protocols"), module.exports);
|
|
500
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
501
|
+
0 && (module.exports = {
|
|
502
|
+
AxiomLatticeProvider,
|
|
503
|
+
useAgentGraph,
|
|
504
|
+
useAgentState,
|
|
505
|
+
useAxiomLattice,
|
|
506
|
+
useChat,
|
|
507
|
+
useThread,
|
|
508
|
+
...require("@axiom-lattice/protocols")
|
|
509
|
+
});
|
|
510
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/hooks/useChat.ts","../src/context.tsx","../src/hooks/useThread.ts","../src/hooks/useAgentState.ts","../src/hooks/useAgentGraph.ts"],"sourcesContent":["/**\n * @packageDocumentation\n * Axiom Lattice React SDK - React hooks for the Axiom Lattice Agent Service API\n */\n\n// Export types\nexport * from \"./types\";\n\n// Export hooks\nexport * from \"./hooks/useChat\";\nexport * from \"./hooks/useThread\";\nexport * from \"./hooks/useAgentState\";\nexport * from \"./hooks/useAgentGraph\";\n\n// Export context\nexport * from \"./context\";\n\nexport * from \"@axiom-lattice/protocols\";\n","import { useState, useCallback, useEffect, useRef } from \"react\";\nimport { useAxiomLattice } from \"../context\";\nimport {\n ChatState,\n UseChatOptions,\n StreamEventHandlerOptions,\n ChatResponse,\n} from \"../types\";\nimport { Message, MessageChunk } from \"@axiom-lattice/protocols\";\nimport { createSimpleMessageMerger } from \"@axiom-lattice/client-sdk\";\n\n/**\n * Hook for managing chat interactions with an agent\n *\n * This hook provides functionality for:\n * - Sending messages to an agent\n * - Receiving streaming and non-streaming responses\n * - Loading message history\n * - Managing the chat state\n *\n * @param threadId - Thread ID to use for chat\n * @param options - Chat options\n * @returns Chat state and operations\n */\nexport function useChat(\n threadId: string | null,\n options: UseChatOptions = {}\n): ChatState & {\n sendMessage: (data: {\n input?: { message: string; files?: { name: string; id: string }[] };\n command?: {\n resume?: {\n action: string;\n data: Record<string, any> & {\n config?: { thread_id?: string; work_log_id?: string };\n };\n message: string;\n };\n update?: any;\n send?: { node: string; input: any };\n };\n streaming?: boolean;\n }) => Promise<void>;\n stopStreaming: () => void;\n loadMessages: (limit?: number) => Promise<void>;\n clearMessages: () => void;\n} {\n const client = useAxiomLattice();\n const [state, setState] = useState<ChatState>({\n messages: options.initialMessages || [],\n isLoading: false,\n error: null,\n streamingMessage: null,\n });\n\n // Reference to the stop function for streaming\n const stopStreamingRef = useRef<(() => void) | null>(null);\n\n // Create a message merger to handle streaming chunks\n const chunkMessageMerger = useRef(createSimpleMessageMerger());\n\n // Initialize message merger with initial messages\n useEffect(() => {\n if (options.initialMessages && options.initialMessages.length > 0) {\n chunkMessageMerger.current.initialMessages(options.initialMessages);\n }\n }, [options.initialMessages]);\n\n /**\n * Handles stream events\n * @param chunk - Message chunk\n * @param customHandlers - Custom event handlers\n */\n const handleStreamEvent = useCallback((chunk: MessageChunk) => {\n // Push the chunk to the message merger\n chunkMessageMerger.current.push(chunk);\n\n // Get the updated messages\n const updatedMessages = chunkMessageMerger.current.getMessages();\n\n // Update the state with the updated messages\n setState((prev) => ({\n ...prev,\n messages: updatedMessages,\n isLoading: false,\n streamingMessage: null,\n }));\n }, []);\n\n /**\n * Sends a message to the agent\n * @param data - Message data\n */\n const sendMessage = useCallback(\n async (data: {\n input?: { message: string; files?: { name: string; id: string }[] };\n command?: {\n resume?: {\n action: string;\n data: Record<string, any> & {\n config?: { thread_id?: string; work_log_id?: string };\n };\n message: string;\n };\n update?: any;\n send?: { node: string; input: any };\n };\n streaming?: boolean;\n }) => {\n if (!threadId) {\n throw new Error(\"Thread ID is required to send messages\");\n }\n\n // Stop any ongoing streaming\n if (stopStreamingRef.current) {\n stopStreamingRef.current();\n stopStreamingRef.current = null;\n }\n\n const { input, command, streaming = true } = data;\n const { message, files } = input || {};\n\n setState((prev) => ({\n ...prev,\n isLoading: true,\n error: null,\n streamingMessage: null,\n }));\n\n // Create user message\n const userMessage: Message = {\n id: Date.now().toString(),\n content: message || command?.resume?.message || \"\",\n files,\n role: \"human\",\n };\n\n // Add user message to the message merger\n chunkMessageMerger.current.push({\n type: \"human\",\n data: {\n id: userMessage.id,\n content: userMessage.content,\n },\n });\n\n // Update state with messages from the merger\n setState((prev) => ({\n ...prev,\n messages: chunkMessageMerger.current.getMessages(),\n }));\n\n try {\n if (options.streaming !== false && streaming !== false) {\n // Use streaming API\n const stopStreaming = client.chat.stream(\n {\n threadId,\n messages: [userMessage as any], // Cast to any to avoid type conflicts\n },\n (chunk: MessageChunk) => handleStreamEvent(chunk),\n () => {\n // Stream completed\n stopStreamingRef.current = null;\n },\n (error: Error) => {\n // Stream error\n setState((prev) => ({\n ...prev,\n isLoading: false,\n error,\n streamingMessage: null,\n }));\n stopStreamingRef.current = null;\n }\n );\n\n stopStreamingRef.current = stopStreaming;\n } else {\n // Use non-streaming API\n const response = await client.chat.send({\n threadId,\n messages: [userMessage as any], // Cast to any to avoid type conflicts\n });\n\n // Add the response to the message merger\n chunkMessageMerger.current.push({\n type: \"ai\",\n data: {\n id: response.message.id || `assistant-${Date.now()}`,\n content: response.message.content || \"\",\n },\n });\n\n // Update state with messages from the merger\n setState((prev) => ({\n ...prev,\n messages: chunkMessageMerger.current.getMessages().map((msg) => ({\n id: msg.id,\n role:\n msg.role === \"ai\"\n ? \"assistant\"\n : msg.role === \"human\"\n ? \"user\"\n : msg.role === \"system\"\n ? \"system\"\n : \"tool\",\n content:\n typeof msg.content === \"string\"\n ? msg.content\n : JSON.stringify(msg.content || \"\"),\n createdAt: new Date().toISOString(),\n })) as Message[],\n isLoading: false,\n }));\n }\n } catch (error) {\n setState((prev) => ({\n ...prev,\n isLoading: false,\n error: error instanceof Error ? error : new Error(String(error)),\n }));\n }\n },\n [client, threadId, options.streaming, handleStreamEvent]\n );\n\n /**\n * Stops any ongoing streaming\n */\n const stopStreaming = useCallback(() => {\n if (stopStreamingRef.current) {\n stopStreamingRef.current();\n stopStreamingRef.current = null;\n\n // Get the current messages from the merger\n const currentMessages = chunkMessageMerger.current\n .getMessages()\n .map((msg) => ({\n id: msg.id,\n role:\n msg.role === \"ai\"\n ? \"assistant\"\n : msg.role === \"human\"\n ? \"user\"\n : msg.role === \"system\"\n ? \"system\"\n : \"tool\",\n content:\n typeof msg.content === \"string\"\n ? msg.content\n : JSON.stringify(msg.content || \"\"),\n createdAt: new Date().toISOString(),\n })) as Message[];\n\n setState((prev) => ({\n ...prev,\n messages: currentMessages,\n isLoading: false,\n streamingMessage: null,\n }));\n }\n }, []);\n\n /**\n * Loads messages from the thread\n * @param limit - Maximum number of messages to load\n */\n const loadMessages = useCallback(\n async (limit?: number) => {\n if (!threadId) {\n return;\n }\n\n setState((prev) => ({ ...prev, isLoading: true, error: null }));\n\n try {\n const fetchedMessages = await client.getMessages({\n threadId,\n limit,\n });\n\n // Reset and initialize the message merger with fetched messages\n chunkMessageMerger.current.reset();\n chunkMessageMerger.current.initialMessages(fetchedMessages);\n\n setState((prev) => ({\n ...prev,\n messages: fetchedMessages,\n isLoading: false,\n }));\n } catch (error) {\n setState((prev) => ({\n ...prev,\n isLoading: false,\n error: error instanceof Error ? error : new Error(String(error)),\n }));\n }\n },\n [client, threadId]\n );\n\n /**\n * Clears all messages from state\n */\n const clearMessages = useCallback(() => {\n chunkMessageMerger.current.reset();\n setState((prev) => ({\n ...prev,\n messages: [],\n streamingMessage: null,\n }));\n }, []);\n\n // Load messages when thread ID changes\n useEffect(() => {\n if (threadId) {\n loadMessages();\n } else {\n clearMessages();\n }\n\n // Clean up streaming when component unmounts or thread changes\n return () => {\n if (stopStreamingRef.current) {\n stopStreamingRef.current();\n stopStreamingRef.current = null;\n }\n };\n }, [threadId, loadMessages, clearMessages]);\n\n return {\n ...state,\n sendMessage,\n stopStreaming,\n loadMessages,\n clearMessages,\n };\n}\n","import React, { createContext, useContext, useMemo } from \"react\";\nimport { AxiomLatticeProviderProps, ClientConfig } from \"./types\";\nimport { Client } from \"@axiom-lattice/client-sdk\";\n\n/**\n * Context for the Axiom Lattice client\n */\ninterface AxiomLatticeContextValue {\n client: Client | null;\n}\n\n/**\n * Context object for the Axiom Lattice client\n */\nconst AxiomLatticeContext = createContext<AxiomLatticeContextValue>({\n client: null,\n});\n\n/**\n * Provider component for the Axiom Lattice client\n * @param props - Provider props\n * @returns Provider component\n */\nexport function AxiomLatticeProvider({\n config,\n children,\n}: AxiomLatticeProviderProps) {\n // Create client instance\n const client = useMemo(\n () => new Client(config),\n [config.baseURL, config.apiKey, config.assistantId, config.transport]\n );\n\n // Set tenant ID if provided\n useMemo(() => {\n if (config.headers?.[\"x-tenant-id\"]) {\n client.setTenantId(config.headers[\"x-tenant-id\"]);\n }\n }, [client, config.headers]);\n\n const value = useMemo(() => ({ client }), [client]);\n\n return (\n <AxiomLatticeContext.Provider value={value}>\n {children}\n </AxiomLatticeContext.Provider>\n );\n}\n\n/**\n * Hook to access the Axiom Lattice client\n * @returns The Axiom Lattice client\n * @throws Error if used outside of AxiomLatticeProvider\n */\nexport function useAxiomLattice(): Client {\n const context = useContext(AxiomLatticeContext);\n\n if (!context.client) {\n throw new Error(\n \"useAxiomLattice must be used within an AxiomLatticeProvider\"\n );\n }\n\n return context.client;\n}\n","import { useState, useCallback, useEffect } from \"react\";\nimport { useAxiomLattice } from \"../context\";\nimport { ThreadState, Thread } from \"../types\";\n\n/**\n * Interface for thread creation options\n */\ninterface CreateThreadOptions {\n metadata?: Record<string, any>;\n}\n\n/**\n * Hook for managing threads\n * @returns Thread state and operations\n */\nexport function useThread(): ThreadState & {\n createThread: (options?: CreateThreadOptions) => Promise<string>;\n getThread: (threadId: string) => Promise<Thread>;\n listThreads: (limit?: number, offset?: number) => Promise<void>;\n deleteThread: (threadId: string) => Promise<void>;\n selectThread: (threadId: string) => Promise<void>;\n} {\n const client = useAxiomLattice();\n const [state, setState] = useState<ThreadState>({\n threads: [],\n currentThread: null,\n isLoading: false,\n error: null,\n });\n\n /**\n * Creates a new thread\n * @param options - Thread creation options\n * @returns Promise resolving to the thread ID\n */\n const createThread = useCallback(\n async (options: CreateThreadOptions = {}) => {\n setState((prev) => ({ ...prev, isLoading: true, error: null }));\n try {\n const threadId = await client.createThread(options);\n const thread = await client.getThread(threadId);\n\n setState((prev) => ({\n ...prev,\n threads: [...prev.threads, thread],\n currentThread: thread,\n isLoading: false,\n }));\n\n return threadId;\n } catch (error) {\n setState((prev) => ({\n ...prev,\n isLoading: false,\n error: error instanceof Error ? error : new Error(String(error)),\n }));\n throw error;\n }\n },\n [client]\n );\n\n /**\n * Gets a thread by ID\n * @param threadId - Thread ID\n * @returns Promise resolving to the thread\n */\n const getThread = useCallback(\n async (threadId: string) => {\n setState((prev) => ({ ...prev, isLoading: true, error: null }));\n try {\n const thread = await client.getThread(threadId);\n\n setState((prev) => ({\n ...prev,\n isLoading: false,\n }));\n\n return thread;\n } catch (error) {\n setState((prev) => ({\n ...prev,\n isLoading: false,\n error: error instanceof Error ? error : new Error(String(error)),\n }));\n throw error;\n }\n },\n [client]\n );\n\n /**\n * Lists all threads\n * @param limit - Maximum number of threads to return\n * @param offset - Offset for pagination\n */\n const listThreads = useCallback(\n async (limit?: number, offset?: number) => {\n setState((prev) => ({ ...prev, isLoading: true, error: null }));\n try {\n const threads = await client.listThreads({ limit, offset });\n\n setState((prev) => ({\n ...prev,\n threads,\n isLoading: false,\n }));\n } catch (error) {\n setState((prev) => ({\n ...prev,\n isLoading: false,\n error: error instanceof Error ? error : new Error(String(error)),\n }));\n }\n },\n [client]\n );\n\n /**\n * Deletes a thread\n * @param threadId - Thread ID\n */\n const deleteThread = useCallback(\n async (threadId: string) => {\n setState((prev) => ({ ...prev, isLoading: true, error: null }));\n try {\n await client.deleteThread(threadId);\n\n setState((prev) => ({\n ...prev,\n threads: prev.threads.filter((t) => t.id !== threadId),\n currentThread:\n prev.currentThread?.id === threadId ? null : prev.currentThread,\n isLoading: false,\n }));\n } catch (error) {\n setState((prev) => ({\n ...prev,\n isLoading: false,\n error: error instanceof Error ? error : new Error(String(error)),\n }));\n throw error;\n }\n },\n [client]\n );\n\n /**\n * Selects a thread as the current thread\n * @param threadId - Thread ID\n */\n const selectThread = useCallback(\n async (threadId: string) => {\n setState((prev) => ({ ...prev, isLoading: true, error: null }));\n try {\n const thread = await client.getThread(threadId);\n\n setState((prev) => ({\n ...prev,\n currentThread: thread,\n isLoading: false,\n }));\n } catch (error) {\n setState((prev) => ({\n ...prev,\n isLoading: false,\n error: error instanceof Error ? error : new Error(String(error)),\n }));\n throw error;\n }\n },\n [client]\n );\n\n return {\n ...state,\n createThread,\n getThread,\n listThreads,\n deleteThread,\n selectThread,\n };\n}","import { useState, useCallback, useEffect, useRef } from \"react\";\nimport { useAxiomLattice } from \"../context\";\nimport { UseAgentStateOptions, UseAgentStateReturn, AgentState } from \"../types\";\n\n/**\n * Hook for monitoring agent state\n * @param threadId - Thread ID to monitor\n * @param options - Agent state options\n * @returns Agent state and control functions\n */\nexport function useAgentState(\n threadId: string | null,\n options: UseAgentStateOptions = {}\n): UseAgentStateReturn {\n const client = useAxiomLattice();\n const [agentState, setAgentState] = useState<AgentState | null>(null);\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [error, setError] = useState<Error | null>(null);\n\n const pollingIntervalRef = useRef<number | null>(null);\n const pollingTimeoutRef = useRef<NodeJS.Timeout | null>(null);\n\n // Default options\n const {\n pollingInterval = 2000, // 2 seconds by default\n autoStart = true,\n } = options;\n\n /**\n * Fetches the current agent state\n */\n const fetchAgentState = useCallback(async () => {\n if (!threadId) {\n return;\n }\n\n setIsLoading(true);\n setError(null);\n\n try {\n const state = await client.getAgentState(threadId);\n setAgentState(state);\n } catch (err) {\n setError(err instanceof Error ? err : new Error(String(err)));\n } finally {\n setIsLoading(false);\n }\n }, [client, threadId]);\n\n /**\n * Starts polling for agent state\n */\n const startPolling = useCallback(() => {\n if (!threadId) {\n return;\n }\n\n // Clear any existing polling\n if (pollingTimeoutRef.current) {\n clearTimeout(pollingTimeoutRef.current);\n pollingTimeoutRef.current = null;\n }\n\n // Generate a unique ID for this polling session\n const pollingId = Date.now();\n pollingIntervalRef.current = pollingId;\n\n // Define the polling function\n const poll = async () => {\n // Check if this polling session is still active\n if (pollingIntervalRef.current !== pollingId) {\n return;\n }\n\n await fetchAgentState();\n\n // Schedule next poll if still active\n if (pollingIntervalRef.current === pollingId) {\n pollingTimeoutRef.current = setTimeout(poll, pollingInterval);\n }\n };\n\n // Start polling\n poll();\n }, [threadId, pollingInterval, fetchAgentState]);\n\n /**\n * Stops polling for agent state\n */\n const stopPolling = useCallback(() => {\n pollingIntervalRef.current = null;\n\n if (pollingTimeoutRef.current) {\n clearTimeout(pollingTimeoutRef.current);\n pollingTimeoutRef.current = null;\n }\n }, []);\n\n /**\n * Manually refreshes agent state\n */\n const refresh = useCallback(async () => {\n await fetchAgentState();\n }, [fetchAgentState]);\n\n // Start/stop polling when thread ID changes\n useEffect(() => {\n if (threadId && autoStart) {\n startPolling();\n } else {\n stopPolling();\n }\n\n return () => {\n stopPolling();\n };\n }, [threadId, autoStart, startPolling, stopPolling]);\n\n return {\n agentState,\n isLoading,\n error,\n startPolling,\n stopPolling,\n refresh,\n };\n}","import { useState, useCallback } from \"react\";\nimport { useAxiomLattice } from \"../context\";\n\n/**\n * Hook for fetching agent graph visualization\n * @returns Graph state and operations\n */\nexport function useAgentGraph(): {\n graphImage: string | null;\n isLoading: boolean;\n error: Error | null;\n fetchGraph: () => Promise<void>;\n} {\n const client = useAxiomLattice();\n const [graphImage, setGraphImage] = useState<string | null>(null);\n const [isLoading, setIsLoading] = useState<boolean>(false);\n const [error, setError] = useState<Error | null>(null);\n\n /**\n * Fetches the agent graph visualization\n */\n const fetchGraph = useCallback(async () => {\n setIsLoading(true);\n setError(null);\n\n try {\n const image = await client.getAgentGraph();\n setGraphImage(image);\n } catch (err) {\n setError(err instanceof Error ? err : new Error(String(err)));\n } finally {\n setIsLoading(false);\n }\n }, [client]);\n\n return {\n graphImage,\n isLoading,\n error,\n fetchGraph,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAAyD;;;ACAzD,mBAA0D;AAE1D,wBAAuB;AAyCnB;AA7BJ,IAAM,0BAAsB,4BAAwC;AAAA,EAClE,QAAQ;AACV,CAAC;AAOM,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AACF,GAA8B;AAE5B,QAAM,aAAS;AAAA,IACb,MAAM,IAAI,yBAAO,MAAM;AAAA,IACvB,CAAC,OAAO,SAAS,OAAO,QAAQ,OAAO,aAAa,OAAO,SAAS;AAAA,EACtE;AAGA,4BAAQ,MAAM;AACZ,QAAI,OAAO,UAAU,aAAa,GAAG;AACnC,aAAO,YAAY,OAAO,QAAQ,aAAa,CAAC;AAAA,IAClD;AAAA,EACF,GAAG,CAAC,QAAQ,OAAO,OAAO,CAAC;AAE3B,QAAM,YAAQ,sBAAQ,OAAO,EAAE,OAAO,IAAI,CAAC,MAAM,CAAC;AAElD,SACE,4CAAC,oBAAoB,UAApB,EAA6B,OAC3B,UACH;AAEJ;AAOO,SAAS,kBAA0B;AACxC,Q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kB,KAAK;AACzD,QAAM,CAAC,OAAO,QAAQ,QAAI,wBAAuB,IAAI;AAKrD,QAAM,iBAAa,2BAAY,YAAY;AACzC,iBAAa,IAAI;AACjB,aAAS,IAAI;AAEb,QAAI;AACF,YAAM,QAAQ,MAAM,OAAO,cAAc;AACzC,oBAAc,KAAK;AAAA,IACrB,SAAS,KAAK;AACZ,eAAS,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,GAAG,CAAC,CAAC;AAAA,IAC9D,UAAE;AACA,mBAAa,KAAK;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,MAAM,CAAC;AAEX,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;;;ALxBA,0BAAc,qCAjBd;","names":["import_react","import_client_sdk","stopStreaming","import_react","import_react","import_react"]}
|