@rodrigocoliveira/agno-react 1.4.0 → 2.1.0

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.
Files changed (61) hide show
  1. package/README.md +32 -46
  2. package/dist/hooks/useAgnoToolExecution.d.ts +7 -11
  3. package/dist/hooks/useAgnoToolExecution.d.ts.map +1 -1
  4. package/dist/index.d.ts +7 -6
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +2353 -1043
  7. package/dist/index.js.map +31 -6
  8. package/dist/index.mjs +2371 -1040
  9. package/dist/index.mjs.map +31 -6
  10. package/dist/ui/components/chart.d.ts +63 -0
  11. package/dist/ui/components/chart.d.ts.map +1 -0
  12. package/dist/ui/composed/AgnoMessageItem.d.ts +12 -24
  13. package/dist/ui/composed/AgnoMessageItem.d.ts.map +1 -1
  14. package/dist/ui/composed/agno-chat/agno-chat.d.ts +25 -3
  15. package/dist/ui/composed/agno-chat/agno-chat.d.ts.map +1 -1
  16. package/dist/ui/composed/agno-chat/context.d.ts +4 -3
  17. package/dist/ui/composed/agno-chat/context.d.ts.map +1 -1
  18. package/dist/ui/composed/agno-chat/messages.d.ts +9 -15
  19. package/dist/ui/composed/agno-chat/messages.d.ts.map +1 -1
  20. package/dist/ui/composed/agno-chat/render-tool.d.ts +11 -0
  21. package/dist/ui/composed/agno-chat/render-tool.d.ts.map +1 -0
  22. package/dist/ui/composed/agno-chat/tool-building-blocks.d.ts +7 -0
  23. package/dist/ui/composed/agno-chat/tool-building-blocks.d.ts.map +1 -0
  24. package/dist/ui/composed/agno-message/content.d.ts +2 -0
  25. package/dist/ui/composed/agno-message/content.d.ts.map +1 -0
  26. package/dist/ui/composed/agno-message/context.d.ts +21 -0
  27. package/dist/ui/composed/agno-message/context.d.ts.map +1 -0
  28. package/dist/ui/composed/agno-message/footer.d.ts +6 -0
  29. package/dist/ui/composed/agno-message/footer.d.ts.map +1 -0
  30. package/dist/ui/composed/agno-message/index.d.ts +13 -0
  31. package/dist/ui/composed/agno-message/index.d.ts.map +1 -0
  32. package/dist/ui/composed/agno-message/media.d.ts +2 -0
  33. package/dist/ui/composed/agno-message/media.d.ts.map +1 -0
  34. package/dist/ui/composed/agno-message/message.d.ts +41 -0
  35. package/dist/ui/composed/agno-message/message.d.ts.map +1 -0
  36. package/dist/ui/composed/agno-message/reasoning.d.ts +2 -0
  37. package/dist/ui/composed/agno-message/reasoning.d.ts.map +1 -0
  38. package/dist/ui/composed/agno-message/references.d.ts +2 -0
  39. package/dist/ui/composed/agno-message/references.d.ts.map +1 -0
  40. package/dist/ui/composed/agno-message/tools.d.ts +7 -0
  41. package/dist/ui/composed/agno-message/tools.d.ts.map +1 -0
  42. package/dist/ui/composed/generative-components/card-grid.d.ts +4 -0
  43. package/dist/ui/composed/generative-components/card-grid.d.ts.map +1 -0
  44. package/dist/ui/composed/generative-components/charts.d.ts +7 -0
  45. package/dist/ui/composed/generative-components/charts.d.ts.map +1 -0
  46. package/dist/ui/composed/index.d.ts +10 -0
  47. package/dist/ui/composed/index.d.ts.map +1 -1
  48. package/dist/ui/index.d.ts +12 -0
  49. package/dist/ui/index.d.ts.map +1 -1
  50. package/dist/ui/primitives/badge.d.ts +1 -1
  51. package/dist/ui/primitives/button.d.ts +1 -1
  52. package/dist/ui/primitives/command.d.ts +1 -1
  53. package/dist/ui.js +1305 -640
  54. package/dist/ui.js.map +20 -7
  55. package/dist/ui.mjs +1306 -636
  56. package/dist/ui.mjs.map +20 -7
  57. package/package.json +8 -3
  58. package/dist/components/GenerativeUIRenderer.d.ts +0 -21
  59. package/dist/components/GenerativeUIRenderer.d.ts.map +0 -1
  60. package/dist/utils/component-registry.d.ts +0 -63
  61. package/dist/utils/component-registry.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -48,6 +48,7 @@ __export(exports_src, {
48
48
  useAgnoSessionState: () => useAgnoSessionState,
49
49
  useAgnoSession: () => useAgnoSession,
50
50
  useAgnoMetrics: () => useAgnoMetrics,
51
+ useAgnoMessageContext: () => useAgnoMessageContext,
51
52
  useAgnoMemory: () => useAgnoMemory,
52
53
  useAgnoKnowledge: () => useAgnoKnowledge,
53
54
  useAgnoEvals: () => useAgnoEvals,
@@ -60,10 +61,6 @@ __export(exports_src, {
60
61
  resultWithSmartChart: () => resultWithSmartChart,
61
62
  resultWithCardGrid: () => resultWithCardGrid,
62
63
  resultWithBarChart: () => resultWithBarChart,
63
- registerChartComponent: () => registerChartComponent,
64
- getCustomRender: () => getCustomRender,
65
- getComponentRegistry: () => getComponentRegistry,
66
- getChartComponent: () => getChartComponent,
67
64
  createToolResult: () => createToolResult,
68
65
  createTable: () => createTable,
69
66
  createSmartChart: () => createSmartChart,
@@ -76,10 +73,18 @@ __export(exports_src, {
76
73
  createBarChart: () => createBarChart,
77
74
  createArtifact: () => createArtifact,
78
75
  createAreaChart: () => createAreaChart,
76
+ byToolName: () => byToolName,
79
77
  ToolHandlerProvider: () => ToolHandlerProvider,
80
- GenerativeUIRenderer: () => GenerativeUIRenderer,
81
- ComponentRegistry: () => ComponentRegistry,
82
- AgnoProvider: () => AgnoProvider
78
+ ToolDebugCard: () => ToolDebugCard,
79
+ AgnoProvider: () => AgnoProvider,
80
+ AgnoMessageTools: () => AgnoMessageTools,
81
+ AgnoMessageReferences: () => AgnoMessageReferences,
82
+ AgnoMessageReasoning: () => AgnoMessageReasoning,
83
+ AgnoMessageMedia: () => AgnoMessageMedia,
84
+ AgnoMessageFooter: () => AgnoMessageFooter,
85
+ AgnoMessageContext: () => AgnoMessageContext,
86
+ AgnoMessageContent: () => AgnoMessageContent,
87
+ AgnoMessage: () => AgnoMessage
83
88
  });
84
89
  module.exports = __toCommonJS(exports_src);
85
90
 
@@ -138,1026 +143,2331 @@ function ToolHandlerProvider({ handlers: initialHandlers = {}, children }) {
138
143
  function useToolHandlers() {
139
144
  return import_react2.useContext(ToolHandlerContext);
140
145
  }
141
- // src/components/GenerativeUIRenderer.tsx
142
- var import_react4 = __toESM(require("react"));
143
-
144
- // src/utils/component-registry.ts
145
- class ComponentRegistry {
146
- static instance;
147
- components = new Map;
148
- constructor() {}
149
- static getInstance() {
150
- if (!ComponentRegistry.instance) {
151
- ComponentRegistry.instance = new ComponentRegistry;
152
- }
153
- return ComponentRegistry.instance;
154
- }
155
- register(type, renderer) {
156
- this.components.set(type, renderer);
157
- }
158
- registerBatch(components) {
159
- Object.entries(components).forEach(([type, renderer]) => {
160
- this.register(type, renderer);
161
- });
162
- }
163
- get(type) {
164
- return this.components.get(type);
165
- }
166
- has(type) {
167
- return this.components.has(type);
168
- }
169
- unregister(type) {
170
- this.components.delete(type);
171
- }
172
- getRegisteredTypes() {
173
- return Array.from(this.components.keys());
174
- }
175
- clear() {
176
- this.components.clear();
177
- }
146
+ // src/utils/ui-helpers.ts
147
+ function createBarChart(data, xKey, bars, options) {
148
+ return {
149
+ type: "chart",
150
+ component: "BarChart",
151
+ layout: options?.layout,
152
+ title: options?.title,
153
+ description: options?.description,
154
+ props: {
155
+ data,
156
+ xKey,
157
+ bars: bars.map((bar) => ({
158
+ key: bar.key,
159
+ label: bar.label || bar.key,
160
+ color: bar.color
161
+ })),
162
+ showLegend: options?.showLegend ?? true,
163
+ showGrid: options?.showGrid ?? true,
164
+ height: options?.height,
165
+ width: options?.width
166
+ }
167
+ };
178
168
  }
179
- function getComponentRegistry() {
180
- return ComponentRegistry.getInstance();
169
+ function createLineChart(data, xKey, lines, options) {
170
+ return {
171
+ type: "chart",
172
+ component: "LineChart",
173
+ layout: options?.layout,
174
+ title: options?.title,
175
+ description: options?.description,
176
+ props: {
177
+ data,
178
+ xKey,
179
+ lines: lines.map((line) => ({
180
+ key: line.key,
181
+ label: line.label || line.key,
182
+ color: line.color
183
+ })),
184
+ showLegend: options?.showLegend ?? true,
185
+ showGrid: options?.showGrid ?? true,
186
+ height: options?.height,
187
+ width: options?.width
188
+ }
189
+ };
181
190
  }
182
- function registerChartComponent(name, renderer) {
183
- getComponentRegistry().register(`chart:${name}`, renderer);
191
+ function createPieChart(data, dataKey, nameKey, options) {
192
+ return {
193
+ type: "chart",
194
+ component: "PieChart",
195
+ layout: options?.layout,
196
+ title: options?.title,
197
+ description: options?.description,
198
+ props: {
199
+ data,
200
+ pie: {
201
+ dataKey,
202
+ nameKey,
203
+ label: options?.showLabel ?? true
204
+ },
205
+ showLegend: options?.showLegend ?? true,
206
+ height: options?.height || 400,
207
+ width: options?.width
208
+ }
209
+ };
184
210
  }
185
- function getChartComponent(name) {
186
- return getComponentRegistry().get(`chart:${name}`);
211
+ function createAreaChart(data, xKey, areas, options) {
212
+ return {
213
+ type: "chart",
214
+ component: "AreaChart",
215
+ layout: options?.layout,
216
+ title: options?.title,
217
+ description: options?.description,
218
+ props: {
219
+ data,
220
+ xKey,
221
+ areas: areas.map((area) => ({
222
+ key: area.key,
223
+ label: area.label || area.key,
224
+ color: area.color
225
+ })),
226
+ showLegend: options?.showLegend ?? true,
227
+ showGrid: options?.showGrid ?? true,
228
+ height: options?.height,
229
+ width: options?.width
230
+ }
231
+ };
187
232
  }
188
-
189
- // src/hooks/useAgnoToolExecution.ts
190
- var import_react3 = require("react");
191
- var customRenderRegistry = new Map;
192
- function registerCustomRender(renderFn) {
193
- const key = `custom-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
194
- customRenderRegistry.set(key, renderFn);
195
- return key;
233
+ function createCardGrid(cards, options) {
234
+ return {
235
+ type: "card-grid",
236
+ layout: options?.layout,
237
+ title: options?.title,
238
+ description: options?.description,
239
+ props: {
240
+ cards,
241
+ columns: options?.columns || { default: 1, md: 2, lg: 3 },
242
+ variant: options?.variant || "default"
243
+ }
244
+ };
196
245
  }
197
- function getCustomRender(key) {
198
- return customRenderRegistry.get(key);
246
+ function createCard(id, title, description, options) {
247
+ return {
248
+ id,
249
+ title,
250
+ description,
251
+ image: options?.image,
252
+ metadata: options?.metadata,
253
+ actions: options?.actions
254
+ };
199
255
  }
200
- function isToolHandlerResult(value) {
201
- return value && typeof value === "object" && (("data" in value) || ("ui" in value));
256
+ function createTable(data, columns, options) {
257
+ return {
258
+ type: "table",
259
+ layout: options?.layout,
260
+ title: options?.title,
261
+ description: options?.description,
262
+ props: {
263
+ data,
264
+ columns,
265
+ sortable: options?.sortable ?? true,
266
+ filterable: options?.filterable,
267
+ pagination: options?.pagination,
268
+ density: options?.density || "comfortable"
269
+ }
270
+ };
202
271
  }
203
- function isUIComponentSpec(value) {
204
- return value && typeof value === "object" && "type" in value;
272
+ function createColumn(key, header, options) {
273
+ return {
274
+ key,
275
+ header,
276
+ width: options?.width,
277
+ sortable: options?.sortable,
278
+ cellType: options?.cellType || "text",
279
+ format: options?.format
280
+ };
205
281
  }
206
- function processToolResult(result, _tool) {
207
- if (isToolHandlerResult(result)) {
208
- const { data, ui } = result;
209
- let uiComponent = undefined;
210
- if (ui) {
211
- if (ui.type === "custom" && typeof ui.render === "function") {
212
- const renderKey = registerCustomRender(ui.render);
213
- uiComponent = {
214
- ...ui,
215
- renderKey,
216
- render: undefined
217
- };
218
- } else {
219
- uiComponent = ui;
220
- }
282
+ function createMarkdown(content, options) {
283
+ return {
284
+ type: "markdown",
285
+ layout: options?.layout,
286
+ title: options?.title,
287
+ description: options?.description,
288
+ props: {
289
+ content,
290
+ syntaxHighlight: options?.syntaxHighlight ?? true
221
291
  }
222
- return {
223
- resultData: typeof data === "string" ? data : JSON.stringify(data),
224
- uiComponent
225
- };
292
+ };
293
+ }
294
+ function createArtifact(content, options) {
295
+ return {
296
+ type: "artifact",
297
+ title: options?.title,
298
+ description: options?.description,
299
+ props: {
300
+ content,
301
+ variant: options?.variant || "default"
302
+ }
303
+ };
304
+ }
305
+ function createSmartChart(data, options) {
306
+ if (!data || data.length === 0) {
307
+ return createBarChart([], "", [], options);
226
308
  }
227
- if (isUIComponentSpec(result)) {
228
- let uiComponent;
229
- if (result.type === "custom" && typeof result.render === "function") {
230
- const renderKey = registerCustomRender(result.render);
231
- uiComponent = {
232
- ...result,
233
- renderKey,
234
- render: undefined
235
- };
236
- } else {
237
- uiComponent = result;
309
+ const firstItem = data[0];
310
+ const keys = Object.keys(firstItem);
311
+ const xKey = options?.xKey || keys.find((k) => ["name", "label", "category", "date", "time", "month", "year"].includes(k.toLowerCase())) || keys[0];
312
+ const numericKeys = keys.filter((k) => k !== xKey && typeof firstItem[k] === "number");
313
+ const yKeys = options?.yKeys || numericKeys;
314
+ if (options?.preferredType) {
315
+ switch (options.preferredType) {
316
+ case "bar":
317
+ return createBarChart(data, xKey, yKeys.map((key) => ({ key })), options);
318
+ case "line":
319
+ return createLineChart(data, xKey, yKeys.map((key) => ({ key })), options);
320
+ case "area":
321
+ return createAreaChart(data, xKey, yKeys.map((key) => ({ key })), options);
322
+ case "pie":
323
+ return createPieChart(data, yKeys[0], xKey, options);
238
324
  }
239
- return {
240
- resultData: JSON.stringify(result),
241
- uiComponent
242
- };
243
325
  }
244
- return {
245
- resultData: typeof result === "string" ? result : JSON.stringify(result),
246
- uiComponent: undefined
247
- };
326
+ if (yKeys.length === 1 && typeof firstItem[xKey] === "string") {
327
+ return createPieChart(data, yKeys[0], xKey, options);
328
+ }
329
+ if (xKey.toLowerCase().includes("date") || xKey.toLowerCase().includes("time") || xKey.toLowerCase().includes("month") || xKey.toLowerCase().includes("year")) {
330
+ return createLineChart(data, xKey, yKeys.map((key) => ({ key })), options);
331
+ }
332
+ return createBarChart(data, xKey, yKeys.map((key) => ({ key })), options);
248
333
  }
249
- function useAgnoToolExecution(handlers = {}, autoExecute = true, options) {
334
+ function createToolResult(data, ui) {
335
+ return { data, ui };
336
+ }
337
+ function resultWithBarChart(data, xKey, bars, options) {
338
+ return createToolResult(data, createBarChart(data, xKey, bars, options));
339
+ }
340
+ function resultWithSmartChart(data, options) {
341
+ return createToolResult(data, createSmartChart(data, options));
342
+ }
343
+ function resultWithCardGrid(cards, options) {
344
+ return createToolResult(cards, createCardGrid(cards, options));
345
+ }
346
+ function resultWithTable(data, columns, options) {
347
+ return createToolResult(data, createTable(data, columns, options));
348
+ }
349
+ // src/hooks/useAgnoChat.ts
350
+ var import_react3 = require("react");
351
+ function useAgnoChat() {
250
352
  const client = useAgnoClient();
251
- const toolHandlerContext = useToolHandlers();
252
- const isTeamMode = client.getConfig().mode === "team";
253
- import_react3.useEffect(() => {
254
- if (isTeamMode) {
255
- console.warn("[useAgnoToolExecution] HITL (Human-in-the-Loop) frontend tool execution is not supported for teams. " + "Only agents support the continue endpoint. This hook will not function in team mode.");
256
- }
257
- }, [isTeamMode]);
258
- const mergedHandlers = import_react3.useMemo(() => {
259
- const globalHandlers = toolHandlerContext?.handlers || {};
260
- return { ...globalHandlers, ...handlers };
261
- }, [toolHandlerContext?.handlers, handlers]);
262
- const [pendingTools, setPendingTools] = import_react3.useState([]);
263
- const [isPaused, setIsPaused] = import_react3.useState(false);
264
- const [isExecuting, setIsExecuting] = import_react3.useState(false);
265
- const [executionError, setExecutionError] = import_react3.useState();
353
+ const [messages, setMessages] = import_react3.useState(client.getMessages());
354
+ const [state, setState] = import_react3.useState(client.getState());
266
355
  import_react3.useEffect(() => {
267
- if (isTeamMode) {
268
- return;
269
- }
270
- const handleRunPaused = (event) => {
271
- setIsPaused(true);
272
- setPendingTools(event.tools);
273
- setExecutionError(undefined);
356
+ const handleMessageUpdate = (updatedMessages) => {
357
+ setMessages(updatedMessages);
274
358
  };
275
- const handleRunContinued = () => {
276
- setIsPaused(false);
277
- setPendingTools([]);
278
- setIsExecuting(false);
279
- setExecutionError(undefined);
359
+ const handleMessageComplete = (updatedMessages) => {
360
+ setMessages(updatedMessages);
280
361
  };
281
- client.on("run:paused", handleRunPaused);
282
- client.on("run:continued", handleRunContinued);
283
- return () => {
284
- client.off("run:paused", handleRunPaused);
285
- client.off("run:continued", handleRunContinued);
362
+ const handleMessageRefreshed = (updatedMessages) => {
363
+ setMessages(updatedMessages);
286
364
  };
287
- }, [client, isTeamMode]);
288
- const executeAndContinue = import_react3.useCallback(async () => {
289
- if (!isPaused || pendingTools.length === 0) {
290
- console.warn("[useAgnoToolExecution] Cannot execute: no pending tools");
291
- return;
292
- }
293
- setIsExecuting(true);
294
- setExecutionError(undefined);
295
- try {
296
- const updatedTools = await Promise.all(pendingTools.map(async (tool) => {
297
- const handler = mergedHandlers[tool.tool_name];
298
- if (!handler) {
299
- return {
300
- ...tool,
301
- result: JSON.stringify({
302
- error: `No handler registered for ${tool.tool_name}`
303
- })
304
- };
305
- }
306
- try {
307
- const result = await handler(tool.tool_args);
308
- const { resultData, uiComponent } = processToolResult(result, tool);
309
- return {
310
- ...tool,
311
- result: resultData,
312
- ui_component: uiComponent
313
- };
314
- } catch (error) {
315
- return {
316
- ...tool,
317
- result: JSON.stringify({
318
- error: error instanceof Error ? error.message : String(error)
319
- })
320
- };
365
+ const handleStateChange = (newState) => {
366
+ setState(newState);
367
+ };
368
+ const handleUIRender = (event) => {
369
+ const { tools } = event;
370
+ for (const tool of tools) {
371
+ if (tool.ui_component) {
372
+ client.hydrateToolCallUI(tool.tool_call_id, tool.ui_component);
321
373
  }
322
- }));
323
- const toolsWithUI = updatedTools.filter((t) => t.ui_component);
324
- if (toolsWithUI.length > 0) {
325
- client.emit("ui:render", {
326
- tools: updatedTools,
327
- runId: client.getState().pausedRunId
328
- });
329
374
  }
330
- client.addToolCallsToLastMessage(updatedTools);
331
- await client.continueRun(updatedTools);
332
- } catch (error) {
333
- const errorMessage = error instanceof Error ? error.message : String(error);
334
- setExecutionError(errorMessage);
335
- setIsExecuting(false);
336
- throw error;
375
+ };
376
+ const handleRunCancelled = () => {};
377
+ client.on("message:update", handleMessageUpdate);
378
+ client.on("message:complete", handleMessageComplete);
379
+ client.on("message:refreshed", handleMessageRefreshed);
380
+ client.on("state:change", handleStateChange);
381
+ client.on("ui:render", handleUIRender);
382
+ client.on("run:cancelled", handleRunCancelled);
383
+ setMessages(client.getMessages());
384
+ setState(client.getState());
385
+ return () => {
386
+ client.off("message:update", handleMessageUpdate);
387
+ client.off("message:complete", handleMessageComplete);
388
+ client.off("message:refreshed", handleMessageRefreshed);
389
+ client.off("state:change", handleStateChange);
390
+ client.off("ui:render", handleUIRender);
391
+ client.off("run:cancelled", handleRunCancelled);
392
+ };
393
+ }, [client]);
394
+ const sendMessage = import_react3.useCallback(async (message, options) => {
395
+ try {
396
+ await client.sendMessage(message, options);
397
+ } catch (err) {
398
+ throw err;
337
399
  }
338
- }, [client, mergedHandlers, isPaused, pendingTools]);
339
- import_react3.useEffect(() => {
340
- const handleSessionLoaded = async (_sessionId) => {
341
- const messages = client.getMessages();
342
- for (const message of messages) {
343
- if (!message.tool_calls)
344
- continue;
345
- for (const tool of message.tool_calls) {
346
- if (tool.ui_component)
347
- continue;
348
- if (options?.skipHydration?.includes(tool.tool_name))
349
- continue;
350
- const handler = mergedHandlers[tool.tool_name];
351
- if (!handler)
352
- continue;
353
- try {
354
- const result = await handler(tool.tool_args);
355
- const { uiComponent } = processToolResult(result, tool);
356
- if (uiComponent) {
357
- client.hydrateToolCallUI(tool.tool_call_id, uiComponent);
358
- }
359
- } catch (err) {
360
- console.error(`Failed to hydrate UI for ${tool.tool_name}:`, err);
361
- }
362
- }
363
- }
400
+ }, [client]);
401
+ const clearMessages = import_react3.useCallback(() => {
402
+ client.clearMessages();
403
+ setMessages([]);
404
+ }, [client]);
405
+ const cancelRun = import_react3.useCallback(async () => {
406
+ await client.cancelRun();
407
+ }, [client]);
408
+ return {
409
+ messages,
410
+ sendMessage,
411
+ clearMessages,
412
+ cancelRun,
413
+ isStreaming: state.isStreaming,
414
+ isRefreshing: state.isRefreshing,
415
+ isPaused: state.isPaused,
416
+ isCancelling: state.isCancelling,
417
+ currentRunId: state.currentRunId,
418
+ error: state.errorMessage,
419
+ state
420
+ };
421
+ }
422
+ // src/hooks/useAgnoSession.ts
423
+ var import_react4 = require("react");
424
+ function useAgnoSession() {
425
+ const client = useAgnoClient();
426
+ const [sessions, setSessions] = import_react4.useState([]);
427
+ const [currentSessionId, setCurrentSessionId] = import_react4.useState(client.getConfig().sessionId);
428
+ const [isLoading, setIsLoading] = import_react4.useState(false);
429
+ const [error, setError] = import_react4.useState();
430
+ import_react4.useEffect(() => {
431
+ const handleSessionLoaded = (sessionId) => {
432
+ setCurrentSessionId(sessionId);
433
+ };
434
+ const handleSessionCreated = (session) => {
435
+ setSessions((prev) => [session, ...prev]);
436
+ setCurrentSessionId(session.session_id);
437
+ };
438
+ const handleStateChange = () => {
439
+ const config = client.getConfig();
440
+ setCurrentSessionId(config.sessionId);
441
+ setSessions(client.getState().sessions);
364
442
  };
365
443
  client.on("session:loaded", handleSessionLoaded);
444
+ client.on("session:created", handleSessionCreated);
445
+ client.on("state:change", handleStateChange);
446
+ setSessions(client.getState().sessions);
447
+ setCurrentSessionId(client.getConfig().sessionId);
366
448
  return () => {
367
449
  client.off("session:loaded", handleSessionLoaded);
450
+ client.off("session:created", handleSessionCreated);
451
+ client.off("state:change", handleStateChange);
368
452
  };
369
- }, [client, mergedHandlers]);
370
- const executeTools = import_react3.useCallback(async (tools) => {
371
- return Promise.all(tools.map(async (tool) => {
372
- const handler = mergedHandlers[tool.tool_name];
373
- if (!handler)
374
- return tool;
375
- try {
376
- const result = await handler(tool.tool_args);
377
- const { resultData, uiComponent } = processToolResult(result, tool);
378
- return {
379
- ...tool,
380
- result: resultData,
381
- ui_component: uiComponent
382
- };
383
- } catch (error) {
384
- return {
385
- ...tool,
386
- result: JSON.stringify({
387
- error: error instanceof Error ? error.message : String(error)
388
- })
389
- };
390
- }
391
- }));
392
- }, [mergedHandlers]);
393
- const continueWithResults = import_react3.useCallback(async (tools, options2) => {
394
- if (!isPaused) {
395
- throw new Error("No paused run to continue");
453
+ }, [client]);
454
+ const loadSession = import_react4.useCallback(async (sessionId, options) => {
455
+ setIsLoading(true);
456
+ setError(undefined);
457
+ try {
458
+ const messages = await client.loadSession(sessionId, options);
459
+ setCurrentSessionId(sessionId);
460
+ return messages;
461
+ } catch (err) {
462
+ const errorMessage = err instanceof Error ? err.message : String(err);
463
+ setError(errorMessage);
464
+ throw err;
465
+ } finally {
466
+ setIsLoading(false);
396
467
  }
397
- setIsExecuting(true);
468
+ }, [client]);
469
+ const fetchSessions = import_react4.useCallback(async (options) => {
470
+ setIsLoading(true);
471
+ setError(undefined);
398
472
  try {
399
- await client.continueRun(tools, options2);
400
- } catch (error) {
401
- setIsExecuting(false);
402
- throw error;
473
+ const fetchedSessions = await client.fetchSessions(options);
474
+ setSessions(fetchedSessions);
475
+ return fetchedSessions;
476
+ } catch (err) {
477
+ const errorMessage = err instanceof Error ? err.message : String(err);
478
+ setError(errorMessage);
479
+ throw err;
480
+ } finally {
481
+ setIsLoading(false);
403
482
  }
404
- }, [client, isPaused]);
405
- import_react3.useEffect(() => {
406
- if (autoExecute && isPaused && !isExecuting && pendingTools.length > 0) {
407
- executeAndContinue();
483
+ }, [client]);
484
+ const getSessionById = import_react4.useCallback(async (sessionId, options) => {
485
+ setIsLoading(true);
486
+ setError(undefined);
487
+ try {
488
+ return await client.getSessionById(sessionId, options);
489
+ } catch (err) {
490
+ const errorMessage = err instanceof Error ? err.message : String(err);
491
+ setError(errorMessage);
492
+ throw err;
493
+ } finally {
494
+ setIsLoading(false);
408
495
  }
409
- }, [autoExecute, isPaused, isExecuting, pendingTools.length, executeAndContinue]);
410
- return {
411
- isPaused,
412
- isExecuting,
413
- pendingTools,
414
- executeAndContinue,
415
- executeTools,
416
- continueWithResults,
417
- executionError
418
- };
419
- }
420
-
421
- // src/components/GenerativeUIRenderer.tsx
422
- var jsx_runtime3 = require("react/jsx-runtime");
423
-
424
- class UIErrorBoundary extends import_react4.default.Component {
425
- constructor(props) {
426
- super(props);
427
- this.state = { hasError: false };
428
- }
429
- static getDerivedStateFromError(error) {
430
- return { hasError: true, error };
431
- }
432
- componentDidCatch(error, errorInfo) {
433
- console.error("[GenerativeUIRenderer] Error rendering component:", error, errorInfo);
434
- this.props.onError?.(error);
435
- }
436
- render() {
437
- if (this.state.hasError) {
438
- return this.props.fallback || /* @__PURE__ */ jsx_runtime3.jsxs("div", {
439
- className: "p-4 border border-red-300 rounded-md bg-red-50 text-red-800",
440
- children: [
441
- /* @__PURE__ */ jsx_runtime3.jsx("p", {
442
- className: "font-semibold",
443
- children: "Failed to render UI component"
444
- }),
445
- /* @__PURE__ */ jsx_runtime3.jsx("p", {
446
- className: "text-sm mt-1",
447
- children: this.state.error?.message || "Unknown error"
448
- })
449
- ]
450
- });
496
+ }, [client]);
497
+ const getRunById = import_react4.useCallback(async (sessionId, runId, options) => {
498
+ setIsLoading(true);
499
+ setError(undefined);
500
+ try {
501
+ return await client.getRunById(sessionId, runId, options);
502
+ } catch (err) {
503
+ const errorMessage = err instanceof Error ? err.message : String(err);
504
+ setError(errorMessage);
505
+ throw err;
506
+ } finally {
507
+ setIsLoading(false);
451
508
  }
452
- return this.props.children;
453
- }
454
- }
455
- function GenerativeUIRenderer({
456
- spec,
457
- className,
458
- onError
459
- }) {
460
- const registry = getComponentRegistry();
461
- if (spec.type === "custom") {
462
- const customSpec = spec;
463
- if (customSpec.renderKey) {
464
- const renderFn = getCustomRender(customSpec.renderKey);
465
- if (renderFn) {
466
- return /* @__PURE__ */ jsx_runtime3.jsx(UIErrorBoundary, {
467
- onError,
468
- children: /* @__PURE__ */ jsx_runtime3.jsx("div", {
469
- className,
470
- children: renderFn(customSpec.props || {})
471
- })
472
- });
473
- }
509
+ }, [client]);
510
+ const createSession = import_react4.useCallback(async (request, options) => {
511
+ setIsLoading(true);
512
+ setError(undefined);
513
+ try {
514
+ const session = await client.createSession(request, options);
515
+ return session;
516
+ } catch (err) {
517
+ const errorMessage = err instanceof Error ? err.message : String(err);
518
+ setError(errorMessage);
519
+ throw err;
520
+ } finally {
521
+ setIsLoading(false);
474
522
  }
475
- return /* @__PURE__ */ jsx_runtime3.jsxs("div", {
476
- className: `p-4 border border-yellow-300 rounded-md bg-yellow-50 text-yellow-800 ${className || ""}`,
477
- children: [
478
- /* @__PURE__ */ jsx_runtime3.jsx("p", {
479
- className: "font-semibold",
480
- children: "Custom component not available"
481
- }),
482
- /* @__PURE__ */ jsx_runtime3.jsx("p", {
483
- className: "text-sm mt-1",
484
- children: "The custom render function for this component is not available."
485
- })
486
- ]
487
- });
488
- }
489
- if (spec.type === "chart") {
490
- const chartSpec = spec;
491
- const chartType = `chart:${chartSpec.component}`;
492
- if (registry.has(chartType)) {
493
- const ChartRenderer = registry.get(chartType);
494
- return /* @__PURE__ */ jsx_runtime3.jsx(UIErrorBoundary, {
495
- onError,
496
- children: /* @__PURE__ */ jsx_runtime3.jsxs("div", {
497
- className,
498
- children: [
499
- chartSpec.title && /* @__PURE__ */ jsx_runtime3.jsx("h3", {
500
- className: "font-semibold mb-2",
501
- children: chartSpec.title
502
- }),
503
- chartSpec.description && /* @__PURE__ */ jsx_runtime3.jsx("p", {
504
- className: "text-sm text-gray-600 mb-4",
505
- children: chartSpec.description
506
- }),
507
- /* @__PURE__ */ jsx_runtime3.jsx(ChartRenderer, {
508
- ...chartSpec.props
509
- })
510
- ]
511
- })
512
- });
523
+ }, [client]);
524
+ const updateSession = import_react4.useCallback(async (sessionId, request, options) => {
525
+ setIsLoading(true);
526
+ setError(undefined);
527
+ try {
528
+ return await client.updateSession(sessionId, request, options);
529
+ } catch (err) {
530
+ const errorMessage = err instanceof Error ? err.message : String(err);
531
+ setError(errorMessage);
532
+ throw err;
533
+ } finally {
534
+ setIsLoading(false);
513
535
  }
514
- return /* @__PURE__ */ jsx_runtime3.jsxs("div", {
515
- className: `p-4 border border-gray-300 rounded-md ${className || ""}`,
516
- children: [
517
- /* @__PURE__ */ jsx_runtime3.jsx("p", {
518
- className: "font-semibold mb-2",
519
- children: chartSpec.title || "Chart Data"
520
- }),
521
- chartSpec.description && /* @__PURE__ */ jsx_runtime3.jsx("p", {
522
- className: "text-sm text-gray-600 mb-2",
523
- children: chartSpec.description
524
- }),
525
- /* @__PURE__ */ jsx_runtime3.jsx("pre", {
526
- className: "text-xs bg-gray-100 p-2 rounded overflow-auto",
527
- children: JSON.stringify(chartSpec.props.data, null, 2)
528
- })
529
- ]
530
- });
531
- }
532
- if (spec.type === "card-grid") {
533
- const cardGridSpec = spec;
534
- if (registry.has("card-grid")) {
535
- const CardGridRenderer = registry.get("card-grid");
536
- return /* @__PURE__ */ jsx_runtime3.jsx(UIErrorBoundary, {
537
- onError,
538
- children: /* @__PURE__ */ jsx_runtime3.jsxs("div", {
539
- className,
540
- children: [
541
- cardGridSpec.title && /* @__PURE__ */ jsx_runtime3.jsx("h3", {
542
- className: "font-semibold mb-2",
543
- children: cardGridSpec.title
544
- }),
545
- cardGridSpec.description && /* @__PURE__ */ jsx_runtime3.jsx("p", {
546
- className: "text-sm text-gray-600 mb-4",
547
- children: cardGridSpec.description
548
- }),
549
- /* @__PURE__ */ jsx_runtime3.jsx(CardGridRenderer, {
550
- ...cardGridSpec.props
551
- })
552
- ]
553
- })
554
- });
536
+ }, [client]);
537
+ const renameSession = import_react4.useCallback(async (sessionId, newName, options) => {
538
+ setIsLoading(true);
539
+ setError(undefined);
540
+ try {
541
+ return await client.renameSession(sessionId, newName, options);
542
+ } catch (err) {
543
+ const errorMessage = err instanceof Error ? err.message : String(err);
544
+ setError(errorMessage);
545
+ throw err;
546
+ } finally {
547
+ setIsLoading(false);
555
548
  }
556
- }
557
- if (spec.type === "table") {
558
- const tableSpec = spec;
559
- if (registry.has("table")) {
560
- const TableRenderer = registry.get("table");
561
- return /* @__PURE__ */ jsx_runtime3.jsx(UIErrorBoundary, {
562
- onError,
563
- children: /* @__PURE__ */ jsx_runtime3.jsxs("div", {
564
- className,
565
- children: [
566
- tableSpec.title && /* @__PURE__ */ jsx_runtime3.jsx("h3", {
567
- className: "font-semibold mb-2",
568
- children: tableSpec.title
569
- }),
570
- tableSpec.description && /* @__PURE__ */ jsx_runtime3.jsx("p", {
571
- className: "text-sm text-gray-600 mb-4",
572
- children: tableSpec.description
573
- }),
574
- /* @__PURE__ */ jsx_runtime3.jsx(TableRenderer, {
575
- ...tableSpec.props
576
- })
577
- ]
578
- })
579
- });
549
+ }, [client]);
550
+ const deleteSession = import_react4.useCallback(async (sessionId, options) => {
551
+ setIsLoading(true);
552
+ setError(undefined);
553
+ try {
554
+ await client.deleteSession(sessionId, options);
555
+ } catch (err) {
556
+ const errorMessage = err instanceof Error ? err.message : String(err);
557
+ setError(errorMessage);
558
+ throw err;
559
+ } finally {
560
+ setIsLoading(false);
580
561
  }
581
- }
582
- if (spec.type === "markdown") {
583
- const markdownSpec = spec;
584
- if (registry.has("markdown")) {
585
- const MarkdownRenderer = registry.get("markdown");
586
- return /* @__PURE__ */ jsx_runtime3.jsx(UIErrorBoundary, {
587
- onError,
588
- children: /* @__PURE__ */ jsx_runtime3.jsx("div", {
589
- className,
590
- children: /* @__PURE__ */ jsx_runtime3.jsx(MarkdownRenderer, {
591
- ...markdownSpec.props
592
- })
593
- })
594
- });
562
+ }, [client]);
563
+ const deleteMultipleSessions = import_react4.useCallback(async (sessionIds, options) => {
564
+ setIsLoading(true);
565
+ setError(undefined);
566
+ try {
567
+ await client.deleteMultipleSessions(sessionIds, options);
568
+ } catch (err) {
569
+ const errorMessage = err instanceof Error ? err.message : String(err);
570
+ setError(errorMessage);
571
+ throw err;
572
+ } finally {
573
+ setIsLoading(false);
595
574
  }
596
- return /* @__PURE__ */ jsx_runtime3.jsx("div", {
597
- className,
598
- children: markdownSpec.props.content
599
- });
600
- }
601
- if (spec.type === "artifact") {
602
- const artifactSpec = spec;
603
- return /* @__PURE__ */ jsx_runtime3.jsx(UIErrorBoundary, {
604
- onError,
605
- children: /* @__PURE__ */ jsx_runtime3.jsxs("div", {
606
- className: `p-4 border rounded-md ${className || ""}`,
607
- children: [
608
- artifactSpec.title && /* @__PURE__ */ jsx_runtime3.jsx("h3", {
609
- className: "font-semibold mb-4",
610
- children: artifactSpec.title
611
- }),
612
- artifactSpec.description && /* @__PURE__ */ jsx_runtime3.jsx("p", {
613
- className: "text-sm text-gray-600 mb-4",
614
- children: artifactSpec.description
615
- }),
616
- /* @__PURE__ */ jsx_runtime3.jsx("div", {
617
- className: "space-y-4",
618
- children: artifactSpec.props.content?.map((childSpec, index) => /* @__PURE__ */ jsx_runtime3.jsx(GenerativeUIRenderer, {
619
- spec: childSpec,
620
- onError
621
- }, index))
622
- })
623
- ]
624
- })
625
- });
626
- }
627
- return /* @__PURE__ */ jsx_runtime3.jsxs("div", {
628
- className: `p-4 border border-gray-300 rounded-md ${className || ""}`,
629
- children: [
630
- /* @__PURE__ */ jsx_runtime3.jsx("p", {
631
- className: "font-semibold",
632
- children: "Unsupported UI component"
633
- }),
634
- /* @__PURE__ */ jsx_runtime3.jsxs("p", {
635
- className: "text-sm text-gray-600 mt-1",
636
- children: [
637
- "Component type: ",
638
- spec.type
639
- ]
640
- })
641
- ]
642
- });
643
- }
644
- // src/utils/ui-helpers.ts
645
- function createBarChart(data, xKey, bars, options) {
575
+ }, [client]);
646
576
  return {
647
- type: "chart",
648
- component: "BarChart",
649
- layout: options?.layout,
650
- title: options?.title,
651
- description: options?.description,
652
- props: {
653
- data,
654
- xKey,
655
- bars: bars.map((bar) => ({
656
- key: bar.key,
657
- label: bar.label || bar.key,
658
- color: bar.color
659
- })),
660
- showLegend: options?.showLegend ?? true,
661
- showGrid: options?.showGrid ?? true,
662
- height: options?.height,
663
- width: options?.width
664
- }
577
+ sessions,
578
+ currentSessionId,
579
+ loadSession,
580
+ fetchSessions,
581
+ getSessionById,
582
+ getRunById,
583
+ createSession,
584
+ updateSession,
585
+ renameSession,
586
+ deleteSession,
587
+ deleteMultipleSessions,
588
+ isLoading,
589
+ error
665
590
  };
666
591
  }
667
- function createLineChart(data, xKey, lines, options) {
668
- return {
669
- type: "chart",
670
- component: "LineChart",
671
- layout: options?.layout,
672
- title: options?.title,
673
- description: options?.description,
674
- props: {
675
- data,
676
- xKey,
677
- lines: lines.map((line) => ({
678
- key: line.key,
679
- label: line.label || line.key,
680
- color: line.color
681
- })),
682
- showLegend: options?.showLegend ?? true,
683
- showGrid: options?.showGrid ?? true,
684
- height: options?.height,
685
- width: options?.width
592
+ // src/hooks/useAgnoActions.ts
593
+ var import_react5 = require("react");
594
+ function useAgnoActions() {
595
+ const client = useAgnoClient();
596
+ const [isInitializing, setIsInitializing] = import_react5.useState(false);
597
+ const [error, setError] = import_react5.useState();
598
+ const initialize = import_react5.useCallback(async (options) => {
599
+ setIsInitializing(true);
600
+ setError(undefined);
601
+ try {
602
+ const result = await client.initialize(options);
603
+ return result;
604
+ } catch (err) {
605
+ const errorMessage = err instanceof Error ? err.message : String(err);
606
+ setError(errorMessage);
607
+ throw err;
608
+ } finally {
609
+ setIsInitializing(false);
686
610
  }
687
- };
688
- }
689
- function createPieChart(data, dataKey, nameKey, options) {
690
- return {
691
- type: "chart",
692
- component: "PieChart",
693
- layout: options?.layout,
694
- title: options?.title,
695
- description: options?.description,
696
- props: {
697
- data,
698
- pie: {
699
- dataKey,
700
- nameKey,
701
- label: options?.showLabel ?? true
702
- },
703
- showLegend: options?.showLegend ?? true,
704
- height: options?.height || 400,
705
- width: options?.width
611
+ }, [client]);
612
+ const checkStatus = import_react5.useCallback(async (options) => {
613
+ setError(undefined);
614
+ try {
615
+ return await client.checkStatus(options);
616
+ } catch (err) {
617
+ const errorMessage = err instanceof Error ? err.message : String(err);
618
+ setError(errorMessage);
619
+ return false;
706
620
  }
707
- };
708
- }
709
- function createAreaChart(data, xKey, areas, options) {
710
- return {
711
- type: "chart",
712
- component: "AreaChart",
713
- layout: options?.layout,
714
- title: options?.title,
715
- description: options?.description,
716
- props: {
717
- data,
718
- xKey,
719
- areas: areas.map((area) => ({
720
- key: area.key,
721
- label: area.label || area.key,
722
- color: area.color
723
- })),
724
- showLegend: options?.showLegend ?? true,
725
- showGrid: options?.showGrid ?? true,
726
- height: options?.height,
727
- width: options?.width
621
+ }, [client]);
622
+ const fetchAgents = import_react5.useCallback(async (options) => {
623
+ setError(undefined);
624
+ try {
625
+ return await client.fetchAgents(options);
626
+ } catch (err) {
627
+ const errorMessage = err instanceof Error ? err.message : String(err);
628
+ setError(errorMessage);
629
+ throw err;
728
630
  }
729
- };
730
- }
731
- function createCardGrid(cards, options) {
631
+ }, [client]);
632
+ const fetchTeams = import_react5.useCallback(async (options) => {
633
+ setError(undefined);
634
+ try {
635
+ return await client.fetchTeams(options);
636
+ } catch (err) {
637
+ const errorMessage = err instanceof Error ? err.message : String(err);
638
+ setError(errorMessage);
639
+ throw err;
640
+ }
641
+ }, [client]);
642
+ const updateConfig = import_react5.useCallback((updates) => {
643
+ client.updateConfig(updates);
644
+ }, [client]);
732
645
  return {
733
- type: "card-grid",
734
- layout: options?.layout,
735
- title: options?.title,
736
- description: options?.description,
737
- props: {
738
- cards,
739
- columns: options?.columns || { default: 1, md: 2, lg: 3 },
740
- variant: options?.variant || "default"
741
- }
742
- };
743
- }
744
- function createCard(id, title, description, options) {
745
- return {
746
- id,
747
- title,
748
- description,
749
- image: options?.image,
750
- metadata: options?.metadata,
751
- actions: options?.actions
646
+ initialize,
647
+ checkStatus,
648
+ fetchAgents,
649
+ fetchTeams,
650
+ updateConfig,
651
+ isInitializing,
652
+ error
752
653
  };
753
654
  }
754
- function createTable(data, columns, options) {
755
- return {
756
- type: "table",
757
- layout: options?.layout,
758
- title: options?.title,
759
- description: options?.description,
760
- props: {
761
- data,
762
- columns,
763
- sortable: options?.sortable ?? true,
764
- filterable: options?.filterable,
765
- pagination: options?.pagination,
766
- density: options?.density || "comfortable"
767
- }
768
- };
655
+ // src/hooks/useAgnoToolExecution.ts
656
+ var import_react6 = require("react");
657
+ function isToolHandlerResult(value) {
658
+ return value && typeof value === "object" && (("data" in value) || ("ui" in value));
769
659
  }
770
- function createColumn(key, header, options) {
771
- return {
772
- key,
773
- header,
774
- width: options?.width,
775
- sortable: options?.sortable,
776
- cellType: options?.cellType || "text",
777
- format: options?.format
778
- };
660
+ function isUIComponentSpec(value) {
661
+ return value && typeof value === "object" && "type" in value;
779
662
  }
780
- function createMarkdown(content, options) {
663
+ function processToolResult(result, _tool) {
664
+ if (isToolHandlerResult(result)) {
665
+ const { data, ui } = result;
666
+ return {
667
+ resultData: typeof data === "string" ? data : JSON.stringify(data),
668
+ uiComponent: ui
669
+ };
670
+ }
671
+ if (isUIComponentSpec(result)) {
672
+ return {
673
+ resultData: JSON.stringify(result),
674
+ uiComponent: result
675
+ };
676
+ }
781
677
  return {
782
- type: "markdown",
783
- layout: options?.layout,
784
- title: options?.title,
785
- description: options?.description,
786
- props: {
787
- content,
788
- syntaxHighlight: options?.syntaxHighlight ?? true
789
- }
678
+ resultData: typeof result === "string" ? result : JSON.stringify(result),
679
+ uiComponent: undefined
790
680
  };
791
681
  }
792
- function createArtifact(content, options) {
793
- return {
794
- type: "artifact",
795
- title: options?.title,
796
- description: options?.description,
797
- props: {
798
- content,
799
- variant: options?.variant || "default"
682
+ function useAgnoToolExecution(handlers = {}, autoExecute = true, options) {
683
+ const client = useAgnoClient();
684
+ const toolHandlerContext = useToolHandlers();
685
+ const isTeamMode = client.getConfig().mode === "team";
686
+ import_react6.useEffect(() => {
687
+ if (isTeamMode) {
688
+ console.warn("[useAgnoToolExecution] HITL (Human-in-the-Loop) frontend tool execution is not supported for teams. " + "Only agents support the continue endpoint. This hook will not function in team mode.");
800
689
  }
801
- };
802
- }
803
- function createSmartChart(data, options) {
804
- if (!data || data.length === 0) {
805
- return createBarChart([], "", [], options);
806
- }
807
- const firstItem = data[0];
808
- const keys = Object.keys(firstItem);
809
- const xKey = options?.xKey || keys.find((k) => ["name", "label", "category", "date", "time", "month", "year"].includes(k.toLowerCase())) || keys[0];
810
- const numericKeys = keys.filter((k) => k !== xKey && typeof firstItem[k] === "number");
811
- const yKeys = options?.yKeys || numericKeys;
812
- if (options?.preferredType) {
813
- switch (options.preferredType) {
814
- case "bar":
815
- return createBarChart(data, xKey, yKeys.map((key) => ({ key })), options);
816
- case "line":
817
- return createLineChart(data, xKey, yKeys.map((key) => ({ key })), options);
818
- case "area":
819
- return createAreaChart(data, xKey, yKeys.map((key) => ({ key })), options);
820
- case "pie":
821
- return createPieChart(data, yKeys[0], xKey, options);
690
+ }, [isTeamMode]);
691
+ const mergedHandlers = import_react6.useMemo(() => {
692
+ const globalHandlers = toolHandlerContext?.handlers || {};
693
+ return { ...globalHandlers, ...handlers };
694
+ }, [toolHandlerContext?.handlers, handlers]);
695
+ const [pendingTools, setPendingTools] = import_react6.useState([]);
696
+ const [isPaused, setIsPaused] = import_react6.useState(false);
697
+ const [isExecuting, setIsExecuting] = import_react6.useState(false);
698
+ const [executionError, setExecutionError] = import_react6.useState();
699
+ import_react6.useEffect(() => {
700
+ if (isTeamMode) {
701
+ return;
822
702
  }
823
- }
824
- if (yKeys.length === 1 && typeof firstItem[xKey] === "string") {
825
- return createPieChart(data, yKeys[0], xKey, options);
826
- }
827
- if (xKey.toLowerCase().includes("date") || xKey.toLowerCase().includes("time") || xKey.toLowerCase().includes("month") || xKey.toLowerCase().includes("year")) {
828
- return createLineChart(data, xKey, yKeys.map((key) => ({ key })), options);
829
- }
830
- return createBarChart(data, xKey, yKeys.map((key) => ({ key })), options);
831
- }
832
- function createToolResult(data, ui) {
833
- return { data, ui };
834
- }
835
- function resultWithBarChart(data, xKey, bars, options) {
836
- return createToolResult(data, createBarChart(data, xKey, bars, options));
837
- }
838
- function resultWithSmartChart(data, options) {
839
- return createToolResult(data, createSmartChart(data, options));
840
- }
841
- function resultWithCardGrid(cards, options) {
842
- return createToolResult(cards, createCardGrid(cards, options));
843
- }
844
- function resultWithTable(data, columns, options) {
845
- return createToolResult(data, createTable(data, columns, options));
846
- }
847
- // src/hooks/useAgnoChat.ts
848
- var import_react5 = require("react");
849
- function useAgnoChat() {
850
- const client = useAgnoClient();
851
- const [messages, setMessages] = import_react5.useState(client.getMessages());
852
- const [state, setState] = import_react5.useState(client.getState());
853
- import_react5.useEffect(() => {
854
- const handleMessageUpdate = (updatedMessages) => {
855
- setMessages(updatedMessages);
856
- };
857
- const handleMessageComplete = (updatedMessages) => {
858
- setMessages(updatedMessages);
859
- };
860
- const handleMessageRefreshed = (updatedMessages) => {
861
- setMessages(updatedMessages);
862
- };
863
- const handleStateChange = (newState) => {
864
- setState(newState);
703
+ const handleRunPaused = (event) => {
704
+ setIsPaused(true);
705
+ setPendingTools(event.tools);
706
+ setExecutionError(undefined);
865
707
  };
866
- const handleUIRender = (event) => {
867
- const { tools } = event;
868
- for (const tool of tools) {
869
- if (tool.ui_component) {
870
- client.hydrateToolCallUI(tool.tool_call_id, tool.ui_component);
871
- }
872
- }
708
+ const handleRunContinued = () => {
709
+ setIsPaused(false);
710
+ setPendingTools([]);
711
+ setIsExecuting(false);
712
+ setExecutionError(undefined);
873
713
  };
874
- const handleRunCancelled = () => {};
875
- client.on("message:update", handleMessageUpdate);
876
- client.on("message:complete", handleMessageComplete);
877
- client.on("message:refreshed", handleMessageRefreshed);
878
- client.on("state:change", handleStateChange);
879
- client.on("ui:render", handleUIRender);
880
- client.on("run:cancelled", handleRunCancelled);
881
- setMessages(client.getMessages());
882
- setState(client.getState());
714
+ client.on("run:paused", handleRunPaused);
715
+ client.on("run:continued", handleRunContinued);
883
716
  return () => {
884
- client.off("message:update", handleMessageUpdate);
885
- client.off("message:complete", handleMessageComplete);
886
- client.off("message:refreshed", handleMessageRefreshed);
887
- client.off("state:change", handleStateChange);
888
- client.off("ui:render", handleUIRender);
889
- client.off("run:cancelled", handleRunCancelled);
717
+ client.off("run:paused", handleRunPaused);
718
+ client.off("run:continued", handleRunContinued);
890
719
  };
891
- }, [client]);
892
- const sendMessage = import_react5.useCallback(async (message, options) => {
720
+ }, [client, isTeamMode]);
721
+ const executeAndContinue = import_react6.useCallback(async () => {
722
+ if (!isPaused || pendingTools.length === 0) {
723
+ console.warn("[useAgnoToolExecution] Cannot execute: no pending tools");
724
+ return;
725
+ }
726
+ setIsExecuting(true);
727
+ setExecutionError(undefined);
893
728
  try {
894
- await client.sendMessage(message, options);
895
- } catch (err) {
896
- throw err;
729
+ const updatedTools = await Promise.all(pendingTools.map(async (tool) => {
730
+ const handler = mergedHandlers[tool.tool_name];
731
+ if (!handler) {
732
+ return {
733
+ ...tool,
734
+ result: JSON.stringify({
735
+ error: `No handler registered for ${tool.tool_name}`
736
+ })
737
+ };
738
+ }
739
+ try {
740
+ const result = await handler(tool.tool_args);
741
+ const { resultData, uiComponent } = processToolResult(result, tool);
742
+ return {
743
+ ...tool,
744
+ result: resultData,
745
+ ui_component: uiComponent
746
+ };
747
+ } catch (error) {
748
+ return {
749
+ ...tool,
750
+ result: JSON.stringify({
751
+ error: error instanceof Error ? error.message : String(error)
752
+ })
753
+ };
754
+ }
755
+ }));
756
+ const toolsWithUI = updatedTools.filter((t) => t.ui_component);
757
+ if (toolsWithUI.length > 0) {
758
+ client.emit("ui:render", {
759
+ tools: updatedTools,
760
+ runId: client.getState().pausedRunId
761
+ });
762
+ }
763
+ client.addToolCallsToLastMessage(updatedTools);
764
+ await client.continueRun(updatedTools);
765
+ } catch (error) {
766
+ const errorMessage = error instanceof Error ? error.message : String(error);
767
+ setExecutionError(errorMessage);
768
+ setIsExecuting(false);
769
+ throw error;
897
770
  }
898
- }, [client]);
899
- const clearMessages = import_react5.useCallback(() => {
900
- client.clearMessages();
901
- setMessages([]);
902
- }, [client]);
903
- const cancelRun = import_react5.useCallback(async () => {
904
- await client.cancelRun();
905
- }, [client]);
906
- return {
907
- messages,
908
- sendMessage,
909
- clearMessages,
910
- cancelRun,
911
- isStreaming: state.isStreaming,
912
- isRefreshing: state.isRefreshing,
913
- isPaused: state.isPaused,
914
- isCancelling: state.isCancelling,
915
- currentRunId: state.currentRunId,
916
- error: state.errorMessage,
917
- state
771
+ }, [client, mergedHandlers, isPaused, pendingTools]);
772
+ import_react6.useEffect(() => {
773
+ const handleSessionLoaded = async (_sessionId) => {
774
+ const messages = client.getMessages();
775
+ for (const message of messages) {
776
+ if (!message.tool_calls)
777
+ continue;
778
+ for (const tool of message.tool_calls) {
779
+ if (tool.ui_component)
780
+ continue;
781
+ if (options?.skipToolsOnSessionLoad?.includes(tool.tool_name))
782
+ continue;
783
+ const handler = mergedHandlers[tool.tool_name];
784
+ if (!handler)
785
+ continue;
786
+ try {
787
+ const result = await handler(tool.tool_args);
788
+ const { uiComponent } = processToolResult(result, tool);
789
+ if (uiComponent) {
790
+ client.hydrateToolCallUI(tool.tool_call_id, uiComponent);
791
+ }
792
+ } catch (err) {
793
+ console.error(`Failed to hydrate UI for ${tool.tool_name}:`, err);
794
+ }
795
+ }
796
+ }
797
+ };
798
+ client.on("session:loaded", handleSessionLoaded);
799
+ return () => {
800
+ client.off("session:loaded", handleSessionLoaded);
801
+ };
802
+ }, [client, mergedHandlers]);
803
+ const executeTools = import_react6.useCallback(async (tools) => {
804
+ return Promise.all(tools.map(async (tool) => {
805
+ const handler = mergedHandlers[tool.tool_name];
806
+ if (!handler)
807
+ return tool;
808
+ try {
809
+ const result = await handler(tool.tool_args);
810
+ const { resultData, uiComponent } = processToolResult(result, tool);
811
+ return {
812
+ ...tool,
813
+ result: resultData,
814
+ ui_component: uiComponent
815
+ };
816
+ } catch (error) {
817
+ return {
818
+ ...tool,
819
+ result: JSON.stringify({
820
+ error: error instanceof Error ? error.message : String(error)
821
+ })
822
+ };
823
+ }
824
+ }));
825
+ }, [mergedHandlers]);
826
+ const continueWithResults = import_react6.useCallback(async (tools, options2) => {
827
+ if (!isPaused) {
828
+ throw new Error("No paused run to continue");
829
+ }
830
+ setIsExecuting(true);
831
+ try {
832
+ await client.continueRun(tools, options2);
833
+ } catch (error) {
834
+ setIsExecuting(false);
835
+ throw error;
836
+ }
837
+ }, [client, isPaused]);
838
+ import_react6.useEffect(() => {
839
+ if (autoExecute && isPaused && !isExecuting && pendingTools.length > 0) {
840
+ executeAndContinue();
841
+ }
842
+ }, [autoExecute, isPaused, isExecuting, pendingTools.length, executeAndContinue]);
843
+ return {
844
+ isPaused,
845
+ isExecuting,
846
+ pendingTools,
847
+ executeAndContinue,
848
+ executeTools,
849
+ continueWithResults,
850
+ executionError
851
+ };
852
+ }
853
+ // src/ui/composed/agno-chat/render-tool.ts
854
+ function byToolName(map, fallback) {
855
+ return (tool, args) => {
856
+ if (!Object.prototype.hasOwnProperty.call(map, tool.tool_name)) {
857
+ return fallback ? fallback(tool, args) : args.defaultRender();
858
+ }
859
+ const entry = map[tool.tool_name];
860
+ if (entry === false)
861
+ return null;
862
+ return entry(tool, args);
863
+ };
864
+ }
865
+ // src/ui/primitives/badge.tsx
866
+ var import_class_variance_authority = require("class-variance-authority");
867
+
868
+ // src/ui/lib/cn.ts
869
+ var import_clsx = require("clsx");
870
+ var import_tailwind_merge = require("tailwind-merge");
871
+ function cn(...inputs) {
872
+ return import_tailwind_merge.twMerge(import_clsx.clsx(inputs));
873
+ }
874
+
875
+ // src/ui/primitives/badge.tsx
876
+ var jsx_runtime3 = require("react/jsx-runtime");
877
+ var badgeVariants = import_class_variance_authority.cva("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", {
878
+ variants: {
879
+ variant: {
880
+ default: "border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
881
+ secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
882
+ destructive: "border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",
883
+ outline: "text-foreground"
884
+ }
885
+ },
886
+ defaultVariants: {
887
+ variant: "default"
888
+ }
889
+ });
890
+ function Badge({ className, variant, ...props }) {
891
+ return /* @__PURE__ */ jsx_runtime3.jsx("div", {
892
+ className: cn(badgeVariants({ variant }), className),
893
+ ...props
894
+ });
895
+ }
896
+
897
+ // src/ui/primitives/collapsible.tsx
898
+ var CollapsiblePrimitive = __toESM(require("@radix-ui/react-collapsible"));
899
+ var Collapsible = CollapsiblePrimitive.Root;
900
+ var CollapsibleTrigger2 = CollapsiblePrimitive.CollapsibleTrigger;
901
+ var CollapsibleContent2 = CollapsiblePrimitive.CollapsibleContent;
902
+
903
+ // src/ui/components/tool.tsx
904
+ var import_lucide_react2 = require("lucide-react");
905
+ var import_react8 = require("react");
906
+
907
+ // src/ui/primitives/button.tsx
908
+ var React3 = __toESM(require("react"));
909
+ var import_react_slot = require("@radix-ui/react-slot");
910
+ var import_class_variance_authority2 = require("class-variance-authority");
911
+ var jsx_runtime4 = require("react/jsx-runtime");
912
+ var buttonVariants = import_class_variance_authority2.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", {
913
+ variants: {
914
+ variant: {
915
+ default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
916
+ destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
917
+ outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
918
+ secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
919
+ ghost: "hover:bg-accent hover:text-accent-foreground",
920
+ link: "text-primary underline-offset-4 hover:underline"
921
+ },
922
+ size: {
923
+ default: "h-9 px-4 py-2",
924
+ sm: "h-8 rounded-md px-3 text-xs",
925
+ lg: "h-10 rounded-md px-8",
926
+ icon: "h-9 w-9"
927
+ }
928
+ },
929
+ defaultVariants: {
930
+ variant: "default",
931
+ size: "default"
932
+ }
933
+ });
934
+ var Button = React3.forwardRef(({ className, variant, size, asChild = false, ...props }, ref) => {
935
+ const Comp = asChild ? import_react_slot.Slot : "button";
936
+ return /* @__PURE__ */ jsx_runtime4.jsx(Comp, {
937
+ className: cn(buttonVariants({ variant, size, className })),
938
+ ref,
939
+ ...props
940
+ });
941
+ });
942
+ Button.displayName = "Button";
943
+
944
+ // src/ui/components/code-block.tsx
945
+ var import_lucide_react = require("lucide-react");
946
+ var import_react7 = require("react");
947
+ var jsx_runtime5 = require("react/jsx-runtime");
948
+ var CodeBlockContext = import_react7.createContext({
949
+ code: ""
950
+ });
951
+ async function highlightCode(code, language, showLineNumbers = false) {
952
+ try {
953
+ const shiki = await import("shiki");
954
+ const lineNumberTransformer = showLineNumbers ? [
955
+ {
956
+ name: "line-numbers",
957
+ line(node, line) {
958
+ node.children.unshift({
959
+ type: "element",
960
+ tagName: "span",
961
+ properties: {
962
+ className: ["inline-block", "min-w-10", "mr-4", "text-right", "select-none", "text-muted-foreground"]
963
+ },
964
+ children: [{ type: "text", value: String(line) }]
965
+ });
966
+ }
967
+ }
968
+ ] : [];
969
+ const [light, dark] = await Promise.all([
970
+ shiki.codeToHtml(code, { lang: language, theme: "one-light", transformers: lineNumberTransformer }),
971
+ shiki.codeToHtml(code, { lang: language, theme: "one-dark-pro", transformers: lineNumberTransformer })
972
+ ]);
973
+ return [light, dark];
974
+ } catch {
975
+ return ["", ""];
976
+ }
977
+ }
978
+ var CodeBlock = ({
979
+ code,
980
+ language,
981
+ showLineNumbers = false,
982
+ className,
983
+ children,
984
+ ...props
985
+ }) => {
986
+ const [html, setHtml] = import_react7.useState("");
987
+ const [darkHtml, setDarkHtml] = import_react7.useState("");
988
+ const effectIdRef = import_react7.useRef(0);
989
+ import_react7.useEffect(() => {
990
+ const id = ++effectIdRef.current;
991
+ highlightCode(code, language, showLineNumbers).then(([light, dark]) => {
992
+ if (id === effectIdRef.current) {
993
+ setHtml(light);
994
+ setDarkHtml(dark);
995
+ }
996
+ });
997
+ }, [code, language, showLineNumbers]);
998
+ const useFallback = !html && !darkHtml;
999
+ return /* @__PURE__ */ jsx_runtime5.jsx(CodeBlockContext.Provider, {
1000
+ value: { code },
1001
+ children: /* @__PURE__ */ jsx_runtime5.jsx("div", {
1002
+ className: cn("group relative w-full overflow-hidden rounded-md border bg-background text-foreground", className),
1003
+ ...props,
1004
+ children: /* @__PURE__ */ jsx_runtime5.jsxs("div", {
1005
+ className: "relative",
1006
+ children: [
1007
+ useFallback ? /* @__PURE__ */ jsx_runtime5.jsx("pre", {
1008
+ className: "m-0 overflow-auto bg-background p-4 text-foreground text-sm",
1009
+ children: /* @__PURE__ */ jsx_runtime5.jsx("code", {
1010
+ className: "font-mono text-sm",
1011
+ children: code
1012
+ })
1013
+ }) : /* @__PURE__ */ jsx_runtime5.jsxs(jsx_runtime5.Fragment, {
1014
+ children: [
1015
+ /* @__PURE__ */ jsx_runtime5.jsx("div", {
1016
+ className: "overflow-hidden dark:hidden [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm",
1017
+ dangerouslySetInnerHTML: { __html: html }
1018
+ }),
1019
+ /* @__PURE__ */ jsx_runtime5.jsx("div", {
1020
+ className: "hidden overflow-hidden dark:block [&>pre]:m-0 [&>pre]:bg-background! [&>pre]:p-4 [&>pre]:text-foreground! [&>pre]:text-sm [&_code]:font-mono [&_code]:text-sm",
1021
+ dangerouslySetInnerHTML: { __html: darkHtml }
1022
+ })
1023
+ ]
1024
+ }),
1025
+ children && /* @__PURE__ */ jsx_runtime5.jsx("div", {
1026
+ className: "absolute top-2 right-2 flex items-center gap-2",
1027
+ children
1028
+ })
1029
+ ]
1030
+ })
1031
+ })
1032
+ });
1033
+ };
1034
+
1035
+ // src/ui/components/tool.tsx
1036
+ var jsx_runtime6 = require("react/jsx-runtime");
1037
+ var Tool = ({ className, ...props }) => /* @__PURE__ */ jsx_runtime6.jsx(Collapsible, {
1038
+ className: cn("not-prose mb-4 w-full rounded-md border", className),
1039
+ ...props
1040
+ });
1041
+ var getStatusBadge = (status) => {
1042
+ const labels = {
1043
+ "input-streaming": "Pending",
1044
+ "input-available": "Running",
1045
+ "approval-requested": "Awaiting Approval",
1046
+ "approval-responded": "Responded",
1047
+ "output-available": "Completed",
1048
+ "output-error": "Error",
1049
+ "output-denied": "Denied"
1050
+ };
1051
+ const icons = {
1052
+ "input-streaming": /* @__PURE__ */ jsx_runtime6.jsx(import_lucide_react2.CircleIcon, {
1053
+ className: "size-4"
1054
+ }),
1055
+ "input-available": /* @__PURE__ */ jsx_runtime6.jsx(import_lucide_react2.ClockIcon, {
1056
+ className: "size-4 animate-pulse"
1057
+ }),
1058
+ "approval-requested": /* @__PURE__ */ jsx_runtime6.jsx(import_lucide_react2.ClockIcon, {
1059
+ className: "size-4 text-yellow-600"
1060
+ }),
1061
+ "approval-responded": /* @__PURE__ */ jsx_runtime6.jsx(import_lucide_react2.CheckCircleIcon, {
1062
+ className: "size-4 text-blue-600"
1063
+ }),
1064
+ "output-available": /* @__PURE__ */ jsx_runtime6.jsx(import_lucide_react2.CheckCircleIcon, {
1065
+ className: "size-4 text-green-600"
1066
+ }),
1067
+ "output-error": /* @__PURE__ */ jsx_runtime6.jsx(import_lucide_react2.XCircleIcon, {
1068
+ className: "size-4 text-red-600"
1069
+ }),
1070
+ "output-denied": /* @__PURE__ */ jsx_runtime6.jsx(import_lucide_react2.XCircleIcon, {
1071
+ className: "size-4 text-orange-600"
1072
+ })
918
1073
  };
1074
+ return /* @__PURE__ */ jsx_runtime6.jsxs(Badge, {
1075
+ className: "gap-1.5 rounded-full text-xs",
1076
+ variant: "secondary",
1077
+ children: [
1078
+ icons[status],
1079
+ labels[status]
1080
+ ]
1081
+ });
1082
+ };
1083
+ var ToolHeader = ({ className, title, type, state, ...props }) => /* @__PURE__ */ jsx_runtime6.jsxs(CollapsibleTrigger2, {
1084
+ className: cn("group flex w-full items-center justify-between gap-4 p-3", className),
1085
+ ...props,
1086
+ children: [
1087
+ /* @__PURE__ */ jsx_runtime6.jsxs("div", {
1088
+ className: "flex items-center gap-2",
1089
+ children: [
1090
+ /* @__PURE__ */ jsx_runtime6.jsx(import_lucide_react2.WrenchIcon, {
1091
+ className: "size-4 text-muted-foreground"
1092
+ }),
1093
+ /* @__PURE__ */ jsx_runtime6.jsx("span", {
1094
+ className: "font-medium text-sm",
1095
+ children: title ?? type?.split("-").slice(1).join("-") ?? "Tool"
1096
+ }),
1097
+ getStatusBadge(state)
1098
+ ]
1099
+ }),
1100
+ /* @__PURE__ */ jsx_runtime6.jsx(import_lucide_react2.ChevronDownIcon, {
1101
+ className: "size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"
1102
+ })
1103
+ ]
1104
+ });
1105
+ var ToolContent = ({ className, ...props }) => /* @__PURE__ */ jsx_runtime6.jsx(CollapsibleContent2, {
1106
+ className: cn("data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", className),
1107
+ ...props
1108
+ });
1109
+ var ToolInput = ({ className, input, ...props }) => /* @__PURE__ */ jsx_runtime6.jsxs("div", {
1110
+ className: cn("space-y-2 overflow-hidden p-4", className),
1111
+ ...props,
1112
+ children: [
1113
+ /* @__PURE__ */ jsx_runtime6.jsx("h4", {
1114
+ className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
1115
+ children: "Parameters"
1116
+ }),
1117
+ /* @__PURE__ */ jsx_runtime6.jsx("div", {
1118
+ className: "rounded-md bg-muted/50",
1119
+ children: /* @__PURE__ */ jsx_runtime6.jsx(CodeBlock, {
1120
+ code: JSON.stringify(input, null, 2),
1121
+ language: "json"
1122
+ })
1123
+ })
1124
+ ]
1125
+ });
1126
+ var ToolOutput = ({ className, output, errorText, ...props }) => {
1127
+ if (!(output || errorText)) {
1128
+ return null;
1129
+ }
1130
+ let Output = /* @__PURE__ */ jsx_runtime6.jsx("div", {
1131
+ children: output
1132
+ });
1133
+ if (typeof output === "object" && !import_react8.isValidElement(output)) {
1134
+ Output = /* @__PURE__ */ jsx_runtime6.jsx(CodeBlock, {
1135
+ code: JSON.stringify(output, null, 2),
1136
+ language: "json"
1137
+ });
1138
+ } else if (typeof output === "string") {
1139
+ Output = /* @__PURE__ */ jsx_runtime6.jsx(CodeBlock, {
1140
+ code: output,
1141
+ language: "json"
1142
+ });
1143
+ }
1144
+ return /* @__PURE__ */ jsx_runtime6.jsxs("div", {
1145
+ className: cn("space-y-2 p-4", className),
1146
+ ...props,
1147
+ children: [
1148
+ /* @__PURE__ */ jsx_runtime6.jsx("h4", {
1149
+ className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
1150
+ children: errorText ? "Error" : "Result"
1151
+ }),
1152
+ /* @__PURE__ */ jsx_runtime6.jsxs("div", {
1153
+ className: cn("overflow-x-auto rounded-md text-xs [&_table]:w-full", errorText ? "bg-destructive/10 text-destructive" : "bg-muted/50 text-foreground"),
1154
+ children: [
1155
+ errorText && /* @__PURE__ */ jsx_runtime6.jsx("div", {
1156
+ children: errorText
1157
+ }),
1158
+ Output
1159
+ ]
1160
+ })
1161
+ ]
1162
+ });
1163
+ };
1164
+
1165
+ // src/ui/composed/agno-chat/tool-building-blocks.tsx
1166
+ var jsx_runtime7 = require("react/jsx-runtime");
1167
+ var getToolState = (tool) => tool.tool_call_error ? "output-error" : "output-available";
1168
+ function ToolDebugCard({ tool, defaultOpen }) {
1169
+ const output = tool.result ?? tool.content;
1170
+ return /* @__PURE__ */ jsx_runtime7.jsxs(Tool, {
1171
+ defaultOpen,
1172
+ children: [
1173
+ /* @__PURE__ */ jsx_runtime7.jsx(ToolHeader, {
1174
+ title: tool.tool_name,
1175
+ type: "tool-use",
1176
+ state: getToolState(tool)
1177
+ }),
1178
+ /* @__PURE__ */ jsx_runtime7.jsxs(ToolContent, {
1179
+ children: [
1180
+ /* @__PURE__ */ jsx_runtime7.jsx(ToolInput, {
1181
+ input: tool.tool_args
1182
+ }),
1183
+ output ? /* @__PURE__ */ jsx_runtime7.jsx(ToolOutput, {
1184
+ output,
1185
+ errorText: tool.tool_call_error ? "Tool execution failed" : undefined
1186
+ }) : null
1187
+ ]
1188
+ })
1189
+ ]
1190
+ });
1191
+ }
1192
+ // src/ui/composed/agno-message/message.tsx
1193
+ var import_react13 = require("react");
1194
+ var import_lucide_react12 = require("lucide-react");
1195
+
1196
+ // src/ui/primitives/tooltip.tsx
1197
+ var React4 = __toESM(require("react"));
1198
+ var TooltipPrimitive = __toESM(require("@radix-ui/react-tooltip"));
1199
+ var jsx_runtime8 = require("react/jsx-runtime");
1200
+ var TooltipProvider = TooltipPrimitive.Provider;
1201
+ var Tooltip = TooltipPrimitive.Root;
1202
+ var TooltipTrigger = TooltipPrimitive.Trigger;
1203
+ var TooltipContent = React4.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx_runtime8.jsx(TooltipPrimitive.Portal, {
1204
+ children: /* @__PURE__ */ jsx_runtime8.jsx(TooltipPrimitive.Content, {
1205
+ ref,
1206
+ sideOffset,
1207
+ className: cn("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]", className),
1208
+ ...props
1209
+ })
1210
+ }));
1211
+ TooltipContent.displayName = TooltipPrimitive.Content.displayName;
1212
+
1213
+ // src/ui/lib/format-timestamp.ts
1214
+ function formatSmartTimestamp(date) {
1215
+ const now = new Date;
1216
+ const isToday = date.getFullYear() === now.getFullYear() && date.getMonth() === now.getMonth() && date.getDate() === now.getDate();
1217
+ if (isToday) {
1218
+ return new Intl.DateTimeFormat(undefined, {
1219
+ hour: "numeric",
1220
+ minute: "2-digit",
1221
+ hour12: true
1222
+ }).format(date);
1223
+ }
1224
+ const isSameYear = date.getFullYear() === now.getFullYear();
1225
+ if (isSameYear) {
1226
+ return new Intl.DateTimeFormat(undefined, {
1227
+ month: "short",
1228
+ day: "numeric"
1229
+ }).format(date);
1230
+ }
1231
+ return new Intl.DateTimeFormat(undefined, {
1232
+ month: "short",
1233
+ day: "numeric",
1234
+ year: "numeric"
1235
+ }).format(date);
1236
+ }
1237
+ function formatFullTimestamp(date) {
1238
+ return new Intl.DateTimeFormat(undefined, {
1239
+ month: "short",
1240
+ day: "numeric",
1241
+ year: "numeric",
1242
+ hour: "numeric",
1243
+ minute: "2-digit",
1244
+ hour12: true
1245
+ }).format(date);
1246
+ }
1247
+
1248
+ // src/ui/components/smart-timestamp.tsx
1249
+ var jsx_runtime9 = require("react/jsx-runtime");
1250
+ function SmartTimestamp({ date, formatShort, className }) {
1251
+ const shortText = formatShort ? formatShort(date) : formatSmartTimestamp(date);
1252
+ const fullText = formatFullTimestamp(date);
1253
+ return /* @__PURE__ */ jsx_runtime9.jsx(TooltipProvider, {
1254
+ children: /* @__PURE__ */ jsx_runtime9.jsxs(Tooltip, {
1255
+ children: [
1256
+ /* @__PURE__ */ jsx_runtime9.jsx(TooltipTrigger, {
1257
+ asChild: true,
1258
+ children: /* @__PURE__ */ jsx_runtime9.jsx("span", {
1259
+ className,
1260
+ children: shortText
1261
+ })
1262
+ }),
1263
+ /* @__PURE__ */ jsx_runtime9.jsx(TooltipContent, {
1264
+ children: /* @__PURE__ */ jsx_runtime9.jsx("p", {
1265
+ children: fullText
1266
+ })
1267
+ })
1268
+ ]
1269
+ })
1270
+ });
1271
+ }
1272
+
1273
+ // src/ui/lib/file-utils.ts
1274
+ function getFilePreviewType(mimeType) {
1275
+ if (!mimeType)
1276
+ return "none";
1277
+ if (mimeType.startsWith("image/"))
1278
+ return "image";
1279
+ if (mimeType === "application/pdf")
1280
+ return "pdf";
1281
+ if (mimeType.startsWith("text/"))
1282
+ return "text";
1283
+ if (mimeType.startsWith("video/"))
1284
+ return "video";
1285
+ if (mimeType.startsWith("audio/"))
1286
+ return "audio";
1287
+ return "none";
1288
+ }
1289
+ function formatFileSize(bytes) {
1290
+ if (bytes === 0)
1291
+ return "0 B";
1292
+ const units = ["B", "KB", "MB", "GB", "TB"];
1293
+ const k = 1024;
1294
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
1295
+ const value = bytes / Math.pow(k, i);
1296
+ return `${value % 1 === 0 ? value : value.toFixed(1)} ${units[i]}`;
1297
+ }
1298
+ function getFileExtension(filename, mimeType) {
1299
+ const lastDot = filename.lastIndexOf(".");
1300
+ if (lastDot !== -1 && lastDot !== 0) {
1301
+ return filename.slice(lastDot + 1).toLowerCase();
1302
+ }
1303
+ if (mimeType) {
1304
+ return extensionFromMime(mimeType);
1305
+ }
1306
+ return "";
1307
+ }
1308
+ var mimeToExt = {
1309
+ "application/pdf": "pdf",
1310
+ "application/zip": "zip",
1311
+ "application/x-rar-compressed": "rar",
1312
+ "application/json": "json",
1313
+ "application/xml": "xml",
1314
+ "application/msword": "doc",
1315
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx",
1316
+ "application/vnd.ms-excel": "xls",
1317
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx",
1318
+ "application/vnd.ms-powerpoint": "ppt",
1319
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx",
1320
+ "text/csv": "csv",
1321
+ "text/plain": "txt",
1322
+ "text/html": "html",
1323
+ "text/css": "css",
1324
+ "text/javascript": "js"
1325
+ };
1326
+ function extensionFromMime(mimeType) {
1327
+ if (mimeToExt[mimeType])
1328
+ return mimeToExt[mimeType];
1329
+ const subtype = mimeType.split("/")[1];
1330
+ if (subtype && !subtype.includes(".") && !subtype.includes("+")) {
1331
+ return subtype.toLowerCase();
1332
+ }
1333
+ return "";
1334
+ }
1335
+ function isPreviewable(mimeType) {
1336
+ const type = getFilePreviewType(mimeType);
1337
+ return type === "image" || type === "pdf";
1338
+ }
1339
+
1340
+ // src/ui/components/file-preview-card.tsx
1341
+ var import_lucide_react3 = require("lucide-react");
1342
+ var jsx_runtime10 = require("react/jsx-runtime");
1343
+ function ExtBadge({ ext }) {
1344
+ if (!ext)
1345
+ return null;
1346
+ return /* @__PURE__ */ jsx_runtime10.jsx("span", {
1347
+ className: "absolute bottom-1.5 left-1.5 rounded px-1 py-0.5 text-[9px] font-semibold uppercase leading-none bg-background/80 text-muted-foreground border border-border/50 backdrop-blur-sm",
1348
+ children: ext
1349
+ });
1350
+ }
1351
+ function FilePreviewCard({ file, onClick, className }) {
1352
+ const previewType = getFilePreviewType(file.type);
1353
+ const isClickable = !!onClick;
1354
+ const ext = getFileExtension(file.name, file.type);
1355
+ const cardBase = cn("group relative flex flex-col overflow-hidden rounded-xl border border-border bg-muted/20 w-28 h-28", isClickable && "cursor-pointer hover:border-foreground/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 transition-colors", className);
1356
+ if (previewType === "image" && file.url) {
1357
+ return /* @__PURE__ */ jsx_runtime10.jsxs("button", {
1358
+ type: "button",
1359
+ onClick,
1360
+ disabled: !isClickable,
1361
+ className: cardBase,
1362
+ children: [
1363
+ /* @__PURE__ */ jsx_runtime10.jsx("img", {
1364
+ src: file.url,
1365
+ alt: file.name,
1366
+ className: "w-full h-full object-cover"
1367
+ }),
1368
+ /* @__PURE__ */ jsx_runtime10.jsx(ExtBadge, {
1369
+ ext
1370
+ }),
1371
+ isClickable && /* @__PURE__ */ jsx_runtime10.jsx("div", {
1372
+ className: "absolute inset-0 flex items-center justify-center bg-black/0 group-hover:bg-black/30 transition-colors",
1373
+ children: /* @__PURE__ */ jsx_runtime10.jsx(import_lucide_react3.Search, {
1374
+ className: "h-5 w-5 text-white opacity-0 group-hover:opacity-100 transition-opacity"
1375
+ })
1376
+ })
1377
+ ]
1378
+ });
1379
+ }
1380
+ if (previewType === "pdf" && file.url) {
1381
+ return /* @__PURE__ */ jsx_runtime10.jsxs("button", {
1382
+ type: "button",
1383
+ onClick,
1384
+ disabled: !isClickable,
1385
+ className: cardBase,
1386
+ children: [
1387
+ /* @__PURE__ */ jsx_runtime10.jsx("div", {
1388
+ className: "w-full h-full overflow-hidden pointer-events-none",
1389
+ children: /* @__PURE__ */ jsx_runtime10.jsx("object", {
1390
+ data: `${file.url}#page=1&view=FitH`,
1391
+ type: "application/pdf",
1392
+ className: "w-[200%] h-[200%] origin-top-left scale-50",
1393
+ "aria-label": file.name,
1394
+ children: /* @__PURE__ */ jsx_runtime10.jsx("div", {
1395
+ className: "flex items-center justify-center w-full h-full",
1396
+ children: /* @__PURE__ */ jsx_runtime10.jsx(import_lucide_react3.FileIcon, {
1397
+ className: "h-8 w-8 text-muted-foreground/40"
1398
+ })
1399
+ })
1400
+ })
1401
+ }),
1402
+ /* @__PURE__ */ jsx_runtime10.jsx(ExtBadge, {
1403
+ ext
1404
+ }),
1405
+ isClickable && /* @__PURE__ */ jsx_runtime10.jsx("div", {
1406
+ className: "absolute inset-0 flex items-center justify-center bg-black/0 group-hover:bg-black/10 transition-colors",
1407
+ children: /* @__PURE__ */ jsx_runtime10.jsx(import_lucide_react3.Search, {
1408
+ className: "h-5 w-5 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"
1409
+ })
1410
+ })
1411
+ ]
1412
+ });
1413
+ }
1414
+ return /* @__PURE__ */ jsx_runtime10.jsxs("button", {
1415
+ type: "button",
1416
+ onClick,
1417
+ disabled: !isClickable,
1418
+ className: cardBase,
1419
+ children: [
1420
+ /* @__PURE__ */ jsx_runtime10.jsx("div", {
1421
+ className: "flex-1 flex items-center justify-center",
1422
+ children: /* @__PURE__ */ jsx_runtime10.jsx(import_lucide_react3.FileIcon, {
1423
+ className: "h-8 w-8 text-muted-foreground/40"
1424
+ })
1425
+ }),
1426
+ /* @__PURE__ */ jsx_runtime10.jsxs("div", {
1427
+ className: "w-full text-center min-w-0 px-2 pb-2 space-y-0.5",
1428
+ children: [
1429
+ /* @__PURE__ */ jsx_runtime10.jsx("p", {
1430
+ className: "text-[10px] text-foreground truncate leading-tight",
1431
+ title: file.name,
1432
+ children: file.name
1433
+ }),
1434
+ file.size != null && file.size > 0 && /* @__PURE__ */ jsx_runtime10.jsx("p", {
1435
+ className: "text-[9px] text-muted-foreground leading-tight",
1436
+ children: formatFileSize(file.size)
1437
+ })
1438
+ ]
1439
+ }),
1440
+ /* @__PURE__ */ jsx_runtime10.jsx(ExtBadge, {
1441
+ ext
1442
+ })
1443
+ ]
1444
+ });
1445
+ }
1446
+
1447
+ // src/ui/primitives/dialog.tsx
1448
+ var React5 = __toESM(require("react"));
1449
+ var DialogPrimitive = __toESM(require("@radix-ui/react-dialog"));
1450
+ var import_class_variance_authority3 = require("class-variance-authority");
1451
+ var import_lucide_react4 = require("lucide-react");
1452
+ var jsx_runtime11 = require("react/jsx-runtime");
1453
+ var Dialog = DialogPrimitive.Root;
1454
+ var DialogPortal = DialogPrimitive.Portal;
1455
+ var DialogOverlay = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx_runtime11.jsx(DialogPrimitive.Overlay, {
1456
+ ref,
1457
+ className: cn("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0", className),
1458
+ ...props
1459
+ }));
1460
+ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
1461
+ var dialogContentVariants = import_class_variance_authority3.cva("fixed left-[50%] top-[50%] z-50 grid translate-x-[-50%] translate-y-[-50%] gap-4 border shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg", {
1462
+ variants: {
1463
+ variant: {
1464
+ default: "w-full max-w-lg bg-background p-6",
1465
+ lightbox: "max-w-[90vw] max-h-[90vh] bg-background/95 backdrop-blur-sm p-2"
1466
+ }
1467
+ },
1468
+ defaultVariants: {
1469
+ variant: "default"
1470
+ }
1471
+ });
1472
+ var DialogContent = React5.forwardRef(({ className, variant, children, ...props }, ref) => /* @__PURE__ */ jsx_runtime11.jsxs(DialogPortal, {
1473
+ children: [
1474
+ /* @__PURE__ */ jsx_runtime11.jsx(DialogOverlay, {}),
1475
+ /* @__PURE__ */ jsx_runtime11.jsxs(DialogPrimitive.Content, {
1476
+ ref,
1477
+ className: cn(dialogContentVariants({ variant }), className),
1478
+ ...props,
1479
+ children: [
1480
+ children,
1481
+ /* @__PURE__ */ jsx_runtime11.jsxs(DialogPrimitive.Close, {
1482
+ className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",
1483
+ children: [
1484
+ /* @__PURE__ */ jsx_runtime11.jsx(import_lucide_react4.X, {
1485
+ className: "h-4 w-4"
1486
+ }),
1487
+ /* @__PURE__ */ jsx_runtime11.jsx("span", {
1488
+ className: "sr-only",
1489
+ children: "Close"
1490
+ })
1491
+ ]
1492
+ })
1493
+ ]
1494
+ })
1495
+ ]
1496
+ }));
1497
+ DialogContent.displayName = DialogPrimitive.Content.displayName;
1498
+ var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ jsx_runtime11.jsx("div", {
1499
+ className: cn("flex flex-col space-y-1.5 text-center sm:text-left", className),
1500
+ ...props
1501
+ });
1502
+ DialogHeader.displayName = "DialogHeader";
1503
+ var DialogFooter = ({ className, ...props }) => /* @__PURE__ */ jsx_runtime11.jsx("div", {
1504
+ className: cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className),
1505
+ ...props
1506
+ });
1507
+ DialogFooter.displayName = "DialogFooter";
1508
+ var DialogTitle = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx_runtime11.jsx(DialogPrimitive.Title, {
1509
+ ref,
1510
+ className: cn("text-lg font-semibold leading-none tracking-tight", className),
1511
+ ...props
1512
+ }));
1513
+ DialogTitle.displayName = DialogPrimitive.Title.displayName;
1514
+ var DialogDescription = React5.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx_runtime11.jsx(DialogPrimitive.Description, {
1515
+ ref,
1516
+ className: cn("text-sm text-muted-foreground", className),
1517
+ ...props
1518
+ }));
1519
+ DialogDescription.displayName = DialogPrimitive.Description.displayName;
1520
+
1521
+ // src/ui/components/file-preview-modal.tsx
1522
+ var import_lucide_react5 = require("lucide-react");
1523
+ var jsx_runtime12 = require("react/jsx-runtime");
1524
+ function FilePreviewModal({ open, onOpenChange, file }) {
1525
+ if (!file)
1526
+ return null;
1527
+ const previewType = getFilePreviewType(file.type);
1528
+ const canPreview = isPreviewable(file.type) && !!file.url;
1529
+ return /* @__PURE__ */ jsx_runtime12.jsx(Dialog, {
1530
+ open,
1531
+ onOpenChange,
1532
+ children: previewType === "image" && file.url ? /* @__PURE__ */ jsx_runtime12.jsxs(DialogContent, {
1533
+ variant: "lightbox",
1534
+ "aria-describedby": undefined,
1535
+ children: [
1536
+ /* @__PURE__ */ jsx_runtime12.jsx(DialogTitle, {
1537
+ className: "sr-only",
1538
+ children: file.name
1539
+ }),
1540
+ /* @__PURE__ */ jsx_runtime12.jsx("img", {
1541
+ src: file.url,
1542
+ alt: file.name,
1543
+ className: "max-h-[85vh] max-w-full object-contain rounded-md"
1544
+ })
1545
+ ]
1546
+ }) : previewType === "pdf" && file.url ? /* @__PURE__ */ jsx_runtime12.jsxs(DialogContent, {
1547
+ variant: "lightbox",
1548
+ className: "w-[80vw] h-[85vh]",
1549
+ "aria-describedby": undefined,
1550
+ children: [
1551
+ /* @__PURE__ */ jsx_runtime12.jsx(DialogTitle, {
1552
+ className: "sr-only",
1553
+ children: file.name
1554
+ }),
1555
+ /* @__PURE__ */ jsx_runtime12.jsx("object", {
1556
+ data: file.url,
1557
+ type: "application/pdf",
1558
+ className: "w-full h-full rounded-md",
1559
+ children: /* @__PURE__ */ jsx_runtime12.jsxs("div", {
1560
+ className: "flex flex-col items-center justify-center h-full gap-3 text-muted-foreground",
1561
+ children: [
1562
+ /* @__PURE__ */ jsx_runtime12.jsx("p", {
1563
+ className: "text-sm",
1564
+ children: "Unable to display PDF"
1565
+ }),
1566
+ /* @__PURE__ */ jsx_runtime12.jsxs("a", {
1567
+ href: file.url,
1568
+ target: "_blank",
1569
+ rel: "noopener noreferrer",
1570
+ className: "inline-flex items-center gap-1.5 text-sm text-primary hover:underline",
1571
+ children: [
1572
+ /* @__PURE__ */ jsx_runtime12.jsx(import_lucide_react5.Download, {
1573
+ className: "h-4 w-4"
1574
+ }),
1575
+ "Download ",
1576
+ file.name
1577
+ ]
1578
+ })
1579
+ ]
1580
+ })
1581
+ })
1582
+ ]
1583
+ }) : /* @__PURE__ */ jsx_runtime12.jsxs(DialogContent, {
1584
+ children: [
1585
+ /* @__PURE__ */ jsx_runtime12.jsxs(DialogHeader, {
1586
+ children: [
1587
+ /* @__PURE__ */ jsx_runtime12.jsxs(DialogTitle, {
1588
+ className: "flex items-center gap-2",
1589
+ children: [
1590
+ /* @__PURE__ */ jsx_runtime12.jsx(import_lucide_react5.FileIcon, {
1591
+ className: "h-5 w-5 text-muted-foreground"
1592
+ }),
1593
+ file.name
1594
+ ]
1595
+ }),
1596
+ /* @__PURE__ */ jsx_runtime12.jsxs(DialogDescription, {
1597
+ children: [
1598
+ file.size != null && file.size > 0 && /* @__PURE__ */ jsx_runtime12.jsx("span", {
1599
+ children: formatFileSize(file.size)
1600
+ }),
1601
+ !canPreview && /* @__PURE__ */ jsx_runtime12.jsx("span", {
1602
+ children: " · Preview not available for this file type"
1603
+ })
1604
+ ]
1605
+ })
1606
+ ]
1607
+ }),
1608
+ /* @__PURE__ */ jsx_runtime12.jsxs("div", {
1609
+ className: "flex flex-col items-center justify-center py-8 text-muted-foreground gap-3",
1610
+ children: [
1611
+ /* @__PURE__ */ jsx_runtime12.jsx(import_lucide_react5.FileIcon, {
1612
+ className: "h-12 w-12"
1613
+ }),
1614
+ /* @__PURE__ */ jsx_runtime12.jsx("p", {
1615
+ className: "text-sm",
1616
+ children: "Preview not available"
1617
+ }),
1618
+ file.url && /^https?:\/\//i.test(file.url) && /* @__PURE__ */ jsx_runtime12.jsxs("a", {
1619
+ href: file.url,
1620
+ target: "_blank",
1621
+ rel: "noopener noreferrer",
1622
+ className: "inline-flex items-center gap-1.5 text-sm text-primary hover:underline",
1623
+ children: [
1624
+ /* @__PURE__ */ jsx_runtime12.jsx(import_lucide_react5.Download, {
1625
+ className: "h-4 w-4"
1626
+ }),
1627
+ "Download file"
1628
+ ]
1629
+ })
1630
+ ]
1631
+ })
1632
+ ]
1633
+ })
1634
+ });
1635
+ }
1636
+
1637
+ // src/ui/components/image-lightbox.tsx
1638
+ var import_react9 = require("react");
1639
+ var import_lucide_react6 = require("lucide-react");
1640
+ var jsx_runtime13 = require("react/jsx-runtime");
1641
+ function ImageLightbox({ open, onOpenChange, images, initialIndex = 0 }) {
1642
+ const [currentIndex, setCurrentIndex] = import_react9.useState(initialIndex);
1643
+ const hasMultiple = images.length > 1;
1644
+ import_react9.useEffect(() => {
1645
+ if (open)
1646
+ setCurrentIndex(initialIndex);
1647
+ }, [open, initialIndex]);
1648
+ const goNext = import_react9.useCallback(() => {
1649
+ setCurrentIndex((i) => (i + 1) % images.length);
1650
+ }, [images.length]);
1651
+ const goPrev = import_react9.useCallback(() => {
1652
+ setCurrentIndex((i) => (i - 1 + images.length) % images.length);
1653
+ }, [images.length]);
1654
+ import_react9.useEffect(() => {
1655
+ if (!open || !hasMultiple)
1656
+ return;
1657
+ const handler = (e) => {
1658
+ if (e.key === "ArrowRight")
1659
+ goNext();
1660
+ if (e.key === "ArrowLeft")
1661
+ goPrev();
1662
+ };
1663
+ window.addEventListener("keydown", handler);
1664
+ return () => window.removeEventListener("keydown", handler);
1665
+ }, [open, hasMultiple, goNext, goPrev]);
1666
+ if (images.length === 0)
1667
+ return null;
1668
+ const current = images[currentIndex];
1669
+ if (!current)
1670
+ return null;
1671
+ return /* @__PURE__ */ jsx_runtime13.jsx(Dialog, {
1672
+ open,
1673
+ onOpenChange,
1674
+ children: /* @__PURE__ */ jsx_runtime13.jsxs(DialogContent, {
1675
+ variant: "lightbox",
1676
+ "aria-describedby": undefined,
1677
+ children: [
1678
+ /* @__PURE__ */ jsx_runtime13.jsx(DialogTitle, {
1679
+ className: "sr-only",
1680
+ children: current.alt || `Image ${currentIndex + 1} of ${images.length}`
1681
+ }),
1682
+ /* @__PURE__ */ jsx_runtime13.jsxs("div", {
1683
+ className: "relative flex items-center justify-center",
1684
+ children: [
1685
+ /* @__PURE__ */ jsx_runtime13.jsx("img", {
1686
+ src: current.url,
1687
+ alt: current.alt || "Image preview",
1688
+ className: "max-h-[85vh] max-w-full object-contain rounded-md"
1689
+ }),
1690
+ hasMultiple && /* @__PURE__ */ jsx_runtime13.jsxs(jsx_runtime13.Fragment, {
1691
+ children: [
1692
+ /* @__PURE__ */ jsx_runtime13.jsxs("button", {
1693
+ type: "button",
1694
+ onClick: goPrev,
1695
+ className: cn("absolute left-2 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white", "hover:bg-black/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors"),
1696
+ children: [
1697
+ /* @__PURE__ */ jsx_runtime13.jsx(import_lucide_react6.ChevronLeft, {
1698
+ className: "h-5 w-5"
1699
+ }),
1700
+ /* @__PURE__ */ jsx_runtime13.jsx("span", {
1701
+ className: "sr-only",
1702
+ children: "Previous image"
1703
+ })
1704
+ ]
1705
+ }),
1706
+ /* @__PURE__ */ jsx_runtime13.jsxs("button", {
1707
+ type: "button",
1708
+ onClick: goNext,
1709
+ className: cn("absolute right-2 top-1/2 -translate-y-1/2 rounded-full bg-black/50 p-2 text-white", "hover:bg-black/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors"),
1710
+ children: [
1711
+ /* @__PURE__ */ jsx_runtime13.jsx(import_lucide_react6.ChevronRight, {
1712
+ className: "h-5 w-5"
1713
+ }),
1714
+ /* @__PURE__ */ jsx_runtime13.jsx("span", {
1715
+ className: "sr-only",
1716
+ children: "Next image"
1717
+ })
1718
+ ]
1719
+ }),
1720
+ /* @__PURE__ */ jsx_runtime13.jsxs("div", {
1721
+ className: "absolute bottom-2 left-1/2 -translate-x-1/2 rounded-full bg-black/50 px-3 py-1 text-xs text-white",
1722
+ children: [
1723
+ currentIndex + 1,
1724
+ " / ",
1725
+ images.length
1726
+ ]
1727
+ })
1728
+ ]
1729
+ })
1730
+ ]
1731
+ })
1732
+ ]
1733
+ })
1734
+ });
1735
+ }
1736
+
1737
+ // src/ui/composed/agno-message/context.ts
1738
+ var import_react10 = require("react");
1739
+ var AgnoMessageContext = import_react10.createContext(null);
1740
+ function useAgnoMessageContext() {
1741
+ const ctx = import_react10.useContext(AgnoMessageContext);
1742
+ if (!ctx) {
1743
+ throw new Error("useAgnoMessageContext must be used within an <AgnoMessage> provider. " + "Wrap your slots with <AgnoMessage message={...}>.");
1744
+ }
1745
+ return ctx;
1746
+ }
1747
+
1748
+ // src/ui/composed/agno-message/reasoning.tsx
1749
+ var import_lucide_react8 = require("lucide-react");
1750
+
1751
+ // src/ui/primitives/accordion.tsx
1752
+ var React6 = __toESM(require("react"));
1753
+ var AccordionPrimitive = __toESM(require("@radix-ui/react-accordion"));
1754
+ var import_lucide_react7 = require("lucide-react");
1755
+ var jsx_runtime14 = require("react/jsx-runtime");
1756
+ var Accordion = AccordionPrimitive.Root;
1757
+ var AccordionItem = React6.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx_runtime14.jsx(AccordionPrimitive.Item, {
1758
+ ref,
1759
+ className: cn("border-b", className),
1760
+ ...props
1761
+ }));
1762
+ AccordionItem.displayName = "AccordionItem";
1763
+ var AccordionTrigger = React6.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx_runtime14.jsx(AccordionPrimitive.Header, {
1764
+ className: "flex",
1765
+ children: /* @__PURE__ */ jsx_runtime14.jsxs(AccordionPrimitive.Trigger, {
1766
+ ref,
1767
+ className: cn("flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline text-left [&[data-state=open]>svg]:rotate-180", className),
1768
+ ...props,
1769
+ children: [
1770
+ children,
1771
+ /* @__PURE__ */ jsx_runtime14.jsx(import_lucide_react7.ChevronDown, {
1772
+ className: "h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200"
1773
+ })
1774
+ ]
1775
+ })
1776
+ }));
1777
+ AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
1778
+ var AccordionContent = React6.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx_runtime14.jsx(AccordionPrimitive.Content, {
1779
+ ref,
1780
+ className: "overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",
1781
+ ...props,
1782
+ children: /* @__PURE__ */ jsx_runtime14.jsx("div", {
1783
+ className: cn("pb-4 pt-0", className),
1784
+ children
1785
+ })
1786
+ }));
1787
+ AccordionContent.displayName = AccordionPrimitive.Content.displayName;
1788
+
1789
+ // src/ui/composed/agno-message/reasoning.tsx
1790
+ var jsx_runtime15 = require("react/jsx-runtime");
1791
+ function AgnoMessageReasoning() {
1792
+ const { message, classNames } = useAgnoMessageContext();
1793
+ const steps = message.extra_data?.reasoning_steps;
1794
+ if (!steps || steps.length === 0)
1795
+ return null;
1796
+ return /* @__PURE__ */ jsx_runtime15.jsxs("div", {
1797
+ className: cn("space-y-2 pt-1", classNames?.assistant?.reasoning),
1798
+ children: [
1799
+ /* @__PURE__ */ jsx_runtime15.jsxs("div", {
1800
+ className: "flex items-center gap-2 text-xs font-medium text-muted-foreground",
1801
+ children: [
1802
+ /* @__PURE__ */ jsx_runtime15.jsx(import_lucide_react8.Lightbulb, {
1803
+ className: "h-3.5 w-3.5"
1804
+ }),
1805
+ "Reasoning (",
1806
+ steps.length,
1807
+ " steps)"
1808
+ ]
1809
+ }),
1810
+ /* @__PURE__ */ jsx_runtime15.jsx(Accordion, {
1811
+ type: "multiple",
1812
+ className: "w-full",
1813
+ children: steps.map((step, idx) => /* @__PURE__ */ jsx_runtime15.jsxs(AccordionItem, {
1814
+ value: `reasoning-${idx}`,
1815
+ className: "border-muted",
1816
+ children: [
1817
+ /* @__PURE__ */ jsx_runtime15.jsx(AccordionTrigger, {
1818
+ className: "text-xs py-1.5 hover:no-underline",
1819
+ children: step.title || `Step ${idx + 1}`
1820
+ }),
1821
+ /* @__PURE__ */ jsx_runtime15.jsxs(AccordionContent, {
1822
+ className: "space-y-1.5 text-xs text-muted-foreground",
1823
+ children: [
1824
+ step.action && /* @__PURE__ */ jsx_runtime15.jsxs("div", {
1825
+ children: [
1826
+ /* @__PURE__ */ jsx_runtime15.jsx("span", {
1827
+ className: "font-medium text-foreground",
1828
+ children: "Action:"
1829
+ }),
1830
+ " ",
1831
+ step.action
1832
+ ]
1833
+ }),
1834
+ step.reasoning && /* @__PURE__ */ jsx_runtime15.jsxs("div", {
1835
+ children: [
1836
+ /* @__PURE__ */ jsx_runtime15.jsx("span", {
1837
+ className: "font-medium text-foreground",
1838
+ children: "Reasoning:"
1839
+ }),
1840
+ " ",
1841
+ step.reasoning
1842
+ ]
1843
+ }),
1844
+ step.result && /* @__PURE__ */ jsx_runtime15.jsxs("div", {
1845
+ children: [
1846
+ /* @__PURE__ */ jsx_runtime15.jsx("span", {
1847
+ className: "font-medium text-foreground",
1848
+ children: "Result:"
1849
+ }),
1850
+ " ",
1851
+ step.result
1852
+ ]
1853
+ }),
1854
+ step.confidence !== undefined && /* @__PURE__ */ jsx_runtime15.jsxs("div", {
1855
+ children: [
1856
+ /* @__PURE__ */ jsx_runtime15.jsx("span", {
1857
+ className: "font-medium text-foreground",
1858
+ children: "Confidence:"
1859
+ }),
1860
+ " ",
1861
+ (step.confidence * 100).toFixed(1),
1862
+ "%"
1863
+ ]
1864
+ })
1865
+ ]
1866
+ })
1867
+ ]
1868
+ }, idx))
1869
+ })
1870
+ ]
1871
+ });
1872
+ }
1873
+
1874
+ // src/ui/composed/agno-message/media.tsx
1875
+ var import_lucide_react9 = require("lucide-react");
1876
+ var jsx_runtime16 = require("react/jsx-runtime");
1877
+ function AgnoMessageMedia() {
1878
+ const {
1879
+ message,
1880
+ classNames,
1881
+ showImageLightbox,
1882
+ showFilePreview,
1883
+ openImageLightbox,
1884
+ openFilePreview
1885
+ } = useAgnoMessageContext();
1886
+ const mediaClassName = classNames?.assistant?.media;
1887
+ const hasImages = !!message.images && message.images.length > 0;
1888
+ const hasVideos = !!message.videos && message.videos.length > 0;
1889
+ const hasAudio = !!message.audio && message.audio.length > 0;
1890
+ const hasFiles = !!message.files && message.files.length > 0;
1891
+ const hasResponseAudio = !!message.response_audio;
1892
+ if (!hasImages && !hasVideos && !hasAudio && !hasFiles && !hasResponseAudio)
1893
+ return null;
1894
+ return /* @__PURE__ */ jsx_runtime16.jsxs(jsx_runtime16.Fragment, {
1895
+ children: [
1896
+ hasImages && /* @__PURE__ */ jsx_runtime16.jsxs("div", {
1897
+ className: cn("space-y-2 pt-1", mediaClassName),
1898
+ children: [
1899
+ /* @__PURE__ */ jsx_runtime16.jsxs("div", {
1900
+ className: "flex items-center gap-2 text-xs font-medium text-muted-foreground",
1901
+ children: [
1902
+ /* @__PURE__ */ jsx_runtime16.jsx(import_lucide_react9.Image, {
1903
+ className: "h-3.5 w-3.5"
1904
+ }),
1905
+ "Images (",
1906
+ message.images.length,
1907
+ ")"
1908
+ ]
1909
+ }),
1910
+ /* @__PURE__ */ jsx_runtime16.jsx("div", {
1911
+ className: "grid grid-cols-2 gap-2",
1912
+ children: message.images.map((img, idx) => /* @__PURE__ */ jsx_runtime16.jsxs("div", {
1913
+ className: "space-y-1",
1914
+ children: [
1915
+ showImageLightbox ? /* @__PURE__ */ jsx_runtime16.jsx("button", {
1916
+ type: "button",
1917
+ onClick: () => openImageLightbox(message.images.map((i) => ({ url: i.url, alt: i.revised_prompt })), idx),
1918
+ className: "group relative w-full overflow-hidden rounded-lg border border-border cursor-pointer hover:border-primary/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-colors",
1919
+ children: /* @__PURE__ */ jsx_runtime16.jsx("img", {
1920
+ src: img.url,
1921
+ alt: img.revised_prompt || "Generated image",
1922
+ className: "w-full rounded-lg"
1923
+ })
1924
+ }) : /* @__PURE__ */ jsx_runtime16.jsx("img", {
1925
+ src: img.url,
1926
+ alt: img.revised_prompt || "Generated image",
1927
+ className: "w-full rounded-lg border border-border"
1928
+ }),
1929
+ img.revised_prompt && /* @__PURE__ */ jsx_runtime16.jsx("p", {
1930
+ className: "text-[11px] text-muted-foreground italic px-0.5",
1931
+ children: img.revised_prompt
1932
+ })
1933
+ ]
1934
+ }, idx))
1935
+ })
1936
+ ]
1937
+ }),
1938
+ hasVideos && /* @__PURE__ */ jsx_runtime16.jsxs("div", {
1939
+ className: cn("space-y-2 pt-1", mediaClassName),
1940
+ children: [
1941
+ /* @__PURE__ */ jsx_runtime16.jsxs("div", {
1942
+ className: "flex items-center gap-2 text-xs font-medium text-muted-foreground",
1943
+ children: [
1944
+ /* @__PURE__ */ jsx_runtime16.jsx(import_lucide_react9.Video, {
1945
+ className: "h-3.5 w-3.5"
1946
+ }),
1947
+ "Videos (",
1948
+ message.videos.length,
1949
+ ")"
1950
+ ]
1951
+ }),
1952
+ /* @__PURE__ */ jsx_runtime16.jsx("div", {
1953
+ className: "space-y-2",
1954
+ children: message.videos.map((video, idx) => /* @__PURE__ */ jsx_runtime16.jsx("div", {
1955
+ children: video.url ? /* @__PURE__ */ jsx_runtime16.jsx("video", {
1956
+ src: video.url,
1957
+ controls: true,
1958
+ className: "w-full rounded-lg border border-border"
1959
+ }) : /* @__PURE__ */ jsx_runtime16.jsxs("div", {
1960
+ className: "bg-muted/50 border border-border p-2.5 rounded-lg text-xs text-muted-foreground",
1961
+ children: [
1962
+ "Video ID: ",
1963
+ video.id,
1964
+ " (ETA: ",
1965
+ video.eta,
1966
+ "s)"
1967
+ ]
1968
+ })
1969
+ }, idx))
1970
+ })
1971
+ ]
1972
+ }),
1973
+ hasAudio && /* @__PURE__ */ jsx_runtime16.jsxs("div", {
1974
+ className: cn("space-y-2 pt-1", mediaClassName),
1975
+ children: [
1976
+ /* @__PURE__ */ jsx_runtime16.jsxs("div", {
1977
+ className: "flex items-center gap-2 text-xs font-medium text-muted-foreground",
1978
+ children: [
1979
+ /* @__PURE__ */ jsx_runtime16.jsx(import_lucide_react9.Music, {
1980
+ className: "h-3.5 w-3.5"
1981
+ }),
1982
+ "Audio (",
1983
+ message.audio.length,
1984
+ ")"
1985
+ ]
1986
+ }),
1987
+ /* @__PURE__ */ jsx_runtime16.jsx("div", {
1988
+ className: "space-y-2",
1989
+ children: message.audio.map((audio, idx) => /* @__PURE__ */ jsx_runtime16.jsx("div", {
1990
+ children: audio.url ? /* @__PURE__ */ jsx_runtime16.jsx("audio", {
1991
+ src: audio.url,
1992
+ controls: true,
1993
+ className: "w-full"
1994
+ }) : audio.base64_audio ? /* @__PURE__ */ jsx_runtime16.jsx("audio", {
1995
+ src: `data:${audio.mime_type || "audio/wav"};base64,${audio.base64_audio}`,
1996
+ controls: true,
1997
+ className: "w-full"
1998
+ }) : /* @__PURE__ */ jsx_runtime16.jsx("div", {
1999
+ className: "bg-muted/50 border border-border p-2.5 rounded-lg text-xs text-muted-foreground",
2000
+ children: "Audio data unavailable"
2001
+ })
2002
+ }, idx))
2003
+ })
2004
+ ]
2005
+ }),
2006
+ hasFiles && /* @__PURE__ */ jsx_runtime16.jsxs("div", {
2007
+ className: cn("space-y-2 pt-1", mediaClassName),
2008
+ children: [
2009
+ /* @__PURE__ */ jsx_runtime16.jsxs("div", {
2010
+ className: "flex items-center gap-2 text-xs font-medium text-muted-foreground",
2011
+ children: [
2012
+ /* @__PURE__ */ jsx_runtime16.jsx(import_lucide_react9.Paperclip, {
2013
+ className: "h-3.5 w-3.5"
2014
+ }),
2015
+ "Files (",
2016
+ message.files.length,
2017
+ ")"
2018
+ ]
2019
+ }),
2020
+ /* @__PURE__ */ jsx_runtime16.jsx("div", {
2021
+ className: "flex flex-wrap gap-2",
2022
+ children: message.files.map((file, idx) => showFilePreview ? /* @__PURE__ */ jsx_runtime16.jsx(FilePreviewCard, {
2023
+ file: { name: file.name, type: file.type, url: file.url, size: file.size },
2024
+ onClick: () => openFilePreview({ name: file.name, type: file.type, url: file.url, size: file.size })
2025
+ }, idx) : /* @__PURE__ */ jsx_runtime16.jsxs("div", {
2026
+ className: "flex items-center gap-2 rounded-lg border border-border px-3 py-2 text-xs bg-muted/30 hover:bg-muted/50 transition-colors",
2027
+ children: [
2028
+ /* @__PURE__ */ jsx_runtime16.jsx(import_lucide_react9.FileIcon, {
2029
+ className: "h-3.5 w-3.5 shrink-0 text-muted-foreground"
2030
+ }),
2031
+ /* @__PURE__ */ jsx_runtime16.jsx("span", {
2032
+ className: "truncate max-w-[180px]",
2033
+ children: file.name
2034
+ }),
2035
+ file.size && /* @__PURE__ */ jsx_runtime16.jsxs("span", {
2036
+ className: "text-muted-foreground/70",
2037
+ children: [
2038
+ "(",
2039
+ (file.size / 1024).toFixed(1),
2040
+ "KB)"
2041
+ ]
2042
+ }),
2043
+ file.url && /^https?:\/\//i.test(file.url) && /* @__PURE__ */ jsx_runtime16.jsx("a", {
2044
+ href: file.url,
2045
+ target: "_blank",
2046
+ rel: "noopener noreferrer",
2047
+ className: "text-primary hover:underline font-medium",
2048
+ children: "View"
2049
+ })
2050
+ ]
2051
+ }, idx))
2052
+ })
2053
+ ]
2054
+ }),
2055
+ hasResponseAudio && message.response_audio && /* @__PURE__ */ jsx_runtime16.jsxs("div", {
2056
+ className: cn("space-y-2 pt-1", mediaClassName),
2057
+ children: [
2058
+ /* @__PURE__ */ jsx_runtime16.jsxs("div", {
2059
+ className: "flex items-center gap-2 text-xs font-medium text-muted-foreground",
2060
+ children: [
2061
+ /* @__PURE__ */ jsx_runtime16.jsx(import_lucide_react9.Music, {
2062
+ className: "h-3.5 w-3.5"
2063
+ }),
2064
+ "Response Audio"
2065
+ ]
2066
+ }),
2067
+ message.response_audio.transcript && /* @__PURE__ */ jsx_runtime16.jsxs("div", {
2068
+ className: "text-xs italic bg-muted/50 border border-border p-2.5 rounded-lg text-muted-foreground",
2069
+ children: [
2070
+ '"',
2071
+ message.response_audio.transcript,
2072
+ '"'
2073
+ ]
2074
+ }),
2075
+ message.response_audio.content && /* @__PURE__ */ jsx_runtime16.jsx("audio", {
2076
+ src: `data:audio/wav;base64,${message.response_audio.content}`,
2077
+ controls: true,
2078
+ className: "w-full"
2079
+ })
2080
+ ]
2081
+ })
2082
+ ]
2083
+ });
2084
+ }
2085
+
2086
+ // src/ui/composed/agno-chat/context.ts
2087
+ var import_react11 = require("react");
2088
+ var AgnoChatContext = import_react11.createContext(null);
2089
+ function useAgnoChatContext() {
2090
+ const ctx = import_react11.useContext(AgnoChatContext);
2091
+ if (!ctx) {
2092
+ throw new Error("useAgnoChatContext must be used within an <AgnoChat> provider. " + "Wrap your component tree with <AgnoChat>.");
2093
+ }
2094
+ return ctx;
2095
+ }
2096
+
2097
+ // src/ui/composed/agno-message/tools.tsx
2098
+ var jsx_runtime17 = require("react/jsx-runtime");
2099
+ function AgnoMessageTools({ renderTool: renderToolProp } = {}) {
2100
+ const { message, classNames, renderTool: ctxMsgRenderTool } = useAgnoMessageContext();
2101
+ const { renderTool: ctxChatRenderTool, isDebug } = useAgnoChatContext();
2102
+ const renderTool = renderToolProp ?? ctxMsgRenderTool ?? ctxChatRenderTool;
2103
+ if (!message.tool_calls || message.tool_calls.length === 0)
2104
+ return null;
2105
+ return /* @__PURE__ */ jsx_runtime17.jsx("div", {
2106
+ className: cn("space-y-2 pt-1", classNames?.assistant?.toolCalls),
2107
+ children: message.tool_calls.map((tool, idx) => {
2108
+ const defaultRender = () => isDebug ? /* @__PURE__ */ jsx_runtime17.jsx(ToolDebugCard, {
2109
+ tool,
2110
+ defaultOpen: idx === 0
2111
+ }) : null;
2112
+ const node = renderTool ? renderTool(tool, { index: idx, isDebug, defaultRender }) : defaultRender();
2113
+ if (node === null || node === undefined)
2114
+ return null;
2115
+ return /* @__PURE__ */ jsx_runtime17.jsx("div", {
2116
+ children: node
2117
+ }, tool.tool_call_id || idx);
2118
+ })
2119
+ });
2120
+ }
2121
+
2122
+ // src/ui/components/response.tsx
2123
+ var import_react12 = require("react");
2124
+ var import_streamdown = require("streamdown");
2125
+ var jsx_runtime18 = require("react/jsx-runtime");
2126
+ var Response = import_react12.memo(({ className, ...props }) => /* @__PURE__ */ jsx_runtime18.jsx(import_streamdown.Streamdown, {
2127
+ className: cn("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", className),
2128
+ ...props
2129
+ }), (prevProps, nextProps) => prevProps.children === nextProps.children);
2130
+ Response.displayName = "Response";
2131
+
2132
+ // src/ui/composed/agno-message/content.tsx
2133
+ var jsx_runtime19 = require("react/jsx-runtime");
2134
+ function AgnoMessageContent() {
2135
+ const { message } = useAgnoMessageContext();
2136
+ if (!message.content)
2137
+ return null;
2138
+ return /* @__PURE__ */ jsx_runtime19.jsx("div", {
2139
+ className: "prose prose-sm dark:prose-invert max-w-none prose-p:leading-relaxed prose-pre:bg-muted prose-pre:border prose-pre:border-border",
2140
+ children: /* @__PURE__ */ jsx_runtime19.jsx(Response, {
2141
+ children: message.content
2142
+ })
2143
+ });
2144
+ }
2145
+
2146
+ // src/ui/composed/agno-message/references.tsx
2147
+ var import_lucide_react10 = require("lucide-react");
2148
+ var jsx_runtime20 = require("react/jsx-runtime");
2149
+ function AgnoMessageReferences() {
2150
+ const { message, classNames } = useAgnoMessageContext();
2151
+ const references = message.extra_data?.references;
2152
+ if (!references || references.length === 0)
2153
+ return null;
2154
+ return /* @__PURE__ */ jsx_runtime20.jsxs("div", {
2155
+ className: cn("space-y-2 pt-1", classNames?.assistant?.references),
2156
+ children: [
2157
+ /* @__PURE__ */ jsx_runtime20.jsxs("div", {
2158
+ className: "flex items-center gap-2 text-xs font-medium text-muted-foreground",
2159
+ children: [
2160
+ /* @__PURE__ */ jsx_runtime20.jsx(import_lucide_react10.FileText, {
2161
+ className: "h-3.5 w-3.5"
2162
+ }),
2163
+ "References (",
2164
+ references.length,
2165
+ ")"
2166
+ ]
2167
+ }),
2168
+ /* @__PURE__ */ jsx_runtime20.jsx("div", {
2169
+ className: "space-y-2",
2170
+ children: references.map((refData, idx) => /* @__PURE__ */ jsx_runtime20.jsxs("div", {
2171
+ className: "text-xs space-y-1.5",
2172
+ children: [
2173
+ refData.query && /* @__PURE__ */ jsx_runtime20.jsxs("div", {
2174
+ className: "font-medium text-foreground",
2175
+ children: [
2176
+ "Query: ",
2177
+ refData.query
2178
+ ]
2179
+ }),
2180
+ refData.references.map((ref, refIdx) => /* @__PURE__ */ jsx_runtime20.jsxs("div", {
2181
+ className: "bg-muted/50 border border-border p-2.5 rounded-lg",
2182
+ children: [
2183
+ /* @__PURE__ */ jsx_runtime20.jsxs("div", {
2184
+ className: "italic text-muted-foreground mb-1",
2185
+ children: [
2186
+ '"',
2187
+ ref.content,
2188
+ '"'
2189
+ ]
2190
+ }),
2191
+ /* @__PURE__ */ jsx_runtime20.jsxs("div", {
2192
+ className: "text-muted-foreground/70",
2193
+ children: [
2194
+ "Source: ",
2195
+ ref.name,
2196
+ " (chunk ",
2197
+ ref.meta_data.chunk,
2198
+ "/",
2199
+ ref.meta_data.chunk_size,
2200
+ ")"
2201
+ ]
2202
+ })
2203
+ ]
2204
+ }, refIdx))
2205
+ ]
2206
+ }, idx))
2207
+ })
2208
+ ]
2209
+ });
2210
+ }
2211
+
2212
+ // src/ui/composed/agno-message/footer.tsx
2213
+ var import_lucide_react11 = require("lucide-react");
2214
+ var jsx_runtime21 = require("react/jsx-runtime");
2215
+ function AgnoMessageFooter({ showTimestamp = true } = {}) {
2216
+ const { message, classNames, actions, isLastAssistantMessage, formatTimestamp } = useAgnoMessageContext();
2217
+ const hasError = message.streamingError;
2218
+ const isCustomTimestamp = !!formatTimestamp;
2219
+ const resolvedFormatTimestamp = formatTimestamp ?? formatSmartTimestamp;
2220
+ if (!actions?.assistant && !showTimestamp && !hasError)
2221
+ return null;
2222
+ return /* @__PURE__ */ jsx_runtime21.jsxs("div", {
2223
+ className: "flex items-center gap-2 pt-1",
2224
+ children: [
2225
+ actions?.assistant && (() => {
2226
+ const visibility = actions.visibility ?? "visible";
2227
+ if (visibility === "last-assistant" && !isLastAssistantMessage)
2228
+ return null;
2229
+ const useHover = visibility === "hover" || visibility === "hover-last-visible" && !isLastAssistantMessage;
2230
+ return /* @__PURE__ */ jsx_runtime21.jsx("div", {
2231
+ className: cn("flex items-center gap-1 transition-opacity", useHover && "opacity-0 group-hover/message:opacity-100", classNames?.assistant?.actions),
2232
+ children: actions.assistant(message)
2233
+ });
2234
+ })(),
2235
+ hasError && /* @__PURE__ */ jsx_runtime21.jsxs("span", {
2236
+ className: "flex items-center gap-1 text-[11px] text-destructive",
2237
+ children: [
2238
+ /* @__PURE__ */ jsx_runtime21.jsx(import_lucide_react11.AlertCircle, {
2239
+ className: "h-3 w-3"
2240
+ }),
2241
+ "Error"
2242
+ ]
2243
+ }),
2244
+ showTimestamp && /* @__PURE__ */ jsx_runtime21.jsx(SmartTimestamp, {
2245
+ date: new Date(message.created_at * 1000),
2246
+ formatShort: isCustomTimestamp ? resolvedFormatTimestamp : undefined,
2247
+ className: "text-[11px] text-muted-foreground"
2248
+ })
2249
+ ]
2250
+ });
2251
+ }
2252
+
2253
+ // src/ui/composed/agno-message/message.tsx
2254
+ var jsx_runtime22 = require("react/jsx-runtime");
2255
+ function DefaultAssistantComposition({ showTimestamp }) {
2256
+ return /* @__PURE__ */ jsx_runtime22.jsxs(jsx_runtime22.Fragment, {
2257
+ children: [
2258
+ /* @__PURE__ */ jsx_runtime22.jsx(AgnoMessageReasoning, {}),
2259
+ /* @__PURE__ */ jsx_runtime22.jsx(AgnoMessageMedia, {}),
2260
+ /* @__PURE__ */ jsx_runtime22.jsx(AgnoMessageTools, {}),
2261
+ /* @__PURE__ */ jsx_runtime22.jsx(AgnoMessageContent, {}),
2262
+ /* @__PURE__ */ jsx_runtime22.jsx(AgnoMessageReferences, {}),
2263
+ /* @__PURE__ */ jsx_runtime22.jsx(AgnoMessageFooter, {
2264
+ showTimestamp
2265
+ })
2266
+ ]
2267
+ });
919
2268
  }
920
- // src/hooks/useAgnoSession.ts
921
- var import_react6 = require("react");
922
- function useAgnoSession() {
923
- const client = useAgnoClient();
924
- const [sessions, setSessions] = import_react6.useState([]);
925
- const [currentSessionId, setCurrentSessionId] = import_react6.useState(client.getConfig().sessionId);
926
- const [isLoading, setIsLoading] = import_react6.useState(false);
927
- const [error, setError] = import_react6.useState();
928
- import_react6.useEffect(() => {
929
- const handleSessionLoaded = (sessionId) => {
930
- setCurrentSessionId(sessionId);
931
- };
932
- const handleSessionCreated = (session) => {
933
- setSessions((prev) => [session, ...prev]);
934
- setCurrentSessionId(session.session_id);
935
- };
936
- const handleStateChange = () => {
937
- const config = client.getConfig();
938
- setCurrentSessionId(config.sessionId);
939
- setSessions(client.getState().sessions);
940
- };
941
- client.on("session:loaded", handleSessionLoaded);
942
- client.on("session:created", handleSessionCreated);
943
- client.on("state:change", handleStateChange);
944
- setSessions(client.getState().sessions);
945
- setCurrentSessionId(client.getConfig().sessionId);
946
- return () => {
947
- client.off("session:loaded", handleSessionLoaded);
948
- client.off("session:created", handleSessionCreated);
949
- client.off("state:change", handleStateChange);
950
- };
951
- }, [client]);
952
- const loadSession = import_react6.useCallback(async (sessionId, options) => {
953
- setIsLoading(true);
954
- setError(undefined);
955
- try {
956
- const messages = await client.loadSession(sessionId, options);
957
- setCurrentSessionId(sessionId);
958
- return messages;
959
- } catch (err) {
960
- const errorMessage = err instanceof Error ? err.message : String(err);
961
- setError(errorMessage);
962
- throw err;
963
- } finally {
964
- setIsLoading(false);
965
- }
966
- }, [client]);
967
- const fetchSessions = import_react6.useCallback(async (options) => {
968
- setIsLoading(true);
969
- setError(undefined);
970
- try {
971
- const fetchedSessions = await client.fetchSessions(options);
972
- setSessions(fetchedSessions);
973
- return fetchedSessions;
974
- } catch (err) {
975
- const errorMessage = err instanceof Error ? err.message : String(err);
976
- setError(errorMessage);
977
- throw err;
978
- } finally {
979
- setIsLoading(false);
980
- }
981
- }, [client]);
982
- const getSessionById = import_react6.useCallback(async (sessionId, options) => {
983
- setIsLoading(true);
984
- setError(undefined);
985
- try {
986
- return await client.getSessionById(sessionId, options);
987
- } catch (err) {
988
- const errorMessage = err instanceof Error ? err.message : String(err);
989
- setError(errorMessage);
990
- throw err;
991
- } finally {
992
- setIsLoading(false);
993
- }
994
- }, [client]);
995
- const getRunById = import_react6.useCallback(async (sessionId, runId, options) => {
996
- setIsLoading(true);
997
- setError(undefined);
998
- try {
999
- return await client.getRunById(sessionId, runId, options);
1000
- } catch (err) {
1001
- const errorMessage = err instanceof Error ? err.message : String(err);
1002
- setError(errorMessage);
1003
- throw err;
1004
- } finally {
1005
- setIsLoading(false);
1006
- }
1007
- }, [client]);
1008
- const createSession = import_react6.useCallback(async (request, options) => {
1009
- setIsLoading(true);
1010
- setError(undefined);
1011
- try {
1012
- const session = await client.createSession(request, options);
1013
- return session;
1014
- } catch (err) {
1015
- const errorMessage = err instanceof Error ? err.message : String(err);
1016
- setError(errorMessage);
1017
- throw err;
1018
- } finally {
1019
- setIsLoading(false);
1020
- }
1021
- }, [client]);
1022
- const updateSession = import_react6.useCallback(async (sessionId, request, options) => {
1023
- setIsLoading(true);
1024
- setError(undefined);
1025
- try {
1026
- return await client.updateSession(sessionId, request, options);
1027
- } catch (err) {
1028
- const errorMessage = err instanceof Error ? err.message : String(err);
1029
- setError(errorMessage);
1030
- throw err;
1031
- } finally {
1032
- setIsLoading(false);
1033
- }
1034
- }, [client]);
1035
- const renameSession = import_react6.useCallback(async (sessionId, newName, options) => {
1036
- setIsLoading(true);
1037
- setError(undefined);
1038
- try {
1039
- return await client.renameSession(sessionId, newName, options);
1040
- } catch (err) {
1041
- const errorMessage = err instanceof Error ? err.message : String(err);
1042
- setError(errorMessage);
1043
- throw err;
1044
- } finally {
1045
- setIsLoading(false);
1046
- }
1047
- }, [client]);
1048
- const deleteSession = import_react6.useCallback(async (sessionId, options) => {
1049
- setIsLoading(true);
1050
- setError(undefined);
1051
- try {
1052
- await client.deleteSession(sessionId, options);
1053
- } catch (err) {
1054
- const errorMessage = err instanceof Error ? err.message : String(err);
1055
- setError(errorMessage);
1056
- throw err;
1057
- } finally {
1058
- setIsLoading(false);
1059
- }
1060
- }, [client]);
1061
- const deleteMultipleSessions = import_react6.useCallback(async (sessionIds, options) => {
1062
- setIsLoading(true);
1063
- setError(undefined);
1064
- try {
1065
- await client.deleteMultipleSessions(sessionIds, options);
1066
- } catch (err) {
1067
- const errorMessage = err instanceof Error ? err.message : String(err);
1068
- setError(errorMessage);
1069
- throw err;
1070
- } finally {
1071
- setIsLoading(false);
1072
- }
1073
- }, [client]);
1074
- return {
1075
- sessions,
1076
- currentSessionId,
1077
- loadSession,
1078
- fetchSessions,
1079
- getSessionById,
1080
- getRunById,
1081
- createSession,
1082
- updateSession,
1083
- renameSession,
1084
- deleteSession,
1085
- deleteMultipleSessions,
1086
- isLoading,
1087
- error
1088
- };
2269
+ function AgnoMessage({
2270
+ message,
2271
+ className,
2272
+ classNames,
2273
+ avatars,
2274
+ actions,
2275
+ isLastAssistantMessage = false,
2276
+ showFilePreview = true,
2277
+ showImageLightbox = true,
2278
+ showTimestamp = true,
2279
+ formatTimestamp,
2280
+ renderTool,
2281
+ children
2282
+ }) {
2283
+ const isUser = message.role === "user";
2284
+ const hasError = message.streamingError;
2285
+ const [preview, setPreview] = import_react13.useState(null);
2286
+ const isCustomTimestamp = !!formatTimestamp;
2287
+ const resolvedFormatTimestamp = formatTimestamp ?? formatSmartTimestamp;
2288
+ const ctx = import_react13.useMemo(() => ({
2289
+ message,
2290
+ isLastAssistantMessage,
2291
+ classNames,
2292
+ actions,
2293
+ avatars,
2294
+ formatTimestamp,
2295
+ showFilePreview,
2296
+ showImageLightbox,
2297
+ openImageLightbox: (images, index) => {
2298
+ if (!showImageLightbox)
2299
+ return;
2300
+ setPreview({ type: "image", images, initialIndex: index });
2301
+ },
2302
+ openFilePreview: (file) => {
2303
+ if (!showFilePreview)
2304
+ return;
2305
+ setPreview({ type: "file", file });
2306
+ },
2307
+ renderTool
2308
+ }), [
2309
+ message,
2310
+ isLastAssistantMessage,
2311
+ classNames,
2312
+ actions,
2313
+ avatars,
2314
+ formatTimestamp,
2315
+ showFilePreview,
2316
+ showImageLightbox,
2317
+ renderTool
2318
+ ]);
2319
+ const closePreview = () => setPreview(null);
2320
+ return /* @__PURE__ */ jsx_runtime22.jsx(AgnoMessageContext.Provider, {
2321
+ value: ctx,
2322
+ children: /* @__PURE__ */ jsx_runtime22.jsxs("div", {
2323
+ className: cn("py-5 first:pt-2", isUser ? "flex justify-end" : "", classNames?.root, className),
2324
+ children: [
2325
+ isUser ? /* @__PURE__ */ jsx_runtime22.jsx(UserMessageLayout, {
2326
+ message,
2327
+ classNames,
2328
+ avatars,
2329
+ actions,
2330
+ isCustomTimestamp,
2331
+ resolvedFormatTimestamp,
2332
+ showTimestamp,
2333
+ showImageLightbox,
2334
+ showFilePreview,
2335
+ openImageLightbox: ctx.openImageLightbox,
2336
+ openFilePreview: ctx.openFilePreview,
2337
+ hasError
2338
+ }) : /* @__PURE__ */ jsx_runtime22.jsxs("div", {
2339
+ className: "flex items-start gap-3 group/message",
2340
+ children: [
2341
+ avatars?.assistant,
2342
+ /* @__PURE__ */ jsx_runtime22.jsx("div", {
2343
+ className: cn("flex-1 min-w-0 space-y-3", classNames?.assistant?.container),
2344
+ children: children ?? /* @__PURE__ */ jsx_runtime22.jsx(DefaultAssistantComposition, {
2345
+ showTimestamp
2346
+ })
2347
+ })
2348
+ ]
2349
+ }),
2350
+ preview?.type === "image" && /* @__PURE__ */ jsx_runtime22.jsx(ImageLightbox, {
2351
+ open: true,
2352
+ onOpenChange: (open) => {
2353
+ if (!open)
2354
+ closePreview();
2355
+ },
2356
+ images: preview.images,
2357
+ initialIndex: preview.initialIndex
2358
+ }),
2359
+ preview?.type === "file" && /* @__PURE__ */ jsx_runtime22.jsx(FilePreviewModal, {
2360
+ open: true,
2361
+ onOpenChange: (open) => {
2362
+ if (!open)
2363
+ closePreview();
2364
+ },
2365
+ file: preview.file
2366
+ })
2367
+ ]
2368
+ })
2369
+ });
1089
2370
  }
1090
- // src/hooks/useAgnoActions.ts
1091
- var import_react7 = require("react");
1092
- function useAgnoActions() {
1093
- const client = useAgnoClient();
1094
- const [isInitializing, setIsInitializing] = import_react7.useState(false);
1095
- const [error, setError] = import_react7.useState();
1096
- const initialize = import_react7.useCallback(async (options) => {
1097
- setIsInitializing(true);
1098
- setError(undefined);
1099
- try {
1100
- const result = await client.initialize(options);
1101
- return result;
1102
- } catch (err) {
1103
- const errorMessage = err instanceof Error ? err.message : String(err);
1104
- setError(errorMessage);
1105
- throw err;
1106
- } finally {
1107
- setIsInitializing(false);
1108
- }
1109
- }, [client]);
1110
- const checkStatus = import_react7.useCallback(async (options) => {
1111
- setError(undefined);
1112
- try {
1113
- return await client.checkStatus(options);
1114
- } catch (err) {
1115
- const errorMessage = err instanceof Error ? err.message : String(err);
1116
- setError(errorMessage);
1117
- return false;
1118
- }
1119
- }, [client]);
1120
- const fetchAgents = import_react7.useCallback(async (options) => {
1121
- setError(undefined);
1122
- try {
1123
- return await client.fetchAgents(options);
1124
- } catch (err) {
1125
- const errorMessage = err instanceof Error ? err.message : String(err);
1126
- setError(errorMessage);
1127
- throw err;
1128
- }
1129
- }, [client]);
1130
- const fetchTeams = import_react7.useCallback(async (options) => {
1131
- setError(undefined);
1132
- try {
1133
- return await client.fetchTeams(options);
1134
- } catch (err) {
1135
- const errorMessage = err instanceof Error ? err.message : String(err);
1136
- setError(errorMessage);
1137
- throw err;
1138
- }
1139
- }, [client]);
1140
- const updateConfig = import_react7.useCallback((updates) => {
1141
- client.updateConfig(updates);
1142
- }, [client]);
1143
- return {
1144
- initialize,
1145
- checkStatus,
1146
- fetchAgents,
1147
- fetchTeams,
1148
- updateConfig,
1149
- isInitializing,
1150
- error
1151
- };
2371
+ AgnoMessage.Reasoning = AgnoMessageReasoning;
2372
+ AgnoMessage.Media = AgnoMessageMedia;
2373
+ AgnoMessage.Tools = AgnoMessageTools;
2374
+ AgnoMessage.Content = AgnoMessageContent;
2375
+ AgnoMessage.References = AgnoMessageReferences;
2376
+ AgnoMessage.Footer = AgnoMessageFooter;
2377
+ function UserMessageLayout({
2378
+ message,
2379
+ classNames,
2380
+ avatars,
2381
+ actions,
2382
+ isCustomTimestamp,
2383
+ resolvedFormatTimestamp,
2384
+ showTimestamp,
2385
+ showImageLightbox,
2386
+ showFilePreview,
2387
+ openImageLightbox,
2388
+ openFilePreview,
2389
+ hasError
2390
+ }) {
2391
+ return /* @__PURE__ */ jsx_runtime22.jsxs("div", {
2392
+ className: "flex items-start gap-2.5 max-w-[80%] flex-row-reverse",
2393
+ children: [
2394
+ avatars?.user,
2395
+ /* @__PURE__ */ jsx_runtime22.jsxs("div", {
2396
+ className: "space-y-1.5 flex flex-col items-end min-w-0",
2397
+ children: [
2398
+ (message.images && message.images.length > 0 || message.audio && message.audio.length > 0 || message.files && message.files.length > 0) && /* @__PURE__ */ jsx_runtime22.jsxs("div", {
2399
+ className: "flex flex-wrap gap-2 justify-end",
2400
+ children: [
2401
+ message.images?.map((img, idx) => /* @__PURE__ */ jsx_runtime22.jsx(FilePreviewCard, {
2402
+ file: { name: img.revised_prompt || `Image ${idx + 1}`, type: "image/png", url: img.url },
2403
+ onClick: showImageLightbox ? () => openImageLightbox(message.images.map((i) => ({ url: i.url, alt: i.revised_prompt })), idx) : undefined
2404
+ }, `img-${idx}`)),
2405
+ message.audio?.map((audio, idx) => /* @__PURE__ */ jsx_runtime22.jsxs("div", {
2406
+ className: "flex items-center gap-1.5 rounded-lg border border-border bg-muted/50 px-2.5 py-1.5 text-xs text-foreground self-end",
2407
+ children: [
2408
+ /* @__PURE__ */ jsx_runtime22.jsx(import_lucide_react12.Music, {
2409
+ className: "h-3.5 w-3.5 text-muted-foreground"
2410
+ }),
2411
+ /* @__PURE__ */ jsx_runtime22.jsx("span", {
2412
+ className: "truncate max-w-[150px]",
2413
+ children: audio.id || `Audio ${idx + 1}`
2414
+ })
2415
+ ]
2416
+ }, `audio-${idx}`)),
2417
+ message.files?.map((file, idx) => showFilePreview ? /* @__PURE__ */ jsx_runtime22.jsx(FilePreviewCard, {
2418
+ file: { name: file.name, type: file.type, url: file.url, size: file.size },
2419
+ onClick: () => openFilePreview({ name: file.name, type: file.type, url: file.url, size: file.size })
2420
+ }, `file-${idx}`) : /* @__PURE__ */ jsx_runtime22.jsxs("div", {
2421
+ className: "flex items-center gap-1.5 rounded-lg border border-border bg-muted/50 px-2.5 py-1.5 text-xs text-foreground self-end",
2422
+ children: [
2423
+ /* @__PURE__ */ jsx_runtime22.jsx(import_lucide_react12.FileIcon, {
2424
+ className: "h-3.5 w-3.5 text-muted-foreground"
2425
+ }),
2426
+ /* @__PURE__ */ jsx_runtime22.jsx("span", {
2427
+ className: "truncate max-w-[150px]",
2428
+ children: file.name
2429
+ })
2430
+ ]
2431
+ }, `file-${idx}`))
2432
+ ]
2433
+ }),
2434
+ message.content && /* @__PURE__ */ jsx_runtime22.jsx("div", {
2435
+ className: cn("rounded-2xl rounded-br-md px-4 py-2.5", classNames?.user?.bubble ?? "bg-primary text-primary-foreground", hasError && "opacity-70"),
2436
+ children: /* @__PURE__ */ jsx_runtime22.jsx("p", {
2437
+ className: "text-sm whitespace-pre-wrap",
2438
+ children: message.content
2439
+ })
2440
+ }),
2441
+ (showTimestamp || actions?.user) && /* @__PURE__ */ jsx_runtime22.jsxs("div", {
2442
+ className: "flex items-center justify-end gap-1.5 px-1",
2443
+ children: [
2444
+ actions?.user && /* @__PURE__ */ jsx_runtime22.jsx("div", {
2445
+ className: "flex items-center gap-1",
2446
+ children: actions.user(message)
2447
+ }),
2448
+ /* @__PURE__ */ jsx_runtime22.jsx(SmartTimestamp, {
2449
+ date: new Date(message.created_at * 1000),
2450
+ formatShort: isCustomTimestamp ? resolvedFormatTimestamp : undefined,
2451
+ className: "text-[11px] text-muted-foreground"
2452
+ }),
2453
+ hasError && /* @__PURE__ */ jsx_runtime22.jsx(import_lucide_react12.AlertCircle, {
2454
+ className: "h-3 w-3 text-destructive"
2455
+ })
2456
+ ]
2457
+ })
2458
+ ]
2459
+ })
2460
+ ]
2461
+ });
1152
2462
  }
1153
2463
  // src/hooks/useAgnoCustomEvents.ts
1154
- var import_react8 = require("react");
2464
+ var import_react14 = require("react");
1155
2465
  function useAgnoCustomEvents(handler) {
1156
2466
  const client = useAgnoClient();
1157
- const [events, setEvents] = import_react8.useState([]);
1158
- const handlerRef = import_react8.useRef(handler);
2467
+ const [events, setEvents] = import_react14.useState([]);
2468
+ const handlerRef = import_react14.useRef(handler);
1159
2469
  handlerRef.current = handler;
1160
- import_react8.useEffect(() => {
2470
+ import_react14.useEffect(() => {
1161
2471
  const handleCustomEvent = (event) => {
1162
2472
  setEvents((prev) => [...prev, event]);
1163
2473
  handlerRef.current?.(event);
@@ -1167,20 +2477,20 @@ function useAgnoCustomEvents(handler) {
1167
2477
  client.off("custom:event", handleCustomEvent);
1168
2478
  };
1169
2479
  }, [client]);
1170
- const clearEvents = import_react8.useCallback(() => {
2480
+ const clearEvents = import_react14.useCallback(() => {
1171
2481
  setEvents([]);
1172
2482
  }, []);
1173
2483
  return { events, clearEvents };
1174
2484
  }
1175
2485
  // src/hooks/useAgnoMemory.ts
1176
- var import_react9 = require("react");
2486
+ var import_react15 = require("react");
1177
2487
  function useAgnoMemory() {
1178
2488
  const client = useAgnoClient();
1179
- const [memories, setMemories] = import_react9.useState([]);
1180
- const [topics, setTopics] = import_react9.useState([]);
1181
- const [isLoading, setIsLoading] = import_react9.useState(false);
1182
- const [error, setError] = import_react9.useState();
1183
- import_react9.useEffect(() => {
2489
+ const [memories, setMemories] = import_react15.useState([]);
2490
+ const [topics, setTopics] = import_react15.useState([]);
2491
+ const [isLoading, setIsLoading] = import_react15.useState(false);
2492
+ const [error, setError] = import_react15.useState();
2493
+ import_react15.useEffect(() => {
1184
2494
  const handleMemoryCreated = (memory) => {
1185
2495
  setMemories((prev) => [memory, ...prev]);
1186
2496
  };
@@ -1215,7 +2525,7 @@ function useAgnoMemory() {
1215
2525
  client.off("state:change", handleStateChange);
1216
2526
  };
1217
2527
  }, [client]);
1218
- const fetchMemories = import_react9.useCallback(async (queryParams, options) => {
2528
+ const fetchMemories = import_react15.useCallback(async (queryParams, options) => {
1219
2529
  setIsLoading(true);
1220
2530
  setError(undefined);
1221
2531
  try {
@@ -1230,7 +2540,7 @@ function useAgnoMemory() {
1230
2540
  setIsLoading(false);
1231
2541
  }
1232
2542
  }, [client]);
1233
- const getMemoryById = import_react9.useCallback(async (memoryId, options) => {
2543
+ const getMemoryById = import_react15.useCallback(async (memoryId, options) => {
1234
2544
  setIsLoading(true);
1235
2545
  setError(undefined);
1236
2546
  try {
@@ -1243,7 +2553,7 @@ function useAgnoMemory() {
1243
2553
  setIsLoading(false);
1244
2554
  }
1245
2555
  }, [client]);
1246
- const getMemoryTopics = import_react9.useCallback(async (options) => {
2556
+ const getMemoryTopics = import_react15.useCallback(async (options) => {
1247
2557
  setIsLoading(true);
1248
2558
  setError(undefined);
1249
2559
  try {
@@ -1258,7 +2568,7 @@ function useAgnoMemory() {
1258
2568
  setIsLoading(false);
1259
2569
  }
1260
2570
  }, [client]);
1261
- const getUserMemoryStats = import_react9.useCallback(async (queryParams, options) => {
2571
+ const getUserMemoryStats = import_react15.useCallback(async (queryParams, options) => {
1262
2572
  setIsLoading(true);
1263
2573
  setError(undefined);
1264
2574
  try {
@@ -1271,7 +2581,7 @@ function useAgnoMemory() {
1271
2581
  setIsLoading(false);
1272
2582
  }
1273
2583
  }, [client]);
1274
- const createMemory = import_react9.useCallback(async (request, options) => {
2584
+ const createMemory = import_react15.useCallback(async (request, options) => {
1275
2585
  setIsLoading(true);
1276
2586
  setError(undefined);
1277
2587
  try {
@@ -1284,7 +2594,7 @@ function useAgnoMemory() {
1284
2594
  setIsLoading(false);
1285
2595
  }
1286
2596
  }, [client]);
1287
- const updateMemory = import_react9.useCallback(async (memoryId, request, options) => {
2597
+ const updateMemory = import_react15.useCallback(async (memoryId, request, options) => {
1288
2598
  setIsLoading(true);
1289
2599
  setError(undefined);
1290
2600
  try {
@@ -1297,7 +2607,7 @@ function useAgnoMemory() {
1297
2607
  setIsLoading(false);
1298
2608
  }
1299
2609
  }, [client]);
1300
- const deleteMemory = import_react9.useCallback(async (memoryId, options) => {
2610
+ const deleteMemory = import_react15.useCallback(async (memoryId, options) => {
1301
2611
  setIsLoading(true);
1302
2612
  setError(undefined);
1303
2613
  try {
@@ -1310,7 +2620,7 @@ function useAgnoMemory() {
1310
2620
  setIsLoading(false);
1311
2621
  }
1312
2622
  }, [client]);
1313
- const deleteMultipleMemories = import_react9.useCallback(async (memoryIds, options) => {
2623
+ const deleteMultipleMemories = import_react15.useCallback(async (memoryIds, options) => {
1314
2624
  setIsLoading(true);
1315
2625
  setError(undefined);
1316
2626
  try {
@@ -1339,12 +2649,12 @@ function useAgnoMemory() {
1339
2649
  };
1340
2650
  }
1341
2651
  // src/hooks/useAgnoSessionState.ts
1342
- var import_react10 = require("react");
2652
+ var import_react16 = require("react");
1343
2653
  function useAgnoSessionState() {
1344
2654
  const client = useAgnoClient();
1345
- const [sessionState, setLocalSessionState] = import_react10.useState(() => client.getSessionState());
1346
- const [isRefreshing, setIsRefreshing] = import_react10.useState(() => client.getState().isSessionStateRefreshing ?? false);
1347
- import_react10.useEffect(() => {
2655
+ const [sessionState, setLocalSessionState] = import_react16.useState(() => client.getSessionState());
2656
+ const [isRefreshing, setIsRefreshing] = import_react16.useState(() => client.getState().isSessionStateRefreshing ?? false);
2657
+ import_react16.useEffect(() => {
1348
2658
  const handleStateChange = (state) => {
1349
2659
  setLocalSessionState(state);
1350
2660
  };
@@ -1361,16 +2671,16 @@ function useAgnoSessionState() {
1361
2671
  client.off("session-state:refresh:end", handleRefreshEnd);
1362
2672
  };
1363
2673
  }, [client]);
1364
- const setSessionState = import_react10.useCallback(async (next) => {
2674
+ const setSessionState = import_react16.useCallback(async (next) => {
1365
2675
  const resolved = typeof next === "function" ? next(client.getSessionState()) : next;
1366
2676
  await client.setSessionState(resolved);
1367
2677
  }, [client]);
1368
- const mergeSessionState = import_react10.useCallback(async (partial) => {
2678
+ const mergeSessionState = import_react16.useCallback(async (partial) => {
1369
2679
  const current = client.getSessionState() ?? {};
1370
2680
  const merged = { ...current, ...partial };
1371
2681
  await client.setSessionState(merged);
1372
2682
  }, [client]);
1373
- const refreshSessionState = import_react10.useCallback(async () => {
2683
+ const refreshSessionState = import_react16.useCallback(async () => {
1374
2684
  const result = await client.refreshSessionState();
1375
2685
  return result ?? null;
1376
2686
  }, [client]);
@@ -1383,14 +2693,14 @@ function useAgnoSessionState() {
1383
2693
  };
1384
2694
  }
1385
2695
  // src/hooks/useAgnoKnowledge.ts
1386
- var import_react11 = require("react");
2696
+ var import_react17 = require("react");
1387
2697
  function useAgnoKnowledge() {
1388
2698
  const client = useAgnoClient();
1389
- const [isLoading, setIsLoading] = import_react11.useState(false);
1390
- const [error, setError] = import_react11.useState();
1391
- const [config, setConfig] = import_react11.useState();
1392
- const [content, setContent] = import_react11.useState([]);
1393
- const getConfig = import_react11.useCallback(async (options) => {
2699
+ const [isLoading, setIsLoading] = import_react17.useState(false);
2700
+ const [error, setError] = import_react17.useState();
2701
+ const [config, setConfig] = import_react17.useState();
2702
+ const [content, setContent] = import_react17.useState([]);
2703
+ const getConfig = import_react17.useCallback(async (options) => {
1394
2704
  setIsLoading(true);
1395
2705
  setError(undefined);
1396
2706
  try {
@@ -1405,7 +2715,7 @@ function useAgnoKnowledge() {
1405
2715
  setIsLoading(false);
1406
2716
  }
1407
2717
  }, [client]);
1408
- const listContent = import_react11.useCallback(async (listOptions, options) => {
2718
+ const listContent = import_react17.useCallback(async (listOptions, options) => {
1409
2719
  setIsLoading(true);
1410
2720
  setError(undefined);
1411
2721
  try {
@@ -1420,7 +2730,7 @@ function useAgnoKnowledge() {
1420
2730
  setIsLoading(false);
1421
2731
  }
1422
2732
  }, [client]);
1423
- const getContent = import_react11.useCallback(async (contentId, options) => {
2733
+ const getContent = import_react17.useCallback(async (contentId, options) => {
1424
2734
  setIsLoading(true);
1425
2735
  setError(undefined);
1426
2736
  try {
@@ -1433,7 +2743,7 @@ function useAgnoKnowledge() {
1433
2743
  setIsLoading(false);
1434
2744
  }
1435
2745
  }, [client]);
1436
- const getContentStatus = import_react11.useCallback(async (contentId, options) => {
2746
+ const getContentStatus = import_react17.useCallback(async (contentId, options) => {
1437
2747
  setIsLoading(true);
1438
2748
  setError(undefined);
1439
2749
  try {
@@ -1446,7 +2756,7 @@ function useAgnoKnowledge() {
1446
2756
  setIsLoading(false);
1447
2757
  }
1448
2758
  }, [client]);
1449
- const search = import_react11.useCallback(async (request, options) => {
2759
+ const search = import_react17.useCallback(async (request, options) => {
1450
2760
  setIsLoading(true);
1451
2761
  setError(undefined);
1452
2762
  try {
@@ -1459,7 +2769,7 @@ function useAgnoKnowledge() {
1459
2769
  setIsLoading(false);
1460
2770
  }
1461
2771
  }, [client]);
1462
- const uploadContent = import_react11.useCallback(async (data, options) => {
2772
+ const uploadContent = import_react17.useCallback(async (data, options) => {
1463
2773
  setIsLoading(true);
1464
2774
  setError(undefined);
1465
2775
  try {
@@ -1474,7 +2784,7 @@ function useAgnoKnowledge() {
1474
2784
  setIsLoading(false);
1475
2785
  }
1476
2786
  }, [client]);
1477
- const updateContent = import_react11.useCallback(async (contentId, request, options) => {
2787
+ const updateContent = import_react17.useCallback(async (contentId, request, options) => {
1478
2788
  setIsLoading(true);
1479
2789
  setError(undefined);
1480
2790
  try {
@@ -1489,7 +2799,7 @@ function useAgnoKnowledge() {
1489
2799
  setIsLoading(false);
1490
2800
  }
1491
2801
  }, [client]);
1492
- const deleteAllContent = import_react11.useCallback(async (options) => {
2802
+ const deleteAllContent = import_react17.useCallback(async (options) => {
1493
2803
  setIsLoading(true);
1494
2804
  setError(undefined);
1495
2805
  try {
@@ -1503,7 +2813,7 @@ function useAgnoKnowledge() {
1503
2813
  setIsLoading(false);
1504
2814
  }
1505
2815
  }, [client]);
1506
- const deleteContent = import_react11.useCallback(async (contentId, options) => {
2816
+ const deleteContent = import_react17.useCallback(async (contentId, options) => {
1507
2817
  setIsLoading(true);
1508
2818
  setError(undefined);
1509
2819
  try {
@@ -1535,14 +2845,14 @@ function useAgnoKnowledge() {
1535
2845
  };
1536
2846
  }
1537
2847
  // src/hooks/useAgnoMetrics.ts
1538
- var import_react12 = require("react");
2848
+ var import_react18 = require("react");
1539
2849
  function useAgnoMetrics() {
1540
2850
  const client = useAgnoClient();
1541
- const [isLoading, setIsLoading] = import_react12.useState(false);
1542
- const [isRefreshing, setIsRefreshing] = import_react12.useState(false);
1543
- const [error, setError] = import_react12.useState();
1544
- const [metrics, setMetrics] = import_react12.useState();
1545
- const fetchMetrics = import_react12.useCallback(async (options) => {
2851
+ const [isLoading, setIsLoading] = import_react18.useState(false);
2852
+ const [isRefreshing, setIsRefreshing] = import_react18.useState(false);
2853
+ const [error, setError] = import_react18.useState();
2854
+ const [metrics, setMetrics] = import_react18.useState();
2855
+ const fetchMetrics = import_react18.useCallback(async (options) => {
1546
2856
  setIsLoading(true);
1547
2857
  setError(undefined);
1548
2858
  try {
@@ -1557,7 +2867,7 @@ function useAgnoMetrics() {
1557
2867
  setIsLoading(false);
1558
2868
  }
1559
2869
  }, [client]);
1560
- const refreshMetrics = import_react12.useCallback(async (options) => {
2870
+ const refreshMetrics = import_react18.useCallback(async (options) => {
1561
2871
  setIsRefreshing(true);
1562
2872
  setError(undefined);
1563
2873
  try {
@@ -1571,7 +2881,7 @@ function useAgnoMetrics() {
1571
2881
  setIsRefreshing(false);
1572
2882
  }
1573
2883
  }, [client]);
1574
- const clearMetrics = import_react12.useCallback(() => {
2884
+ const clearMetrics = import_react18.useCallback(() => {
1575
2885
  setMetrics(undefined);
1576
2886
  setError(undefined);
1577
2887
  }, []);
@@ -1586,14 +2896,14 @@ function useAgnoMetrics() {
1586
2896
  };
1587
2897
  }
1588
2898
  // src/hooks/useAgnoEvals.ts
1589
- var import_react13 = require("react");
2899
+ var import_react19 = require("react");
1590
2900
  function useAgnoEvals() {
1591
2901
  const client = useAgnoClient();
1592
- const [evalRuns, setEvalRuns] = import_react13.useState([]);
1593
- const [pagination, setPagination] = import_react13.useState();
1594
- const [isLoading, setIsLoading] = import_react13.useState(false);
1595
- const [error, setError] = import_react13.useState();
1596
- const listEvalRuns = import_react13.useCallback(async (listParams = {}, options) => {
2902
+ const [evalRuns, setEvalRuns] = import_react19.useState([]);
2903
+ const [pagination, setPagination] = import_react19.useState();
2904
+ const [isLoading, setIsLoading] = import_react19.useState(false);
2905
+ const [error, setError] = import_react19.useState();
2906
+ const listEvalRuns = import_react19.useCallback(async (listParams = {}, options) => {
1597
2907
  setIsLoading(true);
1598
2908
  setError(undefined);
1599
2909
  try {
@@ -1609,7 +2919,7 @@ function useAgnoEvals() {
1609
2919
  setIsLoading(false);
1610
2920
  }
1611
2921
  }, [client]);
1612
- const getEvalRun = import_react13.useCallback(async (evalRunId, options) => {
2922
+ const getEvalRun = import_react19.useCallback(async (evalRunId, options) => {
1613
2923
  setIsLoading(true);
1614
2924
  setError(undefined);
1615
2925
  try {
@@ -1622,7 +2932,7 @@ function useAgnoEvals() {
1622
2932
  setIsLoading(false);
1623
2933
  }
1624
2934
  }, [client]);
1625
- const executeEval = import_react13.useCallback(async (request, options) => {
2935
+ const executeEval = import_react19.useCallback(async (request, options) => {
1626
2936
  setIsLoading(true);
1627
2937
  setError(undefined);
1628
2938
  try {
@@ -1637,7 +2947,7 @@ function useAgnoEvals() {
1637
2947
  setIsLoading(false);
1638
2948
  }
1639
2949
  }, [client]);
1640
- const updateEvalRun = import_react13.useCallback(async (evalRunId, request, options) => {
2950
+ const updateEvalRun = import_react19.useCallback(async (evalRunId, request, options) => {
1641
2951
  setIsLoading(true);
1642
2952
  setError(undefined);
1643
2953
  try {
@@ -1652,7 +2962,7 @@ function useAgnoEvals() {
1652
2962
  setIsLoading(false);
1653
2963
  }
1654
2964
  }, [client]);
1655
- const deleteEvalRuns = import_react13.useCallback(async (evalRunIds, options) => {
2965
+ const deleteEvalRuns = import_react19.useCallback(async (evalRunIds, options) => {
1656
2966
  setIsLoading(true);
1657
2967
  setError(undefined);
1658
2968
  try {
@@ -1667,7 +2977,7 @@ function useAgnoEvals() {
1667
2977
  setIsLoading(false);
1668
2978
  }
1669
2979
  }, [client]);
1670
- const renameEvalRun = import_react13.useCallback(async (evalRunId, newName, options) => {
2980
+ const renameEvalRun = import_react19.useCallback(async (evalRunId, newName, options) => {
1671
2981
  return updateEvalRun(evalRunId, { name: newName }, options);
1672
2982
  }, [updateEvalRun]);
1673
2983
  return {
@@ -1684,14 +2994,14 @@ function useAgnoEvals() {
1684
2994
  };
1685
2995
  }
1686
2996
  // src/hooks/useAgnoTraces.ts
1687
- var import_react14 = require("react");
2997
+ var import_react20 = require("react");
1688
2998
  function useAgnoTraces() {
1689
2999
  const client = useAgnoClient();
1690
- const [traces, setTraces] = import_react14.useState([]);
1691
- const [traceSessionStats, setTraceSessionStats] = import_react14.useState([]);
1692
- const [isLoading, setIsLoading] = import_react14.useState(false);
1693
- const [error, setError] = import_react14.useState();
1694
- import_react14.useEffect(() => {
3000
+ const [traces, setTraces] = import_react20.useState([]);
3001
+ const [traceSessionStats, setTraceSessionStats] = import_react20.useState([]);
3002
+ const [isLoading, setIsLoading] = import_react20.useState(false);
3003
+ const [error, setError] = import_react20.useState();
3004
+ import_react20.useEffect(() => {
1695
3005
  const handleStateChange = () => {
1696
3006
  const state2 = client.getState();
1697
3007
  setTraces(state2.traces);
@@ -1705,7 +3015,7 @@ function useAgnoTraces() {
1705
3015
  client.off("state:change", handleStateChange);
1706
3016
  };
1707
3017
  }, [client]);
1708
- const fetchTraces = import_react14.useCallback(async (options = {}, requestOptions) => {
3018
+ const fetchTraces = import_react20.useCallback(async (options = {}, requestOptions) => {
1709
3019
  setIsLoading(true);
1710
3020
  setError(undefined);
1711
3021
  try {
@@ -1720,7 +3030,7 @@ function useAgnoTraces() {
1720
3030
  setIsLoading(false);
1721
3031
  }
1722
3032
  }, [client]);
1723
- const getTraceDetail = import_react14.useCallback(async (traceId, options = {}, requestOptions) => {
3033
+ const getTraceDetail = import_react20.useCallback(async (traceId, options = {}, requestOptions) => {
1724
3034
  setIsLoading(true);
1725
3035
  setError(undefined);
1726
3036
  try {
@@ -1733,7 +3043,7 @@ function useAgnoTraces() {
1733
3043
  setIsLoading(false);
1734
3044
  }
1735
3045
  }, [client]);
1736
- const fetchTraceSessionStats = import_react14.useCallback(async (options = {}, requestOptions) => {
3046
+ const fetchTraceSessionStats = import_react20.useCallback(async (options = {}, requestOptions) => {
1737
3047
  setIsLoading(true);
1738
3048
  setError(undefined);
1739
3049
  try {
@@ -1759,13 +3069,13 @@ function useAgnoTraces() {
1759
3069
  };
1760
3070
  }
1761
3071
  // src/hooks/useAgnoComponents.ts
1762
- var import_react15 = require("react");
3072
+ var import_react21 = require("react");
1763
3073
  function useAgnoComponents() {
1764
3074
  const client = useAgnoClient();
1765
- const [components, setComponents] = import_react15.useState([]);
1766
- const [isLoading, setIsLoading] = import_react15.useState(false);
1767
- const [error, setError] = import_react15.useState();
1768
- import_react15.useEffect(() => {
3075
+ const [components, setComponents] = import_react21.useState([]);
3076
+ const [isLoading, setIsLoading] = import_react21.useState(false);
3077
+ const [error, setError] = import_react21.useState();
3078
+ import_react21.useEffect(() => {
1769
3079
  const handleComponentCreated = (component) => {
1770
3080
  setComponents((prev) => [component, ...prev]);
1771
3081
  };
@@ -1790,7 +3100,7 @@ function useAgnoComponents() {
1790
3100
  client.off("state:change", handleStateChange);
1791
3101
  };
1792
3102
  }, [client]);
1793
- const fetchComponents = import_react15.useCallback(async (queryParams, options) => {
3103
+ const fetchComponents = import_react21.useCallback(async (queryParams, options) => {
1794
3104
  setIsLoading(true);
1795
3105
  setError(undefined);
1796
3106
  try {
@@ -1805,7 +3115,7 @@ function useAgnoComponents() {
1805
3115
  setIsLoading(false);
1806
3116
  }
1807
3117
  }, [client]);
1808
- const getComponentById = import_react15.useCallback(async (componentId, options) => {
3118
+ const getComponentById = import_react21.useCallback(async (componentId, options) => {
1809
3119
  setIsLoading(true);
1810
3120
  setError(undefined);
1811
3121
  try {
@@ -1818,7 +3128,7 @@ function useAgnoComponents() {
1818
3128
  setIsLoading(false);
1819
3129
  }
1820
3130
  }, [client]);
1821
- const createComponent = import_react15.useCallback(async (request, options) => {
3131
+ const createComponent = import_react21.useCallback(async (request, options) => {
1822
3132
  setIsLoading(true);
1823
3133
  setError(undefined);
1824
3134
  try {
@@ -1831,7 +3141,7 @@ function useAgnoComponents() {
1831
3141
  setIsLoading(false);
1832
3142
  }
1833
3143
  }, [client]);
1834
- const updateComponent = import_react15.useCallback(async (componentId, request, options) => {
3144
+ const updateComponent = import_react21.useCallback(async (componentId, request, options) => {
1835
3145
  setIsLoading(true);
1836
3146
  setError(undefined);
1837
3147
  try {
@@ -1844,7 +3154,7 @@ function useAgnoComponents() {
1844
3154
  setIsLoading(false);
1845
3155
  }
1846
3156
  }, [client]);
1847
- const deleteComponent = import_react15.useCallback(async (componentId, options) => {
3157
+ const deleteComponent = import_react21.useCallback(async (componentId, options) => {
1848
3158
  setIsLoading(true);
1849
3159
  setError(undefined);
1850
3160
  try {
@@ -1857,7 +3167,7 @@ function useAgnoComponents() {
1857
3167
  setIsLoading(false);
1858
3168
  }
1859
3169
  }, [client]);
1860
- const fetchComponentConfigs = import_react15.useCallback(async (componentId, options) => {
3170
+ const fetchComponentConfigs = import_react21.useCallback(async (componentId, options) => {
1861
3171
  setIsLoading(true);
1862
3172
  setError(undefined);
1863
3173
  try {
@@ -1870,7 +3180,7 @@ function useAgnoComponents() {
1870
3180
  setIsLoading(false);
1871
3181
  }
1872
3182
  }, [client]);
1873
- const createComponentConfig = import_react15.useCallback(async (componentId, request, options) => {
3183
+ const createComponentConfig = import_react21.useCallback(async (componentId, request, options) => {
1874
3184
  setIsLoading(true);
1875
3185
  setError(undefined);
1876
3186
  try {
@@ -1883,7 +3193,7 @@ function useAgnoComponents() {
1883
3193
  setIsLoading(false);
1884
3194
  }
1885
3195
  }, [client]);
1886
- const getCurrentComponentConfig = import_react15.useCallback(async (componentId, options) => {
3196
+ const getCurrentComponentConfig = import_react21.useCallback(async (componentId, options) => {
1887
3197
  setIsLoading(true);
1888
3198
  setError(undefined);
1889
3199
  try {
@@ -1896,7 +3206,7 @@ function useAgnoComponents() {
1896
3206
  setIsLoading(false);
1897
3207
  }
1898
3208
  }, [client]);
1899
- const getComponentConfigByVersion = import_react15.useCallback(async (componentId, version, options) => {
3209
+ const getComponentConfigByVersion = import_react21.useCallback(async (componentId, version, options) => {
1900
3210
  setIsLoading(true);
1901
3211
  setError(undefined);
1902
3212
  try {
@@ -1909,7 +3219,7 @@ function useAgnoComponents() {
1909
3219
  setIsLoading(false);
1910
3220
  }
1911
3221
  }, [client]);
1912
- const updateComponentConfig = import_react15.useCallback(async (componentId, version, request, options) => {
3222
+ const updateComponentConfig = import_react21.useCallback(async (componentId, version, request, options) => {
1913
3223
  setIsLoading(true);
1914
3224
  setError(undefined);
1915
3225
  try {
@@ -1922,7 +3232,7 @@ function useAgnoComponents() {
1922
3232
  setIsLoading(false);
1923
3233
  }
1924
3234
  }, [client]);
1925
- const deleteComponentConfig = import_react15.useCallback(async (componentId, version, options) => {
3235
+ const deleteComponentConfig = import_react21.useCallback(async (componentId, version, options) => {
1926
3236
  setIsLoading(true);
1927
3237
  setError(undefined);
1928
3238
  try {
@@ -1935,7 +3245,7 @@ function useAgnoComponents() {
1935
3245
  setIsLoading(false);
1936
3246
  }
1937
3247
  }, [client]);
1938
- const setCurrentComponentConfig = import_react15.useCallback(async (componentId, version, options) => {
3248
+ const setCurrentComponentConfig = import_react21.useCallback(async (componentId, version, options) => {
1939
3249
  setIsLoading(true);
1940
3250
  setError(undefined);
1941
3251
  try {
@@ -1967,4 +3277,4 @@ function useAgnoComponents() {
1967
3277
  };
1968
3278
  }
1969
3279
 
1970
- //# debugId=D27FED2F9BD03ABF64756E2164756E21
3280
+ //# debugId=6A9B00E27FD63EE064756E2164756E21