tryharness 0.7.36 → 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,
@@ -1291,8 +1292,7 @@ export async function startDaemon() {
1291
1292
  ? mentionsIn(task.result || "", ROOM_AGENTS).filter(
1292
1293
  (agent) =>
1293
1294
  agent !== who &&
1294
- (!["bankr", "quotient"].includes(agent) ||
1295
- goal.goal.team.includes(agent))
1295
+ (!TAGGED_ONLY.includes(agent) || goal.goal.team.includes(agent))
1296
1296
  )
1297
1297
  : [];
1298
1298
  const joining = named.filter((agent) => !goal.goal.team.includes(agent));
@@ -1431,6 +1431,7 @@ export async function startDaemon() {
1431
1431
  DEFAULT_MAX_WAKES,
1432
1432
  HELD_NOTE,
1433
1433
  ROOM_AGENTS,
1434
+ available,
1434
1435
  getActiveRuns: () => activeRuns,
1435
1436
  endGuestThreads,
1436
1437
  getFirewall: () => firewall,
@@ -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) =>
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). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tryharness",
3
- "version": "0.7.36",
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"