herm-tui 1.7.2-dev.1 → 1.7.2-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +1 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -4121,7 +4121,7 @@ The child returns whatever partial result it has so far.`,yes:"interrupt",danger
4121
4121
  `)[0].slice(0,200)}`}):null]},r.id)})]}):null,d2.events.length>0?$jsxs($Fragment,{children:[$jsx("box",{height:1,marginTop:1,children:$jsx("text",{fg:theme.textMuted,children:`Events (${d2.events.length})`})}),d2.events.map((e)=>$jsx("box",{height:1,children:$jsxs("text",{children:[$jsx("span",{fg:theme.textMuted,children:`${ago(e.created_at).padEnd(10)} `}),$jsx("span",{fg:theme.text,children:e.kind}),e.payload?$jsx("span",{fg:theme.textMuted,children:` ${JSON.stringify(e.payload)}`}):null]})},e.id))]}):null,d2.comments.length>0?$jsxs($Fragment,{children:[$jsx("box",{height:1,marginTop:1,children:$jsx("text",{fg:theme.textMuted,children:`Comments (${d2.comments.length})`})}),d2.comments.map((c,i)=>$jsxs("box",{flexDirection:"column",children:[$jsx("box",{height:1,children:$jsx("text",{fg:theme.textMuted,children:`${c.author} \xB7 ${ago(c.at)}`})}),$jsx("text",{wrapMode:"word",children:c.body})]},i))]}):null,p.on&&cur==="comment"?$jsx("box",{height:1,marginTop:1,children:$jsx("text",{fg:theme.accent,children:"Enter add comment"})}):null]})}),$jsx("box",{height:1,children:$jsx("text",{fg:theme.textMuted,children:p.on?"Tab/\u2191\u2193 field Enter edit Esc grid a assign c comment l log":"Tab into pane a assign c comment u unblock d archive l log N child"})})]})}),Kanban=import_react80.memo((props)=>{let theme=useTheme().theme,gw=useGateway(),dialog=useDialog(),toast=useToast(),dims=useTerminalDimensions(),keys=useKeys(),[boards,setBoards]=import_react80.useState(listBoards),[data2,setData]=import_react80.useState(()=>new Map(boards.map((b2)=>[b2.slug,boardOf(b2.slug)]))),[diags,setDiags]=import_react80.useState(()=>new Map),[masks,setMasks]=import_react80.useState(()=>maskFromPrefs(load2().kanban?.masks)),[open2,setOpen]=import_react80.useState(()=>{let saved=load2().kanban?.open;if(saved)return new Set(saved);let init=currentBoard();return new Set(listBoards().filter((b2)=>b2.slug===init||[...boardOf(b2.slug).values()].some((v2)=>v2.length>0)).map((b2)=>b2.slug))}),[at,setAt]=import_react80.useState(currentBoard),[tier,setTier]=import_react80.useState("grid"),[col,setCol]=import_react80.useState(0),[row2,setRow]=import_react80.useState(0),[chip,setChip]=import_react80.useState(0),[paneSel,setPaneSel]=import_react80.useState(0),[pane,setPane]=import_react80.useState(null),outer=import_react80.useRef(null),load4=import_react80.useCallback(()=>{let bs=listBoards();setBoards(bs),setData(new Map(bs.map((b2)=>[b2.slug,boardOf(b2.slug)]))),setPane((p)=>p?.kind==="detail"?((d2)=>d2?{...p,d:d2}:null)(detailOf(p.slug,p.d.id)):p),Promise.all(bs.map((b2)=>gw.request("shell.exec",{command:`hermes kanban --board ${q3(b2.slug)} diagnostics --json`}).then((r)=>r.code===0?parseDiagnostics(r.stdout):[]).catch(()=>[]).then((rows3)=>[b2.slug,indexDiags(rows3)]))).then((pairs)=>setDiags(new Map(pairs)))},[gw]);import_react80.useEffect(load4,[load4]),import_react80.useEffect(()=>{persist(masks,open2)},[masks,open2]);let maskOf=(s)=>masks.get(s)??EMPTY2,wide=dims.width>=160,maxH=Math.max(8,dims.height-16),sections=import_react80.useMemo(()=>{let built=boards.map((b2)=>{let d2=data2.get(b2.slug)??new Map,flat=STATUSES.flatMap((s)=>d2.get(s)??[]),total=flat.length,who=[...new Set(flat.map((t2)=>t2.assignee).filter((v2)=>!!v2))].sort(),pri=[...new Set(flat.map((t2)=>t2.priority).filter((n)=>n>0))].sort((a,z2)=>z2-a),chips=[...who.map((v2)=>({kind:"who",v:v2})),...pri.map((v2)=>({kind:"pri",v:v2})),...STATUSES.map((v2)=>({kind:"status",v:v2}))],m2=maskOf(b2.slug),cols3=STATUSES.filter((s)=>admits(m2.status,s)).map((s)=>({status:s,tasks:(d2.get(s)??[]).filter((t2)=>pass(t2,m2))})).filter((c)=>wide||c.tasks.length>0),shown=cols3.reduce((a,c)=>a+c.tasks.length,0),tall=cols3.reduce((a,c)=>Math.max(a,c.tasks.length),0);return{board:b2,cols:cols3,chips,total,shown,running:d2.get("running")?.length??0,cap:Math.min(maxH,Math.max(5,3+2*tall))}});return[...built.filter((s)=>s.total>0),...built.filter((s)=>s.total===0)]},[boards,data2,masks,wide,maxH]),idx=sections.findIndex((s)=>s.board.slug===at),sec3=sections[idx]??sections[0],cols2=sec3?.cols??[],clampCol=Math.min(col,Math.max(0,cols2.length-1)),cur=cols2[clampCol],task=tier==="grid"||tier==="pane"?cur?.tasks[Math.min(row2,Math.max(0,(cur?.tasks.length??1)-1))]:void 0,grand=sections.reduce((a,s)=>a+s.total,0),running2=sections.reduce((a,s)=>a+s.running,0);import_react80.useEffect(()=>{if(pane?.kind!=="detail")return;if(tier!=="grid"&&tier!=="pane"){setPane(null);return}if(!task){setPane(null);return}if(pane.slug===at&&pane.d.id===task.id)return;let d2=detailOf(at,task.id);setPane(d2?{kind:"detail",slug:at,d:d2}:null),setPaneSel(0)},[task?.id,at,tier]),import_react80.useEffect(()=>{if(!props.focused||running2===0)return;let t2=setInterval(load4,3000);return()=>clearInterval(t2)},[props.focused,running2,load4]),import_react80.useEffect(()=>{outer.current?.scrollChildIntoView(`kb-sec-${at}`)},[at,open2]);let sh=import_react80.useCallback((argv,ok)=>gw.request("shell.exec",{command:`hermes kanban --board ${q3(at)} ${argv}`}).then((r)=>{if(r.code!==0)throw Error((r.stderr||r.stdout||`exit ${r.code}`).trim());if(ok)toast.show({variant:"success",message:ok});return resetKanban(),load4(),r.stdout}).catch((e)=>void toast.show({variant:"error",message:trunc5(e.message,120)})),[gw,toast,load4,at]),patchDirect=import_react80.useCallback((id,p,ok)=>{try{if(!patchTask(at,id,p))return void toast.show({variant:"error",message:`no such task: ${id}`});toast.show({variant:"success",message:ok}),load4()}catch(e){toast.show({variant:"error",message:trunc5(e.message,120)})}},[at,toast,load4]),enterTop=(s)=>{setAt(s.board.slug),setTier("head"),setChip(0),setRow(0)},enterBottom=(s)=>{if(setAt(s.board.slug),setChip(Math.max(0,s.chips.length-1)),open2.has(s.board.slug)&&s.shown>0){let nc=Math.min(col,Math.max(0,s.cols.length-1));setTier("grid"),setCol(nc),setRow(Math.max(0,(s.cols[nc]?.tasks.length??1)-1));return}if(open2.has(s.board.slug)){setTier("filter");return}setTier("head")},stepBoard=(d2)=>{let n=idx+d2;return n<0||n>=sections.length?null:sections[n]},goBoard=import_react80.useCallback((d2)=>{let n=(idx+d2+sections.length)%sections.length,s=sections[n];setAt(s.board.slug),setTier("head"),setCol(0),setRow(0),setChip(0),setOpen((o)=>o.has(s.board.slug)?o:new Set(o).add(s.board.slug))},[idx,sections]),flip=import_react80.useCallback((c)=>setMasks((m2)=>{let cur2=m2.get(at)??EMPTY2,who=new Map(cur2.who),pri=new Map(cur2.pri),status=new Map(cur2.status),g=c.kind==="who"?who:c.kind==="pri"?pri:status,next2=cycle(g.get(c.v)??"off");next2==="off"?g.delete(c.v):g.set(c.v,next2);let out=new Map(m2);return out.set(at,{who,pri,status}),setRow(0),out}),[at]),toggle=import_react80.useCallback((s)=>setOpen((o)=>{let n=new Set(o);return n.has(s)?n.delete(s):n.add(s),n}),[]),newBoard=import_react80.useCallback(()=>openTextPrompt(dialog,{title:"New board",label:"Slug (a-z, 0-9, -_)"}).then((v2)=>{if(!v2)return;return gw.request("shell.exec",{command:`hermes kanban boards create ${q3(v2)}`}).then((r)=>r.code===0?(toast.show({variant:"success",message:`Board '${v2}' created`}),resetKanban(),load4(),setAt(v2),setTier("head")):Promise.reject(Error((r.stderr||r.stdout).trim()))).catch((e)=>toast.show({variant:"error",message:trunc5(e.message,120)}))}),[dialog,gw,toast,load4]),live=import_react80.useRef({task,at,sec:sec3});live.current={task,at,sec:sec3};let create=import_react80.useCallback((parent2)=>openCreateTask(dialog,{assignees:assignees(live.current.at),parent:parent2?{id:parent2.id,title:parent2.title}:void 0}).then((d2)=>{if(!d2)return;let ws=d2.workspace.kind==="scratch"?"":d2.workspace.kind==="worktree"?"--workspace worktree":`--workspace ${q3(`dir:${d2.workspace.path}`)}`,flags=[d2.assignee?`--assignee ${q3(d2.assignee)}`:"",d2.body?`--body ${q3(d2.body)}`:"",d2.priority?`--priority ${d2.priority}`:"",d2.parent?`--parent ${q3(d2.parent)}`:"",d2.triage?"--triage":"",d2.tenant?`--tenant ${q3(d2.tenant)}`:"",ws,d2.maxRuntime?`--max-runtime ${q3(d2.maxRuntime)}`:"",...d2.skills.map((s)=>`--skill ${q3(s)}`)].filter(Boolean).join(" ");return sh(`create ${q3(d2.title)} ${flags}`.trim(),`Created${d2.triage?" (triage)":""}${d2.assignee?` \u2192 ${d2.assignee}`:""}`)}),[dialog,sh]),assign=import_react80.useCallback((t2)=>{let opts=[{title:"(unassigned)",value:"none"},...assignees(live.current.at).map((n)=>({title:n,value:n}))];dialog.replace($jsx(DialogSelect,{title:`Assign ${t2.id}`,options:opts,current:t2.assignee??"none",placeholder:"Search profiles\u2026",onSelect:(o)=>{dialog.clear(),sh(`assign ${q3(t2.id)} ${q3(o.value)}`,o.value==="none"?`Unassigned ${t2.id}`:`${t2.id} \u2192 ${o.value}`)}}))},[dialog,sh]),comment=import_react80.useCallback((t2)=>openTextPrompt(dialog,{title:`Comment on ${t2.id}`,label:t2.title}).then((v2)=>v2&&sh(`comment ${q3(t2.id)} ${q3(v2)} --author user`,"Comment added")),[dialog,sh]),unblock=import_react80.useCallback((t2)=>{if(t2.status!=="blocked"&&t2.status!=="scheduled")return void toast.show({variant:"info",message:`${t2.id} is ${t2.status}, not blocked/scheduled`});if(t2.status==="scheduled")return void sh(`unblock ${q3(t2.id)}`,`Released ${t2.id}`);return openTextPrompt(dialog,{title:`Unblock ${t2.id}`,label:"Answer (posted as comment, then task \u2192 ready)"}).then((v2)=>{if(v2)return sh(`comment ${q3(t2.id)} ${q3(v2)} --author user`)}).then(()=>sh(`unblock ${q3(t2.id)}`,`Unblocked ${t2.id}`))},[dialog,sh,toast]),archive=import_react80.useCallback((t2)=>openConfirm(dialog,{title:"Archive task?",danger:!0,yes:"archive",body:`${t2.id} \xB7 ${trunc5(t2.title,60)}
4122
4122
 
4123
4123
  Moves to 'archived' and ends any open run. Children stay; their dependency on this task is treated as satisfied.`}).then((ok)=>{if(ok)sh(`archive ${q3(t2.id)}`,`Archived ${t2.id}`)}),[dialog,sh]),parseSpecify=(out)=>out.split(`
4124
- `).flatMap((l)=>l.trim()?[JSON.parse(l)]:[]),specify=import_react80.useCallback((t2)=>{if(t2.status!=="triage")return void toast.show({variant:"info",message:`${t2.id} is ${t2.status}, not triage`});return sh(`specify ${q3(t2.id)} --json`).then((out)=>{if(out==null)return;let r=parseSpecify(out)[0];if(!r)return;if(!r.ok)return void toast.show({variant:"error",message:`specify ${r.task_id}: ${trunc5(r.reason??"failed",100)}`});toast.show({variant:"success",message:r.new_title?`Specified ${r.task_id} \u2192 ${trunc5(r.new_title,60)}`:`Specified ${r.task_id} \u2192 todo`})})},[sh,toast]),specifyAll=import_react80.useCallback(()=>{let triage=live.current.sec?.cols.find((c)=>c.status==="triage")?.tasks.length??0;if(triage===0)return void toast.show({variant:"info",message:`No 'triage' tasks on ${live.current.at}`});return openConfirm(dialog,{title:`Specify all \xB7 ${live.current.at}`,body:`${triage} task${triage===1?"":"s"} in 'triage'. Auxiliary LLM expands each body and promotes to todo.`,yes:"specify"}).then((go)=>{if(!go)return;return sh("specify --all --json").then((out)=>{if(out==null)return;let rows3=parseSpecify(out),ok=rows3.filter((r)=>r.ok).length,bad=rows3.length-ok;toast.show({variant:ok===0&&bad>0?"error":"success",message:`Specified ${ok}/${rows3.length}${bad?` (${bad} failed)`:""}`})})})},[dialog,sh,toast]),dispatch=import_react80.useCallback(()=>{let ready=live.current.sec?.cols.find((c)=>c.status==="ready")?.tasks.length??0;if(ready===0)return void toast.show({variant:"info",message:`No 'ready' tasks on ${live.current.at}`});return openConfirm(dialog,{title:`Dispatch \xB7 ${live.current.at}`,body:`${ready} task${ready===1?"":"s"} in 'ready'. Spawns one worker per task (one pass).`,yes:"dispatch"}).then((ok)=>{if(ok)sh("dispatch --json",`Dispatched (${ready} ready)`)})},[dialog,sh,toast]),showLog=import_react80.useCallback((t2)=>{let s=live.current.at,text2=tailLogOf(s,t2.id);if(text2==null)return void toast.show({variant:"info",message:`No worker log for ${t2.id}`});setPane({kind:"log",slug:s,id:t2.id,text:text2})},[toast]),editTitle=import_react80.useCallback((t2)=>openTextPrompt(dialog,{title:"Edit title",label:t2.id,initial:t2.title}).then((v2)=>v2!==null&&v2!==void 0&&patchDirect(t2.id,{title:v2},`Updated ${t2.id}`)),[dialog,patchDirect]),editBody=import_react80.useCallback((t2)=>openTextPrompt(dialog,{title:"Edit body",label:t2.id,initial:t2.body??""}).then((v2)=>{if(v2===null||v2===void 0)return;patchDirect(t2.id,{body:v2},`Updated ${t2.id}`)}),[dialog,patchDirect]),editPriority=import_react80.useCallback((t2)=>{let opts=Array.from({length:10},(_2,i)=>({title:i===0?"P0 (none)":`P${i}`,value:String(i)}));dialog.replace($jsx(DialogSelect,{title:`Priority for ${t2.id}`,options:opts,current:String(t2.priority),filterable:!1,onSelect:(o)=>{dialog.clear(),patchDirect(t2.id,{priority:Number(o.value)},`${t2.id} \u2192 P${o.value}`)}}))},[dialog,patchDirect]),editResult=import_react80.useCallback((t2)=>{if(t2.status!=="done")return void toast.show({variant:"info",message:`${t2.id} is not done`});return openTextPrompt(dialog,{title:"Edit result",label:t2.id,initial:t2.result??""}).then((v2)=>{if(v2==null)return;sh(`edit ${q3(t2.id)} --result ${q3(v2)}`,`Updated ${t2.id} result`)})},[dialog,sh,toast]),editStatus=import_react80.useCallback((t2)=>{let opts=[];if(t2.status!=="done")opts.push({title:"done",value:"complete",description:"mark complete (prompts for result)"});if(t2.status!=="blocked")opts.push({title:"blocked",value:"block",description:"mark blocked (prompts for reason)"});if(t2.status!=="scheduled")opts.push({title:"scheduled",value:"schedule",description:"park until externally unblocked (prompts for reason)"});if(t2.status==="blocked"||t2.status==="scheduled")opts.push({title:"ready",value:"unblock",description:t2.status==="scheduled"?"release back to ready":"return to ready"});opts.push({title:"archived",value:"archive",description:"archive (terminal)"}),dialog.replace($jsx(DialogSelect,{title:`Status for ${t2.id}`,options:opts,current:t2.status,filterable:!1,onSelect:async(o)=>{if(dialog.clear(),o.value==="complete"){let res=await openTextPrompt(dialog,{title:`Complete ${t2.id}`,label:"Result (optional)",initial:t2.result??""}),flag=res?` --result ${q3(res)}`:"";sh(`complete ${q3(t2.id)}${flag}`,`Completed ${t2.id}`);return}if(o.value==="block"){let r=await openTextPrompt(dialog,{title:`Block ${t2.id}`,label:"Reason (optional, posted as comment)"}),arg=r?` ${q3(r)}`:"";sh(`block ${q3(t2.id)}${arg}`,`Blocked ${t2.id}`);return}if(o.value==="schedule"){let r=await openTextPrompt(dialog,{title:`Schedule ${t2.id}`,label:"Reason (optional, posted as comment)"}),arg=r?` ${q3(r)}`:"";sh(`schedule ${q3(t2.id)}${arg}`,`Scheduled ${t2.id}`);return}if(o.value==="unblock")return void sh(`unblock ${q3(t2.id)}`,`Unblocked ${t2.id}`);if(o.value==="archive")return void archive(t2)}}))},[dialog,sh,archive]),editParents=import_react80.useCallback((t2)=>{let cur2=(pane?.kind==="detail"&&pane.d.id===t2.id?pane.d:detailOf(at,t2.id))?.parents??[],d2=data2.get(at)??new Map,opts=STATUSES.flatMap((s)=>d2.get(s)??[]).filter((x2)=>x2.id!==t2.id).map((x2)=>({title:x2.id,description:trunc5(x2.title,50),value:x2.id,category:cur2.includes(x2.id)?"linked":"available"}));dialog.replace($jsx(DialogSelect,{title:`Parents for ${t2.id}`,options:opts,placeholder:"Select to toggle link\u2026",onSelect:(o)=>{if(dialog.clear(),cur2.includes(o.value))sh(`unlink ${q3(o.value)} ${q3(t2.id)}`,`Unlinked ${o.value}`);else sh(`link ${q3(o.value)} ${q3(t2.id)}`,`Linked ${o.value}`)}}))},[dialog,sh,data2,at,pane]),openField=import_react80.useCallback((f,t2)=>{if(f==="title")return void editTitle(t2);if(f==="body")return void editBody(t2);if(f==="assignee")return assign(t2);if(f==="priority")return editPriority(t2);if(f==="status")return editStatus(t2);if(f==="parents")return editParents(t2);if(f==="result")return void editResult(t2);if(f==="comment")return void comment(t2)},[editTitle,editBody,assign,editPriority,editStatus,editParents,editResult,comment]),bumpPriority=import_react80.useCallback((t2,d2)=>{let next2=Math.max(0,Math.min(9,t2.priority+d2));if(next2===t2.priority)return;patchDirect(t2.id,{priority:next2},`${t2.id} \u2192 P${next2}`)},[patchDirect]),ACTS=import_react80.useMemo(()=>[{key:"n",title:"New task",when:()=>!0,run:()=>void create()},{key:"N",title:"New child",when:(t2)=>!!t2,run:(t2)=>void create(t2)},{key:"a",title:"Assign",when:(t2)=>!!t2,run:(t2)=>void assign(t2)},{key:"c",title:"Comment",when:(t2)=>!!t2,run:(t2)=>void comment(t2)},{key:"s",title:"Specify",when:(t2)=>t2?.status==="triage",run:(t2)=>void specify(t2)},{key:"S",title:"Specify all",when:()=>!0,run:()=>void specifyAll()},{key:"u",title:"Unblock",when:(t2)=>t2?.status==="blocked"||t2?.status==="scheduled",run:(t2)=>void unblock(t2)},{key:"d",title:"Archive",when:(t2)=>!!t2,run:(t2)=>void archive(t2)},{key:"l",title:"Worker log",when:(t2)=>!!t2,run:(t2)=>showLog(t2)},{key:"b",title:"New board",when:()=>!0,run:()=>void newBoard()},{key:"D",title:"Dispatch",when:()=>!0,run:()=>void dispatch()}],[create,assign,comment,specify,specifyAll,unblock,archive,showLog,newBoard,dispatch]),isOpen=open2.has(at),paneOpen=pane?.kind==="detail",paneFields=paneOpen?fieldsFor(pane.d):[];useKeyboard((key2)=>{if(!props.focused||dialog.open())return;if(key2.name==="escape"&&pane){if(tier==="pane"){setTier("grid");return}return setPane(null)}if(keys.match("list.refresh",key2))return load4();if(key2.name==="tab"){if(paneOpen&&tier!=="pane"){setTier("pane"),setPaneSel(0);return}if(tier==="pane"){let n=paneFields.length;if(n===0)return;let d2=key2.shift?-1:1;setPaneSel((s)=>(s+d2+n)%n);return}return goBoard(key2.shift?-1:1)}if(tier==="pane"){let t3=live.current.task;if(!t3||!paneOpen)return;let f=paneFields[Math.min(paneSel,paneFields.length-1)];if(key2.name==="up"){if(f==="priority")return bumpPriority(t3,1);let n=paneFields.length;if(n===0)return;return setPaneSel((s)=>(s-1+n)%n)}if(key2.name==="down"){if(f==="priority")return bumpPriority(t3,-1);let n=paneFields.length;if(n===0)return;return setPaneSel((s)=>(s+1)%n)}if(key2.name==="return")return openField(f,t3);let hit2=ACTS.find((a)=>a.key===key2.raw&&a.when(t3));if(hit2)return hit2.run(t3);return}if(key2.name==="space"||key2.name===" "){if(tier==="head")return toggle(at);if(tier==="filter"&&sec3?.chips[chip])return flip(sec3.chips[chip]);return}if(key2.name==="down"){if(tier==="head"){if(isOpen)return setTier("filter");let n2=stepBoard(1);return n2?enterTop(n2):void 0}if(tier==="filter"){if(sec3&&sec3.shown>0){setTier("grid"),setRow(0);return}let n2=stepBoard(1);return n2?enterTop(n2):void 0}if(row2<(cur?.tasks.length??1)-1)return setRow((r)=>r+1);let n=stepBoard(1);return n?enterTop(n):void 0}if(key2.name==="up"){if(tier==="head"){let p=stepBoard(-1);return p?enterBottom(p):void 0}if(tier==="filter")return setTier("head");if(row2>0)return setRow((r)=>r-1);return setTier("filter")}if(key2.name==="left"){if(tier==="filter")return setChip((c)=>Math.max(0,c-1));if(tier==="grid")return setCol((c)=>{let n=Math.max(0,c-1);return setRow(0),n});return}if(key2.name==="right"){if(tier==="filter")return setChip((c)=>Math.min((sec3?.chips.length??1)-1,c+1));if(tier==="grid")return setCol((c)=>{let n=Math.min(cols2.length-1,c+1);return setRow(0),n});return}if(key2.name==="return"){if(tier==="head")return toggle(at);if(tier==="filter"&&sec3?.chips[chip])return flip(sec3.chips[chip]);if(task)return setPane((p)=>p?.kind==="detail"&&p.d.id===task.id?null:((d2)=>d2?{kind:"detail",slug:at,d:d2}:null)(detailOf(at,task.id)));return}let t2=live.current.task,hit=ACTS.find((a)=>a.key===key2.raw&&a.when(t2));if(hit)return hit.run(t2)});let hint=import_react80.useMemo(()=>{let t2=task;return[tier==="pane"?"Esc grid":"Tab board",tier==="head"?"\u2191\u2193 nav Space fold":tier==="filter"?"\u2190\u2192 chip Space toggle":tier==="pane"?"Tab/\u2191\u2193 field Enter edit Esc grid":"\u2190\u2192\u2191\u2193 nav Enter detail",...ACTS.filter((a)=>a.when(t2)).map((a)=>`${a.key} ${a.title.toLowerCase()}`),`${keys.print("list.refresh")} reload`].join(" ")},[ACTS,keys,task,tier]),onHead=import_react80.useCallback((s)=>{setAt(s),setTier("head"),toggle(s)},[toggle]),onChip=import_react80.useCallback((s,i,c)=>{setAt(s),setTier("filter"),setChip(i),flip(c)},[flip]),onPick=import_react80.useCallback((s,ci,ri,id)=>{setAt(s),setTier("grid"),setCol(ci),setRow(ri),setOpen((o)=>o.has(s)?o:new Set(o).add(s));let d2=detailOf(s,id);if(d2)setPane({kind:"detail",slug:s,d:d2})},[]);return $jsxs("box",{flexDirection:"column",flexGrow:1,minWidth:0,children:[$jsxs("box",{flexDirection:"row",flexGrow:1,children:[$jsx(TabShell,{title:`Kanban \xB7 ${sections.length} board${sections.length===1?"":"s"} \xB7 ${grand} task${grand===1?"":"s"}${running2?` \xB7 ${running2} running`:""}`,children:$jsx("scrollbox",{ref:outer,scrollY:!0,flexGrow:1,verticalScrollbarOptions:NOBAR,children:$jsx("box",{flexDirection:"column",width:"100%",children:sections.map((s)=>{let on=s.board.slug===at,secOpen=open2.has(s.board.slug),m2=maskOf(s.board.slug),filt=m2.who.size+m2.pri.size+m2.status.size,dg=diags.get(s.board.slug)??EMPTY_DIAG;return $jsxs("box",{id:`kb-sec-${s.board.slug}`,flexDirection:"column",flexShrink:0,marginBottom:1,children:[$jsx("box",{height:1,onMouseDown:()=>onHead(s.board.slug),backgroundColor:on&&tier==="head"?theme.backgroundElement:void 0,children:$jsxs("text",{children:[$jsx("span",{fg:on?theme.accent:theme.textMuted,children:secOpen?"\u25BE ":"\u25B8 "}),$jsx("span",{fg:on?theme.primary:theme.text,children:$jsx("strong",{children:s.board.name})}),$jsx("span",{fg:theme.textMuted,children:s.total===0?" \xB7 empty":` \xB7 ${filt?`${s.shown}/`:""}${s.total} task${s.total===1?"":"s"}${s.running?` \xB7 ${s.running} running`:""}`})]})}),secOpen?s.total===0?$jsx("box",{height:1,marginLeft:2,children:$jsxs("text",{fg:theme.textMuted,children:["no tasks \u2014 ",$jsx("span",{fg:theme.accent,children:"n"})," to create one here"]})}):$jsxs($Fragment,{children:[$jsx(FilterBar,{chips:s.chips,mask:m2,on:on&&tier==="filter",sel:on?Math.min(chip,s.chips.length-1):-1,onPick:(i)=>onChip(s.board.slug,i,s.chips[i])}),s.cols.length>0?$jsx("box",{flexDirection:"row",height:s.cap,gap:1,children:s.cols.map((c,ci)=>$jsx(Column,{slug:s.board.slug,status:c.status,tasks:c.tasks,diags:dg,on:on&&(tier==="grid"||tier==="pane")&&ci===clampCol,sel:on?row2:0,onPick:(ri)=>onPick(s.board.slug,ci,ri,c.tasks[ri].id)},c.status))}):$jsx("box",{height:1,marginLeft:2,children:$jsx("text",{fg:theme.textMuted,children:"all columns hidden"})})]}):null]},s.board.slug)})})})}),pane?$jsx(SidePane,{pane,on:tier==="pane",sel:paneSel,diags:pane.kind==="detail"?diags.get(pane.slug)?.get(pane.d.id)??EMPTY_DIAGS:EMPTY_DIAGS}):null]}),$jsx(HintBar,{raw:hint})]})});var Automation=import_react82.memo((props)=>{let keys=useKeys(),labels=SUB_TABS[AUTOMATION_TAB];import_react82.useEffect(()=>{if(props.sub>=labels.length)props.setSub(0)},[props.sub,labels.length]);let hint=`${keys.print("tab.prev")}/${keys.print("tab.next")} group \xB7 shift+\u2190/\u2192 sub`;return $jsxs("box",{flexDirection:"column",flexGrow:1,minWidth:0,children:[$jsx(SubTabBar,{tabs:labels,active:props.sub,onChange:props.setSub,hint}),$jsxs("box",{flexGrow:1,minWidth:0,flexDirection:"column",children:[$jsx(Pane2,{visible:props.sub===0,children:$jsx(Kanban,{focused:!!props.focused&&props.sub===0})}),$jsx(Pane2,{visible:props.sub===1,children:$jsx(Agents,{focused:!!props.focused&&props.sub===1,sessionId:props.sessionId,onSwitchProfile:props.onSwitchProfile})}),$jsx(Pane2,{visible:props.sub===2,children:$jsx(Cron,{focused:!!props.focused&&props.sub===2})})]})]})}),Pane2=({visible,children:children2})=>visible?$jsx("box",{flexGrow:1,minWidth:0,minHeight:0,flexDirection:"column",children:children2}):null;var import_react94=__toESM(require_react_production(),1);var import_react84=__toESM(require_react_production(),1);init_lane();var int=(lo,hi,what=`${lo}\u2013${hi}`)=>(raw)=>{let n=Number(raw);if(!Number.isInteger(n))return`expected integer ${what}`;if(n<lo||n>hi)return`expected ${what}`;return null},float=(lo,hi)=>(raw)=>{let n=Number(raw);if(!Number.isFinite(n))return`expected number ${lo}\u2013${hi}`;if(n<lo||n>hi)return`expected ${lo}\u2013${hi}`;return null},oneOf=(...opts)=>(raw)=>opts.includes(raw)?null:`expected one of: ${opts.join(" | ")}`,nonNeg=(raw)=>{let n=Number(raw);return Number.isFinite(n)&&n>=0?null:"expected \u2265 0"},RULES={"compression.threshold":float(0.1,0.95),"compression.target_ratio":float(0.05,0.9),"prompt_caching.cache_ttl":(raw)=>/^\d+[smhd]$/.test(raw.trim())?null:"expected duration e.g. 5m, 1h","agent.max_turns":int(1,1e4),"delegation.max_iterations":int(1,1e4),"delegation.max_concurrent_children":int(1,64),"delegation.max_spawn_depth":int(1,3),"agent.gateway_timeout":nonNeg,"agent.gateway_timeout_warning":nonNeg,"agent.gateway_notify_interval":nonNeg,"agent.restart_drain_timeout":nonNeg,"delegation.child_timeout_seconds":int(30,86400),"browser.command_timeout":int(1,600),"approvals.timeout":int(1,3600),"security.tirith_timeout":int(1,120),"agent.api_max_retries":int(0,20),"tool_output.max_bytes":int(1024,1e7),"tool_output.max_lines":int(10,1e5),"sessions.retention_days":int(1,3650),"sessions.min_interval_hours":int(1,720),"agent.service_tier":oneOf("","fast","standard"),"display.busy_input_mode":oneOf("queue","steer","interrupt"),"display.details_mode":oneOf("hidden","collapsed","expanded"),"display.thinking_mode":oneOf("collapsed","truncated","full"),"display.tool_progress":oneOf("off","new","all","verbose"),"display.final_response_markdown":oneOf("render","strip","raw"),"logging.level":oneOf("DEBUG","INFO","WARNING","ERROR"),"approvals.mode":oneOf("manual","ask","yolo","deny"),"code_execution.mode":oneOf("project","strict")},check=(key2,raw)=>RULES[key2]?.(raw)??null;init_schema();init_lane();var SELECTS={"terminal.backend":["local","docker","ssh","modal","daytona","singularity","vercel_sandbox"],"tts.provider":["edge","elevenlabs","openai","neutts","xai","mistral"],"display.skin":[...SKINS],"logging.level":["DEBUG","INFO","WARNING","ERROR"],"agent.reasoning_effort":["","none","minimal","low","medium","high","xhigh"],"display.busy_input_mode":["queue","steer","interrupt"],"display.details_mode":["hidden","collapsed","expanded"],"display.thinking_mode":["collapsed","truncated","full"],"display.tool_progress":["off","new","all","verbose"],"approvals.mode":["manual","ask","yolo","deny"]},get4=(obj,path7)=>{let cur=obj;for(let p of path7.split("."))if(cur&&typeof cur==="object"&&!Array.isArray(cur))cur=cur[p];else return;return cur},classify2=(key2,t2)=>{if(route(key2).via==="readonly")return"readonly";if(SELECTS[key2])return"select";if(t2==="bool")return"boolean";if(t2==="int"||t2==="float")return"number";return"string"},labelOf=(key2)=>{let raw=SCHEMA[key2]?.group??key2.split(".")[0];return key2.startsWith(`${raw}.`)?key2.slice(raw.length+1):key2},buildFields=(user)=>{let seen=new Set,out=[];for(let key2 of SCHEMA_KEYS){let s=SCHEMA[key2],uv=get4(user,key2),set2=uv!==void 0;out.push({key:key2,label:labelOf(key2),type:classify2(key2,s.type),value:set2?uv:s.default,set:set2,doc:s.doc,effect:s.effect,options:SELECTS[key2]}),seen.add(key2)}let walk=(obj,prefix="")=>{for(let[k2,v2]of Object.entries(obj)){let key2=prefix?`${prefix}.${k2}`:k2;if(v2&&typeof v2==="object"&&!Array.isArray(v2)){if(SCHEMA[key2]?.type==="dict"){seen.add(key2);continue}walk(v2,key2);continue}if(seen.has(key2))continue;out.push({key:key2,label:labelOf(key2),type:Array.isArray(v2)?"readonly":typeof v2==="boolean"?"boolean":typeof v2==="number"?"number":"string",value:v2,set:!0,doc:"",effect:"live"})}};return walk(user),out},MERGE={approvals:"security",privacy:"security",checkpoints:"agent",context:"agent",cron:"agent",network:"agent",model_catalog:"general",onboarding:"general",human_delay:"display",dashboard:"display",tool_output:"agent",prompt_caching:"compression",code_execution:"terminal",lsp:"agent",x_search:"agent",slack:"platforms",telegram:"platforms",mattermost:"platforms",discord:"platforms",whatsapp:"platforms",matrix:"platforms"},rawGroupOf=(key2)=>SCHEMA[key2]?.group??(key2.includes(".")?key2.split(".")[0]:"general"),groupOf=(key2)=>{let raw=rawGroupOf(key2);return MERGE[raw]??raw},sections=(group,fields)=>{let by=new Map;for(let f of fields){let r=rawGroupOf(f.key);if(!by.has(r))by.set(r,[]);by.get(r).push(f)}if(by.size<=1)return[{head:null,items:fields}];return[...by.keys()].sort((a,b2)=>a===group?-1:b2===group?1:a.localeCompare(b2)).map((r)=>({head:r,items:by.get(r)}))},GROUPS=(()=>{let g=new Set(["general"]);for(let k2 of SCHEMA_KEYS)g.add(groupOf(k2));return[...g]})(),EFFECT_GLYPH={live:"",session:"\u21BB",restart:"\u27F3"};init_lane();var AUX_TASKS=[{key:"vision",label:"Vision",hint:"Image analysis"},{key:"web_extract",label:"Web Extract",hint:"Page summarization"},{key:"compression",label:"Compression",hint:"Context compaction"},{key:"session_search",label:"Session Search",hint:"Recall queries"},{key:"skills_hub",label:"Skills Hub",hint:"Skill search"},{key:"approval",label:"Approval",hint:"Smart auto-approve"},{key:"mcp",label:"MCP",hint:"MCP tool routing"},{key:"title_generation",label:"Title Gen",hint:"Session titles"},{key:"curator",label:"Curator",hint:"Skill-usage review"}],dig=(o,...path7)=>path7.reduce((c,p)=>c&&typeof c==="object"?c[p]:void 0,o),str2=(v2)=>typeof v2==="string"?v2:"",readSlots=(raw)=>{let main2={kind:"main",key:"main",label:"Main model",hint:"Primary agent model",provider:str2(dig(raw,"model","provider")),model:str2(dig(raw,"model","default"))||str2(dig(raw,"model","name")),auto:!1},aux=AUX_TASKS.map((t2)=>{let p=str2(dig(raw,"auxiliary",t2.key,"provider"));return{kind:"aux",key:t2.key,label:t2.label,hint:t2.hint,provider:p,model:str2(dig(raw,"auxiliary",t2.key,"model")),auto:p===""||p==="auto"}});return[main2,...aux]},assign=async(gw,slot,provider,model)=>{if(slot==="main"){let r=await gw.request("config.set",{key:"model",value:`${model} --provider ${provider} --global`,session_id:void 0});return{ok:["model.default","model.provider"],failed:[],warnings:[],warning:r.warning}}return writeConfig(gw,[{key:`auxiliary.${slot}.provider`,to:provider},{key:`auxiliary.${slot}.model`,to:model}])},resetAux=(gw,slot)=>{let keys=slot==="all"?AUX_TASKS.map((t2)=>t2.key):[slot];return writeConfig(gw,keys.flatMap((k2)=>[{key:`auxiliary.${k2}.provider`,to:"auto"},{key:`auxiliary.${k2}.model`,to:""}]))};var import_react83=__toESM(require_react_production(),1);var ModelPickerDialog=(props)=>{let dialog=useDialog(),toast=useToast(),theme=useTheme().theme,[data2,setData]=import_react83.useState(null),[step,setStep]=import_react83.useState("provider"),[provider,setProvider]=import_react83.useState(null),[global2,setGlobal]=import_react83.useState(!1);import_react83.useEffect(()=>{props.gw.request("model.options").then(setData).catch(()=>setData({providers:[]}))},[props.gw]);let apply=import_react83.useCallback((model,prov)=>{if(props.onApply)return void props.onApply(prov,model).catch((e)=>toast.show({variant:"error",message:e.message}));let value=`${model} --provider ${prov}${global2?" --global":""}`;props.gw.request("config.set",global2?{key:"model",value,session_id:void 0}:{key:"model",value}).then((r)=>{if(toast.show({variant:"success",message:`model \u2192 ${r.value??model}${global2?" (global)":""}`}),r.warning)toast.show({variant:"warning",message:r.warning})}).catch((e)=>toast.show({variant:"error",message:e.message}))},[props.gw,props.onApply,global2,toast]),onKey=import_react83.useCallback((k2)=>{if(k2.name==="tab"&&!props.onApply)return setGlobal((g)=>!g),!0;if(k2.name==="left"&&step==="model")return setStep("provider"),!0;return!1},[step,props.onApply]),footer=props.onApply?$jsx("text",{fg:theme.textMuted,children:step==="model"?"\u2190: providers":" "}):$jsxs("text",{fg:theme.textMuted,children:[$jsx("span",{children:"Scope: "}),$jsx("span",{fg:global2?theme.warning:theme.accent,children:global2?"global (persists to config)":"this session"}),$jsxs("span",{children:[" \xB7 Tab: toggle",step==="model"?" \xB7 \u2190: providers":""]})]});if(!data2)return $jsx("box",{width:50,padding:1,children:$jsx("text",{children:"Loading models\u2026"})});if(step==="provider"){let options2=(data2.providers??[]).toSorted((a,b2)=>Number(Boolean(b2.is_current))-Number(Boolean(a.is_current))).map((p2)=>({title:p2.name,value:p2.slug,description:p2.total_models?`${p2.total_models} models`:void 0,category:p2.is_current?"Current":"Available"}));return $jsx(DialogSelect,{title:props.title??"Switch Provider",options:options2,current:data2.provider,onSelect:(o)=>{setProvider(o.value),setStep("model")},onKey,placeholder:"Search providers...",footer})}let p=data2.providers?.find((pp)=>pp.slug===provider),options=(p?.models??[]).map((m2)=>({title:m2,value:m2}));return $jsx(DialogSelect,{title:props.title?`${props.title} \xB7 ${p?.name??provider}`:`Switch Model (${p?.name??provider})`,options,current:provider===data2.provider?data2.model:void 0,onSelect:(o)=>{if(provider)apply(o.value,provider);dialog.clear()},onKey,placeholder:"Search models...",footer})},openModelPicker=(dialog,gw,opts)=>{dialog.replace($jsx(ModelPickerDialog,{gw,title:opts?.title,onApply:opts?.onApply}))};var flatten=(obj,prefix="")=>Object.entries(obj).flatMap(([k2,v2])=>{let key2=prefix?`${prefix}.${k2}`:k2;if(v2&&typeof v2==="object"&&!Array.isArray(v2))return flatten(v2,key2);return[[key2,v2]]}),setNested=(obj,path7,val)=>{let parts2=path7.split("."),cur=obj;for(let i=0;i<parts2.length-1;i++){if(!cur[parts2[i]]||typeof cur[parts2[i]]!=="object")cur[parts2[i]]={};cur=cur[parts2[i]]}cur[parts2[parts2.length-1]]=val},getNested=(obj,path7)=>{let parts2=path7.split("."),cur=obj;for(let p of parts2)if(cur&&typeof cur==="object"&&!Array.isArray(cur))cur=cur[p];else return;return cur},FieldRow=import_react84.memo((props)=>{let theme=useTheme().theme,f=props.field,bg2=props.active?theme.backgroundElement:void 0,indicator=props.active?"\u25B8 ":" ",mark2=props.changed?"\u25CF ":f.set?"\xB7":" ",markFg=props.changed?theme.warning:theme.textMuted,display=()=>{if(props.editing)return props.buf+"\u2588";if(f.type==="readonly"){let n=Array.isArray(f.value)?f.value.length:f.value&&typeof f.value==="object"?Object.keys(f.value).length:0;return n===0?"\u2014":`${n} item${n===1?"":"s"}`}if(f.type==="boolean")return f.value?"\u2713 ON":"\u2717 OFF";return String(f.value??"")},hint=()=>{if(props.readonly||f.type==="readonly")return"\uD83D\uDD12";if(f.type==="boolean")return"[space]";if(f.type==="select")return"[h/l]";return"[enter]"},ro=props.readonly||f.type==="readonly",valFg=ro||!f.set?theme.textMuted:f.type==="boolean"?f.value?theme.success:theme.error:theme.text,labelFg=ro?theme.textMuted:props.active?theme.accent:theme.text,lead=4+(props.badge!==void 0?12:0),glyph=props.active?EFFECT_GLYPH[f.effect]:"";return $jsxs("box",{id:props.id,flexDirection:"column",backgroundColor:bg2,children:[$jsxs("box",{flexDirection:"row",height:1,children:[$jsx(Col,{w:2,fg:markFg,children:mark2}),$jsx(Col,{w:2,fg:props.active?theme.primary:theme.text,children:indicator}),props.badge!==void 0?$jsx(Col,{w:12,fg:theme.textMuted,children:props.badge}):null,$jsx(Col,{w:40,fg:labelFg,children:f.label}),$jsx(Col,{grow:!0,min:6,fg:valFg,children:display()}),$jsx(Col,{w:2,fg:theme.textMuted,children:glyph}),$jsx(Col,{w:9,fg:theme.textMuted,right:!0,children:props.active?hint():""})]}),props.error?$jsxs("box",{flexDirection:"row",height:1,children:[$jsx(Col,{w:lead+40,fg:theme.textMuted,children:""}),$jsx(Col,{grow:!0,min:6,fg:theme.error,children:`\u2717 ${props.error}`})]}):props.active&&f.doc?$jsxs("box",{flexDirection:"row",minHeight:1,children:[$jsx("box",{width:lead,flexShrink:0}),$jsx("box",{width:40,flexShrink:0,minHeight:1,children:$jsx("text",{wrapMode:"word",fg:theme.textMuted,children:f.doc})})]}):null]})}),SlotRow=import_react84.memo((p)=>{let theme=useTheme().theme,main2=p.s.kind==="main",val=main2?`${p.s.provider||"(unset)"} \xB7 ${p.s.model||"(unset)"}`:p.s.auto?"auto (use main model)":`${p.s.provider} \xB7 ${p.s.model||"(provider default)"}`;return $jsxs("box",{id:p.id,flexDirection:"row",height:1,backgroundColor:p.on?theme.backgroundElement:void 0,children:[$jsx(Col,{w:2,fg:p.on?theme.primary:theme.text,children:p.on?"\u25B8 ":" "}),$jsx(Col,{w:2,fg:main2?theme.primary:theme.textMuted,children:main2?"\u2605":" "}),$jsx(Col,{w:16,fg:p.on?theme.accent:theme.text,children:p.s.label}),$jsx(Col,{w:22,fg:theme.textMuted,children:p.s.hint}),$jsx(Col,{grow:!0,min:10,fg:p.s.auto?theme.textMuted:theme.text,children:val}),$jsx(Col,{w:14,fg:theme.textMuted,right:!0,children:p.on?main2?"[enter]":"[enter] [x]":""})]})}),Config=import_react84.memo((props)=>{let theme=useTheme().theme,gw=useGateway(),toast=useToast(),dialog=useDialog(),[raw,setRaw]=import_react84.useState({}),[original,setOriginal]=import_react84.useState({}),[yaml,setYaml]=import_react84.useState(""),[mode,setMode]=import_react84.useState("form"),[cat,setCat]=import_react84.useState(0),[cursor,setCursor]=import_react84.useState(0),[editing,setEditing]=import_react84.useState(!1),[buf,setBuf]=import_react84.useState(""),[err,setErr]=import_react84.useState({}),[searching,setSearching]=import_react84.useState(!1),[query,setQuery]=import_react84.useState(""),[focus,setFocus]=import_react84.useState("categories"),[managed,setManaged]=import_react84.useState(null);import_react84.useEffect(()=>{managedSystem().then(setManaged)},[]);let load4=import_react84.useCallback(()=>{gw.request("config.get",{key:"full"}).then((res)=>{let parsed=res.config??{};setRaw(structuredClone(parsed)),setOriginal(structuredClone(parsed)),setYaml($stringify(parsed)),setErr({})}).catch(()=>{setRaw({}),setOriginal({}),setYaml("")})},[gw]);import_react84.useEffect(()=>{load4()},[load4]);let all=buildFields(raw),grouped=all.reduce((map,f)=>{let g=groupOf(f.key);if(!map.has(g))map.set(g,[]);return map.get(g).push(f),map},new Map(GROUPS.map((g)=>[g,[]]))),groups=[...grouped.keys()];groups.splice(1,0,"models");let active=groups[cat]??groups[0],onSlots=active==="models"&&!searching,slots=readSlots(raw),secs=searching&&query.trim()?[{head:null,items:all.filter((f)=>f.key.toLowerCase().includes(query.toLowerCase()))}]:sections(active,grouped.get(active)??[]),fields=secs.flatMap((s)=>s.items),count3=onSlots?slots.length:fields.length,follow=useFollow("cfg"),catFollow=useFollow("cfg-cat"),changed=(key2)=>JSON.stringify(getNested(raw,key2))!==JSON.stringify(getNested(original,key2)),nChanged=all.reduce((n,f)=>n+(changed(f.key)?1:0),0),update=(key2,val)=>{let next2=structuredClone(raw);setNested(next2,key2,val),setRaw(next2),setYaml($stringify(next2))},fmt3=(v2)=>v2===void 0?"\u2014":Array.isArray(v2)?v2.join(", "):String(v2),save2=async()=>{if(managed){toast.show({variant:"error",message:`Managed by ${managed} \u2014 edit configuration.nix`});return}let nErr=Object.keys(err).length;if(nErr>0){toast.show({variant:"error",message:`${nErr} invalid field${nErr===1?"":"s"}`});return}let target=mode==="yaml"?$parse(yaml)??{}:raw,diffs=flatten(target).filter(([key2])=>JSON.stringify(getNested(target,key2))!==JSON.stringify(getNested(original,key2))).map(([key2,val])=>({key:key2,from:getNested(original,key2),to:val}));if(diffs.length===0){toast.show({variant:"info",message:"No changes"});return}let body=diffs.map((d2)=>`${d2.key}: ${fmt3(d2.from)} \u2192 ${fmt3(d2.to)}`).join(`
4124
+ `).flatMap((l)=>l.trim()?[JSON.parse(l)]:[]),specify=import_react80.useCallback((t2)=>{if(t2.status!=="triage")return void toast.show({variant:"info",message:`${t2.id} is ${t2.status}, not triage`});return sh(`specify ${q3(t2.id)} --json`).then((out)=>{if(out==null)return;let r=parseSpecify(out)[0];if(!r)return;if(!r.ok)return void toast.show({variant:"error",message:`specify ${r.task_id}: ${trunc5(r.reason??"failed",100)}`});toast.show({variant:"success",message:r.new_title?`Specified ${r.task_id} \u2192 ${trunc5(r.new_title,60)}`:`Specified ${r.task_id} \u2192 todo`})})},[sh,toast]),specifyAll=import_react80.useCallback(()=>{let triage=live.current.sec?.cols.find((c)=>c.status==="triage")?.tasks.length??0;if(triage===0)return void toast.show({variant:"info",message:`No 'triage' tasks on ${live.current.at}`});return openConfirm(dialog,{title:`Specify all \xB7 ${live.current.at}`,body:`${triage} task${triage===1?"":"s"} in 'triage'. Auxiliary LLM expands each body and promotes to todo.`,yes:"specify"}).then((go)=>{if(!go)return;return sh("specify --all --json").then((out)=>{if(out==null)return;let rows3=parseSpecify(out),ok=rows3.filter((r)=>r.ok).length,bad=rows3.length-ok;toast.show({variant:ok===0&&bad>0?"error":"success",message:`Specified ${ok}/${rows3.length}${bad?` (${bad} failed)`:""}`})})})},[dialog,sh,toast]),dispatch=import_react80.useCallback(()=>{let ready=live.current.sec?.cols.find((c)=>c.status==="ready")?.tasks.length??0;if(ready===0)return void toast.show({variant:"info",message:`No 'ready' tasks on ${live.current.at}`});return openConfirm(dialog,{title:`Dispatch \xB7 ${live.current.at}`,body:`${ready} task${ready===1?"":"s"} in 'ready'. Spawns one worker per task (one pass).`,yes:"dispatch"}).then((ok)=>{if(ok)sh("dispatch --json",`Dispatched (${ready} ready)`)})},[dialog,sh,toast]),showLog=import_react80.useCallback((t2)=>{let s=live.current.at,text2=tailLogOf(s,t2.id);if(text2==null)return void toast.show({variant:"info",message:`No worker log for ${t2.id}`});setPane({kind:"log",slug:s,id:t2.id,text:text2})},[toast]),editTitle=import_react80.useCallback((t2)=>openTextPrompt(dialog,{title:"Edit title",label:t2.id,initial:t2.title}).then((v2)=>v2!==null&&v2!==void 0&&patchDirect(t2.id,{title:v2},`Updated ${t2.id}`)),[dialog,patchDirect]),editBody=import_react80.useCallback((t2)=>openTextPrompt(dialog,{title:"Edit body",label:t2.id,initial:t2.body??""}).then((v2)=>{if(v2===null||v2===void 0)return;patchDirect(t2.id,{body:v2},`Updated ${t2.id}`)}),[dialog,patchDirect]),editPriority=import_react80.useCallback((t2)=>{let opts=Array.from({length:10},(_2,i)=>({title:i===0?"P0 (none)":`P${i}`,value:String(i)}));dialog.replace($jsx(DialogSelect,{title:`Priority for ${t2.id}`,options:opts,current:String(t2.priority),filterable:!1,onSelect:(o)=>{dialog.clear(),patchDirect(t2.id,{priority:Number(o.value)},`${t2.id} \u2192 P${o.value}`)}}))},[dialog,patchDirect]),editResult=import_react80.useCallback((t2)=>{if(t2.status!=="done")return void toast.show({variant:"info",message:`${t2.id} is not done`});return openTextPrompt(dialog,{title:"Edit result",label:t2.id,initial:t2.result??""}).then((v2)=>{if(v2==null)return;sh(`edit ${q3(t2.id)} --result ${q3(v2)}`,`Updated ${t2.id} result`)})},[dialog,sh,toast]),editStatus=import_react80.useCallback((t2)=>{let opts=[];if(t2.status!=="done")opts.push({title:"done",value:"complete",description:"mark complete (prompts for result)"});if(t2.status!=="blocked")opts.push({title:"blocked",value:"block",description:"mark blocked (prompts for reason)"});if(t2.status!=="scheduled")opts.push({title:"scheduled",value:"schedule",description:"park until externally unblocked (prompts for reason)"});if(t2.status==="blocked"||t2.status==="scheduled")opts.push({title:"ready",value:"unblock",description:t2.status==="scheduled"?"release back to ready":"return to ready"});opts.push({title:"archived",value:"archive",description:"archive (terminal)"}),dialog.replace($jsx(DialogSelect,{title:`Status for ${t2.id}`,options:opts,current:t2.status,filterable:!1,onSelect:async(o)=>{if(dialog.clear(),o.value==="complete"){let res=await openTextPrompt(dialog,{title:`Complete ${t2.id}`,label:"Result (optional)",initial:t2.result??""}),flag=res?` --result ${q3(res)}`:"";sh(`complete ${q3(t2.id)}${flag}`,`Completed ${t2.id}`);return}if(o.value==="block"){let r=await openTextPrompt(dialog,{title:`Block ${t2.id}`,label:"Reason (optional, posted as comment)"}),arg=r?` ${q3(r)}`:"";sh(`block ${q3(t2.id)}${arg}`,`Blocked ${t2.id}`);return}if(o.value==="schedule"){let r=await openTextPrompt(dialog,{title:`Schedule ${t2.id}`,label:"Reason (optional, posted as comment)"}),arg=r?` ${q3(r)}`:"";sh(`schedule ${q3(t2.id)}${arg}`,`Scheduled ${t2.id}`);return}if(o.value==="unblock")return void sh(`unblock ${q3(t2.id)}`,`Unblocked ${t2.id}`);if(o.value==="archive")return void archive(t2)}}))},[dialog,sh,archive]),editParents=import_react80.useCallback((t2)=>{let cur2=(pane?.kind==="detail"&&pane.d.id===t2.id?pane.d:detailOf(at,t2.id))?.parents??[],d2=data2.get(at)??new Map,opts=STATUSES.flatMap((s)=>d2.get(s)??[]).filter((x2)=>x2.id!==t2.id).map((x2)=>({title:x2.id,description:trunc5(x2.title,50),value:x2.id,category:cur2.includes(x2.id)?"linked":"available"}));dialog.replace($jsx(DialogSelect,{title:`Parents for ${t2.id}`,options:opts,placeholder:"Select to toggle link\u2026",onSelect:(o)=>{if(dialog.clear(),cur2.includes(o.value))sh(`unlink ${q3(o.value)} ${q3(t2.id)}`,`Unlinked ${o.value}`);else sh(`link ${q3(o.value)} ${q3(t2.id)}`,`Linked ${o.value}`)}}))},[dialog,sh,data2,at,pane]),openField=import_react80.useCallback((f,t2)=>{if(f==="title")return void editTitle(t2);if(f==="body")return void editBody(t2);if(f==="assignee")return assign(t2);if(f==="priority")return editPriority(t2);if(f==="status")return editStatus(t2);if(f==="parents")return editParents(t2);if(f==="result")return void editResult(t2);if(f==="comment")return void comment(t2)},[editTitle,editBody,assign,editPriority,editStatus,editParents,editResult,comment]),bumpPriority=import_react80.useCallback((t2,d2)=>{let next2=Math.max(0,Math.min(9,t2.priority+d2));if(next2===t2.priority)return;patchDirect(t2.id,{priority:next2},`${t2.id} \u2192 P${next2}`)},[patchDirect]),ACTS=import_react80.useMemo(()=>[{key:"n",title:"New task",when:()=>!0,run:()=>void create()},{key:"N",title:"New child",when:(t2)=>!!t2,run:(t2)=>void create(t2)},{key:"a",title:"Assign",when:(t2)=>!!t2,run:(t2)=>void assign(t2)},{key:"c",title:"Comment",when:(t2)=>!!t2,run:(t2)=>void comment(t2)},{key:"s",title:"Specify",when:(t2)=>t2?.status==="triage",run:(t2)=>void specify(t2)},{key:"S",title:"Specify all",when:()=>!0,run:()=>void specifyAll()},{key:"u",title:"Unblock",when:(t2)=>t2?.status==="blocked"||t2?.status==="scheduled",run:(t2)=>void unblock(t2)},{key:"d",title:"Archive",when:(t2)=>!!t2,run:(t2)=>void archive(t2)},{key:"l",title:"Worker log",when:(t2)=>!!t2,run:(t2)=>showLog(t2)},{key:"b",title:"New board",when:()=>!0,run:()=>void newBoard()},{key:"D",title:"Dispatch",when:()=>!0,run:()=>void dispatch()}],[create,assign,comment,specify,specifyAll,unblock,archive,showLog,newBoard,dispatch]),isOpen=open2.has(at),paneOpen=pane?.kind==="detail",paneFields=paneOpen?fieldsFor(pane.d):[];useKeyboard((key2)=>{if(!props.focused||dialog.open())return;if(key2.name==="escape"&&pane){if(tier==="pane"){setTier("grid");return}return setPane(null)}if(keys.match("list.refresh",key2))return load4();if(key2.name==="tab"){if(paneOpen&&tier!=="pane"){setTier("pane"),setPaneSel(0);return}if(tier==="pane"){let n=paneFields.length;if(n===0)return;let d2=key2.shift?-1:1;setPaneSel((s)=>(s+d2+n)%n);return}return goBoard(key2.shift?-1:1)}if(tier==="pane"){let t3=live.current.task;if(!t3||!paneOpen)return;let f=paneFields[Math.min(paneSel,paneFields.length-1)];if(key2.name==="up"){if(f==="priority")return bumpPriority(t3,1);let n=paneFields.length;if(n===0)return;return setPaneSel((s)=>(s-1+n)%n)}if(key2.name==="down"){if(f==="priority")return bumpPriority(t3,-1);let n=paneFields.length;if(n===0)return;return setPaneSel((s)=>(s+1)%n)}if(key2.name==="return")return openField(f,t3);let hit2=ACTS.find((a)=>a.key===key2.raw&&a.when(t3));if(hit2)return hit2.run(t3);return}if(key2.name==="space"||key2.name===" "){if(tier==="head")return toggle(at);if(tier==="filter"&&sec3?.chips[chip])return flip(sec3.chips[chip]);return}if(key2.name==="down"){if(tier==="head"){if(isOpen)return setTier("filter");let n2=stepBoard(1);return n2?enterTop(n2):void 0}if(tier==="filter"){if(sec3&&sec3.shown>0){setTier("grid"),setRow(0);return}let n2=stepBoard(1);return n2?enterTop(n2):void 0}if(row2<(cur?.tasks.length??1)-1)return setRow((r)=>r+1);let n=stepBoard(1);return n?enterTop(n):void 0}if(key2.name==="up"){if(tier==="head"){let p=stepBoard(-1);return p?enterBottom(p):void 0}if(tier==="filter")return setTier("head");if(row2>0)return setRow((r)=>r-1);return setTier("filter")}if(key2.name==="left"){if(tier==="filter")return setChip((c)=>Math.max(0,c-1));if(tier==="grid")return setCol((c)=>{let n=Math.max(0,c-1);return setRow(0),n});return}if(key2.name==="right"){if(tier==="filter")return setChip((c)=>Math.min((sec3?.chips.length??1)-1,c+1));if(tier==="grid")return setCol((c)=>{let n=Math.min(cols2.length-1,c+1);return setRow(0),n});return}if(key2.name==="return"){if(tier==="head")return toggle(at);if(tier==="filter"&&sec3?.chips[chip])return flip(sec3.chips[chip]);if(task)return setPane((p)=>p?.kind==="detail"&&p.d.id===task.id?null:((d2)=>d2?{kind:"detail",slug:at,d:d2}:null)(detailOf(at,task.id)));return}let t2=live.current.task,hit=ACTS.find((a)=>a.key===key2.raw&&a.when(t2));if(hit)return hit.run(t2)});let hint=import_react80.useMemo(()=>{let t2=task;return[tier==="pane"?"Esc grid":"Tab board",tier==="head"?"\u2191\u2193 nav Space fold":tier==="filter"?"\u2190\u2192 chip Space toggle":tier==="pane"?"Tab/\u2191\u2193 field Enter edit Esc grid":"\u2190\u2192\u2191\u2193 nav Enter detail",...ACTS.filter((a)=>a.when(t2)).map((a)=>`${a.key} ${a.title.toLowerCase()}`),`${keys.print("list.refresh")} reload`].join(" ")},[ACTS,keys,task,tier]),onHead=import_react80.useCallback((s)=>{setAt(s),setTier("head"),toggle(s)},[toggle]),onChip=import_react80.useCallback((s,i,c)=>{setAt(s),setTier("filter"),setChip(i),flip(c)},[flip]),onPick=import_react80.useCallback((s,ci,ri,id)=>{setAt(s),setTier("grid"),setCol(ci),setRow(ri),setOpen((o)=>o.has(s)?o:new Set(o).add(s));let d2=detailOf(s,id);if(d2)setPane({kind:"detail",slug:s,d:d2})},[]);return $jsxs("box",{flexDirection:"column",flexGrow:1,minWidth:0,children:[$jsxs("box",{flexDirection:"row",flexGrow:1,children:[$jsx(TabShell,{title:`Kanban \xB7 ${sections.length} board${sections.length===1?"":"s"} \xB7 ${grand} task${grand===1?"":"s"}${running2?` \xB7 ${running2} running`:""}`,children:$jsx("scrollbox",{ref:outer,scrollY:!0,flexGrow:1,verticalScrollbarOptions:NOBAR,children:$jsx("box",{flexDirection:"column",width:"100%",children:sections.map((s)=>{let on=s.board.slug===at,secOpen=open2.has(s.board.slug),m2=maskOf(s.board.slug),filt=m2.who.size+m2.pri.size+m2.status.size,dg=diags.get(s.board.slug)??EMPTY_DIAG;return $jsxs("box",{id:`kb-sec-${s.board.slug}`,flexDirection:"column",flexShrink:0,marginBottom:1,children:[$jsx("box",{height:1,onMouseDown:()=>onHead(s.board.slug),backgroundColor:on&&tier==="head"?theme.backgroundElement:void 0,children:$jsxs("text",{children:[$jsx("span",{fg:on?theme.accent:theme.textMuted,children:secOpen?"\u25BE ":"\u25B8 "}),$jsx("span",{fg:on?theme.primary:theme.text,children:$jsx("strong",{children:s.board.name})}),$jsx("span",{fg:theme.textMuted,children:s.total===0?" \xB7 empty":` \xB7 ${filt?`${s.shown}/`:""}${s.total} task${s.total===1?"":"s"}${s.running?` \xB7 ${s.running} running`:""}`})]})}),secOpen?s.total===0?$jsx("box",{height:1,marginLeft:2,children:$jsxs("text",{fg:theme.textMuted,children:["no tasks \u2014 ",$jsx("span",{fg:theme.accent,children:"n"})," to create one here"]})}):$jsxs($Fragment,{children:[$jsx(FilterBar,{chips:s.chips,mask:m2,on:on&&tier==="filter",sel:on?Math.min(chip,s.chips.length-1):-1,onPick:(i)=>onChip(s.board.slug,i,s.chips[i])}),s.cols.length>0?$jsx("box",{flexDirection:"row",height:s.cap,gap:1,children:s.cols.map((c,ci)=>$jsx(Column,{slug:s.board.slug,status:c.status,tasks:c.tasks,diags:dg,on:on&&(tier==="grid"||tier==="pane")&&ci===clampCol,sel:on?row2:0,onPick:(ri)=>onPick(s.board.slug,ci,ri,c.tasks[ri].id)},c.status))}):$jsx("box",{height:1,marginLeft:2,children:$jsx("text",{fg:theme.textMuted,children:"all columns hidden"})})]}):null]},s.board.slug)})})})}),pane?$jsx(SidePane,{pane,on:tier==="pane",sel:paneSel,diags:pane.kind==="detail"?diags.get(pane.slug)?.get(pane.d.id)??EMPTY_DIAGS:EMPTY_DIAGS}):null]}),$jsx(HintBar,{raw:hint})]})});var Automation=import_react82.memo((props)=>{let keys=useKeys(),labels=SUB_TABS[AUTOMATION_TAB];import_react82.useEffect(()=>{if(props.sub>=labels.length)props.setSub(0)},[props.sub,labels.length]);let hint=`${keys.print("tab.prev")}/${keys.print("tab.next")} group \xB7 shift+\u2190/\u2192 sub`;return $jsxs("box",{flexDirection:"column",flexGrow:1,minWidth:0,children:[$jsx(SubTabBar,{tabs:labels,active:props.sub,onChange:props.setSub,hint}),$jsxs("box",{flexGrow:1,minWidth:0,flexDirection:"column",children:[$jsx(Pane2,{visible:props.sub===0,children:$jsx(Kanban,{focused:!!props.focused&&props.sub===0})}),$jsx(Pane2,{visible:props.sub===1,children:$jsx(Agents,{focused:!!props.focused&&props.sub===1,sessionId:props.sessionId,onSwitchProfile:props.onSwitchProfile})}),$jsx(Pane2,{visible:props.sub===2,children:$jsx(Cron,{focused:!!props.focused&&props.sub===2})})]})]})}),Pane2=({visible,children:children2})=>visible?$jsx("box",{flexGrow:1,minWidth:0,minHeight:0,flexDirection:"column",children:children2}):null;var import_react94=__toESM(require_react_production(),1);var import_react84=__toESM(require_react_production(),1);init_lane();var int=(lo,hi,what=`${lo}\u2013${hi}`)=>(raw)=>{let n=Number(raw);if(!Number.isInteger(n))return`expected integer ${what}`;if(n<lo||n>hi)return`expected ${what}`;return null},float=(lo,hi)=>(raw)=>{let n=Number(raw);if(!Number.isFinite(n))return`expected number ${lo}\u2013${hi}`;if(n<lo||n>hi)return`expected ${lo}\u2013${hi}`;return null},oneOf=(...opts)=>(raw)=>opts.includes(raw)?null:`expected one of: ${opts.join(" | ")}`,nonNeg=(raw)=>{let n=Number(raw);return Number.isFinite(n)&&n>=0?null:"expected \u2265 0"},RULES={"compression.threshold":float(0.1,0.95),"compression.target_ratio":float(0.05,0.9),"prompt_caching.cache_ttl":(raw)=>/^\d+[smhd]$/.test(raw.trim())?null:"expected duration e.g. 5m, 1h","agent.max_turns":int(1,1e4),"delegation.max_iterations":int(1,1e4),"delegation.max_concurrent_children":int(1,64),"delegation.max_spawn_depth":int(1,3),"agent.gateway_timeout":nonNeg,"agent.gateway_timeout_warning":nonNeg,"agent.gateway_notify_interval":nonNeg,"agent.restart_drain_timeout":nonNeg,"delegation.child_timeout_seconds":int(30,86400),"browser.command_timeout":int(1,600),"approvals.timeout":int(1,3600),"security.tirith_timeout":int(1,120),"agent.api_max_retries":int(0,20),"tool_output.max_bytes":int(1024,1e7),"tool_output.max_lines":int(10,1e5),"sessions.retention_days":int(1,3650),"sessions.min_interval_hours":int(1,720),"agent.service_tier":oneOf("","fast","standard"),"display.busy_input_mode":oneOf("queue","steer","interrupt"),"display.details_mode":oneOf("hidden","collapsed","expanded"),"display.thinking_mode":oneOf("collapsed","truncated","full"),"display.tool_progress":oneOf("off","new","all","verbose"),"display.final_response_markdown":oneOf("render","strip","raw"),"logging.level":oneOf("DEBUG","INFO","WARNING","ERROR"),"approvals.mode":oneOf("manual","ask","yolo","deny"),"code_execution.mode":oneOf("project","strict")},check=(key2,raw)=>RULES[key2]?.(raw)??null;init_schema();init_lane();var SELECTS={"terminal.backend":["local","docker","ssh","modal","daytona","singularity","vercel_sandbox"],"tts.provider":["edge","elevenlabs","openai","neutts","xai","mistral"],"display.skin":[...SKINS],"logging.level":["DEBUG","INFO","WARNING","ERROR"],"agent.reasoning_effort":["","none","minimal","low","medium","high","xhigh"],"display.busy_input_mode":["queue","steer","interrupt"],"display.details_mode":["hidden","collapsed","expanded"],"display.thinking_mode":["collapsed","truncated","full"],"display.tool_progress":["off","new","all","verbose"],"approvals.mode":["manual","ask","yolo","deny"]},get4=(obj,path7)=>{let cur=obj;for(let p of path7.split("."))if(cur&&typeof cur==="object"&&!Array.isArray(cur))cur=cur[p];else return;return cur},classify2=(key2,t2)=>{if(route(key2).via==="readonly")return"readonly";if(SELECTS[key2])return"select";if(t2==="bool")return"boolean";if(t2==="int"||t2==="float")return"number";return"string"},labelOf=(key2)=>{let raw=SCHEMA[key2]?.group??key2.split(".")[0];return key2.startsWith(`${raw}.`)?key2.slice(raw.length+1):key2},buildFields=(user)=>{let seen=new Set,out=[];for(let key2 of SCHEMA_KEYS){let s=SCHEMA[key2],uv=get4(user,key2),set2=uv!==void 0;out.push({key:key2,label:labelOf(key2),type:classify2(key2,s.type),value:set2?uv:s.default,set:set2,doc:s.doc,effect:s.effect,options:SELECTS[key2]}),seen.add(key2)}let walk=(obj,prefix="")=>{for(let[k2,v2]of Object.entries(obj)){let key2=prefix?`${prefix}.${k2}`:k2;if(v2&&typeof v2==="object"&&!Array.isArray(v2)){if(SCHEMA[key2]?.type==="dict"){seen.add(key2);continue}walk(v2,key2);continue}if(seen.has(key2))continue;out.push({key:key2,label:labelOf(key2),type:Array.isArray(v2)?"readonly":typeof v2==="boolean"?"boolean":typeof v2==="number"?"number":"string",value:v2,set:!0,doc:"",effect:"live"})}};return walk(user),out},MERGE={approvals:"security",privacy:"security",checkpoints:"agent",context:"agent",cron:"agent",network:"agent",model_catalog:"general",onboarding:"general",human_delay:"display",dashboard:"display",tool_output:"agent",prompt_caching:"compression",code_execution:"terminal",lsp:"agent",x_search:"agent",slack:"platforms",telegram:"platforms",mattermost:"platforms",discord:"platforms",whatsapp:"platforms",matrix:"platforms"},rawGroupOf=(key2)=>SCHEMA[key2]?.group??(key2.includes(".")?key2.split(".")[0]:"general"),groupOf=(key2)=>{let raw=rawGroupOf(key2);return MERGE[raw]??raw},sections=(group,fields)=>{let by=new Map;for(let f of fields){let r=rawGroupOf(f.key);if(!by.has(r))by.set(r,[]);by.get(r).push(f)}if(by.size<=1)return[{head:null,items:fields}];return[...by.keys()].sort((a,b2)=>a===group?-1:b2===group?1:a.localeCompare(b2)).map((r)=>({head:r,items:by.get(r)}))},GROUPS=(()=>{let g=new Set(["general"]);for(let k2 of SCHEMA_KEYS)g.add(groupOf(k2));return[...g]})(),EFFECT_GLYPH={live:"",session:"\u21BB",restart:"\u27F3"};init_lane();var AUX_TASKS=[{key:"vision",label:"Vision",hint:"Image analysis"},{key:"web_extract",label:"Web Extract",hint:"Page summarization"},{key:"compression",label:"Compression",hint:"Context compaction"},{key:"session_search",label:"Session Search",hint:"Recall queries"},{key:"skills_hub",label:"Skills Hub",hint:"Skill search"},{key:"approval",label:"Approval",hint:"Smart auto-approve"},{key:"mcp",label:"MCP",hint:"MCP tool routing"},{key:"title_generation",label:"Title Gen",hint:"Session titles"},{key:"triage_specifier",label:"Triage Specifier",hint:"Kanban spec fleshing"},{key:"kanban_decomposer",label:"Kanban Decomposer",hint:"Task decomposition"},{key:"profile_describer",label:"Profile Describer",hint:"Auto profile descriptions"},{key:"curator",label:"Curator",hint:"Skill-usage review"}],dig=(o,...path7)=>path7.reduce((c,p)=>c&&typeof c==="object"?c[p]:void 0,o),str2=(v2)=>typeof v2==="string"?v2:"",readSlots=(raw)=>{let main2={kind:"main",key:"main",label:"Main model",hint:"Primary agent model",provider:str2(dig(raw,"model","provider")),model:str2(dig(raw,"model","default"))||str2(dig(raw,"model","name")),auto:!1},aux=AUX_TASKS.map((t2)=>{let p=str2(dig(raw,"auxiliary",t2.key,"provider"));return{kind:"aux",key:t2.key,label:t2.label,hint:t2.hint,provider:p,model:str2(dig(raw,"auxiliary",t2.key,"model")),auto:p===""||p==="auto"}});return[main2,...aux]},assign=async(gw,slot,provider,model)=>{if(slot==="main"){let r=await gw.request("config.set",{key:"model",value:`${model} --provider ${provider} --global`,session_id:void 0});return{ok:["model.default","model.provider"],failed:[],warnings:[],warning:r.warning}}return writeConfig(gw,[{key:`auxiliary.${slot}.provider`,to:provider},{key:`auxiliary.${slot}.model`,to:model}])},resetAux=(gw,slot)=>{let keys=slot==="all"?AUX_TASKS.map((t2)=>t2.key):[slot];return writeConfig(gw,keys.flatMap((k2)=>[{key:`auxiliary.${k2}.provider`,to:"auto"},{key:`auxiliary.${k2}.model`,to:""}]))};var import_react83=__toESM(require_react_production(),1);var ModelPickerDialog=(props)=>{let dialog=useDialog(),toast=useToast(),theme=useTheme().theme,[data2,setData]=import_react83.useState(null),[step,setStep]=import_react83.useState("provider"),[provider,setProvider]=import_react83.useState(null),[global2,setGlobal]=import_react83.useState(!1);import_react83.useEffect(()=>{props.gw.request("model.options").then(setData).catch(()=>setData({providers:[]}))},[props.gw]);let apply=import_react83.useCallback((model,prov)=>{if(props.onApply)return void props.onApply(prov,model).catch((e)=>toast.show({variant:"error",message:e.message}));let value=`${model} --provider ${prov}${global2?" --global":""}`;props.gw.request("config.set",global2?{key:"model",value,session_id:void 0}:{key:"model",value}).then((r)=>{if(toast.show({variant:"success",message:`model \u2192 ${r.value??model}${global2?" (global)":""}`}),r.warning)toast.show({variant:"warning",message:r.warning})}).catch((e)=>toast.show({variant:"error",message:e.message}))},[props.gw,props.onApply,global2,toast]),onKey=import_react83.useCallback((k2)=>{if(k2.name==="tab"&&!props.onApply)return setGlobal((g)=>!g),!0;if(k2.name==="left"&&step==="model")return setStep("provider"),!0;return!1},[step,props.onApply]),footer=props.onApply?$jsx("text",{fg:theme.textMuted,children:step==="model"?"\u2190: providers":" "}):$jsxs("text",{fg:theme.textMuted,children:[$jsx("span",{children:"Scope: "}),$jsx("span",{fg:global2?theme.warning:theme.accent,children:global2?"global (persists to config)":"this session"}),$jsxs("span",{children:[" \xB7 Tab: toggle",step==="model"?" \xB7 \u2190: providers":""]})]});if(!data2)return $jsx("box",{width:50,padding:1,children:$jsx("text",{children:"Loading models\u2026"})});if(step==="provider"){let options2=(data2.providers??[]).toSorted((a,b2)=>Number(Boolean(b2.is_current))-Number(Boolean(a.is_current))).map((p2)=>({title:p2.name,value:p2.slug,description:p2.total_models?`${p2.total_models} models`:void 0,category:p2.is_current?"Current":"Available"}));return $jsx(DialogSelect,{title:props.title??"Switch Provider",options:options2,current:data2.provider,onSelect:(o)=>{setProvider(o.value),setStep("model")},onKey,placeholder:"Search providers...",footer})}let p=data2.providers?.find((pp)=>pp.slug===provider),options=(p?.models??[]).map((m2)=>({title:m2,value:m2}));return $jsx(DialogSelect,{title:props.title?`${props.title} \xB7 ${p?.name??provider}`:`Switch Model (${p?.name??provider})`,options,current:provider===data2.provider?data2.model:void 0,onSelect:(o)=>{if(provider)apply(o.value,provider);dialog.clear()},onKey,placeholder:"Search models...",footer})},openModelPicker=(dialog,gw,opts)=>{dialog.replace($jsx(ModelPickerDialog,{gw,title:opts?.title,onApply:opts?.onApply}))};var flatten=(obj,prefix="")=>Object.entries(obj).flatMap(([k2,v2])=>{let key2=prefix?`${prefix}.${k2}`:k2;if(v2&&typeof v2==="object"&&!Array.isArray(v2))return flatten(v2,key2);return[[key2,v2]]}),setNested=(obj,path7,val)=>{let parts2=path7.split("."),cur=obj;for(let i=0;i<parts2.length-1;i++){if(!cur[parts2[i]]||typeof cur[parts2[i]]!=="object")cur[parts2[i]]={};cur=cur[parts2[i]]}cur[parts2[parts2.length-1]]=val},getNested=(obj,path7)=>{let parts2=path7.split("."),cur=obj;for(let p of parts2)if(cur&&typeof cur==="object"&&!Array.isArray(cur))cur=cur[p];else return;return cur},FieldRow=import_react84.memo((props)=>{let theme=useTheme().theme,f=props.field,bg2=props.active?theme.backgroundElement:void 0,indicator=props.active?"\u25B8 ":" ",mark2=props.changed?"\u25CF ":f.set?"\xB7":" ",markFg=props.changed?theme.warning:theme.textMuted,display=()=>{if(props.editing)return props.buf+"\u2588";if(f.type==="readonly"){let n=Array.isArray(f.value)?f.value.length:f.value&&typeof f.value==="object"?Object.keys(f.value).length:0;return n===0?"\u2014":`${n} item${n===1?"":"s"}`}if(f.type==="boolean")return f.value?"\u2713 ON":"\u2717 OFF";return String(f.value??"")},hint=()=>{if(props.readonly||f.type==="readonly")return"\uD83D\uDD12";if(f.type==="boolean")return"[space]";if(f.type==="select")return"[h/l]";return"[enter]"},ro=props.readonly||f.type==="readonly",valFg=ro||!f.set?theme.textMuted:f.type==="boolean"?f.value?theme.success:theme.error:theme.text,labelFg=ro?theme.textMuted:props.active?theme.accent:theme.text,lead=4+(props.badge!==void 0?12:0),glyph=props.active?EFFECT_GLYPH[f.effect]:"";return $jsxs("box",{id:props.id,flexDirection:"column",backgroundColor:bg2,children:[$jsxs("box",{flexDirection:"row",height:1,children:[$jsx(Col,{w:2,fg:markFg,children:mark2}),$jsx(Col,{w:2,fg:props.active?theme.primary:theme.text,children:indicator}),props.badge!==void 0?$jsx(Col,{w:12,fg:theme.textMuted,children:props.badge}):null,$jsx(Col,{w:40,fg:labelFg,children:f.label}),$jsx(Col,{grow:!0,min:6,fg:valFg,children:display()}),$jsx(Col,{w:2,fg:theme.textMuted,children:glyph}),$jsx(Col,{w:9,fg:theme.textMuted,right:!0,children:props.active?hint():""})]}),props.error?$jsxs("box",{flexDirection:"row",height:1,children:[$jsx(Col,{w:lead+40,fg:theme.textMuted,children:""}),$jsx(Col,{grow:!0,min:6,fg:theme.error,children:`\u2717 ${props.error}`})]}):props.active&&f.doc?$jsxs("box",{flexDirection:"row",minHeight:1,children:[$jsx("box",{width:lead,flexShrink:0}),$jsx("box",{width:40,flexShrink:0,minHeight:1,children:$jsx("text",{wrapMode:"word",fg:theme.textMuted,children:f.doc})})]}):null]})}),SlotRow=import_react84.memo((p)=>{let theme=useTheme().theme,main2=p.s.kind==="main",val=main2?`${p.s.provider||"(unset)"} \xB7 ${p.s.model||"(unset)"}`:p.s.auto?"auto (use main model)":`${p.s.provider} \xB7 ${p.s.model||"(provider default)"}`;return $jsxs("box",{id:p.id,flexDirection:"row",height:1,backgroundColor:p.on?theme.backgroundElement:void 0,children:[$jsx(Col,{w:2,fg:p.on?theme.primary:theme.text,children:p.on?"\u25B8 ":" "}),$jsx(Col,{w:2,fg:main2?theme.primary:theme.textMuted,children:main2?"\u2605":" "}),$jsx(Col,{w:16,fg:p.on?theme.accent:theme.text,children:p.s.label}),$jsx(Col,{w:22,fg:theme.textMuted,children:p.s.hint}),$jsx(Col,{grow:!0,min:10,fg:p.s.auto?theme.textMuted:theme.text,children:val}),$jsx(Col,{w:14,fg:theme.textMuted,right:!0,children:p.on?main2?"[enter]":"[enter] [x]":""})]})}),Config=import_react84.memo((props)=>{let theme=useTheme().theme,gw=useGateway(),toast=useToast(),dialog=useDialog(),[raw,setRaw]=import_react84.useState({}),[original,setOriginal]=import_react84.useState({}),[yaml,setYaml]=import_react84.useState(""),[mode,setMode]=import_react84.useState("form"),[cat,setCat]=import_react84.useState(0),[cursor,setCursor]=import_react84.useState(0),[editing,setEditing]=import_react84.useState(!1),[buf,setBuf]=import_react84.useState(""),[err,setErr]=import_react84.useState({}),[searching,setSearching]=import_react84.useState(!1),[query,setQuery]=import_react84.useState(""),[focus,setFocus]=import_react84.useState("categories"),[managed,setManaged]=import_react84.useState(null);import_react84.useEffect(()=>{managedSystem().then(setManaged)},[]);let load4=import_react84.useCallback(()=>{gw.request("config.get",{key:"full"}).then((res)=>{let parsed=res.config??{};setRaw(structuredClone(parsed)),setOriginal(structuredClone(parsed)),setYaml($stringify(parsed)),setErr({})}).catch(()=>{setRaw({}),setOriginal({}),setYaml("")})},[gw]);import_react84.useEffect(()=>{load4()},[load4]);let all=buildFields(raw),grouped=all.reduce((map,f)=>{let g=groupOf(f.key);if(!map.has(g))map.set(g,[]);return map.get(g).push(f),map},new Map(GROUPS.map((g)=>[g,[]]))),groups=[...grouped.keys()];groups.splice(1,0,"models");let active=groups[cat]??groups[0],onSlots=active==="models"&&!searching,slots=readSlots(raw),secs=searching&&query.trim()?[{head:null,items:all.filter((f)=>f.key.toLowerCase().includes(query.toLowerCase()))}]:sections(active,grouped.get(active)??[]),fields=secs.flatMap((s)=>s.items),count3=onSlots?slots.length:fields.length,follow=useFollow("cfg"),catFollow=useFollow("cfg-cat"),changed=(key2)=>JSON.stringify(getNested(raw,key2))!==JSON.stringify(getNested(original,key2)),nChanged=all.reduce((n,f)=>n+(changed(f.key)?1:0),0),update=(key2,val)=>{let next2=structuredClone(raw);setNested(next2,key2,val),setRaw(next2),setYaml($stringify(next2))},fmt3=(v2)=>v2===void 0?"\u2014":Array.isArray(v2)?v2.join(", "):String(v2),save2=async()=>{if(managed){toast.show({variant:"error",message:`Managed by ${managed} \u2014 edit configuration.nix`});return}let nErr=Object.keys(err).length;if(nErr>0){toast.show({variant:"error",message:`${nErr} invalid field${nErr===1?"":"s"}`});return}let target=mode==="yaml"?$parse(yaml)??{}:raw,diffs=flatten(target).filter(([key2])=>JSON.stringify(getNested(target,key2))!==JSON.stringify(getNested(original,key2))).map(([key2,val])=>({key:key2,from:getNested(original,key2),to:val}));if(diffs.length===0){toast.show({variant:"info",message:"No changes"});return}let body=diffs.map((d2)=>`${d2.key}: ${fmt3(d2.from)} \u2192 ${fmt3(d2.to)}`).join(`
4125
4125
  `);if(!await openConfirm(dialog,{title:`Write ${diffs.length} change${diffs.length===1?"":"s"} to config.yaml?`,body,yes:"save"}))return;let res=await writeConfig(gw,diffs.map((d2)=>({key:d2.key,to:d2.to})));for(let w2 of res.warnings)toast.show({variant:"info",message:`${w2.key}: ${w2.msg}`});if(load4(),res.failed.length>0){toast.show({variant:"error",message:`${res.failed.length} failed: ${res.failed.map((f)=>f.key).join(", ")}`});return}let landed=diffs.filter((d2)=>res.ok.includes(d2.key)),miss=await verifyWrite(gw,landed.map((d2)=>({key:d2.key,to:d2.to})));if(miss.length>0){toast.show({variant:"error",message:`Write didn't land: ${miss.join(", ")}`});return}let tier=maxEffect(res.ok);if(tier==="restart"){if(await openConfirm(dialog,{title:`Saved \u2014 ${res.ok.length} setting${res.ok.length===1?"":"s"} need a gateway restart`,body:"Restart now? This interrupts any running turn.",yes:"restart now",no:"later",danger:!0}))gw.start(),toast.show({variant:"info",message:"Gateway restarting\u2026"});return}toast.show({variant:"success",message:tier==="live"?"Saved":"Saved \u2014 new sessions pick this up"})},pick=import_react84.useCallback((s)=>{if(managed)return toast.show({variant:"error",message:`Managed by ${managed}`});openModelPicker(dialog,gw,{title:s.kind==="main"?"Set main model":`Set auxiliary \xB7 ${s.label}`,onApply:async(prov,model)=>{let r=await assign(gw,s.key,prov,model);if(r.failed.length)return toast.show({variant:"error",message:r.failed.map((f)=>f.err).join("; ")});if(toast.show({variant:"success",message:s.kind==="main"?`main \u2192 ${prov} \xB7 ${model}`:`${s.key} \u2192 ${prov} \xB7 ${model}`}),r.warning)toast.show({variant:"warning",message:r.warning});load4()}})},[gw,dialog,toast,load4,managed]),unset=import_react84.useCallback((s)=>{if(managed||s.kind!=="aux"||s.auto)return;resetAux(gw,s.key).then((r)=>{if(r.failed.length)return toast.show({variant:"error",message:r.failed.map((f)=>f.err).join("; ")});toast.show({variant:"success",message:`${s.key} \u2192 auto`}),load4()})},[gw,toast,load4,managed]),unsetAll=import_react84.useCallback(()=>openConfirm(dialog,{title:"Reset all auxiliary slots to auto?",body:`${AUX_TASKS.length} slots. Each falls back to the main model.`,yes:"reset",danger:!0}).then((ok)=>{if(!ok)return;resetAux(gw,"all").then((r)=>{if(r.failed.length)return toast.show({variant:"error",message:`${r.failed.length} failed`});toast.show({variant:"success",message:"All auxiliary slots \u2192 auto"}),load4()})}),[gw,dialog,toast,load4]),keys=useKeys();if(useKeyboard((key2)=>{if(!props.focused||dialog.open())return;if(keys.match("config.mode",key2)&&!editing&&!searching){setMode((m2)=>m2==="form"?"yaml":"form");return}if(keys.match("config.save",key2))return void save2();if(mode==="yaml"){if(key2.name==="backspace"){setYaml((prev)=>prev.slice(0,-1));return}if(key2.name==="return"){setYaml((prev)=>prev+`
4126
4126
  `);return}if(key2.raw&&key2.raw.length===1&&key2.raw>=" "){setYaml((prev)=>prev+key2.raw);return}return}if(searching){if(key2.name==="escape"){setSearching(!1),setQuery(""),setCursor(0);return}if(key2.name==="backspace"){setQuery((prev)=>prev.slice(0,-1)),setCursor(0);return}if(key2.name==="up"){setCursor((c)=>Math.max(0,c-1));return}if(key2.name==="down"){setCursor((c)=>Math.min(count3-1,c+1));return}if(key2.raw&&key2.raw.length===1&&key2.raw>=" "){setQuery((prev)=>prev+key2.raw),setCursor(0);return}return}if(editing){let f2=fields[cursor];if(key2.name==="escape"){if(setEditing(!1),setBuf(""),f2)setErr((e)=>{let{[f2.key]:_2,...rest}=e;return rest});return}if(key2.name==="return"){if(f2){let msg=check(f2.key,buf);if(msg){setErr((e)=>({...e,[f2.key]:msg}));return}setErr((e)=>{let{[f2.key]:_2,...rest}=e;return rest});let val=f2.type==="number"?Number(buf)||0:buf;update(f2.key,val)}setEditing(!1),setBuf("");return}if(key2.name==="backspace"){setBuf((prev)=>prev.slice(0,-1));return}if(key2.raw&&key2.raw.length===1){setBuf((prev)=>prev+key2.raw);return}return}if(key2.name==="tab"){setFocus((f2)=>f2==="categories"?"fields":"categories");return}if(keys.match("list.search",key2)){setSearching(!0),setQuery(""),setCursor(0);return}if(focus==="categories"){if(key2.name==="up"){setCat((c)=>{let n=Math.max(0,c-1);return catFollow.opts.scrollTo(n),n}),setCursor(0);return}if(key2.name==="down"){setCat((c)=>{let n=Math.min(groups.length-1,c+1);return catFollow.opts.scrollTo(n),n}),setCursor(0);return}if(key2.name==="return"){setFocus("fields");return}return}if(onSlots){let s=slots[cursor];if(handleListKey(keys,key2,{count:count3,setSel:setCursor,...follow.opts,onActivate:s?()=>pick(s):void 0,onRefresh:()=>{load4(),toast.show({variant:"info",message:"Reloaded",duration:1000})}})||!s)return;if(key2.raw==="x")return unset(s);if(key2.raw==="X")return void unsetAll();return}let f=fields[cursor],writable=!managed;if(handleListKey(keys,key2,{count:count3,setSel:setCursor,...follow.opts,onRefresh:()=>{load4(),toast.show({variant:"info",message:"Reloaded",duration:1000})},onToggle:writable&&f?.type==="boolean"?()=>update(f.key,!f.value):void 0,onActivate:f&&writable&&(f.type==="string"||f.type==="number")?()=>{setEditing(!0),setBuf(String(f.value??""))}:void 0})||!f||!writable)return;if(f.type==="select"&&f.options){let idx=f.options.indexOf(String(f.value));if(key2.raw==="l"||key2.raw==="]"){update(f.key,f.options[(idx+1)%f.options.length]);return}if(key2.raw==="h"||key2.raw==="["){update(f.key,f.options[(idx-1+f.options.length)%f.options.length]);return}}}),mode==="yaml")return $jsxs("box",{flexDirection:"column",flexGrow:1,minWidth:0,children:[$jsx(TabShell,{title:"Config \xB7 YAML",children:$jsx("scrollbox",{scrollY:!0,flexGrow:1,children:$jsxs("text",{wrapMode:"word",children:[$jsx("span",{fg:theme.text,children:yaml}),$jsx("span",{fg:theme.accent,children:"\u2588"})]})})}),$jsx(HintBar,{pairs:[[keys.print("config.mode"),"form"],[keys.print("config.save"),"save"]]})]});return $jsxs("box",{flexDirection:"column",flexGrow:1,children:[searching?$jsx("box",{height:1,paddingLeft:1,paddingRight:1,children:$jsxs("text",{children:[$jsx("span",{fg:theme.accent,children:"\u2503 "}),$jsx("span",{fg:theme.text,children:query}),$jsx("span",{fg:theme.accent,children:"\u2588"}),$jsx("span",{fg:theme.textMuted,children:` ${count3} of ${all.length} \xB7 \u2191\u2193 nav \xB7 Esc close`})]})}):null,$jsxs("box",{flexDirection:"row",flexGrow:1,children:[searching?null:$jsx(TabShell,{title:"Config",grow:1,focus:focus==="categories",children:$jsx("scrollbox",{ref:catFollow.ref,scrollY:!0,flexGrow:1,children:groups.map((c,i)=>{let sel=i===cat,hot=sel&&focus==="categories",items=grouped.get(c)??[],n=c==="models"?slots.length:items.length,catDirty=items.some((f)=>changed(f.key));return $jsx("box",{id:catFollow.id(i),backgroundColor:hot?theme.backgroundElement:void 0,onMouseDown:()=>{setCat(i),setCursor(0),setFocus("categories")},children:$jsxs("text",{children:[$jsx("span",{fg:catDirty?theme.warning:theme.textMuted,children:catDirty?"\u25CF":" "}),$jsxs("span",{fg:hot?theme.accent:sel?theme.primary:theme.text,children:[sel?"\u25B8 ":" ",c]}),$jsx("span",{fg:theme.textMuted,children:` (${n})`})]})},c)})})}),$jsxs(TabShell,{title:onSlots?"models \xB7 applies immediately":searching?"Search":nChanged>0?`${active} \xB7 ${nChanged} unsaved`:active,grow:3,focus:focus==="fields"||searching,children:[managed?$jsxs("box",{height:1,flexDirection:"row",gap:1,children:[$jsx("text",{fg:theme.warning,children:"\uD83D\uDD12 managed install \u2014 edit"}),$jsx(FileLink,{source:makeSource("config.yaml"),children:"config.yaml"}),$jsx("text",{fg:theme.warning,children:"via configuration.nix"})]}):null,onSlots?$jsxs("box",{flexDirection:"column",flexGrow:1,children:[$jsx("box",{height:1,children:$jsx("text",{fg:theme.textMuted,children:"Auxiliary tasks handle side-jobs. 'auto' = use main model. Per-task api_key/base_url/timeout live in the 'auxiliary' category."})}),$jsx("box",{height:1}),$jsx("scrollbox",{ref:follow.ref,scrollY:!0,flexGrow:1,verticalScrollbarOptions:VBAR,children:slots.map((s,i)=>$jsx(SlotRow,{id:follow.id(i),s,on:i===cursor&&focus==="fields"},s.key))})]},"slots"):$jsxs($Fragment,{children:[$jsxs(Hdr,{children:[$jsx(Col,{w:4,fg:theme.textMuted,children:""}),searching?$jsx(Col,{w:12,fg:theme.textMuted,bold:!0,children:"Category"}):null,$jsx(Col,{w:40,fg:theme.textMuted,bold:!0,children:"Field"}),$jsx(Col,{grow:!0,min:6,fg:theme.textMuted,bold:!0,children:"Value"}),$jsx(Col,{w:2,fg:theme.textMuted,children:""}),$jsx(Col,{w:9,fg:theme.textMuted,children:""})]}),$jsx("box",{height:1}),count3===0?$jsx("box",{flexGrow:1,padding:2,children:$jsx("text",{fg:theme.textMuted,children:searching?"No matching fields":"No fields in this category"})},"empty"):$jsx("scrollbox",{ref:follow.ref,scrollY:!0,flexGrow:1,verticalScrollbarOptions:VBAR,children:secs.reduce((acc2,s)=>{if(s.head!==null)acc2.out.push($jsx("box",{height:1,marginTop:acc2.base>0?1:0,children:$jsxs("text",{fg:theme.textMuted,children:["\u2500 ",s.head," "]})},`\xA7${s.head}`));return s.items.forEach((f,j2)=>{let i=acc2.base+j2;acc2.out.push($jsx(FieldRow,{id:follow.id(i),field:f,active:i===cursor&&(focus==="fields"||searching),changed:changed(f.key),editing:editing&&i===cursor,buf,readonly:!!managed,error:err[f.key],badge:searching?groupOf(f.key):void 0},f.key))}),acc2.base+=s.items.length,acc2},{base:0,out:[]}).out},"list")]})]})]}),managed?$jsx(HintBar,{raw:`read-only \xB7 managed by ${managed}`}):onSlots?$jsx(HintBar,{pairs:[["\u2191\u2193","nav"],["Enter","pick"],["x","reset"],["X","reset-all"],["Tab","categories"]]}):focus==="categories"&&!searching?$jsx(HintBar,{pairs:[["\u2191\u2193","select"],["Tab","fields"]]}):$jsx(HintBar,{pairs:[[keys.print("config.mode"),"yaml"],["Tab","categories"],["\u2191\u2193","nav"],[keys.print("list.search"),"search"],[keys.print("config.save"),"save"]],suffix:nChanged>0?`\u25CF ${nChanged} unsaved`:void 0})]})});var import_react88=__toESM(require_react_production(),1);var import_react86=__toESM(require_react_production(),1);var iso2=(s)=>{if(!s)return null;let t2=Date.parse(s);return Number.isFinite(t2)?Math.floor(t2/1000):null},parseList=(stdout)=>stdout.split(`
4127
4127
  `).map((s)=>s.trim()).filter((s)=>s.length>0&&!s.startsWith("(")),CuratorDialog=()=>{let{theme,syntaxStyle}=useTheme(),gw=useGateway(),toast=useToast(),dialog=useDialog(),state2=useHome("curatorState"),cfg=useHome("config")?.curator,[report2,setReport]=import_react86.useState(null),[loaded,setLoaded]=import_react86.useState(!1),[busy,setBusy]=import_react86.useState(null),[archived,setArchived]=import_react86.useState([]),[mode,setMode]=import_react86.useState("report"),[sel,setSel]=import_react86.useState(0),sb=import_react86.useRef(null);import_react86.useEffect(()=>{readLatestCuratorReport().then((r)=>{setReport(r),setLoaded(!0)}).catch(()=>setLoaded(!0))},[]);let refreshArchived=import_react86.useCallback(()=>{gw.request("shell.exec",{command:"hermes curator list-archived"}).then((r)=>{if(r.code===0)setArchived(parseList(r.stdout))}).catch(()=>{})},[gw]);import_react86.useEffect(()=>{refreshArchived()},[refreshArchived]);let sh=import_react86.useCallback((verb,ok)=>{if(busy)return;setBusy(verb),gw.request("shell.exec",{command:`hermes curator ${verb}`}).then((r)=>{if(r.code!==0)throw Error((r.stderr||r.stdout||`exit ${r.code}`).trim());toast.show({variant:"success",message:ok}),home2.invalidate("curatorState")}).catch((e)=>toast.show({variant:"error",message:trunc5(e.message,120)})).finally(()=>setBusy(null))},[gw,toast,busy]),restore=import_react86.useCallback((name)=>{if(busy)return;setBusy("restore"),gw.request("shell.exec",{command:`hermes curator restore ${name}`}).then((r)=>{if(r.code!==0)throw Error((r.stderr||r.stdout||`exit ${r.code}`).trim());toast.show({variant:"success",message:`Restored ${name}`}),setArchived((prev)=>prev.filter((n)=>n!==name)),setSel((s)=>Math.max(0,s-1))}).catch((e)=>toast.show({variant:"error",message:trunc5(e.message,120)})).finally(()=>setBusy(null))},[gw,toast,busy]);useKeyboard((key2)=>{if(mode==="archived"){if(key2.name==="escape"){setMode("report");return}if(key2.raw==="a"){setMode("report");return}if(key2.name==="up")return setSel((s)=>Math.max(0,s-1));if(key2.name==="down")return setSel((s)=>Math.min(archived.length-1,s+1));if(key2.name==="return"){let name=archived[sel];if(name)restore(name);return}return}if(key2.name==="escape")return dialog.clear();if(key2.raw==="r")return sh("run","Curator run started (background)");if(key2.raw==="p")return state2?.paused?sh("resume","Curator resumed"):sh("pause","Curator paused");if(key2.raw==="a"&&archived.length>0)setSel(0),setMode("archived")}),import_react86.useEffect(()=>{if(mode==="archived")sb.current?.scrollChildIntoView(`arch-${sel}`)},[sel,mode]);let last3=iso2(state2?.last_run_at??null),due=last3&&cfg?last3+cfg.interval_hours*3600:null,status=cfg?.enabled===!1?"disabled":state2?.paused?"paused":"enabled",tint=status==="enabled"?theme.success:status==="paused"?theme.warning:theme.textMuted;return $jsxs("box",{flexDirection:"column",width:120,height:34,children:[$jsxs("box",{height:1,flexDirection:"row",children:[$jsxs("text",{children:[$jsx("span",{fg:theme.primary,children:$jsx("strong",{children:"Skill Curator"})}),$jsx("span",{fg:tint,children:` \xB7 ${status}`})]}),busy?$jsx("box",{marginLeft:2,children:$jsx(Spinner,{color:theme.textMuted,label:busy})}):null]}),$jsx("box",{height:1,children:$jsx("text",{fg:theme.textMuted,children:state2?`${state2.run_count} run${state2.run_count===1?"":"s"}${last3?" \xB7 last "+ago(last3):" \xB7 never"} \xB7 Esc to close`:"No curator state yet \xB7 Esc to close"})}),$jsx("box",{height:1}),$jsxs("box",{flexDirection:"row",flexGrow:1,gap:2,children:[$jsxs("box",{flexDirection:"column",width:40,height:"100%",flexShrink:0,children:[$jsx(KVBlock,{rows:[["Next run",status!=="enabled"?`\u2014 (${status})`:due?until(due):"when idle"],["Last run",last3?ago(last3):"never"],["Duration",state2?.last_run_duration_seconds?dur2(state2.last_run_duration_seconds):void 0],["Archived",archived.length>0?String(archived.length):void 0]]}),$jsx("box",{height:1}),$jsx("box",{height:1,children:$jsx("text",{fg:theme.textMuted,children:"Config \xB7 edit in Config tab"})}),$jsx(KVBlock,{rows:[["Interval",cfg?`${cfg.interval_hours}h`:"\u2014"],["Stale after",cfg?`${cfg.stale_after_days}d`:"\u2014"],["Archive after",cfg?`${cfg.archive_after_days}d`:"\u2014"]]}),$jsx("box",{height:1}),$jsxs("box",{flexDirection:"column",children:[$jsx("box",{height:1,children:$jsxs("text",{children:[$jsx("span",{fg:theme.accent,children:"r "}),$jsx("span",{fg:theme.text,children:"run now"}),$jsx("span",{fg:theme.textMuted,children:" (background)"})]})}),$jsx("box",{height:1,children:$jsxs("text",{children:[$jsx("span",{fg:theme.accent,children:"p "}),$jsx("span",{fg:theme.text,children:state2?.paused?"resume":"pause"})]})}),archived.length>0?$jsx("box",{height:1,children:$jsxs("text",{children:[$jsx("span",{fg:theme.accent,children:"a "}),$jsx("span",{fg:theme.text,children:"archived skills"}),$jsx("span",{fg:theme.textMuted,children:` (${archived.length})`})]})}):null]}),state2?.last_run_summary?$jsxs($Fragment,{children:[$jsx("box",{height:1}),$jsx("box",{height:1,children:$jsx("text",{fg:theme.textMuted,children:"Last run"})}),$jsx("scrollbox",{scrollY:!0,flexGrow:1,children:$jsx("markdown",{content:state2.last_run_summary,fg:theme.markdownText,syntaxStyle})})]}):null]}),mode==="archived"?$jsxs("box",{flexDirection:"column",flexGrow:1,height:"100%",minWidth:0,children:[$jsx("box",{height:1,children:$jsx("text",{fg:theme.info,children:$jsx("strong",{children:`\u25BE Archived skills (${archived.length})`})})}),$jsx("box",{height:1,children:$jsx("text",{fg:theme.textMuted,children:"\u2191\u2193 select \xB7 Enter restore \xB7 a/Esc back to report"})}),$jsx("box",{height:1}),$jsx("scrollbox",{ref:sb,scrollY:!0,flexGrow:1,border:!0,borderColor:theme.border,paddingLeft:1,paddingRight:1,contentOptions:{flexDirection:"column"},children:archived.length===0?$jsx("text",{fg:theme.textMuted,children:"No archived skills."}):archived.map((name,i)=>$jsx("box",{id:`arch-${i}`,height:1,backgroundColor:i===sel?theme.backgroundElement:void 0,onMouseMove:()=>setSel(i),onMouseDown:()=>restore(name),children:$jsxs("text",{fg:i===sel?theme.text:theme.textMuted,children:[i===sel?"\u25B8 ":" ",name]})},name))})]}):!loaded?$jsx("box",{height:1,children:$jsx("text",{fg:theme.textMuted,children:"loading report\u2026"})}):report2?$jsxs("box",{flexDirection:"column",flexGrow:1,height:"100%",minWidth:0,children:[$jsx("box",{height:1,children:$jsx("text",{fg:theme.info,children:$jsx("strong",{children:`\u25BE Report \xB7 ${report2.runId}`})})}),$jsx(KVLink,{label:"File",source:report2.source,text:report2.source.relative}),$jsx("box",{height:1}),$jsx("scrollbox",{scrollY:!0,flexGrow:1,border:!0,borderColor:theme.border,paddingLeft:1,paddingRight:1,children:$jsx("box",{flexDirection:"column",width:"100%",children:$jsx("markdown",{content:report2.content||"(empty)",fg:theme.markdownText,syntaxStyle})})})]}):$jsx("box",{height:1,children:$jsx("text",{fg:theme.textMuted,children:"No runs yet \u2014 curator has not completed a cycle."})})]})]})},openCurator=(dialog)=>dialog.replace($jsx(CuratorDialog,{}),void 0,{ownCancel:!0});var NO_EVENTS=[],iso3=(s)=>{if(!s)return null;let t2=Date.parse(s);return Number.isFinite(t2)?Math.floor(t2/1000):null},SkillRow=import_react88.memo((props)=>{let theme=useTheme().theme,s=props.skill,u3=props.usage,bg2=props.selected?theme.backgroundElement:void 0,used=iso3(u3?.last_used_at)??iso3(u3?.last_viewed_at),stale=u3?.state==="stale",archived=u3?.state==="archived";return $jsxs("box",{id:props.id,flexDirection:"row",height:1,backgroundColor:bg2,onMouseDown:props.onSelect,onMouseMove:props.onHover,children:[$jsx(Col,{w:2,fg:props.selected?theme.primary:theme.text,children:props.selected?"\u25B8 ":" "}),$jsx(Col,{w:2,fg:theme.warning,children:u3?.pinned?"\uD83D\uDCCC":" "}),$jsx(Marquee,{grow:!0,min:8,active:props.selected,fg:archived?theme.textMuted:props.selected?theme.accent:theme.text,children:s.name}),archived?$jsx(Col,{w:10,fg:theme.textMuted,children:"archived"}):stale?$jsx(Col,{w:10,fg:theme.warning,children:"stale"}):$jsx(Col,{w:10,fg:theme.textMuted,children:used?ago(used):""})]})}),HitRow=import_react88.memo((props)=>{let theme=useTheme().theme,on=props.selected;return $jsxs("box",{flexDirection:"row",height:1,backgroundColor:on?theme.backgroundElement:void 0,onMouseMove:props.onHover,children:[$jsx(Col,{w:2,fg:on?theme.primary:theme.textMuted,children:on?"\u25B8 ":" "}),$jsx(Col,{w:28,fg:on?theme.accent:theme.text,children:props.hit.name}),$jsx(Col,{grow:!0,min:8,fg:theme.textMuted,children:props.hit.description||"\u2014"})]})}),bycat=(skills)=>skills.reduce((map,s)=>{let cat=s.category||"uncategorized";return map.set(cat,[...map.get(cat)??[],s]),map},new Map),line2=(e)=>{switch(e.kind){case"absorbed":return`absorbed ${e.sources.map((s)=>`\`${s}\``).join(", ")}`;case"merged":return`merged into \`${e.into}\`${e.reason?` \u2014 ${e.reason}`:""}`;case"transition":return`${e.from} \u2192 ${e.to}`;case"pruned":return`pruned${e.reason?` \u2014 ${e.reason}`:""}`;case"added":return"created by curator"}},DetailPanel2=import_react88.memo((props)=>{let theme=useTheme().theme,s=props.skill,u3=props.usage,used=iso3(u3?.last_used_at),viewed=iso3(u3?.last_viewed_at),patched=iso3(u3?.last_patched_at);return $jsxs("box",{flexDirection:"column",padding:1,border:!0,borderColor:theme.border,backgroundColor:theme.backgroundPanel,width:"50%",children:[$jsx("box",{height:1,children:$jsxs("text",{children:[$jsx("span",{fg:theme.primary,children:$jsx("strong",{children:"Skill Detail"})}),u3?.pinned?$jsx("span",{fg:theme.warning,children:" \uD83D\uDCCC pinned"}):null,u3?.state==="stale"?$jsx("span",{fg:theme.warning,children:" \xB7 stale"}):null,u3?.state==="archived"?$jsx("span",{fg:theme.textMuted,children:" \xB7 archived"}):null]})}),$jsx("box",{height:1}),$jsx("box",{height:1,children:$jsx("text",{fg:theme.accent,children:$jsx("strong",{children:s.name})})}),$jsx("box",{height:1}),$jsx(KVBlock,{rows:[["Category",s.category||"uncategorized",theme.info],["Tags",s.tags.length>0?s.tags.join(", "):void 0],u3?["Used",u3.use_count>0?`${u3.use_count}\xD7 \xB7 last ${used?ago(used):"never"}`:"never"]:null,u3&&viewed?["Viewed",`${u3.view_count}\xD7 \xB7 last ${ago(viewed)}`]:null,u3&&patched?["Patched",`${u3.patch_count}\xD7 \xB7 last ${ago(patched)}`]:null].filter(Boolean)}),$jsx(KVLink,{label:"File",source:s.source,text:s.source.relative}),$jsx("box",{height:1}),s.description?$jsx("text",{wrapMode:"word",children:$jsx("span",{fg:theme.text,children:s.description})}):$jsx("text",{fg:theme.textMuted,children:"No description"}),props.events.length>0?$jsxs("box",{flexDirection:"column",marginTop:1,children:[$jsx("box",{height:1,children:$jsx("text",{fg:theme.textMuted,children:"Curator lineage"})}),props.events.map((e,i)=>$jsxs("box",{flexDirection:"row",minHeight:1,children:[$jsx("box",{width:10,flexShrink:0,children:$jsx("text",{fg:theme.textMuted,children:ago(e.at)})}),$jsx("box",{flexGrow:1,minHeight:1,children:$jsx("text",{wrapMode:"word",fg:theme.text,children:line2(e)})})]},i))]}):u3?$jsx("box",{height:1,marginTop:1,children:$jsx("text",{fg:theme.textMuted,children:"No curator events for this skill"})}):null]})}),EmptyState=import_react88.memo((props)=>{let theme=useTheme().theme;return $jsx("box",{flexGrow:1,padding:2,children:$jsx("text",{children:$jsx("span",{fg:theme.textMuted,children:props.searching?"No matching skills on hub":"No skills found in ~/.hermes/skills/"})})})}),HistoryPanel=import_react88.memo((props)=>{let{theme,syntaxStyle}=useTheme(),keys=useKeys(),follow=useFollow("skills-history"),[runs,setRuns]=import_react88.useState(()=>listCuratorRuns()),[sel,setSel]=import_react88.useState(0),[open2,setOpen]=import_react88.useState(!1),[body,setBody]=import_react88.useState(""),run=runs[sel];import_react88.useEffect(()=>{if(!open2||!run)return;let live=!0;return readCuratorReport(run.id).then((t2)=>{if(live)setBody(t2)}),()=>{live=!1}},[open2,run?.id]);let moveSel=import_react88.useCallback((v2)=>{setOpen(!1),setSel(v2)},[]);return useKeyboard((key2)=>{if(!props.focused)return;handleListKey(keys,key2,{count:runs.length,setSel:moveSel,...follow.opts,onActivate:()=>setOpen((o)=>!o),onRefresh:()=>setRuns(listCuratorRuns())})}),$jsxs("box",{flexDirection:"column",padding:1,border:!0,borderColor:props.focused?theme.primary:theme.border,backgroundColor:theme.backgroundPanel,width:"50%",children:[$jsx("box",{height:1,children:$jsxs("text",{children:[$jsx("span",{fg:theme.primary,children:$jsx("strong",{children:"Curator History"})}),$jsx("span",{fg:theme.textMuted,children:` ${runs.length} run${runs.length===1?"":"s"}${runs[0]?` \xB7 last ${ago(runs[0].at)}`:""}`})]})}),$jsx("box",{height:1,children:$jsx("text",{fg:theme.textMuted,children:`\u2191\u2193 select \xB7 Enter expand \xB7 ${keys.print("list.refresh")} reload \xB7 h close`})}),$jsx("box",{height:1}),runs.length===0?$jsx("text",{fg:theme.textMuted,children:"no runs in ~/.hermes/logs/curator/"}):$jsx("scrollbox",{ref:follow.ref,scrollY:!0,flexGrow:1,children:$jsx("box",{flexDirection:"column",width:"100%",children:runs.map((r,i)=>{let on=i===sel;return $jsxs("box",{id:follow.id(i),flexDirection:"column",children:[$jsxs("box",{height:1,flexDirection:"row",backgroundColor:on?theme.backgroundElement:void 0,onMouseDown:()=>{setSel(i),setOpen((o)=>i===sel?!o:!0)},children:[$jsx(Col,{w:2,fg:on?theme.primary:theme.textMuted,children:on?"\u25B8 ":" "}),$jsx(Col,{w:12,fg:on?theme.accent:theme.text,children:ago(r.at)}),$jsx(Col,{grow:!0,fg:theme.textMuted,children:`${r.before}\u2192${r.after} arch ${r.archived} cons ${r.consolidated}${r.added?` +${r.added}`:""}`})]}),on&&open2?$jsx("box",{marginLeft:2,marginTop:1,marginBottom:1,children:$jsx("markdown",{content:body||"\u2026",fg:theme.markdownText,syntaxStyle})}):null]},r.id)})})})]})}),Skills=import_react88.memo((props)=>{let theme=useTheme().theme,gw=useGateway(),dialog=useDialog(),toast=useToast(),usage=useHome("skillUsage")??{},curator=useHome("curatorState"),lineage2=import_react88.useRef(indexCuratorLineage());import_react88.useEffect(()=>{lineage2.current=indexCuratorLineage()},[curator?.run_count]);let[skills,setSkills]=import_react88.useState([]),[selected,setSelected]=import_react88.useState(0),[searching,setSearching]=import_react88.useState(!1),[query,setQuery]=import_react88.useState(""),[hits,setHits]=import_react88.useState([]),[sort,setSort]=import_react88.useState("name"),[history,setHistory]=import_react88.useState(!1),seq=import_react88.useRef(0),load4=import_react88.useCallback(()=>{gw.request("skills.manage",{action:"list"}).then((res)=>{let raw=res.skills??{},rows3=Object.entries(raw).flatMap(([cat,names])=>names.map((n)=>{let source=makeSource(`skills/${cat}/${n}/SKILL.md`,`${n}/SKILL.md`),fm=readSkillFrontmatter(source);return{source,category:cat,name:n,description:fm.description,tags:fm.tags,tokenEstimate:count2(`${n} ${fm.description}`)}}));rows3.sort((a,b2)=>a.source.relative.localeCompare(b2.source.relative)),setSkills(rows3)}).catch(()=>{})},[gw]);import_react88.useEffect(()=>{load4()},[load4]),import_react88.useEffect(()=>{let id=++seq.current;if(!searching||!query.trim()){setHits([]);return}let t2=setTimeout(()=>{gw.request("skills.manage",{action:"search",query}).then((r)=>{if(seq.current!==id)return;setHits(r.results??[]),setSelected(0)}).catch(()=>{if(seq.current===id)setHits([])})},150);return()=>clearTimeout(t2)},[gw,query,searching]);let flat=[...sort==="used"?new Map([["by recency",[...skills].sort((a,b2)=>{let ta=iso3(usage[a.name]?.last_used_at)??iso3(usage[a.name]?.last_viewed_at)??0;return(iso3(usage[b2.name]?.last_used_at)??iso3(usage[b2.name]?.last_viewed_at)??0)-ta})]]):bycat(skills)].flatMap(([cat,items])=>[{type:"header",category:cat},...items.map((s)=>({type:"skill",skill:s}))]),skillRows=flat.filter((r)=>r.type==="skill"),count3=searching?hits.length:skillRows.length,current=!searching&&skillRows[selected]?.type==="skill"?skillRows[selected].skill:null,follow=useFollow("sk"),exit=import_react88.useCallback(()=>{setSearching(!1),setQuery(""),setHits([]),setSelected(0)},[]),install2=import_react88.useCallback(async(name)=>{if(!await openConfirm(dialog,{title:"Install skill?",body:name,yes:"install"}))return;gw.request("skills.manage",{action:"install",query:name}).then(()=>{toast.show({variant:"success",message:`Installed ${name}`}),exit(),load4()}).catch((e)=>toast.show({variant:"error",message:`Install failed: ${e.message}`}))},[dialog,gw,toast,exit,load4]),keys=useKeys();useKeyboard((key2)=>{if(!props.focused||dialog.open())return;if(searching){if(key2.name==="escape"){exit();return}if(key2.name==="backspace"){setQuery((p)=>p.slice(0,-1)),setSelected(0);return}if(key2.name==="up")return setSelected((p)=>Math.max(0,p-1));if(key2.name==="down")return setSelected((p)=>Math.min(count3-1,p+1));if(key2.name==="return"){let hit=hits[selected];if(hit)install2(hit.name);return}if(key2.raw&&key2.raw.length===1&&key2.raw>=" ")setQuery((p)=>p+key2.raw),setSelected(0);return}if(!key2.ctrl&&!key2.meta&&key2.raw==="s"){setSort((p)=>p==="name"?"used":"name"),setSelected(0);return}if(!key2.ctrl&&!key2.meta&&key2.raw==="c"){openCurator(dialog);return}if(!key2.ctrl&&!key2.meta&&key2.raw==="h"){setHistory((h2)=>!h2);return}if(history){if(key2.name==="escape")return setHistory(!1);return}handleListKey(keys,key2,{count:count3,setSel:setSelected,...follow.opts,onRefresh:()=>{load4(),toast.show({variant:"info",message:"Reloaded",duration:1000})},onSearch:()=>{setSearching(!0),setQuery(""),setHits([]),setSelected(0)}})});let skillIdx=-1;return $jsxs("box",{flexDirection:"column",flexGrow:1,minWidth:0,children:[$jsxs("box",{flexDirection:"row",flexGrow:1,children:[$jsxs(TabShell,{title:searching?`Hub Search (${hits.length})`:`Skills (${skills.length}${sort==="used"?" \xB7 by use":""})`,children:[searching?$jsx("box",{height:1,children:$jsxs("text",{children:[$jsx("span",{fg:theme.accent,children:"/ "}),$jsx("span",{fg:theme.text,children:query}),$jsx("span",{fg:theme.accent,children:"\u2588"})]})}):null,searching?null:$jsxs(Hdr,{children:[$jsx(Col,{w:2,fg:theme.textMuted,children:""}),$jsx(Col,{grow:!0,min:8,fg:theme.textMuted,bold:!0,children:"Name"})]}),searching?null:$jsx("box",{height:1}),count3===0?$jsx(EmptyState,{searching}):searching?$jsx("scrollbox",{scrollY:!0,flexGrow:1,children:$jsx("box",{flexDirection:"column",width:"100%",children:hits.map((h2,i)=>$jsx(HitRow,{hit:h2,selected:i===selected,onHover:()=>setSelected(i)},h2.name))})}):$jsx("scrollbox",{ref:follow.ref,scrollY:!0,flexGrow:1,verticalScrollbarOptions:VBAR,children:flat.map((row2,i)=>{if(row2.type==="header")return $jsx("box",{marginTop:i>0?1:0,children:$jsx("text",{fg:theme.info,children:$jsx("strong",{children:`\u25BE ${row2.category}`})})},`h-${row2.category}`);skillIdx++;let idx=skillIdx;return $jsx(SkillRow,{id:follow.id(idx),skill:row2.skill,usage:usage[row2.skill.name],selected:idx===selected,onSelect:()=>setSelected(idx),onHover:()=>setSelected(idx)},row2.skill.name)})}),!searching&&curator?$jsx("box",{height:1,flexShrink:0,children:$jsxs("text",{children:[$jsx("span",{fg:theme.textMuted,children:"curator \xB7 "}),curator.paused?$jsx("span",{fg:theme.warning,children:"paused"}):curator.last_run_at?$jsx("span",{fg:theme.textMuted,children:`${curator.run_count} run${curator.run_count===1?"":"s"} \xB7 last ${ago(iso3(curator.last_run_at)??0)}`}):$jsx("span",{fg:theme.textMuted,children:"never run"})]})}):null]}),history?$jsx(HistoryPanel,{focused:!!props.focused&&!searching}):current?$jsx(DetailPanel2,{skill:current,usage:usage[current.name],events:lineage2.current.get(current.name)??NO_EVENTS}):null]}),$jsx(HintBar,{pairs:searching?[["\u2191\u2193","navigate"],["Enter","install"],["Esc","cancel"]]:[["\u2191\u2193","navigate"],[keys.print("list.search"),"search hub"],["s","sort"],["c","curator"],["h","history"],[keys.print("list.refresh"),"refresh"]]})]})});var import_react90=__toESM(require_react_production(),1);var kindOf=(ts)=>ts.name.includes(":")?"mcp":ts.name.startsWith("hermes-")?"platform":"core",KIND_LABEL={core:"core",platform:"platform bundles",mcp:"mcp"},group=(list2)=>{let by={core:[],platform:[],mcp:[]};for(let ts of list2)by[kindOf(ts)].push(ts);return["core","platform","mcp"].filter((k2)=>by[k2].length>0).map((k2)=>({kind:k2,items:by[k2]}))},Row2=import_react90.memo((props)=>{let theme=useTheme().theme,ts=props.ts,bg2=props.selected?theme.backgroundElement:void 0,unavail=ts.available===!1,glyph=unavail?"\u25CC":ts.enabled?"\u25CF":"\u25CB",glyphFg=unavail?theme.warning:ts.enabled?theme.success:theme.textMuted;return $jsxs("box",{id:props.id,flexDirection:"row",height:1,backgroundColor:bg2,onMouseDown:props.onSelect,onMouseMove:props.onHover,children:[$jsx(Col,{w:2,fg:props.selected?theme.primary:theme.text,children:props.selected?"\u25B8 ":" "}),$jsx(Col,{w:2,fg:glyphFg,children:`${glyph} `}),$jsx(Col,{grow:!0,fg:props.selected?theme.accent:theme.text,children:ts.name}),$jsx(Col,{w:9,fg:theme.info,right:!0,children:`${ts.tool_count} tools`})]})}),DetailPanel3=import_react90.memo((props)=>{let theme=useTheme().theme,ts=props.ts,unavail=ts.available===!1;return $jsxs("box",{flexDirection:"column",padding:1,border:!0,borderColor:theme.border,backgroundColor:theme.backgroundPanel,width:"40%",children:[$jsx("box",{height:1,children:$jsx("text",{fg:theme.accent,children:$jsx("strong",{children:ts.name})})}),$jsx("box",{height:1,children:$jsx("text",{fg:theme.textMuted,children:KIND_LABEL[kindOf(ts)]})}),$jsx("box",{height:1}),$jsx(KVBlock,{rows:[["Status",unavail?"unavailable":ts.enabled?"enabled":"disabled",unavail?theme.warning:ts.enabled?theme.success:theme.textMuted],["Tools",String(ts.tool_count),theme.info],["Includes",ts.includes?.length?ts.includes.join(", "):void 0,theme.text],["Requires",ts.requirements?.length?ts.requirements.join(", "):void 0,unavail?theme.warning:theme.text]]}),$jsx("box",{height:1}),$jsx("box",{minHeight:1,children:$jsx("text",{wrapMode:"word",fg:theme.text,children:ts.description||"\u2014"})}),ts.tools?.length?$jsxs($Fragment,{children:[$jsx("box",{height:1}),$jsx("box",{height:1,children:$jsxs("text",{fg:theme.textMuted,children:["Tools (",ts.tools.length,"):"]})}),$jsx("scrollbox",{flexGrow:1,scrollY:!0,children:ts.tools.map((n)=>$jsxs("text",{fg:theme.text,children:["\xB7 ",n]},n))})]}):null]})}),Toolsets=import_react90.memo((props)=>{let theme=useTheme().theme,gw=useGateway(),dialog=useDialog(),toast=useToast(),[list2,setList]=import_react90.useState([]),[sel,setSel]=import_react90.useState(0),[err,setErr]=import_react90.useState(null),secs=group(list2),flat=secs.flatMap((s)=>s.items),live=import_react90.useRef({flat,sel});live.current={flat,sel};let load4=import_react90.useCallback(()=>{gw.request("toolsets.list",{}).then((r)=>{setList(r.toolsets??[]),setErr(null)}).catch((e)=>setErr(e instanceof Error?e.message:String(e)))},[gw]);import_react90.useEffect(()=>{load4()},[load4]);let toggle=import_react90.useCallback(()=>{let ts2=live.current.flat[live.current.sel];if(!ts2)return;if(ts2.available===!1){toast.show({variant:"warning",message:`${ts2.name} is unavailable`});return}let action=ts2.enabled?"disable":"enable",was=ts2.enabled;setList((prev)=>prev.map((t2)=>t2.name===ts2.name?{...t2,enabled:!t2.enabled}:t2)),gw.request("tools.configure",{action,names:[ts2.name]}).then((r)=>{if(r.unknown?.includes(ts2.name)){setList((prev)=>prev.map((t2)=>t2.name===ts2.name?{...t2,enabled:was}:t2)),toast.show({variant:"warning",message:`${ts2.name} is not configurable`});return}if(r.missing_servers?.length&&ts2.name.includes(":")){let server=ts2.name.split(":",1)[0];if(r.missing_servers.includes(server)){setList((prev)=>prev.map((t2)=>t2.name===ts2.name?{...t2,enabled:was}:t2)),toast.show({variant:"warning",message:`MCP server '${server}' not in config`});return}}if(Array.isArray(r.enabled_toolsets)){let on=new Set(r.enabled_toolsets);setList((prev)=>prev.map((t2)=>({...t2,enabled:on.has(t2.name)})))}else load4()}).catch((e)=>{setList((prev)=>prev.map((t2)=>t2.name===ts2.name?{...t2,enabled:was}:t2)),toast.show({variant:"error",message:e.message})})},[gw,toast,load4]),count3=flat.length,ts=flat[sel]??null,follow=useFollow("ts"),keys=useListKeys({active:()=>!!props.focused&&!dialog.open(),count:count3,setSel,...follow.opts,onToggle:toggle,onRefresh:()=>{load4(),toast.show({variant:"info",message:"Reloaded",duration:1000})}});return $jsxs("box",{flexDirection:"column",flexGrow:1,minWidth:0,children:[$jsxs("box",{flexDirection:"row",flexGrow:1,children:[$jsxs(TabShell,{title:`Toolsets (${count3})`,error:err,children:[$jsxs(Hdr,{children:[$jsx(Col,{w:4,fg:theme.textMuted,children:""}),$jsx(Col,{grow:!0,fg:theme.textMuted,bold:!0,children:"Name"}),$jsx(Col,{w:9,fg:theme.textMuted,bold:!0,right:!0,children:"Tools"})]}),$jsx("box",{height:1}),count3===0?$jsx("box",{flexGrow:1,padding:2,children:$jsx("text",{fg:theme.textMuted,children:"No toolsets found"})},"empty"):$jsx("scrollbox",{ref:follow.ref,scrollY:!0,flexGrow:1,verticalScrollbarOptions:VBAR,children:secs.reduce((acc2,s)=>{return acc2.out.push($jsx("box",{height:1,marginTop:acc2.base>0?1:0,children:$jsxs("text",{fg:theme.textMuted,children:["\u2500 ",KIND_LABEL[s.kind]," (",s.items.length,") "]})},`\xA7${s.kind}`)),s.items.forEach((t2,j2)=>{let i=acc2.base+j2;acc2.out.push($jsx(Row2,{id:follow.id(i),ts:t2,selected:i===sel,onSelect:()=>setSel(i),onHover:()=>setSel(i)},t2.name))}),acc2.base+=s.items.length,acc2},{base:0,out:[]}).out},"list")]}),ts?$jsx(DetailPanel3,{ts}):null]}),$jsx(HintBar,{pairs:[["\u2191\u2193","nav"],[keys.print("list.toggle"),"toggle"],[keys.print("list.refresh"),"refresh"]]})]})});var import_react91=__toESM(require_react_production(),1);var mask=(val)=>"\u2022".repeat(Math.min(val.length,12)),VarRow=import_react91.memo((props)=>{let theme=useTheme().theme,set2=props.value!==void 0,bg2=props.selected?theme.backgroundElement:void 0;return $jsxs("box",{id:props.id,flexDirection:"row",height:1,backgroundColor:bg2,onMouseDown:props.onClick,onMouseMove:props.onHover,children:[$jsx(Col,{w:2,fg:props.selected?theme.primary:theme.text,children:props.selected?"\u25B8 ":" "}),$jsx(Col,{w:28,fg:props.selected?theme.accent:theme.text,children:props.name}),$jsx(Col,{w:8,fg:set2?theme.success:theme.textMuted,children:set2?" SET ":"UNSET"}),$jsx(Col,{grow:!0,min:4,fg:props.shown?theme.text:theme.textMuted,children:set2?props.shown?props.value:mask(props.value):"\u2014"})]})}),Env=import_react91.memo((props)=>{let theme=useTheme().theme,dialog=useDialog(),toast=useToast(),vars=useHome("env")??{},[sel,setSel]=import_react91.useState(0),[reveal,setReveal]=import_react91.useState(new Set),[collapsed,setCollapsed]=import_react91.useState({}),[searching,setSearching]=import_react91.useState(!1),[query,setQuery]=import_react91.useState(""),known=new Set(ENV_CATALOG.flatMap((g)=>g.keys)),extra=Object.keys(vars).filter((k2)=>!known.has(k2)).sort(),rows3=(extra.length>0?[...ENV_CATALOG,{category:"Other",keys:extra}]:ENV_CATALOG).flatMap((g)=>{let keys2=searching&&query.trim()?g.keys.filter((k2)=>k2.toLowerCase().includes(query.toLowerCase())):g.keys;if(keys2.length===0)return[];let hide=collapsed[g.category]??!1,header={type:"header",category:g.category,collapsed:hide};if(hide)return[header];return[header,...keys2.map((key2)=>({type:"var",key:key2,value:vars[key2]}))]}),count3=rows3.length,cur=rows3[sel],setKeys=rows3.flatMap((r)=>r.type==="var"&&r.value!==void 0?[r.key]:[]),follow=useFollow("env"),edit=import_react91.useCallback(async(key2,initial)=>{let val=await openTextPrompt(dialog,{title:`Edit ${key2}`,label:"Value",initial});if(val==null)return;await writeEnvVar(key2,val),home2.invalidate("env"),toast.show({variant:"success",message:`${key2} saved`})},[dialog,toast]),add=import_react91.useCallback(async()=>{let key2=await openTextPrompt(dialog,{title:"New Variable",label:"Name (e.g. FOO_API_KEY)"});if(!key2)return;let val=await openTextPrompt(dialog,{title:`Set ${key2}`,label:"Value"});if(val==null)return;await writeEnvVar(key2,val),home2.invalidate("env"),toast.show({variant:"success",message:`${key2} added`})},[dialog,toast]),del=import_react91.useCallback(async(key2)=>{if(!await openConfirm(dialog,{title:"Delete Variable",body:`Remove ${key2} from .env?`,yes:"delete",danger:!0}))return;await removeEnvVar(key2),home2.invalidate("env"),toast.show({variant:"success",message:`${key2} removed`})},[dialog,toast]),revealAll=import_react91.useCallback(()=>setReveal((s)=>s.size===setKeys.length&&setKeys.length>0?new Set:new Set(setKeys)),[setKeys]),activateAt=import_react91.useCallback((i)=>{let r=rows3[i];if(r?.type==="header")return setCollapsed((p)=>({...p,[r.category]:!p[r.category]}));if(r?.type==="var"){if(r.value!==void 0&&!reveal.has(r.key))return setReveal((s)=>new Set(s).add(r.key));return void edit(r.key,r.value??"")}},[rows3,reveal,edit]),activate=import_react91.useCallback(()=>activateAt(sel),[activateAt,sel]),rowClick=import_react91.useCallback((i)=>{setSel(i),activateAt(i)},[activateAt]),keys=useKeys();return useKeyboard((key2)=>{if(!props.focused||dialog.open())return;if(searching){if(key2.name==="escape"){setSearching(!1),setQuery(""),setSel(0);return}if(key2.name==="backspace"){setQuery((q4)=>q4.slice(0,-1)),setSel(0);return}if(key2.name==="up")return setSel((p)=>Math.max(0,p-1));if(key2.name==="down")return setSel((p)=>Math.min(count3-1,p+1));if(key2.name==="return")return setSearching(!1),activate();if(key2.raw&&key2.raw.length===1&&key2.raw>=" "){setQuery((q4)=>q4+key2.raw),setSel(0);return}return}handleListKey(keys,key2,{count:count3,setSel,...follow.opts,onActivate:activate,onToggle:revealAll,onNew:add,onDelete:()=>{if(cur?.type==="var"&&cur.value!==void 0)del(cur.key)},onSearch:()=>{setSearching(!0),setQuery(""),setSel(0)},onRefresh:()=>{home2.invalidate("env"),toast.show({variant:"info",message:"Reloaded",duration:1000})}})}),$jsxs("box",{flexDirection:"column",flexGrow:1,minWidth:0,children:[$jsxs(TabShell,{title:searching?"Env (searching)":"Env / API Keys",children:[searching?$jsx("box",{height:1,children:$jsxs("text",{children:[$jsx("span",{fg:theme.accent,children:"/ "}),$jsx("span",{fg:theme.text,children:query}),$jsx("span",{fg:theme.accent,children:"\u2588"})]})}):null,$jsxs(Hdr,{children:[$jsx(Col,{w:2,fg:theme.textMuted,children:""}),$jsx(Col,{w:28,fg:theme.textMuted,bold:!0,children:"Name"}),$jsx(Col,{w:8,fg:theme.textMuted,bold:!0,children:"Status"}),$jsx(Col,{grow:!0,min:4,fg:theme.textMuted,bold:!0,children:"Value"})]}),$jsx("box",{height:1}),count3===0?$jsx("box",{flexGrow:1,padding:2,children:$jsx("text",{fg:theme.textMuted,children:searching?"No matching variables":"No variables configured"})},"empty"):$jsx("scrollbox",{ref:follow.ref,scrollY:!0,flexGrow:1,verticalScrollbarOptions:VBAR,children:$jsx("box",{flexDirection:"column",width:"100%",children:rows3.map((row2,i)=>row2.type==="header"?$jsx("box",{id:follow.id(i),marginTop:i>0?1:0,backgroundColor:i===sel?theme.backgroundElement:void 0,onMouseMove:()=>setSel(i),onMouseDown:()=>rowClick(i),children:$jsx("text",{fg:theme.info,children:$jsx("strong",{children:`${row2.collapsed?"\u25B8":"\u25BE"} ${row2.category}`})})},`h-${row2.category}`):$jsx(VarRow,{id:follow.id(i),name:row2.key,value:row2.value,shown:reveal.has(row2.key),selected:i===sel,onHover:()=>setSel(i),onClick:()=>rowClick(i)},row2.key))})},"list")]}),$jsx(HintBar,{pairs:searching?[["\u2191\u2193","move"],["Enter","reveal/edit"],["Esc","cancel"]]:[["\u2191\u2193","move"],[keys.print("list.activate"),"reveal/edit"],[keys.print("list.toggle"),"show-all"],[keys.print("list.new"),"new"],[keys.print("list.delete"),"delete"],[keys.print("list.search"),"search"],[keys.print("list.refresh"),"reload"]]})]})});var import_react93=__toESM(require_react_production(),1);function usageColor(pct,theme){if(pct>=95)return theme.error;if(pct>=80)return theme.warning;return theme.success}function bar2(pct,w2){let filled=Math.round(pct/100*w2);return"\u2588".repeat(filled)+"\u2591".repeat(w2-filled)}var DESC={builtin:"File-based \xA7-delimited entries (MEMORY.md + USER.md). Always active.",mem0:"Server-side LLM fact extraction with semantic search and reranking.",honcho:"AI-native cross-session user modeling with dialectic Q&A.",hindsight:"Knowledge graph with entity resolution and multi-strategy retrieval.",holographic:"Local SQLite fact store with FTS5, trust scoring, HRR retrieval.",openviking:"Session-managed memory with tiered retrieval.",retaindb:"Cloud memory API with hybrid search and 7 memory types.",byterover:"Persistent knowledge tree via brv CLI.",supermemory:"Semantic long-term memory with profile recall and session ingest."},Memory=import_react93.memo((props)=>{let theme=useTheme().theme,dialog=useDialog(),toast=useToast(),gw=useGateway(),[sel,setSel]=import_react93.useState(0),config=useHome("config"),memory=useHome("memory"),userProfile=useHome("userProfile"),providers=useHome("memoryProviders")??[],activity=useHome("memoryActivity")??[],cfg=config?.memory,active=cfg?.provider||"",cur=providers[sel],on=!!cur&&(cur.name==="builtin"||cur.name===active),toggle=async()=>{if(!cur||cur.name==="builtin")return;let isOn=cur.name===active;if(!await openConfirm(dialog,{title:isOn?"Deactivate memory provider?":"Activate memory provider?",body:isOn?`Clear '${cur.name}' as the active provider (revert to built-in only).`:`Set '${cur.name}' as the active provider. Ensure required env vars are set (Env tab).`,yes:isOn?"deactivate":"activate"}))return;let{writeConfig:writeConfig2}=await Promise.resolve().then(() => (init_lane(),exports_lane)),r=await writeConfig2(gw,[{key:"memory.provider",to:isOn?"":cur.name}]);if(r.failed.length)return toast.show({variant:"error",message:r.failed[0].err});home2.invalidate("config"),home2.invalidate("memoryProviders"),toast.show({variant:"success",message:isOn?"Deactivated":`Activated ${cur.name} \u2014 new sessions pick this up`})},keys=useListKeys({active:()=>!!props.focused&&!dialog.open(),count:providers.length,setSel,onToggle:toggle,onRefresh:()=>{home2.invalidate("memoryProviders"),home2.invalidate("memoryActivity"),toast.show({variant:"info",message:"Reloaded",duration:1000})}}),feed=!cur?[]:cur.name==="builtin"?activity:activity.filter((a)=>a.provider===cur.name);return $jsxs("box",{flexDirection:"column",flexGrow:1,minWidth:0,children:[$jsxs("box",{flexDirection:"row",flexGrow:1,children:[$jsx(TabShell,{title:"Memory Providers",grow:1,children:$jsx("scrollbox",{scrollY:!0,flexGrow:1,children:providers.map((p,i)=>{let pOn=p.name==="builtin"||p.name===active,has=Object.keys(p.config).length>0,dot=pOn?"\u25CF":has?"\u25D0":"\u25CB",fg2=pOn?theme.success:has?theme.warning:theme.textMuted,tag=pOn?"active":has?"configured":"";return $jsxs("box",{flexDirection:"column",marginBottom:1,backgroundColor:i===sel?theme.backgroundElement:void 0,onMouseDown:()=>setSel(i),onMouseMove:()=>setSel(i),children:[$jsx("box",{height:1,children:$jsxs("text",{children:[$jsxs("span",{fg:fg2,children:[dot," "]}),$jsx("span",{fg:i===sel?theme.accent:theme.text,children:p.name}),tag?$jsxs("span",{fg:fg2,children:[" (",tag,")"]}):null]})}),$jsx("box",{height:1,overflow:"hidden",paddingLeft:2,children:$jsx("text",{fg:theme.textMuted,children:DESC[p.name]||"\u2014"})})]},p.name)})})}),$jsx(TabShell,{title:cur?.name??"Provider",grow:2,children:cur?$jsx(ProviderDetail,{provider:cur,active,cfg,memory,userProfile,feed}):$jsx("text",{fg:theme.textMuted,children:"Select a provider"})})]}),$jsx(HintBar,{pairs:[["\u2191\u2193","select"],[keys.print("list.toggle"),"activate"]],suffix:on?"\u25CF active":"\u25CB inactive"})]})}),ProviderDetail=import_react93.memo((props)=>{let theme=useTheme().theme,p=props.provider,on=p.name==="builtin"||p.name===props.active;return $jsx("scrollbox",{scrollY:!0,flexGrow:1,children:$jsxs("box",{flexDirection:"column",children:[$jsx("box",{minHeight:1,children:$jsx("text",{wrapMode:"word",fg:theme.textMuted,children:DESC[p.name]||"Memory provider"})}),$jsx("box",{height:1}),p.name==="builtin"?$jsxs("box",{flexDirection:"column",children:[props.cfg?$jsxs($Fragment,{children:[$jsx(KVBlock,{rows:[["Notes",props.cfg.memory_enabled?"enabled":"disabled",props.cfg.memory_enabled?theme.success:theme.error],["Profile",props.cfg.user_profile_enabled?"enabled":"disabled",props.cfg.user_profile_enabled?theme.success:theme.error]]}),$jsx("box",{height:1})]}):null,$jsx(CapacityBar,{title:"Notes (MEMORY.md)",info:props.memory??null}),$jsx("box",{height:1}),$jsx(CapacityBar,{title:"Profile (USER.md)",info:props.userProfile??null})]}):null,p.name!=="builtin"&&on&&props.cfg?$jsxs($Fragment,{children:[$jsx("box",{height:1,children:$jsx("text",{fg:theme.accent,children:$jsx("strong",{children:"Agent Settings"})})}),$jsx(KVBlock,{rows:[["Nudge",`every ${props.cfg.nudge_interval} turns`],["Flush",`after ${props.cfg.flush_min_turns} turns`]]}),$jsx("box",{height:1})]}):null,Object.keys(p.config).length>0?$jsxs($Fragment,{children:[$jsx("box",{height:1,children:$jsx("text",{fg:theme.accent,children:$jsx("strong",{children:"Local Configuration"})})}),$jsx(KVBlock,{rows:Object.entries(p.config).map(([k2,v2])=>[k2,String(v2)])})]}):p.name!=="builtin"?$jsx("box",{height:1,marginTop:1,children:$jsx("text",{fg:theme.textMuted,children:"No local config found. Run `hermes memory setup` to configure."})}):null,$jsx(ActivityFeed,{items:props.feed,own:p.name})]})})}),OP_GLYPH={write:"+",read:"?"},ActivityFeed=import_react93.memo((props)=>{let theme=useTheme().theme,all=props.own==="builtin",nW=props.items.filter((a)=>a.op==="write").length;return $jsxs("box",{flexDirection:"column",marginTop:1,children:[$jsx("box",{height:1,children:$jsxs("text",{children:[$jsx("span",{fg:theme.accent,children:$jsx("strong",{children:"Recent Activity"})}),props.items.length?$jsxs("span",{fg:theme.textMuted,children:[" \xB7 ",nW," writes, ",props.items.length-nW," reads"]}):null]})}),props.items.length===0?$jsx("box",{height:1,children:$jsx("text",{fg:theme.textMuted,children:"No memory-tool calls in the last ~2000 messages"})}):null,props.items.map((a,i)=>$jsx("box",{height:1,flexDirection:"row",overflow:"hidden",children:$jsxs("text",{children:[$jsxs("span",{fg:a.op==="write"?theme.success:theme.textMuted,children:[OP_GLYPH[a.op]," "]}),$jsx("span",{fg:theme.textMuted,children:ago(a.ts).padEnd(8)}),all&&a.provider!=="builtin"?$jsxs("span",{fg:theme.primary,children:[a.provider,"\xB7"]}):null,$jsx("span",{fg:theme.text,children:a.verb}),$jsxs("span",{fg:theme.textMuted,children:[" ",a.summary]})]})},i))]})}),CapacityBar=import_react93.memo((props)=>{let theme=useTheme().theme;if(!props.info)return $jsx("box",{height:1,children:$jsxs("text",{fg:theme.textMuted,children:[props.title,": unavailable"]})});let color=usageColor(props.info.usagePercent,theme);return $jsxs("box",{flexDirection:"column",children:[$jsx("box",{height:1,children:$jsxs("text",{children:[$jsx("span",{fg:theme.text,children:props.title}),$jsxs("span",{fg:theme.textMuted,children:[" \xB7 ",props.info.entryCount," entries"]})]})}),$jsx("box",{height:1,children:$jsxs("text",{children:[$jsx("span",{fg:color,children:bar2(props.info.usagePercent,20)}),$jsxs("span",{fg:theme.textMuted,children:[" ",props.info.charCount,"/",props.info.charLimit," (",props.info.usagePercent,"%)"]})]})})]})});var ConfigGroup=import_react94.memo((props)=>{let keys=useKeys(),labels=SUB_TABS[CONFIG_TAB];import_react94.useEffect(()=>{if(props.sub>=labels.length)props.setSub(0)},[props.sub,labels.length]);let hint=`${keys.print("tab.prev")}/${keys.print("tab.next")} group \xB7 shift+\u2190/\u2192 sub`;return $jsxs("box",{flexDirection:"column",flexGrow:1,minWidth:0,children:[$jsx(SubTabBar,{tabs:labels,active:props.sub,onChange:props.setSub,hint}),$jsxs("box",{flexGrow:1,minWidth:0,flexDirection:"column",children:[$jsx(Pane3,{visible:props.sub===0,children:$jsx(Config,{focused:!!props.focused&&props.sub===0})}),$jsx(Pane3,{visible:props.sub===1,children:$jsx(Skills,{focused:!!props.focused&&props.sub===1})}),$jsx(Pane3,{visible:props.sub===2,children:$jsx(Toolsets,{focused:!!props.focused&&props.sub===2})}),$jsx(Pane3,{visible:props.sub===3,children:$jsx(Env,{focused:!!props.focused&&props.sub===3})}),$jsx(Pane3,{visible:props.sub===4,children:$jsx(Memory,{focused:!!props.focused&&props.sub===4})})]})]})}),Pane3=({visible,children:children2})=>visible?$jsx("box",{flexGrow:1,minWidth:0,minHeight:0,flexDirection:"column",children:children2}):null;var import_react105=__toESM(require_react_production(),1);var import_react101=__toESM(require_react_production(),1);import{readFileSync as readFileSync8,statSync as statSync6}from"fs";import{basename as basename10}from"path";var import_react95=__toESM(require_react_production(),1);var PathPrompt=(props)=>{let theme=useTheme().theme,[value,setValue]=import_react95.useState(props.initial??""),[items,setItems]=import_react95.useState([]),seq=import_react95.useRef(0),ok=(it)=>it.meta==="dir"||!props.filter||props.filter.test(it.text);return import_react95.useEffect(()=>{if(!value.trim()){setItems([]);return}let me2=++seq.current,t2=setTimeout(()=>{props.gw.request("complete.path",{word:value}).then((r)=>{if(seq.current===me2)setItems((r.items??[]).filter(ok).slice(0,5))}).catch(()=>{if(seq.current===me2)setItems([])})},120);return()=>clearTimeout(t2)},[value,props.gw]),useKeyboard((key2)=>{if(key2.name!=="tab")return;key2.preventDefault();let hit=items[0];if(hit)setValue(hit.text)}),$jsxs("box",{flexDirection:"column",width:72,children:[$jsx("box",{height:1,children:$jsx("text",{fg:theme.primary,children:$jsx("strong",{children:props.title})})}),$jsx("box",{height:1}),props.label?$jsx("box",{height:1,children:$jsx("text",{fg:theme.textMuted,children:props.label})}):null,$jsxs("box",{height:1,flexDirection:"row",overflow:"hidden",children:[$jsx("box",{flexShrink:0,children:$jsx("text",{fg:theme.accent,children:"\u2503 "})}),$jsx("box",{flexGrow:1,minWidth:0,height:1,overflow:"hidden",children:$jsx("input",{value,onInput:setValue,onSubmit:()=>{let v2=value.trim();if(v2)props.onSubmit(v2)},focused:!0,textColor:theme.text,backgroundColor:theme.backgroundElement,focusedBackgroundColor:theme.backgroundElement})})]}),$jsx("box",{height:1}),items.length>0?items.map((it)=>$jsxs("box",{height:1,flexDirection:"row",overflow:"hidden",children:[$jsx("box",{flexGrow:1,minWidth:0,height:1,overflow:"hidden",children:$jsx("text",{fg:theme.textMuted,children:it.text})}),it.meta?$jsx("box",{flexShrink:0,height:1,children:$jsx("text",{fg:theme.textMuted,children:` ${it.meta}`})}):null]},it.text)):null,items.length>0?$jsx("box",{height:1}):null,$jsx("box",{height:1,children:$jsx("text",{fg:theme.textMuted,children:value.trim()?`Tab complete \xB7 Enter confirm \xB7 Esc cancel${items.length>0?` \xB7 ${items.length} match${items.length===1?"":"es"}`:""}`:"Type a path \xB7 Esc cancel"})})]})};function openPathPrompt(dialog,gw,opts){return new Promise((resolve4)=>{dialog.replace($jsx(PathPrompt,{title:opts.title,label:opts.label,initial:opts.initial,filter:opts.filter,gw,onSubmit:(v2)=>{resolve4(v2),dialog.clear()}}),()=>resolve4(null))})}var import_react97=__toESM(require_react_production(),1);var BASE=`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "herm-tui",
3
- "version": "1.7.2-dev.1",
3
+ "version": "1.7.2-dev.2",
4
4
  "description": "A modern TUI for Hermes Agent",
5
5
  "license": "MIT",
6
6
  "repository": {