@flexkit/studio 0.2.9 → 0.2.10

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 (40) hide show
  1. package/dist/{chat-page-FLCLBZUX.js → chat-page-N2PGTH56.js} +3 -3
  2. package/dist/{chat-page-FLCLBZUX.js.map → chat-page-N2PGTH56.js.map} +1 -1
  3. package/dist/{chunk-3OAEG7AE.js → chunk-6SAZGEAA.js} +2 -2
  4. package/dist/{chunk-3OAEG7AE.js.map → chunk-6SAZGEAA.js.map} +1 -1
  5. package/dist/{chunk-VARGD74X.js → chunk-AMEYKXZV.js} +2 -2
  6. package/dist/{chunk-VARGD74X.js.map → chunk-AMEYKXZV.js.map} +1 -1
  7. package/dist/{chunk-TK4UYLCV.js → chunk-HZJNNJOK.js} +2 -2
  8. package/dist/{chunk-TK4UYLCV.js.map → chunk-HZJNNJOK.js.map} +1 -1
  9. package/dist/{chunk-753V3IWO.js → chunk-IPLOSXZS.js} +3 -3
  10. package/dist/{chunk-753V3IWO.js.map → chunk-IPLOSXZS.js.map} +1 -1
  11. package/dist/{chunk-Z5TZVTX3.js → chunk-L66FPBO7.js} +7 -7
  12. package/dist/chunk-L66FPBO7.js.map +1 -0
  13. package/dist/{chunk-S5I2UQ6Y.js → chunk-RXP6EQNE.js} +2 -2
  14. package/dist/{chunk-S5I2UQ6Y.js.map → chunk-RXP6EQNE.js.map} +1 -1
  15. package/dist/{chunk-CMZV7EPC.js → chunk-SV5KK5K6.js} +3 -3
  16. package/dist/{chunk-CMZV7EPC.js.map → chunk-SV5KK5K6.js.map} +1 -1
  17. package/dist/{chunk-UUC4PXUB.js → chunk-YLZV43AR.js} +3 -3
  18. package/dist/{chunk-UUC4PXUB.js.map → chunk-YLZV43AR.js.map} +1 -1
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.js +1 -1
  21. package/dist/{list-37T3A4P7.js → list-AJ76FKMO.js} +2 -2
  22. package/dist/{list-37T3A4P7.js.map → list-AJ76FKMO.js.map} +1 -1
  23. package/dist/{pages-R35VNLN5.js → pages-LZKWC2H3.js} +3 -3
  24. package/dist/{pages-R35VNLN5.js.map → pages-LZKWC2H3.js.map} +1 -1
  25. package/dist/{plugin-pages-FTCCUJBD.js → plugin-pages-YJFH66UO.js} +2 -2
  26. package/dist/{plugin-pages-FTCCUJBD.js.map → plugin-pages-YJFH66UO.js.map} +1 -1
  27. package/dist/{root-TKWXADN7.js → root-2UU3C6EP.js} +3 -3
  28. package/dist/{root-TKWXADN7.js.map → root-2UU3C6EP.js.map} +1 -1
  29. package/dist/{root-4YLQNL62.js → root-APTYXHHX.js} +2 -2
  30. package/dist/{root-4YLQNL62.js.map → root-APTYXHHX.js.map} +1 -1
  31. package/dist/{root-E6BD5WNQ.js → root-GD6WNTP5.js} +3 -3
  32. package/dist/{root-E6BD5WNQ.js.map → root-GD6WNTP5.js.map} +1 -1
  33. package/dist/{root-OBXJWAZN.js → root-VJPSB2DG.js} +2 -2
  34. package/dist/{root-OBXJWAZN.js.map → root-VJPSB2DG.js.map} +1 -1
  35. package/dist/{search-YS3HRU2A.js → search-5X4N4M3X.js} +2 -2
  36. package/dist/{search-YS3HRU2A.js.map → search-5X4N4M3X.js.map} +1 -1
  37. package/dist/{skills-pages-4UQRSKQS.js → skills-pages-V4BILOOI.js} +2 -2
  38. package/dist/{skills-pages-4UQRSKQS.js.map → skills-pages-V4BILOOI.js.map} +1 -1
  39. package/package.json +3 -3
  40. package/dist/chunk-Z5TZVTX3.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/apps/ai/agent/chat-list.tsx"],"names":["useAgentBasePath","location","useLocation","marker","index","useDebouncedValue","value","delayMs","debounced","setDebounced","useState","useEffect","timeout","getChatGroupLabel","chat","timestamp","now","startOfToday","groupChats","chats","groups","label","group","candidate","ChatListItem","active","api","onChanged","onDeleted","onOpen","dialog","setDialog","title","setTitle","isMutating","startMutation","useTransition","handleRename","handleDelete","jsxs","jsx","DropdownMenu","DropdownMenuTrigger","Button","MoreHorizontalIcon","DropdownMenuContent","DropdownMenuItem","PencilIcon","Trash2Icon","Dialog","open","DialogContent","DialogHeader","DialogTitle","Input","event","DialogFooter","SearchResults","projectId","query","data","isLoading","useSWR","paths","fetcher","LoaderCircle","result","AgentChatsSection","useProjectApi","navigate","useNavigate","globalMutate","useSWRConfig","activeChatId","mutate","setSize","size","useSWRInfinite","pageIndex","previousPage","activeChatDetail","useMemo","listed","page","generatedTitle","hasMore","chatApi","chatProjectId","openChat","chatId","handleDeleted","MessageSquareIcon"],"mappings":"8kBAwBO,SAASA,EAAAA,EAA2B,CACzC,IAAMC,CAAAA,CAAWC,WAAAA,EAAY,CACvBC,CAAAA,CAAS,QAAA,CACTC,CAAAA,CAAQH,CAAAA,CAAS,QAAA,CAAS,OAAA,CAAQE,CAAM,CAAA,CAE9C,OAAIC,CAAAA,GAAU,EAAA,CACL,CAAA,EAAGH,CAAAA,CAAS,SAAS,OAAA,CAAQ,KAAA,CAAO,EAAE,CAAC,CAAA,MAAA,CAAA,CAGzCA,CAAAA,CAAS,QAAA,CAAS,KAAA,CAAM,CAAA,CAAGG,CAAAA,CAAQD,CAAAA,CAAO,MAAM,CACzD,CAEO,SAASE,EAAAA,CAAkBC,CAAAA,CAAeC,CAAAA,CAAyB,CACxE,GAAM,CAACC,CAAAA,CAAWC,CAAY,CAAA,CAAIC,QAAAA,CAASJ,CAAK,CAAA,CAEhD,OAAAK,SAAAA,CAAU,IAAM,CACd,IAAMC,CAAAA,CAAU,MAAA,CAAO,UAAA,CAAW,IAAM,CACtCH,CAAAA,CAAaH,CAAK,EACpB,CAAA,CAAGC,CAAO,CAAA,CAEV,OAAO,IAAM,CACX,MAAA,CAAO,YAAA,CAAaK,CAAO,EAC7B,CACF,CAAA,CAAG,CAACL,CAAAA,CAASD,CAAK,CAAC,CAAA,CAEZE,CACT,CAEA,SAASK,CAAAA,CAAkBC,CAAAA,CAAyB,CAClD,IAAMC,CAAAA,CAAY,IAA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A,CACzCnD,GAAAA,CAAC,MAAA,CAAA,CAAK,QAAA,CAAA,oDAAA,CAAkD,CAAA,CAAA,CAC1D,CAAA,CACE,IAAA,CACH6C,CAAAA,CACC7C,GAAAA,CAACG,CAAAA,CAAA,CAAO,SAAA,CAAU,WAAA,CAAY,IAAA,CAAK,IAAA,CAAK,OAAA,CAAQ,OAAA,CAAQ,OAAA,CAAS,IAAG,CAAQgC,CAAAA,CAAQC,CAAAA,CAAO,CAAC,EAAA,CAAA,CAAG,QAAA,CAAA,WAAA,CAE/F,CAAA,CACE,IAAA,CAAA,CACN,CAAA,CAEJ,CAEJ","file":"chunk-3OAEG7AE.js","sourcesContent":["import type { JSX } from 'react';\nimport { useEffect, useMemo, useState, useTransition } from 'react';\nimport { LoaderCircle, MessageSquareIcon, MoreHorizontalIcon, PencilIcon, Trash2Icon } from 'lucide-react';\nimport { useLocation, useNavigate } from 'react-router-dom';\nimport useSWR, { useSWRConfig } from 'swr';\nimport useSWRInfinite from 'swr/infinite';\nimport {\n Button,\n Dialog,\n DialogContent,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n Input,\n} from '../../../ui';\nimport { fetcher, paths, type ApiClient } from '../api';\nimport { useProjectApi } from '../replay';\nimport type { AgentChat, AgentChatDetail, AgentChatSearchResult, AgentChatsList } from '../types';\n\n/** Returns the absolute route prefix of the agent app (`.../ai/agent`). */\nexport function useAgentBasePath(): string {\n const location = useLocation();\n const marker = '/agent';\n const index = location.pathname.indexOf(marker);\n\n if (index === -1) {\n return `${location.pathname.replace(/\\/$/, '')}/agent`;\n }\n\n return location.pathname.slice(0, index + marker.length);\n}\n\nexport function useDebouncedValue(value: string, delayMs: number): string {\n const [debounced, setDebounced] = useState(value);\n\n useEffect(() => {\n const timeout = window.setTimeout(() => {\n setDebounced(value);\n }, delayMs);\n\n return () => {\n window.clearTimeout(timeout);\n };\n }, [delayMs, value]);\n\n return debounced;\n}\n\nfunction getChatGroupLabel(chat: AgentChat): string {\n const timestamp = new Date(chat.lastMessageAt ?? chat.updatedAt).getTime();\n const now = new Date();\n const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();\n\n if (timestamp >= startOfToday) {\n return 'Today';\n }\n\n if (timestamp >= startOfToday - 86_400_000) {\n return 'Yesterday';\n }\n\n if (timestamp >= startOfToday - 7 * 86_400_000) {\n return 'Previous 7 days';\n }\n\n return 'Older';\n}\n\nfunction groupChats(chats: AgentChat[]): { chats: AgentChat[]; label: string }[] {\n const groups: { chats: AgentChat[]; label: string }[] = [];\n\n for (const chat of chats) {\n const label = getChatGroupLabel(chat);\n const group = groups.find((candidate) => candidate.label === label);\n\n if (group) {\n group.chats.push(chat);\n } else {\n groups.push({ chats: [chat], label });\n }\n }\n\n return groups;\n}\n\nfunction ChatListItem({\n active,\n api,\n chat,\n onChanged,\n onDeleted,\n onOpen,\n}: {\n active: boolean;\n api: ApiClient;\n chat: AgentChat;\n onChanged: () => void;\n onDeleted: () => void;\n onOpen: () => void;\n}): JSX.Element {\n const [dialog, setDialog] = useState<'rename' | 'delete' | null>(null);\n const [title, setTitle] = useState(chat.title ?? '');\n const [isMutating, startMutation] = useTransition();\n const label = chat.title?.trim() || 'New chat';\n\n function handleRename(): void {\n startMutation(async () => {\n await api.renameAgentChat(chat.id, title.trim());\n setDialog(null);\n onChanged();\n });\n }\n\n function handleDelete(): void {\n startMutation(async () => {\n await api.deleteAgentChat(chat.id);\n setDialog(null);\n onDeleted();\n });\n }\n\n return (\n <div\n className={`fk:group/chat fk:flex fk:items-center fk:gap-1 fk:rounded-md fk:pr-1 ${\n active ? 'fk:bg-sidebar-accent' : 'fk:hover:bg-accent/60'\n } fk:corner-squircle`}\n >\n <button\n className=\"fk:min-w-0 fk:flex-1 fk:truncate fk:px-2 fk:py-1.5 fk:text-left fk:text-sm\"\n title={label}\n type=\"button\"\n onClick={onOpen}\n >\n {label}\n </button>\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n className=\"fk:size-6 fk:shrink-0 fk:opacity-0 fk:group-hover/chat:opacity-100 fk:data-[state=open]:opacity-100\"\n size=\"icon\"\n variant=\"ghost\"\n >\n <MoreHorizontalIcon className=\"fk:size-4\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"start\">\n <DropdownMenuItem\n onClick={() => {\n setTitle(chat.title ?? '');\n setDialog('rename');\n }}\n >\n <PencilIcon className=\"fk:size-4\" />\n Rename\n </DropdownMenuItem>\n <DropdownMenuItem className=\"fk:text-destructive\" onClick={() => setDialog('delete')}>\n <Trash2Icon className=\"fk:size-4\" />\n Delete\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n <Dialog open={dialog === 'rename'} onOpenChange={(open) => setDialog(open ? 'rename' : null)}>\n <DialogContent className=\"fk:max-w-sm\">\n <DialogHeader>\n <DialogTitle>Rename chat</DialogTitle>\n </DialogHeader>\n <Input value={title} onChange={(event) => setTitle(event.target.value)} placeholder=\"Chat title\" />\n <DialogFooter>\n <Button disabled={isMutating || !title.trim()} size=\"sm\" onClick={handleRename}>\n {isMutating ? 'Saving...' : 'Save'}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n <Dialog open={dialog === 'delete'} onOpenChange={(open) => setDialog(open ? 'delete' : null)}>\n <DialogContent className=\"fk:max-w-sm\">\n <DialogHeader>\n <DialogTitle>Delete chat?</DialogTitle>\n </DialogHeader>\n <p className=\"fk:text-sm fk:text-muted-foreground\">\n &ldquo;{label}&rdquo; and its messages will be permanently deleted.\n </p>\n <DialogFooter>\n <Button disabled={isMutating} size=\"sm\" variant=\"destructive\" onClick={handleDelete}>\n {isMutating ? 'Deleting...' : 'Delete'}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </div>\n );\n}\n\nfunction SearchResults({\n onOpen,\n projectId,\n query,\n}: {\n onOpen: (_chatId: string) => void;\n projectId: string;\n query: string;\n}): JSX.Element {\n const { data, isLoading } = useSWR<{ results: AgentChatSearchResult[] }>(\n paths(projectId).agentChatSearch(query),\n fetcher,\n { keepPreviousData: true }\n );\n\n if (isLoading && !data) {\n return (\n <div className=\"fk:flex fk:items-center fk:gap-2 fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground\">\n <LoaderCircle className=\"fk:size-3.5 fk:animate-spin\" />\n Searching...\n </div>\n );\n }\n\n if (!data?.results.length) {\n return <p className=\"fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground\">No matching chats.</p>;\n }\n\n return (\n <div className=\"fk:space-y-1\">\n {data.results.map((result) => (\n <button\n className=\"fk:block fk:w-full fk:rounded-md fk:px-2 fk:py-1.5 fk:text-left fk:hover:bg-accent/60 fk:corner-squircle\"\n key={result.messageId}\n type=\"button\"\n onClick={() => onOpen(result.chatId)}\n >\n <span className=\"fk:block fk:truncate fk:text-sm\">{result.chatTitle?.trim() || 'New chat'}</span>\n <span className=\"fk:block fk:truncate fk:text-xs fk:text-muted-foreground\">{result.snippet}</span>\n </button>\n ))}\n </div>\n );\n}\n\n/**\n * ChatGPT-style chats section embedded in the AI sidebar: new chat button and\n * the user's recent chats grouped by date with rename/delete. When `query` is\n * set, the recent list is replaced by hybrid keyword + semantic search results.\n * Rendered inside the app layout route, so relative navigation resolves\n * against the app root (`agent`, `agent/chats/:chatId`).\n */\nexport function AgentChatsSection({ query }: { query: string }): JSX.Element | null {\n const { api, projectId } = useProjectApi();\n const navigate = useNavigate();\n const location = useLocation();\n const { mutate: globalMutate } = useSWRConfig();\n const activeChatId = /\\/agent\\/chats\\/([^/]+)/.exec(location.pathname)?.[1];\n const { data, isLoading, mutate, setSize, size } = useSWRInfinite<AgentChatsList>(\n (pageIndex, previousPage: AgentChatsList | null) => {\n if (!projectId || (previousPage && !previousPage.hasMore)) {\n return null;\n }\n\n return paths(projectId).agentChats(pageIndex * 30);\n },\n fetcher,\n { revalidateFirstPage: true }\n );\n const { data: activeChatDetail } = useSWR<AgentChatDetail>(\n projectId && activeChatId ? paths(projectId).agentChat(activeChatId) : null,\n fetcher\n );\n const chats = useMemo(() => {\n const listed = (data ?? []).flatMap((page) => page.chats);\n const generatedTitle = activeChatDetail?.chat.title?.trim();\n\n if (!activeChatId || !generatedTitle) {\n return listed;\n }\n\n return listed.map((chat) => {\n if (chat.id !== activeChatId || chat.title?.trim()) {\n return chat;\n }\n\n return { ...chat, title: generatedTitle };\n });\n }, [activeChatDetail?.chat.title, activeChatId, data]);\n const hasMore = data?.[data.length - 1]?.hasMore ?? false;\n const groups = useMemo(() => groupChats(chats), [chats]);\n\n // Refresh the list when the user lands on a chat (new chats, fresh titles).\n useEffect(() => {\n void mutate();\n }, [activeChatId, mutate]);\n\n if (!projectId || !api) {\n return null;\n }\n\n const chatApi = api;\n const chatProjectId = projectId;\n\n function openChat(chatId: string): void {\n navigate(`agent/chats/${chatId}`);\n }\n\n function handleDeleted(chatId: string): void {\n void mutate();\n\n if (chatId === activeChatId) {\n navigate('agent');\n } else {\n // Drop the cached detail so a re-open does not show stale data.\n void globalMutate(paths(chatProjectId).agentChat(chatId), undefined, { revalidate: false });\n }\n }\n\n return (\n <div className=\"fk:space-y-2\">\n {query ? (\n <SearchResults projectId={chatProjectId} query={query} onOpen={openChat} />\n ) : (\n <div className=\"fk:space-y-3\">\n {groups.map((group) => (\n <div key={group.label}>\n <p className=\"fk:px-2 fk:pb-1 fk:text-xs fk:font-medium fk:text-muted-foreground\">{group.label}</p>\n <div className=\"fk:space-y-0.5\">\n {group.chats.map((chat) => (\n <ChatListItem\n active={chat.id === activeChatId}\n api={chatApi}\n chat={chat}\n key={chat.id}\n onChanged={() => void mutate()}\n onDeleted={() => handleDeleted(chat.id)}\n onOpen={() => openChat(chat.id)}\n />\n ))}\n </div>\n </div>\n ))}\n {isLoading ? (\n <div className=\"fk:flex fk:items-center fk:gap-2 fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground\">\n <LoaderCircle className=\"fk:size-3.5 fk:animate-spin\" />\n Loading recent chats...\n </div>\n ) : null}\n {!isLoading && chats.length === 0 ? (\n <div className=\"fk:flex fk:flex-col fk:items-center fk:gap-2 fk:px-2 fk:py-6 fk:text-center fk:text-xs fk:text-muted-foreground\">\n <MessageSquareIcon className=\"fk:size-5\" />\n <span>No chats yet. Start a conversation with the agent.</span>\n </div>\n ) : null}\n {hasMore ? (\n <Button className=\"fk:w-full\" size=\"sm\" variant=\"ghost\" onClick={() => void setSize(size + 1)}>\n Load more\n </Button>\n ) : null}\n </div>\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/apps/ai/agent/chat-list.tsx"],"names":["useAgentBasePath","location","useLocation","marker","index","useDebouncedValue","value","delayMs","debounced","setDebounced","useState","useEffect","timeout","getChatGroupLabel","chat","timestamp","now","startOfToday","groupChats","chats","groups","label","group","candidate","ChatListItem","active","api","onChanged","onDeleted","onOpen","dialog","setDialog","title","setTitle","isMutating","startMutation","useTransition","handleRename","handleDelete","jsxs","jsx","DropdownMenu","DropdownMenuTrigger","Button","MoreHorizontalIcon","DropdownMenuContent","DropdownMenuItem","PencilIcon","Trash2Icon","Dialog","open","DialogContent","DialogHeader","DialogTitle","Input","event","DialogFooter","SearchResults","projectId","query","data","isLoading","useSWR","paths","fetcher","LoaderCircle","result","AgentChatsSection","useProjectApi","navigate","useNavigate","globalMutate","useSWRConfig","activeChatId","mutate","setSize","size","useSWRInfinite","pageIndex","previousPage","activeChatDetail","useMemo","listed","page","generatedTitle","hasMore","chatApi","chatProjectId","openChat","chatId","handleDeleted","MessageSquareIcon"],"mappings":"8kBAwBO,SAASA,EAAAA,EAA2B,CACzC,IAAMC,CAAAA,CAAWC,WAAAA,EAAY,CACvBC,CAAAA,CAAS,QAAA,CACTC,CAAAA,CAAQH,CAAAA,CAAS,QAAA,CAAS,OAAA,CAAQE,CAAM,CAAA,CAE9C,OAAIC,CAAAA,GAAU,EAAA,CACL,CAAA,EAAGH,CAAAA,CAAS,SAAS,OAAA,CAAQ,KAAA,CA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,CAAAA,CAAK,EAAE,CAAA,CACtC,MAAA,CAAQ,IAAM0E,CAAAA,CAAS1E,CAAAA,CAAK,EAAE,CAAA,CAAA,CAHzBA,CAAAA,CAAK,EAIZ,CACD,CAAA,CACH,CAAA,CAAA,CAAA,CAdQQ,CAAAA,CAAM,KAehB,CACD,CAAA,CACAuC,GAAAA,CACCtB,IAAAA,CAAC,KAAA,CAAA,CAAI,SAAA,CAAU,sFAAA,CACb,QAAA,CAAA,CAAAC,GAAAA,CAACyB,YAAAA,CAAA,CAAa,SAAA,CAAU,6BAAA,CAA8B,CAAA,CAAE,yBAAA,CAAA,CAE1D,CAAA,CACE,IAAA,CACH,CAACJ,GAAAA,EAAa1C,CAAAA,CAAM,MAAA,GAAW,CAAA,CAC9BoB,IAAAA,CAAC,KAAA,CAAA,CAAI,SAAA,CAAU,iHAAA,CACb,QAAA,CAAA,CAAAC,GAAAA,CAACmD,iBAAAA,CAAA,CAAkB,SAAA,CAAU,WAAA,CAAY,CAAA,CACzCnD,GAAAA,CAAC,MAAA,CAAA,CAAK,QAAA,CAAA,oDAAA,CAAkD,CAAA,CAAA,CAC1D,CAAA,CACE,IAAA,CACH6C,CAAAA,CACC7C,GAAAA,CAACG,CAAAA,CAAA,CAAO,SAAA,CAAU,WAAA,CAAY,IAAA,CAAK,IAAA,CAAK,OAAA,CAAQ,OAAA,CAAQ,OAAA,CAAS,IAAG,CAAQgC,CAAAA,CAAQC,CAAAA,CAAO,CAAC,EAAA,CAAA,CAAG,QAAA,CAAA,WAAA,CAE/F,CAAA,CACE,IAAA,CAAA,CACN,CAAA,CAEJ,CAEJ","file":"chunk-6SAZGEAA.js","sourcesContent":["import type { JSX } from 'react';\nimport { useEffect, useMemo, useState, useTransition } from 'react';\nimport { LoaderCircle, MessageSquareIcon, MoreHorizontalIcon, PencilIcon, Trash2Icon } from 'lucide-react';\nimport { useLocation, useNavigate } from 'react-router-dom';\nimport useSWR, { useSWRConfig } from 'swr';\nimport useSWRInfinite from 'swr/infinite';\nimport {\n Button,\n Dialog,\n DialogContent,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n Input,\n} from '../../../ui';\nimport { fetcher, paths, type ApiClient } from '../api';\nimport { useProjectApi } from '../replay';\nimport type { AgentChat, AgentChatDetail, AgentChatSearchResult, AgentChatsList } from '../types';\n\n/** Returns the absolute route prefix of the agent app (`.../ai/agent`). */\nexport function useAgentBasePath(): string {\n const location = useLocation();\n const marker = '/agent';\n const index = location.pathname.indexOf(marker);\n\n if (index === -1) {\n return `${location.pathname.replace(/\\/$/, '')}/agent`;\n }\n\n return location.pathname.slice(0, index + marker.length);\n}\n\nexport function useDebouncedValue(value: string, delayMs: number): string {\n const [debounced, setDebounced] = useState(value);\n\n useEffect(() => {\n const timeout = window.setTimeout(() => {\n setDebounced(value);\n }, delayMs);\n\n return () => {\n window.clearTimeout(timeout);\n };\n }, [delayMs, value]);\n\n return debounced;\n}\n\nfunction getChatGroupLabel(chat: AgentChat): string {\n const timestamp = new Date(chat.lastMessageAt ?? chat.updatedAt).getTime();\n const now = new Date();\n const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();\n\n if (timestamp >= startOfToday) {\n return 'Today';\n }\n\n if (timestamp >= startOfToday - 86_400_000) {\n return 'Yesterday';\n }\n\n if (timestamp >= startOfToday - 7 * 86_400_000) {\n return 'Previous 7 days';\n }\n\n return 'Older';\n}\n\nfunction groupChats(chats: AgentChat[]): { chats: AgentChat[]; label: string }[] {\n const groups: { chats: AgentChat[]; label: string }[] = [];\n\n for (const chat of chats) {\n const label = getChatGroupLabel(chat);\n const group = groups.find((candidate) => candidate.label === label);\n\n if (group) {\n group.chats.push(chat);\n } else {\n groups.push({ chats: [chat], label });\n }\n }\n\n return groups;\n}\n\nfunction ChatListItem({\n active,\n api,\n chat,\n onChanged,\n onDeleted,\n onOpen,\n}: {\n active: boolean;\n api: ApiClient;\n chat: AgentChat;\n onChanged: () => void;\n onDeleted: () => void;\n onOpen: () => void;\n}): JSX.Element {\n const [dialog, setDialog] = useState<'rename' | 'delete' | null>(null);\n const [title, setTitle] = useState(chat.title ?? '');\n const [isMutating, startMutation] = useTransition();\n const label = chat.title?.trim() || 'New chat';\n\n function handleRename(): void {\n startMutation(async () => {\n await api.renameAgentChat(chat.id, title.trim());\n setDialog(null);\n onChanged();\n });\n }\n\n function handleDelete(): void {\n startMutation(async () => {\n await api.deleteAgentChat(chat.id);\n setDialog(null);\n onDeleted();\n });\n }\n\n return (\n <div\n className={`fk:group/chat fk:flex fk:items-center fk:gap-1 fk:rounded-md fk:pr-1 ${\n active ? 'fk:bg-sidebar-accent' : 'fk:hover:bg-accent/60'\n } fk:corner-squircle`}\n >\n <button\n className=\"fk:min-w-0 fk:flex-1 fk:truncate fk:px-2 fk:py-1.5 fk:text-left fk:text-sm\"\n title={label}\n type=\"button\"\n onClick={onOpen}\n >\n {label}\n </button>\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n className=\"fk:size-6 fk:shrink-0 fk:opacity-0 fk:group-hover/chat:opacity-100 fk:data-[state=open]:opacity-100\"\n size=\"icon\"\n variant=\"ghost\"\n >\n <MoreHorizontalIcon className=\"fk:size-4\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"start\">\n <DropdownMenuItem\n onClick={() => {\n setTitle(chat.title ?? '');\n setDialog('rename');\n }}\n >\n <PencilIcon className=\"fk:size-4\" />\n Rename\n </DropdownMenuItem>\n <DropdownMenuItem className=\"fk:text-destructive\" onClick={() => setDialog('delete')}>\n <Trash2Icon className=\"fk:size-4\" />\n Delete\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n <Dialog open={dialog === 'rename'} onOpenChange={(open) => setDialog(open ? 'rename' : null)}>\n <DialogContent className=\"fk:max-w-sm\">\n <DialogHeader>\n <DialogTitle>Rename chat</DialogTitle>\n </DialogHeader>\n <Input value={title} onChange={(event) => setTitle(event.target.value)} placeholder=\"Chat title\" />\n <DialogFooter>\n <Button disabled={isMutating || !title.trim()} size=\"sm\" onClick={handleRename}>\n {isMutating ? 'Saving...' : 'Save'}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n <Dialog open={dialog === 'delete'} onOpenChange={(open) => setDialog(open ? 'delete' : null)}>\n <DialogContent className=\"fk:max-w-sm\">\n <DialogHeader>\n <DialogTitle>Delete chat?</DialogTitle>\n </DialogHeader>\n <p className=\"fk:text-sm fk:text-muted-foreground\">\n &ldquo;{label}&rdquo; and its messages will be permanently deleted.\n </p>\n <DialogFooter>\n <Button disabled={isMutating} size=\"sm\" variant=\"destructive\" onClick={handleDelete}>\n {isMutating ? 'Deleting...' : 'Delete'}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n </div>\n );\n}\n\nfunction SearchResults({\n onOpen,\n projectId,\n query,\n}: {\n onOpen: (_chatId: string) => void;\n projectId: string;\n query: string;\n}): JSX.Element {\n const { data, isLoading } = useSWR<{ results: AgentChatSearchResult[] }>(\n paths(projectId).agentChatSearch(query),\n fetcher,\n { keepPreviousData: true }\n );\n\n if (isLoading && !data) {\n return (\n <div className=\"fk:flex fk:items-center fk:gap-2 fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground\">\n <LoaderCircle className=\"fk:size-3.5 fk:animate-spin\" />\n Searching...\n </div>\n );\n }\n\n if (!data?.results.length) {\n return <p className=\"fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground\">No matching chats.</p>;\n }\n\n return (\n <div className=\"fk:space-y-1\">\n {data.results.map((result) => (\n <button\n className=\"fk:block fk:w-full fk:rounded-md fk:px-2 fk:py-1.5 fk:text-left fk:hover:bg-accent/60 fk:corner-squircle\"\n key={result.messageId}\n type=\"button\"\n onClick={() => onOpen(result.chatId)}\n >\n <span className=\"fk:block fk:truncate fk:text-sm\">{result.chatTitle?.trim() || 'New chat'}</span>\n <span className=\"fk:block fk:truncate fk:text-xs fk:text-muted-foreground\">{result.snippet}</span>\n </button>\n ))}\n </div>\n );\n}\n\n/**\n * ChatGPT-style chats section embedded in the AI sidebar: new chat button and\n * the user's recent chats grouped by date with rename/delete. When `query` is\n * set, the recent list is replaced by hybrid keyword + semantic search results.\n * Rendered inside the app layout route, so relative navigation resolves\n * against the app root (`agent`, `agent/chats/:chatId`).\n */\nexport function AgentChatsSection({ query }: { query: string }): JSX.Element | null {\n const { api, projectId } = useProjectApi();\n const navigate = useNavigate();\n const location = useLocation();\n const { mutate: globalMutate } = useSWRConfig();\n const activeChatId = /\\/agent\\/chats\\/([^/]+)/.exec(location.pathname)?.[1];\n const { data, isLoading, mutate, setSize, size } = useSWRInfinite<AgentChatsList>(\n (pageIndex, previousPage: AgentChatsList | null) => {\n if (!projectId || (previousPage && !previousPage.hasMore)) {\n return null;\n }\n\n return paths(projectId).agentChats(pageIndex * 30);\n },\n fetcher,\n { revalidateFirstPage: true }\n );\n const { data: activeChatDetail } = useSWR<AgentChatDetail>(\n projectId && activeChatId ? paths(projectId).agentChat(activeChatId) : null,\n fetcher\n );\n const chats = useMemo(() => {\n const listed = (data ?? []).flatMap((page) => page.chats);\n const generatedTitle = activeChatDetail?.chat.title?.trim();\n\n if (!activeChatId || !generatedTitle) {\n return listed;\n }\n\n return listed.map((chat) => {\n if (chat.id !== activeChatId || chat.title?.trim()) {\n return chat;\n }\n\n return { ...chat, title: generatedTitle };\n });\n }, [activeChatDetail?.chat.title, activeChatId, data]);\n const hasMore = data?.[data.length - 1]?.hasMore ?? false;\n const groups = useMemo(() => groupChats(chats), [chats]);\n\n // Refresh the list when the user lands on a chat (new chats, fresh titles).\n useEffect(() => {\n void mutate();\n }, [activeChatId, mutate]);\n\n if (!projectId || !api) {\n return null;\n }\n\n const chatApi = api;\n const chatProjectId = projectId;\n\n function openChat(chatId: string): void {\n navigate(`agent/chats/${chatId}`);\n }\n\n function handleDeleted(chatId: string): void {\n void mutate();\n\n if (chatId === activeChatId) {\n navigate('agent');\n } else {\n // Drop the cached detail so a re-open does not show stale data.\n void globalMutate(paths(chatProjectId).agentChat(chatId), undefined, { revalidate: false });\n }\n }\n\n return (\n <div className=\"fk:space-y-2\">\n {query ? (\n <SearchResults projectId={chatProjectId} query={query} onOpen={openChat} />\n ) : (\n <div className=\"fk:space-y-3\">\n {groups.map((group) => (\n <div key={group.label}>\n <p className=\"fk:px-2 fk:pb-1 fk:text-xs fk:font-medium fk:text-muted-foreground\">{group.label}</p>\n <div className=\"fk:space-y-0.5\">\n {group.chats.map((chat) => (\n <ChatListItem\n active={chat.id === activeChatId}\n api={chatApi}\n chat={chat}\n key={chat.id}\n onChanged={() => void mutate()}\n onDeleted={() => handleDeleted(chat.id)}\n onOpen={() => openChat(chat.id)}\n />\n ))}\n </div>\n </div>\n ))}\n {isLoading ? (\n <div className=\"fk:flex fk:items-center fk:gap-2 fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground\">\n <LoaderCircle className=\"fk:size-3.5 fk:animate-spin\" />\n Loading recent chats...\n </div>\n ) : null}\n {!isLoading && chats.length === 0 ? (\n <div className=\"fk:flex fk:flex-col fk:items-center fk:gap-2 fk:px-2 fk:py-6 fk:text-center fk:text-xs fk:text-muted-foreground\">\n <MessageSquareIcon className=\"fk:size-5\" />\n <span>No chats yet. Start a conversation with the agent.</span>\n </div>\n ) : null}\n {hasMore ? (\n <Button className=\"fk:w-full\" size=\"sm\" variant=\"ghost\" onClick={() => void setSize(size + 1)}>\n Load more\n </Button>\n ) : null}\n </div>\n )}\n </div>\n );\n}\n"]}
@@ -1,2 +1,2 @@
1
- import'./index.css';import {c,e as e$1}from'./chunk-P6BZ4QP7.js';import {f}from'./chunk-CMZV7EPC.js';import {e}from'./chunk-TYDYAOQ7.js';import {useMemo}from'react';import A from'swr';import {find,propEq}from'ramda';function T(n,i){let{scope:c$1}=c(),{currentProject:e$1}=f(),o=useMemo(()=>e$1?.schema??[],[e$1]),a=e$1?.scopes?.find(t=>t.isDefault)?.name??"default",m=i?.commonParams.q?JSON.stringify(i):null,{data:r,error:s,isLoading:y}=A(m,()=>fetch(e(n).search,{headers:{"Content-Type":"application/json"},body:JSON.stringify(i),method:"POST",mode:"cors"}).then(t=>t.json()));return {results:useMemo(()=>E(r?.results??[],n,o,c$1,a)??[],[r,a,n,o,c$1]),error:s,isLoading:y}}function E(n,i,c,e,o){return n?.filter(l=>l?.hits?.length>0).map(l=>{let a=l,m=a.collection.replace(`${i}_`,"").replace(/_\d+$/,""),r=find(propEq(m,"plural"))(c);if(!r)return [];let s=e$1(r)?.name??"",y=r?.name??m;return a.hits.map(({document:u})=>{let t=u[s],b=(t&&typeof t!="string"?t[e]??t[o]:null)??u[s],N=Object.entries(u).reduce((d,[p,f])=>{if(p!==s&&p!=="id"&&p!=="_updatedAt"){let _=typeof f!="string"?f[e]??f[o]:f;d[p]=_;}return d},{});return {_id:u.id,_entityName:y,_entityNamePlural:m,[s]:b,...N}})}).flat()}export{T as a};//# sourceMappingURL=chunk-VARGD74X.js.map
2
- //# sourceMappingURL=chunk-VARGD74X.js.map
1
+ import'./index.css';import {c,e as e$1}from'./chunk-P6BZ4QP7.js';import {f}from'./chunk-SV5KK5K6.js';import {e}from'./chunk-TYDYAOQ7.js';import {useMemo}from'react';import A from'swr';import {find,propEq}from'ramda';function T(n,i){let{scope:c$1}=c(),{currentProject:e$1}=f(),o=useMemo(()=>e$1?.schema??[],[e$1]),a=e$1?.scopes?.find(t=>t.isDefault)?.name??"default",m=i?.commonParams.q?JSON.stringify(i):null,{data:r,error:s,isLoading:y}=A(m,()=>fetch(e(n).search,{headers:{"Content-Type":"application/json"},body:JSON.stringify(i),method:"POST",mode:"cors"}).then(t=>t.json()));return {results:useMemo(()=>E(r?.results??[],n,o,c$1,a)??[],[r,a,n,o,c$1]),error:s,isLoading:y}}function E(n,i,c,e,o){return n?.filter(l=>l?.hits?.length>0).map(l=>{let a=l,m=a.collection.replace(`${i}_`,"").replace(/_\d+$/,""),r=find(propEq(m,"plural"))(c);if(!r)return [];let s=e$1(r)?.name??"",y=r?.name??m;return a.hits.map(({document:u})=>{let t=u[s],b=(t&&typeof t!="string"?t[e]??t[o]:null)??u[s],N=Object.entries(u).reduce((d,[p,f])=>{if(p!==s&&p!=="id"&&p!=="_updatedAt"){let _=typeof f!="string"?f[e]??f[o]:f;d[p]=_;}return d},{});return {_id:u.id,_entityName:y,_entityNamePlural:m,[s]:b,...N}})}).flat()}export{T as a};//# sourceMappingURL=chunk-AMEYKXZV.js.map
2
+ //# sourceMappingURL=chunk-AMEYKXZV.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/use-search.tsx"],"names":["useSearch","projectId","searchRequest","scope","useAppContext","currentProject","useConfig","schema","useMemo","defaultScope","s","swrKey","data","error","isLoading","useSWR","apiPaths","res","mapResults","results","result","item","entityNamePlural","entitySchema","find","propEq","primaryAttributeName","getDisplayAttribute","entityName","document","primaryAttribute","primaryAttributeValue","attributes","acc","key","value","scopedValue"],"mappings":"wNAWO,SAASA,EACdC,CAAAA,CACAC,CAAAA,CACwE,CACxE,GAAM,CAAE,KAAA,CAAAC,GAAM,CAAA,CAAIC,GAAc,CAC1B,CAAE,cAAA,CAAAC,GAAe,CAAA,CAAIC,CAAAA,EAAU,CAC/BC,CAAAA,CAASC,QAAQ,IAAMH,GAAAA,EAAgB,MAAA,EAAU,EAAC,CAAG,CAACA,GAAc,CAAC,EAErEI,CAAAA,CADSJ,GAAAA,EAAgB,MAAA,EACF,IAAA,CAAMK,CAAAA,EAAMA,CAAAA,CAAE,SAAS,CAAA,EAAG,MAAQ,SAAA,CACzDC,CAAAA,CAAST,CAAAA,EAAe,YAAA,CAAa,CAAA,CAAI,IAAA,CAAK,SAAA,CAAUA,CAAa,EAAI,IAAA,CACzE,CAAE,IAAA,CAAAU,CAAAA,CAAM,MAAAC,CAAAA,CAAO,SAAA,CAAAC,CAAU,CAAA,CAAIC,EAAOJ,CAAAA,CAAQ,IAChD,KAAA,CAAMK,CAAAA,CAASf,CAAS,CAAA,C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AAQD,CAAAA,CAGzC,OAAOD,CAAAA,CAAK,KAAK,GAAA,CAAI,CAAC,CAAE,QAAA,CAAAQ,CAAS,CAAA,GAAM,CACrC,IAAMC,EAAmBD,CAAAA,CAASH,CAAoB,CAAA,CAKhDK,CAAAA,CAAAA,CAHJD,GAAoB,OAAOA,CAAAA,EAAqB,QAAA,CAC3CA,CAAAA,CAAiB3B,CAAK,CAAA,EAAK2B,CAAAA,CAAiBrB,CAAY,CAAA,CACzD,IAAA,GACkDoB,CAAAA,CAASH,CAAoB,CAAA,CAC/EM,EAAa,MAAA,CAAO,OAAA,CAAQH,CAAQ,CAAA,CAAE,MAAA,CAC1C,CAACI,CAAAA,CAA0E,CAACC,EAAKC,CAAK,CAAA,GAAM,CAC1F,GAAID,CAAAA,GAAQR,CAAAA,EAAwBQ,CAAAA,GAAQ,IAAA,EAAQA,IAAQ,YAAA,CAAc,CACxE,IAAME,CAAAA,CAAc,OAAOD,CAAAA,EAAU,QAAA,CAAYA,CAAAA,CAAMhC,CAAK,CAAA,EAAKgC,CAAAA,CAAM1B,CAAY,CAAA,CAAK0B,CAAAA,CAExFF,CAAAA,CAAIC,CAAG,CAAA,CAAIE,EACb,CAEA,OAAOH,CACT,CAAA,CACA,EACF,CAAA,CAEA,OAAO,CACL,GAAA,CAAKJ,CAAAA,CAAS,EAAA,CACd,WAAA,CAAaD,CAAAA,CACb,iBAAA,CAAmBN,CAAAA,CACnB,CAACI,CAAoB,EAAGK,CAAAA,CACxB,GAAGC,CACL,CACF,CAAC,CACH,CAAC,CAAA,CACA,MACL","file":"chunk-VARGD74X.js","sourcesContent":["'use client';\n\nimport { useMemo } from 'react';\nimport useSWR from 'swr';\nimport { find, propEq } from 'ramda';\nimport { apiPaths } from './api-paths';\nimport { useAppContext } from './app-context';\nimport { useConfig } from './config/config-context';\nimport { getDisplayAttribute } from './get-display-attribute';\nimport type { Entity, RawResultItem, RawSearchResultItems, SearchRequestProps, SearchResultItem } from './types';\n\nexport function useSearch(\n projectId: string,\n searchRequest: SearchRequestProps | null\n): { results: SearchResultItem[] | []; error: Error; isLoading: boolean } {\n const { scope } = useAppContext();\n const { currentProject } = useConfig();\n const schema = useMemo(() => currentProject?.schema ?? [], [currentProject]);\n const scopes = currentProject?.scopes;\n const defaultScope = scopes?.find((s) => s.isDefault)?.name ?? 'default';\n const swrKey = searchRequest?.commonParams.q ? JSON.stringify(searchRequest) : null;\n const { data, error, isLoading } = useSWR(swrKey, () =>\n fetch(apiPaths(projectId).search, {\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(searchRequest),\n method: 'POST',\n mode: 'cors',\n }).then((res) => res.json() as Promise<{ results: RawSearchResultItems }>)\n );\n const results = useMemo(\n () => mapResults(data?.results ?? [], projectId, schema, scope, defaultScope) ?? [],\n [data, defaultScope, projectId, schema, scope]\n );\n\n return { results, error, isLoading };\n}\n\nfunction mapResults(\n results: RawSearchResultItems | undefined,\n projectId: string,\n schema: Entity[],\n scope: string,\n defaultScope: string\n): SearchResultItem[] | undefined {\n return results\n ?.filter((result) => (result as RawResultItem)?.hits?.length > 0)\n .map((result) => {\n const item = result as RawResultItem;\n const entityNamePlural = item.collection.replace(`${projectId}_`, '').replace(/_\\d+$/, '');\n const entitySchema = find<Entity>(propEq(entityNamePlural, 'plural'))(schema);\n\n if (!entitySchema) {\n return [];\n }\n\n const primaryAttributeName = getDisplayAttribute(entitySchema)?.name ?? '';\n const entityName = entitySchema?.name ?? entityNamePlural;\n\n // iterate over the hits and return an object with the primary attribute value first and then the rest of the attributes.\n return item.hits.map(({ document }) => {\n const primaryAttribute = document[primaryAttributeName];\n const scopedPrimaryAttribute =\n primaryAttribute && typeof primaryAttribute !== 'string'\n ? (primaryAttribute[scope] ?? primaryAttribute[defaultScope])\n : null;\n const primaryAttributeValue = scopedPrimaryAttribute ?? document[primaryAttributeName];\n const attributes = Object.entries(document).reduce(\n (acc: Omit<SearchResultItem, '_id' | '_entityName' | '_entityNamePlural'>, [key, value]) => {\n if (key !== primaryAttributeName && key !== 'id' && key !== '_updatedAt') {\n const scopedValue = typeof value !== 'string' ? (value[scope] ?? value[defaultScope]) : value;\n\n acc[key] = scopedValue;\n }\n\n return acc;\n },\n {}\n );\n\n return {\n _id: document.id,\n _entityName: entityName,\n _entityNamePlural: entityNamePlural,\n [primaryAttributeName]: primaryAttributeValue as string,\n ...attributes,\n };\n });\n })\n .flat();\n}\n"]}
1
+ {"version":3,"sources":["../src/core/use-search.tsx"],"names":["useSearch","projectId","searchRequest","scope","useAppContext","currentProject","useConfig","schema","useMemo","defaultScope","s","swrKey","data","error","isLoading","useSWR","apiPaths","res","mapResults","results","result","item","entityNamePlural","entitySchema","find","propEq","primaryAttributeName","getDisplayAttribute","entityName","document","primaryAttribute","primaryAttributeValue","attributes","acc","key","value","scopedValue"],"mappings":"wNAWO,SAASA,EACdC,CAAAA,CACAC,CAAAA,CACwE,CACxE,GAAM,CAAE,KAAA,CAAAC,GAAM,CAAA,CAAIC,GAAc,CAC1B,CAAE,cAAA,CAAAC,GAAe,CAAA,CAAIC,CAAAA,EAAU,CAC/BC,CAAAA,CAASC,QAAQ,IAAMH,GAAAA,EAAgB,MAAA,EAAU,EAAC,CAAG,CAACA,GAAc,CAAC,EAErEI,CAAAA,CADSJ,GAAAA,EAAgB,MAAA,EACF,IAAA,CAAMK,CAAAA,EAAMA,CAAAA,CAAE,SAAS,CAAA,EAAG,MAAQ,SAAA,CACzDC,CAAAA,CAAST,CAAAA,EAAe,YAAA,CAAa,CAAA,CAAI,IAAA,CAAK,SAAA,CAAUA,CAAa,EAAI,IAAA,CACzE,CAAE,IAAA,CAAAU,CAAAA,CAAM,MAAAC,CAAAA,CAAO,SAAA,CAAAC,CAAU,CAAA,CAAIC,EAAOJ,CAAAA,CAAQ,IAChD,KAAA,CAAMK,CAAAA,CAASf,CAAS,CAAA,CAAE,MAAA,CAAQ,CAChC,QAAS,CAAE,cAAA,CAAgB,kBAAmB,CAAA,CAC9C,IAAA,CAAM,IAAA,CAAK,SAA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AAM,CACrC,IAAMC,EAAmBD,CAAAA,CAASH,CAAoB,CAAA,CAKhDK,CAAAA,CAAAA,CAHJD,GAAoB,OAAOA,CAAAA,EAAqB,QAAA,CAC3CA,CAAAA,CAAiB3B,CAAK,CAAA,EAAK2B,CAAAA,CAAiBrB,CAAY,CAAA,CACzD,IAAA,GACkDoB,CAAAA,CAASH,CAAoB,CAAA,CAC/EM,EAAa,MAAA,CAAO,OAAA,CAAQH,CAAQ,CAAA,CAAE,MAAA,CAC1C,CAACI,CAAAA,CAA0E,CAACC,EAAKC,CAAK,CAAA,GAAM,CAC1F,GAAID,CAAAA,GAAQR,CAAAA,EAAwBQ,CAAAA,GAAQ,IAAA,EAAQA,IAAQ,YAAA,CAAc,CACxE,IAAME,CAAAA,CAAc,OAAOD,CAAAA,EAAU,QAAA,CAAYA,CAAAA,CAAMhC,CAAK,CAAA,EAAKgC,CAAAA,CAAM1B,CAAY,CAAA,CAAK0B,CAAAA,CAExFF,CAAAA,CAAIC,CAAG,CAAA,CAAIE,EACb,CAEA,OAAOH,CACT,CAAA,CACA,EACF,CAAA,CAEA,OAAO,CACL,GAAA,CAAKJ,CAAAA,CAAS,EAAA,CACd,WAAA,CAAaD,CAAAA,CACb,iBAAA,CAAmBN,CAAAA,CACnB,CAACI,CAAoB,EAAGK,CAAAA,CACxB,GAAGC,CACL,CACF,CAAC,CACH,CAAC,CAAA,CACA,MACL","file":"chunk-AMEYKXZV.js","sourcesContent":["'use client';\n\nimport { useMemo } from 'react';\nimport useSWR from 'swr';\nimport { find, propEq } from 'ramda';\nimport { apiPaths } from './api-paths';\nimport { useAppContext } from './app-context';\nimport { useConfig } from './config/config-context';\nimport { getDisplayAttribute } from './get-display-attribute';\nimport type { Entity, RawResultItem, RawSearchResultItems, SearchRequestProps, SearchResultItem } from './types';\n\nexport function useSearch(\n projectId: string,\n searchRequest: SearchRequestProps | null\n): { results: SearchResultItem[] | []; error: Error; isLoading: boolean } {\n const { scope } = useAppContext();\n const { currentProject } = useConfig();\n const schema = useMemo(() => currentProject?.schema ?? [], [currentProject]);\n const scopes = currentProject?.scopes;\n const defaultScope = scopes?.find((s) => s.isDefault)?.name ?? 'default';\n const swrKey = searchRequest?.commonParams.q ? JSON.stringify(searchRequest) : null;\n const { data, error, isLoading } = useSWR(swrKey, () =>\n fetch(apiPaths(projectId).search, {\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(searchRequest),\n method: 'POST',\n mode: 'cors',\n }).then((res) => res.json() as Promise<{ results: RawSearchResultItems }>)\n );\n const results = useMemo(\n () => mapResults(data?.results ?? [], projectId, schema, scope, defaultScope) ?? [],\n [data, defaultScope, projectId, schema, scope]\n );\n\n return { results, error, isLoading };\n}\n\nfunction mapResults(\n results: RawSearchResultItems | undefined,\n projectId: string,\n schema: Entity[],\n scope: string,\n defaultScope: string\n): SearchResultItem[] | undefined {\n return results\n ?.filter((result) => (result as RawResultItem)?.hits?.length > 0)\n .map((result) => {\n const item = result as RawResultItem;\n const entityNamePlural = item.collection.replace(`${projectId}_`, '').replace(/_\\d+$/, '');\n const entitySchema = find<Entity>(propEq(entityNamePlural, 'plural'))(schema);\n\n if (!entitySchema) {\n return [];\n }\n\n const primaryAttributeName = getDisplayAttribute(entitySchema)?.name ?? '';\n const entityName = entitySchema?.name ?? entityNamePlural;\n\n // iterate over the hits and return an object with the primary attribute value first and then the rest of the attributes.\n return item.hits.map(({ document }) => {\n const primaryAttribute = document[primaryAttributeName];\n const scopedPrimaryAttribute =\n primaryAttribute && typeof primaryAttribute !== 'string'\n ? (primaryAttribute[scope] ?? primaryAttribute[defaultScope])\n : null;\n const primaryAttributeValue = scopedPrimaryAttribute ?? document[primaryAttributeName];\n const attributes = Object.entries(document).reduce(\n (acc: Omit<SearchResultItem, '_id' | '_entityName' | '_entityNamePlural'>, [key, value]) => {\n if (key !== primaryAttributeName && key !== 'id' && key !== '_updatedAt') {\n const scopedValue = typeof value !== 'string' ? (value[scope] ?? value[defaultScope]) : value;\n\n acc[key] = scopedValue;\n }\n\n return acc;\n },\n {}\n );\n\n return {\n _id: document.id,\n _entityName: entityName,\n _entityNamePlural: entityNamePlural,\n [primaryAttributeName]: primaryAttributeValue as string,\n ...attributes,\n };\n });\n })\n .flat();\n}\n"]}
@@ -1,2 +1,2 @@
1
- import'./index.css';import {f,b as b$3,d as d$1}from'./chunk-ROCYIGFD.js';import {f as f$1}from'./chunk-CMZV7EPC.js';import {N,ga,ha,ia,Rc,Tc,oa,s,p,q,r}from'./chunk-YCCFUGWJ.js';import {w,b as b$2}from'./chunk-32ZU4MLE.js';import {e,g,h,i,j,t,d,a,b as b$4,c as c$1,o}from'./chunk-SZEGGBOC.js';import {b as b$1,c,e as e$1}from'./chunk-USNXQOMJ.js';import {b}from'./chunk-6NRQMG26.js';import {useState,useMemo,useRef,useEffect}from'react';import {useNavigate,useLocation,useParams,Link}from'react-router-dom';import V,{useSWRConfig}from'swr';import {Plug,ArrowLeft,ExternalLink,RefreshCw,ChevronLeft,ChevronRight,Plus,CheckIcon,XIcon,MoreHorizontal,TriangleAlert}from'lucide-react';import {jsxs,jsx,Fragment}from'react/jsx-runtime';var ye="/plugins/oauth/start",M=class extends Error{code="account_mismatch";constructor(){super('You signed in with a different account. Use "Connect another account" to add it.'),this.name="PluginAccountMismatchError";}};function fe(n){let t;try{t=new URL(n);}catch{return null}return t.protocol!=="https:"||t.username!==""||t.password!==""?null:t}function Ce(n,t){let a=b$3(),s=fe(n),i=fe(t);return !s||!i||s.origin!==a||s.pathname!==ye||i.origin!==a||i.pathname!=="/"?null:{href:s.href,origin:a}}async function U(n,t,a,s){let i=window.open("about:blank",`flexkit-plugin-${crypto.randomUUID()}`,"popup,width=560,height=720");if(!i)throw new Error("Allow popups for Studio, then connect again.");let r;try{r=await n.connectPlugins({pluginId:t,scope:a,studioOrigin:window.location.origin,...s?.connectionId?{connectionId:s.connectionId}:{}});}catch(p){throw i.close(),p}let d=Ce(r.authorizeUrl,r.completionOrigin);if(!d)throw i.close(),new Error("Connection could not be started.");let c=d.origin;await new Promise((p,x)=>{let l=false,w=false,u=m=>{if(!w){if(w=true,window.clearInterval(f),window.clearTimeout(k),window.removeEventListener("message",N),i.close(),m){x(m);return}p();}},g=async()=>{if(l||w)return;l=true;let m;try{m=await n.pluginOAuthStatus(r.transactionId);}catch{l=false;return}if(l=false,m.status==="complete"){u();return}if(i.closed&&m.status==="pending"){u(new Error("Connection window was closed."));return}(m.status==="failed"||new Date(m.expires_at).getTime()<Date.now())&&u(new Error("Connection was not completed. Please try again."));},N=m=>{if(m.origin!==c||m.source!==i||!m.data||typeof m.data!="object")return;let v=m.data;if(v.type==="flexkit:plugin-oauth-ready"&&v.transactionId===r.transactionId){i.postMessage({type:"flexkit:plugin-oauth-start",transactionId:r.transactionId,ticket:r.launchTicket},c);return}if(v.type==="flexkit:plugin-oauth"&&v.transactionId===r.transactionId){if(v.status==="failed"&&v.error==="account_mismatch"){u(new M);return}g();}},f=window.setInterval(()=>{g();},2e3),k=window.setTimeout(()=>u(new Error("Connection timed out. Please try again.")),6e5);window.addEventListener("message",N),i.location.href=d.href;});}function Ue(n){let t;try{t=new URL(n);}catch{return null}return t.protocol!=="https:"||t.username!==""||t.password!==""?null:t.href}function be(){let{currentProjectId:n}=f$1();return {api:useMemo(()=>n?d$1(n):null,[n]),base:n?`/api/flexkit/${n}`:null}}function $e(n){return n.length===2?"Project & Personal":n[0]==="project"?"Project":"Personal"}function je(n){return n.length===2?"fk:bg-indigo-100 fk:text-indigo-800 fk:dark:bg-indigo-950 fk:dark:text-indigo-300":n[0]==="project"?"fk:bg-sky-100 fk:text-sky-800 fk:dark:bg-sky-950 fk:dark:text-sky-300":"fk:bg-teal-100 fk:text-teal-800 fk:dark:bg-teal-950 fk:dark:text-teal-300"}function D(n){return n.connections.length>0}function _e(n){return n==="project"?"Project":"Personal"}function $(n,t,a){return a==="personal"?n.allowPersonal:t}function Ne(n,t){return n.connections.filter(a=>a.scope===t).sort((a,s)=>Number(s.isPrimary)-Number(a.isPrimary)||a.createdAt.localeCompare(s.createdAt))}function Be(n){let t=n.connections.filter(a=>a.isPrimary&&a.status==="connected");return t.find(a=>a.scope==="personal")??t.find(a=>a.scope==="project")??null}function We({busy:n,canManage:t,plugin:a,onConnect:s}){let i$1=a.scopes.filter(c=>Ne(a,c).length===0),[r]=i$1;if(!r)return null;if(a.scopes.length===1)return jsxs(b,{disabled:n||!a.enabled||!$(a,t,r),size:"sm",type:"button",onClick:()=>s(r),children:[jsx(Plug,{}),"Connect"]});let d=i$1.some(c=>$(a,t,c));return jsxs(e,{children:[jsx(g,{asChild:true,children:jsxs(b,{disabled:n||!a.enabled||!d,size:"sm",type:"button",children:[jsx(Plug,{}),"Connect"]})}),jsx(h,{align:"end",className:"fk:w-72",children:jsx(i,{children:i$1.map(c=>jsx(j,{disabled:!$(a,t,c),onSelect:()=>s(c),children:jsxs("span",{className:"fk:flex fk:flex-col fk:gap-0.5",children:[jsx("span",{children:_e(c)}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:c==="personal"?"Only you can use this connection in this project.":"Shared with project members who can use this plugin."})]})},c))})})]})}function I(n,t){let a=/^(.*\/ai)(?:\/|$)/.exec(n);return a?`${a[1]}/${t}`:t}function F(n){return n.split(/[\s_-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Xe(n){let t={};for(let a of n){let s=t[a.category];if(s){s.push(a);continue}t[a.category]=[a];}return Object.entries(t).sort(([a],[s])=>F(a).localeCompare(F(s))).map(([a,s])=>({category:a,plugins:s}))}var de=[{id:"first",rows:[{descriptionWidth:"fk:w-44",id:"first-a",nameWidth:"fk:w-24"},{descriptionWidth:"fk:w-52",id:"first-b",nameWidth:"fk:w-16"},{descriptionWidth:"fk:w-40",id:"first-c",nameWidth:"fk:w-28"},{descriptionWidth:"fk:w-48",id:"first-d",nameWidth:"fk:w-20"}]},{id:"second",rows:[{descriptionWidth:"fk:w-36",id:"second-a",nameWidth:"fk:w-32"},{descriptionWidth:"fk:w-56",id:"second-b",nameWidth:"fk:w-24"}]}];function pe({action:n,row:t$1}){return jsxs("div",{className:"fk:-mx-3 fk:flex fk:min-w-0 fk:items-center fk:gap-3 fk:px-3 fk:py-2",children:[jsx(t,{className:"fk:size-10 fk:shrink-0 fk:rounded-lg"}),jsxs("span",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:flex-col fk:gap-1.5",children:[jsx(t,{className:`fk:h-4 ${t$1.nameWidth}`}),jsx(t,{className:`fk:h-4 ${t$1.descriptionWidth}`})]}),n?jsx(t,{className:"fk:size-4 fk:shrink-0"}):null]})}var K="fk:grid fk:grid-cols-1 fk:gap-x-16 fk:gap-y-1 fk:lg:grid-cols-2";function Je({grouped:n=true}){let t$1=de.flatMap(a=>a.rows);return n?jsxs("div",{"aria-busy":"true",className:"fk:flex fk:flex-col fk:gap-8",children:[jsx("span",{className:"fk:sr-only",children:"Loading plugins"}),de.map(a=>jsxs("section",{children:[jsx(t,{className:"fk:mb-1 fk:h-4 fk:w-28"}),jsx("div",{className:K,children:a.rows.map(s=>jsx(pe,{action:true,row:s},s.id))})]},a.id))]}):jsxs("div",{"aria-busy":"true",className:K,children:[jsx("span",{className:"fk:sr-only",children:"Loading plugins"}),t$1.map(a=>jsx(pe,{action:true,row:a},a.id))]})}function Oe(){let n=useNavigate(),{pathname:t}=useLocation(),a=/\/ai\/plugins\/?$/.test(t),s=t.includes("/ai/skills");return jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs(b$1,{children:[jsx(c,{asChild:true,children:jsx(N,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(ga,{value:s?"skills":"plugins",onValueChange:r=>{let d=r==="skills"?"skills":"plugins";(r==="skills"?s:a)||n(I(t,d));},children:jsxs(ha,{children:[jsx(ia,{value:"plugins",onClick:()=>{a||n(I(t,"plugins"));},children:"Plugins"}),jsx(ia,{value:"skills",children:"Skills"})]})})]})}function Ge({onOpen:n,plugin:t}){let a=D(t),s=t.connections.filter(r=>r.status==="needs_auth").length,i=s===1?"An account needs to be reconnected":`${s.toString()} accounts need to be reconnected`;return jsxs("button",{type:"button",onClick:n,className:"fk:-mx-3 fk:flex fk:min-w-0 fk:items-center fk:gap-3 fk:rounded-lg fk:px-3 fk:py-2 fk:text-left fk:transition-colors fk:hover:bg-accent fk:focus-visible:bg-accent fk:focus-visible:outline-none fk:corner-squircle",children:[jsx("img",{src:t.logoUrl,alt:"",className:"fk:size-10 fk:shrink-0 fk:rounded-lg fk:corner-squircle"}),jsxs("span",{className:"fk:min-w-0 fk:flex-1",children:[jsx("span",{className:"fk:block fk:truncate fk:text-sm fk:font-medium",children:t.name}),jsx("span",{className:"fk:block fk:truncate fk:text-sm fk:text-muted-foreground",children:t.description})]}),s>0?jsxs(b$1,{children:[jsx(c,{asChild:true,children:jsxs("span",{className:"fk:flex fk:shrink-0",children:[jsx(TriangleAlert,{"aria-hidden":true,className:"fk:size-4 fk:text-destructive"}),jsx("span",{className:"fk:sr-only",children:i})]})}),jsx(e$1,{children:i})]}):a?jsx(CheckIcon,{className:"fk:size-4 fk:shrink-0 fk:text-success"}):jsx(Plus,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"})]})}function me({onOpen:n,plugins:t}){return jsx("div",{className:K,children:t.map(a=>jsx(Ge,{plugin:a,onOpen:()=>n(a.id)},a.id))})}function ve({installedOnly:n=false}){let{base:t$1}=be(),{data:a$1,error:s$1,isLoading:i}=V(t$1?`${t$1}/plugins`:null,f),[r,d$1]=useState(""),c=useNavigate(),{pathname:p}=useLocation(),x=r.trim().toLowerCase(),l=(a$1?.plugins??[]).filter(k=>(!n||D(k))&&`${k.name} ${k.description}`.toLowerCase().includes(x)),w$1=(a$1?.plugins??[]).filter(D),u=n?[]:Xe(l),g="Plugins are being prepared. Check back soon.";n&&!x?g="No plugins installed yet.":(a$1?.catalogSha||n)&&(g="No plugins match your search.");function N(k){c(I(p,`plugins/${k}`));}let f$1=jsx("div",{className:"fk:flex fk:flex-col fk:gap-8",children:u.map(k=>jsxs("section",{children:[jsx("h3",{className:"fk:mb-1 fk:text-sm fk:font-medium",children:F(k.category)}),jsx(me,{plugins:k.plugins,onOpen:N})]},k.category))});return n&&(f$1=jsx(me,{plugins:l,onOpen:N})),(i||s$1||l.length===0)&&(f$1=null),jsxs("main",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:[jsx(Oe,{}),jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{className:"fk:mx-auto fk:flex fk:w-full fk:max-w-4xl fk:flex-col fk:gap-8 fk:py-6 fk:pl-4 fk:pr-6",children:[jsxs("div",{children:[jsx("h2",{className:"fk:text-2xl fk:font-semibold",children:"Plugins"}),jsx("p",{className:"fk:mt-2 fk:text-muted-foreground",children:"Connect the tools you use and add skills to your workflows."})]}),jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-3",children:[jsx(s,{"aria-label":"Search plugins",className:"fk:mr-auto fk:w-full fk:max-w-xs",placeholder:"Search plugins\u2026",value:r,onChange:k=>d$1(k.target.value)}),!n&&i?jsxs("div",{className:"fk:flex fk:items-center fk:gap-3",children:[jsx("div",{className:"fk:flex fk:-space-x-2",children:["installed-a","installed-b","installed-c"].map(k=>jsx(t,{className:"fk:size-8 fk:rounded-md fk:ring-2 fk:ring-background"},k))}),jsx(t,{className:"fk:h-4 fk:w-20"})]}):null,!n&&!i&&w$1.length>0?jsx(d,{children:w$1.slice(0,9).map(k=>jsxs(a,{className:"fk:rounded-md",children:[jsx(b$4,{src:k.logoUrl,alt:""}),jsx(c$1,{children:k.name.charAt(0)})]},k.id))}):null,n?jsxs(Link,{to:I(p,"plugins"),className:"fk:inline-flex fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground fk:hover:text-foreground",children:[jsx(ChevronLeft,{className:"fk:size-4"}),"Show all"]}):null,!n&&!i?jsxs(Link,{to:I(p,"plugins/installed"),className:"fk:inline-flex fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground fk:hover:text-foreground",children:[w$1.length," installed",jsx(ChevronRight,{className:"fk:size-4"})]}):null]}),s$1?jsx(Rc,{variant:"destructive",children:jsx(Tc,{children:"Unable to load plugins. Please try again."})}):null,i?jsx(Je,{grouped:!n}):null,!i&&!s$1&&l.length===0?jsx(Rc,{children:jsx(Tc,{children:g})}):null,f$1]})})]})}function fn(){return jsx(ve,{})}function cn(){return jsx(ve,{installedOnly:true})}function He({base:n,connectionId:t$1}){let{data:a,error:s}=V(`${n}/plugin-connections/${t$1}/tools`,f);return s?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"Unable to discover tools. Reconnect or try again."}):a?jsx("div",{className:"fk:flex fk:flex-col fk:gap-3",children:a.servers.map(i=>jsxs("section",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx("h4",{className:"fk:font-medium",children:i.name}),i.error?jsx("p",{children:i.error}):null,i.tools.length>0?jsxs(p,{className:"fk:group",children:[jsxs(q,{className:"fk:flex fk:w-fit fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground",children:[jsx(ChevronRight,{className:"fk:size-4 fk:transition-transform fk:group-data-[state=open]:rotate-90"}),qe(i.tools.length)]}),jsx(r,{children:jsx("ul",{className:"fk:mt-2 fk:flex fk:flex-col fk:gap-2",children:i.tools.map(r=>jsxs("li",{children:[jsx("span",{className:"fk:text-sm fk:font-medium",children:r.name}),jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:r.description})]},r.name))})})]}):null]},i.name))}):jsx(t,{className:"fk:h-12 fk:w-full"})}function qe(n){return n===1?"1 tool":`${n.toString()} tools`}function Fe(n){return n.accountName&&n.accountName!==n.displayName?n.accountName:n.scope==="project"?"Shared with this project":"Only you can use this account"}function Ke({actionable:n,actions:t,busy:a$1,connection:s$1,pluginEnabled:i$1}){let[r,d]=useState(false),[c,p]=useState(""),x=useRef(null),l=s$1.status==="needs_auth",w=async()=>{let u=c.trim();await t.onRename(s$1,u||null),d(false);};return useEffect(()=>{if(!r)return;let u=window.setTimeout(()=>x.current?.focus(),0);return ()=>window.clearTimeout(u)},[r]),jsxs("li",{className:"fk:flex fk:min-w-0 fk:items-center fk:gap-3 fk:py-2",children:[jsx(a,{className:"fk:size-8",children:jsx(c$1,{children:s$1.displayName.charAt(0).toUpperCase()})}),r?jsxs("form",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:items-center fk:gap-2",onSubmit:u=>{u.preventDefault(),w();},children:[jsx(s,{"aria-label":"Account name",ref:x,className:"fk:h-8 fk:max-w-xs",disabled:a$1,placeholder:s$1.accountName??"Account name",value:c,onChange:u=>p(u.target.value),onKeyDown:u=>{u.key==="Escape"&&d(false);}}),jsx(b,{"aria-label":"Save name",disabled:a$1,size:"icon",type:"submit",variant:"ghost",children:jsx(CheckIcon,{})}),jsx(b,{"aria-label":"Cancel rename",size:"icon",type:"button",variant:"ghost",onClick:()=>d(false),children:jsx(XIcon,{})})]}):jsxs("span",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:flex-col",children:[jsxs("span",{className:"fk:flex fk:min-w-0 fk:items-center fk:gap-2",children:[jsx("span",{className:"fk:truncate fk:text-sm fk:font-medium",children:s$1.displayName}),s$1.isPrimary?jsx(b$2,{variant:"secondary",children:"Primary"}):null,l?jsx(b$2,{variant:"destructive",children:"Needs reconnect"}):null]}),jsx("span",{className:"fk:truncate fk:text-sm fk:text-muted-foreground",children:Fe(s$1)})]}),n&&!r?jsxs(e,{children:[jsx(g,{asChild:true,children:jsx(b,{"aria-label":`Manage ${s$1.displayName}`,disabled:a$1,size:"icon",variant:"ghost",children:jsx(MoreHorizontal,{})})}),jsxs(h,{align:"end",children:[jsxs(i,{children:[!s$1.isPrimary&&!l?jsx(j,{onSelect:()=>t.onMakePrimary(s$1),children:"Make primary"}):null,jsx(j,{onSelect:()=>{p(s$1.label??""),d(true);},children:"Rename"}),jsx(j,{disabled:!i$1,onSelect:()=>t.onReconnect(s$1),children:"Reconnect"})]}),jsx(o,{}),jsx(j,{variant:"destructive",onSelect:()=>t.onDisconnect(s$1),children:"Disconnect"})]})]}):null]})}function Ye({actions:n,busy:t,canManage:a,onConnect:s,plugin:i}){let r=i.scopes.length>1;return jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsx("h2",{className:"fk:text-xl fk:font-semibold",children:"Connected accounts"}),i.scopes.map(d=>{let c=Ne(i,d),p=$(i,a,d),x=d==="personal"||a;return c.length===0&&!p?null:jsxs("div",{className:"fk:flex fk:flex-col",children:[r?jsx("h3",{className:"fk:text-sm fk:font-medium fk:text-muted-foreground",children:d==="project"?"Project accounts":"Your accounts"}):null,jsxs("ul",{className:"fk:flex fk:flex-col fk:divide-y",children:[c.map(l=>jsx(Ke,{actionable:x,actions:n,busy:t,connection:l,pluginEnabled:i.enabled},l.id)),p?jsx("li",{children:jsxs("button",{className:"fk:flex fk:w-full fk:items-center fk:gap-3 fk:py-2 fk:text-left fk:text-sm fk:text-muted-foreground fk:transition-colors fk:hover:text-foreground fk:disabled:pointer-events-none fk:disabled:opacity-50",disabled:t||!i.enabled,type:"button",onClick:()=>s(d),children:[jsx("span",{className:"fk:flex fk:size-8 fk:shrink-0 fk:items-center fk:justify-center fk:rounded-full fk:border fk:border-dashed",children:jsx(Plus,{className:"fk:size-4"})}),c.length>0?"Connect another account":"Connect an account"]})}):null]})]},d)})]})}function un(){let{pluginId:n}=useParams(),{api:t$1,base:a}=be(),{data:s,error:i,mutate:r}=V(a&&n?`${a}/plugins/${n}`:null,f),{mutate:d}=useSWRConfig(),c$1=useNavigate(),[p,x]=useState(false),l=s?.plugin,w$1=l?Ue(l.sourceUrl):null,u=async f=>{x(true);try{await f(),await r();}catch(k){if(k instanceof M){oa.error('You signed in with a different account. Use "Connect another account" to add it.');return}oa.error(k instanceof Error?k.message:"Unable to complete this action.");}finally{x(false);}};if(i)return jsx("div",{className:"fk:p-6",children:jsx(Rc,{variant:"destructive",children:jsx(Tc,{children:"Unable to load this plugin."})})});if(!l||!s||!t$1||!a)return jsxs("main",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:[jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs(b$1,{children:[jsx(c,{asChild:true,children:jsx(N,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsxs(b,{variant:"ghost",size:"sm",onClick:()=>c$1("..",{relative:"path"}),children:[jsx(ArrowLeft,{}),"Plugins"]})]}),jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{"aria-busy":"true",className:"fk:mx-auto fk:flex fk:w-full fk:max-w-4xl fk:flex-col fk:gap-8 fk:py-6 fk:pl-4 fk:pr-6",children:[jsx("span",{className:"fk:sr-only",children:"Loading plugin"}),jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-4",children:[jsx(t,{className:"fk:size-14 fk:shrink-0 fk:rounded-lg"}),jsx(t,{className:"fk:h-7 fk:w-40"}),jsx(t,{className:"fk:ml-auto fk:h-9 fk:w-28"})]}),jsx(t,{className:"fk:h-4 fk:w-full"}),jsx(t,{className:"fk:h-4 fk:w-2/3"}),jsx(t,{className:"fk:h-6 fk:w-24 fk:rounded-full"})]})]})})]});let g=Be(l),N$1={onDisconnect:f=>{u(()=>t$1.disconnectPlugin(f.id));},onMakePrimary:f=>{u(()=>t$1.updatePluginConnection(f.id,{primary:!0}));},onReconnect:f=>{u(()=>U(t$1,l.id,f.scope,{connectionId:f.id}));},onRename:(f,k)=>u(()=>t$1.updatePluginConnection(f.id,{label:k}))};return jsxs("main",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:[jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs(b$1,{children:[jsx(c,{asChild:true,children:jsx(N,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsxs(b,{variant:"ghost",size:"sm",onClick:()=>c$1("..",{relative:"path"}),children:[jsx(ArrowLeft,{}),"Plugins"]})]}),jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{className:"fk:mx-auto fk:flex fk:w-full fk:max-w-4xl fk:flex-col fk:gap-8 fk:py-6 fk:pl-4 fk:pr-6",children:[jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-4",children:[jsx("img",{src:l.logoUrl,alt:"",className:"fk:size-14 fk:shrink-0 fk:rounded-lg fk:corner-squircle"}),jsxs("div",{className:"fk:flex fk:min-w-0 fk:flex-col fk:gap-0.5",children:[jsx("h1",{className:"fk:text-xl fk:font-semibold",children:l.name}),w$1?jsxs("a",{href:w$1,target:"_blank",rel:"noopener noreferrer",className:"fk:inline-flex fk:w-fit fk:items-center fk:gap-1 fk:text-sm fk:hover:underline fk:text-muted-foreground",children:["View source",jsx(ExternalLink,{className:"fk:size-3"})]}):null]}),jsx("div",{className:"fk:ml-auto fk:flex fk:shrink-0 fk:flex-wrap fk:items-center fk:justify-end fk:gap-2",children:D(l)?null:jsx(We,{busy:p,canManage:s.canManage,plugin:l,onConnect:f=>{u(()=>U(t$1,l.id,f));}})})]}),jsx("p",{className:"fk:text-muted-foreground",children:l.description}),jsx("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-3",children:jsx(b$2,{className:`fk:border-0 fk:text-[0.625rem] fk:leading-4.5 fk:font-normal fk:py-0 fk:px-2 ${je(l.scopes)}`,variant:"default",children:$e(l.scopes)})}),l.scopes.map(f=>(f==="personal"?l.allowPersonal:s.canManage)?null:jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:f==="project"?"Ask an owner or developer to connect.":"Personal connections are disabled by project policy."},f))]}),l.enabled?null:jsx(Rc,{children:jsx(Tc,{children:"This plugin is disabled by project policy."})}),D(l)?jsx(Ye,{actions:N$1,busy:p,canManage:s.canManage,plugin:l,onConnect:f=>{u(()=>U(t$1,l.id,f));}}):null,jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-3",children:[jsx("h2",{className:"fk:text-xl fk:font-semibold",children:"Included tools"}),l.capabilities.agentTools&&g?jsxs(b,{className:"fk:ml-auto",disabled:p,size:"sm",variant:"ghost",onClick:()=>{u(async()=>{await t$1.refreshPluginTools(g.id),await d(`${a}/plugin-connections/${g.id}/tools`);});},children:[jsx(RefreshCw,{}),"Refresh"]}):null]}),l.capabilities.automationDelivery?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"Automation delivery to selected channels. This plugin does not expose MCP messaging tools."}):null,l.capabilities.agentTools&&!g?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"Connect to discover available tools."}):null,l.capabilities.agentTools&&g?jsxs(Fragment,{children:[jsxs("p",{className:"fk:text-sm fk:text-muted-foreground",children:["Tools \xB7 via ",g.displayName]}),jsx(He,{base:a,connectionId:g.id},g.id)]}):null]}),jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsx("h2",{className:"fk:text-xl fk:font-semibold",children:"Included skills"}),s.skills.length===0?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"This plugin includes no skills."}):s.skills.map(f=>jsxs("div",{children:[jsx("h3",{className:"fk:font-medium",children:f.name}),jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:f.description})]},f.key))]}),jsxs("section",{className:"fk:space-y-3",children:[jsx("h2",{className:"fk:text-xl fk:font-semibold",children:"Used by"}),l.usedBy.length===0?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"No automations visible to you use this plugin yet."}):jsx("ul",{children:l.usedBy.map(f=>jsx("li",{children:jsx(b,{className:"fk:pl-0!",variant:"link",onClick:()=>c$1(`../../automations/${f.id}`,{relative:"path"}),children:f.name})},f.id))})]})]})})]})}export{U as a,We as b,Oe as c,fn as d,cn as e,un as f};//# sourceMappingURL=chunk-TK4UYLCV.js.map
2
- //# sourceMappingURL=chunk-TK4UYLCV.js.map
1
+ import'./index.css';import {f,b as b$3,d as d$1}from'./chunk-ROCYIGFD.js';import {f as f$1}from'./chunk-SV5KK5K6.js';import {N,ga,ha,ia,Rc,Tc,oa,s,p,q,r}from'./chunk-YCCFUGWJ.js';import {w,b as b$2}from'./chunk-32ZU4MLE.js';import {e,g,h,i,j,t,d,a,b as b$4,c as c$1,o}from'./chunk-SZEGGBOC.js';import {b as b$1,c,e as e$1}from'./chunk-USNXQOMJ.js';import {b}from'./chunk-6NRQMG26.js';import {useState,useMemo,useRef,useEffect}from'react';import {useNavigate,useLocation,useParams,Link}from'react-router-dom';import V,{useSWRConfig}from'swr';import {Plug,ArrowLeft,ExternalLink,RefreshCw,ChevronLeft,ChevronRight,Plus,CheckIcon,XIcon,MoreHorizontal,TriangleAlert}from'lucide-react';import {jsxs,jsx,Fragment}from'react/jsx-runtime';var ye="/plugins/oauth/start",M=class extends Error{code="account_mismatch";constructor(){super('You signed in with a different account. Use "Connect another account" to add it.'),this.name="PluginAccountMismatchError";}};function fe(n){let t;try{t=new URL(n);}catch{return null}return t.protocol!=="https:"||t.username!==""||t.password!==""?null:t}function Ce(n,t){let a=b$3(),s=fe(n),i=fe(t);return !s||!i||s.origin!==a||s.pathname!==ye||i.origin!==a||i.pathname!=="/"?null:{href:s.href,origin:a}}async function U(n,t,a,s){let i=window.open("about:blank",`flexkit-plugin-${crypto.randomUUID()}`,"popup,width=560,height=720");if(!i)throw new Error("Allow popups for Studio, then connect again.");let r;try{r=await n.connectPlugins({pluginId:t,scope:a,studioOrigin:window.location.origin,...s?.connectionId?{connectionId:s.connectionId}:{}});}catch(p){throw i.close(),p}let d=Ce(r.authorizeUrl,r.completionOrigin);if(!d)throw i.close(),new Error("Connection could not be started.");let c=d.origin;await new Promise((p,x)=>{let l=false,w=false,u=m=>{if(!w){if(w=true,window.clearInterval(f),window.clearTimeout(k),window.removeEventListener("message",N),i.close(),m){x(m);return}p();}},g=async()=>{if(l||w)return;l=true;let m;try{m=await n.pluginOAuthStatus(r.transactionId);}catch{l=false;return}if(l=false,m.status==="complete"){u();return}if(i.closed&&m.status==="pending"){u(new Error("Connection window was closed."));return}(m.status==="failed"||new Date(m.expires_at).getTime()<Date.now())&&u(new Error("Connection was not completed. Please try again."));},N=m=>{if(m.origin!==c||m.source!==i||!m.data||typeof m.data!="object")return;let v=m.data;if(v.type==="flexkit:plugin-oauth-ready"&&v.transactionId===r.transactionId){i.postMessage({type:"flexkit:plugin-oauth-start",transactionId:r.transactionId,ticket:r.launchTicket},c);return}if(v.type==="flexkit:plugin-oauth"&&v.transactionId===r.transactionId){if(v.status==="failed"&&v.error==="account_mismatch"){u(new M);return}g();}},f=window.setInterval(()=>{g();},2e3),k=window.setTimeout(()=>u(new Error("Connection timed out. Please try again.")),6e5);window.addEventListener("message",N),i.location.href=d.href;});}function Ue(n){let t;try{t=new URL(n);}catch{return null}return t.protocol!=="https:"||t.username!==""||t.password!==""?null:t.href}function be(){let{currentProjectId:n}=f$1();return {api:useMemo(()=>n?d$1(n):null,[n]),base:n?`/api/flexkit/${n}`:null}}function $e(n){return n.length===2?"Project & Personal":n[0]==="project"?"Project":"Personal"}function je(n){return n.length===2?"fk:bg-indigo-100 fk:text-indigo-800 fk:dark:bg-indigo-950 fk:dark:text-indigo-300":n[0]==="project"?"fk:bg-sky-100 fk:text-sky-800 fk:dark:bg-sky-950 fk:dark:text-sky-300":"fk:bg-teal-100 fk:text-teal-800 fk:dark:bg-teal-950 fk:dark:text-teal-300"}function D(n){return n.connections.length>0}function _e(n){return n==="project"?"Project":"Personal"}function $(n,t,a){return a==="personal"?n.allowPersonal:t}function Ne(n,t){return n.connections.filter(a=>a.scope===t).sort((a,s)=>Number(s.isPrimary)-Number(a.isPrimary)||a.createdAt.localeCompare(s.createdAt))}function Be(n){let t=n.connections.filter(a=>a.isPrimary&&a.status==="connected");return t.find(a=>a.scope==="personal")??t.find(a=>a.scope==="project")??null}function We({busy:n,canManage:t,plugin:a,onConnect:s}){let i$1=a.scopes.filter(c=>Ne(a,c).length===0),[r]=i$1;if(!r)return null;if(a.scopes.length===1)return jsxs(b,{disabled:n||!a.enabled||!$(a,t,r),size:"sm",type:"button",onClick:()=>s(r),children:[jsx(Plug,{}),"Connect"]});let d=i$1.some(c=>$(a,t,c));return jsxs(e,{children:[jsx(g,{asChild:true,children:jsxs(b,{disabled:n||!a.enabled||!d,size:"sm",type:"button",children:[jsx(Plug,{}),"Connect"]})}),jsx(h,{align:"end",className:"fk:w-72",children:jsx(i,{children:i$1.map(c=>jsx(j,{disabled:!$(a,t,c),onSelect:()=>s(c),children:jsxs("span",{className:"fk:flex fk:flex-col fk:gap-0.5",children:[jsx("span",{children:_e(c)}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:c==="personal"?"Only you can use this connection in this project.":"Shared with project members who can use this plugin."})]})},c))})})]})}function I(n,t){let a=/^(.*\/ai)(?:\/|$)/.exec(n);return a?`${a[1]}/${t}`:t}function F(n){return n.split(/[\s_-]+/).filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Xe(n){let t={};for(let a of n){let s=t[a.category];if(s){s.push(a);continue}t[a.category]=[a];}return Object.entries(t).sort(([a],[s])=>F(a).localeCompare(F(s))).map(([a,s])=>({category:a,plugins:s}))}var de=[{id:"first",rows:[{descriptionWidth:"fk:w-44",id:"first-a",nameWidth:"fk:w-24"},{descriptionWidth:"fk:w-52",id:"first-b",nameWidth:"fk:w-16"},{descriptionWidth:"fk:w-40",id:"first-c",nameWidth:"fk:w-28"},{descriptionWidth:"fk:w-48",id:"first-d",nameWidth:"fk:w-20"}]},{id:"second",rows:[{descriptionWidth:"fk:w-36",id:"second-a",nameWidth:"fk:w-32"},{descriptionWidth:"fk:w-56",id:"second-b",nameWidth:"fk:w-24"}]}];function pe({action:n,row:t$1}){return jsxs("div",{className:"fk:-mx-3 fk:flex fk:min-w-0 fk:items-center fk:gap-3 fk:px-3 fk:py-2",children:[jsx(t,{className:"fk:size-10 fk:shrink-0 fk:rounded-lg"}),jsxs("span",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:flex-col fk:gap-1.5",children:[jsx(t,{className:`fk:h-4 ${t$1.nameWidth}`}),jsx(t,{className:`fk:h-4 ${t$1.descriptionWidth}`})]}),n?jsx(t,{className:"fk:size-4 fk:shrink-0"}):null]})}var K="fk:grid fk:grid-cols-1 fk:gap-x-16 fk:gap-y-1 fk:lg:grid-cols-2";function Je({grouped:n=true}){let t$1=de.flatMap(a=>a.rows);return n?jsxs("div",{"aria-busy":"true",className:"fk:flex fk:flex-col fk:gap-8",children:[jsx("span",{className:"fk:sr-only",children:"Loading plugins"}),de.map(a=>jsxs("section",{children:[jsx(t,{className:"fk:mb-1 fk:h-4 fk:w-28"}),jsx("div",{className:K,children:a.rows.map(s=>jsx(pe,{action:true,row:s},s.id))})]},a.id))]}):jsxs("div",{"aria-busy":"true",className:K,children:[jsx("span",{className:"fk:sr-only",children:"Loading plugins"}),t$1.map(a=>jsx(pe,{action:true,row:a},a.id))]})}function Oe(){let n=useNavigate(),{pathname:t}=useLocation(),a=/\/ai\/plugins\/?$/.test(t),s=t.includes("/ai/skills");return jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs(b$1,{children:[jsx(c,{asChild:true,children:jsx(N,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(ga,{value:s?"skills":"plugins",onValueChange:r=>{let d=r==="skills"?"skills":"plugins";(r==="skills"?s:a)||n(I(t,d));},children:jsxs(ha,{children:[jsx(ia,{value:"plugins",onClick:()=>{a||n(I(t,"plugins"));},children:"Plugins"}),jsx(ia,{value:"skills",children:"Skills"})]})})]})}function Ge({onOpen:n,plugin:t}){let a=D(t),s=t.connections.filter(r=>r.status==="needs_auth").length,i=s===1?"An account needs to be reconnected":`${s.toString()} accounts need to be reconnected`;return jsxs("button",{type:"button",onClick:n,className:"fk:-mx-3 fk:flex fk:min-w-0 fk:items-center fk:gap-3 fk:rounded-lg fk:px-3 fk:py-2 fk:text-left fk:transition-colors fk:hover:bg-accent fk:focus-visible:bg-accent fk:focus-visible:outline-none fk:corner-squircle",children:[jsx("img",{src:t.logoUrl,alt:"",className:"fk:size-10 fk:shrink-0 fk:rounded-lg fk:corner-squircle"}),jsxs("span",{className:"fk:min-w-0 fk:flex-1",children:[jsx("span",{className:"fk:block fk:truncate fk:text-sm fk:font-medium",children:t.name}),jsx("span",{className:"fk:block fk:truncate fk:text-sm fk:text-muted-foreground",children:t.description})]}),s>0?jsxs(b$1,{children:[jsx(c,{asChild:true,children:jsxs("span",{className:"fk:flex fk:shrink-0",children:[jsx(TriangleAlert,{"aria-hidden":true,className:"fk:size-4 fk:text-destructive"}),jsx("span",{className:"fk:sr-only",children:i})]})}),jsx(e$1,{children:i})]}):a?jsx(CheckIcon,{className:"fk:size-4 fk:shrink-0 fk:text-success"}):jsx(Plus,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"})]})}function me({onOpen:n,plugins:t}){return jsx("div",{className:K,children:t.map(a=>jsx(Ge,{plugin:a,onOpen:()=>n(a.id)},a.id))})}function ve({installedOnly:n=false}){let{base:t$1}=be(),{data:a$1,error:s$1,isLoading:i}=V(t$1?`${t$1}/plugins`:null,f),[r,d$1]=useState(""),c=useNavigate(),{pathname:p}=useLocation(),x=r.trim().toLowerCase(),l=(a$1?.plugins??[]).filter(k=>(!n||D(k))&&`${k.name} ${k.description}`.toLowerCase().includes(x)),w$1=(a$1?.plugins??[]).filter(D),u=n?[]:Xe(l),g="Plugins are being prepared. Check back soon.";n&&!x?g="No plugins installed yet.":(a$1?.catalogSha||n)&&(g="No plugins match your search.");function N(k){c(I(p,`plugins/${k}`));}let f$1=jsx("div",{className:"fk:flex fk:flex-col fk:gap-8",children:u.map(k=>jsxs("section",{children:[jsx("h3",{className:"fk:mb-1 fk:text-sm fk:font-medium",children:F(k.category)}),jsx(me,{plugins:k.plugins,onOpen:N})]},k.category))});return n&&(f$1=jsx(me,{plugins:l,onOpen:N})),(i||s$1||l.length===0)&&(f$1=null),jsxs("main",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:[jsx(Oe,{}),jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{className:"fk:mx-auto fk:flex fk:w-full fk:max-w-4xl fk:flex-col fk:gap-8 fk:py-6 fk:pl-4 fk:pr-6",children:[jsxs("div",{children:[jsx("h2",{className:"fk:text-2xl fk:font-semibold",children:"Plugins"}),jsx("p",{className:"fk:mt-2 fk:text-muted-foreground",children:"Connect the tools you use and add skills to your workflows."})]}),jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-3",children:[jsx(s,{"aria-label":"Search plugins",className:"fk:mr-auto fk:w-full fk:max-w-xs",placeholder:"Search plugins\u2026",value:r,onChange:k=>d$1(k.target.value)}),!n&&i?jsxs("div",{className:"fk:flex fk:items-center fk:gap-3",children:[jsx("div",{className:"fk:flex fk:-space-x-2",children:["installed-a","installed-b","installed-c"].map(k=>jsx(t,{className:"fk:size-8 fk:rounded-md fk:ring-2 fk:ring-background"},k))}),jsx(t,{className:"fk:h-4 fk:w-20"})]}):null,!n&&!i&&w$1.length>0?jsx(d,{children:w$1.slice(0,9).map(k=>jsxs(a,{className:"fk:rounded-md",children:[jsx(b$4,{src:k.logoUrl,alt:""}),jsx(c$1,{children:k.name.charAt(0)})]},k.id))}):null,n?jsxs(Link,{to:I(p,"plugins"),className:"fk:inline-flex fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground fk:hover:text-foreground",children:[jsx(ChevronLeft,{className:"fk:size-4"}),"Show all"]}):null,!n&&!i?jsxs(Link,{to:I(p,"plugins/installed"),className:"fk:inline-flex fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground fk:hover:text-foreground",children:[w$1.length," installed",jsx(ChevronRight,{className:"fk:size-4"})]}):null]}),s$1?jsx(Rc,{variant:"destructive",children:jsx(Tc,{children:"Unable to load plugins. Please try again."})}):null,i?jsx(Je,{grouped:!n}):null,!i&&!s$1&&l.length===0?jsx(Rc,{children:jsx(Tc,{children:g})}):null,f$1]})})]})}function fn(){return jsx(ve,{})}function cn(){return jsx(ve,{installedOnly:true})}function He({base:n,connectionId:t$1}){let{data:a,error:s}=V(`${n}/plugin-connections/${t$1}/tools`,f);return s?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"Unable to discover tools. Reconnect or try again."}):a?jsx("div",{className:"fk:flex fk:flex-col fk:gap-3",children:a.servers.map(i=>jsxs("section",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx("h4",{className:"fk:font-medium",children:i.name}),i.error?jsx("p",{children:i.error}):null,i.tools.length>0?jsxs(p,{className:"fk:group",children:[jsxs(q,{className:"fk:flex fk:w-fit fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground",children:[jsx(ChevronRight,{className:"fk:size-4 fk:transition-transform fk:group-data-[state=open]:rotate-90"}),qe(i.tools.length)]}),jsx(r,{children:jsx("ul",{className:"fk:mt-2 fk:flex fk:flex-col fk:gap-2",children:i.tools.map(r=>jsxs("li",{children:[jsx("span",{className:"fk:text-sm fk:font-medium",children:r.name}),jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:r.description})]},r.name))})})]}):null]},i.name))}):jsx(t,{className:"fk:h-12 fk:w-full"})}function qe(n){return n===1?"1 tool":`${n.toString()} tools`}function Fe(n){return n.accountName&&n.accountName!==n.displayName?n.accountName:n.scope==="project"?"Shared with this project":"Only you can use this account"}function Ke({actionable:n,actions:t,busy:a$1,connection:s$1,pluginEnabled:i$1}){let[r,d]=useState(false),[c,p]=useState(""),x=useRef(null),l=s$1.status==="needs_auth",w=async()=>{let u=c.trim();await t.onRename(s$1,u||null),d(false);};return useEffect(()=>{if(!r)return;let u=window.setTimeout(()=>x.current?.focus(),0);return ()=>window.clearTimeout(u)},[r]),jsxs("li",{className:"fk:flex fk:min-w-0 fk:items-center fk:gap-3 fk:py-2",children:[jsx(a,{className:"fk:size-8",children:jsx(c$1,{children:s$1.displayName.charAt(0).toUpperCase()})}),r?jsxs("form",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:items-center fk:gap-2",onSubmit:u=>{u.preventDefault(),w();},children:[jsx(s,{"aria-label":"Account name",ref:x,className:"fk:h-8 fk:max-w-xs",disabled:a$1,placeholder:s$1.accountName??"Account name",value:c,onChange:u=>p(u.target.value),onKeyDown:u=>{u.key==="Escape"&&d(false);}}),jsx(b,{"aria-label":"Save name",disabled:a$1,size:"icon",type:"submit",variant:"ghost",children:jsx(CheckIcon,{})}),jsx(b,{"aria-label":"Cancel rename",size:"icon",type:"button",variant:"ghost",onClick:()=>d(false),children:jsx(XIcon,{})})]}):jsxs("span",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:flex-col",children:[jsxs("span",{className:"fk:flex fk:min-w-0 fk:items-center fk:gap-2",children:[jsx("span",{className:"fk:truncate fk:text-sm fk:font-medium",children:s$1.displayName}),s$1.isPrimary?jsx(b$2,{variant:"secondary",children:"Primary"}):null,l?jsx(b$2,{variant:"destructive",children:"Needs reconnect"}):null]}),jsx("span",{className:"fk:truncate fk:text-sm fk:text-muted-foreground",children:Fe(s$1)})]}),n&&!r?jsxs(e,{children:[jsx(g,{asChild:true,children:jsx(b,{"aria-label":`Manage ${s$1.displayName}`,disabled:a$1,size:"icon",variant:"ghost",children:jsx(MoreHorizontal,{})})}),jsxs(h,{align:"end",children:[jsxs(i,{children:[!s$1.isPrimary&&!l?jsx(j,{onSelect:()=>t.onMakePrimary(s$1),children:"Make primary"}):null,jsx(j,{onSelect:()=>{p(s$1.label??""),d(true);},children:"Rename"}),jsx(j,{disabled:!i$1,onSelect:()=>t.onReconnect(s$1),children:"Reconnect"})]}),jsx(o,{}),jsx(j,{variant:"destructive",onSelect:()=>t.onDisconnect(s$1),children:"Disconnect"})]})]}):null]})}function Ye({actions:n,busy:t,canManage:a,onConnect:s,plugin:i}){let r=i.scopes.length>1;return jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsx("h2",{className:"fk:text-xl fk:font-semibold",children:"Connected accounts"}),i.scopes.map(d=>{let c=Ne(i,d),p=$(i,a,d),x=d==="personal"||a;return c.length===0&&!p?null:jsxs("div",{className:"fk:flex fk:flex-col",children:[r?jsx("h3",{className:"fk:text-sm fk:font-medium fk:text-muted-foreground",children:d==="project"?"Project accounts":"Your accounts"}):null,jsxs("ul",{className:"fk:flex fk:flex-col fk:divide-y",children:[c.map(l=>jsx(Ke,{actionable:x,actions:n,busy:t,connection:l,pluginEnabled:i.enabled},l.id)),p?jsx("li",{children:jsxs("button",{className:"fk:flex fk:w-full fk:items-center fk:gap-3 fk:py-2 fk:text-left fk:text-sm fk:text-muted-foreground fk:transition-colors fk:hover:text-foreground fk:disabled:pointer-events-none fk:disabled:opacity-50",disabled:t||!i.enabled,type:"button",onClick:()=>s(d),children:[jsx("span",{className:"fk:flex fk:size-8 fk:shrink-0 fk:items-center fk:justify-center fk:rounded-full fk:border fk:border-dashed",children:jsx(Plus,{className:"fk:size-4"})}),c.length>0?"Connect another account":"Connect an account"]})}):null]})]},d)})]})}function un(){let{pluginId:n}=useParams(),{api:t$1,base:a}=be(),{data:s,error:i,mutate:r}=V(a&&n?`${a}/plugins/${n}`:null,f),{mutate:d}=useSWRConfig(),c$1=useNavigate(),[p,x]=useState(false),l=s?.plugin,w$1=l?Ue(l.sourceUrl):null,u=async f=>{x(true);try{await f(),await r();}catch(k){if(k instanceof M){oa.error('You signed in with a different account. Use "Connect another account" to add it.');return}oa.error(k instanceof Error?k.message:"Unable to complete this action.");}finally{x(false);}};if(i)return jsx("div",{className:"fk:p-6",children:jsx(Rc,{variant:"destructive",children:jsx(Tc,{children:"Unable to load this plugin."})})});if(!l||!s||!t$1||!a)return jsxs("main",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:[jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs(b$1,{children:[jsx(c,{asChild:true,children:jsx(N,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsxs(b,{variant:"ghost",size:"sm",onClick:()=>c$1("..",{relative:"path"}),children:[jsx(ArrowLeft,{}),"Plugins"]})]}),jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{"aria-busy":"true",className:"fk:mx-auto fk:flex fk:w-full fk:max-w-4xl fk:flex-col fk:gap-8 fk:py-6 fk:pl-4 fk:pr-6",children:[jsx("span",{className:"fk:sr-only",children:"Loading plugin"}),jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-4",children:[jsx(t,{className:"fk:size-14 fk:shrink-0 fk:rounded-lg"}),jsx(t,{className:"fk:h-7 fk:w-40"}),jsx(t,{className:"fk:ml-auto fk:h-9 fk:w-28"})]}),jsx(t,{className:"fk:h-4 fk:w-full"}),jsx(t,{className:"fk:h-4 fk:w-2/3"}),jsx(t,{className:"fk:h-6 fk:w-24 fk:rounded-full"})]})]})})]});let g=Be(l),N$1={onDisconnect:f=>{u(()=>t$1.disconnectPlugin(f.id));},onMakePrimary:f=>{u(()=>t$1.updatePluginConnection(f.id,{primary:!0}));},onReconnect:f=>{u(()=>U(t$1,l.id,f.scope,{connectionId:f.id}));},onRename:(f,k)=>u(()=>t$1.updatePluginConnection(f.id,{label:k}))};return jsxs("main",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:[jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs(b$1,{children:[jsx(c,{asChild:true,children:jsx(N,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsxs(b,{variant:"ghost",size:"sm",onClick:()=>c$1("..",{relative:"path"}),children:[jsx(ArrowLeft,{}),"Plugins"]})]}),jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{className:"fk:mx-auto fk:flex fk:w-full fk:max-w-4xl fk:flex-col fk:gap-8 fk:py-6 fk:pl-4 fk:pr-6",children:[jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-4",children:[jsx("img",{src:l.logoUrl,alt:"",className:"fk:size-14 fk:shrink-0 fk:rounded-lg fk:corner-squircle"}),jsxs("div",{className:"fk:flex fk:min-w-0 fk:flex-col fk:gap-0.5",children:[jsx("h1",{className:"fk:text-xl fk:font-semibold",children:l.name}),w$1?jsxs("a",{href:w$1,target:"_blank",rel:"noopener noreferrer",className:"fk:inline-flex fk:w-fit fk:items-center fk:gap-1 fk:text-sm fk:hover:underline fk:text-muted-foreground",children:["View source",jsx(ExternalLink,{className:"fk:size-3"})]}):null]}),jsx("div",{className:"fk:ml-auto fk:flex fk:shrink-0 fk:flex-wrap fk:items-center fk:justify-end fk:gap-2",children:D(l)?null:jsx(We,{busy:p,canManage:s.canManage,plugin:l,onConnect:f=>{u(()=>U(t$1,l.id,f));}})})]}),jsx("p",{className:"fk:text-muted-foreground",children:l.description}),jsx("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-3",children:jsx(b$2,{className:`fk:border-0 fk:text-[0.625rem] fk:leading-4.5 fk:font-normal fk:py-0 fk:px-2 ${je(l.scopes)}`,variant:"default",children:$e(l.scopes)})}),l.scopes.map(f=>(f==="personal"?l.allowPersonal:s.canManage)?null:jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:f==="project"?"Ask an owner or developer to connect.":"Personal connections are disabled by project policy."},f))]}),l.enabled?null:jsx(Rc,{children:jsx(Tc,{children:"This plugin is disabled by project policy."})}),D(l)?jsx(Ye,{actions:N$1,busy:p,canManage:s.canManage,plugin:l,onConnect:f=>{u(()=>U(t$1,l.id,f));}}):null,jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-3",children:[jsx("h2",{className:"fk:text-xl fk:font-semibold",children:"Included tools"}),l.capabilities.agentTools&&g?jsxs(b,{className:"fk:ml-auto",disabled:p,size:"sm",variant:"ghost",onClick:()=>{u(async()=>{await t$1.refreshPluginTools(g.id),await d(`${a}/plugin-connections/${g.id}/tools`);});},children:[jsx(RefreshCw,{}),"Refresh"]}):null]}),l.capabilities.automationDelivery?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"Automation delivery to selected channels. This plugin does not expose MCP messaging tools."}):null,l.capabilities.agentTools&&!g?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"Connect to discover available tools."}):null,l.capabilities.agentTools&&g?jsxs(Fragment,{children:[jsxs("p",{className:"fk:text-sm fk:text-muted-foreground",children:["Tools \xB7 via ",g.displayName]}),jsx(He,{base:a,connectionId:g.id},g.id)]}):null]}),jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsx("h2",{className:"fk:text-xl fk:font-semibold",children:"Included skills"}),s.skills.length===0?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"This plugin includes no skills."}):s.skills.map(f=>jsxs("div",{children:[jsx("h3",{className:"fk:font-medium",children:f.name}),jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:f.description})]},f.key))]}),jsxs("section",{className:"fk:space-y-3",children:[jsx("h2",{className:"fk:text-xl fk:font-semibold",children:"Used by"}),l.usedBy.length===0?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"No automations visible to you use this plugin yet."}):jsx("ul",{children:l.usedBy.map(f=>jsx("li",{children:jsx(b,{className:"fk:pl-0!",variant:"link",onClick:()=>c$1(`../../automations/${f.id}`,{relative:"path"}),children:f.name})},f.id))})]})]})})]})}export{U as a,We as b,Oe as c,fn as d,cn as e,un as f};//# sourceMappingURL=chunk-HZJNNJOK.js.map
2
+ //# sourceMappingURL=chunk-HZJNNJOK.js.map