pi-cowboy 0.29.0 → 0.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/harness/opencode/session-export.d.ts +0 -26
- package/dist/agents/harness/opencode/staging.d.ts +2 -0
- package/dist/{chunk-ZKIMQHX3.js → chunk-FG6EPDPT.js} +2 -2
- package/dist/{chunk-MH6MGDZZ.js → chunk-GQCYX6VD.js} +2 -2
- package/dist/{chunk-QJGNUIRH.js → chunk-HJRZSWB4.js} +3 -3
- package/dist/chunk-LTAAWA6Q.js +54 -0
- package/dist/{chunk-D7UZYABH.js → chunk-VQ2JXCQB.js} +2 -2
- package/dist/index.js +1 -1
- package/dist/{menu-worktree-command-76YXH6XZ.js → menu-worktree-command-J7U2NV6J.js} +2 -2
- package/dist/{menus-ZGFQDRCE.js → menus-AMT4U7FK.js} +2 -2
- package/dist/{model-picker-EPZ4PLUV.js → model-picker-SXUEGCKV.js} +2 -2
- package/package.json +3 -3
- package/dist/chunk-K63J25IC.js +0 -53
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
1
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
3
2
|
import { type HandoverRecord, type HandoverRecordSource } from "../../harness.js";
|
|
4
|
-
declare const OpencodeSessionSummarySchema: z.ZodObject<{
|
|
5
|
-
id: z.ZodString;
|
|
6
|
-
agent: z.ZodOptional<z.ZodString>;
|
|
7
|
-
model: z.ZodOptional<z.ZodObject<{
|
|
8
|
-
id: z.ZodString;
|
|
9
|
-
providerID: z.ZodString;
|
|
10
|
-
}, z.core.$strip>>;
|
|
11
|
-
time: z.ZodObject<{
|
|
12
|
-
updated: z.ZodNumber;
|
|
13
|
-
}, z.core.$strip>;
|
|
14
|
-
location: z.ZodObject<{
|
|
15
|
-
directory: z.ZodString;
|
|
16
|
-
}, z.core.$strip>;
|
|
17
|
-
}, z.core.$strip>;
|
|
18
|
-
export type OpencodeSessionSummary = z.infer<typeof OpencodeSessionSummarySchema>;
|
|
19
3
|
export interface OpencodeSessionExport {
|
|
20
4
|
readonly sessionId: string;
|
|
21
5
|
readonly messages: readonly unknown[];
|
|
@@ -23,17 +7,7 @@ export interface OpencodeSessionExport {
|
|
|
23
7
|
export interface OpencodeSessionExportRequest {
|
|
24
8
|
readonly pi: ExtensionAPI;
|
|
25
9
|
readonly subagentId: string;
|
|
26
|
-
readonly cwd: string;
|
|
27
|
-
readonly proofModel: string;
|
|
28
10
|
}
|
|
29
|
-
export declare function opencodeSessionListPath(cwd: string): string;
|
|
30
|
-
export declare function parseOpencodeSessionList(stdout: string): readonly OpencodeSessionSummary[] | undefined;
|
|
31
|
-
export declare function selectOpencodeRunSession(sessions: readonly OpencodeSessionSummary[], input: {
|
|
32
|
-
readonly cwd: string;
|
|
33
|
-
readonly subagentId: string;
|
|
34
|
-
readonly proofModel: string;
|
|
35
|
-
}): OpencodeSessionSummary | undefined;
|
|
36
11
|
export declare function parseOpencodeSessionExport(stdout: string): OpencodeSessionExport | undefined;
|
|
37
12
|
export declare function classifyOpencodeMessages(messages: readonly unknown[]): Iterable<HandoverRecord>;
|
|
38
13
|
export declare function readOpencodeSessionRecords(request: OpencodeSessionExportRequest): Promise<HandoverRecordSource>;
|
|
39
|
-
export {};
|
|
@@ -3,8 +3,10 @@ import type { OpencodeConfigRoot } from "./config.js";
|
|
|
3
3
|
export interface OpencodeStaging {
|
|
4
4
|
readonly configDir: string;
|
|
5
5
|
readonly explicitConfigFile?: string;
|
|
6
|
+
readonly sessionId: string;
|
|
6
7
|
}
|
|
7
8
|
export declare function opencodeConfigDir(subagentId: string): string;
|
|
9
|
+
export declare function opencodeSessionRecordFile(configDir: string): string;
|
|
8
10
|
export declare function writeOpencodeStaging(input: {
|
|
9
11
|
subagentId: string;
|
|
10
12
|
systemPromptFile: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{h as l,n as h}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{h as l,n as h}from"./chunk-GQCYX6VD.js";import{a as r}from"./chunk-KOCSQ3ZV.js";import{isFocusable as c}from"@earendil-works/pi-tui";var g=new Map([["\x1B[C","\r"],["\x1BOC","\r"],["\x1B[D","\x1B"],["\x1BOD","\x1B"]]),p=class{static{r(this,"SettingsListWrapper")}settingsList;title;theme;separatorChar;passthroughKeys;constructor(t,e){this.settingsList=e.passthroughKeys?t:h(t),this.title=e.title,this.theme=e.theme,this.separatorChar=e.separatorChar??"\u2500",this.passthroughKeys=e.passthroughKeys??!1;let n=this.settingsList;if(e.onCancel&&!n.onCancel){let s=e.onCancel;n.onCancel=()=>s()}if(e.onCancel&&l(n),e.onRebuild){let s=r((o,m)=>{n.items=o,n.filteredItems=o,n.submenuComponent=null;let a=o.findIndex(u=>u.id===m);n.selectedIndex=a>0?a:0},"rebuild");e.onRebuild(s)}}invalidate(){this.settingsList.invalidate()}get submenuComponent(){return this.settingsList.submenuComponent??null}get hasSubmenu(){return c(this.submenuComponent)}handleInput(t){if(this.passthroughKeys||this.hasSubmenu){this.settingsList.handleInput?.(t);return}let e=g.get(t);if(e!==void 0){this.settingsList.handleInput?.(e);return}this.settingsList.handleInput?.(t)}render(t){let e=[];e.push(this.separatorChar.repeat(t)),e.push("");let n=this.theme.bold(this.theme.fg("accent",this.title));e.push(" "+n),e.push("");let s=this.settingsList.render(t),o=/Enter\/Space|Esc to cancel/;return s.length>=2&&o.test(s[s.length-1]??"")?e.push(...s.slice(0,-2)):e.push(...s),e.push(""),e.push(this.separatorChar.repeat(t)),e}};import{Input as d}from"@earendil-works/pi-tui";function f(i){let t=i.codePointAt(0)??0;return t<32||t===127||t>=128&&t<=159}r(f,"isControlCharacter");function S(i){let t=new d;t.focused=!0;for(let e of i.prefill)f(e)||t.handleInput(e);return t.onSubmit=e=>{let n=e.trim(),s=i.validate(n);if(s){i.notify(i.describeProblem(s),"error");return}i.onDone(n)},t.onEscape=()=>i.onCancel(),t}r(S,"createNameField");export{S as a,p as b};
|
|
2
|
+
//# sourceMappingURL=chunk-FG6EPDPT.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Ca as x}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{Ca as x}from"./chunk-LTAAWA6Q.js";import{a as s,h as f,s as C}from"./chunk-KOCSQ3ZV.js";import{Container as y,fuzzyFilter as M,getKeybindings as N,Input as k,Spacer as v,Text as b}from"@earendil-works/pi-tui";import{DynamicBorder as w}from"@earendil-works/pi-coding-agent";var h=10,g=class extends y{static{s(this,"SearchableSelectDialog")}searchInput;listContainer;items;filteredItems;selectedIndex;currentValue;callbacks;theme;_focused=!1;get focused(){return this._focused}set focused(e){this._focused=e,this.searchInput.focused=e}constructor(e,n,r,l){super(),this.items=e,this.currentValue=n,this.callbacks=r,this.theme=l,this.filteredItems=[...e];let a=e.findIndex(o=>o.value===n);this.selectedIndex=a>=0?a:0,this.addChild(new w),this.addChild(new v(1)),this.searchInput=new k,this.searchInput.onSubmit=()=>{this.filteredItems[this.selectedIndex]&&this.callbacks.onSelect(this.filteredItems[this.selectedIndex].value)},this.addChild(this.searchInput),this.addChild(new v(1)),this.listContainer=new y,this.addChild(this.listContainer),this.addChild(new v(1)),this.addChild(new w),this.updateList()}handleInput(e){let n=N();if(!(this.filteredItems.length===0&&(n.matches(e,"tui.select.up")||n.matches(e,"tui.select.down")||n.matches(e,"tui.select.pageUp")||n.matches(e,"tui.select.pageDown")))){if(n.matches(e,"tui.select.up")){this.selectedIndex=this.selectedIndex===0?this.filteredItems.length-1:this.selectedIndex-1,this.updateList();return}if(n.matches(e,"tui.select.down")){this.selectedIndex=this.selectedIndex===this.filteredItems.length-1?0:this.selectedIndex+1,this.updateList();return}if(n.matches(e,"tui.select.pageUp")){this.selectedIndex=Math.max(0,this.selectedIndex-h),this.updateList();return}if(n.matches(e,"tui.select.pageDown")){this.selectedIndex=Math.min(this.filteredItems.length-1,this.selectedIndex+h),this.updateList();return}if(n.matches(e,"tui.select.confirm")){let r=this.filteredItems.at(this.selectedIndex);r&&this.callbacks.onSelect(r.value);return}if(n.matches(e,"tui.select.cancel")){this.callbacks.onCancel();return}this.searchInput.handleInput(e),this.filterItems()}}invalidate(){}filterItems(){let e=this.searchInput.getValue();e?this.filteredItems=M(this.items,e,n=>`${n.label} ${n.provider} ${n.value??""}`):this.filteredItems=[...this.items],this.selectedIndex=Math.min(this.selectedIndex,Math.max(0,this.filteredItems.length-1)),this.updateList()}updateList(){this.listContainer.clear();let{filteredItems:e}=this;if(e.length===0){this.listContainer.addChild(new b(this.theme.fg("muted"," No matching items"),0,0));return}let n=Math.max(0,Math.min(this.selectedIndex-Math.floor(h/2),e.length-h)),r=Math.min(n+h,e.length);for(let l=n;l<r;l++){let a=e.at(l);if(!a)continue;let o=l===this.selectedIndex,d=a.value===this.currentValue,c=o?this.theme.fg("accent","\u2192 ")+this.theme.fg("accent",a.label):` ${a.label}`,i=a.provider?this.theme.fg("muted",`[${a.provider}]`):"",u=d?this.theme.fg("success"," \u2713"):"",m=`${c} ${i}${u}`;this.listContainer.addChild(new b(m,0,0))}if(n>0||r<e.length){let l=this.theme.fg("muted",` (${this.selectedIndex+1}/${e.length})`);this.listContainer.addChild(new b(l,0,0))}}};import{isFocusable as L}from"@earendil-works/pi-tui";var O=class{constructor(e){this.ctx=e}ctx;static{s(this,"ScreenHost")}async open(e){return await this.show(e,!1)}async openOverlay(e){return await this.show(e,!0)}async show(e,n){if(x(this.ctx))return await new Promise(r=>{this.ctx.ui.custom((l,a,o,d)=>e({tui:l,theme:a,keybindings:o,close:s(c=>{x(this.ctx)&&d(c),r(c)},"close")}),n?{overlay:!0}:void 0).then(r)})}},j=void 0;function K(t){return Object.assign(t,{focused:!0})}s(K,"asSubmenuComponent");var I=class{static{s(this,"SwappableView")}active;constructor(e){this.active=e}activate(e){this.active=e}invalidate(){this.active.invalidate()}render(e){return this.active.render(e)}handleInput(e){this.active.handleInput?.(e)}get focused(){return L(this.active)?this.active.focused:!1}set focused(e){L(this.active)&&(this.active.focused=e)}};var F="group-header";function q(t,e){return{id:T,kind:F,label:t.bold(t.fg("accent",e)),currentValue:""}}s(q,"headerItem");var T="__sep__",p=new WeakMap;function X(t){if(!Array.isArray(t.items))return;let e=s(o=>o?.value===T||o?.id===T,"isSep"),n=s((o,d,c)=>{let i=d+c;for(;i>=0&&i<o.length&&e(o[i]);)i+=c;return i},"firstNonSepFrom"),r=s((o,d)=>d>=0&&d<o.length,"inBounds"),l=s((o,d)=>{let c=Math.max(0,Math.min(d,o.length-1));for(let i=c;i<o.length;i+=1)if(!e(o[i]))return i;for(let i=c-1;i>=0;i-=1)if(!e(o[i]))return i;return 0},"seedIndex"),a=t.selectedIndex??0;Object.defineProperty(t,"selectedIndex",{get(){return p.get(t)},set(o){let d=t.items,c=p.get(t)??0,i=Math.max(0,Math.min(o,d.length-1));if(!e(d[i])){p.set(t,i);return}let u=o>c?1:-1,m=n(d,i,u),S=n(d,i,-u);r(d,m)?p.set(t,m):r(d,S)?p.set(t,S):p.set(t,i)},configurable:!0}),p.set(t,l(t.items,a))}s(X,"installSeparatorSkip");function J(t,e,n){let r=[{value:null,label:"(none)",provider:""}],l=[];for(let i of t){let u=f(i);u&&l.push({value:i,label:u.modelId,provider:u.provider})}if(e===null&&n.length===0)return r.push(...l),r;let a=[],o=[],d=[],c=new Set;if(e){let i=f(e);i&&(a.push({value:e,label:i.modelId,provider:i.provider}),c.add(e))}for(let i of n){if(c.has(i))continue;let u=f(i);u&&(o.push({value:i,label:u.modelId,provider:u.provider}),c.add(i))}for(let i of l)i.value!=null&&!c.has(i.value)&&d.push(i);return r.push(...a,...o,...d),r}s(J,"buildModelOptions");function Q(t){let e=[];t.default&&typeof t.default=="string"&&e.push(t.default);for(let[n,r]of Object.entries(t))n!=="default"&&typeof r=="string"&&r.includes("/")&&e.push(r);return[...new Set(e)]}s(Q,"extractConfiguredModels");function Y(t,e){return C(t)?e:[]}s(Y,"mergedModelsForHarness");function Z(t){return{label:s((e,n)=>n?t.fg("accent",e):e,"label"),value:s((e,n)=>n?t.fg("accent",e):t.fg("muted",e),"value"),description:s(e=>t.fg("dim",e),"description"),cursor:t.fg("accent","\u2192 "),hint:s(e=>t.fg("dim",e),"hint")}}s(Z,"buildSettingsListTheme");function ee(t,e){let n=t.trim();if(!/^\d*\.?\d+$/.test(n))return;let r=parseFloat(n);if(!(r<e))return r}s(ee,"validateNumeric");var _=new Map([["k","\x1B[A"],["j","\x1B[B"]]);function te(t){let e=t,n=e.handleInput?.bind(e);return n&&(e.handleInput=r=>{let l=e.submenuComponent?void 0:_.get(r);n(l??r)}),t}s(te,"withVimKeys");function ne(t){return{selectedPrefix:s(()=>t.fg("accent","\u2192 "),"selectedPrefix"),selectedText:s(e=>t.fg("accent",e),"selectedText"),description:s(e=>t.fg("muted",e),"description"),scrollInfo:s(e=>t.fg("dim",e),"scrollInfo"),noMatch:s(e=>t.fg("dim",e),"noMatch")}}s(ne,"buildSelectListTheme");function ie(t,e,n){let r,l=new g(t,null,{onSelect:s(a=>{let o=e.onSelect(a);o&&r.activate(o)},"onSelect"),onCancel:e.onCancel},n);return r=new I(l),r}s(ie,"createSearchableSelect");function se(t){return t.length===1?`agent ${t[0]}`:`${t.length} agent(s)`}s(se,"agentSubject");export{g as a,O as b,j as c,K as d,I as e,q as f,T as g,X as h,J as i,Q as j,Y as k,Z as l,ee as m,te as n,ne as o,ie as p,se as q};
|
|
2
|
+
//# sourceMappingURL=chunk-GQCYX6VD.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as pt,B as gt,C as ht,D as Z,J,K as mt,M as ft,N as yt,O as ee,b as ot,c as st,e as it,g as at,k as xe,l as dt,p as lt,u as ct,v as X,w as ut}from"./chunk-D7UZYABH.js";import{Ba as rt,Ea as be,H as me,J as Xe,K as fe,N as ye,O as Ze,Q as Y,R as T,S as I,U as Je,Y as et,Z as tt,b as Le,ha as x,ia as z,j,ja as w,k as je,l as Ue,la as y,m as ge,ma as E,na as we,o as qe,oa as ve,qa as nt,ta as ke,ua as V,v as We,va as O,w as Fe,wa as N,x as Ke,y as Ge,ya as Q}from"./chunk-K63J25IC.js";import{D as K,E as G,a as r,g as $,i as he,j as Ye,m as ze,o as Ve,q as F,s as Qe}from"./chunk-KOCSQ3ZV.js";import{visibleWidth as Re}from"@earendil-works/pi-tui";var Ae="\u{1F920}",kt="\u{1F404}",an="\u{1F4A9}",dn=2,ln=1e3,te=Re(kt),cn="76;175;80";function un(e){return`\x1B[48;2;${cn}m${e}\x1B[49m`}r(un,"greenBackground");function bt(e){return e===0?0:Math.max(dn,Math.ceil(Math.sqrt(2*e)))}r(bt,"pastureEdge");function xt(e){return Array.from({length:e},()=>Array.from({length:e},()=>"empty"))}r(xt,"emptyPasture");function pn(e,t){let n=bt(e.cows+e.droppings),o=xt(n),i=Array.from({length:n*n},(s,d)=>d),a=[...Array.from({length:e.cows},()=>"cow"),...Array.from({length:e.droppings},()=>"dropping")];for(let s=0;s<a.length;s+=1){let d=s+Math.floor(t()*(i.length-s)),c=i[d];i[d]=i[s],i[s]=c,o[Math.floor(c/n)][c%n]=a[s]}return o}r(pn,"grazedPasture");function ne(e,t){let n=[];for(let o=0;o<e.length;o+=1)for(let i=0;i<e[o].length;i+=1)e[o][i]===t&&n.push({row:o,col:i});return n}r(ne,"cellsOf");function gn(e,t){return[{row:e.row-1,col:e.col},{row:e.row,col:e.col+1},{row:e.row+1,col:e.col},{row:e.row,col:e.col-1}].filter(({row:o,col:i})=>o>=0&&o<t&&i>=0&&i<t)}r(gn,"neighboursOf");function wt(e,t){return gn(e,t.length).filter(({row:n,col:o})=>t[n][o]==="empty")}r(wt,"openNeighboursOf");function hn(e,t){let n=ne(e,"cow").filter(d=>wt(d,e).length>0);if(n.length===0||t()>=.05)return e;let o=n[Math.floor(t()*n.length)],i=wt(o,e),a=i[Math.floor(t()*i.length)],s=e.map(d=>d.slice());return s[o.row][o.col]="empty",s[a.row][a.col]="cow",s}r(hn,"moveHerd");function vt(e,t,n,o){for(let i=0;i<n;i+=1){let a=ne(e,"empty"),s=a[Math.floor(o()*a.length)];e[s.row][s.col]=t}}r(vt,"placeAtRandom");function mn(e,t,n,o){let i=ne(e,"cow"),a=ne(e,"dropping"),s=i.length-t,d=a.length-n;for(;s>0&&d<0;){let c=i.pop();e[c.row][c.col]="dropping",s-=1,d+=1}for(;s>0;){let c=i.pop();e[c.row][c.col]="empty",s-=1}for(;d>0;){let c=a.pop();e[c.row][c.col]="empty",d-=1}vt(e,"cow",-s,o),vt(e,"dropping",-d,o)}r(mn,"reconcileCounts");function fn(e,t,n){if(e===null)return pn(t,n);let o=bt(t.cows+t.droppings),i=xt(o);for(let a=0;a<e.length&&a<o;a+=1)for(let s=0;s<e[a].length&&s<o;s+=1)i[a][s]=e[a][s];return mn(i,t.cows,t.droppings,n),i}r(fn,"reconcilePasture");var yn={anchor:"top-right",width:Re(Ae),get offsetX(){return E()?.cowboyOffsetX??0},nonCapturing:!0},wn={anchor:"top-right",offsetY:1,get width(){return E()?.pastureWidth??0},nonCapturing:!0};function vn(e){return e==="cow"?kt:e==="dropping"?an:" ".repeat(te)}r(vn,"cellText");function kn(e,t){return e.map(n=>t(n.map(vn).join("")))}r(kn,"drawnRows");function bn(){return ve().list(["spawned"]).length}r(bn,"liveAgentCount");function xn(){return ve().list(Ze).length}r(xn,"endedAgentCount");function An(){return{live:bn(),ended:xn()}}r(An,"agentCounts");function Sn(){return y().agent.grazingEnabled}r(Sn,"grazingEnabled");var Se=class{constructor(t,n,o,i,a){this.tui=t;this.countAgents=n;this.isGrazing=o;this.grass=i;this.random=a}tui;countAgents;isGrazing;grass;random;static{r(this,"PresenceMarker")}herd=null;cowboyHandle=null;pastureHandle=null;poll=null;disposed=!1;grazing=null;get cowboyWidth(){return Re(Ae)}get pastureWidth(){return this.drawnPasture().length*te}get cowboyOffsetX(){let t=this.drawnPasture().length;return t===0?0:Math.floor(t/2)*te-(t*te-this.cowboyWidth)}render(){return this.frame(),[Ae]}pastureRows(){return this.frame(),kn(this.drawnPasture(),this.grass)}invalidate(){}attachCowboy(t){this.cowboyHandle=t}attachPasture(t){this.pastureHandle=t}dispose(){let t=this.drawnPasture().length>0&&(this.cowboyHandle!==null||this.pastureHandle!==null);this.disposed=!0,this.poll!==null&&(clearInterval(this.poll),this.poll=null),this.cowboyHandle?.hide(),this.cowboyHandle=null,this.pastureHandle?.hide(),this.pastureHandle=null,t&&this.tui.requestRender(!0)}drawnPasture(){return this.herd===null||!this.isGrazing()?[]:this.herd.pasture}frame(){if(this.disposed)return;let t=this.isGrazing();this.herd===null?(this.herd=this.place(this.countAgents()),this.grazing=t):t!==this.grazing&&this.recount(),this.pollWhile(t)}pollWhile(t){!t&&this.poll!==null?(clearInterval(this.poll),this.poll=null):t&&this.poll===null&&(this.poll=setInterval(()=>this.recount(),ln))}recount(){let{live:t,ended:n}=this.countAgents(),o=this.isGrazing(),i=o!==this.grazing,a=(this.grazing??o)&&(this.herd?.pasture.length??0)>0;if(this.herd===null||t!==this.herd.liveAgents||n!==this.herd.endedAgents)this.herd=this.place({live:t,ended:n});else if(o&&!i)this.herd={...this.herd,pasture:hn(this.herd.pasture,this.random)};else if(!i)return;if(this.grazing=o,this.pollWhile(o),o||i){let s=a&&this.drawnPasture().length===0;this.tui.requestRender(s)}}place({live:t,ended:n}){return{liveAgents:t,endedAgents:n,pasture:fn(this.herd?.pasture??null,{cows:t,droppings:n},this.random)}}},Te=class{static{r(this,"PastureView")}render(){return E()?.pastureRows()??[]}invalidate(){}};function At(e){Ie(),e.custom(t=>{let n=new Se(t,An,Sn,un,Math.random);return we(n),n},{overlay:!0,overlayOptions:yn,onHandle:r(t=>E()?.attachCowboy(t),"onHandle")}),e.custom(()=>new Te,{overlay:!0,overlayOptions:wn,onHandle:r(t=>E()?.attachPasture(t),"onHandle")})}r(At,"showExtensionIndicator");function Ie(){let e=E();we(null),e?.dispose()}r(Ie,"hideExtensionIndicator");function re(){return y().agent.extensionEnabled}r(re,"isExtensionEnabled");function Tn(){return re()&&y().agent.showActiveIndicator}r(Tn,"isActiveIndicatorShown");function oe(e){Tn()?At(e):Ie()}r(oe,"syncExtensionIndicator");function Xr(e,t){y().mutate.agent.setShowActiveIndicator(t),oe(e)}r(Xr,"setShowActiveIndicator");import{Type as M}from"typebox";import{Text as Pr}from"@earendil-works/pi-tui";import{Type as h}from"typebox";var Rn="Task instructions for the agent. If the task requires code changes, the agent works in an isolated branch and will review and commit its changes upon approval. Do not instruct the agent to avoid committing when code modifications are needed.",In=`REQUIRED. Short 2-3 word task name (e.g. "fix login flow"). This single value names the agent's branch/tab/worktree/agent so you can recognize it at a glance, and the extension appends a unique spawn id so parallel spawns \u2014 and every entry in a batch \u2014 are always distinct. Limits: 3 words, 19 characters when slugged (lowercase, dashes). A longer name throws with the exact overshoot \u2014 retry with a shorter name. Missing name throws too. The same name twice in one call is rejected before anything spawns.`,En=`Optional model for THIS agent as "provider/model-id". Omit it, or pass null, to leave it unset and use the configured default for this session and agent type \u2014 the usual case, and never a value to guess at. Pass it when the user asked for a specific model for this task. When a previous attempt failed with a provider/model error, pass a different model here and instruct the agent in plain text to continue where the failed attempt left off. A model that is not in this session's registry fails the call before anything is spawned.`,On=`Optional harness that launches THIS agent, overriding the agent template's harness_type and the configured default harness. Available: the built-in harnesses (${F.join(", ")}) and any harness a plugin registered in this session. Omit it, or pass null, to leave it unset and use the agent template's harness_type, then the configured default \u2014 never pass a harness the user did not ask for. A harness this session did not register, or this machine cannot launch, fails the call before anything is spawned \u2014 unlike the configured default, an explicit request never falls back to pi.`,Cn=h.Object({prompt:h.String({description:Rn}),task_name:h.String({description:In}),agent_type:h.Optional(h.Union([h.String(),h.Null()])),model:h.Optional(h.Union([h.String(),h.Null()],{description:En})),harness_type:h.Optional(h.Union([h.String(),h.Null()],{description:On}))},{additionalProperties:!1,required:["prompt","task_name"]}),H=h.Object({agents:h.Array(Cn,{minItems:1}),run_in_background:h.Optional(h.Boolean())},{additionalProperties:!1,required:["agents"]});var m={agent:"cowboy_agent",stopAgent:"stop_cowboy_agent",mergeBranch:"merge_cowboy_branch",steerAgent:"steer_cowboy_agent",handoverAgent:"handover_cowboy_agent",cleanupAgent:"cleanup_cowboy_agent"},Ee=Object.values(m),b={type:"json_schema",strict:"prefer"};var Oe="_configuredModel",Ce="_configuredThinking";function D(e){return typeof e=="string"&&e.trim()!==""?e.trim():void 0}r(D,"readModelKey");function se(e){return D(e.thinking)??D(e[Ce])}r(se,"readThinkingRequest");function ie(e){let t=D(e.model);if(t)return{source:"call",key:t};let n=D(e[Oe]);if(n)return{source:"configured",key:n}}r(ie,"readModelRequest");function U(e){return{resolved:e===void 0?{kind:"none"}:{kind:"level",thinking:e},notices:[]}}r(U,"withoutModel");function ae(e){switch(e.kind){case"resolved":return{model:e.model,key:e.modelKey,thinking:e.thinking};case"foreign":return{harness:e.harness,key:e.modelKey,name:e.modelName,thinking:e.thinking};case"level":return{levelOnly:!0,thinking:e.thinking};case"none":return}}r(ae,"modelChoiceFor");function q(e){return`${e.provider}/${e.id}`}r(q,"modelKey");function _n(e,t){if(t!==void 0&&!fe.safeParse(t).success)return`Thinking level "${t}" is not recognized by Pi (valid: ${fe.options.join(", ")}); launching "${q(e)}" with "${t}".`}r(_n,"undeclaredLevelWarning");function St(e,t){let n=_n(e,t);return{resolved:{kind:"resolved",model:e,modelKey:q(e),thinking:t??null},notices:n===void 0?[]:[n]}}r(St,"resolvedModel");function Pn(e){return`No API key found for "${e}"`}r(Pn,"missingCredential");function Tt(e,t){let n;try{n=e.getProviderAuthStatus(t.provider)}catch(o){return{verdict:"inconclusive",reason:$(o)}}return!Ve(n)||typeof n.configured!="boolean"?{verdict:"inconclusive",reason:"the registry reported no credential status for the provider"}:n.configured?{verdict:"usable"}:{verdict:"unusable",reason:Pn(t.provider)}}r(Tt,"probeCredentials");function _e(e,t){return`${e}: ${t}. Nothing was spawned.`}r(_e,"refusal");function Pe(e,t){let{registry:n,parent:o,thinking:i}=t;if(!e){if(!o)return U(i);let d=Tt(n,o);if(d.verdict!=="unusable")return St(o,i);throw new Error(_e(`The parent session's model "${q(o)}" did not resolve credentials in this session`,d.reason))}let a=e.source==="call"?he(e.key,n,void 0):he(e.key,n,o);if(!a){if(e.source==="call")throw new Error(`Model "${e.key}" is not available in this session. Nothing was spawned.`);return U(i)}let s=Tt(n,a);if(s.verdict!=="unusable")return St(a,i);throw e.source==="call"?new Error(_e(`Model "${q(a)}" cannot authenticate in this session`,s.reason)):new Error(_e(`The subagent model "${q(a)}" for this configured default cannot authenticate in this session`,s.reason))}r(Pe,"resolvePiModel");async function Mn(e){try{return await e.listModels(e.harness)}catch{return[]}}r(Mn,"harnessModels");function $n(e,t,n){if(t===void 0||t.thinkingLevels.kind!=="closed")return;let{levels:o}=t.thinkingLevels;if(!o.includes(n))return o.length===0?`Model "${t.key}" (${e}) does not support thinking levels; launching with "${n}".`:`Thinking level "${n}" is not declared by ${e} model "${t.key}" (supported: ${o.join(", ")}); proceeding with "${n}".`}r($n,"undeclaredLevelWarning");async function Rt(e,t){if(!e)return U(t.thinking);let n=await Mn(t),o=n.find(a=>a.key===e.key),i=[];if(n.length>0&&!o&&i.push(`The ${t.harness} model list does not include "${e.key}"; launching with that key anyway.`),t.thinking!==void 0){let a=$n(t.harness,o,t.thinking);a!==void 0&&i.push(a)}return{resolved:{kind:"foreign",harness:t.harness,modelKey:e.key,modelName:o?.label??e.key,thinking:t.thinking??null},notices:i}}r(Rt,"resolveForeignModel");async function de(e,t){let{harness:n}=t;if(Qe(n))return Pe(e,{registry:t.registry,parent:t.parent,thinking:t.thinking});let o={harness:n,listModels:t.listModels,thinking:t.thinking};return Rt(e,o)}r(de,"resolveSpawnModel");function B(e,t,n){return{content:[{type:"text",text:t}],details:{...n,severity:e}}}r(B,"resultWithSeverity");function le(e){return e.includes("error")?"error":e.includes("warning")?"warning":"success"}r(le,"foldSeverity");var Me=`
|
|
1
|
+
import{A as pt,B as gt,C as ht,D as Z,J,K as mt,M as ft,N as yt,O as ee,b as ot,c as st,e as it,g as at,k as xe,l as dt,p as lt,u as ct,v as X,w as ut}from"./chunk-VQ2JXCQB.js";import{Ba as rt,Ea as be,H as me,J as Xe,K as fe,N as ye,O as Ze,Q as Y,R as T,S as I,U as Je,Y as et,Z as tt,b as Le,ha as x,ia as z,j,ja as w,k as je,l as Ue,la as y,m as ge,ma as E,na as we,o as qe,oa as ve,qa as nt,ta as ke,ua as V,v as We,va as O,w as Fe,wa as N,x as Ke,y as Ge,ya as Q}from"./chunk-LTAAWA6Q.js";import{D as K,E as G,a as r,g as $,i as he,j as Ye,m as ze,o as Ve,q as F,s as Qe}from"./chunk-KOCSQ3ZV.js";import{visibleWidth as Re}from"@earendil-works/pi-tui";var Ae="\u{1F920}",kt="\u{1F404}",an="\u{1F4A9}",dn=2,ln=1e3,te=Re(kt),cn="76;175;80";function un(e){return`\x1B[48;2;${cn}m${e}\x1B[49m`}r(un,"greenBackground");function bt(e){return e===0?0:Math.max(dn,Math.ceil(Math.sqrt(2*e)))}r(bt,"pastureEdge");function xt(e){return Array.from({length:e},()=>Array.from({length:e},()=>"empty"))}r(xt,"emptyPasture");function pn(e,t){let n=bt(e.cows+e.droppings),o=xt(n),i=Array.from({length:n*n},(s,d)=>d),a=[...Array.from({length:e.cows},()=>"cow"),...Array.from({length:e.droppings},()=>"dropping")];for(let s=0;s<a.length;s+=1){let d=s+Math.floor(t()*(i.length-s)),c=i[d];i[d]=i[s],i[s]=c,o[Math.floor(c/n)][c%n]=a[s]}return o}r(pn,"grazedPasture");function ne(e,t){let n=[];for(let o=0;o<e.length;o+=1)for(let i=0;i<e[o].length;i+=1)e[o][i]===t&&n.push({row:o,col:i});return n}r(ne,"cellsOf");function gn(e,t){return[{row:e.row-1,col:e.col},{row:e.row,col:e.col+1},{row:e.row+1,col:e.col},{row:e.row,col:e.col-1}].filter(({row:o,col:i})=>o>=0&&o<t&&i>=0&&i<t)}r(gn,"neighboursOf");function wt(e,t){return gn(e,t.length).filter(({row:n,col:o})=>t[n][o]==="empty")}r(wt,"openNeighboursOf");function hn(e,t){let n=ne(e,"cow").filter(d=>wt(d,e).length>0);if(n.length===0||t()>=.05)return e;let o=n[Math.floor(t()*n.length)],i=wt(o,e),a=i[Math.floor(t()*i.length)],s=e.map(d=>d.slice());return s[o.row][o.col]="empty",s[a.row][a.col]="cow",s}r(hn,"moveHerd");function vt(e,t,n,o){for(let i=0;i<n;i+=1){let a=ne(e,"empty"),s=a[Math.floor(o()*a.length)];e[s.row][s.col]=t}}r(vt,"placeAtRandom");function mn(e,t,n,o){let i=ne(e,"cow"),a=ne(e,"dropping"),s=i.length-t,d=a.length-n;for(;s>0&&d<0;){let c=i.pop();e[c.row][c.col]="dropping",s-=1,d+=1}for(;s>0;){let c=i.pop();e[c.row][c.col]="empty",s-=1}for(;d>0;){let c=a.pop();e[c.row][c.col]="empty",d-=1}vt(e,"cow",-s,o),vt(e,"dropping",-d,o)}r(mn,"reconcileCounts");function fn(e,t,n){if(e===null)return pn(t,n);let o=bt(t.cows+t.droppings),i=xt(o);for(let a=0;a<e.length&&a<o;a+=1)for(let s=0;s<e[a].length&&s<o;s+=1)i[a][s]=e[a][s];return mn(i,t.cows,t.droppings,n),i}r(fn,"reconcilePasture");var yn={anchor:"top-right",width:Re(Ae),get offsetX(){return E()?.cowboyOffsetX??0},nonCapturing:!0},wn={anchor:"top-right",offsetY:1,get width(){return E()?.pastureWidth??0},nonCapturing:!0};function vn(e){return e==="cow"?kt:e==="dropping"?an:" ".repeat(te)}r(vn,"cellText");function kn(e,t){return e.map(n=>t(n.map(vn).join("")))}r(kn,"drawnRows");function bn(){return ve().list(["spawned"]).length}r(bn,"liveAgentCount");function xn(){return ve().list(Ze).length}r(xn,"endedAgentCount");function An(){return{live:bn(),ended:xn()}}r(An,"agentCounts");function Sn(){return y().agent.grazingEnabled}r(Sn,"grazingEnabled");var Se=class{constructor(t,n,o,i,a){this.tui=t;this.countAgents=n;this.isGrazing=o;this.grass=i;this.random=a}tui;countAgents;isGrazing;grass;random;static{r(this,"PresenceMarker")}herd=null;cowboyHandle=null;pastureHandle=null;poll=null;disposed=!1;grazing=null;get cowboyWidth(){return Re(Ae)}get pastureWidth(){return this.drawnPasture().length*te}get cowboyOffsetX(){let t=this.drawnPasture().length;return t===0?0:Math.floor(t/2)*te-(t*te-this.cowboyWidth)}render(){return this.frame(),[Ae]}pastureRows(){return this.frame(),kn(this.drawnPasture(),this.grass)}invalidate(){}attachCowboy(t){this.cowboyHandle=t}attachPasture(t){this.pastureHandle=t}dispose(){let t=this.drawnPasture().length>0&&(this.cowboyHandle!==null||this.pastureHandle!==null);this.disposed=!0,this.poll!==null&&(clearInterval(this.poll),this.poll=null),this.cowboyHandle?.hide(),this.cowboyHandle=null,this.pastureHandle?.hide(),this.pastureHandle=null,t&&this.tui.requestRender(!0)}drawnPasture(){return this.herd===null||!this.isGrazing()?[]:this.herd.pasture}frame(){if(this.disposed)return;let t=this.isGrazing();this.herd===null?(this.herd=this.place(this.countAgents()),this.grazing=t):t!==this.grazing&&this.recount(),this.pollWhile(t)}pollWhile(t){!t&&this.poll!==null?(clearInterval(this.poll),this.poll=null):t&&this.poll===null&&(this.poll=setInterval(()=>this.recount(),ln))}recount(){let{live:t,ended:n}=this.countAgents(),o=this.isGrazing(),i=o!==this.grazing,a=(this.grazing??o)&&(this.herd?.pasture.length??0)>0;if(this.herd===null||t!==this.herd.liveAgents||n!==this.herd.endedAgents)this.herd=this.place({live:t,ended:n});else if(o&&!i)this.herd={...this.herd,pasture:hn(this.herd.pasture,this.random)};else if(!i)return;if(this.grazing=o,this.pollWhile(o),o||i){let s=a&&this.drawnPasture().length===0;this.tui.requestRender(s)}}place({live:t,ended:n}){return{liveAgents:t,endedAgents:n,pasture:fn(this.herd?.pasture??null,{cows:t,droppings:n},this.random)}}},Te=class{static{r(this,"PastureView")}render(){return E()?.pastureRows()??[]}invalidate(){}};function At(e){Ie(),e.custom(t=>{let n=new Se(t,An,Sn,un,Math.random);return we(n),n},{overlay:!0,overlayOptions:yn,onHandle:r(t=>E()?.attachCowboy(t),"onHandle")}),e.custom(()=>new Te,{overlay:!0,overlayOptions:wn,onHandle:r(t=>E()?.attachPasture(t),"onHandle")})}r(At,"showExtensionIndicator");function Ie(){let e=E();we(null),e?.dispose()}r(Ie,"hideExtensionIndicator");function re(){return y().agent.extensionEnabled}r(re,"isExtensionEnabled");function Tn(){return re()&&y().agent.showActiveIndicator}r(Tn,"isActiveIndicatorShown");function oe(e){Tn()?At(e):Ie()}r(oe,"syncExtensionIndicator");function Xr(e,t){y().mutate.agent.setShowActiveIndicator(t),oe(e)}r(Xr,"setShowActiveIndicator");import{Type as M}from"typebox";import{Text as Pr}from"@earendil-works/pi-tui";import{Type as h}from"typebox";var Rn="Task instructions for the agent. If the task requires code changes, the agent works in an isolated branch and will review and commit its changes upon approval. Do not instruct the agent to avoid committing when code modifications are needed.",In=`REQUIRED. Short 2-3 word task name (e.g. "fix login flow"). This single value names the agent's branch/tab/worktree/agent so you can recognize it at a glance, and the extension appends a unique spawn id so parallel spawns \u2014 and every entry in a batch \u2014 are always distinct. Limits: 3 words, 19 characters when slugged (lowercase, dashes). A longer name throws with the exact overshoot \u2014 retry with a shorter name. Missing name throws too. The same name twice in one call is rejected before anything spawns.`,En=`Optional model for THIS agent as "provider/model-id". Omit it, or pass null, to leave it unset and use the configured default for this session and agent type \u2014 the usual case, and never a value to guess at. Pass it when the user asked for a specific model for this task. When a previous attempt failed with a provider/model error, pass a different model here and instruct the agent in plain text to continue where the failed attempt left off. A model that is not in this session's registry fails the call before anything is spawned.`,On=`Optional harness that launches THIS agent, overriding the agent template's harness_type and the configured default harness. Available: the built-in harnesses (${F.join(", ")}) and any harness a plugin registered in this session. Omit it, or pass null, to leave it unset and use the agent template's harness_type, then the configured default \u2014 never pass a harness the user did not ask for. A harness this session did not register, or this machine cannot launch, fails the call before anything is spawned \u2014 unlike the configured default, an explicit request never falls back to pi.`,Cn=h.Object({prompt:h.String({description:Rn}),task_name:h.String({description:In}),agent_type:h.Optional(h.Union([h.String(),h.Null()])),model:h.Optional(h.Union([h.String(),h.Null()],{description:En})),harness_type:h.Optional(h.Union([h.String(),h.Null()],{description:On}))},{additionalProperties:!1,required:["prompt","task_name"]}),H=h.Object({agents:h.Array(Cn,{minItems:1}),run_in_background:h.Optional(h.Boolean())},{additionalProperties:!1,required:["agents"]});var m={agent:"cowboy_agent",stopAgent:"stop_cowboy_agent",mergeBranch:"merge_cowboy_branch",steerAgent:"steer_cowboy_agent",handoverAgent:"handover_cowboy_agent",cleanupAgent:"cleanup_cowboy_agent"},Ee=Object.values(m),b={type:"json_schema",strict:"prefer"};var Oe="_configuredModel",Ce="_configuredThinking";function D(e){return typeof e=="string"&&e.trim()!==""?e.trim():void 0}r(D,"readModelKey");function se(e){return D(e.thinking)??D(e[Ce])}r(se,"readThinkingRequest");function ie(e){let t=D(e.model);if(t)return{source:"call",key:t};let n=D(e[Oe]);if(n)return{source:"configured",key:n}}r(ie,"readModelRequest");function U(e){return{resolved:e===void 0?{kind:"none"}:{kind:"level",thinking:e},notices:[]}}r(U,"withoutModel");function ae(e){switch(e.kind){case"resolved":return{model:e.model,key:e.modelKey,thinking:e.thinking};case"foreign":return{harness:e.harness,key:e.modelKey,name:e.modelName,thinking:e.thinking};case"level":return{levelOnly:!0,thinking:e.thinking};case"none":return}}r(ae,"modelChoiceFor");function q(e){return`${e.provider}/${e.id}`}r(q,"modelKey");function _n(e,t){if(t!==void 0&&!fe.safeParse(t).success)return`Thinking level "${t}" is not recognized by Pi (valid: ${fe.options.join(", ")}); launching "${q(e)}" with "${t}".`}r(_n,"undeclaredLevelWarning");function St(e,t){let n=_n(e,t);return{resolved:{kind:"resolved",model:e,modelKey:q(e),thinking:t??null},notices:n===void 0?[]:[n]}}r(St,"resolvedModel");function Pn(e){return`No API key found for "${e}"`}r(Pn,"missingCredential");function Tt(e,t){let n;try{n=e.getProviderAuthStatus(t.provider)}catch(o){return{verdict:"inconclusive",reason:$(o)}}return!Ve(n)||typeof n.configured!="boolean"?{verdict:"inconclusive",reason:"the registry reported no credential status for the provider"}:n.configured?{verdict:"usable"}:{verdict:"unusable",reason:Pn(t.provider)}}r(Tt,"probeCredentials");function _e(e,t){return`${e}: ${t}. Nothing was spawned.`}r(_e,"refusal");function Pe(e,t){let{registry:n,parent:o,thinking:i}=t;if(!e){if(!o)return U(i);let d=Tt(n,o);if(d.verdict!=="unusable")return St(o,i);throw new Error(_e(`The parent session's model "${q(o)}" did not resolve credentials in this session`,d.reason))}let a=e.source==="call"?he(e.key,n,void 0):he(e.key,n,o);if(!a){if(e.source==="call")throw new Error(`Model "${e.key}" is not available in this session. Nothing was spawned.`);return U(i)}let s=Tt(n,a);if(s.verdict!=="unusable")return St(a,i);throw e.source==="call"?new Error(_e(`Model "${q(a)}" cannot authenticate in this session`,s.reason)):new Error(_e(`The subagent model "${q(a)}" for this configured default cannot authenticate in this session`,s.reason))}r(Pe,"resolvePiModel");async function Mn(e){try{return await e.listModels(e.harness)}catch{return[]}}r(Mn,"harnessModels");function $n(e,t,n){if(t===void 0||t.thinkingLevels.kind!=="closed")return;let{levels:o}=t.thinkingLevels;if(!o.includes(n))return o.length===0?`Model "${t.key}" (${e}) does not support thinking levels; launching with "${n}".`:`Thinking level "${n}" is not declared by ${e} model "${t.key}" (supported: ${o.join(", ")}); proceeding with "${n}".`}r($n,"undeclaredLevelWarning");async function Rt(e,t){if(!e)return U(t.thinking);let n=await Mn(t),o=n.find(a=>a.key===e.key),i=[];if(n.length>0&&!o&&i.push(`The ${t.harness} model list does not include "${e.key}"; launching with that key anyway.`),t.thinking!==void 0){let a=$n(t.harness,o,t.thinking);a!==void 0&&i.push(a)}return{resolved:{kind:"foreign",harness:t.harness,modelKey:e.key,modelName:o?.label??e.key,thinking:t.thinking??null},notices:i}}r(Rt,"resolveForeignModel");async function de(e,t){let{harness:n}=t;if(Qe(n))return Pe(e,{registry:t.registry,parent:t.parent,thinking:t.thinking});let o={harness:n,listModels:t.listModels,thinking:t.thinking};return Rt(e,o)}r(de,"resolveSpawnModel");function B(e,t,n){return{content:[{type:"text",text:t}],details:{...n,severity:e}}}r(B,"resultWithSeverity");function le(e){return e.includes("error")?"error":e.includes("warning")?"warning":"success"}r(le,"foldSeverity");var Me=`
|
|
2
2
|
|
|
3
3
|
---
|
|
4
4
|
|
|
@@ -10,5 +10,5 @@ ${qn(u)}`,details:S}}let p=c;if(u.lifecycle.phase==="queued"){let S=w().listAgen
|
|
|
10
10
|
`).map(n=>n.trim()).filter(n=>n!==""):[]}r(hr,"parseConflictFiles");function mr(e,t){return e.includes(`branch "${t}" does not exist`)}r(mr,"isUnknownBranchError");async function fr(e,t,n,o,i){let a=t.target!==void 0&&t.target.trim()!==""?t.target.trim():"main",s=t.repo!==void 0&&t.repo.trim()!==""?t.repo.trim():void 0,d,c=r(()=>(d??=(async()=>{let l=z().cwd;if(typeof l!="string"||l.trim()==="")throw new Error("merge_cowboy_branch cannot verify the session repo: the session working directory is unavailable, so the repo-scope check is impossible. Refusing to merge without a repo-scope check.");return{sessionRoot:await cr(x(),l),cwd:s??l}})(),d),"mergeScope");return R({toolName:"merge_cowboy_branch",param:"branches",detailsKey:"branches",items:t.branches,severity:ur,prepare:r(async()=>{xe(a,"target");for(let l of t.branches)xe(l.trim(),"branch");await c()},"prepare"),halt:{on:r(l=>l.kind==="conflict","on"),skip:r((l,v)=>{let g=l.trim(),u=`not attempted \u2014 the merge of "${v.trim()}" conflicted and is still in progress`;return{outcome:{kind:"not-attempted",branch:g,reason:u},text:`"${g}" ${u}.`}},"skip")},handleItem:r(async l=>{let{sessionRoot:v,cwd:g}=await c(),u=l.trim();try{let p=await dt(x(),{cwd:g,branch:u,target:a}),f=dr(p.mainRoot,v)?void 0:lr(p.mainRoot,v);if(f!==void 0)try{i.ui.notify(f,"warning")}catch{}let k=f!==void 0?`${f}
|
|
11
11
|
`:"";return p.alreadyMerged?{outcome:{kind:"already-merged",branch:u,target:a},text:`${k}"${u}" is already merged into "${p.target}" \u2014 nothing to do.`}:{outcome:{kind:"merged",branch:u,target:p.target,output:p.output},text:`${k}Merged "${u}" into "${p.target}" in ${p.mainRoot}.`+(p.output?`
|
|
12
12
|
${p.output}`:"")}}catch(p){let f=p instanceof Error?p.message:String(p);return gr(f)?{outcome:{kind:"conflict",branch:u,target:a,files:hr(f)},text:`"${u}": ${f}`}:mr(f,u)?{outcome:{kind:"unknown",branch:u},text:`"${u}": ${f}`}:{outcome:{kind:"failed",branch:u,error:f},text:`"${u}": ${f}`}}},"handleItem")})}r(fr,"executeMergeBranchTool");import{Type as ce}from"typebox";var yr="REQUIRED. One or more agent ids to steer (as printed by the cowboy_agent spawn result or a completion message). Every id is handled independently in input order \u2014 delivered, or refused with its reason \u2014 and one id's refusal never blocks the rest. A settled agent is revived by the delivery. A repeated id is rejected before anything is delivered \u2014 pass each id once.",wr="REQUIRED. The single message delivered verbatim to every id in `agent_ids`. Plain instructions work best (e.g. \"stop refactoring; just fix the failing test and report\"). Delivery is fire-and-forget: nothing here waits for an agent to act on it. Because the text is entered into the agent's pi session, a command prefixed with `!` runs and adds its output to that agent's context, while `!!` runs it without adding the output to its context.",Ft=ce.Object({agent_ids:ce.Array(ce.String({minLength:1}),{minItems:1,description:yr}),message:ce.String({description:wr})},{additionalProperties:!1,required:["agent_ids","message"]});var Kt={name:m.steerAgent,label:m.steerAgent,description:"Send one message to one or more agents in one call: pass every id in `agent_ids` and the single `message` delivered to each. Each id is handled independently in input order \u2014 delivered, or refused with its reason \u2014 and one id's refusal never blocks the rest. A repeated id in `agent_ids` is rejected before anything is delivered \u2014 pass each id once. A spawned agent receives the message before its next model call; a SETTLED one is REVIVED \u2014 spawned again, given the message, and it sends you another completion message when it settles again. That second result arrives only as that completion message: the spawn's result promise closed with the first turn and never opens again. Delivery is fire-and-forget: nothing here waits for an agent to act on it, so do not poll for a reply. The message is entered into the agent's pi session, so it can also be a bash command: `!command` runs the command and sends its output to the agent's context; `!!command` runs it without adding the output to the agent's context. A QUEUED agent cannot be steered \u2014 it has no pane yet; wait for a concurrency slot first. An agent whose pane is gone (cleaned up) cannot be steered either, and neither can an agent being TORN DOWN (wait for its report) or handed over (wait for the handover to finish). Every refusal states its reason and what to do about it.",parameters:Ft,execute:kr,constrainedSampling:b};function vr(e){switch(e.kind){case"delivered":return"success";case"delivered-not-revived":case"refused":return"warning"}}r(vr,"steerSeverity");async function kr(e,t,n,o,i){let a=t.message.trim();return R({toolName:"steer_cowboy_agent",param:"agent_ids",detailsKey:"agents",items:t.agent_ids,severity:vr,prepare:r(()=>{if(a==="")throw new Error("message is required")},"prepare"),handleItem:r(async s=>{let d=w().getSpawn(s);if(!d){let g=`not found. Active agents: ${C()}`;return{outcome:{kind:"refused",agentId:s,reason:g},text:`Agent ${s} was not steered: ${g}`}}let c=I(d.lifecycle),l;try{l=await w().steer(s,a)}catch(g){l={kind:"refused",reason:`steering failed: ${$(g)}`}}if(l.kind==="refused")return{outcome:{kind:"refused",agentId:s,reason:l.reason},text:`Agent ${s} was not steered (${c}): ${l.reason}`};if(l.kind==="delivered-not-revived")return{outcome:{kind:"delivered-not-revived",agentId:s,reason:l.reason},text:`Agent ${s} had settled (${c}) and the message reached its pane, but it was not revived: ${l.reason}`};let v=c!=="spawned"&&d.lifecycle.phase==="spawned";return{outcome:{kind:"delivered",agentId:s},text:v?`Agent ${s} had settled (${c}) \u2014 revived: the message was delivered to its pane and the agent is spawned again. Merge nothing yet; a new completion message will arrive when it settles again.`:c==="spawned"?`Message delivered to spawned agent ${s}. Delivery is fire-and-forget \u2014 the agent picks it up on its next turn; its next completion message will report the result.`:`Agent ${s} was delivered to (${c}), but it was not revived \u2014 it has no process left to act on the message.`}},"handleItem")})}r(kr,"executeSteerAgentTool");function Fs(e,t,n){return ge(e.ids(),t).filter(o=>o!==n)}r(Fs,"handoverTargets");function Gt(e,t,n){let o=e.trim();return o===""?{kind:"faulted",fault:{kind:"request-refused",detail:"`harness_type` is required \u2014 name the harness that runs the next run. Nothing was changed."}}:t.get(o)===void 0?{kind:"faulted",fault:{kind:"request-refused",detail:`Unknown harness_type "${o}": this session registered ${t.ids().join(", ")}. Nothing was changed \u2014 name a registered harness that runs the next run.`}}:Ue(o,n)?{kind:"ready",harness:o}:{kind:"faulted",fault:{kind:"request-refused",detail:`Harness "${o}" cannot be launched on this machine \u2014 this machine can launch ${ge(t.ids(),n).join(", ")}. Nothing was changed.`}}}r(Gt,"resolveHandoverTarget");import{Type as A}from"typebox";var br="REQUIRED. The id of the SETTLED agent to hand over, as printed by the cowboy_agent spawn result or a completion message. A live agent is refused, never stopped \u2014 stop it with stop_cowboy_agent and hand it over once it has settled.",xr=`REQUIRED. The harness that executes the next run of this agent. Available: the built-in harnesses (${F.join(", ")}) and any harness a plugin registered in this session. Unlike the configured default, an explicit harness never falls back: an ID this session did not register, or one this machine cannot launch, causes the call to be refused before anything is stopped. The source harness must be able to export its own session; a harness that cannot is reported in the result and nothing changes.`,Ar=`Optional model for the next run as "provider/model-id", in the target harness's own vocabulary. Omit it, or pass null, to leave it unset and let the harness choose its default. A model that is not in this session's registry (or in the target harness's list) refuses the call before anything is stopped.`,Sr="Optional thinking level for the next run, in the target harness's vocabulary. Omit it, or pass null, to leave it unset.",Yt=A.Object({agent_id:A.String({minLength:1,description:br}),harness_type:A.String({description:xr}),model:A.Optional(A.Union([A.String(),A.Null()],{description:Ar})),thinking:A.Optional(A.Union([A.String(),A.Null()],{description:Sr}))},{additionalProperties:!1,required:["agent_id","harness_type"]});async function Tr(e,t){let n=Gt(e.harness_type,O(),Q());if(n.kind==="faulted")return{kind:"faulted",fault:n.fault};let o=n.harness;try{let i=await de(ie(e),{harness:o,registry:t.modelRegistry,parent:t.model,thinking:se(e),listModels:r(async a=>{let s=await O().require(a).listModels({pi:x(),modelCatalog:N(t.modelRegistry)}),d=G(s);return d!==void 0&&t.hasUI&&t.ui.notify(d,"warning"),K(s)},"listModels")});for(let a of i.notices)t.hasUI&&t.ui.notify(a,"warning");return{kind:"ready",harness:o,modelChoice:ae(i.resolved)}}catch(i){return{kind:"faulted",fault:{kind:"request-refused",detail:$(i)}}}}r(Tr,"resolveIntent");function Rr(e,t){return`Agent ${e} ${Ir(t)}`}r(Rr,"renderHandoverOutcome");function Ir(e){if(e.kind==="handed-over"){let t=e.loss===void 0?"":et(e.loss);return`handed over from "${e.from}" to "${e.to}".${t} The ended run is archived; the next one runs in the same checkout and reports when it settles.`}switch(e.fault.kind){case"agent-unknown":return"not found \u2014 check the id from its spawn or completion result.";case"agent-not-settled":return e.fault.status==="queued"?"is still queued \u2014 it has not started, so there is no session to hand over. Wait for a concurrency slot (or stop it). Nothing was changed.":`is still ${e.fault.status} \u2014 stop it with stop_cowboy_agent and hand it over once it has settled. Nothing was changed.`;case"harness-cannot-export-session":return`was not handed over: harness "${e.fault.harness}" cannot export its own session, so there is nothing to hand over. Nothing was stopped or changed.`;case"never-started":return"was not handed over: it never started, so there is no session to export.";case"stop-failed":return`was not handed over: its run could not be stopped (${e.fault.detail}). Nothing was changed.`;case"session-empty":return`was not handed over: harness "${e.fault.harness}" returned an empty session. Nothing was changed: the run was not stopped.`;case"session-export-failed":return`was not handed over: harness "${e.fault.harness}" could not export its session (${e.fault.detail}). Nothing was changed: the run was not stopped.`;case"request-refused":return`was not handed over: ${e.fault.detail}`;case"launch-failed":return`ended its previous run but its next one did not start (${e.fault.detail}). It stays tracked and can be cleaned up.`}}r(Ir,"handoverReport");async function Er(e,t,n,o,i){let a=t.agent_id.trim(),s=await Tr(t,i),d=s.kind==="faulted"?{kind:"faulted",fault:s.fault}:await w().handover(a,{harness:s.harness,modelChoice:s.modelChoice});return B(tt(d),Rr(a,d),{agentId:a,outcome:d})}r(Er,"executeHandoverAgentTool");var zt={name:m.handoverAgent,label:m.handoverAgent,description:"Hand over one SETTLED agent to another harness in one call: pass its `agent_id` and the `harness_type` that executes its next run. The ended run is stopped, its session exported by the source harness, the run archived, and the next one launched in the same checkout with that session and its ID quoted in its task \u2014 so the work continues under the new harness instead of starting over. Nothing is removed: the ended run's pane and harness state stay until cleanup_cowboy_agent, which tears every run down at its own address. A live agent is REFUSED, never stopped \u2014 stop it with stop_cowboy_agent first. `harness_type` is required and, unlike a configured default, never falls back: if an ID was not registered in this session or cannot be launched on this machine, the call is refused before anything is stopped. The source harness must be able to export its own session; a harness that cannot is reported in the result, naming the harness, and nothing is stopped or changed. The next run reports through its own completion message; this call returns when that run has started, not when it finishes.",parameters:Yt,execute:Er,constrainedSampling:b};import{Text as Or}from"@earendil-works/pi-tui";var Cr={success:"\u2713",warning:"!",error:"\u2717"};function _r(e,t,n,o){let i=e.content.map(d=>d.text??"").join(`
|
|
13
|
-
`),a=o.isError?"error":e.details?.severity??"success",s=a==="success"?i:n.fg(a,i);return new Or(`${n.fg(a,Cr[a])} ${s}`,0,0)}r(_r,"renderCowboyToolResult");function P(e){return{...e,renderResult:_r}}r(P,"withCowboyRenderer");var Mr=Ee;function $r(e){let t=M.Object({prompt:H.properties.agents.items.properties.prompt,task_name:H.properties.agents.items.properties.task_name,agent_type:M.Optional(M.Union([M.String(),M.Null()],{description:`Optional agent type. Omit it, or pass null, to use the configured default agent type \u2014 never pass a type the user did not ask for. An unknown or ambiguous name is rejected before any agent in the batch spawns.${e.length>0?` Available: ${e.join(",")}`:""}`})),model:H.properties.agents.items.properties.model,harness_type:H.properties.agents.items.properties.harness_type},{additionalProperties:!1,required:["prompt","task_name"]});return M.Object({agents:M.Array(t,{minItems:1}),run_in_background:H.properties.run_in_background},{additionalProperties:!1,required:["agents"]})}r($r,"cowboyAgentsSchemaWithTypes");function Qt(e){let t=$r(ut()),n={name:m.agent,label:m.agent,description:"Delegate one or more tasks to agents. Each agent gets an isolated worktree and a fresh pi process \u2014 pass a single-item `agents` array to delegate one task, or several to launch them in one call. Every item in `agents` requires its own short `task_name`; a name used twice in one call is rejected before anything spawns. Each agent is instructed to write its complete final response to a report file when it finishes \u2014 do not repeat reporting instructions in the `prompt`. Delegation is NON-BLOCKING by default: the call returns immediately with one agent id per item, and each result is delivered to you as a message when that agent settles \u2014 do not poll, do not re-delegate the task, do not duplicate the work. Pass `run_in_background: false` ONLY when `agents` has exactly one item AND you need that result inline in the same turn; a non-background call with multiple items is rejected before anything spawns. When an agent settles, the completion message names its `cow-` branch and says whether the worktree is kept and why. Merge the settled branch with merge_cowboy_branch when the work is good (or reject it), then call cleanup_cowboy_agent to remove it.",parameters:t,execute:_t,constrainedSampling:b};e.registerTool(P(n))}r(Qt,"registerAgentTool");function Nr(e,t){y().mutate.agent.setExtensionEnabled(t),t?Hr(e):Dr(e)}r(Nr,"setExtensionEnabled");function Hr(e){let t=x();Qt(t),t.setActiveTools([...new Set([...t.getActiveTools(),...Mr])]),oe(e)}r(Hr,"activateExtension");function Dr(e){let t=x();t.setActiveTools(t.getActiveTools().filter(n=>!Ee.includes(n))),oe(e)}r(Dr,"deactivateExtension");function Si(e){Qt(e),e.registerTool(P(Pt)),e.registerTool(P(Wt)),e.registerTool(P(Kt)),e.registerTool(P(zt)),e.registerTool(P(Lt)),e.registerMessageRenderer("subagent-result",(t,n,o)=>{let i=typeof t=="object"&&typeof t.content=="string"?t.content:"",a=/\b(error|stopped)\b/.test(i.slice(0,200)),s=o.fg(a?"error":"success",a?"\u2717":"\u2713");return new Pr(`${s} ${i}`,0,0)})}r(Si,"registerTools");async function Vt(e,t){let n=await O().listModelOptions({pi:e,modelCatalog:N(t.modelRegistry)},Q());for(let o of n.notices)t.ui.notify(o,"warning");return n.options}r(Vt,"harnessModelOptions");var Xt="cowboy",Br={wt:"worktree",sp:"spawn",st:"status"};function Ti(e,t){e.registerCommand(Xt,{description:t,handler:r(async(n,o)=>{o.ui.notify(t,"warning")},"handler")})}r(Ti,"registerUnavailableCowboyCommand");function Ri(e){e.registerCommand(Xt,{description:"Manage agents: status, spawn, settings. `status` lists spawned, queued and settled agents; `spawn` opens the spawn wizard; `worktree` creates one git worktree with no agent attached to it. `status`, `spawn` and `worktree` also answer to `st`, `sp` and `wt`. `enable`/`disable` load or unload the cowboy tools. Pass `model` (optionally a provider/model-id) to set the model agents use for this session \u2014 opens pi's model picker.",getArgumentCompletions:r(async t=>(await import("./model-picker-
|
|
14
|
-
//# sourceMappingURL=chunk-
|
|
13
|
+
`),a=o.isError?"error":e.details?.severity??"success",s=a==="success"?i:n.fg(a,i);return new Or(`${n.fg(a,Cr[a])} ${s}`,0,0)}r(_r,"renderCowboyToolResult");function P(e){return{...e,renderResult:_r}}r(P,"withCowboyRenderer");var Mr=Ee;function $r(e){let t=M.Object({prompt:H.properties.agents.items.properties.prompt,task_name:H.properties.agents.items.properties.task_name,agent_type:M.Optional(M.Union([M.String(),M.Null()],{description:`Optional agent type. Omit it, or pass null, to use the configured default agent type \u2014 never pass a type the user did not ask for. An unknown or ambiguous name is rejected before any agent in the batch spawns.${e.length>0?` Available: ${e.join(",")}`:""}`})),model:H.properties.agents.items.properties.model,harness_type:H.properties.agents.items.properties.harness_type},{additionalProperties:!1,required:["prompt","task_name"]});return M.Object({agents:M.Array(t,{minItems:1}),run_in_background:H.properties.run_in_background},{additionalProperties:!1,required:["agents"]})}r($r,"cowboyAgentsSchemaWithTypes");function Qt(e){let t=$r(ut()),n={name:m.agent,label:m.agent,description:"Delegate one or more tasks to agents. Each agent gets an isolated worktree and a fresh pi process \u2014 pass a single-item `agents` array to delegate one task, or several to launch them in one call. Every item in `agents` requires its own short `task_name`; a name used twice in one call is rejected before anything spawns. Each agent is instructed to write its complete final response to a report file when it finishes \u2014 do not repeat reporting instructions in the `prompt`. Delegation is NON-BLOCKING by default: the call returns immediately with one agent id per item, and each result is delivered to you as a message when that agent settles \u2014 do not poll, do not re-delegate the task, do not duplicate the work. Pass `run_in_background: false` ONLY when `agents` has exactly one item AND you need that result inline in the same turn; a non-background call with multiple items is rejected before anything spawns. When an agent settles, the completion message names its `cow-` branch and says whether the worktree is kept and why. Merge the settled branch with merge_cowboy_branch when the work is good (or reject it), then call cleanup_cowboy_agent to remove it.",parameters:t,execute:_t,constrainedSampling:b};e.registerTool(P(n))}r(Qt,"registerAgentTool");function Nr(e,t){y().mutate.agent.setExtensionEnabled(t),t?Hr(e):Dr(e)}r(Nr,"setExtensionEnabled");function Hr(e){let t=x();Qt(t),t.setActiveTools([...new Set([...t.getActiveTools(),...Mr])]),oe(e)}r(Hr,"activateExtension");function Dr(e){let t=x();t.setActiveTools(t.getActiveTools().filter(n=>!Ee.includes(n))),oe(e)}r(Dr,"deactivateExtension");function Si(e){Qt(e),e.registerTool(P(Pt)),e.registerTool(P(Wt)),e.registerTool(P(Kt)),e.registerTool(P(zt)),e.registerTool(P(Lt)),e.registerMessageRenderer("subagent-result",(t,n,o)=>{let i=typeof t=="object"&&typeof t.content=="string"?t.content:"",a=/\b(error|stopped)\b/.test(i.slice(0,200)),s=o.fg(a?"error":"success",a?"\u2717":"\u2713");return new Pr(`${s} ${i}`,0,0)})}r(Si,"registerTools");async function Vt(e,t){let n=await O().listModelOptions({pi:e,modelCatalog:N(t.modelRegistry)},Q());for(let o of n.notices)t.ui.notify(o,"warning");return n.options}r(Vt,"harnessModelOptions");var Xt="cowboy",Br={wt:"worktree",sp:"spawn",st:"status"};function Ti(e,t){e.registerCommand(Xt,{description:t,handler:r(async(n,o)=>{o.ui.notify(t,"warning")},"handler")})}r(Ti,"registerUnavailableCowboyCommand");function Ri(e){e.registerCommand(Xt,{description:"Manage agents: status, spawn, settings. `status` lists spawned, queued and settled agents; `spawn` opens the spawn wizard; `worktree` creates one git worktree with no agent attached to it. `status`, `spawn` and `worktree` also answer to `st`, `sp` and `wt`. `enable`/`disable` load or unload the cowboy tools. Pass `model` (optionally a provider/model-id) to set the model agents use for this session \u2014 opens pi's model picker.",getArgumentCompletions:r(async t=>(await import("./model-picker-SXUEGCKV.js")).cowboyCompletions(t),"getArgumentCompletions"),handler:r(async(t,n)=>{rt(n);let[o,...i]=t.trim().split(/\s+/),a=Br[o]??o,s=[a,...i].join(" ");if(s==="enable"||s==="disable"){let l=s==="enable";if(l&&be()===null){n.ui.notify(me,"warning");return}if(re()===l){n.ui.notify(`pi-cowboy is already ${l?"enabled":"disabled"}`,"info");return}Nr(n.ui,l),n.ui.notify(l?"pi-cowboy enabled":"pi-cowboy disabled","info");return}if(be()===null){n.ui.notify(me,"warning");return}if(a==="worktree"){let{showWorktreeCommandMenu:l}=await import("./menu-worktree-command-J7U2NV6J.js");await l(n,i.join(" "));return}if((a==="model"||s==="spawn"||s==="status")&&!re()){n.ui.notify("pi-cowboy is disabled. Run /cowboy enable first.","warning");return}if(a==="model"){let{handleModelArg:l}=await import("./model-picker-SXUEGCKV.js");await l(i.join(" "),n);return}if(s==="spawn"||s==="status"){let{showAgentsActionMenu:l}=await import("./menus-AMT4U7FK.js");await l(n,s,await Vt(e,n));return}if(s!==""){n.ui.notify(`Unknown option "${o}". Usage: /cowboy [status | spawn | worktree [<name>] | model [<provider/model-id>|clear] | enable | disable]`,"warning");return}let{showAgentsMainMenu:c}=await import("./menus-AMT4U7FK.js");await c(n,await Vt(e,n))},"handler")})}r(Ri,"registerCowboyCommand");import*as Zt from"node:fs";import{tmpdir as Lr}from"node:os";import*as ue from"node:path";async function Jt(e,t){try{return await ot(e).probe(t),j(qe)}catch{return j(["checkout"])}}r(Jt,"detectCowAvailability");function en(e){let t=ue.resolve(e??Le());for(;;){try{if(Zt.statSync(t).isDirectory())return t}catch{}let n=ue.dirname(t);if(n===t)return Lr();t=n}}r(en,"probeTargetFor");function jr(e){return(t,n,o)=>e.exec(t,n,o)}r(jr,"execOf");function Li(e){return tn(e,ke())}r(Li,"startCowSupportProbe");function ji(e){let t=ke();return V(t,je()),tn(e,t)}r(ji,"refreshCowSupportProbe");function tn(e,t){let n=en(y().agent.worktreeRoot);return Jt(jr(e),n).then(o=>{V(t,o)},()=>{V(t,j(["checkout"]))})}r(tn,"probe");import nn from"node:fs";var Ur="/tmp";function qr(e){return e.replace(/[^A-Za-z0-9._-]/g,"-")}r(qr,"handoverNameField");function rn(e){return`cowboy-handover_${[e.worktree,e.harness,e.sessionId].map(qr).join("_")}.md`}r(rn,"handoverFileName");function on(e){return`${Ur}/${e}`}r(on,"handoverFilePath");function Wr(e){return nn.existsSync(e)}r(Wr,"handoverFileExists");function Fi(e,t){let n=Wr(e);return nn.writeFileSync(e,t,"utf8"),{replaced:n}}r(Fi,"writeHandoverFile");function zi(e){return{kind:"prepared",path:on(rn({worktree:e.worktree,harness:e.harness,sessionId:e.sessionId})),text:e.text,sessionId:e.sessionId,...e.loss===void 0?{}:{loss:e.loss}}}r(zi,"handoverExportArtifact");function Vi(e){switch(e.kind){case"agent-unknown":return"not found \u2014 check the id from its spawn or completion result.";case"agent-not-settled":return`is still ${e.status} \u2014 only a settled run has a session to export. Nothing was changed.`;case"harness-cannot-export-session":return`was not exported: harness "${e.harness}" cannot export its own session, so there is nothing to write.`;case"never-started":return"was not exported: it never started, so there is no session to export.";case"handover-in-progress":return`was not exported: ${e.detail}`;case"session-empty":return`was not exported: harness "${e.harness}" returned an empty session.`;case"session-export-failed":return`was not exported: harness "${e.harness}" could not export its session (${e.detail}).`}}r(Vi,"handoverExportFaultReason");function Qi(e){if(e.kind==="prepared")return e.loss===void 0?"success":"warning";switch(e.fault.kind){case"agent-unknown":case"agent-not-settled":case"harness-cannot-export-session":case"never-started":case"handover-in-progress":return"warning";case"session-empty":case"session-export-failed":return"error"}}r(Qi,"handoverExportSeverity");export{$e as a,Un as b,qn as c,ss as d,Nt as e,cs as f,us as g,Fs as h,Rr as i,Ie as j,re as k,Xr as l,Wr as m,Fi as n,zi as o,Vi as p,Qi as q,Li as r,ji as s,Nr as t,Hr as u,Dr as v,Si as w,Ti as x,Ri as y};
|
|
14
|
+
//# sourceMappingURL=chunk-HJRZSWB4.js.map
|