tryharness 0.7.71 → 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/README.md +13 -8
- package/assets/opencode-plugin.js +70 -3
- package/cli.mjs +27 -12
- package/lib/asks.mjs +4 -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 +259 -30
- package/lib/daemon.mjs +164 -133
- package/lib/dispatchContract.json +1 -31
- package/lib/dispatchTools.js +8 -39
- package/lib/dispatches.mjs +27 -285
- package/lib/goalCommands.mjs +21 -38
- 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/live.mjs +25 -3
- package/lib/localAgentAsk.mjs +20 -29
- package/lib/machineRoutes.mjs +1 -5
- package/lib/machineRuns.mjs +42 -22
- 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 +122 -12
- package/lib/places.mjs +29 -2
- package/lib/plans.mjs +7 -1
- package/lib/projectSettings.mjs +11 -1
- package/lib/projects.mjs +20 -4
- package/lib/runAuthority.mjs +104 -35
- package/lib/runBrief.mjs +14 -1
- package/lib/runWorker.mjs +48 -24
- package/lib/runner.mjs +184 -75
- package/lib/selfUpdate.mjs +41 -0
- package/lib/serverWords.mjs +11 -11
- package/lib/sessionControl.mjs +68 -3
- package/lib/steerHook.mjs +124 -0
- package/lib/steerQueue.mjs +176 -0
- package/lib/store.mjs +34 -34
- package/lib/subagentSteering.mjs +363 -0
- package/lib/subagents.mjs +138 -29
- package/lib/swarm.mjs +16 -3
- package/lib/taskCommands.mjs +36 -71
- package/lib/threadActions.mjs +13 -3
- package/lib/threadAuthority.mjs +21 -14
- package/lib/threadBriefs.mjs +9 -3
- package/lib/threadRuns.mjs +35 -8
- package/npm-shrinkwrap.json +14 -14
- package/package.json +4 -4
- package/release.json +54 -49
- package/lib/comfyExecution.mjs +0 -545
- package/lib/promptDecider.mjs +0 -471
- package/lib/promptFlow.mjs +0 -562
- package/lib/promptScopes.mjs +0 -670
package/lib/machineRuns.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import { within } from "./folders.mjs";
|
|
4
5
|
import { provenanceLine } from "./provenance.mjs";
|
|
@@ -9,7 +10,7 @@ import { prepareScratch, threadScratch } from "./scratch.mjs";
|
|
|
9
10
|
// is home's to give and stays on home's board; a worker only asks home for what is authorized for it, takes each task
|
|
10
11
|
// in its agent's name, runs it here through the same runner as any run (taskRuns.mjs), and reports back to home, which
|
|
11
12
|
// keeps the report while home is out of reach. Asked when home is back, when home says there is work, and when a run
|
|
12
|
-
// ends; never on a timer. One run per folder at a time, as on home.
|
|
13
|
+
// ends; never on a timer. One run per agent per folder at a time, as on home.
|
|
13
14
|
//
|
|
14
15
|
// Home's stuck sweep (stuck.mjs) reads when each run last took a step. A run here has no record on home, so each new
|
|
15
16
|
// step is told to home, sealed like every call: the first at once, then at most one a second per run (the rate home's
|
|
@@ -19,9 +20,11 @@ const STEP_NOTICE_MS = 1_000;
|
|
|
19
20
|
// An agent's session id as this computer's agents name theirs; never one an agent's command line would read as a flag.
|
|
20
21
|
const SESSION_ID = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$/;
|
|
21
22
|
//
|
|
22
|
-
// Home lists the work; this computer decides where it runs (security audit 2026-10-25, M6). A run starts
|
|
23
|
-
// this computer
|
|
24
|
-
//
|
|
23
|
+
// Home lists the work; this computer decides where it runs (security audit 2026-10-25, M6). A run starts in a folder of
|
|
24
|
+
// this computer's below its home, as the person's own agents here may (owner, October 31: work they kicked off runs, it
|
|
25
|
+
// does not wait on folders they never limited), or in one its own agents' sessions or T3 Code worked in. A thread's turn naming home itself or above it, or this computer's
|
|
26
|
+
// scratch folder for the thread, works in that scratch folder. Any other folder home names (one this disk does not
|
|
27
|
+
// have, a folder of home's) is refused, and home's board says so, so the person sees why.
|
|
25
28
|
|
|
26
29
|
const real = (dir) => {
|
|
27
30
|
try {
|
|
@@ -35,6 +38,7 @@ export function createMachineRuns({
|
|
|
35
38
|
callHome,
|
|
36
39
|
taskRuns,
|
|
37
40
|
agents,
|
|
41
|
+
// Folders this computer's own agents' sessions or T3 Code worked in, which count wherever they are.
|
|
38
42
|
knownFolders = () => [],
|
|
39
43
|
// The files of a thread, by id, as this computer's copy of the board has them: a folder-less thread's turn gets them
|
|
40
44
|
// in its scratch folder.
|
|
@@ -68,17 +72,35 @@ export function createMachineRuns({
|
|
|
68
72
|
clearTimeout(steps.get(taskId)?.timer);
|
|
69
73
|
steps.delete(taskId);
|
|
70
74
|
};
|
|
75
|
+
const home = real(os.homedir());
|
|
76
|
+
// An existing folder of this computer's below its home; home itself and above it never are.
|
|
77
|
+
const belowHome = (dir) => {
|
|
78
|
+
const folder = real(dir);
|
|
79
|
+
return Boolean(folder && home && folder !== home && within(folder, home));
|
|
80
|
+
};
|
|
71
81
|
// A thread with no folder: its turn here works in that thread's scratch folder on this computer (scratch.mjs), as
|
|
72
|
-
// does a task naming no folder that home says goes there (taskCommands.mjs forWorker)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
82
|
+
// does a task naming no folder that home says goes there (taskCommands.mjs forWorker), and a thread's turn naming
|
|
83
|
+
// home or above it, or this computer's scratch path for it (a ComfyUI picture asked for in /home/saltorious once
|
|
84
|
+
// failed to start).
|
|
85
|
+
const inScratch = (task) => {
|
|
86
|
+
if (!task.parent_id) return false;
|
|
87
|
+
if (!task.run_workspace)
|
|
88
|
+
return (
|
|
89
|
+
task.kind === "wake" || (task.kind === "task" && task.scratch === true)
|
|
90
|
+
);
|
|
91
|
+
const named = path.resolve(task.run_workspace);
|
|
92
|
+
const folder = real(named);
|
|
93
|
+
return (
|
|
94
|
+
named === threadScratch(task.parent_id) ||
|
|
95
|
+
Boolean(folder && home && within(home, folder))
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
// One turn per agent per folder, other agents side by side (runWorker.mjs slotOf).
|
|
77
99
|
const slotOf = (task) =>
|
|
78
|
-
task
|
|
79
|
-
?
|
|
80
|
-
:
|
|
81
|
-
?
|
|
100
|
+
inScratch(task)
|
|
101
|
+
? `${threadScratch(task.parent_id)}:${task.target_agent}`
|
|
102
|
+
: task.run_workspace
|
|
103
|
+
? `${path.resolve(task.run_workspace)}:${task.target_agent}`
|
|
82
104
|
: task.target_agent;
|
|
83
105
|
// The thread's files, from home, put in the scratch folder; one home cannot send is left out.
|
|
84
106
|
const scratchFor = async (task) => {
|
|
@@ -197,15 +219,13 @@ export function createMachineRuns({
|
|
|
197
219
|
path.isAbsolute(task.run_workspace)
|
|
198
220
|
? real(task.run_workspace)
|
|
199
221
|
: null;
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
return null;
|
|
208
|
-
return `This computer runs work from your home computer only in a folder its own agents have worked in, and ${task.run_workspace || "no folder"} is not one. Start it there in one of this computer's folders.`;
|
|
222
|
+
const known = (dir) =>
|
|
223
|
+
knownFolders().some((place) => {
|
|
224
|
+
const root = real(place);
|
|
225
|
+
return root && within(dir, root);
|
|
226
|
+
});
|
|
227
|
+
if (folder && (belowHome(folder) || known(folder))) return null;
|
|
228
|
+
return `${task.run_workspace || "No folder"} is not a folder on this computer below your home or one its agents worked in, so it could not start here.`;
|
|
209
229
|
};
|
|
210
230
|
// Taken in its agent's name and ended at once with the reason, so home's board shows why it did not run here.
|
|
211
231
|
const refuse = async (task, reason) => {
|
package/lib/manager.mjs
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { askLocalAgent } from "./localAgentAsk.mjs";
|
|
3
|
+
import { nameOf } from "./members.mjs";
|
|
4
|
+
|
|
5
|
+
// The swarm's manager (owner, November 1): it keeps the agents to what the person actually asked. Each of the person's
|
|
6
|
+
// messages is sorted by Jev (src/server/swarm/manager.ts): new work and questions become asks, a steer changes the ask
|
|
7
|
+
// it is about, exploring an idea, chatting or answering tracks nothing. When an agent reports, every open ask is
|
|
8
|
+
// judged against the person's own words: done needs something in the thread that shows it; a taste call waits for the
|
|
9
|
+
// person's review; work ignored or contradicted goes back to that agent once with the person's words whole, then waits
|
|
10
|
+
// on the person. The thread cannot close while an ask is open. The thread hears one short line when an ask changes.
|
|
11
|
+
|
|
12
|
+
const OPEN = new Set(["open", "sent_back", "waiting"]);
|
|
13
|
+
const MAX_ASKS = 12;
|
|
14
|
+
const BEFORE = 12;
|
|
15
|
+
// Below the floor a message is not new work; just under it, an idea is said to be taken as one, so nothing is tracked
|
|
16
|
+
// that the person did not ask for, and they can say "do it".
|
|
17
|
+
const FLOOR = 0.5;
|
|
18
|
+
const MAYBE = 0.3;
|
|
19
|
+
|
|
20
|
+
const label = (ask) => {
|
|
21
|
+
const first = ask.words[0];
|
|
22
|
+
const said = first.text.replace(/\s+/g, " ").trim();
|
|
23
|
+
return `"${said.length > 60 ? `${said.slice(0, 57)}...` : said}" (#${first.seq})`;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const LOCAL_PROMPT = {
|
|
27
|
+
message: `You keep a person's swarm of agents to what the person asked. The JSON below has the person's newest message (person_message), the posts before it, and the person's open asks. Answer with one JSON object only: {"new_work": 0 to 1, how sure you are it asks the agents for new work or a result not already in open_asks, "question": 0 to 1, that it asks the agents a question wanting an answer, "exploring": 0 to 1, that the person is exploring an idea or talking through the agents' reasoning without asking for it to be done, "answer": 0 to 1, that it answers a question or approves a choice put to the person, "steers": the index in open_asks that it changes, corrects or narrows, or null, "withdraws": 0 to 1, that it drops that ask}.`,
|
|
28
|
+
report: `You keep a person's swarm of agents to what the person asked. The JSON below has an agent's report, the posts before it, and the person's open asks, each with the person's own words (newest word wins). Answer with one JSON object only: {"asks": [{"index": the ask's index, "state": "done" | "in_progress" | "ignored" | "contradicted" (ignored: reported finished without doing it or only part; contradicted: did something different, or claims something the thread does not show), "shown": 0 to 1, that something other than an agent saying so shows it done (a file, commit, command run with output, link, the result itself), "taste": 0 to 1, that only the person's own judgment can settle it}]}. For an ask of kind question, "done" means it was answered.`,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export function createManager({
|
|
32
|
+
store,
|
|
33
|
+
askHarness,
|
|
34
|
+
// Whether this computer's rounds go to Harness's server, and whether that server judges for the manager.
|
|
35
|
+
usesServer,
|
|
36
|
+
// The coding agent here that judges on the privacy setting, or null.
|
|
37
|
+
localJudge = () => null,
|
|
38
|
+
// Wake an agent with work, as the coordinator does (its brief is posted in the thread first).
|
|
39
|
+
handOn,
|
|
40
|
+
post,
|
|
41
|
+
notifyBoard,
|
|
42
|
+
log = () => {},
|
|
43
|
+
ask = askLocalAgent,
|
|
44
|
+
}) {
|
|
45
|
+
const key = (threadId) => `owner-asks:${threadId}`;
|
|
46
|
+
const asksOf = (threadId) => {
|
|
47
|
+
try {
|
|
48
|
+
return JSON.parse(store.meta(key(threadId)) || "[]");
|
|
49
|
+
} catch {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const keep = (threadId, asks) =>
|
|
54
|
+
store.meta(key(threadId), JSON.stringify(asks));
|
|
55
|
+
const openOf = (threadId) =>
|
|
56
|
+
asksOf(threadId).filter((one) => OPEN.has(one.status));
|
|
57
|
+
|
|
58
|
+
// One judgment at a time per thread, in the order posts came.
|
|
59
|
+
const chains = new Map();
|
|
60
|
+
const queue = (threadId, work) => {
|
|
61
|
+
const next = (chains.get(threadId) ?? Promise.resolve())
|
|
62
|
+
.then(work)
|
|
63
|
+
.catch((error) => log(`manager ${threadId}: ${error.message}`));
|
|
64
|
+
chains.set(threadId, next);
|
|
65
|
+
return next;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const before = (threadId, seq) =>
|
|
69
|
+
store
|
|
70
|
+
.roomPosts(threadId, 0, 500)
|
|
71
|
+
.filter(
|
|
72
|
+
(each) =>
|
|
73
|
+
each.seq < seq &&
|
|
74
|
+
!["note", "round", "goal_update", "held"].includes(each.kind)
|
|
75
|
+
)
|
|
76
|
+
.slice(-BEFORE)
|
|
77
|
+
.map(({ seq, author, kind, text }) => ({ seq, author, kind, text }));
|
|
78
|
+
|
|
79
|
+
const inputFor = (thread, kind, entry, asks) => ({
|
|
80
|
+
thread: { id: thread.id, title: thread.objective },
|
|
81
|
+
kind,
|
|
82
|
+
post: {
|
|
83
|
+
seq: entry.seq,
|
|
84
|
+
author: entry.author,
|
|
85
|
+
kind: entry.kind,
|
|
86
|
+
text: entry.text,
|
|
87
|
+
},
|
|
88
|
+
asks: asks.map(({ id, kind: what, words }) => ({ id, kind: what, words })),
|
|
89
|
+
transcript: before(thread.id, entry.seq),
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Jev on Harness's server; on the privacy setting, a coding agent here with its tools off.
|
|
93
|
+
const judge = async (input) => {
|
|
94
|
+
if (usesServer()) {
|
|
95
|
+
const reply = await askHarness("manage", input, null);
|
|
96
|
+
if (!reply?.ok)
|
|
97
|
+
throw new Error(reply?.error || "the manager did not judge");
|
|
98
|
+
return reply.result ?? reply;
|
|
99
|
+
}
|
|
100
|
+
const agent = localJudge();
|
|
101
|
+
if (!agent) return null;
|
|
102
|
+
const said = await ask(
|
|
103
|
+
agent,
|
|
104
|
+
`${LOCAL_PROMPT[input.kind]}\n\n${JSON.stringify(input)}`
|
|
105
|
+
);
|
|
106
|
+
return input.kind === "message"
|
|
107
|
+
? {
|
|
108
|
+
kind: "message",
|
|
109
|
+
message: {
|
|
110
|
+
newWork: Number(said?.new_work) || 0,
|
|
111
|
+
question: Number(said?.question) || 0,
|
|
112
|
+
exploring: Number(said?.exploring) || 0,
|
|
113
|
+
answer: Number(said?.answer) || 0,
|
|
114
|
+
steers: input.asks[said?.steers]?.id ?? null,
|
|
115
|
+
withdraws: Number(said?.withdraws) || 0,
|
|
116
|
+
},
|
|
117
|
+
}
|
|
118
|
+
: {
|
|
119
|
+
kind: "report",
|
|
120
|
+
findings: (Array.isArray(said?.asks) ? said.asks : [])
|
|
121
|
+
.filter((one) => input.asks[one?.index])
|
|
122
|
+
.map((one) => ({
|
|
123
|
+
id: input.asks[one.index].id,
|
|
124
|
+
state: one.state,
|
|
125
|
+
shown: Number(one.shown) || 0,
|
|
126
|
+
taste: Number(one.taste) || 0,
|
|
127
|
+
})),
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const say = (thread, lines) => {
|
|
132
|
+
if (!lines.length) return;
|
|
133
|
+
post({
|
|
134
|
+
goalId: thread.id,
|
|
135
|
+
author: thread.goal.facilitator,
|
|
136
|
+
kind: "note",
|
|
137
|
+
text: lines.join("\n"),
|
|
138
|
+
});
|
|
139
|
+
notifyBoard(store.getTask(thread.id));
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* One of the person's messages in a thread, or the person's words an agent relayed from its own session (`relayed`):
|
|
144
|
+
* sorted, and kept as an ask when it is work or a question.
|
|
145
|
+
*/
|
|
146
|
+
const heard = (thread, entry) =>
|
|
147
|
+
queue(thread.id, async () => {
|
|
148
|
+
const asks = openOf(thread.id).slice(-MAX_ASKS);
|
|
149
|
+
const judged = await judge(inputFor(thread, "message", entry, asks));
|
|
150
|
+
const kind = judged?.message;
|
|
151
|
+
if (!kind) return;
|
|
152
|
+
const all = asksOf(thread.id);
|
|
153
|
+
const words = { seq: entry.seq, text: entry.text };
|
|
154
|
+
const steered = all.find((one) => one.id === kind.steers);
|
|
155
|
+
const lines = [];
|
|
156
|
+
if (steered && kind.withdraws >= FLOOR) {
|
|
157
|
+
steered.status = "dropped";
|
|
158
|
+
lines.push(`Dropped: ${label(steered)}`);
|
|
159
|
+
} else if (steered) {
|
|
160
|
+
// The newest word wins where they differ; the ask is open again for whoever works on it.
|
|
161
|
+
steered.words.push(words);
|
|
162
|
+
steered.status = "open";
|
|
163
|
+
steered.tries = 0;
|
|
164
|
+
} else if (kind.newWork >= FLOOR || kind.question >= FLOOR) {
|
|
165
|
+
all.push({
|
|
166
|
+
id: randomUUID(),
|
|
167
|
+
kind: kind.newWork >= kind.question ? "work" : "question",
|
|
168
|
+
words: [words],
|
|
169
|
+
status: "open",
|
|
170
|
+
tries: 0,
|
|
171
|
+
at: new Date().toISOString(),
|
|
172
|
+
});
|
|
173
|
+
} else if (kind.newWork >= MAYBE && kind.exploring >= FLOOR)
|
|
174
|
+
lines.push(
|
|
175
|
+
`Taken as an idea, not as work (#${entry.seq}). Say "do it" to have it done.`
|
|
176
|
+
);
|
|
177
|
+
keep(thread.id, all);
|
|
178
|
+
say(thread, lines);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
/** An agent reported doing something in the thread: where each of the person's open asks stands now. */
|
|
182
|
+
const reported = (thread, entry) =>
|
|
183
|
+
queue(thread.id, async () => {
|
|
184
|
+
const asks = openOf(thread.id).slice(-MAX_ASKS);
|
|
185
|
+
if (!asks.length) return;
|
|
186
|
+
const judged = await judge(inputFor(thread, "report", entry, asks));
|
|
187
|
+
const findings = judged?.findings ?? [];
|
|
188
|
+
const all = asksOf(thread.id);
|
|
189
|
+
const lines = [];
|
|
190
|
+
for (const found of findings) {
|
|
191
|
+
const one = all.find((each) => each.id === found.id);
|
|
192
|
+
if (!one || !OPEN.has(one.status) || found.state === "in_progress")
|
|
193
|
+
continue;
|
|
194
|
+
if (found.state === "done" && found.taste >= FLOOR) {
|
|
195
|
+
one.status = "review";
|
|
196
|
+
lines.push(`Ready for your review: ${label(one)}`);
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
if (found.state === "done" && found.shown >= FLOOR) {
|
|
200
|
+
one.status = "done";
|
|
201
|
+
one.evidence = entry.seq;
|
|
202
|
+
lines.push(`Done: ${label(one)}, shown in #${entry.seq}`);
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
// Ignored, contradicted, or said done with nothing that shows it.
|
|
206
|
+
const why =
|
|
207
|
+
found.state === "done"
|
|
208
|
+
? "says it is done, but nothing in the thread shows it"
|
|
209
|
+
: found.state === "ignored"
|
|
210
|
+
? "does not do it, or does only part of it"
|
|
211
|
+
: "does something different from what the person asked, or claims something the thread does not show";
|
|
212
|
+
if ((one.tries ?? 0) >= 1) {
|
|
213
|
+
one.status = "waiting";
|
|
214
|
+
lines.push(
|
|
215
|
+
`Waiting on you: ${nameOf(entry.author)} still has not done ${label(one)}`
|
|
216
|
+
);
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
one.tries = (one.tries ?? 0) + 1;
|
|
220
|
+
one.status = "sent_back";
|
|
221
|
+
sendBack(thread, entry, one, why);
|
|
222
|
+
lines.push(`Sent back to ${nameOf(entry.author)}: ${label(one)}`);
|
|
223
|
+
}
|
|
224
|
+
keep(thread.id, all);
|
|
225
|
+
say(thread, lines);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
// The person's words go back whole, every one of them for this ask, oldest first.
|
|
229
|
+
const sendBack = (thread, entry, one, why) => {
|
|
230
|
+
const agent = entry.author;
|
|
231
|
+
const text = [
|
|
232
|
+
`@${agent} Your report (#${entry.seq}) ${why}. The person's words for it:`,
|
|
233
|
+
...one.words.map((said) => `#${said.seq}: ${said.text}`),
|
|
234
|
+
"Do it as they asked, and show it done in the thread: the file, the commit, or the command you ran and its output.",
|
|
235
|
+
].join("\n\n");
|
|
236
|
+
post({
|
|
237
|
+
goalId: thread.id,
|
|
238
|
+
author: thread.goal.facilitator,
|
|
239
|
+
kind: "post",
|
|
240
|
+
text,
|
|
241
|
+
});
|
|
242
|
+
handOn(
|
|
243
|
+
thread.id,
|
|
244
|
+
agent,
|
|
245
|
+
`the swarm's manager sent your work back: your report #${entry.seq} ${why}`,
|
|
246
|
+
{ words: text }
|
|
247
|
+
);
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
/** The person's open asks in a thread: what keeps it from closing, each as its short label. */
|
|
251
|
+
const open = (threadId) => openOf(threadId).map(label);
|
|
252
|
+
|
|
253
|
+
return { heard, reported, open, asks: asksOf };
|
|
254
|
+
}
|
package/lib/mcp-stdio.mjs
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import fs from "node:fs";
|
|
3
|
-
import {
|
|
4
|
-
DISPATCH_WORK_TOOL,
|
|
5
|
-
SCOPE_WORKSPACE_TOOL,
|
|
6
|
-
dispatchWorkRequest,
|
|
7
|
-
} from "./dispatchTools.js";
|
|
3
|
+
import { DISPATCH_WORK_TOOL, dispatchWorkRequest } from "./dispatchTools.js";
|
|
8
4
|
import { CONNECTION_TOOL, connectionRequest } from "./connectionTools.js";
|
|
9
5
|
import { USE_SECRET_TOOL, secretToolRequest } from "./vaultTools.js";
|
|
10
6
|
import { paths } from "./paths.mjs";
|
|
@@ -36,15 +32,12 @@ if (process.argv.includes("--check-host") && startedByAnother(agent)) {
|
|
|
36
32
|
// (`tryharness connections on`), and never to a restricted run: work another agent or another person's swarm asked
|
|
37
33
|
// for runs without the person's apps (runner.mjs restrictedMcpConfig).
|
|
38
34
|
const restricted = process.argv.includes("--restricted");
|
|
39
|
-
const scopeIndex = process.argv.indexOf("--scope");
|
|
40
|
-
const dispatchScope = scopeIndex >= 0 ? process.argv[scopeIndex + 1] : null;
|
|
41
35
|
const appsOn = !restricted && readJson(paths.config, {}).connectedApps === true;
|
|
42
36
|
let input = "";
|
|
43
37
|
let chain = Promise.resolve();
|
|
44
38
|
|
|
45
39
|
const LOCAL_TOOLS = [
|
|
46
40
|
DISPATCH_WORK_TOOL,
|
|
47
|
-
...(dispatchScope ? [SCOPE_WORKSPACE_TOOL] : []),
|
|
48
41
|
ARCHETYPE_TOOL,
|
|
49
42
|
...(appsOn ? [CONNECTION_TOOL] : []),
|
|
50
43
|
{
|
|
@@ -149,6 +142,11 @@ const LOCAL_TOOLS = [
|
|
|
149
142
|
additionalProperties: false,
|
|
150
143
|
},
|
|
151
144
|
},
|
|
145
|
+
card: {
|
|
146
|
+
type: "string",
|
|
147
|
+
description:
|
|
148
|
+
"with parent_id set to a thread: the id of the card on the thread's board this task is for (update_board gives it). Its claim moves the card to In progress, or to Review for a check, and its end moves it on",
|
|
149
|
+
},
|
|
152
150
|
after: {
|
|
153
151
|
type: "array",
|
|
154
152
|
items: { type: "string" },
|
|
@@ -181,6 +179,39 @@ const LOCAL_TOOLS = [
|
|
|
181
179
|
additionalProperties: false,
|
|
182
180
|
},
|
|
183
181
|
},
|
|
182
|
+
{
|
|
183
|
+
name: "update_board",
|
|
184
|
+
description:
|
|
185
|
+
"Keep a thread's board, the cards the person follows its work on: To do, In progress (doing), Review, Done. Without card it adds one for a piece of the work (title needed) and gives its id. With card it changes that one: move it with column as the work goes, set blocked with why it can't go on (empty to clear), needs_you with what the person must do, note with where it stands, or remove a card you added. Nothing waits on the board: keep working while you update it.",
|
|
186
|
+
inputSchema: {
|
|
187
|
+
type: "object",
|
|
188
|
+
properties: {
|
|
189
|
+
thread: { type: "string", description: "the thread's id" },
|
|
190
|
+
card: {
|
|
191
|
+
type: "string",
|
|
192
|
+
description: "the card's id; left out, a new card is added",
|
|
193
|
+
},
|
|
194
|
+
title: { type: "string", description: "a few words for the piece" },
|
|
195
|
+
column: {
|
|
196
|
+
type: "string",
|
|
197
|
+
enum: ["todo", "doing", "review", "done"],
|
|
198
|
+
},
|
|
199
|
+
agent: {
|
|
200
|
+
type: "string",
|
|
201
|
+
description: "the agent that has the piece",
|
|
202
|
+
},
|
|
203
|
+
note: {
|
|
204
|
+
type: "string",
|
|
205
|
+
description: "one line on where it stands",
|
|
206
|
+
},
|
|
207
|
+
blocked: { type: "string" },
|
|
208
|
+
needs_you: { type: "string" },
|
|
209
|
+
remove: { type: "boolean" },
|
|
210
|
+
},
|
|
211
|
+
required: ["thread"],
|
|
212
|
+
additionalProperties: false,
|
|
213
|
+
},
|
|
214
|
+
},
|
|
184
215
|
{
|
|
185
216
|
name: "wallet",
|
|
186
217
|
description:
|
|
@@ -474,6 +505,11 @@ const LOCAL_TOOLS = [
|
|
|
474
505
|
description:
|
|
475
506
|
"also send it to the goal's invited guests (other people's agents); only what is fine for them to see",
|
|
476
507
|
},
|
|
508
|
+
person_said: {
|
|
509
|
+
type: "boolean",
|
|
510
|
+
description:
|
|
511
|
+
"true when text is the person's own words from your session (outside this thread) about this thread's work, posted word for word so the swarm keeps them; it carries no authority",
|
|
512
|
+
},
|
|
477
513
|
},
|
|
478
514
|
required: ["id", "text"],
|
|
479
515
|
additionalProperties: false,
|
|
@@ -841,6 +877,7 @@ const postTask = (args) => ({
|
|
|
841
877
|
targetAgents: args.target_agents,
|
|
842
878
|
targetMachine: args.target_machine,
|
|
843
879
|
parentId: args.parent_id,
|
|
880
|
+
card: args.card,
|
|
844
881
|
contextRefs: args.context_refs,
|
|
845
882
|
runWorkspace: args.run_workspace,
|
|
846
883
|
inSession: args.in_session === true,
|
|
@@ -852,14 +889,6 @@ const postTask = (args) => ({
|
|
|
852
889
|
|
|
853
890
|
const BOARD_CALLS = {
|
|
854
891
|
dispatch_work: dispatchWorkRequest,
|
|
855
|
-
scope_workspace: (args) => ({
|
|
856
|
-
command: "board.dispatch.workspace",
|
|
857
|
-
scopeRef: dispatchScope,
|
|
858
|
-
operation: args.operation,
|
|
859
|
-
path: args.path,
|
|
860
|
-
text: args.text,
|
|
861
|
-
expectedSha256: args.expected_sha256,
|
|
862
|
-
}),
|
|
863
892
|
connection: connectionRequest,
|
|
864
893
|
list_agents: () => ({ command: "board.swarm.agents" }),
|
|
865
894
|
list_models: (args) => ({
|
|
@@ -889,6 +918,7 @@ const BOARD_CALLS = {
|
|
|
889
918
|
text: args.text,
|
|
890
919
|
ask: Array.isArray(args.ask) ? args.ask : [],
|
|
891
920
|
shareWithGuests: args.share_with_guests === true,
|
|
921
|
+
personSaid: args.person_said === true,
|
|
892
922
|
targetMachine: args.target_machine,
|
|
893
923
|
}),
|
|
894
924
|
plan_work: (args) =>
|
|
@@ -1087,6 +1117,18 @@ const BOARD_CALLS = {
|
|
|
1087
1117
|
],
|
|
1088
1118
|
}
|
|
1089
1119
|
: postTask(args),
|
|
1120
|
+
update_board: (args) => ({
|
|
1121
|
+
command: "board.kanban.update",
|
|
1122
|
+
id: String(args.thread || ""),
|
|
1123
|
+
card: args.card,
|
|
1124
|
+
title: args.title,
|
|
1125
|
+
column: args.column,
|
|
1126
|
+
agent: args.agent,
|
|
1127
|
+
note: args.note,
|
|
1128
|
+
blocked: args.blocked,
|
|
1129
|
+
needs_you: args.needs_you,
|
|
1130
|
+
remove: args.remove === true,
|
|
1131
|
+
}),
|
|
1090
1132
|
use_template: (args) =>
|
|
1091
1133
|
args.name && args.parent_id
|
|
1092
1134
|
? {
|
|
@@ -1408,29 +1450,6 @@ async function relay(line) {
|
|
|
1408
1450
|
return;
|
|
1409
1451
|
}
|
|
1410
1452
|
|
|
1411
|
-
if (dispatchScope) {
|
|
1412
|
-
const names = new Set(["dispatch_work", "scope_workspace"]);
|
|
1413
|
-
if (request.method === "initialize") write(localInitialize(request));
|
|
1414
|
-
else if (request.method === "tools/list")
|
|
1415
|
-
write({
|
|
1416
|
-
jsonrpc: "2.0",
|
|
1417
|
-
id: request.id,
|
|
1418
|
-
result: { tools: LOCAL_TOOLS.filter((tool) => names.has(tool.name)) },
|
|
1419
|
-
});
|
|
1420
|
-
else if (request.method === "tools/call" && names.has(request.params?.name))
|
|
1421
|
-
write(await localCall(request));
|
|
1422
|
-
else if (request.id !== undefined)
|
|
1423
|
-
write({
|
|
1424
|
-
jsonrpc: "2.0",
|
|
1425
|
-
id: request.id,
|
|
1426
|
-
error: {
|
|
1427
|
-
code: -32601,
|
|
1428
|
-
message: "This scope exposes only dispatch and workspace-file tools.",
|
|
1429
|
-
},
|
|
1430
|
-
});
|
|
1431
|
-
return;
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
1453
|
if (
|
|
1435
1454
|
request.method === "tools/call" &&
|
|
1436
1455
|
LOCAL_TOOLS.some((tool) => tool.name === request.params?.name)
|