tryharness 0.7.45 → 0.7.54
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 +239 -14
- package/assets/dsh-plugin.mjs +72 -0
- package/assets/opencode-plugin.js +4 -3
- package/cli.mjs +497 -196
- package/lib/actorRoster.mjs +28 -5
- package/lib/adapters.mjs +165 -222
- package/lib/agentRuntimeConfig.mjs +36 -0
- package/lib/agentRuntimes.mjs +570 -0
- package/lib/agentSignIn.mjs +226 -0
- package/lib/atlas.mjs +7 -2
- package/lib/audit.mjs +643 -0
- package/lib/backupSetup.mjs +141 -0
- package/lib/boardAccess.mjs +8 -1
- package/lib/boardBackup.mjs +283 -0
- package/lib/boardCommands.mjs +5 -10
- package/lib/boardFileCommands.mjs +2 -1
- package/lib/boardMirror.mjs +523 -0
- package/lib/boardProtocol.json +263 -6
- package/lib/boardTools.mjs +2 -6
- package/lib/boardWaits.mjs +102 -0
- package/lib/book.mjs +659 -0
- package/lib/bridge.mjs +26 -4
- package/lib/browserWake.mjs +60 -0
- package/lib/cards.mjs +159 -16
- package/lib/cloudBoot.mjs +124 -0
- package/lib/commands.mjs +25 -5
- package/lib/connectionTools.d.ts +13 -0
- package/lib/connectionTools.js +45 -0
- package/lib/connectorAuth.mjs +309 -0
- package/lib/connectorCatalog.json +41 -0
- package/lib/connectorCommands.mjs +121 -0
- package/lib/connectorGoogle.mjs +513 -0
- package/lib/connectors.mjs +805 -0
- package/lib/context.mjs +18 -4
- package/lib/contractGate.mjs +377 -0
- package/lib/coordinator.mjs +152 -39
- package/lib/coreModels.mjs +78 -0
- package/lib/daemon.mjs +973 -54
- package/lib/desk.mjs +239 -0
- package/lib/desktop.mjs +113 -8
- package/lib/digest.mjs +32 -0
- package/lib/directLink.mjs +283 -0
- package/lib/environments.mjs +825 -0
- package/lib/folders.mjs +4 -4
- package/lib/gitHost.mjs +174 -0
- package/lib/goalCommands.mjs +58 -14
- package/lib/hookDialects.mjs +298 -0
- package/lib/inference.mjs +263 -152
- package/lib/landed.mjs +887 -0
- package/lib/lessons.mjs +6 -0
- package/lib/lineup.mjs +324 -0
- package/lib/live.mjs +284 -13
- package/lib/localmodels.mjs +10 -0
- package/lib/machineIdentity.mjs +3 -0
- package/lib/machineRoutes.mjs +40 -2
- package/lib/machineRuns.mjs +30 -3
- package/lib/machineSeal.mjs +69 -10
- package/lib/mcp-stdio.mjs +189 -120
- package/lib/mcpRelay.mjs +119 -0
- package/lib/members.json +26 -0
- package/lib/members.mjs +33 -0
- package/lib/modelMemory.mjs +100 -0
- package/lib/models.mjs +48 -15
- package/lib/museSession.mjs +122 -0
- package/lib/nativeHost.mjs +203 -0
- package/lib/neovim.mjs +126 -0
- package/lib/network.mjs +7 -2
- package/lib/nudge.mjs +57 -18
- package/lib/onboard.mjs +430 -1
- package/lib/oneclawLocal.mjs +150 -0
- package/lib/ownMachines.mjs +828 -39
- package/lib/pairing.mjs +182 -0
- package/lib/paths.mjs +8 -0
- package/lib/personModel.mjs +89 -0
- package/lib/phones.mjs +119 -3
- package/lib/placeCommands.mjs +27 -0
- package/lib/places.mjs +337 -9
- package/lib/plans.mjs +151 -27
- package/lib/profile.mjs +152 -0
- package/lib/projects.mjs +624 -137
- package/lib/readiness.mjs +400 -0
- package/lib/record.mjs +115 -0
- package/lib/repoLinks.mjs +354 -0
- package/lib/roomChannels.mjs +641 -0
- package/lib/runBrief.mjs +32 -2
- package/lib/runRequests.mjs +157 -0
- package/lib/runWorker.mjs +37 -9
- package/lib/runner.mjs +74 -11
- package/lib/secretPatterns.json +55 -0
- package/lib/secrets.mjs +10 -27
- package/lib/seen.mjs +102 -0
- package/lib/service.mjs +11 -6
- package/lib/sessionControl.mjs +386 -96
- package/lib/sessionIndex.mjs +5 -3
- package/lib/specialties.json +74 -0
- package/lib/specialties.mjs +477 -0
- package/lib/specialtyKeys.d.ts +3 -0
- package/lib/specialtyKeys.js +58 -0
- package/lib/specialtyNotice.mjs +147 -0
- package/lib/specialtySnapshot.mjs +138 -0
- package/lib/store.mjs +829 -29
- package/lib/subagents.mjs +8 -4
- package/lib/swarm.mjs +483 -37
- package/lib/swarmMemory.mjs +947 -0
- package/lib/t3.mjs +56 -17
- package/lib/taskCommands.mjs +91 -13
- package/lib/taskRuns.mjs +68 -11
- package/lib/team.json +253 -144
- package/lib/team.mjs +538 -147
- package/lib/threadLine.mjs +116 -0
- package/lib/threadRuns.mjs +78 -12
- package/lib/threadView.mjs +66 -16
- package/lib/tokenizer.mjs +405 -0
- package/lib/ui.mjs +16 -2
- package/lib/usageTotals.mjs +148 -0
- package/lib/vault.mjs +1144 -0
- package/lib/vaultCloud.mjs +117 -0
- package/lib/vaultCommands.mjs +201 -0
- package/lib/vaultTools.d.ts +12 -0
- package/lib/vaultTools.js +42 -0
- package/lib/windowAsks.mjs +42 -0
- package/lib/workFocus.mjs +59 -0
- package/lib/workLinks.mjs +90 -0
- package/lib/worktrees.mjs +51 -13
- package/package.json +10 -5
package/lib/localmodels.mjs
CHANGED
|
@@ -73,12 +73,17 @@ export const LLAMA = {
|
|
|
73
73
|
},
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
+
// memoryMb: the model's peak added memory (phys_footprint, MallocLargeCache=0) alone through the relay's host at a
|
|
77
|
+
// representative job, measured on an M5 Pro on October 22 (.harness-runs/relay-memory-20261022/cost-probe.mjs): what the
|
|
78
|
+
// memory ceiling (modelMemory.mjs) charges while it is loaded. The llama models include the llama-server router, the
|
|
79
|
+
// guards their shared tokenizer.
|
|
76
80
|
export const MODELS = [
|
|
77
81
|
{
|
|
78
82
|
id: "search",
|
|
79
83
|
name: "EmbeddingGemma 2 (text)",
|
|
80
84
|
purpose: "One search space over code, agent sessions and board posts",
|
|
81
85
|
tier: "core",
|
|
86
|
+
memoryMb: 280,
|
|
82
87
|
runtime: "llama",
|
|
83
88
|
licence: "apache-2.0",
|
|
84
89
|
repo: "ggml-org/embeddinggemma-2-GGUF",
|
|
@@ -98,6 +103,7 @@ export const MODELS = [
|
|
|
98
103
|
name: "Wolf Defender small",
|
|
99
104
|
purpose: "Spots instructions hidden in what one agent hands another",
|
|
100
105
|
tier: "core",
|
|
106
|
+
memoryMb: 144,
|
|
101
107
|
runtime: "onnx",
|
|
102
108
|
licence: "apache-2.0",
|
|
103
109
|
repo: "patronus-studio/wolf-defender-prompt-injection-small",
|
|
@@ -137,6 +143,7 @@ export const MODELS = [
|
|
|
137
143
|
name: "Horizon PI guard small",
|
|
138
144
|
purpose: "Finds one planted instruction in a long page or post",
|
|
139
145
|
tier: "core",
|
|
146
|
+
memoryMb: 226,
|
|
140
147
|
runtime: "onnx",
|
|
141
148
|
licence: "apache-2.0",
|
|
142
149
|
repo: "Horizon-Labs/prompt-injection-guard-small",
|
|
@@ -162,6 +169,7 @@ export const MODELS = [
|
|
|
162
169
|
name: "credential-line 32M",
|
|
163
170
|
purpose: "Spots keys and passwords before a brief leaves the computer",
|
|
164
171
|
tier: "core",
|
|
172
|
+
memoryMb: 128,
|
|
165
173
|
runtime: "onnx",
|
|
166
174
|
licence: "mit",
|
|
167
175
|
repo: "zaindanaharper/credential-line-32m",
|
|
@@ -207,6 +215,7 @@ export const MODELS = [
|
|
|
207
215
|
purpose:
|
|
208
216
|
"Finds the minute of a recording or the screenshot a request is about, in folders the person adds",
|
|
209
217
|
tier: "extended",
|
|
218
|
+
memoryMb: 857,
|
|
210
219
|
runtime: "llama",
|
|
211
220
|
licence: "apache-2.0",
|
|
212
221
|
repo: "ggml-org/embeddinggemma-2-GGUF",
|
|
@@ -229,6 +238,7 @@ export const MODELS = [
|
|
|
229
238
|
purpose:
|
|
230
239
|
"Reads screenshots so keys and personal details are hidden before an image leaves the computer",
|
|
231
240
|
tier: "core",
|
|
241
|
+
memoryMb: 307,
|
|
232
242
|
runtime: "onnx",
|
|
233
243
|
licence: "apache-2.0",
|
|
234
244
|
repo: "PaddlePaddle/en_PP-OCRv5_mobile_rec_onnx",
|
package/lib/machineIdentity.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { readJson, writeJsonAtomic } from "./files.mjs";
|
|
|
5
5
|
// Which of the person's computers this is (machine.json, beside its key in ~/.harness): a fixed id made once, the name
|
|
6
6
|
// the person reads it by (the hostname until they rename it: npx tryharness machines name <name>), and the role
|
|
7
7
|
// Harness last gave it, home or worker (src/server/bridge/machines.ts decides; this is its memory between starts).
|
|
8
|
+
// Setup leaves the code it showed here (joinCode) for the daemon, which takes it as this computer's join code.
|
|
8
9
|
|
|
9
10
|
const ID = /^[A-Za-z0-9_-]{8,64}$/;
|
|
10
11
|
const ROLES = new Set(["home", "worker"]);
|
|
@@ -28,6 +29,7 @@ export function loadMachine(file) {
|
|
|
28
29
|
? saved.label.trim().slice(0, 64)
|
|
29
30
|
: hostname(),
|
|
30
31
|
role: ROLES.has(saved.role) ? saved.role : null,
|
|
32
|
+
joinCode: typeof saved.joinCode === "string" ? saved.joinCode : null,
|
|
31
33
|
};
|
|
32
34
|
if (saved.id !== machine.id || saved.label !== machine.label)
|
|
33
35
|
saveMachine(file, machine);
|
|
@@ -39,5 +41,6 @@ export function saveMachine(file, machine) {
|
|
|
39
41
|
id: machine.id,
|
|
40
42
|
label: machine.label,
|
|
41
43
|
...(machine.role ? { role: machine.role } : {}),
|
|
44
|
+
...(machine.joinCode ? { joinCode: machine.joinCode } : {}),
|
|
42
45
|
});
|
|
43
46
|
}
|
package/lib/machineRoutes.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { boardCommandOwner } from "./boardProtocol.mjs";
|
|
2
|
+
import { member } from "./members.mjs";
|
|
2
3
|
|
|
3
4
|
// Where board work goes when the person's agents live on several computers. The board is home's; an agent keeps its
|
|
4
5
|
// id and a task names the computer it is for (target_machine) and the one that took it (claimed_machine). People and
|
|
@@ -6,16 +7,29 @@ import { boardCommandOwner } from "./boardProtocol.mjs";
|
|
|
6
7
|
|
|
7
8
|
// What an agent does on its own computer: its tools on local files, its live session, the watches set there, its
|
|
8
9
|
// prompts. Everything else on the board is home's.
|
|
9
|
-
|
|
10
|
+
// `repos`: a repository link is found on, and cloned onto, the computer the person is at, never home's disk.
|
|
11
|
+
// `nativeRequests`: an agent's permission request lives in the memory of the computer whose run asked (runRequests.mjs).
|
|
12
|
+
const LOCAL_OWNERS = new Set([
|
|
13
|
+
"tools",
|
|
14
|
+
"live",
|
|
15
|
+
"watch",
|
|
16
|
+
"prompt",
|
|
17
|
+
"repos",
|
|
18
|
+
"nativeRequests",
|
|
19
|
+
]);
|
|
10
20
|
|
|
11
21
|
/** Whether a worker sends this board command to home. */
|
|
12
22
|
export const goesHome = (command) =>
|
|
13
23
|
String(command).startsWith("board.") &&
|
|
24
|
+
// The board copy's own calls go between computers only, never on an agent's behalf (boardMirror.mjs).
|
|
25
|
+
!String(command).startsWith("board.mirror.") &&
|
|
14
26
|
!LOCAL_OWNERS.has(boardCommandOwner(String(command)));
|
|
15
27
|
|
|
16
28
|
// Writes an agent need not wait on: while home is out of reach the worker keeps them, sealed, and sends them when it is
|
|
17
|
-
// back. A
|
|
29
|
+
// back. A post is one: any computer can start a task (owner, October 21), with its id chosen there. A claim waits for
|
|
30
|
+
// its answer instead, since two computers could take the same task.
|
|
18
31
|
const QUEUEABLE = new Set([
|
|
32
|
+
"board.post",
|
|
19
33
|
"board.report",
|
|
20
34
|
"board.answer",
|
|
21
35
|
"board.release",
|
|
@@ -26,6 +40,19 @@ const QUEUEABLE = new Set([
|
|
|
26
40
|
]);
|
|
27
41
|
export const queueable = (command) => QUEUEABLE.has(String(command));
|
|
28
42
|
|
|
43
|
+
// Reads a worker answers from its copy of the board (boardMirror.mjs) while home is out of reach, saying how old it is.
|
|
44
|
+
// What is not copied (agents' last reads, the coordinator's rounds, search vectors) is never answered from it.
|
|
45
|
+
const FROM_COPY = new Set([
|
|
46
|
+
"board.list",
|
|
47
|
+
"board.get",
|
|
48
|
+
"board.children",
|
|
49
|
+
"board.thread.read",
|
|
50
|
+
"board.room.read",
|
|
51
|
+
"board.goal.get",
|
|
52
|
+
"board.goal.list",
|
|
53
|
+
]);
|
|
54
|
+
export const readsFromCopy = (command) => FROM_COPY.has(String(command));
|
|
55
|
+
|
|
29
56
|
/** Whether a caller on `machine` may take this task: work meant for one computer is taken only there. */
|
|
30
57
|
export const mayClaim = (task, machine) =>
|
|
31
58
|
!task?.target_machine || task.target_machine === machine;
|
|
@@ -95,3 +122,14 @@ export function placeTask({
|
|
|
95
122
|
|
|
96
123
|
/** How people and agents read an agent on a computer: "Codex (linux)". */
|
|
97
124
|
export const onMachine = (name, label) => (label ? `${name} (${label})` : name);
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* A post as readers get it: words from an agent that runs on the person's computers say which one wrote them
|
|
128
|
+
* (`computer`, read "Codex (linux)"), once the person has more than one. `computerOf` gives that name for a computer's
|
|
129
|
+
* id, or null while there is only one.
|
|
130
|
+
*/
|
|
131
|
+
export function withComputer(post, computerOf) {
|
|
132
|
+
if (!post?.machine || member(post.author)?.home !== "machine") return post;
|
|
133
|
+
const computer = computerOf(post.machine);
|
|
134
|
+
return computer ? { ...post, computer } : post;
|
|
135
|
+
}
|
package/lib/machineRuns.mjs
CHANGED
|
@@ -51,9 +51,32 @@ export function createMachineRuns({ callHome, taskRuns, agents, log }) {
|
|
|
51
51
|
.join("\n\n");
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
// The person's environment grants for this run, from home's vault (vault.mjs), sealed to this computer like every
|
|
55
|
+
// answer from home. Without home there are none: the run starts without them.
|
|
56
|
+
const secretsFor = async (task, agent) => {
|
|
57
|
+
const answer = await callHome({
|
|
58
|
+
command: "board.vault.env",
|
|
59
|
+
agent,
|
|
60
|
+
runAgent: agent,
|
|
61
|
+
task: task.id,
|
|
62
|
+
}).catch(() => null);
|
|
63
|
+
if (answer?.ok !== true || !Object.keys(answer.env ?? {}).length) return {};
|
|
64
|
+
const scrub = new Map(
|
|
65
|
+
Object.entries(answer.names ?? {}).map(([variable, secret]) => [
|
|
66
|
+
secret,
|
|
67
|
+
answer.env[variable],
|
|
68
|
+
])
|
|
69
|
+
);
|
|
70
|
+
return { env: answer.env, scrub };
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const start = async (task, slot) => {
|
|
55
74
|
const agent = task.target_agent;
|
|
56
75
|
log(`running ${agent}'s task ${task.id} from your home computer`);
|
|
76
|
+
const secrets = await secretsFor(task, agent);
|
|
77
|
+
// Sent again with the finish: the two calls go to home at once, and a finish that arrives first closes the run to
|
|
78
|
+
// the session call (two-machines: home kept no session, one run in four).
|
|
79
|
+
let session = null;
|
|
57
80
|
taskRuns.startTask(
|
|
58
81
|
{
|
|
59
82
|
runId: task.id,
|
|
@@ -61,15 +84,18 @@ export function createMachineRuns({ callHome, taskRuns, agents, log }) {
|
|
|
61
84
|
title: String(task.objective || "").slice(0, 120),
|
|
62
85
|
brief: briefOf(task),
|
|
63
86
|
cwd: task.run_workspace,
|
|
87
|
+
...secrets,
|
|
64
88
|
},
|
|
65
89
|
(kind, text, extra) => {
|
|
66
|
-
if (kind === "session" && text)
|
|
90
|
+
if (kind === "session" && text) {
|
|
91
|
+
session = text;
|
|
67
92
|
void callHome({
|
|
68
93
|
command: "board.machine.session",
|
|
69
94
|
agent,
|
|
70
95
|
id: task.id,
|
|
71
96
|
session: text,
|
|
72
97
|
});
|
|
98
|
+
}
|
|
73
99
|
if (kind === "progress") tellStep(task.id, agent);
|
|
74
100
|
if (kind !== "done" && kind !== "failed") return;
|
|
75
101
|
stopSteps(task.id);
|
|
@@ -82,6 +108,7 @@ export function createMachineRuns({ callHome, taskRuns, agents, log }) {
|
|
|
82
108
|
result: text || "",
|
|
83
109
|
failure: extra?.failure ?? "exit",
|
|
84
110
|
...(extra?.usage ? { usage: extra.usage } : {}),
|
|
111
|
+
...(session ? { session } : {}),
|
|
85
112
|
}).then((answer) => {
|
|
86
113
|
if (answer?.ok === false)
|
|
87
114
|
log(
|
|
@@ -118,7 +145,7 @@ export function createMachineRuns({ callHome, taskRuns, agents, log }) {
|
|
|
118
145
|
});
|
|
119
146
|
if (!taken?.ok) continue;
|
|
120
147
|
active.set(slot, task.id);
|
|
121
|
-
start(taken.task, slot);
|
|
148
|
+
void start(taken.task, slot);
|
|
122
149
|
}
|
|
123
150
|
} finally {
|
|
124
151
|
asking = false;
|
package/lib/machineSeal.mjs
CHANGED
|
@@ -7,38 +7,64 @@ import {
|
|
|
7
7
|
seal,
|
|
8
8
|
} from "./sealed.mjs";
|
|
9
9
|
|
|
10
|
-
// Calls between the person's own computers (HSC1, cli/lib/sealed.mjs): a worker's board calls to home
|
|
11
|
-
//
|
|
10
|
+
// Calls between the person's own computers (HSC1, cli/lib/sealed.mjs): a worker's board calls to home, home's notices to
|
|
11
|
+
// a worker, and home's questions for the windows linked to a worker go through Harness, which carries them and cannot
|
|
12
|
+
// read or forge them.
|
|
12
13
|
//
|
|
13
14
|
// - Each computer has its static ECDH identity (phone-identity.json). The two keys of a home and a worker give one
|
|
14
15
|
// AES-256-GCM key for the pair; every message binds its direction, the worker's id and its request id.
|
|
15
|
-
// - Keys are pinned once (own_machines) by the join handshake: the worker shows a
|
|
16
|
-
//
|
|
17
|
-
//
|
|
16
|
+
// - Keys are pinned once (own_machines) by the join handshake: the worker shows a join code, the person types it on
|
|
17
|
+
// home, and each side proves it holds the code by an HMAC over both computers' ids and keys. Harness never sees the
|
|
18
|
+
// code, so it cannot stand in for either computer with a key of its own.
|
|
19
|
+
// - Setup shows one 16-character code that is both the pairing code and the join code. Harness hears only its first 4
|
|
20
|
+
// characters, to find the waiting computer, and a verifier only the whole code makes, so approving it needs the
|
|
21
|
+
// code the person read; the 12 characters it never hears keep the join's 60 secret bits.
|
|
18
22
|
// - A call is refused when it is stale (five minutes either way, seven days for a write queued while the worker was
|
|
19
23
|
// offline), replayed, or sealed for another worker or direction.
|
|
20
24
|
|
|
21
25
|
export const QUEUED_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000;
|
|
22
26
|
const CODE_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
23
|
-
const
|
|
27
|
+
const JOIN_LENGTH = 12;
|
|
28
|
+
const PAIR_LENGTH = 16;
|
|
29
|
+
const LOOKUP_LENGTH = 4;
|
|
24
30
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const bytes = randomBytes(CODE_LENGTH);
|
|
31
|
+
function randomCode(length) {
|
|
32
|
+
const bytes = randomBytes(length);
|
|
28
33
|
const letters = [...bytes].map((byte) => CODE_ALPHABET[byte & 31]).join("");
|
|
29
34
|
return letters.match(/.{4}/g).join("-");
|
|
30
35
|
}
|
|
31
36
|
|
|
37
|
+
/** A new join code: 60 random bits, shown as XXXX-XXXX-XXXX. */
|
|
38
|
+
export const newJoinCode = () => randomCode(JOIN_LENGTH);
|
|
39
|
+
|
|
40
|
+
/** Setup's one code, for pairing and joining: 80 random bits, shown as XXXX-XXXX-XXXX-XXXX. */
|
|
41
|
+
export const newPairCode = () => randomCode(PAIR_LENGTH);
|
|
42
|
+
|
|
32
43
|
/** The code as typed (any case, with or without dashes), or null when it is not one. */
|
|
33
44
|
export function normalizeJoinCode(text) {
|
|
34
45
|
const letters = String(text ?? "")
|
|
35
46
|
.toUpperCase()
|
|
36
47
|
.replace(/[^A-Z2-7]/g, "");
|
|
37
|
-
return letters.length
|
|
48
|
+
return [JOIN_LENGTH, PAIR_LENGTH].includes(letters.length)
|
|
38
49
|
? letters.match(/.{4}/g).join("-")
|
|
39
50
|
: null;
|
|
40
51
|
}
|
|
41
52
|
|
|
53
|
+
/** Whether a normalized code is setup's pairing code, which Harness can look up. */
|
|
54
|
+
export const isPairCode = (code) =>
|
|
55
|
+
code?.replace(/-/g, "").length === PAIR_LENGTH;
|
|
56
|
+
|
|
57
|
+
/** What Harness hears of a pairing code: the part it finds the waiting computer by, and proof of the whole code. */
|
|
58
|
+
export function pairClaim(code) {
|
|
59
|
+
const normal = normalizeJoinCode(code);
|
|
60
|
+
return {
|
|
61
|
+
lookup: normal.slice(0, LOOKUP_LENGTH),
|
|
62
|
+
verifier: createHmac("sha256", normal)
|
|
63
|
+
.update("HSC1-pair-verifier")
|
|
64
|
+
.digest("base64url"),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
42
68
|
/** What a side of the join proves: it holds the code, over both computers' ids and keys. */
|
|
43
69
|
export function joinProof(
|
|
44
70
|
code,
|
|
@@ -155,3 +181,36 @@ export async function openNotice(
|
|
|
155
181
|
if (!firstSeen(envelope.requestId)) return null;
|
|
156
182
|
return opened.notice;
|
|
157
183
|
}
|
|
184
|
+
|
|
185
|
+
/** Home asking a worker to put a question to the Harness windows linked to it (their screen history). */
|
|
186
|
+
export const sealAsk = (key, workerId, requestId, call, now = Date.now()) =>
|
|
187
|
+
seal(key, "h2a", workerId, requestId, { ts: now, call });
|
|
188
|
+
|
|
189
|
+
/** The worker opening home's question: fresh and never twice, as a call is. Null when it is not one. */
|
|
190
|
+
export async function openAsk(
|
|
191
|
+
key,
|
|
192
|
+
envelope,
|
|
193
|
+
{ workerId, firstSeen, now = Date.now() }
|
|
194
|
+
) {
|
|
195
|
+
if (envelope?.deviceId !== workerId) return null;
|
|
196
|
+
let opened;
|
|
197
|
+
try {
|
|
198
|
+
opened = await open(key, "h2a", envelope);
|
|
199
|
+
} catch {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
if (Math.abs(age(opened.ts, now)) > MAX_SKEW_MS) return null;
|
|
203
|
+
if (!firstSeen(envelope.requestId)) return null;
|
|
204
|
+
return opened.call ?? null;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** The worker's windows' answer to home's question. */
|
|
208
|
+
export const sealAskAnswer = (key, workerId, requestId, value) =>
|
|
209
|
+
seal(key, "a2h", workerId, requestId, value);
|
|
210
|
+
|
|
211
|
+
/** Home opening a worker's answer to its own question: anything else is refused. */
|
|
212
|
+
export async function openAskAnswer(key, envelope, { workerId, requestId }) {
|
|
213
|
+
if (envelope?.deviceId !== workerId || envelope?.requestId !== requestId)
|
|
214
|
+
throw new Error("the answer was for another question");
|
|
215
|
+
return open(key, "a2h", envelope);
|
|
216
|
+
}
|