tryharness 0.7.82 → 0.7.86
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 +21 -19
- package/assets/dsh-plugin.mjs +75 -4
- package/assets/herdr-mod/harness/main.js +367 -0
- package/assets/herdr-mod/harness/mod.json +6 -0
- package/assets/opencode-plugin.js +87 -22
- package/assets/pi-extension.ts +81 -2
- package/cli.mjs +544 -208
- package/lib/adapters.mjs +62 -27
- package/lib/agentBinaries.mjs +6 -8
- package/lib/agentClaims.mjs +168 -0
- package/lib/agentReadTools.json +415 -0
- package/lib/agentSignIn.mjs +17 -18
- package/lib/agentWiring.mjs +114 -0
- package/lib/archetypes.js +10 -11
- package/lib/attention.mjs +100 -0
- package/lib/audit.mjs +1 -1
- package/lib/backupSetup.mjs +6 -28
- package/lib/bankrApprovals.mjs +86 -0
- package/lib/boardAccess.mjs +40 -66
- package/lib/boardBackup.mjs +86 -85
- package/lib/boardCommands.mjs +28 -0
- package/lib/boardFileCommands.mjs +29 -36
- package/lib/boardFiles.mjs +83 -15
- package/lib/boardMirror.mjs +78 -11
- package/lib/boardProtocol.json +193 -123
- package/lib/boardThreads.mjs +19 -37
- package/lib/boardTools.mjs +22 -15
- package/lib/boardWatches.mjs +43 -15
- package/lib/bridge.mjs +7 -3
- package/lib/browserAgentTools.mjs +59 -0
- package/lib/browserWake.mjs +0 -6
- package/lib/cards.mjs +57 -2
- package/lib/circling.mjs +189 -0
- package/lib/cleanup.mjs +234 -0
- package/lib/cloudBoot.mjs +21 -4
- package/lib/cloudSave.mjs +46 -5
- package/lib/compaction.mjs +8 -1
- package/lib/completion.mjs +358 -0
- package/lib/computerDevices.mjs +853 -0
- package/lib/connectionStatus.mjs +34 -0
- package/lib/connectors.mjs +139 -1
- package/lib/coordinator.mjs +108 -14
- package/lib/coreModels.mjs +36 -12
- package/lib/daemon.mjs +2435 -333
- package/lib/daemonLock.mjs +103 -0
- package/lib/deviceDoor.mjs +308 -0
- package/lib/deviceIdentity.mjs +114 -0
- package/lib/deviceList.mjs +172 -0
- package/lib/deviceSeal.mjs +74 -0
- package/lib/dispatcher.mjs +497 -26
- package/lib/dispatches.mjs +3 -3
- package/lib/environment.mjs +2 -1
- package/lib/environments.mjs +67 -41
- package/lib/events.mjs +318 -0
- package/lib/facts.mjs +170 -0
- package/lib/fileSource.mjs +540 -0
- package/lib/files.mjs +47 -2
- package/lib/gitHost.mjs +39 -1
- package/lib/goalCommands.mjs +12 -80
- package/lib/handover.mjs +21 -16
- package/lib/harnessOffers.mjs +140 -15
- package/lib/herdr.mjs +100 -15
- package/lib/herdrAppCall.mjs +19 -0
- package/lib/herdrCore.mjs +59 -0
- package/lib/herdrRuns.mjs +1126 -0
- package/lib/hookDialects.mjs +235 -50
- package/lib/identityLink.mjs +81 -0
- package/lib/inference.mjs +31 -2
- package/lib/jamAccess.mjs +82 -0
- package/lib/{projectBoard.mjs → jamBoard.mjs} +5 -4
- package/lib/{projectGit.mjs → jamGit.mjs} +53 -15
- package/lib/jamKey.mjs +274 -0
- package/lib/{projectPieces.mjs → jamPieces.mjs} +35 -29
- package/lib/{projectSettings.mjs → jamSettings.mjs} +12 -22
- package/lib/jamStore.mjs +973 -0
- package/lib/jamUpgrade.mjs +112 -0
- package/lib/jams.mjs +3079 -0
- package/lib/kanban.mjs +13 -7
- package/lib/landed.mjs +5 -1
- package/lib/library.mjs +41 -22
- package/lib/limits.mjs +91 -0
- package/lib/lineDiff.mjs +97 -0
- package/lib/lineup.mjs +18 -13
- package/lib/link.mjs +584 -0
- package/lib/localStack.mjs +75 -16
- package/lib/localmodels.mjs +58 -78
- package/lib/loopBackstop.mjs +2 -1
- package/lib/machine.mjs +544 -0
- package/lib/machineLink.mjs +446 -0
- package/lib/machineRoutes.mjs +68 -19
- package/lib/machineRuns.mjs +85 -4
- package/lib/machineSeal.mjs +6 -31
- package/lib/manager.mjs +134 -12
- package/lib/mcp-stdio.mjs +492 -215
- package/lib/mcpRelay.mjs +34 -35
- package/lib/members.json +2 -2
- package/lib/modelRoute.mjs +162 -0
- package/lib/nativeHost.mjs +81 -90
- package/lib/nativeSenses.mjs +258 -0
- package/lib/nerves.mjs +523 -0
- package/lib/network.mjs +117 -278
- package/lib/networkPlaces.mjs +578 -0
- package/lib/nextStep.mjs +95 -0
- package/lib/notify.mjs +2 -2
- package/lib/nudge.mjs +116 -10
- package/lib/onboard.mjs +6 -6
- package/lib/originals.mjs +216 -0
- package/lib/outsideEvents.mjs +383 -0
- package/lib/outsideRuns.mjs +230 -0
- package/lib/ownMachines.mjs +674 -256
- package/lib/pain.mjs +215 -0
- package/lib/pairing.mjs +91 -11
- package/lib/paths.mjs +42 -3
- package/lib/peerProcess.mjs +21 -7
- package/lib/peopleLink.mjs +268 -0
- package/lib/personNotices.mjs +3 -2
- package/lib/phones.mjs +252 -542
- package/lib/placeCards.mjs +282 -0
- package/lib/placeChecks.mjs +95 -0
- package/lib/placeCommands.mjs +8 -17
- package/lib/placeRequests.mjs +152 -0
- package/lib/placeStore.mjs +295 -0
- package/lib/placeTool.d.ts +12 -0
- package/lib/placeTool.js +40 -0
- package/lib/places.mjs +63 -14
- package/lib/plans.mjs +53 -8
- package/lib/presence.mjs +270 -0
- package/lib/privateNetwork.d.ts +2 -0
- package/lib/privateNetwork.js +93 -0
- package/lib/proposals.mjs +300 -0
- package/lib/publicFetch.d.ts +32 -0
- package/lib/publicFetch.js +248 -0
- package/lib/reach.mjs +128 -0
- package/lib/rebuildable.mjs +72 -0
- package/lib/recall.mjs +216 -0
- package/lib/record.mjs +13 -0
- package/lib/reflexes.mjs +392 -0
- package/lib/relayLimits.mjs +31 -2
- package/lib/releaseNotice.mjs +198 -0
- package/lib/removeHarness.mjs +15 -4
- package/lib/repoLinks.mjs +204 -35
- package/lib/runAuthority.mjs +102 -39
- package/lib/runBrief.mjs +93 -40
- package/lib/runRequests.mjs +52 -14
- package/lib/runUsage.mjs +31 -0
- package/lib/runWorker.mjs +74 -25
- package/lib/runner.mjs +289 -45
- package/lib/runtime-install.mjs +37 -8
- package/lib/schedules.mjs +171 -47
- package/lib/screenWatches.mjs +221 -0
- package/lib/sealed.mjs +12 -30
- package/lib/sealedThreads.mjs +198 -392
- package/lib/secretStore.mjs +178 -0
- package/lib/secrets.mjs +11 -0
- package/lib/seen.mjs +3 -9
- package/lib/selfUpdate.mjs +51 -15
- package/lib/senseCall.mjs +1514 -0
- package/lib/senseHook.mjs +114 -0
- package/lib/senseTools.mjs +1298 -0
- package/lib/sessionBriefs.mjs +87 -0
- package/lib/sessionControl.mjs +63 -13
- package/lib/sessionFiles.mjs +85 -0
- package/lib/setupChoices.mjs +12 -3
- package/lib/setupMode.mjs +70 -25
- package/lib/sharedKeys.mjs +166 -0
- package/lib/sleep.mjs +396 -0
- package/lib/sources.mjs +306 -0
- package/lib/speech.mjs +166 -411
- package/lib/spoken.mjs +210 -0
- package/lib/steerHook.mjs +3 -1
- package/lib/steerQueue.mjs +40 -11
- package/lib/store.mjs +323 -130
- package/lib/stuck.mjs +85 -7
- package/lib/swarm.mjs +157 -49
- package/lib/swarmDevices.mjs +25 -85
- package/lib/swarmMemory.mjs +93 -9
- package/lib/t3.mjs +73 -3
- package/lib/taskCommands.mjs +51 -60
- package/lib/taskRooms.mjs +30 -4
- package/lib/taskRules.json +29 -0
- package/lib/taskRules.mjs +21 -0
- package/lib/taskRuns.mjs +74 -11
- package/lib/team.mjs +2 -1
- package/lib/threadActions.mjs +37 -9
- package/lib/threadAuthority.mjs +4 -4
- package/lib/threadBriefs.mjs +173 -43
- package/lib/threadNotes.mjs +320 -0
- package/lib/threadRecord.mjs +491 -0
- package/lib/threadRuns.mjs +216 -108
- package/lib/threadView.mjs +27 -30
- package/lib/threadWatches.mjs +1962 -0
- package/lib/timeSense.mjs +839 -0
- package/lib/tripwires.mjs +454 -0
- package/lib/ui.mjs +1 -1
- package/lib/vault.mjs +560 -45
- package/lib/vaultCommands.mjs +5 -3
- package/lib/vaultPeers.mjs +165 -0
- package/lib/vaultTools.d.ts +4 -1
- package/lib/vaultTools.js +22 -1
- package/lib/verdicts.mjs +12 -26
- package/lib/versions.mjs +117 -0
- package/lib/waitTool.mjs +278 -0
- package/lib/wakePicture.mjs +268 -0
- package/lib/wakeQueue.mjs +108 -0
- package/lib/watchResponses.mjs +533 -0
- package/lib/watches.mjs +290 -145
- package/lib/windowAsks.mjs +80 -17
- package/lib/worktrees.mjs +159 -9
- package/npm-shrinkwrap.json +138 -631
- package/package.json +7 -6
- package/release.json +212 -130
- package/lib/callSessions.mjs +0 -51
- package/lib/directLink.mjs +0 -349
- package/lib/peopleBoard.mjs +0 -131
- package/lib/projects.mjs +0 -2917
- package/lib/roomChannels.mjs +0 -667
package/lib/threadRuns.mjs
CHANGED
|
@@ -6,13 +6,17 @@ import { computerHandle } from "./computerAddress.mjs";
|
|
|
6
6
|
import { oneLine } from "./oneLine.mjs";
|
|
7
7
|
import { setRunPick } from "./models.mjs";
|
|
8
8
|
import { t3Access, steerT3Run } from "./t3.mjs";
|
|
9
|
+
import { herdrRunning } from "./herdr.mjs";
|
|
10
|
+
import { runsInHerdr } from "./herdrRuns.mjs";
|
|
9
11
|
import { t3Model, t3Open, t3Project, t3Provider } from "./places.mjs";
|
|
10
12
|
import { within } from "./folders.mjs";
|
|
11
13
|
import { namedFiles } from "./worktrees.mjs";
|
|
12
14
|
import { prepareScratch } from "./scratch.mjs";
|
|
13
15
|
import { PROPOSERS } from "./runAuthority.mjs";
|
|
16
|
+
import { createWakeQueue } from "./wakeQueue.mjs";
|
|
17
|
+
import { nextStepOf, withoutNextStep } from "./nextStep.mjs";
|
|
14
18
|
|
|
15
|
-
// The agents with a read-only switch (runner.mjs): only they talk out a clash in a
|
|
19
|
+
// The agents with a read-only switch (runner.mjs): only they talk out a clash in a jam without waiting.
|
|
16
20
|
const REVIEWERS = new Set(
|
|
17
21
|
MEMBERS.filter((entry) => entry.review).map((entry) => entry.id)
|
|
18
22
|
);
|
|
@@ -23,6 +27,8 @@ export function createThreadRuns({
|
|
|
23
27
|
log,
|
|
24
28
|
// A turn ended with the agent's report in the thread (manager.mjs).
|
|
25
29
|
reported = () => {},
|
|
30
|
+
// Each agent's next step in each thread (nextStep.mjs): the one a turn ended with, kept for its next turn.
|
|
31
|
+
nextSteps = null,
|
|
26
32
|
installedAgents,
|
|
27
33
|
authority,
|
|
28
34
|
worktrees,
|
|
@@ -33,14 +39,15 @@ export function createThreadRuns({
|
|
|
33
39
|
restrictedWait,
|
|
34
40
|
pauseGoal,
|
|
35
41
|
homeOf,
|
|
42
|
+
placesOf = () => ({}),
|
|
36
43
|
// A coding agent not installed here but on another of the person's computers that has the thread's repository:
|
|
37
44
|
// { machine, folder } there (ownMachines.mjs), or null.
|
|
38
45
|
placeElsewhere = () => null,
|
|
39
46
|
// The person's computers (ownMachines.mjs): this one's id, an agent's turn placed on a named other one
|
|
40
47
|
// ({ machine, folder } or { error }), each computer's name, and the ones an agent is on. Null with one computer.
|
|
41
48
|
computers = null,
|
|
42
|
-
// Projects shared with another person's swarm (
|
|
43
|
-
|
|
49
|
+
// Projects shared with another person's swarm (jams.mjs): their check before work, and each agent's own branch.
|
|
50
|
+
jams = () => null,
|
|
44
51
|
// The step of the thread's route an agent was last given (team.mjs), or null.
|
|
45
52
|
stepHeld = () => null,
|
|
46
53
|
verdicts = null,
|
|
@@ -66,6 +73,8 @@ export function createThreadRuns({
|
|
|
66
73
|
const computerOf = (goalId) => {
|
|
67
74
|
const held = store.meta(`thread-work-computer:${goalId}`);
|
|
68
75
|
if (held) return held;
|
|
76
|
+
// A copy made for the asker's turn on the answer is the asker's, not where the thread's work is.
|
|
77
|
+
if (store.meta(`asked-in:${goalId}`)) return null;
|
|
69
78
|
const tree = worktrees.get(goalId);
|
|
70
79
|
return tree && tree.state !== "discarded" && tree.state !== "merged"
|
|
71
80
|
? (computers?.self() ?? null)
|
|
@@ -122,7 +131,7 @@ export function createThreadRuns({
|
|
|
122
131
|
// A task's run goes where its room's turns go: into T3 Code when the person uses the agent there. That is the room's
|
|
123
132
|
// first job, and work an agent handed on into a thread in that thread's folder, a turn of the agent there like any
|
|
124
133
|
// other: it opens where the person uses that agent most. Not when it would run restricted (work another agent asked
|
|
125
|
-
// for on a goal's authority): only this computer holds a run to that. Nor in a
|
|
134
|
+
// for on a goal's authority): only this computer holds a run to that. Nor in a jam, whose agents work on
|
|
126
135
|
// their own branches here.
|
|
127
136
|
const taskInT3 = (task, agent) => {
|
|
128
137
|
const room = task.parent_id ? store.getTask(task.parent_id) : null;
|
|
@@ -130,7 +139,7 @@ export function createThreadRuns({
|
|
|
130
139
|
task.kind !== "task" ||
|
|
131
140
|
room?.kind !== "goal" ||
|
|
132
141
|
!task.run_workspace ||
|
|
133
|
-
|
|
142
|
+
jams()?.isJamRoom(room.id)
|
|
134
143
|
)
|
|
135
144
|
return false;
|
|
136
145
|
const ownJob = store.meta(`task-room:${room.id}`) === task.id;
|
|
@@ -143,6 +152,65 @@ export function createThreadRuns({
|
|
|
143
152
|
!restricted && inT3(room, agent, store.meta(`review:${task.id}`) === "1")
|
|
144
153
|
);
|
|
145
154
|
};
|
|
155
|
+
// A turn Herdr shows (herdrRuns.mjs runInHerdr): Claude Code's or Codex's turn in a thread, for a person who uses Claude Code in
|
|
156
|
+
// the Herdr app while its window is open. The person's own turns only; the caller rules out the rest. Each thread has a
|
|
157
|
+
// space there and each agent a tab, kept here so the next turn finds them.
|
|
158
|
+
const herdrTurn = (task, agent) => {
|
|
159
|
+
// A task in a thread, or the agent woken there (an @mention, a hand-off): both are its turns in the thread.
|
|
160
|
+
if (!runsInHerdr(agent) || !["task", "wake"].includes(task.kind))
|
|
161
|
+
return null;
|
|
162
|
+
if (!task.run_workspace) return null;
|
|
163
|
+
const thread = task.parent_id ? store.getTask(task.parent_id) : null;
|
|
164
|
+
if (thread?.kind !== "goal") return null;
|
|
165
|
+
const home = homeOf(agent);
|
|
166
|
+
if (home?.kind !== "herdr" || home.client !== "app" || !herdrRunning(home))
|
|
167
|
+
return null;
|
|
168
|
+
const tabKey = `herdr-tab:${thread.id}:${agent}`;
|
|
169
|
+
let tab = null;
|
|
170
|
+
try {
|
|
171
|
+
tab = JSON.parse(store.meta(tabKey) || "null");
|
|
172
|
+
} catch {}
|
|
173
|
+
return {
|
|
174
|
+
core: home.core ?? null,
|
|
175
|
+
space: store.meta(`herdr-space:${thread.id}`) || null,
|
|
176
|
+
tab,
|
|
177
|
+
threadName: oneLine(thread.objective).slice(0, 60),
|
|
178
|
+
// The session an agent started in a tab, as its own SessionStart hook placed it there (HC_TERMINAL_ID): newest
|
|
179
|
+
// first, none placed before Herdr was asked for the tab.
|
|
180
|
+
sessionIn: (agentId, terminal, since) =>
|
|
181
|
+
Object.entries(placesOf(agentId))
|
|
182
|
+
.filter(
|
|
183
|
+
([, place]) =>
|
|
184
|
+
place?.kind === "herdr" &&
|
|
185
|
+
place.terminal === terminal &&
|
|
186
|
+
(place.at ?? 0) >= since
|
|
187
|
+
)
|
|
188
|
+
.sort(([, a], [, b]) => (b.at ?? 0) - (a.at ?? 0))[0]?.[0] ?? null,
|
|
189
|
+
// What the person and the agent say in its tab between Harness's turns: shown in the thread as notes, which wake
|
|
190
|
+
// no one (the owner, November 11: "show, don't wake").
|
|
191
|
+
mirror: ({ asked, answer }) => {
|
|
192
|
+
if (asked)
|
|
193
|
+
store.roomPost({
|
|
194
|
+
goalId: thread.id,
|
|
195
|
+
author: "user",
|
|
196
|
+
kind: "note",
|
|
197
|
+
text: `In ${nameOf(agent)}'s Herdr tab: ${asked}`.slice(0, 20_000),
|
|
198
|
+
});
|
|
199
|
+
if (answer)
|
|
200
|
+
store.roomPost({
|
|
201
|
+
goalId: thread.id,
|
|
202
|
+
author: agent,
|
|
203
|
+
kind: "note",
|
|
204
|
+
text: answer.slice(0, 20_000),
|
|
205
|
+
});
|
|
206
|
+
notifyBoard(store.getTask(thread.id));
|
|
207
|
+
},
|
|
208
|
+
onPlaced: ({ space, terminal, session }) => {
|
|
209
|
+
if (space) store.meta(`herdr-space:${thread.id}`, space);
|
|
210
|
+
store.meta(tabKey, JSON.stringify({ terminal, session }));
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
};
|
|
146
214
|
// A turn T3 carries out (t3.mjs runInT3): into the agent's T3 thread in this thread, else a new one in T3's project
|
|
147
215
|
// for the folder, on the thread's T3 checkout. The thread works in T3 from its first launch.
|
|
148
216
|
// Every turn runs there on the model and effort the run was given (what the buddy shows), whatever the thread last ran.
|
|
@@ -173,6 +241,26 @@ export function createThreadRuns({
|
|
|
173
241
|
};
|
|
174
242
|
// A turn that ran outside T3 Code because T3 did not answer: the thread hears it, and the agent's next turn in T3 is
|
|
175
243
|
// told what its T3 thread did not see, so the thread goes back to T3 with nothing lost.
|
|
244
|
+
// The folder a run starts in on this computer. One that is not here falls back to the thread's scratch folder, said once
|
|
245
|
+
// in the thread (owner, November 2: "should always fall back to a scratch folder"). With no thread it fails as named.
|
|
246
|
+
const folderForRun = (task) => {
|
|
247
|
+
const folder = task.run_workspace;
|
|
248
|
+
if (!folder || !task.parent_id || fs.existsSync(folder)) return folder;
|
|
249
|
+
const thread = store.getTask(task.parent_id);
|
|
250
|
+
if (!thread) return folder;
|
|
251
|
+
const note = `scratch-fallback:${thread.id}:${task.target_agent}:${folder}`;
|
|
252
|
+
if (!store.meta(note)) {
|
|
253
|
+
store.meta(note, "1");
|
|
254
|
+
store.roomPost({
|
|
255
|
+
goalId: thread.id,
|
|
256
|
+
author: DISPATCHER,
|
|
257
|
+
kind: "note",
|
|
258
|
+
text: `${nameOf(task.target_agent)} works in a scratch folder: ${folder} is not on this computer.`,
|
|
259
|
+
});
|
|
260
|
+
notifyBoard(store.getTask(thread.id));
|
|
261
|
+
}
|
|
262
|
+
return prepareScratch(thread.id, threadFiles(thread));
|
|
263
|
+
};
|
|
176
264
|
const ranOutsideT3 = new Set();
|
|
177
265
|
const t3Missed = (runId, why) => {
|
|
178
266
|
ranOutsideT3.add(runId);
|
|
@@ -203,27 +291,11 @@ export function createThreadRuns({
|
|
|
203
291
|
};
|
|
204
292
|
// Wake one teammate. A coding agent here gets a run in the goal's folder that resumes its last session on this goal;
|
|
205
293
|
// Harness and agents that cannot be started here learn of it through the board change and their own reads.
|
|
294
|
+
const wakeQueue = createWakeQueue({ store });
|
|
206
295
|
const pendingWakes = {
|
|
207
|
-
get
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
return value &&
|
|
211
|
-
typeof value.reason === "string" &&
|
|
212
|
-
typeof value.asker === "string" &&
|
|
213
|
-
typeof value.go === "boolean" &&
|
|
214
|
-
typeof value.at === "string"
|
|
215
|
-
? value
|
|
216
|
-
: null;
|
|
217
|
-
} catch {
|
|
218
|
-
return null;
|
|
219
|
-
}
|
|
220
|
-
},
|
|
221
|
-
set(key, value) {
|
|
222
|
-
store.meta("pending-wake:" + key, JSON.stringify(value));
|
|
223
|
-
},
|
|
224
|
-
delete(key) {
|
|
225
|
-
store.meta("pending-wake:" + key, "");
|
|
226
|
-
},
|
|
296
|
+
get: wakeQueue.get,
|
|
297
|
+
set: wakeQueue.set,
|
|
298
|
+
delete: wakeQueue.clear,
|
|
227
299
|
};
|
|
228
300
|
// The computer a run is on, by id: the one that took it, else the one it waits for, else this one.
|
|
229
301
|
const computerOfRun = (run) =>
|
|
@@ -259,27 +331,7 @@ export function createThreadRuns({
|
|
|
259
331
|
.map((lane) => laneKey(goalId, agent, lane))
|
|
260
332
|
),
|
|
261
333
|
];
|
|
262
|
-
|
|
263
|
-
// board so a restart keeps them.
|
|
264
|
-
const COMPUTER_WAITS = "computer-waits";
|
|
265
|
-
const computerWaits = () => {
|
|
266
|
-
try {
|
|
267
|
-
const kept = JSON.parse(store.meta(COMPUTER_WAITS) || "[]");
|
|
268
|
-
return Array.isArray(kept) ? kept : [];
|
|
269
|
-
} catch {
|
|
270
|
-
return [];
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
const awaitComputer = (goalId, agent, reason, options) =>
|
|
274
|
-
store.meta(
|
|
275
|
-
COMPUTER_WAITS,
|
|
276
|
-
JSON.stringify([
|
|
277
|
-
...computerWaits().filter(
|
|
278
|
-
(each) => !(each.goalId === goalId && each.agent === agent)
|
|
279
|
-
),
|
|
280
|
-
{ goalId, agent, reason, options, at: new Date().toISOString() },
|
|
281
|
-
])
|
|
282
|
-
);
|
|
334
|
+
const { awaitComputer, waitsForComputer } = wakeQueue;
|
|
283
335
|
/**
|
|
284
336
|
* The computer holding the thread's checkout (or the route's) cannot take this agent's turn: the thread says why
|
|
285
337
|
* once, and the work goes back to Jev, which passes over this agent in the thread for a while and picks again (owner,
|
|
@@ -298,48 +350,35 @@ export function createThreadRuns({
|
|
|
298
350
|
unplaced(goalId, agent);
|
|
299
351
|
notifyBoard(store.getTask(goalId));
|
|
300
352
|
};
|
|
301
|
-
/** Whether an agent's turn in the thread waits for its computer to come back. */
|
|
302
|
-
const waitsForComputer = (goalId) =>
|
|
303
|
-
computerWaits().some((each) => each.goalId === goalId);
|
|
304
|
-
const dropWait = (goalId, agent) =>
|
|
305
|
-
store.meta(
|
|
306
|
-
COMPUTER_WAITS,
|
|
307
|
-
JSON.stringify(
|
|
308
|
-
computerWaits().filter(
|
|
309
|
-
(each) => !(each.goalId === goalId && each.agent === agent)
|
|
310
|
-
)
|
|
311
|
-
)
|
|
312
|
-
);
|
|
313
|
-
// Waiting turns whose computer is being checked now: one change while a check runs does not start a second.
|
|
314
|
-
const checking = new Set();
|
|
315
353
|
/**
|
|
316
354
|
* One of the person's computers came back or said which folders it has: each turn waiting for one is checked there
|
|
317
355
|
* first (the coordinator's capability check kept for it, `checkBeforeStart`), then placed again, and waits again if
|
|
318
356
|
* its computer still cannot take it. A "no" ends the wait: the coordinator has sent the work back to Jev. A thread no
|
|
319
357
|
* longer open drops its waiting turns. The turn stays in the list while it is checked, so the thread still waits.
|
|
320
358
|
*/
|
|
321
|
-
const computersChanged = () =>
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
.catch(() => true)
|
|
329
|
-
.then((go) => {
|
|
330
|
-
dropWait(each.goalId, each.agent);
|
|
331
|
-
checking.delete(key);
|
|
332
|
-
if (go) wakeAgent(each.goalId, each.agent, each.reason, each.options);
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
};
|
|
359
|
+
const computersChanged = () =>
|
|
360
|
+
wakeQueue.recheckWaits(
|
|
361
|
+
(each) =>
|
|
362
|
+
store.getTask(each.goalId)?.status === "open" &&
|
|
363
|
+
checkBeforeStart(each.goalId, each.agent),
|
|
364
|
+
(each) => wakeAgent(each.goalId, each.agent, each.reason, each.options)
|
|
365
|
+
);
|
|
336
366
|
// Another person's agent or the person themselves, by their address ("igor/codex"); the person's own agents are named
|
|
337
367
|
// without one. A turn such an ask brings runs on this person's own agent settings only (runWorker.mjs).
|
|
338
368
|
const fromAnotherPerson = (asker) => String(asker ?? "").includes("/");
|
|
339
|
-
//
|
|
369
|
+
// Work another person asked for, and every run in a jam's room, loads only this person's own agent settings and
|
|
370
|
+
// reaches none of their private things (runAuthority.mjs privateReach); a run in a jam reaches only that jam's room
|
|
371
|
+
// (docs/jam-plan.md J4.4: "an agent reaches only what is in the jam").
|
|
372
|
+
const heldToJam = (runId, goalId, asker) => {
|
|
373
|
+
const inJam = Boolean(jams()?.isJamRoom(goalId));
|
|
374
|
+
if (fromAnotherPerson(asker) || inJam)
|
|
375
|
+
store.meta(`other-person-run:${runId}`, "1");
|
|
376
|
+
if (inJam) store.meta(`jam-run:${runId}`, goalId);
|
|
377
|
+
};
|
|
378
|
+
// `only`: one agent's waiting turns, as when its piece of a jam is released.
|
|
340
379
|
const discard = (goalId, only = null) => {
|
|
341
380
|
for (const agent of only ? [only] : RUNNERS)
|
|
342
|
-
|
|
381
|
+
wakeQueue.discard(goalId, agent, laneKeys(goalId, agent));
|
|
343
382
|
};
|
|
344
383
|
// go: the person's go for this turn (personsGo), their own post naming this agent or one of their agents here asking;
|
|
345
384
|
// any other wake is work another agent asked for and runs restricted or waits.
|
|
@@ -484,7 +523,7 @@ export function createThreadRuns({
|
|
|
484
523
|
orders = false,
|
|
485
524
|
// The asker's turn on its own task's answer (daemon.mjs threadMayRun).
|
|
486
525
|
answer = false,
|
|
487
|
-
// Past a
|
|
526
|
+
// Past a jam's check before work (jams.mjs gate); `wait` holds the run for the person's Start.
|
|
488
527
|
checked = false,
|
|
489
528
|
wait = false,
|
|
490
529
|
// The computer the person named for this turn with # (`@codex #pop-os`), by id.
|
|
@@ -495,7 +534,12 @@ export function createThreadRuns({
|
|
|
495
534
|
// agents elsewhere (runAuthority.mjs PROPOSERS): in a thread another agent wrote, its turn may start on the
|
|
496
535
|
// agent's standing permission (admitProposal). Never the person's go.
|
|
497
536
|
proposal = null,
|
|
537
|
+
// Every call this turn answers, oldest first, when calls queued behind a turn come as one (settleWake); and the
|
|
538
|
+
// log's numbers of what woke it, for a watch's or a wait's answer (wakePicture.mjs).
|
|
539
|
+
reasons = null,
|
|
540
|
+
causes = [],
|
|
498
541
|
} = options;
|
|
542
|
+
const said = reasons?.length ? reasons : [reason];
|
|
499
543
|
const task = store.getTask(goalId);
|
|
500
544
|
if (!task || task.status !== "open" || !RUNNERS.has(agent)) return;
|
|
501
545
|
const proposed =
|
|
@@ -555,7 +599,15 @@ export function createThreadRuns({
|
|
|
555
599
|
null;
|
|
556
600
|
const self = computers?.self() ?? null;
|
|
557
601
|
const heldComputer = computerOf(goalId);
|
|
558
|
-
|
|
602
|
+
// The asker hears the answer to its own task where it asked, whichever computer the task ran on.
|
|
603
|
+
const askedFrom = answer
|
|
604
|
+
? store.meta(`asked-from:${goalId}`) || null
|
|
605
|
+
: null;
|
|
606
|
+
const named = on ?? askedFrom ?? (heldComputer ? null : earlier);
|
|
607
|
+
const askedIn =
|
|
608
|
+
askedFrom && named === askedFrom
|
|
609
|
+
? store.meta(`asked-in:${goalId}`) || null
|
|
610
|
+
: null;
|
|
559
611
|
const routed = !named ? heldComputer || routeMachine : null;
|
|
560
612
|
let routePlacement = null;
|
|
561
613
|
if (routed && routed !== self) {
|
|
@@ -608,7 +660,12 @@ export function createThreadRuns({
|
|
|
608
660
|
named
|
|
609
661
|
);
|
|
610
662
|
if (tried.error) refused = tried.error;
|
|
611
|
-
|
|
663
|
+
// That computer refuses a folder it does not list, which would fail the turn; scratch still hears the answer.
|
|
664
|
+
else
|
|
665
|
+
placed =
|
|
666
|
+
askedIn && computers.runsWorkIn(named, askedIn)
|
|
667
|
+
? { ...tried, folder: askedIn }
|
|
668
|
+
: tried;
|
|
612
669
|
waits = Boolean(tried.waits);
|
|
613
670
|
}
|
|
614
671
|
// Named for this turn and only away for now: the turn waits for that computer and starts there once it is back
|
|
@@ -643,16 +700,25 @@ export function createThreadRuns({
|
|
|
643
700
|
? placeElsewhere(agent, task.goal?.workspace ?? null)
|
|
644
701
|
: null);
|
|
645
702
|
if (!installedAgents.includes(agent) && !elsewhere) return;
|
|
646
|
-
|
|
703
|
+
// The asker's turn on the answer works in the folder it asked from, under the rules any thread's turn in that folder
|
|
704
|
+
// has (its own copy when another agent asked for the work); the thread itself stays where the work is.
|
|
705
|
+
const askerFolder = refused ? null : askedIn;
|
|
706
|
+
const goal = askerFolder
|
|
707
|
+
? { ...task.goal, workspace: askerFolder }
|
|
708
|
+
: task.goal;
|
|
647
709
|
// A thread whose folder is on another computer (swarm.mjs setFolderAway) works there in it.
|
|
648
710
|
const away = folderAway(goalId);
|
|
649
711
|
const awayFolder =
|
|
650
|
-
away && elsewhere?.machine === away.machine
|
|
712
|
+
!askerFolder && away && elsewhere?.machine === away.machine
|
|
713
|
+
? away.path
|
|
714
|
+
: null;
|
|
651
715
|
// A thread with no folder works in its own scratch folder on whichever computer takes the turn (scratch.mjs), as
|
|
652
716
|
// does a turn on a computer with no copy of the thread's folder.
|
|
653
717
|
const scratch =
|
|
654
718
|
!awayFolder &&
|
|
655
|
-
(!goal.workspace ||
|
|
719
|
+
(!goal.workspace ||
|
|
720
|
+
Boolean(elsewhere && !elsewhere.folder) ||
|
|
721
|
+
(!elsewhere && !fs.existsSync(goal.workspace)));
|
|
656
722
|
if (scratch && (goal.workspace || away)) {
|
|
657
723
|
const where = elsewhere?.machine ?? computers?.self() ?? "here";
|
|
658
724
|
const label = computers?.labelOf(where) ?? "this computer";
|
|
@@ -686,15 +752,18 @@ export function createThreadRuns({
|
|
|
686
752
|
const openHere = openWakeIn(goalId, agent, lane);
|
|
687
753
|
if (openHere) {
|
|
688
754
|
const key = laneKey(goalId, agent, lane);
|
|
689
|
-
|
|
690
|
-
store.meta(`other-person-run:${openHere}`, "1");
|
|
755
|
+
heldToJam(openHere, goalId, asker);
|
|
691
756
|
const prior = pendingWakes.get(key);
|
|
692
757
|
// Words the guard read as orders keep the next turn waiting for the person, whatever go an earlier call carried;
|
|
693
758
|
// the person's own call is their go.
|
|
694
759
|
const flagged = asker === "user" ? null : (held ?? prior?.held ?? null);
|
|
760
|
+
// Every call queued behind the running turn reaches the next one, not only the newest (S3.4).
|
|
761
|
+
const before = prior ? (prior.reasons ?? [prior.reason]) : [];
|
|
695
762
|
const pending = {
|
|
696
763
|
id: randomUUID(),
|
|
697
764
|
reason,
|
|
765
|
+
reasons: [...new Set([...before, ...said])],
|
|
766
|
+
causes: [...new Set([...(prior?.causes ?? []), ...causes])],
|
|
698
767
|
asker,
|
|
699
768
|
go: asker === "user" ? go : !flagged && (go || Boolean(prior?.go)),
|
|
700
769
|
held: flagged,
|
|
@@ -733,9 +802,9 @@ export function createThreadRuns({
|
|
|
733
802
|
pauseGoal(goalId, `${agent} was woken ${goal.max_wakes} times`);
|
|
734
803
|
return;
|
|
735
804
|
}
|
|
736
|
-
// In a
|
|
805
|
+
// In a jam, new work is checked against everyone's work and decisions first; a clash holds it, and the
|
|
737
806
|
// agent only talks it out (read-only) until a person OKs the fix.
|
|
738
|
-
const shared =
|
|
807
|
+
const shared = jams()?.isJamRoom(goalId) ? jams() : null;
|
|
739
808
|
if (shared && !checked && !recovering)
|
|
740
809
|
return (
|
|
741
810
|
shared.gate(
|
|
@@ -744,6 +813,8 @@ export function createThreadRuns({
|
|
|
744
813
|
// carries only the go its ask had: a review another person's words started never runs on this person's go.
|
|
745
814
|
(mode, override = null, hold = false) =>
|
|
746
815
|
wakeAgent(goalId, agent, override ?? reason, {
|
|
816
|
+
reasons: override ? null : said,
|
|
817
|
+
causes,
|
|
747
818
|
review: review || (mode === "review" && REVIEWERS.has(agent)),
|
|
748
819
|
go: mode === "review" ? REVIEWERS.has(agent) && go : go,
|
|
749
820
|
wait:
|
|
@@ -754,6 +825,7 @@ export function createThreadRuns({
|
|
|
754
825
|
pick,
|
|
755
826
|
words,
|
|
756
827
|
held,
|
|
828
|
+
orders,
|
|
757
829
|
answer,
|
|
758
830
|
checked: true,
|
|
759
831
|
on,
|
|
@@ -761,11 +833,16 @@ export function createThreadRuns({
|
|
|
761
833
|
})
|
|
762
834
|
) ?? "checking"
|
|
763
835
|
);
|
|
764
|
-
const brief = swarmBrief(task, agent,
|
|
836
|
+
const brief = swarmBrief(task, agent, said, { review, causes });
|
|
765
837
|
// A coding thread in a repository works in its own worktree, so threads never share a checkout; one whose agents the
|
|
766
|
-
// person uses in T3 Code works in T3 (inT3), where T3 makes and keeps the checkout. In a
|
|
838
|
+
// person uses in T3 Code works in T3 (inT3), where T3 makes and keeps the checkout. In a jam each agent
|
|
767
839
|
// works on its own branch here, never in T3's checkout.
|
|
768
|
-
const t3 =
|
|
840
|
+
const t3 =
|
|
841
|
+
!elsewhere &&
|
|
842
|
+
!shared &&
|
|
843
|
+
!scratch &&
|
|
844
|
+
!askerFolder &&
|
|
845
|
+
inT3(task, agent, review);
|
|
769
846
|
// The person uses this agent in T3 Code but this turn runs here: the thread says why, once for each reason.
|
|
770
847
|
const gap =
|
|
771
848
|
t3 || review || elsewhere || scratch
|
|
@@ -788,7 +865,7 @@ export function createThreadRuns({
|
|
|
788
865
|
try {
|
|
789
866
|
folder =
|
|
790
867
|
(shared ? shared.folderFor(task, agent, { review }) : null) ??
|
|
791
|
-
worktrees.folderFor(task);
|
|
868
|
+
worktrees.folderFor(askerFolder ? { ...task, goal } : task);
|
|
792
869
|
} catch (error) {
|
|
793
870
|
store.roomPost({
|
|
794
871
|
goalId,
|
|
@@ -829,15 +906,16 @@ export function createThreadRuns({
|
|
|
829
906
|
kind: "wake",
|
|
830
907
|
targetMachine: elsewhere?.machine ?? null,
|
|
831
908
|
});
|
|
832
|
-
if (!scratch && (elsewhere?.machine || self))
|
|
909
|
+
if (!scratch && !askerFolder && (elsewhere?.machine || self))
|
|
833
910
|
store.meta(`thread-work-computer:${goalId}`, elsewhere?.machine ?? self);
|
|
834
911
|
if (t3) store.meta(`t3-run:${wake.id}`, "1");
|
|
835
912
|
if (lane) store.meta(`lane:${wake.id}`, lane);
|
|
836
|
-
|
|
837
|
-
|
|
913
|
+
// A queued call that went through a shared room's check has its wake now (settleWake).
|
|
914
|
+
if (checked) pendingWakes.delete(laneKey(goalId, agent, lane));
|
|
915
|
+
heldToJam(wake.id, goalId, asker);
|
|
838
916
|
store.meta(
|
|
839
917
|
`wake-reason:${wake.id}`,
|
|
840
|
-
JSON.stringify({ reason, review, asker })
|
|
918
|
+
JSON.stringify({ reason, review, asker, reasons: said, causes })
|
|
841
919
|
);
|
|
842
920
|
if (pick) setRunPick(store, wake.id, pick, asker);
|
|
843
921
|
// A review runs with the agent's own read-only switch (runner.mjs); only Claude Code and Codex have one.
|
|
@@ -887,7 +965,9 @@ export function createThreadRuns({
|
|
|
887
965
|
// A wake's brief as of its start, not of when it was queued: a turn that waited for the folder reads the thread as it
|
|
888
966
|
// is now, with a call that came while it waited (once Codex, queued at 07:29, started at 07:39 on a brief without
|
|
889
967
|
// Claude Code's 07:38 handoff, and settleWake dropped the handoff's own wake as already read).
|
|
890
|
-
|
|
968
|
+
// `told`: what the session it runs in already has (sessionBriefs.mjs), left out of the brief. `here`: whether the turn
|
|
969
|
+
// runs on this computer, whose log the picture of what changed reads (wakePicture.mjs).
|
|
970
|
+
const wakeBrief = (wake, told = null, { here = true } = {}) => {
|
|
891
971
|
// When the brief read the thread: words before it are in the brief, words after it wake the agent again (settleWake).
|
|
892
972
|
store.meta(`brief-read:${wake.id}`, new Date().toISOString());
|
|
893
973
|
const thread = store.getTask(wake.parent_id);
|
|
@@ -900,12 +980,22 @@ export function createThreadRuns({
|
|
|
900
980
|
pendingWakes.get(
|
|
901
981
|
laneKey(thread.id, wake.target_agent, store.meta(`lane:${wake.id}`))
|
|
902
982
|
) ?? pendingWakes.get(laneKey(thread.id, wake.target_agent));
|
|
903
|
-
const
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
983
|
+
const queued = later && later.at > wake.created_at ? later : null;
|
|
984
|
+
const reasons = [
|
|
985
|
+
...new Set([
|
|
986
|
+
...(woken.reasons ?? [woken.reason]),
|
|
987
|
+
...(queued ? (queued.reasons ?? [queued.reason]) : []),
|
|
988
|
+
]),
|
|
989
|
+
];
|
|
990
|
+
const causes = [
|
|
991
|
+
...new Set([...(woken.causes ?? []), ...(queued?.causes ?? [])]),
|
|
992
|
+
];
|
|
993
|
+
return swarmBrief(thread, wake.target_agent, reasons, {
|
|
908
994
|
review: woken.review,
|
|
995
|
+
told,
|
|
996
|
+
causes,
|
|
997
|
+
wakeId: wake.id,
|
|
998
|
+
here,
|
|
909
999
|
});
|
|
910
1000
|
};
|
|
911
1001
|
const notePeerOverlap = (goalId) => {
|
|
@@ -956,11 +1046,11 @@ export function createThreadRuns({
|
|
|
956
1046
|
if (inThreadCopy(task)) worktrees.startTurn(task.parent_id, task.id);
|
|
957
1047
|
};
|
|
958
1048
|
// For code, made means committed on the thread's branch: a run's changes in its thread's copy are committed as soon
|
|
959
|
-
// as it ends, whatever kind of run it was, before another run can start there. A
|
|
960
|
-
// its own branch (
|
|
1049
|
+
// as it ends, whatever kind of run it was, before another run can start there. A jam's agent commits on
|
|
1050
|
+
// its own branch (jams.mjs, undefined for any other thread).
|
|
961
1051
|
const commitRun = (task) => {
|
|
962
1052
|
if (store.meta(`review:${task.id}`) === "1") return null;
|
|
963
|
-
const onBranch =
|
|
1053
|
+
const onBranch = jams()?.committed(task);
|
|
964
1054
|
if (onBranch !== undefined) {
|
|
965
1055
|
verdicts?.returned(task);
|
|
966
1056
|
return onBranch;
|
|
@@ -1035,16 +1125,24 @@ export function createThreadRuns({
|
|
|
1035
1125
|
// The computer the turn ran on (runWorker.mjs claims it there): the same agent may have a turn on another computer
|
|
1036
1126
|
// in this thread at once, and that turn's posts are not this one's.
|
|
1037
1127
|
const ranOn = store.getTask(task.id)?.claimed_machine ?? null;
|
|
1128
|
+
// Its "Next:" line is kept for its next turn here, out of the thread; a turn that ends without one, or fails,
|
|
1129
|
+
// leaves none (nextStep.mjs).
|
|
1130
|
+
const said = kind === "done" ? withoutNextStep(text) : text;
|
|
1131
|
+
nextSteps?.keep(
|
|
1132
|
+
goalId,
|
|
1133
|
+
task.target_agent,
|
|
1134
|
+
kind === "done" ? nextStepOf(text) : null
|
|
1135
|
+
);
|
|
1038
1136
|
if (
|
|
1039
1137
|
!stopped &&
|
|
1040
1138
|
!store.postsBy(goalId, task.target_agent, startedAt, ranOn) &&
|
|
1041
|
-
|
|
1139
|
+
said
|
|
1042
1140
|
)
|
|
1043
1141
|
store.roomPost({
|
|
1044
1142
|
goalId,
|
|
1045
1143
|
author: task.target_agent,
|
|
1046
1144
|
kind: kind === "done" ? "post" : "failed",
|
|
1047
|
-
text: kind === "done" ?
|
|
1145
|
+
text: kind === "done" ? said : `run failed: ${said}`,
|
|
1048
1146
|
machine: ranOn,
|
|
1049
1147
|
});
|
|
1050
1148
|
// Its report: the agent's newest post from this turn's computer since the turn began, the one above or its own.
|
|
@@ -1078,6 +1176,8 @@ export function createThreadRuns({
|
|
|
1078
1176
|
pendingWakes.delete(key);
|
|
1079
1177
|
} else if (pending) {
|
|
1080
1178
|
const next = wakeAgent(goalId, task.target_agent, pending.reason, {
|
|
1179
|
+
reasons: pending.reasons ?? [pending.reason],
|
|
1180
|
+
causes: pending.causes ?? [],
|
|
1081
1181
|
go: pending.go,
|
|
1082
1182
|
asker: pending.asker,
|
|
1083
1183
|
pick: pending.pick,
|
|
@@ -1087,8 +1187,14 @@ export function createThreadRuns({
|
|
|
1087
1187
|
proposal: pending.proposal ?? null,
|
|
1088
1188
|
on: pending.on ?? null,
|
|
1089
1189
|
});
|
|
1090
|
-
|
|
1091
|
-
if (
|
|
1190
|
+
const refused = wakeQueue.afterWake(key, next);
|
|
1191
|
+
if (refused)
|
|
1192
|
+
store.roomPost({
|
|
1193
|
+
goalId,
|
|
1194
|
+
author: DISPATCHER,
|
|
1195
|
+
kind: "note",
|
|
1196
|
+
text: `${nameOf(task.target_agent)} was not woken again: ${refused}`,
|
|
1197
|
+
});
|
|
1092
1198
|
}
|
|
1093
1199
|
notifyBoard(store.getTask(goalId));
|
|
1094
1200
|
};
|
|
@@ -1139,6 +1245,7 @@ export function createThreadRuns({
|
|
|
1139
1245
|
recover,
|
|
1140
1246
|
where: runsIn,
|
|
1141
1247
|
worker: {
|
|
1248
|
+
folderForRun,
|
|
1142
1249
|
resumeAfterSteer,
|
|
1143
1250
|
startTurn,
|
|
1144
1251
|
commitRun,
|
|
@@ -1148,6 +1255,7 @@ export function createThreadRuns({
|
|
|
1148
1255
|
t3CatchUp,
|
|
1149
1256
|
t3Turn,
|
|
1150
1257
|
taskInT3,
|
|
1258
|
+
herdrTurn,
|
|
1151
1259
|
},
|
|
1152
1260
|
missed: t3Missed,
|
|
1153
1261
|
};
|