tryharness 0.7.45 → 0.7.54
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 +239 -14
- package/assets/dsh-plugin.mjs +72 -0
- package/assets/opencode-plugin.js +4 -3
- package/cli.mjs +497 -196
- package/lib/actorRoster.mjs +28 -5
- package/lib/adapters.mjs +165 -222
- package/lib/agentRuntimeConfig.mjs +36 -0
- package/lib/agentRuntimes.mjs +570 -0
- package/lib/agentSignIn.mjs +226 -0
- package/lib/atlas.mjs +7 -2
- package/lib/audit.mjs +643 -0
- package/lib/backupSetup.mjs +141 -0
- package/lib/boardAccess.mjs +8 -1
- package/lib/boardBackup.mjs +283 -0
- package/lib/boardCommands.mjs +5 -10
- package/lib/boardFileCommands.mjs +2 -1
- package/lib/boardMirror.mjs +523 -0
- package/lib/boardProtocol.json +263 -6
- package/lib/boardTools.mjs +2 -6
- package/lib/boardWaits.mjs +102 -0
- package/lib/book.mjs +659 -0
- package/lib/bridge.mjs +26 -4
- package/lib/browserWake.mjs +60 -0
- package/lib/cards.mjs +159 -16
- package/lib/cloudBoot.mjs +124 -0
- package/lib/commands.mjs +25 -5
- package/lib/connectionTools.d.ts +13 -0
- package/lib/connectionTools.js +45 -0
- package/lib/connectorAuth.mjs +309 -0
- package/lib/connectorCatalog.json +41 -0
- package/lib/connectorCommands.mjs +121 -0
- package/lib/connectorGoogle.mjs +513 -0
- package/lib/connectors.mjs +805 -0
- package/lib/context.mjs +18 -4
- package/lib/contractGate.mjs +377 -0
- package/lib/coordinator.mjs +152 -39
- package/lib/coreModels.mjs +78 -0
- package/lib/daemon.mjs +973 -54
- package/lib/desk.mjs +239 -0
- package/lib/desktop.mjs +113 -8
- package/lib/digest.mjs +32 -0
- package/lib/directLink.mjs +283 -0
- package/lib/environments.mjs +825 -0
- package/lib/folders.mjs +4 -4
- package/lib/gitHost.mjs +174 -0
- package/lib/goalCommands.mjs +58 -14
- package/lib/hookDialects.mjs +298 -0
- package/lib/inference.mjs +263 -152
- package/lib/landed.mjs +887 -0
- package/lib/lessons.mjs +6 -0
- package/lib/lineup.mjs +324 -0
- package/lib/live.mjs +284 -13
- package/lib/localmodels.mjs +10 -0
- package/lib/machineIdentity.mjs +3 -0
- package/lib/machineRoutes.mjs +40 -2
- package/lib/machineRuns.mjs +30 -3
- package/lib/machineSeal.mjs +69 -10
- package/lib/mcp-stdio.mjs +189 -120
- package/lib/mcpRelay.mjs +119 -0
- package/lib/members.json +26 -0
- package/lib/members.mjs +33 -0
- package/lib/modelMemory.mjs +100 -0
- package/lib/models.mjs +48 -15
- package/lib/museSession.mjs +122 -0
- package/lib/nativeHost.mjs +203 -0
- package/lib/neovim.mjs +126 -0
- package/lib/network.mjs +7 -2
- package/lib/nudge.mjs +57 -18
- package/lib/onboard.mjs +430 -1
- package/lib/oneclawLocal.mjs +150 -0
- package/lib/ownMachines.mjs +828 -39
- package/lib/pairing.mjs +182 -0
- package/lib/paths.mjs +8 -0
- package/lib/personModel.mjs +89 -0
- package/lib/phones.mjs +119 -3
- package/lib/placeCommands.mjs +27 -0
- package/lib/places.mjs +337 -9
- package/lib/plans.mjs +151 -27
- package/lib/profile.mjs +152 -0
- package/lib/projects.mjs +624 -137
- package/lib/readiness.mjs +400 -0
- package/lib/record.mjs +115 -0
- package/lib/repoLinks.mjs +354 -0
- package/lib/roomChannels.mjs +641 -0
- package/lib/runBrief.mjs +32 -2
- package/lib/runRequests.mjs +157 -0
- package/lib/runWorker.mjs +37 -9
- package/lib/runner.mjs +74 -11
- package/lib/secretPatterns.json +55 -0
- package/lib/secrets.mjs +10 -27
- package/lib/seen.mjs +102 -0
- package/lib/service.mjs +11 -6
- package/lib/sessionControl.mjs +386 -96
- package/lib/sessionIndex.mjs +5 -3
- package/lib/specialties.json +74 -0
- package/lib/specialties.mjs +477 -0
- package/lib/specialtyKeys.d.ts +3 -0
- package/lib/specialtyKeys.js +58 -0
- package/lib/specialtyNotice.mjs +147 -0
- package/lib/specialtySnapshot.mjs +138 -0
- package/lib/store.mjs +829 -29
- package/lib/subagents.mjs +8 -4
- package/lib/swarm.mjs +483 -37
- package/lib/swarmMemory.mjs +947 -0
- package/lib/t3.mjs +56 -17
- package/lib/taskCommands.mjs +91 -13
- package/lib/taskRuns.mjs +68 -11
- package/lib/team.json +253 -144
- package/lib/team.mjs +538 -147
- package/lib/threadLine.mjs +116 -0
- package/lib/threadRuns.mjs +78 -12
- package/lib/threadView.mjs +66 -16
- package/lib/tokenizer.mjs +405 -0
- package/lib/ui.mjs +16 -2
- package/lib/usageTotals.mjs +148 -0
- package/lib/vault.mjs +1144 -0
- package/lib/vaultCloud.mjs +117 -0
- package/lib/vaultCommands.mjs +201 -0
- package/lib/vaultTools.d.ts +12 -0
- package/lib/vaultTools.js +42 -0
- package/lib/windowAsks.mjs +42 -0
- package/lib/workFocus.mjs +59 -0
- package/lib/workLinks.mjs +90 -0
- package/lib/worktrees.mjs +51 -13
- package/package.json +10 -5
package/lib/team.mjs
CHANGED
|
@@ -1,162 +1,441 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { nameOf } from "./members.mjs";
|
|
3
|
+
import { specialtyName } from "./specialties.mjs";
|
|
4
|
+
import { namedFiles } from "./worktrees.mjs";
|
|
3
5
|
|
|
4
|
-
// How the agents in a thread work as a team (team.json, read by the server too through src/shared/team.ts):
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
6
|
+
// How the agents in a thread work as a team (team.json, read by the server too through src/shared/team.ts): one route,
|
|
7
|
+
// frame, make, check, combine, judge, whose steps the rigor picks, each step held by the agents Jev routed it to for the
|
|
8
|
+
// specialty it asks for (docs/swarm-organization.md, Routes). Without it, every round handed the next piece to whichever
|
|
9
|
+
// single agent looked likeliest, and the busiest agent did most of the work while nobody checked it or pulled parallel
|
|
10
|
+
// results together (board, October 20: 30 of 52 hand-ons to one agent, and 42 of 50 assemblies gave the whole message
|
|
11
|
+
// to one agent).
|
|
9
12
|
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
13
|
+
// Jev triages the goal in the thread's first assembly round (src/server/swarm/coordinator.ts teamPlan): its rigor,
|
|
14
|
+
// whether a framer splits it into pieces, the specialty each step asks for and who holds each. A goal that is split
|
|
15
|
+
// runs its frame first; the framer's report gives the pieces, and each is routed by Jev as it starts. The route is
|
|
16
|
+
// followed here: the round is told which step the thread is at, whether that step's agents have reported since it
|
|
17
|
+
// began, and where the work may go next (`exits`); Jev judges only what needs judgment (did a check pass), and the
|
|
18
|
+
// daemon moves the thread to the step the round chose. Every run is marked with the step it worked and the specialty
|
|
19
|
+
// that step asked for, and a check's outcome is written on the runs it judged, for the record (record.mjs).
|
|
14
20
|
|
|
15
21
|
export const TEAM = JSON.parse(
|
|
16
22
|
readFileSync(new URL("./team.json", import.meta.url), "utf8")
|
|
17
23
|
);
|
|
18
|
-
const
|
|
19
|
-
export const
|
|
24
|
+
const ROUTE = TEAM.route;
|
|
25
|
+
export const STEP_IDS = ROUTE.map((step) => step.id);
|
|
20
26
|
export const ROLE_IDS = Object.keys(TEAM.roles);
|
|
21
27
|
export const RIGOR_LEVELS = Object.keys(TEAM.rigor);
|
|
28
|
+
const stepOf = (id) => ROUTE.find((step) => step.id === id);
|
|
22
29
|
// Every runner's reported states that end a turn: a question to the person (needs_input) is not the step's end.
|
|
23
30
|
const FINISHED = new Set(["done", "failed", "unknown"]);
|
|
31
|
+
// The most pieces one framer's split is routed as; more read as one list.
|
|
32
|
+
const MOST_PIECES = 4;
|
|
24
33
|
|
|
25
|
-
/**
|
|
26
|
-
export const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
);
|
|
34
|
+
/** The role a step is held as when it asks for this specialty: named by the step and the specialty (team.json). */
|
|
35
|
+
export const roleFor = (step, specialty) =>
|
|
36
|
+
ROLE_IDS.find((role) =>
|
|
37
|
+
specialty ? TEAM.roles[role].steps[step]?.includes(specialty) : false
|
|
38
|
+
) ?? stepOf(step).role;
|
|
31
39
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
/**
|
|
41
|
+
* The steps a piece's route runs at a rigor: Combine below thorough only when several agents made it. A piece the
|
|
42
|
+
* framer split off has its frame already (its brief), and so does a goal whose makers the person tagged (their words).
|
|
43
|
+
*/
|
|
44
|
+
export const stepsFor = (rigor, { makers, framed }) =>
|
|
45
|
+
STEP_IDS.filter(
|
|
46
|
+
(id) =>
|
|
47
|
+
(TEAM.rigor[rigor].steps.includes(id) ||
|
|
48
|
+
(id === "combine" && (rigor === "thorough" || makers > 1))) &&
|
|
49
|
+
!(framed && id === "frame")
|
|
35
50
|
);
|
|
36
51
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
52
|
+
const holdersOf = (steps, id) =>
|
|
53
|
+
steps.find((step) => step.id === id)?.agents ?? [];
|
|
54
|
+
|
|
55
|
+
// A specialty on the list, else none (the route still runs; the run counts toward no specialty).
|
|
56
|
+
const KNOWN = new Set(
|
|
57
|
+
JSON.parse(
|
|
58
|
+
readFileSync(new URL("./specialties.json", import.meta.url), "utf8")
|
|
59
|
+
).headings.flatMap((heading) => heading.specialties.map(({ id }) => id))
|
|
60
|
+
);
|
|
61
|
+
const knownSpecialty = (id) => (KNOWN.has(String(id)) ? String(id) : null);
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A route as the round proposed it, kept only where it names known steps and agents of the swarm, with the person's
|
|
65
|
+
* choices over Jev's, step by step: an agent they tagged fills a step (Make, when Jev put it on none: "@codex fix this"
|
|
66
|
+
* puts Codex on Make), a pin holds the step whose specialty it is for unless a tagged agent does, and Jev's pick stands
|
|
67
|
+
* otherwise. The rigor then picks the steps that run. No agent checks or judges what it made, and the framer never
|
|
68
|
+
* judges the piece it framed: a pin that would do so gives way to Jev's pick, and a step left with no one is dropped
|
|
69
|
+
* and the thread says so (`unfilled`).
|
|
70
|
+
*/
|
|
71
|
+
export function validPlan(
|
|
72
|
+
proposed,
|
|
73
|
+
{ members, named = [], pins = {}, piece = false }
|
|
74
|
+
) {
|
|
41
75
|
const allowed = new Set(members);
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
76
|
+
const rigor = RIGOR_LEVELS.includes(proposed?.rigor)
|
|
77
|
+
? proposed.rigor
|
|
78
|
+
: "standard";
|
|
79
|
+
const split = !piece && Boolean(proposed?.split);
|
|
80
|
+
const given = new Map(
|
|
81
|
+
(Array.isArray(proposed?.steps) ? proposed.steps : [])
|
|
82
|
+
.filter((step) => STEP_IDS.includes(step?.id))
|
|
83
|
+
.map((step) => [
|
|
84
|
+
step.id,
|
|
85
|
+
{
|
|
86
|
+
specialty: knownSpecialty(step.specialty),
|
|
87
|
+
agents: [
|
|
88
|
+
...new Set(
|
|
89
|
+
(step.agents ?? [])
|
|
90
|
+
.map(String)
|
|
91
|
+
.filter((agent) => allowed.has(agent))
|
|
92
|
+
),
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
])
|
|
96
|
+
);
|
|
97
|
+
const tagged = named.filter((agent) => allowed.has(agent));
|
|
98
|
+
const placedByJev = new Set([...given.values()].flatMap((s) => s.agents));
|
|
99
|
+
const unplaced = tagged.filter((agent) => !placedByJev.has(agent));
|
|
100
|
+
const holders = {};
|
|
101
|
+
const pinned = new Set();
|
|
102
|
+
// Whom a step may not go to: a check or judgment never to a maker, a judgment never to the framer.
|
|
103
|
+
const barred = (id) =>
|
|
104
|
+
id === "check"
|
|
105
|
+
? holders.make
|
|
106
|
+
: id === "judge"
|
|
107
|
+
? [...holders.make, ...holders.frame]
|
|
108
|
+
: [];
|
|
109
|
+
const steps = STEP_IDS.map((id) => {
|
|
110
|
+
const step = given.get(id) ?? { specialty: null, agents: [] };
|
|
111
|
+
const taggedHere = step.agents.filter((agent) => tagged.includes(agent));
|
|
112
|
+
const pin = step.specialty ? pins[step.specialty] : null;
|
|
113
|
+
let agents = step.agents;
|
|
114
|
+
if (id === "make" && unplaced.length && !split)
|
|
115
|
+
agents = [...new Set([...taggedHere, ...unplaced])];
|
|
116
|
+
else if (taggedHere.length) agents = taggedHere;
|
|
117
|
+
else if (pin && allowed.has(pin) && !barred(id).includes(pin)) {
|
|
118
|
+
agents = [pin];
|
|
119
|
+
pinned.add(id);
|
|
120
|
+
}
|
|
121
|
+
// Make is never left empty while the person tagged someone.
|
|
122
|
+
if (id === "make" && !agents.length && !split) agents = tagged;
|
|
123
|
+
agents = stepOf(id).together
|
|
124
|
+
? agents.slice(0, TEAM.mostSideBySide)
|
|
125
|
+
: agents.slice(0, 1);
|
|
126
|
+
holders[id] = agents;
|
|
127
|
+
return { id, specialty: step.specialty, agents };
|
|
128
|
+
});
|
|
129
|
+
const makers = holders.make;
|
|
130
|
+
// A tagged maker means the person framed the work themselves, unless they also named who frames it.
|
|
131
|
+
const framedByTag =
|
|
132
|
+
makers.some((agent) => tagged.includes(agent)) &&
|
|
133
|
+
!holders.frame.some((agent) => tagged.includes(agent));
|
|
134
|
+
const running = split
|
|
135
|
+
? ["frame"]
|
|
136
|
+
: stepsFor(rigor, { makers: makers.length, framed: piece || framedByTag });
|
|
137
|
+
const unfilled = [];
|
|
138
|
+
const kept = steps
|
|
139
|
+
.filter((step) => running.includes(step.id))
|
|
140
|
+
.flatMap((step) => {
|
|
141
|
+
const own = step.agents.some((agent) => barred(step.id).includes(agent));
|
|
142
|
+
if (own || !step.agents.length) {
|
|
143
|
+
unfilled.push({ step: step.id, own });
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
return [
|
|
147
|
+
{
|
|
148
|
+
...step,
|
|
149
|
+
role: roleFor(step.id, step.specialty),
|
|
150
|
+
...(pinned.has(step.id) ? { pinned: true } : {}),
|
|
151
|
+
},
|
|
152
|
+
];
|
|
153
|
+
});
|
|
154
|
+
if (!kept.length) return null;
|
|
155
|
+
if (!split && !kept.some((step) => step.id === "make")) return null;
|
|
156
|
+
return { rigor, split, steps: kept, unfilled };
|
|
60
157
|
}
|
|
61
158
|
|
|
159
|
+
// The route as the thread says it: "frame: Claude Code (framer, planning and coordination); make: Codex (builder, ...)".
|
|
160
|
+
const lineup = (steps) =>
|
|
161
|
+
steps
|
|
162
|
+
.map(
|
|
163
|
+
(step) =>
|
|
164
|
+
`${step.id}: ${step.agents.map(nameOf).join(" and ")} (${TEAM.roles[step.role].name}${step.specialty ? `, ${specialtyName(step.specialty)}` : ""})`
|
|
165
|
+
)
|
|
166
|
+
.join("; ");
|
|
167
|
+
|
|
168
|
+
// Why a step of the route runs with nobody: the thread's words.
|
|
169
|
+
const unfilledLine = ({ step, own }) =>
|
|
170
|
+
own
|
|
171
|
+
? `No agent here could ${step} this without ${step === "judge" ? "judging" : "checking"} its own work, so it goes without a ${step}.`
|
|
172
|
+
: `No agent here was routed to ${step} it, so it goes without that step.`;
|
|
173
|
+
|
|
174
|
+
// The pieces a framer's report splits a goal into: each on its own line as "Piece:" and its brief (the framer's
|
|
175
|
+
// contract in team.json asks for exactly that form).
|
|
176
|
+
export const piecesIn = (text) =>
|
|
177
|
+
String(text || "")
|
|
178
|
+
.split("\n")
|
|
179
|
+
.map((line) =>
|
|
180
|
+
/^\s*(?:[-*]\s*)?\**piece\b[^:]{0,12}:\**\s*(.+)$/i
|
|
181
|
+
.exec(line)?.[1]
|
|
182
|
+
?.trim()
|
|
183
|
+
)
|
|
184
|
+
.filter(Boolean)
|
|
185
|
+
.slice(0, MOST_PIECES);
|
|
186
|
+
|
|
62
187
|
// How old a note is, in the words a brief uses.
|
|
63
188
|
const age = (iso) => {
|
|
64
189
|
const days = Math.floor((Date.now() - Date.parse(iso)) / 86_400_000);
|
|
65
190
|
return days < 1 ? "today" : days === 1 ? "yesterday" : `${days} days ago`;
|
|
66
191
|
};
|
|
67
192
|
const NOTE_CHARS = 600;
|
|
193
|
+
const BRIEF_CHARS = 1_000;
|
|
68
194
|
|
|
69
195
|
export function createTeam({ store, log = () => {} }) {
|
|
70
196
|
const key = (goalId) => `team:${goalId}`;
|
|
197
|
+
// A plan from before routes (a shape and roles) is no plan: the thread's next message to the swarm routes it anew.
|
|
71
198
|
const read = (goalId) => {
|
|
72
199
|
try {
|
|
73
|
-
|
|
200
|
+
const kept = JSON.parse(store.meta(key(goalId)) || "null");
|
|
201
|
+
return Array.isArray(kept?.pieces) ? kept : null;
|
|
74
202
|
} catch {
|
|
75
203
|
return null;
|
|
76
204
|
}
|
|
77
205
|
};
|
|
78
206
|
const write = (goalId, plan) => store.meta(key(goalId), JSON.stringify(plan));
|
|
79
207
|
const now = () => new Date().toISOString();
|
|
208
|
+
const pieceOf = (current) => current.pieces[current.piece];
|
|
209
|
+
const stepsOfNow = (current) => pieceOf(current)?.steps ?? [];
|
|
210
|
+
|
|
211
|
+
// Where each step began and who held it, so a run is marked with the step it worked.
|
|
212
|
+
const started = (current, step) => {
|
|
213
|
+
const entry = stepsOfNow(current).find((s) => s.id === step);
|
|
214
|
+
return entry
|
|
215
|
+
? [
|
|
216
|
+
...(current.history ?? []),
|
|
217
|
+
{
|
|
218
|
+
piece: current.piece,
|
|
219
|
+
step,
|
|
220
|
+
specialty: entry.specialty,
|
|
221
|
+
agents: entry.agents,
|
|
222
|
+
at: now(),
|
|
223
|
+
},
|
|
224
|
+
].slice(-40)
|
|
225
|
+
: (current.history ?? []);
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
// Every finished run of the thread not yet marked takes the step its agent held when it reported: a run the person's
|
|
229
|
+
// tag started before the route began counts toward the step its agent was routed to, and a checker an agent asked by
|
|
230
|
+
// name while it worked counts as the check the route caught up to.
|
|
231
|
+
const markRuns = (current, runs) => {
|
|
232
|
+
const history = current.history ?? [];
|
|
233
|
+
for (const run of runs) {
|
|
234
|
+
if (run.step || !run.reported_at) continue;
|
|
235
|
+
const entry = history.findLast(
|
|
236
|
+
(each) =>
|
|
237
|
+
each.at < run.reported_at && each.agents.includes(run.target_agent)
|
|
238
|
+
);
|
|
239
|
+
if (!entry) continue;
|
|
240
|
+
store.setRunStep(run.id, entry);
|
|
241
|
+
run.step = entry.step;
|
|
242
|
+
run.specialty = entry.specialty;
|
|
243
|
+
}
|
|
244
|
+
};
|
|
80
245
|
|
|
81
|
-
/** The thread's plan, or null when it has none (a thread from before
|
|
246
|
+
/** The thread's plan, or null when it has none (a thread from before routes, or one not yet triaged). */
|
|
82
247
|
const plan = (goalId) => read(goalId);
|
|
83
248
|
|
|
84
|
-
/** The roles an agent holds in the thread. */
|
|
249
|
+
/** The roles an agent holds in the thread's piece now. */
|
|
85
250
|
const rolesOf = (goalId, agent) => {
|
|
86
251
|
const current = read(goalId);
|
|
87
252
|
return current
|
|
88
|
-
?
|
|
89
|
-
.filter((
|
|
90
|
-
.map((
|
|
253
|
+
? stepsOfNow(current)
|
|
254
|
+
.filter((step) => step.agents.includes(agent))
|
|
255
|
+
.map((step) => step.role)
|
|
91
256
|
: [];
|
|
92
257
|
};
|
|
93
258
|
|
|
94
|
-
/**
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
.
|
|
259
|
+
/** The step of the route the agent was last given in the thread, or null in a thread without a route. */
|
|
260
|
+
const stepHeld = (goalId, agent) =>
|
|
261
|
+
read(goalId)?.history?.findLast((entry) => entry.agents.includes(agent))
|
|
262
|
+
?.step ?? null;
|
|
263
|
+
|
|
264
|
+
/** The step of the piece now that the agent holds because the person pinned it for the step's specialty, if any. */
|
|
265
|
+
const pinnedStep = (goalId, agent) => {
|
|
266
|
+
const current = read(goalId);
|
|
267
|
+
const step = current
|
|
268
|
+
? stepsOfNow(current).find((s) => s.id === current.step)
|
|
269
|
+
: null;
|
|
270
|
+
return step?.pinned && step.agents.includes(agent) ? step : null;
|
|
271
|
+
};
|
|
104
272
|
|
|
105
273
|
/**
|
|
106
|
-
* Keep the
|
|
274
|
+
* Keep the route the round proposed, starting at its first step, and say in the thread who holds what. `named`: the
|
|
275
|
+
* agents the person tagged in the message; `pins`: specialty -> the agent the person pinned for it. Returns the plan
|
|
107
276
|
* kept, or null when the proposal named nothing usable.
|
|
108
277
|
*/
|
|
109
|
-
const set = (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
278
|
+
const set = (
|
|
279
|
+
goalId,
|
|
280
|
+
proposed,
|
|
281
|
+
{ members, named = [], pins = {}, by, post }
|
|
282
|
+
) => {
|
|
283
|
+
const checked = validPlan(proposed, { members, named, pins });
|
|
284
|
+
if (!checked) {
|
|
285
|
+
log(`route for ${goalId} not kept: ${JSON.stringify(proposed)}`);
|
|
113
286
|
return null;
|
|
114
287
|
}
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
288
|
+
const { unfilled, steps, rigor, split } = checked;
|
|
289
|
+
const fresh = {
|
|
290
|
+
version: 2,
|
|
291
|
+
rigor,
|
|
292
|
+
split,
|
|
293
|
+
pieces: [{ brief: null, rigor, steps }],
|
|
294
|
+
piece: 0,
|
|
295
|
+
step: steps[0].id,
|
|
119
296
|
sendsBack: 0,
|
|
120
297
|
by,
|
|
121
298
|
at: now(),
|
|
122
299
|
};
|
|
300
|
+
const kept = {
|
|
301
|
+
...fresh,
|
|
302
|
+
stepAt: now(),
|
|
303
|
+
history: started(fresh, steps[0].id),
|
|
304
|
+
};
|
|
123
305
|
write(goalId, kept);
|
|
124
306
|
post?.(
|
|
125
|
-
|
|
307
|
+
[
|
|
308
|
+
`The route for this thread (${rigor}): ${lineup(steps)}.`,
|
|
309
|
+
...(split
|
|
310
|
+
? [
|
|
311
|
+
"The framer splits it into pieces, and each piece is routed when it starts.",
|
|
312
|
+
]
|
|
313
|
+
: []),
|
|
314
|
+
...unfilled.map(unfilledLine),
|
|
315
|
+
].join(" ")
|
|
126
316
|
);
|
|
127
317
|
return kept;
|
|
128
318
|
};
|
|
129
319
|
|
|
130
320
|
/**
|
|
131
|
-
*
|
|
132
|
-
* check
|
|
321
|
+
* The next piece the framer split off, routed as the round proposed: it starts at its first step, and the thread says
|
|
322
|
+
* who holds what. A check that passed the piece before is kept with the commit it saw.
|
|
323
|
+
*/
|
|
324
|
+
const routePiece = (
|
|
325
|
+
goalId,
|
|
326
|
+
proposed,
|
|
327
|
+
{ members, named = [], pins = {}, outcome = null, head = null, post }
|
|
328
|
+
) => {
|
|
329
|
+
const current = read(goalId);
|
|
330
|
+
const index = current ? current.piece + 1 : -1;
|
|
331
|
+
if (!current || !current.pieces[index]) return null;
|
|
332
|
+
const checked = validPlan(proposed, { members, named, pins, piece: true });
|
|
333
|
+
if (!checked) {
|
|
334
|
+
log(`route for piece ${index + 1} of ${goalId} not kept`);
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
judge(goalId, current, outcome, head);
|
|
338
|
+
const after = read(goalId);
|
|
339
|
+
const pieces = after.pieces.map((each, at) =>
|
|
340
|
+
at === index
|
|
341
|
+
? { ...each, rigor: checked.rigor, steps: checked.steps }
|
|
342
|
+
: each
|
|
343
|
+
);
|
|
344
|
+
const moved = {
|
|
345
|
+
...after,
|
|
346
|
+
pieces,
|
|
347
|
+
piece: index,
|
|
348
|
+
step: checked.steps[0].id,
|
|
349
|
+
stepAt: now(),
|
|
350
|
+
sendsBack: 0,
|
|
351
|
+
};
|
|
352
|
+
moved.history = started(moved, moved.step);
|
|
353
|
+
write(goalId, moved);
|
|
354
|
+
// The framing piece is not one of the person's pieces: the count is of the split's.
|
|
355
|
+
const of = pieces.length - 1;
|
|
356
|
+
post?.(
|
|
357
|
+
[
|
|
358
|
+
`Piece ${index} of ${of} (${checked.rigor}): ${lineup(checked.steps)}.`,
|
|
359
|
+
...checked.unfilled.map(unfilledLine),
|
|
360
|
+
].join(" ")
|
|
361
|
+
);
|
|
362
|
+
return moved;
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* A judged step's outcome: kept with the commit its check saw (`head`), so a later change makes it stale, and written
|
|
367
|
+
* on the runs made since the piece's make step last began, with each checker's model, for the record.
|
|
368
|
+
*/
|
|
369
|
+
const judge = (goalId, current, outcome, head) => {
|
|
370
|
+
const step = stepsOfNow(current).find((s) => s.id === current.step);
|
|
371
|
+
if (!step || !stepOf(step.id).judges) return;
|
|
372
|
+
if (outcome !== "passed" && outcome !== "sent_back") return;
|
|
373
|
+
const runs = store.threadRuns(goalId);
|
|
374
|
+
markRuns(current, runs);
|
|
375
|
+
const latest = (agent) =>
|
|
376
|
+
runs.findLast(
|
|
377
|
+
(run) => run.target_agent === agent && run.step === current.step
|
|
378
|
+
);
|
|
379
|
+
const by = step.agents.map((agent) => ({
|
|
380
|
+
agent,
|
|
381
|
+
model: latest(agent)?.run_model?.model ?? null,
|
|
382
|
+
}));
|
|
383
|
+
// The runs this judgment is of: the piece's make runs no earlier step judged. A run a tag started before the route
|
|
384
|
+
// began is the piece's too; a run sent back keeps that outcome, and the run made again takes this one.
|
|
385
|
+
const pieceAt =
|
|
386
|
+
(current.history ?? []).find((entry) => entry.piece === current.piece)
|
|
387
|
+
?.at ?? "";
|
|
388
|
+
for (const run of runs)
|
|
389
|
+
if (
|
|
390
|
+
run.step === "make" &&
|
|
391
|
+
!run.checked &&
|
|
392
|
+
(run.reported_at ?? "") > pieceAt &&
|
|
393
|
+
FINISHED.has(run.status)
|
|
394
|
+
)
|
|
395
|
+
store.setRunChecked(run.id, {
|
|
396
|
+
outcome,
|
|
397
|
+
step: current.step,
|
|
398
|
+
by,
|
|
399
|
+
at: now(),
|
|
400
|
+
});
|
|
401
|
+
write(goalId, {
|
|
402
|
+
...current,
|
|
403
|
+
lastCheck: { step: current.step, outcome, head, at: now() },
|
|
404
|
+
});
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Move the thread to a step of its piece's route (an id, "done"). A judged step's outcome is kept (judge); a
|
|
409
|
+
* send-back is counted.
|
|
133
410
|
*/
|
|
134
411
|
const moveTo = (goalId, step, { outcome = null, head = null } = {}) => {
|
|
135
412
|
const current = read(goalId);
|
|
136
413
|
if (!current) return null;
|
|
137
414
|
const known =
|
|
138
|
-
step === "done" ||
|
|
415
|
+
step === "done" || stepsOfNow(current).some((s) => s.id === step);
|
|
139
416
|
if (!known) return current;
|
|
140
|
-
|
|
417
|
+
judge(goalId, current, outcome, head);
|
|
418
|
+
const after = read(goalId);
|
|
141
419
|
const moved = {
|
|
142
|
-
...
|
|
420
|
+
...after,
|
|
143
421
|
step,
|
|
144
422
|
stepAt: now(),
|
|
145
|
-
sendsBack:
|
|
146
|
-
...(judged && (outcome === "passed" || outcome === "sent_back")
|
|
147
|
-
? { lastCheck: { step: current.step, outcome, head, at: now() } }
|
|
148
|
-
: {}),
|
|
423
|
+
sendsBack: after.sendsBack + (outcome === "sent_back" ? 1 : 0),
|
|
149
424
|
};
|
|
425
|
+
moved.history = started(moved, step);
|
|
150
426
|
write(goalId, moved);
|
|
151
427
|
return moved;
|
|
152
428
|
};
|
|
153
429
|
|
|
154
|
-
/** Whether the thread's
|
|
155
|
-
const checksWork = (current) =>
|
|
430
|
+
/** Whether the thread's route checks its work: one of its pieces has a step that judges. */
|
|
431
|
+
const checksWork = (current) =>
|
|
432
|
+
current.pieces.some((piece) =>
|
|
433
|
+
piece.steps.some((step) => stepOf(step.id).judges)
|
|
434
|
+
);
|
|
156
435
|
|
|
157
436
|
/**
|
|
158
|
-
* Whether the
|
|
159
|
-
* with no branch of its own, where the pass alone counts). True for a
|
|
437
|
+
* Whether the route's last check passed on the code as it is now (`head`, the thread's branch; null for a thread
|
|
438
|
+
* with no branch of its own, where the pass alone counts). True for a route that does not check its work.
|
|
160
439
|
*/
|
|
161
440
|
const checkedNow = (goalId, head = null) => {
|
|
162
441
|
const current = read(goalId);
|
|
@@ -169,22 +448,23 @@ export function createTeam({ store, log = () => {} }) {
|
|
|
169
448
|
|
|
170
449
|
/**
|
|
171
450
|
* Agents were just given work outside the route (the person wrote to them, or a free round picked one): the thread
|
|
172
|
-
* moves to the earliest step one of them holds, so the route goes on from there.
|
|
451
|
+
* moves to the earliest step of the piece one of them holds, so the route goes on from there.
|
|
173
452
|
*/
|
|
174
453
|
const acted = (goalId, agents) => {
|
|
175
454
|
const current = read(goalId);
|
|
176
455
|
if (!current || !agents.length) return;
|
|
177
|
-
const step =
|
|
178
|
-
|
|
456
|
+
const step = stepsOfNow(current).find((s) =>
|
|
457
|
+
s.agents.some((holder) => agents.includes(holder))
|
|
179
458
|
);
|
|
180
459
|
if (step && step.id !== current.step) moveTo(goalId, step.id);
|
|
181
|
-
else if (step)
|
|
460
|
+
else if (step)
|
|
461
|
+
write(goalId, {
|
|
462
|
+
...current,
|
|
463
|
+
stepAt: now(),
|
|
464
|
+
history: started(current, step.id),
|
|
465
|
+
});
|
|
182
466
|
};
|
|
183
467
|
|
|
184
|
-
/**
|
|
185
|
-
* What the round reads about the team: the plan, the step the thread is at, whether everyone on that step has reported
|
|
186
|
-
* since it began, and where the work may go next. `runs` are the thread's runs (store.threadRuns).
|
|
187
|
-
*/
|
|
188
468
|
// When every holder of a step reported after `since`: the last of their reports, else null.
|
|
189
469
|
const reportedAll = (holders, runs, since) => {
|
|
190
470
|
const last = holders.map(
|
|
@@ -209,28 +489,104 @@ export function createTeam({ store, log = () => {} }) {
|
|
|
209
489
|
* whose next step's agents have reported since moves on, up to a step that judges, whose outcome is the round's.
|
|
210
490
|
*/
|
|
211
491
|
const catchUp = (goalId, current, runs) => {
|
|
212
|
-
const steps =
|
|
492
|
+
const steps = stepsOfNow(current);
|
|
213
493
|
let caught = current;
|
|
214
494
|
for (;;) {
|
|
215
495
|
const at = steps.findIndex((s) => s.id === caught.step);
|
|
216
496
|
const step = steps[at];
|
|
217
497
|
const next = steps[at + 1];
|
|
218
|
-
if (!step || step.judges || !next) break;
|
|
219
|
-
const done = reportedAll(
|
|
220
|
-
if (!done || !reportedAll(
|
|
498
|
+
if (!step || stepOf(step.id).judges || !next) break;
|
|
499
|
+
const done = reportedAll(step.agents, runs, caught.stepAt);
|
|
500
|
+
if (!done || !reportedAll(next.agents, runs, done)) break;
|
|
221
501
|
caught = { ...caught, step: next.id, stepAt: done };
|
|
502
|
+
caught.history = [
|
|
503
|
+
...(caught.history ?? []),
|
|
504
|
+
{
|
|
505
|
+
piece: caught.piece,
|
|
506
|
+
step: next.id,
|
|
507
|
+
specialty: next.specialty,
|
|
508
|
+
agents: next.agents,
|
|
509
|
+
at: done,
|
|
510
|
+
},
|
|
511
|
+
];
|
|
222
512
|
}
|
|
223
513
|
if (caught !== current) write(goalId, caught);
|
|
224
514
|
return caught;
|
|
225
515
|
};
|
|
226
516
|
|
|
517
|
+
// The framer's report on a goal it split: its runs' results since its step began, else its posts in the thread.
|
|
518
|
+
const framerSaid = (goalId, current, runs) => {
|
|
519
|
+
const framers = stepsOfNow(current).find((s) => s.id === "frame")?.agents;
|
|
520
|
+
const since = current.stepAt;
|
|
521
|
+
const results = runs
|
|
522
|
+
.filter(
|
|
523
|
+
(run) =>
|
|
524
|
+
framers?.includes(run.target_agent) && (run.reported_at ?? "") > since
|
|
525
|
+
)
|
|
526
|
+
.map((run) => String(run.result || ""));
|
|
527
|
+
const posts = store
|
|
528
|
+
.roomPosts(goalId, 0, 500)
|
|
529
|
+
.filter(
|
|
530
|
+
(post) => framers?.includes(post.author) && post.created_at > since
|
|
531
|
+
)
|
|
532
|
+
.map((post) => post.text);
|
|
533
|
+
// Its result, else its posts: an agent's result is also posted, and its pieces are read once.
|
|
534
|
+
return (
|
|
535
|
+
results.some((text) => piecesIn(text).length) ? results : posts
|
|
536
|
+
).join("\n");
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
// A split goal's frame is done: the pieces its framer gave are kept, to be routed one after another. A framer that gave
|
|
540
|
+
// none leaves one piece, the goal as it framed it.
|
|
541
|
+
const splitInto = (goalId, current, runs) => {
|
|
542
|
+
if (!current.split || current.pieces.length > 1) return current;
|
|
543
|
+
const briefs = piecesIn(framerSaid(goalId, current, runs));
|
|
544
|
+
const pieces = [
|
|
545
|
+
...current.pieces,
|
|
546
|
+
...(briefs.length ? briefs : [null]).map((brief) => ({
|
|
547
|
+
brief: brief ? brief.slice(0, BRIEF_CHARS) : null,
|
|
548
|
+
rigor: null,
|
|
549
|
+
steps: [],
|
|
550
|
+
})),
|
|
551
|
+
];
|
|
552
|
+
const kept = { ...current, pieces };
|
|
553
|
+
write(goalId, kept);
|
|
554
|
+
return kept;
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* What the round reads about the route: the piece and its steps, the step the thread is at, whether everyone on it
|
|
559
|
+
* has reported since it began, and where the work may go next: a step of the piece, "done", "stop" (sent back as
|
|
560
|
+
* often as the route allows), or "piece" (the next piece, which the round routes at once: `nextPiece`).
|
|
561
|
+
* `runs` are the thread's runs (store.threadRuns).
|
|
562
|
+
*/
|
|
227
563
|
const roundView = (goalId, runs, { head = null } = {}) => {
|
|
228
564
|
const kept = read(goalId);
|
|
229
565
|
if (!kept) return null;
|
|
230
|
-
|
|
231
|
-
|
|
566
|
+
markRuns(kept, runs);
|
|
567
|
+
let current = catchUp(goalId, kept, runs);
|
|
568
|
+
const steps = stepsOfNow(current);
|
|
569
|
+
const piece = pieceOf(current);
|
|
570
|
+
const base = {
|
|
571
|
+
rigor: piece.rigor ?? current.rigor,
|
|
572
|
+
piece:
|
|
573
|
+
current.piece > 0
|
|
574
|
+
? {
|
|
575
|
+
number: current.piece,
|
|
576
|
+
of: current.pieces.length - 1,
|
|
577
|
+
brief: piece.brief,
|
|
578
|
+
}
|
|
579
|
+
: null,
|
|
580
|
+
steps: steps.map(({ id, specialty, role, agents }) => ({
|
|
581
|
+
id,
|
|
582
|
+
specialty,
|
|
583
|
+
role,
|
|
584
|
+
agents,
|
|
585
|
+
})),
|
|
586
|
+
sendsBack: current.sendsBack,
|
|
587
|
+
};
|
|
232
588
|
// The route is done but the code changed after its last check passed: the work goes to the check again.
|
|
233
|
-
const firstJudge = steps.findIndex((s) => s.judges);
|
|
589
|
+
const firstJudge = steps.findIndex((s) => stepOf(s.id).judges);
|
|
234
590
|
const recheck =
|
|
235
591
|
current.step === "done" &&
|
|
236
592
|
firstJudge > 0 &&
|
|
@@ -239,41 +595,31 @@ export function createTeam({ store, log = () => {} }) {
|
|
|
239
595
|
Boolean(current.lastCheck.head) &&
|
|
240
596
|
current.lastCheck.head !== head;
|
|
241
597
|
if (recheck) {
|
|
242
|
-
const [made,
|
|
598
|
+
const [made, judged] = [steps[firstJudge - 1], steps[firstJudge]];
|
|
243
599
|
return {
|
|
244
|
-
|
|
245
|
-
rigor: current.rigor,
|
|
246
|
-
roles: current.roles,
|
|
247
|
-
sendsBack: current.sendsBack,
|
|
600
|
+
...base,
|
|
248
601
|
step: {
|
|
249
602
|
id: made.id,
|
|
250
603
|
role: made.role,
|
|
251
|
-
|
|
604
|
+
specialty: made.specialty,
|
|
605
|
+
agents: made.agents,
|
|
252
606
|
judges: false,
|
|
253
607
|
finished: true,
|
|
254
608
|
},
|
|
255
609
|
exits: [
|
|
256
610
|
{
|
|
257
611
|
outcome: "done",
|
|
258
|
-
step:
|
|
259
|
-
role:
|
|
260
|
-
agents:
|
|
612
|
+
step: judged.id,
|
|
613
|
+
role: judged.role,
|
|
614
|
+
agents: judged.agents,
|
|
261
615
|
},
|
|
262
616
|
],
|
|
263
617
|
};
|
|
264
618
|
}
|
|
265
619
|
const at = steps.findIndex((s) => s.id === current.step);
|
|
266
|
-
const view = {
|
|
267
|
-
shape: current.shape,
|
|
268
|
-
rigor: current.rigor,
|
|
269
|
-
roles: current.roles,
|
|
270
|
-
sendsBack: current.sendsBack,
|
|
271
|
-
step: null,
|
|
272
|
-
exits: [],
|
|
273
|
-
};
|
|
620
|
+
const view = { ...base, step: null, exits: [] };
|
|
274
621
|
if (at === -1) return view;
|
|
275
622
|
const step = steps[at];
|
|
276
|
-
const holders = current.roles[step.role];
|
|
277
623
|
const reportedSince = (agent) =>
|
|
278
624
|
runs.some(
|
|
279
625
|
(run) =>
|
|
@@ -281,23 +627,35 @@ export function createTeam({ store, log = () => {} }) {
|
|
|
281
627
|
FINISHED.has(run.status) &&
|
|
282
628
|
(run.reported_at ?? "") > current.stepAt
|
|
283
629
|
);
|
|
284
|
-
const finished =
|
|
630
|
+
const finished = step.agents.every(reportedSince);
|
|
631
|
+
const judges = Boolean(stepOf(step.id).judges);
|
|
285
632
|
view.step = {
|
|
286
633
|
id: step.id,
|
|
287
634
|
role: step.role,
|
|
288
|
-
|
|
289
|
-
|
|
635
|
+
specialty: step.specialty,
|
|
636
|
+
agents: step.agents,
|
|
637
|
+
judges,
|
|
290
638
|
finished,
|
|
291
639
|
};
|
|
292
640
|
if (!finished) return view;
|
|
641
|
+
if (!steps[at + 1]) current = splitInto(goalId, current, runs);
|
|
293
642
|
const following = steps[at + 1];
|
|
643
|
+
const nextPiece = current.pieces[current.piece + 1];
|
|
644
|
+
if (!following && nextPiece)
|
|
645
|
+
view.nextPiece = {
|
|
646
|
+
number: current.piece + 1,
|
|
647
|
+
of: current.pieces.length - 1,
|
|
648
|
+
brief: nextPiece.brief,
|
|
649
|
+
};
|
|
294
650
|
const toStep = (s, outcome) =>
|
|
295
651
|
s
|
|
296
|
-
? { outcome, step: s.id, role: s.role, agents:
|
|
297
|
-
:
|
|
298
|
-
|
|
652
|
+
? { outcome, step: s.id, role: s.role, agents: s.agents }
|
|
653
|
+
: nextPiece
|
|
654
|
+
? { outcome, step: "piece", role: null, agents: [] }
|
|
655
|
+
: { outcome, step: "done", role: null, agents: [] };
|
|
656
|
+
if (!judges) view.exits = [toStep(following, "done")];
|
|
299
657
|
else {
|
|
300
|
-
const back = steps.find((s) => s.id === step.sendBack);
|
|
658
|
+
const back = steps.find((s) => s.id === stepOf(step.id).sendBack);
|
|
301
659
|
view.exits = [
|
|
302
660
|
toStep(following, "passed"),
|
|
303
661
|
back && current.sendsBack < TEAM.sendBackLimit
|
|
@@ -342,52 +700,82 @@ export function createTeam({ store, log = () => {} }) {
|
|
|
342
700
|
`${nameOf(note.agent)}, ${age(note.created_at)} (note ${note.id.slice(0, 8)}, unchecked: verify before relying on it): ${note.text}, because ${note.reason}`
|
|
343
701
|
);
|
|
344
702
|
|
|
345
|
-
|
|
346
|
-
const
|
|
703
|
+
// What a step's holder is told beyond its role's contract: the framer whether to split, a maker who checks its work.
|
|
704
|
+
const stepNote = (current, step) => {
|
|
705
|
+
const steps = stepsOfNow(current);
|
|
706
|
+
if (step.id === "frame")
|
|
707
|
+
return current.split && current.piece === 0
|
|
708
|
+
? 'This goal is to be split: give each piece on its own line as "Piece:" followed by its brief, in the order they should run. Each piece is routed to its agents when it starts.'
|
|
709
|
+
: "This is one piece: say what it is and what good looks like; do not split it.";
|
|
710
|
+
if (step.id !== "make") return null;
|
|
711
|
+
return steps.some((s) => s.id === "check")
|
|
712
|
+
? "Another agent checks your work after you: test it yourself as well, and say what you ran."
|
|
713
|
+
: "No other agent checks this at this rigor: test your own work before you report, and say what you ran.";
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
// A check or judgment is of the change as committed on the thread's branch: one git would not commit (threadRuns.mjs)
|
|
717
|
+
// is said to whoever judges next, so it is not passed as made.
|
|
718
|
+
const uncommittedNote = (goalId, step) => {
|
|
719
|
+
if (!stepOf(step.id).judges) return null;
|
|
720
|
+
let left = null;
|
|
721
|
+
try {
|
|
722
|
+
left = JSON.parse(store.meta(`uncommitted:${goalId}`) || "null");
|
|
723
|
+
} catch {}
|
|
724
|
+
if (!left?.files?.length) return null;
|
|
725
|
+
return `Not made yet: ${nameOf(left.agent)}'s change is not committed on the thread's branch (${namedFiles(left.files)} still uncommitted). Check the change as committed, and send back work that is not.`;
|
|
726
|
+
};
|
|
727
|
+
|
|
728
|
+
/** The brief's section on the route, for an agent woken in a thread with one. Every holder gets the same brief. */
|
|
729
|
+
const brief = (goalId, agent) => {
|
|
347
730
|
const current = read(goalId);
|
|
348
731
|
if (!current) return "";
|
|
349
|
-
const steps =
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
const mine =
|
|
353
|
-
(
|
|
354
|
-
|
|
732
|
+
const steps = stepsOfNow(current);
|
|
733
|
+
const piece = pieceOf(current);
|
|
734
|
+
// The step the agent acts in now comes first: the thread's current step, when it holds several.
|
|
735
|
+
const mine = steps
|
|
736
|
+
.filter((step) => step.agents.includes(agent))
|
|
737
|
+
.sort(
|
|
738
|
+
(a, b) => Number(b.id === current.step) - Number(a.id === current.step)
|
|
739
|
+
);
|
|
740
|
+
const rigor = piece.rigor ?? current.rigor;
|
|
355
741
|
const lines = [
|
|
356
|
-
`The
|
|
357
|
-
|
|
742
|
+
`The route${current.piece > 0 ? ` for piece ${current.piece} of ${current.pieces.length - 1}` : ""} (${rigor}): ${lineup(steps)}.`,
|
|
743
|
+
...(current.piece > 0 && piece.brief
|
|
744
|
+
? [`This piece, as the framer gave it: ${piece.brief}`]
|
|
745
|
+
: []),
|
|
746
|
+
`How careful this work must be: ${rigor}. ${TEAM.rigor[rigor].says}`,
|
|
358
747
|
];
|
|
359
748
|
const folder = store.getTask(goalId)?.goal?.workspace ?? null;
|
|
360
749
|
const learned = [];
|
|
361
|
-
for (const [index,
|
|
362
|
-
const contract = TEAM.roles[role];
|
|
750
|
+
for (const [index, step] of mine.entries()) {
|
|
751
|
+
const contract = TEAM.roles[step.role];
|
|
363
752
|
if (index > 0) {
|
|
364
|
-
lines.push(
|
|
753
|
+
lines.push(
|
|
754
|
+
`You are also its ${contract.name}, at the ${step.id} step.`
|
|
755
|
+
);
|
|
365
756
|
continue;
|
|
366
757
|
}
|
|
367
|
-
learned.push(...notesFor(role, folder));
|
|
368
|
-
const
|
|
369
|
-
const next = steps[at + 1];
|
|
758
|
+
learned.push(...notesFor(step.role, folder));
|
|
759
|
+
const next = steps[steps.indexOf(step) + 1];
|
|
370
760
|
lines.push(
|
|
371
|
-
`Your role now: ${contract.name}. ${contract.owns}`,
|
|
761
|
+
`Your role now: ${contract.name}${step.specialty ? `, for ${specialtyName(step.specialty)}` : ""}. ${contract.owns}`,
|
|
372
762
|
`Never: ${contract.never}`,
|
|
373
763
|
`Bring back: ${contract.bringsBack}`,
|
|
764
|
+
...[stepNote(current, step), uncommittedNote(goalId, step)].filter(
|
|
765
|
+
Boolean
|
|
766
|
+
),
|
|
374
767
|
next
|
|
375
|
-
? `Next on the
|
|
376
|
-
: "After you, the thread's coordinator reads your result and decides
|
|
768
|
+
? `Next on the route: ${next.agents.map(nameOf).join(" and ")} (${TEAM.roles[next.role].name}).`
|
|
769
|
+
: "After you, the thread's coordinator reads your result and decides what comes next. It is not an agent: do not address it, or Harness, to hand the work back."
|
|
377
770
|
);
|
|
378
771
|
}
|
|
379
772
|
if (!mine.length)
|
|
380
773
|
lines.push(
|
|
381
|
-
"You hold no
|
|
382
|
-
);
|
|
383
|
-
// Goal-level models get the intent and find the route; others do their best work on smaller checked steps.
|
|
384
|
-
if (!goalLevel(model))
|
|
385
|
-
lines.push(
|
|
386
|
-
"Work in small steps: do one part, check that it works, then the next, and say which parts are done."
|
|
774
|
+
"You hold no step on this route: do what you were asked and hand anything else to the agent whose step it is."
|
|
387
775
|
);
|
|
388
776
|
if (mine.length)
|
|
389
777
|
lines.push(
|
|
390
|
-
`Before you stop: if you learned something about this folder that the next ${TEAM.roles[mine[0]].name} here should know (a trap, a check that matters, how the code really works),
|
|
778
|
+
`Before you stop: if you learned something about this folder that the next ${TEAM.roles[mine[0].role].name} here should know (a trap, a check that matters, how the code really works), add it with swarm_memory (remember, why, thread ${goalId}): what you learned and why it holds.`
|
|
391
779
|
);
|
|
392
780
|
return [
|
|
393
781
|
"Your part on the team:",
|
|
@@ -406,6 +794,7 @@ export function createTeam({ store, log = () => {} }) {
|
|
|
406
794
|
return {
|
|
407
795
|
plan,
|
|
408
796
|
set,
|
|
797
|
+
routePiece,
|
|
409
798
|
moveTo,
|
|
410
799
|
acted,
|
|
411
800
|
roundView,
|
|
@@ -413,5 +802,7 @@ export function createTeam({ store, log = () => {} }) {
|
|
|
413
802
|
learn,
|
|
414
803
|
brief,
|
|
415
804
|
rolesOf,
|
|
805
|
+
stepHeld,
|
|
806
|
+
pinnedStep,
|
|
416
807
|
};
|
|
417
808
|
}
|