@lovelybunch/api 1.0.76-alpha.8 → 1.0.76-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/static/assets/{ActivityPage-uL-Qknui.js → ActivityPage-BaSoKgwZ.js} +1 -1
- package/static/assets/{ApiKeysSettingsPage-BhaH6ZYP.js → ApiKeysSettingsPage-CjrCuHHE.js} +1 -1
- package/static/assets/{ArchitectureEditPage-BWKyKi3T.js → ArchitectureEditPage-MYU7btLs.js} +1 -1
- package/static/assets/{ArchitecturePage-Dtm0OAac.js → ArchitecturePage-CGqWy8b1.js} +1 -1
- package/static/assets/{AuthSettingsPage-D0MQlHyh.js → AuthSettingsPage-elJX4TCV.js} +1 -1
- package/static/assets/{CallbackPage-Bz4m3_W8.js → CallbackPage-CUuZYgBL.js} +1 -1
- package/static/assets/{CodePage-BuO2K_xx.js → CodePage-C_bzfOnI.js} +1 -1
- package/static/assets/{CollapsibleSection-CxX11hr-.js → CollapsibleSection-DfTxWX0X.js} +1 -1
- package/static/assets/{DashboardPage-B3HR1UM7.js → DashboardPage-CmS8UPSm.js} +1 -1
- package/static/assets/{GitPage-Dm36PRw_.js → GitPage-DSfn76oO.js} +1 -1
- package/static/assets/{GitSettingsPage-CRWcjgVI.js → GitSettingsPage-Bu8h7hcr.js} +1 -1
- package/static/assets/{IdentityPage-YCkmdyzR.js → IdentityPage-NFKq2FHi.js} +2 -2
- package/static/assets/{ImplementationStepsEditor-u3dPxmKW.js → ImplementationStepsEditor-Cn-MshnR.js} +1 -1
- package/static/assets/{IntegrationsSettingsPage-Z8xCUmX9.js → IntegrationsSettingsPage-Cw6ItrNf.js} +1 -1
- package/static/assets/{JobDetailPage-B8Za82RA.js → JobDetailPage-DLSD4HiU.js} +1 -1
- package/static/assets/{KnowledgeDetailPage-CR9c4_WD.js → KnowledgeDetailPage-DY8PpD9X.js} +1 -1
- package/static/assets/{KnowledgeEditPage-DhrF6UPg.js → KnowledgeEditPage-B28N-7vM.js} +1 -1
- package/static/assets/{KnowledgePage-_gZhpTe3.js → KnowledgePage-C3zoPEcH.js} +1 -1
- package/static/assets/{LoginPage-Cc1Ac2j4.js → LoginPage-BYNLGEnz.js} +1 -1
- package/static/assets/{MailInboxPage-B_h1Kz4D.js → MailInboxPage-DDYg0W70.js} +1 -1
- package/static/assets/{MailProcessingModal-D_qEwqmL.js → MailProcessingModal-CXIrtSz0.js} +1 -1
- package/static/assets/{MailReadPage-_q-xk_cX.js → MailReadPage-CVz6oD-y.js} +1 -1
- package/static/assets/{MailSentPage-Dj63oQ5D.js → MailSentPage-ClaVWZCR.js} +1 -1
- package/static/assets/{McpSettingsPage-DYZ0QNbp.js → McpSettingsPage-CfhBioEH.js} +1 -1
- package/static/assets/NewKnowledgePage-BUwh_DFd.js +1 -0
- package/static/assets/{NewSkillPage-BEn18f2A.js → NewSkillPage-B2rztwzD.js} +1 -1
- package/static/assets/{NewTaskPage-CSlncpI5.js → NewTaskPage-Cvw20nug.js} +1 -1
- package/static/assets/{NotFoundPage-C4x0lGai.js → NotFoundPage-CXvLVHsT.js} +1 -1
- package/static/assets/{NotificationsSettingsPage-C9YnfRlj.js → NotificationsSettingsPage-Df_GZ7_p.js} +1 -1
- package/static/assets/{ProjectEditPage-X0-4mEAS.js → ProjectEditPage-DKf6ZoiG.js} +1 -1
- package/static/assets/{ProjectPage-D8OX1GKt.js → ProjectPage-CHhx9s1k.js} +1 -1
- package/static/assets/{PromptsSettingsPage-Chc4da1S.js → PromptsSettingsPage-QTxJgO5-.js} +1 -1
- package/static/assets/{ResourceDetailPage-DDYKQxpM.js → ResourceDetailPage-C9RHHVKu.js} +1 -1
- package/static/assets/{ResourcesPage-BmOpgt3L.js → ResourcesPage-BI8tfYZ2.js} +1 -1
- package/static/assets/{RoleEditPage-Ccfu1tn1.js → RoleEditPage-N2-v2MXN.js} +1 -1
- package/static/assets/{RolePage-CcdEUjSm.js → RolePage-Da0kZMUH.js} +1 -1
- package/static/assets/{RulesSettingsPage-Cz1g_eAj.js → RulesSettingsPage-CSd5iz22.js} +1 -1
- package/static/assets/{SchedulePage-CGxZHEL-.js → SchedulePage-CS8g2Db-.js} +1 -1
- package/static/assets/{SkillDetailPage-sJg-L8A8.js → SkillDetailPage-QjqBAuFU.js} +1 -1
- package/static/assets/{SkillEditPage-BksV7GmD.js → SkillEditPage-BB0x4VVH.js} +1 -1
- package/static/assets/{SkillsPage-CwarkJmZ.js → SkillsPage-BMDNxMmZ.js} +1 -1
- package/static/assets/{SkillsSettingsPage-DTnBlBdE.js → SkillsSettingsPage-DcdeOlAl.js} +1 -1
- package/static/assets/{SourceInput-CWazIr6v.js → SourceInput-rc4KSqcv.js} +1 -1
- package/static/assets/{TagInput-Bgyxb_JU.js → TagInput-bxFcAknC.js} +1 -1
- package/static/assets/{TaskDetailPage-DlmG1kZR.js → TaskDetailPage-CAmREdfh.js} +1 -1
- package/static/assets/{TaskEditPage-BnpNeed_.js → TaskEditPage-BDgZtG36.js} +1 -1
- package/static/assets/{TasksPage-CXeTMpgy.js → TasksPage-BQ6eLw0T.js} +1 -1
- package/static/assets/{TerminalPage-BLcPt381.js → TerminalPage-BhWGRGf1.js} +1 -1
- package/static/assets/TerminalSessionPage-Bu-WiE0d.js +3 -0
- package/static/assets/{UserPreferencesPage-BNwEqlRW.js → UserPreferencesPage-B_Tu1a8h.js} +1 -1
- package/static/assets/{UserSettingsPage-BRafqkiD.js → UserSettingsPage-BnEGtrGo.js} +1 -1
- package/static/assets/{UtilitiesPage-BPX_Unxu.js → UtilitiesPage-k7ABCAig.js} +1 -1
- package/static/assets/{alert-Ci2-OWZ_.js → alert-C42EBWiI.js} +1 -1
- package/static/assets/{arrow-down-C6Flf0DF.js → arrow-down-CuFFg288.js} +1 -1
- package/static/assets/{arrow-left-7TCkaJlN.js → arrow-left-C8VbyW3d.js} +1 -1
- package/static/assets/{arrow-up-down-tqbfiBy6.js → arrow-up-down-GN3qK2mU.js} +1 -1
- package/static/assets/{arrow-up-DeQAxOPq.js → arrow-up-vC1c-5gW.js} +1 -1
- package/static/assets/{badge-D4vHU_w_.js → badge-CKwUSKzT.js} +1 -1
- package/static/assets/{browser-modal-BiaqhKHm.js → browser-modal-C9VBJ_El.js} +1 -1
- package/static/assets/{card-xkODbJy-.js → card-DRBgMGuU.js} +1 -1
- package/static/assets/{chevron-left-CvpfJBPQ.js → chevron-left-2sP4ienq.js} +1 -1
- package/static/assets/{chevron-up-BB-6OS4z.js → chevron-up-DJfyvHso.js} +1 -1
- package/static/assets/{chevrons-up-CLKrQHMU.js → chevrons-up-DfFpzHXf.js} +1 -1
- package/static/assets/{circle-alert-lnP0-w3N.js → circle-alert-DP4rtmEK.js} +1 -1
- package/static/assets/{circle-check-BPkEav83.js → circle-check-Cnp-EoKX.js} +1 -1
- package/static/assets/{circle-check-big-Dbo-OmWQ.js → circle-check-big-3mrGMFVn.js} +1 -1
- package/static/assets/{circle-play-BbtBIeo3.js → circle-play-7F5AVehH.js} +1 -1
- package/static/assets/{circle-x-BBwi8e5G.js → circle-x-DxbiyJ6w.js} +1 -1
- package/static/assets/{clipboard-Ce816tAO.js → clipboard-CQNR4_yT.js} +1 -1
- package/static/assets/{clock-BIeoO5Mt.js → clock-DGw3R_UL.js} +1 -1
- package/static/assets/{code-DTW3giBe.js → code-DSNMK8tD.js} +1 -1
- package/static/assets/{download-BgKxfry9.js → download-BWL6PFiw.js} +1 -1
- package/static/assets/{external-link--RjKXREe.js → external-link-BqUE-DMN.js} +1 -1
- package/static/assets/{eye--K-OgK7L.js → eye-BD57N1qQ.js} +1 -1
- package/static/assets/{folder-git-2-Bgv7r0zC.js → folder-git-2-CW5Zi8Bm.js} +1 -1
- package/static/assets/{index-DF_KNbKf.js → index-B0fLM-4F.js} +1 -1
- package/static/assets/{index-LMsLdXw_.js → index-B9OOTqx4.js} +1 -1
- package/static/assets/{index-4RuWYO4M.js → index-BArpuuuE.js} +1 -1
- package/static/assets/{index-Db5-BoCU.js → index-BG5vEV31.js} +1 -1
- package/static/assets/{index-R44k73Ca.js → index-BWktaW8U.js} +1 -1
- package/static/assets/{index-BQYB8kWb.js → index-Bedu89qc.js} +1 -1
- package/static/assets/{index-BD9UBXsr.js → index-BmTTXfmk.js} +1 -1
- package/static/assets/{index-Do92mBFr.js → index-CMQcknsg.js} +1 -1
- package/static/assets/{index-iIFwHD3L.js → index-CMt1ExW-.js} +1 -1
- package/static/assets/{index-BteQHbZ1.js → index-CVVL2h9f.js} +1 -1
- package/static/assets/{index-BbrX1XcC.js → index-CXWGFCS-.js} +1 -1
- package/static/assets/{index-Di7xMYoG.js → index-CheR43vH.js} +1 -1
- package/static/assets/index-Cht-fo9a.css +1 -0
- package/static/assets/{index-Dt_WtbUU.js → index-D4awulBm.js} +1 -1
- package/static/assets/{index-PyVlsLW8.js → index-DB2Tq9wz.js} +3 -3
- package/static/assets/{index-D9xZafJb.js → index-DO47L-WG.js} +1 -1
- package/static/assets/{index-Cd5hBt4x.js → index-EpelXypg.js} +1 -1
- package/static/assets/{index-BkEdELOI.js → index-X4fPPLHI.js} +1 -1
- package/static/assets/{index-CW9pK_cZ.js → index-stPObw-o.js} +1 -1
- package/static/assets/{index-Ch4GVR8L.js → index-uxv5vQZF.js} +1 -1
- package/static/assets/{info-DgZN3xWF.js → info-DMJxIp7i.js} +1 -1
- package/static/assets/{label-DvPENm3h.js → label-DxDedS8x.js} +1 -1
- package/static/assets/{markdown-editor-DpZxV-fa.js → markdown-editor-DJ2CscSp.js} +3 -3
- package/static/assets/{message-square-CoaQYehb.js → message-square-DF58cqKJ.js} +1 -1
- package/static/assets/{paperclip-ChugoOAp.js → paperclip-CHyfSVll.js} +1 -1
- package/static/assets/{pause-m9YcgxdE.js → pause-B-ouFhaQ.js} +1 -1
- package/static/assets/{play-DtFz_MLh.js → play-B0y1weCV.js} +1 -1
- package/static/assets/{radio-group-C5Te9bVb.js → radio-group-DFNQiPDU.js} +1 -1
- package/static/assets/{refresh-cw-B1bWW9Rg.js → refresh-cw-5y5jTc6x.js} +1 -1
- package/static/assets/{search-CPOHeeUa.js → search-B5deRThk.js} +1 -1
- package/static/assets/{select-B1v2u6hQ.js → select-BzOa_wZx.js} +1 -1
- package/static/assets/{switch-Bf1Cq3P6.js → switch-Bf2z8aaj.js} +1 -1
- package/static/assets/{tabs-DAbCZiFC.js → tabs-DkdBSep3.js} +1 -1
- package/static/assets/{tag-Cz4z82t0.js → tag-gRsTk0jY.js} +1 -1
- package/static/assets/{terminal-preview-DTUohQ5b.js → terminal-preview-BfrUN2ok.js} +1 -1
- package/static/assets/{use-terminal-CFbQv1ie.js → use-terminal-D6Qe1nwM.js} +1 -1
- package/static/assets/{video-B6ZJ-Epb.js → video-DXo9sCfT.js} +1 -1
- package/static/index.html +2 -2
- package/dist/lib/mcp-client.d.ts +0 -39
- package/dist/lib/mcp-client.js +0 -131
- package/dist/routes/api/v1/ai/tools.d.ts +0 -17
- package/dist/routes/api/v1/ai/tools.js +0 -931
- package/dist/routes/api/v1/context/knowledge/[filename]/index.d.ts +0 -1
- package/dist/routes/api/v1/context/knowledge/[filename]/index.js +0 -1
- package/dist/routes/api/v1/context/knowledge/[filename]/route.d.ts +0 -3
- package/dist/routes/api/v1/context/knowledge/[filename]/route.js +0 -254
- package/dist/routes/api/v1/context/knowledge/index.d.ts +0 -1
- package/dist/routes/api/v1/context/knowledge/index.js +0 -1
- package/dist/routes/api/v1/context/knowledge/route.d.ts +0 -3
- package/dist/routes/api/v1/context/knowledge/route.js +0 -176
- package/dist/routes/api/v1/proposals/[id]/route.d.ts +0 -337
- package/dist/routes/api/v1/proposals/[id]/route.js +0 -165
- package/dist/routes/api/v1/proposals/index.d.ts +0 -3
- package/dist/routes/api/v1/proposals/index.js +0 -10
- package/dist/routes/api/v1/proposals/route.d.ts +0 -315
- package/dist/routes/api/v1/proposals/route.js +0 -129
- package/dist/routes/api/v1/terminal/[proposalId]/create/index.d.ts +0 -3
- package/dist/routes/api/v1/terminal/[proposalId]/create/index.js +0 -5
- package/dist/routes/api/v1/terminal/[proposalId]/create/route.d.ts +0 -10
- package/dist/routes/api/v1/terminal/[proposalId]/create/route.js +0 -27
- package/dist/routes/api/v1/terminal/[proposalId]/destroy/index.d.ts +0 -3
- package/dist/routes/api/v1/terminal/[proposalId]/destroy/index.js +0 -5
- package/dist/routes/api/v1/terminal/[proposalId]/destroy/route.d.ts +0 -10
- package/dist/routes/api/v1/terminal/[proposalId]/destroy/route.js +0 -21
- package/dist/routes/api/v1/terminal/[proposalId]/resize/index.d.ts +0 -3
- package/dist/routes/api/v1/terminal/[proposalId]/resize/index.js +0 -5
- package/dist/routes/api/v1/terminal/[proposalId]/resize/route.d.ts +0 -10
- package/dist/routes/api/v1/terminal/[proposalId]/resize/route.js +0 -21
- package/static/assets/NewKnowledgePage-BEVMYnKG.js +0 -9
- package/static/assets/TerminalSessionPage-CeAd8IAy.js +0 -8
- package/static/assets/index-DH_vXhd4.css +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovelybunch/api",
|
|
3
|
-
"version": "1.0.76-alpha.
|
|
3
|
+
"version": "1.0.76-alpha.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/server-with-static.js",
|
|
6
6
|
"exports": {
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"@ai-sdk/anthropic": "^3.0.41",
|
|
38
38
|
"@hono/node-server": "^1.13.7",
|
|
39
39
|
"@hono/node-ws": "^1.0.6",
|
|
40
|
-
"@lovelybunch/core": "^1.0.76-alpha.
|
|
41
|
-
"@lovelybunch/mcp": "^1.0.76-alpha.
|
|
42
|
-
"@lovelybunch/types": "^1.0.76-alpha.
|
|
40
|
+
"@lovelybunch/core": "^1.0.76-alpha.9",
|
|
41
|
+
"@lovelybunch/mcp": "^1.0.76-alpha.9",
|
|
42
|
+
"@lovelybunch/types": "^1.0.76-alpha.9",
|
|
43
43
|
"adm-zip": "^0.5.16",
|
|
44
44
|
"ai": "^6.0.79",
|
|
45
45
|
"bcryptjs": "^2.4.3",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,A as p,j as e,t as y,bI as v,B as N,n as w,C as b}from"./index-
|
|
1
|
+
import{r as a,A as p,j as e,t as y,bI as v,B as N,n as w,C as b}from"./index-DB2Tq9wz.js";import{C as c,a as d,b as k,c as C}from"./card-DRBgMGuU.js";import{B as m}from"./badge-CKwUSKzT.js";import{R as E}from"./refresh-cw-5y5jTc6x.js";const A=5e3;function $(){const[n,o]=a.useState([]),[i,x]=a.useState(!0),[h,u]=a.useState(new Set),l=a.useCallback(async()=>{x(!0);try{const s=await fetch(`${p}/api/v1/events?limit=${A}`);if(!s.ok)throw new Error("Failed to load events");const t=await s.json();o(Array.isArray(t.items)?[...t.items].reverse():[])}catch(s){console.error("Failed to load events:",s),o([])}finally{x(!1)}},[]),g=a.useCallback(s=>{u(t=>{const r=new Set(t);return r.has(s)?r.delete(s):r.add(s),r})},[]);a.useEffect(()=>{l()},[l]);const f=s=>{if(!s)return"Unknown time";try{return new Date(s).toLocaleString()}catch{return s}},j=s=>{switch(s?.toLowerCase()){case"error":return"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200";case"warn":case"warning":return"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200";case"info":return"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200";case"debug":return"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200";default:return"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200"}};return i?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Activity"}),e.jsx("p",{className:"text-muted-foreground",children:"View system activity and events"})]}),e.jsx(c,{children:e.jsx(d,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(y,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading events..."})]})})})]}):n.length===0?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Activity"}),e.jsx("p",{className:"text-muted-foreground",children:"View system activity and events"})]}),e.jsx(c,{children:e.jsx(d,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(v,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Events Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Activity events will appear here as they occur."})]})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Activity"}),e.jsxs("p",{className:"text-muted-foreground",children:["View system activity and events (",n.length," events)"]})]}),e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>void l(),disabled:i,children:[e.jsx(E,{className:`h-4 w-4 mr-2 ${i?"animate-spin":""}`}),"Refresh"]})]}),e.jsx("div",{className:"space-y-3",children:n.map(s=>{const t=h.has(s.seq);return e.jsxs(c,{className:"transition-colors",children:[e.jsx(k,{className:"py-3 cursor-pointer hover:bg-muted/30",onClick:()=>g(s.seq),children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-2 flex-1 min-w-0",children:[t?e.jsx(w,{className:"h-4 w-4 mt-0.5 text-muted-foreground shrink-0"}):e.jsx(b,{className:"h-4 w-4 mt-0.5 text-muted-foreground shrink-0"}),e.jsxs("div",{className:"space-y-1 flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(C,{className:"text-sm font-medium",children:["#",s.seq]}),s.kind&&e.jsx(m,{variant:"outline",className:"text-xs",children:s.kind}),s.level&&e.jsx(m,{className:`text-xs ${j(s.level)}`,children:s.level})]}),s.message&&e.jsx("p",{className:`text-sm text-muted-foreground ${t?"":"truncate"}`,children:s.message})]})]}),e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:f(s.ts)})]})}),t&&e.jsx(d,{className:"pt-0 pb-4",children:e.jsx("pre",{className:"text-xs bg-muted p-3 rounded-md overflow-x-auto",children:JSON.stringify(s,null,2)})})]},s.seq)})})]})}export{$ as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{s as R,r as t,bw as y,j as e,B as a,P as W,bx as X,E as Y,D as j,b as g,d as v,f,g as A,I as F,W as N,
|
|
1
|
+
import{s as R,r as t,bw as y,j as e,B as a,P as W,bx as X,E as Y,D as j,b as g,d as v,f,g as A,I as F,W as N,ae as J,v as i}from"./index-DB2Tq9wz.js";import{C as G,b as Q,c as V,d as Z,a as _}from"./card-DRBgMGuU.js";import{L as w}from"./label-DxDedS8x.js";import{B as ee}from"./badge-CKwUSKzT.js";import{A as I,a as C}from"./alert-C42EBWiI.js";import{I as L}from"./info-DMJxIp7i.js";import{C as se}from"./circle-alert-DP4rtmEK.js";function oe(){const{authEnabled:n}=R(),[P,k]=t.useState([]),[b,K]=t.useState(!0),[O,l]=t.useState(!1),[M,d]=t.useState(!1),[x,D]=t.useState(""),[h,E]=t.useState("never"),[c,S]=t.useState(null),[m,o]=t.useState(null);t.useEffect(()=>{p()},[]);const p=async()=>{K(!0);try{const s=await y("/api/v1/api-keys");s.success&&k(s.data?.apiKeys||[])}catch(s){console.error("Failed to load API keys:",s),k([])}finally{K(!1)}},U=async()=>{if(!x.trim()){i({title:"Error",description:"Please provide a name for the API key",variant:"destructive"});return}try{const s={name:x,scopes:["*"]};h!=="never"&&(s.expiresIn=h);const r=await y("/api/v1/api-keys",{method:"POST",body:JSON.stringify(s)});r.success&&(S(r.data),l(!1),d(!0),D(""),E("never"),await p(),i({title:"API Key Created",description:"Make sure to copy your API key now. You won't be able to see it again!"}))}catch(s){console.error("Failed to create API key:",s),i({title:"Error",description:"Failed to create API key",variant:"destructive"})}},B=async s=>{try{(await y(`/api/v1/api-keys/${s}`,{method:"DELETE"})).success&&(await p(),o(null),i({title:"API Key Deleted",description:"The API key has been permanently deleted"}))}catch(r){console.error("Failed to delete API key:",r),i({title:"Error",description:"Failed to delete API key",variant:"destructive"})}},H=async s=>{try{await navigator.clipboard.writeText(s),i({title:"Copied",description:"API key copied to clipboard"})}catch{i({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},u=s=>new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),$=s=>s?new Date(s)<new Date:!1,q=typeof window<"u"?window.location.origin:"http://localhost:3000",z=c?`curl -H "X-API-Key: ${c.key}" \\
|
|
2
2
|
+ ${q}/api/v1/tasks`:"",T=n?null:e.jsxs(I,{children:[e.jsx(L,{className:"h-4 w-4"}),e.jsxs(C,{children:["Authentication is currently disabled. API keys will only be required once you enable authentication in the ",e.jsx("a",{href:"/settings/authentication",className:"underline",children:"Authentication settings"}),"."]})]});return!n&&b?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"API Keys"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage API keys for programmatic access"})]}),T]}):b?e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"API Keys"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"API Keys"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage API keys for programmatic access to your Coconut instance"})]}),T,n&&e.jsxs(I,{children:[e.jsx(L,{className:"h-4 w-4"}),e.jsxs(C,{children:["API keys provide programmatic access to your Coconut instance. Use them in CI/CD pipelines or automation scripts by including the key in the ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:"X-API-Key"})," header."]})]}),e.jsxs(G,{children:[e.jsx(Q,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(V,{children:"Active API Keys"}),e.jsx(Z,{children:"API keys you've created for programmatic access"})]}),e.jsxs(a,{onClick:()=>l(!0),disabled:!n,children:[e.jsx(W,{className:"mr-2 h-4 w-4"}),"Create API Key"]})]})}),e.jsx(_,{children:P.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(X,{className:"h-12 w-12 mx-auto mb-4 opacity-20"}),e.jsx("p",{children:"No API keys yet"}),e.jsx("p",{className:"text-sm",children:"Create an API key to get started with programmatic access"})]}):e.jsx("div",{className:"space-y-4",children:P.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("p",{className:"font-medium",children:s.name}),$(s.expiresAt)&&e.jsx(ee,{variant:"destructive",children:"Expired"})]}),e.jsx("p",{className:"text-sm text-muted-foreground font-mono",children:s.keyPreview}),e.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Created: ",u(s.createdAt)]}),s.expiresAt&&e.jsxs("span",{children:["Expires: ",u(s.expiresAt)]}),s.lastUsedAt&&e.jsxs("span",{children:["Last used: ",u(s.lastUsedAt)]})]})]}),e.jsx(a,{variant:"ghost",size:"icon",onClick:()=>o(s.id),children:e.jsx(Y,{className:"h-4 w-4 text-destructive"})})]},s.id))})})]}),e.jsx(j,{open:O,onOpenChange:l,children:e.jsxs(g,{children:[e.jsxs(v,{children:[e.jsx(f,{children:"Create API Key"}),e.jsx(A,{children:"Create a new API key for programmatic access. The key will only be shown once."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"keyName",children:"Name"}),e.jsx(F,{id:"keyName",placeholder:"CI/CD Pipeline",value:x,onChange:s=>D(s.target.value)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"A descriptive name to identify this API key"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"keyExpiry",children:"Expiration"}),e.jsxs("select",{id:"keyExpiry",className:"w-full rounded-md border border-input bg-background px-3 py-2 text-sm",value:h,onChange:s=>E(s.target.value),children:[e.jsx("option",{value:"never",children:"Never"}),e.jsx("option",{value:"30d",children:"30 days"}),e.jsx("option",{value:"90d",children:"90 days"}),e.jsx("option",{value:"1y",children:"1 year"})]})]})]}),e.jsxs(N,{children:[e.jsx(a,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(a,{onClick:U,disabled:!n,children:"Create API Key"})]})]})}),e.jsx(j,{open:M,onOpenChange:d,children:e.jsxs(g,{className:"sm:max-w-[600px]",children:[e.jsxs(v,{children:[e.jsx(f,{children:"API Key Created"}),e.jsx(A,{children:"Make sure to copy your API key now. You won't be able to see it again!"})]}),e.jsxs(I,{variant:"destructive",className:"my-4",children:[e.jsx(se,{className:"h-4 w-4"}),e.jsx(C,{children:"This is the only time you will see this key. Store it securely."})]}),c&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{children:"API Key"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(F,{readOnly:!0,value:c.key,className:"font-mono text-sm"}),e.jsx(a,{variant:"outline",size:"icon",onClick:()=>H(c.key),children:e.jsx(J,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("p",{className:"mb-2",children:"Usage example:"}),e.jsx("pre",{className:"bg-muted p-3 rounded-md whitespace-pre-wrap break-words",children:e.jsx("code",{className:"font-mono text-xs",children:z})})]})]}),e.jsx(N,{children:e.jsx(a,{onClick:()=>{d(!1),S(null)},children:"I've Saved My Key"})})]})}),e.jsx(j,{open:!!m,onOpenChange:s=>!s&&o(null),children:e.jsxs(g,{children:[e.jsxs(v,{children:[e.jsx(f,{children:"Delete API Key"}),e.jsx(A,{children:"Are you sure you want to delete this API key? This action cannot be undone and any scripts using this key will stop working."})]}),e.jsxs(N,{children:[e.jsx(a,{variant:"outline",onClick:()=>o(null),children:"Cancel"}),e.jsx(a,{variant:"destructive",onClick:()=>m&&B(m),children:"Delete API Key"})]})]})})]})}export{oe as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{u as D,a as M,r as l,A as b,j as e,B as S,L as I,a0 as _,I as d,o as B}from"./index-
|
|
1
|
+
import{u as D,a as M,r as l,A as b,j as e,B as S,L as I,a0 as _,I as d,o as B}from"./index-DB2Tq9wz.js";import{C as u,a as p,b as j,c as v}from"./card-DRBgMGuU.js";import{L as o}from"./label-DxDedS8x.js";import{M as P}from"./markdown-editor-DJ2CscSp.js";import{A as R}from"./arrow-left-C8VbyW3d.js";import{C as $}from"./circle-check-big-3mrGMFVn.js";import"./index-Bedu89qc.js";function W(){const F=D(),{toast:h}=M(),[n,x]=l.useState({stack:{runtime:"",framework:"",language:"",database:"",deployment:"",repository:""},commands:{}}),[y,f]=l.useState(""),[E,k]=l.useState(""),[L,N]=l.useState(!0),[C,w]=l.useState(!1);l.useEffect(()=>{fetch(`${b}/api/v1/context/architecture`).then(t=>t.json()).then(t=>{if(t.success){const a=t.document,m={stack:{runtime:a.metadata.stack?.runtime||"",framework:a.metadata.stack?.framework||"",language:a.metadata.stack?.language||"",database:a.metadata.stack?.database||"",deployment:a.metadata.stack?.deployment||"",repository:a.metadata.stack?.repository||""},commands:a.metadata.commands||{}};x(m);const s=Object.entries(m.commands).map(([r,c])=>`${r}: ${c}`).join(`
|
|
2
2
|
`);k(s),f(a.content.trim())}N(!1)}).catch(t=>{console.error("Failed to load context:",t),h({title:"Error",description:"Failed to load architecture documentation",variant:"destructive"}),N(!1)})},[h]);const A=async()=>{w(!0);try{const a=await(await fetch(`${b}/api/v1/context/architecture`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:y,metadata:{stack:n.stack,commands:n.commands}})})).json();if(a.success)h({title:"Success",description:"Architecture documentation saved successfully",action:e.jsx($,{className:"h-4 w-4"})}),F("/context/architecture");else throw new Error(a.error||"Failed to save context")}catch(t){console.error("Save error:",t),h({title:"Error",description:"Failed to save architecture documentation",variant:"destructive"})}finally{w(!1)}},i=(t,a)=>{x(m=>{const s={...m},r=t.split(".");let c=s;for(let g=0;g<r.length-1;g++)c=c[r[g]];return c[r[r.length-1]]=a,s})},T=t=>{k(t);const a={};t.split(`
|
|
3
3
|
`).filter(s=>s.trim()).forEach(s=>{const[r,...c]=s.split(":");r&&c.length>0&&(a[r.trim()]=c.join(":").trim())}),x(s=>({...s,commands:a}))};return L?e.jsx("div",{className:"space-y-6",children:e.jsx(u,{children:e.jsx(p,{className:"pt-6",children:e.jsx("div",{className:"text-center",children:e.jsx("p",{children:"Loading..."})})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Edit Architecture"}),e.jsx("p",{className:"text-muted-foreground text-sm hidden sm:block",children:"Edit technical architecture and supporting metadata"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(S,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(I,{to:"/context/architecture",className:"text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(R,{className:"w-4 h-4"})})}),e.jsxs(S,{onClick:A,disabled:C,size:"sm",children:[e.jsx(_,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:C?"Saving...":"Save"})]})]})]}),e.jsxs(u,{children:[e.jsx(j,{children:e.jsx(v,{children:"Technology Stack"})}),e.jsxs(p,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"runtime",children:"Runtime"}),e.jsx(d,{id:"runtime",value:n.stack.runtime,onChange:t=>i("stack.runtime",t.target.value),placeholder:"node|python|go|etc"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"framework",children:"Framework"}),e.jsx(d,{id:"framework",value:n.stack.framework,onChange:t=>i("stack.framework",t.target.value),placeholder:"express|fastify|django|gin|etc"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"language",children:"Language"}),e.jsx(d,{id:"language",value:n.stack.language,onChange:t=>i("stack.language",t.target.value),placeholder:"typescript|javascript|python|go|etc"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"database",children:"Database"}),e.jsx(d,{id:"database",value:n.stack.database,onChange:t=>i("stack.database",t.target.value),placeholder:"postgresql|mysql|mongodb|sqlite|etc"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"deployment",children:"Deployment"}),e.jsx(d,{id:"deployment",value:n.stack.deployment,onChange:t=>i("stack.deployment",t.target.value),placeholder:"docker|kubernetes|vercel|aws|etc"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"repository",children:"Repository"}),e.jsx(d,{id:"repository",value:n.stack.repository,onChange:t=>i("stack.repository",t.target.value),placeholder:"https://github.com/yourorg/yourproject"})]})]})]})]}),e.jsxs(u,{children:[e.jsx(j,{children:e.jsx(v,{children:"Quick Commands"})}),e.jsx(p,{className:"space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"commands",children:"Commands (format: command_name: command_to_run)"}),e.jsx(B,{id:"commands",value:E,onChange:t=>T(t.target.value),placeholder:`install: npm install
|
|
4
4
|
dev: npm run dev
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as g,r as n,A as v,j as e,t as y,F as k,B as l,M as b,au as w,L as C,Y as E,
|
|
1
|
+
import{a as g,r as n,A as v,j as e,t as y,F as k,B as l,M as b,au as w,L as C,Y as E,aq as A}from"./index-DB2Tq9wz.js";import{C as a,a as c,b as o,c as m}from"./card-DRBgMGuU.js";import{c as D}from"./clipboard-B9ndUJKl.js";function S(){const{toast:h}=g(),[r,x]=n.useState(null),[u,p]=n.useState(!0),[j,i]=n.useState(!1);n.useEffect(()=>{fetch(`${v}/api/v1/context/architecture`).then(t=>{if(t.ok)return t.json();throw new Error("Not found")}).then(t=>{t.success?(x(t.document),i(!0)):i(!1)}).catch(()=>{i(!1)}).finally(()=>{p(!1)})},[]);const N=async()=>{const t=".nut/context/architecture.md";try{await D(t),h({title:"Copied!",description:`Path ${t} copied to clipboard`})}catch(d){console.error("Failed to copy path:",d),h({title:"Error",description:"Failed to copy path to clipboard",variant:"destructive"})}},f=()=>{const t=new CustomEvent("discuss-in-chat",{detail:{type:"context",id:"architecture-md",filename:"architecture.md",name:"architecture.md",path:".nut/context/architecture.md"}});window.dispatchEvent(t)};if(u)return e.jsx("div",{className:"space-y-6",children:e.jsx(a,{children:e.jsx(c,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(y,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading architecture documentation..."})]})})})});if(!j||!r)return e.jsx("div",{className:"space-y-6",children:e.jsx(a,{children:e.jsx(c,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(k,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Architecture Documentation Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Architecture documentation will appear here once created."})]})})})});const s=r.metadata;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Technical Architecture"}),e.jsx("p",{className:"text-muted-foreground",children:"System design, components, and technical patterns"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(l,{variant:"outline",size:"sm",onClick:f,children:[e.jsx(b,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsxs(l,{variant:"outline",size:"sm",onClick:N,children:[e.jsx(w,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy Path"})]}),e.jsx(l,{size:"sm",asChild:!0,children:e.jsxs(C,{to:"/context/architecture/edit",children:[e.jsx(E,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})})]})]}),s&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(a,{children:[e.jsx(o,{className:"pb-3",children:e.jsx(m,{className:"text-lg font-semibold",children:"Technology Stack"})}),e.jsx(c,{className:"space-y-3",children:s.stack&&e.jsxs("div",{className:"space-y-1 text-sm",children:[s.stack.runtime&&e.jsxs("div",{children:["Runtime: ",s.stack.runtime]}),s.stack.framework&&e.jsxs("div",{children:["Framework: ",s.stack.framework]}),s.stack.language&&e.jsxs("div",{children:["Language: ",s.stack.language]}),s.stack.database&&e.jsxs("div",{children:["Database: ",s.stack.database]}),s.stack.deployment&&e.jsxs("div",{children:["Deployment: ",s.stack.deployment]}),s.stack.repository&&e.jsxs("div",{children:["Repository:"," ",e.jsx("a",{href:s.stack.repository,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:s.stack.repository})]})]})})]}),e.jsxs(a,{children:[e.jsx(o,{className:"pb-3",children:e.jsx(m,{className:"text-lg font-semibold",children:"Quick Commands"})}),e.jsx(c,{className:"space-y-3",children:s.commands&&e.jsxs("div",{className:"space-y-1",children:[Object.entries(s.commands).slice(0,5).map(([t,d])=>e.jsxs("div",{className:"text-sm",children:[e.jsxs("span",{className:"font-medium capitalize",children:[t,": "]}),e.jsx("code",{className:"bg-muted px-2 py-1 rounded text-xs",children:d})]},t)),Object.entries(s.commands).length>5&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["+ ",Object.entries(s.commands).length-5," more commands"]})]})})]})]}),e.jsxs(a,{children:[e.jsx(o,{children:e.jsx(m,{className:"text-lg font-semibold",children:"Architecture Documentation"})}),e.jsx(c,{children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(A,{children:r.content||"No content available"})})})]})]})}export{S as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as Y,s as le,r as n,bw as c,j as e,bv as O,i as ce,D as I,V as M,B as l,b as V,d as $,f as H,g as J,I as j,W as z,y as oe,z as de,E as he,H as ue,J as xe,N as me,O as ge,Q as je,R as pe,U as ve,v as r}from"./index-
|
|
1
|
+
import{c as Y,s as le,r as n,bw as c,j as e,bv as O,i as ce,D as I,V as M,B as l,b as V,d as $,f as H,g as J,I as j,W as z,y as oe,z as de,E as he,H as ue,J as xe,N as me,O as ge,Q as je,R as pe,U as ve,v as r}from"./index-DB2Tq9wz.js";import{C as p,b as v,c as w,d as f,a as y}from"./card-DRBgMGuU.js";import{L as o}from"./label-DxDedS8x.js";import{S as _,a as W,b as q,c as B,d as a}from"./select-BzOa_wZx.js";import{S as U}from"./switch-Bf2z8aaj.js";import{B as k}from"./badge-CKwUSKzT.js";import{C as we}from"./circle-alert-DP4rtmEK.js";import"./index-Bedu89qc.js";import"./chevron-up-DJfyvHso.js";/**
|
|
2
2
|
* @license lucide-react v0.542.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as m,j as e,t as x,A as f}from"./index-
|
|
1
|
+
import{r as m,j as e,t as x,A as f}from"./index-DB2Tq9wz.js";import{C as w}from"./circle-check-Cnp-EoKX.js";import{C as b}from"./circle-x-DxbiyJ6w.js";const r="coconut/github-auth-state";function j(s){try{window.opener&&window.opener.postMessage({type:"github-auth",...s},window.location.origin)}catch{}}const v=()=>{const[s,d]=m.useState("pending"),[h,p]=m.useState("Authorizing GitHub…");return m.useEffect(()=>{const a=new URLSearchParams(window.location.search),u=a.get("error"),l=a.get("token"),n=a.get("expires_at")||a.get("expiresAt"),c=a.get("state"),o=t=>{j(t),d(t.success?"success":"error"),p(t.message),setTimeout(()=>{try{window.close()}catch{}},1200)};if(u){localStorage.removeItem(r),o({success:!1,message:decodeURIComponent(u)});return}if(!l||!n||!c){localStorage.removeItem(r),o({success:!1,message:"Missing authorization parameters. Please try again."});return}const g=localStorage.getItem(r);if(!g||g!==c){localStorage.removeItem(r),o({success:!1,message:"Authorization state mismatch. Please start again."});return}(async()=>{try{const t=await fetch(`${f}/api/v1/git/providers/github/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:l,expiresAt:n,state:c})}),i=await t.json();if(!t.ok||!i.success)throw new Error(i?.error?.message||"Failed to store GitHub token");localStorage.removeItem(r),o({success:!0,message:"GitHub connected successfully!",expiresAt:i.data?.expiresAt||n})}catch(t){localStorage.removeItem(r),o({success:!1,message:t?.message||"Failed to store GitHub token. Please try again."})}})()},[]),e.jsx("div",{className:"flex h-screen items-center justify-center bg-background px-6",children:e.jsxs("div",{className:"max-w-sm rounded-lg border bg-card p-6 text-center shadow-sm",children:[e.jsxs("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:[s==="pending"&&e.jsx(x,{className:"h-6 w-6 animate-spin text-muted-foreground"}),s==="success"&&e.jsx(w,{className:"h-6 w-6 text-green-600"}),s==="error"&&e.jsx(b,{className:"h-6 w-6 text-red-600"})]}),e.jsx("h1",{className:"text-lg font-semibold",children:"GitHub Authorization"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:h}),s!=="pending"&&e.jsx("p",{className:"mt-4 text-xs text-muted-foreground",children:"You can close this window and return to Coconut."})]})})};export{v as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{u as ce,a as de,r as i,j as e,B as r,T as oe,n as M,X as me,F as xe,Y as he,D as ue,b as fe,d as pe,f as je,k as ge,a2 as B,a3 as R,a4 as H,a5 as L,a6 as O,aa as G,a9 as ve,o as Ne,A as T}from"./index-PyVlsLW8.js";import{C as g,b as ye,a as _,c as we}from"./card-xkODbJy-.js";import{B as U}from"./badge-D4vHU_w_.js";import{u as Se}from"./use-terminal-CFbQv1ie.js";import{T as Ce}from"./terminal-preview-DTUohQ5b.js";import{S as be,a as ke,b as Ae,c as De,d as w}from"./select-B1v2u6hQ.js";import{b as Me,e as Te,d as Ie,c as $e,a as Ee}from"./pipeline-builders-Bkf0wt_O.js";import{R as Pe}from"./refresh-cw-B1bWW9Rg.js";import{C as ze,a as Fe}from"./chevrons-up-CLKrQHMU.js";import{P as Be}from"./play-DtFz_MLh.js";import{C as Re}from"./code-DTW3giBe.js";import{C as He}from"./chevron-up-BB-6OS4z.js";import"./xterm-DTxiCjtJ.js";import"./index-BQYB8kWb.js";const Le=c=>c?Array.isArray(c)?c.filter(x=>typeof x=="string").map(x=>x.trim()).filter(Boolean):typeof c=="string"?c.split(",").map(x=>x.trim()).filter(Boolean):[]:[];function ss(){const c=ce(),{sessions:x,loading:b,error:I,refreshSessions:S,createSession:V,destroySession:K}=Se(),{toast:v}=de(),[$,W]=i.useState([]),[q,X]=i.useState(!0),[j,k]=i.useState(()=>({})),[A,N]=i.useState(!1),[f,Y]=i.useState("claude"),[E,J]=i.useState(""),[D,P]=i.useState(!1),[h,Q]=i.useState([]),[p,y]=i.useState([]),[Z,ee]=i.useState({}),[u,se]=i.useState([]),[o,C]=i.useState([]),te=s=>{const t=Date.now(),a=new Date(s).getTime(),n=Math.max(0,Math.floor((t-a)/1e3));if(n<60)return`${n}s ago`;const d=Math.floor(n/60);if(d<60)return`${d}m ago`;const l=Math.floor(d/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`};i.useEffect(()=>{(async()=>{try{const t=await fetch(`${T}/api/v1/tasks`);if(t.ok){const a=await t.json(),n=a.data||a;W(Array.isArray(n)?n:[])}}catch(t){console.error("Error loading tasks:",t)}finally{X(!1)}})()},[]),i.useEffect(()=>{S()},[S]),i.useEffect(()=>{if(!A)return;(async()=>{try{const t=await fetch(`${T}/api/v1/mcp`);if(t.ok){const a=await t.json();a?.success&&Array.isArray(a.servers)&&(Q(a.servers),y(n=>n.filter(d=>a.servers.includes(d))),a.mcpServers&&typeof a.mcpServers=="object"&&ee(a.mcpServers))}}catch(t){console.error("Failed to load MCP servers",t)}try{const t=await fetch(`${T}/api/v1/skills`);if(t.ok){const a=await t.json(),d=(Array.isArray(a?.documents)?a.documents:[]).map(l=>({id:l.id,name:l?.metadata?.name||l.id,mcpServers:Le(l?.metadata?.metadata?.mcpServers)}));se(d),C(l=>l.filter(F=>d.some(le=>le.id===F)))}}catch(t){console.error("Failed to load skills",t)}})()},[A]),i.useEffect(()=>{o.length!==0&&y(s=>{const t=new Set(s),a=h.length>0?new Set(h):void 0;return o.forEach(n=>{const d=u.find(l=>l.id===n);d&&d.mcpServers.forEach(l=>{(!a||a.has(l))&&t.add(l)})}),Array.from(t)})},[o,u,h]);const m=i.useMemo(()=>x.filter(s=>s.taskId?.startsWith("cp-")||s.taskId?.startsWith("ag-")).sort((s,t)=>new Date(t.lastActivity).getTime()-new Date(s.lastActivity).getTime()),[x]);i.useEffect(()=>{k(s=>{const t={...s};return m.forEach(a=>{a.id in t||(t[a.id]=!0)}),t})},[m]);const z=i.useMemo(()=>$.filter(s=>s.status==="draft"||s.status==="ready").sort((s,t)=>new Date(t.metadata.createdAt).getTime()-new Date(s.metadata.createdAt).getTime()).slice(0,3),[$]),ae=()=>{const s=m.every(a=>j[a.id]),t={};m.forEach(a=>{t[a.id]=!s}),k(t)},ie=m.length>0&&m.every(s=>j[s.id]),ne=async s=>{await K(s)?(v({title:"Session closed",description:s}),setTimeout(()=>S(),100)):v({title:"Failed to close session",description:s,variant:"destructive"})},re=async()=>{P(!0);try{const s=`session-${Date.now()}`,t={taskId:s,contextType:"change-task",cliAgent:f,mcpServersMap:Z,selectedMcpServers:p,skills:u,selectedSkillIds:o,automationEnabled:!1,customInstruction:E.trim(),includeDefaultInstructions:!1};let a="";f==="claude"?a=Me(t):f==="gemini"?a=Te(t):f==="codex"?a=Ie(t):f==="droid"?a=$e(t):f==="kiro"&&(a=Ee(t)),await V(s,a)?(v({title:"Coding session started",description:`Session ${s} created`}),N(!1),c(`/terminal/${s}`)):v({title:"Failed to start session",description:"Could not create terminal session",variant:"destructive"})}catch(s){console.error("Error starting coding session:",s),v({title:"Error",description:"Failed to start coding session",variant:"destructive"})}finally{P(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Agents"}),e.jsx("p",{className:"text-muted-foreground hidden sm:block",children:"Manage agents and their active sessions"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(r,{variant:"outline",size:"sm",onClick:()=>S(),disabled:b,children:[e.jsx(Pe,{className:`h-4 w-4 sm:mr-2 ${b?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),m.length>0&&e.jsx(r,{variant:"outline",size:"sm",onClick:ae,children:ie?e.jsxs(e.Fragment,{children:[e.jsx(ze,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Hide All"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Fe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Show All"})]})}),e.jsxs(r,{size:"sm",onClick:()=>N(!0),children:[e.jsx(Be,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Interactive Session"})]})]})]}),I&&e.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("div",{className:"text-red-600",children:I})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sessions"}),b?e.jsx("div",{className:"space-y-2",children:[...Array(2)].map((s,t)=>e.jsx(g,{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-4 w-4 rounded bg-muted animate-pulse"}),e.jsxs("div",{children:[e.jsx("div",{className:"h-4 w-40 bg-muted rounded animate-pulse mb-2"}),e.jsx("div",{className:"h-3 w-24 bg-muted rounded animate-pulse"})]})]}),e.jsx("div",{className:"h-6 w-20 bg-muted rounded animate-pulse"})]})},t))}):m.length===0?e.jsx(g,{className:"p-8",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3",children:[e.jsx(Re,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No active sessions"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Get started by launching an"," ",e.jsx("button",{onClick:()=>N(!0),className:"text-primary hover:underline font-medium",children:"Interactive Session"})," ","or working on a"," ",e.jsx("button",{onClick:()=>c("/tasks"),className:"text-primary hover:underline font-medium",children:"New Task"})]})]})]})}):e.jsx("div",{className:"space-y-2",children:m.slice(0,10).map(s=>e.jsxs(g,{className:"p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(oe,{className:"h-4 w-4 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:s.taskId}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Session ",s.id.split("-").slice(-1)[0].substring(0,8)," • Last activity ",te(s.lastActivity)]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("div",{className:`flex items-center gap-1 ${s.connected?"text-green-600":"text-gray-400"}`,title:s.connected?"Connected":"Disconnected",children:e.jsx("div",{className:`w-2 h-2 rounded-full ${s.connected?"bg-green-500":"bg-gray-400"}`})}),e.jsx(r,{size:"sm",variant:"outline",onClick:()=>{k(t=>({...t,[s.id]:!t[s.id]}))},"aria-label":j[s.id]?"Hide preview":"Show preview",title:j[s.id]?"Hide preview":"Show preview",children:j[s.id]?e.jsx(He,{className:"h-4 w-4"}):e.jsx(M,{className:"h-4 w-4"})}),e.jsx(r,{size:"sm",variant:"outline",onClick:()=>c(`/terminal/${s.taskId}`),children:"Open"}),e.jsx(r,{size:"icon",variant:"destructive",onClick:()=>ne(s.id),title:"Close session","aria-label":"Close session",children:e.jsx(me,{className:"h-4 w-4"})})]})]}),j[s.id]&&e.jsx("div",{className:"mt-2 w-full p-2 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>c(`/terminal/${s.taskId}`),title:"Click to open full terminal session",children:e.jsx(Ce,{sessionId:s.id,heightPx:160,maxScrollback:200})})]},s.id))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"New Tasks"}),q?e.jsx("div",{className:"space-y-3",children:[...Array(3)].map((s,t)=>e.jsx(g,{children:e.jsx(ye,{className:"py-3",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-2/3 animate-pulse"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/3 animate-pulse"})]}),e.jsx("div",{className:"h-5 bg-muted rounded w-16 animate-pulse"})]})})},t))}):z.length===0?e.jsx(g,{children:e.jsx(_,{className:"flex items-center justify-center py-6",children:e.jsx("div",{className:"text-center text-sm text-gray-500",children:"No draft or approved tasks found"})})}):e.jsx("div",{className:"space-y-2",children:z.map(s=>e.jsx(g,{className:"hover:shadow-md transition-all cursor-pointer hover:border-primary/50",onClick:()=>c(`/terminal/${s.id}`),children:e.jsx(_,{className:"py-4",children:e.jsx("div",{className:"flex justify-between items-start gap-4",children:e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(we,{className:"text-base leading-tight",children:s.title||s.intent}),e.jsxs("div",{className:"flex gap-1 ml-3 flex-shrink-0",children:[s.priority&&e.jsx(U,{variant:s.priority==="high"||s.priority==="critical"?"destructive":s.priority==="medium"?"secondary":"outline",className:"text-xs",children:s.priority}),e.jsx(U,{variant:"default",className:"text-xs",children:s.status})]})]}),s.content&&e.jsxs("div",{className:"text-sm text-muted-foreground leading-relaxed",children:[s.content.split(`
|
|
1
|
+
import{u as ce,a as de,r as i,j as e,B as r,T as oe,n as M,X as me,F as xe,Y as he,D as ue,b as fe,d as pe,f as je,k as ge,a4 as B,a5 as R,a6 as H,a7 as L,a8 as O,a9 as G,a3 as ve,o as Ne,A as T}from"./index-DB2Tq9wz.js";import{C as g,b as ye,a as _,c as we}from"./card-DRBgMGuU.js";import{B as U}from"./badge-CKwUSKzT.js";import{u as Se}from"./use-terminal-D6Qe1nwM.js";import{T as Ce}from"./terminal-preview-BfrUN2ok.js";import{S as be,a as ke,b as Ae,c as De,d as w}from"./select-BzOa_wZx.js";import{b as Me,e as Te,d as Ie,c as $e,a as Ee}from"./pipeline-builders-Bkf0wt_O.js";import{R as Pe}from"./refresh-cw-5y5jTc6x.js";import{C as ze,a as Fe}from"./chevrons-up-DfFpzHXf.js";import{P as Be}from"./play-B0y1weCV.js";import{C as Re}from"./code-DSNMK8tD.js";import{C as He}from"./chevron-up-DJfyvHso.js";import"./xterm-DTxiCjtJ.js";import"./index-Bedu89qc.js";const Le=c=>c?Array.isArray(c)?c.filter(x=>typeof x=="string").map(x=>x.trim()).filter(Boolean):typeof c=="string"?c.split(",").map(x=>x.trim()).filter(Boolean):[]:[];function ss(){const c=ce(),{sessions:x,loading:b,error:I,refreshSessions:S,createSession:V,destroySession:K}=Se(),{toast:v}=de(),[$,W]=i.useState([]),[q,X]=i.useState(!0),[j,k]=i.useState(()=>({})),[A,N]=i.useState(!1),[f,Y]=i.useState("claude"),[E,J]=i.useState(""),[D,P]=i.useState(!1),[h,Q]=i.useState([]),[p,y]=i.useState([]),[Z,ee]=i.useState({}),[u,se]=i.useState([]),[o,C]=i.useState([]),te=s=>{const t=Date.now(),a=new Date(s).getTime(),n=Math.max(0,Math.floor((t-a)/1e3));if(n<60)return`${n}s ago`;const d=Math.floor(n/60);if(d<60)return`${d}m ago`;const l=Math.floor(d/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`};i.useEffect(()=>{(async()=>{try{const t=await fetch(`${T}/api/v1/tasks`);if(t.ok){const a=await t.json(),n=a.data||a;W(Array.isArray(n)?n:[])}}catch(t){console.error("Error loading tasks:",t)}finally{X(!1)}})()},[]),i.useEffect(()=>{S()},[S]),i.useEffect(()=>{if(!A)return;(async()=>{try{const t=await fetch(`${T}/api/v1/mcp`);if(t.ok){const a=await t.json();a?.success&&Array.isArray(a.servers)&&(Q(a.servers),y(n=>n.filter(d=>a.servers.includes(d))),a.mcpServers&&typeof a.mcpServers=="object"&&ee(a.mcpServers))}}catch(t){console.error("Failed to load MCP servers",t)}try{const t=await fetch(`${T}/api/v1/skills`);if(t.ok){const a=await t.json(),d=(Array.isArray(a?.documents)?a.documents:[]).map(l=>({id:l.id,name:l?.metadata?.name||l.id,mcpServers:Le(l?.metadata?.metadata?.mcpServers)}));se(d),C(l=>l.filter(F=>d.some(le=>le.id===F)))}}catch(t){console.error("Failed to load skills",t)}})()},[A]),i.useEffect(()=>{o.length!==0&&y(s=>{const t=new Set(s),a=h.length>0?new Set(h):void 0;return o.forEach(n=>{const d=u.find(l=>l.id===n);d&&d.mcpServers.forEach(l=>{(!a||a.has(l))&&t.add(l)})}),Array.from(t)})},[o,u,h]);const m=i.useMemo(()=>x.filter(s=>s.taskId?.startsWith("cp-")||s.taskId?.startsWith("ag-")).sort((s,t)=>new Date(t.lastActivity).getTime()-new Date(s.lastActivity).getTime()),[x]);i.useEffect(()=>{k(s=>{const t={...s};return m.forEach(a=>{a.id in t||(t[a.id]=!0)}),t})},[m]);const z=i.useMemo(()=>$.filter(s=>s.status==="draft"||s.status==="ready").sort((s,t)=>new Date(t.metadata.createdAt).getTime()-new Date(s.metadata.createdAt).getTime()).slice(0,3),[$]),ae=()=>{const s=m.every(a=>j[a.id]),t={};m.forEach(a=>{t[a.id]=!s}),k(t)},ie=m.length>0&&m.every(s=>j[s.id]),ne=async s=>{await K(s)?(v({title:"Session closed",description:s}),setTimeout(()=>S(),100)):v({title:"Failed to close session",description:s,variant:"destructive"})},re=async()=>{P(!0);try{const s=`session-${Date.now()}`,t={taskId:s,contextType:"change-task",cliAgent:f,mcpServersMap:Z,selectedMcpServers:p,skills:u,selectedSkillIds:o,automationEnabled:!1,customInstruction:E.trim(),includeDefaultInstructions:!1};let a="";f==="claude"?a=Me(t):f==="gemini"?a=Te(t):f==="codex"?a=Ie(t):f==="droid"?a=$e(t):f==="kiro"&&(a=Ee(t)),await V(s,a)?(v({title:"Coding session started",description:`Session ${s} created`}),N(!1),c(`/terminal/${s}`)):v({title:"Failed to start session",description:"Could not create terminal session",variant:"destructive"})}catch(s){console.error("Error starting coding session:",s),v({title:"Error",description:"Failed to start coding session",variant:"destructive"})}finally{P(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Agents"}),e.jsx("p",{className:"text-muted-foreground hidden sm:block",children:"Manage agents and their active sessions"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(r,{variant:"outline",size:"sm",onClick:()=>S(),disabled:b,children:[e.jsx(Pe,{className:`h-4 w-4 sm:mr-2 ${b?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),m.length>0&&e.jsx(r,{variant:"outline",size:"sm",onClick:ae,children:ie?e.jsxs(e.Fragment,{children:[e.jsx(ze,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Hide All"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Fe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Show All"})]})}),e.jsxs(r,{size:"sm",onClick:()=>N(!0),children:[e.jsx(Be,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Interactive Session"})]})]})]}),I&&e.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("div",{className:"text-red-600",children:I})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sessions"}),b?e.jsx("div",{className:"space-y-2",children:[...Array(2)].map((s,t)=>e.jsx(g,{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-4 w-4 rounded bg-muted animate-pulse"}),e.jsxs("div",{children:[e.jsx("div",{className:"h-4 w-40 bg-muted rounded animate-pulse mb-2"}),e.jsx("div",{className:"h-3 w-24 bg-muted rounded animate-pulse"})]})]}),e.jsx("div",{className:"h-6 w-20 bg-muted rounded animate-pulse"})]})},t))}):m.length===0?e.jsx(g,{className:"p-8",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3",children:[e.jsx(Re,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No active sessions"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Get started by launching an"," ",e.jsx("button",{onClick:()=>N(!0),className:"text-primary hover:underline font-medium",children:"Interactive Session"})," ","or working on a"," ",e.jsx("button",{onClick:()=>c("/tasks"),className:"text-primary hover:underline font-medium",children:"New Task"})]})]})]})}):e.jsx("div",{className:"space-y-2",children:m.slice(0,10).map(s=>e.jsxs(g,{className:"p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(oe,{className:"h-4 w-4 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:s.taskId}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Session ",s.id.split("-").slice(-1)[0].substring(0,8)," • Last activity ",te(s.lastActivity)]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("div",{className:`flex items-center gap-1 ${s.connected?"text-green-600":"text-gray-400"}`,title:s.connected?"Connected":"Disconnected",children:e.jsx("div",{className:`w-2 h-2 rounded-full ${s.connected?"bg-green-500":"bg-gray-400"}`})}),e.jsx(r,{size:"sm",variant:"outline",onClick:()=>{k(t=>({...t,[s.id]:!t[s.id]}))},"aria-label":j[s.id]?"Hide preview":"Show preview",title:j[s.id]?"Hide preview":"Show preview",children:j[s.id]?e.jsx(He,{className:"h-4 w-4"}):e.jsx(M,{className:"h-4 w-4"})}),e.jsx(r,{size:"sm",variant:"outline",onClick:()=>c(`/terminal/${s.taskId}`),children:"Open"}),e.jsx(r,{size:"icon",variant:"destructive",onClick:()=>ne(s.id),title:"Close session","aria-label":"Close session",children:e.jsx(me,{className:"h-4 w-4"})})]})]}),j[s.id]&&e.jsx("div",{className:"mt-2 w-full p-2 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>c(`/terminal/${s.taskId}`),title:"Click to open full terminal session",children:e.jsx(Ce,{sessionId:s.id,heightPx:160,maxScrollback:200})})]},s.id))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"New Tasks"}),q?e.jsx("div",{className:"space-y-3",children:[...Array(3)].map((s,t)=>e.jsx(g,{children:e.jsx(ye,{className:"py-3",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-2/3 animate-pulse"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/3 animate-pulse"})]}),e.jsx("div",{className:"h-5 bg-muted rounded w-16 animate-pulse"})]})})},t))}):z.length===0?e.jsx(g,{children:e.jsx(_,{className:"flex items-center justify-center py-6",children:e.jsx("div",{className:"text-center text-sm text-gray-500",children:"No draft or approved tasks found"})})}):e.jsx("div",{className:"space-y-2",children:z.map(s=>e.jsx(g,{className:"hover:shadow-md transition-all cursor-pointer hover:border-primary/50",onClick:()=>c(`/terminal/${s.id}`),children:e.jsx(_,{className:"py-4",children:e.jsx("div",{className:"flex justify-between items-start gap-4",children:e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(we,{className:"text-base leading-tight",children:s.title||s.intent}),e.jsxs("div",{className:"flex gap-1 ml-3 flex-shrink-0",children:[s.priority&&e.jsx(U,{variant:s.priority==="high"||s.priority==="critical"?"destructive":s.priority==="medium"?"secondary":"outline",className:"text-xs",children:s.priority}),e.jsx(U,{variant:"default",className:"text-xs",children:s.status})]})]}),s.content&&e.jsxs("div",{className:"text-sm text-muted-foreground leading-relaxed",children:[s.content.split(`
|
|
2
2
|
`).slice(0,2).join(" ").substring(0,150),s.content.length>150?"...":""]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{className:"text-xs text-muted-foreground",children:[s.id," • by ",s.author.name," • ",new Date(s.metadata.createdAt).toLocaleDateString()]}),e.jsxs("div",{className:"flex gap-2",onClick:t=>t.stopPropagation(),children:[e.jsxs(r,{variant:"ghost",size:"sm",onClick:()=>c(`/tasks/${s.id}`),className:"h-7 px-2 text-xs",children:[e.jsx(xe,{className:"h-3 w-3 mr-1"})," View"]}),e.jsxs(r,{variant:"ghost",size:"sm",onClick:()=>c(`/tasks/${s.id}/edit`),className:"h-7 px-2 text-xs",children:[e.jsx(he,{className:"h-3 w-3 mr-1"})," Edit"]})]})]})]})})})},s.id))})]}),e.jsx(ue,{open:A,onOpenChange:N,children:e.jsxs(fe,{className:"max-w-lg",children:[e.jsxs(pe,{children:[e.jsx(je,{children:"Start Agent"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Start an interactive session"})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Agent"}),e.jsxs(be,{value:f,onValueChange:s=>Y(s),children:[e.jsx(ke,{className:"w-full",children:e.jsx(Ae,{placeholder:"Select coding agent"})}),e.jsxs(De,{children:[e.jsx(w,{value:"claude",children:"Claude Code"}),e.jsx(w,{value:"gemini",children:"Google Gemini"}),e.jsx(w,{value:"codex",children:"OpenAI Codex"}),e.jsx(w,{value:"droid",children:"Factory Droid"}),e.jsx(w,{value:"kiro",children:"Kiro"})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ge,{className:"h-4 w-4"}),"Skills"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[o.length," of ",u.length," selected"]})]}),e.jsxs(B,{children:[e.jsx(R,{asChild:!0,children:e.jsxs(r,{variant:"outline",className:"w-full justify-between",children:[o.length===0?"Select skills...":o.length===u.length?"All skills selected":`${o.length} skill${o.length!==1?"s":""} selected`,e.jsx(M,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(H,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(L,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Skills"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(r,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),C(u.map(t=>t.id))},children:"All"}),e.jsx(r,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),C([])},children:"None"})]})]}),e.jsx(O,{}),u.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No skills found"}):u.map(s=>e.jsx(G,{checked:o.includes(s.id),onCheckedChange:t=>{C(a=>t?a.includes(s.id)?a:[...a,s.id]:a.filter(n=>n!==s.id))},children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:s.name}),s.mcpServers.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["MCP servers: ",s.mcpServers.join(", ")]}),s.mcpServers.length===0&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Inherits available MCP servers"})]})},s.id))]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(ve,{className:"h-4 w-4"}),"MCP Servers"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[p.length," of ",h.length," selected"]})]}),e.jsxs(B,{children:[e.jsx(R,{asChild:!0,children:e.jsxs(r,{variant:"outline",className:"w-full justify-between",children:[p.length===0?"Select MCP servers...":p.length===h.length?"All servers selected":`${p.length} server${p.length!==1?"s":""} selected`,e.jsx(M,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(H,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(L,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Servers"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(r,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),y(h)},children:"All"}),e.jsx(r,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),y([])},children:"None"})]})]}),e.jsx(O,{}),h.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-gray-500",children:"No MCP servers found"}):h.map(s=>e.jsx(G,{checked:p.includes(s),onCheckedChange:t=>{y(a=>t?a.includes(s)?a:[...a,s]:a.filter(n=>n!==s))},children:s},s))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Additional Instructions (optional)"}),e.jsx(Ne,{value:E,onChange:s=>J(s.target.value),placeholder:"Add any custom instructions for the coding agent...",rows:4,className:"resize-none"})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(r,{variant:"outline",onClick:()=>N(!1),disabled:D,children:"Cancel"}),e.jsx(r,{onClick:re,disabled:D,children:D?"Starting...":"Start Session"})]})]})]})})]})}export{ss as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as x,j as e,e as a,n as m}from"./index-
|
|
1
|
+
import{r as x,j as e,e as a,n as m}from"./index-DB2Tq9wz.js";function u({title:n,description:t,icon:r,defaultOpen:o=!1,children:i,className:l}){const[s,d]=x.useState(o);return e.jsxs("div",{className:a("rounded-lg border bg-card text-card-foreground",l),children:[e.jsxs("button",{type:"button",onClick:()=>d(c=>!c),className:"flex w-full items-center justify-between gap-4 px-4 py-3 text-left","aria-expanded":s,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[r,e.jsxs("div",{children:[e.jsx("p",{className:"font-medium leading-tight",children:n}),t&&e.jsx("p",{className:"text-sm text-muted-foreground leading-snug",children:t})]})]}),e.jsx(m,{className:a("h-4 w-4 shrink-0 transition-transform duration-200",s?"rotate-180":"rotate-0")})]}),s&&e.jsx("div",{className:"border-t px-4 py-4",children:i})]})}export{u as C};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as y,u as Re,a as Le,r as l,j as e,D as De,b as _e,d as te,e as f,f as ae,g as ne,S as re,B as d,C as le,I as B,h as G,i as qe,G as Ie,F as Pe,k as ue,Z as ze,l as We,m as Fe,T as ce,n as Ve,o as Be,L as N,P as Ee,M as $e,K as A,p as g,A as Ke}from"./index-
|
|
1
|
+
import{c as y,u as Re,a as Le,r as l,j as e,D as De,b as _e,d as te,e as f,f as ae,g as ne,S as re,B as d,C as le,I as B,h as G,i as qe,G as Ie,F as Pe,k as ue,Z as ze,l as We,m as Fe,T as ce,n as Ve,o as Be,L as N,P as Ee,M as $e,K as A,p as g,A as Ke}from"./index-DB2Tq9wz.js";import{C as x,a as u,b as R,c as L,d as ie}from"./card-DRBgMGuU.js";import{B as Ge}from"./badge-CKwUSKzT.js";import{g as He}from"./status-utils-PwF3DXLL.js";import{L as Oe}from"./label-DxDedS8x.js";import{S as oe,a as de,b as me,c as he,d as E}from"./select-BzOa_wZx.js";import{u as Ye}from"./use-terminal-D6Qe1nwM.js";import{T as Qe}from"./terminal-preview-BfrUN2ok.js";import{C as Ue}from"./circle-check-Cnp-EoKX.js";import{C as Ze}from"./chevron-left-2sP4ienq.js";import{S as Je}from"./search-B5deRThk.js";import{C as Xe}from"./code-DSNMK8tD.js";import{F as es}from"./folder-git-2-CW5Zi8Bm.js";import{E as ss}from"./external-link-BqUE-DMN.js";import{P as ts}from"./play-B0y1weCV.js";import{C as as}from"./clock-DGw3R_UL.js";import{C as ns}from"./circle-check-big-3mrGMFVn.js";import"./index-Bedu89qc.js";import"./chevron-up-DJfyvHso.js";import"./xterm-DTxiCjtJ.js";/**
|
|
2
2
|
* @license lucide-react v0.542.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as le,A as l,bF as ws,r as n,a as vs,
|
|
1
|
+
import{c as le,A as l,bF as ws,r as n,a as vs,ac as ys,j as e,L as ee,l as $e,B as o,G as D,aa as Ns,X as Cs,I as k,n as Me,E as Be,D as se,b as te,d as ae,f as re,g as ne,bx as ks,W as Oe}from"./index-DB2Tq9wz.js";import{C as ie}from"./card-DRBgMGuU.js";import{L as Re}from"./label-DxDedS8x.js";import{T as Ss,a as Ps,b as Ge,c as We}from"./tabs-DkdBSep3.js";import{C as Ts}from"./circle-check-Cnp-EoKX.js";import{C as As}from"./circle-x-DxbiyJ6w.js";import{A as Ds}from"./arrow-down-CuFFg288.js";import{A as Es}from"./arrow-up-vC1c-5gW.js";import{R as ze}from"./refresh-cw-5y5jTc6x.js";import{C as ce}from"./circle-alert-DP4rtmEK.js";import{C as Ue}from"./chevron-up-DJfyvHso.js";import{F as oe}from"./folder-git-2-CW5Zi8Bm.js";/**
|
|
2
2
|
* @license lucide-react v0.542.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as Te,r,a as He,A as u,j as e,bv as he,B as o,E as Fe,t as De,bx as ze,I as U,D as W,b as B,d as q,f as J,g as K,W as Y}from"./index-
|
|
1
|
+
import{c as Te,r,a as He,A as u,j as e,bv as he,B as o,E as Fe,t as De,bx as ze,I as U,D as W,b as B,d as q,f as J,g as K,W as Y}from"./index-DB2Tq9wz.js";import{C as xe,b as pe,c as ge,d as fe,a as be}from"./card-DRBgMGuU.js";import{L as f}from"./label-DxDedS8x.js";import{R as Me,a as je}from"./radio-group-DFNQiPDU.js";import{R as A}from"./refresh-cw-5y5jTc6x.js";import{E as ve}from"./external-link-BqUE-DMN.js";import{C as Oe}from"./circle-check-Cnp-EoKX.js";import{C as Ie}from"./circle-x-DxbiyJ6w.js";/**
|
|
2
2
|
* @license lucide-react v0.542.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{c as ge,a as ve,r as u,j as e,t as se,B as x,a0 as fe,$ as Ne,bt as
|
|
1
|
+
import{c as ge,a as ve,r as u,j as e,t as se,B as x,a0 as fe,$ as Ne,bt as Te,i as be,Z as Ce,bu as Se,I as c,o as O,aa as ae,P as E,bv as ne,E as we,A as ie}from"./index-DB2Tq9wz.js";import{C as y,b as j,c as g,d as v,a as f,e as Ae}from"./card-DRBgMGuU.js";import{L as o}from"./label-DxDedS8x.js";import{B as re}from"./badge-CKwUSKzT.js";import{S as ke,a as Ie,b as Oe,c as Fe,d as Pe}from"./select-BzOa_wZx.js";import{A as Ee,a as Me}from"./alert-C42EBWiI.js";import{T as De,a as Le,b as C,c as S}from"./tabs-DkdBSep3.js";import{E as Ue}from"./eye-BD57N1qQ.js";import{C as _e,a as Re}from"./clipboard-CQNR4_yT.js";import"./index-Bedu89qc.js";import"./chevron-up-DJfyvHso.js";/**
|
|
2
2
|
* @license lucide-react v0.542.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Je=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],$e=ge("refresh-ccw",Je),Be=["a2a_v0.2","a2a_v0.1","jsonrpc2","jsonrpc","openrpc","rest"],Ke=["GET","POST","PUT","PATCH","DELETE"],qe=()=>({id:"",skill:"",description:"",endpoint:"",method:"POST",enabled:!0,inputMimeType:"application/json",outputMimeType:"application/json",inputSchema:"",outputSchema:""}),w={id:"",name:"",description:"",version:"1.0.0",url:"",documentation:"",protocols:["a2a_v0.2"],authentication:{scheme:"api_key",in:"header",name:"X-API-Key",example:"",description:""},capabilities:[],supportedInputTypes:["application/json"],supportedOutputTypes:["application/json"],security:{transport:"https",encryption:"TLS 1.3",notes:""},contact:{name:"",email:""},lastUpdated:void 0},N=a=>({...a,protocols:[...a.protocols],authentication:{...a.authentication},capabilities:a.capabilities.map(n=>({...n})),supportedInputTypes:[...a.supportedInputTypes],supportedOutputTypes:[...a.supportedOutputTypes],security:{...a.security},contact:{...a.contact}}),F=()=>N(w);function He(a){if(!a)return F();const n=Array.isArray(a.protocols)?a.protocols.filter(r=>typeof r=="string"):[],d=Array.isArray(a.supportedContentTypes?.input)?a.supportedContentTypes.input.filter(r=>typeof r=="string"):[],A=Array.isArray(a.supportedContentTypes?.output)?a.supportedContentTypes.output.filter(r=>typeof r=="string"):[],b=Array.isArray(a.capabilities)?a.capabilities.map(r=>({id:typeof r.id=="string"?r.id:"",skill:typeof r.skill=="string"?r.skill:"",description:typeof r.description=="string"?r.description:"",endpoint:typeof r.endpoint=="string"?r.endpoint:"",method:typeof r.method=="string"?r.method:"POST",enabled:r?.enabled!==!1,inputMimeType:typeof r.input?.mimeType=="string"?r.input.mimeType:"application/json",outputMimeType:typeof r.output?.mimeType=="string"?r.output.mimeType:"application/json",inputSchema:r.input?.schema?JSON.stringify(r.input.schema,null,2):"",outputSchema:r.output?.schema?JSON.stringify(r.output.schema,null,2):""})):[],M={scheme:typeof a.authentication?.scheme=="string"?a.authentication.scheme:"api_key",in:typeof a.authentication?.in=="string"?a.authentication.in:"header",name:typeof a.authentication?.name=="string"?a.authentication.name:"X-API-Key",example:typeof a.authentication?.example=="string"?a.authentication.example:"",description:typeof a.authentication?.description=="string"?a.authentication.description:""};return{id:typeof a.id=="string"?a.id:"",name:typeof a.name=="string"?a.name:"",description:typeof a.description=="string"?a.description:"",version:typeof a.version=="string"?a.version:"1.0.0",url:typeof a.url=="string"?a.url:"",documentation:typeof a.documentation=="string"?a.documentation:"",protocols:n.length>0?n:w.protocols,authentication:M,capabilities:b,supportedInputTypes:d.length>0?d:w.supportedInputTypes,supportedOutputTypes:A.length>0?A:w.supportedOutputTypes,security:{transport:typeof a.security?.transport=="string"?a.security.transport:w.security.transport,encryption:typeof a.security?.encryption=="string"?a.security.encryption:w.security.encryption,notes:typeof a.security?.notes=="string"?a.security.notes:""},contact:{name:typeof a.contact?.name=="string"?a.contact.name:"",email:typeof a.contact?.email=="string"?a.contact.email:""},lastUpdated:typeof a.lastUpdated=="string"?a.lastUpdated:void 0}}function at(){const{toast:a}=ve(),[n,d]=u.useState(()=>F()),[A,b]=u.useState(()=>F()),[M,r]=u.useState(!0),[D,K]=u.useState(!1),[q,k]=u.useState(null),[H,L]=u.useState(""),[V,U]=u.useState(""),[X,_]=u.useState(""),[P,R]=u.useState(void 0),[oe,z]=u.useState(!1),le=u.useMemo(()=>{const t=new Set([...Be,...n.protocols]);return Array.from(t).sort()},[n.protocols]);u.useEffect(()=>{let t=!0;return(async()=>{r(!0),k(null);try{const s=await fetch(`${ie}/api/v1/identity/agent-card`);if(!s.ok)throw new Error(`Failed to load agent card (${s.status})`);const l=await s.json();if(l.success&&l.data){const p=He(l.data.card||void 0);if(p.id||(p.id="urn:agent:coconut"),p.url||(p.url=`${window.location.origin}/api/v1`),p.lastUpdated=l.data.updatedAt??p.lastUpdated,t){const h=N(p);d(h),b(N(h)),R(l.data.updatedAt??h.lastUpdated)}}else{if(l.error)throw new Error(l.error);if(t){const p=F();d(p),b(N(p))}}}catch(s){if(console.error("Failed to fetch agent card",s),t){k(s instanceof Error?s.message:"Failed to load agent identity");const l=F();d(l),b(N(l))}}finally{t&&r(!1)}})(),()=>{t=!1}},[]);const ce=(t,i)=>{d(s=>{const l=i?[...new Set([...s.protocols,t])]:s.protocols.filter(p=>p!==t);return{...s,protocols:l}})},Y=()=>{const t=H.trim();t&&(d(i=>({...i,protocols:[...new Set([...i.protocols,t])]})),L(""))},Z=()=>{const t=V.trim();t&&(d(i=>({...i,supportedInputTypes:[...new Set([...i.supportedInputTypes,t])]})),U(""))},G=()=>{const t=X.trim();t&&(d(i=>({...i,supportedOutputTypes:[...new Set([...i.supportedOutputTypes,t])]})),_(""))},de=t=>{d(i=>({...i,supportedInputTypes:i.supportedInputTypes.filter(s=>s!==t)}))},pe=t=>{d(i=>({...i,supportedOutputTypes:i.supportedOutputTypes.filter(s=>s!==t)}))},T=(t,i)=>{d(s=>({...s,[t]:i}))},I=(t,i)=>{d(s=>({...s,authentication:{...s.authentication,[t]:i}}))},J=(t,i)=>{d(s=>({...s,security:{...s.security,[t]:i}}))},Q=(t,i)=>{d(s=>({...s,contact:{...s.contact,[t]:i}}))},ue=()=>{d(t=>({...t,capabilities:[...t.capabilities,qe()]}))},m=(t,i)=>{d(s=>{const l=[...s.capabilities];return l[t]={...l[t],...i},{...s,capabilities:l}})},me=t=>{d(i=>({...i,capabilities:i.capabilities.filter((s,l)=>l!==t)}))},$=()=>{const t=[["id","Agent ID"],["name","Name"],["description","Description"],["version","Version"],["url","Service URL"]];for(const[s,l]of t){const p=n[s];if(typeof p!="string"||!p.trim())throw new Error(`${l} is required`)}const i=n.capabilities.map((s,l)=>({cap:s,index:l})).filter(({cap:s})=>s.enabled&&s.id.trim()&&s.endpoint.trim()).map(({cap:s,index:l})=>{const p=s.id.trim()||`Capability ${l+1}`,h={id:s.id.trim(),skill:s.skill.trim(),description:s.description.trim(),endpoint:s.endpoint.trim(),method:s.method||"POST"},ee=(B,je)=>{if(!(!B||!B.trim()))try{return JSON.parse(B)}catch(te){throw new Error(`${p} ${je} schema must be valid JSON. ${te?.message??te}`)}};return(s.inputMimeType?.trim()||s.inputSchema?.trim())&&(h.input={mimeType:s.inputMimeType?.trim()||"application/json",schema:ee(s.inputSchema,"input")}),(s.outputMimeType?.trim()||s.outputSchema?.trim())&&(h.output={mimeType:s.outputMimeType?.trim()||"application/json",schema:ee(s.outputSchema,"output")}),h});return{id:n.id.trim(),name:n.name.trim(),description:n.description.trim(),version:n.version.trim(),url:n.url.trim(),documentation:n.documentation.trim()||void 0,protocols:n.protocols,authentication:{scheme:n.authentication.scheme.trim()||"api_key",in:n.authentication.in.trim()||"header",name:n.authentication.name.trim()||"X-API-Key",example:n.authentication.example.trim()||void 0,description:n.authentication.description.trim()||void 0},capabilities:i,supportedContentTypes:{input:n.supportedInputTypes,output:n.supportedOutputTypes},security:{transport:n.security.transport.trim()||"https",encryption:n.security.encryption.trim()||"TLS 1.3",notes:n.security.notes.trim()||void 0},contact:{name:n.contact.name.trim()||void 0,email:n.contact.email.trim()||void 0},lastUpdated:new Date().toISOString()}},he=async()=>{K(!0),k(null);try{const t=$(),i=await fetch(`${ie}/api/v1/identity/agent-card`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({card:t})}),s=await i.json();if(!i.ok||!s?.success)throw new Error(s?.error||"Failed to save agent card");a({title:"Agent card saved",description:"The identity card has been updated successfully."});const l=s?.data?.updatedAt??new Date().toISOString();d(p=>{const h={...p,lastUpdated:l};return b(N(h)),h}),R(l)}catch(t){console.error("Failed to save agent card",t),k(t instanceof Error?t.message:"Failed to save agent card"),a({title:"Save failed",description:t instanceof Error?t.message:"Failed to save agent card, see console for details.",variant:"destructive"})}finally{K(!1)}},xe=()=>{d(N(A)),k(null),L(""),U(""),_(""),R(A.lastUpdated??P)},ye=async()=>{try{const t=JSON.stringify($(),null,2);await navigator.clipboard.writeText(t),z(!0),setTimeout(()=>z(!1),1500),a({title:"Copied!",description:"Agent card JSON copied to clipboard."})}catch(t){console.error("Failed to copy agent card preview:",t),a({title:"Copy failed",description:"Unable to copy agent card JSON to clipboard.",variant:"destructive"})}},W=u.useMemo(()=>{if(!P)return null;try{return new Date(P).toLocaleString()}catch{return null}},[P]);return M?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(se,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading identity card..."})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col justify-between gap-4 md:flex-row md:items-end",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Agent Identity"}),e.jsxs("p",{className:"text-muted-foreground",children:["Manage the"," ",e.jsx("a",{href:"/.well-known/agent-card.json",target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-4 hover:text-primary",children:"/.well-known/agent-card.json"})," ","descriptor for A2A discovery."]}),W&&e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["Last updated ",W]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(x,{variant:"outline",onClick:xe,disabled:D,children:[e.jsx($e,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Reset"})]}),e.jsx(x,{onClick:he,disabled:D,children:D?e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"h-4 w-4 animate-spin sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Saving..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Save Changes"})]})})]})]}),q&&e.jsxs(Ee,{variant:"destructive",children:[e.jsx("div",{className:"font-semibold",children:"Something went wrong"}),e.jsx(Me,{children:q})]}),e.jsxs(De,{defaultValue:"overview",className:"space-y-6",children:[e.jsxs(Le,{className:"grid w-full grid-cols-6 h-auto p-1",children:[e.jsxs(C,{value:"overview",className:"gap-2",children:[e.jsx(Ne,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Identity"})]}),e.jsxs(C,{value:"protocols",className:"gap-2",children:[e.jsx(be,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Protocols"})]}),e.jsxs(C,{value:"auth",className:"gap-2",children:[e.jsx(Te,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Security"})]}),e.jsxs(C,{value:"capabilities",className:"gap-2",children:[e.jsx(Ce,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Capabilities"})]}),e.jsxs(C,{value:"contact",className:"gap-2",children:[e.jsx(Se,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contact"})]}),e.jsxs(C,{value:"preview",className:"gap-2",children:[e.jsx(Ue,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Preview"})]})]}),e.jsx(S,{value:"overview",children:e.jsxs(y,{children:[e.jsxs(j,{children:[e.jsx(g,{children:"Identity Overview"}),e.jsx(v,{children:"Define core attributes used for discovery."})]}),e.jsxs(f,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-id",children:"Agent Identifier"}),e.jsx(c,{id:"agent-id",value:n.id,placeholder:"urn:agent:coconut-dev",onChange:t=>T("id",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-name",children:"Name"}),e.jsx(c,{id:"agent-name",value:n.name,placeholder:"Coconut Development Agent",onChange:t=>T("name",t.target.value)})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-version",children:"Version"}),e.jsx(c,{id:"agent-version",value:n.version,placeholder:"1.0.0",onChange:t=>T("version",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-url",children:"Primary Endpoint"}),e.jsx(c,{id:"agent-url",value:n.url,placeholder:"https://coconut.dev/api/v1",onChange:t=>T("url",t.target.value)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-description",children:"Description"}),e.jsx(O,{id:"agent-description",value:n.description,placeholder:"Agent responsible for managing tasks, plans, and operations...",onChange:t=>T("description",t.target.value),rows:4})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-docs",children:"Documentation URL"}),e.jsx(c,{id:"agent-docs",value:n.documentation,placeholder:"https://docs.coconut.dev/a2a",onChange:t=>T("documentation",t.target.value)})]})]})]})}),e.jsx(S,{value:"protocols",children:e.jsxs(y,{children:[e.jsxs(j,{children:[e.jsx(g,{children:"Protocols & Content Types"}),e.jsx(v,{children:"Select supported discovery protocols and payload formats."})]}),e.jsxs(f,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Protocols"}),e.jsx("div",{className:"grid gap-2 md:grid-cols-3",children:le.map(t=>e.jsxs("label",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/20 px-3 py-2",children:[e.jsx(ae,{checked:n.protocols.includes(t),onCheckedChange:i=>ce(t,!!i)}),e.jsx("span",{className:"text-sm font-medium",children:t})]},t))}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row",children:[e.jsx(c,{value:H,placeholder:"Add custom protocol (press Add)",onChange:t=>L(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),Y())}}),e.jsxs(x,{type:"button",variant:"outline",onClick:Y,children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Add"]})]})]}),e.jsx(ne,{}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Supported Input Types"}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row",children:[e.jsx(c,{value:V,placeholder:"application/json",onChange:t=>U(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),Z())}}),e.jsxs(x,{type:"button",variant:"outline",onClick:Z,children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.supportedInputTypes.map(t=>e.jsxs(re,{variant:"secondary",className:"flex items-center gap-1",children:[t,e.jsx("button",{type:"button",onClick:()=>de(t),className:"ml-1 rounded-full border border-transparent bg-transparent text-muted-foreground transition hover:text-foreground",children:"×"})]},t))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Supported Output Types"}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row",children:[e.jsx(c,{value:X,placeholder:"application/json",onChange:t=>_(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),G())}}),e.jsxs(x,{type:"button",variant:"outline",onClick:G,children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.supportedOutputTypes.map(t=>e.jsxs(re,{variant:"secondary",className:"flex items-center gap-1",children:[t,e.jsx("button",{type:"button",onClick:()=>pe(t),className:"ml-1 rounded-full border border-transparent bg-transparent text-muted-foreground transition hover:text-foreground",children:"×"})]},t))})]})]})]})]})}),e.jsx(S,{value:"auth",children:e.jsxs(y,{children:[e.jsxs(j,{children:[e.jsx(g,{children:"Authentication & Security"}),e.jsx(v,{children:"Document how peer agents should authenticate and connect."})]}),e.jsxs(f,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-scheme",children:"Authentication Scheme"}),e.jsx(c,{id:"auth-scheme",value:n.authentication.scheme,placeholder:"api_key",onChange:t=>I("scheme",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-in",children:"Credential Location"}),e.jsx(c,{id:"auth-in",value:n.authentication.in,placeholder:"header",onChange:t=>I("in",t.target.value)})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-name",children:"Header or Field Name"}),e.jsx(c,{id:"auth-name",value:n.authentication.name,placeholder:"X-API-Key",onChange:t=>I("name",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-example",children:"Example Secret"}),e.jsx(c,{id:"auth-example",value:n.authentication.example,placeholder:"nut_***************",onChange:t=>I("example",t.target.value)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-description",children:"Authentication Notes"}),e.jsx(O,{id:"auth-description",value:n.authentication.description,placeholder:"Provide API key via X-API-Key header to authenticate requests between agents.",onChange:t=>I("description",t.target.value),rows:3})]}),e.jsx(ne,{}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"security-transport",children:"Transport"}),e.jsx(c,{id:"security-transport",value:n.security.transport,placeholder:"https",onChange:t=>J("transport",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"security-encryption",children:"Encryption"}),e.jsx(c,{id:"security-encryption",value:n.security.encryption,placeholder:"TLS 1.3",onChange:t=>J("encryption",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"security-notes",children:"Security Notes"}),e.jsx(c,{id:"security-notes",value:n.security.notes,placeholder:"Requests must be encrypted over TLS.",onChange:t=>J("notes",t.target.value)})]})]})]})]})}),e.jsx(S,{value:"capabilities",children:e.jsxs(y,{children:[e.jsxs(j,{children:[e.jsx(g,{children:"Capabilities"}),e.jsx(v,{children:"Describe the skills other agents can invoke."})]}),e.jsxs(f,{className:"space-y-4",children:[n.capabilities.length===0&&e.jsx("div",{className:"rounded-lg border border-dashed border-border bg-muted/40 p-6 text-center text-sm text-muted-foreground",children:"No capabilities defined yet. Add one to expose functionality for peer agents."}),n.capabilities.map((t,i)=>e.jsxs(y,{className:"border border-border/60",children:[e.jsxs(j,{className:"flex flex-col gap-2 space-y-0 md:flex-row md:items-center",children:[e.jsxs("div",{className:"flex flex-1 flex-col",children:[e.jsxs(g,{className:"text-lg font-semibold",children:["Capability #",i+1]}),e.jsx(v,{children:"Toggle availability and describe request contracts."})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(ae,{checked:t.enabled,onCheckedChange:s=>m(i,{enabled:!!s})}),"Expose capability"]}),e.jsxs(x,{size:"icon",variant:"ghost",onClick:()=>me(i),title:"Remove capability",children:[e.jsx(we,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Remove capability"})]})]})]}),e.jsxs(f,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Capability ID"}),e.jsx(c,{value:t.id,placeholder:"create-task",onChange:s=>m(i,{id:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Skill"}),e.jsx(c,{value:t.skill,placeholder:"task_management.create",onChange:s=>m(i,{skill:s.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Description"}),e.jsx(O,{value:t.description,placeholder:"Creates a new task containing intent, plan, and artifacts.",rows:3,onChange:s=>m(i,{description:s.target.value})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Endpoint"}),e.jsx(c,{value:t.endpoint,placeholder:"https://coconut.dev/api/v1/tasks",onChange:s=>m(i,{endpoint:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"HTTP Method"}),e.jsxs(ke,{value:t.method,onValueChange:s=>m(i,{method:s}),children:[e.jsx(Ie,{children:e.jsx(Oe,{placeholder:"Select method"})}),e.jsx(Fe,{children:Ke.map(s=>e.jsx(Pe,{value:s,children:s},s))})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Input MIME Type"}),e.jsx(c,{value:t.inputMimeType??"",placeholder:"application/json",onChange:s=>m(i,{inputMimeType:s.target.value})}),e.jsx(o,{children:"Input Schema (JSON)"}),e.jsx(O,{value:t.inputSchema??"",placeholder:'{ "type": "object", "properties": { "title": { "type": "string" } } }',rows:5,onChange:s=>m(i,{inputSchema:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Output MIME Type"}),e.jsx(c,{value:t.outputMimeType??"",placeholder:"application/json",onChange:s=>m(i,{outputMimeType:s.target.value})}),e.jsx(o,{children:"Output Schema (JSON)"}),e.jsx(O,{value:t.outputSchema??"",placeholder:'{ "type": "object", "properties": { "status": { "type": "string" } } }',rows:5,onChange:s=>m(i,{outputSchema:s.target.value})})]})]})]})]},`${t.id||"capability"}-${i}`))]}),e.jsx(Ae,{children:e.jsxs(x,{type:"button",variant:"outline",onClick:ue,children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Add Capability"]})})]})}),e.jsx(S,{value:"contact",children:e.jsxs(y,{children:[e.jsxs(j,{children:[e.jsx(g,{children:"Contact"}),e.jsx(v,{children:"Provide a human escalation path for peer agents."})]}),e.jsxs(f,{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"contact-name",children:"Contact Name"}),e.jsx(c,{id:"contact-name",value:n.contact.name,placeholder:"Coconut DevOps Team",onChange:t=>Q("name",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"contact-email",children:"Contact Email"}),e.jsx(c,{id:"contact-email",value:n.contact.email,placeholder:"support@coconut.dev",onChange:t=>Q("email",t.target.value)})]})]})]})}),e.jsx(S,{value:"preview",children:e.jsxs(y,{children:[e.jsx(j,{children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(g,{children:"Preview"}),e.jsx(v,{children:"Review the JSON payload served at /.well-known/agent-card.json."})]}),e.jsx(x,{variant:"outline",size:"sm",onClick:ye,children:oe?e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copied"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Re,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy"})]})})]})}),e.jsx(f,{children:e.jsx("pre",{className:"max-h-96 overflow-auto rounded-md bg-muted p-4 text-sm",children:JSON.stringify((()=>{try{return $()}catch{return{id:n.id,name:n.name,description:n.description,version:n.version,url:n.url,protocols:n.protocols}}})(),null,2)})})]})})]})]})}export{at as default};
|
|
6
|
+
*/const Je=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],$e=ge("refresh-ccw",Je),Be=["a2a_v0.2","a2a_v0.1","jsonrpc2","jsonrpc","openrpc","rest"],Ke=["GET","POST","PUT","PATCH","DELETE"],qe=()=>({id:"",skill:"",description:"",endpoint:"",method:"POST",enabled:!0,inputMimeType:"application/json",outputMimeType:"application/json",inputSchema:"",outputSchema:""}),w={id:"",name:"",description:"",version:"1.0.0",url:"",documentation:"",protocols:["a2a_v0.2"],authentication:{scheme:"api_key",in:"header",name:"X-API-Key",example:"",description:""},capabilities:[],supportedInputTypes:["application/json"],supportedOutputTypes:["application/json"],security:{transport:"https",encryption:"TLS 1.3",notes:""},contact:{name:"",email:""},lastUpdated:void 0},N=a=>({...a,protocols:[...a.protocols],authentication:{...a.authentication},capabilities:a.capabilities.map(n=>({...n})),supportedInputTypes:[...a.supportedInputTypes],supportedOutputTypes:[...a.supportedOutputTypes],security:{...a.security},contact:{...a.contact}}),F=()=>N(w);function He(a){if(!a)return F();const n=Array.isArray(a.protocols)?a.protocols.filter(r=>typeof r=="string"):[],d=Array.isArray(a.supportedContentTypes?.input)?a.supportedContentTypes.input.filter(r=>typeof r=="string"):[],A=Array.isArray(a.supportedContentTypes?.output)?a.supportedContentTypes.output.filter(r=>typeof r=="string"):[],T=Array.isArray(a.capabilities)?a.capabilities.map(r=>({id:typeof r.id=="string"?r.id:"",skill:typeof r.skill=="string"?r.skill:"",description:typeof r.description=="string"?r.description:"",endpoint:typeof r.endpoint=="string"?r.endpoint:"",method:typeof r.method=="string"?r.method:"POST",enabled:r?.enabled!==!1,inputMimeType:typeof r.input?.mimeType=="string"?r.input.mimeType:"application/json",outputMimeType:typeof r.output?.mimeType=="string"?r.output.mimeType:"application/json",inputSchema:r.input?.schema?JSON.stringify(r.input.schema,null,2):"",outputSchema:r.output?.schema?JSON.stringify(r.output.schema,null,2):""})):[],M={scheme:typeof a.authentication?.scheme=="string"?a.authentication.scheme:"api_key",in:typeof a.authentication?.in=="string"?a.authentication.in:"header",name:typeof a.authentication?.name=="string"?a.authentication.name:"X-API-Key",example:typeof a.authentication?.example=="string"?a.authentication.example:"",description:typeof a.authentication?.description=="string"?a.authentication.description:""};return{id:typeof a.id=="string"?a.id:"",name:typeof a.name=="string"?a.name:"",description:typeof a.description=="string"?a.description:"",version:typeof a.version=="string"?a.version:"1.0.0",url:typeof a.url=="string"?a.url:"",documentation:typeof a.documentation=="string"?a.documentation:"",protocols:n.length>0?n:w.protocols,authentication:M,capabilities:T,supportedInputTypes:d.length>0?d:w.supportedInputTypes,supportedOutputTypes:A.length>0?A:w.supportedOutputTypes,security:{transport:typeof a.security?.transport=="string"?a.security.transport:w.security.transport,encryption:typeof a.security?.encryption=="string"?a.security.encryption:w.security.encryption,notes:typeof a.security?.notes=="string"?a.security.notes:""},contact:{name:typeof a.contact?.name=="string"?a.contact.name:"",email:typeof a.contact?.email=="string"?a.contact.email:""},lastUpdated:typeof a.lastUpdated=="string"?a.lastUpdated:void 0}}function at(){const{toast:a}=ve(),[n,d]=u.useState(()=>F()),[A,T]=u.useState(()=>F()),[M,r]=u.useState(!0),[D,K]=u.useState(!1),[q,k]=u.useState(null),[H,L]=u.useState(""),[V,U]=u.useState(""),[X,_]=u.useState(""),[P,R]=u.useState(void 0),[oe,z]=u.useState(!1),le=u.useMemo(()=>{const t=new Set([...Be,...n.protocols]);return Array.from(t).sort()},[n.protocols]);u.useEffect(()=>{let t=!0;return(async()=>{r(!0),k(null);try{const s=await fetch(`${ie}/api/v1/identity/agent-card`);if(!s.ok)throw new Error(`Failed to load agent card (${s.status})`);const l=await s.json();if(l.success&&l.data){const p=He(l.data.card||void 0);if(p.id||(p.id="urn:agent:coconut"),p.url||(p.url=`${window.location.origin}/api/v1`),p.lastUpdated=l.data.updatedAt??p.lastUpdated,t){const h=N(p);d(h),T(N(h)),R(l.data.updatedAt??h.lastUpdated)}}else{if(l.error)throw new Error(l.error);if(t){const p=F();d(p),T(N(p))}}}catch(s){if(console.error("Failed to fetch agent card",s),t){k(s instanceof Error?s.message:"Failed to load agent identity");const l=F();d(l),T(N(l))}}finally{t&&r(!1)}})(),()=>{t=!1}},[]);const ce=(t,i)=>{d(s=>{const l=i?[...new Set([...s.protocols,t])]:s.protocols.filter(p=>p!==t);return{...s,protocols:l}})},Y=()=>{const t=H.trim();t&&(d(i=>({...i,protocols:[...new Set([...i.protocols,t])]})),L(""))},Z=()=>{const t=V.trim();t&&(d(i=>({...i,supportedInputTypes:[...new Set([...i.supportedInputTypes,t])]})),U(""))},G=()=>{const t=X.trim();t&&(d(i=>({...i,supportedOutputTypes:[...new Set([...i.supportedOutputTypes,t])]})),_(""))},de=t=>{d(i=>({...i,supportedInputTypes:i.supportedInputTypes.filter(s=>s!==t)}))},pe=t=>{d(i=>({...i,supportedOutputTypes:i.supportedOutputTypes.filter(s=>s!==t)}))},b=(t,i)=>{d(s=>({...s,[t]:i}))},I=(t,i)=>{d(s=>({...s,authentication:{...s.authentication,[t]:i}}))},J=(t,i)=>{d(s=>({...s,security:{...s.security,[t]:i}}))},Q=(t,i)=>{d(s=>({...s,contact:{...s.contact,[t]:i}}))},ue=()=>{d(t=>({...t,capabilities:[...t.capabilities,qe()]}))},m=(t,i)=>{d(s=>{const l=[...s.capabilities];return l[t]={...l[t],...i},{...s,capabilities:l}})},me=t=>{d(i=>({...i,capabilities:i.capabilities.filter((s,l)=>l!==t)}))},$=()=>{const t=[["id","Agent ID"],["name","Name"],["description","Description"],["version","Version"],["url","Service URL"]];for(const[s,l]of t){const p=n[s];if(typeof p!="string"||!p.trim())throw new Error(`${l} is required`)}const i=n.capabilities.map((s,l)=>({cap:s,index:l})).filter(({cap:s})=>s.enabled&&s.id.trim()&&s.endpoint.trim()).map(({cap:s,index:l})=>{const p=s.id.trim()||`Capability ${l+1}`,h={id:s.id.trim(),skill:s.skill.trim(),description:s.description.trim(),endpoint:s.endpoint.trim(),method:s.method||"POST"},ee=(B,je)=>{if(!(!B||!B.trim()))try{return JSON.parse(B)}catch(te){throw new Error(`${p} ${je} schema must be valid JSON. ${te?.message??te}`)}};return(s.inputMimeType?.trim()||s.inputSchema?.trim())&&(h.input={mimeType:s.inputMimeType?.trim()||"application/json",schema:ee(s.inputSchema,"input")}),(s.outputMimeType?.trim()||s.outputSchema?.trim())&&(h.output={mimeType:s.outputMimeType?.trim()||"application/json",schema:ee(s.outputSchema,"output")}),h});return{id:n.id.trim(),name:n.name.trim(),description:n.description.trim(),version:n.version.trim(),url:n.url.trim(),documentation:n.documentation.trim()||void 0,protocols:n.protocols,authentication:{scheme:n.authentication.scheme.trim()||"api_key",in:n.authentication.in.trim()||"header",name:n.authentication.name.trim()||"X-API-Key",example:n.authentication.example.trim()||void 0,description:n.authentication.description.trim()||void 0},capabilities:i,supportedContentTypes:{input:n.supportedInputTypes,output:n.supportedOutputTypes},security:{transport:n.security.transport.trim()||"https",encryption:n.security.encryption.trim()||"TLS 1.3",notes:n.security.notes.trim()||void 0},contact:{name:n.contact.name.trim()||void 0,email:n.contact.email.trim()||void 0},lastUpdated:new Date().toISOString()}},he=async()=>{K(!0),k(null);try{const t=$(),i=await fetch(`${ie}/api/v1/identity/agent-card`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({card:t})}),s=await i.json();if(!i.ok||!s?.success)throw new Error(s?.error||"Failed to save agent card");a({title:"Agent card saved",description:"The identity card has been updated successfully."});const l=s?.data?.updatedAt??new Date().toISOString();d(p=>{const h={...p,lastUpdated:l};return T(N(h)),h}),R(l)}catch(t){console.error("Failed to save agent card",t),k(t instanceof Error?t.message:"Failed to save agent card"),a({title:"Save failed",description:t instanceof Error?t.message:"Failed to save agent card, see console for details.",variant:"destructive"})}finally{K(!1)}},xe=()=>{d(N(A)),k(null),L(""),U(""),_(""),R(A.lastUpdated??P)},ye=async()=>{try{const t=JSON.stringify($(),null,2);await navigator.clipboard.writeText(t),z(!0),setTimeout(()=>z(!1),1500),a({title:"Copied!",description:"Agent card JSON copied to clipboard."})}catch(t){console.error("Failed to copy agent card preview:",t),a({title:"Copy failed",description:"Unable to copy agent card JSON to clipboard.",variant:"destructive"})}},W=u.useMemo(()=>{if(!P)return null;try{return new Date(P).toLocaleString()}catch{return null}},[P]);return M?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(se,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading identity card..."})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col justify-between gap-4 md:flex-row md:items-end",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Agent Identity"}),e.jsxs("p",{className:"text-muted-foreground",children:["Manage the"," ",e.jsx("a",{href:"/.well-known/agent-card.json",target:"_blank",rel:"noopener noreferrer",className:"underline underline-offset-4 hover:text-primary",children:"/.well-known/agent-card.json"})," ","descriptor for A2A discovery."]}),W&&e.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["Last updated ",W]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(x,{variant:"outline",onClick:xe,disabled:D,children:[e.jsx($e,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Reset"})]}),e.jsx(x,{onClick:he,disabled:D,children:D?e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"h-4 w-4 animate-spin sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Saving..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(fe,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Save Changes"})]})})]})]}),q&&e.jsxs(Ee,{variant:"destructive",children:[e.jsx("div",{className:"font-semibold",children:"Something went wrong"}),e.jsx(Me,{children:q})]}),e.jsxs(De,{defaultValue:"overview",className:"space-y-6",children:[e.jsxs(Le,{className:"grid w-full grid-cols-6 h-auto p-1",children:[e.jsxs(C,{value:"overview",className:"gap-2",children:[e.jsx(Ne,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Identity"})]}),e.jsxs(C,{value:"protocols",className:"gap-2",children:[e.jsx(Te,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Protocols"})]}),e.jsxs(C,{value:"auth",className:"gap-2",children:[e.jsx(be,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Security"})]}),e.jsxs(C,{value:"capabilities",className:"gap-2",children:[e.jsx(Ce,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Capabilities"})]}),e.jsxs(C,{value:"contact",className:"gap-2",children:[e.jsx(Se,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contact"})]}),e.jsxs(C,{value:"preview",className:"gap-2",children:[e.jsx(Ue,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Preview"})]})]}),e.jsx(S,{value:"overview",children:e.jsxs(y,{children:[e.jsxs(j,{children:[e.jsx(g,{children:"Identity Overview"}),e.jsx(v,{children:"Define core attributes used for discovery."})]}),e.jsxs(f,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-id",children:"Agent Identifier"}),e.jsx(c,{id:"agent-id",value:n.id,placeholder:"urn:agent:coconut-dev",onChange:t=>b("id",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-name",children:"Name"}),e.jsx(c,{id:"agent-name",value:n.name,placeholder:"Coconut Development Agent",onChange:t=>b("name",t.target.value)})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-version",children:"Version"}),e.jsx(c,{id:"agent-version",value:n.version,placeholder:"1.0.0",onChange:t=>b("version",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-url",children:"Primary Endpoint"}),e.jsx(c,{id:"agent-url",value:n.url,placeholder:"https://coconut.dev/api/v1",onChange:t=>b("url",t.target.value)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-description",children:"Description"}),e.jsx(O,{id:"agent-description",value:n.description,placeholder:"Agent responsible for managing tasks, plans, and operations...",onChange:t=>b("description",t.target.value),rows:4})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"agent-docs",children:"Documentation URL"}),e.jsx(c,{id:"agent-docs",value:n.documentation,placeholder:"https://docs.coconut.dev/a2a",onChange:t=>b("documentation",t.target.value)})]})]})]})}),e.jsx(S,{value:"protocols",children:e.jsxs(y,{children:[e.jsxs(j,{children:[e.jsx(g,{children:"Protocols & Content Types"}),e.jsx(v,{children:"Select supported discovery protocols and payload formats."})]}),e.jsxs(f,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Protocols"}),e.jsx("div",{className:"grid gap-2 md:grid-cols-3",children:le.map(t=>e.jsxs("label",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/20 px-3 py-2",children:[e.jsx(ae,{checked:n.protocols.includes(t),onCheckedChange:i=>ce(t,!!i)}),e.jsx("span",{className:"text-sm font-medium",children:t})]},t))}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row",children:[e.jsx(c,{value:H,placeholder:"Add custom protocol (press Add)",onChange:t=>L(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),Y())}}),e.jsxs(x,{type:"button",variant:"outline",onClick:Y,children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Add"]})]})]}),e.jsx(ne,{}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Supported Input Types"}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row",children:[e.jsx(c,{value:V,placeholder:"application/json",onChange:t=>U(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),Z())}}),e.jsxs(x,{type:"button",variant:"outline",onClick:Z,children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.supportedInputTypes.map(t=>e.jsxs(re,{variant:"secondary",className:"flex items-center gap-1",children:[t,e.jsx("button",{type:"button",onClick:()=>de(t),className:"ml-1 rounded-full border border-transparent bg-transparent text-muted-foreground transition hover:text-foreground",children:"×"})]},t))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Supported Output Types"}),e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row",children:[e.jsx(c,{value:X,placeholder:"application/json",onChange:t=>_(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),G())}}),e.jsxs(x,{type:"button",variant:"outline",onClick:G,children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Add"]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.supportedOutputTypes.map(t=>e.jsxs(re,{variant:"secondary",className:"flex items-center gap-1",children:[t,e.jsx("button",{type:"button",onClick:()=>pe(t),className:"ml-1 rounded-full border border-transparent bg-transparent text-muted-foreground transition hover:text-foreground",children:"×"})]},t))})]})]})]})]})}),e.jsx(S,{value:"auth",children:e.jsxs(y,{children:[e.jsxs(j,{children:[e.jsx(g,{children:"Authentication & Security"}),e.jsx(v,{children:"Document how peer agents should authenticate and connect."})]}),e.jsxs(f,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-scheme",children:"Authentication Scheme"}),e.jsx(c,{id:"auth-scheme",value:n.authentication.scheme,placeholder:"api_key",onChange:t=>I("scheme",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-in",children:"Credential Location"}),e.jsx(c,{id:"auth-in",value:n.authentication.in,placeholder:"header",onChange:t=>I("in",t.target.value)})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-name",children:"Header or Field Name"}),e.jsx(c,{id:"auth-name",value:n.authentication.name,placeholder:"X-API-Key",onChange:t=>I("name",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-example",children:"Example Secret"}),e.jsx(c,{id:"auth-example",value:n.authentication.example,placeholder:"nut_***************",onChange:t=>I("example",t.target.value)})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"auth-description",children:"Authentication Notes"}),e.jsx(O,{id:"auth-description",value:n.authentication.description,placeholder:"Provide API key via X-API-Key header to authenticate requests between agents.",onChange:t=>I("description",t.target.value),rows:3})]}),e.jsx(ne,{}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"security-transport",children:"Transport"}),e.jsx(c,{id:"security-transport",value:n.security.transport,placeholder:"https",onChange:t=>J("transport",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"security-encryption",children:"Encryption"}),e.jsx(c,{id:"security-encryption",value:n.security.encryption,placeholder:"TLS 1.3",onChange:t=>J("encryption",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"security-notes",children:"Security Notes"}),e.jsx(c,{id:"security-notes",value:n.security.notes,placeholder:"Requests must be encrypted over TLS.",onChange:t=>J("notes",t.target.value)})]})]})]})]})}),e.jsx(S,{value:"capabilities",children:e.jsxs(y,{children:[e.jsxs(j,{children:[e.jsx(g,{children:"Capabilities"}),e.jsx(v,{children:"Describe the skills other agents can invoke."})]}),e.jsxs(f,{className:"space-y-4",children:[n.capabilities.length===0&&e.jsx("div",{className:"rounded-lg border border-dashed border-border bg-muted/40 p-6 text-center text-sm text-muted-foreground",children:"No capabilities defined yet. Add one to expose functionality for peer agents."}),n.capabilities.map((t,i)=>e.jsxs(y,{className:"border border-border/60",children:[e.jsxs(j,{className:"flex flex-col gap-2 space-y-0 md:flex-row md:items-center",children:[e.jsxs("div",{className:"flex flex-1 flex-col",children:[e.jsxs(g,{className:"text-lg font-semibold",children:["Capability #",i+1]}),e.jsx(v,{children:"Toggle availability and describe request contracts."})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(ae,{checked:t.enabled,onCheckedChange:s=>m(i,{enabled:!!s})}),"Expose capability"]}),e.jsxs(x,{size:"icon",variant:"ghost",onClick:()=>me(i),title:"Remove capability",children:[e.jsx(we,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Remove capability"})]})]})]}),e.jsxs(f,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Capability ID"}),e.jsx(c,{value:t.id,placeholder:"create-task",onChange:s=>m(i,{id:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Skill"}),e.jsx(c,{value:t.skill,placeholder:"task_management.create",onChange:s=>m(i,{skill:s.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Description"}),e.jsx(O,{value:t.description,placeholder:"Creates a new task containing intent, plan, and artifacts.",rows:3,onChange:s=>m(i,{description:s.target.value})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Endpoint"}),e.jsx(c,{value:t.endpoint,placeholder:"https://coconut.dev/api/v1/tasks",onChange:s=>m(i,{endpoint:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"HTTP Method"}),e.jsxs(ke,{value:t.method,onValueChange:s=>m(i,{method:s}),children:[e.jsx(Ie,{children:e.jsx(Oe,{placeholder:"Select method"})}),e.jsx(Fe,{children:Ke.map(s=>e.jsx(Pe,{value:s,children:s},s))})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Input MIME Type"}),e.jsx(c,{value:t.inputMimeType??"",placeholder:"application/json",onChange:s=>m(i,{inputMimeType:s.target.value})}),e.jsx(o,{children:"Input Schema (JSON)"}),e.jsx(O,{value:t.inputSchema??"",placeholder:'{ "type": "object", "properties": { "title": { "type": "string" } } }',rows:5,onChange:s=>m(i,{inputSchema:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Output MIME Type"}),e.jsx(c,{value:t.outputMimeType??"",placeholder:"application/json",onChange:s=>m(i,{outputMimeType:s.target.value})}),e.jsx(o,{children:"Output Schema (JSON)"}),e.jsx(O,{value:t.outputSchema??"",placeholder:'{ "type": "object", "properties": { "status": { "type": "string" } } }',rows:5,onChange:s=>m(i,{outputSchema:s.target.value})})]})]})]})]},`${t.id||"capability"}-${i}`))]}),e.jsx(Ae,{children:e.jsxs(x,{type:"button",variant:"outline",onClick:ue,children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Add Capability"]})})]})}),e.jsx(S,{value:"contact",children:e.jsxs(y,{children:[e.jsxs(j,{children:[e.jsx(g,{children:"Contact"}),e.jsx(v,{children:"Provide a human escalation path for peer agents."})]}),e.jsxs(f,{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"contact-name",children:"Contact Name"}),e.jsx(c,{id:"contact-name",value:n.contact.name,placeholder:"Coconut DevOps Team",onChange:t=>Q("name",t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"contact-email",children:"Contact Email"}),e.jsx(c,{id:"contact-email",value:n.contact.email,placeholder:"support@coconut.dev",onChange:t=>Q("email",t.target.value)})]})]})]})}),e.jsx(S,{value:"preview",children:e.jsxs(y,{children:[e.jsx(j,{children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(g,{children:"Preview"}),e.jsx(v,{children:"Review the JSON payload served at /.well-known/agent-card.json."})]}),e.jsx(x,{variant:"outline",size:"sm",onClick:ye,children:oe?e.jsxs(e.Fragment,{children:[e.jsx(_e,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copied"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Re,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Copy"})]})})]})}),e.jsx(f,{children:e.jsx("pre",{className:"max-h-96 overflow-auto rounded-md bg-muted p-4 text-sm",children:JSON.stringify((()=>{try{return $()}catch{return{id:n.id,name:n.name,description:n.description,version:n.version,url:n.url,protocols:n.protocols}}})(),null,2)})})]})})]})]})}export{at as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as u,j as e,e as p,B as c,E as x,I as j,P as v}from"./index-
|
|
1
|
+
import{c as u,j as e,e as p,B as c,E as x,I as j,P as v}from"./index-DB2Tq9wz.js";import{L as r}from"./label-DxDedS8x.js";import{S,a as y,b,c as f,d as k}from"./select-BzOa_wZx.js";/**
|
|
2
2
|
* @license lucide-react v0.542.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
package/static/assets/{IntegrationsSettingsPage-Z8xCUmX9.js → IntegrationsSettingsPage-Cw6ItrNf.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as d,bw as A,v as l,j as e,bv as T,e as j,n as y,C as v,ae as N,I as b,B as r,E as k,a0 as w,h as $}from"./index-PyVlsLW8.js";import{C as U,b as Y,c as q,d as B,a as H}from"./card-xkODbJy-.js";import{L as m}from"./label-DvPENm3h.js";import{S as Q,a as W,b as X,c as Z,d as ee}from"./select-B1v2u6hQ.js";import"./index-BQYB8kWb.js";import"./chevron-up-BB-6OS4z.js";const se=[{id:"openai/gpt-4o",label:"GPT-4o",provider:"openai",supportsMCP:!0,strengths:["balanced","reasoning","code","tools"],notes:"Great general model with tool/function calling support."},{id:"openai/gpt-4o-mini",label:"GPT-4o Mini",provider:"openai",supportsMCP:!0,strengths:["cost-effective","fast","tools"],notes:"Good for quick, inexpensive tasks with function calling."},{id:"openai/gpt-4.1",label:"GPT-4.1",provider:"openai",supportsMCP:!0,strengths:["coding","instruction following","long context"],notes:"Latest GPT-4 series with enhanced capabilities."},{id:"openai/o3-mini",label:"o3-mini",provider:"openai",supportsMCP:!0,strengths:["reasoning","math","coding"],notes:"Reasoning model optimized for efficiency."},{id:"anthropic/claude-sonnet-4.5",label:"Claude Sonnet 4.5",provider:"anthropic",supportsMCP:!0,strengths:["agents","coding","tools","fast","long context"],notes:"Most advanced Sonnet - 1.5-2x faster, optimized for agents and tool orchestration."},{id:"anthropic/claude-sonnet-4",label:"Claude Sonnet 4",provider:"anthropic",supportsMCP:!0,strengths:["reasoning","analysis","tools","coding"],notes:"Excellent tool use and reasoning capabilities."},{id:"anthropic/claude-3.5-sonnet",label:"Claude 3.5 Sonnet",provider:"anthropic",supportsMCP:!0,strengths:["reasoning","analysis","tools"],notes:"Reliable Claude model with strong tool support."},{id:"google/gemini-2.0-flash-001",label:"Gemini 2.0 Flash",provider:"google",supportsMCP:!0,strengths:["speed","multimodal","tools"],notes:"Fast Google model with function calling."},{id:"meta-llama/llama-3.1-405b-instruct",label:"Llama 3.1 405B",provider:"meta-llama",supportsMCP:!0,strengths:["reasoning","open weights","code"],notes:"High-capacity open model; function calling often available."},{id:"qwen/qwen-2.5-72b-instruct",label:"Qwen 2.5 72B",provider:"qwen",supportsMCP:!0,strengths:["cost-effective","code","tools"],notes:"Strong value open model with tool support."}],te={models:se},ae=te;function E(){return ae.models}function de(){const[t,F]=d.useState({}),[i,M]=d.useState(!0),[_,G]=d.useState(!1),[p,z]=d.useState({}),[I,R]=d.useState({}),[O,L]=d.useState(E()[0]?.id||"openai/gpt-4o"),[n,J]=d.useState({openrouter:!1,replicate:!1,anthropic:!1,openai:!1,gemini:!1,factorydroid:!1});d.useEffect(()=>{P()},[]);const P=async()=>{try{M(!0);const s=await A("/api/v1/config?type=global");if(s.success&&s.data){const a=s.data.apiKeys||{},o={},c={};for(const C of["openrouter","replicate","anthropic","openai","gemini","factorydroid"]){const K=a[C];K&&typeof K=="string"&&K.trim()!==""?(o[C]=!0,c[C]="***"):(o[C]=!1,c[C]="")}F(c);const S=s.data.defaults&&s.data.defaults.model?String(s.data.defaults.model):void 0;L(S||E()[0]?.id||"openai/gpt-4o")}}catch(s){console.error("Failed to load API keys:",s),l({title:"Error",description:"Failed to load API keys",variant:"destructive"})}finally{M(!1)}},x=(s,a)=>{F(o=>({...o,[s]:a}))},D=async s=>{try{R(S=>({...S,[s]:!0}));const a=t[s],o={provider:s};a&&a!=="***"&&(o.key=a);const c=await A("/api/v1/config/test",{method:"POST",body:JSON.stringify(o)});c.success&&c.message?l({title:"Test Result",description:c.message}):c.success?l({title:"Test Result",description:"Success"}):l({title:"Test Failed",description:c.message||"Unknown error",variant:"destructive"})}catch(a){l({title:"Test Failed",description:a instanceof Error?a.message:"Unknown error",variant:"destructive"})}finally{R(a=>({...a,[s]:!1}))}},h=s=>{J(a=>({...a,[s]:!a[s]}))},u=async s=>{try{const a={[s]:""};await A("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({apiKeys:a})}),l({title:"Success",description:`${s} API key cleared`}),await P()}catch(a){console.error("Failed to clear API key:",a),l({title:"Error",description:"Failed to clear API key",variant:"destructive"})}},g=async s=>{try{z(o=>({...o,[s]:!0}));const a={[s]:t[s]};await A("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({apiKeys:a})}),l({title:"Success",description:`${s} API key saved`}),await P()}catch(a){console.error("Failed to save API key:",a),l({title:"Error",description:"Failed to save API key",variant:"destructive"})}finally{z(a=>({...a,[s]:!1}))}},V=async()=>{try{G(!0),await A("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({defaults:{model:O}})}),l({title:"Success",description:"Default model saved successfully"})}catch(s){console.error("Failed to save default model:",s),l({title:"Error",description:"Failed to save default model",variant:"destructive"})}finally{G(!1)}},f={openrouter:"OPENROUTER_API_KEY",replicate:"REPLICATE_API_TOKEN",anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GEMINI_API_KEY",factorydroid:"FACTORY_API_KEY"};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"AI & LLM"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure Coconut's connections to LLM providers."})]}),e.jsx(T,{}),e.jsxs(U,{children:[e.jsxs(Y,{children:[e.jsx(q,{children:"API Keys & Authentication"}),e.jsx(B,{children:"Manage API keys and authentication tokens for integrated services."})]}),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1 mb-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"AI Assistant API Keys"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Keys used by the AI Assistant sidebar for chat and code suggestions."})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("openrouter"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.openrouter&&t.openrouter!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.openrouter?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"OpenRouter"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:f.openrouter})]})]}),t.openrouter&&t.openrouter!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.openrouter&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"openrouterKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(b,{id:"openrouterKey",type:"password",placeholder:"sk-or-v1-...",className:"flex-1",value:t.openrouter||"",onChange:s=>x("openrouter",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("openrouter"),title:"Clear API key",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>D("openrouter"),disabled:!!I.openrouter,title:"Test API key",children:I.openrouter?"Testing...":"Test"}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("openrouter"),disabled:p.openrouter||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"OpenRouter"})]})]})]}),e.jsx(T,{className:"my-6"}),e.jsxs("div",{className:"space-y-1 mb-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Resource Creation API Keys"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Keys used for generating images and other resources."})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("replicate"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.replicate&&t.replicate!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.replicate?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Replicate"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:f.replicate})]})]}),t.replicate&&t.replicate!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.replicate&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"replicateKey",children:"API Token"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(b,{id:"replicateKey",type:"password",placeholder:"r8_...",className:"flex-1",value:t.replicate||"",onChange:s=>x("replicate",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("replicate"),title:"Clear API token",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>D("replicate"),disabled:!!I.replicate,title:"Test API token",children:I.replicate?"Testing...":"Test"}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("replicate"),disabled:p.replicate||i,title:"Save API token",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your token from"," ",e.jsx("a",{href:"https://replicate.com/account/api-tokens",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Replicate"})]})]})]}),e.jsx(T,{className:"my-6"}),e.jsxs("div",{className:"space-y-1 mb-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Coding Agent API Keys"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"These keys are automatically provided to coding agents when they start running."})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("anthropic"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.anthropic&&t.anthropic!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.anthropic?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Anthropic Claude"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:f.anthropic})]})]}),t.anthropic&&t.anthropic!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.anthropic&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"anthropicKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(b,{id:"anthropicKey",type:"password",placeholder:"sk-ant-...",className:"flex-1",value:t.anthropic||"",onChange:s=>x("anthropic",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("anthropic"),title:"Clear API key",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("anthropic"),disabled:p.anthropic||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://console.anthropic.com/",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Anthropic Console"})]})]})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("openai"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.openai&&t.openai!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.openai?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"OpenAI"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:f.openai})]})]}),t.openai&&t.openai!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.openai&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"openaiKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(b,{id:"openaiKey",type:"password",placeholder:"sk-...",className:"flex-1",value:t.openai||"",onChange:s=>x("openai",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("openai"),title:"Clear API key",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("openai"),disabled:p.openai||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://platform.openai.com/api-keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"OpenAI Platform"})]})]})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("gemini"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.gemini&&t.gemini!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.gemini?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Google Gemini"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:f.gemini})]})]}),t.gemini&&t.gemini!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.gemini&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"geminiKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(b,{id:"geminiKey",type:"password",placeholder:"AIza...",className:"flex-1",value:t.gemini||"",onChange:s=>x("gemini",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("gemini"),title:"Clear API key",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("gemini"),disabled:p.gemini||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://makersuite.google.com/app/apikey",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Google AI Studio"})]})]})]}),e.jsxs("div",{className:"border rounded-lg mt-4",children:[e.jsxs("button",{onClick:()=>h("factorydroid"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.factorydroid&&t.factorydroid!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.factorydroid?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Factory Droid"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:f.factorydroid})]})]}),t.factorydroid&&t.factorydroid!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.factorydroid&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"factorydroidKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(b,{id:"factorydroidKey",type:"password",placeholder:"fd-...",className:"flex-1",value:t.factorydroid||"",onChange:s=>x("factorydroid",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("factorydroid"),title:"Clear API key",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("factorydroid"),disabled:p.factorydroid||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://factorydroid.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Factory Droid"})]})]})]})]})]}),e.jsxs(U,{children:[e.jsxs(Y,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-5 w-5"}),e.jsx(q,{children:"AI Assistant Settings"})]}),e.jsx(B,{children:"Configure default AI model and behavior for the AI assistant sidebar."})]}),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(m,{htmlFor:"defaultModel",children:"Default AI Model"}),e.jsxs(Q,{value:O,onValueChange:L,children:[e.jsx(W,{children:e.jsx(X,{placeholder:"Select default AI model"})}),e.jsx(Z,{children:E().map(s=>e.jsx(ee,{value:s.id,children:s.label},s.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"This model will be selected by default when opening the AI assistant."})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(r,{onClick:V,disabled:_||i,children:_?"Saving...":"Save"})})]})]})]})}export{de as default};
|
|
1
|
+
import{r as d,bw as A,v as l,j as e,bv as T,e as j,n as y,C as v,ad as N,I as b,B as r,E as k,a0 as w,h as $}from"./index-DB2Tq9wz.js";import{C as U,b as Y,c as q,d as B,a as H}from"./card-DRBgMGuU.js";import{L as m}from"./label-DxDedS8x.js";import{S as Q,a as W,b as X,c as Z,d as ee}from"./select-BzOa_wZx.js";import"./index-Bedu89qc.js";import"./chevron-up-DJfyvHso.js";const se=[{id:"openai/gpt-4o",label:"GPT-4o",provider:"openai",supportsMCP:!0,strengths:["balanced","reasoning","code","tools"],notes:"Great general model with tool/function calling support."},{id:"openai/gpt-4o-mini",label:"GPT-4o Mini",provider:"openai",supportsMCP:!0,strengths:["cost-effective","fast","tools"],notes:"Good for quick, inexpensive tasks with function calling."},{id:"openai/gpt-4.1",label:"GPT-4.1",provider:"openai",supportsMCP:!0,strengths:["coding","instruction following","long context"],notes:"Latest GPT-4 series with enhanced capabilities."},{id:"openai/o3-mini",label:"o3-mini",provider:"openai",supportsMCP:!0,strengths:["reasoning","math","coding"],notes:"Reasoning model optimized for efficiency."},{id:"anthropic/claude-sonnet-4.5",label:"Claude Sonnet 4.5",provider:"anthropic",supportsMCP:!0,strengths:["agents","coding","tools","fast","long context"],notes:"Most advanced Sonnet - 1.5-2x faster, optimized for agents and tool orchestration."},{id:"anthropic/claude-sonnet-4",label:"Claude Sonnet 4",provider:"anthropic",supportsMCP:!0,strengths:["reasoning","analysis","tools","coding"],notes:"Excellent tool use and reasoning capabilities."},{id:"anthropic/claude-3.5-sonnet",label:"Claude 3.5 Sonnet",provider:"anthropic",supportsMCP:!0,strengths:["reasoning","analysis","tools"],notes:"Reliable Claude model with strong tool support."},{id:"google/gemini-2.0-flash-001",label:"Gemini 2.0 Flash",provider:"google",supportsMCP:!0,strengths:["speed","multimodal","tools"],notes:"Fast Google model with function calling."},{id:"meta-llama/llama-3.1-405b-instruct",label:"Llama 3.1 405B",provider:"meta-llama",supportsMCP:!0,strengths:["reasoning","open weights","code"],notes:"High-capacity open model; function calling often available."},{id:"qwen/qwen-2.5-72b-instruct",label:"Qwen 2.5 72B",provider:"qwen",supportsMCP:!0,strengths:["cost-effective","code","tools"],notes:"Strong value open model with tool support."}],te={models:se},ae=te;function E(){return ae.models}function de(){const[t,F]=d.useState({}),[i,M]=d.useState(!0),[_,G]=d.useState(!1),[p,z]=d.useState({}),[I,R]=d.useState({}),[O,L]=d.useState(E()[0]?.id||"openai/gpt-4o"),[n,J]=d.useState({openrouter:!1,replicate:!1,anthropic:!1,openai:!1,gemini:!1,factorydroid:!1});d.useEffect(()=>{P()},[]);const P=async()=>{try{M(!0);const s=await A("/api/v1/config?type=global");if(s.success&&s.data){const a=s.data.apiKeys||{},o={},c={};for(const C of["openrouter","replicate","anthropic","openai","gemini","factorydroid"]){const K=a[C];K&&typeof K=="string"&&K.trim()!==""?(o[C]=!0,c[C]="***"):(o[C]=!1,c[C]="")}F(c);const S=s.data.defaults&&s.data.defaults.model?String(s.data.defaults.model):void 0;L(S||E()[0]?.id||"openai/gpt-4o")}}catch(s){console.error("Failed to load API keys:",s),l({title:"Error",description:"Failed to load API keys",variant:"destructive"})}finally{M(!1)}},x=(s,a)=>{F(o=>({...o,[s]:a}))},D=async s=>{try{R(S=>({...S,[s]:!0}));const a=t[s],o={provider:s};a&&a!=="***"&&(o.key=a);const c=await A("/api/v1/config/test",{method:"POST",body:JSON.stringify(o)});c.success&&c.message?l({title:"Test Result",description:c.message}):c.success?l({title:"Test Result",description:"Success"}):l({title:"Test Failed",description:c.message||"Unknown error",variant:"destructive"})}catch(a){l({title:"Test Failed",description:a instanceof Error?a.message:"Unknown error",variant:"destructive"})}finally{R(a=>({...a,[s]:!1}))}},h=s=>{J(a=>({...a,[s]:!a[s]}))},u=async s=>{try{const a={[s]:""};await A("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({apiKeys:a})}),l({title:"Success",description:`${s} API key cleared`}),await P()}catch(a){console.error("Failed to clear API key:",a),l({title:"Error",description:"Failed to clear API key",variant:"destructive"})}},g=async s=>{try{z(o=>({...o,[s]:!0}));const a={[s]:t[s]};await A("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({apiKeys:a})}),l({title:"Success",description:`${s} API key saved`}),await P()}catch(a){console.error("Failed to save API key:",a),l({title:"Error",description:"Failed to save API key",variant:"destructive"})}finally{z(a=>({...a,[s]:!1}))}},V=async()=>{try{G(!0),await A("/api/v1/config?type=global",{method:"PUT",body:JSON.stringify({defaults:{model:O}})}),l({title:"Success",description:"Default model saved successfully"})}catch(s){console.error("Failed to save default model:",s),l({title:"Error",description:"Failed to save default model",variant:"destructive"})}finally{G(!1)}},f={openrouter:"OPENROUTER_API_KEY",replicate:"REPLICATE_API_TOKEN",anthropic:"ANTHROPIC_API_KEY",openai:"OPENAI_API_KEY",gemini:"GEMINI_API_KEY",factorydroid:"FACTORY_API_KEY"};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium",children:"AI & LLM"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure Coconut's connections to LLM providers."})]}),e.jsx(T,{}),e.jsxs(U,{children:[e.jsxs(Y,{children:[e.jsx(q,{children:"API Keys & Authentication"}),e.jsx(B,{children:"Manage API keys and authentication tokens for integrated services."})]}),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1 mb-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"AI Assistant API Keys"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Keys used by the AI Assistant sidebar for chat and code suggestions."})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("openrouter"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.openrouter&&t.openrouter!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.openrouter?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"OpenRouter"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:f.openrouter})]})]}),t.openrouter&&t.openrouter!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.openrouter&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"openrouterKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(b,{id:"openrouterKey",type:"password",placeholder:"sk-or-v1-...",className:"flex-1",value:t.openrouter||"",onChange:s=>x("openrouter",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("openrouter"),title:"Clear API key",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>D("openrouter"),disabled:!!I.openrouter,title:"Test API key",children:I.openrouter?"Testing...":"Test"}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("openrouter"),disabled:p.openrouter||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"OpenRouter"})]})]})]}),e.jsx(T,{className:"my-6"}),e.jsxs("div",{className:"space-y-1 mb-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Resource Creation API Keys"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Keys used for generating images and other resources."})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("replicate"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.replicate&&t.replicate!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.replicate?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Replicate"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:f.replicate})]})]}),t.replicate&&t.replicate!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.replicate&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"replicateKey",children:"API Token"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(b,{id:"replicateKey",type:"password",placeholder:"r8_...",className:"flex-1",value:t.replicate||"",onChange:s=>x("replicate",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("replicate"),title:"Clear API token",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>D("replicate"),disabled:!!I.replicate,title:"Test API token",children:I.replicate?"Testing...":"Test"}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("replicate"),disabled:p.replicate||i,title:"Save API token",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your token from"," ",e.jsx("a",{href:"https://replicate.com/account/api-tokens",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Replicate"})]})]})]}),e.jsx(T,{className:"my-6"}),e.jsxs("div",{className:"space-y-1 mb-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Coding Agent API Keys"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"These keys are automatically provided to coding agents when they start running."})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("anthropic"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.anthropic&&t.anthropic!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.anthropic?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Anthropic Claude"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:f.anthropic})]})]}),t.anthropic&&t.anthropic!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.anthropic&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"anthropicKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(b,{id:"anthropicKey",type:"password",placeholder:"sk-ant-...",className:"flex-1",value:t.anthropic||"",onChange:s=>x("anthropic",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("anthropic"),title:"Clear API key",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("anthropic"),disabled:p.anthropic||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://console.anthropic.com/",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Anthropic Console"})]})]})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("openai"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.openai&&t.openai!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.openai?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"OpenAI"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:f.openai})]})]}),t.openai&&t.openai!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.openai&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"openaiKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(b,{id:"openaiKey",type:"password",placeholder:"sk-...",className:"flex-1",value:t.openai||"",onChange:s=>x("openai",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("openai"),title:"Clear API key",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("openai"),disabled:p.openai||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://platform.openai.com/api-keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"OpenAI Platform"})]})]})]}),e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs("button",{onClick:()=>h("gemini"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.gemini&&t.gemini!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.gemini?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Google Gemini"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:f.gemini})]})]}),t.gemini&&t.gemini!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.gemini&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"geminiKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(b,{id:"geminiKey",type:"password",placeholder:"AIza...",className:"flex-1",value:t.gemini||"",onChange:s=>x("gemini",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("gemini"),title:"Clear API key",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("gemini"),disabled:p.gemini||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://makersuite.google.com/app/apikey",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Google AI Studio"})]})]})]}),e.jsxs("div",{className:"border rounded-lg mt-4",children:[e.jsxs("button",{onClick:()=>h("factorydroid"),className:"w-full flex items-center justify-between p-4 hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:j("flex items-center justify-center w-8 h-8 rounded-md",t.factorydroid&&t.factorydroid!==""?"bg-green-100 dark:bg-green-950":"bg-muted"),children:n.factorydroid?e.jsx(y,{className:"h-4 w-4"}):e.jsx(v,{className:"h-4 w-4"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-medium",children:"Factory Droid"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:f.factorydroid})]})]}),t.factorydroid&&t.factorydroid!==""&&e.jsx(N,{className:"h-5 w-5 text-green-600 dark:text-green-400"})]}),n.factorydroid&&e.jsxs("div",{className:"p-4 pt-0 space-y-2",children:[e.jsx(m,{htmlFor:"factorydroidKey",children:"API Key"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(b,{id:"factorydroidKey",type:"password",placeholder:"fd-...",className:"flex-1",value:t.factorydroid||"",onChange:s=>x("factorydroid",s.target.value),disabled:i}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>u("factorydroid"),title:"Clear API key",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsx(r,{variant:"outline",size:"sm",onClick:()=>g("factorydroid"),disabled:p.factorydroid||i,title:"Save API key",children:e.jsx(w,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your key from"," ",e.jsx("a",{href:"https://factorydroid.com",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"Factory Droid"})]})]})]})]})]}),e.jsxs(U,{children:[e.jsxs(Y,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-5 w-5"}),e.jsx(q,{children:"AI Assistant Settings"})]}),e.jsx(B,{children:"Configure default AI model and behavior for the AI assistant sidebar."})]}),e.jsxs(H,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(m,{htmlFor:"defaultModel",children:"Default AI Model"}),e.jsxs(Q,{value:O,onValueChange:L,children:[e.jsx(W,{children:e.jsx(X,{placeholder:"Select default AI model"})}),e.jsx(Z,{children:E().map(s=>e.jsx(ee,{value:s.id,children:s.label},s.id))})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"This model will be selected by default when opening the AI assistant."})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(r,{onClick:V,disabled:_||i,children:_?"Saving...":"Save"})})]})]})]})}export{de as default};
|