tryharness 0.7.54 → 0.7.57
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 +15 -16
- package/cli.mjs +377 -62
- package/lib/activity.mjs +10 -10
- package/lib/adapters.mjs +16 -0
- package/lib/agentBinaries.mjs +71 -0
- package/lib/agentRuntimeConfig.mjs +1 -1
- package/lib/agentRuntimes.mjs +9 -3
- package/lib/agentSignIn.mjs +271 -41
- package/lib/answers.mjs +5 -5
- package/lib/archetypes.d.ts +64 -0
- package/lib/archetypes.js +989 -0
- package/lib/asks.mjs +4 -4
- package/lib/audit.mjs +36 -13
- package/lib/backupSetup.mjs +4 -2
- package/lib/boardAccess.mjs +17 -11
- package/lib/boardBackup.mjs +6 -6
- package/lib/boardFileCommands.mjs +6 -6
- package/lib/boardFiles.mjs +13 -12
- package/lib/boardMirror.mjs +82 -47
- package/lib/boardProtocol.json +30 -1
- package/lib/boardWaits.mjs +2 -3
- package/lib/book.mjs +6 -6
- package/lib/bridge.mjs +5 -5
- package/lib/cards.mjs +2 -2
- package/lib/cloudAgents.mjs +216 -0
- package/lib/cloudAi.mjs +1312 -0
- package/lib/cloudAssistants.mjs +242 -0
- package/lib/cloudBoot.mjs +81 -86
- package/lib/cloudSave.mjs +197 -0
- package/lib/cloudSsh.mjs +178 -0
- package/lib/context.mjs +3 -3
- package/lib/contractGate.mjs +34 -12
- package/lib/control-client.mjs +9 -1
- package/lib/controlSocket.mjs +86 -0
- package/lib/coordinator.mjs +103 -101
- package/lib/daemon.mjs +1128 -2865
- package/lib/desk.mjs +7 -6
- package/lib/desktop.mjs +72 -68
- package/lib/directLink.mjs +16 -5
- package/lib/environment.mjs +2 -1
- package/lib/environments.mjs +14 -6
- package/lib/firewall.mjs +9 -9
- package/lib/folders.mjs +18 -14
- package/lib/frames.mjs +2 -3
- package/lib/gitHost.mjs +3 -3
- package/lib/goalCommands.mjs +25 -7
- package/lib/goals.mjs +7 -7
- package/lib/guestRequests.mjs +94 -0
- package/lib/handoffs.mjs +8 -7
- package/lib/handover.mjs +4 -4
- package/lib/harnessModel.mjs +6 -6
- package/lib/harnessOffers.mjs +266 -0
- package/lib/inference.mjs +26 -8
- package/lib/jobAnswers.mjs +190 -0
- package/lib/landed.mjs +1 -1
- package/lib/lane.mjs +42 -11
- package/lib/lessons.mjs +16 -16
- package/lib/library.mjs +3 -3
- package/lib/lineup.mjs +3 -0
- package/lib/linkRelay.mjs +574 -0
- package/lib/localAgentAsk.mjs +74 -0
- package/lib/localStack.mjs +536 -0
- package/lib/localmodels.mjs +6 -4
- package/lib/loopBackstop.mjs +4 -4
- package/lib/machineIdentity.mjs +9 -1
- package/lib/machineRoutes.mjs +181 -2
- package/lib/machineRuns.mjs +76 -1
- package/lib/machineSeal.mjs +39 -12
- package/lib/mcp-stdio.mjs +96 -26
- package/lib/mcpRelay.mjs +1 -1
- package/lib/members.json +13 -0
- package/lib/members.mjs +1 -1
- package/lib/models.mjs +77 -23
- package/lib/museSession.mjs +6 -1
- package/lib/nativeHost.mjs +35 -7
- package/lib/network.mjs +50 -5
- package/lib/notify.mjs +7 -5
- package/lib/nudge.mjs +3 -3
- package/lib/ocr.mjs +9 -9
- package/lib/onboard.mjs +26 -20
- package/lib/oneLine.mjs +7 -7
- package/lib/ownMachines.mjs +928 -149
- package/lib/pairing.mjs +33 -6
- package/lib/paths.mjs +15 -1
- package/lib/peerProcess.mjs +124 -0
- package/lib/personModel.mjs +3 -3
- package/lib/personNotices.mjs +151 -0
- package/lib/phones.mjs +490 -38
- package/lib/placeCommands.mjs +4 -4
- package/lib/places.mjs +70 -2
- package/lib/profile.mjs +67 -14
- package/lib/projectGit.mjs +158 -14
- package/lib/projectPieces.mjs +902 -0
- package/lib/projectSettings.mjs +7 -4
- package/lib/projects.mjs +384 -62
- package/lib/provenance.mjs +5 -1
- package/lib/proxyLinks.mjs +267 -0
- package/lib/reactions.mjs +7 -5
- package/lib/readiness.mjs +12 -7
- package/lib/record.mjs +19 -6
- package/lib/redact.mjs +4 -4
- package/lib/relayLimits.mjs +62 -0
- package/lib/release.mjs +170 -0
- package/lib/releaseKeys.json +6 -0
- package/lib/repoLinks.mjs +4 -4
- package/lib/roomChannels.mjs +24 -0
- package/lib/roomPage.mjs +1 -1
- package/lib/runAuthority.mjs +101 -0
- package/lib/runBrief.mjs +19 -8
- package/lib/runWorker.mjs +14 -5
- package/lib/runner.mjs +215 -25
- package/lib/runtime-install.mjs +143 -9
- package/lib/schedules.mjs +2 -2
- package/lib/screens.mjs +1 -1
- package/lib/sealed.mjs +11 -2
- package/lib/sealedThreads.mjs +671 -0
- package/lib/secretPatterns.json +1 -1
- package/lib/secrets.mjs +4 -4
- package/lib/seen.mjs +6 -6
- package/lib/serverWords.mjs +175 -0
- package/lib/service.mjs +22 -12
- package/lib/sessionControl.mjs +6 -6
- package/lib/specialties.mjs +6 -6
- package/lib/specialtyKeys.js +4 -5
- package/lib/specialtyNotice.mjs +7 -7
- package/lib/specialtySnapshot.mjs +5 -5
- package/lib/speech.mjs +5 -5
- package/lib/store.mjs +140 -39
- package/lib/stuck.mjs +1 -1
- package/lib/swarm.mjs +167 -16
- package/lib/swarmDevices.mjs +319 -0
- package/lib/swarmMemory.mjs +27 -25
- package/lib/t3.mjs +13 -13
- package/lib/taskCommands.mjs +44 -11
- package/lib/taskRooms.mjs +125 -0
- package/lib/taskRuns.mjs +36 -1
- package/lib/team.mjs +41 -18
- package/lib/threadActions.mjs +315 -0
- package/lib/threadAuthority.mjs +101 -0
- package/lib/threadBriefs.mjs +178 -0
- package/lib/threadLine.mjs +2 -2
- package/lib/threadRuns.mjs +138 -43
- package/lib/threadView.mjs +5 -5
- package/lib/usageTotals.mjs +2 -3
- package/lib/vault.mjs +101 -10
- package/lib/vaultCloud.mjs +2 -2
- package/lib/vaultCommands.mjs +15 -6
- package/lib/vaultTools.js +2 -2
- package/lib/verdicts.mjs +328 -0
- package/lib/wakes.mjs +1 -1
- package/lib/watches.mjs +2 -2
- package/lib/windowAsks.mjs +13 -5
- package/lib/worktrees.mjs +112 -18
- package/npm-shrinkwrap.json +1093 -0
- package/package.json +11 -10
- package/release.json +220 -0
package/lib/asks.mjs
CHANGED
|
@@ -11,10 +11,10 @@ import { nameOf } from "./members.mjs";
|
|
|
11
11
|
// Agents on Harness's server (Bankr, Quotient, Muse) keep their tasks there and take asks side by side. A send that may
|
|
12
12
|
// have reached Harness is looked up by its id before it goes again, so a retry never makes a second task.
|
|
13
13
|
//
|
|
14
|
-
// An ask for an agent whose earlier ask is running as a turn that takes words mid-turn (Harness on its server) goes
|
|
15
|
-
// that turn instead of waiting for it: the turn's answer answers both. One the turn ended without reading waits as
|
|
16
|
-
// other, and goes to the agent as its own task (
|
|
17
|
-
//
|
|
14
|
+
// An ask for an agent whose earlier ask is running as a turn that takes words mid-turn (Harness on its server) goes
|
|
15
|
+
// into that turn instead of waiting for it: the turn's answer answers both. One the turn ended without reading waits as
|
|
16
|
+
// any other, and goes to the agent as its own task (an ask that waited behind Harness's turn once went to Harness after
|
|
17
|
+
// that turn had already answered it).
|
|
18
18
|
|
|
19
19
|
const OPEN_RUN = ["open", "claimed", "running", "needs_input"];
|
|
20
20
|
// Sends lost on the way to Harness before the ask is given up and said as failed.
|
package/lib/audit.mjs
CHANGED
|
@@ -4,17 +4,17 @@ import { receiptOfTransaction, receiptsForThread } from "./book.mjs";
|
|
|
4
4
|
import { offices } from "./specialties.mjs";
|
|
5
5
|
import { underperforming } from "./record.mjs";
|
|
6
6
|
import { namedFiles } from "./worktrees.mjs";
|
|
7
|
+
import { READ_ONLY_AGENTS } from "./runner.mjs";
|
|
7
8
|
|
|
8
|
-
// The auditor
|
|
9
|
+
// The auditor: whether work said to be done was done, after the fact.
|
|
9
10
|
//
|
|
10
11
|
// - Code, on every report, no model: each claim a report makes in its structured fields (report_task's `claims`) is
|
|
11
12
|
// compared with what the board recorded: the run's receipt (receipts.mjs), the sub-pieces still open, the chain
|
|
12
13
|
// receipts filed in the book, whether its change is committed on its thread's branch, and whether the agent was
|
|
13
14
|
// answering when the work was assigned. A claim made only in the report's words is not audited: code never reads
|
|
14
|
-
// intent from prose
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
// not answering; only the agent's count toward `ok`.
|
|
15
|
+
// intent from prose. The result goes in board_tasks.audit, and the record (record.mjs) reads a report whose claims
|
|
16
|
+
// its receipts do not bear out as rejected. A mismatch is against the agent, or against the dispatcher when the
|
|
17
|
+
// dispatcher routed work to an agent that was not answering; only the agent's count toward `ok`.
|
|
18
18
|
// - An agent, weekly: a read-only task for the appointed auditor with the week's record and Harness's routing. Its one
|
|
19
19
|
// short report goes straight to the person (board.audit.week), never through the liaison and never as a notice: the
|
|
20
20
|
// liaison is Jev, and the auditor audits Jev.
|
|
@@ -218,19 +218,38 @@ function auditCommitted(store, task) {
|
|
|
218
218
|
];
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
// A piece of a shared project this run handed on stays its own until the receiver reports (projectPieces.mjs keeps
|
|
222
|
+
// the run's open handoffs, and audits it again when one is reported).
|
|
223
|
+
const openHandoffs = (store, task) => {
|
|
224
|
+
try {
|
|
225
|
+
return JSON.parse(store.meta(`handoffs-open:${task.id}`) || "[]");
|
|
226
|
+
} catch {
|
|
227
|
+
return [];
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
|
|
221
231
|
function auditPieces(store, task) {
|
|
222
232
|
if (task.status !== "done") return [];
|
|
223
233
|
const open = store
|
|
224
234
|
.children(task.id)
|
|
225
235
|
.filter((child) => !["done", "failed", "unknown"].includes(child.status));
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
236
|
+
const handed = openHandoffs(store, task);
|
|
237
|
+
return [
|
|
238
|
+
...(open.length
|
|
239
|
+
? [
|
|
240
|
+
mismatch(
|
|
241
|
+
"piece_open",
|
|
242
|
+
`Reported done while ${plural(open.length, "sub-piece")} ${open.length === 1 ? "is" : "are"} still open.`
|
|
243
|
+
),
|
|
244
|
+
]
|
|
245
|
+
: []),
|
|
246
|
+
...handed.map((handoff) =>
|
|
247
|
+
mismatch(
|
|
248
|
+
"piece_open",
|
|
249
|
+
`Reported done while the piece it handed to ${handoff.to} has no report yet.`
|
|
250
|
+
)
|
|
251
|
+
),
|
|
252
|
+
];
|
|
234
253
|
}
|
|
235
254
|
|
|
236
255
|
/**
|
|
@@ -305,6 +324,10 @@ export function auditorRefusal(
|
|
|
305
324
|
return `${nameOf(id)} works on Harness's server and cannot read the board`;
|
|
306
325
|
if (privacy && !onMachine(id))
|
|
307
326
|
return `on the privacy setting only an agent on this computer audits, and ${nameOf(id)} is not one`;
|
|
327
|
+
// A coding agent here audits in a run Harness starts, read-only; one with no read-only mode would run unrestricted
|
|
328
|
+
// on a brief built from the week's agent-written records.
|
|
329
|
+
if (MACHINE_RUNNERS.includes(id) && !READ_ONLY_AGENTS.has(id))
|
|
330
|
+
return `${nameOf(id)} has no read-only mode, so it cannot audit`;
|
|
308
331
|
return null;
|
|
309
332
|
}
|
|
310
333
|
|
package/lib/backupSetup.mjs
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
// A Resident coming back to a computer with an empty board is offered their backup first; a Resident without one is
|
|
3
3
|
// offered to start it; anyone else is told plainly that their board stays on this computer.
|
|
4
4
|
|
|
5
|
+
import { relayCommand } from "./runtime-install.mjs";
|
|
6
|
+
|
|
5
7
|
const when = (iso) => {
|
|
6
8
|
const at = new Date(iso);
|
|
7
9
|
return Number.isNaN(at.getTime())
|
|
@@ -60,7 +62,7 @@ export async function offerBackup({ ui, daemonRequest, role, boardIsEmpty }) {
|
|
|
60
62
|
ui.warn(restored.error || "That backup could not be opened.");
|
|
61
63
|
if (restored.code !== "wrong_passphrase") break;
|
|
62
64
|
}
|
|
63
|
-
ui.info(
|
|
65
|
+
ui.info(`To try again later: ${relayCommand()} backup restore`);
|
|
64
66
|
return;
|
|
65
67
|
}
|
|
66
68
|
const yes = await ui.confirm({
|
|
@@ -131,7 +133,7 @@ export async function backupCommand({ argv, ui, daemonRequest }) {
|
|
|
131
133
|
console.log(
|
|
132
134
|
status.on
|
|
133
135
|
? `Backups are on${status.last ? `: last ${when(status.last.at)}, ${status.last.rows} items` : ""}.`
|
|
134
|
-
:
|
|
136
|
+
: `Backups are off on this computer: ${relayCommand()} backup on`
|
|
135
137
|
);
|
|
136
138
|
if (status.latest)
|
|
137
139
|
console.log(
|
package/lib/boardAccess.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { randomUUID } from "node:crypto";
|
|
|
3
3
|
import { documentText, isDocument } from "./files.mjs";
|
|
4
4
|
import { secretReason } from "./secrets.mjs";
|
|
5
5
|
import { imageKind } from "./ocr.mjs";
|
|
6
|
+
import { member } from "./members.mjs";
|
|
6
7
|
|
|
7
8
|
export function createBoardAccess({
|
|
8
9
|
store,
|
|
@@ -14,12 +15,14 @@ export function createBoardAccess({
|
|
|
14
15
|
textLike,
|
|
15
16
|
coveredImage,
|
|
16
17
|
}) {
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
// results, room posts, folders). The person's and
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
18
|
+
// Harness's server carries; it never acts as the person. A call in the clear naming "user" or "harness" is the
|
|
19
|
+
// server's word for who asks, so it gets metadata only: who, which state, when, the same as every board_changed
|
|
20
|
+
// already carries, and never the words (objectives, briefs, results, room posts, folders). The person's and
|
|
21
|
+
// Harness's own reads and writes come sealed from a paired device. This holds whether or not a browser is paired
|
|
22
|
+
// (security audit S2, October 25): an unpaired relay once gave the server the whole board as the person, a Start
|
|
23
|
+
// included. What still works in the clear, for what runs on Harness's servers: a run's status, the timeline's
|
|
24
|
+
// counts, a trace's timings, a bounty's check that a guest posted, the person's Stop on standing permission; a
|
|
25
|
+
// hosted caller (Muse, Grok Bot, any connector) works the tasks it is part of in full, which it has to read.
|
|
23
26
|
const SEALED_ONLY = {
|
|
24
27
|
ok: false,
|
|
25
28
|
code: "sealed_only",
|
|
@@ -143,7 +146,7 @@ export function createBoardAccess({
|
|
|
143
146
|
(task.kind === "goal" && inRoom(task, agent)) ||
|
|
144
147
|
Boolean(roomOf(task) && inRoom(roomOf(task), agent)));
|
|
145
148
|
// What leaves this computer for an agent through Harness: any text in the answer that looks like a secret (the room's
|
|
146
|
-
// check, cli/lib/secrets.mjs) is replaced with a notice; the person still reads it in full here
|
|
149
|
+
// check, cli/lib/secrets.mjs) is replaced with a notice; the person still reads it in full here.
|
|
147
150
|
const withoutSecrets = (value) => {
|
|
148
151
|
if (typeof value === "string") {
|
|
149
152
|
const flag = secretReason(value);
|
|
@@ -207,6 +210,13 @@ export function createBoardAccess({
|
|
|
207
210
|
const answerPlain = (input) => {
|
|
208
211
|
const agent = String(input.agent || "");
|
|
209
212
|
const command = String(input.command || "");
|
|
213
|
+
// A member that runs on this computer calls on its own socket here, never through Harness (members.mjs): a call in
|
|
214
|
+
// the clear in its name is someone else using it (security audit S7).
|
|
215
|
+
if (member(agent)?.road === "local")
|
|
216
|
+
return {
|
|
217
|
+
ok: false,
|
|
218
|
+
error: `${agent} runs on this computer, so a call through Harness is never taken for it`,
|
|
219
|
+
};
|
|
210
220
|
// The desk's book and the audits are personal (book.mjs, audit.mjs): never read through Harness in the clear.
|
|
211
221
|
if (command.startsWith("board.desk.") || command.startsWith("board.audit."))
|
|
212
222
|
return {
|
|
@@ -214,10 +224,6 @@ export function createBoardAccess({
|
|
|
214
224
|
error:
|
|
215
225
|
"the desk's book and the audits stay on the person's computers: only the person and agents there read them",
|
|
216
226
|
};
|
|
217
|
-
// The person's and Harness's calls are answered in full only while no browser is paired; a hosted agent is always
|
|
218
|
-
// limited to what it is part of, paired or not.
|
|
219
|
-
if (!store.sealedOnly() && (agent === "user" || agent === "harness"))
|
|
220
|
-
return boardCommand(input);
|
|
221
227
|
// A thread Harness posts on accept: on the asking side, only one this machine asked for (it supplies the words itself).
|
|
222
228
|
if (
|
|
223
229
|
command === "board.post" &&
|
package/lib/boardBackup.mjs
CHANGED
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
import { gunzipSync, gzipSync } from "node:zlib";
|
|
10
10
|
import { readJson, writeJsonAtomic } from "./files.mjs";
|
|
11
11
|
|
|
12
|
-
// The board's encrypted backup, for Residents (
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
12
|
+
// The board's encrypted backup, for Residents (Harness's server keeps it). The board survives losing a computer,
|
|
13
|
+
// encrypted as a Resident's browser backup is. Home seals every board row (boardMirror.mjs's tables, as its pages carry
|
|
14
|
+
// them) with a key made from a passphrase only the person knows, and Harness keeps ciphertext it cannot read. Restoring
|
|
15
|
+
// brings the rows into the board here the way a computer joining brings its own (boardMirror.mjs bring): what is
|
|
16
|
+
// missing comes in, nothing here is removed.
|
|
17
17
|
//
|
|
18
18
|
// The key is kept beside the board in Harness's folder (0600), so backups go on by themselves: the board is on that
|
|
19
19
|
// disk unsealed anyway, and the seal is against Harness's servers. The same on every platform. Thread files' bytes
|
|
@@ -23,7 +23,7 @@ const MAGIC = Buffer.from("HRB1");
|
|
|
23
23
|
const SALT_BYTES = 16;
|
|
24
24
|
const IV_BYTES = 12;
|
|
25
25
|
const TAG_BYTES = 16;
|
|
26
|
-
// As the browser's backup derives its key
|
|
26
|
+
// As the browser's backup client derives its key, kept in step with it.
|
|
27
27
|
const ITERATIONS = 210_000;
|
|
28
28
|
const PART_BYTES = 512 * 1024;
|
|
29
29
|
const MIN_PASSPHRASE = 8;
|
|
@@ -102,9 +102,9 @@ export function createBoardFileCommands({
|
|
|
102
102
|
: mimeFor(name);
|
|
103
103
|
const limit = fileLimit(mime, bytes);
|
|
104
104
|
if (bytes.length > limit.bytes) return tooBig(bytes.length, limit);
|
|
105
|
-
// Shared with the agents on Harness's side unless whoever attached it keeps it on the computer
|
|
106
|
-
//
|
|
107
|
-
//
|
|
105
|
+
// Shared with the agents on Harness's side unless whoever attached it keeps it on the computer: shared is the
|
|
106
|
+
// default and the person chooses what is not shared. Bytes that came through Harness were readable there already.
|
|
107
|
+
// To another person's computer a file still goes only sealed.
|
|
108
108
|
const file = store.addFile({
|
|
109
109
|
taskId: id,
|
|
110
110
|
name,
|
|
@@ -169,9 +169,9 @@ export function createBoardFileCommands({
|
|
|
169
169
|
ok: false,
|
|
170
170
|
error: "this file is still on its way from the other computer",
|
|
171
171
|
};
|
|
172
|
-
// A part of the file for the person's own phone or linked browser: a sealed answer carries about 1 MB
|
|
173
|
-
//
|
|
174
|
-
// file, which the checks in plainBoard read as a whole.
|
|
172
|
+
// A part of the file for the person's own phone or linked browser: a sealed answer carries about 1 MB (the sealed
|
|
173
|
+
// wire's limit, kept in step with Harness), so a larger file is read in parts. A caller through Harness gets the
|
|
174
|
+
// whole file, which the checks in plainBoard read as a whole.
|
|
175
175
|
if (request.offset !== undefined && !request.hostedCaller) {
|
|
176
176
|
const offset = Number(request.offset),
|
|
177
177
|
length = Number(request.length ?? FILE_PART_BYTES);
|
package/lib/boardFiles.mjs
CHANGED
|
@@ -308,10 +308,10 @@ export function createBoardFiles({
|
|
|
308
308
|
data: out.bytes.toString("base64"),
|
|
309
309
|
};
|
|
310
310
|
};
|
|
311
|
-
// Harness's files on a task given to it, asked by Harness's server for the run or window working it
|
|
312
|
-
//
|
|
313
|
-
//
|
|
314
|
-
//
|
|
311
|
+
// Harness's files on a task given to it, asked by Harness's server for the run or window working it: it lists and
|
|
312
|
+
// reads what its thread shared with agents on Harness's side, under the checks any agent reading through Harness
|
|
313
|
+
// gets, and adds what it made there. Allowed with a browser paired too: what Harness adds it made on its own servers,
|
|
314
|
+
// as with its answers to the tasks given to it.
|
|
315
315
|
const harnessFile = async (input) => {
|
|
316
316
|
const { scrubber } = processing();
|
|
317
317
|
const task = store.getTask(String(input.taskId || ""));
|
|
@@ -319,9 +319,9 @@ export function createBoardFiles({
|
|
|
319
319
|
return { ok: false, error: "not a task given to Harness" };
|
|
320
320
|
const place = roomOf(task) ?? task;
|
|
321
321
|
// The thread's posts a page at a time, as every agent reads them (roomPage.mjs): its newest, the ones before a post
|
|
322
|
-
// going back, or the ones after one Harness has seen, so it reads the thread again before it answers (
|
|
323
|
-
//
|
|
324
|
-
//
|
|
322
|
+
// going back, or the ones after one Harness has seen, so it reads the thread again before it answers (answers built
|
|
323
|
+
// on the snapshot its task started with once restated what had changed since). Keys are swapped out, as in its
|
|
324
|
+
// task.
|
|
325
325
|
if (input.op === "posts") {
|
|
326
326
|
const page = roomPage(store, place.id, {
|
|
327
327
|
since: Math.max(0, Math.floor(Number(input.since) || 0)),
|
|
@@ -441,7 +441,8 @@ export function createBoardFiles({
|
|
|
441
441
|
place.goal.team.includes(agent)
|
|
442
442
|
),
|
|
443
443
|
});
|
|
444
|
-
|
|
444
|
+
// Said by Harness's server (harness_file comes only from there): it wakes the asker without the person's go.
|
|
445
|
+
wakeFor(place.id, post, "harness", undefined, { hosted: true });
|
|
445
446
|
}
|
|
446
447
|
return { ok: true };
|
|
447
448
|
}
|
|
@@ -449,7 +450,7 @@ export function createBoardFiles({
|
|
|
449
450
|
const bytes = Buffer.from(String(input.data || ""), "base64");
|
|
450
451
|
if (!bytes.length) return { ok: false, error: "the file is empty" };
|
|
451
452
|
// A finished render keeps the name its rendering was given (the shot it is), and no two of Harness's files in a
|
|
452
|
-
// thread share a name (
|
|
453
|
+
// thread share a name (four takes were once all named set-a-tiny-character-on-a.mp4, told apart by guesswork).
|
|
453
454
|
const named = fileName(
|
|
454
455
|
(jobId && rendering.find((each) => each.jobId === jobId)?.name) ||
|
|
455
456
|
input.name
|
|
@@ -503,8 +504,8 @@ export function createBoardFiles({
|
|
|
503
504
|
JSON.stringify(rendering.filter((each) => each.jobId !== jobId))
|
|
504
505
|
);
|
|
505
506
|
// Made after Harness answered (a video renders for minutes): said in the thread, waking whoever asked. Asked by
|
|
506
|
-
// Harness itself (the coordinator handing work on in its name), there is no one else to wake and the file's own
|
|
507
|
-
// shows it (
|
|
507
|
+
// Harness itself (the coordinator handing work on in its name), there is no one else to wake and the file's own
|
|
508
|
+
// post shows it (one thread once had five "Made for Harness" posts, each a copy of the file posted above it).
|
|
508
509
|
if (
|
|
509
510
|
["done", "failed"].includes(task.status) &&
|
|
510
511
|
place.kind === "goal" &&
|
|
@@ -525,7 +526,7 @@ export function createBoardFiles({
|
|
|
525
526
|
place.goal.team.includes(agent)
|
|
526
527
|
),
|
|
527
528
|
});
|
|
528
|
-
wakeFor(place.id, post, "harness");
|
|
529
|
+
wakeFor(place.id, post, "harness", undefined, { hosted: true });
|
|
529
530
|
}
|
|
530
531
|
notifyBoard(store.getTask(place.id));
|
|
531
532
|
return { ok: true, file: harnessFileView(file) };
|
package/lib/boardMirror.mjs
CHANGED
|
@@ -5,8 +5,8 @@ import { BOOK_MIRRORED } from "./book.mjs";
|
|
|
5
5
|
|
|
6
6
|
// Every computer of the person's swarm keeps the board. Home's is the board; each worker keeps a copy of it in its own
|
|
7
7
|
// board tables, so its agents still read the board when home is out of reach, and a worker standing in for home
|
|
8
|
-
// already holds it
|
|
9
|
-
//
|
|
8
|
+
// already holds it. Every computer stays in step with home as closely as it can, home's board is the canonical one,
|
|
9
|
+
// and the whole swarm works off that one shared board.
|
|
10
10
|
//
|
|
11
11
|
// - Every computer numbers the changes to its board tables (triggers into board_changes: the latest change per row, so
|
|
12
12
|
// the log is never larger than the board). Its feed id names that numbering.
|
|
@@ -17,8 +17,12 @@ import { BOOK_MIRRORED } from "./book.mjs";
|
|
|
17
17
|
// - Home tells connected workers when its board changed; a worker also catches up after each write it sent home and
|
|
18
18
|
// when home is back.
|
|
19
19
|
// - A computer that worked on a board of its own (a worker not confirmed yet, or one that was home) brings it to home
|
|
20
|
-
// once confirmed, before it follows home: home takes the rows it lacks and
|
|
21
|
-
//
|
|
20
|
+
// once confirmed, before it follows home: home takes only the rows it lacks, and nothing of home's is removed or
|
|
21
|
+
// overwritten (owner, October 22: a computer set up again must not lose the swarm).
|
|
22
|
+
// - What another computer's changes bring never carries authority (security audit 2026-10-25, M2): a task new to home
|
|
23
|
+
// arrives without the person's Start and with an agent's trust, a task home has keeps home's Start and trust, and
|
|
24
|
+
// merging starts no run. A board brought also comes with nobody holding its tasks, and without its standing
|
|
25
|
+
// permission or appointments; a stand-in, which was home meanwhile, hands those back.
|
|
22
26
|
|
|
23
27
|
/** A worker's call for home's changes (ownMachines.mjs answers it on home, never through the board's own commands). */
|
|
24
28
|
export const MIRROR_COMMAND = "board.mirror.since";
|
|
@@ -51,6 +55,17 @@ export const MIRRORED = {
|
|
|
51
55
|
board_offices: ["office"],
|
|
52
56
|
board_specialty_benchmarks: ["agent", "model", "effort", "specialty"],
|
|
53
57
|
};
|
|
58
|
+
// The person's grants, made on whichever computer was home: never taken from a board a computer kept on its own.
|
|
59
|
+
const AUTHORITY_TABLES = new Set(["board_standing", "board_offices"]);
|
|
60
|
+
// What says a task may run and on whose word, and who holds it: home's own, never another computer's.
|
|
61
|
+
const TASK_AUTHORITY = ["run_authorized_at", "run_authorized_by", "trust"];
|
|
62
|
+
const TASK_HOLD = [
|
|
63
|
+
"holder",
|
|
64
|
+
"claimed_by",
|
|
65
|
+
"claimed_at",
|
|
66
|
+
"lease_until",
|
|
67
|
+
"claimed_machine",
|
|
68
|
+
];
|
|
54
69
|
// A page stays well under what one sealed call carries (MAX_CT, src/shared/bridge/sealedWire.ts).
|
|
55
70
|
const PAGE_BYTES = 512 * 1024;
|
|
56
71
|
const FEED = "mirror-feed";
|
|
@@ -74,7 +89,7 @@ function install(db) {
|
|
|
74
89
|
)`);
|
|
75
90
|
for (const [table, columns] of Object.entries(MIRRORED)) {
|
|
76
91
|
// A delete then an insert, never "insert or replace": the conflict rule of the statement that fired the trigger
|
|
77
|
-
// (a store's "insert or ignore") would override the trigger's own and drop the change
|
|
92
|
+
// (a store's "insert or ignore") would override the trigger's own and drop the change.
|
|
78
93
|
const changed = (prefix, gone) =>
|
|
79
94
|
`delete from board_changes where tbl = '${table}' and pk = ${keyJson(prefix, columns)};
|
|
80
95
|
insert into board_changes(tbl, pk, gone) values('${table}', ${keyJson(prefix, columns)}, ${gone});`;
|
|
@@ -342,15 +357,15 @@ export function createBoardMirror({
|
|
|
342
357
|
/**
|
|
343
358
|
* Another computer's changes merged into this board, never overwriting newer work: a task by its version (every
|
|
344
359
|
* write bumps it), a lesson by when it changed, and any other row as the computer that changed it while standing in
|
|
345
|
-
* has it. Nothing here is taken out for being absent from the page. A board brought (`bring`) only adds
|
|
346
|
-
*
|
|
360
|
+
* has it. Nothing here is taken out for being absent from the page. A board brought (`bring`) only adds rows this board
|
|
361
|
+
* lacks and removes nothing. Either way a task comes in with this board's authority on it, never the sender's.
|
|
347
362
|
*/
|
|
348
363
|
const merge = (page, { bring = false } = {}) => {
|
|
349
364
|
db.exec("begin immediate");
|
|
350
365
|
try {
|
|
351
366
|
for (const change of page.changes ?? []) {
|
|
352
367
|
const columns = MIRRORED[change.tbl];
|
|
353
|
-
if (!columns) continue;
|
|
368
|
+
if (!columns || (bring && AUTHORITY_TABLES.has(change.tbl))) continue;
|
|
354
369
|
if (change.gone) {
|
|
355
370
|
if (!bring) removeRow(change.tbl, change.gone);
|
|
356
371
|
continue;
|
|
@@ -359,8 +374,13 @@ export function createBoardMirror({
|
|
|
359
374
|
`select * from ${change.tbl} where ${whereKey(columns)}`,
|
|
360
375
|
columns.map((column) => change.row[column])
|
|
361
376
|
);
|
|
362
|
-
if (here &&
|
|
363
|
-
writeRow(
|
|
377
|
+
if (here && (bring || !newer(change.row, here))) continue;
|
|
378
|
+
writeRow(
|
|
379
|
+
change.tbl,
|
|
380
|
+
change.tbl === "board_tasks"
|
|
381
|
+
? withoutAuthority(change.row, here, { bring })
|
|
382
|
+
: change.row
|
|
383
|
+
);
|
|
364
384
|
}
|
|
365
385
|
db.exec("commit");
|
|
366
386
|
merged();
|
|
@@ -370,9 +390,20 @@ export function createBoardMirror({
|
|
|
370
390
|
throw error;
|
|
371
391
|
}
|
|
372
392
|
};
|
|
393
|
+
// A task as another computer sent it, with this board's say over it: the Start and trust home gave it (none for a task
|
|
394
|
+
// new here, so it waits for the person), and, in a brought board, nobody holding it.
|
|
395
|
+
const withoutAuthority = (row, here, { bring }) => {
|
|
396
|
+
const task = { ...row };
|
|
397
|
+
for (const column of TASK_AUTHORITY)
|
|
398
|
+
task[column] = here ? here[column] : column === "trust" ? "agent" : null;
|
|
399
|
+
if (bring) {
|
|
400
|
+
for (const column of TASK_HOLD) task[column] = null;
|
|
401
|
+
if (["claimed", "running"].includes(task.status)) task.status = "open";
|
|
402
|
+
}
|
|
403
|
+
return task;
|
|
404
|
+
};
|
|
373
405
|
// A row with no version or time of change (a thread's state, a goal's sessions, a reaction) is taken from the
|
|
374
|
-
// computer that sent it: only rows it changed while standing in come in a merge (
|
|
375
|
-
// dropped).
|
|
406
|
+
// computer that sent it: only rows it changed while standing in come in a merge (these edits were once dropped).
|
|
376
407
|
const newer = (incoming, here) => {
|
|
377
408
|
if ("version" in incoming && "version" in here) {
|
|
378
409
|
if (Number(incoming.version) !== Number(here.version))
|
|
@@ -383,41 +414,43 @@ export function createBoardMirror({
|
|
|
383
414
|
return String(incoming.updated_at) > String(here.updated_at);
|
|
384
415
|
return true;
|
|
385
416
|
};
|
|
386
|
-
// In a board brought to home, only a row that says when it changed may replace home's.
|
|
387
|
-
const newerVersion = (incoming, here) =>
|
|
388
|
-
("version" in incoming && "version" in here) ||
|
|
389
|
-
("updated_at" in incoming && "updated_at" in here)
|
|
390
|
-
? newer(incoming, here)
|
|
391
|
-
: false;
|
|
392
417
|
|
|
393
418
|
/** This computer works on a board of its own: once confirmed, it brings that board to home. */
|
|
394
419
|
const markBring = () => {
|
|
395
420
|
if (!meta(BRING))
|
|
396
421
|
setMeta(BRING, JSON.stringify({ at: new Date().toISOString() }));
|
|
397
422
|
};
|
|
398
|
-
//
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
let after = 0;
|
|
402
|
-
let pages = 0;
|
|
423
|
+
// Pages from `after` to home, the last always sent (empty or not), since home ends what it takes with it. True when
|
|
424
|
+
// home took them all; the refusal when home said it takes none (answerMergeCall), so this computer stops asking.
|
|
425
|
+
const pushAll = async (after, options) => {
|
|
403
426
|
for (;;) {
|
|
404
427
|
const page = since({ after, feed: feed() });
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
if (answer?.ok !== true) {
|
|
408
|
-
log(
|
|
409
|
-
`this computer's board could not go to home yet: ${answer?.error || "home did not answer"}`
|
|
410
|
-
);
|
|
411
|
-
return false;
|
|
412
|
-
}
|
|
413
|
-
pages++;
|
|
428
|
+
const answer = await pushPage(page, options);
|
|
429
|
+
if (answer?.ok !== true) return answer ?? { ok: false };
|
|
414
430
|
after = page.to;
|
|
415
|
-
if (page.to >= page.head)
|
|
431
|
+
if (page.to >= page.head) return { ok: true };
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
// Home took none of it: the rows only this computer has go to a file when it lists home's board again (sweep).
|
|
435
|
+
const followAfresh = () =>
|
|
436
|
+
db.run("delete from board_meta where key = ?", [CURSOR]);
|
|
437
|
+
|
|
438
|
+
// Confirmed now: the whole board here goes to home, a page at a time, before this computer follows home's.
|
|
439
|
+
const bring = async () => {
|
|
440
|
+
if (!meta(BRING)) return true;
|
|
441
|
+
const answer = await pushAll(0, { bring: true });
|
|
442
|
+
if (answer.ok !== true && answer.code !== "not_armed") {
|
|
443
|
+
log(
|
|
444
|
+
`this computer's board could not go to home yet: ${answer.error || "home did not answer"}`
|
|
445
|
+
);
|
|
446
|
+
return false;
|
|
416
447
|
}
|
|
417
448
|
db.run("delete from board_meta where key = ?", [BRING]);
|
|
418
|
-
log(
|
|
419
|
-
|
|
420
|
-
|
|
449
|
+
if (answer.ok) log("brought this computer's board to home");
|
|
450
|
+
else {
|
|
451
|
+
log(`home did not take this computer's board: ${answer.error}`);
|
|
452
|
+
followAfresh();
|
|
453
|
+
}
|
|
421
454
|
return true;
|
|
422
455
|
};
|
|
423
456
|
|
|
@@ -425,17 +458,14 @@ export function createBoardMirror({
|
|
|
425
458
|
const handOver = async () => {
|
|
426
459
|
const standing = standInRecord();
|
|
427
460
|
if (!standing) return true;
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
const page = since({ after, feed: feed() });
|
|
431
|
-
if (!page.changes.length) break;
|
|
432
|
-
const answer = await pushPage(page);
|
|
433
|
-
if (answer?.ok !== true) return false;
|
|
434
|
-
after = page.to;
|
|
435
|
-
if (page.to >= page.head) break;
|
|
436
|
-
}
|
|
461
|
+
const answer = await pushAll(standing.from, {});
|
|
462
|
+
if (answer.ok !== true && answer.code !== "not_stand_in") return false;
|
|
437
463
|
db.run("delete from board_meta where key = ?", [STAND_IN]);
|
|
438
|
-
log(`gave home what this computer wrote while it stood in`);
|
|
464
|
+
if (answer.ok) log(`gave home what this computer wrote while it stood in`);
|
|
465
|
+
else {
|
|
466
|
+
log(`home did not take what this computer wrote: ${answer.error}`);
|
|
467
|
+
followAfresh();
|
|
468
|
+
}
|
|
439
469
|
return true;
|
|
440
470
|
};
|
|
441
471
|
|
|
@@ -448,7 +478,12 @@ export function createBoardMirror({
|
|
|
448
478
|
if (!page?.ok || !Array.isArray(page.changes)) {
|
|
449
479
|
// The stand-in is away too, or kept no record of standing in: home is taken back now, and the stand-in hands
|
|
450
480
|
// its changes over when it is back (handOver), rather than the swarm having no home (review, October 21).
|
|
451
|
-
if (page?.ok === false || !standInReachable())
|
|
481
|
+
if (page?.ok === false || !standInReachable()) {
|
|
482
|
+
log(
|
|
483
|
+
`taking home back without the stand-in's changes for now: ${page?.error || "it is out of reach"}`
|
|
484
|
+
);
|
|
485
|
+
break;
|
|
486
|
+
}
|
|
452
487
|
return;
|
|
453
488
|
}
|
|
454
489
|
merge(page);
|
package/lib/boardProtocol.json
CHANGED
|
@@ -76,6 +76,10 @@
|
|
|
76
76
|
"board.project.share": "projects",
|
|
77
77
|
"board.project.withdraw": "projects",
|
|
78
78
|
"board.project.work": "projects",
|
|
79
|
+
"board.project.verdict": "verdicts",
|
|
80
|
+
"board.project.piece": "projects",
|
|
81
|
+
"board.project.release": "projects",
|
|
82
|
+
"board.project.handoff": "projects",
|
|
79
83
|
"board.prompted": "prompt",
|
|
80
84
|
"board.relay.decide": "relay",
|
|
81
85
|
"board.relay.defaults": "relay",
|
|
@@ -141,6 +145,7 @@
|
|
|
141
145
|
"board.swarm.specialty": "swarm",
|
|
142
146
|
"board.swarm.start": "swarm",
|
|
143
147
|
"board.swarm.start_run": "swarm",
|
|
148
|
+
"board.swarm.steer": "swarm",
|
|
144
149
|
"board.swarm.stop": "swarm",
|
|
145
150
|
"board.swarm.stop_all": "swarm",
|
|
146
151
|
"board.swarm.use_browser": "swarm",
|
|
@@ -321,6 +326,7 @@
|
|
|
321
326
|
"board.swarm.file",
|
|
322
327
|
"board.swarm.start",
|
|
323
328
|
"board.swarm.post",
|
|
329
|
+
"board.swarm.steer",
|
|
324
330
|
"board.swarm.stop",
|
|
325
331
|
"board.swarm.stop_all",
|
|
326
332
|
"board.swarm.resume",
|
|
@@ -406,6 +412,7 @@
|
|
|
406
412
|
"board.swarm.file",
|
|
407
413
|
"board.swarm.start",
|
|
408
414
|
"board.swarm.post",
|
|
415
|
+
"board.swarm.steer",
|
|
409
416
|
"board.swarm.stop",
|
|
410
417
|
"board.swarm.stop_all",
|
|
411
418
|
"board.swarm.resume",
|
|
@@ -461,6 +468,9 @@
|
|
|
461
468
|
"board.project.share",
|
|
462
469
|
"board.project.held",
|
|
463
470
|
"board.project.work",
|
|
471
|
+
"board.project.verdict",
|
|
472
|
+
"board.project.piece",
|
|
473
|
+
"board.project.release",
|
|
464
474
|
"board.project.leave",
|
|
465
475
|
"board.connector.list",
|
|
466
476
|
"board.connector.add",
|
|
@@ -609,6 +619,7 @@
|
|
|
609
619
|
"board.swarm.file",
|
|
610
620
|
"board.swarm.start",
|
|
611
621
|
"board.swarm.post",
|
|
622
|
+
"board.swarm.steer",
|
|
612
623
|
"board.swarm.stop",
|
|
613
624
|
"board.swarm.stop_all",
|
|
614
625
|
"board.swarm.resume",
|
|
@@ -675,11 +686,15 @@
|
|
|
675
686
|
"board.swarm.held",
|
|
676
687
|
"machines.list",
|
|
677
688
|
"machines.add",
|
|
689
|
+
"machines.home",
|
|
678
690
|
"machines.models",
|
|
679
691
|
"machines.model",
|
|
680
692
|
"swarm.lineup",
|
|
681
693
|
"swarm.add",
|
|
682
694
|
"swarm.remove",
|
|
695
|
+
"phone.list",
|
|
696
|
+
"phone.link.answer",
|
|
697
|
+
"phone.revoke",
|
|
683
698
|
"board.project.list",
|
|
684
699
|
"board.project.repos",
|
|
685
700
|
"board.repo.find",
|
|
@@ -702,6 +717,9 @@
|
|
|
702
717
|
"board.project.share",
|
|
703
718
|
"board.project.held",
|
|
704
719
|
"board.project.work",
|
|
720
|
+
"board.project.verdict",
|
|
721
|
+
"board.project.piece",
|
|
722
|
+
"board.project.release",
|
|
705
723
|
"board.project.leave",
|
|
706
724
|
"board.place.op",
|
|
707
725
|
"board.connector.list",
|
|
@@ -764,7 +782,18 @@
|
|
|
764
782
|
"agents.signin.read",
|
|
765
783
|
"agents.signin.send",
|
|
766
784
|
"agents.signin.stop",
|
|
767
|
-
"agents.signin.key"
|
|
785
|
+
"agents.signin.key",
|
|
786
|
+
"agents.signin.link",
|
|
787
|
+
"agents.models",
|
|
788
|
+
"agents.model"
|
|
789
|
+
],
|
|
790
|
+
"browserLinks": [
|
|
791
|
+
"links.allow",
|
|
792
|
+
"links.list",
|
|
793
|
+
"links.forget"
|
|
794
|
+
],
|
|
795
|
+
"browserSsh": [
|
|
796
|
+
"ssh.allow"
|
|
768
797
|
]
|
|
769
798
|
},
|
|
770
799
|
"metadata": {
|
package/lib/boardWaits.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// The board's revision, and whoever waits for it to move. Every surface that shows the board (the buddy over the local
|
|
2
|
-
// socket, the PiP and the phone through Harness) reads it again the moment it changes, rather than on a timer
|
|
3
|
-
//
|
|
4
|
-
// near instant").
|
|
2
|
+
// socket, the PiP and the phone through Harness) reads it again the moment it changes, rather than on a timer: the
|
|
3
|
+
// relay's state has to reach every device, the PiP and the phone close to instantly.
|
|
5
4
|
//
|
|
6
5
|
// The revision is the board's change log head (boardMirror.mjs: every write to a board table, through any of the
|
|
7
6
|
// daemon's paths, and every page copied from home) with a count of changes kept outside those tables (the T3 Code work
|