@rodrigocoliveira/agno-react 1.0.2 → 1.0.3

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 (159) hide show
  1. package/README.md +2 -2
  2. package/dist/components/GenerativeUIRenderer.d.ts +21 -0
  3. package/dist/components/GenerativeUIRenderer.d.ts.map +1 -0
  4. package/dist/context/AgnoContext.d.ts +16 -0
  5. package/dist/context/AgnoContext.d.ts.map +1 -0
  6. package/dist/context/ToolHandlerContext.d.ts +44 -0
  7. package/dist/context/ToolHandlerContext.d.ts.map +1 -0
  8. package/dist/hooks/useAgnoActions.d.ts +25 -0
  9. package/dist/hooks/useAgnoActions.d.ts.map +1 -0
  10. package/dist/hooks/useAgnoChat.d.ts +22 -0
  11. package/dist/hooks/useAgnoChat.d.ts.map +1 -0
  12. package/dist/hooks/useAgnoCustomEvents.d.ts +38 -0
  13. package/dist/hooks/useAgnoCustomEvents.d.ts.map +1 -0
  14. package/dist/hooks/useAgnoEvals.d.ts +39 -0
  15. package/dist/hooks/useAgnoEvals.d.ts.map +1 -0
  16. package/dist/hooks/useAgnoKnowledge.d.ts +56 -0
  17. package/dist/hooks/useAgnoKnowledge.d.ts.map +1 -0
  18. package/dist/hooks/useAgnoMemory.d.ts +42 -0
  19. package/dist/hooks/useAgnoMemory.d.ts.map +1 -0
  20. package/dist/hooks/useAgnoMetrics.d.ts +51 -0
  21. package/dist/hooks/useAgnoMetrics.d.ts.map +1 -0
  22. package/dist/hooks/useAgnoSession.d.ts +38 -0
  23. package/dist/hooks/useAgnoSession.d.ts.map +1 -0
  24. package/dist/hooks/useAgnoToolExecution.d.ts +70 -0
  25. package/dist/hooks/useAgnoToolExecution.d.ts.map +1 -0
  26. package/dist/hooks/useAgnoTraces.d.ts +51 -0
  27. package/dist/hooks/useAgnoTraces.d.ts.map +1 -0
  28. package/dist/index.d.ts +27 -723
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +932 -1052
  31. package/dist/index.js.map +24 -0
  32. package/dist/index.mjs +816 -909
  33. package/dist/index.mjs.map +24 -0
  34. package/dist/ui/components/artifact.d.ts +24 -0
  35. package/dist/ui/components/artifact.d.ts.map +1 -0
  36. package/dist/ui/components/audio-recorder.d.ts +32 -0
  37. package/dist/ui/components/audio-recorder.d.ts.map +1 -0
  38. package/dist/ui/components/code-block.d.ts +15 -0
  39. package/dist/ui/components/code-block.d.ts.map +1 -0
  40. package/dist/ui/components/conversation.d.ts +17 -0
  41. package/dist/ui/components/conversation.d.ts.map +1 -0
  42. package/dist/ui/components/file-preview-card.d.ts +13 -0
  43. package/dist/ui/components/file-preview-card.d.ts.map +1 -0
  44. package/dist/ui/components/file-preview-modal.d.ts +8 -0
  45. package/dist/ui/components/file-preview-modal.d.ts.map +1 -0
  46. package/dist/ui/components/image-lightbox.d.ts +12 -0
  47. package/dist/ui/components/image-lightbox.d.ts.map +1 -0
  48. package/dist/ui/components/message.d.ts +19 -0
  49. package/dist/ui/components/message.d.ts.map +1 -0
  50. package/dist/ui/components/prompt-input/attachments.d.ts +21 -0
  51. package/dist/ui/components/prompt-input/attachments.d.ts.map +1 -0
  52. package/dist/ui/components/prompt-input/buttons.d.ts +19 -0
  53. package/dist/ui/components/prompt-input/buttons.d.ts.map +1 -0
  54. package/dist/ui/components/prompt-input/command.d.ts +17 -0
  55. package/dist/ui/components/prompt-input/command.d.ts.map +1 -0
  56. package/dist/ui/components/prompt-input/context.d.ts +36 -0
  57. package/dist/ui/components/prompt-input/context.d.ts.map +1 -0
  58. package/dist/ui/components/prompt-input/drop-zone.d.ts +7 -0
  59. package/dist/ui/components/prompt-input/drop-zone.d.ts.map +1 -0
  60. package/dist/ui/components/prompt-input/footer.d.ts +11 -0
  61. package/dist/ui/components/prompt-input/footer.d.ts.map +1 -0
  62. package/dist/ui/components/prompt-input/index.d.ts +25 -0
  63. package/dist/ui/components/prompt-input/index.d.ts.map +1 -0
  64. package/dist/ui/components/prompt-input/model-select.d.ts +13 -0
  65. package/dist/ui/components/prompt-input/model-select.d.ts.map +1 -0
  66. package/dist/ui/components/prompt-input/prompt-input.d.ts +22 -0
  67. package/dist/ui/components/prompt-input/prompt-input.d.ts.map +1 -0
  68. package/dist/ui/components/prompt-input/provider.d.ts +6 -0
  69. package/dist/ui/components/prompt-input/provider.d.ts.map +1 -0
  70. package/dist/ui/components/prompt-input/speech.d.ts +51 -0
  71. package/dist/ui/components/prompt-input/speech.d.ts.map +1 -0
  72. package/dist/ui/components/prompt-input/tabs.d.ts +12 -0
  73. package/dist/ui/components/prompt-input/tabs.d.ts.map +1 -0
  74. package/dist/ui/components/prompt-input/textarea.d.ts +5 -0
  75. package/dist/ui/components/prompt-input/textarea.d.ts.map +1 -0
  76. package/dist/ui/components/response.d.ts +5 -0
  77. package/dist/ui/components/response.d.ts.map +1 -0
  78. package/dist/ui/components/smart-timestamp.d.ts +8 -0
  79. package/dist/ui/components/smart-timestamp.d.ts.map +1 -0
  80. package/dist/ui/components/streaming-indicator.d.ts +8 -0
  81. package/dist/ui/components/streaming-indicator.d.ts.map +1 -0
  82. package/dist/ui/components/tool.d.ts +24 -0
  83. package/dist/ui/components/tool.d.ts.map +1 -0
  84. package/dist/ui/composed/AgnoChatInput.d.ts +44 -0
  85. package/dist/ui/composed/AgnoChatInput.d.ts.map +1 -0
  86. package/dist/ui/composed/AgnoChatInterface.d.ts +49 -0
  87. package/dist/ui/composed/AgnoChatInterface.d.ts.map +1 -0
  88. package/dist/ui/composed/AgnoMessageItem.d.ts +38 -0
  89. package/dist/ui/composed/AgnoMessageItem.d.ts.map +1 -0
  90. package/dist/ui/composed/agno-chat/agno-chat.d.ts +9 -0
  91. package/dist/ui/composed/agno-chat/agno-chat.d.ts.map +1 -0
  92. package/dist/ui/composed/agno-chat/context.d.ts +33 -0
  93. package/dist/ui/composed/agno-chat/context.d.ts.map +1 -0
  94. package/dist/ui/composed/agno-chat/empty-state.d.ts +6 -0
  95. package/dist/ui/composed/agno-chat/empty-state.d.ts.map +1 -0
  96. package/dist/ui/composed/agno-chat/error-bar.d.ts +5 -0
  97. package/dist/ui/composed/agno-chat/error-bar.d.ts.map +1 -0
  98. package/dist/ui/composed/agno-chat/index.d.ts +33 -0
  99. package/dist/ui/composed/agno-chat/index.d.ts.map +1 -0
  100. package/dist/ui/composed/agno-chat/input.d.ts +39 -0
  101. package/dist/ui/composed/agno-chat/input.d.ts.map +1 -0
  102. package/dist/ui/composed/agno-chat/messages.d.ts +21 -0
  103. package/dist/ui/composed/agno-chat/messages.d.ts.map +1 -0
  104. package/dist/ui/composed/agno-chat/suggested-prompts.d.ts +7 -0
  105. package/dist/ui/composed/agno-chat/suggested-prompts.d.ts.map +1 -0
  106. package/dist/ui/composed/agno-chat/tool-status.d.ts +5 -0
  107. package/dist/ui/composed/agno-chat/tool-status.d.ts.map +1 -0
  108. package/dist/ui/composed/index.d.ts +9 -0
  109. package/dist/ui/composed/index.d.ts.map +1 -0
  110. package/dist/ui/index.d.ts +59 -0
  111. package/dist/ui/index.d.ts.map +1 -0
  112. package/dist/ui/lib/cn.d.ts +3 -0
  113. package/dist/ui/lib/cn.d.ts.map +1 -0
  114. package/dist/ui/lib/file-utils.d.ts +20 -0
  115. package/dist/ui/lib/file-utils.d.ts.map +1 -0
  116. package/dist/ui/lib/format-timestamp.d.ts +16 -0
  117. package/dist/ui/lib/format-timestamp.d.ts.map +1 -0
  118. package/dist/ui/primitives/accordion.d.ts +8 -0
  119. package/dist/ui/primitives/accordion.d.ts.map +1 -0
  120. package/dist/ui/primitives/avatar.d.ts +7 -0
  121. package/dist/ui/primitives/avatar.d.ts.map +1 -0
  122. package/dist/ui/primitives/badge.d.ts +10 -0
  123. package/dist/ui/primitives/badge.d.ts.map +1 -0
  124. package/dist/ui/primitives/button.d.ts +12 -0
  125. package/dist/ui/primitives/button.d.ts.map +1 -0
  126. package/dist/ui/primitives/collapsible.d.ts +6 -0
  127. package/dist/ui/primitives/collapsible.d.ts.map +1 -0
  128. package/dist/ui/primitives/command.d.ts +79 -0
  129. package/dist/ui/primitives/command.d.ts.map +1 -0
  130. package/dist/ui/primitives/dialog.d.ts +26 -0
  131. package/dist/ui/primitives/dialog.d.ts.map +1 -0
  132. package/dist/ui/primitives/dropdown-menu.d.ts +28 -0
  133. package/dist/ui/primitives/dropdown-menu.d.ts.map +1 -0
  134. package/dist/ui/primitives/hover-card.d.ts +7 -0
  135. package/dist/ui/primitives/hover-card.d.ts.map +1 -0
  136. package/dist/ui/primitives/index.d.ts +16 -0
  137. package/dist/ui/primitives/index.d.ts.map +1 -0
  138. package/dist/ui/primitives/input-group.d.ts +17 -0
  139. package/dist/ui/primitives/input-group.d.ts.map +1 -0
  140. package/dist/ui/primitives/select.d.ts +14 -0
  141. package/dist/ui/primitives/select.d.ts.map +1 -0
  142. package/dist/ui/primitives/tooltip.d.ts +8 -0
  143. package/dist/ui/primitives/tooltip.d.ts.map +1 -0
  144. package/dist/ui/types.d.ts +56 -0
  145. package/dist/ui/types.d.ts.map +1 -0
  146. package/dist/ui.d.ts +2 -891
  147. package/dist/ui.d.ts.map +1 -0
  148. package/dist/ui.js +2757 -2323
  149. package/dist/ui.js.map +60 -0
  150. package/dist/ui.mjs +2644 -2055
  151. package/dist/ui.mjs.map +60 -0
  152. package/dist/utils/component-registry.d.ts +63 -0
  153. package/dist/utils/component-registry.d.ts.map +1 -0
  154. package/dist/utils/ui-helpers.d.ts +165 -0
  155. package/dist/utils/ui-helpers.d.ts.map +1 -0
  156. package/package.json +9 -10
  157. package/LICENSE +0 -21
  158. package/dist/index.d.mts +0 -724
  159. package/dist/ui.d.mts +0 -891
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  // src/context/AgnoContext.tsx
2
2
  import { createContext, useContext, useMemo, useEffect } from "react";
3
3
  import { AgnoClient } from "@rodrigocoliveira/agno-client";
4
- import { jsx } from "react/jsx-runtime";
4
+ import { jsxDEV } from "react/jsx-dev-runtime";
5
5
  var AgnoContext = createContext(null);
6
6
  function AgnoProvider({ config, children }) {
7
7
  const client = useMemo(() => new AgnoClient(config), []);
@@ -13,7 +13,10 @@ function AgnoProvider({ config, children }) {
13
13
  client.removeAllListeners();
14
14
  };
15
15
  }, [client]);
16
- return /* @__PURE__ */ jsx(AgnoContext.Provider, { value: client, children });
16
+ return /* @__PURE__ */ jsxDEV(AgnoContext.Provider, {
17
+ value: client,
18
+ children
19
+ }, undefined, false, undefined, this);
17
20
  }
18
21
  function useAgnoClient() {
19
22
  const client = useContext(AgnoContext);
@@ -22,10 +25,9 @@ function useAgnoClient() {
22
25
  }
23
26
  return client;
24
27
  }
25
-
26
28
  // src/context/ToolHandlerContext.tsx
27
29
  import { createContext as createContext2, useContext as useContext2, useState, useCallback } from "react";
28
- import { jsx as jsx2 } from "react/jsx-runtime";
30
+ import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
29
31
  var ToolHandlerContext = createContext2(null);
30
32
  function ToolHandlerProvider({ handlers: initialHandlers = {}, children }) {
31
33
  const [handlers, setHandlers] = useState(initialHandlers);
@@ -43,74 +45,52 @@ function ToolHandlerProvider({ handlers: initialHandlers = {}, children }) {
43
45
  registerHandler,
44
46
  unregisterHandler
45
47
  };
46
- return /* @__PURE__ */ jsx2(ToolHandlerContext.Provider, { value, children });
48
+ return /* @__PURE__ */ jsxDEV2(ToolHandlerContext.Provider, {
49
+ value,
50
+ children
51
+ }, undefined, false, undefined, this);
47
52
  }
48
53
  function useToolHandlers() {
49
54
  return useContext2(ToolHandlerContext);
50
55
  }
51
-
52
56
  // src/components/GenerativeUIRenderer.tsx
53
57
  import React3 from "react";
54
58
 
55
59
  // src/utils/component-registry.ts
56
- var ComponentRegistry = class _ComponentRegistry {
57
- constructor() {
58
- this.components = /* @__PURE__ */ new Map();
59
- }
60
- /**
61
- * Get the singleton instance
62
- */
60
+ class ComponentRegistry {
61
+ static instance;
62
+ components = new Map;
63
+ constructor() {}
63
64
  static getInstance() {
64
- if (!_ComponentRegistry.instance) {
65
- _ComponentRegistry.instance = new _ComponentRegistry();
65
+ if (!ComponentRegistry.instance) {
66
+ ComponentRegistry.instance = new ComponentRegistry;
66
67
  }
67
- return _ComponentRegistry.instance;
68
+ return ComponentRegistry.instance;
68
69
  }
69
- /**
70
- * Register a component renderer
71
- */
72
70
  register(type, renderer) {
73
71
  this.components.set(type, renderer);
74
72
  }
75
- /**
76
- * Register multiple components at once
77
- */
78
73
  registerBatch(components) {
79
74
  Object.entries(components).forEach(([type, renderer]) => {
80
75
  this.register(type, renderer);
81
76
  });
82
77
  }
83
- /**
84
- * Get a registered component renderer
85
- */
86
78
  get(type) {
87
79
  return this.components.get(type);
88
80
  }
89
- /**
90
- * Check if a component is registered
91
- */
92
81
  has(type) {
93
82
  return this.components.has(type);
94
83
  }
95
- /**
96
- * Unregister a component
97
- */
98
84
  unregister(type) {
99
85
  this.components.delete(type);
100
86
  }
101
- /**
102
- * Get all registered component types
103
- */
104
87
  getRegisteredTypes() {
105
88
  return Array.from(this.components.keys());
106
89
  }
107
- /**
108
- * Clear all registered components
109
- */
110
90
  clear() {
111
91
  this.components.clear();
112
92
  }
113
- };
93
+ }
114
94
  function getComponentRegistry() {
115
95
  return ComponentRegistry.getInstance();
116
96
  }
@@ -123,7 +103,7 @@ function getChartComponent(name) {
123
103
 
124
104
  // src/hooks/useAgnoToolExecution.ts
125
105
  import { useState as useState2, useEffect as useEffect2, useCallback as useCallback2, useMemo as useMemo2 } from "react";
126
- var customRenderRegistry = /* @__PURE__ */ new Map();
106
+ var customRenderRegistry = new Map;
127
107
  function registerCustomRender(renderFn) {
128
108
  const key = `custom-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
129
109
  customRenderRegistry.set(key, renderFn);
@@ -133,7 +113,7 @@ function getCustomRender(key) {
133
113
  return customRenderRegistry.get(key);
134
114
  }
135
115
  function isToolHandlerResult(value) {
136
- return value && typeof value === "object" && ("data" in value || "ui" in value);
116
+ return value && typeof value === "object" && (("data" in value) || ("ui" in value));
137
117
  }
138
118
  function isUIComponentSpec(value) {
139
119
  return value && typeof value === "object" && "type" in value;
@@ -141,15 +121,14 @@ function isUIComponentSpec(value) {
141
121
  function processToolResult(result, _tool) {
142
122
  if (isToolHandlerResult(result)) {
143
123
  const { data, ui } = result;
144
- let uiComponent = void 0;
124
+ let uiComponent = undefined;
145
125
  if (ui) {
146
126
  if (ui.type === "custom" && typeof ui.render === "function") {
147
127
  const renderKey = registerCustomRender(ui.render);
148
128
  uiComponent = {
149
129
  ...ui,
150
130
  renderKey,
151
- render: void 0
152
- // Don't store the function itself
131
+ render: undefined
153
132
  };
154
133
  } else {
155
134
  uiComponent = ui;
@@ -167,7 +146,7 @@ function processToolResult(result, _tool) {
167
146
  uiComponent = {
168
147
  ...result,
169
148
  renderKey,
170
- render: void 0
149
+ render: undefined
171
150
  };
172
151
  } else {
173
152
  uiComponent = result;
@@ -179,7 +158,7 @@ function processToolResult(result, _tool) {
179
158
  }
180
159
  return {
181
160
  resultData: typeof result === "string" ? result : JSON.stringify(result),
182
- uiComponent: void 0
161
+ uiComponent: undefined
183
162
  };
184
163
  }
185
164
  function useAgnoToolExecution(handlers = {}, autoExecute = true) {
@@ -188,9 +167,7 @@ function useAgnoToolExecution(handlers = {}, autoExecute = true) {
188
167
  const isTeamMode = client.getConfig().mode === "team";
189
168
  useEffect2(() => {
190
169
  if (isTeamMode) {
191
- console.warn(
192
- "[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."
193
- );
170
+ 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.");
194
171
  }
195
172
  }, [isTeamMode]);
196
173
  const mergedHandlers = useMemo2(() => {
@@ -208,13 +185,13 @@ function useAgnoToolExecution(handlers = {}, autoExecute = true) {
208
185
  const handleRunPaused = (event) => {
209
186
  setIsPaused(true);
210
187
  setPendingTools(event.tools);
211
- setExecutionError(void 0);
188
+ setExecutionError(undefined);
212
189
  };
213
190
  const handleRunContinued = () => {
214
191
  setIsPaused(false);
215
192
  setPendingTools([]);
216
193
  setIsExecuting(false);
217
- setExecutionError(void 0);
194
+ setExecutionError(undefined);
218
195
  };
219
196
  client.on("run:paused", handleRunPaused);
220
197
  client.on("run:continued", handleRunContinued);
@@ -229,37 +206,35 @@ function useAgnoToolExecution(handlers = {}, autoExecute = true) {
229
206
  return;
230
207
  }
231
208
  setIsExecuting(true);
232
- setExecutionError(void 0);
209
+ setExecutionError(undefined);
233
210
  try {
234
- const updatedTools = await Promise.all(
235
- pendingTools.map(async (tool) => {
236
- const handler = mergedHandlers[tool.tool_name];
237
- if (!handler) {
238
- return {
239
- ...tool,
240
- result: JSON.stringify({
241
- error: `No handler registered for ${tool.tool_name}`
242
- })
243
- };
244
- }
245
- try {
246
- const result = await handler(tool.tool_args);
247
- const { resultData, uiComponent } = processToolResult(result, tool);
248
- return {
249
- ...tool,
250
- result: resultData,
251
- ui_component: uiComponent
252
- };
253
- } catch (error) {
254
- return {
255
- ...tool,
256
- result: JSON.stringify({
257
- error: error instanceof Error ? error.message : String(error)
258
- })
259
- };
260
- }
261
- })
262
- );
211
+ const updatedTools = await Promise.all(pendingTools.map(async (tool) => {
212
+ const handler = mergedHandlers[tool.tool_name];
213
+ if (!handler) {
214
+ return {
215
+ ...tool,
216
+ result: JSON.stringify({
217
+ error: `No handler registered for ${tool.tool_name}`
218
+ })
219
+ };
220
+ }
221
+ try {
222
+ const result = await handler(tool.tool_args);
223
+ const { resultData, uiComponent } = processToolResult(result, tool);
224
+ return {
225
+ ...tool,
226
+ result: resultData,
227
+ ui_component: uiComponent
228
+ };
229
+ } catch (error) {
230
+ return {
231
+ ...tool,
232
+ result: JSON.stringify({
233
+ error: error instanceof Error ? error.message : String(error)
234
+ })
235
+ };
236
+ }
237
+ }));
263
238
  const toolsWithUI = updatedTools.filter((t) => t.ui_component);
264
239
  if (toolsWithUI.length > 0) {
265
240
  client.emit("ui:render", {
@@ -280,11 +255,14 @@ function useAgnoToolExecution(handlers = {}, autoExecute = true) {
280
255
  const handleSessionLoaded = async (_sessionId) => {
281
256
  const messages = client.getMessages();
282
257
  for (const message of messages) {
283
- if (!message.tool_calls) continue;
258
+ if (!message.tool_calls)
259
+ continue;
284
260
  for (const tool of message.tool_calls) {
285
- if (tool.ui_component) continue;
261
+ if (tool.ui_component)
262
+ continue;
286
263
  const handler = mergedHandlers[tool.tool_name];
287
- if (!handler) continue;
264
+ if (!handler)
265
+ continue;
288
266
  try {
289
267
  const result = await handler(tool.tool_args);
290
268
  const { uiComponent } = processToolResult(result, tool);
@@ -302,74 +280,61 @@ function useAgnoToolExecution(handlers = {}, autoExecute = true) {
302
280
  client.off("session:loaded", handleSessionLoaded);
303
281
  };
304
282
  }, [client, mergedHandlers]);
305
- const executeTools = useCallback2(
306
- async (tools) => {
307
- return Promise.all(
308
- tools.map(async (tool) => {
309
- const handler = mergedHandlers[tool.tool_name];
310
- if (!handler) return tool;
311
- try {
312
- const result = await handler(tool.tool_args);
313
- const { resultData, uiComponent } = processToolResult(result, tool);
314
- return {
315
- ...tool,
316
- result: resultData,
317
- ui_component: uiComponent
318
- };
319
- } catch (error) {
320
- return {
321
- ...tool,
322
- result: JSON.stringify({
323
- error: error instanceof Error ? error.message : String(error)
324
- })
325
- };
326
- }
327
- })
328
- );
329
- },
330
- [mergedHandlers]
331
- );
332
- const continueWithResults = useCallback2(
333
- async (tools, options) => {
334
- if (!isPaused) {
335
- throw new Error("No paused run to continue");
336
- }
337
- setIsExecuting(true);
283
+ const executeTools = useCallback2(async (tools) => {
284
+ return Promise.all(tools.map(async (tool) => {
285
+ const handler = mergedHandlers[tool.tool_name];
286
+ if (!handler)
287
+ return tool;
338
288
  try {
339
- await client.continueRun(tools, options);
289
+ const result = await handler(tool.tool_args);
290
+ const { resultData, uiComponent } = processToolResult(result, tool);
291
+ return {
292
+ ...tool,
293
+ result: resultData,
294
+ ui_component: uiComponent
295
+ };
340
296
  } catch (error) {
341
- setIsExecuting(false);
342
- throw error;
297
+ return {
298
+ ...tool,
299
+ result: JSON.stringify({
300
+ error: error instanceof Error ? error.message : String(error)
301
+ })
302
+ };
343
303
  }
344
- },
345
- [client, isPaused]
346
- );
304
+ }));
305
+ }, [mergedHandlers]);
306
+ const continueWithResults = useCallback2(async (tools, options) => {
307
+ if (!isPaused) {
308
+ throw new Error("No paused run to continue");
309
+ }
310
+ setIsExecuting(true);
311
+ try {
312
+ await client.continueRun(tools, options);
313
+ } catch (error) {
314
+ setIsExecuting(false);
315
+ throw error;
316
+ }
317
+ }, [client, isPaused]);
347
318
  useEffect2(() => {
348
319
  if (autoExecute && isPaused && !isExecuting && pendingTools.length > 0) {
349
320
  executeAndContinue();
350
321
  }
351
322
  }, [autoExecute, isPaused, isExecuting, pendingTools.length, executeAndContinue]);
352
323
  return {
353
- /** Whether the run is currently paused awaiting tool execution */
354
324
  isPaused,
355
- /** Whether tools are currently being executed */
356
325
  isExecuting,
357
- /** Tools awaiting execution */
358
326
  pendingTools,
359
- /** Execute all pending tools and continue the run */
360
327
  executeAndContinue,
361
- /** Execute specific tools and return results without continuing */
362
328
  executeTools,
363
- /** Continue the run with manually provided tool results */
364
329
  continueWithResults,
365
- /** Error from tool execution, if any */
366
330
  executionError
367
331
  };
368
332
  }
369
333
 
370
334
  // src/components/GenerativeUIRenderer.tsx
371
- import { jsx as jsx3, jsxs } from "react/jsx-runtime";
372
- var UIErrorBoundary = class extends React3.Component {
335
+ import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
336
+
337
+ class UIErrorBoundary extends React3.Component {
373
338
  constructor(props) {
374
339
  super(props);
375
340
  this.state = { hasError: false };
@@ -383,14 +348,23 @@ var UIErrorBoundary = class extends React3.Component {
383
348
  }
384
349
  render() {
385
350
  if (this.state.hasError) {
386
- return this.props.fallback || /* @__PURE__ */ jsxs("div", { className: "p-4 border border-red-300 rounded-md bg-red-50 text-red-800", children: [
387
- /* @__PURE__ */ jsx3("p", { className: "font-semibold", children: "Failed to render UI component" }),
388
- /* @__PURE__ */ jsx3("p", { className: "text-sm mt-1", children: this.state.error?.message || "Unknown error" })
389
- ] });
351
+ return this.props.fallback || /* @__PURE__ */ jsxDEV3("div", {
352
+ className: "p-4 border border-red-300 rounded-md bg-red-50 text-red-800",
353
+ children: [
354
+ /* @__PURE__ */ jsxDEV3("p", {
355
+ className: "font-semibold",
356
+ children: "Failed to render UI component"
357
+ }, undefined, false, undefined, this),
358
+ /* @__PURE__ */ jsxDEV3("p", {
359
+ className: "text-sm mt-1",
360
+ children: this.state.error?.message || "Unknown error"
361
+ }, undefined, false, undefined, this)
362
+ ]
363
+ }, undefined, true, undefined, this);
390
364
  }
391
365
  return this.props.children;
392
366
  }
393
- };
367
+ }
394
368
  function GenerativeUIRenderer({
395
369
  spec,
396
370
  className,
@@ -402,78 +376,184 @@ function GenerativeUIRenderer({
402
376
  if (customSpec.renderKey) {
403
377
  const renderFn = getCustomRender(customSpec.renderKey);
404
378
  if (renderFn) {
405
- return /* @__PURE__ */ jsx3(UIErrorBoundary, { onError, children: /* @__PURE__ */ jsx3("div", { className, children: renderFn(customSpec.props || {}) }) });
379
+ return /* @__PURE__ */ jsxDEV3(UIErrorBoundary, {
380
+ onError,
381
+ children: /* @__PURE__ */ jsxDEV3("div", {
382
+ className,
383
+ children: renderFn(customSpec.props || {})
384
+ }, undefined, false, undefined, this)
385
+ }, undefined, false, undefined, this);
406
386
  }
407
387
  }
408
- return /* @__PURE__ */ jsxs("div", { className: `p-4 border border-yellow-300 rounded-md bg-yellow-50 text-yellow-800 ${className || ""}`, children: [
409
- /* @__PURE__ */ jsx3("p", { className: "font-semibold", children: "Custom component not available" }),
410
- /* @__PURE__ */ jsx3("p", { className: "text-sm mt-1", children: "The custom render function for this component is not available." })
411
- ] });
388
+ return /* @__PURE__ */ jsxDEV3("div", {
389
+ className: `p-4 border border-yellow-300 rounded-md bg-yellow-50 text-yellow-800 ${className || ""}`,
390
+ children: [
391
+ /* @__PURE__ */ jsxDEV3("p", {
392
+ className: "font-semibold",
393
+ children: "Custom component not available"
394
+ }, undefined, false, undefined, this),
395
+ /* @__PURE__ */ jsxDEV3("p", {
396
+ className: "text-sm mt-1",
397
+ children: "The custom render function for this component is not available."
398
+ }, undefined, false, undefined, this)
399
+ ]
400
+ }, undefined, true, undefined, this);
412
401
  }
413
402
  if (spec.type === "chart") {
414
403
  const chartSpec = spec;
415
404
  const chartType = `chart:${chartSpec.component}`;
416
405
  if (registry.has(chartType)) {
417
406
  const ChartRenderer = registry.get(chartType);
418
- return /* @__PURE__ */ jsx3(UIErrorBoundary, { onError, children: /* @__PURE__ */ jsxs("div", { className, children: [
419
- chartSpec.title && /* @__PURE__ */ jsx3("h3", { className: "font-semibold mb-2", children: chartSpec.title }),
420
- chartSpec.description && /* @__PURE__ */ jsx3("p", { className: "text-sm text-gray-600 mb-4", children: chartSpec.description }),
421
- /* @__PURE__ */ jsx3(ChartRenderer, { ...chartSpec.props })
422
- ] }) });
423
- }
424
- return /* @__PURE__ */ jsxs("div", { className: `p-4 border border-gray-300 rounded-md ${className || ""}`, children: [
425
- /* @__PURE__ */ jsx3("p", { className: "font-semibold mb-2", children: chartSpec.title || "Chart Data" }),
426
- chartSpec.description && /* @__PURE__ */ jsx3("p", { className: "text-sm text-gray-600 mb-2", children: chartSpec.description }),
427
- /* @__PURE__ */ jsx3("pre", { className: "text-xs bg-gray-100 p-2 rounded overflow-auto", children: JSON.stringify(chartSpec.props.data, null, 2) })
428
- ] });
407
+ return /* @__PURE__ */ jsxDEV3(UIErrorBoundary, {
408
+ onError,
409
+ children: /* @__PURE__ */ jsxDEV3("div", {
410
+ className,
411
+ children: [
412
+ chartSpec.title && /* @__PURE__ */ jsxDEV3("h3", {
413
+ className: "font-semibold mb-2",
414
+ children: chartSpec.title
415
+ }, undefined, false, undefined, this),
416
+ chartSpec.description && /* @__PURE__ */ jsxDEV3("p", {
417
+ className: "text-sm text-gray-600 mb-4",
418
+ children: chartSpec.description
419
+ }, undefined, false, undefined, this),
420
+ /* @__PURE__ */ jsxDEV3(ChartRenderer, {
421
+ ...chartSpec.props
422
+ }, undefined, false, undefined, this)
423
+ ]
424
+ }, undefined, true, undefined, this)
425
+ }, undefined, false, undefined, this);
426
+ }
427
+ return /* @__PURE__ */ jsxDEV3("div", {
428
+ className: `p-4 border border-gray-300 rounded-md ${className || ""}`,
429
+ children: [
430
+ /* @__PURE__ */ jsxDEV3("p", {
431
+ className: "font-semibold mb-2",
432
+ children: chartSpec.title || "Chart Data"
433
+ }, undefined, false, undefined, this),
434
+ chartSpec.description && /* @__PURE__ */ jsxDEV3("p", {
435
+ className: "text-sm text-gray-600 mb-2",
436
+ children: chartSpec.description
437
+ }, undefined, false, undefined, this),
438
+ /* @__PURE__ */ jsxDEV3("pre", {
439
+ className: "text-xs bg-gray-100 p-2 rounded overflow-auto",
440
+ children: JSON.stringify(chartSpec.props.data, null, 2)
441
+ }, undefined, false, undefined, this)
442
+ ]
443
+ }, undefined, true, undefined, this);
429
444
  }
430
445
  if (spec.type === "card-grid") {
431
446
  const cardGridSpec = spec;
432
447
  if (registry.has("card-grid")) {
433
448
  const CardGridRenderer = registry.get("card-grid");
434
- return /* @__PURE__ */ jsx3(UIErrorBoundary, { onError, children: /* @__PURE__ */ jsxs("div", { className, children: [
435
- cardGridSpec.title && /* @__PURE__ */ jsx3("h3", { className: "font-semibold mb-2", children: cardGridSpec.title }),
436
- cardGridSpec.description && /* @__PURE__ */ jsx3("p", { className: "text-sm text-gray-600 mb-4", children: cardGridSpec.description }),
437
- /* @__PURE__ */ jsx3(CardGridRenderer, { ...cardGridSpec.props })
438
- ] }) });
449
+ return /* @__PURE__ */ jsxDEV3(UIErrorBoundary, {
450
+ onError,
451
+ children: /* @__PURE__ */ jsxDEV3("div", {
452
+ className,
453
+ children: [
454
+ cardGridSpec.title && /* @__PURE__ */ jsxDEV3("h3", {
455
+ className: "font-semibold mb-2",
456
+ children: cardGridSpec.title
457
+ }, undefined, false, undefined, this),
458
+ cardGridSpec.description && /* @__PURE__ */ jsxDEV3("p", {
459
+ className: "text-sm text-gray-600 mb-4",
460
+ children: cardGridSpec.description
461
+ }, undefined, false, undefined, this),
462
+ /* @__PURE__ */ jsxDEV3(CardGridRenderer, {
463
+ ...cardGridSpec.props
464
+ }, undefined, false, undefined, this)
465
+ ]
466
+ }, undefined, true, undefined, this)
467
+ }, undefined, false, undefined, this);
439
468
  }
440
469
  }
441
470
  if (spec.type === "table") {
442
471
  const tableSpec = spec;
443
472
  if (registry.has("table")) {
444
473
  const TableRenderer = registry.get("table");
445
- return /* @__PURE__ */ jsx3(UIErrorBoundary, { onError, children: /* @__PURE__ */ jsxs("div", { className, children: [
446
- tableSpec.title && /* @__PURE__ */ jsx3("h3", { className: "font-semibold mb-2", children: tableSpec.title }),
447
- tableSpec.description && /* @__PURE__ */ jsx3("p", { className: "text-sm text-gray-600 mb-4", children: tableSpec.description }),
448
- /* @__PURE__ */ jsx3(TableRenderer, { ...tableSpec.props })
449
- ] }) });
474
+ return /* @__PURE__ */ jsxDEV3(UIErrorBoundary, {
475
+ onError,
476
+ children: /* @__PURE__ */ jsxDEV3("div", {
477
+ className,
478
+ children: [
479
+ tableSpec.title && /* @__PURE__ */ jsxDEV3("h3", {
480
+ className: "font-semibold mb-2",
481
+ children: tableSpec.title
482
+ }, undefined, false, undefined, this),
483
+ tableSpec.description && /* @__PURE__ */ jsxDEV3("p", {
484
+ className: "text-sm text-gray-600 mb-4",
485
+ children: tableSpec.description
486
+ }, undefined, false, undefined, this),
487
+ /* @__PURE__ */ jsxDEV3(TableRenderer, {
488
+ ...tableSpec.props
489
+ }, undefined, false, undefined, this)
490
+ ]
491
+ }, undefined, true, undefined, this)
492
+ }, undefined, false, undefined, this);
450
493
  }
451
494
  }
452
495
  if (spec.type === "markdown") {
453
496
  const markdownSpec = spec;
454
497
  if (registry.has("markdown")) {
455
498
  const MarkdownRenderer = registry.get("markdown");
456
- return /* @__PURE__ */ jsx3(UIErrorBoundary, { onError, children: /* @__PURE__ */ jsx3("div", { className, children: /* @__PURE__ */ jsx3(MarkdownRenderer, { ...markdownSpec.props }) }) });
499
+ return /* @__PURE__ */ jsxDEV3(UIErrorBoundary, {
500
+ onError,
501
+ children: /* @__PURE__ */ jsxDEV3("div", {
502
+ className,
503
+ children: /* @__PURE__ */ jsxDEV3(MarkdownRenderer, {
504
+ ...markdownSpec.props
505
+ }, undefined, false, undefined, this)
506
+ }, undefined, false, undefined, this)
507
+ }, undefined, false, undefined, this);
457
508
  }
458
- return /* @__PURE__ */ jsx3("div", { className, children: markdownSpec.props.content });
509
+ return /* @__PURE__ */ jsxDEV3("div", {
510
+ className,
511
+ children: markdownSpec.props.content
512
+ }, undefined, false, undefined, this);
459
513
  }
460
514
  if (spec.type === "artifact") {
461
515
  const artifactSpec = spec;
462
- return /* @__PURE__ */ jsx3(UIErrorBoundary, { onError, children: /* @__PURE__ */ jsxs("div", { className: `p-4 border rounded-md ${className || ""}`, children: [
463
- artifactSpec.title && /* @__PURE__ */ jsx3("h3", { className: "font-semibold mb-4", children: artifactSpec.title }),
464
- artifactSpec.description && /* @__PURE__ */ jsx3("p", { className: "text-sm text-gray-600 mb-4", children: artifactSpec.description }),
465
- /* @__PURE__ */ jsx3("div", { className: "space-y-4", children: artifactSpec.props.content?.map((childSpec, index) => /* @__PURE__ */ jsx3(GenerativeUIRenderer, { spec: childSpec, onError }, index)) })
466
- ] }) });
516
+ return /* @__PURE__ */ jsxDEV3(UIErrorBoundary, {
517
+ onError,
518
+ children: /* @__PURE__ */ jsxDEV3("div", {
519
+ className: `p-4 border rounded-md ${className || ""}`,
520
+ children: [
521
+ artifactSpec.title && /* @__PURE__ */ jsxDEV3("h3", {
522
+ className: "font-semibold mb-4",
523
+ children: artifactSpec.title
524
+ }, undefined, false, undefined, this),
525
+ artifactSpec.description && /* @__PURE__ */ jsxDEV3("p", {
526
+ className: "text-sm text-gray-600 mb-4",
527
+ children: artifactSpec.description
528
+ }, undefined, false, undefined, this),
529
+ /* @__PURE__ */ jsxDEV3("div", {
530
+ className: "space-y-4",
531
+ children: artifactSpec.props.content?.map((childSpec, index) => /* @__PURE__ */ jsxDEV3(GenerativeUIRenderer, {
532
+ spec: childSpec,
533
+ onError
534
+ }, index, false, undefined, this))
535
+ }, undefined, false, undefined, this)
536
+ ]
537
+ }, undefined, true, undefined, this)
538
+ }, undefined, false, undefined, this);
467
539
  }
468
- return /* @__PURE__ */ jsxs("div", { className: `p-4 border border-gray-300 rounded-md ${className || ""}`, children: [
469
- /* @__PURE__ */ jsx3("p", { className: "font-semibold", children: "Unsupported UI component" }),
470
- /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-600 mt-1", children: [
471
- "Component type: ",
472
- spec.type
473
- ] })
474
- ] });
540
+ return /* @__PURE__ */ jsxDEV3("div", {
541
+ className: `p-4 border border-gray-300 rounded-md ${className || ""}`,
542
+ children: [
543
+ /* @__PURE__ */ jsxDEV3("p", {
544
+ className: "font-semibold",
545
+ children: "Unsupported UI component"
546
+ }, undefined, false, undefined, this),
547
+ /* @__PURE__ */ jsxDEV3("p", {
548
+ className: "text-sm text-gray-600 mt-1",
549
+ children: [
550
+ "Component type: ",
551
+ spec.type
552
+ ]
553
+ }, undefined, true, undefined, this)
554
+ ]
555
+ }, undefined, true, undefined, this);
475
556
  }
476
-
477
557
  // src/utils/ui-helpers.ts
478
558
  function createBarChart(data, xKey, bars, options) {
479
559
  return {
@@ -639,34 +719,17 @@ function createSmartChart(data, options) {
639
719
  }
640
720
  const firstItem = data[0];
641
721
  const keys = Object.keys(firstItem);
642
- const xKey = options?.xKey || keys.find(
643
- (k) => ["name", "label", "category", "date", "time", "month", "year"].includes(k.toLowerCase())
644
- ) || keys[0];
722
+ const xKey = options?.xKey || keys.find((k) => ["name", "label", "category", "date", "time", "month", "year"].includes(k.toLowerCase())) || keys[0];
645
723
  const numericKeys = keys.filter((k) => k !== xKey && typeof firstItem[k] === "number");
646
724
  const yKeys = options?.yKeys || numericKeys;
647
725
  if (options?.preferredType) {
648
726
  switch (options.preferredType) {
649
727
  case "bar":
650
- return createBarChart(
651
- data,
652
- xKey,
653
- yKeys.map((key) => ({ key })),
654
- options
655
- );
728
+ return createBarChart(data, xKey, yKeys.map((key) => ({ key })), options);
656
729
  case "line":
657
- return createLineChart(
658
- data,
659
- xKey,
660
- yKeys.map((key) => ({ key })),
661
- options
662
- );
730
+ return createLineChart(data, xKey, yKeys.map((key) => ({ key })), options);
663
731
  case "area":
664
- return createAreaChart(
665
- data,
666
- xKey,
667
- yKeys.map((key) => ({ key })),
668
- options
669
- );
732
+ return createAreaChart(data, xKey, yKeys.map((key) => ({ key })), options);
670
733
  case "pie":
671
734
  return createPieChart(data, yKeys[0], xKey, options);
672
735
  }
@@ -675,19 +738,9 @@ function createSmartChart(data, options) {
675
738
  return createPieChart(data, yKeys[0], xKey, options);
676
739
  }
677
740
  if (xKey.toLowerCase().includes("date") || xKey.toLowerCase().includes("time") || xKey.toLowerCase().includes("month") || xKey.toLowerCase().includes("year")) {
678
- return createLineChart(
679
- data,
680
- xKey,
681
- yKeys.map((key) => ({ key })),
682
- options
683
- );
741
+ return createLineChart(data, xKey, yKeys.map((key) => ({ key })), options);
684
742
  }
685
- return createBarChart(
686
- data,
687
- xKey,
688
- yKeys.map((key) => ({ key })),
689
- options
690
- );
743
+ return createBarChart(data, xKey, yKeys.map((key) => ({ key })), options);
691
744
  }
692
745
  function createToolResult(data, ui) {
693
746
  return { data, ui };
@@ -704,7 +757,6 @@ function resultWithCardGrid(cards, options) {
704
757
  function resultWithTable(data, columns, options) {
705
758
  return createToolResult(data, createTable(data, columns, options));
706
759
  }
707
-
708
760
  // src/hooks/useAgnoChat.ts
709
761
  import { useState as useState3, useEffect as useEffect3, useCallback as useCallback3 } from "react";
710
762
  function useAgnoChat() {
@@ -736,8 +788,7 @@ function useAgnoChat() {
736
788
  }
737
789
  }
738
790
  };
739
- const handleRunCancelled = () => {
740
- };
791
+ const handleRunCancelled = () => {};
741
792
  client.on("message:update", handleMessageUpdate);
742
793
  client.on("message:complete", handleMessageComplete);
743
794
  client.on("message:refreshed", handleMessageRefreshed);
@@ -757,23 +808,20 @@ function useAgnoChat() {
757
808
  client.off("run:cancelled", handleRunCancelled);
758
809
  };
759
810
  }, [client]);
760
- const sendMessage = useCallback3(
761
- async (message, options) => {
762
- setError(void 0);
763
- try {
764
- await client.sendMessage(message, options);
765
- } catch (err) {
766
- const errorMessage = err instanceof Error ? err.message : String(err);
767
- setError(errorMessage);
768
- throw err;
769
- }
770
- },
771
- [client]
772
- );
811
+ const sendMessage = useCallback3(async (message, options) => {
812
+ setError(undefined);
813
+ try {
814
+ await client.sendMessage(message, options);
815
+ } catch (err) {
816
+ const errorMessage = err instanceof Error ? err.message : String(err);
817
+ setError(errorMessage);
818
+ throw err;
819
+ }
820
+ }, [client]);
773
821
  const clearMessages = useCallback3(() => {
774
822
  client.clearMessages();
775
823
  setMessages([]);
776
- setError(void 0);
824
+ setError(undefined);
777
825
  }, [client]);
778
826
  const cancelRun = useCallback3(async () => {
779
827
  try {
@@ -798,15 +846,12 @@ function useAgnoChat() {
798
846
  state
799
847
  };
800
848
  }
801
-
802
849
  // src/hooks/useAgnoSession.ts
803
850
  import { useState as useState4, useEffect as useEffect4, useCallback as useCallback4 } from "react";
804
851
  function useAgnoSession() {
805
852
  const client = useAgnoClient();
806
853
  const [sessions, setSessions] = useState4([]);
807
- const [currentSessionId, setCurrentSessionId] = useState4(
808
- client.getConfig().sessionId
809
- );
854
+ const [currentSessionId, setCurrentSessionId] = useState4(client.getConfig().sessionId);
810
855
  const [isLoading, setIsLoading] = useState4(false);
811
856
  const [error, setError] = useState4();
812
857
  useEffect4(() => {
@@ -833,27 +878,24 @@ function useAgnoSession() {
833
878
  client.off("state:change", handleStateChange);
834
879
  };
835
880
  }, [client]);
836
- const loadSession = useCallback4(
837
- async (sessionId, options) => {
838
- setIsLoading(true);
839
- setError(void 0);
840
- try {
841
- const messages = await client.loadSession(sessionId, options);
842
- setCurrentSessionId(sessionId);
843
- return messages;
844
- } catch (err) {
845
- const errorMessage = err instanceof Error ? err.message : String(err);
846
- setError(errorMessage);
847
- throw err;
848
- } finally {
849
- setIsLoading(false);
850
- }
851
- },
852
- [client]
853
- );
881
+ const loadSession = useCallback4(async (sessionId, options) => {
882
+ setIsLoading(true);
883
+ setError(undefined);
884
+ try {
885
+ const messages = await client.loadSession(sessionId, options);
886
+ setCurrentSessionId(sessionId);
887
+ return messages;
888
+ } catch (err) {
889
+ const errorMessage = err instanceof Error ? err.message : String(err);
890
+ setError(errorMessage);
891
+ throw err;
892
+ } finally {
893
+ setIsLoading(false);
894
+ }
895
+ }, [client]);
854
896
  const fetchSessions = useCallback4(async (options) => {
855
897
  setIsLoading(true);
856
- setError(void 0);
898
+ setError(undefined);
857
899
  try {
858
900
  const fetchedSessions = await client.fetchSessions(options);
859
901
  setSessions(fetchedSessions);
@@ -866,119 +908,98 @@ function useAgnoSession() {
866
908
  setIsLoading(false);
867
909
  }
868
910
  }, [client]);
869
- const getSessionById = useCallback4(
870
- async (sessionId, options) => {
871
- setIsLoading(true);
872
- setError(void 0);
873
- try {
874
- return await client.getSessionById(sessionId, options);
875
- } catch (err) {
876
- const errorMessage = err instanceof Error ? err.message : String(err);
877
- setError(errorMessage);
878
- throw err;
879
- } finally {
880
- setIsLoading(false);
881
- }
882
- },
883
- [client]
884
- );
885
- const getRunById = useCallback4(
886
- async (sessionId, runId, options) => {
887
- setIsLoading(true);
888
- setError(void 0);
889
- try {
890
- return await client.getRunById(sessionId, runId, options);
891
- } catch (err) {
892
- const errorMessage = err instanceof Error ? err.message : String(err);
893
- setError(errorMessage);
894
- throw err;
895
- } finally {
896
- setIsLoading(false);
897
- }
898
- },
899
- [client]
900
- );
901
- const createSession = useCallback4(
902
- async (request, options) => {
903
- setIsLoading(true);
904
- setError(void 0);
905
- try {
906
- const session = await client.createSession(request, options);
907
- return session;
908
- } catch (err) {
909
- const errorMessage = err instanceof Error ? err.message : String(err);
910
- setError(errorMessage);
911
- throw err;
912
- } finally {
913
- setIsLoading(false);
914
- }
915
- },
916
- [client]
917
- );
918
- const updateSession = useCallback4(
919
- async (sessionId, request, options) => {
920
- setIsLoading(true);
921
- setError(void 0);
922
- try {
923
- return await client.updateSession(sessionId, request, options);
924
- } catch (err) {
925
- const errorMessage = err instanceof Error ? err.message : String(err);
926
- setError(errorMessage);
927
- throw err;
928
- } finally {
929
- setIsLoading(false);
930
- }
931
- },
932
- [client]
933
- );
934
- const renameSession = useCallback4(
935
- async (sessionId, newName, options) => {
936
- setIsLoading(true);
937
- setError(void 0);
938
- try {
939
- return await client.renameSession(sessionId, newName, options);
940
- } catch (err) {
941
- const errorMessage = err instanceof Error ? err.message : String(err);
942
- setError(errorMessage);
943
- throw err;
944
- } finally {
945
- setIsLoading(false);
946
- }
947
- },
948
- [client]
949
- );
950
- const deleteSession = useCallback4(
951
- async (sessionId, options) => {
952
- setIsLoading(true);
953
- setError(void 0);
954
- try {
955
- await client.deleteSession(sessionId, options);
956
- } catch (err) {
957
- const errorMessage = err instanceof Error ? err.message : String(err);
958
- setError(errorMessage);
959
- throw err;
960
- } finally {
961
- setIsLoading(false);
962
- }
963
- },
964
- [client]
965
- );
966
- const deleteMultipleSessions = useCallback4(
967
- async (sessionIds, options) => {
968
- setIsLoading(true);
969
- setError(void 0);
970
- try {
971
- await client.deleteMultipleSessions(sessionIds, options);
972
- } catch (err) {
973
- const errorMessage = err instanceof Error ? err.message : String(err);
974
- setError(errorMessage);
975
- throw err;
976
- } finally {
977
- setIsLoading(false);
978
- }
979
- },
980
- [client]
981
- );
911
+ const getSessionById = useCallback4(async (sessionId, options) => {
912
+ setIsLoading(true);
913
+ setError(undefined);
914
+ try {
915
+ return await client.getSessionById(sessionId, options);
916
+ } catch (err) {
917
+ const errorMessage = err instanceof Error ? err.message : String(err);
918
+ setError(errorMessage);
919
+ throw err;
920
+ } finally {
921
+ setIsLoading(false);
922
+ }
923
+ }, [client]);
924
+ const getRunById = useCallback4(async (sessionId, runId, options) => {
925
+ setIsLoading(true);
926
+ setError(undefined);
927
+ try {
928
+ return await client.getRunById(sessionId, runId, options);
929
+ } catch (err) {
930
+ const errorMessage = err instanceof Error ? err.message : String(err);
931
+ setError(errorMessage);
932
+ throw err;
933
+ } finally {
934
+ setIsLoading(false);
935
+ }
936
+ }, [client]);
937
+ const createSession = useCallback4(async (request, options) => {
938
+ setIsLoading(true);
939
+ setError(undefined);
940
+ try {
941
+ const session = await client.createSession(request, options);
942
+ return session;
943
+ } catch (err) {
944
+ const errorMessage = err instanceof Error ? err.message : String(err);
945
+ setError(errorMessage);
946
+ throw err;
947
+ } finally {
948
+ setIsLoading(false);
949
+ }
950
+ }, [client]);
951
+ const updateSession = useCallback4(async (sessionId, request, options) => {
952
+ setIsLoading(true);
953
+ setError(undefined);
954
+ try {
955
+ return await client.updateSession(sessionId, request, options);
956
+ } catch (err) {
957
+ const errorMessage = err instanceof Error ? err.message : String(err);
958
+ setError(errorMessage);
959
+ throw err;
960
+ } finally {
961
+ setIsLoading(false);
962
+ }
963
+ }, [client]);
964
+ const renameSession = useCallback4(async (sessionId, newName, options) => {
965
+ setIsLoading(true);
966
+ setError(undefined);
967
+ try {
968
+ return await client.renameSession(sessionId, newName, options);
969
+ } catch (err) {
970
+ const errorMessage = err instanceof Error ? err.message : String(err);
971
+ setError(errorMessage);
972
+ throw err;
973
+ } finally {
974
+ setIsLoading(false);
975
+ }
976
+ }, [client]);
977
+ const deleteSession = useCallback4(async (sessionId, options) => {
978
+ setIsLoading(true);
979
+ setError(undefined);
980
+ try {
981
+ await client.deleteSession(sessionId, options);
982
+ } catch (err) {
983
+ const errorMessage = err instanceof Error ? err.message : String(err);
984
+ setError(errorMessage);
985
+ throw err;
986
+ } finally {
987
+ setIsLoading(false);
988
+ }
989
+ }, [client]);
990
+ const deleteMultipleSessions = useCallback4(async (sessionIds, options) => {
991
+ setIsLoading(true);
992
+ setError(undefined);
993
+ try {
994
+ await client.deleteMultipleSessions(sessionIds, options);
995
+ } catch (err) {
996
+ const errorMessage = err instanceof Error ? err.message : String(err);
997
+ setError(errorMessage);
998
+ throw err;
999
+ } finally {
1000
+ setIsLoading(false);
1001
+ }
1002
+ }, [client]);
982
1003
  return {
983
1004
  sessions,
984
1005
  currentSessionId,
@@ -995,7 +1016,6 @@ function useAgnoSession() {
995
1016
  error
996
1017
  };
997
1018
  }
998
-
999
1019
  // src/hooks/useAgnoActions.ts
1000
1020
  import { useState as useState5, useCallback as useCallback5 } from "react";
1001
1021
  function useAgnoActions() {
@@ -1004,7 +1024,7 @@ function useAgnoActions() {
1004
1024
  const [error, setError] = useState5();
1005
1025
  const initialize = useCallback5(async (options) => {
1006
1026
  setIsInitializing(true);
1007
- setError(void 0);
1027
+ setError(undefined);
1008
1028
  try {
1009
1029
  const result = await client.initialize(options);
1010
1030
  return result;
@@ -1017,7 +1037,7 @@ function useAgnoActions() {
1017
1037
  }
1018
1038
  }, [client]);
1019
1039
  const checkStatus = useCallback5(async (options) => {
1020
- setError(void 0);
1040
+ setError(undefined);
1021
1041
  try {
1022
1042
  return await client.checkStatus(options);
1023
1043
  } catch (err) {
@@ -1027,7 +1047,7 @@ function useAgnoActions() {
1027
1047
  }
1028
1048
  }, [client]);
1029
1049
  const fetchAgents = useCallback5(async (options) => {
1030
- setError(void 0);
1050
+ setError(undefined);
1031
1051
  try {
1032
1052
  return await client.fetchAgents(options);
1033
1053
  } catch (err) {
@@ -1037,7 +1057,7 @@ function useAgnoActions() {
1037
1057
  }
1038
1058
  }, [client]);
1039
1059
  const fetchTeams = useCallback5(async (options) => {
1040
- setError(void 0);
1060
+ setError(undefined);
1041
1061
  try {
1042
1062
  return await client.fetchTeams(options);
1043
1063
  } catch (err) {
@@ -1046,12 +1066,9 @@ function useAgnoActions() {
1046
1066
  throw err;
1047
1067
  }
1048
1068
  }, [client]);
1049
- const updateConfig = useCallback5(
1050
- (updates) => {
1051
- client.updateConfig(updates);
1052
- },
1053
- [client]
1054
- );
1069
+ const updateConfig = useCallback5((updates) => {
1070
+ client.updateConfig(updates);
1071
+ }, [client]);
1055
1072
  return {
1056
1073
  initialize,
1057
1074
  checkStatus,
@@ -1062,7 +1079,6 @@ function useAgnoActions() {
1062
1079
  error
1063
1080
  };
1064
1081
  }
1065
-
1066
1082
  // src/hooks/useAgnoCustomEvents.ts
1067
1083
  import { useState as useState6, useEffect as useEffect5, useCallback as useCallback6, useRef } from "react";
1068
1084
  function useAgnoCustomEvents(handler) {
@@ -1085,7 +1101,6 @@ function useAgnoCustomEvents(handler) {
1085
1101
  }, []);
1086
1102
  return { events, clearEvents };
1087
1103
  }
1088
-
1089
1104
  // src/hooks/useAgnoMemory.ts
1090
1105
  import { useState as useState7, useEffect as useEffect6, useCallback as useCallback7 } from "react";
1091
1106
  function useAgnoMemory() {
@@ -1099,9 +1114,7 @@ function useAgnoMemory() {
1099
1114
  setMemories((prev) => [memory, ...prev]);
1100
1115
  };
1101
1116
  const handleMemoryUpdated = (memory) => {
1102
- setMemories(
1103
- (prev) => prev.map((m) => m.memory_id === memory.memory_id ? memory : m)
1104
- );
1117
+ setMemories((prev) => prev.map((m) => m.memory_id === memory.memory_id ? memory : m));
1105
1118
  };
1106
1119
  const handleMemoryDeleted = ({ memoryId }) => {
1107
1120
  setMemories((prev) => prev.filter((m) => m.memory_id !== memoryId));
@@ -1131,138 +1144,114 @@ function useAgnoMemory() {
1131
1144
  client.off("state:change", handleStateChange);
1132
1145
  };
1133
1146
  }, [client]);
1134
- const fetchMemories = useCallback7(
1135
- async (queryParams, options) => {
1136
- setIsLoading(true);
1137
- setError(void 0);
1138
- try {
1139
- const response = await client.fetchMemories(queryParams, options);
1140
- setMemories(response.data);
1141
- return response;
1142
- } catch (err) {
1143
- const errorMessage = err instanceof Error ? err.message : String(err);
1144
- setError(errorMessage);
1145
- throw err;
1146
- } finally {
1147
- setIsLoading(false);
1148
- }
1149
- },
1150
- [client]
1151
- );
1152
- const getMemoryById = useCallback7(
1153
- async (memoryId, options) => {
1154
- setIsLoading(true);
1155
- setError(void 0);
1156
- try {
1157
- return await client.getMemoryById(memoryId, options);
1158
- } catch (err) {
1159
- const errorMessage = err instanceof Error ? err.message : String(err);
1160
- setError(errorMessage);
1161
- throw err;
1162
- } finally {
1163
- setIsLoading(false);
1164
- }
1165
- },
1166
- [client]
1167
- );
1168
- const getMemoryTopics = useCallback7(
1169
- async (options) => {
1170
- setIsLoading(true);
1171
- setError(void 0);
1172
- try {
1173
- const result = await client.getMemoryTopics(options);
1174
- setTopics(result);
1175
- return result;
1176
- } catch (err) {
1177
- const errorMessage = err instanceof Error ? err.message : String(err);
1178
- setError(errorMessage);
1179
- throw err;
1180
- } finally {
1181
- setIsLoading(false);
1182
- }
1183
- },
1184
- [client]
1185
- );
1186
- const getUserMemoryStats = useCallback7(
1187
- async (queryParams, options) => {
1188
- setIsLoading(true);
1189
- setError(void 0);
1190
- try {
1191
- return await client.getUserMemoryStats(queryParams, options);
1192
- } catch (err) {
1193
- const errorMessage = err instanceof Error ? err.message : String(err);
1194
- setError(errorMessage);
1195
- throw err;
1196
- } finally {
1197
- setIsLoading(false);
1198
- }
1199
- },
1200
- [client]
1201
- );
1202
- const createMemory = useCallback7(
1203
- async (request, options) => {
1204
- setIsLoading(true);
1205
- setError(void 0);
1206
- try {
1207
- return await client.createMemory(request, options);
1208
- } catch (err) {
1209
- const errorMessage = err instanceof Error ? err.message : String(err);
1210
- setError(errorMessage);
1211
- throw err;
1212
- } finally {
1213
- setIsLoading(false);
1214
- }
1215
- },
1216
- [client]
1217
- );
1218
- const updateMemory = useCallback7(
1219
- async (memoryId, request, options) => {
1220
- setIsLoading(true);
1221
- setError(void 0);
1222
- try {
1223
- return await client.updateMemory(memoryId, request, options);
1224
- } catch (err) {
1225
- const errorMessage = err instanceof Error ? err.message : String(err);
1226
- setError(errorMessage);
1227
- throw err;
1228
- } finally {
1229
- setIsLoading(false);
1230
- }
1231
- },
1232
- [client]
1233
- );
1234
- const deleteMemory = useCallback7(
1235
- async (memoryId, options) => {
1236
- setIsLoading(true);
1237
- setError(void 0);
1238
- try {
1239
- await client.deleteMemory(memoryId, options);
1240
- } catch (err) {
1241
- const errorMessage = err instanceof Error ? err.message : String(err);
1242
- setError(errorMessage);
1243
- throw err;
1244
- } finally {
1245
- setIsLoading(false);
1246
- }
1247
- },
1248
- [client]
1249
- );
1250
- const deleteMultipleMemories = useCallback7(
1251
- async (memoryIds, options) => {
1252
- setIsLoading(true);
1253
- setError(void 0);
1254
- try {
1255
- await client.deleteMultipleMemories(memoryIds, options);
1256
- } catch (err) {
1257
- const errorMessage = err instanceof Error ? err.message : String(err);
1258
- setError(errorMessage);
1259
- throw err;
1260
- } finally {
1261
- setIsLoading(false);
1262
- }
1263
- },
1264
- [client]
1265
- );
1147
+ const fetchMemories = useCallback7(async (queryParams, options) => {
1148
+ setIsLoading(true);
1149
+ setError(undefined);
1150
+ try {
1151
+ const response = await client.fetchMemories(queryParams, options);
1152
+ setMemories(response.data);
1153
+ return response;
1154
+ } catch (err) {
1155
+ const errorMessage = err instanceof Error ? err.message : String(err);
1156
+ setError(errorMessage);
1157
+ throw err;
1158
+ } finally {
1159
+ setIsLoading(false);
1160
+ }
1161
+ }, [client]);
1162
+ const getMemoryById = useCallback7(async (memoryId, options) => {
1163
+ setIsLoading(true);
1164
+ setError(undefined);
1165
+ try {
1166
+ return await client.getMemoryById(memoryId, options);
1167
+ } catch (err) {
1168
+ const errorMessage = err instanceof Error ? err.message : String(err);
1169
+ setError(errorMessage);
1170
+ throw err;
1171
+ } finally {
1172
+ setIsLoading(false);
1173
+ }
1174
+ }, [client]);
1175
+ const getMemoryTopics = useCallback7(async (options) => {
1176
+ setIsLoading(true);
1177
+ setError(undefined);
1178
+ try {
1179
+ const result = await client.getMemoryTopics(options);
1180
+ setTopics(result);
1181
+ return result;
1182
+ } catch (err) {
1183
+ const errorMessage = err instanceof Error ? err.message : String(err);
1184
+ setError(errorMessage);
1185
+ throw err;
1186
+ } finally {
1187
+ setIsLoading(false);
1188
+ }
1189
+ }, [client]);
1190
+ const getUserMemoryStats = useCallback7(async (queryParams, options) => {
1191
+ setIsLoading(true);
1192
+ setError(undefined);
1193
+ try {
1194
+ return await client.getUserMemoryStats(queryParams, options);
1195
+ } catch (err) {
1196
+ const errorMessage = err instanceof Error ? err.message : String(err);
1197
+ setError(errorMessage);
1198
+ throw err;
1199
+ } finally {
1200
+ setIsLoading(false);
1201
+ }
1202
+ }, [client]);
1203
+ const createMemory = useCallback7(async (request, options) => {
1204
+ setIsLoading(true);
1205
+ setError(undefined);
1206
+ try {
1207
+ return await client.createMemory(request, options);
1208
+ } catch (err) {
1209
+ const errorMessage = err instanceof Error ? err.message : String(err);
1210
+ setError(errorMessage);
1211
+ throw err;
1212
+ } finally {
1213
+ setIsLoading(false);
1214
+ }
1215
+ }, [client]);
1216
+ const updateMemory = useCallback7(async (memoryId, request, options) => {
1217
+ setIsLoading(true);
1218
+ setError(undefined);
1219
+ try {
1220
+ return await client.updateMemory(memoryId, request, options);
1221
+ } catch (err) {
1222
+ const errorMessage = err instanceof Error ? err.message : String(err);
1223
+ setError(errorMessage);
1224
+ throw err;
1225
+ } finally {
1226
+ setIsLoading(false);
1227
+ }
1228
+ }, [client]);
1229
+ const deleteMemory = useCallback7(async (memoryId, options) => {
1230
+ setIsLoading(true);
1231
+ setError(undefined);
1232
+ try {
1233
+ await client.deleteMemory(memoryId, options);
1234
+ } catch (err) {
1235
+ const errorMessage = err instanceof Error ? err.message : String(err);
1236
+ setError(errorMessage);
1237
+ throw err;
1238
+ } finally {
1239
+ setIsLoading(false);
1240
+ }
1241
+ }, [client]);
1242
+ const deleteMultipleMemories = useCallback7(async (memoryIds, options) => {
1243
+ setIsLoading(true);
1244
+ setError(undefined);
1245
+ try {
1246
+ await client.deleteMultipleMemories(memoryIds, options);
1247
+ } catch (err) {
1248
+ const errorMessage = err instanceof Error ? err.message : String(err);
1249
+ setError(errorMessage);
1250
+ throw err;
1251
+ } finally {
1252
+ setIsLoading(false);
1253
+ }
1254
+ }, [client]);
1266
1255
  return {
1267
1256
  memories,
1268
1257
  topics,
@@ -1278,7 +1267,6 @@ function useAgnoMemory() {
1278
1267
  deleteMultipleMemories
1279
1268
  };
1280
1269
  }
1281
-
1282
1270
  // src/hooks/useAgnoKnowledge.ts
1283
1271
  import { useState as useState8, useCallback as useCallback8 } from "react";
1284
1272
  function useAgnoKnowledge() {
@@ -1287,172 +1275,139 @@ function useAgnoKnowledge() {
1287
1275
  const [error, setError] = useState8();
1288
1276
  const [config, setConfig] = useState8();
1289
1277
  const [content, setContent] = useState8([]);
1290
- const getConfig = useCallback8(
1291
- async (options) => {
1292
- setIsLoading(true);
1293
- setError(void 0);
1294
- try {
1295
- const result = await client.getKnowledgeConfig(options);
1296
- setConfig(result);
1297
- return result;
1298
- } catch (err) {
1299
- const errorMessage = err instanceof Error ? err.message : String(err);
1300
- setError(errorMessage);
1301
- throw err;
1302
- } finally {
1303
- setIsLoading(false);
1304
- }
1305
- },
1306
- [client]
1307
- );
1308
- const listContent = useCallback8(
1309
- async (listOptions, options) => {
1310
- setIsLoading(true);
1311
- setError(void 0);
1312
- try {
1313
- const result = await client.listKnowledgeContent(listOptions, options);
1314
- setContent(result.data);
1315
- return result;
1316
- } catch (err) {
1317
- const errorMessage = err instanceof Error ? err.message : String(err);
1318
- setError(errorMessage);
1319
- throw err;
1320
- } finally {
1321
- setIsLoading(false);
1322
- }
1323
- },
1324
- [client]
1325
- );
1326
- const getContent = useCallback8(
1327
- async (contentId, options) => {
1328
- setIsLoading(true);
1329
- setError(void 0);
1330
- try {
1331
- return await client.getKnowledgeContent(contentId, options);
1332
- } catch (err) {
1333
- const errorMessage = err instanceof Error ? err.message : String(err);
1334
- setError(errorMessage);
1335
- throw err;
1336
- } finally {
1337
- setIsLoading(false);
1338
- }
1339
- },
1340
- [client]
1341
- );
1342
- const getContentStatus = useCallback8(
1343
- async (contentId, options) => {
1344
- setIsLoading(true);
1345
- setError(void 0);
1346
- try {
1347
- return await client.getKnowledgeContentStatus(contentId, options);
1348
- } catch (err) {
1349
- const errorMessage = err instanceof Error ? err.message : String(err);
1350
- setError(errorMessage);
1351
- throw err;
1352
- } finally {
1353
- setIsLoading(false);
1354
- }
1355
- },
1356
- [client]
1357
- );
1358
- const search = useCallback8(
1359
- async (request, options) => {
1360
- setIsLoading(true);
1361
- setError(void 0);
1362
- try {
1363
- return await client.searchKnowledge(request, options);
1364
- } catch (err) {
1365
- const errorMessage = err instanceof Error ? err.message : String(err);
1366
- setError(errorMessage);
1367
- throw err;
1368
- } finally {
1369
- setIsLoading(false);
1370
- }
1371
- },
1372
- [client]
1373
- );
1374
- const uploadContent = useCallback8(
1375
- async (data, options) => {
1376
- setIsLoading(true);
1377
- setError(void 0);
1378
- try {
1379
- const result = await client.uploadKnowledgeContent(data, options);
1380
- setContent((prev) => [result, ...prev]);
1381
- return result;
1382
- } catch (err) {
1383
- const errorMessage = err instanceof Error ? err.message : String(err);
1384
- setError(errorMessage);
1385
- throw err;
1386
- } finally {
1387
- setIsLoading(false);
1388
- }
1389
- },
1390
- [client]
1391
- );
1392
- const updateContent = useCallback8(
1393
- async (contentId, request, options) => {
1394
- setIsLoading(true);
1395
- setError(void 0);
1396
- try {
1397
- const result = await client.updateKnowledgeContent(
1398
- contentId,
1399
- request,
1400
- options
1401
- );
1402
- setContent((prev) => prev.map((c) => c.id === contentId ? result : c));
1403
- return result;
1404
- } catch (err) {
1405
- const errorMessage = err instanceof Error ? err.message : String(err);
1406
- setError(errorMessage);
1407
- throw err;
1408
- } finally {
1409
- setIsLoading(false);
1410
- }
1411
- },
1412
- [client]
1413
- );
1414
- const deleteAllContent = useCallback8(
1415
- async (options) => {
1416
- setIsLoading(true);
1417
- setError(void 0);
1418
- try {
1419
- await client.deleteAllKnowledgeContent(options);
1420
- setContent([]);
1421
- } catch (err) {
1422
- const errorMessage = err instanceof Error ? err.message : String(err);
1423
- setError(errorMessage);
1424
- throw err;
1425
- } finally {
1426
- setIsLoading(false);
1427
- }
1428
- },
1429
- [client]
1430
- );
1431
- const deleteContent = useCallback8(
1432
- async (contentId, options) => {
1433
- setIsLoading(true);
1434
- setError(void 0);
1435
- try {
1436
- const result = await client.deleteKnowledgeContent(contentId, options);
1437
- setContent((prev) => prev.filter((c) => c.id !== contentId));
1438
- return result;
1439
- } catch (err) {
1440
- const errorMessage = err instanceof Error ? err.message : String(err);
1441
- setError(errorMessage);
1442
- throw err;
1443
- } finally {
1444
- setIsLoading(false);
1445
- }
1446
- },
1447
- [client]
1448
- );
1278
+ const getConfig = useCallback8(async (options) => {
1279
+ setIsLoading(true);
1280
+ setError(undefined);
1281
+ try {
1282
+ const result = await client.getKnowledgeConfig(options);
1283
+ setConfig(result);
1284
+ return result;
1285
+ } catch (err) {
1286
+ const errorMessage = err instanceof Error ? err.message : String(err);
1287
+ setError(errorMessage);
1288
+ throw err;
1289
+ } finally {
1290
+ setIsLoading(false);
1291
+ }
1292
+ }, [client]);
1293
+ const listContent = useCallback8(async (listOptions, options) => {
1294
+ setIsLoading(true);
1295
+ setError(undefined);
1296
+ try {
1297
+ const result = await client.listKnowledgeContent(listOptions, options);
1298
+ setContent(result.data);
1299
+ return result;
1300
+ } catch (err) {
1301
+ const errorMessage = err instanceof Error ? err.message : String(err);
1302
+ setError(errorMessage);
1303
+ throw err;
1304
+ } finally {
1305
+ setIsLoading(false);
1306
+ }
1307
+ }, [client]);
1308
+ const getContent = useCallback8(async (contentId, options) => {
1309
+ setIsLoading(true);
1310
+ setError(undefined);
1311
+ try {
1312
+ return await client.getKnowledgeContent(contentId, options);
1313
+ } catch (err) {
1314
+ const errorMessage = err instanceof Error ? err.message : String(err);
1315
+ setError(errorMessage);
1316
+ throw err;
1317
+ } finally {
1318
+ setIsLoading(false);
1319
+ }
1320
+ }, [client]);
1321
+ const getContentStatus = useCallback8(async (contentId, options) => {
1322
+ setIsLoading(true);
1323
+ setError(undefined);
1324
+ try {
1325
+ return await client.getKnowledgeContentStatus(contentId, options);
1326
+ } catch (err) {
1327
+ const errorMessage = err instanceof Error ? err.message : String(err);
1328
+ setError(errorMessage);
1329
+ throw err;
1330
+ } finally {
1331
+ setIsLoading(false);
1332
+ }
1333
+ }, [client]);
1334
+ const search = useCallback8(async (request, options) => {
1335
+ setIsLoading(true);
1336
+ setError(undefined);
1337
+ try {
1338
+ return await client.searchKnowledge(request, options);
1339
+ } catch (err) {
1340
+ const errorMessage = err instanceof Error ? err.message : String(err);
1341
+ setError(errorMessage);
1342
+ throw err;
1343
+ } finally {
1344
+ setIsLoading(false);
1345
+ }
1346
+ }, [client]);
1347
+ const uploadContent = useCallback8(async (data, options) => {
1348
+ setIsLoading(true);
1349
+ setError(undefined);
1350
+ try {
1351
+ const result = await client.uploadKnowledgeContent(data, options);
1352
+ setContent((prev) => [result, ...prev]);
1353
+ return result;
1354
+ } catch (err) {
1355
+ const errorMessage = err instanceof Error ? err.message : String(err);
1356
+ setError(errorMessage);
1357
+ throw err;
1358
+ } finally {
1359
+ setIsLoading(false);
1360
+ }
1361
+ }, [client]);
1362
+ const updateContent = useCallback8(async (contentId, request, options) => {
1363
+ setIsLoading(true);
1364
+ setError(undefined);
1365
+ try {
1366
+ const result = await client.updateKnowledgeContent(contentId, request, options);
1367
+ setContent((prev) => prev.map((c) => c.id === contentId ? result : c));
1368
+ return result;
1369
+ } catch (err) {
1370
+ const errorMessage = err instanceof Error ? err.message : String(err);
1371
+ setError(errorMessage);
1372
+ throw err;
1373
+ } finally {
1374
+ setIsLoading(false);
1375
+ }
1376
+ }, [client]);
1377
+ const deleteAllContent = useCallback8(async (options) => {
1378
+ setIsLoading(true);
1379
+ setError(undefined);
1380
+ try {
1381
+ await client.deleteAllKnowledgeContent(options);
1382
+ setContent([]);
1383
+ } catch (err) {
1384
+ const errorMessage = err instanceof Error ? err.message : String(err);
1385
+ setError(errorMessage);
1386
+ throw err;
1387
+ } finally {
1388
+ setIsLoading(false);
1389
+ }
1390
+ }, [client]);
1391
+ const deleteContent = useCallback8(async (contentId, options) => {
1392
+ setIsLoading(true);
1393
+ setError(undefined);
1394
+ try {
1395
+ const result = await client.deleteKnowledgeContent(contentId, options);
1396
+ setContent((prev) => prev.filter((c) => c.id !== contentId));
1397
+ return result;
1398
+ } catch (err) {
1399
+ const errorMessage = err instanceof Error ? err.message : String(err);
1400
+ setError(errorMessage);
1401
+ throw err;
1402
+ } finally {
1403
+ setIsLoading(false);
1404
+ }
1405
+ }, [client]);
1449
1406
  return {
1450
- // State
1451
1407
  config,
1452
1408
  content,
1453
1409
  isLoading,
1454
1410
  error,
1455
- // Methods
1456
1411
  getConfig,
1457
1412
  listContent,
1458
1413
  getContent,
@@ -1464,7 +1419,6 @@ function useAgnoKnowledge() {
1464
1419
  deleteContent
1465
1420
  };
1466
1421
  }
1467
-
1468
1422
  // src/hooks/useAgnoMetrics.ts
1469
1423
  import { useState as useState9, useCallback as useCallback9 } from "react";
1470
1424
  function useAgnoMetrics() {
@@ -1473,59 +1427,49 @@ function useAgnoMetrics() {
1473
1427
  const [isRefreshing, setIsRefreshing] = useState9(false);
1474
1428
  const [error, setError] = useState9();
1475
1429
  const [metrics, setMetrics] = useState9();
1476
- const fetchMetrics = useCallback9(
1477
- async (options) => {
1478
- setIsLoading(true);
1479
- setError(void 0);
1480
- try {
1481
- const result = await client.fetchMetrics(options);
1482
- setMetrics(result);
1483
- return result;
1484
- } catch (err) {
1485
- const errorMessage = err instanceof Error ? err.message : String(err);
1486
- setError(errorMessage);
1487
- throw err;
1488
- } finally {
1489
- setIsLoading(false);
1490
- }
1491
- },
1492
- [client]
1493
- );
1494
- const refreshMetrics = useCallback9(
1495
- async (options) => {
1496
- setIsRefreshing(true);
1497
- setError(void 0);
1498
- try {
1499
- const result = await client.refreshMetrics(options);
1500
- return result;
1501
- } catch (err) {
1502
- const errorMessage = err instanceof Error ? err.message : String(err);
1503
- setError(errorMessage);
1504
- throw err;
1505
- } finally {
1506
- setIsRefreshing(false);
1507
- }
1508
- },
1509
- [client]
1510
- );
1430
+ const fetchMetrics = useCallback9(async (options) => {
1431
+ setIsLoading(true);
1432
+ setError(undefined);
1433
+ try {
1434
+ const result = await client.fetchMetrics(options);
1435
+ setMetrics(result);
1436
+ return result;
1437
+ } catch (err) {
1438
+ const errorMessage = err instanceof Error ? err.message : String(err);
1439
+ setError(errorMessage);
1440
+ throw err;
1441
+ } finally {
1442
+ setIsLoading(false);
1443
+ }
1444
+ }, [client]);
1445
+ const refreshMetrics = useCallback9(async (options) => {
1446
+ setIsRefreshing(true);
1447
+ setError(undefined);
1448
+ try {
1449
+ const result = await client.refreshMetrics(options);
1450
+ return result;
1451
+ } catch (err) {
1452
+ const errorMessage = err instanceof Error ? err.message : String(err);
1453
+ setError(errorMessage);
1454
+ throw err;
1455
+ } finally {
1456
+ setIsRefreshing(false);
1457
+ }
1458
+ }, [client]);
1511
1459
  const clearMetrics = useCallback9(() => {
1512
- setMetrics(void 0);
1513
- setError(void 0);
1460
+ setMetrics(undefined);
1461
+ setError(undefined);
1514
1462
  }, []);
1515
1463
  return {
1516
- // Data
1517
1464
  metrics,
1518
- // Actions
1519
1465
  fetchMetrics,
1520
1466
  refreshMetrics,
1521
1467
  clearMetrics,
1522
- // State
1523
1468
  isLoading,
1524
1469
  isRefreshing,
1525
1470
  error
1526
1471
  };
1527
1472
  }
1528
-
1529
1473
  // src/hooks/useAgnoEvals.ts
1530
1474
  import { useState as useState10, useCallback as useCallback10 } from "react";
1531
1475
  function useAgnoEvals() {
@@ -1534,110 +1478,88 @@ function useAgnoEvals() {
1534
1478
  const [pagination, setPagination] = useState10();
1535
1479
  const [isLoading, setIsLoading] = useState10(false);
1536
1480
  const [error, setError] = useState10();
1537
- const listEvalRuns = useCallback10(
1538
- async (listParams = {}, options) => {
1539
- setIsLoading(true);
1540
- setError(void 0);
1541
- try {
1542
- const response = await client.listEvalRuns(listParams, options);
1543
- setEvalRuns(response.data);
1544
- setPagination(response.meta);
1545
- return response;
1546
- } catch (err) {
1547
- const errorMessage = err instanceof Error ? err.message : String(err);
1548
- setError(errorMessage);
1549
- throw err;
1550
- } finally {
1551
- setIsLoading(false);
1552
- }
1553
- },
1554
- [client]
1555
- );
1556
- const getEvalRun = useCallback10(
1557
- async (evalRunId, options) => {
1558
- setIsLoading(true);
1559
- setError(void 0);
1560
- try {
1561
- return await client.getEvalRun(evalRunId, options);
1562
- } catch (err) {
1563
- const errorMessage = err instanceof Error ? err.message : String(err);
1564
- setError(errorMessage);
1565
- throw err;
1566
- } finally {
1567
- setIsLoading(false);
1568
- }
1569
- },
1570
- [client]
1571
- );
1572
- const executeEval = useCallback10(
1573
- async (request, options) => {
1574
- setIsLoading(true);
1575
- setError(void 0);
1576
- try {
1577
- const result = await client.executeEval(request, options);
1578
- setEvalRuns((prev) => [result, ...prev]);
1579
- return result;
1580
- } catch (err) {
1581
- const errorMessage = err instanceof Error ? err.message : String(err);
1582
- setError(errorMessage);
1583
- throw err;
1584
- } finally {
1585
- setIsLoading(false);
1586
- }
1587
- },
1588
- [client]
1589
- );
1590
- const updateEvalRun = useCallback10(
1591
- async (evalRunId, request, options) => {
1592
- setIsLoading(true);
1593
- setError(void 0);
1594
- try {
1595
- const result = await client.updateEvalRun(evalRunId, request, options);
1596
- setEvalRuns(
1597
- (prev) => prev.map((evalRun) => evalRun.id === evalRunId ? result : evalRun)
1598
- );
1599
- return result;
1600
- } catch (err) {
1601
- const errorMessage = err instanceof Error ? err.message : String(err);
1602
- setError(errorMessage);
1603
- throw err;
1604
- } finally {
1605
- setIsLoading(false);
1606
- }
1607
- },
1608
- [client]
1609
- );
1610
- const deleteEvalRuns = useCallback10(
1611
- async (evalRunIds, options) => {
1612
- setIsLoading(true);
1613
- setError(void 0);
1614
- try {
1615
- await client.deleteEvalRuns(evalRunIds, options);
1616
- const deletedSet = new Set(evalRunIds);
1617
- setEvalRuns((prev) => prev.filter((evalRun) => !deletedSet.has(evalRun.id)));
1618
- } catch (err) {
1619
- const errorMessage = err instanceof Error ? err.message : String(err);
1620
- setError(errorMessage);
1621
- throw err;
1622
- } finally {
1623
- setIsLoading(false);
1624
- }
1625
- },
1626
- [client]
1627
- );
1628
- const renameEvalRun = useCallback10(
1629
- async (evalRunId, newName, options) => {
1630
- return updateEvalRun(evalRunId, { name: newName }, options);
1631
- },
1632
- [updateEvalRun]
1633
- );
1481
+ const listEvalRuns = useCallback10(async (listParams = {}, options) => {
1482
+ setIsLoading(true);
1483
+ setError(undefined);
1484
+ try {
1485
+ const response = await client.listEvalRuns(listParams, options);
1486
+ setEvalRuns(response.data);
1487
+ setPagination(response.meta);
1488
+ return response;
1489
+ } catch (err) {
1490
+ const errorMessage = err instanceof Error ? err.message : String(err);
1491
+ setError(errorMessage);
1492
+ throw err;
1493
+ } finally {
1494
+ setIsLoading(false);
1495
+ }
1496
+ }, [client]);
1497
+ const getEvalRun = useCallback10(async (evalRunId, options) => {
1498
+ setIsLoading(true);
1499
+ setError(undefined);
1500
+ try {
1501
+ return await client.getEvalRun(evalRunId, options);
1502
+ } catch (err) {
1503
+ const errorMessage = err instanceof Error ? err.message : String(err);
1504
+ setError(errorMessage);
1505
+ throw err;
1506
+ } finally {
1507
+ setIsLoading(false);
1508
+ }
1509
+ }, [client]);
1510
+ const executeEval = useCallback10(async (request, options) => {
1511
+ setIsLoading(true);
1512
+ setError(undefined);
1513
+ try {
1514
+ const result = await client.executeEval(request, options);
1515
+ setEvalRuns((prev) => [result, ...prev]);
1516
+ return result;
1517
+ } catch (err) {
1518
+ const errorMessage = err instanceof Error ? err.message : String(err);
1519
+ setError(errorMessage);
1520
+ throw err;
1521
+ } finally {
1522
+ setIsLoading(false);
1523
+ }
1524
+ }, [client]);
1525
+ const updateEvalRun = useCallback10(async (evalRunId, request, options) => {
1526
+ setIsLoading(true);
1527
+ setError(undefined);
1528
+ try {
1529
+ const result = await client.updateEvalRun(evalRunId, request, options);
1530
+ setEvalRuns((prev) => prev.map((evalRun) => evalRun.id === evalRunId ? result : evalRun));
1531
+ return result;
1532
+ } catch (err) {
1533
+ const errorMessage = err instanceof Error ? err.message : String(err);
1534
+ setError(errorMessage);
1535
+ throw err;
1536
+ } finally {
1537
+ setIsLoading(false);
1538
+ }
1539
+ }, [client]);
1540
+ const deleteEvalRuns = useCallback10(async (evalRunIds, options) => {
1541
+ setIsLoading(true);
1542
+ setError(undefined);
1543
+ try {
1544
+ await client.deleteEvalRuns(evalRunIds, options);
1545
+ const deletedSet = new Set(evalRunIds);
1546
+ setEvalRuns((prev) => prev.filter((evalRun) => !deletedSet.has(evalRun.id)));
1547
+ } catch (err) {
1548
+ const errorMessage = err instanceof Error ? err.message : String(err);
1549
+ setError(errorMessage);
1550
+ throw err;
1551
+ } finally {
1552
+ setIsLoading(false);
1553
+ }
1554
+ }, [client]);
1555
+ const renameEvalRun = useCallback10(async (evalRunId, newName, options) => {
1556
+ return updateEvalRun(evalRunId, { name: newName }, options);
1557
+ }, [updateEvalRun]);
1634
1558
  return {
1635
- // State
1636
1559
  evalRuns,
1637
1560
  pagination,
1638
1561
  isLoading,
1639
1562
  error,
1640
- // Methods
1641
1563
  listEvalRuns,
1642
1564
  getEvalRun,
1643
1565
  executeEval,
@@ -1646,7 +1568,6 @@ function useAgnoEvals() {
1646
1568
  renameEvalRun
1647
1569
  };
1648
1570
  }
1649
-
1650
1571
  // src/hooks/useAgnoTraces.ts
1651
1572
  import { useState as useState11, useEffect as useEffect7, useCallback as useCallback11 } from "react";
1652
1573
  function useAgnoTraces() {
@@ -1669,110 +1590,96 @@ function useAgnoTraces() {
1669
1590
  client.off("state:change", handleStateChange);
1670
1591
  };
1671
1592
  }, [client]);
1672
- const fetchTraces = useCallback11(
1673
- async (options = {}, requestOptions) => {
1674
- setIsLoading(true);
1675
- setError(void 0);
1676
- try {
1677
- const result = await client.fetchTraces(options, requestOptions);
1678
- setTraces(result.traces);
1679
- return result;
1680
- } catch (err) {
1681
- const errorMessage = err instanceof Error ? err.message : String(err);
1682
- setError(errorMessage);
1683
- throw err;
1684
- } finally {
1685
- setIsLoading(false);
1686
- }
1687
- },
1688
- [client]
1689
- );
1690
- const getTraceDetail = useCallback11(
1691
- async (traceId, options = {}, requestOptions) => {
1692
- setIsLoading(true);
1693
- setError(void 0);
1694
- try {
1695
- return await client.getTraceDetail(traceId, options, requestOptions);
1696
- } catch (err) {
1697
- const errorMessage = err instanceof Error ? err.message : String(err);
1698
- setError(errorMessage);
1699
- throw err;
1700
- } finally {
1701
- setIsLoading(false);
1702
- }
1703
- },
1704
- [client]
1705
- );
1706
- const fetchTraceSessionStats = useCallback11(
1707
- async (options = {}, requestOptions) => {
1708
- setIsLoading(true);
1709
- setError(void 0);
1710
- try {
1711
- const result = await client.fetchTraceSessionStats(options, requestOptions);
1712
- setTraceSessionStats(result.stats);
1713
- return result;
1714
- } catch (err) {
1715
- const errorMessage = err instanceof Error ? err.message : String(err);
1716
- setError(errorMessage);
1717
- throw err;
1718
- } finally {
1719
- setIsLoading(false);
1720
- }
1721
- },
1722
- [client]
1723
- );
1593
+ const fetchTraces = useCallback11(async (options = {}, requestOptions) => {
1594
+ setIsLoading(true);
1595
+ setError(undefined);
1596
+ try {
1597
+ const result = await client.fetchTraces(options, requestOptions);
1598
+ setTraces(result.traces);
1599
+ return result;
1600
+ } catch (err) {
1601
+ const errorMessage = err instanceof Error ? err.message : String(err);
1602
+ setError(errorMessage);
1603
+ throw err;
1604
+ } finally {
1605
+ setIsLoading(false);
1606
+ }
1607
+ }, [client]);
1608
+ const getTraceDetail = useCallback11(async (traceId, options = {}, requestOptions) => {
1609
+ setIsLoading(true);
1610
+ setError(undefined);
1611
+ try {
1612
+ return await client.getTraceDetail(traceId, options, requestOptions);
1613
+ } catch (err) {
1614
+ const errorMessage = err instanceof Error ? err.message : String(err);
1615
+ setError(errorMessage);
1616
+ throw err;
1617
+ } finally {
1618
+ setIsLoading(false);
1619
+ }
1620
+ }, [client]);
1621
+ const fetchTraceSessionStats = useCallback11(async (options = {}, requestOptions) => {
1622
+ setIsLoading(true);
1623
+ setError(undefined);
1624
+ try {
1625
+ const result = await client.fetchTraceSessionStats(options, requestOptions);
1626
+ setTraceSessionStats(result.stats);
1627
+ return result;
1628
+ } catch (err) {
1629
+ const errorMessage = err instanceof Error ? err.message : String(err);
1630
+ setError(errorMessage);
1631
+ throw err;
1632
+ } finally {
1633
+ setIsLoading(false);
1634
+ }
1635
+ }, [client]);
1724
1636
  return {
1725
- /** Current list of traces (from last fetchTraces call) */
1726
1637
  traces,
1727
- /** Current trace session statistics (from last fetchTraceSessionStats call) */
1728
1638
  traceSessionStats,
1729
- /** Fetch traces with optional filters and pagination */
1730
1639
  fetchTraces,
1731
- /** Get trace detail or specific span */
1732
1640
  getTraceDetail,
1733
- /** Fetch trace session statistics */
1734
1641
  fetchTraceSessionStats,
1735
- /** Loading state */
1736
1642
  isLoading,
1737
- /** Error message if last operation failed */
1738
1643
  error
1739
1644
  };
1740
1645
  }
1741
1646
  export {
1742
- AgnoProvider,
1743
- ComponentRegistry,
1744
- GenerativeUIRenderer,
1745
- ToolHandlerProvider,
1746
- createAreaChart,
1747
- createArtifact,
1748
- createBarChart,
1749
- createCard,
1750
- createCardGrid,
1751
- createColumn,
1752
- createLineChart,
1753
- createMarkdown,
1754
- createPieChart,
1755
- createSmartChart,
1756
- createTable,
1757
- createToolResult,
1758
- getChartComponent,
1759
- getComponentRegistry,
1760
- getCustomRender,
1761
- registerChartComponent,
1762
- resultWithBarChart,
1763
- resultWithCardGrid,
1764
- resultWithSmartChart,
1765
- resultWithTable,
1766
- useAgnoActions,
1767
- useAgnoChat,
1768
- useAgnoClient,
1769
- useAgnoCustomEvents,
1770
- useAgnoEvals,
1771
- useAgnoKnowledge,
1772
- useAgnoMemory,
1773
- useAgnoMetrics,
1774
- useAgnoSession,
1775
- useAgnoToolExecution,
1647
+ useToolHandlers,
1776
1648
  useAgnoTraces,
1777
- useToolHandlers
1649
+ useAgnoToolExecution,
1650
+ useAgnoSession,
1651
+ useAgnoMetrics,
1652
+ useAgnoMemory,
1653
+ useAgnoKnowledge,
1654
+ useAgnoEvals,
1655
+ useAgnoCustomEvents,
1656
+ useAgnoClient,
1657
+ useAgnoChat,
1658
+ useAgnoActions,
1659
+ resultWithTable,
1660
+ resultWithSmartChart,
1661
+ resultWithCardGrid,
1662
+ resultWithBarChart,
1663
+ registerChartComponent,
1664
+ getCustomRender,
1665
+ getComponentRegistry,
1666
+ getChartComponent,
1667
+ createToolResult,
1668
+ createTable,
1669
+ createSmartChart,
1670
+ createPieChart,
1671
+ createMarkdown,
1672
+ createLineChart,
1673
+ createColumn,
1674
+ createCardGrid,
1675
+ createCard,
1676
+ createBarChart,
1677
+ createArtifact,
1678
+ createAreaChart,
1679
+ ToolHandlerProvider,
1680
+ GenerativeUIRenderer,
1681
+ ComponentRegistry,
1682
+ AgnoProvider
1778
1683
  };
1684
+
1685
+ //# debugId=1246E6D11194364664756E2164756E21