@flexkit/studio 0.2.17 → 0.2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/activity-nav-button-V5DFHADL.js +2 -0
- package/dist/{activity-nav-button-7SVTTHBQ.js.map → activity-nav-button-V5DFHADL.js.map} +1 -1
- package/dist/chat-page-LAK4TFN4.js +4 -0
- package/dist/chat-page-LAK4TFN4.js.map +1 -0
- package/dist/chunk-2NXQF2F7.js +2 -0
- package/dist/chunk-2NXQF2F7.js.map +1 -0
- package/dist/chunk-4IEOAKKK.js +2 -0
- package/dist/chunk-4IEOAKKK.js.map +1 -0
- package/dist/{chunk-3C2EG3SI.js → chunk-54AXLGAK.js} +2 -2
- package/dist/{chunk-3C2EG3SI.js.map → chunk-54AXLGAK.js.map} +1 -1
- package/dist/chunk-6RRB47OZ.js +8 -0
- package/dist/chunk-6RRB47OZ.js.map +1 -0
- package/dist/chunk-A7XHA2P6.js +3 -0
- package/dist/chunk-A7XHA2P6.js.map +1 -0
- package/dist/chunk-BMO7JFAX.js +2 -0
- package/dist/chunk-BMO7JFAX.js.map +1 -0
- package/dist/{chunk-U5D3EDCY.js → chunk-BMX4URYN.js} +2 -2
- package/dist/{chunk-U5D3EDCY.js.map → chunk-BMX4URYN.js.map} +1 -1
- package/dist/chunk-CLCIE5RF.js +2 -0
- package/dist/chunk-CLCIE5RF.js.map +1 -0
- package/dist/{chunk-RYKUNA7Z.js → chunk-DFLAX7EE.js} +2 -2
- package/dist/{chunk-RYKUNA7Z.js.map → chunk-DFLAX7EE.js.map} +1 -1
- package/dist/chunk-DGIY4SKN.js +7 -0
- package/dist/chunk-DGIY4SKN.js.map +1 -0
- package/dist/chunk-DHVKE36X.js +3 -0
- package/dist/chunk-DHVKE36X.js.map +1 -0
- package/dist/chunk-EMFHKTAV.js +2 -0
- package/dist/chunk-EMFHKTAV.js.map +1 -0
- package/dist/chunk-ERDARDGB.js +2 -0
- package/dist/chunk-ERDARDGB.js.map +1 -0
- package/dist/chunk-H2RWSC56.js +3 -0
- package/dist/chunk-H2RWSC56.js.map +1 -0
- package/dist/{chunk-FDN23BPI.js → chunk-HCJAM5LG.js} +2 -2
- package/dist/{chunk-FDN23BPI.js.map → chunk-HCJAM5LG.js.map} +1 -1
- package/dist/chunk-ME55YNBF.js +30 -0
- package/dist/chunk-ME55YNBF.js.map +1 -0
- package/dist/chunk-OOYCTZ3C.js +379 -0
- package/dist/chunk-OOYCTZ3C.js.map +1 -0
- package/dist/chunk-QWQHXMXW.js +2 -0
- package/dist/{chunk-FNWEP2NM.js.map → chunk-QWQHXMXW.js.map} +1 -1
- package/dist/{chunk-ALCK2BJY.js → chunk-UOR437J2.js} +2 -2
- package/dist/{chunk-ALCK2BJY.js.map → chunk-UOR437J2.js.map} +1 -1
- package/dist/{chunk-3KMR2CXS.js → chunk-V6RB45UU.js} +2 -2
- package/dist/{chunk-3KMR2CXS.js.map → chunk-V6RB45UU.js.map} +1 -1
- package/dist/chunk-VMWUMFUL.js +4 -0
- package/dist/chunk-VMWUMFUL.js.map +1 -0
- package/dist/chunk-XMOSCJOI.js +2 -0
- package/dist/chunk-XMOSCJOI.js.map +1 -0
- package/dist/chunk-XNHSHVG2.js +7 -0
- package/dist/chunk-XNHSHVG2.js.map +1 -0
- package/dist/chunk-YDVO6XWD.js +2 -0
- package/dist/chunk-YDVO6XWD.js.map +1 -0
- package/dist/chunk-ZKA2HKNI.js +2 -0
- package/dist/chunk-ZKA2HKNI.js.map +1 -0
- package/dist/entry-3JSFO4OU.js +2 -0
- package/dist/entry-3JSFO4OU.js.map +1 -0
- package/dist/index.css +712 -246
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/list-SY3L2ACH.js +3 -0
- package/dist/list-SY3L2ACH.js.map +1 -0
- package/dist/list-Z2C74QDN.js +2 -0
- package/dist/{list-EXNTXASK.js.map → list-Z2C74QDN.js.map} +1 -1
- package/dist/pages-INCA54HE.js +5 -0
- package/dist/{pages-NWZLOKQM.js.map → pages-INCA54HE.js.map} +1 -1
- package/dist/plugin-pages-WO3MCJKC.js +2 -0
- package/dist/{plugin-pages-2KMZFNFB.js.map → plugin-pages-WO3MCJKC.js.map} +1 -1
- package/dist/record-links-CTB4SC4J.js +2 -0
- package/dist/record-links-CTB4SC4J.js.map +1 -0
- package/dist/root-6MSWGFZX.js +2 -0
- package/dist/root-6MSWGFZX.js.map +1 -0
- package/dist/root-B4D3C37Q.js +2 -0
- package/dist/root-B4D3C37Q.js.map +1 -0
- package/dist/root-DOOWSYWY.js +23 -0
- package/dist/root-DOOWSYWY.js.map +1 -0
- package/dist/root-JA2LFGNX.js +2 -0
- package/dist/root-JA2LFGNX.js.map +1 -0
- package/dist/root-OGX4DUTM.js +2 -0
- package/dist/root-OGX4DUTM.js.map +1 -0
- package/dist/{root-BRCN3D2D.js → root-XHXX3SZG.js} +3 -3
- package/dist/{root-BRCN3D2D.js.map → root-XHXX3SZG.js.map} +1 -1
- package/dist/search-Z4M4R4NJ.js +2 -0
- package/dist/{search-7IJJYUSR.js.map → search-Z4M4R4NJ.js.map} +1 -1
- package/dist/skills-pages-TP2XQPCQ.js +2 -0
- package/dist/{skills-pages-4ELHNJVY.js.map → skills-pages-TP2XQPCQ.js.map} +1 -1
- package/dist/source-5J56KIFA.js +2 -0
- package/dist/source-5J56KIFA.js.map +1 -0
- package/dist/spec-renderer-3GAVSV52.js +2 -0
- package/dist/{spec-renderer-EX7SCFWH.js.map → spec-renderer-3GAVSV52.js.map} +1 -1
- package/dist/ui.d.ts +15 -5
- package/dist/ui.js +1 -1
- package/package.json +13 -5
- package/dist/activity-nav-button-7SVTTHBQ.js +0 -2
- package/dist/chat-page-X3MIN6YC.js +0 -4
- package/dist/chat-page-X3MIN6YC.js.map +0 -1
- package/dist/chunk-7ZFUS62K.js +0 -3
- package/dist/chunk-7ZFUS62K.js.map +0 -1
- package/dist/chunk-D6H64Z37.js +0 -8
- package/dist/chunk-D6H64Z37.js.map +0 -1
- package/dist/chunk-FNWEP2NM.js +0 -2
- package/dist/chunk-NLRSLQUT.js +0 -3
- package/dist/chunk-NLRSLQUT.js.map +0 -1
- package/dist/chunk-P6BZ4QP7.js +0 -2
- package/dist/chunk-P6BZ4QP7.js.map +0 -1
- package/dist/chunk-PKAWL5W4.js +0 -4
- package/dist/chunk-PKAWL5W4.js.map +0 -1
- package/dist/chunk-RNMAR527.js +0 -384
- package/dist/chunk-RNMAR527.js.map +0 -1
- package/dist/chunk-YCCFUGWJ.js +0 -7
- package/dist/chunk-YCCFUGWJ.js.map +0 -1
- package/dist/list-EXNTXASK.js +0 -2
- package/dist/pages-NWZLOKQM.js +0 -5
- package/dist/plugin-pages-2KMZFNFB.js +0 -2
- package/dist/root-A6FK3OR6.js +0 -2
- package/dist/root-A6FK3OR6.js.map +0 -1
- package/dist/root-CUNQWMK4.js +0 -23
- package/dist/root-CUNQWMK4.js.map +0 -1
- package/dist/root-SCCUPXFD.js +0 -2
- package/dist/root-SCCUPXFD.js.map +0 -1
- package/dist/search-7IJJYUSR.js +0 -2
- package/dist/skills-pages-4ELHNJVY.js +0 -2
- package/dist/spec-renderer-EX7SCFWH.js +0 -2
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import'./index.css';import {f}from'./chunk-A7XHA2P6.js';import {b as b$1,c}from'./chunk-5CVDMZUI.js';import {put}from'@vercel/blob/client';function b(i,o){let l=o.trim();return l?i.trim()?/\s$/.test(i)||/^[.,!?;:]/.test(l)?`${i}${l}`:`${i} ${l}`:i.length===0?l:`${i}${l}`:i}async function C(i){if(typeof window>"u")throw new Error("Dictation is only available in the browser.");let o=window.AudioContext??window.webkitAudioContext;if(!o)throw new Error("This browser cannot decode recorded audio.");let l=await i.arrayBuffer(),u=new o;try{let n=await u.decodeAudioData(l.slice(0)),s=S(n),t=I(s,n.sampleRate,24e3),e=P(t),a=t.length/24e3;if(a<.25)throw new Error("No speech was captured. Try again.");if(a>60)throw new Error(`Dictation is limited to ${String(60)} seconds.`);return {durationSeconds:a,pcm:new Blob([e],{type:"audio/pcm"})}}finally{await u.close();}}function S(i){let{length:o,numberOfChannels:l}=i;if(l===1)return i.getChannelData(0).slice();let u=new Float32Array(o);for(let n=0;n<o;n+=1){let s=0;for(let t=0;t<l;t+=1)s+=i.getChannelData(t)[n]??0;u[n]=s/l;}return u}function I(i,o,l){if(o===l)return i;let u=o/l,n=Math.max(1,Math.round(i.length/u)),s=new Float32Array(n);for(let t=0;t<n;t+=1){let e=t*u,a=Math.floor(e),c=Math.min(a+1,i.length-1),r=e-a,g=i[a]??0,m=i[c]??0;s[t]=g+(m-g)*r;}return s}function P(i){let o=new ArrayBuffer(i.length*2),l=new DataView(o);for(let u=0;u<i.length;u+=1){let n=Math.max(-1,Math.min(1,i[u]??0));l.setInt16(u*2,n<0?n*32768:n*32767,true);}return o}async function w(i){if(!(typeof crypto>"u"||!crypto.subtle))try{let o=await crypto.subtle.digest("SHA-256",await i.arrayBuffer());return Array.from(new Uint8Array(o),l=>l.toString(16).padStart(2,"0")).join("")}catch{return}}var d=class extends Error{code;status;constructor(o,l,u=null){super(l),this.name="AgentUploadError",this.code=u,this.status=o;}};function y(){if(typeof window>"u")return "flexkit.io";if(b$1())return c;let{hostname:i}=window.location;return i==="localhost"||i==="127.0.0.1"||i==="flexkit.test"||i.endsWith(".flexkit.test")?"flexkit.test":"flexkit.io"}function v(){return `https://${y()}`}function x(i,o){return `https://${i}.api.${y()}/automations/webhook/${encodeURIComponent(o)}`}function N(i){let o=`/api/flexkit/${i}`,l=`${o}/automations`,u=`${o}/skills`,n=`${o}/agent/chats`;async function s(t,e){let a=await fetch(t,{credentials:"include",headers:{"Content-Type":"application/json",...e?.headers??{}},...e}),c=await a.json();if(!a.ok){let r=c&&typeof c=="object"&&"error"in c?String(c.error):"Request failed";throw new Error(r)}return c}return {connectPlugins:t=>s(`${o}/plugins/connect`,{method:"POST",body:JSON.stringify(t)}),pluginOAuthStatus:t=>s(`${o}/plugins/oauth-transactions/${encodeURIComponent(t)}`),updatePluginConnection:(t,e)=>s(`${o}/plugin-connections/${encodeURIComponent(t)}`,{method:"PATCH",body:JSON.stringify(e)}),disconnectPlugin:t=>s(`${o}/plugin-connections/${encodeURIComponent(t)}`,{method:"DELETE"}),installPlugin:t=>s(`${o}/plugins/${encodeURIComponent(t)}/installation`,{method:"PUT",body:JSON.stringify({})}),setPluginPolicy:(t,e)=>s(`${o}/plugins/${encodeURIComponent(t)}/policy`,{method:"PATCH",body:JSON.stringify(e)}),refreshPluginTools:t=>s(`${o}/plugin-connections/${encodeURIComponent(t)}/tools/refresh`,{method:"POST"}),cancelRun:async t=>s(`${l}/runs/${encodeURIComponent(t)}/cancel`,{method:"POST"}),createAgentChat:async t=>s(n,{body:JSON.stringify({modelId:t?.modelId??null}),method:"POST"}),deleteAgentChat:async t=>s(`${n}/${encodeURIComponent(t)}`,{method:"DELETE"}),getAgentChatStreamUrl:(t,e)=>`${n}/${encodeURIComponent(t)}/stream?workflowRunId=${encodeURIComponent(e)}`,renameAgentChat:async(t,e)=>s(`${n}/${encodeURIComponent(t)}`,{body:JSON.stringify({title:e}),method:"PATCH"}),sendAgentChatMessage:async(t,e)=>s(`${n}/${encodeURIComponent(t)}/messages`,{body:JSON.stringify(e),method:"POST"}),announcePluginConnected:async(t,e)=>s(`${n}/${encodeURIComponent(t)}/plugin-connected`,{body:JSON.stringify({pluginId:e}),method:"POST"}),sendAgentChatFollowUp:async(t,e)=>s(`${n}/${encodeURIComponent(t)}/follow-ups`,{body:JSON.stringify(e),method:"POST"}),answerAgentChatQuestion:async(t,e,a)=>{let c=await fetch(`${n}/${encodeURIComponent(t)}/questions/${encodeURIComponent(e)}/answer`,{body:JSON.stringify(a),credentials:"include",headers:{"Content-Type":"application/json"},method:"POST"}),r=await c.json();if(!c.ok&&!r.question)throw new Error(r.errorMessage??r.error??"Request failed");return {errorMessage:c.ok?void 0:r.errorMessage,question:r.question}},startAgentChat:async({attachments:t,content:e,modelId:a})=>s(n,{body:JSON.stringify({message:{attachments:t,content:e},modelId:a??null}),method:"POST"}),startQueuedAgentChatMessage:async(t,e)=>s(`${n}/${encodeURIComponent(t)}/follow-ups/${encodeURIComponent(e)}/start`,{method:"POST"}),stopAgentChat:async t=>s(`${n}/${encodeURIComponent(t)}/stop`,{method:"POST"}),stopAgentChatMonitor:async(t,e)=>s(`${n}/${encodeURIComponent(t)}/monitors/${encodeURIComponent(e)}/stop`,{method:"POST"}),transcribeAgentAudio:async(t,e)=>{let{durationSeconds:a,pcm:c}=await C(t),r=new FormData;r.append("file",c,"audio.pcm"),r.append("durationSeconds",String(a));let g=await fetch(`${o}/agent/transcribe`,{body:r,credentials:"include",method:"POST",signal:e}),m=await g.json();if(!g.ok){let $=m&&typeof m=="object"&&m.error?String(m.error):"Request failed";throw new Error($)}if(!m.text?.trim())throw new Error("No speech was recognized. Try again.");return {text:m.text}},uploadAgentChatAttachment:async(t,e)=>{let[a,c]=await Promise.all([fetch(`${o}/agent/uploads`,{body:JSON.stringify({filename:t.name,mediaType:t.type||null,sizeBytes:t.size}),credentials:"include",headers:{"Content-Type":"application/json"},method:"POST",signal:e}),f({name:t.name,size:t.size})===null?w(t):void 0]),r=await a.json();if(!a.ok||!r.pathname||!r.token||!r.mediaType)throw new d(a.status,r.error?String(r.error):"The file could not be uploaded.",r.code??null);let g=await put(r.pathname,t,{abortSignal:e,access:"public",contentType:r.mediaType,token:r.token});return {filename:t.name,mediaType:r.mediaType,sizeBytes:t.size,url:g.url,...c?{sha256:c}:{}}},decideApproval:async(t,e)=>{let a=await fetch(`${l}/approvals/${encodeURIComponent(t)}/decide`,{body:JSON.stringify(e),credentials:"include",headers:{"Content-Type":"application/json"},method:"POST"}),c=await a.json();if(!a.ok&&typeof c.success!="boolean")throw new Error(c.error?String(c.error):"Request failed");return c},markActivityRead:async t=>s(`${o}/activity/read`,{body:JSON.stringify(t==="all"?{all:true}:{ids:t}),method:"POST"}),setActivityItemState:async(t,e)=>s(`${o}/activity/${encodeURIComponent(t)}`,{body:JSON.stringify({state:e}),method:"PATCH"}),createAutomation:async t=>s(l,{body:JSON.stringify(t),method:"POST"}),createSkill:async t=>s(u,{body:JSON.stringify(t),method:"POST"}),deleteAutomation:async t=>s(`${l}/${encodeURIComponent(t)}`,{method:"DELETE"}),deleteSkill:async t=>s(`${u}/${encodeURIComponent(t)}`,{method:"DELETE"}),getArtifactUrl:(t,e)=>{let a=e?.download?"?download=1":"";return `${l}/artifacts/${encodeURIComponent(t)}/content${a}`},getRunArtifacts:async t=>s(`${l}/runs/${encodeURIComponent(t)}/artifacts`).then(e=>e.artifacts),getStreamUrl:t=>`${l}/runs/${encodeURIComponent(t)}/stream`,getTranscriptUrl:t=>`${l}/runs/${encodeURIComponent(t)}/transcript`,listChannels:async(t,e)=>{let a=e?`${o}/plugin-connections/${encodeURIComponent(e)}/channels`:`${o}/plugins/${t}/channels`,c=await fetch(a,{credentials:"include",headers:{"Content-Type":"application/json"}}),r=await c.json();if(c.ok)return {channels:r.channels??[],errorMessage:r.errorMessage,success:r.success??true};if(r.success===false)return {channels:r.channels??[],errorMessage:r.errorMessage??`Failed to load ${t==="slack"?"Slack":"Teams"} channels.`,success:false};let g=r.error?String(r.error):"Request failed";throw new Error(g)},runAutomation:async t=>s(`${l}/${encodeURIComponent(t)}/runs`,{method:"POST"}),updateAutomation:async(t,e)=>s(`${l}/${encodeURIComponent(t)}`,{body:JSON.stringify(e),method:"PATCH"}),updateSkill:async(t,e)=>s(`${u}/${encodeURIComponent(t)}`,{body:JSON.stringify(e),method:"PATCH"})}}var p=class extends Error{status;constructor(o,l="Request failed"){super(l),this.name="FetcherError",this.status=o;}},D=async i=>{let o=await fetch(i,{credentials:"include"});if(!o.ok)throw new p(o.status);return await o.json()};function E(i){let o=`/api/flexkit/${i}/automations`,l=`/api/flexkit/${i}/skills`,u=`/api/flexkit/${i}/agent/chats`;return {activity:(n={})=>{let{filter:s="all",limit:t=25,offset:e=0}=n,a=new URLSearchParams({filter:s,limit:t.toString(),offset:e.toString()});return `/api/flexkit/${i}/activity?${a.toString()}`},activityItem:n=>`/api/flexkit/${i}/activity/${encodeURIComponent(n)}`,activitySummary:n=>n?`/api/flexkit/${i}/activity/summary?since=${encodeURIComponent(n)}`:`/api/flexkit/${i}/activity/summary`,agentChat:n=>`${u}/${encodeURIComponent(n)}`,agentChatSearch:n=>`${u}/search?q=${encodeURIComponent(n)}`,agentChats:(n=0)=>`${u}?offset=${n.toString()}`,agentProfile:()=>`/api/flexkit/${i}/agent/profile`,approval:n=>`${o}/approvals/${encodeURIComponent(n)}`,approvals:(n={})=>{let{limit:s=25,offset:t=0,runId:e,status:a}=n,c=new URLSearchParams({limit:s.toString(),offset:t.toString()});return a&&c.set("status",a),e&&c.set("runId",e),`${o}/approvals?${c.toString()}`},approvalsCount:`${o}/approvals?limit=1`,automation:n=>`${o}/${encodeURIComponent(n)}`,automationRuns:(n,s=0,t=25)=>`${o}/${encodeURIComponent(n)}/runs?offset=${s.toString()}&limit=${t.toString()}`,automations:(n={})=>{let{enabled:s,limit:t=25,offset:e=0,search:a,visibility:c}=n,r=new URLSearchParams({limit:t.toString(),offset:e.toString()});s&&s.length>0&&r.set("enabled",s.map(m=>m?"true":"false").join(",")),c&&c.length>0&&r.set("visibility",c.join(","));let g=a?.trim();return g&&r.set("q",g),`${o}?${r.toString()}`},creditBalance:`${o}/credits`,entities:`${o}/entities`,run:n=>`${o}/runs/${encodeURIComponent(n)}`,runHistory:(n,s=0,t=25)=>`${o}/runs?scope=${n}&offset=${s.toString()}&limit=${t.toString()}`,skill:n=>`${l}/${encodeURIComponent(n)}`,skills:(n={})=>{let{limit:s=25,offset:t=0,search:e,visibility:a}=n,c=new URLSearchParams({limit:s.toString(),offset:t.toString()});a&&a.length>0&&c.set("visibility",a.join(","));let r=e?.trim();return r&&c.set("q",r),`${l}?${c.toString()}`},spaces:`/api/flexkit/${i}/spaces`,members:n=>n?`/api/flexkit/${i}/members?spaceId=${encodeURIComponent(n)}`:`/api/flexkit/${i}/members`,tools:n=>n?`${o}/${encodeURIComponent(n)}/tools`:`${o}/tools`}}
|
|
2
|
+
export{b as a,v as b,x as c,N as d,p as e,D as f,E as g};//# sourceMappingURL=chunk-DHVKE36X.js.map
|
|
3
|
+
//# sourceMappingURL=chunk-DHVKE36X.js.map
|
|
@@ -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","sha256Hex","file","digest","byte","AgentUploadError","status","message","code","getApiRootDomain","getDesktop","flexkitDomain","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","tokenResponse","sha256","getKnowledgeFileProblem","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":"2IAIO,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,EAAGF,CAAQ,CAAA,EAAGE,CAAQ,CAAA,CAAA,CAGxB,CAAA,EAAGF,CAAQ,CAAA,CAA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B,CAAAA,CACjDW,CAAAA,CAAS,IAAI,eAAA,CAAgB,CACjC,KAAA,CAAOF,CAAAA,CAAM,QAAA,GACb,MAAA,CAAQC,CAAAA,CAAO,QAAA,EACjB,CAAC,CAAA,CAEGM,CAAAA,EAAcA,CAAAA,CAAW,MAAA,CAAS,CAAA,EACpCL,CAAAA,CAAO,GAAA,CAAI,YAAA,CAAcK,CAAAA,CAAW,IAAA,CAAK,GAAG,CAAC,CAAA,CAG/C,IAAME,CAAAA,CAAgBH,CAAAA,EAAQ,IAAA,EAAK,CAEnC,OAAIG,CAAAA,EACFP,CAAAA,CAAO,GAAA,CAAI,GAAA,CAAKO,CAAa,CAAA,CAGxB,CAAA,EAAGvD,CAAc,CAAA,CAAA,EAAIgD,EAAO,QAAA,EAAU,CAAA,CAC/C,CAAA,CACA,MAAA,CAAQ,CAAA,aAAA,EAAgBrD,CAAS,CAAA,OAAA,CAAA,CACjC,OAAA,CAAU8D,CAAAA,EACRA,CAAAA,CACI,CAAA,aAAA,EAAgB9D,CAAS,CAAA,iBAAA,EAAoB,kBAAA,CAAmB8D,CAAO,CAAC,CAAA,CAAA,CACxE,CAAA,aAAA,EAAgB9D,CAAS,CAAA,QAAA,CAAA,CAC/B,KAAA,CAAQuC,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-DHVKE36X.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 { getKnowledgeFileProblem } from '../knowledge/knowledge';\nimport type { PluginConnection, PluginScope, PluginTools } from './plugin-types';\nimport { put } from '@vercel/blob/client';\nimport { convertRecordedAudioToPcm } from './agent/dictation';\nimport { getDesktop } from '../../core/desktop';\nimport { flexkitDomain } from '../../core/domains';\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/** Lowercase hex SHA-256 of a file, or undefined where the browser cannot hash (insecure contexts). */\nasync function sha256Hex(file: File): Promise<string | undefined> {\n if (typeof crypto === 'undefined' || !crypto.subtle) {\n return undefined;\n }\n\n try {\n const digest = await crypto.subtle.digest('SHA-256', await file.arrayBuffer());\n\n return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('');\n } catch {\n return undefined;\n }\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: (\n _id: string\n ) => 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: (\n _provider: AutomationToolProvider,\n _connectionId?: string | null\n ) => 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\nfunction getApiRootDomain(): string {\n if (typeof window === 'undefined') {\n return 'flexkit.io';\n }\n\n // The desktop app serves the Studio on its own scheme (`flexkit://app`), so\n // its page hostname says nothing; the backend it was built for does.\n if (getDesktop()) {\n return flexkitDomain;\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) =>\n 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)}`, {\n method: 'PATCH',\n body: JSON.stringify(input),\n }),\n disconnectPlugin: (id) =>\n request(`${projectBasePath}/plugin-connections/${encodeURIComponent(id)}`, { method: 'DELETE' }),\n installPlugin: (id) =>\n request(`${projectBasePath}/plugins/${encodeURIComponent(id)}/installation`, {\n method: 'PUT',\n body: JSON.stringify({}),\n }),\n setPluginPolicy: (id, input) =>\n request(`${projectBasePath}/plugins/${encodeURIComponent(id)}/policy`, {\n method: 'PATCH',\n body: JSON.stringify(input),\n }),\n refreshPluginTools: (id) =>\n 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. The hash is computed\n // alongside: Knowledge documents are keyed by it, so the platform can tell\n // later whether this file is already one.\n const [tokenResponse, sha256] = await Promise.all([\n 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 // Only files Knowledge can index are worth hashing; a screenshot never matches a document.\n getKnowledgeFileProblem({ name: file.name, size: file.size }) === null ? sha256Hex(file) : undefined,\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 ...(sha256 ? { sha256 } : {}),\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?: {\n limit?: number;\n offset?: number;\n search?: string;\n visibility?: AutomationVisibility[];\n }) => 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 {N,R as R$1,S,T,V,W,X,P}from'./chunk-DGIY4SKN.js';import {LibraryIcon,CheckCircle2Icon,LoaderCircleIcon,CircleAlertIcon}from'lucide-react';import {useSearchParams,useLocation,NavLink}from'react-router-dom';import {jsx,jsxs}from'react/jsx-runtime';var f=NavLink,y=[{icon:jsx(LibraryIcon,{className:"fk:size-4",strokeWidth:2}),label:"All documents",status:null},{icon:jsx(CheckCircle2Icon,{className:"fk:size-4",strokeWidth:2}),label:"Ready",status:"ready"},{icon:jsx(LoaderCircleIcon,{className:"fk:size-4",strokeWidth:2}),label:"Indexing",status:"processing"},{icon:jsx(CircleAlertIcon,{className:"fk:size-4",strokeWidth:2}),label:"Failed",status:"failed"}];function I(){let[n]=useSearchParams(),t=n.get("status");return t==="ready"||t==="processing"||t==="failed"?t:void 0}function R(){let{pathname:n}=useLocation(),t=I(),m=/\/knowledge\/?$/.test(n),s=/^(.*\/knowledge)(?:\/|$)/.exec(n)?.[1]??"knowledge";return jsxs(N,{collapsible:"icon",variant:"inset",children:[jsx(R$1,{children:jsxs(S,{children:[jsx(T,{children:"Documents"}),jsx(V,{children:y.map(a=>jsx(W,{children:jsx(X,{asChild:true,isActive:m&&(t??null)===a.status,tooltip:a.label,children:jsxs(f,{end:true,to:a.status?`${s}?status=${a.status}`:s,children:[a.icon,jsx("span",{children:a.label})]})})},a.label))})]})}),jsx(P,{})]})}export{I as a,R as b};//# sourceMappingURL=chunk-EMFHKTAV.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-EMFHKTAV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/apps/knowledge/sidebar.tsx"],"names":["NavLinkCompat","NavLink","FILTERS","jsx","LibraryIcon","CheckCircle2Icon","LoaderCircleIcon","CircleAlertIcon","useKnowledgeStatusFilter","searchParams","useSearchParams","value","KnowledgeSidebar","pathname","useLocation","status","onList","base","jsxs","Sidebar","SidebarContent","SidebarGroup","SidebarGroupLabel","SidebarMenu","filter","SidebarMenuItem","SidebarMenuButton","SidebarRail"],"mappings":"kRAeA,IAAMA,CAAAA,CAAgBC,OAAAA,CAMhBC,CAAAA,CAAwF,CAC5F,CAAE,IAAA,CAAMC,GAAAA,CAACC,WAAAA,CAAA,CAAY,SAAA,CAAU,YAAY,WAAA,CAAa,CAAA,CAAG,CAAA,CAAI,KAAA,CAAO,eAAA,CAAiB,MAAA,CAAQ,IAAK,CAAA,CACpG,CAAE,IAAA,CAAMD,GAAAA,CAACE,gBAAAA,CAAA,CAAiB,UAAU,WAAA,CAAY,WAAA,CAAa,CAAA,CAAG,CAAA,CAAI,KAAA,CAAO,OAAA,CAAS,OAAQ,OAAQ,CAAA,CACpG,CAAE,IAAA,CAAMF,GAAAA,CAACG,gBAAAA,CAAA,CAAiB,SAAA,CAAU,WAAA,CAAY,WAAA,CAAa,CAAA,CAAG,CAAA,CAAI,KAAA,CAAO,WAAY,MAAA,CAAQ,YAAa,CAAA,CAC5G,CAAE,IAAA,CAAMH,GAAAA,CAACI,gBAAA,CAAgB,SAAA,CAAU,WAAA,CAAY,WAAA,CAAa,CAAA,CAAG,CAAA,CAAI,MAAO,QAAA,CAAU,MAAA,CAAQ,QAAS,CACvG,CAAA,CAGO,SAASC,GAA8D,CAC5E,GAAM,CAACC,CAAY,CAAA,CAAIC,eAAAA,GACjBC,CAAAA,CAAQF,CAAAA,CAAa,GAAA,CAAI,QAAQ,CAAA,CAEvC,OAAOE,CAAAA,GAAU,OAAA,EAAWA,CAAAA,GAAU,YAAA,EAAgBA,CAAAA,GAAU,Q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AA,CACH,CAAA,CAAA,CACF,CAAA,CACF,CAAA,CACArB,GAAAA,CAACwB,CAAAA,CAAA,EAAY,CAAA,CAAA,CACf,CAEJ","file":"chunk-EMFHKTAV.js","sourcesContent":["import type { JSX } from 'react';\nimport { CheckCircle2Icon, CircleAlertIcon, LibraryIcon, LoaderCircleIcon } from 'lucide-react';\nimport { NavLink, useLocation, useSearchParams } from 'react-router-dom';\nimport {\n SidebarContent,\n SidebarGroup,\n SidebarGroupLabel,\n SidebarMenu,\n SidebarMenuButton,\n SidebarMenuItem,\n SidebarPanel,\n SidebarRail,\n} from '../../ui';\nimport type { KnowledgeSourceStatus } from './knowledge';\n\nconst NavLinkCompat = NavLink as unknown as React.ComponentType<{\n children?: React.ReactNode;\n end?: boolean;\n to: string;\n}>;\n\nconst FILTERS: { icon: JSX.Element; label: string; status: KnowledgeSourceStatus | null }[] = [\n { icon: <LibraryIcon className=\"fk:size-4\" strokeWidth={2} />, label: 'All documents', status: null },\n { icon: <CheckCircle2Icon className=\"fk:size-4\" strokeWidth={2} />, label: 'Ready', status: 'ready' },\n { icon: <LoaderCircleIcon className=\"fk:size-4\" strokeWidth={2} />, label: 'Indexing', status: 'processing' },\n { icon: <CircleAlertIcon className=\"fk:size-4\" strokeWidth={2} />, label: 'Failed', status: 'failed' },\n];\n\n/** The status the list is filtered on, read from `?status=`; anything else means every document. */\nexport function useKnowledgeStatusFilter(): KnowledgeSourceStatus | undefined {\n const [searchParams] = useSearchParams();\n const value = searchParams.get('status');\n\n return value === 'ready' || value === 'processing' || value === 'failed' ? value : undefined;\n}\n\nexport function KnowledgeSidebar(): JSX.Element {\n const { pathname } = useLocation();\n const status = useKnowledgeStatusFilter();\n const onList = /\\/knowledge\\/?$/.test(pathname);\n // Links resolve against the app root whether the list or a document is open.\n const base = /^(.*\\/knowledge)(?:\\/|$)/.exec(pathname)?.[1] ?? 'knowledge';\n\n return (\n <SidebarPanel collapsible=\"icon\" variant=\"inset\">\n <SidebarContent>\n <SidebarGroup>\n <SidebarGroupLabel>Documents</SidebarGroupLabel>\n <SidebarMenu>\n {FILTERS.map((filter) => (\n <SidebarMenuItem key={filter.label}>\n <SidebarMenuButton\n asChild\n isActive={onList && (status ?? null) === filter.status}\n tooltip={filter.label}\n >\n <NavLinkCompat end to={filter.status ? `${base}?status=${filter.status}` : base}>\n {filter.icon}\n <span>{filter.label}</span>\n </NavLinkCompat>\n </SidebarMenuButton>\n </SidebarMenuItem>\n ))}\n </SidebarMenu>\n </SidebarGroup>\n </SidebarContent>\n <SidebarRail />\n </SidebarPanel>\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/get-display-attribute.ts"],"names":["getDisplayAttribute","entity","attr"],"mappings":"oBAOO,SAASA,CAAAA,CAAoBC,CAAAA,CAAmD,CACrF,GAAKA,CAAAA,EAAQ,UAAA,CAAW,MAAA,CAIxB,OAAIA,CAAAA,CAAO,OAAA,CACFA,CAAAA,CAAO,UAAA,CAAW,IAAA,CAAMC,GAASA,CAAAA,CAAK,IAAA,GAASD,CAAAA,CAAO,OAAO,CAAA,EAAKA,CAAAA,CAAO,UAAA,CAAW,CAAC,CAAA,CAGvFA,CAAAA,CAAO,UAAA,CAAW,CAAC,CAC5B","file":"chunk-ERDARDGB.js","sourcesContent":["import type { Attribute, Entity } from './types';\n\n/**\n * Resolve the attribute used as the entity's human-readable label.\n * Uses `entity.display` when it matches an attribute name; otherwise the first attribute.\n * The effective display attribute must not be space-bound (enforced at define/deploy time).\n */\nexport function getDisplayAttribute(entity: Entity | undefined): Attribute | undefined {\n if (!entity?.attributes.length) {\n return undefined;\n }\n\n if (entity.display) {\n return entity.attributes.find((attr) => attr.name === entity.display) ?? entity.attributes[0];\n }\n\n return entity.attributes[0];\n}\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import'./index.css';import {g,d as d$1}from'./chunk-2HYQVMP3.js';import {b as b$1}from'./chunk-U45E5X3H.js';import {createContext,lazy,Suspense,useMemo,useContext}from'react';import {Navigate,useParams}from'react-router-dom';import {Bot,Layout,FileStack,BookOpenText,Waypoints,SquarePlay}from'lucide-react';import {jsx,jsxs}from'react/jsx-runtime';import w,{mutate}from'swr';var d={name:"_asset",plural:"_assets",display:"originalFilename",menu:{hidden:true},attributes:[{name:"path",label:"Asset",scope:"global",options:{size:140},dataType:"string",inputType:"text",previewType:"assetPreviewField",defaultValue:""},{name:"originalFilename",label:"Filename",scope:"global",options:{size:320},dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"size",label:"Size",scope:"global",options:{size:120},dataType:"int",inputType:"text",previewType:"text",defaultValue:""},{name:"width",label:"Width",scope:"global",options:{size:90},dataType:"int",inputType:"text",previewType:"text",defaultValue:""},{name:"height",label:"Height",scope:"global",options:{size:100},dataType:"int",inputType:"text",previewType:"text",defaultValue:""},{name:"mimeType",label:"Mime Type",scope:"global",options:{size:160},dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"lqip",label:"lqip",scope:"global",hidden:true,dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"url",label:"URL",scope:"global",hidden:true,readOnly:true,dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"_updatedAt",label:"Updated At",scope:"global",options:{size:220},readOnly:true,hidden:true,dataType:"datetime",inputType:"datetime",previewType:"datetime",defaultValue:""},{name:"tags",label:"Tags",scope:"relationship",dataType:"string",inputType:"relationship",defaultValue:"",previewType:"tags",options:{size:300},relationship:{mode:"multiple",field:"name",entity:"_tag"}}]};var f={name:"_tag",plural:"_tags",display:"name",menu:{hidden:true},attributes:[{name:"name",label:"Tag Name",scope:"global",options:{size:220},dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"_updatedAt",label:"Updated At",scope:"global",options:{size:220},readOnly:true,hidden:true,dataType:"datetime",inputType:"datetime",previewType:"datetime",defaultValue:""},{name:"assets",label:"Assets",scope:"relationship",dataType:"string",inputType:"relationship",defaultValue:"",relationship:{mode:"multiple",field:"originalFilename",entity:"_asset"}}]};function x(){let{resolvedTheme:e}=b$1();return jsx("div",{className:"fk:flex fk:w-full fk:h-full fk:justify-center fk:items-center fk:bg-background",children:jsxs("div",{className:"fk:flex fk:flex-col fk:items-center",children:[e==="dark"?jsxs("svg",{className:"fk:h-8 fk:w-8 fk:animate-bounce",fill:"none",viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M7 8H41V40H7V8Z",fill:"#020817"}),jsx("path",{d:"M24 0C42 0 48 6 48 24C48 42 42 48 24 48C6 48 0 42 0 24C0 6 6 0 24 0ZM17.7494 9.52381H8.7619L19.2833 23.8313L8.7619 38.7078H17.7494L21.0499 33.6639V14.2549L17.7494 9.52381ZM38.9577 9.52381H29.9542L26.2857 14.8229V33.0406L29.9542 38.7078H38.9577L28.3908 23.8313L38.9577 9.52381Z",fill:"white"})]}):jsxs("svg",{className:"fk:h-8 fk:w-8 fk:animate-bounce",fill:"none",viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M7 8H41V40H7V8Z",fill:"white"}),jsx("path",{d:"M24 0C42 0 48 6 48 24C48 42 42 48 24 48C6 48 0 42 0 24C0 6 6 0 24 0ZM17.7494 9.52381H8.7619L19.2833 23.8313L8.7619 38.7078H17.7494L21.0499 33.6639V14.2549L17.7494 9.52381ZM38.9577 9.52381H29.9542L26.2857 14.8229V33.0406L29.9542 38.7078H38.9577L28.3908 23.8313L38.9577 9.52381Z",fill:"#020817"})]}),jsx("div",{className:"fk:text-foreground fk:text-center fk:mt-4 fk:animate-pulse",children:"Loading..."})]})})}var _=Navigate;function o(e){let t=lazy(e);return jsx(Suspense,{fallback:jsx(x,{}),children:jsx(t,{})})}var J=o(()=>import('./root-JA2LFGNX.js').then(e=>({default:e.Root}))),X=o(()=>import('./list-Z2C74QDN.js').then(e=>({default:e.List}))),q=o(()=>import('./edit-entity-PVT34FD7.js').then(e=>({default:e.EditEntity}))),K=o(()=>import('./root-DOOWSYWY.js').then(e=>({default:e.Root}))),G=o(()=>import('./root-6MSWGFZX.js').then(e=>({default:e.Root}))),$=o(()=>import('./list-SY3L2ACH.js').then(e=>({default:e.List}))),Q=o(()=>import('./source-5J56KIFA.js').then(e=>({default:e.Source}))),Y=o(()=>import('./root-B4D3C37Q.js').then(e=>({default:e.Root}))),ee=o(()=>import('./root-XHXX3SZG.js').then(e=>({default:e.Root}))),te=o(()=>import('./root-OGX4DUTM.js').then(e=>({default:e.Root}))),oe=o(()=>import('./plugin-pages-WO3MCJKC.js').then(e=>({default:e.PluginsPage}))),ne=o(()=>import('./plugin-pages-WO3MCJKC.js').then(e=>({default:e.InstalledPluginsPage}))),ae=o(()=>import('./plugin-pages-WO3MCJKC.js').then(e=>({default:e.PluginDetailPage}))),T=o(()=>import('./chat-page-LAK4TFN4.js').then(e=>({default:e.AgentChatPage}))),ie=o(()=>import('./pages-INCA54HE.js').then(e=>({default:e.AutomationsPage}))),re=o(()=>import('./pages-INCA54HE.js').then(e=>({default:e.RunHistoryPage}))),se=o(()=>import('./pages-INCA54HE.js').then(e=>({default:e.ApprovalsPage}))),pe=o(()=>import('./pages-INCA54HE.js').then(e=>({default:e.ActivityPage}))),ce=o(()=>import('./pages-INCA54HE.js').then(e=>({default:e.ActivityItemPage}))),le=o(()=>import('./pages-INCA54HE.js').then(e=>({default:e.CreateAutomationPage}))),me=o(()=>import('./pages-INCA54HE.js').then(e=>({default:e.AutomationDetailPage}))),ue=o(()=>import('./pages-INCA54HE.js').then(e=>({default:e.RunsPage}))),de=o(()=>import('./pages-INCA54HE.js').then(e=>({default:e.RunDetailPage}))),fe=o(()=>import('./skills-pages-TP2XQPCQ.js').then(e=>({default:e.SkillsPage}))),ge=o(()=>import('./skills-pages-TP2XQPCQ.js').then(e=>({default:e.CreateSkillPage}))),he=o(()=>import('./skills-pages-TP2XQPCQ.js').then(e=>({default:e.SkillDetailPage}))),l=[{name:"ai",icon:jsx(Bot,{strokeWidth:1.5}),title:"AI",component:te,routes:[{path:"plugins",component:oe},{path:"plugins/installed",component:ne},{path:"plugins/:pluginId",component:ae},{component:jsx(_,{replace:true,to:"agent"}),path:""},{component:T,path:"agent"},{component:T,path:"agent/chats/:chatId"},{component:ie,path:"automations"},{component:re,path:"runs"},{component:se,path:"approvals"},{component:pe,path:"activity"},{component:ce,path:"activity/:itemId"},{component:le,path:"automations/new"},{component:me,path:"automations/:automationId"},{component:ue,path:"automations/:automationId/runs"},{component:de,path:"automations/:automationId/runs/:runId"},{component:fe,path:"skills"},{component:ge,path:"skills/new"},{component:he,path:"skills/:skillId"}]},{name:"desk",icon:jsx(Layout,{strokeWidth:1.5}),title:"Desk",component:J,routes:[{path:"list/:entity",component:X,children:[{path:"edit/:id",component:q}]}]},{name:"asset-manager",icon:jsx(FileStack,{strokeWidth:1.5}),title:"Asset Manager",component:K,routes:[]},{name:"knowledge",icon:jsx(BookOpenText,{strokeWidth:1.5}),title:"Knowledge",component:G,routes:[{component:$,path:""},{component:Q,path:":sourceId"}]},{name:"graph",icon:jsx(Waypoints,{strokeWidth:1.5}),title:"Graph",component:Y,routes:[]},{name:"explorer",icon:jsx(SquarePlay,{strokeWidth:1.5}),title:"Explorer",component:ee,routes:[]}];async function C(e){try{let t=await fetch(d$1(e).schema,{credentials:"include",mode:"cors"});if(!t.ok){let a=t.statusText||`Request failed with status ${String(t.status)}`;try{let i=await t.json();a=i.error??i.message??a;}catch{}return {ok:!1,projectId:e,error:{status:t.status,message:a}}}let n=await t.json();return {ok:!0,project:{...n,projectId:n.projectId||e}}}catch(t){return {ok:false,projectId:e,error:{status:0,message:t instanceof Error?t.message:"Network error"}}}}function b(e,t){let n=[],a={};for(let i of e??[])i.ok?n.push(i.project):a[i.projectId]=i.error;return {projects:n,errors:a,isLoading:t}}function L(e,t){let n=t&&e.length>0?["project-schemas",t,...e]:null,{data:a,isLoading:i}=w(n,()=>Promise.all(e.map(p=>C(p))),{revalidateOnFocus:false,revalidateOnReconnect:false});return b(a,!!n&&(i||a===void 0))}function Pe(e,t){return b(e?[e]:void 0,t)}function A(e,t){let n=t&&e?["project-schema",t,e]:null,{data:a,isLoading:i}=w(n,()=>C(e??""),{revalidateOnFocus:false,revalidateOnReconnect:false});return Pe(a,!!n&&(i||a===void 0))}function Se(e,t){return Array.isArray(e)&&(e[0]==="project-schema"||e[0]==="project-schemas")&&e.slice(2).includes(t)}function Fe(e){return mutate(t=>Se(t,e))}var R=createContext({mode:"projects",apps:l,contributions:{apps:l},currentProjectId:void 0,currentProject:void 0,currentProjectSchema:[],projects:[],projectIds:[],projectSummaries:[],schemaErrors:{},isLoadingSchemas:false});function xe(e){return [...e.filter(n=>n.name!==d.name&&n.name!==f.name),d,f]}function Xe({projectIds:e,projectSummaries:t=[],mode:n="projects",userId:a,children:i}){let{projectId:p}=useParams(),[,I]=g(),h=I.user?.id??a,V=L(n==="projects"?e:[],h),O=A(n==="hosted"&&p&&e.includes(p)?p:void 0,h),{projects:y,errors:P,isLoading:S}=n==="hosted"?O:V,m=useMemo(()=>e.map(s=>y.find(u=>u.projectId===s)).filter(s=>s!==void 0).map(s=>({...s,schema:xe(s.schema)})),[y,e]),H=useMemo(()=>{let s=m.find(u=>u.projectId===p);return {mode:n,apps:l,contributions:{apps:l},currentProjectId:p,currentProject:s,currentProjectSchema:s?.schema??[],projects:m,projectIds:e,projectSummaries:t,schemaErrors:P,isLoadingSchemas:S}},[p,P,S,n,e,t,m]);return jsx(R.Provider,{value:H,children:i})}function qe(){return useContext(R)}
|
|
2
|
+
export{x as a,d as b,f as c,Fe as d,Xe as e,qe as f};//# sourceMappingURL=chunk-H2RWSC56.js.map
|
|
3
|
+
//# sourceMappingURL=chunk-H2RWSC56.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/entities/assets-schema.ts","../src/entities/tags-schema.ts","../src/ui/components/loading.tsx","../src/core/apps/built-in-apps.tsx","../src/core/config/use-project-schemas.ts","../src/core/config/config-context.tsx"],"names":["assetSchema","tagSchema","Loading","resolvedTheme","useTheme","jsx","jsxs","NavigateCompat","Navigate","lazyElement","loader","Component","lazy","Suspense","deskRoot","m","deskList","deskEditEntity","assetManagerRoot","knowledgeRoot","knowledgeList","knowledgeSource","graphRoot","explorerRoot","aiRoot","aiPluginsPage","aiInstalledPluginsPage","aiPluginDetailPage","aiAgentChatPage","aiAutomationsPage","aiRunHistoryPage","aiApprovalsPage","aiActivityPage","aiActivityItemPage","aiCreateAutomationPage","aiAutomationDetailPage","aiRunsPage","aiRunDetailPage","aiSkillsPage","aiCreateSkillPage","aiSkillDetailPage","builtInApps","BotIcon","LayoutIcon","FileStackIcon","BookOpenTextIcon","WaypointsIcon","SquarePlayIcon","fetchProjectSchema","projectId","response","apiPaths","message","body","project","error","toProjectSchemasState","outcomes","isLoading","projects","errors","outcome","useProjectSchemas","projectIds","userId","key","data","useSWR","toProjectSchemaState","useProjectSchema","isProjectSchemaKey","revalidateProjectSchema","mutate","ConfigContext","createContext","upsertReservedEntities","schema","entity","ConfigProvider","projectSummaries","mode","children","currentProjectId","useParams","auth","useAuth","schemaUserId","allSchemas","currentSchema","loadedProjects","useMemo","value","currentProject","useConfig","useContext"],"mappings":"uXAEO,IAAMA,CAAAA,CAAsB,CACjC,IAAA,CAAM,QAAA,CACN,OAAQ,SAAA,CACR,OAAA,CAAS,kBAAA,CACT,IAAA,CAAM,CACJ,MAAA,CAAQ,IACV,CAAA,CACA,UAAA,CAAY,CACV,CACE,IAAA,CAAM,OACN,KAAA,CAAO,OAAA,CACP,KAAA,CAAO,QAAA,CACP,OAAA,CAAS,CACP,KAAM,GACR,CAAA,CACA,SAAU,QAAA,CACV,SAAA,CAAW,OACX,WAAA,CAAa,mBAAA,CACb,YAAA,CAAc,EAChB,CAAA,CACA,CACE,KAAM,kBAAA,CACN,KAAA,CAAO,WACP,KAAA,CAAO,QAAA,CACP,QAAS,CACP,IAAA,CAAM,GACR,CAAA,CACA,QAAA,CAAU,QAAA,CACV,UAAW,MAAA,CACX,WAAA,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CAAAU,EACA,oBAAA,CAAsBA,CAAAA,EAAgB,MAAA,EAAU,EAAC,CACjD,QAAA,CAAAjC,EACA,UAAA,CAAAI,CAAAA,CACA,iBAAAgB,CAAAA,CACA,YAAA,CAAcnB,EACd,gBAAA,CAAkBF,CACpB,CACF,CAAA,CAAG,CAACwB,CAAAA,CAAkBtB,EAAQF,CAAAA,CAAWsB,CAAAA,CAAMjB,EAAYgB,CAAAA,CAAkBpB,CAAQ,CAAC,CAAA,CAEtF,OAAOtD,GAAAA,CAACoE,CAAAA,CAAc,QAAA,CAAd,CAAuB,MAAOkB,CAAAA,CAAQ,QAAA,CAAAV,CAAAA,CAAS,CACzD,CAEO,SAASY,IAA2B,CACzC,OAAOC,UAAAA,CAAWrB,CAAa,CACjC","file":"chunk-H2RWSC56.js","sourcesContent":["import type { Entity } from '../core/types';\n\nexport const assetSchema: Entity = {\n name: '_asset',\n plural: '_assets',\n display: 'originalFilename',\n menu: {\n hidden: true,\n },\n attributes: [\n {\n name: 'path',\n label: 'Asset',\n scope: 'global',\n options: {\n size: 140,\n },\n dataType: 'string',\n inputType: 'text',\n previewType: 'assetPreviewField',\n defaultValue: '',\n },\n {\n name: 'originalFilename',\n label: 'Filename',\n scope: 'global',\n options: {\n size: 320,\n },\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'size',\n label: 'Size',\n scope: 'global',\n options: {\n size: 120,\n },\n dataType: 'int',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'width',\n label: 'Width',\n scope: 'global',\n options: {\n size: 90,\n },\n dataType: 'int',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'height',\n label: 'Height',\n scope: 'global',\n options: {\n size: 100,\n },\n dataType: 'int',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'mimeType',\n label: 'Mime Type',\n scope: 'global',\n options: {\n size: 160,\n },\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'lqip',\n label: 'lqip',\n scope: 'global',\n hidden: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: 'url',\n label: 'URL',\n scope: 'global',\n hidden: true,\n readOnly: true,\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: '_updatedAt',\n label: 'Updated At',\n scope: 'global',\n options: {\n size: 220,\n },\n readOnly: true,\n hidden: true,\n dataType: 'datetime',\n inputType: 'datetime',\n previewType: 'datetime',\n defaultValue: '',\n },\n {\n name: 'tags',\n label: 'Tags',\n scope: 'relationship',\n dataType: 'string',\n inputType: 'relationship',\n defaultValue: '',\n previewType: 'tags',\n options: {\n size: 300,\n },\n relationship: {\n mode: 'multiple',\n field: 'name',\n entity: '_tag',\n },\n },\n ],\n};\n","import type { Entity } from '../core/types';\n\nexport const tagSchema: Entity = {\n name: '_tag',\n plural: '_tags',\n display: 'name',\n menu: {\n hidden: true,\n },\n attributes: [\n {\n name: 'name',\n label: 'Tag Name',\n scope: 'global',\n options: {\n size: 220,\n },\n dataType: 'string',\n inputType: 'text',\n previewType: 'text',\n defaultValue: '',\n },\n {\n name: '_updatedAt',\n label: 'Updated At',\n scope: 'global',\n options: {\n size: 220,\n },\n readOnly: true,\n hidden: true,\n dataType: 'datetime',\n inputType: 'datetime',\n previewType: 'datetime',\n defaultValue: '',\n },\n {\n name: 'assets',\n label: 'Assets',\n scope: 'relationship',\n dataType: 'string',\n inputType: 'relationship',\n defaultValue: '',\n relationship: {\n mode: 'multiple',\n field: 'originalFilename',\n entity: '_asset',\n },\n },\n ],\n};\n","import type { JSX } from 'react';\nimport { useTheme } from '../theme-context';\n\nexport function Loading(): JSX.Element {\n const { resolvedTheme } = useTheme();\n\n return (\n <div className=\"fk:flex fk:w-full fk:h-full fk:justify-center fk:items-center fk:bg-background\">\n <div className=\"fk:flex fk:flex-col fk:items-center\">\n {resolvedTheme === 'dark' ? (\n <svg\n className=\"fk:h-8 fk:w-8 fk:animate-bounce\"\n fill=\"none\"\n viewBox=\"0 0 48 48\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path d=\"M7 8H41V40H7V8Z\" fill=\"#020817\" />\n <path\n d=\"M24 0C42 0 48 6 48 24C48 42 42 48 24 48C6 48 0 42 0 24C0 6 6 0 24 0ZM17.7494 9.52381H8.7619L19.2833 23.8313L8.7619 38.7078H17.7494L21.0499 33.6639V14.2549L17.7494 9.52381ZM38.9577 9.52381H29.9542L26.2857 14.8229V33.0406L29.9542 38.7078H38.9577L28.3908 23.8313L38.9577 9.52381Z\"\n fill=\"white\"\n />\n </svg>\n ) : (\n <svg\n className=\"fk:h-8 fk:w-8 fk:animate-bounce\"\n fill=\"none\"\n viewBox=\"0 0 48 48\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path d=\"M7 8H41V40H7V8Z\" fill=\"white\" />\n <path\n d=\"M24 0C42 0 48 6 48 24C48 42 42 48 24 48C6 48 0 42 0 24C0 6 6 0 24 0ZM17.7494 9.52381H8.7619L19.2833 23.8313L8.7619 38.7078H17.7494L21.0499 33.6639V14.2549L17.7494 9.52381ZM38.9577 9.52381H29.9542L26.2857 14.8229V33.0406L29.9542 38.7078H38.9577L28.3908 23.8313L38.9577 9.52381Z\"\n fill=\"#020817\"\n />\n </svg>\n )}\n <div className=\"fk:text-foreground fk:text-center fk:mt-4 fk:animate-pulse\">Loading...</div>\n </div>\n </div>\n );\n}\n","import { lazy, Suspense } from 'react';\nimport type { ComponentType, JSX } from 'react';\nimport {\n BookOpenText as BookOpenTextIcon,\n Bot as BotIcon,\n FileStack as FileStackIcon,\n Layout as LayoutIcon,\n SquarePlay as SquarePlayIcon,\n Waypoints as WaypointsIcon,\n} from 'lucide-react';\nimport { Navigate } from 'react-router-dom';\nimport { Loading } from '../../ui/components/loading';\nimport type { AppOptions } from '../config/types';\n\nconst NavigateCompat = Navigate as unknown as ComponentType<{\n replace?: boolean;\n to: string;\n}>;\n\n/**\n * Wraps a lazily imported component in Suspense so each built-in app (and each of its routes)\n * is only downloaded when it is first rendered.\n */\nfunction lazyElement(loader: () => Promise<{ default: ComponentType }>): JSX.Element {\n const Component = lazy(loader);\n\n return (\n <Suspense fallback={<Loading />}>\n <Component />\n </Suspense>\n );\n}\n\n// Desk\nconst deskRoot = lazyElement(() => import('../../apps/desk/root').then((m) => ({ default: m.Root })));\nconst deskList = lazyElement(() => import('../../apps/desk/list').then((m) => ({ default: m.List })));\nconst deskEditEntity = lazyElement(() =>\n import('../../apps/desk/edit-entity').then((m) => ({ default: m.EditEntity }))\n);\n\n// Asset Manager\nconst assetManagerRoot = lazyElement(() => import('../../apps/asset-manager/root').then((m) => ({ default: m.Root })));\n\n// Knowledge\nconst knowledgeRoot = lazyElement(() => import('../../apps/knowledge/root').then((m) => ({ default: m.Root })));\nconst knowledgeList = lazyElement(() => import('../../apps/knowledge/list').then((m) => ({ default: m.List })));\nconst knowledgeSource = lazyElement(() => import('../../apps/knowledge/source').then((m) => ({ default: m.Source })));\n\n// Graph\nconst graphRoot = lazyElement(() => import('../../apps/graph/root').then((m) => ({ default: m.Root })));\n\n// Explorer\nconst explorerRoot = lazyElement(() => import('../../apps/explorer/root').then((m) => ({ default: m.Root })));\n\n// AI\nconst aiRoot = lazyElement(() => import('../../apps/ai/root').then((m) => ({ default: m.Root })));\nconst aiPluginsPage = lazyElement(() => import('../../apps/ai/plugin-pages').then((m) => ({ default: m.PluginsPage })));\nconst aiInstalledPluginsPage = lazyElement(() =>\n import('../../apps/ai/plugin-pages').then((m) => ({ default: m.InstalledPluginsPage }))\n);\nconst aiPluginDetailPage = lazyElement(() =>\n import('../../apps/ai/plugin-pages').then((m) => ({ default: m.PluginDetailPage }))\n);\nconst aiAgentChatPage = lazyElement(() =>\n import('../../apps/ai/agent/chat-page').then((m) => ({ default: m.AgentChatPage }))\n);\nconst aiAutomationsPage = lazyElement(() =>\n import('../../apps/ai/pages').then((m) => ({ default: m.AutomationsPage }))\n);\nconst aiRunHistoryPage = lazyElement(() => import('../../apps/ai/pages').then((m) => ({ default: m.RunHistoryPage })));\nconst aiApprovalsPage = lazyElement(() => import('../../apps/ai/pages').then((m) => ({ default: m.ApprovalsPage })));\nconst aiActivityPage = lazyElement(() => import('../../apps/ai/pages').then((m) => ({ default: m.ActivityPage })));\nconst aiActivityItemPage = lazyElement(() =>\n import('../../apps/ai/pages').then((m) => ({ default: m.ActivityItemPage }))\n);\nconst aiCreateAutomationPage = lazyElement(() =>\n import('../../apps/ai/pages').then((m) => ({ default: m.CreateAutomationPage }))\n);\nconst aiAutomationDetailPage = lazyElement(() =>\n import('../../apps/ai/pages').then((m) => ({ default: m.AutomationDetailPage }))\n);\nconst aiRunsPage = lazyElement(() => import('../../apps/ai/pages').then((m) => ({ default: m.RunsPage })));\nconst aiRunDetailPage = lazyElement(() => import('../../apps/ai/pages').then((m) => ({ default: m.RunDetailPage })));\nconst aiSkillsPage = lazyElement(() => import('../../apps/ai/skills-pages').then((m) => ({ default: m.SkillsPage })));\nconst aiCreateSkillPage = lazyElement(() =>\n import('../../apps/ai/skills-pages').then((m) => ({ default: m.CreateSkillPage }))\n);\nconst aiSkillDetailPage = lazyElement(() =>\n import('../../apps/ai/skills-pages').then((m) => ({ default: m.SkillDetailPage }))\n);\n\nexport const builtInApps: AppOptions[] = [\n {\n name: 'ai',\n icon: <BotIcon strokeWidth={1.5} />,\n title: 'AI',\n component: aiRoot,\n routes: [\n { path: 'plugins', component: aiPluginsPage },\n { path: 'plugins/installed', component: aiInstalledPluginsPage },\n { path: 'plugins/:pluginId', component: aiPluginDetailPage },\n {\n component: <NavigateCompat replace to=\"agent\" />,\n path: '',\n },\n {\n component: aiAgentChatPage,\n path: 'agent',\n },\n {\n component: aiAgentChatPage,\n path: 'agent/chats/:chatId',\n },\n {\n component: aiAutomationsPage,\n path: 'automations',\n },\n {\n component: aiRunHistoryPage,\n path: 'runs',\n },\n {\n component: aiApprovalsPage,\n path: 'approvals',\n },\n {\n component: aiActivityPage,\n path: 'activity',\n },\n {\n component: aiActivityItemPage,\n path: 'activity/:itemId',\n },\n {\n component: aiCreateAutomationPage,\n path: 'automations/new',\n },\n {\n component: aiAutomationDetailPage,\n path: 'automations/:automationId',\n },\n {\n component: aiRunsPage,\n path: 'automations/:automationId/runs',\n },\n {\n component: aiRunDetailPage,\n path: 'automations/:automationId/runs/:runId',\n },\n {\n component: aiSkillsPage,\n path: 'skills',\n },\n {\n component: aiCreateSkillPage,\n path: 'skills/new',\n },\n {\n component: aiSkillDetailPage,\n path: 'skills/:skillId',\n },\n ],\n },\n {\n name: 'desk',\n icon: <LayoutIcon strokeWidth={1.5} />,\n title: 'Desk',\n component: deskRoot,\n routes: [\n {\n path: 'list/:entity',\n component: deskList,\n children: [\n {\n path: 'edit/:id',\n component: deskEditEntity, // Not used, left here as an example of how to nest routes in apps\n },\n ],\n },\n ],\n },\n {\n name: 'asset-manager',\n icon: <FileStackIcon strokeWidth={1.5} />,\n title: 'Asset Manager',\n component: assetManagerRoot,\n routes: [],\n },\n {\n name: 'knowledge',\n icon: <BookOpenTextIcon strokeWidth={1.5} />,\n title: 'Knowledge',\n component: knowledgeRoot,\n routes: [\n {\n component: knowledgeList,\n path: '',\n },\n {\n component: knowledgeSource,\n path: ':sourceId',\n },\n ],\n },\n {\n name: 'graph',\n icon: <WaypointsIcon strokeWidth={1.5} />,\n title: 'Graph',\n component: graphRoot,\n routes: [],\n },\n {\n name: 'explorer',\n icon: <SquarePlayIcon strokeWidth={1.5} />,\n title: 'Explorer',\n component: explorerRoot,\n routes: [],\n },\n];\n","'use client';\n\nimport useSWR, { mutate } from 'swr';\nimport { apiPaths } from '../api-paths';\nimport type { ProjectSchemaError, ProjectUiConfig } from './types';\n\nexport type ProjectSchemasState = {\n projects: ProjectUiConfig[];\n errors: { [projectId: string]: ProjectSchemaError };\n isLoading: boolean;\n};\n\ntype FetchOutcome = { ok: true; project: ProjectUiConfig } | { ok: false; projectId: string; error: ProjectSchemaError };\n\nasync function fetchProjectSchema(projectId: string): Promise<FetchOutcome> {\n try {\n const response = await fetch(apiPaths(projectId).schema, { credentials: 'include', mode: 'cors' });\n\n if (!response.ok) {\n let message = response.statusText || `Request failed with status ${String(response.status)}`;\n\n try {\n const body = (await response.json()) as { error?: string; message?: string };\n message = body.error ?? body.message ?? message;\n } catch {\n // keep the status text\n }\n\n return { ok: false, projectId, error: { status: response.status, message } };\n }\n\n const project = (await response.json()) as ProjectUiConfig;\n\n return { ok: true, project: { ...project, projectId: project.projectId || projectId } };\n } catch (error) {\n return {\n ok: false,\n projectId,\n error: { status: 0, message: error instanceof Error ? error.message : 'Network error' },\n };\n }\n}\n\nexport function toProjectSchemasState(outcomes: FetchOutcome[] | undefined, isLoading: boolean): ProjectSchemasState {\n const projects: ProjectUiConfig[] = [];\n const errors: { [projectId: string]: ProjectSchemaError } = {};\n\n for (const outcome of outcomes ?? []) {\n if (outcome.ok) {\n projects.push(outcome.project);\n } else {\n errors[outcome.projectId] = outcome.error;\n }\n }\n\n return { projects, errors, isLoading };\n}\n\n/**\n * Loads the deployed schema of every project the Studio can open. Fetching\n * starts once the user is known (the endpoint needs a session) and the result\n * is kept for the lifetime of the page: schemas only change on deploy.\n */\nexport function useProjectSchemas(projectIds: string[], userId: string | undefined): ProjectSchemasState {\n const key = userId && projectIds.length > 0 ? ['project-schemas', userId, ...projectIds] : null;\n const { data, isLoading } = useSWR(key, () => Promise.all(projectIds.map((projectId) => fetchProjectSchema(projectId))), {\n revalidateOnFocus: false,\n revalidateOnReconnect: false,\n });\n\n return toProjectSchemasState(data, Boolean(key) && (isLoading || data === undefined));\n}\n\n/** State of a single project's schema, in the same shape as the multi-project hook. */\nexport function toProjectSchemaState(outcome: FetchOutcome | undefined, isLoading: boolean): ProjectSchemasState {\n return toProjectSchemasState(outcome ? [outcome] : undefined, isLoading);\n}\n\n/**\n * Hosted mode: loads only the project currently open. Each project has its own\n * SWR key, so switching back to a project reuses the schema already fetched.\n */\nexport function useProjectSchema(projectId: string | undefined, userId: string | undefined): ProjectSchemasState {\n const key = userId && projectId ? ['project-schema', userId, projectId] : null;\n const { data, isLoading } = useSWR(key, () => fetchProjectSchema(projectId ?? ''), {\n revalidateOnFocus: false,\n revalidateOnReconnect: false,\n });\n\n return toProjectSchemaState(data, Boolean(key) && (isLoading || data === undefined));\n}\n\n/** True for the SWR keys that hold `projectId`'s schema (single- and multi-project hooks). */\nexport function isProjectSchemaKey(key: unknown, projectId: string): boolean {\n return (\n Array.isArray(key) &&\n (key[0] === 'project-schema' || key[0] === 'project-schemas') &&\n key.slice(2).includes(projectId)\n );\n}\n\n/** Refetches the deployed schema of `projectId`, e.g. after the agent deployed a schema change. */\nexport function revalidateProjectSchema(projectId: string): Promise<unknown> {\n return mutate((key) => isProjectSchemaKey(key, projectId));\n}\n","'use client';\n\nimport { createContext, useContext, useMemo } from 'react';\nimport type { JSX } from 'react';\nimport { useParams } from 'react-router-dom';\nimport { useAuth } from '../../auth/auth-context';\nimport { assetSchema } from '../../entities/assets-schema';\nimport { tagSchema } from '../../entities/tags-schema';\nimport { builtInApps } from '../apps/built-in-apps';\nimport type { AppOptions, ProjectSchemaError, ProjectSummary, ProjectUiConfig, StudioMode } from './types';\nimport type { Entity } from '../types';\nimport { useProjectSchema, useProjectSchemas } from './use-project-schemas';\n\nexport interface ConfigContext {\n /** `projects` when the host passed `projectIds`, `hosted` when the Studio listed the user's projects itself. */\n mode: StudioMode;\n /** The Studio apps shown in the app bar, in order. */\n apps: AppOptions[];\n /** Kept for callers that read `contributions.apps`; same list as `apps`. */\n contributions: {\n apps: AppOptions[];\n };\n currentProjectId?: string;\n /** The project named by the `:projectId` route param, once its schema has loaded. */\n currentProject?: ProjectUiConfig;\n currentProjectSchema: Entity[];\n /** Projects whose schema loaded, in `projectIds` order. */\n projects: ProjectUiConfig[];\n /** Every project id the Studio can open, loaded or not. */\n projectIds: string[];\n /** Hosted mode: name, avatar, role and team of each project, known before any schema loads. */\n projectSummaries: ProjectSummary[];\n /** Per project id: why its schema could not be loaded. */\n schemaErrors: { [projectId: string]: ProjectSchemaError };\n isLoadingSchemas: boolean;\n}\n\nconst ConfigContext = createContext<ConfigContext>({\n mode: 'projects',\n apps: builtInApps,\n contributions: { apps: builtInApps },\n currentProjectId: undefined,\n currentProject: undefined,\n currentProjectSchema: [],\n projects: [],\n projectIds: [],\n projectSummaries: [],\n schemaErrors: {},\n isLoadingSchemas: false,\n});\n\n/** Appends the reserved asset and tag entities to a deployed schema. */\nexport function upsertReservedEntities(schema: Entity[]): Entity[] {\n const withoutReserved = schema.filter((entity) => entity.name !== assetSchema.name && entity.name !== tagSchema.name);\n\n return [...withoutReserved, assetSchema, tagSchema];\n}\n\nexport function ConfigProvider({\n projectIds,\n projectSummaries = [],\n mode = 'projects',\n userId,\n children,\n}: {\n projectIds: string[];\n projectSummaries?: ProjectSummary[];\n mode?: StudioMode;\n /** Hosted mode: the signed-in user's id, known before the per-project `/users/me` call. */\n userId?: string;\n children: React.ReactNode;\n}): JSX.Element {\n /**\n * Getting the projectId from the URL via react-router-dom's useParams hook triggers a rerender of this Context\n * every time the URL changes.\n */\n const { projectId: currentProjectId } = useParams<{ projectId: string }>();\n const [, auth] = useAuth();\n const schemaUserId = auth.user?.id ?? userId;\n // Project mode loads every project up front (short, host-defined list); hosted mode only the one open.\n const allSchemas = useProjectSchemas(mode === 'projects' ? projectIds : [], schemaUserId);\n const currentSchema = useProjectSchema(\n mode === 'hosted' && currentProjectId && projectIds.includes(currentProjectId) ? currentProjectId : undefined,\n schemaUserId\n );\n const { projects: loadedProjects, errors, isLoading } = mode === 'hosted' ? currentSchema : allSchemas;\n const projects = useMemo(\n () =>\n projectIds\n .map((projectId) => loadedProjects.find((project) => project.projectId === projectId))\n .filter((project): project is ProjectUiConfig => project !== undefined)\n .map((project) => ({ ...project, schema: upsertReservedEntities(project.schema) })),\n [loadedProjects, projectIds]\n );\n\n const value = useMemo<ConfigContext>(() => {\n const currentProject = projects.find((project) => project.projectId === currentProjectId);\n\n return {\n mode,\n apps: builtInApps,\n contributions: { apps: builtInApps },\n currentProjectId,\n currentProject,\n currentProjectSchema: currentProject?.schema ?? [],\n projects,\n projectIds,\n projectSummaries,\n schemaErrors: errors,\n isLoadingSchemas: isLoading,\n };\n }, [currentProjectId, errors, isLoading, mode, projectIds, projectSummaries, projects]);\n\n return <ConfigContext.Provider value={value}>{children}</ConfigContext.Provider>;\n}\n\nexport function useConfig(): ConfigContext {\n return useContext(ConfigContext);\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import'./index.css';import {a,b as b$3}from'./chunk-ALCK2BJY.js';import {f,d as d$1}from'./chunk-NLRSLQUT.js';import {f as f$1}from'./chunk-7ZFUS62K.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-FDN23BPI.js.map
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import'./index.css';import {a,b as b$3}from'./chunk-UOR437J2.js';import {f,d as d$1}from'./chunk-DHVKE36X.js';import {f as f$1}from'./chunk-H2RWSC56.js';import {O,ha,ia,ja,Tc,Vc,qa,s,p,q as q$1,r}from'./chunk-DGIY4SKN.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 {w,b as b$2}from'./chunk-32ZU4MLE.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(O,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(ha,{value:s?"skills":"plugins",onValueChange:f=>{let m=f==="skills"?"skills":"plugins";(f==="skills"?s:t)||n(S(a,m));},children:jsxs(ia,{children:[jsx(ja,{value:"plugins",onClick:()=>{t||n(S(a,"plugins"));},children:"Plugins"}),jsx(ja,{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(Tc,{variant:"destructive",children:jsx(Vc,{children:"Unable to load plugins. Please try again."})}):null,i?jsx(Be,{grouped:!n}):null,!i&&!s$1&&l.length===0?jsx(Tc,{children:jsx(Vc,{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){qa.error('You signed in with a different account. Use "Connect another account" to add it.');return}qa.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(Tc,{variant:"destructive",children:jsx(Vc,{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(O,{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(O,{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(Tc,{children:jsx(Vc,{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-HCJAM5LG.js.map
|
|
2
|
+
//# sourceMappingURL=chunk-HCJAM5LG.js.map
|