@rodrigocoliveira/agno-react 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/useAgnoComponents.d.ts +54 -0
- package/dist/hooks/useAgnoComponents.d.ts.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +297 -88
- package/dist/index.js.map +5 -4
- package/dist/index.mjs +297 -88
- package/dist/index.mjs.map +5 -4
- package/dist/ui.js +947 -947
- package/dist/ui.js.map +2 -2
- package/dist/ui.mjs +947 -947
- package/dist/ui.mjs.map +2 -2
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/context/AgnoContext.tsx
|
|
2
2
|
import { createContext, useContext, useMemo, useEffect } from "react";
|
|
3
3
|
import { AgnoClient } from "@rodrigocoliveira/agno-client";
|
|
4
|
-
import {
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
var AgnoContext = createContext(null);
|
|
6
6
|
function AgnoProvider({ config, children }) {
|
|
7
7
|
const client = useMemo(() => new AgnoClient(config), []);
|
|
@@ -13,10 +13,10 @@ function AgnoProvider({ config, children }) {
|
|
|
13
13
|
client.removeAllListeners();
|
|
14
14
|
};
|
|
15
15
|
}, [client]);
|
|
16
|
-
return /* @__PURE__ */
|
|
16
|
+
return /* @__PURE__ */ jsx(AgnoContext.Provider, {
|
|
17
17
|
value: client,
|
|
18
18
|
children
|
|
19
|
-
}
|
|
19
|
+
});
|
|
20
20
|
}
|
|
21
21
|
function useAgnoClient() {
|
|
22
22
|
const client = useContext(AgnoContext);
|
|
@@ -27,7 +27,7 @@ function useAgnoClient() {
|
|
|
27
27
|
}
|
|
28
28
|
// src/context/ToolHandlerContext.tsx
|
|
29
29
|
import { createContext as createContext2, useContext as useContext2, useState, useCallback } from "react";
|
|
30
|
-
import {
|
|
30
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
31
31
|
var ToolHandlerContext = createContext2(null);
|
|
32
32
|
function ToolHandlerProvider({ handlers: initialHandlers = {}, children }) {
|
|
33
33
|
const [handlers, setHandlers] = useState(initialHandlers);
|
|
@@ -45,10 +45,10 @@ function ToolHandlerProvider({ handlers: initialHandlers = {}, children }) {
|
|
|
45
45
|
registerHandler,
|
|
46
46
|
unregisterHandler
|
|
47
47
|
};
|
|
48
|
-
return /* @__PURE__ */
|
|
48
|
+
return /* @__PURE__ */ jsx2(ToolHandlerContext.Provider, {
|
|
49
49
|
value,
|
|
50
50
|
children
|
|
51
|
-
}
|
|
51
|
+
});
|
|
52
52
|
}
|
|
53
53
|
function useToolHandlers() {
|
|
54
54
|
return useContext2(ToolHandlerContext);
|
|
@@ -334,7 +334,7 @@ function useAgnoToolExecution(handlers = {}, autoExecute = true, options) {
|
|
|
334
334
|
}
|
|
335
335
|
|
|
336
336
|
// src/components/GenerativeUIRenderer.tsx
|
|
337
|
-
import {
|
|
337
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
338
338
|
|
|
339
339
|
class UIErrorBoundary extends React3.Component {
|
|
340
340
|
constructor(props) {
|
|
@@ -350,19 +350,19 @@ class UIErrorBoundary extends React3.Component {
|
|
|
350
350
|
}
|
|
351
351
|
render() {
|
|
352
352
|
if (this.state.hasError) {
|
|
353
|
-
return this.props.fallback || /* @__PURE__ */
|
|
353
|
+
return this.props.fallback || /* @__PURE__ */ jsxs("div", {
|
|
354
354
|
className: "p-4 border border-red-300 rounded-md bg-red-50 text-red-800",
|
|
355
355
|
children: [
|
|
356
|
-
/* @__PURE__ */
|
|
356
|
+
/* @__PURE__ */ jsx3("p", {
|
|
357
357
|
className: "font-semibold",
|
|
358
358
|
children: "Failed to render UI component"
|
|
359
|
-
}
|
|
360
|
-
/* @__PURE__ */
|
|
359
|
+
}),
|
|
360
|
+
/* @__PURE__ */ jsx3("p", {
|
|
361
361
|
className: "text-sm mt-1",
|
|
362
362
|
children: this.state.error?.message || "Unknown error"
|
|
363
|
-
}
|
|
363
|
+
})
|
|
364
364
|
]
|
|
365
|
-
}
|
|
365
|
+
});
|
|
366
366
|
}
|
|
367
367
|
return this.props.children;
|
|
368
368
|
}
|
|
@@ -378,183 +378,183 @@ function GenerativeUIRenderer({
|
|
|
378
378
|
if (customSpec.renderKey) {
|
|
379
379
|
const renderFn = getCustomRender(customSpec.renderKey);
|
|
380
380
|
if (renderFn) {
|
|
381
|
-
return /* @__PURE__ */
|
|
381
|
+
return /* @__PURE__ */ jsx3(UIErrorBoundary, {
|
|
382
382
|
onError,
|
|
383
|
-
children: /* @__PURE__ */
|
|
383
|
+
children: /* @__PURE__ */ jsx3("div", {
|
|
384
384
|
className,
|
|
385
385
|
children: renderFn(customSpec.props || {})
|
|
386
|
-
}
|
|
387
|
-
}
|
|
386
|
+
})
|
|
387
|
+
});
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
|
-
return /* @__PURE__ */
|
|
390
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
391
391
|
className: `p-4 border border-yellow-300 rounded-md bg-yellow-50 text-yellow-800 ${className || ""}`,
|
|
392
392
|
children: [
|
|
393
|
-
/* @__PURE__ */
|
|
393
|
+
/* @__PURE__ */ jsx3("p", {
|
|
394
394
|
className: "font-semibold",
|
|
395
395
|
children: "Custom component not available"
|
|
396
|
-
}
|
|
397
|
-
/* @__PURE__ */
|
|
396
|
+
}),
|
|
397
|
+
/* @__PURE__ */ jsx3("p", {
|
|
398
398
|
className: "text-sm mt-1",
|
|
399
399
|
children: "The custom render function for this component is not available."
|
|
400
|
-
}
|
|
400
|
+
})
|
|
401
401
|
]
|
|
402
|
-
}
|
|
402
|
+
});
|
|
403
403
|
}
|
|
404
404
|
if (spec.type === "chart") {
|
|
405
405
|
const chartSpec = spec;
|
|
406
406
|
const chartType = `chart:${chartSpec.component}`;
|
|
407
407
|
if (registry.has(chartType)) {
|
|
408
408
|
const ChartRenderer = registry.get(chartType);
|
|
409
|
-
return /* @__PURE__ */
|
|
409
|
+
return /* @__PURE__ */ jsx3(UIErrorBoundary, {
|
|
410
410
|
onError,
|
|
411
|
-
children: /* @__PURE__ */
|
|
411
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
412
412
|
className,
|
|
413
413
|
children: [
|
|
414
|
-
chartSpec.title && /* @__PURE__ */
|
|
414
|
+
chartSpec.title && /* @__PURE__ */ jsx3("h3", {
|
|
415
415
|
className: "font-semibold mb-2",
|
|
416
416
|
children: chartSpec.title
|
|
417
|
-
}
|
|
418
|
-
chartSpec.description && /* @__PURE__ */
|
|
417
|
+
}),
|
|
418
|
+
chartSpec.description && /* @__PURE__ */ jsx3("p", {
|
|
419
419
|
className: "text-sm text-gray-600 mb-4",
|
|
420
420
|
children: chartSpec.description
|
|
421
|
-
}
|
|
422
|
-
/* @__PURE__ */
|
|
421
|
+
}),
|
|
422
|
+
/* @__PURE__ */ jsx3(ChartRenderer, {
|
|
423
423
|
...chartSpec.props
|
|
424
|
-
}
|
|
424
|
+
})
|
|
425
425
|
]
|
|
426
|
-
}
|
|
427
|
-
}
|
|
426
|
+
})
|
|
427
|
+
});
|
|
428
428
|
}
|
|
429
|
-
return /* @__PURE__ */
|
|
429
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
430
430
|
className: `p-4 border border-gray-300 rounded-md ${className || ""}`,
|
|
431
431
|
children: [
|
|
432
|
-
/* @__PURE__ */
|
|
432
|
+
/* @__PURE__ */ jsx3("p", {
|
|
433
433
|
className: "font-semibold mb-2",
|
|
434
434
|
children: chartSpec.title || "Chart Data"
|
|
435
|
-
}
|
|
436
|
-
chartSpec.description && /* @__PURE__ */
|
|
435
|
+
}),
|
|
436
|
+
chartSpec.description && /* @__PURE__ */ jsx3("p", {
|
|
437
437
|
className: "text-sm text-gray-600 mb-2",
|
|
438
438
|
children: chartSpec.description
|
|
439
|
-
}
|
|
440
|
-
/* @__PURE__ */
|
|
439
|
+
}),
|
|
440
|
+
/* @__PURE__ */ jsx3("pre", {
|
|
441
441
|
className: "text-xs bg-gray-100 p-2 rounded overflow-auto",
|
|
442
442
|
children: JSON.stringify(chartSpec.props.data, null, 2)
|
|
443
|
-
}
|
|
443
|
+
})
|
|
444
444
|
]
|
|
445
|
-
}
|
|
445
|
+
});
|
|
446
446
|
}
|
|
447
447
|
if (spec.type === "card-grid") {
|
|
448
448
|
const cardGridSpec = spec;
|
|
449
449
|
if (registry.has("card-grid")) {
|
|
450
450
|
const CardGridRenderer = registry.get("card-grid");
|
|
451
|
-
return /* @__PURE__ */
|
|
451
|
+
return /* @__PURE__ */ jsx3(UIErrorBoundary, {
|
|
452
452
|
onError,
|
|
453
|
-
children: /* @__PURE__ */
|
|
453
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
454
454
|
className,
|
|
455
455
|
children: [
|
|
456
|
-
cardGridSpec.title && /* @__PURE__ */
|
|
456
|
+
cardGridSpec.title && /* @__PURE__ */ jsx3("h3", {
|
|
457
457
|
className: "font-semibold mb-2",
|
|
458
458
|
children: cardGridSpec.title
|
|
459
|
-
}
|
|
460
|
-
cardGridSpec.description && /* @__PURE__ */
|
|
459
|
+
}),
|
|
460
|
+
cardGridSpec.description && /* @__PURE__ */ jsx3("p", {
|
|
461
461
|
className: "text-sm text-gray-600 mb-4",
|
|
462
462
|
children: cardGridSpec.description
|
|
463
|
-
}
|
|
464
|
-
/* @__PURE__ */
|
|
463
|
+
}),
|
|
464
|
+
/* @__PURE__ */ jsx3(CardGridRenderer, {
|
|
465
465
|
...cardGridSpec.props
|
|
466
|
-
}
|
|
466
|
+
})
|
|
467
467
|
]
|
|
468
|
-
}
|
|
469
|
-
}
|
|
468
|
+
})
|
|
469
|
+
});
|
|
470
470
|
}
|
|
471
471
|
}
|
|
472
472
|
if (spec.type === "table") {
|
|
473
473
|
const tableSpec = spec;
|
|
474
474
|
if (registry.has("table")) {
|
|
475
475
|
const TableRenderer = registry.get("table");
|
|
476
|
-
return /* @__PURE__ */
|
|
476
|
+
return /* @__PURE__ */ jsx3(UIErrorBoundary, {
|
|
477
477
|
onError,
|
|
478
|
-
children: /* @__PURE__ */
|
|
478
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
479
479
|
className,
|
|
480
480
|
children: [
|
|
481
|
-
tableSpec.title && /* @__PURE__ */
|
|
481
|
+
tableSpec.title && /* @__PURE__ */ jsx3("h3", {
|
|
482
482
|
className: "font-semibold mb-2",
|
|
483
483
|
children: tableSpec.title
|
|
484
|
-
}
|
|
485
|
-
tableSpec.description && /* @__PURE__ */
|
|
484
|
+
}),
|
|
485
|
+
tableSpec.description && /* @__PURE__ */ jsx3("p", {
|
|
486
486
|
className: "text-sm text-gray-600 mb-4",
|
|
487
487
|
children: tableSpec.description
|
|
488
|
-
}
|
|
489
|
-
/* @__PURE__ */
|
|
488
|
+
}),
|
|
489
|
+
/* @__PURE__ */ jsx3(TableRenderer, {
|
|
490
490
|
...tableSpec.props
|
|
491
|
-
}
|
|
491
|
+
})
|
|
492
492
|
]
|
|
493
|
-
}
|
|
494
|
-
}
|
|
493
|
+
})
|
|
494
|
+
});
|
|
495
495
|
}
|
|
496
496
|
}
|
|
497
497
|
if (spec.type === "markdown") {
|
|
498
498
|
const markdownSpec = spec;
|
|
499
499
|
if (registry.has("markdown")) {
|
|
500
500
|
const MarkdownRenderer = registry.get("markdown");
|
|
501
|
-
return /* @__PURE__ */
|
|
501
|
+
return /* @__PURE__ */ jsx3(UIErrorBoundary, {
|
|
502
502
|
onError,
|
|
503
|
-
children: /* @__PURE__ */
|
|
503
|
+
children: /* @__PURE__ */ jsx3("div", {
|
|
504
504
|
className,
|
|
505
|
-
children: /* @__PURE__ */
|
|
505
|
+
children: /* @__PURE__ */ jsx3(MarkdownRenderer, {
|
|
506
506
|
...markdownSpec.props
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
}
|
|
507
|
+
})
|
|
508
|
+
})
|
|
509
|
+
});
|
|
510
510
|
}
|
|
511
|
-
return /* @__PURE__ */
|
|
511
|
+
return /* @__PURE__ */ jsx3("div", {
|
|
512
512
|
className,
|
|
513
513
|
children: markdownSpec.props.content
|
|
514
|
-
}
|
|
514
|
+
});
|
|
515
515
|
}
|
|
516
516
|
if (spec.type === "artifact") {
|
|
517
517
|
const artifactSpec = spec;
|
|
518
|
-
return /* @__PURE__ */
|
|
518
|
+
return /* @__PURE__ */ jsx3(UIErrorBoundary, {
|
|
519
519
|
onError,
|
|
520
|
-
children: /* @__PURE__ */
|
|
520
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
521
521
|
className: `p-4 border rounded-md ${className || ""}`,
|
|
522
522
|
children: [
|
|
523
|
-
artifactSpec.title && /* @__PURE__ */
|
|
523
|
+
artifactSpec.title && /* @__PURE__ */ jsx3("h3", {
|
|
524
524
|
className: "font-semibold mb-4",
|
|
525
525
|
children: artifactSpec.title
|
|
526
|
-
}
|
|
527
|
-
artifactSpec.description && /* @__PURE__ */
|
|
526
|
+
}),
|
|
527
|
+
artifactSpec.description && /* @__PURE__ */ jsx3("p", {
|
|
528
528
|
className: "text-sm text-gray-600 mb-4",
|
|
529
529
|
children: artifactSpec.description
|
|
530
|
-
}
|
|
531
|
-
/* @__PURE__ */
|
|
530
|
+
}),
|
|
531
|
+
/* @__PURE__ */ jsx3("div", {
|
|
532
532
|
className: "space-y-4",
|
|
533
|
-
children: artifactSpec.props.content?.map((childSpec, index) => /* @__PURE__ */
|
|
533
|
+
children: artifactSpec.props.content?.map((childSpec, index) => /* @__PURE__ */ jsx3(GenerativeUIRenderer, {
|
|
534
534
|
spec: childSpec,
|
|
535
535
|
onError
|
|
536
|
-
}, index
|
|
537
|
-
}
|
|
536
|
+
}, index))
|
|
537
|
+
})
|
|
538
538
|
]
|
|
539
|
-
}
|
|
540
|
-
}
|
|
539
|
+
})
|
|
540
|
+
});
|
|
541
541
|
}
|
|
542
|
-
return /* @__PURE__ */
|
|
542
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
543
543
|
className: `p-4 border border-gray-300 rounded-md ${className || ""}`,
|
|
544
544
|
children: [
|
|
545
|
-
/* @__PURE__ */
|
|
545
|
+
/* @__PURE__ */ jsx3("p", {
|
|
546
546
|
className: "font-semibold",
|
|
547
547
|
children: "Unsupported UI component"
|
|
548
|
-
}
|
|
549
|
-
/* @__PURE__ */
|
|
548
|
+
}),
|
|
549
|
+
/* @__PURE__ */ jsxs("p", {
|
|
550
550
|
className: "text-sm text-gray-600 mt-1",
|
|
551
551
|
children: [
|
|
552
552
|
"Component type: ",
|
|
553
553
|
spec.type
|
|
554
554
|
]
|
|
555
|
-
}
|
|
555
|
+
})
|
|
556
556
|
]
|
|
557
|
-
}
|
|
557
|
+
});
|
|
558
558
|
}
|
|
559
559
|
// src/utils/ui-helpers.ts
|
|
560
560
|
function createBarChart(data, xKey, bars, options) {
|
|
@@ -1673,6 +1673,214 @@ function useAgnoTraces() {
|
|
|
1673
1673
|
error
|
|
1674
1674
|
};
|
|
1675
1675
|
}
|
|
1676
|
+
// src/hooks/useAgnoComponents.ts
|
|
1677
|
+
import { useState as useState13, useEffect as useEffect9, useCallback as useCallback13 } from "react";
|
|
1678
|
+
function useAgnoComponents() {
|
|
1679
|
+
const client = useAgnoClient();
|
|
1680
|
+
const [components, setComponents] = useState13([]);
|
|
1681
|
+
const [isLoading, setIsLoading] = useState13(false);
|
|
1682
|
+
const [error, setError] = useState13();
|
|
1683
|
+
useEffect9(() => {
|
|
1684
|
+
const handleComponentCreated = (component) => {
|
|
1685
|
+
setComponents((prev) => [component, ...prev]);
|
|
1686
|
+
};
|
|
1687
|
+
const handleComponentUpdated = (component) => {
|
|
1688
|
+
setComponents((prev) => prev.map((c) => c.component_id === component.component_id ? component : c));
|
|
1689
|
+
};
|
|
1690
|
+
const handleComponentDeleted = ({ componentId }) => {
|
|
1691
|
+
setComponents((prev) => prev.filter((c) => c.component_id !== componentId));
|
|
1692
|
+
};
|
|
1693
|
+
const handleStateChange = () => {
|
|
1694
|
+
setComponents(client.getState().components);
|
|
1695
|
+
};
|
|
1696
|
+
client.on("component:created", handleComponentCreated);
|
|
1697
|
+
client.on("component:updated", handleComponentUpdated);
|
|
1698
|
+
client.on("component:deleted", handleComponentDeleted);
|
|
1699
|
+
client.on("state:change", handleStateChange);
|
|
1700
|
+
setComponents(client.getState().components);
|
|
1701
|
+
return () => {
|
|
1702
|
+
client.off("component:created", handleComponentCreated);
|
|
1703
|
+
client.off("component:updated", handleComponentUpdated);
|
|
1704
|
+
client.off("component:deleted", handleComponentDeleted);
|
|
1705
|
+
client.off("state:change", handleStateChange);
|
|
1706
|
+
};
|
|
1707
|
+
}, [client]);
|
|
1708
|
+
const fetchComponents = useCallback13(async (queryParams, options) => {
|
|
1709
|
+
setIsLoading(true);
|
|
1710
|
+
setError(undefined);
|
|
1711
|
+
try {
|
|
1712
|
+
const response = await client.fetchComponents(queryParams, options);
|
|
1713
|
+
setComponents(response.data);
|
|
1714
|
+
return response;
|
|
1715
|
+
} catch (err) {
|
|
1716
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1717
|
+
setError(errorMessage);
|
|
1718
|
+
throw err;
|
|
1719
|
+
} finally {
|
|
1720
|
+
setIsLoading(false);
|
|
1721
|
+
}
|
|
1722
|
+
}, [client]);
|
|
1723
|
+
const getComponentById = useCallback13(async (componentId, options) => {
|
|
1724
|
+
setIsLoading(true);
|
|
1725
|
+
setError(undefined);
|
|
1726
|
+
try {
|
|
1727
|
+
return await client.getComponentById(componentId, options);
|
|
1728
|
+
} catch (err) {
|
|
1729
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1730
|
+
setError(errorMessage);
|
|
1731
|
+
throw err;
|
|
1732
|
+
} finally {
|
|
1733
|
+
setIsLoading(false);
|
|
1734
|
+
}
|
|
1735
|
+
}, [client]);
|
|
1736
|
+
const createComponent = useCallback13(async (request, options) => {
|
|
1737
|
+
setIsLoading(true);
|
|
1738
|
+
setError(undefined);
|
|
1739
|
+
try {
|
|
1740
|
+
return await client.createComponent(request, options);
|
|
1741
|
+
} catch (err) {
|
|
1742
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1743
|
+
setError(errorMessage);
|
|
1744
|
+
throw err;
|
|
1745
|
+
} finally {
|
|
1746
|
+
setIsLoading(false);
|
|
1747
|
+
}
|
|
1748
|
+
}, [client]);
|
|
1749
|
+
const updateComponent = useCallback13(async (componentId, request, options) => {
|
|
1750
|
+
setIsLoading(true);
|
|
1751
|
+
setError(undefined);
|
|
1752
|
+
try {
|
|
1753
|
+
return await client.updateComponent(componentId, request, options);
|
|
1754
|
+
} catch (err) {
|
|
1755
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1756
|
+
setError(errorMessage);
|
|
1757
|
+
throw err;
|
|
1758
|
+
} finally {
|
|
1759
|
+
setIsLoading(false);
|
|
1760
|
+
}
|
|
1761
|
+
}, [client]);
|
|
1762
|
+
const deleteComponent = useCallback13(async (componentId, options) => {
|
|
1763
|
+
setIsLoading(true);
|
|
1764
|
+
setError(undefined);
|
|
1765
|
+
try {
|
|
1766
|
+
await client.deleteComponent(componentId, options);
|
|
1767
|
+
} catch (err) {
|
|
1768
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1769
|
+
setError(errorMessage);
|
|
1770
|
+
throw err;
|
|
1771
|
+
} finally {
|
|
1772
|
+
setIsLoading(false);
|
|
1773
|
+
}
|
|
1774
|
+
}, [client]);
|
|
1775
|
+
const fetchComponentConfigs = useCallback13(async (componentId, options) => {
|
|
1776
|
+
setIsLoading(true);
|
|
1777
|
+
setError(undefined);
|
|
1778
|
+
try {
|
|
1779
|
+
return await client.fetchComponentConfigs(componentId, options);
|
|
1780
|
+
} catch (err) {
|
|
1781
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1782
|
+
setError(errorMessage);
|
|
1783
|
+
throw err;
|
|
1784
|
+
} finally {
|
|
1785
|
+
setIsLoading(false);
|
|
1786
|
+
}
|
|
1787
|
+
}, [client]);
|
|
1788
|
+
const createComponentConfig = useCallback13(async (componentId, request, options) => {
|
|
1789
|
+
setIsLoading(true);
|
|
1790
|
+
setError(undefined);
|
|
1791
|
+
try {
|
|
1792
|
+
return await client.createComponentConfig(componentId, request, options);
|
|
1793
|
+
} catch (err) {
|
|
1794
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1795
|
+
setError(errorMessage);
|
|
1796
|
+
throw err;
|
|
1797
|
+
} finally {
|
|
1798
|
+
setIsLoading(false);
|
|
1799
|
+
}
|
|
1800
|
+
}, [client]);
|
|
1801
|
+
const getCurrentComponentConfig = useCallback13(async (componentId, options) => {
|
|
1802
|
+
setIsLoading(true);
|
|
1803
|
+
setError(undefined);
|
|
1804
|
+
try {
|
|
1805
|
+
return await client.getCurrentComponentConfig(componentId, options);
|
|
1806
|
+
} catch (err) {
|
|
1807
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1808
|
+
setError(errorMessage);
|
|
1809
|
+
throw err;
|
|
1810
|
+
} finally {
|
|
1811
|
+
setIsLoading(false);
|
|
1812
|
+
}
|
|
1813
|
+
}, [client]);
|
|
1814
|
+
const getComponentConfigByVersion = useCallback13(async (componentId, version, options) => {
|
|
1815
|
+
setIsLoading(true);
|
|
1816
|
+
setError(undefined);
|
|
1817
|
+
try {
|
|
1818
|
+
return await client.getComponentConfigByVersion(componentId, version, options);
|
|
1819
|
+
} catch (err) {
|
|
1820
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1821
|
+
setError(errorMessage);
|
|
1822
|
+
throw err;
|
|
1823
|
+
} finally {
|
|
1824
|
+
setIsLoading(false);
|
|
1825
|
+
}
|
|
1826
|
+
}, [client]);
|
|
1827
|
+
const updateComponentConfig = useCallback13(async (componentId, version, request, options) => {
|
|
1828
|
+
setIsLoading(true);
|
|
1829
|
+
setError(undefined);
|
|
1830
|
+
try {
|
|
1831
|
+
return await client.updateComponentConfig(componentId, version, request, options);
|
|
1832
|
+
} catch (err) {
|
|
1833
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1834
|
+
setError(errorMessage);
|
|
1835
|
+
throw err;
|
|
1836
|
+
} finally {
|
|
1837
|
+
setIsLoading(false);
|
|
1838
|
+
}
|
|
1839
|
+
}, [client]);
|
|
1840
|
+
const deleteComponentConfig = useCallback13(async (componentId, version, options) => {
|
|
1841
|
+
setIsLoading(true);
|
|
1842
|
+
setError(undefined);
|
|
1843
|
+
try {
|
|
1844
|
+
await client.deleteComponentConfig(componentId, version, options);
|
|
1845
|
+
} catch (err) {
|
|
1846
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1847
|
+
setError(errorMessage);
|
|
1848
|
+
throw err;
|
|
1849
|
+
} finally {
|
|
1850
|
+
setIsLoading(false);
|
|
1851
|
+
}
|
|
1852
|
+
}, [client]);
|
|
1853
|
+
const setCurrentComponentConfig = useCallback13(async (componentId, version, options) => {
|
|
1854
|
+
setIsLoading(true);
|
|
1855
|
+
setError(undefined);
|
|
1856
|
+
try {
|
|
1857
|
+
return await client.setCurrentComponentConfig(componentId, version, options);
|
|
1858
|
+
} catch (err) {
|
|
1859
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
1860
|
+
setError(errorMessage);
|
|
1861
|
+
throw err;
|
|
1862
|
+
} finally {
|
|
1863
|
+
setIsLoading(false);
|
|
1864
|
+
}
|
|
1865
|
+
}, [client]);
|
|
1866
|
+
return {
|
|
1867
|
+
components,
|
|
1868
|
+
isLoading,
|
|
1869
|
+
error,
|
|
1870
|
+
fetchComponents,
|
|
1871
|
+
getComponentById,
|
|
1872
|
+
createComponent,
|
|
1873
|
+
updateComponent,
|
|
1874
|
+
deleteComponent,
|
|
1875
|
+
fetchComponentConfigs,
|
|
1876
|
+
createComponentConfig,
|
|
1877
|
+
getCurrentComponentConfig,
|
|
1878
|
+
getComponentConfigByVersion,
|
|
1879
|
+
updateComponentConfig,
|
|
1880
|
+
deleteComponentConfig,
|
|
1881
|
+
setCurrentComponentConfig
|
|
1882
|
+
};
|
|
1883
|
+
}
|
|
1676
1884
|
export {
|
|
1677
1885
|
useToolHandlers,
|
|
1678
1886
|
useAgnoTraces,
|
|
@@ -1684,6 +1892,7 @@ export {
|
|
|
1684
1892
|
useAgnoKnowledge,
|
|
1685
1893
|
useAgnoEvals,
|
|
1686
1894
|
useAgnoCustomEvents,
|
|
1895
|
+
useAgnoComponents,
|
|
1687
1896
|
useAgnoClient,
|
|
1688
1897
|
useAgnoChat,
|
|
1689
1898
|
useAgnoActions,
|
|
@@ -1713,4 +1922,4 @@ export {
|
|
|
1713
1922
|
AgnoProvider
|
|
1714
1923
|
};
|
|
1715
1924
|
|
|
1716
|
-
//# debugId=
|
|
1925
|
+
//# debugId=001BF048D0CD48E164756E2164756E21
|