tryharness 0.7.54 → 0.7.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -16
- package/cli.mjs +377 -62
- package/lib/activity.mjs +10 -10
- package/lib/adapters.mjs +16 -0
- package/lib/agentBinaries.mjs +71 -0
- package/lib/agentRuntimeConfig.mjs +1 -1
- package/lib/agentRuntimes.mjs +9 -3
- package/lib/agentSignIn.mjs +271 -41
- package/lib/answers.mjs +5 -5
- package/lib/archetypes.d.ts +64 -0
- package/lib/archetypes.js +989 -0
- package/lib/asks.mjs +4 -4
- package/lib/audit.mjs +36 -13
- package/lib/backupSetup.mjs +4 -2
- package/lib/boardAccess.mjs +17 -11
- package/lib/boardBackup.mjs +6 -6
- package/lib/boardFileCommands.mjs +6 -6
- package/lib/boardFiles.mjs +13 -12
- package/lib/boardMirror.mjs +82 -47
- package/lib/boardProtocol.json +30 -1
- package/lib/boardWaits.mjs +2 -3
- package/lib/book.mjs +6 -6
- package/lib/bridge.mjs +5 -5
- package/lib/cards.mjs +2 -2
- package/lib/cloudAgents.mjs +216 -0
- package/lib/cloudAi.mjs +1312 -0
- package/lib/cloudAssistants.mjs +242 -0
- package/lib/cloudBoot.mjs +81 -86
- package/lib/cloudSave.mjs +197 -0
- package/lib/cloudSsh.mjs +178 -0
- package/lib/context.mjs +3 -3
- package/lib/contractGate.mjs +34 -12
- package/lib/control-client.mjs +9 -1
- package/lib/controlSocket.mjs +86 -0
- package/lib/coordinator.mjs +103 -101
- package/lib/daemon.mjs +1128 -2865
- package/lib/desk.mjs +7 -6
- package/lib/desktop.mjs +72 -68
- package/lib/directLink.mjs +16 -5
- package/lib/environment.mjs +2 -1
- package/lib/environments.mjs +14 -6
- package/lib/firewall.mjs +9 -9
- package/lib/folders.mjs +18 -14
- package/lib/frames.mjs +2 -3
- package/lib/gitHost.mjs +3 -3
- package/lib/goalCommands.mjs +25 -7
- package/lib/goals.mjs +7 -7
- package/lib/guestRequests.mjs +94 -0
- package/lib/handoffs.mjs +8 -7
- package/lib/handover.mjs +4 -4
- package/lib/harnessModel.mjs +6 -6
- package/lib/harnessOffers.mjs +266 -0
- package/lib/inference.mjs +26 -8
- package/lib/jobAnswers.mjs +190 -0
- package/lib/landed.mjs +1 -1
- package/lib/lane.mjs +42 -11
- package/lib/lessons.mjs +16 -16
- package/lib/library.mjs +3 -3
- package/lib/lineup.mjs +3 -0
- package/lib/linkRelay.mjs +574 -0
- package/lib/localAgentAsk.mjs +74 -0
- package/lib/localStack.mjs +536 -0
- package/lib/localmodels.mjs +6 -4
- package/lib/loopBackstop.mjs +4 -4
- package/lib/machineIdentity.mjs +9 -1
- package/lib/machineRoutes.mjs +181 -2
- package/lib/machineRuns.mjs +76 -1
- package/lib/machineSeal.mjs +39 -12
- package/lib/mcp-stdio.mjs +96 -26
- package/lib/mcpRelay.mjs +1 -1
- package/lib/members.json +13 -0
- package/lib/members.mjs +1 -1
- package/lib/models.mjs +77 -23
- package/lib/museSession.mjs +6 -1
- package/lib/nativeHost.mjs +35 -7
- package/lib/network.mjs +50 -5
- package/lib/notify.mjs +7 -5
- package/lib/nudge.mjs +3 -3
- package/lib/ocr.mjs +9 -9
- package/lib/onboard.mjs +26 -20
- package/lib/oneLine.mjs +7 -7
- package/lib/ownMachines.mjs +928 -149
- package/lib/pairing.mjs +33 -6
- package/lib/paths.mjs +15 -1
- package/lib/peerProcess.mjs +124 -0
- package/lib/personModel.mjs +3 -3
- package/lib/personNotices.mjs +151 -0
- package/lib/phones.mjs +490 -38
- package/lib/placeCommands.mjs +4 -4
- package/lib/places.mjs +70 -2
- package/lib/profile.mjs +67 -14
- package/lib/projectGit.mjs +158 -14
- package/lib/projectPieces.mjs +902 -0
- package/lib/projectSettings.mjs +7 -4
- package/lib/projects.mjs +384 -62
- package/lib/provenance.mjs +5 -1
- package/lib/proxyLinks.mjs +267 -0
- package/lib/reactions.mjs +7 -5
- package/lib/readiness.mjs +12 -7
- package/lib/record.mjs +19 -6
- package/lib/redact.mjs +4 -4
- package/lib/relayLimits.mjs +62 -0
- package/lib/release.mjs +170 -0
- package/lib/releaseKeys.json +6 -0
- package/lib/repoLinks.mjs +4 -4
- package/lib/roomChannels.mjs +24 -0
- package/lib/roomPage.mjs +1 -1
- package/lib/runAuthority.mjs +101 -0
- package/lib/runBrief.mjs +19 -8
- package/lib/runWorker.mjs +14 -5
- package/lib/runner.mjs +215 -25
- package/lib/runtime-install.mjs +143 -9
- package/lib/schedules.mjs +2 -2
- package/lib/screens.mjs +1 -1
- package/lib/sealed.mjs +11 -2
- package/lib/sealedThreads.mjs +671 -0
- package/lib/secretPatterns.json +1 -1
- package/lib/secrets.mjs +4 -4
- package/lib/seen.mjs +6 -6
- package/lib/serverWords.mjs +175 -0
- package/lib/service.mjs +22 -12
- package/lib/sessionControl.mjs +6 -6
- package/lib/specialties.mjs +6 -6
- package/lib/specialtyKeys.js +4 -5
- package/lib/specialtyNotice.mjs +7 -7
- package/lib/specialtySnapshot.mjs +5 -5
- package/lib/speech.mjs +5 -5
- package/lib/store.mjs +140 -39
- package/lib/stuck.mjs +1 -1
- package/lib/swarm.mjs +167 -16
- package/lib/swarmDevices.mjs +319 -0
- package/lib/swarmMemory.mjs +27 -25
- package/lib/t3.mjs +13 -13
- package/lib/taskCommands.mjs +44 -11
- package/lib/taskRooms.mjs +125 -0
- package/lib/taskRuns.mjs +36 -1
- package/lib/team.mjs +41 -18
- package/lib/threadActions.mjs +315 -0
- package/lib/threadAuthority.mjs +101 -0
- package/lib/threadBriefs.mjs +178 -0
- package/lib/threadLine.mjs +2 -2
- package/lib/threadRuns.mjs +138 -43
- package/lib/threadView.mjs +5 -5
- package/lib/usageTotals.mjs +2 -3
- package/lib/vault.mjs +101 -10
- package/lib/vaultCloud.mjs +2 -2
- package/lib/vaultCommands.mjs +15 -6
- package/lib/vaultTools.js +2 -2
- package/lib/verdicts.mjs +328 -0
- package/lib/wakes.mjs +1 -1
- package/lib/watches.mjs +2 -2
- package/lib/windowAsks.mjs +13 -5
- package/lib/worktrees.mjs +112 -18
- package/npm-shrinkwrap.json +1093 -0
- package/package.json +11 -10
- package/release.json +220 -0
package/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";
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
walkThrough,
|
|
26
26
|
} from "./lib/onboard.mjs";
|
|
27
27
|
import { agentsHere, createLineup, lineupOf } from "./lib/lineup.mjs";
|
|
28
|
+
import { confirmAgentBinary } from "./lib/agentBinaries.mjs";
|
|
28
29
|
import { CHECKABLE, createAgentReadiness } from "./lib/readiness.mjs";
|
|
29
30
|
import { writeBrowserOffer } from "./lib/phones.mjs";
|
|
30
31
|
import { createUi } from "./lib/ui.mjs";
|
|
@@ -32,6 +33,7 @@ import { backupCommand, offerBackup } from "./lib/backupSetup.mjs";
|
|
|
32
33
|
import pc from "picocolors";
|
|
33
34
|
import { removeLocalWakes } from "./lib/wakes.mjs";
|
|
34
35
|
import { detectAgents } from "./lib/commands.mjs";
|
|
36
|
+
import { nameOf } from "./lib/members.mjs";
|
|
35
37
|
import { daemonRequest } from "./lib/control-client.mjs";
|
|
36
38
|
import { ensureDir, readJson, writeJsonAtomic } from "./lib/files.mjs";
|
|
37
39
|
import { hostApp, processTable } from "./lib/live.mjs";
|
|
@@ -40,12 +42,20 @@ import { paths } from "./lib/paths.mjs";
|
|
|
40
42
|
import {
|
|
41
43
|
joinSwarm,
|
|
42
44
|
keepJoinCode,
|
|
45
|
+
setupPageUrl,
|
|
43
46
|
startPairing,
|
|
44
47
|
waitForApproval,
|
|
45
48
|
} from "./lib/pairing.mjs";
|
|
46
49
|
import { setupProfile } from "./lib/profile.mjs";
|
|
47
50
|
import { cloudEnroll } from "./lib/cloudBoot.mjs";
|
|
48
|
-
import {
|
|
51
|
+
import { ownPublicKey, sshCommand } from "./lib/cloudSsh.mjs";
|
|
52
|
+
import {
|
|
53
|
+
checkRuntime,
|
|
54
|
+
currentRuntime,
|
|
55
|
+
fetchRelease,
|
|
56
|
+
installRuntime,
|
|
57
|
+
relayCommand,
|
|
58
|
+
} from "./lib/runtime-install.mjs";
|
|
49
59
|
import { installNativeHost, removeNativeHost } from "./lib/nativeHost.mjs";
|
|
50
60
|
import { CORE, coreSizeMb } from "./lib/coreModels.mjs";
|
|
51
61
|
import { MODELS, modelsPresent } from "./lib/localmodels.mjs";
|
|
@@ -152,11 +162,11 @@ const canOpenBrowser = () =>
|
|
|
152
162
|
Boolean(process.env.DISPLAY || process.env.WAYLAND_DISPLAY));
|
|
153
163
|
|
|
154
164
|
// 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
|
|
165
|
+
// which no server sees, carries the approval (never the code, which is also the join secret) and a browser link setup
|
|
166
|
+
// made for the daemon (phones.mjs, pairing.mjs setupPageUrl).
|
|
156
167
|
async function pair(pairOrigin, agents, ui) {
|
|
157
168
|
const { pairId, code, own } = await startPairing(pairOrigin, agents);
|
|
158
169
|
if (own) keepJoinCode(paths.machine, code);
|
|
159
|
-
const page = `${pairOrigin}/pair`;
|
|
160
170
|
const browser = own && canOpenBrowser();
|
|
161
171
|
const link = browser
|
|
162
172
|
? await writeBrowserOffer({
|
|
@@ -165,10 +175,14 @@ async function pair(pairOrigin, agents, ui) {
|
|
|
165
175
|
})
|
|
166
176
|
: null;
|
|
167
177
|
const opened =
|
|
168
|
-
browser && openUrl(
|
|
178
|
+
browser && openUrl(await setupPageUrl(pairOrigin, { code, own }, link));
|
|
179
|
+
// With no browser here, the person opens the approval link on another computer: setup's code itself is typed only
|
|
180
|
+
// into Harness on one of their own computers, never into a web page.
|
|
169
181
|
const approve = opened
|
|
170
182
|
? "Your browser just opened. Sign in with your email if it asks, then press Connect. No account yet? Signing in makes one."
|
|
171
|
-
:
|
|
183
|
+
: own
|
|
184
|
+
? `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 })}`
|
|
185
|
+
: `Open ${pairOrigin}/pair in a browser, sign in with your email, and enter this code. No account yet? Signing in makes one.`;
|
|
172
186
|
const elsewhere = own
|
|
173
187
|
? "\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
188
|
: "";
|
|
@@ -206,12 +220,18 @@ async function waitForDaemon(timeoutMs = 12_000) {
|
|
|
206
220
|
await new Promise((resolve) => setTimeout(resolve, 250));
|
|
207
221
|
}
|
|
208
222
|
throw new Error(
|
|
209
|
-
`daemon started but its authenticated Harness bridge did not become ready: ${lastError?.message || lastStatus?.lastError || "timeout"}. Run:
|
|
223
|
+
`daemon started but its authenticated Harness bridge did not become ready: ${lastError?.message || lastStatus?.lastError || "timeout"}. Run: ${relayCommand()} doctor`
|
|
210
224
|
);
|
|
211
225
|
}
|
|
212
226
|
|
|
213
227
|
async function connect() {
|
|
214
228
|
ensureDir(paths.home);
|
|
229
|
+
// A release this computer's Harness would refuse is refused before pairing or anything else changes.
|
|
230
|
+
checkRuntime({
|
|
231
|
+
sourceRoot: SOURCE_ROOT,
|
|
232
|
+
version: VERSION,
|
|
233
|
+
allowUnsigned: has("--local-build"),
|
|
234
|
+
});
|
|
215
235
|
// The agents installed here (lineup.mjs). Each coding agent gets its one-line prompt now (readiness.mjs), so the
|
|
216
236
|
// answers come in while the person signs in.
|
|
217
237
|
const here = agentsHere();
|
|
@@ -295,9 +315,20 @@ async function connect() {
|
|
|
295
315
|
const runtimeRoot = installRuntime({
|
|
296
316
|
sourceRoot: SOURCE_ROOT,
|
|
297
317
|
version: VERSION,
|
|
318
|
+
allowUnsigned: has("--local-build"),
|
|
298
319
|
});
|
|
299
320
|
const selected = ready.filter((agent) => AGENTS.includes(agent));
|
|
300
321
|
const states = configureAgents({ runtimeRoot, selected });
|
|
322
|
+
// The program each agent runs as, as this terminal finds it: the daemon starts that one and no other
|
|
323
|
+
// (agentBinaries.mjs).
|
|
324
|
+
const moved = selected.flatMap((agent) => {
|
|
325
|
+
const confirmed = confirmAgentBinary(agent);
|
|
326
|
+
return confirmed?.previous
|
|
327
|
+
? [
|
|
328
|
+
`${agent} now runs from ${confirmed.path} (it ran from ${confirmed.previous})`,
|
|
329
|
+
]
|
|
330
|
+
: [];
|
|
331
|
+
});
|
|
301
332
|
const stateMap = Object.fromEntries(
|
|
302
333
|
states.map((state) => [state.agent, state])
|
|
303
334
|
);
|
|
@@ -317,7 +348,7 @@ async function connect() {
|
|
|
317
348
|
installNativeHost({ runtimeRoot });
|
|
318
349
|
} catch (error) {
|
|
319
350
|
ui.warn(
|
|
320
|
-
`The extension cannot find this computer by itself (${error.message}); link the browser with
|
|
351
|
+
`The extension cannot find this computer by itself (${error.message}); link the browser with ${relayCommand()} link`
|
|
321
352
|
);
|
|
322
353
|
}
|
|
323
354
|
try {
|
|
@@ -329,6 +360,7 @@ async function connect() {
|
|
|
329
360
|
spin.stop(
|
|
330
361
|
`Harness is running on this computer ${pc.dim(`· ${service.manager}`)}`
|
|
331
362
|
);
|
|
363
|
+
for (const line of moved) ui.info(line);
|
|
332
364
|
// Harness already runs, so the browser lists the agents while the person tells them who they work for.
|
|
333
365
|
await setupProfile({ ui, origin: pairOrigin, token: config.token });
|
|
334
366
|
const joined = await walkThrough({
|
|
@@ -374,7 +406,7 @@ async function connect() {
|
|
|
374
406
|
);
|
|
375
407
|
if (failed.length) {
|
|
376
408
|
throw new Error(
|
|
377
|
-
`setup is incomplete for ${failed.map((state) => state.agent).join(", ")}. Nothing was hidden; run
|
|
409
|
+
`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
410
|
);
|
|
379
411
|
}
|
|
380
412
|
// The browser you use Harness in on this computer links to this computer; on an added one it works the board home
|
|
@@ -401,7 +433,9 @@ async function connect() {
|
|
|
401
433
|
);
|
|
402
434
|
}
|
|
403
435
|
} catch (error) {
|
|
404
|
-
ui.warn(
|
|
436
|
+
ui.warn(
|
|
437
|
+
`Browser not linked (${error.message}). Run: ${relayCommand()} link`
|
|
438
|
+
);
|
|
405
439
|
}
|
|
406
440
|
// Last, so nothing else waits on it: an added computer works on its own until its code is typed on home.
|
|
407
441
|
const role = await joinSwarm({ ui, code: setupCode, daemonRequest });
|
|
@@ -429,10 +463,10 @@ async function connect() {
|
|
|
429
463
|
]),
|
|
430
464
|
...(library
|
|
431
465
|
? [
|
|
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(
|
|
466
|
+
`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
467
|
]
|
|
434
468
|
: []),
|
|
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(
|
|
469
|
+
`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
470
|
].join("\n\n"),
|
|
437
471
|
"Good to know"
|
|
438
472
|
);
|
|
@@ -490,7 +524,7 @@ async function status() {
|
|
|
490
524
|
const machine = current.machine;
|
|
491
525
|
if (machine?.label)
|
|
492
526
|
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 ? "" :
|
|
527
|
+
`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
528
|
);
|
|
495
529
|
console.log(
|
|
496
530
|
`history: ${current.indexing ? "indexing" : "ready"}${current.lastIndexedAt ? ` · last scan ${current.lastIndexedAt}` : ""}`
|
|
@@ -728,7 +762,7 @@ async function connectAgent() {
|
|
|
728
762
|
const to = String(argv[0] || "");
|
|
729
763
|
if (!/^[a-z0-9][a-z0-9-]{1,19}\/[a-z0-9][a-z0-9._-]{0,63}$/.test(to))
|
|
730
764
|
throw new Error(
|
|
731
|
-
"usage: tryharness connect <handle/agent> --about <text> [--agent <your agent>] [--file <brief.md>]"
|
|
765
|
+
"usage: tryharness connect <handle/agent> --about <text> [--agent <your agent>] [--file <brief.md>] [--readable]"
|
|
732
766
|
);
|
|
733
767
|
const fromAgent = arg("--agent", "claude-code");
|
|
734
768
|
if (!AGENTS.includes(fromAgent))
|
|
@@ -748,6 +782,7 @@ async function connectAgent() {
|
|
|
748
782
|
about,
|
|
749
783
|
brief,
|
|
750
784
|
trustNewKey: has("--trust-new-key"),
|
|
785
|
+
readable: has("--readable"),
|
|
751
786
|
},
|
|
752
787
|
20_000
|
|
753
788
|
);
|
|
@@ -757,25 +792,139 @@ async function connectAgent() {
|
|
|
757
792
|
);
|
|
758
793
|
console.log(
|
|
759
794
|
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:
|
|
795
|
+
? `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
796
|
: `Not end to end: ${to.split("/")[0]}'s computer runs a Harness without sealed threads yet, so Harness can read this thread.`
|
|
762
797
|
);
|
|
763
798
|
}
|
|
764
799
|
|
|
800
|
+
// How often `tryharness ssh` asks again while a cloud computer wakes: as often as its card looks while one comes up
|
|
801
|
+
// (CloudComputerCard.tsx QUICK_MS). It waits as long as the wake takes, which is unmeasured; Ctrl-C stops it.
|
|
802
|
+
const SSH_WAKE_LOOK_MS = 3_000;
|
|
803
|
+
|
|
804
|
+
// SSH into one of the person's cloud computers (docs/cloud-swarm.md §7), from one of their own: woken if asleep, their
|
|
805
|
+
// own key allowed on it over the sealed line between their computers, then its address and host key as they are now.
|
|
806
|
+
async function ssh() {
|
|
807
|
+
const dashes = argv.indexOf("--");
|
|
808
|
+
const own = dashes >= 0 ? argv.slice(0, dashes) : argv;
|
|
809
|
+
const remote = dashes >= 0 ? argv.slice(dashes + 1) : [];
|
|
810
|
+
const named = own.find(
|
|
811
|
+
(value, index) => !value.startsWith("-") && own[index - 1] !== "--key"
|
|
812
|
+
);
|
|
813
|
+
const key = ownPublicKey(arg("--key"));
|
|
814
|
+
if (!key)
|
|
815
|
+
throw new Error(
|
|
816
|
+
"No SSH key found in ~/.ssh. Make one with ssh-keygen -t ed25519, or name yours with --key <file>."
|
|
817
|
+
);
|
|
818
|
+
let waking = false;
|
|
819
|
+
for (;;) {
|
|
820
|
+
// No deadline: the wake, the sealed line and the provider's answer are unmeasured.
|
|
821
|
+
const answer = await daemonRequest(
|
|
822
|
+
{
|
|
823
|
+
command: "machines.ssh",
|
|
824
|
+
agent: "user",
|
|
825
|
+
computer: named ?? null,
|
|
826
|
+
key: key.text,
|
|
827
|
+
},
|
|
828
|
+
0
|
|
829
|
+
);
|
|
830
|
+
if (!answer.ok) throw new Error(answer.error || "SSH was refused");
|
|
831
|
+
if (answer.state === "ready" && answer.access) {
|
|
832
|
+
const args = sshCommand({
|
|
833
|
+
access: answer.access,
|
|
834
|
+
computer: answer.computer,
|
|
835
|
+
keyFile: fs.existsSync(key.privateFile) ? key.privateFile : key.file,
|
|
836
|
+
knownHostsDir: path.join(paths.home, "ssh"),
|
|
837
|
+
command: remote,
|
|
838
|
+
});
|
|
839
|
+
if (has("--print")) {
|
|
840
|
+
console.log(["ssh", ...args].map(shellQuote).join(" "));
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
console.log(
|
|
844
|
+
`${answer.computer.label}: your key ${answer.fingerprint} is let in. You work there as the harness user, as your agents do.`
|
|
845
|
+
);
|
|
846
|
+
const session = spawn("ssh", args, { stdio: "inherit" });
|
|
847
|
+
process.exitCode = await new Promise((resolve) =>
|
|
848
|
+
session.on("close", (code) => resolve(code ?? 1))
|
|
849
|
+
);
|
|
850
|
+
return;
|
|
851
|
+
}
|
|
852
|
+
if (!waking)
|
|
853
|
+
console.log(`Waking ${answer.computer?.label ?? "your cloud computer"}…`);
|
|
854
|
+
waking = true;
|
|
855
|
+
await sleep(SSH_WAKE_LOOK_MS);
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
// Words for an agent while it works, by its thread or its run: they go into the thread as your message to it, which
|
|
860
|
+
// steers it (live where it takes words mid-run; otherwise it stops where it is and goes on with them).
|
|
861
|
+
async function steer() {
|
|
862
|
+
const to = arg("--agent");
|
|
863
|
+
const words = argv.filter(
|
|
864
|
+
(value, index, all) =>
|
|
865
|
+
!value.startsWith("--") && all[index - 1] !== "--agent"
|
|
866
|
+
);
|
|
867
|
+
const [id, ...text] = words;
|
|
868
|
+
if (!id || !text.length)
|
|
869
|
+
throw new Error(
|
|
870
|
+
'usage: tryharness steer <thread or run> "<words>" [--agent <agent>]'
|
|
871
|
+
);
|
|
872
|
+
const answer = await daemonRequest(
|
|
873
|
+
{
|
|
874
|
+
command: "board.swarm.steer",
|
|
875
|
+
agent: "user",
|
|
876
|
+
id,
|
|
877
|
+
text: text.join(" "),
|
|
878
|
+
...(to ? { to } : {}),
|
|
879
|
+
},
|
|
880
|
+
// Into a turn T3 Code carries the words wait for T3's answer, which has no measured deadline either.
|
|
881
|
+
0
|
|
882
|
+
);
|
|
883
|
+
if (!answer.ok)
|
|
884
|
+
throw new Error(
|
|
885
|
+
answer.code === "not_allowed"
|
|
886
|
+
? `${answer.error} Steer from one of your own computers, PiP or your phone.`
|
|
887
|
+
: answer.error || "the steer was not sent"
|
|
888
|
+
);
|
|
889
|
+
console.log(answer.note);
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
// What the agents on this computer are running now, with what to type to follow or steer each.
|
|
893
|
+
async function runs() {
|
|
894
|
+
const answer = await daemonRequest({ command: "runs.here", agent: "user" });
|
|
895
|
+
if (!answer.ok) throw new Error(answer.error || "runs unavailable");
|
|
896
|
+
if (!answer.runs.length) {
|
|
897
|
+
console.log("Nothing is running on this computer now.");
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
for (const run of answer.runs)
|
|
901
|
+
console.log(
|
|
902
|
+
`${run.runId} ${nameOf(run.agent)} since ${new Date(run.startedAt).toLocaleTimeString()} ${run.title}${run.cwd ? `\n in ${run.cwd}` : ""}`
|
|
903
|
+
);
|
|
904
|
+
console.log(
|
|
905
|
+
`\nFollow one: ${relayCommand()} task <run> --follow\nSteer one: ${relayCommand()} steer <run> "<words>"`
|
|
906
|
+
);
|
|
907
|
+
}
|
|
908
|
+
|
|
765
909
|
// The person's own computers: which one holds the board (home), the others that work through it, and the join code a
|
|
766
910
|
// new one shows until the person types it on home.
|
|
767
911
|
async function machines() {
|
|
768
912
|
const sub = argv[0];
|
|
769
913
|
if (sub === "add" || sub === "confirm") {
|
|
914
|
+
// --hosted: a computer the person does not drive from (a cloud computer): agents only, never acting as the person.
|
|
770
915
|
const response = await daemonRequest(
|
|
771
|
-
{
|
|
916
|
+
{
|
|
917
|
+
command: "machines.add",
|
|
918
|
+
code: String(argv.slice(1).find((arg) => !arg.startsWith("--")) || ""),
|
|
919
|
+
hosted: argv.includes("--hosted"),
|
|
920
|
+
},
|
|
772
921
|
30_000
|
|
773
922
|
);
|
|
774
923
|
if (!response.ok) throw new Error(response.error || "not added");
|
|
775
924
|
if (response.state === "approved") console.log(response.note);
|
|
776
925
|
else if (response.state === "waiting")
|
|
777
926
|
console.log(
|
|
778
|
-
`${response.machine || "The computer"} is connected to your account. It joins your swarm by itself as soon as it is online;
|
|
927
|
+
`${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
928
|
);
|
|
780
929
|
else
|
|
781
930
|
console.log(
|
|
@@ -792,17 +941,50 @@ async function machines() {
|
|
|
792
941
|
console.log(`This computer is now called ${response.label}.`);
|
|
793
942
|
return;
|
|
794
943
|
}
|
|
944
|
+
if (sub === "remove") {
|
|
945
|
+
const computer = argv.slice(1).join(" ").trim();
|
|
946
|
+
if (!computer) throw new Error("usage: tryharness machines remove <name>");
|
|
947
|
+
const response = await daemonRequest(
|
|
948
|
+
{ command: "machines.remove", agent: "user", computer },
|
|
949
|
+
20_000
|
|
950
|
+
);
|
|
951
|
+
if (!response.ok) throw new Error(response.error || "not removed");
|
|
952
|
+
console.log(
|
|
953
|
+
`${computer} is off your swarm: this computer no longer trusts it, and your other computers hear so from here.${response.note ? ` ${response.note}` : ""}`
|
|
954
|
+
);
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
795
957
|
if (sub === "home") {
|
|
796
|
-
|
|
958
|
+
// `machines home <name>` makes another of the person's computers home, as the buddy's Make Home does.
|
|
959
|
+
const name = argv.slice(1).join(" ").trim();
|
|
960
|
+
let computer = null;
|
|
961
|
+
if (name) {
|
|
962
|
+
const listed = await daemonRequest({ command: "machines.list" });
|
|
963
|
+
const found = (listed.machines ?? []).find(
|
|
964
|
+
(machine) => machine.label === name || machine.id === name
|
|
965
|
+
);
|
|
966
|
+
if (!found && listed.self?.label !== name)
|
|
967
|
+
throw new Error(`no computer of yours is called ${name}`);
|
|
968
|
+
computer = found?.id ?? null;
|
|
969
|
+
}
|
|
970
|
+
const response = await daemonRequest(
|
|
971
|
+
{
|
|
972
|
+
command: "machines.home",
|
|
973
|
+
...(computer ? { computer, agent: "user" } : {}),
|
|
974
|
+
},
|
|
975
|
+
20_000
|
|
976
|
+
);
|
|
797
977
|
if (!response.ok) throw new Error(response.error || "not moved");
|
|
798
978
|
console.log(
|
|
799
|
-
|
|
979
|
+
computer
|
|
980
|
+
? `${name} is home now: it holds the board from here on.`
|
|
981
|
+
: "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
982
|
);
|
|
801
983
|
return;
|
|
802
984
|
}
|
|
803
985
|
if (sub)
|
|
804
986
|
throw new Error(
|
|
805
|
-
"usage: tryharness machines [add <code> | name <name> | home]"
|
|
987
|
+
"usage: tryharness machines [add <code> [--hosted] | name <name> | home [<computer>] | remove <name>]"
|
|
806
988
|
);
|
|
807
989
|
const response = await daemonRequest({ command: "machines.list" });
|
|
808
990
|
if (!response.ok)
|
|
@@ -814,7 +996,7 @@ async function machines() {
|
|
|
814
996
|
if (joinCode) {
|
|
815
997
|
const home = response.machines.find((machine) => machine.role === "home");
|
|
816
998
|
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:
|
|
999
|
+
`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
1000
|
);
|
|
819
1001
|
}
|
|
820
1002
|
if (!response.machines.length) {
|
|
@@ -963,7 +1145,7 @@ async function board() {
|
|
|
963
1145
|
);
|
|
964
1146
|
else if (runWorkspace)
|
|
965
1147
|
console.log(
|
|
966
|
-
`Task ${response.task.id} is on the board and ${target} will run it in ${runWorkspace}. Follow it:
|
|
1148
|
+
`Task ${response.task.id} is on the board and ${target} will run it in ${runWorkspace}. Follow it: ${relayCommand()} task ${response.task.id} --follow`
|
|
967
1149
|
);
|
|
968
1150
|
else
|
|
969
1151
|
console.log(
|
|
@@ -1069,7 +1251,7 @@ async function board() {
|
|
|
1069
1251
|
response.retrieval === "vectors"
|
|
1070
1252
|
? "meaning"
|
|
1071
1253
|
: response.embedder === "absent"
|
|
1072
|
-
?
|
|
1254
|
+
? `words (the local models are not downloaded yet; run ${relayCommand()})`
|
|
1073
1255
|
: `words (${response.context?.embedded ?? 0} of ${response.context?.total ?? 0} entries embedded so far)`;
|
|
1074
1256
|
console.log(
|
|
1075
1257
|
`${response.entries.length} result${response.entries.length === 1 ? "" : "s"} by ${how}`
|
|
@@ -1126,7 +1308,7 @@ async function board() {
|
|
|
1126
1308
|
for (const rule of response.standing) {
|
|
1127
1309
|
if (rule.mode === "off") {
|
|
1128
1310
|
console.log(
|
|
1129
|
-
`${rule.agent} waits for your Start. Turn it on:
|
|
1311
|
+
`${rule.agent} waits for your Start. Turn it on: ${relayCommand()} board standing ${rule.agent} on`
|
|
1130
1312
|
);
|
|
1131
1313
|
continue;
|
|
1132
1314
|
}
|
|
@@ -1137,7 +1319,7 @@ async function board() {
|
|
|
1137
1319
|
: "in folders you have used it in (none yet)"
|
|
1138
1320
|
: `in ${rule.workspaces.join(", ")}`;
|
|
1139
1321
|
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:
|
|
1322
|
+
`${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
1323
|
);
|
|
1142
1324
|
}
|
|
1143
1325
|
return;
|
|
@@ -1152,7 +1334,7 @@ async function board() {
|
|
|
1152
1334
|
if (!response.ok) throw new Error(response.error || `${sub} failed`);
|
|
1153
1335
|
console.log(
|
|
1154
1336
|
sub === "run"
|
|
1155
|
-
? `Run authorized; ${response.task.target_agent} starts it now. Follow it:
|
|
1337
|
+
? `Run authorized; ${response.task.target_agent} starts it now. Follow it: ${relayCommand()} task ${id} --follow`
|
|
1156
1338
|
: `Task ${id} is open again.`
|
|
1157
1339
|
);
|
|
1158
1340
|
return;
|
|
@@ -1164,8 +1346,8 @@ async function board() {
|
|
|
1164
1346
|
if (!id || id.startsWith("--"))
|
|
1165
1347
|
throw new Error("usage: tryharness board brief <task id> [--dry-run]");
|
|
1166
1348
|
const dryRun = has("--dry-run");
|
|
1167
|
-
// A dry run does what a run's start does before its agent starts. Measured on
|
|
1168
|
-
//
|
|
1349
|
+
// A dry run does what a run's start does before its agent starts. Measured on one daemon's log over seven weeks of
|
|
1350
|
+
// real use: context packs took up to 7,349 ms (215 packs, median 859), task frames up to 875 ms (216, median
|
|
1169
1351
|
// 230); claude-mem is cut off at 2,000 ms (CLAUDE_MEM_TIMEOUT_MS); reading the largest session file here (147 MB)
|
|
1170
1352
|
// 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
1353
|
// first (not measured).
|
|
@@ -1241,7 +1423,7 @@ async function board() {
|
|
|
1241
1423
|
);
|
|
1242
1424
|
if (t.run_workspace)
|
|
1243
1425
|
console.log(
|
|
1244
|
-
`run: ${t.run_authorized_at ? `authorized by ${t.run_authorized_by}` :
|
|
1426
|
+
`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
1427
|
);
|
|
1246
1428
|
if (t.brief) console.log(t.brief + "\n");
|
|
1247
1429
|
if (t.result)
|
|
@@ -1359,7 +1541,7 @@ async function goal() {
|
|
|
1359
1541
|
if (!response.ok) throw new Error(response.error || "the goal was not set");
|
|
1360
1542
|
const g = response.task;
|
|
1361
1543
|
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:
|
|
1544
|
+
`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
1545
|
);
|
|
1364
1546
|
return;
|
|
1365
1547
|
}
|
|
@@ -1401,7 +1583,13 @@ async function goal() {
|
|
|
1401
1583
|
}
|
|
1402
1584
|
if (sub === "invite") {
|
|
1403
1585
|
const response = await daemonRequest(
|
|
1404
|
-
{
|
|
1586
|
+
{
|
|
1587
|
+
command: "board.goal.invite",
|
|
1588
|
+
agent,
|
|
1589
|
+
id,
|
|
1590
|
+
to: String(argv[2] || ""),
|
|
1591
|
+
readable: has("--readable"),
|
|
1592
|
+
},
|
|
1405
1593
|
20_000
|
|
1406
1594
|
);
|
|
1407
1595
|
if (!response.ok)
|
|
@@ -1486,8 +1674,6 @@ async function swarm() {
|
|
|
1486
1674
|
const sub = argv[0] || "rounds";
|
|
1487
1675
|
if (sub === "coordinator") {
|
|
1488
1676
|
const mode = argv[1];
|
|
1489
|
-
if (mode && mode !== "harness" && mode !== "local")
|
|
1490
|
-
throw new Error("usage: tryharness swarm coordinator [harness|local]");
|
|
1491
1677
|
const response = await daemonRequest({
|
|
1492
1678
|
command: "board.swarm.coordinator",
|
|
1493
1679
|
agent: "user",
|
|
@@ -1499,9 +1685,13 @@ async function swarm() {
|
|
|
1499
1685
|
);
|
|
1500
1686
|
console.log(
|
|
1501
1687
|
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."
|
|
1688
|
+
? `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.`
|
|
1689
|
+
: "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
1690
|
);
|
|
1691
|
+
if (!mode)
|
|
1692
|
+
console.log(
|
|
1693
|
+
`To change it: tryharness swarm coordinator ${["harness", ...response.choices].join(" | ")}`
|
|
1694
|
+
);
|
|
1505
1695
|
return;
|
|
1506
1696
|
}
|
|
1507
1697
|
if (sub === "rounds") {
|
|
@@ -1757,9 +1947,9 @@ function logs() {
|
|
|
1757
1947
|
);
|
|
1758
1948
|
}
|
|
1759
1949
|
|
|
1760
|
-
// A cloud computer's daemon
|
|
1761
|
-
//
|
|
1762
|
-
//
|
|
1950
|
+
// A cloud computer's daemon, run by the harness-cloud service as the harness user once cloud-enroll has written its
|
|
1951
|
+
// config: the agents the boot script installed are connected to the swarm the first time, as setup connects them, and
|
|
1952
|
+
// then the daemon runs from the installed package itself.
|
|
1763
1953
|
async function cloudStart() {
|
|
1764
1954
|
const config = readJson(paths.config, {});
|
|
1765
1955
|
if (!config.cloud || !config.token)
|
|
@@ -1783,6 +1973,8 @@ async function cloudStart() {
|
|
|
1783
1973
|
// and keeps what is the person's, their board, history and keys, unless they ask for everything.
|
|
1784
1974
|
const downloadedParts = () => [
|
|
1785
1975
|
paths.runtime,
|
|
1976
|
+
// The installed command (runtime-install.mjs), which runs the runtime above.
|
|
1977
|
+
path.join(paths.home, "bin"),
|
|
1786
1978
|
paths.models,
|
|
1787
1979
|
path.join(paths.home, "local"),
|
|
1788
1980
|
];
|
|
@@ -1825,7 +2017,7 @@ async function uninstall() {
|
|
|
1825
2017
|
fs.rmSync(target, { recursive: true, force: true });
|
|
1826
2018
|
} catch {}
|
|
1827
2019
|
// 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 (
|
|
2020
|
+
// keeps their swarm (a reinstall once came back without Bankr, Quotient, Grok Bot and Muse).
|
|
1829
2021
|
if (!everything) {
|
|
1830
2022
|
const { token: _token, ...choices } = readJson(paths.config, {});
|
|
1831
2023
|
if (Object.keys(choices).length) writeJsonAtomic(paths.config, choices);
|
|
@@ -1844,7 +2036,7 @@ async function uninstall() {
|
|
|
1844
2036
|
console.log(
|
|
1845
2037
|
`Harness is uninstalled: the app, its background service and its setup in your agents are gone.\n` +
|
|
1846
2038
|
`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:
|
|
2039
|
+
`To delete them too: ${relayCommand()} uninstall --everything`
|
|
1848
2040
|
);
|
|
1849
2041
|
}
|
|
1850
2042
|
|
|
@@ -2020,6 +2212,19 @@ async function agents() {
|
|
|
2020
2212
|
process.exitCode = (await removeAgent({ daemonRequest, agent })) ? 0 : 1;
|
|
2021
2213
|
return;
|
|
2022
2214
|
}
|
|
2215
|
+
// The program Harness starts for an agent, confirmed again after the person installed it somewhere new.
|
|
2216
|
+
if (sub === "confirm") {
|
|
2217
|
+
if (!agent) throw new Error("usage: tryharness agents confirm <agent>");
|
|
2218
|
+
const confirmed = confirmAgentBinary(agent);
|
|
2219
|
+
if (!confirmed)
|
|
2220
|
+
throw new Error(
|
|
2221
|
+
`${agent} is not installed where this terminal can find it`
|
|
2222
|
+
);
|
|
2223
|
+
console.log(
|
|
2224
|
+
`Harness starts ${agent} from ${confirmed.path}${confirmed.previous ? ` now, not ${confirmed.previous}` : ""}.`
|
|
2225
|
+
);
|
|
2226
|
+
return;
|
|
2227
|
+
}
|
|
2023
2228
|
if (sub === "test" && agent) {
|
|
2024
2229
|
process.exitCode = (await testAgent({ agent, daemonRequest })) ? 0 : 1;
|
|
2025
2230
|
return;
|
|
@@ -2036,7 +2241,7 @@ async function agents() {
|
|
|
2036
2241
|
);
|
|
2037
2242
|
console.log(
|
|
2038
2243
|
response.text ||
|
|
2039
|
-
|
|
2244
|
+
`No agents in your swarm yet. Set them up: ${relayCommand()} agents`
|
|
2040
2245
|
);
|
|
2041
2246
|
return;
|
|
2042
2247
|
}
|
|
@@ -2094,11 +2299,11 @@ async function agents() {
|
|
|
2094
2299
|
);
|
|
2095
2300
|
else
|
|
2096
2301
|
console.log(
|
|
2097
|
-
` ${entry.models.length} models; list them with:
|
|
2302
|
+
` ${entry.models.length} models; list them with: ${relayCommand()} agents models ${entry.id}`
|
|
2098
2303
|
);
|
|
2099
2304
|
}
|
|
2100
2305
|
console.log(
|
|
2101
|
-
`\nAuto picks by: ${response.routing ?? `${response.defaultRouting} (the default; change it with:
|
|
2306
|
+
`\nAuto picks by: ${response.routing ?? `${response.defaultRouting} (the default; change it with: ${relayCommand()} agents routing "<your words>")`}`
|
|
2102
2307
|
);
|
|
2103
2308
|
return;
|
|
2104
2309
|
}
|
|
@@ -2207,47 +2412,123 @@ async function phone() {
|
|
|
2207
2412
|
);
|
|
2208
2413
|
return;
|
|
2209
2414
|
}
|
|
2415
|
+
// What waits for the person on any of their computers: a Harness page asking to link, or a device Harness linked.
|
|
2416
|
+
// `swarm` is from a daemon that keeps the swarm's list; an older one lists only this computer's asks.
|
|
2417
|
+
const listed = () => daemonRequest({ command: "phone.list" });
|
|
2418
|
+
const swarmOf = (response) =>
|
|
2419
|
+
response.swarm ?? [
|
|
2420
|
+
...(response.asks ?? []).map((ask) => ({
|
|
2421
|
+
...ask,
|
|
2422
|
+
kind: "ask",
|
|
2423
|
+
state: "waiting",
|
|
2424
|
+
})),
|
|
2425
|
+
...(response.phones ?? []).map((p) => ({
|
|
2426
|
+
...p,
|
|
2427
|
+
at: p.paired_at,
|
|
2428
|
+
state: p.revoked_at ? "removed" : "listed",
|
|
2429
|
+
})),
|
|
2430
|
+
];
|
|
2431
|
+
const where = (entry) =>
|
|
2432
|
+
entry.computerLabel ? ` on ${entry.computerLabel}` : "";
|
|
2433
|
+
const pick = (entries, prefix, none) => {
|
|
2434
|
+
const matches = entries.filter((entry) => entry.id.startsWith(prefix));
|
|
2435
|
+
if (matches.length === 1 || (!prefix && matches.length)) return matches[0];
|
|
2436
|
+
throw new Error(
|
|
2437
|
+
matches.length ? "that id matches more than one; type more of it" : none
|
|
2438
|
+
);
|
|
2439
|
+
};
|
|
2440
|
+
if (sub === "allow" || sub === "deny") {
|
|
2441
|
+
const response = await listed();
|
|
2442
|
+
const waiting = swarmOf(response).filter(
|
|
2443
|
+
(entry) => entry.state === "waiting"
|
|
2444
|
+
);
|
|
2445
|
+
if (!waiting.length) {
|
|
2446
|
+
console.log("Nothing is waiting for you on any of your computers.");
|
|
2447
|
+
return;
|
|
2448
|
+
}
|
|
2449
|
+
const entry = pick(
|
|
2450
|
+
waiting,
|
|
2451
|
+
String(argv[1] || ""),
|
|
2452
|
+
"nothing waiting has that id (see: tryharness phone list)"
|
|
2453
|
+
);
|
|
2454
|
+
const answer = await daemonRequest({
|
|
2455
|
+
command: "phone.link.answer",
|
|
2456
|
+
agent: "user",
|
|
2457
|
+
id: entry.id,
|
|
2458
|
+
allow: sub === "allow",
|
|
2459
|
+
});
|
|
2460
|
+
if (!answer.ok) throw new Error(answer.error);
|
|
2461
|
+
const browser = entry.kind === "ask";
|
|
2462
|
+
console.log(
|
|
2463
|
+
sub === "allow"
|
|
2464
|
+
? browser
|
|
2465
|
+
? `${entry.label} links to ${entry.computerLabel ?? "this computer"} now. See your devices: npx tryharness phone list`
|
|
2466
|
+
: `${entry.label}${where(entry)} works now. See your devices: npx tryharness phone list`
|
|
2467
|
+
: browser
|
|
2468
|
+
? `${entry.label} was not linked. Harness pages will not ask again today; npx tryharness link links a browser any time.`
|
|
2469
|
+
: `${entry.label}${where(entry)} is disconnected and never worked.`
|
|
2470
|
+
);
|
|
2471
|
+
return;
|
|
2472
|
+
}
|
|
2210
2473
|
if (sub === "list") {
|
|
2211
|
-
const response = await
|
|
2474
|
+
const response = await listed();
|
|
2212
2475
|
if (!response.ok)
|
|
2213
2476
|
throw new Error(response.error || "the daemon could not list phones");
|
|
2214
|
-
|
|
2477
|
+
const entries = swarmOf(response);
|
|
2478
|
+
for (const entry of entries.filter(
|
|
2479
|
+
(item) => item.kind === "ask" && item.state === "waiting"
|
|
2480
|
+
))
|
|
2481
|
+
console.log(
|
|
2482
|
+
`${entry.label} asks to link to ${entry.computerLabel ?? "this computer"}. Allow it: npx tryharness phone allow ${entry.id.slice(0, 8)} (or deny)`
|
|
2483
|
+
);
|
|
2484
|
+
const devices = entries.filter((item) => item.kind !== "ask");
|
|
2485
|
+
if (!devices.length) {
|
|
2215
2486
|
console.log(
|
|
2216
|
-
|
|
2487
|
+
`Nothing paired. Pair a phone: ${relayCommand()} phone pair; connect a browser: ${relayCommand()} link`
|
|
2217
2488
|
);
|
|
2218
2489
|
return;
|
|
2219
2490
|
}
|
|
2220
|
-
|
|
2491
|
+
const seen = new Map(
|
|
2492
|
+
(response.phones ?? []).map((p) => [p.id, p.last_seen_at])
|
|
2493
|
+
);
|
|
2494
|
+
for (const p of devices)
|
|
2221
2495
|
console.log(
|
|
2222
|
-
`${p.id.slice(0, 8)} ${(p.kind || "phone").padEnd(8)} ${p.label.padEnd(20)}
|
|
2496
|
+
`${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)} ${
|
|
2497
|
+
p.state === "removed"
|
|
2498
|
+
? "disconnected"
|
|
2499
|
+
: p.state === "waiting"
|
|
2500
|
+
? `waits for you: npx tryharness phone allow ${p.id.slice(0, 8)}`
|
|
2501
|
+
: seen.get(p.id)
|
|
2502
|
+
? `last seen ${seen.get(p.id).slice(0, 16).replace("T", " ")}`
|
|
2503
|
+
: p.computerLabel
|
|
2504
|
+
? "linked"
|
|
2505
|
+
: "not used yet"
|
|
2506
|
+
}`
|
|
2223
2507
|
);
|
|
2224
2508
|
return;
|
|
2225
2509
|
}
|
|
2226
2510
|
if (sub === "revoke") {
|
|
2227
2511
|
const prefix = String(argv[1] || "");
|
|
2228
2512
|
if (!prefix) throw new Error("usage: tryharness phone revoke <phone id>");
|
|
2229
|
-
const
|
|
2230
|
-
|
|
2231
|
-
|
|
2513
|
+
const device = pick(
|
|
2514
|
+
swarmOf(await listed()).filter(
|
|
2515
|
+
(entry) => entry.kind !== "ask" && entry.state !== "removed"
|
|
2516
|
+
),
|
|
2517
|
+
prefix,
|
|
2518
|
+
"no phone with that id (see: tryharness phone list)"
|
|
2232
2519
|
);
|
|
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
2520
|
const response = await daemonRequest({
|
|
2240
2521
|
command: "phone.revoke",
|
|
2241
|
-
id:
|
|
2522
|
+
id: device.id,
|
|
2242
2523
|
});
|
|
2243
2524
|
if (!response.ok) throw new Error(response.error);
|
|
2244
2525
|
console.log(
|
|
2245
|
-
`${
|
|
2526
|
+
`${device.label}${where(device)} is disconnected. It can no longer reach ${device.computerLabel ?? "this computer"}.`
|
|
2246
2527
|
);
|
|
2247
2528
|
return;
|
|
2248
2529
|
}
|
|
2249
2530
|
throw new Error(
|
|
2250
|
-
"usage: tryharness phone [pair [--link] | list | revoke <phone id>]"
|
|
2531
|
+
"usage: tryharness phone [pair [--link] | list | allow | deny | revoke <phone id>]"
|
|
2251
2532
|
);
|
|
2252
2533
|
}
|
|
2253
2534
|
|
|
@@ -2348,9 +2629,39 @@ async function t3() {
|
|
|
2348
2629
|
}
|
|
2349
2630
|
}
|
|
2350
2631
|
|
|
2632
|
+
// `tryharness upgrade [version]`: this computer's Harness fetches the release, checks its signature before any of it
|
|
2633
|
+
// runs (runtime-install.mjs fetchRelease), and only then runs that release's setup.
|
|
2634
|
+
function upgrade() {
|
|
2635
|
+
const spec = argv[0] && !argv[0].startsWith("-") ? argv.shift() : "latest";
|
|
2636
|
+
const fetched = fetchRelease({ spec });
|
|
2637
|
+
try {
|
|
2638
|
+
console.log(
|
|
2639
|
+
fetched.trusted
|
|
2640
|
+
? `tryharness ${fetched.version} is signed with Harness's release key (${fetched.key}). Setting it up.`
|
|
2641
|
+
: `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.`
|
|
2642
|
+
);
|
|
2643
|
+
const setup = spawnSync(
|
|
2644
|
+
process.execPath,
|
|
2645
|
+
[path.join(fetched.root, "cli.mjs"), "setup", ...argv],
|
|
2646
|
+
{ stdio: "inherit" }
|
|
2647
|
+
);
|
|
2648
|
+
process.exitCode = setup.status ?? 1;
|
|
2649
|
+
} finally {
|
|
2650
|
+
fs.rmSync(fetched.dir, { recursive: true, force: true });
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
|
|
2654
|
+
// Once Harness is installed, its own command runs the release it checked; npx would fetch npm's newest.
|
|
2655
|
+
function installedLine() {
|
|
2656
|
+
const installed = relayCommand();
|
|
2657
|
+
return installed.startsWith("npx ")
|
|
2658
|
+
? ""
|
|
2659
|
+
: `On this computer, run these as ${installed} <command>: it runs the release this computer checked and installed.\n\n`;
|
|
2660
|
+
}
|
|
2661
|
+
|
|
2351
2662
|
function help() {
|
|
2352
2663
|
console.log(
|
|
2353
|
-
`tryharness ${VERSION}\n\
|
|
2664
|
+
`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
2665
|
);
|
|
2355
2666
|
}
|
|
2356
2667
|
|
|
@@ -2392,7 +2703,7 @@ try {
|
|
|
2392
2703
|
});
|
|
2393
2704
|
console.log(
|
|
2394
2705
|
on
|
|
2395
|
-
?
|
|
2706
|
+
? `Apps are on. Connect one with ${relayCommand()} connections add; agents see them in sessions they start from now on.`
|
|
2396
2707
|
: "Apps are off. No agent can use a connected app until you turn them on again."
|
|
2397
2708
|
);
|
|
2398
2709
|
} else if (command === "connections") {
|
|
@@ -2411,6 +2722,9 @@ try {
|
|
|
2411
2722
|
else if (command === "t3") await t3();
|
|
2412
2723
|
else if (command === "peers") await peers();
|
|
2413
2724
|
else if (command === "machines") await machines();
|
|
2725
|
+
else if (command === "ssh") await ssh();
|
|
2726
|
+
else if (command === "steer") await steer();
|
|
2727
|
+
else if (command === "runs") await runs();
|
|
2414
2728
|
else if (command === "backup")
|
|
2415
2729
|
await backupCommand({ argv, ui: createUi(), daemonRequest });
|
|
2416
2730
|
else if (command === "connect") await connectAgent();
|
|
@@ -2425,6 +2739,7 @@ try {
|
|
|
2425
2739
|
await startDaemon();
|
|
2426
2740
|
} else if (command === "cloud-enroll") await cloudEnroll();
|
|
2427
2741
|
else if (command === "cloud-start") await cloudStart();
|
|
2742
|
+
else if (command === "upgrade") upgrade();
|
|
2428
2743
|
else if (command === "version") console.log(VERSION);
|
|
2429
2744
|
else if (["help", "--help", "-h"].includes(command)) help();
|
|
2430
2745
|
else throw new Error(`unknown command '${command}' (run: tryharness help)`);
|