@howaboua/pi-shepherdr 0.1.6 → 0.2.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/CHANGELOG.md +9 -0
- package/README.md +20 -5
- package/package.json +3 -3
- package/src/agents-contract.ts +10 -3
- package/src/agents-operations.ts +54 -15
- package/src/agents-tool.ts +32 -18
- package/src/controller.ts +4 -8
- package/src/delivery.ts +24 -0
- package/src/fleet.ts +59 -63
- package/src/herdr.ts +17 -1
- package/src/launch.ts +0 -25
- package/src/machine-catalog.ts +60 -0
- package/src/messages.ts +66 -11
- package/src/monitor-record.ts +6 -19
- package/src/monitor-state.ts +14 -5
- package/src/monitor.ts +10 -7
- package/src/remote/shepherdr.mjs +29 -13
- package/src/remote-client.ts +17 -18
- package/src/session-reader.ts +21 -11
- package/src/settlement.ts +15 -13
- package/src/types.ts +9 -4
- package/src/widget.ts +4 -4
- package/src/machine-menu.ts +0 -163
- package/src/machines-config.ts +0 -148
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @howaboua/pi-shepherdr
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
- Shepherdr now reads existing Herdr machine profiles and requires Herdr 0.9 or newer. Manage profiles in Herdr; `shepherdr.json`, old machine aliases and their saved watches are no longer used.
|
|
6
|
+
|
|
7
|
+
- Agent prompts and reports identify their source workspace, tab and pane, including current names.
|
|
8
|
+
- Attributed messages to running Pi Codex agents use developer steering. Idle tasks retain normal user kickoff and extension preparation.
|
|
9
|
+
- `send` delivers peer messages without blocking or subscribing; use `assign` to delegate work to an existing agent.
|
|
10
|
+
- Automatic task watches end on completion or failure. Only explicit `watch` subscriptions persist; legacy watches are cleared with a notice.
|
|
11
|
+
|
|
3
12
|
## 0.1.6
|
|
4
13
|
|
|
5
14
|
- Deliver blocked-agent handoffs even when transcripts are unavailable.
|
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ With Pi Codex's compatible custom developer-message API active, asynchronous wor
|
|
|
14
14
|
pi install npm:@howaboua/pi-shepherdr
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
Requires Pi 0.84.3 or newer, Herdr 0.
|
|
17
|
+
Requires Pi 0.84.3 or newer, Herdr 0.9 or newer and the Herdr Pi integration:
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
20
|
herdr integration install pi
|
|
@@ -34,9 +34,15 @@ The agent tool is always available in Pi, Code Mode and Notebook Mode. Run Pi in
|
|
|
34
34
|
|
|
35
35
|
The command only records one visible guidance message without triggering a turn. Run `/herdr` again to return to normal guidance. Resumed sessions restore their last mode; new sessions start with normal guidance. Tool availability and monitoring do not depend on this mode.
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
Shepherdr reads Herdr's existing machine profiles and connects enabled profiles at session startup. Manage profiles in Herdr. `/herdr connect [profile-id]` refreshes the catalog and retries failed connections or incomplete monitoring without dropping working connections. A catalog refresh stops watches for disabled or removed profiles without stopping remote agents.
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
Profiles belong to the host running Pi, not the laptop or desktop displaying its terminal. Each profile targets one remote session. Agent calls use the opaque profile ID returned by `list`; `local` means Pi's current server. Renaming a profile changes its label, not its routing identity.
|
|
40
|
+
|
|
41
|
+
Remote machines connect over noninteractive SSH. The target needs `node` on its SSH PATH, Herdr 0.9 or newer, the Herdr Pi integration and a running Herdr session. Shepherdr installs one helper at `~/.pi/agent/shepherdr.mjs` on each remote, runs it only for the connection lifetime and leaves no remote daemon behind. Herdr's multi-machine UI does not expose a cross-machine automation socket, so Shepherdr still owns its remote transport and Pi transcript reads.
|
|
42
|
+
|
|
43
|
+
### Migrating from separate Shepherdr machines
|
|
44
|
+
|
|
45
|
+
`shepherdr.json` is no longer read. Existing Herdr profiles are used directly. Configure any missing profiles in Herdr on the host running Pi. Old machine aliases are not migrated. Legacy watches, including local watches, are cleared with a notice because they cannot distinguish explicit subscriptions from accidental ones. Re-select any ongoing watches explicitly.
|
|
40
46
|
|
|
41
47
|
## Agent calls
|
|
42
48
|
|
|
@@ -48,13 +54,18 @@ Call the `agents` tool with `action: "help"` before first use, then send flat re
|
|
|
48
54
|
| `list` | Profiles, machines and matching Pi agents |
|
|
49
55
|
| `find` | Agents matching a query or status |
|
|
50
56
|
| `spawn` | Spawn a profiled Pi agent and send its initial task |
|
|
51
|
-
| `send` | Send
|
|
57
|
+
| `send` | Send a peer message without waiting or subscribing |
|
|
58
|
+
| `assign` | Delegate a task to an existing agent |
|
|
52
59
|
| `read` | Read the latest assistant reply or bounded terminal output |
|
|
53
60
|
| `answer` | Answer a worker blocked on Pi Ask |
|
|
54
61
|
| `watch` | Push future settlement from an existing Pi agent |
|
|
55
62
|
| `unwatch` | Stop reporting an agent |
|
|
56
63
|
|
|
57
|
-
`spawn`, `
|
|
64
|
+
`spawn`, `assign` and `answer` block by default. Set `blocking: false` when the controller should continue other work immediately. Task completion and blockage are then delivered automatically.
|
|
65
|
+
|
|
66
|
+
Questions, status updates and replies 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.
|
|
67
|
+
|
|
68
|
+
Automatic delegation watches end when the task finishes or fails. Blocked tasks stay watched until resolved. Only an explicit `watch` keeps reporting subsequent work until `unwatch`. Sending an update to your worker preserves its existing task watch without replacing the task.
|
|
58
69
|
|
|
59
70
|
Reviewer spawns always block, even when `blocking: false` is supplied. The controller waits for the review before continuing work on its scope.
|
|
60
71
|
|
|
@@ -62,6 +73,10 @@ Every `spawn` needs an `agent_type` and a concise two- or three-word `label`. Th
|
|
|
62
73
|
|
|
63
74
|
Cancelling a blocking call does not kill its worker. The waiter detaches and the eventual result returns through normal asynchronous delivery.
|
|
64
75
|
|
|
76
|
+
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.
|
|
77
|
+
|
|
78
|
+
Idle task prompts retain Pi's normal user kickoff and extension preparation. When the receiving agent is already running and Pi Codex developer delivery is active, Shepherdr routes attributed messages into that prepared run as developer steering. Without it, messages remain normal prompts. Install Shepherdr on receiving agents as well as controllers for this delivery.
|
|
79
|
+
|
|
65
80
|
For `answer` inside Code or Notebook Mode, update Pi Ask on workers together with Shepherdr on controllers.
|
|
66
81
|
|
|
67
82
|
## Profiles
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@howaboua/pi-shepherdr",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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.31",
|
|
47
47
|
"@earendil-works/pi-ai": ">=0.84.3",
|
|
48
48
|
"@earendil-works/pi-coding-agent": ">=0.84.3",
|
|
49
49
|
"@earendil-works/pi-tui": ">=0.84.3",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@howaboua/pi-codex-conversion": "3.0.
|
|
58
|
+
"@howaboua/pi-codex-conversion": "3.0.31",
|
|
59
59
|
"@biomejs/biome": "^2.5.10",
|
|
60
60
|
"@earendil-works/pi-ai": "0.85.1",
|
|
61
61
|
"@earendil-works/pi-coding-agent": "0.85.1",
|
package/src/agents-contract.ts
CHANGED
|
@@ -11,10 +11,11 @@ const ACTIONS = [
|
|
|
11
11
|
"watch",
|
|
12
12
|
"unwatch",
|
|
13
13
|
"send",
|
|
14
|
+
"assign",
|
|
14
15
|
"read",
|
|
15
16
|
"answer",
|
|
16
17
|
] as const;
|
|
17
|
-
const BLOCKING_ACTIONS = new Set<string>(["spawn", "
|
|
18
|
+
const BLOCKING_ACTIONS = new Set<string>(["spawn", "assign", "answer"]);
|
|
18
19
|
export const READ_SOURCES = ["latest", "visible", "recent"] as const;
|
|
19
20
|
const STATUSES = ["idle", "working", "blocked", "done", "unknown"] as const;
|
|
20
21
|
|
|
@@ -38,7 +39,8 @@ const ACTION_FIELDS: Record<(typeof ACTIONS)[number], ReadonlySet<string>> = {
|
|
|
38
39
|
]),
|
|
39
40
|
watch: new Set(["action", "machine", "target"]),
|
|
40
41
|
unwatch: new Set(["action", "machine", "target"]),
|
|
41
|
-
send: new Set(["action", "machine", "target", "message"
|
|
42
|
+
send: new Set(["action", "machine", "target", "message"]),
|
|
43
|
+
assign: new Set(["action", "machine", "target", "message", "blocking"]),
|
|
42
44
|
read: new Set(["action", "machine", "target", "source", "lines"]),
|
|
43
45
|
answer: new Set(["action", "machine", "target", "answers", "blocking"]),
|
|
44
46
|
};
|
|
@@ -79,7 +81,7 @@ const AgentsRequest = Type.Object(
|
|
|
79
81
|
blocking: Type.Optional(
|
|
80
82
|
Type.Boolean({
|
|
81
83
|
description:
|
|
82
|
-
"
|
|
84
|
+
"Delegation only; defaults true. False pushes task settlement later",
|
|
83
85
|
}),
|
|
84
86
|
),
|
|
85
87
|
query: Type.Optional(Type.String()),
|
|
@@ -118,6 +120,11 @@ export function parseAgentsRequest(input: unknown): AgentsParams {
|
|
|
118
120
|
if (typeof action !== "string" || !Object.hasOwn(ACTION_FIELDS, action)) {
|
|
119
121
|
throw new Error(`agents action must be one of: ${ACTIONS.join(", ")}`);
|
|
120
122
|
}
|
|
123
|
+
if (action === "send" && "blocking" in value) {
|
|
124
|
+
throw new Error(
|
|
125
|
+
"send is message-only; omit blocking. Use assign to delegate work",
|
|
126
|
+
);
|
|
127
|
+
}
|
|
121
128
|
const unknown = Object.keys(value).filter(
|
|
122
129
|
(key) => !ACTION_FIELDS[action as keyof typeof ACTION_FIELDS].has(key),
|
|
123
130
|
);
|
package/src/agents-operations.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { AgentToolUpdateCallback } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { activityTask } from "./activity.js";
|
|
2
3
|
import type { AgentsParams, READ_SOURCES } from "./agents-contract.js";
|
|
3
4
|
import type { AgentFleet, ConnectedMachine } from "./fleet.js";
|
|
4
5
|
import { getSnapshot } from "./herdr.js";
|
|
6
|
+
import { isHerdrResponseError } from "./herdr-client.js";
|
|
7
|
+
import { agentSource } from "./messages.js";
|
|
8
|
+
import type { WorkAttempt } from "./monitor-state.js";
|
|
5
9
|
import { loadAgentProfiles } from "./profiles.js";
|
|
6
10
|
import type { ClaimedSettlement } from "./settlement.js";
|
|
7
11
|
import type { AgentStatus, PaneInfo, SessionSnapshot } from "./types.js";
|
|
@@ -38,16 +42,22 @@ export async function agentsHelp(): Promise<Record<string, unknown>> {
|
|
|
38
42
|
"agent_type label message name? machine? placement? workspace? pane? cwd? base? blocking?",
|
|
39
43
|
watch: "target machine?",
|
|
40
44
|
unwatch: "target machine?",
|
|
41
|
-
send: "target message machine?
|
|
45
|
+
send: "target message machine?",
|
|
46
|
+
assign: "target message machine? blocking?",
|
|
42
47
|
read: "target machine? source? lines?",
|
|
43
48
|
answer: "target answers machine? blocking?",
|
|
44
49
|
},
|
|
45
50
|
rules: {
|
|
51
|
+
machine: "Herdr profile ID from list; local = current server",
|
|
46
52
|
target: "Use spawn/find target exactly",
|
|
47
53
|
label: "2-3 words; tab/session",
|
|
48
54
|
answers: "[{selections?:string[],other?:string,comment?:string}]",
|
|
55
|
+
send: "Peer questions, updates, replies; submission only, no wait or watch",
|
|
56
|
+
assign: "Delegate a task to an existing agent",
|
|
49
57
|
blocking:
|
|
50
|
-
"
|
|
58
|
+
"spawn/assign/answer default true; false pushes task settlement; reviewers always wait; never poll",
|
|
59
|
+
watch:
|
|
60
|
+
"Explicit watch persists until unwatch; automatic task watches end on finish/failure, not blockage",
|
|
51
61
|
prompt:
|
|
52
62
|
"Only task + inaccessible context; no method/evidence/reporting boilerplate",
|
|
53
63
|
reuse:
|
|
@@ -135,7 +145,7 @@ export async function listFleetAgents(
|
|
|
135
145
|
compactAgent(
|
|
136
146
|
agent,
|
|
137
147
|
machine.snapshot!,
|
|
138
|
-
machine.
|
|
148
|
+
machine.id,
|
|
139
149
|
machine.monitoredPaneIds?.has(agent.pane_id) ?? false,
|
|
140
150
|
),
|
|
141
151
|
)
|
|
@@ -143,7 +153,7 @@ export async function listFleetAgents(
|
|
|
143
153
|
});
|
|
144
154
|
const workspaces = machines.flatMap((machine) =>
|
|
145
155
|
(machine.snapshot?.workspaces ?? []).map((workspace) => ({
|
|
146
|
-
machine: machine.
|
|
156
|
+
machine: machine.id,
|
|
147
157
|
id: workspace.workspace_id,
|
|
148
158
|
label: workspace.label,
|
|
149
159
|
})),
|
|
@@ -224,10 +234,15 @@ export function settlementResult(
|
|
|
224
234
|
`${settlement.agent.pane_id} assistant stopped with an error`,
|
|
225
235
|
);
|
|
226
236
|
}
|
|
237
|
+
const { pane, name, ...source } = agentSource(
|
|
238
|
+
settlement.agent,
|
|
239
|
+
settlement.labels,
|
|
240
|
+
);
|
|
227
241
|
return {
|
|
228
242
|
machine,
|
|
229
|
-
target:
|
|
230
|
-
...(
|
|
243
|
+
target: pane,
|
|
244
|
+
...(name ? { name } : {}),
|
|
245
|
+
source,
|
|
231
246
|
status: settlement.status,
|
|
232
247
|
...(settlement.reply ? { reply: settlement.reply.text } : {}),
|
|
233
248
|
...(settlement.ask
|
|
@@ -263,18 +278,27 @@ export async function dispatchAgentWork(
|
|
|
263
278
|
options: { expectUserMessage?: boolean } = {},
|
|
264
279
|
): Promise<ClaimedSettlement | undefined> {
|
|
265
280
|
signal.throwIfAborted();
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
if (!attempt) throw new Error(`${panel.pane_id} is not monitored`);
|
|
281
|
+
const addedWatch = !runtime.monitor
|
|
282
|
+
.list()
|
|
283
|
+
.some(
|
|
284
|
+
(record) =>
|
|
285
|
+
record.terminalId === panel.terminal_id ||
|
|
286
|
+
record.paneId === panel.pane_id,
|
|
287
|
+
);
|
|
288
|
+
let attempt: WorkAttempt | undefined;
|
|
275
289
|
let settlement: Promise<ClaimedSettlement> | undefined;
|
|
276
290
|
let sendStarted = false;
|
|
277
291
|
try {
|
|
292
|
+
await runtime.monitor.track(panel);
|
|
293
|
+
const baseline = options.expectUserMessage
|
|
294
|
+
? await runtime.monitor.view(panel)
|
|
295
|
+
: undefined;
|
|
296
|
+
attempt = runtime.monitor.beginWork(
|
|
297
|
+
panel.pane_id,
|
|
298
|
+
task,
|
|
299
|
+
options.expectUserMessage ? (baseline?.input?.id ?? null) : undefined,
|
|
300
|
+
);
|
|
301
|
+
if (!attempt) throw new Error(`${panel.pane_id} is not monitored`);
|
|
278
302
|
settlement = blocking
|
|
279
303
|
? runtime.monitor.claimWork(attempt, signal)
|
|
280
304
|
: undefined;
|
|
@@ -287,6 +311,21 @@ export async function dispatchAgentWork(
|
|
|
287
311
|
runtime.monitor.releaseWorkClaim(attempt, error);
|
|
288
312
|
if (sendStarted) await runtime.monitor.handleWorkFailure(attempt, error);
|
|
289
313
|
else runtime.monitor.rejectWork(attempt);
|
|
314
|
+
if (addedWatch && (!sendStarted || isHerdrResponseError(error))) {
|
|
315
|
+
const record = runtime.monitor
|
|
316
|
+
.list()
|
|
317
|
+
.find((record) => record.terminalId === panel.terminal_id);
|
|
318
|
+
try {
|
|
319
|
+
if (record?.scope === "task" && !activityTask(record.activity)) {
|
|
320
|
+
await runtime.monitor.unwatch(record.paneId);
|
|
321
|
+
}
|
|
322
|
+
} catch (cleanupError) {
|
|
323
|
+
throw new AggregateError(
|
|
324
|
+
[error, cleanupError],
|
|
325
|
+
"Delegation failed; temporary watch cleanup also failed",
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
290
329
|
throw error;
|
|
291
330
|
}
|
|
292
331
|
if (!blocking) return undefined;
|
package/src/agents-tool.ts
CHANGED
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
rollbackStartedAgent,
|
|
28
28
|
startAgent,
|
|
29
29
|
} from "./launch.js";
|
|
30
|
+
import { attributeAgentPrompt } from "./messages.js";
|
|
30
31
|
import {
|
|
31
32
|
loadAgentProfiles,
|
|
32
33
|
prepareProfileMessage,
|
|
@@ -55,7 +56,7 @@ export function createAgentsTool(fleet: AgentFleet) {
|
|
|
55
56
|
parameters: AgentsParameters,
|
|
56
57
|
promptSnippet: "Load agents help before first use.",
|
|
57
58
|
promptGuidelines: [
|
|
58
|
-
"agents: Reviewer spawns always block
|
|
59
|
+
"agents: send messages to peers; assign delegates work. Reviewer spawns always block; await review before working its scope.",
|
|
59
60
|
"agents: Specialists know their job. Give only the concrete task and inaccessible context; never append generic method, evidence, or reporting instructions.",
|
|
60
61
|
"agents: Reuse specialists only for the same investigation. Keep reviews independent. New scope gets a new agent.",
|
|
61
62
|
"agents: For advanced Herdr workspace, pane, process or layout control, run herdr --skill.",
|
|
@@ -127,6 +128,11 @@ export function createAgentsTool(fleet: AgentFleet) {
|
|
|
127
128
|
},
|
|
128
129
|
{ targetLocal: runtime.local },
|
|
129
130
|
);
|
|
131
|
+
const attributedMessage = await attributeAgentPrompt(
|
|
132
|
+
fleet.connected().client,
|
|
133
|
+
message,
|
|
134
|
+
"task",
|
|
135
|
+
);
|
|
130
136
|
reportProgress(update, `Spawning ${label}`, {
|
|
131
137
|
machine: runtime.machine,
|
|
132
138
|
name,
|
|
@@ -135,7 +141,6 @@ export function createAgentsTool(fleet: AgentFleet) {
|
|
|
135
141
|
});
|
|
136
142
|
const started = await startAgent(
|
|
137
143
|
runtime.client,
|
|
138
|
-
runtime.monitor,
|
|
139
144
|
startParams,
|
|
140
145
|
runtime.fallbackCwd,
|
|
141
146
|
runtime.resolveDirectory,
|
|
@@ -161,7 +166,7 @@ export function createAgentsTool(fleet: AgentFleet) {
|
|
|
161
166
|
promptSubmissionStarted = true;
|
|
162
167
|
await runtime.client.request("agent.prompt", {
|
|
163
168
|
target: started.id,
|
|
164
|
-
text:
|
|
169
|
+
text: attributedMessage,
|
|
165
170
|
});
|
|
166
171
|
promptAccepted = true;
|
|
167
172
|
},
|
|
@@ -172,12 +177,7 @@ export function createAgentsTool(fleet: AgentFleet) {
|
|
|
172
177
|
!promptAccepted &&
|
|
173
178
|
(!promptSubmissionStarted || isHerdrResponseError(error))
|
|
174
179
|
) {
|
|
175
|
-
return rollbackStartedAgent(
|
|
176
|
-
runtime.client,
|
|
177
|
-
runtime.monitor,
|
|
178
|
-
started,
|
|
179
|
-
error,
|
|
180
|
-
);
|
|
180
|
+
return rollbackStartedAgent(runtime.client, started, error);
|
|
181
181
|
}
|
|
182
182
|
throw error;
|
|
183
183
|
}
|
|
@@ -257,7 +257,7 @@ export function createAgentsTool(fleet: AgentFleet) {
|
|
|
257
257
|
: {}),
|
|
258
258
|
});
|
|
259
259
|
}
|
|
260
|
-
if (params.action === "send") {
|
|
260
|
+
if (params.action === "send" || params.action === "assign") {
|
|
261
261
|
if (panel.agent_status === "blocked") {
|
|
262
262
|
const view = await runtime.monitor.view(panel);
|
|
263
263
|
throw new Error(
|
|
@@ -265,8 +265,22 @@ export function createAgentsTool(fleet: AgentFleet) {
|
|
|
265
265
|
);
|
|
266
266
|
}
|
|
267
267
|
const message = required(params.message, "message");
|
|
268
|
-
|
|
269
|
-
|
|
268
|
+
const attributedMessage = await attributeAgentPrompt(
|
|
269
|
+
fleet.connected().client,
|
|
270
|
+
message,
|
|
271
|
+
params.action === "send" ? "message" : "task",
|
|
272
|
+
);
|
|
273
|
+
if (params.action === "send") {
|
|
274
|
+
executionSignal.throwIfAborted();
|
|
275
|
+
await runtime.client.request("agent.prompt", {
|
|
276
|
+
target: panel.pane_id,
|
|
277
|
+
text: attributedMessage,
|
|
278
|
+
});
|
|
279
|
+
return toolResult({
|
|
280
|
+
sent: true,
|
|
281
|
+
machine: runtime.machine,
|
|
282
|
+
target: panel.pane_id,
|
|
283
|
+
});
|
|
270
284
|
}
|
|
271
285
|
const settlement = await dispatchAgentWork(
|
|
272
286
|
runtime,
|
|
@@ -278,15 +292,18 @@ export function createAgentsTool(fleet: AgentFleet) {
|
|
|
278
292
|
() =>
|
|
279
293
|
runtime.client.request("agent.prompt", {
|
|
280
294
|
target: panel.pane_id,
|
|
281
|
-
text:
|
|
295
|
+
text: attributedMessage,
|
|
282
296
|
}),
|
|
283
297
|
{ expectUserMessage: true },
|
|
284
298
|
);
|
|
285
299
|
return toolResult(
|
|
286
300
|
settlement
|
|
287
|
-
? {
|
|
301
|
+
? {
|
|
302
|
+
assigned: true,
|
|
303
|
+
...settlementResult(runtime.machine, settlement),
|
|
304
|
+
}
|
|
288
305
|
: {
|
|
289
|
-
|
|
306
|
+
assigned: true,
|
|
290
307
|
machine: runtime.machine,
|
|
291
308
|
target: panel.pane_id,
|
|
292
309
|
status: "working",
|
|
@@ -295,9 +312,6 @@ export function createAgentsTool(fleet: AgentFleet) {
|
|
|
295
312
|
);
|
|
296
313
|
}
|
|
297
314
|
if (params.action === "answer") {
|
|
298
|
-
if (!runtime.monitor.isMonitored(panel.pane_id)) {
|
|
299
|
-
await runtime.monitor.track(panel);
|
|
300
|
-
}
|
|
301
315
|
const prepared = await prepareAskAnswer(
|
|
302
316
|
runtime.client,
|
|
303
317
|
runtime.monitor,
|
package/src/controller.ts
CHANGED
|
@@ -4,7 +4,6 @@ import type {
|
|
|
4
4
|
} from "@earendil-works/pi-coding-agent";
|
|
5
5
|
import { sendPolicyMessage } from "./delivery.js";
|
|
6
6
|
import type { AgentFleet } from "./fleet.js";
|
|
7
|
-
import { showMachineMenu } from "./machine-menu.js";
|
|
8
7
|
import { loadAgentProfiles } from "./profiles.js";
|
|
9
8
|
|
|
10
9
|
const ORCHESTRATION_STATE_TYPE = "pi-shepherdr-orchestration-state";
|
|
@@ -20,9 +19,9 @@ export function registerAgentController(
|
|
|
20
19
|
): void {
|
|
21
20
|
let orchestrationEnabled = false;
|
|
22
21
|
pi.registerCommand("herdr", {
|
|
23
|
-
description: "Toggle agent orchestration or
|
|
22
|
+
description: "Toggle agent orchestration or reconnect machines",
|
|
24
23
|
getArgumentCompletions: (prefix) =>
|
|
25
|
-
["
|
|
24
|
+
["connect"]
|
|
26
25
|
.filter((action) => action.startsWith(prefix.trim().toLowerCase()))
|
|
27
26
|
.map((value) => ({ label: value, value })),
|
|
28
27
|
handler: async (args, ctx) => {
|
|
@@ -51,16 +50,13 @@ export function registerAgentController(
|
|
|
51
50
|
);
|
|
52
51
|
return;
|
|
53
52
|
}
|
|
54
|
-
if (action === "machines") {
|
|
55
|
-
await showMachineMenu(fleet, ctx);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
53
|
if (action === "connect") {
|
|
59
54
|
if (!fleet.isActive()) {
|
|
60
55
|
await activateController(fleet, ctx);
|
|
61
56
|
if (!fleet.isActive()) return;
|
|
62
57
|
}
|
|
63
58
|
try {
|
|
59
|
+
await fleet.reload();
|
|
64
60
|
ctx.ui.notify(fleet.connect(rest[0]), "info");
|
|
65
61
|
} catch (error) {
|
|
66
62
|
ctx.ui.notify(
|
|
@@ -70,7 +66,7 @@ export function registerAgentController(
|
|
|
70
66
|
}
|
|
71
67
|
return;
|
|
72
68
|
}
|
|
73
|
-
ctx.ui.notify("Usage: /herdr [
|
|
69
|
+
ctx.ui.notify("Usage: /herdr [connect [machine]]", "warning");
|
|
74
70
|
},
|
|
75
71
|
});
|
|
76
72
|
|
package/src/delivery.ts
CHANGED
|
@@ -24,6 +24,30 @@ export async function registerDeveloperDelivery(
|
|
|
24
24
|
} catch (error) {
|
|
25
25
|
if (!isUnavailable(error)) throw error;
|
|
26
26
|
}
|
|
27
|
+
pi.on("input", (event, ctx) => {
|
|
28
|
+
// Idle prompts must run Pi's complete before_agent_start preparation chain.
|
|
29
|
+
if (
|
|
30
|
+
ctx.isIdle() ||
|
|
31
|
+
event.streamingBehavior === undefined ||
|
|
32
|
+
event.images?.length ||
|
|
33
|
+
!/^<herdr_sender [^\n]+ \/>\n/.test(event.text)
|
|
34
|
+
)
|
|
35
|
+
return;
|
|
36
|
+
if (
|
|
37
|
+
senders.get(pi)?.(
|
|
38
|
+
pi,
|
|
39
|
+
{
|
|
40
|
+
customType: "herdr-agent-message",
|
|
41
|
+
content: event.text,
|
|
42
|
+
display: true,
|
|
43
|
+
},
|
|
44
|
+
{ deliverAs: event.streamingBehavior },
|
|
45
|
+
)
|
|
46
|
+
) {
|
|
47
|
+
return { action: "handled" };
|
|
48
|
+
}
|
|
49
|
+
return;
|
|
50
|
+
});
|
|
27
51
|
}
|
|
28
52
|
|
|
29
53
|
export function sendPolicyMessage(
|