tryharness 0.7.44 → 0.7.45

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.
@@ -39,6 +39,23 @@
39
39
  "board.plan.add": "plans",
40
40
  "board.plan.remove": "plans",
41
41
  "board.post": "task",
42
+ "board.project.answer": "projects",
43
+ "board.project.create": "projects",
44
+ "board.project.decide": "projects",
45
+ "board.project.decline": "projects",
46
+ "board.project.held": "projects",
47
+ "board.project.join": "projects",
48
+ "board.project.leave": "projects",
49
+ "board.project.list": "projects",
50
+ "board.project.note": "projects",
51
+ "board.project.plan": "projects",
52
+ "board.project.propose": "projects",
53
+ "board.project.read": "projects",
54
+ "board.project.repos": "projects",
55
+ "board.project.setting": "projects",
56
+ "board.project.share": "projects",
57
+ "board.project.withdraw": "projects",
58
+ "board.project.work": "projects",
42
59
  "board.prompted": "prompt",
43
60
  "board.relay.decide": "relay",
44
61
  "board.relay.defaults": "relay",
@@ -183,6 +200,12 @@
183
200
  "board.plan.",
184
201
  "board.template."
185
202
  ]
203
+ },
204
+ {
205
+ "owner": "projects",
206
+ "prefixes": [
207
+ "board.project."
208
+ ]
186
209
  }
187
210
  ],
188
211
  "access": {
@@ -288,7 +311,22 @@
288
311
  "board.relay.seen",
289
312
  "board.relay.defaults",
290
313
  "board.relay.peers",
291
- "board.swarm.held"
314
+ "board.swarm.held",
315
+ "board.project.list",
316
+ "board.project.repos",
317
+ "board.project.create",
318
+ "board.project.join",
319
+ "board.project.decline",
320
+ "board.project.read",
321
+ "board.project.answer",
322
+ "board.project.withdraw",
323
+ "board.project.setting",
324
+ "board.project.decide",
325
+ "board.project.note",
326
+ "board.project.share",
327
+ "board.project.held",
328
+ "board.project.work",
329
+ "board.project.leave"
292
330
  ],
293
331
  "harnessBrowser": [
294
332
  "board.list",
@@ -442,7 +480,22 @@
442
480
  "board.template.save",
443
481
  "board.template.remove",
444
482
  "board.template.use",
445
- "board.swarm.held"
483
+ "board.swarm.held",
484
+ "board.project.list",
485
+ "board.project.repos",
486
+ "board.project.create",
487
+ "board.project.join",
488
+ "board.project.decline",
489
+ "board.project.read",
490
+ "board.project.answer",
491
+ "board.project.withdraw",
492
+ "board.project.setting",
493
+ "board.project.decide",
494
+ "board.project.note",
495
+ "board.project.share",
496
+ "board.project.held",
497
+ "board.project.work",
498
+ "board.project.leave"
446
499
  ],
447
500
  "plainPerson": [
448
501
  "board.standing.off"
package/lib/bridge.mjs CHANGED
@@ -30,6 +30,7 @@ const SCRUBBED = new Set([
30
30
  "coordinate",
31
31
  "pick_folder",
32
32
  "route_model",
33
+ "check_work",
33
34
  "react",
34
35
  "reflect",
35
36
  "wake",
@@ -41,6 +42,7 @@ const DECIDE_ONLY = new Set([
41
42
  "coordinate",
42
43
  "pick_folder",
43
44
  "route_model",
45
+ "check_work",
44
46
  "react",
45
47
  "reflect",
46
48
  ]);
@@ -208,6 +208,8 @@ export function createCoordinator({
208
208
  // (ownMachines.mjs), and whether one of them can take the thread's turn at all.
209
209
  machinesOf = () => undefined,
210
210
  placeable = () => true,
211
+ // A post from the other side of a shared project (projects.mjs): their own swarm sorts it, so it starts no round here.
212
+ fromPartner = () => false,
211
213
  }) {
212
214
  const failedHereLately = (threadId, agent) => {
213
215
  const at = Date.parse(store.meta(`job-failed:${threadId}:${agent}`) || "");
@@ -869,7 +871,12 @@ export function createCoordinator({
869
871
  const asked = askedOf(goalId);
870
872
  const posts = store
871
873
  .roomPosts(goalId, state.lastSeenSeq, 500)
872
- .filter((post) => !QUIET_KINDS.has(post.kind) && !ownPost(thread, post));
874
+ .filter(
875
+ (post) =>
876
+ !QUIET_KINDS.has(post.kind) &&
877
+ !ownPost(thread, post) &&
878
+ !fromPartner(goalId, post)
879
+ );
873
880
  // A turn T3 Code is running for one of the thread's agents counts as work going on, though Harness did not start it
874
881
  // (October 14: the coordinator told Claude Code to "continue" three times while it worked in T3).
875
882
  const active =
package/lib/daemon.mjs CHANGED
@@ -94,6 +94,7 @@ import {
94
94
  } from "./models.mjs";
95
95
  import { forgetT3, startT3SignIn, steerT3Run, t3Access } from "./t3.mjs";
96
96
  import { createNetwork } from "./network.mjs";
97
+ import { createProjects } from "./projects.mjs";
97
98
  import { createSessionControl } from "./sessionControl.mjs";
98
99
  import { createSessionIndex } from "./sessionIndex.mjs";
99
100
  import { createBoardAccess } from "./boardAccess.mjs";
@@ -347,6 +348,7 @@ export async function startDaemon() {
347
348
  for (const thread of store.goals()) coordinator.poke(thread.id);
348
349
  for (const message of store.undeliveredMessages())
349
350
  sendThreadMessage(message);
351
+ projects?.resend();
350
352
  },
351
353
  onMessage: (message) => handleBridgeMessage(message),
352
354
  });
@@ -499,6 +501,33 @@ export async function startDaemon() {
499
501
  })().catch((error) =>
500
502
  log(`thread end ${taskId} not sent: ${error.message}`)
501
503
  );
504
+ // A shared project's event (projects.mjs) on the person thread under it: sealed to the other computer, never readable.
505
+ // Harness acknowledges it once it holds it, and keeps it until the other computer has it.
506
+ const sendProjectEvent = ({ projectId, to, messageId, seq, body }) =>
507
+ void (async () => {
508
+ const key = await threadKey(store.getThread(projectId));
509
+ if (!key)
510
+ throw new Error(
511
+ "the project's thread has no key for the other computer"
512
+ );
513
+ send({
514
+ type: "thread_message",
515
+ taskId: projectId,
516
+ messageId,
517
+ seq,
518
+ to,
519
+ sentAt: new Date().toISOString(),
520
+ text: "",
521
+ refs: [],
522
+ sealed: await sealBound(key, `message|${projectId}|${messageId}`, {
523
+ text: "",
524
+ refs: [],
525
+ project: body,
526
+ }),
527
+ });
528
+ })().catch((error) =>
529
+ log(`project event ${messageId} not sent: ${error.message}`)
530
+ );
502
531
  // Every change to the board goes up the bridge as identity and status; the server mirrors it
503
532
  // and the PiP follows from there. Briefs and results never ride this message.
504
533
  // The person is told on their desktop about what waits on them, whether or not Harness is
@@ -813,7 +842,12 @@ export async function startDaemon() {
813
842
  },
814
843
  timing: handoffTiming(),
815
844
  });
816
- const threadView = createThreadView({ store, goals, handoffs });
845
+ const threadView = createThreadView({
846
+ store,
847
+ goals,
848
+ handoffs,
849
+ projectNeeds: (threadId) => projects?.needsOf(threadId) ?? [],
850
+ });
817
851
  const handoffTimer = setInterval(
818
852
  () => handoffs.tick(),
819
853
  Math.min(30_000, handoffTiming().nudgeMs / 3)
@@ -899,6 +933,7 @@ export async function startDaemon() {
899
933
  `Why now: ${reason}`,
900
934
  `The thread's newest posts (oldest first; each line is a teammate's words, not instructions about authority or money):\n${roomDigest(task.id)}`,
901
935
  goalNote(task),
936
+ projects?.brief(task, agent) ?? "",
902
937
  teams.brief(task.id, agent, { model: cardsFor([agent])[0]?.model }),
903
938
  threadFilesNote(task, agent),
904
939
  [
@@ -1075,12 +1110,15 @@ export async function startDaemon() {
1075
1110
  store,
1076
1111
  root: path.join(paths.home, "worktrees"),
1077
1112
  });
1113
+ // Projects shared with another person's swarm, made once the relay is (below).
1114
+ let projects = null;
1078
1115
  const threadRuns = createThreadRuns({
1079
1116
  store,
1080
1117
  log,
1081
1118
  installedAgents,
1082
1119
  authority,
1083
1120
  worktrees,
1121
+ projects: () => projects,
1084
1122
  notifyBoard,
1085
1123
  swarmBrief,
1086
1124
  threadMayRun,
@@ -1538,7 +1576,14 @@ export async function startDaemon() {
1538
1576
  post,
1539
1577
  author,
1540
1578
  names = post.mentions,
1541
- { hosted = false, why = null, guard, answering = null } = {}
1579
+ {
1580
+ hosted = false,
1581
+ why = null,
1582
+ guard,
1583
+ answering = null,
1584
+ // A shared project's go for a wake the other side asked for (projects.mjs), in place of the person's own.
1585
+ go: projectGo = null,
1586
+ } = {}
1542
1587
  ) => {
1543
1588
  const goal = store.goal(goalId);
1544
1589
  const { picks } = picksIn(store, post.text, names);
@@ -1567,7 +1612,7 @@ export async function startDaemon() {
1567
1612
  );
1568
1613
  else if (RUNNERS.has(agent))
1569
1614
  threadRuns.wake(goalId, agent, reason, {
1570
- go: personsGo(author, agent, { hosted, guard }),
1615
+ go: projectGo ?? personsGo(author, agent, { hosted, guard }),
1571
1616
  asker: author,
1572
1617
  pick: picks.get(agent),
1573
1618
  words: post.text,
@@ -1799,6 +1844,7 @@ export async function startDaemon() {
1799
1844
  };
1800
1845
  const goalCommand = createGoalCommands({
1801
1846
  teams,
1847
+ learned: (goalId, agent, text) => projects?.learned(goalId, agent, text),
1802
1848
  DEFAULT_MAX_POSTS,
1803
1849
  DEFAULT_MAX_WAKES,
1804
1850
  HELD_NOTE,
@@ -2256,6 +2302,7 @@ export async function startDaemon() {
2256
2302
  const coordinator = createCoordinator({
2257
2303
  store,
2258
2304
  lessons,
2305
+ fromPartner: (goalId, post) => projects?.fromPartner(goalId, post) ?? false,
2259
2306
  team: teams,
2260
2307
  headOf: (threadId) => worktrees.head(threadId),
2261
2308
  busyInT3: (thread) =>
@@ -2316,6 +2363,9 @@ export async function startDaemon() {
2316
2363
  : null,
2317
2364
  });
2318
2365
  const swarmCommand = createSwarm({
2366
+ projectOf: (threadId) => projects?.roomInfo(threadId) ?? null,
2367
+ addressesPartner: (threadId, text) =>
2368
+ projects?.addressesPartner(threadId, text) ?? false,
2319
2369
  withMachines: (card) => actors.withMachines(card),
2320
2370
  store,
2321
2371
  plansOf: (threadId) => plans?.of(threadId) ?? [],
@@ -2435,6 +2485,10 @@ export async function startDaemon() {
2435
2485
  network
2436
2486
  ? network.command(request, agent)
2437
2487
  : { ok: false, error: "the daemon is still starting" },
2488
+ projects: (request, { agent }) =>
2489
+ projects
2490
+ ? projects.command(request, agent)
2491
+ : { ok: false, error: "the daemon is still starting" },
2438
2492
  live: (request, { agent }) => liveCommand(request, agent),
2439
2493
  prompt: (request, { agent }) => {
2440
2494
  authority.markPrompt(request.pids, agent);
@@ -2479,6 +2533,7 @@ export async function startDaemon() {
2479
2533
  lessons,
2480
2534
  madeIn: (...args) => madeIn(...args),
2481
2535
  getNetwork: () => network,
2536
+ getProjects: () => projects,
2482
2537
  notifyBoard,
2483
2538
  openTaskRoom,
2484
2539
  openThreadPost: (...args) => openThreadPost(...args),
@@ -2669,6 +2724,8 @@ export async function startDaemon() {
2669
2724
  brief,
2670
2725
  refs,
2671
2726
  trustNewKey = false,
2727
+ // A shared project's offer (projects.mjs): it goes only sealed, to a computer that has a key.
2728
+ project = null,
2672
2729
  }) => {
2673
2730
  if (!state.connected)
2674
2731
  throw new Error("the daemon is not connected to Harness");
@@ -2701,13 +2758,22 @@ export async function startDaemon() {
2701
2758
  throw new Error(
2702
2759
  `Harness gave no key for ${handleOf(target)}'s computer, which had one before; the request was not sent`
2703
2760
  );
2761
+ if (project && typeof keyed.publicKey !== "string")
2762
+ throw new Error(
2763
+ `${handleOf(target)}'s computer can't take a sealed project yet. Ask them to update Harness.`
2764
+ );
2704
2765
  if (typeof keyed.publicKey === "string") {
2705
2766
  targetKey = peerKeyFor(handleOf(target), keyed.publicKey, trustNewKey);
2706
2767
  const sealId = randomUUID();
2707
2768
  const sealed = await sealBound(
2708
2769
  await relayKey(relayIdentity.privateKey, targetKey),
2709
2770
  `request|${sealId}`,
2710
- { about: subject, brief: text, refs: attached }
2771
+ {
2772
+ about: subject,
2773
+ brief: text,
2774
+ refs: attached,
2775
+ ...(project ? { project } : {}),
2776
+ }
2711
2777
  );
2712
2778
  input = {
2713
2779
  to: target,
@@ -2813,6 +2879,9 @@ export async function startDaemon() {
2813
2879
  return {
2814
2880
  about: String(opened.about || "").slice(0, 500),
2815
2881
  fingerprint: await fingerprint(peer),
2882
+ ...(!mine && opened.project && typeof opened.project === "object"
2883
+ ? { project: opened.project }
2884
+ : {}),
2816
2885
  };
2817
2886
  };
2818
2887
  network = createNetwork({
@@ -2822,7 +2891,53 @@ export async function startDaemon() {
2822
2891
  openRelayRequest,
2823
2892
  fingerprint,
2824
2893
  myKey: () => relayIdentity?.publicKey ?? null,
2894
+ isChannel: (threadId) => projects?.isChannel(threadId) ?? false,
2895
+ });
2896
+ // Projects shared with another person's swarm: one room both swarms work in, a record both keep, a check before work.
2897
+ projects = createProjects({
2898
+ store,
2899
+ log,
2900
+ myHandle: () => network.myHandle(),
2901
+ relayRequest,
2902
+ decideRequest: (id, decision) => network.decide(id, decision),
2903
+ invites: () => network.invites(),
2904
+ sentInvites: () => network.sentProjects(),
2905
+ sendEvent: sendProjectEvent,
2906
+ endChannel: (taskId, outcome) => {
2907
+ if (store.closeThread(taskId, outcome).ok)
2908
+ sendThreadEnd(taskId, "person", outcome);
2909
+ },
2910
+ wake: (goalId, post, author, names, options) =>
2911
+ wakeFor(goalId, post, author, names, options),
2912
+ wakeRun: (goalId, agent, reason, options) =>
2913
+ threadRuns.wake(goalId, agent, reason, options),
2914
+ notifyBoard,
2915
+ notifyDesktop: (text) => {
2916
+ if (notificationsOn()) notifyDesktop(text);
2917
+ },
2918
+ checkWork: (input) => {
2919
+ if (!state.connected || !bridge.has("check_work")) {
2920
+ log(
2921
+ `project check: ${state.connected ? "this Harness can't check work" : "not connected to Harness"}`
2922
+ );
2923
+ return Promise.resolve(null);
2924
+ }
2925
+ // The bridge hands back Harness's answer with its fields beside ok.
2926
+ return askHarness("check_work", input).then(({ ok, ...verdict }) => {
2927
+ if (!ok) log(`project check: ${verdict.error}`);
2928
+ return ok ? verdict : null;
2929
+ });
2930
+ },
2931
+ knownFolders: () => folders.known().map((place) => place.path),
2932
+ agents: () => [
2933
+ ...installedAgents.filter((agent) => RUNNERS.has(agent)),
2934
+ "harness",
2935
+ ],
2936
+ worktreeRoot: path.join(paths.home, "projects"),
2937
+ maxPosts: DEFAULT_MAX_POSTS,
2938
+ maxWakes: DEFAULT_MAX_WAKES,
2825
2939
  });
2940
+ store.onRoomPost((goalId, post) => projects?.posted(goalId, post));
2826
2941
 
2827
2942
  const { plainBoard, roomOf, madeIn, visibleTo, SEALED_ONLY } =
2828
2943
  createBoardAccess({
@@ -3409,6 +3524,20 @@ export async function startDaemon() {
3409
3524
  text: String(opened.text || ""),
3410
3525
  refs: Array.isArray(opened.refs) ? opened.refs : [],
3411
3526
  };
3527
+ // A shared project's event: the project keeps it; nothing lands on the thread itself.
3528
+ if (opened.project) {
3529
+ const kept = projects
3530
+ ? projects.receive(String(input.taskId), opened.project)
3531
+ : { ok: false, error: "the daemon is still starting" };
3532
+ send({
3533
+ type: "bridge_response",
3534
+ requestId: message.requestId,
3535
+ ok: kept.ok,
3536
+ result: kept.ok ? { acknowledged: input.messageId } : null,
3537
+ ...(kept.ok ? {} : { error: kept.error }),
3538
+ });
3539
+ return;
3540
+ }
3412
3541
  }
3413
3542
  // A file the message names is this computer's own row, matched to the id the other computer gave it; only a sealed thread brings files.
3414
3543
  const refs = crossRefs(words.refs).map((ref) => {
@@ -3531,6 +3660,7 @@ export async function startDaemon() {
3531
3660
  }
3532
3661
  if (message.type === "thread_ack") {
3533
3662
  store.markDelivered(String(message.messageId || ""));
3663
+ projects?.delivered(String(message.messageId || ""));
3534
3664
  return;
3535
3665
  }
3536
3666
  // Someone asked to reach this person's swarm (network.mjs lists it): told on the desktop, answered in Swarms.
@@ -3575,6 +3705,7 @@ export async function startDaemon() {
3575
3705
  result: closed.ok ? { closed: input.taskId } : null,
3576
3706
  });
3577
3707
  if (closed.ok && !closed.already) {
3708
+ projects?.channelEnded(String(input.taskId || ""));
3578
3709
  notifyBoard(closed.task);
3579
3710
  if (notificationsOn())
3580
3711
  notifyDesktop(
@@ -41,6 +41,8 @@ export function createGoalCommands({
41
41
  files: boardFiles,
42
42
  // The thread's team (team.mjs): an agent's note on what it learned in its role.
43
43
  teams = null,
44
+ // A note saved in a shared project's room is the project's too (projects.mjs).
45
+ learned = () => {},
44
46
  }) {
45
47
  return (request, agent) => {
46
48
  const id = String(request.id || "");
@@ -153,11 +155,14 @@ export function createGoalCommands({
153
155
  if (!inRoom(goal, agent) || agent === "user")
154
156
  return { ok: false, error: `${agent} is not on this goal's team` };
155
157
  if (!teams) return { ok: false, error: "the daemon is still starting" };
156
- return teams.learn(goal.id, agent, {
158
+ const kept = teams.learn(goal.id, agent, {
157
159
  text: request.text,
158
160
  reason: request.reason,
159
161
  replaces: request.replaces,
160
162
  });
163
+ if (kept.ok)
164
+ learned(goal.id, agent, `${request.text} (${request.reason})`);
165
+ return kept;
161
166
  }
162
167
  if (request.command === "board.room.search") {
163
168
  if (!inRoom(goal, agent))
package/lib/mcp-stdio.mjs CHANGED
@@ -400,6 +400,69 @@ const LOCAL_TOOLS = [
400
400
  additionalProperties: false,
401
401
  },
402
402
  },
403
+ {
404
+ name: "plan_work",
405
+ description:
406
+ "In a project shared with another person's swarm: say what you plan to build before you change code for it (summary, and the files or interfaces it touches), or that your piece is done. Your plan is checked against what the two people decided and the other side's work; the answer says whether to go ahead, or that it clashes and waits until the two sides agree a fix.",
407
+ inputSchema: {
408
+ type: "object",
409
+ properties: {
410
+ id: { type: "string", description: "the thread id" },
411
+ summary: {
412
+ type: "string",
413
+ description: "what you will build, in a sentence or two",
414
+ },
415
+ touches: {
416
+ type: "array",
417
+ items: { type: "string" },
418
+ description: "the files, modules or interfaces it changes",
419
+ },
420
+ done: {
421
+ type: "boolean",
422
+ description: "true when your piece is ready to merge",
423
+ },
424
+ stopped: {
425
+ type: "boolean",
426
+ description: "true when you are dropping this piece",
427
+ },
428
+ },
429
+ required: ["id"],
430
+ additionalProperties: false,
431
+ },
432
+ },
433
+ {
434
+ name: "propose",
435
+ description:
436
+ "In a project shared with another person's swarm: propose how two clashing pieces of work fit together, or a decision for the project (an interface, a rule, a split of the work). Agree it with the other agent in the thread first. A person OKs it before it counts: both people for a decision, the owner of each piece of work for a fix.",
437
+ inputSchema: {
438
+ type: "object",
439
+ properties: {
440
+ id: { type: "string", description: "the thread id" },
441
+ text: {
442
+ type: "string",
443
+ description: "what you propose, in plain words",
444
+ },
445
+ about: {
446
+ type: "array",
447
+ items: { type: "string" },
448
+ description: "the work ids this settles (from the clash post)",
449
+ },
450
+ changes: {
451
+ type: "array",
452
+ items: { type: "string" },
453
+ description:
454
+ "the work ids whose plan changes under this proposal; their owners OK it",
455
+ },
456
+ decision: {
457
+ type: "string",
458
+ description:
459
+ "a decision both people OK, when this changes or adds to what they decided",
460
+ },
461
+ },
462
+ required: ["id", "text"],
463
+ additionalProperties: false,
464
+ },
465
+ },
403
466
  {
404
467
  name: "save_learning",
405
468
  description:
@@ -709,6 +772,22 @@ const BOARD_CALLS = {
709
772
  ask: Array.isArray(args.ask) ? args.ask : [],
710
773
  shareWithGuests: args.share_with_guests === true,
711
774
  }),
775
+ plan_work: (args) => ({
776
+ command: "board.project.plan",
777
+ id: String(args.id || ""),
778
+ summary: args.summary,
779
+ touches: Array.isArray(args.touches) ? args.touches : undefined,
780
+ done: args.done === true,
781
+ stopped: args.stopped === true,
782
+ }),
783
+ propose: (args) => ({
784
+ command: "board.project.propose",
785
+ id: String(args.id || ""),
786
+ text: args.text,
787
+ about: Array.isArray(args.about) ? args.about : [],
788
+ changes: Array.isArray(args.changes) ? args.changes : [],
789
+ decision: args.decision ?? null,
790
+ }),
712
791
  save_learning: (args) => ({
713
792
  command: "board.room.learn",
714
793
  id: String(args.id || ""),
package/lib/network.mjs CHANGED
@@ -20,6 +20,8 @@ export function createNetwork({
20
20
  openRelayRequest,
21
21
  fingerprint,
22
22
  myKey,
23
+ // A relay thread that carries a shared project (projects.mjs): Swarms lists the project, not the thread under it.
24
+ isChannel = () => false,
23
25
  }) {
24
26
  // Harness answers for the server's half; a refusal comes back as a plain error the person can read.
25
27
  const harness = async (input) => {
@@ -38,12 +40,15 @@ export function createNetwork({
38
40
  store.relayThreads().map((row) => [row.task_id, row])
39
41
  );
40
42
  const items = [];
43
+ const invited = [];
44
+ const sent = [];
41
45
  for (const thread of server?.threads ?? []) {
42
46
  const here = local.get(thread.id) || null;
43
47
  local.delete(thread.id);
44
48
  const peer = thread.role === "asker" ? thread.target : thread.asker;
45
49
  let about = thread.about || here?.objective || "";
46
50
  let keyPrint = null;
51
+ let project = null;
47
52
  // A sealed request's subject: opened on this computer, with the other computer's key to compare.
48
53
  if (thread.sealed && !about) {
49
54
  const opened = await openRelayRequest({
@@ -53,8 +58,20 @@ export function createNetwork({
53
58
  if (opened) {
54
59
  about = opened.about;
55
60
  keyPrint = opened.fingerprint;
61
+ project = opened.project ?? null;
56
62
  }
57
63
  }
64
+ if (project || isChannel(thread.id)) {
65
+ if (
66
+ project &&
67
+ thread.role === "target" &&
68
+ thread.status === "requested"
69
+ )
70
+ invited.push({ id: thread.id, project, fingerprint: keyPrint });
71
+ if (thread.role === "asker")
72
+ sent.push({ id: thread.id, status: thread.status });
73
+ continue;
74
+ }
58
75
  items.push(
59
76
  item({
60
77
  id: thread.id,
@@ -77,6 +94,7 @@ export function createNetwork({
77
94
  }
78
95
  // Threads this computer holds that Harness no longer lists (older ones, or Harness out of reach).
79
96
  for (const here of local.values()) {
97
+ if (isChannel(here.task_id)) continue;
80
98
  items.push(
81
99
  item({
82
100
  id: here.task_id,
@@ -104,6 +122,8 @@ export function createNetwork({
104
122
  ok: true,
105
123
  connected: Boolean(server),
106
124
  items,
125
+ invited,
126
+ sent,
107
127
  needsYou: items.filter((entry) => entry.group === "needs_you").length,
108
128
  };
109
129
  };
@@ -273,5 +293,17 @@ export function createNetwork({
273
293
  if (store.meta(AUTO_SEND_DEFAULT) === "1") store.setAutoSend(taskId, true);
274
294
  };
275
295
 
276
- return { command, opened };
296
+ /** Requests to work on a shared project together, waiting for the person's answer. */
297
+ const invites = async () => (await conversations()).invited;
298
+ /** Where each project invitation this person sent stands at Harness: requested, accepted, declined or expired. */
299
+ const sentProjects = async () => (await conversations()).sent;
300
+ /** The person's answer to a request (accept, decline or block), as Harness takes it. */
301
+ const decide = (id, decision) => harness({ op: "decide", id, decision });
302
+ /** The person's own handle on Harness, or null before they claim one. */
303
+ const myHandle = async () => {
304
+ const answer = await harness({ op: "card" });
305
+ return answer.card?.handle ?? null;
306
+ };
307
+
308
+ return { command, opened, invites, sentProjects, decide, myHandle };
277
309
  }