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/machineRuns.mjs
CHANGED
|
@@ -17,6 +17,8 @@ import { prepareScratch, threadScratch } from "./scratch.mjs";
|
|
|
17
17
|
// own run worker tells its steps, runWorker.mjs), the latest standing for those between. Nothing is told while a run
|
|
18
18
|
// takes no step, and a step home could not hear is not kept: the last one it heard stands, as for a computer offline.
|
|
19
19
|
const STEP_NOTICE_MS = 1_000;
|
|
20
|
+
// Longer than this from posted to started is said in the log, with where it went.
|
|
21
|
+
const SLOW_START_MS = 2_000;
|
|
20
22
|
// An agent's session id as this computer's agents name theirs; never one an agent's command line would read as a flag.
|
|
21
23
|
const SESSION_ID = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$/;
|
|
22
24
|
//
|
|
@@ -49,8 +51,40 @@ export function createMachineRuns({
|
|
|
49
51
|
modelFor = async () => null,
|
|
50
52
|
// The person holds new runs on this computer (runWorker.mjs hold): none of home's work starts here meanwhile.
|
|
51
53
|
held = () => false,
|
|
54
|
+
// The runs this computer took from home and has not reported yet, kept on disk across a restart: { taskId: agent }.
|
|
55
|
+
remembered = () => ({}),
|
|
56
|
+
remember = () => {},
|
|
52
57
|
}) {
|
|
53
58
|
const active = new Map();
|
|
59
|
+
// Every run this computer takes is reported to home as it ends. One a stopped or crashed daemon never reported is
|
|
60
|
+
// reported when it starts again (reportLeft): its process went with it, so home must not keep it going.
|
|
61
|
+
const taken = new Map(Object.entries(remembered()));
|
|
62
|
+
const left = new Set(taken.keys());
|
|
63
|
+
const keepTaken = () => remember(Object.fromEntries(taken));
|
|
64
|
+
const tellEnded = (id, agent, result) =>
|
|
65
|
+
callHome({
|
|
66
|
+
command: "board.machine.finish",
|
|
67
|
+
agent,
|
|
68
|
+
id,
|
|
69
|
+
status: "failed",
|
|
70
|
+
result,
|
|
71
|
+
failure: "exit",
|
|
72
|
+
}).catch(() => null);
|
|
73
|
+
const forget = (id) => {
|
|
74
|
+
taken.delete(id);
|
|
75
|
+
left.delete(id);
|
|
76
|
+
keepTaken();
|
|
77
|
+
};
|
|
78
|
+
const reportLeft = async () => {
|
|
79
|
+
for (const id of [...left]) {
|
|
80
|
+
await tellEnded(
|
|
81
|
+
id,
|
|
82
|
+
taken.get(id),
|
|
83
|
+
"Harness on the computer running this stopped during it (a restart or a crash), so it ended there; its outcome is unknown. Check the folder."
|
|
84
|
+
);
|
|
85
|
+
forget(id);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
54
88
|
const steps = new Map();
|
|
55
89
|
let asking = false;
|
|
56
90
|
let askAgain = false;
|
|
@@ -81,7 +115,8 @@ export function createMachineRuns({
|
|
|
81
115
|
// A thread with no folder: its turn here works in that thread's scratch folder on this computer (scratch.mjs), as
|
|
82
116
|
// does a task naming no folder that home says goes there (taskCommands.mjs forWorker), and a thread's turn naming
|
|
83
117
|
// home or above it, or this computer's scratch path for it (a ComfyUI picture asked for in /home/saltorious once
|
|
84
|
-
// failed to start)
|
|
118
|
+
// failed to start), or a folder that is not on this computer at all (owner, November 2: "should always fall back to a
|
|
119
|
+
// scratch folder").
|
|
85
120
|
const inScratch = (task) => {
|
|
86
121
|
if (!task.parent_id) return false;
|
|
87
122
|
if (!task.run_workspace)
|
|
@@ -91,8 +126,9 @@ export function createMachineRuns({
|
|
|
91
126
|
const named = path.resolve(task.run_workspace);
|
|
92
127
|
const folder = real(named);
|
|
93
128
|
return (
|
|
129
|
+
!folder ||
|
|
94
130
|
named === threadScratch(task.parent_id) ||
|
|
95
|
-
Boolean(
|
|
131
|
+
Boolean(home && within(home, folder))
|
|
96
132
|
);
|
|
97
133
|
};
|
|
98
134
|
// One turn per agent per folder, other agents side by side (runWorker.mjs slotOf).
|
|
@@ -123,7 +159,17 @@ export function createMachineRuns({
|
|
|
123
159
|
)
|
|
124
160
|
.join("\n");
|
|
125
161
|
const notice = provenanceLine(task, readProfile()?.displayName);
|
|
126
|
-
|
|
162
|
+
const noFolder =
|
|
163
|
+
task.run_workspace && inScratch(task) && !real(task.run_workspace)
|
|
164
|
+
? `${task.run_workspace} is not on this computer, so you are working in a scratch folder. Say so in your report.`
|
|
165
|
+
: "";
|
|
166
|
+
return [
|
|
167
|
+
notice,
|
|
168
|
+
noFolder,
|
|
169
|
+
task.objective,
|
|
170
|
+
task.brief,
|
|
171
|
+
refs ? `Context:\n${refs}` : "",
|
|
172
|
+
]
|
|
127
173
|
.filter(Boolean)
|
|
128
174
|
.join("\n\n");
|
|
129
175
|
};
|
|
@@ -156,6 +202,8 @@ export function createMachineRuns({
|
|
|
156
202
|
const start = async (task, slot, { chosen, cwd }) => {
|
|
157
203
|
const agent = task.target_agent;
|
|
158
204
|
log(`running ${agent}'s task ${task.id} from your home computer`);
|
|
205
|
+
taken.set(task.id, agent);
|
|
206
|
+
keepTaken();
|
|
159
207
|
// A start on another of the person's agents' asks on standing permission grants no secrets (runAuthority.mjs).
|
|
160
208
|
// Nor for a held-in run, nor work another person asked for (runWorker.mjs startBoardRun).
|
|
161
209
|
const secrets =
|
|
@@ -183,6 +231,9 @@ export function createMachineRuns({
|
|
|
183
231
|
...(task.readOnly === true ? { readOnly: true } : {}),
|
|
184
232
|
...(task.restricted === true ? { restricted: true } : {}),
|
|
185
233
|
...(task.ownSettingsOnly === true ? { ownSettingsOnly: true } : {}),
|
|
234
|
+
...(typeof task.jamThread === "string"
|
|
235
|
+
? { jamThread: task.jamThread }
|
|
236
|
+
: {}),
|
|
186
237
|
...secrets,
|
|
187
238
|
},
|
|
188
239
|
(kind, text, extra) => {
|
|
@@ -213,6 +264,7 @@ export function createMachineRuns({
|
|
|
213
264
|
log(
|
|
214
265
|
`task ${task.id} ended ${kind} but home did not take it: ${answer.error}`
|
|
215
266
|
);
|
|
267
|
+
forget(task.id);
|
|
216
268
|
void check();
|
|
217
269
|
});
|
|
218
270
|
}
|
|
@@ -264,6 +316,7 @@ export function createMachineRuns({
|
|
|
264
316
|
}
|
|
265
317
|
asking = true;
|
|
266
318
|
try {
|
|
319
|
+
await reportLeft();
|
|
267
320
|
const answer = await callHome({
|
|
268
321
|
command: "board.machine.runnable",
|
|
269
322
|
agent: "user",
|
|
@@ -278,7 +331,9 @@ export function createMachineRuns({
|
|
|
278
331
|
const slot = slotOf(task);
|
|
279
332
|
if (held() || active.has(slot)) continue;
|
|
280
333
|
active.set(slot, task.id);
|
|
334
|
+
const heardAt = Date.now();
|
|
281
335
|
const prepared = await prepare(task).catch(() => null);
|
|
336
|
+
const preparedAt = Date.now();
|
|
282
337
|
// Preparing awaited the model and home's files: a hold or a changed folder since then starts nothing.
|
|
283
338
|
const refusedNow = prepared ? refusalFor(task) : null;
|
|
284
339
|
if (!prepared || held() || refusedNow) {
|
|
@@ -296,6 +351,13 @@ export function createMachineRuns({
|
|
|
296
351
|
active.delete(slot);
|
|
297
352
|
continue;
|
|
298
353
|
}
|
|
354
|
+
// Where the wait went when work takes long to start here (owner, November 5: a task for this computer started 66 s
|
|
355
|
+
// after home posted it, and nothing said why).
|
|
356
|
+
const sinceCreated = heardAt - Date.parse(task.created_at);
|
|
357
|
+
if (Date.now() - Date.parse(task.created_at) > SLOW_START_MS)
|
|
358
|
+
log(
|
|
359
|
+
`task ${task.id}: heard of it ${sinceCreated} ms after it was posted, got ready in ${preparedAt - heardAt} ms, home handed it over in ${Date.now() - preparedAt} ms`
|
|
360
|
+
);
|
|
299
361
|
// What home handed over is what was prepared: the same agent, folder and kind of place, still one this
|
|
300
362
|
// computer runs in. Anything else is ended with why, since it is taken now.
|
|
301
363
|
const changed = held()
|
|
@@ -332,5 +394,24 @@ export function createMachineRuns({
|
|
|
332
394
|
}
|
|
333
395
|
};
|
|
334
396
|
|
|
335
|
-
|
|
397
|
+
/**
|
|
398
|
+
* As the daemon stops: every run going here is told to home as ended, before this computer goes. A report home cannot
|
|
399
|
+
* take now is kept for it (queued, ownMachines.mjs callHome); one cut off by the stop is sent at the next start.
|
|
400
|
+
*/
|
|
401
|
+
const interruptAll = () =>
|
|
402
|
+
Promise.all(
|
|
403
|
+
[...taken]
|
|
404
|
+
.filter(([id]) => !left.has(id))
|
|
405
|
+
.map(async ([id, agent]) => {
|
|
406
|
+
stopSteps(id);
|
|
407
|
+
const answer = await tellEnded(
|
|
408
|
+
id,
|
|
409
|
+
agent,
|
|
410
|
+
"Harness on the computer running this stopped during it, so it ended there; its outcome is unknown. Check the folder."
|
|
411
|
+
);
|
|
412
|
+
if (answer) forget(id);
|
|
413
|
+
})
|
|
414
|
+
);
|
|
415
|
+
|
|
416
|
+
return { check, interruptAll, running: () => [...active.values()] };
|
|
336
417
|
}
|
package/lib/machineSeal.mjs
CHANGED
|
@@ -114,35 +114,26 @@ export const pairKey = (privateKey, peerPublicKey, workerId) =>
|
|
|
114
114
|
export const newRequestId = () => randomBytes(16).toString("base64url");
|
|
115
115
|
|
|
116
116
|
/** A worker's board call, sealed for home. */
|
|
117
|
-
// `session`: the session home gave this worker (callSessions.mjs), for a call through Harness that home guards in
|
|
118
|
-
// memory rather than by keeping its request id.
|
|
119
117
|
export function sealCall(
|
|
120
118
|
key,
|
|
121
119
|
workerId,
|
|
122
120
|
requestId,
|
|
123
121
|
call,
|
|
124
|
-
{ queued = false,
|
|
122
|
+
{ queued = false, now = Date.now() } = {}
|
|
125
123
|
) {
|
|
126
|
-
return seal(key, "w2h", workerId, requestId, {
|
|
127
|
-
ts: now,
|
|
128
|
-
call,
|
|
129
|
-
queued,
|
|
130
|
-
...(session ? { session } : {}),
|
|
131
|
-
});
|
|
124
|
+
return seal(key, "w2h", workerId, requestId, { ts: now, call, queued });
|
|
132
125
|
}
|
|
133
126
|
|
|
134
127
|
const age = (ts, now) => (typeof ts === "number" ? now - ts : Infinity);
|
|
135
128
|
|
|
136
129
|
/**
|
|
137
|
-
* Home opening a worker's call. `from` is the worker
|
|
138
|
-
*
|
|
139
|
-
* "fresh", "replayed", or "expired" for a session home no longer holds (it restarted, or gave the worker a newer one).
|
|
140
|
-
* Returns { ok, call, queued, session } or { ok: false, code, error }.
|
|
130
|
+
* Home opening a worker's call. `from` is the worker that sent it; `firstSeen(requestId)` is false for a request id
|
|
131
|
+
* already taken. Returns { ok, call, queued } or { ok: false, code, error }.
|
|
141
132
|
*/
|
|
142
133
|
export async function openCall(
|
|
143
134
|
key,
|
|
144
135
|
envelope,
|
|
145
|
-
{ from, firstSeen,
|
|
136
|
+
{ from, firstSeen, now = Date.now() }
|
|
146
137
|
) {
|
|
147
138
|
if (envelope?.deviceId !== from)
|
|
148
139
|
return {
|
|
@@ -171,22 +162,7 @@ export async function openCall(
|
|
|
171
162
|
code: "stale",
|
|
172
163
|
error: "the call is too old or the computer's clock is off",
|
|
173
164
|
};
|
|
174
|
-
|
|
175
|
-
!opened.queued && typeof opened.session === "string"
|
|
176
|
-
? opened.session
|
|
177
|
-
: null;
|
|
178
|
-
const seen = session
|
|
179
|
-
? inSession(session, envelope.requestId)
|
|
180
|
-
: firstSeen(envelope.requestId)
|
|
181
|
-
? "fresh"
|
|
182
|
-
: "replayed";
|
|
183
|
-
if (seen === "expired")
|
|
184
|
-
return {
|
|
185
|
-
ok: false,
|
|
186
|
-
code: "session_expired",
|
|
187
|
-
error: "this computer's session with home ended; it starts a new one",
|
|
188
|
-
};
|
|
189
|
-
if (seen !== "fresh")
|
|
165
|
+
if (!firstSeen(envelope.requestId))
|
|
190
166
|
return {
|
|
191
167
|
ok: false,
|
|
192
168
|
code: "replayed",
|
|
@@ -196,7 +172,6 @@ export async function openCall(
|
|
|
196
172
|
ok: true,
|
|
197
173
|
call: opened.call,
|
|
198
174
|
queued: opened.queued === true,
|
|
199
|
-
session,
|
|
200
175
|
};
|
|
201
176
|
}
|
|
202
177
|
|
package/lib/manager.mjs
CHANGED
|
@@ -39,6 +39,10 @@ export function createManager({
|
|
|
39
39
|
computerAddress = () => ({ ok: true, forAgent: () => null }),
|
|
40
40
|
// The agents a post names (members.mjs mentionsIn over the thread's agents).
|
|
41
41
|
agentsIn = () => [],
|
|
42
|
+
// Who judges an agent's result: Jev on Harness's server, as a function of the input, or null for the dispatcher (the
|
|
43
|
+
// privacy setting, or a server that does not judge). On real threads round 3 of the fine-tune called "done" 24 of 33
|
|
44
|
+
// times, for plans and refusals among them; Jev called 8 (real-flow, November 5).
|
|
45
|
+
resultsJudge = () => null,
|
|
42
46
|
log = () => {},
|
|
43
47
|
}) {
|
|
44
48
|
const key = (threadId) => `owner-asks:${threadId}`;
|
|
@@ -121,6 +125,73 @@ export function createManager({
|
|
|
121
125
|
transcript: before(thread.id, entry.seq),
|
|
122
126
|
});
|
|
123
127
|
|
|
128
|
+
// A number that names no open task: with one open it can only mean that one; with several, nothing is folded into a
|
|
129
|
+
// guess, so the words stay a task of their own (real-flow: round 3 said task 12 of 1 for "lets make this nicer").
|
|
130
|
+
const steeredAsk = (asks, steers) => {
|
|
131
|
+
if (steers === null || steers === undefined) return null;
|
|
132
|
+
if (asks[steers]) return asks[steers].id;
|
|
133
|
+
log(`manager: the dispatcher named task ${steers} of ${asks.length}`);
|
|
134
|
+
return asks.length === 1 ? asks[0].id : null;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// Jev reads a goal's check as one more item of work. If it can't be reached the items stay as they are: an open ask
|
|
138
|
+
// waits for the next report, and is never settled on a guess.
|
|
139
|
+
const judgedByJev = async (input, ask) => {
|
|
140
|
+
const { handed_to: _, ...post } = input.post;
|
|
141
|
+
const items = input.asks.slice(-MAX_ASKS);
|
|
142
|
+
const reply = await ask({
|
|
143
|
+
thread: input.thread,
|
|
144
|
+
kind: "report",
|
|
145
|
+
post,
|
|
146
|
+
transcript: input.transcript,
|
|
147
|
+
asks: items.map((item) =>
|
|
148
|
+
item.kind === "check"
|
|
149
|
+
? {
|
|
150
|
+
id: item.id,
|
|
151
|
+
kind: "work",
|
|
152
|
+
words: item.words.map(({ text }) => ({
|
|
153
|
+
seq: input.post.seq,
|
|
154
|
+
text,
|
|
155
|
+
})),
|
|
156
|
+
}
|
|
157
|
+
: item
|
|
158
|
+
),
|
|
159
|
+
}).catch((error) => {
|
|
160
|
+
log(`manager: Jev could not judge a report (${error.message})`);
|
|
161
|
+
return null;
|
|
162
|
+
});
|
|
163
|
+
// The bridge lays the server's answer out beside `ok` (bridge.mjs).
|
|
164
|
+
const found = reply?.ok ? (reply.findings ?? []) : [];
|
|
165
|
+
const isCheck = (finding) =>
|
|
166
|
+
items.find((item) => item.id === finding.id)?.kind === "check";
|
|
167
|
+
return {
|
|
168
|
+
kind: "report",
|
|
169
|
+
findings: found.filter((finding) => !isCheck(finding)),
|
|
170
|
+
reached: found
|
|
171
|
+
.filter(
|
|
172
|
+
(finding) =>
|
|
173
|
+
isCheck(finding) &&
|
|
174
|
+
finding.state === "done" &&
|
|
175
|
+
finding.shown >= FLOOR
|
|
176
|
+
)
|
|
177
|
+
.map((finding) => finding.id),
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// Whether everyone this report names is an agent that called on its author earlier in the thread.
|
|
182
|
+
const answersItsCaller = ({ thread, post }) => {
|
|
183
|
+
const callers = store
|
|
184
|
+
.roomPosts(thread.id, 0, 500)
|
|
185
|
+
.filter(
|
|
186
|
+
(each) =>
|
|
187
|
+
each.seq < post.seq &&
|
|
188
|
+
each.author !== post.author &&
|
|
189
|
+
handedTo(each).includes(post.author)
|
|
190
|
+
)
|
|
191
|
+
.map((each) => each.author);
|
|
192
|
+
return post.handed_to.every((agent) => callers.includes(agent));
|
|
193
|
+
};
|
|
194
|
+
|
|
124
195
|
const judge = async (input) => {
|
|
125
196
|
// A report that calls on another agent and holds no result of its own settles nothing: that agent's own report
|
|
126
197
|
// will. Asked on its own and as "does it hold the result": the base LFM3-Omni judged Claude Code's handoff done
|
|
@@ -132,8 +203,26 @@ export function createManager({
|
|
|
132
203
|
.catch(() => null);
|
|
133
204
|
if (handed?.has_result === false)
|
|
134
205
|
return { kind: "report", findings: [], reached: [], handedOff: true };
|
|
206
|
+
// With Jev, a report the slot thinks holds a result goes on to Jev, which reads it right (eval handoff-report). Alone,
|
|
207
|
+
// a wrong "holds a result" here settles the ask with nothing done, so it is asked a second way, and either "no" is
|
|
208
|
+
// enough. An answer to the agent that called on this one isn't passing anything on, so it isn't asked.
|
|
209
|
+
if (!resultsJudge() && !answersItsCaller(input)) {
|
|
210
|
+
const left = await dispatcher
|
|
211
|
+
.judge("handoff_left", { post: input.post })
|
|
212
|
+
.catch(() => null);
|
|
213
|
+
if (left?.has_result === false)
|
|
214
|
+
return { kind: "report", findings: [], reached: [], handedOff: true };
|
|
215
|
+
}
|
|
135
216
|
}
|
|
136
217
|
if (input.kind === "message") {
|
|
218
|
+
// While the slot's model is still coming down, Jev sorts the message so it isn't lost.
|
|
219
|
+
const stopgap =
|
|
220
|
+
dispatcher.state?.().ready === false ? resultsJudge() : null;
|
|
221
|
+
if (stopgap) {
|
|
222
|
+
const reply = await stopgap(input).catch(() => null);
|
|
223
|
+
if (reply?.ok && reply.message)
|
|
224
|
+
return { kind: "message", message: reply.message };
|
|
225
|
+
}
|
|
137
226
|
const said = await dispatcher.judge("message", input);
|
|
138
227
|
// The dispatcher names the message's kind; a model that answers in sureness (0 to 1, as Jev did) is read too.
|
|
139
228
|
const sure = (kind, field) =>
|
|
@@ -145,20 +234,25 @@ export function createManager({
|
|
|
145
234
|
question: sure("question", "question"),
|
|
146
235
|
exploring: sure("idea", "exploring"),
|
|
147
236
|
answer: sure("answer", "answer"),
|
|
148
|
-
steers: input.asks
|
|
237
|
+
steers: steeredAsk(input.asks, said?.steers),
|
|
149
238
|
withdraws:
|
|
150
239
|
said?.withdraws === true ? 1 : Number(said?.withdraws) || 0,
|
|
151
240
|
},
|
|
152
241
|
};
|
|
153
242
|
}
|
|
243
|
+
const jev = resultsJudge();
|
|
244
|
+
if (jev) return judgedByJev(input, jev);
|
|
154
245
|
const truth = (value) => (value === true ? 1 : Number(value) || 0);
|
|
155
246
|
const judged = [];
|
|
156
247
|
for (const item of input.asks) {
|
|
248
|
+
// From the ask on: what came before it was about something else, and the model held Codex's right answer about
|
|
249
|
+
// pop-os against an earlier question about this Mac (dispatcher-slot 2b).
|
|
250
|
+
const asked = item.words?.[0]?.seq ?? 0;
|
|
157
251
|
const one = await dispatcher
|
|
158
252
|
.judge("report", {
|
|
159
253
|
thread: input.thread,
|
|
160
254
|
post: input.post,
|
|
161
|
-
transcript: input.transcript,
|
|
255
|
+
transcript: input.transcript.filter((each) => each.seq >= asked),
|
|
162
256
|
item: { kind: item.kind, words: item.words },
|
|
163
257
|
})
|
|
164
258
|
.catch((error) => {
|
|
@@ -294,9 +388,9 @@ export function createManager({
|
|
|
294
388
|
});
|
|
295
389
|
};
|
|
296
390
|
/** An agent reported doing something in the thread: where each of the person's open asks stands now. */
|
|
297
|
-
const reported = (thread, entry) =>
|
|
391
|
+
const reported = (thread, entry, { goalOnly = false } = {}) =>
|
|
298
392
|
queue(thread.id, async () => {
|
|
299
|
-
const asks = openOf(thread.id).slice(-MAX_ASKS);
|
|
393
|
+
const asks = goalOnly ? [] : openOf(thread.id).slice(-MAX_ASKS);
|
|
300
394
|
const criteria = openCriteria(thread);
|
|
301
395
|
if (!asks.length && !criteria.length) return;
|
|
302
396
|
const judged = await judge(inputFor(thread, "report", entry, asks));
|
|
@@ -338,13 +432,20 @@ export function createManager({
|
|
|
338
432
|
lines.push(`Done: ${label(one)}, shown in #${entry.seq}`);
|
|
339
433
|
continue;
|
|
340
434
|
}
|
|
341
|
-
//
|
|
435
|
+
// Said done with nothing that shows it: the person looks. Sending it back made agents redo finished work (real-flow:
|
|
436
|
+
// "Finder's open on MacBook-Pro-3" was done, and Jev found little to show it).
|
|
437
|
+
if (found.state === "done") {
|
|
438
|
+
one.status = "review";
|
|
439
|
+
lines.push(
|
|
440
|
+
`Ready for your review: ${label(one)}. ${nameOf(entry.author)} says it is done, but nothing in the thread shows it`
|
|
441
|
+
);
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
// Ignored or contradicted.
|
|
342
445
|
const why =
|
|
343
|
-
found.state === "
|
|
344
|
-
? "
|
|
345
|
-
:
|
|
346
|
-
? "does not do it, or does only part of it"
|
|
347
|
-
: "does something different from what the person asked, or claims something the thread does not show";
|
|
446
|
+
found.state === "ignored"
|
|
447
|
+
? "does not do it, or does only part of it"
|
|
448
|
+
: "does something different from what the person asked, or claims something the thread does not show";
|
|
348
449
|
if ((one.tries ?? 0) >= 1) {
|
|
349
450
|
one.status = "waiting";
|
|
350
451
|
lines.push(
|
|
@@ -359,9 +460,30 @@ export function createManager({
|
|
|
359
460
|
}
|
|
360
461
|
keep(thread.id, all);
|
|
361
462
|
say(thread, lines);
|
|
362
|
-
if (
|
|
463
|
+
if (
|
|
464
|
+
(goalOnly ? reached.length : findings.length) &&
|
|
465
|
+
!openOf(thread.id).length
|
|
466
|
+
)
|
|
467
|
+
settled(thread.id);
|
|
363
468
|
});
|
|
364
469
|
|
|
470
|
+
/**
|
|
471
|
+
* The thread's goal was written just now, after the agent had the message (coordinator.mjs): an agent that already
|
|
472
|
+
* reported since the person's last word is read against its checks, or a quick answer would leave them open for good.
|
|
473
|
+
*/
|
|
474
|
+
const goalWritten = (thread) => {
|
|
475
|
+
const posts = store.roomPosts(thread.id, 0, 500);
|
|
476
|
+
const said = posts.findLast((post) => post.author === "user")?.seq ?? 0;
|
|
477
|
+
const report = posts.findLast(
|
|
478
|
+
(post) =>
|
|
479
|
+
post.seq > said &&
|
|
480
|
+
post.author !== "user" &&
|
|
481
|
+
post.author !== thread.goal.facilitator &&
|
|
482
|
+
["result", "post"].includes(post.kind)
|
|
483
|
+
);
|
|
484
|
+
if (report) void reported(thread, report, { goalOnly: true });
|
|
485
|
+
};
|
|
486
|
+
|
|
365
487
|
// The person's words go back whole, every one of them for this ask, oldest first.
|
|
366
488
|
const sendBack = (thread, entry, one, why) => {
|
|
367
489
|
const agent = entry.author;
|
|
@@ -387,5 +509,5 @@ export function createManager({
|
|
|
387
509
|
/** The person's open asks in a thread: what keeps it from closing, each as its short label. */
|
|
388
510
|
const open = (threadId) => openOf(threadId).map(label);
|
|
389
511
|
|
|
390
|
-
return { heard, reported, open, asks: asksOf };
|
|
512
|
+
return { heard, reported, goalWritten, open, asks: asksOf };
|
|
391
513
|
}
|