@flexkit/studio 0.2.35 → 0.2.36

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 (85) hide show
  1. package/dist/{activity-nav-button-ZHQOZBCC.js → activity-nav-button-KOOMUTOW.js} +2 -2
  2. package/dist/{activity-nav-button-ZHQOZBCC.js.map → activity-nav-button-KOOMUTOW.js.map} +1 -1
  3. package/dist/chat-page-NDVHLH5Q.js +4 -0
  4. package/dist/chat-page-NDVHLH5Q.js.map +1 -0
  5. package/dist/{chunk-XYE6ZAUB.js → chunk-27JTWTU6.js} +2 -2
  6. package/dist/{chunk-XYE6ZAUB.js.map → chunk-27JTWTU6.js.map} +1 -1
  7. package/dist/{chunk-PZWEC6KD.js → chunk-2PBDHGRR.js} +2 -2
  8. package/dist/{chunk-PZWEC6KD.js.map → chunk-2PBDHGRR.js.map} +1 -1
  9. package/dist/{chunk-ZRTWLY77.js → chunk-474MQNDK.js} +3 -3
  10. package/dist/{chunk-ZRTWLY77.js.map → chunk-474MQNDK.js.map} +1 -1
  11. package/dist/{chunk-RFKMFD2O.js → chunk-CGMKGENV.js} +2 -2
  12. package/dist/{chunk-RFKMFD2O.js.map → chunk-CGMKGENV.js.map} +1 -1
  13. package/dist/{chunk-DEG7QP5C.js → chunk-FF5EBXYN.js} +3 -3
  14. package/dist/{chunk-DEG7QP5C.js.map → chunk-FF5EBXYN.js.map} +1 -1
  15. package/dist/{chunk-KEGJNZLW.js → chunk-FJS4SN3K.js} +3 -3
  16. package/dist/{chunk-KEGJNZLW.js.map → chunk-FJS4SN3K.js.map} +1 -1
  17. package/dist/{chunk-W7JDZHCV.js → chunk-FXUD4JRG.js} +2 -2
  18. package/dist/{chunk-W7JDZHCV.js.map → chunk-FXUD4JRG.js.map} +1 -1
  19. package/dist/{chunk-PWGLA33F.js → chunk-GTR4M2BQ.js} +3 -3
  20. package/dist/{chunk-PWGLA33F.js.map → chunk-GTR4M2BQ.js.map} +1 -1
  21. package/dist/{chunk-J6EGNRRT.js → chunk-HXPETSXC.js} +3 -3
  22. package/dist/{chunk-J6EGNRRT.js.map → chunk-HXPETSXC.js.map} +1 -1
  23. package/dist/{chunk-WU2KCXBC.js → chunk-L5Z56DDM.js} +2 -2
  24. package/dist/{chunk-WU2KCXBC.js.map → chunk-L5Z56DDM.js.map} +1 -1
  25. package/dist/{chunk-RAUQCO6W.js → chunk-LTM3MW2D.js} +2 -2
  26. package/dist/{chunk-RAUQCO6W.js.map → chunk-LTM3MW2D.js.map} +1 -1
  27. package/dist/{chunk-36DLIVZF.js → chunk-LVKBKU6Q.js} +2 -2
  28. package/dist/{chunk-36DLIVZF.js.map → chunk-LVKBKU6Q.js.map} +1 -1
  29. package/dist/{chunk-PMLDA2FF.js → chunk-LXLEUEWT.js} +2 -2
  30. package/dist/{chunk-PMLDA2FF.js.map → chunk-LXLEUEWT.js.map} +1 -1
  31. package/dist/{chunk-BTH7HU5Y.js → chunk-MHEFVYKP.js} +2 -2
  32. package/dist/{chunk-BTH7HU5Y.js.map → chunk-MHEFVYKP.js.map} +1 -1
  33. package/dist/{chunk-Q4CWQHBJ.js → chunk-NKDQQHCL.js} +2 -2
  34. package/dist/{chunk-Q4CWQHBJ.js.map → chunk-NKDQQHCL.js.map} +1 -1
  35. package/dist/{chunk-ZMONKGWJ.js → chunk-OJ4RI6IQ.js} +3 -3
  36. package/dist/{chunk-ZMONKGWJ.js.map → chunk-OJ4RI6IQ.js.map} +1 -1
  37. package/dist/chunk-PLCI2RJA.js +3 -0
  38. package/dist/chunk-PLCI2RJA.js.map +1 -0
  39. package/dist/{chunk-R6DPAMLC.js → chunk-SOA2F7Z6.js} +3 -3
  40. package/dist/{chunk-R6DPAMLC.js.map → chunk-SOA2F7Z6.js.map} +1 -1
  41. package/dist/{chunk-TI3EHLRE.js → chunk-TWA6OG5U.js} +3 -3
  42. package/dist/{chunk-TI3EHLRE.js.map → chunk-TWA6OG5U.js.map} +1 -1
  43. package/dist/{chunk-7N3LTSVX.js → chunk-VIBGMCLS.js} +2 -2
  44. package/dist/{chunk-7N3LTSVX.js.map → chunk-VIBGMCLS.js.map} +1 -1
  45. package/dist/{chunk-FJRDLP7V.js → chunk-YJ4NWJCC.js} +4 -4
  46. package/dist/{chunk-FJRDLP7V.js.map → chunk-YJ4NWJCC.js.map} +1 -1
  47. package/dist/{entry-NQRN7SWV.js → entry-XHH3NKN2.js} +2 -2
  48. package/dist/{entry-NQRN7SWV.js.map → entry-XHH3NKN2.js.map} +1 -1
  49. package/dist/index.js +2 -2
  50. package/dist/{list-RPIG75US.js → list-R64THLZD.js} +2 -2
  51. package/dist/{list-RPIG75US.js.map → list-R64THLZD.js.map} +1 -1
  52. package/dist/{list-7SCWJXUE.js → list-XIE55HYD.js} +3 -3
  53. package/dist/{list-7SCWJXUE.js.map → list-XIE55HYD.js.map} +1 -1
  54. package/dist/{pages-KXERA5Z6.js → pages-OWXBU64L.js} +3 -3
  55. package/dist/{pages-KXERA5Z6.js.map → pages-OWXBU64L.js.map} +1 -1
  56. package/dist/{plugin-pages-NXA4BT7Y.js → plugin-pages-JBJQHBIN.js} +2 -2
  57. package/dist/{plugin-pages-NXA4BT7Y.js.map → plugin-pages-JBJQHBIN.js.map} +1 -1
  58. package/dist/{project-selector-SA6UUVBK.js → project-selector-L2WZ3MB5.js} +2 -2
  59. package/dist/{project-selector-SA6UUVBK.js.map → project-selector-L2WZ3MB5.js.map} +1 -1
  60. package/dist/record-links-BEKOPDDR.js +2 -0
  61. package/dist/{record-links-RTMCYEPM.js.map → record-links-BEKOPDDR.js.map} +1 -1
  62. package/dist/{root-MBFQXX4E.js → root-B5XP6VYU.js} +2 -2
  63. package/dist/{root-MBFQXX4E.js.map → root-B5XP6VYU.js.map} +1 -1
  64. package/dist/{root-TZIXWEZO.js → root-DUQULYRX.js} +2 -2
  65. package/dist/{root-TZIXWEZO.js.map → root-DUQULYRX.js.map} +1 -1
  66. package/dist/{root-6H6K3YQF.js → root-I22KNOFC.js} +3 -3
  67. package/dist/{root-6H6K3YQF.js.map → root-I22KNOFC.js.map} +1 -1
  68. package/dist/{root-W5ZPSNQ2.js → root-O4DMQLEH.js} +2 -2
  69. package/dist/{root-W5ZPSNQ2.js.map → root-O4DMQLEH.js.map} +1 -1
  70. package/dist/{root-IBZPU2D4.js → root-RUOT5OSO.js} +3 -3
  71. package/dist/{root-IBZPU2D4.js.map → root-RUOT5OSO.js.map} +1 -1
  72. package/dist/{root-TSZ3CSJU.js → root-VLD6GNZL.js} +3 -3
  73. package/dist/{root-TSZ3CSJU.js.map → root-VLD6GNZL.js.map} +1 -1
  74. package/dist/{search-ZLEYFT3T.js → search-4UQR6ENH.js} +2 -2
  75. package/dist/{search-ZLEYFT3T.js.map → search-4UQR6ENH.js.map} +1 -1
  76. package/dist/{skills-pages-RPMWIBLS.js → skills-pages-VUIOUEYQ.js} +2 -2
  77. package/dist/{skills-pages-RPMWIBLS.js.map → skills-pages-VUIOUEYQ.js.map} +1 -1
  78. package/dist/{source-VYWE5EB5.js → source-L54C4T3X.js} +2 -2
  79. package/dist/{source-VYWE5EB5.js.map → source-L54C4T3X.js.map} +1 -1
  80. package/package.json +3 -3
  81. package/dist/chat-page-IR4RF46H.js +0 -4
  82. package/dist/chat-page-IR4RF46H.js.map +0 -1
  83. package/dist/chunk-U6VZY3V2.js +0 -3
  84. package/dist/chunk-U6VZY3V2.js.map +0 -1
  85. package/dist/record-links-RTMCYEPM.js +0 -2
@@ -1,2 +1,2 @@
1
- import'./index.css';import {b as b$1}from'./chunk-U6VZY3V2.js';import {b}from'./chunk-G5N6HEPW.js';import {k,p,q as q$1,s,t,r}from'./chunk-S7Z6KKIN.js';import {c}from'./chunk-X3SHNHHM.js';import {useSyncExternalStore,useId,useState}from'react';import {LoaderCircle,ExternalLinkIcon}from'lucide-react';import {jsx,jsxs}from'react/jsx-runtime';var K="/plugins/oauth/start",R=class extends Error{code="account_mismatch";constructor(){super('You signed in with a different account. Use "Connect another account" to add it.'),this.name="PluginAccountMismatchError";}};function U(t){let e;try{e=new URL(t);}catch{return null}return e.protocol!=="https:"||e.username!==""||e.password!==""?null:e}function Q(t,e){let n=b$1(),r=U(t),o=U(e);return !r||!o||r.origin!==n||r.pathname!==K||o.origin!==n||o.pathname!=="/"?null:{href:r.href,origin:n}}async function O(t,e,n,r){let o=window.open("about:blank",`flexkit-plugin-${crypto.randomUUID()}`,"popup,width=560,height=720");if(!o)throw new Error("Allow popups for Studio, then connect again.");let a;try{a=await t.connectPlugins({pluginId:e,scope:n,studioOrigin:window.location.origin,...r?.connectionId?{connectionId:r.connectionId}:{}});}catch(u){throw o.close(),u}let d=Q(a.authorizeUrl,a.completionOrigin);if(!d)throw o.close(),new Error("Connection could not be started.");let g=d.origin;await new Promise((u,m)=>{let c=false,f=false,k=false,h=i=>{if(!f){if(f=true,window.clearInterval(l),window.clearTimeout(C),window.removeEventListener("message",P),o.close(),i){m(i);return}u();}},v=async()=>{if(c||f)return;c=true;let i;try{i=await t.pluginOAuthStatus(a.transactionId);}catch{c=false;return}if(c=false,i.status==="complete"){h();return}if(!k&&o.closed&&i.status==="pending"){h(new Error("Connection window was closed."));return}(i.status==="failed"||new Date(i.expires_at).getTime()<Date.now())&&h(new Error("Connection was not completed. Please try again."));},P=i=>{if(i.origin!==g||i.source!==o||!i.data||typeof i.data!="object")return;let y=i.data;if(y.type==="flexkit:plugin-oauth-ready"&&y.transactionId===a.transactionId){k=true,o.postMessage({type:"flexkit:plugin-oauth-start",transactionId:a.transactionId,ticket:a.launchTicket},g);return}if(y.type==="flexkit:plugin-oauth"&&y.transactionId===a.transactionId){if(y.status==="failed"&&y.error==="account_mismatch"){h(new R);return}v();}},l=window.setInterval(()=>{v();},2e3),C=window.setTimeout(()=>h(new Error("Connection timed out. Please try again.")),6e5);window.addEventListener("message",P),o.location.href=d.href;});}function W(t){let{connect:e}=t;return e?.type==="api-token"?e.pattern?[{label:e.tokenLabel,pattern:e.pattern}]:[]:e?.type==="credentials"?[...e.fields,...e.methods.flatMap(n=>n.fields)].filter(n=>n.kind==="secret"&&n.detect).map(n=>({label:n.label,pattern:n.detect})):[]}function M(t,e){let n=t.methods.find(r=>r.key===e);return [...t.fields,...n?.fields??[]]}function z(t,e){return t.every(n=>!n.required||!!e[n.key]?.trim())}function X(t,e){for(let n of t){let r=e[n.key]?.trim()??"";if(!r){if(n.required)return {field:n.key,message:`Enter the ${n.label}.`};continue}if(r.length>4096)return {field:n.key,message:`The ${n.label} is too long; paste only the value.`};if(!S(r,n.pattern))return {field:n.key,message:`That is not a valid ${n.label}.`}}return null}function S(t,e){if(!e)return true;try{return new RegExp(e,"u").test(t)}catch{return true}}function Z(t){if(!t)return null;try{return new RegExp(t,"u")}catch{return null}}function ae(t,e){let n=t.split(/[\s"'`()<>[\]{},;:=!?&]+/).map(a=>a.replace(/\.+$/,"")).filter(Boolean),r=null,o=new Set;for(let a of e)for(let d of W(a)){let g=Z(d.pattern);for(let u of g?n:[])g.test(u)&&(r??={plugin:a,label:d.label},o.add(u));}return r?{...r,tokens:[...o]}:null}var _=null,q=0,L=null,N=new Set;function B(t){_=t,N.forEach(e=>e());}function ne(t){return N.add(t),()=>N.delete(t)}function me(t,e,n,r){let{connect:o}=e;if(o?.type!=="api-token"&&o?.type!=="credentials")return O(t,e.id,n,r).then(()=>true);L?.();let a=++q,d=r?.connectionId?{connectionId:r.connectionId}:{};return new Promise(g=>{let u=c=>{_?.id===a&&B(null),q===a&&(L=null),g(c);},m=o.type==="api-token"?{kind:"token",id:a,plugin:{...e,connect:o},submit:async c=>{await t.connectPluginToken({pluginId:e.id,scope:n,token:c,...d});},settle:u}:{kind:"credentials",id:a,plugin:{...e,connect:o},submit:async(c,f)=>{await t.connectPluginCredentials({pluginId:e.id,scope:n,method:c,values:f,...d});},settle:u};L=()=>u(false),setTimeout(()=>{q===a&&B(m);});})}function oe(t){if(!t)return null;try{let e=new URL(t);return e.protocol==="https:"?e.href:null}catch{return null}}function ke(){let t=useSyncExternalStore(ne,()=>_,()=>null);return t?t.kind==="token"?jsx(le,{request:t},t.id):jsx(re,{request:t},t.id):null}function $({id:t,message:e}){return e?jsx("p",{className:"fk:text-sm fk:text-destructive",id:t,children:e}):null}function V({href:t,label:e}){let n=oe(t);return n?jsxs("a",{className:"fk:inline-flex fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground fk:underline-offset-4 fk:hover:underline",href:n,rel:"noreferrer",target:"_blank",children:[e,jsx(ExternalLinkIcon,{className:"fk:size-3.5"})]}):null}function re({request:t$1}){let{connect:e,name:n}=t$1.plugin,r$1=useId(),[o,a]=useState(e.methods[0]?.key??null),[d,g]=useState({}),[u,m]=useState(null),[c$1,f]=useState(false),k$1=M(e,o),h=e.methods.find(l=>l.key===o)??null,v=z(k$1,d);async function P(l){if(l.preventDefault(),c$1)return;let C=X(k$1,d);if(C){m(C);return}f(true),m(null);try{await t$1.submit(o??void 0,Object.fromEntries(k$1.map(i=>[i.key,d[i.key]?.trim()??""]).filter(([,i])=>i))),g({}),t$1.settle(!0);}catch(i){m({field:null,message:i instanceof Error?i.message:`${n} could not be connected.`});}finally{f(false);}}return jsx(k,{open:true,onOpenChange:l=>{!l&&!c$1&&t$1.settle(false);},children:jsx(p,{children:jsxs("form",{className:"fk:flex fk:flex-col fk:gap-4",onSubmit:l=>{P(l);},children:[jsxs(q$1,{children:[jsxs(s,{children:["Connect ",n]}),jsxs(t,{children:[e.description," Flexkit checks the credentials with ",n,", stores them encrypted and sends them only to Flexkit's own ",n," server; the agent can use the tools but never sees them."]})]}),e.methods.length>1?jsx("div",{className:"fk:space-y-1.5",role:"group","aria-label":"How to connect",children:e.methods.map(l=>jsxs("button",{"aria-pressed":o===l.key,className:`fk:flex fk:w-full fk:flex-col fk:rounded-lg fk:border fk:px-3 fk:py-2 fk:text-left fk:corner-squircle ${o===l.key?"fk:border-primary fk:bg-primary/5":"fk:border-border fk:hover:bg-muted/60"}`,disabled:c$1,onClick:()=>{a(l.key),m(null);},type:"button",children:[jsx("span",{className:"fk:text-sm fk:font-medium",children:l.label}),l.description?jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:l.description}):null]},l.key))}):h?.description?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:h.description}):null,k$1.map((l,C)=>{let i=`${r$1}-${l.key}`,y=u?.field===l.key?u.message:null;return jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx("label",{className:"fk:text-sm fk:font-medium",htmlFor:i,children:l.label}),jsx(b,{"aria-describedby":y?`${i}-error`:l.help?`${i}-help`:void 0,"aria-invalid":y?true:void 0,autoComplete:"off",autoFocus:C===0,disabled:c$1,id:i,placeholder:l.placeholder??void 0,spellCheck:false,type:l.kind==="secret"?"password":"text",value:d[l.key]??"",onChange:j=>{g(Y=>({...Y,[l.key]:j.target.value})),m(null);}}),l.help&&!y?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",id:`${i}-help`,children:l.help}):null,jsx($,{id:`${i}-error`,message:y})]},l.key)}),jsx($,{id:`${r$1}-error`,message:u?.field===null?u.message:null}),jsx(V,{href:e.helpUrl,label:`How to set up ${n}`}),jsxs(r,{children:[jsx(c,{disabled:c$1,size:"sm",type:"button",variant:"outline",onClick:()=>t$1.settle(false),children:"Cancel"}),jsxs(c,{disabled:c$1||!v,size:"sm",type:"submit",children:[c$1?jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}):null,"Connect"]})]})]})})})}function le({request:t$1}){let{connect:e,name:n}=t$1.plugin,r$1=useId(),[o,a]=useState(""),[d,g]=useState(null),[u,m]=useState(false);async function c$1(f){f.preventDefault();let k=o.trim();if(!(u||!k)){if(!S(k,e.pattern)){g(`That does not look like a ${e.tokenLabel}.`);return}m(true),g(null);try{await t$1.submit(k),a(""),t$1.settle(!0);}catch(h){g(h instanceof Error?h.message:`${n} could not be connected.`);}finally{m(false);}}}return jsx(k,{open:true,onOpenChange:f=>{!f&&!u&&t$1.settle(false);},children:jsx(p,{children:jsxs("form",{className:"fk:flex fk:flex-col fk:gap-4",onSubmit:f=>{c$1(f);},children:[jsxs(q$1,{children:[jsxs(s,{children:["Connect ",n]}),jsxs(t,{children:["Paste a ",e.tokenLabel,". Flexkit stores it encrypted and sends it only to ",n,"; the agent can use"," ",n,"'s tools but never sees the token. Give it read access only, unless the agent should change things in ",n,"."]})]}),jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx("label",{className:"fk:text-sm fk:font-medium",htmlFor:r$1,children:e.tokenLabel}),jsx(b,{"aria-describedby":d?`${r$1}-error`:void 0,"aria-invalid":d?true:void 0,autoComplete:"off",autoFocus:true,disabled:u,id:r$1,placeholder:e.placeholder??void 0,spellCheck:false,type:"password",value:o,onChange:f=>{a(f.target.value),g(null);}}),jsx($,{id:`${r$1}-error`,message:d}),jsx(V,{href:e.helpUrl,label:`How to create a ${e.tokenLabel}`})]}),jsxs(r,{children:[jsx(c,{disabled:u,size:"sm",type:"button",variant:"outline",onClick:()=>t$1.settle(false),children:"Cancel"}),jsxs(c,{disabled:u||!o.trim(),size:"sm",type:"submit",children:[u?jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}):null,"Connect"]})]})]})})})}export{R as a,O as b,ae as c,me as d,ke as e};//# sourceMappingURL=chunk-WU2KCXBC.js.map
2
- //# sourceMappingURL=chunk-WU2KCXBC.js.map
1
+ import'./index.css';import {b as b$1}from'./chunk-PLCI2RJA.js';import {b}from'./chunk-G5N6HEPW.js';import {k,p,q as q$1,s,t,r}from'./chunk-S7Z6KKIN.js';import {c}from'./chunk-X3SHNHHM.js';import {useSyncExternalStore,useId,useState}from'react';import {LoaderCircle,ExternalLinkIcon}from'lucide-react';import {jsx,jsxs}from'react/jsx-runtime';var K="/plugins/oauth/start",R=class extends Error{code="account_mismatch";constructor(){super('You signed in with a different account. Use "Connect another account" to add it.'),this.name="PluginAccountMismatchError";}};function U(t){let e;try{e=new URL(t);}catch{return null}return e.protocol!=="https:"||e.username!==""||e.password!==""?null:e}function Q(t,e){let n=b$1(),r=U(t),o=U(e);return !r||!o||r.origin!==n||r.pathname!==K||o.origin!==n||o.pathname!=="/"?null:{href:r.href,origin:n}}async function O(t,e,n,r){let o=window.open("about:blank",`flexkit-plugin-${crypto.randomUUID()}`,"popup,width=560,height=720");if(!o)throw new Error("Allow popups for Studio, then connect again.");let a;try{a=await t.connectPlugins({pluginId:e,scope:n,studioOrigin:window.location.origin,...r?.connectionId?{connectionId:r.connectionId}:{}});}catch(u){throw o.close(),u}let d=Q(a.authorizeUrl,a.completionOrigin);if(!d)throw o.close(),new Error("Connection could not be started.");let g=d.origin;await new Promise((u,m)=>{let c=false,f=false,k=false,h=i=>{if(!f){if(f=true,window.clearInterval(l),window.clearTimeout(C),window.removeEventListener("message",P),o.close(),i){m(i);return}u();}},v=async()=>{if(c||f)return;c=true;let i;try{i=await t.pluginOAuthStatus(a.transactionId);}catch{c=false;return}if(c=false,i.status==="complete"){h();return}if(!k&&o.closed&&i.status==="pending"){h(new Error("Connection window was closed."));return}(i.status==="failed"||new Date(i.expires_at).getTime()<Date.now())&&h(new Error("Connection was not completed. Please try again."));},P=i=>{if(i.origin!==g||i.source!==o||!i.data||typeof i.data!="object")return;let y=i.data;if(y.type==="flexkit:plugin-oauth-ready"&&y.transactionId===a.transactionId){k=true,o.postMessage({type:"flexkit:plugin-oauth-start",transactionId:a.transactionId,ticket:a.launchTicket},g);return}if(y.type==="flexkit:plugin-oauth"&&y.transactionId===a.transactionId){if(y.status==="failed"&&y.error==="account_mismatch"){h(new R);return}v();}},l=window.setInterval(()=>{v();},2e3),C=window.setTimeout(()=>h(new Error("Connection timed out. Please try again.")),6e5);window.addEventListener("message",P),o.location.href=d.href;});}function W(t){let{connect:e}=t;return e?.type==="api-token"?e.pattern?[{label:e.tokenLabel,pattern:e.pattern}]:[]:e?.type==="credentials"?[...e.fields,...e.methods.flatMap(n=>n.fields)].filter(n=>n.kind==="secret"&&n.detect).map(n=>({label:n.label,pattern:n.detect})):[]}function M(t,e){let n=t.methods.find(r=>r.key===e);return [...t.fields,...n?.fields??[]]}function z(t,e){return t.every(n=>!n.required||!!e[n.key]?.trim())}function X(t,e){for(let n of t){let r=e[n.key]?.trim()??"";if(!r){if(n.required)return {field:n.key,message:`Enter the ${n.label}.`};continue}if(r.length>4096)return {field:n.key,message:`The ${n.label} is too long; paste only the value.`};if(!S(r,n.pattern))return {field:n.key,message:`That is not a valid ${n.label}.`}}return null}function S(t,e){if(!e)return true;try{return new RegExp(e,"u").test(t)}catch{return true}}function Z(t){if(!t)return null;try{return new RegExp(t,"u")}catch{return null}}function ae(t,e){let n=t.split(/[\s"'`()<>[\]{},;:=!?&]+/).map(a=>a.replace(/\.+$/,"")).filter(Boolean),r=null,o=new Set;for(let a of e)for(let d of W(a)){let g=Z(d.pattern);for(let u of g?n:[])g.test(u)&&(r??={plugin:a,label:d.label},o.add(u));}return r?{...r,tokens:[...o]}:null}var _=null,q=0,L=null,N=new Set;function B(t){_=t,N.forEach(e=>e());}function ne(t){return N.add(t),()=>N.delete(t)}function me(t,e,n,r){let{connect:o}=e;if(o?.type!=="api-token"&&o?.type!=="credentials")return O(t,e.id,n,r).then(()=>true);L?.();let a=++q,d=r?.connectionId?{connectionId:r.connectionId}:{};return new Promise(g=>{let u=c=>{_?.id===a&&B(null),q===a&&(L=null),g(c);},m=o.type==="api-token"?{kind:"token",id:a,plugin:{...e,connect:o},submit:async c=>{await t.connectPluginToken({pluginId:e.id,scope:n,token:c,...d});},settle:u}:{kind:"credentials",id:a,plugin:{...e,connect:o},submit:async(c,f)=>{await t.connectPluginCredentials({pluginId:e.id,scope:n,method:c,values:f,...d});},settle:u};L=()=>u(false),setTimeout(()=>{q===a&&B(m);});})}function oe(t){if(!t)return null;try{let e=new URL(t);return e.protocol==="https:"?e.href:null}catch{return null}}function ke(){let t=useSyncExternalStore(ne,()=>_,()=>null);return t?t.kind==="token"?jsx(le,{request:t},t.id):jsx(re,{request:t},t.id):null}function $({id:t,message:e}){return e?jsx("p",{className:"fk:text-sm fk:text-destructive",id:t,children:e}):null}function V({href:t,label:e}){let n=oe(t);return n?jsxs("a",{className:"fk:inline-flex fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground fk:underline-offset-4 fk:hover:underline",href:n,rel:"noreferrer",target:"_blank",children:[e,jsx(ExternalLinkIcon,{className:"fk:size-3.5"})]}):null}function re({request:t$1}){let{connect:e,name:n}=t$1.plugin,r$1=useId(),[o,a]=useState(e.methods[0]?.key??null),[d,g]=useState({}),[u,m]=useState(null),[c$1,f]=useState(false),k$1=M(e,o),h=e.methods.find(l=>l.key===o)??null,v=z(k$1,d);async function P(l){if(l.preventDefault(),c$1)return;let C=X(k$1,d);if(C){m(C);return}f(true),m(null);try{await t$1.submit(o??void 0,Object.fromEntries(k$1.map(i=>[i.key,d[i.key]?.trim()??""]).filter(([,i])=>i))),g({}),t$1.settle(!0);}catch(i){m({field:null,message:i instanceof Error?i.message:`${n} could not be connected.`});}finally{f(false);}}return jsx(k,{open:true,onOpenChange:l=>{!l&&!c$1&&t$1.settle(false);},children:jsx(p,{children:jsxs("form",{className:"fk:flex fk:flex-col fk:gap-4",onSubmit:l=>{P(l);},children:[jsxs(q$1,{children:[jsxs(s,{children:["Connect ",n]}),jsxs(t,{children:[e.description," Flexkit checks the credentials with ",n,", stores them encrypted and sends them only to Flexkit's own ",n," server; the agent can use the tools but never sees them."]})]}),e.methods.length>1?jsx("div",{className:"fk:space-y-1.5",role:"group","aria-label":"How to connect",children:e.methods.map(l=>jsxs("button",{"aria-pressed":o===l.key,className:`fk:flex fk:w-full fk:flex-col fk:rounded-lg fk:border fk:px-3 fk:py-2 fk:text-left fk:corner-squircle ${o===l.key?"fk:border-primary fk:bg-primary/5":"fk:border-border fk:hover:bg-muted/60"}`,disabled:c$1,onClick:()=>{a(l.key),m(null);},type:"button",children:[jsx("span",{className:"fk:text-sm fk:font-medium",children:l.label}),l.description?jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:l.description}):null]},l.key))}):h?.description?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",children:h.description}):null,k$1.map((l,C)=>{let i=`${r$1}-${l.key}`,y=u?.field===l.key?u.message:null;return jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx("label",{className:"fk:text-sm fk:font-medium",htmlFor:i,children:l.label}),jsx(b,{"aria-describedby":y?`${i}-error`:l.help?`${i}-help`:void 0,"aria-invalid":y?true:void 0,autoComplete:"off",autoFocus:C===0,disabled:c$1,id:i,placeholder:l.placeholder??void 0,spellCheck:false,type:l.kind==="secret"?"password":"text",value:d[l.key]??"",onChange:j=>{g(Y=>({...Y,[l.key]:j.target.value})),m(null);}}),l.help&&!y?jsx("p",{className:"fk:text-sm fk:text-muted-foreground",id:`${i}-help`,children:l.help}):null,jsx($,{id:`${i}-error`,message:y})]},l.key)}),jsx($,{id:`${r$1}-error`,message:u?.field===null?u.message:null}),jsx(V,{href:e.helpUrl,label:`How to set up ${n}`}),jsxs(r,{children:[jsx(c,{disabled:c$1,size:"sm",type:"button",variant:"outline",onClick:()=>t$1.settle(false),children:"Cancel"}),jsxs(c,{disabled:c$1||!v,size:"sm",type:"submit",children:[c$1?jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}):null,"Connect"]})]})]})})})}function le({request:t$1}){let{connect:e,name:n}=t$1.plugin,r$1=useId(),[o,a]=useState(""),[d,g]=useState(null),[u,m]=useState(false);async function c$1(f){f.preventDefault();let k=o.trim();if(!(u||!k)){if(!S(k,e.pattern)){g(`That does not look like a ${e.tokenLabel}.`);return}m(true),g(null);try{await t$1.submit(k),a(""),t$1.settle(!0);}catch(h){g(h instanceof Error?h.message:`${n} could not be connected.`);}finally{m(false);}}}return jsx(k,{open:true,onOpenChange:f=>{!f&&!u&&t$1.settle(false);},children:jsx(p,{children:jsxs("form",{className:"fk:flex fk:flex-col fk:gap-4",onSubmit:f=>{c$1(f);},children:[jsxs(q$1,{children:[jsxs(s,{children:["Connect ",n]}),jsxs(t,{children:["Paste a ",e.tokenLabel,". Flexkit stores it encrypted and sends it only to ",n,"; the agent can use"," ",n,"'s tools but never sees the token. Give it read access only, unless the agent should change things in ",n,"."]})]}),jsxs("div",{className:"fk:flex fk:flex-col fk:gap-2",children:[jsx("label",{className:"fk:text-sm fk:font-medium",htmlFor:r$1,children:e.tokenLabel}),jsx(b,{"aria-describedby":d?`${r$1}-error`:void 0,"aria-invalid":d?true:void 0,autoComplete:"off",autoFocus:true,disabled:u,id:r$1,placeholder:e.placeholder??void 0,spellCheck:false,type:"password",value:o,onChange:f=>{a(f.target.value),g(null);}}),jsx($,{id:`${r$1}-error`,message:d}),jsx(V,{href:e.helpUrl,label:`How to create a ${e.tokenLabel}`})]}),jsxs(r,{children:[jsx(c,{disabled:u,size:"sm",type:"button",variant:"outline",onClick:()=>t$1.settle(false),children:"Cancel"}),jsxs(c,{disabled:u||!o.trim(),size:"sm",type:"submit",children:[u?jsx(LoaderCircle,{className:"fk:size-4 fk:animate-spin"}):null,"Connect"]})]})]})})})}export{R as a,O as b,ae as c,me as d,ke as e};//# sourceMappingURL=chunk-L5Z56DDM.js.map
2
+ //# sourceMappingURL=chunk-L5Z56DDM.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/apps/ai/plugin-oauth.ts","../src/apps/ai/plugin-token-format.ts","../src/apps/ai/plugin-token.tsx"],"names":["OAUTH_START_PATH","PluginAccountMismatchError","httpsUrl","value","url","trustedPluginOAuthTargets","authorizeUrl","completionOrigin","origin","getPlatformOrigin","authorize","completion","connectPluginPopup","api","pluginId","scope","options","popup","transaction","error","targets","expectedOrigin","resolve","reject","polling","finished","handedOff","finish","interval","timeout","onMessage","poll","status","event","payload","pluginSecretFormats","plugin","connect","method","field","credentialFormFields","selected","item","credentialFormComplete","fields","values","credentialFormError","matchesTokenPattern","token","pattern","compileTokenPattern","findPastedPluginToken","text","plugins","words","word","found","tokens","format","request","lastRequestId","cancelLatest","listeners","setRequest","next","listener","subscribe","connectPlugin","id","connectionId","settle","connected","httpsHref","PluginTokenDialogHost","current","useSyncExternalStore","jsx","PluginTokenDialog","PluginCredentialsDialog","FieldError","message","HelpLink","href","label","safeHref","jsxs","ExternalLinkIcon","name","formId","useId","setMethod","useState","setValues","setError","saving","setSaving","selectedMethod","ready","save","problem","failure","Dialog","open","DialogContent","DialogHeader","DialogTitle","DialogDescription","index","inputId","fieldError","Input","previous","DialogFooter","Button","LoaderCircle","setToken"],"mappings":"sVAGA,IAAMA,CAAAA,CAAmB,sBAAA,CAGZC,CAAAA,CAAN,cAAyC,KAAM,CAC3C,IAAA,CAAO,kBAAA,CAEhB,WAAA,EAAc,CACZ,KAAA,CAAM,kFAAkF,EACxF,IAAA,CAAK,IAAA,CAAO,6BACd,CACF,EAEA,SAASC,CAAAA,CAASC,CAAAA,CAA2B,CAC3C,IAAIC,CAAAA,CAEJ,GAAI,CACFA,CAAAA,CAAM,IAAI,GAAA,CAAID,CAAK,EACrB,CAAA,KAAQ,CACN,OAAO,IACT,CAEA,OAAIC,CAAAA,CAAI,QAAA,GAAa,QAAA,EAAYA,CAAAA,CAAI,QAAA,GAAa,IAAMA,CAAAA,CAAI,QAAA,GAAa,EAAA,CAChE,IAAA,CAGFA,CACT,CAGA,SAASC,CAAAA,CACPC,CAAAA,CACAC,CAAAA,CACyC,CACzC,IAAMC,CAAAA,CAASC,GAAAA,GACTC,CAAAA,CAAYR,CAAAA,CAASI,CAAY,CAAA,CACjCK,CAAAA,CAAaT,CAAAA,CAASK,CAAgB,CAAA,CAU5C,OARI,CAACG,CAAAA,EAAa,CAACC,CAAAA,EAIfD,CAAAA,CAAU,SAAWF,CAAAA,EAAUE,CAAAA,CAAU,QAAA,GAAaV,CAAAA,EAItDW,CAAAA,CAAW,MAAA,GAAWH,CAAAA,EAAUG,CAAAA,CAAW,QAAA,GAAa,GAAA,CACnD,IAAA,CAGF,CAAE,IAAA,CAAMD,CAAAA,CAAU,KAAM,MAAA,CAAAF,CAAO,CACxC,CAGA,eAAsBI,CAAAA,CACpBC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACAC,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plugin-types';\n\nconst OAUTH_START_PATH = '/plugins/oauth/start';\n\n/** A Reconnect was completed with a different provider account than the one being reconnected. */\nexport class PluginAccountMismatchError extends Error {\n readonly code = 'account_mismatch';\n\n constructor() {\n super('You signed in with a different account. Use \"Connect another account\" to add it.');\n this.name = 'PluginAccountMismatchError';\n }\n}\n\nfunction httpsUrl(value: string): URL | null {\n let url: URL;\n\n try {\n url = new URL(value);\n } catch {\n return null;\n }\n\n if (url.protocol !== 'https:' || url.username !== '' || url.password !== '') {\n return null;\n }\n\n return url;\n}\n\n/** Popup navigation and postMessage stay on the platform OAuth start page. */\nfunction trustedPluginOAuthTargets(\n authorizeUrl: string,\n completionOrigin: string\n): { href: string; origin: string } | null {\n const origin = getPlatformOrigin();\n const authorize = httpsUrl(authorizeUrl);\n const completion = httpsUrl(completionOrigin);\n\n if (!authorize || !completion) {\n return null;\n }\n\n if (authorize.origin !== origin || authorize.pathname !== OAUTH_START_PATH) {\n return null;\n }\n\n if (completion.origin !== origin || completion.pathname !== '/') {\n return null;\n }\n\n return { href: authorize.href, origin };\n}\n\n/** Must be called directly from the click handler so browsers allow the popup. */\nexport async function connectPluginPopup(\n api: ApiClient,\n pluginId: string,\n scope: PluginScope,\n options?: { connectionId?: string }\n): Promise<void> {\n const popup = window.open('about:blank', `flexkit-plugin-${crypto.randomUUID()}`, 'popup,width=560,height=720');\n\n if (!popup) {\n throw new Error('Allow popups for Studio, then connect again.');\n }\n\n let transaction: Awaited<ReturnType<ApiClient['connectPlugins']>>;\n\n try {\n transaction = await api.connectPlugins({\n pluginId,\n scope,\n studioOrigin: window.location.origin,\n ...(options?.connectionId ? { connectionId: options.connectionId } : {}),\n });\n } catch (error) {\n popup.close();\n throw error;\n }\n\n const targets = trustedPluginOAuthTargets(transaction.authorizeUrl, transaction.completionOrigin);\n\n if (!targets) {\n popup.close();\n throw new Error('Connection could not be started.');\n }\n\n const expectedOrigin = targets.origin;\n\n await new Promise<void>((resolve, reject) => {\n let polling = false;\n let finished = false;\n // Once the popup leaves for the provider, `popup.closed` says nothing:\n // providers isolate their pages (Cross-Origin-Opener-Policy), which severs\n // the opener and reports the window as closed while it is open. From then\n // on only the transaction's status (and the timeout) ends the wait.\n let handedOff = false;\n const finish = (error?: Error) => {\n if (finished) {\n return;\n }\n\n finished = true;\n window.clearInterval(interval);\n window.clearTimeout(timeout);\n window.removeEventListener('message', onMessage);\n popup.close();\n\n if (error) {\n reject(error);\n\n return;\n }\n\n resolve();\n };\n const poll = async () => {\n if (polling || finished) {\n return;\n }\n\n polling = true;\n let status: Awaited<ReturnType<ApiClient['pluginOAuthStatus']>>;\n\n try {\n status = await api.pluginOAuthStatus(transaction.transactionId);\n } catch {\n polling = false;\n\n return;\n }\n\n polling = false;\n\n if (status.status === 'complete') {\n finish();\n\n return;\n }\n\n if (!handedOff && popup.closed && status.status === 'pending') {\n finish(new Error('Connection window was closed.'));\n\n return;\n }\n\n if (status.status === 'failed' || new Date(status.expires_at).getTime() < Date.now()) {\n finish(new Error('Connection was not completed. Please try again.'));\n }\n };\n const onMessage = (event: MessageEvent<unknown>) => {\n if (event.origin !== expectedOrigin || event.source !== popup || !event.data || typeof event.data !== 'object') {\n return;\n }\n\n const payload = event.data as { type?: string; transactionId?: string; status?: string; error?: string };\n\n if (payload.type === 'flexkit:plugin-oauth-ready' && payload.transactionId === transaction.transactionId) {\n handedOff = true;\n popup.postMessage(\n {\n type: 'flexkit:plugin-oauth-start',\n transactionId: transaction.transactionId,\n ticket: transaction.launchTicket,\n },\n expectedOrigin\n );\n\n return;\n }\n\n if (payload.type === 'flexkit:plugin-oauth' && payload.transactionId === transaction.transactionId) {\n if (payload.status === 'failed' && payload.error === 'account_mismatch') {\n finish(new PluginAccountMismatchError());\n\n return;\n }\n\n void poll();\n }\n };\n const interval = window.setInterval(() => {\n void poll();\n }, 2000);\n const timeout = window.setTimeout(() => finish(new Error('Connection timed out. Please try again.')), 600_000);\n window.addEventListener('message', onMessage);\n popup.location.href = targets.href;\n });\n}\n","import type { MarketplacePlugin, PluginCredentialField, PluginCredentialsConnect } from './plugin-types';\n\nexport type ConnectablePlugin = Pick<MarketplacePlugin, 'connect' | 'id' | 'name'>;\n\n/** Longer than any credential a provider issues; the server rejects more. */\nexport const MAX_CREDENTIAL_VALUE_LENGTH = 4096;\n\n/**\n * The secrets a plugin's connect form takes that can be recognized on their\n * own (a distinctive prefix, say), each with that pattern and what to call it.\n */\nexport function pluginSecretFormats(plugin: ConnectablePlugin): Array<{ label: string; pattern: string }> {\n const { connect } = plugin;\n\n if (connect?.type === 'api-token') {\n return connect.pattern ? [{ label: connect.tokenLabel, pattern: connect.pattern }] : [];\n }\n\n if (connect?.type === 'credentials') {\n return [...connect.fields, ...connect.methods.flatMap((method) => method.fields)]\n .filter((field) => field.kind === 'secret' && field.detect)\n .map((field) => ({ label: field.label, pattern: field.detect! }));\n }\n\n return [];\n}\n\n/** The fields a credentials form shows: the shared ones, then those of the chosen method. */\nexport function credentialFormFields(connect: PluginCredentialsConnect, method: string | null): PluginCredentialField[] {\n const selected = connect.methods.find((item) => item.key === method);\n\n return [...connect.fields, ...(selected?.fields ?? [])];\n}\n\n/** Whether every required field has a value: what the Connect button waits for. */\nexport function credentialFormComplete(\n fields: readonly PluginCredentialField[],\n values: { [key: string]: string }\n): boolean {\n return fields.every((field) => !field.required || Boolean(values[field.key]?.trim()));\n}\n\n/** The first problem with the values entered, or null when they can be submitted. */\nexport function credentialFormError(\n fields: readonly PluginCredentialField[],\n values: { [key: string]: string }\n): { field: string; message: string } | null {\n for (const field of fields) {\n const value = values[field.key]?.trim() ?? '';\n\n if (!value) {\n if (field.required) {\n return { field: field.key, message: `Enter the ${field.label}.` };\n }\n\n continue;\n }\n\n if (value.length > MAX_CREDENTIAL_VALUE_LENGTH) {\n return { field: field.key, message: `The ${field.label} is too long; paste only the value.` };\n }\n\n if (!matchesTokenPattern(value, field.pattern)) {\n return { field: field.key, message: `That is not a valid ${field.label}.` };\n }\n }\n\n return null;\n}\n\nexport function matchesTokenPattern(token: string, pattern: string | null): boolean {\n if (!pattern) {\n return true;\n }\n\n try {\n return new RegExp(pattern, 'u').test(token);\n } catch {\n // The server validates the pattern when it admits the plugin; never block on a bad one here.\n return true;\n }\n}\n\n/** A pattern that compiles; an empty or broken one detects nothing rather than every word. */\nfunction compileTokenPattern(pattern: string | null): RegExp | null {\n if (!pattern) {\n return null;\n }\n\n try {\n return new RegExp(pattern, 'u');\n } catch {\n return null;\n }\n}\n\n/**\n * The first plugin whose secret format `text` contains, if any, with every\n * secret-shaped word in the message and what the plugin calls that secret: a\n * token pasted into the chat would be stored in the conversation and sent to\n * the model.\n */\nexport function findPastedPluginToken(\n text: string,\n plugins: readonly ConnectablePlugin[]\n): { plugin: ConnectablePlugin; tokens: string[]; label: string } | null {\n // A token is often glued to a label (`token=…`, `key: …`) or wrapped in\n // brackets, quotes or a sentence's punctuation; none of those are part of it.\n const words = text\n .split(/[\\s\"'`()<>[\\]{},;:=!?&]+/)\n .map((word) => word.replace(/\\.+$/, ''))\n .filter(Boolean);\n let found: { plugin: ConnectablePlugin; label: string } | null = null;\n const tokens = new Set<string>();\n\n for (const plugin of plugins) {\n for (const format of pluginSecretFormats(plugin)) {\n const pattern = compileTokenPattern(format.pattern);\n\n for (const word of pattern ? words : []) {\n if (pattern!.test(word)) {\n found ??= { plugin, label: format.label };\n tokens.add(word);\n }\n }\n }\n }\n\n return found ? { ...found, tokens: [...tokens] } : null;\n}\n","import type { FormEvent, JSX } from 'react';\nimport { useId, useState, useSyncExternalStore } from 'react';\nimport { ExternalLinkIcon, LoaderCircle } from 'lucide-react';\nimport {\n Button,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n Input,\n} from '../../ui';\nimport type { ApiClient } from './api';\nimport { connectPluginPopup } from './plugin-oauth';\nimport {\n credentialFormComplete,\n credentialFormError,\n credentialFormFields,\n matchesTokenPattern,\n type ConnectablePlugin,\n} from './plugin-token-format';\nimport type { PluginApiTokenConnect, PluginCredentialsConnect, PluginScope } from './plugin-types';\n\ninterface TokenRequest {\n id: number;\n plugin: ConnectablePlugin & { connect: PluginApiTokenConnect };\n /** Saves the token; rejects with a message the dialog shows next to the field. */\n submit: (_token: string) => Promise<void>;\n settle: (_connected: boolean) => void;\n}\n\ninterface CredentialsRequest {\n id: number;\n plugin: ConnectablePlugin & { connect: PluginCredentialsConnect };\n /** Saves the form; rejects with a message the dialog shows under the fields. */\n submit: (_method: string | undefined, _values: { [key: string]: string }) => Promise<void>;\n settle: (_connected: boolean) => void;\n}\n\ntype FormRequest = ({ kind: 'token' } & TokenRequest) | ({ kind: 'credentials' } & CredentialsRequest);\n\n/** The one open connect form, outside React so any connect button can open it. */\nlet request: FormRequest | null = null;\nlet lastRequestId = 0;\n/** Cancels the latest request, whether its dialog has opened yet or not. */\nlet cancelLatest: (() => void) | null = null;\nconst listeners = new Set<() => void>();\n\nfunction setRequest(next: FormRequest | null): void {\n request = next;\n listeners.forEach((listener) => listener());\n}\n\nfunction subscribe(listener: () => void): () => void {\n listeners.add(listener);\n\n return () => listeners.delete(listener);\n}\n\n/**\n * Connects a plugin: a sign-in popup for OAuth plugins, the token dialog for\n * plugins that take a pasted token, the credentials dialog for plugins that\n * take the credentials of an app the user created at the provider. Resolves\n * `false` when the user closes a dialog without connecting.\n *\n * Call it straight from a click handler: browsers only allow the popup there.\n */\nexport function connectPlugin(\n api: ApiClient,\n plugin: ConnectablePlugin,\n scope: PluginScope,\n options?: { connectionId?: string }\n): Promise<boolean> {\n const { connect } = plugin;\n\n if (connect?.type !== 'api-token' && connect?.type !== 'credentials') {\n return connectPluginPopup(api, plugin.id, scope, options).then(() => true);\n }\n\n // Opening a second dialog closes the first, as if cancelled.\n cancelLatest?.();\n\n const id = ++lastRequestId;\n const connectionId = options?.connectionId ? { connectionId: options.connectionId } : {};\n\n return new Promise<boolean>((resolve) => {\n const settle = (connected: boolean): void => {\n // A save still running for a replaced dialog must not close its successor.\n if (request?.id === id) {\n setRequest(null);\n }\n\n if (lastRequestId === id) {\n cancelLatest = null;\n }\n\n resolve(connected);\n };\n const next: FormRequest =\n connect.type === 'api-token'\n ? {\n kind: 'token',\n id,\n plugin: { ...plugin, connect },\n submit: async (token) => {\n await api.connectPluginToken({ pluginId: plugin.id, scope, token, ...connectionId });\n },\n settle,\n }\n : {\n kind: 'credentials',\n id,\n plugin: { ...plugin, connect },\n submit: async (method, values) => {\n await api.connectPluginCredentials({ pluginId: plugin.id, scope, method, values, ...connectionId });\n },\n settle,\n };\n\n cancelLatest = () => settle(false);\n\n // Open after the current event: a menu item that started this closes first\n // and returns focus to its trigger, which would take it from the first field.\n setTimeout(() => {\n if (lastRequestId === id) {\n setRequest(next);\n }\n });\n });\n}\n\nfunction httpsHref(value: string | null): string | null {\n if (!value) {\n return null;\n }\n\n try {\n const url = new URL(value);\n\n return url.protocol === 'https:' ? url.href : null;\n } catch {\n return null;\n }\n}\n\n/** Mounted once by the Studio layout; renders the dialog `connectPlugin` opens for token and credentials plugins. */\nexport function PluginTokenDialogHost(): JSX.Element | null {\n const current = useSyncExternalStore(\n subscribe,\n () => request,\n () => null\n );\n\n if (!current) {\n return null;\n }\n\n // A new key per request resets the fields, so a secret never outlives its dialog.\n return current.kind === 'token' ? (\n <PluginTokenDialog key={current.id} request={current} />\n ) : (\n <PluginCredentialsDialog key={current.id} request={current} />\n );\n}\n\nfunction FieldError({ id, message }: { id: string; message: string | null }): JSX.Element | null {\n return message ? (\n <p className=\"fk:text-sm fk:text-destructive\" id={id}>\n {message}\n </p>\n ) : null;\n}\n\nfunction HelpLink({ href, label }: { href: string | null; label: string }): JSX.Element | null {\n const safeHref = httpsHref(href);\n\n return safeHref ? (\n <a\n className=\"fk:inline-flex fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground fk:underline-offset-4 fk:hover:underline\"\n href={safeHref}\n rel=\"noreferrer\"\n target=\"_blank\"\n >\n {label}\n <ExternalLinkIcon className=\"fk:size-3.5\" />\n </a>\n ) : null;\n}\n\nfunction PluginCredentialsDialog({ request: current }: { request: CredentialsRequest }): JSX.Element {\n const { connect, name } = current.plugin;\n const formId = useId();\n const [method, setMethod] = useState<string | null>(connect.methods[0]?.key ?? null);\n const [values, setValues] = useState<{ [key: string]: string }>({});\n const [error, setError] = useState<{ field: string | null; message: string } | null>(null);\n const [saving, setSaving] = useState(false);\n const fields = credentialFormFields(connect, method);\n const selectedMethod = connect.methods.find((item) => item.key === method) ?? null;\n // Submitting surfaces which field is malformed; the button only waits for the required values.\n const ready = credentialFormComplete(fields, values);\n\n async function save(event: FormEvent): Promise<void> {\n event.preventDefault();\n\n if (saving) {\n return;\n }\n\n const problem = credentialFormError(fields, values);\n\n if (problem) {\n setError(problem);\n\n return;\n }\n\n setSaving(true);\n setError(null);\n\n try {\n await current.submit(\n method ?? undefined,\n Object.fromEntries(fields.map((field) => [field.key, values[field.key]?.trim() ?? '']).filter(([, value]) => value))\n );\n setValues({});\n current.settle(true);\n } catch (failure) {\n setError({ field: null, message: failure instanceof Error ? failure.message : `${name} could not be connected.` });\n } finally {\n setSaving(false);\n }\n }\n\n return (\n <Dialog\n open\n onOpenChange={(open) => {\n if (!open && !saving) {\n current.settle(false);\n }\n }}\n >\n <DialogContent>\n <form className=\"fk:flex fk:flex-col fk:gap-4\" onSubmit={(event) => void save(event)}>\n <DialogHeader>\n <DialogTitle>Connect {name}</DialogTitle>\n <DialogDescription>\n {connect.description} Flexkit checks the credentials with {name}, stores them encrypted and sends them\n only to Flexkit&apos;s own {name} server; the agent can use the tools but never sees them.\n </DialogDescription>\n </DialogHeader>\n {connect.methods.length > 1 ? (\n <div className=\"fk:space-y-1.5\" role=\"group\" aria-label=\"How to connect\">\n {connect.methods.map((item) => (\n <button\n aria-pressed={method === item.key}\n className={`fk:flex fk:w-full fk:flex-col fk:rounded-lg fk:border fk:px-3 fk:py-2 fk:text-left fk:corner-squircle ${\n method === item.key ? 'fk:border-primary fk:bg-primary/5' : 'fk:border-border fk:hover:bg-muted/60'\n }`}\n disabled={saving}\n key={item.key}\n onClick={() => {\n setMethod(item.key);\n setError(null);\n }}\n type=\"button\"\n >\n <span className=\"fk:text-sm fk:font-medium\">{item.label}</span>\n {item.description ? (\n <span className=\"fk:text-xs fk:text-muted-foreground\">{item.description}</span>\n ) : null}\n </button>\n ))}\n </div>\n ) : selectedMethod?.description ? (\n <p className=\"fk:text-sm fk:text-muted-foreground\">{selectedMethod.description}</p>\n ) : null}\n {fields.map((field, index) => {\n const inputId = `${formId}-${field.key}`;\n const fieldError = error?.field === field.key ? error.message : null;\n\n return (\n <div className=\"fk:flex fk:flex-col fk:gap-2\" key={field.key}>\n <label className=\"fk:text-sm fk:font-medium\" htmlFor={inputId}>\n {field.label}\n </label>\n <Input\n aria-describedby={fieldError ? `${inputId}-error` : field.help ? `${inputId}-help` : undefined}\n aria-invalid={fieldError ? true : undefined}\n autoComplete=\"off\"\n autoFocus={index === 0}\n disabled={saving}\n id={inputId}\n placeholder={field.placeholder ?? undefined}\n spellCheck={false}\n type={field.kind === 'secret' ? 'password' : 'text'}\n value={values[field.key] ?? ''}\n onChange={(event) => {\n setValues((previous) => ({ ...previous, [field.key]: event.target.value }));\n setError(null);\n }}\n />\n {field.help && !fieldError ? (\n <p className=\"fk:text-sm fk:text-muted-foreground\" id={`${inputId}-help`}>\n {field.help}\n </p>\n ) : null}\n <FieldError id={`${inputId}-error`} message={fieldError} />\n </div>\n );\n })}\n <FieldError id={`${formId}-error`} message={error?.field === null ? error.message : null} />\n <HelpLink href={connect.helpUrl} label={`How to set up ${name}`} />\n <DialogFooter>\n <Button disabled={saving} size=\"sm\" type=\"button\" variant=\"outline\" onClick={() => current.settle(false)}>\n Cancel\n </Button>\n <Button disabled={saving || !ready} size=\"sm\" type=\"submit\">\n {saving ? <LoaderCircle className=\"fk:size-4 fk:animate-spin\" /> : null}\n Connect\n </Button>\n </DialogFooter>\n </form>\n </DialogContent>\n </Dialog>\n );\n}\n\nfunction PluginTokenDialog({ request: current }: { request: TokenRequest }): JSX.Element {\n const { connect, name } = current.plugin;\n const inputId = useId();\n const [token, setToken] = useState('');\n const [error, setError] = useState<string | null>(null);\n const [saving, setSaving] = useState(false);\n\n async function save(event: FormEvent): Promise<void> {\n event.preventDefault();\n const value = token.trim();\n\n if (saving || !value) {\n return;\n }\n\n if (!matchesTokenPattern(value, connect.pattern)) {\n setError(`That does not look like a ${connect.tokenLabel}.`);\n\n return;\n }\n\n setSaving(true);\n setError(null);\n\n try {\n await current.submit(value);\n setToken('');\n current.settle(true);\n } catch (failure) {\n setError(failure instanceof Error ? failure.message : `${name} could not be connected.`);\n } finally {\n setSaving(false);\n }\n }\n\n return (\n <Dialog\n open\n onOpenChange={(open) => {\n if (!open && !saving) {\n current.settle(false);\n }\n }}\n >\n <DialogContent>\n <form className=\"fk:flex fk:flex-col fk:gap-4\" onSubmit={(event) => void save(event)}>\n <DialogHeader>\n <DialogTitle>Connect {name}</DialogTitle>\n <DialogDescription>\n Paste a {connect.tokenLabel}. Flexkit stores it encrypted and sends it only to {name}; the agent can use{' '}\n {name}&apos;s tools but never sees the token. Give it read access only, unless the agent should change\n things in {name}.\n </DialogDescription>\n </DialogHeader>\n <div className=\"fk:flex fk:flex-col fk:gap-2\">\n <label className=\"fk:text-sm fk:font-medium\" htmlFor={inputId}>\n {connect.tokenLabel}\n </label>\n <Input\n aria-describedby={error ? `${inputId}-error` : undefined}\n aria-invalid={error ? true : undefined}\n autoComplete=\"off\"\n autoFocus\n disabled={saving}\n id={inputId}\n placeholder={connect.placeholder ?? undefined}\n spellCheck={false}\n type=\"password\"\n value={token}\n onChange={(event) => {\n setToken(event.target.value);\n setError(null);\n }}\n />\n <FieldError id={`${inputId}-error`} message={error} />\n <HelpLink href={connect.helpUrl} label={`How to create a ${connect.tokenLabel}`} />\n </div>\n <DialogFooter>\n <Button disabled={saving} size=\"sm\" type=\"button\" variant=\"outline\" onClick={() => current.settle(false)}>\n Cancel\n </Button>\n <Button disabled={saving || !token.trim()} size=\"sm\" type=\"submit\">\n {saving ? <LoaderCircle className=\"fk:size-4 fk:animate-spin\" /> : null}\n Connect\n </Button>\n </DialogFooter>\n </form>\n </DialogContent>\n </Dialog>\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/apps/ai/plugin-oauth.ts","../src/apps/ai/plugin-token-format.ts","../src/apps/ai/plugin-token.tsx"],"names":["OAUTH_START_PATH","PluginAccountMismatchError","httpsUrl","value","url","trustedPluginOAuthTargets","authorizeUrl","completionOrigin","origin","getPlatformOrigin","authorize","completion","connectPluginPopup","api","pluginId","scope","options","popup","transaction","error","targets","expectedOrigin","resolve","reject","polling","finished","handedOff","finish","interval","timeout","onMessage","poll","status","event","payload","pluginSecretFormats","plugin","connect","method","field","credentialFormFields","selected","item","credentialFormComplete","fields","values","credentialFormError","matchesTokenPattern","token","pattern","compileTokenPattern","findPastedPluginToken","text","plugins","words","word","found","tokens","format","request","lastRequestId","cancelLatest","listeners","setRequest","next","listener","subscribe","connectPlugin","id","connectionId","settle","connected","httpsHref","PluginTokenDialogHost","current","useSyncExternalStore","jsx","PluginTokenDialog","PluginCredentialsDialog","FieldError","message","HelpLink","href","label","safeHref","jsxs","ExternalLinkIcon","name","formId","useId","setMethod","useState","setValues","setError","saving","setSaving","selectedMethod","ready","save","problem","failure","Dialog","open","DialogContent","DialogHeader","DialogTitle","DialogDescription","index","inputId","fieldError","Input","previous","DialogFooter","Button","LoaderCircle","setToken"],"mappings":"sVAGA,IAAMA,CAAAA,CAAmB,sBAAA,CAGZC,CAAAA,CAAN,cAAyC,KAAM,CAC3C,IAAA,CAAO,kBAAA,CAEhB,WAAA,EAAc,CACZ,KAAA,CAAM,kFAAkF,EACxF,IAAA,CAAK,IAAA,CAAO,6BACd,CACF,EAEA,SAASC,CAAAA,CAASC,CAAAA,CAA2B,CAC3C,IAAIC,CAAAA,CAEJ,GAAI,CACFA,CAAAA,CAAM,IAAI,GAAA,CAAID,CAAK,EACrB,CAAA,KAAQ,CACN,OAAO,IACT,CAEA,OAAIC,CAAA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AApC,GAAAA,CAACqC,CAAAA,CAAA,CAAO,SAAUnB,CAAAA,CAAQ,IAAA,CAAK,IAAA,CAAK,IAAA,CAAK,QAAA,CAAS,OAAA,CAAQ,SAAA,CAAU,OAAA,CAAS,IAAMpB,GAAAA,CAAQ,MAAA,CAAO,KAAK,CAAA,CAAG,QAAA,CAAA,QAAA,CAE1G,EACAW,IAAAA,CAAC4B,CAAAA,CAAA,CAAO,QAAA,CAAUnB,CAAAA,EAAU,CAAC9C,CAAAA,CAAM,IAAA,EAAK,CAAG,IAAA,CAAK,IAAA,CAAK,IAAA,CAAK,QAAA,CACvD,QAAA,CAAA,CAAA8C,EAASlB,GAAAA,CAACsC,YAAAA,CAAA,CAAa,SAAA,CAAU,2BAAA,CAA4B,CAAA,CAAK,IAAA,CAAK,SAAA,CAAA,CAE1E,CAAA,CAAA,CACF,CAAA,CAAA,CACF,CAAA,CACF,CAAA,CACF,CAEJ","file":"chunk-L5Z56DDM.js","sourcesContent":["import { getPlatformOrigin, type ApiClient } from './api';\nimport type { PluginScope } from './plugin-types';\n\nconst OAUTH_START_PATH = '/plugins/oauth/start';\n\n/** A Reconnect was completed with a different provider account than the one being reconnected. */\nexport class PluginAccountMismatchError extends Error {\n readonly code = 'account_mismatch';\n\n constructor() {\n super('You signed in with a different account. Use \"Connect another account\" to add it.');\n this.name = 'PluginAccountMismatchError';\n }\n}\n\nfunction httpsUrl(value: string): URL | null {\n let url: URL;\n\n try {\n url = new URL(value);\n } catch {\n return null;\n }\n\n if (url.protocol !== 'https:' || url.username !== '' || url.password !== '') {\n return null;\n }\n\n return url;\n}\n\n/** Popup navigation and postMessage stay on the platform OAuth start page. */\nfunction trustedPluginOAuthTargets(\n authorizeUrl: string,\n completionOrigin: string\n): { href: string; origin: string } | null {\n const origin = getPlatformOrigin();\n const authorize = httpsUrl(authorizeUrl);\n const completion = httpsUrl(completionOrigin);\n\n if (!authorize || !completion) {\n return null;\n }\n\n if (authorize.origin !== origin || authorize.pathname !== OAUTH_START_PATH) {\n return null;\n }\n\n if (completion.origin !== origin || completion.pathname !== '/') {\n return null;\n }\n\n return { href: authorize.href, origin };\n}\n\n/** Must be called directly from the click handler so browsers allow the popup. */\nexport async function connectPluginPopup(\n api: ApiClient,\n pluginId: string,\n scope: PluginScope,\n options?: { connectionId?: string }\n): Promise<void> {\n const popup = window.open('about:blank', `flexkit-plugin-${crypto.randomUUID()}`, 'popup,width=560,height=720');\n\n if (!popup) {\n throw new Error('Allow popups for Studio, then connect again.');\n }\n\n let transaction: Awaited<ReturnType<ApiClient['connectPlugins']>>;\n\n try {\n transaction = await api.connectPlugins({\n pluginId,\n scope,\n studioOrigin: window.location.origin,\n ...(options?.connectionId ? { connectionId: options.connectionId } : {}),\n });\n } catch (error) {\n popup.close();\n throw error;\n }\n\n const targets = trustedPluginOAuthTargets(transaction.authorizeUrl, transaction.completionOrigin);\n\n if (!targets) {\n popup.close();\n throw new Error('Connection could not be started.');\n }\n\n const expectedOrigin = targets.origin;\n\n await new Promise<void>((resolve, reject) => {\n let polling = false;\n let finished = false;\n // Once the popup leaves for the provider, `popup.closed` says nothing:\n // providers isolate their pages (Cross-Origin-Opener-Policy), which severs\n // the opener and reports the window as closed while it is open. From then\n // on only the transaction's status (and the timeout) ends the wait.\n let handedOff = false;\n const finish = (error?: Error) => {\n if (finished) {\n return;\n }\n\n finished = true;\n window.clearInterval(interval);\n window.clearTimeout(timeout);\n window.removeEventListener('message', onMessage);\n popup.close();\n\n if (error) {\n reject(error);\n\n return;\n }\n\n resolve();\n };\n const poll = async () => {\n if (polling || finished) {\n return;\n }\n\n polling = true;\n let status: Awaited<ReturnType<ApiClient['pluginOAuthStatus']>>;\n\n try {\n status = await api.pluginOAuthStatus(transaction.transactionId);\n } catch {\n polling = false;\n\n return;\n }\n\n polling = false;\n\n if (status.status === 'complete') {\n finish();\n\n return;\n }\n\n if (!handedOff && popup.closed && status.status === 'pending') {\n finish(new Error('Connection window was closed.'));\n\n return;\n }\n\n if (status.status === 'failed' || new Date(status.expires_at).getTime() < Date.now()) {\n finish(new Error('Connection was not completed. Please try again.'));\n }\n };\n const onMessage = (event: MessageEvent<unknown>) => {\n if (event.origin !== expectedOrigin || event.source !== popup || !event.data || typeof event.data !== 'object') {\n return;\n }\n\n const payload = event.data as { type?: string; transactionId?: string; status?: string; error?: string };\n\n if (payload.type === 'flexkit:plugin-oauth-ready' && payload.transactionId === transaction.transactionId) {\n handedOff = true;\n popup.postMessage(\n {\n type: 'flexkit:plugin-oauth-start',\n transactionId: transaction.transactionId,\n ticket: transaction.launchTicket,\n },\n expectedOrigin\n );\n\n return;\n }\n\n if (payload.type === 'flexkit:plugin-oauth' && payload.transactionId === transaction.transactionId) {\n if (payload.status === 'failed' && payload.error === 'account_mismatch') {\n finish(new PluginAccountMismatchError());\n\n return;\n }\n\n void poll();\n }\n };\n const interval = window.setInterval(() => {\n void poll();\n }, 2000);\n const timeout = window.setTimeout(() => finish(new Error('Connection timed out. Please try again.')), 600_000);\n window.addEventListener('message', onMessage);\n popup.location.href = targets.href;\n });\n}\n","import type { MarketplacePlugin, PluginCredentialField, PluginCredentialsConnect } from './plugin-types';\n\nexport type ConnectablePlugin = Pick<MarketplacePlugin, 'connect' | 'id' | 'name'>;\n\n/** Longer than any credential a provider issues; the server rejects more. */\nexport const MAX_CREDENTIAL_VALUE_LENGTH = 4096;\n\n/**\n * The secrets a plugin's connect form takes that can be recognized on their\n * own (a distinctive prefix, say), each with that pattern and what to call it.\n */\nexport function pluginSecretFormats(plugin: ConnectablePlugin): Array<{ label: string; pattern: string }> {\n const { connect } = plugin;\n\n if (connect?.type === 'api-token') {\n return connect.pattern ? [{ label: connect.tokenLabel, pattern: connect.pattern }] : [];\n }\n\n if (connect?.type === 'credentials') {\n return [...connect.fields, ...connect.methods.flatMap((method) => method.fields)]\n .filter((field) => field.kind === 'secret' && field.detect)\n .map((field) => ({ label: field.label, pattern: field.detect! }));\n }\n\n return [];\n}\n\n/** The fields a credentials form shows: the shared ones, then those of the chosen method. */\nexport function credentialFormFields(connect: PluginCredentialsConnect, method: string | null): PluginCredentialField[] {\n const selected = connect.methods.find((item) => item.key === method);\n\n return [...connect.fields, ...(selected?.fields ?? [])];\n}\n\n/** Whether every required field has a value: what the Connect button waits for. */\nexport function credentialFormComplete(\n fields: readonly PluginCredentialField[],\n values: { [key: string]: string }\n): boolean {\n return fields.every((field) => !field.required || Boolean(values[field.key]?.trim()));\n}\n\n/** The first problem with the values entered, or null when they can be submitted. */\nexport function credentialFormError(\n fields: readonly PluginCredentialField[],\n values: { [key: string]: string }\n): { field: string; message: string } | null {\n for (const field of fields) {\n const value = values[field.key]?.trim() ?? '';\n\n if (!value) {\n if (field.required) {\n return { field: field.key, message: `Enter the ${field.label}.` };\n }\n\n continue;\n }\n\n if (value.length > MAX_CREDENTIAL_VALUE_LENGTH) {\n return { field: field.key, message: `The ${field.label} is too long; paste only the value.` };\n }\n\n if (!matchesTokenPattern(value, field.pattern)) {\n return { field: field.key, message: `That is not a valid ${field.label}.` };\n }\n }\n\n return null;\n}\n\nexport function matchesTokenPattern(token: string, pattern: string | null): boolean {\n if (!pattern) {\n return true;\n }\n\n try {\n return new RegExp(pattern, 'u').test(token);\n } catch {\n // The server validates the pattern when it admits the plugin; never block on a bad one here.\n return true;\n }\n}\n\n/** A pattern that compiles; an empty or broken one detects nothing rather than every word. */\nfunction compileTokenPattern(pattern: string | null): RegExp | null {\n if (!pattern) {\n return null;\n }\n\n try {\n return new RegExp(pattern, 'u');\n } catch {\n return null;\n }\n}\n\n/**\n * The first plugin whose secret format `text` contains, if any, with every\n * secret-shaped word in the message and what the plugin calls that secret: a\n * token pasted into the chat would be stored in the conversation and sent to\n * the model.\n */\nexport function findPastedPluginToken(\n text: string,\n plugins: readonly ConnectablePlugin[]\n): { plugin: ConnectablePlugin; tokens: string[]; label: string } | null {\n // A token is often glued to a label (`token=…`, `key: …`) or wrapped in\n // brackets, quotes or a sentence's punctuation; none of those are part of it.\n const words = text\n .split(/[\\s\"'`()<>[\\]{},;:=!?&]+/)\n .map((word) => word.replace(/\\.+$/, ''))\n .filter(Boolean);\n let found: { plugin: ConnectablePlugin; label: string } | null = null;\n const tokens = new Set<string>();\n\n for (const plugin of plugins) {\n for (const format of pluginSecretFormats(plugin)) {\n const pattern = compileTokenPattern(format.pattern);\n\n for (const word of pattern ? words : []) {\n if (pattern!.test(word)) {\n found ??= { plugin, label: format.label };\n tokens.add(word);\n }\n }\n }\n }\n\n return found ? { ...found, tokens: [...tokens] } : null;\n}\n","import type { FormEvent, JSX } from 'react';\nimport { useId, useState, useSyncExternalStore } from 'react';\nimport { ExternalLinkIcon, LoaderCircle } from 'lucide-react';\nimport {\n Button,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n Input,\n} from '../../ui';\nimport type { ApiClient } from './api';\nimport { connectPluginPopup } from './plugin-oauth';\nimport {\n credentialFormComplete,\n credentialFormError,\n credentialFormFields,\n matchesTokenPattern,\n type ConnectablePlugin,\n} from './plugin-token-format';\nimport type { PluginApiTokenConnect, PluginCredentialsConnect, PluginScope } from './plugin-types';\n\ninterface TokenRequest {\n id: number;\n plugin: ConnectablePlugin & { connect: PluginApiTokenConnect };\n /** Saves the token; rejects with a message the dialog shows next to the field. */\n submit: (_token: string) => Promise<void>;\n settle: (_connected: boolean) => void;\n}\n\ninterface CredentialsRequest {\n id: number;\n plugin: ConnectablePlugin & { connect: PluginCredentialsConnect };\n /** Saves the form; rejects with a message the dialog shows under the fields. */\n submit: (_method: string | undefined, _values: { [key: string]: string }) => Promise<void>;\n settle: (_connected: boolean) => void;\n}\n\ntype FormRequest = ({ kind: 'token' } & TokenRequest) | ({ kind: 'credentials' } & CredentialsRequest);\n\n/** The one open connect form, outside React so any connect button can open it. */\nlet request: FormRequest | null = null;\nlet lastRequestId = 0;\n/** Cancels the latest request, whether its dialog has opened yet or not. */\nlet cancelLatest: (() => void) | null = null;\nconst listeners = new Set<() => void>();\n\nfunction setRequest(next: FormRequest | null): void {\n request = next;\n listeners.forEach((listener) => listener());\n}\n\nfunction subscribe(listener: () => void): () => void {\n listeners.add(listener);\n\n return () => listeners.delete(listener);\n}\n\n/**\n * Connects a plugin: a sign-in popup for OAuth plugins, the token dialog for\n * plugins that take a pasted token, the credentials dialog for plugins that\n * take the credentials of an app the user created at the provider. Resolves\n * `false` when the user closes a dialog without connecting.\n *\n * Call it straight from a click handler: browsers only allow the popup there.\n */\nexport function connectPlugin(\n api: ApiClient,\n plugin: ConnectablePlugin,\n scope: PluginScope,\n options?: { connectionId?: string }\n): Promise<boolean> {\n const { connect } = plugin;\n\n if (connect?.type !== 'api-token' && connect?.type !== 'credentials') {\n return connectPluginPopup(api, plugin.id, scope, options).then(() => true);\n }\n\n // Opening a second dialog closes the first, as if cancelled.\n cancelLatest?.();\n\n const id = ++lastRequestId;\n const connectionId = options?.connectionId ? { connectionId: options.connectionId } : {};\n\n return new Promise<boolean>((resolve) => {\n const settle = (connected: boolean): void => {\n // A save still running for a replaced dialog must not close its successor.\n if (request?.id === id) {\n setRequest(null);\n }\n\n if (lastRequestId === id) {\n cancelLatest = null;\n }\n\n resolve(connected);\n };\n const next: FormRequest =\n connect.type === 'api-token'\n ? {\n kind: 'token',\n id,\n plugin: { ...plugin, connect },\n submit: async (token) => {\n await api.connectPluginToken({ pluginId: plugin.id, scope, token, ...connectionId });\n },\n settle,\n }\n : {\n kind: 'credentials',\n id,\n plugin: { ...plugin, connect },\n submit: async (method, values) => {\n await api.connectPluginCredentials({ pluginId: plugin.id, scope, method, values, ...connectionId });\n },\n settle,\n };\n\n cancelLatest = () => settle(false);\n\n // Open after the current event: a menu item that started this closes first\n // and returns focus to its trigger, which would take it from the first field.\n setTimeout(() => {\n if (lastRequestId === id) {\n setRequest(next);\n }\n });\n });\n}\n\nfunction httpsHref(value: string | null): string | null {\n if (!value) {\n return null;\n }\n\n try {\n const url = new URL(value);\n\n return url.protocol === 'https:' ? url.href : null;\n } catch {\n return null;\n }\n}\n\n/** Mounted once by the Studio layout; renders the dialog `connectPlugin` opens for token and credentials plugins. */\nexport function PluginTokenDialogHost(): JSX.Element | null {\n const current = useSyncExternalStore(\n subscribe,\n () => request,\n () => null\n );\n\n if (!current) {\n return null;\n }\n\n // A new key per request resets the fields, so a secret never outlives its dialog.\n return current.kind === 'token' ? (\n <PluginTokenDialog key={current.id} request={current} />\n ) : (\n <PluginCredentialsDialog key={current.id} request={current} />\n );\n}\n\nfunction FieldError({ id, message }: { id: string; message: string | null }): JSX.Element | null {\n return message ? (\n <p className=\"fk:text-sm fk:text-destructive\" id={id}>\n {message}\n </p>\n ) : null;\n}\n\nfunction HelpLink({ href, label }: { href: string | null; label: string }): JSX.Element | null {\n const safeHref = httpsHref(href);\n\n return safeHref ? (\n <a\n className=\"fk:inline-flex fk:items-center fk:gap-1 fk:text-sm fk:text-muted-foreground fk:underline-offset-4 fk:hover:underline\"\n href={safeHref}\n rel=\"noreferrer\"\n target=\"_blank\"\n >\n {label}\n <ExternalLinkIcon className=\"fk:size-3.5\" />\n </a>\n ) : null;\n}\n\nfunction PluginCredentialsDialog({ request: current }: { request: CredentialsRequest }): JSX.Element {\n const { connect, name } = current.plugin;\n const formId = useId();\n const [method, setMethod] = useState<string | null>(connect.methods[0]?.key ?? null);\n const [values, setValues] = useState<{ [key: string]: string }>({});\n const [error, setError] = useState<{ field: string | null; message: string } | null>(null);\n const [saving, setSaving] = useState(false);\n const fields = credentialFormFields(connect, method);\n const selectedMethod = connect.methods.find((item) => item.key === method) ?? null;\n // Submitting surfaces which field is malformed; the button only waits for the required values.\n const ready = credentialFormComplete(fields, values);\n\n async function save(event: FormEvent): Promise<void> {\n event.preventDefault();\n\n if (saving) {\n return;\n }\n\n const problem = credentialFormError(fields, values);\n\n if (problem) {\n setError(problem);\n\n return;\n }\n\n setSaving(true);\n setError(null);\n\n try {\n await current.submit(\n method ?? undefined,\n Object.fromEntries(fields.map((field) => [field.key, values[field.key]?.trim() ?? '']).filter(([, value]) => value))\n );\n setValues({});\n current.settle(true);\n } catch (failure) {\n setError({ field: null, message: failure instanceof Error ? failure.message : `${name} could not be connected.` });\n } finally {\n setSaving(false);\n }\n }\n\n return (\n <Dialog\n open\n onOpenChange={(open) => {\n if (!open && !saving) {\n current.settle(false);\n }\n }}\n >\n <DialogContent>\n <form className=\"fk:flex fk:flex-col fk:gap-4\" onSubmit={(event) => void save(event)}>\n <DialogHeader>\n <DialogTitle>Connect {name}</DialogTitle>\n <DialogDescription>\n {connect.description} Flexkit checks the credentials with {name}, stores them encrypted and sends them\n only to Flexkit&apos;s own {name} server; the agent can use the tools but never sees them.\n </DialogDescription>\n </DialogHeader>\n {connect.methods.length > 1 ? (\n <div className=\"fk:space-y-1.5\" role=\"group\" aria-label=\"How to connect\">\n {connect.methods.map((item) => (\n <button\n aria-pressed={method === item.key}\n className={`fk:flex fk:w-full fk:flex-col fk:rounded-lg fk:border fk:px-3 fk:py-2 fk:text-left fk:corner-squircle ${\n method === item.key ? 'fk:border-primary fk:bg-primary/5' : 'fk:border-border fk:hover:bg-muted/60'\n }`}\n disabled={saving}\n key={item.key}\n onClick={() => {\n setMethod(item.key);\n setError(null);\n }}\n type=\"button\"\n >\n <span className=\"fk:text-sm fk:font-medium\">{item.label}</span>\n {item.description ? (\n <span className=\"fk:text-xs fk:text-muted-foreground\">{item.description}</span>\n ) : null}\n </button>\n ))}\n </div>\n ) : selectedMethod?.description ? (\n <p className=\"fk:text-sm fk:text-muted-foreground\">{selectedMethod.description}</p>\n ) : null}\n {fields.map((field, index) => {\n const inputId = `${formId}-${field.key}`;\n const fieldError = error?.field === field.key ? error.message : null;\n\n return (\n <div className=\"fk:flex fk:flex-col fk:gap-2\" key={field.key}>\n <label className=\"fk:text-sm fk:font-medium\" htmlFor={inputId}>\n {field.label}\n </label>\n <Input\n aria-describedby={fieldError ? `${inputId}-error` : field.help ? `${inputId}-help` : undefined}\n aria-invalid={fieldError ? true : undefined}\n autoComplete=\"off\"\n autoFocus={index === 0}\n disabled={saving}\n id={inputId}\n placeholder={field.placeholder ?? undefined}\n spellCheck={false}\n type={field.kind === 'secret' ? 'password' : 'text'}\n value={values[field.key] ?? ''}\n onChange={(event) => {\n setValues((previous) => ({ ...previous, [field.key]: event.target.value }));\n setError(null);\n }}\n />\n {field.help && !fieldError ? (\n <p className=\"fk:text-sm fk:text-muted-foreground\" id={`${inputId}-help`}>\n {field.help}\n </p>\n ) : null}\n <FieldError id={`${inputId}-error`} message={fieldError} />\n </div>\n );\n })}\n <FieldError id={`${formId}-error`} message={error?.field === null ? error.message : null} />\n <HelpLink href={connect.helpUrl} label={`How to set up ${name}`} />\n <DialogFooter>\n <Button disabled={saving} size=\"sm\" type=\"button\" variant=\"outline\" onClick={() => current.settle(false)}>\n Cancel\n </Button>\n <Button disabled={saving || !ready} size=\"sm\" type=\"submit\">\n {saving ? <LoaderCircle className=\"fk:size-4 fk:animate-spin\" /> : null}\n Connect\n </Button>\n </DialogFooter>\n </form>\n </DialogContent>\n </Dialog>\n );\n}\n\nfunction PluginTokenDialog({ request: current }: { request: TokenRequest }): JSX.Element {\n const { connect, name } = current.plugin;\n const inputId = useId();\n const [token, setToken] = useState('');\n const [error, setError] = useState<string | null>(null);\n const [saving, setSaving] = useState(false);\n\n async function save(event: FormEvent): Promise<void> {\n event.preventDefault();\n const value = token.trim();\n\n if (saving || !value) {\n return;\n }\n\n if (!matchesTokenPattern(value, connect.pattern)) {\n setError(`That does not look like a ${connect.tokenLabel}.`);\n\n return;\n }\n\n setSaving(true);\n setError(null);\n\n try {\n await current.submit(value);\n setToken('');\n current.settle(true);\n } catch (failure) {\n setError(failure instanceof Error ? failure.message : `${name} could not be connected.`);\n } finally {\n setSaving(false);\n }\n }\n\n return (\n <Dialog\n open\n onOpenChange={(open) => {\n if (!open && !saving) {\n current.settle(false);\n }\n }}\n >\n <DialogContent>\n <form className=\"fk:flex fk:flex-col fk:gap-4\" onSubmit={(event) => void save(event)}>\n <DialogHeader>\n <DialogTitle>Connect {name}</DialogTitle>\n <DialogDescription>\n Paste a {connect.tokenLabel}. Flexkit stores it encrypted and sends it only to {name}; the agent can use{' '}\n {name}&apos;s tools but never sees the token. Give it read access only, unless the agent should change\n things in {name}.\n </DialogDescription>\n </DialogHeader>\n <div className=\"fk:flex fk:flex-col fk:gap-2\">\n <label className=\"fk:text-sm fk:font-medium\" htmlFor={inputId}>\n {connect.tokenLabel}\n </label>\n <Input\n aria-describedby={error ? `${inputId}-error` : undefined}\n aria-invalid={error ? true : undefined}\n autoComplete=\"off\"\n autoFocus\n disabled={saving}\n id={inputId}\n placeholder={connect.placeholder ?? undefined}\n spellCheck={false}\n type=\"password\"\n value={token}\n onChange={(event) => {\n setToken(event.target.value);\n setError(null);\n }}\n />\n <FieldError id={`${inputId}-error`} message={error} />\n <HelpLink href={connect.helpUrl} label={`How to create a ${connect.tokenLabel}`} />\n </div>\n <DialogFooter>\n <Button disabled={saving} size=\"sm\" type=\"button\" variant=\"outline\" onClick={() => current.settle(false)}>\n Cancel\n </Button>\n <Button disabled={saving || !token.trim()} size=\"sm\" type=\"submit\">\n {saving ? <LoaderCircle className=\"fk:size-4 fk:animate-spin\" /> : null}\n Connect\n </Button>\n </DialogFooter>\n </form>\n </DialogContent>\n </Dialog>\n );\n}\n"]}
@@ -1,2 +1,2 @@
1
- import'./index.css';import {a}from'./chunk-QSTWBKPN.js';import {a as a$1,d}from'./chunk-WU2KCXBC.js';import {f,d as d$2}from'./chunk-U6VZY3V2.js';import {f as f$1}from'./chunk-TI3EHLRE.js';import {M,ea,fa,ga,ma,o,p,q as q$1}from'./chunk-RULCANNM.js';import {e,g,h,i,j,t,d as d$1,a as a$2,b as b$3,c as c$2,o as o$1}from'./chunk-A4DPLZZF.js';import {e as e$2,g as g$1,b as b$2}from'./chunk-G5N6HEPW.js';import {m,b as b$1}from'./chunk-5JUG4BEF.js';import {b,c as c$1,e as e$1}from'./chunk-N33S7BSG.js';import {c}from'./chunk-X3SHNHHM.js';import {useState,useMemo,useRef,useEffect}from'react';import {useNavigate,useLocation,useParams,Link}from'react-router-dom';import q,{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 xe(){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 ze(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 Ie(n){return n==="project"?"Project":"Personal"}function z(n,a,t){return t==="personal"?n.allowPersonal:a}function he(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 $e(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 je({busy:n,canManage:a,plugin:t,onConnect:s}){let i$1=t.scopes.filter(k=>he(t,k).length===0),[f]=i$1;if(!f)return null;if(t.scopes.length===1)return jsxs(c,{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(c,{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:Ie(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 H(n){return n.split(/[\s_-]+/).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function Be(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])=>H(t).localeCompare(H(s))).map(([t,s])=>({category:t,plugins:s}))}var ce=[{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 ke({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 K="fk:grid fk:grid-cols-1 fk:gap-x-16 fk:gap-y-1 fk:lg:grid-cols-2";function We({grouped:n=true}){let a=ce.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"}),ce.map(t$1=>jsxs("section",{children:[jsx(t,{className:"fk:mb-1 fk:h-4 fk:w-28"}),jsx("div",{className:K,children:t$1.rows.map(s=>jsx(ke,{action:true,row:s},s.id))})]},t$1.id))]}):jsxs("div",{"aria-busy":"true",className:K,children:[jsx("span",{className:"fk:sr-only",children:"Loading plugins"}),a.map(t=>jsx(ke,{action:true,row:t},t.id))]})}function Ue(){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,{children:[jsx(c$1,{asChild:true,children:jsx(M,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(ea,{value:s?"skills":"plugins",onValueChange:f=>{let m=f==="skills"?"skills":"plugins";(f==="skills"?s:t)||n(S(a,m));},children:jsxs(fa,{children:[jsx(ga,{value:"plugins",onClick:()=>{t||n(S(a,"plugins"));},children:"Plugins"}),jsx(ga,{value:"skills",children:"Skills"})]})})]})}function Xe({onOpen:n,plugin:a$1}){let t=T(a$1),s=a$1.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(a,{className:"fk:size-10 fk:rounded-lg",src:a$1.logoUrl}),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$1.name}),jsx("span",{className:"fk:block fk:truncate fk:text-sm fk:text-muted-foreground",children:a$1.description})]}),s>0?jsxs(b,{children:[jsx(c$1,{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 ue({onOpen:n,plugins:a}){return jsx("div",{className:K,children:a.map(t=>jsx(Xe,{plugin:t,onOpen:()=>n(t.id)},t.id))})}function be({installedOnly:n=false}){let{base:a}=xe(),{data:t$1,error:s,isLoading:i}=q(a?`${a}/plugins`:null,f),[f$1,m$1]=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?[]:Be(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:H(c.category)}),jsx(ue,{plugins:c.plugins,onOpen:M})]},c.category))});return n&&(r=jsx(ue,{plugins:l,onOpen:M})),(i||s||l.length===0)&&(r=null),jsxs("main",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:[jsx(Ue,{}),jsx(m,{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(b$2,{"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$1(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$2,{className:"fk:rounded-md",children:[jsx(b$3,{src:c.logoUrl,alt:""}),jsx(c$2,{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?jsx(e$2,{variant:"destructive",children:jsx(g$1,{children:"Unable to load plugins. Please try again."})}):null,i?jsx(We,{grouped:!n}):null,!i&&!s&&l.length===0?jsx(e$2,{children:jsx(g$1,{children:g})}):null,r]})})]})}function on(){return jsx(be,{})}function sn(){return jsx(be,{installedOnly:true})}function Je({base:n,connectionId:a}){let{data:t$1,error:s}=q(`${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(o,{className:"fk:group",children:[jsxs(p,{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"}),_e(i.tools.length)]}),jsx(q$1,{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 _e(n){return n===1?"1 tool":`${n.toString()} tools`}function Ge(n){return n.accountName&&n.accountName!==n.displayName?n.accountName:n.scope==="project"?"Shared with this project":"Only you can use this account"}function Fe({actionable:n,actions:a,busy:t,connection:s,pluginEnabled:i$1}){let[f,m]=useState(false),[k,p]=useState(""),x=useRef(null),l=s.status==="needs_auth",b=async()=>{let u=k.trim();await a.onRename(s,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$2,{className:"fk:size-8",children:jsx(c$2,{children:s.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();},children:[jsx(b$2,{"aria-label":"Account name",ref:x,className:"fk:h-8 fk:max-w-xs",disabled:t,placeholder:s.accountName??"Account name",value:k,onChange:u=>p(u.target.value),onKeyDown:u=>{u.key==="Escape"&&m(false);}}),jsx(c,{"aria-label":"Save name",disabled:t,size:"icon",type:"submit",variant:"ghost",children:jsx(CheckIcon,{})}),jsx(c,{"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.displayName}),s.isPrimary?jsx(b$1,{variant:"secondary",children:"Primary"}):null,l?jsx(b$1,{variant:"destructive",children:"Needs reconnect"}):null]}),jsx("span",{className:"fk:truncate fk:text-sm fk:text-muted-foreground",children:Ge(s)})]}),n&&!f?jsxs(e,{children:[jsx(g,{asChild:true,children:jsx(c,{"aria-label":`Manage ${s.displayName}`,disabled:t,size:"icon",variant:"ghost",children:jsx(MoreHorizontal,{})})}),jsxs(h,{align:"end",children:[jsxs(i,{children:[!s.isPrimary&&!l?jsx(j,{onSelect:()=>a.onMakePrimary(s),children:"Make primary"}):null,jsx(j,{onSelect:()=>{p(s.label??""),m(true);},children:"Rename"}),jsx(j,{disabled:!i$1,onSelect:()=>a.onReconnect(s),children:"Reconnect"})]}),jsx(o$1,{}),jsx(j,{variant:"destructive",onSelect:()=>a.onDisconnect(s),children:"Disconnect"})]})]}):null]})}function He({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=he(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(Fe,{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 ln(){let{pluginId:n}=useParams(),{api:a$2,base:t$1}=xe(),{data:s,error:i,mutate:f$1}=q(t$1&&n?`${t$1}/plugins/${n}`:null,f),{mutate:m$1}=useSWRConfig(),k=useNavigate(),[p,x]=useState(false),l=s?.plugin,b$2=l?Re(l.sourceUrl):null,u=async r=>{x(true);try{await r(),await f$1();}catch(c){if(c instanceof a$1){ma.error('You signed in with a different account. Use "Connect another account" to add it.');return}ma.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(e$2,{variant:"destructive",children:jsx(g$1,{children:"Unable to load this plugin."})})});if(!l||!s||!a$2||!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,{children:[jsx(c$1,{asChild:true,children:jsx(M,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsxs(c,{variant:"ghost",size:"sm",onClick:()=>k("..",{relative:"path"}),children:[jsx(ArrowLeft,{}),"Plugins"]})]}),jsx(m,{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=$e(l),M$1={onDisconnect:r=>{u(()=>a$2.disconnectPlugin(r.id));},onMakePrimary:r=>{u(()=>a$2.updatePluginConnection(r.id,{primary:!0}));},onReconnect:r=>{u(()=>d(a$2,l,r.scope,{connectionId:r.id}));},onRename:(r,c)=>u(()=>a$2.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,{children:[jsx(c$1,{asChild:true,children:jsx(M,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsxs(c,{variant:"ghost",size:"sm",onClick:()=>k("..",{relative:"path"}),children:[jsx(ArrowLeft,{}),"Plugins"]})]}),jsx(m,{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(a,{className:"fk:size-14 fk:rounded-lg",src:l.logoUrl}),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$2?jsxs("a",{href:b$2,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(je,{busy:p,canManage:s.canManage,plugin:l,onConnect:r=>{u(()=>d(a$2,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$1,{className:`fk:border-0 fk:text-[0.625rem] fk:leading-4.5 fk:font-normal fk:py-0 fk:px-2 ${ze(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(e$2,{children:jsx(g$1,{children:"This plugin is disabled by project policy."})}),T(l)?jsx(He,{actions:M$1,busy:p,canManage:s.canManage,plugin:l,onConnect:r=>{u(()=>d(a$2,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(c,{className:"fk:ml-auto",disabled:p,size:"sm",variant:"ghost",onClick:()=>{u(async()=>{await a$2.refreshPluginTools(g.id),await m$1(`${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(Je,{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(c,{className:"fk:pl-0!",variant:"link",onClick:()=>k(`../../automations/${r.id}`,{relative:"path"}),children:r.name})},r.id))})]})]})})]})}export{je as a,Ue as b,on as c,sn as d,ln as e};//# sourceMappingURL=chunk-RAUQCO6W.js.map
2
- //# sourceMappingURL=chunk-RAUQCO6W.js.map
1
+ import'./index.css';import {a}from'./chunk-QSTWBKPN.js';import {a as a$1,d}from'./chunk-L5Z56DDM.js';import {f,d as d$2}from'./chunk-PLCI2RJA.js';import {f as f$1}from'./chunk-TWA6OG5U.js';import {M,ea,fa,ga,ma,o,p,q as q$1}from'./chunk-RULCANNM.js';import {e,g,h,i,j,t,d as d$1,a as a$2,b as b$3,c as c$2,o as o$1}from'./chunk-A4DPLZZF.js';import {e as e$2,g as g$1,b as b$2}from'./chunk-G5N6HEPW.js';import {m,b as b$1}from'./chunk-5JUG4BEF.js';import {b,c as c$1,e as e$1}from'./chunk-N33S7BSG.js';import {c}from'./chunk-X3SHNHHM.js';import {useState,useMemo,useRef,useEffect}from'react';import {useNavigate,useLocation,useParams,Link}from'react-router-dom';import q,{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 xe(){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 ze(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 Ie(n){return n==="project"?"Project":"Personal"}function z(n,a,t){return t==="personal"?n.allowPersonal:a}function he(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 $e(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 je({busy:n,canManage:a,plugin:t,onConnect:s}){let i$1=t.scopes.filter(k=>he(t,k).length===0),[f]=i$1;if(!f)return null;if(t.scopes.length===1)return jsxs(c,{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(c,{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:Ie(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 H(n){return n.split(/[\s_-]+/).filter(Boolean).map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join(" ")}function Be(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])=>H(t).localeCompare(H(s))).map(([t,s])=>({category:t,plugins:s}))}var ce=[{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 ke({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 K="fk:grid fk:grid-cols-1 fk:gap-x-16 fk:gap-y-1 fk:lg:grid-cols-2";function We({grouped:n=true}){let a=ce.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"}),ce.map(t$1=>jsxs("section",{children:[jsx(t,{className:"fk:mb-1 fk:h-4 fk:w-28"}),jsx("div",{className:K,children:t$1.rows.map(s=>jsx(ke,{action:true,row:s},s.id))})]},t$1.id))]}):jsxs("div",{"aria-busy":"true",className:K,children:[jsx("span",{className:"fk:sr-only",children:"Loading plugins"}),a.map(t=>jsx(ke,{action:true,row:t},t.id))]})}function Ue(){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,{children:[jsx(c$1,{asChild:true,children:jsx(M,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsx(ea,{value:s?"skills":"plugins",onValueChange:f=>{let m=f==="skills"?"skills":"plugins";(f==="skills"?s:t)||n(S(a,m));},children:jsxs(fa,{children:[jsx(ga,{value:"plugins",onClick:()=>{t||n(S(a,"plugins"));},children:"Plugins"}),jsx(ga,{value:"skills",children:"Skills"})]})})]})}function Xe({onOpen:n,plugin:a$1}){let t=T(a$1),s=a$1.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(a,{className:"fk:size-10 fk:rounded-lg",src:a$1.logoUrl}),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$1.name}),jsx("span",{className:"fk:block fk:truncate fk:text-sm fk:text-muted-foreground",children:a$1.description})]}),s>0?jsxs(b,{children:[jsx(c$1,{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 ue({onOpen:n,plugins:a}){return jsx("div",{className:K,children:a.map(t=>jsx(Xe,{plugin:t,onOpen:()=>n(t.id)},t.id))})}function be({installedOnly:n=false}){let{base:a}=xe(),{data:t$1,error:s,isLoading:i}=q(a?`${a}/plugins`:null,f),[f$1,m$1]=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?[]:Be(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:H(c.category)}),jsx(ue,{plugins:c.plugins,onOpen:M})]},c.category))});return n&&(r=jsx(ue,{plugins:l,onOpen:M})),(i||s||l.length===0)&&(r=null),jsxs("main",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:[jsx(Ue,{}),jsx(m,{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(b$2,{"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$1(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$2,{className:"fk:rounded-md",children:[jsx(b$3,{src:c.logoUrl,alt:""}),jsx(c$2,{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?jsx(e$2,{variant:"destructive",children:jsx(g$1,{children:"Unable to load plugins. Please try again."})}):null,i?jsx(We,{grouped:!n}):null,!i&&!s&&l.length===0?jsx(e$2,{children:jsx(g$1,{children:g})}):null,r]})})]})}function on(){return jsx(be,{})}function sn(){return jsx(be,{installedOnly:true})}function Je({base:n,connectionId:a}){let{data:t$1,error:s}=q(`${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(o,{className:"fk:group",children:[jsxs(p,{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"}),_e(i.tools.length)]}),jsx(q$1,{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 _e(n){return n===1?"1 tool":`${n.toString()} tools`}function Ge(n){return n.accountName&&n.accountName!==n.displayName?n.accountName:n.scope==="project"?"Shared with this project":"Only you can use this account"}function Fe({actionable:n,actions:a,busy:t,connection:s,pluginEnabled:i$1}){let[f,m]=useState(false),[k,p]=useState(""),x=useRef(null),l=s.status==="needs_auth",b=async()=>{let u=k.trim();await a.onRename(s,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$2,{className:"fk:size-8",children:jsx(c$2,{children:s.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();},children:[jsx(b$2,{"aria-label":"Account name",ref:x,className:"fk:h-8 fk:max-w-xs",disabled:t,placeholder:s.accountName??"Account name",value:k,onChange:u=>p(u.target.value),onKeyDown:u=>{u.key==="Escape"&&m(false);}}),jsx(c,{"aria-label":"Save name",disabled:t,size:"icon",type:"submit",variant:"ghost",children:jsx(CheckIcon,{})}),jsx(c,{"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.displayName}),s.isPrimary?jsx(b$1,{variant:"secondary",children:"Primary"}):null,l?jsx(b$1,{variant:"destructive",children:"Needs reconnect"}):null]}),jsx("span",{className:"fk:truncate fk:text-sm fk:text-muted-foreground",children:Ge(s)})]}),n&&!f?jsxs(e,{children:[jsx(g,{asChild:true,children:jsx(c,{"aria-label":`Manage ${s.displayName}`,disabled:t,size:"icon",variant:"ghost",children:jsx(MoreHorizontal,{})})}),jsxs(h,{align:"end",children:[jsxs(i,{children:[!s.isPrimary&&!l?jsx(j,{onSelect:()=>a.onMakePrimary(s),children:"Make primary"}):null,jsx(j,{onSelect:()=>{p(s.label??""),m(true);},children:"Rename"}),jsx(j,{disabled:!i$1,onSelect:()=>a.onReconnect(s),children:"Reconnect"})]}),jsx(o$1,{}),jsx(j,{variant:"destructive",onSelect:()=>a.onDisconnect(s),children:"Disconnect"})]})]}):null]})}function He({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=he(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(Fe,{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 ln(){let{pluginId:n}=useParams(),{api:a$2,base:t$1}=xe(),{data:s,error:i,mutate:f$1}=q(t$1&&n?`${t$1}/plugins/${n}`:null,f),{mutate:m$1}=useSWRConfig(),k=useNavigate(),[p,x]=useState(false),l=s?.plugin,b$2=l?Re(l.sourceUrl):null,u=async r=>{x(true);try{await r(),await f$1();}catch(c){if(c instanceof a$1){ma.error('You signed in with a different account. Use "Connect another account" to add it.');return}ma.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(e$2,{variant:"destructive",children:jsx(g$1,{children:"Unable to load this plugin."})})});if(!l||!s||!a$2||!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,{children:[jsx(c$1,{asChild:true,children:jsx(M,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsxs(c,{variant:"ghost",size:"sm",onClick:()=>k("..",{relative:"path"}),children:[jsx(ArrowLeft,{}),"Plugins"]})]}),jsx(m,{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=$e(l),M$1={onDisconnect:r=>{u(()=>a$2.disconnectPlugin(r.id));},onMakePrimary:r=>{u(()=>a$2.updatePluginConnection(r.id,{primary:!0}));},onReconnect:r=>{u(()=>d(a$2,l,r.scope,{connectionId:r.id}));},onRename:(r,c)=>u(()=>a$2.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,{children:[jsx(c$1,{asChild:true,children:jsx(M,{className:"fk:-ml-1 fk:h-4 fk:w-4"})}),jsx(e$1,{children:"Toggle Sidebar"})]}),jsxs(c,{variant:"ghost",size:"sm",onClick:()=>k("..",{relative:"path"}),children:[jsx(ArrowLeft,{}),"Plugins"]})]}),jsx(m,{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(a,{className:"fk:size-14 fk:rounded-lg",src:l.logoUrl}),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$2?jsxs("a",{href:b$2,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(je,{busy:p,canManage:s.canManage,plugin:l,onConnect:r=>{u(()=>d(a$2,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$1,{className:`fk:border-0 fk:text-[0.625rem] fk:leading-4.5 fk:font-normal fk:py-0 fk:px-2 ${ze(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(e$2,{children:jsx(g$1,{children:"This plugin is disabled by project policy."})}),T(l)?jsx(He,{actions:M$1,busy:p,canManage:s.canManage,plugin:l,onConnect:r=>{u(()=>d(a$2,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(c,{className:"fk:ml-auto",disabled:p,size:"sm",variant:"ghost",onClick:()=>{u(async()=>{await a$2.refreshPluginTools(g.id),await m$1(`${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(Je,{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(c,{className:"fk:pl-0!",variant:"link",onClick:()=>k(`../../automations/${r.id}`,{relative:"path"}),children:r.name})},r.id))})]})]})})]})}export{je as a,Ue as b,on as c,sn as d,ln as e};//# sourceMappingURL=chunk-LTM3MW2D.js.map
2
+ //# sourceMappingURL=chunk-LTM3MW2D.js.map