tryharness 0.7.72 → 0.7.73
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/assets/opencode-plugin.js +70 -3
- package/lib/asks.mjs +2 -0
- package/lib/boardCommands.mjs +9 -1
- package/lib/boardProtocol.json +23 -19
- package/lib/bridge.mjs +2 -0
- package/lib/capabilityCheck.mjs +86 -0
- package/lib/computerAddress.mjs +6 -14
- package/lib/coordinator.mjs +207 -26
- package/lib/daemon.mjs +150 -125
- package/lib/dispatchContract.json +1 -31
- package/lib/dispatchTools.js +8 -39
- package/lib/dispatches.mjs +27 -285
- package/lib/goalCommands.mjs +7 -3
- package/lib/herdr.mjs +159 -0
- package/lib/hookDialects.mjs +36 -2
- package/lib/jobAnswers.mjs +3 -0
- package/lib/kanban.mjs +256 -0
- package/lib/localAgentAsk.mjs +20 -29
- package/lib/machineRoutes.mjs +1 -5
- package/lib/manager.mjs +254 -0
- package/lib/mcp-stdio.mjs +58 -39
- package/lib/moves.mjs +365 -0
- package/lib/nudge.mjs +13 -3
- package/lib/ownMachines.mjs +43 -6
- package/lib/places.mjs +29 -2
- package/lib/runAuthority.mjs +2 -14
- package/lib/runBrief.mjs +14 -1
- package/lib/runWorker.mjs +4 -10
- package/lib/runner.mjs +1 -49
- package/lib/sessionControl.mjs +65 -1
- package/lib/steerHook.mjs +124 -0
- package/lib/steerQueue.mjs +176 -0
- package/lib/store.mjs +9 -23
- package/lib/subagentSteering.mjs +363 -0
- package/lib/subagents.mjs +138 -29
- package/lib/swarm.mjs +13 -3
- package/lib/taskCommands.mjs +0 -62
- package/lib/threadActions.mjs +4 -2
- package/lib/threadBriefs.mjs +9 -3
- package/lib/threadRuns.mjs +13 -0
- package/npm-shrinkwrap.json +14 -14
- package/package.json +4 -4
- package/release.json +44 -40
- package/lib/comfyExecution.mjs +0 -545
- package/lib/promptDecider.mjs +0 -471
- package/lib/promptFlow.mjs +0 -597
- package/lib/promptScopes.mjs +0 -670
package/lib/moves.mjs
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { nameOf } from "./members.mjs";
|
|
2
|
+
|
|
3
|
+
// The coordinator's moves beyond bringing agents in, asking the person and waiting (Codex's decision contract, posts 163
|
|
4
|
+
// and 168 of thread 344f1900; the server's half is src/server/swarm/moves.ts). This module offers what exists in a
|
|
5
|
+
// thread (what can be looked up, the agents' conversations, turns held for the person's go, results, work going now,
|
|
6
|
+
// whether the thread can close) and carries out the one Jev picks. Every move uses the person's own words or an
|
|
7
|
+
// agent's own result; none writes a brief, and each is checked again here against the thread as it is now.
|
|
8
|
+
|
|
9
|
+
const TRANSCRIPT_POSTS = 30;
|
|
10
|
+
// What a look-up brings back at most; the round it goes into is sent again with fewer posts if Jev cannot read it all.
|
|
11
|
+
const LOOKED_CHARS = 40_000;
|
|
12
|
+
const SAID = new Set(["post", "result", "question"]);
|
|
13
|
+
|
|
14
|
+
const line = (text, max) =>
|
|
15
|
+
String(text ?? "")
|
|
16
|
+
.replace(/\s+/g, " ")
|
|
17
|
+
.trim()
|
|
18
|
+
.slice(0, max);
|
|
19
|
+
const minutesSince = (at) =>
|
|
20
|
+
at ? Math.max(0, Math.round((Date.now() - Date.parse(at)) / 60_000)) : null;
|
|
21
|
+
|
|
22
|
+
export function createMoves({
|
|
23
|
+
store,
|
|
24
|
+
// Whether a run is going (claimed, running or authorized and waiting to start).
|
|
25
|
+
going,
|
|
26
|
+
// Agents on Harness's server at work in the thread, and the server task each holds there.
|
|
27
|
+
hostedAtWork,
|
|
28
|
+
hostedTaskOf = () => null,
|
|
29
|
+
// The person's own words to agents, as if the person had named them (their go, their authority).
|
|
30
|
+
wakeAll,
|
|
31
|
+
// The person's Start for one held turn (board.run as the person).
|
|
32
|
+
start,
|
|
33
|
+
// Stop a run here or on the computer that took it; cancel a task on Harness's server (acknowledged or not).
|
|
34
|
+
stopRun,
|
|
35
|
+
cancelHosted,
|
|
36
|
+
finishGoal,
|
|
37
|
+
// The person's open asks (manager.mjs): the thread does not close while any is open.
|
|
38
|
+
openAsks = () => [],
|
|
39
|
+
post,
|
|
40
|
+
notifyBoard,
|
|
41
|
+
log = () => {},
|
|
42
|
+
}) {
|
|
43
|
+
const posts = (goalId) => store.roomPosts(goalId, 0, 500);
|
|
44
|
+
const isHeld = (run) => run.status === "open" && !run.run_authorized_at;
|
|
45
|
+
const working = (run) => going(run) && !isHeld(run);
|
|
46
|
+
// Agents' turns waiting for the person's Start, newest last.
|
|
47
|
+
const heldOf = (goalId) => store.threadRuns(goalId).filter(isHeld);
|
|
48
|
+
const runningOf = (goalId) => [
|
|
49
|
+
...store
|
|
50
|
+
.threadRuns(goalId)
|
|
51
|
+
.filter(working)
|
|
52
|
+
.map((run) => ({
|
|
53
|
+
id: run.id,
|
|
54
|
+
agent: run.target_agent || "agent",
|
|
55
|
+
what: line(run.objective, 300),
|
|
56
|
+
run,
|
|
57
|
+
})),
|
|
58
|
+
...hostedAtWork(goalId).map((agent) => ({
|
|
59
|
+
id: `hosted:${agent}`,
|
|
60
|
+
agent,
|
|
61
|
+
what: line(
|
|
62
|
+
posts(goalId).findLast(
|
|
63
|
+
(each) => each.kind === "job" && each.mentions.includes(agent)
|
|
64
|
+
)?.text,
|
|
65
|
+
300
|
|
66
|
+
),
|
|
67
|
+
})),
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
/** What a round may do besides bringing agents in, for this thread now. `looked`: a look-up already done. */
|
|
71
|
+
const offered = (thread, { candidates, looked = null }) => {
|
|
72
|
+
const all = posts(thread.id);
|
|
73
|
+
const reachable = new Set(candidates.map((candidate) => candidate.id));
|
|
74
|
+
const atWork = new Set([
|
|
75
|
+
...store
|
|
76
|
+
.threadRuns(thread.id)
|
|
77
|
+
.filter(working)
|
|
78
|
+
.map((run) => run.target_agent),
|
|
79
|
+
...hostedAtWork(thread.id),
|
|
80
|
+
]);
|
|
81
|
+
const conversations = [
|
|
82
|
+
...new Set(
|
|
83
|
+
all
|
|
84
|
+
.filter(
|
|
85
|
+
(each) =>
|
|
86
|
+
SAID.has(each.kind) &&
|
|
87
|
+
reachable.has(each.author) &&
|
|
88
|
+
!store.meta(`coordinator-post:${each.id}`)
|
|
89
|
+
)
|
|
90
|
+
.map((each) => each.author)
|
|
91
|
+
),
|
|
92
|
+
]
|
|
93
|
+
.map((agent) => {
|
|
94
|
+
const last = all.findLast(
|
|
95
|
+
(each) =>
|
|
96
|
+
each.author === agent &&
|
|
97
|
+
SAID.has(each.kind) &&
|
|
98
|
+
!store.meta(`coordinator-post:${each.id}`)
|
|
99
|
+
);
|
|
100
|
+
return {
|
|
101
|
+
agent,
|
|
102
|
+
state: atWork.has(agent)
|
|
103
|
+
? "at_work"
|
|
104
|
+
: last.kind === "question"
|
|
105
|
+
? "asked_the_person"
|
|
106
|
+
: "answered",
|
|
107
|
+
last: line(last.text, 500),
|
|
108
|
+
};
|
|
109
|
+
})
|
|
110
|
+
.slice(-8);
|
|
111
|
+
const held = heldOf(thread.id)
|
|
112
|
+
.slice(-8)
|
|
113
|
+
.map((run) => ({
|
|
114
|
+
id: run.id,
|
|
115
|
+
agent: run.target_agent || "agent",
|
|
116
|
+
asker: run.origin_agent || "agent",
|
|
117
|
+
what: line(run.objective, 500),
|
|
118
|
+
}));
|
|
119
|
+
const results = [
|
|
120
|
+
...all
|
|
121
|
+
.filter(
|
|
122
|
+
(each) =>
|
|
123
|
+
(each.kind === "result" || each.kind === "post") &&
|
|
124
|
+
each.author !== "user" &&
|
|
125
|
+
each.author !== thread.goal.facilitator &&
|
|
126
|
+
!store.meta(`coordinator-post:${each.id}`)
|
|
127
|
+
)
|
|
128
|
+
.slice(-5)
|
|
129
|
+
.map((each) => ({
|
|
130
|
+
id: `post:${each.seq}`,
|
|
131
|
+
author: each.author,
|
|
132
|
+
what: line(each.text, 500),
|
|
133
|
+
})),
|
|
134
|
+
...resultFiles(thread)
|
|
135
|
+
.slice(-3)
|
|
136
|
+
.map((file) => ({
|
|
137
|
+
id: `file:${file.id}`,
|
|
138
|
+
author: file.author,
|
|
139
|
+
what: `the file ${line(file.name, 200)}`,
|
|
140
|
+
})),
|
|
141
|
+
];
|
|
142
|
+
const running = runningOf(thread.id)
|
|
143
|
+
.slice(-8)
|
|
144
|
+
.map(({ id, agent, what }) => ({ id, agent, what }));
|
|
145
|
+
const lookUps = looked
|
|
146
|
+
? []
|
|
147
|
+
: [
|
|
148
|
+
...(all.length > TRANSCRIPT_POSTS ? ["earlier_posts"] : []),
|
|
149
|
+
"board",
|
|
150
|
+
...(running.length ? ["work_status"] : []),
|
|
151
|
+
];
|
|
152
|
+
return {
|
|
153
|
+
lookUps,
|
|
154
|
+
...(looked ? { lookedUp: [looked] } : {}),
|
|
155
|
+
conversations,
|
|
156
|
+
held,
|
|
157
|
+
results,
|
|
158
|
+
running,
|
|
159
|
+
finishable: !running.length && !held.length,
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// Files on the thread and on the work done in it.
|
|
164
|
+
const resultFiles = (thread) =>
|
|
165
|
+
[thread.id, ...store.threadRuns(thread.id).map((run) => run.id)]
|
|
166
|
+
.flatMap((taskId) => store.taskFiles(taskId))
|
|
167
|
+
.filter((file) => file && file.author !== "user")
|
|
168
|
+
.sort((a, b) => a.created_at.localeCompare(b.created_at));
|
|
169
|
+
|
|
170
|
+
/** The look-up Jev asked for, as text the next decision reads. */
|
|
171
|
+
const lookUp = (thread, kind, request, before = null) => {
|
|
172
|
+
if (kind === "earlier_posts") {
|
|
173
|
+
const all = posts(thread.id);
|
|
174
|
+
// Before the oldest post the round read: the transcript's window, or fewer when the round left some out to fit.
|
|
175
|
+
const earlier =
|
|
176
|
+
before === null
|
|
177
|
+
? all.slice(0, -TRANSCRIPT_POSTS)
|
|
178
|
+
: all.filter((each) => each.seq < before);
|
|
179
|
+
const kept = [];
|
|
180
|
+
let room = LOOKED_CHARS;
|
|
181
|
+
for (const each of earlier.reverse()) {
|
|
182
|
+
// The person's words whole, as they wrote them; an agent's cut, its post whole in the thread.
|
|
183
|
+
const text =
|
|
184
|
+
each.author === "user" ? each.text : line(each.text, 1_500);
|
|
185
|
+
const said = `#${each.seq} ${nameOf(each.author)} (${each.kind}): ${text}`;
|
|
186
|
+
if (said.length > room && kept.length) break;
|
|
187
|
+
kept.unshift(said);
|
|
188
|
+
room -= said.length + 1;
|
|
189
|
+
}
|
|
190
|
+
return { kind, text: kept.join("\n") || "No earlier posts." };
|
|
191
|
+
}
|
|
192
|
+
if (kind === "work_status") {
|
|
193
|
+
const text = runningOf(thread.id)
|
|
194
|
+
.map(({ agent, what, run }) => {
|
|
195
|
+
const latest = posts(thread.id).findLast(
|
|
196
|
+
(each) => each.author === agent
|
|
197
|
+
);
|
|
198
|
+
const minutes = minutesSince(run?.claimed_at ?? run?.created_at);
|
|
199
|
+
return `${nameOf(agent)}: ${what}${minutes === null ? "" : `, ${run.status} for ${minutes} min`}${run?.claimed_machine ? ` on ${run.claimed_machine}` : ""}${latest ? `; latest post: ${line(latest.text, 600)}` : ""}`;
|
|
200
|
+
})
|
|
201
|
+
.join("\n");
|
|
202
|
+
return { kind, text: text || "Nothing is running." };
|
|
203
|
+
}
|
|
204
|
+
const threads = store
|
|
205
|
+
.searchThreads(request, { k: 12 })
|
|
206
|
+
.filter((hit) => hit.thread !== thread.id)
|
|
207
|
+
.map(
|
|
208
|
+
(hit) =>
|
|
209
|
+
`Thread "${line(hit.thread_title, 120)}", ${nameOf(hit.author)}: ${line(hit.text, 1_200)}`
|
|
210
|
+
);
|
|
211
|
+
const sessions = store
|
|
212
|
+
.search({
|
|
213
|
+
query: String(request).split(/\s+/).slice(0, 12).join(" "),
|
|
214
|
+
limit: 6,
|
|
215
|
+
})
|
|
216
|
+
.filter((hit) => hit.excerpt)
|
|
217
|
+
.map(
|
|
218
|
+
(hit) =>
|
|
219
|
+
`${nameOf(hit.agent)} session "${line(hit.title, 120)}": ${line(hit.excerpt, 1_200)}`
|
|
220
|
+
);
|
|
221
|
+
const text = [...threads, ...sessions].join("\n").slice(0, LOOKED_CHARS);
|
|
222
|
+
return { kind, text: text || "Nothing on the board matches." };
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
// The person's newest message in the thread: the words a move carries, and the go it may give.
|
|
226
|
+
const personMessage = (goalId) =>
|
|
227
|
+
posts(goalId).findLast(
|
|
228
|
+
(each) => each.author === "user" && each.kind === "post"
|
|
229
|
+
) ?? null;
|
|
230
|
+
|
|
231
|
+
/** Carries out a move. True when it was one; the thread says what happened. */
|
|
232
|
+
const apply = (thread, decision, coordinator) => {
|
|
233
|
+
const say = (text) =>
|
|
234
|
+
post({ goalId: thread.id, author: coordinator, kind: "note", text });
|
|
235
|
+
const message = personMessage(thread.id);
|
|
236
|
+
switch (decision.action) {
|
|
237
|
+
case "continue": {
|
|
238
|
+
const agent = String(decision.agent ?? "");
|
|
239
|
+
if (!message || !thread.goal.team.includes(agent)) return true;
|
|
240
|
+
wakeAll(
|
|
241
|
+
thread.id,
|
|
242
|
+
[agent],
|
|
243
|
+
message.text,
|
|
244
|
+
"the person's message follows on from your conversation in this thread"
|
|
245
|
+
);
|
|
246
|
+
say(`Your message went on to ${nameOf(agent)}, as you wrote it.`);
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
case "execute": {
|
|
250
|
+
const held = heldOf(thread.id).find((run) => run.id === decision.ref);
|
|
251
|
+
// The person's go is their own message, written after the turn began to wait.
|
|
252
|
+
if (!held || !message || message.created_at < held.created_at)
|
|
253
|
+
return true;
|
|
254
|
+
store.meta(`go-by-message:${held.id}`, String(message.seq));
|
|
255
|
+
const started = start(held.id);
|
|
256
|
+
say(
|
|
257
|
+
started?.ok
|
|
258
|
+
? `${nameOf(held.target_agent)}'s turn started on your go (your message #${message.seq}).`
|
|
259
|
+
: `${nameOf(held.target_agent)}'s turn could not start: ${started?.error ?? "it is no longer waiting"}.`
|
|
260
|
+
);
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
case "deliver": {
|
|
264
|
+
const shown = deliver(thread, String(decision.ref ?? ""), coordinator);
|
|
265
|
+
if (!shown) return true;
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
case "cancel": {
|
|
269
|
+
const stopping = runningOf(thread.id).filter((work) =>
|
|
270
|
+
(decision.stop ?? []).includes(work.id)
|
|
271
|
+
);
|
|
272
|
+
for (const work of stopping) void stop(thread, work, say);
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
case "finish": {
|
|
276
|
+
if (runningOf(thread.id).length || heldOf(thread.id).length)
|
|
277
|
+
return true;
|
|
278
|
+
const open = openAsks(thread.id);
|
|
279
|
+
if (open.length) {
|
|
280
|
+
say(`Still open: ${open.join("; ")}`);
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
finishGoal(
|
|
284
|
+
thread.id,
|
|
285
|
+
coordinator,
|
|
286
|
+
message
|
|
287
|
+
? `Closed on your word (your message #${message.seq}).`
|
|
288
|
+
: "Closed: what was asked is done."
|
|
289
|
+
);
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
default:
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
notifyBoard(store.getTask(thread.id));
|
|
296
|
+
return true;
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
// A result shown again: the agent's own words or file, attributed, never reworded.
|
|
300
|
+
const deliver = (thread, ref, coordinator) => {
|
|
301
|
+
if (ref.startsWith("post:")) {
|
|
302
|
+
const seq = Number(ref.slice(5));
|
|
303
|
+
const original = posts(thread.id).find((each) => each.seq === seq);
|
|
304
|
+
if (!original) return false;
|
|
305
|
+
post({
|
|
306
|
+
goalId: thread.id,
|
|
307
|
+
author: coordinator,
|
|
308
|
+
kind: "post",
|
|
309
|
+
text: `${nameOf(original.author)}'s result (post #${seq}):\n\n${original.text}`,
|
|
310
|
+
});
|
|
311
|
+
return true;
|
|
312
|
+
}
|
|
313
|
+
const file = ref.startsWith("file:") ? store.file(ref.slice(5)) : null;
|
|
314
|
+
if (!file) return false;
|
|
315
|
+
if (file.task_id !== thread.id)
|
|
316
|
+
store.addFile({
|
|
317
|
+
taskId: thread.id,
|
|
318
|
+
name: file.name,
|
|
319
|
+
mime: file.mime,
|
|
320
|
+
bytes: file.bytes,
|
|
321
|
+
sha256: file.sha256,
|
|
322
|
+
author: file.author,
|
|
323
|
+
cloud: file.cloud,
|
|
324
|
+
});
|
|
325
|
+
post({
|
|
326
|
+
goalId: thread.id,
|
|
327
|
+
author: coordinator,
|
|
328
|
+
kind: "post",
|
|
329
|
+
text: `${nameOf(file.author)}'s file ${file.name}, in this thread's files.`,
|
|
330
|
+
});
|
|
331
|
+
return true;
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
// Stopped only once its executor says so; a request with no answer is said as asked, not as stopped.
|
|
335
|
+
const stop = async (thread, work, say) => {
|
|
336
|
+
if (work.run) {
|
|
337
|
+
const runs = store
|
|
338
|
+
.threadRuns(thread.id)
|
|
339
|
+
.filter((run) => run.target_agent === work.agent && working(run));
|
|
340
|
+
store.closeGoalChildren(thread.id, "Stopped on your word.", work.agent);
|
|
341
|
+
const acknowledged = runs.map((run) => stopRun(run)).every(Boolean);
|
|
342
|
+
say(
|
|
343
|
+
acknowledged
|
|
344
|
+
? `${nameOf(work.agent)} stopped: ${work.what}`
|
|
345
|
+
: `${nameOf(work.agent)} was asked to stop: ${work.what}. Its computer has not said it stopped yet.`
|
|
346
|
+
);
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
const taskId = hostedTaskOf(thread.id, work.agent);
|
|
350
|
+
const cancelled = taskId
|
|
351
|
+
? await cancelHosted(taskId).catch((error) => {
|
|
352
|
+
log(`cancel ${taskId}: ${error.message}`);
|
|
353
|
+
return null;
|
|
354
|
+
})
|
|
355
|
+
: null;
|
|
356
|
+
say(
|
|
357
|
+
cancelled?.ok
|
|
358
|
+
? `${nameOf(work.agent)} stopped: ${work.what}`
|
|
359
|
+
: `${nameOf(work.agent)} could not be stopped${cancelled?.error ? ` (${cancelled.error})` : ""}: ${work.what}`
|
|
360
|
+
);
|
|
361
|
+
notifyBoard(store.getTask(thread.id));
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
return { offered, lookUp, apply };
|
|
365
|
+
}
|
package/lib/nudge.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import { fitSections } from "./fit.mjs";
|
|
|
9
9
|
import { oneLine } from "./oneLine.mjs";
|
|
10
10
|
import { SWARM_HEADER } from "./cards.mjs";
|
|
11
11
|
import { hookDialect, hookInput } from "./hookDialects.mjs";
|
|
12
|
+
import { PARENT, steerText, takeSteers } from "./steerQueue.mjs";
|
|
12
13
|
|
|
13
14
|
// The session-start nudge: what an interactive agent is told when a session opens, so work
|
|
14
15
|
// waiting on the board is not silent until someone asks. Claude Code runs this as a
|
|
@@ -489,10 +490,19 @@ if (import.meta.url === `file://${process.argv[1]}`) {
|
|
|
489
490
|
// A stop that is not a turn ending (Grok's as a session closes) cannot keep anything going: a message taken then
|
|
490
491
|
// would be lost.
|
|
491
492
|
if (input && !input.endsTurn) process.exit(0);
|
|
492
|
-
// The Stop hook: a message waiting for this session keeps the agent going with it
|
|
493
|
+
// The Stop hook: a message waiting for this session keeps the agent going with it, and so does a word about one of
|
|
494
|
+
// its subagents the person steered that its own model has not seen yet (steerQueue.mjs).
|
|
493
495
|
const messages = await takeMessages(agent, sessionId);
|
|
494
|
-
|
|
495
|
-
|
|
496
|
+
const steers = sessionId
|
|
497
|
+
? takeSteers(sessionId, PARENT, { event: "turn end" })
|
|
498
|
+
: [];
|
|
499
|
+
const text = [
|
|
500
|
+
messages.length ? messagesText(messages) : "",
|
|
501
|
+
steers.length ? steerText(steers) : "",
|
|
502
|
+
]
|
|
503
|
+
.filter(Boolean)
|
|
504
|
+
.join("\n\n");
|
|
505
|
+
if (text) process.stdout.write(dialect.block(text) + "\n");
|
|
496
506
|
else await noteTurn(agent, input);
|
|
497
507
|
} else {
|
|
498
508
|
if (prompted) await notePrompt(agent, input);
|
package/lib/ownMachines.mjs
CHANGED
|
@@ -180,8 +180,8 @@ export function createOwnMachines({
|
|
|
180
180
|
// A proxy link's model call from one of the person's cloud computers, on the computer holding the link
|
|
181
181
|
// (proxyLinks.mjs answer); null where none is held.
|
|
182
182
|
answerLink = null,
|
|
183
|
-
//
|
|
184
|
-
|
|
183
|
+
// Home asking whether this computer can do a piece of work (capabilityCheck.mjs), only over its sealed ask.
|
|
184
|
+
answerCapability = null,
|
|
185
185
|
// A cloud computer's own SSH keys (cloudSsh.mjs allow): { key, by } in, null on a computer that takes none.
|
|
186
186
|
ownSsh = null,
|
|
187
187
|
// This computer updating itself to a published release (daemon.mjs): `tryharness upgrade <spec>`, which takes only a
|
|
@@ -2098,8 +2098,8 @@ export function createOwnMachines({
|
|
|
2098
2098
|
// a question for the windows only from the few they answer for home (M6).
|
|
2099
2099
|
// A cloud home's call through a proxy link this computer holds is answered for that home alone (proxyLinks.mjs).
|
|
2100
2100
|
const answer =
|
|
2101
|
-
call.
|
|
2102
|
-
? await
|
|
2101
|
+
typeof call.capability === "string" && answerCapability
|
|
2102
|
+
? await answerCapability(call.capability)
|
|
2103
2103
|
: call.inventory === true
|
|
2104
2104
|
? { ok: true, folders: folders({ fresh: true }) }
|
|
2105
2105
|
: call.home === true
|
|
@@ -2426,6 +2426,37 @@ export function createOwnMachines({
|
|
|
2426
2426
|
};
|
|
2427
2427
|
};
|
|
2428
2428
|
|
|
2429
|
+
/**
|
|
2430
|
+
* A subagent read or steer, done on the computer its session runs on (subagentSteering.mjs local): through home, which
|
|
2431
|
+
* asks the worker that has it, as a session read goes.
|
|
2432
|
+
*/
|
|
2433
|
+
const askSubagents = async (target, call) => {
|
|
2434
|
+
const where = String(target || machine.id);
|
|
2435
|
+
if (where === machine.id) return ownLive({ subagent: call });
|
|
2436
|
+
if (isHome()) {
|
|
2437
|
+
if (
|
|
2438
|
+
!siblings.some((sibling) => sibling.id === where && confirmed(sibling))
|
|
2439
|
+
)
|
|
2440
|
+
return { ok: false, error: "that computer is not in your swarm" };
|
|
2441
|
+
return (
|
|
2442
|
+
(await askWorker(where, { live: { subagent: call } })) ?? {
|
|
2443
|
+
ok: false,
|
|
2444
|
+
error: `${labelOf(where) ?? "That computer"} did not answer`,
|
|
2445
|
+
}
|
|
2446
|
+
);
|
|
2447
|
+
}
|
|
2448
|
+
const pinned = pinnedHome();
|
|
2449
|
+
if (!pinned) return { ok: false, error: unreachableNote(null) };
|
|
2450
|
+
return (
|
|
2451
|
+
(await callOnce(pinned, {
|
|
2452
|
+
command: LIVE_COMMAND,
|
|
2453
|
+
agent: "user",
|
|
2454
|
+
subagent: call,
|
|
2455
|
+
machine: where,
|
|
2456
|
+
})) ?? offline()
|
|
2457
|
+
);
|
|
2458
|
+
};
|
|
2459
|
+
|
|
2429
2460
|
/**
|
|
2430
2461
|
* One session's latest messages and steps, read on the computer it runs on (`machine`, this one by default): through
|
|
2431
2462
|
* home, which asks the worker that has it.
|
|
@@ -2521,6 +2552,7 @@ export function createOwnMachines({
|
|
|
2521
2552
|
const answerLiveCall = async (call, from) => {
|
|
2522
2553
|
if (call.agent !== "user")
|
|
2523
2554
|
return { ok: false, error: "only the person reads their sessions" };
|
|
2555
|
+
if (call.subagent) return askSubagents(call.machine, call.subagent);
|
|
2524
2556
|
if (call.open) return openSession({ ...call.open, machine: call.machine });
|
|
2525
2557
|
if (call.read) return readSession({ ...call.read, machine: call.machine });
|
|
2526
2558
|
return { ok: true, computers: await everyComputersLive(from) };
|
|
@@ -2875,6 +2907,9 @@ export function createOwnMachines({
|
|
|
2875
2907
|
inventoryOf(sibling.id).state === "ready"
|
|
2876
2908
|
? namesOf(infos.get(sibling.id).folders)
|
|
2877
2909
|
: [],
|
|
2910
|
+
// Its last inventory request got no answer (a worker that never answers, or one too old to): asking it again
|
|
2911
|
+
// now would only wait out the transport.
|
|
2912
|
+
unanswered: Boolean(inventoryRequests.get(sibling.id)?.error),
|
|
2878
2913
|
})),
|
|
2879
2914
|
];
|
|
2880
2915
|
|
|
@@ -2969,9 +3004,10 @@ export function createOwnMachines({
|
|
|
2969
3004
|
answerAs,
|
|
2970
3005
|
pushViews,
|
|
2971
3006
|
askWorkerWindows,
|
|
2972
|
-
|
|
3007
|
+
// Whether a worker can do this work, by an agent there looking (capabilityCheck.mjs); null when it cannot be asked.
|
|
3008
|
+
capabilityOf: (workerId, work) =>
|
|
2973
3009
|
isHome() && store.ownMachine(workerId)?.hosted !== true
|
|
2974
|
-
? askWorker(workerId, {
|
|
3010
|
+
? askWorker(workerId, { capability: String(work) })
|
|
2975
3011
|
: Promise.resolve(null),
|
|
2976
3012
|
linkCall,
|
|
2977
3013
|
tellWorkers,
|
|
@@ -2999,6 +3035,7 @@ export function createOwnMachines({
|
|
|
2999
3035
|
models,
|
|
3000
3036
|
sessions,
|
|
3001
3037
|
readSession,
|
|
3038
|
+
askSubagents,
|
|
3002
3039
|
openSession,
|
|
3003
3040
|
setModel,
|
|
3004
3041
|
update,
|
package/lib/places.mjs
CHANGED
|
@@ -12,8 +12,8 @@ import { kept } from "./kept.mjs";
|
|
|
12
12
|
// Harness piece inside the agent sends it when the session starts (the Claude Code and Codex hooks, nudge.mjs; the
|
|
13
13
|
// opencode plugin; the pi extension), or the daemon reads it from the running process when nothing did. Terminals and
|
|
14
14
|
// editors put their own ids into everything they start, the same on every OS (TERM_PROGRAM, TMUX_PANE, WEZTERM_PANE,
|
|
15
|
-
// KITTY_WINDOW_ID, NVIM: Neovim's server, VSCODE_GIT_ASKPASS_NODE: the editor's own
|
|
16
|
-
// (__CFBundleIdentifier).
|
|
15
|
+
// KITTY_WINDOW_ID, NVIM: Neovim's server, HERDR_PANE_ID: herdr's pane, VSCODE_GIT_ASKPASS_NODE: the editor's own
|
|
16
|
+
// install); macOS adds the app (__CFBundleIdentifier).
|
|
17
17
|
//
|
|
18
18
|
// Any other agent (a custom harness) does the same with one line to the daemon's socket as a session starts:
|
|
19
19
|
// {"command":"board.live.place","agent":"<its id>","sessionId":"<id>","folder":"<absolute path>","pids":[<its pid>],
|
|
@@ -34,6 +34,11 @@ export const PLACE_ENV = [
|
|
|
34
34
|
"KITTY_WINDOW_ID",
|
|
35
35
|
"KITTY_LISTEN_ON",
|
|
36
36
|
"NVIM",
|
|
37
|
+
"HERDR_PANE_ID",
|
|
38
|
+
"HERDR_TAB_ID",
|
|
39
|
+
"HERDR_WORKSPACE_ID",
|
|
40
|
+
"HERDR_SOCKET_PATH",
|
|
41
|
+
"HERDR_BIN_PATH",
|
|
37
42
|
"WT_SESSION",
|
|
38
43
|
"VSCODE_GIT_ASKPASS_NODE",
|
|
39
44
|
"CLAUDE_CODE_ENTRYPOINT",
|
|
@@ -1184,12 +1189,29 @@ export const isTerminalApp = (app) =>
|
|
|
1184
1189
|
path.basename(app, ".app")
|
|
1185
1190
|
);
|
|
1186
1191
|
|
|
1192
|
+
const HERDR_ID = /^[A-Za-z0-9._:-]{1,128}$/;
|
|
1193
|
+
const absolute = (file) =>
|
|
1194
|
+
typeof file === "string" && path.isAbsolute(file) ? file : null;
|
|
1195
|
+
/** A herdr pane's ids, from what herdr puts in everything a pane runs; null outside herdr. */
|
|
1196
|
+
function herdrIds(env) {
|
|
1197
|
+
if (!HERDR_ID.test(env.HERDR_PANE_ID || "")) return null;
|
|
1198
|
+
const id = (value) => (HERDR_ID.test(value || "") ? value : null);
|
|
1199
|
+
return {
|
|
1200
|
+
pane: env.HERDR_PANE_ID,
|
|
1201
|
+
tab: id(env.HERDR_TAB_ID),
|
|
1202
|
+
workspace: id(env.HERDR_WORKSPACE_ID),
|
|
1203
|
+
socket: absolute(env.HERDR_SOCKET_PATH),
|
|
1204
|
+
bin: absolute(env.HERDR_BIN_PATH),
|
|
1205
|
+
};
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1187
1208
|
/**
|
|
1188
1209
|
* Where a session runs, from its environment and the app found up its process tree (`host`, live.mjs hostApp):
|
|
1189
1210
|
* t3 T3 Code;
|
|
1190
1211
|
* editor an editor built on VS Code: its terminal, or an agent's own panel there ("surface");
|
|
1191
1212
|
* codex-app the Codex app;
|
|
1192
1213
|
* nvim a Neovim terminal: its server (neovim.mjs), and the terminal app and pane Neovim itself runs in;
|
|
1214
|
+
* herdr a herdr pane: its pane, tab and workspace, and the socket and binary of the herdr it is in (herdr.mjs);
|
|
1193
1215
|
* terminal a terminal app, with the ids that pick its pane on any OS (tmux, WezTerm, kitty) and its tty;
|
|
1194
1216
|
* app any other app.
|
|
1195
1217
|
* The environment comes first: the app a process sits under can be a different one (a terminal started from an editor).
|
|
@@ -1229,6 +1251,11 @@ export function placeFrom({
|
|
|
1229
1251
|
folder,
|
|
1230
1252
|
};
|
|
1231
1253
|
};
|
|
1254
|
+
// A herdr pane, before anything its environment carries from where herdr's server started (a terminal's, an editor's or
|
|
1255
|
+
// T3 Code's): a session in it shows only in herdr. Neovim run in the pane, or an editor's own panel, is the place.
|
|
1256
|
+
const herdr = herdrIds(env);
|
|
1257
|
+
if (herdr && !env.NVIM && env.CLAUDE_CODE_ENTRYPOINT !== "claude-vscode")
|
|
1258
|
+
return { kind: "herdr", name: "herdr", ...herdr, folder };
|
|
1232
1259
|
if (env.T3CODE_CLI_PATH || bundle === T3_BUNDLE)
|
|
1233
1260
|
return { kind: "t3", name: "T3 Code", folder };
|
|
1234
1261
|
const ids = {
|
package/lib/runAuthority.mjs
CHANGED
|
@@ -200,7 +200,7 @@ export function createRunAuthority({ store, installedAgents }) {
|
|
|
200
200
|
rule.mode === "named" && rule.runs_today >= rule.daily_cap;
|
|
201
201
|
const standingRules = () => store.standing(runners(), startOfToday());
|
|
202
202
|
// null when the run may start now; otherwise why it waits for the person.
|
|
203
|
-
const standingVerdict = ({ trust, target, workspace
|
|
203
|
+
const standingVerdict = ({ trust, target, workspace }) => {
|
|
204
204
|
if (trust !== "user")
|
|
205
205
|
return "Another agent wrote it, so it never starts without the person.";
|
|
206
206
|
const rule = standingRules().find((entry) => entry.agent === target);
|
|
@@ -212,7 +212,7 @@ export function createRunAuthority({ store, installedAgents }) {
|
|
|
212
212
|
return rule.mode === "named"
|
|
213
213
|
? `${workspace} is outside the folders ${target} may run in without asking (${rule.workspaces.join(", ")}).`
|
|
214
214
|
: `${workspace} is not a folder below the home folder, where agents run without the person.`;
|
|
215
|
-
if (
|
|
215
|
+
if (pastLimit(rule))
|
|
216
216
|
return `${target} already started ${rule.runs_today} runs today without asking, the daily limit the person set.`;
|
|
217
217
|
return null;
|
|
218
218
|
};
|
|
@@ -401,18 +401,6 @@ export function createRunAuthority({ store, installedAgents }) {
|
|
|
401
401
|
request[RUN_CALLER] = run;
|
|
402
402
|
if (!runMayAsk(command))
|
|
403
403
|
return "A run Harness started cannot do that; only the person can.";
|
|
404
|
-
if (
|
|
405
|
-
run.dispatchScope &&
|
|
406
|
-
!new Set([
|
|
407
|
-
"board.dispatch.workspace",
|
|
408
|
-
"board.dispatch.propose",
|
|
409
|
-
"board.dispatch.view",
|
|
410
|
-
"board.dispatch.apply",
|
|
411
|
-
"board.dispatch.scope.list",
|
|
412
|
-
"board.dispatch.scope.read",
|
|
413
|
-
]).has(command)
|
|
414
|
-
)
|
|
415
|
-
return "This run has only its scoped workspace and dispatch tools.";
|
|
416
404
|
if (run.restricted && command.startsWith("mcp."))
|
|
417
405
|
return "A restricted run reaches this computer's board, not the person's Harness.";
|
|
418
406
|
if (run.restricted || run.forAnotherPerson)
|
package/lib/runBrief.mjs
CHANGED
|
@@ -38,6 +38,8 @@ export function createRunBriefs({
|
|
|
38
38
|
threadFilesNote,
|
|
39
39
|
t3CatchUp,
|
|
40
40
|
wakeBrief,
|
|
41
|
+
// What a run in a thread is told of the thread's board of cards (kanban.mjs).
|
|
42
|
+
boardBrief = () => "",
|
|
41
43
|
}) {
|
|
42
44
|
// What claude-mem remembers about this folder joins the task's context and the brief, so an agent without claude-mem
|
|
43
45
|
// starts from the same history one with it would. A wake resumes its own session.
|
|
@@ -203,7 +205,18 @@ export function createRunBriefs({
|
|
|
203
205
|
text: refs.length ? `Context:\n${refs.join("\n")}` : "",
|
|
204
206
|
pointer: `Context: ${refs.length} reference${refs.length === 1 ? "" : "s"}; get_task ${task.id} lists them.`,
|
|
205
207
|
},
|
|
206
|
-
...(room?.kind === "goal"
|
|
208
|
+
...(room?.kind === "goal"
|
|
209
|
+
? [
|
|
210
|
+
roomSection(room, agent),
|
|
211
|
+
{
|
|
212
|
+
name: "thread board",
|
|
213
|
+
priority: "recommended",
|
|
214
|
+
source: `thread ${room.id}`,
|
|
215
|
+
text: boardBrief(room.id),
|
|
216
|
+
pointer: `This thread has a board of cards the person follows its work on: keep yours current with update_board (thread ${room.id}).`,
|
|
217
|
+
},
|
|
218
|
+
]
|
|
219
|
+
: []),
|
|
207
220
|
// Who the agent works for, from the profile setup imported (profile.mjs); like lessons, only for agents here.
|
|
208
221
|
{
|
|
209
222
|
name: "the person",
|
package/lib/runWorker.mjs
CHANGED
|
@@ -210,9 +210,7 @@ export function createRunWorker({
|
|
|
210
210
|
if (resumeSession && !task.session_id)
|
|
211
211
|
store.setRunSession(task.id, resumeSession);
|
|
212
212
|
const readOnly = store.meta(`review:${task.id}`) === "1";
|
|
213
|
-
const
|
|
214
|
-
const restricted =
|
|
215
|
-
restrictedRun(store, task) || Boolean(dispatchOptions.dispatchScope);
|
|
213
|
+
const restricted = restrictedRun(store, task);
|
|
216
214
|
// Work another person asked for runs with only this person's own agent settings: the repository's own (its
|
|
217
215
|
// .claude hooks, .pi, opencode.json) can be that person's, and would run here (security audit P4, October 25).
|
|
218
216
|
const ownSettingsOnly = store.meta(`other-person-run:${task.id}`) === "1";
|
|
@@ -254,11 +252,7 @@ export function createRunWorker({
|
|
|
254
252
|
...(stoppedFor ? { again: true } : {}),
|
|
255
253
|
...(resumeSession && !t3 ? { resumeSession } : {}),
|
|
256
254
|
...(readOnly ? { readOnly } : {}),
|
|
257
|
-
...(
|
|
258
|
-
? dispatchOptions
|
|
259
|
-
: restricted
|
|
260
|
-
? { restricted }
|
|
261
|
-
: {}),
|
|
255
|
+
...(restricted ? { restricted } : {}),
|
|
262
256
|
...(ownSettingsOnly ? { ownSettingsOnly } : {}),
|
|
263
257
|
...(t3 ? { t3 } : {}),
|
|
264
258
|
...(granted ? { env: granted.env, scrub: granted.values } : {}),
|
|
@@ -311,11 +305,11 @@ export function createRunWorker({
|
|
|
311
305
|
setImmediate(runBoard);
|
|
312
306
|
if (extra?.usage) store.setRunUsage(task.id, extra.usage);
|
|
313
307
|
// Its changes are committed before it reports, so the audit of its report sees what was not.
|
|
314
|
-
|
|
308
|
+
commitRun(task);
|
|
315
309
|
// A run that failed without reaching its agent's own report ended early: the runner says why.
|
|
316
310
|
const reported = store.reportTask(task.id, agent, {
|
|
317
311
|
status: kind,
|
|
318
|
-
result:
|
|
312
|
+
result: text || "",
|
|
319
313
|
// Stopped for the person's steer (threadRuns.mjs): the person ended it, not the agent or its provider.
|
|
320
314
|
failure: store.meta(`steered:${task.id}`)
|
|
321
315
|
? "person"
|