tryharness 0.7.43 → 0.7.45
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/lib/boardProtocol.json +55 -2
- package/lib/bridge.mjs +2 -0
- package/lib/coordinator.mjs +8 -1
- package/lib/daemon.mjs +145 -8
- package/lib/goalCommands.mjs +6 -1
- package/lib/mcp-stdio.mjs +79 -0
- package/lib/network.mjs +33 -1
- package/lib/projectGit.mjs +328 -0
- package/lib/projectSettings.mjs +120 -0
- package/lib/projects.mjs +2052 -0
- package/lib/store.mjs +13 -1
- package/lib/swarm.mjs +12 -1
- package/lib/taskCommands.mjs +2 -0
- package/lib/threadRuns.mjs +53 -8
- package/lib/threadView.mjs +18 -2
- package/package.json +1 -1
package/lib/store.mjs
CHANGED
|
@@ -461,6 +461,8 @@ export function openStore(file) {
|
|
|
461
461
|
return { ok: false, error: describe(task), conflict: true, task };
|
|
462
462
|
};
|
|
463
463
|
|
|
464
|
+
const roomPostListeners = [];
|
|
465
|
+
|
|
464
466
|
return {
|
|
465
467
|
db,
|
|
466
468
|
needsIndex(agent, sessionId, mtime, size) {
|
|
@@ -1071,7 +1073,17 @@ export function openStore(file) {
|
|
|
1071
1073
|
JSON.stringify(mentions),
|
|
1072
1074
|
post.id
|
|
1073
1075
|
);
|
|
1074
|
-
|
|
1076
|
+
const made = post ? { ...post, mentions } : null;
|
|
1077
|
+
// Whoever follows a room's posts (a shared project carries them to the other side) hears each one as it is made.
|
|
1078
|
+
if (made)
|
|
1079
|
+
for (const listener of roomPostListeners)
|
|
1080
|
+
try {
|
|
1081
|
+
listener(goalId, made);
|
|
1082
|
+
} catch {}
|
|
1083
|
+
return made;
|
|
1084
|
+
},
|
|
1085
|
+
onRoomPost(listener) {
|
|
1086
|
+
roomPostListeners.push(listener);
|
|
1075
1087
|
},
|
|
1076
1088
|
roomPosts(goalId, since = 0, limit = 200) {
|
|
1077
1089
|
return execute(
|
package/lib/swarm.mjs
CHANGED
|
@@ -118,6 +118,10 @@ export function createSwarm({
|
|
|
118
118
|
plansOf = () => [],
|
|
119
119
|
// The thread as the person reads it on every surface (threadView.mjs).
|
|
120
120
|
threadView = null,
|
|
121
|
+
// The project a thread is the room of, shared with another person's swarm (projects.mjs).
|
|
122
|
+
projectOf = () => null,
|
|
123
|
+
// The person's words name an agent of the other side of a shared project: theirs to answer, not this swarm's to sort.
|
|
124
|
+
addressesPartner = () => false,
|
|
121
125
|
}) {
|
|
122
126
|
// What the person let a thread spend of their Harness credits, in dollars, or null for no limit of its own.
|
|
123
127
|
const ceilingOf = (threadId) => {
|
|
@@ -297,6 +301,8 @@ export function createSwarm({
|
|
|
297
301
|
checkIns: schedules?.list({ threadId: thread.id }) ?? [],
|
|
298
302
|
ceilingUsd: ceilingOf(thread.id),
|
|
299
303
|
changes: worktrees.summary(thread.id),
|
|
304
|
+
// A project shared with another person's swarm (projects.mjs): which, and with whom.
|
|
305
|
+
project: projectOf(thread.id),
|
|
300
306
|
};
|
|
301
307
|
};
|
|
302
308
|
|
|
@@ -466,7 +472,12 @@ export function createSwarm({
|
|
|
466
472
|
},
|
|
467
473
|
"user"
|
|
468
474
|
);
|
|
469
|
-
if (
|
|
475
|
+
if (
|
|
476
|
+
!to &&
|
|
477
|
+
posted?.ok &&
|
|
478
|
+
!posted.paused &&
|
|
479
|
+
!addressesPartner(thread.id, text)
|
|
480
|
+
)
|
|
470
481
|
heardBy(current, posted.post, text);
|
|
471
482
|
return posted;
|
|
472
483
|
};
|
package/lib/taskCommands.mjs
CHANGED
|
@@ -46,6 +46,7 @@ export function createTaskCommands({
|
|
|
46
46
|
lessons,
|
|
47
47
|
madeIn,
|
|
48
48
|
getNetwork,
|
|
49
|
+
getProjects = () => null,
|
|
49
50
|
notifyBoard,
|
|
50
51
|
openTaskRoom,
|
|
51
52
|
openThreadPost,
|
|
@@ -489,6 +490,7 @@ export function createTaskCommands({
|
|
|
489
490
|
thread[OPENED] && thread.peerKey ? String(thread.peerKey) : null,
|
|
490
491
|
});
|
|
491
492
|
getNetwork()?.opened(task.id);
|
|
493
|
+
getProjects()?.channelOpened(task.id);
|
|
492
494
|
}
|
|
493
495
|
if (pick) setRunPick(store, task.id, pick, agent);
|
|
494
496
|
// A job in a goal's room runs on the goal's authority; anywhere else, standing permission decides. The goal covers
|
package/lib/threadRuns.mjs
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
|
-
import { nameOf } from "./members.mjs";
|
|
4
|
+
import { MEMBERS, nameOf } from "./members.mjs";
|
|
5
5
|
import { oneLine } from "./oneLine.mjs";
|
|
6
6
|
import { setRunPick } from "./models.mjs";
|
|
7
7
|
import { t3Access, startT3SignIn, steerT3Run } from "./t3.mjs";
|
|
8
8
|
import { t3Model, t3Open, t3Project, t3Provider } from "./places.mjs";
|
|
9
9
|
|
|
10
|
+
// The agents with a read-only switch (runner.mjs): only they talk out a clash in a shared project without waiting.
|
|
11
|
+
const REVIEWERS = new Set(
|
|
12
|
+
MEMBERS.filter((entry) => entry.review).map((entry) => entry.id)
|
|
13
|
+
);
|
|
14
|
+
|
|
10
15
|
/** Thread execution owns queued calls, fresh briefs, worktree settlement and T3 continuity. */
|
|
11
16
|
export function createThreadRuns({
|
|
12
17
|
store,
|
|
@@ -24,6 +29,8 @@ export function createThreadRuns({
|
|
|
24
29
|
// A coding agent not installed here but on another of the person's computers that has the thread's repository:
|
|
25
30
|
// { machine, folder } there (ownMachines.mjs), or null.
|
|
26
31
|
placeElsewhere = () => null,
|
|
32
|
+
// Projects shared with another person's swarm (projects.mjs): their check before work, and each agent's own branch.
|
|
33
|
+
projects = () => null,
|
|
27
34
|
}) {
|
|
28
35
|
const { RUNNERS } = authority;
|
|
29
36
|
const inT3 = (thread, agent, review) => {
|
|
@@ -213,7 +220,8 @@ export function createThreadRuns({
|
|
|
213
220
|
const startHeldWake = (goalId, agent) => {
|
|
214
221
|
const wake = store.getTask(store.openWake(goalId, agent));
|
|
215
222
|
if (wake?.status !== "open" || wake.run_authorized_at) return;
|
|
216
|
-
|
|
223
|
+
const answer = Boolean(pendingWakes.get(`${goalId}:${agent}`)?.answer);
|
|
224
|
+
if (!threadMayRun(store.getTask(goalId), { answer })) return;
|
|
217
225
|
store.meta(`person-wake:${wake.id}`, "1");
|
|
218
226
|
if (store.authorizeGoalRun(wake.id)) notifyBoard(store.getTask(wake.id));
|
|
219
227
|
};
|
|
@@ -229,6 +237,11 @@ export function createThreadRuns({
|
|
|
229
237
|
words = null,
|
|
230
238
|
recovering = false,
|
|
231
239
|
held = null,
|
|
240
|
+
// The asker's turn on its own task's answer (daemon.mjs threadMayRun).
|
|
241
|
+
answer = false,
|
|
242
|
+
// Past a shared project's check before work (projects.mjs gate); `wait` holds the run for the person's Start.
|
|
243
|
+
checked = false,
|
|
244
|
+
wait = false,
|
|
232
245
|
} = {}
|
|
233
246
|
) => {
|
|
234
247
|
const task = store.getTask(goalId);
|
|
@@ -270,6 +283,7 @@ export function createThreadRuns({
|
|
|
270
283
|
go: asker === "user" ? go : !flagged && (go || Boolean(prior?.go)),
|
|
271
284
|
held: flagged,
|
|
272
285
|
pick: pick ?? prior?.pick ?? null,
|
|
286
|
+
answer: answer || Boolean(prior?.answer),
|
|
273
287
|
at: new Date().toISOString(),
|
|
274
288
|
};
|
|
275
289
|
pendingWakes.set(`${goalId}:${agent}`, pending);
|
|
@@ -285,10 +299,33 @@ export function createThreadRuns({
|
|
|
285
299
|
pauseGoal(goalId, `${agent} was woken ${goal.max_wakes} times`);
|
|
286
300
|
return;
|
|
287
301
|
}
|
|
302
|
+
// In a shared project, new work is checked against both sides' work and decisions first; a clash holds it, and the
|
|
303
|
+
// agent only talks it out (read-only) until a person OKs the fix.
|
|
304
|
+
const shared = projects()?.isProjectRoom(goalId) ? projects() : null;
|
|
305
|
+
if (shared && !checked && !recovering)
|
|
306
|
+
return (
|
|
307
|
+
shared.gate(
|
|
308
|
+
{ task, agent, reason, asker, go, mode: null, words },
|
|
309
|
+
(mode, override = null) =>
|
|
310
|
+
wakeAgent(goalId, agent, override ?? reason, {
|
|
311
|
+
review: review || (mode === "review" && REVIEWERS.has(agent)),
|
|
312
|
+
go: mode === "review" ? REVIEWERS.has(agent) : go,
|
|
313
|
+
wait:
|
|
314
|
+
mode === "wait" || (mode === "review" && !REVIEWERS.has(agent)),
|
|
315
|
+
asker,
|
|
316
|
+
pick,
|
|
317
|
+
words,
|
|
318
|
+
held,
|
|
319
|
+
answer,
|
|
320
|
+
checked: true,
|
|
321
|
+
})
|
|
322
|
+
) ?? "checking"
|
|
323
|
+
);
|
|
288
324
|
const brief = swarmBrief(task, agent, reason, { review });
|
|
289
325
|
// A coding thread in a repository works in its own worktree, so threads never share a checkout; one whose agents the
|
|
290
|
-
// person uses in T3 Code works in T3 (inT3), where T3 makes and keeps the checkout.
|
|
291
|
-
|
|
326
|
+
// person uses in T3 Code works in T3 (inT3), where T3 makes and keeps the checkout. In a shared project each agent
|
|
327
|
+
// works on its own branch here, never in T3's checkout.
|
|
328
|
+
const t3 = !elsewhere && !shared && inT3(task, agent, review);
|
|
292
329
|
// The person uses this agent in T3 Code but this turn runs here: the thread says why, once for each reason.
|
|
293
330
|
const gap = t3 || review || elsewhere ? null : t3Gap(agent, goal.workspace);
|
|
294
331
|
if (gap && !store.meta(`t3-gap-note:${goalId}:${agent}:${gap}`)) {
|
|
@@ -303,7 +340,9 @@ export function createThreadRuns({
|
|
|
303
340
|
let folder = elsewhere?.folder ?? goal.workspace;
|
|
304
341
|
if (!t3 && !elsewhere)
|
|
305
342
|
try {
|
|
306
|
-
folder =
|
|
343
|
+
folder =
|
|
344
|
+
(shared && !review ? shared.folderFor(task, agent) : null) ??
|
|
345
|
+
worktrees.folderFor(task);
|
|
307
346
|
} catch (error) {
|
|
308
347
|
store.roomPost({
|
|
309
348
|
goalId,
|
|
@@ -340,7 +379,9 @@ export function createThreadRuns({
|
|
|
340
379
|
if (pick) setRunPick(store, wake.id, pick, asker);
|
|
341
380
|
// A review runs with the agent's own read-only switch (runner.mjs); only Claude Code and Codex have one.
|
|
342
381
|
if (review) store.meta(`review:${wake.id}`, "1");
|
|
343
|
-
if (
|
|
382
|
+
if (wait) {
|
|
383
|
+
// Waits for the person's Start; the project already said why in the thread.
|
|
384
|
+
} else if (!recovering && threadMayRun(task, { answer })) {
|
|
344
385
|
if (go) {
|
|
345
386
|
store.meta(`person-wake:${wake.id}`, "1");
|
|
346
387
|
store.authorizeGoalRun(wake.id);
|
|
@@ -413,12 +454,16 @@ export function createThreadRuns({
|
|
|
413
454
|
}
|
|
414
455
|
};
|
|
415
456
|
// The turn's changes are committed in its thread's copy as soon as it ends, before another run can start there.
|
|
416
|
-
|
|
417
|
-
|
|
457
|
+
// A shared project's agent commits on its own branch (projects.mjs); it is undefined for any other thread.
|
|
458
|
+
const commitWake = (task) => {
|
|
459
|
+
const onBranch = projects()?.committed(task);
|
|
460
|
+
if (onBranch !== undefined) return onBranch;
|
|
461
|
+
return worktrees.commitTurn(
|
|
418
462
|
task.parent_id,
|
|
419
463
|
task.id,
|
|
420
464
|
`${task.target_agent}: ${task.objective.replace(/^Room: /, "")}`
|
|
421
465
|
);
|
|
466
|
+
};
|
|
422
467
|
const settleWake = (task, kind, text, startedAt) => {
|
|
423
468
|
const goalId = task.parent_id;
|
|
424
469
|
try {
|
package/lib/threadView.mjs
CHANGED
|
@@ -35,6 +35,13 @@ export function shorten(text, limit) {
|
|
|
35
35
|
|
|
36
36
|
const capitalized = (text) => text.charAt(0).toUpperCase() + text.slice(1);
|
|
37
37
|
|
|
38
|
+
// Who said something, as the person reads it: another person's agent in a shared project is "igor's Codex".
|
|
39
|
+
const whoIs = (name) => {
|
|
40
|
+
const [handle, agent] = String(name).split("/");
|
|
41
|
+
if (!agent) return nameOf(name);
|
|
42
|
+
return agent === "person" ? handle : `${handle}'s ${nameOf(agent)}`;
|
|
43
|
+
};
|
|
44
|
+
|
|
38
45
|
const withoutMentions = (text) =>
|
|
39
46
|
text.replace(/(^|\s)@[a-z][a-z0-9:./-]*/gi, "$1").trim();
|
|
40
47
|
|
|
@@ -70,6 +77,8 @@ export function createThreadView({
|
|
|
70
77
|
goals = null,
|
|
71
78
|
handoffs = null,
|
|
72
79
|
now = Date.now,
|
|
80
|
+
// What a shared project's room waits on the person for (projects.mjs needsOf): an OK, a post to share.
|
|
81
|
+
projectNeeds = () => [],
|
|
73
82
|
}) {
|
|
74
83
|
const coordinated = (post) =>
|
|
75
84
|
Boolean(store.meta(`coordinator-post:${post.id}`));
|
|
@@ -93,6 +102,9 @@ export function createThreadView({
|
|
|
93
102
|
};
|
|
94
103
|
|
|
95
104
|
function titleOf(thread, posts) {
|
|
105
|
+
// A shared project's room keeps the project's name, the same on both people's computers.
|
|
106
|
+
if (store.meta(`project-room:${thread.id}`))
|
|
107
|
+
return shorten(thread.objective, TITLE_LIMIT);
|
|
96
108
|
const written = goals?.record(thread.id)?.title;
|
|
97
109
|
if (written) return written;
|
|
98
110
|
// A task's own thread is named by its task, not by what the person writes in it later.
|
|
@@ -214,6 +226,7 @@ export function createThreadView({
|
|
|
214
226
|
seq: held.seq,
|
|
215
227
|
at: held.created_at,
|
|
216
228
|
});
|
|
229
|
+
items.push(...projectNeeds(thread.id));
|
|
217
230
|
return items.sort((a, b) => String(a.at).localeCompare(String(b.at)));
|
|
218
231
|
}
|
|
219
232
|
|
|
@@ -263,12 +276,15 @@ export function createThreadView({
|
|
|
263
276
|
: thread.goal.paused_reason || "Stopped";
|
|
264
277
|
const last = lastWords(posts);
|
|
265
278
|
if (!last) return "Nothing yet";
|
|
266
|
-
const who = last.author === "user" ? "You" :
|
|
279
|
+
const who = last.author === "user" ? "You" : whoIs(last.author);
|
|
267
280
|
return `${who}: ${shorten(withoutMentions(firstLine(last.text)), 140)}`;
|
|
268
281
|
}
|
|
269
282
|
|
|
270
283
|
function itemLine(item) {
|
|
271
|
-
const who =
|
|
284
|
+
const who = whoIs(item.agent);
|
|
285
|
+
if (item.kind === "agree")
|
|
286
|
+
return `${item.who ?? who} asks for your OK: ${shorten(firstLine(item.text), 140)}`;
|
|
287
|
+
if (item.kind === "share") return item.text;
|
|
272
288
|
if (item.kind === "answer")
|
|
273
289
|
return `${who} asks you: ${shorten(firstLine(item.text), 140)}`;
|
|
274
290
|
if (item.kind === "start") return `${who} waits for your Start`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tryharness",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.45",
|
|
4
4
|
"description": "Harness Relay: the daemon that turns the agents on this machine into your personal swarm. Memory, history, and work handed between any of them.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tryharness": "cli.mjs"
|