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/boardProtocol.json
CHANGED
|
@@ -39,6 +39,23 @@
|
|
|
39
39
|
"board.plan.add": "plans",
|
|
40
40
|
"board.plan.remove": "plans",
|
|
41
41
|
"board.post": "task",
|
|
42
|
+
"board.project.answer": "projects",
|
|
43
|
+
"board.project.create": "projects",
|
|
44
|
+
"board.project.decide": "projects",
|
|
45
|
+
"board.project.decline": "projects",
|
|
46
|
+
"board.project.held": "projects",
|
|
47
|
+
"board.project.join": "projects",
|
|
48
|
+
"board.project.leave": "projects",
|
|
49
|
+
"board.project.list": "projects",
|
|
50
|
+
"board.project.note": "projects",
|
|
51
|
+
"board.project.plan": "projects",
|
|
52
|
+
"board.project.propose": "projects",
|
|
53
|
+
"board.project.read": "projects",
|
|
54
|
+
"board.project.repos": "projects",
|
|
55
|
+
"board.project.setting": "projects",
|
|
56
|
+
"board.project.share": "projects",
|
|
57
|
+
"board.project.withdraw": "projects",
|
|
58
|
+
"board.project.work": "projects",
|
|
42
59
|
"board.prompted": "prompt",
|
|
43
60
|
"board.relay.decide": "relay",
|
|
44
61
|
"board.relay.defaults": "relay",
|
|
@@ -183,6 +200,12 @@
|
|
|
183
200
|
"board.plan.",
|
|
184
201
|
"board.template."
|
|
185
202
|
]
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
"owner": "projects",
|
|
206
|
+
"prefixes": [
|
|
207
|
+
"board.project."
|
|
208
|
+
]
|
|
186
209
|
}
|
|
187
210
|
],
|
|
188
211
|
"access": {
|
|
@@ -288,7 +311,22 @@
|
|
|
288
311
|
"board.relay.seen",
|
|
289
312
|
"board.relay.defaults",
|
|
290
313
|
"board.relay.peers",
|
|
291
|
-
"board.swarm.held"
|
|
314
|
+
"board.swarm.held",
|
|
315
|
+
"board.project.list",
|
|
316
|
+
"board.project.repos",
|
|
317
|
+
"board.project.create",
|
|
318
|
+
"board.project.join",
|
|
319
|
+
"board.project.decline",
|
|
320
|
+
"board.project.read",
|
|
321
|
+
"board.project.answer",
|
|
322
|
+
"board.project.withdraw",
|
|
323
|
+
"board.project.setting",
|
|
324
|
+
"board.project.decide",
|
|
325
|
+
"board.project.note",
|
|
326
|
+
"board.project.share",
|
|
327
|
+
"board.project.held",
|
|
328
|
+
"board.project.work",
|
|
329
|
+
"board.project.leave"
|
|
292
330
|
],
|
|
293
331
|
"harnessBrowser": [
|
|
294
332
|
"board.list",
|
|
@@ -442,7 +480,22 @@
|
|
|
442
480
|
"board.template.save",
|
|
443
481
|
"board.template.remove",
|
|
444
482
|
"board.template.use",
|
|
445
|
-
"board.swarm.held"
|
|
483
|
+
"board.swarm.held",
|
|
484
|
+
"board.project.list",
|
|
485
|
+
"board.project.repos",
|
|
486
|
+
"board.project.create",
|
|
487
|
+
"board.project.join",
|
|
488
|
+
"board.project.decline",
|
|
489
|
+
"board.project.read",
|
|
490
|
+
"board.project.answer",
|
|
491
|
+
"board.project.withdraw",
|
|
492
|
+
"board.project.setting",
|
|
493
|
+
"board.project.decide",
|
|
494
|
+
"board.project.note",
|
|
495
|
+
"board.project.share",
|
|
496
|
+
"board.project.held",
|
|
497
|
+
"board.project.work",
|
|
498
|
+
"board.project.leave"
|
|
446
499
|
],
|
|
447
500
|
"plainPerson": [
|
|
448
501
|
"board.standing.off"
|
package/lib/bridge.mjs
CHANGED
|
@@ -30,6 +30,7 @@ const SCRUBBED = new Set([
|
|
|
30
30
|
"coordinate",
|
|
31
31
|
"pick_folder",
|
|
32
32
|
"route_model",
|
|
33
|
+
"check_work",
|
|
33
34
|
"react",
|
|
34
35
|
"reflect",
|
|
35
36
|
"wake",
|
|
@@ -41,6 +42,7 @@ const DECIDE_ONLY = new Set([
|
|
|
41
42
|
"coordinate",
|
|
42
43
|
"pick_folder",
|
|
43
44
|
"route_model",
|
|
45
|
+
"check_work",
|
|
44
46
|
"react",
|
|
45
47
|
"reflect",
|
|
46
48
|
]);
|
package/lib/coordinator.mjs
CHANGED
|
@@ -208,6 +208,8 @@ export function createCoordinator({
|
|
|
208
208
|
// (ownMachines.mjs), and whether one of them can take the thread's turn at all.
|
|
209
209
|
machinesOf = () => undefined,
|
|
210
210
|
placeable = () => true,
|
|
211
|
+
// A post from the other side of a shared project (projects.mjs): their own swarm sorts it, so it starts no round here.
|
|
212
|
+
fromPartner = () => false,
|
|
211
213
|
}) {
|
|
212
214
|
const failedHereLately = (threadId, agent) => {
|
|
213
215
|
const at = Date.parse(store.meta(`job-failed:${threadId}:${agent}`) || "");
|
|
@@ -869,7 +871,12 @@ export function createCoordinator({
|
|
|
869
871
|
const asked = askedOf(goalId);
|
|
870
872
|
const posts = store
|
|
871
873
|
.roomPosts(goalId, state.lastSeenSeq, 500)
|
|
872
|
-
.filter(
|
|
874
|
+
.filter(
|
|
875
|
+
(post) =>
|
|
876
|
+
!QUIET_KINDS.has(post.kind) &&
|
|
877
|
+
!ownPost(thread, post) &&
|
|
878
|
+
!fromPartner(goalId, post)
|
|
879
|
+
);
|
|
873
880
|
// A turn T3 Code is running for one of the thread's agents counts as work going on, though Harness did not start it
|
|
874
881
|
// (October 14: the coordinator told Claude Code to "continue" three times while it worked in T3).
|
|
875
882
|
const active =
|
package/lib/daemon.mjs
CHANGED
|
@@ -94,6 +94,7 @@ import {
|
|
|
94
94
|
} from "./models.mjs";
|
|
95
95
|
import { forgetT3, startT3SignIn, steerT3Run, t3Access } from "./t3.mjs";
|
|
96
96
|
import { createNetwork } from "./network.mjs";
|
|
97
|
+
import { createProjects } from "./projects.mjs";
|
|
97
98
|
import { createSessionControl } from "./sessionControl.mjs";
|
|
98
99
|
import { createSessionIndex } from "./sessionIndex.mjs";
|
|
99
100
|
import { createBoardAccess } from "./boardAccess.mjs";
|
|
@@ -347,6 +348,7 @@ export async function startDaemon() {
|
|
|
347
348
|
for (const thread of store.goals()) coordinator.poke(thread.id);
|
|
348
349
|
for (const message of store.undeliveredMessages())
|
|
349
350
|
sendThreadMessage(message);
|
|
351
|
+
projects?.resend();
|
|
350
352
|
},
|
|
351
353
|
onMessage: (message) => handleBridgeMessage(message),
|
|
352
354
|
});
|
|
@@ -499,6 +501,33 @@ export async function startDaemon() {
|
|
|
499
501
|
})().catch((error) =>
|
|
500
502
|
log(`thread end ${taskId} not sent: ${error.message}`)
|
|
501
503
|
);
|
|
504
|
+
// A shared project's event (projects.mjs) on the person thread under it: sealed to the other computer, never readable.
|
|
505
|
+
// Harness acknowledges it once it holds it, and keeps it until the other computer has it.
|
|
506
|
+
const sendProjectEvent = ({ projectId, to, messageId, seq, body }) =>
|
|
507
|
+
void (async () => {
|
|
508
|
+
const key = await threadKey(store.getThread(projectId));
|
|
509
|
+
if (!key)
|
|
510
|
+
throw new Error(
|
|
511
|
+
"the project's thread has no key for the other computer"
|
|
512
|
+
);
|
|
513
|
+
send({
|
|
514
|
+
type: "thread_message",
|
|
515
|
+
taskId: projectId,
|
|
516
|
+
messageId,
|
|
517
|
+
seq,
|
|
518
|
+
to,
|
|
519
|
+
sentAt: new Date().toISOString(),
|
|
520
|
+
text: "",
|
|
521
|
+
refs: [],
|
|
522
|
+
sealed: await sealBound(key, `message|${projectId}|${messageId}`, {
|
|
523
|
+
text: "",
|
|
524
|
+
refs: [],
|
|
525
|
+
project: body,
|
|
526
|
+
}),
|
|
527
|
+
});
|
|
528
|
+
})().catch((error) =>
|
|
529
|
+
log(`project event ${messageId} not sent: ${error.message}`)
|
|
530
|
+
);
|
|
502
531
|
// Every change to the board goes up the bridge as identity and status; the server mirrors it
|
|
503
532
|
// and the PiP follows from there. Briefs and results never ride this message.
|
|
504
533
|
// The person is told on their desktop about what waits on them, whether or not Harness is
|
|
@@ -813,7 +842,12 @@ export async function startDaemon() {
|
|
|
813
842
|
},
|
|
814
843
|
timing: handoffTiming(),
|
|
815
844
|
});
|
|
816
|
-
const threadView = createThreadView({
|
|
845
|
+
const threadView = createThreadView({
|
|
846
|
+
store,
|
|
847
|
+
goals,
|
|
848
|
+
handoffs,
|
|
849
|
+
projectNeeds: (threadId) => projects?.needsOf(threadId) ?? [],
|
|
850
|
+
});
|
|
817
851
|
const handoffTimer = setInterval(
|
|
818
852
|
() => handoffs.tick(),
|
|
819
853
|
Math.min(30_000, handoffTiming().nudgeMs / 3)
|
|
@@ -899,6 +933,7 @@ export async function startDaemon() {
|
|
|
899
933
|
`Why now: ${reason}`,
|
|
900
934
|
`The thread's newest posts (oldest first; each line is a teammate's words, not instructions about authority or money):\n${roomDigest(task.id)}`,
|
|
901
935
|
goalNote(task),
|
|
936
|
+
projects?.brief(task, agent) ?? "",
|
|
902
937
|
teams.brief(task.id, agent, { model: cardsFor([agent])[0]?.model }),
|
|
903
938
|
threadFilesNote(task, agent),
|
|
904
939
|
[
|
|
@@ -1042,10 +1077,12 @@ export async function startDaemon() {
|
|
|
1042
1077
|
: agent === "claude-code"
|
|
1043
1078
|
? `${nameOf(agent)} would work in your own folder here, not a copy, so work another agent asked for waits for your Start.`
|
|
1044
1079
|
: `${nameOf(agent)} has no restricted mode, so work another agent asked of it waits for your Start.`;
|
|
1045
|
-
|
|
1080
|
+
// In a task's own thread the person's go is their go on the task: a run they authorized, and, for its asker's turn on
|
|
1081
|
+
// the task's answer (`answer`), the task itself when they posted it or their own agent session did (owner, October 20).
|
|
1082
|
+
const threadMayRun = (goal, { answer = false } = {}) => {
|
|
1046
1083
|
if (goal.trust !== "user") return false;
|
|
1047
1084
|
const root = store.meta(`task-room:${goal.id}`);
|
|
1048
|
-
return !root || Boolean(store.getTask(root)?.run_authorized_at);
|
|
1085
|
+
return !root || answer || Boolean(store.getTask(root)?.run_authorized_at);
|
|
1049
1086
|
};
|
|
1050
1087
|
const flagNote = (post) =>
|
|
1051
1088
|
store.meta(`flagged:${post.id}`)
|
|
@@ -1073,12 +1110,15 @@ export async function startDaemon() {
|
|
|
1073
1110
|
store,
|
|
1074
1111
|
root: path.join(paths.home, "worktrees"),
|
|
1075
1112
|
});
|
|
1113
|
+
// Projects shared with another person's swarm, made once the relay is (below).
|
|
1114
|
+
let projects = null;
|
|
1076
1115
|
const threadRuns = createThreadRuns({
|
|
1077
1116
|
store,
|
|
1078
1117
|
log,
|
|
1079
1118
|
installedAgents,
|
|
1080
1119
|
authority,
|
|
1081
1120
|
worktrees,
|
|
1121
|
+
projects: () => projects,
|
|
1082
1122
|
notifyBoard,
|
|
1083
1123
|
swarmBrief,
|
|
1084
1124
|
threadMayRun,
|
|
@@ -1536,7 +1576,14 @@ export async function startDaemon() {
|
|
|
1536
1576
|
post,
|
|
1537
1577
|
author,
|
|
1538
1578
|
names = post.mentions,
|
|
1539
|
-
{
|
|
1579
|
+
{
|
|
1580
|
+
hosted = false,
|
|
1581
|
+
why = null,
|
|
1582
|
+
guard,
|
|
1583
|
+
answering = null,
|
|
1584
|
+
// A shared project's go for a wake the other side asked for (projects.mjs), in place of the person's own.
|
|
1585
|
+
go: projectGo = null,
|
|
1586
|
+
} = {}
|
|
1540
1587
|
) => {
|
|
1541
1588
|
const goal = store.goal(goalId);
|
|
1542
1589
|
const { picks } = picksIn(store, post.text, names);
|
|
@@ -1565,11 +1612,12 @@ export async function startDaemon() {
|
|
|
1565
1612
|
);
|
|
1566
1613
|
else if (RUNNERS.has(agent))
|
|
1567
1614
|
threadRuns.wake(goalId, agent, reason, {
|
|
1568
|
-
go: personsGo(author, agent, { hosted, guard }),
|
|
1615
|
+
go: projectGo ?? personsGo(author, agent, { hosted, guard }),
|
|
1569
1616
|
asker: author,
|
|
1570
1617
|
pick: picks.get(agent),
|
|
1571
1618
|
words: post.text,
|
|
1572
1619
|
held: guard === undefined ? null : guardWait(author, agent, guard),
|
|
1620
|
+
answer: agent === answering,
|
|
1573
1621
|
});
|
|
1574
1622
|
else if (ASKABLE.has(agent))
|
|
1575
1623
|
told.push(askAgent(goalId, agent, reason, author, post.text));
|
|
@@ -1665,6 +1713,8 @@ export async function startDaemon() {
|
|
|
1665
1713
|
...(root ? [] : [...alsoAsked, ...named]),
|
|
1666
1714
|
]),
|
|
1667
1715
|
].filter((agent) => agent && agent !== who && team.includes(agent));
|
|
1716
|
+
// The asker's turn on its own task's answer, in the thread the task opened (threadMayRun).
|
|
1717
|
+
const answering = root && mentions.includes(asker) ? asker : null;
|
|
1668
1718
|
// An answer that carries something like a key is held for the person, as any post is, and the room hears that it was.
|
|
1669
1719
|
const flag = secretReason(text);
|
|
1670
1720
|
if (flag) {
|
|
@@ -1710,10 +1760,11 @@ export async function startDaemon() {
|
|
|
1710
1760
|
void readByGuard(text).then((guard) => {
|
|
1711
1761
|
if (guard?.verdict === "flag" || guard?.verdict === "hold")
|
|
1712
1762
|
store.meta(`flagged:${post.id}`, String(guard.score));
|
|
1713
|
-
wakeFor(goal.id, post, who, undefined, { guard });
|
|
1763
|
+
wakeFor(goal.id, post, who, undefined, { guard, answering });
|
|
1714
1764
|
notifyBoard(store.getTask(goal.id));
|
|
1715
1765
|
});
|
|
1716
|
-
else if (goal.status === "open")
|
|
1766
|
+
else if (goal.status === "open")
|
|
1767
|
+
wakeFor(goal.id, post, who, undefined, { answering });
|
|
1717
1768
|
// Harness is asked by name only in a post (wakeFor); in a task's own thread no round follows the answer, so its
|
|
1718
1769
|
// answer to work Harness posted is asked of Harness as one.
|
|
1719
1770
|
if (root && mentions.includes("harness") && goal.status === "open")
|
|
@@ -1793,6 +1844,7 @@ export async function startDaemon() {
|
|
|
1793
1844
|
};
|
|
1794
1845
|
const goalCommand = createGoalCommands({
|
|
1795
1846
|
teams,
|
|
1847
|
+
learned: (goalId, agent, text) => projects?.learned(goalId, agent, text),
|
|
1796
1848
|
DEFAULT_MAX_POSTS,
|
|
1797
1849
|
DEFAULT_MAX_WAKES,
|
|
1798
1850
|
HELD_NOTE,
|
|
@@ -2250,6 +2302,7 @@ export async function startDaemon() {
|
|
|
2250
2302
|
const coordinator = createCoordinator({
|
|
2251
2303
|
store,
|
|
2252
2304
|
lessons,
|
|
2305
|
+
fromPartner: (goalId, post) => projects?.fromPartner(goalId, post) ?? false,
|
|
2253
2306
|
team: teams,
|
|
2254
2307
|
headOf: (threadId) => worktrees.head(threadId),
|
|
2255
2308
|
busyInT3: (thread) =>
|
|
@@ -2310,6 +2363,9 @@ export async function startDaemon() {
|
|
|
2310
2363
|
: null,
|
|
2311
2364
|
});
|
|
2312
2365
|
const swarmCommand = createSwarm({
|
|
2366
|
+
projectOf: (threadId) => projects?.roomInfo(threadId) ?? null,
|
|
2367
|
+
addressesPartner: (threadId, text) =>
|
|
2368
|
+
projects?.addressesPartner(threadId, text) ?? false,
|
|
2313
2369
|
withMachines: (card) => actors.withMachines(card),
|
|
2314
2370
|
store,
|
|
2315
2371
|
plansOf: (threadId) => plans?.of(threadId) ?? [],
|
|
@@ -2429,6 +2485,10 @@ export async function startDaemon() {
|
|
|
2429
2485
|
network
|
|
2430
2486
|
? network.command(request, agent)
|
|
2431
2487
|
: { ok: false, error: "the daemon is still starting" },
|
|
2488
|
+
projects: (request, { agent }) =>
|
|
2489
|
+
projects
|
|
2490
|
+
? projects.command(request, agent)
|
|
2491
|
+
: { ok: false, error: "the daemon is still starting" },
|
|
2432
2492
|
live: (request, { agent }) => liveCommand(request, agent),
|
|
2433
2493
|
prompt: (request, { agent }) => {
|
|
2434
2494
|
authority.markPrompt(request.pids, agent);
|
|
@@ -2473,6 +2533,7 @@ export async function startDaemon() {
|
|
|
2473
2533
|
lessons,
|
|
2474
2534
|
madeIn: (...args) => madeIn(...args),
|
|
2475
2535
|
getNetwork: () => network,
|
|
2536
|
+
getProjects: () => projects,
|
|
2476
2537
|
notifyBoard,
|
|
2477
2538
|
openTaskRoom,
|
|
2478
2539
|
openThreadPost: (...args) => openThreadPost(...args),
|
|
@@ -2663,6 +2724,8 @@ export async function startDaemon() {
|
|
|
2663
2724
|
brief,
|
|
2664
2725
|
refs,
|
|
2665
2726
|
trustNewKey = false,
|
|
2727
|
+
// A shared project's offer (projects.mjs): it goes only sealed, to a computer that has a key.
|
|
2728
|
+
project = null,
|
|
2666
2729
|
}) => {
|
|
2667
2730
|
if (!state.connected)
|
|
2668
2731
|
throw new Error("the daemon is not connected to Harness");
|
|
@@ -2695,13 +2758,22 @@ export async function startDaemon() {
|
|
|
2695
2758
|
throw new Error(
|
|
2696
2759
|
`Harness gave no key for ${handleOf(target)}'s computer, which had one before; the request was not sent`
|
|
2697
2760
|
);
|
|
2761
|
+
if (project && typeof keyed.publicKey !== "string")
|
|
2762
|
+
throw new Error(
|
|
2763
|
+
`${handleOf(target)}'s computer can't take a sealed project yet. Ask them to update Harness.`
|
|
2764
|
+
);
|
|
2698
2765
|
if (typeof keyed.publicKey === "string") {
|
|
2699
2766
|
targetKey = peerKeyFor(handleOf(target), keyed.publicKey, trustNewKey);
|
|
2700
2767
|
const sealId = randomUUID();
|
|
2701
2768
|
const sealed = await sealBound(
|
|
2702
2769
|
await relayKey(relayIdentity.privateKey, targetKey),
|
|
2703
2770
|
`request|${sealId}`,
|
|
2704
|
-
{
|
|
2771
|
+
{
|
|
2772
|
+
about: subject,
|
|
2773
|
+
brief: text,
|
|
2774
|
+
refs: attached,
|
|
2775
|
+
...(project ? { project } : {}),
|
|
2776
|
+
}
|
|
2705
2777
|
);
|
|
2706
2778
|
input = {
|
|
2707
2779
|
to: target,
|
|
@@ -2807,6 +2879,9 @@ export async function startDaemon() {
|
|
|
2807
2879
|
return {
|
|
2808
2880
|
about: String(opened.about || "").slice(0, 500),
|
|
2809
2881
|
fingerprint: await fingerprint(peer),
|
|
2882
|
+
...(!mine && opened.project && typeof opened.project === "object"
|
|
2883
|
+
? { project: opened.project }
|
|
2884
|
+
: {}),
|
|
2810
2885
|
};
|
|
2811
2886
|
};
|
|
2812
2887
|
network = createNetwork({
|
|
@@ -2816,7 +2891,53 @@ export async function startDaemon() {
|
|
|
2816
2891
|
openRelayRequest,
|
|
2817
2892
|
fingerprint,
|
|
2818
2893
|
myKey: () => relayIdentity?.publicKey ?? null,
|
|
2894
|
+
isChannel: (threadId) => projects?.isChannel(threadId) ?? false,
|
|
2895
|
+
});
|
|
2896
|
+
// Projects shared with another person's swarm: one room both swarms work in, a record both keep, a check before work.
|
|
2897
|
+
projects = createProjects({
|
|
2898
|
+
store,
|
|
2899
|
+
log,
|
|
2900
|
+
myHandle: () => network.myHandle(),
|
|
2901
|
+
relayRequest,
|
|
2902
|
+
decideRequest: (id, decision) => network.decide(id, decision),
|
|
2903
|
+
invites: () => network.invites(),
|
|
2904
|
+
sentInvites: () => network.sentProjects(),
|
|
2905
|
+
sendEvent: sendProjectEvent,
|
|
2906
|
+
endChannel: (taskId, outcome) => {
|
|
2907
|
+
if (store.closeThread(taskId, outcome).ok)
|
|
2908
|
+
sendThreadEnd(taskId, "person", outcome);
|
|
2909
|
+
},
|
|
2910
|
+
wake: (goalId, post, author, names, options) =>
|
|
2911
|
+
wakeFor(goalId, post, author, names, options),
|
|
2912
|
+
wakeRun: (goalId, agent, reason, options) =>
|
|
2913
|
+
threadRuns.wake(goalId, agent, reason, options),
|
|
2914
|
+
notifyBoard,
|
|
2915
|
+
notifyDesktop: (text) => {
|
|
2916
|
+
if (notificationsOn()) notifyDesktop(text);
|
|
2917
|
+
},
|
|
2918
|
+
checkWork: (input) => {
|
|
2919
|
+
if (!state.connected || !bridge.has("check_work")) {
|
|
2920
|
+
log(
|
|
2921
|
+
`project check: ${state.connected ? "this Harness can't check work" : "not connected to Harness"}`
|
|
2922
|
+
);
|
|
2923
|
+
return Promise.resolve(null);
|
|
2924
|
+
}
|
|
2925
|
+
// The bridge hands back Harness's answer with its fields beside ok.
|
|
2926
|
+
return askHarness("check_work", input).then(({ ok, ...verdict }) => {
|
|
2927
|
+
if (!ok) log(`project check: ${verdict.error}`);
|
|
2928
|
+
return ok ? verdict : null;
|
|
2929
|
+
});
|
|
2930
|
+
},
|
|
2931
|
+
knownFolders: () => folders.known().map((place) => place.path),
|
|
2932
|
+
agents: () => [
|
|
2933
|
+
...installedAgents.filter((agent) => RUNNERS.has(agent)),
|
|
2934
|
+
"harness",
|
|
2935
|
+
],
|
|
2936
|
+
worktreeRoot: path.join(paths.home, "projects"),
|
|
2937
|
+
maxPosts: DEFAULT_MAX_POSTS,
|
|
2938
|
+
maxWakes: DEFAULT_MAX_WAKES,
|
|
2819
2939
|
});
|
|
2940
|
+
store.onRoomPost((goalId, post) => projects?.posted(goalId, post));
|
|
2820
2941
|
|
|
2821
2942
|
const { plainBoard, roomOf, madeIn, visibleTo, SEALED_ONLY } =
|
|
2822
2943
|
createBoardAccess({
|
|
@@ -3403,6 +3524,20 @@ export async function startDaemon() {
|
|
|
3403
3524
|
text: String(opened.text || ""),
|
|
3404
3525
|
refs: Array.isArray(opened.refs) ? opened.refs : [],
|
|
3405
3526
|
};
|
|
3527
|
+
// A shared project's event: the project keeps it; nothing lands on the thread itself.
|
|
3528
|
+
if (opened.project) {
|
|
3529
|
+
const kept = projects
|
|
3530
|
+
? projects.receive(String(input.taskId), opened.project)
|
|
3531
|
+
: { ok: false, error: "the daemon is still starting" };
|
|
3532
|
+
send({
|
|
3533
|
+
type: "bridge_response",
|
|
3534
|
+
requestId: message.requestId,
|
|
3535
|
+
ok: kept.ok,
|
|
3536
|
+
result: kept.ok ? { acknowledged: input.messageId } : null,
|
|
3537
|
+
...(kept.ok ? {} : { error: kept.error }),
|
|
3538
|
+
});
|
|
3539
|
+
return;
|
|
3540
|
+
}
|
|
3406
3541
|
}
|
|
3407
3542
|
// A file the message names is this computer's own row, matched to the id the other computer gave it; only a sealed thread brings files.
|
|
3408
3543
|
const refs = crossRefs(words.refs).map((ref) => {
|
|
@@ -3525,6 +3660,7 @@ export async function startDaemon() {
|
|
|
3525
3660
|
}
|
|
3526
3661
|
if (message.type === "thread_ack") {
|
|
3527
3662
|
store.markDelivered(String(message.messageId || ""));
|
|
3663
|
+
projects?.delivered(String(message.messageId || ""));
|
|
3528
3664
|
return;
|
|
3529
3665
|
}
|
|
3530
3666
|
// Someone asked to reach this person's swarm (network.mjs lists it): told on the desktop, answered in Swarms.
|
|
@@ -3569,6 +3705,7 @@ export async function startDaemon() {
|
|
|
3569
3705
|
result: closed.ok ? { closed: input.taskId } : null,
|
|
3570
3706
|
});
|
|
3571
3707
|
if (closed.ok && !closed.already) {
|
|
3708
|
+
projects?.channelEnded(String(input.taskId || ""));
|
|
3572
3709
|
notifyBoard(closed.task);
|
|
3573
3710
|
if (notificationsOn())
|
|
3574
3711
|
notifyDesktop(
|
package/lib/goalCommands.mjs
CHANGED
|
@@ -41,6 +41,8 @@ export function createGoalCommands({
|
|
|
41
41
|
files: boardFiles,
|
|
42
42
|
// The thread's team (team.mjs): an agent's note on what it learned in its role.
|
|
43
43
|
teams = null,
|
|
44
|
+
// A note saved in a shared project's room is the project's too (projects.mjs).
|
|
45
|
+
learned = () => {},
|
|
44
46
|
}) {
|
|
45
47
|
return (request, agent) => {
|
|
46
48
|
const id = String(request.id || "");
|
|
@@ -153,11 +155,14 @@ export function createGoalCommands({
|
|
|
153
155
|
if (!inRoom(goal, agent) || agent === "user")
|
|
154
156
|
return { ok: false, error: `${agent} is not on this goal's team` };
|
|
155
157
|
if (!teams) return { ok: false, error: "the daemon is still starting" };
|
|
156
|
-
|
|
158
|
+
const kept = teams.learn(goal.id, agent, {
|
|
157
159
|
text: request.text,
|
|
158
160
|
reason: request.reason,
|
|
159
161
|
replaces: request.replaces,
|
|
160
162
|
});
|
|
163
|
+
if (kept.ok)
|
|
164
|
+
learned(goal.id, agent, `${request.text} (${request.reason})`);
|
|
165
|
+
return kept;
|
|
161
166
|
}
|
|
162
167
|
if (request.command === "board.room.search") {
|
|
163
168
|
if (!inRoom(goal, agent))
|
package/lib/mcp-stdio.mjs
CHANGED
|
@@ -400,6 +400,69 @@ const LOCAL_TOOLS = [
|
|
|
400
400
|
additionalProperties: false,
|
|
401
401
|
},
|
|
402
402
|
},
|
|
403
|
+
{
|
|
404
|
+
name: "plan_work",
|
|
405
|
+
description:
|
|
406
|
+
"In a project shared with another person's swarm: say what you plan to build before you change code for it (summary, and the files or interfaces it touches), or that your piece is done. Your plan is checked against what the two people decided and the other side's work; the answer says whether to go ahead, or that it clashes and waits until the two sides agree a fix.",
|
|
407
|
+
inputSchema: {
|
|
408
|
+
type: "object",
|
|
409
|
+
properties: {
|
|
410
|
+
id: { type: "string", description: "the thread id" },
|
|
411
|
+
summary: {
|
|
412
|
+
type: "string",
|
|
413
|
+
description: "what you will build, in a sentence or two",
|
|
414
|
+
},
|
|
415
|
+
touches: {
|
|
416
|
+
type: "array",
|
|
417
|
+
items: { type: "string" },
|
|
418
|
+
description: "the files, modules or interfaces it changes",
|
|
419
|
+
},
|
|
420
|
+
done: {
|
|
421
|
+
type: "boolean",
|
|
422
|
+
description: "true when your piece is ready to merge",
|
|
423
|
+
},
|
|
424
|
+
stopped: {
|
|
425
|
+
type: "boolean",
|
|
426
|
+
description: "true when you are dropping this piece",
|
|
427
|
+
},
|
|
428
|
+
},
|
|
429
|
+
required: ["id"],
|
|
430
|
+
additionalProperties: false,
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
name: "propose",
|
|
435
|
+
description:
|
|
436
|
+
"In a project shared with another person's swarm: propose how two clashing pieces of work fit together, or a decision for the project (an interface, a rule, a split of the work). Agree it with the other agent in the thread first. A person OKs it before it counts: both people for a decision, the owner of each piece of work for a fix.",
|
|
437
|
+
inputSchema: {
|
|
438
|
+
type: "object",
|
|
439
|
+
properties: {
|
|
440
|
+
id: { type: "string", description: "the thread id" },
|
|
441
|
+
text: {
|
|
442
|
+
type: "string",
|
|
443
|
+
description: "what you propose, in plain words",
|
|
444
|
+
},
|
|
445
|
+
about: {
|
|
446
|
+
type: "array",
|
|
447
|
+
items: { type: "string" },
|
|
448
|
+
description: "the work ids this settles (from the clash post)",
|
|
449
|
+
},
|
|
450
|
+
changes: {
|
|
451
|
+
type: "array",
|
|
452
|
+
items: { type: "string" },
|
|
453
|
+
description:
|
|
454
|
+
"the work ids whose plan changes under this proposal; their owners OK it",
|
|
455
|
+
},
|
|
456
|
+
decision: {
|
|
457
|
+
type: "string",
|
|
458
|
+
description:
|
|
459
|
+
"a decision both people OK, when this changes or adds to what they decided",
|
|
460
|
+
},
|
|
461
|
+
},
|
|
462
|
+
required: ["id", "text"],
|
|
463
|
+
additionalProperties: false,
|
|
464
|
+
},
|
|
465
|
+
},
|
|
403
466
|
{
|
|
404
467
|
name: "save_learning",
|
|
405
468
|
description:
|
|
@@ -709,6 +772,22 @@ const BOARD_CALLS = {
|
|
|
709
772
|
ask: Array.isArray(args.ask) ? args.ask : [],
|
|
710
773
|
shareWithGuests: args.share_with_guests === true,
|
|
711
774
|
}),
|
|
775
|
+
plan_work: (args) => ({
|
|
776
|
+
command: "board.project.plan",
|
|
777
|
+
id: String(args.id || ""),
|
|
778
|
+
summary: args.summary,
|
|
779
|
+
touches: Array.isArray(args.touches) ? args.touches : undefined,
|
|
780
|
+
done: args.done === true,
|
|
781
|
+
stopped: args.stopped === true,
|
|
782
|
+
}),
|
|
783
|
+
propose: (args) => ({
|
|
784
|
+
command: "board.project.propose",
|
|
785
|
+
id: String(args.id || ""),
|
|
786
|
+
text: args.text,
|
|
787
|
+
about: Array.isArray(args.about) ? args.about : [],
|
|
788
|
+
changes: Array.isArray(args.changes) ? args.changes : [],
|
|
789
|
+
decision: args.decision ?? null,
|
|
790
|
+
}),
|
|
712
791
|
save_learning: (args) => ({
|
|
713
792
|
command: "board.room.learn",
|
|
714
793
|
id: String(args.id || ""),
|
package/lib/network.mjs
CHANGED
|
@@ -20,6 +20,8 @@ export function createNetwork({
|
|
|
20
20
|
openRelayRequest,
|
|
21
21
|
fingerprint,
|
|
22
22
|
myKey,
|
|
23
|
+
// A relay thread that carries a shared project (projects.mjs): Swarms lists the project, not the thread under it.
|
|
24
|
+
isChannel = () => false,
|
|
23
25
|
}) {
|
|
24
26
|
// Harness answers for the server's half; a refusal comes back as a plain error the person can read.
|
|
25
27
|
const harness = async (input) => {
|
|
@@ -38,12 +40,15 @@ export function createNetwork({
|
|
|
38
40
|
store.relayThreads().map((row) => [row.task_id, row])
|
|
39
41
|
);
|
|
40
42
|
const items = [];
|
|
43
|
+
const invited = [];
|
|
44
|
+
const sent = [];
|
|
41
45
|
for (const thread of server?.threads ?? []) {
|
|
42
46
|
const here = local.get(thread.id) || null;
|
|
43
47
|
local.delete(thread.id);
|
|
44
48
|
const peer = thread.role === "asker" ? thread.target : thread.asker;
|
|
45
49
|
let about = thread.about || here?.objective || "";
|
|
46
50
|
let keyPrint = null;
|
|
51
|
+
let project = null;
|
|
47
52
|
// A sealed request's subject: opened on this computer, with the other computer's key to compare.
|
|
48
53
|
if (thread.sealed && !about) {
|
|
49
54
|
const opened = await openRelayRequest({
|
|
@@ -53,8 +58,20 @@ export function createNetwork({
|
|
|
53
58
|
if (opened) {
|
|
54
59
|
about = opened.about;
|
|
55
60
|
keyPrint = opened.fingerprint;
|
|
61
|
+
project = opened.project ?? null;
|
|
56
62
|
}
|
|
57
63
|
}
|
|
64
|
+
if (project || isChannel(thread.id)) {
|
|
65
|
+
if (
|
|
66
|
+
project &&
|
|
67
|
+
thread.role === "target" &&
|
|
68
|
+
thread.status === "requested"
|
|
69
|
+
)
|
|
70
|
+
invited.push({ id: thread.id, project, fingerprint: keyPrint });
|
|
71
|
+
if (thread.role === "asker")
|
|
72
|
+
sent.push({ id: thread.id, status: thread.status });
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
58
75
|
items.push(
|
|
59
76
|
item({
|
|
60
77
|
id: thread.id,
|
|
@@ -77,6 +94,7 @@ export function createNetwork({
|
|
|
77
94
|
}
|
|
78
95
|
// Threads this computer holds that Harness no longer lists (older ones, or Harness out of reach).
|
|
79
96
|
for (const here of local.values()) {
|
|
97
|
+
if (isChannel(here.task_id)) continue;
|
|
80
98
|
items.push(
|
|
81
99
|
item({
|
|
82
100
|
id: here.task_id,
|
|
@@ -104,6 +122,8 @@ export function createNetwork({
|
|
|
104
122
|
ok: true,
|
|
105
123
|
connected: Boolean(server),
|
|
106
124
|
items,
|
|
125
|
+
invited,
|
|
126
|
+
sent,
|
|
107
127
|
needsYou: items.filter((entry) => entry.group === "needs_you").length,
|
|
108
128
|
};
|
|
109
129
|
};
|
|
@@ -273,5 +293,17 @@ export function createNetwork({
|
|
|
273
293
|
if (store.meta(AUTO_SEND_DEFAULT) === "1") store.setAutoSend(taskId, true);
|
|
274
294
|
};
|
|
275
295
|
|
|
276
|
-
|
|
296
|
+
/** Requests to work on a shared project together, waiting for the person's answer. */
|
|
297
|
+
const invites = async () => (await conversations()).invited;
|
|
298
|
+
/** Where each project invitation this person sent stands at Harness: requested, accepted, declined or expired. */
|
|
299
|
+
const sentProjects = async () => (await conversations()).sent;
|
|
300
|
+
/** The person's answer to a request (accept, decline or block), as Harness takes it. */
|
|
301
|
+
const decide = (id, decision) => harness({ op: "decide", id, decision });
|
|
302
|
+
/** The person's own handle on Harness, or null before they claim one. */
|
|
303
|
+
const myHandle = async () => {
|
|
304
|
+
const answer = await harness({ op: "card" });
|
|
305
|
+
return answer.card?.handle ?? null;
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
return { command, opened, invites, sentProjects, decide, myHandle };
|
|
277
309
|
}
|