pi-cowboy 0.22.2 → 0.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -1
- package/dist/agents/agent-assets.d.ts +11 -2
- package/dist/agents/agent-cleanup.d.ts +6 -22
- package/dist/agents/agent-environment.d.ts +6 -0
- package/dist/agents/agent-host.d.ts +3 -3
- package/dist/agents/agent-manager.d.ts +5 -1
- package/dist/agents/batch.d.ts +2 -1
- package/dist/agents/cleanup-policy.d.ts +15 -16
- package/dist/agents/handover.d.ts +71 -0
- package/dist/agents/harness/claude/session-export.d.ts +7 -0
- package/dist/agents/harness/claude/staging.d.ts +9 -1
- package/dist/agents/harness/codex-session-schema.d.ts +90 -0
- package/dist/agents/harness/codex-session.d.ts +17 -0
- package/dist/agents/harness/opencode/session-export.d.ts +39 -0
- package/dist/agents/harness/pi-compatible.d.ts +3 -1
- package/dist/agents/harness/pi-session.d.ts +12 -0
- package/dist/agents/harness/pi-store.d.ts +8 -0
- package/dist/agents/harness/pi.d.ts +2 -0
- package/dist/agents/harness/pig-store.d.ts +7 -0
- package/dist/agents/harness/stop-keys.d.ts +2 -0
- package/dist/agents/harness.d.ts +53 -0
- package/dist/agents/run-state.d.ts +1 -0
- package/dist/agents/schemas/handover.schema.d.ts +8 -0
- package/dist/agents/subagent-session.d.ts +8 -1
- package/dist/agents/tool-cleanup.d.ts +16 -2
- package/dist/agents/tool-execution.d.ts +21 -2
- package/dist/agents/tool-handover.d.ts +28 -0
- package/dist/agents/tool-merge.d.ts +18 -2
- package/dist/agents/tool-renderer.d.ts +21 -0
- package/dist/agents/tool-result.d.ts +9 -2
- package/dist/agents/tool-steer.d.ts +17 -2
- package/dist/{chunk-F526OOT6.js → chunk-277WT5MT.js} +2 -2
- package/dist/chunk-J5TU3AFX.js +2 -0
- package/dist/chunk-M42XWVYW.js +45 -0
- package/dist/{chunk-WL3QYM2F.js → chunk-MZROKRT4.js} +2 -2
- package/dist/chunk-S4BS2R6G.js +26 -0
- package/dist/chunk-TFQCH2TO.js +14 -0
- package/dist/config/config-store.d.ts +1 -0
- package/dist/config/layered-config.d.ts +2 -3
- package/dist/cowboy-tools.d.ts +13 -0
- package/dist/dev-mode.d.ts +1 -0
- package/dist/index.js +18 -18
- package/dist/infrastructure/herdr/agent-exit.d.ts +12 -0
- package/dist/infrastructure/herdr/agents.d.ts +0 -1
- package/dist/infrastructure/herdr/index.d.ts +1 -1
- package/dist/{menu-worktree-command-SXLBWK4D.js → menu-worktree-command-THJ3VSWU.js} +2 -2
- package/dist/{menus-Q3TEDIPV.js → menus-KXKDXZRN.js} +3 -3
- package/dist/{model-picker-IIXU4GJP.js → model-picker-FMMQY4KI.js} +2 -2
- package/dist/models/model-precedence.d.ts +1 -0
- package/dist/models/model-request-types.d.ts +8 -2
- package/dist/plugin/index.d.ts +1 -1
- package/dist/plugin/index.js +1 -1
- package/dist/predicates.d.ts +1 -0
- package/dist/registration.d.ts +3 -8
- package/dist/spawn/sandbox.d.ts +22 -0
- package/dist/subagent/result-artifacts.d.ts +1 -0
- package/dist/subagent/supervisor.d.ts +2 -0
- package/dist/types.d.ts +11 -0
- package/package.json +2 -2
- package/dist/chunk-254PTGN5.js +0 -2
- package/dist/chunk-CTBFJWEE.js +0 -10
- package/dist/chunk-KMXT7XW7.js +0 -15
- package/dist/chunk-PDV4AFO7.js +0 -24
- package/dist/infrastructure/herdr/agent-stopper.d.ts +0 -14
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{e as Re,f as Gt,g as Je,j as Bt,l as Zt,m as Jt}from"./chunk-TFQCH2TO.js";import{a as Xt,b as H}from"./chunk-277WT5MT.js";import{H as Nt,I as Vt,K as Wt,L as Kt,O as ne,P as zt,S as qt,U as Yt,i as Ht,j as Ft,v as B,w as Pe,x as _t,z as Dt}from"./chunk-S4BS2R6G.js";import{a as pe,b as V,c as re,d as oe,e as je,f as fe,g as U,h as He,i as Qe,j as Fe,k as we,l as _,m as Ut,n as X,o as Q,p as _e,q as Te}from"./chunk-MZROKRT4.js";import{Aa as xe,Da as jt,Ea as Ee,G as Ye,H as Z,L as Tt,M as Ot,N as Mt,Na as J,Q as Ae,R as Ce,S as Le,T as It,U as At,V as Lt,W as $t,X as xt,Y as Et,a as pt,aa as $e,b as ft,fa as Xe,ha as se,ia as me,ja as Pt,ka as ae,l as qe,la as $,m as ke,o as gt,p as ht,qa as Rt,r as yt,s as vt,sa as Ze,t as bt,va as Y,ya as le}from"./chunk-M42XWVYW.js";import{a as t,d as de,e as kt,f as Se,g as St,k as Ct,l as te,m as wt}from"./chunk-J5TU3AFX.js";import{SettingsList as Gn}from"@earendil-works/pi-tui";import{SettingsManager as Un}from"@earendil-works/pi-coding-agent";async function Qt(e,n){return Un.create(e,n??pt()).getDefaultThinkingLevel()}t(Qt,"getPiDefaultThinkingLevel");import{SettingsList as tr}from"@earendil-works/pi-tui";var zn={queued:{icon:"\u25C6",color:"accent"},spawned:{icon:"\u25C8",color:"accent"},completed:{icon:"\u2713",color:"success"},error:{icon:"\u2717",color:"error"},stopped:{icon:"\u25A0",color:"dim"}};function en(e,n){if(e===void 0)return n.fg("muted","\u25B8");let o=zn[e];return n.fg(o.color,o.icon)}t(en,"statusIcon");function et(e){if(!Number.isFinite(e)||e<1e3)return"<1s";let n=Math.floor(e/1e3),o=Math.floor(n/3600),r=Math.floor(n%3600/60),s=n%60,i=[];return o>0&&i.push(`${o}h`),r>0&&i.push(`${r}m`),(s>0||i.length===0)&&i.push(`${s}s`),i.join(" ")}t(et,"formatMs");function tn(e){let n=B(e);return n?.displayName??n?.name??"Agent"}t(tn,"getDisplayName");function ie(e){return`${e.fg("accent","\u2022")} `}t(ie,"agentBulletPrefix");function nn(e,n){return e.length<=n?e:"..."+e.slice(e.length-n+3)}t(nn,"truncatePath");function De(e,n=""){return`${e} slot${e===1?"":"s"}${n}`}t(De,"formatSlotLimit");function rn(e){let{types:n,agentConfigs:o,config:r,sessionOverrides:s,harnessDefaultFor:i,harnessFamilyFor:l,hasProjectModelKey:a,parentModelId:d}=e,c=new Map;for(let u of n){let g=o[u],{model:v,source:h}=$t({subagentType:u,harnessFamily:l(u),agentConfig:g,config:{agent:r},harnessDefault:i(u),parentModelId:d,sessionOverrides:s});if(!tt(s,r,u,e.sessionThinking))continue;let k=h==="session-per-type"||h==="session-default"?"[session]":a(u)?"[project]":"",{level:b,source:T}=nt({type:u,agentConfig:g,harnessFamily:l(u),config:r,harnessDefault:e.harnessDefaultThinkingFor(u),parentThinking:e.parentThinking??void 0,sessionThinking:e.sessionThinking}),C=T==="session-per-type"?" [session]":T==="parent"?" [parent]":T==="config-per-type"&&e.hasProjectThinkingKey(u)?" [project]":"",L=c.get(v)??[];L.push({type:u,thinking:b,thinkingTag:C,tag:k}),c.set(v,L)}return[...c.entries()].sort((u,g)=>u[0]===g[0]?0:u[0]===null?-1:g[0]===null?1:u[0]<g[0]?-1:1).map(([u,g])=>({modelId:u,rows:g}))}t(rn,"buildModelGroups");function tt(e,n,o,r){return e[o]!=null||typeof n[o]=="string"||r[o]!=null||typeof n.thinking?.[o]=="string"}t(tt,"hasExplicitPerTypeOverride");function nt(e){let n=Et({subagentType:e.type,harnessFamily:e.harnessFamily,agentConfig:e.agentConfig,config:{agent:e.config},harnessDefault:e.harnessDefault,parentThinking:e.parentThinking,sessionThinking:e.sessionThinking});return n!==void 0?{level:n.value,source:n.source}:{level:e.harnessFamily==="pi"?xt:null,source:void 0}}t(nt,"displayedThinking");import{SettingsList as Xn}from"@earendil-works/pi-tui";import{matchesKey as Oe,SelectList as qn,truncateToWidth as Yn}from"@earendil-works/pi-tui";function on(e){return(n,o)=>{let r=[{value:"Yes",label:"Yes",description:e.message},{value:"No",label:"No",description:e.message}],s=X(new qn(r,5,Q(e.theme)));return s.onSelect=i=>{i.value==="Yes"?(e.onConfirm(),o("Yes")):o()},s.onCancel=()=>o(),s}}t(on,"createConfirmSubmenu");function sn(e){return oe({invalidate(){},render(o){let r=Math.max(0,o-4),s=t(l=>` ${Yn(l,r,"...",!0)}`,"line"),i=[s(e.theme.bold(e.message))];if(e.detail)for(let l of e.detail.split(`
|
|
2
2
|
`))i.push(s(l));return i.push(s(e.theme.fg("dim","Y yes \xB7 N no"))),i},handleInput(o){if(Oe(o,"y")||Oe(o,"shift+y")){e.onYes();return}(Oe(o,"n")||Oe(o,"shift+n")||Oe(o,"escape"))&&e.onNo()}})}t(sn,"createKeyConfirm");var Zn={session:{label:"Session",setDescription:"Not saved",clearDescription:"Removes from the session"},global:{label:"Global",setDescription:"Saves to the global config file",clearDescription:"Removes from the global config file"},project:{label:"Project",setDescription:"Saves to the project config file",clearDescription:"Removes from the project config file"}};function rt(e,n){let o=Zn[e];return{id:e,label:o.label,currentValue:"",description:n?o.clearDescription:o.setDescription}}t(rt,"levelItem");function ge(e){let n=[];return e.offered.session&&n.push(rt("session",e.clearMode===!0)),e.offered.global&&n.push(rt("global",e.clearMode===!0)),e.offered.project&&n.push(rt("project",e.clearMode===!0)),e.includeClear&&n.push({id:"clear",label:"Clear...",currentValue:""}),e.includeAll&&n.push({id:"all",label:"All levels",currentValue:""}),n}t(ge,"buildLevelItems");function ee(e){return(n,o)=>{let r=e.items.map(i=>({...i,submenu:t((l,a)=>{let d=e.onPick(i.id,a,()=>o());return d||(a(i.id),re)},"submenu")})),s=X(new Xn(r,r.length,_(e.theme),(i,l)=>o(l),()=>o()));return oe(s)}}t(ee,"createLevelPickerSubmenu");function Ne(e){let n=e.availableLevels,o=e.includeAll===!0,r=(e.includeSession??!0)&&(!n||n.session),s=!n||n.global,i=e.projectOffered&&(!n||n.project),l=[r,s,i].filter(Boolean).length,a=e.showClear===!0?e.onClear:void 0,d=ge({offered:{session:r,global:s,project:i},clearMode:o,includeClear:a!==void 0,includeAll:n?l>=2:e.includeAll===!0});return ee({theme:e.theme,items:d,onPick:t((c,u)=>c==="clear"?he({theme:e.theme,projectOffered:e.projectOffered,includeSession:e.includeSession??!0,availableLevels:e.availableLevels,onClear:t(g=>a?.(g),"onClear")})("",u):e.onPick(c,u),"onPick")})}t(Ne,"createTargetSelectSubmenu");function he(e){return Ne({theme:e.theme,projectOffered:e.projectOffered,includeSession:e.includeSession??!0,includeAll:!0,availableLevels:e.availableLevels,onPick:t(n=>e.onClear(n),"onPick")})}t(he,"createClearPickerSubmenu");function Ve(e){return(n,o)=>Ne({theme:e.theme,projectOffered:e.projectOffered,includeAll:!0,availableLevels:e.availableLevels,onPick:t((r,s)=>on({message:e.message(r),theme:e.theme,onConfirm:t(()=>e.onConfirm(r),"onConfirm")})(n,s),"onPick")})(n,o)}t(Ve,"createClearAllSubmenu");import{Input as an}from"@earendil-works/pi-tui";function ot(e,n){let o=n.min??1,r=t(i=>i===0?"\u2265 0":`\u2265 ${i}`,"fmtLabel"),s=t(i=>e.ui.notify(i,"error"),"onError");return(i,l)=>{let a=new an;return a.setValue(i),a.onSubmit=d=>{let c=d.trim();if(!c||/^unlimited$/i.test(c))switch(n.kind){case"required":s(`Invalid value \u2014 must be a number ${r(o)}`);return;case"defaulted":n.onValid?.(n.default),l(String(n.default));return;case"optional":n.onEmpty?.(),l("");return}let u=Ut(c,o);if(u===void 0){s(`Invalid value \u2014 must be a number ${r(o)}`);return}n.onValid?.(u),l(String(u))},a.onEscape=()=>l(),a}}t(ot,"createNumericSubmenu");function ye(e,n){return(o,r)=>{let s=new an;return s.setValue(o),s.onSubmit=i=>{let l=i.trim();if(!l){if(n?.required){e.ui.notify("Cannot be empty","error");return}r();return}r(l)},s.onEscape=()=>r(),s}}t(ye,"createInputSubmenu");var ln="__custom__",ve="__none__";function Jn(e,n){let o=[];if(e.kind!=="none"){for(let r of e.levels)o.push({id:r,label:r==="off"?"Off":r.charAt(0).toUpperCase()+r.slice(1),currentValue:n===r?"(current)":""});e.kind==="advisory"&&o.push({id:ln,label:"Custom token...",currentValue:"",description:"A level or variant this harness advertises beyond its own list."})}return o.push({id:ve,label:"None",currentValue:n===null?"(current)":"",description:"Use the template, configured default, or parent session's level."}),o}t(Jn,"valueItems");function cn(e){return ee({theme:e.theme,items:Jn(e.offering,e.current),onPick:t((n,o)=>{if(n===ln)return ye(e.ctx)(e.current??"",r=>{if(r===void 0){o();return}e.onPick(r),o(r)});e.onPick(n===ve?null:n)},"onPick")})}t(cn,"createThinkingValuePicker");function un(e){let n=e.currentModel??null,o=e.showClear===!0?e.onClear:void 0;return ee({theme:e.theme,items:ge({offered:{session:!0,global:!0,project:e.projectOffered},includeClear:o!==void 0}),onPick:t((r,s,i)=>{if(r==="clear")return he({theme:e.theme,projectOffered:e.projectOffered,availableLevels:e.availableLevels,onClear:t(a=>o?.(a),"onClear")})("",s);let l=r;return new pe(Qe(e.modelOptions,n,e.mergedModels),n,{onSelect:t(a=>{e.onSet(l,a),a==null?i():s(a)},"onSelect"),onCancel:t(()=>s(),"onCancel")},e.theme)},"onPick")})}t(un,"createModelSelectSubmenu");function dn(e){let n=e.currentModel??null;return ee({theme:e.theme,items:ge({offered:{session:!0,global:!0,project:e.projectOffered},includeClear:e.showClear}),onPick:t((o,r,s)=>{if(o==="clear")return he({theme:e.theme,projectOffered:e.projectOffered,availableLevels:e.availableLevels,onClear:t(d=>e.onClear(d),"onClear")})("",r);let i=o,l,a=new pe(Qe(e.modelOptions,n,e.mergedModels),n,{onSelect:t(d=>{if(d==null){e.onClear(i),s();return}let c=e.offeringFor(d);if(c.kind==="none"){e.onSet(i,d,null),r(d);return}l.activate(cn({theme:e.theme,ctx:e.ctx,offering:c,current:e.currentThinking,onPick:t(u=>e.onSet(i,d,u),"onPick")})("",r))},"onSelect"),onCancel:t(()=>r(),"onCancel")},e.theme);return l=new je(a),l},"onPick")})}t(dn,"createModelThinkingSubmenu");import{getSupportedThinkingLevels as Qn}from"@earendil-works/pi-ai";function We(e){let{harnessId:n,modelKey:o,entries:r,piModel:s}=e;if(te(n))return s===void 0?{kind:"advisory",levels:[]}:s.reasoning?{kind:"closed",levels:Qn(s)}:{kind:"none"};if(o==="")return er(r);let i=r.find(l=>l.key===o);return i===void 0?{kind:"advisory",levels:[]}:i.thinkingLevels.kind==="advisory"?{kind:"advisory",levels:i.thinkingLevels.levels}:i.thinkingLevels.levels.length===0?{kind:"none"}:{kind:"closed",levels:i.thinkingLevels.levels}}t(We,"thinkingOfferingFor");function er(e){let n=[...new Set(e.flatMap(r=>r.thinkingLevels.levels))],o=e.length===0||e.some(r=>r.thinkingLevels.kind==="advisory");return n.length===0&&!o?{kind:"none"}:o?{kind:"advisory",levels:n}:{kind:"closed",levels:n}}t(er,"unionThinkingOffering");function mn(e){return We({harnessId:e.harnessId,modelKey:e.modelKey??"",entries:e.entries.get(e.harnessId)??[],piModel:Se(e.modelKey??"",e.registry,e.parentModel)})}t(mn,"thinkingOfferingForModel");function Ke(e){let n=e.model??"(none)",o=e.thinking??"(none)",r=e.model?e.modelTag:"",s=e.thinking?e.thinkingTag:"";return r!==""&&r===s?`${n} \xB7 ${o}${s}`:`${n}${r} \xB7 ${o}${s}`}t(Ke,"pairedRow");function Ge(e,n){return e?" [session]":n?" [project]":""}t(Ge,"layerTag");function it(e,n){return n===null?"":Ge(e.session,e.project)}t(it,"thinkingTagOf");function pn(e,n,o,r){if(o===null){e.mutate.agent.clearHarnessDefaultThinking(n,r);return}r!=="session"&&te(n)&&!Tt.safeParse(o).success||e.mutate.agent.setHarnessDefaultThinking(n,o,r)}t(pn,"writeHarnessDefaultThinking");function nr(e,n,o,r){o===null?e.mutate.agent.clearThinkingOverride(n,r):e.mutate.agent.setThinkingOverride(n,o,r)}t(nr,"writeTypeThinking");function rr(e){return Y().runnable(e).filter(n=>!te(n))}t(rr,"harnessDefaultRowIds");function or(e){let n=rr(le());return oe(ir(e,n))}t(or,"buildModelSettingsScreen");function ir(e,n){let{ctx:o,store:r,theme:s,harnessModelOptions:i,piDefaultThinking:l,close:a}=e,d,c=t(v=>{let h=[],k=r.isProjectWritable,b=t((f,E)=>o.ui.notify(f,E),"notify"),T=me(),C=T.model??o.model,L=C?`${C.provider}/${C.id}`:null,O=T.thinkingLevel??null,P=r.agentConfigSnapshot(),W=Fe(P),R=t(()=>{d?.(c(v))},"refresh"),j=t(f=>E=>mn({harnessId:f,modelKey:E,entries:i,registry:T.modelRegistry,parentModel:C}),"offeringFor"),D=t(f=>{let E={session:f.modelLevels.session||f.thinkingLevels.session,global:f.modelLevels.global||f.thinkingLevels.global,project:f.modelLevels.project||f.thinkingLevels.project};return dn({modelOptions:f.modelOptions,mergedModels:f.mergedModels,projectOffered:k,theme:v,ctx:o,currentModel:f.model,currentThinking:f.thinking,showClear:E.session||E.global||E.project,availableLevels:E,offeringFor:j(f.harnessId),onSet:t((M,G,N)=>{f.write(M,G,N),b(`${f.label} set to ${G} \xB7 ${N??"(none)"} (${M})`,"info")},"onSet"),onClear:t(M=>{f.clear(M),b(`${f.label} cleared (${M})`,"info"),R()},"onClear")})},"pairSubmenu"),K=P.default,p=r.modelOverrideLevels("default"),m=r.harnessDefaultThinkingLevels("pi"),y=r.defaultThinkingForHarness("pi"),S=r.sessionDefaultModel??K;h.push({id:"defaultModel",label:"Pi Default Model",currentValue:Ke({model:S,modelTag:Ge(p.session,r.hasProjectModelKey("default")),thinking:y,thinkingTag:it(m,y)}),description:"Default model and thinking level applied when no session, per-type, or template override is set.",submenu:D({label:"Pi Default Model",harnessId:"pi",modelOptions:Z(i,"pi"),mergedModels:we("pi",W),model:S,thinking:y,modelLevels:p,thinkingLevels:m,write:t((f,E,M)=>{r.mutate.agent.setModelOverride("default",E,f),pn(r,"pi",M,f)},"write"),clear:t(f=>{r.mutate.agent.clearModelOverride("default",f),r.mutate.agent.clearHarnessDefaultThinking("pi",f)},"clear")})});for(let f of n){let E=`${Y().displayName(f)} Default Model`,M=r.harnessDefaultModelLevels(f),G=r.harnessDefaultThinkingLevels(f),N=r.defaultThinkingForHarness(f);h.push({id:`harness:${f}`,label:E,currentValue:Ke({model:r.defaultModelForHarness(f),modelTag:Ge(M.session,M.project),thinking:N,thinkingTag:it(G,N)}),description:`Default model and thinking level applied to agents launched under ${f} when no session, per-type, or template override is set.`,submenu:D({label:E,harnessId:f,modelOptions:Z(i,f),mergedModels:[],model:r.defaultModelForHarness(f),thinking:N,modelLevels:M,thinkingLevels:G,write:t((q,ze,Bn)=>{r.mutate.agent.setHarnessDefaultModel(f,ze,q),pn(r,f,Bn,q)},"write"),clear:t(q=>{r.mutate.agent.clearHarnessDefaultModel(f,q),r.mutate.agent.clearHarnessDefaultThinking(f,q)},"clear")})})}let w=_t(),I={default:r.sessionDefaultModel},A={};for(let f of w)I[f]=r.sessionModelOverride(f),A[f]=B(f);let x={};for(let f of w)x[f]=r.sessionThinkingOverride(f);let F=rn({types:w,agentConfigs:A,config:P,sessionOverrides:I,sessionThinking:x,harnessDefaultFor:t(f=>r.defaultModelForHarness(ne(f)),"harnessDefaultFor"),harnessDefaultThinkingFor:t(f=>{let E=ne(f),M=r.defaultThinkingForHarness(E);return M!==null?M:te(E)&&O===null?l??null:null},"harnessDefaultThinkingFor"),harnessFamilyFor:t(f=>Ye(ne(f)),"harnessFamilyFor"),hasProjectModelKey:t(f=>r.hasProjectModelKey(f),"hasProjectModelKey"),hasProjectThinkingKey:t(f=>r.hasProjectThinkingKey(f),"hasProjectThinkingKey"),parentModelId:L,parentThinking:O}),z=t((f,E,M,G)=>D({label:f,harnessId:E,modelOptions:Z(i,E),mergedModels:we(E,W),model:M,thinking:G,modelLevels:r.modelOverrideLevels(f),thinkingLevels:r.thinkingOverrideLevels(f),write:t((N,q,ze)=>{r.mutate.agent.setModelOverride(f,q,N),nr(r,f,ze,N)},"write"),clear:t(N=>{r.mutate.agent.clearModelOverride(f,N),r.mutate.agent.clearThinkingOverride(f,N)},"clear")}),"typeSubmenu");for(let f of F){h.push({id:U,label:" ",currentValue:""}),h.push(fe(v,f.modelId??"(no model)"));let E=Math.max(...f.rows.map(M=>`${M.thinking??"(none)"}${M.thinkingTag}`.length));for(let M of f.rows){let G=ne(M.type),N=`${M.thinking??"(none)"}${M.thinkingTag}`,q=M.thinking!==null&&M.thinkingTag.trim()===M.tag.trim()?"":M.tag;h.push({id:`type:${M.type}`,label:`${ie(v)}${M.type}`,currentValue:`${N.padEnd(E)} ${q}`.trimEnd(),description:`Model and thinking level for the ${M.type} agent type.`,submenu:z(M.type,G,f.modelId,M.thinking)})}}h.push({id:U,label:"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500",currentValue:"\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"});let Me=w.filter(f=>!tt(I,P,f,x));Me.length>0&&h.push({id:"overrideType",label:"Override another type...",currentValue:"",description:"Configure model and thinking level overrides for an agent type currently using inherited defaults.",submenu:t((f,E)=>_e(Me.map(M=>({value:M,label:`${ie(v)}${M}`})),{onSelect:t(M=>{if(M==null)return E();let G=ne(M),N=B(M),q=r.modelFor(M,L,N,G);return z(M,G,q,nt({type:M,agentConfig:N,harnessFamily:Ye(G),config:P,harnessDefault:r.defaultThinkingForHarness(G),parentThinking:O??void 0,sessionThinking:x}).level)("",E)},"onSelect"),onCancel:t(()=>E(),"onCancel")},v),"submenu")}),h.push({id:U,label:" ",currentValue:""});let mt=r.modelSettingsLevels(),Ie={...mt,project:mt.project&&k};return(Ie.session||Ie.global||Ie.project)&&h.push({id:"clearAll",label:"Clear all model and thinking overrides...",currentValue:"",description:"Remove model and thinking level overrides across a selected configuration layer (session, global, project, or all).",submenu:Ve({theme:v,projectOffered:k,availableLevels:Ie,message:t(f=>`Clear all model and thinking overrides at the ${f} level?`,"message"),onConfirm:t(f=>{r.mutate.agent.clearAllModelOverrides(f),b(`Model and thinking overrides cleared (${f})`,"info")},"onConfirm")})}),h},"buildItems"),u=new tr(c(s),15,_(s),(v,h)=>d?.(c(s)),a),g=new H(u,{title:"Model Settings",theme:s,onCancel:a,onRebuild:t(v=>{d=v},"onRebuild")});return oe(g)}t(ir,"buildModelSettingsList");function fn(e){let{ctx:n,store:o,theme:r,harnessModelOptions:s,piDefaultThinking:i}=e,l=t(()=>{let a=o.modelOverrideLevels("default"),d=o.harnessDefaultThinkingLevels("pi"),c=o.defaultThinkingForHarness("pi");return Ke({model:o.sessionDefaultModel??o.agentConfigSnapshot().default,modelTag:Ge(a.session,o.hasProjectModelKey("default")),thinking:c,thinkingTag:it(d,c)})},"defaultDisplay");return{id:"modelOverrides",label:"Model overrides",currentValue:l(),description:"Pi's default model and thinking level, plus per-harness and per-type overrides; opens the model settings screen.",submenu:t((a,d)=>or({ctx:n,store:o,theme:r,harnessModelOptions:s,piDefaultThinking:i,close:t(()=>d(l()),"close")}),"submenu")}}t(fn,"buildModelOverridesRow");import{SettingsList as gn}from"@earendil-works/pi-tui";function hn(e,n){return e==="pi"?n:`${e}:${n}`}t(hn,"qualifiedKey");function Be(e){let n=new Map;for(let o of e){let r=$e(o)?.harness??"pi",s=n.get(r);s?s.push(o):n.set(r,[o])}return n}t(Be,"groupKeysByHarness");function ar(e,n){let o=[...e];for(let r of n.keys())o.includes(r)||o.push(r);return o}t(ar,"sectionHarnesses");async function yn(e,n){let o=[...n.keys()],r=t((i,l)=>{let a=[],d=i.isProjectWritable,c=t((p,m,y)=>m==="default"?p.default!==void 0:y===void 0?!1:m==="harnesses"?p.harnesses?.[y]!==void 0:p[m]?.[y]!==void 0,"layerHas"),u=t((p,m)=>({session:c(i.sessionConcurrency,p,m),global:c(i.globalConcurrency,p,m),project:c(i.projectConcurrency,p,m)}),"entryLevels"),g=t((p,m)=>c(i.sessionConcurrency,p,m)?" [session]":c(i.projectConcurrency,p,m)?" [project]":"","limitTag"),v=t((p,m)=>(y,S)=>Ne({theme:l,projectOffered:d,onPick:t((w,I)=>ot(e,{kind:"optional",min:1,onValid:t(A=>m(w,A),"onValid")})(p,I),"onPick")})(y,S),"targetThenValueSubmenu"),h=t((p,m,y,S)=>(w,I)=>{let A=ge({offered:{session:!0,global:!0,project:d},includeClear:S.session||S.global||S.project});return ee({theme:l,items:A,onPick:t((x,F)=>{if(x==="clear")return he({theme:l,projectOffered:d,availableLevels:S,onClear:y})("",F);let z=x;return ot(e,{kind:"optional",min:1,onValid:t(Me=>m(z,Me),"onValid")})(String(p),F)},"onPick")})(w,I)},"limitSubmenu"),k=t(p=>(m,y)=>{let S=t(()=>p(),"buildFresh"),w,I=X(new gn(S(),15,_(l),(A,x)=>{let F=w,z=S();F.items=z,F.filteredItems=z,F.submenuComponent=null,F.selectedIndex=0},()=>y("closed")));return w=I,He(w),oe(I)},"nestedListSubmenu"),b=t(p=>{let m=$(),y=m.concurrency.harnesses[p],S=Y().displayName(p),w=`Concurrent agents of every model launched under ${p}.`;if(y===void 0)return{id:`harness:${p}`,label:S,currentValue:"unset",description:w,submenu:v("",(A,x)=>{$().mutate.concurrency.setHarness(p,x,A),e.ui.notify(`${p} concurrency set to ${x} (${A})`,"info")})};let I=c(m.sessionConcurrency,"harnesses",p)?" [session]":c(m.projectConcurrency,"harnesses",p)?" [project]":"";return{id:`harness:${p}`,label:S,currentValue:De(y,I),description:w,submenu:h(y,(A,x)=>{$().mutate.concurrency.setHarness(p,x,A),e.ui.notify(`${S} concurrency set to ${x} (${A})`,"info")},A=>{$().mutate.concurrency.removeHarness(p,A),e.ui.notify(`Removed per-harness limit for ${p} (${A})`,"info")},{session:c(m.sessionConcurrency,"harnesses",p),global:c(m.globalConcurrency,"harnesses",p),project:c(m.projectConcurrency,"harnesses",p)})}},"harnessLimitRow"),T=t(()=>{let p=$(),m=[...o];for(let y of Object.keys(p.concurrency.harnesses))y.trim()!==""&&!m.includes(y)&&m.push(y);return m.map(y=>b(y))},"harnessListItems"),C=t(p=>{let m=Z(n,p);return[...new Set(m.map(y=>kt(y)?.provider).filter(y=>y!==void 0))].sort()},"providerOptionsFor"),L=t((p,m)=>{let y=$(),S=y.concurrency.providers[m],w=`Concurrent slots reserved for agents under ${p} using the ${$e(m)?.provider??m} provider.`;if(S===void 0)return{id:`provider:${m}`,label:m,currentValue:"unset",description:w,submenu:v("",(A,x)=>{$().mutate.concurrency.setProvider(m,x,A),e.ui.notify(`${m} concurrency set to ${x} (${A})`,"info")})};let I=c(y.sessionConcurrency,"providers",m)?" [session]":c(y.projectConcurrency,"providers",m)?" [project]":"";return{id:`provider:${m}`,label:m,currentValue:De(S,I),description:w,submenu:h(S,(A,x)=>{$().mutate.concurrency.setProvider(m,x,A),e.ui.notify(`${m} concurrency set to ${x} (${A})`,"info")},A=>{$().mutate.concurrency.removeProvider(m,A),e.ui.notify(`Removed per-provider limit for ${m} (${A})`,"info")},{session:c(y.sessionConcurrency,"providers",m),global:c(y.globalConcurrency,"providers",m),project:c(y.projectConcurrency,"providers",m)})}},"providerLimitRow"),O=t(p=>{let m=$(),y=Be(Object.keys(m.concurrency.providers)).get(p)??[],S=C(p).map(I=>hn(p,I));return[...new Set([...S,...y])].sort().map(I=>L(p,I))},"providerListItems"),P=t((p,m)=>{let y=$(),S=y.concurrency.models[m],w=$e(m),I=w?.kind==="model"?w.model:m,A=`Concurrent slots reserved for agents under ${p} using the ${I} model.`;if(S===void 0)return{id:`model:${m}`,label:m,currentValue:"unset",description:A,submenu:v("",(F,z)=>{$().mutate.concurrency.setModel(m,z,F),e.ui.notify(`${m} concurrency set to ${z} (${F})`,"info")})};let x=c(y.sessionConcurrency,"models",m)?" [session]":c(y.projectConcurrency,"models",m)?" [project]":"";return{id:`model:${m}`,label:m,currentValue:De(S,x),description:A,submenu:h(S,(F,z)=>{$().mutate.concurrency.setModel(m,z,F),e.ui.notify(`${m} concurrency set to ${z} (${F})`,"info")},F=>{$().mutate.concurrency.removeModel(m,F),e.ui.notify(`Removed per-model limit for ${m} (${F})`,"info")},{session:c(y.sessionConcurrency,"models",m),global:c(y.globalConcurrency,"models",m),project:c(y.projectConcurrency,"models",m)})}},"modelLimitRow"),W=t(p=>{let m=$(),y=Be(Object.keys(m.concurrency.models)).get(p)??[],S=Z(n,p).map(I=>hn(p,I));return[...new Set([...S,...y])].sort().map(I=>P(p,I))},"modelListItems"),R=t(p=>{let m=$(),y=Be(Object.keys(p==="providers"?m.concurrency.providers:m.concurrency.models));return ar(o,y).filter(S=>{let w=(y.get(S)??[]).length>0;return p==="providers"?w||C(S).length>0:w||Z(n,S).length>0}).map(S=>({id:`${p}-harness:${S}`,label:Y().displayName(S),currentValue:"",description:p==="providers"?`Provider limits under ${S}.`:`Model limits under ${S}.`,submenu:k(()=>p==="providers"?O(S):W(S))}))},"harnessPickerItems"),j=i.concurrency.default;a.push({id:"defaultConcurrency",label:"Default concurrency limit",currentValue:`${j}${g("default")}`,description:"Concurrent agents, whatever harness, provider, or model they use.",submenu:h(j,(p,m)=>{i.mutate.concurrency.setDefault(m,p),e.ui.notify(`Default concurrency set to ${m} (${p})`,"info")},p=>{i.mutate.concurrency.removeDefault(p),e.ui.notify(`Removed default concurrency limit (${p})`,"info")},u("default"))}),a.push({id:"harnessLimits",label:"Per-harness limits",currentValue:"",description:"Cap how many agents run at once under a single harness.",submenu:k(T)}),a.push({id:"providerLimits",label:"Per-provider limits",currentValue:"",description:"Cap how many agents run at once for a single provider.",submenu:k(()=>R("providers"))}),a.push({id:"modelLimits",label:"Per-model limits",currentValue:"",description:"Cap how many agents run at once for a single model.",submenu:k(()=>R("models"))});let D=i.concurrencySettingsLevels(),K={...D,project:D.project&&d};return(K.session||K.global||K.project)&&a.push({id:"resetAll",label:"Clear all concurrency limits...",currentValue:"",description:"Remove concurrency overrides at the chosen level (session, global, project, or all).",submenu:Ve({theme:l,projectOffered:d,availableLevels:K,message:t(p=>`Clear all concurrency limits at the ${p} level?`,"message"),onConfirm:t(p=>{i.mutate.concurrency.clearAll(p),e.ui.notify(`Concurrency limits cleared (${p})`,"info")},"onConfirm")})}),a},"buildItems"),s;await new V(e).open(({theme:i,close:l})=>{let a=t(()=>s?.(r($(),i)),"triggerRebuild"),d=$(),c=r(d,i),u=new gn(c,15,_(i),(g,v)=>a(),l);return new H(u,{title:"Concurrency Settings",theme:i,onCancel:l,onRebuild:t(g=>{s=g},"onRebuild")})})}t(yn,"showConcurrencySettingsMenu");import{matchesKey as ce,SelectList as at,truncateToWidth as Sn,visibleWidth as Ue}from"@earendil-works/pi-tui";import{SelectList as lr}from"@earendil-works/pi-tui";async function vn(e,n){let o=ae();if(!o)return e.map(s=>({id:s,kind:"error",error:"manager unavailable"}));let r=[];for(let s of e)try{r.push({id:s,kind:"report",report:await o.cleanup(s,n(s))})}catch(i){r.push({id:s,kind:"error",error:de(i)})}return r}t(vn,"runCleanupPass");function st(e,n){let o=J(e.ui);for(let r of n)r.kind==="report"?o.succeeded(Gt(r.report),Je(r.report)?"warning":"info"):o.failed(`Failed to clean up agent ${r.id}`,r.error)}t(st,"reportCleanupOutcomes");function bn(e){return e.outcome.kind==="refused"?e.outcome.reason:void 0}t(bn,"refusalReason");function cr(e){return e.worktree.kind==="kept"?e.worktree.path??void 0:void 0}t(cr,"refusalWorktreePath");function ur(e){switch(e.kind){case"dirty":return"It has uncommitted changes";case"unverifiable":return`Its state could not be verified (${e.detail})`;case"recovered-refusal":return"Herdr still reports it at work";default:return Re(e)}}t(ur,"offerReason");function dr(e,n){return{invalidate(){},render:t(()=>[` ${e.fg("dim",n)}`],"render")}}t(dr,"progressBody");function mr(e,n,o,r){let s=[{value:"force",label:"Force",description:n},{value:"cancel",label:"Cancel",description:"Keep the worktree and its changes"}],i=X(new lr(s,6,Q(e)));return i.onSelect=l=>l.value==="force"?o():r(),i.onCancel=r,i}t(mr,"forceOfferList");function kn(e){let{ctx:n,theme:o,view:r,refresh:s,close:i,requestRender:l}=e,a=t(u=>{r.activate(u),l()},"show"),d=t((u,g,v,h)=>{let k=u.length===1;a(sn({theme:o,message:k?`Force cleanup of agent ${u[0]}?`:`Force cleanup of ${u.length} agents?`,detail:[...v,"",k?"This DELETES its worktree and anything uncommitted in it.":"This DELETES their worktrees and anything uncommitted in them."].join(`
|
|
3
3
|
`),onNo:h,onYes:t(()=>{i(),J(n.ui).pending(`Forcing cleanup of ${Te(u)}`),(async()=>{let b=await vn(u,T=>{let C=g.get(T);return{force:C?{reason:C}:{}}});st(n,b)})()},"onYes")}))},"askForceConfirm"),c=t(u=>{let g=new Map;for(let{id:L,report:O}of u){let P=bn(O);P&&g.set(L,P)}let v=[...g.keys()],h=v.length===1,k=u.map(({id:L,report:O})=>{let P=bn(O),W=P?h?Re(P):`${L}: ${Re(P)}`:`${L}: kept`,R=cr(O);return R?`${W} (${R})`:W}),b=g.get(v[0]??""),T=h?`Clean up agent ${v[0]} anyway? ${b?ur(b):"kept"}.`:`Clean up ${v.length} agents anyway?`,C=t(()=>{st(n,u),s()},"backOut");a(mr(o,T,()=>d(v,g,k,C),C))},"offerForce");return u=>{a(dr(o,`Cleaning up ${Te(u)}\u2026`)),(async()=>{let g=await vn(u,()=>{}),v=g.filter(b=>b.kind==="report"&&zt(b.report)),h=new Set(v.map(b=>b.id));if(st(n,g.filter(b=>!h.has(b.id))),v.length>0){c(v);return}g.some(b=>b.kind==="error"||Je(b.report))?s():i()})()}}t(kn,"createStatusCleanup");async function pr(e,n){let o=n.execution.host;if(!o){e.ui.notify("Agent has no herdr pane yet (still queued)","info");return}let r=Ee();if(!r){e.ui.notify("Agent runtime is not initialized","warning");return}let s=J(e.ui);s.pending(`Focusing agent ${n.id}'s herdr pane`);try{await r.view.focus(o),s.succeeded(`Focused agent ${n.id}'s herdr pane`)}catch(i){s.failed(`Failed to focus agent ${n.id}'s herdr pane`,i)}}t(pr,"focusHerdrPane");async function Cn(e,n,o,r){let s=o==="result"?n.id:"Error",i=r.split(`
|
|
4
|
-
`),l=tn(n.display.type),a=5,d=3,c=70,u=0,g=!0;await new V(e).openOverlay(({tui:v,theme:h,close:k})=>{let b=h.fg("border","\u2502"),T=t(()=>{let C=Math.floor(v.terminal.rows*c/100);return Math.max(d,C-a)},"viewportHeight");return{invalidate(){},render(C){let L=C-4,O=[h.fg("border",`\u256D${"\u2500".repeat(C-2)}\u256E`)],P=h.bold(h.fg("accent",`${l} \xB7 ${s}`)),W=Math.max(0,L-Ue(P));O.push(`${b} ${Sn(P+" ".repeat(W),L,"...",!0)} ${b}`),O.push(`${b} ${h.fg("dim","\u2500".repeat(L))} ${b}`);let R=T(),j=Math.max(0,i.length-R);g&&(u=j);let D=Math.min(u,j),K=i.slice(D,D+R);for(let w=0;w<R;w++){let I=K[w]??"",A=Sn(I,L,"...",!0),x=Math.max(0,L-Ue(A));O.push(`${b} ${A}${" ".repeat(x)} ${b}`)}let p=i.length<=R?"100%":`${Math.round((D+R)/i.length*100)}%`,m=h.fg("dim",`${i.length} lines \xB7 ${p}`),y=h.fg("dim","q/Esc close"),S=Math.max(1,L-Ue(m)-Ue(y));return O.push(`${b} ${m}${" ".repeat(S)}${y} ${b}`),O.push(h.fg("border",`\u2570${"\u2500".repeat(C-2)}\u256F`)),O},handleInput(C){if(ce(C,"q")||ce(C,"escape")){k();return}let L=T(),O=Math.max(0,i.length-L);ce(C,"up")?(u=Math.max(0,u-1),g=u>=O):ce(C,"down")?(u=Math.min(O,u+1),g=u>=O):ce(C,"pageUp")?(u=Math.max(0,u-L),g=!1):ce(C,"pageDown")?(u=Math.min(O,u+L),g=u>=O):ce(C,"home")||C==="g"?(u=0,g=!1):C==="G"&&(u=O,g=!0)}}})}t(Cn,"showTextViewer");function wn(e,n){let o=ae(),r=Te(n),s=J(e.ui);if(!o){s.failed(`Failed to stop ${r}`,"manager unavailable");return}(async()=>{let i=0,l=[];for(let d of n)try{await o.abort(d,"user")?i+=1:l.push({id:d,reason:"already settled"})}catch(c){l.push({id:d,reason:de(c)})}if(l.length===0){s.succeeded(n.length===1?`Stopped ${n[0]}`:`Stopped ${n.length} agent(s)`);return}let a=l.map(({id:d,reason:c})=>n.length===1?c:`${d} (${c})`).join(", ");i>0?s.succeeded(`Stopped ${i} of ${n.length} agent(s); ${a}`,"warning"):s.failed(`Failed to stop ${r}`,a)})()}t(wn,"stopAgentsOffMenu");function fr(e,n,o,r,s,i){let l=[],a=n.id,d=Ce(n.lifecycle.phase),c=!!n.execution.host,u=At(n.lifecycle),g=Le(n.lifecycle)&&n.lifecycle.status==="error"?n.lifecycle.error:"",v=u.length>0,h=g.length>0;if(c&&l.push({value:"focus-pane",label:"View shell",description:"Focus the subagent's herdr pane"}),v&&l.push({value:"view-result",label:"View result"}),h&&l.push({value:"view-error",label:"View error"}),d?l.push({value:"stop",label:"Stop"}):l.push({value:"cleanup",label:"Clean up",description:"Close its pane and remove its worktree and merged branch"}),l.length===0)return e.ui.notify(`Agent ${a} \u2014 no actions available`,"info"),r(),new at([],5,Q(o));let k=X(new at(l,10,Q(o)));return k.onSelect=async b=>{b.value==="focus-pane"?await pr(e,n):b.value==="view-result"?await Cn(e,n,"result",u):b.value==="view-error"?await Cn(e,n,"error",g):b.value==="stop"?(J(e.ui).pending(`Stopping agent ${a}`),r(),wn(e,[n.id])):b.value==="cleanup"&&i([n.id])},k.onCancel=()=>r(),k}t(fr,"buildAgentActionsList");async function Tn(e){if((ae()?.listAgents(Ae)??[]).length===0){e.ui.notify("No agents have been spawned this session","info");return}await new V(e).open(({tui:n,theme:o,close:r})=>{let s=ae()?.listAgents(Ae)??[],i=t(()=>s.filter(k=>Ce(k.lifecycle.phase)),"activeAgents"),l=t(()=>s.filter(k=>!Ce(k.lifecycle.phase)),"finishedAgents"),a=t(()=>s.filter(k=>Le(k.lifecycle)&&k.lifecycle.status==="completed"),"completedAgents"),d=t(()=>{let k=Date.now(),b=s.map(O=>{let P=It(O.lifecycle),W=Ce(O.lifecycle.phase),R=Le(O.lifecycle)?O.lifecycle.completedAt:k,j=et(R-Lt(O.lifecycle)),D=W?"":` ${et(k-R)} ago`,K=en(P,o),p=O.display.description?O.display.description:"",m=p?` \u2014 ${p}`:"",y=ie(o),S=O.display.worktree?` wt:${O.display.worktree.branch}`:"";return{value:O.id,label:`${K} ${O.id} ${y}${O.display.type} ${P} ${j}${S}${m}${D}`}}),T=i(),C=l(),L=a();return T.length>0&&(b.push({value:U,label:" "}),b.push({value:"__stop-all",label:`Stop ${T.length} active agent(s)`})),C.length>0&&(b.push({value:U,label:" "}),b.push({value:"__cleanup-finished",label:`Clean up ${C.length} settled agent(s)`}),L.length>0&&b.push({value:"__cleanup-completed",label:`Clean up ${L.length} completed agent(s)`})),b},"buildAgentItems"),c=X(new at(d(),15,Q(o)));He(c);let u=new je(c),g=t(()=>n.requestRender(),"requestRender"),v=t(k=>{s=ae()?.listAgents(Ae)??[];let b=c,T=d();b.items=T,b.filteredItems=T;let C=k?T.findIndex(L=>L.value===k):-1;c.setSelectedIndex(C>=0?C:0),u.activate(c),g()},"refresh"),h=kn({ctx:e,theme:o,view:u,refresh:v,close:r,requestRender:g});return c.onSelect=async k=>{if(k.value==="__stop-all"){let T=i();J(e.ui).pending(`Stopping ${T.length} agent(s)`),r(),wn(e,T.map(C=>C.id));return}if(k.value==="__cleanup-finished"){h(l().map(T=>T.id));return}if(k.value==="__cleanup-completed"){h(a().map(T=>T.id));return}let b=s.find(T=>T.id===k.value);b&&u.activate(fr(e,b,o,()=>v(b.id),()=>r(),h))},c.onCancel=()=>r(),new H(u,{title:"Status",theme:o,passthroughKeys:!0})})}t(Tn,"showAgentStatusMenu");import{SettingsList as gr,Input as hr}from"@earendil-works/pi-tui";function yr(e){let n="Harness that launches agents whose template omits harness_type. pi = the real pi binary; pig and pi-bolt = pi-compatible binaries launched through a shell function in the agent's own pane; opencode and codex = binaries of their own launched as their interactive UIs in the agent's own pane.",o=Ct.filter(l=>l!=="pi"&&!qe(l,e)),r=o.length===0?n:`${n} Not on PATH: ${o.join(", ")}.`,s=Y(),i=On().filter(l=>wt(l)===void 0);return i.length===0?r:`${r} Plugin harnesses: ${i.map(l=>s.displayName(l)).join(", ")}.`}t(yr,"harnessDescription");function On(){return[...ke(Y().ids(),le())]}t(On,"offerableHarnesses");async function Mn(e){let n=$(),o=t(i=>[fe(i,"Spawn defaults"),{id:U,label:" ",currentValue:""},{id:"harnessType",label:"Default harness",currentValue:jt(),values:On(),description:yr(le())},{id:U,label:" ",currentValue:""},fe(i,"Worktrees"),{id:"worktreeRoot",label:"Worktree root",currentValue:n.agent.worktreeRoot??"(default)",submenu:t((l,a)=>{let d=new hr;return d.setValue(l==="(default)"?"":l),d.onSubmit=c=>{let u=c.trim();n.mutate.agent.setWorktreeRoot(u||void 0),Zt(se()),e.ui.notify(u?`Worktree root set to ${u}`:"Worktree root cleared (default)","info"),a(u||"(default)")},d.onEscape=()=>a(),d},"submenu"),description:`Where worktrees are created. Blank = ${ft()}.`},{id:"worktreeMaterialization",label:"Worktree materialization",currentValue:xe(),values:[...ke(gt,Ze())],description:qe("copy-on-write",Ze())?"Copy-on-write = clone of the parent working tree (shares node_modules, .env). checkout = git's classic checkout, nothing shared.":"This volume cannot clone, so copy-on-write is unavailable and new worktrees use git's classic checkout."},{id:"worktreeCheckoutType",label:"Worktree checkout",currentValue:n.agent.worktreeCheckoutType,values:[...yt],description:"Where a new worktree's checkout starts when the parent has uncommitted work. clean = the worktree starts at HEAD: under copy-on-write, only ignored files like node_modules and .env are copied in; under checkout, it is git's plain checkout. dirty = the parent's work rides along: copy-on-write clones its edits and untracked files too, while checkout applies only its tracked changes, leaving untracked files behind. A clean parent starts at HEAD either way."},{id:U,label:" ",currentValue:""},fe(i,"Tools"),{id:"disableDefaultAgents",label:"Disable default agents",currentValue:n.agent.disableDefaultAgents?"ON":"OFF",values:["ON","OFF"],description:"Skip auto-loading built-in agent types next session; only .pi/agents types load."}],"buildItems"),r=t((i,l)=>{switch(i){case"worktreeRoot":break;case"worktreeMaterialization":{let a=ht(l);a!==void 0&&(n.mutate.agent.setWorktreeMaterialization(a),e.ui.notify(`Worktree materialization set to ${a}`,"info"));break}case"worktreeCheckoutType":{let a=vt(l);a!==void 0&&(n.mutate.agent.setWorktreeCheckoutType(a),e.ui.notify(`Worktree checkout set to ${a}`,"info"));break}case"harnessType":{n.mutate.agent.setHarnessType(l),e.ui.notify(`Default harness set to ${l}`,"info");break}case"disableDefaultAgents":n.mutate.agent.setDisableDefaultAgents(l==="ON"),e.ui.notify(`Disable default agents ${l} (takes effect on next session)`,"info");break}},"onChange"),s;await new V(e).open(({theme:i,close:l})=>{let a=o(i),d=t(()=>s?.(o(i)),"triggerRebuild"),c=new gr(a,10,_(i),(u,g)=>{r(u,g),a.some(v=>v.id===u&&v.submenu)&&d()},l);return new H(c,{title:"Agent settings",theme:i,onCancel:l,onRebuild:t(u=>{s=u},"onRebuild")})})}t(Mn,"showSpawnOptionsMenu");function vr(e,n,o){return(r,s)=>{let i=Pe();i.length===0&&n("No agent types available","error");let l=i.map(a=>({value:a,label:a,provider:B(a)?.description??""}));return new pe(l,e.agent.defaultAgentType,{onSelect:t(a=>{a!=null&&(e.mutate.agent.setDefaultAgentType(a),n(`Agent set to ${a}`,"info")),s(a??void 0)},"onSelect"),onCancel:t(()=>s(),"onCancel")},o)}}t(vr,"createAgentTypeSubmenu");function br(e,n,o){return(r,s)=>{let i=Nt(),a=(i.length>0?i:Object.keys(Dt)).map(d=>({value:d,label:d}));return new pe(a,e.agent.defaultOrchestrator,{onSelect:t(d=>{d!=null&&(e.mutate.agent.setDefaultOrchestrator(d),n(`Default orchestrator set to ${d}`,"info")),s(d??void 0)},"onSelect"),onCancel:t(()=>s(),"onCancel")},o)}}t(br,"createOrchestratorSubmenu");function In(e){return{id:"defaultAgentType",label:"Agent",currentValue:e.store.agent.defaultAgentType,submenu:vr(e.store,e.notify,e.theme),description:`Agent type used when cowboy_agent omits \`agent_type\`. Default: ${Ot}.`}}t(In,"buildDefaultAgentTypeRow");function An(e){return{id:"defaultOrchestrator",label:"Default orchestrator",currentValue:e.store.agent.defaultOrchestrator,submenu:br(e.store,e.notify,e.theme),description:`Orchestration template used for every cowboy_agent spawn; the tool accepts no per-call orchestrator input. Default: ${Mt}.`}}t(An,"buildDefaultOrchestratorRow");import lt from"node:fs";import kr from"node:path";import{SettingsList as Sr}from"@earendil-works/pi-tui";async function Ln(e){let n=$(),o=t(()=>{let l=Xe(),a=[{id:"systemPromptMode",label:"System prompt mode",currentValue:n.agent.systemPromptMode,values:["replace","inherit","custom"],description:"How the subagent system prompt is built: replace, inherit, or custom."}];return n.agent.systemPromptMode==="custom"&&!lt.existsSync(l)&&a.push({id:"createPromptFile",label:"Create prompt file",currentValue:l,values:["Create"],description:`Create ${l} with a starter template for custom mode.`}),a.push({id:"includeContextFiles",label:"Include context files",currentValue:n.agent.includeContextFiles?"ON":"OFF",values:["ON","OFF"],description:"Load project and ~/.pi/agent AGENTS.md as shared <project_context>."},{id:"loadSkillsImplicitly",label:"Load skills implicitly",currentValue:n.agent.loadSkillsImplicitly?"ON":"OFF",values:["ON","OFF"],description:"Give new agents all skills when an agent template omits the field."},{id:"loadExtensionsImplicitly",label:"Load extensions implicitly",currentValue:n.agent.loadExtensionsImplicitly?"ON":"OFF",values:["ON","OFF"],description:"Give new agents all extensions when an agent template omits the field."}),a},"buildItems"),r=o(),s=null,i=t((l,a)=>{switch(l){case"systemPromptMode":n.mutate.agent.setSystemPromptMode(a),e.ui.notify(`System prompt mode set to ${a}`,"info"),r=o(),s?.(r);break;case"createPromptFile":try{let d=Xe();lt.mkdirSync(kr.dirname(d),{recursive:!0}),lt.writeFileSync(d,`You are a Pi, an expert coding sub-agent.
|
|
4
|
+
`),l=tn(n.display.type),a=5,d=3,c=70,u=0,g=!0;await new V(e).openOverlay(({tui:v,theme:h,close:k})=>{let b=h.fg("border","\u2502"),T=t(()=>{let C=Math.floor(v.terminal.rows*c/100);return Math.max(d,C-a)},"viewportHeight");return{invalidate(){},render(C){let L=C-4,O=[h.fg("border",`\u256D${"\u2500".repeat(C-2)}\u256E`)],P=h.bold(h.fg("accent",`${l} \xB7 ${s}`)),W=Math.max(0,L-Ue(P));O.push(`${b} ${Sn(P+" ".repeat(W),L,"...",!0)} ${b}`),O.push(`${b} ${h.fg("dim","\u2500".repeat(L))} ${b}`);let R=T(),j=Math.max(0,i.length-R);g&&(u=j);let D=Math.min(u,j),K=i.slice(D,D+R);for(let w=0;w<R;w++){let I=K[w]??"",A=Sn(I,L,"...",!0),x=Math.max(0,L-Ue(A));O.push(`${b} ${A}${" ".repeat(x)} ${b}`)}let p=i.length<=R?"100%":`${Math.round((D+R)/i.length*100)}%`,m=h.fg("dim",`${i.length} lines \xB7 ${p}`),y=h.fg("dim","q/Esc close"),S=Math.max(1,L-Ue(m)-Ue(y));return O.push(`${b} ${m}${" ".repeat(S)}${y} ${b}`),O.push(h.fg("border",`\u2570${"\u2500".repeat(C-2)}\u256F`)),O},handleInput(C){if(ce(C,"q")||ce(C,"escape")){k();return}let L=T(),O=Math.max(0,i.length-L);ce(C,"up")?(u=Math.max(0,u-1),g=u>=O):ce(C,"down")?(u=Math.min(O,u+1),g=u>=O):ce(C,"pageUp")?(u=Math.max(0,u-L),g=!1):ce(C,"pageDown")?(u=Math.min(O,u+L),g=u>=O):ce(C,"home")||C==="g"?(u=0,g=!1):C==="G"&&(u=O,g=!0)}}})}t(Cn,"showTextViewer");function wn(e,n){let o=ae(),r=Te(n),s=J(e.ui);if(!o){s.failed(`Failed to stop ${r}`,"manager unavailable");return}(async()=>{let i=0,l=[];for(let d of n)try{await o.abort(d,"user")?i+=1:l.push({id:d,reason:"already settled"})}catch(c){l.push({id:d,reason:de(c)})}if(l.length===0){s.succeeded(n.length===1?`Stopped ${n[0]}`:`Stopped ${n.length} agent(s)`);return}let a=l.map(({id:d,reason:c})=>n.length===1?c:`${d} (${c})`).join(", ");i>0?s.succeeded(`Stopped ${i} of ${n.length} agent(s); ${a}`,"warning"):s.failed(`Failed to stop ${r}`,a)})()}t(wn,"stopAgentsOffMenu");function fr(e,n,o,r,s,i){let l=[],a=n.id,d=Ce(n.lifecycle.phase),c=n.execution.host!==void 0,u=At(n.lifecycle),g=Le(n.lifecycle)&&n.lifecycle.status==="error"?n.lifecycle.error:"",v=u.length>0,h=g.length>0;if(c&&l.push({value:"focus-pane",label:"View shell",description:"Focus the subagent's herdr pane"}),v&&l.push({value:"view-result",label:"View result"}),h&&l.push({value:"view-error",label:"View error"}),d?l.push({value:"stop",label:"Stop"}):l.push({value:"cleanup",label:"Clean up",description:"Close its pane and remove its worktree and merged branch"}),l.length===0)return e.ui.notify(`Agent ${a} \u2014 no actions available`,"info"),r(),new at([],5,Q(o));let k=X(new at(l,10,Q(o)));return k.onSelect=async b=>{b.value==="focus-pane"?await pr(e,n):b.value==="view-result"?await Cn(e,n,"result",u):b.value==="view-error"?await Cn(e,n,"error",g):b.value==="stop"?(J(e.ui).pending(`Stopping agent ${a}`),r(),wn(e,[n.id])):b.value==="cleanup"&&i([n.id])},k.onCancel=()=>r(),k}t(fr,"buildAgentActionsList");async function Tn(e){if((ae()?.listAgents(Ae)??[]).length===0){e.ui.notify("No agents have been spawned this session","info");return}await new V(e).open(({tui:n,theme:o,close:r})=>{let s=ae()?.listAgents(Ae)??[],i=t(()=>s.filter(k=>Ce(k.lifecycle.phase)),"activeAgents"),l=t(()=>s.filter(k=>!Ce(k.lifecycle.phase)),"finishedAgents"),a=t(()=>s.filter(k=>Le(k.lifecycle)&&k.lifecycle.status==="completed"),"completedAgents"),d=t(()=>{let k=Date.now(),b=s.map(O=>{let P=It(O.lifecycle),W=Ce(O.lifecycle.phase),R=Le(O.lifecycle)?O.lifecycle.completedAt:k,j=et(R-Lt(O.lifecycle)),D=W?"":` ${et(k-R)} ago`,K=en(P,o),p=O.display.description?O.display.description:"",m=p?` \u2014 ${p}`:"",y=ie(o),S=O.display.worktree?` wt:${O.display.worktree.branch}`:"";return{value:O.id,label:`${K} ${O.id} ${y}${O.display.type} ${P} ${j}${S}${m}${D}`}}),T=i(),C=l(),L=a();return T.length>0&&(b.push({value:U,label:" "}),b.push({value:"__stop-all",label:`Stop ${T.length} active agent(s)`})),C.length>0&&(b.push({value:U,label:" "}),b.push({value:"__cleanup-finished",label:`Clean up ${C.length} settled agent(s)`}),L.length>0&&b.push({value:"__cleanup-completed",label:`Clean up ${L.length} completed agent(s)`})),b},"buildAgentItems"),c=X(new at(d(),15,Q(o)));He(c);let u=new je(c),g=t(()=>n.requestRender(),"requestRender"),v=t(k=>{s=ae()?.listAgents(Ae)??[];let b=c,T=d();b.items=T,b.filteredItems=T;let C=k?T.findIndex(L=>L.value===k):-1;c.setSelectedIndex(C>=0?C:0),u.activate(c),g()},"refresh"),h=kn({ctx:e,theme:o,view:u,refresh:v,close:r,requestRender:g});return c.onSelect=async k=>{if(k.value==="__stop-all"){let T=i();J(e.ui).pending(`Stopping ${T.length} agent(s)`),r(),wn(e,T.map(C=>C.id));return}if(k.value==="__cleanup-finished"){h(l().map(T=>T.id));return}if(k.value==="__cleanup-completed"){h(a().map(T=>T.id));return}let b=s.find(T=>T.id===k.value);b&&u.activate(fr(e,b,o,()=>v(b.id),()=>r(),h))},c.onCancel=()=>r(),new H(u,{title:"Status",theme:o,passthroughKeys:!0})})}t(Tn,"showAgentStatusMenu");import{SettingsList as gr,Input as hr}from"@earendil-works/pi-tui";function yr(e){let n="Harness that launches agents whose template omits harness_type. pi = the real pi binary; pig and pi-bolt = pi-compatible binaries launched through a shell function in the agent's own pane; opencode and codex = binaries of their own launched as their interactive UIs in the agent's own pane.",o=Ct.filter(l=>l!=="pi"&&!qe(l,e)),r=o.length===0?n:`${n} Not on PATH: ${o.join(", ")}.`,s=Y(),i=On().filter(l=>wt(l)===void 0);return i.length===0?r:`${r} Plugin harnesses: ${i.map(l=>s.displayName(l)).join(", ")}.`}t(yr,"harnessDescription");function On(){return[...ke(Y().ids(),le())]}t(On,"offerableHarnesses");async function Mn(e){let n=$(),o=t(i=>[fe(i,"Spawn defaults"),{id:U,label:" ",currentValue:""},{id:"harnessType",label:"Default harness",currentValue:jt(),values:On(),description:yr(le())},{id:U,label:" ",currentValue:""},fe(i,"Worktrees"),{id:"worktreeRoot",label:"Worktree root",currentValue:n.agent.worktreeRoot??"(default)",submenu:t((l,a)=>{let d=new hr;return d.setValue(l==="(default)"?"":l),d.onSubmit=c=>{let u=c.trim();n.mutate.agent.setWorktreeRoot(u||void 0),Zt(se()),e.ui.notify(u?`Worktree root set to ${u}`:"Worktree root cleared (default)","info"),a(u||"(default)")},d.onEscape=()=>a(),d},"submenu"),description:`Where worktrees are created. Blank = ${ft()}.`},{id:"worktreeMaterialization",label:"Worktree materialization",currentValue:xe(),values:[...ke(gt,Ze())],description:qe("copy-on-write",Ze())?"Copy-on-write = clone of the parent working tree (shares node_modules, .env). checkout = git's classic checkout, nothing shared.":"This volume cannot clone, so copy-on-write is unavailable and new worktrees use git's classic checkout."},{id:"worktreeCheckoutType",label:"Worktree checkout",currentValue:n.agent.worktreeCheckoutType,values:[...yt],description:"Where a new worktree's checkout starts when the parent has uncommitted work. clean = the worktree starts at HEAD: under copy-on-write, only ignored files like node_modules and .env are copied in; under checkout, it is git's plain checkout. dirty = the parent's work rides along: copy-on-write clones its edits and untracked files too, while checkout applies only its tracked changes, leaving untracked files behind. A clean parent starts at HEAD either way."},{id:U,label:" ",currentValue:""},fe(i,"Tools"),{id:"disableDefaultAgents",label:"Disable default agents",currentValue:n.agent.disableDefaultAgents?"ON":"OFF",values:["ON","OFF"],description:"Skip auto-loading built-in agent types next session; only .pi/agents types load."}],"buildItems"),r=t((i,l)=>{switch(i){case"worktreeRoot":break;case"worktreeMaterialization":{let a=ht(l);a!==void 0&&(n.mutate.agent.setWorktreeMaterialization(a),e.ui.notify(`Worktree materialization set to ${a}`,"info"));break}case"worktreeCheckoutType":{let a=vt(l);a!==void 0&&(n.mutate.agent.setWorktreeCheckoutType(a),e.ui.notify(`Worktree checkout set to ${a}`,"info"));break}case"harnessType":{n.mutate.agent.setHarnessType(l),e.ui.notify(`Default harness set to ${l}`,"info");break}case"disableDefaultAgents":n.mutate.agent.setDisableDefaultAgents(l==="ON"),e.ui.notify(`Disable default agents ${l} (takes effect on next session)`,"info");break}},"onChange"),s;await new V(e).open(({theme:i,close:l})=>{let a=o(i),d=t(()=>s?.(o(i)),"triggerRebuild"),c=new gr(a,10,_(i),(u,g)=>{r(u,g),a.some(v=>v.id===u&&v.submenu)&&d()},l);return new H(c,{title:"Agent settings",theme:i,onCancel:l,onRebuild:t(u=>{s=u},"onRebuild")})})}t(Mn,"showSpawnOptionsMenu");function vr(e,n,o){return(r,s)=>{let i=Pe();i.length===0&&n("No agent types available","error");let l=i.map(a=>({value:a,label:a,provider:B(a)?.description??""}));return new pe(l,e.agent.defaultAgentType,{onSelect:t(a=>{a!=null&&(e.mutate.agent.setDefaultAgentType(a),n(`Agent set to ${a}`,"info")),s(a??void 0)},"onSelect"),onCancel:t(()=>s(),"onCancel")},o)}}t(vr,"createAgentTypeSubmenu");function br(e,n,o){return(r,s)=>{let i=Nt(),a=(i.length>0?i:Object.keys(Dt)).map(d=>({value:d,label:d}));return new pe(a,e.agent.defaultOrchestrator,{onSelect:t(d=>{d!=null&&(e.mutate.agent.setDefaultOrchestrator(d),n(`Default orchestrator set to ${d}`,"info")),s(d??void 0)},"onSelect"),onCancel:t(()=>s(),"onCancel")},o)}}t(br,"createOrchestratorSubmenu");function In(e){return{id:"defaultAgentType",label:"Agent",currentValue:e.store.agent.defaultAgentType,submenu:vr(e.store,e.notify,e.theme),description:`Agent type used when cowboy_agent omits \`agent_type\`. Default: ${Ot}.`}}t(In,"buildDefaultAgentTypeRow");function An(e){return{id:"defaultOrchestrator",label:"Default orchestrator",currentValue:e.store.agent.defaultOrchestrator,submenu:br(e.store,e.notify,e.theme),description:`Orchestration template used for every cowboy_agent spawn; the tool accepts no per-call orchestrator input. Default: ${Mt}.`}}t(An,"buildDefaultOrchestratorRow");import lt from"node:fs";import kr from"node:path";import{SettingsList as Sr}from"@earendil-works/pi-tui";async function Ln(e){let n=$(),o=t(()=>{let l=Xe(),a=[{id:"systemPromptMode",label:"System prompt mode",currentValue:n.agent.systemPromptMode,values:["replace","inherit","custom"],description:"How the subagent system prompt is built: replace, inherit, or custom."}];return n.agent.systemPromptMode==="custom"&&!lt.existsSync(l)&&a.push({id:"createPromptFile",label:"Create prompt file",currentValue:l,values:["Create"],description:`Create ${l} with a starter template for custom mode.`}),a.push({id:"includeContextFiles",label:"Include context files",currentValue:n.agent.includeContextFiles?"ON":"OFF",values:["ON","OFF"],description:"Load project and ~/.pi/agent AGENTS.md as shared <project_context>."},{id:"loadSkillsImplicitly",label:"Load skills implicitly",currentValue:n.agent.loadSkillsImplicitly?"ON":"OFF",values:["ON","OFF"],description:"Give new agents all skills when an agent template omits the field."},{id:"loadExtensionsImplicitly",label:"Load extensions implicitly",currentValue:n.agent.loadExtensionsImplicitly?"ON":"OFF",values:["ON","OFF"],description:"Give new agents all extensions when an agent template omits the field."}),a},"buildItems"),r=o(),s=null,i=t((l,a)=>{switch(l){case"systemPromptMode":n.mutate.agent.setSystemPromptMode(a),e.ui.notify(`System prompt mode set to ${a}`,"info"),r=o(),s?.(r);break;case"createPromptFile":try{let d=Xe();lt.mkdirSync(kr.dirname(d),{recursive:!0}),lt.writeFileSync(d,`You are a Pi, an expert coding sub-agent.
|
|
5
5
|
You have been invoked to handle a specific task autonomously`,"utf-8"),e.ui.notify(`Created prompt file: ${d}`,"info")}catch(d){e.ui.notify(`Failed to create prompt file: ${de(d)}`,"error")}return;case"includeContextFiles":n.mutate.agent.setIncludeContextFiles(a==="ON"),e.ui.notify(`Include context files set to ${a}`,"info");break;case"loadSkillsImplicitly":n.mutate.agent.setLoadSkillsImplicitly(a==="ON"),e.ui.notify(`Load skills implicitly set to ${a}`,"info");break;case"loadExtensionsImplicitly":n.mutate.agent.setLoadExtensionsImplicitly(a==="ON"),e.ui.notify(`Load extensions implicitly set to ${a}`,"info");break}},"onChange");await new V(e).open(({theme:l,close:a})=>{let d=new Sr(r,10,_(l),i,a);return new H(d,{title:"System Prompt",theme:l,onCancel:a,onRebuild:t(c=>{s=c},"onRebuild")})})}t(Ln,"showSystemPromptMenu");var ct="thinkingLevel",$n="__custom__";function xn(e){return{modelName:St(e),thinkingLevel:e?.thinking??void 0}}t(xn,"choiceInvocation");function En(e){let{entries:n,registry:o,parentModel:r}=e,s=t((l,a)=>We({harnessId:l,modelKey:a,entries:n.get(l)??[],piModel:Se(a,o,r)}),"offeringOf"),i=t((l,a,d)=>{if(l.kind==="none")return;let c=l.levels.map(u=>({id:u,label:u==="off"?"Off":u.charAt(0).toUpperCase()+u.slice(1),currentValue:a===u?"(current)":""}));return l.kind==="advisory"&&c.push({id:$n,label:"Custom token...",currentValue:"",description:"A level or variant this model advertises beyond its own list."}),c.push({id:ve,label:"None",currentValue:a===void 0?"(current)":"",description:"Use the template, configured default, or parent session's level."}),ee({theme:d.theme,items:c,onPick:t((u,g)=>{if(u===$n)return ye(d.ctx)(a??"",g)},"onPick")})},"levelRow");return{clamp(l,a,d){if(d===void 0)return;let c=s(l,a);if(c.kind!=="none")return c.kind==="advisory"||c.levels.includes(d)?d:void 0},row(l,a,d,c){let u=s(l,a);return{id:ct,label:"Thinking level",currentValue:d??"(none)",description:u.kind==="none"?"The selected model does not support thinking levels.":"Reasoning effort for this spawn, supported by the selected harness",submenu:i(u,d,c)}},choice(l,a,d){if(a==="")return d===void 0?{kind:"none"}:{kind:"chosen",modelChoice:te(l)?{inherit:!0,thinking:d}:{levelOnly:!0,thinking:d}};let c=te(l)?Cr(a,d,o):wr(l,a,d,n);return c===void 0?{kind:"missing",modelKey:a}:{kind:"chosen",modelChoice:c}}}}t(En,"spawnChoices");function Cr(e,n,o){let r=Se(e,o,void 0);if(r!==void 0)return{model:r,key:`${r.provider}/${r.id}`,thinking:n??null}}t(Cr,"piChoice");function wr(e,n,o,r){let s=(r.get(e)??[]).find(i=>i.key===n);return{harness:e,key:n,name:s?.label??n,thinking:o??null}}t(wr,"foreignChoice");import*as jn from"node:path";var ue="cow-",ut=bt;function Tr(e){if(!e.startsWith(ue))return{kind:"missing-prefix"};let n=e.slice(ue.length);return n===""?{kind:"empty-name"}:/^[a-z0-9_-]+$/.test(n)?e.length>ut?{kind:"too-long"}:null:{kind:"invalid-characters"}}t(Tr,"validateWorktreeBranchName");function Or(e){switch(e.kind){case"missing-prefix":return`Worktree name must start with "${ue}" \u2014 it is prefilled; add your name after it.`;case"empty-name":return`Enter a name after "${ue}" (for example cow-fix-login).`;case"invalid-characters":return"Invalid name: only lowercase letters, numbers, hyphens, and underscores allowed.";case"too-long":return`Worktree name is too long: herdr agent names cap at ${ut} characters, so the name after "${ue}" can be at most ${ut-ue.length} characters.`}}t(Or,"describeWorktreeNameProblem");function Pn(e){return Xt({prefill:ue,notify:e.notify,validate:Tr,describeProblem:Or,onDone:e.onDone,onCancel:e.onCancel})}t(Pn,"createWorktreeNameInput");var Hn="__inherit_worktree__",Fn="__create_new_worktree__",Mr=60;function Ir(e){return e.branch??jn.basename(e.path)}t(Ir,"worktreeBranch");function Rn(e){switch(e.kind){case"inherit":return"Inherits parent cwd";case"picked":return e.branch;case"new":return"New worktree"}}t(Rn,"pickLabel");function Ar(e){return[{value:Fn,label:"New worktree"},{value:Hn,label:"Inherits parent cwd"},...e.map(n=>({value:n.path,label:nn(n.path,Mr),provider:n.isDetached?"detached":n.branch??"detached"}))]}t(Ar,"pickerItems");async function _n(e,n){return n===null||!await Ft(e,n)?null:await Ht(e,n)??[]}t(_n,"loadWorktreeChoices");function Dn(e,n){return{id:"worktree",label:"Worktree",currentValue:Rn(n.current),description:"Run in a linked git worktree instead of parent cwd; a new one is named after Spawn",submenu:t((o,r)=>{let s=t(i=>{n.onPick(i),r(Rn(i))},"record");return _e(Ar(e),{onSelect:t(i=>{if(i===Fn){s({kind:"new"});return}if(i===Hn){s({kind:"inherit"});return}let l=e.find(a=>a.path===i);l&&s({kind:"picked",path:l.path,branch:Ir(l)})},"onSelect"),onCancel:t(()=>r(),"onCancel")},n.theme)},"submenu")}}t(Dn,"buildWorktreeRow");async function Nn(e,n){return await e.open(({theme:o,close:r})=>new H(Pn({notify:n,onDone:t(s=>r(s),"onDone"),onCancel:t(()=>r(),"onCancel")}),{title:"Worktree Name",theme:o,passthroughKeys:!0}))}t(Nn,"showWorktreeNameStep");import{Editor as Lr}from"@earendil-works/pi-tui";function Vn(e){let{tui:n,theme:o,keybindings:r,prefill:s,onDone:i,onCancel:l}=e,a=new Lr(n,{borderColor:t(d=>o.fg("dim",d),"borderColor"),selectList:Q(o)},{paddingX:2});return a.focused=!0,s&&a.setText(s),a.onSubmit=d=>{let c=d.trim();if(!c&&e.required){e.notify("Cannot be empty","error");return}i(c)},{render:t(d=>a.render(d),"render"),invalidate:t(()=>a.invalidate(),"invalidate"),handleInput:t(d=>{if(r.matches(d,"tui.select.cancel")){l();return}a.handleInput(d)},"handleInput"),get focused(){return a.focused},set focused(d){a.focused=d}}}t(Vn,"createTextEditor");import{SettingsList as dt}from"@earendil-works/pi-tui";async function Wn(e,n){let o=Pe();if(o.length===0){e.ui.notify("No agent types available","error");return}let r=Vt(),s=o.includes(r)?r:o[0],i=me(),l=await _n(se(),i.cwd),a=$(),d=i.model?`${i.model.provider}/${i.model.id}`:null,c=[...ke(Y().ids(),le())],u=t((p,m)=>a.modelFor(p,d,B(p),m)??"","modelFor"),g=En({entries:n,registry:i.modelRegistry,parentModel:i.model}),v=t((p,m)=>a.thinkingFor(p,B(p),m,i.thinkingLevel),"seedThinking"),h=ne(s),k=u(s,h),b=v(s,h),T=!0,C=B(s)?.fork??!1,L=l?{kind:"new"}:{kind:"inherit"},O="",P=t(p=>{s=p,h=ne(p),k=u(p,h),b=v(p,h),C=B(p)?.fork??!1},"applyType"),W=t(p=>{h=p,k=u(s,p),b=v(s,p)},"applyHarness"),R=t(()=>{let p=k||"(no model)";return[{id:"spawn",label:"Spawn",currentValue:"",description:"Ask for the worktree name and prompt, then launch",submenu:t((m,y)=>{let S=g.choice(h,k,b);return S.kind==="missing"?(e.ui.notify(`Model not found: ${S.modelKey}`,"error"),y(),re):(D({type:s,harness:h,modelChoice:S.kind==="chosen"?S.modelChoice:void 0,worktreeChoice:L,description:O,fork:C,runInBackground:T}),re)},"submenu")},{id:U,label:" ",currentValue:""},{id:"type",label:"Type",currentValue:s,description:B(s)?.description??"Agent type",submenu:t((m,y)=>{let S=new dt(o.map(w=>({id:w,label:`${ie(j)}${w}`,currentValue:w,description:B(w)?.description??"Agent type",submenu:t((I,A)=>(y(w),re),"submenu")})),10,_(j),()=>{},()=>y(),{enableSearch:!0});return S.selectItem(s),S},"submenu")},{id:"harness",label:"Harness",currentValue:h,description:"Harness that launches this agent. A change re-seeds the model and thinking level from that harness's own defaults: both belong to the harness that reads them.",submenu:t((m,y)=>{let S=new dt(c.map(w=>({id:w,label:`${ie(j)}${w}`,currentValue:w,submenu:t((I,A)=>(y(w),re),"submenu")})),10,_(j),()=>{},()=>y(),{enableSearch:!0});return S.selectItem(h),S},"submenu")},{id:"model",label:"Model",currentValue:p,description:"Override the default model for this agent",submenu:un({modelOptions:Z(n,h),mergedModels:we(h,Fe(a.agentConfigSnapshot())),showClear:!1,projectOffered:a.isProjectWritable,theme:j,onSet:t((m,y)=>{k=y??"",b=g.clamp(h,k,b),K?.(R())},"onSet")})},{id:"background",label:"Background",currentValue:T?"ON":"OFF",description:"Run the agent in the background",values:["ON","OFF"]},{id:"fork",label:"Fork session",currentValue:C?"Yes":"No",description:"Fork the parent session context into the subagent",values:["Yes","No"]},...l?[Dn(l,{current:L,theme:j,onPick:t(m=>{L=m},"onPick")})]:[],g.row(h,k,b,{ctx:e,theme:j}),{id:U,label:" ",currentValue:""},{id:"description",label:"Description",currentValue:O,description:"Short label shown in the agents list; derived from the prompt when left empty",submenu:ye(e)}]},"buildItems"),j,D,K;return await new V(e).open(({theme:p,close:m})=>{j=p,D=m;let y=t((w,I)=>{switch(w){case"type":P(I);break;case"harness":{let A=c.find(x=>x===I);A!==void 0&&W(A);break}case ct:b=I===ve?v(s,h):I;break;case"background":T=I==="ON";break;case"fork":C=I==="Yes";break;case"description":O=I;break}K?.(R())},"onChange"),S=new dt(R(),15,_(j),y,m);return new H(S,{title:"Spawn Options",theme:j,onCancel:m,onRebuild:t(w=>{K=w},"onRebuild")})})}t(Wn,"askSpawnConfiguration");var $r=50;async function Kn(e,n){let o=me(),r=$(),s=o.cwd,i=t(async(g,v)=>{try{return await qt.allocate(se(),{naming:{kind:"explicit",branch:g},parentCwd:s,worktreeRoot:r.agent.worktreeRoot,materialization:xe(),dirtyCheckout:Kt(v),notify:t((h,k)=>e.ui.notify(h,k),"notify"),host:Ee().host})}catch(h){e.ui.notify(`Worktree creation failed: ${h instanceof Error?h.message:String(h)}`,"error");return}},"allocateWorktree"),l=t(async(g,v,h)=>{let k=se(),b=Pt().mintSpawnId();J(e.ui).pending(`Spawning agent ${b} (${g.type})`);let T;if(v.kind==="new"&&(T=await i(v.branch,g.type),!T))return;let C=T?.worktree,L=C!==void 0?{kind:"owned",path:C.path,branch:C.branch}:v.kind==="picked"?{kind:"picked",path:v.path,branch:v.branch}:void 0,O=g.description.trim()!==""?g.description:(h.split(`
|
|
6
6
|
`,1)[0]??"").slice(0,$r),P=Rt(),W=Wt();try{await P.spawn(o,{spawnId:b,type:g.type,requestedHarness:g.harness,prompt:h,description:O,orchestration:W,modelChoice:g.modelChoice,worktree:L,hostRef:T?.hostRef,projectTrusted:T?.projectTrusted,invocation:{...xn(g.modelChoice),runInBackground:g.runInBackground,fork:g.fork},runInBackground:g.runInBackground,fork:g.fork})}catch(R){let j=`Spawn failed: ${R instanceof Error?R.message:String(R)}`;if(!T){e.ui.notify(j,"error");return}let D=await T.teardown(k);e.ui.notify(`${j}
|
|
7
7
|
|
|
8
8
|
${Yt(D)}`,"error")}},"launch"),a=await Wn(e,n);if(a===void 0)return;let d=new V(e),c;if(a.worktreeChoice.kind==="new"){let g=await Nn(d,(v,h)=>e.ui.notify(v,h));if(g===void 0)return;c={kind:"new",branch:g}}else c=a.worktreeChoice;let u=await d.open(({tui:g,theme:v,keybindings:h,close:k})=>new H(Vn({prefill:"",onDone:t(b=>k(b),"onDone"),onCancel:t(()=>k(),"onCancel"),tui:g,theme:v,keybindings:h}),{title:"Agent Prompt (optional)",theme:v,passthroughKeys:!0}));u!==void 0&&await l(a,c,u)}t(Kn,"showSpawnAgentMenu");async function xr(e){return await new V(e).open(({theme:n,close:o})=>{let r=t(c=>o(c),"handOff"),s=$(),i=s.agent.showActiveIndicator,l=s.agent.grazingEnabled,a=[be("concurrency","Concurrency Settings","Set per-model slot limits",r),be("spawnoptions","Agent behavior","spawn defaults, results delivery, output, tools, worktrees",r),be("systemprompt","System prompt","Prompt mode, AGENTS.md, skills, extensions",r),{id:"showActiveIndicator",label:"Show cowboy \u{1F920}",currentValue:i?"ON":"OFF",values:["ON","OFF"]},{id:"grazingEnabled",label:"Grazing \u{1F404}",currentValue:l?"ON":"OFF",values:["ON","OFF"]}],d=new Gn(a,10,_(n),(c,u)=>{c==="showActiveIndicator"?Bt(e.ui,u==="ON"):c==="grazingEnabled"&&s.mutate.agent.setGrazingEnabled(u==="ON")},o);return new H(d,{title:"Settings",theme:n,onCancel:o})})}t(xr,"showSettingsList");async function Er(e,n){for(;;){let o=await xr(e);if(o===void 0)return;switch(o){case"concurrency":await yn(e,n);break;case"spawnoptions":await Mn(e);break;case"systemprompt":await Ln(e);break}}}t(Er,"showSettingsMenu");async function Pr(e,n,o){switch(n){case"status":await Tn(e);break;case"spawn":await Kn(e,o);break;case"settings":await Er(e,o);break}}t(Pr,"showAgentsActionMenu");function be(e,n,o,r){return{id:e,label:n,description:o,currentValue:"",submenu:t(()=>(r(e),re),"submenu")}}t(be,"handOffRow");async function Rr(e,n){let o=await Qt(e.cwd),r;return await new V(e).open(({theme:s,close:i})=>{let l=t(c=>i(c),"handOff"),a=t(()=>{let c=$(),u=t((h,k)=>e.ui.notify(h,k),"notify"),g=c.agent.extensionEnabled,v={id:"extensionEnabled",label:"Enabled",currentValue:g?"ON":"OFF",values:["ON","OFF"],description:g?"Unload the cowboy tools and stop subagent-result notifications. Persisted; active agents keep working.":"cowboy tools are unloaded and the rest of this menu is hidden. Active agents keep working."};return g?[fn({ctx:e,store:c,theme:s,harnessModelOptions:n,piDefaultThinking:o}),An({store:c,theme:s,notify:u}),In({store:c,theme:s,notify:u}),be("status","Status","List spawned, queued and settled agents",l),be("spawn","Spawn agent","Manually spawn a new agent",l),be("settings","Settings","Concurrency, agent behavior, and system prompt settings",l),v]:[v]},"buildItems"),d=new Gn(a(),10,_(s),(c,u)=>{let g=c==="extensionEnabled";if(g){let v=u==="ON";Jt(e.ui,v),e.ui.notify(v?"pi-cowboy enabled":"pi-cowboy disabled","info")}r?.(a(),g?"extensionEnabled":void 0)},i);return new H(d,{title:"Agents",theme:s,onCancel:i,onRebuild:t(c=>{r=c},"onRebuild")})})}t(Rr,"showAgentsMainList");async function ma(e,n){for(;;){let o=await Rr(e,n);if(o===void 0)return;await Pr(e,o,n)}}t(ma,"showAgentsMainMenu");export{Pr as showAgentsActionMenu,ma as showAgentsMainMenu,Er as showSettingsMenu,Kn as showSpawnAgentMenu};
|
|
9
|
-
//# sourceMappingURL=menus-
|
|
9
|
+
//# sourceMappingURL=menus-KXKDXZRN.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as E,b as R,i as A}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=model-picker-
|
|
1
|
+
import{a as E,b as R,i as A}from"./chunk-MZROKRT4.js";import{ha as v,ia as u,la as c,va as S,wa as k}from"./chunk-M42XWVYW.js";import{a as s,e as w,f as m,u as h,v as C}from"./chunk-J5TU3AFX.js";import{ModelSelectorComponent as L}from"@earendil-works/pi-coding-agent";import{fuzzyFilter as $}from"@earendil-works/pi-tui";function b(e,t,n){let o=`${n.provider}/${n.id}`;e.mutate.session.setOverride("default",o),t.ui.notify(`Subagent model set to ${o} (session)`,"info")}s(b,"applySessionDefault");function D(e){let t=c(),o=u().model??e.model,d=o?`${o.provider}/${o.id}`:null,r=t.sessionDefaultModel??t.agentConfigSnapshot().default??d;return r?m(r,e.modelRegistry,e.model):void 0}s(D,"currentSubagentModel");function O(e){let t=e.modelRegistry.runtime;return t&&typeof t.getAvailableSnapshot=="function"?t:void 0}s(O,"sessionModelRuntime");async function z(e,t){let n=c(),o=O(e),d=e.scopedModels,r=o?[]:await x(e);await new R(e).open(({tui:p,theme:f,close:l})=>{let i=D(e);if(!o){let y=u().modelRegistry,I=r.map(a=>a.key),P=A(I,i?.id??null,[]).filter(a=>a.value!=null);return new E(P,i?`${i.provider}/${i.id}`:null,{onSelect:s(a=>{let M=m(a,y,void 0);M&&b(n,e,M),l()},"onSelect"),onCancel:s(()=>l(),"onCancel")},f)}return new L(p,i,o,d,y=>{b(n,e,y),l()},()=>l(),t?.initialSearch)})}s(z,"openSubagentModelPicker");async function G(e){let n=e.trim();if(n==="model"||n.startsWith("model ")){let r=n.slice(5).trim(),p=await H(),f=[{value:"model clear",label:"clear",description:"Clear the session model override (the configured chain decides)"},...p.map(i=>{let g=w(i.key);return{value:`model ${i.key}`,label:g?.modelId??i.key,description:g?.provider??""}})],l=$(f,r,i=>`${i.label} ${i.description??""} ${i.value}`);return l.length>0?l:null}let d=$([{value:"status",label:"status",description:"List spawned, queued and settled agents"},{value:"spawn",label:"spawn",description:"Open the spawn wizard"},{value:"worktree",label:"worktree",description:"Create a git worktree with no agent attached"},{value:"model",label:"model",description:"Set the model sub-agents use (opens pi's model picker)"},{value:"enable",label:"enable",description:"Enable pi-cowboy"},{value:"disable",label:"disable",description:"Disable pi-cowboy"}],n,r=>r.label);return d.length>0?d:null}s(G,"cowboyCompletions");async function x(e){try{let t=await S().require("pi").listModels({pi:v(),modelCatalog:k(e.modelRegistry)}),n=C(t);return n!==void 0&&e.hasUI&&e.ui.notify(n,"warning"),h(t)}catch{return[]}}s(x,"piHarnessModels");async function H(){return await x(u())}s(H,"availableModelsForCompletion");async function J(e,t){let n=c();if(e==="clear"){n.mutate.session.clearOverride("default"),t.ui.notify("Subagent model override cleared (session) \u2014 the configured chain decides","info");return}if(e!==""){let o=m(e,t.modelRegistry,void 0);if(o){b(n,t,o);return}}await z(t,e!==""?{initialSearch:e}:void 0)}s(J,"handleModelArg");export{G as cowboyCompletions,J as handleModelArg,z as openSubagentModelPicker};
|
|
2
|
+
//# sourceMappingURL=model-picker-FMMQY4KI.js.map
|
|
@@ -21,6 +21,7 @@ export interface SubagentsConfig {
|
|
|
21
21
|
worktreeRoot?: string;
|
|
22
22
|
worktreeMaterialization?: WorktreeMaterialization;
|
|
23
23
|
worktreeCheckoutType?: WorktreeCheckoutType;
|
|
24
|
+
handoverMaxExcludedRatio?: number;
|
|
24
25
|
harnessType?: AnyHarnessId;
|
|
25
26
|
defaultModelByHarness?: Record<string, string | null>;
|
|
26
27
|
[agentType: string]: string | null | undefined | boolean | number | Record<string, string | null>;
|
|
@@ -11,8 +11,14 @@ export type ModelRequest = {
|
|
|
11
11
|
key: string;
|
|
12
12
|
};
|
|
13
13
|
export declare function readModelKey(value: unknown): string | undefined;
|
|
14
|
-
export
|
|
15
|
-
|
|
14
|
+
export interface ModelRequestParams {
|
|
15
|
+
readonly model?: unknown;
|
|
16
|
+
readonly thinking?: unknown;
|
|
17
|
+
readonly _configuredModel?: unknown;
|
|
18
|
+
readonly _configuredThinking?: unknown;
|
|
19
|
+
}
|
|
20
|
+
export declare function readThinkingRequest(params: ModelRequestParams): string | undefined;
|
|
21
|
+
export declare function readModelRequest(params: ModelRequestParams): ModelRequest | undefined;
|
|
16
22
|
export type ResolvedModel = {
|
|
17
23
|
kind: "resolved";
|
|
18
24
|
model: Model<Api>;
|
package/dist/plugin/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { CowboyPluginApi, CowboyPluginDisposer, CowboyPluginFactory, PluginMultiplexer, PluginHarness, } from "./contract.js";
|
|
2
|
-
export type { AnyHarnessId, Harness, HarnessAvailability, HarnessConfigCodec, HarnessConfigIssue, HarnessConfigLayers, HarnessConfigReport, HarnessListModelsRequest, HarnessPrepareRequest, HarnessTeardownContext, HarnessTeardownRequest, ModelEntry, ModelList, SubagentLaunchInputs, ThinkingLevels, ToolSelection, } from "../agents/harness.js";
|
|
2
|
+
export type { AnyHarnessId, Harness, HarnessAvailability, HarnessConfigCodec, HarnessConfigIssue, HarnessConfigLayers, HarnessConfigReport, HarnessListModelsRequest, HarnessExportRequest, HandoverRecord, HandoverRecordSource, HarnessPrepareRequest, HarnessStop, HarnessStopRequest, HarnessTeardownContext, HarnessTeardownRequest, ModelEntry, ModelList, ReadHandoverRecords, SessionExportTurn, SubagentLaunchInputs, ThinkingLevels, ToolSelection, } from "../agents/harness.js";
|
|
3
3
|
export { modelListEntries, modelListNotice } from "../agents/harness.js";
|
|
4
4
|
export { launchEnvBody, singleQuoteShellWord, } from "../agents/harness/pane-launcher.js";
|
|
5
5
|
export { isReservedEnvVar, isUniversalReservedEnvVar, reservedEnvVarsOf, RESERVED_ENV_VARS_BY_FAMILY, } from "../agents/harness.js";
|
package/dist/plugin/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{p as e,q as s,r as n,s as
|
|
1
|
+
import{p as e,q as s,r as n,s as r,u as o,v as t,x as a,y as i}from"../chunk-J5TU3AFX.js";export{r as RESERVED_ENV_VARS_BY_FAMILY,s as isReservedEnvVar,e as isUniversalReservedEnvVar,i as launchEnvBody,o as modelListEntries,t as modelListNotice,n as reservedEnvVarsOf,a as singleQuoteShellWord};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/predicates.d.ts
CHANGED
package/dist/registration.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import type { ExtensionAPI, ExtensionUIContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { type CowboyAgentParams } from "./agents/schemas/cowboy-agents.schema.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
readonly mergeBranch: "merge_cowboy_branch";
|
|
7
|
-
readonly steerAgent: "steer_cowboy_agent";
|
|
8
|
-
readonly cleanupAgent: "cleanup_cowboy_agent";
|
|
9
|
-
};
|
|
10
|
-
export declare const COWBOY_TOOL_NAMES: readonly string[];
|
|
3
|
+
import { COWBOY_TOOL_NAMES, COWBOY_TOOLS } from "./cowboy-tools.js";
|
|
4
|
+
export { COWBOY_TOOLS, COWBOY_TOOL_NAMES };
|
|
5
|
+
export declare const REGISTERED_TOOL_NAMES: readonly string[];
|
|
11
6
|
export declare function registerAgentTool(pi: ExtensionAPI): void;
|
|
12
7
|
export type { CowboyAgentParams };
|
|
13
8
|
export declare function setExtensionEnabled(ui: ExtensionUIContext, enabled: boolean): void;
|
package/dist/spawn/sandbox.d.ts
CHANGED
|
@@ -49,6 +49,28 @@ type SandboxState = {
|
|
|
49
49
|
kind: "teardown-failed";
|
|
50
50
|
detail: string;
|
|
51
51
|
};
|
|
52
|
+
export interface OwnedCheckoutRequest {
|
|
53
|
+
readonly pi: ExtensionAPI;
|
|
54
|
+
readonly host: AgentHost;
|
|
55
|
+
readonly parentCwd: string;
|
|
56
|
+
readonly spawnId: string;
|
|
57
|
+
readonly agentType: string;
|
|
58
|
+
readonly taskSlug: string | undefined;
|
|
59
|
+
readonly worktreeRoot: string | undefined;
|
|
60
|
+
readonly materialization: WorktreeMaterialization;
|
|
61
|
+
readonly notify: (message: string, kind: "warning") => void;
|
|
62
|
+
}
|
|
63
|
+
export type OwnedCheckout = {
|
|
64
|
+
readonly kind: "owned";
|
|
65
|
+
readonly hostRef: AgentHostRef;
|
|
66
|
+
readonly worktree: {
|
|
67
|
+
readonly path: string;
|
|
68
|
+
readonly branch: string;
|
|
69
|
+
};
|
|
70
|
+
} | {
|
|
71
|
+
readonly kind: "parent-cwd";
|
|
72
|
+
};
|
|
73
|
+
export declare function provisionOwnedCheckout(request: OwnedCheckoutRequest): Promise<OwnedCheckout>;
|
|
52
74
|
export declare class AgentSandbox {
|
|
53
75
|
readonly branch: string;
|
|
54
76
|
readonly projectTrusted: boolean;
|
|
@@ -25,6 +25,7 @@ export interface ProcessSupervisor {
|
|
|
25
25
|
}
|
|
26
26
|
export interface ProcessSupervisorOptions {
|
|
27
27
|
pollMs?: number;
|
|
28
|
+
stopProcess?: (ref: AgentHostRef, timeoutMs: number) => Promise<boolean>;
|
|
28
29
|
stopInitiator?: StopInitiator;
|
|
29
30
|
onFollowUp?: (deliverable: string) => void;
|
|
30
31
|
}
|
|
@@ -34,6 +35,7 @@ export declare class ProcessSupervisorEngine implements ProcessSupervisor {
|
|
|
34
35
|
private readonly pollMs;
|
|
35
36
|
private readonly stopInitiator;
|
|
36
37
|
private readonly onFollowUp;
|
|
38
|
+
private readonly stopProcess;
|
|
37
39
|
private phase;
|
|
38
40
|
private outcome;
|
|
39
41
|
private readonly settlement;
|
package/dist/types.d.ts
CHANGED
|
@@ -157,9 +157,20 @@ interface AgentDisplayInfo {
|
|
|
157
157
|
export interface AgentLaunchState {
|
|
158
158
|
resultFile: string;
|
|
159
159
|
}
|
|
160
|
+
export interface EngagedRun {
|
|
161
|
+
readonly harness: AnyHarnessId;
|
|
162
|
+
readonly host: AgentHostRef;
|
|
163
|
+
readonly cwd: string | null;
|
|
164
|
+
}
|
|
165
|
+
export interface EndedRun extends EngagedRun {
|
|
166
|
+
readonly sessionId: string;
|
|
167
|
+
readonly startedAt: number;
|
|
168
|
+
readonly endedAt: number;
|
|
169
|
+
}
|
|
160
170
|
export interface AgentExecutionState {
|
|
161
171
|
host?: AgentHostRef;
|
|
162
172
|
harness?: AnyHarnessId;
|
|
173
|
+
history: EndedRun[];
|
|
163
174
|
promise: Promise<string>;
|
|
164
175
|
spawnCtx?: ExtensionContext;
|
|
165
176
|
abortController: AbortController;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-cowboy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"packageManager": "pnpm@12.9.1",
|
|
6
6
|
"description": "Agent orchestrator for pi: can manage Codex, Claude Code, OpenCode, pi, pig and pi-bolt as subagents. Runs subagents in background Herdr panes, isolated in copy-on-write Git worktrees.",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"eslint-plugin-import-x": "^4.17.1",
|
|
102
102
|
"husky": "^9.1.7",
|
|
103
103
|
"oxlint": "1.89.0",
|
|
104
|
-
"oxlint-tsgolint": "7.0.
|
|
104
|
+
"oxlint-tsgolint": "7.0.2005",
|
|
105
105
|
"prettier": "^3.9.9",
|
|
106
106
|
"semantic-release": "^25.0.9",
|
|
107
107
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
package/dist/chunk-254PTGN5.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var u=Object.defineProperty;var r=(e,n)=>u(e,"name",{value:n,configurable:!0});function S(e){return!e||e.length>128||!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(e)}r(S,"isUnsafeName");function p(e){return e.replace(/[\r\n]+/g," ").trim()}r(p,"toSingleLine");function i(e){return new Promise(n=>setTimeout(n,e))}r(i,"sleep");function A(e){return p(e instanceof Error?e.message:String(e))}r(A,"errorMessage");function y(e){if(typeof e!="string")return null;let n=e.indexOf("/");return n<=0?null:{provider:e.slice(0,n),modelId:e.slice(n+1)}}r(y,"parseModelKey");function H(e,n,t){if(!e)return t;let o=y(e);return o?n.find(o.provider,o.modelId)??t:t}r(H,"findModelInRegistry");function M(e){if(e)return"model"in e?e.model.id:"harness"in e?e.name:void 0}r(M,"modelChoiceName");function N(e){return e!=null&&"key"in e?e.key:void 0}r(N,"modelChoiceKey");var O=5e3;function v(e){throw new Error(`Unhandled variant: ${JSON.stringify(e)}`)}r(v,"assertNever");var c=["pi","pig","pi-bolt","opencode","codex","claude"];var g=["pi","pig","pi-bolt"];function k(e){return g.some(n=>n===e)}r(k,"isPiFamilyHarness");function b(e){return c.find(n=>n===e)}r(b,"parseHarnessId");var f=["PATH","HOME","SHELL","PWD","OLDPWD","IFS","CDPATH","GLOBIGNORE","PS1","PS2","PS3","PS4","BASH_ENV","ENV","NODE_OPTIONS","LD_PRELOAD","LD_AUDIT"],E=["DYLD_","HERDR_","COWBOY_"],s=Object.freeze([]),x=/^[A-Za-z_][A-Za-z0-9_]*$/;function w(e){return x.test(e)}r(w,"isEnvVarName");function F(e){return new RegExp("\\p{Cc}","u").test(e)}r(F,"hasControlCharacter");function L(e){return f.includes(e)||E.some(n=>e.startsWith(n))}r(L,"isUniversalReservedEnvVar");function q(e,n=s){return L(e)||n.includes(e)}r(q,"isReservedEnvVar");function V(e){return e.reservedEnvVars?.()??s}r(V,"reservedEnvVarsOf");var U={pi:["PI_CODING_AGENT_DIR","PI_CODING_AGENT_SESSION_DIR","HERDR_AGENT"],opencode:["OPENCODE_CONFIG_DIR","OPENCODE_CONFIG","OPENCODE_CONFIG_CONTENT","OPENCODE_DISABLE_PROJECT_CONFIG","OPENCODE_DISABLE_AUTOUPDATE"],codex:["CODEX_HOME"],claude:["CLAUDE_CONFIG_DIR","CLAUDE_SECURESTORAGE_CONFIG_DIR","CLAUDE_CODE_DISABLE_CLAUDE_MDS","ANTHROPIC_API_KEY","COWBOY_API_KEY"]};function $(e){return e.kind==="unavailable"?[]:e.entries}r($,"modelListEntries");function G(e){return e.kind==="listed"?void 0:e.notice}r(G,"modelListNotice");function m(e){return`'${e.replaceAll("'","'\\''")}'`}r(m,"singleQuoteShellWord");function j(e,n){return e===null?n:`( . ${m(e)} && { ${n}; } )`}r(j,"launchEnvBody");var d=5,_=2e3,I=250;function P(e){let n=e.indexOf("_");return n===-1?e:`${e.slice(0,n+1)}""${e.slice(n+1)}`}r(P,"splitMarker");async function W(e,n,t){let o=`${t.commandName}() { : "${t.signature}"; ${t.body}; }`,l=`typeset -f ${t.commandName} 2>/dev/null | grep -q "${t.signature}" && echo ${P(t.readyMarker)}`;for(let a=1;a<=d;a++){if(await e.run(n,o),await e.run(n,l),await R(e,n,t.readyMarker,_)){t.proof!==void 0&&await C(e,n,t.proof);return}a<d&&await i(I)}throw new Error(`failed to prepare pane ${n}: the ${t.commandName} launcher never landed`)}r(W,"installPaneLauncher");async function R(e,n,t,o){try{return await e.waitForOutput(n,t,o),!0}catch{return!1}}r(R,"panePrinted");async function C(e,n,t){await e.run(n,t.command);try{await e.waitForOutput(n,t.output,t.timeoutMs)}catch{throw new Error(t.failure)}}r(C,"requirePaneProof");export{r as a,S as b,i as c,A as d,y as e,H as f,M as g,N as h,O as i,v as j,c as k,k as l,b as m,w as n,F as o,L as p,q,V as r,U as s,$ as t,G as u,m as v,j as w,P as x,W as y};
|
|
2
|
-
//# sourceMappingURL=chunk-254PTGN5.js.map
|