pi-straw-boss 0.101.0 → 0.102.0
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/prompts/member.md +1 -1
- package/src/callpeer.ts +52 -0
- package/src/header.ts +1 -1
- package/src/index.ts +3 -1
- package/src/membership.ts +1 -1
- package/src/tools.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-straw-boss",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.102.0",
|
|
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/member.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Straw Boss: you are a member of tab {{tab}} of workspace {{workspace}}, and the tab has a main agent
|
|
1
|
+
Straw Boss: you are a member of tab {{tab}} of workspace {{workspace}}, and the tab has a main agent. Before you dispatch a subagent, tell it with `call_peer` (to: main) what you will do and which resources (ports, databases, files, branches) it uses; take other shared-resource questions there too. Write to agents terse, caveman-style: point first, no ceremony; keep negations, numbers, paths, IDs, and quoted decisions verbatim; full sentences where a fragment could mislead; a brief still carries its goal, context, reasons with their cause, scope, what others own, and acceptance check, because a thin brief makes workers redo or miss work; a reader unsure of the intent restates it or asks before acting. Report coordination friction, such as an agent, endpoint, or shared resource you cannot reach, with `call_tower` and `why: blocked`.
|
package/src/callpeer.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import type { Reach } from "./reach.ts";
|
|
3
|
+
import type { Kit } from "./state.ts";
|
|
4
|
+
|
|
5
|
+
// `call_peer`: a member's way to a peer of its tab's net, found by sb when it is called (the boss, 2026-11-26: 「sb 包一個工具,當下找 main」; intercom stays the fallback). The one target now is `main`: the broker's record
|
|
6
|
+
// of the tab's main, read again at the call (`sync`), so a handover or a rotation never sends to the old session. Only a member has it in its active tools, set before each run's first model call as thread_post is
|
|
7
|
+
// (threadtools.ts); a main, a train, a tower, and a subagent never see it, and a call from any of them is refused.
|
|
8
|
+
|
|
9
|
+
export const PEER_TOOL = "call_peer";
|
|
10
|
+
export const PEER_DESCRIPTION = "Message a peer of your tab; sb finds it at the call. to: main (now, after a handover too). ask: you expect a reply (it comes by intercom).";
|
|
11
|
+
export const peerParameters = () => Type.Object({
|
|
12
|
+
to: Type.Literal("main"),
|
|
13
|
+
message: Type.String(),
|
|
14
|
+
ask: Type.Optional(Type.Boolean()),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export interface PeerDeps {
|
|
18
|
+
post: Reach["post"];
|
|
19
|
+
/** The membership's refresh: reads the broker's record of the tab's main and the live sessions again. */
|
|
20
|
+
sync: () => Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Returns the registration, made once at the join (a joined session's tools come then); the active set follows the role at every run's start. */
|
|
24
|
+
export function createPeerTool({ pi, s, role }: Kit, { post, sync }: PeerDeps): () => void {
|
|
25
|
+
let registered = false;
|
|
26
|
+
pi.on("before_agent_start", () => {
|
|
27
|
+
if (!registered) return;
|
|
28
|
+
const active = pi.getActiveTools(), want = role() === "member" ? [...new Set([...active, PEER_TOOL])] : active.filter((name) => name !== PEER_TOOL);
|
|
29
|
+
if (want.length !== active.length) pi.setActiveTools(want);
|
|
30
|
+
});
|
|
31
|
+
return () => {
|
|
32
|
+
if (registered) return;
|
|
33
|
+
registered = true;
|
|
34
|
+
pi.registerTool({
|
|
35
|
+
name: PEER_TOOL, label: PEER_TOOL, description: PEER_DESCRIPTION, parameters: peerParameters(), defaultActive: false,
|
|
36
|
+
execute: async (_id, { message, ask }) => {
|
|
37
|
+
if (role() !== "member") throw new Error(`${PEER_TOOL} is for a tab's members; this session is ${role() ?? "in no tab's net"}. Use intercom, or call_tower for your tower.`);
|
|
38
|
+
if (!message.trim()) throw new Error("The message is empty");
|
|
39
|
+
await sync();
|
|
40
|
+
const main = s.mainId;
|
|
41
|
+
if (!main) throw new Error(`Your tab ${s.info.tab ?? ""} has no main agent. When your work grows, call boss_promote to become it (dispatching a subagent promotes you); report coordination friction with call_tower.`);
|
|
42
|
+
const name = s.info.main || main;
|
|
43
|
+
const result = await post(main, message, "call_peer", "tab", ask === true);
|
|
44
|
+
if (result.status !== "sent") throw new Error(`The main ${name} (${main.slice(0, 8)}) did not take the message: ${[result.status, result.code, result.detail].filter(Boolean).join(" ")}`);
|
|
45
|
+
return {
|
|
46
|
+
content: [{ type: "text", text: `Sent to ${name}, the main of tab ${s.info.tab}. ${ask ? "Its reply comes by intercom." : "No reply is expected."}` }],
|
|
47
|
+
details: { to: "main", id: main, name, status: result.status, ask: ask === true },
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
}
|
package/src/header.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { restrictLabel } from "./link/text.ts";
|
|
9
9
|
|
|
10
|
-
export type Kind = "call_tower" | "broadcast" | "tower_send" | "tower_reply" | "handoff" | "link_reply" | "wait_card" | "car_notice" | "board_clear" | "auto_notice" | "capacity_notice" | "wait_parked" | "wait_returned" | "watch_report" | "link_wait" | "link_wait_state" | "link_notice";
|
|
10
|
+
export type Kind = "call_tower" | "call_peer" | "broadcast" | "tower_send" | "tower_reply" | "handoff" | "link_reply" | "wait_card" | "car_notice" | "board_clear" | "auto_notice" | "capacity_notice" | "wait_parked" | "wait_returned" | "watch_report" | "link_wait" | "link_wait_state" | "link_notice";
|
|
11
11
|
/** The roles a joined session publishes in its pane's `sb_role` token, and so the roles a header names (`train`: the worker the tower opened for an integrator's manifest). */
|
|
12
12
|
export const ROLE_WORDS = ["tower", "main", "member", "train"] as const;
|
|
13
13
|
/** `session` is a pi session that did not join the net (a scope `all` broadcast reaches it). `head`: the tower of the head workspace. */
|
package/src/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ import { createLink } from "./link/runtime.ts";
|
|
|
29
29
|
import { createMainDuty } from "./mainduty.ts";
|
|
30
30
|
import { createMembership } from "./membership.ts";
|
|
31
31
|
import { createPresence } from "./presence.ts";
|
|
32
|
+
import { createPeerTool } from "./callpeer.ts";
|
|
32
33
|
import { createReach } from "./reach.ts";
|
|
33
34
|
import { createRunMode } from "./runmode.ts";
|
|
34
35
|
import { createRoles } from "./roles.ts";
|
|
@@ -101,8 +102,9 @@ export function createStrawBoss({ run: given, world: reading, api = herdrApi(),
|
|
|
101
102
|
const cars = carLink(kit);
|
|
102
103
|
pi.on("session_start", () => void (kit.s.toolSet ??= { link: link.inUse() && link.attended(), cars: cars.enabled(), carApp: hasIntegrationApp(cfg.cwd()) }));
|
|
103
104
|
let trainGuard: TrainGuard | undefined;
|
|
105
|
+
const addPeer = createPeerTool(kit, { post: reach.post, sync: () => membership.sync() }); // a member's call_peer (callpeer.ts)
|
|
104
106
|
const addTrainCar = trainCarTool(kit, () => trainGuard, cars, (text) => reach.callTower(text, undefined, false, "blocked"));
|
|
105
|
-
const membership = createMembership(kit, { presence, election, guard, briefing, roles, openTower: reach.openTower, register: () => (tools.addNetTools(), s.isTower || (watch.addTool(), pair.addTool(), wrap.addTool()), tools.addPromote(), tools.addDuty(), tools.addHandover(), addTrainCar()), onMain: link.look, control: () => control });
|
|
107
|
+
const membership = createMembership(kit, { presence, election, guard, briefing, roles, openTower: reach.openTower, register: () => (tools.addNetTools(), s.isTower || (watch.addTool(), pair.addTool(), wrap.addTool()), tools.addPromote(), tools.addDuty(), tools.addHandover(), addTrainCar(), addPeer()), onMain: link.look, control: () => control });
|
|
106
108
|
// `look` (above) starts and upgrades the sb server (src/server/) and is the way to it; a session that is no part of that has none.
|
|
107
109
|
const pair = createBossPair(kit, { ask: cfg.ask ?? look?.ask, remote: () => Boolean(link.remoteScope()) }); // boss_pair and board_read's review threads (bosspair.ts)
|
|
108
110
|
createCapFill(kit); // a main's capacity facts for the board (capfill.ts)
|
package/src/membership.ts
CHANGED
|
@@ -137,6 +137,6 @@ export function createMembership({ pi, cfg, s, me, tell }: Kit, { presence, elec
|
|
|
137
137
|
}
|
|
138
138
|
return { promoted: true, text: `You are now the main agent of tab ${s.info.tab}.` };
|
|
139
139
|
};
|
|
140
|
-
return { connect, connected, joinNet, promote, adoptOpener };
|
|
140
|
+
return { connect, connected, joinNet, promote, adoptOpener, /** Reads the tab's net again (its main, the labels); call_peer looks before it sends (callpeer.ts). */ sync };
|
|
141
141
|
}
|
|
142
142
|
export type Membership = ReturnType<typeof createMembership>;
|
package/src/tools.ts
CHANGED
|
@@ -44,7 +44,7 @@ export const linkRequestParameters = () => Type.Object({
|
|
|
44
44
|
reason: Type.String({ description: "One line: why you ask. The boss reads it in the dialog." }),
|
|
45
45
|
});
|
|
46
46
|
/** Every tool sb registers, all of them after the child return (index.ts): a role that lists one fails `/boss roles-check` (rolescheck.ts). tests/roles-check.test.ts pins it to the recorded registry. */
|
|
47
|
-
export const PARENT_ONLY: readonly string[] = ["board_read", "board_set", "boss_auto", "boss_broadcast", "boss_close_main", "boss_duty", "boss_handover", "boss_open_main", "boss_pair", "boss_promote", "boss_rename", "boss_revive_main", "boss_server", "boss_wait_ask", "boss_watch", "boss_wrap", "call_tower", "ledger_sweep", "link_request", "tower_done", "tower_list", "tower_memory", "tower_reply", "tower_send", "train_car"];
|
|
47
|
+
export const PARENT_ONLY: readonly string[] = ["board_read", "board_set", "boss_auto", "boss_broadcast", "boss_close_main", "boss_duty", "boss_handover", "boss_open_main", "boss_pair", "boss_promote", "boss_rename", "boss_revive_main", "boss_server", "boss_wait_ask", "boss_watch", "boss_wrap", "call_peer", "call_tower", "ledger_sweep", "link_request", "tower_done", "tower_list", "tower_memory", "tower_reply", "tower_send", "train_car"];
|
|
48
48
|
/** `boss_revive_main` (docs/specs/2026-11-23-tower-revive.md §4): its description and parameters, the same for a tower session and a tower run (runmode.ts proxies the latter to the server). */
|
|
49
49
|
export const REVIVE_DESCRIPTION = "List the mains and trains of this workspace that have a role record, with their state (live, dead, quit, restoring, stale, invalid), or revive a dead one: the same pi session comes back in a new tab as the same Straw Boss identity (its role, kind, name, board row, todos, and the waits it held), and it picks up its own subagents. Call it when a main_died notice names one and its work is not done, or when a request names a main that died. Revive a quit one only when a request names it. Refused, with the reason, for members, towers, mains opened for a teammate's device, a session a live pane runs, a second try of one death, and a session that died twice in a day after a revive.";
|
|
50
50
|
export const reviveParameters = () => Type.Object({
|