pi-straw-boss 0.109.2 → 0.109.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/{chunk-5PW3W2YV.mjs → chunk-RYFPCRML.mjs} +5 -5
- package/dist/server/cli.mjs +1 -1
- package/dist/server/main.mjs +12 -12
- package/package.json +1 -1
- package/prompts/worker.md +1 -1
- package/src/deadpane.ts +6 -6
- package/src/moments.ts +1 -1
- package/src/opener.ts +2 -2
- package/src/reviver.ts +4 -3
- package/src/server/towers.ts +5 -4
- package/src/spawn.ts +3 -3
- package/src/tools.ts +1 -1
- package/src/tower.ts +3 -2
- package/src/towertab.ts +2 -2
|
@@ -8610,18 +8610,18 @@ function createDeadPanes(env) {
|
|
|
8610
8610
|
}
|
|
8611
8611
|
return rows;
|
|
8612
8612
|
},
|
|
8613
|
-
/**
|
|
8613
|
+
/**
|
|
8614
|
+
* Closes one dead agent pane, and only the pane: Herdr closes a tab its last pane leaves (and a workspace its last tab leaves), so a pane split into the tab since the look is never taken with it (boss 2026-11-27).
|
|
8615
|
+
* Refused with the table's reason otherwise.
|
|
8616
|
+
*/
|
|
8614
8617
|
async close(query) {
|
|
8615
8618
|
onWindows();
|
|
8616
8619
|
const { all, facts } = await look2();
|
|
8617
8620
|
const f = facts(query), refused3 = await why(f);
|
|
8618
8621
|
if (refused3) throw new Error(refused3);
|
|
8619
8622
|
const p = f.pane, alone = all.filter((x) => x.tab_id === p.tab_id).length === 1;
|
|
8620
|
-
if (alone) {
|
|
8621
|
-
await run4(["tab", "close", p.tab_id]);
|
|
8622
|
-
return { text: `Closed tab ${p.tab_id} with its only pane ${p.pane_id} (${paneWhat(p)}), whose pi was gone.`, pane: p.pane_id, tab: p.tab_id };
|
|
8623
|
-
}
|
|
8624
8623
|
await run4(["pane", "close", p.pane_id]);
|
|
8624
|
+
if (alone) return { text: `Closed pane ${p.pane_id} (${paneWhat(p)}), whose pi was gone; it was the only pane of its tab, so its tab ${p.tab_id} closes with it.`, pane: p.pane_id, tab: p.tab_id };
|
|
8625
8625
|
return { text: `Closed pane ${p.pane_id} (${paneWhat(p)}), whose pi was gone; its tab ${p.tab_id} keeps its other panes.`, pane: p.pane_id };
|
|
8626
8626
|
}
|
|
8627
8627
|
};
|
package/dist/server/cli.mjs
CHANGED
package/dist/server/main.mjs
CHANGED
|
@@ -303,7 +303,7 @@ import {
|
|
|
303
303
|
writeStartError,
|
|
304
304
|
writerAlive,
|
|
305
305
|
yardPath
|
|
306
|
-
} from "./chunk-
|
|
306
|
+
} from "./chunk-RYFPCRML.mjs";
|
|
307
307
|
|
|
308
308
|
// src/server/main.ts
|
|
309
309
|
import { homedir as homedir18 } from "node:os";
|
|
@@ -3691,7 +3691,7 @@ async function open({ run: run2, sleep: sleep2, live, moveFirst, model, trustDir
|
|
|
3691
3691
|
if (!running) await assertSettingsSafe([reused.cwd ?? workspace.worktree?.checkout_path ?? cwd]);
|
|
3692
3692
|
if (!marked) await report(run2, "pane", paneId, { sb_role: "tower" });
|
|
3693
3693
|
await moveFirst(reused.tab_id);
|
|
3694
|
-
for (const extra of bare2.slice(1)) await run2(["
|
|
3694
|
+
for (const extra of bare2.slice(1)) await run2(["pane", "close", extra.pane_id]).catch(() => {
|
|
3695
3695
|
});
|
|
3696
3696
|
} else {
|
|
3697
3697
|
const dir = workspace.worktree?.checkout_path ?? cwd;
|
|
@@ -3710,7 +3710,7 @@ async function open({ run: run2, sleep: sleep2, live, moveFirst, model, trustDir
|
|
|
3710
3710
|
});
|
|
3711
3711
|
}
|
|
3712
3712
|
const id2 = await waitPastTrust(sleep2, held2, TOWER_WAIT_MS, 1e3, trustDir2 ? { dir: trustDir2, pane: paneId } : void 0).catch(async (error) => {
|
|
3713
|
-
if (created) await run2(["
|
|
3713
|
+
if (created) await run2(["pane", "close", paneId]).catch(() => {
|
|
3714
3714
|
});
|
|
3715
3715
|
throw error;
|
|
3716
3716
|
});
|
|
@@ -10132,7 +10132,7 @@ function createSpawn({ run: run2, sleep: sleep2, call, live, sessionAt, home = h
|
|
|
10132
10132
|
const name2 = basename6(dir) || dir;
|
|
10133
10133
|
await assertSettingsSafe([dir]);
|
|
10134
10134
|
const { tabId, paneId } = await createTab(run2, ws.workspace_id, dir, ["STRAW_BOSS_ROLE=main"], name2);
|
|
10135
|
-
const failed3 = await orClose(["
|
|
10135
|
+
const failed3 = await orClose(["pane", "close", paneId], async () => {
|
|
10136
10136
|
await report(run2, "pane", paneId, { sb_open_main: "1" });
|
|
10137
10137
|
return boot(d, paneId, `main \xB7 ${name2}`, prompt, "main");
|
|
10138
10138
|
});
|
|
@@ -10148,7 +10148,7 @@ function createSpawn({ run: run2, sleep: sleep2, call, live, sessionAt, home = h
|
|
|
10148
10148
|
if (!dir) return OUTSIDE2;
|
|
10149
10149
|
await assertSettingsSafe([dir]);
|
|
10150
10150
|
const opened2 = await createTab(run2, ws.workspace_id, dir, ["STRAW_BOSS_ROLE=member"], basename6(dir) || dir);
|
|
10151
|
-
created = { ...opened2, close: ["
|
|
10151
|
+
created = { ...opened2, close: ["pane", "close", opened2.paneId] };
|
|
10152
10152
|
} else {
|
|
10153
10153
|
const lead = await leadOf2(ws.workspace_id, tabId);
|
|
10154
10154
|
if (!lead) return no10(404, "not_found", "That tab is not open any more.");
|
|
@@ -21815,7 +21815,7 @@ async function reviveMain(env, { session, reason, origin }) {
|
|
|
21815
21815
|
const closedOld = await closeOldTab(env, row2, paneId).catch(() => void 0);
|
|
21816
21816
|
return { tab: tabId, pane: paneId, main: main.id, file: row2.file, ...row2.name ? { name: row2.name } : {}, ...row2.kind ? { kind: row2.kind } : {}, ...train ? { train } : {}, ...row2.openedBy ? { openedBy: row2.openedBy } : {}, ...closedOld ? { closedOld } : {} };
|
|
21817
21817
|
} catch (error) {
|
|
21818
|
-
await run2(["
|
|
21818
|
+
await run2(["pane", "close", paneId]).catch(() => {
|
|
21819
21819
|
});
|
|
21820
21820
|
if (!(error instanceof ReviveRefused)) attempt("failed", { error: error.message.slice(0, 300) });
|
|
21821
21821
|
throw error;
|
|
@@ -21831,7 +21831,7 @@ async function closeOldTab(env, row2, newPane) {
|
|
|
21831
21831
|
const info = JSON.parse(await env.run(["pane", "process-info", "--pane", row2.record.pane])).result?.process_info;
|
|
21832
21832
|
const fg = info?.foreground_processes ?? [];
|
|
21833
21833
|
if (!(fg.length === 1 && typeof info?.shell_pid === "number" && fg[0].pid === info.shell_pid)) return void 0;
|
|
21834
|
-
await env.run(["
|
|
21834
|
+
await env.run(["pane", "close", row2.record.pane]);
|
|
21835
21835
|
return row2.record.tab;
|
|
21836
21836
|
}
|
|
21837
21837
|
|
|
@@ -22018,7 +22018,7 @@ function opener(env) {
|
|
|
22018
22018
|
if (sent.status !== "sent") throw new Error(`The new ${train ? "train" : integ ? "integrator" : "main"} ${main.name ?? main.id} did not take the ${integ ? "handoff" : "request"}: ${sent.status} ${sent.code ?? ""} ${sent.detail ?? ""}`.trim());
|
|
22019
22019
|
return { tab: tabId, pane: paneId, main: main.id, sender: sender.id, ...train ? { train } : {}, ...integ ? { integrator: integ } : {} };
|
|
22020
22020
|
} catch (error) {
|
|
22021
|
-
await run2(["
|
|
22021
|
+
await run2(["pane", "close", paneId]).catch(() => {
|
|
22022
22022
|
});
|
|
22023
22023
|
throw error;
|
|
22024
22024
|
}
|
|
@@ -28974,7 +28974,7 @@ function createTowers(o) {
|
|
|
28974
28974
|
l.renewing = true;
|
|
28975
28975
|
let made;
|
|
28976
28976
|
const abandon = async () => {
|
|
28977
|
-
if (made) await run2(["
|
|
28977
|
+
if (made) await run2(["pane", "close", made.paneId]).catch(() => {
|
|
28978
28978
|
});
|
|
28979
28979
|
return void 0;
|
|
28980
28980
|
};
|
|
@@ -29293,7 +29293,7 @@ function createTowers(o) {
|
|
|
29293
29293
|
pane = { pane_id: tab.paneId, tab_id: tab.tabId };
|
|
29294
29294
|
made = true;
|
|
29295
29295
|
} else {
|
|
29296
|
-
for (const extra of bare2.slice(1)) await run2(["
|
|
29296
|
+
for (const extra of bare2.slice(1)) await run2(["pane", "close", extra.pane_id]).catch(() => {
|
|
29297
29297
|
});
|
|
29298
29298
|
if (given && (await tabs(run2, ws)).find((t) => t.tab_id === given.tab_id)?.label !== TOWER_LABEL) await run2(["tab", "rename", given.tab_id, TOWER_LABEL]).catch(() => {
|
|
29299
29299
|
});
|
|
@@ -29686,8 +29686,8 @@ ${d.message}`, at: new Date(now()).toISOString(), messageId: `quiet:${createHash
|
|
|
29686
29686
|
async close(workspace) {
|
|
29687
29687
|
const l = services.get(workspace);
|
|
29688
29688
|
if (!l) throw new Error(`The sb server stands in for no tower of workspace ${workspace}`);
|
|
29689
|
-
if (l.seated || await prove(l) === "ours") {
|
|
29690
|
-
if (await proven(l)) await run2(["
|
|
29689
|
+
if (!tabless(l) && (l.seated || await prove(l) === "ours")) {
|
|
29690
|
+
if (await proven(l)) await run2(["pane", "close", l.record.pane]).catch(() => {
|
|
29691
29691
|
});
|
|
29692
29692
|
}
|
|
29693
29693
|
await lose(l, "closed by the boss");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-straw-boss",
|
|
3
|
-
"version": "0.109.
|
|
3
|
+
"version": "0.109.3",
|
|
4
4
|
"description": "Straw Boss coordination for pi in Herdr: sessions join a tab's net by choice, the first joiner is its main agent, a workspace tower opens on demand with a live monitoring dashboard, and boss_broadcast reaches the rest",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/prompts/worker.md
CHANGED
|
@@ -4,4 +4,4 @@ You are a worker of Herdr tab {{tab}}, opened for a teammate's device: one brief
|
|
|
4
4
|
- Nobody is at your pane: never `ask_user_question`. Scouts and reviewers may help you; you dispatch no `worker` subagents.
|
|
5
5
|
- Stay in your worktree and on your branch: commit there and push that branch. Never merge, deploy, send a car slip, or change anything outside the worktree.
|
|
6
6
|
- Your board line names what you do now. Write to agents terse: point first; keep numbers, paths, IDs, and quoted words verbatim.
|
|
7
|
-
- End with exactly one `call_tower` `why: milestone`, your final report, blocked or done: it goes back to the device that asked, and
|
|
7
|
+
- End with exactly one `call_tower` `why: milestone`, your final report, blocked or done: it goes back to the device that asked, and your pane closes after it.
|
package/src/deadpane.ts
CHANGED
|
@@ -66,7 +66,7 @@ export const paneWhat = (p: Pane) => {
|
|
|
66
66
|
const t = p.tokens ?? {}, kind = t.sb_role ?? (t.sb_train ? "train" : Object.keys(t).some((k) => k.startsWith("piha_")) ? "subagent" : "pi"), name = t.sb_main_tab ?? t.sb_name ?? t.sb_tab ?? t.sb_member_tab;
|
|
67
67
|
return name ? `${kind} ${name}` : kind;
|
|
68
68
|
};
|
|
69
|
-
export interface DeadPane { pane: string; tab: string; what: string; /** The tab's only pane: the tab
|
|
69
|
+
export interface DeadPane { pane: string; tab: string; what: string; /** The tab's only pane: Herdr closes the tab with it. */ alone: boolean }
|
|
70
70
|
/** The list `boss_close_main` gives with neither main nor pane. */
|
|
71
71
|
export const deadList = (rows: DeadPane[]) => ({
|
|
72
72
|
text: rows.length ? `Dead agent panes of this workspace (close one with boss_close_main pane):\n${rows.map((r) => `- ${r.pane} (tab ${r.tab}${r.alone ? ", its only pane" : ""}): ${r.what}`).join("\n")}` : "No dead agent pane in this workspace.",
|
|
@@ -110,18 +110,18 @@ export function createDeadPanes(env: DeadPaneEnv) {
|
|
|
110
110
|
}
|
|
111
111
|
return rows;
|
|
112
112
|
},
|
|
113
|
-
/**
|
|
113
|
+
/**
|
|
114
|
+
* Closes one dead agent pane, and only the pane: Herdr closes a tab its last pane leaves (and a workspace its last tab leaves), so a pane split into the tab since the look is never taken with it (boss 2026-11-27).
|
|
115
|
+
* Refused with the table's reason otherwise.
|
|
116
|
+
*/
|
|
114
117
|
async close(query: string): Promise<ClosedPane> {
|
|
115
118
|
onWindows();
|
|
116
119
|
const { all, facts } = await look();
|
|
117
120
|
const f = facts(query), refused = await why(f);
|
|
118
121
|
if (refused) throw new Error(refused);
|
|
119
122
|
const p = f.pane!, alone = all.filter((x) => x.tab_id === p.tab_id).length === 1;
|
|
120
|
-
if (alone) {
|
|
121
|
-
await run(["tab", "close", p.tab_id]);
|
|
122
|
-
return { text: `Closed tab ${p.tab_id} with its only pane ${p.pane_id} (${paneWhat(p)}), whose pi was gone.`, pane: p.pane_id, tab: p.tab_id };
|
|
123
|
-
}
|
|
124
123
|
await run(["pane", "close", p.pane_id]);
|
|
124
|
+
if (alone) return { text: `Closed pane ${p.pane_id} (${paneWhat(p)}), whose pi was gone; it was the only pane of its tab, so its tab ${p.tab_id} closes with it.`, pane: p.pane_id, tab: p.tab_id };
|
|
125
125
|
return { text: `Closed pane ${p.pane_id} (${paneWhat(p)}), whose pi was gone; its tab ${p.tab_id} keeps its other panes.`, pane: p.pane_id };
|
|
126
126
|
},
|
|
127
127
|
};
|
package/src/moments.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { CarState } from "./train/cars.ts";
|
|
|
6
6
|
/** The idle nudge (idlewake.ts, wired in wrapup.ts): a coordinator or integrator main idle 30 minutes with nothing running. */
|
|
7
7
|
export const NUDGE_TEXT = "sb: you have been idle 30 minutes. Is your work done? If work remains: dispatch your ready todos now; none ready, take your next eligible work; or clean up stale todos. If you wait on someone other than the boss, set that todo's `metadata.waitsOn` (who) and stop. If it is done: answer the intercom asks you owe, remove the worktrees you made, complete or delete every todo, stop your monitors and loops, write a daily memory entry if you have a memory tool, then call boss_wrap with a summary: it asks the boss before this pane closes.";
|
|
8
8
|
/** The worker's nudge (wrapup.ts): a worker opened for a teammate's device, idle 15 minutes with nothing running and no final report (docs/specs/2026-11-26-ally-workers.md). */
|
|
9
|
-
export const WORKER_NUDGE = "sb: you have been idle 15 minutes. Finish the brief now, or send your final report with call_tower why: milestone (blocked or done): it is your only one, and
|
|
9
|
+
export const WORKER_NUDGE = "sb: you have been idle 15 minutes. Finish the brief now, or send your final report with call_tower why: milestone (blocked or done): it is your only one, and your pane closes after it. At 60 minutes idle without it the box stops you and keeps your worktree.";
|
|
10
10
|
/** `boss_wrap`'s description (wrapup.ts): every main that has the tool, on every turn. */
|
|
11
11
|
export const WRAP_DESCRIPTION = "Main only, when your work is done: asks the boss here whether to wrap up; on yes it sends your summary to the tower as a milestone (and to whoever a tower opened you for), clears your board, and closes this session and its pane. Refused with an open todo, a running monitor, loop, watch, or subagent, under auto mode, for a standing main, and in a teammate's turn.";
|
|
12
12
|
/** The standing main's wake (idlewake.ts `armWake`): a standing main idle 2 hours with nothing armed. */
|
package/src/opener.ts
CHANGED
|
@@ -279,8 +279,8 @@ export function opener(env: OpenerEnv) {
|
|
|
279
279
|
if (sent.status !== "sent") throw new Error(`The new ${train ? "train" : integ ? "integrator" : "main"} ${main.name ?? main.id} did not take the ${integ ? "handoff" : "request"}: ${sent.status} ${sent.code ?? ""} ${sent.detail ?? ""}`.trim());
|
|
280
280
|
return { tab: tabId, pane: paneId, main: main.id, sender: sender.id, ...(train ? { train } : {}), ...(integ ? { integrator: integ } : {}) };
|
|
281
281
|
} catch (error) {
|
|
282
|
-
// Nothing was handed over, so no work is lost with the tab.
|
|
283
|
-
await run(["
|
|
282
|
+
// Nothing was handed over, so no work is lost with the pane it made; it closes alone, never the tab: a split the boss made there during the waits stays, and Herdr closes the tab its last pane leaves.
|
|
283
|
+
await run(["pane", "close", paneId]).catch(() => {});
|
|
284
284
|
throw error;
|
|
285
285
|
}
|
|
286
286
|
};
|
package/src/reviver.ts
CHANGED
|
@@ -110,7 +110,7 @@ export async function reviveMain(env: OpenerEnv, { session, reason, origin }: Re
|
|
|
110
110
|
const closedOld = await closeOldTab(env, row, paneId).catch(() => undefined);
|
|
111
111
|
return { tab: tabId, pane: paneId, main: main.id, file: row.file, ...(row.name ? { name: row.name } : {}), ...(row.kind ? { kind: row.kind } : {}), ...(train ? { train } : {}), ...(row.openedBy ? { openedBy: row.openedBy } : {}), ...(closedOld ? { closedOld } : {}) };
|
|
112
112
|
} catch (error) {
|
|
113
|
-
await run(["
|
|
113
|
+
await run(["pane", "close", paneId]).catch(() => {}); // the pane it made, never the tab: a split the boss made there meanwhile stays (Herdr closes an emptied tab)
|
|
114
114
|
if (!(error instanceof ReviveRefused)) attempt("failed", { error: (error as Error).message.slice(0, 300) });
|
|
115
115
|
throw error;
|
|
116
116
|
}
|
|
@@ -120,6 +120,7 @@ export async function reviveMain(env: OpenerEnv, { session, reason, origin }: Re
|
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
122
|
* D3: the old tab is closed only when the tower opened it (the record names an opener) and its one pane is the dead pane, sitting at a bare shell: `process-info` lists the shell alone in the foreground. Anything else stays for the boss.
|
|
123
|
+
* It closes by its pane, never by a tab close: Herdr takes the tab its last pane leaves, and a pane split into it since the look stays (boss 2026-11-27).
|
|
123
124
|
*/
|
|
124
125
|
async function closeOldTab(env: OpenerEnv, row: DeadRow, newPane: string): Promise<string | undefined> {
|
|
125
126
|
if (!row.openedBy || row.record.tab === undefined) return undefined;
|
|
@@ -128,7 +129,7 @@ async function closeOldTab(env: OpenerEnv, row: DeadRow, newPane: string): Promi
|
|
|
128
129
|
const info = JSON.parse(await env.run(["pane", "process-info", "--pane", row.record.pane])).result?.process_info as { shell_pid?: number; foreground_processes?: { pid?: number }[] } | undefined;
|
|
129
130
|
const fg = info?.foreground_processes ?? [];
|
|
130
131
|
if (!(fg.length === 1 && typeof info?.shell_pid === "number" && fg[0]!.pid === info.shell_pid)) return undefined;
|
|
131
|
-
await env.run(["
|
|
132
|
+
await env.run(["pane", "close", row.record.pane]);
|
|
132
133
|
return row.record.tab;
|
|
133
134
|
}
|
|
134
135
|
/** What a main's own handover needs (docs/specs/2026-11-23-tower-revive.md §8): the same safe start as an open, in the main's own workspace. */
|
|
@@ -174,7 +175,7 @@ export async function openSuccessor(env: SuccessorEnv, r: SuccessorRequest): Pro
|
|
|
174
175
|
if (sent.status !== "sent") throw new Error(`The successor ${main.name ?? main.id} did not take the handoff: ${sent.status} ${sent.code ?? ""} ${sent.detail ?? ""}`.trim());
|
|
175
176
|
return { tab: tabId, pane: paneId, main: main.id, name: r.from.name };
|
|
176
177
|
} catch (error) {
|
|
177
|
-
await run(["
|
|
178
|
+
await run(["pane", "close", paneId]).catch(() => {}); // the pane it made, never the tab (Herdr closes an emptied tab)
|
|
178
179
|
throw error;
|
|
179
180
|
}
|
|
180
181
|
}
|
package/src/server/towers.ts
CHANGED
|
@@ -710,7 +710,7 @@ export function createTowers(o: TowersOptions): Towers {
|
|
|
710
710
|
let made: Awaited<ReturnType<typeof createTab>> | undefined;
|
|
711
711
|
// The service was closed (or retired) while this ran: the new tab is not left standing.
|
|
712
712
|
const abandon = async () => {
|
|
713
|
-
if (made) await run(["
|
|
713
|
+
if (made) await run(["pane", "close", made.paneId]).catch(() => {}); // the pane it made, never the tab (Herdr closes an emptied tab)
|
|
714
714
|
return undefined;
|
|
715
715
|
};
|
|
716
716
|
try {
|
|
@@ -1083,7 +1083,7 @@ export function createTowers(o: TowersOptions): Towers {
|
|
|
1083
1083
|
made = true;
|
|
1084
1084
|
} else {
|
|
1085
1085
|
// Other shell-only leftovers are closed; failing to close one leaves a harmless tab.
|
|
1086
|
-
for (const extra of bare.slice(1)) await run(["
|
|
1086
|
+
for (const extra of bare.slice(1)) await run(["pane", "close", extra.pane_id]).catch(() => {}); // its one pane, never the tab: Herdr closes the emptied tab, and a pane split there since the look stays
|
|
1087
1087
|
if (given && (await tabs(run, ws)).find((t) => t.tab_id === given.tab_id)?.label !== TOWER_LABEL) await run(["tab", "rename", given.tab_id, TOWER_LABEL]).catch(() => {});
|
|
1088
1088
|
}
|
|
1089
1089
|
// Marked at once, so a tab left without its identity is recognised (while the marker lasts); the label stays display only.
|
|
@@ -1398,8 +1398,9 @@ export function createTowers(o: TowersOptions): Towers {
|
|
|
1398
1398
|
async close(workspace) {
|
|
1399
1399
|
const l = services.get(workspace);
|
|
1400
1400
|
if (!l) throw new Error(`The sb server stands in for no tower of workspace ${workspace}`);
|
|
1401
|
-
// The
|
|
1402
|
-
|
|
1401
|
+
// The standing pane is closed only while it is proven the tower's own (a new Herdr may have given its id to a pane of the boss's); an unproven one is left, and the service ends all the same.
|
|
1402
|
+
// The pane alone, never the tab (boss 2026-11-27): a split of the boss's there stays, the panes of its ally runs close with their runs (`lose` ends them), and Herdr closes the tab its last pane leaves.
|
|
1403
|
+
if (!tabless(l) && (l.seated || (await prove(l)) === "ours")) if (await proven(l)) await run(["pane", "close", l.record.pane]).catch(() => {});
|
|
1403
1404
|
await lose(l, "closed by the boss");
|
|
1404
1405
|
return { workspace, id: l.record.id };
|
|
1405
1406
|
},
|
package/src/spawn.ts
CHANGED
|
@@ -180,7 +180,7 @@ export function createSpawn({ run, sleep, call, live, sessionAt, home = homedir(
|
|
|
180
180
|
}
|
|
181
181
|
if (prompt) return deliver(d, paneId, prompt, track);
|
|
182
182
|
}
|
|
183
|
-
/** Runs `open` on what was just created, and closes it again when the open fails: nothing was typed into it yet, so nothing is lost with it. */
|
|
183
|
+
/** Runs `open` on what was just created, and closes it again when the open fails: nothing was typed into it yet, so nothing is lost with it. A new tab goes by its one pane (Herdr closes the emptied tab), so a split the boss made there during the join wait stays. */
|
|
184
184
|
const orClose = async (close: string[], open: () => Promise<Reply | undefined>) => {
|
|
185
185
|
try {
|
|
186
186
|
return await open();
|
|
@@ -198,7 +198,7 @@ export function createSpawn({ run, sleep, call, live, sessionAt, home = homedir(
|
|
|
198
198
|
const name = basename(dir) || dir;
|
|
199
199
|
await assertSettingsSafe([dir]);
|
|
200
200
|
const { tabId, paneId } = await createTab(run, ws.workspace_id, dir, ["STRAW_BOSS_ROLE=main"], name);
|
|
201
|
-
const failed = await orClose(["
|
|
201
|
+
const failed = await orClose(["pane", "close", paneId], async () => {
|
|
202
202
|
// sb_open_main authorises exactly one pi in this shell to promote itself (index.ts consumes it).
|
|
203
203
|
await report(run, "pane", paneId, { sb_open_main: "1" });
|
|
204
204
|
return boot(d, paneId, `main · ${name}`, prompt, "main");
|
|
@@ -216,7 +216,7 @@ export function createSpawn({ run, sleep, call, live, sessionAt, home = homedir(
|
|
|
216
216
|
if (!dir) return OUTSIDE;
|
|
217
217
|
await assertSettingsSafe([dir]);
|
|
218
218
|
const opened = await createTab(run, ws.workspace_id, dir, ["STRAW_BOSS_ROLE=member"], basename(dir) || dir);
|
|
219
|
-
created = { ...opened, close: ["
|
|
219
|
+
created = { ...opened, close: ["pane", "close", opened.paneId] };
|
|
220
220
|
} else {
|
|
221
221
|
// The new member sits beside the tab's main, or its first pane, in the picked folder, else in that pane's.
|
|
222
222
|
const lead = await leadOf(ws.workspace_id, tabId);
|
package/src/tools.ts
CHANGED
|
@@ -54,7 +54,7 @@ export const reviveParameters = () => Type.Object({
|
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
/** `boss_close_main` (docs/specs/2026-11-23-tower-close-panes.md): its description and parameters, the same for a tower session and a tower run (runmode.ts proxies the latter to the server). */
|
|
57
|
-
export const CLOSE_DESCRIPTION = "Close a main, or a dead agent pane, of your workspace. main: ask the main to quit as /boss close would, so its pane
|
|
57
|
+
export const CLOSE_DESCRIPTION = "Close a main, or a dead agent pane, of your workspace. main: ask the main to quit as /boss close would, so its pane closes: a main you opened with boss_open_main (after its done report, unless it waits for a boss decision), or a main that handed over with boss_handover once its successor is live, whoever opened it. Refused while it has a running turn, a queued message, an open dialog, a monitor, or a subagent; try again later. A main the boss opened that has not handed over, and a standing main that has not, are refused: only the boss closes them. pane: close an agent pane whose pi is gone (a bare shell, no session), the pane alone (Herdr closes a tab it empties); never a live pi, a tower's pane, or one being opened or revived. Neither: list the dead agent panes.";
|
|
58
58
|
export const closeParameters = () => Type.Object({
|
|
59
59
|
main: Type.Optional(Type.String({ description: "The main's intercom name or session id." })),
|
|
60
60
|
pane: Type.Optional(Type.String({ description: "A dead agent pane's Herdr id (as the list shows it, e.g. w1:p3)." })),
|
package/src/tower.ts
CHANGED
|
@@ -52,9 +52,10 @@ export function createTower({ pi, cfg, s, guiDir, me, tell }: Kit, { membership,
|
|
|
52
52
|
// A second tower in one workspace yields before it publishes: the live token holder wins, otherwise the lower tab id.
|
|
53
53
|
if ((holder && holder !== me() && sessions.some((x) => x.id === holder)) || (rival && rival.tab_id < s.at.tabId)) {
|
|
54
54
|
await report(run, "pane", s.at.paneId, { sb_role: null });
|
|
55
|
-
s.closing = { keepPane: true }; // its
|
|
55
|
+
s.closing = { keepPane: true }; // its pane goes with it already
|
|
56
56
|
roles.forget();
|
|
57
|
-
|
|
57
|
+
// Its own pane only, never the tab: a split beside it is not this tower's, and Herdr closes a tab its last pane leaves (boss 2026-11-27).
|
|
58
|
+
await run(["pane", "close", s.at.paneId]);
|
|
58
59
|
return;
|
|
59
60
|
}
|
|
60
61
|
s.holdsTower = true;
|
package/src/towertab.ts
CHANGED
|
@@ -46,7 +46,7 @@ async function open({ run, sleep, live, moveFirst, model, trustDir }: TowerEnv,
|
|
|
46
46
|
if (!marked) await report(run, "pane", paneId, { sb_role: "tower" });
|
|
47
47
|
await moveFirst(reused.tab_id);
|
|
48
48
|
// Other shell-only leftovers are closed; failing to close one leaves a harmless tab, so it does not stop the tower.
|
|
49
|
-
for (const extra of bare.slice(1)) await run(["
|
|
49
|
+
for (const extra of bare.slice(1)) await run(["pane", "close", extra.pane_id]).catch(() => {}); // its one pane, never the tab: Herdr closes the emptied tab, and a pane split there since the look stays
|
|
50
50
|
} else {
|
|
51
51
|
const dir = workspace.worktree?.checkout_path ?? cwd;
|
|
52
52
|
await assertSettingsSafe([dir]);
|
|
@@ -67,7 +67,7 @@ async function open({ run, sleep, live, moveFirst, model, trustDir }: TowerEnv,
|
|
|
67
67
|
}
|
|
68
68
|
// A trust question the tower waits on is not counted (trust/wait.ts); one nobody answers fails the opening, and a tab this opening made goes with it (a leftover tab is the user's to keep).
|
|
69
69
|
const id = await waitPastTrust(sleep, held, TOWER_WAIT_MS, 1000, trustDir ? { dir: trustDir, pane: paneId } : undefined).catch(async (error: unknown) => {
|
|
70
|
-
if (created) await run(["
|
|
70
|
+
if (created) await run(["pane", "close", paneId]).catch(() => {}); // the pane it made, never the tab (Herdr closes an emptied tab)
|
|
71
71
|
throw error;
|
|
72
72
|
});
|
|
73
73
|
if (!id) throw new Error(`The tower of ${workspace.label} did not publish its token within ${TOWER_WAIT_MS / 1000} s (pane ${paneId})`);
|