@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
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/apps/ai/agent/dictation.ts","../src/apps/ai/api.ts"],"names":["appendDictatedText","existing","transcript","dictated","convertRecordedAudioToPcm","blob","AudioContextCtor","arrayBuffer","audioContext","audioBuffer","mono","mixToMono","resampled","resample","pcm","floatToPcm16","durationSeconds","buffer","length","channelCount","index","sum","channel","samples","sourceRate","targetRate","ratio","outputLength","output","sourceIndex","left","right","fraction","leftSample","rightSample","view","sample","AgentUploadError","status","message","code","getApiRootDomain","hostname","getPlatformOrigin","getWebhookTriggerUrl","projectId","token","createApiClient","projectBasePath","automationsBasePath","skillsBasePath","agentChatsBasePath","request","url","init","response","data","error","input","id","runId","chatId","workflowRunId","title","pluginId","questionId","result","attachments","content","modelId","messageId","monitorId","audio","signal","formData","file","tokenResponse","tokenData","put","approvalId","ids","itemId","state","automationId","skillId","artifactId","options","suffix","provider","connectionId","FetcherError","fetcher","paths","basePath","filter","limit","offset","params","since","query","enabled","search","visibility","value","trimmedSearch","scope","spaceId"],"mappings":"0DAIO,SAASA,CAAAA,CAAmBC,CAAAA,CAAkBC,CAAAA,CAA4B,CAC/E,IAAMC,CAAAA,CAAWD,CAAAA,CAAW,IAAA,EAAK,CAEjC,OAAKC,CAAAA,CAIAF,CAAAA,CAAS,IAAA,EAAK,CAIf,KAAA,CAAM,IAAA,CAAKA,CAAQ,CAAA,EAAK,WAAA,CAAY,IAAA,CAAKE,CAAQ,CAAA,CAC5C,CAAA,EAAG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AI,GAAA,CAAKO,CAAa,CAAA,CAGxB,CAAA,EAAGtD,CAAc,CAAA,CAAA,EAAI+C,CAAAA,CAAO,QAAA,EAAU,CAAA,CAC/C,CAAA,CACA,MAAA,CAAQ,CAAA,aAAA,EAAgBpD,CAAS,CAAA,OAAA,CAAA,CACjC,OAAA,CAAU6D,CAAAA,EACRA,CAAAA,CACI,CAAA,aAAA,EAAgB7D,CAAS,CAAA,iBAAA,EAAoB,kBAAA,CAAmB6D,CAAO,CAAC,CAAA,CAAA,CACxE,CAAA,aAAA,EAAgB7D,CAAS,CAAA,QAAA,CAAA,CAC/B,KAAA,CAAQsC,CAAAA,EACNA,CAAAA,CAAe,CAAA,EAAGU,CAAQ,CAAA,CAAA,EAAI,kBAAA,CAAmBV,CAAY,CAAC,CAAA,MAAA,CAAA,CAAW,CAAA,EAAGU,CAAQ,QACxF,CACF","file":"chunk-2HSIWUH3.js","sourcesContent":["export const DICTATION_SAMPLE_RATE = 24_000;\nexport const DICTATION_MAX_DURATION_SECONDS = 60;\nexport const DICTATION_MIN_DURATION_SECONDS = 0.25;\n\nexport function appendDictatedText(existing: string, transcript: string): string {\n const dictated = transcript.trim();\n\n if (!dictated) {\n return existing;\n }\n\n if (!existing.trim()) {\n return existing.length === 0 ? dictated : `${existing}${dictated}`;\n }\n\n if (/\\s$/.test(existing) || /^[.,!?;:]/.test(dictated)) {\n return `${existing}${dictated}`;\n }\n\n return `${existing} ${dictated}`;\n}\n\nexport async function convertRecordedAudioToPcm(blob: Blob): Promise<{ durationSeconds: number; pcm: Blob }> {\n if (typeof window === 'undefined') {\n throw new Error('Dictation is only available in the browser.');\n }\n\n const AudioContextCtor = window.AudioContext ?? window.webkitAudioContext;\n\n if (!AudioContextCtor) {\n throw new Error('This browser cannot decode recorded audio.');\n }\n\n const arrayBuffer = await blob.arrayBuffer();\n const audioContext = new AudioContextCtor();\n\n try {\n const audioBuffer = await audioContext.decodeAudioData(arrayBuffer.slice(0));\n const mono = mixToMono(audioBuffer);\n const resampled = resample(mono, audioBuffer.sampleRate, DICTATION_SAMPLE_RATE);\n const pcm = floatToPcm16(resampled);\n const durationSeconds = resampled.length / DICTATION_SAMPLE_RATE;\n\n if (durationSeconds < DICTATION_MIN_DURATION_SECONDS) {\n throw new Error('No speech was captured. Try again.');\n }\n\n if (durationSeconds > DICTATION_MAX_DURATION_SECONDS) {\n throw new Error(`Dictation is limited to ${String(DICTATION_MAX_DURATION_SECONDS)} seconds.`);\n }\n\n return {\n durationSeconds,\n pcm: new Blob([pcm], { type: 'audio/pcm' }),\n };\n } finally {\n await audioContext.close();\n }\n}\n\nfunction mixToMono(buffer: AudioBuffer): Float32Array {\n const { length, numberOfChannels: channelCount } = buffer;\n\n if (channelCount === 1) {\n return buffer.getChannelData(0).slice();\n }\n\n const mono = new Float32Array(length);\n\n for (let index = 0; index < length; index += 1) {\n let sum = 0;\n\n for (let channel = 0; channel < channelCount; channel += 1) {\n sum += buffer.getChannelData(channel)[index] ?? 0;\n }\n\n mono[index] = sum / channelCount;\n }\n\n return mono;\n}\n\nfunction resample(samples: Float32Array, sourceRate: number, targetRate: number): Float32Array {\n if (sourceRate === targetRate) {\n return samples;\n }\n\n const ratio = sourceRate / targetRate;\n const outputLength = Math.max(1, Math.round(samples.length / ratio));\n const output = new Float32Array(outputLength);\n\n for (let index = 0; index < outputLength; index += 1) {\n const sourceIndex = index * ratio;\n const left = Math.floor(sourceIndex);\n const right = Math.min(left + 1, samples.length - 1);\n const fraction = sourceIndex - left;\n const leftSample = samples[left] ?? 0;\n const rightSample = samples[right] ?? 0;\n output[index] = leftSample + (rightSample - leftSample) * fraction;\n }\n\n return output;\n}\n\nfunction floatToPcm16(samples: Float32Array): ArrayBuffer {\n const buffer = new ArrayBuffer(samples.length * 2);\n const view = new DataView(buffer);\n\n for (let index = 0; index < samples.length; index += 1) {\n const sample = Math.max(-1, Math.min(1, samples[index] ?? 0));\n view.setInt16(index * 2, sample < 0 ? sample * 0x8000 : sample * 0x7fff, true);\n }\n\n return buffer;\n}\n\ndeclare global {\n interface Window {\n webkitAudioContext?: typeof AudioContext;\n }\n}\n","import type { PluginConnection, PluginScope, PluginTools } from './plugin-types';\nimport { put } from '@vercel/blob/client';\nimport { convertRecordedAudioToPcm } from './agent/dictation';\nimport type {\n ActivityItem,\n ActivityItemState,\n AgentChat,\n AgentChatAttachment,\n AgentChatFollowUpResult,\n AgentChatMessage,\n AgentChatMonitor,\n AgentChatQuestion,\n AgentChatQuestionResponse,\n AgentChatTurn,\n Automation,\n AutomationApproval,\n AutomationApprovalStatus,\n AutomationArtifact,\n AutomationInput,\n AutomationToolChannel,\n AutomationToolProvider,\n AutomationVisibility,\n MutationResult,\n Skill,\n SkillInput,\n} from './types';\n\nexport interface DecideApprovalInput {\n /** Approve and always allow this plugin tool for the automation. */\n remember?: boolean;\n approved: boolean;\n /** For a proposed automation: the approver's edited instructions and whether to run it once now. */\n automationEdits?: { instructions?: string; runOnce?: boolean };\n force?: boolean;\n reason?: string;\n}\n\nexport interface SendAgentChatMessageInput {\n attachments?: AgentChatAttachment[];\n content: string;\n modelId?: string | null;\n}\n\n/** A new chat and its first turn, started by one request. */\nexport interface StartAgentChatResult {\n chat: AgentChat;\n turn: AgentChatTurn;\n}\n\n/** Thrown when the API refuses an upload; `code` lets the UI tailor the message. */\nexport class AgentUploadError extends Error {\n code: string | null;\n status: number;\n\n constructor(status: number, message: string, code: string | null = null) {\n super(message);\n this.name = 'AgentUploadError';\n this.code = code;\n this.status = status;\n }\n}\n\nexport interface ApiClient {\n /** Starts OAuth for a new account, or for `connectionId` to reconnect that specific account. */\n connectPlugins: (_input: {\n pluginId: string;\n scope: PluginScope;\n studioOrigin: string;\n connectionId?: string;\n }) => Promise<{ transactionId: string; authorizeUrl: string; completionOrigin: string; launchTicket: string }>;\n /** Renames (label null resets to the provider name) or makes a connection primary. */\n updatePluginConnection: (\n _id: string,\n _input: { label?: string | null; primary?: true }\n ) => Promise<{ connection: PluginConnection }>;\n pluginOAuthStatus: (_id: string) => Promise<{ id: string; status: 'pending' | 'exchanging' | 'complete' | 'failed'; expires_at: string }>;\n disconnectPlugin: (_id: string) => Promise<{ success: boolean }>;\n installPlugin: (_id: string) => Promise<unknown>;\n setPluginPolicy: (_id: string, _input: { enabled: boolean; allowPersonal: boolean }) => Promise<{ success: boolean }>;\n refreshPluginTools: (_id: string) => Promise<PluginTools>;\n\n cancelRun: (_runId: string) => Promise<MutationResult>;\n createAgentChat: (_input?: { modelId?: string | null }) => Promise<{ chat: AgentChat }>;\n deleteAgentChat: (_chatId: string) => Promise<{ success: boolean }>;\n getAgentChatStreamUrl: (_chatId: string, _workflowRunId: string) => string;\n renameAgentChat: (_chatId: string, _title: string) => Promise<{ chat: AgentChat }>;\n sendAgentChatMessage: (_chatId: string, _input: SendAgentChatMessageInput) => Promise<AgentChatTurn>;\n /**\n * Sends a message while the chat's turn is running. The platform decides\n * whether it steers that turn or waits as the next one; if the turn has\n * meanwhile ended, the message starts the next turn.\n */\n sendAgentChatFollowUp: (_chatId: string, _input: SendAgentChatMessageInput) => Promise<AgentChatFollowUpResult>;\n /** The user connected a plugin from the chat's connect card: starts the turn that uses it, or queues it. */\n announcePluginConnected: (\n _chatId: string,\n _pluginId: string\n ) => Promise<Extract<AgentChatFollowUpResult, { followUp: unknown } | { turn: unknown }>>;\n /** Answers (or dismisses) the questions a chat turn waits on; a settled question comes back with an error. */\n answerAgentChatQuestion: (\n _chatId: string,\n _questionId: string,\n _response: AgentChatQuestionResponse\n ) => Promise<{ errorMessage?: string; question?: AgentChatQuestion }>;\n /** Creates a chat and sends its first message in one request. */\n startAgentChat: (_input: SendAgentChatMessageInput) => Promise<StartAgentChatResult>;\n /** Starts the next turn from a queued follow-up once the previous turn has ended. */\n startQueuedAgentChatMessage: (_chatId: string, _messageId: string) => Promise<AgentChatTurn>;\n stopAgentChat: (_chatId: string) => Promise<{ message: AgentChatMessage }>;\n stopAgentChatMonitor: (_chatId: string, _monitorId: string) => Promise<{ monitor: AgentChatMonitor }>;\n transcribeAgentAudio: (_audio: Blob, _signal?: AbortSignal) => Promise<{ text: string }>;\n /** Uploads a chat attachment straight to the platform file store. */\n uploadAgentChatAttachment: (_file: File, _signal?: AbortSignal) => Promise<AgentChatAttachment>;\n decideApproval: (\n _approvalId: string,\n _input: DecideApprovalInput\n ) => Promise<MutationResult & { approval?: AutomationApproval }>;\n createAutomation: (_input: AutomationInput) => Promise<MutationResult & { automation?: Automation }>;\n createSkill: (_input: SkillInput) => Promise<MutationResult & { skill?: Skill }>;\n deleteAutomation: (_automationId: string) => Promise<MutationResult>;\n deleteSkill: (_skillId: string) => Promise<MutationResult>;\n getArtifactUrl: (_artifactId: string, _options?: { download?: boolean }) => string;\n getRunArtifacts: (_workflowRunId: string) => Promise<AutomationArtifact[]>;\n getStreamUrl: (_workflowRunId: string) => string;\n /** JSON transcript of a finished run (owners and developers). */\n getTranscriptUrl: (_runId: string) => string;\n /** Lists delivery channels of `connectionId`, or of the provider's primary project account when omitted. */\n listChannels: (_provider: AutomationToolProvider, _connectionId?: string | null) => Promise<{\n channels: AutomationToolChannel[];\n errorMessage?: string;\n success: boolean;\n }>;\n runAutomation: (_automationId: string) => Promise<MutationResult & { runId?: string }>;\n updateAutomation: (\n _automationId: string,\n _input: AutomationInput\n ) => Promise<MutationResult & { automation?: Automation }>;\n updateSkill: (_skillId: string, _input: SkillInput) => Promise<MutationResult & { skill?: Skill }>;\n /** Marks the caller's Activity items read; `'all'` marks every unread item. */\n markActivityRead: (_ids: string[] | 'all') => Promise<{ success: boolean }>;\n setActivityItemState: (\n _itemId: string,\n _state: Extract<ActivityItemState, 'unread' | 'read' | 'dismissed'>\n ) => Promise<{ item: ActivityItem }>;\n}\n\n\nfunction getApiRootDomain(): string {\n if (typeof window === 'undefined') {\n return 'flexkit.io';\n }\n\n const { hostname } = window.location;\n const isDevHost =\n hostname === 'localhost' ||\n hostname === '127.0.0.1' ||\n hostname === 'flexkit.test' ||\n hostname.endsWith('.flexkit.test');\n\n return isDevHost ? 'flexkit.test' : 'flexkit.io';\n}\n\n/** Origin that hosts plugin OAuth start and completion. */\nexport function getPlatformOrigin(): string {\n return `https://${getApiRootDomain()}`;\n}\n\n/** Public URL an external system calls to fire a webhook trigger. */\nexport function getWebhookTriggerUrl(projectId: string, token: string): string {\n return `https://${projectId}.api.${getApiRootDomain()}/automations/webhook/${encodeURIComponent(token)}`;\n}\n\nexport function createApiClient(projectId: string): ApiClient {\n const projectBasePath = `/api/flexkit/${projectId}`;\n const automationsBasePath = `${projectBasePath}/automations`;\n const skillsBasePath = `${projectBasePath}/skills`;\n const agentChatsBasePath = `${projectBasePath}/agent/chats`;\n\n async function request<T>(url: string, init?: RequestInit): Promise<T> {\n const response = await fetch(url, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n ...(init?.headers ?? {}),\n },\n ...init,\n });\n const data = (await response.json()) as T;\n\n if (!response.ok) {\n const error = data && typeof data === 'object' && 'error' in data ? String(data.error) : 'Request failed';\n\n throw new Error(error);\n }\n\n return data;\n }\n\n return {\n connectPlugins: (input) => request(`${projectBasePath}/plugins/connect`, { method: 'POST', body: JSON.stringify(input) }),\n pluginOAuthStatus: (id) => request(`${projectBasePath}/plugins/oauth-transactions/${encodeURIComponent(id)}`),\n updatePluginConnection: (id, input) =>\n request(`${projectBasePath}/plugin-connections/${encodeURIComponent(id)}`, { method: 'PATCH', body: JSON.stringify(input) }),\n disconnectPlugin: (id) => request(`${projectBasePath}/plugin-connections/${encodeURIComponent(id)}`, { method: 'DELETE' }),\n installPlugin: (id) => request(`${projectBasePath}/plugins/${encodeURIComponent(id)}/installation`, { method: 'PUT', body: JSON.stringify({}) }),\n setPluginPolicy: (id, input) => request(`${projectBasePath}/plugins/${encodeURIComponent(id)}/policy`, { method: 'PATCH', body: JSON.stringify(input) }),\n refreshPluginTools: (id) => request(`${projectBasePath}/plugin-connections/${encodeURIComponent(id)}/tools/refresh`, { method: 'POST' }),\n cancelRun: async (runId) =>\n request<MutationResult>(`${automationsBasePath}/runs/${encodeURIComponent(runId)}/cancel`, { method: 'POST' }),\n createAgentChat: async (input) =>\n request<{ chat: AgentChat }>(agentChatsBasePath, {\n body: JSON.stringify({ modelId: input?.modelId ?? null }),\n method: 'POST',\n }),\n deleteAgentChat: async (chatId) =>\n request<{ success: boolean }>(`${agentChatsBasePath}/${encodeURIComponent(chatId)}`, { method: 'DELETE' }),\n getAgentChatStreamUrl: (chatId, workflowRunId) =>\n `${agentChatsBasePath}/${encodeURIComponent(chatId)}/stream?workflowRunId=${encodeURIComponent(workflowRunId)}`,\n renameAgentChat: async (chatId, title) =>\n request<{ chat: AgentChat }>(`${agentChatsBasePath}/${encodeURIComponent(chatId)}`, {\n body: JSON.stringify({ title }),\n method: 'PATCH',\n }),\n sendAgentChatMessage: async (chatId, input) =>\n request<AgentChatTurn>(`${agentChatsBasePath}/${encodeURIComponent(chatId)}/messages`, {\n body: JSON.stringify(input),\n method: 'POST',\n }),\n announcePluginConnected: async (chatId, pluginId) =>\n request(`${agentChatsBasePath}/${encodeURIComponent(chatId)}/plugin-connected`, {\n body: JSON.stringify({ pluginId }),\n method: 'POST',\n }),\n sendAgentChatFollowUp: async (chatId, input) =>\n request<AgentChatFollowUpResult>(`${agentChatsBasePath}/${encodeURIComponent(chatId)}/follow-ups`, {\n body: JSON.stringify(input),\n method: 'POST',\n }),\n answerAgentChatQuestion: async (chatId, questionId, response) => {\n const result = await fetch(\n `${agentChatsBasePath}/${encodeURIComponent(chatId)}/questions/${encodeURIComponent(questionId)}/answer`,\n {\n body: JSON.stringify(response),\n credentials: 'include',\n headers: { 'Content-Type': 'application/json' },\n method: 'POST',\n }\n );\n const data = (await result.json()) as { errorMessage?: string; error?: string; question?: AgentChatQuestion };\n\n // A question settled elsewhere (409) comes back with its final state for the card to show.\n if (!result.ok && !data.question) {\n throw new Error(data.errorMessage ?? data.error ?? 'Request failed');\n }\n\n return { errorMessage: result.ok ? undefined : data.errorMessage, question: data.question };\n },\n startAgentChat: async ({ attachments, content, modelId }) =>\n request<StartAgentChatResult>(agentChatsBasePath, {\n body: JSON.stringify({ message: { attachments, content }, modelId: modelId ?? null }),\n method: 'POST',\n }),\n startQueuedAgentChatMessage: async (chatId, messageId) =>\n request<AgentChatTurn>(\n `${agentChatsBasePath}/${encodeURIComponent(chatId)}/follow-ups/${encodeURIComponent(messageId)}/start`,\n { method: 'POST' }\n ),\n stopAgentChat: async (chatId) =>\n request<{ message: AgentChatMessage }>(`${agentChatsBasePath}/${encodeURIComponent(chatId)}/stop`, {\n method: 'POST',\n }),\n stopAgentChatMonitor: async (chatId, monitorId) =>\n request<{ monitor: AgentChatMonitor }>(\n `${agentChatsBasePath}/${encodeURIComponent(chatId)}/monitors/${encodeURIComponent(monitorId)}/stop`,\n { method: 'POST' }\n ),\n transcribeAgentAudio: async (audio, signal) => {\n const { durationSeconds, pcm } = await convertRecordedAudioToPcm(audio);\n const formData = new FormData();\n formData.append('file', pcm, 'audio.pcm');\n formData.append('durationSeconds', String(durationSeconds));\n\n const response = await fetch(`${projectBasePath}/agent/transcribe`, {\n body: formData,\n credentials: 'include',\n method: 'POST',\n signal,\n });\n const data = (await response.json()) as { error?: string; text?: string };\n\n if (!response.ok) {\n const error = data && typeof data === 'object' && data.error ? String(data.error) : 'Request failed';\n\n throw new Error(error);\n }\n\n if (!data.text?.trim()) {\n throw new Error('No speech was recognized. Try again.');\n }\n\n return { text: data.text };\n },\n uploadAgentChatAttachment: async (file, signal) => {\n // The platform issues a token scoped to one pathname, type and size; the\n // browser then writes the bytes to the store directly, so large files\n // never pass through the API function body limit.\n const tokenResponse = await fetch(`${projectBasePath}/agent/uploads`, {\n body: JSON.stringify({ filename: file.name, mediaType: file.type || null, sizeBytes: file.size }),\n credentials: 'include',\n headers: { 'Content-Type': 'application/json' },\n method: 'POST',\n signal,\n });\n const tokenData = (await tokenResponse.json()) as {\n code?: string;\n error?: string;\n mediaType?: string;\n pathname?: string;\n token?: string;\n };\n\n if (!tokenResponse.ok || !tokenData.pathname || !tokenData.token || !tokenData.mediaType) {\n throw new AgentUploadError(\n tokenResponse.status,\n tokenData.error ? String(tokenData.error) : 'The file could not be uploaded.',\n tokenData.code ?? null\n );\n }\n\n const blob = await put(tokenData.pathname, file, {\n abortSignal: signal,\n access: 'public',\n contentType: tokenData.mediaType,\n token: tokenData.token,\n });\n\n return {\n filename: file.name,\n mediaType: tokenData.mediaType,\n sizeBytes: file.size,\n url: blob.url,\n };\n },\n decideApproval: async (approvalId, input) => {\n const response = await fetch(`${automationsBasePath}/approvals/${encodeURIComponent(approvalId)}/decide`, {\n body: JSON.stringify(input),\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n });\n const data = (await response.json()) as MutationResult & { approval?: AutomationApproval; error?: string };\n\n // Business errors (stale_preview, already_decided) come back as 400\n // with a structured body the caller must be able to inspect.\n if (!response.ok && typeof data.success !== 'boolean') {\n throw new Error(data.error ? String(data.error) : 'Request failed');\n }\n\n return data;\n },\n markActivityRead: async (ids) =>\n request<{ success: boolean }>(`${projectBasePath}/activity/read`, {\n body: JSON.stringify(ids === 'all' ? { all: true } : { ids }),\n method: 'POST',\n }),\n setActivityItemState: async (itemId, state) =>\n request<{ item: ActivityItem }>(`${projectBasePath}/activity/${encodeURIComponent(itemId)}`, {\n body: JSON.stringify({ state }),\n method: 'PATCH',\n }),\n createAutomation: async (input) =>\n request<MutationResult & { automation?: Automation }>(automationsBasePath, {\n body: JSON.stringify(input),\n method: 'POST',\n }),\n createSkill: async (input) =>\n request<MutationResult & { skill?: Skill }>(skillsBasePath, {\n body: JSON.stringify(input),\n method: 'POST',\n }),\n deleteAutomation: async (automationId) =>\n request<MutationResult>(`${automationsBasePath}/${encodeURIComponent(automationId)}`, { method: 'DELETE' }),\n deleteSkill: async (skillId) =>\n request<MutationResult>(`${skillsBasePath}/${encodeURIComponent(skillId)}`, { method: 'DELETE' }),\n getArtifactUrl: (artifactId, options) => {\n const suffix = options?.download ? '?download=1' : '';\n\n return `${automationsBasePath}/artifacts/${encodeURIComponent(artifactId)}/content${suffix}`;\n },\n getRunArtifacts: async (workflowRunId) =>\n request<{ artifacts: AutomationArtifact[] }>(\n `${automationsBasePath}/runs/${encodeURIComponent(workflowRunId)}/artifacts`\n ).then((response) => response.artifacts),\n getStreamUrl: (workflowRunId) => `${automationsBasePath}/runs/${encodeURIComponent(workflowRunId)}/stream`,\n getTranscriptUrl: (runId) => `${automationsBasePath}/runs/${encodeURIComponent(runId)}/transcript`,\n listChannels: async (provider, connectionId) => {\n const url = connectionId\n ? `${projectBasePath}/plugin-connections/${encodeURIComponent(connectionId)}/channels`\n : `${projectBasePath}/plugins/${provider}/channels`;\n const response = await fetch(url, {\n credentials: 'include',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n const data = (await response.json()) as {\n channels?: AutomationToolChannel[];\n error?: string;\n errorMessage?: string;\n success?: boolean;\n };\n\n if (response.ok) {\n return {\n channels: data.channels ?? [],\n errorMessage: data.errorMessage,\n success: data.success ?? true,\n };\n }\n\n if (data.success === false) {\n return {\n channels: data.channels ?? [],\n errorMessage: data.errorMessage ?? `Failed to load ${provider === 'slack' ? 'Slack' : 'Teams'} channels.`,\n success: false,\n };\n }\n\n const error = data.error ? String(data.error) : 'Request failed';\n\n throw new Error(error);\n },\n runAutomation: async (automationId) =>\n request<MutationResult & { runId?: string }>(`${automationsBasePath}/${encodeURIComponent(automationId)}/runs`, {\n method: 'POST',\n }),\n updateAutomation: async (automationId, input) =>\n request<MutationResult & { automation?: Automation }>(\n `${automationsBasePath}/${encodeURIComponent(automationId)}`,\n {\n body: JSON.stringify(input),\n method: 'PATCH',\n }\n ),\n updateSkill: async (skillId, input) =>\n request<MutationResult & { skill?: Skill }>(`${skillsBasePath}/${encodeURIComponent(skillId)}`, {\n body: JSON.stringify(input),\n method: 'PATCH',\n }),\n };\n}\n\nexport class FetcherError extends Error {\n status: number;\n\n constructor(status: number, message = 'Request failed') {\n super(message);\n this.name = 'FetcherError';\n this.status = status;\n }\n}\n\nexport const fetcher = async <T>(url: string): Promise<T> => {\n const response = await fetch(url, { credentials: 'include' });\n\n if (!response.ok) {\n throw new FetcherError(response.status);\n }\n\n return (await response.json()) as T;\n};\n\nexport function paths(projectId: string): {\n activity: (_options?: { filter?: 'all' | 'needs_action'; limit?: number; offset?: number }) => string;\n activityItem: (_itemId: string) => string;\n /** Badge counts; with `since`, also the unread items created after it. */\n activitySummary: (_since?: string | null) => string;\n agentChat: (_chatId: string) => string;\n agentChatSearch: (_query: string) => string;\n agentChats: (_offset?: number) => string;\n agentProfile: () => string;\n approval: (_approvalId: string) => string;\n approvals: (_options?: {\n limit?: number;\n offset?: number;\n runId?: string;\n status?: AutomationApprovalStatus;\n }) => string;\n approvalsCount: string;\n automation: (_automationId: string) => string;\n automationRuns: (_automationId: string, _offset?: number, _limit?: number) => string;\n automations: (_options?: {\n enabled?: boolean[];\n limit?: number;\n offset?: number;\n search?: string;\n visibility?: AutomationVisibility[];\n }) => string;\n creditBalance: string;\n entities: string;\n run: (_runId: string) => string;\n runHistory: (_scope: 'mine' | 'team', _offset?: number, _limit?: number) => string;\n skill: (_skillId: string) => string;\n skills: (_options?: { limit?: number; offset?: number; search?: string; visibility?: AutomationVisibility[] }) => string;\n spaces: string;\n /** Members for pickers; with a space id, only members who can see that space. */\n members: (_spaceId?: string | null) => string;\n tools: (_automationId?: string) => string;\n} {\n const basePath = `/api/flexkit/${projectId}/automations`;\n const skillsBasePath = `/api/flexkit/${projectId}/skills`;\n const agentChatsBasePath = `/api/flexkit/${projectId}/agent/chats`;\n\n return {\n activity: (options = {}) => {\n const { filter = 'all', limit = 25, offset = 0 } = options;\n const params = new URLSearchParams({ filter, limit: limit.toString(), offset: offset.toString() });\n\n return `/api/flexkit/${projectId}/activity?${params.toString()}`;\n },\n activityItem: (itemId) => `/api/flexkit/${projectId}/activity/${encodeURIComponent(itemId)}`,\n activitySummary: (since) =>\n since\n ? `/api/flexkit/${projectId}/activity/summary?since=${encodeURIComponent(since)}`\n : `/api/flexkit/${projectId}/activity/summary`,\n agentChat: (chatId) => `${agentChatsBasePath}/${encodeURIComponent(chatId)}`,\n agentChatSearch: (query) => `${agentChatsBasePath}/search?q=${encodeURIComponent(query)}`,\n agentChats: (offset = 0) => `${agentChatsBasePath}?offset=${offset.toString()}`,\n agentProfile: () => `/api/flexkit/${projectId}/agent/profile`,\n approval: (approvalId) => `${basePath}/approvals/${encodeURIComponent(approvalId)}`,\n approvals: (options = {}) => {\n const { limit = 25, offset = 0, runId, status } = options;\n const params = new URLSearchParams({\n limit: limit.toString(),\n offset: offset.toString(),\n });\n\n if (status) {\n params.set('status', status);\n }\n\n if (runId) {\n params.set('runId', runId);\n }\n\n return `${basePath}/approvals?${params.toString()}`;\n },\n approvalsCount: `${basePath}/approvals?limit=1`,\n automation: (automationId) => `${basePath}/${encodeURIComponent(automationId)}`,\n automationRuns: (automationId, offset = 0, limit = 25) =>\n `${basePath}/${encodeURIComponent(automationId)}/runs?offset=${offset.toString()}&limit=${limit.toString()}`,\n automations: (options = {}) => {\n const { enabled, limit = 25, offset = 0, search, visibility } = options;\n const params = new URLSearchParams({\n limit: limit.toString(),\n offset: offset.toString(),\n });\n\n if (enabled && enabled.length > 0) {\n params.set('enabled', enabled.map((value) => (value ? 'true' : 'false')).join(','));\n }\n\n if (visibility && visibility.length > 0) {\n params.set('visibility', visibility.join(','));\n }\n\n const trimmedSearch = search?.trim();\n\n if (trimmedSearch) {\n params.set('q', trimmedSearch);\n }\n\n return `${basePath}?${params.toString()}`;\n },\n creditBalance: `${basePath}/credits`,\n entities: `${basePath}/entities`,\n run: (runId) => `${basePath}/runs/${encodeURIComponent(runId)}`,\n runHistory: (scope, offset = 0, limit = 25) =>\n `${basePath}/runs?scope=${scope}&offset=${offset.toString()}&limit=${limit.toString()}`,\n skill: (skillId) => `${skillsBasePath}/${encodeURIComponent(skillId)}`,\n skills: (options = {}) => {\n const { limit = 25, offset = 0, search, visibility } = options;\n const params = new URLSearchParams({\n limit: limit.toString(),\n offset: offset.toString(),\n });\n\n if (visibility && visibility.length > 0) {\n params.set('visibility', visibility.join(','));\n }\n\n const trimmedSearch = search?.trim();\n\n if (trimmedSearch) {\n params.set('q', trimmedSearch);\n }\n\n return `${skillsBasePath}?${params.toString()}`;\n },\n spaces: `/api/flexkit/${projectId}/spaces`,\n members: (spaceId) =>\n spaceId\n ? `/api/flexkit/${projectId}/members?spaceId=${encodeURIComponent(spaceId)}`\n : `/api/flexkit/${projectId}/members`,\n tools: (automationId) =>\n automationId ? `${basePath}/${encodeURIComponent(automationId)}/tools` : `${basePath}/tools`,\n };\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import'./index.css';import {a,b as b$3}from'./chunk-KXAGLQ2B.js';import {f,d as d$1}from'./chunk-2HSIWUH3.js';import {f as f$1}from'./chunk-TPLL535V.js';import {N,ga,ha,ia,Rc,Tc,oa,s,p,q as q$1,r}from'./chunk-YCCFUGWJ.js';import {w,b as b$2}from'./chunk-32ZU4MLE.js';import {e,g,h,i,j,t,d,a as a$1,b as b$4,c as c$1,o}from'./chunk-SZEGGBOC.js';import {b as b$1,c,e as e$1}from'./chunk-USNXQOMJ.js';import {b}from'./chunk-6NRQMG26.js';import {useState,useMemo,useRef,useEffect}from'react';import {useNavigate,useLocation,useParams,Link}from'react-router-dom';import K,{useSWRConfig}from'swr';import {Plug,ArrowLeft,ExternalLink,RefreshCw,ChevronLeft,ChevronRight,Plus,CheckIcon,XIcon,MoreHorizontal,TriangleAlert}from'lucide-react';import {jsxs,jsx,Fragment}from'react/jsx-runtime';function Re(n){let a;try{a=new URL(n);}catch{return null}return a.protocol!=="https:"||a.username!==""||a.password!==""?null:a.href}function ge(){let{currentProjectId:n}=f$1();return {api:useMemo(()=>n?d$1(n):null,[n]),base:n?`/api/flexkit/${n}`:null}}function Ee(n){return n.length===2?"Project & Personal":n[0]==="project"?"Project":"Personal"}function Le(n){return n.length===2?"fk:bg-indigo-100 fk:text-indigo-800 fk:dark:bg-indigo-950 fk:dark:text-indigo-300":n[0]==="project"?"fk:bg-sky-100 fk:text-sky-800 fk:dark:bg-sky-950 fk:dark:text-sky-300":"fk:bg-teal-100 fk:text-teal-800 fk:dark:bg-teal-950 fk:dark:text-teal-300"}function T(n){return n.connections.length>0}function ze(n){return n==="project"?"Project":"Personal"}function z(n,a,t){return t==="personal"?n.allowPersonal:a}function xe(n,a){return n.connections.filter(t=>t.scope===a).sort((t,s)=>Number(s.isPrimary)-Number(t.isPrimary)||t.createdAt.localeCompare(s.createdAt))}function Ie(n){let a=n.connections.filter(t=>t.isPrimary&&t.status==="connected");return a.find(t=>t.scope==="personal")??a.find(t=>t.scope==="project")??null}function $e({busy:n,canManage:a,plugin:t,onConnect:s}){let i$1=t.scopes.filter(k=>xe(t,k).length===0),[f]=i$1;if(!f)return null;if(t.scopes.length===1)return jsxs(b,{disabled:n||!t.enabled||!z(t,a,f),size:"sm",type:"button",onClick:()=>s(f),children:[jsx(Plug,{}),"Connect"]});let m=i$1.some(k=>z(t,a,k));return jsxs(e,{children:[jsx(g,{asChild:true,children:jsxs(b,{disabled:n||!t.enabled||!m,size:"sm",type:"button",children:[jsx(Plug,{}),"Connect"]})}),jsx(h,{align:"end",className:"fk:w-72",children:jsx(i,{children:i$1.map(k=>jsx(j,{disabled:!z(t,a,k),onSelect:()=>s(k),children:jsxs("span",{className:"fk:flex fk:flex-col fk:gap-0.5",children:[jsx("span",{children:ze(k)}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:k==="personal"?"Only you can use this connection in this project.":"Shared with project members who can use this plugin."})]})},k))})})]})}function S(n,a){let t=/^(.*\/ai)(?:\/|$)/.exec(n);return t?`${t[1]}/${a}`:a}function q(n){return n.split(/[\s_-]+/).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function je(n){let a={};for(let t of n){let s=a[t.category];if(s){s.push(t);continue}a[t.category]=[t];}return Object.entries(a).sort(([t],[s])=>q(t).localeCompare(q(s))).map(([t,s])=>({category:t,plugins:s}))}var fe=[{id:"first",rows:[{descriptionWidth:"fk:w-44",id:"first-a",nameWidth:"fk:w-24"},{descriptionWidth:"fk:w-52",id:"first-b",nameWidth:"fk:w-16"},{descriptionWidth:"fk:w-40",id:"first-c",nameWidth:"fk:w-28"},{descriptionWidth:"fk:w-48",id:"first-d",nameWidth:"fk:w-20"}]},{id:"second",rows:[{descriptionWidth:"fk:w-36",id:"second-a",nameWidth:"fk:w-32"},{descriptionWidth:"fk:w-56",id:"second-b",nameWidth:"fk:w-24"}]}];function ce({action:n,row:a}){return jsxs("div",{className:"fk:-mx-3 fk:flex fk:min-w-0 fk:items-center fk:gap-3 fk:px-3 fk:py-2",children:[jsx(t,{className:"fk:size-10 fk:shrink-0 fk:rounded-lg"}),jsxs("span",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:flex-col fk:gap-1.5",children:[jsx(t,{className:`fk:h-4 ${a.nameWidth}`}),jsx(t,{className:`fk:h-4 ${a.descriptionWidth}`})]}),n?jsx(t,{className:"fk:size-4 fk:shrink-0"}):null]})}var F="fk:grid fk:grid-cols-1 fk:gap-x-16 fk:gap-y-1 fk:lg:grid-cols-2";function Be({grouped:n=true}){let a=fe.flatMap(t=>t.rows);return n?jsxs("div",{"aria-busy":"true",className:"fk:flex fk:flex-col fk:gap-8",children:[jsx("span",{className:"fk:sr-only",children:"Loading plugins"}),fe.map(t$1=>jsxs("section",{children:[jsx(t,{className:"fk:mb-1 fk:h-4 fk:w-28"}),jsx("div",{className:F,children:t$1.rows.map(s=>jsx(ce,{action:true,row:s},s.id))})]},t$1.id))]}):jsxs("div",{"aria-busy":"true",className:F,children:[jsx("span",{className:"fk:sr-only",children:"Loading plugins"}),a.map(t=>jsx(ce,{action:true,row:t},t.id))]})}function We(){let n=useNavigate(),{pathname:a}=useLocation(),t=/\/ai\/plugins\/?$/.test(a),s=a.includes("/ai/skills");return jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs(b$1,{children:[jsx(c,{asChild:true,children:jsx(N,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(ga,{value:s?"skills":"plugins",onValueChange:f=>{let m=f==="skills"?"skills":"plugins";(f==="skills"?s:t)||n(S(a,m));},children:jsxs(ha,{children:[jsx(ia,{value:"plugins",onClick:()=>{t||n(S(a,"plugins"));},children:"Plugins"}),jsx(ia,{value:"skills",children:"Skills"})]})})]})}function Ue({onOpen:n,plugin:a}){let t=T(a),s=a.connections.filter(f=>f.status==="needs_auth").length,i=s===1?"An account needs to be reconnected":`${s.toString()} accounts need to be reconnected`;return jsxs("button",{type:"button",onClick:n,className:"fk:-mx-3 fk:flex fk:min-w-0 fk:items-center fk:gap-3 fk:rounded-lg fk:px-3 fk:py-2 fk:text-left fk:transition-colors fk:hover:bg-accent fk:focus-visible:bg-accent fk:focus-visible:outline-none fk:corner-squircle",children:[jsx("img",{src:a.logoUrl,alt:"",className:"fk:size-10 fk:shrink-0 fk:rounded-lg fk:corner-squircle"}),jsxs("span",{className:"fk:min-w-0 fk:flex-1",children:[jsx("span",{className:"fk:block fk:truncate fk:text-sm fk:font-medium",children:a.name}),jsx("span",{className:"fk:block fk:truncate fk:text-sm fk:text-muted-foreground",children:a.description})]}),s>0?jsxs(b$1,{children:[jsx(c,{asChild:true,children:jsxs("span",{className:"fk:flex fk:shrink-0",children:[jsx(TriangleAlert,{"aria-hidden":true,className:"fk:size-4 fk:text-destructive"}),jsx("span",{className:"fk:sr-only",children:i})]})}),jsx(e$1,{children:i})]}):t?jsx(CheckIcon,{className:"fk:size-4 fk:shrink-0 fk:text-success"}):jsx(Plus,{className:"fk:size-4 fk:shrink-0 fk:text-muted-foreground"})]})}function ke({onOpen:n,plugins:a}){return jsx("div",{className:F,children:a.map(t=>jsx(Ue,{plugin:t,onOpen:()=>n(t.id)},t.id))})}function he({installedOnly:n=false}){let{base:a}=ge(),{data:t$1,error:s$1,isLoading:i}=K(a?`${a}/plugins`:null,f),[f$1,m]=useState(""),k=useNavigate(),{pathname:p}=useLocation(),x=f$1.trim().toLowerCase(),l=(t$1?.plugins??[]).filter(c=>(!n||T(c))&&`${c.name} ${c.description}`.toLowerCase().includes(x)),b=(t$1?.plugins??[]).filter(T),u=n?[]:je(l),g="Plugins are being prepared. Check back soon.";n&&!x?g="No plugins installed yet.":(t$1?.catalogSha||n)&&(g="No plugins match your search.");function M(c){k(S(p,`plugins/${c}`));}let r=jsx("div",{className:"fk:flex fk:flex-col fk:gap-8",children:u.map(c=>jsxs("section",{children:[jsx("h3",{className:"fk:mb-1 fk:text-sm fk:font-medium",children:q(c.category)}),jsx(ke,{plugins:c.plugins,onOpen:M})]},c.category))});return n&&(r=jsx(ke,{plugins:l,onOpen:M})),(i||s$1||l.length===0)&&(r=null),jsxs("main",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:[jsx(We,{}),jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{className:"fk:mx-auto fk:flex fk:w-full fk:max-w-4xl fk:flex-col fk:gap-8 fk:py-6 fk:pl-4 fk:pr-6",children:[jsxs("div",{children:[jsx("h2",{className:"fk:text-2xl fk:font-semibold",children:"Plugins"}),jsx("p",{className:"fk:mt-2 fk:text-muted-foreground",children:"Connect the tools you use and add skills to your workflows."})]}),jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-3",children:[jsx(s,{"aria-label":"Search plugins",className:"fk:mr-auto fk:w-full fk:max-w-xs",placeholder:"Search plugins\u2026",value:f$1,onChange:c=>m(c.target.value)}),!n&&i?jsxs("div",{className:"fk:flex fk:items-center fk:gap-3",children:[jsx("div",{className:"fk:flex fk:-space-x-2",children:["installed-a","installed-b","installed-c"].map(c=>jsx(t,{className:"fk:size-8 fk:rounded-md fk:ring-2 fk:ring-background"},c))}),jsx(t,{className:"fk:h-4 fk:w-20"})]}):null,!n&&!i&&b.length>0?jsx(d,{children:b.slice(0,9).map(c=>jsxs(a$1,{className:"fk:rounded-md",children:[jsx(b$4,{src:c.logoUrl,alt:""}),jsx(c$1,{children:c.name.charAt(0)})]},c.id))}):null,n?jsxs(Link,{to:S(p,"plugins"),className:"fk:inline-flex fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground fk:hover:text-foreground",children:[jsx(ChevronLeft,{className:"fk:size-4"}),"Show all"]}):null,!n&&!i?jsxs(Link,{to:S(p,"plugins/installed"),className:"fk:inline-flex fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground fk:hover:text-foreground",children:[b.length," installed",jsx(ChevronRight,{className:"fk:size-4"})]}):null]}),s$1?jsx(Rc,{variant:"destructive",children:jsx(Tc,{children:"Unable to load plugins. Please try again."})}):null,i?jsx(Be,{grouped:!n}):null,!i&&!s$1&&l.length===0?jsx(Rc,{children:jsx(Tc,{children:g})}):null,r]})})]})}function nn(){return jsx(he,{})}function tn(){return jsx(he,{installedOnly:true})}function Xe({base:n,connectionId:a}){let{data:t$1,error:s}=K(`${n}/plugin-connections/${a}/tools`,f);return s?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"Unable to discover tools. Reconnect or try again."}):t$1?jsx("div",{className:"fk:flex fk:flex-col fk:gap-3",children:t$1.servers.map(i=>jsxs("section",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx("h4",{className:"fk:font-medium",children:i.name}),i.error?jsx("p",{children:i.error}):null,i.tools.length>0?jsxs(p,{className:"fk:group",children:[jsxs(q$1,{className:"fk:flex fk:w-fit fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground",children:[jsx(ChevronRight,{className:"fk:size-4 fk:transition-transform fk:group-data-[state=open]:rotate-90"}),Je(i.tools.length)]}),jsx(r,{children:jsx("ul",{className:"fk:mt-2 fk:flex fk:flex-col fk:gap-2",children:i.tools.map(f=>jsxs("li",{children:[jsx("span",{className:"fk:text-sm fk:font-medium",children:f.name}),jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:f.description})]},f.name))})})]}):null]},i.name))}):jsx(t,{className:"fk:h-12 fk:w-full"})}function Je(n){return n===1?"1 tool":`${n.toString()} tools`}function _e(n){return n.accountName&&n.accountName!==n.displayName?n.accountName:n.scope==="project"?"Shared with this project":"Only you can use this account"}function Ge({actionable:n,actions:a,busy:t,connection:s$1,pluginEnabled:i$1}){let[f,m]=useState(false),[k,p]=useState(""),x=useRef(null),l=s$1.status==="needs_auth",b$1=async()=>{let u=k.trim();await a.onRename(s$1,u||null),m(false);};return useEffect(()=>{if(!f)return;let u=window.setTimeout(()=>x.current?.focus(),0);return ()=>window.clearTimeout(u)},[f]),jsxs("li",{className:"fk:flex fk:min-w-0 fk:items-center fk:gap-3 fk:py-2",children:[jsx(a$1,{className:"fk:size-8",children:jsx(c$1,{children:s$1.displayName.charAt(0).toUpperCase()})}),f?jsxs("form",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:items-center fk:gap-2",onSubmit:u=>{u.preventDefault(),b$1();},children:[jsx(s,{"aria-label":"Account name",ref:x,className:"fk:h-8 fk:max-w-xs",disabled:t,placeholder:s$1.accountName??"Account name",value:k,onChange:u=>p(u.target.value),onKeyDown:u=>{u.key==="Escape"&&m(false);}}),jsx(b,{"aria-label":"Save name",disabled:t,size:"icon",type:"submit",variant:"ghost",children:jsx(CheckIcon,{})}),jsx(b,{"aria-label":"Cancel rename",size:"icon",type:"button",variant:"ghost",onClick:()=>m(false),children:jsx(XIcon,{})})]}):jsxs("span",{className:"fk:flex fk:min-w-0 fk:flex-1 fk:flex-col",children:[jsxs("span",{className:"fk:flex fk:min-w-0 fk:items-center fk:gap-2",children:[jsx("span",{className:"fk:truncate fk:text-sm fk:font-medium",children:s$1.displayName}),s$1.isPrimary?jsx(b$2,{variant:"secondary",children:"Primary"}):null,l?jsx(b$2,{variant:"destructive",children:"Needs reconnect"}):null]}),jsx("span",{className:"fk:truncate fk:text-sm fk:text-muted-foreground",children:_e(s$1)})]}),n&&!f?jsxs(e,{children:[jsx(g,{asChild:true,children:jsx(b,{"aria-label":`Manage ${s$1.displayName}`,disabled:t,size:"icon",variant:"ghost",children:jsx(MoreHorizontal,{})})}),jsxs(h,{align:"end",children:[jsxs(i,{children:[!s$1.isPrimary&&!l?jsx(j,{onSelect:()=>a.onMakePrimary(s$1),children:"Make primary"}):null,jsx(j,{onSelect:()=>{p(s$1.label??""),m(true);},children:"Rename"}),jsx(j,{disabled:!i$1,onSelect:()=>a.onReconnect(s$1),children:"Reconnect"})]}),jsx(o,{}),jsx(j,{variant:"destructive",onSelect:()=>a.onDisconnect(s$1),children:"Disconnect"})]})]}):null]})}function qe({actions:n,busy:a,canManage:t,onConnect:s,plugin:i}){let f=i.scopes.length>1;return jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsx("h2",{className:"fk:text-xl fk:font-semibold",children:"Connected accounts"}),i.scopes.map(m=>{let k=xe(i,m),p=z(i,t,m),x=m==="personal"||t;return k.length===0&&!p?null:jsxs("div",{className:"fk:flex fk:flex-col",children:[f?jsx("h3",{className:"fk:text-sm fk:font-medium fk:text-muted-foreground",children:m==="project"?"Project accounts":"Your accounts"}):null,jsxs("ul",{className:"fk:flex fk:flex-col fk:divide-y",children:[k.map(l=>jsx(Ge,{actionable:x,actions:n,busy:a,connection:l,pluginEnabled:i.enabled},l.id)),p?jsx("li",{children:jsxs("button",{className:"fk:flex fk:w-full fk:items-center fk:gap-3 fk:py-2 fk:text-left fk:text-sm fk:text-muted-foreground fk:transition-colors fk:hover:text-foreground fk:disabled:pointer-events-none fk:disabled:opacity-50",disabled:a||!i.enabled,type:"button",onClick:()=>s(m),children:[jsx("span",{className:"fk:flex fk:size-8 fk:shrink-0 fk:items-center fk:justify-center fk:rounded-full fk:border fk:border-dashed",children:jsx(Plus,{className:"fk:size-4"})}),k.length>0?"Connect another account":"Connect an account"]})}):null]})]},m)})]})}function an(){let{pluginId:n}=useParams(),{api:a$1,base:t$1}=ge(),{data:s,error:i,mutate:f$1}=K(t$1&&n?`${t$1}/plugins/${n}`:null,f),{mutate:m}=useSWRConfig(),k=useNavigate(),[p,x]=useState(false),l=s?.plugin,b$4=l?Re(l.sourceUrl):null,u=async r=>{x(true);try{await r(),await f$1();}catch(c){if(c instanceof a){oa.error('You signed in with a different account. Use "Connect another account" to add it.');return}oa.error(c instanceof Error?c.message:"Unable to complete this action.");}finally{x(false);}};if(i)return jsx("div",{className:"fk:p-6",children:jsx(Rc,{variant:"destructive",children:jsx(Tc,{children:"Unable to load this plugin."})})});if(!l||!s||!a$1||!t$1)return jsxs("main",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:[jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs(b$1,{children:[jsx(c,{asChild:true,children:jsx(N,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsxs(b,{variant:"ghost",size:"sm",onClick:()=>k("..",{relative:"path"}),children:[jsx(ArrowLeft,{}),"Plugins"]})]}),jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{"aria-busy":"true",className:"fk:mx-auto fk:flex fk:w-full fk:max-w-4xl fk:flex-col fk:gap-8 fk:py-6 fk:pl-4 fk:pr-6",children:[jsx("span",{className:"fk:sr-only",children:"Loading plugin"}),jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-4",children:[jsx(t,{className:"fk:size-14 fk:shrink-0 fk:rounded-lg"}),jsx(t,{className:"fk:h-7 fk:w-40"}),jsx(t,{className:"fk:ml-auto fk:h-9 fk:w-28"})]}),jsx(t,{className:"fk:h-4 fk:w-full"}),jsx(t,{className:"fk:h-4 fk:w-2/3"}),jsx(t,{className:"fk:h-6 fk:w-24 fk:rounded-full"})]})]})})]});let g=Ie(l),M={onDisconnect:r=>{u(()=>a$1.disconnectPlugin(r.id));},onMakePrimary:r=>{u(()=>a$1.updatePluginConnection(r.id,{primary:!0}));},onReconnect:r=>{u(()=>b$3(a$1,l.id,r.scope,{connectionId:r.id}));},onRename:(r,c)=>u(()=>a$1.updatePluginConnection(r.id,{label:c}))};return jsxs("main",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:[jsxs("div",{className:"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2",children:[jsxs(b$1,{children:[jsx(c,{asChild:true,children:jsx(N,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsxs(b,{variant:"ghost",size:"sm",onClick:()=>k("..",{relative:"path"}),children:[jsx(ArrowLeft,{}),"Plugins"]})]}),jsx(w,{className:"fk:h-0 fk:min-h-0 fk:flex-1",children:jsxs("div",{className:"fk:mx-auto fk:flex fk:w-full fk:max-w-4xl fk:flex-col fk:gap-8 fk:py-6 fk:pl-4 fk:pr-6",children:[jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-4",children:[jsx("img",{src:l.logoUrl,alt:"",className:"fk:size-14 fk:shrink-0 fk:rounded-lg fk:corner-squircle"}),jsxs("div",{className:"fk:flex fk:min-w-0 fk:flex-col fk:gap-0.5",children:[jsx("h1",{className:"fk:text-xl fk:font-semibold",children:l.name}),b$4?jsxs("a",{href:b$4,target:"_blank",rel:"noopener noreferrer",className:"fk:inline-flex fk:w-fit fk:items-center fk:gap-1 fk:text-sm fk:hover:underline fk:text-muted-foreground",children:["View source",jsx(ExternalLink,{className:"fk:size-3"})]}):null]}),jsx("div",{className:"fk:ml-auto fk:flex fk:shrink-0 fk:flex-wrap fk:items-center fk:justify-end fk:gap-2",children:T(l)?null:jsx($e,{busy:p,canManage:s.canManage,plugin:l,onConnect:r=>{u(()=>b$3(a$1,l.id,r));}})})]}),jsx("p",{className:"fk:text-muted-foreground",children:l.description}),jsx("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-3",children:jsx(b$2,{className:`fk:border-0 fk:text-[0.625rem] fk:leading-4.5 fk:font-normal fk:py-0 fk:px-2 ${Le(l.scopes)}`,variant:"default",children:Ee(l.scopes)})}),l.scopes.map(r=>(r==="personal"?l.allowPersonal:s.canManage)?null:jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:r==="project"?"Ask an owner or developer to connect.":"Personal connections are disabled by project policy."},r))]}),l.enabled?null:jsx(Rc,{children:jsx(Tc,{children:"This plugin is disabled by project policy."})}),T(l)?jsx(qe,{actions:M,busy:p,canManage:s.canManage,plugin:l,onConnect:r=>{u(()=>b$3(a$1,l.id,r));}}):null,jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-3",children:[jsx("h2",{className:"fk:text-xl fk:font-semibold",children:"Included tools"}),l.capabilities.agentTools&&g?jsxs(b,{className:"fk:ml-auto",disabled:p,size:"sm",variant:"ghost",onClick:()=>{u(async()=>{await a$1.refreshPluginTools(g.id),await m(`${t$1}/plugin-connections/${g.id}/tools`);});},children:[jsx(RefreshCw,{}),"Refresh"]}):null]}),l.capabilities.automationDelivery?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"Automation delivery to selected channels. This plugin does not expose MCP messaging tools."}):null,l.capabilities.agentTools&&!g?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"Connect to discover available tools."}):null,l.capabilities.agentTools&&g?jsxs(Fragment,{children:[jsxs("p",{className:"fk:text-sm fk:text-muted-foreground",children:["Tools \xB7 via ",g.displayName]}),jsx(Xe,{base:t$1,connectionId:g.id},g.id)]}):null]}),jsxs("section",{className:"fk:flex fk:flex-col fk:gap-3",children:[jsx("h2",{className:"fk:text-xl fk:font-semibold",children:"Included skills"}),s.skills.length===0?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"This plugin includes no skills."}):s.skills.map(r=>jsxs("div",{children:[jsx("h3",{className:"fk:font-medium",children:r.name}),jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:r.description})]},r.key))]}),jsxs("section",{className:"fk:space-y-3",children:[jsx("h2",{className:"fk:text-xl fk:font-semibold",children:"Used by"}),l.usedBy.length===0?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:"No automations visible to you use this plugin yet."}):jsx("ul",{children:l.usedBy.map(r=>jsx("li",{children:jsx(b,{className:"fk:pl-0!",variant:"link",onClick:()=>k(`../../automations/${r.id}`,{relative:"path"}),children:r.name})},r.id))})]})]})})]})}export{$e as a,We as b,nn as c,tn as d,an as e};//# sourceMappingURL=chunk-7JSGAY3E.js.map
2
+ //# sourceMappingURL=chunk-7JSGAY3E.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/apps/ai/plugin-pages.tsx"],"names":["httpsCatalogUrl","value","url","useMarketplaceApi","currentProjectId","useConfig","useMemo","createApiClient","scopeLabel","scopes","scopeColorClassname","isConnected","plugin","scopeTitle","scope","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","error","isLoading","useSWR","fetcher","search","setSearch","useState","query","connectedPlugins","emptyMessage","openPlugin","pluginId","list","group","ScrollArea","Input","event","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","api","mutate","revalidateKey","useSWRConfig","setBusy","sourceUrl","perform","failure","PluginAccountMismatchError","toast","ArrowLeft","toolConnection","connectionActions","connectPluginPopup","ExternalLink","RefreshCw","Fragment","skill","automation"],"mappings":"6wBA0DA,SAASA,EAAAA,CAAgBC,EAA8B,CACrD,IAAIC,EAEJ,GAAI,CACFA,EAAM,IAAI,GAAA,CAAID,CAAK,EACrB,CAAA,KAAQ,CACN,OAAO,IACT,CAEA,OAAIC,CAAAA,CAAI,WAAa,QAAA,EAAYA,CAAAA,CAAI,WAAa,EAAA,EAAMA,CAAAA,CAAI,WAAa,EAAA,CAChE,IAAA,CAGFA,EAAI,IACb,CAEA,SAASC,EAAAA,EAAoB,CAC3B,GAAM,CAAE,iBAAAC,CAAiB,CAAA,CAAIC,KAAU,CAGvC,OAAO,CAAE,GAAA,CAFGC,OAAAA,CAAQ,IAAOF,CAAAA,CAAmBG,GAAAA,CAAgBH,CAAgB,CAAA,CAAI,IAAA,CAAO,CAACA,CAAgB,CAAC,EAE7F,IAAA,CAAMA,CAAAA,CAAmB,gBAAgBA,CAAgB,CAAA,CAAA,CAAK,IAAK,CACnF,CAEA,SAASI,EAAAA,CAAWC,CAAAA,CAA+B,CACjD,OAAIA,CAAAA,CAAO,SAAW,CAAA,CACb,oBAAA,CAGFA,EAAO,CAAC,CAAA,GAAM,UAAY,SAAA,CAAY,UAC/C,CAEA,SAASC,EAAAA,CAAoBD,CAAAA,CAA+B,CAC1D,OAAIA,CAAAA,CAAO,MAAA,GAAW,EACb,mFAAA,CAGFA,CAAAA,CAAO,CAAC,CAAA,GAAM,SAAA,CACjB,wEACA,2EACN,CAEA,SAASE,C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AAA,EAAqB4G,CAAAA,CAAW,EAAE,CAAA,CAAA,CAAI,CAAE,SAAU,MAAO,CAAC,EAEjF,QAAA,CAAAA,CAAAA,CAAW,KACd,CAAA,CAAA,CAPOA,CAAAA,CAAW,EAQpB,CACD,CAAA,CACH,GAEJ,CAAA,CAAA,CACF,CAAA,CACA,GACF,CAEJ","file":"chunk-7JSGAY3E.js","sourcesContent":["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"]}
@@ -0,0 +1,8 @@
1
+ import'./index.css';import {b as b$3}from'./chunk-KXAGLQ2B.js';import {g,f as f$1,d}from'./chunk-2HSIWUH3.js';import {f,d as d$1}from'./chunk-TPLL535V.js';import {na,Nb,Qb,ob,oa as oa$1,o,ka,ta,_,$,ca as ca$1,da as da$1,aa,ea,s}from'./chunk-YCCFUGWJ.js';import {b,c as c$1,h as h$1,i,k,l,j,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 {createContext,lazy,useCallback,useState,useRef,useEffect,useMemo,useContext,useTransition,useId,Suspense}from'react';import Yn,{useSWRConfig}from'swr';import {formatDistance,format}from'date-fns';import {RadarIcon,BotIcon,XIcon,PlugIcon,XCircleIcon,LoaderCircle,CheckIcon,CloudUploadIcon,FileTextIcon,DownloadIcon,LinkIcon,MessageSquareIcon,SendIcon,CheckCircle2Icon,CircleSlashIcon,ShieldIcon,DatabaseZapIcon,MessageCircleQuestionIcon,ShieldCheckIcon,TriangleAlertIcon,PlayIcon,ArrowRightIcon,FileIcon,CornerDownRightIcon,CircleAlertIcon,MoveRightIcon}from'lucide-react';import {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 rt(){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 ln=5e3,un=150,Pe=new Set;function cn(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 fn(e,t,a=d$1){return !e||e.kind!=="schema"||e.status!=="approved"||e.error?false:e.executedAt?(a(t),false):true}function ke({approvalId:e,approvalUrl:t,fetchApproval:a,projectId:n,revalidate:r=d$1,sleep:s=i=>new Promise(u=>setTimeout(u,i))}){let i=`${n}:${e}`,u=a??(t?cn(t):null);!u||Pe.has(i)||(Pe.add(i),(async()=>{try{for(let c=0;c<un;c+=1){let p=null;try{p=await u();}catch{p=null;}if(p==="missing"||p!==null&&!fn(p,n,r))return;await s(ln);}}finally{Pe.delete(i);}})());}var gn={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 vn({status:e}){return jsx(b,{className:`fk:border-none fk:h-4.75 fk:text-[0.6875rem] fk:leading-4.5 fk:tracking-wide ${gn[e]}`,variant:"secondary",children:e})}function U(e){return e==null?"\u2014":typeof e=="object"?JSON.stringify(e):String(e)}function ut({after:e,before:t}){let a=U(t),n=U(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 yn(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 hn({operation:e}){if(e.rows.length===0)return null;let t=(e.contextColumns??[]).filter(n=>n!=="_id");if(e.kind==="delete")return jsxs(_,{children:[jsx($,{children:jsxs(ca$1,{children:[jsx(da$1,{children:"Records to delete"}),t.map(n=>jsx(da$1,{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??U(n.before?._id)}),t.map(s=>jsx(ea,{className:"fk:text-xs fk:text-muted-foreground",children:U(n.before?.[s])},s))]},n.id??r.toString()))})]});let a=e.columns.filter(n=>n!=="_id"&&!t.includes(n));return jsxs(_,{children:[jsx($,{children:jsxs(ca$1,{children:[jsx(da$1,{children:"ID"}),t.map(n=>jsx(da$1,{children:n},n)),a.map(n=>jsx(da$1,{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:U(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:U(n.after?.[s])}):jsx(ut,{after:n.after?.[s],before:n.before?.[s]})},s))]},n.id??r.toString()))})]})}function bn({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 ct(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(),i=r.replace(/[_-]+/g," ").replace(/\b\w/g,f=>f.toUpperCase()),u=e.operations[0]?.query??"",c=/^Connection:\s*(Project|Personal)\s+—\s+(.+)$/m.exec(u);if(c?.[1]&&c[2])return {action:s,app:i,account:c[2].trim(),scope:c[1]==="Project"?"project":"personal"};let p=/^Connection:.*?([^\s<>]+@[^\s<>]+)\s*$/m.exec(u)?.[1];return {action:s,app:i,account:p}}function xn(e){let t=ct(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 wn({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=>U(s.before?.[n])!==U(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(_,{className:"fk:text-xs",children:[jsx($,{children:jsxs(ca$1,{children:[jsx(da$1,{className:"fk:h-8",children:e.entity==="scopes"||e.entity==="spaces"||e.entity==="studio"?"Setting":"Attribute"}),a.map(n=>jsx(da$1,{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:U(n.after?.[s])}):e.kind==="delete"?jsx("span",{className:"fk:text-muted-foreground",children:U(n.before?.[s])}):jsx(ut,{after:n.after?.[s],before:n.before?.[s]})},s))]},n.id??r.toString()))})]})})}function Sn(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 Nn({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:Sn(a)}),jsx(wn,{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 An(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 ft({api:e,approval:t,onDecided:a}){let[n,r]=useState(t),[s,i]=useState(t),[u,c]=useState(""),[p,f]=useTransition(),[k,x]=useState(false),[v,d]=useState(false),[m,w]=useState(""),D=rt();t!==s&&(i(t),An(t,s)||n.id===t.id&&n.status!=="pending"&&t.status==="pending"||r(t));function S(b){r(b),D(),b.kind==="schema"&&b.status==="approved"&&ke({approvalId:b.id,approvalUrl:g(b.projectId).approval(b.id),projectId:b.projectId}),a?.(b);}function E({approved:b,automationEdits:M,force:$=false,reason:I,remember:ee=false}){f(async()=>{c("");try{let R=await e.decideApproval(n.id,{approved:b,...M?{automationEdits:M}:{},force:$,reason:I,remember:ee});if(R.errorCode==="stale_preview"){d(!0),R.approval&&r(R.approval);return}if(d(!1),x(!1),R.approval?S(R.approval):R.success?S({...n,decidedAt:n.decidedAt??new Date().toISOString(),reason:I??n.reason,status:b?"approved":"rejected"}):R.errorCode==="already_decided"&&a?.(n),!R.success&&(R.errorCode!=="already_decided"||!R.approval)){let Q=Array.isArray(R.errorMessage)?R.errorMessage.join(", "):R.errorMessage;c(Q||"Failed to submit the decision.");}}catch(R){c(R instanceof Error?R.message:"Failed to submit the decision.");}});}return {approval:n,decide:E,errorMessage:u,isDeciding:p,isPending:n.status==="pending",isRejectDialogOpen:k,isStale:v,rejectReason:m,setIsRejectDialogOpen:x,setRejectReason:w}}function dt({allowRemember:e=false,askForRejectionReason:t,decide:a,isDeciding:n,isRejectDialogOpen:r,isStale:s,rejectReason:i$1,setIsRejectDialogOpen:u,setRejectReason:c,variant:p}){let f=p==="header",k$1=f?"fk:px-8 fk:min-w-32":void 0,x=f?"default":"sm",[v,d]=useState(false),m=useId();return jsxs(Fragment,{children:[jsxs("div",{className:"fk:flex fk:flex-nowrap fk:items-center fk:gap-2",children:[jsxs(b$2,{className:k$1,disabled:n,size:x,onClick:()=>a({approved:true,force:s,remember:e&&v}),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:k$1,disabled:n,size:x,variant:"outline",onClick:()=>{t?(c(""),u(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:m,children:[jsx(o,{checked:v,id:m,onCheckedChange:w=>d(w===true)}),"Always allow this tool for this automation"]}):null]}),t?jsx(c$1,{open:r,onOpenChange:u,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,{placeholder:"Optional reason for the agent...",value:i$1,onChange:w=>c(w.target.value)}),jsxs(j,{children:[jsx(b$2,{disabled:n,size:"sm",variant:"outline",onClick:()=>u(false),children:"Cancel"}),jsxs(b$2,{disabled:n,size:"sm",variant:"destructive",onClick:()=>a({approved:false,reason:i$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 Rn={always:"Every finished run",failures:"Failures only",never:"Never",when_flagged:"Results that need attention"};function Cn(e){return e.visibility==="personal"?"Only you":e.visibility==="space"?`Space: ${e.spaceLabel??"unknown"}`:"Everyone in the project"}function Pn({approval:e,instructions:t,isPending:a,proposal:n,onInstructionsChange:r}){let s=useId(),i=e.createdAutomation??null,u=[...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:Cn(n)},{label:"Data changes",value:n.mutationPolicy==="auto_approve"?"Applied without review":"Wait for approval"},{label:"Notifications",value:`${Rn[n.notifyRule]}${n.notifyCreator?", to you":""}${n.subscribers.length>0?` and ${n.subscribers.join(", ")}`:""}`},...n.plugins.length>0?[{label:"Plugins",value:n.plugins.map(c=>[c.account?`${c.name} as ${c.account}`:c.name,c.deliveryChannels.length>0?`posting to ${c.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:u.map(c=>jsxs("div",{className:"fk:contents",children:[jsx("dt",{className:"fk:text-muted-foreground",children:c.label}),jsx("dd",{className:"fk:whitespace-pre-line",children:c.value})]},c.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,{className:"fk:min-h-40 fk:text-sm",id:s,value:t,onChange:c=>r(c.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})]}),i?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/${i.automationId}`,children:"Open the automation"})}),i.runId?jsx(b$2,{asChild:true,size:"sm",variant:"ghost",children:jsx(Link,{to:`/${e.projectId}/ai/automations/${i.automationId}/runs/${i.runId}`,children:"View its first run"})}):null]}):null]})}function Tn({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 pt({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 mt({approval:e,automationInstructions:t,chat:a,errorMessage:n,isPending:r,isStale:s,onAutomationInstructionsChange:i}){let{preview:u}=e,c=a?ct(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(vn,{status:e.status}),e.kind==="schema"?jsx(b,{variant:"outline",children:"Schema change"}):null,e.kind==="automation"?jsx(b,{variant:"outline",children:u?.automationChange?"Automation change":"New automation"}):null,jsx("span",{className:"fk:text-sm fk:font-medium",children:a?xn(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"&&u?.automation?jsx(Pn,{approval:e,instructions:t??u.automation.instructions,isPending:r,proposal:u.automation,onInstructionsChange:i}):e.kind==="automation"&&u?.automationChange?jsx(Tn,{approval:e,change:u.automationChange}):e.kind==="schema"&&u?jsx(Nn,{preview:u}):u&&u.operations.length>0?jsx("div",{className:"fk:space-y-4",children:u.operations.map((p,f)=>jsxs("div",{className:"fk:space-y-2",children:[jsx("div",{className:"fk:text-sm fk:font-medium",children:yn(p)}),p.kind==="delete"&&p.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:[p.affectedCount.toString()," record",p.affectedCount===1?"":"s"," will be permanently deleted."]}):null,jsx(hn,{operation:p}),p.truncated?jsxs("div",{className:"fk:text-xs fk:text-muted-foreground",children:["Preview limited to the first ",p.rows.length.toString()," rows."]}):null]},f.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?c?`This action uses ${c.scope==="project"?"the project's":"your"} ${c.app} account${c.account?` (${c.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(bn,{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 kt({api:e,approval:t,chat:a,onDecided:n}){let{approval:r,decide:s,errorMessage:i,isDeciding:u,isPending:c,isRejectDialogOpen:p,isStale:f,rejectReason:k,setIsRejectDialogOpen:x,setRejectReason:v}=ft({api:e,approval:t,onDecided:n}),d=r.kind==="automation"?r.preview?.automation??null:null,[m,w]=useState(d?.instructions??"");return jsxs(Fragment,{children:[jsx(mt,{approval:r,automationInstructions:d?m:void 0,chat:a,errorMessage:i,isPending:c,isStale:f,onAutomationInstructionsChange:d?w:void 0}),c&&d?jsx("div",{className:"fk:mt-4",children:jsx(pt,{decide:s,instructions:m,isDeciding:u,proposal:d})}):c?jsx("div",{className:"fk:mt-4",children:jsx(dt,{allowRemember:!a&&r.kind==="plugin"&&!!r.automationId,askForRejectionReason:!a,decide:s,isDeciding:u,isRejectDialogOpen:p,isStale:f,rejectReason:k,setIsRejectDialogOpen:x,setRejectReason:v,variant:"inline"})}):null]})}function xr({api:e,approval:t,onClose:a,onDecided:n}){let{approval:r,decide:s,errorMessage:i,isDeciding:u,isPending:c,isRejectDialogOpen:p,isStale:f,rejectReason:k,setIsRejectDialogOpen:x,setRejectReason:v}=ft({api:e,approval:t,onDecided:n}),d=r.kind==="automation"?r.preview?.automation??null:null,[m,w]=useState(d?.instructions??"");return jsx(na,{actions:c&&d?jsx(pt,{decide:s,instructions:m,isDeciding:u,proposal:d}):c?jsx(dt,{allowRemember:r.kind==="plugin"&&!!r.automationId,askForRejectionReason:true,decide:s,isDeciding:u,isRejectDialogOpen:p,isStale:f,rejectReason:k,setIsRejectDialogOpen:x,setRejectReason:v,variant:"header"}):null,depth:0,isFocused:true,onClose:a,title:d?"Automation proposal":r.preview?.automationChange?"Automation change":"Mutation proposal",children:jsx(mt,{approval:r,automationInstructions:d?m:void 0,chat:false,errorMessage:i,isPending:c,isStale:f,onAutomationInstructionsChange:d?w:void 0})})}var Dn="Approved by Flexkit Jev policy",In="Approved by automation tool allow rule",Mn=new Set(["data-create-sandbox","data-execute-graphql","data-export-records","data-load-skill","data-plan","data-plugin-call","data-run-command","data-search-schema","data-update-memory","data-validate-graphql","data-web-search"]);function ue(e){return Mn.has(e)}function h(e){return e.data}function $e(e){return !e.decidedBy&&!!(e.reason?.startsWith(Dn)||e.reason?.startsWith(In))}function G(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 En(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 $n(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 _n(e,t){let n=($n(e)).split(/\r?\n/).map(c=>c.trim()).filter(Boolean),r=n[n.length-1];if(!r)return null;let i=/^\*\*(.+?)\*\*:?$/.exec(r)?.[1]??/^#{1,6}\s+(.+)$/.exec(r)?.[1]??/^(.+?[.!?])(?:\s|$)/.exec(r)?.[1]??r,u=En(i);return !u||/^reasoning$/i.test(u)?null:G(u)}function gt(e){return e.replace(/[_-]+/g," ").trim()}function zn(e){if(e.type==="data-load-skill"){let t=h(e);return t.status!=="loading"?null:t.skillName?G(`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-export-records"){let t=h(e);return t.status!=="loading"?null:t.rowCount>0?`Exporting records (${t.rowCount.toLocaleString("en-US")} so far)`:"Exporting records"}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?G(`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)?G(`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:G(`Calling ${t.pluginId}: ${gt(t.tool)}`)}if(e.type==="data-subtask"){let t=h(e);return t.status==="running"?G(`Running subtask: ${t.title}`):null}return null}var jn=new Set(["data-execute-graphql","data-search-schema","data-validate-graphql"]);function ge(e){if(!ue(e.type)||e.type==="data-plan"||jn.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??"")}: ${gt(String(t.tool??""))}`;default:return "The tool call failed"}}function ve(e){if(e.type==="step-start"||e.type==="reasoning")return true;if(ue(e.type))return ge(e)===null;if(e.type==="data-mutation-approval"){let t=h(e);return $e(t)&&t.status!=="error"}return false}function le(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:G(`Step ${(r+1).toString()} of ${n.steps.length.toString()}: ${n.steps[r].step}`)}return null}function On(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"?_n(a.text)??le(e):le(e):a.type==="data-mutation-approval"?h(a).status==="pending"?"Awaiting approval":le(e):a.type==="data-user-question"?h(a).status==="pending"?"Waiting for your answer":le(e):a.type==="text"?null:zn(a)??le(e)}return null}function _e(e){return e?e.parts.some(t=>t.type!=="data-mutation-approval"?false:h(t).status==="pending"):false}function ze(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 i=t[s.approvalId];i&&i!=="pending"&&n.push({...r,data:{...s,status:i}});}return a?{...e,parts:n}:e}function vt(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 Un(e){return vt(e,{pendingOnly:true})}function je(e){return !!e?.parts.some(t=>t.type==="data-user-question"&&h(t).status==="pending")}function yt(e){return e.map(()=>({other:"",selected:[]}))}function ht(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 bt(e,t,a){return e.multiSelect?{...t,other:a}:{other:a,selected:a.trim()?[]:t.selected}}function xt(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 wt(e){return e&&[...e.selected,...e.other?[`\u201C${e.other}\u201D`]:[]].join(", ")||"\u2014"}var St=20*1024*1024,Mr=10,At=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"]),Rt=new Set(["application/pdf","image/gif","image/jpeg","image/png","image/webp"]),Er=[...[...At].map(e=>`.${e}`),...Rt].join(",");function Ct(e){let t=e.lastIndexOf(".");return t<=0?"":e.slice(t+1).toLowerCase()}function Jn(e){let t=Ct(e.name);return (t?At.has(t):Rt.has(e.type))?e.size===0?`"${e.name}" is empty.`:e.size>St?`"${e.name}" exceeds the ${String(Math.round(St/(1024*1024)))} MB limit.`:null:`"${e.name}" is not supported. Attach images, PDFs, or text files.`}async function Xn(e){let a=await(await fetch(e.url)).blob();return new File([a],e.filename??"file",{type:e.mediaType||a.type})}function $r(e,t){let{attachments:a}=Nb(),n=useRef({}),[,r]=useState(0),s=useCallback(()=>r(p=>p+1),[]),i=useRef(a.remove);i.current=a.remove;let u=useRef(t);u.current=t,useEffect(()=>{let p=new Set(a.files.map(f=>f.id));for(let[f,k]of Object.entries(n.current))p.has(f)||(k.controller.abort(),delete n.current[f]);for(let f of a.files){if(n.current[f.id])continue;let k=new AbortController,x={controller:k,status:"uploading"};n.current[f.id]=x,(async()=>{try{let v=await Xn(f),d=Jn(v);if(d)throw new Error(d);let m=await e.uploadAgentChatAttachment(v,k.signal);if(k.signal.aborted)return;x.attachment=m,x.status="done";}catch(v){if(k.signal.aborted)return;x.status="error",delete n.current[f.id],i.current(f.id),u.current(v instanceof Error?v.message:"The file could not be uploaded.");}finally{s();}})();}s();},[e,a.files,s]);let c=Object.values(n.current).some(p=>p.status==="uploading");return {getUploaded:p=>p.map(f=>n.current[f]?.attachment).filter(f=>!!f),isUploading:c,isUploadingFile:p=>n.current[p]?.status==="uploading"}}function Ue(e){return !!e?.startsWith("image/")}function Pt({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 Tt({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 Dt({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(Tt,{label:`Remove ${e.filename}`,onRemove:n}):null]})}function Qn(e,t){let a=Ct(e);if(a)return a.toUpperCase();let n=t?.split("/")[1]?.split("+")[0];return n?n.toUpperCase():"FILE"}function It({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:Qn(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(Tt,{label:`Remove ${e.filename}`,onRemove:n}):null]})}function _r({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(Ue(r.mediaType)&&r.url){let s={filename:r.filename??"Image",url:r.url};return jsx(Dt,{image:s,isUploading:e.isUploadingFile(r.id),onOpen:()=>n(s),onRemove:()=>t.remove(r.id),sizeClassName:"fk:size-14"},r.id)}return jsx(It,{file:{filename:r.filename??"file",mediaType:r.mediaType},isUploading:e.isUploadingFile(r.id),onRemove:()=>t.remove(r.id)},r.id)})}),jsx(Pt,{image:a,onClose:()=>n(null)})]})}function zr(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 Mt({attachments:e}){let[t,a]=useState(null);if(e.length===0)return null;let n=e.filter(s=>Ue(s.mediaType)),r=e.filter(s=>!Ue(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(Dt,{image:s,onOpen:()=>a(s),sizeClassName:"fk:size-24"},s.url))}):null,jsx(Pt,{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(It,{file:s,href:s.url},s.url))}):null]})}function Qr(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 _t({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 Fr({api:e$1,chatId:t,onTurnIntoAutomation:a,projectId:n,sending:r=false}){let{data:s,mutate:i}=Yn(g(n).agentChat(t),f$1,{revalidateOnMount:false}),[u,c$1]=useState(null),p=s?.monitors??[];if(p.length===0)return null;async function f(k){c$1(k.id);try{await e$1.stopAgentChatMonitor(t,k.id),await i();}catch{oa$1.error("Unable to stop the monitor.");}finally{c$1(null);}}return jsx("div",{className:"fk:mx-auto fk:mb-2 fk:flex fk:max-w-4xl fk:flex-wrap fk:gap-2",children:p.map(k=>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: ",k.description," \xB7 expires ",formatDistance(new Date(k.expiresAt),new Date,{addSuffix:true})]}),a&&k.sourceType&&k.sourceType!=="job"?jsxs(b$1,{children:[jsx(c,{asChild:true,children:jsx(b$2,{"aria-label":`Turn ${k.description} into an automation`,className:"fk:size-6 fk:rounded-full",disabled:r,size:"icon",variant:"ghost",onClick:()=>a(k),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 ${k.description}`,className:"fk:size-6 fk:rounded-full",disabled:u===k.id,size:"icon",variant:"ghost",onClick:()=>{f(k);},children:jsx(XIcon,{className:"fk:size-3.5"})})}),jsx(e,{children:"Stop watching"})]})]},k.id))})}function Gn(e){let t=e.connections.filter(a=>a.isPrimary&&a.status==="connected");return t.find(a=>a.scope==="personal")??t.find(a=>a.scope==="project")??null}function zt(e,t,a){return a==="personal"?e.allowPersonal:t}function jt(e,t,a){if(!e.enabled)return {kind:"disabled"};let n=a?e.connections.find(i=>i.id===a&&i.status==="needs_auth"):void 0;if(n)return zt(e,t,n.scope)?{kind:"reconnect",connection:n}:{kind:"not_permitted"};let r=Gn(e);if(r)return {kind:"connected",connection:r};let s=e.scopes.filter(i=>zt(e,t,i));return s.length>0?{kind:"connect",scopes:s}:{kind:"not_permitted"}}var sa=createContext(null),Lt={personal:{description:"Only you can use this connection in this project.",title:"Personal"},project:{description:"Shared with project members who can use this plugin.",title:"Project"}};function Bt({name:e,src:t,size:a}){return jsx("span",{className:`fk:flex fk:shrink-0 fk:items-center fk:justify-center fk:rounded-xl fk:bg-muted fk:corner-squircle ${a==="lg"?"fk:size-16 fk:p-3":"fk:size-11 fk:p-2"}`,children:jsx("img",{alt:e,className:"fk:size-full fk:object-contain",src:t})})}function oa({busy:e,logoUrl:t,name:a,onContinue:n,onOpenChange:r,open:s,scopes:i}){let[u,c]=useState(i.length===1?i[0]??null:null),p=[{description:"Flexkit never sees your password.",title:`Sign in securely to your ${a} account`},{description:`The agent only gets the access you approve on ${a}'s sign-in page.`,title:"You decide what the agent can do"},{description:`Remove the connection to ${a} at any time.`,title:"You stay in control"}];return jsx(c$1,{onOpenChange:r,open:s,children:jsxs(h$1,{className:"fk:sm:max-w-md",children:[jsxs("div",{className:"fk:flex fk:flex-col fk:items-center fk:gap-3 fk:pt-2 fk:text-center",children:[jsx(Bt,{name:a,size:"lg",src:t}),jsxs(k,{className:"fk:text-xl",children:["Connect to ",a]}),jsxs(l,{children:["Let the Flexkit agent access and use ",a," on your behalf."]})]}),jsx("ul",{className:"fk:space-y-3 fk:rounded-xl fk:bg-muted/60 fk:p-4 fk:corner-squircle",children:p.map(f=>jsxs("li",{className:"fk:flex fk:gap-3",children:[jsx(CheckIcon,{className:"fk:mt-0.5 fk:size-4 fk:shrink-0"}),jsxs("span",{children:[jsx("span",{className:"fk:block fk:text-sm fk:font-medium",children:f.title}),jsx("span",{className:"fk:block fk:text-sm fk:text-muted-foreground",children:f.description})]})]},f.title))}),i.length>1?jsx("div",{className:"fk:space-y-1.5",role:"radiogroup","aria-label":"Connection",children:i.map(f=>jsxs("button",{"aria-checked":u===f,className:`fk:flex fk:w-full fk:flex-col fk:rounded-lg fk:border fk:px-3 fk:py-2 fk:text-left fk:corner-squircle ${u===f?"fk:border-primary fk:bg-primary/5":"fk:border-border fk:hover:bg-muted/60"}`,onClick:()=>c(f),role:"radio",type:"button",children:[jsx("span",{className:"fk:text-sm fk:font-medium",children:Lt[f].title}),jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:Lt[f].description})]},f))}):null,jsx("p",{className:"fk:text-center fk:text-xs fk:text-muted-foreground",children:"You can manage connections anytime in AI \u2192 Marketplace."}),jsx(b$2,{className:"fk:w-full",disabled:e||!u,onClick:()=>u&&n(u),type:"button",children:"Continue"})]})})}function Jt({connectionId:e,pluginId:t}){let{currentProjectId:a}=f(),n=useMemo(()=>a?d(a):null,[a]),r=a?`/api/flexkit/${a}`:null,s=r?`${r}/plugins/${encodeURIComponent(t)}`:null,{data:i,error:u,mutate:c}=Yn(s,f$1),{mutate:p}=useSWRConfig(),f$2=useContext(sa),[k,x]=useState(false),[v,d$1]=useState(false),m=useRef(false),[w,D]=useState(null);if(!i)return jsxs("div",{className:"fk:flex fk:items-center fk:gap-2 fk:rounded-2xl fk:border fk:border-border fk:p-4 fk:text-sm fk:text-muted-foreground fk:corner-squircle",children:[u?jsx(CircleAlertIcon,{className:"fk:size-4"}):jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}),u?`${t} could not be loaded.`:`Loading ${t}\u2026`]});let{plugin:S}=i,E=jt(S,i.canManage,e),b=E.kind==="reconnect"?E.connection:null;function M(ee){!n||m.current||(m.current=true,x(false),d$1(true),D(null),b$3(n,t,ee,b?{connectionId:b.id}:void 0).then(()=>{c().catch(()=>{}),r&&p(`${r}/plugins`).catch(()=>{}),f$2?.onConnected(t);},R=>{let Q=R instanceof Error?R.message:"";D({message:/popups|different account/i.test(Q)?Q:`${S.name} authorization didn't finish`,scope:ee});}).finally(()=>{m.current=false,d$1(false);}));}let $=null,I=null;return E.kind==="connected"?$=jsxs("span",{className:"fk:flex fk:items-center fk:gap-1.5 fk:text-sm fk:text-muted-foreground",children:[jsx(CheckIcon,{className:"fk:size-4 fk:text-green-700"}),"Connected \xB7 ",E.connection.displayName]}):E.kind==="disabled"?$=jsxs("span",{className:"fk:text-sm fk:text-muted-foreground",children:["An owner turned ",S.name," off for this project."]}):E.kind==="not_permitted"?$=jsxs("span",{className:"fk:text-sm fk:text-muted-foreground",children:["Ask a project owner or developer to connect ",S.name,"."]}):w?($=jsxs("span",{className:"fk:flex fk:items-center fk:gap-1.5 fk:text-sm fk:text-muted-foreground",children:[jsx(CircleAlertIcon,{className:"fk:size-4 fk:shrink-0 fk:text-amber-600"}),w.message]}),I=jsx(b$2,{disabled:v,onClick:()=>M(w.scope),size:"sm",type:"button",variant:"secondary",children:"Retry"})):I=jsxs(b$2,{disabled:v,onClick:()=>b?M(b.scope):x(true),size:"sm",type:"button",children:[v?jsx(LoaderCircle,{className:"fk:size-3.5 fk:animate-spin"}):null,b?"Reconnect":"Authorize"]}),jsxs("div",{className:"fk:space-y-2",children:[jsxs("div",{className:"fk:space-y-3 fk:rounded-2xl fk:border fk:border-border fk:bg-background fk:p-4 fk:corner-squircle",children:[jsxs("div",{className:"fk:flex fk:items-center fk:gap-3",children:[jsx(Bt,{name:S.name,size:"md",src:S.logoUrl}),jsxs("div",{className:"fk:min-w-0 fk:flex-1",children:[jsx("div",{className:"fk:truncate fk:font-medium",children:S.name}),jsx("div",{className:"fk:truncate fk:text-sm fk:text-muted-foreground",children:b?`Sign in again so the agent can keep using ${S.name}`:`Let the Flexkit agent use ${S.name}`})]}),I&&!w?I:null]}),$?jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:gap-3",children:[$,w?I:null]}):null]}),E.kind==="connect"||E.kind==="reconnect"?jsx("p",{className:"fk:px-1 fk:text-xs fk:text-muted-foreground",children:"Plugin actions follow your project's approval rules. Disconnect any time in AI \u2192 Marketplace."}):null,E.kind==="connect"?jsx(oa,{busy:v,logoUrl:S.logoUrl,name:S.name,onContinue:M,onOpenChange:x,open:k,scopes:E.scopes}):null]})}function rs({data:e,error:t,label:a}){return jsxs("div",{className:"fk:mr-auto fk:flex fk:max-w-[85%] fk:flex-wrap fk:items-center fk:gap-x-2 fk:gap-y-1 fk:text-sm fk:text-muted-foreground",children:[jsx(PlugIcon,{className:"fk:size-3.5 fk:shrink-0"}),jsxs("span",{children:["Connected ",jsx("span",{className:"fk:font-medium fk:text-foreground",children:e.pluginName}),e.accountName?` \xB7 ${e.accountName}`:""]}),a?jsxs("span",{className:"fk:text-xs",children:["\xB7 ",a]}):null,t?jsx("span",{className:"fk:text-xs fk:text-destructive",children:t}):null]})}function ss(e){let t=(Array.isArray(e)?e:[]).find(a=>a.type==="data-plugin-connected");return t&&typeof t.data=="object"&&t.data!==null?t.data:null}var oe=class extends Error{},he=class extends Error{};function Xt({url:e,signal:t,state:a,onState:n,wake:r,fetchStream:s=fetch,retryMs:i=2e3}){let u=0,c=0,p=new TransformStream,f=p.writable.getWriter(),k=new AbortController;f.closed.catch(m=>k.abort(m));let x=()=>{k.abort(t.reason),f.abort(t.reason).catch(()=>{});};t.addEventListener("abort",x,{once:true}),t.aborted&&x();let v=()=>new Promise(m=>{let w=()=>{clearTimeout(D),k.signal.removeEventListener("abort",w),r?.removeEventListener("wake",w),m();},D=setTimeout(w,i);k.signal.addEventListener("abort",w,{once:true}),r?.addEventListener("wake",w,{once:true}),k.signal.aborted&&w();});async function d(){try{for(await f.write({type:"start"});!k.signal.aborted;){try{let m=await s(`${e}${e.includes("?")?"&":"?"}wire=2&startIndex=${u}`,{credentials:"include",signal:k.signal});if(m.status===404){n("unavailable"),await f.close();return}if(m.status===401||m.status===403)throw new he("Stream access denied");if(!m.ok||!m.body)throw new Error(`Stream request failed: ${m.status}`);if(m.headers.get("x-flexkit-stream-version")!=="2")throw await m.body.cancel(),new oe("Backend uses legacy replay");n("streaming");let w=m.body.pipeThrough(new TextDecoderStream).getReader(),D="",S=!1;try{for(;!k.signal.aborted;){let{value:E,done:b}=await w.read();if(b)break;D+=E;let M;for(;(M=D.indexOf(`
6
+ `))>=0;){let $=D.slice(0,M);if(D=D.slice(M+1),!$)continue;let I=JSON.parse($);if(!Number.isSafeInteger(I.index)||I.index<0)throw new Error("Invalid replay cursor");if(!(I.index<u)){if(I.index!==u)throw new Error("Replay cursor gap");I.chunk&&await f.write(I.chunk),u=I.index+1,c=0,I.chunk?.type==="finish"&&I.chunk.messageMetadata?.flexkitTerminal&&(S=!0);}}if(D.length>2e6)throw new Error("Oversized replay frame");if(S)break}}finally{await w.cancel().catch(()=>{}),w.releaseLock();}if(S||a().terminal&&!D){await f.write({type:"finish"}),await f.close(),n("finished");return}}catch(m){if(k.signal.aborted||m instanceof oe||m instanceof he||++c>=5)throw m}do n(a().paused?"paused":"streaming"),await v();while(!k.signal.aborted&&a().paused&&!a().terminal)}}catch(m){await f.abort(m).catch(()=>{});}finally{t.removeEventListener("abort",x),f.releaseLock();}}return d(),pipeJsonRender(p.readable)}var ua={pending:"Waiting for an answer.",cancelled:"The turn was stopped before you answered.",dismissed:"You skipped these questions.",expired:"Nobody answered in time."};function ca({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 fa({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(ca,{description:r.description,label:r.label,multiSelect:n.multiSelect,onClick:()=>a(ht(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(bt(n,t,r.target.value)),placeholder:"Other \u2014 type your own answer",value:t.other})]})]})}function da({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:ua[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:wt(e.answers?.[a])})]},a))})}function Ft({answer:e,data:t}){let[a,n]=useState(()=>yt(t.questions)),[r,s]=useState(null),[i,u]=useState(null),[c,p]=useState(""),f=t.status==="pending"&&r?r:t;if(f.status!=="pending"||!e)return jsx(da,{data:f});let k=xt(a);async function x(v){if(e){u(v.action),p("");try{let d=await e(t.questionId,v);d&&s({...d.answers?{answers:d.answers}:{},...d.message!==null?{message:d.message}:{},questionId:d.id,questions:d.questions,status:d.status});}catch(d){p(d instanceof Error?d.message:"Could not send the answer.");}finally{u(null);}}}return jsxs("form",{className:"fk:space-y-5",onSubmit:v=>{v.preventDefault(),k&&x({action:"answer",answers:k});},children:[t.questions.map((v,d)=>jsx(fa,{disabled:i!==null,draft:a[d]??{other:"",selected:[]},onChange:m=>n(w=>w.map((D,S)=>S===d?m:D)),question:v},d)),c?jsx("p",{className:"fk:text-xs fk:text-destructive",children:c}):null,jsxs("div",{className:"fk:flex fk:flex-wrap fk:items-center fk:gap-2",children:[jsxs(b$2,{disabled:!k||i!==null,size:"sm",type:"submit",children:[i==="answer"?jsx(LoaderCircle,{className:"fk:size-3.5 fk:animate-spin"}):null,"Submit"]}),jsxs(b$2,{disabled:i!==null,onClick:()=>{x({action:"dismiss"});},size:"sm",type:"button",variant:"ghost",children:[i==="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 Ia=lazy(()=>import('./spec-renderer-EX7SCFWH.js').then(e=>({default:e.RunSpecPart})));function Ma(e){return jsx(Suspense,{fallback:null,children:jsx(Ia,{...e})})}function Ea(){let{currentProjectId:e}=f();return {api:useMemo(()=>e?d(e):null,[e]),projectId:e}}var Ht=5,en=2e3,tn=120,qe="data-spec",nn=createContext(null),$a=createContext(false);function _a(e){return new Promise(t=>window.setTimeout(t,e))}function za(e){return e instanceof Error?e.name==="AbortError"||e.message.toLowerCase().includes("aborted"):false}function ja(e){return e.some(t=>!ve(t))}function Oa(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 Ua(e){let t=Oa(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,i=()=>{ja(r)&&a.push({...n,id:`${n.id}-${s.toString()}`,parts:r}),s++,r=[];};for(let u of n.parts){if(u.type==="data-user-message"){let c=h(u);i(),a.push({id:u.id??crypto.randomUUID(),parts:c.parts,role:"user"});continue}r.push(u);}i();}return a}function $s(e){return useMemo(()=>Ua(e),[e])}function ie(e){return e==="success"||e==="failed"||e==="cancelled"||e==="skipped"}function an({latestMessage:e,recordStatus:t,suppressApprovalPause:a}){return ie(t)||a||t==="running"?false:t==="awaiting_approval"?true:_e(e)||je(e)}function _s(e,t){let[a,n]=useState(false),r=La(a?e:"",t),[s,i]=useState(),[u,c]=useState("streaming"),p=useRef(t);p.current=t;let f=useRef(null);f.current||(f.current=new EventTarget);let k=f.current,x=t?.resumeToken;return useEffect(()=>{k.dispatchEvent(new Event("wake"));},[x,k]),useEffect(()=>{if(n(false),i(void 0),!e){c("unavailable");return}let v=new AbortController,d,m,w=()=>{d=void 0,m&&!v.signal.aborted&&i({...m});},D=Xt({url:e,signal:v.signal,state:()=>({terminal:ie(p.current?.recordStatus),paused:an({latestMessage:m,recordStatus:p.current?.recordStatus,suppressApprovalPause:p.current?.suppressApprovalPause??false})}),onState:S=>{v.signal.aborted||c(S);},wake:k});return (async()=>{try{for await(let S of readUIMessageStream({stream:D,terminateOnError:!0}))m=S,d||(d=setTimeout(w,tn));w();}catch(S){if(v.signal.aborted)return;S instanceof oe?n(true):(console.error("Run stream error",S),c("error"));}})(),()=>{v.abort(),d&&clearTimeout(d);}},[e,k]),a?r:{message:s?ze(s,t?.decidedApprovals??{}):void 0,status:u}}function La(e,t){let[a,n]=useState(),[r,s]=useState("streaming"),i=t?.recordStatus,u=t?.resumeToken??0,c=useRef(t?.decidedApprovals??{});c.current=t?.decidedApprovals??{};let p=useRef(t?.suppressApprovalPause??false);p.current=t?.suppressApprovalPause??false;let f=useRef(e),k=useRef(a);return k.current=a,useEffect(()=>{let x=f.current!==e;if(f.current=e,!e){n(void 0),s("unavailable");return}let v=new AbortController,d=x?void 0:k.current,m=x?0:d?.parts.length??0;if(x)n(void 0);else if(d&&(i==="running"||ie(i))){let b=ze(d,c.current);b!==d&&(d=b,n(b));}s("streaming");let w=e.includes("?")?"&":"?",D=async()=>{let b=await fetch(`${e}${w}startIndex=0`,{credentials:"include",signal:v.signal});if(b.status===404)return "unavailable";if(!b.ok||!b.body)throw new Error(`Failed to fetch the run stream (status ${b.status.toString()})`);let M=false,I=parseJsonEventStream({schema:uiMessageChunkSchema,stream:b.body}).pipeThrough(new TransformStream({transform:(j,rn)=>{if(!j.success)throw j.error;j.value.type==="finish"&&(M=true),rn.enqueue(j.value);}})),ee=readUIMessageStream({onError:j=>{v.signal.aborted||console.error("Run stream chunk error",j);},stream:I}),R=null,Q=m===0,Fe=(j=false)=>{v.signal.aborted||!d||!Q&&(Q=j||d.parts.length>=m,!Q)||n({...d});};try{for await(let j of ee){if(v.signal.aborted)break;d=j,R===null&&(R=window.setTimeout(()=>{R=null,Fe();},tn));}}finally{R!==null&&(window.clearTimeout(R),R=null),Fe(true);}return M?"finished":"incomplete"},S=async()=>{let b=0;for(;!v.signal.aborted;){b>0&&await _a(en);try{let M=await D();if(v.signal.aborted)return;if(M==="unavailable"){s("unavailable");return}if(M==="finished"&&ie(i)){s("finished");return}if(ie(i)){s("finished");return}if(an({latestMessage:d,recordStatus:i,suppressApprovalPause:p.current})){s("paused");return}if(!(i==="running"||p.current)&&b>=Ht-1){s("error");return}}catch(M){if(v.signal.aborted||za(M))return;if(console.error("Run stream error",M),ie(i)){s("finished");return}if(!(i==="running"||p.current)&&b>=Ht-1){s("error");return}}b+=1;}},E=window.setTimeout(()=>{S();},0);return ()=>{window.clearTimeout(E),v.abort("Run replay unmounted");}},[i,u,e]),{message:a,status:r}}function zs(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 qa(e){let t=e.trim();return t?t.split(`
7
+ `).every(a=>/^`{3,}[\w-]*$/.test(a.trim())):false}function Ba({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(Mt,{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 js({api:e,part:t,partIndex:a,parts:n}){if(ve(t))return null;if(ue(t.type)){let r=ge(t);return r?jsx(Xa,{message:r}):null}if(t.type==="text")return qa(t.text)&&n.some(s=>s.type===qe)?null:jsx(Ja,{part:t});if(t.type==="data-generating-files")return jsx(Wa,{message:h(t)});if(t.type==="data-run-artifact")return jsx(Ya,{api:e,message:h(t)});if(t.type==="data-tool-delivery")return jsx(Ga,{message:h(t)});if(t.type==="data-run-summary")return jsx(Ka,{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(X,{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(xe,{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(_t,{data:r.monitorEvent}):jsx(Ba,{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(Jt,{connectionId:r.connectionId,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(X,{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 $e(r)?jsx(tr,{message:r}):jsx(Za,{api:e,message:r})}return t.type==="data-user-question"?jsx(er,{data:h(t)}):t.type==="data-bulk-graphql-action"?jsx(nr,{message:h(t)}):t.type===qe?n.slice(a+1).find(s=>s.type===qe)?null:jsx(Ma,{parts:n}):t.type.startsWith("data-")?jsx(ar,{part:t}):null}function Ja({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 Xa({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 Qa=1e3;function Fa({text:e}){let t=useRef(typeof performance>"u"?0:performance.now()),a=()=>-(((typeof performance>"u"?0:performance.now())-t.current)%Qa),[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 Ha=1e3;function Va(e,t){let a=Ha,[n,r]=useState(e),s=useRef(Date.now()),i=useRef(e);return i.current=e,useEffect(()=>{if(e===n)return;let u=Math.max(0,a-(Date.now()-s.current)),c=window.setTimeout(()=>{s.current=Date.now(),r(i.current);},u);return ()=>{window.clearTimeout(c);}},[n,e,a]),n}function Os({label:e,visible:t}){let a=Va(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(Fa,{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 X({children:e}){return jsx("div",{className:"fk:flex fk:items-center fk:gap-2 fk:font-medium fk:text-muted-foreground",children:e})}function xe({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 Qe({error:e,icon:t,loading:a,message:n,title:r}){return jsxs(J,{children:[jsxs(X,{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(xe,{isError:!!e,loading:a})}),jsx("span",{className:"fk:text-xs",children:n})]})]})}function Wa({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(X,{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(xe,{isError:e.status==="error",loading:e.status!=="error"}),jsx("span",{children:e.status==="error"?e.error?.message??n:n})]}):null]})]})}function Ya({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=rr(t.sizeBytes);return jsxs(J,{children:[jsxs(X,{children:[jsx(FileTextIcon,{className:"fk:size-3.5"}),t.kind==="csv"||t.kind==="json"?"Exported file":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(xe,{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"&&[sr(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:[t.kind==="csv"?null: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 Ga({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(Qe,{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 Ka({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(X,{children:[t,jsx("span",{children:a})]}),e.status==="failed"?jsx("p",{className:"fk:whitespace-pre-wrap fk:text-xs",children:e.summary}):null]})}function Za({api:e,message:t}){let{projectId:a}=Ea(),n=useContext(nn),r=useContext($a),s=useRef(void 0),{data:i,error:u,isValidating:c,mutate:p}=Yn(a?g(a).approval(t.approvalId):null,f$1,{refreshInterval:m=>t.status!=="pending"||m?.approval?.status&&m.approval.status!=="pending"?0:en}),f=i?.approval?.status,k=(f??t.status)==="pending",x=i?.approval?.kind==="schema"&&i.approval.status==="approved";useEffect(()=>{!x||!a||ke({approvalId:t.approvalId,approvalUrl:g(a).approval(t.approvalId),projectId:a});},[x,t.approvalId,a]),useEffect(()=>{p();},[t.status,p]),useEffect(()=>{let m=s.current;s.current=f,!(t.status!=="pending"||!f||f==="pending")&&m==="pending"&&n?.onApprovalDecided(i?.approval?.id??t.approvalId,f);},[f,i?.approval?.id,t.approvalId,t.status,n]);function v(m){m.status!=="pending"&&(s.current=m.status),p(),n?.onApprovalDecided(m.id,m.status);}let d;if(i?.approval)d=jsx(kt,{api:e,approval:i.approval,chat:r,onDecided:v},i.approval.status);else if(u&&!c){let m=u instanceof Error&&u.message?u.message:"Request failed";d=jsxs("div",{className:"fk:space-y-2",children:[jsxs("p",{className:"fk:text-xs fk:text-destructive",children:["Failed to load proposal ",t.operationsSummary,": ",m]}),jsx(b$2,{size:"sm",variant:"outline",onClick:()=>{p();},children:"Retry"})]});}else d=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(X,{children:[r?jsx(ShieldIcon,{className:"fk:size-3.5"}):jsx(DatabaseZapIcon,{className:"fk:size-3.5"}),r?"Approval request":"Mutation approval",k?jsx(LoaderCircle,{className:"fk:ml-1 fk:size-3.5 fk:animate-spin"}):null]}),jsx("div",{className:"fk:mt-2",children:d}),t.status==="error"&&t.error?jsx("p",{className:"fk:mt-2 fk:text-xs fk:text-destructive",children:t.error.message}):null]})}function er({data:e}){let t=useContext(nn),a=e.questions.length>1;return jsxs(J,{children:[jsxs(X,{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(Ft,{answer:t?.answerQuestion,data:e},e.status)})]})}function tr({message:e}){let t=e.operationsSummary.replace(/^Call /,"");return jsx(Qe,{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 nr({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(Qe,{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 ar({part:e}){return jsxs(J,{className:"fk:bg-muted/30",children:[jsxs(X,{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 rr(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 sr(e){return e.kind==="pdf"?"PDF artifact":e.kind==="html"?"HTML artifact":e.kind==="csv"?"CSV file":e.kind==="json"?"JSON file":"Artifact"}export{$a as A,$s as B,ie as C,_s as D,zs as E,js as F,Xa as G,Os as H,Za as I,rt as a,vn as b,kt as c,xr as d,ve as e,On as f,_e as g,vt as h,Un as i,je as j,St as k,Mr as l,Er as m,$r as n,_r as o,zr as p,Mt as q,Qr as r,_t as s,Fr as t,sa as u,rs as v,ss as w,Ea as x,en as y,nn as z};//# sourceMappingURL=chunk-B4WSTNZ3.js.map
8
+ //# sourceMappingURL=chunk-B4WSTNZ3.js.map