@agentconnect.md/daemon 1.49.0-rc.3 → 1.49.0-rc.5

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.
@@ -0,0 +1,549 @@
1
+ #!/usr/bin/env node
2
+ import { createHash } from "node:crypto";
3
+ import { constants, promises } from "node:fs";
4
+ import { dirname, isAbsolute, join, relative, sep } from "node:path";
5
+ //#region src/skills/skill-workspace-mutation-cli.ts
6
+ const SAFE_SEGMENT = /^\.?[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9_-])?$/;
7
+ const SAFE_BUNDLE = /^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,126}[A-Za-z0-9_-])?$/;
8
+ const RESERVED_FIRST = /* @__PURE__ */ new Set([".git", ".agentconnect"]);
9
+ const SAFE_OPERATION = /^[a-f0-9-]{36}$/;
10
+ const SAFE_QUARANTINE = /^\.agentconnect-skill-(?:new|old|trash)-[a-f0-9-]{36}$/;
11
+ const CONTROL_RE = /[\u0000-\u001f\u007f-\u009f]/;
12
+ const READ_FLAGS = constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK;
13
+ const WRITE_FLAGS = constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW;
14
+ function fail(message) {
15
+ throw new Error(message);
16
+ }
17
+ function identity(stat) {
18
+ return {
19
+ dev: stat.dev.toString(),
20
+ ino: stat.ino.toString()
21
+ };
22
+ }
23
+ function sameIdentity(left, right) {
24
+ return left.dev === right.dev && left.ino === right.ino;
25
+ }
26
+ function validateIdentity(value) {
27
+ if (!value || !/^\d+$/.test(value.dev) || !/^\d+$/.test(value.ino)) fail("invalid filesystem identity");
28
+ }
29
+ function validateReservation(value) {
30
+ if (!value) fail("missing skill mutation reservation authority");
31
+ validateIdentity(value.identity);
32
+ validateIdentity(value.markerIdentity);
33
+ }
34
+ function validateRelativeRoot(value) {
35
+ if (isAbsolute(value) || value.includes("\\") || value.includes("\0") || Buffer.byteLength(value, "utf8") > 1024) fail("unsafe skill mutation path");
36
+ const parts = value.split("/");
37
+ if (parts.length < 2 || parts.length > 8 || parts.at(-2) !== "skills" || !SAFE_BUNDLE.test(parts.at(-1))) fail("unsafe skill mutation path");
38
+ for (const part of parts.slice(0, -1)) if (part.length > 128 || !SAFE_SEGMENT.test(part)) fail("unsafe skill mutation path");
39
+ if (RESERVED_FIRST.has(parts[0].toLowerCase())) fail("reserved skill mutation path");
40
+ return parts;
41
+ }
42
+ function validateReceipt(receipt) {
43
+ if (!/^[a-f0-9]{64}$/.test(receipt.treeDigest) || !Array.isArray(receipt.files) || receipt.files.length === 0) fail("invalid skill mutation receipt");
44
+ let total = 0;
45
+ const seen = /* @__PURE__ */ new Set();
46
+ for (const file of receipt.files) {
47
+ const parts = file.path.split("/");
48
+ if (!file.path || isAbsolute(file.path) || file.path.includes("\\") || file.path.includes("\0") || CONTROL_RE.test(file.path) || parts.some((part) => !part || part === "." || part === "..") || parts.length > 32 || file.mode !== 384 && file.mode !== 448 || !Number.isSafeInteger(file.size) || file.size < 0 || file.size > 512 * 1024 || !/^[a-f0-9]{64}$/.test(file.sha256) || seen.has(file.path)) fail("invalid skill mutation receipt");
49
+ total += file.size;
50
+ if (total > 4 * 1024 * 1024) fail("invalid skill mutation receipt");
51
+ seen.add(file.path);
52
+ }
53
+ if (!seen.has("SKILL.md") || digest(receipt.files) !== receipt.treeDigest) fail("invalid skill mutation receipt");
54
+ }
55
+ function digest(files) {
56
+ return createHash("sha256").update(JSON.stringify(files)).digest("hex");
57
+ }
58
+ function under(root, path) {
59
+ const rel = relative(root, path);
60
+ return rel === "" || rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel);
61
+ }
62
+ async function checkedWorkspace(cwdInput, expected) {
63
+ const lexical = await promises.lstat(cwdInput, { bigint: true });
64
+ if (!lexical.isDirectory() || lexical.isSymbolicLink() || !sameIdentity(identity(lexical), expected)) fail("skill mutation workspace identity changed");
65
+ const cwd = await promises.realpath(cwdInput);
66
+ const canonical = await promises.lstat(cwd, { bigint: true });
67
+ if (!canonical.isDirectory() || canonical.isSymbolicLink() || !sameIdentity(identity(canonical), expected)) fail("skill mutation workspace identity changed");
68
+ return cwd;
69
+ }
70
+ async function safeTarget(cwdInput, relativeRoot, createParents, workspaceIdentity) {
71
+ const parts = validateRelativeRoot(relativeRoot);
72
+ const cwd = await checkedWorkspace(cwdInput, workspaceIdentity);
73
+ let parent = cwd;
74
+ for (const part of parts.slice(0, -1)) {
75
+ const next = join(parent, part);
76
+ if (createParents) {
77
+ let created = false;
78
+ try {
79
+ await promises.mkdir(next);
80
+ created = true;
81
+ } catch (error) {
82
+ if (error.code !== "EEXIST") throw error;
83
+ }
84
+ if (created) {
85
+ await syncDirectory(next);
86
+ await syncDirectory(parent);
87
+ }
88
+ } else try {
89
+ await promises.lstat(next);
90
+ } catch (error) {
91
+ if (error.code === "ENOENT") fail("skill mutation parent is missing");
92
+ throw error;
93
+ }
94
+ const stat = await promises.lstat(next);
95
+ if (!stat.isDirectory() || stat.isSymbolicLink()) fail("skill mutation parent is unsafe");
96
+ parent = await promises.realpath(next);
97
+ if (!under(cwd, parent)) fail("skill mutation parent escapes workspace");
98
+ }
99
+ return join(parent, parts.at(-1));
100
+ }
101
+ /** Resolve a target without creating parents. A missing ancestor proves the
102
+ * target and every journaled sibling artifact are absent; existing ancestors
103
+ * still receive the full no-link containment checks. */
104
+ async function safeTargetWhenParentExists(cwdInput, relativeRoot, workspaceIdentity) {
105
+ const parts = validateRelativeRoot(relativeRoot);
106
+ const cwd = await checkedWorkspace(cwdInput, workspaceIdentity);
107
+ let parent = cwd;
108
+ for (const part of parts.slice(0, -1)) {
109
+ const next = join(parent, part);
110
+ let stat;
111
+ try {
112
+ stat = await promises.lstat(next);
113
+ } catch (error) {
114
+ if (error.code === "ENOENT") return void 0;
115
+ throw error;
116
+ }
117
+ if (!stat.isDirectory() || stat.isSymbolicLink()) fail("skill mutation parent is unsafe");
118
+ parent = await promises.realpath(next);
119
+ if (!under(cwd, parent)) fail("skill mutation parent escapes workspace");
120
+ }
121
+ return join(parent, parts.at(-1));
122
+ }
123
+ async function boundedRead(path, expected) {
124
+ const before = await promises.lstat(path, { bigint: true });
125
+ if (!before.isFile() || before.isSymbolicLink() || before.nlink !== 1n || before.size !== BigInt(expected.size)) fail("skill mutation source changed");
126
+ const handle = await promises.open(path, READ_FLAGS);
127
+ try {
128
+ const opened = await handle.stat({ bigint: true });
129
+ if (!opened.isFile() || !sameIdentity(identity(before), identity(opened)) || opened.size !== BigInt(expected.size)) fail("skill mutation source changed");
130
+ const body = Buffer.alloc(expected.size);
131
+ let offset = 0;
132
+ while (offset < body.length) {
133
+ const { bytesRead } = await handle.read(body, offset, body.length - offset, offset);
134
+ if (bytesRead === 0) fail("skill mutation source changed");
135
+ offset += bytesRead;
136
+ }
137
+ const probe = Buffer.alloc(1);
138
+ if ((await handle.read(probe, 0, 1, offset)).bytesRead !== 0) fail("skill mutation source changed");
139
+ if (createHash("sha256").update(body).digest("hex") !== expected.sha256) fail("skill mutation source changed");
140
+ return body;
141
+ } finally {
142
+ await handle.close();
143
+ }
144
+ }
145
+ async function inspectBundle(root, expected, operationId, markerIdentity) {
146
+ validateReceipt(expected);
147
+ const rootStat = await promises.lstat(root, { bigint: true });
148
+ if (!rootStat.isDirectory() || rootStat.isSymbolicLink()) fail("skill mutation bundle root is unsafe");
149
+ const files = new Map(expected.files.map((file) => [file.path, file]));
150
+ const directories = /* @__PURE__ */ new Set();
151
+ for (const file of expected.files) {
152
+ const parts = file.path.split("/");
153
+ for (let index = 1; index < parts.length; index += 1) directories.add(parts.slice(0, index).join("/"));
154
+ }
155
+ const seen = /* @__PURE__ */ new Set();
156
+ let entries = 0;
157
+ const walk = async (dir, prefix = "") => {
158
+ for (const entry of await promises.readdir(dir, { withFileTypes: true })) {
159
+ entries += 1;
160
+ if (entries > 1024) fail("skill mutation bundle has too many entries");
161
+ const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
162
+ const abs = join(dir, entry.name);
163
+ const stat = await promises.lstat(abs);
164
+ if (entry.isSymbolicLink() || stat.isSymbolicLink()) fail("skill mutation bundle contains a link");
165
+ if (prefix === "" && operationId && rel === `.agentconnect-installing-${operationId}` && await markerMatches(root, operationId, markerIdentity)) continue;
166
+ if (entry.isDirectory() && stat.isDirectory()) {
167
+ if (!directories.has(rel)) fail("skill mutation bundle contains an unexpected directory");
168
+ await walk(abs, rel);
169
+ continue;
170
+ }
171
+ const receipt = files.get(rel);
172
+ if (!receipt || !entry.isFile() || !stat.isFile()) fail("skill mutation bundle contains an unexpected entry");
173
+ const body = await boundedRead(abs, receipt);
174
+ if ((stat.mode & 73 ? 448 : 384) !== receipt.mode || body.length !== receipt.size) fail("skill mutation bundle does not match receipt");
175
+ seen.add(rel);
176
+ }
177
+ };
178
+ await walk(root);
179
+ if (seen.size !== files.size) fail("skill mutation bundle is incomplete");
180
+ const rootAfter = await promises.lstat(root, { bigint: true });
181
+ if (!sameIdentity(identity(rootStat), identity(rootAfter))) fail("skill mutation bundle changed during inspection");
182
+ return identity(rootAfter);
183
+ }
184
+ async function ensureDirectoryPath(root, path) {
185
+ let current = root;
186
+ for (const part of path.split("/").slice(0, -1)) {
187
+ current = join(current, part);
188
+ try {
189
+ await promises.mkdir(current, { mode: 448 });
190
+ } catch (error) {
191
+ if (error.code !== "EEXIST") throw error;
192
+ }
193
+ const stat = await promises.lstat(current);
194
+ if (!stat.isDirectory() || stat.isSymbolicLink()) fail("skill mutation destination parent is unsafe");
195
+ }
196
+ }
197
+ function operationMarkerName(operationId) {
198
+ return `.agentconnect-installing-${operationId}`;
199
+ }
200
+ async function reserve(spec) {
201
+ if (!SAFE_OPERATION.test(spec.operationId) || !SAFE_QUARANTINE.test(spec.reservationName) || !SAFE_QUARANTINE.test(spec.quarantineName)) fail("invalid reservation operation");
202
+ if (spec.prior) validateReceipt(spec.prior);
203
+ const target = await safeTarget(spec.cwd, spec.relativeRoot, true, spec.workspaceIdentity);
204
+ const quarantine = join(dirname(target), spec.quarantineName);
205
+ try {
206
+ const current = await promises.lstat(target, { bigint: true });
207
+ if (!spec.prior || !sameIdentity(identity(current), spec.prior.identity)) fail("refusing to replace unowned skill");
208
+ await inspectBundle(target, spec.prior);
209
+ await promises.rename(target, quarantine);
210
+ await syncParent(quarantine);
211
+ if (!sameIdentity(await inspectBundle(quarantine, spec.prior), spec.prior.identity)) fail("skill changed while quarantining");
212
+ } catch (error) {
213
+ if (error.code !== "ENOENT") throw error;
214
+ if (spec.prior) fail("owned skill disappeared during reservation");
215
+ }
216
+ await promises.mkdir(target, { mode: 448 });
217
+ const reservationIdentity = identity(await promises.lstat(target, { bigint: true }));
218
+ const marker = join(target, operationMarkerName(spec.operationId));
219
+ await promises.mkdir(marker, { mode: 448 });
220
+ const markerIdentity = identity(await promises.lstat(marker, { bigint: true }));
221
+ await syncDirectory(marker);
222
+ await syncDirectory(target);
223
+ await syncParent(target);
224
+ const reservationAfter = identity(await promises.lstat(target, { bigint: true }));
225
+ if (!sameIdentity(reservationIdentity, reservationAfter) || !await markerMatches(target, spec.operationId, markerIdentity)) fail("skill mutation reservation changed while reserving");
226
+ await checkedWorkspace(spec.cwd, spec.workspaceIdentity);
227
+ return {
228
+ identity: reservationAfter,
229
+ markerIdentity
230
+ };
231
+ }
232
+ async function populateReservation(source, target, receipt, operationId, authority) {
233
+ validateReceipt(receipt);
234
+ validateReservation(authority);
235
+ await inspectBundle(source, receipt);
236
+ const rootIdentity = identity(await promises.lstat(target, { bigint: true }));
237
+ if (!sameIdentity(rootIdentity, authority.identity) || !await markerMatches(target, operationId, authority.markerIdentity)) fail("skill mutation reservation authority changed");
238
+ const publicationOrder = [...receipt.files.filter((file) => file.path !== "SKILL.md"), ...receipt.files.filter((file) => file.path === "SKILL.md")];
239
+ for (const file of publicationOrder) {
240
+ if (file.path === "SKILL.md") await syncDirectoryTree(target, {
241
+ ...receipt,
242
+ files: publicationOrder.filter((candidate) => candidate.path !== "SKILL.md")
243
+ });
244
+ await ensureDirectoryPath(target, file.path);
245
+ const body = await boundedRead(join(source, ...file.path.split("/")), file);
246
+ const output = await promises.open(join(target, ...file.path.split("/")), WRITE_FLAGS, file.mode);
247
+ try {
248
+ await output.writeFile(body);
249
+ await output.chmod(file.mode);
250
+ await output.sync();
251
+ } finally {
252
+ await output.close();
253
+ }
254
+ }
255
+ const publishedIdentity = await inspectBundle(target, receipt, operationId, authority.markerIdentity);
256
+ if (!sameIdentity(rootIdentity, publishedIdentity)) fail("skill mutation destination was replaced");
257
+ await syncDirectoryTree(target, receipt);
258
+ await syncParent(target);
259
+ return publishedIdentity;
260
+ }
261
+ async function syncDirectoryTree(root, receipt) {
262
+ if (process.platform === "win32") return;
263
+ const dirs = /* @__PURE__ */ new Set([root]);
264
+ for (const file of receipt.files) {
265
+ let current = dirname(join(root, ...file.path.split("/")));
266
+ while (under(root, current)) {
267
+ dirs.add(current);
268
+ if (current === root) break;
269
+ current = dirname(current);
270
+ }
271
+ }
272
+ for (const dir of [...dirs].sort((a, b) => b.length - a.length)) {
273
+ const handle = await promises.open(dir, constants.O_RDONLY);
274
+ try {
275
+ await handle.sync();
276
+ } finally {
277
+ await handle.close();
278
+ }
279
+ }
280
+ }
281
+ async function syncDirectory(path) {
282
+ if (process.platform === "win32") return;
283
+ const handle = await promises.open(path, constants.O_RDONLY);
284
+ try {
285
+ await handle.sync();
286
+ } finally {
287
+ await handle.close();
288
+ }
289
+ }
290
+ async function syncParent(path) {
291
+ if (process.platform === "win32") return;
292
+ const handle = await promises.open(dirname(path), constants.O_RDONLY);
293
+ try {
294
+ await handle.sync();
295
+ } finally {
296
+ await handle.close();
297
+ }
298
+ }
299
+ async function markerMatches(root, operationId, expected) {
300
+ try {
301
+ const marker = join(root, operationMarkerName(operationId));
302
+ const before = await promises.lstat(marker, { bigint: true });
303
+ if (!before.isDirectory() || before.isSymbolicLink()) return false;
304
+ const directory = await promises.opendir(marker);
305
+ try {
306
+ if (await directory.read() !== null) return false;
307
+ } finally {
308
+ await directory.close();
309
+ }
310
+ const after = await promises.lstat(marker, { bigint: true });
311
+ const found = identity(after);
312
+ return after.isDirectory() && !after.isSymbolicLink() && sameIdentity(identity(before), found) && (!expected || sameIdentity(found, expected));
313
+ } catch {
314
+ return false;
315
+ }
316
+ }
317
+ async function apply(spec) {
318
+ if (!SAFE_OPERATION.test(spec.operationId) || !SAFE_QUARANTINE.test(spec.reservationName) || !SAFE_QUARANTINE.test(spec.quarantineName)) fail("invalid operation");
319
+ if (spec.prior) validateReceipt(spec.prior);
320
+ if (spec.candidate) {
321
+ validateReceipt(spec.candidate);
322
+ validateReservation(spec.reservation);
323
+ if (spec.prior) fail("candidate prior must be quarantined during reservation");
324
+ } else if (spec.reservation) fail("unexpected reservation authority");
325
+ const target = await safeTarget(spec.cwd, spec.relativeRoot, true, spec.workspaceIdentity);
326
+ const quarantine = join(dirname(target), spec.quarantineName);
327
+ let quarantineIdentity;
328
+ if (!spec.candidate) try {
329
+ const current = await promises.lstat(target, { bigint: true });
330
+ if (!spec.prior || !sameIdentity(identity(current), spec.prior.identity)) fail("refusing to replace unowned skill");
331
+ await inspectBundle(target, spec.prior);
332
+ await promises.rename(target, quarantine);
333
+ await syncParent(quarantine);
334
+ quarantineIdentity = await inspectBundle(quarantine, spec.prior);
335
+ if (!sameIdentity(quarantineIdentity, spec.prior.identity)) fail("skill changed while quarantining");
336
+ } catch (error) {
337
+ if (error.code !== "ENOENT") throw error;
338
+ if (spec.prior) fail("owned skill disappeared during mutation");
339
+ }
340
+ let targetIdentity;
341
+ if (spec.candidate) {
342
+ const reservationIdentity = await populateReservation(spec.candidate.sourceDir, target, spec.candidate, spec.operationId, spec.reservation);
343
+ targetIdentity = await inspectBundle(target, spec.candidate, spec.operationId, spec.reservation.markerIdentity);
344
+ if (!sameIdentity(reservationIdentity, targetIdentity)) fail("skill mutation destination changed while publishing");
345
+ }
346
+ await checkedWorkspace(spec.cwd, spec.workspaceIdentity);
347
+ return {
348
+ quarantineIdentity,
349
+ targetIdentity
350
+ };
351
+ }
352
+ async function pathExists(path) {
353
+ try {
354
+ await promises.lstat(path);
355
+ return true;
356
+ } catch (error) {
357
+ if (error.code === "ENOENT") return false;
358
+ throw error;
359
+ }
360
+ }
361
+ async function removeExpectedArtifact(path, expected, requireComplete) {
362
+ const stat = await promises.lstat(path, { bigint: true });
363
+ if (!stat.isDirectory() || stat.isSymbolicLink() || !sameIdentity(identity(stat), expected.identity)) fail("cleanup target was replaced");
364
+ if (requireComplete) {
365
+ if (!sameIdentity(await inspectBundle(path, expected), expected.identity)) fail("cleanup target was replaced");
366
+ }
367
+ await promises.rm(path, {
368
+ recursive: true,
369
+ force: false
370
+ });
371
+ await syncParent(path);
372
+ }
373
+ /** Before reservation identities are durably journaled, correct code cannot
374
+ * have written a candidate byte. Recovery may therefore remove only the two
375
+ * content-free crash shapes (empty root, or root + empty marker). Anything
376
+ * else could be user/attacker content and fails closed. */
377
+ async function removePreByteReservation(path, operationId) {
378
+ const stat = await promises.lstat(path, { bigint: true });
379
+ if (!stat.isDirectory() || stat.isSymbolicLink()) fail("discard reservation is unsafe");
380
+ const entries = await promises.readdir(path);
381
+ if (entries.length === 0) {
382
+ const after = await promises.lstat(path, { bigint: true });
383
+ if (!sameIdentity(identity(stat), identity(after))) fail("discard reservation changed");
384
+ await promises.rmdir(path);
385
+ await syncParent(path);
386
+ return;
387
+ }
388
+ if (entries.length !== 1 || entries[0] !== operationMarkerName(operationId)) fail("refusing to discard an unowned reservation");
389
+ if (!await markerMatches(path, operationId)) fail("discard reservation marker is unsafe");
390
+ const after = await promises.lstat(path, { bigint: true });
391
+ if (!sameIdentity(identity(stat), identity(after))) fail("discard reservation changed");
392
+ await promises.rmdir(join(path, operationMarkerName(operationId)));
393
+ await promises.rmdir(path);
394
+ await syncParent(path);
395
+ }
396
+ /** Remove a reservation whose root and marker identities were persisted before
397
+ * any candidate byte was permitted. The marker stays until all other entries
398
+ * are gone, so an interrupted deletion remains resumable under the same inode
399
+ * authority. */
400
+ async function removeOwnedReservation(path, operationId, authority) {
401
+ validateReservation(authority);
402
+ const stat = await promises.lstat(path, { bigint: true });
403
+ if (!stat.isDirectory() || stat.isSymbolicLink() || !sameIdentity(identity(stat), authority.identity)) fail("discard reservation identity changed");
404
+ const markerName = operationMarkerName(operationId);
405
+ if (!await markerMatches(path, operationId, authority.markerIdentity)) {
406
+ if ((await promises.readdir(path)).length === 0) {
407
+ if (!sameIdentity(identity(await promises.lstat(path, { bigint: true })), authority.identity)) fail("discard reservation identity changed");
408
+ await promises.rmdir(path);
409
+ await syncParent(path);
410
+ return;
411
+ }
412
+ fail("discard reservation marker changed");
413
+ }
414
+ let entries = 0;
415
+ const directory = await promises.opendir(path);
416
+ for await (const entry of directory) {
417
+ entries += 1;
418
+ if (entries > 4096) fail("discard reservation has too many entries");
419
+ if (entry.name === markerName) continue;
420
+ if (!sameIdentity(identity(await promises.lstat(path, { bigint: true })), authority.identity)) fail("discard reservation identity changed");
421
+ await promises.rm(join(path, entry.name), {
422
+ recursive: true,
423
+ force: false
424
+ });
425
+ }
426
+ await syncDirectory(path);
427
+ if (!sameIdentity(identity(await promises.lstat(path, { bigint: true })), authority.identity) || !await markerMatches(path, operationId, authority.markerIdentity)) fail("discard reservation authority changed");
428
+ await promises.rmdir(join(path, markerName));
429
+ const empty = await promises.readdir(path);
430
+ const finalStat = await promises.lstat(path, { bigint: true });
431
+ if (empty.length !== 0 || !sameIdentity(identity(finalStat), authority.identity)) fail("discard reservation changed before removal");
432
+ await promises.rmdir(path);
433
+ await syncParent(path);
434
+ }
435
+ async function moveAndRemoveOwnedReservation(path, tombstone, operationId, authority) {
436
+ const stat = await promises.lstat(path, { bigint: true });
437
+ if (!stat.isDirectory() || stat.isSymbolicLink() || !sameIdentity(identity(stat), authority.identity) || !await markerMatches(path, operationId, authority.markerIdentity)) fail("discard reservation authority changed");
438
+ if (await pathExists(tombstone)) fail("discard tombstone already exists");
439
+ await promises.rename(path, tombstone);
440
+ await syncParent(tombstone);
441
+ if (!sameIdentity(identity(await promises.lstat(tombstone, { bigint: true })), authority.identity)) fail("discard reservation changed while moving");
442
+ await removeOwnedReservation(tombstone, operationId, authority);
443
+ }
444
+ async function cleanup(spec) {
445
+ if (!SAFE_QUARANTINE.test(spec.name) || !SAFE_QUARANTINE.test(spec.tombstoneName)) fail("invalid cleanup name");
446
+ const target = await safeTargetWhenParentExists(spec.cwd, spec.relativeRoot, spec.workspaceIdentity);
447
+ if (!target) return;
448
+ const quarantine = join(dirname(target), spec.name);
449
+ const tombstone = join(dirname(target), spec.tombstoneName);
450
+ const quarantineExists = await pathExists(quarantine);
451
+ const tombstoneExists = await pathExists(tombstone);
452
+ if (quarantineExists && tombstoneExists) fail("cleanup artifacts conflict");
453
+ if (quarantineExists) {
454
+ if (!sameIdentity(await inspectBundle(quarantine, spec.expected), spec.expected.identity)) fail("cleanup target was replaced");
455
+ await promises.rename(quarantine, tombstone);
456
+ await syncParent(tombstone);
457
+ await removeExpectedArtifact(tombstone, spec.expected, true);
458
+ } else if (tombstoneExists) await removeExpectedArtifact(tombstone, spec.expected, false);
459
+ await checkedWorkspace(spec.cwd, spec.workspaceIdentity);
460
+ }
461
+ async function discard(spec) {
462
+ if (!SAFE_QUARANTINE.test(spec.tombstoneName) || spec.reservationName !== void 0 && !SAFE_QUARANTINE.test(spec.reservationName)) fail("invalid discard name");
463
+ if (spec.operationId && !SAFE_OPERATION.test(spec.operationId)) fail("invalid discard operation");
464
+ if (spec.reservation) validateReservation(spec.reservation);
465
+ if (spec.prior) validateReceipt(spec.prior);
466
+ const target = await safeTargetWhenParentExists(spec.cwd, spec.relativeRoot, spec.workspaceIdentity);
467
+ if (!target) return;
468
+ const tombstone = join(dirname(target), spec.tombstoneName);
469
+ if (await pathExists(tombstone)) {
470
+ if (!spec.operationId || !spec.reservation) fail("refusing to discard an unknown tombstone");
471
+ await removeOwnedReservation(tombstone, spec.operationId, spec.reservation);
472
+ }
473
+ if (!await pathExists(target)) return;
474
+ const targetStat = await promises.lstat(target, { bigint: true });
475
+ if (spec.prior && sameIdentity(identity(targetStat), spec.prior.identity)) {
476
+ if (!sameIdentity(await inspectBundle(target, spec.prior), spec.prior.identity)) fail("prior skill changed during recovery");
477
+ return;
478
+ }
479
+ if (!spec.operationId) fail("invalid discard operation");
480
+ if (!spec.reservation) {
481
+ await removePreByteReservation(target, spec.operationId);
482
+ return;
483
+ }
484
+ await moveAndRemoveOwnedReservation(target, tombstone, spec.operationId, spec.reservation);
485
+ await checkedWorkspace(spec.cwd, spec.workspaceIdentity);
486
+ }
487
+ async function restore(spec) {
488
+ if (!SAFE_OPERATION.test(spec.operationId) || !SAFE_QUARANTINE.test(spec.quarantineName)) fail("invalid restore");
489
+ const target = await safeTarget(spec.cwd, spec.relativeRoot, false, spec.workspaceIdentity);
490
+ const quarantine = join(dirname(target), spec.quarantineName);
491
+ try {
492
+ const live = await inspectBundle(target, spec.prior);
493
+ if (sameIdentity(live, spec.prior.identity)) return live;
494
+ fail("restore target was replaced");
495
+ } catch (error) {
496
+ if (error.code !== "ENOENT") throw error;
497
+ }
498
+ if (!sameIdentity(await inspectBundle(quarantine, spec.prior), spec.prior.identity)) fail("restore source was replaced");
499
+ try {
500
+ await promises.lstat(target);
501
+ fail("refusing to overwrite content planted during recovery");
502
+ } catch (error) {
503
+ if (error.code !== "ENOENT") throw error;
504
+ }
505
+ await promises.rename(quarantine, target);
506
+ await syncParent(target);
507
+ const restored = await inspectBundle(target, spec.prior);
508
+ if (!sameIdentity(restored, spec.prior.identity)) fail("restored skill identity changed");
509
+ await checkedWorkspace(spec.cwd, spec.workspaceIdentity);
510
+ return restored;
511
+ }
512
+ async function finalize(spec) {
513
+ if (!SAFE_OPERATION.test(spec.operationId)) fail("invalid finalize operation");
514
+ validateIdentity(spec.markerIdentity);
515
+ const target = await safeTarget(spec.cwd, spec.relativeRoot, false, spec.workspaceIdentity);
516
+ if (!sameIdentity(await inspectBundle(target, spec.expected, spec.operationId, spec.markerIdentity), spec.expected.identity)) fail("finalize target was replaced");
517
+ const marker = join(target, operationMarkerName(spec.operationId));
518
+ if (await markerMatches(target, spec.operationId, spec.markerIdentity)) await promises.rmdir(marker);
519
+ const finalized = await inspectBundle(target, spec.expected);
520
+ if (!sameIdentity(finalized, spec.expected.identity)) fail("finalized skill identity changed");
521
+ await syncDirectoryTree(target, spec.expected);
522
+ await syncParent(target);
523
+ await checkedWorkspace(spec.cwd, spec.workspaceIdentity);
524
+ return finalized;
525
+ }
526
+ async function main() {
527
+ const specPath = process.argv[2];
528
+ if (!specPath || !isAbsolute(specPath)) fail("expected an absolute mutation spec path");
529
+ const stat = await promises.lstat(specPath);
530
+ if (!stat.isFile() || stat.isSymbolicLink() || stat.size > 2 * 1024 * 1024) fail("invalid mutation spec");
531
+ const spec = JSON.parse(await promises.readFile(specPath, "utf8"));
532
+ let result;
533
+ if (spec.action === "reserve") result = await reserve(spec);
534
+ else if (spec.action === "apply") result = await apply(spec);
535
+ else if (spec.action === "cleanup") result = await cleanup(spec);
536
+ else if (spec.action === "discard") result = await discard(spec);
537
+ else if (spec.action === "restore") result = await restore(spec);
538
+ else if (spec.action === "finalize") result = await finalize(spec);
539
+ else fail("unknown mutation action");
540
+ process.stdout.write(`${JSON.stringify(result ?? {})}\n`);
541
+ }
542
+ main().catch((error) => {
543
+ process.stderr.write(`agentconnect skill mutation: ${error instanceof Error ? error.message : String(error)}\n`);
544
+ process.exitCode = 1;
545
+ });
546
+ //#endregion
547
+ export {};
548
+
549
+ //# sourceMappingURL=workspace-mutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-mutation.js","names":["fsp"],"sources":["../../../src/skills/skill-workspace-mutation-cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { createHash } from 'node:crypto'\nimport { constants, promises as fsp, type BigIntStats } from 'node:fs'\nimport { dirname, isAbsolute, join, relative, sep } from 'node:path'\n\ninterface PathIdentity {\n dev: string\n ino: string\n}\n\ninterface FileReceipt {\n path: string\n mode: number\n size: number\n sha256: string\n}\n\ninterface BundleReceipt {\n treeDigest: string\n files: FileReceipt[]\n}\n\ninterface ReservationAuthority {\n identity: PathIdentity\n markerIdentity: PathIdentity\n}\n\ninterface ReserveSpec {\n action: 'reserve'\n cwd: string\n workspaceIdentity: PathIdentity\n relativeRoot: string\n operationId: string\n reservationName: string\n quarantineName: string\n prior?: BundleReceipt & { identity: PathIdentity }\n}\n\ninterface ApplySpec {\n action: 'apply'\n cwd: string\n workspaceIdentity: PathIdentity\n relativeRoot: string\n operationId: string\n reservationName: string\n quarantineName: string\n reservation?: ReservationAuthority\n prior?: BundleReceipt & { identity: PathIdentity }\n candidate?: BundleReceipt & { sourceDir: string }\n}\n\ninterface CleanupSpec {\n action: 'cleanup'\n cwd: string\n workspaceIdentity: PathIdentity\n relativeRoot: string\n name: string\n tombstoneName: string\n expected: BundleReceipt & { identity: PathIdentity }\n}\n\ninterface DiscardSpec {\n action: 'discard'\n cwd: string\n workspaceIdentity: PathIdentity\n relativeRoot: string\n tombstoneName: string\n operationId?: string\n reservationName?: string\n reservation?: ReservationAuthority\n prior?: BundleReceipt & { identity: PathIdentity }\n}\n\ninterface RestoreSpec {\n action: 'restore'\n cwd: string\n workspaceIdentity: PathIdentity\n relativeRoot: string\n operationId: string\n quarantineName: string\n prior: BundleReceipt & { identity: PathIdentity }\n}\n\ninterface FinalizeSpec {\n action: 'finalize'\n cwd: string\n workspaceIdentity: PathIdentity\n relativeRoot: string\n operationId: string\n markerIdentity: PathIdentity\n expected: BundleReceipt & { identity: PathIdentity }\n}\n\ntype MutationSpec = ReserveSpec | ApplySpec | CleanupSpec | DiscardSpec | RestoreSpec | FinalizeSpec\n\nconst SAFE_SEGMENT = /^\\.?[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9_-])?$/\nconst SAFE_BUNDLE = /^[A-Za-z0-9](?:[A-Za-z0-9._-]{0,126}[A-Za-z0-9_-])?$/\nconst RESERVED_FIRST = new Set(['.git', '.agentconnect'])\nconst SAFE_OPERATION = /^[a-f0-9-]{36}$/\nconst SAFE_QUARANTINE = /^\\.agentconnect-skill-(?:new|old|trash)-[a-f0-9-]{36}$/\nconst CONTROL_RE = /[\\u0000-\\u001f\\u007f-\\u009f]/\nconst READ_FLAGS = constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK\nconst WRITE_FLAGS = constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | constants.O_NOFOLLOW\n\nfunction fail(message: string): never {\n throw new Error(message)\n}\n\nfunction identity(stat: BigIntStats): PathIdentity {\n return { dev: stat.dev.toString(), ino: stat.ino.toString() }\n}\n\nfunction sameIdentity(left: PathIdentity, right: PathIdentity): boolean {\n return left.dev === right.dev && left.ino === right.ino\n}\n\nfunction validateIdentity(value: PathIdentity | undefined): asserts value is PathIdentity {\n if (!value || !/^\\d+$/.test(value.dev) || !/^\\d+$/.test(value.ino)) fail('invalid filesystem identity')\n}\n\nfunction validateReservation(value: ReservationAuthority | undefined): asserts value is ReservationAuthority {\n if (!value) fail('missing skill mutation reservation authority')\n validateIdentity(value.identity)\n validateIdentity(value.markerIdentity)\n}\n\nfunction validateRelativeRoot(value: string): string[] {\n if (isAbsolute(value) || value.includes('\\\\') || value.includes('\\0') || Buffer.byteLength(value, 'utf8') > 1_024) {\n fail('unsafe skill mutation path')\n }\n const parts = value.split('/')\n if (parts.length < 2 || parts.length > 8 || parts.at(-2) !== 'skills' || !SAFE_BUNDLE.test(parts.at(-1)!)) {\n fail('unsafe skill mutation path')\n }\n for (const part of parts.slice(0, -1)) {\n if (part.length > 128 || !SAFE_SEGMENT.test(part)) fail('unsafe skill mutation path')\n }\n if (RESERVED_FIRST.has(parts[0]!.toLowerCase())) fail('reserved skill mutation path')\n return parts\n}\n\nfunction validateReceipt(receipt: BundleReceipt): void {\n if (!/^[a-f0-9]{64}$/.test(receipt.treeDigest) || !Array.isArray(receipt.files) || receipt.files.length === 0) {\n fail('invalid skill mutation receipt')\n }\n let total = 0\n const seen = new Set<string>()\n for (const file of receipt.files) {\n const parts = file.path.split('/')\n if (\n !file.path ||\n isAbsolute(file.path) ||\n file.path.includes('\\\\') ||\n file.path.includes('\\0') ||\n CONTROL_RE.test(file.path) ||\n parts.some((part) => !part || part === '.' || part === '..') ||\n parts.length > 32 ||\n (file.mode !== 0o600 && file.mode !== 0o700) ||\n !Number.isSafeInteger(file.size) ||\n file.size < 0 ||\n file.size > 512 * 1024 ||\n !/^[a-f0-9]{64}$/.test(file.sha256) ||\n seen.has(file.path)\n ) {\n fail('invalid skill mutation receipt')\n }\n total += file.size\n if (total > 4 * 1024 * 1024) fail('invalid skill mutation receipt')\n seen.add(file.path)\n }\n if (!seen.has('SKILL.md') || digest(receipt.files) !== receipt.treeDigest) fail('invalid skill mutation receipt')\n}\n\nfunction digest(files: FileReceipt[]): string {\n return createHash('sha256').update(JSON.stringify(files)).digest('hex')\n}\n\nfunction under(root: string, path: string): boolean {\n const rel = relative(root, path)\n return rel === '' || (rel !== '..' && !rel.startsWith(`..${sep}`) && !isAbsolute(rel))\n}\n\nasync function checkedWorkspace(cwdInput: string, expected: PathIdentity): Promise<string> {\n const lexical = await fsp.lstat(cwdInput, { bigint: true })\n if (!lexical.isDirectory() || lexical.isSymbolicLink() || !sameIdentity(identity(lexical), expected)) {\n fail('skill mutation workspace identity changed')\n }\n const cwd = await fsp.realpath(cwdInput)\n const canonical = await fsp.lstat(cwd, { bigint: true })\n if (!canonical.isDirectory() || canonical.isSymbolicLink() || !sameIdentity(identity(canonical), expected)) {\n fail('skill mutation workspace identity changed')\n }\n return cwd\n}\n\nasync function safeTarget(\n cwdInput: string,\n relativeRoot: string,\n createParents: boolean,\n workspaceIdentity: PathIdentity\n): Promise<string> {\n const parts = validateRelativeRoot(relativeRoot)\n const cwd = await checkedWorkspace(cwdInput, workspaceIdentity)\n let parent = cwd\n for (const part of parts.slice(0, -1)) {\n const next = join(parent, part)\n if (createParents) {\n let created = false\n try {\n await fsp.mkdir(next)\n created = true\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error\n }\n if (created) {\n await syncDirectory(next)\n await syncDirectory(parent)\n }\n } else {\n try {\n await fsp.lstat(next)\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') fail('skill mutation parent is missing')\n throw error\n }\n }\n const stat = await fsp.lstat(next)\n if (!stat.isDirectory() || stat.isSymbolicLink()) fail('skill mutation parent is unsafe')\n parent = await fsp.realpath(next)\n if (!under(cwd, parent)) fail('skill mutation parent escapes workspace')\n }\n return join(parent, parts.at(-1)!)\n}\n\n/** Resolve a target without creating parents. A missing ancestor proves the\n * target and every journaled sibling artifact are absent; existing ancestors\n * still receive the full no-link containment checks. */\nasync function safeTargetWhenParentExists(\n cwdInput: string,\n relativeRoot: string,\n workspaceIdentity: PathIdentity\n): Promise<string | undefined> {\n const parts = validateRelativeRoot(relativeRoot)\n const cwd = await checkedWorkspace(cwdInput, workspaceIdentity)\n let parent = cwd\n for (const part of parts.slice(0, -1)) {\n const next = join(parent, part)\n let stat\n try {\n stat = await fsp.lstat(next)\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return undefined\n throw error\n }\n if (!stat.isDirectory() || stat.isSymbolicLink()) fail('skill mutation parent is unsafe')\n parent = await fsp.realpath(next)\n if (!under(cwd, parent)) fail('skill mutation parent escapes workspace')\n }\n return join(parent, parts.at(-1)!)\n}\n\nasync function boundedRead(path: string, expected: FileReceipt): Promise<Buffer> {\n const before = await fsp.lstat(path, { bigint: true })\n if (!before.isFile() || before.isSymbolicLink() || before.nlink !== 1n || before.size !== BigInt(expected.size)) {\n fail('skill mutation source changed')\n }\n const handle = await fsp.open(path, READ_FLAGS)\n try {\n const opened = await handle.stat({ bigint: true })\n if (\n !opened.isFile() ||\n !sameIdentity(identity(before), identity(opened)) ||\n opened.size !== BigInt(expected.size)\n ) {\n fail('skill mutation source changed')\n }\n const body = Buffer.alloc(expected.size)\n let offset = 0\n while (offset < body.length) {\n const { bytesRead } = await handle.read(body, offset, body.length - offset, offset)\n if (bytesRead === 0) fail('skill mutation source changed')\n offset += bytesRead\n }\n const probe = Buffer.alloc(1)\n if ((await handle.read(probe, 0, 1, offset)).bytesRead !== 0) fail('skill mutation source changed')\n if (createHash('sha256').update(body).digest('hex') !== expected.sha256) fail('skill mutation source changed')\n return body\n } finally {\n await handle.close()\n }\n}\n\nasync function inspectBundle(\n root: string,\n expected: BundleReceipt,\n operationId?: string,\n markerIdentity?: PathIdentity\n): Promise<PathIdentity> {\n validateReceipt(expected)\n const rootStat = await fsp.lstat(root, { bigint: true })\n if (!rootStat.isDirectory() || rootStat.isSymbolicLink()) fail('skill mutation bundle root is unsafe')\n const files = new Map(expected.files.map((file) => [file.path, file]))\n const directories = new Set<string>()\n for (const file of expected.files) {\n const parts = file.path.split('/')\n for (let index = 1; index < parts.length; index += 1) directories.add(parts.slice(0, index).join('/'))\n }\n const seen = new Set<string>()\n let entries = 0\n const walk = async (dir: string, prefix = ''): Promise<void> => {\n for (const entry of await fsp.readdir(dir, { withFileTypes: true })) {\n entries += 1\n if (entries > 1_024) fail('skill mutation bundle has too many entries')\n const rel = prefix ? `${prefix}/${entry.name}` : entry.name\n const abs = join(dir, entry.name)\n const stat = await fsp.lstat(abs)\n if (entry.isSymbolicLink() || stat.isSymbolicLink()) fail('skill mutation bundle contains a link')\n if (\n prefix === '' &&\n operationId &&\n rel === `.agentconnect-installing-${operationId}` &&\n (await markerMatches(root, operationId, markerIdentity))\n ) {\n continue\n }\n if (entry.isDirectory() && stat.isDirectory()) {\n if (!directories.has(rel)) fail('skill mutation bundle contains an unexpected directory')\n await walk(abs, rel)\n continue\n }\n const receipt = files.get(rel)\n if (!receipt || !entry.isFile() || !stat.isFile()) fail('skill mutation bundle contains an unexpected entry')\n const body = await boundedRead(abs, receipt)\n const mode = stat.mode & 0o111 ? 0o700 : 0o600\n if (mode !== receipt.mode || body.length !== receipt.size) fail('skill mutation bundle does not match receipt')\n seen.add(rel)\n }\n }\n await walk(root)\n if (seen.size !== files.size) fail('skill mutation bundle is incomplete')\n const rootAfter = await fsp.lstat(root, { bigint: true })\n if (!sameIdentity(identity(rootStat), identity(rootAfter))) fail('skill mutation bundle changed during inspection')\n return identity(rootAfter)\n}\n\nasync function ensureDirectoryPath(root: string, path: string): Promise<void> {\n let current = root\n for (const part of path.split('/').slice(0, -1)) {\n current = join(current, part)\n try {\n await fsp.mkdir(current, { mode: 0o700 })\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error\n }\n const stat = await fsp.lstat(current)\n if (!stat.isDirectory() || stat.isSymbolicLink()) fail('skill mutation destination parent is unsafe')\n }\n}\n\nfunction operationMarkerName(operationId: string): string {\n return `.agentconnect-installing-${operationId}`\n}\n\nasync function reserve(spec: ReserveSpec): Promise<ReservationAuthority> {\n if (\n !SAFE_OPERATION.test(spec.operationId) ||\n !SAFE_QUARANTINE.test(spec.reservationName) ||\n !SAFE_QUARANTINE.test(spec.quarantineName)\n ) {\n fail('invalid reservation operation')\n }\n if (spec.prior) validateReceipt(spec.prior)\n const target = await safeTarget(spec.cwd, spec.relativeRoot, true, spec.workspaceIdentity)\n const quarantine = join(dirname(target), spec.quarantineName)\n try {\n const current = await fsp.lstat(target, { bigint: true })\n if (!spec.prior || !sameIdentity(identity(current), spec.prior.identity)) fail('refusing to replace unowned skill')\n await inspectBundle(target, spec.prior)\n await fsp.rename(target, quarantine)\n await syncParent(quarantine)\n const quarantined = await inspectBundle(quarantine, spec.prior)\n if (!sameIdentity(quarantined, spec.prior.identity)) fail('skill changed while quarantining')\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error\n if (spec.prior) fail('owned skill disappeared during reservation')\n }\n\n // mkdir is the atomic no-clobber publication claim. Candidate bytes are\n // populated only after this root + marker identity are fsynced into the\n // external journal, so a concurrent workspace writer can make us fail but\n // can never have its destination replaced by rename().\n await fsp.mkdir(target, { mode: 0o700 })\n const reservationIdentity = identity(await fsp.lstat(target, { bigint: true }))\n const marker = join(target, operationMarkerName(spec.operationId))\n await fsp.mkdir(marker, { mode: 0o700 })\n const markerIdentity = identity(await fsp.lstat(marker, { bigint: true }))\n await syncDirectory(marker)\n await syncDirectory(target)\n await syncParent(target)\n\n const reservationAfter = identity(await fsp.lstat(target, { bigint: true }))\n if (\n !sameIdentity(reservationIdentity, reservationAfter) ||\n !(await markerMatches(target, spec.operationId, markerIdentity))\n ) {\n fail('skill mutation reservation changed while reserving')\n }\n await checkedWorkspace(spec.cwd, spec.workspaceIdentity)\n return { identity: reservationAfter, markerIdentity }\n}\n\nasync function populateReservation(\n source: string,\n target: string,\n receipt: BundleReceipt,\n operationId: string,\n authority: ReservationAuthority\n): Promise<PathIdentity> {\n validateReceipt(receipt)\n validateReservation(authority)\n await inspectBundle(source, receipt)\n const rootIdentity = identity(await fsp.lstat(target, { bigint: true }))\n if (\n !sameIdentity(rootIdentity, authority.identity) ||\n !(await markerMatches(target, operationId, authority.markerIdentity))\n ) {\n fail('skill mutation reservation authority changed')\n }\n // The in-place mkdir claim is no-clobber but not an atomic directory swap.\n // Keep the runtime's discovery manifest absent until every support file is\n // durable, so a concurrent warm reader sees either no skill or a complete one.\n const publicationOrder = [\n ...receipt.files.filter((file) => file.path !== 'SKILL.md'),\n ...receipt.files.filter((file) => file.path === 'SKILL.md')\n ]\n for (const file of publicationOrder) {\n if (file.path === 'SKILL.md') {\n await syncDirectoryTree(target, {\n ...receipt,\n files: publicationOrder.filter((candidate) => candidate.path !== 'SKILL.md')\n })\n }\n await ensureDirectoryPath(target, file.path)\n const body = await boundedRead(join(source, ...file.path.split('/')), file)\n const output = await fsp.open(join(target, ...file.path.split('/')), WRITE_FLAGS, file.mode)\n try {\n await output.writeFile(body)\n await output.chmod(file.mode)\n await output.sync()\n } finally {\n await output.close()\n }\n }\n const publishedIdentity = await inspectBundle(target, receipt, operationId, authority.markerIdentity)\n if (!sameIdentity(rootIdentity, publishedIdentity)) fail('skill mutation destination was replaced')\n await syncDirectoryTree(target, receipt)\n // The caller may durably commit a ready ledger immediately after this helper\n // returns, so the containing directory entry must reach disk first.\n await syncParent(target)\n return publishedIdentity\n}\n\nasync function syncDirectoryTree(root: string, receipt: BundleReceipt): Promise<void> {\n if (process.platform === 'win32') return\n const dirs = new Set<string>([root])\n for (const file of receipt.files) {\n let current = dirname(join(root, ...file.path.split('/')))\n while (under(root, current)) {\n dirs.add(current)\n if (current === root) break\n current = dirname(current)\n }\n }\n for (const dir of [...dirs].sort((a, b) => b.length - a.length)) {\n const handle = await fsp.open(dir, constants.O_RDONLY)\n try {\n await handle.sync()\n } finally {\n await handle.close()\n }\n }\n}\n\nasync function syncDirectory(path: string): Promise<void> {\n if (process.platform === 'win32') return\n const handle = await fsp.open(path, constants.O_RDONLY)\n try {\n await handle.sync()\n } finally {\n await handle.close()\n }\n}\n\nasync function syncParent(path: string): Promise<void> {\n if (process.platform === 'win32') return\n const handle = await fsp.open(dirname(path), constants.O_RDONLY)\n try {\n await handle.sync()\n } finally {\n await handle.close()\n }\n}\n\nasync function markerMatches(root: string, operationId: string, expected?: PathIdentity): Promise<boolean> {\n try {\n const marker = join(root, operationMarkerName(operationId))\n const before = await fsp.lstat(marker, { bigint: true })\n if (!before.isDirectory() || before.isSymbolicLink()) return false\n const directory = await fsp.opendir(marker)\n try {\n if ((await directory.read()) !== null) return false\n } finally {\n await directory.close()\n }\n const after = await fsp.lstat(marker, { bigint: true })\n const found = identity(after)\n return (\n after.isDirectory() &&\n !after.isSymbolicLink() &&\n sameIdentity(identity(before), found) &&\n (!expected || sameIdentity(found, expected))\n )\n } catch {\n return false\n }\n}\n\nasync function apply(spec: ApplySpec): Promise<Record<string, PathIdentity | undefined>> {\n if (\n !SAFE_OPERATION.test(spec.operationId) ||\n !SAFE_QUARANTINE.test(spec.reservationName) ||\n !SAFE_QUARANTINE.test(spec.quarantineName)\n ) {\n fail('invalid operation')\n }\n if (spec.prior) validateReceipt(spec.prior)\n if (spec.candidate) {\n validateReceipt(spec.candidate)\n validateReservation(spec.reservation)\n if (spec.prior) fail('candidate prior must be quarantined during reservation')\n } else if (spec.reservation) {\n fail('unexpected reservation authority')\n }\n const target = await safeTarget(spec.cwd, spec.relativeRoot, true, spec.workspaceIdentity)\n const quarantine = join(dirname(target), spec.quarantineName)\n let quarantineIdentity: PathIdentity | undefined\n if (!spec.candidate) {\n try {\n const current = await fsp.lstat(target, { bigint: true })\n if (!spec.prior || !sameIdentity(identity(current), spec.prior.identity))\n fail('refusing to replace unowned skill')\n await inspectBundle(target, spec.prior)\n await fsp.rename(target, quarantine)\n await syncParent(quarantine)\n quarantineIdentity = await inspectBundle(quarantine, spec.prior)\n if (!sameIdentity(quarantineIdentity, spec.prior.identity)) fail('skill changed while quarantining')\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error\n if (spec.prior) fail('owned skill disappeared during mutation')\n }\n }\n let targetIdentity: PathIdentity | undefined\n if (spec.candidate) {\n const reservationIdentity = await populateReservation(\n spec.candidate.sourceDir,\n target,\n spec.candidate,\n spec.operationId,\n spec.reservation!\n )\n targetIdentity = await inspectBundle(target, spec.candidate, spec.operationId, spec.reservation!.markerIdentity)\n if (!sameIdentity(reservationIdentity, targetIdentity)) fail('skill mutation destination changed while publishing')\n }\n await checkedWorkspace(spec.cwd, spec.workspaceIdentity)\n return { quarantineIdentity, targetIdentity }\n}\n\nasync function pathExists(path: string): Promise<boolean> {\n try {\n await fsp.lstat(path)\n return true\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return false\n throw error\n }\n}\n\nasync function removeExpectedArtifact(\n path: string,\n expected: BundleReceipt & { identity: PathIdentity },\n requireComplete: boolean\n): Promise<void> {\n const stat = await fsp.lstat(path, { bigint: true })\n if (!stat.isDirectory() || stat.isSymbolicLink() || !sameIdentity(identity(stat), expected.identity)) {\n fail('cleanup target was replaced')\n }\n if (requireComplete) {\n const found = await inspectBundle(path, expected)\n if (!sameIdentity(found, expected.identity)) fail('cleanup target was replaced')\n }\n await fsp.rm(path, { recursive: true, force: false })\n await syncParent(path)\n}\n\n/** Before reservation identities are durably journaled, correct code cannot\n * have written a candidate byte. Recovery may therefore remove only the two\n * content-free crash shapes (empty root, or root + empty marker). Anything\n * else could be user/attacker content and fails closed. */\nasync function removePreByteReservation(path: string, operationId: string): Promise<void> {\n const stat = await fsp.lstat(path, { bigint: true })\n if (!stat.isDirectory() || stat.isSymbolicLink()) fail('discard reservation is unsafe')\n const entries = await fsp.readdir(path)\n if (entries.length === 0) {\n const after = await fsp.lstat(path, { bigint: true })\n if (!sameIdentity(identity(stat), identity(after))) fail('discard reservation changed')\n await fsp.rmdir(path)\n await syncParent(path)\n return\n }\n if (entries.length !== 1 || entries[0] !== operationMarkerName(operationId)) {\n fail('refusing to discard an unowned reservation')\n }\n if (!(await markerMatches(path, operationId))) fail('discard reservation marker is unsafe')\n const after = await fsp.lstat(path, { bigint: true })\n if (!sameIdentity(identity(stat), identity(after))) fail('discard reservation changed')\n await fsp.rmdir(join(path, operationMarkerName(operationId)))\n await fsp.rmdir(path)\n await syncParent(path)\n}\n\n/** Remove a reservation whose root and marker identities were persisted before\n * any candidate byte was permitted. The marker stays until all other entries\n * are gone, so an interrupted deletion remains resumable under the same inode\n * authority. */\nasync function removeOwnedReservation(\n path: string,\n operationId: string,\n authority: ReservationAuthority\n): Promise<void> {\n validateReservation(authority)\n const stat = await fsp.lstat(path, { bigint: true })\n if (!stat.isDirectory() || stat.isSymbolicLink() || !sameIdentity(identity(stat), authority.identity)) {\n fail('discard reservation identity changed')\n }\n const markerName = operationMarkerName(operationId)\n if (!(await markerMatches(path, operationId, authority.markerIdentity))) {\n const entries = await fsp.readdir(path)\n if (entries.length === 0) {\n const after = await fsp.lstat(path, { bigint: true })\n if (!sameIdentity(identity(after), authority.identity)) fail('discard reservation identity changed')\n await fsp.rmdir(path)\n await syncParent(path)\n return\n }\n fail('discard reservation marker changed')\n }\n\n let entries = 0\n const directory = await fsp.opendir(path)\n for await (const entry of directory) {\n entries += 1\n if (entries > 4_096) fail('discard reservation has too many entries')\n if (entry.name === markerName) continue\n const current = await fsp.lstat(path, { bigint: true })\n if (!sameIdentity(identity(current), authority.identity)) fail('discard reservation identity changed')\n await fsp.rm(join(path, entry.name), { recursive: true, force: false })\n }\n await syncDirectory(path)\n const after = await fsp.lstat(path, { bigint: true })\n if (\n !sameIdentity(identity(after), authority.identity) ||\n !(await markerMatches(path, operationId, authority.markerIdentity))\n ) {\n fail('discard reservation authority changed')\n }\n await fsp.rmdir(join(path, markerName))\n const empty = await fsp.readdir(path)\n const finalStat = await fsp.lstat(path, { bigint: true })\n if (empty.length !== 0 || !sameIdentity(identity(finalStat), authority.identity)) {\n fail('discard reservation changed before removal')\n }\n await fsp.rmdir(path)\n await syncParent(path)\n}\n\nasync function moveAndRemoveOwnedReservation(\n path: string,\n tombstone: string,\n operationId: string,\n authority: ReservationAuthority\n): Promise<void> {\n const stat = await fsp.lstat(path, { bigint: true })\n if (\n !stat.isDirectory() ||\n stat.isSymbolicLink() ||\n !sameIdentity(identity(stat), authority.identity) ||\n !(await markerMatches(path, operationId, authority.markerIdentity))\n ) {\n fail('discard reservation authority changed')\n }\n if (await pathExists(tombstone)) fail('discard tombstone already exists')\n await fsp.rename(path, tombstone)\n await syncParent(tombstone)\n const moved = await fsp.lstat(tombstone, { bigint: true })\n if (!sameIdentity(identity(moved), authority.identity)) fail('discard reservation changed while moving')\n await removeOwnedReservation(tombstone, operationId, authority)\n}\n\nasync function cleanup(spec: CleanupSpec): Promise<void> {\n if (!SAFE_QUARANTINE.test(spec.name) || !SAFE_QUARANTINE.test(spec.tombstoneName)) fail('invalid cleanup name')\n const target = await safeTargetWhenParentExists(spec.cwd, spec.relativeRoot, spec.workspaceIdentity)\n if (!target) return\n const quarantine = join(dirname(target), spec.name)\n const tombstone = join(dirname(target), spec.tombstoneName)\n const quarantineExists = await pathExists(quarantine)\n const tombstoneExists = await pathExists(tombstone)\n if (quarantineExists && tombstoneExists) fail('cleanup artifacts conflict')\n if (quarantineExists) {\n const found = await inspectBundle(quarantine, spec.expected)\n if (!sameIdentity(found, spec.expected.identity)) fail('cleanup target was replaced')\n await fsp.rename(quarantine, tombstone)\n await syncParent(tombstone)\n await removeExpectedArtifact(tombstone, spec.expected, true)\n } else if (tombstoneExists) {\n // A prior cleanup may have crashed during recursive removal. The root inode\n // remains the durable authority even when its receipt is now incomplete.\n await removeExpectedArtifact(tombstone, spec.expected, false)\n }\n await checkedWorkspace(spec.cwd, spec.workspaceIdentity)\n}\n\nasync function discard(spec: DiscardSpec): Promise<void> {\n if (\n !SAFE_QUARANTINE.test(spec.tombstoneName) ||\n (spec.reservationName !== undefined && !SAFE_QUARANTINE.test(spec.reservationName))\n ) {\n fail('invalid discard name')\n }\n if (spec.operationId && !SAFE_OPERATION.test(spec.operationId)) fail('invalid discard operation')\n if (spec.reservation) validateReservation(spec.reservation)\n if (spec.prior) validateReceipt(spec.prior)\n const target = await safeTargetWhenParentExists(spec.cwd, spec.relativeRoot, spec.workspaceIdentity)\n if (!target) return\n const tombstone = join(dirname(target), spec.tombstoneName)\n\n if (await pathExists(tombstone)) {\n if (!spec.operationId || !spec.reservation) fail('refusing to discard an unknown tombstone')\n await removeOwnedReservation(tombstone, spec.operationId, spec.reservation)\n }\n if (!(await pathExists(target))) return\n const targetStat = await fsp.lstat(target, { bigint: true })\n if (spec.prior && sameIdentity(identity(targetStat), spec.prior.identity)) {\n const found = await inspectBundle(target, spec.prior)\n if (!sameIdentity(found, spec.prior.identity)) fail('prior skill changed during recovery')\n return\n }\n if (!spec.operationId) fail('invalid discard operation')\n if (!spec.reservation) {\n await removePreByteReservation(target, spec.operationId)\n return\n }\n await moveAndRemoveOwnedReservation(target, tombstone, spec.operationId, spec.reservation)\n await checkedWorkspace(spec.cwd, spec.workspaceIdentity)\n}\n\nasync function restore(spec: RestoreSpec): Promise<PathIdentity> {\n if (!SAFE_OPERATION.test(spec.operationId) || !SAFE_QUARANTINE.test(spec.quarantineName)) fail('invalid restore')\n const target = await safeTarget(spec.cwd, spec.relativeRoot, false, spec.workspaceIdentity)\n const quarantine = join(dirname(target), spec.quarantineName)\n try {\n const live = await inspectBundle(target, spec.prior)\n if (sameIdentity(live, spec.prior.identity)) return live\n fail('restore target was replaced')\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error\n }\n const found = await inspectBundle(quarantine, spec.prior)\n if (!sameIdentity(found, spec.prior.identity)) fail('restore source was replaced')\n try {\n await fsp.lstat(target)\n fail('refusing to overwrite content planted during recovery')\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error\n }\n await fsp.rename(quarantine, target)\n await syncParent(target)\n const restored = await inspectBundle(target, spec.prior)\n if (!sameIdentity(restored, spec.prior.identity)) fail('restored skill identity changed')\n await checkedWorkspace(spec.cwd, spec.workspaceIdentity)\n return restored\n}\n\nasync function finalize(spec: FinalizeSpec): Promise<PathIdentity> {\n if (!SAFE_OPERATION.test(spec.operationId)) fail('invalid finalize operation')\n validateIdentity(spec.markerIdentity)\n const target = await safeTarget(spec.cwd, spec.relativeRoot, false, spec.workspaceIdentity)\n const found = await inspectBundle(target, spec.expected, spec.operationId, spec.markerIdentity)\n if (!sameIdentity(found, spec.expected.identity)) fail('finalize target was replaced')\n const marker = join(target, operationMarkerName(spec.operationId))\n if (await markerMatches(target, spec.operationId, spec.markerIdentity)) {\n await fsp.rmdir(marker)\n }\n const finalized = await inspectBundle(target, spec.expected)\n if (!sameIdentity(finalized, spec.expected.identity)) fail('finalized skill identity changed')\n await syncDirectoryTree(target, spec.expected)\n await syncParent(target)\n await checkedWorkspace(spec.cwd, spec.workspaceIdentity)\n return finalized\n}\n\nasync function main(): Promise<void> {\n const specPath = process.argv[2]\n if (!specPath || !isAbsolute(specPath)) fail('expected an absolute mutation spec path')\n const stat = await fsp.lstat(specPath)\n if (!stat.isFile() || stat.isSymbolicLink() || stat.size > 2 * 1024 * 1024) fail('invalid mutation spec')\n const spec = JSON.parse(await fsp.readFile(specPath, 'utf8')) as MutationSpec\n let result: unknown\n if (spec.action === 'reserve') result = await reserve(spec)\n else if (spec.action === 'apply') result = await apply(spec)\n else if (spec.action === 'cleanup') result = await cleanup(spec)\n else if (spec.action === 'discard') result = await discard(spec)\n else if (spec.action === 'restore') result = await restore(spec)\n else if (spec.action === 'finalize') result = await finalize(spec)\n else fail('unknown mutation action')\n process.stdout.write(`${JSON.stringify(result ?? {})}\\n`)\n}\n\nmain().catch((error) => {\n process.stderr.write(`agentconnect skill mutation: ${error instanceof Error ? error.message : String(error)}\\n`)\n process.exitCode = 1\n})\n"],"mappings":";;;;;AA+FA,MAAM,eAAe;AACrB,MAAM,cAAc;AACpB,MAAM,iCAAiB,IAAI,IAAI,CAAC,QAAQ,eAAe,CAAC;AACxD,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;AACxB,MAAM,aAAa;AACnB,MAAM,aAAa,UAAU,WAAW,UAAU,aAAa,UAAU;AACzE,MAAM,cAAc,UAAU,WAAW,UAAU,UAAU,UAAU,SAAS,UAAU;AAE1F,SAAS,KAAK,SAAwB;CACpC,MAAM,IAAI,MAAM,OAAO;AACzB;AAEA,SAAS,SAAS,MAAiC;CACjD,OAAO;EAAE,KAAK,KAAK,IAAI,SAAS;EAAG,KAAK,KAAK,IAAI,SAAS;CAAE;AAC9D;AAEA,SAAS,aAAa,MAAoB,OAA8B;CACtE,OAAO,KAAK,QAAQ,MAAM,OAAO,KAAK,QAAQ,MAAM;AACtD;AAEA,SAAS,iBAAiB,OAAgE;CACxF,IAAI,CAAC,SAAS,CAAC,QAAQ,KAAK,MAAM,GAAG,KAAK,CAAC,QAAQ,KAAK,MAAM,GAAG,GAAG,KAAK,6BAA6B;AACxG;AAEA,SAAS,oBAAoB,OAAgF;CAC3G,IAAI,CAAC,OAAO,KAAK,8CAA8C;CAC/D,iBAAiB,MAAM,QAAQ;CAC/B,iBAAiB,MAAM,cAAc;AACvC;AAEA,SAAS,qBAAqB,OAAyB;CACrD,IA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C7C,MAAM,WAAW,MAAM;CACvB,MAAM,iBAAiB,KAAK,KAAK,KAAK,iBAAiB;CACvD,OAAO;AACT;AAEA,eAAe,OAAsB;CACnC,MAAM,WAAW,QAAQ,KAAK;CAC9B,IAAI,CAAC,YAAY,CAAC,WAAW,QAAQ,GAAG,KAAK,yCAAyC;CACtF,MAAM,OAAO,MAAMA,SAAI,MAAM,QAAQ;CACrC,IAAI,CAAC,KAAK,OAAO,KAAK,KAAK,eAAe,KAAK,KAAK,OAAO,IAAI,OAAO,MAAM,KAAK,uBAAuB;CACxG,MAAM,OAAO,KAAK,MAAM,MAAMA,SAAI,SAAS,UAAU,MAAM,CAAC;CAC5D,IAAI;CACJ,IAAI,KAAK,WAAW,WAAW,SAAS,MAAM,QAAQ,IAAI;MACrD,IAAI,KAAK,WAAW,SAAS,SAAS,MAAM,MAAM,IAAI;MACtD,IAAI,KAAK,WAAW,WAAW,SAAS,MAAM,QAAQ,IAAI;MAC1D,IAAI,KAAK,WAAW,WAAW,SAAS,MAAM,QAAQ,IAAI;MAC1D,IAAI,KAAK,WAAW,WAAW,SAAS,MAAM,QAAQ,IAAI;MAC1D,IAAI,KAAK,WAAW,YAAY,SAAS,MAAM,SAAS,IAAI;MAC5D,KAAK,yBAAyB;CACnC,QAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,UAAU,CAAC,CAAC,EAAE,GAAG;AAC1D;AAEA,KAAK,CAAC,CAAC,OAAO,UAAU;CACtB,QAAQ,OAAO,MAAM,gCAAgC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE,GAAG;CAC/G,QAAQ,WAAW;AACrB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentconnect.md/daemon",
3
- "version": "1.49.0-rc.3",
3
+ "version": "1.49.0-rc.5",
4
4
  "description": "AgentConnect daemon — edge message + agent execution unit",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {