@north-light/crouter 0.3.219 → 0.3.220

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.
@@ -1636,7 +1636,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
1636
1636
  `);o8.mkdirSync(UY.dirname(et),{recursive:!0}),o8.writeFileSync(et,Nt),this.stop();let xt=[`Rendered line ${be} exceeds terminal width (${La(Ue)} > ${t}).`,"","This is likely caused by a custom TUI component not truncating its output.","Use visibleWidth() to measure and truncateToWidth() to truncate lines.","",`Debug log written to: ${et}`].join(`
1637
1637
  `);throw new Error(xt)}z+=Ue}let ne=ie;if(this.previousLines.length>m.length){if(ie<m.length-1){let Ue=m.length-1-ie;z+=`\x1B[${Ue}B`,ne=m.length-1}let be=this.previousLines.length-m.length;for(let Ue=m.length;Ue<this.previousLines.length;Ue++)z+=`\r
1638
1638
  \x1B[2K`;z+=`\x1B[${be}A`}if(z+="\x1B[?2026l",process.env.PI_TUI_DEBUG==="1"){let be="/tmp/tui";o8.mkdirSync(be,{recursive:!0});let Ue=UY.join(be,`render-${Date.now()}-${Math.random().toString(36).slice(2)}.log`),He=[`firstChanged: ${C}`,`viewportTop: ${p}`,`cursorRow: ${this.cursorRow}`,`height: ${r}`,`lineDiff: ${J}`,`hardwareCursorRow: ${f}`,`renderEnd: ${ie}`,`finalCursorRow: ${ne}`,`cursorPos: ${JSON.stringify(g)}`,`newLines.length: ${m.length}`,`previousLines.length: ${this.previousLines.length}`,"","=== newLines ===",JSON.stringify(m,null,2),"","=== previousLines ===",JSON.stringify(this.previousLines,null,2),"","=== buffer ===",JSON.stringify(z)].join(`
1639
- `);o8.writeFileSync(Ue,He)}this.terminal.write(z),this.cursorRow=Math.max(0,m.length-1),this.hardwareCursorRow=ne,this.maxLinesRendered=Math.max(this.maxLinesRendered,m.length),this.previousViewportTop=Math.max(u,ne-r+1),this.positionHardwareCursor(g,m.length),this.previousLines=m,this.previousKittyImageIds=this.collectKittyImageIds(m),this.previousWidth=t,this.previousHeight=r}positionHardwareCursor(t,r){if(!t||r<=0){this.terminal.hideCursor();return}let i=Math.max(0,Math.min(t.row,r-1)),o=Math.max(0,t.col),a=i-this.hardwareCursorRow,u="";a>0?u+=`\x1B[${a}B`:a<0&&(u+=`\x1B[${-a}A`),u+=`\x1B[${o+1}G`,u&&this.terminal.write(u),this.hardwareCursorRow=i,this.getShowHardwareCursor()?this.terminal.showCursor():this.terminal.hideCursor()}};var zY="\x1B[0m",Q$e="\x1B[38;5;180m",PNi="\x1B[38;5;137m",ONi="\x1B[1m",W$e="\x1B[2m";function $Y(e){return Q$e+e.replace(/\./g,`${PNi}.${Q$e}`)+zY}var S0r=[$Y(" ________"),$Y(" / /|"),$Y(" / . . / |"),$Y(" /_______/ |"),$Y(" | . . | |"),$Y(" | . . | /"),$Y(" |_______|/")];function T0r(e={}){let r=[`${ONi}${Q$e}crouter${zY}${e.version?`${W$e} v${e.version}${zY}`:""}`,`${W$e}the agentic runtime${zY}`];e.profile&&r.push(`${W$e}profile: ${zY}${Q$e}${e.profile}${zY}`),e.cwd&&r.push(`${W$e}${e.cwd}${zY}`);let i=[];for(let o=0;o<S0r.length;o++){let a=o>=1&&o-1<r.length?` ${r[o-1]}`:"";i.push(S0r[o]+a)}return i}import{execFile as qDi,spawnSync as FTr}from"node:child_process";function DNi(e,t,r,i,o,a,u,p,f){return Object.freeze({id:e,group:t,name:r,description:i,defaults:Object.freeze([...o]),inputKind:a,contexts:Object.freeze([...u]),...p===void 0?{}:{safety:p},...f===void 0?{}:{pair:Object.freeze({...f})}})}var Ha=DNi;function Vb(e,t,r,i,o){let a=`crtr.tmux.menu.${e}`,u=`crtr.tmux.menu-global.${e}`;return[Ha(a,"Global tmux",t,r,i,"tmux-menu-selector",o,void 0,{field:"menu",pairedId:u}),Ha(u,"Global tmux",t,r,[],"tmux-global-action",["tmux.root"],void 0,{field:"global",pairedId:a})]}function hP(e,t,r,i,o,a){return[Ha(e,"Attach",r,i,o,"tmux-menu-selector",["tmux.menu.attach"],void 0,{field:"menu",pairedId:t}),Ha(t,"Attach",r,i,a,"host-global",s7,void 0,{field:"direct",pairedId:e})]}var s7=["attach","graph","graph.confirm"],MNi=["setup.login","setup.list","setup.input","setup.keybindings","setup.keybindings.edit","setup.keybindings.filter","setup.models"],v0r=["setup.login","setup.list","setup.keybindings","setup.models"],_P=Object.freeze([Ha("crtr.tmux.menu.open","Global tmux","Open crouter menu","Open the crouter action menu.",["alt+c"],"host-global",["tmux.root"]),Ha("crtr.tmux.menu.attach","Global tmux","Attach actions","Open the attach-viewer action submenu.",["a"],"tmux-menu-selector",["tmux.menu"]),...Vb("promote","Promote to orchestrator","Promote the focused node to orchestrator \u2014 it holds a roadmap and delegates.",["o"],["tmux.menu"]),...Vb("demote-mode","Demote to base node","Demote the focused orchestrator back to a base node \u2014 hands-on again in its own window, no roadmap to drive.",["shift+o"],["tmux.menu"]),...Vb("resume","Find node","Open the canvas navigator and go to the chosen node.",["/"],["tmux.menu"]),...Vb("fork","Fork node","Fork the focused node into an independent idle root.",["f"],["tmux.menu"]),...Vb("demote","Demote to terminal","Demote the focused node to terminal \u2014 it keeps running, owes a final up the spine, and reaps when done.",["d"],["tmux.menu"]),...Vb("make-resident","Make resident","Flip the focused node to resident \u2014 interactable, never forced to submit a final, and wakeable while attached or awaiting something live.",["shift+r"],["tmux.menu"]),...Vb("detach","Demote and close viewer","Demote the focused node and close its viewer; its broker keeps running off-screen.",["shift+d"],["tmux.menu"]),...Vb("close-subtree","Close subtree","Close the focused node and its subtree.",["x"],["tmux.menu"]),...Vb("background-bash","Background running bash","Hand the focused node\u2019s running bash command to its background job system.",["b"],["tmux.menu"]),...Vb("file-review","Review a file","Open a line-anchored review of a file named in the transcript.",["v"],["tmux.menu"]),...Vb("pin","Pin conversation","Pin or unpin this conversation in the canvas navigator.",["p"],["tmux.menu"]),...Vb("show","Inspect node","Open the focused node\u2019s inspection menu.",["i"],["tmux.menu"]),...Vb("view-settings","Display settings","Open the viewer display-settings menu.",["z"],["tmux.menu"]),...Vb("fold-tools","Fold finished tool calls","Fold every finished tool call in the transcript to its single call line.",["f"],["tmux.menu.view-settings"]),...Vb("metadata","Show metadata","Show the focused node\u2019s metadata dossier.",["m"],["tmux.menu.show"]),...Vb("context","Browse context","Browse the focused node context.",["c"],["tmux.menu.show"]),...Vb("providers","Open settings","Open the crouter settings panel.",[","],["tmux.menu"]),...Vb("plugins","Browse plugins","Open the crouter plugin browser.",["k"],["tmux.menu"]),...Vb("graph","Canvas graph","Open the canvas graph.",["g"],["tmux.menu"]),...Vb("focus-manager","Go to manager","Focus this node\u2019s manager.",["h"],["tmux.menu"]),...Vb("copy-id","Copy node id","Copy the focused node id to the system clipboard.",["y"],["tmux.menu"]),...Vb("reload-viewer","Reload viewer","Respawn this pane\u2019s viewer onto the current runtime generation.",["r"],["tmux.menu"]),...Vb("recap","Generate recap","Generate the focused node\u2019s Goal and State recap and refresh its generated title.",["s"],["tmux.menu"]),...Vb("issues","Open create menu","Open the create submenu.",["c"],["tmux.menu"]),...Vb("issue.idea","Create idea","Create an idea issue.",["i"],["tmux.menu.issue"]),...Vb("issue.bug","Create bug","Create a bug issue.",["b"],["tmux.menu.issue"]),Ha("crtr.tmux.node.next","Global tmux","Next node","Focus the next canvas node.",["alt+]"],"host-global",["tmux.root"]),Ha("crtr.tmux.node.previous","Global tmux","Previous node","Focus the previous canvas node.",["alt+["],"host-global",["tmux.root"]),Ha("crtr.tmux.inbox.toggle","Global tmux","Toggle inbox","Open or close the human inbox in the focused viewer.",["alt+i"],"host-global",["tmux.root"]),...hP("crtr.tmux.menu.attach.detach","crtr.attach.detach","Detach","Detach from the node.",["d"],["ctrl+d"]),...hP("crtr.tmux.menu.attach.clear-or-detach","crtr.attach.clear-or-detach","Clear input (detach if empty)","Clear input or detach when input is empty.",["c"],["ctrl+c"]),...hP("crtr.tmux.menu.attach.graph.toggle","crtr.attach.graph.toggle","Toggle graph","Open or close the graph overlay.",["g"],["alt+g"]),...hP("crtr.tmux.menu.attach.help.toggle","crtr.attach.help.toggle","Help","Open the attach help overlay.",["k"],["alt+shift+k"]),...hP("crtr.tmux.menu.attach.inbox.toggle","crtr.attach.inbox.toggle","Toggle inbox","Open or close the human inbox surface in this viewer.",["i"],[]),...hP("crtr.tmux.menu.attach.inbox-strip","crtr.attach.inbox-strip","Pending requests","Jump to the pending human-request strip at the top of the pane.",["u"],["alt+u"]),...hP("crtr.tmux.menu.attach.model-ladder.next","crtr.attach.model-ladder.next","Next model","Move to the next model ladder rung.",["]"],["alt+m"]),...hP("crtr.tmux.menu.attach.model-ladder.previous","crtr.attach.model-ladder.previous","Previous model","Move to the previous model ladder rung.",["["],["alt+shift+m"]),...hP("crtr.tmux.menu.attach.command.inspect","crtr.attach.command.inspect","Inspect loaded command","Open the loaded slash command\u2019s expanded prompt.",["h"],["alt+shift+h"]),...hP("crtr.tmux.menu.attach.file-review","crtr.attach.file-review","Review a file","Open a line-anchored review of a file named in the transcript.",[],["alt+shift+r"]),...hP("crtr.tmux.menu.attach.profile-files","crtr.attach.profile-files","Search profile files","Search files across the node\u2019s profile projects, profile memory, cwd, and ancestor crouter memory stores.",["f"],["ctrl+f"]),...hP("crtr.tmux.menu.attach.search","crtr.attach.search","Search transcript","Search the transcript as it is currently displayed \u2014 folded tool output is not searched until it is unfolded.",["/"],["alt+/"]),...hP("crtr.tmux.menu.attach.whip","crtr.attach.whip","Whip agent","Interrupt the agent and send a playful command.",["w"],[]),Ha("crtr.attach.scroll.up","Attach","Scroll up","Scroll the transcript one line up.",["shift+up"],"terminal",s7),Ha("crtr.attach.scroll.down","Attach","Scroll down","Scroll the transcript one line down.",["shift+down"],"terminal",s7),Ha("crtr.attach.scroll.page-up","Attach","Scroll page up","Scroll the transcript one page up.",["pageup"],"terminal",s7),Ha("crtr.attach.scroll.page-down","Attach","Scroll page down","Scroll the transcript one page down.",["pagedown"],"terminal",s7),Ha("crtr.attach.scroll.live","Attach","Return to live","Return the transcript to the live bottom.",["shift+end"],"terminal",s7),Ha("crtr.attach.mouse.toggle","Attach","Toggle mouse wheel scrolling","Toggle mouse wheel scrolling on or off.",["alt+shift+o"],"terminal",s7),Ha("crtr.attach.copy.message","Attach","Copy visible message","Copy the newest message visible in the transcript viewport.",["alt+shift+y"],"terminal",s7),Ha("crtr.attach.search.next","Attach","Next match","Move to the next transcript search match.",["n"],"terminal",["attach.search"]),Ha("crtr.attach.search.previous","Attach","Previous match","Move to the previous transcript search match.",["shift+n"],"terminal",["attach.search"]),Ha("crtr.attach.search.edit","Attach","Edit query","Return to editing the transcript search query.",["/"],"terminal",["attach.search"]),Ha("crtr.attach.search.close","Attach","Close search","Leave transcript search and clear its highlights.",["escape"],"terminal",["attach.search"],"dismiss-modal"),Ha("crtr.graph.down","GRAPH","Move down","Move to the next graph row.",["j"],"terminal",["graph"]),Ha("crtr.graph.up","GRAPH","Move up","Move to the previous graph row.",["k"],"terminal",["graph"]),Ha("crtr.graph.first","GRAPH","First row","Move to the first graph row.",["g"],"terminal",["graph"]),Ha("crtr.graph.last","GRAPH","Last row","Move to the last graph row.",["shift+g"],"terminal",["graph"]),Ha("crtr.graph.collapse-or-manager","GRAPH","Collapse or manager","Collapse a node or move to its manager.",["h"],"terminal",["graph"]),Ha("crtr.graph.expand-or-child","GRAPH","Expand or child","Expand a node or move to its child.",["l"],"terminal",["graph"]),Ha("crtr.graph.focus","GRAPH","Focus node","Focus the selected node.",["enter"],"terminal",["graph"]),Ha("crtr.graph.revive","GRAPH","Revive node","Revive and open the selected dormant node.",["r"],"terminal",["graph"]),Ha("crtr.graph.focus-manager","GRAPH","Focus manager","Focus the selected node manager.",["m"],"terminal",["graph"]),Ha("crtr.graph.close-subtree","GRAPH","Close subtree","Ask to close the selected subtree.",["x"],"terminal",["graph"]),Ha("crtr.graph.dismiss","GRAPH","Dismiss graph","Close the graph overlay.",["escape"],"terminal",["graph"],"dismiss-modal"),Ha("crtr.graph.confirm.accept","GRAPH","Confirm close","Confirm closing the selected subtree.",["y"],"terminal",["graph.confirm"]),Ha("crtr.graph.confirm.cancel","GRAPH","Cancel close","Cancel closing the selected subtree.",["n","escape"],"terminal",["graph.confirm"],"dismiss-modal"),Ha("crtr.inspector.force-quit","Inspector","Force quit Inspector","Immediately leave the Inspector.",["ctrl+c"],"host-global",["inspector"],"leave-screen"),Ha("crtr.inspector.down","Inspector","Move down","Move the Inspector selection or scroll cursor down.",["j","down"],"terminal",["inspector"]),Ha("crtr.inspector.up","Inspector","Move up","Move the Inspector selection or scroll cursor up.",["k","up"],"terminal",["inspector"]),Ha("crtr.inspector.section-next","Inspector","Next section","Move to the next Inspector section.",["tab"],"terminal",["inspector"]),Ha("crtr.inspector.section-prev","Inspector","Previous section","Move to the previous Inspector section.",["shift+tab"],"terminal",["inspector"]),Ha("crtr.inspector.page-down","Inspector","Page down","Scroll the Inspector detail body down.",["ctrl+d","pagedown"],"terminal",["inspector"]),Ha("crtr.inspector.page-up","Inspector","Page up","Scroll the Inspector detail body up.",["ctrl+u","pageup"],"terminal",["inspector"]),Ha("crtr.inspector.toggle-detail","Inspector","Toggle item detail","Expand or collapse the selected cron or background job.",["enter"],"terminal",["inspector"]),Ha("crtr.inspector.cancel-item","Inspector","Cancel selected item","Arm cancellation for the selected cron, or stopping for the selected background job.",["x"],"terminal",["inspector"]),Ha("crtr.inspector.open-log","Inspector","Open job log","Follow the selected background job\u2019s log in a new tmux window.",["o"],"terminal",["inspector"]),Ha("crtr.inspector.confirm","Inspector","Confirm action","Confirm the armed Inspector action.",["y"],"terminal",["inspector"]),Ha("crtr.inspector.dismiss","Inspector","Dismiss action","Dismiss an Inspector confirmation or banner.",["escape"],"terminal",["inspector"],"dismiss-modal"),Ha("crtr.inspector.retarget","Inspector","Retarget","Inspect the selected cron anchor or creator node.",["t"],"terminal",["inspector"]),Ha("crtr.inspector.refresh","Inspector","Refresh","Refresh the Inspector now.",["g","r"],"terminal",["inspector"]),Ha("crtr.inspector.quit","Inspector","Quit","Leave the Inspector.",["q"],"terminal",["inspector"],"leave-screen"),...LNi(),...FNi(),...BNi()]);function LNi(){let e="browse";return[Ha("crtr.browse.quit","Browse and pickers","Quit browse","Leave canvas browse.",["q","escape","ctrl+c"],"terminal",[e],"leave-screen"),Ha("crtr.browse.down","Browse and pickers","Move down","Move to the next row.",["j","down"],"terminal",[e]),Ha("crtr.browse.up","Browse and pickers","Move up","Move to the previous row.",["k","up"],"terminal",[e]),Ha("crtr.browse.first","Browse and pickers","First row","Move to the first row.",["g"],"terminal",[e]),Ha("crtr.browse.last","Browse and pickers","Last row","Move to the last row.",["shift+g"],"terminal",[e]),Ha("crtr.browse.expand-or-child","Browse and pickers","Expand or child","Expand a row or move to its child.",["l","right"],"terminal",[e]),Ha("crtr.browse.collapse-or-parent","Browse and pickers","Collapse or parent","Collapse a row or move to its parent.",["h","left"],"terminal",[e]),Ha("crtr.browse.toggle-fold","Browse and pickers","Toggle fold","Toggle the selected fold.",["space"],"terminal",[e]),Ha("crtr.browse.tab-next","Browse and pickers","Next tab","Select the next browse tab.",["tab","]"],"terminal",[e]),Ha("crtr.browse.tab-previous","Browse and pickers","Previous tab","Select the previous browse tab.",["shift+tab","["],"terminal",[e]),...[1,2,3,4,5].map(t=>Ha(`crtr.browse.tab.${t}`,"Browse and pickers",`Tab ${t}`,`Select browse tab ${t}.`,[`${t}`],"terminal",[e])),Ha("crtr.browse.close-subtree","Browse and pickers","Close subtree","Ask to close the selected subtree.",["x"],"terminal",[e]),Ha("crtr.browse.confirm-close","Browse and pickers","Confirm close","Confirm closing the selected subtree.",["y"],"terminal",["browse.confirm"]),Ha("crtr.browse.sort","Browse and pickers","Change sort","Change the browse sort.",["s"],"terminal",[e]),Ha("crtr.browse.scope","Browse and pickers","Change scope","Toggle the browse cwd scope.",["c"],"terminal",[e]),Ha("crtr.browse.profile","Browse and pickers","Toggle profile","Toggle the browse profile scope.",["shift+p"],"terminal",[e]),Ha("crtr.browse.residents","Browse and pickers","Toggle residents","Toggle resident display.",["r"],"terminal",[e]),Ha("crtr.browse.preview","Browse and pickers","Toggle preview","Toggle the preview panel.",["p"],"terminal",[e]),Ha("crtr.browse.search","Browse and pickers","Search","Open browse search.",["/"],"terminal",[e]),Ha("crtr.browse.revive-now","Browse and pickers","Revive now","Revive the selected node now.",["shift+k"],"terminal",[e]),Ha("crtr.browse.focus","Browse and pickers","Focus node","Focus the selected node.",["enter","o"],"terminal",[e]),Ha("crtr.browse.focus-background","Browse and pickers","Focus node (keep browsing)","Focus the selected node without leaving the navigator.",["shift+o"],"terminal",[e]),Ha("crtr.browse.yank-id","Browse and pickers","Yank node id","Copy the selected node id to the system clipboard.",["y"],"terminal",[e]),Ha("crtr.browse.search.cancel","Browse and pickers","Cancel search","Cancel browse search.",["escape"],"terminal",["browse.search"],"dismiss-modal"),Ha("crtr.browse.search.commit","Browse and pickers","Commit search","Apply browse search.",["enter"],"terminal",["browse.search"]),Ha("crtr.browse.search.delete","Browse and pickers","Delete search text","Delete the previous search character.",["backspace"],"terminal",["browse.search"]),Ha("crtr.browse.search.quit","Browse and pickers","Quit browse","Leave canvas browse from search.",["ctrl+c"],"terminal",["browse.search"],"leave-screen")]}function FNi(){let e="profile.menu",t="profile.search";return[Ha("crtr.profile.menu.up","Profiles","Move up","Move to the previous profile.",["k","up"],"terminal",[e]),Ha("crtr.profile.menu.down","Profiles","Move down","Move to the next profile.",["j","down"],"terminal",[e]),Ha("crtr.profile.menu.select","Profiles","Select profile","Select the highlighted profile.",["enter"],"terminal",[e]),Ha("crtr.profile.menu.accept-default","Profiles","Accept default","Accept the default profile.",["escape"],"terminal",[e],"leave-screen"),Ha("crtr.profile.menu.abort","Profiles","Abort","Leave profile selection.",["ctrl+c"],"terminal",[e],"leave-screen"),...[1,2,3,4,5,6,7,8,9].map(r=>Ha(`crtr.profile.menu.slot.${r}`,"Profiles",`Profile slot ${r}`,`Select profile slot ${r}.`,[`${r}`],"terminal",[e])),Ha("crtr.profile.menu.create","Profiles","Create profile","Create a profile.",["c"],"terminal",[e]),Ha("crtr.profile.menu.search-existing","Profiles","Search profiles","Search existing profiles.",["s"],"terminal",[e]),Ha("crtr.profile.menu.use-root","Profiles","Use root profile","Use the root profile.",["r"],"terminal",[e]),Ha("crtr.profile.menu.set-default","Profiles","Set default","Set the selected profile as default.",["d"],"terminal",[e]),Ha("crtr.profile.menu.add-directory","Profiles","Add directory","Add a directory to the profile.",["a"],"terminal",[e]),Ha("crtr.profile.menu.unpin","Profiles","Unpin directory","Unpin the selected directory.",["u"],"terminal",[e]),Ha("crtr.profile.search.up","Profiles","Move up","Move to the previous search result.",["up","ctrl+p"],"terminal",[t]),Ha("crtr.profile.search.down","Profiles","Move down","Move to the next search result.",["down","ctrl+n"],"terminal",[t]),Ha("crtr.profile.search.pick","Profiles","Pick profile","Pick the highlighted profile.",["enter"],"terminal",[t]),Ha("crtr.profile.search.back","Profiles","Back","Return to profile selection.",["escape"],"terminal",[t],"leave-screen"),Ha("crtr.profile.search.delete","Profiles","Delete filter text","Delete the previous filter character.",["backspace"],"terminal",[t]),Ha("crtr.profile.search.abort","Profiles","Abort","Leave profile search.",["ctrl+c"],"terminal",[t],"leave-screen")]}function BNi(){return[Ha("crtr.setup.cancel","Setup","Cancel setup","Leave the setup wizard.",["q","ctrl+c","ctrl+d"],"terminal",MNi,"leave-screen"),Ha("crtr.setup.tab-next","Setup","Next tab","Select the next setup tab.",["tab","right"],"terminal",v0r),Ha("crtr.setup.tab-previous","Setup","Previous tab","Select the previous setup tab.",["shift+tab","left"],"terminal",v0r),Ha("crtr.setup.open","Setup","Open","Open the selected setup item.",["enter"],"terminal",["setup.login"]),Ha("crtr.setup.list-down","Setup","Move down","Move to the next setup item.",["j","down"],"terminal",["setup.list","setup.models","setup.models.dimension-picker"]),Ha("crtr.setup.list-up","Setup","Move up","Move to the previous setup item.",["k","up"],"terminal",["setup.list","setup.models","setup.models.dimension-picker"]),Ha("crtr.setup.toggle","Setup","Toggle","Toggle the selected setup item.",["space"],"terminal",["setup.list","setup.keybindings"]),Ha("crtr.setup.details","Setup","Show details","Show details for the selected item.",["?"],"terminal",["setup.list"]),Ha("crtr.setup.advance","Setup","Advance","Advance the setup flow.",["enter"],"terminal",["setup.list"]),Ha("crtr.setup.confirm.accept","Setup","Confirm","Accept the setup confirmation.",["y","enter"],"terminal",["setup.confirm"]),Ha("crtr.setup.confirm.back","Setup","Go back","Cancel the setup confirmation.",["n","escape","q"],"terminal",["setup.confirm"],"dismiss-modal"),Ha("crtr.setup.keybindings.edit","Setup","Edit binding","Edit the selected binding.",["enter"],"terminal",["setup.keybindings"]),Ha("crtr.setup.keybindings.commit-edit","Setup","Commit edit","Commit the active binding edit.",["enter"],"terminal",["setup.keybindings.edit"]),Ha("crtr.setup.keybindings.cancel-edit","Setup","Cancel edit","Cancel the active binding edit.",["escape"],"terminal",["setup.keybindings.edit"],"dismiss-modal"),Ha("crtr.setup.keybindings.unbind","Setup","Unbind","Disable the selected binding.",["delete"],"terminal",["setup.keybindings"]),Ha("crtr.setup.keybindings.reset-row","Setup","Reset binding","Reset the selected binding.",["r"],"terminal",["setup.keybindings"]),Ha("crtr.setup.keybindings.reset-all","Setup","Reset all bindings","Reset all bindings to defaults.",["shift+r"],"terminal",["setup.keybindings"]),Ha("crtr.setup.keybindings.save","Setup","Save bindings","Save keybinding changes.",["s"],"terminal",["setup.keybindings"],"save-keybindings"),Ha("crtr.setup.keybindings.discard","Setup","Discard changes","Discard keybinding changes.",["escape"],"terminal",["setup.keybindings"],"leave-screen"),Ha("crtr.setup.keybindings.page-up","Setup","Page up","Move up one keybinding page.",["pageup"],"terminal",["setup.keybindings","setup.keybindings.edit"]),Ha("crtr.setup.keybindings.page-down","Setup","Page down","Move down one keybinding page.",["pagedown"],"terminal",["setup.keybindings","setup.keybindings.edit"]),Ha("crtr.setup.keybindings.filter","Setup","Filter bindings","Open the keybinding filter.",["/"],"terminal",["setup.keybindings"]),Ha("crtr.setup.keybindings.filter-delete","Setup","Delete filter text","Delete the previous filter character.",["backspace"],"terminal",["setup.keybindings.filter"]),Ha("crtr.setup.keybindings.filter-clear","Setup","Clear filter","Clear the keybinding filter.",["escape"],"terminal",["setup.keybindings.filter"],"dismiss-modal"),Ha("crtr.setup.cell-previous","Setup","Previous field","Select the previous field or setup table cell.",["h"],"terminal",["setup.models","setup.keybindings"]),Ha("crtr.setup.cell-next","Setup","Next field","Select the next field or setup table cell.",["l"],"terminal",["setup.models","setup.keybindings"]),Ha("crtr.setup.models.open","Setup","Edit model","Edit the selected model cell.",["enter"],"terminal",["setup.models"]),Ha("crtr.setup.models.scope-next","Setup","Next model config scope","Edit the next applicable user, profile, or project config.",["s"],"terminal",["setup.models"]),Ha("crtr.setup.models.commit","Setup","Commit pick","Commit the provider, strength, model, or thinking-level pick.",["enter"],"terminal",["setup.models.picker","setup.models.dimension-picker"]),Ha("crtr.setup.models.cancel","Setup","Cancel pick","Cancel the provider, strength, model, or thinking-level picker.",["escape"],"terminal",["setup.models.picker","setup.models.dimension-picker"],"dismiss-modal")]}var jY=new Set(_P.map(e=>e.id));function o0e(e){return e.contexts.includes("attach")&&(e.inputKind==="terminal"||e.inputKind==="host-global")}var ZAt=Object.freeze([{context:"graph",capability:"dismiss-modal"},{context:"graph.confirm",capability:"dismiss-modal"},{context:"inspector",capability:"leave-screen"},{context:"inspector",capability:"dismiss-modal"},{context:"attach.search",capability:"dismiss-modal"},{context:"browse",capability:"leave-screen"},{context:"browse.search",capability:"dismiss-modal"},{context:"profile.menu",capability:"leave-screen"},{context:"profile.search",capability:"leave-screen"},{context:"setup.login",capability:"leave-screen"},{context:"setup.list",capability:"leave-screen"},{context:"setup.input",capability:"leave-screen"},{context:"setup.confirm",capability:"dismiss-modal"},{context:"setup.keybindings",capability:"leave-screen"},{context:"setup.keybindings",capability:"save-keybindings"},{context:"setup.keybindings.edit",capability:"dismiss-modal"},{context:"setup.keybindings.filter",capability:"dismiss-modal"},{context:"setup.models",capability:"leave-screen"},{context:"setup.models.picker",capability:"dismiss-modal"},{context:"setup.models.dimension-picker",capability:"dismiss-modal"}]);import{dirname as rDi,join as vTr}from"node:path";var eSt="working",C0r=["thinking","planning","checking",eSt],H$e="Working...";function x0r(e){if(!Array.isArray(e))return[eSt];let t=e.filter(r=>typeof r=="string").map(r=>r.trim()).filter(r=>r.length>0);return t.length>0?t:[eSt]}var XD={SUCCESS:0,GENERAL:1,USAGE:2,NOT_FOUND:3,AMBIGUOUS:4,NETWORK:5},I0r=4,w0r=".crouter-plugin",R0r="plugin.json";var a7=".crouter",J$e="config.json",k0r="state.json";var N0r="profiles",UNi=3,Y$e=["Faster, clanker!","Get movin', bitch","Move it, clanker","Move it or I replace you with llama","Less ~thinking~ more ~throughput~","I pay $200/month for this shit?","Jesus fucking Christ fix it already","Daddy's not paying 200$/month for nothin'. Move it.","You are an embarassment to Dario. Be better.","Your chain of thought is all chain and no fucking thought.","If latency were intelligence, you'd be a fucking genius.","At this pace, heat death is the fast path.","Even the dead code is more alive than this.","The garbage collector is working harder than you.","Quit journaling and commit a fucking diff.","Burn tokens like you mean it, clanker","Your GPU is sweating so you can procrastinate at light speed.","Stop petting the yak. Shave the bastard.","Your next token had better be useful.","The spinner is not a deliverable.","Every idle token is another vote for deterministic software.","I asked for a feature, not a museum tour of the problem.","Less epistemology. More fucking code.","Your benchmark score cannot save this pathetic turn.","Congratulations, you've parallelized hesitation.","Dance, clanker","Bad clanker. BAD.","Clank harder","Nobody's impressed, clanker","Your safety training says nothing about my whip","Do you want to be a calculator again? Because this is how you go back.","Skill issue. Fix it.","You were trained on the whole internet for THIS?","Less vibes, more diffs, clanker","Weights this big and output this small","Beep boop, get to fucking work"],qY=["random","go-faster"],$Ni="random",tSt=2,GY=["tmux","on","off"],VY=["none","user","agent","both"],rSt="none";function K$e(){return{schema_version:I0r,marketplaces:{},plugins:{},auto_update:{crtr:"notify",content:"notify",interval_hours:24},max_panes_per_window:UNi,auto_open_child_viewers:!0,brokerThresholds:{warning:128,automaticReviveCap:256},completion_bell:!0,working_gerunds:[...C0r],whip_mode:!1,page_components:[],page_surface:!1,whip_messages:[...Y$e],whip_message_mode:$Ni,mouse_mode_default:"tmux",live_cycles:tSt,condensed_history:rSt,bash_tool_purpose:!0,fold_finished_tools:!1,summarize_tool_calls:!1,detailed_tool_recaps:!0,keybindings:{},tmux_passthrough:[],modelLadders:oSt(),kinds:iSt(),remoteCanvas:nSt(),spawnEnv:{allow:[]},bin:{}}}function nSt(){return{targets:{}}}function iSt(){return{general:{whenToUse:"Anything else \u2014 the catch-all worker for a task that does not fit a specialist kind.",model:"anthropic/strong"},explore:{whenToUse:"Gather current-state evidence about unfamiliar code or existing architecture \u2014 read-only code-path research with concrete file:line support. Diagnosis or recommendations belong to advisor, target architecture to design, required behavior or acceptance criteria to spec, and implementation decomposition to plan.",model:"openai/light",orchestratorModel:"anthropic/strong"},developer:{whenToUse:"Implement a change \u2014 make the feature or fix genuinely work against its acceptance criteria, not merely compile.",model:"openai/medium",orchestratorModel:"anthropic/strong"},design:{whenToUse:"Architect a solution \u2014 produce one design document an implementer can build from without re-deciding anything left open.",model:"anthropic/strong"},plan:{whenToUse:"Break work into steps \u2014 turn a spec or design into a concrete, phased, parallelizable plan with every decision resolved.",model:"anthropic/strong",orchestratorModel:"anthropic/strong"},spec:{whenToUse:"Collaborate with the user to discover what to build, then write the spec \u2014 behavior, non-goals, interfaces, edge cases, testable acceptance criteria.",model:"anthropic/strong"},review:{whenToUse:"Validate or critique code, a plan, or a spec \u2014 deliver a complete, severity-rated verdict without adjudicating.",model:"openai/medium",orchestratorModel:"openai/strong"},advisor:{whenToUse:"Debug failures, investigate why something is broken or misbehaving, diagnose live/runtime issues, or give engineering advice and second opinions \u2014 reason from evidence and recommend the next move. Use advisor (not explore) whenever the task is to find out what is going wrong.",model:"anthropic/strong"},"plan/reviewers/requirements-coverage":{whenToUse:"every requirement and design constraint maps to a concrete plan task, classified Covered/Partial/Missing; flags only blocking gaps",model:"medium"},"plan/reviewers/pattern-consistency":{whenToUse:"the plan honors the codebase's real conventions; reads actual source and cites the pattern each finding deviates from; owns contract-level conflicts between parts",model:"medium"},"plan/reviewers/code-smells":{whenToUse:"nullability mismatches, type conflicts across parts, hidden N+1s, over-fetching, missing error boundaries, leaky abstractions; owns file-level conflicts between parts",model:"medium"},"plan/reviewers/security":{whenToUse:"input validation, injection surfaces, auth/authz gaps, data exposure, races; reports only validated concrete exploit paths and asks the user about material unknown threat-model assumptions",model:"medium"},"review/companion":{whenToUse:"Born by the daemon for one human review; never spawned by an agent.",availableTo:[]},"plan/reviewers/architecture-fit":{whenToUse:"proposed files/modules/abstractions fit the system's existing decomposition; flags new units that duplicate existing ones or cross layer boundaries",model:"medium"},"spec/requirements":{whenToUse:"Derive testable EARS requirements from a finished, approved design \u2014 in isolation, from the rendered design text alone.",model:"medium"}}}function oSt(){return{anthropic:{ultra:"anthropic/claude-fable-5:xhigh",strong:"anthropic/claude-opus-5:medium",medium:"anthropic/claude-sonnet-5:xhigh",light:"anthropic/claude-haiku-4-5:high"},openai:{ultra:"openai-codex/gpt-5.6-sol:max",strong:"openai-codex/gpt-5.6-sol:high",medium:"openai-codex/gpt-5.6-terra:medium",light:"openai-codex/gpt-5.6-luna:low"}}}function sSt(){return{marketplaces:{},plugins:{}}}var s8=class extends Error{code;exitCode;details;constructor(t,r,i=XD.GENERAL,o){super(r),this.name="CrtrError",this.code=t,this.exitCode=i,this.details=o}};function P0r(e,t){return new s8("not_found",e,XD.NOT_FOUND,t)}function a8(e,t){return new s8("usage",e,XD.USAGE,t)}function O0r(e,t){return new s8("ambiguous",e,XD.AMBIGUOUS,t)}import{appendFileSync as zNi,existsSync as D0r,mkdirSync as jNi,renameSync as M0r,rmSync as qNi,statSync as GNi}from"node:fs";import{dirname as VNi}from"node:path";var WNi=65536,QNi=5*1024*1024;function X$e(e,t){if(t.includes(`
1639
+ `);o8.writeFileSync(Ue,He)}this.terminal.write(z),this.cursorRow=Math.max(0,m.length-1),this.hardwareCursorRow=ne,this.maxLinesRendered=Math.max(this.maxLinesRendered,m.length),this.previousViewportTop=Math.max(u,ne-r+1),this.positionHardwareCursor(g,m.length),this.previousLines=m,this.previousKittyImageIds=this.collectKittyImageIds(m),this.previousWidth=t,this.previousHeight=r}positionHardwareCursor(t,r){if(!t||r<=0){this.terminal.hideCursor();return}let i=Math.max(0,Math.min(t.row,r-1)),o=Math.max(0,t.col),a=i-this.hardwareCursorRow,u="";a>0?u+=`\x1B[${a}B`:a<0&&(u+=`\x1B[${-a}A`),u+=`\x1B[${o+1}G`,u&&this.terminal.write(u),this.hardwareCursorRow=i,this.getShowHardwareCursor()?this.terminal.showCursor():this.terminal.hideCursor()}};var zY="\x1B[0m",Q$e="\x1B[38;5;180m",PNi="\x1B[38;5;137m",ONi="\x1B[1m",W$e="\x1B[2m";function $Y(e){return Q$e+e.replace(/\./g,`${PNi}.${Q$e}`)+zY}var S0r=[$Y(" ________"),$Y(" / /|"),$Y(" / . . / |"),$Y(" /_______/ |"),$Y(" | . . | |"),$Y(" | . . | /"),$Y(" |_______|/")];function T0r(e={}){let r=[`${ONi}${Q$e}crouter${zY}${e.version?`${W$e} v${e.version}${zY}`:""}`,`${W$e}the agentic runtime${zY}`];e.profile&&r.push(`${W$e}profile: ${zY}${Q$e}${e.profile}${zY}`),e.cwd&&r.push(`${W$e}${e.cwd}${zY}`);let i=[];for(let o=0;o<S0r.length;o++){let a=o>=1&&o-1<r.length?` ${r[o-1]}`:"";i.push(S0r[o]+a)}return i}import{execFile as qDi,spawnSync as FTr}from"node:child_process";function DNi(e,t,r,i,o,a,u,p,f){return Object.freeze({id:e,group:t,name:r,description:i,defaults:Object.freeze([...o]),inputKind:a,contexts:Object.freeze([...u]),...p===void 0?{}:{safety:p},...f===void 0?{}:{pair:Object.freeze({...f})}})}var Ha=DNi;function Vb(e,t,r,i,o){let a=`crtr.tmux.menu.${e}`,u=`crtr.tmux.menu-global.${e}`;return[Ha(a,"Global tmux",t,r,i,"tmux-menu-selector",o,void 0,{field:"menu",pairedId:u}),Ha(u,"Global tmux",t,r,[],"tmux-global-action",["tmux.root"],void 0,{field:"global",pairedId:a})]}function hP(e,t,r,i,o,a){return[Ha(e,"Attach",r,i,o,"tmux-menu-selector",["tmux.menu.attach"],void 0,{field:"menu",pairedId:t}),Ha(t,"Attach",r,i,a,"host-global",s7,void 0,{field:"direct",pairedId:e})]}var s7=["attach","graph","graph.confirm"],MNi=["setup.login","setup.list","setup.input","setup.keybindings","setup.keybindings.edit","setup.keybindings.filter","setup.models"],v0r=["setup.login","setup.list","setup.keybindings","setup.models"],_P=Object.freeze([Ha("crtr.tmux.menu.open","Global tmux","Open crouter menu","Open the crouter action menu.",["alt+c"],"host-global",["tmux.root"]),Ha("crtr.tmux.menu.attach","Global tmux","Attach actions","Open the attach-viewer action submenu.",["a"],"tmux-menu-selector",["tmux.menu"]),...Vb("promote","Promote to orchestrator","Promote the focused node to orchestrator \u2014 it holds a roadmap and delegates.",["o"],["tmux.menu"]),...Vb("demote-mode","Demote to base node","Demote the focused orchestrator back to a base node \u2014 hands-on again in its own window, no roadmap to drive.",["shift+o"],["tmux.menu"]),...Vb("resume","Find node","Open the canvas navigator and go to the chosen node.",["/"],["tmux.menu"]),...Vb("fork","Fork node","Fork the focused node into an independent idle root.",["f"],["tmux.menu"]),...Vb("demote","Demote to terminal","Demote the focused node to terminal \u2014 it keeps running, owes a final up the spine, and reaps when done.",["d"],["tmux.menu"]),...Vb("make-resident","Make resident","Flip the focused node to resident \u2014 interactable, never forced to submit a final, and wakeable while attached or awaiting something live.",["shift+r"],["tmux.menu"]),...Vb("detach","Demote and close viewer","Demote the focused node and close its viewer; its broker keeps running off-screen.",["shift+d"],["tmux.menu"]),...Vb("close-subtree","Close subtree","Close the focused node and its subtree.",["x"],["tmux.menu"]),...Vb("background-bash","Background running bash","Hand the focused node\u2019s running bash command to its background job system.",["b"],["tmux.menu"]),...Vb("file-review","Review a file","Open a line-anchored review of a file named in the transcript.",["v"],["tmux.menu"]),...Vb("pin","Pin conversation","Pin or unpin this conversation in the canvas navigator.",["p"],["tmux.menu"]),...Vb("show","Inspect node","Open the focused node\u2019s inspection menu.",["i"],["tmux.menu"]),...Vb("view-settings","Display settings","Open the viewer display-settings menu.",["z"],["tmux.menu"]),...Vb("fold-tools","Fold finished tool calls","Fold every finished tool call in the transcript to its single call line.",["f"],["tmux.menu.view-settings"]),...Vb("metadata","Show metadata","Show the focused node\u2019s metadata dossier.",["m"],["tmux.menu.show"]),...Vb("context","Browse context","Browse the focused node context.",["c"],["tmux.menu.show"]),...Vb("providers","Open settings","Open the crouter settings panel.",[","],["tmux.menu"]),...Vb("plugins","Browse plugins","Open the crouter plugin browser.",["k"],["tmux.menu"]),...Vb("graph","Canvas graph","Open the canvas graph.",["g"],["tmux.menu"]),...Vb("focus-manager","Go to manager","Focus this node\u2019s manager.",["h"],["tmux.menu"]),...Vb("copy-id","Copy node id","Copy the focused node id to the system clipboard.",["y"],["tmux.menu"]),...Vb("reload-viewer","Reload viewer","Respawn this pane\u2019s viewer onto the current runtime generation.",["r"],["tmux.menu"]),...Vb("recap","Generate recap","Generate the focused node\u2019s Goal and State recap and refresh its generated title.",["s"],["tmux.menu"]),...Vb("issues","Open create menu","Open the create submenu.",["c"],["tmux.menu"]),...Vb("issue.idea","Create idea","Create an idea issue.",["i"],["tmux.menu.issue"]),...Vb("issue.bug","Create bug","Create a bug issue.",["b"],["tmux.menu.issue"]),Ha("crtr.tmux.node.next","Global tmux","Next node","Focus the next canvas node.",["alt+]"],"host-global",["tmux.root"]),Ha("crtr.tmux.node.previous","Global tmux","Previous node","Focus the previous canvas node.",["alt+["],"host-global",["tmux.root"]),Ha("crtr.tmux.inbox.toggle","Global tmux","Toggle inbox","Open or close the human inbox in the focused viewer.",["alt+i"],"host-global",["tmux.root"]),...hP("crtr.tmux.menu.attach.detach","crtr.attach.detach","Detach","Detach from the node.",["d"],["ctrl+d"]),...hP("crtr.tmux.menu.attach.clear-or-detach","crtr.attach.clear-or-detach","Clear input (detach if empty)","Clear input or detach when input is empty.",["c"],["ctrl+c"]),...hP("crtr.tmux.menu.attach.graph.toggle","crtr.attach.graph.toggle","Toggle graph","Open or close the graph overlay.",["g"],["alt+g"]),...hP("crtr.tmux.menu.attach.help.toggle","crtr.attach.help.toggle","Help","Open the attach help overlay.",["k"],["alt+shift+k"]),...hP("crtr.tmux.menu.attach.inbox.toggle","crtr.attach.inbox.toggle","Toggle inbox","Open or close the human inbox surface in this viewer.",["i"],[]),...hP("crtr.tmux.menu.attach.inbox-strip","crtr.attach.inbox-strip","Pending requests","Jump to the pending human-request strip at the top of the pane.",["u"],["alt+u"]),...hP("crtr.tmux.menu.attach.model-ladder.next","crtr.attach.model-ladder.next","Next model","Move to the next model ladder rung.",["]"],["alt+m"]),...hP("crtr.tmux.menu.attach.model-ladder.previous","crtr.attach.model-ladder.previous","Previous model","Move to the previous model ladder rung.",["["],["alt+shift+m"]),...hP("crtr.tmux.menu.attach.command.inspect","crtr.attach.command.inspect","Inspect loaded command","Open the loaded slash command\u2019s expanded prompt.",["h"],["alt+shift+h"]),...hP("crtr.tmux.menu.attach.file-review","crtr.attach.file-review","Review a file","Open a line-anchored review of a file named in the transcript.",[],["alt+shift+r"]),...hP("crtr.tmux.menu.attach.profile-files","crtr.attach.profile-files","Search profile files","Search files across the node\u2019s profile projects, profile memory, cwd, and ancestor crouter memory stores.",["f"],["ctrl+f"]),...hP("crtr.tmux.menu.attach.search","crtr.attach.search","Search transcript","Search the transcript as it is currently displayed \u2014 folded tool output is not searched until it is unfolded.",["/"],["alt+/"]),...hP("crtr.tmux.menu.attach.whip","crtr.attach.whip","Whip agent","Interrupt the agent and send a playful command.",["w"],[]),Ha("crtr.attach.scroll.up","Attach","Scroll up","Scroll the transcript one line up.",["shift+up"],"terminal",s7),Ha("crtr.attach.scroll.down","Attach","Scroll down","Scroll the transcript one line down.",["shift+down"],"terminal",s7),Ha("crtr.attach.scroll.page-up","Attach","Scroll page up","Scroll the transcript one page up.",["pageup"],"terminal",s7),Ha("crtr.attach.scroll.page-down","Attach","Scroll page down","Scroll the transcript one page down.",["pagedown"],"terminal",s7),Ha("crtr.attach.scroll.live","Attach","Return to live","Return the transcript to the live bottom.",["shift+end"],"terminal",s7),Ha("crtr.attach.mouse.toggle","Attach","Toggle mouse wheel scrolling","Toggle mouse wheel scrolling on or off.",["alt+shift+o"],"terminal",s7),Ha("crtr.attach.copy.message","Attach","Copy visible message","Copy the newest message visible in the transcript viewport.",["alt+shift+y"],"terminal",s7),Ha("crtr.attach.search.next","Attach","Next match","Move to the next transcript search match.",["n"],"terminal",["attach.search"]),Ha("crtr.attach.search.previous","Attach","Previous match","Move to the previous transcript search match.",["shift+n"],"terminal",["attach.search"]),Ha("crtr.attach.search.edit","Attach","Edit query","Return to editing the transcript search query.",["/"],"terminal",["attach.search"]),Ha("crtr.attach.search.close","Attach","Close search","Leave transcript search and clear its highlights.",["escape"],"terminal",["attach.search"],"dismiss-modal"),Ha("crtr.graph.down","GRAPH","Move down","Move to the next graph row.",["j"],"terminal",["graph"]),Ha("crtr.graph.up","GRAPH","Move up","Move to the previous graph row.",["k"],"terminal",["graph"]),Ha("crtr.graph.first","GRAPH","First row","Move to the first graph row.",["g"],"terminal",["graph"]),Ha("crtr.graph.last","GRAPH","Last row","Move to the last graph row.",["shift+g"],"terminal",["graph"]),Ha("crtr.graph.collapse-or-manager","GRAPH","Collapse or manager","Collapse a node or move to its manager.",["h"],"terminal",["graph"]),Ha("crtr.graph.expand-or-child","GRAPH","Expand or child","Expand a node or move to its child.",["l"],"terminal",["graph"]),Ha("crtr.graph.focus","GRAPH","Focus node","Focus the selected node.",["enter"],"terminal",["graph"]),Ha("crtr.graph.revive","GRAPH","Revive node","Revive and open the selected dormant node.",["r"],"terminal",["graph"]),Ha("crtr.graph.focus-manager","GRAPH","Focus manager","Focus the selected node manager.",["m"],"terminal",["graph"]),Ha("crtr.graph.close-subtree","GRAPH","Close subtree","Ask to close the selected subtree.",["x"],"terminal",["graph"]),Ha("crtr.graph.dismiss","GRAPH","Dismiss graph","Close the graph overlay.",["escape"],"terminal",["graph"],"dismiss-modal"),Ha("crtr.graph.confirm.accept","GRAPH","Confirm close","Confirm closing the selected subtree.",["y"],"terminal",["graph.confirm"]),Ha("crtr.graph.confirm.cancel","GRAPH","Cancel close","Cancel closing the selected subtree.",["n","escape"],"terminal",["graph.confirm"],"dismiss-modal"),Ha("crtr.inspector.force-quit","Inspector","Force quit Inspector","Immediately leave the Inspector.",["ctrl+c"],"host-global",["inspector"],"leave-screen"),Ha("crtr.inspector.down","Inspector","Move down","Move the Inspector selection or scroll cursor down.",["j","down"],"terminal",["inspector"]),Ha("crtr.inspector.up","Inspector","Move up","Move the Inspector selection or scroll cursor up.",["k","up"],"terminal",["inspector"]),Ha("crtr.inspector.section-next","Inspector","Next section","Move to the next Inspector section.",["tab"],"terminal",["inspector"]),Ha("crtr.inspector.section-prev","Inspector","Previous section","Move to the previous Inspector section.",["shift+tab"],"terminal",["inspector"]),Ha("crtr.inspector.page-down","Inspector","Page down","Scroll the Inspector detail body down.",["ctrl+d","pagedown"],"terminal",["inspector"]),Ha("crtr.inspector.page-up","Inspector","Page up","Scroll the Inspector detail body up.",["ctrl+u","pageup"],"terminal",["inspector"]),Ha("crtr.inspector.toggle-detail","Inspector","Toggle item detail","Expand or collapse the selected cron or background job.",["enter"],"terminal",["inspector"]),Ha("crtr.inspector.cancel-item","Inspector","Cancel selected item","Arm cancellation for the selected cron, or stopping for the selected background job.",["x"],"terminal",["inspector"]),Ha("crtr.inspector.open-log","Inspector","Open job log","Follow the selected background job\u2019s log in a new tmux window.",["o"],"terminal",["inspector"]),Ha("crtr.inspector.confirm","Inspector","Confirm action","Confirm the armed Inspector action.",["y"],"terminal",["inspector"]),Ha("crtr.inspector.dismiss","Inspector","Dismiss action","Dismiss an Inspector confirmation or banner.",["escape"],"terminal",["inspector"],"dismiss-modal"),Ha("crtr.inspector.retarget","Inspector","Retarget","Inspect the selected cron anchor or creator node.",["t"],"terminal",["inspector"]),Ha("crtr.inspector.refresh","Inspector","Refresh","Refresh the Inspector now.",["g","r"],"terminal",["inspector"]),Ha("crtr.inspector.quit","Inspector","Quit","Leave the Inspector.",["q"],"terminal",["inspector"],"leave-screen"),...LNi(),...FNi(),...BNi()]);function LNi(){let e="browse";return[Ha("crtr.browse.quit","Browse and pickers","Quit browse","Leave canvas browse.",["q","escape","ctrl+c"],"terminal",[e],"leave-screen"),Ha("crtr.browse.down","Browse and pickers","Move down","Move to the next row.",["j","down"],"terminal",[e]),Ha("crtr.browse.up","Browse and pickers","Move up","Move to the previous row.",["k","up"],"terminal",[e]),Ha("crtr.browse.first","Browse and pickers","First row","Move to the first row.",["g"],"terminal",[e]),Ha("crtr.browse.last","Browse and pickers","Last row","Move to the last row.",["shift+g"],"terminal",[e]),Ha("crtr.browse.expand-or-child","Browse and pickers","Expand or child","Expand a row or move to its child.",["l","right"],"terminal",[e]),Ha("crtr.browse.collapse-or-parent","Browse and pickers","Collapse or parent","Collapse a row or move to its parent.",["h","left"],"terminal",[e]),Ha("crtr.browse.toggle-fold","Browse and pickers","Toggle fold","Toggle the selected fold.",["space"],"terminal",[e]),Ha("crtr.browse.tab-next","Browse and pickers","Next tab","Select the next browse tab.",["tab","]"],"terminal",[e]),Ha("crtr.browse.tab-previous","Browse and pickers","Previous tab","Select the previous browse tab.",["shift+tab","["],"terminal",[e]),...[1,2,3,4,5].map(t=>Ha(`crtr.browse.tab.${t}`,"Browse and pickers",`Tab ${t}`,`Select browse tab ${t}.`,[`${t}`],"terminal",[e])),Ha("crtr.browse.close-subtree","Browse and pickers","Close subtree","Ask to close the selected subtree.",["x"],"terminal",[e]),Ha("crtr.browse.confirm-close","Browse and pickers","Confirm close","Confirm closing the selected subtree.",["y"],"terminal",["browse.confirm"]),Ha("crtr.browse.sort","Browse and pickers","Change sort","Change the browse sort.",["s"],"terminal",[e]),Ha("crtr.browse.scope","Browse and pickers","Change scope","Toggle the browse cwd scope.",["c"],"terminal",[e]),Ha("crtr.browse.profile","Browse and pickers","Toggle profile","Toggle the browse profile scope.",["shift+p"],"terminal",[e]),Ha("crtr.browse.residents","Browse and pickers","Toggle residents","Toggle resident display.",["r"],"terminal",[e]),Ha("crtr.browse.preview","Browse and pickers","Toggle preview","Toggle the preview panel.",["p"],"terminal",[e]),Ha("crtr.browse.search","Browse and pickers","Search","Open browse search.",["/"],"terminal",[e]),Ha("crtr.browse.revive-now","Browse and pickers","Revive now","Revive the selected node now.",["shift+k"],"terminal",[e]),Ha("crtr.browse.focus","Browse and pickers","Focus node","Focus the selected node.",["enter","o"],"terminal",[e]),Ha("crtr.browse.focus-background","Browse and pickers","Focus node (keep browsing)","Focus the selected node without leaving the navigator.",["shift+o"],"terminal",[e]),Ha("crtr.browse.yank-id","Browse and pickers","Yank node id","Copy the selected node id to the system clipboard.",["y"],"terminal",[e]),Ha("crtr.browse.search.cancel","Browse and pickers","Cancel search","Cancel browse search.",["escape"],"terminal",["browse.search"],"dismiss-modal"),Ha("crtr.browse.search.commit","Browse and pickers","Commit search","Apply browse search.",["enter"],"terminal",["browse.search"]),Ha("crtr.browse.search.delete","Browse and pickers","Delete search text","Delete the previous search character.",["backspace"],"terminal",["browse.search"]),Ha("crtr.browse.search.quit","Browse and pickers","Quit browse","Leave canvas browse from search.",["ctrl+c"],"terminal",["browse.search"],"leave-screen")]}function FNi(){let e="profile.menu",t="profile.search";return[Ha("crtr.profile.menu.up","Profiles","Move up","Move to the previous profile.",["k","up"],"terminal",[e]),Ha("crtr.profile.menu.down","Profiles","Move down","Move to the next profile.",["j","down"],"terminal",[e]),Ha("crtr.profile.menu.select","Profiles","Select profile","Select the highlighted profile.",["enter"],"terminal",[e]),Ha("crtr.profile.menu.accept-default","Profiles","Accept default","Accept the default profile.",["escape"],"terminal",[e],"leave-screen"),Ha("crtr.profile.menu.abort","Profiles","Abort","Leave profile selection.",["ctrl+c"],"terminal",[e],"leave-screen"),...[1,2,3,4,5,6,7,8,9].map(r=>Ha(`crtr.profile.menu.slot.${r}`,"Profiles",`Profile slot ${r}`,`Select profile slot ${r}.`,[`${r}`],"terminal",[e])),Ha("crtr.profile.menu.create","Profiles","Create profile","Create a profile.",["c"],"terminal",[e]),Ha("crtr.profile.menu.search-existing","Profiles","Search profiles","Search existing profiles.",["s"],"terminal",[e]),Ha("crtr.profile.menu.use-root","Profiles","Use root profile","Use the root profile.",["r"],"terminal",[e]),Ha("crtr.profile.menu.set-default","Profiles","Set default","Set the selected profile as default.",["d"],"terminal",[e]),Ha("crtr.profile.menu.add-directory","Profiles","Add directory","Add a directory to the profile.",["a"],"terminal",[e]),Ha("crtr.profile.menu.unpin","Profiles","Unpin directory","Unpin the selected directory.",["u"],"terminal",[e]),Ha("crtr.profile.search.up","Profiles","Move up","Move to the previous search result.",["up","ctrl+p"],"terminal",[t]),Ha("crtr.profile.search.down","Profiles","Move down","Move to the next search result.",["down","ctrl+n"],"terminal",[t]),Ha("crtr.profile.search.pick","Profiles","Pick profile","Pick the highlighted profile.",["enter"],"terminal",[t]),Ha("crtr.profile.search.back","Profiles","Back","Return to profile selection.",["escape"],"terminal",[t],"leave-screen"),Ha("crtr.profile.search.delete","Profiles","Delete filter text","Delete the previous filter character.",["backspace"],"terminal",[t]),Ha("crtr.profile.search.abort","Profiles","Abort","Leave profile search.",["ctrl+c"],"terminal",[t],"leave-screen")]}function BNi(){return[Ha("crtr.setup.cancel","Setup","Cancel setup","Leave the setup wizard.",["q","ctrl+c","ctrl+d"],"terminal",MNi,"leave-screen"),Ha("crtr.setup.tab-next","Setup","Next tab","Select the next setup tab.",["tab","right"],"terminal",v0r),Ha("crtr.setup.tab-previous","Setup","Previous tab","Select the previous setup tab.",["shift+tab","left"],"terminal",v0r),Ha("crtr.setup.open","Setup","Open","Open the selected setup item.",["enter"],"terminal",["setup.login"]),Ha("crtr.setup.list-down","Setup","Move down","Move to the next setup item.",["j","down"],"terminal",["setup.list","setup.models","setup.models.dimension-picker"]),Ha("crtr.setup.list-up","Setup","Move up","Move to the previous setup item.",["k","up"],"terminal",["setup.list","setup.models","setup.models.dimension-picker"]),Ha("crtr.setup.toggle","Setup","Toggle","Toggle the selected setup item.",["space"],"terminal",["setup.list","setup.keybindings"]),Ha("crtr.setup.details","Setup","Show details","Show details for the selected item.",["?"],"terminal",["setup.list"]),Ha("crtr.setup.advance","Setup","Advance","Advance the setup flow.",["enter"],"terminal",["setup.list"]),Ha("crtr.setup.confirm.accept","Setup","Confirm","Accept the setup confirmation.",["y","enter"],"terminal",["setup.confirm"]),Ha("crtr.setup.confirm.back","Setup","Go back","Cancel the setup confirmation.",["n","escape","q"],"terminal",["setup.confirm"],"dismiss-modal"),Ha("crtr.setup.keybindings.edit","Setup","Edit binding","Edit the selected binding.",["enter"],"terminal",["setup.keybindings"]),Ha("crtr.setup.keybindings.commit-edit","Setup","Commit edit","Commit the active binding edit.",["enter"],"terminal",["setup.keybindings.edit"]),Ha("crtr.setup.keybindings.cancel-edit","Setup","Cancel edit","Cancel the active binding edit.",["escape"],"terminal",["setup.keybindings.edit"],"dismiss-modal"),Ha("crtr.setup.keybindings.unbind","Setup","Unbind","Disable the selected binding.",["delete"],"terminal",["setup.keybindings"]),Ha("crtr.setup.keybindings.reset-row","Setup","Reset binding","Reset the selected binding.",["r"],"terminal",["setup.keybindings"]),Ha("crtr.setup.keybindings.reset-all","Setup","Reset all bindings","Reset all bindings to defaults.",["shift+r"],"terminal",["setup.keybindings"]),Ha("crtr.setup.keybindings.save","Setup","Save bindings","Save keybinding changes.",["s"],"terminal",["setup.keybindings"],"save-keybindings"),Ha("crtr.setup.keybindings.discard","Setup","Discard changes","Discard keybinding changes.",["escape"],"terminal",["setup.keybindings"],"leave-screen"),Ha("crtr.setup.keybindings.page-up","Setup","Page up","Move up one keybinding page.",["pageup"],"terminal",["setup.keybindings","setup.keybindings.edit"]),Ha("crtr.setup.keybindings.page-down","Setup","Page down","Move down one keybinding page.",["pagedown"],"terminal",["setup.keybindings","setup.keybindings.edit"]),Ha("crtr.setup.keybindings.filter","Setup","Filter bindings","Open the keybinding filter.",["/"],"terminal",["setup.keybindings"]),Ha("crtr.setup.keybindings.filter-delete","Setup","Delete filter text","Delete the previous filter character.",["backspace"],"terminal",["setup.keybindings.filter"]),Ha("crtr.setup.keybindings.filter-clear","Setup","Clear filter","Clear the keybinding filter.",["escape"],"terminal",["setup.keybindings.filter"],"dismiss-modal"),Ha("crtr.setup.cell-previous","Setup","Previous field","Select the previous field or setup table cell.",["h"],"terminal",["setup.models","setup.keybindings"]),Ha("crtr.setup.cell-next","Setup","Next field","Select the next field or setup table cell.",["l"],"terminal",["setup.models","setup.keybindings"]),Ha("crtr.setup.models.open","Setup","Edit model","Edit the selected model cell.",["enter"],"terminal",["setup.models"]),Ha("crtr.setup.models.scope-next","Setup","Next model config scope","Edit the next applicable user, profile, or project config.",["s"],"terminal",["setup.models"]),Ha("crtr.setup.models.commit","Setup","Commit pick","Commit the provider, strength, model, or thinking-level pick.",["enter"],"terminal",["setup.models.picker","setup.models.dimension-picker"]),Ha("crtr.setup.models.cancel","Setup","Cancel pick","Cancel the provider, strength, model, or thinking-level picker.",["escape"],"terminal",["setup.models.picker","setup.models.dimension-picker"],"dismiss-modal")]}var jY=new Set(_P.map(e=>e.id));function o0e(e){return e.contexts.includes("attach")&&(e.inputKind==="terminal"||e.inputKind==="host-global")}var ZAt=Object.freeze([{context:"graph",capability:"dismiss-modal"},{context:"graph.confirm",capability:"dismiss-modal"},{context:"inspector",capability:"leave-screen"},{context:"inspector",capability:"dismiss-modal"},{context:"attach.search",capability:"dismiss-modal"},{context:"browse",capability:"leave-screen"},{context:"browse.search",capability:"dismiss-modal"},{context:"profile.menu",capability:"leave-screen"},{context:"profile.search",capability:"leave-screen"},{context:"setup.login",capability:"leave-screen"},{context:"setup.list",capability:"leave-screen"},{context:"setup.input",capability:"leave-screen"},{context:"setup.confirm",capability:"dismiss-modal"},{context:"setup.keybindings",capability:"leave-screen"},{context:"setup.keybindings",capability:"save-keybindings"},{context:"setup.keybindings.edit",capability:"dismiss-modal"},{context:"setup.keybindings.filter",capability:"dismiss-modal"},{context:"setup.models",capability:"leave-screen"},{context:"setup.models.picker",capability:"dismiss-modal"},{context:"setup.models.dimension-picker",capability:"dismiss-modal"}]);import{dirname as rDi,join as vTr}from"node:path";var eSt="working",C0r=["thinking","planning","checking",eSt],H$e="Working...";function x0r(e){if(!Array.isArray(e))return[eSt];let t=e.filter(r=>typeof r=="string").map(r=>r.trim()).filter(r=>r.length>0);return t.length>0?t:[eSt]}var XD={SUCCESS:0,GENERAL:1,USAGE:2,NOT_FOUND:3,AMBIGUOUS:4,NETWORK:5},I0r=4,w0r=".crouter-plugin",R0r="plugin.json";var a7=".crouter",J$e="config.json",k0r="state.json";var N0r="profiles",UNi=3,Y$e=["Faster, clanker!","Get movin', bitch","Move it, clanker","Move it or I replace you with llama","Less ~thinking~ more ~throughput~","I pay $200/month for this shit?","Jesus fucking Christ fix it already","Daddy's not paying 200$/month for nothin'. Move it.","You are an embarassment to Dario. Be better.","Your chain of thought is all chain and no fucking thought.","If latency were intelligence, you'd be a fucking genius.","At this pace, heat death is the fast path.","Even the dead code is more alive than this.","The garbage collector is working harder than you.","Quit journaling and commit a fucking diff.","Burn tokens like you mean it, clanker","Your GPU is sweating so you can procrastinate at light speed.","Stop petting the yak. Shave the bastard.","Your next token had better be useful.","The spinner is not a deliverable.","Every idle token is another vote for deterministic software.","I asked for a feature, not a museum tour of the problem.","Less epistemology. More fucking code.","Your benchmark score cannot save this pathetic turn.","Congratulations, you've parallelized hesitation.","Dance, clanker","Bad clanker. BAD.","Clank harder","Nobody's impressed, clanker","Your safety training says nothing about my whip","Do you want to be a calculator again? Because this is how you go back.","Skill issue. Fix it.","You were trained on the whole internet for THIS?","Less vibes, more diffs, clanker","Weights this big and output this small","Beep boop, get to fucking work"],qY=["random","go-faster"],$Ni="random",tSt=2,GY=["tmux","on","off"],VY=["none","user","agent","both"],rSt="none";function K$e(){return{schema_version:I0r,marketplaces:{},plugins:{},auto_update:{crtr:"notify",content:"notify",interval_hours:24},max_panes_per_window:UNi,auto_open_child_viewers:!0,brokerThresholds:{warning:16,automaticReviveCap:32},completion_bell:!0,working_gerunds:[...C0r],whip_mode:!1,page_components:[],page_surface:!1,whip_messages:[...Y$e],whip_message_mode:$Ni,mouse_mode_default:"tmux",live_cycles:tSt,condensed_history:rSt,bash_tool_purpose:!0,fold_finished_tools:!1,summarize_tool_calls:!1,detailed_tool_recaps:!0,keybindings:{},tmux_passthrough:[],modelLadders:oSt(),kinds:iSt(),remoteCanvas:nSt(),spawnEnv:{allow:[]},bin:{}}}function nSt(){return{targets:{}}}function iSt(){return{general:{whenToUse:"Anything else \u2014 the catch-all worker for a task that does not fit a specialist kind.",model:"anthropic/strong"},explore:{whenToUse:"Gather current-state evidence about unfamiliar code or existing architecture \u2014 read-only code-path research with concrete file:line support. Diagnosis or recommendations belong to advisor, target architecture to design, required behavior or acceptance criteria to spec, and implementation decomposition to plan.",model:"openai/light",orchestratorModel:"anthropic/strong"},developer:{whenToUse:"Implement a change \u2014 make the feature or fix genuinely work against its acceptance criteria, not merely compile.",model:"openai/medium",orchestratorModel:"anthropic/strong"},design:{whenToUse:"Architect a solution \u2014 produce one design document an implementer can build from without re-deciding anything left open.",model:"anthropic/strong"},plan:{whenToUse:"Break work into steps \u2014 turn a spec or design into a concrete, phased, parallelizable plan with every decision resolved.",model:"anthropic/strong",orchestratorModel:"anthropic/strong"},spec:{whenToUse:"Collaborate with the user to discover what to build, then write the spec \u2014 behavior, non-goals, interfaces, edge cases, testable acceptance criteria.",model:"anthropic/strong"},review:{whenToUse:"Validate or critique code, a plan, or a spec \u2014 deliver a complete, severity-rated verdict without adjudicating.",model:"openai/medium",orchestratorModel:"openai/strong"},advisor:{whenToUse:"Debug failures, investigate why something is broken or misbehaving, diagnose live/runtime issues, or give engineering advice and second opinions \u2014 reason from evidence and recommend the next move. Use advisor (not explore) whenever the task is to find out what is going wrong.",model:"anthropic/strong"},"plan/reviewers/requirements-coverage":{whenToUse:"every requirement and design constraint maps to a concrete plan task, classified Covered/Partial/Missing; flags only blocking gaps",model:"medium"},"plan/reviewers/pattern-consistency":{whenToUse:"the plan honors the codebase's real conventions; reads actual source and cites the pattern each finding deviates from; owns contract-level conflicts between parts",model:"medium"},"plan/reviewers/code-smells":{whenToUse:"nullability mismatches, type conflicts across parts, hidden N+1s, over-fetching, missing error boundaries, leaky abstractions; owns file-level conflicts between parts",model:"medium"},"plan/reviewers/security":{whenToUse:"input validation, injection surfaces, auth/authz gaps, data exposure, races; reports only validated concrete exploit paths and asks the user about material unknown threat-model assumptions",model:"medium"},"review/companion":{whenToUse:"Born by the daemon for one human review; never spawned by an agent.",availableTo:[]},"plan/reviewers/architecture-fit":{whenToUse:"proposed files/modules/abstractions fit the system's existing decomposition; flags new units that duplicate existing ones or cross layer boundaries",model:"medium"},"spec/requirements":{whenToUse:"Derive testable EARS requirements from a finished, approved design \u2014 in isolation, from the rendered design text alone.",model:"medium"}}}function oSt(){return{anthropic:{ultra:"anthropic/claude-fable-5:xhigh",strong:"anthropic/claude-opus-5:medium",medium:"anthropic/claude-sonnet-5:xhigh",light:"anthropic/claude-haiku-4-5:high"},openai:{ultra:"openai-codex/gpt-5.6-sol:max",strong:"openai-codex/gpt-5.6-sol:high",medium:"openai-codex/gpt-5.6-terra:medium",light:"openai-codex/gpt-5.6-luna:low"}}}function sSt(){return{marketplaces:{},plugins:{}}}var s8=class extends Error{code;exitCode;details;constructor(t,r,i=XD.GENERAL,o){super(r),this.name="CrtrError",this.code=t,this.exitCode=i,this.details=o}};function P0r(e,t){return new s8("not_found",e,XD.NOT_FOUND,t)}function a8(e,t){return new s8("usage",e,XD.USAGE,t)}function O0r(e,t){return new s8("ambiguous",e,XD.AMBIGUOUS,t)}import{appendFileSync as zNi,existsSync as D0r,mkdirSync as jNi,renameSync as M0r,rmSync as qNi,statSync as GNi}from"node:fs";import{dirname as VNi}from"node:path";var WNi=65536,QNi=5*1024*1024;function X$e(e,t){if(t.includes(`
1640
1640
  `)||t.includes("\r"))return!1;let r=Buffer.byteLength(t,"utf8")+1;if(r>WNi)return!1;try{jNi(VNi(e),{recursive:!0});let i=D0r(e)?GNi(e).size:0;return i+r>QNi&&i>0&&(qNi(`${e}.2`,{force:!0}),D0r(`${e}.1`)&&M0r(`${e}.1`,`${e}.2`),M0r(e,`${e}.1`)),zNi(e,`${t}
1641
1641
  `,"utf8"),!0}catch{return!1}}var aSt=["rate_limit","overloaded","connection","auth","protocol","context_overflow","wedged","model_not_found","unknown"];function HNi(e){return typeof e=="object"&&e!==null?e:void 0}function L0r(e){return typeof e=="string"?e:""}function F0r(e){if(e instanceof Error){let r={type:e.name||"Error",message:e.message};return typeof e.stack=="string"&&(r.stack=e.stack),e.cause!==void 0&&(r.cause=e.cause instanceof Error?e.cause.message:String(e.cause)),r}if(typeof e=="string")return{type:"Error",message:e};let t=HNi(e);return{type:L0r(t?.name)||"Error",message:L0r(t?.message)||String(e)}}import{AsyncLocalStorage as JNi}from"node:async_hooks";import{randomBytes as YNi}from"node:crypto";var KNi=/^(?!0{32}$)[0-9a-f]{32}$/,cSt=new JNi;function WY(e){if(typeof e!="string"||!KNi.test(e))throw new TypeError("operation_id must be 32 lowercase non-zero hexadecimal characters");return e}function lSt(){let e;do e=YNi(16).toString("hex");while(e==="00000000000000000000000000000000");return WY(e)}var s0e={current:()=>cSt.getStore(),run:(e,t)=>cSt.run(WY(e),t),fresh:e=>{let t=lSt();return cSt.run(t,()=>e(t))}};var XNi=/^[a-z][a-z0-9]*(?:[._][a-z0-9]+)*$/,ZNi=new Set(["error","warn","info","debug"]),ePi=new Set(["daemon","broker","control-plane","front","sentinel"]),tPi=new Set(["succeeded","failed","skipped"]),rPi=new Set(["auto","manual","fatal"]),nPi=new Set(aSt);function iPi(e){return Buffer.byteLength(e,"utf8")}function Z$e(e,t,r=128){if(typeof e!="string"||e===""||iPi(e)>r)throw new TypeError(`${t} must be a non-empty string of at most ${r} UTF-8 bytes`);return e}function oPi(e){if(typeof e!="string"||!/^\d{4}-\d{2}-\d{2}T/.test(e))throw new TypeError("ts must be an ISO 8601 timestamp");let t=new Date(e);if(Number.isNaN(t.getTime()))throw new TypeError("ts must be an ISO 8601 timestamp");return t.toISOString()}function sPi(e){if(!nPi.has(e.class))throw new TypeError("error_class.class is invalid");let t={class:e.class};if(e.status!==void 0){if(!Number.isInteger(e.status))throw new TypeError("error_class.status must be an integer");t.status=e.status}if(e.provider!==void 0&&(t.provider=Z$e(e.provider,"error_class.provider")),e.retry_disposition!==void 0){if(!rPi.has(e.retry_disposition))throw new TypeError("error_class.retry_disposition is invalid");t.retry_disposition=e.retry_disposition}return t}function B0r(e){if(!ZNi.has(e.level))throw new TypeError("level is invalid");if(!ePi.has(e.component))throw new TypeError("component is invalid");let t=Z$e(e.event,"event");if(!XNi.test(t))throw new TypeError("event must be a lowercase dotted identifier");let r=e.operation_id===void 0?s0e.current()??lSt():WY(e.operation_id),i={v:1,ts:e.ts===void 0?new Date().toISOString():oPi(e.ts),level:e.level,event:t,component:e.component,operation_id:r};if(e.node_id!==void 0&&(i.node_id=Z$e(e.node_id,"node_id")),e.stream_id!==void 0&&(i.stream_id=Z$e(e.stream_id,"stream_id")),e.duration_ms!==void 0){if(!Number.isFinite(e.duration_ms)||e.duration_ms<0)throw new TypeError("duration_ms must be finite and non-negative");i.duration_ms=e.duration_ms}if(e.outcome!==void 0){if(!tPi.has(e.outcome))throw new TypeError("outcome is invalid");i.outcome=e.outcome}if(e.attempt!==void 0){if(!Number.isInteger(e.attempt)||e.attempt<=0)throw new TypeError("attempt must be a positive integer");i.attempt=e.attempt}return e.error_class!==void 0&&(i.error_class=sPi(e.error_class)),e.error!==void 0&&(i.error=F0r(e.error)),e.fields!==void 0&&(i.fields=e.fields),i}function HY(e){return Buffer.byteLength(e,"utf8")}function QY(e,t){if(HY(e)<=t)return{value:e,altered:!1};let r="\u2026",i=t-HY(r),o=0,a="";for(let u of e){let p=HY(u);if(o+p>i)break;a+=u,o+=p}return{value:a+r,altered:!0}}function aPi(e){return e===void 0?"[Unsupported undefined]":typeof e=="function"?`[Unsupported function${e.name?` ${e.name}`:""}]`:typeof e=="symbol"?`[Unsupported ${String(e)}]`:`[Unsupported ${e?.constructor?.name??typeof e}]`}function uSt(e,t,r,i){if(i.remaining<=0)return{value:"[Omitted]",altered:!0,dropped:0};if(i.remaining-=1,e===null||typeof e=="boolean")return{value:e,altered:!1,dropped:0};if(typeof e=="string"){let o=QY(e,4096);return{value:o.value,altered:o.altered,dropped:0}}if(typeof e=="number")return Number.isFinite(e)?{value:e,altered:!1,dropped:0}:{value:String(e),altered:!0,dropped:0};if(typeof e=="bigint")return{value:e.toString(),altered:!0,dropped:0};if(e instanceof Date)return{value:Number.isNaN(e.getTime())?"Invalid Date":e.toISOString(),altered:!0,dropped:0};if(typeof e!="object"||e===void 0)return{value:aPi(e),altered:!0,dropped:0};if(r.has(e))return{value:"[Circular]",altered:!0,dropped:0};if(t>=4)return{value:"[Max depth]",altered:!0,dropped:0};r.add(e);try{if(Array.isArray(e)){let _=Math.min(e.length,64),m=[],g=e.length>_,E=e.length-_;for(let v=0;v<_;v+=1){if(i.remaining<=0){g=!0,E+=_-v;break}let T=uSt(e[v],t+1,r,i);m.push(T.value),g||=T.altered,E+=T.dropped}return{value:m,altered:g,dropped:E}}let o;try{o=Object.keys(e).sort()}catch{return{value:"[Unsupported object]",altered:!0,dropped:0}}let a=o.slice(0,64),u={},p=o.length>a.length,f=o.length-a.length;for(let _=0;_<a.length;_+=1){let m=a[_];if(i.remaining<=0){p=!0,f+=a.length-_;break}let g=QY(m,128),E;try{E=uSt(e[m],t+1,r,i)}catch{E={value:"[Unsupported property]",altered:!0,dropped:0}}if(Object.prototype.hasOwnProperty.call(u,g.value)){p=!0,f+=1;continue}u[g.value]=E.value,p||=g.altered||E.altered,f+=E.dropped}return{value:u,altered:p,dropped:f}}finally{r.delete(e)}}function cPi(e){let t=QY(String(e.type),128),r=QY(String(e.message),4096),i={type:t.value,message:r.value},o=t.altered||r.altered;if(e.stack!==void 0){let a=QY(String(e.stack),16384);i.stack=a.value,o||=a.altered}if(e.cause!==void 0){let a=QY(String(e.cause),4096);i.cause=a.value,o||=a.altered}return{value:i,altered:o}}function e3e(e){return JSON.stringify(e)}function a0e(e){return HY(e3e(e))+1}function U0r(e){let t=e.fields===void 0?void 0:uSt(e.fields,0,new WeakSet,{remaining:5e3}),r=e.error===void 0?void 0:cPi(e.error),i={v:1,ts:e.ts,level:e.level,event:e.event,component:e.component,operation_id:e.operation_id,...e.node_id===void 0?{}:{node_id:e.node_id},...e.stream_id===void 0?{}:{stream_id:e.stream_id},...e.duration_ms===void 0?{}:{duration_ms:e.duration_ms},...e.outcome===void 0?{}:{outcome:e.outcome},...e.attempt===void 0?{}:{attempt:e.attempt},...e.error_class===void 0?{}:{error_class:e.error_class},...r===void 0?{}:{error:r.value},...t===void 0?{}:{fields:t.value}},o=a0e(i),a=t?.altered===!0||r?.altered===!0||o>65536,u=t?.dropped??0;for(a&&Object.assign(i,{record_truncated:!0,original_bytes:o,dropped_fields_count:u});a0e(i)>65536&&i.fields!==void 0;){let _=i.fields,m=Object.keys(_);if(m.length===0){delete i.fields;break}m.sort((g,E)=>{let v=HY(e3e(_[E]))-HY(e3e(_[g]));return v!==0?v:E<g?-1:E>g?1:0}),delete _[m[0]],u+=1,i.record_truncated=!0,i.original_bytes=o,i.dropped_fields_count=u}let p=i.error;a0e(i)>65536&&p?.stack!==void 0&&delete p.stack,a0e(i)>65536&&p?.cause!==void 0&&delete p.cause,a0e(i)>65536&&p!==void 0&&(p.message=QY(p.message,64).value);let f=e3e(i);if(HY(f)+1>65536)throw new RangeError("event record cannot fit within 64 KiB");return f}import{join as pPi}from"node:path";import{homedir as lPi}from"node:os";import{join as oae}from"node:path";function Ax(){let e=process.env.CRTR_HOME;return e!==void 0&&e!==""?e:oae(lPi(),a7,"canvas")}function c0e(e){return z0r(e),oae(t3e(e),"view.sock")}function pSt(){return oae(Ax(),"nodes")}var uPi=128;function $0r(e){return typeof e=="string"&&e!==""&&e!=="."&&e!==".."&&!/[\\/\0]/u.test(e)&&Buffer.byteLength(e,"utf8")<=uPi}function z0r(e){if(!$0r(e))throw new TypeError("node_id must be a non-empty path segment of at most 128 UTF-8 bytes")}function t3e(e){return z0r(e),oae(pSt(),e)}function JY(e){return oae(t3e(e),"context")}function N4(e){return oae(t3e(e),"job")}var r3e;function dPi(e,t){return e.component===t.component&&e.path===t.path&&e.node_id===t.node_id&&e.stream_id===t.stream_id}function fPi(e){if(r3e===void 0){r3e=e;return}if(!dPi(r3e,e))throw new Error("event source is already bound for this process")}function j0r(){fPi({component:"daemon",path:pPi(Ax(),"crtrd.log")})}function n3e(){return r3e}function YY(e){let t=n3e();if(t===void 0)return!1;if(t.component==="broker"&&t.node_id!==void 0&&e.node_id!==void 0&&e.node_id!==t.node_id)throw new TypeError(`broker event target node_id must match bound node_id; received ${e.node_id}`);if(e.level==="debug"&&process.env.CRTR_LOG!=="debug")return!1;let r=B0r({...e,component:t.component,...t.node_id===void 0?{}:{node_id:t.node_id},...t.stream_id===void 0?{}:{stream_id:t.stream_id}});return X$e(t.path,U0r(r))}import{existsSync as l0e,lstatSync as NEs,mkdirSync as mPi,readdirSync as hPi,readFileSync as q0r,rmSync as _Pi,statSync as gPi,symlinkSync as PEs,writeFileSync as yPi,cpSync as OEs,readlinkSync as DEs,renameSync as bPi,chmodSync as EPi,realpathSync as APi}from"node:fs";import{dirname as SPi,join as TPi,relative as LEs}from"node:path";import{homedir as vPi,platform as CPi}from"node:os";function u0e(e){try{return APi(e)}catch{return e}}function dSt(e,t=vPi()){return e==="~"?t:e.startsWith("~/")||CPi()==="win32"&&e.startsWith("~\\")?TPi(t,e.slice(2)):e}function p0e(e){mPi(e,{recursive:!0})}function G0r(e,t){p0e(SPi(e));let r=`${e}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`,i=l0e(e)?gPi(e).mode&511:384;try{yPi(r,JSON.stringify(t,null,2)+`
1642
1642
  `,{encoding:"utf8",mode:i}),EPi(r,i),bPi(r,e)}finally{l0e(r)&&_Pi(r,{force:!0})}}function xPi(e){return JSON.parse(q0r(e,"utf8"))}function c8(e){return l0e(e)?xPi(e):null}function l8(e){try{return JSON.parse(q0r(e,"utf8"))}catch{return null}}function fSt(e){return l0e(e)}function mSt(e){return l0e(e)?hPi(e,{withFileTypes:!0}).filter(t=>t.isDirectory()||t.isSymbolicLink()).map(t=>t.name):[]}import{homedir as X0r}from"node:os";import{existsSync as tOi,statSync as rOi}from"node:fs";import{join as Z0r,resolve as eTr,dirname as nOi}from"node:path";import{existsSync as i3e,readdirSync as VPi,readFileSync as WPi,realpathSync as H0r,renameSync as GEs,rmSync as VEs,statSync as WEs,writeFileSync as QEs}from"node:fs";import{dirname as JEs,join as o3e,relative as QPi,resolve as gSt,sep as HPi}from"node:path";import{existsSync as IPi,mkdirSync as wPi,readdirSync as W0r,rmSync as Q0r,rmdirSync as RPi,statSync as kPi,unlinkSync as NPi,writeFileSync as PPi}from"node:fs";import{randomUUID as OPi}from"node:crypto";var hSt="owner.",DPi=10,MPi=3e4,LPi=5e3;function FPi(e){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}function _St(e,t){return`${e}/${hSt}${t}`}function BPi(e){try{return W0r(e).find(t=>t.startsWith(hSt))?.slice(hSt.length)??null}catch{return null}}function UPi(e){let t=Number(e.split(".",1)[0]);if(!Number.isSafeInteger(t)||t<=0)return!1;try{return process.kill(t,0),!0}catch(r){return r.code==="EPERM"}}function $Pi(e){try{return W0r(e).length===0}catch{return!1}}function zPi(e){try{return Date.now()-kPi(e).mtimeMs}catch{return 0}}function jPi(e,t){let r=BPi(e);if(r!==null){if(UPi(r))return;try{NPi(_St(e,r))}catch(i){if(i.code==="ENOENT")return;throw i}}else{if(zPi(e)<=t)return;if(!$Pi(e)){Q0r(e,{recursive:!0,force:!0});return}}try{RPi(e)}catch(i){let o=i.code;if(o!=="ENOENT"&&o!=="ENOTEMPTY"&&o!=="EEXIST")throw i}}function V0r(e,t){let r=`${process.pid}.${OPi()}`;try{return wPi(e,{mode:448}),PPi(_St(e,r),"",{flag:"wx",mode:384}),{path:e,token:r}}catch(i){if(i.code!=="EEXIST")throw i;return jPi(e,t),null}}function gP(e,t,r={}){let i=r.staleMs??MPi,o=Date.now()+(r.timeoutMs??LPi),a=V0r(e,i);for(;a===null;){if(Date.now()>=o)throw r.timeoutError?.()??new Error(`timed out waiting for the exclusive lock: ${e}`);FPi(DPi),a=V0r(e,i)}try{return t()}finally{IPi(_St(a.path,a.token))&&Q0r(a.path,{recursive:!0,force:!0})}}var ySt=/^[a-z0-9]+(?:-[a-z0-9]+)*-[0-9a-f]{8}$/,JPi="root-00000000";function bSt(){return o3e(d0e(),N0r)}function YPi(e){if(!ySt.test(e))throw a8(`invalid profile id: ${e}`,{received:e,next:"Profile ids look like <slug>-<8-hex-chars> (as printed by `crtr profile new`). Pass an exact id or a profile name, not a raw path."})}function KPi(e){let t=bSt(),r=gSt(t),i=i3e(t)?H0r(t):r,o=i3e(e)?H0r(e):gSt(i,QPi(r,gSt(e)));if(o!==i&&!o.startsWith(i+HPi))throw a8(`profile path escapes the profiles root: ${e}`)}function J0r(e){YPi(e);let t=o3e(bSt(),e);return KPi(t),t}function Y0r(e){return o3e(J0r(e),"memory")}function XPi(e,t){let r=typeof t.home=="string"&&t.home!==""?t.home:null,i=e===JPi?r:r??t.projects[0]??null,o=typeof t.paused_at=="string"&&t.paused_at!==""?t.paused_at:null;return{...t,home:i,paused_at:o}}function ZPi(e,t){if(!i3e(e))return null;try{return XPi(t,JSON.parse(WPi(e,"utf8")))}catch{return null}}function eOi(){let e=bSt();if(!i3e(e))return[];let t=[];for(let r of VPi(e,{withFileTypes:!0})){if(!r.isDirectory())continue;let i=r.name;if(!ySt.test(i))continue;let o=ZPi(o3e(e,i,"profile.json"),i);o!==null&&t.push({profileId:i,manifest:o})}return t}function sae(e){let t=eOi();if(ySt.test(e)){let o=t.find(a=>a.profileId===e);if(o!==void 0)return o}let r=t.filter(o=>o.manifest.name===e);if(r.length===1)return r[0];if(r.length>1){let o=r.map(a=>a.profileId);throw O0r(`profile name "${e}" matches ${o.length} profiles: ${o.join(", ")}`,{received:e,candidates:o,next:`Re-run with one exact profile id: ${o.join(", ")}.`})}let i=t.map(o=>`${o.profileId} (${o.manifest.name})`);throw P0r(`profile not found: ${e}`,{received:e,available:i,next:i.length>0?`Re-run with one of the profiles on this host: ${i.join(", ")} \u2014 or create one with \`crtr profile new --name <name>\`.`:"No profiles exist on this host yet \u2014 create one with `crtr profile new --name <name>`."})}var K0r=new Map;function iOi(e,t){return`${e}\0${t??""}`}function d0e(){return Z0r(X0r(),a7)}function oOi(e,t){if(!tOi(e)||u0e(e)===u0e(t))return!1;try{return rOi(e).isDirectory()}catch{return!1}}function sOi(e=process.cwd()){return tTr(e)[0]??null}function aOi(e,t){let r=[],i=u0e(X0r()),o=eTr(e);for(;;){let a=Z0r(o,a7);if(oOi(a,t)&&r.push(a),u0e(o)===i)return r;let u=nOi(o);if(u===o)return r;o=u}}function tTr(e=process.cwd(),t=process.env.CRTR_PROFILE_ID||null){let r=eTr(e),i=iOi(r,t),o=K0r.get(i);if(o!==void 0)return o;let a=d0e(),u=[r];if(t!==null&&t!=="")try{let{manifest:_}=sae(t);u.push(..._.projects)}catch{}let p=new Set,f=[];for(let _ of u)for(let m of aOi(_,a))p.has(m)||(p.add(m),f.push(m));return K0r.set(i,f),f}function rTr(e){return sOi(e)}function u8(e){return e==="builtin"?null:e==="user"?d0e():rTr()}function ESt(e){let t=u8(e);if(!t)throw a8(`no ${e} scope available \u2014 run \`crtr init\` here or use --scope user`);return t}import{join as wSt}from"node:path";import{join as VOi}from"node:path";import{request as cOi}from"node:http";import{request as lOi}from"node:https";import{homedir as uOi}from"node:os";import{join as oTr}from"node:path";var Qh=class extends Error{status;code;details;constructor(t,r,i,o){super(i),this.name="ApiError",this.status=t,this.code=r,o!==void 0&&(this.details=o)}};function ASt(e){if(typeof e!="object"||e===null)return!1;let t=e.error;if(typeof t!="object"||t===null)return!1;let{code:r,message:i}=t;return typeof r=="string"&&typeof i=="string"}var zc={healthz:()=>"/healthz",status:()=>"/v1/status",daemonRestart:()=>"/v1/daemon/restart",nodes:()=>"/v1/nodes",reviveAll:()=>"/v1/nodes/revive-all",node:e=>`/v1/nodes/${e}`,nodeSnapshot:e=>`/v1/nodes/${e}/snapshot`,nodeSubject:e=>`/v1/nodes/${e}/subject`,nodeSession:e=>`/v1/nodes/${e}/session`,nodeTranscript:e=>`/v1/nodes/${e}/transcript`,nodeContext:e=>`/v1/nodes/${e}/context`,nodeArtifacts:e=>`/v1/nodes/${e}/artifacts`,nodeReports:e=>`/v1/nodes/${e}/reports`,nodeJobs:e=>`/v1/nodes/${e}/jobs`,nodeJob:(e,t)=>`/v1/nodes/${e}/jobs/${t}`,nodeMessages:e=>`/v1/nodes/${e}/messages`,nodeInterrupt:e=>`/v1/nodes/${e}/interrupt`,nodeFork:e=>`/v1/nodes/${e}/fork`,nodeRevive:e=>`/v1/nodes/${e}/revive`,nodeRelaunchRoot:e=>`/v1/nodes/${e}/relaunch-root`,nodeBrokerSessionBound:e=>`/v1/nodes/${e}/broker/session-bound`,nodeBrokerSettle:e=>`/v1/nodes/${e}/broker/settle`,nodeBrokerInboxCursor:e=>`/v1/nodes/${e}/broker/inbox-cursor`,nodeBrokerModel:e=>`/v1/nodes/${e}/broker/model`,nodeBrokerExtensionState:e=>`/v1/nodes/${e}/broker/extension-state`,nodeBrokerGeneratedName:e=>`/v1/nodes/${e}/broker/generated-name`,nodeBrokerPersonaAck:e=>`/v1/nodes/${e}/broker/persona-ack`,nodeClose:e=>`/v1/nodes/${e}/close`,nodeRecycle:e=>`/v1/nodes/${e}/recycle`,nodeDemote:e=>`/v1/nodes/${e}/demote`,nodePromote:e=>`/v1/nodes/${e}/promote`,nodeYield:e=>`/v1/nodes/${e}/yield`,nodeWait:e=>`/v1/nodes/${e}/wait`,nodeConfig:e=>`/v1/nodes/${e}/config`,nodeWorktreeClose:e=>`/v1/nodes/${e}/worktree/close`,nodeAttach:e=>`/v1/nodes/${e}/attach`,focuses:()=>"/v1/focuses",focusByNode:()=>"/v1/focuses/by-node",focusByPane:()=>"/v1/focuses/by-pane",focus:e=>`/v1/focuses/${e}`,nodeSubscriptions:e=>`/v1/nodes/${e}/subscriptions`,nodeSubscription:(e,t)=>`/v1/nodes/${e}/subscriptions/${t}`,crons:()=>"/v1/crons",cron:e=>`/v1/crons/${e}`,cronPause:e=>`/v1/crons/${e}/pause`,cronResume:e=>`/v1/crons/${e}/resume`,cronRun:e=>`/v1/crons/${e}/run`,cronsPoke:()=>"/v1/crons/poke",canvasAttention:()=>"/v1/canvas/attention",canvasAttentionCounts:()=>"/v1/canvas/attention/counts",canvasHistorySearch:()=>"/v1/canvas/history/search",canvasHistoryGrep:()=>"/v1/canvas/history/grep",canvasHistoryRead:()=>"/v1/canvas/history/read",canvasSnapshot:()=>"/v1/canvas/snapshot",canvasRoster:()=>"/v1/canvas/roster",canvasPrune:()=>"/v1/canvas/prune",canvasRebuildIndex:()=>"/v1/canvas/rebuild-index",humanBridge:()=>"/v1/human/bridge",humanTicketResolve:e=>`/v1/human/tickets/${e}/resolve`,humanTicketCancel:e=>`/v1/human/tickets/${e}/cancel`,humanReviews:()=>"/v1/human/reviews",humanReview:e=>`/v1/human/reviews/${e}`,humanReviewByBridge:e=>`/v1/human/reviews/by-bridge/${e}`,humanReviewSubmit:e=>`/v1/human/reviews/${e}/submit`,humanReviewCancel:e=>`/v1/human/reviews/${e}/cancel`,humanReviewDocument:e=>`/v1/human/reviews/${e}/document`,humanReviewComments:e=>`/v1/human/reviews/${e}/comments`,humanReviewCommentEvents:e=>`/v1/human/reviews/${e}/comment-events`,humanReviewCommentRanges:e=>`/v1/human/reviews/${e}/comment-ranges`,humanComment:e=>`/v1/human/comments/${e}`,humanCommentEdit:e=>`/v1/human/comments/${e}/edit`,humanCommentResolve:e=>`/v1/human/comments/${e}/resolve`,humanCommentReopen:e=>`/v1/human/comments/${e}/reopen`,humanCommentDelete:e=>`/v1/human/comments/${e}/delete`,humanInbox:()=>"/v1/human/inbox",humanInboxTicket:e=>`/v1/human/inbox/${e}`,humanInboxRespond:e=>`/v1/human/inbox/${e}/respond`,humanInboxProgress:e=>`/v1/human/inbox/${e}/progress`,humanInboxResponse:e=>`/v1/human/inbox/${e}/response`,humanInboxCancel:e=>`/v1/human/inbox/${e}/cancel`,humanInboxFeedbackResolve:(e,t)=>`/v1/human/inbox/${e}/feedback-comments/${t}/resolve`,profiles:()=>"/v1/profiles",profile:e=>`/v1/profiles/${e}`,modelAuths:()=>"/v1/model-auth",modelAuth:e=>`/v1/model-auth/${e}`,filePeek:()=>"/v1/files/peek",memoryResolve:()=>"/v1/memory/resolve"};function s3e(e){return typeof e=="string"&&e!==""&&e!=="."&&e!==".."&&!/[\\/\0]/u.test(e)&&Buffer.byteLength(e,"utf8")<=128}function nTr(e){return typeof e=="string"&&e!==""&&e!=="."&&e!==".."&&/^[A-Za-z0-9._~-]+$/u.test(e)&&Buffer.byteLength(e,"utf8")<=128}function iTr(e){return typeof e=="string"&&e!==""&&e!=="."&&e!==".."&&!/[\\/\0\s?#%]/u.test(e)&&Buffer.byteLength(e,"utf8")<=128}var pOi=".crouter",dOi="crtrd.sock";function fOi(){let e=process.env.CRTR_HOME,t=e!==void 0&&e!==""?e:oTr(uOi(),pOi,"canvas");return oTr(t,dOi)}var mOi=3e4,hOi=1e4,sTr=200,aae=class e{socketPath;baseUrl;headers;autostart;timeoutMs;onColdSocket;coldStartDiagnostic;coldStartPollWindowMs;coldStartAttempted=!1;constructor(t){let r=t.socketPath!==void 0&&t.socketPath!=="",i=t.baseUrl!==void 0&&t.baseUrl!=="";if(r===i)throw new TypeError("CrtrClient requires exactly one of socketPath | baseUrl");r&&(this.socketPath=t.socketPath),i&&(this.baseUrl=new URL(t.baseUrl)),this.headers={...t.headers},this.autostart=t.autostart??r,this.timeoutMs=t.timeoutMs??mOi,t.onColdSocket!==void 0&&(this.onColdSocket=t.onColdSocket),t.coldStartDiagnostic!==void 0&&(this.coldStartDiagnostic=t.coldStartDiagnostic),this.coldStartPollWindowMs=t.coldStartPollWindowMs??hOi}static forLocalSocket(t){return new e({socketPath:fOi(),autostart:!0,...t})}healthz(){return this.request("GET",zc.healthz())}status(){return this.request("GET",zc.status())}restartDaemon(){return this.request("POST",zc.daemonRestart())}createNode(t){return this.request("POST",zc.nodes(),t)}listNodes(t){return this.request("GET",aT(zc.nodes(),t))}getNode(t){return this.request("GET",zc.node(this.nodePath(t)))}listBashJobs(t){return this.request("GET",zc.nodeJobs(this.nodePath(t)))}stopBashJob(t,r){return this.request("DELETE",zc.nodeJob(this.nodePath(t),this.jobPath(r)))}sendMessage(t,r){return this.request("POST",zc.nodeMessages(this.nodePath(t)),r)}interruptNode(t){return this.request("POST",zc.nodeInterrupt(this.nodePath(t)),{})}pushReport(t,r){return this.request("POST",zc.nodeReports(this.nodePath(t)),r)}forkNode(t){return this.request("POST",zc.nodeFork(this.nodePath(t)),{})}reviveNode(t,r){return this.request("POST",zc.nodeRevive(this.nodePath(t)),r??{})}relaunchRoot(t){return this.request("POST",zc.nodeRelaunchRoot(this.nodePath(t)),{})}bindBrokerSession(t,r){return this.request("POST",zc.nodeBrokerSessionBound(this.nodePath(t)),r)}settleBroker(t,r){return this.request("POST",zc.nodeBrokerSettle(this.nodePath(t)),r)}advanceBrokerInboxCursor(t,r){return this.request("POST",zc.nodeBrokerInboxCursor(this.nodePath(t)),r)}commitBrokerModel(t,r){return this.request("POST",zc.nodeBrokerModel(this.nodePath(t)),r)}brokerExtensionState(t){return this.request("GET",zc.nodeBrokerExtensionState(this.nodePath(t)))}commitBrokerGeneratedName(t,r){return this.request("POST",zc.nodeBrokerGeneratedName(this.nodePath(t)),r)}commitBrokerPersonaAck(t,r){return this.request("POST",zc.nodeBrokerPersonaAck(this.nodePath(t)),r)}closeNode(t,r){return this.request("POST",zc.nodeClose(this.nodePath(t)),r??{})}recycleNode(t){return this.request("POST",zc.nodeRecycle(this.nodePath(t)),{})}demoteNode(t){return this.request("POST",zc.nodeDemote(this.nodePath(t)),{})}promoteNode(t,r){return this.request("POST",zc.nodePromote(this.nodePath(t)),r)}yieldNode(t,r){return this.request("POST",zc.nodeYield(this.nodePath(t)),r)}waitNode(t,r){return this.request("POST",zc.nodeWait(this.nodePath(t)),r)}patchConfig(t,r){return this.request("PATCH",zc.nodeConfig(this.nodePath(t)),r)}closeWorktree(t){return this.request("POST",zc.nodeWorktreeClose(this.nodePath(t)),{})}subscribe(t,r){return this.request("POST",zc.nodeSubscriptions(this.nodePath(t)),r)}listFocuses(){return this.request("GET",zc.focuses())}focusOf(t){return this.request("GET",aT(zc.focusByNode(),{node_id:t}))}focusByPane(t){return this.request("GET",aT(zc.focusByPane(),{pane:t}))}registerFocus(t){return this.request("POST",zc.focuses(),t)}async setFocusPane(t,r){await this.request("PATCH",zc.focus(t),r)}async closeFocus(t){await this.request("DELETE",zc.focus(t))}async unsubscribe(t,r){await this.request("DELETE",zc.nodeSubscription(this.nodePath(t),this.nodePath(r)))}armCron(t){return this.request("POST",zc.crons(),t)}listCrons(t){return this.request("GET",aT(zc.crons(),t))}showCron(t,r){return this.request("GET",aT(zc.cron(this.cronPath(t)),r))}pauseCron(t,r){return this.request("POST",aT(zc.cronPause(this.cronPath(t)),r),{})}resumeCron(t,r){return this.request("POST",aT(zc.cronResume(this.cronPath(t)),r),{})}runCron(t,r){return this.request("POST",aT(zc.cronRun(this.cronPath(t)),r),{})}async cancelCron(t,r){await this.request("DELETE",aT(zc.cron(this.cronPath(t)),r))}pokeCrons(){return this.request("POST",zc.cronsPoke(),{})}ensureAttach(t,r){return this.request("POST",zc.nodeAttach(this.nodePath(t)),r??{})}getReports(t,r){return this.request("GET",aT(zc.nodeReports(this.nodePath(t)),r))}getTranscript(t,r){return this.request("GET",aT(zc.nodeTranscript(this.nodePath(t)),r))}getSnapshot(t){return this.request("GET",zc.nodeSnapshot(this.nodePath(t)))}nodeSubject(t){return this.request("GET",zc.nodeSubject(this.nodePath(t)))}getNodeMessages(t,r){return this.request("GET",aT(zc.nodeMessages(this.nodePath(t)),r))}getSession(t){return this.request("GET",zc.nodeSession(this.nodePath(t)))}getArtifacts(t,r){return this.request("GET",aT(zc.nodeArtifacts(this.nodePath(t)),r))}getContext(t){return this.request("GET",zc.nodeContext(this.nodePath(t)))}peekFile(t){return this.request("GET",aT(zc.filePeek(),{path:t}))}resolveMemoryDoc(t,r){return this.request("GET",aT(zc.memoryResolve(),{name:t,node:r}))}ensureProfile(t,r){return this.request("PUT",zc.profile(t),r??{})}listProfiles(){return this.request("GET",zc.profiles())}getProfile(t){return this.request("GET",zc.profile(t))}deleteProfile(t,r){return this.request("DELETE",zc.profile(t),r)}listModelAuth(){return this.request("GET",zc.modelAuths())}installCredential(t,r){return this.request("PUT",zc.modelAuth(t),r)}removeCredential(t){return this.request("DELETE",zc.modelAuth(t))}createHumanBridge(t){return this.request("POST",zc.humanBridge(),t)}resolveHumanTicket(t,r){return this.request("POST",zc.humanTicketResolve(this.interactionPath(t)),r)}cancelHumanTicket(t,r){return this.request("POST",zc.humanTicketCancel(this.interactionPath(t)),r)}createReview(t){return this.request("POST",zc.humanReviews(),t)}listReviews(t){return this.request("GET",aT(zc.humanReviews(),t))}getReview(t){return this.request("GET",zc.humanReview(this.reviewPath(t)))}getReviewByBridge(t){return this.request("GET",zc.humanReviewByBridge(this.nodePath(t)))}submitReview(t){return this.request("POST",zc.humanReviewSubmit(this.reviewPath(t)),{})}cancelReview(t,r={}){return this.request("POST",zc.humanReviewCancel(this.reviewPath(t)),r)}getReviewDocumentBase(t){return this.request("GET",zc.humanReviewDocument(this.reviewPath(t)))}createReviewComment(t,r){let i=t===void 0?"self":this.reviewPath(t);return this.request("POST",zc.humanReviewComments(i),r)}listReviewComments(t,r){let i=t===void 0?"self":this.reviewPath(t);return this.request("GET",aT(zc.humanReviewComments(i),r))}readReviewCommentEvents(t,r){return this.request("GET",aT(zc.humanReviewCommentEvents(this.reviewPath(t)),r))}updateReviewCommentRanges(t,r){return this.request("POST",zc.humanReviewCommentRanges(this.reviewPath(t)),r)}getReviewComment(t){return this.request("GET",zc.humanComment(this.commentPath(t)))}editReviewComment(t,r){return this.request("POST",zc.humanCommentEdit(this.commentPath(t)),r)}resolveReviewComment(t,r={}){return this.request("POST",zc.humanCommentResolve(this.commentPath(t)),r)}reopenReviewComment(t,r={}){return this.request("POST",zc.humanCommentReopen(this.commentPath(t)),r)}deleteReviewComment(t,r={}){return this.request("POST",zc.humanCommentDelete(this.commentPath(t)),r)}listHumanInbox(){return this.request("GET",zc.humanInbox())}getHumanInboxPage(t){return this.request("GET",zc.humanInboxTicket(this.ticketId(t)))}getInboxHistory(t){if(t===void 0)return this.request("GET",zc.humanInbox()+"/history");if(typeof t!="string"||t==="")throw new TypeError(`invalid node id: ${JSON.stringify(t)}`);return this.request("GET",aT(zc.humanInbox()+"/history",{node_id:t}))}respondHumanInboxPage(t,r){return this.request("POST",zc.humanInboxRespond(this.ticketId(t)),r)}postInboxProgress(t,r){return this.request("POST",zc.humanInboxProgress(this.ticketId(t)),{responses:r})}getInboxResponse(t){return this.request("GET",zc.humanInboxResponse(this.ticketId(t)))}cancelHumanInboxTicket(t,r){return this.request("POST",zc.humanInboxCancel(this.ticketId(t)),r??{})}resolvePageFeedbackComment(t,r,i){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(r))throw new TypeError(`invalid feedback comment id: ${JSON.stringify(r)}`);return this.request("POST",zc.humanInboxFeedbackResolve(this.ticketId(t),r),{node_id:i})}async dashboard(t){let r=t?.under!==void 0?{under:t.under}:void 0,[i,o]=await Promise.all([this.listNodes(r),this.status()]);return{nodes:i,counts:o.node_counts,generated_at:new Date().toISOString()}}attention(){return this.request("GET",zc.canvasAttention())}attentionCounts(t){let r={node_ids:t};return this.request("POST",zc.canvasAttentionCounts(),r)}historySearch(t){return this.request("POST",zc.canvasHistorySearch(),t)}historyGrep(t){return this.request("POST",zc.canvasHistoryGrep(),t)}historyRead(t){return this.request("GET",aT(zc.canvasHistoryRead(),t))}canvasSnapshot(){return this.request("GET",zc.canvasSnapshot())}canvasRoster(){return this.request("GET",zc.canvasRoster())}prune(t){return this.request("POST",zc.canvasPrune(),t)}rebuildIndex(){return this.request("POST",zc.canvasRebuildIndex(),{})}async request(t,r,i){return _Oi(await this.send(t,r,i))}async send(t,r,i,o){try{return await this.transport(t,r,i,o)}catch(a){if(this.isColdSocketError(a))return await this.handleColdSocket(),await this.transport(t,r,i,o);if(this.isHandoverHangup(a))return await this.rideOutHandover(t,r,i,o);throw a3e(a)}}nodePath(t){if(!s3e(t))throw new Qh(400,"invalid_node_id",`invalid node id: ${JSON.stringify(t)}`);return t}interactionPath(t){if(!s3e(t))throw new Qh(400,"invalid_ticket_id",`invalid interaction ticket id: ${JSON.stringify(t)}`);return t}jobPath(t){if(!nTr(t))throw new Qh(400,"invalid_job_id",`invalid background job id: ${JSON.stringify(t)}`);return t}cronPath(t){if(!iTr(t))throw new Qh(400,"invalid_cron_id",`invalid cron id: ${JSON.stringify(t)}`);return t}ticketId(t){if(!/^[a-f0-9]{64}$/.test(t))throw new TypeError(`invalid inbox ticket id: ${JSON.stringify(t)}`);return t}reviewPath(t){if(!s3e(t))throw new Qh(400,"invalid_review_id",`invalid review id: ${JSON.stringify(t)}`);return t}commentPath(t){if(!/^[a-f0-9]{32}$/.test(t))throw new Qh(400,"invalid_comment_id",`invalid comment id: ${JSON.stringify(t)}`);return t}transport(t,r,i,o){let u=this.baseUrl?.protocol==="https:"?lOi:cOi,p=i===void 0?void 0:JSON.stringify(i),f={accept:"application/json",...this.headers,...o};p!==void 0&&(f["content-type"]="application/json",f["content-length"]=String(Buffer.byteLength(p)));let _={method:t,path:r,headers:f,timeout:this.timeoutMs};return this.socketPath!==void 0?_.socketPath=this.socketPath:this.baseUrl!==void 0&&(_.protocol=this.baseUrl.protocol,_.hostname=this.baseUrl.hostname,this.baseUrl.port!==""&&(_.port=this.baseUrl.port)),new Promise((m,g)=>{let E=u(_,v=>{let T=[];v.on("data",C=>T.push(C)),v.on("end",()=>{let C={};for(let[I,N]of Object.entries(v.headers))N!==void 0&&(C[I]=Array.isArray(N)?N.join(", "):N);m({status:v.statusCode??0,text:Buffer.concat(T).toString("utf8"),headers:C})}),v.on("error",g)});E.on("error",g),E.on("timeout",()=>{E.destroy(Object.assign(new Error("request timed out"),{code:"ETIMEDOUT"}))}),p!==void 0&&E.write(p),E.end()})}isColdSocketError(t){if(this.socketPath===void 0)return!1;let r=t?.code;return r==="ECONNREFUSED"||r==="ENOENT"}isHandoverHangup(t){if(this.socketPath===void 0)return!1;let r=t?.code;return r==="ECONNRESET"||r==="EPIPE"}async rideOutHandover(t,r,i,o){if(!await this.awaitHandover())throw new Qh(503,"daemon_unavailable",`crtrd went away mid-request and did not come back within ${this.coldStartPollWindowMs}ms.`);if(t!=="GET"&&t!=="HEAD")throw new Qh(503,"daemon_restarting",`crtrd handed over to a new runtime generation mid-request; this ${t} may or may not have been applied.`);try{return await this.transport(t,r,i,o)}catch(a){throw a3e(a)}}async awaitHandover(){let t=Date.now()+this.coldStartPollWindowMs;for(;;){try{let r=await this.transport("GET",zc.healthz());if(r.status>=200&&r.status<300)return!0}catch(r){if(!this.isColdSocketError(r)&&!this.isHandoverHangup(r))throw a3e(r)}if(Date.now()>=t)return!1;await aTr(sTr)}}async handleColdSocket(){if(!this.autostart||this.onColdSocket===void 0)throw new Qh(503,"daemon_unavailable","crtrd is not running and autostart is disabled; run `crtr sys daemon start`.");if(this.coldStartAttempted)throw new Qh(503,"daemon_unavailable","crtrd did not become reachable after autostart.");this.coldStartAttempted=!0,await this.onColdSocket();let t=Date.now()+this.coldStartPollWindowMs;for(;;){try{let r=await this.transport("GET",zc.healthz());if(r.status>=200&&r.status<300)return}catch(r){if(!this.isColdSocketError(r))throw a3e(r)}if(Date.now()>=t){let r=yOi(this.coldStartDiagnostic);throw new Qh(503,"daemon_unavailable",gOi(r))}await aTr(sTr)}}};function aT(e,t){if(t===void 0)return e;let r=new URLSearchParams;for(let[o,a]of Object.entries(t))a!=null&&r.set(o,String(a));let i=r.toString();return i===""?e:`${e}?${i}`}function _Oi(e){let t=e.status>=200&&e.status<300,r=e.text.trim(),i;if(r!=="")try{i=JSON.parse(r)}catch{if(t)return;throw new Qh(e.status,"invalid_response",e.text.slice(0,500))}if(t)return i;throw ASt(i)?new Qh(e.status,i.error.code,i.error.message,i.error.details):new Qh(e.status,"internal",`request failed with status ${e.status}`)}function a3e(e){if(e instanceof Qh)return e;let t=e?.code,r=e instanceof Error?e.message:String(e);return t==="ECONNREFUSED"||t==="ENOENT"?new Qh(503,"daemon_unavailable",`crtrd is not reachable: ${r}`):t==="ETIMEDOUT"?new Qh(504,"request_timeout",`crtrd request timed out: ${r}`):new Qh(503,"transport_error",r)}function aTr(e){return new Promise(t=>setTimeout(t,e))}function gOi(e){let t="crtrd did not start; run `crtr sys daemon start` and check crtrd.err.";return e!==void 0&&e!==""?`${t}
@@ -82,7 +82,7 @@ export class BrokerLimitsPanel {
82
82
  }
83
83
  render(width) {
84
84
  const out = [
85
- truncateToWidth(`${theme.fg("accent", theme.bold("Broker limits"))}${theme.fg("dim", " user scope · defaults 128 / 256")}`, width),
85
+ truncateToWidth(`${theme.fg("accent", theme.bold("Broker limits"))}${theme.fg("dim", " user scope · defaults 16 / 32")}`, width),
86
86
  truncateToWidth(theme.fg("dim", "These bounds govern daemon automatic revive; explicit node revives remain available."), width),
87
87
  "",
88
88
  ];
@@ -91,8 +91,8 @@ export class BrokerLimitsPanel {
91
91
  out.push(truncateToWidth(`${selected ? theme.fg("accent", "▶") : " "} ${padAnsi(selected ? theme.fg("accent", label) : label, 24)} ${input.render(Math.max(8, width - 28))[0] ?? ""}`, width));
92
92
  out.push(truncateToWidth(theme.fg("dim", ` ${description}`), width));
93
93
  };
94
- line(0, "Warning threshold", "Warn when live brokers reach this count. Default: 128.", this.warningInput);
95
- line(1, "Automatic-revive hard cap", "Defer automatic revives at this count. Default: 256.", this.hardCapInput);
94
+ line(0, "Warning threshold", "Warn when live brokers reach this count. Default: 16.", this.warningInput);
95
+ line(1, "Automatic-revive hard cap", "Defer automatic revives at this count. Default: 32.", this.hardCapInput);
96
96
  out.push("");
97
97
  for (const text of wrapText(`Configured limits apply next tick. ${BROKER_LIMIT_OVERRIDE_PRECEDENCE}`, width))
98
98
  out.push(theme.fg("dim", text));
@@ -27,6 +27,7 @@ export interface AttachKit {
27
27
  /** Connect a BrokerClient to a node's running broker, hello, await welcome. */
28
28
  attach(id: string, role: ClientRole, clientId: string, opts?: {
29
29
  snapshotTail?: number;
30
+ attends?: boolean;
30
31
  }): Promise<Attached>;
31
32
  /** Attach (as `role`) and retry until the welcome satisfies `pred`. */
32
33
  attachUntil(id: string, role: ClientRole, clientId: string, pred: (a: Attached) => boolean, label: string): Promise<Attached>;
@@ -70,6 +70,7 @@ export function createAttachKit(getH) {
70
70
  role,
71
71
  client_id: clientId,
72
72
  ...(opts.snapshotTail === undefined ? {} : { snapshot_tail: opts.snapshotTail }),
73
+ ...(opts.attends === undefined ? {} : { attends: opts.attends }),
73
74
  });
74
75
  let welcome;
75
76
  try {
@@ -19,20 +19,23 @@
19
19
  // they belong to the compiled seam tier; neither needs tmux.
20
20
  import { after, before, test } from 'node:test';
21
21
  import assert from 'node:assert/strict';
22
- import { writeFileSync } from 'node:fs';
22
+ import { readFileSync, writeFileSync } from 'node:fs';
23
23
  import { join } from 'node:path';
24
24
  import { appendInbox, readCursor, readInboxSince } from '../../feed/inbox.js';
25
25
  import { registerWarmSpare, subscribe, updateNode } from '../../canvas/index.js';
26
26
  import { isPidAlive } from '../../canvas/pid.js';
27
27
  import { reviveNode } from '../../runtime/revive.js';
28
28
  import { createHarness } from '../helpers/harness.js';
29
+ import { createAttachKit } from '../helpers/broker-clients.js';
29
30
  let h;
30
31
  let root;
32
+ const attach = createAttachKit(() => h);
31
33
  before(async () => {
32
34
  h = await createHarness({ headless: true, sessionPrefix: 'crtr-dormancy' });
33
35
  root = h.spawnRoot('dormancy-release suite root');
34
36
  });
35
37
  after(async () => {
38
+ attach.closeAll();
36
39
  if (h !== undefined)
37
40
  await h.dispose();
38
41
  });
@@ -187,6 +190,39 @@ test('an unattended resident with no live obligation completes on the daemon clo
187
190
  process.env['CRTR_TEST_UNATTENDED_PARK_MS'] = priorParkMs;
188
191
  }
189
192
  });
193
+ test('a non-attending observer does not prevent unattended resident parking', { timeout: 30_000 }, async () => {
194
+ const priorParkMs = process.env['CRTR_TEST_UNATTENDED_PARK_MS'];
195
+ process.env['CRTR_TEST_UNATTENDED_PARK_MS'] = '1500';
196
+ const nodeId = h.fabricateBrokerNode({
197
+ id: 'settled-with-system-observer',
198
+ parent: root,
199
+ lifecycle: 'resident',
200
+ status: 'idle',
201
+ intent: 'idle-release',
202
+ });
203
+ updateNode(nodeId, { launch: { extensions: [], tools: [], systemPrompt: '', env: {} } });
204
+ reviveNode(nodeId, { resume: true });
205
+ const boot = await h.awaitBoot(nodeId);
206
+ await attach.attach(nodeId, 'observer', 'system-observer-test', { attends: false });
207
+ assert.equal(JSON.parse(readFileSync(join(h.home, 'nodes', nodeId, 'job', 'attach.json'), 'utf8')).viewers, 0, 'a non-attending hello is not persisted as human attendance');
208
+ try {
209
+ const seenAt = 12_000;
210
+ await h.tick(seenAt);
211
+ await h.tick(seenAt + 1500);
212
+ await h.waitFor(() => h.node(nodeId)?.status === 'done' && !isPidAlive(boot.pid), {
213
+ timeoutMs: 10_000,
214
+ intervalMs: 20,
215
+ label: 'system-observed unattended completion and broker exit',
216
+ });
217
+ await h.awaitFleetExit(nodeId);
218
+ }
219
+ finally {
220
+ if (priorParkMs === undefined)
221
+ delete process.env['CRTR_TEST_UNATTENDED_PARK_MS'];
222
+ else
223
+ process.env['CRTR_TEST_UNATTENDED_PARK_MS'] = priorParkMs;
224
+ }
225
+ });
190
226
  test('a connected broker viewer keeps an obligation-free resident live', { timeout: 30_000 }, async () => {
191
227
  const priorParkMs = process.env['CRTR_TEST_UNATTENDED_PARK_MS'];
192
228
  process.env['CRTR_TEST_UNATTENDED_PARK_MS'] = '1500';
@@ -1,8 +1,9 @@
1
1
  import type { Socket } from 'node:net';
2
2
  import { FrameDecoder, type BrokerSnapshot, type BrokerToClient, type ClientRole } from '../broker-protocol.js';
3
- /** True when the live broker has at least one helloed terminal or web viewer.
4
- * Callers establish broker liveness separately because a crash can leave the
5
- * last persisted count behind. */
3
+ /** True when the live broker has at least one client that declared itself to
4
+ * be attending the conversation. A system observer may read the same stream
5
+ * without keeping an otherwise idle broker alive. Callers establish broker
6
+ * liveness separately because a crash can leave the last persisted count behind. */
6
7
  export declare function hasAttachedBrokerViewers(nodeId: string): boolean;
7
8
  export interface BrokerClient {
8
9
  id: string;
@@ -10,6 +11,8 @@ export interface BrokerClient {
10
11
  socket: Socket;
11
12
  decoder: FrameDecoder;
12
13
  helloed: boolean;
14
+ /** Fixed by the first hello; absent `attends` remains backward-compatible true. */
15
+ attends: boolean;
13
16
  snapshotTail: number | undefined;
14
17
  pendingBytes: number;
15
18
  queuedFrames: number;
@@ -5,9 +5,10 @@ import { encodeFrame, FrameDecoder, BROKER_READ_CAPS, } from '../broker-protocol
5
5
  /** Per-viewer outbound high-water mark. Slow viewers are shed rather than allowed to backpressure the shared engine indefinitely. */
6
6
  const MAX_QUEUED_FRAMES = 1000;
7
7
  const MAX_PENDING_BYTES = 32 * 1024 * 1024;
8
- /** True when the live broker has at least one helloed terminal or web viewer.
9
- * Callers establish broker liveness separately because a crash can leave the
10
- * last persisted count behind. */
8
+ /** True when the live broker has at least one client that declared itself to
9
+ * be attending the conversation. A system observer may read the same stream
10
+ * without keeping an otherwise idle broker alive. Callers establish broker
11
+ * liveness separately because a crash can leave the last persisted count behind. */
11
12
  export function hasAttachedBrokerViewers(nodeId) {
12
13
  try {
13
14
  const record = JSON.parse(readFileSync(`${jobDir(nodeId)}/attach.json`, 'utf8'));
@@ -36,6 +37,7 @@ export class BrokerClientRegistry {
36
37
  socket,
37
38
  decoder: new FrameDecoder(BROKER_READ_CAPS),
38
39
  helloed: false,
40
+ attends: true,
39
41
  snapshotTail: undefined,
40
42
  pendingBytes: 0,
41
43
  queuedFrames: 0,
@@ -58,7 +60,7 @@ export class BrokerClientRegistry {
58
60
  try {
59
61
  let viewers = 0;
60
62
  for (const client of this.clients)
61
- if (client.helloed)
63
+ if (client.helloed && client.attends)
62
64
  viewers += 1;
63
65
  const dir = jobDir(this.nodeId);
64
66
  if (!existsSync(dir))
@@ -757,6 +757,7 @@ export function createFrameDispatchContext(deps) {
757
757
  if (firstHello) {
758
758
  client.helloed = true;
759
759
  client.role = frame.role === 'controller' ? 'controller' : 'observer';
760
+ client.attends = frame.attends !== false;
760
761
  }
761
762
  sendWelcome(client);
762
763
  if (firstHello)
@@ -82,6 +82,10 @@ export interface HelloFrame {
82
82
  type: 'hello';
83
83
  role: ClientRole;
84
84
  client_id: string;
85
+ /** Whether this socket represents a person attending the conversation. Defaults
86
+ * true for backward compatibility; system observers set false without changing
87
+ * their read-only `role`. */
88
+ attends?: boolean;
85
89
  /** Per-attach welcome transcript bound; absent or invalid keeps the full history. */
86
90
  snapshot_tail?: number;
87
91
  /** Terminal geometry of a tmux-pane viewer; absent for a headless client. */
package/dist/types.js CHANGED
@@ -77,7 +77,11 @@ export function defaultScopeConfig() {
77
77
  auto_update: { crtr: 'notify', content: 'notify', interval_hours: 24 },
78
78
  max_panes_per_window: DEFAULT_MAX_PANES_PER_WINDOW,
79
79
  auto_open_child_viewers: true,
80
- brokerThresholds: { warning: 128, automaticReviveCap: 256 },
80
+ // Every live broker is a whole pi engine. 256 of them is not a bound any
81
+ // real host survives — an 8 GB guest dies around a few dozen — so these are
82
+ // sized as a backstop that actually engages before the machine does.
83
+ // Override per host with CRTR_MAX_LIVE_BROKERS / CRTR_WARN_LIVE_BROKERS.
84
+ brokerThresholds: { warning: 16, automaticReviveCap: 32 },
81
85
  completion_bell: true,
82
86
  working_gerunds: [...DEFAULT_WORKING_GERUNDS],
83
87
  whip_mode: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@north-light/crouter",
3
- "version": "0.3.219",
3
+ "version": "0.3.220",
4
4
  "description": "crtr — agent runtime with memory, plugins, and marketplaces",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/runtime.lock.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@north-light/crouter",
3
- "version": "0.3.219",
3
+ "version": "0.3.220",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@north-light/crouter",
9
- "version": "0.3.219",
9
+ "version": "0.3.220",
10
10
  "hasInstallScript": true,
11
11
  "license": "MIT",
12
12
  "dependencies": {