@howaboua/pi-shepherdr 0.2.13 → 0.2.15
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/CHANGELOG.md +14 -0
- package/README.md +11 -5
- package/package.json +6 -6
- package/src/agents-answer.ts +22 -0
- package/src/agents-discovery.ts +2 -2
- package/src/agents-tool.ts +2 -1
- package/src/ask-answer.ts +32 -18
- package/src/board/awareness.ts +115 -0
- package/src/board/host.ts +59 -6
- package/src/board/tool.ts +0 -3
- package/src/context-briefing.ts +226 -0
- package/src/controller.ts +81 -14
- package/src/delivery.ts +33 -0
- package/src/messages.ts +141 -15
- package/src/monitor-questions.ts +249 -0
- package/src/monitor-record.ts +6 -0
- package/src/monitor-state.ts +10 -4
- package/src/monitor.ts +40 -2
- package/src/remote/shepherdr-session-watch.mjs +72 -0
- package/src/remote/shepherdr-session.mjs +32 -2
- package/src/remote/shepherdr.mjs +21 -1
- package/src/remote-client.ts +66 -24
- package/src/session-reader.ts +49 -3
- package/src/types.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @howaboua/pi-shepherdr
|
|
2
2
|
|
|
3
|
+
## 0.2.15
|
|
4
|
+
|
|
5
|
+
- Show a quiet, theme-aware notice with the channel name after an agent successfully posts to the board. Notices remain visible in restored history without adding model context.
|
|
6
|
+
|
|
7
|
+
## 0.2.14
|
|
8
|
+
|
|
9
|
+
- Delegated agents keep reporting after task completion, including follow-up work.
|
|
10
|
+
|
|
11
|
+
- Added shared-board awareness across native, Code and Notebook modes.
|
|
12
|
+
- Preserves orchestration guidance across compaction and context rollover.
|
|
13
|
+
- Restores running workers' targets and full tasks after compaction or context rollover to prevent duplicate delegation.
|
|
14
|
+
- Parents receive and answer asynchronous Ask questions while workers continue.
|
|
15
|
+
- Updated agent guidance to close finished workers without sending extra messages.
|
|
16
|
+
|
|
3
17
|
## 0.2.13
|
|
4
18
|
|
|
5
19
|
- Added Remote notes and history to existing-agent attachment, including mixed Local, Tree and Remote storage.
|
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ The agent tool is always available in Pi, Code Mode and Notebook Mode. Run Pi in
|
|
|
34
34
|
|
|
35
35
|
**Settings** contains orchestration and board preferences. **Status** shows machine connections and reconnect actions. **Connections** adds SSH machines through Herdr's setup flow. Agents handle discovery, attachment and detachment through the `agents` tool, not this panel.
|
|
36
36
|
|
|
37
|
-
`/herdr` is the only entry point; board, connect and orchestration subcommands are replaced by panel controls. Outside the TUI, it reports status without changing it. An orchestration change records one visible guidance message without triggering a turn. Resumed sessions restore their last mode; new sessions start with normal guidance. Tool availability and monitoring do not depend on this mode.
|
|
37
|
+
`/herdr` is the only entry point; board, connect and orchestration subcommands are replaced by panel controls. Outside the TUI, it reports status without changing it. An orchestration change records one visible guidance message without triggering a turn. Resumed sessions restore their last mode; new sessions start with normal guidance. The current guidance returns when a new model context no longer contains it, including turns started by worker messages. Tool availability and monitoring do not depend on this mode.
|
|
38
38
|
|
|
39
39
|
To add a machine, enter an SSH target or alias, a label and an optional remote session under **Connections**. Herdr performs setup in the terminal and asks before installing or replacing its remote server. OpenSSH owns authentication; Shepherdr does not store credentials. Profiles remain in Herdr's existing catalog, where they can also be renamed, disabled or removed.
|
|
40
40
|
|
|
@@ -63,22 +63,26 @@ Call the `agents` tool with `action: "help"` before first use, then send flat re
|
|
|
63
63
|
| `attach` | Share context or join a board with an existing idle agent |
|
|
64
64
|
| `detach` | Leave selected membership and retain read-only counterpart checkpoints |
|
|
65
65
|
| `read` | Read the latest assistant reply or bounded terminal output |
|
|
66
|
-
| `answer` | Answer a worker
|
|
66
|
+
| `answer` | Answer a worker's blocking or asynchronous Pi Ask |
|
|
67
67
|
| `watch` | Push future settlement from an existing Pi agent |
|
|
68
68
|
| `unwatch` | Stop reporting an agent |
|
|
69
69
|
|
|
70
70
|
`spawn` and `assign` block by default. Set `blocking: false` when the controller should continue other work immediately. A profile's `blocking` setting overrides the call for `spawn`. Task completion and blockage are then delivered automatically.
|
|
71
71
|
|
|
72
|
-
`answer` requires the pending `ask_id` from `read` or a
|
|
72
|
+
`answer` requires the pending `ask_id` from `read` or a question report. It handles both blocking and asynchronous Ask prompts. It returns `accepted` only when that exact Ask persisted the supplied responses; an accepted retry sends no input. Answering an asynchronous question does not wait for the worker's task to finish.
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
Asynchronous Ask prompts notify the controller while the worker keeps working. Session-file events drive local and remote notifications without marking the worker blocked or settling its task. Duplicate notifications are suppressed across controller restoration. Update Pi Ask on workers together with Shepherdr on controllers.
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
Needed input and work changes use `send`. It returns after submission, does not accept `blocking`, and never creates or changes a watch or task. Use `assign` only to delegate work whose result you need, not to exchange coordination messages. Close finished workers silently instead of waking them with completion acknowledgements or shutdown notices.
|
|
77
|
+
|
|
78
|
+
Delegation and explicit `watch` keep reporting subsequent work until `unwatch` or the agent's pane closes. Finishing or failing a task clears that task, not its watch. Follow-up messages through `send` retain completion reporting without replacing the task.
|
|
77
79
|
|
|
78
80
|
Every `spawn` needs an `agent_type` and a concise two- or three-word `label`. The label names both the Herdr tab and Pi session; the routing `name` remains optional and is derived from it when omitted.
|
|
79
81
|
|
|
80
82
|
Cancelling a blocking call does not kill its worker. The waiter detaches and the eventual result returns through normal asynchronous delivery.
|
|
81
83
|
|
|
84
|
+
After Pi compaction or Pi Codex context rollover, the controller receives its active agents' exact machine and target, full delegated task and last observed status. Existing work stays assigned instead of being delegated again. This reminder does not start a turn or bypass normal turn preparation.
|
|
85
|
+
|
|
82
86
|
Prompts sent through `agents` identify peer messages versus delegated tasks and include the sender's host, session, workspace, tab and pane identity, with current names. Reports include source workspace and tab names too. Raw `herdr agent prompt` calls bypass this attribution. These are runtime locations, not the desktop window showing a pane.
|
|
83
87
|
|
|
84
88
|
Messages sent through `agents` bypass the receiving Pi editor, preserving unsent drafts. Update and reload Shepherdr on receiving agents as well as controllers. If a receiver is unavailable, delivery fails without pasting into its terminal. Raw `herdr agent prompt` still uses terminal input and does not provide this protection.
|
|
@@ -137,6 +141,8 @@ If the global agent directory is the launch folder's `.pi` directory, that file
|
|
|
137
141
|
|
|
138
142
|
Agents call `board` with `action: "help"` to discover channels, posts, replies, search, subscriptions and bounded reads. Code and Notebook Mode use `tools.board`. Agents choose when discussions are useful. Enabling the board, starting sessions, reading history and spawning children do not create an empty board. The first successful channel creation or post to a new channel creates it.
|
|
139
143
|
|
|
144
|
+
Agents receive a board briefing once per context window, including after compaction. It distinguishes an empty board from existing posts, leaves setup to the main agent, and points members to relevant discussion. Joining or re-enabling a board adds a briefing at the next model request. Resuming the same window does not repeat it. Post text stays behind the board tool.
|
|
145
|
+
|
|
140
146
|
Results fit 8,000 serialized UTF-8 bytes, including JSON escaping and metadata. Reads may return smaller pages or text slices than requested. Continue with the returned cursor or `next_offset_chars`. A search with `after_message_id` requires a post in the selected board, even before an archive exists.
|
|
141
147
|
|
|
142
148
|
One archive at `<owning-folder>/.pi/agent-message-board.sqlite` retains all boards for that folder. Each root Pi session has an isolated board; resume keeps it and new root sessions get separate boards. Children spawned while the board is enabled inherit its location and board ID even with another working directory. The spawn result's `boardAgent` is their address for subscriptions and explicit notifications, distinct from a pane or shared-notes identity. Independently started agents, existing `assign` targets and children spawned while it is off do not join automatically; use explicit `attach` to join an existing agent. Board identity is independent of shared notes and `share_context`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@howaboua/pi-shepherdr",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.15",
|
|
4
4
|
"description": "Persistent blocking and asynchronous Pi agents through Herdr.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"pack:dry": "npm pack --dry-run"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@howaboua/pi-codex-conversion": ">=3.0.
|
|
46
|
+
"@howaboua/pi-codex-conversion": ">=3.0.47",
|
|
47
47
|
"@earendil-works/pi-ai": ">=1.0.0",
|
|
48
48
|
"@earendil-works/pi-coding-agent": ">=1.0.0",
|
|
49
49
|
"@earendil-works/pi-tui": ">=1.0.0",
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"unicode-case-folding": "1.1.2"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@howaboua/pi-codex-conversion": "3.0.
|
|
61
|
+
"@howaboua/pi-codex-conversion": "3.0.47",
|
|
62
62
|
"@biomejs/biome": "^2.5.10",
|
|
63
|
-
"@earendil-works/pi-ai": "1.0.
|
|
64
|
-
"@earendil-works/pi-coding-agent": "1.0.
|
|
65
|
-
"@earendil-works/pi-tui": "1.0.
|
|
63
|
+
"@earendil-works/pi-ai": "1.0.4",
|
|
64
|
+
"@earendil-works/pi-coding-agent": "1.0.4",
|
|
65
|
+
"@earendil-works/pi-tui": "1.0.4",
|
|
66
66
|
"@types/node": "^26.2.0",
|
|
67
67
|
"typebox": "1.3.18",
|
|
68
68
|
"typescript": "^7.0.2"
|
package/src/agents-answer.ts
CHANGED
|
@@ -59,6 +59,28 @@ export async function answerAgent(
|
|
|
59
59
|
signal,
|
|
60
60
|
askId,
|
|
61
61
|
);
|
|
62
|
+
if (prepared.ask.delivery === "steer") {
|
|
63
|
+
const result = await runtime.monitor.submitAskAnswer(
|
|
64
|
+
panel,
|
|
65
|
+
askId,
|
|
66
|
+
prepared.submit,
|
|
67
|
+
signal,
|
|
68
|
+
);
|
|
69
|
+
const accepted =
|
|
70
|
+
result?.status === "accepted" && answersMatch(answers, result.responses);
|
|
71
|
+
return toolResult({
|
|
72
|
+
answered: accepted,
|
|
73
|
+
ask_id: askId,
|
|
74
|
+
machine: runtime.machine,
|
|
75
|
+
status:
|
|
76
|
+
result?.status === "rejected"
|
|
77
|
+
? "rejected"
|
|
78
|
+
: accepted
|
|
79
|
+
? "accepted"
|
|
80
|
+
: "unknown",
|
|
81
|
+
target: panel.pane_id,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
62
84
|
const task = `Answer: ${prepared.ask.prompts
|
|
63
85
|
.map((prompt) => prompt.title)
|
|
64
86
|
.join(", ")}`;
|
package/src/agents-discovery.ts
CHANGED
|
@@ -48,7 +48,7 @@ export async function agentsHelp(): Promise<Record<string, unknown>> {
|
|
|
48
48
|
label: "2-3 words; tab/session",
|
|
49
49
|
answers: "[{selections?:string[],other?:string,comment?:string}]",
|
|
50
50
|
ask_id: "Exact pending Ask ID",
|
|
51
|
-
send: "Only
|
|
51
|
+
send: "Only needed input or work changes; wakes idle agents, no wait/watch. Never wake finished workers to acknowledge completion or announce closure; close finished panes silently with host controls",
|
|
52
52
|
assign: "Delegate a task to an existing agent",
|
|
53
53
|
attach:
|
|
54
54
|
"Idle target; context/board booleans choose shared access and board membership independently; no task/watch",
|
|
@@ -59,7 +59,7 @@ export async function agentsHelp(): Promise<Record<string, unknown>> {
|
|
|
59
59
|
share_context:
|
|
60
60
|
"Profile false isolates notes/history; otherwise follows controller sharing setting",
|
|
61
61
|
watch:
|
|
62
|
-
"
|
|
62
|
+
"Delegation and watch keep reporting subsequent work until unwatch or close",
|
|
63
63
|
prompt:
|
|
64
64
|
"Only task + inaccessible context; no method/evidence/reporting boilerplate",
|
|
65
65
|
slash:
|
package/src/agents-tool.ts
CHANGED
|
@@ -125,7 +125,8 @@ export function createAgentsTool(
|
|
|
125
125
|
...(view.assistant
|
|
126
126
|
? { reply: view.assistant.text }
|
|
127
127
|
: { reply: null }),
|
|
128
|
-
...(
|
|
128
|
+
...(view.ask &&
|
|
129
|
+
(panel.agent_status === "blocked" || view.ask.delivery === "steer")
|
|
129
130
|
? {
|
|
130
131
|
ask: modelAsk(view.ask),
|
|
131
132
|
}
|
package/src/ask-answer.ts
CHANGED
|
@@ -255,6 +255,7 @@ async function sendInput(
|
|
|
255
255
|
signal.throwIfAborted();
|
|
256
256
|
if (step.text !== undefined) {
|
|
257
257
|
await requireSameAgent(client, panel);
|
|
258
|
+
signal.throwIfAborted();
|
|
258
259
|
await client.request("pane.send_input", {
|
|
259
260
|
pane_id: panel.pane_id,
|
|
260
261
|
text: step.text,
|
|
@@ -262,6 +263,7 @@ async function sendInput(
|
|
|
262
263
|
}
|
|
263
264
|
if (step.keys) {
|
|
264
265
|
await requireSameAgent(client, panel);
|
|
266
|
+
signal.throwIfAborted();
|
|
265
267
|
await client.request("agent.send_keys", {
|
|
266
268
|
target: panel.pane_id,
|
|
267
269
|
keys: step.keys,
|
|
@@ -302,22 +304,28 @@ export async function prepareAskAnswer(
|
|
|
302
304
|
answers: AskAnswer[],
|
|
303
305
|
signal: AbortSignal,
|
|
304
306
|
expectedAskId: string,
|
|
305
|
-
): Promise<{ ask: PendingAsk; submit(): Promise<void> }> {
|
|
306
|
-
if (panel.agent_status !== "blocked") {
|
|
307
|
-
throw new Error(
|
|
308
|
-
`${panel.pane_id} is ${panel.agent_status}, not blocked on ask`,
|
|
309
|
-
);
|
|
310
|
-
}
|
|
307
|
+
): Promise<{ ask: PendingAsk; submit(signal?: AbortSignal): Promise<void> }> {
|
|
311
308
|
const view = await monitor.view(panel);
|
|
312
309
|
if (!view.ask) {
|
|
313
|
-
throw new Error(
|
|
314
|
-
`${panel.pane_id} has no pending pi-ask call on its active branch`,
|
|
315
|
-
);
|
|
310
|
+
throw new Error(`${panel.pane_id} has no live Ask on its active branch`);
|
|
316
311
|
}
|
|
317
312
|
const ask = view.ask;
|
|
313
|
+
if (panel.agent_status !== "blocked" && ask.delivery !== "steer") {
|
|
314
|
+
throw new Error(`${panel.pane_id} is not waiting on Ask`);
|
|
315
|
+
}
|
|
318
316
|
if (ask.toolCallId !== expectedAskId) {
|
|
319
|
-
throw new Error(`${panel.pane_id}
|
|
317
|
+
throw new Error(`${panel.pane_id} has a different Ask call`);
|
|
320
318
|
}
|
|
319
|
+
const requireLiveAsk = async () => {
|
|
320
|
+
const current = await getAgent(client, panel.pane_id);
|
|
321
|
+
if (
|
|
322
|
+
!sameAgentIdentity(panel, current) ||
|
|
323
|
+
(ask.delivery !== "steer" && current.agent_status !== "blocked") ||
|
|
324
|
+
(await monitor.view(current)).ask?.toolCallId !== ask.toolCallId
|
|
325
|
+
) {
|
|
326
|
+
throw new Error("ask closed before all requested answers were entered");
|
|
327
|
+
}
|
|
328
|
+
};
|
|
321
329
|
const initial = inspectAskScreen(await screen(client, panel.pane_id), ask);
|
|
322
330
|
const first = ask.prompts[0];
|
|
323
331
|
const expectedSelection = first?.choices[0]?.label ?? "Other/rephrase";
|
|
@@ -339,15 +347,10 @@ export async function prepareAskAnswer(
|
|
|
339
347
|
const final = plan.pop();
|
|
340
348
|
if (!final?.final) throw new Error("ask answer plan has no final submission");
|
|
341
349
|
for (const step of plan) {
|
|
350
|
+
await requireLiveAsk();
|
|
342
351
|
await sendInput(client, panel, step, signal);
|
|
343
352
|
await new Promise((resolve) => setTimeout(resolve, 35));
|
|
344
|
-
|
|
345
|
-
if (
|
|
346
|
-
!sameAgentIdentity(panel, current) ||
|
|
347
|
-
current.agent_status !== "blocked"
|
|
348
|
-
) {
|
|
349
|
-
throw new Error("ask closed before all requested answers were entered");
|
|
350
|
-
}
|
|
353
|
+
await requireLiveAsk();
|
|
351
354
|
if (
|
|
352
355
|
!inspectAskScreen(await screen(client, panel.pane_id), ask).recognized
|
|
353
356
|
) {
|
|
@@ -358,6 +361,17 @@ export async function prepareAskAnswer(
|
|
|
358
361
|
}
|
|
359
362
|
return {
|
|
360
363
|
ask,
|
|
361
|
-
submit:
|
|
364
|
+
submit: async (submitSignal = signal) => {
|
|
365
|
+
await requireLiveAsk();
|
|
366
|
+
if (
|
|
367
|
+
inspectAskScreen(await screen(client, panel.pane_id), ask)
|
|
368
|
+
.currentPrompt !== "Review"
|
|
369
|
+
) {
|
|
370
|
+
throw new Error(
|
|
371
|
+
"ask UI is not ready to submit; stopped without retrying input",
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
await sendInput(client, panel, final, submitSignal);
|
|
375
|
+
},
|
|
362
376
|
};
|
|
363
377
|
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import type {
|
|
3
|
+
ExtensionAPI,
|
|
4
|
+
ExtensionContext,
|
|
5
|
+
} from "@earendil-works/pi-coding-agent";
|
|
6
|
+
import {
|
|
7
|
+
contextBriefingWindow,
|
|
8
|
+
recordContextBriefing,
|
|
9
|
+
registerContextBriefing,
|
|
10
|
+
} from "../context-briefing.js";
|
|
11
|
+
import { boardBriefing } from "../messages.js";
|
|
12
|
+
import { binding } from "./identity.js";
|
|
13
|
+
|
|
14
|
+
const OWNER = "shepherdr-board";
|
|
15
|
+
const STATE = "shepherdr-board-awareness";
|
|
16
|
+
interface AwarenessState {
|
|
17
|
+
sessionId: string;
|
|
18
|
+
signature: string;
|
|
19
|
+
epoch: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Board state is sampled once per selected window/membership, never on a timer. */
|
|
23
|
+
export class BoardAwareness {
|
|
24
|
+
private readonly pi: ExtensionAPI;
|
|
25
|
+
private readonly read: (ctx: ExtensionContext) => Promise<unknown>;
|
|
26
|
+
constructor(
|
|
27
|
+
pi: ExtensionAPI,
|
|
28
|
+
read: (ctx: ExtensionContext) => Promise<unknown>,
|
|
29
|
+
) {
|
|
30
|
+
this.pi = pi;
|
|
31
|
+
this.read = read;
|
|
32
|
+
registerContextBriefing(
|
|
33
|
+
pi,
|
|
34
|
+
"board",
|
|
35
|
+
(ctx) => binding(ctx).enabled,
|
|
36
|
+
(ctx, windowId) => this.record(ctx, windowId),
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
refresh(ctx: ExtensionContext): AwarenessState {
|
|
41
|
+
const own = binding(ctx);
|
|
42
|
+
const signature = JSON.stringify([
|
|
43
|
+
own.boardId,
|
|
44
|
+
own.rootSessionId,
|
|
45
|
+
own.agentName,
|
|
46
|
+
own.upstream,
|
|
47
|
+
own.enabled,
|
|
48
|
+
]);
|
|
49
|
+
const saved = ctx.sessionManager
|
|
50
|
+
.getEntries()
|
|
51
|
+
.findLast(
|
|
52
|
+
(entry) =>
|
|
53
|
+
entry.type === "custom" &&
|
|
54
|
+
entry.customType === STATE &&
|
|
55
|
+
readState(entry.data).sessionId === own.sessionId,
|
|
56
|
+
);
|
|
57
|
+
if (saved?.type === "custom") {
|
|
58
|
+
const state = readState(saved.data);
|
|
59
|
+
if (state.signature === signature) return state;
|
|
60
|
+
}
|
|
61
|
+
const state = { sessionId: own.sessionId, signature, epoch: randomUUID() };
|
|
62
|
+
this.pi.appendEntry(STATE, state);
|
|
63
|
+
return state;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private async record(ctx: ExtensionContext, windowId?: string) {
|
|
67
|
+
const own = binding(ctx);
|
|
68
|
+
const state = this.refresh(ctx);
|
|
69
|
+
if (!own.enabled) return;
|
|
70
|
+
const window = contextBriefingWindow(ctx, windowId);
|
|
71
|
+
const key = JSON.stringify([own.sessionId, window, state.epoch]);
|
|
72
|
+
await recordContextBriefing(this.pi, ctx, OWNER, key, async () => {
|
|
73
|
+
let population: "empty" | "populated" | "unavailable";
|
|
74
|
+
try {
|
|
75
|
+
const value = await this.read(ctx);
|
|
76
|
+
if (!binding(ctx).enabled) return;
|
|
77
|
+
if (
|
|
78
|
+
!value ||
|
|
79
|
+
typeof value !== "object" ||
|
|
80
|
+
!("results" in value) ||
|
|
81
|
+
!Array.isArray(value.results)
|
|
82
|
+
)
|
|
83
|
+
throw new Error("Invalid board population response");
|
|
84
|
+
population = value.results.length ? "populated" : "empty";
|
|
85
|
+
} catch (error) {
|
|
86
|
+
ctx.signal?.throwIfAborted();
|
|
87
|
+
population = "unavailable";
|
|
88
|
+
ctx.ui.notify(`Board status unavailable: ${String(error)}`, "warning");
|
|
89
|
+
}
|
|
90
|
+
ctx.signal?.throwIfAborted();
|
|
91
|
+
if (!binding(ctx).enabled) return;
|
|
92
|
+
if (
|
|
93
|
+
binding(ctx).enabled !== own.enabled ||
|
|
94
|
+
this.refresh(ctx).epoch !== state.epoch
|
|
95
|
+
)
|
|
96
|
+
throw new Error("Board membership changed during its briefing");
|
|
97
|
+
return boardBriefing(Boolean(own.upstream), population);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function readState(value: unknown): AwarenessState {
|
|
103
|
+
if (
|
|
104
|
+
!value ||
|
|
105
|
+
typeof value !== "object" ||
|
|
106
|
+
!("sessionId" in value) ||
|
|
107
|
+
typeof value.sessionId !== "string" ||
|
|
108
|
+
!("signature" in value) ||
|
|
109
|
+
typeof value.signature !== "string" ||
|
|
110
|
+
!("epoch" in value) ||
|
|
111
|
+
typeof value.epoch !== "string"
|
|
112
|
+
)
|
|
113
|
+
throw new Error("Invalid saved board awareness");
|
|
114
|
+
return value as AwarenessState;
|
|
115
|
+
}
|
package/src/board/host.ts
CHANGED
|
@@ -5,11 +5,13 @@ import type {
|
|
|
5
5
|
} from "@earendil-works/pi-coding-agent";
|
|
6
6
|
import type { AgentFleet, ConnectedMachine } from "../fleet.js";
|
|
7
7
|
import { sessionPath } from "../herdr.js";
|
|
8
|
+
import { recordBoardPostMarker } from "../messages.js";
|
|
8
9
|
import {
|
|
9
10
|
requestContext,
|
|
10
11
|
sessionContextPath,
|
|
11
12
|
} from "../remote/shepherdr-context.mjs";
|
|
12
13
|
import { executeArchive } from "./archive.js";
|
|
14
|
+
import { BoardAwareness } from "./awareness.js";
|
|
13
15
|
import {
|
|
14
16
|
type BoardScope,
|
|
15
17
|
readBoardConfig,
|
|
@@ -51,12 +53,14 @@ export class AgentBoard {
|
|
|
51
53
|
private readonly pi: ExtensionAPI;
|
|
52
54
|
private readonly fleet: AgentFleet;
|
|
53
55
|
private readonly turns: BoardTurns;
|
|
56
|
+
private readonly awareness: BoardAwareness;
|
|
54
57
|
private refreshTools: (() => void) | undefined;
|
|
55
58
|
private lastSetting: { sessionId: string; enabled: boolean } | undefined;
|
|
56
59
|
private configError: string | undefined;
|
|
57
60
|
constructor(pi: ExtensionAPI, fleet: AgentFleet) {
|
|
58
61
|
this.pi = pi;
|
|
59
62
|
this.fleet = fleet;
|
|
63
|
+
this.awareness = new BoardAwareness(pi, (ctx) => this.population(ctx));
|
|
60
64
|
this.turns = new BoardTurns(pi, (ctx, request) =>
|
|
61
65
|
this.toOwner(ctx, request),
|
|
62
66
|
);
|
|
@@ -99,11 +103,44 @@ export class AgentBoard {
|
|
|
99
103
|
setToolRefresh(refresh: () => void) {
|
|
100
104
|
this.refreshTools = refresh;
|
|
101
105
|
}
|
|
106
|
+
private async population(ctx: ExtensionContext) {
|
|
107
|
+
const own = binding(ctx);
|
|
108
|
+
if (own.upstream) {
|
|
109
|
+
const status = await this.toOwner(
|
|
110
|
+
ctx,
|
|
111
|
+
{
|
|
112
|
+
operation: "board-call",
|
|
113
|
+
caller: own,
|
|
114
|
+
params: { action: "help" },
|
|
115
|
+
requestId: "briefing-status",
|
|
116
|
+
},
|
|
117
|
+
ctx.signal,
|
|
118
|
+
);
|
|
119
|
+
if (
|
|
120
|
+
!status ||
|
|
121
|
+
typeof status !== "object" ||
|
|
122
|
+
!("enabled" in status) ||
|
|
123
|
+
typeof status.enabled !== "boolean"
|
|
124
|
+
)
|
|
125
|
+
throw new Error("Board status unavailable");
|
|
126
|
+
if (status.enabled !== own.enabled) {
|
|
127
|
+
saveBinding(this.pi, { ...own, enabled: status.enabled });
|
|
128
|
+
await this.refresh(ctx);
|
|
129
|
+
}
|
|
130
|
+
if (!status.enabled) return;
|
|
131
|
+
}
|
|
132
|
+
return this.execute(
|
|
133
|
+
ctx,
|
|
134
|
+
{ action: "search_posts", limit: 1, max_chars_per_post: 1 },
|
|
135
|
+
"briefing",
|
|
136
|
+
);
|
|
137
|
+
}
|
|
102
138
|
enabled(ctx: ExtensionContext | undefined) {
|
|
103
139
|
return ctx ? binding(ctx).enabled : false;
|
|
104
140
|
}
|
|
105
141
|
async refresh(ctx: ExtensionContext) {
|
|
106
142
|
const own = binding(ctx);
|
|
143
|
+
this.awareness.refresh(ctx);
|
|
107
144
|
const setting = own.upstream ? undefined : rootBoardSetting(ctx);
|
|
108
145
|
if (setting?.error && setting.error !== this.configError)
|
|
109
146
|
ctx.ui.notify(`Board disabled: ${setting.error}`, "error");
|
|
@@ -159,12 +196,28 @@ export class AgentBoard {
|
|
|
159
196
|
throw new Error(
|
|
160
197
|
"Board is off; the user can enable it in /herdr → Settings",
|
|
161
198
|
);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
199
|
+
const value = await this.toOwner(
|
|
200
|
+
ctx,
|
|
201
|
+
{
|
|
202
|
+
operation: "board-call",
|
|
203
|
+
caller,
|
|
204
|
+
params,
|
|
205
|
+
requestId,
|
|
206
|
+
},
|
|
207
|
+
ctx.signal,
|
|
208
|
+
);
|
|
209
|
+
if (params.action === "post") {
|
|
210
|
+
try {
|
|
211
|
+
recordBoardPostMarker(this.pi, ctx, value);
|
|
212
|
+
} catch {
|
|
213
|
+
// Presentation failure must not turn a committed post into a retry.
|
|
214
|
+
ctx.ui.notify(
|
|
215
|
+
"Posted to board. Its history notice is unavailable. Read the board to check the post; do not repost.",
|
|
216
|
+
"warning",
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return value;
|
|
168
221
|
}
|
|
169
222
|
async prepare(
|
|
170
223
|
ctx: ExtensionContext,
|
package/src/board/tool.ts
CHANGED
|
@@ -9,9 +9,6 @@ export function createBoardTool(board: AgentBoard) {
|
|
|
9
9
|
label: "Message board",
|
|
10
10
|
description:
|
|
11
11
|
"Shared discussions and saved board history; call help for actions",
|
|
12
|
-
promptGuidelines: [
|
|
13
|
-
"board is shared with your agent tree. Use it for plans, decisions and findings in substantial multi-agent work, not routine delegation. Use agents for task assignment and urgent messages",
|
|
14
|
-
],
|
|
15
12
|
parameters: BoardParameters,
|
|
16
13
|
executionMode: "sequential",
|
|
17
14
|
async execute(id, params, signal, _onUpdate, ctx) {
|