tryharness 0.7.53 → 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 +23 -19
- package/assets/dsh-plugin.mjs +72 -0
- package/assets/opencode-plugin.js +4 -3
- package/cli.mjs +484 -90
- package/lib/activity.mjs +10 -10
- package/lib/adapters.mjs +173 -222
- package/lib/agentBinaries.mjs +71 -0
- package/lib/agentRuntimeConfig.mjs +1 -1
- package/lib/agentRuntimes.mjs +34 -18
- package/lib/agentSignIn.mjs +456 -0
- 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 +666 -0
- package/lib/backupSetup.mjs +143 -0
- package/lib/boardAccess.mjs +24 -11
- package/lib/boardBackup.mjs +283 -0
- package/lib/boardFileCommands.mjs +6 -6
- package/lib/boardFiles.mjs +13 -12
- package/lib/boardMirror.mjs +124 -25
- package/lib/boardProtocol.json +88 -2
- package/lib/boardWaits.mjs +101 -0
- package/lib/book.mjs +659 -0
- package/lib/bridge.mjs +6 -6
- package/lib/cards.mjs +138 -28
- package/lib/cloudAgents.mjs +216 -0
- package/lib/cloudAi.mjs +1312 -0
- package/lib/cloudAssistants.mjs +242 -0
- package/lib/cloudBoot.mjs +119 -0
- package/lib/cloudSave.mjs +197 -0
- package/lib/cloudSsh.mjs +178 -0
- package/lib/commands.mjs +7 -2
- package/lib/context.mjs +19 -5
- package/lib/contractGate.mjs +399 -0
- package/lib/control-client.mjs +9 -1
- package/lib/controlSocket.mjs +86 -0
- package/lib/coordinator.mjs +252 -144
- package/lib/daemon.mjs +1351 -2767
- package/lib/desk.mjs +240 -0
- package/lib/desktop.mjs +178 -74
- package/lib/directLink.mjs +16 -5
- package/lib/environment.mjs +2 -1
- package/lib/environments.mjs +247 -9
- package/lib/firewall.mjs +9 -9
- package/lib/folders.mjs +20 -16
- package/lib/frames.mjs +2 -3
- package/lib/gitHost.mjs +174 -0
- 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/hookDialects.mjs +298 -0
- package/lib/inference.mjs +26 -8
- package/lib/jobAnswers.mjs +190 -0
- package/lib/landed.mjs +887 -0
- 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/live.mjs +284 -13
- 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 +163 -27
- package/lib/mcpRelay.mjs +1 -1
- package/lib/members.json +29 -2
- package/lib/members.mjs +1 -1
- package/lib/models.mjs +85 -31
- package/lib/museSession.mjs +21 -13
- package/lib/nativeHost.mjs +36 -8
- package/lib/neovim.mjs +126 -0
- package/lib/network.mjs +50 -5
- package/lib/notify.mjs +7 -5
- package/lib/nudge.mjs +50 -19
- package/lib/ocr.mjs +9 -9
- package/lib/onboard.mjs +26 -20
- package/lib/oneLine.mjs +7 -7
- package/lib/ownMachines.mjs +1223 -140
- package/lib/pairing.mjs +60 -16
- package/lib/paths.mjs +19 -1
- package/lib/peerProcess.mjs +124 -0
- package/lib/personModel.mjs +89 -0
- package/lib/personNotices.mjs +151 -0
- package/lib/phones.mjs +538 -31
- package/lib/placeCommands.mjs +4 -4
- package/lib/places.mjs +400 -12
- 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 +145 -23
- package/lib/record.mjs +128 -0
- 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 +31 -7
- package/lib/runner.mjs +223 -29
- 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 +378 -90
- package/lib/specialties.json +74 -0
- package/lib/specialties.mjs +477 -0
- package/lib/specialtyKeys.d.ts +3 -0
- package/lib/specialtyKeys.js +57 -0
- package/lib/specialtyNotice.mjs +147 -0
- package/lib/specialtySnapshot.mjs +138 -0
- package/lib/speech.mjs +5 -5
- package/lib/store.mjs +420 -36
- package/lib/stuck.mjs +1 -1
- package/lib/swarm.mjs +304 -37
- package/lib/swarmDevices.mjs +319 -0
- package/lib/swarmMemory.mjs +27 -25
- package/lib/t3.mjs +24 -15
- package/lib/taskCommands.mjs +80 -20
- package/lib/taskRooms.mjs +125 -0
- package/lib/taskRuns.mjs +45 -3
- package/lib/team.json +255 -148
- package/lib/team.mjs +554 -190
- package/lib/threadActions.mjs +315 -0
- package/lib/threadAuthority.mjs +101 -0
- package/lib/threadBriefs.mjs +178 -0
- package/lib/threadLine.mjs +116 -0
- package/lib/threadRuns.mjs +209 -50
- package/lib/threadView.mjs +20 -7
- 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 +157 -25
- package/npm-shrinkwrap.json +1093 -0
- package/package.json +12 -11
- package/release.json +220 -0
- package/lib/modelTiers.json +0 -1183
- package/lib/modelTiers.mjs +0 -133
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
// The person's devices across all their computers: one list, kept by home, that only the person changes.
|
|
2
|
+
//
|
|
3
|
+
// Each computer pairs its own devices (phones.mjs: a browser or phone holds a key for that computer alone). This module
|
|
4
|
+
// makes them one swarm: every computer reports its devices and the browsers asking to link to it, home keeps the whole
|
|
5
|
+
// list, and a decision the person makes on any of their computers (allow, turn down, disconnect) reaches the computer the
|
|
6
|
+
// device is paired with. Decisions travel only on the sealed line between the person's own computers (ownMachines.mjs),
|
|
7
|
+
// so Harness's server, which carries that line, can neither add a device nor take one away (security audit,
|
|
8
|
+
// October 26: "devices registered to the swarm").
|
|
9
|
+
//
|
|
10
|
+
// A device is let in by the person's own action: a link or QR code made on one of their computers, or an ask they
|
|
11
|
+
// allowed on one of their computers or devices. One paired through an offer Harness made (a cloud computer's seeded
|
|
12
|
+
// link, cloudBoot.mjs) waits until they allow it, unless it is the first device of a cloud computer that is on its own:
|
|
13
|
+
// that one is the browser where the person pressed Add, and the box is Harness's to run anyway.
|
|
14
|
+
|
|
15
|
+
export const DEVICES_COMMAND = "machine.devices";
|
|
16
|
+
|
|
17
|
+
// On home: what the other computers reported, by computer. On every computer: the person's decisions it has not yet
|
|
18
|
+
// seen carried out, by device or ask id.
|
|
19
|
+
const REPORTED = "swarm-devices";
|
|
20
|
+
const DECISIONS = "swarm-device-decisions";
|
|
21
|
+
const waitingKey = (id) => `device-waiting:${id}`;
|
|
22
|
+
const DECISION_WORDS = new Set(["allow", "refuse", "remove"]);
|
|
23
|
+
// A report is a computer's own devices and asks; more than this is not a person's.
|
|
24
|
+
const MAX_REPORTED = 200;
|
|
25
|
+
const ID = /^[A-Za-z0-9_-]{8,64}$/;
|
|
26
|
+
|
|
27
|
+
export function createSwarmDevices({
|
|
28
|
+
store,
|
|
29
|
+
// The person's computers (ownMachines.mjs), or null on a computer that is not in a swarm.
|
|
30
|
+
computers = () => null,
|
|
31
|
+
// This computer's own browsers asking to link (phones.mjs linkAsk): their list, and the person's answer to one.
|
|
32
|
+
asks = () => [],
|
|
33
|
+
answerAsk = () => ({ ok: false, error: "that browser is no longer asking" }),
|
|
34
|
+
notify = () => {},
|
|
35
|
+
log = () => {},
|
|
36
|
+
}) {
|
|
37
|
+
const own = () => computers();
|
|
38
|
+
const self = () => own()?.self?.() ?? "this";
|
|
39
|
+
const isHome = () => own()?.isHome?.() ?? true;
|
|
40
|
+
const labelOf = (id) =>
|
|
41
|
+
id === self() ? null : (own()?.labelOf?.(id) ?? null);
|
|
42
|
+
|
|
43
|
+
const readJson = (key, fallback) => {
|
|
44
|
+
try {
|
|
45
|
+
return JSON.parse(store.meta(key) || "null") ?? fallback;
|
|
46
|
+
} catch {
|
|
47
|
+
return fallback;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const decisions = () => readJson(DECISIONS, {});
|
|
51
|
+
const keepDecisions = (all) => store.meta(DECISIONS, JSON.stringify(all));
|
|
52
|
+
const reported = () => readJson(REPORTED, {});
|
|
53
|
+
|
|
54
|
+
const waiting = (id) => Boolean(store.meta(waitingKey(id)));
|
|
55
|
+
// This computer's devices and asks, as the swarm's list holds them.
|
|
56
|
+
const mine = () => [
|
|
57
|
+
...store.phones().map((device) => ({
|
|
58
|
+
id: device.id,
|
|
59
|
+
kind: device.kind || "phone",
|
|
60
|
+
label: device.label,
|
|
61
|
+
at: device.paired_at,
|
|
62
|
+
state: device.revoked_at
|
|
63
|
+
? "removed"
|
|
64
|
+
: waiting(device.id)
|
|
65
|
+
? "waiting"
|
|
66
|
+
: "listed",
|
|
67
|
+
})),
|
|
68
|
+
...asks().map((ask) => ({
|
|
69
|
+
id: ask.id,
|
|
70
|
+
kind: "ask",
|
|
71
|
+
label: ask.label,
|
|
72
|
+
at: ask.askedAt,
|
|
73
|
+
state: "waiting",
|
|
74
|
+
})),
|
|
75
|
+
];
|
|
76
|
+
// A decision the person made shows at once in the list, before the computer it is for has carried it out.
|
|
77
|
+
const decided = (entry) => {
|
|
78
|
+
const decision = decisions()[entry.id]?.decision;
|
|
79
|
+
if (!decision || entry.state === "removed") return entry;
|
|
80
|
+
if (decision === "remove") return { ...entry, state: "removed" };
|
|
81
|
+
if (entry.state !== "waiting") return entry;
|
|
82
|
+
return {
|
|
83
|
+
...entry,
|
|
84
|
+
state:
|
|
85
|
+
decision === "allow"
|
|
86
|
+
? entry.kind === "ask"
|
|
87
|
+
? "allowed"
|
|
88
|
+
: "listed"
|
|
89
|
+
: "refused",
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/** The swarm's whole list, on home; on a worker, its own devices and what home last told it of the others. */
|
|
94
|
+
const list = () => {
|
|
95
|
+
const here = mine().map((entry) => ({ ...entry, computer: self() }));
|
|
96
|
+
const elsewhere = Object.entries(reported())
|
|
97
|
+
.filter(([computer]) => computer !== self())
|
|
98
|
+
.flatMap(([computer, entries]) =>
|
|
99
|
+
(Array.isArray(entries) ? entries : []).map((entry) => ({
|
|
100
|
+
...entry,
|
|
101
|
+
computer,
|
|
102
|
+
}))
|
|
103
|
+
);
|
|
104
|
+
return [...here, ...elsewhere]
|
|
105
|
+
.map(decided)
|
|
106
|
+
.map((entry) => ({ ...entry, computerLabel: labelOf(entry.computer) }));
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// ---- carrying out the person's decisions on this computer ----
|
|
110
|
+
|
|
111
|
+
const applyHere = (id, decision) => {
|
|
112
|
+
const device = store.getPhone(id);
|
|
113
|
+
if (device) {
|
|
114
|
+
if (decision === "remove") store.revokePhone(id);
|
|
115
|
+
else if (decision === "allow") store.meta(waitingKey(id), "");
|
|
116
|
+
// A device turned down is disconnected: it never worked here.
|
|
117
|
+
else store.revokePhone(id);
|
|
118
|
+
return { ok: true };
|
|
119
|
+
}
|
|
120
|
+
if (asks().some((ask) => ask.id === id))
|
|
121
|
+
return answerAsk(id, decision === "allow");
|
|
122
|
+
return null;
|
|
123
|
+
};
|
|
124
|
+
// The decisions home holds for this computer's own devices and asks, carried out; each is dropped once done.
|
|
125
|
+
const carryOut = (forHere) => {
|
|
126
|
+
let changed = false;
|
|
127
|
+
for (const [id, entry] of Object.entries(forHere ?? {})) {
|
|
128
|
+
if (!ID.test(id) || !DECISION_WORDS.has(entry?.decision)) continue;
|
|
129
|
+
const done = applyHere(id, entry.decision);
|
|
130
|
+
if (done) changed = true;
|
|
131
|
+
}
|
|
132
|
+
return changed;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// ---- a worker and home ----
|
|
136
|
+
|
|
137
|
+
// On a worker: its devices and asks to home, which answers with the person's decisions for them. One report at a time;
|
|
138
|
+
// anything that changes while one is out is sent in the next, right after.
|
|
139
|
+
let reporting = null;
|
|
140
|
+
let again = false;
|
|
141
|
+
const report = () => {
|
|
142
|
+
const machines = own();
|
|
143
|
+
if (!machines || isHome() || !machines.joined?.()) return null;
|
|
144
|
+
if (reporting) {
|
|
145
|
+
again = true;
|
|
146
|
+
return reporting;
|
|
147
|
+
}
|
|
148
|
+
again = false;
|
|
149
|
+
reporting = machines
|
|
150
|
+
.callHome({ command: DEVICES_COMMAND, op: "report", devices: mine() })
|
|
151
|
+
.then((answer) => {
|
|
152
|
+
if (answer?.ok !== true) return answer;
|
|
153
|
+
store.meta(REPORTED, JSON.stringify(othersFrom(answer.devices)));
|
|
154
|
+
if (carryOut(answer.decisions)) again = true;
|
|
155
|
+
return answer;
|
|
156
|
+
})
|
|
157
|
+
.catch((error) => log(`devices: report failed: ${error.message}`))
|
|
158
|
+
.finally(() => {
|
|
159
|
+
reporting = null;
|
|
160
|
+
if (again) void report();
|
|
161
|
+
});
|
|
162
|
+
return reporting;
|
|
163
|
+
};
|
|
164
|
+
// Home's list as a worker keeps it: every other computer's entries, by computer.
|
|
165
|
+
const othersFrom = (entries) => {
|
|
166
|
+
const byComputer = {};
|
|
167
|
+
for (const entry of Array.isArray(entries) ? entries : []) {
|
|
168
|
+
if (!entry?.computer || entry.computer === self()) continue;
|
|
169
|
+
(byComputer[entry.computer] ??= []).push(clean(entry));
|
|
170
|
+
}
|
|
171
|
+
return byComputer;
|
|
172
|
+
};
|
|
173
|
+
const clean = (entry) => ({
|
|
174
|
+
id: String(entry.id),
|
|
175
|
+
kind: ["phone", "browser", "ask"].includes(entry.kind)
|
|
176
|
+
? entry.kind
|
|
177
|
+
: "phone",
|
|
178
|
+
label: String(entry.label ?? "").slice(0, 40),
|
|
179
|
+
at: typeof entry.at === "string" ? entry.at.slice(0, 40) : null,
|
|
180
|
+
state: ["listed", "waiting", "removed", "allowed", "refused"].includes(
|
|
181
|
+
entry.state
|
|
182
|
+
)
|
|
183
|
+
? entry.state
|
|
184
|
+
: "waiting",
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
// On home: the decisions for one computer's devices and asks, and those already carried out dropped.
|
|
188
|
+
const decisionsFor = (computer, entries) => {
|
|
189
|
+
const all = decisions();
|
|
190
|
+
const ids = new Set(entries.map((entry) => entry.id));
|
|
191
|
+
const forIt = {};
|
|
192
|
+
for (const [id, entry] of Object.entries(all)) {
|
|
193
|
+
if (entry.computer !== computer) continue;
|
|
194
|
+
const now = entries.find((item) => item.id === id);
|
|
195
|
+
const done =
|
|
196
|
+
!ids.has(id) ||
|
|
197
|
+
now?.state === "removed" ||
|
|
198
|
+
(entry.decision === "allow" && now?.state === "listed");
|
|
199
|
+
if (done) delete all[id];
|
|
200
|
+
else forIt[id] = entry;
|
|
201
|
+
}
|
|
202
|
+
keepDecisions(all);
|
|
203
|
+
return forIt;
|
|
204
|
+
};
|
|
205
|
+
const tellNew = (computer, before, entries) => {
|
|
206
|
+
const known = new Set(before.map((entry) => entry.id));
|
|
207
|
+
for (const entry of entries)
|
|
208
|
+
if (entry.state === "waiting" && !known.has(entry.id))
|
|
209
|
+
notify(
|
|
210
|
+
entry.kind === "ask"
|
|
211
|
+
? `A browser (${entry.label}) asks to link to ${labelOf(computer) ?? "another of your computers"}. Allow it on any of your computers or devices: npx tryharness phone allow`
|
|
212
|
+
: `${entry.label} was linked to ${labelOf(computer) ?? "another of your computers"} by Harness, not from one of your computers, so it waits for you. Allow it on any of your computers or devices (npx tryharness phone allow), or leave it and it never works.`,
|
|
213
|
+
`devices:${entry.id}`
|
|
214
|
+
);
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* On home: a sealed call from another of the person's computers (ownMachines.mjs answerOpened). `drives`: the person
|
|
219
|
+
* works from that computer; a hosted one (agents only) reports its devices but decides nothing for the person.
|
|
220
|
+
*/
|
|
221
|
+
const answer = (from, call, { drives = true } = {}) => {
|
|
222
|
+
if (!isHome()) return { ok: false, error: "this computer is not home" };
|
|
223
|
+
if (call?.op === "report") {
|
|
224
|
+
const entries = (Array.isArray(call.devices) ? call.devices : [])
|
|
225
|
+
.slice(0, MAX_REPORTED)
|
|
226
|
+
.filter((entry) => ID.test(String(entry?.id)))
|
|
227
|
+
.map(clean);
|
|
228
|
+
const all = reported();
|
|
229
|
+
tellNew(from, all[from] ?? [], entries);
|
|
230
|
+
all[from] = entries;
|
|
231
|
+
store.meta(REPORTED, JSON.stringify(all));
|
|
232
|
+
return {
|
|
233
|
+
ok: true,
|
|
234
|
+
devices: list(),
|
|
235
|
+
decisions: decisionsFor(from, entries),
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
if (call?.op === "decide")
|
|
239
|
+
return drives
|
|
240
|
+
? decide(String(call.id ?? ""), String(call.decision ?? ""))
|
|
241
|
+
: {
|
|
242
|
+
ok: false,
|
|
243
|
+
code: "not_allowed",
|
|
244
|
+
error:
|
|
245
|
+
"a computer that only runs agents does not decide on the person's devices",
|
|
246
|
+
};
|
|
247
|
+
return { ok: false, error: "unknown devices call" };
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* The person's decision on a device or ask, from any of their computers: carried out here when it is this computer's,
|
|
252
|
+
* else kept by home for the computer it is for, which hears at once when it can and otherwise on its next report.
|
|
253
|
+
*/
|
|
254
|
+
const decide = async (id, decision) => {
|
|
255
|
+
if (!ID.test(id) || !DECISION_WORDS.has(decision))
|
|
256
|
+
return { ok: false, error: "no device or browser with that id" };
|
|
257
|
+
const here = applyHere(id, decision);
|
|
258
|
+
if (here) {
|
|
259
|
+
void report();
|
|
260
|
+
return here;
|
|
261
|
+
}
|
|
262
|
+
const machines = own();
|
|
263
|
+
if (machines && !isHome()) {
|
|
264
|
+
if (!machines.joined?.())
|
|
265
|
+
return { ok: false, error: "no device or browser with that id" };
|
|
266
|
+
const answer = await machines.callHome({
|
|
267
|
+
command: DEVICES_COMMAND,
|
|
268
|
+
op: "decide",
|
|
269
|
+
id,
|
|
270
|
+
decision,
|
|
271
|
+
});
|
|
272
|
+
void report();
|
|
273
|
+
return answer ?? { ok: false, error: "home is out of reach" };
|
|
274
|
+
}
|
|
275
|
+
const entry = list().find((item) => item.id === id);
|
|
276
|
+
if (!entry || entry.computer === self())
|
|
277
|
+
return { ok: false, error: "no device or browser with that id" };
|
|
278
|
+
const all = decisions();
|
|
279
|
+
all[id] = { decision, computer: entry.computer, at: Date.now() };
|
|
280
|
+
keepDecisions(all);
|
|
281
|
+
void machines?.noticeTo?.(entry.computer, { devices: true });
|
|
282
|
+
log(`devices: ${decision} ${id} on ${entry.computer}`);
|
|
283
|
+
return { ok: true, computer: labelOf(entry.computer) };
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
// A device of the person's that works here: paired, not disconnected and not waiting for them.
|
|
287
|
+
const anotherListed = (id) =>
|
|
288
|
+
store
|
|
289
|
+
.phones()
|
|
290
|
+
.some(
|
|
291
|
+
(device) =>
|
|
292
|
+
device.id !== id && !device.revoked_at && !waiting(device.id)
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* A device just paired on this computer. One the person's own action let in (a link or code made here) is listed. One
|
|
297
|
+
* paired through an offer Harness made waits for the person, who allows it with one press on any of their computers
|
|
298
|
+
* or devices, when this computer works for a home of theirs or already has a device of theirs. The first device of a
|
|
299
|
+
* cloud computer on its own is listed: it is the browser where they pressed Add, with nothing else of theirs to press
|
|
300
|
+
* on.
|
|
301
|
+
*/
|
|
302
|
+
const paired = (device, { seeded = false } = {}) => {
|
|
303
|
+
if (seeded && (own()?.joined?.() || anotherListed(device.id)))
|
|
304
|
+
store.meta(waitingKey(device.id), new Date().toISOString());
|
|
305
|
+
void report();
|
|
306
|
+
return waiting(device.id) ? "waiting" : "listed";
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
return {
|
|
310
|
+
list,
|
|
311
|
+
paired,
|
|
312
|
+
waiting,
|
|
313
|
+
decide,
|
|
314
|
+
report,
|
|
315
|
+
answer,
|
|
316
|
+
// Home's notice that decisions wait for this computer.
|
|
317
|
+
heard: () => void report(),
|
|
318
|
+
};
|
|
319
|
+
}
|
package/lib/swarmMemory.mjs
CHANGED
|
@@ -4,28 +4,28 @@ import { oneLine } from "./oneLine.mjs";
|
|
|
4
4
|
import { nameOf } from "./members.mjs";
|
|
5
5
|
import { fromBlob, toBlob, topK } from "./vectors.mjs";
|
|
6
6
|
|
|
7
|
-
// The swarm's long-running memory, after Hindsight (vectorize-io/hindsight, MIT
|
|
8
|
-
//
|
|
9
|
-
//
|
|
7
|
+
// The swarm's long-running memory, after Hindsight (vectorize-io/hindsight, MIT): its dream architecture, applied to
|
|
8
|
+
// a swarm's memory over long-running work. The raw facts are what the board already keeps: every post, job result and
|
|
9
|
+
// receipt, by who wrote it, where and when.
|
|
10
10
|
//
|
|
11
11
|
// - recall: what an agent finds when it looks back. Hindsight's parallel searches fused by rank: by meaning (the
|
|
12
12
|
// search model's vectors) and by words, over threads and jobs alike, each item with its thread, author and time.
|
|
13
13
|
// Held posts and what the person forgot or replaced never come back; a hosted asker sees only its own threads and
|
|
14
14
|
// none of the person's lessons or observations; a receipt (written by code from a run's own session) comes before
|
|
15
15
|
// what the agent said about the same thread. With nothing close, it says so (`weak`) instead of passing near misses
|
|
16
|
-
// off as answers (
|
|
16
|
+
// off as answers (measured: a never-said question's nearest posts score like a real one's).
|
|
17
17
|
// - forBrief: what a woken agent is told without asking: the observations that hold for its work, then what other
|
|
18
|
-
// threads and earlier jobs found or failed at (
|
|
19
|
-
//
|
|
18
|
+
// threads and earlier jobs found or failed at (without it, a finding was searchable but never reached the next agent;
|
|
19
|
+
// a failed attempt's cause and a receipt reached no one).
|
|
20
20
|
// - heard: each post of the person's is read on Harness's server (swarm/memoryChange.ts) against their earlier posts
|
|
21
21
|
// and what the memory holds: what it replaces is marked replaced, what it asks to forget is released (out of recall
|
|
22
22
|
// and briefs, still in the thread) or purged (its words gone everywhere). ForgetEval's finding: the judgment belongs
|
|
23
|
-
// at the moment of change (
|
|
23
|
+
// at the moment of change (before it, the relay forgot next to nothing: 1 of 385).
|
|
24
24
|
// - dream: the background consolidation. New facts are read on Harness's server (swarm/dream.ts) against the
|
|
25
25
|
// observations already kept: a belief borne out again gains the new words, a changed one keeps what it said before
|
|
26
26
|
// in its history, and only what should still hold later is kept (Hindsight's mission: durable, specific facts, not
|
|
27
27
|
// ephemeral state). With hindsight, lessons that were instructions for one job are retired and lessons that hold
|
|
28
|
-
// for all work are widened beyond their folder (
|
|
28
|
+
// for all work are widened beyond their folder (measured on real threads, 5 of 11 lessons were one-job instructions).
|
|
29
29
|
// Observations are what Hindsight calls them; its mental models, standing answers per scope, are assembled here by
|
|
30
30
|
// code from the observations of a folder or agent at the moment a brief needs them, so they are never stale.
|
|
31
31
|
//
|
|
@@ -38,8 +38,8 @@ const POOL = 60;
|
|
|
38
38
|
const RRF_K = 60;
|
|
39
39
|
const QUERY_CHARS = 500;
|
|
40
40
|
// The nearest post's similarity below which nothing closely matches: what at least 95% of answerable questions reach,
|
|
41
|
-
// on LongMemEval-S questions no other memory eval scores (
|
|
42
|
-
//
|
|
41
|
+
// on LongMemEval-S questions no other memory eval scores (measured while tuning, stopped at 36 of 48: 35 of 36
|
|
42
|
+
// answerable kept, 23 of 36 never-said caught).
|
|
43
43
|
export const WEAK_BELOW = 0.7;
|
|
44
44
|
const POST_CHARS = 2_000;
|
|
45
45
|
const RECALL_OBSERVATIONS = 4;
|
|
@@ -74,6 +74,8 @@ export function createSwarmMemory({
|
|
|
74
74
|
inRoom = () => false,
|
|
75
75
|
isCoordinatorPost = () => false,
|
|
76
76
|
isFlagged = () => false,
|
|
77
|
+
// A post's words as an agent reads them (serverWords.mjs agentText): a round's words the guard did not clear are left out.
|
|
78
|
+
agentText = (row) => row.text,
|
|
77
79
|
// What the person saw (seen.mjs): read at each dream, shown to the person's own searches only.
|
|
78
80
|
seenMemory = null,
|
|
79
81
|
log = () => {},
|
|
@@ -94,7 +96,7 @@ export function createSwarmMemory({
|
|
|
94
96
|
task: row.task_id,
|
|
95
97
|
kind: row.kind,
|
|
96
98
|
author: row.author,
|
|
97
|
-
text: String(row
|
|
99
|
+
text: String(agentText(row)).slice(0, POST_CHARS),
|
|
98
100
|
created_at: row.created_at,
|
|
99
101
|
// Written by code from a run's own session file (receipts.mjs), never by the agent.
|
|
100
102
|
checked: row.kind === "receipt",
|
|
@@ -114,8 +116,8 @@ export function createSwarmMemory({
|
|
|
114
116
|
(folder && path.resolve(item.folder) === path.resolve(folder));
|
|
115
117
|
|
|
116
118
|
// The kept observations closest to a text that hold for this folder and agent: by meaning (at or above `floor` when
|
|
117
|
-
// given), then by words unless `byWords` is off. Never topped up with ones that do not bear on the text:
|
|
118
|
-
//
|
|
119
|
+
// given), then by words unless `byWords` is off. Never topped up with ones that do not bear on the text: on real
|
|
120
|
+
// history the dream also kept agents' passing progress, which a brief should not carry for being well borne out.
|
|
119
121
|
const closestObservations = async (
|
|
120
122
|
text,
|
|
121
123
|
{ folder, agent, limit, floor = null, byWords = true, everyFolder = false }
|
|
@@ -153,7 +155,7 @@ export function createSwarmMemory({
|
|
|
153
155
|
|
|
154
156
|
// Hindsight's graph strategy for what the dream kept, by the thread: the newest observations standing on the threads
|
|
155
157
|
// found come along. A later post refers to them without their words ("the same song selection" for "the person liked
|
|
156
|
-
// the candy track",
|
|
158
|
+
// the candy track": measured, kept, and shown at no limit up to 12 by meaning or words).
|
|
157
159
|
const threadObservations = (threads, { folder, agent, everyFolder }) => {
|
|
158
160
|
const followed = new Set(threads.slice(0, THREADS_FOLLOWED));
|
|
159
161
|
const taken = new Map();
|
|
@@ -688,12 +690,12 @@ export function createSwarmMemory({
|
|
|
688
690
|
* DREAM_FACTS new facts; the rest wait for the next night.
|
|
689
691
|
*/
|
|
690
692
|
/**
|
|
691
|
-
* An agent's note pushed to the swarm (swarm_memory remember, goalCommands.mjs checks it first): kept as an
|
|
692
|
-
* agent pulls through swarm_memory and briefs, on any computer (board_observations is mirrored),
|
|
693
|
-
* agent's own words and unchecked until later work bears it out; the dream confirms, changes or
|
|
694
|
-
* other. Its `agent` stays null: an observation about one agent reaches only that agent, and a
|
|
695
|
-
*
|
|
696
|
-
* replaces the agent's own earlier one takes its pushed observation's place.
|
|
693
|
+
* An agent's note pushed to the swarm (swarm_memory remember, goalCommands.mjs checks it first): kept as an
|
|
694
|
+
* observation every agent pulls through swarm_memory and briefs, on any computer (board_observations is mirrored),
|
|
695
|
+
* standing on the agent's own words and unchecked until later work bears it out; the dream confirms, changes or
|
|
696
|
+
* replaces it like any other. Its `agent` stays null: an observation about one agent reaches only that agent, and a
|
|
697
|
+
* push is for all of them: the memory is the swarm's, not one agent's, and every agent pushes to it and pulls from
|
|
698
|
+
* it. A note that replaces the agent's own earlier one takes its pushed observation's place.
|
|
697
699
|
*/
|
|
698
700
|
const push = async (thread, agent, note) => {
|
|
699
701
|
if (!note?.id) return null;
|
|
@@ -726,7 +728,7 @@ export function createSwarmMemory({
|
|
|
726
728
|
// `before`: only what was written before a moment (an eval replaying a board in the order it was written).
|
|
727
729
|
// The person's approvals, as the board recorded them (reactions.mjs), kept as decisions by code: each stands on their
|
|
728
730
|
// words and the work approved. Approvals are what "the two videos I okayed" refers to, and the model-read dream kept
|
|
729
|
-
// none of them
|
|
731
|
+
// none of them on real history ("I would post that!" read at 0.36). One decision per post of theirs.
|
|
730
732
|
const keepApprovals = async (before, report) => {
|
|
731
733
|
const rows = store
|
|
732
734
|
.approvalsAfter(meta("dream-approvals-cursor") || "", 200)
|
|
@@ -744,7 +746,7 @@ export function createSwarmMemory({
|
|
|
744
746
|
const added = store.addObservation({
|
|
745
747
|
kind: "decision",
|
|
746
748
|
// What the person okayed is theirs, not one folder's: "the two videos I okayed" was asked from a thread in
|
|
747
|
-
// another folder than the videos'
|
|
749
|
+
// another folder than the videos'.
|
|
748
750
|
folder: null,
|
|
749
751
|
text: `The person approved${changes ? ", with changes," : ""} ${agents.join(" and ")}'s work in "${clip(first.thread_title, 120)}" on ${dateOf(first.said_at)}${work ? `: ${clip(work.work, 200)}` : ""}`,
|
|
750
752
|
evidence: [
|
|
@@ -781,8 +783,8 @@ export function createSwarmMemory({
|
|
|
781
783
|
meta(`dream-approved:${fact.id}`, new Date().toISOString());
|
|
782
784
|
const held = store.observations({ limit: 5000 }).some(
|
|
783
785
|
// An approval code already kept (keepApprovals), not the writer's reading of the same post: the writer read "I
|
|
784
|
-
// would post that!" as "The person reviewed video 5 ... and provided critical feedback"
|
|
785
|
-
//
|
|
786
|
+
// would post that!" as "The person reviewed video 5 ... and provided critical feedback", and the approval was
|
|
787
|
+
// never kept.
|
|
786
788
|
(observation) =>
|
|
787
789
|
observation.text.startsWith("The person approved") &&
|
|
788
790
|
observation.evidence.some((entry) => entry.contributionId === fact.id)
|
|
@@ -806,7 +808,7 @@ export function createSwarmMemory({
|
|
|
806
808
|
};
|
|
807
809
|
|
|
808
810
|
// A night that fails is tried again later (daemon.mjs waits an hour after one): Jev now and then answers a choice
|
|
809
|
-
// that is not its likeliest, which its validator refuses (
|
|
811
|
+
// that is not its likeliest, which its validator refuses (one comparison in 113 nights).
|
|
810
812
|
const failed = (report, why) => {
|
|
811
813
|
log(`dream: ${why}`);
|
|
812
814
|
meta("dream-failed", report.at);
|
package/lib/t3.mjs
CHANGED
|
@@ -17,8 +17,8 @@ import { trackRun } from "./runner.mjs";
|
|
|
17
17
|
// T3's desktop app binds the first free port from 3773 up (T3 apps/server/src/auth/utils.ts).
|
|
18
18
|
const FIRST_PORT = 3773;
|
|
19
19
|
const PORTS = 20;
|
|
20
|
-
// Its descriptor answered in at most 1.7 ms over 40 tries while T3 ran four busy sessions
|
|
21
|
-
//
|
|
20
|
+
// Its descriptor answered in at most 1.7 ms over 40 tries while T3 ran four busy sessions; a closed port refuses in
|
|
21
|
+
// under 0.4 ms. The limit only keeps a port held by something else from stalling the search.
|
|
22
22
|
const PROBE_MS = 1_000;
|
|
23
23
|
const PROTOCOL = "2025-06-18";
|
|
24
24
|
|
|
@@ -42,6 +42,8 @@ export async function findT3(home = t3Home(), hint = null) {
|
|
|
42
42
|
} catch {
|
|
43
43
|
return null;
|
|
44
44
|
}
|
|
45
|
+
// "late" when the limit ran out: either nothing answered in time, or this process was busy past the limit and its
|
|
46
|
+
// timer fired before it read an answer already waiting.
|
|
45
47
|
const answers = async (origin) => {
|
|
46
48
|
try {
|
|
47
49
|
const response = await fetch(`${origin}/.well-known/t3/environment`, {
|
|
@@ -50,14 +52,21 @@ export async function findT3(home = t3Home(), hint = null) {
|
|
|
50
52
|
return (
|
|
51
53
|
response.ok && (await response.json())?.environmentId === environmentId
|
|
52
54
|
);
|
|
53
|
-
} catch {
|
|
54
|
-
return false;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
return error?.name === "TimeoutError" ? "late" : false;
|
|
55
57
|
}
|
|
56
58
|
};
|
|
57
|
-
|
|
59
|
+
// The address T3 last answered on is asked again when it was late: the daemon's own work blocked it for up to 11 s
|
|
60
|
+
// during the context engine's pass while T3 answered in under 50 ms, so a late answer there said "not running" and
|
|
61
|
+
// the T3 threads list emptied.
|
|
62
|
+
if (hint) {
|
|
63
|
+
const first = await answers(hint);
|
|
64
|
+
const found = first === "late" ? await answers(hint) : first;
|
|
65
|
+
if (found === true) return { origin: hint, environmentId };
|
|
66
|
+
}
|
|
58
67
|
for (let port = FIRST_PORT; port < FIRST_PORT + PORTS; port++) {
|
|
59
68
|
const origin = `http://127.0.0.1:${port}`;
|
|
60
|
-
if (origin !== hint && (await answers(origin)))
|
|
69
|
+
if (origin !== hint && (await answers(origin)) === true)
|
|
61
70
|
return { origin, environmentId };
|
|
62
71
|
}
|
|
63
72
|
return null;
|
|
@@ -442,7 +451,7 @@ function stepOf(item) {
|
|
|
442
451
|
|
|
443
452
|
// The option T3 gives each agent's effort under, by agent.
|
|
444
453
|
const EFFORT_OPTIONS = new Set(["reasoningEffort", "effort"]);
|
|
445
|
-
// An option's choices: `values` since T3 #22889
|
|
454
|
+
// An option's choices: `values` since T3 #22889, `options: [{ id }]` before.
|
|
446
455
|
const choicesOf = (option) =>
|
|
447
456
|
option.values ?? option.options?.map((level) => level.id) ?? [];
|
|
448
457
|
const versionOf = (id) => (id.match(/\d+/g) ?? []).map(Number);
|
|
@@ -465,13 +474,13 @@ const matching = (provider, model) => {
|
|
|
465
474
|
|
|
466
475
|
/**
|
|
467
476
|
* The selection T3 Code runs an agent's turn with: the model and effort the buddy shows for it (the person's pick, else
|
|
468
|
-
* the agent's own settings), as T3 names them. T3 names Claude's models in full (claude-opus-5-5) where Claude Code
|
|
469
|
-
* a short name (opus), which is the newest of that family T3 offers. Null when nothing names a model. A model or
|
|
470
|
-
* T3 does not offer fails the turn rather than letting T3 run it on another (
|
|
471
|
-
*
|
|
477
|
+
* the agent's own settings), as T3 names them. T3 names Claude's models in full (claude-opus-5-5) where Claude Code
|
|
478
|
+
* takes a short name (opus), which is the newest of that family T3 offers. Null when nothing names a model. A model or
|
|
479
|
+
* effort T3 does not offer fails the turn rather than letting T3 run it on another (Codex once ran on gpt-6-astra for
|
|
480
|
+
* days while the buddy showed gpt-6.1-sol).
|
|
472
481
|
*
|
|
473
|
-
* Since T3 #22889
|
|
474
|
-
*
|
|
482
|
+
* Since T3 #22889, T3 lists a short list of each agent's models and says how many it left out; a model not on it is
|
|
483
|
+
* looked up with T3's search. An older T3 lists every model and leaves out none, so it is never searched.
|
|
475
484
|
*/
|
|
476
485
|
async function selectionFor({ instanceId, model, effort } = {}) {
|
|
477
486
|
if (!model) return null;
|
|
@@ -688,8 +697,8 @@ export function runInT3(run, emit, observe) {
|
|
|
688
697
|
if (stopped) await interrupt();
|
|
689
698
|
void read();
|
|
690
699
|
} catch (error) {
|
|
691
|
-
// T3 Code did not answer before the turn began, though it was there a moment before (
|
|
692
|
-
//
|
|
700
|
+
// T3 Code did not answer before the turn began, though it was there a moment before (twice a turn failed this way
|
|
701
|
+
// while T3 was running): where the caller can run the agent itself, it does.
|
|
693
702
|
if (error.code === "not_running" && !runId && run.fallback && !stopped) {
|
|
694
703
|
letGo();
|
|
695
704
|
run.fallback(error.message);
|