@sqlrooms/ai-core 0.26.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +488 -0
  3. package/dist/AiSlice.d.ts +52 -0
  4. package/dist/AiSlice.d.ts.map +1 -0
  5. package/dist/AiSlice.js +367 -0
  6. package/dist/AiSlice.js.map +1 -0
  7. package/dist/analysis.d.ts +51 -0
  8. package/dist/analysis.d.ts.map +1 -0
  9. package/dist/analysis.js +43 -0
  10. package/dist/analysis.js.map +1 -0
  11. package/dist/components/AnalysisAnswer.d.ts +15 -0
  12. package/dist/components/AnalysisAnswer.d.ts.map +1 -0
  13. package/dist/components/AnalysisAnswer.js +102 -0
  14. package/dist/components/AnalysisAnswer.js.map +1 -0
  15. package/dist/components/AnalysisResult.d.ts +22 -0
  16. package/dist/components/AnalysisResult.d.ts.map +1 -0
  17. package/dist/components/AnalysisResult.js +39 -0
  18. package/dist/components/AnalysisResult.js.map +1 -0
  19. package/dist/components/AnalysisResultsContainer.d.ts +5 -0
  20. package/dist/components/AnalysisResultsContainer.d.ts.map +1 -0
  21. package/dist/components/AnalysisResultsContainer.js +26 -0
  22. package/dist/components/AnalysisResultsContainer.js.map +1 -0
  23. package/dist/components/ErrorMessage.d.ts +4 -0
  24. package/dist/components/ErrorMessage.d.ts.map +1 -0
  25. package/dist/components/ErrorMessage.js +8 -0
  26. package/dist/components/ErrorMessage.js.map +1 -0
  27. package/dist/components/MessageContainer.d.ts +10 -0
  28. package/dist/components/MessageContainer.d.ts.map +1 -0
  29. package/dist/components/MessageContainer.js +9 -0
  30. package/dist/components/MessageContainer.js.map +1 -0
  31. package/dist/components/ModelSelector.d.ts +13 -0
  32. package/dist/components/ModelSelector.d.ts.map +1 -0
  33. package/dist/components/ModelSelector.js +34 -0
  34. package/dist/components/ModelSelector.js.map +1 -0
  35. package/dist/components/QueryControls.d.ts +10 -0
  36. package/dist/components/QueryControls.d.ts.map +1 -0
  37. package/dist/components/QueryControls.js +52 -0
  38. package/dist/components/QueryControls.js.map +1 -0
  39. package/dist/components/SessionControls.d.ts +17 -0
  40. package/dist/components/SessionControls.d.ts.map +1 -0
  41. package/dist/components/SessionControls.js +20 -0
  42. package/dist/components/SessionControls.js.map +1 -0
  43. package/dist/components/session/DeleteSessionButton.d.ts +19 -0
  44. package/dist/components/session/DeleteSessionButton.d.ts.map +1 -0
  45. package/dist/components/session/DeleteSessionButton.js +54 -0
  46. package/dist/components/session/DeleteSessionButton.js.map +1 -0
  47. package/dist/components/session/DeleteSessionDialog.d.ts +27 -0
  48. package/dist/components/session/DeleteSessionDialog.d.ts.map +1 -0
  49. package/dist/components/session/DeleteSessionDialog.js +19 -0
  50. package/dist/components/session/DeleteSessionDialog.js.map +1 -0
  51. package/dist/components/session/SessionActions.d.ts +18 -0
  52. package/dist/components/session/SessionActions.d.ts.map +1 -0
  53. package/dist/components/session/SessionActions.js +19 -0
  54. package/dist/components/session/SessionActions.js.map +1 -0
  55. package/dist/components/session/SessionDropdown.d.ts +18 -0
  56. package/dist/components/session/SessionDropdown.d.ts.map +1 -0
  57. package/dist/components/session/SessionDropdown.js +21 -0
  58. package/dist/components/session/SessionDropdown.js.map +1 -0
  59. package/dist/components/session/SessionTitle.d.ts +18 -0
  60. package/dist/components/session/SessionTitle.d.ts.map +1 -0
  61. package/dist/components/session/SessionTitle.js +22 -0
  62. package/dist/components/session/SessionTitle.js.map +1 -0
  63. package/dist/components/session/SessionType.d.ts +24 -0
  64. package/dist/components/session/SessionType.d.ts.map +1 -0
  65. package/dist/components/session/SessionType.js +2 -0
  66. package/dist/components/session/SessionType.js.map +1 -0
  67. package/dist/components/session/index.d.ts +7 -0
  68. package/dist/components/session/index.d.ts.map +1 -0
  69. package/dist/components/session/index.js +7 -0
  70. package/dist/components/session/index.js.map +1 -0
  71. package/dist/components/tools/ToolErrorMessage.d.ts +39 -0
  72. package/dist/components/tools/ToolErrorMessage.d.ts.map +1 -0
  73. package/dist/components/tools/ToolErrorMessage.js +20 -0
  74. package/dist/components/tools/ToolErrorMessage.js.map +1 -0
  75. package/dist/components/tools/ToolResult.d.ts +11 -0
  76. package/dist/components/tools/ToolResult.d.ts.map +1 -0
  77. package/dist/components/tools/ToolResult.js +29 -0
  78. package/dist/components/tools/ToolResult.js.map +1 -0
  79. package/dist/components/tools/ToolResultErrorBoundary.d.ts +19 -0
  80. package/dist/components/tools/ToolResultErrorBoundary.d.ts.map +1 -0
  81. package/dist/components/tools/ToolResultErrorBoundary.js +24 -0
  82. package/dist/components/tools/ToolResultErrorBoundary.js.map +1 -0
  83. package/dist/hasAiSettingsConfig.d.ts +13 -0
  84. package/dist/hasAiSettingsConfig.d.ts.map +1 -0
  85. package/dist/hasAiSettingsConfig.js +16 -0
  86. package/dist/hasAiSettingsConfig.js.map +1 -0
  87. package/dist/hooks/useScrollToBottom.d.ts +82 -0
  88. package/dist/hooks/useScrollToBottom.d.ts.map +1 -0
  89. package/dist/hooks/useScrollToBottom.js +142 -0
  90. package/dist/hooks/useScrollToBottom.js.map +1 -0
  91. package/dist/index.d.ts +21 -0
  92. package/dist/index.d.ts.map +1 -0
  93. package/dist/index.js +18 -0
  94. package/dist/index.js.map +1 -0
  95. package/dist/utils.d.ts +15 -0
  96. package/dist/utils.d.ts.map +1 -0
  97. package/dist/utils.js +31 -0
  98. package/dist/utils.js.map +1 -0
  99. package/package.json +51 -0
@@ -0,0 +1,54 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button, cn } from '@sqlrooms/ui';
3
+ import { Trash2 } from 'lucide-react';
4
+ import { useState } from 'react';
5
+ import { useStoreWithAi } from '../../AiSlice';
6
+ import { DeleteSessionDialog } from './DeleteSessionDialog';
7
+ /**
8
+ * A button component that handles session deletion with confirmation dialog.
9
+ * Only appears when there is more than one session available.
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * <DeleteSessionButton className="my-custom-class" />
14
+ * ```
15
+ */
16
+ export const DeleteSessionButton = ({ className, }) => {
17
+ const sessions = useStoreWithAi((s) => s.ai.config.sessions);
18
+ const currentSessionId = useStoreWithAi((s) => s.ai.config.currentSessionId);
19
+ const deleteSession = useStoreWithAi((s) => s.ai.deleteSession);
20
+ const [sessionToDeleteId, setSessionToDeleteId] = useState(null);
21
+ const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
22
+ /**
23
+ * Opens the delete confirmation dialog for the current session
24
+ */
25
+ const handleOpenDeleteDialog = () => {
26
+ if (currentSessionId) {
27
+ setSessionToDeleteId(currentSessionId);
28
+ setIsDeleteDialogOpen(true);
29
+ }
30
+ };
31
+ /**
32
+ * Deletes the session after confirmation
33
+ */
34
+ const handleDeleteSession = () => {
35
+ if (sessionToDeleteId) {
36
+ deleteSession(sessionToDeleteId);
37
+ setIsDeleteDialogOpen(false);
38
+ setSessionToDeleteId(null);
39
+ }
40
+ };
41
+ /**
42
+ * Closes the delete confirmation dialog without deleting
43
+ */
44
+ const handleCloseDeleteDialog = () => {
45
+ setIsDeleteDialogOpen(false);
46
+ setSessionToDeleteId(null);
47
+ };
48
+ // Only show the delete button if there's more than one session
49
+ if (sessions.length <= 1 || !currentSessionId) {
50
+ return null;
51
+ }
52
+ return (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", size: "sm", className: cn('text-destructive', className), onClick: handleOpenDeleteDialog, children: _jsx(Trash2, { className: "h-4 w-4" }) }), _jsx(DeleteSessionDialog, { isOpen: isDeleteDialogOpen, onClose: handleCloseDeleteDialog, onDelete: handleDeleteSession })] }));
53
+ };
54
+ //# sourceMappingURL=DeleteSessionButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeleteSessionButton.js","sourceRoot":"","sources":["../../../src/components/session/DeleteSessionButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,EAAE,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,MAAM,EAAC,MAAM,cAAc,CAAC;AACpC,OAAc,EAAC,QAAQ,EAAC,MAAM,OAAO,CAAC;AACtC,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAU1D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAuC,CAAC,EACtE,SAAS,GACV,EAAE,EAAE;IACH,MAAM,QAAQ,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC7D,MAAM,gBAAgB,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAC7E,MAAM,aAAa,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;IAEhE,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,QAAQ,CACxD,IAAI,CACL,CAAC;IACF,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEpE;;OAEG;IACH,MAAM,sBAAsB,GAAG,GAAG,EAAE;QAClC,IAAI,gBAAgB,EAAE,CAAC;YACrB,oBAAoB,CAAC,gBAAgB,CAAC,CAAC;YACvC,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC,CAAC;IAEF;;OAEG;IACH,MAAM,mBAAmB,GAAG,GAAG,EAAE;QAC/B,IAAI,iBAAiB,EAAE,CAAC;YACtB,aAAa,CAAC,iBAAiB,CAAC,CAAC;YACjC,qBAAqB,CAAC,KAAK,CAAC,CAAC;YAC7B,oBAAoB,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC,CAAC;IAEF;;OAEG;IACH,MAAM,uBAAuB,GAAG,GAAG,EAAE;QACnC,qBAAqB,CAAC,KAAK,CAAC,CAAC;QAC7B,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC;IAEF,+DAA+D;IAC/D,IAAI,QAAQ,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,8BACE,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,IAAI,EACT,SAAS,EAAE,EAAE,CAAC,kBAAkB,EAAE,SAAS,CAAC,EAC5C,OAAO,EAAE,sBAAsB,YAE/B,KAAC,MAAM,IAAC,SAAS,EAAC,SAAS,GAAG,GACvB,EAGT,KAAC,mBAAmB,IAClB,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,uBAAuB,EAChC,QAAQ,EAAE,mBAAmB,GAC7B,IACD,CACJ,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {Button, cn} from '@sqlrooms/ui';\nimport {Trash2} from 'lucide-react';\nimport React, {useState} from 'react';\nimport {useStoreWithAi} from '../../AiSlice';\nimport {DeleteSessionDialog} from './DeleteSessionDialog';\n\n/**\n * Props for the DeleteSessionButton component\n */\nexport interface DeleteSessionButtonProps {\n /** Optional CSS class names to apply to the button */\n className?: string;\n}\n\n/**\n * A button component that handles session deletion with confirmation dialog.\n * Only appears when there is more than one session available.\n *\n * @example\n * ```tsx\n * <DeleteSessionButton className=\"my-custom-class\" />\n * ```\n */\nexport const DeleteSessionButton: React.FC<DeleteSessionButtonProps> = ({\n className,\n}) => {\n const sessions = useStoreWithAi((s) => s.ai.config.sessions);\n const currentSessionId = useStoreWithAi((s) => s.ai.config.currentSessionId);\n const deleteSession = useStoreWithAi((s) => s.ai.deleteSession);\n\n const [sessionToDeleteId, setSessionToDeleteId] = useState<string | null>(\n null,\n );\n const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);\n\n /**\n * Opens the delete confirmation dialog for the current session\n */\n const handleOpenDeleteDialog = () => {\n if (currentSessionId) {\n setSessionToDeleteId(currentSessionId);\n setIsDeleteDialogOpen(true);\n }\n };\n\n /**\n * Deletes the session after confirmation\n */\n const handleDeleteSession = () => {\n if (sessionToDeleteId) {\n deleteSession(sessionToDeleteId);\n setIsDeleteDialogOpen(false);\n setSessionToDeleteId(null);\n }\n };\n\n /**\n * Closes the delete confirmation dialog without deleting\n */\n const handleCloseDeleteDialog = () => {\n setIsDeleteDialogOpen(false);\n setSessionToDeleteId(null);\n };\n\n // Only show the delete button if there's more than one session\n if (sessions.length <= 1 || !currentSessionId) {\n return null;\n }\n\n return (\n <>\n <Button\n variant=\"outline\"\n size=\"sm\"\n className={cn('text-destructive', className)}\n onClick={handleOpenDeleteDialog}\n >\n <Trash2 className=\"h-4 w-4\" />\n </Button>\n\n {/* Delete Confirmation Dialog */}\n <DeleteSessionDialog\n isOpen={isDeleteDialogOpen}\n onClose={handleCloseDeleteDialog}\n onDelete={handleDeleteSession}\n />\n </>\n );\n};\n"]}
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ /**
3
+ * Props for the DeleteSessionDialog component
4
+ */
5
+ export interface DeleteSessionDialogProps {
6
+ /** Whether the dialog is currently open */
7
+ isOpen: boolean;
8
+ /** Callback function to close the dialog */
9
+ onClose: () => void;
10
+ /** Callback function to confirm deletion */
11
+ onDelete: () => void;
12
+ }
13
+ /**
14
+ * Dialog component for confirming session deletion.
15
+ * Displays a warning message and provides cancel/delete buttons.
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * <DeleteSessionDialog
20
+ * isOpen={true}
21
+ * onClose={() => console.log("Dialog closed")}
22
+ * onDelete={() => console.log("Session deleted")}
23
+ * />
24
+ * ```
25
+ */
26
+ export declare const DeleteSessionDialog: React.FC<DeleteSessionDialogProps>;
27
+ //# sourceMappingURL=DeleteSessionDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeleteSessionDialog.d.ts","sourceRoot":"","sources":["../../../src/components/session/DeleteSessionDialog.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,2CAA2C;IAC3C,MAAM,EAAE,OAAO,CAAC;IAEhB,4CAA4C;IAC5C,OAAO,EAAE,MAAM,IAAI,CAAC;IAEpB,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA0BlE,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@sqlrooms/ui';
3
+ /**
4
+ * Dialog component for confirming session deletion.
5
+ * Displays a warning message and provides cancel/delete buttons.
6
+ *
7
+ * @example
8
+ * ```tsx
9
+ * <DeleteSessionDialog
10
+ * isOpen={true}
11
+ * onClose={() => console.log("Dialog closed")}
12
+ * onDelete={() => console.log("Session deleted")}
13
+ * />
14
+ * ```
15
+ */
16
+ export const DeleteSessionDialog = ({ isOpen, onClose, onDelete, }) => {
17
+ return (_jsx(Dialog, { open: isOpen, onOpenChange: onClose, children: _jsxs(DialogContent, { children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: "Delete Session" }), _jsx(DialogDescription, { children: "Are you sure you want to delete this session? This action cannot be undone." })] }), _jsxs(DialogFooter, { children: [_jsx(Button, { variant: "outline", onClick: onClose, children: "Cancel" }), _jsx(Button, { variant: "destructive", onClick: onDelete, children: "Delete" })] })] }) }));
18
+ };
19
+ //# sourceMappingURL=DeleteSessionDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeleteSessionDialog.js","sourceRoot":"","sources":["../../../src/components/session/DeleteSessionDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,EACN,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,WAAW,GACZ,MAAM,cAAc,CAAC;AAiBtB;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAuC,CAAC,EACtE,MAAM,EACN,OAAO,EACP,QAAQ,GACT,EAAE,EAAE;IACH,OAAO,CACL,KAAC,MAAM,IAAC,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,YACzC,MAAC,aAAa,eACZ,MAAC,YAAY,eACX,KAAC,WAAW,iCAA6B,EACzC,KAAC,iBAAiB,8FAGE,IACP,EACf,MAAC,YAAY,eACX,KAAC,MAAM,IAAC,OAAO,EAAC,SAAS,EAAC,OAAO,EAAE,OAAO,uBAEjC,EACT,KAAC,MAAM,IAAC,OAAO,EAAC,aAAa,EAAC,OAAO,EAAE,QAAQ,uBAEtC,IACI,IACD,GACT,CACV,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n Button,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from '@sqlrooms/ui';\nimport React from 'react';\n\n/**\n * Props for the DeleteSessionDialog component\n */\nexport interface DeleteSessionDialogProps {\n /** Whether the dialog is currently open */\n isOpen: boolean;\n\n /** Callback function to close the dialog */\n onClose: () => void;\n\n /** Callback function to confirm deletion */\n onDelete: () => void;\n}\n\n/**\n * Dialog component for confirming session deletion.\n * Displays a warning message and provides cancel/delete buttons.\n *\n * @example\n * ```tsx\n * <DeleteSessionDialog\n * isOpen={true}\n * onClose={() => console.log(\"Dialog closed\")}\n * onDelete={() => console.log(\"Session deleted\")}\n * />\n * ```\n */\nexport const DeleteSessionDialog: React.FC<DeleteSessionDialogProps> = ({\n isOpen,\n onClose,\n onDelete,\n}) => {\n return (\n <Dialog open={isOpen} onOpenChange={onClose}>\n <DialogContent>\n <DialogHeader>\n <DialogTitle>Delete Session</DialogTitle>\n <DialogDescription>\n Are you sure you want to delete this session? This action cannot be\n undone.\n </DialogDescription>\n </DialogHeader>\n <DialogFooter>\n <Button variant=\"outline\" onClick={onClose}>\n Cancel\n </Button>\n <Button variant=\"destructive\" onClick={onDelete}>\n Delete\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n );\n};\n"]}
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ /**
3
+ * Props for the SessionActions component
4
+ */
5
+ export interface SessionActionsProps {
6
+ className?: string;
7
+ }
8
+ /**
9
+ * Component that displays action buttons for session management.
10
+ * Shows a delete button (via DeleteSessionButton) and a create new session button.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * <SessionActions className="my-custom-class" />
15
+ * ```
16
+ */
17
+ export declare const SessionActions: React.FC<SessionActionsProps>;
18
+ //# sourceMappingURL=SessionActions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionActions.d.ts","sourceRoot":"","sources":["../../../src/components/session/SessionActions.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAoBxD,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button, cn } from '@sqlrooms/ui';
3
+ import { Plus as PlusIcon } from 'lucide-react';
4
+ import { useStoreWithAi } from '../../AiSlice';
5
+ import { DeleteSessionButton } from './DeleteSessionButton';
6
+ /**
7
+ * Component that displays action buttons for session management.
8
+ * Shows a delete button (via DeleteSessionButton) and a create new session button.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * <SessionActions className="my-custom-class" />
13
+ * ```
14
+ */
15
+ export const SessionActions = ({ className }) => {
16
+ const createSession = useStoreWithAi((s) => s.ai.createSession);
17
+ return (_jsxs("div", { className: cn('flex items-center gap-2', className), children: [_jsx(DeleteSessionButton, {}), _jsxs(Button, { variant: "outline", size: "sm", className: "gap-1", onClick: () => createSession(), children: [_jsx(PlusIcon, { className: "h-4 w-4" }), "New Session"] })] }));
18
+ };
19
+ //# sourceMappingURL=SessionActions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionActions.js","sourceRoot":"","sources":["../../../src/components/session/SessionActions.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,EAAE,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAS1D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAkC,CAAC,EAAC,SAAS,EAAC,EAAE,EAAE;IAC3E,MAAM,aAAa,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;IAEhE,OAAO,CACL,eAAK,SAAS,EAAE,EAAE,CAAC,yBAAyB,EAAE,SAAS,CAAC,aAEtD,KAAC,mBAAmB,KAAG,EAGvB,MAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,IAAI,EACT,SAAS,EAAC,OAAO,EACjB,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,EAAE,aAE9B,KAAC,QAAQ,IAAC,SAAS,EAAC,SAAS,GAAG,mBAEzB,IACL,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {Button, cn} from '@sqlrooms/ui';\nimport {Plus as PlusIcon} from 'lucide-react';\nimport React from 'react';\nimport {useStoreWithAi} from '../../AiSlice';\nimport {DeleteSessionButton} from './DeleteSessionButton';\n\n/**\n * Props for the SessionActions component\n */\nexport interface SessionActionsProps {\n className?: string;\n}\n\n/**\n * Component that displays action buttons for session management.\n * Shows a delete button (via DeleteSessionButton) and a create new session button.\n *\n * @example\n * ```tsx\n * <SessionActions className=\"my-custom-class\" />\n * ```\n */\nexport const SessionActions: React.FC<SessionActionsProps> = ({className}) => {\n const createSession = useStoreWithAi((s) => s.ai.createSession);\n\n return (\n <div className={cn('flex items-center gap-2', className)}>\n {/* Delete Current Session Button */}\n <DeleteSessionButton />\n\n {/* Create New Session Button */}\n <Button\n variant=\"outline\"\n size=\"sm\"\n className=\"gap-1\"\n onClick={() => createSession()}\n >\n <PlusIcon className=\"h-4 w-4\" />\n New Session\n </Button>\n </div>\n );\n};\n"]}
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ /**
3
+ * Props for the SessionDropdown component
4
+ */
5
+ export interface SessionDropdownProps {
6
+ className?: string;
7
+ }
8
+ /**
9
+ * Dropdown component for managing AI sessions.
10
+ * Allows users to switch between existing sessions or create a new one.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * <SessionDropdown className="my-custom-class" />
15
+ * ```
16
+ */
17
+ export declare const SessionDropdown: React.FC<SessionDropdownProps>;
18
+ //# sourceMappingURL=SessionDropdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionDropdown.d.ts","sourceRoot":"","sources":["../../../src/components/session/SessionDropdown.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAwC1D,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button, cn, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@sqlrooms/ui';
3
+ import { Check, ChevronDown, History, Plus as PlusIcon } from 'lucide-react';
4
+ import { useStoreWithAi } from '../../AiSlice';
5
+ /**
6
+ * Dropdown component for managing AI sessions.
7
+ * Allows users to switch between existing sessions or create a new one.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * <SessionDropdown className="my-custom-class" />
12
+ * ```
13
+ */
14
+ export const SessionDropdown = ({ className, }) => {
15
+ const sessions = useStoreWithAi((s) => s.ai.config.sessions);
16
+ const currentSessionId = useStoreWithAi((s) => s.ai.config.currentSessionId);
17
+ const switchSession = useStoreWithAi((s) => s.ai.switchSession);
18
+ const createSession = useStoreWithAi((s) => s.ai.createSession);
19
+ return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { className: cn('gap-1', className), variant: "outline", size: "sm", children: [_jsx(History, { className: "h-4 w-4" }), _jsx(ChevronDown, { className: "ml-1 h-4 w-4" })] }) }), _jsxs(DropdownMenuContent, { align: "start", className: "w-70", children: [_jsxs(DropdownMenuItem, { onClick: () => createSession(), className: "flex items-center py-2", children: [_jsx(PlusIcon, { className: "mr-2 h-4 w-4" }), "New Session"] }), _jsx("div", { className: "bg-border my-1 h-px" }), sessions.map((session) => (_jsxs(DropdownMenuItem, { className: "flex justify-between py-2", onClick: () => switchSession(session.id), children: [_jsx("span", { className: "truncate", children: session.name }), session.id === currentSessionId && (_jsx(Check, { className: "ml-2 h-4 w-4" }))] }, session.id)))] })] }));
20
+ };
21
+ //# sourceMappingURL=SessionDropdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionDropdown.js","sourceRoot":"","sources":["../../../src/components/session/SessionDropdown.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,MAAM,EACN,EAAE,EACF,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAC,MAAM,cAAc,CAAC;AAE3E,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAS7C;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,eAAe,GAAmC,CAAC,EAC9D,SAAS,GACV,EAAE,EAAE;IACH,MAAM,QAAQ,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC7D,MAAM,gBAAgB,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAC7E,MAAM,aAAa,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;IAChE,MAAM,aAAa,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;IAEhE,OAAO,CACL,MAAC,YAAY,eACX,KAAC,mBAAmB,IAAC,OAAO,kBAC1B,MAAC,MAAM,IAAC,SAAS,EAAE,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,OAAO,EAAC,SAAS,EAAC,IAAI,EAAC,IAAI,aACpE,KAAC,OAAO,IAAC,SAAS,EAAC,SAAS,GAAG,EAC/B,KAAC,WAAW,IAAC,SAAS,EAAC,cAAc,GAAG,IACjC,GACW,EACtB,MAAC,mBAAmB,IAAC,KAAK,EAAC,OAAO,EAAC,SAAS,EAAC,MAAM,aACjD,MAAC,gBAAgB,IACf,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,EAAE,EAC9B,SAAS,EAAC,wBAAwB,aAElC,KAAC,QAAQ,IAAC,SAAS,EAAC,cAAc,GAAG,mBAEpB,EACnB,cAAK,SAAS,EAAC,qBAAqB,GAAG,EACtC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CACzB,MAAC,gBAAgB,IAEf,SAAS,EAAC,2BAA2B,EACrC,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,aAExC,eAAM,SAAS,EAAC,UAAU,YAAE,OAAO,CAAC,IAAI,GAAQ,EAC/C,OAAO,CAAC,EAAE,KAAK,gBAAgB,IAAI,CAClC,KAAC,KAAK,IAAC,SAAS,EAAC,cAAc,GAAG,CACnC,KAPI,OAAO,CAAC,EAAE,CAQE,CACpB,CAAC,IACkB,IACT,CAChB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n Button,\n cn,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n} from '@sqlrooms/ui';\nimport {Check, ChevronDown, History, Plus as PlusIcon} from 'lucide-react';\nimport React from 'react';\nimport {useStoreWithAi} from '../../AiSlice';\n\n/**\n * Props for the SessionDropdown component\n */\nexport interface SessionDropdownProps {\n className?: string;\n}\n\n/**\n * Dropdown component for managing AI sessions.\n * Allows users to switch between existing sessions or create a new one.\n *\n * @example\n * ```tsx\n * <SessionDropdown className=\"my-custom-class\" />\n * ```\n */\nexport const SessionDropdown: React.FC<SessionDropdownProps> = ({\n className,\n}) => {\n const sessions = useStoreWithAi((s) => s.ai.config.sessions);\n const currentSessionId = useStoreWithAi((s) => s.ai.config.currentSessionId);\n const switchSession = useStoreWithAi((s) => s.ai.switchSession);\n const createSession = useStoreWithAi((s) => s.ai.createSession);\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button className={cn('gap-1', className)} variant=\"outline\" size=\"sm\">\n <History className=\"h-4 w-4\" />\n <ChevronDown className=\"ml-1 h-4 w-4\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"start\" className=\"w-70\">\n <DropdownMenuItem\n onClick={() => createSession()}\n className=\"flex items-center py-2\"\n >\n <PlusIcon className=\"mr-2 h-4 w-4\" />\n New Session\n </DropdownMenuItem>\n <div className=\"bg-border my-1 h-px\" />\n {sessions.map((session) => (\n <DropdownMenuItem\n key={session.id}\n className=\"flex justify-between py-2\"\n onClick={() => switchSession(session.id)}\n >\n <span className=\"truncate\">{session.name}</span>\n {session.id === currentSessionId && (\n <Check className=\"ml-2 h-4 w-4\" />\n )}\n </DropdownMenuItem>\n ))}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n};\n"]}
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ /**
3
+ * Props for the SessionTitle component
4
+ */
5
+ export interface SessionTitleProps {
6
+ className?: string;
7
+ }
8
+ /**
9
+ * Component that displays the current session name as an editable text field.
10
+ * Shows the model name if available and a placeholder if no session is selected.
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * <SessionTitle className="my-custom-class" />
15
+ * ```
16
+ */
17
+ export declare const SessionTitle: React.FC<SessionTitleProps>;
18
+ //# sourceMappingURL=SessionTitle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionTitle.d.ts","sourceRoot":"","sources":["../../../src/components/session/SessionTitle.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAyBpD,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cn, EditableText } from '@sqlrooms/ui';
3
+ import { useStoreWithAi } from '../../AiSlice';
4
+ /**
5
+ * Component that displays the current session name as an editable text field.
6
+ * Shows the model name if available and a placeholder if no session is selected.
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * <SessionTitle className="my-custom-class" />
11
+ * ```
12
+ */
13
+ export const SessionTitle = ({ className }) => {
14
+ const currentSession = useStoreWithAi((s) => s.ai.getCurrentSession());
15
+ const renameSession = useStoreWithAi((s) => s.ai.renameSession);
16
+ return (_jsx("div", { className: cn('flex items-center gap-2', className), children: currentSession ? (_jsx(EditableText, { value: currentSession.name, onChange: (newName) => {
17
+ if (currentSession && newName.trim()) {
18
+ renameSession(currentSession.id, newName);
19
+ }
20
+ }, placeholder: "Session name", className: "text-sm font-medium", maxWidth: 300 })) : (_jsx("span", { className: "text-muted-foreground text-sm font-medium", children: "No session selected" })) }));
21
+ };
22
+ //# sourceMappingURL=SessionTitle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionTitle.js","sourceRoot":"","sources":["../../../src/components/session/SessionTitle.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,EAAE,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAS7C;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,YAAY,GAAgC,CAAC,EAAC,SAAS,EAAC,EAAE,EAAE;IACvE,MAAM,cAAc,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,iBAAiB,EAAE,CAAC,CAAC;IACvE,MAAM,aAAa,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;IAEhE,OAAO,CACL,cAAK,SAAS,EAAE,EAAE,CAAC,yBAAyB,EAAE,SAAS,CAAC,YACrD,cAAc,CAAC,CAAC,CAAC,CAChB,KAAC,YAAY,IACX,KAAK,EAAE,cAAc,CAAC,IAAI,EAC1B,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE;gBACpB,IAAI,cAAc,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;oBACrC,aAAa,CAAC,cAAc,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;gBAC5C,CAAC;YACH,CAAC,EACD,WAAW,EAAC,cAAc,EAC1B,SAAS,EAAC,qBAAqB,EAC/B,QAAQ,EAAE,GAAG,GACb,CACH,CAAC,CAAC,CAAC,CACF,eAAM,SAAS,EAAC,2CAA2C,oCAEpD,CACR,GACG,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {cn, EditableText} from '@sqlrooms/ui';\nimport React from 'react';\nimport {useStoreWithAi} from '../../AiSlice';\n\n/**\n * Props for the SessionTitle component\n */\nexport interface SessionTitleProps {\n className?: string;\n}\n\n/**\n * Component that displays the current session name as an editable text field.\n * Shows the model name if available and a placeholder if no session is selected.\n *\n * @example\n * ```tsx\n * <SessionTitle className=\"my-custom-class\" />\n * ```\n */\nexport const SessionTitle: React.FC<SessionTitleProps> = ({className}) => {\n const currentSession = useStoreWithAi((s) => s.ai.getCurrentSession());\n const renameSession = useStoreWithAi((s) => s.ai.renameSession);\n\n return (\n <div className={cn('flex items-center gap-2', className)}>\n {currentSession ? (\n <EditableText\n value={currentSession.name}\n onChange={(newName) => {\n if (currentSession && newName.trim()) {\n renameSession(currentSession.id, newName);\n }\n }}\n placeholder=\"Session name\"\n className=\"text-sm font-medium\"\n maxWidth={300}\n />\n ) : (\n <span className=\"text-muted-foreground text-sm font-medium\">\n No session selected\n </span>\n )}\n </div>\n );\n};\n"]}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Represents a session in the AI system.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * const session: SessionType = {
7
+ * id: "session_123",
8
+ * name: "My Analysis Session",
9
+ * modelProvider: "openai",
10
+ * model: "gpt-4o-mini"
11
+ * };
12
+ * ```
13
+ */
14
+ export type SessionType = {
15
+ /** Unique identifier for the session */
16
+ id: string;
17
+ /** Display name of the session */
18
+ name: string;
19
+ /** Provider of the AI model (e.g., "openai") */
20
+ modelProvider?: string;
21
+ /** Name of the AI model being used (e.g., "gpt-4o-mini") */
22
+ model?: string;
23
+ };
24
+ //# sourceMappingURL=SessionType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionType.d.ts","sourceRoot":"","sources":["../../../src/components/session/SessionType.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,wCAAwC;IACxC,EAAE,EAAE,MAAM,CAAC;IAEX,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IAEb,gDAAgD;IAChD,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=SessionType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionType.js","sourceRoot":"","sources":["../../../src/components/session/SessionType.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Represents a session in the AI system.\n *\n * @example\n * ```typescript\n * const session: SessionType = {\n * id: \"session_123\",\n * name: \"My Analysis Session\",\n * modelProvider: \"openai\",\n * model: \"gpt-4o-mini\"\n * };\n * ```\n */\nexport type SessionType = {\n /** Unique identifier for the session */\n id: string;\n\n /** Display name of the session */\n name: string;\n\n /** Provider of the AI model (e.g., \"openai\") */\n modelProvider?: string;\n\n /** Name of the AI model being used (e.g., \"gpt-4o-mini\") */\n model?: string;\n};\n"]}
@@ -0,0 +1,7 @@
1
+ export * from './DeleteSessionButton';
2
+ export * from './DeleteSessionDialog';
3
+ export * from './SessionActions';
4
+ export * from './SessionDropdown';
5
+ export * from './SessionTitle';
6
+ export * from './SessionType';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/session/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from './DeleteSessionButton';
2
+ export * from './DeleteSessionDialog';
3
+ export * from './SessionActions';
4
+ export * from './SessionDropdown';
5
+ export * from './SessionTitle';
6
+ export * from './SessionType';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/session/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC","sourcesContent":["export * from './DeleteSessionButton';\nexport * from './DeleteSessionDialog';\nexport * from './SessionActions';\nexport * from './SessionDropdown';\nexport * from './SessionTitle';\nexport * from './SessionType';\n"]}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Displays a compact, reusable popover with a warning icon and error details.
3
+ * Intended for tool rendering/processing errors to keep UIs consistent.
4
+ *
5
+ * The popover is controllable to optimize performance by only rendering the
6
+ * JsonMonacoEditor when the popover is actually open.
7
+ */
8
+ export interface ToolErrorMessageProps {
9
+ /**
10
+ * Error object or message to display inside the popover body.
11
+ */
12
+ error?: unknown;
13
+ /**
14
+ * Optional structured details to render in a Monaco JSON editor.
15
+ */
16
+ details?: string | object;
17
+ /**
18
+ * Header text shown at the top of the popover.
19
+ * Defaults to "Tool rendering error".
20
+ */
21
+ title?: string;
22
+ /**
23
+ * Label shown next to the warning icon in the trigger button.
24
+ * Defaults to "Tool rendering failed".
25
+ */
26
+ triggerLabel?: string;
27
+ /**
28
+ * Alignment of the popover content relative to its trigger.
29
+ * Defaults to "start".
30
+ */
31
+ align?: 'start' | 'center' | 'end';
32
+ /**
33
+ * Height for the embedded editor when details are provided.
34
+ * Defaults to 300px.
35
+ */
36
+ editorHeightPx?: number;
37
+ }
38
+ export declare function ToolErrorMessage(props: ToolErrorMessageProps): import("react/jsx-runtime").JSX.Element;
39
+ //# sourceMappingURL=ToolErrorMessage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolErrorMessage.d.ts","sourceRoot":"","sources":["../../../src/components/tools/ToolErrorMessage.tsx"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IACnC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,2CAkD5D"}
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { JsonMonacoEditor } from '@sqlrooms/monaco-editor';
3
+ import { Button, Popover, PopoverContent, PopoverTrigger, useDisclosure, } from '@sqlrooms/ui';
4
+ import { TriangleAlertIcon } from 'lucide-react';
5
+ export function ToolErrorMessage(props) {
6
+ const title = props.title ?? 'Tool rendering error';
7
+ const triggerLabel = props.triggerLabel ?? 'Tool rendering failed';
8
+ const align = props.align ?? 'start';
9
+ const errorText = props.error != null ? String(props.error) : '';
10
+ const editorHeightPx = props.editorHeightPx ?? 300;
11
+ const hasDetails = props.details != null;
12
+ const popoverOpen = useDisclosure();
13
+ return (_jsxs(Popover, { open: popoverOpen.isOpen, onOpenChange: popoverOpen.onToggle, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx(Button, { className: "w-fit", variant: "ghost", size: "xs", children: _jsxs("p", { className: "flex items-center gap-2 text-xs text-orange-500", children: [_jsx(TriangleAlertIcon, {}), triggerLabel] }) }) }), _jsx(PopoverContent, { align: align, style: { width: '600px', maxWidth: '80%' }, children: _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("div", { className: "border-b text-sm font-medium text-orange-500", children: title }), errorText ? (_jsx("div", { className: "whitespace-pre-wrap font-mono text-xs text-orange-500", children: errorText })) : null, hasDetails && popoverOpen.isOpen ? (_jsx("div", { className: "w-full overflow-hidden rounded-md border", style: { height: editorHeightPx }, children: _jsx(JsonMonacoEditor, { value: props.details, readOnly: true, options: {
14
+ lineNumbers: 'off',
15
+ minimap: { enabled: false },
16
+ scrollBeyondLastLine: false,
17
+ wordWrap: 'on',
18
+ } }) })) : null] }) })] }));
19
+ }
20
+ //# sourceMappingURL=ToolErrorMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolErrorMessage.js","sourceRoot":"","sources":["../../../src/components/tools/ToolErrorMessage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,yBAAyB,CAAC;AACzD,OAAO,EACL,MAAM,EACN,OAAO,EACP,cAAc,EACd,cAAc,EACd,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,iBAAiB,EAAC,MAAM,cAAc,CAAC;AAwC/C,MAAM,UAAU,gBAAgB,CAAC,KAA4B;IAC3D,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,sBAAsB,CAAC;IACpD,MAAM,YAAY,GAAG,KAAK,CAAC,YAAY,IAAI,uBAAuB,CAAC;IACnE,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,OAAO,CAAC;IACrC,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACjE,MAAM,cAAc,GAAG,KAAK,CAAC,cAAc,IAAI,GAAG,CAAC;IACnD,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC;IACzC,MAAM,WAAW,GAAG,aAAa,EAAE,CAAC;IAEpC,OAAO,CACL,MAAC,OAAO,IAAC,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,WAAW,CAAC,QAAQ,aACnE,KAAC,cAAc,IAAC,OAAO,kBACrB,KAAC,MAAM,IAAC,SAAS,EAAC,OAAO,EAAC,OAAO,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,YACjD,aAAG,SAAS,EAAC,iDAAiD,aAC5D,KAAC,iBAAiB,KAAG,EACpB,YAAY,IACX,GACG,GACM,EACjB,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,EAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAC,YACpE,eAAK,SAAS,EAAC,qBAAqB,aAClC,cAAK,SAAS,EAAC,8CAA8C,YAC1D,KAAK,GACF,EACL,SAAS,CAAC,CAAC,CAAC,CACX,cAAK,SAAS,EAAC,uDAAuD,YACnE,SAAS,GACN,CACP,CAAC,CAAC,CAAC,IAAI,EACP,UAAU,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAClC,cACE,SAAS,EAAC,0CAA0C,EACpD,KAAK,EAAE,EAAC,MAAM,EAAE,cAAc,EAAC,YAE/B,KAAC,gBAAgB,IACf,KAAK,EAAE,KAAK,CAAC,OAAiD,EAC9D,QAAQ,EAAE,IAAI,EACd,OAAO,EAAE;oCACP,WAAW,EAAE,KAAK;oCAClB,OAAO,EAAE,EAAC,OAAO,EAAE,KAAK,EAAC;oCACzB,oBAAoB,EAAE,KAAK;oCAC3B,QAAQ,EAAE,IAAI;iCACf,GACD,GACE,CACP,CAAC,CAAC,CAAC,IAAI,IACJ,GACS,IACT,CACX,CAAC;AACJ,CAAC","sourcesContent":["import {JsonMonacoEditor} from '@sqlrooms/monaco-editor';\nimport {\n Button,\n Popover,\n PopoverContent,\n PopoverTrigger,\n useDisclosure,\n} from '@sqlrooms/ui';\nimport {TriangleAlertIcon} from 'lucide-react';\n\n/**\n * Displays a compact, reusable popover with a warning icon and error details.\n * Intended for tool rendering/processing errors to keep UIs consistent.\n *\n * The popover is controllable to optimize performance by only rendering the\n * JsonMonacoEditor when the popover is actually open.\n */\nexport interface ToolErrorMessageProps {\n /**\n * Error object or message to display inside the popover body.\n */\n error?: unknown;\n /**\n * Optional structured details to render in a Monaco JSON editor.\n */\n details?: string | object;\n /**\n * Header text shown at the top of the popover.\n * Defaults to \"Tool rendering error\".\n */\n title?: string;\n /**\n * Label shown next to the warning icon in the trigger button.\n * Defaults to \"Tool rendering failed\".\n */\n triggerLabel?: string;\n /**\n * Alignment of the popover content relative to its trigger.\n * Defaults to \"start\".\n */\n align?: 'start' | 'center' | 'end';\n /**\n * Height for the embedded editor when details are provided.\n * Defaults to 300px.\n */\n editorHeightPx?: number;\n}\n\nexport function ToolErrorMessage(props: ToolErrorMessageProps) {\n const title = props.title ?? 'Tool rendering error';\n const triggerLabel = props.triggerLabel ?? 'Tool rendering failed';\n const align = props.align ?? 'start';\n const errorText = props.error != null ? String(props.error) : '';\n const editorHeightPx = props.editorHeightPx ?? 300;\n const hasDetails = props.details != null;\n const popoverOpen = useDisclosure();\n\n return (\n <Popover open={popoverOpen.isOpen} onOpenChange={popoverOpen.onToggle}>\n <PopoverTrigger asChild>\n <Button className=\"w-fit\" variant=\"ghost\" size=\"xs\">\n <p className=\"flex items-center gap-2 text-xs text-orange-500\">\n <TriangleAlertIcon />\n {triggerLabel}\n </p>\n </Button>\n </PopoverTrigger>\n <PopoverContent align={align} style={{width: '600px', maxWidth: '80%'}}>\n <div className=\"flex flex-col gap-2\">\n <div className=\"border-b text-sm font-medium text-orange-500\">\n {title}\n </div>\n {errorText ? (\n <div className=\"whitespace-pre-wrap font-mono text-xs text-orange-500\">\n {errorText}\n </div>\n ) : null}\n {hasDetails && popoverOpen.isOpen ? (\n <div\n className=\"w-full overflow-hidden rounded-md border\"\n style={{height: editorHeightPx}}\n >\n <JsonMonacoEditor\n value={props.details as unknown as object | string | undefined}\n readOnly={true}\n options={{\n lineNumbers: 'off',\n minimap: {enabled: false},\n scrollBeyondLastLine: false,\n wordWrap: 'on',\n }}\n />\n </div>\n ) : null}\n </div>\n </PopoverContent>\n </Popover>\n );\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { ToolInvocation } from 'ai';
3
+ type ToolResultProps = {
4
+ toolInvocation: ToolInvocation;
5
+ additionalData: unknown;
6
+ isCompleted: boolean;
7
+ errorMessage?: string;
8
+ };
9
+ export declare const ToolResult: React.FC<ToolResultProps>;
10
+ export {};
11
+ //# sourceMappingURL=ToolResult.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolResult.d.ts","sourceRoot":"","sources":["../../../src/components/tools/ToolResult.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAC,cAAc,EAAC,MAAM,IAAI,CAAC;AAGlC,KAAK,eAAe,GAAG;IACrB,cAAc,EAAE,cAAc,CAAC;IAC/B,cAAc,EAAE,OAAO,CAAC;IACxB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAqEhD,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useDisclosure } from '@sqlrooms/ui';
3
+ import { useStoreWithAi } from '../../AiSlice';
4
+ import { MessageContainer } from '../MessageContainer';
5
+ import { ToolCallErrorBoundary } from './ToolResultErrorBoundary';
6
+ import { ToolErrorMessage } from './ToolErrorMessage';
7
+ export const ToolResult = ({ toolInvocation, additionalData, isCompleted, errorMessage, }) => {
8
+ const { isOpen: showDetails, onToggle: toggleShowDetails } = useDisclosure(false);
9
+ const { toolName, args, state } = toolInvocation;
10
+ const llmResult = state === 'result' ? toolInvocation.result : null;
11
+ // show reason text before tool call complete
12
+ const text = args.reasoning || '';
13
+ const ToolComponent = useStoreWithAi((state) => state.ai.findToolComponent(toolName));
14
+ // check if args has a property called 'reason'
15
+ const reason = args.reasoning;
16
+ // check if llmResult is an object and has a success property
17
+ const isSuccess = typeof llmResult === 'object' &&
18
+ llmResult !== null &&
19
+ 'success' in llmResult &&
20
+ llmResult.success === true;
21
+ return !isCompleted ? (_jsx("div", { className: "text-sm text-gray-500", children: text })) : (_jsxs(MessageContainer, { isSuccess: isSuccess, type: toolName, content: {
22
+ toolName,
23
+ args,
24
+ llmResult,
25
+ additionalData,
26
+ isCompleted,
27
+ }, children: [_jsx("div", { className: "text-sm text-gray-500", children: reason && _jsx("span", { children: reason }) }), ToolComponent && isSuccess && isCompleted && (_jsx(ToolCallErrorBoundary, { children: typeof ToolComponent === 'function' ? (_jsx(ToolComponent, { ...llmResult, ...additionalData })) : (ToolComponent) })), isCompleted && (errorMessage || !isSuccess) && (_jsx(ToolErrorMessage, { error: errorMessage ?? 'Tool call failed', details: toolInvocation, title: "Tool call error", triggerLabel: "Tool call failed", editorHeightPx: 300 }))] }));
28
+ };
29
+ //# sourceMappingURL=ToolResult.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolResult.js","sourceRoot":"","sources":["../../../src/components/tools/ToolResult.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAS,aAAa,EAAC,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAC,qBAAqB,EAAC,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AASpD,MAAM,CAAC,MAAM,UAAU,GAA8B,CAAC,EACpD,cAAc,EACd,cAAc,EACd,WAAW,EACX,YAAY,GACb,EAAE,EAAE;IACH,MAAM,EAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,iBAAiB,EAAC,GACtD,aAAa,CAAC,KAAK,CAAC,CAAC;IAEvB,MAAM,EAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAC,GAAG,cAAc,CAAC;IAC/C,MAAM,SAAS,GAAG,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;IAEpE,6CAA6C;IAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;IAElC,MAAM,aAAa,GAAG,cAAc,CAAC,CAAC,KAAK,EAAE,EAAE,CAC7C,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CACrC,CAAC;IAEF,+CAA+C;IAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,SAAmB,CAAC;IAExC,6DAA6D;IAC7D,MAAM,SAAS,GACb,OAAO,SAAS,KAAK,QAAQ;QAC7B,SAAS,KAAK,IAAI;QAClB,SAAS,IAAI,SAAS;QACtB,SAAS,CAAC,OAAO,KAAK,IAAI,CAAC;IAE7B,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CACpB,cAAK,SAAS,EAAC,uBAAuB,YAAE,IAAI,GAAO,CACpD,CAAC,CAAC,CAAC,CACF,MAAC,gBAAgB,IACf,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE;YACP,QAAQ;YACR,IAAI;YACJ,SAAS;YACT,cAAc;YACd,WAAW;SACZ,aAED,cAAK,SAAS,EAAC,uBAAuB,YACnC,MAAM,IAAI,yBAAO,MAAM,GAAQ,GAC5B,EACL,aAAa,IAAI,SAAS,IAAI,WAAW,IAAI,CAC5C,KAAC,qBAAqB,cACnB,OAAO,aAAa,KAAK,UAAU,CAAC,CAAC,CAAC,CACrC,KAAC,aAAa,OACP,SAAqC,KACrC,cAA0C,GAC/C,CACH,CAAC,CAAC,CAAC,CACF,aAAa,CACd,GACqB,CACzB,EACA,WAAW,IAAI,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,IAAI,CAC9C,KAAC,gBAAgB,IACf,KAAK,EAAE,YAAY,IAAI,kBAAkB,EACzC,OAAO,EAAE,cAAc,EACvB,KAAK,EAAC,iBAAiB,EACvB,YAAY,EAAC,kBAAkB,EAC/B,cAAc,EAAE,GAAG,GACnB,CACH,IACgB,CACpB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {Button, useDisclosure} from '@sqlrooms/ui';\nimport React from 'react';\nimport {useStoreWithAi} from '../../AiSlice';\nimport {MessageContainer} from '../MessageContainer';\nimport {ToolCallErrorBoundary} from './ToolResultErrorBoundary';\nimport {ToolInvocation} from 'ai';\nimport {ToolErrorMessage} from './ToolErrorMessage';\n\ntype ToolResultProps = {\n toolInvocation: ToolInvocation;\n additionalData: unknown;\n isCompleted: boolean;\n errorMessage?: string;\n};\n\nexport const ToolResult: React.FC<ToolResultProps> = ({\n toolInvocation,\n additionalData,\n isCompleted,\n errorMessage,\n}) => {\n const {isOpen: showDetails, onToggle: toggleShowDetails} =\n useDisclosure(false);\n\n const {toolName, args, state} = toolInvocation;\n const llmResult = state === 'result' ? toolInvocation.result : null;\n\n // show reason text before tool call complete\n const text = args.reasoning || '';\n\n const ToolComponent = useStoreWithAi((state) =>\n state.ai.findToolComponent(toolName),\n );\n\n // check if args has a property called 'reason'\n const reason = args.reasoning as string;\n\n // check if llmResult is an object and has a success property\n const isSuccess =\n typeof llmResult === 'object' &&\n llmResult !== null &&\n 'success' in llmResult &&\n llmResult.success === true;\n\n return !isCompleted ? (\n <div className=\"text-sm text-gray-500\">{text}</div>\n ) : (\n <MessageContainer\n isSuccess={isSuccess}\n type={toolName}\n content={{\n toolName,\n args,\n llmResult,\n additionalData,\n isCompleted,\n }}\n >\n <div className=\"text-sm text-gray-500\">\n {reason && <span>{reason}</span>}\n </div>\n {ToolComponent && isSuccess && isCompleted && (\n <ToolCallErrorBoundary>\n {typeof ToolComponent === 'function' ? (\n <ToolComponent\n {...(llmResult as Record<string, unknown>)}\n {...(additionalData as Record<string, unknown>)}\n />\n ) : (\n ToolComponent\n )}\n </ToolCallErrorBoundary>\n )}\n {isCompleted && (errorMessage || !isSuccess) && (\n <ToolErrorMessage\n error={errorMessage ?? 'Tool call failed'}\n details={toolInvocation}\n title=\"Tool call error\"\n triggerLabel=\"Tool call failed\"\n editorHeightPx={300}\n />\n )}\n </MessageContainer>\n );\n};\n"]}
@@ -0,0 +1,19 @@
1
+ import React, { ReactNode } from 'react';
2
+ export declare class ToolCallErrorBoundary extends React.Component<{
3
+ children: ReactNode;
4
+ onError?: () => void;
5
+ }, {
6
+ hasError: boolean;
7
+ error?: Error;
8
+ }> {
9
+ constructor(props: {
10
+ children: ReactNode;
11
+ onError?: () => void;
12
+ });
13
+ static getDerivedStateFromError(): {
14
+ hasError: boolean;
15
+ };
16
+ componentDidCatch(error: Error): void;
17
+ render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
18
+ }
19
+ //# sourceMappingURL=ToolResultErrorBoundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolResultErrorBoundary.d.ts","sourceRoot":"","sources":["../../../src/components/tools/ToolResultErrorBoundary.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAEvC,qBAAa,qBAAsB,SAAQ,KAAK,CAAC,SAAS,CACxD;IAAC,QAAQ,EAAE,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CAAC,EAC3C;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAC,CACnC;gBACa,KAAK,EAAE;QAAC,QAAQ,EAAE,SAAS,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;KAAC;IAK9D,MAAM,CAAC,wBAAwB;;;IAI/B,iBAAiB,CAAC,KAAK,EAAE,KAAK;IAM9B,MAAM;CAOP"}
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ToolErrorMessage } from './ToolErrorMessage';
3
+ import React from 'react';
4
+ export class ToolCallErrorBoundary extends React.Component {
5
+ constructor(props) {
6
+ super(props);
7
+ this.state = { hasError: false };
8
+ }
9
+ static getDerivedStateFromError() {
10
+ return { hasError: true };
11
+ }
12
+ componentDidCatch(error) {
13
+ console.error('Tool call component error:', error);
14
+ this.setState({ error });
15
+ this.props.onError?.();
16
+ }
17
+ render() {
18
+ if (this.state.hasError) {
19
+ return _jsx(ToolErrorMessage, { error: this.state.error });
20
+ }
21
+ return this.props.children;
22
+ }
23
+ }
24
+ //# sourceMappingURL=ToolResultErrorBoundary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolResultErrorBoundary.js","sourceRoot":"","sources":["../../../src/components/tools/ToolResultErrorBoundary.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAkB,MAAM,OAAO,CAAC;AAEvC,MAAM,OAAO,qBAAsB,SAAQ,KAAK,CAAC,SAGhD;IACC,YAAY,KAAkD;QAC5D,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,EAAC,QAAQ,EAAE,KAAK,EAAC,CAAC;IACjC,CAAC;IAED,MAAM,CAAC,wBAAwB;QAC7B,OAAO,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;IAC1B,CAAC;IAED,iBAAiB,CAAC,KAAY;QAC5B,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;QACnD,IAAI,CAAC,QAAQ,CAAC,EAAC,KAAK,EAAC,CAAC,CAAC;QACvB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,MAAM;QACJ,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YACxB,OAAO,KAAC,gBAAgB,IAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAI,CAAC;QACvD,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;IAC7B,CAAC;CACF","sourcesContent":["import {ToolErrorMessage} from './ToolErrorMessage';\nimport React, {ReactNode} from 'react';\n\nexport class ToolCallErrorBoundary extends React.Component<\n {children: ReactNode; onError?: () => void},\n {hasError: boolean; error?: Error}\n> {\n constructor(props: {children: ReactNode; onError?: () => void}) {\n super(props);\n this.state = {hasError: false};\n }\n\n static getDerivedStateFromError() {\n return {hasError: true};\n }\n\n componentDidCatch(error: Error) {\n console.error('Tool call component error:', error);\n this.setState({error});\n this.props.onError?.();\n }\n\n render() {\n if (this.state.hasError) {\n return <ToolErrorMessage error={this.state.error} />;\n }\n\n return this.props.children;\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { RoomState } from '@sqlrooms/room-store';
2
+ import { AiSettingsSliceConfig } from '@sqlrooms/ai-config';
3
+ /**
4
+ * Helper function to type guard the store config if we have aiSettings
5
+ * @param store
6
+ * @returns
7
+ */
8
+ export declare function hasAiSettingsConfig<S extends RoomState<any>>(store: S): store is S & {
9
+ aiSettings: {
10
+ config: AiSettingsSliceConfig;
11
+ };
12
+ };
13
+ //# sourceMappingURL=hasAiSettingsConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasAiSettingsConfig.d.ts","sourceRoot":"","sources":["../src/hasAiSettingsConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAC,qBAAqB,EAAC,MAAM,qBAAqB,CAAC;AAE1D;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,SAAS,CAAC,GAAG,CAAC,EAC1D,KAAK,EAAE,CAAC,GACP,KAAK,IAAI,CAAC,GAAG;IAAC,UAAU,EAAE;QAAC,MAAM,EAAE,qBAAqB,CAAA;KAAC,CAAA;CAAC,CAQ5D"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Helper function to type guard the store config if we have aiSettings
3
+ * @param store
4
+ * @returns
5
+ */
6
+ export function hasAiSettingsConfig(store) {
7
+ return (isObject(store) &&
8
+ 'aiSettings' in store &&
9
+ isObject(store.aiSettings) &&
10
+ 'config' in store.aiSettings &&
11
+ isObject(store.aiSettings.config));
12
+ }
13
+ function isObject(val) {
14
+ return typeof val === 'object' && val !== null;
15
+ }
16
+ //# sourceMappingURL=hasAiSettingsConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasAiSettingsConfig.js","sourceRoot":"","sources":["../src/hasAiSettingsConfig.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAQ;IAER,OAAO,CACL,QAAQ,CAAC,KAAK,CAAC;QACf,YAAY,IAAI,KAAK;QACrB,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC;QAC1B,QAAQ,IAAI,KAAK,CAAC,UAAU;QAC5B,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAClC,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,GAAY;IAC5B,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,CAAC;AACjD,CAAC","sourcesContent":["import {RoomState} from '@sqlrooms/room-store';\nimport {AiSettingsSliceConfig} from '@sqlrooms/ai-config';\n\n/**\n * Helper function to type guard the store config if we have aiSettings\n * @param store\n * @returns\n */\nexport function hasAiSettingsConfig<S extends RoomState<any>>(\n store: S,\n): store is S & {aiSettings: {config: AiSettingsSliceConfig}} {\n return (\n isObject(store) &&\n 'aiSettings' in store &&\n isObject(store.aiSettings) &&\n 'config' in store.aiSettings &&\n isObject(store.aiSettings.config)\n );\n}\n\nfunction isObject(val: unknown): val is object {\n return typeof val === 'object' && val !== null;\n}\n"]}