@rodrigocoliveira/agno-react 1.0.1 → 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 (158) hide show
  1. package/README.md +363 -83
  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 -0
  147. package/dist/ui.d.ts.map +1 -0
  148. package/dist/ui.js +4059 -0
  149. package/dist/ui.js.map +60 -0
  150. package/dist/ui.mjs +4044 -0
  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 +122 -17
  157. package/LICENSE +0 -21
  158. package/dist/index.d.mts +0 -724
package/dist/index.js CHANGED
@@ -1,109 +1,123 @@
1
- "use strict";
2
1
  var __create = Object.create;
2
+ var __getProtoOf = Object.getPrototypeOf;
3
3
  var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __toESM = (mod, isNodeMode, target) => {
8
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
9
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
+ for (let key of __getOwnPropNames(mod))
11
+ if (!__hasOwnProp.call(to, key))
12
+ __defProp(to, key, {
13
+ get: () => mod[key],
14
+ enumerable: true
15
+ });
16
+ return to;
17
+ };
18
+ var __moduleCache = /* @__PURE__ */ new WeakMap;
19
+ var __toCommonJS = (from) => {
20
+ var entry = __moduleCache.get(from), desc;
21
+ if (entry)
22
+ return entry;
23
+ entry = __defProp({}, "__esModule", { value: true });
24
+ if (from && typeof from === "object" || typeof from === "function")
25
+ __getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
26
+ get: () => from[key],
27
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
28
+ }));
29
+ __moduleCache.set(from, entry);
30
+ return entry;
31
+ };
8
32
  var __export = (target, all) => {
9
33
  for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
34
+ __defProp(target, name, {
35
+ get: all[name],
36
+ enumerable: true,
37
+ configurable: true,
38
+ set: (newValue) => all[name] = () => newValue
39
+ });
19
40
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
41
 
30
42
  // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
33
- AgnoProvider: () => AgnoProvider,
34
- ComponentRegistry: () => ComponentRegistry,
35
- GenerativeUIRenderer: () => GenerativeUIRenderer,
36
- ToolHandlerProvider: () => ToolHandlerProvider,
37
- createAreaChart: () => createAreaChart,
38
- createArtifact: () => createArtifact,
39
- createBarChart: () => createBarChart,
40
- createCard: () => createCard,
41
- createCardGrid: () => createCardGrid,
42
- createColumn: () => createColumn,
43
- createLineChart: () => createLineChart,
44
- createMarkdown: () => createMarkdown,
45
- createPieChart: () => createPieChart,
46
- createSmartChart: () => createSmartChart,
47
- createTable: () => createTable,
48
- createToolResult: () => createToolResult,
49
- getChartComponent: () => getChartComponent,
50
- getComponentRegistry: () => getComponentRegistry,
51
- getCustomRender: () => getCustomRender,
52
- registerChartComponent: () => registerChartComponent,
53
- resultWithBarChart: () => resultWithBarChart,
54
- resultWithCardGrid: () => resultWithCardGrid,
55
- resultWithSmartChart: () => resultWithSmartChart,
56
- resultWithTable: () => resultWithTable,
57
- useAgnoActions: () => useAgnoActions,
58
- useAgnoChat: () => useAgnoChat,
59
- useAgnoClient: () => useAgnoClient,
60
- useAgnoCustomEvents: () => useAgnoCustomEvents,
61
- useAgnoEvals: () => useAgnoEvals,
62
- useAgnoKnowledge: () => useAgnoKnowledge,
63
- useAgnoMemory: () => useAgnoMemory,
64
- useAgnoMetrics: () => useAgnoMetrics,
65
- useAgnoSession: () => useAgnoSession,
66
- useAgnoToolExecution: () => useAgnoToolExecution,
43
+ var exports_src = {};
44
+ __export(exports_src, {
45
+ useToolHandlers: () => useToolHandlers,
67
46
  useAgnoTraces: () => useAgnoTraces,
68
- useToolHandlers: () => useToolHandlers
47
+ useAgnoToolExecution: () => useAgnoToolExecution,
48
+ useAgnoSession: () => useAgnoSession,
49
+ useAgnoMetrics: () => useAgnoMetrics,
50
+ useAgnoMemory: () => useAgnoMemory,
51
+ useAgnoKnowledge: () => useAgnoKnowledge,
52
+ useAgnoEvals: () => useAgnoEvals,
53
+ useAgnoCustomEvents: () => useAgnoCustomEvents,
54
+ useAgnoClient: () => useAgnoClient,
55
+ useAgnoChat: () => useAgnoChat,
56
+ useAgnoActions: () => useAgnoActions,
57
+ resultWithTable: () => resultWithTable,
58
+ resultWithSmartChart: () => resultWithSmartChart,
59
+ resultWithCardGrid: () => resultWithCardGrid,
60
+ resultWithBarChart: () => resultWithBarChart,
61
+ registerChartComponent: () => registerChartComponent,
62
+ getCustomRender: () => getCustomRender,
63
+ getComponentRegistry: () => getComponentRegistry,
64
+ getChartComponent: () => getChartComponent,
65
+ createToolResult: () => createToolResult,
66
+ createTable: () => createTable,
67
+ createSmartChart: () => createSmartChart,
68
+ createPieChart: () => createPieChart,
69
+ createMarkdown: () => createMarkdown,
70
+ createLineChart: () => createLineChart,
71
+ createColumn: () => createColumn,
72
+ createCardGrid: () => createCardGrid,
73
+ createCard: () => createCard,
74
+ createBarChart: () => createBarChart,
75
+ createArtifact: () => createArtifact,
76
+ createAreaChart: () => createAreaChart,
77
+ ToolHandlerProvider: () => ToolHandlerProvider,
78
+ GenerativeUIRenderer: () => GenerativeUIRenderer,
79
+ ComponentRegistry: () => ComponentRegistry,
80
+ AgnoProvider: () => AgnoProvider
69
81
  });
70
- module.exports = __toCommonJS(index_exports);
82
+ module.exports = __toCommonJS(exports_src);
71
83
 
72
84
  // src/context/AgnoContext.tsx
73
85
  var import_react = require("react");
74
86
  var import_agno_client = require("@rodrigocoliveira/agno-client");
75
- var import_jsx_runtime = require("react/jsx-runtime");
76
- var AgnoContext = (0, import_react.createContext)(null);
87
+ var jsx_dev_runtime = require("react/jsx-dev-runtime");
88
+ var AgnoContext = import_react.createContext(null);
77
89
  function AgnoProvider({ config, children }) {
78
- const client = (0, import_react.useMemo)(() => new import_agno_client.AgnoClient(config), []);
79
- (0, import_react.useEffect)(() => {
90
+ const client = import_react.useMemo(() => new import_agno_client.AgnoClient(config), []);
91
+ import_react.useEffect(() => {
80
92
  client.updateConfig(config);
81
93
  }, [client, config]);
82
- (0, import_react.useEffect)(() => {
94
+ import_react.useEffect(() => {
83
95
  return () => {
84
96
  client.removeAllListeners();
85
97
  };
86
98
  }, [client]);
87
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AgnoContext.Provider, { value: client, children });
99
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(AgnoContext.Provider, {
100
+ value: client,
101
+ children
102
+ }, undefined, false, undefined, this);
88
103
  }
89
104
  function useAgnoClient() {
90
- const client = (0, import_react.useContext)(AgnoContext);
105
+ const client = import_react.useContext(AgnoContext);
91
106
  if (!client) {
92
107
  throw new Error("useAgnoClient must be used within an AgnoProvider");
93
108
  }
94
109
  return client;
95
110
  }
96
-
97
111
  // src/context/ToolHandlerContext.tsx
98
112
  var import_react2 = require("react");
99
- var import_jsx_runtime2 = require("react/jsx-runtime");
100
- var ToolHandlerContext = (0, import_react2.createContext)(null);
113
+ var jsx_dev_runtime2 = require("react/jsx-dev-runtime");
114
+ var ToolHandlerContext = import_react2.createContext(null);
101
115
  function ToolHandlerProvider({ handlers: initialHandlers = {}, children }) {
102
- const [handlers, setHandlers] = (0, import_react2.useState)(initialHandlers);
103
- const registerHandler = (0, import_react2.useCallback)((name, handler) => {
116
+ const [handlers, setHandlers] = import_react2.useState(initialHandlers);
117
+ const registerHandler = import_react2.useCallback((name, handler) => {
104
118
  setHandlers((prev) => ({ ...prev, [name]: handler }));
105
119
  }, []);
106
- const unregisterHandler = (0, import_react2.useCallback)((name) => {
120
+ const unregisterHandler = import_react2.useCallback((name) => {
107
121
  setHandlers((prev) => {
108
122
  const { [name]: _, ...rest } = prev;
109
123
  return rest;
@@ -114,74 +128,52 @@ function ToolHandlerProvider({ handlers: initialHandlers = {}, children }) {
114
128
  registerHandler,
115
129
  unregisterHandler
116
130
  };
117
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ToolHandlerContext.Provider, { value, children });
131
+ return /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ToolHandlerContext.Provider, {
132
+ value,
133
+ children
134
+ }, undefined, false, undefined, this);
118
135
  }
119
136
  function useToolHandlers() {
120
- return (0, import_react2.useContext)(ToolHandlerContext);
137
+ return import_react2.useContext(ToolHandlerContext);
121
138
  }
122
-
123
139
  // src/components/GenerativeUIRenderer.tsx
124
140
  var import_react4 = __toESM(require("react"));
125
141
 
126
142
  // src/utils/component-registry.ts
127
- var ComponentRegistry = class _ComponentRegistry {
128
- constructor() {
129
- this.components = /* @__PURE__ */ new Map();
130
- }
131
- /**
132
- * Get the singleton instance
133
- */
143
+ class ComponentRegistry {
144
+ static instance;
145
+ components = new Map;
146
+ constructor() {}
134
147
  static getInstance() {
135
- if (!_ComponentRegistry.instance) {
136
- _ComponentRegistry.instance = new _ComponentRegistry();
148
+ if (!ComponentRegistry.instance) {
149
+ ComponentRegistry.instance = new ComponentRegistry;
137
150
  }
138
- return _ComponentRegistry.instance;
151
+ return ComponentRegistry.instance;
139
152
  }
140
- /**
141
- * Register a component renderer
142
- */
143
153
  register(type, renderer) {
144
154
  this.components.set(type, renderer);
145
155
  }
146
- /**
147
- * Register multiple components at once
148
- */
149
156
  registerBatch(components) {
150
157
  Object.entries(components).forEach(([type, renderer]) => {
151
158
  this.register(type, renderer);
152
159
  });
153
160
  }
154
- /**
155
- * Get a registered component renderer
156
- */
157
161
  get(type) {
158
162
  return this.components.get(type);
159
163
  }
160
- /**
161
- * Check if a component is registered
162
- */
163
164
  has(type) {
164
165
  return this.components.has(type);
165
166
  }
166
- /**
167
- * Unregister a component
168
- */
169
167
  unregister(type) {
170
168
  this.components.delete(type);
171
169
  }
172
- /**
173
- * Get all registered component types
174
- */
175
170
  getRegisteredTypes() {
176
171
  return Array.from(this.components.keys());
177
172
  }
178
- /**
179
- * Clear all registered components
180
- */
181
173
  clear() {
182
174
  this.components.clear();
183
175
  }
184
- };
176
+ }
185
177
  function getComponentRegistry() {
186
178
  return ComponentRegistry.getInstance();
187
179
  }
@@ -194,7 +186,7 @@ function getChartComponent(name) {
194
186
 
195
187
  // src/hooks/useAgnoToolExecution.ts
196
188
  var import_react3 = require("react");
197
- var customRenderRegistry = /* @__PURE__ */ new Map();
189
+ var customRenderRegistry = new Map;
198
190
  function registerCustomRender(renderFn) {
199
191
  const key = `custom-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
200
192
  customRenderRegistry.set(key, renderFn);
@@ -204,7 +196,7 @@ function getCustomRender(key) {
204
196
  return customRenderRegistry.get(key);
205
197
  }
206
198
  function isToolHandlerResult(value) {
207
- return value && typeof value === "object" && ("data" in value || "ui" in value);
199
+ return value && typeof value === "object" && (("data" in value) || ("ui" in value));
208
200
  }
209
201
  function isUIComponentSpec(value) {
210
202
  return value && typeof value === "object" && "type" in value;
@@ -212,15 +204,14 @@ function isUIComponentSpec(value) {
212
204
  function processToolResult(result, _tool) {
213
205
  if (isToolHandlerResult(result)) {
214
206
  const { data, ui } = result;
215
- let uiComponent = void 0;
207
+ let uiComponent = undefined;
216
208
  if (ui) {
217
209
  if (ui.type === "custom" && typeof ui.render === "function") {
218
210
  const renderKey = registerCustomRender(ui.render);
219
211
  uiComponent = {
220
212
  ...ui,
221
213
  renderKey,
222
- render: void 0
223
- // Don't store the function itself
214
+ render: undefined
224
215
  };
225
216
  } else {
226
217
  uiComponent = ui;
@@ -238,7 +229,7 @@ function processToolResult(result, _tool) {
238
229
  uiComponent = {
239
230
  ...result,
240
231
  renderKey,
241
- render: void 0
232
+ render: undefined
242
233
  };
243
234
  } else {
244
235
  uiComponent = result;
@@ -250,42 +241,40 @@ function processToolResult(result, _tool) {
250
241
  }
251
242
  return {
252
243
  resultData: typeof result === "string" ? result : JSON.stringify(result),
253
- uiComponent: void 0
244
+ uiComponent: undefined
254
245
  };
255
246
  }
256
247
  function useAgnoToolExecution(handlers = {}, autoExecute = true) {
257
248
  const client = useAgnoClient();
258
249
  const toolHandlerContext = useToolHandlers();
259
250
  const isTeamMode = client.getConfig().mode === "team";
260
- (0, import_react3.useEffect)(() => {
251
+ import_react3.useEffect(() => {
261
252
  if (isTeamMode) {
262
- console.warn(
263
- "[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."
264
- );
253
+ 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.");
265
254
  }
266
255
  }, [isTeamMode]);
267
- const mergedHandlers = (0, import_react3.useMemo)(() => {
256
+ const mergedHandlers = import_react3.useMemo(() => {
268
257
  const globalHandlers = toolHandlerContext?.handlers || {};
269
258
  return { ...globalHandlers, ...handlers };
270
259
  }, [toolHandlerContext?.handlers, handlers]);
271
- const [pendingTools, setPendingTools] = (0, import_react3.useState)([]);
272
- const [isPaused, setIsPaused] = (0, import_react3.useState)(false);
273
- const [isExecuting, setIsExecuting] = (0, import_react3.useState)(false);
274
- const [executionError, setExecutionError] = (0, import_react3.useState)();
275
- (0, import_react3.useEffect)(() => {
260
+ const [pendingTools, setPendingTools] = import_react3.useState([]);
261
+ const [isPaused, setIsPaused] = import_react3.useState(false);
262
+ const [isExecuting, setIsExecuting] = import_react3.useState(false);
263
+ const [executionError, setExecutionError] = import_react3.useState();
264
+ import_react3.useEffect(() => {
276
265
  if (isTeamMode) {
277
266
  return;
278
267
  }
279
268
  const handleRunPaused = (event) => {
280
269
  setIsPaused(true);
281
270
  setPendingTools(event.tools);
282
- setExecutionError(void 0);
271
+ setExecutionError(undefined);
283
272
  };
284
273
  const handleRunContinued = () => {
285
274
  setIsPaused(false);
286
275
  setPendingTools([]);
287
276
  setIsExecuting(false);
288
- setExecutionError(void 0);
277
+ setExecutionError(undefined);
289
278
  };
290
279
  client.on("run:paused", handleRunPaused);
291
280
  client.on("run:continued", handleRunContinued);
@@ -294,43 +283,41 @@ function useAgnoToolExecution(handlers = {}, autoExecute = true) {
294
283
  client.off("run:continued", handleRunContinued);
295
284
  };
296
285
  }, [client, isTeamMode]);
297
- const executeAndContinue = (0, import_react3.useCallback)(async () => {
286
+ const executeAndContinue = import_react3.useCallback(async () => {
298
287
  if (!isPaused || pendingTools.length === 0) {
299
288
  console.warn("[useAgnoToolExecution] Cannot execute: no pending tools");
300
289
  return;
301
290
  }
302
291
  setIsExecuting(true);
303
- setExecutionError(void 0);
292
+ setExecutionError(undefined);
304
293
  try {
305
- const updatedTools = await Promise.all(
306
- pendingTools.map(async (tool) => {
307
- const handler = mergedHandlers[tool.tool_name];
308
- if (!handler) {
309
- return {
310
- ...tool,
311
- result: JSON.stringify({
312
- error: `No handler registered for ${tool.tool_name}`
313
- })
314
- };
315
- }
316
- try {
317
- const result = await handler(tool.tool_args);
318
- const { resultData, uiComponent } = processToolResult(result, tool);
319
- return {
320
- ...tool,
321
- result: resultData,
322
- ui_component: uiComponent
323
- };
324
- } catch (error) {
325
- return {
326
- ...tool,
327
- result: JSON.stringify({
328
- error: error instanceof Error ? error.message : String(error)
329
- })
330
- };
331
- }
332
- })
333
- );
294
+ const updatedTools = await Promise.all(pendingTools.map(async (tool) => {
295
+ const handler = mergedHandlers[tool.tool_name];
296
+ if (!handler) {
297
+ return {
298
+ ...tool,
299
+ result: JSON.stringify({
300
+ error: `No handler registered for ${tool.tool_name}`
301
+ })
302
+ };
303
+ }
304
+ try {
305
+ const result = await handler(tool.tool_args);
306
+ const { resultData, uiComponent } = processToolResult(result, tool);
307
+ return {
308
+ ...tool,
309
+ result: resultData,
310
+ ui_component: uiComponent
311
+ };
312
+ } catch (error) {
313
+ return {
314
+ ...tool,
315
+ result: JSON.stringify({
316
+ error: error instanceof Error ? error.message : String(error)
317
+ })
318
+ };
319
+ }
320
+ }));
334
321
  const toolsWithUI = updatedTools.filter((t) => t.ui_component);
335
322
  if (toolsWithUI.length > 0) {
336
323
  client.emit("ui:render", {
@@ -347,15 +334,18 @@ function useAgnoToolExecution(handlers = {}, autoExecute = true) {
347
334
  throw error;
348
335
  }
349
336
  }, [client, mergedHandlers, isPaused, pendingTools]);
350
- (0, import_react3.useEffect)(() => {
337
+ import_react3.useEffect(() => {
351
338
  const handleSessionLoaded = async (_sessionId) => {
352
339
  const messages = client.getMessages();
353
340
  for (const message of messages) {
354
- if (!message.tool_calls) continue;
341
+ if (!message.tool_calls)
342
+ continue;
355
343
  for (const tool of message.tool_calls) {
356
- if (tool.ui_component) continue;
344
+ if (tool.ui_component)
345
+ continue;
357
346
  const handler = mergedHandlers[tool.tool_name];
358
- if (!handler) continue;
347
+ if (!handler)
348
+ continue;
359
349
  try {
360
350
  const result = await handler(tool.tool_args);
361
351
  const { uiComponent } = processToolResult(result, tool);
@@ -373,74 +363,61 @@ function useAgnoToolExecution(handlers = {}, autoExecute = true) {
373
363
  client.off("session:loaded", handleSessionLoaded);
374
364
  };
375
365
  }, [client, mergedHandlers]);
376
- const executeTools = (0, import_react3.useCallback)(
377
- async (tools) => {
378
- return Promise.all(
379
- tools.map(async (tool) => {
380
- const handler = mergedHandlers[tool.tool_name];
381
- if (!handler) return tool;
382
- try {
383
- const result = await handler(tool.tool_args);
384
- const { resultData, uiComponent } = processToolResult(result, tool);
385
- return {
386
- ...tool,
387
- result: resultData,
388
- ui_component: uiComponent
389
- };
390
- } catch (error) {
391
- return {
392
- ...tool,
393
- result: JSON.stringify({
394
- error: error instanceof Error ? error.message : String(error)
395
- })
396
- };
397
- }
398
- })
399
- );
400
- },
401
- [mergedHandlers]
402
- );
403
- const continueWithResults = (0, import_react3.useCallback)(
404
- async (tools, options) => {
405
- if (!isPaused) {
406
- throw new Error("No paused run to continue");
407
- }
408
- setIsExecuting(true);
366
+ const executeTools = import_react3.useCallback(async (tools) => {
367
+ return Promise.all(tools.map(async (tool) => {
368
+ const handler = mergedHandlers[tool.tool_name];
369
+ if (!handler)
370
+ return tool;
409
371
  try {
410
- await client.continueRun(tools, options);
372
+ const result = await handler(tool.tool_args);
373
+ const { resultData, uiComponent } = processToolResult(result, tool);
374
+ return {
375
+ ...tool,
376
+ result: resultData,
377
+ ui_component: uiComponent
378
+ };
411
379
  } catch (error) {
412
- setIsExecuting(false);
413
- throw error;
380
+ return {
381
+ ...tool,
382
+ result: JSON.stringify({
383
+ error: error instanceof Error ? error.message : String(error)
384
+ })
385
+ };
414
386
  }
415
- },
416
- [client, isPaused]
417
- );
418
- (0, import_react3.useEffect)(() => {
387
+ }));
388
+ }, [mergedHandlers]);
389
+ const continueWithResults = import_react3.useCallback(async (tools, options) => {
390
+ if (!isPaused) {
391
+ throw new Error("No paused run to continue");
392
+ }
393
+ setIsExecuting(true);
394
+ try {
395
+ await client.continueRun(tools, options);
396
+ } catch (error) {
397
+ setIsExecuting(false);
398
+ throw error;
399
+ }
400
+ }, [client, isPaused]);
401
+ import_react3.useEffect(() => {
419
402
  if (autoExecute && isPaused && !isExecuting && pendingTools.length > 0) {
420
403
  executeAndContinue();
421
404
  }
422
405
  }, [autoExecute, isPaused, isExecuting, pendingTools.length, executeAndContinue]);
423
406
  return {
424
- /** Whether the run is currently paused awaiting tool execution */
425
407
  isPaused,
426
- /** Whether tools are currently being executed */
427
408
  isExecuting,
428
- /** Tools awaiting execution */
429
409
  pendingTools,
430
- /** Execute all pending tools and continue the run */
431
410
  executeAndContinue,
432
- /** Execute specific tools and return results without continuing */
433
411
  executeTools,
434
- /** Continue the run with manually provided tool results */
435
412
  continueWithResults,
436
- /** Error from tool execution, if any */
437
413
  executionError
438
414
  };
439
415
  }
440
416
 
441
417
  // src/components/GenerativeUIRenderer.tsx
442
- var import_jsx_runtime3 = require("react/jsx-runtime");
443
- var UIErrorBoundary = class extends import_react4.default.Component {
418
+ var jsx_dev_runtime3 = require("react/jsx-dev-runtime");
419
+
420
+ class UIErrorBoundary extends import_react4.default.Component {
444
421
  constructor(props) {
445
422
  super(props);
446
423
  this.state = { hasError: false };
@@ -454,14 +431,23 @@ var UIErrorBoundary = class extends import_react4.default.Component {
454
431
  }
455
432
  render() {
456
433
  if (this.state.hasError) {
457
- return this.props.fallback || /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "p-4 border border-red-300 rounded-md bg-red-50 text-red-800", children: [
458
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "font-semibold", children: "Failed to render UI component" }),
459
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "text-sm mt-1", children: this.state.error?.message || "Unknown error" })
460
- ] });
434
+ return this.props.fallback || /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
435
+ className: "p-4 border border-red-300 rounded-md bg-red-50 text-red-800",
436
+ children: [
437
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
438
+ className: "font-semibold",
439
+ children: "Failed to render UI component"
440
+ }, undefined, false, undefined, this),
441
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
442
+ className: "text-sm mt-1",
443
+ children: this.state.error?.message || "Unknown error"
444
+ }, undefined, false, undefined, this)
445
+ ]
446
+ }, undefined, true, undefined, this);
461
447
  }
462
448
  return this.props.children;
463
449
  }
464
- };
450
+ }
465
451
  function GenerativeUIRenderer({
466
452
  spec,
467
453
  className,
@@ -473,78 +459,184 @@ function GenerativeUIRenderer({
473
459
  if (customSpec.renderKey) {
474
460
  const renderFn = getCustomRender(customSpec.renderKey);
475
461
  if (renderFn) {
476
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(UIErrorBoundary, { onError, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className, children: renderFn(customSpec.props || {}) }) });
462
+ return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(UIErrorBoundary, {
463
+ onError,
464
+ children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
465
+ className,
466
+ children: renderFn(customSpec.props || {})
467
+ }, undefined, false, undefined, this)
468
+ }, undefined, false, undefined, this);
477
469
  }
478
470
  }
479
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: `p-4 border border-yellow-300 rounded-md bg-yellow-50 text-yellow-800 ${className || ""}`, children: [
480
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "font-semibold", children: "Custom component not available" }),
481
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "text-sm mt-1", children: "The custom render function for this component is not available." })
482
- ] });
471
+ return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
472
+ className: `p-4 border border-yellow-300 rounded-md bg-yellow-50 text-yellow-800 ${className || ""}`,
473
+ children: [
474
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
475
+ className: "font-semibold",
476
+ children: "Custom component not available"
477
+ }, undefined, false, undefined, this),
478
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
479
+ className: "text-sm mt-1",
480
+ children: "The custom render function for this component is not available."
481
+ }, undefined, false, undefined, this)
482
+ ]
483
+ }, undefined, true, undefined, this);
483
484
  }
484
485
  if (spec.type === "chart") {
485
486
  const chartSpec = spec;
486
487
  const chartType = `chart:${chartSpec.component}`;
487
488
  if (registry.has(chartType)) {
488
489
  const ChartRenderer = registry.get(chartType);
489
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(UIErrorBoundary, { onError, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className, children: [
490
- chartSpec.title && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h3", { className: "font-semibold mb-2", children: chartSpec.title }),
491
- chartSpec.description && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "text-sm text-gray-600 mb-4", children: chartSpec.description }),
492
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChartRenderer, { ...chartSpec.props })
493
- ] }) });
494
- }
495
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: `p-4 border border-gray-300 rounded-md ${className || ""}`, children: [
496
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "font-semibold mb-2", children: chartSpec.title || "Chart Data" }),
497
- chartSpec.description && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "text-sm text-gray-600 mb-2", children: chartSpec.description }),
498
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("pre", { className: "text-xs bg-gray-100 p-2 rounded overflow-auto", children: JSON.stringify(chartSpec.props.data, null, 2) })
499
- ] });
490
+ return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(UIErrorBoundary, {
491
+ onError,
492
+ children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
493
+ className,
494
+ children: [
495
+ chartSpec.title && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("h3", {
496
+ className: "font-semibold mb-2",
497
+ children: chartSpec.title
498
+ }, undefined, false, undefined, this),
499
+ chartSpec.description && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
500
+ className: "text-sm text-gray-600 mb-4",
501
+ children: chartSpec.description
502
+ }, undefined, false, undefined, this),
503
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ChartRenderer, {
504
+ ...chartSpec.props
505
+ }, undefined, false, undefined, this)
506
+ ]
507
+ }, undefined, true, undefined, this)
508
+ }, undefined, false, undefined, this);
509
+ }
510
+ return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
511
+ className: `p-4 border border-gray-300 rounded-md ${className || ""}`,
512
+ children: [
513
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
514
+ className: "font-semibold mb-2",
515
+ children: chartSpec.title || "Chart Data"
516
+ }, undefined, false, undefined, this),
517
+ chartSpec.description && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
518
+ className: "text-sm text-gray-600 mb-2",
519
+ children: chartSpec.description
520
+ }, undefined, false, undefined, this),
521
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("pre", {
522
+ className: "text-xs bg-gray-100 p-2 rounded overflow-auto",
523
+ children: JSON.stringify(chartSpec.props.data, null, 2)
524
+ }, undefined, false, undefined, this)
525
+ ]
526
+ }, undefined, true, undefined, this);
500
527
  }
501
528
  if (spec.type === "card-grid") {
502
529
  const cardGridSpec = spec;
503
530
  if (registry.has("card-grid")) {
504
531
  const CardGridRenderer = registry.get("card-grid");
505
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(UIErrorBoundary, { onError, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className, children: [
506
- cardGridSpec.title && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h3", { className: "font-semibold mb-2", children: cardGridSpec.title }),
507
- cardGridSpec.description && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "text-sm text-gray-600 mb-4", children: cardGridSpec.description }),
508
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CardGridRenderer, { ...cardGridSpec.props })
509
- ] }) });
532
+ return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(UIErrorBoundary, {
533
+ onError,
534
+ children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
535
+ className,
536
+ children: [
537
+ cardGridSpec.title && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("h3", {
538
+ className: "font-semibold mb-2",
539
+ children: cardGridSpec.title
540
+ }, undefined, false, undefined, this),
541
+ cardGridSpec.description && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
542
+ className: "text-sm text-gray-600 mb-4",
543
+ children: cardGridSpec.description
544
+ }, undefined, false, undefined, this),
545
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(CardGridRenderer, {
546
+ ...cardGridSpec.props
547
+ }, undefined, false, undefined, this)
548
+ ]
549
+ }, undefined, true, undefined, this)
550
+ }, undefined, false, undefined, this);
510
551
  }
511
552
  }
512
553
  if (spec.type === "table") {
513
554
  const tableSpec = spec;
514
555
  if (registry.has("table")) {
515
556
  const TableRenderer = registry.get("table");
516
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(UIErrorBoundary, { onError, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className, children: [
517
- tableSpec.title && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h3", { className: "font-semibold mb-2", children: tableSpec.title }),
518
- tableSpec.description && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "text-sm text-gray-600 mb-4", children: tableSpec.description }),
519
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TableRenderer, { ...tableSpec.props })
520
- ] }) });
557
+ return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(UIErrorBoundary, {
558
+ onError,
559
+ children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
560
+ className,
561
+ children: [
562
+ tableSpec.title && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("h3", {
563
+ className: "font-semibold mb-2",
564
+ children: tableSpec.title
565
+ }, undefined, false, undefined, this),
566
+ tableSpec.description && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
567
+ className: "text-sm text-gray-600 mb-4",
568
+ children: tableSpec.description
569
+ }, undefined, false, undefined, this),
570
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(TableRenderer, {
571
+ ...tableSpec.props
572
+ }, undefined, false, undefined, this)
573
+ ]
574
+ }, undefined, true, undefined, this)
575
+ }, undefined, false, undefined, this);
521
576
  }
522
577
  }
523
578
  if (spec.type === "markdown") {
524
579
  const markdownSpec = spec;
525
580
  if (registry.has("markdown")) {
526
581
  const MarkdownRenderer = registry.get("markdown");
527
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(UIErrorBoundary, { onError, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MarkdownRenderer, { ...markdownSpec.props }) }) });
582
+ return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(UIErrorBoundary, {
583
+ onError,
584
+ children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
585
+ className,
586
+ children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(MarkdownRenderer, {
587
+ ...markdownSpec.props
588
+ }, undefined, false, undefined, this)
589
+ }, undefined, false, undefined, this)
590
+ }, undefined, false, undefined, this);
528
591
  }
529
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className, children: markdownSpec.props.content });
592
+ return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
593
+ className,
594
+ children: markdownSpec.props.content
595
+ }, undefined, false, undefined, this);
530
596
  }
531
597
  if (spec.type === "artifact") {
532
598
  const artifactSpec = spec;
533
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(UIErrorBoundary, { onError, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: `p-4 border rounded-md ${className || ""}`, children: [
534
- artifactSpec.title && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h3", { className: "font-semibold mb-4", children: artifactSpec.title }),
535
- artifactSpec.description && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "text-sm text-gray-600 mb-4", children: artifactSpec.description }),
536
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "space-y-4", children: artifactSpec.props.content?.map((childSpec, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(GenerativeUIRenderer, { spec: childSpec, onError }, index)) })
537
- ] }) });
599
+ return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(UIErrorBoundary, {
600
+ onError,
601
+ children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
602
+ className: `p-4 border rounded-md ${className || ""}`,
603
+ children: [
604
+ artifactSpec.title && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("h3", {
605
+ className: "font-semibold mb-4",
606
+ children: artifactSpec.title
607
+ }, undefined, false, undefined, this),
608
+ artifactSpec.description && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
609
+ className: "text-sm text-gray-600 mb-4",
610
+ children: artifactSpec.description
611
+ }, undefined, false, undefined, this),
612
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
613
+ className: "space-y-4",
614
+ children: artifactSpec.props.content?.map((childSpec, index) => /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(GenerativeUIRenderer, {
615
+ spec: childSpec,
616
+ onError
617
+ }, index, false, undefined, this))
618
+ }, undefined, false, undefined, this)
619
+ ]
620
+ }, undefined, true, undefined, this)
621
+ }, undefined, false, undefined, this);
538
622
  }
539
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: `p-4 border border-gray-300 rounded-md ${className || ""}`, children: [
540
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "font-semibold", children: "Unsupported UI component" }),
541
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { className: "text-sm text-gray-600 mt-1", children: [
542
- "Component type: ",
543
- spec.type
544
- ] })
545
- ] });
623
+ return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
624
+ className: `p-4 border border-gray-300 rounded-md ${className || ""}`,
625
+ children: [
626
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
627
+ className: "font-semibold",
628
+ children: "Unsupported UI component"
629
+ }, undefined, false, undefined, this),
630
+ /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
631
+ className: "text-sm text-gray-600 mt-1",
632
+ children: [
633
+ "Component type: ",
634
+ spec.type
635
+ ]
636
+ }, undefined, true, undefined, this)
637
+ ]
638
+ }, undefined, true, undefined, this);
546
639
  }
547
-
548
640
  // src/utils/ui-helpers.ts
549
641
  function createBarChart(data, xKey, bars, options) {
550
642
  return {
@@ -710,34 +802,17 @@ function createSmartChart(data, options) {
710
802
  }
711
803
  const firstItem = data[0];
712
804
  const keys = Object.keys(firstItem);
713
- const xKey = options?.xKey || keys.find(
714
- (k) => ["name", "label", "category", "date", "time", "month", "year"].includes(k.toLowerCase())
715
- ) || keys[0];
805
+ const xKey = options?.xKey || keys.find((k) => ["name", "label", "category", "date", "time", "month", "year"].includes(k.toLowerCase())) || keys[0];
716
806
  const numericKeys = keys.filter((k) => k !== xKey && typeof firstItem[k] === "number");
717
807
  const yKeys = options?.yKeys || numericKeys;
718
808
  if (options?.preferredType) {
719
809
  switch (options.preferredType) {
720
810
  case "bar":
721
- return createBarChart(
722
- data,
723
- xKey,
724
- yKeys.map((key) => ({ key })),
725
- options
726
- );
811
+ return createBarChart(data, xKey, yKeys.map((key) => ({ key })), options);
727
812
  case "line":
728
- return createLineChart(
729
- data,
730
- xKey,
731
- yKeys.map((key) => ({ key })),
732
- options
733
- );
813
+ return createLineChart(data, xKey, yKeys.map((key) => ({ key })), options);
734
814
  case "area":
735
- return createAreaChart(
736
- data,
737
- xKey,
738
- yKeys.map((key) => ({ key })),
739
- options
740
- );
815
+ return createAreaChart(data, xKey, yKeys.map((key) => ({ key })), options);
741
816
  case "pie":
742
817
  return createPieChart(data, yKeys[0], xKey, options);
743
818
  }
@@ -746,19 +821,9 @@ function createSmartChart(data, options) {
746
821
  return createPieChart(data, yKeys[0], xKey, options);
747
822
  }
748
823
  if (xKey.toLowerCase().includes("date") || xKey.toLowerCase().includes("time") || xKey.toLowerCase().includes("month") || xKey.toLowerCase().includes("year")) {
749
- return createLineChart(
750
- data,
751
- xKey,
752
- yKeys.map((key) => ({ key })),
753
- options
754
- );
824
+ return createLineChart(data, xKey, yKeys.map((key) => ({ key })), options);
755
825
  }
756
- return createBarChart(
757
- data,
758
- xKey,
759
- yKeys.map((key) => ({ key })),
760
- options
761
- );
826
+ return createBarChart(data, xKey, yKeys.map((key) => ({ key })), options);
762
827
  }
763
828
  function createToolResult(data, ui) {
764
829
  return { data, ui };
@@ -775,15 +840,14 @@ function resultWithCardGrid(cards, options) {
775
840
  function resultWithTable(data, columns, options) {
776
841
  return createToolResult(data, createTable(data, columns, options));
777
842
  }
778
-
779
843
  // src/hooks/useAgnoChat.ts
780
844
  var import_react5 = require("react");
781
845
  function useAgnoChat() {
782
846
  const client = useAgnoClient();
783
- const [messages, setMessages] = (0, import_react5.useState)(client.getMessages());
784
- const [state, setState] = (0, import_react5.useState)(client.getState());
785
- const [error, setError] = (0, import_react5.useState)();
786
- (0, import_react5.useEffect)(() => {
847
+ const [messages, setMessages] = import_react5.useState(client.getMessages());
848
+ const [state, setState] = import_react5.useState(client.getState());
849
+ const [error, setError] = import_react5.useState();
850
+ import_react5.useEffect(() => {
787
851
  const handleMessageUpdate = (updatedMessages) => {
788
852
  setMessages(updatedMessages);
789
853
  };
@@ -807,8 +871,7 @@ function useAgnoChat() {
807
871
  }
808
872
  }
809
873
  };
810
- const handleRunCancelled = () => {
811
- };
874
+ const handleRunCancelled = () => {};
812
875
  client.on("message:update", handleMessageUpdate);
813
876
  client.on("message:complete", handleMessageComplete);
814
877
  client.on("message:refreshed", handleMessageRefreshed);
@@ -828,25 +891,22 @@ function useAgnoChat() {
828
891
  client.off("run:cancelled", handleRunCancelled);
829
892
  };
830
893
  }, [client]);
831
- const sendMessage = (0, import_react5.useCallback)(
832
- async (message, options) => {
833
- setError(void 0);
834
- try {
835
- await client.sendMessage(message, options);
836
- } catch (err) {
837
- const errorMessage = err instanceof Error ? err.message : String(err);
838
- setError(errorMessage);
839
- throw err;
840
- }
841
- },
842
- [client]
843
- );
844
- const clearMessages = (0, import_react5.useCallback)(() => {
894
+ const sendMessage = import_react5.useCallback(async (message, options) => {
895
+ setError(undefined);
896
+ try {
897
+ await client.sendMessage(message, options);
898
+ } catch (err) {
899
+ const errorMessage = err instanceof Error ? err.message : String(err);
900
+ setError(errorMessage);
901
+ throw err;
902
+ }
903
+ }, [client]);
904
+ const clearMessages = import_react5.useCallback(() => {
845
905
  client.clearMessages();
846
906
  setMessages([]);
847
- setError(void 0);
907
+ setError(undefined);
848
908
  }, [client]);
849
- const cancelRun = (0, import_react5.useCallback)(async () => {
909
+ const cancelRun = import_react5.useCallback(async () => {
850
910
  try {
851
911
  await client.cancelRun();
852
912
  } catch (err) {
@@ -869,18 +929,15 @@ function useAgnoChat() {
869
929
  state
870
930
  };
871
931
  }
872
-
873
932
  // src/hooks/useAgnoSession.ts
874
933
  var import_react6 = require("react");
875
934
  function useAgnoSession() {
876
935
  const client = useAgnoClient();
877
- const [sessions, setSessions] = (0, import_react6.useState)([]);
878
- const [currentSessionId, setCurrentSessionId] = (0, import_react6.useState)(
879
- client.getConfig().sessionId
880
- );
881
- const [isLoading, setIsLoading] = (0, import_react6.useState)(false);
882
- const [error, setError] = (0, import_react6.useState)();
883
- (0, import_react6.useEffect)(() => {
936
+ const [sessions, setSessions] = import_react6.useState([]);
937
+ const [currentSessionId, setCurrentSessionId] = import_react6.useState(client.getConfig().sessionId);
938
+ const [isLoading, setIsLoading] = import_react6.useState(false);
939
+ const [error, setError] = import_react6.useState();
940
+ import_react6.useEffect(() => {
884
941
  const handleSessionLoaded = (sessionId) => {
885
942
  setCurrentSessionId(sessionId);
886
943
  };
@@ -904,27 +961,24 @@ function useAgnoSession() {
904
961
  client.off("state:change", handleStateChange);
905
962
  };
906
963
  }, [client]);
907
- const loadSession = (0, import_react6.useCallback)(
908
- async (sessionId, options) => {
909
- setIsLoading(true);
910
- setError(void 0);
911
- try {
912
- const messages = await client.loadSession(sessionId, options);
913
- setCurrentSessionId(sessionId);
914
- return messages;
915
- } catch (err) {
916
- const errorMessage = err instanceof Error ? err.message : String(err);
917
- setError(errorMessage);
918
- throw err;
919
- } finally {
920
- setIsLoading(false);
921
- }
922
- },
923
- [client]
924
- );
925
- const fetchSessions = (0, import_react6.useCallback)(async (options) => {
964
+ const loadSession = import_react6.useCallback(async (sessionId, options) => {
965
+ setIsLoading(true);
966
+ setError(undefined);
967
+ try {
968
+ const messages = await client.loadSession(sessionId, options);
969
+ setCurrentSessionId(sessionId);
970
+ return messages;
971
+ } catch (err) {
972
+ const errorMessage = err instanceof Error ? err.message : String(err);
973
+ setError(errorMessage);
974
+ throw err;
975
+ } finally {
976
+ setIsLoading(false);
977
+ }
978
+ }, [client]);
979
+ const fetchSessions = import_react6.useCallback(async (options) => {
926
980
  setIsLoading(true);
927
- setError(void 0);
981
+ setError(undefined);
928
982
  try {
929
983
  const fetchedSessions = await client.fetchSessions(options);
930
984
  setSessions(fetchedSessions);
@@ -937,119 +991,98 @@ function useAgnoSession() {
937
991
  setIsLoading(false);
938
992
  }
939
993
  }, [client]);
940
- const getSessionById = (0, import_react6.useCallback)(
941
- async (sessionId, options) => {
942
- setIsLoading(true);
943
- setError(void 0);
944
- try {
945
- return await client.getSessionById(sessionId, options);
946
- } catch (err) {
947
- const errorMessage = err instanceof Error ? err.message : String(err);
948
- setError(errorMessage);
949
- throw err;
950
- } finally {
951
- setIsLoading(false);
952
- }
953
- },
954
- [client]
955
- );
956
- const getRunById = (0, import_react6.useCallback)(
957
- async (sessionId, runId, options) => {
958
- setIsLoading(true);
959
- setError(void 0);
960
- try {
961
- return await client.getRunById(sessionId, runId, options);
962
- } catch (err) {
963
- const errorMessage = err instanceof Error ? err.message : String(err);
964
- setError(errorMessage);
965
- throw err;
966
- } finally {
967
- setIsLoading(false);
968
- }
969
- },
970
- [client]
971
- );
972
- const createSession = (0, import_react6.useCallback)(
973
- async (request, options) => {
974
- setIsLoading(true);
975
- setError(void 0);
976
- try {
977
- const session = await client.createSession(request, options);
978
- return session;
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
- },
987
- [client]
988
- );
989
- const updateSession = (0, import_react6.useCallback)(
990
- async (sessionId, request, options) => {
991
- setIsLoading(true);
992
- setError(void 0);
993
- try {
994
- return await client.updateSession(sessionId, request, 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
- },
1003
- [client]
1004
- );
1005
- const renameSession = (0, import_react6.useCallback)(
1006
- async (sessionId, newName, options) => {
1007
- setIsLoading(true);
1008
- setError(void 0);
1009
- try {
1010
- return await client.renameSession(sessionId, newName, options);
1011
- } catch (err) {
1012
- const errorMessage = err instanceof Error ? err.message : String(err);
1013
- setError(errorMessage);
1014
- throw err;
1015
- } finally {
1016
- setIsLoading(false);
1017
- }
1018
- },
1019
- [client]
1020
- );
1021
- const deleteSession = (0, import_react6.useCallback)(
1022
- async (sessionId, options) => {
1023
- setIsLoading(true);
1024
- setError(void 0);
1025
- try {
1026
- await client.deleteSession(sessionId, options);
1027
- } catch (err) {
1028
- const errorMessage = err instanceof Error ? err.message : String(err);
1029
- setError(errorMessage);
1030
- throw err;
1031
- } finally {
1032
- setIsLoading(false);
1033
- }
1034
- },
1035
- [client]
1036
- );
1037
- const deleteMultipleSessions = (0, import_react6.useCallback)(
1038
- async (sessionIds, options) => {
1039
- setIsLoading(true);
1040
- setError(void 0);
1041
- try {
1042
- await client.deleteMultipleSessions(sessionIds, options);
1043
- } catch (err) {
1044
- const errorMessage = err instanceof Error ? err.message : String(err);
1045
- setError(errorMessage);
1046
- throw err;
1047
- } finally {
1048
- setIsLoading(false);
1049
- }
1050
- },
1051
- [client]
1052
- );
994
+ const getSessionById = import_react6.useCallback(async (sessionId, options) => {
995
+ setIsLoading(true);
996
+ setError(undefined);
997
+ try {
998
+ return await client.getSessionById(sessionId, options);
999
+ } catch (err) {
1000
+ const errorMessage = err instanceof Error ? err.message : String(err);
1001
+ setError(errorMessage);
1002
+ throw err;
1003
+ } finally {
1004
+ setIsLoading(false);
1005
+ }
1006
+ }, [client]);
1007
+ const getRunById = import_react6.useCallback(async (sessionId, runId, options) => {
1008
+ setIsLoading(true);
1009
+ setError(undefined);
1010
+ try {
1011
+ return await client.getRunById(sessionId, runId, options);
1012
+ } catch (err) {
1013
+ const errorMessage = err instanceof Error ? err.message : String(err);
1014
+ setError(errorMessage);
1015
+ throw err;
1016
+ } finally {
1017
+ setIsLoading(false);
1018
+ }
1019
+ }, [client]);
1020
+ const createSession = import_react6.useCallback(async (request, options) => {
1021
+ setIsLoading(true);
1022
+ setError(undefined);
1023
+ try {
1024
+ const session = await client.createSession(request, options);
1025
+ return session;
1026
+ } catch (err) {
1027
+ const errorMessage = err instanceof Error ? err.message : String(err);
1028
+ setError(errorMessage);
1029
+ throw err;
1030
+ } finally {
1031
+ setIsLoading(false);
1032
+ }
1033
+ }, [client]);
1034
+ const updateSession = import_react6.useCallback(async (sessionId, request, options) => {
1035
+ setIsLoading(true);
1036
+ setError(undefined);
1037
+ try {
1038
+ return await client.updateSession(sessionId, request, options);
1039
+ } catch (err) {
1040
+ const errorMessage = err instanceof Error ? err.message : String(err);
1041
+ setError(errorMessage);
1042
+ throw err;
1043
+ } finally {
1044
+ setIsLoading(false);
1045
+ }
1046
+ }, [client]);
1047
+ const renameSession = import_react6.useCallback(async (sessionId, newName, options) => {
1048
+ setIsLoading(true);
1049
+ setError(undefined);
1050
+ try {
1051
+ return await client.renameSession(sessionId, newName, options);
1052
+ } catch (err) {
1053
+ const errorMessage = err instanceof Error ? err.message : String(err);
1054
+ setError(errorMessage);
1055
+ throw err;
1056
+ } finally {
1057
+ setIsLoading(false);
1058
+ }
1059
+ }, [client]);
1060
+ const deleteSession = import_react6.useCallback(async (sessionId, options) => {
1061
+ setIsLoading(true);
1062
+ setError(undefined);
1063
+ try {
1064
+ await client.deleteSession(sessionId, options);
1065
+ } catch (err) {
1066
+ const errorMessage = err instanceof Error ? err.message : String(err);
1067
+ setError(errorMessage);
1068
+ throw err;
1069
+ } finally {
1070
+ setIsLoading(false);
1071
+ }
1072
+ }, [client]);
1073
+ const deleteMultipleSessions = import_react6.useCallback(async (sessionIds, options) => {
1074
+ setIsLoading(true);
1075
+ setError(undefined);
1076
+ try {
1077
+ await client.deleteMultipleSessions(sessionIds, options);
1078
+ } catch (err) {
1079
+ const errorMessage = err instanceof Error ? err.message : String(err);
1080
+ setError(errorMessage);
1081
+ throw err;
1082
+ } finally {
1083
+ setIsLoading(false);
1084
+ }
1085
+ }, [client]);
1053
1086
  return {
1054
1087
  sessions,
1055
1088
  currentSessionId,
@@ -1066,16 +1099,15 @@ function useAgnoSession() {
1066
1099
  error
1067
1100
  };
1068
1101
  }
1069
-
1070
1102
  // src/hooks/useAgnoActions.ts
1071
1103
  var import_react7 = require("react");
1072
1104
  function useAgnoActions() {
1073
1105
  const client = useAgnoClient();
1074
- const [isInitializing, setIsInitializing] = (0, import_react7.useState)(false);
1075
- const [error, setError] = (0, import_react7.useState)();
1076
- const initialize = (0, import_react7.useCallback)(async (options) => {
1106
+ const [isInitializing, setIsInitializing] = import_react7.useState(false);
1107
+ const [error, setError] = import_react7.useState();
1108
+ const initialize = import_react7.useCallback(async (options) => {
1077
1109
  setIsInitializing(true);
1078
- setError(void 0);
1110
+ setError(undefined);
1079
1111
  try {
1080
1112
  const result = await client.initialize(options);
1081
1113
  return result;
@@ -1087,8 +1119,8 @@ function useAgnoActions() {
1087
1119
  setIsInitializing(false);
1088
1120
  }
1089
1121
  }, [client]);
1090
- const checkStatus = (0, import_react7.useCallback)(async (options) => {
1091
- setError(void 0);
1122
+ const checkStatus = import_react7.useCallback(async (options) => {
1123
+ setError(undefined);
1092
1124
  try {
1093
1125
  return await client.checkStatus(options);
1094
1126
  } catch (err) {
@@ -1097,8 +1129,8 @@ function useAgnoActions() {
1097
1129
  return false;
1098
1130
  }
1099
1131
  }, [client]);
1100
- const fetchAgents = (0, import_react7.useCallback)(async (options) => {
1101
- setError(void 0);
1132
+ const fetchAgents = import_react7.useCallback(async (options) => {
1133
+ setError(undefined);
1102
1134
  try {
1103
1135
  return await client.fetchAgents(options);
1104
1136
  } catch (err) {
@@ -1107,8 +1139,8 @@ function useAgnoActions() {
1107
1139
  throw err;
1108
1140
  }
1109
1141
  }, [client]);
1110
- const fetchTeams = (0, import_react7.useCallback)(async (options) => {
1111
- setError(void 0);
1142
+ const fetchTeams = import_react7.useCallback(async (options) => {
1143
+ setError(undefined);
1112
1144
  try {
1113
1145
  return await client.fetchTeams(options);
1114
1146
  } catch (err) {
@@ -1117,12 +1149,9 @@ function useAgnoActions() {
1117
1149
  throw err;
1118
1150
  }
1119
1151
  }, [client]);
1120
- const updateConfig = (0, import_react7.useCallback)(
1121
- (updates) => {
1122
- client.updateConfig(updates);
1123
- },
1124
- [client]
1125
- );
1152
+ const updateConfig = import_react7.useCallback((updates) => {
1153
+ client.updateConfig(updates);
1154
+ }, [client]);
1126
1155
  return {
1127
1156
  initialize,
1128
1157
  checkStatus,
@@ -1133,15 +1162,14 @@ function useAgnoActions() {
1133
1162
  error
1134
1163
  };
1135
1164
  }
1136
-
1137
1165
  // src/hooks/useAgnoCustomEvents.ts
1138
1166
  var import_react8 = require("react");
1139
1167
  function useAgnoCustomEvents(handler) {
1140
1168
  const client = useAgnoClient();
1141
- const [events, setEvents] = (0, import_react8.useState)([]);
1142
- const handlerRef = (0, import_react8.useRef)(handler);
1169
+ const [events, setEvents] = import_react8.useState([]);
1170
+ const handlerRef = import_react8.useRef(handler);
1143
1171
  handlerRef.current = handler;
1144
- (0, import_react8.useEffect)(() => {
1172
+ import_react8.useEffect(() => {
1145
1173
  const handleCustomEvent = (event) => {
1146
1174
  setEvents((prev) => [...prev, event]);
1147
1175
  handlerRef.current?.(event);
@@ -1151,28 +1179,25 @@ function useAgnoCustomEvents(handler) {
1151
1179
  client.off("custom:event", handleCustomEvent);
1152
1180
  };
1153
1181
  }, [client]);
1154
- const clearEvents = (0, import_react8.useCallback)(() => {
1182
+ const clearEvents = import_react8.useCallback(() => {
1155
1183
  setEvents([]);
1156
1184
  }, []);
1157
1185
  return { events, clearEvents };
1158
1186
  }
1159
-
1160
1187
  // src/hooks/useAgnoMemory.ts
1161
1188
  var import_react9 = require("react");
1162
1189
  function useAgnoMemory() {
1163
1190
  const client = useAgnoClient();
1164
- const [memories, setMemories] = (0, import_react9.useState)([]);
1165
- const [topics, setTopics] = (0, import_react9.useState)([]);
1166
- const [isLoading, setIsLoading] = (0, import_react9.useState)(false);
1167
- const [error, setError] = (0, import_react9.useState)();
1168
- (0, import_react9.useEffect)(() => {
1191
+ const [memories, setMemories] = import_react9.useState([]);
1192
+ const [topics, setTopics] = import_react9.useState([]);
1193
+ const [isLoading, setIsLoading] = import_react9.useState(false);
1194
+ const [error, setError] = import_react9.useState();
1195
+ import_react9.useEffect(() => {
1169
1196
  const handleMemoryCreated = (memory) => {
1170
1197
  setMemories((prev) => [memory, ...prev]);
1171
1198
  };
1172
1199
  const handleMemoryUpdated = (memory) => {
1173
- setMemories(
1174
- (prev) => prev.map((m) => m.memory_id === memory.memory_id ? memory : m)
1175
- );
1200
+ setMemories((prev) => prev.map((m) => m.memory_id === memory.memory_id ? memory : m));
1176
1201
  };
1177
1202
  const handleMemoryDeleted = ({ memoryId }) => {
1178
1203
  setMemories((prev) => prev.filter((m) => m.memory_id !== memoryId));
@@ -1202,328 +1227,270 @@ function useAgnoMemory() {
1202
1227
  client.off("state:change", handleStateChange);
1203
1228
  };
1204
1229
  }, [client]);
1205
- const fetchMemories = (0, import_react9.useCallback)(
1206
- async (queryParams, options) => {
1207
- setIsLoading(true);
1208
- setError(void 0);
1209
- try {
1210
- const response = await client.fetchMemories(queryParams, options);
1211
- setMemories(response.data);
1212
- return response;
1213
- } catch (err) {
1214
- const errorMessage = err instanceof Error ? err.message : String(err);
1215
- setError(errorMessage);
1216
- throw err;
1217
- } finally {
1218
- setIsLoading(false);
1219
- }
1220
- },
1221
- [client]
1222
- );
1223
- const getMemoryById = (0, import_react9.useCallback)(
1224
- async (memoryId, options) => {
1225
- setIsLoading(true);
1226
- setError(void 0);
1227
- try {
1228
- return await client.getMemoryById(memoryId, options);
1229
- } catch (err) {
1230
- const errorMessage = err instanceof Error ? err.message : String(err);
1231
- setError(errorMessage);
1232
- throw err;
1233
- } finally {
1234
- setIsLoading(false);
1235
- }
1236
- },
1237
- [client]
1238
- );
1239
- const getMemoryTopics = (0, import_react9.useCallback)(
1240
- async (options) => {
1241
- setIsLoading(true);
1242
- setError(void 0);
1243
- try {
1244
- const result = await client.getMemoryTopics(options);
1245
- setTopics(result);
1246
- return result;
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
- },
1255
- [client]
1256
- );
1257
- const getUserMemoryStats = (0, import_react9.useCallback)(
1258
- async (queryParams, options) => {
1259
- setIsLoading(true);
1260
- setError(void 0);
1261
- try {
1262
- return await client.getUserMemoryStats(queryParams, options);
1263
- } catch (err) {
1264
- const errorMessage = err instanceof Error ? err.message : String(err);
1265
- setError(errorMessage);
1266
- throw err;
1267
- } finally {
1268
- setIsLoading(false);
1269
- }
1270
- },
1271
- [client]
1272
- );
1273
- const createMemory = (0, import_react9.useCallback)(
1274
- async (request, options) => {
1275
- setIsLoading(true);
1276
- setError(void 0);
1277
- try {
1278
- return await client.createMemory(request, options);
1279
- } catch (err) {
1280
- const errorMessage = err instanceof Error ? err.message : String(err);
1281
- setError(errorMessage);
1282
- throw err;
1283
- } finally {
1284
- setIsLoading(false);
1285
- }
1286
- },
1287
- [client]
1288
- );
1289
- const updateMemory = (0, import_react9.useCallback)(
1290
- async (memoryId, request, options) => {
1291
- setIsLoading(true);
1292
- setError(void 0);
1293
- try {
1294
- return await client.updateMemory(memoryId, request, options);
1295
- } catch (err) {
1296
- const errorMessage = err instanceof Error ? err.message : String(err);
1297
- setError(errorMessage);
1298
- throw err;
1299
- } finally {
1300
- setIsLoading(false);
1301
- }
1302
- },
1303
- [client]
1304
- );
1305
- const deleteMemory = (0, import_react9.useCallback)(
1306
- async (memoryId, options) => {
1307
- setIsLoading(true);
1308
- setError(void 0);
1309
- try {
1310
- await client.deleteMemory(memoryId, options);
1311
- } catch (err) {
1312
- const errorMessage = err instanceof Error ? err.message : String(err);
1313
- setError(errorMessage);
1314
- throw err;
1315
- } finally {
1316
- setIsLoading(false);
1317
- }
1318
- },
1319
- [client]
1320
- );
1321
- const deleteMultipleMemories = (0, import_react9.useCallback)(
1322
- async (memoryIds, options) => {
1323
- setIsLoading(true);
1324
- setError(void 0);
1325
- try {
1326
- await client.deleteMultipleMemories(memoryIds, options);
1327
- } catch (err) {
1328
- const errorMessage = err instanceof Error ? err.message : String(err);
1329
- setError(errorMessage);
1330
- throw err;
1331
- } finally {
1332
- setIsLoading(false);
1333
- }
1334
- },
1335
- [client]
1336
- );
1337
- return {
1338
- memories,
1339
- topics,
1340
- isLoading,
1341
- error,
1342
- fetchMemories,
1343
- getMemoryById,
1344
- getMemoryTopics,
1345
- getUserMemoryStats,
1346
- createMemory,
1347
- updateMemory,
1348
- deleteMemory,
1349
- deleteMultipleMemories
1350
- };
1351
- }
1352
-
1353
- // src/hooks/useAgnoKnowledge.ts
1230
+ const fetchMemories = import_react9.useCallback(async (queryParams, options) => {
1231
+ setIsLoading(true);
1232
+ setError(undefined);
1233
+ try {
1234
+ const response = await client.fetchMemories(queryParams, options);
1235
+ setMemories(response.data);
1236
+ return response;
1237
+ } catch (err) {
1238
+ const errorMessage = err instanceof Error ? err.message : String(err);
1239
+ setError(errorMessage);
1240
+ throw err;
1241
+ } finally {
1242
+ setIsLoading(false);
1243
+ }
1244
+ }, [client]);
1245
+ const getMemoryById = import_react9.useCallback(async (memoryId, options) => {
1246
+ setIsLoading(true);
1247
+ setError(undefined);
1248
+ try {
1249
+ return await client.getMemoryById(memoryId, options);
1250
+ } catch (err) {
1251
+ const errorMessage = err instanceof Error ? err.message : String(err);
1252
+ setError(errorMessage);
1253
+ throw err;
1254
+ } finally {
1255
+ setIsLoading(false);
1256
+ }
1257
+ }, [client]);
1258
+ const getMemoryTopics = import_react9.useCallback(async (options) => {
1259
+ setIsLoading(true);
1260
+ setError(undefined);
1261
+ try {
1262
+ const result = await client.getMemoryTopics(options);
1263
+ setTopics(result);
1264
+ return result;
1265
+ } catch (err) {
1266
+ const errorMessage = err instanceof Error ? err.message : String(err);
1267
+ setError(errorMessage);
1268
+ throw err;
1269
+ } finally {
1270
+ setIsLoading(false);
1271
+ }
1272
+ }, [client]);
1273
+ const getUserMemoryStats = import_react9.useCallback(async (queryParams, options) => {
1274
+ setIsLoading(true);
1275
+ setError(undefined);
1276
+ try {
1277
+ return await client.getUserMemoryStats(queryParams, options);
1278
+ } catch (err) {
1279
+ const errorMessage = err instanceof Error ? err.message : String(err);
1280
+ setError(errorMessage);
1281
+ throw err;
1282
+ } finally {
1283
+ setIsLoading(false);
1284
+ }
1285
+ }, [client]);
1286
+ const createMemory = import_react9.useCallback(async (request, options) => {
1287
+ setIsLoading(true);
1288
+ setError(undefined);
1289
+ try {
1290
+ return await client.createMemory(request, options);
1291
+ } catch (err) {
1292
+ const errorMessage = err instanceof Error ? err.message : String(err);
1293
+ setError(errorMessage);
1294
+ throw err;
1295
+ } finally {
1296
+ setIsLoading(false);
1297
+ }
1298
+ }, [client]);
1299
+ const updateMemory = import_react9.useCallback(async (memoryId, request, options) => {
1300
+ setIsLoading(true);
1301
+ setError(undefined);
1302
+ try {
1303
+ return await client.updateMemory(memoryId, request, options);
1304
+ } catch (err) {
1305
+ const errorMessage = err instanceof Error ? err.message : String(err);
1306
+ setError(errorMessage);
1307
+ throw err;
1308
+ } finally {
1309
+ setIsLoading(false);
1310
+ }
1311
+ }, [client]);
1312
+ const deleteMemory = import_react9.useCallback(async (memoryId, options) => {
1313
+ setIsLoading(true);
1314
+ setError(undefined);
1315
+ try {
1316
+ await client.deleteMemory(memoryId, options);
1317
+ } catch (err) {
1318
+ const errorMessage = err instanceof Error ? err.message : String(err);
1319
+ setError(errorMessage);
1320
+ throw err;
1321
+ } finally {
1322
+ setIsLoading(false);
1323
+ }
1324
+ }, [client]);
1325
+ const deleteMultipleMemories = import_react9.useCallback(async (memoryIds, options) => {
1326
+ setIsLoading(true);
1327
+ setError(undefined);
1328
+ try {
1329
+ await client.deleteMultipleMemories(memoryIds, options);
1330
+ } catch (err) {
1331
+ const errorMessage = err instanceof Error ? err.message : String(err);
1332
+ setError(errorMessage);
1333
+ throw err;
1334
+ } finally {
1335
+ setIsLoading(false);
1336
+ }
1337
+ }, [client]);
1338
+ return {
1339
+ memories,
1340
+ topics,
1341
+ isLoading,
1342
+ error,
1343
+ fetchMemories,
1344
+ getMemoryById,
1345
+ getMemoryTopics,
1346
+ getUserMemoryStats,
1347
+ createMemory,
1348
+ updateMemory,
1349
+ deleteMemory,
1350
+ deleteMultipleMemories
1351
+ };
1352
+ }
1353
+ // src/hooks/useAgnoKnowledge.ts
1354
1354
  var import_react10 = require("react");
1355
1355
  function useAgnoKnowledge() {
1356
1356
  const client = useAgnoClient();
1357
- const [isLoading, setIsLoading] = (0, import_react10.useState)(false);
1358
- const [error, setError] = (0, import_react10.useState)();
1359
- const [config, setConfig] = (0, import_react10.useState)();
1360
- const [content, setContent] = (0, import_react10.useState)([]);
1361
- const getConfig = (0, import_react10.useCallback)(
1362
- async (options) => {
1363
- setIsLoading(true);
1364
- setError(void 0);
1365
- try {
1366
- const result = await client.getKnowledgeConfig(options);
1367
- setConfig(result);
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
- },
1377
- [client]
1378
- );
1379
- const listContent = (0, import_react10.useCallback)(
1380
- async (listOptions, options) => {
1381
- setIsLoading(true);
1382
- setError(void 0);
1383
- try {
1384
- const result = await client.listKnowledgeContent(listOptions, options);
1385
- setContent(result.data);
1386
- return result;
1387
- } catch (err) {
1388
- const errorMessage = err instanceof Error ? err.message : String(err);
1389
- setError(errorMessage);
1390
- throw err;
1391
- } finally {
1392
- setIsLoading(false);
1393
- }
1394
- },
1395
- [client]
1396
- );
1397
- const getContent = (0, import_react10.useCallback)(
1398
- async (contentId, options) => {
1399
- setIsLoading(true);
1400
- setError(void 0);
1401
- try {
1402
- return await client.getKnowledgeContent(contentId, options);
1403
- } catch (err) {
1404
- const errorMessage = err instanceof Error ? err.message : String(err);
1405
- setError(errorMessage);
1406
- throw err;
1407
- } finally {
1408
- setIsLoading(false);
1409
- }
1410
- },
1411
- [client]
1412
- );
1413
- const getContentStatus = (0, import_react10.useCallback)(
1414
- async (contentId, options) => {
1415
- setIsLoading(true);
1416
- setError(void 0);
1417
- try {
1418
- return await client.getKnowledgeContentStatus(contentId, options);
1419
- } catch (err) {
1420
- const errorMessage = err instanceof Error ? err.message : String(err);
1421
- setError(errorMessage);
1422
- throw err;
1423
- } finally {
1424
- setIsLoading(false);
1425
- }
1426
- },
1427
- [client]
1428
- );
1429
- const search = (0, import_react10.useCallback)(
1430
- async (request, options) => {
1431
- setIsLoading(true);
1432
- setError(void 0);
1433
- try {
1434
- return await client.searchKnowledge(request, options);
1435
- } catch (err) {
1436
- const errorMessage = err instanceof Error ? err.message : String(err);
1437
- setError(errorMessage);
1438
- throw err;
1439
- } finally {
1440
- setIsLoading(false);
1441
- }
1442
- },
1443
- [client]
1444
- );
1445
- const uploadContent = (0, import_react10.useCallback)(
1446
- async (data, options) => {
1447
- setIsLoading(true);
1448
- setError(void 0);
1449
- try {
1450
- const result = await client.uploadKnowledgeContent(data, options);
1451
- setContent((prev) => [result, ...prev]);
1452
- return result;
1453
- } catch (err) {
1454
- const errorMessage = err instanceof Error ? err.message : String(err);
1455
- setError(errorMessage);
1456
- throw err;
1457
- } finally {
1458
- setIsLoading(false);
1459
- }
1460
- },
1461
- [client]
1462
- );
1463
- const updateContent = (0, import_react10.useCallback)(
1464
- async (contentId, request, options) => {
1465
- setIsLoading(true);
1466
- setError(void 0);
1467
- try {
1468
- const result = await client.updateKnowledgeContent(
1469
- contentId,
1470
- request,
1471
- options
1472
- );
1473
- setContent((prev) => prev.map((c) => c.id === contentId ? result : c));
1474
- return result;
1475
- } catch (err) {
1476
- const errorMessage = err instanceof Error ? err.message : String(err);
1477
- setError(errorMessage);
1478
- throw err;
1479
- } finally {
1480
- setIsLoading(false);
1481
- }
1482
- },
1483
- [client]
1484
- );
1485
- const deleteAllContent = (0, import_react10.useCallback)(
1486
- async (options) => {
1487
- setIsLoading(true);
1488
- setError(void 0);
1489
- try {
1490
- await client.deleteAllKnowledgeContent(options);
1491
- setContent([]);
1492
- } catch (err) {
1493
- const errorMessage = err instanceof Error ? err.message : String(err);
1494
- setError(errorMessage);
1495
- throw err;
1496
- } finally {
1497
- setIsLoading(false);
1498
- }
1499
- },
1500
- [client]
1501
- );
1502
- const deleteContent = (0, import_react10.useCallback)(
1503
- async (contentId, options) => {
1504
- setIsLoading(true);
1505
- setError(void 0);
1506
- try {
1507
- const result = await client.deleteKnowledgeContent(contentId, options);
1508
- setContent((prev) => prev.filter((c) => c.id !== contentId));
1509
- return result;
1510
- } catch (err) {
1511
- const errorMessage = err instanceof Error ? err.message : String(err);
1512
- setError(errorMessage);
1513
- throw err;
1514
- } finally {
1515
- setIsLoading(false);
1516
- }
1517
- },
1518
- [client]
1519
- );
1357
+ const [isLoading, setIsLoading] = import_react10.useState(false);
1358
+ const [error, setError] = import_react10.useState();
1359
+ const [config, setConfig] = import_react10.useState();
1360
+ const [content, setContent] = import_react10.useState([]);
1361
+ const getConfig = import_react10.useCallback(async (options) => {
1362
+ setIsLoading(true);
1363
+ setError(undefined);
1364
+ try {
1365
+ const result = await client.getKnowledgeConfig(options);
1366
+ setConfig(result);
1367
+ return result;
1368
+ } catch (err) {
1369
+ const errorMessage = err instanceof Error ? err.message : String(err);
1370
+ setError(errorMessage);
1371
+ throw err;
1372
+ } finally {
1373
+ setIsLoading(false);
1374
+ }
1375
+ }, [client]);
1376
+ const listContent = import_react10.useCallback(async (listOptions, options) => {
1377
+ setIsLoading(true);
1378
+ setError(undefined);
1379
+ try {
1380
+ const result = await client.listKnowledgeContent(listOptions, options);
1381
+ setContent(result.data);
1382
+ return result;
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 getContent = import_react10.useCallback(async (contentId, options) => {
1392
+ setIsLoading(true);
1393
+ setError(undefined);
1394
+ try {
1395
+ return await client.getKnowledgeContent(contentId, options);
1396
+ } catch (err) {
1397
+ const errorMessage = err instanceof Error ? err.message : String(err);
1398
+ setError(errorMessage);
1399
+ throw err;
1400
+ } finally {
1401
+ setIsLoading(false);
1402
+ }
1403
+ }, [client]);
1404
+ const getContentStatus = import_react10.useCallback(async (contentId, options) => {
1405
+ setIsLoading(true);
1406
+ setError(undefined);
1407
+ try {
1408
+ return await client.getKnowledgeContentStatus(contentId, options);
1409
+ } catch (err) {
1410
+ const errorMessage = err instanceof Error ? err.message : String(err);
1411
+ setError(errorMessage);
1412
+ throw err;
1413
+ } finally {
1414
+ setIsLoading(false);
1415
+ }
1416
+ }, [client]);
1417
+ const search = import_react10.useCallback(async (request, options) => {
1418
+ setIsLoading(true);
1419
+ setError(undefined);
1420
+ try {
1421
+ return await client.searchKnowledge(request, options);
1422
+ } catch (err) {
1423
+ const errorMessage = err instanceof Error ? err.message : String(err);
1424
+ setError(errorMessage);
1425
+ throw err;
1426
+ } finally {
1427
+ setIsLoading(false);
1428
+ }
1429
+ }, [client]);
1430
+ const uploadContent = import_react10.useCallback(async (data, options) => {
1431
+ setIsLoading(true);
1432
+ setError(undefined);
1433
+ try {
1434
+ const result = await client.uploadKnowledgeContent(data, options);
1435
+ setContent((prev) => [result, ...prev]);
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 updateContent = import_react10.useCallback(async (contentId, request, options) => {
1446
+ setIsLoading(true);
1447
+ setError(undefined);
1448
+ try {
1449
+ const result = await client.updateKnowledgeContent(contentId, request, options);
1450
+ setContent((prev) => prev.map((c) => c.id === contentId ? result : c));
1451
+ return result;
1452
+ } catch (err) {
1453
+ const errorMessage = err instanceof Error ? err.message : String(err);
1454
+ setError(errorMessage);
1455
+ throw err;
1456
+ } finally {
1457
+ setIsLoading(false);
1458
+ }
1459
+ }, [client]);
1460
+ const deleteAllContent = import_react10.useCallback(async (options) => {
1461
+ setIsLoading(true);
1462
+ setError(undefined);
1463
+ try {
1464
+ await client.deleteAllKnowledgeContent(options);
1465
+ setContent([]);
1466
+ } catch (err) {
1467
+ const errorMessage = err instanceof Error ? err.message : String(err);
1468
+ setError(errorMessage);
1469
+ throw err;
1470
+ } finally {
1471
+ setIsLoading(false);
1472
+ }
1473
+ }, [client]);
1474
+ const deleteContent = import_react10.useCallback(async (contentId, options) => {
1475
+ setIsLoading(true);
1476
+ setError(undefined);
1477
+ try {
1478
+ const result = await client.deleteKnowledgeContent(contentId, options);
1479
+ setContent((prev) => prev.filter((c) => c.id !== contentId));
1480
+ return result;
1481
+ } catch (err) {
1482
+ const errorMessage = err instanceof Error ? err.message : String(err);
1483
+ setError(errorMessage);
1484
+ throw err;
1485
+ } finally {
1486
+ setIsLoading(false);
1487
+ }
1488
+ }, [client]);
1520
1489
  return {
1521
- // State
1522
1490
  config,
1523
1491
  content,
1524
1492
  isLoading,
1525
1493
  error,
1526
- // Methods
1527
1494
  getConfig,
1528
1495
  listContent,
1529
1496
  getContent,
@@ -1535,180 +1502,147 @@ function useAgnoKnowledge() {
1535
1502
  deleteContent
1536
1503
  };
1537
1504
  }
1538
-
1539
1505
  // src/hooks/useAgnoMetrics.ts
1540
1506
  var import_react11 = require("react");
1541
1507
  function useAgnoMetrics() {
1542
1508
  const client = useAgnoClient();
1543
- const [isLoading, setIsLoading] = (0, import_react11.useState)(false);
1544
- const [isRefreshing, setIsRefreshing] = (0, import_react11.useState)(false);
1545
- const [error, setError] = (0, import_react11.useState)();
1546
- const [metrics, setMetrics] = (0, import_react11.useState)();
1547
- const fetchMetrics = (0, import_react11.useCallback)(
1548
- async (options) => {
1549
- setIsLoading(true);
1550
- setError(void 0);
1551
- try {
1552
- const result = await client.fetchMetrics(options);
1553
- setMetrics(result);
1554
- return result;
1555
- } catch (err) {
1556
- const errorMessage = err instanceof Error ? err.message : String(err);
1557
- setError(errorMessage);
1558
- throw err;
1559
- } finally {
1560
- setIsLoading(false);
1561
- }
1562
- },
1563
- [client]
1564
- );
1565
- const refreshMetrics = (0, import_react11.useCallback)(
1566
- async (options) => {
1567
- setIsRefreshing(true);
1568
- setError(void 0);
1569
- try {
1570
- const result = await client.refreshMetrics(options);
1571
- return result;
1572
- } catch (err) {
1573
- const errorMessage = err instanceof Error ? err.message : String(err);
1574
- setError(errorMessage);
1575
- throw err;
1576
- } finally {
1577
- setIsRefreshing(false);
1578
- }
1579
- },
1580
- [client]
1581
- );
1582
- const clearMetrics = (0, import_react11.useCallback)(() => {
1583
- setMetrics(void 0);
1584
- setError(void 0);
1509
+ const [isLoading, setIsLoading] = import_react11.useState(false);
1510
+ const [isRefreshing, setIsRefreshing] = import_react11.useState(false);
1511
+ const [error, setError] = import_react11.useState();
1512
+ const [metrics, setMetrics] = import_react11.useState();
1513
+ const fetchMetrics = import_react11.useCallback(async (options) => {
1514
+ setIsLoading(true);
1515
+ setError(undefined);
1516
+ try {
1517
+ const result = await client.fetchMetrics(options);
1518
+ setMetrics(result);
1519
+ return result;
1520
+ } catch (err) {
1521
+ const errorMessage = err instanceof Error ? err.message : String(err);
1522
+ setError(errorMessage);
1523
+ throw err;
1524
+ } finally {
1525
+ setIsLoading(false);
1526
+ }
1527
+ }, [client]);
1528
+ const refreshMetrics = import_react11.useCallback(async (options) => {
1529
+ setIsRefreshing(true);
1530
+ setError(undefined);
1531
+ try {
1532
+ const result = await client.refreshMetrics(options);
1533
+ return result;
1534
+ } catch (err) {
1535
+ const errorMessage = err instanceof Error ? err.message : String(err);
1536
+ setError(errorMessage);
1537
+ throw err;
1538
+ } finally {
1539
+ setIsRefreshing(false);
1540
+ }
1541
+ }, [client]);
1542
+ const clearMetrics = import_react11.useCallback(() => {
1543
+ setMetrics(undefined);
1544
+ setError(undefined);
1585
1545
  }, []);
1586
1546
  return {
1587
- // Data
1588
1547
  metrics,
1589
- // Actions
1590
1548
  fetchMetrics,
1591
1549
  refreshMetrics,
1592
1550
  clearMetrics,
1593
- // State
1594
1551
  isLoading,
1595
1552
  isRefreshing,
1596
1553
  error
1597
1554
  };
1598
1555
  }
1599
-
1600
1556
  // src/hooks/useAgnoEvals.ts
1601
1557
  var import_react12 = require("react");
1602
1558
  function useAgnoEvals() {
1603
1559
  const client = useAgnoClient();
1604
- const [evalRuns, setEvalRuns] = (0, import_react12.useState)([]);
1605
- const [pagination, setPagination] = (0, import_react12.useState)();
1606
- const [isLoading, setIsLoading] = (0, import_react12.useState)(false);
1607
- const [error, setError] = (0, import_react12.useState)();
1608
- const listEvalRuns = (0, import_react12.useCallback)(
1609
- async (listParams = {}, options) => {
1610
- setIsLoading(true);
1611
- setError(void 0);
1612
- try {
1613
- const response = await client.listEvalRuns(listParams, options);
1614
- setEvalRuns(response.data);
1615
- setPagination(response.meta);
1616
- return response;
1617
- } catch (err) {
1618
- const errorMessage = err instanceof Error ? err.message : String(err);
1619
- setError(errorMessage);
1620
- throw err;
1621
- } finally {
1622
- setIsLoading(false);
1623
- }
1624
- },
1625
- [client]
1626
- );
1627
- const getEvalRun = (0, import_react12.useCallback)(
1628
- async (evalRunId, options) => {
1629
- setIsLoading(true);
1630
- setError(void 0);
1631
- try {
1632
- return await client.getEvalRun(evalRunId, options);
1633
- } catch (err) {
1634
- const errorMessage = err instanceof Error ? err.message : String(err);
1635
- setError(errorMessage);
1636
- throw err;
1637
- } finally {
1638
- setIsLoading(false);
1639
- }
1640
- },
1641
- [client]
1642
- );
1643
- const executeEval = (0, import_react12.useCallback)(
1644
- async (request, options) => {
1645
- setIsLoading(true);
1646
- setError(void 0);
1647
- try {
1648
- const result = await client.executeEval(request, options);
1649
- setEvalRuns((prev) => [result, ...prev]);
1650
- return result;
1651
- } catch (err) {
1652
- const errorMessage = err instanceof Error ? err.message : String(err);
1653
- setError(errorMessage);
1654
- throw err;
1655
- } finally {
1656
- setIsLoading(false);
1657
- }
1658
- },
1659
- [client]
1660
- );
1661
- const updateEvalRun = (0, import_react12.useCallback)(
1662
- async (evalRunId, request, options) => {
1663
- setIsLoading(true);
1664
- setError(void 0);
1665
- try {
1666
- const result = await client.updateEvalRun(evalRunId, request, options);
1667
- setEvalRuns(
1668
- (prev) => prev.map((evalRun) => evalRun.id === evalRunId ? result : evalRun)
1669
- );
1670
- return result;
1671
- } catch (err) {
1672
- const errorMessage = err instanceof Error ? err.message : String(err);
1673
- setError(errorMessage);
1674
- throw err;
1675
- } finally {
1676
- setIsLoading(false);
1677
- }
1678
- },
1679
- [client]
1680
- );
1681
- const deleteEvalRuns = (0, import_react12.useCallback)(
1682
- async (evalRunIds, options) => {
1683
- setIsLoading(true);
1684
- setError(void 0);
1685
- try {
1686
- await client.deleteEvalRuns(evalRunIds, options);
1687
- const deletedSet = new Set(evalRunIds);
1688
- setEvalRuns((prev) => prev.filter((evalRun) => !deletedSet.has(evalRun.id)));
1689
- } catch (err) {
1690
- const errorMessage = err instanceof Error ? err.message : String(err);
1691
- setError(errorMessage);
1692
- throw err;
1693
- } finally {
1694
- setIsLoading(false);
1695
- }
1696
- },
1697
- [client]
1698
- );
1699
- const renameEvalRun = (0, import_react12.useCallback)(
1700
- async (evalRunId, newName, options) => {
1701
- return updateEvalRun(evalRunId, { name: newName }, options);
1702
- },
1703
- [updateEvalRun]
1704
- );
1560
+ const [evalRuns, setEvalRuns] = import_react12.useState([]);
1561
+ const [pagination, setPagination] = import_react12.useState();
1562
+ const [isLoading, setIsLoading] = import_react12.useState(false);
1563
+ const [error, setError] = import_react12.useState();
1564
+ const listEvalRuns = import_react12.useCallback(async (listParams = {}, options) => {
1565
+ setIsLoading(true);
1566
+ setError(undefined);
1567
+ try {
1568
+ const response = await client.listEvalRuns(listParams, options);
1569
+ setEvalRuns(response.data);
1570
+ setPagination(response.meta);
1571
+ return response;
1572
+ } catch (err) {
1573
+ const errorMessage = err instanceof Error ? err.message : String(err);
1574
+ setError(errorMessage);
1575
+ throw err;
1576
+ } finally {
1577
+ setIsLoading(false);
1578
+ }
1579
+ }, [client]);
1580
+ const getEvalRun = import_react12.useCallback(async (evalRunId, options) => {
1581
+ setIsLoading(true);
1582
+ setError(undefined);
1583
+ try {
1584
+ return await client.getEvalRun(evalRunId, options);
1585
+ } catch (err) {
1586
+ const errorMessage = err instanceof Error ? err.message : String(err);
1587
+ setError(errorMessage);
1588
+ throw err;
1589
+ } finally {
1590
+ setIsLoading(false);
1591
+ }
1592
+ }, [client]);
1593
+ const executeEval = import_react12.useCallback(async (request, options) => {
1594
+ setIsLoading(true);
1595
+ setError(undefined);
1596
+ try {
1597
+ const result = await client.executeEval(request, options);
1598
+ setEvalRuns((prev) => [result, ...prev]);
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 updateEvalRun = import_react12.useCallback(async (evalRunId, request, options) => {
1609
+ setIsLoading(true);
1610
+ setError(undefined);
1611
+ try {
1612
+ const result = await client.updateEvalRun(evalRunId, request, options);
1613
+ setEvalRuns((prev) => prev.map((evalRun) => evalRun.id === evalRunId ? result : evalRun));
1614
+ return result;
1615
+ } catch (err) {
1616
+ const errorMessage = err instanceof Error ? err.message : String(err);
1617
+ setError(errorMessage);
1618
+ throw err;
1619
+ } finally {
1620
+ setIsLoading(false);
1621
+ }
1622
+ }, [client]);
1623
+ const deleteEvalRuns = import_react12.useCallback(async (evalRunIds, options) => {
1624
+ setIsLoading(true);
1625
+ setError(undefined);
1626
+ try {
1627
+ await client.deleteEvalRuns(evalRunIds, options);
1628
+ const deletedSet = new Set(evalRunIds);
1629
+ setEvalRuns((prev) => prev.filter((evalRun) => !deletedSet.has(evalRun.id)));
1630
+ } catch (err) {
1631
+ const errorMessage = err instanceof Error ? err.message : String(err);
1632
+ setError(errorMessage);
1633
+ throw err;
1634
+ } finally {
1635
+ setIsLoading(false);
1636
+ }
1637
+ }, [client]);
1638
+ const renameEvalRun = import_react12.useCallback(async (evalRunId, newName, options) => {
1639
+ return updateEvalRun(evalRunId, { name: newName }, options);
1640
+ }, [updateEvalRun]);
1705
1641
  return {
1706
- // State
1707
1642
  evalRuns,
1708
1643
  pagination,
1709
1644
  isLoading,
1710
1645
  error,
1711
- // Methods
1712
1646
  listEvalRuns,
1713
1647
  getEvalRun,
1714
1648
  executeEval,
@@ -1717,16 +1651,15 @@ function useAgnoEvals() {
1717
1651
  renameEvalRun
1718
1652
  };
1719
1653
  }
1720
-
1721
1654
  // src/hooks/useAgnoTraces.ts
1722
1655
  var import_react13 = require("react");
1723
1656
  function useAgnoTraces() {
1724
1657
  const client = useAgnoClient();
1725
- const [traces, setTraces] = (0, import_react13.useState)([]);
1726
- const [traceSessionStats, setTraceSessionStats] = (0, import_react13.useState)([]);
1727
- const [isLoading, setIsLoading] = (0, import_react13.useState)(false);
1728
- const [error, setError] = (0, import_react13.useState)();
1729
- (0, import_react13.useEffect)(() => {
1658
+ const [traces, setTraces] = import_react13.useState([]);
1659
+ const [traceSessionStats, setTraceSessionStats] = import_react13.useState([]);
1660
+ const [isLoading, setIsLoading] = import_react13.useState(false);
1661
+ const [error, setError] = import_react13.useState();
1662
+ import_react13.useEffect(() => {
1730
1663
  const handleStateChange = () => {
1731
1664
  const state2 = client.getState();
1732
1665
  setTraces(state2.traces);
@@ -1740,111 +1673,58 @@ function useAgnoTraces() {
1740
1673
  client.off("state:change", handleStateChange);
1741
1674
  };
1742
1675
  }, [client]);
1743
- const fetchTraces = (0, import_react13.useCallback)(
1744
- async (options = {}, requestOptions) => {
1745
- setIsLoading(true);
1746
- setError(void 0);
1747
- try {
1748
- const result = await client.fetchTraces(options, requestOptions);
1749
- setTraces(result.traces);
1750
- return result;
1751
- } catch (err) {
1752
- const errorMessage = err instanceof Error ? err.message : String(err);
1753
- setError(errorMessage);
1754
- throw err;
1755
- } finally {
1756
- setIsLoading(false);
1757
- }
1758
- },
1759
- [client]
1760
- );
1761
- const getTraceDetail = (0, import_react13.useCallback)(
1762
- async (traceId, options = {}, requestOptions) => {
1763
- setIsLoading(true);
1764
- setError(void 0);
1765
- try {
1766
- return await client.getTraceDetail(traceId, options, requestOptions);
1767
- } catch (err) {
1768
- const errorMessage = err instanceof Error ? err.message : String(err);
1769
- setError(errorMessage);
1770
- throw err;
1771
- } finally {
1772
- setIsLoading(false);
1773
- }
1774
- },
1775
- [client]
1776
- );
1777
- const fetchTraceSessionStats = (0, import_react13.useCallback)(
1778
- async (options = {}, requestOptions) => {
1779
- setIsLoading(true);
1780
- setError(void 0);
1781
- try {
1782
- const result = await client.fetchTraceSessionStats(options, requestOptions);
1783
- setTraceSessionStats(result.stats);
1784
- return result;
1785
- } catch (err) {
1786
- const errorMessage = err instanceof Error ? err.message : String(err);
1787
- setError(errorMessage);
1788
- throw err;
1789
- } finally {
1790
- setIsLoading(false);
1791
- }
1792
- },
1793
- [client]
1794
- );
1676
+ const fetchTraces = import_react13.useCallback(async (options = {}, requestOptions) => {
1677
+ setIsLoading(true);
1678
+ setError(undefined);
1679
+ try {
1680
+ const result = await client.fetchTraces(options, requestOptions);
1681
+ setTraces(result.traces);
1682
+ return result;
1683
+ } catch (err) {
1684
+ const errorMessage = err instanceof Error ? err.message : String(err);
1685
+ setError(errorMessage);
1686
+ throw err;
1687
+ } finally {
1688
+ setIsLoading(false);
1689
+ }
1690
+ }, [client]);
1691
+ const getTraceDetail = import_react13.useCallback(async (traceId, options = {}, requestOptions) => {
1692
+ setIsLoading(true);
1693
+ setError(undefined);
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
+ }, [client]);
1704
+ const fetchTraceSessionStats = import_react13.useCallback(async (options = {}, requestOptions) => {
1705
+ setIsLoading(true);
1706
+ setError(undefined);
1707
+ try {
1708
+ const result = await client.fetchTraceSessionStats(options, requestOptions);
1709
+ setTraceSessionStats(result.stats);
1710
+ return result;
1711
+ } catch (err) {
1712
+ const errorMessage = err instanceof Error ? err.message : String(err);
1713
+ setError(errorMessage);
1714
+ throw err;
1715
+ } finally {
1716
+ setIsLoading(false);
1717
+ }
1718
+ }, [client]);
1795
1719
  return {
1796
- /** Current list of traces (from last fetchTraces call) */
1797
1720
  traces,
1798
- /** Current trace session statistics (from last fetchTraceSessionStats call) */
1799
1721
  traceSessionStats,
1800
- /** Fetch traces with optional filters and pagination */
1801
1722
  fetchTraces,
1802
- /** Get trace detail or specific span */
1803
1723
  getTraceDetail,
1804
- /** Fetch trace session statistics */
1805
1724
  fetchTraceSessionStats,
1806
- /** Loading state */
1807
1725
  isLoading,
1808
- /** Error message if last operation failed */
1809
1726
  error
1810
1727
  };
1811
1728
  }
1812
- // Annotate the CommonJS export names for ESM import in node:
1813
- 0 && (module.exports = {
1814
- AgnoProvider,
1815
- ComponentRegistry,
1816
- GenerativeUIRenderer,
1817
- ToolHandlerProvider,
1818
- createAreaChart,
1819
- createArtifact,
1820
- createBarChart,
1821
- createCard,
1822
- createCardGrid,
1823
- createColumn,
1824
- createLineChart,
1825
- createMarkdown,
1826
- createPieChart,
1827
- createSmartChart,
1828
- createTable,
1829
- createToolResult,
1830
- getChartComponent,
1831
- getComponentRegistry,
1832
- getCustomRender,
1833
- registerChartComponent,
1834
- resultWithBarChart,
1835
- resultWithCardGrid,
1836
- resultWithSmartChart,
1837
- resultWithTable,
1838
- useAgnoActions,
1839
- useAgnoChat,
1840
- useAgnoClient,
1841
- useAgnoCustomEvents,
1842
- useAgnoEvals,
1843
- useAgnoKnowledge,
1844
- useAgnoMemory,
1845
- useAgnoMetrics,
1846
- useAgnoSession,
1847
- useAgnoToolExecution,
1848
- useAgnoTraces,
1849
- useToolHandlers
1850
- });
1729
+
1730
+ //# debugId=7C493B5C15A68B3E64756E2164756E21