@lovelybunch/api 1.0.75-alpha.6 → 1.0.75-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server-with-static.js +2 -0
- package/package.json +4 -4
- package/static/assets/{ActivityPage-QmXUVEPm.js → ActivityPage-BsNcwPRH.js} +1 -1
- package/static/assets/{ApiKeysSettingsPage-qie8F6gb.js → ApiKeysSettingsPage-Dk-JIhny.js} +1 -1
- package/static/assets/{ArchitectureEditPage-CPQnvHk4.js → ArchitectureEditPage-Cq3jRBeK.js} +1 -1
- package/static/assets/{ArchitecturePage-CJNygJU2.js → ArchitecturePage-DG4RrZCK.js} +1 -1
- package/static/assets/{AuthSettingsPage-B204F8bT.js → AuthSettingsPage-C7a7q-Q2.js} +1 -1
- package/static/assets/{CallbackPage-MGCRI7r_.js → CallbackPage-4mY02Tgr.js} +1 -1
- package/static/assets/{CodePage-BxEsUJP-.js → CodePage-DV9WWikT.js} +1 -1
- package/static/assets/{CollapsibleSection-CtALgJpu.js → CollapsibleSection-BfOUBfzq.js} +1 -1
- package/static/assets/{DashboardPage-DbvVqN24.js → DashboardPage-dRge5Q81.js} +1 -1
- package/static/assets/{GitPage-D2bnwXyJ.js → GitPage-r3PCQC0B.js} +1 -1
- package/static/assets/{GitSettingsPage-ZDdKMZl1.js → GitSettingsPage-fszzi8GW.js} +1 -1
- package/static/assets/{IdentityPage-Bu-duoN6.js → IdentityPage-BzVHjOMb.js} +1 -1
- package/static/assets/{ImplementationStepsEditor-PDSNPMod.js → ImplementationStepsEditor-COEh2NTL.js} +1 -1
- package/static/assets/{IntegrationsSettingsPage-DsM2vBgQ.js → IntegrationsSettingsPage-D8jiPBI8.js} +1 -1
- package/static/assets/{JobDetailPage-BBCASAAb.js → JobDetailPage-BIa9-NLI.js} +1 -1
- package/static/assets/{KnowledgeDetailPage-D1EptY9f.js → KnowledgeDetailPage-BQxD9Lz3.js} +1 -1
- package/static/assets/{KnowledgeEditPage-Dd4B0Zol.js → KnowledgeEditPage-kCUvyQ02.js} +1 -1
- package/static/assets/{KnowledgePage-ibFc3y1K.js → KnowledgePage-CzjHNc32.js} +1 -1
- package/static/assets/{LoginPage-v8StIMKr.js → LoginPage-C5GfXwon.js} +1 -1
- package/static/assets/{McpSettingsPage-m5Wzim08.js → McpSettingsPage-CrXjyI7N.js} +1 -1
- package/static/assets/{NewKnowledgePage-rmXqT_ay.js → NewKnowledgePage-DfSlEoq7.js} +1 -1
- package/static/assets/{NewProposalPage-CmMTQLo5.js → NewProposalPage-BEqehTAn.js} +1 -1
- package/static/assets/{NewSkillPage-D3Fffhkj.js → NewSkillPage-C4F8b-zZ.js} +1 -1
- package/static/assets/{ProjectEditPage-C37nAWFP.js → ProjectEditPage-Dxj0T_OR.js} +1 -1
- package/static/assets/{ProjectPage--_Q_QLC1.js → ProjectPage-WQwLaUBo.js} +1 -1
- package/static/assets/{PromptsSettingsPage-CGXj9CAs.js → PromptsSettingsPage-Bs1yLOnd.js} +1 -1
- package/static/assets/{ProposalDetailPage-BUHhxZ3l.js → ProposalDetailPage-Ox4VO8dP.js} +1 -1
- package/static/assets/{ProposalEditPage-C0eEdxJc.js → ProposalEditPage-RK0-VJcu.js} +1 -1
- package/static/assets/{ProposalsPage-DyQC5FFd.js → ProposalsPage-DYoO3Zmv.js} +1 -1
- package/static/assets/{ResourcesPage-IrMHiK53.js → ResourcesPage-DUSDibSA.js} +1 -1
- package/static/assets/{RoleEditPage-Bw35Wz-d.js → RoleEditPage-BNKO37rN.js} +1 -1
- package/static/assets/{RolePage-BOjMgEYI.js → RolePage-B4Crd8sw.js} +1 -1
- package/static/assets/{RulesSettingsPage-B0eW6OmX.js → RulesSettingsPage-C9JZf3Q-.js} +1 -1
- package/static/assets/{SchedulePage-CrfWjM5k.js → SchedulePage-BqPWdx_U.js} +1 -1
- package/static/assets/{SkillDetailPage-CKDNJYXm.js → SkillDetailPage-CaVyuMJn.js} +1 -1
- package/static/assets/{SkillEditPage-DnBv-wu9.js → SkillEditPage-BmzUm8ZL.js} +1 -1
- package/static/assets/{SkillsPage-C5VD2DNt.js → SkillsPage-qw5UquV7.js} +1 -1
- package/static/assets/{SkillsSettingsPage-D3M6mo3a.js → SkillsSettingsPage-DyomY5Jn.js} +1 -1
- package/static/assets/{SourceInput-BN8ZVkqs.js → SourceInput-D-9ARKki.js} +1 -1
- package/static/assets/{TagInput-CICgcKUW.js → TagInput-CaHIGpWw.js} +1 -1
- package/static/assets/{TerminalPage-PJ6jkMN5.js → TerminalPage-Cidkdbnm.js} +1 -1
- package/static/assets/{TerminalSessionPage-DuJ2n3mT.js → TerminalSessionPage-COs2_qA8.js} +1 -1
- package/static/assets/{UserPreferencesPage-CyNuAJru.js → UserPreferencesPage-D868VFVd.js} +1 -1
- package/static/assets/{UserSettingsPage-Bq2TlR-8.js → UserSettingsPage-DEFpDWXY.js} +1 -1
- package/static/assets/{UtilitiesPage-mZb2CtxF.js → UtilitiesPage-BBbNWbSM.js} +1 -1
- package/static/assets/{alert-CrqaDLRU.js → alert-YHLFG4kD.js} +1 -1
- package/static/assets/{arrow-down-CfqDgiIx.js → arrow-down-CVaEeC0E.js} +1 -1
- package/static/assets/{arrow-left-CIkDScAO.js → arrow-left-BpPEBvVt.js} +1 -1
- package/static/assets/{arrow-up-DoOW0Uek.js → arrow-up-BDiN-tgD.js} +1 -1
- package/static/assets/{badge-ikmjXCY_.js → badge-B59i_2WR.js} +1 -1
- package/static/assets/{browser-modal-BJ16icY9.js → browser-modal-DZpkwK9n.js} +1 -1
- package/static/assets/{calendar-B3EFURS-.js → calendar-Ck6-s6Vl.js} +1 -1
- package/static/assets/{card-C0a11V0T.js → card-B1BNEOKA.js} +1 -1
- package/static/assets/{chevron-left-Cbq2vuK_.js → chevron-left-D13rHXtZ.js} +1 -1
- package/static/assets/{chevrons-up-C3zGaueJ.js → chevrons-up-DrGM9h8F.js} +1 -1
- package/static/assets/{circle-alert-BZyc7kNR.js → circle-alert-3FuqDs2g.js} +1 -1
- package/static/assets/{circle-check-CC67C1b-.js → circle-check-Cq24IiHP.js} +1 -1
- package/static/assets/{circle-check-big-tNM4uoO8.js → circle-check-big-XKpfzr-Y.js} +1 -1
- package/static/assets/{circle-play-DgDKRctX.js → circle-play-CEPnc0z3.js} +1 -1
- package/static/assets/{circle-x-CbIXbCmI.js → circle-x-4bsQsvLG.js} +1 -1
- package/static/assets/{clipboard-Bhg2iYmV.js → clipboard-Xdr0FfgD.js} +1 -1
- package/static/assets/{clock-DUwjJehj.js → clock-BkRDj1VL.js} +1 -1
- package/static/assets/{download-CAr6POG8.js → download-_PvO8olJ.js} +1 -1
- package/static/assets/{external-link-C552Tasx.js → external-link-C34deyLk.js} +1 -1
- package/static/assets/{eye-F-BxEo2B.js → eye-CApn6EOn.js} +1 -1
- package/static/assets/{folder-git-2-BCO-gmji.js → folder-git-2-B5Xz-Xdp.js} +1 -1
- package/static/assets/{index-Cb4mP03_.js → index-DLvo1sdI.js} +3 -3
- package/static/assets/{info-DZ6rfcGz.js → info-BzNlGG-G.js} +1 -1
- package/static/assets/{label-VXwOLYGm.js → label-CdwSXdXm.js} +1 -1
- package/static/assets/{markdown-editor-DKBU3Sgf.js → markdown-editor-BfIQ27jO.js} +1 -1
- package/static/assets/{pause-CJhh_zgy.js → pause-FjNAOibm.js} +1 -1
- package/static/assets/{play-DqF_TESp.js → play-ps1v3QHM.js} +1 -1
- package/static/assets/{plus-B-nP-2Bc.js → plus-ChDS7MXp.js} +1 -1
- package/static/assets/{radio-group-CkXoX9re.js → radio-group-xmkSGMqE.js} +1 -1
- package/static/assets/{refresh-cw-DNCHo2vd.js → refresh-cw-DZmqHMC0.js} +1 -1
- package/static/assets/{search-pT3zGN1p.js → search-1cnszOvc.js} +1 -1
- package/static/assets/{switch-DKgMJKx9.js → switch-DIjerrYl.js} +1 -1
- package/static/assets/{tabs-LRqYZP6q.js → tabs-DHfBLbor.js} +1 -1
- package/static/assets/{tag-CNJNVCjj.js → tag-CGdHqvLW.js} +1 -1
- package/static/assets/{terminal-preview-C_hF2vLs.js → terminal-preview-DfhfOJmr.js} +1 -1
- package/static/assets/{use-terminal-B3kcgG1Q.js → use-terminal-BZlVNW2z.js} +1 -1
- package/static/assets/{zap-DeMKwLsi.js → zap-CN2EX1x-.js} +1 -1
- package/static/index.html +1 -1
|
@@ -176,6 +176,7 @@ import skillsById from './routes/api/v1/skills/[id]/index.js';
|
|
|
176
176
|
import identity, { readAgentCard, PUBLIC_AGENT_CARD_PATH } from './routes/api/v1/identity/index.js';
|
|
177
177
|
import git from './routes/api/v1/git/index.js';
|
|
178
178
|
import mcp from './routes/api/v1/mcp/index.js';
|
|
179
|
+
import symlinks from './routes/api/v1/symlinks/index.js';
|
|
179
180
|
import jobs from './routes/api/v1/jobs/index.js';
|
|
180
181
|
import events from './routes/api/v1/events/index.js';
|
|
181
182
|
import version from './routes/api/v1/version/index.js';
|
|
@@ -203,6 +204,7 @@ app.route('/api/v1/skills/:id', skillsById);
|
|
|
203
204
|
app.route('/api/v1/identity', identity);
|
|
204
205
|
app.route('/api/v1/git', git);
|
|
205
206
|
app.route('/api/v1/mcp', mcp);
|
|
207
|
+
app.route('/api/v1/symlinks', symlinks);
|
|
206
208
|
app.route('/api/v1/jobs', jobs);
|
|
207
209
|
app.route('/api/v1/events', events);
|
|
208
210
|
app.route('/api/v1/version', version);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovelybunch/api",
|
|
3
|
-
"version": "1.0.75-alpha.
|
|
3
|
+
"version": "1.0.75-alpha.7",
|
|
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.75-alpha.
|
|
41
|
-
"@lovelybunch/mcp": "^1.0.75-alpha.
|
|
42
|
-
"@lovelybunch/types": "^1.0.75-alpha.
|
|
40
|
+
"@lovelybunch/core": "^1.0.75-alpha.7",
|
|
41
|
+
"@lovelybunch/mcp": "^1.0.75-alpha.7",
|
|
42
|
+
"@lovelybunch/types": "^1.0.75-alpha.7",
|
|
43
43
|
"adm-zip": "^0.5.16",
|
|
44
44
|
"ai": "^6.0.79",
|
|
45
45
|
"arctic": "^1.9.2",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,A as p,j as e,H as v,bh as y,B as N,v as w,C as b}from"./index-
|
|
1
|
+
import{r as a,A as p,j as e,H as v,bh as y,B as N,v as w,C as b}from"./index-DLvo1sdI.js";import{C as c,a as d,b as k,c as C}from"./card-B1BNEOKA.js";import{B as m}from"./badge-B59i_2WR.js";import{R as E}from"./refresh-cw-DZmqHMC0.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(v,{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(y,{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{E as J,r as t,b5 as y,j as e,B as a,b6 as R,V as X,D as j,b as g,d as v,f,g as A,I as F,a5 as N,am as Y,J as i}from"./index-
|
|
1
|
+
import{E as J,r as t,b5 as y,j as e,B as a,b6 as R,V as X,D as j,b as g,d as v,f,g as A,I as F,a5 as N,am as Y,J as i}from"./index-DLvo1sdI.js";import{C as V,b as W,c as G,d as Q,a as Z}from"./card-B1BNEOKA.js";import{L as w}from"./label-CdwSXdXm.js";import{B as _}from"./badge-B59i_2WR.js";import{A as I,a as C}from"./alert-YHLFG4kD.js";import{I as L}from"./info-BzNlGG-G.js";import{P as ee}from"./plus-ChDS7MXp.js";import{C as se}from"./circle-alert-3FuqDs2g.js";function de(){const{authEnabled:n}=J(),[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/proposals`:"",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(V,{children:[e.jsx(W,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(G,{children:"Active API Keys"}),e.jsx(Q,{children:"API keys you've created for programmatic access"})]}),e.jsxs(a,{onClick:()=>l(!0),disabled:!n,children:[e.jsx(ee,{className:"mr-2 h-4 w-4"}),"Create API Key"]})]})}),e.jsx(Z,{children:P.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(R,{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(_,{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(X,{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(Y,{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{de 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,a7 as _,I as d,w 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,a7 as _,I as d,w as B}from"./index-DLvo1sdI.js";import{C as u,a as p,b as j,c as v}from"./card-B1BNEOKA.js";import{L as o}from"./label-CdwSXdXm.js";import{M as P}from"./markdown-editor-BfIQ27jO.js";import{A as R}from"./arrow-left-BpPEBvVt.js";import{C as $}from"./circle-check-big-XKpfzr-Y.js";function Q(){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,H as y,F as k,B as l,M as b,aB as w,L as C,Q as E,ay as A}from"./index-
|
|
1
|
+
import{a as g,r as n,A as v,j as e,H as y,F as k,B as l,M as b,aB as w,L as C,Q as E,ay as A}from"./index-DLvo1sdI.js";import{C as a,a as c,b as o,c as m}from"./card-B1BNEOKA.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,E as le,r as n,b5 as c,j as e,a6 as I,o as ce,D as O,a4 as $,B as l,b as M,d as V,f as J,g as _,I as j,h as H,i as z,k as W,l as q,m as a,a5 as B,R as oe,U as de,V as he,W as ue,Y as xe,Z as me,_ as ge,$ as je,a0 as pe,a1 as ve,J as r}from"./index-
|
|
1
|
+
import{c as Y,E as le,r as n,b5 as c,j as e,a6 as I,o as ce,D as O,a4 as $,B as l,b as M,d as V,f as J,g as _,I as j,h as H,i as z,k as W,l as q,m as a,a5 as B,R as oe,U as de,V as he,W as ue,Y as xe,Z as me,_ as ge,$ as je,a0 as pe,a1 as ve,J as r}from"./index-DLvo1sdI.js";import{C as p,b as v,c as w,d as f,a as y}from"./card-B1BNEOKA.js";import{L as o}from"./label-CdwSXdXm.js";import{S as U}from"./switch-DIjerrYl.js";import{B as k}from"./badge-B59i_2WR.js";import{C as we}from"./circle-alert-3FuqDs2g.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,H as x,A as f}from"./index-
|
|
1
|
+
import{r as m,j as e,H as x,A as f}from"./index-DLvo1sdI.js";import{C as w}from"./circle-check-Cq24IiHP.js";import{C as b}from"./circle-x-4bsQsvLG.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 l,q as oe,T as me,O as xe,v as M,X as he,F as ue,Q as fe,D as pe,b as je,d as ge,f as ve,h as Ne,i as ye,k as we,l as Se,m as C,p as Ce,a9 as B,aa as R,ab as O,ac as H,ad as L,ai as G,ah as be,w as ke,A as I}from"./index-Cb4mP03_.js";import{C as g,b as Ae,a as _,c as De}from"./card-C0a11V0T.js";import{B as U}from"./badge-ikmjXCY_.js";import{u as Me}from"./use-terminal-B3kcgG1Q.js";import{T as Ie}from"./terminal-preview-C_hF2vLs.js";import{b as Te,d as $e,c as Ee,a as Pe}from"./droid-DqWsM2dp.js";import{R as ze}from"./refresh-cw-DNCHo2vd.js";import{C as Fe,a as Be}from"./chevrons-up-C3zGaueJ.js";import{P as Re}from"./play-DqF_TESp.js";import"./xterm-DTxiCjtJ.js";const Oe=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 Je(){const c=ce(),{sessions:x,loading:b,error:T,refreshSessions:w,createSession:V,destroySession:q}=Me(),{toast:v}=de(),[$,W]=i.useState([]),[Q,X]=i.useState(!0),[p,k]=i.useState(()=>({})),[A,N]=i.useState(!1),[j,J]=i.useState("claude"),[E,K]=i.useState(""),[D,P]=i.useState(!1),[h,Y]=i.useState([]),[f,y]=i.useState([]),[Z,ee]=i.useState({}),[u,se]=i.useState([]),[o,S]=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 r=Math.floor(d/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`};i.useEffect(()=>{(async()=>{try{const t=await fetch(`${I}/api/v1/proposals`);if(t.ok){const a=await t.json(),n=a.data||a;W(Array.isArray(n)?n:[])}}catch(t){console.error("Error loading proposals:",t)}finally{X(!1)}})()},[]),i.useEffect(()=>{w()},[w]),i.useEffect(()=>{if(!A)return;(async()=>{try{const t=await fetch(`${I}/api/v1/mcp`);if(t.ok){const a=await t.json();a?.success&&Array.isArray(a.servers)&&(Y(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(`${I}/api/v1/skills`);if(t.ok){const a=await t.json(),d=(Array.isArray(a?.documents)?a.documents:[]).map(r=>({id:r.id,name:r?.metadata?.name||r.id,mcpServers:Oe(r?.metadata?.metadata?.mcpServers)}));se(d),S(r=>r.filter(F=>d.some(re=>re.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(r=>r.id===n);d&&d.mcpServers.forEach(r=>{(!a||a.has(r))&&t.add(r)})}),Array.from(t)})},[o,u,h]);const m=i.useMemo(()=>x.filter(s=>s.proposalId?.startsWith("cp-")||s.proposalId?.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=>p[a.id]),t={};m.forEach(a=>{t[a.id]=!s}),k(t)},ie=m.length>0&&m.every(s=>p[s.id]),ne=async s=>{await q(s)?(v({title:"Session closed",description:s}),setTimeout(()=>w(),100)):v({title:"Failed to close session",description:s,variant:"destructive"})},le=async()=>{P(!0);try{const s=`cp-${Date.now()}`,t={proposalId:s,contextType:"change-proposal",cliAgent:j,mcpServersMap:Z,selectedMcpServers:f,skills:u,selectedSkillIds:o,automationEnabled:!1,customInstruction:E.trim(),includeDefaultInstructions:!1};let a="";j==="claude"?a=Te(t):j==="gemini"?a=$e(t):j==="codex"?a=Ee(t):j==="droid"&&(a=Pe(t)),await V(s,!1,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:"Code"}),e.jsx("p",{className:"text-muted-foreground hidden sm:block",children:"Terminal sessions and coding agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(l,{variant:"outline",size:"sm",onClick:()=>w(),disabled:b,children:[e.jsx(ze,{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(l,{variant:"outline",size:"sm",onClick:ae,children:ie?e.jsxs(e.Fragment,{children:[e.jsx(Fe,{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(Be,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Show All"})]})}),e.jsxs(l,{size:"sm",onClick:()=>N(!0),children:[e.jsx(Re,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Interactive Session"})]})]})]}),T&&e.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("div",{className:"text-red-600",children:T})}),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(oe,{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("/proposals"),className:"text-primary hover:underline font-medium",children:"Change Proposal"})]})]})]})}):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(me,{className:"h-4 w-4 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:s.proposalId}),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(l,{size:"sm",variant:"outline",onClick:()=>{k(t=>({...t,[s.id]:!t[s.id]}))},"aria-label":p[s.id]?"Hide preview":"Show preview",title:p[s.id]?"Hide preview":"Show preview",children:p[s.id]?e.jsx(xe,{className:"h-4 w-4"}):e.jsx(M,{className:"h-4 w-4"})}),e.jsx(l,{size:"sm",variant:"outline",onClick:()=>c(`/terminal/${s.proposalId}`),children:"Open"}),e.jsx(l,{size:"icon",variant:"destructive",onClick:()=>ne(s.id),title:"Close session","aria-label":"Close session",children:e.jsx(he,{className:"h-4 w-4"})})]})]}),p[s.id]&&e.jsx("div",{className:"mt-2 w-full p-2 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>c(`/terminal/${s.proposalId}`),title:"Click to open full terminal session",children:e.jsx(Ie,{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(Ae,{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 proposals 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(De,{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 l,q as oe,T as me,O as xe,v as M,X as he,F as ue,Q as fe,D as pe,b as je,d as ge,f as ve,h as Ne,i as ye,k as we,l as Se,m as C,p as Ce,a9 as B,aa as R,ab as O,ac as H,ad as L,ai as G,ah as be,w as ke,A as I}from"./index-DLvo1sdI.js";import{C as g,b as Ae,a as _,c as De}from"./card-B1BNEOKA.js";import{B as U}from"./badge-B59i_2WR.js";import{u as Me}from"./use-terminal-BZlVNW2z.js";import{T as Ie}from"./terminal-preview-DfhfOJmr.js";import{b as Te,d as $e,c as Ee,a as Pe}from"./droid-DqWsM2dp.js";import{R as ze}from"./refresh-cw-DZmqHMC0.js";import{C as Fe,a as Be}from"./chevrons-up-DrGM9h8F.js";import{P as Re}from"./play-ps1v3QHM.js";import"./xterm-DTxiCjtJ.js";const Oe=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 Je(){const c=ce(),{sessions:x,loading:b,error:T,refreshSessions:w,createSession:V,destroySession:q}=Me(),{toast:v}=de(),[$,W]=i.useState([]),[Q,X]=i.useState(!0),[p,k]=i.useState(()=>({})),[A,N]=i.useState(!1),[j,J]=i.useState("claude"),[E,K]=i.useState(""),[D,P]=i.useState(!1),[h,Y]=i.useState([]),[f,y]=i.useState([]),[Z,ee]=i.useState({}),[u,se]=i.useState([]),[o,S]=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 r=Math.floor(d/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`};i.useEffect(()=>{(async()=>{try{const t=await fetch(`${I}/api/v1/proposals`);if(t.ok){const a=await t.json(),n=a.data||a;W(Array.isArray(n)?n:[])}}catch(t){console.error("Error loading proposals:",t)}finally{X(!1)}})()},[]),i.useEffect(()=>{w()},[w]),i.useEffect(()=>{if(!A)return;(async()=>{try{const t=await fetch(`${I}/api/v1/mcp`);if(t.ok){const a=await t.json();a?.success&&Array.isArray(a.servers)&&(Y(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(`${I}/api/v1/skills`);if(t.ok){const a=await t.json(),d=(Array.isArray(a?.documents)?a.documents:[]).map(r=>({id:r.id,name:r?.metadata?.name||r.id,mcpServers:Oe(r?.metadata?.metadata?.mcpServers)}));se(d),S(r=>r.filter(F=>d.some(re=>re.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(r=>r.id===n);d&&d.mcpServers.forEach(r=>{(!a||a.has(r))&&t.add(r)})}),Array.from(t)})},[o,u,h]);const m=i.useMemo(()=>x.filter(s=>s.proposalId?.startsWith("cp-")||s.proposalId?.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=>p[a.id]),t={};m.forEach(a=>{t[a.id]=!s}),k(t)},ie=m.length>0&&m.every(s=>p[s.id]),ne=async s=>{await q(s)?(v({title:"Session closed",description:s}),setTimeout(()=>w(),100)):v({title:"Failed to close session",description:s,variant:"destructive"})},le=async()=>{P(!0);try{const s=`cp-${Date.now()}`,t={proposalId:s,contextType:"change-proposal",cliAgent:j,mcpServersMap:Z,selectedMcpServers:f,skills:u,selectedSkillIds:o,automationEnabled:!1,customInstruction:E.trim(),includeDefaultInstructions:!1};let a="";j==="claude"?a=Te(t):j==="gemini"?a=$e(t):j==="codex"?a=Ee(t):j==="droid"&&(a=Pe(t)),await V(s,!1,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:"Code"}),e.jsx("p",{className:"text-muted-foreground hidden sm:block",children:"Terminal sessions and coding agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(l,{variant:"outline",size:"sm",onClick:()=>w(),disabled:b,children:[e.jsx(ze,{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(l,{variant:"outline",size:"sm",onClick:ae,children:ie?e.jsxs(e.Fragment,{children:[e.jsx(Fe,{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(Be,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Show All"})]})}),e.jsxs(l,{size:"sm",onClick:()=>N(!0),children:[e.jsx(Re,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Interactive Session"})]})]})]}),T&&e.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("div",{className:"text-red-600",children:T})}),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(oe,{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("/proposals"),className:"text-primary hover:underline font-medium",children:"Change Proposal"})]})]})]})}):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(me,{className:"h-4 w-4 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium text-sm",children:s.proposalId}),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(l,{size:"sm",variant:"outline",onClick:()=>{k(t=>({...t,[s.id]:!t[s.id]}))},"aria-label":p[s.id]?"Hide preview":"Show preview",title:p[s.id]?"Hide preview":"Show preview",children:p[s.id]?e.jsx(xe,{className:"h-4 w-4"}):e.jsx(M,{className:"h-4 w-4"})}),e.jsx(l,{size:"sm",variant:"outline",onClick:()=>c(`/terminal/${s.proposalId}`),children:"Open"}),e.jsx(l,{size:"icon",variant:"destructive",onClick:()=>ne(s.id),title:"Close session","aria-label":"Close session",children:e.jsx(he,{className:"h-4 w-4"})})]})]}),p[s.id]&&e.jsx("div",{className:"mt-2 w-full p-2 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>c(`/terminal/${s.proposalId}`),title:"Click to open full terminal session",children:e.jsx(Ie,{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(Ae,{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 proposals 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(De,{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(l,{variant:"ghost",size:"sm",onClick:()=>c(`/proposals/${s.id}`),className:"h-7 px-2 text-xs",children:[e.jsx(ue,{className:"h-3 w-3 mr-1"})," View"]}),e.jsxs(l,{variant:"ghost",size:"sm",onClick:()=>c(`/proposals/${s.id}/edit`),className:"h-7 px-2 text-xs",children:[e.jsx(fe,{className:"h-3 w-3 mr-1"})," Edit"]})]})]})]})})})},s.id))})]}),e.jsx(pe,{open:A,onOpenChange:N,children:e.jsxs(je,{className:"max-w-lg",children:[e.jsxs(ge,{children:[e.jsx(ve,{children:"Start Coding Agent"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Start an interactive coding 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:"Coding Agent"}),e.jsxs(Ne,{value:j,onValueChange:s=>J(s),children:[e.jsx(ye,{className:"w-full",children:e.jsx(we,{placeholder:"Select coding agent"})}),e.jsxs(Se,{children:[e.jsx(C,{value:"claude",children:"Claude Code"}),e.jsx(C,{value:"gemini",children:"Google Gemini"}),e.jsx(C,{value:"codex",children:"OpenAI Codex"}),e.jsx(C,{value:"droid",children:"Factory Droid"})]})]})]}),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(Ce,{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(l,{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(O,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(H,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Skills"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(l,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),S(u.map(t=>t.id))},children:"All"}),e.jsx(l,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),S([])},children:"None"})]})]}),e.jsx(L,{}),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=>{S(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(be,{className:"h-4 w-4"}),"MCP Servers"]}),e.jsxs("div",{className:"text-xs text-gray-500",children:[f.length," of ",h.length," selected"]})]}),e.jsxs(B,{children:[e.jsx(R,{asChild:!0,children:e.jsxs(l,{variant:"outline",className:"w-full justify-between",children:[f.length===0?"Select MCP servers...":f.length===h.length?"All servers selected":`${f.length} server${f.length!==1?"s":""} selected`,e.jsx(M,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(O,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsxs(H,{className:"flex items-center justify-between",children:[e.jsx("span",{children:"Available Servers"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(l,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),y(h)},children:"All"}),e.jsx(l,{size:"sm",variant:"ghost",className:"h-5 px-1 text-xs",onClick:s=>{s.preventDefault(),y([])},children:"None"})]})]}),e.jsx(L,{}),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:f.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(ke,{value:E,onChange:s=>K(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(l,{variant:"outline",onClick:()=>N(!1),disabled:D,children:"Cancel"}),e.jsx(l,{onClick:le,disabled:D,children:D?"Starting...":"Start Session"})]})]})]})})]})}export{Je as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as x,j as e,e as a,v as m}from"./index-
|
|
1
|
+
import{r as x,j as e,e as a,v as m}from"./index-DLvo1sdI.js";function u({title:r,description:t,icon:n,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:[n,e.jsxs("div",{children:[e.jsx("p",{className:"font-medium leading-tight",children:r}),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 b,u as Pe,a as Re,r as l,j as e,D as Le,b as De,d as te,e as f,f as ae,g as ne,S as re,B as d,C as le,I as E,h as oe,i as ce,k as ie,l as de,m as V,n as G,o as Ie,G as _e,F as ze,p as ue,q as We,s as qe,t as W,T as me,v as Fe,w as Be,L as v,M as Ee,K as A,x as g,y as Ve,A as Ke}from"./index-
|
|
1
|
+
import{c as b,u as Pe,a as Re,r as l,j as e,D as Le,b as De,d as te,e as f,f as ae,g as ne,S as re,B as d,C as le,I as E,h as oe,i as ce,k as ie,l as de,m as V,n as G,o as Ie,G as _e,F as ze,p as ue,q as We,s as qe,t as W,T as me,v as Fe,w as Be,L as v,M as Ee,K as A,x as g,y as Ve,A as Ke}from"./index-DLvo1sdI.js";import{C as h,a as u,b as P,c as R,d as xe}from"./card-B1BNEOKA.js";import{B as $e}from"./badge-B59i_2WR.js";import{g as Ge}from"./status-utils-BDOyevaX.js";import{L as He}from"./label-CdwSXdXm.js";import{u as Oe}from"./use-terminal-BZlVNW2z.js";import{T as Ye}from"./terminal-preview-DfhfOJmr.js";import{C as Qe}from"./circle-check-Cq24IiHP.js";import{C as Ue}from"./chevron-left-D13rHXtZ.js";import{S as Ze}from"./search-1cnszOvc.js";import{Z as Je}from"./zap-CN2EX1x-.js";import{C as Xe}from"./calendar-Ck6-s6Vl.js";import{F as es}from"./folder-git-2-B5Xz-Xdp.js";import{E as ss}from"./external-link-C34deyLk.js";import{P as ts}from"./play-ps1v3QHM.js";import{C as as}from"./clock-BkRDj1VL.js";import{C as ns}from"./circle-check-big-XKpfzr-Y.js";import{P as rs}from"./plus-ChDS7MXp.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,be as ws,r as n,a as vs,ak as ys,j as e,L as ee,s as Fe,B as o,G as D,ag as Ns,X as Cs,I as k,O as Me,v as Be,V as Oe,D as se,b as te,d as ae,f as re,g as ne,b6 as ks,a5 as Re}from"./index-
|
|
1
|
+
import{c as le,A as l,be as ws,r as n,a as vs,ak as ys,j as e,L as ee,s as Fe,B as o,G as D,ag as Ns,X as Cs,I as k,O as Me,v as Be,V as Oe,D as se,b as te,d as ae,f as re,g as ne,b6 as ks,a5 as Re}from"./index-DLvo1sdI.js";import{C as ie}from"./card-B1BNEOKA.js";import{L as Ge}from"./label-CdwSXdXm.js";import{T as Ss,a as Ps,b as We,c as ze}from"./tabs-DHfBLbor.js";import{C as Ts}from"./circle-check-Cq24IiHP.js";import{C as As}from"./circle-x-4bsQsvLG.js";import{A as Ds}from"./arrow-down-CVaEeC0E.js";import{A as Es}from"./arrow-up-BDiN-tgD.js";import{R as Ue}from"./refresh-cw-DZmqHMC0.js";import{C as ce}from"./circle-alert-3FuqDs2g.js";import{F as oe}from"./folder-git-2-B5Xz-Xdp.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 He,r,a as Te,A as u,j as e,a6 as he,B as o,V as Fe,H as De,b6 as ze,I as U,D as W,b as B,d as q,f as J,g as K,a5 as V}from"./index-
|
|
1
|
+
import{c as He,r,a as Te,A as u,j as e,a6 as he,B as o,V as Fe,H as De,b6 as ze,I as U,D as W,b as B,d as q,f as J,g as K,a5 as V}from"./index-DLvo1sdI.js";import{C as xe,b as pe,c as ge,d as fe,a as be}from"./card-B1BNEOKA.js";import{L as f}from"./label-CdwSXdXm.js";import{R as Me,a as je}from"./radio-group-xmkSGMqE.js";import{R as A}from"./refresh-cw-DZmqHMC0.js";import{E as ve}from"./external-link-C34deyLk.js";import{C as Oe}from"./circle-check-Cq24IiHP.js";import{C as Ie}from"./circle-x-4bsQsvLG.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 oe,a as ve,r as u,j as e,H as se,B as x,a7 as fe,a3 as Ne,b4 as Te,o as Ce,I as c,w as O,ag as ae,a6 as ne,V as be,h as Se,i as we,k as Ae,l as ke,m as Ie,A as ie}from"./index-
|
|
1
|
+
import{c as oe,a as ve,r as u,j as e,H as se,B as x,a7 as fe,a3 as Ne,b4 as Te,o as Ce,I as c,w as O,ag as ae,a6 as ne,V as be,h as Se,i as we,k as Ae,l as ke,m as Ie,A as ie}from"./index-DLvo1sdI.js";import{C as y,b as g,c as j,d as v,a as f,e as Oe}from"./card-B1BNEOKA.js";import{L as o}from"./label-CdwSXdXm.js";import{B as re}from"./badge-B59i_2WR.js";import{A as Fe,a as Pe}from"./alert-YHLFG4kD.js";import{T as Ee,a as Me,b,c as S}from"./tabs-DHfBLbor.js";import{Z as Le}from"./zap-CN2EX1x-.js";import{E as De}from"./eye-CApn6EOn.js";import{P as E}from"./plus-ChDS7MXp.js";import{C as _e,a as Ue}from"./clipboard-Xdr0FfgD.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 u,j as e,e as p,B as r,V as x,I as j,h as v,i as y,k as S,l as f,m as g}from"./index-
|
|
1
|
+
import{c as u,j as e,e as p,B as r,V as x,I as j,h as v,i as y,k as S,l as f,m as g}from"./index-DLvo1sdI.js";import{L as c}from"./label-CdwSXdXm.js";import{P as k}from"./plus-ChDS7MXp.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-DsM2vBgQ.js → IntegrationsSettingsPage-D8jiPBI8.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as d,b5 as A,J as l,j as e,a6 as T,e as j,v as y,C as v,al as N,I as b,B as r,V as k,a7 as w,n as $,h as Q,i as W,k as X,l as Z,m as ee}from"./index-Cb4mP03_.js";import{C as U,b as Y,c as q,d as J,a as B}from"./card-C0a11V0T.js";import{L as m}from"./label-VXwOLYGm.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 le(){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,H]=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=>{H(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(J,{children:"Manage API keys and authentication tokens for integrated services."})]}),e.jsxs(B,{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(J,{children:"Configure default AI model and behavior for the AI assistant sidebar."})]}),e.jsxs(B,{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{le as default};
|
|
1
|
+
import{r as d,b5 as A,J as l,j as e,a6 as T,e as j,v as y,C as v,al as N,I as b,B as r,V as k,a7 as w,n as $,h as Q,i as W,k as X,l as Z,m as ee}from"./index-DLvo1sdI.js";import{C as U,b as Y,c as q,d as J,a as B}from"./card-B1BNEOKA.js";import{L as m}from"./label-CdwSXdXm.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 le(){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,H]=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=>{H(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(J,{children:"Manage API keys and authentication tokens for integrated services."})]}),e.jsxs(B,{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(J,{children:"Configure default AI model and behavior for the AI assistant sidebar."})]}),e.jsxs(B,{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{le as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as se,u as te,a as ae,ak as re,r as d,j as e,B as c,L as N,H as C,R as ne,U as ie,V as de,W as le,Y as ce,Z as oe,_ as me,$ as xe,a0 as ue,a1 as he,p as H,ah as pe,O as je,v as ge,F as fe,Q as Ne,a6 as O,A as v}from"./index-Cb4mP03_.js";import{c as ve}from"./clipboard-B9ndUJKl.js";import{C as o,b as g,a as m,c as b,d as G}from"./card-C0a11V0T.js";import{B as w}from"./badge-ikmjXCY_.js";import{A as D}from"./arrow-left-CIkDScAO.js";import{P as S}from"./play-DqF_TESp.js";import{C as be,a as we}from"./clipboard-Bhg2iYmV.js";import{R as ye}from"./refresh-cw-DNCHo2vd.js";import{P as Ce}from"./pause-CJhh_zgy.js";import{C as V}from"./clock-DUwjJehj.js";import{C as Se}from"./calendar-B3EFURS-.js";const Ae=[{id:"claude",label:"Claude Code"},{id:"gemini",label:"Google Gemini"},{id:"codex",label:"OpenAI Codex"},{id:"droid",label:"Factory Droid"}],f=a=>{if(!a)return"—";try{return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(a))}catch{return a}},$=a=>{if(!a)return"—";const i=new Date(a).getTime()-Date.now(),l=Math.round(i/(1e3*60));if(Number.isNaN(l))return f(a);if(Math.abs(l)<1)return"now";if(l>0){if(l<60)return`in ${l}m`;const h=Math.round(l/60);return h<24?`in ${h}h`:`in ${Math.round(h/24)}d`}const t=Math.abs(l);if(t<60)return`${t}m ago`;const u=Math.round(t/60);return u<24?`${u}h ago`:`${Math.round(u/24)}d ago`},ke=a=>{if(a.type==="interval"){const x=a.daysOfWeek.map(i=>i.slice(0,3).toUpperCase()).join(", ");return`Every ${a.hours}h (${x||"All days"})`}return a.description||`Cron: ${a.expression}`},Re=a=>{const x=Ae.find(i=>i.id===a);return x?x.label:a},L=a=>{switch(a){case"active":case"succeeded":return"default";case"paused":case"running":return"secondary";case"failed":return"destructive";default:return"outline"}};function Me(){const{id:a}=se(),x=te(),{toast:i}=ae(),{refresh:l}=re(),[t,u]=d.useState(null),[T,h]=d.useState(!0),[y,E]=d.useState(null),[P,F]=d.useState(!1),[A,J]=d.useState(!1),[p,U]=d.useState(!1),[W,_]=d.useState(!1),[q,Q]=d.useState(new Set),[B,k]=d.useState({}),[Y,M]=d.useState(new Set),R=async()=>{if(a)try{h(!0);const r=await(await fetch(`${v}/api/v1/jobs/${a}`)).json();r.success?u(r.data):E(r.error?.message||"Failed to fetch job")}catch(s){E(s instanceof Error?s.message:"Unknown error")}finally{h(!1)}};d.useEffect(()=>{R()},[a]);const Z=async()=>{if(a){F(!0);try{const r=await(await fetch(`${v}/api/v1/jobs/${a}`,{method:"DELETE"})).json();r.success?(i({title:"Job deleted",description:t?.name||"Scheduled job has been deleted"}),x("/schedule")):i({title:"Failed to delete job",description:r.error?.message||"Unknown error",variant:"destructive"})}catch(s){i({title:"Failed to delete job",description:s instanceof Error?s.message:"Unknown error",variant:"destructive"})}finally{F(!1)}}},K=async()=>{if(!t||!a)return;J(!0);const s=t.status==="active"?"paused":"active";try{const n=await(await fetch(`${v}/api/v1/jobs/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:s})})).json();n.success?(u(n.data),await l(),i({title:s==="active"?"Job resumed":"Job paused",description:t.name})):i({title:"Failed to update job",description:n.error?.message||"Unknown error",variant:"destructive"})}catch(r){i({title:"Failed to update job",description:r instanceof Error?r.message:"Unknown error",variant:"destructive"})}finally{J(!1)}},z=async()=>{if(!(!t||!a)){U(!0);try{const s=await fetch(`${v}/api/v1/jobs/${a}/run`,{method:"POST"}),r=await s.json();r.success||s.ok?(i({title:"Run started",description:`${t.name} is executing.`}),await R(),await l()):i({title:"Failed to start run",description:r.error?.message||"Unknown error",variant:"destructive"})}catch(s){i({title:"Failed to start run",description:s instanceof Error?s.message:"Unknown error",variant:"destructive"})}finally{U(!1)}}},X=async s=>{Q(r=>{const n=new Set(r);return n.has(s)?n.delete(s):(n.add(s),!B[s]&&a&&ee(s)),n})},ee=async s=>{if(a){M(r=>new Set(r).add(s));try{const r=await fetch(`${v}/api/v1/jobs/${a}/runs/${s}/log`);if(r.ok){const n=await r.text();k(j=>({...j,[s]:n}))}else{const n=await r.json().catch(()=>({}));k(j=>({...j,[s]:n.error?.message||"Log not available"}))}}catch(r){k(n=>({...n,[s]:r instanceof Error?r.message:"Failed to load log"}))}finally{M(r=>{const n=new Set(r);return n.delete(s),n})}}};if(T)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-3/4 animate-pulse"}),e.jsx(c,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(N,{to:"/schedule",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})})]}),e.jsxs(o,{children:[e.jsx(g,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-3/4 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-1/2 animate-pulse"})]})}),e.jsx(m,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-4 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-5/6 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-4/6 animate-pulse"})]})})]})]});if(y||!t)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:y||"Job not found"})}),e.jsx(c,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(N,{to:"/schedule",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})})]}),e.jsx(o,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:y||"Job not found"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:['The job with ID "',a,'" could not be found.']}),e.jsx(c,{asChild:!0,className:"mt-4",children:e.jsx(N,{to:"/schedule",children:"Back to Schedule"})})]})})})]});const I=t.agentIds||(t.agentId?[t.agentId]:[]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight min-w-0",children:t.name}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(c,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(N,{to:"/schedule",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})}),e.jsxs(c,{variant:"default",size:"sm",onClick:z,disabled:p||!!t._error,children:[p?e.jsx(C,{className:"h-4 w-4 animate-spin sm:mr-2"}):e.jsx(S,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:p?"Running...":"Run Now"})]}),e.jsxs(ne,{children:[e.jsx(ie,{asChild:!0,children:e.jsxs(c,{variant:"destructive",size:"sm",disabled:P,children:[e.jsx(de,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:P?"Deleting...":"Delete"})]})}),e.jsxs(le,{children:[e.jsxs(ce,{children:[e.jsx(oe,{children:"Are you absolutely sure?"}),e.jsxs(me,{children:["This action cannot be undone. This will permanently delete the scheduled job",e.jsxs("span",{className:"font-semibold",children:[' "',t.name,'"']}),". Existing run logs will remain in ",e.jsx("code",{children:".nut/jobs/logs"}),"."]})]}),e.jsxs(xe,{children:[e.jsx(ue,{children:"Cancel"}),e.jsx(he,{onClick:Z,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Job"})]})]})]})]})]}),e.jsxs("button",{type:"button",onClick:async()=>{const s=`.nut/jobs/job-${t.id}.md`;try{await ve(s),_(!0),i({title:"Copied!",description:`${s} copied to clipboard`}),setTimeout(()=>_(!1),2e3)}catch(r){console.error("Failed to copy path:",r),i({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors font-mono",children:[e.jsx("span",{children:`.nut/jobs/job-${t.id}.md`}),W?e.jsx(be,{className:"h-3.5 w-3.5"}):e.jsx(we,{className:"h-3.5 w-3.5"})]})]}),t._error&&e.jsx(o,{className:"border-destructive/50 bg-destructive/5",children:e.jsxs(m,{className:"pt-6",children:[e.jsx("p",{className:"text-sm text-destructive font-medium",children:t._error}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Please review the job file at ",e.jsxs("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:[".nut/jobs/job-",t.id,".md"]})]})]})}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(o,{children:[e.jsxs(g,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:"Job Configuration"}),e.jsx(w,{variant:L(t.status),className:"capitalize",children:t.status})]}),t.description&&e.jsx(G,{children:t.description})]}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Instructions"}),e.jsx("div",{className:"rounded-md bg-muted/50 p-3 font-mono text-sm whitespace-pre-wrap",children:t.prompt})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-1",children:"AI Model"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:Re(t.model)})]})]}),I.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-1",children:"Custom Agents"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:I.map(s=>e.jsxs("div",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800 text-xs",children:[e.jsx(H,{className:"h-3 w-3 text-blue-600 dark:text-blue-400"}),e.jsx("span",{className:"font-medium text-blue-900 dark:text-blue-100",children:s.replace(".md","")})]},s))})]}),t.mcpServers&&t.mcpServers.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-1",children:"MCP Servers"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.mcpServers.map(s=>e.jsxs("div",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-purple-50 dark:bg-purple-950/20 border border-purple-200 dark:border-purple-800 text-xs",children:[e.jsx(pe,{className:"h-3 w-3 text-purple-600 dark:text-purple-400"}),e.jsx("span",{className:"font-medium text-purple-900 dark:text-purple-100",children:s})]},s))})]})]})]})]}),e.jsxs(o,{children:[e.jsx(g,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(b,{children:"Run History"}),e.jsxs(G,{children:[t.runs.length," recorded run",t.runs.length!==1?"s":""]})]}),e.jsxs(c,{variant:"outline",size:"sm",onClick:R,children:[e.jsx(ye,{className:"h-4 w-4 mr-2"}),"Refresh"]})]})}),e.jsx(m,{children:t.runs.length===0?e.jsx("div",{className:"rounded-md border border-dashed bg-muted/20 p-6 text-center text-sm text-muted-foreground",children:'No runs yet. Click "Run Now" to execute this job.'}):e.jsx("div",{className:"space-y-3",children:t.runs.map(s=>{const r=q.has(s.id),n=Y.has(s.id),j=B[s.id];return e.jsxs("div",{className:"rounded-md border bg-card/50 overflow-hidden",children:[e.jsxs("div",{className:"p-3 cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>X(s.id),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx(w,{variant:L(s.status),className:"capitalize text-xs",children:s.status}),e.jsx("span",{className:"text-sm text-muted-foreground",children:f(s.startedAt)}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",$(s.startedAt),")"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.trigger==="manual"&&e.jsx(w,{variant:"outline",className:"text-xs",children:"manual"}),r?e.jsx(je,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ge,{className:"h-4 w-4 text-muted-foreground"})]})]}),s.error&&e.jsx("p",{className:"text-sm text-destructive font-medium mb-2",children:s.error}),s.summary&&!r&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:s.summary})]}),r&&e.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t bg-muted/20",children:[e.jsxs("div",{className:"pt-3 grid gap-2 text-xs",children:[s.finishedAt&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Finished:"}),e.jsx("span",{children:f(s.finishedAt)})]}),s.cliCommand&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Command:"}),e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded text-xs break-all",children:s.cliCommand})]}),s.outputPath&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Log path:"}),e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded text-xs",children:s.outputPath})]})]}),s.summary&&e.jsxs("div",{children:[e.jsx("h5",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Summary"}),e.jsx("div",{className:"rounded bg-muted/50 p-2 font-mono text-xs leading-relaxed whitespace-pre-wrap",children:s.summary})]}),e.jsxs("div",{children:[e.jsxs("h5",{className:"text-xs font-medium text-muted-foreground mb-1 flex items-center gap-1.5",children:[e.jsx(fe,{className:"h-3 w-3"}),"Full Log"]}),n?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground p-2",children:[e.jsx(C,{className:"h-3 w-3 animate-spin"}),"Loading log..."]}):j?e.jsx("div",{className:"rounded bg-muted/50 p-2 font-mono text-xs leading-relaxed max-h-96 overflow-auto whitespace-pre-wrap",children:j}):e.jsx("div",{className:"text-xs text-muted-foreground p-2",children:"Log not available"})]})]})]},s.id)})})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(o,{children:[e.jsx(g,{children:e.jsx(b,{children:"Actions"})}),e.jsxs(m,{className:"space-y-2",children:[e.jsxs(c,{variant:"default",className:"w-full justify-start",onClick:z,disabled:p||!!t._error,children:[p?e.jsx(C,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(S,{className:"h-4 w-4 mr-2"}),p?"Running...":"Run Now"]}),e.jsxs(c,{variant:"outline",className:"w-full justify-start",onClick:K,disabled:A||!!t._error,children:[A?e.jsx(C,{className:"h-4 w-4 mr-2 animate-spin"}):t.status==="active"?e.jsx(Ce,{className:"h-4 w-4 mr-2"}):e.jsx(S,{className:"h-4 w-4 mr-2"}),A?"Updating...":t.status==="active"?"Pause Job":"Resume Job"]}),e.jsx(c,{variant:"outline",className:"w-full justify-start",asChild:!0,disabled:!!t._error,children:e.jsxs(N,{to:"/schedule",state:{editJobId:t.id},children:[e.jsx(Ne,{className:"h-4 w-4 mr-2"}),"Edit Job"]})})]})]}),e.jsxs(o,{children:[e.jsx(g,{children:e.jsx(b,{children:"Schedule"})}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(V,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:ke(t.schedule)})]}),t.schedule.type==="interval"&&t.schedule.anchorHour!==void 0&&e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Start hour:"})," ",e.jsxs("span",{children:[t.schedule.anchorHour,":00"]})]}),e.jsx(O,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Next run:"}),e.jsx("span",{className:"font-medium",children:$(t.metadata.nextRunAt)})]}),t.metadata.nextRunAt&&e.jsx("div",{className:"text-xs text-muted-foreground",children:f(t.metadata.nextRunAt)})]})]})]}),e.jsxs(o,{children:[e.jsx(g,{children:e.jsx(b,{children:"Information"})}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Se,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Created:"}),e.jsx("span",{children:f(t.metadata.createdAt)})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(V,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Updated:"}),e.jsx("span",{children:f(t.metadata.updatedAt)})]}),t.metadata.lastRunAt&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(S,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Last run:"}),e.jsx("span",{children:$(t.metadata.lastRunAt)})]}),e.jsx(O,{}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Status:"}),e.jsx("div",{className:"mt-1",children:e.jsx(w,{variant:L(t.status),className:"capitalize",children:t.status})})]}),t.tags&&t.tags.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Tags:"}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:t.tags.map(s=>e.jsx(w,{variant:"outline",className:"text-xs",children:s},s))})]})]})]})]})]})]})}export{Me as default};
|
|
1
|
+
import{P as se,u as te,a as ae,ak as re,r as d,j as e,B as c,L as N,H as C,R as ne,U as ie,V as de,W as le,Y as ce,Z as oe,_ as me,$ as xe,a0 as ue,a1 as he,p as H,ah as pe,O as je,v as ge,F as fe,Q as Ne,a6 as O,A as v}from"./index-DLvo1sdI.js";import{c as ve}from"./clipboard-B9ndUJKl.js";import{C as o,b as g,a as m,c as b,d as G}from"./card-B1BNEOKA.js";import{B as w}from"./badge-B59i_2WR.js";import{A as D}from"./arrow-left-BpPEBvVt.js";import{P as S}from"./play-ps1v3QHM.js";import{C as be,a as we}from"./clipboard-Xdr0FfgD.js";import{R as ye}from"./refresh-cw-DZmqHMC0.js";import{P as Ce}from"./pause-FjNAOibm.js";import{C as V}from"./clock-BkRDj1VL.js";import{C as Se}from"./calendar-Ck6-s6Vl.js";const Ae=[{id:"claude",label:"Claude Code"},{id:"gemini",label:"Google Gemini"},{id:"codex",label:"OpenAI Codex"},{id:"droid",label:"Factory Droid"}],f=a=>{if(!a)return"—";try{return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(a))}catch{return a}},$=a=>{if(!a)return"—";const i=new Date(a).getTime()-Date.now(),l=Math.round(i/(1e3*60));if(Number.isNaN(l))return f(a);if(Math.abs(l)<1)return"now";if(l>0){if(l<60)return`in ${l}m`;const h=Math.round(l/60);return h<24?`in ${h}h`:`in ${Math.round(h/24)}d`}const t=Math.abs(l);if(t<60)return`${t}m ago`;const u=Math.round(t/60);return u<24?`${u}h ago`:`${Math.round(u/24)}d ago`},ke=a=>{if(a.type==="interval"){const x=a.daysOfWeek.map(i=>i.slice(0,3).toUpperCase()).join(", ");return`Every ${a.hours}h (${x||"All days"})`}return a.description||`Cron: ${a.expression}`},Re=a=>{const x=Ae.find(i=>i.id===a);return x?x.label:a},L=a=>{switch(a){case"active":case"succeeded":return"default";case"paused":case"running":return"secondary";case"failed":return"destructive";default:return"outline"}};function Me(){const{id:a}=se(),x=te(),{toast:i}=ae(),{refresh:l}=re(),[t,u]=d.useState(null),[T,h]=d.useState(!0),[y,E]=d.useState(null),[P,F]=d.useState(!1),[A,J]=d.useState(!1),[p,U]=d.useState(!1),[W,_]=d.useState(!1),[q,Q]=d.useState(new Set),[B,k]=d.useState({}),[Y,M]=d.useState(new Set),R=async()=>{if(a)try{h(!0);const r=await(await fetch(`${v}/api/v1/jobs/${a}`)).json();r.success?u(r.data):E(r.error?.message||"Failed to fetch job")}catch(s){E(s instanceof Error?s.message:"Unknown error")}finally{h(!1)}};d.useEffect(()=>{R()},[a]);const Z=async()=>{if(a){F(!0);try{const r=await(await fetch(`${v}/api/v1/jobs/${a}`,{method:"DELETE"})).json();r.success?(i({title:"Job deleted",description:t?.name||"Scheduled job has been deleted"}),x("/schedule")):i({title:"Failed to delete job",description:r.error?.message||"Unknown error",variant:"destructive"})}catch(s){i({title:"Failed to delete job",description:s instanceof Error?s.message:"Unknown error",variant:"destructive"})}finally{F(!1)}}},K=async()=>{if(!t||!a)return;J(!0);const s=t.status==="active"?"paused":"active";try{const n=await(await fetch(`${v}/api/v1/jobs/${a}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:s})})).json();n.success?(u(n.data),await l(),i({title:s==="active"?"Job resumed":"Job paused",description:t.name})):i({title:"Failed to update job",description:n.error?.message||"Unknown error",variant:"destructive"})}catch(r){i({title:"Failed to update job",description:r instanceof Error?r.message:"Unknown error",variant:"destructive"})}finally{J(!1)}},z=async()=>{if(!(!t||!a)){U(!0);try{const s=await fetch(`${v}/api/v1/jobs/${a}/run`,{method:"POST"}),r=await s.json();r.success||s.ok?(i({title:"Run started",description:`${t.name} is executing.`}),await R(),await l()):i({title:"Failed to start run",description:r.error?.message||"Unknown error",variant:"destructive"})}catch(s){i({title:"Failed to start run",description:s instanceof Error?s.message:"Unknown error",variant:"destructive"})}finally{U(!1)}}},X=async s=>{Q(r=>{const n=new Set(r);return n.has(s)?n.delete(s):(n.add(s),!B[s]&&a&&ee(s)),n})},ee=async s=>{if(a){M(r=>new Set(r).add(s));try{const r=await fetch(`${v}/api/v1/jobs/${a}/runs/${s}/log`);if(r.ok){const n=await r.text();k(j=>({...j,[s]:n}))}else{const n=await r.json().catch(()=>({}));k(j=>({...j,[s]:n.error?.message||"Log not available"}))}}catch(r){k(n=>({...n,[s]:r instanceof Error?r.message:"Failed to load log"}))}finally{M(r=>{const n=new Set(r);return n.delete(s),n})}}};if(T)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-3/4 animate-pulse"}),e.jsx(c,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(N,{to:"/schedule",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})})]}),e.jsxs(o,{children:[e.jsx(g,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-3/4 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-1/2 animate-pulse"})]})}),e.jsx(m,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-4 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-5/6 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-4/6 animate-pulse"})]})})]})]});if(y||!t)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:y||"Job not found"})}),e.jsx(c,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(N,{to:"/schedule",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})})]}),e.jsx(o,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-destructive",children:y||"Job not found"}),e.jsxs("p",{className:"text-muted-foreground mt-2",children:['The job with ID "',a,'" could not be found.']}),e.jsx(c,{asChild:!0,className:"mt-4",children:e.jsx(N,{to:"/schedule",children:"Back to Schedule"})})]})})})]});const I=t.agentIds||(t.agentId?[t.agentId]:[]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight min-w-0",children:t.name}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(c,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(N,{to:"/schedule",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(D,{className:"h-4 w-4"})})}),e.jsxs(c,{variant:"default",size:"sm",onClick:z,disabled:p||!!t._error,children:[p?e.jsx(C,{className:"h-4 w-4 animate-spin sm:mr-2"}):e.jsx(S,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:p?"Running...":"Run Now"})]}),e.jsxs(ne,{children:[e.jsx(ie,{asChild:!0,children:e.jsxs(c,{variant:"destructive",size:"sm",disabled:P,children:[e.jsx(de,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:P?"Deleting...":"Delete"})]})}),e.jsxs(le,{children:[e.jsxs(ce,{children:[e.jsx(oe,{children:"Are you absolutely sure?"}),e.jsxs(me,{children:["This action cannot be undone. This will permanently delete the scheduled job",e.jsxs("span",{className:"font-semibold",children:[' "',t.name,'"']}),". Existing run logs will remain in ",e.jsx("code",{children:".nut/jobs/logs"}),"."]})]}),e.jsxs(xe,{children:[e.jsx(ue,{children:"Cancel"}),e.jsx(he,{onClick:Z,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Job"})]})]})]})]})]}),e.jsxs("button",{type:"button",onClick:async()=>{const s=`.nut/jobs/job-${t.id}.md`;try{await ve(s),_(!0),i({title:"Copied!",description:`${s} copied to clipboard`}),setTimeout(()=>_(!1),2e3)}catch(r){console.error("Failed to copy path:",r),i({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})}},className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors font-mono",children:[e.jsx("span",{children:`.nut/jobs/job-${t.id}.md`}),W?e.jsx(be,{className:"h-3.5 w-3.5"}):e.jsx(we,{className:"h-3.5 w-3.5"})]})]}),t._error&&e.jsx(o,{className:"border-destructive/50 bg-destructive/5",children:e.jsxs(m,{className:"pt-6",children:[e.jsx("p",{className:"text-sm text-destructive font-medium",children:t._error}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Please review the job file at ",e.jsxs("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:[".nut/jobs/job-",t.id,".md"]})]})]})}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(o,{children:[e.jsxs(g,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(b,{children:"Job Configuration"}),e.jsx(w,{variant:L(t.status),className:"capitalize",children:t.status})]}),t.description&&e.jsx(G,{children:t.description})]}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-2",children:"Instructions"}),e.jsx("div",{className:"rounded-md bg-muted/50 p-3 font-mono text-sm whitespace-pre-wrap",children:t.prompt})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-1",children:"AI Model"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:Re(t.model)})]})]}),I.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-1",children:"Custom Agents"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:I.map(s=>e.jsxs("div",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800 text-xs",children:[e.jsx(H,{className:"h-3 w-3 text-blue-600 dark:text-blue-400"}),e.jsx("span",{className:"font-medium text-blue-900 dark:text-blue-100",children:s.replace(".md","")})]},s))})]}),t.mcpServers&&t.mcpServers.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-muted-foreground mb-1",children:"MCP Servers"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.mcpServers.map(s=>e.jsxs("div",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-purple-50 dark:bg-purple-950/20 border border-purple-200 dark:border-purple-800 text-xs",children:[e.jsx(pe,{className:"h-3 w-3 text-purple-600 dark:text-purple-400"}),e.jsx("span",{className:"font-medium text-purple-900 dark:text-purple-100",children:s})]},s))})]})]})]})]}),e.jsxs(o,{children:[e.jsx(g,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(b,{children:"Run History"}),e.jsxs(G,{children:[t.runs.length," recorded run",t.runs.length!==1?"s":""]})]}),e.jsxs(c,{variant:"outline",size:"sm",onClick:R,children:[e.jsx(ye,{className:"h-4 w-4 mr-2"}),"Refresh"]})]})}),e.jsx(m,{children:t.runs.length===0?e.jsx("div",{className:"rounded-md border border-dashed bg-muted/20 p-6 text-center text-sm text-muted-foreground",children:'No runs yet. Click "Run Now" to execute this job.'}):e.jsx("div",{className:"space-y-3",children:t.runs.map(s=>{const r=q.has(s.id),n=Y.has(s.id),j=B[s.id];return e.jsxs("div",{className:"rounded-md border bg-card/50 overflow-hidden",children:[e.jsxs("div",{className:"p-3 cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>X(s.id),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx(w,{variant:L(s.status),className:"capitalize text-xs",children:s.status}),e.jsx("span",{className:"text-sm text-muted-foreground",children:f(s.startedAt)}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",$(s.startedAt),")"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.trigger==="manual"&&e.jsx(w,{variant:"outline",className:"text-xs",children:"manual"}),r?e.jsx(je,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(ge,{className:"h-4 w-4 text-muted-foreground"})]})]}),s.error&&e.jsx("p",{className:"text-sm text-destructive font-medium mb-2",children:s.error}),s.summary&&!r&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:s.summary})]}),r&&e.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t bg-muted/20",children:[e.jsxs("div",{className:"pt-3 grid gap-2 text-xs",children:[s.finishedAt&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Finished:"}),e.jsx("span",{children:f(s.finishedAt)})]}),s.cliCommand&&e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Command:"}),e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded text-xs break-all",children:s.cliCommand})]}),s.outputPath&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Log path:"}),e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded text-xs",children:s.outputPath})]})]}),s.summary&&e.jsxs("div",{children:[e.jsx("h5",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Summary"}),e.jsx("div",{className:"rounded bg-muted/50 p-2 font-mono text-xs leading-relaxed whitespace-pre-wrap",children:s.summary})]}),e.jsxs("div",{children:[e.jsxs("h5",{className:"text-xs font-medium text-muted-foreground mb-1 flex items-center gap-1.5",children:[e.jsx(fe,{className:"h-3 w-3"}),"Full Log"]}),n?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground p-2",children:[e.jsx(C,{className:"h-3 w-3 animate-spin"}),"Loading log..."]}):j?e.jsx("div",{className:"rounded bg-muted/50 p-2 font-mono text-xs leading-relaxed max-h-96 overflow-auto whitespace-pre-wrap",children:j}):e.jsx("div",{className:"text-xs text-muted-foreground p-2",children:"Log not available"})]})]})]},s.id)})})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(o,{children:[e.jsx(g,{children:e.jsx(b,{children:"Actions"})}),e.jsxs(m,{className:"space-y-2",children:[e.jsxs(c,{variant:"default",className:"w-full justify-start",onClick:z,disabled:p||!!t._error,children:[p?e.jsx(C,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(S,{className:"h-4 w-4 mr-2"}),p?"Running...":"Run Now"]}),e.jsxs(c,{variant:"outline",className:"w-full justify-start",onClick:K,disabled:A||!!t._error,children:[A?e.jsx(C,{className:"h-4 w-4 mr-2 animate-spin"}):t.status==="active"?e.jsx(Ce,{className:"h-4 w-4 mr-2"}):e.jsx(S,{className:"h-4 w-4 mr-2"}),A?"Updating...":t.status==="active"?"Pause Job":"Resume Job"]}),e.jsx(c,{variant:"outline",className:"w-full justify-start",asChild:!0,disabled:!!t._error,children:e.jsxs(N,{to:"/schedule",state:{editJobId:t.id},children:[e.jsx(Ne,{className:"h-4 w-4 mr-2"}),"Edit Job"]})})]})]}),e.jsxs(o,{children:[e.jsx(g,{children:e.jsx(b,{children:"Schedule"})}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(V,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:ke(t.schedule)})]}),t.schedule.type==="interval"&&t.schedule.anchorHour!==void 0&&e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Start hour:"})," ",e.jsxs("span",{children:[t.schedule.anchorHour,":00"]})]}),e.jsx(O,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Next run:"}),e.jsx("span",{className:"font-medium",children:$(t.metadata.nextRunAt)})]}),t.metadata.nextRunAt&&e.jsx("div",{className:"text-xs text-muted-foreground",children:f(t.metadata.nextRunAt)})]})]})]}),e.jsxs(o,{children:[e.jsx(g,{children:e.jsx(b,{children:"Information"})}),e.jsxs(m,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Se,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Created:"}),e.jsx("span",{children:f(t.metadata.createdAt)})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(V,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Updated:"}),e.jsx("span",{children:f(t.metadata.updatedAt)})]}),t.metadata.lastRunAt&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(S,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:"Last run:"}),e.jsx("span",{children:$(t.metadata.lastRunAt)})]}),e.jsx(O,{}),e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Status:"}),e.jsx("div",{className:"mt-1",children:e.jsx(w,{variant:L(t.status),className:"capitalize",children:t.status})})]}),t.tags&&t.tags.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:"Tags:"}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:t.tags.map(s=>e.jsx(w,{variant:"outline",className:"text-xs",children:s},s))})]})]})]})]})]})]})}export{Me as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as A,u as T,a as $,r as i,A as p,j as e,H as g,B as o,L as x,M as F,Q as L,R as S,U as P,V as z,W as B,Y as K,Z as U,_,$ as H,a0 as M,a1 as R,al as W,am as q,a2 as I}from"./index-
|
|
1
|
+
import{P as A,u as T,a as $,r as i,A as p,j as e,H as g,B as o,L as x,M as F,Q as L,R as S,U as P,V as z,W as B,Y as K,Z as U,_,$ as H,a0 as M,a1 as R,al as W,am as q,a2 as I}from"./index-DLvo1sdI.js";import{C as d,a as m,b as V,c as Q}from"./card-B1BNEOKA.js";import{B as Y}from"./badge-B59i_2WR.js";import{c as Z}from"./clipboard-B9ndUJKl.js";import{A as j}from"./arrow-left-BpPEBvVt.js";import{C as G}from"./calendar-Ck6-s6Vl.js";import{T as J}from"./tag-CGdHqvLW.js";import{E as O}from"./external-link-C34deyLk.js";function X(n){return typeof n=="string"?n.startsWith("http://")||n.startsWith("https://")?{title:n,url:n}:{title:n}:n}function oe(){const n=A(),v=T(),{toast:r}=$(),l=n.filename,[t,w]=i.useState(null),[N,k]=i.useState(!0),[h,u]=i.useState(!1),[y,f]=i.useState(!1);i.useEffect(()=>{l&&C()},[l]);const C=async()=>{try{const a=await(await fetch(`${p}/api/v1/context/knowledge/${l}`)).json();a.success?w(a.document):r({title:"Error",description:"Failed to load knowledge document",variant:"destructive"})}catch(s){console.error("Error fetching document:",s),r({title:"Error",description:"Failed to load knowledge document",variant:"destructive"})}finally{k(!1)}},D=async()=>{if(!t)return;const s=`.nut/context/knowledge/${t.filename}`;try{await Z(s),f(!0),setTimeout(()=>f(!1),2e3),r({title:"Copied!",description:`Path copied to clipboard: ${s}`})}catch(a){console.error("Failed to copy path:",a),r({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},b=()=>{if(!t)return;const s=new CustomEvent("discuss-in-chat",{detail:{type:"knowledge",id:`knowledge-${t.filename.replace(".md","")}`,filename:t.filename,name:t.filename,path:`.nut/context/knowledge/${t.filename}`}});window.dispatchEvent(s)},E=async()=>{if(t){u(!0);try{const a=await(await fetch(`${p}/api/v1/context/knowledge/${l}`,{method:"DELETE"})).json();a.success?(r({title:"Success",description:"Knowledge document deleted successfully"}),v("/context/knowledge")):r({title:"Error",description:a.error||"Failed to delete knowledge document",variant:"destructive"})}catch(s){console.error("Error deleting document:",s),r({title:"Error",description:"Failed to delete knowledge document",variant:"destructive"})}finally{u(!1)}}};return N?e.jsx("div",{className:"space-y-6",children:e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(g,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading knowledge document..."})]})})})}):t?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight min-w-0",children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(o,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(x,{to:"/context/knowledge",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(j,{className:"h-4 w-4"})})}),e.jsxs(o,{variant:"outline",size:"sm",onClick:b,children:[e.jsx(F,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Discuss"})]}),e.jsx(o,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(x,{to:`/context/knowledge/${l}/edit`,children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})}),e.jsxs(S,{children:[e.jsx(P,{asChild:!0,children:e.jsxs(o,{variant:"destructive",size:"sm",children:[e.jsx(z,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Delete"})]})}),e.jsxs(B,{children:[e.jsxs(K,{children:[e.jsx(U,{children:"Delete Knowledge Document"}),e.jsxs(_,{children:["Are you sure you want to delete “",t.title,"”? This action cannot be undone."]})]}),e.jsxs(H,{children:[e.jsx(M,{children:"Cancel"}),e.jsx(R,{onClick:E,disabled:h,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:h?e.jsx(g,{className:"w-4 h-4 animate-spin"}):"Delete"})]})]})]})]})]}),e.jsx("div",{className:"text-left",children:e.jsxs("button",{type:"button",onClick:D,className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors font-mono text-left",children:[e.jsxs("span",{className:"break-all",children:[".nut/context/knowledge/",t.filename]}),y?e.jsx(W,{className:"h-3.5 w-3.5 flex-shrink-0 text-green-600"}):e.jsx(q,{className:"h-3.5 w-3.5 flex-shrink-0"})]})})]}),e.jsxs("div",{className:"flex flex-col gap-2 text-sm text-muted-foreground sm:flex-row sm:flex-wrap sm:items-center sm:gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(G,{className:"w-3.5 h-3.5 flex-shrink-0"}),e.jsxs("span",{children:["Updated ",t.metadata.updated]})]}),t.metadata.tags&&t.metadata.tags.length>0&&e.jsxs("div",{className:"flex items-start gap-1.5 sm:items-center",children:[e.jsx(J,{className:"w-3.5 h-3.5 flex-shrink-0 mt-0.5 sm:mt-0"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:t.metadata.tags.map((s,a)=>e.jsx(Y,{variant:"outline",className:"text-xs",children:s},a))})]})]}),t.metadata.sources&&t.metadata.sources.length>0&&e.jsxs(d,{children:[e.jsx(V,{children:e.jsx(Q,{children:"Sources"})}),e.jsx(m,{children:e.jsx("ul",{className:"space-y-2",children:t.metadata.sources.map((s,a)=>{const c=X(s);return e.jsx("li",{children:c.url?e.jsxs("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 text-foreground hover:text-primary transition-colors group",children:[e.jsx("span",{className:"group-hover:underline",children:c.title}),e.jsx(O,{className:"w-3.5 h-3.5 text-muted-foreground group-hover:text-primary flex-shrink-0"})]}):e.jsx("span",{className:"text-muted-foreground",children:c.title})},a)})})})]}),e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsx(I,{children:t.content})})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("div",{children:e.jsx("h3",{className:"text-lg font-semibold",children:"Knowledge Document Not Found"})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(o,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(x,{to:"/context/knowledge",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(j,{className:"h-4 w-4"})})})})]}),e.jsx(d,{children:e.jsx(m,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Knowledge Document Not Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"The requested knowledge document could not be found."})]})})})]})}export{oe as default};
|