@flexkit/studio 0.2.9 → 0.2.11

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 (61) hide show
  1. package/dist/activity-nav-button-LZESIQL2.js +2 -0
  2. package/dist/{activity-nav-button-EP6GYASE.js.map → activity-nav-button-LZESIQL2.js.map} +1 -1
  3. package/dist/chat-page-3YSJP7FC.js +4 -0
  4. package/dist/chat-page-3YSJP7FC.js.map +1 -0
  5. package/dist/{chunk-3OAEG7AE.js → chunk-22DXYOXX.js} +2 -2
  6. package/dist/{chunk-3OAEG7AE.js.map → chunk-22DXYOXX.js.map} +1 -1
  7. package/dist/chunk-2HSIWUH3.js +3 -0
  8. package/dist/chunk-2HSIWUH3.js.map +1 -0
  9. package/dist/chunk-7JSGAY3E.js +2 -0
  10. package/dist/chunk-7JSGAY3E.js.map +1 -0
  11. package/dist/chunk-B4WSTNZ3.js +8 -0
  12. package/dist/chunk-B4WSTNZ3.js.map +1 -0
  13. package/dist/{chunk-UUC4PXUB.js → chunk-GDTOP4MU.js} +3 -3
  14. package/dist/{chunk-UUC4PXUB.js.map → chunk-GDTOP4MU.js.map} +1 -1
  15. package/dist/{chunk-WQUCLXMU.js → chunk-HYSTMQD7.js} +2 -2
  16. package/dist/{chunk-WQUCLXMU.js.map → chunk-HYSTMQD7.js.map} +1 -1
  17. package/dist/chunk-KXAGLQ2B.js +2 -0
  18. package/dist/chunk-KXAGLQ2B.js.map +1 -0
  19. package/dist/{chunk-753V3IWO.js → chunk-OI6GA6PE.js} +3 -3
  20. package/dist/{chunk-753V3IWO.js.map → chunk-OI6GA6PE.js.map} +1 -1
  21. package/dist/{chunk-CMZV7EPC.js → chunk-TPLL535V.js} +3 -3
  22. package/dist/{chunk-CMZV7EPC.js.map → chunk-TPLL535V.js.map} +1 -1
  23. package/dist/{chunk-VARGD74X.js → chunk-YODWX4WT.js} +2 -2
  24. package/dist/{chunk-VARGD74X.js.map → chunk-YODWX4WT.js.map} +1 -1
  25. package/dist/{chunk-S5I2UQ6Y.js → chunk-YSMRXGVX.js} +2 -2
  26. package/dist/{chunk-S5I2UQ6Y.js.map → chunk-YSMRXGVX.js.map} +1 -1
  27. package/dist/index.css +13 -0
  28. package/dist/index.d.ts +1 -1
  29. package/dist/index.js +1 -1
  30. package/dist/{list-37T3A4P7.js → list-N5WCJSJC.js} +2 -2
  31. package/dist/{list-37T3A4P7.js.map → list-N5WCJSJC.js.map} +1 -1
  32. package/dist/pages-65QNO7ME.js +5 -0
  33. package/dist/{pages-R35VNLN5.js.map → pages-65QNO7ME.js.map} +1 -1
  34. package/dist/plugin-pages-F5K745MZ.js +2 -0
  35. package/dist/{plugin-pages-FTCCUJBD.js.map → plugin-pages-F5K745MZ.js.map} +1 -1
  36. package/dist/{root-E6BD5WNQ.js → root-4E3YUTQU.js} +3 -3
  37. package/dist/{root-E6BD5WNQ.js.map → root-4E3YUTQU.js.map} +1 -1
  38. package/dist/root-DK5C7DYH.js +2 -0
  39. package/dist/{root-OBXJWAZN.js.map → root-DK5C7DYH.js.map} +1 -1
  40. package/dist/{root-TKWXADN7.js → root-MMAJEVBH.js} +3 -3
  41. package/dist/{root-TKWXADN7.js.map → root-MMAJEVBH.js.map} +1 -1
  42. package/dist/{root-4YLQNL62.js → root-WYRLSQPK.js} +2 -2
  43. package/dist/{root-4YLQNL62.js.map → root-WYRLSQPK.js.map} +1 -1
  44. package/dist/{search-YS3HRU2A.js → search-EK4XBDGL.js} +2 -2
  45. package/dist/{search-YS3HRU2A.js.map → search-EK4XBDGL.js.map} +1 -1
  46. package/dist/skills-pages-O35YZMMC.js +2 -0
  47. package/dist/{skills-pages-4UQRSKQS.js.map → skills-pages-O35YZMMC.js.map} +1 -1
  48. package/package.json +3 -3
  49. package/dist/activity-nav-button-EP6GYASE.js +0 -2
  50. package/dist/chat-page-FLCLBZUX.js +0 -4
  51. package/dist/chat-page-FLCLBZUX.js.map +0 -1
  52. package/dist/chunk-ROCYIGFD.js +0 -3
  53. package/dist/chunk-ROCYIGFD.js.map +0 -1
  54. package/dist/chunk-TK4UYLCV.js +0 -2
  55. package/dist/chunk-TK4UYLCV.js.map +0 -1
  56. package/dist/chunk-Z5TZVTX3.js +0 -8
  57. package/dist/chunk-Z5TZVTX3.js.map +0 -1
  58. package/dist/pages-R35VNLN5.js +0 -5
  59. package/dist/plugin-pages-FTCCUJBD.js +0 -2
  60. package/dist/root-OBXJWAZN.js +0 -2
  61. package/dist/skills-pages-4UQRSKQS.js +0 -2
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/apps/ai/plugin-oauth.ts","../src/apps/ai/plugin-pages.tsx"],"names":["OAUTH_START_PATH","PluginAccountMismatchError","httpsUrl","value","url","trustedPluginOAuthTargets","authorizeUrl","completionOrigin","origin","getPlatformOrigin","authorize","completion","connectPluginPopup","api","pluginId","scope","options","popup","transaction","error","targets","expectedOrigin","resolve","reject","polling","finished","finish","interval","timeout","onMessage","poll","status","event","payload","httpsCatalogUrl","useMarketplaceApi","currentProjectId","useConfig","useMemo","createApiClient","scopeLabel","scopes","scopeColorClassname","isConnected","plugin","scopeTitle","scopePermitted","canManage","scopeConnections","connection","left","right","primaryToolConnection","primaries","PluginConnectControl","busy","onConnect","pendingScopes","jsxs","Button","jsx","Plug","anyPermitted","item","DropdownMenu","DropdownMenuTrigger","DropdownMenuContent","DropdownMenuGroup","DropdownMenuItem","aiSectionPath","pathname","section","match","categoryLabel","category","word","groupPlugins","plugins","groups","existing","items","PLUGIN_SKELETON_SECTIONS","CatalogRowSkeleton","action","row","Skeleton","pluginGridClassName","PluginListSkeleton","grouped","rows","CatalogHeader","navigate","useNavigate","useLocation","onPlugins","onSkills","Tooltip","TooltipTrigger","SidebarTrigger","TooltipContent","Tabs","next","destination","TabsList","TabsTrigger","PluginRow","onOpen","connected","needsReconnect","reconnectLabel","TriangleAlert","CheckIcon","Plus","PluginRows","PluginCatalog","installedOnly","base","data","isLoading","useSWR","fetcher","search","setSearch","useState","query","connectedPlugins","emptyMessage","openPlugin","list","group","ScrollArea","Input","id","AvatarGroup","Avatar","AvatarImage","AvatarFallback","Link","ChevronLeft","ChevronRight","Alert","AlertDescription","PluginsPage","InstalledPluginsPage","ConnectionTools","connectionId","server","Collapsible","CollapsibleTrigger","toolCountLabel","CollapsibleContent","tool","count","connectionSecondaryLine","ConnectionRow","actionable","actions","pluginEnabled","editing","setEditing","draft","setDraft","inputRef","useRef","needsAuth","saveRename","label","useEffect","timer","XIcon","Badge","MoreHorizontal","DropdownMenuSeparator","ConnectedAccounts","connections","permitted","PluginDetailPage","useParams","mutate","revalidateKey","useSWRConfig","setBusy","sourceUrl","perform","failure","toast","ArrowLeft","toolConnection","connectionActions","ExternalLink","RefreshCw","Fragment","skill","automation"],"mappings":"2tBAGA,IAAMA,EAAAA,CAAmB,sBAAA,CAGZC,EAAN,cAAyC,KAAM,CAC3C,IAAA,CAAO,kBAAA,CAEhB,aAAc,CACZ,KAAA,CAAM,kFAAkF,CAAA,CACxF,IAAA,CAAK,IAAA,CAAO,6BACd,CACF,CAAA,CAEA,SAASC,EAAAA,CAASC,CAAAA,CAA2B,CAC3C,IAAIC,CAAAA,CAEJ,GAAI,CACFA,CAAAA,CAAM,IAAI,IAAID,CAAK,EACrB,MAAQ,CACN,OAAO,IACT,CAEA,OAAIC,CAAAA,CAAI,QAAA,GAAa,QAAA,EAAYA,CAAAA,CAAI,WAAa,EAAA,EAAMA,CAAAA,CAAI,QAAA,GAAa,EAAA,CAChE,IAAA,CAGFA,CACT,CAGA,SAASC,EAAAA,CACPC,CAAAA,CACAC,CAAAA,CACyC,CACzC,IAAMC,EAASC,GAAAA,EAAkB,CAC3BC,EAAYR,EAAAA,CAASI,CAAY,EACjCK,CAAAA,CAAaT,EAAAA,CAASK,CAAgB,CAAA,CAU5C,OARI,CAACG,GAAa,CAACC,CAAAA,EAIfD,EAAU,MAAA,GAAWF,CAAAA,EAAUE,EAAU,QAAA,GAAaV,EAAAA,EAItDW,CAAAA,CAAW,MA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POA,CAAAA,CAAW,EAQpB,CACD,EACH,CAAA,CAAA,CAEJ,CAAA,CAAA,CACF,CAAA,CACA,CAAA,CAAA,CACF,CAEJ","file":"chunk-TK4UYLCV.js","sourcesContent":["import { getPlatformOrigin, type ApiClient } from './api';\nimport type { PluginScope } from './plugin-types';\n\nconst OAUTH_START_PATH = '/plugins/oauth/start';\n\n/** A Reconnect was completed with a different provider account than the one being reconnected. */\nexport class PluginAccountMismatchError extends Error {\n readonly code = 'account_mismatch';\n\n constructor() {\n super('You signed in with a different account. Use \"Connect another account\" to add it.');\n this.name = 'PluginAccountMismatchError';\n }\n}\n\nfunction httpsUrl(value: string): URL | null {\n let url: URL;\n\n try {\n url = new URL(value);\n } catch {\n return null;\n }\n\n if (url.protocol !== 'https:' || url.username !== '' || url.password !== '') {\n return null;\n }\n\n return url;\n}\n\n/** Popup navigation and postMessage stay on the platform OAuth start page. */\nfunction trustedPluginOAuthTargets(\n authorizeUrl: string,\n completionOrigin: string\n): { href: string; origin: string } | null {\n const origin = getPlatformOrigin();\n const authorize = httpsUrl(authorizeUrl);\n const completion = httpsUrl(completionOrigin);\n\n if (!authorize || !completion) {\n return null;\n }\n\n if (authorize.origin !== origin || authorize.pathname !== OAUTH_START_PATH) {\n return null;\n }\n\n if (completion.origin !== origin || completion.pathname !== '/') {\n return null;\n }\n\n return { href: authorize.href, origin };\n}\n\n/** Must be called directly from the click handler so browsers allow the popup. */\nexport async function connectPluginPopup(\n api: ApiClient,\n pluginId: string,\n scope: PluginScope,\n options?: { connectionId?: string }\n): Promise<void> {\n const popup = window.open('about:blank', `flexkit-plugin-${crypto.randomUUID()}`, 'popup,width=560,height=720');\n\n if (!popup) {\n throw new Error('Allow popups for Studio, then connect again.');\n }\n\n let transaction: Awaited<ReturnType<ApiClient['connectPlugins']>>;\n\n try {\n transaction = await api.connectPlugins({\n pluginId,\n scope,\n studioOrigin: window.location.origin,\n ...(options?.connectionId ? { connectionId: options.connectionId } : {}),\n });\n } catch (error) {\n popup.close();\n throw error;\n }\n\n const targets = trustedPluginOAuthTargets(transaction.authorizeUrl, transaction.completionOrigin);\n\n if (!targets) {\n popup.close();\n throw new Error('Connection could not be started.');\n }\n\n const expectedOrigin = targets.origin;\n\n await new Promise<void>((resolve, reject) => {\n let polling = false;\n let finished = false;\n const finish = (error?: Error) => {\n if (finished) {\n return;\n }\n\n finished = true;\n window.clearInterval(interval);\n window.clearTimeout(timeout);\n window.removeEventListener('message', onMessage);\n popup.close();\n\n if (error) {\n reject(error);\n\n return;\n }\n\n resolve();\n };\n const poll = async () => {\n if (polling || finished) {\n return;\n }\n\n polling = true;\n let status: Awaited<ReturnType<ApiClient['pluginOAuthStatus']>>;\n\n try {\n status = await api.pluginOAuthStatus(transaction.transactionId);\n } catch {\n polling = false;\n\n return;\n }\n\n polling = false;\n\n if (status.status === 'complete') {\n finish();\n\n return;\n }\n\n if (popup.closed && status.status === 'pending') {\n finish(new Error('Connection window was closed.'));\n\n return;\n }\n\n if (status.status === 'failed' || new Date(status.expires_at).getTime() < Date.now()) {\n finish(new Error('Connection was not completed. Please try again.'));\n }\n };\n const onMessage = (event: MessageEvent<unknown>) => {\n if (event.origin !== expectedOrigin || event.source !== popup || !event.data || typeof event.data !== 'object') {\n return;\n }\n\n const payload = event.data as { type?: string; transactionId?: string; status?: string; error?: string };\n\n if (payload.type === 'flexkit:plugin-oauth-ready' && payload.transactionId === transaction.transactionId) {\n popup.postMessage(\n {\n type: 'flexkit:plugin-oauth-start',\n transactionId: transaction.transactionId,\n ticket: transaction.launchTicket,\n },\n expectedOrigin\n );\n\n return;\n }\n\n if (payload.type === 'flexkit:plugin-oauth' && payload.transactionId === transaction.transactionId) {\n if (payload.status === 'failed' && payload.error === 'account_mismatch') {\n finish(new PluginAccountMismatchError());\n\n return;\n }\n\n void poll();\n }\n };\n const interval = window.setInterval(() => {\n void poll();\n }, 2000);\n const timeout = window.setTimeout(() => finish(new Error('Connection timed out. Please try again.')), 600_000);\n window.addEventListener('message', onMessage);\n popup.location.href = targets.href;\n });\n}\n","import { useEffect, useMemo, useRef, useState, type JSX } from 'react';\nimport { Link, useLocation, useNavigate, useParams } from 'react-router-dom';\nimport useSWR, { useSWRConfig } from 'swr';\nimport { useConfig } from '../../core/config/config-context';\nimport {\n Alert,\n AlertDescription,\n Avatar,\n AvatarFallback,\n AvatarGroup,\n AvatarImage,\n Badge,\n Button,\n Collapsible,\n CollapsibleContent,\n CollapsibleTrigger,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuItem,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n Input,\n ScrollArea,\n SidebarTrigger,\n Skeleton,\n Tabs,\n TabsList,\n TabsTrigger,\n toast,\n Tooltip,\n TooltipContent,\n TooltipTrigger\n} from '../../ui';\nimport {\n ArrowLeft,\n CheckIcon,\n ChevronLeft,\n ChevronRight,\n ExternalLink,\n MoreHorizontal,\n Plug,\n Plus,\n RefreshCw,\n TriangleAlert,\n XIcon,\n} from 'lucide-react';\nimport { createApiClient, fetcher } from './api';\nimport { connectPluginPopup, PluginAccountMismatchError } from './plugin-oauth';\nimport type {\n Marketplace,\n MarketplacePlugin,\n PluginConnection,\n PluginDetail,\n PluginScope,\n PluginTools,\n} from './plugin-types';\n\nfunction httpsCatalogUrl(value: string): string | null {\n let url: URL;\n\n try {\n url = new URL(value);\n } catch {\n return null;\n }\n\n if (url.protocol !== 'https:' || url.username !== '' || url.password !== '') {\n return null;\n }\n\n return url.href;\n}\n\nfunction useMarketplaceApi() {\n const { currentProjectId } = useConfig();\n const api = useMemo(() => (currentProjectId ? createApiClient(currentProjectId) : null), [currentProjectId]);\n\n return { api, base: currentProjectId ? `/api/flexkit/${currentProjectId}` : null };\n}\n\nfunction scopeLabel(scopes: PluginScope[]): string {\n if (scopes.length === 2) {\n return 'Project & Personal';\n }\n\n return scopes[0] === 'project' ? 'Project' : 'Personal';\n}\n\nfunction scopeColorClassname(scopes: PluginScope[]): string {\n if (scopes.length === 2) {\n return 'fk:bg-indigo-100 fk:text-indigo-800 fk:dark:bg-indigo-950 fk:dark:text-indigo-300';\n }\n\n return scopes[0] === 'project'\n ? 'fk:bg-sky-100 fk:text-sky-800 fk:dark:bg-sky-950 fk:dark:text-sky-300'\n : 'fk:bg-teal-100 fk:text-teal-800 fk:dark:bg-teal-950 fk:dark:text-teal-300';\n}\n\nfunction isConnected(plugin: MarketplacePlugin): boolean {\n return plugin.connections.length > 0;\n}\n\nfunction scopeTitle(scope: PluginScope): string {\n if (scope === 'project') {\n return 'Project';\n }\n\n return 'Personal';\n}\n\nfunction scopePermitted(plugin: MarketplacePlugin, canManage: boolean, scope: PluginScope): boolean {\n if (scope === 'personal') {\n return plugin.allowPersonal;\n }\n\n return canManage;\n}\n\nfunction scopeConnections(plugin: MarketplacePlugin, scope: PluginScope): PluginConnection[] {\n return plugin.connections\n .filter((connection) => connection.scope === scope)\n .sort((left, right) => Number(right.isPrimary) - Number(left.isPrimary) || left.createdAt.localeCompare(right.createdAt));\n}\n\n/** Mirrors chat: the personal primary account wins over the project primary. */\nfunction primaryToolConnection(plugin: MarketplacePlugin): PluginConnection | null {\n const primaries = plugin.connections.filter((connection) => connection.isPrimary && connection.status === 'connected');\n\n return primaries.find((connection) => connection.scope === 'personal') ?? primaries.find((connection) => connection.scope === 'project') ?? null;\n}\n\n/** Connect button; asks for the scope when the plugin supports both project and personal accounts. */\nexport function PluginConnectControl({\n busy,\n canManage,\n plugin,\n onConnect\n}: {\n busy: boolean;\n canManage: boolean;\n plugin: MarketplacePlugin;\n onConnect: (scope: PluginScope) => void;\n}): JSX.Element | null {\n const pendingScopes = plugin.scopes.filter((scope) => scopeConnections(plugin, scope).length === 0);\n const [scope] = pendingScopes;\n\n if (!scope) {\n return null;\n }\n\n if (plugin.scopes.length === 1) {\n return (\n <Button\n disabled={busy || !plugin.enabled || !scopePermitted(plugin, canManage, scope)}\n size=\"sm\"\n type=\"button\"\n onClick={() => onConnect(scope)}\n >\n <Plug />\n Connect\n </Button>\n );\n }\n\n const anyPermitted = pendingScopes.some((item) => scopePermitted(plugin, canManage, item));\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button disabled={busy || !plugin.enabled || !anyPermitted} size=\"sm\" type=\"button\">\n <Plug />\n Connect\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"fk:w-72\">\n <DropdownMenuGroup>\n {pendingScopes.map((item) => (\n <DropdownMenuItem\n disabled={!scopePermitted(plugin, canManage, item)}\n key={item}\n onSelect={() => onConnect(item)}\n >\n <span className=\"fk:flex fk:flex-col fk:gap-0.5\">\n <span>{scopeTitle(item)}</span>\n <span className=\"fk:text-xs fk:text-muted-foreground\">\n {item === 'personal'\n ? 'Only you can use this connection in this project.'\n : 'Shared with project members who can use this plugin.'}\n </span>\n </span>\n </DropdownMenuItem>\n ))}\n </DropdownMenuGroup>\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\nfunction aiSectionPath(pathname: string, section: string): string {\n const match = /^(.*\\/ai)(?:\\/|$)/.exec(pathname);\n\n if (!match) {\n return section;\n }\n\n return `${match[1]}/${section}`;\n}\n\nfunction categoryLabel(category: string): string {\n return category\n .split(/[\\s_-]+/)\n .filter(Boolean)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(' ');\n}\n\nfunction groupPlugins(plugins: MarketplacePlugin[]): Array<{ category: string; plugins: MarketplacePlugin[] }> {\n const groups: { [category: string]: MarketplacePlugin[] } = {};\n\n for (const plugin of plugins) {\n const existing = groups[plugin.category];\n\n if (existing) {\n existing.push(plugin);\n\n continue;\n }\n\n groups[plugin.category] = [plugin];\n }\n\n return Object.entries(groups)\n .sort(([left], [right]) => categoryLabel(left).localeCompare(categoryLabel(right)))\n .map(([category, items]) => ({ category, plugins: items }));\n}\n\ninterface CatalogSkeletonRow {\n descriptionWidth: string;\n id: string;\n nameWidth: string;\n}\n\nconst PLUGIN_SKELETON_SECTIONS: { id: string; rows: CatalogSkeletonRow[] }[] = [\n {\n id: 'first',\n rows: [\n { descriptionWidth: 'fk:w-44', id: 'first-a', nameWidth: 'fk:w-24' },\n { descriptionWidth: 'fk:w-52', id: 'first-b', nameWidth: 'fk:w-16' },\n { descriptionWidth: 'fk:w-40', id: 'first-c', nameWidth: 'fk:w-28' },\n { descriptionWidth: 'fk:w-48', id: 'first-d', nameWidth: 'fk:w-20' },\n ],\n },\n {\n id: 'second',\n rows: [\n { descriptionWidth: 'fk:w-36', id: 'second-a', nameWidth: 'fk:w-32' },\n { descriptionWidth: 'fk:w-56', id: 'second-b', nameWidth: 'fk:w-24' },\n ],\n },\n];\n\nfunction CatalogRowSkeleton({ action, row }: { action?: boolean; row: CatalogSkeletonRow }): JSX.Element {\n return (\n <div className=\"fk:-mx-3 fk:flex fk:min-w-0 fk:items-center fk:gap-3 fk:px-3 fk:py-2\">\n <Skeleton className=\"fk:size-10 fk:shrink-0 fk:rounded-lg\" />\n <span className=\"fk:flex fk:min-w-0 fk:flex-1 fk:flex-col fk:gap-1.5\">\n <Skeleton className={`fk:h-4 ${row.nameWidth}`} />\n <Skeleton className={`fk:h-4 ${row.descriptionWidth}`} />\n </span>\n {action ? <Skeleton className=\"fk:size-4 fk:shrink-0\" /> : null}\n </div>\n );\n}\n\nconst pluginGridClassName = 'fk:grid fk:grid-cols-1 fk:gap-x-16 fk:gap-y-1 fk:lg:grid-cols-2';\n\nfunction PluginListSkeleton({ grouped = true }: { grouped?: boolean }): JSX.Element {\n const rows = PLUGIN_SKELETON_SECTIONS.flatMap((section) => section.rows);\n\n if (!grouped) {\n return (\n <div aria-busy=\"true\" className={pluginGridClassName}>\n <span className=\"fk:sr-only\">Loading plugins</span>\n {rows.map((row) => (\n <CatalogRowSkeleton action key={row.id} row={row} />\n ))}\n </div>\n );\n }\n\n return (\n <div aria-busy=\"true\" className=\"fk:flex fk:flex-col fk:gap-8\">\n <span className=\"fk:sr-only\">Loading plugins</span>\n {PLUGIN_SKELETON_SECTIONS.map((section) => (\n <section key={section.id}>\n <Skeleton className=\"fk:mb-1 fk:h-4 fk:w-28\" />\n <div className={pluginGridClassName}>\n {section.rows.map((row) => (\n <CatalogRowSkeleton action key={row.id} row={row} />\n ))}\n </div>\n </section>\n ))}\n </div>\n );\n}\n\nexport function CatalogHeader(): JSX.Element {\n const navigate = useNavigate();\n const { pathname } = useLocation();\n const onPlugins = /\\/ai\\/plugins\\/?$/.test(pathname);\n const onSkills = pathname.includes('/ai/skills');\n const value = onSkills ? 'skills' : 'plugins';\n\n return (\n <div className=\"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2\">\n <Tooltip>\n <TooltipTrigger asChild>\n <SidebarTrigger className=\"fk:-ml-1 fk:h-4 fk:w-4\" />\n </TooltipTrigger>\n <TooltipContent>Toggle Sidebar</TooltipContent>\n </Tooltip>\n <Tabs\n value={value}\n onValueChange={(next) => {\n const destination = next === 'skills' ? 'skills' : 'plugins';\n const alreadyThere = next === 'skills' ? onSkills : onPlugins;\n\n if (alreadyThere) {\n return;\n }\n\n navigate(aiSectionPath(pathname, destination));\n }}\n >\n <TabsList>\n <TabsTrigger\n value=\"plugins\"\n onClick={() => {\n if (onPlugins) {\n return;\n }\n\n navigate(aiSectionPath(pathname, 'plugins'));\n }}\n >\n Plugins\n </TabsTrigger>\n <TabsTrigger value=\"skills\">Skills</TabsTrigger>\n </TabsList>\n </Tabs>\n </div>\n );\n}\n\nfunction PluginRow({ onOpen, plugin }: { onOpen: () => void; plugin: MarketplacePlugin }): JSX.Element {\n const connected = isConnected(plugin);\n const needsReconnect = plugin.connections.filter((connection) => connection.status === 'needs_auth').length;\n const reconnectLabel =\n needsReconnect === 1 ? 'An account needs to be reconnected' : `${needsReconnect.toString()} accounts need to be reconnected`;\n\n return (\n <button\n type=\"button\"\n onClick={onOpen}\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\"\n >\n <img src={plugin.logoUrl} alt=\"\" className=\"fk:size-10 fk:shrink-0 fk:rounded-lg fk:corner-squircle\" />\n <span className=\"fk:min-w-0 fk:flex-1\">\n <span className=\"fk:block fk:truncate fk:text-sm fk:font-medium\">{plugin.name}</span>\n <span className=\"fk:block fk:truncate fk:text-sm fk:text-muted-foreground\">{plugin.description}</span>\n </span>\n {needsReconnect > 0 ? (\n <Tooltip>\n <TooltipTrigger asChild>\n <span className=\"fk:flex fk:shrink-0\">\n <TriangleAlert aria-hidden className=\"fk:size-4 fk:text-destructive\" />\n <span className=\"fk:sr-only\">{reconnectLabel}</span>\n </span>\n </TooltipTrigger>\n <TooltipContent>{reconnectLabel}</TooltipContent>\n </Tooltip>\n ) : connected ? (\n <CheckIcon className=\"fk:size-4 fk:shrink-0 fk:text-success\" />\n ) : (\n <Plus className=\"fk:size-4 fk:shrink-0 fk:text-muted-foreground\" />\n )}\n </button>\n );\n}\n\nfunction PluginRows({\n onOpen,\n plugins,\n}: {\n onOpen: (_pluginId: string) => void;\n plugins: MarketplacePlugin[];\n}): JSX.Element {\n return (\n <div className={pluginGridClassName}>\n {plugins.map((plugin) => (\n <PluginRow key={plugin.id} plugin={plugin} onOpen={() => onOpen(plugin.id)} />\n ))}\n </div>\n );\n}\n\nfunction PluginCatalog({ installedOnly = false }: { installedOnly?: boolean }): JSX.Element {\n const { base } = useMarketplaceApi();\n const { data, error, isLoading } = useSWR<Marketplace>(base ? `${base}/plugins` : null, fetcher);\n const [search, setSearch] = useState('');\n const navigate = useNavigate();\n const { pathname } = useLocation();\n const query = search.trim().toLowerCase();\n const plugins = (data?.plugins ?? []).filter((plugin) => {\n const matchesInstall = !installedOnly || isConnected(plugin);\n\n return matchesInstall && `${plugin.name} ${plugin.description}`.toLowerCase().includes(query);\n });\n const connectedPlugins = (data?.plugins ?? []).filter(isConnected);\n const groups = installedOnly ? [] : groupPlugins(plugins);\n let emptyMessage = 'Plugins are being prepared. Check back soon.';\n\n if (installedOnly && !query) {\n emptyMessage = 'No plugins installed yet.';\n } else if (data?.catalogSha || installedOnly) {\n emptyMessage = 'No plugins match your search.';\n }\n\n function openPlugin(pluginId: string): void {\n navigate(aiSectionPath(pathname, `plugins/${pluginId}`));\n }\n\n let list: JSX.Element | null = (\n <div className=\"fk:flex fk:flex-col fk:gap-8\">\n {groups.map((group) => (\n <section key={group.category}>\n <h3 className=\"fk:mb-1 fk:text-sm fk:font-medium\">{categoryLabel(group.category)}</h3>\n <PluginRows plugins={group.plugins} onOpen={openPlugin} />\n </section>\n ))}\n </div>\n );\n\n if (installedOnly) {\n list = <PluginRows plugins={plugins} onOpen={openPlugin} />;\n }\n\n if (isLoading || error || plugins.length === 0) {\n list = null;\n }\n\n return (\n <main className=\"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col\">\n <CatalogHeader />\n <ScrollArea className=\"fk:h-0 fk:min-h-0 fk:flex-1\">\n <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\">\n <div>\n <h2 className=\"fk:text-2xl fk:font-semibold\">Plugins</h2>\n <p className=\"fk:mt-2 fk:text-muted-foreground\">\n Connect the tools you use and add skills to your workflows.\n </p>\n </div>\n <div className=\"fk:flex fk:flex-wrap fk:items-center fk:gap-3\">\n <Input\n aria-label=\"Search plugins\"\n className=\"fk:mr-auto fk:w-full fk:max-w-xs\"\n placeholder=\"Search plugins…\"\n value={search}\n onChange={(event) => setSearch(event.target.value)}\n />\n {!installedOnly && isLoading ? (\n <div className=\"fk:flex fk:items-center fk:gap-3\">\n <div className=\"fk:flex fk:-space-x-2\">\n {['installed-a', 'installed-b', 'installed-c'].map((id) => (\n <Skeleton className=\"fk:size-8 fk:rounded-md fk:ring-2 fk:ring-background\" key={id} />\n ))}\n </div>\n <Skeleton className=\"fk:h-4 fk:w-20\" />\n </div>\n ) : null}\n {!installedOnly && !isLoading && connectedPlugins.length > 0 ? (\n <AvatarGroup>\n {connectedPlugins.slice(0, 9).map((plugin) => (\n <Avatar className=\"fk:rounded-md\" key={plugin.id}>\n <AvatarImage src={plugin.logoUrl} alt=\"\" />\n <AvatarFallback>{plugin.name.charAt(0)}</AvatarFallback>\n </Avatar>\n ))}\n </AvatarGroup>\n ) : null}\n {installedOnly ? (\n <Link\n to={aiSectionPath(pathname, 'plugins')}\n className=\"fk:inline-flex fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground fk:hover:text-foreground\"\n >\n <ChevronLeft className=\"fk:size-4\" />\n Show all\n </Link>\n ) : null}\n {!installedOnly && !isLoading ? (\n <Link\n to={aiSectionPath(pathname, 'plugins/installed')}\n className=\"fk:inline-flex fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground fk:hover:text-foreground\"\n >\n {connectedPlugins.length} installed\n <ChevronRight className=\"fk:size-4\" />\n </Link>\n ) : null}\n </div>\n {error ? (\n <Alert variant=\"destructive\">\n <AlertDescription>Unable to load plugins. Please try again.</AlertDescription>\n </Alert>\n ) : null}\n {isLoading ? <PluginListSkeleton grouped={!installedOnly} /> : null}\n {!isLoading && !error && plugins.length === 0 ? (\n <Alert>\n <AlertDescription>{emptyMessage}</AlertDescription>\n </Alert>\n ) : null}\n {list}\n </div>\n </ScrollArea>\n </main>\n );\n}\n\nexport function PluginsPage(): JSX.Element {\n return <PluginCatalog />;\n}\n\nexport function InstalledPluginsPage(): JSX.Element {\n return <PluginCatalog installedOnly />;\n}\n\nfunction ConnectionTools({ base, connectionId }: { base: string; connectionId: string }): JSX.Element {\n const { data, error } = useSWR<PluginTools>(`${base}/plugin-connections/${connectionId}/tools`, fetcher);\n\n if (error) {\n return <p className=\"fk:text-sm fk:text-muted-foreground\">Unable to discover tools. Reconnect or try again.</p>;\n }\n\n if (!data) {\n return <Skeleton className=\"fk:h-12 fk:w-full\" />;\n }\n\n return (\n <div className=\"fk:flex fk:flex-col fk:gap-3\">\n {data.servers.map((server) => (\n <section className=\"fk:flex fk:flex-col fk:gap-2\" key={server.name}>\n <h4 className=\"fk:font-medium\">{server.name}</h4>\n {server.error ? <p>{server.error}</p> : null}\n {server.tools.length > 0 ? (\n <Collapsible className=\"fk:group\">\n <CollapsibleTrigger className=\"fk:flex fk:w-fit fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground\">\n <ChevronRight className=\"fk:size-4 fk:transition-transform fk:group-data-[state=open]:rotate-90\" />\n {toolCountLabel(server.tools.length)}\n </CollapsibleTrigger>\n <CollapsibleContent>\n <ul className=\"fk:mt-2 fk:flex fk:flex-col fk:gap-2\">\n {server.tools.map((tool) => (\n <li key={tool.name}>\n <span className=\"fk:text-sm fk:font-medium\">{tool.name}</span>\n <p className=\"fk:text-sm fk:text-muted-foreground\">{tool.description}</p>\n </li>\n ))}\n </ul>\n </CollapsibleContent>\n </Collapsible>\n ) : null}\n </section>\n ))}\n </div>\n );\n}\n\nfunction toolCountLabel(count: number): string {\n if (count === 1) {\n return '1 tool';\n }\n\n return `${count.toString()} tools`;\n}\n\ninterface ConnectionActions {\n onDisconnect: (_connection: PluginConnection) => void;\n onMakePrimary: (_connection: PluginConnection) => void;\n onReconnect: (_connection: PluginConnection) => void;\n onRename: (_connection: PluginConnection, _label: string | null) => Promise<void>;\n}\n\nfunction connectionSecondaryLine(connection: PluginConnection): string {\n if (connection.accountName && connection.accountName !== connection.displayName) {\n return connection.accountName;\n }\n\n return connection.scope === 'project' ? 'Shared with this project' : 'Only you can use this account';\n}\n\nfunction ConnectionRow({\n actionable,\n actions,\n busy,\n connection,\n pluginEnabled,\n}: {\n actionable: boolean;\n actions: ConnectionActions;\n busy: boolean;\n connection: PluginConnection;\n pluginEnabled: boolean;\n}): JSX.Element {\n const [editing, setEditing] = useState(false);\n const [draft, setDraft] = useState('');\n const inputRef = useRef<HTMLInputElement | null>(null);\n const needsAuth = connection.status === 'needs_auth';\n const saveRename = async () => {\n const label = draft.trim();\n\n await actions.onRename(connection, label ? label : null);\n setEditing(false);\n };\n\n // The menu restores focus to its trigger as it closes; focus the field afterwards.\n useEffect(() => {\n if (!editing) {\n return;\n }\n\n const timer = window.setTimeout(() => inputRef.current?.focus(), 0);\n\n return () => window.clearTimeout(timer);\n }, [editing]);\n\n return (\n <li className=\"fk:flex fk:min-w-0 fk:items-center fk:gap-3 fk:py-2\">\n <Avatar className=\"fk:size-8\">\n <AvatarFallback>{connection.displayName.charAt(0).toUpperCase()}</AvatarFallback>\n </Avatar>\n {editing ? (\n <form\n className=\"fk:flex fk:min-w-0 fk:flex-1 fk:items-center fk:gap-2\"\n onSubmit={(event) => {\n event.preventDefault();\n void saveRename();\n }}\n >\n <Input\n aria-label=\"Account name\"\n ref={inputRef}\n className=\"fk:h-8 fk:max-w-xs\"\n disabled={busy}\n placeholder={connection.accountName ?? 'Account name'}\n value={draft}\n onChange={(event) => setDraft(event.target.value)}\n onKeyDown={(event) => {\n if (event.key === 'Escape') {\n setEditing(false);\n }\n }}\n />\n <Button aria-label=\"Save name\" disabled={busy} size=\"icon\" type=\"submit\" variant=\"ghost\">\n <CheckIcon />\n </Button>\n <Button aria-label=\"Cancel rename\" size=\"icon\" type=\"button\" variant=\"ghost\" onClick={() => setEditing(false)}>\n <XIcon />\n </Button>\n </form>\n ) : (\n <span className=\"fk:flex fk:min-w-0 fk:flex-1 fk:flex-col\">\n <span className=\"fk:flex fk:min-w-0 fk:items-center fk:gap-2\">\n <span className=\"fk:truncate fk:text-sm fk:font-medium\">{connection.displayName}</span>\n {connection.isPrimary ? <Badge variant=\"secondary\">Primary</Badge> : null}\n {needsAuth ? <Badge variant=\"destructive\">Needs reconnect</Badge> : null}\n </span>\n <span className=\"fk:truncate fk:text-sm fk:text-muted-foreground\">{connectionSecondaryLine(connection)}</span>\n </span>\n )}\n {actionable && !editing ? (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button aria-label={`Manage ${connection.displayName}`} disabled={busy} size=\"icon\" variant=\"ghost\">\n <MoreHorizontal />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n <DropdownMenuGroup>\n {!connection.isPrimary && !needsAuth ? (\n <DropdownMenuItem onSelect={() => actions.onMakePrimary(connection)}>Make primary</DropdownMenuItem>\n ) : null}\n <DropdownMenuItem\n onSelect={() => {\n setDraft(connection.label ?? '');\n setEditing(true);\n }}\n >\n Rename\n </DropdownMenuItem>\n <DropdownMenuItem disabled={!pluginEnabled} onSelect={() => actions.onReconnect(connection)}>\n Reconnect\n </DropdownMenuItem>\n </DropdownMenuGroup>\n <DropdownMenuSeparator />\n <DropdownMenuItem variant=\"destructive\" onSelect={() => actions.onDisconnect(connection)}>\n Disconnect\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n ) : null}\n </li>\n );\n}\n\nfunction ConnectedAccounts({\n actions,\n busy,\n canManage,\n onConnect,\n plugin,\n}: {\n actions: ConnectionActions;\n busy: boolean;\n canManage: boolean;\n onConnect: (_scope: PluginScope) => void;\n plugin: MarketplacePlugin;\n}): JSX.Element {\n const grouped = plugin.scopes.length > 1;\n\n return (\n <section className=\"fk:flex fk:flex-col fk:gap-3\">\n <h2 className=\"fk:text-xl fk:font-semibold\">Connected accounts</h2>\n {plugin.scopes.map((scope) => {\n const connections = scopeConnections(plugin, scope);\n const permitted = scopePermitted(plugin, canManage, scope);\n // Personal rows are only ever returned for the current user.\n const actionable = scope === 'personal' || canManage;\n\n if (connections.length === 0 && !permitted) {\n return null;\n }\n\n return (\n <div className=\"fk:flex fk:flex-col\" key={scope}>\n {grouped ? (\n <h3 className=\"fk:text-sm fk:font-medium fk:text-muted-foreground\">\n {scope === 'project' ? 'Project accounts' : 'Your accounts'}\n </h3>\n ) : null}\n <ul className=\"fk:flex fk:flex-col fk:divide-y\">\n {connections.map((connection) => (\n <ConnectionRow\n actionable={actionable}\n actions={actions}\n busy={busy}\n connection={connection}\n key={connection.id}\n pluginEnabled={plugin.enabled}\n />\n ))}\n {permitted ? (\n <li>\n <button\n 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\"\n disabled={busy || !plugin.enabled}\n type=\"button\"\n onClick={() => onConnect(scope)}\n >\n <span className=\"fk:flex fk:size-8 fk:shrink-0 fk:items-center fk:justify-center fk:rounded-full fk:border fk:border-dashed\">\n <Plus className=\"fk:size-4\" />\n </span>\n {connections.length > 0 ? 'Connect another account' : 'Connect an account'}\n </button>\n </li>\n ) : null}\n </ul>\n </div>\n );\n })}\n </section>\n );\n}\n\nexport function PluginDetailPage(): JSX.Element {\n const { pluginId } = useParams<{ pluginId: string }>();\n const { api, base } = useMarketplaceApi();\n const { data, error, mutate } = useSWR<PluginDetail>(\n base && pluginId ? `${base}/plugins/${pluginId}` : null,\n fetcher\n );\n const { mutate: revalidateKey } = useSWRConfig();\n const navigate = useNavigate();\n const [busy, setBusy] = useState(false);\n const plugin = data?.plugin;\n const sourceUrl = plugin ? httpsCatalogUrl(plugin.sourceUrl) : null;\n const perform = async (action: () => Promise<unknown>) => {\n setBusy(true);\n\n try {\n await action();\n await mutate();\n } catch (failure) {\n if (failure instanceof PluginAccountMismatchError) {\n toast.error('You signed in with a different account. Use \"Connect another account\" to add it.');\n\n return;\n }\n\n toast.error(failure instanceof Error ? failure.message : 'Unable to complete this action.');\n } finally {\n setBusy(false);\n }\n };\n\n if (error) {\n return (\n <div className=\"fk:p-6\">\n <Alert variant=\"destructive\">\n <AlertDescription>Unable to load this plugin.</AlertDescription>\n </Alert>\n </div>\n );\n }\n\n if (!plugin || !data || !api || !base) {\n return (\n <main className=\"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col\">\n <div className=\"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2\">\n <Tooltip>\n <TooltipTrigger asChild>\n <SidebarTrigger className=\"fk:-ml-1 fk:h-4 fk:w-4\" />\n </TooltipTrigger>\n <TooltipContent>Toggle Sidebar</TooltipContent>\n </Tooltip>\n <Button variant=\"ghost\" size=\"sm\" onClick={() => navigate('..', { relative: 'path' })}>\n <ArrowLeft />\n Plugins\n </Button>\n </div>\n <ScrollArea className=\"fk:h-0 fk:min-h-0 fk:flex-1\">\n <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\">\n <span className=\"fk:sr-only\">Loading plugin</span>\n <section className=\"fk:flex fk:flex-col fk:gap-3\">\n <div className=\"fk:flex fk:items-center fk:gap-4\">\n <Skeleton className=\"fk:size-14 fk:shrink-0 fk:rounded-lg\" />\n <Skeleton className=\"fk:h-7 fk:w-40\" />\n <Skeleton className=\"fk:ml-auto fk:h-9 fk:w-28\" />\n </div>\n <Skeleton className=\"fk:h-4 fk:w-full\" />\n <Skeleton className=\"fk:h-4 fk:w-2/3\" />\n <Skeleton className=\"fk:h-6 fk:w-24 fk:rounded-full\" />\n </section>\n </div>\n </ScrollArea>\n </main>\n );\n }\n\n const toolConnection = primaryToolConnection(plugin);\n const connectionActions: ConnectionActions = {\n onDisconnect: (connection) => void perform(() => api.disconnectPlugin(connection.id)),\n onMakePrimary: (connection) => void perform(() => api.updatePluginConnection(connection.id, { primary: true })),\n onReconnect: (connection) =>\n void perform(() => connectPluginPopup(api, plugin.id, connection.scope, { connectionId: connection.id })),\n onRename: (connection, label) => perform(() => api.updatePluginConnection(connection.id, { label })),\n };\n\n return (\n <main className=\"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col\">\n <div className=\"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2\">\n <Tooltip>\n <TooltipTrigger asChild>\n <SidebarTrigger className=\"fk:-ml-1 fk:h-4 fk:w-4\" />\n </TooltipTrigger>\n <TooltipContent>Toggle Sidebar</TooltipContent>\n </Tooltip>\n <Button variant=\"ghost\" size=\"sm\" onClick={() => navigate('..', { relative: 'path' })}>\n <ArrowLeft />\n Plugins\n </Button>\n </div>\n <ScrollArea className=\"fk:h-0 fk:min-h-0 fk:flex-1\">\n <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\">\n <section className=\"fk:flex fk:flex-col fk:gap-3\">\n <div className=\"fk:flex fk:flex-wrap fk:items-center fk:gap-4\">\n <img src={plugin.logoUrl} alt=\"\" className=\"fk:size-14 fk:shrink-0 fk:rounded-lg fk:corner-squircle\" />\n <div className=\"fk:flex fk:min-w-0 fk:flex-col fk:gap-0.5\">\n <h1 className=\"fk:text-xl fk:font-semibold\">{plugin.name}</h1>\n {sourceUrl ? (\n <a\n href={sourceUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"fk:inline-flex fk:w-fit fk:items-center fk:gap-1 fk:text-sm fk:hover:underline fk:text-muted-foreground\"\n >\n View source\n <ExternalLink className=\"fk:size-3\" />\n </a>\n ) : null}\n </div>\n <div className=\"fk:ml-auto fk:flex fk:shrink-0 fk:flex-wrap fk:items-center fk:justify-end fk:gap-2\">\n {isConnected(plugin) ? null : (\n <PluginConnectControl\n busy={busy}\n canManage={data.canManage}\n plugin={plugin}\n onConnect={(scope) => void perform(() => connectPluginPopup(api, plugin.id, scope))}\n />\n )}\n </div>\n </div>\n <p className=\"fk:text-muted-foreground\">{plugin.description}</p>\n <div className=\"fk:flex fk:flex-wrap fk:items-center fk:gap-3\">\n <Badge\n className={`fk:border-0 fk:text-[0.625rem] fk:leading-4.5 fk:font-normal fk:py-0 fk:px-2 ${scopeColorClassname(plugin.scopes)}`}\n variant=\"default\"\n >\n {scopeLabel(plugin.scopes)}\n </Badge>\n </div>\n {plugin.scopes.map((scope) => {\n const permitted = scope === 'personal' ? plugin.allowPersonal : data.canManage;\n\n if (permitted) {\n return null;\n }\n\n const message =\n scope === 'project'\n ? 'Ask an owner or developer to connect.'\n : 'Personal connections are disabled by project policy.';\n\n return (\n <p className=\"fk:text-sm fk:text-muted-foreground\" key={scope}>\n {message}\n </p>\n );\n })}\n </section>\n {!plugin.enabled ? (\n <Alert>\n <AlertDescription>This plugin is disabled by project policy.</AlertDescription>\n </Alert>\n ) : null}\n {isConnected(plugin) ? (\n <ConnectedAccounts\n actions={connectionActions}\n busy={busy}\n canManage={data.canManage}\n plugin={plugin}\n onConnect={(scope) => void perform(() => connectPluginPopup(api, plugin.id, scope))}\n />\n ) : null}\n <section className=\"fk:flex fk:flex-col fk:gap-3\">\n <div className=\"fk:flex fk:items-center fk:gap-3\">\n <h2 className=\"fk:text-xl fk:font-semibold\">Included tools</h2>\n {plugin.capabilities.agentTools && toolConnection ? (\n <Button\n className=\"fk:ml-auto\"\n disabled={busy}\n size=\"sm\"\n variant=\"ghost\"\n onClick={() =>\n void perform(async () => {\n await api.refreshPluginTools(toolConnection.id);\n await revalidateKey(`${base}/plugin-connections/${toolConnection.id}/tools`);\n })\n }\n >\n <RefreshCw />\n Refresh\n </Button>\n ) : null}\n </div>\n {plugin.capabilities.automationDelivery ? (\n <p className=\"fk:text-sm fk:text-muted-foreground\">\n Automation delivery to selected channels. This plugin does not expose MCP messaging tools.\n </p>\n ) : null}\n {plugin.capabilities.agentTools && !toolConnection ? (\n <p className=\"fk:text-sm fk:text-muted-foreground\">Connect to discover available tools.</p>\n ) : null}\n {plugin.capabilities.agentTools && toolConnection ? (\n <>\n <p className=\"fk:text-sm fk:text-muted-foreground\">Tools · via {toolConnection.displayName}</p>\n <ConnectionTools base={base} connectionId={toolConnection.id} key={toolConnection.id} />\n </>\n ) : null}\n </section>\n <section className=\"fk:flex fk:flex-col fk:gap-3\">\n <h2 className=\"fk:text-xl fk:font-semibold\">Included skills</h2>\n {data.skills.length === 0 ? (\n <p className=\"fk:text-sm fk:text-muted-foreground\">This plugin includes no skills.</p>\n ) : (\n data.skills.map((skill) => (\n <div key={skill.key}>\n <h3 className=\"fk:font-medium\">{skill.name}</h3>\n <p className=\"fk:text-sm fk:text-muted-foreground\">{skill.description}</p>\n </div>\n ))\n )}\n </section>\n <section className=\"fk:space-y-3\">\n <h2 className=\"fk:text-xl fk:font-semibold\">Used by</h2>\n {plugin.usedBy.length === 0 ? (\n <p className=\"fk:text-sm fk:text-muted-foreground\">No automations visible to you use this plugin yet.</p>\n ) : (\n <ul>\n {plugin.usedBy.map((automation) => (\n <li key={automation.id}>\n <Button\n className=\"fk:pl-0!\"\n variant=\"link\"\n onClick={() => navigate(`../../automations/${automation.id}`, { relative: 'path' })}\n >\n {automation.name}\n </Button>\n </li>\n ))}\n </ul>\n )}\n </section>\n </div>\n </ScrollArea>\n </main>\n );\n}\n"]}
@@ -1,8 +0,0 @@
1
- import'./index.css';import {g,f as f$1,d}from'./chunk-ROCYIGFD.js';import {f,d as d$1}from'./chunk-CMZV7EPC.js';import {na,Nb,Qb,ob,oa,o,ka as ka$1,ta,_ as _$1,$,ca as ca$1,da,aa,ea,s}from'./chunk-YCCFUGWJ.js';import {b,c as c$1,h as h$1,i,k,l,j as j$1,f as f$2}from'./chunk-32ZU4MLE.js';import {b as b$1,c,e}from'./chunk-USNXQOMJ.js';import {b as b$2}from'./chunk-6NRQMG26.js';import {lazy,createContext,useCallback,useState,useRef,useEffect,useMemo,useContext,useTransition,useId,Suspense}from'react';import On,{useSWRConfig}from'swr';import {formatDistance,format}from'date-fns';import {RadarIcon,BotIcon,XIcon,XCircleIcon,LoaderCircle,CheckIcon,CloudUploadIcon,FileTextIcon,DownloadIcon,LinkIcon,MessageSquareIcon,SendIcon,CheckCircle2Icon,CircleSlashIcon,ShieldIcon,DatabaseZapIcon,MessageCircleQuestionIcon,ShieldCheckIcon,TriangleAlertIcon,PlayIcon,ArrowRightIcon,FileIcon,CornerDownRightIcon,MoveRightIcon}from'lucide-react';import {useLocation,Link}from'react-router-dom';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {pipeJsonRender}from'@json-render/core';import {readUIMessageStream,parseJsonEventStream,uiMessageChunkSchema}from'ai';function et(){let{currentProjectId:e}=f(),{mutate:t}=useSWRConfig();return useCallback(a=>{if(!e)return;let n=g(e).approvalsCount;a?t(n,a,{revalidate:true}):t(n),t(g(e).activitySummary());},[e,t])}var Gt=5e3,Wt=150,Ae=new Set;function Yt(e){return async()=>{let t=await fetch(e,{credentials:"include",mode:"cors"});return t.status===404?"missing":t.ok?(await t.json()).approval??"missing":null}}function Kt(e,t,a=d$1){return !e||e.kind!=="schema"||e.status!=="approved"||e.error?false:e.executedAt?(a(t),false):true}function de({approvalId:e,approvalUrl:t,fetchApproval:a,projectId:n,revalidate:r=d$1,sleep:s=l=>new Promise(d=>setTimeout(d,l))}){let l=`${n}:${e}`,d=a??(t?Yt(t):null);!d||Ae.has(l)||(Ae.add(l),(async()=>{try{for(let u=0;u<Wt;u+=1){let c=null;try{c=await d();}catch{c=null;}if(c==="missing"||c!==null&&!Kt(c,n,r))return;await s(Gt);}}finally{Ae.delete(l);}})());}var an={approved:"fk:bg-success/20 fk:text-success",cancelled:"fk:bg-secondary fk:text-secondary-foreground",expired:"fk:bg-secondary fk:text-secondary-foreground",pending:"fk:bg-amber-500/20 fk:text-amber-600",rejected:"fk:bg-destructive/15 fk:text-destructive"};function rn({status:e}){return jsx(b,{className:`fk:border-none fk:h-4.75 fk:text-[0.6875rem] fk:leading-4.5 fk:tracking-wide ${an[e]}`,variant:"secondary",children:e})}function _(e){return e==null?"\u2014":typeof e=="object"?JSON.stringify(e):String(e)}function st({after:e,before:t}){let a=_(t),n=_(e);return a===n?jsx("span",{className:"fk:text-muted-foreground",children:a}):jsxs("span",{className:"fk:inline-flex fk:flex-wrap fk:items-center fk:gap-1.5",children:[jsx("span",{className:"fk:rounded fk:bg-destructive/10 fk:px-1 fk:text-destructive fk:line-through fk:corner-squircle",children:a}),jsx(MoveRightIcon,{className:"fk:size-3 fk:shrink-0 fk:text-muted-foreground"}),jsx("span",{className:"fk:rounded fk:bg-success/15 fk:px-1 fk:text-success fk:corner-squircle",children:n})]})}function sn(e){let t=e.entity??"entities",a=e.affectedCount!==null?` \xB7 ${e.affectedCount.toString()} affected`:"";return e.kind==="create"?`Create ${t}${a}`:e.kind==="update"?`Update ${t}${a}`:e.kind==="delete"?`Delete ${t}${a}`:`Mutation on ${t}${a}`}function on({operation:e}){if(e.rows.length===0)return null;let t=(e.contextColumns??[]).filter(n=>n!=="_id");if(e.kind==="delete")return jsxs(_$1,{children:[jsx($,{children:jsxs(ca$1,{children:[jsx(da,{children:"Records to delete"}),t.map(n=>jsx(da,{children:n},n))]})}),jsx(aa,{children:e.rows.map((n,r)=>jsxs(ca$1,{className:"fk:bg-destructive/5",children:[jsx(ea,{className:"fk:font-mono fk:text-xs fk:text-destructive",children:n.id??_(n.before?._id)}),t.map(s=>jsx(ea,{className:"fk:text-xs fk:text-muted-foreground",children:_(n.before?.[s])},s))]},n.id??r.toString()))})]});let a=e.columns.filter(n=>n!=="_id"&&!t.includes(n));return jsxs(_$1,{children:[jsx($,{children:jsxs(ca$1,{children:[jsx(da,{children:"ID"}),t.map(n=>jsx(da,{children:n},n)),a.map(n=>jsx(da,{children:n},n))]})}),jsx(aa,{children:e.rows.map((n,r)=>jsxs(ca$1,{children:[jsx(ea,{className:"fk:font-mono fk:text-xs fk:text-muted-foreground",children:n.id??"\u2014"}),t.map(s=>jsx(ea,{className:"fk:max-w-72 fk:text-xs fk:text-muted-foreground",children:jsx("span",{className:"fk:line-clamp-3",children:_(n.before?.[s])})},s)),a.map(s=>jsx(ea,{className:"fk:text-xs",children:e.kind==="create"?jsx("span",{className:"fk:rounded fk:bg-success/15 fk:px-1 fk:text-success fk:corner-squircle",children:_(n.after?.[s])}):jsx(st,{after:n.after?.[s],before:n.before?.[s]})},s))]},n.id??r.toString()))})]})}function ln({operations:e,plugin:t,chat:a,title:n}){return jsxs("details",{className:"fk:rounded-md fk:border fk:border-border fk:corner-squircle",children:[jsx("summary",{className:"fk:cursor-pointer fk:px-3 fk:py-2 fk:text-xs fk:font-medium fk:text-muted-foreground",children:n??(a?"Action details":t?"Plugin tool and arguments":`GraphQL documents (${e.length})`)}),jsx("div",{className:"fk:space-y-3 fk:border-t fk:border-border fk:p-3",children:e.map((r,s)=>jsxs("div",{className:"fk:space-y-2",children:[jsx("pre",{className:"fk:overflow-x-auto fk:rounded-md fk:bg-muted fk:p-3 fk:text-xs fk:corner-squircle",children:r.query}),r.variables&&Object.keys(r.variables).length>0?jsx("pre",{className:"fk:overflow-x-auto fk:rounded-md fk:bg-muted/60 fk:p-3 fk:text-xs fk:corner-squircle",children:JSON.stringify(r.variables,null,2)}):null]},s.toString()))})]})}function ot(e){if(e.kind!=="plugin")return null;let a=e.operations[0]?.query.split(`
2
- `)[0]?.trim()?.split("/"),n=a?.at(-1),r=a?.[0];if(!n||!r||a?.length<2)return null;let s=n.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").toLowerCase(),l=r.replace(/[_-]+/g," ").replace(/\b\w/g,p=>p.toUpperCase()),d=e.operations[0]?.query??"",u=/^Connection:\s*(Project|Personal)\s+—\s+(.+)$/m.exec(d);if(u?.[1]&&u[2])return {action:s,app:l,account:u[2].trim(),scope:u[1]==="Project"?"project":"personal"};let c=/^Connection:.*?([^\s<>]+@[^\s<>]+)\s*$/m.exec(d)?.[1];return {action:s,app:l,account:c}}function un(e){let t=ot(e);return t?`${t.action.charAt(0).toUpperCase()}${t.action.slice(1)} in ${t.app}`:e.kind==="exec"?"Run a sandbox command":e.kind==="schema"?e.operationsSummary.replace(/^Schema: /,""):e.kind==="automation"&&e.preview?.automation?`Create the automation \u201C${e.preview.automation.name}\u201D`:e.kind==="automation"&&e.preview?.automationChange?`Change the automation \u201C${e.preview.automationChange.name}\u201D`:e.kind==="plugin"?"Use a connected app":e.operationsSummary}function dn({operation:e}){if(e.rows.length===0)return null;let t=n=>n!=null&&n!==false,a=e.columns.filter(n=>e.rows.some(s=>t(s.before?.[n])||t(s.after?.[n]))?e.kind!=="update"?true:e.rows.some(s=>_(s.before?.[n])!==_(s.after?.[n])):false);return jsx("div",{className:"fk:overflow-x-auto fk:rounded-md fk:border fk:border-border fk:corner-squircle",children:jsxs(_$1,{className:"fk:text-xs",children:[jsx($,{children:jsxs(ca$1,{children:[jsx(da,{className:"fk:h-8",children:e.entity==="scopes"||e.entity==="spaces"||e.entity==="studio"?"Setting":"Attribute"}),a.map(n=>jsx(da,{className:"fk:h-8",children:n},n))]})}),jsx(aa,{children:e.rows.map((n,r)=>jsxs(ca$1,{children:[jsxs(ea,{className:"fk:py-1.5 fk:font-mono fk:text-[0.7rem]",children:[e.kind==="delete"?jsx("span",{className:"fk:line-through fk:text-destructive",children:n.id}):n.id,e.kind==="update"&&n.before===null?jsx(b,{className:"fk:ml-2",variant:"secondary",children:"new"}):null,e.kind==="update"&&n.after===null?jsx(b,{className:"fk:ml-2",variant:"destructive",children:"removed"}):null]}),a.map(s=>jsx(ea,{className:"fk:py-1.5",children:e.kind==="create"?jsx("span",{children:_(n.after?.[s])}):e.kind==="delete"?jsx("span",{className:"fk:text-muted-foreground",children:_(n.before?.[s])}):jsx(st,{after:n.after?.[s],before:n.before?.[s]})},s))]},n.id??r.toString()))})]})})}function fn(e){let t=e.entity??"schema";return t==="scopes"||t==="spaces"||t==="studio"?`Change ${t==="studio"?"Studio settings":t}`:e.kind==="create"?`Add entity ${t} \xB7 ${e.rows.length.toString()} attribute${e.rows.length===1?"":"s"}`:e.kind==="delete"?`Remove entity ${t}`:`Change entity ${t}`}function cn({preview:e}){let t=e.schema;return jsxs("div",{className:"fk:space-y-4",children:[t&&t.breakingChanges.length>0?jsxs("div",{className:"fk:rounded-md fk:border fk:border-destructive/30 fk:bg-destructive/5 fk:p-3 fk:text-sm fk:corner-squircle",children:[jsxs("div",{className:"fk:mb-1 fk:flex fk:items-center fk:gap-2 fk:font-medium fk:text-destructive",children:[jsx(TriangleAlertIcon,{className:"fk:size-4"}),"Breaking changes: existing data becomes inaccessible"]}),jsx("ul",{className:"fk:list-disc fk:pl-5 fk:text-destructive",children:t.breakingChanges.map(a=>jsx("li",{children:a},a))})]}):null,t&&t.warnings.length>0?jsx("div",{className:"fk:rounded-md fk:border fk:border-amber-500/40 fk:bg-amber-500/10 fk:p-3 fk:text-sm fk:corner-squircle",children:jsx("ul",{className:"fk:list-disc fk:pl-5",children:t.warnings.map(a=>jsx("li",{children:a},a))})}):null,e.operations.map((a,n)=>jsxs("div",{className:"fk:space-y-2",children:[jsx("div",{className:`fk:text-sm fk:font-medium ${a.kind==="delete"?"fk:text-destructive":""}`,children:fn(a)}),jsx(dn,{operation:a})]},`${a.entity??""}-${n.toString()}`)),e.operations.length===0?jsx("div",{className:"fk:rounded-md fk:border fk:border-dashed fk:p-3 fk:text-xs fk:text-muted-foreground fk:corner-squircle",children:"No visible entity changes. Review the operations below."}):null]})}function pn(e,t){return e.id===t.id&&e.status===t.status&&e.decidedAt===t.decidedAt&&e.decidedBy===t.decidedBy&&e.executedAt===t.executedAt&&e.error===t.error&&e.reason===t.reason&&e.expiresAt===t.expiresAt&&e.operationsSummary===t.operationsSummary&&e.affectedCount===t.affectedCount&&JSON.stringify(e.preview)===JSON.stringify(t.preview)}function it({api:e,approval:t,onDecided:a}){let[n,r]=useState(t),[s,l]=useState(t),[d,u]=useState(""),[c,p]=useTransition(),[m,b]=useState(false),[y,f]=useState(false),[k,A]=useState(""),C=et();t!==s&&(l(t),pn(t,s)||n.id===t.id&&n.status!=="pending"&&t.status==="pending"||r(t));function P(x){r(x),C(),x.kind==="schema"&&x.status==="approved"&&de({approvalId:x.id,approvalUrl:g(x.projectId).approval(x.id),projectId:x.projectId}),a?.(x);}function K({approved:x,automationEdits:T,force:X=false,reason:D,remember:ge=false}){p(async()=>{u("");try{let R=await e.decideApproval(n.id,{approved:x,...T?{automationEdits:T}:{},force:X,reason:D,remember:ge});if(R.errorCode==="stale_preview"){f(!0),R.approval&&r(R.approval);return}if(f(!1),b(!1),R.approval?P(R.approval):R.success?P({...n,decidedAt:n.decidedAt??new Date().toISOString(),reason:D??n.reason,status:x?"approved":"rejected"}):R.errorCode==="already_decided"&&a?.(n),!R.success&&(R.errorCode!=="already_decided"||!R.approval)){let Z=Array.isArray(R.errorMessage)?R.errorMessage.join(", "):R.errorMessage;u(Z||"Failed to submit the decision.");}}catch(R){u(R instanceof Error?R.message:"Failed to submit the decision.");}});}return {approval:n,decide:K,errorMessage:d,isDeciding:c,isPending:n.status==="pending",isRejectDialogOpen:m,isStale:y,rejectReason:k,setIsRejectDialogOpen:b,setRejectReason:A}}function lt({allowRemember:e=false,askForRejectionReason:t,decide:a,isDeciding:n,isRejectDialogOpen:r,isStale:s,rejectReason:l$1,setIsRejectDialogOpen:d,setRejectReason:u,variant:c}){let p=c==="header",m=p?"fk:px-8 fk:min-w-32":void 0,b=p?"default":"sm",[y,f]=useState(false),k$1=useId();return jsxs(Fragment,{children:[jsxs("div",{className:"fk:flex fk:flex-nowrap fk:items-center fk:gap-2",children:[jsxs(b$2,{className:m,disabled:n,size:b,onClick:()=>a({approved:true,force:s,remember:e&&y}),children:[n?jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}):jsx(CheckIcon,{className:"fk:size-4"}),s?"Approve anyway":"Approve"]}),jsxs(b$2,{className:m,disabled:n,size:b,variant:"outline",onClick:()=>{t?(u(""),d(true)):a({approved:false});},children:[jsx(XIcon,{className:"fk:size-4"}),"Reject"]}),e?jsxs("label",{className:"fk:ml-1 fk:flex fk:cursor-pointer fk:items-center fk:gap-1.5 fk:whitespace-nowrap fk:text-xs fk:text-muted-foreground",htmlFor:k$1,children:[jsx(o,{checked:y,id:k$1,onCheckedChange:A=>f(A===true)}),"Always allow this tool for this automation"]}):null]}),t?jsx(c$1,{open:r,onOpenChange:d,children:jsxs(h$1,{children:[jsxs(i,{children:[jsx(k,{children:"Reject this proposal?"}),jsx(l,{children:"The mutation will not be executed. The agent receives your reason and can adapt its plan."})]}),jsx(ka$1,{placeholder:"Optional reason for the agent...",value:l$1,onChange:A=>u(A.target.value)}),jsxs(j$1,{children:[jsx(b$2,{disabled:n,size:"sm",variant:"outline",onClick:()=>d(false),children:"Cancel"}),jsxs(b$2,{disabled:n,size:"sm",variant:"destructive",onClick:()=>a({approved:false,reason:l$1.trim()||void 0}),children:[n?jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}):jsx(ArrowRightIcon,{className:"fk:size-4"}),"Reject proposal"]})]})]})}):null]})}var mn={always:"Every finished run",failures:"Failures only",never:"Never",when_flagged:"Results that need attention"};function kn(e){return e.visibility==="personal"?"Only you":e.visibility==="space"?`Space: ${e.spaceLabel??"unknown"}`:"Everyone in the project"}function gn({approval:e,instructions:t,isPending:a,proposal:n,onInstructionsChange:r}){let s=useId(),l=e.createdAutomation??null,d=[...n.replacesMonitor?[{label:"Replaces",value:`The monitor \u201C${n.replacesMonitor}\u201D, which stops once this exists`}]:[],{label:"Runs",value:n.triggers.join(`
3
- `)},{label:"Visible to",value:kn(n)},{label:"Data changes",value:n.mutationPolicy==="auto_approve"?"Applied without review":"Wait for approval"},{label:"Notifications",value:`${mn[n.notifyRule]}${n.notifyCreator?", to you":""}${n.subscribers.length>0?` and ${n.subscribers.join(", ")}`:""}`},...n.plugins.length>0?[{label:"Plugins",value:n.plugins.map(u=>[u.account?`${u.name} as ${u.account}`:u.name,u.deliveryChannels.length>0?`posting to ${u.deliveryChannels.join(", ")}`:""].filter(Boolean).join(", ")).join(`
4
- `)}]:[],...n.skills.length>0?[{label:"Skills",value:n.skills.join(", ")}]:[],...n.customTools.length>0?[{label:"Custom tools",value:n.customTools.join(", ")}]:[],{label:"Model",value:n.modelLabel}];return jsxs("div",{className:"fk:space-y-4",children:[n.mutationPolicy==="auto_approve"?jsxs("div",{className:"fk:flex fk:items-start fk:gap-2 fk:rounded-md fk:border fk:border-amber-500/40 fk:bg-amber-500/10 fk:p-3 fk:text-sm fk:corner-squircle",role:"status",children:[jsx(TriangleAlertIcon,{className:"fk:mt-0.5 fk:size-4 fk:shrink-0 fk:text-amber-600"}),jsxs("span",{children:["Every run will change data",n.plugins.length>0?" and call these plugins":""," without asking anyone first. Reject and ask for review if that is not what you want."]})]}):null,jsx("dl",{className:"fk:grid fk:grid-cols-[max-content_1fr] fk:gap-x-4 fk:gap-y-1.5 fk:text-sm",children:d.map(u=>jsxs("div",{className:"fk:contents",children:[jsx("dt",{className:"fk:text-muted-foreground",children:u.label}),jsx("dd",{className:"fk:whitespace-pre-line",children:u.value})]},u.label))}),jsxs("div",{className:"fk:space-y-1.5",children:[jsx("label",{className:"fk:text-sm fk:font-medium",htmlFor:s,children:"Instructions"}),a&&r?jsxs(Fragment,{children:[jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"The automation never sees this chat, so these instructions are all it has to go on. Edit them before creating it."}),jsx(ka$1,{className:"fk:min-h-40 fk:text-sm",id:s,value:t,onChange:u=>r(u.target.value)})]}):jsx("p",{className:"fk:whitespace-pre-wrap fk:rounded-md fk:border fk:p-3 fk:text-sm fk:corner-squircle",id:s,children:t})]}),l?jsxs("div",{className:"fk:flex fk:flex-wrap fk:gap-2",children:[jsx(b$2,{asChild:true,size:"sm",variant:"outline",children:jsx(Link,{to:`/${e.projectId}/ai/automations/${l.automationId}`,children:"Open the automation"})}),l.runId?jsx(b$2,{asChild:true,size:"sm",variant:"ghost",children:jsx(Link,{to:`/${e.projectId}/ai/automations/${l.automationId}/runs/${l.runId}`,children:"View its first run"})}):null]}):null]})}function vn({approval:e,change:t}){let a=t.changes.filter(r=>r.field!=="instructions"),n=t.changes.find(r=>r.field==="instructions");return jsxs("div",{className:"fk:space-y-4",children:[a.length>0?jsx("dl",{className:"fk:grid fk:grid-cols-[max-content_1fr] fk:gap-x-4 fk:gap-y-2 fk:text-sm",children:a.map(r=>jsxs("div",{className:"fk:contents",children:[jsx("dt",{className:"fk:text-muted-foreground",children:r.label}),jsxs("dd",{className:"fk:space-y-0.5",children:[jsx("div",{className:"fk:whitespace-pre-line fk:text-muted-foreground fk:line-through",children:r.before}),jsx("div",{className:"fk:whitespace-pre-line",children:r.after})]})]},r.field))}):null,n?jsx("div",{className:"fk:grid fk:gap-3 fk:md:grid-cols-2",children:[{label:"Current instructions",muted:true,text:n.before},{label:"New instructions",muted:false,text:n.after}].map(r=>jsxs("div",{className:"fk:min-w-0 fk:space-y-1.5",children:[jsx("div",{className:"fk:text-sm fk:font-medium",children:r.label}),jsx("p",{className:`fk:whitespace-pre-wrap fk:rounded-md fk:border fk:p-3 fk:text-sm fk:corner-squircle${r.muted?" fk:text-muted-foreground":""}`,children:r.text})]},r.label))}):null,jsx(b$2,{asChild:true,size:"sm",variant:"outline",children:jsx(Link,{to:`/${e.projectId}/ai/automations/${t.automationId}`,children:"Open the automation"})})]})}function ut({decide:e,instructions:t,isDeciding:a,proposal:n}){let r=t.trim(),s=r!==n.instructions.trim()?{instructions:r}:{};return jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:[jsxs(b$2,{disabled:a||r.length===0,size:"sm",variant:n.runOnceAfterCreate?"outline":"default",onClick:()=>e({approved:true,automationEdits:{...s,runOnce:false}}),children:[a?jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}):jsx(CheckIcon,{className:"fk:size-4"}),"Create"]}),jsxs(b$2,{disabled:a||r.length===0,size:"sm",variant:n.runOnceAfterCreate?"default":"outline",onClick:()=>e({approved:true,automationEdits:{...s,runOnce:true}}),children:[jsx(PlayIcon,{className:"fk:size-4"}),"Create and run once now"]}),jsxs(b$2,{disabled:a,size:"sm",variant:"outline",onClick:()=>e({approved:false}),children:[jsx(XIcon,{className:"fk:size-4"}),"Reject"]})]})}function dt({approval:e,automationInstructions:t,chat:a,errorMessage:n,isPending:r,isStale:s,onAutomationInstructionsChange:l}){let{preview:d}=e,u=a?ot(e):null;return jsxs("div",{className:"fk:min-w-0 fk:max-w-full fk:space-y-4",children:[jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:[jsx(rn,{status:e.status}),e.kind==="schema"?jsx(b,{variant:"outline",children:"Schema change"}):null,e.kind==="automation"?jsx(b,{variant:"outline",children:d?.automationChange?"Automation change":"New automation"}):null,jsx("span",{className:"fk:text-sm fk:font-medium",children:a?un(e):e.operationsSummary})]}),jsxs("div",{className:"fk:text-xs fk:text-muted-foreground",children:[e.automationName?`${e.automationName} \xB7 `:"","requested ",formatDistance(new Date(e.requestedAt),new Date,{addSuffix:true}),r?` \xB7 expires ${formatDistance(new Date(e.expiresAt),new Date,{addSuffix:true})}`:"",e.decidedAt?` \xB7 decided ${format(new Date(e.decidedAt),"PPpp")}`:""]}),s?jsxs("div",{className:"fk:flex fk:items-start fk:gap-2 fk:rounded-md fk:border fk:border-amber-500/40 fk:bg-amber-500/10 fk:p-3 fk:text-sm fk:corner-squircle",children:[jsx(TriangleAlertIcon,{className:"fk:mt-0.5 fk:size-4 fk:shrink-0 fk:text-amber-600"}),jsx("span",{children:"The affected data changed since this proposal was created. The preview below has been refreshed \u2014 review it and approve again to proceed."})]}):null,e.kind==="automation"&&d?.automation?jsx(gn,{approval:e,instructions:t??d.automation.instructions,isPending:r,proposal:d.automation,onInstructionsChange:l}):e.kind==="automation"&&d?.automationChange?jsx(vn,{approval:e,change:d.automationChange}):e.kind==="schema"&&d?jsx(cn,{preview:d}):d&&d.operations.length>0?jsx("div",{className:"fk:space-y-4",children:d.operations.map((c,p)=>jsxs("div",{className:"fk:space-y-2",children:[jsx("div",{className:"fk:text-sm fk:font-medium",children:sn(c)}),c.kind==="delete"&&c.affectedCount!==null?jsxs("div",{className:"fk:rounded-md fk:border fk:border-destructive/30 fk:bg-destructive/5 fk:p-3 fk:text-sm fk:text-destructive fk:corner-squircle",children:[c.affectedCount.toString()," record",c.affectedCount===1?"":"s"," will be permanently deleted."]}):null,jsx(on,{operation:c}),c.truncated?jsxs("div",{className:"fk:text-xs fk:text-muted-foreground",children:["Preview limited to the first ",c.rows.length.toString()," rows."]}):null]},p.toString()))}):jsx("div",{className:"fk:rounded-md fk:border fk:border-dashed fk:p-3 fk:text-xs fk:text-muted-foreground fk:corner-squircle",children:a?u?`This action uses ${u.scope==="project"?"the project's":"your"} ${u.app} account${u.account?` (${u.account})`:""}. Check the details before deciding.`:"The assistant wants to make this change. Check the details before deciding.":e.kind==="plugin"?"Review the account, tool, and arguments before allowing this external call.":e.kind==="exec"?"This command runs inside the run's ephemeral sandbox but may send data out or reach other hosts. Review the command line before allowing it.":"No structured preview is available for this proposal. Review the raw GraphQL documents below."}),e.kind==="automation"?null:jsx(ln,{chat:a,operations:e.operations,plugin:e.kind==="plugin"||e.kind==="exec",title:e.kind==="exec"?"Command and options":e.kind==="schema"?"Operations":void 0}),e.reason?jsxs("div",{className:"fk:text-sm",children:[jsx("span",{className:"fk:font-medium",children:"Reason:"})," ",e.reason]}):null,e.error?jsxs("div",{className:"fk:rounded-md fk:border fk:border-destructive/30 fk:bg-destructive/5 fk:p-3 fk:text-sm fk:corner-squircle",children:["Execution failed: ",e.error]}):null,e.executedAt&&!e.error?jsxs("div",{className:"fk:flex fk:items-center fk:gap-2 fk:text-sm fk:text-success",children:[jsx(CheckIcon,{className:"fk:size-4"}),"Executed ",format(new Date(e.executedAt),"PPpp")]}):null,n?jsx("div",{className:"fk:text-sm fk:text-destructive",children:n}):null]})}function ft({api:e,approval:t,chat:a,onDecided:n}){let{approval:r,decide:s,errorMessage:l,isDeciding:d,isPending:u,isRejectDialogOpen:c,isStale:p,rejectReason:m,setIsRejectDialogOpen:b,setRejectReason:y}=it({api:e,approval:t,onDecided:n}),f=r.kind==="automation"?r.preview?.automation??null:null,[k,A]=useState(f?.instructions??"");return jsxs(Fragment,{children:[jsx(dt,{approval:r,automationInstructions:f?k:void 0,chat:a,errorMessage:l,isPending:u,isStale:p,onAutomationInstructionsChange:f?A:void 0}),u&&f?jsx("div",{className:"fk:mt-4",children:jsx(ut,{decide:s,instructions:k,isDeciding:d,proposal:f})}):u?jsx("div",{className:"fk:mt-4",children:jsx(lt,{allowRemember:!a&&r.kind==="plugin"&&!!r.automationId,askForRejectionReason:!a,decide:s,isDeciding:d,isRejectDialogOpen:c,isStale:p,rejectReason:m,setIsRejectDialogOpen:b,setRejectReason:y,variant:"inline"})}):null]})}function nr({api:e,approval:t,onClose:a,onDecided:n}){let{approval:r,decide:s,errorMessage:l,isDeciding:d,isPending:u,isRejectDialogOpen:c,isStale:p,rejectReason:m,setIsRejectDialogOpen:b,setRejectReason:y}=it({api:e,approval:t,onDecided:n}),f=r.kind==="automation"?r.preview?.automation??null:null,[k,A]=useState(f?.instructions??"");return jsx(na,{actions:u&&f?jsx(ut,{decide:s,instructions:k,isDeciding:d,proposal:f}):u?jsx(lt,{allowRemember:r.kind==="plugin"&&!!r.automationId,askForRejectionReason:true,decide:s,isDeciding:d,isRejectDialogOpen:c,isStale:p,rejectReason:m,setIsRejectDialogOpen:b,setRejectReason:y,variant:"header"}):null,depth:0,isFocused:true,onClose:a,title:f?"Automation proposal":r.preview?.automationChange?"Automation change":"Mutation proposal",children:jsx(dt,{approval:r,automationInstructions:f?k:void 0,chat:false,errorMessage:l,isPending:u,isStale:p,onAutomationInstructionsChange:f?A:void 0})})}var yn="Approved by Flexkit Jev policy",hn="Approved by automation tool allow rule",bn=new Set(["data-create-sandbox","data-execute-graphql","data-load-skill","data-plan","data-plugin-call","data-run-command","data-search-schema","data-update-memory","data-validate-graphql","data-web-search"]);function te(e){return bn.has(e)}function h(e){return e.data}function Te(e){return !e.decidedBy&&!!(e.reason?.startsWith(yn)||e.reason?.startsWith(hn))}function H(e,t=72){let a=e.trim();if(a.length<=t)return a;let n=a.slice(0,t),r=n.lastIndexOf(" ");return `${(r>=Math.floor(t*.6)?n.slice(0,r):n).trimEnd()}\u2026`}function xn(e){return e.replace(/^#{1,6}\s+/,"").replace(/^(?:[-*+]|\d+[.)])\s+/,"").replace(/!?\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/(\*\*|__)(.*?)\1/g,"$2").replace(/(\*|_)(.*?)\1/g,"$2").replace(/`([^`]*)`/g,"$1").replace(/[*_`#>]/g,"").replace(/\s+/g," ").trim().replace(/[.:]+$/,"")}function wn(e){let t=e.lastIndexOf(`
5
- `),a=-1,n=/[.!?](?=\s)/g,r;for(;(r=n.exec(e))!==null;)a=r.index;let s=Math.max(t,a);return s<0?"":e.slice(0,s+1)}function An(e,t){let n=(wn(e)).split(/\r?\n/).map(u=>u.trim()).filter(Boolean),r=n[n.length-1];if(!r)return null;let l=/^\*\*(.+?)\*\*:?$/.exec(r)?.[1]??/^#{1,6}\s+(.+)$/.exec(r)?.[1]??/^(.+?[.!?])(?:\s|$)/.exec(r)?.[1]??r,d=xn(l);return !d||/^reasoning$/i.test(d)?null:H(d)}function ct(e){return e.replace(/[_-]+/g," ").trim()}function Rn(e){if(e.type==="data-load-skill"){let t=h(e);return t.status!=="loading"?null:t.skillName?H(`Loading skill "${t.skillName}"`):"Loading skill"}if(e.type==="data-search-schema")return h(e).status==="loading"?"Searching schema":null;if(e.type==="data-validate-graphql")return h(e).status==="loading"?"Validating GraphQL query":null;if(e.type==="data-execute-graphql"){let t=h(e);return t.status!=="loading"?null:t.operationType==="mutation"?"Executing GraphQL mutation":"Executing GraphQL query"}if(e.type==="data-update-memory")return h(e).status==="loading"?"Updating memory":null;if(e.type==="data-web-search"){let t=h(e);return t.status!=="loading"?null:t.query?H(`Searching the web for "${t.query}"`):"Searching the web"}if(e.type==="data-run-command"){let t=h(e);return ["executing","running","waiting"].includes(t.status)?H(`Running ${[t.command,...t.args].join(" ")}`):null}if(e.type==="data-create-sandbox")return h(e).status==="loading"?"Creating sandbox":null;if(e.type==="data-plugin-call"){let t=h(e);return t.status!=="loading"?null:H(`Calling ${t.pluginId}: ${ct(t.tool)}`)}if(e.type==="data-subtask"){let t=h(e);return t.status==="running"?H(`Running subtask: ${t.title}`):null}return null}var Sn=new Set(["data-execute-graphql","data-search-schema","data-validate-graphql"]);function fe(e){if(!te(e.type)||e.type==="data-plan"||Sn.has(e.type))return null;let t=h(e);if(t.status!=="error")return null;if(t.error?.message)return t.error.message;switch(e.type){case "data-web-search":return "Failed to search the web";case "data-run-command":return `Command failed: ${String(t.command??"")}`.trim();case "data-create-sandbox":return "Failed to create sandbox";case "data-load-skill":return "Failed to load skill";case "data-update-memory":return "Failed to update memory";case "data-plugin-call":return `Plugin call failed: ${String(t.pluginId??"")}: ${ct(String(t.tool??""))}`;default:return "The tool call failed"}}function ce(e){if(e.type==="step-start"||e.type==="reasoning")return true;if(te(e.type))return fe(e)===null;if(e.type==="data-mutation-approval"){let t=h(e);return Te(t)&&t.status!=="error"}return false}function ee(e){if(!e)return null;for(let t=e.parts.length-1;t>=0;t--){let a=e.parts[t];if(a?.type!=="data-plan")continue;let n=h(a),r=n.steps.findIndex(s=>s.status==="in_progress");return r<0?null:H(`Step ${(r+1).toString()} of ${n.steps.length.toString()}: ${n.steps[r].step}`)}return null}function Nn(e){if(!e)return null;for(let t=e.parts.length-1;t>=0;t--){let a=e.parts[t];if(!(!a||a.type==="step-start"))return a.type==="reasoning"?a.state==="streaming"?An(a.text)??ee(e):ee(e):a.type==="data-mutation-approval"?h(a).status==="pending"?"Awaiting approval":ee(e):a.type==="data-user-question"?h(a).status==="pending"?"Waiting for your answer":ee(e):a.type==="text"?null:Rn(a)??ee(e)}return null}function De(e){return e?e.parts.some(t=>t.type!=="data-mutation-approval"?false:h(t).status==="pending"):false}function Ie(e,t={}){let a=false,n=[];for(let r of e.parts){if(r.type!=="data-mutation-approval"){n.push(r);continue}let s=h(r);if(s.status!=="pending"){n.push(r);continue}a=true;let l=t[s.approvalId];l&&l!=="pending"&&n.push({...r,data:{...s,status:l}});}return a?{...e,parts:n}:e}function pt(e,t){if(!e)return [];let a=[],n=t?.pendingOnly??false;for(let r of e.parts){if(r.type!=="data-mutation-approval")continue;let s=h(r);n&&s.status!=="pending"||a.push(s.approvalId);}return a}function Cn(e){return pt(e,{pendingOnly:true})}function Me(e){return !!e?.parts.some(t=>t.type==="data-user-question"&&h(t).status==="pending")}function mt(e){return e.map(()=>({other:"",selected:[]}))}function kt(e,t,a){return e.multiSelect?{...t,selected:t.selected.includes(a)?t.selected.filter(n=>n!==a):[...t.selected,a]}:{other:"",selected:[a]}}function gt(e,t,a){return e.multiSelect?{...t,other:a}:{other:a,selected:a.trim()?[]:t.selected}}function vt(e){let t=[];for(let a of e){let n=a.other.trim();if(a.selected.length===0&&!n)return null;t.push(n?{other:n,selected:a.selected}:{selected:a.selected});}return t}function yt(e){return e&&[...e.selected,...e.other?[`\u201C${e.other}\u201D`]:[]].join(", ")||"\u2014"}var ht=20*1024*1024,pr=10,xt=new Set(["css","csv","gif","gql","graphql","htm","html","jpeg","jpg","js","json","jsx","log","markdown","md","mjs","ndjson","pdf","png","py","sql","ts","tsv","tsx","txt","webp","xml","yaml","yml"]),wt=new Set(["application/pdf","image/gif","image/jpeg","image/png","image/webp"]),mr=[...[...xt].map(e=>`.${e}`),...wt].join(",");function At(e){let t=e.lastIndexOf(".");return t<=0?"":e.slice(t+1).toLowerCase()}function In(e){let t=At(e.name);return (t?xt.has(t):wt.has(e.type))?e.size===0?`"${e.name}" is empty.`:e.size>ht?`"${e.name}" exceeds the ${String(Math.round(ht/(1024*1024)))} MB limit.`:null:`"${e.name}" is not supported. Attach images, PDFs, or text files.`}async function Mn(e){let a=await(await fetch(e.url)).blob();return new File([a],e.filename??"file",{type:e.mediaType||a.type})}function kr(e,t){let{attachments:a}=Nb(),n=useRef({}),[,r]=useState(0),s=useCallback(()=>r(c=>c+1),[]),l=useRef(a.remove);l.current=a.remove;let d=useRef(t);d.current=t,useEffect(()=>{let c=new Set(a.files.map(p=>p.id));for(let[p,m]of Object.entries(n.current))c.has(p)||(m.controller.abort(),delete n.current[p]);for(let p of a.files){if(n.current[p.id])continue;let m=new AbortController,b={controller:m,status:"uploading"};n.current[p.id]=b,(async()=>{try{let y=await Mn(p),f=In(y);if(f)throw new Error(f);let k=await e.uploadAgentChatAttachment(y,m.signal);if(m.signal.aborted)return;b.attachment=k,b.status="done";}catch(y){if(m.signal.aborted)return;b.status="error",delete n.current[p.id],l.current(p.id),d.current(y instanceof Error?y.message:"The file could not be uploaded.");}finally{s();}})();}s();},[e,a.files,s]);let u=Object.values(n.current).some(c=>c.status==="uploading");return {getUploaded:c=>c.map(p=>n.current[p]?.attachment).filter(p=>!!p),isUploading:u,isUploadingFile:c=>n.current[c]?.status==="uploading"}}function $e(e){return !!e?.startsWith("image/")}function Rt({image:e,onClose:t}){return jsx(c$1,{onOpenChange:a=>a?void 0:t(),open:e!==null,children:jsxs(h$1,{className:"fk:h-dvh fk:w-dvw fk:max-w-none fk:sm:max-w-none fk:rounded-none fk:border-0 fk:bg-black/90 fk:p-4 fk:shadow-none fk:flex fk:items-center fk:justify-center fk:corner-squircle",showCloseButton:false,children:[jsx(k,{className:"fk:sr-only",children:e?.filename??"Image preview"}),e?jsx("img",{alt:e.filename,className:"fk:block fk:h-auto fk:w-auto fk:max-h-full fk:max-w-full fk:object-contain",src:e.url}):null,jsx(f$2,{"aria-label":"Close preview",className:"fk:absolute fk:top-4 fk:right-4 fk:flex fk:size-9 fk:items-center fk:justify-center fk:rounded-full fk:bg-white/10 fk:text-white fk:transition-colors fk:hover:bg-white/20 fk:focus-visible:outline-none fk:focus-visible:ring-2 fk:focus-visible:ring-white/60 fk:corner-squircle",children:jsx(XIcon,{className:"fk:size-5"})})]})})}function St({label:e,onRemove:t}){return jsx("button",{"aria-label":e,className:"fk:absolute fk:top-1 fk:right-1 fk:z-10 fk:flex fk:size-5 fk:items-center fk:justify-center fk:rounded-full fk:border fk:border-border fk:bg-background fk:text-foreground fk:shadow-sm fk:transition-colors fk:hover:bg-accent fk:focus-visible:outline-none fk:focus-visible:ring-2 fk:focus-visible:ring-ring fk:corner-squircle",onClick:a=>{a.stopPropagation(),t();},type:"button",children:jsx(XIcon,{className:"fk:size-3"})})}function Nt({image:e,isUploading:t=false,onOpen:a,onRemove:n,sizeClassName:r}){return jsxs("div",{className:`fk:relative fk:shrink-0 fk:overflow-hidden fk:rounded-xl fk:bg-muted ${r} fk:corner-squircle`,children:[jsx("button",{"aria-label":`Preview ${e.filename}`,className:"fk:block fk:size-full fk:cursor-zoom-in fk:focus-visible:outline-none fk:focus-visible:ring-2 fk:focus-visible:ring-ring",onClick:a,type:"button",children:jsx("img",{alt:e.filename,className:"fk:size-full fk:object-cover",src:e.url})}),t?jsx("div",{className:"fk:pointer-events-none fk:absolute fk:inset-0 fk:flex fk:items-center fk:justify-center fk:bg-background/60",children:jsx(ta,{className:"fk:size-4"})}):null,n?jsx(St,{label:`Remove ${e.filename}`,onRemove:n}):null]})}function En(e,t){let a=At(e);if(a)return a.toUpperCase();let n=t?.split("/")[1]?.split("+")[0];return n?n.toUpperCase():"FILE"}function Ct({file:e,href:t,isUploading:a=false,onRemove:n}){let r=jsxs(Fragment,{children:[jsx("div",{className:"fk:flex fk:size-10 fk:shrink-0 fk:items-center fk:justify-center fk:rounded-lg fk:bg-muted fk:text-muted-foreground fk:corner-squircle",children:a?jsx(ta,{className:"fk:size-4"}):jsx(FileIcon,{className:"fk:size-5"})}),jsxs("div",{className:"fk:min-w-0 fk:pr-4 fk:text-left",children:[jsx("div",{className:"fk:truncate fk:text-sm fk:font-medium fk:text-foreground",children:e.filename}),jsx("div",{className:"fk:truncate fk:text-xs fk:text-muted-foreground",children:En(e.filename,e.mediaType)})]})]}),s="fk:flex fk:h-14 fk:max-w-64 fk:items-center fk:gap-2.5 fk:rounded-xl fk:border fk:border-border fk:bg-background fk:px-2 fk:corner-squircle";return jsxs("div",{className:"fk:relative fk:shrink-0",children:[t?jsx("a",{className:`${s} fk:transition-colors fk:hover:bg-accent/50 fk:focus-visible:outline-none fk:focus-visible:ring-2 fk:focus-visible:ring-ring`,href:t,rel:"noreferrer",target:"_blank",children:r}):jsx("div",{className:s,children:r}),n?jsx(St,{label:`Remove ${e.filename}`,onRemove:n}):null]})}function gr({uploads:e}){let t=Qb(),[a,n]=useState(null);return t.files.length===0?null:jsxs(Fragment,{children:[jsx("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:t.files.map(r=>{if($e(r.mediaType)&&r.url){let s={filename:r.filename??"Image",url:r.url};return jsx(Nt,{image:s,isUploading:e.isUploadingFile(r.id),onOpen:()=>n(s),onRemove:()=>t.remove(r.id),sizeClassName:"fk:size-14"},r.id)}return jsx(Ct,{file:{filename:r.filename??"file",mediaType:r.mediaType},isUploading:e.isUploadingFile(r.id),onRemove:()=>t.remove(r.id)},r.id)})}),jsx(Rt,{image:a,onClose:()=>n(null)})]})}function vr(e){return Array.isArray(e)?e.filter(t=>t.type==="file"&&typeof t.url=="string").map(t=>({filename:t.filename??"file",mediaType:t.mediaType??"application/octet-stream",sizeBytes:t.sizeBytes??0,url:t.url??""})):[]}function Pt({attachments:e}){let[t,a]=useState(null);if(e.length===0)return null;let n=e.filter(s=>$e(s.mediaType)),r=e.filter(s=>!$e(s.mediaType));return jsxs("div",{className:"fk:flex fk:flex-col fk:items-end fk:gap-2",children:[n.length>0?jsx("div",{className:"fk:flex fk:flex-wrap fk:justify-end fk:gap-2",children:n.map(s=>jsx(Nt,{image:s,onOpen:()=>a(s),sizeClassName:"fk:size-24"},s.url))}):null,jsx(Rt,{image:t,onClose:()=>a(null)}),r.length>0?jsx("div",{className:"fk:flex fk:flex-wrap fk:justify-end fk:gap-2",children:r.map(s=>jsx(Ct,{file:s,href:s.url},s.url))}):null]})}function Nr(e){let t=(Array.isArray(e.parts)?e.parts:[]).find(a=>a.type==="data-monitor-event");return t&&typeof t.data=="object"&&t.data!==null?t.data:null}function It({data:e,error:t}){let a=e.total-e.events.length;return jsxs("div",{className:"fk:mr-auto fk:w-full fk:max-w-[85%] fk:space-y-1.5 fk:rounded-lg fk:border fk:border-border fk:bg-muted/40 fk:px-3.5 fk:py-2.5 fk:text-sm fk:corner-squircle",children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-2 fk:text-xs fk:text-muted-foreground",children:[jsx(RadarIcon,{className:"fk:size-3.5 fk:shrink-0"}),jsxs("span",{className:"fk:truncate",children:["Monitor \xB7 ",e.description]})]}),jsxs("ul",{className:"fk:space-y-0.5",children:[e.events.map(n=>jsx("li",{children:n.summary},n.id)),a>0?jsxs("li",{className:"fk:text-muted-foreground",children:["\u2026and ",a.toString()," more"]}):null]}),t?jsx("p",{className:"fk:text-xs fk:text-destructive",children:t}):null]})}function Cr({api:e$1,chatId:t,onTurnIntoAutomation:a,projectId:n,sending:r=false}){let{data:s,mutate:l}=On(g(n).agentChat(t),f$1,{revalidateOnMount:false}),[d,u]=useState(null),c$1=s?.monitors??[];if(c$1.length===0)return null;async function p(m){u(m.id);try{await e$1.stopAgentChatMonitor(t,m.id),await l();}catch{oa.error("Unable to stop the monitor.");}finally{u(null);}}return jsx("div",{className:"fk:mx-auto fk:mb-2 fk:flex fk:max-w-4xl fk:flex-wrap fk:gap-2",children:c$1.map(m=>jsxs("div",{className:"fk:flex fk:max-w-full fk:items-center fk:gap-2 fk:rounded-full fk:border fk:border-border fk:py-1 fk:pl-3 fk:pr-1 fk:text-xs fk:text-muted-foreground",children:[jsx(RadarIcon,{className:"fk:size-3.5 fk:shrink-0 fk:animate-pulse"}),jsxs("span",{className:"fk:truncate",children:["Watching: ",m.description," \xB7 expires ",formatDistance(new Date(m.expiresAt),new Date,{addSuffix:true})]}),a&&m.sourceType&&m.sourceType!=="job"?jsxs(b$1,{children:[jsx(c,{asChild:true,children:jsx(b$2,{"aria-label":`Turn ${m.description} into an automation`,className:"fk:size-6 fk:rounded-full",disabled:r,size:"icon",variant:"ghost",onClick:()=>a(m),children:jsx(BotIcon,{className:"fk:size-3.5"})})}),jsx(e,{children:"Turn into automation"})]}):null,jsxs(b$1,{children:[jsx(c,{asChild:true,children:jsx(b$2,{"aria-label":`Stop watching ${m.description}`,className:"fk:size-6 fk:rounded-full",disabled:d===m.id,size:"icon",variant:"ghost",onClick:()=>{p(m);},children:jsx(XIcon,{className:"fk:size-3.5"})})}),jsx(e,{children:"Stop watching"})]})]},m.id))})}var W=class extends Error{},pe=class extends Error{};function Mt({url:e,signal:t,state:a,onState:n,wake:r,fetchStream:s=fetch,retryMs:l=2e3}){let d=0,u=0,c=new TransformStream,p=c.writable.getWriter(),m=new AbortController;p.closed.catch(k=>m.abort(k));let b=()=>{m.abort(t.reason),p.abort(t.reason).catch(()=>{});};t.addEventListener("abort",b,{once:true}),t.aborted&&b();let y=()=>new Promise(k=>{let A=()=>{clearTimeout(C),m.signal.removeEventListener("abort",A),r?.removeEventListener("wake",A),k();},C=setTimeout(A,l);m.signal.addEventListener("abort",A,{once:true}),r?.addEventListener("wake",A,{once:true}),m.signal.aborted&&A();});async function f(){try{for(await p.write({type:"start"});!m.signal.aborted;){try{let k=await s(`${e}${e.includes("?")?"&":"?"}wire=2&startIndex=${d}`,{credentials:"include",signal:m.signal});if(k.status===404){n("unavailable"),await p.close();return}if(k.status===401||k.status===403)throw new pe("Stream access denied");if(!k.ok||!k.body)throw new Error(`Stream request failed: ${k.status}`);if(k.headers.get("x-flexkit-stream-version")!=="2")throw await k.body.cancel(),new W("Backend uses legacy replay");n("streaming");let A=k.body.pipeThrough(new TextDecoderStream).getReader(),C="",P=!1;try{for(;!m.signal.aborted;){let{value:K,done:x}=await A.read();if(x)break;C+=K;let T;for(;(T=C.indexOf(`
6
- `))>=0;){let X=C.slice(0,T);if(C=C.slice(T+1),!X)continue;let D=JSON.parse(X);if(!Number.isSafeInteger(D.index)||D.index<0)throw new Error("Invalid replay cursor");if(!(D.index<d)){if(D.index!==d)throw new Error("Replay cursor gap");D.chunk&&await p.write(D.chunk),d=D.index+1,u=0,D.chunk?.type==="finish"&&D.chunk.messageMetadata?.flexkitTerminal&&(P=!0);}}if(C.length>2e6)throw new Error("Oversized replay frame");if(P)break}}finally{await A.cancel().catch(()=>{}),A.releaseLock();}if(P||a().terminal&&!C){await p.write({type:"finish"}),await p.close(),n("finished");return}}catch(k){if(m.signal.aborted||k instanceof W||k instanceof pe||++u>=5)throw k}do n(a().paused?"paused":"streaming"),await y();while(!m.signal.aborted&&a().paused&&!a().terminal)}}catch(k){await p.abort(k).catch(()=>{});}finally{t.removeEventListener("abort",b),p.releaseLock();}}return f(),pipeJsonRender(c.readable)}var qn={pending:"Waiting for an answer.",cancelled:"The turn was stopped before you answered.",dismissed:"You skipped these questions.",expired:"Nobody answered in time."};function Bn({description:e,label:t,multiSelect:a,onClick:n,selected:r}){return jsxs("button",{"aria-checked":r,className:`fk:flex fk:w-full fk:items-start fk:gap-2.5 fk:rounded-lg fk:border fk:px-3 fk:py-2 fk:text-left fk:transition-colors fk:corner-squircle ${r?"fk:border-primary fk:bg-primary/5":"fk:border-border fk:hover:bg-muted/60"}`,onClick:n,role:a?"checkbox":"radio",type:"button",children:[jsx("span",{className:`fk:mt-0.5 fk:flex fk:size-4 fk:shrink-0 fk:items-center fk:justify-center fk:border ${a?"fk:rounded-sm":"fk:rounded-full"} ${r?"fk:border-primary fk:bg-primary fk:text-primary-foreground":"fk:border-muted-foreground/50"}`,children:r?jsx(CheckIcon,{className:"fk:size-3"}):null}),jsxs("span",{className:"fk:min-w-0",children:[jsx("span",{className:"fk:block fk:text-sm fk:font-medium",children:t}),e?jsx("span",{className:"fk:block fk:text-xs fk:text-muted-foreground",children:e}):null]})]})}function Qn({disabled:e,draft:t,onChange:a,question:n}){return jsxs("fieldset",{className:"fk:space-y-2",disabled:e,children:[jsxs("legend",{className:"fk:mb-2 fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:[jsx(b,{variant:"outline",children:n.header}),jsx("span",{className:"fk:text-sm fk:font-medium",children:n.question}),n.multiSelect?jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:"Pick any"}):null]}),jsxs("div",{className:"fk:space-y-1.5",role:n.multiSelect?"group":"radiogroup",children:[n.options.map(r=>jsx(Bn,{description:r.description,label:r.label,multiSelect:n.multiSelect,onClick:()=>a(kt(n,t,r.label)),selected:t.selected.includes(r.label)},r.label)),jsx(s,{"aria-label":`Your own answer to: ${n.question}`,className:"fk:h-9",maxLength:4e3,onChange:r=>a(gt(n,t,r.target.value)),placeholder:"Other \u2014 type your own answer",value:t.other})]})]})}function Jn({data:e}){return e.status==="answered"&&e.message!==void 0?jsxs("div",{className:"fk:space-y-1",children:[jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:e.questions.map(t=>t.question).join(" \xB7 ")}),jsxs("p",{className:"fk:text-sm",children:["You replied: ",jsxs("span",{className:"fk:whitespace-pre-wrap",children:["\u201C",e.message,"\u201D"]})]})]}):e.status!=="answered"?jsxs("div",{className:"fk:space-y-1",children:[jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:e.questions.map(t=>t.question).join(" \xB7 ")}),jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:qn[e.status]})]}):jsx("dl",{className:"fk:space-y-1.5",children:e.questions.map((t,a)=>jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-baseline fk:gap-x-2",children:[jsx("dt",{className:"fk:text-xs fk:text-muted-foreground",children:t.question}),jsx("dd",{className:"fk:text-sm fk:font-medium",children:yt(e.answers?.[a])})]},a))})}function $t({answer:e,data:t}){let[a,n]=useState(()=>mt(t.questions)),[r,s]=useState(null),[l,d]=useState(null),[u,c]=useState(""),p=t.status==="pending"&&r?r:t;if(p.status!=="pending"||!e)return jsx(Jn,{data:p});let m=vt(a);async function b(y){if(e){d(y.action),c("");try{let f=await e(t.questionId,y);f&&s({...f.answers?{answers:f.answers}:{},...f.message!==null?{message:f.message}:{},questionId:f.id,questions:f.questions,status:f.status});}catch(f){c(f instanceof Error?f.message:"Could not send the answer.");}finally{d(null);}}}return jsxs("form",{className:"fk:space-y-5",onSubmit:y=>{y.preventDefault(),m&&b({action:"answer",answers:m});},children:[t.questions.map((y,f)=>jsx(Qn,{disabled:l!==null,draft:a[f]??{other:"",selected:[]},onChange:k=>n(A=>A.map((C,P)=>P===f?k:C)),question:y},f)),u?jsx("p",{className:"fk:text-xs fk:text-destructive",children:u}):null,jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:[jsxs(b$2,{disabled:!m||l!==null,size:"sm",type:"submit",children:[l==="answer"?jsx(LoaderCircle,{className:"fk:size-3.5 fk:animate-spin"}):null,"Submit"]}),jsxs(b$2,{disabled:l!==null,onClick:()=>{b({action:"dismiss"});},size:"sm",type:"button",variant:"ghost",children:[l==="dismiss"?jsx(LoaderCircle,{className:"fk:size-3.5 fk:animate-spin"}):null,"Skip"]}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:"or reply in the chat"})]})]})}var fa=lazy(()=>import('./spec-renderer-EX7SCFWH.js').then(e=>({default:e.RunSpecPart})));function ca(e){return jsx(Suspense,{fallback:null,children:jsx(fa,{...e})})}function pa(){let{currentProjectId:e}=f();return {api:useMemo(()=>e?d(e):null,[e]),projectId:e}}var _t=5,Bt=2e3,Qt=120,ze="data-spec",Jt=createContext(null),ma=createContext(false);function ka(e){return new Promise(t=>window.setTimeout(t,e))}function ga(e){return e instanceof Error?e.name==="AbortError"||e.message.toLowerCase().includes("aborted"):false}function va(e){return e.some(t=>!ce(t))}function ya(e){let t=new Set;for(let a of e)for(let n of a.parts)n.type==="data-user-message"&&n.id&&t.add(n.id);return t}function ha(e){let t=ya(e),a=[];for(let n of e){if(n.role==="user"){t.has(n.id)||a.push(n);continue}if(n.role!=="assistant"){a.push(n);continue}let r=[],s=0,l=()=>{va(r)&&a.push({...n,id:`${n.id}-${s.toString()}`,parts:r}),s++,r=[];};for(let d of n.parts){if(d.type==="data-user-message"){let u=h(d);l(),a.push({id:d.id??crypto.randomUUID(),parts:u.parts,role:"user"});continue}r.push(d);}l();}return a}function ns(e){return useMemo(()=>ha(e),[e])}function Y(e){return e==="success"||e==="failed"||e==="cancelled"||e==="skipped"}function Xt({latestMessage:e,recordStatus:t,suppressApprovalPause:a}){return Y(t)||a||t==="running"?false:t==="awaiting_approval"?true:De(e)||Me(e)}function as(e,t){let[a,n]=useState(false),r=ba(a?e:"",t),[s,l]=useState(),[d,u]=useState("streaming"),c=useRef(t);c.current=t;let p=useRef(null);p.current||(p.current=new EventTarget);let m=p.current,b=t?.resumeToken;return useEffect(()=>{m.dispatchEvent(new Event("wake"));},[b,m]),useEffect(()=>{if(n(false),l(void 0),!e){u("unavailable");return}let y=new AbortController,f,k,A=()=>{f=void 0,k&&!y.signal.aborted&&l({...k});},C=Mt({url:e,signal:y.signal,state:()=>({terminal:Y(c.current?.recordStatus),paused:Xt({latestMessage:k,recordStatus:c.current?.recordStatus,suppressApprovalPause:c.current?.suppressApprovalPause??false})}),onState:P=>{y.signal.aborted||u(P);},wake:m});return (async()=>{try{for await(let P of readUIMessageStream({stream:C,terminateOnError:!0}))k=P,f||(f=setTimeout(A,Qt));A();}catch(P){if(y.signal.aborted)return;P instanceof W?n(true):(console.error("Run stream error",P),u("error"));}})(),()=>{y.abort(),f&&clearTimeout(f);}},[e,m]),a?r:{message:s?Ie(s,t?.decidedApprovals??{}):void 0,status:d}}function ba(e,t){let[a,n]=useState(),[r,s]=useState("streaming"),l=t?.recordStatus,d=t?.resumeToken??0,u=useRef(t?.decidedApprovals??{});u.current=t?.decidedApprovals??{};let c=useRef(t?.suppressApprovalPause??false);c.current=t?.suppressApprovalPause??false;let p=useRef(e),m=useRef(a);return m.current=a,useEffect(()=>{let b=p.current!==e;if(p.current=e,!e){n(void 0),s("unavailable");return}let y=new AbortController,f=b?void 0:m.current,k=b?0:f?.parts.length??0;if(b)n(void 0);else if(f&&(l==="running"||Y(l))){let x=Ie(f,u.current);x!==f&&(f=x,n(x));}s("streaming");let A=e.includes("?")?"&":"?",C=async()=>{let x=await fetch(`${e}${A}startIndex=0`,{credentials:"include",signal:y.signal});if(x.status===404)return "unavailable";if(!x.ok||!x.body)throw new Error(`Failed to fetch the run stream (status ${x.status.toString()})`);let T=false,D=parseJsonEventStream({schema:uiMessageChunkSchema,stream:x.body}).pipeThrough(new TransformStream({transform:(E,Ft)=>{if(!E.success)throw E.error;E.value.type==="finish"&&(T=true),Ft.enqueue(E.value);}})),ge=readUIMessageStream({onError:E=>{y.signal.aborted||console.error("Run stream chunk error",E);},stream:D}),R=null,Z=k===0,qe=(E=false)=>{y.signal.aborted||!f||!Z&&(Z=E||f.parts.length>=k,!Z)||n({...f});};try{for await(let E of ge){if(y.signal.aborted)break;f=E,R===null&&(R=window.setTimeout(()=>{R=null,qe();},Qt));}}finally{R!==null&&(window.clearTimeout(R),R=null),qe(true);}return T?"finished":"incomplete"},P=async()=>{let x=0;for(;!y.signal.aborted;){x>0&&await ka(Bt);try{let T=await C();if(y.signal.aborted)return;if(T==="unavailable"){s("unavailable");return}if(T==="finished"&&Y(l)){s("finished");return}if(Y(l)){s("finished");return}if(Xt({latestMessage:f,recordStatus:l,suppressApprovalPause:c.current})){s("paused");return}if(!(l==="running"||c.current)&&x>=_t-1){s("error");return}}catch(T){if(y.signal.aborted||ga(T))return;if(console.error("Run stream error",T),Y(l)){s("finished");return}if(!(l==="running"||c.current)&&x>=_t-1){s("error");return}}x+=1;}},K=window.setTimeout(()=>{P();},0);return ()=>{window.clearTimeout(K),y.abort("Run replay unmounted");}},[l,d,e]),{message:a,status:r}}function rs(e){return {affectedCount:e.affectedCount,approvalId:e.id,decidedBy:e.decidedBy??void 0,operationsSummary:e.operationsSummary,reason:e.reason??void 0,status:e.status}}function xa(e){let t=e.trim();return t?t.split(`
7
- `).every(a=>/^`{3,}[\w-]*$/.test(a.trim())):false}function wa({attachments:e,text:t}){return jsxs("div",{className:"fk:ml-auto fk:flex fk:w-fit fk:max-w-[70%] fk:flex-col fk:items-end fk:gap-1",children:[jsx(Pt,{attachments:e}),t.trim()?jsx("div",{className:"fk:whitespace-pre-wrap fk:rounded-xl fk:bg-muted fk:dark:bg-white/20 fk:px-3.5 fk:py-2 fk:text-base fk:corner-squircle",children:t}):null,jsxs("span",{className:"fk:inline-flex fk:items-center fk:gap-1 fk:text-xs fk:text-muted-foreground",children:[jsx(CornerDownRightIcon,{className:"fk:size-3 fk:shrink-0"}),"Added while the agent was working"]})]})}function ss({api:e,part:t,partIndex:a,parts:n}){if(ce(t))return null;if(te(t.type)){let r=fe(t);return r?jsx(Ra,{message:r}):null}if(t.type==="text")return xa(t.text)&&n.some(s=>s.type===ze)?null:jsx(Aa,{part:t});if(t.type==="data-generating-files")return jsx(Ta,{message:h(t)});if(t.type==="data-run-artifact")return jsx(Da,{api:e,message:h(t)});if(t.type==="data-tool-delivery")return jsx(Ia,{message:h(t)});if(t.type==="data-run-summary")return jsx(Ma,{message:h(t)});if(t.type==="data-subtask"){let r=h(t),s=r.status==="running"?`Running "${r.title}"`:r.status==="done"?`Completed "${r.title}"${typeof r.stepsUsed=="number"?` in ${r.stepsUsed.toString()} steps`:""}`:`"${r.title}" failed: ${r.error?.message??"unknown error"}`;return jsxs(j,{children:[jsxs(U,{children:[jsx(BotIcon,{className:"fk:size-3.5"}),"Subtask"]}),jsxs("div",{className:"fk:relative fk:min-h-5 fk:pl-6",children:[jsx("span",{className:"fk:absolute fk:left-0 fk:top-0",children:jsx(ke,{isError:r.status==="error",loading:r.status==="running"})}),jsx("span",{className:"fk:text-xs",children:s}),r.resultPreview?jsx("p",{className:"fk:mt-1 fk:text-xs fk:text-muted-foreground",children:r.resultPreview}):null]})]})}if(t.type==="data-mid-turn-message"){let r=h(t);return r.monitorEvent?jsx(It,{data:r.monitorEvent}):jsx(wa,{attachments:r.attachments,text:r.text})}if(t.type==="data-context-compaction"){let r=h(t);return jsxs("p",{className:"fk:text-xs fk:text-muted-foreground",children:["Earlier messages (",r.summarizedMessageCount.toString(),") were summarized to keep this conversation within the model's context. Details may need to be re-fetched."]})}if(t.type==="data-plugin-connection"){let r=h(t);return jsx(Ua,{pluginId:r.pluginId})}if(t.type==="data-suggested-prompt")return null;if(t.type==="data-turn-error"){let r=h(t);return jsxs(j,{className:"fk:border-red-700/40",children:[jsxs(U,{children:[jsx(XCircleIcon,{className:"fk:size-3.5 fk:text-red-700"}),jsx("span",{children:"Turn failed"})]}),jsx("p",{className:"fk:whitespace-pre-wrap fk:text-xs",children:r.message})]})}if(t.type==="data-mutation-approval"){let r=h(t);return Te(r)?jsx(_a,{message:r}):jsx(Ea,{api:e,message:r})}return t.type==="data-user-question"?jsx($a,{data:h(t)}):t.type==="data-bulk-graphql-action"?jsx(za,{message:h(t)}):t.type===ze?n.slice(a+1).find(s=>s.type===ze)?null:jsx(ca,{parts:n}):t.type.startsWith("data-")?jsx(ja,{part:t}):null}function Aa({part:e}){return jsx(ob,{className:"fk:min-w-0 fk:max-w-full fk:overflow-x-auto fk:text-base fk:leading-relaxed fk:text-foreground",isAnimating:e.state==="streaming",children:e.text})}function Ra({message:e}){return jsxs("div",{className:"fk:flex fk:items-start fk:gap-2 fk:rounded-xl fk:border fk:border-red-700/40 fk:bg-destructive/5 fk:px-3.5 fk:py-3 fk:text-sm fk:corner-squircle",children:[jsx(XCircleIcon,{className:"fk:mt-0.5 fk:size-3.5 fk:shrink-0 fk:text-red-700"}),jsx("span",{className:"fk:whitespace-pre-wrap fk:text-xs",children:e})]})}var Sa=1e3;function Na({text:e}){let t=useRef(typeof performance>"u"?0:performance.now()),a=()=>-(((typeof performance>"u"?0:performance.now())-t.current)%Sa),[n,r]=useState({current:e,currentDelayMs:0,key:0,previous:null,previousDelayMs:0});return useEffect(()=>{r(s=>s.current===e?s:{current:e,currentDelayMs:a(),key:s.key+1,previous:s.current,previousDelayMs:s.currentDelayMs});},[e]),jsxs("span",{className:"fk:relative fk:block fk:h-5 fk:min-w-0 fk:flex-1 fk:overflow-hidden",children:[n.previous?jsx("span",{"aria-hidden":true,className:"fk:absolute fk:inset-x-0 fk:top-0 fk:block fk:animate-roll-up-out",children:jsx("span",{className:"fk:block fk:truncate fk:shimmer fk:shimmer-duration-1000",style:{animationDelay:`${n.previousDelayMs.toString()}ms`},children:n.previous})},`previous-${n.key.toString()}`):null,jsx("span",{className:n.previous?"fk:block fk:animate-roll-up-in":"fk:block",role:"status",children:jsx("span",{className:"fk:block fk:truncate fk:shimmer fk:shimmer-duration-1000",style:{animationDelay:`${n.currentDelayMs.toString()}ms`},children:n.current})},`current-${n.key.toString()}`)]})}var Ca=1e3;function Pa(e,t){let a=Ca,[n,r]=useState(e),s=useRef(Date.now()),l=useRef(e);return l.current=e,useEffect(()=>{if(e===n)return;let d=Math.max(0,a-(Date.now()-s.current)),u=window.setTimeout(()=>{s.current=Date.now(),r(l.current);},d);return ()=>{window.clearTimeout(u);}},[n,e,a]),n}function os({label:e,visible:t}){let a=Pa(e);return jsx("div",{"aria-hidden":!t,className:`fk:flex fk:h-9 fk:items-center fk:text-sm fk:text-muted-foreground fk:transition-[opacity,visibility] fk:duration-200 ${t?"fk:visible fk:opacity-100":"fk:invisible fk:opacity-0"}`,children:jsx(Na,{text:a})})}function j({children:e,className:t=""}){return jsx("div",{className:`fk:min-w-0 fk:max-w-full fk:overflow-x-auto fk:rounded-xl fk:border fk:border-border fk:bg-background fk:px-3.5 fk:py-3 fk:text-sm ${t} fk:corner-squircle`,children:e})}function U({children:e}){return jsx("div",{className:"fk:flex fk:items-center fk:gap-2 fk:font-medium fk:text-muted-foreground",children:e})}function ke({isError:e,loading:t}){return t?jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}):e?jsx(XIcon,{className:"fk:size-4 fk:text-red-700"}):jsx(CheckIcon,{className:"fk:size-4"})}function Ue({error:e,icon:t,loading:a,message:n,title:r}){return jsxs(j,{children:[jsxs(U,{children:[t,r]}),jsxs("div",{className:"fk:relative fk:min-h-5 fk:pl-6",children:[jsx("span",{className:"fk:absolute fk:left-0 fk:top-0",children:jsx(ke,{isError:!!e,loading:a})}),jsx("span",{className:"fk:text-xs",children:n})]})]})}function Ta({message:e}){let t=["error","uploading","generating"].includes(e.status),a=t?e.paths.slice(0,e.paths.length-1):e.paths,n=t?e.paths[e.paths.length-1]??"":null;return jsxs(j,{children:[jsxs(U,{children:[jsx(CloudUploadIcon,{className:"fk:size-3.5"}),jsx("span",{children:e.status==="done"?"Uploaded files":"Generating files"})]}),jsxs("div",{className:"fk:space-y-1 fk:text-sm",children:[a.map((r,s)=>jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(CheckIcon,{className:"fk:size-4"}),jsx("span",{className:"fk:whitespace-pre-wrap",children:r})]},`${r}-${s.toString()}`)),typeof n=="string"?jsxs("div",{className:"fk:flex fk:items-center fk:gap-2",children:[jsx(ke,{isError:e.status==="error",loading:e.status!=="error"}),jsx("span",{children:e.status==="error"?e.error?.message??n:n})]}):null]})]})}function Da({api:e,message:t}){let a=t.status==="done"&&t.artifactId,n=a?e.getArtifactUrl(t.artifactId??""):"",r=a?e.getArtifactUrl(t.artifactId??"",{download:true}):"",s=Oa(t.sizeBytes);return jsxs(j,{children:[jsxs(U,{children:[jsx(FileTextIcon,{className:"fk:size-3.5"}),t.status==="done"?"Published artifact":"Publishing artifact"]}),jsxs("div",{className:"fk:relative fk:min-h-5 fk:pl-6",children:[jsx("span",{className:"fk:absolute fk:left-0 fk:top-0",children:jsx(ke,{isError:t.status==="error",loading:t.status==="uploading"})}),jsxs("div",{className:"fk:min-w-0 fk:space-y-2",children:[jsxs("div",{className:"fk:min-w-0",children:[jsx("div",{className:"fk:truncate fk:font-medium",children:t.filename}),jsxs("div",{className:"fk:text-xs fk:text-muted-foreground",children:[t.status==="uploading"&&"Uploading to artifacts",t.status==="done"&&[La(t),s].filter(Boolean).join(" \xB7 "),t.status==="error"&&(t.error?.message??"Failed to publish artifact")]})]}),a?jsxs("div",{className:"fk:flex fk:flex-wrap fk:gap-2",children:[jsx(b$2,{asChild:true,size:"sm",variant:"outline",children:jsx("a",{href:n,rel:"noreferrer",target:"_blank",children:"Preview"})}),jsx(b$2,{asChild:true,size:"sm",variant:"outline",children:jsxs("a",{href:r,children:[jsx(DownloadIcon,{className:"fk:size-3"}),"Download"]})}),t.url?jsx(b$2,{asChild:true,size:"sm",variant:"outline",children:jsxs("a",{href:t.url,rel:"noreferrer",target:"_blank",children:[jsx(LinkIcon,{className:"fk:size-3"}),"Permanent link"]})}):null]}):null]})]})]})}function Ia({message:e}){let t=e.provider==="slack"?"Slack":"Microsoft Teams",a=e.provider==="slack"?jsx(MessageSquareIcon,{className:"fk:size-3.5"}):jsx(SendIcon,{className:"fk:size-3.5"});return jsx(Ue,{error:e.error?.message,icon:a,loading:e.status==="loading",message:e.status==="error"?e.error?.message??`Failed to send result to ${e.channelName}`:`${e.status==="done"?"Sent":"Sending"} result to ${e.channelName}`,title:`${t} Delivery`})}function Ma({message:e}){let t=e.status==="success"?jsx(CheckCircle2Icon,{className:"fk:size-3.5 fk:text-green-700"}):e.status==="skipped"?jsx(CircleSlashIcon,{className:"fk:size-3.5"}):jsx(XCircleIcon,{className:"fk:size-3.5 fk:text-red-700"}),a=e.status==="success"?"Run completed":e.status==="skipped"?"Run skipped":"Run failed";return jsxs(j,{className:e.status==="failed"?"fk:border-red-700/40":"fk:border-green-700/40",children:[jsxs(U,{children:[t,jsx("span",{children:a})]}),e.status==="failed"?jsx("p",{className:"fk:whitespace-pre-wrap fk:text-xs",children:e.summary}):null]})}function Ea({api:e,message:t}){let{projectId:a}=pa(),n=useContext(Jt),r=useContext(ma),s=useRef(void 0),{data:l,error:d,isValidating:u,mutate:c}=On(a?g(a).approval(t.approvalId):null,f$1,{refreshInterval:k=>t.status!=="pending"||k?.approval?.status&&k.approval.status!=="pending"?0:Bt}),p=l?.approval?.status,m=(p??t.status)==="pending",b=l?.approval?.kind==="schema"&&l.approval.status==="approved";useEffect(()=>{!b||!a||de({approvalId:t.approvalId,approvalUrl:g(a).approval(t.approvalId),projectId:a});},[b,t.approvalId,a]),useEffect(()=>{c();},[t.status,c]),useEffect(()=>{let k=s.current;s.current=p,!(t.status!=="pending"||!p||p==="pending")&&k==="pending"&&n?.onApprovalDecided(l?.approval?.id??t.approvalId,p);},[p,l?.approval?.id,t.approvalId,t.status,n]);function y(k){k.status!=="pending"&&(s.current=k.status),c(),n?.onApprovalDecided(k.id,k.status);}let f;if(l?.approval)f=jsx(ft,{api:e,approval:l.approval,chat:r,onDecided:y},l.approval.status);else if(d&&!u){let k=d instanceof Error&&d.message?d.message:"Request failed";f=jsxs("div",{className:"fk:space-y-2",children:[jsxs("p",{className:"fk:text-xs fk:text-destructive",children:["Failed to load proposal ",t.operationsSummary,": ",k]}),jsx(b$2,{size:"sm",variant:"outline",onClick:()=>{c();},children:"Retry"})]});}else f=jsxs("div",{className:"fk:flex fk:items-center fk:gap-2 fk:text-xs fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-3.5 fk:animate-spin"}),jsxs("span",{children:["Loading proposal ",t.operationsSummary,"..."]})]});return jsxs(j,{children:[jsxs(U,{children:[r?jsx(ShieldIcon,{className:"fk:size-3.5"}):jsx(DatabaseZapIcon,{className:"fk:size-3.5"}),r?"Approval request":"Mutation approval",m?jsx(LoaderCircle,{className:"fk:ml-1 fk:size-3.5 fk:animate-spin"}):null]}),jsx("div",{className:"fk:mt-2",children:f}),t.status==="error"&&t.error?jsx("p",{className:"fk:mt-2 fk:text-xs fk:text-destructive",children:t.error.message}):null]})}function $a({data:e}){let t=useContext(Jt),a=e.questions.length>1;return jsxs(j,{children:[jsxs(U,{children:[jsx(MessageCircleQuestionIcon,{className:"fk:size-3.5"}),e.status==="pending"?a?"The agent has questions":"The agent has a question":a?"Questions":"Question"]}),jsx("div",{className:"fk:mt-3",children:jsx($t,{answer:t?.answerQuestion,data:e},e.status)})]})}function _a({message:e}){let t=e.operationsSummary.replace(/^Call /,"");return jsx(Ue,{error:e.status==="error"?e.error?.message??"The call failed.":void 0,icon:jsx(ShieldCheckIcon,{className:"fk:size-3.5"}),loading:false,message:e.status==="error"?`${t}: ${e.error?.message??"The call failed."}`:`${t} \xB7 Auto-approved by Jev`,title:"Plugin call"})}function za({message:e}){let t=[typeof e.processedItems=="number"?`${e.processedItems.toString()} processed`:"",typeof e.changedItems=="number"?`${e.changedItems.toString()} changed`:"",typeof e.failedItems=="number"?`${e.failedItems.toString()} failed`:"",typeof e.totalItems=="number"?`${e.totalItems.toString()} total`:""].filter(Boolean);return jsx(Ue,{error:e.error?.message,icon:jsx(DatabaseZapIcon,{className:"fk:size-3.5"}),loading:e.status==="loading"||e.status==="running",message:e.status==="error"?e.error?.message??`Failed bulk ${e.operationName}`:`${e.status==="done"?"Completed":"Running"} ${e.operationName}${t.length>0?` (${t.join(", ")})`:""}`,title:"Bulk GraphQL action"})}function ja({part:e}){return jsxs(j,{className:"fk:bg-muted/30",children:[jsxs(U,{children:[jsx(CheckCircle2Icon,{className:"fk:size-3.5"}),e.type.replace(/^data-/,"").replaceAll("-"," ")]}),jsx("p",{className:"fk:text-xs fk:text-muted-foreground",children:"This run emitted a structured event that is not yet rendered by Studio."})]})}function Oa(e){if(typeof e!="number")return "";if(e<1024)return `${e.toString()} B`;let t=e/1024;return t<1024?`${t.toFixed(1)} KB`:`${(t/1024).toFixed(1)} MB`}function La(e){return e.kind==="pdf"?"PDF artifact":e.kind==="html"?"HTML artifact":"Artifact"}function Ua({pluginId:e}){let{pathname:t}=useLocation(),[a]=t.split("/ai/");return jsxs(j,{children:[jsxs("p",{className:"fk:text-sm",children:["Connect ",e," to use it in this conversation."]}),jsx(b$2,{asChild:true,size:"sm",variant:"outline",children:jsxs(Link,{to:`${a}/ai/plugins/${encodeURIComponent(e)}`,children:["Connect ",e]})})]})}export{as as A,rs as B,ss as C,Ra as D,os as E,Ea as F,et as a,rn as b,ft as c,nr as d,ce as e,Nn as f,De as g,pt as h,Cn as i,Me as j,ht as k,pr as l,mr as m,kr as n,gr as o,vr as p,Pt as q,Nr as r,It as s,Cr as t,pa as u,Bt as v,Jt as w,ma as x,ns as y,Y as z};//# sourceMappingURL=chunk-Z5TZVTX3.js.map
8
- //# sourceMappingURL=chunk-Z5TZVTX3.js.map