pi-straw-boss 0.7.1 → 0.7.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/README.md +1 -1
- package/package.json +1 -1
- package/src/index.ts +7 -1
- package/src/order.ts +7 -3
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ The view is on whenever the Herdr server starts, and one key switches it off and
|
|
|
61
61
|
pi-straw-boss writes the sort key (`sb_order`), a role label (`sb_mark`) and, on subagents, a tree branch (`sb_indent`) the view and your sidebar rows can use.
|
|
62
62
|
It needs Herdr 0.9.3 or newer and node.
|
|
63
63
|
|
|
64
|
-
<p align="center"><img src="docs/sidebar-net-view.png" width="308" alt="Herdr's sidebar in the net view
|
|
64
|
+
<p align="center"><img src="docs/sidebar-net-view.png" width="308" alt="Herdr's sidebar in the net view: each workspace's tower with the radio tower glyph first, each main agent on two rows with a star and its tab's label, and every subagent on a tree branch under the session that launched it"></p>
|
|
65
65
|
|
|
66
66
|
<p align="center"><sub>The net view with each agent's role mark. <a href="docs/how-it-works.md#sidebar-net-view">How it works</a> has the sidebar rows that show them.</sub></p>
|
|
67
67
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-straw-boss",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.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/src/index.ts
CHANGED
|
@@ -22,6 +22,7 @@ const NAMESPACE = /^[a-z0-9][a-z0-9._/-]{0,63}$/;
|
|
|
22
22
|
const ENTRY = "straw-boss";
|
|
23
23
|
const PROMPTS = ["main", "tower", "member", "member-no-main"];
|
|
24
24
|
const REFRESH_MS = 4 * 60_000;
|
|
25
|
+
const KID_MARK_MS = [3_000, 15_000];
|
|
25
26
|
const CLAIM_MS = 5000;
|
|
26
27
|
const CONNECT_MS = 15_000;
|
|
27
28
|
const SEND_MS = 30_000;
|
|
@@ -390,6 +391,11 @@ export function createStrawBoss({ run = herdrRun, api = herdrApi(), call = herdr
|
|
|
390
391
|
}
|
|
391
392
|
});
|
|
392
393
|
|
|
394
|
+
// A launched subagent is marked within seconds, once its pane shows its session file, instead of at the next 4 minute refresh.
|
|
395
|
+
pi.on("tool_result", (event) => {
|
|
396
|
+
if (["subagent", "subagent_resume"].includes(event.toolName) && !isTower && !barred && role()) for (const ms of KID_MARK_MS) setTimeout(() => void publish(), ms).unref();
|
|
397
|
+
});
|
|
398
|
+
|
|
393
399
|
pi.on("session_shutdown", async () => {
|
|
394
400
|
if (gui) await switchRemote(gui, false, guiDir, ts).catch(() => {});
|
|
395
401
|
await gui?.stop();
|
|
@@ -403,7 +409,7 @@ export function createStrawBoss({ run = herdrRun, api = herdrApi(), call = herdr
|
|
|
403
409
|
const held = holdsTower;
|
|
404
410
|
holdsTower = false;
|
|
405
411
|
if (!role() || !at) return;
|
|
406
|
-
await report(run, "pane", at.paneId, { sb_role: null, sb_order: null, sb_mark: null, sb_indent: null }).catch(() => {});
|
|
412
|
+
await report(run, "pane", at.paneId, { sb_role: null, sb_order: null, sb_mark: null, sb_indent: null, sb_tab: null }).catch(() => {});
|
|
407
413
|
await clearOrder(run, [...kids]);
|
|
408
414
|
if (held) await report(run, "workspace", at.workspaceId, { tower: null }).catch(() => {});
|
|
409
415
|
});
|
package/src/order.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { subagents } from "./dashboard.ts";
|
|
2
2
|
import { ARROW, type HerdrRun, type HerdrTab, isSub, MARK, type Pane, panes, type Place, report, tabs, workspaces, type Workspace } from "./herdr.ts";
|
|
3
3
|
|
|
4
|
-
//
|
|
4
|
+
// Four display tokens for the sidebar plugin and for Herdr's own Agents rows, written next to `sb_role`:
|
|
5
5
|
// - `sb_order`: a sort key that lays the net out as the head tower's workspace first, then the other workspaces in Herdr's order, in each the tower
|
|
6
6
|
// and then the tabs in tab order, in each tab the main agent and then the members, and every subagent right after the session that launched it,
|
|
7
7
|
// its own subagents after it in turn. Segments are fixed-width and `.`-separated, so plain string order is the numeric order of every segment,
|
|
8
8
|
// and a subagent's key is its parent's key plus one more segment, which sorts after the parent and before the parent's next sibling.
|
|
9
|
-
// - `sb_mark`: a short label that says what a net member is, a star and
|
|
9
|
+
// - `sb_mark`: a short label that says what a net member is, a star and its tab's label for a main agent, a person (U+F007) alone for a member, and `[sub]` and the launcher's name for a subagent.
|
|
10
10
|
// A tower has none: its tab already carries the radio tower glyph.
|
|
11
|
+
// - `sb_tab`: a member's tab label, which the first row shows in place of Herdr's tab item; a main agent's is in its mark instead.
|
|
11
12
|
// - `sb_indent`: a tree branch on a subagent alone, like Herdr's Spaces panel draws a worktree: `├─` while a later subagent of the same launcher is marked, `└─` on the last. A row put before the state icon shows it as the
|
|
12
13
|
// indent under the launcher. A tower, a main agent and a member carry none.
|
|
13
14
|
// A session writes them for itself and for the subagents it launched, which never join and write nothing, on the same 4 minute refresh as `sb_role`.
|
|
@@ -58,7 +59,10 @@ export async function netTokens(run: HerdrRun, place: Place, role: "tower" | "ma
|
|
|
58
59
|
const [ps, all, tabList] = [await panes(run), await workspaces(run), await tabs(run, place.workspaceId)];
|
|
59
60
|
const pane = ps.find((p) => p.pane_id === place.paneId), key = pane && orderKey(role, pane, ps, all, tabList);
|
|
60
61
|
const joined = new Set(ps.filter((p) => p.tokens?.sb_role).map((p) => p.pane_id));
|
|
61
|
-
|
|
62
|
+
// A main agent's tab label goes in its mark, for a row of its own; a member's in `sb_tab`, which stands for the tab item in the first row.
|
|
63
|
+
const tab = tabList.find((t) => t.tab_id === pane?.tab_id)?.label || null;
|
|
64
|
+
const mark = role === "tower" ? null : role === "main" ? (tab ? `${MARK.main} ${tab}` : MARK.main) : MARK[role];
|
|
65
|
+
return { own: { sb_order: key ?? null, sb_mark: mark, sb_indent: null, sb_tab: role === "member" ? tab : null }, kids: key ? descendants(pane, key, name, ps, now) : [], joined };
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
/**
|