tryharness 0.7.81 → 0.7.82

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.
Files changed (46) hide show
  1. package/README.md +4 -3
  2. package/assets/install.sh +104 -0
  3. package/cli.mjs +203 -321
  4. package/lib/adapters.mjs +7 -6
  5. package/lib/agentRuntimes.mjs +2 -1
  6. package/lib/backupSetup.mjs +0 -52
  7. package/lib/boardProtocol.json +17 -1
  8. package/lib/browserPage.mjs +30 -0
  9. package/lib/daemon.mjs +89 -5
  10. package/lib/desktop.mjs +7 -1
  11. package/lib/dispatcher.mjs +12 -2
  12. package/lib/environments.mjs +4 -11
  13. package/lib/goalCommands.mjs +2 -1
  14. package/lib/hookDialects.mjs +2 -1
  15. package/lib/jobAnswers.mjs +2 -1
  16. package/lib/localStack.mjs +24 -9
  17. package/lib/mcp-stdio.mjs +6 -0
  18. package/lib/museSession.mjs +2 -1
  19. package/lib/nativeHost.mjs +11 -2
  20. package/lib/network.mjs +1 -0
  21. package/lib/notify.mjs +48 -16
  22. package/lib/onboard.mjs +71 -366
  23. package/lib/ownMachines.mjs +4 -1
  24. package/lib/pairing.mjs +0 -84
  25. package/lib/paths.mjs +17 -0
  26. package/lib/personNotices.mjs +9 -25
  27. package/lib/profile.mjs +0 -109
  28. package/lib/projects.mjs +18 -4
  29. package/lib/removeHarness.mjs +91 -0
  30. package/lib/roomChannels.mjs +2 -0
  31. package/lib/runner.mjs +3 -3
  32. package/lib/runtime-install.mjs +22 -2
  33. package/lib/screen.mjs +133 -0
  34. package/lib/selfUpdate.mjs +6 -6
  35. package/lib/service.mjs +120 -7
  36. package/lib/sessionControl.mjs +10 -0
  37. package/lib/setupChoices.mjs +400 -0
  38. package/lib/setupMode.mjs +137 -0
  39. package/lib/t3.mjs +23 -14
  40. package/lib/threadActions.mjs +2 -1
  41. package/lib/toolCheck.mjs +136 -0
  42. package/lib/ui.mjs +15 -1
  43. package/lib/wakes.mjs +3 -3
  44. package/npm-shrinkwrap.json +14 -14
  45. package/package.json +4 -4
  46. package/release.json +47 -40
package/lib/adapters.mjs CHANGED
@@ -10,6 +10,7 @@ import {
10
10
  removeSessionHooks,
11
11
  sessionHooksPath,
12
12
  } from "./hookDialects.mjs";
13
+ import { harnessNode } from "./paths.mjs";
13
14
 
14
15
  export const AGENTS = MACHINE_RUNNERS;
15
16
 
@@ -94,7 +95,7 @@ export function detectMcpClients({
94
95
  export function mcpClientSnippet({
95
96
  runtimeRoot,
96
97
  client,
97
- nodePath = process.execPath,
98
+ nodePath = harnessNode(),
98
99
  }) {
99
100
  return {
100
101
  mcpServers: {
@@ -115,7 +116,7 @@ export function mcpClientSnippet({
115
116
  function installAsset(
116
117
  source,
117
118
  target,
118
- { runtimeRoot, nodePath = process.execPath, agent = "" }
119
+ { runtimeRoot, nodePath = harnessNode(), agent = "" }
119
120
  ) {
120
121
  ensureDir(path.dirname(target));
121
122
  const text = fs
@@ -186,7 +187,7 @@ function writeDshRows(homeDir, { mcpPath } = {}) {
186
187
  " config:",
187
188
  " serverName: harness",
188
189
  " transport: stdio",
189
- ` command: ${JSON.stringify(process.execPath)}`,
190
+ ` command: ${JSON.stringify(harnessNode())}`,
190
191
  ` args: ${JSON.stringify([mcpPath, "--agent", "dsh"])}`,
191
192
  " env: {}",
192
193
  " - id: tryharness",
@@ -262,14 +263,14 @@ function addMcpServer(agent, executable, { mcpPath, homeDir, execute }) {
262
263
  if (setup.file) {
263
264
  writeMcpEntry(setup.file(homeDir), {
264
265
  ...setup.entry,
265
- command: process.execPath,
266
+ command: harnessNode(),
266
267
  args: server,
267
268
  });
268
269
  if (setup.enable) execute(executable, setup.enable);
269
270
  return { ok: true };
270
271
  }
271
272
  execute(executable, setup.remove);
272
- return execute(executable, [...setup.add, "--", process.execPath, ...server]);
273
+ return execute(executable, [...setup.add, "--", harnessNode(), ...server]);
273
274
  }
274
275
 
275
276
  function removeMcpServer(agent, executable, { homeDir, execute }) {
@@ -357,7 +358,7 @@ export function configureAgents({
357
358
  "add",
358
359
  "harness",
359
360
  "--",
360
- process.execPath,
361
+ harnessNode(),
361
362
  mcpPath,
362
363
  "--agent",
363
364
  agent,
@@ -7,6 +7,7 @@ import { agentEnvironment } from "./agentnode.mjs";
7
7
  import { agentBinary } from "./agentBinaries.mjs";
8
8
  import { runtimeOf } from "./agentRuntimeConfig.mjs";
9
9
  import { openMuseSession } from "./museSession.mjs";
10
+ import { harnessNode } from "./paths.mjs";
10
11
 
11
12
  const progress = (emit, observe, kind, text) => {
12
13
  observe(
@@ -282,7 +283,7 @@ async function runAcp(task, runtime, hooks) {
282
283
  : [
283
284
  {
284
285
  name: "harness",
285
- command: process.execPath,
286
+ command: harnessNode(),
286
287
  args: [
287
288
  fileURLToPath(new URL("./mcp-stdio.mjs", import.meta.url)),
288
289
  "--agent",
@@ -27,58 +27,6 @@ async function askPassphrase(ui, { twice }) {
27
27
  return first;
28
28
  }
29
29
 
30
- /** Setup's step, on home only: bring a Resident's board back, or offer to start backing it up. */
31
- export async function offerBackup({ ui, daemonRequest, role, boardIsEmpty }) {
32
- if (role !== "home") return;
33
- const status = await daemonRequest({ command: "backup.status" }).catch(
34
- () => null
35
- );
36
- if (!status?.ok || status.entitled === null) return;
37
- if (status.entitled === false) {
38
- ui.info(
39
- "Your board stays on this computer. With Resident, Harness also keeps an encrypted backup of it, so a new computer can bring it back."
40
- );
41
- return;
42
- }
43
- if (status.on) return;
44
- if (!ui.interactive) return;
45
- if (status.latest && boardIsEmpty) {
46
- ui.info(
47
- `You have a backup of your board from ${status.latest.fromLabel || "another computer"}, ${when(status.latest.createdAt)}.`
48
- );
49
- for (let tries = 0; tries < 3; tries++) {
50
- const passphrase = await askPassphrase(ui, { twice: false });
51
- if (!passphrase) break;
52
- const restored = await daemonRequest(
53
- { command: "backup.restore", passphrase },
54
- 120_000
55
- );
56
- if (restored.ok) {
57
- ui.success(
58
- `Your board is back (${restored.rows} items). It goes on backing up from this computer.`
59
- );
60
- return;
61
- }
62
- ui.warn(restored.error || "That backup could not be opened.");
63
- if (restored.code !== "wrong_passphrase") break;
64
- }
65
- ui.info(`To try again later: ${relayCommand()} backup restore`);
66
- return;
67
- }
68
- const yes = await ui.confirm({
69
- message:
70
- "Keep an encrypted backup of your board with Harness? A new computer can bring it back with your passphrase; Harness cannot read it.",
71
- initialValue: true,
72
- });
73
- if (!yes) return;
74
- const passphrase = await askPassphrase(ui, { twice: true });
75
- if (!passphrase) return;
76
- const on = await daemonRequest({ command: "backup.on", passphrase }, 120_000);
77
- if (on.ok)
78
- ui.success("Your board is backed up, sealed with your passphrase.");
79
- else ui.warn(on.error || "The backup did not start.");
80
- }
81
-
82
30
  /** npx tryharness backup [on | now | restore | off] */
83
31
  export async function backupCommand({ argv, ui, daemonRequest }) {
84
32
  const sub = argv[0];
@@ -711,6 +711,21 @@
711
711
  "swarm.lineup",
712
712
  "swarm.add",
713
713
  "swarm.remove",
714
+ "setup.signin",
715
+ "setup.cancel",
716
+ "setup.bankr",
717
+ "setup.state",
718
+ "setup.finish",
719
+ "setup.notify",
720
+ "setup.apps",
721
+ "setup.workplace",
722
+ "setup.folders",
723
+ "setup.folder",
724
+ "setup.findFolders",
725
+ "setup.toolCheck",
726
+ "setup.fix",
727
+ "swarm.check",
728
+ "wake.server",
714
729
  "phone.list",
715
730
  "phone.link.answer",
716
731
  "phone.revoke",
@@ -778,7 +793,8 @@
778
793
  "board.wait",
779
794
  "board.landed.thread",
780
795
  "board.landed.folder",
781
- "board.landed.open"
796
+ "board.landed.open",
797
+ "browser.page"
782
798
  ],
783
799
  "plainPerson": ["board.standing.off"],
784
800
  "plainHarnessReads": [
@@ -0,0 +1,30 @@
1
+ // Which page the person is on, as the Harness extension tells this computer (the extension's computerPage.js, through
2
+ // nativeHost.mjs), for the buddy's chip on their next message. It holds only a web page's title and link, in memory, and
3
+ // only the person's own buddy reads it: an agent sees a page only when the person sends one with their words.
4
+ const MAX_TITLE = 500;
5
+ const MAX_URL = 2_000;
6
+
7
+ /** A page as the extension may tell it, or null for anything else. */
8
+ function pageOf(page) {
9
+ if (typeof page?.title !== "string" || typeof page?.url !== "string")
10
+ return null;
11
+ if (!/^https?:\/\//.test(page.url) || page.url.length > MAX_URL) return null;
12
+ return { title: page.title.slice(0, MAX_TITLE), url: page.url };
13
+ }
14
+
15
+ export function createBrowserPage() {
16
+ let page = null;
17
+ return {
18
+ /** From the native host, which names no agent; an agent cannot say what the person is looking at. */
19
+ set(request) {
20
+ if (request.agent) return { ok: false, error: "only the browser says" };
21
+ page = pageOf(request.page);
22
+ return { ok: true };
23
+ },
24
+ read(request) {
25
+ if (request.agent !== "user")
26
+ return { ok: false, error: "only the person reads this" };
27
+ return { ok: true, page };
28
+ },
29
+ };
30
+ }
package/lib/daemon.mjs CHANGED
@@ -112,7 +112,14 @@ import {
112
112
  RUN_CALLER,
113
113
  } from "./runAuthority.mjs";
114
114
  import { createActorRoster } from "./actorRoster.mjs";
115
- import { createLineup, createLineupCommands } from "./lineup.mjs";
115
+ import { agentsHere, createLineup, createLineupCommands } from "./lineup.mjs";
116
+ import { untilSignedIn } from "./setupMode.mjs";
117
+ import { createSetupChoices } from "./setupChoices.mjs";
118
+ import { checkTools, TOOL_CHECK_DEADLINE_MS } from "./toolCheck.mjs";
119
+ import { AGENTS } from "./adapters.mjs";
120
+
121
+ // Where a computer signs in when setup has not said otherwise.
122
+ const DEFAULT_ORIGIN = "https://tryharness.ai";
116
123
  import {
117
124
  CHECKABLE,
118
125
  SIGN_IN,
@@ -150,6 +157,7 @@ import { createDirectLink } from "./directLink.mjs";
150
157
  import { readsFromCopy } from "./machineRoutes.mjs";
151
158
  import { createConnectors } from "./connectors.mjs";
152
159
  import { createBrowserWake } from "./browserWake.mjs";
160
+ import { createBrowserPage } from "./browserPage.mjs";
153
161
  import { createWindowAsks } from "./windowAsks.mjs";
154
162
  import { createSeen } from "./seen.mjs";
155
163
  import { createAuditor } from "./audit.mjs";
@@ -227,6 +235,12 @@ function stuckThresholds() {
227
235
 
228
236
  export async function startDaemon() {
229
237
  ensureDir(paths.home);
238
+ // One daemon per computer. While setup's daemon hands over to the app's background item, the item's own one starts
239
+ // and finds the other still answering: it leaves, and launchd starts it again once the other has gone.
240
+ if (await daemonAnswers(paths.socket)) {
241
+ appendLog(paths.log, "another Harness daemon is running here; leaving it");
242
+ process.exit(0);
243
+ }
230
244
  // Started by the Harness app's launcher (HarnessDaemon.swift): if it goes, this goes too, so the daemon launchd starts
231
245
  // next is the only one. The agents this daemon starts do not inherit the mark.
232
246
  const launcher = Number(process.env.HARNESS_LAUNCHER_PID);
@@ -235,9 +249,17 @@ export async function startDaemon() {
235
249
  setInterval(() => {
236
250
  if (process.ppid !== launcher) process.exit(0);
237
251
  }, 5_000).unref();
252
+ // Not signed in yet: Harness runs anyway, so the buddy can show setup, and carries on from here once signed in.
253
+ if (!readJson(paths.config, {}).token)
254
+ await untilSignedIn({
255
+ paths,
256
+ origin: readJson(paths.config, {}).origin || DEFAULT_ORIGIN,
257
+ agents: agentsHere()
258
+ .filter((entry) => AGENTS.includes(entry.id))
259
+ .map((entry) => entry.id),
260
+ log: (line) => appendLog(paths.log, line),
261
+ });
238
262
  const config = readJson(paths.config, {});
239
- if (!config.origin || !config.token)
240
- throw new Error("Harness is not paired. Run: npx tryharness");
241
263
  // node-sqlite3-wasm locks with a directory that exists only during a transaction. A daemon
242
264
  // killed mid-transaction leaves it behind and every later open fails "database is locked";
243
265
  // with no daemon answering, nothing can hold it.
@@ -786,7 +808,8 @@ export async function startDaemon() {
786
808
  }
787
809
  if (first)
788
810
  notices.notify(
789
- `${nameOf(agent)} is not answering its wakes (${detail}). Its work waits until it does.`
811
+ `${nameOf(agent)} is not answering its wakes (${detail}). Its work waits until it does.`,
812
+ { thread: threads[0] }
790
813
  );
791
814
  },
792
815
  });
@@ -1052,6 +1075,7 @@ export async function startDaemon() {
1052
1075
  });
1053
1076
  // What this computer hands the person's Harness page through the extension (browserWake.mjs): Harness's tasks they
1054
1077
  // let it finish in their browser, sent again when a browser starts listening after this daemon restarted.
1078
+ const browserPage = createBrowserPage();
1055
1079
  const browserWake = createBrowserWake({
1056
1080
  log,
1057
1081
  pending: () =>
@@ -2954,7 +2978,29 @@ export async function startDaemon() {
2954
2978
  };
2955
2979
  // What the control socket answers that no module answers itself, by command.
2956
2980
  const controlCommands = {
2957
- status: () => ({ ok: true, ...state, counts: store.counts() }),
2981
+ status: () => ({
2982
+ ok: true,
2983
+ ...state,
2984
+ counts: store.counts(),
2985
+ // The app shows its setup until the person finishes it there (setup.finish). A computer set up before the app
2986
+ // had setup has no such mark, and nothing left to set up.
2987
+ setupDone: readJson(paths.config, {}).setupDone !== false,
2988
+ }),
2989
+ // "Tell me when an agent needs me" in setup: off stops desktop notices (notify.mjs), never the board's own.
2990
+ "setup.notify": (request) => {
2991
+ writeJsonAtomic(paths.config, {
2992
+ ...readJson(paths.config, {}),
2993
+ desktopNotices: request.on !== false,
2994
+ });
2995
+ return { ok: true };
2996
+ },
2997
+ "setup.finish": () => {
2998
+ writeJsonAtomic(paths.config, {
2999
+ ...readJson(paths.config, {}),
3000
+ setupDone: true,
3001
+ });
3002
+ return { ok: true };
3003
+ },
2958
3004
  doctor: () => ({
2959
3005
  ok: true,
2960
3006
  status: state,
@@ -3091,6 +3137,9 @@ export async function startDaemon() {
3091
3137
  browserWake
3092
3138
  .next(request.waitMs)
3093
3139
  .then((messages) => ({ ok: true, messages })),
3140
+ // Which page the person is on, from the extension's native host, for the buddy's chip (browserPage.mjs).
3141
+ "browser.page.set": (request) => browserPage.set(request),
3142
+ "browser.page": (request) => browserPage.read(request),
3094
3143
  // A Harness page's ask for a link offer, from the extension's native host: it waits for the person's answer here.
3095
3144
  "phone.link.ask": (request) =>
3096
3145
  phones.linkAsk.request({
@@ -3128,6 +3177,9 @@ export async function startDaemon() {
3128
3177
  },
3129
3178
  // How Harness wakes the agents it keeps on the server (Grok Bot): read and saved there, never here.
3130
3179
  "wake.server": (request) => askHarness("wake", request.input || {}),
3180
+ // Bankr in setup: status, Connect (makes the person's Harness wallet) and Link (a code for their Bankr agent).
3181
+ "setup.bankr": (request) =>
3182
+ askHarness("bankr_setup", { action: String(request.action || "") }),
3131
3183
  // Whether agent work is going on here, for the desktop app deciding when the Mac may sleep.
3132
3184
  activity: () =>
3133
3185
  machineActivity({
@@ -3233,6 +3285,14 @@ export async function startDaemon() {
3233
3285
  };
3234
3286
  const answerControl = (request) => {
3235
3287
  const command = String(request.command || "");
3288
+ // An agent loading its Harness tools, or calling list_agents through them: what setup's tool check listens for
3289
+ // (toolCheck.mjs).
3290
+ if (
3291
+ (command === "agent.toolsListed" || command === "board.swarm.agents") &&
3292
+ request.agent
3293
+ )
3294
+ toolCallsHeard.set(String(request.agent), Date.now());
3295
+ if (command === "agent.toolsListed") return { ok: true };
3236
3296
  if (command.startsWith("board.")) return answerBoard(request);
3237
3297
  if (local.handles(command)) return local.command(request);
3238
3298
  if (Object.hasOwn(controlCommands, command))
@@ -3243,8 +3303,32 @@ export async function startDaemon() {
3243
3303
  }
3244
3304
  // An agent's call to Harness from its MCP server on this computer, carried on the bridge (mcpRelay.mjs).
3245
3305
  if (mcpRelay.handles(command)) return mcpRelay.run(request);
3306
+ if (setupChoices.handles(command)) return setupChoices.answer(request);
3246
3307
  return { ok: false, error: "unknown command" };
3247
3308
  };
3309
+ // Setup's check that Harness's tools load inside an agent, and its Fix: the agent's Harness entries written again
3310
+ // (lineup.mjs joinAgent, on Harness's own Node), then checked again.
3311
+ const toolCallsHeard = new Map();
3312
+ const heardSince = (agent, at) => (toolCallsHeard.get(agent) ?? 0) >= at;
3313
+ const toolCheck = (agent) =>
3314
+ checkTools(agent, { heardSince, deadlineMs: TOOL_CHECK_DEADLINE_MS });
3315
+ controlCommands["setup.toolCheck"] = (request) =>
3316
+ toolCheck(String(request.target || "")).then((result) => ({
3317
+ ok: true,
3318
+ agent: String(request.target || ""),
3319
+ ...result,
3320
+ }));
3321
+ controlCommands["setup.fix"] = (request) => {
3322
+ const agent = String(request.target || "");
3323
+ const joined = lineupCommands.run({ command: "swarm.add", target: agent });
3324
+ if (!joined?.ok) return joined;
3325
+ return controlCommands["setup.toolCheck"](request);
3326
+ };
3327
+ // What the app's setup window and settings choose: where threads open, and which guarded folders search reads.
3328
+ const setupChoices = createSetupChoices({
3329
+ configPath: paths.config,
3330
+ knownFolders: () => folders.known().map((place) => place.path),
3331
+ });
3248
3332
  const control = await listenControl({
3249
3333
  socketPath: paths.socket,
3250
3334
  answer: answerControl,
package/lib/desktop.mjs CHANGED
@@ -256,6 +256,12 @@ export function installDesktop({
256
256
  return { target, updated: true };
257
257
  }
258
258
 
259
+ /** Whether setup installed the app here before, so an upgrade keeps it on the same release. */
260
+ export function desktopInstalled() {
261
+ const recorded = readJson(marker(), {}).path;
262
+ return Boolean(recorded && fs.existsSync(recorded));
263
+ }
264
+
259
265
  /** Whether this login can show a window at all: not a server reached over SSH. */
260
266
  export function canShowDesktop({
261
267
  env = process.env,
@@ -286,7 +292,7 @@ export function openDesktop({
286
292
  child.unref();
287
293
  }
288
294
 
289
- const BUNDLE_ID = "ai.tryharness.desktop";
295
+ export const BUNDLE_ID = "ai.tryharness.desktop";
290
296
  // The app's own uninstall run (UNINSTALL_ARG in the app's lib.rs) takes out what macOS registered for it, the
291
297
  // Lid-Closed power helper and its backstop job, which nothing outside the app can remove. Buddies up to 0.7.53 don't
292
298
  // know the argument and would open instead.
@@ -3,6 +3,8 @@ import os from "node:os";
3
3
  import path from "node:path";
4
4
  import { askLocalAgent, DISPATCH_AGENTS } from "./localAgentAsk.mjs";
5
5
  import { ensureModels, modelById, modelsPresent } from "./localmodels.mjs";
6
+ import { readJson } from "./files.mjs";
7
+ import { paths } from "./paths.mjs";
6
8
 
7
9
  // The dispatcher slot (owner, November 1): "manager - it is its own slot", "lfm slot should act as a dispatcher not an
8
10
  // orchestrator", "facilitator is dispatcher". Jev decides who takes the work, where and how; the dispatcher carries the
@@ -154,11 +156,17 @@ const ownEntry = (file) => {
154
156
  // Where the person's own models are found for the Swarm tab's list: these folders, a few levels down. A path typed
155
157
  // there reaches any other (no file dialog, owner rule: folders are typed or listed, never opened by the OS).
156
158
  const MODEL_FOLDERS = ["models", "Downloads", "Documents", "Desktop"];
159
+ // macOS asks before Harness reads these three; only the ones the person picked in setup are read (localStack.mjs).
160
+ const ASKED_FOLDERS = new Set(["Downloads", "Documents", "Desktop"]);
161
+ const pickedFolders = () => {
162
+ const picked = readJson(paths.config, {}).searchFolders;
163
+ return Array.isArray(picked) ? picked : [...ASKED_FOLDERS];
164
+ };
157
165
  const MODEL_DEPTH = 3;
158
166
  const SKIPPED = new Set(["node_modules", ".git", "Library", ".Trash"]);
159
167
 
160
168
  /** The .gguf model files under the person's usual folders, largest first; projectors (mmproj) are parts, not models. */
161
- export function ownModelFiles(home = os.homedir()) {
169
+ export function ownModelFiles(home = os.homedir(), picked = pickedFolders()) {
162
170
  const found = [];
163
171
  const walk = (dir, depth) => {
164
172
  let entries = [];
@@ -179,7 +187,9 @@ export function ownModelFiles(home = os.homedir()) {
179
187
  found.push({ file: at, bytes: fs.statSync(at).size });
180
188
  }
181
189
  };
182
- for (const folder of MODEL_FOLDERS) walk(path.join(home, folder), 1);
190
+ for (const folder of MODEL_FOLDERS)
191
+ if (!ASKED_FOLDERS.has(folder) || picked.includes(folder))
192
+ walk(path.join(home, folder), 1);
183
193
  return found.sort((a, b) => b.bytes - a.bytes).slice(0, 20);
184
194
  }
185
195
 
@@ -2,7 +2,7 @@ import fs from "node:fs";
2
2
  import { createHash } from "node:crypto";
3
3
  import { detectAgents } from "./commands.mjs";
4
4
  import { member, nameOf } from "./members.mjs";
5
- import { t3Access, t3Tool } from "./t3.mjs";
5
+ import { t3Access, t3Step, t3Tool } from "./t3.mjs";
6
6
  import { t3Checkouts, t3Committers, t3Link } from "./places.mjs";
7
7
 
8
8
  const DRIVER_AGENT = {
@@ -623,17 +623,10 @@ export function createEnvironments({
623
623
  model: { model: entry.model, effort: null, by: "T3 Code" },
624
624
  subagents: [],
625
625
  steps: items
626
- .filter(
627
- (item) =>
628
- item.type !== "reasoning" &&
629
- item.type !== "user_message" &&
630
- item.text
631
- )
626
+ .map(t3Step)
627
+ .filter(Boolean)
632
628
  .slice(-10)
633
- .map((item) => ({
634
- kind: item.type === "assistant_message" ? "say" : "do",
635
- text: item.text.slice(0, 1_000),
636
- })),
629
+ .map((step) => ({ ...step, text: step.text.slice(0, 1_000) })),
637
630
  });
638
631
  }
639
632
  if (!authorized() || grant !== readGrant)
@@ -266,7 +266,8 @@ export function createGoalCommands({
266
266
  text,
267
267
  });
268
268
  notifyDesktop(
269
- `A post by ${nameOf(agent)} in a thread was held: it looks like ${flag}.`
269
+ `A post by ${nameOf(agent)} in a thread was held: it looks like ${flag}.`,
270
+ { thread: goal.id }
270
271
  );
271
272
  return {
272
273
  ok: true,
@@ -3,6 +3,7 @@ import os from "node:os";
3
3
  import path from "node:path";
4
4
  import { ensureDir, readJson } from "./files.mjs";
5
5
  import { steerRoot } from "./steerQueue.mjs";
6
+ import { harnessNode } from "./paths.mjs";
6
7
 
7
8
  // How each agent runs session hooks: the file it reads them from, that file's shape, and what it does with a hook's
8
9
  // output. Harness hooks three moments, by the names Claude Code gave them: a session starting (its board notice, where it
@@ -267,7 +268,7 @@ export function installSessionHooks(
267
268
  {
268
269
  runtimeRoot,
269
270
  homeDir = os.homedir(),
270
- nodePath = process.execPath,
271
+ nodePath = harnessNode(),
271
272
  env = process.env,
272
273
  }
273
274
  ) {
@@ -137,7 +137,8 @@ export function createJobAnswers({
137
137
  machine: task.claimed_machine,
138
138
  });
139
139
  notifyDesktop(
140
- `${nameOf(who)}'s answer in a thread was held: it looks like ${flag}.`
140
+ `${nameOf(who)}'s answer in a thread was held: it looks like ${flag}.`,
141
+ { thread: goal.id }
141
142
  );
142
143
  }
143
144
  const post = store.roomPost({
@@ -155,18 +155,33 @@ export function createLocalStack({
155
155
  };
156
156
  };
157
157
 
158
- // Where people keep their own files and the folders they added (tryharness local add), searched or not.
159
- const ownFolders = () => {
160
- const config = readJson(configPath, {});
161
- const added = Array.isArray(config.localFolders) ? config.localFolders : [];
162
- const own = OWN_FOLDERS.map((name) => path.join(os.homedir(), name));
163
- return [...new Set([...own, ...added])].filter(
158
+ const existing = (folders) =>
159
+ [...new Set(folders)].filter(
164
160
  (folder) => typeof folder === "string" && fs.existsSync(folder)
165
161
  );
162
+ const added = (config) =>
163
+ Array.isArray(config.localFolders) ? config.localFolders : [];
164
+ // Where people keep their own files and the folders they added (tryharness local add), searched or not: what is
165
+ // in them stays on their computers when shared.
166
+ const ownFolders = () =>
167
+ existing([
168
+ ...OWN_FOLDERS.map((name) => path.join(os.homedir(), name)),
169
+ ...added(readJson(configPath, {})),
170
+ ]);
171
+ // The folders the library searches, which the person picked in setup (`searchFolders`, names of Desktop, Documents
172
+ // and Downloads): macOS asks before Harness may read each of those, so one never picked is never read. A computer
173
+ // set up before setup asked searches all three, unless search is off.
174
+ const libraryFolders = () => {
175
+ const config = readJson(configPath, {});
176
+ if (config.libraryOff === true) return [];
177
+ const picked = Array.isArray(config.searchFolders)
178
+ ? OWN_FOLDERS.filter((name) => config.searchFolders.includes(name))
179
+ : OWN_FOLDERS;
180
+ return existing([
181
+ ...picked.map((name) => path.join(os.homedir(), name)),
182
+ ...added(config),
183
+ ]);
166
184
  };
167
- // The folders the library searches: the person's own, unless they turned search off.
168
- const libraryFolders = () =>
169
- readJson(configPath, {}).libraryOff === true ? [] : ownFolders();
170
185
  /** Whether a file is in one of the person's own folders, after links are followed. */
171
186
  const inOwnFolder = (file) => {
172
187
  let real;
package/lib/mcp-stdio.mjs CHANGED
@@ -1465,6 +1465,12 @@ async function relay(line) {
1465
1465
  return;
1466
1466
  }
1467
1467
  if (request.method === "notifications/initialized") return;
1468
+ // The agent loading Harness's tools: what setup's tool check needs to hear, whether or not the agent's model then
1469
+ // calls one (a small local model can answer without calling anything).
1470
+ if (request.method === "tools/list")
1471
+ daemonRequest({ command: "agent.toolsListed", agent }, 2_000).catch(
1472
+ () => {}
1473
+ );
1468
1474
 
1469
1475
  const config = readJson(paths.config, {});
1470
1476
  if (!config.origin || !config.token) {
@@ -1,4 +1,5 @@
1
1
  import { fileURLToPath } from "node:url";
2
+ import { harnessNode } from "./paths.mjs";
2
3
 
3
4
  /** One owned Muse session, including tools and frames sent during its opening handshake. */
4
5
  export async function openMuseSession({
@@ -70,7 +71,7 @@ export async function openMuseSession({
70
71
  harness: {
71
72
  transport: "stdio",
72
73
  mode: "required",
73
- command: process.execPath,
74
+ command: harnessNode(),
74
75
  args: [
75
76
  fileURLToPath(new URL("./mcp-stdio.mjs", import.meta.url)),
76
77
  "--agent",
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
- import { paths } from "./paths.mjs";
4
+ import { harnessNode, paths } from "./paths.mjs";
5
5
 
6
6
  // The Harness extension finds the daemon on its own computer through Chrome's native messaging: Chrome starts this
7
7
  // host for the extension, one message in and one answer out, so the Harness window links to the computer it runs on
@@ -61,7 +61,7 @@ const manifestFor = (program) => ({
61
61
  */
62
62
  export function installNativeHost({
63
63
  runtimeRoot,
64
- nodePath = process.execPath,
64
+ nodePath = harnessNode(),
65
65
  platform = process.platform,
66
66
  home = os.homedir(),
67
67
  folders = browserFolders(platform, home),
@@ -142,6 +142,13 @@ export async function serveNativeHost({
142
142
  }
143
143
  return { ok: true, listening: true };
144
144
  }
145
+ // The page the person is on (the extension's computerPage.js), for the buddy's chip.
146
+ if (message?.type === "active-page") {
147
+ await daemon({ command: "browser.page.set", page: message.page }).catch(
148
+ () => null
149
+ );
150
+ return { ok: true };
151
+ }
145
152
  try {
146
153
  if (message?.type === "this-computer") {
147
154
  const found = await daemon({ command: "phone.identity" });
@@ -221,6 +228,8 @@ export async function serveNativeHost({
221
228
  }
222
229
  }
223
230
  closed = true;
231
+ // The browser went: no page is the one the person is on any more.
232
+ await daemon({ command: "browser.page.set", page: null }).catch(() => null);
224
233
  }
225
234
 
226
235
  export function writeMessage(output, message) {
package/lib/network.mjs CHANGED
@@ -91,6 +91,7 @@ export function createNetwork({
91
91
  project,
92
92
  sender: peer.handle,
93
93
  fingerprint: keyPrint,
94
+ createdAt: thread.createdAt,
94
95
  });
95
96
  if (thread.role === "asker")
96
97
  sent.push({ id: thread.id, status: thread.status, project });