@rodrigocoliveira/agno-react 1.0.2 → 1.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 (157) 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 +924 -1060
  31. package/dist/index.js.map +24 -0
  32. package/dist/index.mjs +814 -923
  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 +38 -0
  85. package/dist/ui/composed/AgnoChatInput.d.ts.map +1 -0
  86. package/dist/ui/composed/AgnoMessageItem.d.ts +38 -0
  87. package/dist/ui/composed/AgnoMessageItem.d.ts.map +1 -0
  88. package/dist/ui/composed/agno-chat/agno-chat.d.ts +9 -0
  89. package/dist/ui/composed/agno-chat/agno-chat.d.ts.map +1 -0
  90. package/dist/ui/composed/agno-chat/context.d.ts +33 -0
  91. package/dist/ui/composed/agno-chat/context.d.ts.map +1 -0
  92. package/dist/ui/composed/agno-chat/empty-state.d.ts +6 -0
  93. package/dist/ui/composed/agno-chat/empty-state.d.ts.map +1 -0
  94. package/dist/ui/composed/agno-chat/error-bar.d.ts +16 -0
  95. package/dist/ui/composed/agno-chat/error-bar.d.ts.map +1 -0
  96. package/dist/ui/composed/agno-chat/index.d.ts +33 -0
  97. package/dist/ui/composed/agno-chat/index.d.ts.map +1 -0
  98. package/dist/ui/composed/agno-chat/input.d.ts +34 -0
  99. package/dist/ui/composed/agno-chat/input.d.ts.map +1 -0
  100. package/dist/ui/composed/agno-chat/messages.d.ts +45 -0
  101. package/dist/ui/composed/agno-chat/messages.d.ts.map +1 -0
  102. package/dist/ui/composed/agno-chat/suggested-prompts.d.ts +7 -0
  103. package/dist/ui/composed/agno-chat/suggested-prompts.d.ts.map +1 -0
  104. package/dist/ui/composed/agno-chat/tool-status.d.ts +5 -0
  105. package/dist/ui/composed/agno-chat/tool-status.d.ts.map +1 -0
  106. package/dist/ui/composed/index.d.ts +7 -0
  107. package/dist/ui/composed/index.d.ts.map +1 -0
  108. package/dist/ui/index.d.ts +57 -0
  109. package/dist/ui/index.d.ts.map +1 -0
  110. package/dist/ui/lib/cn.d.ts +3 -0
  111. package/dist/ui/lib/cn.d.ts.map +1 -0
  112. package/dist/ui/lib/file-utils.d.ts +20 -0
  113. package/dist/ui/lib/file-utils.d.ts.map +1 -0
  114. package/dist/ui/lib/format-timestamp.d.ts +16 -0
  115. package/dist/ui/lib/format-timestamp.d.ts.map +1 -0
  116. package/dist/ui/primitives/accordion.d.ts +8 -0
  117. package/dist/ui/primitives/accordion.d.ts.map +1 -0
  118. package/dist/ui/primitives/avatar.d.ts +7 -0
  119. package/dist/ui/primitives/avatar.d.ts.map +1 -0
  120. package/dist/ui/primitives/badge.d.ts +10 -0
  121. package/dist/ui/primitives/badge.d.ts.map +1 -0
  122. package/dist/ui/primitives/button.d.ts +12 -0
  123. package/dist/ui/primitives/button.d.ts.map +1 -0
  124. package/dist/ui/primitives/collapsible.d.ts +6 -0
  125. package/dist/ui/primitives/collapsible.d.ts.map +1 -0
  126. package/dist/ui/primitives/command.d.ts +79 -0
  127. package/dist/ui/primitives/command.d.ts.map +1 -0
  128. package/dist/ui/primitives/dialog.d.ts +26 -0
  129. package/dist/ui/primitives/dialog.d.ts.map +1 -0
  130. package/dist/ui/primitives/dropdown-menu.d.ts +28 -0
  131. package/dist/ui/primitives/dropdown-menu.d.ts.map +1 -0
  132. package/dist/ui/primitives/hover-card.d.ts +7 -0
  133. package/dist/ui/primitives/hover-card.d.ts.map +1 -0
  134. package/dist/ui/primitives/index.d.ts +16 -0
  135. package/dist/ui/primitives/index.d.ts.map +1 -0
  136. package/dist/ui/primitives/input-group.d.ts +17 -0
  137. package/dist/ui/primitives/input-group.d.ts.map +1 -0
  138. package/dist/ui/primitives/select.d.ts +14 -0
  139. package/dist/ui/primitives/select.d.ts.map +1 -0
  140. package/dist/ui/primitives/tooltip.d.ts +8 -0
  141. package/dist/ui/primitives/tooltip.d.ts.map +1 -0
  142. package/dist/ui/types.d.ts +91 -0
  143. package/dist/ui/types.d.ts.map +1 -0
  144. package/dist/ui.d.ts +2 -891
  145. package/dist/ui.d.ts.map +1 -0
  146. package/dist/ui.js +2963 -2496
  147. package/dist/ui.js.map +59 -0
  148. package/dist/ui.mjs +2854 -2232
  149. package/dist/ui.mjs.map +59 -0
  150. package/dist/utils/component-registry.d.ts +63 -0
  151. package/dist/utils/component-registry.d.ts.map +1 -0
  152. package/dist/utils/ui-helpers.d.ts +165 -0
  153. package/dist/utils/ui-helpers.d.ts.map +1 -0
  154. package/package.json +9 -10
  155. package/LICENSE +0 -21
  156. package/dist/index.d.mts +0 -724
  157. 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,14 +757,12 @@ 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() {
711
763
  const client = useAgnoClient();
712
764
  const [messages, setMessages] = useState3(client.getMessages());
713
765
  const [state, setState] = useState3(client.getState());
714
- const [error, setError] = useState3();
715
766
  useEffect3(() => {
716
767
  const handleMessageUpdate = (updatedMessages) => {
717
768
  setMessages(updatedMessages);
@@ -722,9 +773,6 @@ function useAgnoChat() {
722
773
  const handleMessageRefreshed = (updatedMessages) => {
723
774
  setMessages(updatedMessages);
724
775
  };
725
- const handleMessageError = (errorMessage) => {
726
- setError(errorMessage);
727
- };
728
776
  const handleStateChange = (newState) => {
729
777
  setState(newState);
730
778
  };
@@ -736,12 +784,10 @@ function useAgnoChat() {
736
784
  }
737
785
  }
738
786
  };
739
- const handleRunCancelled = () => {
740
- };
787
+ const handleRunCancelled = () => {};
741
788
  client.on("message:update", handleMessageUpdate);
742
789
  client.on("message:complete", handleMessageComplete);
743
790
  client.on("message:refreshed", handleMessageRefreshed);
744
- client.on("message:error", handleMessageError);
745
791
  client.on("state:change", handleStateChange);
746
792
  client.on("ui:render", handleUIRender);
747
793
  client.on("run:cancelled", handleRunCancelled);
@@ -751,38 +797,24 @@ function useAgnoChat() {
751
797
  client.off("message:update", handleMessageUpdate);
752
798
  client.off("message:complete", handleMessageComplete);
753
799
  client.off("message:refreshed", handleMessageRefreshed);
754
- client.off("message:error", handleMessageError);
755
800
  client.off("state:change", handleStateChange);
756
801
  client.off("ui:render", handleUIRender);
757
802
  client.off("run:cancelled", handleRunCancelled);
758
803
  };
759
804
  }, [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
- );
805
+ const sendMessage = useCallback3(async (message, options) => {
806
+ try {
807
+ await client.sendMessage(message, options);
808
+ } catch (err) {
809
+ throw err;
810
+ }
811
+ }, [client]);
773
812
  const clearMessages = useCallback3(() => {
774
813
  client.clearMessages();
775
814
  setMessages([]);
776
- setError(void 0);
777
815
  }, [client]);
778
816
  const cancelRun = useCallback3(async () => {
779
- try {
780
- await client.cancelRun();
781
- } catch (err) {
782
- const errorMessage = err instanceof Error ? err.message : String(err);
783
- setError(errorMessage);
784
- throw err;
785
- }
817
+ await client.cancelRun();
786
818
  }, [client]);
787
819
  return {
788
820
  messages,
@@ -794,19 +826,16 @@ function useAgnoChat() {
794
826
  isPaused: state.isPaused,
795
827
  isCancelling: state.isCancelling,
796
828
  currentRunId: state.currentRunId,
797
- error,
829
+ error: state.errorMessage,
798
830
  state
799
831
  };
800
832
  }
801
-
802
833
  // src/hooks/useAgnoSession.ts
803
834
  import { useState as useState4, useEffect as useEffect4, useCallback as useCallback4 } from "react";
804
835
  function useAgnoSession() {
805
836
  const client = useAgnoClient();
806
837
  const [sessions, setSessions] = useState4([]);
807
- const [currentSessionId, setCurrentSessionId] = useState4(
808
- client.getConfig().sessionId
809
- );
838
+ const [currentSessionId, setCurrentSessionId] = useState4(client.getConfig().sessionId);
810
839
  const [isLoading, setIsLoading] = useState4(false);
811
840
  const [error, setError] = useState4();
812
841
  useEffect4(() => {
@@ -833,27 +862,24 @@ function useAgnoSession() {
833
862
  client.off("state:change", handleStateChange);
834
863
  };
835
864
  }, [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
- );
865
+ const loadSession = useCallback4(async (sessionId, options) => {
866
+ setIsLoading(true);
867
+ setError(undefined);
868
+ try {
869
+ const messages = await client.loadSession(sessionId, options);
870
+ setCurrentSessionId(sessionId);
871
+ return messages;
872
+ } catch (err) {
873
+ const errorMessage = err instanceof Error ? err.message : String(err);
874
+ setError(errorMessage);
875
+ throw err;
876
+ } finally {
877
+ setIsLoading(false);
878
+ }
879
+ }, [client]);
854
880
  const fetchSessions = useCallback4(async (options) => {
855
881
  setIsLoading(true);
856
- setError(void 0);
882
+ setError(undefined);
857
883
  try {
858
884
  const fetchedSessions = await client.fetchSessions(options);
859
885
  setSessions(fetchedSessions);
@@ -866,119 +892,98 @@ function useAgnoSession() {
866
892
  setIsLoading(false);
867
893
  }
868
894
  }, [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
- );
895
+ const getSessionById = useCallback4(async (sessionId, options) => {
896
+ setIsLoading(true);
897
+ setError(undefined);
898
+ try {
899
+ return await client.getSessionById(sessionId, options);
900
+ } catch (err) {
901
+ const errorMessage = err instanceof Error ? err.message : String(err);
902
+ setError(errorMessage);
903
+ throw err;
904
+ } finally {
905
+ setIsLoading(false);
906
+ }
907
+ }, [client]);
908
+ const getRunById = useCallback4(async (sessionId, runId, options) => {
909
+ setIsLoading(true);
910
+ setError(undefined);
911
+ try {
912
+ return await client.getRunById(sessionId, runId, options);
913
+ } catch (err) {
914
+ const errorMessage = err instanceof Error ? err.message : String(err);
915
+ setError(errorMessage);
916
+ throw err;
917
+ } finally {
918
+ setIsLoading(false);
919
+ }
920
+ }, [client]);
921
+ const createSession = useCallback4(async (request, options) => {
922
+ setIsLoading(true);
923
+ setError(undefined);
924
+ try {
925
+ const session = await client.createSession(request, options);
926
+ return session;
927
+ } catch (err) {
928
+ const errorMessage = err instanceof Error ? err.message : String(err);
929
+ setError(errorMessage);
930
+ throw err;
931
+ } finally {
932
+ setIsLoading(false);
933
+ }
934
+ }, [client]);
935
+ const updateSession = useCallback4(async (sessionId, request, options) => {
936
+ setIsLoading(true);
937
+ setError(undefined);
938
+ try {
939
+ return await client.updateSession(sessionId, request, 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
+ }, [client]);
948
+ const renameSession = useCallback4(async (sessionId, newName, options) => {
949
+ setIsLoading(true);
950
+ setError(undefined);
951
+ try {
952
+ return await client.renameSession(sessionId, newName, options);
953
+ } catch (err) {
954
+ const errorMessage = err instanceof Error ? err.message : String(err);
955
+ setError(errorMessage);
956
+ throw err;
957
+ } finally {
958
+ setIsLoading(false);
959
+ }
960
+ }, [client]);
961
+ const deleteSession = useCallback4(async (sessionId, options) => {
962
+ setIsLoading(true);
963
+ setError(undefined);
964
+ try {
965
+ await client.deleteSession(sessionId, options);
966
+ } catch (err) {
967
+ const errorMessage = err instanceof Error ? err.message : String(err);
968
+ setError(errorMessage);
969
+ throw err;
970
+ } finally {
971
+ setIsLoading(false);
972
+ }
973
+ }, [client]);
974
+ const deleteMultipleSessions = useCallback4(async (sessionIds, options) => {
975
+ setIsLoading(true);
976
+ setError(undefined);
977
+ try {
978
+ await client.deleteMultipleSessions(sessionIds, options);
979
+ } catch (err) {
980
+ const errorMessage = err instanceof Error ? err.message : String(err);
981
+ setError(errorMessage);
982
+ throw err;
983
+ } finally {
984
+ setIsLoading(false);
985
+ }
986
+ }, [client]);
982
987
  return {
983
988
  sessions,
984
989
  currentSessionId,
@@ -995,7 +1000,6 @@ function useAgnoSession() {
995
1000
  error
996
1001
  };
997
1002
  }
998
-
999
1003
  // src/hooks/useAgnoActions.ts
1000
1004
  import { useState as useState5, useCallback as useCallback5 } from "react";
1001
1005
  function useAgnoActions() {
@@ -1004,7 +1008,7 @@ function useAgnoActions() {
1004
1008
  const [error, setError] = useState5();
1005
1009
  const initialize = useCallback5(async (options) => {
1006
1010
  setIsInitializing(true);
1007
- setError(void 0);
1011
+ setError(undefined);
1008
1012
  try {
1009
1013
  const result = await client.initialize(options);
1010
1014
  return result;
@@ -1017,7 +1021,7 @@ function useAgnoActions() {
1017
1021
  }
1018
1022
  }, [client]);
1019
1023
  const checkStatus = useCallback5(async (options) => {
1020
- setError(void 0);
1024
+ setError(undefined);
1021
1025
  try {
1022
1026
  return await client.checkStatus(options);
1023
1027
  } catch (err) {
@@ -1027,7 +1031,7 @@ function useAgnoActions() {
1027
1031
  }
1028
1032
  }, [client]);
1029
1033
  const fetchAgents = useCallback5(async (options) => {
1030
- setError(void 0);
1034
+ setError(undefined);
1031
1035
  try {
1032
1036
  return await client.fetchAgents(options);
1033
1037
  } catch (err) {
@@ -1037,7 +1041,7 @@ function useAgnoActions() {
1037
1041
  }
1038
1042
  }, [client]);
1039
1043
  const fetchTeams = useCallback5(async (options) => {
1040
- setError(void 0);
1044
+ setError(undefined);
1041
1045
  try {
1042
1046
  return await client.fetchTeams(options);
1043
1047
  } catch (err) {
@@ -1046,12 +1050,9 @@ function useAgnoActions() {
1046
1050
  throw err;
1047
1051
  }
1048
1052
  }, [client]);
1049
- const updateConfig = useCallback5(
1050
- (updates) => {
1051
- client.updateConfig(updates);
1052
- },
1053
- [client]
1054
- );
1053
+ const updateConfig = useCallback5((updates) => {
1054
+ client.updateConfig(updates);
1055
+ }, [client]);
1055
1056
  return {
1056
1057
  initialize,
1057
1058
  checkStatus,
@@ -1062,7 +1063,6 @@ function useAgnoActions() {
1062
1063
  error
1063
1064
  };
1064
1065
  }
1065
-
1066
1066
  // src/hooks/useAgnoCustomEvents.ts
1067
1067
  import { useState as useState6, useEffect as useEffect5, useCallback as useCallback6, useRef } from "react";
1068
1068
  function useAgnoCustomEvents(handler) {
@@ -1085,7 +1085,6 @@ function useAgnoCustomEvents(handler) {
1085
1085
  }, []);
1086
1086
  return { events, clearEvents };
1087
1087
  }
1088
-
1089
1088
  // src/hooks/useAgnoMemory.ts
1090
1089
  import { useState as useState7, useEffect as useEffect6, useCallback as useCallback7 } from "react";
1091
1090
  function useAgnoMemory() {
@@ -1099,9 +1098,7 @@ function useAgnoMemory() {
1099
1098
  setMemories((prev) => [memory, ...prev]);
1100
1099
  };
1101
1100
  const handleMemoryUpdated = (memory) => {
1102
- setMemories(
1103
- (prev) => prev.map((m) => m.memory_id === memory.memory_id ? memory : m)
1104
- );
1101
+ setMemories((prev) => prev.map((m) => m.memory_id === memory.memory_id ? memory : m));
1105
1102
  };
1106
1103
  const handleMemoryDeleted = ({ memoryId }) => {
1107
1104
  setMemories((prev) => prev.filter((m) => m.memory_id !== memoryId));
@@ -1131,138 +1128,114 @@ function useAgnoMemory() {
1131
1128
  client.off("state:change", handleStateChange);
1132
1129
  };
1133
1130
  }, [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
- );
1131
+ const fetchMemories = useCallback7(async (queryParams, options) => {
1132
+ setIsLoading(true);
1133
+ setError(undefined);
1134
+ try {
1135
+ const response = await client.fetchMemories(queryParams, options);
1136
+ setMemories(response.data);
1137
+ return response;
1138
+ } catch (err) {
1139
+ const errorMessage = err instanceof Error ? err.message : String(err);
1140
+ setError(errorMessage);
1141
+ throw err;
1142
+ } finally {
1143
+ setIsLoading(false);
1144
+ }
1145
+ }, [client]);
1146
+ const getMemoryById = useCallback7(async (memoryId, options) => {
1147
+ setIsLoading(true);
1148
+ setError(undefined);
1149
+ try {
1150
+ return await client.getMemoryById(memoryId, options);
1151
+ } catch (err) {
1152
+ const errorMessage = err instanceof Error ? err.message : String(err);
1153
+ setError(errorMessage);
1154
+ throw err;
1155
+ } finally {
1156
+ setIsLoading(false);
1157
+ }
1158
+ }, [client]);
1159
+ const getMemoryTopics = useCallback7(async (options) => {
1160
+ setIsLoading(true);
1161
+ setError(undefined);
1162
+ try {
1163
+ const result = await client.getMemoryTopics(options);
1164
+ setTopics(result);
1165
+ return result;
1166
+ } catch (err) {
1167
+ const errorMessage = err instanceof Error ? err.message : String(err);
1168
+ setError(errorMessage);
1169
+ throw err;
1170
+ } finally {
1171
+ setIsLoading(false);
1172
+ }
1173
+ }, [client]);
1174
+ const getUserMemoryStats = useCallback7(async (queryParams, options) => {
1175
+ setIsLoading(true);
1176
+ setError(undefined);
1177
+ try {
1178
+ return await client.getUserMemoryStats(queryParams, options);
1179
+ } catch (err) {
1180
+ const errorMessage = err instanceof Error ? err.message : String(err);
1181
+ setError(errorMessage);
1182
+ throw err;
1183
+ } finally {
1184
+ setIsLoading(false);
1185
+ }
1186
+ }, [client]);
1187
+ const createMemory = useCallback7(async (request, options) => {
1188
+ setIsLoading(true);
1189
+ setError(undefined);
1190
+ try {
1191
+ return await client.createMemory(request, 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
+ }, [client]);
1200
+ const updateMemory = useCallback7(async (memoryId, request, options) => {
1201
+ setIsLoading(true);
1202
+ setError(undefined);
1203
+ try {
1204
+ return await client.updateMemory(memoryId, request, options);
1205
+ } catch (err) {
1206
+ const errorMessage = err instanceof Error ? err.message : String(err);
1207
+ setError(errorMessage);
1208
+ throw err;
1209
+ } finally {
1210
+ setIsLoading(false);
1211
+ }
1212
+ }, [client]);
1213
+ const deleteMemory = useCallback7(async (memoryId, options) => {
1214
+ setIsLoading(true);
1215
+ setError(undefined);
1216
+ try {
1217
+ await client.deleteMemory(memoryId, options);
1218
+ } catch (err) {
1219
+ const errorMessage = err instanceof Error ? err.message : String(err);
1220
+ setError(errorMessage);
1221
+ throw err;
1222
+ } finally {
1223
+ setIsLoading(false);
1224
+ }
1225
+ }, [client]);
1226
+ const deleteMultipleMemories = useCallback7(async (memoryIds, options) => {
1227
+ setIsLoading(true);
1228
+ setError(undefined);
1229
+ try {
1230
+ await client.deleteMultipleMemories(memoryIds, options);
1231
+ } catch (err) {
1232
+ const errorMessage = err instanceof Error ? err.message : String(err);
1233
+ setError(errorMessage);
1234
+ throw err;
1235
+ } finally {
1236
+ setIsLoading(false);
1237
+ }
1238
+ }, [client]);
1266
1239
  return {
1267
1240
  memories,
1268
1241
  topics,
@@ -1278,7 +1251,6 @@ function useAgnoMemory() {
1278
1251
  deleteMultipleMemories
1279
1252
  };
1280
1253
  }
1281
-
1282
1254
  // src/hooks/useAgnoKnowledge.ts
1283
1255
  import { useState as useState8, useCallback as useCallback8 } from "react";
1284
1256
  function useAgnoKnowledge() {
@@ -1287,172 +1259,139 @@ function useAgnoKnowledge() {
1287
1259
  const [error, setError] = useState8();
1288
1260
  const [config, setConfig] = useState8();
1289
1261
  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
- );
1262
+ const getConfig = useCallback8(async (options) => {
1263
+ setIsLoading(true);
1264
+ setError(undefined);
1265
+ try {
1266
+ const result = await client.getKnowledgeConfig(options);
1267
+ setConfig(result);
1268
+ return result;
1269
+ } catch (err) {
1270
+ const errorMessage = err instanceof Error ? err.message : String(err);
1271
+ setError(errorMessage);
1272
+ throw err;
1273
+ } finally {
1274
+ setIsLoading(false);
1275
+ }
1276
+ }, [client]);
1277
+ const listContent = useCallback8(async (listOptions, options) => {
1278
+ setIsLoading(true);
1279
+ setError(undefined);
1280
+ try {
1281
+ const result = await client.listKnowledgeContent(listOptions, options);
1282
+ setContent(result.data);
1283
+ return result;
1284
+ } catch (err) {
1285
+ const errorMessage = err instanceof Error ? err.message : String(err);
1286
+ setError(errorMessage);
1287
+ throw err;
1288
+ } finally {
1289
+ setIsLoading(false);
1290
+ }
1291
+ }, [client]);
1292
+ const getContent = useCallback8(async (contentId, options) => {
1293
+ setIsLoading(true);
1294
+ setError(undefined);
1295
+ try {
1296
+ return await client.getKnowledgeContent(contentId, options);
1297
+ } catch (err) {
1298
+ const errorMessage = err instanceof Error ? err.message : String(err);
1299
+ setError(errorMessage);
1300
+ throw err;
1301
+ } finally {
1302
+ setIsLoading(false);
1303
+ }
1304
+ }, [client]);
1305
+ const getContentStatus = useCallback8(async (contentId, options) => {
1306
+ setIsLoading(true);
1307
+ setError(undefined);
1308
+ try {
1309
+ return await client.getKnowledgeContentStatus(contentId, options);
1310
+ } catch (err) {
1311
+ const errorMessage = err instanceof Error ? err.message : String(err);
1312
+ setError(errorMessage);
1313
+ throw err;
1314
+ } finally {
1315
+ setIsLoading(false);
1316
+ }
1317
+ }, [client]);
1318
+ const search = useCallback8(async (request, options) => {
1319
+ setIsLoading(true);
1320
+ setError(undefined);
1321
+ try {
1322
+ return await client.searchKnowledge(request, options);
1323
+ } catch (err) {
1324
+ const errorMessage = err instanceof Error ? err.message : String(err);
1325
+ setError(errorMessage);
1326
+ throw err;
1327
+ } finally {
1328
+ setIsLoading(false);
1329
+ }
1330
+ }, [client]);
1331
+ const uploadContent = useCallback8(async (data, options) => {
1332
+ setIsLoading(true);
1333
+ setError(undefined);
1334
+ try {
1335
+ const result = await client.uploadKnowledgeContent(data, options);
1336
+ setContent((prev) => [result, ...prev]);
1337
+ return result;
1338
+ } catch (err) {
1339
+ const errorMessage = err instanceof Error ? err.message : String(err);
1340
+ setError(errorMessage);
1341
+ throw err;
1342
+ } finally {
1343
+ setIsLoading(false);
1344
+ }
1345
+ }, [client]);
1346
+ const updateContent = useCallback8(async (contentId, request, options) => {
1347
+ setIsLoading(true);
1348
+ setError(undefined);
1349
+ try {
1350
+ const result = await client.updateKnowledgeContent(contentId, request, options);
1351
+ setContent((prev) => prev.map((c) => c.id === contentId ? result : c));
1352
+ return result;
1353
+ } catch (err) {
1354
+ const errorMessage = err instanceof Error ? err.message : String(err);
1355
+ setError(errorMessage);
1356
+ throw err;
1357
+ } finally {
1358
+ setIsLoading(false);
1359
+ }
1360
+ }, [client]);
1361
+ const deleteAllContent = useCallback8(async (options) => {
1362
+ setIsLoading(true);
1363
+ setError(undefined);
1364
+ try {
1365
+ await client.deleteAllKnowledgeContent(options);
1366
+ setContent([]);
1367
+ } catch (err) {
1368
+ const errorMessage = err instanceof Error ? err.message : String(err);
1369
+ setError(errorMessage);
1370
+ throw err;
1371
+ } finally {
1372
+ setIsLoading(false);
1373
+ }
1374
+ }, [client]);
1375
+ const deleteContent = useCallback8(async (contentId, options) => {
1376
+ setIsLoading(true);
1377
+ setError(undefined);
1378
+ try {
1379
+ const result = await client.deleteKnowledgeContent(contentId, options);
1380
+ setContent((prev) => prev.filter((c) => c.id !== contentId));
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
+ }, [client]);
1449
1390
  return {
1450
- // State
1451
1391
  config,
1452
1392
  content,
1453
1393
  isLoading,
1454
1394
  error,
1455
- // Methods
1456
1395
  getConfig,
1457
1396
  listContent,
1458
1397
  getContent,
@@ -1464,7 +1403,6 @@ function useAgnoKnowledge() {
1464
1403
  deleteContent
1465
1404
  };
1466
1405
  }
1467
-
1468
1406
  // src/hooks/useAgnoMetrics.ts
1469
1407
  import { useState as useState9, useCallback as useCallback9 } from "react";
1470
1408
  function useAgnoMetrics() {
@@ -1473,59 +1411,49 @@ function useAgnoMetrics() {
1473
1411
  const [isRefreshing, setIsRefreshing] = useState9(false);
1474
1412
  const [error, setError] = useState9();
1475
1413
  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
- );
1414
+ const fetchMetrics = useCallback9(async (options) => {
1415
+ setIsLoading(true);
1416
+ setError(undefined);
1417
+ try {
1418
+ const result = await client.fetchMetrics(options);
1419
+ setMetrics(result);
1420
+ return result;
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
+ }, [client]);
1429
+ const refreshMetrics = useCallback9(async (options) => {
1430
+ setIsRefreshing(true);
1431
+ setError(undefined);
1432
+ try {
1433
+ const result = await client.refreshMetrics(options);
1434
+ return result;
1435
+ } catch (err) {
1436
+ const errorMessage = err instanceof Error ? err.message : String(err);
1437
+ setError(errorMessage);
1438
+ throw err;
1439
+ } finally {
1440
+ setIsRefreshing(false);
1441
+ }
1442
+ }, [client]);
1511
1443
  const clearMetrics = useCallback9(() => {
1512
- setMetrics(void 0);
1513
- setError(void 0);
1444
+ setMetrics(undefined);
1445
+ setError(undefined);
1514
1446
  }, []);
1515
1447
  return {
1516
- // Data
1517
1448
  metrics,
1518
- // Actions
1519
1449
  fetchMetrics,
1520
1450
  refreshMetrics,
1521
1451
  clearMetrics,
1522
- // State
1523
1452
  isLoading,
1524
1453
  isRefreshing,
1525
1454
  error
1526
1455
  };
1527
1456
  }
1528
-
1529
1457
  // src/hooks/useAgnoEvals.ts
1530
1458
  import { useState as useState10, useCallback as useCallback10 } from "react";
1531
1459
  function useAgnoEvals() {
@@ -1534,110 +1462,88 @@ function useAgnoEvals() {
1534
1462
  const [pagination, setPagination] = useState10();
1535
1463
  const [isLoading, setIsLoading] = useState10(false);
1536
1464
  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
- );
1465
+ const listEvalRuns = useCallback10(async (listParams = {}, options) => {
1466
+ setIsLoading(true);
1467
+ setError(undefined);
1468
+ try {
1469
+ const response = await client.listEvalRuns(listParams, options);
1470
+ setEvalRuns(response.data);
1471
+ setPagination(response.meta);
1472
+ return response;
1473
+ } catch (err) {
1474
+ const errorMessage = err instanceof Error ? err.message : String(err);
1475
+ setError(errorMessage);
1476
+ throw err;
1477
+ } finally {
1478
+ setIsLoading(false);
1479
+ }
1480
+ }, [client]);
1481
+ const getEvalRun = useCallback10(async (evalRunId, options) => {
1482
+ setIsLoading(true);
1483
+ setError(undefined);
1484
+ try {
1485
+ return await client.getEvalRun(evalRunId, options);
1486
+ } catch (err) {
1487
+ const errorMessage = err instanceof Error ? err.message : String(err);
1488
+ setError(errorMessage);
1489
+ throw err;
1490
+ } finally {
1491
+ setIsLoading(false);
1492
+ }
1493
+ }, [client]);
1494
+ const executeEval = useCallback10(async (request, options) => {
1495
+ setIsLoading(true);
1496
+ setError(undefined);
1497
+ try {
1498
+ const result = await client.executeEval(request, options);
1499
+ setEvalRuns((prev) => [result, ...prev]);
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
+ setIsLoading(false);
1507
+ }
1508
+ }, [client]);
1509
+ const updateEvalRun = useCallback10(async (evalRunId, request, options) => {
1510
+ setIsLoading(true);
1511
+ setError(undefined);
1512
+ try {
1513
+ const result = await client.updateEvalRun(evalRunId, request, options);
1514
+ setEvalRuns((prev) => prev.map((evalRun) => evalRun.id === evalRunId ? result : evalRun));
1515
+ return result;
1516
+ } catch (err) {
1517
+ const errorMessage = err instanceof Error ? err.message : String(err);
1518
+ setError(errorMessage);
1519
+ throw err;
1520
+ } finally {
1521
+ setIsLoading(false);
1522
+ }
1523
+ }, [client]);
1524
+ const deleteEvalRuns = useCallback10(async (evalRunIds, options) => {
1525
+ setIsLoading(true);
1526
+ setError(undefined);
1527
+ try {
1528
+ await client.deleteEvalRuns(evalRunIds, options);
1529
+ const deletedSet = new Set(evalRunIds);
1530
+ setEvalRuns((prev) => prev.filter((evalRun) => !deletedSet.has(evalRun.id)));
1531
+ } catch (err) {
1532
+ const errorMessage = err instanceof Error ? err.message : String(err);
1533
+ setError(errorMessage);
1534
+ throw err;
1535
+ } finally {
1536
+ setIsLoading(false);
1537
+ }
1538
+ }, [client]);
1539
+ const renameEvalRun = useCallback10(async (evalRunId, newName, options) => {
1540
+ return updateEvalRun(evalRunId, { name: newName }, options);
1541
+ }, [updateEvalRun]);
1634
1542
  return {
1635
- // State
1636
1543
  evalRuns,
1637
1544
  pagination,
1638
1545
  isLoading,
1639
1546
  error,
1640
- // Methods
1641
1547
  listEvalRuns,
1642
1548
  getEvalRun,
1643
1549
  executeEval,
@@ -1646,7 +1552,6 @@ function useAgnoEvals() {
1646
1552
  renameEvalRun
1647
1553
  };
1648
1554
  }
1649
-
1650
1555
  // src/hooks/useAgnoTraces.ts
1651
1556
  import { useState as useState11, useEffect as useEffect7, useCallback as useCallback11 } from "react";
1652
1557
  function useAgnoTraces() {
@@ -1669,110 +1574,96 @@ function useAgnoTraces() {
1669
1574
  client.off("state:change", handleStateChange);
1670
1575
  };
1671
1576
  }, [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
- );
1577
+ const fetchTraces = useCallback11(async (options = {}, requestOptions) => {
1578
+ setIsLoading(true);
1579
+ setError(undefined);
1580
+ try {
1581
+ const result = await client.fetchTraces(options, requestOptions);
1582
+ setTraces(result.traces);
1583
+ return result;
1584
+ } catch (err) {
1585
+ const errorMessage = err instanceof Error ? err.message : String(err);
1586
+ setError(errorMessage);
1587
+ throw err;
1588
+ } finally {
1589
+ setIsLoading(false);
1590
+ }
1591
+ }, [client]);
1592
+ const getTraceDetail = useCallback11(async (traceId, options = {}, requestOptions) => {
1593
+ setIsLoading(true);
1594
+ setError(undefined);
1595
+ try {
1596
+ return await client.getTraceDetail(traceId, options, requestOptions);
1597
+ } catch (err) {
1598
+ const errorMessage = err instanceof Error ? err.message : String(err);
1599
+ setError(errorMessage);
1600
+ throw err;
1601
+ } finally {
1602
+ setIsLoading(false);
1603
+ }
1604
+ }, [client]);
1605
+ const fetchTraceSessionStats = useCallback11(async (options = {}, requestOptions) => {
1606
+ setIsLoading(true);
1607
+ setError(undefined);
1608
+ try {
1609
+ const result = await client.fetchTraceSessionStats(options, requestOptions);
1610
+ setTraceSessionStats(result.stats);
1611
+ return result;
1612
+ } catch (err) {
1613
+ const errorMessage = err instanceof Error ? err.message : String(err);
1614
+ setError(errorMessage);
1615
+ throw err;
1616
+ } finally {
1617
+ setIsLoading(false);
1618
+ }
1619
+ }, [client]);
1724
1620
  return {
1725
- /** Current list of traces (from last fetchTraces call) */
1726
1621
  traces,
1727
- /** Current trace session statistics (from last fetchTraceSessionStats call) */
1728
1622
  traceSessionStats,
1729
- /** Fetch traces with optional filters and pagination */
1730
1623
  fetchTraces,
1731
- /** Get trace detail or specific span */
1732
1624
  getTraceDetail,
1733
- /** Fetch trace session statistics */
1734
1625
  fetchTraceSessionStats,
1735
- /** Loading state */
1736
1626
  isLoading,
1737
- /** Error message if last operation failed */
1738
1627
  error
1739
1628
  };
1740
1629
  }
1741
1630
  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,
1631
+ useToolHandlers,
1776
1632
  useAgnoTraces,
1777
- useToolHandlers
1633
+ useAgnoToolExecution,
1634
+ useAgnoSession,
1635
+ useAgnoMetrics,
1636
+ useAgnoMemory,
1637
+ useAgnoKnowledge,
1638
+ useAgnoEvals,
1639
+ useAgnoCustomEvents,
1640
+ useAgnoClient,
1641
+ useAgnoChat,
1642
+ useAgnoActions,
1643
+ resultWithTable,
1644
+ resultWithSmartChart,
1645
+ resultWithCardGrid,
1646
+ resultWithBarChart,
1647
+ registerChartComponent,
1648
+ getCustomRender,
1649
+ getComponentRegistry,
1650
+ getChartComponent,
1651
+ createToolResult,
1652
+ createTable,
1653
+ createSmartChart,
1654
+ createPieChart,
1655
+ createMarkdown,
1656
+ createLineChart,
1657
+ createColumn,
1658
+ createCardGrid,
1659
+ createCard,
1660
+ createBarChart,
1661
+ createArtifact,
1662
+ createAreaChart,
1663
+ ToolHandlerProvider,
1664
+ GenerativeUIRenderer,
1665
+ ComponentRegistry,
1666
+ AgnoProvider
1778
1667
  };
1668
+
1669
+ //# debugId=414F45CD3B3482F064756E2164756E21