tryharness 0.7.35 → 0.7.37

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.
@@ -45,6 +45,8 @@ export const MAX_FILE_BYTES = Math.max(
45
45
  );
46
46
  // One part of a file read through the sealed channel: 512 KiB is 683 KiB as base64, inside a sealed answer's 1 MB.
47
47
  const FILE_PART_BYTES = 512 * 1024;
48
+ // The most files one search across the person's threads answers with.
49
+ const FOUND_FILES = 20;
48
50
  const fileLimit = (mime, bytes) =>
49
51
  FILE_LIMITS.find((limit) =>
50
52
  limit.test(mime, bytes.subarray(0, 5).toString("latin1"))
@@ -339,6 +341,16 @@ export function createBoardFiles({
339
341
  laterAfter: page.laterAfter,
340
342
  };
341
343
  }
344
+ // Who attached a file, and in which thread, is a record, so Harness reads it instead of guessing from how a post
345
+ // was worded (a file Codex made in another thread was taken for Harness's own and left for the window, which could
346
+ // not find it either). Records only, scrubbed as posts are: a file is read in its own thread.
347
+ if (input.op === "find") {
348
+ const found = findFiles(String(input.query || ""), place.id);
349
+ return {
350
+ ok: true,
351
+ files: scrubber ? await scrubDeep(scrubber, found, new Map()) : found,
352
+ };
353
+ }
342
354
  const files = placeFiles(place);
343
355
  if (input.op === "list")
344
356
  return {
@@ -534,6 +546,43 @@ export function createBoardFiles({
534
546
  data: bytes.subarray(offset, offset + FILE_PART_BYTES).toString("base64"),
535
547
  };
536
548
  };
549
+ // The person's files in every thread that match the words asked, best first: a word in the file's name counts
550
+ // double a word in its type or its thread's title. Each with where it is, who attached it and when.
551
+ const searchWords = (text) =>
552
+ String(text)
553
+ .toLowerCase()
554
+ .split(/[^\p{L}\p{N}]+/u)
555
+ .filter((word) => word.length > 1);
556
+ const findFiles = (query, hereId) => {
557
+ const asked = [...new Set(searchWords(query))];
558
+ if (!asked.length) return [];
559
+ const matches = store.presentFiles().flatMap((file) => {
560
+ const task = store.getTask(file.task_id);
561
+ const thread = task && (roomOf(task) ?? task);
562
+ if (!thread || task.removed_at || thread.removed_at) return [];
563
+ const named = searchWords(file.name).join(" ");
564
+ const about = searchWords(`${file.mime} ${thread.objective}`).join(" ");
565
+ const score = asked.reduce(
566
+ (sum, word) =>
567
+ sum + (named.includes(word) ? 2 : about.includes(word) ? 1 : 0),
568
+ file.id === query.trim() ? 100 : 0
569
+ );
570
+ return score ? [{ score, file, thread }] : [];
571
+ });
572
+ return matches
573
+ .sort(
574
+ (a, b) =>
575
+ b.score - a.score ||
576
+ b.file.created_at.localeCompare(a.file.created_at)
577
+ )
578
+ .slice(0, FOUND_FILES)
579
+ .map(({ file, thread }) => ({
580
+ ...harnessFileView(file),
581
+ attached_at: file.created_at,
582
+ thread: { id: thread.id, title: thread.objective.slice(0, 200) },
583
+ in_this_thread: thread.id === hereId,
584
+ }));
585
+ };
537
586
  const harnessFilesOf = (taskId) => {
538
587
  try {
539
588
  return JSON.parse(store.meta(`harness-files:${taskId}`) || "[]");
@@ -1,6 +1,6 @@
1
1
  import os from "node:os";
2
2
  import { spawn } from "node:child_process";
3
- import { MACHINE_RUNNERS, MEMBERS, nameOf } from "./members.mjs";
3
+ import { MACHINE_RUNNERS, MEMBERS, TAGGED_ONLY, nameOf } from "./members.mjs";
4
4
  import { LEAD_TIMES } from "./schedules.mjs";
5
5
 
6
6
  // The swarm's coordinator, run from this machine whether or not a Harness window is open. When a thread goes quiet
@@ -25,7 +25,7 @@ const REVIEWERS = new Set(
25
25
  MEMBERS.filter((entry) => entry.review).map((entry) => entry.id)
26
26
  );
27
27
  // Agents that move money or take positions are never brought in on a guess: only once they are in the thread.
28
- const MONEY = new Set(["bankr", "quotient"]);
28
+ const TAGGED = new Set(TAGGED_ONLY);
29
29
  const TRANSCRIPT_POSTS = 30;
30
30
  // The goal's own updates go to the round as the goal itself (goals.mjs), not as posts. (A goal room's opening post,
31
31
  // kind goal, is the person's request and stays.)
@@ -283,7 +283,9 @@ export function createCoordinator({
283
283
  !asked?.named.includes(candidate.id) &&
284
284
  // In every round, not only an assembly (owner, October 16: "yah", to Bankr scoring 0.33 to 0.38 as the agent
285
285
  // to hand a production keeper fix to in the eval swarm-coordination).
286
- !(MONEY.has(candidate.id) && !thread.goal.team.includes(candidate.id))
286
+ !(
287
+ TAGGED.has(candidate.id) && !thread.goal.team.includes(candidate.id)
288
+ )
287
289
  )
288
290
  .map((candidate) => ({
289
291
  ...candidate,
@@ -403,7 +405,7 @@ export function createCoordinator({
403
405
  agent !== "harness" &&
404
406
  !asked.named.includes(agent) &&
405
407
  (!CODING.has(agent) || thread.goal.workspace) &&
406
- (!MONEY.has(agent) || inThread.includes(agent)) &&
408
+ (!TAGGED.has(agent) || inThread.includes(agent)) &&
407
409
  (reachable || CODING.has(agent))
408
410
  );
409
411
  const words = store
package/lib/daemon.mjs CHANGED
@@ -52,6 +52,7 @@ import {
52
52
  ASKED_BY_TASK,
53
53
  CLOUD_HOMED,
54
54
  MEMBERS,
55
+ TAGGED_ONLY,
55
56
  TARGETS,
56
57
  aboutOf,
57
58
  member,
@@ -776,19 +777,37 @@ export async function startDaemon() {
776
777
  // for a task's room, their go on that task. Anything else waits for the person's Start like any agent-written run.
777
778
  // In such a thread, the person's own agents asking for work carry the person's go, as their @mention does (owner,
778
779
  // October 13; docs/member-runs.md): Harness and its agents on its server (Bankr, Quotient), and the coding agents on
779
- // this computer; full permissions, Stop always there. An agent the person set to wait still waits. Work another agent
780
- // asked for (Grok Bot, Muse, another person's agent, a call through Harness) runs on a goal's authority only where it
781
- // can be held in: Claude Code in restricted mode, in a copy of the folder this daemon made. Anything else waits.
780
+ // this computer; full permissions, Stop always there. An agent the person set to wait still waits. Grok Bot and Muse
781
+ // carry it too for words the injection guard found clean (fromElsewhere, below). Work any other agent asked for
782
+ // (another person's agent, a call through Harness, Grok Bot's or Muse's flagged words) runs on a goal's authority only
783
+ // where it can be held in: Claude Code in restricted mode, in a copy of the folder this daemon made. Anything else waits.
782
784
  const worktreeRoot = path.join(paths.home, "worktrees");
783
785
  const restrictable = (agent, folder) =>
784
786
  agent === "claude-code" && Boolean(folder) && within(folder, worktreeRoot);
785
787
  const setToWait = (agent) =>
786
788
  standingRules().find((rule) => rule.agent === agent)?.mode === "off";
787
- const personsGo = (asker, agent, { hosted = false } = {}) =>
789
+ // The person's own agents that run elsewhere (Grok Bot, Muse) carry the go too, for words the injection guard read and
790
+ // found clean (owner, October 18: only what actually needs the person waits for them). Words it flagged, or could not
791
+ // read, wait for the Start, and the thread says why (guardWait).
792
+ const fromElsewhere = (agent) => {
793
+ const entry = member(agent);
794
+ return entry?.road === "hosted" && entry.runs === "self" && entry.target;
795
+ };
796
+ const guardClean = (guard) =>
797
+ guard?.verdict === "clean" && !guard.unavailable;
798
+ const personsGo = (asker, agent, { hosted = false, guard = null } = {}) =>
788
799
  asker === "user" ||
789
800
  ((member(asker)?.runs === "server" ||
790
- (!hosted && member(asker)?.runs === "machine")) &&
801
+ (!hosted && member(asker)?.runs === "machine") ||
802
+ (fromElsewhere(asker) && guardClean(guard))) &&
791
803
  !setToWait(agent));
804
+ const guardWait = (asker, agent, guard) => {
805
+ if (!fromElsewhere(asker) || setToWait(agent) || guardClean(guard))
806
+ return null;
807
+ return !guard || guard.unavailable
808
+ ? `The guard that reads ${nameOf(asker)}'s words for planted instructions is not running on this computer, so ${nameOf(agent)} waits for your Start.`
809
+ : `The guard flagged ${nameOf(asker)}'s words as possibly carrying instructions from something it read, so ${nameOf(agent)} waits for your Start. Read them before you start it.`;
810
+ };
792
811
  const restrictedWait = (agent) =>
793
812
  setToWait(agent)
794
813
  ? `${nameOf(agent)} is set to wait for your Start.`
@@ -1177,12 +1196,13 @@ export async function startDaemon() {
1177
1196
  }
1178
1197
  };
1179
1198
  // `why`: what the agents are told in place of "mentioned you" (the coordinator's word to everyone in a thread).
1199
+ // `guard`: the injection guard's reading of the words, where the caller had it read (firewall.mjs inspect).
1180
1200
  const wakeFor = (
1181
1201
  goalId,
1182
1202
  post,
1183
1203
  author,
1184
1204
  names = post.mentions,
1185
- { hosted = false, why = null } = {}
1205
+ { hosted = false, why = null, guard } = {}
1186
1206
  ) => {
1187
1207
  const goal = store.goal(goalId);
1188
1208
  const { picks } = picksIn(store, post.text, names);
@@ -1204,10 +1224,11 @@ export async function startDaemon() {
1204
1224
  );
1205
1225
  else if (RUNNERS.has(agent))
1206
1226
  threadRuns.wake(goalId, agent, reason, {
1207
- go: personsGo(author, agent, { hosted }),
1227
+ go: personsGo(author, agent, { hosted, guard }),
1208
1228
  asker: author,
1209
1229
  pick: picks.get(agent),
1210
1230
  words: post.text,
1231
+ held: guard === undefined ? null : guardWait(author, agent, guard),
1211
1232
  });
1212
1233
  else if (ASKABLE.has(agent))
1213
1234
  told.push(askAgent(goalId, agent, reason, author));
@@ -1271,8 +1292,7 @@ export async function startDaemon() {
1271
1292
  ? mentionsIn(task.result || "", ROOM_AGENTS).filter(
1272
1293
  (agent) =>
1273
1294
  agent !== who &&
1274
- (!["bankr", "quotient"].includes(agent) ||
1275
- goal.goal.team.includes(agent))
1295
+ (!TAGGED_ONLY.includes(agent) || goal.goal.team.includes(agent))
1276
1296
  )
1277
1297
  : [];
1278
1298
  const joining = named.filter((agent) => !goal.goal.team.includes(agent));
@@ -1330,7 +1350,15 @@ export async function startDaemon() {
1330
1350
  status: task.status,
1331
1351
  result: task.result || "",
1332
1352
  });
1333
- } else if (goal.status === "open") wakeFor(goal.id, post, who);
1353
+ } else if (goal.status === "open" && fromElsewhere(who) && !flag)
1354
+ // An answer from the person's agents elsewhere wakes its asker on the guard's reading of it, as their posts do.
1355
+ void readByGuard(text).then((guard) => {
1356
+ if (guard?.verdict === "flag" || guard?.verdict === "hold")
1357
+ store.meta(`flagged:${post.id}`, String(guard.score));
1358
+ wakeFor(goal.id, post, who, undefined, { guard });
1359
+ notifyBoard(store.getTask(goal.id));
1360
+ });
1361
+ else if (goal.status === "open") wakeFor(goal.id, post, who);
1334
1362
  notifyBoard(store.getTask(goal.id));
1335
1363
  };
1336
1364
  const endGuestThreads = (goal, outcome) => {
@@ -1403,6 +1431,7 @@ export async function startDaemon() {
1403
1431
  DEFAULT_MAX_WAKES,
1404
1432
  HELD_NOTE,
1405
1433
  ROOM_AGENTS,
1434
+ available,
1406
1435
  getActiveRuns: () => activeRuns,
1407
1436
  endGuestThreads,
1408
1437
  getFirewall: () => firewall,
@@ -1630,6 +1659,11 @@ export async function startDaemon() {
1630
1659
  },
1631
1660
  });
1632
1661
  const firewall = createFirewall({ inference, log });
1662
+ // The guard's reading of words an agent hands the swarm, as a post's is read (goalCommands.mjs).
1663
+ const readByGuard = (text) =>
1664
+ localReady(["guard"])
1665
+ ? firewall.inspect(text)
1666
+ : Promise.resolve({ score: null, verdict: "clean", unavailable: true });
1633
1667
  if (localReady(["credentials"])) scrubber = firewall;
1634
1668
  if (localReady(["search"])) contextEngine.start();
1635
1669
  // An image leaving this computer readable through Harness (redact.mjs) has every key, private key, seed phrase,
@@ -5,7 +5,7 @@ import { stopAgentTask } from "./runner.mjs";
5
5
  import { notifyDesktop } from "./notify.mjs";
6
6
  import { secretReason } from "./secrets.mjs";
7
7
  import { provenanceFor } from "./provenance.mjs";
8
- import { nameOf } from "./members.mjs";
8
+ import { TAGGED_ONLY, nameOf } from "./members.mjs";
9
9
  import { picksIn } from "./models.mjs";
10
10
  import { roomPage } from "./roomPage.mjs";
11
11
 
@@ -14,6 +14,7 @@ export function createGoalCommands({
14
14
  DEFAULT_MAX_WAKES,
15
15
  HELD_NOTE,
16
16
  ROOM_AGENTS,
17
+ available,
17
18
  getActiveRuns,
18
19
  endGuestThreads,
19
20
  getFirewall,
@@ -53,10 +54,16 @@ export function createGoalCommands({
53
54
  .trim()
54
55
  .slice(0, 500);
55
56
  if (!objective) return { ok: false, error: "a goal needs an objective" };
57
+ // With no team, the agents the person named that can work here; the coordinator brings in the rest as it hands
58
+ // out work. Never every agent the relay knows: that put Bankr, Quotient and agents never installed into an
59
+ // @swarm thread (October 18).
60
+ const reachable = available();
56
61
  const team =
57
62
  Array.isArray(request.team) && request.team.length
58
63
  ? [...new Set(request.team.map(String))]
59
- : ROOM_AGENTS;
64
+ : mentionsIn(objective, ROOM_AGENTS).filter((name) =>
65
+ reachable.includes(name)
66
+ );
60
67
  if (!team.every(validAgent)) return { ok: false, error: "invalid team" };
61
68
  const facilitator = request.facilitator
62
69
  ? String(request.facilitator)
@@ -214,7 +221,18 @@ export function createGoalCommands({
214
221
  .map(String)
215
222
  .filter((name) => ROOM_AGENTS.includes(name) && name !== agent);
216
223
  const named = mentionsIn(text, ROOM_AGENTS);
217
- const mentions = [...new Set([...asked, ...named])];
224
+ // An agent that joins only when tagged comes in on the person's name for it or another agent's ask, never on
225
+ // Harness or an agent naming it in passing; once in the thread it hears its name like anyone.
226
+ const askedOutright = Array.isArray(request.ask)
227
+ ? request.ask.map(String)
228
+ : [];
229
+ const mentions = [...new Set([...asked, ...named])].filter(
230
+ (name) =>
231
+ !TAGGED_ONLY.includes(name) ||
232
+ agent === "user" ||
233
+ (agent !== "harness" && askedOutright.includes(name)) ||
234
+ goal.goal.team.includes(name)
235
+ );
218
236
  const waitingKey = (asker, answerer) =>
219
237
  `room-ask:${goal.id}:${asker}:${answerer}`;
220
238
  const answered = named.filter((name) =>
@@ -270,6 +288,11 @@ export function createGoalCommands({
270
288
  }
271
289
  const told = wakeFor(goal.id, post, agent, wakes, {
272
290
  hosted: request.hostedCaller === true,
291
+ guard: verdict ?? {
292
+ score: null,
293
+ verdict: "clean",
294
+ unavailable: true,
295
+ },
273
296
  });
274
297
  notifyBoard(store.getTask(goal.id));
275
298
  // An agent that asks a teammate who can only start once the asker's own turn ends hears so now, so it stops
package/lib/members.json CHANGED
@@ -19,10 +19,10 @@
19
19
  { "id": "grok-bot", "name": "Grok Bot", "aliases": ["grok", "grok bot"], "road": "hosted", "home": "machine", "runs": "self", "target": true, "wake": "email",
20
20
  "about": "research on X and the web",
21
21
  "where": "in its own cloud", "limits": "Cannot see files on this computer unless one is attached with share_with_cloud, and cannot run anything here." },
22
- { "id": "bankr", "name": "Bankr", "aliases": [], "road": "server", "home": "cloud", "runs": "server", "target": true, "wake": "run",
22
+ { "id": "bankr", "name": "Bankr", "aliases": [], "road": "server", "home": "cloud", "runs": "server", "target": true, "tagged": true, "wake": "run",
23
23
  "about": "holds the swarm's wallet, which is the person's own, and does anything onchain the work needs: buying, selling, swapping, sending or bridging tokens, or any other transaction, always under the person's own approval and limits",
24
24
  "where": "on Harness's server, through Bankr", "limits": "Cannot see files on this computer. Reading balances or a transaction needs no task: an agent on this computer reads them with the wallet tool in seconds." },
25
- { "id": "quotient", "name": "Quotient", "aliases": [], "road": "server", "home": "cloud", "runs": "server", "target": true, "wake": "run",
25
+ { "id": "quotient", "name": "Quotient", "aliases": [], "road": "server", "home": "cloud", "runs": "server", "target": true, "tagged": true, "wake": "run",
26
26
  "about": "prediction markets research: one search over the markets it tracks, with their odds and rules",
27
27
  "where": "on Harness's server", "limits": "Takes no positions from a task. Cannot see files on this computer." },
28
28
  { "id": "muse", "name": "Muse", "aliases": [], "road": "hosted", "home": "cloud", "runs": "self", "target": true, "wake": "schedule",
package/lib/members.mjs CHANGED
@@ -18,6 +18,9 @@ export const ids = (keep = () => true) =>
18
18
  MEMBERS.filter(keep).map((entry) => entry.id);
19
19
  /** Members others may hand work to, Harness included. */
20
20
  export const TARGETS = ids((entry) => entry.target);
21
+ /** Members that join a thread only when tagged: named by the person, or asked for by another agent with `ask`. Never
22
+ * by @swarm, the coordinator's assembly or fallback, a default team, or Harness naming them in passing. */
23
+ export const TAGGED_ONLY = ids((entry) => entry.tagged);
21
24
  /** Coding agents the daemon runs on this machine. */
22
25
  export const MACHINE_RUNNERS = ids((entry) => entry.runs === "machine");
23
26
  /** Targets whose tasks live on Harness's server, not the machine (Harness itself excluded). */
@@ -224,6 +224,7 @@ export function createThreadRuns({
224
224
  pick = null,
225
225
  words = null,
226
226
  recovering = false,
227
+ held = null,
227
228
  } = {}
228
229
  ) => {
229
230
  const task = store.getTask(goalId);
@@ -248,12 +249,17 @@ export function createThreadRuns({
248
249
  return;
249
250
  }
250
251
  if (store.openWake(goalId, agent)) {
252
+ const prior = pendingWakes.get(`${goalId}:${agent}`);
253
+ // Words the guard flagged keep the next turn waiting for the person, whatever go an earlier call carried; the
254
+ // person's own call is their go.
255
+ const flagged = asker === "user" ? null : (held ?? prior?.held ?? null);
251
256
  const pending = {
252
257
  id: randomUUID(),
253
258
  reason,
254
259
  asker,
255
- go: go || Boolean(pendingWakes.get(`${goalId}:${agent}`)?.go),
256
- pick: pick ?? pendingWakes.get(`${goalId}:${agent}`)?.pick ?? null,
260
+ go: asker === "user" ? go : !flagged && (go || Boolean(prior?.go)),
261
+ held: flagged,
262
+ pick: pick ?? prior?.pick ?? null,
257
263
  at: new Date().toISOString(),
258
264
  };
259
265
  pendingWakes.set(`${goalId}:${agent}`, pending);
@@ -325,6 +331,8 @@ export function createThreadRuns({
325
331
  store.meta(`person-wake:${wake.id}`, "1");
326
332
  store.authorizeGoalRun(wake.id);
327
333
  } else if (restrictable(agent, folder)) store.authorizeGoalRun(wake.id);
334
+ else if (held)
335
+ store.roomPost({ goalId, author: "harness", kind: "note", text: held });
328
336
  else if (!store.meta(`restricted-note:${goalId}:${agent}`)) {
329
337
  store.meta(`restricted-note:${goalId}:${agent}`, "1");
330
338
  store.roomPost({
@@ -429,6 +437,7 @@ export function createThreadRuns({
429
437
  go: pending.go,
430
438
  asker: pending.asker,
431
439
  pick: pending.pick,
440
+ held: pending.held ?? null,
432
441
  });
433
442
  // Keep the accepted call durable until its replacement wake exists.
434
443
  if (next) pendingWakes.delete(key);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tryharness",
3
- "version": "0.7.35",
3
+ "version": "0.7.37",
4
4
  "description": "Harness Relay: the daemon that turns the agents on this machine into your personal swarm. Memory, history, and work handed between any of them.",
5
5
  "bin": {
6
6
  "tryharness": "cli.mjs"