tryharness 0.7.59 → 0.7.61

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.
package/lib/readers.mjs CHANGED
@@ -328,14 +328,21 @@ async function recording(file) {
328
328
  }
329
329
  }
330
330
 
331
- const soundParts = async (file) =>
332
- windows(await recording(file)).map((window) => ({
333
- modality: "audio",
334
- data: encodeWav(window.samples, RATE),
335
- loc: window.startMs,
336
- locEnd: window.endMs,
337
- embed: true,
338
- }));
331
+ const soundParts = async (file) => {
332
+ const parts = [];
333
+ for (const window of windows(await recording(file))) {
334
+ parts.push({
335
+ modality: "audio",
336
+ data: encodeWav(window.samples, RATE),
337
+ loc: window.startMs,
338
+ locEnd: window.endMs,
339
+ embed: true,
340
+ });
341
+ // A window at a time: a long recording read in one go held up the daemon's requests for as long.
342
+ await new Promise((resolve) => setImmediate(resolve));
343
+ }
344
+ return parts;
345
+ };
339
346
 
340
347
  /**
341
348
  * A file's parts: [{ modality: "text" | "image" | "audio", text?, data?, loc, locEnd?, embed }]. loc is a page (PDF),
@@ -0,0 +1,42 @@
1
+ import { createHash } from "node:crypto";
2
+
3
+ // A thread's read for a reader away from this computer (the phone, or a browser through Harness). Its answer comes
4
+ // back sealed through Harness in one piece, and Harness takes about 1 MB (src/shared/bridge/sealedWire.ts MAX_CT),
5
+ // while a long T3 Code thread read whole is 1 to 3 MB. So such a reader gets the newest of the timeline up to
6
+ // RECENT_BYTES, a page a phone takes in a moment, and `start`, how many entries came before; asking with `before` (a
7
+ // `start` it holds) gives the page that ends there. A reader that sends the `version` it holds and still has it hears
8
+ // only that, so an open thread asked about every two seconds costs nothing while it is quiet.
9
+ export const RECENT_BYTES = 200_000;
10
+
11
+ /** `read` is board.swarm.read's whole answer; what goes back to a reader away from this computer. */
12
+ export function recentRead(read, { since, before } = {}) {
13
+ if (!read?.ok) return read;
14
+ const version = createHash("sha256")
15
+ .update(JSON.stringify(read))
16
+ .digest("base64url");
17
+ const paging = Number.isInteger(before);
18
+ if (!paging && since === version)
19
+ return { ok: true, unchanged: true, version };
20
+ const timeline = read.timeline ?? [];
21
+ const end = paging
22
+ ? Math.max(0, Math.min(before, timeline.length))
23
+ : timeline.length;
24
+ let start = end;
25
+ let bytes = 0;
26
+ while (start > 0) {
27
+ const size = JSON.stringify(timeline[start - 1]).length;
28
+ // One entry is always given, however long, so a reader never waits on a page that cannot come.
29
+ if (start < end && bytes + size > RECENT_BYTES) break;
30
+ bytes += size;
31
+ start--;
32
+ }
33
+ const shown = timeline.slice(start, end);
34
+ const seqs = new Set(shown.map((entry) => entry.seq));
35
+ return {
36
+ ...read,
37
+ timeline: shown,
38
+ posts: (read.posts ?? []).filter((post) => seqs.has(post.seq)),
39
+ start,
40
+ version,
41
+ };
42
+ }
@@ -379,7 +379,7 @@ export function createSessionControl({
379
379
  }));
380
380
  // A running session no hook placed (it started before Harness was set up, or its agent has none): read from its process.
381
381
  // One in no terminal, app or editor is a program's, not the person's: claude-mem's worker runs Claude Code that way,
382
- // and left 53 running on one computer.
382
+ // and left 53 running on one computer. One another agent or a Harness run started stays, in its own group.
383
383
  return sessions.filter((session) => {
384
384
  if (placesOf(session.agent)[session.sessionId]) return true;
385
385
  const env = {
@@ -401,7 +401,7 @@ export function createSessionControl({
401
401
  ? { ...place, startedBy: session.startedBy }
402
402
  : place
403
403
  );
404
- return Boolean(place);
404
+ return Boolean(place) || Boolean(session.startedBy?.by);
405
405
  });
406
406
  };
407
407
 
@@ -2,7 +2,7 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { spawn } from "node:child_process";
4
4
  import { randomBytes } from "node:crypto";
5
- import { run } from "./commands.mjs";
5
+ import { runAsync } from "./commands.mjs";
6
6
  import { listJsonl } from "./files.mjs";
7
7
  import { parseSessionFile } from "./parsers.mjs";
8
8
  import { historyRoots } from "./paths.mjs";
@@ -193,7 +193,7 @@ export function createSessionIndex({
193
193
  for (const item of requested)
194
194
  await readOpencodeSession(item.sessionId, item.cwd);
195
195
  } else {
196
- const listed = run(
196
+ const listed = await runAsync(
197
197
  "opencode",
198
198
  ["session", "list", "--format", "json"],
199
199
  { timeout: 20_000, maxBuffer: 20_000_000 }
package/lib/speech.mjs CHANGED
@@ -344,6 +344,167 @@ export function createAppleSpeech({
344
344
  };
345
345
  }
346
346
 
347
+ // The models' own work, run on the model thread (onnxWorker.mjs) beside the sessions; each returns what the daemon's
348
+ // side turns into words. Samples are sent as a copy of just their piece: a piece of a longer recording sent as is
349
+ // would copy the whole recording to the other thread.
350
+ /** The VAD's speech probability for each 32 ms frame: a job on the model thread (onnxWorker.mjs). */
351
+ export async function vadProbabilities({ ort, graph }, file, samples) {
352
+ const vad = await graph(file);
353
+ const rate = new ort.Tensor("int64", BigInt64Array.from([BigInt(RATE)]), []);
354
+ let state = new ort.Tensor("float32", new Float32Array(2 * 128), [2, 1, 128]);
355
+ const input = new Float32Array(CONTEXT + FRAME);
356
+ const probs = new Float32Array(Math.floor(samples.length / FRAME));
357
+ for (let i = 0; i < probs.length; i += 1) {
358
+ // Each frame carries the last 64 samples of the one before it, as the model was trained.
359
+ input.copyWithin(0, FRAME, FRAME + CONTEXT);
360
+ input.set(samples.subarray(i * FRAME, (i + 1) * FRAME), CONTEXT);
361
+ const out = await vad.run({
362
+ input: new ort.Tensor("float32", input.slice(), [1, CONTEXT + FRAME]),
363
+ state,
364
+ sr: rate,
365
+ });
366
+ probs[i] = out.output.data[0];
367
+ state = out.stateN;
368
+ }
369
+ return probs;
370
+ }
371
+
372
+ /** Moonshine's token ids for one piece of speech: a job on the model thread. */
373
+ export async function moonshineIds({ ort, graph }, files, config, samples) {
374
+ const [encoder, decoder] = await Promise.all([
375
+ graph(files.encoder),
376
+ graph(files.decoder),
377
+ ]);
378
+ const { last_hidden_state: states } = await encoder.run({
379
+ input_values: new ort.Tensor("float32", samples, [1, samples.length]),
380
+ });
381
+ const layers = config.decoder_num_hidden_layers,
382
+ heads = config.decoder_num_key_value_heads,
383
+ width = config.hidden_size / config.decoder_num_attention_heads;
384
+ const empty = new ort.Tensor("float32", new Float32Array(0), [
385
+ 1,
386
+ heads,
387
+ 0,
388
+ width,
389
+ ]);
390
+ const past = {};
391
+ for (let i = 0; i < layers; i += 1)
392
+ for (const part of ["decoder", "encoder"])
393
+ for (const kv of ["key", "value"])
394
+ past[`past_key_values.${i}.${part}.${kv}`] = empty;
395
+ const limit = Math.ceil((samples.length / RATE) * TOKENS_PER_SECOND) + 4;
396
+ const ids = [];
397
+ let token = config.decoder_start_token_id;
398
+ for (let step = 0; step < limit; step += 1) {
399
+ const out = await decoder.run({
400
+ input_ids: new ort.Tensor(
401
+ "int64",
402
+ BigInt64Array.from([BigInt(token)]),
403
+ [1, 1]
404
+ ),
405
+ encoder_hidden_states: states,
406
+ use_cache_branch: new ort.Tensor(
407
+ "bool",
408
+ Uint8Array.from([step > 0 ? 1 : 0]),
409
+ [1]
410
+ ),
411
+ ...past,
412
+ });
413
+ const logits = out.logits.data;
414
+ let best = 0;
415
+ for (let v = 1; v < logits.length; v += 1)
416
+ if (logits[v] > logits[best]) best = v;
417
+ // The encoder's keys and values come from the first step and stay; the decoder's grow by one each step.
418
+ for (let i = 0; i < layers; i += 1)
419
+ for (const part of step === 0 ? ["decoder", "encoder"] : ["decoder"])
420
+ for (const kv of ["key", "value"])
421
+ past[`past_key_values.${i}.${part}.${kv}`] =
422
+ out[`present.${i}.${part}.${kv}`];
423
+ if (best === config.eos_token_id) break;
424
+ ids.push(best);
425
+ token = best;
426
+ }
427
+ return ids;
428
+ }
429
+
430
+ /**
431
+ * Parakeet's token ids for one piece of speech, a job on the model thread: its feature extractor and encoder, then a
432
+ * greedy token-and-duration decode over the encoder's frames (as NeMo and onnx-asr do): each step names a token (or
433
+ * blank) and how many frames to move. `vocabulary` is how many tokens there are; `blank` the blank's id.
434
+ */
435
+ export async function parakeetIds(
436
+ { ort, graph },
437
+ files,
438
+ { vocabulary, blank },
439
+ samples
440
+ ) {
441
+ const [features, encoder, joint] = await Promise.all(
442
+ [files.features, files.encoder, files.joint].map((file) => graph(file))
443
+ );
444
+ const count = new ort.Tensor(
445
+ "int64",
446
+ BigInt64Array.from([BigInt(samples.length)]),
447
+ [1]
448
+ );
449
+ const heard = await features.run({
450
+ waveforms: new ort.Tensor("float32", samples, [1, samples.length]),
451
+ waveforms_lens: count,
452
+ });
453
+ const { outputs, encoded_lengths } = await encoder.run({
454
+ audio_signal: heard.features,
455
+ length: heard.features_lens,
456
+ });
457
+ const [, width, frames] = outputs.dims,
458
+ length = Number(encoded_lengths.data[0]);
459
+ const frame = (t) => {
460
+ const v = new Float32Array(width);
461
+ for (let d = 0; d < width; d += 1) v[d] = outputs.data[d * frames + t];
462
+ return v;
463
+ };
464
+ let states = [1, 2].map(
465
+ () => new ort.Tensor("float32", new Float32Array(2 * 640), [2, 1, 640])
466
+ );
467
+ const ids = [];
468
+ for (let t = 0, emitted = 0; t < length;) {
469
+ const out = await joint.run({
470
+ encoder_outputs: new ort.Tensor("float32", frame(t), [1, width, 1]),
471
+ targets: new ort.Tensor(
472
+ "int32",
473
+ Int32Array.from([ids.at(-1) ?? blank]),
474
+ [1, 1]
475
+ ),
476
+ target_length: new ort.Tensor("int32", Int32Array.from([1]), [1]),
477
+ input_states_1: states[0],
478
+ input_states_2: states[1],
479
+ });
480
+ const scores = out.outputs.data;
481
+ let token = 0,
482
+ step = 0;
483
+ for (let v = 1; v < vocabulary; v += 1)
484
+ if (scores[v] > scores[token]) token = v;
485
+ for (let k = 1; k < scores.length - vocabulary; k += 1)
486
+ if (scores[vocabulary + k] > scores[vocabulary + step]) step = k;
487
+ if (token !== blank) {
488
+ states = [out.output_states_1, out.output_states_2];
489
+ ids.push(token);
490
+ emitted += 1;
491
+ }
492
+ // At most ten tokens on one frame, as the model's decoding allows.
493
+ if (step > 0) {
494
+ t += step;
495
+ emitted = 0;
496
+ } else if (token === blank || emitted === 10) {
497
+ t += 1;
498
+ emitted = 0;
499
+ }
500
+ }
501
+ return ids;
502
+ }
503
+
504
+ const VAD_JOB = { module: import.meta.url, name: "vadProbabilities" };
505
+ const MOONSHINE_JOB = { module: import.meta.url, name: "moonshineIds" };
506
+ const PARAKEET_JOB = { module: import.meta.url, name: "parakeetIds" };
507
+
347
508
  export function createSpeech({
348
509
  inference,
349
510
  root,
@@ -488,194 +649,48 @@ export function createSpeech({
488
649
  const vadFile = fileOf(vadEntry, /\.onnx$/);
489
650
  /** The VAD's speech probability for each 32 ms frame. */
490
651
  const probabilities = (samples, lane) =>
491
- inference.onnx(
492
- "vad",
493
- async ({ ort, graph }) => {
494
- const vad = await graph(vadFile);
495
- const rate = new ort.Tensor(
496
- "int64",
497
- BigInt64Array.from([BigInt(RATE)]),
498
- []
499
- );
500
- let state = new ort.Tensor(
501
- "float32",
502
- new Float32Array(2 * 128),
503
- [2, 1, 128]
504
- );
505
- const input = new Float32Array(CONTEXT + FRAME);
506
- const probs = new Float32Array(Math.floor(samples.length / FRAME));
507
- for (let i = 0; i < probs.length; i += 1) {
508
- // Each frame carries the last 64 samples of the one before it, as the model was trained.
509
- input.copyWithin(0, FRAME, FRAME + CONTEXT);
510
- input.set(samples.subarray(i * FRAME, (i + 1) * FRAME), CONTEXT);
511
- const out = await vad.run({
512
- input: new ort.Tensor("float32", input.slice(), [
513
- 1,
514
- CONTEXT + FRAME,
515
- ]),
516
- state,
517
- sr: rate,
518
- });
519
- probs[i] = out.output.data[0];
520
- state = out.stateN;
521
- }
522
- return probs;
523
- },
524
- { lane }
525
- );
652
+ inference.onnx("vad", VAD_JOB, [vadFile, samples.slice()], { lane });
526
653
 
527
654
  /** Where in the samples someone spoke: [start, end) pairs, none for noise or silence. */
528
655
  const voiced = async (samples, { lane = "interactive" } = {}) =>
529
656
  speechSpans(await probabilities(samples, lane), { total: samples.length });
530
657
 
531
658
  /** Moonshine's words for one piece of speech. */
532
- const moonshine = (samples, { lane = "interactive" } = {}) =>
533
- inference.onnx(
659
+ const moonshine = async (samples, { lane = "interactive" } = {}) => {
660
+ load();
661
+ const files = {
662
+ encoder: fileOf(speechEntry, /encoder[^/]*\.onnx$/),
663
+ decoder: fileOf(speechEntry, /decoder[^/]*\.onnx$/),
664
+ };
665
+ const ids = await inference.onnx(
534
666
  "speech",
535
- async ({ ort, graph }) => {
536
- load();
537
- const [encoder, decoder] = await Promise.all([
538
- graph(fileOf(speechEntry, /encoder[^/]*\.onnx$/)),
539
- graph(fileOf(speechEntry, /decoder[^/]*\.onnx$/)),
540
- ]);
541
- const { last_hidden_state: states } = await encoder.run({
542
- input_values: new ort.Tensor("float32", samples, [1, samples.length]),
543
- });
544
- const layers = config.decoder_num_hidden_layers,
545
- heads = config.decoder_num_key_value_heads,
546
- width = config.hidden_size / config.decoder_num_attention_heads;
547
- const empty = new ort.Tensor("float32", new Float32Array(0), [
548
- 1,
549
- heads,
550
- 0,
551
- width,
552
- ]);
553
- const past = {};
554
- for (let i = 0; i < layers; i += 1)
555
- for (const part of ["decoder", "encoder"])
556
- for (const kv of ["key", "value"])
557
- past[`past_key_values.${i}.${part}.${kv}`] = empty;
558
- const limit =
559
- Math.ceil((samples.length / RATE) * TOKENS_PER_SECOND) + 4;
560
- const ids = [];
561
- let token = config.decoder_start_token_id;
562
- for (let step = 0; step < limit; step += 1) {
563
- const out = await decoder.run({
564
- input_ids: new ort.Tensor(
565
- "int64",
566
- BigInt64Array.from([BigInt(token)]),
567
- [1, 1]
568
- ),
569
- encoder_hidden_states: states,
570
- use_cache_branch: new ort.Tensor(
571
- "bool",
572
- Uint8Array.from([step > 0 ? 1 : 0]),
573
- [1]
574
- ),
575
- ...past,
576
- });
577
- const logits = out.logits.data;
578
- let best = 0;
579
- for (let v = 1; v < logits.length; v += 1)
580
- if (logits[v] > logits[best]) best = v;
581
- // The encoder's keys and values come from the first step and stay; the decoder's grow by one each step.
582
- for (let i = 0; i < layers; i += 1)
583
- for (const part of step === 0
584
- ? ["decoder", "encoder"]
585
- : ["decoder"])
586
- for (const kv of ["key", "value"])
587
- past[`past_key_values.${i}.${part}.${kv}`] =
588
- out[`present.${i}.${part}.${kv}`];
589
- if (best === config.eos_token_id) break;
590
- ids.push(best);
591
- token = best;
592
- }
593
- return tokens.decode(ids).trim();
594
- },
667
+ MOONSHINE_JOB,
668
+ [files, config, samples.slice()],
595
669
  { lane }
596
670
  );
671
+ return tokens.decode(ids).trim();
672
+ };
597
673
 
598
- /**
599
- * Parakeet's words for one piece of speech: its feature extractor and encoder, then a greedy token-and-duration decode
600
- * over the encoder's frames (as NeMo and onnx-asr do): each step names a token (or blank) and how many frames to move.
601
- */
602
- const parakeet = (samples, { lane = "interactive" } = {}) =>
603
- inference.onnx(
674
+ /** Parakeet's words for one piece of speech. */
675
+ const parakeet = async (samples, { lane = "interactive" } = {}) => {
676
+ load();
677
+ const files = {
678
+ features: fileOf(speechEntry, /nemo\d+\.onnx$/),
679
+ encoder: fileOf(speechEntry, /encoder[^/]*\.onnx$/),
680
+ joint: fileOf(speechEntry, /decoder_joint[^/]*\.onnx$/),
681
+ };
682
+ const ids = await inference.onnx(
604
683
  "speech",
605
- async ({ ort, graph }) => {
606
- load();
607
- const [features, encoder, joint] = await Promise.all(
608
- [
609
- /nemo\d+\.onnx$/,
610
- /encoder[^/]*\.onnx$/,
611
- /decoder_joint[^/]*\.onnx$/,
612
- ].map((pattern) => graph(fileOf(speechEntry, pattern)))
613
- );
614
- const count = new ort.Tensor(
615
- "int64",
616
- BigInt64Array.from([BigInt(samples.length)]),
617
- [1]
618
- );
619
- const heard = await features.run({
620
- waveforms: new ort.Tensor("float32", samples, [1, samples.length]),
621
- waveforms_lens: count,
622
- });
623
- const { outputs, encoded_lengths } = await encoder.run({
624
- audio_signal: heard.features,
625
- length: heard.features_lens,
626
- });
627
- const [, width, frames] = outputs.dims,
628
- length = Number(encoded_lengths.data[0]);
629
- const frame = (t) => {
630
- const v = new Float32Array(width);
631
- for (let d = 0; d < width; d += 1)
632
- v[d] = outputs.data[d * frames + t];
633
- return v;
634
- };
635
- const { pieces, blank } = tokens;
636
- let states = [1, 2].map(
637
- () =>
638
- new ort.Tensor("float32", new Float32Array(2 * 640), [2, 1, 640])
639
- );
640
- const ids = [];
641
- for (let t = 0, emitted = 0; t < length;) {
642
- const out = await joint.run({
643
- encoder_outputs: new ort.Tensor("float32", frame(t), [1, width, 1]),
644
- targets: new ort.Tensor(
645
- "int32",
646
- Int32Array.from([ids.at(-1) ?? blank]),
647
- [1, 1]
648
- ),
649
- target_length: new ort.Tensor("int32", Int32Array.from([1]), [1]),
650
- input_states_1: states[0],
651
- input_states_2: states[1],
652
- });
653
- const scores = out.outputs.data;
654
- let token = 0,
655
- step = 0;
656
- for (let v = 1; v < pieces.length; v += 1)
657
- if (scores[v] > scores[token]) token = v;
658
- for (let k = 1; k < scores.length - pieces.length; k += 1)
659
- if (scores[pieces.length + k] > scores[pieces.length + step])
660
- step = k;
661
- if (token !== blank) {
662
- states = [out.output_states_1, out.output_states_2];
663
- ids.push(token);
664
- emitted += 1;
665
- }
666
- // At most ten tokens on one frame, as the model's decoding allows.
667
- if (step > 0) {
668
- t += step;
669
- emitted = 0;
670
- } else if (token === blank || emitted === 10) {
671
- t += 1;
672
- emitted = 0;
673
- }
674
- }
675
- return tokens.decode(ids).trim();
676
- },
684
+ PARAKEET_JOB,
685
+ [
686
+ files,
687
+ { vocabulary: tokens.pieces.length, blank: tokens.blank },
688
+ samples.slice(),
689
+ ],
677
690
  { lane }
678
691
  );
692
+ return tokens.decode(ids).trim();
693
+ };
679
694
  const recognise = engine === "parakeet" ? parakeet : moonshine;
680
695
 
681
696
  /** Speech stretches joined into pieces Moonshine can take, cut between stretches. */
package/lib/swarm.mjs CHANGED
@@ -26,6 +26,8 @@ import {
26
26
  } from "./specialties.mjs";
27
27
  import { askOfRun } from "./threadView.mjs";
28
28
  import { createWorkFocus } from "./workFocus.mjs";
29
+ import { createListVersions } from "./listVersions.mjs";
30
+ import { recentRead } from "./recentRead.mjs";
29
31
  import { createWorkLinks } from "./workLinks.mjs";
30
32
  import {
31
33
  DEFAULT_ROUTING,
@@ -694,6 +696,12 @@ export function createSwarm({
694
696
  };
695
697
  };
696
698
 
699
+ // The thread list's versions, one for each list a reader can ask for (all of it, or what is open).
700
+ const listVersions = {
701
+ all: createListVersions(),
702
+ open: createListVersions(),
703
+ };
704
+
697
705
  return function swarmCommand(request, agent, machine = null) {
698
706
  const command = String(request.command);
699
707
  if (command === "board.swarm.list") {
@@ -702,9 +710,9 @@ export function createSwarm({
702
710
  ok: false,
703
711
  error: "only the person and Harness read the swarm",
704
712
  };
705
- const listed = () => ({
706
- ok: true,
707
- threads: [
713
+ const listed = () => {
714
+ // activityVersion only tells this side when a T3 thread moved (focus.decorate has read it); no reader uses it.
715
+ const threads = [
708
716
  ...store
709
717
  .goals({ all: request.all === true })
710
718
  .filter((thread) => !SETUP_CHECK.test(thread.objective))
@@ -712,13 +720,30 @@ export function createSwarm({
712
720
  ...(!request.hostedCaller
713
721
  ? (environments?.roots() ?? []).map(focus.decorate)
714
722
  : []),
715
- ],
716
- sessions: request.sessions === false ? [] : sessions(),
717
- agents: roster(),
718
- joining: request.hostedCaller ? [] : joining(),
719
- // What waits on the person about an agent, outside any thread (threadView.mjs swarmNeeds).
720
- needsYou: request.hostedCaller ? [] : (threadView?.swarmNeeds() ?? []),
721
- });
723
+ ].map(({ activityVersion, ...shown }) => shown);
724
+ // A reader on the person's computers that keeps the list (the buddy) sends the version its copy is at and gets
725
+ // what changed since (listVersions.mjs); one that sends none gets it whole, as before.
726
+ const sent = request.hostedCaller
727
+ ? null
728
+ : listVersions[request.all === true ? "all" : "open"](threads, {
729
+ epoch: request.epoch,
730
+ after: request.after,
731
+ });
732
+ return {
733
+ ok: true,
734
+ threads: sent ? sent.items : threads,
735
+ ...(sent
736
+ ? { gone: sent.gone, whole: sent.whole, listVersion: sent.version }
737
+ : {}),
738
+ sessions: request.sessions === false ? [] : sessions(),
739
+ agents: roster(),
740
+ joining: request.hostedCaller ? [] : joining(),
741
+ // What waits on the person about an agent, outside any thread (threadView.mjs swarmNeeds).
742
+ needsYou: request.hostedCaller
743
+ ? []
744
+ : (threadView?.swarmNeeds() ?? []),
745
+ };
746
+ };
722
747
  // The work in T3 Code beside the board as T3 Code last said it; only the first read waits for it.
723
748
  const loading = request.hostedCaller ? null : environments?.ready();
724
749
  return loading ? { pending: loading.then(listed) } : listed();
@@ -864,6 +889,9 @@ export function createSwarm({
864
889
  ? { ...result, thread: focus.decorate(result.thread) }
865
890
  : result
866
891
  )
892
+ .then((result) =>
893
+ request.recent === true ? recentRead(result, request) : result
894
+ )
867
895
  );
868
896
  if (command === "board.swarm.post" || command === "board.swarm.stop")
869
897
  return pending(
@@ -1570,8 +1598,10 @@ export function createSwarm({
1570
1598
  thread: summary(store.getTask(thread.id)),
1571
1599
  };
1572
1600
  }
1573
- if (command === "board.swarm.read")
1574
- return read(thread, request.hostedCaller === true);
1601
+ if (command === "board.swarm.read") {
1602
+ const whole = read(thread, request.hostedCaller === true);
1603
+ return request.recent === true ? recentRead(whole, request) : whole;
1604
+ }
1575
1605
  if (command === "board.swarm.diff")
1576
1606
  return worktrees.diff(
1577
1607
  thread.id,
@@ -148,8 +148,12 @@ export function createThreadActions({
148
148
  const goal = store.goal(goalId);
149
149
  const { picks } = picksIn(store, post.text, names);
150
150
  // `@codex #pop-os`: the computer named with # is where the agents named work. A # naming no runner sets it for
151
- // whoever takes the thread's work.
152
- const computer = ownMachines()?.computerNamed(post.text) ?? null;
151
+ // whoever takes the thread's work. Only the person and their own agents choose among the person's computers;
152
+ // another person's post (author "maya/codex") never does.
153
+ const ownWords = !String(author ?? "").includes("/");
154
+ const computer = ownWords
155
+ ? (ownMachines()?.computerNamed(post.text) ?? null)
156
+ : null;
153
157
  if (computer && !names.some((agent) => runsHere(agent)))
154
158
  store.meta(`thread-computer:${goalId}`, computer.id);
155
159
  const told = [];