@agent-device/proxy 0.21.40-nightly.20261118.186 → 0.21.40
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/dist/process.mjs +46 -20
- package/package.json +3 -3
package/dist/process.mjs
CHANGED
|
@@ -1364,33 +1364,59 @@ function gracefulSignalFor(record) {
|
|
|
1364
1364
|
//#endregion
|
|
1365
1365
|
//#region ../host-kit/src/internal/atomic-file.ts
|
|
1366
1366
|
/**
|
|
1367
|
-
*
|
|
1368
|
-
*
|
|
1367
|
+
* The canonical temp path for a destination: a sibling of the name, inside the directory the publish will
|
|
1368
|
+
* create the entry in — the walk's answer for a script destination, `path.dirname` for every other one. Its
|
|
1369
|
+
* name stays bounded whatever the destination's length, so any name that fits the filesystem has a temp
|
|
1370
|
+
* sibling that fits too.
|
|
1371
|
+
*/
|
|
1372
|
+
function createAtomicPublishTempPath(directory, destination) {
|
|
1373
|
+
return path.join(directory, `${temporaryNamePrefix(destination)}${process.pid}-${crypto.randomBytes(8).toString("hex")}.tmp`);
|
|
1374
|
+
}
|
|
1375
|
+
/** How many bytes of the destination's name a temp sibling repeats, so a reader can still tell whose it is. */
|
|
1376
|
+
const TEMP_NAME_STEM_BYTES = 32;
|
|
1377
|
+
/**
|
|
1378
|
+
* The start every temp sibling of `destination` shares, and no other destination's: at most 32 bytes of its
|
|
1379
|
+
* name for a reader, then a hash of the WHOLE name, so two names that share their first bytes never share it.
|
|
1380
|
+
*/
|
|
1381
|
+
function temporaryNamePrefix(destination) {
|
|
1382
|
+
const name = path.basename(destination);
|
|
1383
|
+
let stem = "";
|
|
1384
|
+
for (const character of name) {
|
|
1385
|
+
if (Buffer.byteLength(stem + character) > TEMP_NAME_STEM_BYTES) break;
|
|
1386
|
+
stem += character;
|
|
1387
|
+
}
|
|
1388
|
+
const digest = crypto.createHash("sha256").update(name).digest("hex").slice(0, 16);
|
|
1389
|
+
return `.${stem}.${digest}.`;
|
|
1390
|
+
}
|
|
1391
|
+
function removeTempBestEffort(destination, temporaryPath) {
|
|
1392
|
+
if (temporaryPath === void 0) return;
|
|
1393
|
+
try {
|
|
1394
|
+
fs.rmSync(temporaryPath, { force: true });
|
|
1395
|
+
} catch (error) {
|
|
1396
|
+
emitDiagnostic({
|
|
1397
|
+
level: "warn",
|
|
1398
|
+
phase: "atomic_file_cleanup_failed",
|
|
1399
|
+
data: {
|
|
1400
|
+
destination,
|
|
1401
|
+
temporaryPath,
|
|
1402
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1403
|
+
}
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Gives a publisher a canonical temp path and cleanup ownership while it performs its own write protocol.
|
|
1409
|
+
* The sibling goes in `directory`, which the caller must name when it knows the physical directory the entry
|
|
1410
|
+
* is created in; a spelling that sends `..` or a link elsewhere is not where a temporary file may land.
|
|
1369
1411
|
*/
|
|
1370
1412
|
function withAtomicPublishTempPathSync(destination, publish) {
|
|
1371
|
-
const temporaryPath = createAtomicPublishTempPath(destination);
|
|
1413
|
+
const temporaryPath = createAtomicPublishTempPath(path.dirname(destination), destination);
|
|
1372
1414
|
try {
|
|
1373
1415
|
return publish(temporaryPath);
|
|
1374
1416
|
} finally {
|
|
1375
|
-
|
|
1376
|
-
fs.rmSync(temporaryPath, { force: true });
|
|
1377
|
-
} catch (error) {
|
|
1378
|
-
emitDiagnostic({
|
|
1379
|
-
level: "warn",
|
|
1380
|
-
phase: "atomic_file_cleanup_failed",
|
|
1381
|
-
data: {
|
|
1382
|
-
destination,
|
|
1383
|
-
temporaryPath,
|
|
1384
|
-
error: error instanceof Error ? error.message : String(error)
|
|
1385
|
-
}
|
|
1386
|
-
});
|
|
1387
|
-
}
|
|
1417
|
+
removeTempBestEffort(destination, temporaryPath);
|
|
1388
1418
|
}
|
|
1389
1419
|
}
|
|
1390
|
-
/** Returns the canonical same-directory temp path used by atomic publishers. */
|
|
1391
|
-
function createAtomicPublishTempPath(destination) {
|
|
1392
|
-
return path.join(path.dirname(destination), `.${path.basename(destination)}.${process.pid}-${crypto.randomUUID()}.tmp`);
|
|
1393
|
-
}
|
|
1394
1420
|
//#endregion
|
|
1395
1421
|
//#region ../host-kit/src/internal/owned-process-record.ts
|
|
1396
1422
|
const RECORD_FILE_NAME = "owned-processes.json";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-device/proxy",
|
|
3
|
-
"version": "0.21.40
|
|
3
|
+
"version": "0.21.40",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Transport-neutral authenticating proxy in front of an agent-device daemon.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@agent-device/contracts": "0.0.0",
|
|
29
28
|
"@agent-device/host-kit": "0.0.0",
|
|
30
|
-
"@agent-device/kernel": "0.0.0"
|
|
29
|
+
"@agent-device/kernel": "0.0.0",
|
|
30
|
+
"@agent-device/contracts": "0.0.0"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "tsdown --config tsdown.config.ts"
|