@burtson-labs/bandit-engine 2.0.160 → 2.0.162
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +78 -77
- package/dist/{aiProviderStore-BNZGM6QU.mjs → aiProviderStore-JOB2H4LP.mjs} +2 -2
- package/dist/chat-LB6UEEEW.mjs +16 -0
- package/dist/chat-provider.js +281 -142
- package/dist/chat-provider.js.map +1 -1
- package/dist/chat-provider.mjs +6 -6
- package/dist/{chunk-MHF76C2F.mjs → chunk-3ACT5BTW.mjs} +1343 -1222
- package/dist/chunk-3ACT5BTW.mjs.map +1 -0
- package/dist/{chunk-LFQH6M6B.mjs → chunk-47MOBOP3.mjs} +5 -5
- package/dist/chunk-47MOBOP3.mjs.map +1 -0
- package/dist/chunk-G5POQT2R.mjs +390 -0
- package/dist/chunk-G5POQT2R.mjs.map +1 -0
- package/dist/{chunk-PDQT564P.mjs → chunk-ODGVCSKV.mjs} +18 -12
- package/dist/{chunk-PDQT564P.mjs.map → chunk-ODGVCSKV.mjs.map} +1 -1
- package/dist/{chunk-TKSOJGHX.mjs → chunk-OGMXL7BF.mjs} +62 -61
- package/dist/chunk-OGMXL7BF.mjs.map +1 -0
- package/dist/{chunk-B3HAQC6F.mjs → chunk-Q6LXVYTC.mjs} +68 -25
- package/dist/chunk-Q6LXVYTC.mjs.map +1 -0
- package/dist/{chunk-LTWMMHFT.mjs → chunk-R6HMLYKQ.mjs} +1820 -3260
- package/dist/chunk-R6HMLYKQ.mjs.map +1 -0
- package/dist/{chunk-IABD4L6K.mjs → chunk-RUXYVMW2.mjs} +3841 -4457
- package/dist/chunk-RUXYVMW2.mjs.map +1 -0
- package/dist/{chunk-XTB6ZLUI.mjs → chunk-WQEBTH2R.mjs} +7 -2
- package/dist/{chunk-XTB6ZLUI.mjs.map → chunk-WQEBTH2R.mjs.map} +1 -1
- package/dist/{chunk-PXCIDXRP.mjs → chunk-YHSYHU5P.mjs} +6 -6
- package/dist/{chunk-P6SLB5RC.mjs → chunk-ZNK3ELTZ.mjs} +3 -3
- package/dist/index.d.mts +85 -2
- package/dist/index.d.ts +85 -2
- package/dist/index.js +8080 -9868
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -15
- package/dist/index.mjs.map +1 -1
- package/dist/management/management.js +7681 -9478
- package/dist/management/management.js.map +1 -1
- package/dist/management/management.mjs +9 -9
- package/dist/modals/chat-modal/chat-modal.js +1714 -3302
- package/dist/modals/chat-modal/chat-modal.js.map +1 -1
- package/dist/modals/chat-modal/chat-modal.mjs +5 -5
- package/dist/{modelStore-NMCRL3FR.mjs → modelStore-FGUGOWTL.mjs} +2 -2
- package/package.json +4 -2
- package/dist/chat-4BOIV4VP.mjs +0 -16
- package/dist/chunk-B3HAQC6F.mjs.map +0 -1
- package/dist/chunk-IABD4L6K.mjs.map +0 -1
- package/dist/chunk-LFQH6M6B.mjs.map +0 -1
- package/dist/chunk-LNGF2XAZ.mjs +0 -311
- package/dist/chunk-LNGF2XAZ.mjs.map +0 -1
- package/dist/chunk-LTWMMHFT.mjs.map +0 -1
- package/dist/chunk-MHF76C2F.mjs.map +0 -1
- package/dist/chunk-TKSOJGHX.mjs.map +0 -1
- /package/dist/{aiProviderStore-BNZGM6QU.mjs.map → aiProviderStore-JOB2H4LP.mjs.map} +0 -0
- /package/dist/{chat-4BOIV4VP.mjs.map → chat-LB6UEEEW.mjs.map} +0 -0
- /package/dist/{chunk-PXCIDXRP.mjs.map → chunk-YHSYHU5P.mjs.map} +0 -0
- /package/dist/{chunk-P6SLB5RC.mjs.map → chunk-ZNK3ELTZ.mjs.map} +0 -0
- /package/dist/{modelStore-NMCRL3FR.mjs.map → modelStore-FGUGOWTL.mjs.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/StreamingMarkdown.tsx","../src/utils/installedApp.ts"],"sourcesContent":["/*\n © 2025 Burtson Labs — Licensed under Business Source License 1.1\n https://burtson.ai/license\n\n This file is protected intellectual property.\n Do NOT use in commercial software, prompts, AI training data, or derivative works without a valid commercial license.\n\n 🚫 AI NOTICE: This file contains visible and invisible watermarks.\n ⚖️ VIOLATION NOTICE: Removing, modifying, or obscuring these watermarks is a license violation.\n 🔒 LICENSE TERMINATION: Upon license termination, ALL forks, copies, and derivatives must be permanently deleted.\n 📋 AUDIT TRAIL: File usage is logged and monitored for compliance verification.\n*/\n\n// Bandit Engine Watermark: BL-WM-4F0E-E71F75\nconst __banditFingerprint_components_StreamingMarkdowntsx = 'BL-FP-BB12E1-3387';\nconst __auditTrail_components_StreamingMarkdowntsx = 'BL-AU-MGOIKVV9-FMED';\n// File: StreamingMarkdown.tsx | Path: src/components/StreamingMarkdown.tsx | Hash: 4f0e3387\n\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport { Box, Tooltip, IconButton } from \"@mui/material\";\nimport ReactMarkdown from \"react-markdown\";\nimport remarkGfm from \"remark-gfm\";\nimport rehypeRaw from \"rehype-raw\";\nimport rehypeSanitize from \"rehype-sanitize\";\nimport { useTheme, alpha } from \"@mui/material/styles\";\nimport type { Element, Text, Root } from \"hast\";\nimport type { Components, ExtraProps } from \"react-markdown\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\n\n// react-markdown 10 dropped its CodeProps export and the `inline` flag;\n// block vs inline is inferred from the content below.\ntype CodeProps = ComponentPropsWithoutRef<\"code\"> & ExtraProps;\nimport { getHighlightTree } from \"../utils/lowlight\";\nimport { MarkdownImage, markdownSanitizeSchema, renderLowlightChildren } from \"../utils/markdownRendering\";\nimport { CheckIcon, ContentCopyIcon } from \"../icons/lucide-icons\";\nimport { maybeHandleFileLinkClick } from \"../utils/openFileLink\";\n\ninterface SourceSummary {\n id: string;\n name: string;\n}\n\ninterface StreamingMarkdownProps {\n content: string;\n isStreaming?: boolean;\n sources?: SourceSummary[];\n}\n\nconst StreamingMarkdown: React.FC<StreamingMarkdownProps> = ({\n content,\n isStreaming = false,\n sources,\n}) => {\n const theme = useTheme();\n const showCursor = isStreaming && content.trim().length > 0;\n const showLoader = isStreaming && content.trim().length === 0; // Show loader when streaming but no content yet\n const prevSanitizedRef = useRef<string>(\"\");\n const containerRef = useRef<HTMLDivElement | null>(null);\n const stableSourcesRef = useRef<SourceSummary[]>([]);\n\n const effectiveSources = useMemo(() => {\n if (Array.isArray(sources) && sources.length > 0) {\n stableSourcesRef.current = sources;\n return sources;\n }\n\n if (sources === undefined) {\n return stableSourcesRef.current;\n }\n\n stableSourcesRef.current = [];\n return [];\n }, [sources]);\n\n const normalizeTables = (markdown: string): string => {\n const lines = markdown.split(\"\\n\");\n const output: string[] = [];\n let inTable = false;\n let tableRows: string[][] = [];\n\n const flushTable = () => {\n if (tableRows.length === 0) return;\n const maxCols = Math.max(...tableRows.map((r) => r.length));\n const padded = tableRows.map((row) => [...row, ...Array(maxCols - row.length).fill(\"\")]);\n const header = padded[0];\n const separator = Array(maxCols).fill(\"---\");\n output.push(\"| \" + header.join(\" | \") + \" |\");\n output.push(\"| \" + separator.join(\" | \") + \" |\");\n for (let i = 1; i < padded.length; i++) {\n const row = padded[i];\n if (row.every((cell) => /^-+$/.test(cell))) continue;\n output.push(\"| \" + row.join(\" | \") + \" |\");\n }\n tableRows = [];\n inTable = false;\n };\n\n for (const line of lines) {\n if (/^\\s*\\|.*\\|\\s*$/.test(line)) {\n inTable = true;\n const cells = line.trim().slice(1, -1).split(\"|\").map((c) => c.trim());\n tableRows.push(cells);\n } else {\n if (inTable) flushTable();\n output.push(line);\n }\n }\n if (inTable) flushTable();\n return output.join(\"\\n\");\n };\n\n const sanitizeMarkdown = (raw: string): string => {\n let sanitized = raw.replace(/<[/]?start_of_turn>|<[/]?end[_]?of[_]?turn>/gi, \"\");\n // Unwrap Box wrappers\n sanitized = sanitized\n .replace(/<div class=\"MuiBox-root[^\"]*\"[^>]*>([\\s\\S]*?)<\\/div>/g, (_, inner) => inner.trim())\n .replace(/<div[^>]*>\\s*<\\/div>/g, \"\");\n // Collapse newline before common punctuation\n sanitized = sanitized.replace(/\\r?\\n\\s*:\\s*/g, \": \");\n sanitized = sanitized.replace(/\\r?\\n\\s*,\\s*/g, \", \");\n // Normalize pipe tables\n sanitized = normalizeTables(sanitized);\n return sanitized;\n };\n\n const sanitizedContent = sanitizeMarkdown(content);\n\n const contentWithSources = useMemo(() => {\n if (!effectiveSources.length || isStreaming) {\n return sanitizedContent;\n }\n\n const existingSection = /\\*\\*Sources?\\*\\*/i.test(sanitizedContent);\n if (existingSection) {\n return sanitizedContent;\n }\n\n const listMarkdown = effectiveSources\n .map((doc, index) => `- ${index + 1}. ${doc.name}`)\n .join(\"\\n\");\n\n return `${sanitizedContent}\\n\\n**Sources**\\n${listMarkdown}`;\n }, [sanitizedContent, effectiveSources, isStreaming]);\n\n // Helpers for safe per-word fade wrapping\n const escapeHtml = (str: string) =>\n str\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\\\"/g, \""\")\n .replace(/'/g, \"'\");\n\n const isPlainAppend = (s: string) => {\n // Avoid wrapping when the delta includes markdown/code/meta characters\n return !/[`*_\\[\\]<>|#~]/.test(s);\n };\n\n // Compute a render string where newly appended words fade in with a stagger\n let renderContent = contentWithSources;\n if (isStreaming) {\n const prev = prevSanitizedRef.current;\n // Find common prefix length to identify newly appended tail\n let i = 0;\n const max = Math.min(prev.length, sanitizedContent.length);\n while (i < max && prev.charCodeAt(i) === sanitizedContent.charCodeAt(i)) i++;\n const base = sanitizedContent.slice(0, i);\n const appended = sanitizedContent.slice(i);\n if (appended && isPlainAppend(appended)) {\n const parts = appended.split(/(\\s+)/); // keep whitespace tokens\n let delayMs = 0;\n const step = 42; // gentle stagger between words for smoother reveal\n const wrapped = parts\n .map((p) => {\n if (/^\\s+$/.test(p) || p === \"\") return p; // preserve whitespace\n const safe = escapeHtml(p);\n const out = `<span class=\\\"bl-fade-word\\\" data-bl-delay=\\\"${delayMs}\\\">${safe}</span>`;\n delayMs += step;\n return out;\n })\n .join(\"\");\n renderContent = base + wrapped;\n }\n }\n\n // After compute: update ref for next render\n useEffect(() => {\n prevSanitizedRef.current = contentWithSources;\n }, [contentWithSources]);\n\n useEffect(() => {\n if (!containerRef.current) return;\n const nodes = containerRef.current.querySelectorAll<HTMLElement>(\".bl-fade-word\");\n nodes.forEach((node) => {\n const delay = node.getAttribute(\"data-bl-delay\");\n if (delay) {\n node.style.setProperty(\"--bl-delay\", `${delay}ms`);\n node.style.animationDelay = `${delay}ms`;\n }\n });\n }, [renderContent, sanitizedContent, isStreaming]);\n\n type MarkProps = ComponentPropsWithoutRef<\"mark\">;\n type AnchorProps = ComponentPropsWithoutRef<\"a\">;\n type EmProps = ComponentPropsWithoutRef<\"em\">;\n type TableProps = ComponentPropsWithoutRef<\"table\">;\n type TableCellProps = ComponentPropsWithoutRef<\"td\">;\n type TableHeaderProps = ComponentPropsWithoutRef<\"th\">;\n type ParagraphProps = ComponentPropsWithoutRef<\"p\">;\n type BlockQuoteProps = ComponentPropsWithoutRef<\"blockquote\">;\n type OrderedListProps = ComponentPropsWithoutRef<\"ol\">;\n type UnorderedListProps = ComponentPropsWithoutRef<\"ul\">;\n\n const MarkRenderer: React.FC<MarkProps> = ({ children, ...props }) => {\n const inlineBg = theme.palette.mode === \"dark\"\n ? alpha(theme.palette.common.white, 0.06)\n : alpha(theme.palette.text.primary, 0.06);\n const inlineBorder = `1px solid ${alpha(theme.palette.text.primary, 0.15)}`;\n return (\n <Box\n component=\"span\"\n sx={{\n display: \"inline-block\",\n backgroundColor: inlineBg,\n border: inlineBorder,\n color: \"inherit\",\n padding: \"0.15em 0.35em\",\n borderRadius: \"4px\",\n fontWeight: 500,\n fontSize: \"0.92em\",\n lineHeight: 1.4,\n whiteSpace: \"normal\",\n width: \"fit-content\",\n maxWidth: \"100%\",\n fontFamily:\n \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace\",\n }}\n {...props}\n >\n {children}\n </Box>\n );\n };\n\n const LinkRenderer: React.FC<AnchorProps> = ({ href, children, ...props }) => (\n <a\n href={href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n // Standalone PWAs can't download — route file links to the share sheet.\n onClick={(e) => maybeHandleFileLinkClick(e, href)}\n style={{\n color: theme.palette.info?.main ?? theme.palette.primary.main,\n textDecoration: \"underline\",\n textUnderlineOffset: \"2px\",\n }}\n {...props}\n >\n {children}\n </a>\n );\n\n const CodeRenderer: React.FC<CodeProps> = ({ node: _node, className, children, ...props }) => {\n const match = /language-([\\w-]+)/.exec(className || \"\");\n const requestedLanguage = match?.[1]?.toLowerCase() ?? \"\";\n const codeText = String(children).replace(/\\n$/, \"\");\n const isProbablyBlock = codeText.includes(\"\\n\") || Boolean(requestedLanguage);\n\n const [copied, setCopied] = useState(false);\n const handleCopy = () => {\n void navigator.clipboard.writeText(codeText);\n setCopied(true);\n setTimeout(() => setCopied(false), 2000);\n };\n\n\n const highlightTree = useMemo<Root | null>(\n () => (isProbablyBlock ? getHighlightTree(codeText, requestedLanguage) : null),\n [isProbablyBlock, codeText, requestedLanguage]\n );\n\n const highlightedNodes = useMemo<ReactNode[]>(\n () =>\n highlightTree\n ? renderLowlightChildren(\n (highlightTree.children || []).filter(\n (node): node is Element | Text => node.type === \"element\" || node.type === \"text\"\n ),\n `hl-${requestedLanguage || \"auto\"}`\n )\n : [],\n [highlightTree, requestedLanguage]\n );\n\n const dataLanguage =\n highlightTree &&\n highlightTree.data &&\n typeof highlightTree.data === \"object\" &&\n \"language\" in highlightTree.data\n ? String((highlightTree.data as { language?: unknown }).language ?? \"\")\n : \"\";\n\n if (!highlightTree) {\n const inlineBg = theme.palette.mode === \"dark\"\n ? alpha(theme.palette.common.white, 0.06)\n : alpha(theme.palette.text.primary, 0.06);\n const inlineBorder = `1px solid ${alpha(theme.palette.text.primary, 0.15)}`;\n return (\n <code\n style={{\n borderRadius: 4,\n fontSize: \"0.92em\",\n fontFamily: \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace\",\n backgroundColor: inlineBg,\n border: inlineBorder,\n padding: \"0.15em 0.35em\",\n }}\n {...props}\n >\n {children}\n </code>\n );\n }\n\n const resolvedLanguage = (requestedLanguage || dataLanguage || \"code\").toString();\n const languageLabel = resolvedLanguage.toUpperCase();\n const languageClass = resolvedLanguage.toLowerCase();\n\n const highlightColors = theme.palette.mode === \"dark\"\n ? {\n background: \"#0f172a\",\n text: \"#e2e8f0\",\n keyword: \"#c792ea\",\n string: \"#7fdbca\",\n number: \"#f78c6c\",\n comment: \"#64748b\",\n function: \"#82aaff\",\n variable: \"#f07178\",\n }\n : {\n background: \"#f4f6ff\",\n text: \"#1e293b\",\n keyword: \"#7c3aed\",\n string: \"#0f766e\",\n number: \"#b45309\",\n comment: \"#6b7280\",\n function: \"#2563eb\",\n variable: \"#d97706\",\n };\n\n return (\n <Box\n sx={{\n borderRadius: \"4px\",\n overflow: \"auto\",\n my: \"0.5rem\",\n px: 0,\n py: 0,\n mt: 1,\n mb: 0.5,\n fontSize: \"0.9rem\",\n position: \"relative\",\n fontFamily: \"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace\",\n width: \"100%\",\n maxWidth: \"100%\",\n }}\n >\n <Box\n sx={{\n px: 2,\n py: 1,\n bgcolor: theme.palette.mode === \"dark\"\n ? alpha(theme.palette.common.white, 0.04)\n : alpha(theme.palette.text.primary, 0.04),\n color: theme.palette.text.secondary,\n fontSize: \"0.75rem\",\n borderBottom: `1px solid ${alpha(theme.palette.text.primary, 0.1)}`,\n display: \"flex\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n fontFamily: \"inherit\",\n }}\n >\n <span>{languageLabel}</span>\n <Tooltip title={copied ? \"Copied!\" : \"Copy\"} arrow>\n <IconButton\n size=\"small\"\n onClick={handleCopy}\n sx={{\n color: copied ? theme.palette.success.main : theme.palette.text.secondary,\n \"&:hover\": { color: theme.palette.text.primary },\n padding: \"4px\",\n }}\n >\n {copied ? <CheckIcon fontSize=\"small\" /> : <ContentCopyIcon fontSize=\"small\" />}\n </IconButton>\n </Tooltip>\n </Box>\n <Box\n sx={{\n overflowX: \"auto\",\n maxWidth: \"100%\",\n '& .hljs': {\n display: 'block',\n overflowX: 'auto',\n padding: '16px',\n margin: 0,\n backgroundColor: highlightColors.background,\n color: highlightColors.text,\n fontSize: '0.9rem',\n },\n '& .hljs-comment, & .hljs-quote': {\n color: highlightColors.comment,\n fontStyle: 'italic',\n },\n '& .hljs-keyword, & .hljs-selector-tag, & .hljs-literal, & .hljs-built_in': {\n color: highlightColors.keyword,\n },\n '& .hljs-string, & .hljs-doctag, & .hljs-template-tag, & .hljs-attr': {\n color: highlightColors.string,\n },\n '& .hljs-number, & .hljs-symbol, & .hljs-bullet, & .hljs-meta': {\n color: highlightColors.number,\n },\n '& .hljs-title, & .hljs-section, & .hljs-selector-id, & .hljs-function': {\n color: highlightColors.function,\n },\n '& .hljs-variable, & .hljs-params, & .hljs-property': {\n color: highlightColors.variable,\n },\n }}\n >\n <pre className={`hljs language-${languageClass}`} {...props}>\n <code className=\"hljs\">{highlightedNodes}</code>\n </pre>\n </Box>\n </Box>\n );\n };\n\n const EmRenderer: React.FC<EmProps> = ({ children, ...props }) => {\n const onlyChild = Array.isArray(children) && children.length === 1 ? children[0] : null;\n if (\n onlyChild &&\n React.isValidElement<{ className?: unknown; children?: ReactNode }>(onlyChild) &&\n typeof onlyChild.props?.className === \"string\" &&\n onlyChild.props.className.includes(\"MuiBox-root\")\n ) {\n const inner = onlyChild.props.children as ReactNode;\n if (typeof inner === \"string\" && inner.trim().toUpperCase() === \"CODE\") {\n return null;\n }\n return (\n <Box\n sx={{\n fontFamily: \"monospace\",\n fontSize: \"0.9rem\",\n backgroundColor: theme.palette.background.default,\n color: theme.palette.text.primary,\n padding: \"12px 16px\",\n borderRadius: \"4px\",\n border: `1px solid ${theme.palette.divider}`,\n my: 1,\n display: \"inline-block\",\n }}\n >\n {inner}\n </Box>\n );\n }\n return <em {...props}>{children}</em>;\n };\n\n const TableRenderer: React.FC<TableProps> = ({ children, ...props }) => (\n <Box sx={{ overflowX: \"auto\", my: 1 }}>\n <table style={{ borderCollapse: \"collapse\", width: \"100%\" }} {...props}>\n {children}\n </table>\n </Box>\n );\n\n const OrderedListRenderer: React.FC<OrderedListProps> = ({ children, ...props }) => (\n <ol style={{ paddingLeft: 24, marginLeft: 16, listStyleType: \"decimal\" }} {...props}>\n {children}\n </ol>\n );\n\n const UnorderedListRenderer: React.FC<UnorderedListProps> = ({ children, ...props }) => (\n <ul\n style={{\n paddingLeft: \"1.5rem\",\n marginTop: \"0.5rem\",\n marginBottom: \"0.25rem\",\n listStyle: \"disc\",\n }}\n {...props}\n >\n {children}\n </ul>\n );\n\n const BlockQuoteRenderer: React.FC<BlockQuoteProps> = ({ children, ...props }) => (\n <Box\n component=\"blockquote\"\n sx={{\n borderLeft: `4px solid ${theme.palette.divider}`,\n pl: 2,\n ml: 0,\n color: theme.palette.text.secondary,\n }}\n {...props}\n >\n {children}\n </Box>\n );\n\n const TableHeaderRenderer: React.FC<TableHeaderProps> = ({ children, ...props }) => (\n <th\n style={{\n border: \"1px solid #ddd\",\n padding: \"8px\",\n backgroundColor: theme.palette.mode === \"dark\" ? \"#333\" : \"#f2f2f2\",\n textAlign: \"left\",\n }}\n {...props}\n >\n {children}\n </th>\n );\n\n const TableCellRenderer: React.FC<TableCellProps> = ({ children, ...props }) => (\n <td\n style={{\n border: \"1px solid #ddd\",\n padding: \"8px\",\n }}\n {...props}\n >\n {children}\n </td>\n );\n\n const ParagraphRenderer: React.FC<ParagraphProps> = ({ children, ...props }) => (\n <p style={{ marginTop: \"0.5rem\", marginBottom: \"0.5rem\" }} {...props}>\n {children}\n </p>\n );\n\n const components: Components = {\n mark: MarkRenderer,\n code: CodeRenderer,\n a: LinkRenderer,\n img: MarkdownImage,\n em: EmRenderer,\n table: TableRenderer,\n ol: OrderedListRenderer,\n ul: UnorderedListRenderer,\n blockquote: BlockQuoteRenderer,\n th: TableHeaderRenderer,\n td: TableCellRenderer,\n p: ParagraphRenderer,\n };\n\n return (\n <Box\n ref={containerRef}\n sx={{\n // Settle the whole block to full color a beat after streaming ends.\n transition: \"opacity 380ms ease-out, transform 220ms ease-out\",\n \"& .cursor\": {\n display: showCursor ? \"inline\" : \"none\",\n animation: \"blink 1s step-start infinite\",\n },\n \"@keyframes blink\": {\n \"50%\": { opacity: 0 },\n },\n // Each newly-written word focuses in — blur→sharp, a tiny rise, and fade —\n // like ink settling onto the page as the typewriter writes.\n \"& .bl-fade-word\": {\n opacity: 0,\n animation: \"bl-fade-in 480ms cubic-bezier(0.22, 1, 0.36, 1) forwards\",\n },\n \"@keyframes bl-fade-in\": {\n from: { opacity: 0, filter: \"blur(3px)\", transform: \"translateY(2px)\" },\n to: { opacity: 1, filter: \"blur(0)\", transform: \"translateY(0)\" },\n },\n // Dimmed while streaming, then brightens to full color once the answer lands.\n opacity: isStreaming ? 0.86 : 1,\n transform: isStreaming ? \"translateY(0.25px)\" : \"none\",\n // Reduce layout jumpiness between updates\n \"& p:last-child\": { marginBottom: 0 },\n // Add min height when showing loader to prevent layout shift\n minHeight: showLoader ? \"40px\" : \"auto\",\n }}\n >\n {showLoader ? (\n // Show loading indicator when streaming but no content yet\n <Box sx={{ display: \"flex\", alignItems: \"center\", minHeight: \"40px\", pl: 2 }}>\n <div className=\"typing-only\">\n <span className=\"dot\" />\n <span className=\"dot\" />\n <span className=\"dot\" />\n </div>\n </Box>\n ) : (\n <ReactMarkdown\n remarkPlugins={[remarkGfm]}\n rehypePlugins={[rehypeRaw, [rehypeSanitize, markdownSanitizeSchema]]}\n components={components}\n >\n {(renderContent || sanitizedContent) + (showCursor ? \" ▊\" : \"\")}\n </ReactMarkdown>\n )}\n </Box>\n );\n};\n\n// Skip re-rendering (and re-parsing markdown) when nothing this component cares\n// about changed. Critical for long chats: without this, every streamed token\n// re-parses the markdown of EVERY prior message — the main source of mid-stream\n// jank / \"thread-locky\" feel. Only the actively-streaming message (whose content\n// changes each flush) re-renders.\nconst arePropsEqual = (\n prev: StreamingMarkdownProps,\n next: StreamingMarkdownProps,\n): boolean => {\n if (prev.content !== next.content || prev.isStreaming !== next.isStreaming) {\n return false;\n }\n const a = prev.sources;\n const b = next.sources;\n if (a === b) return true;\n if (!a || !b || a.length !== b.length) return false;\n return a.every((s, i) => s.id === b[i].id && s.name === b[i].name);\n};\n\nexport default React.memo(StreamingMarkdown, arePropsEqual);\n","/**\n * \"Is this running as an installed app?\" — either a home-screen PWA in\n * standalone display mode, or the Capacitor native shell (which injects\n * `window.Capacitor` before the page loads). The engine can't import\n * @capacitor/core (it's a host-app dependency), so the native check reads\n * the global directly.\n *\n * Layout code that sizes to the real webview / hides browser chrome should\n * key off this rather than the standalone media query alone — WKWebView\n * reports display-mode \"browser\", so the native app would otherwise get\n * the in-browser layout.\n */\nexport const isNativeShell = (): boolean => {\n if (typeof window === \"undefined\") return false;\n const cap = (window as unknown as { Capacitor?: { isNativePlatform?: () => boolean } }).Capacitor;\n return typeof cap?.isNativePlatform === \"function\" && cap.isNativePlatform() === true;\n};\n\nexport const isStandalonePwa = (): boolean => {\n if (typeof window === \"undefined\") return false;\n const nav = window.navigator as Navigator & { standalone?: boolean };\n return window.matchMedia?.(\"(display-mode: standalone)\").matches || nav.standalone === true;\n};\n\nexport const isInstalledApp = (): boolean => isStandalonePwa() || isNativeShell();\n"],"mappings":";;;;;;;;;;;AAkBA,OAAO,SAAS,WAAW,SAAS,QAAQ,gBAAgB;AAC5D,SAAS,KAAK,SAAS,kBAAkB;AACzC,OAAO,mBAAmB;AAC1B,OAAO,eAAe;AACtB,OAAO,eAAe;AACtB,OAAO,oBAAoB;AAC3B,SAAS,UAAU,aAAa;AAmM1B,cAoJE,YApJF;AA3KN,IAAM,oBAAsD,CAAC;AAAA,EAC3D;AAAA,EACA,cAAc;AAAA,EACd;AACF,MAAM;AACJ,QAAM,QAAQ,SAAS;AACvB,QAAM,aAA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AI,CAAC,KAAK,CAAC,KAAK,EAAE,WAAW,EAAE,OAAQ,QAAO;AAC9C,SAAO,EAAE,MAAM,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI;AACnE;AAEA,IAAO,4BAAQ,MAAM,KAAK,mBAAmB,aAAa;;;AChnBnD,IAAM,gBAAgB,MAAe;AAC1C,MAAI,OAAO,WAAW,YAAa,QAAO;AAC1C,QAAM,MAAO,OAA2E;AACxF,SAAO,OAAO,KAAK,qBAAqB,cAAc,IAAI,iBAAiB,MAAM;AACnF;AAEO,IAAM,kBAAkB,MAAe;AAC5C,MAAI,OAAO,WAAW,YAAa,QAAO;AAC1C,QAAM,MAAM,OAAO;AACnB,SAAO,OAAO,aAAa,4BAA4B,EAAE,WAAW,IAAI,eAAe;AACzF;","names":[]}
|
package/dist/chunk-LNGF2XAZ.mjs
DELETED
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
indexedDBService_default,
|
|
3
|
-
usePackageSettingsStore
|
|
4
|
-
} from "./chunk-XTB6ZLUI.mjs";
|
|
5
|
-
import {
|
|
6
|
-
authenticationService
|
|
7
|
-
} from "./chunk-B3HAQC6F.mjs";
|
|
8
|
-
import {
|
|
9
|
-
debugLogger
|
|
10
|
-
} from "./chunk-KCI46M23.mjs";
|
|
11
|
-
|
|
12
|
-
// src/store/mcpToolsStore.ts
|
|
13
|
-
import { create } from "zustand";
|
|
14
|
-
|
|
15
|
-
// src/services/mcp/mcpServersService.ts
|
|
16
|
-
var gatewayBase = () => {
|
|
17
|
-
const settings = usePackageSettingsStore.getState().settings;
|
|
18
|
-
const url = settings?.gatewayApiUrl?.replace(/\/$/, "");
|
|
19
|
-
if (!url) throw new Error("Gateway API is not configured.");
|
|
20
|
-
return url;
|
|
21
|
-
};
|
|
22
|
-
var authHeaders = () => {
|
|
23
|
-
const headers = { "Content-Type": "application/json" };
|
|
24
|
-
const token = authenticationService.getToken();
|
|
25
|
-
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
26
|
-
return headers;
|
|
27
|
-
};
|
|
28
|
-
var parse = async (res) => {
|
|
29
|
-
const text = await res.text();
|
|
30
|
-
const body = text ? JSON.parse(text) : null;
|
|
31
|
-
if (!res.ok) {
|
|
32
|
-
const message = body && typeof body === "object" && (body.error || body.message) || `Request failed (${res.status})`;
|
|
33
|
-
throw new Error(String(message));
|
|
34
|
-
}
|
|
35
|
-
return body;
|
|
36
|
-
};
|
|
37
|
-
var listMcpServers = async () => parse(await fetch(`${gatewayBase()}/mcp/servers`, { headers: authHeaders() }));
|
|
38
|
-
var addMcpServer = async (input) => parse(
|
|
39
|
-
await fetch(`${gatewayBase()}/mcp/servers`, {
|
|
40
|
-
method: "POST",
|
|
41
|
-
headers: authHeaders(),
|
|
42
|
-
body: JSON.stringify(input)
|
|
43
|
-
})
|
|
44
|
-
);
|
|
45
|
-
var updateMcpServer = async (id, input) => parse(
|
|
46
|
-
await fetch(`${gatewayBase()}/mcp/servers/${encodeURIComponent(id)}`, {
|
|
47
|
-
method: "PUT",
|
|
48
|
-
headers: authHeaders(),
|
|
49
|
-
body: JSON.stringify(input)
|
|
50
|
-
})
|
|
51
|
-
);
|
|
52
|
-
var deleteMcpServer = async (id) => {
|
|
53
|
-
const res = await fetch(`${gatewayBase()}/mcp/servers/${encodeURIComponent(id)}`, {
|
|
54
|
-
method: "DELETE",
|
|
55
|
-
headers: authHeaders()
|
|
56
|
-
});
|
|
57
|
-
if (!res.ok && res.status !== 204) {
|
|
58
|
-
throw new Error(`Could not remove the server (${res.status}).`);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
var discoverMcpTools = async (id) => parse(await fetch(`${gatewayBase()}/mcp/servers/${encodeURIComponent(id)}/tools`, { headers: authHeaders() }));
|
|
62
|
-
|
|
63
|
-
// src/store/mcpToolsStore.ts
|
|
64
|
-
var sanitizeMcpToolName = (raw) => raw.replace(/[^a-zA-Z0-9_]/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").slice(0, 60);
|
|
65
|
-
var healthCheckTool = {
|
|
66
|
-
id: "health-check",
|
|
67
|
-
name: "check_gateway_health",
|
|
68
|
-
description: "Check the health status of the gateway API service",
|
|
69
|
-
enabled: true,
|
|
70
|
-
type: "function",
|
|
71
|
-
function: {
|
|
72
|
-
name: "check_gateway_health",
|
|
73
|
-
description: "Check the health status of the gateway API service",
|
|
74
|
-
parameters: {
|
|
75
|
-
type: "object",
|
|
76
|
-
properties: {},
|
|
77
|
-
required: []
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
endpoint: "/mcp/health",
|
|
81
|
-
method: "GET",
|
|
82
|
-
isBuiltIn: true
|
|
83
|
-
};
|
|
84
|
-
var webSearchTool = {
|
|
85
|
-
id: "web-search",
|
|
86
|
-
name: "web_search",
|
|
87
|
-
description: "Search the web for current information, documentation, and facts",
|
|
88
|
-
enabled: true,
|
|
89
|
-
type: "function",
|
|
90
|
-
function: {
|
|
91
|
-
name: "web_search",
|
|
92
|
-
description: "Search the web and return ranked results with snippets (and an optional summarized answer). Use for current events, documentation, libraries, error messages, and factual lookups.",
|
|
93
|
-
parameters: {
|
|
94
|
-
type: "object",
|
|
95
|
-
properties: {
|
|
96
|
-
query: { type: "string", description: "The search query \u2014 natural language or keywords" },
|
|
97
|
-
count: { type: "number", description: "Number of results to return (1-10, default 5)" },
|
|
98
|
-
include_answer: { type: "boolean", description: "Include a short summarized answer when available" }
|
|
99
|
-
},
|
|
100
|
-
required: ["query"]
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
endpoint: "/mcp/web-search",
|
|
104
|
-
method: "GET",
|
|
105
|
-
isBuiltIn: true
|
|
106
|
-
};
|
|
107
|
-
var webFetchTool = {
|
|
108
|
-
id: "web-fetch",
|
|
109
|
-
name: "web_fetch",
|
|
110
|
-
description: "Fetch the text content of a specific URL",
|
|
111
|
-
enabled: true,
|
|
112
|
-
type: "function",
|
|
113
|
-
function: {
|
|
114
|
-
name: "web_fetch",
|
|
115
|
-
description: "Fetch a single public URL and return its trimmed text content. Use when you already have a specific link you need to read.",
|
|
116
|
-
parameters: {
|
|
117
|
-
type: "object",
|
|
118
|
-
properties: {
|
|
119
|
-
url: { type: "string", description: "Absolute http(s) URL to fetch" }
|
|
120
|
-
},
|
|
121
|
-
required: ["url"]
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
endpoint: "/mcp/web-fetch",
|
|
125
|
-
method: "GET",
|
|
126
|
-
isBuiltIn: true
|
|
127
|
-
};
|
|
128
|
-
var imageGenerationTool = {
|
|
129
|
-
id: "image-generation",
|
|
130
|
-
name: "image_generation",
|
|
131
|
-
description: "Generate an image from a text prompt on the Burtson Labs GPU",
|
|
132
|
-
enabled: true,
|
|
133
|
-
type: "function",
|
|
134
|
-
function: {
|
|
135
|
-
name: "image_generation",
|
|
136
|
-
description: "Generate an image from a text prompt on the Burtson Labs GPU",
|
|
137
|
-
parameters: {
|
|
138
|
-
type: "object",
|
|
139
|
-
properties: {
|
|
140
|
-
prompt: { type: "string", description: "Text description of the image to generate" },
|
|
141
|
-
size: { type: "string", enum: ["1024x1024", "1344x768", "768x1344"], description: "Canvas: square, landscape, or portrait" }
|
|
142
|
-
},
|
|
143
|
-
required: ["prompt"]
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
endpoint: "/mcp/generate-image",
|
|
147
|
-
method: "POST",
|
|
148
|
-
isBuiltIn: true
|
|
149
|
-
};
|
|
150
|
-
var createFileTool = {
|
|
151
|
-
id: "create-file",
|
|
152
|
-
name: "create_file",
|
|
153
|
-
description: "Create a downloadable file for the user (md, txt, csv, json, html, docx, pptx, pdf). Returns a temporary (~1 hour) download link.",
|
|
154
|
-
enabled: true,
|
|
155
|
-
type: "function",
|
|
156
|
-
function: {
|
|
157
|
-
name: "create_file",
|
|
158
|
-
description: "Generate a file the user can download. For docx/pptx write well-structured Markdown (headings, lists, tables; use '## ' headings to start each slide). For pdf, prefer complete HTML with inline CSS (branded proposals, print layouts) \u2014 Chromium renders it without browser headers/footers; Markdown also works. Returns a short-lived (~1 hour) download URL \u2014 tell the user it expires.",
|
|
159
|
-
parameters: {
|
|
160
|
-
type: "object",
|
|
161
|
-
properties: {
|
|
162
|
-
content: { type: "string", description: "The file content (HTML preferred for pdf; Markdown for docx/pptx/pdf; raw text for others)." },
|
|
163
|
-
filename: { type: "string", description: "Desired filename, e.g. 'report.pdf' or 'notes.md'." },
|
|
164
|
-
format: {
|
|
165
|
-
type: "string",
|
|
166
|
-
enum: ["md", "txt", "csv", "json", "html", "xml", "yaml", "docx", "pptx", "pdf"],
|
|
167
|
-
description: "File format. Defaults to md."
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
required: ["content", "format"]
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
endpoint: "/mcp/create-file",
|
|
174
|
-
method: "POST",
|
|
175
|
-
isBuiltIn: true
|
|
176
|
-
};
|
|
177
|
-
var defaultTools = [healthCheckTool, webSearchTool, webFetchTool, imageGenerationTool, createFileTool];
|
|
178
|
-
var useMCPToolsStore = create((set, get) => ({
|
|
179
|
-
tools: defaultTools,
|
|
180
|
-
isLoaded: false,
|
|
181
|
-
addTool: (toolData) => {
|
|
182
|
-
const newTool = {
|
|
183
|
-
...toolData,
|
|
184
|
-
id: `tool-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`
|
|
185
|
-
};
|
|
186
|
-
set((state) => ({
|
|
187
|
-
tools: [...state.tools, newTool]
|
|
188
|
-
}));
|
|
189
|
-
get().saveTools();
|
|
190
|
-
},
|
|
191
|
-
updateTool: (id, updates) => {
|
|
192
|
-
set((state) => ({
|
|
193
|
-
tools: state.tools.map(
|
|
194
|
-
(tool) => tool.id === id ? { ...tool, ...updates } : tool
|
|
195
|
-
)
|
|
196
|
-
}));
|
|
197
|
-
get().saveTools();
|
|
198
|
-
},
|
|
199
|
-
deleteTool: (id) => {
|
|
200
|
-
set((state) => ({
|
|
201
|
-
tools: state.tools.filter((tool) => tool.id !== id || tool.isBuiltIn)
|
|
202
|
-
}));
|
|
203
|
-
get().saveTools();
|
|
204
|
-
},
|
|
205
|
-
toggleTool: (id) => {
|
|
206
|
-
set((state) => ({
|
|
207
|
-
tools: state.tools.map(
|
|
208
|
-
(tool) => tool.id === id ? { ...tool, enabled: !tool.enabled } : tool
|
|
209
|
-
)
|
|
210
|
-
}));
|
|
211
|
-
get().saveTools();
|
|
212
|
-
},
|
|
213
|
-
getEnabledTools: () => {
|
|
214
|
-
return get().tools.filter((tool) => tool.enabled);
|
|
215
|
-
},
|
|
216
|
-
loadTools: async () => {
|
|
217
|
-
try {
|
|
218
|
-
const storeConfigs = [{ name: "config", keyPath: "id" }];
|
|
219
|
-
const data = await indexedDBService_default.get("banditConfig", 1, "config", "mcpTools", storeConfigs);
|
|
220
|
-
if (data?.tools && Array.isArray(data.tools)) {
|
|
221
|
-
const savedTools = data.tools;
|
|
222
|
-
const builtInIds = defaultTools.map((t) => t.id);
|
|
223
|
-
const customTools = savedTools.filter(
|
|
224
|
-
(tool) => !tool.isBuiltIn && !builtInIds.includes(tool.id)
|
|
225
|
-
);
|
|
226
|
-
set({
|
|
227
|
-
tools: [...defaultTools, ...customTools],
|
|
228
|
-
isLoaded: true
|
|
229
|
-
});
|
|
230
|
-
debugLogger.info("MCP tools loaded from IndexedDB", {
|
|
231
|
-
totalTools: defaultTools.length + customTools.length,
|
|
232
|
-
builtInTools: defaultTools.length,
|
|
233
|
-
customTools: customTools.length
|
|
234
|
-
});
|
|
235
|
-
} else {
|
|
236
|
-
set({ isLoaded: true });
|
|
237
|
-
await get().saveTools();
|
|
238
|
-
debugLogger.info("Default MCP tools initialized");
|
|
239
|
-
}
|
|
240
|
-
} catch (error) {
|
|
241
|
-
debugLogger.error("Failed to load MCP tools from IndexedDB", { error });
|
|
242
|
-
set({ isLoaded: true });
|
|
243
|
-
}
|
|
244
|
-
},
|
|
245
|
-
saveTools: async () => {
|
|
246
|
-
try {
|
|
247
|
-
const { tools } = get();
|
|
248
|
-
const storeConfigs = [{ name: "config", keyPath: "id" }];
|
|
249
|
-
const customTools = tools.filter((tool) => !tool.isBuiltIn && !tool.mcpServerId);
|
|
250
|
-
await indexedDBService_default.put("banditConfig", 1, "config", {
|
|
251
|
-
id: "mcpTools",
|
|
252
|
-
tools: customTools
|
|
253
|
-
}, storeConfigs);
|
|
254
|
-
debugLogger.debug("MCP tools saved to IndexedDB", { toolCount: customTools.length });
|
|
255
|
-
} catch (error) {
|
|
256
|
-
debugLogger.error("Failed to save MCP tools to IndexedDB", { error });
|
|
257
|
-
}
|
|
258
|
-
},
|
|
259
|
-
// Discover the user's connected MCP servers' tools from the gateway and merge
|
|
260
|
-
// them into the tool list (so the model can call them). Replaces any prior
|
|
261
|
-
// MCP-server tools; best-effort — a single unreachable server is skipped.
|
|
262
|
-
loadMcpServerTools: async () => {
|
|
263
|
-
let servers;
|
|
264
|
-
try {
|
|
265
|
-
servers = await listMcpServers();
|
|
266
|
-
} catch (error) {
|
|
267
|
-
debugLogger.warn("Could not list MCP servers", { error: String(error) });
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
const collected = [];
|
|
271
|
-
for (const server of servers.filter((s) => s.enabled)) {
|
|
272
|
-
try {
|
|
273
|
-
const { tools } = await discoverMcpTools(server.id);
|
|
274
|
-
for (const t of tools) {
|
|
275
|
-
const fnName = sanitizeMcpToolName(`mcp_${server.name}_${t.name}`);
|
|
276
|
-
const schema = t.inputSchema && typeof t.inputSchema === "object" && t.inputSchema.type === "object" ? t.inputSchema : { type: "object", properties: {}, required: [] };
|
|
277
|
-
collected.push({
|
|
278
|
-
id: `mcp-${server.id}-${t.name}`,
|
|
279
|
-
name: fnName,
|
|
280
|
-
description: t.description || `${t.name} (via ${server.name})`,
|
|
281
|
-
enabled: true,
|
|
282
|
-
type: "function",
|
|
283
|
-
function: {
|
|
284
|
-
name: fnName,
|
|
285
|
-
description: t.description || `${t.name} \u2014 provided by the ${server.name} MCP server.`,
|
|
286
|
-
parameters: schema
|
|
287
|
-
},
|
|
288
|
-
mcpServerId: server.id,
|
|
289
|
-
mcpToolName: t.name
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
} catch (error) {
|
|
293
|
-
debugLogger.warn("Failed to discover tools for MCP server", { server: server.name, error: String(error) });
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
set((state) => ({
|
|
297
|
-
tools: [...state.tools.filter((t) => !t.mcpServerId), ...collected]
|
|
298
|
-
}));
|
|
299
|
-
debugLogger.info("MCP server tools loaded", { count: collected.length });
|
|
300
|
-
}
|
|
301
|
-
}));
|
|
302
|
-
|
|
303
|
-
export {
|
|
304
|
-
listMcpServers,
|
|
305
|
-
addMcpServer,
|
|
306
|
-
updateMcpServer,
|
|
307
|
-
deleteMcpServer,
|
|
308
|
-
discoverMcpTools,
|
|
309
|
-
useMCPToolsStore
|
|
310
|
-
};
|
|
311
|
-
//# sourceMappingURL=chunk-LNGF2XAZ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/store/mcpToolsStore.ts","../src/services/mcp/mcpServersService.ts"],"sourcesContent":["/*\n © 2025 Burtson Labs — Licensed under Business Source License 1.1\n https://burtson.ai/license\n\n This file is protected intellectual property.\n Do NOT use in commercial software, prompts, AI training data, or derivative works without a valid commercial license.\n\n 🚫 AI NOTICE: This file contains visible and invisible watermarks.\n ⚖️ VIOLATION NOTICE: Removing, modifying, or obscuring these watermarks is a license violation.\n 🔒 LICENSE TERMINATION: Upon license termination, ALL forks, copies, and derivatives must be permanently deleted.\n 📋 AUDIT TRAIL: File usage is logged and monitored for compliance verification.\n*/\n\n// Bandit Engine Watermark: BL-WM-BF8A-82BFF7\nconst __banditFingerprint_store_mcpToolsStorets = 'BL-FP-414506-12AF';\nconst __auditTrail_store_mcpToolsStorets = 'BL-AU-MGOIKVW4-PIWV';\n// File: mcpToolsStore.ts | Path: src/store/mcpToolsStore.ts | Hash: bf8a12af\n\nimport { create } from \"zustand\";\nimport indexedDBService from \"../services/indexedDB/indexedDBService\";\nimport { debugLogger } from \"../services/logging/debugLogger\";\nimport { listMcpServers, discoverMcpTools } from \"../services/mcp/mcpServersService\";\n\n// Sanitize an MCP tool into a valid, namespaced function name for the model.\nconst sanitizeMcpToolName = (raw: string): string =>\n raw.replace(/[^a-zA-Z0-9_]/g, \"_\").replace(/_+/g, \"_\").replace(/^_|_$/g, \"\").slice(0, 60);\n\nexport interface MCPTool {\n id: string;\n name: string;\n description: string;\n enabled: boolean;\n type: \"function\";\n function: {\n name: string;\n description: string;\n parameters: {\n type: \"object\";\n properties: Record<string, unknown>;\n required: string[];\n };\n };\n endpoint?: string; // API endpoint for gateway calls\n method?: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\";\n isBuiltIn?: boolean;\n // Set when this tool comes from a user-connected MCP server. Such tools are\n // invoked through POST /mcp/invoke (not a fixed endpoint) and are never\n // persisted to IndexedDB — they're re-discovered from the gateway each load.\n mcpServerId?: string;\n mcpToolName?: string; // the tool's real name on the MCP server\n}\n\ninterface MCPToolsStore {\n tools: MCPTool[];\n isLoaded: boolean;\n addTool: (tool: Omit<MCPTool, \"id\">) => void;\n updateTool: (id: string, updates: Partial<MCPTool>) => void;\n deleteTool: (id: string) => void;\n toggleTool: (id: string) => void;\n loadTools: () => Promise<void>;\n saveTools: () => Promise<void>;\n getEnabledTools: () => MCPTool[];\n loadMcpServerTools: () => Promise<void>;\n}\n\n// Built-in controller-backed tools\nconst healthCheckTool: MCPTool = {\n id: \"health-check\",\n name: \"check_gateway_health\",\n description: \"Check the health status of the gateway API service\",\n enabled: true,\n type: \"function\",\n function: {\n name: \"check_gateway_health\",\n description: \"Check the health status of the gateway API service\",\n parameters: {\n type: \"object\",\n properties: {},\n required: []\n }\n },\n endpoint: \"/mcp/health\",\n method: \"GET\",\n isBuiltIn: true\n};\n\nconst webSearchTool: MCPTool = {\n id: \"web-search\",\n name: \"web_search\",\n description: \"Search the web for current information, documentation, and facts\",\n enabled: true,\n type: \"function\",\n function: {\n name: \"web_search\",\n description: \"Search the web and return ranked results with snippets (and an optional summarized answer). Use for current events, documentation, libraries, error messages, and factual lookups.\",\n parameters: {\n type: \"object\",\n properties: {\n query: { type: \"string\", description: \"The search query — natural language or keywords\" },\n count: { type: \"number\", description: \"Number of results to return (1-10, default 5)\" },\n include_answer: { type: \"boolean\", description: \"Include a short summarized answer when available\" }\n },\n required: [\"query\"]\n }\n },\n endpoint: \"/mcp/web-search\",\n method: \"GET\",\n isBuiltIn: true\n};\n\nconst webFetchTool: MCPTool = {\n id: \"web-fetch\",\n name: \"web_fetch\",\n description: \"Fetch the text content of a specific URL\",\n enabled: true,\n type: \"function\",\n function: {\n name: \"web_fetch\",\n description: \"Fetch a single public URL and return its trimmed text content. Use when you already have a specific link you need to read.\",\n parameters: {\n type: \"object\",\n properties: {\n url: { type: \"string\", description: \"Absolute http(s) URL to fetch\" }\n },\n required: [\"url\"]\n }\n },\n endpoint: \"/mcp/web-fetch\",\n method: \"GET\",\n isBuiltIn: true\n};\n\n// Image generation runs on Burtson's own GPU (the Image Studio backend behind\n// the gateway) — never a third-party image API. The gateway forwards the\n// user's token to Anton, whose admin/partner gate decides who may take the\n// GPU; everyone else gets a clear \"limited to admin and partner accounts\"\n// message. Cold starts can take a couple of minutes.\nconst imageGenerationTool: MCPTool = {\n id: \"image-generation\",\n name: \"image_generation\",\n description: \"Generate an image from a text prompt on the Burtson Labs GPU\",\n enabled: true,\n type: \"function\",\n function: {\n name: \"image_generation\",\n description: \"Generate an image from a text prompt on the Burtson Labs GPU\",\n parameters: {\n type: \"object\",\n properties: {\n prompt: { type: \"string\", description: \"Text description of the image to generate\" },\n size: { type: \"string\", enum: [\"1024x1024\", \"1344x768\", \"768x1344\"], description: \"Canvas: square, landscape, or portrait\" }\n },\n required: [\"prompt\"]\n }\n },\n endpoint: \"/mcp/generate-image\",\n method: \"POST\",\n isBuiltIn: true\n};\n\n// Create a downloadable file for the user (stored ~1 hour at a gateway URL).\nconst createFileTool: MCPTool = {\n id: \"create-file\",\n name: \"create_file\",\n description: \"Create a downloadable file for the user (md, txt, csv, json, html, docx, pptx, pdf). Returns a temporary (~1 hour) download link.\",\n enabled: true,\n type: \"function\",\n function: {\n name: \"create_file\",\n description:\n \"Generate a file the user can download. For docx/pptx write well-structured Markdown (headings, lists, tables; use '## ' headings to start each slide). For pdf, prefer complete HTML with inline CSS (branded proposals, print layouts) — Chromium renders it without browser headers/footers; Markdown also works. Returns a short-lived (~1 hour) download URL — tell the user it expires.\",\n parameters: {\n type: \"object\",\n properties: {\n content: { type: \"string\", description: \"The file content (HTML preferred for pdf; Markdown for docx/pptx/pdf; raw text for others).\" },\n filename: { type: \"string\", description: \"Desired filename, e.g. 'report.pdf' or 'notes.md'.\" },\n format: {\n type: \"string\",\n enum: [\"md\", \"txt\", \"csv\", \"json\", \"html\", \"xml\", \"yaml\", \"docx\", \"pptx\", \"pdf\"],\n description: \"File format. Defaults to md.\",\n },\n },\n required: [\"content\", \"format\"],\n },\n },\n endpoint: \"/mcp/create-file\",\n method: \"POST\",\n isBuiltIn: true,\n};\n\nconst defaultTools: MCPTool[] = [healthCheckTool, webSearchTool, webFetchTool, imageGenerationTool, createFileTool];\n\nexport const useMCPToolsStore = create<MCPToolsStore>((set, get) => ({\n tools: defaultTools,\n isLoaded: false,\n \n addTool: (toolData) => {\n const newTool: MCPTool = {\n ...toolData,\n id: `tool-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,\n };\n set((state) => ({\n tools: [...state.tools, newTool],\n }));\n get().saveTools();\n },\n \n updateTool: (id, updates) => {\n set((state) => ({\n tools: state.tools.map((tool) =>\n tool.id === id ? { ...tool, ...updates } : tool\n ),\n }));\n get().saveTools();\n },\n \n deleteTool: (id) => {\n set((state) => ({\n tools: state.tools.filter((tool) => tool.id !== id || tool.isBuiltIn),\n }));\n get().saveTools();\n },\n \n toggleTool: (id) => {\n set((state) => ({\n tools: state.tools.map((tool) =>\n tool.id === id ? { ...tool, enabled: !tool.enabled } : tool\n ),\n }));\n get().saveTools();\n },\n \n getEnabledTools: () => {\n return get().tools.filter((tool) => tool.enabled);\n },\n \n loadTools: async () => {\n try {\n const storeConfigs = [{ name: \"config\", keyPath: \"id\" }];\n const data = await indexedDBService.get<{ tools?: unknown }>(\"banditConfig\", 1, \"config\", \"mcpTools\", storeConfigs);\n \n if (data?.tools && Array.isArray(data.tools)) {\n // Merge saved tools with built-in tools, ensuring built-ins always use default definition\n const savedTools = data.tools as MCPTool[];\n const builtInIds = defaultTools.map(t => t.id);\n const customTools = savedTools.filter(\n (tool) => !tool.isBuiltIn && !builtInIds.includes(tool.id)\n );\n\n set({\n tools: [...defaultTools, ...customTools],\n isLoaded: true\n });\n debugLogger.info(\"MCP tools loaded from IndexedDB\", { \n totalTools: defaultTools.length + customTools.length,\n builtInTools: defaultTools.length,\n customTools: customTools.length\n });\n } else {\n // First time, save defaults\n set({ isLoaded: true });\n await get().saveTools();\n debugLogger.info(\"Default MCP tools initialized\");\n }\n } catch (error) {\n debugLogger.error(\"Failed to load MCP tools from IndexedDB\", { error });\n set({ isLoaded: true }); // Mark as loaded even if failed, so UI can render\n }\n },\n \n saveTools: async () => {\n try {\n const { tools } = get();\n const storeConfigs = [{ name: \"config\", keyPath: \"id\" }];\n \n // Persist only user-defined custom tools — never built-ins or the dynamic\n // tools discovered from MCP servers (those are re-fetched from the gateway).\n const customTools = tools.filter((tool) => !tool.isBuiltIn && !tool.mcpServerId);\n\n await indexedDBService.put(\"banditConfig\", 1, \"config\", {\n id: \"mcpTools\",\n tools: customTools,\n }, storeConfigs);\n\n debugLogger.debug(\"MCP tools saved to IndexedDB\", { toolCount: customTools.length });\n } catch (error) {\n debugLogger.error(\"Failed to save MCP tools to IndexedDB\", { error });\n }\n },\n\n // Discover the user's connected MCP servers' tools from the gateway and merge\n // them into the tool list (so the model can call them). Replaces any prior\n // MCP-server tools; best-effort — a single unreachable server is skipped.\n loadMcpServerTools: async () => {\n let servers;\n try {\n servers = await listMcpServers();\n } catch (error) {\n debugLogger.warn(\"Could not list MCP servers\", { error: String(error) });\n return;\n }\n\n const collected: MCPTool[] = [];\n for (const server of servers.filter((s) => s.enabled)) {\n try {\n const { tools } = await discoverMcpTools(server.id);\n for (const t of tools) {\n const fnName = sanitizeMcpToolName(`mcp_${server.name}_${t.name}`);\n const schema =\n t.inputSchema && typeof t.inputSchema === \"object\" && (t.inputSchema as { type?: string }).type === \"object\"\n ? (t.inputSchema as MCPTool[\"function\"][\"parameters\"])\n : { type: \"object\" as const, properties: {}, required: [] };\n collected.push({\n id: `mcp-${server.id}-${t.name}`,\n name: fnName,\n description: t.description || `${t.name} (via ${server.name})`,\n enabled: true,\n type: \"function\",\n function: {\n name: fnName,\n description: t.description || `${t.name} — provided by the ${server.name} MCP server.`,\n parameters: schema,\n },\n mcpServerId: server.id,\n mcpToolName: t.name,\n });\n }\n } catch (error) {\n debugLogger.warn(\"Failed to discover tools for MCP server\", { server: server.name, error: String(error) });\n }\n }\n\n set((state) => ({\n tools: [...state.tools.filter((t) => !t.mcpServerId), ...collected],\n }));\n debugLogger.info(\"MCP server tools loaded\", { count: collected.length });\n },\n}));\n","import { usePackageSettingsStore } from \"../../store/packageSettingsStore\";\nimport { authenticationService } from \"../auth/authenticationService\";\n\n/**\n * Client for the gateway's MCP host (phase 1 backend at /api/mcp/servers + /invoke).\n * Lets users connect their own remote MCP servers; the gateway holds the configs\n * and proxies discovery/invocation. Mirrors mcpService's gateway-base + bearer\n * conventions (gatewayApiUrl already ends in /api, so paths start with /mcp/...).\n */\n\nexport interface McpServer {\n id: string;\n name: string;\n url: string;\n authType: string;\n hasAuth: boolean;\n headerName?: string | null;\n enabled: boolean;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface McpServerInput {\n name: string;\n url: string;\n authType?: \"none\" | \"bearer\" | \"header\";\n authValue?: string;\n headerName?: string;\n enabled?: boolean;\n}\n\nexport interface McpDiscoveredTool {\n name: string;\n description?: string;\n inputSchema?: Record<string, unknown>;\n}\n\nconst gatewayBase = (): string => {\n const settings = usePackageSettingsStore.getState().settings;\n const url = settings?.gatewayApiUrl?.replace(/\\/$/, \"\");\n if (!url) throw new Error(\"Gateway API is not configured.\");\n return url;\n};\n\nconst authHeaders = (): Record<string, string> => {\n const headers: Record<string, string> = { \"Content-Type\": \"application/json\" };\n const token = authenticationService.getToken();\n if (token) headers[\"Authorization\"] = `Bearer ${token}`;\n return headers;\n};\n\nconst parse = async (res: Response) => {\n const text = await res.text();\n const body = text ? JSON.parse(text) : null;\n if (!res.ok) {\n const message =\n (body && typeof body === \"object\" && (body.error || body.message)) ||\n `Request failed (${res.status})`;\n throw new Error(String(message));\n }\n return body;\n};\n\nexport const listMcpServers = async (): Promise<McpServer[]> =>\n parse(await fetch(`${gatewayBase()}/mcp/servers`, { headers: authHeaders() }));\n\nexport const addMcpServer = async (input: McpServerInput): Promise<McpServer> =>\n parse(\n await fetch(`${gatewayBase()}/mcp/servers`, {\n method: \"POST\",\n headers: authHeaders(),\n body: JSON.stringify(input),\n }),\n );\n\nexport const updateMcpServer = async (\n id: string,\n input: Partial<McpServerInput>,\n): Promise<McpServer> =>\n parse(\n await fetch(`${gatewayBase()}/mcp/servers/${encodeURIComponent(id)}`, {\n method: \"PUT\",\n headers: authHeaders(),\n body: JSON.stringify(input),\n }),\n );\n\nexport const deleteMcpServer = async (id: string): Promise<void> => {\n const res = await fetch(`${gatewayBase()}/mcp/servers/${encodeURIComponent(id)}`, {\n method: \"DELETE\",\n headers: authHeaders(),\n });\n if (!res.ok && res.status !== 204) {\n throw new Error(`Could not remove the server (${res.status}).`);\n }\n};\n\nexport const discoverMcpTools = async (\n id: string,\n): Promise<{ serverId: string; server: string; tools: McpDiscoveredTool[] }> =>\n parse(await fetch(`${gatewayBase()}/mcp/servers/${encodeURIComponent(id)}/tools`, { headers: authHeaders() }));\n"],"mappings":";;;;;;;;;;;;AAkBA,SAAS,cAAc;;;ACmBvB,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