tryharness 0.7.82 → 0.7.86

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.
Files changed (216) hide show
  1. package/README.md +21 -19
  2. package/assets/dsh-plugin.mjs +75 -4
  3. package/assets/herdr-mod/harness/main.js +367 -0
  4. package/assets/herdr-mod/harness/mod.json +6 -0
  5. package/assets/opencode-plugin.js +87 -22
  6. package/assets/pi-extension.ts +81 -2
  7. package/cli.mjs +544 -208
  8. package/lib/adapters.mjs +62 -27
  9. package/lib/agentBinaries.mjs +6 -8
  10. package/lib/agentClaims.mjs +168 -0
  11. package/lib/agentReadTools.json +415 -0
  12. package/lib/agentSignIn.mjs +17 -18
  13. package/lib/agentWiring.mjs +114 -0
  14. package/lib/archetypes.js +10 -11
  15. package/lib/attention.mjs +100 -0
  16. package/lib/audit.mjs +1 -1
  17. package/lib/backupSetup.mjs +6 -28
  18. package/lib/bankrApprovals.mjs +86 -0
  19. package/lib/boardAccess.mjs +40 -66
  20. package/lib/boardBackup.mjs +86 -85
  21. package/lib/boardCommands.mjs +28 -0
  22. package/lib/boardFileCommands.mjs +29 -36
  23. package/lib/boardFiles.mjs +83 -15
  24. package/lib/boardMirror.mjs +78 -11
  25. package/lib/boardProtocol.json +193 -123
  26. package/lib/boardThreads.mjs +19 -37
  27. package/lib/boardTools.mjs +22 -15
  28. package/lib/boardWatches.mjs +43 -15
  29. package/lib/bridge.mjs +7 -3
  30. package/lib/browserAgentTools.mjs +59 -0
  31. package/lib/browserWake.mjs +0 -6
  32. package/lib/cards.mjs +57 -2
  33. package/lib/circling.mjs +189 -0
  34. package/lib/cleanup.mjs +234 -0
  35. package/lib/cloudBoot.mjs +21 -4
  36. package/lib/cloudSave.mjs +46 -5
  37. package/lib/compaction.mjs +8 -1
  38. package/lib/completion.mjs +358 -0
  39. package/lib/computerDevices.mjs +853 -0
  40. package/lib/connectionStatus.mjs +34 -0
  41. package/lib/connectors.mjs +139 -1
  42. package/lib/coordinator.mjs +108 -14
  43. package/lib/coreModels.mjs +36 -12
  44. package/lib/daemon.mjs +2435 -333
  45. package/lib/daemonLock.mjs +103 -0
  46. package/lib/deviceDoor.mjs +308 -0
  47. package/lib/deviceIdentity.mjs +114 -0
  48. package/lib/deviceList.mjs +172 -0
  49. package/lib/deviceSeal.mjs +74 -0
  50. package/lib/dispatcher.mjs +497 -26
  51. package/lib/dispatches.mjs +3 -3
  52. package/lib/environment.mjs +2 -1
  53. package/lib/environments.mjs +67 -41
  54. package/lib/events.mjs +318 -0
  55. package/lib/facts.mjs +170 -0
  56. package/lib/fileSource.mjs +540 -0
  57. package/lib/files.mjs +47 -2
  58. package/lib/gitHost.mjs +39 -1
  59. package/lib/goalCommands.mjs +12 -80
  60. package/lib/handover.mjs +21 -16
  61. package/lib/harnessOffers.mjs +140 -15
  62. package/lib/herdr.mjs +100 -15
  63. package/lib/herdrAppCall.mjs +19 -0
  64. package/lib/herdrCore.mjs +59 -0
  65. package/lib/herdrRuns.mjs +1126 -0
  66. package/lib/hookDialects.mjs +235 -50
  67. package/lib/identityLink.mjs +81 -0
  68. package/lib/inference.mjs +31 -2
  69. package/lib/jamAccess.mjs +82 -0
  70. package/lib/{projectBoard.mjs → jamBoard.mjs} +5 -4
  71. package/lib/{projectGit.mjs → jamGit.mjs} +53 -15
  72. package/lib/jamKey.mjs +274 -0
  73. package/lib/{projectPieces.mjs → jamPieces.mjs} +35 -29
  74. package/lib/{projectSettings.mjs → jamSettings.mjs} +12 -22
  75. package/lib/jamStore.mjs +973 -0
  76. package/lib/jamUpgrade.mjs +112 -0
  77. package/lib/jams.mjs +3079 -0
  78. package/lib/kanban.mjs +13 -7
  79. package/lib/landed.mjs +5 -1
  80. package/lib/library.mjs +41 -22
  81. package/lib/limits.mjs +91 -0
  82. package/lib/lineDiff.mjs +97 -0
  83. package/lib/lineup.mjs +18 -13
  84. package/lib/link.mjs +584 -0
  85. package/lib/localStack.mjs +75 -16
  86. package/lib/localmodels.mjs +58 -78
  87. package/lib/loopBackstop.mjs +2 -1
  88. package/lib/machine.mjs +544 -0
  89. package/lib/machineLink.mjs +446 -0
  90. package/lib/machineRoutes.mjs +68 -19
  91. package/lib/machineRuns.mjs +85 -4
  92. package/lib/machineSeal.mjs +6 -31
  93. package/lib/manager.mjs +134 -12
  94. package/lib/mcp-stdio.mjs +492 -215
  95. package/lib/mcpRelay.mjs +34 -35
  96. package/lib/members.json +2 -2
  97. package/lib/modelRoute.mjs +162 -0
  98. package/lib/nativeHost.mjs +81 -90
  99. package/lib/nativeSenses.mjs +258 -0
  100. package/lib/nerves.mjs +523 -0
  101. package/lib/network.mjs +117 -278
  102. package/lib/networkPlaces.mjs +578 -0
  103. package/lib/nextStep.mjs +95 -0
  104. package/lib/notify.mjs +2 -2
  105. package/lib/nudge.mjs +116 -10
  106. package/lib/onboard.mjs +6 -6
  107. package/lib/originals.mjs +216 -0
  108. package/lib/outsideEvents.mjs +383 -0
  109. package/lib/outsideRuns.mjs +230 -0
  110. package/lib/ownMachines.mjs +674 -256
  111. package/lib/pain.mjs +215 -0
  112. package/lib/pairing.mjs +91 -11
  113. package/lib/paths.mjs +42 -3
  114. package/lib/peerProcess.mjs +21 -7
  115. package/lib/peopleLink.mjs +268 -0
  116. package/lib/personNotices.mjs +3 -2
  117. package/lib/phones.mjs +252 -542
  118. package/lib/placeCards.mjs +282 -0
  119. package/lib/placeChecks.mjs +95 -0
  120. package/lib/placeCommands.mjs +8 -17
  121. package/lib/placeRequests.mjs +152 -0
  122. package/lib/placeStore.mjs +295 -0
  123. package/lib/placeTool.d.ts +12 -0
  124. package/lib/placeTool.js +40 -0
  125. package/lib/places.mjs +63 -14
  126. package/lib/plans.mjs +53 -8
  127. package/lib/presence.mjs +270 -0
  128. package/lib/privateNetwork.d.ts +2 -0
  129. package/lib/privateNetwork.js +93 -0
  130. package/lib/proposals.mjs +300 -0
  131. package/lib/publicFetch.d.ts +32 -0
  132. package/lib/publicFetch.js +248 -0
  133. package/lib/reach.mjs +128 -0
  134. package/lib/rebuildable.mjs +72 -0
  135. package/lib/recall.mjs +216 -0
  136. package/lib/record.mjs +13 -0
  137. package/lib/reflexes.mjs +392 -0
  138. package/lib/relayLimits.mjs +31 -2
  139. package/lib/releaseNotice.mjs +198 -0
  140. package/lib/removeHarness.mjs +15 -4
  141. package/lib/repoLinks.mjs +204 -35
  142. package/lib/runAuthority.mjs +102 -39
  143. package/lib/runBrief.mjs +93 -40
  144. package/lib/runRequests.mjs +52 -14
  145. package/lib/runUsage.mjs +31 -0
  146. package/lib/runWorker.mjs +74 -25
  147. package/lib/runner.mjs +289 -45
  148. package/lib/runtime-install.mjs +37 -8
  149. package/lib/schedules.mjs +171 -47
  150. package/lib/screenWatches.mjs +221 -0
  151. package/lib/sealed.mjs +12 -30
  152. package/lib/sealedThreads.mjs +198 -392
  153. package/lib/secretStore.mjs +178 -0
  154. package/lib/secrets.mjs +11 -0
  155. package/lib/seen.mjs +3 -9
  156. package/lib/selfUpdate.mjs +51 -15
  157. package/lib/senseCall.mjs +1514 -0
  158. package/lib/senseHook.mjs +114 -0
  159. package/lib/senseTools.mjs +1298 -0
  160. package/lib/sessionBriefs.mjs +87 -0
  161. package/lib/sessionControl.mjs +63 -13
  162. package/lib/sessionFiles.mjs +85 -0
  163. package/lib/setupChoices.mjs +12 -3
  164. package/lib/setupMode.mjs +70 -25
  165. package/lib/sharedKeys.mjs +166 -0
  166. package/lib/sleep.mjs +396 -0
  167. package/lib/sources.mjs +306 -0
  168. package/lib/speech.mjs +166 -411
  169. package/lib/spoken.mjs +210 -0
  170. package/lib/steerHook.mjs +3 -1
  171. package/lib/steerQueue.mjs +40 -11
  172. package/lib/store.mjs +323 -130
  173. package/lib/stuck.mjs +85 -7
  174. package/lib/swarm.mjs +157 -49
  175. package/lib/swarmDevices.mjs +25 -85
  176. package/lib/swarmMemory.mjs +93 -9
  177. package/lib/t3.mjs +73 -3
  178. package/lib/taskCommands.mjs +51 -60
  179. package/lib/taskRooms.mjs +30 -4
  180. package/lib/taskRules.json +29 -0
  181. package/lib/taskRules.mjs +21 -0
  182. package/lib/taskRuns.mjs +74 -11
  183. package/lib/team.mjs +2 -1
  184. package/lib/threadActions.mjs +37 -9
  185. package/lib/threadAuthority.mjs +4 -4
  186. package/lib/threadBriefs.mjs +173 -43
  187. package/lib/threadNotes.mjs +320 -0
  188. package/lib/threadRecord.mjs +491 -0
  189. package/lib/threadRuns.mjs +216 -108
  190. package/lib/threadView.mjs +27 -30
  191. package/lib/threadWatches.mjs +1962 -0
  192. package/lib/timeSense.mjs +839 -0
  193. package/lib/tripwires.mjs +454 -0
  194. package/lib/ui.mjs +1 -1
  195. package/lib/vault.mjs +560 -45
  196. package/lib/vaultCommands.mjs +5 -3
  197. package/lib/vaultPeers.mjs +165 -0
  198. package/lib/vaultTools.d.ts +4 -1
  199. package/lib/vaultTools.js +22 -1
  200. package/lib/verdicts.mjs +12 -26
  201. package/lib/versions.mjs +117 -0
  202. package/lib/waitTool.mjs +278 -0
  203. package/lib/wakePicture.mjs +268 -0
  204. package/lib/wakeQueue.mjs +108 -0
  205. package/lib/watchResponses.mjs +533 -0
  206. package/lib/watches.mjs +290 -145
  207. package/lib/windowAsks.mjs +80 -17
  208. package/lib/worktrees.mjs +159 -9
  209. package/npm-shrinkwrap.json +138 -631
  210. package/package.json +7 -6
  211. package/release.json +212 -130
  212. package/lib/callSessions.mjs +0 -51
  213. package/lib/directLink.mjs +0 -349
  214. package/lib/peopleBoard.mjs +0 -131
  215. package/lib/projects.mjs +0 -2917
  216. package/lib/roomChannels.mjs +0 -667
package/lib/network.mjs CHANGED
@@ -1,31 +1,24 @@
1
- // Swarms talking to swarms, on the person's computer: the one list every surface shows (the buddy's
2
- // Swarms tab, the dashboard, the PiP), built here from what Harness holds (who asked whom, and the
3
- // answer) and what only this computer holds (each thread's words, held replies, what the person has
4
- // read). A sealed request's subject is opened here, never at Harness. Only the person ("user") calls
5
- // these; another agent works a thread through board.thread.* on the task it holds.
6
-
7
- import { peopleBoard } from "./peopleBoard.mjs";
1
+ // Friends, on the person's computer (docs/jam-plan.md J1): the one list every surface shows (the buddy, the
2
+ // dashboard, the PiP), built here from what Harness holds (who asked whom to be friends, and the answer) and what only
3
+ // this computer holds (the other computer's pinned key, what the person has read). Only the person ("user") calls
4
+ // these; no agent is ever in a friendship.
8
5
 
9
6
  const SEEN = (id) => `relay_seen:${id}`;
10
- const AUTO_SEND_DEFAULT = "relay_auto_send_default";
11
7
  const DECISIONS = new Set(["accept", "decline", "block"]);
8
+ const STANDING = new Set(["requested", "accepted", "accepted_pending"]);
12
9
  const handleOf = (identity) =>
13
10
  String(identity || "")
14
11
  .split("/")[0]
15
- .toLowerCase();
16
- const agentOf = (identity) => String(identity || "").split("/")[1] || "";
12
+ .toLowerCase()
13
+ .replace(/^@/, "");
17
14
 
18
15
  export function createNetwork({
19
16
  store,
20
17
  askHarness,
21
- relayRequest,
22
- openRelayRequest,
23
18
  fingerprint,
24
19
  myKey,
25
- // A relay thread that carries a shared project (projects.mjs): Swarms lists the project, not the thread under it.
26
- isChannel = () => false,
27
- // The person blocked a handle: whatever is open with them on this computer ends (security audit P9).
28
- blocked = () => {},
20
+ // A friendship ended (unfriended, or a block from either side): it closes on this computer.
21
+ ended = () => {},
29
22
  }) {
30
23
  // Harness answers for the server's half; a refusal comes back as a plain error the person can read.
31
24
  const harness = async (input) => {
@@ -36,288 +29,159 @@ export function createNetwork({
36
29
  return rest;
37
30
  };
38
31
 
39
- // One row per request or thread, grouped by what it needs: the person (a request to answer, a held reply,
40
- // a message from a person), nothing (open), the other side (a request not answered yet), or nobody (ended).
41
- const conversations = async () => {
42
- const [server, card] = await Promise.all([
43
- harness({ op: "threads" }).catch(() => null),
44
- harness({ op: "card" }).catch(() => null),
45
- ]);
46
- // A block made where this computer did not hear it (the dashboard while it was off) ends what is open here too.
47
- for (const handle of Array.isArray(card?.blocks) ? card.blocks : [])
48
- if (
49
- store
50
- .relayThreads()
51
- .some(
52
- (row) =>
53
- !row.closed_at && handleOf(row.with_agent) === handleOf(handle)
54
- )
55
- )
56
- blocked(handleOf(handle));
57
- const local = new Map(
58
- store.relayThreads().map((row) => [row.task_id, row])
59
- );
60
- const items = [];
61
- const invited = [];
32
+ // The friendship this computer holds under a thread id, open or not.
33
+ const localThread = (id) =>
34
+ store.relayThreads(1_000).find((row) => row.task_id === id) ?? null;
35
+
36
+ const friendOf = async (thread, here) => {
37
+ const handle =
38
+ thread.role === "asker" ? thread.target.handle : thread.asker.handle;
39
+ const pinned = store.relayPeer(handle);
40
+ const seen = Number(store.meta(SEEN(thread.id)) || 0);
41
+ return {
42
+ id: thread.id,
43
+ handle,
44
+ since: thread.decidedAt ?? thread.createdAt,
45
+ // The other computer's key, to compare with them; none yet while the friendship waits for it.
46
+ fingerprint: pinned ? await fingerprint(pinned.public_key) : null,
47
+ // Nothing can be sent until this computer has taken the friendship with their key.
48
+ ready: Boolean(here && !here.closed_at),
49
+ keyChanged: Boolean(store.meta(`relay-key-waiting:${handle}`)),
50
+ unread: Boolean(here && here.last_in_seq > seen),
51
+ // The last thing said, for the line under the friend's name in Messages.
52
+ last: here?.last
53
+ ? {
54
+ direction: here.last.direction,
55
+ text: here.last.text,
56
+ at: here.last.created_at,
57
+ }
58
+ : null,
59
+ };
60
+ };
61
+
62
+ // Friend requests both ways and friendships, from Harness's list. A friendship Harness says ended while this computer
63
+ // was off ends here too.
64
+ const friends = async () => {
65
+ const server = await harness({ op: "friends" }).catch(() => null);
66
+ const incoming = [];
62
67
  const sent = [];
68
+ const list = [];
63
69
  for (const thread of server?.threads ?? []) {
64
- const here = local.get(thread.id) || null;
65
- local.delete(thread.id);
66
- const peer = thread.role === "asker" ? thread.target : thread.asker;
67
- let about = thread.about || here?.objective || "";
68
- let keyPrint = null;
69
- let project = null;
70
- // A sealed request's subject: opened on this computer, with the other computer's key to compare.
71
- if (thread.sealed && !about) {
72
- const opened = await openRelayRequest({
73
- sealed: thread.sealed,
74
- from: `${peer.handle}/${peer.agent}`,
75
- id: thread.role === "target" ? thread.id : null,
76
- }).catch(() => null);
77
- if (opened) {
78
- about = opened.about;
79
- keyPrint = opened.fingerprint;
80
- project = opened.project ?? null;
81
- }
82
- }
83
- if (project || isChannel(thread.id)) {
84
- if (
85
- project &&
86
- thread.role === "target" &&
87
- thread.status === "requested"
88
- )
89
- invited.push({
90
- id: thread.id,
91
- project,
92
- sender: peer.handle,
93
- fingerprint: keyPrint,
94
- createdAt: thread.createdAt,
95
- });
96
- if (thread.role === "asker")
97
- sent.push({ id: thread.id, status: thread.status, project });
70
+ const here = localThread(thread.id);
71
+ if (!STANDING.has(thread.status)) {
72
+ if (here && !here.closed_at) ended(thread.id);
98
73
  continue;
99
74
  }
100
- items.push(
101
- item({
75
+ if (thread.status === "requested" && thread.role === "target")
76
+ incoming.push({
102
77
  id: thread.id,
103
- role: thread.role,
104
- kind:
105
- thread.kind ||
106
- (thread.target?.agent === "person" ? "person" : "agent"),
107
- status: thread.status,
108
- about,
109
- peer: { handle: peer.handle, agent: peer.agent },
110
- mine:
111
- thread.role === "asker" ? thread.asker.agent : thread.target.agent,
112
- askerSince: thread.role === "target" ? thread.asker.since : null,
113
- sealed: Boolean(thread.sealed),
114
- fingerprint: keyPrint,
78
+ handle: thread.asker.handle,
79
+ // How long the asker's account has existed: one thing to judge a stranger by.
80
+ askerSince: thread.asker.since,
115
81
  createdAt: thread.createdAt,
116
- here,
117
- })
118
- );
119
- }
120
- // Threads this computer holds that Harness no longer lists (older ones, or Harness out of reach).
121
- for (const here of local.values()) {
122
- if (isChannel(here.task_id)) continue;
123
- items.push(
124
- item({
125
- id: here.task_id,
126
- role: here.role,
127
- kind: agentOf(here.with_agent) === "person" ? "person" : "agent",
128
- status: here.closed_at ? "closed" : "accepted",
129
- about: here.objective,
130
- peer: {
131
- handle: handleOf(here.with_agent),
132
- agent: agentOf(here.with_agent),
133
- },
134
- mine: here.target_agent === "user" ? "person" : here.target_agent,
135
- askerSince: null,
136
- sealed: false,
137
- fingerprint: null,
138
- createdAt: here.opened_at,
139
- here,
140
- })
141
- );
82
+ });
83
+ else if (thread.status === "requested")
84
+ sent.push({
85
+ id: thread.id,
86
+ handle: thread.target.handle,
87
+ createdAt: thread.createdAt,
88
+ });
89
+ else list.push(await friendOf(thread, here));
142
90
  }
143
- items.sort((a, b) =>
144
- String(b.updatedAt).localeCompare(String(a.updatedAt))
145
- );
146
91
  return {
147
92
  ok: true,
148
93
  connected: Boolean(server),
149
- items,
150
- invited,
151
- sent,
152
- needsYou: items.filter((entry) => entry.group === "needs_you").length,
153
- };
154
- };
155
-
156
- const item = ({
157
- id,
158
- role,
159
- kind,
160
- status,
161
- about,
162
- peer,
163
- mine,
164
- askerSince,
165
- sealed,
166
- fingerprint: keyPrint,
167
- createdAt,
168
- here,
169
- }) => {
170
- const seen = Number(store.meta(SEEN(id)) || 0);
171
- const thread = here
172
- ? {
173
- open: !here.closed_at,
174
- autoSend: here.auto_send,
175
- held: here.held,
176
- unread: here.last_in_seq > seen,
177
- messages: here.messages,
178
- outcome: here.outcome,
179
- last: here.last
180
- ? {
181
- direction: here.last.direction,
182
- sender: here.last.sender,
183
- text: String(here.last.text || "").slice(0, 160),
184
- state: here.last.state,
185
- at: here.last.created_at,
186
- }
187
- : null,
188
- }
189
- : null;
190
- const reason =
191
- role === "target" && status === "requested"
192
- ? "request"
193
- : thread?.open && thread.held
194
- ? "held"
195
- : thread?.open && kind === "person" && thread.unread
196
- ? "message"
197
- : null;
198
- const group = reason
199
- ? "needs_you"
200
- : thread
201
- ? thread.open
202
- ? "open"
203
- : "ended"
204
- : status === "requested"
205
- ? "waiting"
206
- : status === "accepted" || status === "accepted_pending"
207
- ? "open"
208
- : "ended";
209
- return {
210
- id,
211
- role,
212
- kind,
213
- status,
214
- about,
215
- peer,
216
- mine,
217
- askerSince,
218
- sealed,
219
- fingerprint: keyPrint,
220
- group,
221
- reason,
222
- thread,
223
- createdAt,
224
- updatedAt: here?.updated_at || createdAt,
94
+ friends: list,
95
+ requests: { incoming, sent },
96
+ needsYou: incoming.length + list.filter((friend) => friend.unread).length,
225
97
  };
226
98
  };
227
99
 
228
- // A refusal from Harness or the other computer comes back as the answer, in its own words.
100
+ // A refusal from Harness comes back as the answer, in its own words.
229
101
  const answered = (promise) => ({
230
102
  pending: promise.catch((error) => ({ ok: false, error: error.message })),
231
103
  });
104
+ const handleIn = (request) => handleOf(request.handle);
105
+ // The server's half of the person's card and search: what the dashboard asks Harness directly. Friend requests,
106
+ // decisions and unfriending have their own commands.
107
+ const CARD_OPS = new Set([
108
+ "card",
109
+ "check",
110
+ "claim",
111
+ "update",
112
+ "list",
113
+ "unlist",
114
+ "search",
115
+ "show",
116
+ "block",
117
+ "unblock",
118
+ ]);
119
+
232
120
  const command = (request, agent) => {
233
121
  if (agent !== "user")
234
122
  return {
235
123
  ok: false,
236
- error: "only the person talks to other swarms from here",
124
+ error: "only the person adds friends and answers them",
237
125
  };
238
126
  const id = String(request.id || "");
239
127
  switch (request.command) {
240
128
  case "board.relay.list":
241
- return answered(conversations());
242
- // The board of every ask between the person's swarm and one other person's (peopleBoard.mjs).
243
- case "board.relay.board": {
244
- const handle = String(request.handle || "")
245
- .toLowerCase()
246
- .replace(/^@/, "");
247
- if (!handle) return { ok: false, error: "say whose board (handle)" };
129
+ return answered(friends());
130
+ case "board.relay.friend": {
131
+ const handle = handleIn(request);
132
+ if (!handle) return { ok: false, error: "say who (handle)" };
133
+ return answered(
134
+ harness({ op: "friend", handle }).then((answer) => ({
135
+ ok: true,
136
+ ...answer,
137
+ }))
138
+ );
139
+ }
140
+ case "board.relay.decide":
141
+ if (!DECISIONS.has(String(request.decision)))
142
+ return { ok: false, error: "decision is accept, decline or block" };
248
143
  return answered(
249
- conversations().then((list) => ({
144
+ harness({
145
+ op: "decide",
146
+ id,
147
+ decision: String(request.decision),
148
+ }).then((answer) => ({ ok: true, ...answer }))
149
+ );
150
+ case "board.relay.unfriend": {
151
+ const handle = handleIn(request);
152
+ if (!handle) return { ok: false, error: "say who (handle)" };
153
+ return answered(
154
+ harness({ op: "unfriend", handle }).then((answer) => ({
250
155
  ok: true,
251
- ...peopleBoard(list.items, {
252
- handle,
253
- messagesOf: (taskId) => store.threadMessages(taskId),
254
- taskOf: (taskId) => store.getTask(taskId),
255
- }),
156
+ ...answer,
256
157
  }))
257
158
  );
258
159
  }
259
- // The server's half of Swarms (card, search, contacts, blocks): what the dashboard asks Harness directly.
260
160
  case "board.relay.network": {
261
- // Only the operation's own fields go to Harness, which refuses any other (a browser's call adds fromWindow and
262
- // sealedBy, phones.mjs).
161
+ // Only the operation's own fields go to Harness, which refuses any other (a browser's call adds fromWindow,
162
+ // phones.mjs).
263
163
  const {
264
164
  command: _command,
265
165
  agent: _agent,
266
166
  fromWindow: _fromWindow,
267
167
  hostedCaller: _hosted,
268
168
  provenance: _provenance,
269
- sealedBy: _sealedBy,
270
169
  ...input
271
170
  } = request;
272
- if (input.op === "decide" || input.op === "threads")
171
+ if (!CARD_OPS.has(String(input.op)))
273
172
  return {
274
173
  ok: false,
275
- error: "use board.relay.decide and board.relay.list",
174
+ error:
175
+ "use board.relay.list, board.relay.friend, board.relay.decide and board.relay.unfriend",
276
176
  };
277
177
  return answered(
278
- harness(input).then((answer) => {
279
- if (input.op === "block" && input.on === true)
280
- blocked(handleOf(input.handle));
281
- return { ok: true, ...answer };
282
- })
283
- );
284
- }
285
- case "board.relay.decide":
286
- if (!DECISIONS.has(String(request.decision)))
287
- return { ok: false, error: "decision is accept, decline or block" };
288
- return answered(
289
- harness({
290
- op: "decide",
291
- id,
292
- decision: String(request.decision),
293
- }).then((answer) => {
294
- if (request.decision === "block" && answer.thread?.asker?.handle)
295
- blocked(handleOf(answer.thread.asker.handle));
296
- return { ok: true, ...answer };
297
- })
298
- );
299
- // A request from this computer: to one of their listed agents from one of the person's, or to the person themselves.
300
- case "board.relay.request": {
301
- const handle = String(request.handle || "")
302
- .toLowerCase()
303
- .replace(/^@/, "");
304
- const toAgent = String(request.toAgent || "person");
305
- const fromAgent =
306
- toAgent === "person" ? "person" : String(request.fromAgent || "");
307
- return answered(
308
- relayRequest({
309
- to: `${handle}/${toAgent}`,
310
- fromAgent,
311
- about: request.about,
312
- brief: request.brief,
313
- refs: request.refs,
314
- readable: request.readable === true,
315
- }).then((made) => ({ ok: true, ...made }))
178
+ harness(input).then((answer) => ({ ok: true, ...answer }))
316
179
  );
317
180
  }
181
+ // What the person has read of a friend's messages.
318
182
  case "board.relay.seen": {
319
183
  const thread = store.getThread(id);
320
- if (!thread) return { ok: false, error: "no thread on this task" };
184
+ if (!thread) return { ok: false, error: "no friendship by that id" };
321
185
  const last = store
322
186
  .threadMessages(id)
323
187
  .filter((message) => message.direction === "in")
@@ -325,11 +189,6 @@ export function createNetwork({
325
189
  store.meta(SEEN(id), String(last?.seq ?? 0));
326
190
  return { ok: true };
327
191
  }
328
- // Whether replies the person's agents write wait for the person on a new thread (the default) or send on their own.
329
- case "board.relay.defaults":
330
- if (typeof request.autoSend === "boolean")
331
- store.meta(AUTO_SEND_DEFAULT, request.autoSend ? "1" : "0");
332
- return { ok: true, autoSend: store.meta(AUTO_SEND_DEFAULT) === "1" };
333
192
  case "board.relay.peers":
334
193
  return answered(
335
194
  Promise.all(
@@ -349,31 +208,11 @@ export function createNetwork({
349
208
  }
350
209
  };
351
210
 
352
- /** A thread just opened on this computer starts with the person's default for their agents' replies. */
353
- const opened = (taskId) => {
354
- if (store.meta(AUTO_SEND_DEFAULT) === "1") store.setAutoSend(taskId, true);
355
- };
356
-
357
- /** Requests to work on a shared project together, waiting for the person's answer. */
358
- const invites = async () => (await conversations()).invited;
359
- /** Where each project invitation this person sent stands at Harness: requested, accepted, declined or expired. */
360
- const sentProjects = async () => (await conversations()).sent;
361
- /** The person's answer to a request (accept, decline or block), as Harness takes it. */
362
- const decide = (id, decision) => harness({ op: "decide", id, decision });
363
211
  /** The person's own handle on Harness, or null before they claim one. */
364
212
  const myHandle = async () => {
365
213
  const answer = await harness({ op: "card" });
366
214
  return answer.card?.handle ?? null;
367
215
  };
368
216
 
369
- return {
370
- command,
371
- opened,
372
- invites,
373
- sentProjects,
374
- decide,
375
- myHandle,
376
- // Harness says the person blocked a handle from another of their screens.
377
- blockedElsewhere: (handle) => blocked(handleOf(handle)),
378
- };
217
+ return { command, friends, myHandle };
379
218
  }