@flexkit/studio 0.2.22 → 0.2.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/dist/{activity-nav-button-7RLCHOFV.js → activity-nav-button-4VTYGP4T.js} +2 -2
  2. package/dist/{activity-nav-button-7RLCHOFV.js.map → activity-nav-button-4VTYGP4T.js.map} +1 -1
  3. package/dist/astro.js +1 -1
  4. package/dist/chat-page-A7FG7WTN.js +4 -0
  5. package/dist/chat-page-A7FG7WTN.js.map +1 -0
  6. package/dist/{chunk-MHVZXDVL.js → chunk-3COXA5QH.js} +2 -2
  7. package/dist/{chunk-MHVZXDVL.js.map → chunk-3COXA5QH.js.map} +1 -1
  8. package/dist/{chunk-SE4HJCGA.js → chunk-3IUKXOKF.js} +2 -2
  9. package/dist/{chunk-SE4HJCGA.js.map → chunk-3IUKXOKF.js.map} +1 -1
  10. package/dist/{chunk-7ERLYAPR.js → chunk-5OGT6WGZ.js} +2 -2
  11. package/dist/{chunk-7ERLYAPR.js.map → chunk-5OGT6WGZ.js.map} +1 -1
  12. package/dist/{chunk-BM7INZL3.js → chunk-AKW7EKYI.js} +3 -3
  13. package/dist/{chunk-BM7INZL3.js.map → chunk-AKW7EKYI.js.map} +1 -1
  14. package/dist/{chunk-GGC75EMC.js → chunk-C4XLDODU.js} +2 -0
  15. package/dist/{chunk-K2KW6UYG.js → chunk-HTSMODQB.js} +2 -2
  16. package/dist/{chunk-K2KW6UYG.js.map → chunk-HTSMODQB.js.map} +1 -1
  17. package/dist/chunk-I6Z3WLAX.js +2 -0
  18. package/dist/chunk-I6Z3WLAX.js.map +1 -0
  19. package/dist/{chunk-HBTMGDOM.js → chunk-IQ2F2FFF.js} +2 -2
  20. package/dist/{chunk-HBTMGDOM.js.map → chunk-IQ2F2FFF.js.map} +1 -1
  21. package/dist/{chunk-RPLKJVDQ.js → chunk-JSJZKPXU.js} +3 -3
  22. package/dist/{chunk-RPLKJVDQ.js.map → chunk-JSJZKPXU.js.map} +1 -1
  23. package/dist/{chunk-4LVMCUHR.js → chunk-KN7OJFEX.js} +2 -2
  24. package/dist/{chunk-4LVMCUHR.js.map → chunk-KN7OJFEX.js.map} +1 -1
  25. package/dist/chunk-L3GBAK54.js +4 -0
  26. package/dist/chunk-L3GBAK54.js.map +1 -0
  27. package/dist/chunk-MNLYE7DK.js +3 -0
  28. package/dist/chunk-MNLYE7DK.js.map +1 -0
  29. package/dist/{chunk-YXUEPR7K.js → chunk-NO3AH2M3.js} +3 -3
  30. package/dist/{chunk-YXUEPR7K.js.map → chunk-NO3AH2M3.js.map} +1 -1
  31. package/dist/{chunk-6AI7322C.js → chunk-NSVX6HEN.js} +3 -3
  32. package/dist/{chunk-6AI7322C.js.map → chunk-NSVX6HEN.js.map} +1 -1
  33. package/dist/chunk-SZOEW2TL.js +8 -0
  34. package/dist/chunk-SZOEW2TL.js.map +1 -0
  35. package/dist/chunk-U6E7GNQW.js +2 -0
  36. package/dist/chunk-U6E7GNQW.js.map +1 -0
  37. package/dist/{chunk-UJEDL3IZ.js → chunk-UBFBXBPG.js} +2 -2
  38. package/dist/{chunk-UJEDL3IZ.js.map → chunk-UBFBXBPG.js.map} +1 -1
  39. package/dist/{chunk-LIMXKPEK.js → chunk-V7C4EHK3.js} +2 -2
  40. package/dist/{chunk-LIMXKPEK.js.map → chunk-V7C4EHK3.js.map} +1 -1
  41. package/dist/chunk-WPCPL2TQ.js +3 -0
  42. package/dist/chunk-WPCPL2TQ.js.map +1 -0
  43. package/dist/{chunk-UCHWUGRT.js → chunk-XV2B3W6Z.js} +3 -3
  44. package/dist/{chunk-UCHWUGRT.js.map → chunk-XV2B3W6Z.js.map} +1 -1
  45. package/dist/electron.js +1 -1
  46. package/dist/{entry-GWZ7DELK.js → entry-RMRLV3NM.js} +2 -2
  47. package/dist/{entry-GWZ7DELK.js.map → entry-RMRLV3NM.js.map} +1 -1
  48. package/dist/index.js +8 -10
  49. package/dist/index.js.map +1 -1
  50. package/dist/{list-LMIKCT2W.js → list-GVATECOW.js} +2 -2
  51. package/dist/{list-LMIKCT2W.js.map → list-GVATECOW.js.map} +1 -1
  52. package/dist/{list-FQZII7QD.js → list-HR55TZQX.js} +3 -3
  53. package/dist/{list-FQZII7QD.js.map → list-HR55TZQX.js.map} +1 -1
  54. package/dist/nextjs.js +1 -1
  55. package/dist/pages-OJYYLSI3.js +5 -0
  56. package/dist/pages-OJYYLSI3.js.map +1 -0
  57. package/dist/plugin-pages-BS2IMNRU.js +2 -0
  58. package/dist/{plugin-pages-4HTADSK3.js.map → plugin-pages-BS2IMNRU.js.map} +1 -1
  59. package/dist/record-links-2QWJFFZF.js +2 -0
  60. package/dist/{record-links-FDWV4X5W.js.map → record-links-2QWJFFZF.js.map} +1 -1
  61. package/dist/{root-ZYUSZZWR.js → root-54BI6S4V.js} +3 -3
  62. package/dist/{root-ZYUSZZWR.js.map → root-54BI6S4V.js.map} +1 -1
  63. package/dist/root-E35GZ7SV.js +14 -0
  64. package/dist/root-E35GZ7SV.js.map +1 -0
  65. package/dist/{root-X3V4NC2D.js → root-GAB2SFFF.js} +2 -2
  66. package/dist/{root-X3V4NC2D.js.map → root-GAB2SFFF.js.map} +1 -1
  67. package/dist/{root-VL4EM2IS.js → root-JWXXF653.js} +3 -3
  68. package/dist/{root-VL4EM2IS.js.map → root-JWXXF653.js.map} +1 -1
  69. package/dist/{root-OSXC52GL.js → root-U52KZQSD.js} +2 -2
  70. package/dist/{root-OSXC52GL.js.map → root-U52KZQSD.js.map} +1 -1
  71. package/dist/{root-GYJGAS22.js → root-ZCXGZCUT.js} +2 -2
  72. package/dist/{root-GYJGAS22.js.map → root-ZCXGZCUT.js.map} +1 -1
  73. package/dist/{search-UW7WE2CS.js → search-IOYOKT6M.js} +2 -2
  74. package/dist/{search-UW7WE2CS.js.map → search-IOYOKT6M.js.map} +1 -1
  75. package/dist/{skills-pages-Q4YSUQVZ.js → skills-pages-MA6JLBB4.js} +2 -2
  76. package/dist/{skills-pages-Q4YSUQVZ.js.map → skills-pages-MA6JLBB4.js.map} +1 -1
  77. package/dist/{source-PGSWL4DQ.js → source-3YZNNITL.js} +2 -2
  78. package/dist/{source-PGSWL4DQ.js.map → source-3YZNNITL.js.map} +1 -1
  79. package/dist/tanstack-start.js +1 -1
  80. package/dist/{user-nav-B37OEVQN.js → user-nav-OWTTAXZS.js} +2 -2
  81. package/dist/{user-nav-B37OEVQN.js.map → user-nav-OWTTAXZS.js.map} +1 -1
  82. package/package.json +4 -4
  83. package/dist/chat-page-WLKJ3QNZ.js +0 -4
  84. package/dist/chat-page-WLKJ3QNZ.js.map +0 -1
  85. package/dist/chunk-HGXYSP47.js +0 -8
  86. package/dist/chunk-HGXYSP47.js.map +0 -1
  87. package/dist/chunk-JIB4PRLH.js +0 -3
  88. package/dist/chunk-JIB4PRLH.js.map +0 -1
  89. package/dist/chunk-QCVQJN5O.js +0 -2
  90. package/dist/chunk-QCVQJN5O.js.map +0 -1
  91. package/dist/chunk-QTFFVG7C.js +0 -2
  92. package/dist/chunk-QTFFVG7C.js.map +0 -1
  93. package/dist/chunk-SY67F62K.js +0 -3
  94. package/dist/chunk-SY67F62K.js.map +0 -1
  95. package/dist/pages-NKE7FV34.js +0 -5
  96. package/dist/pages-NKE7FV34.js.map +0 -1
  97. package/dist/plugin-pages-4HTADSK3.js +0 -2
  98. package/dist/record-links-FDWV4X5W.js +0 -2
  99. package/dist/root-YDHREGTF.js +0 -14
  100. package/dist/root-YDHREGTF.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import'./index.css';import {a,c,d,f as f$1,g as g$1,e as e$1,i,h as h$2}from'./chunk-2NXQF2F7.js';import {b as b$1}from'./chunk-LIMXKPEK.js';import {h}from'./chunk-7KLXWCDS.js';import {f}from'./chunk-6AI7322C.js';import {qa}from'./chunk-DGIY4SKN.js';import {e,g,h as h$1,j as j$1,o,n}from'./chunk-SZEGGBOC.js';import {b}from'./chunk-32ZU4MLE.js';import {b as b$2}from'./chunk-6NRQMG26.js';import {put}from'@vercel/blob/client';import {useMemo,useRef,useEffect,useState}from'react';import {LoaderCircle,EllipsisVerticalIcon,DownloadIcon,ExternalLinkIcon,Trash2Icon}from'lucide-react';import {mutate}from'swr';import {Document}from'@untitledui/file-icons/dist/solid/document.mjs';import {Docx}from'@untitledui/file-icons/dist/solid/docx.mjs';import {Html}from'@untitledui/file-icons/dist/solid/html.mjs';import {Pdf}from'@untitledui/file-icons/dist/solid/pdf.mjs';import {Pptx}from'@untitledui/file-icons/dist/solid/pptx.mjs';import {Txt}from'@untitledui/file-icons/dist/solid/txt.mjs';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var u=class extends Error{code;status;constructor(n,t,r=null){super(t),this.name="KnowledgeApiError",this.code=r,this.status=n;}},k=class extends Error{status;constructor(n,t="Request failed"){super(t),this.name="FetcherError",this.status=n;}},fe=async e=>{let n=await fetch(e,{credentials:"include"});if(!n.ok)throw new k(n.status);return await n.json()};function j(e){let n=`/api/flexkit/${e}/knowledge`;return {entitySources:t=>`${n}/entities/${encodeURIComponent(t)}/sources`,file:t=>`${n}/sources/${encodeURIComponent(t)}/file`,job:t=>`${n}/jobs/${encodeURIComponent(t)}`,links:t=>`${n}/sources/${encodeURIComponent(t)}/links`,passages:(t,{from:r,to:o})=>`${n}/sources/${encodeURIComponent(t)}/passages?from=${String(r)}&to=${String(o)}`,recordSources:({entity:t,recordId:r})=>`${n}/records/${encodeURIComponent(t)}/${encodeURIComponent(r)}/sources`,source:t=>`${n}/sources/${encodeURIComponent(t)}`,sources:(t={})=>{let{limit:r=25,offset:o=0,search:i,status:a}=t,l=new URLSearchParams({limit:r.toString(),offset:o.toString()}),c=i?.trim();return c&&l.set("q",c),a&&l.set("status",a),`${n}/sources?${l.toString()}`},spaces:`/api/flexkit/${e}/spaces`}}function N(e){return typeof e=="string"&&e.includes("/knowledge/sources?")}function J(e){return typeof e=="string"&&(e.includes("/knowledge/records/")||e.includes("/knowledge/entities/")||e.includes("/knowledge/sources/")&&e.endsWith("/links"))}async function L(e,n){let t={};try{t=await e.json();}catch{}return new u(e.status,t.error?String(t.error):n,t.code??null)}function O(e){let n=`/api/flexkit/${e}/knowledge`;async function t(o,i){let{fallback:a,...l}=i,c=await fetch(o,{credentials:"include",headers:{"Content-Type":"application/json",...l.headers??{}},...l});if(!c.ok)throw await L(c,a);return await c.json()}function r(o){return t(`${n}/sources`,{body:JSON.stringify(o),fallback:"The document could not be added.",method:"POST"})}return {addFile:async(o,i)=>{let a=await fetch(`${n}/uploads`,{body:JSON.stringify({filename:o.name,mediaType:o.type||null,sizeBytes:o.size}),credentials:"include",headers:{"Content-Type":"application/json"},method:"POST",signal:i?.signal});if(!a.ok)throw await L(a,"The file could not be uploaded.");let l=await a.json();if(!l.pathname||!l.token||!l.mediaType)throw new u(a.status,"The file could not be uploaded.");return await put(l.pathname,o,{abortSignal:i?.signal,access:"public",contentType:l.mediaType,token:l.token}),r({kind:"upload",pathname:l.pathname})},addUrl:({title:o,url:i})=>r({kind:"url",url:i,...o?{title:o}:{}}),addChatAttachment:({filename:o,url:i})=>r({filename:o,kind:"chat-attachment",url:i}),deleteSource:o=>t(`${n}/sources/${encodeURIComponent(o)}`,{fallback:"The document could not be removed.",method:"DELETE"}),linkSource:(o,i)=>t(`${n}/sources/${encodeURIComponent(o)}/links`,{body:JSON.stringify(i),fallback:"The document could not be attached.",method:"POST"}),reingestSource:o=>t(`${n}/sources/${encodeURIComponent(o)}/reingest`,{fallback:"The document could not be re-indexed.",method:"POST"}),unlinkSource:(o,{entity:i,recordId:a})=>t(`${n}/sources/${encodeURIComponent(o)}/links/${encodeURIComponent(i)}${a===void 0?"":`/${encodeURIComponent(a)}`}`,{fallback:"The document could not be detached.",method:"DELETE"}),updateSource:(o,i)=>t(`${n}/sources/${encodeURIComponent(o)}`,{body:JSON.stringify(i),fallback:"The document could not be updated.",method:"PATCH"})}}var ae={busy:"fk:bg-amber-500/15 fk:text-amber-700 fk:dark:text-amber-400",error:"fk:bg-destructive/15 fk:text-destructive",muted:"fk:bg-muted fk:text-muted-foreground",ready:"fk:bg-emerald-500/15 fk:text-emerald-700 fk:dark:text-emerald-400"};function le(){let{currentProjectId:e}=f();return {api:useMemo(()=>e?O(e):null,[e]),projectId:e}}function de(){return mutate(N,void 0,{revalidate:true})}function Pe(){return mutate(J,void 0,{revalidate:true})}function ce(e,n){return e instanceof u||e instanceof Error?e.message:n}function Ee(e,n){if(e.duplicate){qa.info(`"${e.source.title}" is already in Knowledge.`);return}qa.success(`Added ${n}. Indexing starts now.`);}function _e({children:e}){return jsx("div",{className:"fk:rounded-md fk:border fk:border-dashed fk:p-8 fk:text-center fk:text-sm fk:text-muted-foreground fk:corner-squircle",children:e})}function Me({label:e,tone:n}){return jsxs(b,{className:`fk:border-none fk:corner-squircle ${ae[n]}`,variant:"outline",children:[n==="busy"?jsx(LoaderCircle,{className:"fk:size-3 fk:animate-spin"}):null,e]})}var ue={document:Document,docx:Docx,html:Html,pdf:Pdf,pptx:Pptx,txt:Txt};function ge({className:e="",size:n=24,source:t}){let r=h(t),o=ue[r.icon];return jsx("span",{"aria-label":r.label,className:`fk:flex fk:shrink-0 fk:items-center fk:justify-center ${e}`,"data-knowledge-type":r.icon,role:"img",children:jsx(o,{size:n})})}function Ue({source:e}){return jsx(ge,{size:40,source:e})}function Le({onVisible:e}){let n=useRef(null),t=useRef(e);return t.current=e,useEffect(()=>{let r=n.current;if(!r)return;let o=new IntersectionObserver(i=>{i.some(a=>a.isIntersecting)&&t.current();});return o.observe(r),()=>{o.disconnect();}},[]),jsx("div",{"aria-hidden":true,className:"fk:h-px",ref:n})}function je({isBusy:e$2=false,onOpen:n$1,onRemoved:t,source:r,trigger:o$1="row"}){let{api:i$1,projectId:a$1}=le(),l=b$1(),[c$1,p]=useState(false),[f,b]=useState(false);if(!i$1||!a$1)return null;let X=i$1;async function H(){b(true);try{await X.deleteSource(r.id),qa.success(`Removed "${r.title}".`),p(!1),t(),de();}catch(w){qa.error(ce(w,"The document could not be removed."));}finally{b(false);}}return jsxs(Fragment,{children:[jsxs(e,{children:[jsx(g,{asChild:true,children:jsx(b$2,{"aria-label":`Actions for ${r.title}`,className:o$1==="row"?"fk:size-8 fk:shrink-0 fk:text-muted-foreground":void 0,"data-knowledge-menu":true,size:"icon-sm",variant:o$1==="row"?"ghost":"outline",children:jsx(EllipsisVerticalIcon,{className:"fk:size-4"})})}),jsxs(h$1,{align:"end",children:[n$1?jsx(j$1,{onSelect:n$1,children:"Open"}):null,r.path?jsx(j$1,{asChild:true,children:jsxs("a",{href:j(a$1).file(r.id),children:[jsx(DownloadIcon,{}),"Download"]})}):null,r.originUrl?jsx(j$1,{asChild:true,children:jsxs("a",{href:r.originUrl,rel:"noreferrer",target:"_blank",children:[jsx(ExternalLinkIcon,{}),"Open page"]})}):null,n$1||r.path||r.originUrl?jsx(o,{}):null,jsxs(j$1,{disabled:!l||e$2,variant:"destructive",onSelect:()=>p(true),children:[jsx(Trash2Icon,{}),"Remove"]}),l?null:jsx(n,{className:"fk:max-w-56 fk:whitespace-normal fk:text-xs fk:font-normal fk:text-muted-foreground",children:"Your member role cannot remove documents."})]})]}),jsx(a,{open:c$1,onOpenChange:p,children:jsxs(c,{children:[jsxs(d,{children:[jsx(f$1,{children:"Remove this document?"}),jsxs(g$1,{children:['"',r.title,'" and its indexed passages are deleted for everyone. Answers the agent gave earlier keep their citations, but the document can no longer be opened.']})]}),jsxs(e$1,{children:[jsx(i,{disabled:f,children:"Cancel"}),jsxs(h$2,{disabled:f,onClick:w=>{w.preventDefault(),H();},children:[f?jsx(LoaderCircle,{className:"fk:animate-spin"}):null,"Remove document"]})]})]})})]})}export{k as a,fe as b,j as c,O as d,le as e,de as f,Pe as g,ce as h,Ee as i,_e as j,Me as k,ge as l,Ue as m,Le as n,je as o};//# sourceMappingURL=chunk-K2KW6UYG.js.map
2
- //# sourceMappingURL=chunk-K2KW6UYG.js.map
1
+ import'./index.css';import {a,c,d,f as f$1,g as g$1,e as e$1,i,h as h$2}from'./chunk-2NXQF2F7.js';import {b as b$1}from'./chunk-V7C4EHK3.js';import {h}from'./chunk-7KLXWCDS.js';import {f}from'./chunk-NSVX6HEN.js';import {qa}from'./chunk-DGIY4SKN.js';import {e,g,h as h$1,j as j$1,o,n}from'./chunk-SZEGGBOC.js';import {b}from'./chunk-32ZU4MLE.js';import {b as b$2}from'./chunk-6NRQMG26.js';import {put}from'@vercel/blob/client';import {useMemo,useRef,useEffect,useState}from'react';import {LoaderCircle,EllipsisVerticalIcon,DownloadIcon,ExternalLinkIcon,Trash2Icon}from'lucide-react';import {mutate}from'swr';import {Document}from'@untitledui/file-icons/dist/solid/document.mjs';import {Docx}from'@untitledui/file-icons/dist/solid/docx.mjs';import {Html}from'@untitledui/file-icons/dist/solid/html.mjs';import {Pdf}from'@untitledui/file-icons/dist/solid/pdf.mjs';import {Pptx}from'@untitledui/file-icons/dist/solid/pptx.mjs';import {Txt}from'@untitledui/file-icons/dist/solid/txt.mjs';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var u=class extends Error{code;status;constructor(n,t,r=null){super(t),this.name="KnowledgeApiError",this.code=r,this.status=n;}},k=class extends Error{status;constructor(n,t="Request failed"){super(t),this.name="FetcherError",this.status=n;}},fe=async e=>{let n=await fetch(e,{credentials:"include"});if(!n.ok)throw new k(n.status);return await n.json()};function j(e){let n=`/api/flexkit/${e}/knowledge`;return {entitySources:t=>`${n}/entities/${encodeURIComponent(t)}/sources`,file:t=>`${n}/sources/${encodeURIComponent(t)}/file`,job:t=>`${n}/jobs/${encodeURIComponent(t)}`,links:t=>`${n}/sources/${encodeURIComponent(t)}/links`,passages:(t,{from:r,to:o})=>`${n}/sources/${encodeURIComponent(t)}/passages?from=${String(r)}&to=${String(o)}`,recordSources:({entity:t,recordId:r})=>`${n}/records/${encodeURIComponent(t)}/${encodeURIComponent(r)}/sources`,source:t=>`${n}/sources/${encodeURIComponent(t)}`,sources:(t={})=>{let{limit:r=25,offset:o=0,search:i,status:a}=t,l=new URLSearchParams({limit:r.toString(),offset:o.toString()}),c=i?.trim();return c&&l.set("q",c),a&&l.set("status",a),`${n}/sources?${l.toString()}`},spaces:`/api/flexkit/${e}/spaces`}}function N(e){return typeof e=="string"&&e.includes("/knowledge/sources?")}function J(e){return typeof e=="string"&&(e.includes("/knowledge/records/")||e.includes("/knowledge/entities/")||e.includes("/knowledge/sources/")&&e.endsWith("/links"))}async function L(e,n){let t={};try{t=await e.json();}catch{}return new u(e.status,t.error?String(t.error):n,t.code??null)}function O(e){let n=`/api/flexkit/${e}/knowledge`;async function t(o,i){let{fallback:a,...l}=i,c=await fetch(o,{credentials:"include",headers:{"Content-Type":"application/json",...l.headers??{}},...l});if(!c.ok)throw await L(c,a);return await c.json()}function r(o){return t(`${n}/sources`,{body:JSON.stringify(o),fallback:"The document could not be added.",method:"POST"})}return {addFile:async(o,i)=>{let a=await fetch(`${n}/uploads`,{body:JSON.stringify({filename:o.name,mediaType:o.type||null,sizeBytes:o.size}),credentials:"include",headers:{"Content-Type":"application/json"},method:"POST",signal:i?.signal});if(!a.ok)throw await L(a,"The file could not be uploaded.");let l=await a.json();if(!l.pathname||!l.token||!l.mediaType)throw new u(a.status,"The file could not be uploaded.");return await put(l.pathname,o,{abortSignal:i?.signal,access:"public",contentType:l.mediaType,token:l.token}),r({kind:"upload",pathname:l.pathname})},addUrl:({title:o,url:i})=>r({kind:"url",url:i,...o?{title:o}:{}}),addChatAttachment:({filename:o,url:i})=>r({filename:o,kind:"chat-attachment",url:i}),deleteSource:o=>t(`${n}/sources/${encodeURIComponent(o)}`,{fallback:"The document could not be removed.",method:"DELETE"}),linkSource:(o,i)=>t(`${n}/sources/${encodeURIComponent(o)}/links`,{body:JSON.stringify(i),fallback:"The document could not be attached.",method:"POST"}),reingestSource:o=>t(`${n}/sources/${encodeURIComponent(o)}/reingest`,{fallback:"The document could not be re-indexed.",method:"POST"}),unlinkSource:(o,{entity:i,recordId:a})=>t(`${n}/sources/${encodeURIComponent(o)}/links/${encodeURIComponent(i)}${a===void 0?"":`/${encodeURIComponent(a)}`}`,{fallback:"The document could not be detached.",method:"DELETE"}),updateSource:(o,i)=>t(`${n}/sources/${encodeURIComponent(o)}`,{body:JSON.stringify(i),fallback:"The document could not be updated.",method:"PATCH"})}}var ae={busy:"fk:bg-amber-500/15 fk:text-amber-700 fk:dark:text-amber-400",error:"fk:bg-destructive/15 fk:text-destructive",muted:"fk:bg-muted fk:text-muted-foreground",ready:"fk:bg-emerald-500/15 fk:text-emerald-700 fk:dark:text-emerald-400"};function le(){let{currentProjectId:e}=f();return {api:useMemo(()=>e?O(e):null,[e]),projectId:e}}function de(){return mutate(N,void 0,{revalidate:true})}function Pe(){return mutate(J,void 0,{revalidate:true})}function ce(e,n){return e instanceof u||e instanceof Error?e.message:n}function Ee(e,n){if(e.duplicate){qa.info(`"${e.source.title}" is already in Knowledge.`);return}qa.success(`Added ${n}. Indexing starts now.`);}function _e({children:e}){return jsx("div",{className:"fk:rounded-md fk:border fk:border-dashed fk:p-8 fk:text-center fk:text-sm fk:text-muted-foreground fk:corner-squircle",children:e})}function Me({label:e,tone:n}){return jsxs(b,{className:`fk:border-none fk:corner-squircle ${ae[n]}`,variant:"outline",children:[n==="busy"?jsx(LoaderCircle,{className:"fk:size-3 fk:animate-spin"}):null,e]})}var ue={document:Document,docx:Docx,html:Html,pdf:Pdf,pptx:Pptx,txt:Txt};function ge({className:e="",size:n=24,source:t}){let r=h(t),o=ue[r.icon];return jsx("span",{"aria-label":r.label,className:`fk:flex fk:shrink-0 fk:items-center fk:justify-center ${e}`,"data-knowledge-type":r.icon,role:"img",children:jsx(o,{size:n})})}function Ue({source:e}){return jsx(ge,{size:40,source:e})}function Le({onVisible:e}){let n=useRef(null),t=useRef(e);return t.current=e,useEffect(()=>{let r=n.current;if(!r)return;let o=new IntersectionObserver(i=>{i.some(a=>a.isIntersecting)&&t.current();});return o.observe(r),()=>{o.disconnect();}},[]),jsx("div",{"aria-hidden":true,className:"fk:h-px",ref:n})}function je({isBusy:e$2=false,onOpen:n$1,onRemoved:t,source:r,trigger:o$1="row"}){let{api:i$1,projectId:a$1}=le(),l=b$1(),[c$1,p]=useState(false),[f,b]=useState(false);if(!i$1||!a$1)return null;let X=i$1;async function H(){b(true);try{await X.deleteSource(r.id),qa.success(`Removed "${r.title}".`),p(!1),t(),de();}catch(w){qa.error(ce(w,"The document could not be removed."));}finally{b(false);}}return jsxs(Fragment,{children:[jsxs(e,{children:[jsx(g,{asChild:true,children:jsx(b$2,{"aria-label":`Actions for ${r.title}`,className:o$1==="row"?"fk:size-8 fk:shrink-0 fk:text-muted-foreground":void 0,"data-knowledge-menu":true,size:"icon-sm",variant:o$1==="row"?"ghost":"outline",children:jsx(EllipsisVerticalIcon,{className:"fk:size-4"})})}),jsxs(h$1,{align:"end",children:[n$1?jsx(j$1,{onSelect:n$1,children:"Open"}):null,r.path?jsx(j$1,{asChild:true,children:jsxs("a",{href:j(a$1).file(r.id),children:[jsx(DownloadIcon,{}),"Download"]})}):null,r.originUrl?jsx(j$1,{asChild:true,children:jsxs("a",{href:r.originUrl,rel:"noreferrer",target:"_blank",children:[jsx(ExternalLinkIcon,{}),"Open page"]})}):null,n$1||r.path||r.originUrl?jsx(o,{}):null,jsxs(j$1,{disabled:!l||e$2,variant:"destructive",onSelect:()=>p(true),children:[jsx(Trash2Icon,{}),"Remove"]}),l?null:jsx(n,{className:"fk:max-w-56 fk:whitespace-normal fk:text-xs fk:font-normal fk:text-muted-foreground",children:"Your member role cannot remove documents."})]})]}),jsx(a,{open:c$1,onOpenChange:p,children:jsxs(c,{children:[jsxs(d,{children:[jsx(f$1,{children:"Remove this document?"}),jsxs(g$1,{children:['"',r.title,'" and its indexed passages are deleted for everyone. Answers the agent gave earlier keep their citations, but the document can no longer be opened.']})]}),jsxs(e$1,{children:[jsx(i,{disabled:f,children:"Cancel"}),jsxs(h$2,{disabled:f,onClick:w=>{w.preventDefault(),H();},children:[f?jsx(LoaderCircle,{className:"fk:animate-spin"}):null,"Remove document"]})]})]})})]})}export{k as a,fe as b,j as c,O as d,le as e,de as f,Pe as g,ce as h,Ee as i,_e as j,Me as k,ge as l,Ue as m,Le as n,je as o};//# sourceMappingURL=chunk-HTSMODQB.js.map
2
+ //# sourceMappingURL=chunk-HTSMODQB.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/apps/knowledge/api.ts","../src/apps/knowledge/shared.tsx"],"names":["KnowledgeApiError","status","message","code","FetcherError","fetcher","url","response","knowledgePaths","projectId","basePath","entity","sourceId","jobId","from","to","recordId","options","limit","offset","search","params","trimmedSearch","isKnowledgeListKey","key","isKnowledgeLinkKey","readError","fallback","data","createKnowledgeApi","request","init","requestInit","register","body","file","tokenResponse","tokenData","put","title","filename","target","patch","STATUS_TONE_CLASSES","useProjectKnowledge","currentProjectId","useConfig","useMemo","invalidateKnowledgeLists","mutateGlobal","invalidateKnowledgeLinks","describeApiError","error","announceRegistered","result","name","toast","PageMessage","children","jsx","StatusBadge","label","tone","jsxs","Badge","LoaderCircle","FILE_ICONS","Document","Docx","Html","Pdf","Pptx","Txt","KnowledgeTypeIcon","className","size","source","format","getKnowledgeFormat","Icon","SourceIcon","InfiniteScrollSentinel","onVisible","sentinelRef","useRef","onVisibleRef","useEffect","node","observer","entries","entry","SourceActionsMenu","isBusy","onOpen","onRemoved","trigger","api","canMutate","useCanMutate","isConfirmingRemoval","setIsConfirmingRemoval","useState","isRemoving","setIsRemoving","knowledgeApi","remove","removeError","Fragment","DropdownMenu","DropdownMenuTrigger","Button","EllipsisVerticalIcon","DropdownMenuContent","DropdownMenuItem","DownloadIcon","ExternalLinkIcon","DropdownMenuSeparator","Trash2Icon","DropdownMenuLabel","AlertDialog","AlertDialogContent","AlertDialogHeader","AlertDialogTitle","AlertDialogDescription","AlertDialogFooter","AlertDialogCancel","AlertDialogAction","event"],"mappings":"0gCAYO,IAAMA,CAAAA,CAAN,cAAgC,KAAM,CAC3C,IAAA,CACA,MAAA,CAEA,YAAYC,CAAAA,CAAgBC,CAAAA,CAA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AAA,CAAA,CAAA9D,GAAAA,CAAC+D,GAAAA,CAAA,CAAiB,iCAAqB,CAAA,CACvC3D,IAAAA,CAAC4D,IAAA,CAAuB,QAAA,CAAA,CAAA,GAAA,CACpB/C,EAAO,KAAA,CAAM,qJAAA,CAAA,CAEjB,CAAA,CAAA,CACF,CAAA,CACAb,KAAC6D,GAAAA,CAAA,CACC,QAAA,CAAA,CAAAjE,GAAAA,CAACkE,EAAA,CAAkB,QAAA,CAAUvB,CAAAA,CAAY,QAAA,CAAA,QAAA,CAAM,EAC/CvC,IAAAA,CAAC+D,GAAAA,CAAA,CACC,QAAA,CAAUxB,CAAAA,CACV,QAAUyB,CAAAA,EAAsB,CAC9BA,CAAAA,CAAM,cAAA,GACDtB,CAAAA,GACP,EAEC,QAAA,CAAA,CAAAH,CAAAA,CAAa3C,IAACM,YAAAA,CAAA,CAAa,SAAA,CAAU,iBAAA,CAAkB,EAAK,IAAA,CAAK,iBAAA,CAAA,CAEpE,GACF,CAAA,CAAA,CACF,CAAA,CACF,GACF,CAEJ","file":"chunk-K2KW6UYG.js","sourcesContent":["import { put } from '@vercel/blob/client';\nimport type {\n KnowledgeJob,\n KnowledgeLinkTarget,\n KnowledgeRecordRef,\n KnowledgeSource,\n KnowledgeSourcePatch,\n KnowledgeSourceStatus,\n RegisterKnowledgeSourceResult,\n} from './knowledge';\n\n/** The platform refused a knowledge request; `code` lets the UI tailor the message. */\nexport class KnowledgeApiError 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 = 'KnowledgeApiError';\n this.code = code;\n this.status = status;\n }\n}\n\nexport interface ProjectSpace {\n code: string;\n id: string;\n label: string;\n}\n\nexport interface KnowledgeApi {\n /** Uploads a document to the file store, then registers it; resolves once indexing is queued or the file was already there. */\n addFile: (_file: File, _options?: { signal?: AbortSignal }) => Promise<RegisterKnowledgeSourceResult>;\n addUrl: (_input: { title?: string; url: string }) => Promise<RegisterKnowledgeSourceResult>;\n /** Promotes a file the caller attached to a chat: the platform copies it into the knowledge folder. */\n addChatAttachment: (_input: { filename: string; url: string }) => Promise<RegisterKnowledgeSourceResult>;\n deleteSource: (_sourceId: string) => Promise<{ deleted: true }>;\n /** Attaches the document to a record, or to every record of an entity type; `linked` is false when it already was. */\n linkSource: (_sourceId: string, _target: KnowledgeLinkTarget) => Promise<{ linked: boolean }>;\n reingestSource: (_sourceId: string) => Promise<{ job: KnowledgeJob }>;\n unlinkSource: (_sourceId: string, _target: KnowledgeLinkTarget) => Promise<{ unlinked: boolean }>;\n updateSource: (_sourceId: string, _patch: KnowledgeSourcePatch) => Promise<{ source: KnowledgeSource }>;\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 knowledgePaths(projectId: string): {\n /** The documents attached to every record of an entity type. */\n entitySources: (_entity: string) => string;\n /** The original file of an uploaded document, served under its name. */\n file: (_sourceId: string) => string;\n job: (_jobId: string) => string;\n /** The records a document is attached to, and the entity types it applies to. */\n links: (_sourceId: string) => string;\n passages: (_sourceId: string, _options: { from: number; to: number }) => string;\n /** The documents attached to a record. */\n recordSources: (_record: KnowledgeRecordRef) => string;\n source: (_sourceId: string) => string;\n sources: (_options?: { limit?: number; offset?: number; search?: string; status?: KnowledgeSourceStatus }) => string;\n spaces: string;\n} {\n const basePath = `/api/flexkit/${projectId}/knowledge`;\n\n return {\n entitySources: (entity) => `${basePath}/entities/${encodeURIComponent(entity)}/sources`,\n file: (sourceId) => `${basePath}/sources/${encodeURIComponent(sourceId)}/file`,\n job: (jobId) => `${basePath}/jobs/${encodeURIComponent(jobId)}`,\n links: (sourceId) => `${basePath}/sources/${encodeURIComponent(sourceId)}/links`,\n passages: (sourceId, { from, to }) =>\n `${basePath}/sources/${encodeURIComponent(sourceId)}/passages?from=${String(from)}&to=${String(to)}`,\n recordSources: ({ entity, recordId }) =>\n `${basePath}/records/${encodeURIComponent(entity)}/${encodeURIComponent(recordId)}/sources`,\n source: (sourceId) => `${basePath}/sources/${encodeURIComponent(sourceId)}`,\n sources: (options = {}) => {\n const { limit = 25, offset = 0, search, status } = options;\n const params = new URLSearchParams({ limit: limit.toString(), offset: offset.toString() });\n const trimmedSearch = search?.trim();\n\n if (trimmedSearch) {\n params.set('q', trimmedSearch);\n }\n\n if (status) {\n params.set('status', status);\n }\n\n return `${basePath}/sources?${params.toString()}`;\n },\n spaces: `/api/flexkit/${projectId}/spaces`,\n };\n}\n\n/** Whether an SWR key is a page of the document list, whatever its filters. */\nexport function isKnowledgeListKey(key: unknown): boolean {\n return typeof key === 'string' && key.includes('/knowledge/sources?');\n}\n\n/** Whether an SWR key lists the documents of a record or an entity type, or the links of a document. */\nexport function isKnowledgeLinkKey(key: unknown): boolean {\n return (\n typeof key === 'string' &&\n (key.includes('/knowledge/records/') ||\n key.includes('/knowledge/entities/') ||\n (key.includes('/knowledge/sources/') && key.endsWith('/links')))\n );\n}\n\nasync function readError(response: Response, fallback: string): Promise<KnowledgeApiError> {\n let data: { code?: string; error?: string } = {};\n\n try {\n data = (await response.json()) as { code?: string; error?: string };\n } catch {\n // Non-JSON error bodies keep the fallback message.\n }\n\n return new KnowledgeApiError(response.status, data.error ? String(data.error) : fallback, data.code ?? null);\n}\n\nexport function createKnowledgeApi(projectId: string): KnowledgeApi {\n const basePath = `/api/flexkit/${projectId}/knowledge`;\n\n async function request<T>(url: string, init: RequestInit & { fallback: string }): Promise<T> {\n const { fallback, ...requestInit } = init;\n const response = await fetch(url, {\n credentials: 'include',\n headers: { 'Content-Type': 'application/json', ...(requestInit.headers ?? {}) },\n ...requestInit,\n });\n\n if (!response.ok) {\n throw await readError(response, fallback);\n }\n\n return (await response.json()) as T;\n }\n\n function register(body: Record<string, unknown>): Promise<RegisterKnowledgeSourceResult> {\n return request<RegisterKnowledgeSourceResult>(`${basePath}/sources`, {\n body: JSON.stringify(body),\n fallback: 'The document could not be added.',\n method: 'POST',\n });\n }\n\n return {\n addFile: async (file, options) => {\n // The platform issues a token pinned to one pathname, type and size; the\n // browser writes the bytes to the store itself, so a 20 MB document never\n // crosses the API function body limit. Registration then hashes the blob.\n const tokenResponse = await fetch(`${basePath}/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: options?.signal,\n });\n\n if (!tokenResponse.ok) {\n throw await readError(tokenResponse, 'The file could not be uploaded.');\n }\n\n const tokenData = (await tokenResponse.json()) as { mediaType?: string; pathname?: string; token?: string };\n\n if (!tokenData.pathname || !tokenData.token || !tokenData.mediaType) {\n throw new KnowledgeApiError(tokenResponse.status, 'The file could not be uploaded.');\n }\n\n await put(tokenData.pathname, file, {\n abortSignal: options?.signal,\n access: 'public',\n contentType: tokenData.mediaType,\n token: tokenData.token,\n });\n\n return register({ kind: 'upload', pathname: tokenData.pathname });\n },\n addUrl: ({ title, url }) => register({ kind: 'url', url, ...(title ? { title } : {}) }),\n addChatAttachment: ({ filename, url }) => register({ filename, kind: 'chat-attachment', url }),\n deleteSource: (sourceId) =>\n request<{ deleted: true }>(`${basePath}/sources/${encodeURIComponent(sourceId)}`, {\n fallback: 'The document could not be removed.',\n method: 'DELETE',\n }),\n linkSource: (sourceId, target) =>\n request<{ linked: boolean }>(`${basePath}/sources/${encodeURIComponent(sourceId)}/links`, {\n body: JSON.stringify(target),\n fallback: 'The document could not be attached.',\n method: 'POST',\n }),\n reingestSource: (sourceId) =>\n request<{ job: KnowledgeJob }>(`${basePath}/sources/${encodeURIComponent(sourceId)}/reingest`, {\n fallback: 'The document could not be re-indexed.',\n method: 'POST',\n }),\n unlinkSource: (sourceId, { entity, recordId }) =>\n request<{ unlinked: boolean }>(\n `${basePath}/sources/${encodeURIComponent(sourceId)}/links/${encodeURIComponent(entity)}${\n recordId === undefined ? '' : `/${encodeURIComponent(recordId)}`\n }`,\n { fallback: 'The document could not be detached.', method: 'DELETE' }\n ),\n updateSource: (sourceId, patch) =>\n request<{ source: KnowledgeSource }>(`${basePath}/sources/${encodeURIComponent(sourceId)}`, {\n body: JSON.stringify(patch),\n fallback: 'The document could not be updated.',\n method: 'PATCH',\n }),\n };\n}\n","import type { JSX, MouseEvent } from 'react';\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { DownloadIcon, EllipsisVerticalIcon, ExternalLinkIcon, LoaderCircle, Trash2Icon } from 'lucide-react';\nimport { mutate as mutateGlobal } from 'swr';\n// File type icons: Untitled UI's free file icons, Solid variant. The set is\n// published as the MIT package `@untitledui/file-icons`; the page below shows\n// every icon and offers each as SVG or JSX should another format need one.\n// https://www.untitledui.com/resources/file-icons\nimport { Document } from '@untitledui/file-icons/dist/solid/document.mjs';\nimport { Docx } from '@untitledui/file-icons/dist/solid/docx.mjs';\nimport { Html } from '@untitledui/file-icons/dist/solid/html.mjs';\nimport { Pdf } from '@untitledui/file-icons/dist/solid/pdf.mjs';\nimport { Pptx } from '@untitledui/file-icons/dist/solid/pptx.mjs';\nimport { Txt } from '@untitledui/file-icons/dist/solid/txt.mjs';\nimport { useConfig } from '../../core/config/config-context';\nimport { useCanMutate } from '../../core/permissions';\nimport {\n Badge,\n Button,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n toast,\n} from '../../ui';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n} from '../../ui/primitives/alert-dialog';\nimport {\n createKnowledgeApi,\n isKnowledgeLinkKey,\n isKnowledgeListKey,\n KnowledgeApiError,\n knowledgePaths,\n type KnowledgeApi,\n} from './api';\nimport {\n getKnowledgeFormat,\n type KnowledgeFileIcon,\n type KnowledgeSource,\n type KnowledgeStatusTone,\n type RegisterKnowledgeSourceResult,\n} from './knowledge';\n\nconst STATUS_TONE_CLASSES: { [tone in KnowledgeStatusTone]: string } = {\n busy: 'fk:bg-amber-500/15 fk:text-amber-700 fk:dark:text-amber-400',\n error: 'fk:bg-destructive/15 fk:text-destructive',\n muted: 'fk:bg-muted fk:text-muted-foreground',\n ready: 'fk:bg-emerald-500/15 fk:text-emerald-700 fk:dark:text-emerald-400',\n};\n\nexport function useProjectKnowledge(): { api: KnowledgeApi | null; projectId: string | undefined } {\n const { currentProjectId } = useConfig();\n const api = useMemo(() => (currentProjectId ? createKnowledgeApi(currentProjectId) : null), [currentProjectId]);\n\n return { api, projectId: currentProjectId };\n}\n\n/** Drops every cached page of the document list, so the next visit fetches it afresh. */\nexport function invalidateKnowledgeLists(): Promise<unknown> {\n return mutateGlobal(isKnowledgeListKey, undefined, { revalidate: true });\n}\n\n/** Drops every cached link listing (a record's documents, a document's records) after a link changed. */\nexport function invalidateKnowledgeLinks(): Promise<unknown> {\n return mutateGlobal(isKnowledgeLinkKey, undefined, { revalidate: true });\n}\n\nexport function describeApiError(error: unknown, fallback: string): string {\n if (error instanceof KnowledgeApiError) {\n return error.message;\n }\n\n return error instanceof Error ? error.message : fallback;\n}\n\n/** What the user hears once a document was registered. */\nexport function announceRegistered(result: RegisterKnowledgeSourceResult, name: string): void {\n if (result.duplicate) {\n toast.info(`\"${result.source.title}\" is already in Knowledge.`);\n\n return;\n }\n\n toast.success(`Added ${name}. Indexing starts now.`);\n}\n\nexport function PageMessage({ children }: { children: string }): JSX.Element {\n return (\n <div className=\"fk:rounded-md fk:border fk:border-dashed fk:p-8 fk:text-center fk:text-sm fk:text-muted-foreground fk:corner-squircle\">\n {children}\n </div>\n );\n}\n\nexport function StatusBadge({ label, tone }: { label: string; tone: KnowledgeStatusTone }): JSX.Element {\n return (\n <Badge className={`fk:border-none fk:corner-squircle ${STATUS_TONE_CLASSES[tone]}`} variant=\"outline\">\n {tone === 'busy' ? <LoaderCircle className=\"fk:size-3 fk:animate-spin\" /> : null}\n {label}\n </Badge>\n );\n}\n\nconst FILE_ICONS: { [icon in KnowledgeFileIcon]: typeof Pdf } = {\n document: Document,\n docx: Docx,\n html: Html,\n pdf: Pdf,\n pptx: Pptx,\n txt: Txt,\n};\n\n/** The document's format as its file icon; the format's name is what a screen reader hears. */\nexport function KnowledgeTypeIcon({\n className = '',\n size = 24,\n source,\n}: {\n className?: string;\n size?: number;\n source: Pick<KnowledgeSource, 'kind' | 'mimeType'>;\n}): JSX.Element {\n const format = getKnowledgeFormat(source);\n const Icon = FILE_ICONS[format.icon];\n\n return (\n <span\n aria-label={format.label}\n className={`fk:flex fk:shrink-0 fk:items-center fk:justify-center ${className}`}\n data-knowledge-type={format.icon}\n role=\"img\"\n >\n <Icon size={size} />\n </span>\n );\n}\n\n/** The larger file icon of the document page and the record panel: the same icon as the list, at 40px. */\nexport function SourceIcon({ source }: { source: Pick<KnowledgeSource, 'kind' | 'mimeType'> }): JSX.Element {\n return <KnowledgeTypeIcon size={40} source={source} />;\n}\n\nexport function InfiniteScrollSentinel({ onVisible }: { onVisible: () => void }): JSX.Element {\n const sentinelRef = useRef<HTMLDivElement>(null);\n const onVisibleRef = useRef(onVisible);\n\n onVisibleRef.current = onVisible;\n\n useEffect(() => {\n const node = sentinelRef.current;\n\n if (!node) {\n return;\n }\n\n const observer = new IntersectionObserver((entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n onVisibleRef.current();\n }\n });\n\n observer.observe(node);\n\n return () => {\n observer.disconnect();\n };\n }, []);\n\n return <div aria-hidden className=\"fk:h-px\" ref={sentinelRef} />;\n}\n\n/**\n * The actions of one document, behind a three-dots button: open (lists\n * only), download the original file (web pages open their address instead)\n * and remove, behind one confirmation. The list and the document page share\n * it so the copy, the download link and the busy rules stay the same.\n */\nexport function SourceActionsMenu({\n isBusy = false,\n onOpen,\n onRemoved,\n source,\n trigger = 'row',\n}: {\n /** Another action on the document is in flight; removing waits for it. */\n isBusy?: boolean;\n /** Offered as the first item when given (the document page is already open). */\n onOpen?: () => void;\n /** The document is gone: drop it from the list, or leave its page. The list invalidation is done here. */\n onRemoved: () => void;\n source: KnowledgeSource;\n /** How the button looks: a quiet icon in a row or card, an outlined one next to page actions. */\n trigger?: 'row' | 'page';\n}): JSX.Element | null {\n const { api, projectId } = useProjectKnowledge();\n const canMutate = useCanMutate();\n const [isConfirmingRemoval, setIsConfirmingRemoval] = useState(false);\n const [isRemoving, setIsRemoving] = useState(false);\n\n if (!api || !projectId) {\n return null;\n }\n\n const knowledgeApi = api;\n\n async function remove(): Promise<void> {\n setIsRemoving(true);\n\n try {\n await knowledgeApi.deleteSource(source.id);\n toast.success(`Removed \"${source.title}\".`);\n setIsConfirmingRemoval(false);\n onRemoved();\n void invalidateKnowledgeLists();\n } catch (removeError) {\n toast.error(describeApiError(removeError, 'The document could not be removed.'));\n } finally {\n setIsRemoving(false);\n }\n }\n\n return (\n <>\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n aria-label={`Actions for ${source.title}`}\n className={trigger === 'row' ? 'fk:size-8 fk:shrink-0 fk:text-muted-foreground' : undefined}\n data-knowledge-menu\n size=\"icon-sm\"\n variant={trigger === 'row' ? 'ghost' : 'outline'}\n >\n <EllipsisVerticalIcon className=\"fk:size-4\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {onOpen ? <DropdownMenuItem onSelect={onOpen}>Open</DropdownMenuItem> : null}\n {source.path ? (\n <DropdownMenuItem asChild>\n <a href={knowledgePaths(projectId).file(source.id)}>\n <DownloadIcon />\n Download\n </a>\n </DropdownMenuItem>\n ) : null}\n {source.originUrl ? (\n <DropdownMenuItem asChild>\n <a href={source.originUrl} rel=\"noreferrer\" target=\"_blank\">\n <ExternalLinkIcon />\n Open page\n </a>\n </DropdownMenuItem>\n ) : null}\n {onOpen || source.path || source.originUrl ? <DropdownMenuSeparator /> : null}\n <DropdownMenuItem\n disabled={!canMutate || isBusy}\n variant=\"destructive\"\n onSelect={() => setIsConfirmingRemoval(true)}\n >\n <Trash2Icon />\n Remove\n </DropdownMenuItem>\n {canMutate ? null : (\n <DropdownMenuLabel className=\"fk:max-w-56 fk:whitespace-normal fk:text-xs fk:font-normal fk:text-muted-foreground\">\n Your member role cannot remove documents.\n </DropdownMenuLabel>\n )}\n </DropdownMenuContent>\n </DropdownMenu>\n <AlertDialog open={isConfirmingRemoval} onOpenChange={setIsConfirmingRemoval}>\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>Remove this document?</AlertDialogTitle>\n <AlertDialogDescription>\n \"{source.title}\" and its indexed passages are deleted for everyone. Answers the agent gave earlier keep\n their citations, but the document can no longer be opened.\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel disabled={isRemoving}>Cancel</AlertDialogCancel>\n <AlertDialogAction\n disabled={isRemoving}\n onClick={(event: MouseEvent) => {\n event.preventDefault();\n void remove();\n }}\n >\n {isRemoving ? <LoaderCircle className=\"fk:animate-spin\" /> : null}\n Remove document\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/apps/knowledge/api.ts","../src/apps/knowledge/shared.tsx"],"names":["KnowledgeApiError","status","message","code","FetcherError","fetcher","url","response","knowledgePaths","projectId","basePath","entity","sourceId","jobId","from","to","recordId","options","limit","offset","search","params","trimmedSearch","isKnowledgeListKey","key","isKnowledgeLinkKey","readError","fallback","data","createKnowledgeApi","request","init","requestInit","register","body","file","tokenResponse","tokenData","put","title","filename","target","patch","STATUS_TONE_CLASSES","useProjectKnowledge","currentProjectId","useConfig","useMemo","invalidateKnowledgeLists","mutateGlobal","invalidateKnowledgeLinks","describeApiError","error","announceRegistered","result","name","toast","PageMessage","children","jsx","StatusBadge","label","tone","jsxs","Badge","LoaderCircle","FILE_ICONS","Document","Docx","Html","Pdf","Pptx","Txt","KnowledgeTypeIcon","className","size","source","format","getKnowledgeFormat","Icon","SourceIcon","InfiniteScrollSentinel","onVisible","sentinelRef","useRef","onVisibleRef","useEffect","node","observer","entries","entry","SourceActionsMenu","isBusy","onOpen","onRemoved","trigger","api","canMutate","useCanMutate","isConfirmingRemoval","setIsConfirmingRemoval","useState","isRemoving","setIsRemoving","knowledgeApi","remove","removeError","Fragment","DropdownMenu","DropdownMenuTrigger","Button","EllipsisVerticalIcon","DropdownMenuContent","DropdownMenuItem","DownloadIcon","ExternalLinkIcon","DropdownMenuSeparator","Trash2Icon","DropdownMenuLabel","AlertDialog","AlertDialogContent","AlertDialogHeader","AlertDialogTitle","AlertDialogDescription","AlertDialogFooter","AlertDialogCancel","AlertDialogAction","event"],"mappings":"0gCAYO,IAAMA,CAAAA,CAAN,cAAgC,KAAM,CAC3C,IAAA,CACA,MAAA,CAEA,YAAYC,CAAAA,CAAgBC,CAAAA,CAAiBC,EAAsB,IAAA,CAAM,CACvE,MAAMD,CAAO,CAAA,CACb,IAAA,CAAK,IAAA,CAAO,oBACZ,IAAA,CAAK,IAAA,CAAOC,CAAAA,CACZ,IAAA,CAAK,OAASF,EAChB,CACF,CAAA,CAsBaG,CAAAA,CAAN,cAA2B,KAAM,CACtC,OAEA,WAAA,CAAYH,CAAAA,CAAgBC,EAAU,gBAAA,CAAkB,CACtD,KAAA,CAAMA,CAAO,EACb,IAAA,CAAK,IAAA,CAAO,cAAA,CACZ,IAAA,CAAK,OAASD,EAChB,CACF,CAAA,CAEaI,EAAAA,CAAU,MAAUC,CAAAA,EAA4B,CAC3D,IAAMC,CAAAA,CAAW,MAAM,MAAMD,CAAAA,CAAK,CAAE,WAAA,CAAa,SAAU,CAAC,CAAA,CAE5D,GAAI,CAACC,CAAAA,CAAS,EAAA,CACZ,MAAM,IAAIH,CAAAA,CAAaG,CAAAA,CAAS,MAAM,EAGxC,OAAQ,MAAMA,EAAS,IAA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AA,CAAA,CACF,CAAA,CACF,GACF,CAEJ","file":"chunk-HTSMODQB.js","sourcesContent":["import { put } from '@vercel/blob/client';\nimport type {\n KnowledgeJob,\n KnowledgeLinkTarget,\n KnowledgeRecordRef,\n KnowledgeSource,\n KnowledgeSourcePatch,\n KnowledgeSourceStatus,\n RegisterKnowledgeSourceResult,\n} from './knowledge';\n\n/** The platform refused a knowledge request; `code` lets the UI tailor the message. */\nexport class KnowledgeApiError 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 = 'KnowledgeApiError';\n this.code = code;\n this.status = status;\n }\n}\n\nexport interface ProjectSpace {\n code: string;\n id: string;\n label: string;\n}\n\nexport interface KnowledgeApi {\n /** Uploads a document to the file store, then registers it; resolves once indexing is queued or the file was already there. */\n addFile: (_file: File, _options?: { signal?: AbortSignal }) => Promise<RegisterKnowledgeSourceResult>;\n addUrl: (_input: { title?: string; url: string }) => Promise<RegisterKnowledgeSourceResult>;\n /** Promotes a file the caller attached to a chat: the platform copies it into the knowledge folder. */\n addChatAttachment: (_input: { filename: string; url: string }) => Promise<RegisterKnowledgeSourceResult>;\n deleteSource: (_sourceId: string) => Promise<{ deleted: true }>;\n /** Attaches the document to a record, or to every record of an entity type; `linked` is false when it already was. */\n linkSource: (_sourceId: string, _target: KnowledgeLinkTarget) => Promise<{ linked: boolean }>;\n reingestSource: (_sourceId: string) => Promise<{ job: KnowledgeJob }>;\n unlinkSource: (_sourceId: string, _target: KnowledgeLinkTarget) => Promise<{ unlinked: boolean }>;\n updateSource: (_sourceId: string, _patch: KnowledgeSourcePatch) => Promise<{ source: KnowledgeSource }>;\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 knowledgePaths(projectId: string): {\n /** The documents attached to every record of an entity type. */\n entitySources: (_entity: string) => string;\n /** The original file of an uploaded document, served under its name. */\n file: (_sourceId: string) => string;\n job: (_jobId: string) => string;\n /** The records a document is attached to, and the entity types it applies to. */\n links: (_sourceId: string) => string;\n passages: (_sourceId: string, _options: { from: number; to: number }) => string;\n /** The documents attached to a record. */\n recordSources: (_record: KnowledgeRecordRef) => string;\n source: (_sourceId: string) => string;\n sources: (_options?: { limit?: number; offset?: number; search?: string; status?: KnowledgeSourceStatus }) => string;\n spaces: string;\n} {\n const basePath = `/api/flexkit/${projectId}/knowledge`;\n\n return {\n entitySources: (entity) => `${basePath}/entities/${encodeURIComponent(entity)}/sources`,\n file: (sourceId) => `${basePath}/sources/${encodeURIComponent(sourceId)}/file`,\n job: (jobId) => `${basePath}/jobs/${encodeURIComponent(jobId)}`,\n links: (sourceId) => `${basePath}/sources/${encodeURIComponent(sourceId)}/links`,\n passages: (sourceId, { from, to }) =>\n `${basePath}/sources/${encodeURIComponent(sourceId)}/passages?from=${String(from)}&to=${String(to)}`,\n recordSources: ({ entity, recordId }) =>\n `${basePath}/records/${encodeURIComponent(entity)}/${encodeURIComponent(recordId)}/sources`,\n source: (sourceId) => `${basePath}/sources/${encodeURIComponent(sourceId)}`,\n sources: (options = {}) => {\n const { limit = 25, offset = 0, search, status } = options;\n const params = new URLSearchParams({ limit: limit.toString(), offset: offset.toString() });\n const trimmedSearch = search?.trim();\n\n if (trimmedSearch) {\n params.set('q', trimmedSearch);\n }\n\n if (status) {\n params.set('status', status);\n }\n\n return `${basePath}/sources?${params.toString()}`;\n },\n spaces: `/api/flexkit/${projectId}/spaces`,\n };\n}\n\n/** Whether an SWR key is a page of the document list, whatever its filters. */\nexport function isKnowledgeListKey(key: unknown): boolean {\n return typeof key === 'string' && key.includes('/knowledge/sources?');\n}\n\n/** Whether an SWR key lists the documents of a record or an entity type, or the links of a document. */\nexport function isKnowledgeLinkKey(key: unknown): boolean {\n return (\n typeof key === 'string' &&\n (key.includes('/knowledge/records/') ||\n key.includes('/knowledge/entities/') ||\n (key.includes('/knowledge/sources/') && key.endsWith('/links')))\n );\n}\n\nasync function readError(response: Response, fallback: string): Promise<KnowledgeApiError> {\n let data: { code?: string; error?: string } = {};\n\n try {\n data = (await response.json()) as { code?: string; error?: string };\n } catch {\n // Non-JSON error bodies keep the fallback message.\n }\n\n return new KnowledgeApiError(response.status, data.error ? String(data.error) : fallback, data.code ?? null);\n}\n\nexport function createKnowledgeApi(projectId: string): KnowledgeApi {\n const basePath = `/api/flexkit/${projectId}/knowledge`;\n\n async function request<T>(url: string, init: RequestInit & { fallback: string }): Promise<T> {\n const { fallback, ...requestInit } = init;\n const response = await fetch(url, {\n credentials: 'include',\n headers: { 'Content-Type': 'application/json', ...(requestInit.headers ?? {}) },\n ...requestInit,\n });\n\n if (!response.ok) {\n throw await readError(response, fallback);\n }\n\n return (await response.json()) as T;\n }\n\n function register(body: Record<string, unknown>): Promise<RegisterKnowledgeSourceResult> {\n return request<RegisterKnowledgeSourceResult>(`${basePath}/sources`, {\n body: JSON.stringify(body),\n fallback: 'The document could not be added.',\n method: 'POST',\n });\n }\n\n return {\n addFile: async (file, options) => {\n // The platform issues a token pinned to one pathname, type and size; the\n // browser writes the bytes to the store itself, so a 20 MB document never\n // crosses the API function body limit. Registration then hashes the blob.\n const tokenResponse = await fetch(`${basePath}/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: options?.signal,\n });\n\n if (!tokenResponse.ok) {\n throw await readError(tokenResponse, 'The file could not be uploaded.');\n }\n\n const tokenData = (await tokenResponse.json()) as { mediaType?: string; pathname?: string; token?: string };\n\n if (!tokenData.pathname || !tokenData.token || !tokenData.mediaType) {\n throw new KnowledgeApiError(tokenResponse.status, 'The file could not be uploaded.');\n }\n\n await put(tokenData.pathname, file, {\n abortSignal: options?.signal,\n access: 'public',\n contentType: tokenData.mediaType,\n token: tokenData.token,\n });\n\n return register({ kind: 'upload', pathname: tokenData.pathname });\n },\n addUrl: ({ title, url }) => register({ kind: 'url', url, ...(title ? { title } : {}) }),\n addChatAttachment: ({ filename, url }) => register({ filename, kind: 'chat-attachment', url }),\n deleteSource: (sourceId) =>\n request<{ deleted: true }>(`${basePath}/sources/${encodeURIComponent(sourceId)}`, {\n fallback: 'The document could not be removed.',\n method: 'DELETE',\n }),\n linkSource: (sourceId, target) =>\n request<{ linked: boolean }>(`${basePath}/sources/${encodeURIComponent(sourceId)}/links`, {\n body: JSON.stringify(target),\n fallback: 'The document could not be attached.',\n method: 'POST',\n }),\n reingestSource: (sourceId) =>\n request<{ job: KnowledgeJob }>(`${basePath}/sources/${encodeURIComponent(sourceId)}/reingest`, {\n fallback: 'The document could not be re-indexed.',\n method: 'POST',\n }),\n unlinkSource: (sourceId, { entity, recordId }) =>\n request<{ unlinked: boolean }>(\n `${basePath}/sources/${encodeURIComponent(sourceId)}/links/${encodeURIComponent(entity)}${\n recordId === undefined ? '' : `/${encodeURIComponent(recordId)}`\n }`,\n { fallback: 'The document could not be detached.', method: 'DELETE' }\n ),\n updateSource: (sourceId, patch) =>\n request<{ source: KnowledgeSource }>(`${basePath}/sources/${encodeURIComponent(sourceId)}`, {\n body: JSON.stringify(patch),\n fallback: 'The document could not be updated.',\n method: 'PATCH',\n }),\n };\n}\n","import type { JSX, MouseEvent } from 'react';\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { DownloadIcon, EllipsisVerticalIcon, ExternalLinkIcon, LoaderCircle, Trash2Icon } from 'lucide-react';\nimport { mutate as mutateGlobal } from 'swr';\n// File type icons: Untitled UI's free file icons, Solid variant. The set is\n// published as the MIT package `@untitledui/file-icons`; the page below shows\n// every icon and offers each as SVG or JSX should another format need one.\n// https://www.untitledui.com/resources/file-icons\nimport { Document } from '@untitledui/file-icons/dist/solid/document.mjs';\nimport { Docx } from '@untitledui/file-icons/dist/solid/docx.mjs';\nimport { Html } from '@untitledui/file-icons/dist/solid/html.mjs';\nimport { Pdf } from '@untitledui/file-icons/dist/solid/pdf.mjs';\nimport { Pptx } from '@untitledui/file-icons/dist/solid/pptx.mjs';\nimport { Txt } from '@untitledui/file-icons/dist/solid/txt.mjs';\nimport { useConfig } from '../../core/config/config-context';\nimport { useCanMutate } from '../../core/permissions';\nimport {\n Badge,\n Button,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n toast,\n} from '../../ui';\nimport {\n AlertDialog,\n AlertDialogAction,\n AlertDialogCancel,\n AlertDialogContent,\n AlertDialogDescription,\n AlertDialogFooter,\n AlertDialogHeader,\n AlertDialogTitle,\n} from '../../ui/primitives/alert-dialog';\nimport {\n createKnowledgeApi,\n isKnowledgeLinkKey,\n isKnowledgeListKey,\n KnowledgeApiError,\n knowledgePaths,\n type KnowledgeApi,\n} from './api';\nimport {\n getKnowledgeFormat,\n type KnowledgeFileIcon,\n type KnowledgeSource,\n type KnowledgeStatusTone,\n type RegisterKnowledgeSourceResult,\n} from './knowledge';\n\nconst STATUS_TONE_CLASSES: { [tone in KnowledgeStatusTone]: string } = {\n busy: 'fk:bg-amber-500/15 fk:text-amber-700 fk:dark:text-amber-400',\n error: 'fk:bg-destructive/15 fk:text-destructive',\n muted: 'fk:bg-muted fk:text-muted-foreground',\n ready: 'fk:bg-emerald-500/15 fk:text-emerald-700 fk:dark:text-emerald-400',\n};\n\nexport function useProjectKnowledge(): { api: KnowledgeApi | null; projectId: string | undefined } {\n const { currentProjectId } = useConfig();\n const api = useMemo(() => (currentProjectId ? createKnowledgeApi(currentProjectId) : null), [currentProjectId]);\n\n return { api, projectId: currentProjectId };\n}\n\n/** Drops every cached page of the document list, so the next visit fetches it afresh. */\nexport function invalidateKnowledgeLists(): Promise<unknown> {\n return mutateGlobal(isKnowledgeListKey, undefined, { revalidate: true });\n}\n\n/** Drops every cached link listing (a record's documents, a document's records) after a link changed. */\nexport function invalidateKnowledgeLinks(): Promise<unknown> {\n return mutateGlobal(isKnowledgeLinkKey, undefined, { revalidate: true });\n}\n\nexport function describeApiError(error: unknown, fallback: string): string {\n if (error instanceof KnowledgeApiError) {\n return error.message;\n }\n\n return error instanceof Error ? error.message : fallback;\n}\n\n/** What the user hears once a document was registered. */\nexport function announceRegistered(result: RegisterKnowledgeSourceResult, name: string): void {\n if (result.duplicate) {\n toast.info(`\"${result.source.title}\" is already in Knowledge.`);\n\n return;\n }\n\n toast.success(`Added ${name}. Indexing starts now.`);\n}\n\nexport function PageMessage({ children }: { children: string }): JSX.Element {\n return (\n <div className=\"fk:rounded-md fk:border fk:border-dashed fk:p-8 fk:text-center fk:text-sm fk:text-muted-foreground fk:corner-squircle\">\n {children}\n </div>\n );\n}\n\nexport function StatusBadge({ label, tone }: { label: string; tone: KnowledgeStatusTone }): JSX.Element {\n return (\n <Badge className={`fk:border-none fk:corner-squircle ${STATUS_TONE_CLASSES[tone]}`} variant=\"outline\">\n {tone === 'busy' ? <LoaderCircle className=\"fk:size-3 fk:animate-spin\" /> : null}\n {label}\n </Badge>\n );\n}\n\nconst FILE_ICONS: { [icon in KnowledgeFileIcon]: typeof Pdf } = {\n document: Document,\n docx: Docx,\n html: Html,\n pdf: Pdf,\n pptx: Pptx,\n txt: Txt,\n};\n\n/** The document's format as its file icon; the format's name is what a screen reader hears. */\nexport function KnowledgeTypeIcon({\n className = '',\n size = 24,\n source,\n}: {\n className?: string;\n size?: number;\n source: Pick<KnowledgeSource, 'kind' | 'mimeType'>;\n}): JSX.Element {\n const format = getKnowledgeFormat(source);\n const Icon = FILE_ICONS[format.icon];\n\n return (\n <span\n aria-label={format.label}\n className={`fk:flex fk:shrink-0 fk:items-center fk:justify-center ${className}`}\n data-knowledge-type={format.icon}\n role=\"img\"\n >\n <Icon size={size} />\n </span>\n );\n}\n\n/** The larger file icon of the document page and the record panel: the same icon as the list, at 40px. */\nexport function SourceIcon({ source }: { source: Pick<KnowledgeSource, 'kind' | 'mimeType'> }): JSX.Element {\n return <KnowledgeTypeIcon size={40} source={source} />;\n}\n\nexport function InfiniteScrollSentinel({ onVisible }: { onVisible: () => void }): JSX.Element {\n const sentinelRef = useRef<HTMLDivElement>(null);\n const onVisibleRef = useRef(onVisible);\n\n onVisibleRef.current = onVisible;\n\n useEffect(() => {\n const node = sentinelRef.current;\n\n if (!node) {\n return;\n }\n\n const observer = new IntersectionObserver((entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n onVisibleRef.current();\n }\n });\n\n observer.observe(node);\n\n return () => {\n observer.disconnect();\n };\n }, []);\n\n return <div aria-hidden className=\"fk:h-px\" ref={sentinelRef} />;\n}\n\n/**\n * The actions of one document, behind a three-dots button: open (lists\n * only), download the original file (web pages open their address instead)\n * and remove, behind one confirmation. The list and the document page share\n * it so the copy, the download link and the busy rules stay the same.\n */\nexport function SourceActionsMenu({\n isBusy = false,\n onOpen,\n onRemoved,\n source,\n trigger = 'row',\n}: {\n /** Another action on the document is in flight; removing waits for it. */\n isBusy?: boolean;\n /** Offered as the first item when given (the document page is already open). */\n onOpen?: () => void;\n /** The document is gone: drop it from the list, or leave its page. The list invalidation is done here. */\n onRemoved: () => void;\n source: KnowledgeSource;\n /** How the button looks: a quiet icon in a row or card, an outlined one next to page actions. */\n trigger?: 'row' | 'page';\n}): JSX.Element | null {\n const { api, projectId } = useProjectKnowledge();\n const canMutate = useCanMutate();\n const [isConfirmingRemoval, setIsConfirmingRemoval] = useState(false);\n const [isRemoving, setIsRemoving] = useState(false);\n\n if (!api || !projectId) {\n return null;\n }\n\n const knowledgeApi = api;\n\n async function remove(): Promise<void> {\n setIsRemoving(true);\n\n try {\n await knowledgeApi.deleteSource(source.id);\n toast.success(`Removed \"${source.title}\".`);\n setIsConfirmingRemoval(false);\n onRemoved();\n void invalidateKnowledgeLists();\n } catch (removeError) {\n toast.error(describeApiError(removeError, 'The document could not be removed.'));\n } finally {\n setIsRemoving(false);\n }\n }\n\n return (\n <>\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button\n aria-label={`Actions for ${source.title}`}\n className={trigger === 'row' ? 'fk:size-8 fk:shrink-0 fk:text-muted-foreground' : undefined}\n data-knowledge-menu\n size=\"icon-sm\"\n variant={trigger === 'row' ? 'ghost' : 'outline'}\n >\n <EllipsisVerticalIcon className=\"fk:size-4\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {onOpen ? <DropdownMenuItem onSelect={onOpen}>Open</DropdownMenuItem> : null}\n {source.path ? (\n <DropdownMenuItem asChild>\n <a href={knowledgePaths(projectId).file(source.id)}>\n <DownloadIcon />\n Download\n </a>\n </DropdownMenuItem>\n ) : null}\n {source.originUrl ? (\n <DropdownMenuItem asChild>\n <a href={source.originUrl} rel=\"noreferrer\" target=\"_blank\">\n <ExternalLinkIcon />\n Open page\n </a>\n </DropdownMenuItem>\n ) : null}\n {onOpen || source.path || source.originUrl ? <DropdownMenuSeparator /> : null}\n <DropdownMenuItem\n disabled={!canMutate || isBusy}\n variant=\"destructive\"\n onSelect={() => setIsConfirmingRemoval(true)}\n >\n <Trash2Icon />\n Remove\n </DropdownMenuItem>\n {canMutate ? null : (\n <DropdownMenuLabel className=\"fk:max-w-56 fk:whitespace-normal fk:text-xs fk:font-normal fk:text-muted-foreground\">\n Your member role cannot remove documents.\n </DropdownMenuLabel>\n )}\n </DropdownMenuContent>\n </DropdownMenu>\n <AlertDialog open={isConfirmingRemoval} onOpenChange={setIsConfirmingRemoval}>\n <AlertDialogContent>\n <AlertDialogHeader>\n <AlertDialogTitle>Remove this document?</AlertDialogTitle>\n <AlertDialogDescription>\n \"{source.title}\" and its indexed passages are deleted for everyone. Answers the agent gave earlier keep\n their citations, but the document can no longer be opened.\n </AlertDialogDescription>\n </AlertDialogHeader>\n <AlertDialogFooter>\n <AlertDialogCancel disabled={isRemoving}>Cancel</AlertDialogCancel>\n <AlertDialogAction\n disabled={isRemoving}\n onClick={(event: MouseEvent) => {\n event.preventDefault();\n void remove();\n }}\n >\n {isRemoving ? <LoaderCircle className=\"fk:animate-spin\" /> : null}\n Remove document\n </AlertDialogAction>\n </AlertDialogFooter>\n </AlertDialogContent>\n </AlertDialog>\n </>\n );\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import'./index.css';import {a,d}from'./chunk-U6E7GNQW.js';import {f,d as d$2}from'./chunk-MNLYE7DK.js';import {f as f$1}from'./chunk-NSVX6HEN.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 as d$1,a as a$1,b as b$3,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$2(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$1,{children:b.slice(0,9).map(c=>jsxs(a$1,{className:"fk:rounded-md",children:[jsx(b$3,{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 tn(){return jsx(he,{})}function an(){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 on(){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$3=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(()=>d(a$1,l,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$3?jsxs("a",{href:b$3,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(()=>d(a$1,l,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(()=>d(a$1,l,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,tn as c,an as d,on as e};//# sourceMappingURL=chunk-I6Z3WLAX.js.map
2
+ //# sourceMappingURL=chunk-I6Z3WLAX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/apps/ai/plugin-pages.tsx"],"names":["httpsCatalogUrl","value","url","useMarketplaceApi","currentProjectId","useConfig","useMemo","createApiClient","scopeLabel","scopes","scopeColorClassname","isConnected","plugin","scopeTitle","scope","scopePermitted","canManage","scopeConnections","connection","left","right","primaryToolConnection","primaries","PluginConnectControl","busy","onConnect","pendingScopes","jsxs","Button","jsx","Plug","anyPermitted","item","DropdownMenu","DropdownMenuTrigger","DropdownMenuContent","DropdownMenuGroup","DropdownMenuItem","aiSectionPath","pathname","section","match","categoryLabel","category","word","groupPlugins","plugins","groups","existing","items","PLUGIN_SKELETON_SECTIONS","CatalogRowSkeleton","action","row","Skeleton","pluginGridClassName","PluginListSkeleton","grouped","rows","CatalogHeader","navigate","useNavigate","useLocation","onPlugins","onSkills","Tooltip","TooltipTrigger","SidebarTrigger","TooltipContent","Tabs","next","destination","TabsList","TabsTrigger","PluginRow","onOpen","connected","needsReconnect","reconnectLabel","TriangleAlert","CheckIcon","Plus","PluginRows","PluginCatalog","installedOnly","base","data","error","isLoading","useSWR","fetcher","search","setSearch","useState","query","connectedPlugins","emptyMessage","openPlugin","pluginId","list","group","ScrollArea","Input","event","id","AvatarGroup","Avatar","AvatarImage","AvatarFallback","Link","ChevronLeft","ChevronRight","Alert","AlertDescription","PluginsPage","InstalledPluginsPage","ConnectionTools","connectionId","server","Collapsible","CollapsibleTrigger","toolCountLabel","CollapsibleContent","tool","count","connectionSecondaryLine","ConnectionRow","actionable","actions","pluginEnabled","editing","setEditing","draft","setDraft","inputRef","useRef","needsAuth","saveRename","label","useEffect","timer","XIcon","Badge","MoreHorizontal","DropdownMenuSeparator","ConnectedAccounts","connections","permitted","PluginDetailPage","useParams","api","mutate","revalidateKey","useSWRConfig","setBusy","sourceUrl","perform","failure","PluginAccountMismatchError","toast","ArrowLeft","toolConnection","connectionActions","connectPlugin","ExternalLink","RefreshCw","Fragment","skill","automation"],"mappings":"6wBA2DA,SAASA,EAAAA,CAAgBC,EAA8B,CACrD,IAAIC,EAEJ,GAAI,CACFA,EAAM,IAAI,GAAA,CAAID,CAAK,EACrB,CAAA,KAAQ,CACN,OAAO,IACT,CAEA,OAAIC,CAAAA,CAAI,WAAa,QAAA,EAAYA,CAAAA,CAAI,WAAa,EAAA,EAAMA,CAAAA,CAAI,WAAa,EAAA,CAChE,IAAA,CAGFA,EAAI,IACb,CAEA,SAASC,EAAAA,EAAoB,CAC3B,GAAM,CAAE,iBAAAC,CAAiB,CAAA,CAAIC,KAAU,CAGvC,OAAO,CAAE,GAAA,CAFGC,OAAAA,CAAQ,IAAOF,CAAAA,CAAmBG,GAAAA,CAAgBH,CAAgB,CAAA,CAAI,IAAA,CAAO,CAACA,CAAgB,CAAC,EAE7F,IAAA,CAAMA,CAAAA,CAAmB,gBAAgBA,CAAgB,CAAA,CAAA,CAAK,IAAK,CACnF,CAEA,SAASI,EAAAA,CAAWC,CAAAA,CAA+B,CACjD,OAAIA,CAAAA,CAAO,SAAW,CAAA,CACb,oBAAA,CAGFA,EAAO,CAAC,CAAA,GAAM,UAAY,SAAA,CAAY,UAC/C,CAEA,SAASC,EAAAA,CAAoBD,CAAAA,CAA+B,CAC1D,OAAIA,CAAAA,CAAO,MAAA,GAAW,EACb,mFAAA,CAGFA,CAAAA,CAAO,CAAC,CAAA,GAAM,SAAA,CACjB,wEACA,2EACN,CAEA,SAASE,CAAAA,CAAYC,CAAAA,CAAoC,CACvD,OAAOA,CAAAA,CAAO,YAAY,MAAA,CAAS,CACrC,CAEA,SAASC,EAAAA,CAAWC,EAA4B,CAC9C,OAAIA,IAAU,SAAA,CACL,SAAA,CAGF,UACT,CAEA,SAASC,EAAeH,CAAAA,CAA2BI,CAAAA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CAAA,CAPOA,CAAAA,CAAW,EAQpB,CACD,CAAA,CACH,GAEJ,CAAA,CAAA,CACF,CAAA,CACA,GACF,CAEJ","file":"chunk-I6Z3WLAX.js","sourcesContent":["import { useEffect, useMemo, useRef, useState, type JSX } from 'react';\nimport { Link, useLocation, useNavigate, useParams } from 'react-router-dom';\nimport useSWR, { useSWRConfig } from 'swr';\nimport { useConfig } from '../../core/config/config-context';\nimport {\n Alert,\n AlertDescription,\n Avatar,\n AvatarFallback,\n AvatarGroup,\n AvatarImage,\n Badge,\n Button,\n Collapsible,\n CollapsibleContent,\n CollapsibleTrigger,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuItem,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n Input,\n ScrollArea,\n SidebarTrigger,\n Skeleton,\n Tabs,\n TabsList,\n TabsTrigger,\n toast,\n Tooltip,\n TooltipContent,\n TooltipTrigger\n} from '../../ui';\nimport {\n ArrowLeft,\n CheckIcon,\n ChevronLeft,\n ChevronRight,\n ExternalLink,\n MoreHorizontal,\n Plug,\n Plus,\n RefreshCw,\n TriangleAlert,\n XIcon,\n} from 'lucide-react';\nimport { createApiClient, fetcher } from './api';\nimport { PluginAccountMismatchError } from './plugin-oauth';\nimport { connectPlugin } from './plugin-token';\nimport type {\n Marketplace,\n MarketplacePlugin,\n PluginConnection,\n PluginDetail,\n PluginScope,\n PluginTools,\n} from './plugin-types';\n\nfunction httpsCatalogUrl(value: string): string | null {\n let url: URL;\n\n try {\n url = new URL(value);\n } catch {\n return null;\n }\n\n if (url.protocol !== 'https:' || url.username !== '' || url.password !== '') {\n return null;\n }\n\n return url.href;\n}\n\nfunction useMarketplaceApi() {\n const { currentProjectId } = useConfig();\n const api = useMemo(() => (currentProjectId ? createApiClient(currentProjectId) : null), [currentProjectId]);\n\n return { api, base: currentProjectId ? `/api/flexkit/${currentProjectId}` : null };\n}\n\nfunction scopeLabel(scopes: PluginScope[]): string {\n if (scopes.length === 2) {\n return 'Project & Personal';\n }\n\n return scopes[0] === 'project' ? 'Project' : 'Personal';\n}\n\nfunction scopeColorClassname(scopes: PluginScope[]): string {\n if (scopes.length === 2) {\n return 'fk:bg-indigo-100 fk:text-indigo-800 fk:dark:bg-indigo-950 fk:dark:text-indigo-300';\n }\n\n return scopes[0] === 'project'\n ? 'fk:bg-sky-100 fk:text-sky-800 fk:dark:bg-sky-950 fk:dark:text-sky-300'\n : 'fk:bg-teal-100 fk:text-teal-800 fk:dark:bg-teal-950 fk:dark:text-teal-300';\n}\n\nfunction isConnected(plugin: MarketplacePlugin): boolean {\n return plugin.connections.length > 0;\n}\n\nfunction scopeTitle(scope: PluginScope): string {\n if (scope === 'project') {\n return 'Project';\n }\n\n return 'Personal';\n}\n\nfunction scopePermitted(plugin: MarketplacePlugin, canManage: boolean, scope: PluginScope): boolean {\n if (scope === 'personal') {\n return plugin.allowPersonal;\n }\n\n return canManage;\n}\n\nfunction scopeConnections(plugin: MarketplacePlugin, scope: PluginScope): PluginConnection[] {\n return plugin.connections\n .filter((connection) => connection.scope === scope)\n .sort((left, right) => Number(right.isPrimary) - Number(left.isPrimary) || left.createdAt.localeCompare(right.createdAt));\n}\n\n/** Mirrors chat: the personal primary account wins over the project primary. */\nfunction primaryToolConnection(plugin: MarketplacePlugin): PluginConnection | null {\n const primaries = plugin.connections.filter((connection) => connection.isPrimary && connection.status === 'connected');\n\n return primaries.find((connection) => connection.scope === 'personal') ?? primaries.find((connection) => connection.scope === 'project') ?? null;\n}\n\n/** Connect button; asks for the scope when the plugin supports both project and personal accounts. */\nexport function PluginConnectControl({\n busy,\n canManage,\n plugin,\n onConnect\n}: {\n busy: boolean;\n canManage: boolean;\n plugin: MarketplacePlugin;\n onConnect: (scope: PluginScope) => void;\n}): JSX.Element | null {\n const pendingScopes = plugin.scopes.filter((scope) => scopeConnections(plugin, scope).length === 0);\n const [scope] = pendingScopes;\n\n if (!scope) {\n return null;\n }\n\n if (plugin.scopes.length === 1) {\n return (\n <Button\n disabled={busy || !plugin.enabled || !scopePermitted(plugin, canManage, scope)}\n size=\"sm\"\n type=\"button\"\n onClick={() => onConnect(scope)}\n >\n <Plug />\n Connect\n </Button>\n );\n }\n\n const anyPermitted = pendingScopes.some((item) => scopePermitted(plugin, canManage, item));\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button disabled={busy || !plugin.enabled || !anyPermitted} size=\"sm\" type=\"button\">\n <Plug />\n Connect\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"fk:w-72\">\n <DropdownMenuGroup>\n {pendingScopes.map((item) => (\n <DropdownMenuItem\n disabled={!scopePermitted(plugin, canManage, item)}\n key={item}\n onSelect={() => onConnect(item)}\n >\n <span className=\"fk:flex fk:flex-col fk:gap-0.5\">\n <span>{scopeTitle(item)}</span>\n <span className=\"fk:text-xs fk:text-muted-foreground\">\n {item === 'personal'\n ? 'Only you can use this connection in this project.'\n : 'Shared with project members who can use this plugin.'}\n </span>\n </span>\n </DropdownMenuItem>\n ))}\n </DropdownMenuGroup>\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\nfunction aiSectionPath(pathname: string, section: string): string {\n const match = /^(.*\\/ai)(?:\\/|$)/.exec(pathname);\n\n if (!match) {\n return section;\n }\n\n return `${match[1]}/${section}`;\n}\n\nfunction categoryLabel(category: string): string {\n return category\n .split(/[\\s_-]+/)\n .filter(Boolean)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join(' ');\n}\n\nfunction groupPlugins(plugins: MarketplacePlugin[]): Array<{ category: string; plugins: MarketplacePlugin[] }> {\n const groups: { [category: string]: MarketplacePlugin[] } = {};\n\n for (const plugin of plugins) {\n const existing = groups[plugin.category];\n\n if (existing) {\n existing.push(plugin);\n\n continue;\n }\n\n groups[plugin.category] = [plugin];\n }\n\n return Object.entries(groups)\n .sort(([left], [right]) => categoryLabel(left).localeCompare(categoryLabel(right)))\n .map(([category, items]) => ({ category, plugins: items }));\n}\n\ninterface CatalogSkeletonRow {\n descriptionWidth: string;\n id: string;\n nameWidth: string;\n}\n\nconst PLUGIN_SKELETON_SECTIONS: { id: string; rows: CatalogSkeletonRow[] }[] = [\n {\n id: 'first',\n rows: [\n { descriptionWidth: 'fk:w-44', id: 'first-a', nameWidth: 'fk:w-24' },\n { descriptionWidth: 'fk:w-52', id: 'first-b', nameWidth: 'fk:w-16' },\n { descriptionWidth: 'fk:w-40', id: 'first-c', nameWidth: 'fk:w-28' },\n { descriptionWidth: 'fk:w-48', id: 'first-d', nameWidth: 'fk:w-20' },\n ],\n },\n {\n id: 'second',\n rows: [\n { descriptionWidth: 'fk:w-36', id: 'second-a', nameWidth: 'fk:w-32' },\n { descriptionWidth: 'fk:w-56', id: 'second-b', nameWidth: 'fk:w-24' },\n ],\n },\n];\n\nfunction CatalogRowSkeleton({ action, row }: { action?: boolean; row: CatalogSkeletonRow }): JSX.Element {\n return (\n <div className=\"fk:-mx-3 fk:flex fk:min-w-0 fk:items-center fk:gap-3 fk:px-3 fk:py-2\">\n <Skeleton className=\"fk:size-10 fk:shrink-0 fk:rounded-lg\" />\n <span className=\"fk:flex fk:min-w-0 fk:flex-1 fk:flex-col fk:gap-1.5\">\n <Skeleton className={`fk:h-4 ${row.nameWidth}`} />\n <Skeleton className={`fk:h-4 ${row.descriptionWidth}`} />\n </span>\n {action ? <Skeleton className=\"fk:size-4 fk:shrink-0\" /> : null}\n </div>\n );\n}\n\nconst pluginGridClassName = 'fk:grid fk:grid-cols-1 fk:gap-x-16 fk:gap-y-1 fk:lg:grid-cols-2';\n\nfunction PluginListSkeleton({ grouped = true }: { grouped?: boolean }): JSX.Element {\n const rows = PLUGIN_SKELETON_SECTIONS.flatMap((section) => section.rows);\n\n if (!grouped) {\n return (\n <div aria-busy=\"true\" className={pluginGridClassName}>\n <span className=\"fk:sr-only\">Loading plugins</span>\n {rows.map((row) => (\n <CatalogRowSkeleton action key={row.id} row={row} />\n ))}\n </div>\n );\n }\n\n return (\n <div aria-busy=\"true\" className=\"fk:flex fk:flex-col fk:gap-8\">\n <span className=\"fk:sr-only\">Loading plugins</span>\n {PLUGIN_SKELETON_SECTIONS.map((section) => (\n <section key={section.id}>\n <Skeleton className=\"fk:mb-1 fk:h-4 fk:w-28\" />\n <div className={pluginGridClassName}>\n {section.rows.map((row) => (\n <CatalogRowSkeleton action key={row.id} row={row} />\n ))}\n </div>\n </section>\n ))}\n </div>\n );\n}\n\nexport function CatalogHeader(): JSX.Element {\n const navigate = useNavigate();\n const { pathname } = useLocation();\n const onPlugins = /\\/ai\\/plugins\\/?$/.test(pathname);\n const onSkills = pathname.includes('/ai/skills');\n const value = onSkills ? 'skills' : 'plugins';\n\n return (\n <div className=\"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2\">\n <Tooltip>\n <TooltipTrigger asChild>\n <SidebarTrigger className=\"fk:-ml-1 fk:h-4 fk:w-4\" />\n </TooltipTrigger>\n <TooltipContent>Toggle Sidebar</TooltipContent>\n </Tooltip>\n <Tabs\n value={value}\n onValueChange={(next) => {\n const destination = next === 'skills' ? 'skills' : 'plugins';\n const alreadyThere = next === 'skills' ? onSkills : onPlugins;\n\n if (alreadyThere) {\n return;\n }\n\n navigate(aiSectionPath(pathname, destination));\n }}\n >\n <TabsList>\n <TabsTrigger\n value=\"plugins\"\n onClick={() => {\n if (onPlugins) {\n return;\n }\n\n navigate(aiSectionPath(pathname, 'plugins'));\n }}\n >\n Plugins\n </TabsTrigger>\n <TabsTrigger value=\"skills\">Skills</TabsTrigger>\n </TabsList>\n </Tabs>\n </div>\n );\n}\n\nfunction PluginRow({ onOpen, plugin }: { onOpen: () => void; plugin: MarketplacePlugin }): JSX.Element {\n const connected = isConnected(plugin);\n const needsReconnect = plugin.connections.filter((connection) => connection.status === 'needs_auth').length;\n const reconnectLabel =\n needsReconnect === 1 ? 'An account needs to be reconnected' : `${needsReconnect.toString()} accounts need to be reconnected`;\n\n return (\n <button\n type=\"button\"\n onClick={onOpen}\n className=\"fk:-mx-3 fk:flex fk:min-w-0 fk:items-center fk:gap-3 fk:rounded-lg fk:px-3 fk:py-2 fk:text-left fk:transition-colors fk:hover:bg-accent fk:focus-visible:bg-accent fk:focus-visible:outline-none fk:corner-squircle\"\n >\n <img src={plugin.logoUrl} alt=\"\" className=\"fk:size-10 fk:shrink-0 fk:rounded-lg fk:corner-squircle\" />\n <span className=\"fk:min-w-0 fk:flex-1\">\n <span className=\"fk:block fk:truncate fk:text-sm fk:font-medium\">{plugin.name}</span>\n <span className=\"fk:block fk:truncate fk:text-sm fk:text-muted-foreground\">{plugin.description}</span>\n </span>\n {needsReconnect > 0 ? (\n <Tooltip>\n <TooltipTrigger asChild>\n <span className=\"fk:flex fk:shrink-0\">\n <TriangleAlert aria-hidden className=\"fk:size-4 fk:text-destructive\" />\n <span className=\"fk:sr-only\">{reconnectLabel}</span>\n </span>\n </TooltipTrigger>\n <TooltipContent>{reconnectLabel}</TooltipContent>\n </Tooltip>\n ) : connected ? (\n <CheckIcon className=\"fk:size-4 fk:shrink-0 fk:text-success\" />\n ) : (\n <Plus className=\"fk:size-4 fk:shrink-0 fk:text-muted-foreground\" />\n )}\n </button>\n );\n}\n\nfunction PluginRows({\n onOpen,\n plugins,\n}: {\n onOpen: (_pluginId: string) => void;\n plugins: MarketplacePlugin[];\n}): JSX.Element {\n return (\n <div className={pluginGridClassName}>\n {plugins.map((plugin) => (\n <PluginRow key={plugin.id} plugin={plugin} onOpen={() => onOpen(plugin.id)} />\n ))}\n </div>\n );\n}\n\nfunction PluginCatalog({ installedOnly = false }: { installedOnly?: boolean }): JSX.Element {\n const { base } = useMarketplaceApi();\n const { data, error, isLoading } = useSWR<Marketplace>(base ? `${base}/plugins` : null, fetcher);\n const [search, setSearch] = useState('');\n const navigate = useNavigate();\n const { pathname } = useLocation();\n const query = search.trim().toLowerCase();\n const plugins = (data?.plugins ?? []).filter((plugin) => {\n const matchesInstall = !installedOnly || isConnected(plugin);\n\n return matchesInstall && `${plugin.name} ${plugin.description}`.toLowerCase().includes(query);\n });\n const connectedPlugins = (data?.plugins ?? []).filter(isConnected);\n const groups = installedOnly ? [] : groupPlugins(plugins);\n let emptyMessage = 'Plugins are being prepared. Check back soon.';\n\n if (installedOnly && !query) {\n emptyMessage = 'No plugins installed yet.';\n } else if (data?.catalogSha || installedOnly) {\n emptyMessage = 'No plugins match your search.';\n }\n\n function openPlugin(pluginId: string): void {\n navigate(aiSectionPath(pathname, `plugins/${pluginId}`));\n }\n\n let list: JSX.Element | null = (\n <div className=\"fk:flex fk:flex-col fk:gap-8\">\n {groups.map((group) => (\n <section key={group.category}>\n <h3 className=\"fk:mb-1 fk:text-sm fk:font-medium\">{categoryLabel(group.category)}</h3>\n <PluginRows plugins={group.plugins} onOpen={openPlugin} />\n </section>\n ))}\n </div>\n );\n\n if (installedOnly) {\n list = <PluginRows plugins={plugins} onOpen={openPlugin} />;\n }\n\n if (isLoading || error || plugins.length === 0) {\n list = null;\n }\n\n return (\n <main className=\"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col\">\n <CatalogHeader />\n <ScrollArea className=\"fk:h-0 fk:min-h-0 fk:flex-1\">\n <div className=\"fk:mx-auto fk:flex fk:w-full fk:max-w-4xl fk:flex-col fk:gap-8 fk:py-6 fk:pl-4 fk:pr-6\">\n <div>\n <h2 className=\"fk:text-2xl fk:font-semibold\">Plugins</h2>\n <p className=\"fk:mt-2 fk:text-muted-foreground\">\n Connect the tools you use and add skills to your workflows.\n </p>\n </div>\n <div className=\"fk:flex fk:flex-wrap fk:items-center fk:gap-3\">\n <Input\n aria-label=\"Search plugins\"\n className=\"fk:mr-auto fk:w-full fk:max-w-xs\"\n placeholder=\"Search plugins…\"\n value={search}\n onChange={(event) => setSearch(event.target.value)}\n />\n {!installedOnly && isLoading ? (\n <div className=\"fk:flex fk:items-center fk:gap-3\">\n <div className=\"fk:flex fk:-space-x-2\">\n {['installed-a', 'installed-b', 'installed-c'].map((id) => (\n <Skeleton className=\"fk:size-8 fk:rounded-md fk:ring-2 fk:ring-background\" key={id} />\n ))}\n </div>\n <Skeleton className=\"fk:h-4 fk:w-20\" />\n </div>\n ) : null}\n {!installedOnly && !isLoading && connectedPlugins.length > 0 ? (\n <AvatarGroup>\n {connectedPlugins.slice(0, 9).map((plugin) => (\n <Avatar className=\"fk:rounded-md\" key={plugin.id}>\n <AvatarImage src={plugin.logoUrl} alt=\"\" />\n <AvatarFallback>{plugin.name.charAt(0)}</AvatarFallback>\n </Avatar>\n ))}\n </AvatarGroup>\n ) : null}\n {installedOnly ? (\n <Link\n to={aiSectionPath(pathname, 'plugins')}\n className=\"fk:inline-flex fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground fk:hover:text-foreground\"\n >\n <ChevronLeft className=\"fk:size-4\" />\n Show all\n </Link>\n ) : null}\n {!installedOnly && !isLoading ? (\n <Link\n to={aiSectionPath(pathname, 'plugins/installed')}\n className=\"fk:inline-flex fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground fk:hover:text-foreground\"\n >\n {connectedPlugins.length} installed\n <ChevronRight className=\"fk:size-4\" />\n </Link>\n ) : null}\n </div>\n {error ? (\n <Alert variant=\"destructive\">\n <AlertDescription>Unable to load plugins. Please try again.</AlertDescription>\n </Alert>\n ) : null}\n {isLoading ? <PluginListSkeleton grouped={!installedOnly} /> : null}\n {!isLoading && !error && plugins.length === 0 ? (\n <Alert>\n <AlertDescription>{emptyMessage}</AlertDescription>\n </Alert>\n ) : null}\n {list}\n </div>\n </ScrollArea>\n </main>\n );\n}\n\nexport function PluginsPage(): JSX.Element {\n return <PluginCatalog />;\n}\n\nexport function InstalledPluginsPage(): JSX.Element {\n return <PluginCatalog installedOnly />;\n}\n\nfunction ConnectionTools({ base, connectionId }: { base: string; connectionId: string }): JSX.Element {\n const { data, error } = useSWR<PluginTools>(`${base}/plugin-connections/${connectionId}/tools`, fetcher);\n\n if (error) {\n return <p className=\"fk:text-sm fk:text-muted-foreground\">Unable to discover tools. Reconnect or try again.</p>;\n }\n\n if (!data) {\n return <Skeleton className=\"fk:h-12 fk:w-full\" />;\n }\n\n return (\n <div className=\"fk:flex fk:flex-col fk:gap-3\">\n {data.servers.map((server) => (\n <section className=\"fk:flex fk:flex-col fk:gap-2\" key={server.name}>\n <h4 className=\"fk:font-medium\">{server.name}</h4>\n {server.error ? <p>{server.error}</p> : null}\n {server.tools.length > 0 ? (\n <Collapsible className=\"fk:group\">\n <CollapsibleTrigger className=\"fk:flex fk:w-fit fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground\">\n <ChevronRight className=\"fk:size-4 fk:transition-transform fk:group-data-[state=open]:rotate-90\" />\n {toolCountLabel(server.tools.length)}\n </CollapsibleTrigger>\n <CollapsibleContent>\n <ul className=\"fk:mt-2 fk:flex fk:flex-col fk:gap-2\">\n {server.tools.map((tool) => (\n <li key={tool.name}>\n <span className=\"fk:text-sm fk:font-medium\">{tool.name}</span>\n <p className=\"fk:text-sm fk:text-muted-foreground\">{tool.description}</p>\n </li>\n ))}\n </ul>\n </CollapsibleContent>\n </Collapsible>\n ) : null}\n </section>\n ))}\n </div>\n );\n}\n\nfunction toolCountLabel(count: number): string {\n if (count === 1) {\n return '1 tool';\n }\n\n return `${count.toString()} tools`;\n}\n\ninterface ConnectionActions {\n onDisconnect: (_connection: PluginConnection) => void;\n onMakePrimary: (_connection: PluginConnection) => void;\n onReconnect: (_connection: PluginConnection) => void;\n onRename: (_connection: PluginConnection, _label: string | null) => Promise<void>;\n}\n\nfunction connectionSecondaryLine(connection: PluginConnection): string {\n if (connection.accountName && connection.accountName !== connection.displayName) {\n return connection.accountName;\n }\n\n return connection.scope === 'project' ? 'Shared with this project' : 'Only you can use this account';\n}\n\nfunction ConnectionRow({\n actionable,\n actions,\n busy,\n connection,\n pluginEnabled,\n}: {\n actionable: boolean;\n actions: ConnectionActions;\n busy: boolean;\n connection: PluginConnection;\n pluginEnabled: boolean;\n}): JSX.Element {\n const [editing, setEditing] = useState(false);\n const [draft, setDraft] = useState('');\n const inputRef = useRef<HTMLInputElement | null>(null);\n const needsAuth = connection.status === 'needs_auth';\n const saveRename = async () => {\n const label = draft.trim();\n\n await actions.onRename(connection, label ? label : null);\n setEditing(false);\n };\n\n // The menu restores focus to its trigger as it closes; focus the field afterwards.\n useEffect(() => {\n if (!editing) {\n return;\n }\n\n const timer = window.setTimeout(() => inputRef.current?.focus(), 0);\n\n return () => window.clearTimeout(timer);\n }, [editing]);\n\n return (\n <li className=\"fk:flex fk:min-w-0 fk:items-center fk:gap-3 fk:py-2\">\n <Avatar className=\"fk:size-8\">\n <AvatarFallback>{connection.displayName.charAt(0).toUpperCase()}</AvatarFallback>\n </Avatar>\n {editing ? (\n <form\n className=\"fk:flex fk:min-w-0 fk:flex-1 fk:items-center fk:gap-2\"\n onSubmit={(event) => {\n event.preventDefault();\n void saveRename();\n }}\n >\n <Input\n aria-label=\"Account name\"\n ref={inputRef}\n className=\"fk:h-8 fk:max-w-xs\"\n disabled={busy}\n placeholder={connection.accountName ?? 'Account name'}\n value={draft}\n onChange={(event) => setDraft(event.target.value)}\n onKeyDown={(event) => {\n if (event.key === 'Escape') {\n setEditing(false);\n }\n }}\n />\n <Button aria-label=\"Save name\" disabled={busy} size=\"icon\" type=\"submit\" variant=\"ghost\">\n <CheckIcon />\n </Button>\n <Button aria-label=\"Cancel rename\" size=\"icon\" type=\"button\" variant=\"ghost\" onClick={() => setEditing(false)}>\n <XIcon />\n </Button>\n </form>\n ) : (\n <span className=\"fk:flex fk:min-w-0 fk:flex-1 fk:flex-col\">\n <span className=\"fk:flex fk:min-w-0 fk:items-center fk:gap-2\">\n <span className=\"fk:truncate fk:text-sm fk:font-medium\">{connection.displayName}</span>\n {connection.isPrimary ? <Badge variant=\"secondary\">Primary</Badge> : null}\n {needsAuth ? <Badge variant=\"destructive\">Needs reconnect</Badge> : null}\n </span>\n <span className=\"fk:truncate fk:text-sm fk:text-muted-foreground\">{connectionSecondaryLine(connection)}</span>\n </span>\n )}\n {actionable && !editing ? (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button aria-label={`Manage ${connection.displayName}`} disabled={busy} size=\"icon\" variant=\"ghost\">\n <MoreHorizontal />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n <DropdownMenuGroup>\n {!connection.isPrimary && !needsAuth ? (\n <DropdownMenuItem onSelect={() => actions.onMakePrimary(connection)}>Make primary</DropdownMenuItem>\n ) : null}\n <DropdownMenuItem\n onSelect={() => {\n setDraft(connection.label ?? '');\n setEditing(true);\n }}\n >\n Rename\n </DropdownMenuItem>\n <DropdownMenuItem disabled={!pluginEnabled} onSelect={() => actions.onReconnect(connection)}>\n Reconnect\n </DropdownMenuItem>\n </DropdownMenuGroup>\n <DropdownMenuSeparator />\n <DropdownMenuItem variant=\"destructive\" onSelect={() => actions.onDisconnect(connection)}>\n Disconnect\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n ) : null}\n </li>\n );\n}\n\nfunction ConnectedAccounts({\n actions,\n busy,\n canManage,\n onConnect,\n plugin,\n}: {\n actions: ConnectionActions;\n busy: boolean;\n canManage: boolean;\n onConnect: (_scope: PluginScope) => void;\n plugin: MarketplacePlugin;\n}): JSX.Element {\n const grouped = plugin.scopes.length > 1;\n\n return (\n <section className=\"fk:flex fk:flex-col fk:gap-3\">\n <h2 className=\"fk:text-xl fk:font-semibold\">Connected accounts</h2>\n {plugin.scopes.map((scope) => {\n const connections = scopeConnections(plugin, scope);\n const permitted = scopePermitted(plugin, canManage, scope);\n // Personal rows are only ever returned for the current user.\n const actionable = scope === 'personal' || canManage;\n\n if (connections.length === 0 && !permitted) {\n return null;\n }\n\n return (\n <div className=\"fk:flex fk:flex-col\" key={scope}>\n {grouped ? (\n <h3 className=\"fk:text-sm fk:font-medium fk:text-muted-foreground\">\n {scope === 'project' ? 'Project accounts' : 'Your accounts'}\n </h3>\n ) : null}\n <ul className=\"fk:flex fk:flex-col fk:divide-y\">\n {connections.map((connection) => (\n <ConnectionRow\n actionable={actionable}\n actions={actions}\n busy={busy}\n connection={connection}\n key={connection.id}\n pluginEnabled={plugin.enabled}\n />\n ))}\n {permitted ? (\n <li>\n <button\n className=\"fk:flex fk:w-full fk:items-center fk:gap-3 fk:py-2 fk:text-left fk:text-sm fk:text-muted-foreground fk:transition-colors fk:hover:text-foreground fk:disabled:pointer-events-none fk:disabled:opacity-50\"\n disabled={busy || !plugin.enabled}\n type=\"button\"\n onClick={() => onConnect(scope)}\n >\n <span className=\"fk:flex fk:size-8 fk:shrink-0 fk:items-center fk:justify-center fk:rounded-full fk:border fk:border-dashed\">\n <Plus className=\"fk:size-4\" />\n </span>\n {connections.length > 0 ? 'Connect another account' : 'Connect an account'}\n </button>\n </li>\n ) : null}\n </ul>\n </div>\n );\n })}\n </section>\n );\n}\n\nexport function PluginDetailPage(): JSX.Element {\n const { pluginId } = useParams<{ pluginId: string }>();\n const { api, base } = useMarketplaceApi();\n const { data, error, mutate } = useSWR<PluginDetail>(\n base && pluginId ? `${base}/plugins/${pluginId}` : null,\n fetcher\n );\n const { mutate: revalidateKey } = useSWRConfig();\n const navigate = useNavigate();\n const [busy, setBusy] = useState(false);\n const plugin = data?.plugin;\n const sourceUrl = plugin ? httpsCatalogUrl(plugin.sourceUrl) : null;\n const perform = async (action: () => Promise<unknown>) => {\n setBusy(true);\n\n try {\n await action();\n await mutate();\n } catch (failure) {\n if (failure instanceof PluginAccountMismatchError) {\n toast.error('You signed in with a different account. Use \"Connect another account\" to add it.');\n\n return;\n }\n\n toast.error(failure instanceof Error ? failure.message : 'Unable to complete this action.');\n } finally {\n setBusy(false);\n }\n };\n\n if (error) {\n return (\n <div className=\"fk:p-6\">\n <Alert variant=\"destructive\">\n <AlertDescription>Unable to load this plugin.</AlertDescription>\n </Alert>\n </div>\n );\n }\n\n if (!plugin || !data || !api || !base) {\n return (\n <main className=\"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col\">\n <div className=\"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2\">\n <Tooltip>\n <TooltipTrigger asChild>\n <SidebarTrigger className=\"fk:-ml-1 fk:h-4 fk:w-4\" />\n </TooltipTrigger>\n <TooltipContent>Toggle Sidebar</TooltipContent>\n </Tooltip>\n <Button variant=\"ghost\" size=\"sm\" onClick={() => navigate('..', { relative: 'path' })}>\n <ArrowLeft />\n Plugins\n </Button>\n </div>\n <ScrollArea className=\"fk:h-0 fk:min-h-0 fk:flex-1\">\n <div aria-busy=\"true\" className=\"fk:mx-auto fk:flex fk:w-full fk:max-w-4xl fk:flex-col fk:gap-8 fk:py-6 fk:pl-4 fk:pr-6\">\n <span className=\"fk:sr-only\">Loading plugin</span>\n <section className=\"fk:flex fk:flex-col fk:gap-3\">\n <div className=\"fk:flex fk:items-center fk:gap-4\">\n <Skeleton className=\"fk:size-14 fk:shrink-0 fk:rounded-lg\" />\n <Skeleton className=\"fk:h-7 fk:w-40\" />\n <Skeleton className=\"fk:ml-auto fk:h-9 fk:w-28\" />\n </div>\n <Skeleton className=\"fk:h-4 fk:w-full\" />\n <Skeleton className=\"fk:h-4 fk:w-2/3\" />\n <Skeleton className=\"fk:h-6 fk:w-24 fk:rounded-full\" />\n </section>\n </div>\n </ScrollArea>\n </main>\n );\n }\n\n const toolConnection = primaryToolConnection(plugin);\n const connectionActions: ConnectionActions = {\n onDisconnect: (connection) => void perform(() => api.disconnectPlugin(connection.id)),\n onMakePrimary: (connection) => void perform(() => api.updatePluginConnection(connection.id, { primary: true })),\n onReconnect: (connection) =>\n void perform(() => connectPlugin(api, plugin, connection.scope, { connectionId: connection.id })),\n onRename: (connection, label) => perform(() => api.updatePluginConnection(connection.id, { label })),\n };\n\n return (\n <main className=\"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col\">\n <div className=\"fk:mb-2 fk:flex fk:shrink-0 fk:items-center fk:gap-2\">\n <Tooltip>\n <TooltipTrigger asChild>\n <SidebarTrigger className=\"fk:-ml-1 fk:h-4 fk:w-4\" />\n </TooltipTrigger>\n <TooltipContent>Toggle Sidebar</TooltipContent>\n </Tooltip>\n <Button variant=\"ghost\" size=\"sm\" onClick={() => navigate('..', { relative: 'path' })}>\n <ArrowLeft />\n Plugins\n </Button>\n </div>\n <ScrollArea className=\"fk:h-0 fk:min-h-0 fk:flex-1\">\n <div className=\"fk:mx-auto fk:flex fk:w-full fk:max-w-4xl fk:flex-col fk:gap-8 fk:py-6 fk:pl-4 fk:pr-6\">\n <section className=\"fk:flex fk:flex-col fk:gap-3\">\n <div className=\"fk:flex fk:flex-wrap fk:items-center fk:gap-4\">\n <img src={plugin.logoUrl} alt=\"\" className=\"fk:size-14 fk:shrink-0 fk:rounded-lg fk:corner-squircle\" />\n <div className=\"fk:flex fk:min-w-0 fk:flex-col fk:gap-0.5\">\n <h1 className=\"fk:text-xl fk:font-semibold\">{plugin.name}</h1>\n {sourceUrl ? (\n <a\n href={sourceUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"fk:inline-flex fk:w-fit fk:items-center fk:gap-1 fk:text-sm fk:hover:underline fk:text-muted-foreground\"\n >\n View source\n <ExternalLink className=\"fk:size-3\" />\n </a>\n ) : null}\n </div>\n <div className=\"fk:ml-auto fk:flex fk:shrink-0 fk:flex-wrap fk:items-center fk:justify-end fk:gap-2\">\n {isConnected(plugin) ? null : (\n <PluginConnectControl\n busy={busy}\n canManage={data.canManage}\n plugin={plugin}\n onConnect={(scope) => void perform(() => connectPlugin(api, plugin, scope))}\n />\n )}\n </div>\n </div>\n <p className=\"fk:text-muted-foreground\">{plugin.description}</p>\n <div className=\"fk:flex fk:flex-wrap fk:items-center fk:gap-3\">\n <Badge\n className={`fk:border-0 fk:text-[0.625rem] fk:leading-4.5 fk:font-normal fk:py-0 fk:px-2 ${scopeColorClassname(plugin.scopes)}`}\n variant=\"default\"\n >\n {scopeLabel(plugin.scopes)}\n </Badge>\n </div>\n {plugin.scopes.map((scope) => {\n const permitted = scope === 'personal' ? plugin.allowPersonal : data.canManage;\n\n if (permitted) {\n return null;\n }\n\n const message =\n scope === 'project'\n ? 'Ask an owner or developer to connect.'\n : 'Personal connections are disabled by project policy.';\n\n return (\n <p className=\"fk:text-sm fk:text-muted-foreground\" key={scope}>\n {message}\n </p>\n );\n })}\n </section>\n {!plugin.enabled ? (\n <Alert>\n <AlertDescription>This plugin is disabled by project policy.</AlertDescription>\n </Alert>\n ) : null}\n {isConnected(plugin) ? (\n <ConnectedAccounts\n actions={connectionActions}\n busy={busy}\n canManage={data.canManage}\n plugin={plugin}\n onConnect={(scope) => void perform(() => connectPlugin(api, plugin, scope))}\n />\n ) : null}\n <section className=\"fk:flex fk:flex-col fk:gap-3\">\n <div className=\"fk:flex fk:items-center fk:gap-3\">\n <h2 className=\"fk:text-xl fk:font-semibold\">Included tools</h2>\n {plugin.capabilities.agentTools && toolConnection ? (\n <Button\n className=\"fk:ml-auto\"\n disabled={busy}\n size=\"sm\"\n variant=\"ghost\"\n onClick={() =>\n void perform(async () => {\n await api.refreshPluginTools(toolConnection.id);\n await revalidateKey(`${base}/plugin-connections/${toolConnection.id}/tools`);\n })\n }\n >\n <RefreshCw />\n Refresh\n </Button>\n ) : null}\n </div>\n {plugin.capabilities.automationDelivery ? (\n <p className=\"fk:text-sm fk:text-muted-foreground\">\n Automation delivery to selected channels. This plugin does not expose MCP messaging tools.\n </p>\n ) : null}\n {plugin.capabilities.agentTools && !toolConnection ? (\n <p className=\"fk:text-sm fk:text-muted-foreground\">Connect to discover available tools.</p>\n ) : null}\n {plugin.capabilities.agentTools && toolConnection ? (\n <>\n <p className=\"fk:text-sm fk:text-muted-foreground\">Tools · via {toolConnection.displayName}</p>\n <ConnectionTools base={base} connectionId={toolConnection.id} key={toolConnection.id} />\n </>\n ) : null}\n </section>\n <section className=\"fk:flex fk:flex-col fk:gap-3\">\n <h2 className=\"fk:text-xl fk:font-semibold\">Included skills</h2>\n {data.skills.length === 0 ? (\n <p className=\"fk:text-sm fk:text-muted-foreground\">This plugin includes no skills.</p>\n ) : (\n data.skills.map((skill) => (\n <div key={skill.key}>\n <h3 className=\"fk:font-medium\">{skill.name}</h3>\n <p className=\"fk:text-sm fk:text-muted-foreground\">{skill.description}</p>\n </div>\n ))\n )}\n </section>\n <section className=\"fk:space-y-3\">\n <h2 className=\"fk:text-xl fk:font-semibold\">Used by</h2>\n {plugin.usedBy.length === 0 ? (\n <p className=\"fk:text-sm fk:text-muted-foreground\">No automations visible to you use this plugin yet.</p>\n ) : (\n <ul>\n {plugin.usedBy.map((automation) => (\n <li key={automation.id}>\n <Button\n className=\"fk:pl-0!\"\n variant=\"link\"\n onClick={() => navigate(`../../automations/${automation.id}`, { relative: 'path' })}\n >\n {automation.name}\n </Button>\n </li>\n ))}\n </ul>\n )}\n </section>\n </div>\n </ScrollArea>\n </main>\n );\n}\n"]}
@@ -1,2 +1,2 @@
1
- import'./index.css';import {x}from'./chunk-HGXYSP47.js';import {g,f}from'./chunk-SY67F62K.js';import {s}from'./chunk-DGIY4SKN.js';import {e,g as g$1,h,j}from'./chunk-SZEGGBOC.js';import {c,h as h$1,i,k,j as j$1}from'./chunk-32ZU4MLE.js';import {b}from'./chunk-6NRQMG26.js';import {useState,useEffect,useMemo,useTransition}from'react';import {LoaderCircle,MessageSquareIcon,MoreHorizontalIcon,PencilIcon,Trash2Icon}from'lucide-react';import {useLocation,useNavigate}from'react-router-dom';import H,{useSWRConfig}from'swr';import U from'swr/infinite';import {jsx,jsxs}from'react/jsx-runtime';function ue(){let a=useLocation(),n="/agent",t=a.pathname.indexOf(n);return t===-1?`${a.pathname.replace(/\/$/,"")}/agent`:a.pathname.slice(0,t+n.length)}function de(a,n){let[t,o]=useState(a);return useEffect(()=>{let f=window.setTimeout(()=>{o(a);},n);return ()=>{window.clearTimeout(f);}},[n,a]),t}function Z(a){let n=new Date(a.lastMessageAt??a.updatedAt).getTime(),t=new Date,o=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime();return n>=o?"Today":n>=o-864e5?"Yesterday":n>=o-7*864e5?"Previous 7 days":"Older"}function ee(a){let n=[];for(let t of a){let o=Z(t),f=n.find(u=>u.label===o);f?f.chats.push(t):n.push({chats:[t],label:o});}return n}function te({active:a,api:n,chat:t,onChanged:o,onDeleted:f,onOpen:u}){let[r,l]=useState(null),[g,d]=useState(t.title??""),[p,D]=useTransition(),k$1=t.title?.trim()||"New chat";function v(){D(async()=>{await n.renameAgentChat(t.id,g.trim()),l(null),o();});}function y(){D(async()=>{await n.deleteAgentChat(t.id),l(null),f();});}return jsxs("div",{className:`fk:group/chat fk:flex fk:items-center fk:gap-1 fk:rounded-md fk:pr-1 ${a?"fk:bg-sidebar-accent":"fk:hover:bg-accent/60"} fk:corner-squircle`,children:[jsx("button",{className:"fk:min-w-0 fk:flex-1 fk:truncate fk:px-2 fk:py-1.5 fk:text-left fk:text-sm",title:k$1,type:"button",onClick:u,children:k$1}),jsxs(e,{children:[jsx(g$1,{asChild:true,children:jsx(b,{className:"fk:size-6 fk:shrink-0 fk:opacity-0 fk:group-hover/chat:opacity-100 fk:data-[state=open]:opacity-100",size:"icon",variant:"ghost",children:jsx(MoreHorizontalIcon,{className:"fk:size-4"})})}),jsxs(h,{align:"start",children:[jsxs(j,{onClick:()=>{d(t.title??""),l("rename");},children:[jsx(PencilIcon,{className:"fk:size-4"}),"Rename"]}),jsxs(j,{className:"fk:text-destructive",onClick:()=>l("delete"),children:[jsx(Trash2Icon,{className:"fk:size-4"}),"Delete"]})]})]}),jsx(c,{open:r==="rename",onOpenChange:m=>l(m?"rename":null),children:jsxs(h$1,{className:"fk:max-w-sm",children:[jsx(i,{children:jsx(k,{children:"Rename chat"})}),jsx(s,{value:g,onChange:m=>d(m.target.value),placeholder:"Chat title"}),jsx(j$1,{children:jsx(b,{disabled:p||!g.trim(),size:"sm",onClick:v,children:p?"Saving...":"Save"})})]})}),jsx(c,{open:r==="delete",onOpenChange:m=>l(m?"delete":null),children:jsxs(h$1,{className:"fk:max-w-sm",children:[jsx(i,{children:jsx(k,{children:"Delete chat?"})}),jsxs("p",{className:"fk:text-sm fk:text-muted-foreground",children:["\u201C",k$1,"\u201D and its messages will be permanently deleted."]}),jsx(j$1,{children:jsx(b,{disabled:p,size:"sm",variant:"destructive",onClick:y,children:p?"Deleting...":"Delete"})})]})})]})}function ne({onOpen:a,projectId:n,query:t}){let{data:o,isLoading:f$1}=H(g(n).agentChatSearch(t),f,{keepPreviousData:true});return f$1&&!o?jsxs("div",{className:"fk:flex fk:items-center fk:gap-2 fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-3.5 fk:animate-spin"}),"Searching..."]}):o?.results.length?jsx("div",{className:"fk:space-y-1",children:o.results.map(u=>jsxs("button",{className:"fk:block fk:w-full fk:rounded-md fk:px-2 fk:py-1.5 fk:text-left fk:hover:bg-accent/60 fk:corner-squircle",type:"button",onClick:()=>a(u.chatId),children:[jsx("span",{className:"fk:block fk:truncate fk:text-sm",children:u.chatTitle?.trim()||"New chat"}),jsx("span",{className:"fk:block fk:truncate fk:text-xs fk:text-muted-foreground",children:u.snippet})]},u.messageId))}):jsx("p",{className:"fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground",children:"No matching chats."})}function me({query:a}){let{api:n,projectId:t}=x(),o=useNavigate(),f$1=useLocation(),{mutate:u}=useSWRConfig(),r=/\/agent\/chats\/([^/]+)/.exec(f$1.pathname)?.[1],{data:l,isLoading:g$1,mutate:d,setSize:p,size:D}=U((s,c)=>!t||c&&!c.hasMore?null:g(t).agentChats(s*30),f,{revalidateFirstPage:true}),{data:k}=H(t&&r?g(t).agentChat(r):null,f),v=useMemo(()=>{let s=(l??[]).flatMap(h=>h.chats),c=k?.chat.title?.trim();return !r||!c?s:s.map(h=>h.id!==r||h.title?.trim()?h:{...h,title:c})},[k?.chat.title,r,l]),y=l?.[l.length-1]?.hasMore??false,m=useMemo(()=>ee(v),[v]);if(useEffect(()=>{d();},[r,d]),!t||!n)return null;let J=n,z=t;function L(s){o(`agent/chats/${s}`);}function X(s){d(),s===r?o("agent"):u(g(z).agentChat(s),void 0,{revalidate:false});}return jsx("div",{className:"fk:space-y-2",children:a?jsx(ne,{projectId:z,query:a,onOpen:L}):jsxs("div",{className:"fk:space-y-3",children:[m.map(s=>jsxs("div",{children:[jsx("p",{className:"fk:px-2 fk:pb-1 fk:text-xs fk:font-medium fk:text-muted-foreground",children:s.label}),jsx("div",{className:"fk:space-y-0.5",children:s.chats.map(c=>jsx(te,{active:c.id===r,api:J,chat:c,onChanged:()=>{d();},onDeleted:()=>X(c.id),onOpen:()=>L(c.id)},c.id))})]},s.label)),g$1?jsxs("div",{className:"fk:flex fk:items-center fk:gap-2 fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-3.5 fk:animate-spin"}),"Loading recent chats..."]}):null,!g$1&&v.length===0?jsxs("div",{className:"fk:flex fk:flex-col fk:items-center fk:gap-2 fk:px-2 fk:py-6 fk:text-center fk:text-xs fk:text-muted-foreground",children:[jsx(MessageSquareIcon,{className:"fk:size-5"}),jsx("span",{children:"No chats yet. Start a conversation with the agent."})]}):null,y?jsx(b,{className:"fk:w-full",size:"sm",variant:"ghost",onClick:()=>{p(D+1);},children:"Load more"}):null]})})}export{ue as a,de as b,me as c};//# sourceMappingURL=chunk-HBTMGDOM.js.map
2
- //# sourceMappingURL=chunk-HBTMGDOM.js.map
1
+ import'./index.css';import {x}from'./chunk-SZOEW2TL.js';import {g,f}from'./chunk-MNLYE7DK.js';import {s}from'./chunk-DGIY4SKN.js';import {e,g as g$1,h,j}from'./chunk-SZEGGBOC.js';import {c,h as h$1,i,k,j as j$1}from'./chunk-32ZU4MLE.js';import {b}from'./chunk-6NRQMG26.js';import {useState,useEffect,useMemo,useTransition}from'react';import {LoaderCircle,MessageSquareIcon,MoreHorizontalIcon,PencilIcon,Trash2Icon}from'lucide-react';import {useLocation,useNavigate}from'react-router-dom';import H,{useSWRConfig}from'swr';import U from'swr/infinite';import {jsx,jsxs}from'react/jsx-runtime';function ue(){let a=useLocation(),n="/agent",t=a.pathname.indexOf(n);return t===-1?`${a.pathname.replace(/\/$/,"")}/agent`:a.pathname.slice(0,t+n.length)}function de(a,n){let[t,o]=useState(a);return useEffect(()=>{let f=window.setTimeout(()=>{o(a);},n);return ()=>{window.clearTimeout(f);}},[n,a]),t}function Z(a){let n=new Date(a.lastMessageAt??a.updatedAt).getTime(),t=new Date,o=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime();return n>=o?"Today":n>=o-864e5?"Yesterday":n>=o-7*864e5?"Previous 7 days":"Older"}function ee(a){let n=[];for(let t of a){let o=Z(t),f=n.find(u=>u.label===o);f?f.chats.push(t):n.push({chats:[t],label:o});}return n}function te({active:a,api:n,chat:t,onChanged:o,onDeleted:f,onOpen:u}){let[r,l]=useState(null),[g,d]=useState(t.title??""),[p,D]=useTransition(),k$1=t.title?.trim()||"New chat";function v(){D(async()=>{await n.renameAgentChat(t.id,g.trim()),l(null),o();});}function y(){D(async()=>{await n.deleteAgentChat(t.id),l(null),f();});}return jsxs("div",{className:`fk:group/chat fk:flex fk:items-center fk:gap-1 fk:rounded-md fk:pr-1 ${a?"fk:bg-sidebar-accent":"fk:hover:bg-accent/60"} fk:corner-squircle`,children:[jsx("button",{className:"fk:min-w-0 fk:flex-1 fk:truncate fk:px-2 fk:py-1.5 fk:text-left fk:text-sm",title:k$1,type:"button",onClick:u,children:k$1}),jsxs(e,{children:[jsx(g$1,{asChild:true,children:jsx(b,{className:"fk:size-6 fk:shrink-0 fk:opacity-0 fk:group-hover/chat:opacity-100 fk:data-[state=open]:opacity-100",size:"icon",variant:"ghost",children:jsx(MoreHorizontalIcon,{className:"fk:size-4"})})}),jsxs(h,{align:"start",children:[jsxs(j,{onClick:()=>{d(t.title??""),l("rename");},children:[jsx(PencilIcon,{className:"fk:size-4"}),"Rename"]}),jsxs(j,{className:"fk:text-destructive",onClick:()=>l("delete"),children:[jsx(Trash2Icon,{className:"fk:size-4"}),"Delete"]})]})]}),jsx(c,{open:r==="rename",onOpenChange:m=>l(m?"rename":null),children:jsxs(h$1,{className:"fk:max-w-sm",children:[jsx(i,{children:jsx(k,{children:"Rename chat"})}),jsx(s,{value:g,onChange:m=>d(m.target.value),placeholder:"Chat title"}),jsx(j$1,{children:jsx(b,{disabled:p||!g.trim(),size:"sm",onClick:v,children:p?"Saving...":"Save"})})]})}),jsx(c,{open:r==="delete",onOpenChange:m=>l(m?"delete":null),children:jsxs(h$1,{className:"fk:max-w-sm",children:[jsx(i,{children:jsx(k,{children:"Delete chat?"})}),jsxs("p",{className:"fk:text-sm fk:text-muted-foreground",children:["\u201C",k$1,"\u201D and its messages will be permanently deleted."]}),jsx(j$1,{children:jsx(b,{disabled:p,size:"sm",variant:"destructive",onClick:y,children:p?"Deleting...":"Delete"})})]})})]})}function ne({onOpen:a,projectId:n,query:t}){let{data:o,isLoading:f$1}=H(g(n).agentChatSearch(t),f,{keepPreviousData:true});return f$1&&!o?jsxs("div",{className:"fk:flex fk:items-center fk:gap-2 fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-3.5 fk:animate-spin"}),"Searching..."]}):o?.results.length?jsx("div",{className:"fk:space-y-1",children:o.results.map(u=>jsxs("button",{className:"fk:block fk:w-full fk:rounded-md fk:px-2 fk:py-1.5 fk:text-left fk:hover:bg-accent/60 fk:corner-squircle",type:"button",onClick:()=>a(u.chatId),children:[jsx("span",{className:"fk:block fk:truncate fk:text-sm",children:u.chatTitle?.trim()||"New chat"}),jsx("span",{className:"fk:block fk:truncate fk:text-xs fk:text-muted-foreground",children:u.snippet})]},u.messageId))}):jsx("p",{className:"fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground",children:"No matching chats."})}function me({query:a}){let{api:n,projectId:t}=x(),o=useNavigate(),f$1=useLocation(),{mutate:u}=useSWRConfig(),r=/\/agent\/chats\/([^/]+)/.exec(f$1.pathname)?.[1],{data:l,isLoading:g$1,mutate:d,setSize:p,size:D}=U((s,c)=>!t||c&&!c.hasMore?null:g(t).agentChats(s*30),f,{revalidateFirstPage:true}),{data:k}=H(t&&r?g(t).agentChat(r):null,f),v=useMemo(()=>{let s=(l??[]).flatMap(h=>h.chats),c=k?.chat.title?.trim();return !r||!c?s:s.map(h=>h.id!==r||h.title?.trim()?h:{...h,title:c})},[k?.chat.title,r,l]),y=l?.[l.length-1]?.hasMore??false,m=useMemo(()=>ee(v),[v]);if(useEffect(()=>{d();},[r,d]),!t||!n)return null;let J=n,z=t;function L(s){o(`agent/chats/${s}`);}function X(s){d(),s===r?o("agent"):u(g(z).agentChat(s),void 0,{revalidate:false});}return jsx("div",{className:"fk:space-y-2",children:a?jsx(ne,{projectId:z,query:a,onOpen:L}):jsxs("div",{className:"fk:space-y-3",children:[m.map(s=>jsxs("div",{children:[jsx("p",{className:"fk:px-2 fk:pb-1 fk:text-xs fk:font-medium fk:text-muted-foreground",children:s.label}),jsx("div",{className:"fk:space-y-0.5",children:s.chats.map(c=>jsx(te,{active:c.id===r,api:J,chat:c,onChanged:()=>{d();},onDeleted:()=>X(c.id),onOpen:()=>L(c.id)},c.id))})]},s.label)),g$1?jsxs("div",{className:"fk:flex fk:items-center fk:gap-2 fk:px-2 fk:py-3 fk:text-xs fk:text-muted-foreground",children:[jsx(LoaderCircle,{className:"fk:size-3.5 fk:animate-spin"}),"Loading recent chats..."]}):null,!g$1&&v.length===0?jsxs("div",{className:"fk:flex fk:flex-col fk:items-center fk:gap-2 fk:px-2 fk:py-6 fk:text-center fk:text-xs fk:text-muted-foreground",children:[jsx(MessageSquareIcon,{className:"fk:size-5"}),jsx("span",{children:"No chats yet. Start a conversation with the agent."})]}):null,y?jsx(b,{className:"fk:w-full",size:"sm",variant:"ghost",onClick:()=>{p(D+1);},children:"Load more"}):null]})})}export{ue as a,de as b,me as c};//# sourceMappingURL=chunk-IQ2F2FFF.js.map
2
+ //# sourceMappingURL=chunk-IQ2F2FFF.js.map