@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.
- package/README.md +363 -83
- package/dist/components/GenerativeUIRenderer.d.ts +21 -0
- package/dist/components/GenerativeUIRenderer.d.ts.map +1 -0
- package/dist/context/AgnoContext.d.ts +16 -0
- package/dist/context/AgnoContext.d.ts.map +1 -0
- package/dist/context/ToolHandlerContext.d.ts +44 -0
- package/dist/context/ToolHandlerContext.d.ts.map +1 -0
- package/dist/hooks/useAgnoActions.d.ts +25 -0
- package/dist/hooks/useAgnoActions.d.ts.map +1 -0
- package/dist/hooks/useAgnoChat.d.ts +22 -0
- package/dist/hooks/useAgnoChat.d.ts.map +1 -0
- package/dist/hooks/useAgnoCustomEvents.d.ts +38 -0
- package/dist/hooks/useAgnoCustomEvents.d.ts.map +1 -0
- package/dist/hooks/useAgnoEvals.d.ts +39 -0
- package/dist/hooks/useAgnoEvals.d.ts.map +1 -0
- package/dist/hooks/useAgnoKnowledge.d.ts +56 -0
- package/dist/hooks/useAgnoKnowledge.d.ts.map +1 -0
- package/dist/hooks/useAgnoMemory.d.ts +42 -0
- package/dist/hooks/useAgnoMemory.d.ts.map +1 -0
- package/dist/hooks/useAgnoMetrics.d.ts +51 -0
- package/dist/hooks/useAgnoMetrics.d.ts.map +1 -0
- package/dist/hooks/useAgnoSession.d.ts +38 -0
- package/dist/hooks/useAgnoSession.d.ts.map +1 -0
- package/dist/hooks/useAgnoToolExecution.d.ts +70 -0
- package/dist/hooks/useAgnoToolExecution.d.ts.map +1 -0
- package/dist/hooks/useAgnoTraces.d.ts +51 -0
- package/dist/hooks/useAgnoTraces.d.ts.map +1 -0
- package/dist/index.d.ts +27 -723
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +932 -1052
- package/dist/index.js.map +24 -0
- package/dist/index.mjs +816 -909
- package/dist/index.mjs.map +24 -0
- package/dist/ui/components/artifact.d.ts +24 -0
- package/dist/ui/components/artifact.d.ts.map +1 -0
- package/dist/ui/components/audio-recorder.d.ts +32 -0
- package/dist/ui/components/audio-recorder.d.ts.map +1 -0
- package/dist/ui/components/code-block.d.ts +15 -0
- package/dist/ui/components/code-block.d.ts.map +1 -0
- package/dist/ui/components/conversation.d.ts +17 -0
- package/dist/ui/components/conversation.d.ts.map +1 -0
- package/dist/ui/components/file-preview-card.d.ts +13 -0
- package/dist/ui/components/file-preview-card.d.ts.map +1 -0
- package/dist/ui/components/file-preview-modal.d.ts +8 -0
- package/dist/ui/components/file-preview-modal.d.ts.map +1 -0
- package/dist/ui/components/image-lightbox.d.ts +12 -0
- package/dist/ui/components/image-lightbox.d.ts.map +1 -0
- package/dist/ui/components/message.d.ts +19 -0
- package/dist/ui/components/message.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/attachments.d.ts +21 -0
- package/dist/ui/components/prompt-input/attachments.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/buttons.d.ts +19 -0
- package/dist/ui/components/prompt-input/buttons.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/command.d.ts +17 -0
- package/dist/ui/components/prompt-input/command.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/context.d.ts +36 -0
- package/dist/ui/components/prompt-input/context.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/drop-zone.d.ts +7 -0
- package/dist/ui/components/prompt-input/drop-zone.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/footer.d.ts +11 -0
- package/dist/ui/components/prompt-input/footer.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/index.d.ts +25 -0
- package/dist/ui/components/prompt-input/index.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/model-select.d.ts +13 -0
- package/dist/ui/components/prompt-input/model-select.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/prompt-input.d.ts +22 -0
- package/dist/ui/components/prompt-input/prompt-input.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/provider.d.ts +6 -0
- package/dist/ui/components/prompt-input/provider.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/speech.d.ts +51 -0
- package/dist/ui/components/prompt-input/speech.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/tabs.d.ts +12 -0
- package/dist/ui/components/prompt-input/tabs.d.ts.map +1 -0
- package/dist/ui/components/prompt-input/textarea.d.ts +5 -0
- package/dist/ui/components/prompt-input/textarea.d.ts.map +1 -0
- package/dist/ui/components/response.d.ts +5 -0
- package/dist/ui/components/response.d.ts.map +1 -0
- package/dist/ui/components/smart-timestamp.d.ts +8 -0
- package/dist/ui/components/smart-timestamp.d.ts.map +1 -0
- package/dist/ui/components/streaming-indicator.d.ts +8 -0
- package/dist/ui/components/streaming-indicator.d.ts.map +1 -0
- package/dist/ui/components/tool.d.ts +24 -0
- package/dist/ui/components/tool.d.ts.map +1 -0
- package/dist/ui/composed/AgnoChatInput.d.ts +44 -0
- package/dist/ui/composed/AgnoChatInput.d.ts.map +1 -0
- package/dist/ui/composed/AgnoChatInterface.d.ts +49 -0
- package/dist/ui/composed/AgnoChatInterface.d.ts.map +1 -0
- package/dist/ui/composed/AgnoMessageItem.d.ts +38 -0
- package/dist/ui/composed/AgnoMessageItem.d.ts.map +1 -0
- package/dist/ui/composed/agno-chat/agno-chat.d.ts +9 -0
- package/dist/ui/composed/agno-chat/agno-chat.d.ts.map +1 -0
- package/dist/ui/composed/agno-chat/context.d.ts +33 -0
- package/dist/ui/composed/agno-chat/context.d.ts.map +1 -0
- package/dist/ui/composed/agno-chat/empty-state.d.ts +6 -0
- package/dist/ui/composed/agno-chat/empty-state.d.ts.map +1 -0
- package/dist/ui/composed/agno-chat/error-bar.d.ts +5 -0
- package/dist/ui/composed/agno-chat/error-bar.d.ts.map +1 -0
- package/dist/ui/composed/agno-chat/index.d.ts +33 -0
- package/dist/ui/composed/agno-chat/index.d.ts.map +1 -0
- package/dist/ui/composed/agno-chat/input.d.ts +39 -0
- package/dist/ui/composed/agno-chat/input.d.ts.map +1 -0
- package/dist/ui/composed/agno-chat/messages.d.ts +21 -0
- package/dist/ui/composed/agno-chat/messages.d.ts.map +1 -0
- package/dist/ui/composed/agno-chat/suggested-prompts.d.ts +7 -0
- package/dist/ui/composed/agno-chat/suggested-prompts.d.ts.map +1 -0
- package/dist/ui/composed/agno-chat/tool-status.d.ts +5 -0
- package/dist/ui/composed/agno-chat/tool-status.d.ts.map +1 -0
- package/dist/ui/composed/index.d.ts +9 -0
- package/dist/ui/composed/index.d.ts.map +1 -0
- package/dist/ui/index.d.ts +59 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/lib/cn.d.ts +3 -0
- package/dist/ui/lib/cn.d.ts.map +1 -0
- package/dist/ui/lib/file-utils.d.ts +20 -0
- package/dist/ui/lib/file-utils.d.ts.map +1 -0
- package/dist/ui/lib/format-timestamp.d.ts +16 -0
- package/dist/ui/lib/format-timestamp.d.ts.map +1 -0
- package/dist/ui/primitives/accordion.d.ts +8 -0
- package/dist/ui/primitives/accordion.d.ts.map +1 -0
- package/dist/ui/primitives/avatar.d.ts +7 -0
- package/dist/ui/primitives/avatar.d.ts.map +1 -0
- package/dist/ui/primitives/badge.d.ts +10 -0
- package/dist/ui/primitives/badge.d.ts.map +1 -0
- package/dist/ui/primitives/button.d.ts +12 -0
- package/dist/ui/primitives/button.d.ts.map +1 -0
- package/dist/ui/primitives/collapsible.d.ts +6 -0
- package/dist/ui/primitives/collapsible.d.ts.map +1 -0
- package/dist/ui/primitives/command.d.ts +79 -0
- package/dist/ui/primitives/command.d.ts.map +1 -0
- package/dist/ui/primitives/dialog.d.ts +26 -0
- package/dist/ui/primitives/dialog.d.ts.map +1 -0
- package/dist/ui/primitives/dropdown-menu.d.ts +28 -0
- package/dist/ui/primitives/dropdown-menu.d.ts.map +1 -0
- package/dist/ui/primitives/hover-card.d.ts +7 -0
- package/dist/ui/primitives/hover-card.d.ts.map +1 -0
- package/dist/ui/primitives/index.d.ts +16 -0
- package/dist/ui/primitives/index.d.ts.map +1 -0
- package/dist/ui/primitives/input-group.d.ts +17 -0
- package/dist/ui/primitives/input-group.d.ts.map +1 -0
- package/dist/ui/primitives/select.d.ts +14 -0
- package/dist/ui/primitives/select.d.ts.map +1 -0
- package/dist/ui/primitives/tooltip.d.ts +8 -0
- package/dist/ui/primitives/tooltip.d.ts.map +1 -0
- package/dist/ui/types.d.ts +56 -0
- package/dist/ui/types.d.ts.map +1 -0
- package/dist/ui.d.ts +2 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +4059 -0
- package/dist/ui.js.map +60 -0
- package/dist/ui.mjs +4044 -0
- package/dist/ui.mjs.map +60 -0
- package/dist/utils/component-registry.d.ts +63 -0
- package/dist/utils/component-registry.d.ts.map +1 -0
- package/dist/utils/ui-helpers.d.ts +165 -0
- package/dist/utils/ui-helpers.d.ts.map +1 -0
- package/package.json +122 -17
- package/LICENSE +0 -21
- 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
|
|
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, {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
32
|
-
__export(
|
|
33
|
-
|
|
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
|
-
|
|
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(
|
|
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
|
|
76
|
-
var AgnoContext =
|
|
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 =
|
|
79
|
-
|
|
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
|
-
|
|
94
|
+
import_react.useEffect(() => {
|
|
83
95
|
return () => {
|
|
84
96
|
client.removeAllListeners();
|
|
85
97
|
};
|
|
86
98
|
}, [client]);
|
|
87
|
-
return /* @__PURE__ */
|
|
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 =
|
|
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
|
|
100
|
-
var ToolHandlerContext =
|
|
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] =
|
|
103
|
-
const registerHandler =
|
|
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 =
|
|
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__ */
|
|
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
|
|
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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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 (!
|
|
136
|
-
|
|
148
|
+
if (!ComponentRegistry.instance) {
|
|
149
|
+
ComponentRegistry.instance = new ComponentRegistry;
|
|
137
150
|
}
|
|
138
|
-
return
|
|
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 =
|
|
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 =
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
-
|
|
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 =
|
|
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] =
|
|
272
|
-
const [isPaused, setIsPaused] =
|
|
273
|
-
const [isExecuting, setIsExecuting] =
|
|
274
|
-
const [executionError, setExecutionError] =
|
|
275
|
-
|
|
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(
|
|
271
|
+
setExecutionError(undefined);
|
|
283
272
|
};
|
|
284
273
|
const handleRunContinued = () => {
|
|
285
274
|
setIsPaused(false);
|
|
286
275
|
setPendingTools([]);
|
|
287
276
|
setIsExecuting(false);
|
|
288
|
-
setExecutionError(
|
|
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 =
|
|
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(
|
|
292
|
+
setExecutionError(undefined);
|
|
304
293
|
try {
|
|
305
|
-
const updatedTools = await Promise.all(
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
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
|
-
|
|
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)
|
|
341
|
+
if (!message.tool_calls)
|
|
342
|
+
continue;
|
|
355
343
|
for (const tool of message.tool_calls) {
|
|
356
|
-
if (tool.ui_component)
|
|
344
|
+
if (tool.ui_component)
|
|
345
|
+
continue;
|
|
357
346
|
const handler = mergedHandlers[tool.tool_name];
|
|
358
|
-
if (!handler)
|
|
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 =
|
|
377
|
-
async (
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
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
|
|
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
|
-
|
|
413
|
-
|
|
380
|
+
return {
|
|
381
|
+
...tool,
|
|
382
|
+
result: JSON.stringify({
|
|
383
|
+
error: error instanceof Error ? error.message : String(error)
|
|
384
|
+
})
|
|
385
|
+
};
|
|
414
386
|
}
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
)
|
|
418
|
-
|
|
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
|
|
443
|
-
|
|
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__ */
|
|
458
|
-
|
|
459
|
-
|
|
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__ */
|
|
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__ */
|
|
480
|
-
|
|
481
|
-
|
|
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__ */
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
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__ */
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
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__ */
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
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__ */
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
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] =
|
|
784
|
-
const [state, setState] =
|
|
785
|
-
const [error, setError] =
|
|
786
|
-
|
|
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 = (
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
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(
|
|
907
|
+
setError(undefined);
|
|
848
908
|
}, [client]);
|
|
849
|
-
const cancelRun =
|
|
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] =
|
|
878
|
-
const [currentSessionId, setCurrentSessionId] =
|
|
879
|
-
|
|
880
|
-
);
|
|
881
|
-
|
|
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 = (
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
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(
|
|
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 = (
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
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] =
|
|
1075
|
-
const [error, setError] =
|
|
1076
|
-
const initialize =
|
|
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(
|
|
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 =
|
|
1091
|
-
setError(
|
|
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 =
|
|
1101
|
-
setError(
|
|
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 =
|
|
1111
|
-
setError(
|
|
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 =
|
|
1121
|
-
(updates)
|
|
1122
|
-
|
|
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] =
|
|
1142
|
-
const handlerRef =
|
|
1169
|
+
const [events, setEvents] = import_react8.useState([]);
|
|
1170
|
+
const handlerRef = import_react8.useRef(handler);
|
|
1143
1171
|
handlerRef.current = handler;
|
|
1144
|
-
|
|
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 =
|
|
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] =
|
|
1165
|
-
const [topics, setTopics] =
|
|
1166
|
-
const [isLoading, setIsLoading] =
|
|
1167
|
-
const [error, setError] =
|
|
1168
|
-
|
|
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 = (
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
setError(
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
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] =
|
|
1358
|
-
const [error, setError] =
|
|
1359
|
-
const [config, setConfig] =
|
|
1360
|
-
const [content, setContent] =
|
|
1361
|
-
const getConfig =
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
}
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
);
|
|
1445
|
-
const
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
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] =
|
|
1544
|
-
const [isRefreshing, setIsRefreshing] =
|
|
1545
|
-
const [error, setError] =
|
|
1546
|
-
const [metrics, setMetrics] =
|
|
1547
|
-
const fetchMetrics =
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
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] =
|
|
1605
|
-
const [pagination, setPagination] =
|
|
1606
|
-
const [isLoading, setIsLoading] =
|
|
1607
|
-
const [error, setError] =
|
|
1608
|
-
const listEvalRuns = (
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
setError(
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
}
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
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] =
|
|
1726
|
-
const [traceSessionStats, setTraceSessionStats] =
|
|
1727
|
-
const [isLoading, setIsLoading] =
|
|
1728
|
-
const [error, setError] =
|
|
1729
|
-
|
|
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 = (
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
setError(
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
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
|
-
|
|
1813
|
-
|
|
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
|