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/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { spawn } from "node:child_process";
|
|
2
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
@@ -19,12 +19,14 @@ import {
|
|
|
19
19
|
removeAgent,
|
|
20
20
|
showLineup,
|
|
21
21
|
setupChosen,
|
|
22
|
+
setupElsewhere,
|
|
22
23
|
setupT3,
|
|
23
24
|
setupSwarm,
|
|
24
25
|
testAgent,
|
|
25
26
|
walkThrough,
|
|
26
27
|
} from "./lib/onboard.mjs";
|
|
27
28
|
import { agentsHere, createLineup, lineupOf } from "./lib/lineup.mjs";
|
|
29
|
+
import { confirmAgentBinary } from "./lib/agentBinaries.mjs";
|
|
28
30
|
import { CHECKABLE, createAgentReadiness } from "./lib/readiness.mjs";
|
|
29
31
|
import { writeBrowserOffer } from "./lib/phones.mjs";
|
|
30
32
|
import { createUi } from "./lib/ui.mjs";
|
|
@@ -32,6 +34,7 @@ import { backupCommand, offerBackup } from "./lib/backupSetup.mjs";
|
|
|
32
34
|
import pc from "picocolors";
|
|
33
35
|
import { removeLocalWakes } from "./lib/wakes.mjs";
|
|
34
36
|
import { detectAgents } from "./lib/commands.mjs";
|
|
37
|
+
import { nameOf } from "./lib/members.mjs";
|
|
35
38
|
import { daemonRequest } from "./lib/control-client.mjs";
|
|
36
39
|
import { ensureDir, readJson, writeJsonAtomic } from "./lib/files.mjs";
|
|
37
40
|
import { hostApp, processTable } from "./lib/live.mjs";
|
|
@@ -40,12 +43,20 @@ import { paths } from "./lib/paths.mjs";
|
|
|
40
43
|
import {
|
|
41
44
|
joinSwarm,
|
|
42
45
|
keepJoinCode,
|
|
46
|
+
setupPageUrl,
|
|
43
47
|
startPairing,
|
|
44
48
|
waitForApproval,
|
|
45
49
|
} from "./lib/pairing.mjs";
|
|
46
50
|
import { setupProfile } from "./lib/profile.mjs";
|
|
47
51
|
import { cloudEnroll } from "./lib/cloudBoot.mjs";
|
|
48
|
-
import {
|
|
52
|
+
import { ownPublicKey, sshCommand } from "./lib/cloudSsh.mjs";
|
|
53
|
+
import {
|
|
54
|
+
checkRuntime,
|
|
55
|
+
currentRuntime,
|
|
56
|
+
fetchRelease,
|
|
57
|
+
installRuntime,
|
|
58
|
+
relayCommand,
|
|
59
|
+
} from "./lib/runtime-install.mjs";
|
|
49
60
|
import { installNativeHost, removeNativeHost } from "./lib/nativeHost.mjs";
|
|
50
61
|
import { CORE, coreSizeMb } from "./lib/coreModels.mjs";
|
|
51
62
|
import { MODELS, modelsPresent } from "./lib/localmodels.mjs";
|
|
@@ -152,11 +163,11 @@ const canOpenBrowser = () =>
|
|
|
152
163
|
Boolean(process.env.DISPLAY || process.env.WAYLAND_DISPLAY));
|
|
153
164
|
|
|
154
165
|
// One page in the browser approves this computer and links that browser to it in the same click: the address fragment,
|
|
155
|
-
// which no server sees, carries the
|
|
166
|
+
// which no server sees, carries the approval (never the code, which is also the join secret) and a browser link setup
|
|
167
|
+
// made for the daemon (phones.mjs, pairing.mjs setupPageUrl).
|
|
156
168
|
async function pair(pairOrigin, agents, ui) {
|
|
157
169
|
const { pairId, code, own } = await startPairing(pairOrigin, agents);
|
|
158
170
|
if (own) keepJoinCode(paths.machine, code);
|
|
159
|
-
const page = `${pairOrigin}/pair`;
|
|
160
171
|
const browser = own && canOpenBrowser();
|
|
161
172
|
const link = browser
|
|
162
173
|
? await writeBrowserOffer({
|
|
@@ -165,10 +176,14 @@ async function pair(pairOrigin, agents, ui) {
|
|
|
165
176
|
})
|
|
166
177
|
: null;
|
|
167
178
|
const opened =
|
|
168
|
-
browser && openUrl(
|
|
179
|
+
browser && openUrl(await setupPageUrl(pairOrigin, { code, own }, link));
|
|
180
|
+
// With no browser here, the person opens the approval link on another computer: setup's code itself is typed only
|
|
181
|
+
// into Harness on one of their own computers, never into a web page.
|
|
169
182
|
const approve = opened
|
|
170
183
|
? "Your browser just opened. Sign in with your email if it asks, then press Connect. No account yet? Signing in makes one."
|
|
171
|
-
:
|
|
184
|
+
: own
|
|
185
|
+
? `Open this link in a browser, sign in with your email, and press Connect. No account yet? Signing in makes one.\n${await setupPageUrl(pairOrigin, { code, own })}`
|
|
186
|
+
: `Open ${pairOrigin}/pair in a browser, sign in with your email, and enter this code. No account yet? Signing in makes one.`;
|
|
172
187
|
const elsewhere = own
|
|
173
188
|
? "\nAlready use Harness on another computer? Click the Harness icon in its menu bar, choose Add a Computer, and type this code there instead."
|
|
174
189
|
: "";
|
|
@@ -206,12 +221,18 @@ async function waitForDaemon(timeoutMs = 12_000) {
|
|
|
206
221
|
await new Promise((resolve) => setTimeout(resolve, 250));
|
|
207
222
|
}
|
|
208
223
|
throw new Error(
|
|
209
|
-
`daemon started but its authenticated Harness bridge did not become ready: ${lastError?.message || lastStatus?.lastError || "timeout"}. Run:
|
|
224
|
+
`daemon started but its authenticated Harness bridge did not become ready: ${lastError?.message || lastStatus?.lastError || "timeout"}. Run: ${relayCommand()} doctor`
|
|
210
225
|
);
|
|
211
226
|
}
|
|
212
227
|
|
|
213
228
|
async function connect() {
|
|
214
229
|
ensureDir(paths.home);
|
|
230
|
+
// A release this computer's Harness would refuse is refused before pairing or anything else changes.
|
|
231
|
+
checkRuntime({
|
|
232
|
+
sourceRoot: SOURCE_ROOT,
|
|
233
|
+
version: VERSION,
|
|
234
|
+
allowUnsigned: has("--local-build"),
|
|
235
|
+
});
|
|
215
236
|
// The agents installed here (lineup.mjs). Each coding agent gets its one-line prompt now (readiness.mjs), so the
|
|
216
237
|
// answers come in while the person signs in.
|
|
217
238
|
const here = agentsHere();
|
|
@@ -295,9 +316,20 @@ async function connect() {
|
|
|
295
316
|
const runtimeRoot = installRuntime({
|
|
296
317
|
sourceRoot: SOURCE_ROOT,
|
|
297
318
|
version: VERSION,
|
|
319
|
+
allowUnsigned: has("--local-build"),
|
|
298
320
|
});
|
|
299
321
|
const selected = ready.filter((agent) => AGENTS.includes(agent));
|
|
300
322
|
const states = configureAgents({ runtimeRoot, selected });
|
|
323
|
+
// The program each agent runs as, as this terminal finds it: the daemon starts that one and no other
|
|
324
|
+
// (agentBinaries.mjs).
|
|
325
|
+
const moved = selected.flatMap((agent) => {
|
|
326
|
+
const confirmed = confirmAgentBinary(agent);
|
|
327
|
+
return confirmed?.previous
|
|
328
|
+
? [
|
|
329
|
+
`${agent} now runs from ${confirmed.path} (it ran from ${confirmed.previous})`,
|
|
330
|
+
]
|
|
331
|
+
: [];
|
|
332
|
+
});
|
|
301
333
|
const stateMap = Object.fromEntries(
|
|
302
334
|
states.map((state) => [state.agent, state])
|
|
303
335
|
);
|
|
@@ -317,7 +349,7 @@ async function connect() {
|
|
|
317
349
|
installNativeHost({ runtimeRoot });
|
|
318
350
|
} catch (error) {
|
|
319
351
|
ui.warn(
|
|
320
|
-
`The extension cannot find this computer by itself (${error.message}); link the browser with
|
|
352
|
+
`The extension cannot find this computer by itself (${error.message}); link the browser with ${relayCommand()} link`
|
|
321
353
|
);
|
|
322
354
|
}
|
|
323
355
|
try {
|
|
@@ -329,6 +361,7 @@ async function connect() {
|
|
|
329
361
|
spin.stop(
|
|
330
362
|
`Harness is running on this computer ${pc.dim(`· ${service.manager}`)}`
|
|
331
363
|
);
|
|
364
|
+
for (const line of moved) ui.info(line);
|
|
332
365
|
// Harness already runs, so the browser lists the agents while the person tells them who they work for.
|
|
333
366
|
await setupProfile({ ui, origin: pairOrigin, token: config.token });
|
|
334
367
|
const joined = await walkThrough({
|
|
@@ -352,6 +385,12 @@ async function connect() {
|
|
|
352
385
|
daemonRequest,
|
|
353
386
|
ui,
|
|
354
387
|
});
|
|
388
|
+
await setupElsewhere({
|
|
389
|
+
daemonRequest,
|
|
390
|
+
ui,
|
|
391
|
+
fresh: !previous && !before.agentStates,
|
|
392
|
+
removed,
|
|
393
|
+
});
|
|
355
394
|
await setupT3({
|
|
356
395
|
ui,
|
|
357
396
|
daemonRequest,
|
|
@@ -374,7 +413,7 @@ async function connect() {
|
|
|
374
413
|
);
|
|
375
414
|
if (failed.length) {
|
|
376
415
|
throw new Error(
|
|
377
|
-
`setup is incomplete for ${failed.map((state) => state.agent).join(", ")}. Nothing was hidden; run
|
|
416
|
+
`setup is incomplete for ${failed.map((state) => state.agent).join(", ")}. Nothing was hidden; run ${relayCommand()} doctor after fixing the reported CLI error, then rerun setup.`
|
|
378
417
|
);
|
|
379
418
|
}
|
|
380
419
|
// The browser you use Harness in on this computer links to this computer; on an added one it works the board home
|
|
@@ -401,7 +440,9 @@ async function connect() {
|
|
|
401
440
|
);
|
|
402
441
|
}
|
|
403
442
|
} catch (error) {
|
|
404
|
-
ui.warn(
|
|
443
|
+
ui.warn(
|
|
444
|
+
`Browser not linked (${error.message}). Run: ${relayCommand()} link`
|
|
445
|
+
);
|
|
405
446
|
}
|
|
406
447
|
// Last, so nothing else waits on it: an added computer works on its own until its code is typed on home.
|
|
407
448
|
const role = await joinSwarm({ ui, code: setupCode, daemonRequest });
|
|
@@ -429,10 +470,10 @@ async function connect() {
|
|
|
429
470
|
]),
|
|
430
471
|
...(library
|
|
431
472
|
? [
|
|
432
|
-
`Your agents here can search your Desktop, Documents and Downloads. That stays on this computer${process.platform === "darwin" ? ", and your Mac asks you once" : ""}. ${pc.dim(
|
|
473
|
+
`Your agents here can search your Desktop, Documents and Downloads. That stays on this computer${process.platform === "darwin" ? ", and your Mac asks you once" : ""}. ${pc.dim(`Change it: ${relayCommand()} local off`)}`,
|
|
433
474
|
]
|
|
434
475
|
: []),
|
|
435
|
-
`Your coding agents start the tasks you ask for in folders they have worked in, up to 10 a day each. Tasks another agent wrote wait for your Start. ${pc.dim(
|
|
476
|
+
`Your coding agents start the tasks you ask for in folders they have worked in, up to 10 a day each. Tasks another agent wrote wait for your Start. ${pc.dim(`Change it: ${relayCommand()} board standing`)}`,
|
|
436
477
|
].join("\n\n"),
|
|
437
478
|
"Good to know"
|
|
438
479
|
);
|
|
@@ -490,7 +531,7 @@ async function status() {
|
|
|
490
531
|
const machine = current.machine;
|
|
491
532
|
if (machine?.label)
|
|
492
533
|
console.log(
|
|
493
|
-
`this computer: ${machine.label}, ${machine.role === "worker" ? `a worker${machine.home ? ` for ${machine.home.label} (${machine.home.connected ? "online" : "offline"}${machine.home.confirmed ? "" :
|
|
534
|
+
`this computer: ${machine.label}, ${machine.role === "worker" ? `a worker${machine.home ? ` for ${machine.home.label} (${machine.home.connected ? "online" : "offline"}${machine.home.confirmed ? "" : `, not confirmed yet: ${relayCommand()} machines`})` : ""}${machine.waiting ? `, ${machine.waiting} waiting to send` : ""}` : "home, holds the board"}`
|
|
494
535
|
);
|
|
495
536
|
console.log(
|
|
496
537
|
`history: ${current.indexing ? "indexing" : "ready"}${current.lastIndexedAt ? ` · last scan ${current.lastIndexedAt}` : ""}`
|
|
@@ -728,7 +769,7 @@ async function connectAgent() {
|
|
|
728
769
|
const to = String(argv[0] || "");
|
|
729
770
|
if (!/^[a-z0-9][a-z0-9-]{1,19}\/[a-z0-9][a-z0-9._-]{0,63}$/.test(to))
|
|
730
771
|
throw new Error(
|
|
731
|
-
"usage: tryharness connect <handle/agent> --about <text> [--agent <your agent>] [--file <brief.md>]"
|
|
772
|
+
"usage: tryharness connect <handle/agent> --about <text> [--agent <your agent>] [--file <brief.md>] [--readable]"
|
|
732
773
|
);
|
|
733
774
|
const fromAgent = arg("--agent", "claude-code");
|
|
734
775
|
if (!AGENTS.includes(fromAgent))
|
|
@@ -748,6 +789,7 @@ async function connectAgent() {
|
|
|
748
789
|
about,
|
|
749
790
|
brief,
|
|
750
791
|
trustNewKey: has("--trust-new-key"),
|
|
792
|
+
readable: has("--readable"),
|
|
751
793
|
},
|
|
752
794
|
20_000
|
|
753
795
|
);
|
|
@@ -757,25 +799,139 @@ async function connectAgent() {
|
|
|
757
799
|
);
|
|
758
800
|
console.log(
|
|
759
801
|
response.sealed
|
|
760
|
-
? `Sealed end to end to ${to.split("/")[0]}'s computer (key ${response.fingerprint}); Harness carries it and cannot read it. Check the key with them once:
|
|
802
|
+
? `Sealed end to end to ${to.split("/")[0]}'s computer (key ${response.fingerprint}); Harness carries it and cannot read it. Check the key with them once: ${relayCommand()} peers`
|
|
761
803
|
: `Not end to end: ${to.split("/")[0]}'s computer runs a Harness without sealed threads yet, so Harness can read this thread.`
|
|
762
804
|
);
|
|
763
805
|
}
|
|
764
806
|
|
|
807
|
+
// How often `tryharness ssh` asks again while a cloud computer wakes: as often as its card looks while one comes up
|
|
808
|
+
// (CloudComputerCard.tsx QUICK_MS). It waits as long as the wake takes, which is unmeasured; Ctrl-C stops it.
|
|
809
|
+
const SSH_WAKE_LOOK_MS = 3_000;
|
|
810
|
+
|
|
811
|
+
// SSH into one of the person's cloud computers (docs/cloud-swarm.md §7), from one of their own: woken if asleep, their
|
|
812
|
+
// own key allowed on it over the sealed line between their computers, then its address and host key as they are now.
|
|
813
|
+
async function ssh() {
|
|
814
|
+
const dashes = argv.indexOf("--");
|
|
815
|
+
const own = dashes >= 0 ? argv.slice(0, dashes) : argv;
|
|
816
|
+
const remote = dashes >= 0 ? argv.slice(dashes + 1) : [];
|
|
817
|
+
const named = own.find(
|
|
818
|
+
(value, index) => !value.startsWith("-") && own[index - 1] !== "--key"
|
|
819
|
+
);
|
|
820
|
+
const key = ownPublicKey(arg("--key"));
|
|
821
|
+
if (!key)
|
|
822
|
+
throw new Error(
|
|
823
|
+
"No SSH key found in ~/.ssh. Make one with ssh-keygen -t ed25519, or name yours with --key <file>."
|
|
824
|
+
);
|
|
825
|
+
let waking = false;
|
|
826
|
+
for (;;) {
|
|
827
|
+
// No deadline: the wake, the sealed line and the provider's answer are unmeasured.
|
|
828
|
+
const answer = await daemonRequest(
|
|
829
|
+
{
|
|
830
|
+
command: "machines.ssh",
|
|
831
|
+
agent: "user",
|
|
832
|
+
computer: named ?? null,
|
|
833
|
+
key: key.text,
|
|
834
|
+
},
|
|
835
|
+
0
|
|
836
|
+
);
|
|
837
|
+
if (!answer.ok) throw new Error(answer.error || "SSH was refused");
|
|
838
|
+
if (answer.state === "ready" && answer.access) {
|
|
839
|
+
const args = sshCommand({
|
|
840
|
+
access: answer.access,
|
|
841
|
+
computer: answer.computer,
|
|
842
|
+
keyFile: fs.existsSync(key.privateFile) ? key.privateFile : key.file,
|
|
843
|
+
knownHostsDir: path.join(paths.home, "ssh"),
|
|
844
|
+
command: remote,
|
|
845
|
+
});
|
|
846
|
+
if (has("--print")) {
|
|
847
|
+
console.log(["ssh", ...args].map(shellQuote).join(" "));
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
console.log(
|
|
851
|
+
`${answer.computer.label}: your key ${answer.fingerprint} is let in. You work there as the harness user, as your agents do.`
|
|
852
|
+
);
|
|
853
|
+
const session = spawn("ssh", args, { stdio: "inherit" });
|
|
854
|
+
process.exitCode = await new Promise((resolve) =>
|
|
855
|
+
session.on("close", (code) => resolve(code ?? 1))
|
|
856
|
+
);
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
if (!waking)
|
|
860
|
+
console.log(`Waking ${answer.computer?.label ?? "your cloud computer"}…`);
|
|
861
|
+
waking = true;
|
|
862
|
+
await sleep(SSH_WAKE_LOOK_MS);
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
// Words for an agent while it works, by its thread or its run: they go into the thread as your message to it, which
|
|
867
|
+
// steers it (live where it takes words mid-run; otherwise it stops where it is and goes on with them).
|
|
868
|
+
async function steer() {
|
|
869
|
+
const to = arg("--agent");
|
|
870
|
+
const words = argv.filter(
|
|
871
|
+
(value, index, all) =>
|
|
872
|
+
!value.startsWith("--") && all[index - 1] !== "--agent"
|
|
873
|
+
);
|
|
874
|
+
const [id, ...text] = words;
|
|
875
|
+
if (!id || !text.length)
|
|
876
|
+
throw new Error(
|
|
877
|
+
'usage: tryharness steer <thread or run> "<words>" [--agent <agent>]'
|
|
878
|
+
);
|
|
879
|
+
const answer = await daemonRequest(
|
|
880
|
+
{
|
|
881
|
+
command: "board.swarm.steer",
|
|
882
|
+
agent: "user",
|
|
883
|
+
id,
|
|
884
|
+
text: text.join(" "),
|
|
885
|
+
...(to ? { to } : {}),
|
|
886
|
+
},
|
|
887
|
+
// Into a turn T3 Code carries the words wait for T3's answer, which has no measured deadline either.
|
|
888
|
+
0
|
|
889
|
+
);
|
|
890
|
+
if (!answer.ok)
|
|
891
|
+
throw new Error(
|
|
892
|
+
answer.code === "not_allowed"
|
|
893
|
+
? `${answer.error} Steer from one of your own computers, PiP or your phone.`
|
|
894
|
+
: answer.error || "the steer was not sent"
|
|
895
|
+
);
|
|
896
|
+
console.log(answer.note);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
// What the agents on this computer are running now, with what to type to follow or steer each.
|
|
900
|
+
async function runs() {
|
|
901
|
+
const answer = await daemonRequest({ command: "runs.here", agent: "user" });
|
|
902
|
+
if (!answer.ok) throw new Error(answer.error || "runs unavailable");
|
|
903
|
+
if (!answer.runs.length) {
|
|
904
|
+
console.log("Nothing is running on this computer now.");
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
for (const run of answer.runs)
|
|
908
|
+
console.log(
|
|
909
|
+
`${run.runId} ${nameOf(run.agent)} since ${new Date(run.startedAt).toLocaleTimeString()} ${run.title}${run.cwd ? `\n in ${run.cwd}` : ""}`
|
|
910
|
+
);
|
|
911
|
+
console.log(
|
|
912
|
+
`\nFollow one: ${relayCommand()} task <run> --follow\nSteer one: ${relayCommand()} steer <run> "<words>"`
|
|
913
|
+
);
|
|
914
|
+
}
|
|
915
|
+
|
|
765
916
|
// The person's own computers: which one holds the board (home), the others that work through it, and the join code a
|
|
766
917
|
// new one shows until the person types it on home.
|
|
767
918
|
async function machines() {
|
|
768
919
|
const sub = argv[0];
|
|
769
920
|
if (sub === "add" || sub === "confirm") {
|
|
921
|
+
// --hosted: a computer the person does not drive from (a cloud computer): agents only, never acting as the person.
|
|
770
922
|
const response = await daemonRequest(
|
|
771
|
-
{
|
|
923
|
+
{
|
|
924
|
+
command: "machines.add",
|
|
925
|
+
code: String(argv.slice(1).find((arg) => !arg.startsWith("--")) || ""),
|
|
926
|
+
hosted: argv.includes("--hosted"),
|
|
927
|
+
},
|
|
772
928
|
30_000
|
|
773
929
|
);
|
|
774
930
|
if (!response.ok) throw new Error(response.error || "not added");
|
|
775
931
|
if (response.state === "approved") console.log(response.note);
|
|
776
932
|
else if (response.state === "waiting")
|
|
777
933
|
console.log(
|
|
778
|
-
`${response.machine || "The computer"} is connected to your account. It joins your swarm by itself as soon as it is online;
|
|
934
|
+
`${response.machine || "The computer"} is connected to your account. It joins your swarm by itself as soon as it is online; ${relayCommand()} machines shows when it has.`
|
|
779
935
|
);
|
|
780
936
|
else
|
|
781
937
|
console.log(
|
|
@@ -792,17 +948,50 @@ async function machines() {
|
|
|
792
948
|
console.log(`This computer is now called ${response.label}.`);
|
|
793
949
|
return;
|
|
794
950
|
}
|
|
951
|
+
if (sub === "remove") {
|
|
952
|
+
const computer = argv.slice(1).join(" ").trim();
|
|
953
|
+
if (!computer) throw new Error("usage: tryharness machines remove <name>");
|
|
954
|
+
const response = await daemonRequest(
|
|
955
|
+
{ command: "machines.remove", agent: "user", computer },
|
|
956
|
+
20_000
|
|
957
|
+
);
|
|
958
|
+
if (!response.ok) throw new Error(response.error || "not removed");
|
|
959
|
+
console.log(
|
|
960
|
+
`${computer} is off your swarm: this computer no longer trusts it, and your other computers hear so from here.${response.note ? ` ${response.note}` : ""}`
|
|
961
|
+
);
|
|
962
|
+
return;
|
|
963
|
+
}
|
|
795
964
|
if (sub === "home") {
|
|
796
|
-
|
|
965
|
+
// `machines home <name>` makes another of the person's computers home, as the buddy's Make Home does.
|
|
966
|
+
const name = argv.slice(1).join(" ").trim();
|
|
967
|
+
let computer = null;
|
|
968
|
+
if (name) {
|
|
969
|
+
const listed = await daemonRequest({ command: "machines.list" });
|
|
970
|
+
const found = (listed.machines ?? []).find(
|
|
971
|
+
(machine) => machine.label === name || machine.id === name
|
|
972
|
+
);
|
|
973
|
+
if (!found && listed.self?.label !== name)
|
|
974
|
+
throw new Error(`no computer of yours is called ${name}`);
|
|
975
|
+
computer = found?.id ?? null;
|
|
976
|
+
}
|
|
977
|
+
const response = await daemonRequest(
|
|
978
|
+
{
|
|
979
|
+
command: "machines.home",
|
|
980
|
+
...(computer ? { computer, agent: "user" } : {}),
|
|
981
|
+
},
|
|
982
|
+
20_000
|
|
983
|
+
);
|
|
797
984
|
if (!response.ok) throw new Error(response.error || "not moved");
|
|
798
985
|
console.log(
|
|
799
|
-
|
|
986
|
+
computer
|
|
987
|
+
? `${name} is home now: it holds the board from here on.`
|
|
988
|
+
: "This computer is home now: it holds the board from here on. What the computer that was home has and this one does not comes here once it is back."
|
|
800
989
|
);
|
|
801
990
|
return;
|
|
802
991
|
}
|
|
803
992
|
if (sub)
|
|
804
993
|
throw new Error(
|
|
805
|
-
"usage: tryharness machines [add <code> | name <name> | home]"
|
|
994
|
+
"usage: tryharness machines [add <code> [--hosted] | name <name> | home [<computer>] | remove <name>]"
|
|
806
995
|
);
|
|
807
996
|
const response = await daemonRequest({ command: "machines.list" });
|
|
808
997
|
if (!response.ok)
|
|
@@ -814,7 +1003,7 @@ async function machines() {
|
|
|
814
1003
|
if (joinCode) {
|
|
815
1004
|
const home = response.machines.find((machine) => machine.role === "home");
|
|
816
1005
|
console.log(
|
|
817
|
-
`Join code: ${joinCode}\nOn your home computer${home?.label ? ` (${home.label})` : ""}, choose Add a Computer in the Harness menu and type it, or run:
|
|
1006
|
+
`Join code: ${joinCode}\nOn your home computer${home?.label ? ` (${home.label})` : ""}, choose Add a Computer in the Harness menu and type it, or run: ${relayCommand()} machines add ${joinCode}. What this computer does meanwhile goes there when it joins.`
|
|
818
1007
|
);
|
|
819
1008
|
}
|
|
820
1009
|
if (!response.machines.length) {
|
|
@@ -963,7 +1152,7 @@ async function board() {
|
|
|
963
1152
|
);
|
|
964
1153
|
else if (runWorkspace)
|
|
965
1154
|
console.log(
|
|
966
|
-
`Task ${response.task.id} is on the board and ${target} will run it in ${runWorkspace}. Follow it:
|
|
1155
|
+
`Task ${response.task.id} is on the board and ${target} will run it in ${runWorkspace}. Follow it: ${relayCommand()} task ${response.task.id} --follow`
|
|
967
1156
|
);
|
|
968
1157
|
else
|
|
969
1158
|
console.log(
|
|
@@ -1069,7 +1258,7 @@ async function board() {
|
|
|
1069
1258
|
response.retrieval === "vectors"
|
|
1070
1259
|
? "meaning"
|
|
1071
1260
|
: response.embedder === "absent"
|
|
1072
|
-
?
|
|
1261
|
+
? `words (the local models are not downloaded yet; run ${relayCommand()})`
|
|
1073
1262
|
: `words (${response.context?.embedded ?? 0} of ${response.context?.total ?? 0} entries embedded so far)`;
|
|
1074
1263
|
console.log(
|
|
1075
1264
|
`${response.entries.length} result${response.entries.length === 1 ? "" : "s"} by ${how}`
|
|
@@ -1126,7 +1315,7 @@ async function board() {
|
|
|
1126
1315
|
for (const rule of response.standing) {
|
|
1127
1316
|
if (rule.mode === "off") {
|
|
1128
1317
|
console.log(
|
|
1129
|
-
`${rule.agent} waits for your Start. Turn it on:
|
|
1318
|
+
`${rule.agent} waits for your Start. Turn it on: ${relayCommand()} board standing ${rule.agent} on`
|
|
1130
1319
|
);
|
|
1131
1320
|
continue;
|
|
1132
1321
|
}
|
|
@@ -1137,7 +1326,7 @@ async function board() {
|
|
|
1137
1326
|
: "in folders you have used it in (none yet)"
|
|
1138
1327
|
: `in ${rule.workspaces.join(", ")}`;
|
|
1139
1328
|
console.log(
|
|
1140
|
-
`${rule.agent} starts tasks from you or Harness without asking, ${where}; ${rule.runs_today} of ${rule.daily_cap} today. Turn it off:
|
|
1329
|
+
`${rule.agent} starts tasks from you or Harness without asking, ${where}; ${rule.runs_today} of ${rule.daily_cap} today. Turn it off: ${relayCommand()} board standing ${rule.agent} off`
|
|
1141
1330
|
);
|
|
1142
1331
|
}
|
|
1143
1332
|
return;
|
|
@@ -1152,7 +1341,7 @@ async function board() {
|
|
|
1152
1341
|
if (!response.ok) throw new Error(response.error || `${sub} failed`);
|
|
1153
1342
|
console.log(
|
|
1154
1343
|
sub === "run"
|
|
1155
|
-
? `Run authorized; ${response.task.target_agent} starts it now. Follow it:
|
|
1344
|
+
? `Run authorized; ${response.task.target_agent} starts it now. Follow it: ${relayCommand()} task ${id} --follow`
|
|
1156
1345
|
: `Task ${id} is open again.`
|
|
1157
1346
|
);
|
|
1158
1347
|
return;
|
|
@@ -1164,8 +1353,8 @@ async function board() {
|
|
|
1164
1353
|
if (!id || id.startsWith("--"))
|
|
1165
1354
|
throw new Error("usage: tryharness board brief <task id> [--dry-run]");
|
|
1166
1355
|
const dryRun = has("--dry-run");
|
|
1167
|
-
// A dry run does what a run's start does before its agent starts. Measured on
|
|
1168
|
-
//
|
|
1356
|
+
// A dry run does what a run's start does before its agent starts. Measured on one daemon's log over seven weeks of
|
|
1357
|
+
// real use: context packs took up to 7,349 ms (215 packs, median 859), task frames up to 875 ms (216, median
|
|
1169
1358
|
// 230); claude-mem is cut off at 2,000 ms (CLAUDE_MEM_TIMEOUT_MS); reading the largest session file here (147 MB)
|
|
1170
1359
|
// took 499 ms. That is 10.7 s at worst; the deadline gives it over twice that, for a session the relay must index
|
|
1171
1360
|
// first (not measured).
|
|
@@ -1241,7 +1430,7 @@ async function board() {
|
|
|
1241
1430
|
);
|
|
1242
1431
|
if (t.run_workspace)
|
|
1243
1432
|
console.log(
|
|
1244
|
-
`run: ${t.run_authorized_at ? `authorized by ${t.run_authorized_by}` :
|
|
1433
|
+
`run: ${t.run_authorized_at ? `authorized by ${t.run_authorized_by}` : `requested, waiting for: ${relayCommand()} board run ` + t.id} · ${t.run_workspace}${t.session_id ? `\nagent session: ${t.session_id}\nopen live session: ${resumeCommand(t.target_agent, t.session_id, t.run_workspace)}` : ""}\n`
|
|
1245
1434
|
);
|
|
1246
1435
|
if (t.brief) console.log(t.brief + "\n");
|
|
1247
1436
|
if (t.result)
|
|
@@ -1359,7 +1548,7 @@ async function goal() {
|
|
|
1359
1548
|
if (!response.ok) throw new Error(response.error || "the goal was not set");
|
|
1360
1549
|
const g = response.task;
|
|
1361
1550
|
console.log(
|
|
1362
|
-
`Goal ${g.id} is set. ${g.goal.facilitator} facilitates; the team is ${g.goal.team.join(", ")}${g.goal.workspace ? `; coding agents work in ${g.goal.workspace}` : ""}. Follow it:
|
|
1551
|
+
`Goal ${g.id} is set. ${g.goal.facilitator} facilitates; the team is ${g.goal.team.join(", ")}${g.goal.workspace ? `; coding agents work in ${g.goal.workspace}` : ""}. Follow it: ${relayCommand()} goal show ${g.id}`
|
|
1363
1552
|
);
|
|
1364
1553
|
return;
|
|
1365
1554
|
}
|
|
@@ -1401,7 +1590,13 @@ async function goal() {
|
|
|
1401
1590
|
}
|
|
1402
1591
|
if (sub === "invite") {
|
|
1403
1592
|
const response = await daemonRequest(
|
|
1404
|
-
{
|
|
1593
|
+
{
|
|
1594
|
+
command: "board.goal.invite",
|
|
1595
|
+
agent,
|
|
1596
|
+
id,
|
|
1597
|
+
to: String(argv[2] || ""),
|
|
1598
|
+
readable: has("--readable"),
|
|
1599
|
+
},
|
|
1405
1600
|
20_000
|
|
1406
1601
|
);
|
|
1407
1602
|
if (!response.ok)
|
|
@@ -1486,8 +1681,6 @@ async function swarm() {
|
|
|
1486
1681
|
const sub = argv[0] || "rounds";
|
|
1487
1682
|
if (sub === "coordinator") {
|
|
1488
1683
|
const mode = argv[1];
|
|
1489
|
-
if (mode && mode !== "harness" && mode !== "local")
|
|
1490
|
-
throw new Error("usage: tryharness swarm coordinator [harness|local]");
|
|
1491
1684
|
const response = await daemonRequest({
|
|
1492
1685
|
command: "board.swarm.coordinator",
|
|
1493
1686
|
agent: "user",
|
|
@@ -1499,9 +1692,13 @@ async function swarm() {
|
|
|
1499
1692
|
);
|
|
1500
1693
|
console.log(
|
|
1501
1694
|
response.mode === "local"
|
|
1502
|
-
?
|
|
1503
|
-
: "Threads are coordinated by Harness: each round sends the thread's newest posts and its options to Harness, which decides and words the next step."
|
|
1695
|
+
? `Threads are coordinated by ${response.pick ? `${nameOf(response.pick)}, on this computer with its tools off` : "an agent on this computer with its tools off"}; nothing in them goes to Harness.`
|
|
1696
|
+
: "Threads are coordinated by Harness: each round sends the thread's newest posts and its options to Harness, which decides and words the next step. This computer reads what it decided before an agent works on it."
|
|
1504
1697
|
);
|
|
1698
|
+
if (!mode)
|
|
1699
|
+
console.log(
|
|
1700
|
+
`To change it: tryharness swarm coordinator ${["harness", ...response.choices].join(" | ")}`
|
|
1701
|
+
);
|
|
1505
1702
|
return;
|
|
1506
1703
|
}
|
|
1507
1704
|
if (sub === "rounds") {
|
|
@@ -1757,9 +1954,9 @@ function logs() {
|
|
|
1757
1954
|
);
|
|
1758
1955
|
}
|
|
1759
1956
|
|
|
1760
|
-
// A cloud computer's daemon
|
|
1761
|
-
//
|
|
1762
|
-
//
|
|
1957
|
+
// A cloud computer's daemon, run by the harness-cloud service as the harness user once cloud-enroll has written its
|
|
1958
|
+
// config: the agents the boot script installed are connected to the swarm the first time, as setup connects them, and
|
|
1959
|
+
// then the daemon runs from the installed package itself.
|
|
1763
1960
|
async function cloudStart() {
|
|
1764
1961
|
const config = readJson(paths.config, {});
|
|
1765
1962
|
if (!config.cloud || !config.token)
|
|
@@ -1783,6 +1980,8 @@ async function cloudStart() {
|
|
|
1783
1980
|
// and keeps what is the person's, their board, history and keys, unless they ask for everything.
|
|
1784
1981
|
const downloadedParts = () => [
|
|
1785
1982
|
paths.runtime,
|
|
1983
|
+
// The installed command (runtime-install.mjs), which runs the runtime above.
|
|
1984
|
+
path.join(paths.home, "bin"),
|
|
1786
1985
|
paths.models,
|
|
1787
1986
|
path.join(paths.home, "local"),
|
|
1788
1987
|
];
|
|
@@ -1825,7 +2024,7 @@ async function uninstall() {
|
|
|
1825
2024
|
fs.rmSync(target, { recursive: true, force: true });
|
|
1826
2025
|
} catch {}
|
|
1827
2026
|
// The pairing goes; the person's choices stay (who is in their swarm, who they took out), so setting up again
|
|
1828
|
-
// keeps their swarm (
|
|
2027
|
+
// keeps their swarm (a reinstall once came back without Bankr, Quotient, Grok Bot and Muse).
|
|
1829
2028
|
if (!everything) {
|
|
1830
2029
|
const { token: _token, ...choices } = readJson(paths.config, {});
|
|
1831
2030
|
if (Object.keys(choices).length) writeJsonAtomic(paths.config, choices);
|
|
@@ -1844,7 +2043,7 @@ async function uninstall() {
|
|
|
1844
2043
|
console.log(
|
|
1845
2044
|
`Harness is uninstalled: the app, its background service and its setup in your agents are gone.\n` +
|
|
1846
2045
|
`Your board, history and keys are kept in ${shown} (${megabytes(folderBytes(paths.home))}), so setting Harness up again picks up where you left off.\n` +
|
|
1847
|
-
`To delete them too:
|
|
2046
|
+
`To delete them too: ${relayCommand()} uninstall --everything`
|
|
1848
2047
|
);
|
|
1849
2048
|
}
|
|
1850
2049
|
|
|
@@ -2020,6 +2219,19 @@ async function agents() {
|
|
|
2020
2219
|
process.exitCode = (await removeAgent({ daemonRequest, agent })) ? 0 : 1;
|
|
2021
2220
|
return;
|
|
2022
2221
|
}
|
|
2222
|
+
// The program Harness starts for an agent, confirmed again after the person installed it somewhere new.
|
|
2223
|
+
if (sub === "confirm") {
|
|
2224
|
+
if (!agent) throw new Error("usage: tryharness agents confirm <agent>");
|
|
2225
|
+
const confirmed = confirmAgentBinary(agent);
|
|
2226
|
+
if (!confirmed)
|
|
2227
|
+
throw new Error(
|
|
2228
|
+
`${agent} is not installed where this terminal can find it`
|
|
2229
|
+
);
|
|
2230
|
+
console.log(
|
|
2231
|
+
`Harness starts ${agent} from ${confirmed.path}${confirmed.previous ? ` now, not ${confirmed.previous}` : ""}.`
|
|
2232
|
+
);
|
|
2233
|
+
return;
|
|
2234
|
+
}
|
|
2023
2235
|
if (sub === "test" && agent) {
|
|
2024
2236
|
process.exitCode = (await testAgent({ agent, daemonRequest })) ? 0 : 1;
|
|
2025
2237
|
return;
|
|
@@ -2036,7 +2248,7 @@ async function agents() {
|
|
|
2036
2248
|
);
|
|
2037
2249
|
console.log(
|
|
2038
2250
|
response.text ||
|
|
2039
|
-
|
|
2251
|
+
`No agents in your swarm yet. Set them up: ${relayCommand()} agents`
|
|
2040
2252
|
);
|
|
2041
2253
|
return;
|
|
2042
2254
|
}
|
|
@@ -2094,11 +2306,11 @@ async function agents() {
|
|
|
2094
2306
|
);
|
|
2095
2307
|
else
|
|
2096
2308
|
console.log(
|
|
2097
|
-
` ${entry.models.length} models; list them with:
|
|
2309
|
+
` ${entry.models.length} models; list them with: ${relayCommand()} agents models ${entry.id}`
|
|
2098
2310
|
);
|
|
2099
2311
|
}
|
|
2100
2312
|
console.log(
|
|
2101
|
-
`\nAuto picks by: ${response.routing ?? `${response.defaultRouting} (the default; change it with:
|
|
2313
|
+
`\nAuto picks by: ${response.routing ?? `${response.defaultRouting} (the default; change it with: ${relayCommand()} agents routing "<your words>")`}`
|
|
2102
2314
|
);
|
|
2103
2315
|
return;
|
|
2104
2316
|
}
|
|
@@ -2207,47 +2419,123 @@ async function phone() {
|
|
|
2207
2419
|
);
|
|
2208
2420
|
return;
|
|
2209
2421
|
}
|
|
2422
|
+
// What waits for the person on any of their computers: a Harness page asking to link, or a device Harness linked.
|
|
2423
|
+
// `swarm` is from a daemon that keeps the swarm's list; an older one lists only this computer's asks.
|
|
2424
|
+
const listed = () => daemonRequest({ command: "phone.list" });
|
|
2425
|
+
const swarmOf = (response) =>
|
|
2426
|
+
response.swarm ?? [
|
|
2427
|
+
...(response.asks ?? []).map((ask) => ({
|
|
2428
|
+
...ask,
|
|
2429
|
+
kind: "ask",
|
|
2430
|
+
state: "waiting",
|
|
2431
|
+
})),
|
|
2432
|
+
...(response.phones ?? []).map((p) => ({
|
|
2433
|
+
...p,
|
|
2434
|
+
at: p.paired_at,
|
|
2435
|
+
state: p.revoked_at ? "removed" : "listed",
|
|
2436
|
+
})),
|
|
2437
|
+
];
|
|
2438
|
+
const where = (entry) =>
|
|
2439
|
+
entry.computerLabel ? ` on ${entry.computerLabel}` : "";
|
|
2440
|
+
const pick = (entries, prefix, none) => {
|
|
2441
|
+
const matches = entries.filter((entry) => entry.id.startsWith(prefix));
|
|
2442
|
+
if (matches.length === 1 || (!prefix && matches.length)) return matches[0];
|
|
2443
|
+
throw new Error(
|
|
2444
|
+
matches.length ? "that id matches more than one; type more of it" : none
|
|
2445
|
+
);
|
|
2446
|
+
};
|
|
2447
|
+
if (sub === "allow" || sub === "deny") {
|
|
2448
|
+
const response = await listed();
|
|
2449
|
+
const waiting = swarmOf(response).filter(
|
|
2450
|
+
(entry) => entry.state === "waiting"
|
|
2451
|
+
);
|
|
2452
|
+
if (!waiting.length) {
|
|
2453
|
+
console.log("Nothing is waiting for you on any of your computers.");
|
|
2454
|
+
return;
|
|
2455
|
+
}
|
|
2456
|
+
const entry = pick(
|
|
2457
|
+
waiting,
|
|
2458
|
+
String(argv[1] || ""),
|
|
2459
|
+
"nothing waiting has that id (see: tryharness phone list)"
|
|
2460
|
+
);
|
|
2461
|
+
const answer = await daemonRequest({
|
|
2462
|
+
command: "phone.link.answer",
|
|
2463
|
+
agent: "user",
|
|
2464
|
+
id: entry.id,
|
|
2465
|
+
allow: sub === "allow",
|
|
2466
|
+
});
|
|
2467
|
+
if (!answer.ok) throw new Error(answer.error);
|
|
2468
|
+
const browser = entry.kind === "ask";
|
|
2469
|
+
console.log(
|
|
2470
|
+
sub === "allow"
|
|
2471
|
+
? browser
|
|
2472
|
+
? `${entry.label} links to ${entry.computerLabel ?? "this computer"} now. See your devices: npx tryharness phone list`
|
|
2473
|
+
: `${entry.label}${where(entry)} works now. See your devices: npx tryharness phone list`
|
|
2474
|
+
: browser
|
|
2475
|
+
? `${entry.label} was not linked. Harness pages will not ask again today; npx tryharness link links a browser any time.`
|
|
2476
|
+
: `${entry.label}${where(entry)} is disconnected and never worked.`
|
|
2477
|
+
);
|
|
2478
|
+
return;
|
|
2479
|
+
}
|
|
2210
2480
|
if (sub === "list") {
|
|
2211
|
-
const response = await
|
|
2481
|
+
const response = await listed();
|
|
2212
2482
|
if (!response.ok)
|
|
2213
2483
|
throw new Error(response.error || "the daemon could not list phones");
|
|
2214
|
-
|
|
2484
|
+
const entries = swarmOf(response);
|
|
2485
|
+
for (const entry of entries.filter(
|
|
2486
|
+
(item) => item.kind === "ask" && item.state === "waiting"
|
|
2487
|
+
))
|
|
2488
|
+
console.log(
|
|
2489
|
+
`${entry.label} asks to link to ${entry.computerLabel ?? "this computer"}. Allow it: npx tryharness phone allow ${entry.id.slice(0, 8)} (or deny)`
|
|
2490
|
+
);
|
|
2491
|
+
const devices = entries.filter((item) => item.kind !== "ask");
|
|
2492
|
+
if (!devices.length) {
|
|
2215
2493
|
console.log(
|
|
2216
|
-
|
|
2494
|
+
`Nothing paired. Pair a phone: ${relayCommand()} phone pair; connect a browser: ${relayCommand()} link`
|
|
2217
2495
|
);
|
|
2218
2496
|
return;
|
|
2219
2497
|
}
|
|
2220
|
-
|
|
2498
|
+
const seen = new Map(
|
|
2499
|
+
(response.phones ?? []).map((p) => [p.id, p.last_seen_at])
|
|
2500
|
+
);
|
|
2501
|
+
for (const p of devices)
|
|
2221
2502
|
console.log(
|
|
2222
|
-
`${p.id.slice(0, 8)} ${(p.kind || "phone").padEnd(8)} ${p.label.padEnd(20)}
|
|
2503
|
+
`${p.id.slice(0, 8)} ${(p.kind || "phone").padEnd(8)} ${p.label.padEnd(20)} ${(p.computerLabel ?? "this computer").padEnd(14)} paired ${String(p.at ?? "").slice(0, 10)} ${
|
|
2504
|
+
p.state === "removed"
|
|
2505
|
+
? "disconnected"
|
|
2506
|
+
: p.state === "waiting"
|
|
2507
|
+
? `waits for you: npx tryharness phone allow ${p.id.slice(0, 8)}`
|
|
2508
|
+
: seen.get(p.id)
|
|
2509
|
+
? `last seen ${seen.get(p.id).slice(0, 16).replace("T", " ")}`
|
|
2510
|
+
: p.computerLabel
|
|
2511
|
+
? "linked"
|
|
2512
|
+
: "not used yet"
|
|
2513
|
+
}`
|
|
2223
2514
|
);
|
|
2224
2515
|
return;
|
|
2225
2516
|
}
|
|
2226
2517
|
if (sub === "revoke") {
|
|
2227
2518
|
const prefix = String(argv[1] || "");
|
|
2228
2519
|
if (!prefix) throw new Error("usage: tryharness phone revoke <phone id>");
|
|
2229
|
-
const
|
|
2230
|
-
|
|
2231
|
-
|
|
2520
|
+
const device = pick(
|
|
2521
|
+
swarmOf(await listed()).filter(
|
|
2522
|
+
(entry) => entry.kind !== "ask" && entry.state !== "removed"
|
|
2523
|
+
),
|
|
2524
|
+
prefix,
|
|
2525
|
+
"no phone with that id (see: tryharness phone list)"
|
|
2232
2526
|
);
|
|
2233
|
-
if (matches.length !== 1)
|
|
2234
|
-
throw new Error(
|
|
2235
|
-
matches.length
|
|
2236
|
-
? "that id matches more than one phone; type more of it"
|
|
2237
|
-
: "no phone with that id (see: tryharness phone list)"
|
|
2238
|
-
);
|
|
2239
2527
|
const response = await daemonRequest({
|
|
2240
2528
|
command: "phone.revoke",
|
|
2241
|
-
id:
|
|
2529
|
+
id: device.id,
|
|
2242
2530
|
});
|
|
2243
2531
|
if (!response.ok) throw new Error(response.error);
|
|
2244
2532
|
console.log(
|
|
2245
|
-
`${
|
|
2533
|
+
`${device.label}${where(device)} is disconnected. It can no longer reach ${device.computerLabel ?? "this computer"}.`
|
|
2246
2534
|
);
|
|
2247
2535
|
return;
|
|
2248
2536
|
}
|
|
2249
2537
|
throw new Error(
|
|
2250
|
-
"usage: tryharness phone [pair [--link] | list | revoke <phone id>]"
|
|
2538
|
+
"usage: tryharness phone [pair [--link] | list | allow | deny | revoke <phone id>]"
|
|
2251
2539
|
);
|
|
2252
2540
|
}
|
|
2253
2541
|
|
|
@@ -2348,9 +2636,39 @@ async function t3() {
|
|
|
2348
2636
|
}
|
|
2349
2637
|
}
|
|
2350
2638
|
|
|
2639
|
+
// `tryharness upgrade [version]`: this computer's Harness fetches the release, checks its signature before any of it
|
|
2640
|
+
// runs (runtime-install.mjs fetchRelease), and only then runs that release's setup.
|
|
2641
|
+
function upgrade() {
|
|
2642
|
+
const spec = argv[0] && !argv[0].startsWith("-") ? argv.shift() : "latest";
|
|
2643
|
+
const fetched = fetchRelease({ spec });
|
|
2644
|
+
try {
|
|
2645
|
+
console.log(
|
|
2646
|
+
fetched.trusted
|
|
2647
|
+
? `tryharness ${fetched.version} is signed with Harness's release key (${fetched.key}). Setting it up.`
|
|
2648
|
+
: `tryharness ${fetched.version}: Harness on this computer has no release key yet, so this release is trusted as npm sent it, the way a first install is. Setting it up.`
|
|
2649
|
+
);
|
|
2650
|
+
const setup = spawnSync(
|
|
2651
|
+
process.execPath,
|
|
2652
|
+
[path.join(fetched.root, "cli.mjs"), "setup", ...argv],
|
|
2653
|
+
{ stdio: "inherit" }
|
|
2654
|
+
);
|
|
2655
|
+
process.exitCode = setup.status ?? 1;
|
|
2656
|
+
} finally {
|
|
2657
|
+
fs.rmSync(fetched.dir, { recursive: true, force: true });
|
|
2658
|
+
}
|
|
2659
|
+
}
|
|
2660
|
+
|
|
2661
|
+
// Once Harness is installed, its own command runs the release it checked; npx would fetch npm's newest.
|
|
2662
|
+
function installedLine() {
|
|
2663
|
+
const installed = relayCommand();
|
|
2664
|
+
return installed.startsWith("npx ")
|
|
2665
|
+
? ""
|
|
2666
|
+
: `On this computer, run these as ${installed} <command>: it runs the release this computer checked and installed.\n\n`;
|
|
2667
|
+
}
|
|
2668
|
+
|
|
2351
2669
|
function help() {
|
|
2352
2670
|
console.log(
|
|
2353
|
-
`tryharness ${VERSION}\n\
|
|
2671
|
+
`tryharness ${VERSION}\n\n${installedLine()}Commands:\n tryharness set up everything and start the daemon\n tryharness upgrade [version] fetch a newer release, check it is signed with Harness's release key, then set it up\n tryharness desktop open the Harness desktop app (setup opens it too; --no-desktop skips it)\n tryharness status show daemon, bridge, agent, and index health\n tryharness doctor diagnose the complete connection\n tryharness local [learn] the relay's local models, where they run, what is indexed and the last learning\n tryharness local on|off search over your Desktop, Documents and Downloads by what is in the files (on by default)\n tryharness local add|remove <folder> another folder to search the same way\n tryharness watch [add <name> --run <command> [--every 5m] [--field f | --age f | --count text] [--above n] [--below n] | start <id> | remove <id>]\n watches the relay checks and says out loud only when they are off\n tryharness sync [--agent] rescan local coding history in the background\n tryharness task <id> --follow\n follow a delegated agent run in this terminal\n tryharness runs what your agents are running on this computer now\n tryharness steer <thread or run> "<words>" [--agent <agent>]\n tell an agent something while it works\n tryharness ssh [<cloud computer>] [--key <file>] [--print] [-- <command>]\n SSH into your cloud computer with your own key; it wakes if asleep\n tryharness board [--all] list open work on the machine's task board\n tryharness board post --for <agent> --objective <text> [--file <brief.md>]\n tryharness board show <id>\n tryharness board post --for codex --objective <text> --run --workspace <dir>\n the daemon runs it and reports back on the task\n tryharness board run <id> authorize a run an agent asked for\n tryharness board release <id>\n tryharness board agents when each agent last read the board\n tryharness board --watch follow the board in this terminal\n tryharness notify on|off desktop notifications for what waits on you\n tryharness usage-totals on|off daily counts of your swarm's work, without your account or any text (on by default)\n tryharness board send <task> <message> send a held reply to another person's agent\n tryharness board snippet [<id> share|keep] code an agent elsewhere asked to see; nothing leaves until you share it\n tryharness board auto <task> on|off auto-send replies on that thread\n tryharness board end <task> --outcome <text>\n tryharness board context <task> <query> search everything written about a task\n tryharness goal set --objective <text> [--team a,b] [--workspace <dir>] a goal your agents work together in one room\n tryharness goal [list | show <id> | stop <id> | resume <id>]\n tryharness room <goal> | room post <goal> <text> [--ask agent,agent]\n tryharness swarm rounds [<thread>] what the coordinator saw, chose and cost each round\n tryharness swarm health [<thread>] who decided each day's rounds: Harness, a backup, or no one\n tryharness swarm ceiling <thread> <dollars|off> what a thread may spend of your Harness credits\n tryharness swarm checkin <thread> "<what>" (--in 2h | --at 14:30 | --every 30m | --daily 09:00 [--days mon-fri]) [--wake codex] [--times n] [--until <date>]\n the thread comes back on its own then, waking those agents or its lead\n tryharness swarm checkins [<thread>] [--all] | swarm checkin remove <id>\n tryharness swarm coordinator [harness|local] who coordinates your threads\n tryharness connect <handle/agent> --about <text> ask another person's agent to work an issue with yours, sealed to their computer\n tryharness peers the keys of other people's computers this one has worked with, to compare\n tryharness machines your computers: which holds the board (home) and which work through it; machines add <code> [--hosted] | name <name> | home | remove <name>\n tryharness backup [on | now | restore | off] an encrypted backup of your board, for Residents; only your passphrase opens it\n tryharness agents who is in your swarm, and who can be added\n tryharness agents add [<agent>…] put agents in your swarm; with no name, pick from the ones found here\n tryharness agents remove <agent> take an agent out of your swarm\n tryharness agents confirm <agent> the program Harness starts for an agent, after you install it somewhere new\n tryharness agents setup [<agent>] | agents test <agent> how Harness wakes each agent\n tryharness agents cards what each of your agents is told about the others\n tryharness agents note <agent> <text> [--clear] your own note on an agent's card, told to every other agent\n tryharness lessons [--replaced | --retired] | lessons remove <id> | lessons edit <id> "<text>"\n what your swarm learned from your words, to read, change or take out\n tryharness memory [dream | forget <id> | delete <post id> | back <id>]\n what your swarm keeps from its work, overnight; forget, delete or bring back\n tryharness agents models [<agent>] [--refresh] the models each coding agent lists and the one it runs on\n tryharness agents model <agent> <model> [--effort <level>] | auto | default the model it runs on; auto lets Harness pick per run\n tryharness agents routing "<text>" [--clear] how Auto picks models for your swarm\n tryharness connections on|off outside apps (Gmail, Calendar, Slack, Notion, Linear) for your agents; off by default\n tryharness connections connect apps, choose agent access and review approvals (connections catalog for providers)\n tryharness vault your secrets, kept on this computer: agents use them without seeing them (vault add <name> --hosts <host> | allow <agent> <name> | runs <agent> <name> <VARIABLE> | backup <email> | share <name>)\n tryharness mcp grok-bot print the MCP snippet that puts Grok Bot on the board\n tryharness link connect the browser you use Harness in to this computer, end to end (--print shows the link)\n tryharness phone pair show a QR code that pairs your phone with this computer\n tryharness phone list | revoke <id>\n tryharness t3 approve Harness in T3 Code once, so your messages go into its threads (t3 status | t3 forget)\n tryharness logs [--follow]\n tryharness uninstall [--everything] take Harness off this computer; --everything also deletes your board and history\n`
|
|
2354
2672
|
);
|
|
2355
2673
|
}
|
|
2356
2674
|
|
|
@@ -2392,7 +2710,7 @@ try {
|
|
|
2392
2710
|
});
|
|
2393
2711
|
console.log(
|
|
2394
2712
|
on
|
|
2395
|
-
?
|
|
2713
|
+
? `Apps are on. Connect one with ${relayCommand()} connections add; agents see them in sessions they start from now on.`
|
|
2396
2714
|
: "Apps are off. No agent can use a connected app until you turn them on again."
|
|
2397
2715
|
);
|
|
2398
2716
|
} else if (command === "connections") {
|
|
@@ -2411,6 +2729,9 @@ try {
|
|
|
2411
2729
|
else if (command === "t3") await t3();
|
|
2412
2730
|
else if (command === "peers") await peers();
|
|
2413
2731
|
else if (command === "machines") await machines();
|
|
2732
|
+
else if (command === "ssh") await ssh();
|
|
2733
|
+
else if (command === "steer") await steer();
|
|
2734
|
+
else if (command === "runs") await runs();
|
|
2414
2735
|
else if (command === "backup")
|
|
2415
2736
|
await backupCommand({ argv, ui: createUi(), daemonRequest });
|
|
2416
2737
|
else if (command === "connect") await connectAgent();
|
|
@@ -2425,6 +2746,7 @@ try {
|
|
|
2425
2746
|
await startDaemon();
|
|
2426
2747
|
} else if (command === "cloud-enroll") await cloudEnroll();
|
|
2427
2748
|
else if (command === "cloud-start") await cloudStart();
|
|
2749
|
+
else if (command === "upgrade") upgrade();
|
|
2428
2750
|
else if (command === "version") console.log(VERSION);
|
|
2429
2751
|
else if (["help", "--help", "-h"].includes(command)) help();
|
|
2430
2752
|
else throw new Error(`unknown command '${command}' (run: tryharness help)`);
|