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
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { spawn } from "node:child_process";
|
|
5
|
+
import { randomUUID } from "node:crypto";
|
|
6
|
+
|
|
7
|
+
// A room from a repository link: the person pastes a GitHub link (or any git host's), Harness finds that repository on
|
|
8
|
+
// this computer by its shared remote, and the room works there; when it is not here, the person picks a folder and
|
|
9
|
+
// Harness clones it into that folder. Git stays the record: the room is anchored by the checkout's first commit and
|
|
10
|
+
// its origin remote (projectGit.mjs anchorOf), so whatever the people agree on lives on the remote, not in Harness.
|
|
11
|
+
//
|
|
12
|
+
// Board commands, the person's only (an agent does not clone onto the computer):
|
|
13
|
+
// board.repo.find { link } → { repo, here: folder | null, places: [folders to clone into] }
|
|
14
|
+
// board.repo.clone { link, parent } → { folder }
|
|
15
|
+
// With detached:true, clone returns {operation,state:"cloning"}; board.repo.clone.read {operation} returns progress
|
|
16
|
+
// or the final result. Short calls fit existing browser/buddy transports while the owner's clone deadline runs here.
|
|
17
|
+
// Then board.project.create { folder } (or board.project.join { folder }) starts or joins the room as for any folder.
|
|
18
|
+
|
|
19
|
+
const HOSTS = ["github.com", "gitlab.com", "bitbucket.org", "codeberg.org"];
|
|
20
|
+
const NAME = /^[A-Za-z0-9._-]+$/;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* A repository link as people paste it: https://github.com/owner/name, with or without .git, a /tree/… page of it,
|
|
24
|
+
* github.com/owner/name, or git@github.com:owner/name.git. Null for anything else.
|
|
25
|
+
*/
|
|
26
|
+
export function parseRepoLink(text) {
|
|
27
|
+
const raw = String(text || "").trim();
|
|
28
|
+
const ssh = raw.match(/^(?:ssh:\/\/)?git@([^:/]+)[:/]([^/]+)\/([^/]+?)\/?$/);
|
|
29
|
+
let host, owner, name;
|
|
30
|
+
if (ssh) [, host, owner, name] = ssh;
|
|
31
|
+
else {
|
|
32
|
+
let url;
|
|
33
|
+
try {
|
|
34
|
+
url = new URL(/^[a-z]+:\/\//i.test(raw) ? raw : `https://${raw}`);
|
|
35
|
+
} catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
if (!["https:", "http:"].includes(url.protocol)) return null;
|
|
39
|
+
host = url.hostname;
|
|
40
|
+
[owner, name] = url.pathname.split("/").filter(Boolean);
|
|
41
|
+
}
|
|
42
|
+
host = String(host || "")
|
|
43
|
+
.toLowerCase()
|
|
44
|
+
.replace(/^www\./, "");
|
|
45
|
+
name = String(name || "").replace(/\.git$/, "");
|
|
46
|
+
if (!HOSTS.includes(host) || !NAME.test(owner || "") || !NAME.test(name))
|
|
47
|
+
return null;
|
|
48
|
+
return {
|
|
49
|
+
host,
|
|
50
|
+
owner,
|
|
51
|
+
name,
|
|
52
|
+
label: `${owner}/${name}`,
|
|
53
|
+
https: `https://${host}/${owner}/${name}.git`,
|
|
54
|
+
ssh: `git@${host}:${owner}/${name}.git`,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Whether a remote's address is the linked repository, however it was written. */
|
|
59
|
+
export const sameRepo = (remote, link) => {
|
|
60
|
+
const parsed = parseRepoLink(
|
|
61
|
+
String(remote || "").replace(/\/\/[^@/]+@/, "//")
|
|
62
|
+
);
|
|
63
|
+
return Boolean(
|
|
64
|
+
parsed &&
|
|
65
|
+
parsed.host === link.host &&
|
|
66
|
+
parsed.owner.toLowerCase() === link.owner.toLowerCase() &&
|
|
67
|
+
parsed.name.toLowerCase() === link.name.toLowerCase()
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** The origin remote's address from a checkout's git config, read without running git. */
|
|
72
|
+
function originOf(folder) {
|
|
73
|
+
let gitDir = path.join(folder, ".git");
|
|
74
|
+
try {
|
|
75
|
+
if (fs.statSync(gitDir).isFile()) {
|
|
76
|
+
// A worktree: .git names the real directory; its config is the main checkout's.
|
|
77
|
+
const pointed = fs
|
|
78
|
+
.readFileSync(gitDir, "utf8")
|
|
79
|
+
.match(/gitdir:\s*(.+)/)?.[1]
|
|
80
|
+
?.trim();
|
|
81
|
+
if (!pointed) return null;
|
|
82
|
+
gitDir = path.resolve(folder, pointed, "..", "..");
|
|
83
|
+
}
|
|
84
|
+
const config = fs.readFileSync(path.join(gitDir, "config"), "utf8");
|
|
85
|
+
const section = config
|
|
86
|
+
.split(/^\[/m)
|
|
87
|
+
.find((part) => /^remote "origin"\]/.test(part));
|
|
88
|
+
return section?.match(/^\s*url\s*=\s*(.+)$/m)?.[1]?.trim() ?? null;
|
|
89
|
+
} catch {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The folders people keep repositories in, those that exist here; the home folder last. */
|
|
95
|
+
export function usualPlaces(homeDir = os.homedir()) {
|
|
96
|
+
const names = [
|
|
97
|
+
"code",
|
|
98
|
+
"Code",
|
|
99
|
+
"src",
|
|
100
|
+
"dev",
|
|
101
|
+
"Developer",
|
|
102
|
+
"projects",
|
|
103
|
+
"Projects",
|
|
104
|
+
"GitHub",
|
|
105
|
+
"github",
|
|
106
|
+
"repos",
|
|
107
|
+
"workspace",
|
|
108
|
+
path.join("Documents", "GitHub"),
|
|
109
|
+
];
|
|
110
|
+
const found = [];
|
|
111
|
+
const seen = new Set();
|
|
112
|
+
for (const name of names) {
|
|
113
|
+
const folder = path.join(homeDir, name);
|
|
114
|
+
try {
|
|
115
|
+
const real = fs.realpathSync(folder);
|
|
116
|
+
if (fs.statSync(real).isDirectory() && !seen.has(real)) {
|
|
117
|
+
seen.add(real);
|
|
118
|
+
found.push(real);
|
|
119
|
+
}
|
|
120
|
+
} catch {}
|
|
121
|
+
}
|
|
122
|
+
return [...found, homeDir];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Git checkouts in a folder and one level below it (two when `deep`). */
|
|
126
|
+
function checkoutsIn(root, deep) {
|
|
127
|
+
const out = [];
|
|
128
|
+
const visit = (folder, depth) => {
|
|
129
|
+
let entries;
|
|
130
|
+
try {
|
|
131
|
+
entries = fs.readdirSync(folder, { withFileTypes: true });
|
|
132
|
+
} catch {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (entries.some((entry) => entry.name === ".git")) {
|
|
136
|
+
out.push(folder);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (depth === 0) return;
|
|
140
|
+
for (const entry of entries)
|
|
141
|
+
if (
|
|
142
|
+
entry.isDirectory() &&
|
|
143
|
+
!entry.name.startsWith(".") &&
|
|
144
|
+
entry.name !== "node_modules" &&
|
|
145
|
+
entry.name !== "Library"
|
|
146
|
+
)
|
|
147
|
+
visit(path.join(folder, entry.name), depth - 1);
|
|
148
|
+
};
|
|
149
|
+
visit(root, deep ? 2 : 1);
|
|
150
|
+
return out;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* This computer's checkout of the linked repository: among the folders the person's agents work in, then the usual
|
|
155
|
+
* places, the first whose origin is that repository. Null when it is not here.
|
|
156
|
+
*/
|
|
157
|
+
export function findHere({ link, folders = [], homeDir = os.homedir() }) {
|
|
158
|
+
const places = usualPlaces(homeDir);
|
|
159
|
+
const candidates = [
|
|
160
|
+
...folders,
|
|
161
|
+
...places.flatMap((place) => checkoutsIn(place, place !== homeDir)),
|
|
162
|
+
];
|
|
163
|
+
const seen = new Set();
|
|
164
|
+
for (const folder of candidates) {
|
|
165
|
+
let real;
|
|
166
|
+
try {
|
|
167
|
+
real = fs.realpathSync(folder);
|
|
168
|
+
} catch {
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
if (seen.has(real)) continue;
|
|
172
|
+
seen.add(real);
|
|
173
|
+
if (sameRepo(originOf(real), link)) return real;
|
|
174
|
+
}
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// How long a clone may wait for the remote to answer: 2 minutes, the owner's value, not yet measured against real
|
|
179
|
+
// GitHub clones. It covers only the wait for the remote's first byte; once the remote is answering, a large
|
|
180
|
+
// repository takes as long as its transfer does.
|
|
181
|
+
export const FIRST_BYTE_MS = 120_000;
|
|
182
|
+
|
|
183
|
+
// What git says before the remote has answered: its own "Cloning into '<folder>'..." line.
|
|
184
|
+
const beforeRemote = (text) =>
|
|
185
|
+
text
|
|
186
|
+
.split(/[\r\n]+/)
|
|
187
|
+
.every((line) => !line.trim() || /^Cloning into /.test(line.trim()));
|
|
188
|
+
|
|
189
|
+
function gitLater(cwd, args, firstByteMs) {
|
|
190
|
+
return new Promise((resolve) => {
|
|
191
|
+
// Its own process group: git hands the network to a helper (git-remote-https, ssh) that would outlive git itself
|
|
192
|
+
// and keep the output open, so giving up stops the whole group.
|
|
193
|
+
const child = spawn("git", args, {
|
|
194
|
+
cwd,
|
|
195
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: "0" },
|
|
196
|
+
detached: true,
|
|
197
|
+
});
|
|
198
|
+
let err = "";
|
|
199
|
+
let answered = false;
|
|
200
|
+
let settled = false;
|
|
201
|
+
const finish = (result) => {
|
|
202
|
+
if (settled) return;
|
|
203
|
+
settled = true;
|
|
204
|
+
clearTimeout(timer);
|
|
205
|
+
resolve(result);
|
|
206
|
+
};
|
|
207
|
+
const timer = setTimeout(() => {
|
|
208
|
+
try {
|
|
209
|
+
process.kill(-child.pid, "SIGTERM");
|
|
210
|
+
} catch {
|
|
211
|
+
child.kill("SIGTERM");
|
|
212
|
+
}
|
|
213
|
+
finish({
|
|
214
|
+
ok: false,
|
|
215
|
+
err: `the remote did not answer within ${Math.round(firstByteMs / 1000)} seconds`,
|
|
216
|
+
});
|
|
217
|
+
}, firstByteMs);
|
|
218
|
+
child.stderr.on("data", (chunk) => {
|
|
219
|
+
err += chunk;
|
|
220
|
+
if (!answered && !beforeRemote(String(chunk))) {
|
|
221
|
+
answered = true;
|
|
222
|
+
clearTimeout(timer);
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
child.on("error", (error) => finish({ ok: false, err: error.message }));
|
|
226
|
+
child.on("close", (code) => finish({ ok: code === 0, err: err.trim() }));
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Clone the linked repository into `parent`, as a folder named for it (name-2 and on when one is there). The https
|
|
232
|
+
* address first, then ssh, so either the person's GitHub sign-in or their ssh key opens a private repository.
|
|
233
|
+
*/
|
|
234
|
+
export async function cloneInto({ link, parent, firstByteMs = FIRST_BYTE_MS }) {
|
|
235
|
+
const where = String(parent || "");
|
|
236
|
+
if (
|
|
237
|
+
!path.isAbsolute(where) ||
|
|
238
|
+
!fs.existsSync(where) ||
|
|
239
|
+
!fs.statSync(where).isDirectory()
|
|
240
|
+
)
|
|
241
|
+
return { ok: false, error: "Pick a folder that is on this computer." };
|
|
242
|
+
let target = path.join(where, link.name);
|
|
243
|
+
for (let n = 2; fs.existsSync(target); n += 1)
|
|
244
|
+
target = path.join(where, `${link.name}-${n}`);
|
|
245
|
+
let last = null;
|
|
246
|
+
for (const address of [link.https, link.ssh]) {
|
|
247
|
+
// --progress: git reports the remote's answer as it comes, which is what the deadline waits for.
|
|
248
|
+
const cloned = await gitLater(
|
|
249
|
+
where,
|
|
250
|
+
["clone", "--progress", address, target],
|
|
251
|
+
firstByteMs
|
|
252
|
+
);
|
|
253
|
+
if (cloned.ok) return { ok: true, folder: fs.realpathSync(target) };
|
|
254
|
+
last = cloned.err.split("\n").filter(Boolean).at(-1) ?? "git clone failed";
|
|
255
|
+
fs.rmSync(target, { recursive: true, force: true });
|
|
256
|
+
}
|
|
257
|
+
return {
|
|
258
|
+
ok: false,
|
|
259
|
+
error: `Couldn't clone ${link.label}: ${last}. If it is private, sign in to ${link.host} on this computer (for GitHub: gh auth login) and try again.`,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** The board commands above. `knownFolders`: the folders the person's agents work in (folders.mjs). */
|
|
264
|
+
export function createRepoLinks({
|
|
265
|
+
knownFolders = () => [],
|
|
266
|
+
homeDir = os.homedir(),
|
|
267
|
+
} = {}) {
|
|
268
|
+
const clones = new Map();
|
|
269
|
+
const destinations = new Map();
|
|
270
|
+
const progress = (job) =>
|
|
271
|
+
job.result ?? { ok: true, operation: job.id, state: "cloning" };
|
|
272
|
+
const keepRecentResults = () => {
|
|
273
|
+
const finished = [...clones.values()].filter((job) => job.result);
|
|
274
|
+
for (const job of finished.slice(0, -32)) {
|
|
275
|
+
clones.delete(job.id);
|
|
276
|
+
if (destinations.get(job.key) === job) destinations.delete(job.key);
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
const linkOf = (request) => {
|
|
280
|
+
const link = parseRepoLink(request.link);
|
|
281
|
+
return link
|
|
282
|
+
? { link }
|
|
283
|
+
: {
|
|
284
|
+
error:
|
|
285
|
+
"That is not a repository link. Paste one like https://github.com/owner/name.",
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
return {
|
|
289
|
+
command(request, agent) {
|
|
290
|
+
// The person on this computer, not a hosted caller acting as them: a clone writes to this computer's disk.
|
|
291
|
+
if (agent !== "user" || request.hostedCaller === true)
|
|
292
|
+
return { ok: false, error: "Only the person opens a repository link." };
|
|
293
|
+
if (request.command === "board.repo.clone.read") {
|
|
294
|
+
const job = clones.get(request.operation);
|
|
295
|
+
return job
|
|
296
|
+
? progress(job)
|
|
297
|
+
: {
|
|
298
|
+
ok: false,
|
|
299
|
+
error:
|
|
300
|
+
"That clone is no longer tracked. Find the repository again.",
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
const { link, error } = linkOf(request);
|
|
304
|
+
if (!link) return { ok: false, error };
|
|
305
|
+
if (request.command === "board.repo.find") {
|
|
306
|
+
const here = findHere({ link, folders: knownFolders(), homeDir });
|
|
307
|
+
return {
|
|
308
|
+
ok: true,
|
|
309
|
+
repo: { label: link.label, host: link.host, remote: link.https },
|
|
310
|
+
here,
|
|
311
|
+
places: here ? [] : usualPlaces(homeDir),
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
if (request.command === "board.repo.clone") {
|
|
315
|
+
const parent = String(request.parent || "");
|
|
316
|
+
let canonicalParent = path.resolve(parent);
|
|
317
|
+
try {
|
|
318
|
+
canonicalParent = fs.realpathSync(parent);
|
|
319
|
+
} catch {}
|
|
320
|
+
const key = JSON.stringify([link.https, canonicalParent]);
|
|
321
|
+
const current = destinations.get(key);
|
|
322
|
+
if (
|
|
323
|
+
request.detached === true &&
|
|
324
|
+
current &&
|
|
325
|
+
(!current.result ||
|
|
326
|
+
(current.result.ok &&
|
|
327
|
+
sameRepo(originOf(current.result.folder), link)))
|
|
328
|
+
)
|
|
329
|
+
return progress(current);
|
|
330
|
+
const already = findHere({ link, folders: knownFolders(), homeDir });
|
|
331
|
+
if (already) return { ok: true, folder: already, cloned: false };
|
|
332
|
+
const pending = cloneInto({ link, parent }).then((done) =>
|
|
333
|
+
done.ok ? { ...done, cloned: true } : done
|
|
334
|
+
);
|
|
335
|
+
if (request.detached !== true) return { pending };
|
|
336
|
+
const job = { id: randomUUID(), key, result: null };
|
|
337
|
+
clones.set(job.id, job);
|
|
338
|
+
destinations.set(key, job);
|
|
339
|
+
void pending
|
|
340
|
+
.catch((failure) => ({ ok: false, error: String(failure) }))
|
|
341
|
+
.then((result) => {
|
|
342
|
+
job.result = result;
|
|
343
|
+
clones.delete(job.id);
|
|
344
|
+
clones.set(job.id, job);
|
|
345
|
+
if (!result.ok && destinations.get(key) === job)
|
|
346
|
+
destinations.delete(key);
|
|
347
|
+
keepRecentResults();
|
|
348
|
+
});
|
|
349
|
+
return progress(job);
|
|
350
|
+
}
|
|
351
|
+
return { ok: false, error: `unknown command ${request.command}` };
|
|
352
|
+
},
|
|
353
|
+
};
|
|
354
|
+
}
|