pi-straw-boss 0.17.0 → 0.17.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/package.json +1 -1
- package/src/index.ts +8 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-straw-boss",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.1",
|
|
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/src/index.ts
CHANGED
|
@@ -193,11 +193,13 @@ export function createStrawBoss({ run = herdrRun, api = herdrApi(), call = herdr
|
|
|
193
193
|
if (autoTower) {
|
|
194
194
|
const all = await panes(run), members = all.filter((p) => p.workspace_id === at.workspaceId && ["member", "main"].includes(p.tokens?.sb_role ?? ""));
|
|
195
195
|
const towers = (await workspaces(run)).filter((w) => w.workspace_id !== at.workspaceId && live(w.tokens?.tower));
|
|
196
|
-
|
|
196
|
+
// A tower closed on purpose stays closed until the base grows past the members it had then (a subagent or /boss tower opens it any time).
|
|
197
|
+
const closedAt = Number(ws?.tokens?.sb_tower_quit ?? -1);
|
|
198
|
+
if (members.length >= 2 && members.length > closedAt && towers.length) return void (await openTower(undefined, true));
|
|
197
199
|
}
|
|
198
200
|
missing ??= now();
|
|
199
201
|
if (!live(main) || (pinned && pinned !== state?.main) || now() - (state?.since ?? 0) < TOWER_OPEN_MS) return;
|
|
200
|
-
if (ws?.tokens?.sb_tower_quit
|
|
202
|
+
if (ws?.tokens?.sb_tower_quit !== undefined || now() - missing >= TOWER_GRACE_MS) pin(c);
|
|
201
203
|
};
|
|
202
204
|
const keepGuard = () => {
|
|
203
205
|
let checking = false; // one check at a time: a slow Herdr must not pile checks up in the queue
|
|
@@ -559,8 +561,10 @@ export function createStrawBoss({ run = herdrRun, api = herdrApi(), call = herdr
|
|
|
559
561
|
if (!role() || !at) return;
|
|
560
562
|
await report(run, "pane", at.paneId, { sb_role: null, sb_opened_by: null, sb_order: null, sb_mark: null, sb_indent: null, sb_name: null, sb_tab: null, sb_main_tab: null, sb_member_tab: null }).catch(() => {});
|
|
561
563
|
await clearOrder(run, [...kids]);
|
|
562
|
-
// A tower that quits says so, so the mains are cleared at once instead of after the grace a /reload gets
|
|
563
|
-
|
|
564
|
+
// A tower that quits says so with the members the base has, so the mains are cleared at once instead of after the grace a /reload gets,
|
|
565
|
+
// and the guard opens no new tower until the base grows past them.
|
|
566
|
+
const members = event.reason === "quit" && held ? (await panes(run, at.workspaceId).catch(() => [])).filter((p) => ["member", "main"].includes(p.tokens?.sb_role ?? "")).length : 0;
|
|
567
|
+
if (held) await report(run, "workspace", at.workspaceId, { tower: null, ...(event.reason === "quit" ? { sb_tower_quit: String(members) } : {}) }).catch(() => {});
|
|
564
568
|
});
|
|
565
569
|
|
|
566
570
|
// /boss gui is a read-only viewer: any session may open it, and it joins nothing and writes no token. A session outside the net
|