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
|
@@ -11,6 +11,14 @@ const RUNTIME = "__HARNESS_RUNTIME__";
|
|
|
11
11
|
const AGENT = "__HARNESS_AGENT__";
|
|
12
12
|
const harness = () =>
|
|
13
13
|
import(pathToFileURL(path.join(RUNTIME, "lib", "nudge.mjs")).href);
|
|
14
|
+
// What the person tells a subagent from Harness waits in steerQueue.mjs for that session's next tool call.
|
|
15
|
+
let queue = null;
|
|
16
|
+
const steering = () =>
|
|
17
|
+
(queue ??= import(
|
|
18
|
+
pathToFileURL(path.join(RUNTIME, "lib", "steerQueue.mjs")).href
|
|
19
|
+
).catch(() => null));
|
|
20
|
+
// When OpenCode's client cannot take the message, a note rides on what the tool returns instead.
|
|
21
|
+
const notes = new Map();
|
|
14
22
|
const socketPath = async () =>
|
|
15
23
|
(await import(pathToFileURL(path.join(RUNTIME, "lib", "paths.mjs")).href))
|
|
16
24
|
.paths.socket;
|
|
@@ -46,6 +54,35 @@ const partId = () => {
|
|
|
46
54
|
};
|
|
47
55
|
|
|
48
56
|
export const TryHarnessPlugin = async ({ directory, client }) => ({
|
|
57
|
+
// An OpenCode subagent is a session of its own, so the person's word for it waits under that session. A note or a new
|
|
58
|
+
// brief goes in as the person's next message, which OpenCode queues for a session at work and the model reads as the
|
|
59
|
+
// person's own (words added to a tool's result are read as the tool's, Claude Code showed). A stop refuses every call
|
|
60
|
+
// with the reason until the session goes idle.
|
|
61
|
+
"tool.execute.before": async (input) => {
|
|
62
|
+
const steer = input?.sessionID ? await steering() : null;
|
|
63
|
+
if (!steer) return;
|
|
64
|
+
const items = steer.takeSteers(input.sessionID, steer.PARENT, {
|
|
65
|
+
tool: input.tool ?? null,
|
|
66
|
+
});
|
|
67
|
+
if (!items.length) return;
|
|
68
|
+
const text = steer.steerText(items);
|
|
69
|
+
if (items.some((item) => item.kind === "stop")) throw new Error(text);
|
|
70
|
+
const send =
|
|
71
|
+
client?.session?.promptAsync?.bind(client.session) ??
|
|
72
|
+
client?.session?.prompt?.bind(client.session);
|
|
73
|
+
if (send)
|
|
74
|
+
await send({
|
|
75
|
+
path: { id: input.sessionID },
|
|
76
|
+
body: { parts: [{ type: "text", text }] },
|
|
77
|
+
}).catch(() => notes.set(input.callID, text));
|
|
78
|
+
else notes.set(input.callID, text);
|
|
79
|
+
},
|
|
80
|
+
"tool.execute.after": async (input, output) => {
|
|
81
|
+
const text = notes.get(input?.callID);
|
|
82
|
+
if (!text || !output) return;
|
|
83
|
+
notes.delete(input.callID);
|
|
84
|
+
output.output = `${output.output ?? ""}\n\n${text}`;
|
|
85
|
+
},
|
|
49
86
|
// A session's first message is its start (Claude Code's SessionStart: the whole board); each later one carries the
|
|
50
87
|
// board again only when it changed (UserPromptSubmit).
|
|
51
88
|
"chat.message": async (input, output) => {
|
|
@@ -92,12 +129,19 @@ export const TryHarnessPlugin = async ({ directory, client }) => ({
|
|
|
92
129
|
const send =
|
|
93
130
|
client?.session?.promptAsync?.bind(client.session) ??
|
|
94
131
|
client?.session?.prompt?.bind(client.session);
|
|
95
|
-
|
|
132
|
+
const steerWords = await leftSteers(client, sessionId);
|
|
133
|
+
const text = [
|
|
134
|
+
messages.length ? board.messagesText(messages) : "",
|
|
135
|
+
steerWords,
|
|
136
|
+
]
|
|
137
|
+
.filter(Boolean)
|
|
138
|
+
.join("\n\n");
|
|
139
|
+
if (text && send)
|
|
96
140
|
await send({
|
|
97
141
|
path: { id: sessionId },
|
|
98
|
-
body: { parts: [{ type: "text", text
|
|
142
|
+
body: { parts: [{ type: "text", text }] },
|
|
99
143
|
}).catch(() => {});
|
|
100
|
-
else if (board && !
|
|
144
|
+
else if (board && !text)
|
|
101
145
|
await board.noteTurn(
|
|
102
146
|
AGENT,
|
|
103
147
|
{ session_id: sessionId, cwd: directory },
|
|
@@ -105,3 +149,26 @@ export const TryHarnessPlugin = async ({ directory, client }) => ({
|
|
|
105
149
|
);
|
|
106
150
|
},
|
|
107
151
|
});
|
|
152
|
+
|
|
153
|
+
// A session went idle: a stop for it is spent. A word the person sent a subagent that finished before reading it goes to
|
|
154
|
+
// the session that started the subagent, which has its answer now; one for a session of the person's own is its next
|
|
155
|
+
// turn (returned, for the caller to send).
|
|
156
|
+
async function leftSteers(client, sessionId) {
|
|
157
|
+
const steer = await steering();
|
|
158
|
+
const left = steer
|
|
159
|
+
? steer.endSteers(sessionId, steer.PARENT, { event: "end" })
|
|
160
|
+
: [];
|
|
161
|
+
if (!left.length) return "";
|
|
162
|
+
const got = await client?.session
|
|
163
|
+
?.get?.({ path: { id: sessionId } })
|
|
164
|
+
.catch(() => null);
|
|
165
|
+
const info = got?.data ?? got;
|
|
166
|
+
if (!info?.parentID) return steer.steerText(left);
|
|
167
|
+
steer.putSteer({
|
|
168
|
+
session: info.parentID,
|
|
169
|
+
agent: steer.PARENT,
|
|
170
|
+
kind: "parent",
|
|
171
|
+
text: `Your subagent "${info.title ?? sessionId}" finished before it read what they sent it, so it is yours to act on:\n\n${left.map((item) => item.text).join("\n\n")}`,
|
|
172
|
+
});
|
|
173
|
+
return "";
|
|
174
|
+
}
|
package/lib/asks.mjs
CHANGED
|
@@ -152,6 +152,8 @@ export function createAsks({
|
|
|
152
152
|
if (sent?.pending) await sent.pending;
|
|
153
153
|
else if (!sent?.ok)
|
|
154
154
|
throw Object.assign(new Error(sent?.error), { refused: connected() });
|
|
155
|
+
// The agent's newest task on Harness's server in this thread, by the ask's own id: what a stop ends (moves.mjs).
|
|
156
|
+
store.meta(`hosted-ask:${thread.id}:${ask.agent}`, ask.id);
|
|
155
157
|
forget(thread.id, ask.id);
|
|
156
158
|
} catch (error) {
|
|
157
159
|
const tries = (ask.tries ?? 0) + 1;
|
package/lib/boardCommands.mjs
CHANGED
|
@@ -9,6 +9,8 @@ export function createBoardCommands({
|
|
|
9
9
|
handlers,
|
|
10
10
|
task,
|
|
11
11
|
machineOf = () => null,
|
|
12
|
+
// What a feature's answer becomes before the caller has it; a pending answer is passed on once it settles.
|
|
13
|
+
answered = (request, answer) => answer,
|
|
12
14
|
}) {
|
|
13
15
|
return (request) => {
|
|
14
16
|
if (!validAgent(request.agent))
|
|
@@ -25,6 +27,12 @@ export function createBoardCommands({
|
|
|
25
27
|
const context = { agent, id, expected, machine };
|
|
26
28
|
const owner = boardCommandOwner(String(request.command));
|
|
27
29
|
const handler = Object.hasOwn(handlers, owner) ? handlers[owner] : task;
|
|
28
|
-
|
|
30
|
+
const answer = handler(request, context);
|
|
31
|
+
return answer?.pending
|
|
32
|
+
? {
|
|
33
|
+
...answer,
|
|
34
|
+
pending: answer.pending.then((settled) => answered(request, settled)),
|
|
35
|
+
}
|
|
36
|
+
: answered(request, answer);
|
|
29
37
|
};
|
|
30
38
|
}
|
package/lib/boardProtocol.json
CHANGED
|
@@ -22,12 +22,6 @@
|
|
|
22
22
|
"board.dispatch.scope.list": "task",
|
|
23
23
|
"board.dispatch.scope.revoke": "task",
|
|
24
24
|
"board.dispatch.propose": "task",
|
|
25
|
-
"board.dispatch.prompt": "task",
|
|
26
|
-
"board.prompt.start": "task",
|
|
27
|
-
"board.prompt.status": "task",
|
|
28
|
-
"board.prompt.cancel": "task",
|
|
29
|
-
"board.prompt.receipt": "task",
|
|
30
|
-
"board.dispatch.workspace": "task",
|
|
31
25
|
"board.dispatch.view": "task",
|
|
32
26
|
"board.dispatch.apply": "task",
|
|
33
27
|
"board.dispatch.advisory": "task",
|
|
@@ -68,6 +62,7 @@
|
|
|
68
62
|
"board.media.search": "tools",
|
|
69
63
|
"board.notices.take": "watch",
|
|
70
64
|
"board.place.op": "place",
|
|
65
|
+
"board.kanban.update": "kanban",
|
|
71
66
|
"board.plan.add": "plans",
|
|
72
67
|
"board.plan.edit": "plans",
|
|
73
68
|
"board.plan.remove": "plans",
|
|
@@ -214,7 +209,9 @@
|
|
|
214
209
|
"board.native.decide": "nativeRequests",
|
|
215
210
|
"board.swarm.links": "swarm",
|
|
216
211
|
"board.swarm.link": "swarm",
|
|
217
|
-
"board.wait": "waits"
|
|
212
|
+
"board.wait": "waits",
|
|
213
|
+
"board.subagent.read": "subagents",
|
|
214
|
+
"board.subagent.steer": "subagents"
|
|
218
215
|
},
|
|
219
216
|
"families": [
|
|
220
217
|
{
|
|
@@ -229,6 +226,10 @@
|
|
|
229
226
|
"owner": "landed",
|
|
230
227
|
"prefixes": ["board.landed."]
|
|
231
228
|
},
|
|
229
|
+
{
|
|
230
|
+
"owner": "subagents",
|
|
231
|
+
"prefixes": ["board.subagent."]
|
|
232
|
+
},
|
|
232
233
|
{
|
|
233
234
|
"owner": "relay",
|
|
234
235
|
"prefixes": ["board.relay."]
|
|
@@ -257,6 +258,10 @@
|
|
|
257
258
|
"owner": "plans",
|
|
258
259
|
"prefixes": ["board.plan.", "board.template."]
|
|
259
260
|
},
|
|
261
|
+
{
|
|
262
|
+
"owner": "kanban",
|
|
263
|
+
"prefixes": ["board.kanban."]
|
|
264
|
+
},
|
|
260
265
|
{
|
|
261
266
|
"owner": "projects",
|
|
262
267
|
"prefixes": ["board.project."]
|
|
@@ -284,6 +289,8 @@
|
|
|
284
289
|
],
|
|
285
290
|
"access": {
|
|
286
291
|
"phone": [
|
|
292
|
+
"board.subagent.read",
|
|
293
|
+
"board.subagent.steer",
|
|
287
294
|
"board.list",
|
|
288
295
|
"board.get",
|
|
289
296
|
"board.children",
|
|
@@ -342,6 +349,7 @@
|
|
|
342
349
|
"board.swarm.link",
|
|
343
350
|
"board.vault.allow",
|
|
344
351
|
"board.vault.dismiss",
|
|
352
|
+
"board.kanban.update",
|
|
345
353
|
"board.plan.add",
|
|
346
354
|
"board.plan.edit",
|
|
347
355
|
"board.plan.remove",
|
|
@@ -376,12 +384,11 @@
|
|
|
376
384
|
"board.swarm.specialty",
|
|
377
385
|
"board.swarm.pin",
|
|
378
386
|
"board.swarm.offices",
|
|
379
|
-
"board.swarm.office"
|
|
380
|
-
"board.prompt.start",
|
|
381
|
-
"board.prompt.status",
|
|
382
|
-
"board.prompt.cancel"
|
|
387
|
+
"board.swarm.office"
|
|
383
388
|
],
|
|
384
389
|
"browserPerson": [
|
|
390
|
+
"board.subagent.read",
|
|
391
|
+
"board.subagent.steer",
|
|
385
392
|
"board.list",
|
|
386
393
|
"board.get",
|
|
387
394
|
"board.children",
|
|
@@ -501,10 +508,7 @@
|
|
|
501
508
|
"board.vault.share",
|
|
502
509
|
"board.vault.unshare",
|
|
503
510
|
"board.vault.import",
|
|
504
|
-
"board.vault.allow"
|
|
505
|
-
"board.prompt.start",
|
|
506
|
-
"board.prompt.status",
|
|
507
|
-
"board.prompt.cancel"
|
|
511
|
+
"board.vault.allow"
|
|
508
512
|
],
|
|
509
513
|
"harnessBrowser": [
|
|
510
514
|
"board.list",
|
|
@@ -591,6 +595,8 @@
|
|
|
591
595
|
"board.room.search"
|
|
592
596
|
],
|
|
593
597
|
"desktop": [
|
|
598
|
+
"board.subagent.read",
|
|
599
|
+
"board.subagent.steer",
|
|
594
600
|
"board.audit.week",
|
|
595
601
|
"board.desk.book",
|
|
596
602
|
"board.desk.contract",
|
|
@@ -674,6 +680,7 @@
|
|
|
674
680
|
"board.relay.seen",
|
|
675
681
|
"board.relay.defaults",
|
|
676
682
|
"board.relay.peers",
|
|
683
|
+
"board.kanban.update",
|
|
677
684
|
"board.plan.add",
|
|
678
685
|
"board.plan.edit",
|
|
679
686
|
"board.plan.remove",
|
|
@@ -763,10 +770,7 @@
|
|
|
763
770
|
"board.wait",
|
|
764
771
|
"board.landed.thread",
|
|
765
772
|
"board.landed.folder",
|
|
766
|
-
"board.landed.open"
|
|
767
|
-
"board.prompt.start",
|
|
768
|
-
"board.prompt.status",
|
|
769
|
-
"board.prompt.cancel"
|
|
773
|
+
"board.landed.open"
|
|
770
774
|
],
|
|
771
775
|
"plainPerson": ["board.standing.off"],
|
|
772
776
|
"plainHarnessReads": [
|
package/lib/bridge.mjs
CHANGED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { askLocalAgent, LOCAL_DECIDERS } from "./localAgentAsk.mjs";
|
|
2
|
+
|
|
3
|
+
// The capability check (owner, November 1): when work comes in, each of the person's computers is asked whether it
|
|
4
|
+
// can do that specific work, and an agent there looks at what the computer has. The coordinator gives the answers to
|
|
5
|
+
// Jev with each agent's computers, so routing goes by what each computer can actually do rather than a fixed list of
|
|
6
|
+
// features any one person's machines happen to have.
|
|
7
|
+
|
|
8
|
+
const ANSWERS = ["yes", "no", "unknown"];
|
|
9
|
+
|
|
10
|
+
const question = (label, work) =>
|
|
11
|
+
[
|
|
12
|
+
`You are checking the computer "${label}" for the person who owns it. Their swarm of agents may send the work below to this computer.`,
|
|
13
|
+
"Look at this computer to see whether it can do that work: what is installed, set up and available here that the work needs. Change nothing.",
|
|
14
|
+
'Answer with only this JSON: {"answer": "yes" | "no" | "unknown", "why": "one sentence naming what you found"}.',
|
|
15
|
+
"",
|
|
16
|
+
"The work:",
|
|
17
|
+
work,
|
|
18
|
+
].join("\n");
|
|
19
|
+
|
|
20
|
+
const unknown = (why) => ({ answer: "unknown", why });
|
|
21
|
+
|
|
22
|
+
/** An agent's reply as an answer, or unknown when it is not one. */
|
|
23
|
+
const shaped = (reply) =>
|
|
24
|
+
ANSWERS.includes(reply?.answer) && typeof reply.why === "string"
|
|
25
|
+
? { answer: reply.answer, why: reply.why.slice(0, 300) }
|
|
26
|
+
: unknown("the check did not answer in the agreed shape");
|
|
27
|
+
|
|
28
|
+
export function createCapabilityCheck({
|
|
29
|
+
machine,
|
|
30
|
+
installedAgents,
|
|
31
|
+
// The person's other computers (ownMachines.mjs), read when a check runs: they connect after this is made.
|
|
32
|
+
ownMachines = () => null,
|
|
33
|
+
log,
|
|
34
|
+
ask = askLocalAgent,
|
|
35
|
+
}) {
|
|
36
|
+
/** This computer's answer for `work`, from the first agent here that can look. */
|
|
37
|
+
const answer = async (work) => {
|
|
38
|
+
const agent = LOCAL_DECIDERS.find((id) => installedAgents.includes(id));
|
|
39
|
+
if (!agent) return unknown("no agent on this computer can look");
|
|
40
|
+
try {
|
|
41
|
+
return shaped(
|
|
42
|
+
await ask(agent, question(machine().label, String(work)), {
|
|
43
|
+
look: true,
|
|
44
|
+
})
|
|
45
|
+
);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
log(`capability check: ${error.message}`);
|
|
48
|
+
return unknown(`the check failed: ${error.message}`);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** Every online computer's answer for `work`, this one included: [{ id, label, answer, why }]. */
|
|
53
|
+
const check = async (work) => {
|
|
54
|
+
const here = machine();
|
|
55
|
+
const own = ownMachines();
|
|
56
|
+
const others = (own?.all() ?? []).filter(
|
|
57
|
+
(computer) => computer.id !== here.id && computer.connected
|
|
58
|
+
);
|
|
59
|
+
// With no other computer online there is no choice of computer to make.
|
|
60
|
+
if (!others.length) return [];
|
|
61
|
+
const asked = [
|
|
62
|
+
answer(work).then((found) => ({
|
|
63
|
+
id: here.id,
|
|
64
|
+
label: here.label,
|
|
65
|
+
...found,
|
|
66
|
+
})),
|
|
67
|
+
...others.map(async (computer) => {
|
|
68
|
+
if (computer.unanswered)
|
|
69
|
+
return {
|
|
70
|
+
id: computer.id,
|
|
71
|
+
label: computer.label,
|
|
72
|
+
...unknown("it did not answer its last request from home"),
|
|
73
|
+
};
|
|
74
|
+
const reply = await own.capabilityOf(computer.id, work);
|
|
75
|
+
return {
|
|
76
|
+
id: computer.id,
|
|
77
|
+
label: computer.label,
|
|
78
|
+
...(reply ? shaped(reply) : unknown("the computer did not answer")),
|
|
79
|
+
};
|
|
80
|
+
}),
|
|
81
|
+
];
|
|
82
|
+
return Promise.all(asked);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
return { answer, check };
|
|
86
|
+
}
|
package/lib/computerAddress.mjs
CHANGED
|
@@ -53,16 +53,12 @@ export function computerAddress({
|
|
|
53
53
|
text,
|
|
54
54
|
computers,
|
|
55
55
|
target = null,
|
|
56
|
-
recipient = null,
|
|
57
56
|
agentOf = (name) => name,
|
|
58
57
|
}) {
|
|
59
58
|
const refuse = (error) => ({ ok: false, error });
|
|
60
|
-
|
|
61
|
-
//
|
|
62
|
-
const words =
|
|
63
|
-
recipient && /^\s*on\s+/i.test(original)
|
|
64
|
-
? `@${recipient} ${original.trimStart()}`
|
|
65
|
-
: original;
|
|
59
|
+
// Only explicit addresses are read here: #computer, `@agent on computer` and a typed computer. Whether plain words
|
|
60
|
+
// ("On pop-os: ...") mean a computer is the coordinator's judgment (Jev), never a pattern (owner, November 1).
|
|
61
|
+
const words = String(text ?? "");
|
|
66
62
|
let typed = null;
|
|
67
63
|
if (target != null && String(target).trim()) {
|
|
68
64
|
const wanted = String(target).trim();
|
|
@@ -118,13 +114,9 @@ export function computerAddress({
|
|
|
118
114
|
const after = words.slice(match.index + match[0].length);
|
|
119
115
|
const found = computersAtStart(after, computers);
|
|
120
116
|
if (!found.length) {
|
|
121
|
-
//
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const explicit =
|
|
125
|
-
match[0].endsWith("#") ||
|
|
126
|
-
(unknown && /^[\w.-]+$/.test(unknown) && /[-._\d]/.test(unknown));
|
|
127
|
-
if (several && unknown && explicit)
|
|
117
|
+
// "@agent on #name" with no such computer is an explicit address to a computer that does not exist.
|
|
118
|
+
const unknown = after.match(/^[\w.-]+/)?.[0];
|
|
119
|
+
if (several && unknown && match[0].endsWith("#"))
|
|
128
120
|
return refuse(
|
|
129
121
|
`No computer is called "${unknown}". Your computers: ${listOf(computers)}.`
|
|
130
122
|
);
|