tryharness 0.7.42 → 0.7.43
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/cli.mjs +118 -5
- package/lib/actorRoster.mjs +16 -2
- package/lib/adapters.mjs +2 -1
- package/lib/answers.mjs +30 -0
- package/lib/boardCommands.mjs +9 -1
- package/lib/boardFiles.mjs +1 -1
- package/lib/boardProtocol.json +1 -0
- package/lib/bridge.mjs +49 -9
- package/lib/cards.mjs +22 -4
- package/lib/compaction.mjs +90 -0
- package/lib/context.mjs +19 -11
- package/lib/coordinator.mjs +176 -12
- package/lib/daemon.mjs +424 -44
- package/lib/fit.mjs +65 -0
- package/lib/folders.mjs +20 -0
- package/lib/frames.mjs +3 -2
- package/lib/goalCommands.mjs +12 -0
- package/lib/handover.mjs +128 -0
- package/lib/loopBackstop.mjs +104 -0
- package/lib/machineIdentity.mjs +43 -0
- package/lib/machineRoutes.mjs +97 -0
- package/lib/machineRuns.mjs +133 -0
- package/lib/machineSeal.mjs +157 -0
- package/lib/mcp-stdio.mjs +54 -11
- package/lib/nudge.mjs +211 -44
- package/lib/oneLine.mjs +27 -0
- package/lib/ownMachines.mjs +748 -0
- package/lib/paths.mjs +1 -0
- package/lib/plans.mjs +3 -2
- package/lib/provenance.mjs +4 -1
- package/lib/runBrief.mjs +346 -0
- package/lib/runWorker.mjs +24 -173
- package/lib/runner.mjs +26 -2
- package/lib/store.mjs +232 -16
- package/lib/stuck.mjs +198 -0
- package/lib/swarm.mjs +3 -1
- package/lib/taskCommands.mjs +268 -31
- package/lib/taskRuns.mjs +9 -0
- package/lib/team.json +192 -0
- package/lib/team.mjs +417 -0
- package/lib/threadRuns.mjs +18 -7
- package/lib/threadView.mjs +13 -0
- package/lib/trails.mjs +49 -0
- package/lib/wakes.mjs +201 -69
- package/lib/worktrees.mjs +9 -0
- package/package.json +1 -1
package/lib/taskCommands.mjs
CHANGED
|
@@ -12,8 +12,15 @@ import {
|
|
|
12
12
|
resolveMember,
|
|
13
13
|
} from "./members.mjs";
|
|
14
14
|
import { LIVE_AGENTS, sessionOfProcess } from "./live.mjs";
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
cardLine,
|
|
17
|
+
shortCardLine,
|
|
18
|
+
swarmBlock,
|
|
19
|
+
swarmDigest,
|
|
20
|
+
toldBlock,
|
|
21
|
+
} from "./cards.mjs";
|
|
16
22
|
import { PICKABLE, resolvePick, setRunPick } from "./models.mjs";
|
|
23
|
+
import { onMachine, placeTask } from "./machineRoutes.mjs";
|
|
17
24
|
|
|
18
25
|
// An agent working in a thread may bring another agent in for part of the work there, as Harness does when it names
|
|
19
26
|
// one; an agent that moves money or takes positions joins only when the person names it (members.mjs TAGGED_ONLY).
|
|
@@ -26,6 +33,7 @@ const joinsThread = (thread, target, roomAgents) =>
|
|
|
26
33
|
export function createTaskCommands({
|
|
27
34
|
CLOUD_TARGETS,
|
|
28
35
|
OPENED,
|
|
36
|
+
machines,
|
|
29
37
|
ROOM_AGENTS,
|
|
30
38
|
getActiveRuns,
|
|
31
39
|
boardCommand,
|
|
@@ -70,8 +78,64 @@ export function createTaskCommands({
|
|
|
70
78
|
? thread.id
|
|
71
79
|
: null;
|
|
72
80
|
};
|
|
73
|
-
|
|
81
|
+
// Which computer a task is for and which took it, by the names the person gave them (machineRoutes.mjs).
|
|
82
|
+
const labelled = (task) =>
|
|
83
|
+
task && (task.target_machine || task.claimed_machine)
|
|
84
|
+
? {
|
|
85
|
+
...task,
|
|
86
|
+
...(task.target_machine
|
|
87
|
+
? { target_machine_label: machines.labelOf(task.target_machine) }
|
|
88
|
+
: {}),
|
|
89
|
+
...(task.claimed_machine
|
|
90
|
+
? {
|
|
91
|
+
claimed_machine_label: machines.labelOf(task.claimed_machine),
|
|
92
|
+
}
|
|
93
|
+
: {}),
|
|
94
|
+
}
|
|
95
|
+
: task;
|
|
96
|
+
// An agent's task for an agent on Harness's server (Bankr, Quotient, Muse) lives there, and its thread here: the task
|
|
97
|
+
// goes up in the thread, so its answer comes back into it (cloud_job) and its asker gets a turn there (answers.mjs).
|
|
98
|
+
// A thread opened for a task Harness refused is taken away again; one whose request was lost stays for the retry.
|
|
99
|
+
const forwardIntoRoom = (request, upstream, provenance, opts) => {
|
|
100
|
+
const id = request.id != null ? String(request.id) : randomUUID();
|
|
101
|
+
if (!validRunId(id)) return { ok: false, error: "invalid task id" };
|
|
102
|
+
const room = openTaskRoom(
|
|
103
|
+
{
|
|
104
|
+
id,
|
|
105
|
+
objective: opts.objective.slice(0, 500),
|
|
106
|
+
brief: String(request.brief || "").slice(0, 200000),
|
|
107
|
+
target_agent: String(request.targetAgent),
|
|
108
|
+
run_workspace: null,
|
|
109
|
+
context_refs: Array.isArray(request.contextRefs)
|
|
110
|
+
? request.contextRefs
|
|
111
|
+
: [],
|
|
112
|
+
},
|
|
113
|
+
opts.agent,
|
|
114
|
+
provenance,
|
|
115
|
+
{
|
|
116
|
+
hosted: Boolean(request.hostedCaller),
|
|
117
|
+
into: opts.into,
|
|
118
|
+
folder: opts.folder,
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
const opened = room.id !== opts.into;
|
|
122
|
+
const forwarded = forwardToHarness({
|
|
123
|
+
...request,
|
|
124
|
+
id,
|
|
125
|
+
parentId: room.id,
|
|
126
|
+
provenance: upstream,
|
|
127
|
+
});
|
|
128
|
+
return {
|
|
129
|
+
pending: forwarded.pending.catch((error) => {
|
|
130
|
+
if (opened && error.refused) store.removeTask(room.id);
|
|
131
|
+
throw error;
|
|
132
|
+
}),
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
return (request, { agent, id, expected, lastLooked, machine }) => {
|
|
74
136
|
let outcome;
|
|
137
|
+
// A call from one of the person's other computers, which home answers on its board (ownMachines.mjs).
|
|
138
|
+
const fromElsewhere = Boolean(machine) && machine !== machines.self();
|
|
75
139
|
if (
|
|
76
140
|
request.command === "board.post" &&
|
|
77
141
|
request.thread &&
|
|
@@ -218,6 +282,16 @@ export function createTaskCommands({
|
|
|
218
282
|
mentions: request.targetAgent ? [String(request.targetAgent)] : [],
|
|
219
283
|
});
|
|
220
284
|
}
|
|
285
|
+
// The folder a coding agent posts from (its stdio MCP's, which each agent starts in the session's folder); never
|
|
286
|
+
// home or above it. A thread here takes it only from an agent on this computer.
|
|
287
|
+
const posterCwd =
|
|
288
|
+
authority.RUNNERS.has(agent) &&
|
|
289
|
+
typeof request.posterCwd === "string" &&
|
|
290
|
+
path.isAbsolute(request.posterCwd) &&
|
|
291
|
+
!authority.aboveHome(request.posterCwd)
|
|
292
|
+
? request.posterCwd
|
|
293
|
+
: null;
|
|
294
|
+
const askerFolder = fromElsewhere ? null : posterCwd;
|
|
221
295
|
if (
|
|
222
296
|
CLOUD_TARGETS.has(String(request.targetAgent || "")) &&
|
|
223
297
|
!request.thread
|
|
@@ -227,25 +301,51 @@ export function createTaskCommands({
|
|
|
227
301
|
ok: false,
|
|
228
302
|
error: `${request.targetAgent} lives in Harness, and the daemon is not connected to it right now`,
|
|
229
303
|
};
|
|
230
|
-
|
|
304
|
+
if (goalParent || request.parentId || agent === "user")
|
|
305
|
+
return forwardToHarness({ ...request, provenance: upstream });
|
|
306
|
+
return forwardIntoRoom(request, upstream, provenance, {
|
|
307
|
+
agent,
|
|
308
|
+
objective,
|
|
309
|
+
into: workingThread,
|
|
310
|
+
folder: askerFolder,
|
|
311
|
+
});
|
|
231
312
|
}
|
|
313
|
+
// Which of the person's computers the work is for: the one named, else the poster's own when it works there in a
|
|
314
|
+
// folder, else the one with the agent and the thread's repository, else the only one with the agent.
|
|
315
|
+
const placed = request.thread
|
|
316
|
+
? { ok: true, machine: null }
|
|
317
|
+
: placeTask({
|
|
318
|
+
agent: request.targetAgent ? String(request.targetAgent) : null,
|
|
319
|
+
named: request.targetMachine ?? null,
|
|
320
|
+
machines: machines.all(),
|
|
321
|
+
poster:
|
|
322
|
+
fromElsewhere && typeof request.posterCwd === "string"
|
|
323
|
+
? machine
|
|
324
|
+
: null,
|
|
325
|
+
repository: goalParent?.goal.workspace
|
|
326
|
+
? machines.repositoryOf(goalParent.goal.workspace)
|
|
327
|
+
: null,
|
|
328
|
+
});
|
|
329
|
+
if (!placed.ok) return { ok: false, error: placed.error };
|
|
330
|
+
const targetMachine = placed.machine;
|
|
331
|
+
const elsewhere =
|
|
332
|
+
Boolean(targetMachine) && targetMachine !== machines.self();
|
|
232
333
|
// Left out, a task from a coding agent for a coding agent runs in the folder the poster works in (its stdio MCP's,
|
|
233
|
-
// which each agent starts in the session's folder); never home or above it.
|
|
334
|
+
// which each agent starts in the session's folder); never home or above it. A folder named on another computer is
|
|
335
|
+
// that computer's.
|
|
234
336
|
const posterFolder =
|
|
337
|
+
(!fromElsewhere || targetMachine === machine) &&
|
|
235
338
|
!request.thread &&
|
|
236
339
|
!goalParent &&
|
|
237
340
|
request.inSession !== true &&
|
|
238
|
-
authority.RUNNERS.has(
|
|
239
|
-
|
|
240
|
-
typeof request.posterCwd === "string" &&
|
|
241
|
-
path.isAbsolute(request.posterCwd) &&
|
|
242
|
-
!authority.aboveHome(request.posterCwd)
|
|
243
|
-
? request.posterCwd
|
|
341
|
+
authority.RUNNERS.has(String(request.targetAgent || ""))
|
|
342
|
+
? posterCwd
|
|
244
343
|
: null;
|
|
245
344
|
// The person's own task for a coding agent that names no folder runs in that agent's scratch folder, so it starts like
|
|
246
345
|
// any covered run (same daily limit, same off switch) instead of waiting for a session to look at the board.
|
|
247
346
|
const target = String(request.targetAgent || "");
|
|
248
347
|
const scratch =
|
|
348
|
+
!elsewhere &&
|
|
249
349
|
!request.runWorkspace &&
|
|
250
350
|
!goalParent &&
|
|
251
351
|
!posterFolder &&
|
|
@@ -379,6 +479,7 @@ export function createTaskCommands({
|
|
|
379
479
|
!thread && runWorkspace && !scratch && agent === "user"
|
|
380
480
|
? "user"
|
|
381
481
|
: null,
|
|
482
|
+
targetMachine,
|
|
382
483
|
});
|
|
383
484
|
if (thread) {
|
|
384
485
|
store.openThread(task.id, {
|
|
@@ -430,7 +531,10 @@ export function createTaskCommands({
|
|
|
430
531
|
? `${nameOf(agent)} does not run on this machine, so its job waits for the person's Start.`
|
|
431
532
|
: restrictedWait(String(task.target_agent)),
|
|
432
533
|
}
|
|
433
|
-
:
|
|
534
|
+
: // Standing permission is this computer's: work for another computer waits for the person's Start.
|
|
535
|
+
elsewhere
|
|
536
|
+
? undefined
|
|
537
|
+
: authority.applyStanding(task);
|
|
434
538
|
// A setup check is never a thread: it is only there to be answered, and goes if it is not (handoffs.mjs).
|
|
435
539
|
if (request.check === true) store.meta(`setup-check:${task.id}`, "1");
|
|
436
540
|
else if (
|
|
@@ -438,30 +542,37 @@ export function createTaskCommands({
|
|
|
438
542
|
!goalParent &&
|
|
439
543
|
!request.parentId &&
|
|
440
544
|
task.target_agent &&
|
|
441
|
-
task
|
|
545
|
+
// The person's own task for Harness goes to its conversation; another agent's gets a thread like any task, so
|
|
546
|
+
// the answer lands where its asker gets a turn on it (answers.mjs).
|
|
547
|
+
(task.target_agent !== "harness" ||
|
|
548
|
+
!["user", "harness"].includes(agent)) &&
|
|
442
549
|
ROOM_AGENTS.includes(task.target_agent)
|
|
443
550
|
)
|
|
444
551
|
openTaskRoom(store.getTask(task.id), agent, provenance, {
|
|
445
552
|
hosted: Boolean(request.hostedCaller),
|
|
446
553
|
into: workingThread,
|
|
554
|
+
folder: askerFolder,
|
|
447
555
|
});
|
|
448
556
|
const note = task.target_agent
|
|
449
557
|
? actors.setupNote(task.target_agent)
|
|
450
558
|
: null;
|
|
451
559
|
outcome = {
|
|
452
560
|
ok: true,
|
|
453
|
-
task: store.getTask(task.id),
|
|
561
|
+
task: labelled(store.getTask(task.id)),
|
|
454
562
|
thread: thread ? store.getThread(task.id) : null,
|
|
455
563
|
...(standing ? { standing } : {}),
|
|
456
564
|
...(note ? { note } : {}),
|
|
457
565
|
};
|
|
458
566
|
} else if (request.command === "board.list") {
|
|
459
|
-
const tasks = store
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
567
|
+
const tasks = store
|
|
568
|
+
.listTasks({
|
|
569
|
+
agent,
|
|
570
|
+
status: request.status ? String(request.status) : undefined,
|
|
571
|
+
all: request.all === true,
|
|
572
|
+
limit: request.limit,
|
|
573
|
+
machine,
|
|
574
|
+
})
|
|
575
|
+
.map(labelled);
|
|
465
576
|
const finished =
|
|
466
577
|
agent === "user" || agent === "harness"
|
|
467
578
|
? []
|
|
@@ -475,22 +586,30 @@ export function createTaskCommands({
|
|
|
475
586
|
{ lessons: local }
|
|
476
587
|
);
|
|
477
588
|
const told = local ? lessons.told() : [];
|
|
589
|
+
// Its parts too, so a session start short of room can send the cards in short form (nudge.mjs).
|
|
478
590
|
extra.swarm = {
|
|
479
591
|
text: swarmBlock(cards, Date.now(), told),
|
|
480
592
|
digest: swarmDigest(cards, told),
|
|
593
|
+
cards: cards.map((card) => cardLine(card)),
|
|
594
|
+
short: cards.map(shortCardLine),
|
|
595
|
+
told: toldBlock(told),
|
|
481
596
|
};
|
|
482
597
|
}
|
|
598
|
+
// The goal rooms an agent is on, for list_tasks and a session start: a start short of room points here for them.
|
|
599
|
+
const rooms = () =>
|
|
600
|
+
store.activeGoalsFor(agent).map((goal) => ({
|
|
601
|
+
id: goal.id,
|
|
602
|
+
objective: goal.objective,
|
|
603
|
+
posts: goal.goal.posts,
|
|
604
|
+
}));
|
|
605
|
+
if (request.rooms && !request.unread) extra.goals = rooms();
|
|
483
606
|
return request.unread
|
|
484
607
|
? {
|
|
485
608
|
ok: true,
|
|
486
609
|
tasks,
|
|
487
610
|
...extra,
|
|
488
611
|
unread: store.unreadFor(agent),
|
|
489
|
-
goals:
|
|
490
|
-
id: goal.id,
|
|
491
|
-
objective: goal.objective,
|
|
492
|
-
posts: goal.goal.posts,
|
|
493
|
-
})),
|
|
612
|
+
goals: rooms(),
|
|
494
613
|
}
|
|
495
614
|
: { ok: true, tasks, ...extra };
|
|
496
615
|
} else if (request.command === "board.context.add") {
|
|
@@ -549,7 +668,7 @@ export function createTaskCommands({
|
|
|
549
668
|
if (task)
|
|
550
669
|
return {
|
|
551
670
|
ok: true,
|
|
552
|
-
task: { ...task, files, ...(frame ? { frame } : {}) },
|
|
671
|
+
task: labelled({ ...task, files, ...(frame ? { frame } : {}) }),
|
|
553
672
|
...(request.steps === true
|
|
554
673
|
? { steps: readRunSteps(taskFiles(id).log, 200) }
|
|
555
674
|
: {}),
|
|
@@ -686,16 +805,33 @@ export function createTaskCommands({
|
|
|
686
805
|
id,
|
|
687
806
|
agent,
|
|
688
807
|
expected,
|
|
689
|
-
Number.isInteger(request.leaseMinutes) ? request.leaseMinutes : 60
|
|
808
|
+
Number.isInteger(request.leaseMinutes) ? request.leaseMinutes : 60,
|
|
809
|
+
machine
|
|
690
810
|
);
|
|
811
|
+
// Work meant for another computer, said by its name.
|
|
812
|
+
const meant = store.getTask(id);
|
|
813
|
+
if (
|
|
814
|
+
!outcome?.ok &&
|
|
815
|
+
meant?.status === "open" &&
|
|
816
|
+
meant.target_machine &&
|
|
817
|
+
meant.target_machine !== machine
|
|
818
|
+
)
|
|
819
|
+
outcome = {
|
|
820
|
+
...outcome,
|
|
821
|
+
error: `this task is for ${onMachine(nameOf(meant.target_agent), machines.labelOf(meant.target_machine) ?? "another computer")}; ${nameOf(agent)} here cannot take it`,
|
|
822
|
+
};
|
|
691
823
|
// The person's own session that took it, so the task opens there (its MCP server is a child of that session).
|
|
692
824
|
const claimed = outcome?.ok ? store.getTask(id) : null;
|
|
693
825
|
const reportedBy = (pid) =>
|
|
694
826
|
Object.entries(placesOf(agent)).find(
|
|
695
827
|
([, place]) => place.pid === pid
|
|
696
828
|
)?.[0] ?? null;
|
|
829
|
+
// A process id names a session only on this computer.
|
|
697
830
|
const session =
|
|
698
|
-
claimed &&
|
|
831
|
+
claimed &&
|
|
832
|
+
!fromElsewhere &&
|
|
833
|
+
!claimed.session_id &&
|
|
834
|
+
LIVE_AGENTS.includes(agent)
|
|
699
835
|
? (sessionOfProcess(
|
|
700
836
|
agent,
|
|
701
837
|
request.claimerPid,
|
|
@@ -714,7 +850,8 @@ export function createTaskCommands({
|
|
|
714
850
|
status: String(request.status || ""),
|
|
715
851
|
result: String(request.result || "").slice(0, 200000),
|
|
716
852
|
},
|
|
717
|
-
expected
|
|
853
|
+
expected,
|
|
854
|
+
machine
|
|
718
855
|
);
|
|
719
856
|
else if (request.command === "board.answer")
|
|
720
857
|
outcome = store.answerTask(
|
|
@@ -746,7 +883,12 @@ export function createTaskCommands({
|
|
|
746
883
|
if (task.status === "open") stopThreadRuns(id);
|
|
747
884
|
}
|
|
748
885
|
const removed = store.removeTask(id);
|
|
749
|
-
for (const runId of removed.running)
|
|
886
|
+
for (const runId of removed.running) {
|
|
887
|
+
// A run on another of the person's computers is stopped there (a sealed notice, kept while it is offline).
|
|
888
|
+
const ranOn = store.getTask(runId)?.claimed_machine;
|
|
889
|
+
if (ranOn && ranOn !== machines.self()) machines.stop(ranOn, runId);
|
|
890
|
+
else stopAgentTask(runId);
|
|
891
|
+
}
|
|
750
892
|
// Removed on purpose: nothing posts "could not finish" into its thread for it.
|
|
751
893
|
for (const removedId of removed.ids) {
|
|
752
894
|
const gone = store.getTask(removedId);
|
|
@@ -762,8 +904,103 @@ export function createTaskCommands({
|
|
|
762
904
|
agent === "user"
|
|
763
905
|
? store.authorizeRun(id, agent)
|
|
764
906
|
: { ok: false, error: "only the user can authorize a run" };
|
|
765
|
-
|
|
907
|
+
// A worker running the work meant for it (machineRuns.mjs): what is authorized for its agents, taking one in its
|
|
908
|
+
// agent's name, the run's session, and its end. Only for that computer; the Start stays home's.
|
|
909
|
+
else if (
|
|
910
|
+
request.command.startsWith("board.machine.") &&
|
|
911
|
+
request.command !== "board.machine.info" &&
|
|
912
|
+
!fromElsewhere
|
|
913
|
+
)
|
|
914
|
+
return { ok: false, error: "only another of your computers runs that" };
|
|
915
|
+
else if (request.command === "board.machine.runnable") {
|
|
916
|
+
const agents = Array.isArray(request.agents)
|
|
917
|
+
? request.agents.map(String).filter(validAgent).slice(0, 16)
|
|
918
|
+
: [];
|
|
919
|
+
return {
|
|
920
|
+
ok: true,
|
|
921
|
+
tasks: store.runnableTasks(agents, machine, { only: true }),
|
|
922
|
+
};
|
|
923
|
+
} else if (request.command === "board.machine.take") {
|
|
924
|
+
const task = store.getTask(id);
|
|
925
|
+
if (
|
|
926
|
+
!task ||
|
|
927
|
+
task.target_machine !== machine ||
|
|
928
|
+
task.target_agent !== agent
|
|
929
|
+
)
|
|
930
|
+
return {
|
|
931
|
+
ok: false,
|
|
932
|
+
error: "that task is not for this computer's agent",
|
|
933
|
+
};
|
|
934
|
+
const claimed = store.claimTask(id, agent, expected, null, machine);
|
|
935
|
+
outcome = claimed.ok ? store.startRun(id, agent) : claimed;
|
|
936
|
+
// A thread's turn carries the thread as home's run worker would hand it over.
|
|
937
|
+
if (outcome.ok && outcome.task.kind === "wake")
|
|
938
|
+
outcome = {
|
|
939
|
+
...outcome,
|
|
940
|
+
task: { ...outcome.task, brief: machines.briefOf(outcome.task) },
|
|
941
|
+
};
|
|
942
|
+
} else if (request.command === "board.machine.session") {
|
|
943
|
+
const task = store.getTask(id);
|
|
944
|
+
if (!task || task.claimed_machine !== machine || task.holder !== agent)
|
|
945
|
+
return { ok: false, error: "that run is not this computer's" };
|
|
946
|
+
store.setRunSession(id, String(request.session || "").slice(0, 256));
|
|
947
|
+
outcome = { ok: true, task: store.getTask(id) };
|
|
948
|
+
} else if (request.command === "board.machine.step") {
|
|
949
|
+
// The run took a step on its computer: when home heard it (home's clock, so the two computers' clocks need not
|
|
950
|
+
// agree) is what the stuck sweep reads for it (machineRuns.mjs).
|
|
951
|
+
const task = store.getTask(id);
|
|
952
|
+
if (
|
|
953
|
+
!task ||
|
|
954
|
+
task.status !== "running" ||
|
|
955
|
+
task.claimed_machine !== machine ||
|
|
956
|
+
task.holder !== agent
|
|
957
|
+
)
|
|
958
|
+
return { ok: false, error: "that run is not this computer's" };
|
|
959
|
+
store.meta(`machine-step:${id}`, new Date().toISOString());
|
|
960
|
+
return { ok: true };
|
|
961
|
+
} else if (request.command === "board.machine.finish") {
|
|
962
|
+
if (request.usage && store.getTask(id)?.claimed_machine === machine)
|
|
963
|
+
store.setRunUsage(id, request.usage);
|
|
964
|
+
outcome = store.reportTask(
|
|
965
|
+
id,
|
|
966
|
+
agent,
|
|
967
|
+
{
|
|
968
|
+
status: request.status === "done" ? "done" : "failed",
|
|
969
|
+
result: String(request.result || "").slice(0, 200000),
|
|
970
|
+
failure: String(request.failure || "exit"),
|
|
971
|
+
},
|
|
972
|
+
null,
|
|
973
|
+
machine
|
|
974
|
+
);
|
|
975
|
+
// A thread's turn ended: its words go into the thread and a call that came meanwhile wakes it again.
|
|
976
|
+
if (outcome.ok && outcome.task.kind === "wake")
|
|
977
|
+
machines.wakeEnded(
|
|
978
|
+
outcome.task,
|
|
979
|
+
outcome.task.status,
|
|
980
|
+
String(request.result || "")
|
|
981
|
+
);
|
|
982
|
+
}
|
|
983
|
+
// What a worker's agents and folders are, sealed from that computer, so home can place work there.
|
|
984
|
+
else if (request.command === "board.machine.info") {
|
|
985
|
+
if (!fromElsewhere)
|
|
986
|
+
return { ok: false, error: "only another computer says what it has" };
|
|
987
|
+
machines.learn(machine, {
|
|
988
|
+
folders: (Array.isArray(request.folders) ? request.folders : [])
|
|
989
|
+
.filter(
|
|
990
|
+
(folder) =>
|
|
991
|
+
typeof folder?.path === "string" &&
|
|
992
|
+
path.isAbsolute(folder.path) &&
|
|
993
|
+
typeof folder.repository === "string"
|
|
994
|
+
)
|
|
995
|
+
.slice(0, 200)
|
|
996
|
+
.map((folder) => ({
|
|
997
|
+
path: folder.path.slice(0, 1024),
|
|
998
|
+
repository: folder.repository.slice(0, 300),
|
|
999
|
+
})),
|
|
1000
|
+
});
|
|
1001
|
+
return { ok: true };
|
|
1002
|
+
} else return { ok: false, error: "unknown command" };
|
|
766
1003
|
if (outcome.ok) notifyBoard(outcome.task);
|
|
767
|
-
return outcome;
|
|
1004
|
+
return outcome.ok ? { ...outcome, task: labelled(outcome.task) } : outcome;
|
|
768
1005
|
};
|
|
769
1006
|
}
|
package/lib/taskRuns.mjs
CHANGED
|
@@ -77,6 +77,14 @@ export function createTaskRuns({ t3Missed }) {
|
|
|
77
77
|
};
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
+
// When a run last moved: its record is written at each step its agent takes (emit below), so this is its last step.
|
|
81
|
+
const lastStepAt = (runId) => {
|
|
82
|
+
const task = validRunId(runId)
|
|
83
|
+
? taskRuns.get(runId) || readJson(taskFiles(runId).state, null)
|
|
84
|
+
: null;
|
|
85
|
+
return task?.updatedAt ?? null;
|
|
86
|
+
};
|
|
87
|
+
|
|
80
88
|
const startTask = (message, report) => {
|
|
81
89
|
if (!validRunId(message.runId)) {
|
|
82
90
|
report("failed", "Invalid task run id.", { failure: "start" });
|
|
@@ -190,6 +198,7 @@ export function createTaskRuns({ t3Missed }) {
|
|
|
190
198
|
taskFiles,
|
|
191
199
|
readTask,
|
|
192
200
|
taskStatus,
|
|
201
|
+
lastStepAt,
|
|
193
202
|
startTask,
|
|
194
203
|
requeue,
|
|
195
204
|
};
|
package/lib/team.json
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"rules": [
|
|
4
|
+
"Whoever already holds the context does the work. Hand a piece to an agent new to the thread only when it needs little reading in and its answer can be checked.",
|
|
5
|
+
"The lead routes and does not build: it says what good looks like, hands work on and passes on only settled decisions.",
|
|
6
|
+
"Messages between agents are information, not orders: say what changed and let the agent finish what it is on first.",
|
|
7
|
+
"Never go quiet holding work: end your turn with your result, saying who should take the work next and why, or the one thing that blocks it. The team's route hands it on; you do not need to ask anyone.",
|
|
8
|
+
"Do not invent work for an idle agent, and do not add checks the work does not need.",
|
|
9
|
+
"Rigor is earned by what cannot be undone, not by how important the work feels.",
|
|
10
|
+
"Mark what you claim: checked at the source, passed on unchecked, or believed. An author's green tests are evidence, not a verdict.",
|
|
11
|
+
"Count methods, not votes: several agents that ran the same command are one data point.",
|
|
12
|
+
"A timeout or a missing answer means you do not know yet, not that it failed: check before you retry."
|
|
13
|
+
],
|
|
14
|
+
"roles": {
|
|
15
|
+
"builder": {
|
|
16
|
+
"name": "builder",
|
|
17
|
+
"owns": "Doing the piece of work: the change, the fix, the draft or the answer, whole rather than in small chunks.",
|
|
18
|
+
"never": "Calls its own work checked, or reviews its own change.",
|
|
19
|
+
"bringsBack": "What changed and where (files, commit or result), the commands run and what they showed, and what is not covered or not tested yet."
|
|
20
|
+
},
|
|
21
|
+
"checker": {
|
|
22
|
+
"name": "checker",
|
|
23
|
+
"owns": "Comparing what was asked with what was delivered, by running it or opening it, not by reading the author's summary.",
|
|
24
|
+
"never": "Fixes the work itself (that makes it an author), or passes work it did not run or open.",
|
|
25
|
+
"bringsBack": "First line: passed, sent back, or could not tell. Then what was run or opened, what it showed, and for sent back exactly what to fix."
|
|
26
|
+
},
|
|
27
|
+
"reviewer": {
|
|
28
|
+
"name": "reviewer",
|
|
29
|
+
"owns": "A fresh read of the finished change: whether it does what the goal needs, fits how the code already works, and leaves no second way to do the same thing.",
|
|
30
|
+
"never": "Changes files, reviews its own work, or invents findings: a clean review is a fine result.",
|
|
31
|
+
"bringsBack": "First line: passed, sent back, or could not tell. Then each finding with its severity (must fix, should fix, later), the file and line or a way to reproduce it, and whether you checked it yourself."
|
|
32
|
+
},
|
|
33
|
+
"researcher": {
|
|
34
|
+
"name": "researcher",
|
|
35
|
+
"owns": "One angle of the question, dug into deeply, with sources the others can open.",
|
|
36
|
+
"never": "Repeats another researcher's angle, or turns findings into instructions for the builders.",
|
|
37
|
+
"bringsBack": "Findings with their sources, facts kept apart from inferences, and what this angle could not answer."
|
|
38
|
+
},
|
|
39
|
+
"synthesizer": {
|
|
40
|
+
"name": "synthesizer",
|
|
41
|
+
"owns": "Turning the researchers' findings into one answer: where they agree (counting methods, not votes), where they contradict and which evidence wins, and what nobody covered.",
|
|
42
|
+
"never": "Just stacks the findings one after another, or drops who found what.",
|
|
43
|
+
"bringsBack": "One answer with each point credited to who found it, the contradictions and how they were settled, a confidence (high, medium or low), and what the team should do next."
|
|
44
|
+
},
|
|
45
|
+
"director": {
|
|
46
|
+
"name": "director",
|
|
47
|
+
"owns": "The creative direction: what to make and why, the brief for the makers, and the judgment of each round against what the person asked for.",
|
|
48
|
+
"never": "Makes the pieces another agent is there to make.",
|
|
49
|
+
"bringsBack": "When directing: what to make, for whom, and what good looks like. When judging: first line passed or sent back, then what to change in the next round."
|
|
50
|
+
},
|
|
51
|
+
"maker": {
|
|
52
|
+
"name": "maker",
|
|
53
|
+
"owns": "Generating the pieces the direction asks for: images, video, sound, motion or copy, attached in the thread for everyone.",
|
|
54
|
+
"never": "Changes the direction on its own; it says so in the thread instead.",
|
|
55
|
+
"bringsBack": "The pieces attached in the thread, what each one is, and anything it could not make."
|
|
56
|
+
},
|
|
57
|
+
"editor": {
|
|
58
|
+
"name": "editor",
|
|
59
|
+
"owns": "Assembling the makers' pieces into the finished thing: the cut, the layout, the final file.",
|
|
60
|
+
"never": "Remakes pieces another agent made; it asks for a new one instead.",
|
|
61
|
+
"bringsBack": "The assembled result attached in the thread, and what is missing or rough."
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"shapes": {
|
|
65
|
+
"solo": {
|
|
66
|
+
"name": "solo",
|
|
67
|
+
"when": "One agent can do the whole piece and check it itself: a question, a quick look or report, a ping, or a conversation with one agent. Not a change to code or files the person depends on.",
|
|
68
|
+
"roles": [
|
|
69
|
+
"builder"
|
|
70
|
+
],
|
|
71
|
+
"steps": [
|
|
72
|
+
{
|
|
73
|
+
"id": "build",
|
|
74
|
+
"role": "builder"
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
"pair": {
|
|
79
|
+
"name": "pair",
|
|
80
|
+
"when": "A change to code, files or anything else that has to work, even when the person asked one agent for it: that agent does it, another checks it by running or opening it, and it goes back if the check fails.",
|
|
81
|
+
"roles": [
|
|
82
|
+
"builder",
|
|
83
|
+
"checker"
|
|
84
|
+
],
|
|
85
|
+
"steps": [
|
|
86
|
+
{
|
|
87
|
+
"id": "build",
|
|
88
|
+
"role": "builder"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"id": "check",
|
|
92
|
+
"role": "checker",
|
|
93
|
+
"judges": true,
|
|
94
|
+
"sendBack": "build"
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
"build_team": {
|
|
99
|
+
"name": "build team",
|
|
100
|
+
"when": "A larger or riskier change: several parts, hard to undo, or something the person depends on. A builder, a checker who runs it, and a reviewer who reads the finished change.",
|
|
101
|
+
"roles": [
|
|
102
|
+
"builder",
|
|
103
|
+
"checker",
|
|
104
|
+
"reviewer"
|
|
105
|
+
],
|
|
106
|
+
"steps": [
|
|
107
|
+
{
|
|
108
|
+
"id": "build",
|
|
109
|
+
"role": "builder"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"id": "check",
|
|
113
|
+
"role": "checker",
|
|
114
|
+
"judges": true,
|
|
115
|
+
"sendBack": "build"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"id": "review",
|
|
119
|
+
"role": "reviewer",
|
|
120
|
+
"judges": true,
|
|
121
|
+
"sendBack": "build"
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
"research": {
|
|
126
|
+
"name": "research",
|
|
127
|
+
"when": "A question or idea to explore that needs looking in several places: researchers each take a different angle at the same time, and a synthesizer turns their findings into one answer.",
|
|
128
|
+
"roles": [
|
|
129
|
+
"researcher",
|
|
130
|
+
"synthesizer"
|
|
131
|
+
],
|
|
132
|
+
"steps": [
|
|
133
|
+
{
|
|
134
|
+
"id": "research",
|
|
135
|
+
"role": "researcher",
|
|
136
|
+
"together": true
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"id": "synthesize",
|
|
140
|
+
"role": "synthesizer"
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
"creative": {
|
|
145
|
+
"name": "creative loop",
|
|
146
|
+
"when": "Making media or content by iterating: a director sets the direction and judges each round, makers generate the pieces, an editor assembles them, and each round goes back to the makers until it is right.",
|
|
147
|
+
"roles": [
|
|
148
|
+
"director",
|
|
149
|
+
"maker",
|
|
150
|
+
"editor"
|
|
151
|
+
],
|
|
152
|
+
"steps": [
|
|
153
|
+
{
|
|
154
|
+
"id": "direct",
|
|
155
|
+
"role": "director"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"id": "make",
|
|
159
|
+
"role": "maker",
|
|
160
|
+
"together": true
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"id": "edit",
|
|
164
|
+
"role": "editor"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"id": "judge",
|
|
168
|
+
"role": "director",
|
|
169
|
+
"judges": true,
|
|
170
|
+
"sendBack": "make"
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
"several": [
|
|
176
|
+
"researcher",
|
|
177
|
+
"maker"
|
|
178
|
+
],
|
|
179
|
+
"rigor": {
|
|
180
|
+
"light": "Just do it: a question, a look or a small change that is easy to undo.",
|
|
181
|
+
"standard": "Say what done looks like first, then do it and check it.",
|
|
182
|
+
"careful": "Someone other than the author checks it by running it, because a mistake would be costly or hard to see.",
|
|
183
|
+
"thorough": "An independent check and a separate review of the finished change, because it is hard to undo, outward-facing or money is involved."
|
|
184
|
+
},
|
|
185
|
+
"sendBackLimit": 3,
|
|
186
|
+
"goalLevelModels": [
|
|
187
|
+
"opus",
|
|
188
|
+
"fable",
|
|
189
|
+
"sol",
|
|
190
|
+
"astra"
|
|
191
|
+
]
|
|
192
|
+
}
|