@rodrigocoliveira/agno-react 1.1.6 → 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/index.js CHANGED
@@ -45,12 +45,14 @@ __export(exports_src, {
45
45
  useToolHandlers: () => useToolHandlers,
46
46
  useAgnoTraces: () => useAgnoTraces,
47
47
  useAgnoToolExecution: () => useAgnoToolExecution,
48
+ useAgnoSessionState: () => useAgnoSessionState,
48
49
  useAgnoSession: () => useAgnoSession,
49
50
  useAgnoMetrics: () => useAgnoMetrics,
50
51
  useAgnoMemory: () => useAgnoMemory,
51
52
  useAgnoKnowledge: () => useAgnoKnowledge,
52
53
  useAgnoEvals: () => useAgnoEvals,
53
54
  useAgnoCustomEvents: () => useAgnoCustomEvents,
55
+ useAgnoComponents: () => useAgnoComponents,
54
56
  useAgnoClient: () => useAgnoClient,
55
57
  useAgnoChat: () => useAgnoChat,
56
58
  useAgnoActions: () => useAgnoActions,
@@ -84,7 +86,7 @@ module.exports = __toCommonJS(exports_src);
84
86
  // src/context/AgnoContext.tsx
85
87
  var import_react = require("react");
86
88
  var import_agno_client = require("@rodrigocoliveira/agno-client");
87
- var jsx_dev_runtime = require("react/jsx-dev-runtime");
89
+ var jsx_runtime = require("react/jsx-runtime");
88
90
  var AgnoContext = import_react.createContext(null);
89
91
  function AgnoProvider({ config, children }) {
90
92
  const client = import_react.useMemo(() => new import_agno_client.AgnoClient(config), []);
@@ -96,10 +98,10 @@ function AgnoProvider({ config, children }) {
96
98
  client.removeAllListeners();
97
99
  };
98
100
  }, [client]);
99
- return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(AgnoContext.Provider, {
101
+ return /* @__PURE__ */ jsx_runtime.jsx(AgnoContext.Provider, {
100
102
  value: client,
101
103
  children
102
- }, undefined, false, undefined, this);
104
+ });
103
105
  }
104
106
  function useAgnoClient() {
105
107
  const client = import_react.useContext(AgnoContext);
@@ -110,7 +112,7 @@ function useAgnoClient() {
110
112
  }
111
113
  // src/context/ToolHandlerContext.tsx
112
114
  var import_react2 = require("react");
113
- var jsx_dev_runtime2 = require("react/jsx-dev-runtime");
115
+ var jsx_runtime2 = require("react/jsx-runtime");
114
116
  var ToolHandlerContext = import_react2.createContext(null);
115
117
  function ToolHandlerProvider({ handlers: initialHandlers = {}, children }) {
116
118
  const [handlers, setHandlers] = import_react2.useState(initialHandlers);
@@ -128,10 +130,10 @@ function ToolHandlerProvider({ handlers: initialHandlers = {}, children }) {
128
130
  registerHandler,
129
131
  unregisterHandler
130
132
  };
131
- return /* @__PURE__ */ jsx_dev_runtime2.jsxDEV(ToolHandlerContext.Provider, {
133
+ return /* @__PURE__ */ jsx_runtime2.jsx(ToolHandlerContext.Provider, {
132
134
  value,
133
135
  children
134
- }, undefined, false, undefined, this);
136
+ });
135
137
  }
136
138
  function useToolHandlers() {
137
139
  return import_react2.useContext(ToolHandlerContext);
@@ -417,7 +419,7 @@ function useAgnoToolExecution(handlers = {}, autoExecute = true, options) {
417
419
  }
418
420
 
419
421
  // src/components/GenerativeUIRenderer.tsx
420
- var jsx_dev_runtime3 = require("react/jsx-dev-runtime");
422
+ var jsx_runtime3 = require("react/jsx-runtime");
421
423
 
422
424
  class UIErrorBoundary extends import_react4.default.Component {
423
425
  constructor(props) {
@@ -433,19 +435,19 @@ class UIErrorBoundary extends import_react4.default.Component {
433
435
  }
434
436
  render() {
435
437
  if (this.state.hasError) {
436
- return this.props.fallback || /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
438
+ return this.props.fallback || /* @__PURE__ */ jsx_runtime3.jsxs("div", {
437
439
  className: "p-4 border border-red-300 rounded-md bg-red-50 text-red-800",
438
440
  children: [
439
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
441
+ /* @__PURE__ */ jsx_runtime3.jsx("p", {
440
442
  className: "font-semibold",
441
443
  children: "Failed to render UI component"
442
- }, undefined, false, undefined, this),
443
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
444
+ }),
445
+ /* @__PURE__ */ jsx_runtime3.jsx("p", {
444
446
  className: "text-sm mt-1",
445
447
  children: this.state.error?.message || "Unknown error"
446
- }, undefined, false, undefined, this)
448
+ })
447
449
  ]
448
- }, undefined, true, undefined, this);
450
+ });
449
451
  }
450
452
  return this.props.children;
451
453
  }
@@ -461,183 +463,183 @@ function GenerativeUIRenderer({
461
463
  if (customSpec.renderKey) {
462
464
  const renderFn = getCustomRender(customSpec.renderKey);
463
465
  if (renderFn) {
464
- return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(UIErrorBoundary, {
466
+ return /* @__PURE__ */ jsx_runtime3.jsx(UIErrorBoundary, {
465
467
  onError,
466
- children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
468
+ children: /* @__PURE__ */ jsx_runtime3.jsx("div", {
467
469
  className,
468
470
  children: renderFn(customSpec.props || {})
469
- }, undefined, false, undefined, this)
470
- }, undefined, false, undefined, this);
471
+ })
472
+ });
471
473
  }
472
474
  }
473
- return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
475
+ return /* @__PURE__ */ jsx_runtime3.jsxs("div", {
474
476
  className: `p-4 border border-yellow-300 rounded-md bg-yellow-50 text-yellow-800 ${className || ""}`,
475
477
  children: [
476
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
478
+ /* @__PURE__ */ jsx_runtime3.jsx("p", {
477
479
  className: "font-semibold",
478
480
  children: "Custom component not available"
479
- }, undefined, false, undefined, this),
480
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
481
+ }),
482
+ /* @__PURE__ */ jsx_runtime3.jsx("p", {
481
483
  className: "text-sm mt-1",
482
484
  children: "The custom render function for this component is not available."
483
- }, undefined, false, undefined, this)
485
+ })
484
486
  ]
485
- }, undefined, true, undefined, this);
487
+ });
486
488
  }
487
489
  if (spec.type === "chart") {
488
490
  const chartSpec = spec;
489
491
  const chartType = `chart:${chartSpec.component}`;
490
492
  if (registry.has(chartType)) {
491
493
  const ChartRenderer = registry.get(chartType);
492
- return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(UIErrorBoundary, {
494
+ return /* @__PURE__ */ jsx_runtime3.jsx(UIErrorBoundary, {
493
495
  onError,
494
- children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
496
+ children: /* @__PURE__ */ jsx_runtime3.jsxs("div", {
495
497
  className,
496
498
  children: [
497
- chartSpec.title && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("h3", {
499
+ chartSpec.title && /* @__PURE__ */ jsx_runtime3.jsx("h3", {
498
500
  className: "font-semibold mb-2",
499
501
  children: chartSpec.title
500
- }, undefined, false, undefined, this),
501
- chartSpec.description && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
502
+ }),
503
+ chartSpec.description && /* @__PURE__ */ jsx_runtime3.jsx("p", {
502
504
  className: "text-sm text-gray-600 mb-4",
503
505
  children: chartSpec.description
504
- }, undefined, false, undefined, this),
505
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(ChartRenderer, {
506
+ }),
507
+ /* @__PURE__ */ jsx_runtime3.jsx(ChartRenderer, {
506
508
  ...chartSpec.props
507
- }, undefined, false, undefined, this)
509
+ })
508
510
  ]
509
- }, undefined, true, undefined, this)
510
- }, undefined, false, undefined, this);
511
+ })
512
+ });
511
513
  }
512
- return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
514
+ return /* @__PURE__ */ jsx_runtime3.jsxs("div", {
513
515
  className: `p-4 border border-gray-300 rounded-md ${className || ""}`,
514
516
  children: [
515
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
517
+ /* @__PURE__ */ jsx_runtime3.jsx("p", {
516
518
  className: "font-semibold mb-2",
517
519
  children: chartSpec.title || "Chart Data"
518
- }, undefined, false, undefined, this),
519
- chartSpec.description && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
520
+ }),
521
+ chartSpec.description && /* @__PURE__ */ jsx_runtime3.jsx("p", {
520
522
  className: "text-sm text-gray-600 mb-2",
521
523
  children: chartSpec.description
522
- }, undefined, false, undefined, this),
523
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("pre", {
524
+ }),
525
+ /* @__PURE__ */ jsx_runtime3.jsx("pre", {
524
526
  className: "text-xs bg-gray-100 p-2 rounded overflow-auto",
525
527
  children: JSON.stringify(chartSpec.props.data, null, 2)
526
- }, undefined, false, undefined, this)
528
+ })
527
529
  ]
528
- }, undefined, true, undefined, this);
530
+ });
529
531
  }
530
532
  if (spec.type === "card-grid") {
531
533
  const cardGridSpec = spec;
532
534
  if (registry.has("card-grid")) {
533
535
  const CardGridRenderer = registry.get("card-grid");
534
- return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(UIErrorBoundary, {
536
+ return /* @__PURE__ */ jsx_runtime3.jsx(UIErrorBoundary, {
535
537
  onError,
536
- children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
538
+ children: /* @__PURE__ */ jsx_runtime3.jsxs("div", {
537
539
  className,
538
540
  children: [
539
- cardGridSpec.title && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("h3", {
541
+ cardGridSpec.title && /* @__PURE__ */ jsx_runtime3.jsx("h3", {
540
542
  className: "font-semibold mb-2",
541
543
  children: cardGridSpec.title
542
- }, undefined, false, undefined, this),
543
- cardGridSpec.description && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
544
+ }),
545
+ cardGridSpec.description && /* @__PURE__ */ jsx_runtime3.jsx("p", {
544
546
  className: "text-sm text-gray-600 mb-4",
545
547
  children: cardGridSpec.description
546
- }, undefined, false, undefined, this),
547
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(CardGridRenderer, {
548
+ }),
549
+ /* @__PURE__ */ jsx_runtime3.jsx(CardGridRenderer, {
548
550
  ...cardGridSpec.props
549
- }, undefined, false, undefined, this)
551
+ })
550
552
  ]
551
- }, undefined, true, undefined, this)
552
- }, undefined, false, undefined, this);
553
+ })
554
+ });
553
555
  }
554
556
  }
555
557
  if (spec.type === "table") {
556
558
  const tableSpec = spec;
557
559
  if (registry.has("table")) {
558
560
  const TableRenderer = registry.get("table");
559
- return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(UIErrorBoundary, {
561
+ return /* @__PURE__ */ jsx_runtime3.jsx(UIErrorBoundary, {
560
562
  onError,
561
- children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
563
+ children: /* @__PURE__ */ jsx_runtime3.jsxs("div", {
562
564
  className,
563
565
  children: [
564
- tableSpec.title && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("h3", {
566
+ tableSpec.title && /* @__PURE__ */ jsx_runtime3.jsx("h3", {
565
567
  className: "font-semibold mb-2",
566
568
  children: tableSpec.title
567
- }, undefined, false, undefined, this),
568
- tableSpec.description && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
569
+ }),
570
+ tableSpec.description && /* @__PURE__ */ jsx_runtime3.jsx("p", {
569
571
  className: "text-sm text-gray-600 mb-4",
570
572
  children: tableSpec.description
571
- }, undefined, false, undefined, this),
572
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(TableRenderer, {
573
+ }),
574
+ /* @__PURE__ */ jsx_runtime3.jsx(TableRenderer, {
573
575
  ...tableSpec.props
574
- }, undefined, false, undefined, this)
576
+ })
575
577
  ]
576
- }, undefined, true, undefined, this)
577
- }, undefined, false, undefined, this);
578
+ })
579
+ });
578
580
  }
579
581
  }
580
582
  if (spec.type === "markdown") {
581
583
  const markdownSpec = spec;
582
584
  if (registry.has("markdown")) {
583
585
  const MarkdownRenderer = registry.get("markdown");
584
- return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(UIErrorBoundary, {
586
+ return /* @__PURE__ */ jsx_runtime3.jsx(UIErrorBoundary, {
585
587
  onError,
586
- children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
588
+ children: /* @__PURE__ */ jsx_runtime3.jsx("div", {
587
589
  className,
588
- children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(MarkdownRenderer, {
590
+ children: /* @__PURE__ */ jsx_runtime3.jsx(MarkdownRenderer, {
589
591
  ...markdownSpec.props
590
- }, undefined, false, undefined, this)
591
- }, undefined, false, undefined, this)
592
- }, undefined, false, undefined, this);
592
+ })
593
+ })
594
+ });
593
595
  }
594
- return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
596
+ return /* @__PURE__ */ jsx_runtime3.jsx("div", {
595
597
  className,
596
598
  children: markdownSpec.props.content
597
- }, undefined, false, undefined, this);
599
+ });
598
600
  }
599
601
  if (spec.type === "artifact") {
600
602
  const artifactSpec = spec;
601
- return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(UIErrorBoundary, {
603
+ return /* @__PURE__ */ jsx_runtime3.jsx(UIErrorBoundary, {
602
604
  onError,
603
- children: /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
605
+ children: /* @__PURE__ */ jsx_runtime3.jsxs("div", {
604
606
  className: `p-4 border rounded-md ${className || ""}`,
605
607
  children: [
606
- artifactSpec.title && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("h3", {
608
+ artifactSpec.title && /* @__PURE__ */ jsx_runtime3.jsx("h3", {
607
609
  className: "font-semibold mb-4",
608
610
  children: artifactSpec.title
609
- }, undefined, false, undefined, this),
610
- artifactSpec.description && /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
611
+ }),
612
+ artifactSpec.description && /* @__PURE__ */ jsx_runtime3.jsx("p", {
611
613
  className: "text-sm text-gray-600 mb-4",
612
614
  children: artifactSpec.description
613
- }, undefined, false, undefined, this),
614
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
615
+ }),
616
+ /* @__PURE__ */ jsx_runtime3.jsx("div", {
615
617
  className: "space-y-4",
616
- children: artifactSpec.props.content?.map((childSpec, index) => /* @__PURE__ */ jsx_dev_runtime3.jsxDEV(GenerativeUIRenderer, {
618
+ children: artifactSpec.props.content?.map((childSpec, index) => /* @__PURE__ */ jsx_runtime3.jsx(GenerativeUIRenderer, {
617
619
  spec: childSpec,
618
620
  onError
619
- }, index, false, undefined, this))
620
- }, undefined, false, undefined, this)
621
+ }, index))
622
+ })
621
623
  ]
622
- }, undefined, true, undefined, this)
623
- }, undefined, false, undefined, this);
624
+ })
625
+ });
624
626
  }
625
- return /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("div", {
627
+ return /* @__PURE__ */ jsx_runtime3.jsxs("div", {
626
628
  className: `p-4 border border-gray-300 rounded-md ${className || ""}`,
627
629
  children: [
628
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
630
+ /* @__PURE__ */ jsx_runtime3.jsx("p", {
629
631
  className: "font-semibold",
630
632
  children: "Unsupported UI component"
631
- }, undefined, false, undefined, this),
632
- /* @__PURE__ */ jsx_dev_runtime3.jsxDEV("p", {
633
+ }),
634
+ /* @__PURE__ */ jsx_runtime3.jsxs("p", {
633
635
  className: "text-sm text-gray-600 mt-1",
634
636
  children: [
635
637
  "Component type: ",
636
638
  spec.type
637
639
  ]
638
- }, undefined, true, undefined, this)
640
+ })
639
641
  ]
640
- }, undefined, true, undefined, this);
642
+ });
641
643
  }
642
644
  // src/utils/ui-helpers.ts
643
645
  function createBarChart(data, xKey, bars, options) {
@@ -1336,15 +1338,59 @@ function useAgnoMemory() {
1336
1338
  deleteMultipleMemories
1337
1339
  };
1338
1340
  }
1339
- // src/hooks/useAgnoKnowledge.ts
1341
+ // src/hooks/useAgnoSessionState.ts
1340
1342
  var import_react10 = require("react");
1343
+ function useAgnoSessionState() {
1344
+ const client = useAgnoClient();
1345
+ const [sessionState, setLocalSessionState] = import_react10.useState(() => client.getSessionState());
1346
+ const [isRefreshing, setIsRefreshing] = import_react10.useState(() => client.getState().isSessionStateRefreshing ?? false);
1347
+ import_react10.useEffect(() => {
1348
+ const handleStateChange = (state) => {
1349
+ setLocalSessionState(state);
1350
+ };
1351
+ const handleRefreshStart = () => setIsRefreshing(true);
1352
+ const handleRefreshEnd = () => setIsRefreshing(false);
1353
+ client.on("session-state:change", handleStateChange);
1354
+ client.on("session-state:refresh:start", handleRefreshStart);
1355
+ client.on("session-state:refresh:end", handleRefreshEnd);
1356
+ setLocalSessionState(client.getSessionState());
1357
+ setIsRefreshing(client.getState().isSessionStateRefreshing ?? false);
1358
+ return () => {
1359
+ client.off("session-state:change", handleStateChange);
1360
+ client.off("session-state:refresh:start", handleRefreshStart);
1361
+ client.off("session-state:refresh:end", handleRefreshEnd);
1362
+ };
1363
+ }, [client]);
1364
+ const setSessionState = import_react10.useCallback(async (next) => {
1365
+ const resolved = typeof next === "function" ? next(client.getSessionState()) : next;
1366
+ await client.setSessionState(resolved);
1367
+ }, [client]);
1368
+ const mergeSessionState = import_react10.useCallback(async (partial) => {
1369
+ const current = client.getSessionState() ?? {};
1370
+ const merged = { ...current, ...partial };
1371
+ await client.setSessionState(merged);
1372
+ }, [client]);
1373
+ const refreshSessionState = import_react10.useCallback(async () => {
1374
+ const result = await client.refreshSessionState();
1375
+ return result ?? null;
1376
+ }, [client]);
1377
+ return {
1378
+ sessionState,
1379
+ isRefreshing,
1380
+ setSessionState,
1381
+ mergeSessionState,
1382
+ refreshSessionState
1383
+ };
1384
+ }
1385
+ // src/hooks/useAgnoKnowledge.ts
1386
+ var import_react11 = require("react");
1341
1387
  function useAgnoKnowledge() {
1342
1388
  const client = useAgnoClient();
1343
- const [isLoading, setIsLoading] = import_react10.useState(false);
1344
- const [error, setError] = import_react10.useState();
1345
- const [config, setConfig] = import_react10.useState();
1346
- const [content, setContent] = import_react10.useState([]);
1347
- const getConfig = import_react10.useCallback(async (options) => {
1389
+ const [isLoading, setIsLoading] = import_react11.useState(false);
1390
+ const [error, setError] = import_react11.useState();
1391
+ const [config, setConfig] = import_react11.useState();
1392
+ const [content, setContent] = import_react11.useState([]);
1393
+ const getConfig = import_react11.useCallback(async (options) => {
1348
1394
  setIsLoading(true);
1349
1395
  setError(undefined);
1350
1396
  try {
@@ -1359,7 +1405,7 @@ function useAgnoKnowledge() {
1359
1405
  setIsLoading(false);
1360
1406
  }
1361
1407
  }, [client]);
1362
- const listContent = import_react10.useCallback(async (listOptions, options) => {
1408
+ const listContent = import_react11.useCallback(async (listOptions, options) => {
1363
1409
  setIsLoading(true);
1364
1410
  setError(undefined);
1365
1411
  try {
@@ -1374,7 +1420,7 @@ function useAgnoKnowledge() {
1374
1420
  setIsLoading(false);
1375
1421
  }
1376
1422
  }, [client]);
1377
- const getContent = import_react10.useCallback(async (contentId, options) => {
1423
+ const getContent = import_react11.useCallback(async (contentId, options) => {
1378
1424
  setIsLoading(true);
1379
1425
  setError(undefined);
1380
1426
  try {
@@ -1387,7 +1433,7 @@ function useAgnoKnowledge() {
1387
1433
  setIsLoading(false);
1388
1434
  }
1389
1435
  }, [client]);
1390
- const getContentStatus = import_react10.useCallback(async (contentId, options) => {
1436
+ const getContentStatus = import_react11.useCallback(async (contentId, options) => {
1391
1437
  setIsLoading(true);
1392
1438
  setError(undefined);
1393
1439
  try {
@@ -1400,7 +1446,7 @@ function useAgnoKnowledge() {
1400
1446
  setIsLoading(false);
1401
1447
  }
1402
1448
  }, [client]);
1403
- const search = import_react10.useCallback(async (request, options) => {
1449
+ const search = import_react11.useCallback(async (request, options) => {
1404
1450
  setIsLoading(true);
1405
1451
  setError(undefined);
1406
1452
  try {
@@ -1413,7 +1459,7 @@ function useAgnoKnowledge() {
1413
1459
  setIsLoading(false);
1414
1460
  }
1415
1461
  }, [client]);
1416
- const uploadContent = import_react10.useCallback(async (data, options) => {
1462
+ const uploadContent = import_react11.useCallback(async (data, options) => {
1417
1463
  setIsLoading(true);
1418
1464
  setError(undefined);
1419
1465
  try {
@@ -1428,7 +1474,7 @@ function useAgnoKnowledge() {
1428
1474
  setIsLoading(false);
1429
1475
  }
1430
1476
  }, [client]);
1431
- const updateContent = import_react10.useCallback(async (contentId, request, options) => {
1477
+ const updateContent = import_react11.useCallback(async (contentId, request, options) => {
1432
1478
  setIsLoading(true);
1433
1479
  setError(undefined);
1434
1480
  try {
@@ -1443,7 +1489,7 @@ function useAgnoKnowledge() {
1443
1489
  setIsLoading(false);
1444
1490
  }
1445
1491
  }, [client]);
1446
- const deleteAllContent = import_react10.useCallback(async (options) => {
1492
+ const deleteAllContent = import_react11.useCallback(async (options) => {
1447
1493
  setIsLoading(true);
1448
1494
  setError(undefined);
1449
1495
  try {
@@ -1457,7 +1503,7 @@ function useAgnoKnowledge() {
1457
1503
  setIsLoading(false);
1458
1504
  }
1459
1505
  }, [client]);
1460
- const deleteContent = import_react10.useCallback(async (contentId, options) => {
1506
+ const deleteContent = import_react11.useCallback(async (contentId, options) => {
1461
1507
  setIsLoading(true);
1462
1508
  setError(undefined);
1463
1509
  try {
@@ -1489,14 +1535,14 @@ function useAgnoKnowledge() {
1489
1535
  };
1490
1536
  }
1491
1537
  // src/hooks/useAgnoMetrics.ts
1492
- var import_react11 = require("react");
1538
+ var import_react12 = require("react");
1493
1539
  function useAgnoMetrics() {
1494
1540
  const client = useAgnoClient();
1495
- const [isLoading, setIsLoading] = import_react11.useState(false);
1496
- const [isRefreshing, setIsRefreshing] = import_react11.useState(false);
1497
- const [error, setError] = import_react11.useState();
1498
- const [metrics, setMetrics] = import_react11.useState();
1499
- const fetchMetrics = import_react11.useCallback(async (options) => {
1541
+ const [isLoading, setIsLoading] = import_react12.useState(false);
1542
+ const [isRefreshing, setIsRefreshing] = import_react12.useState(false);
1543
+ const [error, setError] = import_react12.useState();
1544
+ const [metrics, setMetrics] = import_react12.useState();
1545
+ const fetchMetrics = import_react12.useCallback(async (options) => {
1500
1546
  setIsLoading(true);
1501
1547
  setError(undefined);
1502
1548
  try {
@@ -1511,7 +1557,7 @@ function useAgnoMetrics() {
1511
1557
  setIsLoading(false);
1512
1558
  }
1513
1559
  }, [client]);
1514
- const refreshMetrics = import_react11.useCallback(async (options) => {
1560
+ const refreshMetrics = import_react12.useCallback(async (options) => {
1515
1561
  setIsRefreshing(true);
1516
1562
  setError(undefined);
1517
1563
  try {
@@ -1525,7 +1571,7 @@ function useAgnoMetrics() {
1525
1571
  setIsRefreshing(false);
1526
1572
  }
1527
1573
  }, [client]);
1528
- const clearMetrics = import_react11.useCallback(() => {
1574
+ const clearMetrics = import_react12.useCallback(() => {
1529
1575
  setMetrics(undefined);
1530
1576
  setError(undefined);
1531
1577
  }, []);
@@ -1540,14 +1586,14 @@ function useAgnoMetrics() {
1540
1586
  };
1541
1587
  }
1542
1588
  // src/hooks/useAgnoEvals.ts
1543
- var import_react12 = require("react");
1589
+ var import_react13 = require("react");
1544
1590
  function useAgnoEvals() {
1545
1591
  const client = useAgnoClient();
1546
- const [evalRuns, setEvalRuns] = import_react12.useState([]);
1547
- const [pagination, setPagination] = import_react12.useState();
1548
- const [isLoading, setIsLoading] = import_react12.useState(false);
1549
- const [error, setError] = import_react12.useState();
1550
- const listEvalRuns = import_react12.useCallback(async (listParams = {}, options) => {
1592
+ const [evalRuns, setEvalRuns] = import_react13.useState([]);
1593
+ const [pagination, setPagination] = import_react13.useState();
1594
+ const [isLoading, setIsLoading] = import_react13.useState(false);
1595
+ const [error, setError] = import_react13.useState();
1596
+ const listEvalRuns = import_react13.useCallback(async (listParams = {}, options) => {
1551
1597
  setIsLoading(true);
1552
1598
  setError(undefined);
1553
1599
  try {
@@ -1563,7 +1609,7 @@ function useAgnoEvals() {
1563
1609
  setIsLoading(false);
1564
1610
  }
1565
1611
  }, [client]);
1566
- const getEvalRun = import_react12.useCallback(async (evalRunId, options) => {
1612
+ const getEvalRun = import_react13.useCallback(async (evalRunId, options) => {
1567
1613
  setIsLoading(true);
1568
1614
  setError(undefined);
1569
1615
  try {
@@ -1576,7 +1622,7 @@ function useAgnoEvals() {
1576
1622
  setIsLoading(false);
1577
1623
  }
1578
1624
  }, [client]);
1579
- const executeEval = import_react12.useCallback(async (request, options) => {
1625
+ const executeEval = import_react13.useCallback(async (request, options) => {
1580
1626
  setIsLoading(true);
1581
1627
  setError(undefined);
1582
1628
  try {
@@ -1591,7 +1637,7 @@ function useAgnoEvals() {
1591
1637
  setIsLoading(false);
1592
1638
  }
1593
1639
  }, [client]);
1594
- const updateEvalRun = import_react12.useCallback(async (evalRunId, request, options) => {
1640
+ const updateEvalRun = import_react13.useCallback(async (evalRunId, request, options) => {
1595
1641
  setIsLoading(true);
1596
1642
  setError(undefined);
1597
1643
  try {
@@ -1606,7 +1652,7 @@ function useAgnoEvals() {
1606
1652
  setIsLoading(false);
1607
1653
  }
1608
1654
  }, [client]);
1609
- const deleteEvalRuns = import_react12.useCallback(async (evalRunIds, options) => {
1655
+ const deleteEvalRuns = import_react13.useCallback(async (evalRunIds, options) => {
1610
1656
  setIsLoading(true);
1611
1657
  setError(undefined);
1612
1658
  try {
@@ -1621,7 +1667,7 @@ function useAgnoEvals() {
1621
1667
  setIsLoading(false);
1622
1668
  }
1623
1669
  }, [client]);
1624
- const renameEvalRun = import_react12.useCallback(async (evalRunId, newName, options) => {
1670
+ const renameEvalRun = import_react13.useCallback(async (evalRunId, newName, options) => {
1625
1671
  return updateEvalRun(evalRunId, { name: newName }, options);
1626
1672
  }, [updateEvalRun]);
1627
1673
  return {
@@ -1638,14 +1684,14 @@ function useAgnoEvals() {
1638
1684
  };
1639
1685
  }
1640
1686
  // src/hooks/useAgnoTraces.ts
1641
- var import_react13 = require("react");
1687
+ var import_react14 = require("react");
1642
1688
  function useAgnoTraces() {
1643
1689
  const client = useAgnoClient();
1644
- const [traces, setTraces] = import_react13.useState([]);
1645
- const [traceSessionStats, setTraceSessionStats] = import_react13.useState([]);
1646
- const [isLoading, setIsLoading] = import_react13.useState(false);
1647
- const [error, setError] = import_react13.useState();
1648
- import_react13.useEffect(() => {
1690
+ const [traces, setTraces] = import_react14.useState([]);
1691
+ const [traceSessionStats, setTraceSessionStats] = import_react14.useState([]);
1692
+ const [isLoading, setIsLoading] = import_react14.useState(false);
1693
+ const [error, setError] = import_react14.useState();
1694
+ import_react14.useEffect(() => {
1649
1695
  const handleStateChange = () => {
1650
1696
  const state2 = client.getState();
1651
1697
  setTraces(state2.traces);
@@ -1659,7 +1705,7 @@ function useAgnoTraces() {
1659
1705
  client.off("state:change", handleStateChange);
1660
1706
  };
1661
1707
  }, [client]);
1662
- const fetchTraces = import_react13.useCallback(async (options = {}, requestOptions) => {
1708
+ const fetchTraces = import_react14.useCallback(async (options = {}, requestOptions) => {
1663
1709
  setIsLoading(true);
1664
1710
  setError(undefined);
1665
1711
  try {
@@ -1674,7 +1720,7 @@ function useAgnoTraces() {
1674
1720
  setIsLoading(false);
1675
1721
  }
1676
1722
  }, [client]);
1677
- const getTraceDetail = import_react13.useCallback(async (traceId, options = {}, requestOptions) => {
1723
+ const getTraceDetail = import_react14.useCallback(async (traceId, options = {}, requestOptions) => {
1678
1724
  setIsLoading(true);
1679
1725
  setError(undefined);
1680
1726
  try {
@@ -1687,7 +1733,7 @@ function useAgnoTraces() {
1687
1733
  setIsLoading(false);
1688
1734
  }
1689
1735
  }, [client]);
1690
- const fetchTraceSessionStats = import_react13.useCallback(async (options = {}, requestOptions) => {
1736
+ const fetchTraceSessionStats = import_react14.useCallback(async (options = {}, requestOptions) => {
1691
1737
  setIsLoading(true);
1692
1738
  setError(undefined);
1693
1739
  try {
@@ -1712,5 +1758,213 @@ function useAgnoTraces() {
1712
1758
  error
1713
1759
  };
1714
1760
  }
1761
+ // src/hooks/useAgnoComponents.ts
1762
+ var import_react15 = require("react");
1763
+ function useAgnoComponents() {
1764
+ const client = useAgnoClient();
1765
+ const [components, setComponents] = import_react15.useState([]);
1766
+ const [isLoading, setIsLoading] = import_react15.useState(false);
1767
+ const [error, setError] = import_react15.useState();
1768
+ import_react15.useEffect(() => {
1769
+ const handleComponentCreated = (component) => {
1770
+ setComponents((prev) => [component, ...prev]);
1771
+ };
1772
+ const handleComponentUpdated = (component) => {
1773
+ setComponents((prev) => prev.map((c) => c.component_id === component.component_id ? component : c));
1774
+ };
1775
+ const handleComponentDeleted = ({ componentId }) => {
1776
+ setComponents((prev) => prev.filter((c) => c.component_id !== componentId));
1777
+ };
1778
+ const handleStateChange = () => {
1779
+ setComponents(client.getState().components);
1780
+ };
1781
+ client.on("component:created", handleComponentCreated);
1782
+ client.on("component:updated", handleComponentUpdated);
1783
+ client.on("component:deleted", handleComponentDeleted);
1784
+ client.on("state:change", handleStateChange);
1785
+ setComponents(client.getState().components);
1786
+ return () => {
1787
+ client.off("component:created", handleComponentCreated);
1788
+ client.off("component:updated", handleComponentUpdated);
1789
+ client.off("component:deleted", handleComponentDeleted);
1790
+ client.off("state:change", handleStateChange);
1791
+ };
1792
+ }, [client]);
1793
+ const fetchComponents = import_react15.useCallback(async (queryParams, options) => {
1794
+ setIsLoading(true);
1795
+ setError(undefined);
1796
+ try {
1797
+ const response = await client.fetchComponents(queryParams, options);
1798
+ setComponents(response.data);
1799
+ return response;
1800
+ } catch (err) {
1801
+ const errorMessage = err instanceof Error ? err.message : String(err);
1802
+ setError(errorMessage);
1803
+ throw err;
1804
+ } finally {
1805
+ setIsLoading(false);
1806
+ }
1807
+ }, [client]);
1808
+ const getComponentById = import_react15.useCallback(async (componentId, options) => {
1809
+ setIsLoading(true);
1810
+ setError(undefined);
1811
+ try {
1812
+ return await client.getComponentById(componentId, options);
1813
+ } catch (err) {
1814
+ const errorMessage = err instanceof Error ? err.message : String(err);
1815
+ setError(errorMessage);
1816
+ throw err;
1817
+ } finally {
1818
+ setIsLoading(false);
1819
+ }
1820
+ }, [client]);
1821
+ const createComponent = import_react15.useCallback(async (request, options) => {
1822
+ setIsLoading(true);
1823
+ setError(undefined);
1824
+ try {
1825
+ return await client.createComponent(request, options);
1826
+ } catch (err) {
1827
+ const errorMessage = err instanceof Error ? err.message : String(err);
1828
+ setError(errorMessage);
1829
+ throw err;
1830
+ } finally {
1831
+ setIsLoading(false);
1832
+ }
1833
+ }, [client]);
1834
+ const updateComponent = import_react15.useCallback(async (componentId, request, options) => {
1835
+ setIsLoading(true);
1836
+ setError(undefined);
1837
+ try {
1838
+ return await client.updateComponent(componentId, request, options);
1839
+ } catch (err) {
1840
+ const errorMessage = err instanceof Error ? err.message : String(err);
1841
+ setError(errorMessage);
1842
+ throw err;
1843
+ } finally {
1844
+ setIsLoading(false);
1845
+ }
1846
+ }, [client]);
1847
+ const deleteComponent = import_react15.useCallback(async (componentId, options) => {
1848
+ setIsLoading(true);
1849
+ setError(undefined);
1850
+ try {
1851
+ await client.deleteComponent(componentId, options);
1852
+ } catch (err) {
1853
+ const errorMessage = err instanceof Error ? err.message : String(err);
1854
+ setError(errorMessage);
1855
+ throw err;
1856
+ } finally {
1857
+ setIsLoading(false);
1858
+ }
1859
+ }, [client]);
1860
+ const fetchComponentConfigs = import_react15.useCallback(async (componentId, options) => {
1861
+ setIsLoading(true);
1862
+ setError(undefined);
1863
+ try {
1864
+ return await client.fetchComponentConfigs(componentId, options);
1865
+ } catch (err) {
1866
+ const errorMessage = err instanceof Error ? err.message : String(err);
1867
+ setError(errorMessage);
1868
+ throw err;
1869
+ } finally {
1870
+ setIsLoading(false);
1871
+ }
1872
+ }, [client]);
1873
+ const createComponentConfig = import_react15.useCallback(async (componentId, request, options) => {
1874
+ setIsLoading(true);
1875
+ setError(undefined);
1876
+ try {
1877
+ return await client.createComponentConfig(componentId, request, options);
1878
+ } catch (err) {
1879
+ const errorMessage = err instanceof Error ? err.message : String(err);
1880
+ setError(errorMessage);
1881
+ throw err;
1882
+ } finally {
1883
+ setIsLoading(false);
1884
+ }
1885
+ }, [client]);
1886
+ const getCurrentComponentConfig = import_react15.useCallback(async (componentId, options) => {
1887
+ setIsLoading(true);
1888
+ setError(undefined);
1889
+ try {
1890
+ return await client.getCurrentComponentConfig(componentId, options);
1891
+ } catch (err) {
1892
+ const errorMessage = err instanceof Error ? err.message : String(err);
1893
+ setError(errorMessage);
1894
+ throw err;
1895
+ } finally {
1896
+ setIsLoading(false);
1897
+ }
1898
+ }, [client]);
1899
+ const getComponentConfigByVersion = import_react15.useCallback(async (componentId, version, options) => {
1900
+ setIsLoading(true);
1901
+ setError(undefined);
1902
+ try {
1903
+ return await client.getComponentConfigByVersion(componentId, version, options);
1904
+ } catch (err) {
1905
+ const errorMessage = err instanceof Error ? err.message : String(err);
1906
+ setError(errorMessage);
1907
+ throw err;
1908
+ } finally {
1909
+ setIsLoading(false);
1910
+ }
1911
+ }, [client]);
1912
+ const updateComponentConfig = import_react15.useCallback(async (componentId, version, request, options) => {
1913
+ setIsLoading(true);
1914
+ setError(undefined);
1915
+ try {
1916
+ return await client.updateComponentConfig(componentId, version, request, options);
1917
+ } catch (err) {
1918
+ const errorMessage = err instanceof Error ? err.message : String(err);
1919
+ setError(errorMessage);
1920
+ throw err;
1921
+ } finally {
1922
+ setIsLoading(false);
1923
+ }
1924
+ }, [client]);
1925
+ const deleteComponentConfig = import_react15.useCallback(async (componentId, version, options) => {
1926
+ setIsLoading(true);
1927
+ setError(undefined);
1928
+ try {
1929
+ await client.deleteComponentConfig(componentId, version, options);
1930
+ } catch (err) {
1931
+ const errorMessage = err instanceof Error ? err.message : String(err);
1932
+ setError(errorMessage);
1933
+ throw err;
1934
+ } finally {
1935
+ setIsLoading(false);
1936
+ }
1937
+ }, [client]);
1938
+ const setCurrentComponentConfig = import_react15.useCallback(async (componentId, version, options) => {
1939
+ setIsLoading(true);
1940
+ setError(undefined);
1941
+ try {
1942
+ return await client.setCurrentComponentConfig(componentId, version, options);
1943
+ } catch (err) {
1944
+ const errorMessage = err instanceof Error ? err.message : String(err);
1945
+ setError(errorMessage);
1946
+ throw err;
1947
+ } finally {
1948
+ setIsLoading(false);
1949
+ }
1950
+ }, [client]);
1951
+ return {
1952
+ components,
1953
+ isLoading,
1954
+ error,
1955
+ fetchComponents,
1956
+ getComponentById,
1957
+ createComponent,
1958
+ updateComponent,
1959
+ deleteComponent,
1960
+ fetchComponentConfigs,
1961
+ createComponentConfig,
1962
+ getCurrentComponentConfig,
1963
+ getComponentConfigByVersion,
1964
+ updateComponentConfig,
1965
+ deleteComponentConfig,
1966
+ setCurrentComponentConfig
1967
+ };
1968
+ }
1715
1969
 
1716
- //# debugId=EDC9872997598D6964756E2164756E21
1970
+ //# debugId=D27FED2F9BD03ABF64756E2164756E21