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.
- package/README.md +21 -19
- package/assets/dsh-plugin.mjs +75 -4
- package/assets/herdr-mod/harness/main.js +367 -0
- package/assets/herdr-mod/harness/mod.json +6 -0
- package/assets/opencode-plugin.js +87 -22
- package/assets/pi-extension.ts +81 -2
- package/cli.mjs +544 -208
- package/lib/adapters.mjs +62 -27
- package/lib/agentBinaries.mjs +6 -8
- package/lib/agentClaims.mjs +168 -0
- package/lib/agentReadTools.json +415 -0
- package/lib/agentSignIn.mjs +17 -18
- package/lib/agentWiring.mjs +114 -0
- package/lib/archetypes.js +10 -11
- package/lib/attention.mjs +100 -0
- package/lib/audit.mjs +1 -1
- package/lib/backupSetup.mjs +6 -28
- package/lib/bankrApprovals.mjs +86 -0
- package/lib/boardAccess.mjs +40 -66
- package/lib/boardBackup.mjs +86 -85
- package/lib/boardCommands.mjs +28 -0
- package/lib/boardFileCommands.mjs +29 -36
- package/lib/boardFiles.mjs +83 -15
- package/lib/boardMirror.mjs +78 -11
- package/lib/boardProtocol.json +193 -123
- package/lib/boardThreads.mjs +19 -37
- package/lib/boardTools.mjs +22 -15
- package/lib/boardWatches.mjs +43 -15
- package/lib/bridge.mjs +7 -3
- package/lib/browserAgentTools.mjs +59 -0
- package/lib/browserWake.mjs +0 -6
- package/lib/cards.mjs +57 -2
- package/lib/circling.mjs +189 -0
- package/lib/cleanup.mjs +234 -0
- package/lib/cloudBoot.mjs +21 -4
- package/lib/cloudSave.mjs +46 -5
- package/lib/compaction.mjs +8 -1
- package/lib/completion.mjs +358 -0
- package/lib/computerDevices.mjs +853 -0
- package/lib/connectionStatus.mjs +34 -0
- package/lib/connectors.mjs +139 -1
- package/lib/coordinator.mjs +108 -14
- package/lib/coreModels.mjs +36 -12
- package/lib/daemon.mjs +2435 -333
- package/lib/daemonLock.mjs +103 -0
- package/lib/deviceDoor.mjs +308 -0
- package/lib/deviceIdentity.mjs +114 -0
- package/lib/deviceList.mjs +172 -0
- package/lib/deviceSeal.mjs +74 -0
- package/lib/dispatcher.mjs +497 -26
- package/lib/dispatches.mjs +3 -3
- package/lib/environment.mjs +2 -1
- package/lib/environments.mjs +67 -41
- package/lib/events.mjs +318 -0
- package/lib/facts.mjs +170 -0
- package/lib/fileSource.mjs +540 -0
- package/lib/files.mjs +47 -2
- package/lib/gitHost.mjs +39 -1
- package/lib/goalCommands.mjs +12 -80
- package/lib/handover.mjs +21 -16
- package/lib/harnessOffers.mjs +140 -15
- package/lib/herdr.mjs +100 -15
- package/lib/herdrAppCall.mjs +19 -0
- package/lib/herdrCore.mjs +59 -0
- package/lib/herdrRuns.mjs +1126 -0
- package/lib/hookDialects.mjs +235 -50
- package/lib/identityLink.mjs +81 -0
- package/lib/inference.mjs +31 -2
- package/lib/jamAccess.mjs +82 -0
- package/lib/{projectBoard.mjs → jamBoard.mjs} +5 -4
- package/lib/{projectGit.mjs → jamGit.mjs} +53 -15
- package/lib/jamKey.mjs +274 -0
- package/lib/{projectPieces.mjs → jamPieces.mjs} +35 -29
- package/lib/{projectSettings.mjs → jamSettings.mjs} +12 -22
- package/lib/jamStore.mjs +973 -0
- package/lib/jamUpgrade.mjs +112 -0
- package/lib/jams.mjs +3079 -0
- package/lib/kanban.mjs +13 -7
- package/lib/landed.mjs +5 -1
- package/lib/library.mjs +41 -22
- package/lib/limits.mjs +91 -0
- package/lib/lineDiff.mjs +97 -0
- package/lib/lineup.mjs +18 -13
- package/lib/link.mjs +584 -0
- package/lib/localStack.mjs +75 -16
- package/lib/localmodels.mjs +58 -78
- package/lib/loopBackstop.mjs +2 -1
- package/lib/machine.mjs +544 -0
- package/lib/machineLink.mjs +446 -0
- package/lib/machineRoutes.mjs +68 -19
- package/lib/machineRuns.mjs +85 -4
- package/lib/machineSeal.mjs +6 -31
- package/lib/manager.mjs +134 -12
- package/lib/mcp-stdio.mjs +492 -215
- package/lib/mcpRelay.mjs +34 -35
- package/lib/members.json +2 -2
- package/lib/modelRoute.mjs +162 -0
- package/lib/nativeHost.mjs +81 -90
- package/lib/nativeSenses.mjs +258 -0
- package/lib/nerves.mjs +523 -0
- package/lib/network.mjs +117 -278
- package/lib/networkPlaces.mjs +578 -0
- package/lib/nextStep.mjs +95 -0
- package/lib/notify.mjs +2 -2
- package/lib/nudge.mjs +116 -10
- package/lib/onboard.mjs +6 -6
- package/lib/originals.mjs +216 -0
- package/lib/outsideEvents.mjs +383 -0
- package/lib/outsideRuns.mjs +230 -0
- package/lib/ownMachines.mjs +674 -256
- package/lib/pain.mjs +215 -0
- package/lib/pairing.mjs +91 -11
- package/lib/paths.mjs +42 -3
- package/lib/peerProcess.mjs +21 -7
- package/lib/peopleLink.mjs +268 -0
- package/lib/personNotices.mjs +3 -2
- package/lib/phones.mjs +252 -542
- package/lib/placeCards.mjs +282 -0
- package/lib/placeChecks.mjs +95 -0
- package/lib/placeCommands.mjs +8 -17
- package/lib/placeRequests.mjs +152 -0
- package/lib/placeStore.mjs +295 -0
- package/lib/placeTool.d.ts +12 -0
- package/lib/placeTool.js +40 -0
- package/lib/places.mjs +63 -14
- package/lib/plans.mjs +53 -8
- package/lib/presence.mjs +270 -0
- package/lib/privateNetwork.d.ts +2 -0
- package/lib/privateNetwork.js +93 -0
- package/lib/proposals.mjs +300 -0
- package/lib/publicFetch.d.ts +32 -0
- package/lib/publicFetch.js +248 -0
- package/lib/reach.mjs +128 -0
- package/lib/rebuildable.mjs +72 -0
- package/lib/recall.mjs +216 -0
- package/lib/record.mjs +13 -0
- package/lib/reflexes.mjs +392 -0
- package/lib/relayLimits.mjs +31 -2
- package/lib/releaseNotice.mjs +198 -0
- package/lib/removeHarness.mjs +15 -4
- package/lib/repoLinks.mjs +204 -35
- package/lib/runAuthority.mjs +102 -39
- package/lib/runBrief.mjs +93 -40
- package/lib/runRequests.mjs +52 -14
- package/lib/runUsage.mjs +31 -0
- package/lib/runWorker.mjs +74 -25
- package/lib/runner.mjs +289 -45
- package/lib/runtime-install.mjs +37 -8
- package/lib/schedules.mjs +171 -47
- package/lib/screenWatches.mjs +221 -0
- package/lib/sealed.mjs +12 -30
- package/lib/sealedThreads.mjs +198 -392
- package/lib/secretStore.mjs +178 -0
- package/lib/secrets.mjs +11 -0
- package/lib/seen.mjs +3 -9
- package/lib/selfUpdate.mjs +51 -15
- package/lib/senseCall.mjs +1514 -0
- package/lib/senseHook.mjs +114 -0
- package/lib/senseTools.mjs +1298 -0
- package/lib/sessionBriefs.mjs +87 -0
- package/lib/sessionControl.mjs +63 -13
- package/lib/sessionFiles.mjs +85 -0
- package/lib/setupChoices.mjs +12 -3
- package/lib/setupMode.mjs +70 -25
- package/lib/sharedKeys.mjs +166 -0
- package/lib/sleep.mjs +396 -0
- package/lib/sources.mjs +306 -0
- package/lib/speech.mjs +166 -411
- package/lib/spoken.mjs +210 -0
- package/lib/steerHook.mjs +3 -1
- package/lib/steerQueue.mjs +40 -11
- package/lib/store.mjs +323 -130
- package/lib/stuck.mjs +85 -7
- package/lib/swarm.mjs +157 -49
- package/lib/swarmDevices.mjs +25 -85
- package/lib/swarmMemory.mjs +93 -9
- package/lib/t3.mjs +73 -3
- package/lib/taskCommands.mjs +51 -60
- package/lib/taskRooms.mjs +30 -4
- package/lib/taskRules.json +29 -0
- package/lib/taskRules.mjs +21 -0
- package/lib/taskRuns.mjs +74 -11
- package/lib/team.mjs +2 -1
- package/lib/threadActions.mjs +37 -9
- package/lib/threadAuthority.mjs +4 -4
- package/lib/threadBriefs.mjs +173 -43
- package/lib/threadNotes.mjs +320 -0
- package/lib/threadRecord.mjs +491 -0
- package/lib/threadRuns.mjs +216 -108
- package/lib/threadView.mjs +27 -30
- package/lib/threadWatches.mjs +1962 -0
- package/lib/timeSense.mjs +839 -0
- package/lib/tripwires.mjs +454 -0
- package/lib/ui.mjs +1 -1
- package/lib/vault.mjs +560 -45
- package/lib/vaultCommands.mjs +5 -3
- package/lib/vaultPeers.mjs +165 -0
- package/lib/vaultTools.d.ts +4 -1
- package/lib/vaultTools.js +22 -1
- package/lib/verdicts.mjs +12 -26
- package/lib/versions.mjs +117 -0
- package/lib/waitTool.mjs +278 -0
- package/lib/wakePicture.mjs +268 -0
- package/lib/wakeQueue.mjs +108 -0
- package/lib/watchResponses.mjs +533 -0
- package/lib/watches.mjs +290 -145
- package/lib/windowAsks.mjs +80 -17
- package/lib/worktrees.mjs +159 -9
- package/npm-shrinkwrap.json +138 -631
- package/package.json +7 -6
- package/release.json +212 -130
- package/lib/callSessions.mjs +0 -51
- package/lib/directLink.mjs +0 -349
- package/lib/peopleBoard.mjs +0 -131
- package/lib/projects.mjs +0 -2917
- package/lib/roomChannels.mjs +0 -667
package/lib/network.mjs
CHANGED
|
@@ -1,31 +1,24 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
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
|
-
|
|
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
|
|
26
|
-
|
|
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
|
-
//
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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 =
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
101
|
-
|
|
75
|
+
if (thread.status === "requested" && thread.role === "target")
|
|
76
|
+
incoming.push({
|
|
102
77
|
id: thread.id,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
|
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
|
|
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(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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
|
-
|
|
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
|
-
...
|
|
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
|
|
262
|
-
//
|
|
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 (
|
|
171
|
+
if (!CARD_OPS.has(String(input.op)))
|
|
273
172
|
return {
|
|
274
173
|
ok: false,
|
|
275
|
-
error:
|
|
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
|
|
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
|
}
|