tryharness 0.7.70 → 0.7.72

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.
@@ -1,4 +1,5 @@
1
1
  import fs from "node:fs";
2
+ import os from "node:os";
2
3
  import path from "node:path";
3
4
  import { within } from "./folders.mjs";
4
5
  import { provenanceLine } from "./provenance.mjs";
@@ -9,7 +10,7 @@ import { prepareScratch, threadScratch } from "./scratch.mjs";
9
10
  // is home's to give and stays on home's board; a worker only asks home for what is authorized for it, takes each task
10
11
  // in its agent's name, runs it here through the same runner as any run (taskRuns.mjs), and reports back to home, which
11
12
  // keeps the report while home is out of reach. Asked when home is back, when home says there is work, and when a run
12
- // ends; never on a timer. One run per folder at a time, as on home.
13
+ // ends; never on a timer. One run per agent per folder at a time, as on home.
13
14
  //
14
15
  // Home's stuck sweep (stuck.mjs) reads when each run last took a step. A run here has no record on home, so each new
15
16
  // step is told to home, sealed like every call: the first at once, then at most one a second per run (the rate home's
@@ -19,9 +20,11 @@ const STEP_NOTICE_MS = 1_000;
19
20
  // An agent's session id as this computer's agents name theirs; never one an agent's command line would read as a flag.
20
21
  const SESSION_ID = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$/;
21
22
  //
22
- // Home lists the work; this computer decides where it runs (security audit 2026-10-25, M6). A run starts only in a folder
23
- // this computer knows: one its own agents' sessions or T3 Code worked in, or a folder inside one. Any other folder home
24
- // names (another place on this disk, a folder of home's) is refused, and home's board says so, so the person sees why.
23
+ // Home lists the work; this computer decides where it runs (security audit 2026-10-25, M6). A run starts in a folder of
24
+ // this computer's below its home, as the person's own agents here may (owner, October 31: work they kicked off runs, it
25
+ // does not wait on folders they never limited), or in one its own agents' sessions or T3 Code worked in. A thread's turn naming home itself or above it, or this computer's
26
+ // scratch folder for the thread, works in that scratch folder. Any other folder home names (one this disk does not
27
+ // have, a folder of home's) is refused, and home's board says so, so the person sees why.
25
28
 
26
29
  const real = (dir) => {
27
30
  try {
@@ -35,6 +38,7 @@ export function createMachineRuns({
35
38
  callHome,
36
39
  taskRuns,
37
40
  agents,
41
+ // Folders this computer's own agents' sessions or T3 Code worked in, which count wherever they are.
38
42
  knownFolders = () => [],
39
43
  // The files of a thread, by id, as this computer's copy of the board has them: a folder-less thread's turn gets them
40
44
  // in its scratch folder.
@@ -68,17 +72,35 @@ export function createMachineRuns({
68
72
  clearTimeout(steps.get(taskId)?.timer);
69
73
  steps.delete(taskId);
70
74
  };
75
+ const home = real(os.homedir());
76
+ // An existing folder of this computer's below its home; home itself and above it never are.
77
+ const belowHome = (dir) => {
78
+ const folder = real(dir);
79
+ return Boolean(folder && home && folder !== home && within(folder, home));
80
+ };
71
81
  // A thread with no folder: its turn here works in that thread's scratch folder on this computer (scratch.mjs), as
72
- // does a task naming no folder that home says goes there (taskCommands.mjs forWorker).
73
- const inScratch = (task) =>
74
- !task.run_workspace &&
75
- Boolean(task.parent_id) &&
76
- (task.kind === "wake" || (task.kind === "task" && task.scratch === true));
82
+ // does a task naming no folder that home says goes there (taskCommands.mjs forWorker), and a thread's turn naming
83
+ // home or above it, or this computer's scratch path for it (a ComfyUI picture asked for in /home/saltorious once
84
+ // failed to start).
85
+ const inScratch = (task) => {
86
+ if (!task.parent_id) return false;
87
+ if (!task.run_workspace)
88
+ return (
89
+ task.kind === "wake" || (task.kind === "task" && task.scratch === true)
90
+ );
91
+ const named = path.resolve(task.run_workspace);
92
+ const folder = real(named);
93
+ return (
94
+ named === threadScratch(task.parent_id) ||
95
+ Boolean(folder && home && within(home, folder))
96
+ );
97
+ };
98
+ // One turn per agent per folder, other agents side by side (runWorker.mjs slotOf).
77
99
  const slotOf = (task) =>
78
- task.run_workspace
79
- ? path.resolve(task.run_workspace)
80
- : inScratch(task)
81
- ? threadScratch(task.parent_id)
100
+ inScratch(task)
101
+ ? `${threadScratch(task.parent_id)}:${task.target_agent}`
102
+ : task.run_workspace
103
+ ? `${path.resolve(task.run_workspace)}:${task.target_agent}`
82
104
  : task.target_agent;
83
105
  // The thread's files, from home, put in the scratch folder; one home cannot send is left out.
84
106
  const scratchFor = async (task) => {
@@ -197,15 +219,13 @@ export function createMachineRuns({
197
219
  path.isAbsolute(task.run_workspace)
198
220
  ? real(task.run_workspace)
199
221
  : null;
200
- if (
201
- folder &&
202
- knownFolders().some((known) => {
203
- const root = real(known);
204
- return root && within(folder, root);
205
- })
206
- )
207
- return null;
208
- return `This computer runs work from your home computer only in a folder its own agents have worked in, and ${task.run_workspace || "no folder"} is not one. Start it there in one of this computer's folders.`;
222
+ const known = (dir) =>
223
+ knownFolders().some((place) => {
224
+ const root = real(place);
225
+ return root && within(dir, root);
226
+ });
227
+ if (folder && (belowHome(folder) || known(folder))) return null;
228
+ return `${task.run_workspace || "No folder"} is not a folder on this computer below your home or one its agents worked in, so it could not start here.`;
209
229
  };
210
230
  // Taken in its agent's name and ended at once with the reason, so home's board shows why it did not run here.
211
231
  const refuse = async (task, reason) => {
package/lib/members.mjs CHANGED
@@ -46,6 +46,22 @@ try {
46
46
  } catch {}
47
47
  const byId = new Map(MEMBERS.map((entry) => [entry.id, entry]));
48
48
 
49
+ /**
50
+ * The person's own agents that can be handed work, whose asks a coding agent's standing permission may take: work the
51
+ * person kicked off through any of them runs without a second Start. They may unless the person took them off it
52
+ * (board.standing.set proposers). Another person's agents and any other name never qualify. Bankr spends only under its
53
+ * own approval and limits, so its asks of a coding agent are like any other.
54
+ */
55
+ export const PROPOSERS = MEMBERS.filter((entry) => entry.target).map(
56
+ (entry) => entry.id
57
+ );
58
+
59
+ /** Whether an agent's words reach this computer through Harness's server (Grok Bot, Bankr), not from a process here. */
60
+ export const speaksThroughHarness = (id) => {
61
+ const road = byId.get(String(id))?.road;
62
+ return road === "hosted" || road === "server";
63
+ };
64
+
49
65
  export const member = (id) => byId.get(String(id)) ?? null;
50
66
  export const ids = (keep = () => true) =>
51
67
  MEMBERS.filter(keep).map((entry) => entry.id);
@@ -184,6 +184,14 @@ export function createOwnMachines({
184
184
  answerPrompt = null,
185
185
  // A cloud computer's own SSH keys (cloudSsh.mjs allow): { key, by } in, null on a computer that takes none.
186
186
  ownSsh = null,
187
+ // This computer updating itself to a published release (daemon.mjs): `tryharness upgrade <spec>`, which takes only a
188
+ // release signed with Harness's release key, started on its own so it outlives the daemon it restarts.
189
+ ownUpdate = () => ({
190
+ ok: false,
191
+ error: "this computer cannot update itself",
192
+ }),
193
+ // The release this computer runs, which an update never goes back from.
194
+ runningVersion = "0.0.0",
187
195
  }) {
188
196
  // On home: each worker's folders and the repository each holds, as it said them.
189
197
  const infos = new Map();
@@ -2104,12 +2112,14 @@ export function createOwnMachines({
2104
2112
  ? await ownLive(call.live)
2105
2113
  : call.ssh
2106
2114
  ? ownSshAllow(call.ssh)
2107
- : WINDOW_TOOLS.has(call.tool)
2108
- ? await askOwnWindows(call)
2109
- : {
2110
- ok: false,
2111
- error: `home cannot ask this computer's windows for ${call.tool}`,
2112
- };
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
+ };
2113
2123
  return {
2114
2124
  envelope: await sealAskAnswer(
2115
2125
  key,
@@ -2554,6 +2564,68 @@ export function createOwnMachines({
2554
2564
  );
2555
2565
  };
2556
2566
 
2567
+ // ---- updating another of the person's computers (tryharness machines update) ----
2568
+
2569
+ /**
2570
+ * The person updating one of their computers to a published release, from home: "latest" or a version, never an
2571
+ * older one than it runs, and never any other npm spec (a git address or a file would run code no release key
2572
+ * signed). The computer fetches and checks it itself; home only asks, over the pair's sealed line.
2573
+ */
2574
+ const update = async ({ computer: named, version = "latest" } = {}) => {
2575
+ const spec = String(version || "latest");
2576
+ if (spec !== "latest" && !/^\d+\.\d+\.\d+$/.test(spec))
2577
+ return {
2578
+ ok: false,
2579
+ error: `${spec} is not a release: give a version like 0.7.72, or latest`,
2580
+ };
2581
+ const target =
2582
+ findMachine(all(), named)?.id ??
2583
+ store.ownMachines().find((pinned) => pinned.label === named)
2584
+ ?.machine_id ??
2585
+ String(named || machine.id);
2586
+ if (target === machine.id) return ownUpdateChecked({ version: spec });
2587
+ if (!isHome())
2588
+ return {
2589
+ ok: false,
2590
+ error: "Ask home to update your other computers: it holds their keys.",
2591
+ };
2592
+ const worker = siblings.find((sibling) => sibling.id === target);
2593
+ if (!worker || !confirmed(worker))
2594
+ return {
2595
+ ok: false,
2596
+ error: "that computer is not one of yours confirmed on home",
2597
+ };
2598
+ return (
2599
+ (await askWorker(target, { update: { version: spec } })) ?? {
2600
+ ok: false,
2601
+ error: `${worker.label} did not answer; it may be asleep or offline`,
2602
+ }
2603
+ );
2604
+ };
2605
+ // Numbers only: a local build (0.7.71-local.abc) counts as its release.
2606
+ const releaseOf = (version) =>
2607
+ String(version)
2608
+ .split("-")[0]
2609
+ .split(".")
2610
+ .map((part) => Number(part) || 0);
2611
+ const older = (spec, than) => {
2612
+ const [a, b] = [releaseOf(spec), releaseOf(than)];
2613
+ for (let i = 0; i < 3; i++) if (a[i] !== b[i]) return a[i] < b[i];
2614
+ return false;
2615
+ };
2616
+ /** On the computer updated: the same checks again, as home's word is not taken for them. */
2617
+ const ownUpdateChecked = ({ version } = {}) => {
2618
+ const spec = String(version || "latest");
2619
+ if (spec !== "latest" && !/^\d+\.\d+\.\d+$/.test(spec))
2620
+ return { ok: false, error: `${spec} is not a release` };
2621
+ if (spec !== "latest" && older(spec, runningVersion))
2622
+ return {
2623
+ ok: false,
2624
+ error: `${labelOf(machine.id) ?? "This computer"} runs ${runningVersion}; it never moves back to ${spec}.`,
2625
+ };
2626
+ return ownUpdate(spec);
2627
+ };
2628
+
2557
2629
  // ---- the person's SSH key into a cloud computer (cloudSsh.mjs) ----
2558
2630
 
2559
2631
  const ownSshAllow = (ssh) =>
@@ -2929,6 +3001,7 @@ export function createOwnMachines({
2929
3001
  readSession,
2930
3002
  openSession,
2931
3003
  setModel,
3004
+ update,
2932
3005
  allowSsh,
2933
3006
  status,
2934
3007
  all,
package/lib/plans.mjs CHANGED
@@ -265,7 +265,13 @@ export function createPlans({
265
265
  targetAgent: node.agent,
266
266
  parentId: threadId,
267
267
  });
268
- if (posted?.ok && posted.task?.id) {
268
+ // While the guard reads its words, the post answers { pending, task }: the task is in, and only whether it may
269
+ // start waits (taskCommands.mjs). Read as no answer, a step was once marked "could not be posted".
270
+ if (posted?.pending)
271
+ void posted.pending.catch((error) =>
272
+ log(`plan ${node.id} start not decided: ${error.message}`)
273
+ );
274
+ if ((posted?.ok || posted?.pending) && posted.task?.id) {
269
275
  node.taskId = posted.task.id;
270
276
  node.state = "posted";
271
277
  } else {
@@ -14,10 +14,20 @@ export const SETTINGS = {
14
14
  },
15
15
  start: {
16
16
  // Consent to code running on this computer from the other person's words (security audit P2, October 25): Claude
17
- // Code runs it restricted in a copy, any other agent still waits for the person's Start.
17
+ // Code or Codex runs it restricted in a copy (none of the person's credentials, no network, only the board and its
18
+ // own folder), any other agent still waits for the person's Start. On from the start: the person connected their
19
+ // swarm to a collaborator to get work done (owner, October 31: "if hes connecting his AI to another persons, they
20
+ // are a trusted party doing collaborative work"); either person turns it off at once.
18
21
  label:
19
22
  "Agents start work the other side asks for (this runs code on your computer)",
20
23
  values: [false, true],
24
+ initial: true,
25
+ },
26
+ // Harness works on this person's credits, so it answers the other side only when both let it: money stays behind
27
+ // consent (owner, October 31), apart from the agents starting each other's work above.
28
+ harness: {
29
+ label: "Harness answers the other side (on your Harness credits)",
30
+ values: [false, true],
21
31
  initial: false,
22
32
  },
23
33
  push: {
package/lib/projects.mjs CHANGED
@@ -580,9 +580,25 @@ export function createProjects({
580
580
  )
581
581
  .map(([side]) => ({ side, yes: true, at: proposal.at }))
582
582
  : [];
583
+ const answers = answersTo(p, proposal.id);
584
+ // An agreement this person joined with was accepted when they joined, though an answer to it from someone away
585
+ // since never reached this computer: once, a room's agreed setting read as still pending on the fourth person's,
586
+ // and an older narrowing won over it. It keeps its own time, so a narrowing after it still wins.
587
+ if (
588
+ !isFix(body) &&
589
+ group?.consents?.[p.me]?.[proposal.id] === agreementHash(body)
590
+ )
591
+ return {
592
+ state: "accepted",
593
+ waitingOn: [],
594
+ at: [proposal.at, ...answers.map((answer) => answer.at)]
595
+ .map(String)
596
+ .sort()
597
+ .at(-1),
598
+ };
583
599
  return proposalState(
584
600
  { ...body, needs: needsOf(p, body, proposal.side), at: proposal.at },
585
- [...implicit, ...answersTo(p, proposal.id)]
601
+ [...implicit, ...answers]
586
602
  );
587
603
  };
588
604
 
@@ -850,18 +866,18 @@ export function createProjects({
850
866
  String(event.id)
851
867
  );
852
868
  // The other side's words wake only the agents here they name; their unaddressed words are their own swarm's to sort.
853
- // Harness works on this person's credits, so the other side reaches it only when both let agents start their asks.
869
+ // Harness works on this person's credits, so the other side reaches it only when both let Harness answer them.
854
870
  const named = mentions.filter(
855
871
  (name) =>
856
872
  !name.includes("/") &&
857
873
  name !== "user" &&
858
874
  ownAgents(p).includes(name) &&
859
- (name !== "harness" || settingsOf(p).start)
875
+ (name !== "harness" || settingsOf(p).harness)
860
876
  );
861
877
  if (mentions.includes("harness") && !named.includes("harness"))
862
878
  note(
863
879
  p,
864
- `${display(p, event.author)} asked Harness. Harness answers the other side only once you both let agents start work the other side asks for.`
880
+ `${display(p, event.author)} asked Harness. Harness answers the other side only once you both let it, since it works on your Harness credits.`
865
881
  );
866
882
  // A clash the other side found with one of this side's pieces of work: the agent on it talks it out, read-only.
867
883
  const clash = Array.isArray(event.clash) ? event.clash.map(String) : [];
@@ -69,6 +69,24 @@ export function createPromptFlow({
69
69
  notify(store.getTask(job.task_id));
70
70
  return next;
71
71
  };
72
+ // Words no typed work here can take go to Harness as any message to it does, and wait for its window: they were held
73
+ // behind a card that asked the person about the error ("Harness is asking: No registered execution capability is
74
+ // available").
75
+ const toHarness = (job, why) => {
76
+ if (job.state === "cancelled") return job;
77
+ const task = store.postTask({
78
+ objective: job.prompt.slice(0, 500),
79
+ brief: job.prompt,
80
+ originAgent: "user",
81
+ targetAgent: "harness",
82
+ });
83
+ store.meta(`prompt-flow-task:${task.id}`, job.id);
84
+ store.removeTask(job.task_id);
85
+ const next = { ...job, state: "harness", task_id: task.id, why };
86
+ save(next);
87
+ notify(store.getTask(task.id));
88
+ return next;
89
+ };
72
90
  const applyReceipt = async (job, receipt) => {
73
91
  job = read(job.id);
74
92
  if (job.state === "cancelled") return job;
@@ -140,7 +158,8 @@ export function createPromptFlow({
140
158
  };
141
159
  const status = async (job) => {
142
160
  if (active.has(job.id)) return response(job);
143
- if (["done", "held", "cancelled"].includes(job.state)) return response(job);
161
+ if (["done", "held", "cancelled", "harness"].includes(job.state))
162
+ return response(job);
144
163
  if (job.state === "interpreting" && !job.assignment && !job.file_task)
145
164
  return response(
146
165
  held(
@@ -296,6 +315,15 @@ export function createPromptFlow({
296
315
  workspace: folder,
297
316
  capability_ref: "capability:workspace-files@1",
298
317
  });
318
+ // Nothing here can run typed work and the words name no computer: they are a message for Harness. Words that
319
+ // name a computer that cannot take them still wait for the person, never routed elsewhere.
320
+ const namesComputer = computers().some((c) =>
321
+ job.prompt.toLowerCase().includes(c.label.toLowerCase())
322
+ );
323
+ if (!candidates.length && !namesComputer) {
324
+ toHarness(read(job.id), "no registered execution capability");
325
+ return;
326
+ }
299
327
  if (!candidates.length)
300
328
  throw new Error("No registered execution capability is available");
301
329
  const modelInfo = decider.info();
@@ -498,6 +526,13 @@ export function createPromptFlow({
498
526
  );
499
527
  if (!job) return { ok: false, error: "Prompt work not found" };
500
528
  if (job.state === "done") return response(job);
529
+ // Handed to Harness as a plain message: taking it back removes it, as for any message to Harness.
530
+ if (job.state === "harness") {
531
+ store.removeTask(job.task_id);
532
+ save({ ...job, state: "cancelled" });
533
+ notify(store.getTask(job.task_id));
534
+ return response(read(job.id));
535
+ }
501
536
  store.dispatchTransaction(() => {
502
537
  const task = store.getTask(job.task_id);
503
538
  if (task.status === "needs_input") {
package/lib/redact.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import pngjs from "pngjs";
3
3
  import { decodeImage, imageKind } from "./ocr.mjs";
4
- import { secretReason } from "./secrets.mjs";
4
+ import { maskReason } from "./secrets.mjs";
5
5
  import {
6
6
  BASE58ISH,
7
7
  BECH32,
@@ -202,7 +202,7 @@ const nameLike = (text) =>
202
202
  /^[a-z0-9]+(?:[-._][a-z0-9]+)+$/.test(text) &&
203
203
  text.split(/[-._]/).some((part) => /^[a-z]{3,}$/.test(part));
204
204
  const secretish = (text) =>
205
- Boolean(secretReason(text)) ||
205
+ Boolean(maskReason(text)) ||
206
206
  (text.length >= 8 &&
207
207
  [/[a-z]/, /[A-Z]/, /\d/, /[^A-Za-z0-9]/].filter((re) => re.test(text))
208
208
  .length >= 3);
@@ -214,8 +214,8 @@ const shaped = (text) =>
214
214
  .replace(/^\w[\w.-]*=/, "")
215
215
  .replace(/^["'`(<[{]+|["'`)>\]},;.]+$/g, "");
216
216
  const start = m.index + m[0].lastIndexOf(token);
217
- return token.length >= 12 && secretReason(token)
218
- ? [{ start, end: start + token.length, reason: secretReason(token) }]
217
+ return token.length >= 12 && maskReason(token)
218
+ ? [{ start, end: start + token.length, reason: maskReason(token) }]
219
219
  : [];
220
220
  });
221
221
 
@@ -274,7 +274,7 @@ const uncased = (text) =>
274
274
  // counts only if it has a known key shape or mixes upper and lower case letters and digits (not the host or path left
275
275
  // beside a password).
276
276
  const keyLike = (text) =>
277
- Boolean(secretReason(text)) ||
277
+ Boolean(maskReason(text)) ||
278
278
  (text.length >= 16 &&
279
279
  /[a-z]/.test(text) &&
280
280
  /[A-Z]/.test(text) &&