@cuongtran001/kanna 1.55.2 → 1.55.3
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/client/assets/{ChatPage-APGyM5Xo.js → ChatPage-BguvIH75.js} +1 -1
- package/dist/client/assets/{CronJobRow-tm98WvM8.js → CronJobRow-D5Fc3w-1.js} +1 -1
- package/dist/client/assets/{CronJobsPage-CY5XOuBx.js → CronJobsPage-CHnOjPlF.js} +1 -1
- package/dist/client/assets/{KannaSocketProvider-DJv2gp2E.js → KannaSocketProvider-Owmp4hPQ.js} +1 -1
- package/dist/client/assets/{LocalProjectsPage-HkyhcYMu.js → LocalProjectsPage-DYh4KysM.js} +1 -1
- package/dist/client/assets/{SettingsPage-Ch6NeRlN.js → SettingsPage-CQXiRzcn.js} +1 -1
- package/dist/client/assets/{auth-BoU4Sy16.js → auth-krfVizJR.js} +1 -1
- package/dist/client/assets/{branding-CaxlVtaJ.js → branding-VdNGihTK.js} +1 -1
- package/dist/client/assets/{editor-icons-DRUxmX7g.js → editor-icons-DYs-KAON.js} +1 -1
- package/dist/client/assets/{index-Db52i58i.js → index-C3jqNeUp.js} +3 -3
- package/dist/client/assets/{pushClient-BGXuPFFh.js → pushClient--9ISlWCZ.js} +1 -1
- package/dist/client/assets/{useKannaState-DVfdppcs.js → useKannaState-CJS9H9V_.js} +1 -1
- package/dist/client/index.html +6 -6
- package/package.json +1 -1
- package/src/server/agent.test.ts +8 -1
- package/src/server/claude-harness-stream.test.ts +20 -0
- package/src/server/claude-harness-stream.ts +4 -1
- package/src/server/claude-send-command.test.ts +27 -1
- package/src/server/claude-send-command.ts +7 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-CQOZoUwg.js";import{E as n,L as r,O as i,j as a}from"./chatFocusPolicy-D5WAGQzz.js";import{t as o}from"./jsx-runtime-DREnUpxT.js";import{n as s,s as c}from"./KannaSocketProvider-DJv2gp2E.js";import{t as l}from"./external-link-COo-Uzb1.js";import{l as u,n as d,t as f}from"./statusLabel-1tgAYyyt.js";import{_ as p,a as m,d as h,i as g,n as _,o as v,r as y,s as b,t as x}from"./timer.adapter-CcS8xEBd.js";import{t as ee}from"./input-DLIzWZj4.js";import{s as te}from"./branding-CaxlVtaJ.js";import{l as ne,u as S}from"./pushClient-BGXuPFFh.js";import{a as C}from"./formatters-wSVyvDFZ.js";import{r as w,t as re}from"./formatDuration-BbWTR_M_.js";import{n as ie}from"./state-mark-DyvaV7zQ.js";var T={name:`pause`,size:24,node:[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]};T.node;var ae=a(T),E={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};E.node;var D=a(E),O=e(o(),1),k=e(t(),1),A={timer:x};function j(e=1e3,t){let{timer:n}=t??A,[r,i]=(0,k.useState)(()=>Date.now()),a=(0,k.useRef)(e);return(0,k.useLayoutEffect)(()=>{a.current=e}),(0,k.useEffect)(()=>{let e=n.setInterval(()=>{i(Date.now())},a.current);return()=>n.clearInterval(e)},[n]),r}function M(e){return e===`inline`?`runs in this chat, context cleared each cycle`:`a new chat per run`}var N=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`];function P(e,t){if(e.type===`interval`)return F(e.ms);let{second:n,minute:r,hour:i,dom:a,month:o,dow:s}=e;if(o.kind!==`any`)return t;let c=a.kind===`any`&&s.kind===`any`;if(n!==void 0&&r.kind===`any`&&i.kind===`any`&&c){if(n.kind===`any`)return`every second`;let e=oe(n.values);if(e!==null)return e===1?`every second`:`every ${e} seconds`;if(n.values.length>1)return t}let l=n===void 0?0:I(n);if(l===null)return t;let u=l===0?``:`:${L(l)}`,d=I(r),f=I(i);if(r.kind===`any`&&i.kind===`any`&&c)return l===0?`every minute`:`every minute at :${L(l)}`;if(d!==null&&i.kind===`any`&&c)return`hourly at :${L(d)}${u}`;if(d!==null&&f!==null){let e=`${L(f)}:${L(d)}${u}`;if(c)return`daily at ${e}`;if(a.kind===`any`&&s.kind===`values`)return`every ${s.values.map(e=>N[e]).join(`, `)} at ${e}`;if(s.kind===`any`&&a.kind===`values`&&a.values.length===1)return`on day ${a.values[0]} of each month at ${e}`}return t}function F(e){let t=Math.round(e/1e3);if(t%3600==0){let e=t/3600;return e===1?`every hour`:`every ${e} hours`}if(t%60==0){let e=t/60;return e===1?`every minute`:`every ${e} minutes`}return t===1?`every second`:`every ${t} seconds`}function I(e){return e.kind===`values`&&e.values.length===1?e.values[0]:null}function oe(e){if(e.length<2||e[0]!==0)return null;let t=e[1];if(t<1||60%t!=0||e.length!==60/t)return null;for(let n=1;n<e.length;n++)if(e[n]!==n*t)return null;return t}function L(e){return String(e).padStart(2,`0`)}function se({message:e,cronJobs:t}){let n=(t?.find(t=>t.jobId===e.jobId))?.recentRuns.find(t=>t.runId===e.runId)?.status??`running`;return(0,O.jsxs)(`div`,{className:`px-0.5`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(c,{className:`h-4 w-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:`Cron run`}),(0,O.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.jobId}),(0,O.jsxs)(`span`,{className:`ml-auto flex items-center gap-3`,children:[(0,O.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:C(e.firedAt)}),(0,O.jsx)(R,{status:n})]})]}),(0,O.jsx)(`p`,{className:`mt-1.5 text-sm text-foreground/90`,children:e.instruction}),e.spawnedChatId?(0,O.jsxs)(r,{to:`/chat/${e.spawnedChatId}`,className:`mt-2 inline-flex items-center gap-1.5 text-xs font-medium text-primary hover:underline`,children:[(0,O.jsx)(l,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),`Open run chat`]}):null]})}function R({status:e}){return(0,O.jsx)(ie,{tone:d(e),label:f(e)})}function z(){return(0,O.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-border bg-muted/40 px-2 py-0.5 text-xs font-medium text-muted-foreground`,children:[(0,O.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-muted-foreground`}),`Paused`]})}function B(e){for(let t of e.recentRuns)if(t.status!==`skipped`)return t.status===`running`;return!1}var V={"@hourly":`0 * * * *`,"@daily":`0 0 * * *`,"@weekly":`0 0 * * 0`,"@monthly":`0 0 1 * *`},H=Object.keys(V),U=[{name:`minute`,min:0,max:59},{name:`hour`,min:0,max:23},{name:`day-of-month`,min:1,max:31},{name:`month`,min:1,max:12,names:{jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12}},{name:`day-of-week`,min:0,max:7,names:{sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6},normalize:e=>e===7?0:e}],W={name:`second`,min:0,max:59},G={s:1e3,m:6e4,h:36e5};function ce(e){let t=e.trim();if(t===``)return{ok:!1,part:`schedule`,message:"missing schedule — expected 5- or 6-field cron, @shortcut, or `every <N>s|m|h`"};let n=t.split(/\s+/);return n[0].startsWith(`@`)?le(n):n[0].toLowerCase()===`every`?de(n):K(n)}function le(e){let t=e[0].toLowerCase(),n=V[t];if(n===void 0){let n=ue(t);return{ok:!1,part:`schedule`,message:`unknown shortcut "${e[0]}" — valid shortcuts are ${H.join(`, `)}`,correctedSchedule:n??void 0}}if(e.length>1)return{ok:!1,part:`schedule`,message:`${t} takes no extra tokens (got "${e.slice(1).join(` `)}")`,correctedSchedule:t};let r=K(n.split(` `));if(!r.ok)throw Error(`builtin shortcut ${t} failed to parse: ${r.message}`);return r}function ue(e){let t=null,n=4;for(let r of H){let i=Y(e,r,n);i<n&&(t=r,n=i)}return t}function de(e){if(e.length===1)return{ok:!1,part:`schedule`,message:"missing interval after `every` — expected e.g. `every 30s`, `every 5m`, or `every 2h`"};let t=e.length===3?e[1]+e[2]:e[1];if(e.length>3||e.length===3&&!fe(t))return{ok:!1,part:`schedule`,message:`expected exactly \`every <N>s|m|h\`, got "${e.join(` `)}"`};let n=/^(\d+)(s|m|h)$/.exec(t);if(n){let r=Number.parseInt(n[1],10);if(r<1)return{ok:!1,part:`schedule`,message:`interval must be at least 1`,correctedSchedule:`every 1${n[2]}`};let i=G[n[2]],a=e.length===3?`every ${t}`:void 0;return a===void 0?{ok:!0,schedule:{type:`interval`,ms:r*i}}:{ok:!1,part:`schedule`,message:`interval "${e.slice(1).join(` `)}" has a stray space`,correctedSchedule:a}}let r=/^(\d+)\s*(min|mins|minute|minutes|m|hr|hrs|hour|hours|h|s|sec|secs|second|seconds|d|day|days)$/i.exec(t);if(r){let e=r[1],t=r[2].toLowerCase();if(t.startsWith(`d`))return{ok:!1,part:`schedule`,message:`use @daily instead of "every ${e}${t}"`,correctedSchedule:`@daily`};let n=t[0];return{ok:!1,part:`schedule`,message:`interval unit "${t}" is not valid — use \`s\`, \`m\`, or \`h\``,correctedSchedule:`every ${e}${n}`}}return{ok:!1,part:`schedule`,message:`interval "${t}" is not valid — expected e.g. \`every 30s\`, \`every 5m\`, or \`every 2h\``}}function fe(e){return/^\d+\s*[a-z]+$/i.test(e)}function K(e){let t=e.length===6;if(e.length!==5&&!t){let t=e.length===1&&/^\d+(s|m|h)$/.test(e[0]);return{ok:!1,part:`schedule`,message:`cron schedule has ${e.length} field${e.length===1?``:`s`}, expected 5 (minute hour day-of-month month day-of-week) or 6 with a leading second`,correctedSchedule:t?`every ${e[0]}`:pe(e)}}let n=t?[W,...U]:U,r=[];for(let t=0;t<n.length;t++){let i=me(n[t],e[t]);if(!i.ok)return{ok:!1,part:`schedule_field`,message:i.message};r.push(i.field)}let i=+!!t;return{ok:!0,schedule:{type:`cron`,expression:e.join(` `),...t?{second:r[0]}:{},minute:r[i],hour:r[i+1],dom:r[i+2],month:r[i+3],dow:r[i+4]}}}function pe(e){if(e.length>=2&&e.length<=4){let t=[...e,...Array(5-e.length).fill(`*`)];return K(t).ok?t.join(` `):void 0}if(e.length===7){let t=e.slice(0,6);return K(t).ok?t.join(` `):void 0}}function me(e,t){if(t===`*`)return{ok:!0,field:{kind:`any`}};let n=new Set;for(let r of t.split(`,`)){if(r===``)return{ok:!1,message:`${e.name} field "${t}" has an empty list entry`};let i=/^(\*|[A-Za-z]+|\d+)(?:-([A-Za-z]+|\d+))?(?:\/(\d+))?$/.exec(r);if(!i)return{ok:!1,message:`${e.name} field "${r}" is not valid — expected \`*\`, \`N\`, \`N-M\`, \`*/S\`, or \`N-M/S\``};let[,a,o,s]=i,c,l;if(a===`*`){if(o!==void 0)return{ok:!1,message:`${e.name} field "${r}" is not valid — \`*\` cannot be a range start`};c=e.min,l=e.max}else{let t=q(e,a);if(t===null)return{ok:!1,message:J(e,a)};if(c=t,o!==void 0){let t=q(e,o);if(t===null)return{ok:!1,message:J(e,o)};l=t}else l=c}if(c<e.min||c>e.max||l<e.min||l>e.max)return{ok:!1,message:`${e.name} field "${r}" is out of range ${e.min}-${e.max}`};if(l<c)return{ok:!1,message:`${e.name} field "${r}" has a range end below its start`};let u=1;if(s!==void 0){if(u=Number.parseInt(s,10),u<1)return{ok:!1,message:`${e.name} field "${r}" has a step of 0 — steps start at 1`};if(a!==`*`&&o===void 0)return{ok:!1,message:`${e.name} field "${r}" applies a step to a single value — use \`*/S\` or \`N-M/S\``}}for(let t=c;t<=l;t+=u)n.add(e.normalize?e.normalize(t):t)}return{ok:!0,field:{kind:`values`,values:[...n].sort((e,t)=>e-t)}}}function q(e,t){return/^\d+$/.test(t)?Number.parseInt(t,10):e.names?.[t.toLowerCase()]??null}function J(e,t){return/^\d+$/.test(t)?`${e.name} field "${t}" is out of range ${e.min}-${e.max}`:e.names?`${e.name} field "${t}" is not a valid ${e.name} name (${Object.keys(e.names).join(`, `)})`:`${e.name} field "${t}" is not a number`}function Y(e,t,n){if(Math.abs(e.length-t.length)>n)return n+1;let r=Array.from({length:t.length+1},(e,t)=>t);for(let i=1;i<=e.length;i++){let a=[i],o=i;for(let n=1;n<=t.length;n++){let s=e[i-1]===t[n-1]?0:1,c=Math.min(r[n]+1,a[n-1]+1,r[n-1]+s);a.push(c),c<o&&(o=c)}if(o>n)return n+1;r=a}return r[t.length]}var X=_(`CronJobEditDialog`,e=>t=>({instruction:e.instruction,scheduleText:e.scheduleText,mode:e.mode,setInstruction:e=>t({instruction:e}),setScheduleText:e=>t({scheduleText:e}),setMode:e=>t({mode:e})})),he=[{value:`inline`,label:`inline`},{value:`spawn`,label:`spawn`}];function ge({job:e,open:t,onOpenChange:r,onSave:i}){let a=X.useScopedStore(e=>e.instruction),o=X.useScopedStore(e=>e.scheduleText),s=X.useScopedStore(e=>e.mode),c=X.useScopedStore(e=>e.setInstruction),l=X.useScopedStore(e=>e.setScheduleText),u=X.useScopedStore(e=>e.setMode),d=(0,k.useMemo)(()=>ce(o.trim()),[o]),f=(0,k.useMemo)(()=>{let t={},n=a.trim();n&&n!==e.instruction&&(t.instruction=n),s!==e.mode&&(t.mode=s);let r=o.trim();return d.ok&&r!==e.scheduleText&&(t.schedule=d.schedule,t.scheduleText=r),t},[a,e.instruction,e.mode,e.scheduleText,s,d,o]),p=a.trim().length===0,_=!p&&d.ok&&Object.keys(f).length>0,x=(0,k.useCallback)(()=>{d.ok||d.correctedSchedule===void 0||l(d.correctedSchedule)},[d,l]),S=(0,k.useCallback)(()=>{_&&(i(f),r(!1))},[_,r,i,f]),C=(0,k.useCallback)(()=>{r(!1)},[r]);return(0,O.jsx)(y,{open:t,onOpenChange:r,children:(0,O.jsxs)(m,{size:`lg`,children:[(0,O.jsxs)(g,{className:`space-y-4`,children:[(0,O.jsx)(h,{children:`Edit cron job`}),(0,O.jsxs)(v,{children:[(0,O.jsx)(`span`,{className:`font-mono`,children:e.jobId}),` — saving re-arms the job, which clears its run history and resets its created age.`]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`cron-edit-instruction`,className:`text-sm font-medium text-foreground`,children:`Instruction`}),(0,O.jsx)(ne,{id:`cron-edit-instruction`,rows:4,value:a,onChange:e=>c(e.target.value)}),p?(0,O.jsx)(`p`,{className:`text-xs text-destructive`,children:`An instruction is required.`}):null]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`cron-edit-schedule`,className:`text-sm font-medium text-foreground`,children:`Schedule`}),(0,O.jsx)(ee,{id:`cron-edit-schedule`,value:o,onChange:e=>l(e.target.value),placeholder:`0 9 * * 1, @daily, or every 5m`,className:`font-mono`}),d.ok?(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:P(d.schedule,o.trim())}):(0,O.jsx)(`p`,{className:`text-xs text-destructive`,children:d.message}),!d.ok&&d.correctedSchedule!==void 0?(0,O.jsxs)(n,{variant:`secondary`,size:`sm`,onClick:x,children:[`Use `,(0,O.jsx)(`span`,{className:`ml-1 font-mono`,children:d.correctedSchedule})]}):null]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:`Mode`}),(0,O.jsx)(te,{value:s,onValueChange:u,options:he,size:`sm`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:M(s)})]})]}),(0,O.jsxs)(b,{children:[(0,O.jsx)(n,{variant:`ghost`,size:`sm`,onClick:C,children:`Cancel`}),(0,O.jsx)(n,{size:`sm`,onClick:S,disabled:!_,children:`Save`})]})]})})}function _e(e){return(0,O.jsx)(X.Provider,{init:e.job,children:(0,O.jsx)(ge,{...e})})}var Z=_(`CronJobRow`,()=>e=>({editing:!1,openEditor:()=>e({editing:!0}),setEditing:t=>e({editing:t})})),Q=`rounded-md p-1.5 text-muted-foreground hover:bg-muted/40 hover:text-foreground`,$=`cannot edit while a run is in flight`;function ve({job:e,chatId:t,trailing:n,divider:r}){let a=j(1e3),o=s(),c=Z.useScopedStore(e=>e.editing),l=Z.useScopedStore(e=>e.openEditor),d=Z.useScopedStore(e=>e.setEditing),f=(0,k.useCallback)(e=>{o?.command(e).catch(()=>{})},[o]),m=(0,k.useCallback)(()=>{f({type:`cron.pause`,chatId:t,jobId:e.jobId})},[t,e.jobId,f]),h=(0,k.useCallback)(()=>{f({type:`cron.resume`,chatId:t,jobId:e.jobId})},[t,e.jobId,f]),g=(0,k.useCallback)(()=>{f({type:`cron.remove`,chatId:t,jobId:e.jobId})},[t,e.jobId,f]),_=(0,k.useCallback)(()=>{B(e)||l()},[e,l]),v=(0,k.useCallback)(n=>{o?.command({type:`cron.update`,chatId:t,jobId:e.jobId,patch:n}).catch(()=>{})},[t,e.jobId,o]),y=a-e.armedAt,b=e.lastRun?.status===`running`?e.lastRun:null,x=B(e);return(0,O.jsxs)(`div`,{className:i(`flex items-center gap-3 bg-background px-4 py-2.5`,r&&`border-b border-border`),children:[(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`truncate text-sm text-foreground`,children:e.instruction}),e.paused?(0,O.jsx)(z,{}):null,!e.paused&&e.lastRun?(0,O.jsx)(R,{status:e.lastRun.status}):null]}),(0,O.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,children:[(0,O.jsx)(`span`,{className:`font-mono`,children:e.jobId}),(0,O.jsx)(`span`,{children:P(e.schedule,e.scheduleText)}),(0,O.jsxs)(`span`,{children:[`· `,e.mode]}),e.model?(0,O.jsx)(`span`,{className:`font-mono`,children:e.model}):null,(0,O.jsx)(S,{label:new Date(e.armedAt).toLocaleString(),side:`top`,children:(0,O.jsxs)(`span`,{className:`tabular-nums`,children:[`created `,re(y),` ago`]})}),b?(0,O.jsxs)(`span`,{className:`tabular-nums`,children:[`running for `,w(a-b.firedAt)]}):null,e.paused&&e.lastRun?(0,O.jsxs)(`span`,{className:`tabular-nums`,children:[`Last run: `,(0,O.jsx)(R,{status:e.lastRun.status})]}):null,!e.paused&&e.nextFireAt!==null?(0,O.jsxs)(`span`,{className:`tabular-nums`,children:[`next in `,w(Math.max(0,e.nextFireAt-a))]}):null,n]})]}),(0,O.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[(0,O.jsx)(S,{label:x?$:`Edit cron job`,side:`top`,children:(0,O.jsx)(`button`,{type:`button`,"aria-label":`Edit cron job ${e.jobId}${x?` — ${$}`:``}`,"aria-disabled":x,className:i(Q,x&&`cursor-not-allowed opacity-40 hover:bg-transparent hover:text-muted-foreground`),onClick:_,children:(0,O.jsx)(u,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})}),e.paused?(0,O.jsx)(`button`,{type:`button`,"aria-label":`Resume cron job ${e.jobId}`,className:Q,onClick:h,children:(0,O.jsx)(D,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})}):(0,O.jsx)(`button`,{type:`button`,"aria-label":`Pause cron job ${e.jobId}`,className:Q,onClick:m,children:(0,O.jsx)(ae,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})}),(0,O.jsx)(`button`,{type:`button`,"aria-label":`Remove cron job ${e.jobId}`,className:`rounded-md p-1.5 text-muted-foreground hover:bg-muted/40 hover:text-destructive`,onClick:g,children:(0,O.jsx)(p,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})]}),c?(0,O.jsx)(_e,{job:e,open:!0,onOpenChange:d,onSave:v},`${e.jobId} ${String(e.armedAt)}`):null]})}function ye(e){return(0,O.jsx)(Z.Provider,{init:void 0,children:(0,O.jsx)(ve,{...e})})}export{M as a,P as i,se as n,j as o,R as r,ye as t};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-CQOZoUwg.js";import{E as n,L as r,O as i,j as a}from"./chatFocusPolicy-D5WAGQzz.js";import{t as o}from"./jsx-runtime-DREnUpxT.js";import{n as s,s as c}from"./KannaSocketProvider-Owmp4hPQ.js";import{t as l}from"./external-link-COo-Uzb1.js";import{l as u,n as d,t as f}from"./statusLabel-1tgAYyyt.js";import{_ as p,a as m,d as h,i as g,n as _,o as v,r as y,s as b,t as x}from"./timer.adapter-CcS8xEBd.js";import{t as ee}from"./input-DLIzWZj4.js";import{s as te}from"./branding-VdNGihTK.js";import{l as ne,u as S}from"./pushClient--9ISlWCZ.js";import{a as C}from"./formatters-wSVyvDFZ.js";import{r as w,t as re}from"./formatDuration-BbWTR_M_.js";import{n as ie}from"./state-mark-DyvaV7zQ.js";var T={name:`pause`,size:24,node:[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]};T.node;var ae=a(T),E={name:`play`,size:24,node:[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]};E.node;var D=a(E),O=e(o(),1),k=e(t(),1),A={timer:x};function j(e=1e3,t){let{timer:n}=t??A,[r,i]=(0,k.useState)(()=>Date.now()),a=(0,k.useRef)(e);return(0,k.useLayoutEffect)(()=>{a.current=e}),(0,k.useEffect)(()=>{let e=n.setInterval(()=>{i(Date.now())},a.current);return()=>n.clearInterval(e)},[n]),r}function M(e){return e===`inline`?`runs in this chat, context cleared each cycle`:`a new chat per run`}var N=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`];function P(e,t){if(e.type===`interval`)return F(e.ms);let{second:n,minute:r,hour:i,dom:a,month:o,dow:s}=e;if(o.kind!==`any`)return t;let c=a.kind===`any`&&s.kind===`any`;if(n!==void 0&&r.kind===`any`&&i.kind===`any`&&c){if(n.kind===`any`)return`every second`;let e=oe(n.values);if(e!==null)return e===1?`every second`:`every ${e} seconds`;if(n.values.length>1)return t}let l=n===void 0?0:I(n);if(l===null)return t;let u=l===0?``:`:${L(l)}`,d=I(r),f=I(i);if(r.kind===`any`&&i.kind===`any`&&c)return l===0?`every minute`:`every minute at :${L(l)}`;if(d!==null&&i.kind===`any`&&c)return`hourly at :${L(d)}${u}`;if(d!==null&&f!==null){let e=`${L(f)}:${L(d)}${u}`;if(c)return`daily at ${e}`;if(a.kind===`any`&&s.kind===`values`)return`every ${s.values.map(e=>N[e]).join(`, `)} at ${e}`;if(s.kind===`any`&&a.kind===`values`&&a.values.length===1)return`on day ${a.values[0]} of each month at ${e}`}return t}function F(e){let t=Math.round(e/1e3);if(t%3600==0){let e=t/3600;return e===1?`every hour`:`every ${e} hours`}if(t%60==0){let e=t/60;return e===1?`every minute`:`every ${e} minutes`}return t===1?`every second`:`every ${t} seconds`}function I(e){return e.kind===`values`&&e.values.length===1?e.values[0]:null}function oe(e){if(e.length<2||e[0]!==0)return null;let t=e[1];if(t<1||60%t!=0||e.length!==60/t)return null;for(let n=1;n<e.length;n++)if(e[n]!==n*t)return null;return t}function L(e){return String(e).padStart(2,`0`)}function se({message:e,cronJobs:t}){let n=(t?.find(t=>t.jobId===e.jobId))?.recentRuns.find(t=>t.runId===e.runId)?.status??`running`;return(0,O.jsxs)(`div`,{className:`px-0.5`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(c,{className:`h-4 w-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,O.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:`Cron run`}),(0,O.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.jobId}),(0,O.jsxs)(`span`,{className:`ml-auto flex items-center gap-3`,children:[(0,O.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:C(e.firedAt)}),(0,O.jsx)(R,{status:n})]})]}),(0,O.jsx)(`p`,{className:`mt-1.5 text-sm text-foreground/90`,children:e.instruction}),e.spawnedChatId?(0,O.jsxs)(r,{to:`/chat/${e.spawnedChatId}`,className:`mt-2 inline-flex items-center gap-1.5 text-xs font-medium text-primary hover:underline`,children:[(0,O.jsx)(l,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),`Open run chat`]}):null]})}function R({status:e}){return(0,O.jsx)(ie,{tone:d(e),label:f(e)})}function z(){return(0,O.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-border bg-muted/40 px-2 py-0.5 text-xs font-medium text-muted-foreground`,children:[(0,O.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-muted-foreground`}),`Paused`]})}function B(e){for(let t of e.recentRuns)if(t.status!==`skipped`)return t.status===`running`;return!1}var V={"@hourly":`0 * * * *`,"@daily":`0 0 * * *`,"@weekly":`0 0 * * 0`,"@monthly":`0 0 1 * *`},H=Object.keys(V),U=[{name:`minute`,min:0,max:59},{name:`hour`,min:0,max:23},{name:`day-of-month`,min:1,max:31},{name:`month`,min:1,max:12,names:{jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12}},{name:`day-of-week`,min:0,max:7,names:{sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6},normalize:e=>e===7?0:e}],W={name:`second`,min:0,max:59},G={s:1e3,m:6e4,h:36e5};function ce(e){let t=e.trim();if(t===``)return{ok:!1,part:`schedule`,message:"missing schedule — expected 5- or 6-field cron, @shortcut, or `every <N>s|m|h`"};let n=t.split(/\s+/);return n[0].startsWith(`@`)?le(n):n[0].toLowerCase()===`every`?de(n):K(n)}function le(e){let t=e[0].toLowerCase(),n=V[t];if(n===void 0){let n=ue(t);return{ok:!1,part:`schedule`,message:`unknown shortcut "${e[0]}" — valid shortcuts are ${H.join(`, `)}`,correctedSchedule:n??void 0}}if(e.length>1)return{ok:!1,part:`schedule`,message:`${t} takes no extra tokens (got "${e.slice(1).join(` `)}")`,correctedSchedule:t};let r=K(n.split(` `));if(!r.ok)throw Error(`builtin shortcut ${t} failed to parse: ${r.message}`);return r}function ue(e){let t=null,n=4;for(let r of H){let i=Y(e,r,n);i<n&&(t=r,n=i)}return t}function de(e){if(e.length===1)return{ok:!1,part:`schedule`,message:"missing interval after `every` — expected e.g. `every 30s`, `every 5m`, or `every 2h`"};let t=e.length===3?e[1]+e[2]:e[1];if(e.length>3||e.length===3&&!fe(t))return{ok:!1,part:`schedule`,message:`expected exactly \`every <N>s|m|h\`, got "${e.join(` `)}"`};let n=/^(\d+)(s|m|h)$/.exec(t);if(n){let r=Number.parseInt(n[1],10);if(r<1)return{ok:!1,part:`schedule`,message:`interval must be at least 1`,correctedSchedule:`every 1${n[2]}`};let i=G[n[2]],a=e.length===3?`every ${t}`:void 0;return a===void 0?{ok:!0,schedule:{type:`interval`,ms:r*i}}:{ok:!1,part:`schedule`,message:`interval "${e.slice(1).join(` `)}" has a stray space`,correctedSchedule:a}}let r=/^(\d+)\s*(min|mins|minute|minutes|m|hr|hrs|hour|hours|h|s|sec|secs|second|seconds|d|day|days)$/i.exec(t);if(r){let e=r[1],t=r[2].toLowerCase();if(t.startsWith(`d`))return{ok:!1,part:`schedule`,message:`use @daily instead of "every ${e}${t}"`,correctedSchedule:`@daily`};let n=t[0];return{ok:!1,part:`schedule`,message:`interval unit "${t}" is not valid — use \`s\`, \`m\`, or \`h\``,correctedSchedule:`every ${e}${n}`}}return{ok:!1,part:`schedule`,message:`interval "${t}" is not valid — expected e.g. \`every 30s\`, \`every 5m\`, or \`every 2h\``}}function fe(e){return/^\d+\s*[a-z]+$/i.test(e)}function K(e){let t=e.length===6;if(e.length!==5&&!t){let t=e.length===1&&/^\d+(s|m|h)$/.test(e[0]);return{ok:!1,part:`schedule`,message:`cron schedule has ${e.length} field${e.length===1?``:`s`}, expected 5 (minute hour day-of-month month day-of-week) or 6 with a leading second`,correctedSchedule:t?`every ${e[0]}`:pe(e)}}let n=t?[W,...U]:U,r=[];for(let t=0;t<n.length;t++){let i=me(n[t],e[t]);if(!i.ok)return{ok:!1,part:`schedule_field`,message:i.message};r.push(i.field)}let i=+!!t;return{ok:!0,schedule:{type:`cron`,expression:e.join(` `),...t?{second:r[0]}:{},minute:r[i],hour:r[i+1],dom:r[i+2],month:r[i+3],dow:r[i+4]}}}function pe(e){if(e.length>=2&&e.length<=4){let t=[...e,...Array(5-e.length).fill(`*`)];return K(t).ok?t.join(` `):void 0}if(e.length===7){let t=e.slice(0,6);return K(t).ok?t.join(` `):void 0}}function me(e,t){if(t===`*`)return{ok:!0,field:{kind:`any`}};let n=new Set;for(let r of t.split(`,`)){if(r===``)return{ok:!1,message:`${e.name} field "${t}" has an empty list entry`};let i=/^(\*|[A-Za-z]+|\d+)(?:-([A-Za-z]+|\d+))?(?:\/(\d+))?$/.exec(r);if(!i)return{ok:!1,message:`${e.name} field "${r}" is not valid — expected \`*\`, \`N\`, \`N-M\`, \`*/S\`, or \`N-M/S\``};let[,a,o,s]=i,c,l;if(a===`*`){if(o!==void 0)return{ok:!1,message:`${e.name} field "${r}" is not valid — \`*\` cannot be a range start`};c=e.min,l=e.max}else{let t=q(e,a);if(t===null)return{ok:!1,message:J(e,a)};if(c=t,o!==void 0){let t=q(e,o);if(t===null)return{ok:!1,message:J(e,o)};l=t}else l=c}if(c<e.min||c>e.max||l<e.min||l>e.max)return{ok:!1,message:`${e.name} field "${r}" is out of range ${e.min}-${e.max}`};if(l<c)return{ok:!1,message:`${e.name} field "${r}" has a range end below its start`};let u=1;if(s!==void 0){if(u=Number.parseInt(s,10),u<1)return{ok:!1,message:`${e.name} field "${r}" has a step of 0 — steps start at 1`};if(a!==`*`&&o===void 0)return{ok:!1,message:`${e.name} field "${r}" applies a step to a single value — use \`*/S\` or \`N-M/S\``}}for(let t=c;t<=l;t+=u)n.add(e.normalize?e.normalize(t):t)}return{ok:!0,field:{kind:`values`,values:[...n].sort((e,t)=>e-t)}}}function q(e,t){return/^\d+$/.test(t)?Number.parseInt(t,10):e.names?.[t.toLowerCase()]??null}function J(e,t){return/^\d+$/.test(t)?`${e.name} field "${t}" is out of range ${e.min}-${e.max}`:e.names?`${e.name} field "${t}" is not a valid ${e.name} name (${Object.keys(e.names).join(`, `)})`:`${e.name} field "${t}" is not a number`}function Y(e,t,n){if(Math.abs(e.length-t.length)>n)return n+1;let r=Array.from({length:t.length+1},(e,t)=>t);for(let i=1;i<=e.length;i++){let a=[i],o=i;for(let n=1;n<=t.length;n++){let s=e[i-1]===t[n-1]?0:1,c=Math.min(r[n]+1,a[n-1]+1,r[n-1]+s);a.push(c),c<o&&(o=c)}if(o>n)return n+1;r=a}return r[t.length]}var X=_(`CronJobEditDialog`,e=>t=>({instruction:e.instruction,scheduleText:e.scheduleText,mode:e.mode,setInstruction:e=>t({instruction:e}),setScheduleText:e=>t({scheduleText:e}),setMode:e=>t({mode:e})})),he=[{value:`inline`,label:`inline`},{value:`spawn`,label:`spawn`}];function ge({job:e,open:t,onOpenChange:r,onSave:i}){let a=X.useScopedStore(e=>e.instruction),o=X.useScopedStore(e=>e.scheduleText),s=X.useScopedStore(e=>e.mode),c=X.useScopedStore(e=>e.setInstruction),l=X.useScopedStore(e=>e.setScheduleText),u=X.useScopedStore(e=>e.setMode),d=(0,k.useMemo)(()=>ce(o.trim()),[o]),f=(0,k.useMemo)(()=>{let t={},n=a.trim();n&&n!==e.instruction&&(t.instruction=n),s!==e.mode&&(t.mode=s);let r=o.trim();return d.ok&&r!==e.scheduleText&&(t.schedule=d.schedule,t.scheduleText=r),t},[a,e.instruction,e.mode,e.scheduleText,s,d,o]),p=a.trim().length===0,_=!p&&d.ok&&Object.keys(f).length>0,x=(0,k.useCallback)(()=>{d.ok||d.correctedSchedule===void 0||l(d.correctedSchedule)},[d,l]),S=(0,k.useCallback)(()=>{_&&(i(f),r(!1))},[_,r,i,f]),C=(0,k.useCallback)(()=>{r(!1)},[r]);return(0,O.jsx)(y,{open:t,onOpenChange:r,children:(0,O.jsxs)(m,{size:`lg`,children:[(0,O.jsxs)(g,{className:`space-y-4`,children:[(0,O.jsx)(h,{children:`Edit cron job`}),(0,O.jsxs)(v,{children:[(0,O.jsx)(`span`,{className:`font-mono`,children:e.jobId}),` — saving re-arms the job, which clears its run history and resets its created age.`]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`cron-edit-instruction`,className:`text-sm font-medium text-foreground`,children:`Instruction`}),(0,O.jsx)(ne,{id:`cron-edit-instruction`,rows:4,value:a,onChange:e=>c(e.target.value)}),p?(0,O.jsx)(`p`,{className:`text-xs text-destructive`,children:`An instruction is required.`}):null]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`label`,{htmlFor:`cron-edit-schedule`,className:`text-sm font-medium text-foreground`,children:`Schedule`}),(0,O.jsx)(ee,{id:`cron-edit-schedule`,value:o,onChange:e=>l(e.target.value),placeholder:`0 9 * * 1, @daily, or every 5m`,className:`font-mono`}),d.ok?(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:P(d.schedule,o.trim())}):(0,O.jsx)(`p`,{className:`text-xs text-destructive`,children:d.message}),!d.ok&&d.correctedSchedule!==void 0?(0,O.jsxs)(n,{variant:`secondary`,size:`sm`,onClick:x,children:[`Use `,(0,O.jsx)(`span`,{className:`ml-1 font-mono`,children:d.correctedSchedule})]}):null]}),(0,O.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,O.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:`Mode`}),(0,O.jsx)(te,{value:s,onValueChange:u,options:he,size:`sm`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:M(s)})]})]}),(0,O.jsxs)(b,{children:[(0,O.jsx)(n,{variant:`ghost`,size:`sm`,onClick:C,children:`Cancel`}),(0,O.jsx)(n,{size:`sm`,onClick:S,disabled:!_,children:`Save`})]})]})})}function _e(e){return(0,O.jsx)(X.Provider,{init:e.job,children:(0,O.jsx)(ge,{...e})})}var Z=_(`CronJobRow`,()=>e=>({editing:!1,openEditor:()=>e({editing:!0}),setEditing:t=>e({editing:t})})),Q=`rounded-md p-1.5 text-muted-foreground hover:bg-muted/40 hover:text-foreground`,$=`cannot edit while a run is in flight`;function ve({job:e,chatId:t,trailing:n,divider:r}){let a=j(1e3),o=s(),c=Z.useScopedStore(e=>e.editing),l=Z.useScopedStore(e=>e.openEditor),d=Z.useScopedStore(e=>e.setEditing),f=(0,k.useCallback)(e=>{o?.command(e).catch(()=>{})},[o]),m=(0,k.useCallback)(()=>{f({type:`cron.pause`,chatId:t,jobId:e.jobId})},[t,e.jobId,f]),h=(0,k.useCallback)(()=>{f({type:`cron.resume`,chatId:t,jobId:e.jobId})},[t,e.jobId,f]),g=(0,k.useCallback)(()=>{f({type:`cron.remove`,chatId:t,jobId:e.jobId})},[t,e.jobId,f]),_=(0,k.useCallback)(()=>{B(e)||l()},[e,l]),v=(0,k.useCallback)(n=>{o?.command({type:`cron.update`,chatId:t,jobId:e.jobId,patch:n}).catch(()=>{})},[t,e.jobId,o]),y=a-e.armedAt,b=e.lastRun?.status===`running`?e.lastRun:null,x=B(e);return(0,O.jsxs)(`div`,{className:i(`flex items-center gap-3 bg-background px-4 py-2.5`,r&&`border-b border-border`),children:[(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`truncate text-sm text-foreground`,children:e.instruction}),e.paused?(0,O.jsx)(z,{}):null,!e.paused&&e.lastRun?(0,O.jsx)(R,{status:e.lastRun.status}):null]}),(0,O.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,children:[(0,O.jsx)(`span`,{className:`font-mono`,children:e.jobId}),(0,O.jsx)(`span`,{children:P(e.schedule,e.scheduleText)}),(0,O.jsxs)(`span`,{children:[`· `,e.mode]}),e.model?(0,O.jsx)(`span`,{className:`font-mono`,children:e.model}):null,(0,O.jsx)(S,{label:new Date(e.armedAt).toLocaleString(),side:`top`,children:(0,O.jsxs)(`span`,{className:`tabular-nums`,children:[`created `,re(y),` ago`]})}),b?(0,O.jsxs)(`span`,{className:`tabular-nums`,children:[`running for `,w(a-b.firedAt)]}):null,e.paused&&e.lastRun?(0,O.jsxs)(`span`,{className:`tabular-nums`,children:[`Last run: `,(0,O.jsx)(R,{status:e.lastRun.status})]}):null,!e.paused&&e.nextFireAt!==null?(0,O.jsxs)(`span`,{className:`tabular-nums`,children:[`next in `,w(Math.max(0,e.nextFireAt-a))]}):null,n]})]}),(0,O.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[(0,O.jsx)(S,{label:x?$:`Edit cron job`,side:`top`,children:(0,O.jsx)(`button`,{type:`button`,"aria-label":`Edit cron job ${e.jobId}${x?` — ${$}`:``}`,"aria-disabled":x,className:i(Q,x&&`cursor-not-allowed opacity-40 hover:bg-transparent hover:text-muted-foreground`),onClick:_,children:(0,O.jsx)(u,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})}),e.paused?(0,O.jsx)(`button`,{type:`button`,"aria-label":`Resume cron job ${e.jobId}`,className:Q,onClick:h,children:(0,O.jsx)(D,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})}):(0,O.jsx)(`button`,{type:`button`,"aria-label":`Pause cron job ${e.jobId}`,className:Q,onClick:m,children:(0,O.jsx)(ae,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})}),(0,O.jsx)(`button`,{type:`button`,"aria-label":`Remove cron job ${e.jobId}`,className:`rounded-md p-1.5 text-muted-foreground hover:bg-muted/40 hover:text-destructive`,onClick:g,children:(0,O.jsx)(p,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})})]}),c?(0,O.jsx)(_e,{job:e,open:!0,onOpenChange:d,onSave:v},`${e.jobId} ${String(e.armedAt)}`):null]})}function ye(e){return(0,O.jsx)(Z.Provider,{init:void 0,children:(0,O.jsx)(ve,{...e})})}export{M as a,P as i,se as n,j as o,R as r,ye as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-CQOZoUwg.js";import{L as n}from"./chatFocusPolicy-D5WAGQzz.js";import{t as r}from"./jsx-runtime-DREnUpxT.js";import{a as i,r as a,s as o}from"./KannaSocketProvider-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-CQOZoUwg.js";import{L as n}from"./chatFocusPolicy-D5WAGQzz.js";import{t as r}from"./jsx-runtime-DREnUpxT.js";import{a as i,r as a,s as o}from"./KannaSocketProvider-Owmp4hPQ.js";import{t as s}from"./external-link-COo-Uzb1.js";import{t as c}from"./CronJobRow-D5Fc3w-1.js";import{o as l}from"./formatters-wSVyvDFZ.js";var u=e(t(),1),d=e(r(),1);function f(){let e=a(e=>e.rows),t=(0,u.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.projectId)??{projectPath:n.projectPath,rows:[]};e.rows.push(n),t.set(n.projectId,e)}return[...t.values()]},[e]);return(0,d.jsx)(`div`,{className:i,children:(0,d.jsxs)(`div`,{className:`mx-auto w-full max-w-[900px] px-4 py-8`,children:[(0,d.jsxs)(`h1`,{className:`flex items-center gap-2.5 text-lg font-semibold text-foreground`,children:[(0,d.jsx)(o,{className:`h-5 w-5 text-muted-foreground`,"aria-hidden":`true`}),`Cron jobs`,(0,d.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground tabular-nums`,children:[e.length,` armed`]})]}),e.length===0?(0,d.jsxs)(`p`,{className:`mt-6 text-sm text-muted-foreground`,children:[`No cron jobs armed anywhere. Arm one from any chat with`,` `,(0,d.jsx)(`code`,{className:`font-mono text-xs`,children:`/cron <instruction> inline|spawn <schedule>`}),`.`]}):(0,d.jsx)(`div`,{className:`mt-6 space-y-6`,children:t.map(e=>(0,d.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:[(0,d.jsxs)(`h2`,{className:`border-b border-border bg-card p-3 px-4 text-sm font-medium text-foreground`,children:[l(e.projectPath),(0,d.jsx)(`span`,{className:`ml-2 font-mono text-xs font-normal text-muted-foreground`,children:e.projectPath})]}),(0,d.jsx)(`div`,{children:e.rows.map((t,r)=>(0,d.jsx)(c,{job:t.job,chatId:t.chatId,divider:r<e.rows.length-1,trailing:(0,d.jsxs)(n,{to:`/chat/${t.chatId}`,className:`inline-flex items-center gap-1 text-primary hover:underline`,children:[(0,d.jsx)(s,{className:`h-3 w-3`,"aria-hidden":`true`}),t.chatTitle||`Open chat`]})},`${t.chatId} ${t.job.jobId}`))})]},e.projectPath))})]})})}export{f as CronJobsPage};
|
package/dist/client/assets/{KannaSocketProvider-DJv2gp2E.js → KannaSocketProvider-Owmp4hPQ.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-CQOZoUwg.js";import{F as n,M as r,j as i,k as a}from"./chatFocusPolicy-D5WAGQzz.js";import{t as o}from"./jsx-runtime-DREnUpxT.js";import{c as s}from"./statusLabel-1tgAYyyt.js";import{t as c}from"./timer.adapter-CcS8xEBd.js";import{r as l}from"./branding-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-CQOZoUwg.js";import{F as n,M as r,j as i,k as a}from"./chatFocusPolicy-D5WAGQzz.js";import{t as o}from"./jsx-runtime-DREnUpxT.js";import{c as s}from"./statusLabel-1tgAYyyt.js";import{t as c}from"./timer.adapter-CcS8xEBd.js";import{r as l}from"./branding-VdNGihTK.js";import{c as u,r as d,s as f}from"./pushClient--9ISlWCZ.js";var p={name:`calendar-clock`,size:24,node:[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338`,key:`7hb8p4`}],[`path`,{d:`M3 9h5.859`,key:`numkqi`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]};p.node;var m=i(p),h=`h-[var(--shell-top-band)] max-h-[var(--shell-top-band)]`,g=`md:my-2 md:mr-2 md:rounded-2xl md:border md:border-border`,_=`flex min-h-0 flex-1 flex-col overflow-y-auto`,v=[],y=r()(e=>({rows:v,setRows:t=>e({rows:t.length>0?t:v})})),b=e(t(),1),x={CONNECTING:WebSocket.CONNECTING,OPEN:WebSocket.OPEN,CLOSING:WebSocket.CLOSING,CLOSED:WebSocket.CLOSED,create(e){return new WebSocket(e)}},S=25e3,C=15e3,w=4e3,T=`kanna:profile-send-to-starting`,E=class{url;ws=null;started=!1;reconnectTimer=null;reconnectDelayMs=750;subscriptions=new Map;pending=new Map;outboundQueue=[];statusListeners=new Set;heartbeatTimer=null;pingTimeoutTimer=null;pingPromise=null;lastOpenAt=0;lastMessageAt=0;reconnectImmediatelyOnClose=!1;serviceWorkerCleanup=null;dom;timer;localStore;sessStore;wsBridge;handleWindowFocus=()=>{this.ensureHealthyConnection()};handleVisibilityChange=()=>{if(this.dom.getVisibilityState()===`visible`){this.startHeartbeat(),this.ensureHealthyConnection();return}this.stopHeartbeat()};handleOnline=()=>{this.ensureHealthyConnection()};constructor(e,t={}){this.url=e,this.dom=t.dom??n,this.timer=t.timer??c,this.localStore=t.localStorage??f,this.sessStore=t.sessionStorage??u,this.wsBridge=t.webSocket??x}start(){this.started||(this.started=!0,this.serviceWorkerCleanup=this.dom.addServiceWorkerMessageListener(e=>{let t=e.data;t?.type===`kanna.navigate`&&typeof t.url==`string`&&this.dom.setHref(t.url)}),this.dom.addWindowListener(`focus`,this.handleWindowFocus),this.dom.addWindowListener(`online`,this.handleOnline),this.dom.addDocumentListener(`visibilitychange`,this.handleVisibilityChange),this.connect())}dispose(){this.started=!1,this.reconnectTimer&&=(this.timer.clearTimeout(this.reconnectTimer),null),this.stopHeartbeat(),this.clearPingState(),this.serviceWorkerCleanup&&=(this.serviceWorkerCleanup(),null),this.ws?.close(),this.ws=null;for(let e of this.pending.values())e.reject(Error(`Socket disposed`));this.pending.clear()}onStatus(e){return this.statusListeners.add(e),e(this.getStatus()),()=>{this.statusListeners.delete(e)}}subscribe(e,t,n){let r=a(),i={topic:e,listener:t,eventListener:n};return this.subscriptions.set(r,i),this.enqueue({v:1,type:`subscribe`,id:r,topic:e}),()=>{this.subscriptions.delete(r),this.enqueue({v:1,type:`unsubscribe`,id:r})}}subscribeTerminal(e,t){let n=a(),r={type:`terminal`,terminalId:e},i={topic:r,listener:t.onSnapshot,eventListener:t.onEvent};return this.subscriptions.set(n,i),this.enqueue({v:1,type:`subscribe`,id:n,topic:r}),()=>{this.subscriptions.delete(n),this.enqueue({v:1,type:`unsubscribe`,id:n})}}command(e){let t=a(),n={v:1,type:`command`,id:t,command:e};return new Promise((e,r)=>{this.pending.set(t,{resolve:e,reject:r}),this.enqueue(n)})}setFocusedChat(e){let t=a();this.enqueue({v:1,type:`command`,id:t,command:{type:`push.setFocusedChat`,chatId:e}})}ensureHealthyConnection(){let e=this.wsBridge;return!this.ws||this.ws.readyState===e.CLOSED||this.ws.readyState===e.CLOSING?(this.reconnectNow(),Promise.resolve()):this.ws.readyState===e.CONNECTING||!this.isConnectionStale()?Promise.resolve():this.sendPing()}isSendToStartingProfilingEnabled(){try{return this.sessStore.getItem(T)===`1`||this.localStore.getItem(T)===`1`}catch{return!1}}connect(){this.started&&(this.emitStatus(`connecting`),this.ws=this.wsBridge.create(this.url),this.ws.addEventListener(`open`,()=>{this.reconnectDelayMs=750,this.reconnectImmediatelyOnClose=!1,this.lastOpenAt=Date.now(),this.lastMessageAt=this.lastOpenAt,this.emitStatus(`connected`),this.startHeartbeat();for(let[e,t]of this.subscriptions.entries())this.sendNow({v:1,type:`subscribe`,id:e,topic:t.topic});for(;this.outboundQueue.length>0;){let e=this.outboundQueue.shift();e&&this.sendNow(e)}let e=d();e&&this.sendNow({v:1,type:`command`,id:a(),command:{type:`push.identifyDevice`,pushDeviceId:e}})}),this.ws.addEventListener(`message`,e=>{this.lastMessageAt=Date.now();let t=performance.now(),n=e instanceof MessageEvent?e.data:void 0,r=String(n),i;try{i=JSON.parse(r)}catch{return}if(this.isSendToStartingProfilingEnabled()&&i.type===`snapshot`&&i.snapshot.type===`chat`&&i.snapshot.data?.runtime.status===`starting`&&s.debug(`[kanna/send->starting][client-ws]`,{stage:`socket_message_received`,receivedAt:t,payloadBytes:r.length,chatId:i.snapshot.data.runtime.chatId,status:i.snapshot.data.runtime.status,messageCount:i.snapshot.data.messages.length}),this.isSendToStartingProfilingEnabled()&&i.type===`ack`&&s.debug(`[kanna/send->starting][client-ws]`,{stage:`socket_ack_received`,receivedAt:t,payloadBytes:r.length,commandId:i.id}),i.type===`snapshot`){this.subscriptions.get(i.id)?.listener(i.snapshot.data);return}if(i.type===`event`){this.subscriptions.get(i.id)?.eventListener?.(i.event);return}if(i.type===`ack`){let e=this.pending.get(i.id);if(!e)return;this.pending.delete(i.id),e.resolve(i.result);return}if(i.type===`error`){if(!i.id){s.error(l,i.message);return}let e=this.pending.get(i.id);if(!e)return;this.pending.delete(i.id),e.reject(Error(i.message))}}),this.ws.addEventListener(`close`,()=>{if(!this.started)return;let e=this.reconnectImmediatelyOnClose;this.reconnectImmediatelyOnClose=!1,this.stopHeartbeat(),this.clearPingState(),this.emitStatus(`disconnected`);for(let e of this.pending.values())e.reject(Error(`Disconnected`));if(this.pending.clear(),e){this.connect();return}this.scheduleReconnect()}))}scheduleReconnect(){this.reconnectTimer===null&&(this.reconnectTimer=this.timer.setTimeout(()=>{this.reconnectTimer=null,this.connect(),this.reconnectDelayMs=Math.min(this.reconnectDelayMs*2,5e3)},this.reconnectDelayMs))}getStatus(){let e=this.wsBridge;return this.ws?.readyState===e.OPEN?`connected`:this.ws?.readyState===e.CONNECTING?`connecting`:`disconnected`}emitStatus(e){for(let t of this.statusListeners)t(e)}isConnectionStale(){let e=Math.max(this.lastMessageAt,this.lastOpenAt);return e>0&&Date.now()-e>=S}sendPing(){if(this.pingPromise)return this.pingPromise;let e=this.command({type:`system.ping`}).then(()=>{this.clearPingState()}).catch(e=>{throw this.clearPingState(),this.reconnectNow(),e});return this.pingTimeoutTimer=this.timer.setTimeout(()=>{this.clearPingState(),this.reconnectNow()},w),this.pingPromise=e,e}reconnectNow(){let e=this.wsBridge;if(this.reconnectTimer!==null&&(this.timer.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),!this.ws||this.ws.readyState===e.CLOSED){this.connect();return}this.ws.readyState!==e.CONNECTING&&(this.reconnectImmediatelyOnClose=!0,this.ws.close())}startHeartbeat(){this.dom.getVisibilityState()===`visible`&&this.heartbeatTimer===null&&(this.heartbeatTimer=this.timer.setInterval(()=>{if(this.dom.getVisibilityState()!==`visible`){this.stopHeartbeat();return}let e=this.wsBridge;this.ws?.readyState===e.OPEN&&this.ensureHealthyConnection()},C))}stopHeartbeat(){this.heartbeatTimer!==null&&(this.timer.clearInterval(this.heartbeatTimer),this.heartbeatTimer=null)}clearPingState(){this.pingTimeoutTimer!==null&&(this.timer.clearTimeout(this.pingTimeoutTimer),this.pingTimeoutTimer=null),this.pingPromise=null}enqueue(e){let t=this.wsBridge;if(this.ws?.readyState===t.OPEN){this.sendNow(e);return}this.outboundQueue.push(e)}sendNow(e){this.ws?.send(JSON.stringify(e))}},D=e(o(),1),O=(0,b.createContext)(null);function k(e){let t=e.getHref();return`${t.startsWith(`https://`)?`wss:`:`ws:`}//${new URL(t).host}/ws`}function A({children:e,socket:t,ports:r}){let i=r?.dom??n,a=(0,b.useMemo)(()=>t?null:new E(k(i),r??{}),[]),o=t??a;return(0,b.useEffect)(()=>{if(a)return a.start(),()=>{a.dispose()}},[a]),(0,D.jsx)(O.Provider,{value:o,children:e})}function j(){return(0,b.useContext)(O)}export{_ as a,g as i,j as n,h as o,y as r,m as s,A as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-CQOZoUwg.js";import{E as n,M as r,O as i,W as a}from"./chatFocusPolicy-D5WAGQzz.js";import{t as o}from"./jsx-runtime-DREnUpxT.js";import{i as s,n as c,r as l,t as u}from"./clipboard.adapter-CyzHY22e.js";import{t as d}from"./chevron-right-9vF-mw9m.js";import{n as f,t as p}from"./terminal-STCgoe-i.js";import{t as m}from"./folder-BPm2BBWp.js";import{t as h}from"./monitor-CIs8RSWK.js";import{t as g}from"./plus-BFyTSu3o.js";import{t as _}from"./square-pen-D1KuPs3U.js";import{a as v,d as y,i as b,n as x,r as S,s as C,t as w}from"./timer.adapter-CcS8xEBd.js";import{t as T}from"./input-DLIzWZj4.js";import{a as E,d as D,f as O,i as k,m as A,n as j,s as M,t as N}from"./branding-CaxlVtaJ.js";import{o as P}from"./formatters-wSVyvDFZ.js";var F=e(t(),1),I=x(`CopyButton`,()=>e=>({copied:!1,setCopied:t=>e({copied:t})})),L=e(o(),1);function R({narrow:e=!1,title:t,subtitle:n,icon:r=h}){return(0,L.jsxs)(`div`,{className:i(`w-full`,e?`max-w-2xl px-6 pt-16 mx-auto`:`px-6 pt-16 mb-10`),children:[(0,L.jsxs)(`div`,{className:i(`flex items-center gap-1 mb-2`,e&&`justify-center`),children:[(0,L.jsx)(`div`,{className:`p-2 pl-0 rounded-lg`,children:(0,L.jsx)(r,{className:`h-6 w-6 text-muted-foreground`})}),(0,L.jsx)(`h1`,{className:`text-2xl font-semibold text-foreground`,children:t})]}),n&&(0,L.jsx)(`p`,{className:i(`text-muted-foreground`,e&&`mb-10 text-center`),children:n})]})}var z=r()(e=>({tab:`new`,name:``,existingPath:``,setTab:t=>e({tab:t}),setName:t=>e({name:t}),setExistingPath:t=>e({existingPath:t}),resetForOpen:()=>e({tab:`new`,name:``,existingPath:``})})),B=()=>z(e=>e.tab),V=()=>z(e=>e.name),H=()=>z(e=>e.existingPath);function U(e){return e.toLowerCase().replace(/[\s_]+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``)}function W({open:e,onOpenChange:t,onConfirm:r,ports:i={}}){let a=i.timer??w,o=B(),s=V(),c=H(),l=z(e=>e.setTab),u=z(e=>e.setName),d=z(e=>e.setExistingPath),f=z(e=>e.resetForOpen),p=(0,F.useRef)(null),m=(0,F.useRef)(null);(0,F.useEffect)(()=>{e&&(f(),a.setTimeout(()=>p.current?.focus(),0))},[e,f,a]),(0,F.useEffect)(()=>{e&&a.setTimeout(()=>{o===`new`?p.current?.focus():m.current?.focus()},0)},[o,e,a]);let h=U(s),g=h?`${j}/${h}`:``,_=c.trim(),x=o===`new`?!!h:!!_,E=()=>{if(x){if(o===`new`)r({mode:`new`,localPath:g,title:s.trim()});else{let e=_.split(`/`).pop()||_;r({mode:`existing`,localPath:_,title:e})}t(!1)}};return(0,L.jsx)(S,{open:e,onOpenChange:t,children:(0,L.jsxs)(v,{size:`sm`,children:[(0,L.jsxs)(b,{className:`space-y-4`,children:[(0,L.jsx)(y,{children:`Add Project`}),(0,L.jsx)(M,{value:o,onValueChange:l,options:[{value:`new`,label:`New Folder`},{value:`existing`,label:`Existing Path`}],className:`w-full mb-2`,optionClassName:`flex-1 justify-center`}),o===`new`?(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(T,{ref:p,type:`text`,value:s,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&E(),e.key===`Escape`&&t(!1)},placeholder:`Project name`}),g&&(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground font-mono`,children:g})]}):(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(T,{ref:m,type:`text`,value:c,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&E(),e.key===`Escape`&&t(!1)},placeholder:`~/Projects/my-app`}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The folder will be created if it doesn't exist.`})]})]}),(0,L.jsxs)(C,{children:[(0,L.jsx)(n,{variant:`ghost`,size:`sm`,onClick:()=>t(!1),children:`Cancel`}),(0,L.jsx)(n,{variant:`secondary`,size:`sm`,onClick:E,disabled:!x,children:`Create`})]})]})})}function G({text:e,ports:t={}}){let r=I.useScopedStore(e=>e.copied),i=I.useScopedStore(e=>e.setCopied),a=t.clipboard??u,o=t.timer??w;async function c(){await a.writeText(e),i(!0),o.setTimeout(()=>i(!1),2e3)}return(0,L.jsx)(n,{variant:`ghost`,size:`icon-mobile`,"aria-label":r?`Copied`:`Copy to clipboard`,className:`text-muted-foreground hover:text-foreground`,onClick:()=>void c(),children:r?(0,L.jsx)(s,{className:`h-4 w-4 text-success-text`}):(0,L.jsx)(l,{className:`h-4 w-4`})})}function K({text:e}){return(0,L.jsx)(I.Provider,{init:{},children:(0,L.jsx)(G,{text:e})})}function q({children:e}){return(0,L.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] items-center group bg-background border border-border text-foreground rounded-xl p-1.5 pl-3 font-mono text-sm`,children:[(0,L.jsxs)(`pre`,{className:`inline-flex items-center gap-2 overflow-x-auto`,children:[(0,L.jsx)(d,{className:`inline h-4 w-4 opacity-40`}),(0,L.jsx)(`code`,{children:e})]}),(0,L.jsx)(K,{text:e})]})}function J({children:e}){return(0,L.jsx)(`div`,{className:`bg-card border border-border rounded-2xl p-4`,children:e})}function Y({children:e}){return(0,L.jsx)(`h2`,{className:`text-13 font-medium text-muted-foreground tracking-wider mb-3`,children:e})}function X({icon:e,title:t,subtitle:n,iconClassName:r}){return(0,L.jsxs)(`div`,{className:`flex flex-col items-start gap-1.5 min-w-0`,children:[(0,L.jsx)(e,{className:r||`h-5 w-5 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:t}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground leading-tight`,children:n})]})}function Z(){return(0,L.jsx)(`div`,{"aria-hidden":!0,className:`mt-5 h-px w-6 shrink-0 bg-border`})}function Q({number:e,title:t,children:n}){return(0,L.jsx)(`div`,{className:`flex gap-4`,children:(0,L.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] items-baseline gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex-shrink-0 flex items-center justify-center font-medium text-logo`,children:[e,`.`]}),(0,L.jsx)(`h3`,{className:`font-medium text-foreground mb-2`,children:t})]}),(0,L.jsx)(`div`,{className:`text-muted-foreground text-sm space-y-3`,children:n})]})})}function $({localPath:e,loading:t,onClick:n}){return(0,L.jsxs)(D,{children:[(0,L.jsx)(A,{asChild:!0,children:(0,L.jsxs)(`button`,{className:i(`border border-border hover:border-primary/30 group rounded-lg bg-card px-4 py-3 flex items-center gap-3 w-full text-left hover:bg-muted/50 transition-colors`,t&&`opacity-50 cursor-not-allowed`),disabled:t,onClick:n,children:[(0,L.jsx)(m,{className:`h-4 w-4 text-muted-foreground flex-shrink-0`}),(0,L.jsx)(`span`,{className:`font-medium text-foreground truncate flex-1`,children:P(e)}),t?(0,L.jsx)(c,{className:`h-4 w-4 text-muted-foreground group-hover:text-primary animate-spin flex-shrink-0`}):(0,L.jsx)(_,{className:`h-4 w-4 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0`})]})}),(0,L.jsx)(O,{children:(0,L.jsx)(`p`,{children:e})})]})}function ee({connectionStatus:e,ready:t,snapshot:r,startingLocalPath:i,commandError:a,newProjectOpen:o,onNewProjectOpenChange:s,onOpenProject:l,onCreateProject:u}){let d=(0,F.useMemo)(()=>r?.projects??[],[r?.projects]),m=e===`connecting`||!t;return(0,L.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 bg-background overflow-y-auto`,children:[e===`connected`&&t?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(R,{title:r?.machine.displayName??`Local Projects`,subtitle:`${N} is connected, choose a project below to get started.`}),(0,L.jsxs)(`div`,{className:`w-full px-6 mb-10`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline justify-between mb-3`,children:[(0,L.jsx)(`h2`,{className:`text-13 font-medium text-muted-foreground tracking-wider`,children:`Projects`}),(0,L.jsxs)(n,{variant:`default`,size:`sm`,onClick:()=>s(!0),children:[(0,L.jsx)(g,{className:`h-4 w-4 mr-1.5`}),`Add Project`]})]}),d.length>0?(0,L.jsx)(`div`,{className:`grid gap-2 [grid-template-columns:repeat(auto-fill,minmax(min(260px,100%),1fr))]`,children:d.map(e=>(0,L.jsx)($,{localPath:e.localPath,loading:i===e.localPath,onClick:()=>{l(e.localPath)}},e.localPath))}):(0,L.jsx)(J,{children:(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No local projects discovered yet. Open one with Claude or Codex, or create a new project here.`})}),a?(0,L.jsx)(`div`,{className:`text-sm text-destructive border border-destructive/20 bg-destructive/5 rounded-xl px-4 py-3 mt-4`,children:a}):null]})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(R,{narrow:!0,icon:f,title:m?`Connecting ${N}`:`Connect ${N}`,subtitle:m?`${N} is starting up and loading your local projects.`:`Run ${N} directly on your machine with full access to your local files and agent project history.`}),(0,L.jsxs)(`div`,{className:`max-w-2xl w-full mx-auto pb-12 px-6`,children:[(0,L.jsx)(Y,{children:`Status`}),(0,L.jsx)(`div`,{className:`mb-8`,children:(0,L.jsx)(J,{children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(c,{className:`h-4 w-4 text-muted-foreground animate-spin`}),(0,L.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:m?`Connecting to your local ${N} server...`:(0,L.jsxs)(L.Fragment,{children:[`Not connected. Run `,(0,L.jsx)(`code`,{className:`bg-background border border-border rounded-md mx-0.5 p-1 font-mono text-xs text-foreground`,children:E()}),` from any terminal on this machine.`]})})]})})}),m?null:(0,L.jsxs)(`div`,{className:`mb-10`,children:[(0,L.jsx)(Y,{children:`How it works`}),(0,L.jsx)(J,{children:(0,L.jsxs)(`div`,{className:`flex items-start gap-4 py-2 px-2`,children:[(0,L.jsx)(X,{icon:p,title:`${N} CLI`,subtitle:`On Your Machine`}),(0,L.jsx)(Z,{}),(0,L.jsx)(X,{icon:h,title:`${N} Server`,subtitle:`Local WebSocket`}),(0,L.jsx)(Z,{}),(0,L.jsx)(X,{icon:f,title:`${N} UI`,subtitle:`Project Chat`})]})})]}),m?null:(0,L.jsxs)(`div`,{className:`mb-10`,children:[(0,L.jsx)(Y,{children:`Setup`}),(0,L.jsx)(J,{children:(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(Q,{number:1,title:`Start ${N}`,children:[(0,L.jsx)(`p`,{children:`Run this command in your terminal:`}),(0,L.jsx)(q,{children:E()})]}),(0,L.jsxs)(Q,{number:2,title:`Open the local UI`,children:[(0,L.jsxs)(`p`,{children:[N,` serves the app locally and opens the Local Projects page in an app-style browser window.`]}),(0,L.jsx)(q,{children:`http://localhost:3210/local`})]}),(0,L.jsxs)(`div`,{className:`mt-8`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-muted-foreground tracking-wider mb-4`,children:`Notes`}),(0,L.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,L.jsxs)(`div`,{className:`flex gap-4`,children:[(0,L.jsx)(`code`,{className:`font-mono text-foreground whitespace-nowrap`,children:E(``).trim()}),(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:`Start in the current directory`})]}),(0,L.jsxs)(`div`,{className:`flex gap-4`,children:[(0,L.jsx)(`code`,{className:`font-mono text-foreground whitespace-nowrap`,children:E(`--no-open`)}),(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:`Start the server without opening the browser`})]})]})]})]})})]})]})]}),(0,L.jsx)(W,{open:o,onOpenChange:s,onConfirm:e=>{u(e)}}),(0,L.jsx)(`div`,{className:`py-4 text-center`,children:(0,L.jsxs)(`span`,{className:`text-xs text-muted-foreground/50`,children:[`v`,k.split(`/`)[1]]})})]})}function te(){let e=a();return(0,L.jsx)(`div`,{className:`flex-1 flex flex-col min-w-0 min-h-0 relative`,children:(0,L.jsx)(ee,{connectionStatus:e.connectionStatus,ready:e.localProjectsReady,snapshot:e.localProjects,startingLocalPath:e.startingLocalPath,commandError:e.commandError,newProjectOpen:e.addProjectModalOpen,onNewProjectOpenChange:t=>{if(t){e.openAddProjectModal();return}e.closeAddProjectModal()},onOpenProject:e.handleOpenLocalProject,onCreateProject:e.handleCreateProject})})}export{te as LocalProjectsPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-CQOZoUwg.js";import{E as n,M as r,O as i,W as a}from"./chatFocusPolicy-D5WAGQzz.js";import{t as o}from"./jsx-runtime-DREnUpxT.js";import{i as s,n as c,r as l,t as u}from"./clipboard.adapter-CyzHY22e.js";import{t as d}from"./chevron-right-9vF-mw9m.js";import{n as f,t as p}from"./terminal-STCgoe-i.js";import{t as m}from"./folder-BPm2BBWp.js";import{t as h}from"./monitor-CIs8RSWK.js";import{t as g}from"./plus-BFyTSu3o.js";import{t as _}from"./square-pen-D1KuPs3U.js";import{a as v,d as y,i as b,n as x,r as S,s as C,t as w}from"./timer.adapter-CcS8xEBd.js";import{t as T}from"./input-DLIzWZj4.js";import{a as E,d as D,f as O,i as k,m as A,n as j,s as M,t as N}from"./branding-VdNGihTK.js";import{o as P}from"./formatters-wSVyvDFZ.js";var F=e(t(),1),I=x(`CopyButton`,()=>e=>({copied:!1,setCopied:t=>e({copied:t})})),L=e(o(),1);function R({narrow:e=!1,title:t,subtitle:n,icon:r=h}){return(0,L.jsxs)(`div`,{className:i(`w-full`,e?`max-w-2xl px-6 pt-16 mx-auto`:`px-6 pt-16 mb-10`),children:[(0,L.jsxs)(`div`,{className:i(`flex items-center gap-1 mb-2`,e&&`justify-center`),children:[(0,L.jsx)(`div`,{className:`p-2 pl-0 rounded-lg`,children:(0,L.jsx)(r,{className:`h-6 w-6 text-muted-foreground`})}),(0,L.jsx)(`h1`,{className:`text-2xl font-semibold text-foreground`,children:t})]}),n&&(0,L.jsx)(`p`,{className:i(`text-muted-foreground`,e&&`mb-10 text-center`),children:n})]})}var z=r()(e=>({tab:`new`,name:``,existingPath:``,setTab:t=>e({tab:t}),setName:t=>e({name:t}),setExistingPath:t=>e({existingPath:t}),resetForOpen:()=>e({tab:`new`,name:``,existingPath:``})})),B=()=>z(e=>e.tab),V=()=>z(e=>e.name),H=()=>z(e=>e.existingPath);function U(e){return e.toLowerCase().replace(/[\s_]+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/-+/g,`-`).replace(/^-|-$/g,``)}function W({open:e,onOpenChange:t,onConfirm:r,ports:i={}}){let a=i.timer??w,o=B(),s=V(),c=H(),l=z(e=>e.setTab),u=z(e=>e.setName),d=z(e=>e.setExistingPath),f=z(e=>e.resetForOpen),p=(0,F.useRef)(null),m=(0,F.useRef)(null);(0,F.useEffect)(()=>{e&&(f(),a.setTimeout(()=>p.current?.focus(),0))},[e,f,a]),(0,F.useEffect)(()=>{e&&a.setTimeout(()=>{o===`new`?p.current?.focus():m.current?.focus()},0)},[o,e,a]);let h=U(s),g=h?`${j}/${h}`:``,_=c.trim(),x=o===`new`?!!h:!!_,E=()=>{if(x){if(o===`new`)r({mode:`new`,localPath:g,title:s.trim()});else{let e=_.split(`/`).pop()||_;r({mode:`existing`,localPath:_,title:e})}t(!1)}};return(0,L.jsx)(S,{open:e,onOpenChange:t,children:(0,L.jsxs)(v,{size:`sm`,children:[(0,L.jsxs)(b,{className:`space-y-4`,children:[(0,L.jsx)(y,{children:`Add Project`}),(0,L.jsx)(M,{value:o,onValueChange:l,options:[{value:`new`,label:`New Folder`},{value:`existing`,label:`Existing Path`}],className:`w-full mb-2`,optionClassName:`flex-1 justify-center`}),o===`new`?(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(T,{ref:p,type:`text`,value:s,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&E(),e.key===`Escape`&&t(!1)},placeholder:`Project name`}),g&&(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground font-mono`,children:g})]}):(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(T,{ref:m,type:`text`,value:c,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&E(),e.key===`Escape`&&t(!1)},placeholder:`~/Projects/my-app`}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The folder will be created if it doesn't exist.`})]})]}),(0,L.jsxs)(C,{children:[(0,L.jsx)(n,{variant:`ghost`,size:`sm`,onClick:()=>t(!1),children:`Cancel`}),(0,L.jsx)(n,{variant:`secondary`,size:`sm`,onClick:E,disabled:!x,children:`Create`})]})]})})}function G({text:e,ports:t={}}){let r=I.useScopedStore(e=>e.copied),i=I.useScopedStore(e=>e.setCopied),a=t.clipboard??u,o=t.timer??w;async function c(){await a.writeText(e),i(!0),o.setTimeout(()=>i(!1),2e3)}return(0,L.jsx)(n,{variant:`ghost`,size:`icon-mobile`,"aria-label":r?`Copied`:`Copy to clipboard`,className:`text-muted-foreground hover:text-foreground`,onClick:()=>void c(),children:r?(0,L.jsx)(s,{className:`h-4 w-4 text-success-text`}):(0,L.jsx)(l,{className:`h-4 w-4`})})}function K({text:e}){return(0,L.jsx)(I.Provider,{init:{},children:(0,L.jsx)(G,{text:e})})}function q({children:e}){return(0,L.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] items-center group bg-background border border-border text-foreground rounded-xl p-1.5 pl-3 font-mono text-sm`,children:[(0,L.jsxs)(`pre`,{className:`inline-flex items-center gap-2 overflow-x-auto`,children:[(0,L.jsx)(d,{className:`inline h-4 w-4 opacity-40`}),(0,L.jsx)(`code`,{children:e})]}),(0,L.jsx)(K,{text:e})]})}function J({children:e}){return(0,L.jsx)(`div`,{className:`bg-card border border-border rounded-2xl p-4`,children:e})}function Y({children:e}){return(0,L.jsx)(`h2`,{className:`text-13 font-medium text-muted-foreground tracking-wider mb-3`,children:e})}function X({icon:e,title:t,subtitle:n,iconClassName:r}){return(0,L.jsxs)(`div`,{className:`flex flex-col items-start gap-1.5 min-w-0`,children:[(0,L.jsx)(e,{className:r||`h-5 w-5 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:t}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground leading-tight`,children:n})]})}function Z(){return(0,L.jsx)(`div`,{"aria-hidden":!0,className:`mt-5 h-px w-6 shrink-0 bg-border`})}function Q({number:e,title:t,children:n}){return(0,L.jsx)(`div`,{className:`flex gap-4`,children:(0,L.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] items-baseline gap-3`,children:[(0,L.jsxs)(`div`,{className:`flex-shrink-0 flex items-center justify-center font-medium text-logo`,children:[e,`.`]}),(0,L.jsx)(`h3`,{className:`font-medium text-foreground mb-2`,children:t})]}),(0,L.jsx)(`div`,{className:`text-muted-foreground text-sm space-y-3`,children:n})]})})}function $({localPath:e,loading:t,onClick:n}){return(0,L.jsxs)(D,{children:[(0,L.jsx)(A,{asChild:!0,children:(0,L.jsxs)(`button`,{className:i(`border border-border hover:border-primary/30 group rounded-lg bg-card px-4 py-3 flex items-center gap-3 w-full text-left hover:bg-muted/50 transition-colors`,t&&`opacity-50 cursor-not-allowed`),disabled:t,onClick:n,children:[(0,L.jsx)(m,{className:`h-4 w-4 text-muted-foreground flex-shrink-0`}),(0,L.jsx)(`span`,{className:`font-medium text-foreground truncate flex-1`,children:P(e)}),t?(0,L.jsx)(c,{className:`h-4 w-4 text-muted-foreground group-hover:text-primary animate-spin flex-shrink-0`}):(0,L.jsx)(_,{className:`h-4 w-4 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0`})]})}),(0,L.jsx)(O,{children:(0,L.jsx)(`p`,{children:e})})]})}function ee({connectionStatus:e,ready:t,snapshot:r,startingLocalPath:i,commandError:a,newProjectOpen:o,onNewProjectOpenChange:s,onOpenProject:l,onCreateProject:u}){let d=(0,F.useMemo)(()=>r?.projects??[],[r?.projects]),m=e===`connecting`||!t;return(0,L.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 bg-background overflow-y-auto`,children:[e===`connected`&&t?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(R,{title:r?.machine.displayName??`Local Projects`,subtitle:`${N} is connected, choose a project below to get started.`}),(0,L.jsxs)(`div`,{className:`w-full px-6 mb-10`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline justify-between mb-3`,children:[(0,L.jsx)(`h2`,{className:`text-13 font-medium text-muted-foreground tracking-wider`,children:`Projects`}),(0,L.jsxs)(n,{variant:`default`,size:`sm`,onClick:()=>s(!0),children:[(0,L.jsx)(g,{className:`h-4 w-4 mr-1.5`}),`Add Project`]})]}),d.length>0?(0,L.jsx)(`div`,{className:`grid gap-2 [grid-template-columns:repeat(auto-fill,minmax(min(260px,100%),1fr))]`,children:d.map(e=>(0,L.jsx)($,{localPath:e.localPath,loading:i===e.localPath,onClick:()=>{l(e.localPath)}},e.localPath))}):(0,L.jsx)(J,{children:(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No local projects discovered yet. Open one with Claude or Codex, or create a new project here.`})}),a?(0,L.jsx)(`div`,{className:`text-sm text-destructive border border-destructive/20 bg-destructive/5 rounded-xl px-4 py-3 mt-4`,children:a}):null]})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(R,{narrow:!0,icon:f,title:m?`Connecting ${N}`:`Connect ${N}`,subtitle:m?`${N} is starting up and loading your local projects.`:`Run ${N} directly on your machine with full access to your local files and agent project history.`}),(0,L.jsxs)(`div`,{className:`max-w-2xl w-full mx-auto pb-12 px-6`,children:[(0,L.jsx)(Y,{children:`Status`}),(0,L.jsx)(`div`,{className:`mb-8`,children:(0,L.jsx)(J,{children:(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(c,{className:`h-4 w-4 text-muted-foreground animate-spin`}),(0,L.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:m?`Connecting to your local ${N} server...`:(0,L.jsxs)(L.Fragment,{children:[`Not connected. Run `,(0,L.jsx)(`code`,{className:`bg-background border border-border rounded-md mx-0.5 p-1 font-mono text-xs text-foreground`,children:E()}),` from any terminal on this machine.`]})})]})})}),m?null:(0,L.jsxs)(`div`,{className:`mb-10`,children:[(0,L.jsx)(Y,{children:`How it works`}),(0,L.jsx)(J,{children:(0,L.jsxs)(`div`,{className:`flex items-start gap-4 py-2 px-2`,children:[(0,L.jsx)(X,{icon:p,title:`${N} CLI`,subtitle:`On Your Machine`}),(0,L.jsx)(Z,{}),(0,L.jsx)(X,{icon:h,title:`${N} Server`,subtitle:`Local WebSocket`}),(0,L.jsx)(Z,{}),(0,L.jsx)(X,{icon:f,title:`${N} UI`,subtitle:`Project Chat`})]})})]}),m?null:(0,L.jsxs)(`div`,{className:`mb-10`,children:[(0,L.jsx)(Y,{children:`Setup`}),(0,L.jsx)(J,{children:(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(Q,{number:1,title:`Start ${N}`,children:[(0,L.jsx)(`p`,{children:`Run this command in your terminal:`}),(0,L.jsx)(q,{children:E()})]}),(0,L.jsxs)(Q,{number:2,title:`Open the local UI`,children:[(0,L.jsxs)(`p`,{children:[N,` serves the app locally and opens the Local Projects page in an app-style browser window.`]}),(0,L.jsx)(q,{children:`http://localhost:3210/local`})]}),(0,L.jsxs)(`div`,{className:`mt-8`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-medium text-muted-foreground tracking-wider mb-4`,children:`Notes`}),(0,L.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,L.jsxs)(`div`,{className:`flex gap-4`,children:[(0,L.jsx)(`code`,{className:`font-mono text-foreground whitespace-nowrap`,children:E(``).trim()}),(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:`Start in the current directory`})]}),(0,L.jsxs)(`div`,{className:`flex gap-4`,children:[(0,L.jsx)(`code`,{className:`font-mono text-foreground whitespace-nowrap`,children:E(`--no-open`)}),(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:`Start the server without opening the browser`})]})]})]})]})})]})]})]}),(0,L.jsx)(W,{open:o,onOpenChange:s,onConfirm:e=>{u(e)}}),(0,L.jsx)(`div`,{className:`py-4 text-center`,children:(0,L.jsxs)(`span`,{className:`text-xs text-muted-foreground/50`,children:[`v`,k.split(`/`)[1]]})})]})}function te(){let e=a();return(0,L.jsx)(`div`,{className:`flex-1 flex flex-col min-w-0 min-h-0 relative`,children:(0,L.jsx)(ee,{connectionStatus:e.connectionStatus,ready:e.localProjectsReady,snapshot:e.localProjects,startingLocalPath:e.startingLocalPath,commandError:e.commandError,newProjectOpen:e.addProjectModalOpen,onNewProjectOpenChange:t=>{if(t){e.openAddProjectModal();return}e.closeAddProjectModal()},onOpenProject:e.handleOpenLocalProject,onCreateProject:e.handleCreateProject})})}export{te as LocalProjectsPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-CQOZoUwg.js";import{D as n,E as r,F as i,G as a,M as o,O as s,U as c,W as l,j as u}from"./chatFocusPolicy-D5WAGQzz.js";import{t as d}from"./jsx-runtime-DREnUpxT.js";import{$ as f,B as p,C as m,D as h,E as g,F as _,G as v,H as y,J as b,K as x,M as S,N as C,O as w,P as T,Q as ee,R as E,S as te,T as D,U as O,V as k,W as A,X as ne,Y as re,Z as j,_ as ie,a as ae,b as oe,c as se,f as ce,ft as le,i as M,j as N,k as ue,lt as de,m as fe,mt as pe,o as me,pt as he,q as ge,st as _e,t as ve,u as ye,ut as be,w as xe,x as Se,y as Ce,z as we}from"./auth-BoU4Sy16.js";import{$t as Te,Gt as Ee,Ht as De,Jt as Oe,Kt as ke,Qt as Ae,Ut as je,Wt as Me,Xt as Ne,Yt as Pe,Zt as Fe,a as Ie,en as Le,l as Re,qt as ze,sn as Be,t as Ve,tn as P}from"./asJsonValue-C5MTs1l0.js";import{c as He,d as F,f as Ue,g as I,h as L,l as We,m as R,n as Ge,p as z,r as Ke,u as B,v as V,x as qe}from"./editor-icons-DRUxmX7g.js";import{n as H,r as Je,t as Ye}from"./clipboard.adapter-CyzHY22e.js";import{t as Xe}from"./external-link-COo-Uzb1.js";import{i as Ze,r as Qe,t as $e}from"./status-pill-BlXggLew.js";import{t as et}from"./monitor-CIs8RSWK.js";import{l as tt}from"./statusLabel-1tgAYyyt.js";import{t as nt}from"./plus-BFyTSu3o.js";import{_ as rt,a as it,d as at,i as ot,r as st,s as ct,t as lt}from"./timer.adapter-CcS8xEBd.js";import{t as U}from"./input-DLIzWZj4.js";import{d as ut,f as dt,i as ft,m as pt,o as mt,p as ht,s as W}from"./branding-CaxlVtaJ.js";import{t as gt}from"./chatSounds-DCOu073Z.js";import{a as _t,d as vt,i as yt,l as bt,n as xt,o as St,t as Ct,u as wt}from"./pushClient-BGXuPFFh.js";import{t as Tt}from"./settings-header-button-Dk9ksq2R.js";var Et={name:`book-text`,size:24,node:[[`path`,{d:`M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20`,key:`k3hazp`}],[`path`,{d:`M8 11h8`,key:`vwpz6n`}],[`path`,{d:`M8 7h6`,key:`1f0q6e`}]]};Et.node;var Dt=u(Et),Ot={name:`circle-arrow-up`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]],aliases:[`arrow-up-circle`]};Ot.node;var kt=u(Ot),At={name:`cloud-download`,size:24,node:[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]],aliases:[`download-cloud`]};At.node;var jt=u(At),Mt={name:`command`,size:24,node:[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]};Mt.node;var Nt=u(Mt),Pt={name:`cpu`,size:24,node:[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]};Pt.node;var Ft=u(Pt),It={name:`flask-conical`,size:24,node:[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]};It.node;var Lt=u(It),Rt={name:`info`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]};Rt.node;var zt=u(Rt),Bt={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};Bt.node;var Vt=u(Bt),Ht={name:`message-square-quote`,size:24,node:[[`path`,{d:`M14 14a2 2 0 0 0 2-2V8h-2`,key:`1r06pg`}],[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M8 14a2 2 0 0 0 2-2V8H8`,key:`1jzu5j`}]]};Ht.node;var Ut=u(Ht),Wt={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};Wt.node;var Gt=u(Wt),Kt={name:`plug`,size:24,node:[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]};Kt.node;var qt=u(Kt),Jt={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};Jt.node;var Yt=u(Jt),Xt={name:`power-off`,size:24,node:[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Xt.node;var Zt=u(Xt),Qt={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};Qt.node;var G=u(Qt),$t={name:`type`,size:24,node:[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]};$t.node;var en=u($t),tn={enabled:!1,cloudflaredPath:`cloudflared`,mode:`always-ask`},K=e(t(),1),q=e(d(),1);function nn(e){let t=e.trim();if(t.startsWith(`https://`))try{let e=new URL(t);if(e.protocol!==`https:`)return!1;let n=e.hostname.toLowerCase();return!(n===`localhost`||!n.includes(`.`)||n.startsWith(`.`)||n.endsWith(`.`))}catch{return!1}if(t.startsWith(`mailto:`)){let e=t.slice(7),n=/^[^\s@]+@([^\s@]+)$/.exec(e);if(!n)return!1;let r=n[1].toLowerCase();return!(r===`localhost`||!r.includes(`.`)||r.startsWith(`.`)||r.endsWith(`.`))}return!1}var rn={maxFileSizeMb:100},an=2048,on=`gpt-5.4-mini`;function sn(e){return e===`previous-assistant-reply`||e===`full-transcript`}function cn(e){return e===`auto`||e===`manual`}var ln=[`app_launch`,`project_opened`,`project_created`,`project_removed`,`chat_created`,`chat_deleted`,`message_sent`,`update_checked`,`update_installed`,`update_failed`,`analytics_enabled`,`analytics_disabled`],un=[`current_version`,`environment`,`latest_version`,`custom_port_enabled`,`no_open_enabled`,`password_enabled`,`strict_port_enabled`,`remote_enabled`,`host_enabled`,`share_quick_enabled`,`share_token_enabled`];function dn(){return{name:``,provider:`claude`,model:N(`claude`).defaultModel,modelOptions:{...D},systemPrompt:``,contextScope:`previous-assistant-reply`,triggerMode:`auto`}}function fn(){return{draft:dn(),error:null,pending:!1,confirmDelete:!1}}var J=o()(e=>({editing:{kind:`list`},form:fn(),timeoutDraft:``,loopError:null,setEditing:t=>e({editing:t}),resetForm:t=>e({form:{draft:t,error:null,pending:!1,confirmDelete:!1}}),patchForm:t=>e(e=>({form:{...e.form,...t}})),patchFormDraft:t=>e(e=>({form:{...e.form,draft:{...e.form.draft,...t}}})),setTimeoutDraft:t=>e({timeoutDraft:t}),setLoopError:t=>e({loopError:t})}));function pn(e){return`contextWindow`in e}function mn(e){return`fastMode`in e}function Y(e){let t=e.editing,n=(0,K.useMemo)(()=>t.kind===`edit`?e.subagents.find(e=>e.id===t.id)??null:null,[t,e.subagents]),r=t.kind,i=r!==`list`,a=e.subagents.length===0;return a&&!i?(0,q.jsx)(hn,{onStartCreate:e.onStartCreate}):(0,q.jsxs)(`div`,{className:`flex flex-col gap-6 md:flex-row md:items-start md:gap-8`,children:[a?null:(0,q.jsx)(_n,{subagents:e.subagents,editing:e.editing,onSelect:e.onSelect,onStartCreate:e.onStartCreate}),i?(0,q.jsx)(Cn,{mode:r,subject:r===`edit`?n:null,providerDefaults:e.providerDefaults,availableProviders:e.availableProviders,handlers:e.handlers,onCancelEditing:e.onCancelEditing},r===`edit`?n?.id??`edit`:`create`):(0,q.jsx)(gn,{})]})}function hn(e){return(0,q.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-4 rounded-lg border border-dashed border-border px-6 py-14 text-center`,"data-testid":`subagent-empty`,children:[(0,q.jsx)(`div`,{className:`flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground`,children:(0,q.jsx)(qe,{className:`size-5`,"aria-hidden":!0})}),(0,q.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`No subagents yet`}),(0,q.jsxs)(r,{variant:`default`,size:`sm`,onClick:e.onStartCreate,children:[(0,q.jsx)(nt,{className:`mr-1.5 size-4`}),` Create subagent`]})]})}function gn(){return(0,q.jsx)(`div`,{className:`hidden flex-1 items-center justify-center rounded-lg border border-dashed border-border px-6 py-12 text-center text-sm text-muted-foreground md:flex`,children:`Select a subagent to edit, or create a new one.`})}function _n(e){let t=e.editing.kind===`edit`?e.editing.id:null;return(0,q.jsxs)(`aside`,{className:`flex w-full flex-col gap-2 md:w-64 md:flex-shrink-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsxs)(`span`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,style:{fontVariantNumeric:`tabular-nums`},children:[e.subagents.length,` `,e.subagents.length===1?`agent`:`agents`]}),(0,q.jsxs)(r,{variant:`ghost`,size:`sm`,onClick:e.onStartCreate,"data-testid":`subagent-create`,children:[(0,q.jsx)(nt,{className:`size-4`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Create subagent`})]})]}),(0,q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:e.subagents.map(n=>{let r=n.description?.trim()||(n.contextScope===`previous-assistant-reply`?`Last reply`:`Full transcript`);return(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,"data-testid":`subagent-row:${n.id}`,onClick:()=>e.onSelect(n.id),className:s(`flex w-full flex-col items-start gap-0.5 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-muted`,t===n.id&&`bg-muted`),children:[(0,q.jsxs)(`span`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,q.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:n.name}),(0,q.jsx)(vn,{provider:n.provider})]}),(0,q.jsx)(`span`,{className:`w-full truncate text-xs text-muted-foreground`,children:r})]})},n.id)})})]})}function vn({provider:e}){let t=N(e).label;return(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium tracking-wide text-muted-foreground`,children:[(0,q.jsx)(qe,{className:`size-3`}),` `,t]})}var yn=[{value:`claude`,label:`Claude`},{value:`codex`,label:`Codex`},{value:`openrouter`,label:`OpenRouter`}];function bn(e,t){return t.length===0?e:e.map(e=>e.id===`openrouter`?{...e,models:t.map(e=>({id:e.id,label:e.label}))}:e)}var xn=[{value:`previous-assistant-reply`,label:`Last reply`},{value:`full-transcript`,label:`Full transcript`}],Sn=[{value:`auto`,label:`Auto`},{value:`manual`,label:`Manual`}];function Cn(e){let t=(0,K.useMemo)(()=>e.mode===`edit`&&e.subject?Nn(e.subject):Mn(`claude`,e.providerDefaults,e.availableProviders),[e.mode,e.subject,e.providerDefaults,e.availableProviders]),n=J(e=>e.resetForm),i=J(e=>e.form),a=J(e=>e.patchFormDraft),o=J(e=>e.patchForm);(0,K.useEffect)(()=>{n(t)},[]);let{draft:s,error:c,pending:l,confirmDelete:u}=i,d=c?.field===`name`?c.message:null,f=c?.field===`general`?c.message:null,p=Fn(s,t),h=s.name.trim().length>0&&(e.mode===`create`||p);function _(e){a(e),c?.field===`name`&&`name`in e&&o({error:null})}function v(t){if(t===s.provider)return;let n=Mn(t,e.providerDefaults,e.availableProviders);a({provider:t,model:n.model,modelOptions:n.modelOptions})}function y(e){if(s.provider!==`claude`)return;let t=pn(s.modelOptions)?s.modelOptions:D;a({modelOptions:{...D,...t,reasoningEffort:e}})}function b(e){if(s.provider!==`claude`)return;let t=pn(s.modelOptions)?s.modelOptions:D;a({modelOptions:{...D,...t,contextWindow:e}})}function x(e){if(s.provider!==`codex`)return;let t=mn(s.modelOptions)?s.modelOptions:g;a({modelOptions:{...g,...t,reasoningEffort:e}})}async function w(){if(!(!h||l)){o({pending:!0,error:null});try{let t=e.mode===`create`?await e.handlers.onCreate(s):await e.handlers.onUpdate(e.subject.id,s);t.ok||o({error:Ln(t.error)})}finally{o({pending:!1})}}}async function ee(){if(!(e.mode!==`edit`||!e.subject)){if(!u){o({confirmDelete:!0});return}o({pending:!0});try{await e.handlers.onDelete(e.subject.id)}finally{o({pending:!1,confirmDelete:!1})}}}let E=s.provider===`claude`?{...D,...pn(s.modelOptions)?s.modelOptions:{}}:null,O=s.provider===`codex`?{...g,...mn(s.modelOptions)?s.modelOptions:{}}:null,k=e.availableProviders.find(e=>e.id===s.provider)??N(s.provider);return(0,q.jsxs)(`section`,{className:`flex w-full flex-1 flex-col gap-4`,children:[(0,q.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`h3`,{className:`text-base font-medium text-foreground`,children:e.mode===`create`?`New subagent`:s.name||`Subagent`}),(0,q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Mention with `,(0,q.jsxs)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:[`@agent/`,s.name||`<name>`]}),` in chat.`]})]}),f?(0,q.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive`,children:f}):null,(0,q.jsx)(X,{label:`Name`,hint:d,hintTone:d?`destructive`:`muted`,children:(0,q.jsx)(U,{"data-testid":`subagent-form-name`,value:s.name,onChange:e=>_({name:Rn(e.target.value)}),maxLength:64,placeholder:`reviewer`,className:`font-mono`})}),(0,q.jsx)(X,{label:`Description`,hint:`Optional. Shown next to the name.`,children:(0,q.jsx)(U,{"data-testid":`subagent-form-description`,value:s.description??``,onChange:e=>_({description:e.target.value}),placeholder:`Reviews diffs against the repo style`})}),(0,q.jsx)(X,{label:`Provider`,children:(0,q.jsx)(W,{value:s.provider,onValueChange:e=>{Se(e)&&v(e)},options:yn,size:`sm`})}),(0,q.jsx)(X,{label:`Model`,children:(0,q.jsxs)(B,{value:s.model,onValueChange:e=>_({model:e}),children:[(0,q.jsx)(R,{"data-testid":`subagent-form-model`,className:`w-full md:w-72`,children:(0,q.jsx)(L,{placeholder:`Select a model`})}),(0,q.jsx)(F,{children:k.models.map(e=>(0,q.jsx)(z,{value:e.id,children:e.label},e.id))})]})}),E?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(X,{label:`Reasoning effort`,children:(0,q.jsx)(W,{value:E.reasoningEffort,onValueChange:e=>{C(e)&&y(e)},options:m.map(e=>({value:e.id,label:e.label})),size:`sm`})}),(0,q.jsx)(X,{label:`Context window`,children:(0,q.jsx)(W,{value:E.contextWindow,onValueChange:e=>{S(e)&&b(e)},options:te.map(e=>({value:e.id,label:e.label})),size:`sm`})})]}):null,O?(0,q.jsx)(X,{label:`Reasoning effort`,children:(0,q.jsx)(W,{value:O.reasoningEffort,onValueChange:e=>{T(e)&&x(e)},options:xe.map(e=>({value:e.id,label:e.label})),size:`sm`})}):null,(0,q.jsx)(X,{label:`Context scope`,children:(0,q.jsx)(W,{value:s.contextScope,onValueChange:e=>{sn(e)&&_({contextScope:e})},options:xn,size:`sm`})}),(0,q.jsx)(X,{label:`Trigger`,hint:`Auto: the main agent may delegate on its own. Manual: only runs when you @-mention it.`,children:(0,q.jsx)(W,{value:s.triggerMode??`auto`,onValueChange:e=>{cn(e)&&_({triggerMode:e})},options:Sn,size:`sm`})}),(0,q.jsx)(X,{label:`System prompt`,hint:`What this persona should focus on. Plain text.`,children:(0,q.jsx)(bt,{"data-testid":`subagent-form-system-prompt`,value:s.systemPrompt,onChange:e=>_({systemPrompt:e.target.value}),placeholder:`You are a careful code reviewer...`,rows:6,className:`min-h-32`})}),(0,q.jsx)(X,{label:`Max turns`,hint:`Optional. Caps the agentic turns per run (like Claude Code's per-agent maxTurns). Empty = unbounded. Claude SDK runs stop gracefully at the limit; PTY/Codex runs are aborted.`,children:(0,q.jsx)(U,{"data-testid":`subagent-form-max-turns`,type:`number`,min:1,step:1,value:s.maxTurns?.toString()??``,onChange:e=>{let t=Number.parseInt(e.target.value,10);_({maxTurns:Number.isInteger(t)&&t>0?t:void 0})},placeholder:`unbounded`,className:`w-36`})}),s.provider===`claude`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(X,{label:`Working directory`,hint:`Optional. Relative to the parent chat cwd. Restricts the subagent's filesystem access to this subtree.`,children:(0,q.jsx)(U,{"data-testid":`subagent-form-working-dir`,value:s.workingDir??``,onChange:e=>{let t=e.target.value;_({workingDir:t.length>0?t:void 0})},placeholder:`docs`})}),(0,q.jsx)(X,{label:`Allowed paths`,hint:`Optional. Newline-separated, relative to the parent chat cwd. When set, file tools can only read/write inside these roots.`,children:(0,q.jsx)(bt,{"data-testid":`subagent-form-allowed-paths`,value:(s.allowedPaths??[]).join(`
|
|
1
|
+
import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-CQOZoUwg.js";import{D as n,E as r,F as i,G as a,M as o,O as s,U as c,W as l,j as u}from"./chatFocusPolicy-D5WAGQzz.js";import{t as d}from"./jsx-runtime-DREnUpxT.js";import{$ as f,B as p,C as m,D as h,E as g,F as _,G as v,H as y,J as b,K as x,M as S,N as C,O as w,P as T,Q as ee,R as E,S as te,T as D,U as O,V as k,W as A,X as ne,Y as re,Z as j,_ as ie,a as ae,b as oe,c as se,f as ce,ft as le,i as M,j as N,k as ue,lt as de,m as fe,mt as pe,o as me,pt as he,q as ge,st as _e,t as ve,u as ye,ut as be,w as xe,x as Se,y as Ce,z as we}from"./auth-krfVizJR.js";import{$t as Te,Gt as Ee,Ht as De,Jt as Oe,Kt as ke,Qt as Ae,Ut as je,Wt as Me,Xt as Ne,Yt as Pe,Zt as Fe,a as Ie,en as Le,l as Re,qt as ze,sn as Be,t as Ve,tn as P}from"./asJsonValue-C5MTs1l0.js";import{c as He,d as F,f as Ue,g as I,h as L,l as We,m as R,n as Ge,p as z,r as Ke,u as B,v as V,x as qe}from"./editor-icons-DYs-KAON.js";import{n as H,r as Je,t as Ye}from"./clipboard.adapter-CyzHY22e.js";import{t as Xe}from"./external-link-COo-Uzb1.js";import{i as Ze,r as Qe,t as $e}from"./status-pill-BlXggLew.js";import{t as et}from"./monitor-CIs8RSWK.js";import{l as tt}from"./statusLabel-1tgAYyyt.js";import{t as nt}from"./plus-BFyTSu3o.js";import{_ as rt,a as it,d as at,i as ot,r as st,s as ct,t as lt}from"./timer.adapter-CcS8xEBd.js";import{t as U}from"./input-DLIzWZj4.js";import{d as ut,f as dt,i as ft,m as pt,o as mt,p as ht,s as W}from"./branding-VdNGihTK.js";import{t as gt}from"./chatSounds-DCOu073Z.js";import{a as _t,d as vt,i as yt,l as bt,n as xt,o as St,t as Ct,u as wt}from"./pushClient--9ISlWCZ.js";import{t as Tt}from"./settings-header-button-Dk9ksq2R.js";var Et={name:`book-text`,size:24,node:[[`path`,{d:`M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20`,key:`k3hazp`}],[`path`,{d:`M8 11h8`,key:`vwpz6n`}],[`path`,{d:`M8 7h6`,key:`1f0q6e`}]]};Et.node;var Dt=u(Et),Ot={name:`circle-arrow-up`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]],aliases:[`arrow-up-circle`]};Ot.node;var kt=u(Ot),At={name:`cloud-download`,size:24,node:[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]],aliases:[`download-cloud`]};At.node;var jt=u(At),Mt={name:`command`,size:24,node:[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]};Mt.node;var Nt=u(Mt),Pt={name:`cpu`,size:24,node:[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]};Pt.node;var Ft=u(Pt),It={name:`flask-conical`,size:24,node:[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]};It.node;var Lt=u(It),Rt={name:`info`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]};Rt.node;var zt=u(Rt),Bt={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};Bt.node;var Vt=u(Bt),Ht={name:`message-square-quote`,size:24,node:[[`path`,{d:`M14 14a2 2 0 0 0 2-2V8h-2`,key:`1r06pg`}],[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M8 14a2 2 0 0 0 2-2V8H8`,key:`1jzu5j`}]]};Ht.node;var Ut=u(Ht),Wt={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};Wt.node;var Gt=u(Wt),Kt={name:`plug`,size:24,node:[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]};Kt.node;var qt=u(Kt),Jt={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};Jt.node;var Yt=u(Jt),Xt={name:`power-off`,size:24,node:[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Xt.node;var Zt=u(Xt),Qt={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};Qt.node;var G=u(Qt),$t={name:`type`,size:24,node:[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]};$t.node;var en=u($t),tn={enabled:!1,cloudflaredPath:`cloudflared`,mode:`always-ask`},K=e(t(),1),q=e(d(),1);function nn(e){let t=e.trim();if(t.startsWith(`https://`))try{let e=new URL(t);if(e.protocol!==`https:`)return!1;let n=e.hostname.toLowerCase();return!(n===`localhost`||!n.includes(`.`)||n.startsWith(`.`)||n.endsWith(`.`))}catch{return!1}if(t.startsWith(`mailto:`)){let e=t.slice(7),n=/^[^\s@]+@([^\s@]+)$/.exec(e);if(!n)return!1;let r=n[1].toLowerCase();return!(r===`localhost`||!r.includes(`.`)||r.startsWith(`.`)||r.endsWith(`.`))}return!1}var rn={maxFileSizeMb:100},an=2048,on=`gpt-5.4-mini`;function sn(e){return e===`previous-assistant-reply`||e===`full-transcript`}function cn(e){return e===`auto`||e===`manual`}var ln=[`app_launch`,`project_opened`,`project_created`,`project_removed`,`chat_created`,`chat_deleted`,`message_sent`,`update_checked`,`update_installed`,`update_failed`,`analytics_enabled`,`analytics_disabled`],un=[`current_version`,`environment`,`latest_version`,`custom_port_enabled`,`no_open_enabled`,`password_enabled`,`strict_port_enabled`,`remote_enabled`,`host_enabled`,`share_quick_enabled`,`share_token_enabled`];function dn(){return{name:``,provider:`claude`,model:N(`claude`).defaultModel,modelOptions:{...D},systemPrompt:``,contextScope:`previous-assistant-reply`,triggerMode:`auto`}}function fn(){return{draft:dn(),error:null,pending:!1,confirmDelete:!1}}var J=o()(e=>({editing:{kind:`list`},form:fn(),timeoutDraft:``,loopError:null,setEditing:t=>e({editing:t}),resetForm:t=>e({form:{draft:t,error:null,pending:!1,confirmDelete:!1}}),patchForm:t=>e(e=>({form:{...e.form,...t}})),patchFormDraft:t=>e(e=>({form:{...e.form,draft:{...e.form.draft,...t}}})),setTimeoutDraft:t=>e({timeoutDraft:t}),setLoopError:t=>e({loopError:t})}));function pn(e){return`contextWindow`in e}function mn(e){return`fastMode`in e}function Y(e){let t=e.editing,n=(0,K.useMemo)(()=>t.kind===`edit`?e.subagents.find(e=>e.id===t.id)??null:null,[t,e.subagents]),r=t.kind,i=r!==`list`,a=e.subagents.length===0;return a&&!i?(0,q.jsx)(hn,{onStartCreate:e.onStartCreate}):(0,q.jsxs)(`div`,{className:`flex flex-col gap-6 md:flex-row md:items-start md:gap-8`,children:[a?null:(0,q.jsx)(_n,{subagents:e.subagents,editing:e.editing,onSelect:e.onSelect,onStartCreate:e.onStartCreate}),i?(0,q.jsx)(Cn,{mode:r,subject:r===`edit`?n:null,providerDefaults:e.providerDefaults,availableProviders:e.availableProviders,handlers:e.handlers,onCancelEditing:e.onCancelEditing},r===`edit`?n?.id??`edit`:`create`):(0,q.jsx)(gn,{})]})}function hn(e){return(0,q.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-4 rounded-lg border border-dashed border-border px-6 py-14 text-center`,"data-testid":`subagent-empty`,children:[(0,q.jsx)(`div`,{className:`flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground`,children:(0,q.jsx)(qe,{className:`size-5`,"aria-hidden":!0})}),(0,q.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`No subagents yet`}),(0,q.jsxs)(r,{variant:`default`,size:`sm`,onClick:e.onStartCreate,children:[(0,q.jsx)(nt,{className:`mr-1.5 size-4`}),` Create subagent`]})]})}function gn(){return(0,q.jsx)(`div`,{className:`hidden flex-1 items-center justify-center rounded-lg border border-dashed border-border px-6 py-12 text-center text-sm text-muted-foreground md:flex`,children:`Select a subagent to edit, or create a new one.`})}function _n(e){let t=e.editing.kind===`edit`?e.editing.id:null;return(0,q.jsxs)(`aside`,{className:`flex w-full flex-col gap-2 md:w-64 md:flex-shrink-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsxs)(`span`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,style:{fontVariantNumeric:`tabular-nums`},children:[e.subagents.length,` `,e.subagents.length===1?`agent`:`agents`]}),(0,q.jsxs)(r,{variant:`ghost`,size:`sm`,onClick:e.onStartCreate,"data-testid":`subagent-create`,children:[(0,q.jsx)(nt,{className:`size-4`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Create subagent`})]})]}),(0,q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:e.subagents.map(n=>{let r=n.description?.trim()||(n.contextScope===`previous-assistant-reply`?`Last reply`:`Full transcript`);return(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,"data-testid":`subagent-row:${n.id}`,onClick:()=>e.onSelect(n.id),className:s(`flex w-full flex-col items-start gap-0.5 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-muted`,t===n.id&&`bg-muted`),children:[(0,q.jsxs)(`span`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,q.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:n.name}),(0,q.jsx)(vn,{provider:n.provider})]}),(0,q.jsx)(`span`,{className:`w-full truncate text-xs text-muted-foreground`,children:r})]})},n.id)})})]})}function vn({provider:e}){let t=N(e).label;return(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium tracking-wide text-muted-foreground`,children:[(0,q.jsx)(qe,{className:`size-3`}),` `,t]})}var yn=[{value:`claude`,label:`Claude`},{value:`codex`,label:`Codex`},{value:`openrouter`,label:`OpenRouter`}];function bn(e,t){return t.length===0?e:e.map(e=>e.id===`openrouter`?{...e,models:t.map(e=>({id:e.id,label:e.label}))}:e)}var xn=[{value:`previous-assistant-reply`,label:`Last reply`},{value:`full-transcript`,label:`Full transcript`}],Sn=[{value:`auto`,label:`Auto`},{value:`manual`,label:`Manual`}];function Cn(e){let t=(0,K.useMemo)(()=>e.mode===`edit`&&e.subject?Nn(e.subject):Mn(`claude`,e.providerDefaults,e.availableProviders),[e.mode,e.subject,e.providerDefaults,e.availableProviders]),n=J(e=>e.resetForm),i=J(e=>e.form),a=J(e=>e.patchFormDraft),o=J(e=>e.patchForm);(0,K.useEffect)(()=>{n(t)},[]);let{draft:s,error:c,pending:l,confirmDelete:u}=i,d=c?.field===`name`?c.message:null,f=c?.field===`general`?c.message:null,p=Fn(s,t),h=s.name.trim().length>0&&(e.mode===`create`||p);function _(e){a(e),c?.field===`name`&&`name`in e&&o({error:null})}function v(t){if(t===s.provider)return;let n=Mn(t,e.providerDefaults,e.availableProviders);a({provider:t,model:n.model,modelOptions:n.modelOptions})}function y(e){if(s.provider!==`claude`)return;let t=pn(s.modelOptions)?s.modelOptions:D;a({modelOptions:{...D,...t,reasoningEffort:e}})}function b(e){if(s.provider!==`claude`)return;let t=pn(s.modelOptions)?s.modelOptions:D;a({modelOptions:{...D,...t,contextWindow:e}})}function x(e){if(s.provider!==`codex`)return;let t=mn(s.modelOptions)?s.modelOptions:g;a({modelOptions:{...g,...t,reasoningEffort:e}})}async function w(){if(!(!h||l)){o({pending:!0,error:null});try{let t=e.mode===`create`?await e.handlers.onCreate(s):await e.handlers.onUpdate(e.subject.id,s);t.ok||o({error:Ln(t.error)})}finally{o({pending:!1})}}}async function ee(){if(!(e.mode!==`edit`||!e.subject)){if(!u){o({confirmDelete:!0});return}o({pending:!0});try{await e.handlers.onDelete(e.subject.id)}finally{o({pending:!1,confirmDelete:!1})}}}let E=s.provider===`claude`?{...D,...pn(s.modelOptions)?s.modelOptions:{}}:null,O=s.provider===`codex`?{...g,...mn(s.modelOptions)?s.modelOptions:{}}:null,k=e.availableProviders.find(e=>e.id===s.provider)??N(s.provider);return(0,q.jsxs)(`section`,{className:`flex w-full flex-1 flex-col gap-4`,children:[(0,q.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`h3`,{className:`text-base font-medium text-foreground`,children:e.mode===`create`?`New subagent`:s.name||`Subagent`}),(0,q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Mention with `,(0,q.jsxs)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:[`@agent/`,s.name||`<name>`]}),` in chat.`]})]}),f?(0,q.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive`,children:f}):null,(0,q.jsx)(X,{label:`Name`,hint:d,hintTone:d?`destructive`:`muted`,children:(0,q.jsx)(U,{"data-testid":`subagent-form-name`,value:s.name,onChange:e=>_({name:Rn(e.target.value)}),maxLength:64,placeholder:`reviewer`,className:`font-mono`})}),(0,q.jsx)(X,{label:`Description`,hint:`Optional. Shown next to the name.`,children:(0,q.jsx)(U,{"data-testid":`subagent-form-description`,value:s.description??``,onChange:e=>_({description:e.target.value}),placeholder:`Reviews diffs against the repo style`})}),(0,q.jsx)(X,{label:`Provider`,children:(0,q.jsx)(W,{value:s.provider,onValueChange:e=>{Se(e)&&v(e)},options:yn,size:`sm`})}),(0,q.jsx)(X,{label:`Model`,children:(0,q.jsxs)(B,{value:s.model,onValueChange:e=>_({model:e}),children:[(0,q.jsx)(R,{"data-testid":`subagent-form-model`,className:`w-full md:w-72`,children:(0,q.jsx)(L,{placeholder:`Select a model`})}),(0,q.jsx)(F,{children:k.models.map(e=>(0,q.jsx)(z,{value:e.id,children:e.label},e.id))})]})}),E?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(X,{label:`Reasoning effort`,children:(0,q.jsx)(W,{value:E.reasoningEffort,onValueChange:e=>{C(e)&&y(e)},options:m.map(e=>({value:e.id,label:e.label})),size:`sm`})}),(0,q.jsx)(X,{label:`Context window`,children:(0,q.jsx)(W,{value:E.contextWindow,onValueChange:e=>{S(e)&&b(e)},options:te.map(e=>({value:e.id,label:e.label})),size:`sm`})})]}):null,O?(0,q.jsx)(X,{label:`Reasoning effort`,children:(0,q.jsx)(W,{value:O.reasoningEffort,onValueChange:e=>{T(e)&&x(e)},options:xe.map(e=>({value:e.id,label:e.label})),size:`sm`})}):null,(0,q.jsx)(X,{label:`Context scope`,children:(0,q.jsx)(W,{value:s.contextScope,onValueChange:e=>{sn(e)&&_({contextScope:e})},options:xn,size:`sm`})}),(0,q.jsx)(X,{label:`Trigger`,hint:`Auto: the main agent may delegate on its own. Manual: only runs when you @-mention it.`,children:(0,q.jsx)(W,{value:s.triggerMode??`auto`,onValueChange:e=>{cn(e)&&_({triggerMode:e})},options:Sn,size:`sm`})}),(0,q.jsx)(X,{label:`System prompt`,hint:`What this persona should focus on. Plain text.`,children:(0,q.jsx)(bt,{"data-testid":`subagent-form-system-prompt`,value:s.systemPrompt,onChange:e=>_({systemPrompt:e.target.value}),placeholder:`You are a careful code reviewer...`,rows:6,className:`min-h-32`})}),(0,q.jsx)(X,{label:`Max turns`,hint:`Optional. Caps the agentic turns per run (like Claude Code's per-agent maxTurns). Empty = unbounded. Claude SDK runs stop gracefully at the limit; PTY/Codex runs are aborted.`,children:(0,q.jsx)(U,{"data-testid":`subagent-form-max-turns`,type:`number`,min:1,step:1,value:s.maxTurns?.toString()??``,onChange:e=>{let t=Number.parseInt(e.target.value,10);_({maxTurns:Number.isInteger(t)&&t>0?t:void 0})},placeholder:`unbounded`,className:`w-36`})}),s.provider===`claude`?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(X,{label:`Working directory`,hint:`Optional. Relative to the parent chat cwd. Restricts the subagent's filesystem access to this subtree.`,children:(0,q.jsx)(U,{"data-testid":`subagent-form-working-dir`,value:s.workingDir??``,onChange:e=>{let t=e.target.value;_({workingDir:t.length>0?t:void 0})},placeholder:`docs`})}),(0,q.jsx)(X,{label:`Allowed paths`,hint:`Optional. Newline-separated, relative to the parent chat cwd. When set, file tools can only read/write inside these roots.`,children:(0,q.jsx)(bt,{"data-testid":`subagent-form-allowed-paths`,value:(s.allowedPaths??[]).join(`
|
|
2
2
|
`),onChange:e=>{let t=e.target.value.split(/\r?\n/).map(e=>e.trim()).filter(e=>e.length>0);_({allowedPaths:t.length>0?t:void 0})},placeholder:`docs
|
|
3
3
|
wiki`,rows:3})})]}):null,(0,q.jsxs)(`footer`,{className:`flex flex-wrap items-center justify-end gap-2 pt-2`,children:[(0,q.jsx)(r,{variant:`ghost`,size:`sm`,onClick:e.onCancelEditing,children:`Cancel`}),e.mode===`edit`?(0,q.jsx)(r,{variant:`destructive`,size:`sm`,"data-testid":`subagent-form-delete`,disabled:l,onClick:ee,children:u?`Confirm delete`:`Delete`}):null,(0,q.jsx)(r,{variant:`default`,size:`sm`,"data-testid":`subagent-form-save`,disabled:!h||l,onClick:w,children:l?`Saving…`:`Save`})]})]})}function X(e){return(0,q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,q.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:e.label}),e.children,e.hint?(0,q.jsx)(`span`,{className:s(`text-xs`,e.hintTone===`destructive`?`text-destructive`:`text-muted-foreground`),children:e.hint}):null]})}var Z=[],wn={claude:{model:N(`claude`).defaultModel,modelOptions:{...D},planMode:!1},codex:{model:N(`codex`).defaultModel,modelOptions:{...g},planMode:!1},openrouter:{model:h,modelOptions:{},planMode:!1}};function Tn(e){let t=P(e=>e.settings?.subagents??Z),n=P(e=>e.settings?.providerDefaults??wn),r=P(ze),i=ae(De(e=>e.models)),a=(0,K.useMemo)(()=>bn(_([...w],r),i),[r,i]),o=J(e=>e.editing),s=J(e=>e.setEditing),c=(0,K.useMemo)(()=>({onCreate:async t=>{let n=await e.state.socket.command({type:`subagent.create`,input:t});return n.ok&&s({kind:`edit`,id:n.subagent.id}),n},onUpdate:async(t,n)=>await e.state.socket.command({type:`subagent.update`,id:t,patch:{...n,maxTurns:n.maxTurns??null}}),onDelete:async t=>{await e.state.socket.command({type:`subagent.delete`,id:t}),s({kind:`list`})}}),[e.state.socket,s]),l=(0,K.useCallback)(e=>{s({kind:`edit`,id:e})},[s]),u=(0,K.useCallback)(()=>{s({kind:`create`})},[s]),d=(0,K.useCallback)(()=>{s({kind:`list`})},[s]);return(0,q.jsxs)(`div`,{className:`flex flex-col gap-6 px-6 py-6`,children:[(0,q.jsx)(An,{subagents:t,handleWriteAppSettings:e.state.handleWriteAppSettings}),(0,q.jsx)(Y,{subagents:t,providerDefaults:n,availableProviders:a,editing:o,onSelect:l,onStartCreate:u,onCancelEditing:d,handlers:c})]})}var En=`__none__`,Dn=30,On=86400,kn=600;function An(e){let t=P(e=>e.settings?.subagentRuntime),n=t?Math.round(t.runTimeoutMs/1e3):kn,r=t?.defaultLoopSubagentId??null,i=J(e=>e.timeoutDraft),a=J(e=>e.setTimeoutDraft),o=J(e=>e.loopError),s=J(e=>e.setLoopError);(0,K.useEffect)(()=>{a(String(n))},[n]);function c(){let t=Number(i);if(!Number.isInteger(t)||t<Dn||t>On){a(String(n)),s(`Timeout must be a whole number of seconds between ${Dn} and ${On}.`);return}s(null),t!==n&&e.handleWriteAppSettings({subagentRuntime:{runTimeoutMs:t*1e3}}).catch(e=>s(e instanceof Error?e.message:`Unable to save subagent runtime settings.`))}function l(t){s(null);let n=t===En?null:t;e.handleWriteAppSettings({subagentRuntime:{defaultLoopSubagentId:n}}).catch(e=>s(e instanceof Error?e.message:`Unable to save default loop subagent.`))}return(0,q.jsxs)(`section`,{className:`flex flex-col gap-4 rounded-lg border border-border/60 bg-card/40 p-4`,children:[(0,q.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:`Loop & runtime`}),(0,q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Applies to background subagent runs and the autonomous `,(0,q.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono`,children:`/loop`}),`.`]})]}),o?(0,q.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive`,children:o}):null,(0,q.jsx)(X,{label:`Stall timeout (seconds)`,hint:`A subagent run is aborted only after this long with no streamed activity — not a total wall-clock cap. A steadily-working run is never killed.`,children:(0,q.jsx)(U,{type:`number`,inputMode:`numeric`,min:Dn,max:On,value:i,onChange:e=>a(e.target.value),onBlur:c,onKeyDown:e=>{e.key===`Enter`&&(c(),e.currentTarget.blur())},className:`w-full md:w-48 tabular-nums`})}),(0,q.jsx)(X,{label:`Default loop subagent`,hint:`The subagent setup_loop delegates each chunk to when no explicit id is given.`,children:(0,q.jsxs)(B,{value:r??En,onValueChange:l,children:[(0,q.jsx)(R,{className:`w-full md:w-72`,children:(0,q.jsx)(L,{placeholder:`None`})}),(0,q.jsxs)(F,{children:[(0,q.jsx)(z,{value:En,children:`None (require explicit id)`}),e.subagents.map(e=>(0,q.jsx)(z,{value:e.id,children:e.name},e.id))]})]})})]})}var jn=new Set([`EMPTY_NAME`,`INVALID_CHAR`,`RESERVED_NAME`,`DUPLICATE_NAME`,`TOO_LONG`]);function Mn(e,t,n){if(e===`claude`){let r=t?.claude;return{name:``,provider:e,model:r?.model??n?.find(e=>e.id===`claude`)?.defaultModel??N(`claude`).defaultModel,modelOptions:{...r?.modelOptions??{...D}},systemPrompt:``,contextScope:`previous-assistant-reply`,triggerMode:`auto`}}if(e===`openrouter`)return{name:``,provider:e,model:t?.openrouter?.model??n?.find(e=>e.id===`openrouter`)?.defaultModel??N(`openrouter`).defaultModel,modelOptions:{},systemPrompt:``,contextScope:`previous-assistant-reply`,triggerMode:`auto`};let r=t?.codex;return{name:``,provider:e,model:r?.model??n?.find(e=>e.id===`codex`)?.defaultModel??N(`codex`).defaultModel,modelOptions:{...r?.modelOptions??{...g}},systemPrompt:``,contextScope:`previous-assistant-reply`,triggerMode:`auto`}}function Nn(e){return{name:e.name,description:e.description,provider:e.provider,model:e.model,modelOptions:e.modelOptions,systemPrompt:e.systemPrompt,contextScope:e.contextScope,triggerMode:e.triggerMode,workingDir:e.workingDir,allowedPaths:e.allowedPaths,maxTurns:e.maxTurns}}var Pn=(e,t)=>{if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0};function Fn(e,t){return e.name!==t.name||(e.description??``)!==(t.description??``)||e.provider!==t.provider||e.model!==t.model||e.systemPrompt!==t.systemPrompt||e.contextScope!==t.contextScope||(e.triggerMode??`auto`)!==(t.triggerMode??`auto`)||(e.workingDir??``)!==(t.workingDir??``)||!Pn(e.allowedPaths,t.allowedPaths)||(e.maxTurns??null)!==(t.maxTurns??null)||!In(e.modelOptions,t.modelOptions)}function In(e,t){if(!Be(e)||!Be(t))return!1;let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n)if(e[r]!==t[r])return!1;return!0}function Ln(e){return jn.has(e.code)?{field:`name`,message:e.message}:{field:`general`,message:e.message}}function Rn(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,`-`).slice(0,64)}function Q({title:e,description:t,children:n,bordered:r=!0,alignStart:i=!1}){return(0,q.jsx)(`div`,{className:r?`border-t border-border`:void 0,children:(0,q.jsxs)(`div`,{className:s(`flex flex-col gap-4 py-5 md:flex-row md:justify-between md:gap-8`,i?`md:items-start`:`md:items-center`),children:[(0,q.jsxs)(`div`,{className:`min-w-0 max-w-xl`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e}),(0,q.jsx)(`div`,{className:`mt-1 text-13 text-muted-foreground`,children:t})]}),(0,q.jsx)(`div`,{className:`flex items-center justify-start md:shrink-0 md:justify-end`,children:n})]})})}function zn({icon:e,message:t}){return(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-md border border-dashed px-6 py-10 text-center`,children:[(0,q.jsx)(e,{className:`mb-3 h-8 w-8 text-muted-foreground`,"aria-hidden":!0}),(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t})]})}function Bn({children:e}){return(0,q.jsx)(`ul`,{className:`flex flex-col divide-y rounded-md border`,children:e})}function Vn({label:e,onEdit:t,onDelete:n}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(r,{variant:`ghost`,size:`sm`,onClick:t,"aria-label":`Edit ${e}`,children:(0,q.jsx)(tt,{className:`h-4 w-4`})}),(0,q.jsx)(r,{variant:`ghost`,size:`sm`,onClick:n,"aria-label":`Delete ${e}`,children:(0,q.jsx)(de,{className:`h-4 w-4`})})]})}var Hn=new Set;function Un(e){return{name:e?.name??``,transport:e?.transport??`stdio`,command:e?.transport===`stdio`?e.command:``,argsText:e?.transport===`stdio`?e.args.join(`
|
|
4
4
|
`):``,envText:e?.transport===`stdio`?Object.entries(e.env).map(([e,t])=>`${e}=${t}`).join(`
|