tryharness 0.7.54 → 0.7.58
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 +384 -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 +141 -50
- package/lib/oneLine.mjs +7 -7
- package/lib/ownMachines.mjs +928 -149
- package/lib/pairing.mjs +39 -8
- 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/models.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import os from "node:os";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { spawn } from "node:child_process";
|
|
5
5
|
import { agentEnvironment } from "./agentnode.mjs";
|
|
6
|
+
import { agentBinary } from "./agentBinaries.mjs";
|
|
6
7
|
import { MACHINE_RUNNERS, member, nameOf } from "./members.mjs";
|
|
7
8
|
import { trackHelper } from "./runner.mjs";
|
|
8
9
|
import { listProtocolModels } from "./agentRuntimes.mjs";
|
|
@@ -12,15 +13,17 @@ import { listProtocolModels } from "./agentRuntimes.mjs";
|
|
|
12
13
|
// models the others list here). A run uses, first: a model named for it (`@codex:gpt-6-luna/high` in a post, or
|
|
13
14
|
// post_task's model); then the person's choice for the agent, which may be Auto (Harness's Jev picks from the list
|
|
14
15
|
// against the person's routing words); else nothing, and the agent runs on its own settings. Every pick is checked
|
|
15
|
-
// against the agent's list before a run starts.
|
|
16
|
+
// against the agent's list before a run starts. An agent on Harness's AI on a cloud computer lists Harness's models
|
|
17
|
+
// instead (cloudAi.mjs catalogOf: what the person's pass or credits pay for, each with its limits), where Auto is
|
|
18
|
+
// Harness's own, picking the model for each request, and is the agent's default.
|
|
16
19
|
|
|
17
20
|
const CLAUDE_EFFORTS = ["low", "medium", "high", "xhigh", "max"]; // claude --help
|
|
18
21
|
const PI_THINKING = ["off", "minimal", "low", "medium", "high", "xhigh", "max"]; // pi --help
|
|
19
22
|
const CLAUDE_NAMES = ["fable", "opus", "sonnet", "haiku"];
|
|
20
23
|
/**
|
|
21
|
-
* The routing words Auto goes by until the person writes their own.
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
+
* The routing words Auto goes by until the person writes their own. An earlier wording, "The cheapest model that can do
|
|
25
|
+
* this work well; more effort only for hard work.", sent demanding work to cheap models on a fixed set of routing
|
|
26
|
+
* cases.
|
|
24
27
|
*/
|
|
25
28
|
export const DEFAULT_ROUTING =
|
|
26
29
|
"Match the model to the work: for easy work, the cheapest model that does it well; for demanding work, the most capable one. Pass over a model that keeps failing here. More effort only for hard work.";
|
|
@@ -103,7 +106,8 @@ const LISTS = {
|
|
|
103
106
|
},
|
|
104
107
|
};
|
|
105
108
|
|
|
106
|
-
|
|
109
|
+
// `program` is the agent's confirmed program (agentBinaries.mjs); `command` its name, for the Node it needs.
|
|
110
|
+
function capture(command, args, program) {
|
|
107
111
|
return new Promise((resolve, reject) => {
|
|
108
112
|
const environment = agentEnvironment(command);
|
|
109
113
|
if (environment.error) {
|
|
@@ -112,7 +116,7 @@ function capture(command, args) {
|
|
|
112
116
|
}
|
|
113
117
|
let child;
|
|
114
118
|
try {
|
|
115
|
-
child = spawn(
|
|
119
|
+
child = spawn(program, args, { cwd: os.tmpdir(), env: environment.env });
|
|
116
120
|
} catch (error) {
|
|
117
121
|
reject(error);
|
|
118
122
|
return;
|
|
@@ -149,7 +153,10 @@ export const listingOf = (store, agent) => {
|
|
|
149
153
|
return null;
|
|
150
154
|
}
|
|
151
155
|
};
|
|
152
|
-
/**
|
|
156
|
+
/**
|
|
157
|
+
* An agent's models as it last listed them: [{ id, about?, efforts, defaultEffort?, context?, price? }], and on
|
|
158
|
+
* Harness's AI also name, maxOutput and image, with Auto marked auto.
|
|
159
|
+
*/
|
|
153
160
|
export const catalogOf = (store, agent) =>
|
|
154
161
|
listingOf(store, agent)?.models ?? [];
|
|
155
162
|
|
|
@@ -161,16 +168,32 @@ export async function refreshCatalogs(
|
|
|
161
168
|
store,
|
|
162
169
|
agents,
|
|
163
170
|
log = () => {},
|
|
164
|
-
{ protocols = false } = {}
|
|
171
|
+
{ protocols = false, managed = () => null } = {}
|
|
165
172
|
) {
|
|
173
|
+
// An agent on Harness's AI lists Harness's models, as the computer last read them; its own command is not asked.
|
|
174
|
+
const onHarness = agents.filter((agent) => {
|
|
175
|
+
const listing = managed(agent);
|
|
176
|
+
if (!listing) return false;
|
|
177
|
+
store.meta(
|
|
178
|
+
catalogKey(agent),
|
|
179
|
+
JSON.stringify({ at: new Date().toISOString(), ...listing })
|
|
180
|
+
);
|
|
181
|
+
return true;
|
|
182
|
+
});
|
|
166
183
|
await Promise.all(
|
|
167
184
|
agents
|
|
185
|
+
.filter((name) => !onHarness.includes(name))
|
|
168
186
|
.filter((name) => LISTS[name] || (protocols && member(name)?.runtime))
|
|
169
187
|
.map(async (agent) => {
|
|
170
188
|
try {
|
|
171
189
|
const offered = LISTS[agent]
|
|
172
190
|
? LISTS[agent].parse(
|
|
173
|
-
await capture(
|
|
191
|
+
await capture(
|
|
192
|
+
LISTS[agent].command,
|
|
193
|
+
LISTS[agent].args,
|
|
194
|
+
agentBinary(agent, LISTS[agent].command) ??
|
|
195
|
+
LISTS[agent].command
|
|
196
|
+
)
|
|
174
197
|
)
|
|
175
198
|
: await listProtocolModels(agent, trackHelper);
|
|
176
199
|
const models = offered.filter((entry) => entry.id);
|
|
@@ -180,17 +203,21 @@ export async function refreshCatalogs(
|
|
|
180
203
|
);
|
|
181
204
|
} catch (error) {
|
|
182
205
|
log(`model list for ${agent}: ${error.message}`);
|
|
206
|
+
// Its last own list stands; Harness's list or a proxy link's does not, once the agent is off it.
|
|
207
|
+
const last = listingOf(store, agent);
|
|
183
208
|
store.meta(
|
|
184
209
|
catalogKey(agent),
|
|
185
210
|
JSON.stringify({
|
|
186
|
-
...(
|
|
211
|
+
...(last && !last.harness && !last.link && !last.standin
|
|
212
|
+
? last
|
|
213
|
+
: { models: [] }),
|
|
187
214
|
error: error.message.slice(0, 300),
|
|
188
215
|
})
|
|
189
216
|
);
|
|
190
217
|
}
|
|
191
218
|
})
|
|
192
219
|
);
|
|
193
|
-
if (agents.includes("claude-code")) {
|
|
220
|
+
if (agents.includes("claude-code") && !onHarness.includes("claude-code")) {
|
|
194
221
|
const anthropic = [
|
|
195
222
|
...new Set(
|
|
196
223
|
["pi", "opencode"]
|
|
@@ -236,14 +263,26 @@ function findModel(store, agent, written) {
|
|
|
236
263
|
};
|
|
237
264
|
}
|
|
238
265
|
|
|
239
|
-
/**
|
|
266
|
+
/**
|
|
267
|
+
* A model and effort for an agent, checked against its list: { ok, pick } with pick { model, effort } or { auto: true }.
|
|
268
|
+
* On Harness's AI, Auto is Harness's own entry in the list, which picks the model for each request.
|
|
269
|
+
*/
|
|
240
270
|
export function resolvePick(store, agent, model, effort = null) {
|
|
241
271
|
if (
|
|
242
272
|
String(model || "")
|
|
243
273
|
.trim()
|
|
244
274
|
.toLowerCase() === "auto"
|
|
245
|
-
)
|
|
246
|
-
|
|
275
|
+
) {
|
|
276
|
+
const harnessAuto = listingOf(store, agent)?.harness
|
|
277
|
+
? catalogOf(store, agent).find((entry) => entry.auto)
|
|
278
|
+
: null;
|
|
279
|
+
return {
|
|
280
|
+
ok: true,
|
|
281
|
+
pick: harnessAuto
|
|
282
|
+
? { model: harnessAuto.id, effort: null }
|
|
283
|
+
: { auto: true },
|
|
284
|
+
};
|
|
285
|
+
}
|
|
247
286
|
const found = findModel(store, agent, model);
|
|
248
287
|
if (found.error) return { ok: false, error: found.error };
|
|
249
288
|
const level = effort ? String(effort).trim().toLowerCase() : null;
|
|
@@ -317,6 +356,12 @@ export function setChoice(store, agent, model, effort = null) {
|
|
|
317
356
|
}
|
|
318
357
|
const resolved = resolvePick(store, agent, model, effort);
|
|
319
358
|
if (!resolved.ok) return resolved;
|
|
359
|
+
// On Harness's AI, Auto is the agent's own default: choosing it is choosing nothing else.
|
|
360
|
+
const autoEntry = catalogOf(store, agent).find((entry) => entry.auto);
|
|
361
|
+
if (autoEntry && resolved.pick.model === autoEntry.id) {
|
|
362
|
+
store.meta(choiceKey(agent), "");
|
|
363
|
+
return { ok: true, choice: null };
|
|
364
|
+
}
|
|
320
365
|
store.meta(choiceKey(agent), JSON.stringify(resolved.pick));
|
|
321
366
|
return { ok: true, choice: resolved.pick };
|
|
322
367
|
}
|
|
@@ -484,7 +529,7 @@ function recordByModel(store, agent) {
|
|
|
484
529
|
};
|
|
485
530
|
}
|
|
486
531
|
|
|
487
|
-
/** What Auto sends Harness for one run
|
|
532
|
+
/** What Auto sends Harness for one run: the work, the person's words, every listed model with its record here. */
|
|
488
533
|
export const routeInput = ({
|
|
489
534
|
agent,
|
|
490
535
|
work,
|
|
@@ -526,14 +571,23 @@ export function createModelRouter({
|
|
|
526
571
|
if (!pick) return null;
|
|
527
572
|
const by = named ? (named.by === "user" ? "you" : named.by) : pick.by;
|
|
528
573
|
// A model picked without an effort runs at the default its list gives it, the one the buddy shows, named on the run
|
|
529
|
-
// so the agent's own settings (Codex's model_reasoning_effort) do not put a different one in its place.
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
null,
|
|
536
|
-
|
|
574
|
+
// so the agent's own settings (Codex's model_reasoning_effort) do not put a different one in its place. A model
|
|
575
|
+
// whose list says its window and longest answer (Harness's AI) carries them, for an agent told them per run.
|
|
576
|
+
const withDefaultEffort = (picked) => {
|
|
577
|
+
const entry = findModel(store, agent, picked.model).entry;
|
|
578
|
+
return {
|
|
579
|
+
...picked,
|
|
580
|
+
effort: picked.effort ?? entry?.defaultEffort ?? null,
|
|
581
|
+
...(entry?.context && entry?.maxOutput
|
|
582
|
+
? {
|
|
583
|
+
limits: {
|
|
584
|
+
contextTokens: entry.context,
|
|
585
|
+
maxOutputTokens: entry.maxOutput,
|
|
586
|
+
},
|
|
587
|
+
}
|
|
588
|
+
: {}),
|
|
589
|
+
};
|
|
590
|
+
};
|
|
537
591
|
if (!pick.auto) {
|
|
538
592
|
// The list may have changed since the pick: a model the agent no longer lists runs on its own settings, said so.
|
|
539
593
|
const checked = resolvePick(store, agent, pick.model, pick.effort);
|
package/lib/museSession.mjs
CHANGED
|
@@ -76,7 +76,12 @@ export async function openMuseSession({
|
|
|
76
76
|
"--agent",
|
|
77
77
|
task.agent,
|
|
78
78
|
],
|
|
79
|
-
env: {
|
|
79
|
+
env: {
|
|
80
|
+
HARNESS_RUN_ID: task.runId,
|
|
81
|
+
...(task.capability
|
|
82
|
+
? { HARNESS_RUN_TOKEN: task.capability }
|
|
83
|
+
: {}),
|
|
84
|
+
},
|
|
80
85
|
},
|
|
81
86
|
},
|
|
82
87
|
};
|
package/lib/nativeHost.mjs
CHANGED
|
@@ -5,8 +5,8 @@ import { paths } from "./paths.mjs";
|
|
|
5
5
|
|
|
6
6
|
// The Harness extension finds the daemon on its own computer through Chrome's native messaging: Chrome starts this
|
|
7
7
|
// host for the extension, one message in and one answer out, so the Harness window links to the computer it runs on
|
|
8
|
-
// with no `tryharness link`. The host says which computer this is (its public key and name) and, asked,
|
|
9
|
-
// offer for this browser
|
|
8
|
+
// with no `tryharness link`. The host says which computer this is (its public key and name) and, asked, gets a link
|
|
9
|
+
// offer for this browser once the person allows it on this computer; the page pairs with it through Harness, sealed.
|
|
10
10
|
//
|
|
11
11
|
// Only the extension named in the manifest's allowed_origins can start the host (Chrome enforces it). Its ID is fixed
|
|
12
12
|
// by the public key in packages/browser-extension/manifest.json, the Chrome Web Store item's.
|
|
@@ -110,7 +110,7 @@ const shellQuote = (value) => `'${String(value).replaceAll("'", `'\\''`)}'`;
|
|
|
110
110
|
/**
|
|
111
111
|
* The host itself, run by Chrome: reads length-prefixed JSON messages on `input` and answers each on `output`.
|
|
112
112
|
* `daemon(request)` is the daemon's control socket. Answers: `this-computer` with {publicKey, hostname, label, role},
|
|
113
|
-
* `computer-offer` with a pairing link's fragment for this browser.
|
|
113
|
+
* `computer-offer` with a pairing link's fragment for this browser once the person allows it on this computer.
|
|
114
114
|
*/
|
|
115
115
|
export async function serveNativeHost({
|
|
116
116
|
input,
|
|
@@ -159,11 +159,39 @@ export async function serveNativeHost({
|
|
|
159
159
|
}
|
|
160
160
|
: { ok: false, error: found?.error || "the daemon did not say" };
|
|
161
161
|
}
|
|
162
|
+
// The page asking is served by Harness, so its word alone makes no offer: the daemon asks the person on this
|
|
163
|
+
// computer, and the host waits for their answer (as long as the ask lasts, the offer's ten minutes).
|
|
162
164
|
if (message?.type === "computer-offer") {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
let asked = null;
|
|
166
|
+
do
|
|
167
|
+
asked = await daemon(
|
|
168
|
+
{
|
|
169
|
+
command: "phone.link.ask",
|
|
170
|
+
id: asked?.id ?? null,
|
|
171
|
+
label: String(message.label ?? "").slice(0, 60),
|
|
172
|
+
waitMs: 25_000,
|
|
173
|
+
},
|
|
174
|
+
30_000
|
|
175
|
+
);
|
|
176
|
+
while (asked?.ok && asked.state === "waiting" && !closed);
|
|
177
|
+
if (asked?.ok && asked.state === "allowed" && asked.url)
|
|
178
|
+
return { ok: true, fragment: new URL(asked.url).hash };
|
|
179
|
+
return {
|
|
180
|
+
ok: false,
|
|
181
|
+
code: asked?.state ?? "failed",
|
|
182
|
+
error:
|
|
183
|
+
asked?.state === "refused" || asked?.state === "expired"
|
|
184
|
+
? "the person did not allow this browser on this computer"
|
|
185
|
+
: asked?.error || "no offer was made",
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
// The extension itself asking to hold this browser's link (its deskKey.js), never a page's ask passed on: the
|
|
189
|
+
// background sends this on its own, and the key it pairs stays in the extension.
|
|
190
|
+
if (message?.type === "extension-link") {
|
|
191
|
+
const made = await daemon({ command: "phone.link.extension" });
|
|
192
|
+
return made?.ok && made.fragment
|
|
193
|
+
? { ok: true, fragment: made.fragment }
|
|
194
|
+
: { ok: false, error: made?.error || "no offer was made" };
|
|
167
195
|
}
|
|
168
196
|
return { ok: false, error: "unknown message" };
|
|
169
197
|
} catch (error) {
|
package/lib/network.mjs
CHANGED
|
@@ -22,6 +22,8 @@ export function createNetwork({
|
|
|
22
22
|
myKey,
|
|
23
23
|
// A relay thread that carries a shared project (projects.mjs): Swarms lists the project, not the thread under it.
|
|
24
24
|
isChannel = () => false,
|
|
25
|
+
// The person blocked a handle: whatever is open with them on this computer ends (security audit P9).
|
|
26
|
+
blocked = () => {},
|
|
25
27
|
}) {
|
|
26
28
|
// Harness answers for the server's half; a refusal comes back as a plain error the person can read.
|
|
27
29
|
const harness = async (input) => {
|
|
@@ -35,7 +37,21 @@ export function createNetwork({
|
|
|
35
37
|
// One row per request or thread, grouped by what it needs: the person (a request to answer, a held reply,
|
|
36
38
|
// a message from a person), nothing (open), the other side (a request not answered yet), or nobody (ended).
|
|
37
39
|
const conversations = async () => {
|
|
38
|
-
const server = await
|
|
40
|
+
const [server, card] = await Promise.all([
|
|
41
|
+
harness({ op: "threads" }).catch(() => null),
|
|
42
|
+
harness({ op: "card" }).catch(() => null),
|
|
43
|
+
]);
|
|
44
|
+
// A block made where this computer did not hear it (the dashboard while it was off) ends what is open here too.
|
|
45
|
+
for (const handle of Array.isArray(card?.blocks) ? card.blocks : [])
|
|
46
|
+
if (
|
|
47
|
+
store
|
|
48
|
+
.relayThreads()
|
|
49
|
+
.some(
|
|
50
|
+
(row) =>
|
|
51
|
+
!row.closed_at && handleOf(row.with_agent) === handleOf(handle)
|
|
52
|
+
)
|
|
53
|
+
)
|
|
54
|
+
blocked(handleOf(handle));
|
|
39
55
|
const local = new Map(
|
|
40
56
|
store.relayThreads().map((row) => [row.task_id, row])
|
|
41
57
|
);
|
|
@@ -54,6 +70,7 @@ export function createNetwork({
|
|
|
54
70
|
const opened = await openRelayRequest({
|
|
55
71
|
sealed: thread.sealed,
|
|
56
72
|
from: `${peer.handle}/${peer.agent}`,
|
|
73
|
+
id: thread.role === "target" ? thread.id : null,
|
|
57
74
|
}).catch(() => null);
|
|
58
75
|
if (opened) {
|
|
59
76
|
about = opened.about;
|
|
@@ -221,14 +238,28 @@ export function createNetwork({
|
|
|
221
238
|
return answered(conversations());
|
|
222
239
|
// The server's half of Swarms (card, search, contacts, blocks): what the dashboard asks Harness directly.
|
|
223
240
|
case "board.relay.network": {
|
|
224
|
-
|
|
241
|
+
// Only the operation's own fields go to Harness, which refuses any other (a browser's call adds fromWindow and
|
|
242
|
+
// sealedBy, phones.mjs).
|
|
243
|
+
const {
|
|
244
|
+
command: _command,
|
|
245
|
+
agent: _agent,
|
|
246
|
+
fromWindow: _fromWindow,
|
|
247
|
+
hostedCaller: _hosted,
|
|
248
|
+
provenance: _provenance,
|
|
249
|
+
sealedBy: _sealedBy,
|
|
250
|
+
...input
|
|
251
|
+
} = request;
|
|
225
252
|
if (input.op === "decide" || input.op === "threads")
|
|
226
253
|
return {
|
|
227
254
|
ok: false,
|
|
228
255
|
error: "use board.relay.decide and board.relay.list",
|
|
229
256
|
};
|
|
230
257
|
return answered(
|
|
231
|
-
harness(input).then((answer) =>
|
|
258
|
+
harness(input).then((answer) => {
|
|
259
|
+
if (input.op === "block" && input.on === true)
|
|
260
|
+
blocked(handleOf(input.handle));
|
|
261
|
+
return { ok: true, ...answer };
|
|
262
|
+
})
|
|
232
263
|
);
|
|
233
264
|
}
|
|
234
265
|
case "board.relay.decide":
|
|
@@ -239,7 +270,11 @@ export function createNetwork({
|
|
|
239
270
|
op: "decide",
|
|
240
271
|
id,
|
|
241
272
|
decision: String(request.decision),
|
|
242
|
-
}).then((answer) =>
|
|
273
|
+
}).then((answer) => {
|
|
274
|
+
if (request.decision === "block" && answer.thread?.asker?.handle)
|
|
275
|
+
blocked(handleOf(answer.thread.asker.handle));
|
|
276
|
+
return { ok: true, ...answer };
|
|
277
|
+
})
|
|
243
278
|
);
|
|
244
279
|
// A request from this computer: to one of their listed agents from one of the person's, or to the person themselves.
|
|
245
280
|
case "board.relay.request": {
|
|
@@ -256,6 +291,7 @@ export function createNetwork({
|
|
|
256
291
|
about: request.about,
|
|
257
292
|
brief: request.brief,
|
|
258
293
|
refs: request.refs,
|
|
294
|
+
readable: request.readable === true,
|
|
259
295
|
}).then((made) => ({ ok: true, ...made }))
|
|
260
296
|
);
|
|
261
297
|
}
|
|
@@ -310,5 +346,14 @@ export function createNetwork({
|
|
|
310
346
|
return answer.card?.handle ?? null;
|
|
311
347
|
};
|
|
312
348
|
|
|
313
|
-
return {
|
|
349
|
+
return {
|
|
350
|
+
command,
|
|
351
|
+
opened,
|
|
352
|
+
invites,
|
|
353
|
+
sentProjects,
|
|
354
|
+
decide,
|
|
355
|
+
myHandle,
|
|
356
|
+
// Harness says the person blocked a handle from another of their screens.
|
|
357
|
+
blockedElsewhere: (handle) => blocked(handleOf(handle)),
|
|
358
|
+
};
|
|
314
359
|
}
|
package/lib/notify.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { nameOf } from "./members.mjs";
|
|
|
9
9
|
|
|
10
10
|
const TITLE = "Harness";
|
|
11
11
|
|
|
12
|
-
function command(platform, title, body, env) {
|
|
12
|
+
export function command(platform, title, body, env) {
|
|
13
13
|
if (env.HARNESS_NOTIFY_COMMAND)
|
|
14
14
|
return { command: env.HARNESS_NOTIFY_COMMAND, args: [title, body] };
|
|
15
15
|
if (platform === "darwin") {
|
|
@@ -25,17 +25,18 @@ function command(platform, title, body, env) {
|
|
|
25
25
|
}
|
|
26
26
|
if (platform === "linux")
|
|
27
27
|
return { command: "notify-send", args: [title, body] };
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
// The words go in through the environment, never into the script: PowerShell also ends a quoted string at the
|
|
29
|
+
// typographic quotes an agent's words can carry, so no escaping of them inside a script is safe.
|
|
30
|
+
if (platform === "win32")
|
|
30
31
|
return {
|
|
31
32
|
command: "powershell",
|
|
32
33
|
args: [
|
|
33
34
|
"-NoProfile",
|
|
34
35
|
"-Command",
|
|
35
|
-
|
|
36
|
+
"[void][System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); $n = New-Object System.Windows.Forms.NotifyIcon; $n.Icon = [System.Drawing.SystemIcons]::Information; $n.Visible = $true; $n.ShowBalloonTip(8000, $env:HARNESS_NOTICE_TITLE, $env:HARNESS_NOTICE_BODY, 'Info'); Start-Sleep -Seconds 9; $n.Dispose()",
|
|
36
37
|
],
|
|
38
|
+
env: { HARNESS_NOTICE_TITLE: title, HARNESS_NOTICE_BODY: body },
|
|
37
39
|
};
|
|
38
|
-
}
|
|
39
40
|
return null;
|
|
40
41
|
}
|
|
41
42
|
|
|
@@ -49,6 +50,7 @@ export function notifyDesktop(
|
|
|
49
50
|
const child = spawn(call.command, call.args, {
|
|
50
51
|
stdio: "ignore",
|
|
51
52
|
detached: true,
|
|
53
|
+
...(call.env ? { env: { ...env, ...call.env } } : {}),
|
|
52
54
|
});
|
|
53
55
|
child.on("error", () => {});
|
|
54
56
|
child.unref();
|
package/lib/nudge.mjs
CHANGED
|
@@ -16,9 +16,9 @@ import { hookDialect, hookInput } from "./hookDialects.mjs";
|
|
|
16
16
|
// import this file from the runtime and call the same functions. Nothing waiting, or no daemon, prints nothing.
|
|
17
17
|
|
|
18
18
|
// What a session start may carry. Claude Code 2.1.304 cuts an MCP server's instructions at 4,096 characters and ends
|
|
19
|
-
// them "… [truncated]" (its CLAUDE_CODE_MAX_MCP_DESCRIPTION_LENGTH default); a session
|
|
20
|
-
//
|
|
21
|
-
//
|
|
19
|
+
// them "… [truncated]" (its CLAUDE_CODE_MAX_MCP_DESCRIPTION_LENGTH default); a real session got its handshake cut that
|
|
20
|
+
// way, the last agent cards lost. No client cut a shorter one, so the hook's text keeps to the same budget, and the
|
|
21
|
+
// handshake to what is left of it after the server's own instructions (mcp-stdio.mjs).
|
|
22
22
|
export const HANDSHAKE_LIMIT = 4_096;
|
|
23
23
|
// Each list names this many before saying how many more list_tasks has.
|
|
24
24
|
const LISTED = 5;
|
package/lib/ocr.mjs
CHANGED
|
@@ -197,12 +197,12 @@ function regions(map, width, height) {
|
|
|
197
197
|
return boxes;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
// The detector's memory grows with its input (about 1 KB a pixel: 1.6 GB for a 2048x1280 screenshot,
|
|
201
|
-
//
|
|
202
|
-
//
|
|
203
|
-
//
|
|
204
|
-
//
|
|
205
|
-
//
|
|
200
|
+
// The detector's memory grows with its input (measured at about 1 KB a pixel: 1.6 GB for a 2048x1280 screenshot), and
|
|
201
|
+
// ONNX Runtime keeps memory for every input shape it has run. So the detector reads full-width bands WINDOW rows tall,
|
|
202
|
+
// always the same shape (rows past the image and columns up to a multiple of 512 repeat its edge), and the probability
|
|
203
|
+
// map is stitched from rows at least MARGIN from a band's edge. Lines are never cut: regions are found on the whole
|
|
204
|
+
// map. On a fixed set of test screenshots this found what one pass did, and the OCR models' memory levelled off at
|
|
205
|
+
// 544 MB instead of growing past 2 GB (160-row bands; 256 rows: 766 MB and about 10% faster).
|
|
206
206
|
const BAND = 160,
|
|
207
207
|
MARGIN = 32,
|
|
208
208
|
WINDOW = BAND + 2 * MARGIN;
|
|
@@ -262,9 +262,9 @@ async function detect(image, { ort, graph }) {
|
|
|
262
262
|
.filter(([x0, y0, x1, y1]) => x1 - x0 >= 4 && y1 - y0 >= 4);
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
-
// ONNX Runtime keeps memory for every input shape it has run (400 crop widths: 108 MB grew to 513 MB,
|
|
266
|
-
//
|
|
267
|
-
//
|
|
265
|
+
// ONNX Runtime keeps memory for every input shape it has run (400 crop widths: 108 MB grew to 513 MB), so crops are
|
|
266
|
+
// padded on the right to a few widths, with 0 after normalization as PaddleOCR's own batches pad. Over the same test
|
|
267
|
+
// screenshots, that changed 16 of 845 lines, by spacing or a dash, none of a planted value.
|
|
268
268
|
const bucket = (width) =>
|
|
269
269
|
width <= 512 ? Math.ceil(width / 32) * 32 : Math.ceil(width / 64) * 64;
|
|
270
270
|
|