pi-straw-boss 0.81.3 → 0.81.4

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/tools.ts +10 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-straw-boss",
3
- "version": "0.81.3",
3
+ "version": "0.81.4",
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/tools.ts CHANGED
@@ -36,7 +36,6 @@ export const linkRequestParameters = () => Type.Object({
36
36
  })),
37
37
  reason: Type.String({ description: "One line: why you ask. The boss reads it in the dialog." }),
38
38
  });
39
-
40
39
  /** 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. */
41
40
  export const PARENT_ONLY: readonly string[] = ["board_read", "board_set", "boss_auto", "boss_broadcast", "boss_close_main", "boss_duty", "boss_open_main", "boss_promote", "boss_rename", "boss_server", "boss_status", "boss_wait_ask", "call_tower", "link_request", "tower_done", "tower_list", "tower_memory", "tower_reply", "tower_send", "train_car"];
42
41
 
@@ -50,6 +49,12 @@ export function createTools({ pi, cfg, s, guiDir, me, role }: Kit, { mainDuty, p
50
49
  return { content: [{ type: "text", text }], details };
51
50
  },
52
51
  });
52
+ const standingTwinWarning = async (name = pi.getSessionName() || s.ownName) => {
53
+ const folded = name.trim().toLowerCase(), id = me();
54
+ const net = folded && !s.remoteOrigin ? await read().catch(() => undefined) : undefined, workspace = net?.ps.find((p) => p.pane_id === s.at.paneId)?.workspace_id;
55
+ const twin = net?.sessions.find((x) => x.id !== id && x.name?.trim().toLowerCase() === folded && net.ps.some((p) => p.pane_id === x.herdrLocation?.paneId && p.workspace_id === workspace && p.tokens?.sb_role === "main" && p.tokens.sb_duty === "standing"));
56
+ return twin ? `\nWarning: ${JSON.stringify(twin.name?.trim())} (${twin.id.slice(0, 8)}) is another standing main with this name in your workspace. Both would be told the same link waits when no owner is resolved. If you took over from that session, tell it by intercom to complete the handoff: call boss_duty with duty coordinator, then boss_rename itself. Otherwise, rename one of the sessions.` : "";
57
+ };
53
58
  return {
54
59
  addNetTools() {
55
60
  tool("boss_status", "Show this workspace's Straw Boss coordinators: each tab's main agent and its kind, this workspace's tower, the head tower, and the other towers.", Type.Object({}), async () => {
@@ -135,8 +140,7 @@ export function createTools({ pi, cfg, s, guiDir, me, role }: Kit, { mainDuty, p
135
140
  s.boardId = me();
136
141
  return setBoard({ dir: join(guiDir, "board"), stateDir: guiDir, session: me(), isMain: ownsBoard(role()), now: cfg.now(), cwd, input: { now, items }, home, agentDir, autoFill: true });
137
142
  });
138
- // The session's name is what the net and the GUI show for it. A main agent names its tab too: the tab is its squad, and pi-auto-tab-name
139
- // leaves a tab alone once anyone else labelled it. A tower keeps its own name.
143
+ // A main names its own tab: pi-auto-tab-name leaves a tab alone once anyone else labelled it.
140
144
  if (!s.isTower) tool("boss_rename", "Name this session with a short phrase for the work it is doing now (e.g. \"MP-3584 mask\", \"重構通知模組\"). The net and the GUI show it whole; a main agent's Herdr tab takes it as its label, cut to 16 characters. More than 40 characters is refused.",
141
145
  Type.Object({ name: Type.String({ description: "The phrase: what this session works on now. 16 characters or fewer show whole in the tab label; at most 40." }) }),
142
146
  async ({ name }) => {
@@ -157,7 +161,7 @@ export function createTools({ pi, cfg, s, guiDir, me, role }: Kit, { mainDuty, p
157
161
  const tab = failed === undefined ? "" : failed ? ` The tab kept its label: ${failed}` : ` The tab is now labelled "${label}".`;
158
162
  if (s.joined) await digest.note(s.at.workspaceId, `${was} renamed itself "${phrase}" (tab ${failed === "" ? label : s.info.tab})`).catch(() => {});
159
163
  const kind = migrated ? ` Your kind is now integrator (migrated by name); boss_duty changes it.` : role() === "main" && INTEG_NAME.test(phrase) && s.duty !== undefined && s.duty !== "integrator" ? ` Your kind stays ${s.duty}; boss_duty integrator if you now run trains.` : "";
160
- return { text: `This session is now named "${phrase}".${tab}${kind}`, details: { name: phrase } };
164
+ return { text: `This session is now named "${phrase}".${tab}${kind}${role() === "main" && mainDuty.now() === "standing" ? await standingTwinWarning(phrase) : ""}`, details: { name: phrase } };
161
165
  });
162
166
  },
163
167
  // A main's kind (docs/specs/2026-11-09-agent-kinds.md §3). `integrator` is left out while integration is off.
@@ -173,13 +177,13 @@ export function createTools({ pi, cfg, s, guiDir, me, role }: Kit, { mainDuty, p
173
177
  if (s.remoteOrigin) throw new Error("A teammate's turn cannot change this main's kind");
174
178
  if (!isCoordinatorDuty(duty) || (duty === "integrator" && !mainDuty.integrationOn())) throw new Error("Integration is off on this computer: no integrator");
175
179
  if (!why || why.length > 200) throw new Error("reason is required: one line of 1 to 200 characters");
176
- if (s.duty === duty) return { text: `Your kind is already ${duty}`, details: { duty } };
180
+ if (s.duty === duty) return { text: `Your kind is already ${duty}${duty === "standing" ? await standingTwinWarning() : ""}`, details: { duty } };
177
181
  if (s.duty === "integrator") {
178
182
  const open = (todosOf(snapshotOfBranch(s.branch())) ?? []).filter((t) => t.sb?.kind === "train" && t.status !== "completed").length;
179
183
  if (open) throw new Error(`${open} of your trains are forming or departing: depart or return them first`);
180
184
  }
181
185
  const { from } = mainDuty.write(duty, why, "boss_duty");
182
- return { text: `Your kind is now ${duty} (was ${from ?? "none"}).`, details: { duty, from: from ?? null } };
186
+ return { text: `Your kind is now ${duty} (was ${from ?? "none"}).${duty === "standing" ? await standingTwinWarning() : ""}`, details: { duty, from: from ?? null } };
183
187
  });
184
188
  },
185
189
  addPromote() {