tryharness 0.7.32 → 0.7.33
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/README.md +48 -0
- package/lib/actorRoster.mjs +106 -0
- package/lib/boardAccess.mjs +328 -0
- package/lib/boardCommands.mjs +28 -0
- package/lib/boardFileCommands.mjs +228 -0
- package/lib/boardFiles.mjs +584 -0
- package/lib/boardProtocol.json +470 -0
- package/lib/boardProtocol.mjs +27 -0
- package/lib/boardThreads.mjs +153 -0
- package/lib/boardTools.mjs +202 -0
- package/lib/boardWatches.mjs +92 -0
- package/lib/bridge.mjs +272 -0
- package/lib/cards.mjs +5 -83
- package/lib/coordinator.mjs +13 -3
- package/lib/daemon.mjs +809 -5459
- package/lib/goalCommands.mjs +459 -0
- package/lib/harnessModel.mjs +166 -0
- package/lib/mcp-stdio.mjs +8 -2
- package/lib/models.mjs +107 -11
- package/lib/phones.mjs +8 -121
- package/lib/roomPage.mjs +44 -0
- package/lib/runAuthority.mjs +109 -0
- package/lib/runWorker.mjs +503 -0
- package/lib/sessionControl.mjs +788 -0
- package/lib/sessionIndex.mjs +245 -0
- package/lib/store.mjs +28 -9
- package/lib/swarm.mjs +28 -9
- package/lib/taskCommands.mjs +737 -0
- package/lib/taskRuns.mjs +196 -0
- package/lib/threadRuns.mjs +471 -0
- package/package.json +1 -1
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"inboxVersion": 2,
|
|
4
|
+
"commands": {
|
|
5
|
+
"board.agents": "task",
|
|
6
|
+
"board.answer": "task",
|
|
7
|
+
"board.audio.listen": "tools",
|
|
8
|
+
"board.children": "task",
|
|
9
|
+
"board.claim": "task",
|
|
10
|
+
"board.code.search": "tools",
|
|
11
|
+
"board.context.add": "task",
|
|
12
|
+
"board.context.search": "task",
|
|
13
|
+
"board.digest": "watch",
|
|
14
|
+
"board.file.add": "file",
|
|
15
|
+
"board.file.get": "file",
|
|
16
|
+
"board.file.share": "file",
|
|
17
|
+
"board.files.search": "tools",
|
|
18
|
+
"board.get": "task",
|
|
19
|
+
"board.goal.create": "goals",
|
|
20
|
+
"board.goal.finish": "goals",
|
|
21
|
+
"board.goal.folder": "goals",
|
|
22
|
+
"board.goal.get": "goals",
|
|
23
|
+
"board.goal.invite": "goals",
|
|
24
|
+
"board.goal.list": "goals",
|
|
25
|
+
"board.goal.resume": "goals",
|
|
26
|
+
"board.goal.stop": "goals",
|
|
27
|
+
"board.list": "task",
|
|
28
|
+
"board.live": "live",
|
|
29
|
+
"board.live.focus": "live",
|
|
30
|
+
"board.live.place": "live",
|
|
31
|
+
"board.live.read": "live",
|
|
32
|
+
"board.live.say": "live",
|
|
33
|
+
"board.live.take": "live",
|
|
34
|
+
"board.live.turn": "live",
|
|
35
|
+
"board.live.where": "live",
|
|
36
|
+
"board.local.events": "watch",
|
|
37
|
+
"board.media.search": "tools",
|
|
38
|
+
"board.post": "task",
|
|
39
|
+
"board.prompted": "prompt",
|
|
40
|
+
"board.relay.decide": "relay",
|
|
41
|
+
"board.relay.defaults": "relay",
|
|
42
|
+
"board.relay.list": "relay",
|
|
43
|
+
"board.relay.network": "relay",
|
|
44
|
+
"board.relay.peers": "relay",
|
|
45
|
+
"board.relay.request": "relay",
|
|
46
|
+
"board.relay.seen": "relay",
|
|
47
|
+
"board.release": "task",
|
|
48
|
+
"board.remove": "task",
|
|
49
|
+
"board.report": "task",
|
|
50
|
+
"board.room.post": "goals",
|
|
51
|
+
"board.room.read": "goals",
|
|
52
|
+
"board.room.search": "goals",
|
|
53
|
+
"board.run": "task",
|
|
54
|
+
"board.screen.search": "tools",
|
|
55
|
+
"board.screens.compare": "tools",
|
|
56
|
+
"board.snippet.decide": "tools",
|
|
57
|
+
"board.snippet.list": "tools",
|
|
58
|
+
"board.snippet.request": "tools",
|
|
59
|
+
"board.standing": "task",
|
|
60
|
+
"board.standing.check": "task",
|
|
61
|
+
"board.standing.off": "task",
|
|
62
|
+
"board.standing.on": "task",
|
|
63
|
+
"board.standing.set": "task",
|
|
64
|
+
"board.swarm.agents": "swarm",
|
|
65
|
+
"board.swarm.browse": "swarm",
|
|
66
|
+
"board.swarm.ceiling": "swarm",
|
|
67
|
+
"board.swarm.checkin": "swarm",
|
|
68
|
+
"board.swarm.checkin.remove": "swarm",
|
|
69
|
+
"board.swarm.checkins": "swarm",
|
|
70
|
+
"board.swarm.coordinator": "swarm",
|
|
71
|
+
"board.swarm.diff": "swarm",
|
|
72
|
+
"board.swarm.discard": "swarm",
|
|
73
|
+
"board.swarm.folder": "swarm",
|
|
74
|
+
"board.swarm.goal": "swarm",
|
|
75
|
+
"board.swarm.health": "swarm",
|
|
76
|
+
"board.swarm.lessons": "swarm",
|
|
77
|
+
"board.swarm.lessons.edit": "swarm",
|
|
78
|
+
"board.swarm.lessons.remove": "swarm",
|
|
79
|
+
"board.swarm.lessons.undo": "swarm",
|
|
80
|
+
"board.swarm.list": "swarm",
|
|
81
|
+
"board.swarm.merge": "swarm",
|
|
82
|
+
"board.swarm.model": "swarm",
|
|
83
|
+
"board.swarm.models": "swarm",
|
|
84
|
+
"board.swarm.note": "swarm",
|
|
85
|
+
"board.swarm.place": "swarm",
|
|
86
|
+
"board.swarm.places": "swarm",
|
|
87
|
+
"board.swarm.post": "swarm",
|
|
88
|
+
"board.swarm.read": "swarm",
|
|
89
|
+
"board.swarm.resume": "swarm",
|
|
90
|
+
"board.swarm.rounds": "swarm",
|
|
91
|
+
"board.swarm.routing": "swarm",
|
|
92
|
+
"board.swarm.search": "swarm",
|
|
93
|
+
"board.swarm.start": "swarm",
|
|
94
|
+
"board.swarm.start_run": "swarm",
|
|
95
|
+
"board.swarm.stop": "swarm",
|
|
96
|
+
"board.swarm.stop_all": "swarm",
|
|
97
|
+
"board.thread.auto": "thread",
|
|
98
|
+
"board.thread.discard": "thread",
|
|
99
|
+
"board.thread.end": "thread",
|
|
100
|
+
"board.thread.post": "thread",
|
|
101
|
+
"board.thread.read": "thread",
|
|
102
|
+
"board.thread.send": "thread",
|
|
103
|
+
"board.trace": "task",
|
|
104
|
+
"board.video.watch": "tools",
|
|
105
|
+
"board.wallet": "task",
|
|
106
|
+
"board.watch.add": "watch",
|
|
107
|
+
"board.watch.list": "watch",
|
|
108
|
+
"board.watch.remove": "watch",
|
|
109
|
+
"board.watch.start": "watch",
|
|
110
|
+
"harness.lane.forget": "task",
|
|
111
|
+
"harness.lane.share": "task",
|
|
112
|
+
"harness.lane.status": "task",
|
|
113
|
+
"image.read": "task",
|
|
114
|
+
"relay.open": "task",
|
|
115
|
+
"relay.request": "task",
|
|
116
|
+
"sessions.raw": "task",
|
|
117
|
+
"sessions.read": "task",
|
|
118
|
+
"sessions.search": "task",
|
|
119
|
+
"t3.connect": "task",
|
|
120
|
+
"tasks.status": "task",
|
|
121
|
+
"voice.status": "task",
|
|
122
|
+
"voice.transcribe": "task"
|
|
123
|
+
},
|
|
124
|
+
"families": [
|
|
125
|
+
{
|
|
126
|
+
"owner": "goals",
|
|
127
|
+
"prefixes": [
|
|
128
|
+
"board.goal.",
|
|
129
|
+
"board.room."
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"owner": "swarm",
|
|
134
|
+
"prefixes": [
|
|
135
|
+
"board.swarm."
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"owner": "relay",
|
|
140
|
+
"prefixes": [
|
|
141
|
+
"board.relay."
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"owner": "live",
|
|
146
|
+
"prefixes": [
|
|
147
|
+
"board.live"
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"owner": "watch",
|
|
152
|
+
"prefixes": [
|
|
153
|
+
"board.watch."
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"owner": "thread",
|
|
158
|
+
"prefixes": [
|
|
159
|
+
"board.thread."
|
|
160
|
+
]
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"owner": "file",
|
|
164
|
+
"prefixes": [
|
|
165
|
+
"board.file."
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
],
|
|
169
|
+
"access": {
|
|
170
|
+
"phone": [
|
|
171
|
+
"board.list",
|
|
172
|
+
"board.get",
|
|
173
|
+
"board.children",
|
|
174
|
+
"board.agents",
|
|
175
|
+
"board.post",
|
|
176
|
+
"board.run",
|
|
177
|
+
"board.release",
|
|
178
|
+
"board.answer",
|
|
179
|
+
"board.remove",
|
|
180
|
+
"board.thread.read",
|
|
181
|
+
"board.thread.post",
|
|
182
|
+
"board.thread.send",
|
|
183
|
+
"board.thread.discard",
|
|
184
|
+
"board.thread.auto",
|
|
185
|
+
"board.thread.end",
|
|
186
|
+
"board.goal.list",
|
|
187
|
+
"board.goal.get",
|
|
188
|
+
"board.goal.stop",
|
|
189
|
+
"board.room.read",
|
|
190
|
+
"board.file.get",
|
|
191
|
+
"board.file.share",
|
|
192
|
+
"board.swarm.list",
|
|
193
|
+
"board.swarm.read",
|
|
194
|
+
"board.swarm.start",
|
|
195
|
+
"board.swarm.post",
|
|
196
|
+
"board.swarm.stop",
|
|
197
|
+
"board.swarm.stop_all",
|
|
198
|
+
"board.swarm.resume",
|
|
199
|
+
"board.swarm.folder",
|
|
200
|
+
"board.swarm.coordinator",
|
|
201
|
+
"board.swarm.diff",
|
|
202
|
+
"board.swarm.merge",
|
|
203
|
+
"board.swarm.discard",
|
|
204
|
+
"board.swarm.start_run",
|
|
205
|
+
"board.swarm.agents",
|
|
206
|
+
"board.swarm.note",
|
|
207
|
+
"board.swarm.places",
|
|
208
|
+
"board.swarm.browse",
|
|
209
|
+
"board.swarm.place",
|
|
210
|
+
"board.live",
|
|
211
|
+
"board.live.read",
|
|
212
|
+
"board.live.say"
|
|
213
|
+
],
|
|
214
|
+
"browserPerson": [
|
|
215
|
+
"board.list",
|
|
216
|
+
"board.get",
|
|
217
|
+
"board.children",
|
|
218
|
+
"board.agents",
|
|
219
|
+
"board.post",
|
|
220
|
+
"board.run",
|
|
221
|
+
"board.release",
|
|
222
|
+
"board.answer",
|
|
223
|
+
"board.remove",
|
|
224
|
+
"board.thread.read",
|
|
225
|
+
"board.thread.post",
|
|
226
|
+
"board.thread.send",
|
|
227
|
+
"board.thread.discard",
|
|
228
|
+
"board.thread.auto",
|
|
229
|
+
"board.thread.end",
|
|
230
|
+
"board.goal.list",
|
|
231
|
+
"board.goal.get",
|
|
232
|
+
"board.goal.stop",
|
|
233
|
+
"board.room.read",
|
|
234
|
+
"board.file.get",
|
|
235
|
+
"board.file.share",
|
|
236
|
+
"board.swarm.list",
|
|
237
|
+
"board.swarm.read",
|
|
238
|
+
"board.swarm.start",
|
|
239
|
+
"board.swarm.post",
|
|
240
|
+
"board.swarm.stop",
|
|
241
|
+
"board.swarm.stop_all",
|
|
242
|
+
"board.swarm.resume",
|
|
243
|
+
"board.swarm.folder",
|
|
244
|
+
"board.swarm.coordinator",
|
|
245
|
+
"board.swarm.diff",
|
|
246
|
+
"board.swarm.merge",
|
|
247
|
+
"board.swarm.discard",
|
|
248
|
+
"board.swarm.start_run",
|
|
249
|
+
"board.swarm.agents",
|
|
250
|
+
"board.swarm.note",
|
|
251
|
+
"board.swarm.places",
|
|
252
|
+
"board.swarm.browse",
|
|
253
|
+
"board.swarm.place",
|
|
254
|
+
"board.live",
|
|
255
|
+
"board.live.read",
|
|
256
|
+
"board.live.say",
|
|
257
|
+
"board.goal.resume",
|
|
258
|
+
"board.swarm.lessons",
|
|
259
|
+
"board.standing",
|
|
260
|
+
"board.standing.check",
|
|
261
|
+
"board.standing.off",
|
|
262
|
+
"board.relay.list",
|
|
263
|
+
"board.relay.network",
|
|
264
|
+
"board.relay.decide",
|
|
265
|
+
"board.relay.request",
|
|
266
|
+
"board.relay.seen",
|
|
267
|
+
"board.relay.defaults",
|
|
268
|
+
"board.relay.peers"
|
|
269
|
+
],
|
|
270
|
+
"harnessBrowser": [
|
|
271
|
+
"board.list",
|
|
272
|
+
"board.get",
|
|
273
|
+
"board.post",
|
|
274
|
+
"board.claim",
|
|
275
|
+
"board.report",
|
|
276
|
+
"board.answer",
|
|
277
|
+
"board.thread.read",
|
|
278
|
+
"board.thread.post",
|
|
279
|
+
"board.standing.check",
|
|
280
|
+
"board.goal.create",
|
|
281
|
+
"board.goal.get",
|
|
282
|
+
"board.goal.list",
|
|
283
|
+
"board.goal.finish",
|
|
284
|
+
"board.room.read",
|
|
285
|
+
"board.room.post",
|
|
286
|
+
"board.room.search",
|
|
287
|
+
"board.children",
|
|
288
|
+
"board.agents",
|
|
289
|
+
"board.swarm.list",
|
|
290
|
+
"board.swarm.read",
|
|
291
|
+
"board.swarm.diff"
|
|
292
|
+
],
|
|
293
|
+
"queuedPhone": [
|
|
294
|
+
"board.post",
|
|
295
|
+
"board.run",
|
|
296
|
+
"board.release",
|
|
297
|
+
"board.answer",
|
|
298
|
+
"board.remove",
|
|
299
|
+
"board.thread.post",
|
|
300
|
+
"board.thread.send",
|
|
301
|
+
"board.thread.discard",
|
|
302
|
+
"board.thread.end",
|
|
303
|
+
"board.goal.stop",
|
|
304
|
+
"board.swarm.start",
|
|
305
|
+
"board.swarm.post",
|
|
306
|
+
"board.swarm.stop",
|
|
307
|
+
"board.swarm.stop_all",
|
|
308
|
+
"board.swarm.resume",
|
|
309
|
+
"board.swarm.start_run"
|
|
310
|
+
],
|
|
311
|
+
"browserLane": [
|
|
312
|
+
"harness.lane.share",
|
|
313
|
+
"harness.lane.forget",
|
|
314
|
+
"harness.lane.status"
|
|
315
|
+
],
|
|
316
|
+
"browserReads": [
|
|
317
|
+
"sessions.search",
|
|
318
|
+
"sessions.read",
|
|
319
|
+
"sessions.raw",
|
|
320
|
+
"tasks.status",
|
|
321
|
+
"relay.request",
|
|
322
|
+
"relay.open"
|
|
323
|
+
],
|
|
324
|
+
"harnessServer": [
|
|
325
|
+
"board.list",
|
|
326
|
+
"board.get",
|
|
327
|
+
"board.post",
|
|
328
|
+
"board.claim",
|
|
329
|
+
"board.report",
|
|
330
|
+
"board.answer",
|
|
331
|
+
"board.thread.read",
|
|
332
|
+
"board.thread.post",
|
|
333
|
+
"board.standing.check",
|
|
334
|
+
"board.file.add",
|
|
335
|
+
"board.goal.create",
|
|
336
|
+
"board.goal.get",
|
|
337
|
+
"board.goal.list",
|
|
338
|
+
"board.goal.finish",
|
|
339
|
+
"board.room.read",
|
|
340
|
+
"board.room.post",
|
|
341
|
+
"board.room.search"
|
|
342
|
+
],
|
|
343
|
+
"desktop": [
|
|
344
|
+
"board.list",
|
|
345
|
+
"board.get",
|
|
346
|
+
"board.children",
|
|
347
|
+
"board.agents",
|
|
348
|
+
"board.post",
|
|
349
|
+
"board.run",
|
|
350
|
+
"board.release",
|
|
351
|
+
"board.answer",
|
|
352
|
+
"board.remove",
|
|
353
|
+
"board.thread.read",
|
|
354
|
+
"board.thread.post",
|
|
355
|
+
"board.thread.send",
|
|
356
|
+
"board.thread.discard",
|
|
357
|
+
"board.thread.auto",
|
|
358
|
+
"board.thread.end",
|
|
359
|
+
"board.goal.list",
|
|
360
|
+
"board.goal.get",
|
|
361
|
+
"board.goal.stop",
|
|
362
|
+
"board.room.read",
|
|
363
|
+
"board.swarm.list",
|
|
364
|
+
"board.swarm.read",
|
|
365
|
+
"board.swarm.start",
|
|
366
|
+
"board.swarm.post",
|
|
367
|
+
"board.swarm.stop",
|
|
368
|
+
"board.swarm.stop_all",
|
|
369
|
+
"board.swarm.resume",
|
|
370
|
+
"board.swarm.folder",
|
|
371
|
+
"board.swarm.coordinator",
|
|
372
|
+
"board.swarm.diff",
|
|
373
|
+
"board.swarm.merge",
|
|
374
|
+
"board.swarm.discard",
|
|
375
|
+
"board.swarm.agents",
|
|
376
|
+
"board.swarm.note",
|
|
377
|
+
"board.swarm.lessons",
|
|
378
|
+
"board.swarm.lessons.edit",
|
|
379
|
+
"board.swarm.lessons.remove",
|
|
380
|
+
"board.swarm.lessons.undo",
|
|
381
|
+
"board.swarm.models",
|
|
382
|
+
"board.swarm.model",
|
|
383
|
+
"board.swarm.routing",
|
|
384
|
+
"board.swarm.places",
|
|
385
|
+
"board.swarm.browse",
|
|
386
|
+
"board.swarm.place",
|
|
387
|
+
"board.live",
|
|
388
|
+
"board.live.where",
|
|
389
|
+
"board.live.say",
|
|
390
|
+
"board.live.read",
|
|
391
|
+
"board.live.focus",
|
|
392
|
+
"t3.connect",
|
|
393
|
+
"voice.status",
|
|
394
|
+
"voice.transcribe",
|
|
395
|
+
"board.watch.list",
|
|
396
|
+
"board.watch.start",
|
|
397
|
+
"board.watch.remove",
|
|
398
|
+
"board.digest",
|
|
399
|
+
"board.local.events",
|
|
400
|
+
"board.snippet.list",
|
|
401
|
+
"board.snippet.decide",
|
|
402
|
+
"image.read",
|
|
403
|
+
"board.file.add",
|
|
404
|
+
"board.file.get",
|
|
405
|
+
"board.file.share",
|
|
406
|
+
"board.relay.list",
|
|
407
|
+
"board.relay.network",
|
|
408
|
+
"board.relay.decide",
|
|
409
|
+
"board.relay.request",
|
|
410
|
+
"board.relay.seen",
|
|
411
|
+
"board.relay.defaults",
|
|
412
|
+
"board.relay.peers"
|
|
413
|
+
],
|
|
414
|
+
"plainPerson": [
|
|
415
|
+
"board.standing.off"
|
|
416
|
+
],
|
|
417
|
+
"plainHarnessReads": [
|
|
418
|
+
"board.list",
|
|
419
|
+
"board.get",
|
|
420
|
+
"board.children",
|
|
421
|
+
"board.agents",
|
|
422
|
+
"board.goal.get",
|
|
423
|
+
"board.goal.list",
|
|
424
|
+
"board.room.read"
|
|
425
|
+
]
|
|
426
|
+
},
|
|
427
|
+
"metadata": {
|
|
428
|
+
"task": [
|
|
429
|
+
"id",
|
|
430
|
+
"parent_id",
|
|
431
|
+
"kind",
|
|
432
|
+
"origin_agent",
|
|
433
|
+
"target_agent",
|
|
434
|
+
"claimed_by",
|
|
435
|
+
"holder",
|
|
436
|
+
"status",
|
|
437
|
+
"version",
|
|
438
|
+
"trust",
|
|
439
|
+
"origin_chain",
|
|
440
|
+
"session_id",
|
|
441
|
+
"created_at",
|
|
442
|
+
"updated_at",
|
|
443
|
+
"claimed_at",
|
|
444
|
+
"reported_at",
|
|
445
|
+
"approved_at",
|
|
446
|
+
"run_authorized_at",
|
|
447
|
+
"run_authorized_by",
|
|
448
|
+
"lease_until",
|
|
449
|
+
"stale",
|
|
450
|
+
"needs_approval",
|
|
451
|
+
"thread_with",
|
|
452
|
+
"thread_closed_at",
|
|
453
|
+
"held_messages",
|
|
454
|
+
"child_count",
|
|
455
|
+
"child_done",
|
|
456
|
+
"child_agents",
|
|
457
|
+
"usage",
|
|
458
|
+
"home"
|
|
459
|
+
],
|
|
460
|
+
"goal": [
|
|
461
|
+
"team",
|
|
462
|
+
"facilitator",
|
|
463
|
+
"guests",
|
|
464
|
+
"posts",
|
|
465
|
+
"spend",
|
|
466
|
+
"max_posts",
|
|
467
|
+
"max_wakes"
|
|
468
|
+
]
|
|
469
|
+
}
|
|
470
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
const protocol = createRequire(import.meta.url)("./boardProtocol.json");
|
|
4
|
+
|
|
5
|
+
export const BOARD_PROTOCOL_VERSION = protocol.version;
|
|
6
|
+
export const HARNESS_INBOX_VERSION = protocol.inboxVersion;
|
|
7
|
+
export const boardMetadata = protocol.metadata;
|
|
8
|
+
|
|
9
|
+
// Surface policies are separate grants. Sharing their definition must never make
|
|
10
|
+
// a browser, hosted agent or phone inherit another surface's authority.
|
|
11
|
+
export const boardCommandsFor = (surface) => {
|
|
12
|
+
if (!Object.hasOwn(protocol.access, surface))
|
|
13
|
+
throw new Error(`unknown board surface ${surface}`);
|
|
14
|
+
return new Set(protocol.access[surface]);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function boardCommandOwner(command) {
|
|
18
|
+
if (Object.hasOwn(protocol.commands, command))
|
|
19
|
+
return protocol.commands[command];
|
|
20
|
+
// Unknown members of a command family still reach that feature's refusal, as
|
|
21
|
+
// they did before the catalog; this never grants a surface access to them.
|
|
22
|
+
return (
|
|
23
|
+
protocol.families.find((family) =>
|
|
24
|
+
family.prefixes.some((prefix) => command.startsWith(prefix))
|
|
25
|
+
)?.owner ?? "task"
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { notifyDesktop } from "./notify.mjs";
|
|
4
|
+
import { secretReason } from "./secrets.mjs";
|
|
5
|
+
|
|
6
|
+
export function createBoardThreads({
|
|
7
|
+
blobPath,
|
|
8
|
+
notifyBoard,
|
|
9
|
+
sendThreadEnd,
|
|
10
|
+
sendThreadMessage,
|
|
11
|
+
store,
|
|
12
|
+
textLike,
|
|
13
|
+
visibleFile,
|
|
14
|
+
}) {
|
|
15
|
+
return (request, { agent, id }) => {
|
|
16
|
+
let outcome;
|
|
17
|
+
if (request.command === "board.thread.read") {
|
|
18
|
+
const thread = store.getThread(id);
|
|
19
|
+
return thread
|
|
20
|
+
? {
|
|
21
|
+
ok: true,
|
|
22
|
+
thread,
|
|
23
|
+
task: store.getTask(id),
|
|
24
|
+
messages: store.threadMessages(id),
|
|
25
|
+
}
|
|
26
|
+
: { ok: false, error: "no thread on this task" };
|
|
27
|
+
} else if (request.command === "board.thread.post") {
|
|
28
|
+
const text = String(request.text || "").slice(0, 50_000);
|
|
29
|
+
if (!text.trim()) return { ok: false, error: "a message needs text" };
|
|
30
|
+
const named = (Array.isArray(request.refs) ? request.refs : [])
|
|
31
|
+
.filter(
|
|
32
|
+
(ref) =>
|
|
33
|
+
ref &&
|
|
34
|
+
["log", "repro", "link", "file"].includes(ref.kind) &&
|
|
35
|
+
typeof ref.ref === "string"
|
|
36
|
+
)
|
|
37
|
+
.slice(0, 20)
|
|
38
|
+
.map((ref) => ({
|
|
39
|
+
kind: ref.kind,
|
|
40
|
+
ref: ref.ref,
|
|
41
|
+
...(typeof ref.note === "string" ? { note: ref.note } : {}),
|
|
42
|
+
}));
|
|
43
|
+
// Files go only sealed to the other computer, and a reply carrying one always waits for the person to send it.
|
|
44
|
+
const files = (Array.isArray(request.files) ? request.files : [])
|
|
45
|
+
.slice(0, 10)
|
|
46
|
+
.map((fileId) => store.file(String(fileId)));
|
|
47
|
+
if (
|
|
48
|
+
files.some(
|
|
49
|
+
(file) =>
|
|
50
|
+
!file?.present ||
|
|
51
|
+
!visibleFile(file, agent, request.hostedCaller) ||
|
|
52
|
+
(request.hostedCaller && !file.cloud)
|
|
53
|
+
)
|
|
54
|
+
)
|
|
55
|
+
return {
|
|
56
|
+
ok: false,
|
|
57
|
+
error: "a file in files is not one you can send",
|
|
58
|
+
};
|
|
59
|
+
if (files.length && !store.getThread(id)?.peer_key)
|
|
60
|
+
return {
|
|
61
|
+
ok: false,
|
|
62
|
+
error:
|
|
63
|
+
"the other computer cannot take sealed files yet, and files never go unsealed; nothing was sent",
|
|
64
|
+
};
|
|
65
|
+
const refs = [
|
|
66
|
+
...named,
|
|
67
|
+
...files.map((file) => ({
|
|
68
|
+
kind: "file",
|
|
69
|
+
ref: file.name,
|
|
70
|
+
file: file.id,
|
|
71
|
+
mime: file.mime,
|
|
72
|
+
bytes: file.bytes,
|
|
73
|
+
sha256: file.sha256,
|
|
74
|
+
})),
|
|
75
|
+
];
|
|
76
|
+
const flagReason =
|
|
77
|
+
secretReason(text) ||
|
|
78
|
+
secretReason(JSON.stringify(named)) ||
|
|
79
|
+
files
|
|
80
|
+
.map(
|
|
81
|
+
(file) =>
|
|
82
|
+
textLike(file.mime) &&
|
|
83
|
+
secretReason(fs.readFileSync(blobPath(file.sha256), "utf8"))
|
|
84
|
+
)
|
|
85
|
+
.find(Boolean) ||
|
|
86
|
+
null;
|
|
87
|
+
outcome = store.postMessage({
|
|
88
|
+
id: randomUUID(),
|
|
89
|
+
taskId: id,
|
|
90
|
+
sender: agent,
|
|
91
|
+
text,
|
|
92
|
+
refs,
|
|
93
|
+
flagReason,
|
|
94
|
+
hold: files.length > 0,
|
|
95
|
+
});
|
|
96
|
+
if (outcome.ok && flagReason) store.revertAutoSend(id);
|
|
97
|
+
if (outcome.ok && outcome.message.state === "sent")
|
|
98
|
+
sendThreadMessage(outcome.message);
|
|
99
|
+
if (outcome.ok) {
|
|
100
|
+
outcome = { ...outcome, task: store.getTask(id) };
|
|
101
|
+
if (flagReason)
|
|
102
|
+
notifyDesktop(
|
|
103
|
+
`A reply to ${outcome.message.recipient} was held: it looks like ${flagReason}. Review it in Harness or tryharness board show ${id.slice(0, 8)}`
|
|
104
|
+
);
|
|
105
|
+
else if (outcome.message.state === "held")
|
|
106
|
+
notifyDesktop(
|
|
107
|
+
`${agent} drafted a reply to ${outcome.message.recipient}; send it from Harness or tryharness board send ${id.slice(0, 8)}`
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
} else if (
|
|
111
|
+
request.command === "board.thread.send" ||
|
|
112
|
+
request.command === "board.thread.discard"
|
|
113
|
+
) {
|
|
114
|
+
if (agent !== "user")
|
|
115
|
+
return {
|
|
116
|
+
ok: false,
|
|
117
|
+
error: "only the user sends or discards a held reply",
|
|
118
|
+
};
|
|
119
|
+
const messageId = String(request.messageId || "");
|
|
120
|
+
if (request.command === "board.thread.discard") {
|
|
121
|
+
outcome = store.discardMessage(messageId);
|
|
122
|
+
if (outcome.ok) outcome = { ...outcome, task: store.getTask(id) };
|
|
123
|
+
} else {
|
|
124
|
+
outcome = store.releaseMessage(messageId);
|
|
125
|
+
if (outcome.ok) {
|
|
126
|
+
sendThreadMessage(outcome.message);
|
|
127
|
+
outcome = { ...outcome, task: store.getTask(id) };
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
} else if (request.command === "board.thread.auto") {
|
|
131
|
+
if (agent !== "user")
|
|
132
|
+
return { ok: false, error: "only the user changes auto-send" };
|
|
133
|
+
outcome = store.setAutoSend(id, request.on === true);
|
|
134
|
+
if (outcome.ok) outcome = { ...outcome, task: store.getTask(id) };
|
|
135
|
+
} else if (request.command === "board.thread.end") {
|
|
136
|
+
const task = store.getTask(id);
|
|
137
|
+
if (!task) return { ok: false, error: "task not found" };
|
|
138
|
+
if (agent !== "user" && task.claimed_by !== agent)
|
|
139
|
+
return {
|
|
140
|
+
ok: false,
|
|
141
|
+
error: "only the user or the agent holding the task ends its thread",
|
|
142
|
+
};
|
|
143
|
+
outcome = store.closeThread(
|
|
144
|
+
id,
|
|
145
|
+
String(request.outcome || "").slice(0, 20_000) || null
|
|
146
|
+
);
|
|
147
|
+
if (outcome.ok && !outcome.already)
|
|
148
|
+
sendThreadEnd(id, agent, outcome.thread.outcome);
|
|
149
|
+
} else return { ok: false, error: "unknown command" };
|
|
150
|
+
if (outcome.ok) notifyBoard(outcome.task);
|
|
151
|
+
return outcome;
|
|
152
|
+
};
|
|
153
|
+
}
|