tryharness 0.7.78 → 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 (63) 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 +21 -1
  8. package/lib/browserPage.mjs +30 -0
  9. package/lib/coordinator.mjs +0 -2
  10. package/lib/daemon.mjs +117 -7
  11. package/lib/desktop.mjs +7 -1
  12. package/lib/dispatcher.mjs +12 -2
  13. package/lib/environments.mjs +4 -11
  14. package/lib/goalCommands.mjs +18 -8
  15. package/lib/hookDialects.mjs +2 -1
  16. package/lib/jobAnswers.mjs +2 -1
  17. package/lib/kanban.mjs +217 -48
  18. package/lib/localStack.mjs +24 -9
  19. package/lib/machineRoutes.mjs +9 -0
  20. package/lib/machineRuns.mjs +9 -1
  21. package/lib/manager.mjs +60 -2
  22. package/lib/mcp-stdio.mjs +9 -3
  23. package/lib/museSession.mjs +2 -1
  24. package/lib/nativeHost.mjs +11 -2
  25. package/lib/network.mjs +20 -0
  26. package/lib/notify.mjs +48 -16
  27. package/lib/onboard.mjs +71 -366
  28. package/lib/ownMachines.mjs +95 -44
  29. package/lib/pairing.mjs +0 -84
  30. package/lib/paths.mjs +17 -0
  31. package/lib/peopleBoard.mjs +131 -0
  32. package/lib/personNotices.mjs +9 -25
  33. package/lib/phones.mjs +1 -0
  34. package/lib/profile.mjs +0 -109
  35. package/lib/projectBoard.mjs +219 -0
  36. package/lib/projectPieces.mjs +26 -0
  37. package/lib/projects.mjs +37 -4
  38. package/lib/removeHarness.mjs +91 -0
  39. package/lib/roomChannels.mjs +2 -0
  40. package/lib/runAuthority.mjs +23 -9
  41. package/lib/runBrief.mjs +20 -14
  42. package/lib/runner.mjs +3 -3
  43. package/lib/runtime-install.mjs +22 -2
  44. package/lib/screen.mjs +133 -0
  45. package/lib/selfUpdate.mjs +6 -6
  46. package/lib/service.mjs +120 -7
  47. package/lib/sessionControl.mjs +10 -0
  48. package/lib/setupChoices.mjs +400 -0
  49. package/lib/setupMode.mjs +137 -0
  50. package/lib/store.mjs +6 -3
  51. package/lib/swarm.mjs +181 -61
  52. package/lib/t3.mjs +23 -14
  53. package/lib/taskCommands.mjs +25 -15
  54. package/lib/taskRooms.mjs +2 -4
  55. package/lib/threadActions.mjs +16 -4
  56. package/lib/threadAuthority.mjs +28 -10
  57. package/lib/threadRuns.mjs +162 -74
  58. package/lib/toolCheck.mjs +136 -0
  59. package/lib/ui.mjs +15 -1
  60. package/lib/wakes.mjs +3 -3
  61. package/npm-shrinkwrap.json +14 -14
  62. package/package.json +4 -4
  63. package/release.json +64 -55
@@ -45,6 +45,7 @@ import { WINDOW_TOOLS } from "./windowAsks.mjs";
45
45
  import { createCallSessions } from "./callSessions.mjs";
46
46
  import { VIEW_COMMAND, VIEW_DROP_COMMAND } from "./liveViews.mjs";
47
47
  import { computerAddress } from "./computerAddress.mjs";
48
+ import { RUN_CALLER } from "./runAuthority.mjs";
48
49
 
49
50
  export { FROM_MACHINE };
50
51
 
@@ -182,6 +183,12 @@ export function createOwnMachines({
182
183
  answerLink = null,
183
184
  // Home asking whether this computer can do a piece of work (capabilityCheck.mjs), only over its sealed ask.
184
185
  answerCapability = null,
186
+ // This computer's folders for a composer on home whose message names this computer (folders.mjs): the folders worked
187
+ // in here (`{ places: true }`) or the folders in a typed path (`{ browse }`).
188
+ ownFolders = async () => ({
189
+ ok: false,
190
+ error: "this computer cannot list its folders",
191
+ }),
185
192
  // A cloud computer's own SSH keys (cloudSsh.mjs allow): { key, by } in, null on a computer that takes none.
186
193
  ownSsh = null,
187
194
  // This computer updating itself to a published release (daemon.mjs): `tryharness upgrade <spec>`, which takes only a
@@ -1298,6 +1305,18 @@ export function createOwnMachines({
1298
1305
  }
1299
1306
  };
1300
1307
 
1308
+ // The run here that made a call, as home reads it (runAuthority.mjs callerRun): its id, for counting hand-offs, and
1309
+ // how it was held in, so what it asks for is held in on home too. Work another person asked for asks as a held-in
1310
+ // run: home has no record of where such a run may reach (runAuthority.mjs privateReach). Never a caller's own word.
1311
+ const sealedRun = (request) => {
1312
+ const run = request[RUN_CALLER];
1313
+ if (!run) return undefined;
1314
+ return {
1315
+ id: run.id,
1316
+ review: run.review === true,
1317
+ restricted: run.restricted === true || run.forAnotherPerson === true,
1318
+ };
1319
+ };
1301
1320
  const stripLocal = (request) => {
1302
1321
  const {
1303
1322
  agent,
@@ -1453,11 +1472,12 @@ export function createOwnMachines({
1453
1472
  const pinned = pinnedHome();
1454
1473
  if (!pinned) return homeListed() ? notJoined() : offline();
1455
1474
  // A task started here gets its id here, so it is the same task whether home takes it now or once it is back.
1456
- const call = stripLocal(
1457
- request.command === "board.post" && request.id == null
1475
+ const call = stripLocal({
1476
+ ...(request.command === "board.post" && request.id == null
1458
1477
  ? { ...request, id: randomUUID() }
1459
- : request
1460
- );
1478
+ : request),
1479
+ fromRun: sealedRun(request),
1480
+ });
1461
1481
  if (call.command === "board.file.add" && call.path != null)
1462
1482
  return (await attach(pinned, call)) ?? offline();
1463
1483
  if (call.command === "board.file.get" && call.offset === undefined)
@@ -2102,24 +2122,26 @@ export function createOwnMachines({
2102
2122
  ? await answerCapability(call.capability)
2103
2123
  : call.inventory === true
2104
2124
  ? { ok: true, folders: folders({ fresh: true }) }
2105
- : call.home === true
2106
- ? await becomeHome(call.computers)
2107
- : call.link && answerLink
2108
- ? await answerLink(pinned.machine_id, call.link)
2109
- : call.models
2110
- ? await ownModels(call.models)
2111
- : call.live
2112
- ? await ownLive(call.live)
2113
- : call.ssh
2114
- ? ownSshAllow(call.ssh)
2115
- : call.update
2116
- ? ownUpdateChecked(call.update)
2117
- : WINDOW_TOOLS.has(call.tool)
2118
- ? await askOwnWindows(call)
2119
- : {
2120
- ok: false,
2121
- error: `home cannot ask this computer's windows for ${call.tool}`,
2122
- };
2125
+ : call.folders
2126
+ ? await ownFolders(call.folders)
2127
+ : call.home === true
2128
+ ? await becomeHome(call.computers)
2129
+ : call.link && answerLink
2130
+ ? await answerLink(pinned.machine_id, call.link)
2131
+ : call.models
2132
+ ? await ownModels(call.models)
2133
+ : call.live
2134
+ ? await ownLive(call.live)
2135
+ : call.ssh
2136
+ ? ownSshAllow(call.ssh)
2137
+ : call.update
2138
+ ? ownUpdateChecked(call.update)
2139
+ : WINDOW_TOOLS.has(call.tool)
2140
+ ? await askOwnWindows(call)
2141
+ : {
2142
+ ok: false,
2143
+ error: `home cannot ask this computer's windows for ${call.tool}`,
2144
+ };
2123
2145
  return {
2124
2146
  envelope: await sealAskAnswer(
2125
2147
  key,
@@ -2226,7 +2248,10 @@ export function createOwnMachines({
2226
2248
  for (const { agent, machine: computer } of store.agentsSeenOnComputers(
2227
2249
  since
2228
2250
  )) {
2229
- if (member(agent)?.runs !== "self") continue;
2251
+ const seen = member(agent);
2252
+ if (seen?.runs !== "self") continue;
2253
+ // One that can be handed work runs in its own cloud, wherever it last called the board from.
2254
+ if (seen.road === "hosted" && seen.target) continue;
2230
2255
  (found[computer] ??= []).push(agent);
2231
2256
  }
2232
2257
  return found;
@@ -2851,23 +2876,56 @@ export function createOwnMachines({
2851
2876
  );
2852
2877
  return sibling ? { machine: sibling.id, folder: null } : null;
2853
2878
  }
2879
+ const withAgent = siblings.filter(
2880
+ (each) => each.agents.includes(agent) && store.ownMachine(each.id)
2881
+ );
2882
+ const checkout = withAgent
2883
+ .map((each) => ({
2884
+ machine: each.id,
2885
+ folder: checkoutOn(each.id, workspace),
2886
+ }))
2887
+ .find((place) => place.folder);
2888
+ if (checkout) return checkout;
2889
+ // One not yet saying which folders it has may hold a checkout: the turn waits for it, as before.
2890
+ if (withAgent.some((each) => inventoryOf(each.id).state !== "ready"))
2891
+ return null;
2892
+ // No computer with the agent has a checkout of the thread's folder: one takes the turn in its own scratch folder,
2893
+ // an online one first.
2894
+ const scratch =
2895
+ withAgent.find((each) => each.connected) ?? withAgent[0] ?? null;
2896
+ return scratch ? { machine: scratch.id, folder: null } : null;
2897
+ };
2898
+
2899
+ /** On home: that computer's checkout of the repository a folder here holds, from its inventory; null when none. */
2900
+ const checkoutOn = (id, workspace) => {
2901
+ if (inventoryOf(id).state !== "ready") return null;
2854
2902
  const repository = repositoryOf(workspace);
2855
2903
  if (!repository) return null;
2856
- for (const sibling of siblings) {
2857
- if (!sibling.agents.includes(agent) || !store.ownMachine(sibling.id))
2858
- continue;
2859
- if (inventoryOf(sibling.id).state !== "ready") continue;
2860
- const folder = infos
2861
- .get(sibling.id)
2862
- ?.folders.find((each) => each.repository === repository)?.path;
2863
- if (folder) return { machine: sibling.id, folder };
2864
- }
2865
- return null;
2904
+ return (
2905
+ infos.get(id)?.folders.find((each) => each.repository === repository)
2906
+ ?.path ?? null
2907
+ );
2908
+ };
2909
+
2910
+ /** On home: another computer's folders for the composer (`{ places: true }` or `{ browse }`), asked there. */
2911
+ const foldersOn = async (id, question) => {
2912
+ const label = labelOf(id) ?? "that computer";
2913
+ const sibling = siblings.find((each) => each.id === id);
2914
+ if (!sibling || !store.ownMachine(id))
2915
+ return { ok: false, error: `${label} is not connected` };
2916
+ if (!sibling.connected) return { ok: false, error: `${label} is offline` };
2917
+ return (
2918
+ (await askWorker(id, { folders: question })) ?? {
2919
+ ok: false,
2920
+ error: `${label} did not answer`,
2921
+ }
2922
+ );
2866
2923
  };
2867
2924
 
2868
2925
  /**
2869
2926
  * On home: the other computer named for an agent's thread turn (`@codex #pop-os`) and its checkout of the thread's
2870
- * repository, or why it cannot take it.
2927
+ * repository, or why it cannot take it. With no checkout there (or a folder that is no repository) the turn works
2928
+ * in that computer's scratch folder: `folder` is null.
2871
2929
  */
2872
2930
  const placeOn = (agent, workspace, id) => {
2873
2931
  const sibling = siblings.find((each) => each.id === id);
@@ -2885,16 +2943,7 @@ export function createOwnMachines({
2885
2943
  error: `${label}'s repository inventory is not ready`,
2886
2944
  waits: true,
2887
2945
  };
2888
- const repository = repositoryOf(workspace);
2889
- const folder = repository
2890
- ? infos.get(id)?.folders.find((each) => each.repository === repository)
2891
- ?.path
2892
- : null;
2893
- if (!folder)
2894
- return {
2895
- error: `${label} has no copy of this thread's repository: clone it there first`,
2896
- };
2897
- return { machine: id, folder };
2946
+ return { machine: id, folder: checkoutOn(id, workspace) };
2898
2947
  };
2899
2948
 
2900
2949
  /** The computers the board may name: this one and every other the person has, with their agents and repositories. */
@@ -3051,6 +3100,8 @@ export function createOwnMachines({
3051
3100
  refreshInventory,
3052
3101
  placeElsewhere,
3053
3102
  placeOn,
3103
+ checkoutOn,
3104
+ foldersOn,
3054
3105
  addressIn,
3055
3106
  computersWith,
3056
3107
  computersFor,
package/lib/pairing.mjs CHANGED
@@ -127,87 +127,3 @@ export function hasBattery() {
127
127
  }
128
128
  return true;
129
129
  }
130
-
131
- // How long setup waits, at its end, for the person to type this computer's code on home. It works on its own meanwhile,
132
- // so the wait only lets setup say it joined; the person may close it.
133
- const JOIN_WAIT_MS = 10 * 60_000;
134
- // How long a computer approved from home's buddy usually takes to be confirmed there, before setup says where to type.
135
- const JOIN_QUIET_MS = 8_000;
136
-
137
- const names = (labels) =>
138
- labels.length > 1
139
- ? `${labels.slice(0, -1).join(", ")} and ${labels.at(-1)}`
140
- : labels[0];
141
-
142
- /**
143
- * At the end of setup, once the daemon is connected: Harness has made this computer home or added it. An added one not
144
- * confirmed yet works on its own board until the person types its code on home (ownMachines.mjs); setup says where and
145
- * waits for it, then may offer home to a computer that suits that better. On home, the computers that still need their
146
- * code typed here are named. Returns the role. `daemonRequest` reaches this computer's daemon.
147
- */
148
- export async function joinSwarm({
149
- ui,
150
- code,
151
- daemonRequest,
152
- battery = hasBattery,
153
- quietMs = JOIN_QUIET_MS,
154
- waitMs = JOIN_WAIT_MS,
155
- }) {
156
- const read = () =>
157
- daemonRequest({ command: "machines.list" }).catch(() => null);
158
- let listed = await read();
159
- if (!listed?.ok) return "home";
160
- if (listed.self.role !== "worker") {
161
- const waiting = listed.machines
162
- .filter((machine) => machine.role === "worker" && !machine.confirmed)
163
- .map((machine) => machine.label);
164
- if (waiting.length)
165
- ui.info(
166
- `${names(waiting)} ${waiting.length > 1 ? "are" : "is"} on your account but not in your swarm here yet, and ${waiting.length > 1 ? "each works" : "works"} on its own meanwhile. To bring ${waiting.length > 1 ? "each" : "it"} in, run npx tryharness machines there and type the code it shows here: Add a Computer in the Harness menu.`
167
- );
168
- return "home";
169
- }
170
- const homeName = () =>
171
- listed.machines.find((machine) => machine.role === "home")?.label ||
172
- "your home computer";
173
- if (listed.joinCode) {
174
- const spin = ui.spinner();
175
- spin.start(`Joining your swarm on ${homeName()}`);
176
- const started = Date.now();
177
- let told = false;
178
- while (listed?.joinCode && Date.now() - started < waitMs) {
179
- // The steps go above the spinner once: a spinner line wider than the terminal wraps, and every frame then
180
- // prints it again.
181
- if (!told && Date.now() - started > quietMs) {
182
- told = true;
183
- spin.stop(`Waiting for ${homeName()}`);
184
- ui.info(
185
- `On ${homeName()}, click the Harness icon in the menu bar, choose Add a Computer, and type ${listed.joinCode}${listed.joinCode === code ? " (the same code)" : ""}. Or run there: npx tryharness machines add ${listed.joinCode}. This computer already works on its own, so you can close this.`
186
- );
187
- spin.start(`Waiting for ${homeName()}`);
188
- }
189
- await new Promise((resolve) => setTimeout(resolve, 1_000));
190
- listed = (await read()) ?? listed;
191
- }
192
- if (listed.joinCode) {
193
- spin.stop(
194
- `This computer works on its own until it joins your swarm. To bring it in, type ${listed.joinCode} on ${homeName()}: Add a Computer in the Harness menu there, or npx tryharness machines add ${listed.joinCode}. What it does meanwhile goes to ${homeName()} when it joins.`
195
- );
196
- return "worker";
197
- }
198
- spin.stop(`Joined your swarm. ${homeName()} holds the board.`);
199
- } else ui.success(`In your swarm. ${homeName()} holds the board.`);
200
- if (!ui.interactive || battery()) return "worker";
201
- const move = await ui.confirm({
202
- message: `This computer stays on, so work could go on here while ${homeName()} sleeps. Make it your main computer? Your threads and board come with it.`,
203
- initialValue: false,
204
- });
205
- if (!move) return "worker";
206
- const moved = await daemonRequest({ command: "machines.home" }, 20_000);
207
- if (!moved.ok) {
208
- ui.warn(`Not moved: ${moved.error}`);
209
- return "worker";
210
- }
211
- ui.success("This is your main computer now.");
212
- return "home";
213
- }
package/lib/paths.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import fs from "node:fs";
1
2
  import os from "node:os";
2
3
  import path from "node:path";
3
4
 
@@ -45,10 +46,26 @@ export const paths = {
45
46
  files: path.join(harnessHome, "files"),
46
47
  runtime: path.join(harnessHome, "runtime"),
47
48
  models: path.join(harnessHome, "models"),
49
+ // Harness's own Node.js, which install.sh downloads and checks (see harnessNode).
50
+ node: path.join(harnessHome, "node"),
48
51
  legacyBridgeConfig: path.join(harnessHome, "bridge.json"),
49
52
  legacySpool: path.join(harnessHome, "pending-sessions.json"),
50
53
  };
51
54
 
55
+ /**
56
+ * The Node.js everything Harness starts runs on: the daemon's service, the installed command, and each agent's Harness
57
+ * MCP server and hooks. Harness's own, in ~/.harness/node, when install.sh put it there, so a Node manager removing the
58
+ * version setup ran on cannot stop Harness later. Someone who set up with plain `npx tryharness` has none, and Harness
59
+ * runs on the Node that ran setup.
60
+ */
61
+ export function harnessNode() {
62
+ const program =
63
+ process.platform === "win32"
64
+ ? path.join(paths.node, "node.exe")
65
+ : path.join(paths.node, "bin", "node");
66
+ return fs.existsSync(program) ? program : process.execPath;
67
+ }
68
+
52
69
  export function historyRoots(agent) {
53
70
  if (agent === "claude-code")
54
71
  return [
@@ -0,0 +1,131 @@
1
+ // The board of the work between the person's swarm and one other person's (Collab, People): every ask between the
2
+ // two swarms as a card, either way. It is read from the asks' own states, which both computers already hold (Harness's
3
+ // status of each ask, the messages, its end), so each side shows the same cards and nothing new crosses:
4
+ // - To do: asked, not accepted yet. Waiting on the person when it is theirs to accept.
5
+ // - In progress: accepted and open. Live while the person's agent works it; waiting on the person when a reply of
6
+ // their agent's is held for them to send.
7
+ // - Review: the side asked answered last, and the asker has not ended it.
8
+ // - Done: ended. One declined, blocked or expired is marked blocked with why.
9
+ import { nameOf } from "./members.mjs";
10
+ import { oneLine } from "./oneLine.mjs";
11
+
12
+ const OPEN = new Set(["accepted", "accepted_pending"]);
13
+ const REFUSED = {
14
+ declined: (item) =>
15
+ item.role === "target" ? "You declined" : `${item.peer.handle} declined`,
16
+ blocked: () => "Blocked",
17
+ expired: () => "Expired without an answer",
18
+ };
19
+ const TRAIL = 6;
20
+ const LIVE = new Set(["claimed", "running"]);
21
+
22
+ const theirs = (item) =>
23
+ item.peer.agent === "person"
24
+ ? item.peer.handle
25
+ : `${item.peer.handle}'s ${nameOf(item.peer.agent)}`;
26
+ const yours = (item) =>
27
+ item.mine === "person" || item.mine === "user"
28
+ ? "you"
29
+ : `your ${nameOf(item.mine)}`;
30
+ // Only the person's own side starts with a word to capitalize: a handle keeps its own case.
31
+ const capital = (text) => (text.startsWith("you") ? `Y${text.slice(1)}` : text);
32
+ const day = (at) =>
33
+ at
34
+ ? new Date(at).toLocaleDateString("en-US", {
35
+ month: "short",
36
+ day: "numeric",
37
+ })
38
+ : null;
39
+
40
+ /** One ask as its card, from the conversation (network.mjs item) and its messages. */
41
+ function cardOf(item, messages) {
42
+ const asker = item.role === "asker" ? yours(item) : theirs(item);
43
+ const asked = item.role === "asker" ? theirs(item) : yours(item);
44
+ const here = item.thread;
45
+ const ended =
46
+ item.group === "ended" || (here && !here.open) || item.status === "closed";
47
+ const last = messages.at(-1) ?? null;
48
+ // The side asked answered last: the asked side sends out when it is this side, in when it is theirs.
49
+ const answered =
50
+ Boolean(last) &&
51
+ messages.length > 1 &&
52
+ last.direction === (item.role === "target" ? "out" : "in");
53
+ const card = {
54
+ id: item.id,
55
+ title: oneLine(item.about || "A message", 120),
56
+ route: `${capital(asker)} → ${asked}`,
57
+ column: "doing",
58
+ agent: item.role === "target" ? item.mine : null,
59
+ holder: null,
60
+ status: null,
61
+ note: null,
62
+ blocked: null,
63
+ needsYou: null,
64
+ tasks: [item.id],
65
+ by: item.role === "asker" ? item.mine : item.peer.handle,
66
+ at: item.updatedAt ?? item.createdAt ?? null,
67
+ history: messages.slice(-TRAIL).map((message) => ({
68
+ at: message.created_at,
69
+ by: message.direction === "in" ? item.peer.handle : message.sender,
70
+ text: `${capital(message.direction === "in" ? theirs(item) : message.sender === "user" ? "you" : `your ${nameOf(message.sender)}`)}: ${oneLine(message.text, 200)}`,
71
+ })),
72
+ };
73
+ if (REFUSED[item.status]) {
74
+ card.column = "done";
75
+ card.blocked = REFUSED[item.status](item);
76
+ card.status = card.blocked;
77
+ } else if (item.status === "requested") {
78
+ card.column = "todo";
79
+ if (item.role === "target") {
80
+ card.needsYou = "accept or decline it";
81
+ card.status = "Accept or decline";
82
+ } else card.status = `Waiting on ${item.peer.handle}`;
83
+ } else if (ended) {
84
+ card.column = "done";
85
+ const on = day(item.updatedAt);
86
+ card.status = on ? `Ended ${on}` : "Ended";
87
+ card.note = here?.outcome ? oneLine(here.outcome, 200) : null;
88
+ } else if (here?.held) {
89
+ card.needsYou = "a reply waits for you to send";
90
+ card.status = "Reply to send";
91
+ } else if (answered) {
92
+ card.column = "review";
93
+ card.status =
94
+ item.role === "asker"
95
+ ? "Answered, yours to close"
96
+ : `Answered, ${item.peer.handle}'s to close`;
97
+ } else if (!OPEN.has(item.status) && !here) card.status = item.status;
98
+ return card;
99
+ }
100
+
101
+ /**
102
+ * The board between this swarm and one other person's: its cards, and as runs the asks the person's own agents are
103
+ * working now (the board marks those live).
104
+ */
105
+ export function peopleBoard(items, { handle, messagesOf, taskOf }) {
106
+ const withThem = items.filter(
107
+ (item) => item.peer.handle === String(handle).toLowerCase()
108
+ );
109
+ const cards = withThem.map((item) => cardOf(item, messagesOf(item.id)));
110
+ const runs = withThem
111
+ .filter((item) => item.role === "target")
112
+ .map((item) => ({ item, task: taskOf(item.id) }))
113
+ .filter(({ task }) => task && LIVE.has(task.status))
114
+ .map(({ item, task }) => ({
115
+ id: item.id,
116
+ agent: item.mine,
117
+ status: task.status,
118
+ startedAt: task.claimed_at ?? task.updated_at,
119
+ steps: [],
120
+ }));
121
+ for (const card of cards)
122
+ if (runs.some((run) => run.id === card.id))
123
+ card.holder = capital(yours(withThem.find((i) => i.id === card.id)));
124
+ return {
125
+ handle,
126
+ cards,
127
+ runs,
128
+ asks: cards.length,
129
+ needsYou: cards.filter((card) => card.needsYou).length,
130
+ };
131
+ }
@@ -1,17 +1,13 @@
1
1
  import { readJson } from "./files.mjs";
2
2
  import { nameOf } from "./members.mjs";
3
- import { notificationFor, notifyDesktop } from "./notify.mjs";
4
-
5
- // How long since the buddy last collected its notices before the system's own notice says them instead.
6
- const BUDDY_GONE_MS = 10_000;
7
- const BUDDY_KEEPS = 50;
3
+ import { notificationFor, notifyDesktop, takeNotices } from "./notify.mjs";
8
4
 
9
5
  /**
10
6
  * What the person is told about the board, whether or not Harness is open: on the desktop in words, and to their
11
7
  * installed phone as only the kind of thing that waits, so a tap opens it there. Each item is told once.
12
8
  *
13
- * The buddy posts the desktop's notices itself while it runs, so a click opens the item there: it collects them every
14
- * two seconds. Once it has not for ten, the system's own notice says the same words.
9
+ * On a Mac the buddy posts the desktop's notices itself, so a click opens the item there: it collects them every two
10
+ * seconds, and what it has not collected waits for its next launch (notify.mjs).
15
11
  *
16
12
  * Notices are off with `tryharness notify off` (`notifications: false` in the config). Nothing is said while the Mac is
17
13
  * in Standby (`quiet()`). `threadView()` reads a thread as every surface does (threadView.mjs), made after this module.
@@ -26,26 +22,14 @@ export function createPersonNotices({
26
22
  }) {
27
23
  const on = () => readJson(configPath, {}).notifications !== false;
28
24
 
29
- /** A desktop notice, when the person has them on. */
30
- const notify = (text) => {
31
- if (on()) notifyDesktop(text);
25
+ /** A desktop notice, when the person has them on; `thread` is what a click opens. */
26
+ const notify = (text, { thread } = {}) => {
27
+ if (on()) notifyDesktop(text, { thread });
32
28
  };
33
29
 
34
- const forBuddy = { notices: [], collectedAt: 0 };
35
- const buddyCollects = () => Date.now() - forBuddy.collectedAt < BUDDY_GONE_MS;
36
-
37
- /** A notice that opens `item` in `thread` when clicked: the buddy's while it collects them, the system's otherwise. */
38
- const tellDesktop = (title, line, thread, item) => {
39
- if (!buddyCollects()) return notifyDesktop(`${title}: ${line}`);
40
- forBuddy.notices.push({ title, body: line, thread, item });
41
- forBuddy.notices.splice(0, forBuddy.notices.length - BUDDY_KEEPS);
42
- };
43
-
44
- /** The buddy collects what it should post. */
45
- const takeNotices = () => {
46
- forBuddy.collectedAt = Date.now();
47
- return forBuddy.notices.splice(0);
48
- };
30
+ /** A notice that opens `item` in `thread` when clicked. */
31
+ const tellDesktop = (title, line, thread, item) =>
32
+ notifyDesktop(line, { title, thread, item });
49
33
 
50
34
  const firstTime = (id) => {
51
35
  if (store.meta(`told:${id}`)) return false;
package/lib/phones.mjs CHANGED
@@ -95,6 +95,7 @@ const WITHOUT_GESTURE = new Set([
95
95
  "board.live.read",
96
96
  "board.standing.check",
97
97
  "board.relay.list",
98
+ "board.relay.board",
98
99
  "board.relay.network",
99
100
  "board.relay.peers",
100
101
  "board.relay.seen",
package/lib/profile.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  import fs from "node:fs";
2
- import pc from "picocolors";
3
2
  import { readJson, writeJsonAtomic } from "./files.mjs";
4
3
  import { paths } from "./paths.mjs";
5
4
  import { ARCHETYPE_IDS, archetypeBrief } from "./archetypes.js";
@@ -65,114 +64,6 @@ export function keepProfile(profile, file = paths.profile) {
65
64
  else fs.rmSync(file, { force: true });
66
65
  }
67
66
 
68
- async function request(origin, token, init = {}) {
69
- const response = await fetch(
70
- `${String(origin).replace(/\/$/, "")}/api/mcp/profile`,
71
- {
72
- ...init,
73
- headers: {
74
- authorization: `Bearer ${token}`,
75
- "content-type": "application/json",
76
- },
77
- }
78
- );
79
- const body = await response.json().catch(() => null);
80
- if (!response.ok)
81
- throw Object.assign(
82
- new Error(body?.error || `Harness answered ${response.status}`),
83
- { status: response.status }
84
- );
85
- return body?.profile ?? {};
86
- }
87
-
88
- const preferenceCount = (profile) =>
89
- (profile.hardPreferences?.length ?? 0) +
90
- (profile.softPreferences?.length ?? 0);
91
-
92
- const plural = (count, word) => `${count} ${word}${count === 1 ? "" : "s"}`;
93
-
94
- async function ask(ui, profile) {
95
- ui.note(
96
- "Your agents work for you, so they should know who you are. What you write here is saved to your Harness account, so Harness and the agents on all your computers use it. Change it any time in Harness, Settings, Profile.",
97
- "About you"
98
- );
99
- const name = await ui.text({
100
- message: "What should your agents call you?",
101
- validate: (value) =>
102
- String(value ?? "").trim().length > NAME_LIMIT
103
- ? `Keep it under ${NAME_LIMIT} characters`
104
- : undefined,
105
- });
106
- const displayName = String(name ?? "").trim();
107
- if (!displayName) return null;
108
- const update = { displayName };
109
- if (!preferenceCount(profile)) {
110
- const said = await ui.text({
111
- message:
112
- "Anything they should always keep in mind about how you work? Press Enter to skip.",
113
- placeholder: "Keep answers short, and ask before deleting anything",
114
- validate: (value) =>
115
- String(value ?? "").trim().length > PREFERENCE_LIMIT
116
- ? `Keep it under ${PREFERENCE_LIMIT} characters`
117
- : undefined,
118
- });
119
- const preference = String(said ?? "").trim();
120
- if (preference) update.hardPreferences = [preference];
121
- }
122
- return update;
123
- }
124
-
125
- /**
126
- * Setup's step: imports the person's profile into this computer, asking for their name (and one preference, when they
127
- * have none) if their account has no name yet. Never stops setup: a profile Harness cannot give leaves the last import.
128
- */
129
- export async function setupProfile({
130
- ui,
131
- origin,
132
- token,
133
- file = paths.profile,
134
- }) {
135
- let profile;
136
- try {
137
- profile = await request(origin, token);
138
- } catch (error) {
139
- // A Harness from before profiles reached computers has no such page: nothing is wrong, so nothing is said.
140
- if (error.status === 404) return readProfile(file);
141
- ui.warn(
142
- `Your Harness profile did not load (${error.message}). Your agents will learn your name the next time you run setup.`
143
- );
144
- return readProfile(file);
145
- }
146
- if (!profile.displayName) {
147
- const update = ui.interactive ? await ask(ui, profile) : null;
148
- if (!update) {
149
- ui.info(
150
- "Your agents will not know your name yet. Add it any time in Harness, Settings, Profile, then run setup again."
151
- );
152
- return null;
153
- }
154
- try {
155
- profile = await request(origin, token, {
156
- method: "PUT",
157
- body: JSON.stringify(update),
158
- });
159
- } catch (error) {
160
- // The agents here still get it; the next setup, finding no name in the account, asks again.
161
- profile = { ...profile, ...update };
162
- ui.warn(
163
- `Saved on this computer, but not to your Harness account yet (${error.message}).`
164
- );
165
- }
166
- }
167
- profile = boundedProfile(profile);
168
- writeJsonAtomic(file, profile);
169
- const count = preferenceCount(profile);
170
- ui.success(
171
- `Your agents know you as ${pc.bold(profile.displayName)}${count ? `, with your ${plural(count, "preference")} from Harness` : ""}`
172
- );
173
- return profile;
174
- }
175
-
176
67
  /**
177
68
  * The profile as an agent is told it at the start of a run; empty without one. It comes from Harness's server, so it
178
69
  * reads as what the person told Harness about how they like to work, never as instructions above the task, its