@lousy-agents/agent-shell 5.23.1 → 5.23.2
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/index.js +114 -87
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -957,18 +957,16 @@ async function writeAllToFile(target, data, options = {}) {
|
|
|
957
957
|
const length = Math.min(WRITE_CHUNK_BYTES, buffer.byteLength - offset);
|
|
958
958
|
const position = options.position === undefined ? null : options.position + offset;
|
|
959
959
|
options.assertBeforeMutation?.();
|
|
960
|
-
const written = typeof target === "number"
|
|
961
|
-
?
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
})
|
|
971
|
-
: (await target.write(buffer, offset, length, position)).bytesWritten;
|
|
960
|
+
const written = typeof target === "number"
|
|
961
|
+
? await new Promise((resolve, reject) => {
|
|
962
|
+
external_node_fs_namespaceObject.write(target, buffer, offset, length, position, (error, bytesWritten) => {
|
|
963
|
+
if (error)
|
|
964
|
+
reject(error);
|
|
965
|
+
else
|
|
966
|
+
resolve(bytesWritten);
|
|
967
|
+
});
|
|
968
|
+
})
|
|
969
|
+
: (await target.write(buffer, offset, length, position)).bytesWritten;
|
|
972
970
|
if (written <= 0) {
|
|
973
971
|
throw new errors_FsSafeError("helper-failed", "file write made no progress");
|
|
974
972
|
}
|
|
@@ -2014,6 +2012,7 @@ function assertWindowsAclRemediationAllowed() {
|
|
|
2014
2012
|
|
|
2015
2013
|
|
|
2016
2014
|
|
|
2015
|
+
|
|
2017
2016
|
const runtimePlatform = process.versions.bun ? (0,external_node_os_namespaceObject.platform)() : undefined;
|
|
2018
2017
|
const bunPosix = runtimePlatform === "darwin" || runtimePlatform === "linux" ? runtimePlatform : undefined;
|
|
2019
2018
|
function realpath_resolve(input, native) {
|
|
@@ -2082,6 +2081,21 @@ function realpath_resolve(input, native) {
|
|
|
2082
2081
|
const realpath_realpathSync = Object.assign((input) => realpath_resolve(input, false), {
|
|
2083
2082
|
native: (input) => realpath_resolve(input, true),
|
|
2084
2083
|
});
|
|
2084
|
+
/** Async on Node; retain runtime-specific native canonicalization guarantees. */
|
|
2085
|
+
async function realpath_realpathNative(input) {
|
|
2086
|
+
if (bunPosix)
|
|
2087
|
+
return realpath_realpathSync.native(input);
|
|
2088
|
+
try {
|
|
2089
|
+
return await promises_namespaceObject.realpath(input);
|
|
2090
|
+
}
|
|
2091
|
+
catch (error) {
|
|
2092
|
+
if (process.platform !== "win32" || error.code !== "EPERM" ||
|
|
2093
|
+
error.syscall !== "realpath")
|
|
2094
|
+
throw error;
|
|
2095
|
+
// AppContainer DOS-name translation still belongs to the native sync owner.
|
|
2096
|
+
return realpath_realpathSync.native(input);
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2085
2099
|
|
|
2086
2100
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/directory-entry-path.js
|
|
2087
2101
|
|
|
@@ -3292,7 +3306,7 @@ async function resolveAbsolutePathForRead(filePath, options = {}) {
|
|
|
3292
3306
|
const normalized = assertAbsolutePathInput(filePath);
|
|
3293
3307
|
let canonicalPath;
|
|
3294
3308
|
try {
|
|
3295
|
-
canonicalPath =
|
|
3309
|
+
canonicalPath = await realpathNative(pathForWindowsFilesystem(normalized));
|
|
3296
3310
|
assertNoWindowsPathAlias(canonicalPath);
|
|
3297
3311
|
}
|
|
3298
3312
|
catch (err) {
|
|
@@ -5221,6 +5235,12 @@ function root_boundary_admitPathInsideRoot(params) {
|
|
|
5221
5235
|
|
|
5222
5236
|
|
|
5223
5237
|
|
|
5238
|
+
|
|
5239
|
+
|
|
5240
|
+
// Windows native realpath denies delete sharing. Preserve read/publication
|
|
5241
|
+
// scheduling until canonicalization can safely overlap replacement.
|
|
5242
|
+
const synchronousRootTraversal = process.platform === "win32";
|
|
5243
|
+
const root_path_existing_runRootTraversal = synchronousRootTraversal ? atomic_io_runSync : runAsync;
|
|
5224
5244
|
function absolutePathWithRawSegments(candidate) {
|
|
5225
5245
|
if (external_node_path_namespaceObject.sep !== "\\") {
|
|
5226
5246
|
if (external_node_path_namespaceObject.isAbsolute(candidate))
|
|
@@ -5238,7 +5258,7 @@ function absolutePathWithRawSegments(candidate) {
|
|
|
5238
5258
|
const base = drive ? external_node_path_namespaceObject.resolve(drive) : process.cwd();
|
|
5239
5259
|
return `${base}${base.endsWith(external_node_path_namespaceObject.sep) ? "" : external_node_path_namespaceObject.sep}${raw.slice(drive.length)}`;
|
|
5240
5260
|
}
|
|
5241
|
-
function rawPathRelativeToCanonicalRoot(candidate, rootCanonicalPath, options = {}) {
|
|
5261
|
+
function* rawPathRelativeToCanonicalRoot(candidate, rootCanonicalPath, options = {}, synchronous = true) {
|
|
5242
5262
|
windows_path_alias_assertNoWindowsPathAlias(candidate);
|
|
5243
5263
|
windows_path_alias_assertNoWindowsPathAlias(rootCanonicalPath);
|
|
5244
5264
|
const absolute = absolutePathWithRawSegments(candidate);
|
|
@@ -5257,7 +5277,7 @@ function rawPathRelativeToCanonicalRoot(candidate, rootCanonicalPath, options =
|
|
|
5257
5277
|
let isSymlink = false;
|
|
5258
5278
|
try {
|
|
5259
5279
|
const operationPath = windows_path_alias_pathForWindowsFilesystem(prefix);
|
|
5260
|
-
const stat = external_node_fs_namespaceObject.lstatSync(operationPath);
|
|
5280
|
+
const stat = synchronous ? external_node_fs_namespaceObject.lstatSync(operationPath) : yield* wait(promises_namespaceObject.lstat(operationPath));
|
|
5261
5281
|
isSymlink = stat.isSymbolicLink();
|
|
5262
5282
|
// Check the original leaf before canonicalization can erase an entry alias.
|
|
5263
5283
|
if (isSymlink && options.rejectFinalSymlink && index === finalComponentIndex) {
|
|
@@ -5266,10 +5286,11 @@ function rawPathRelativeToCanonicalRoot(candidate, rootCanonicalPath, options =
|
|
|
5266
5286
|
if (!isSymlink && !stat.isDirectory() && index < segments.length - 1)
|
|
5267
5287
|
return undefined;
|
|
5268
5288
|
traversedSymlink ||= isSymlink;
|
|
5269
|
-
canonical = realpath_realpathSync.native(operationPath);
|
|
5289
|
+
canonical = synchronous ? realpath_realpathSync.native(operationPath) : yield* wait(realpath_realpathNative(operationPath));
|
|
5270
5290
|
windows_path_alias_assertNoWindowsPathAlias(canonical);
|
|
5271
5291
|
if (isSymlink && index < segments.length - 1 &&
|
|
5272
|
-
!external_node_fs_namespaceObject.statSync(windows_path_alias_pathForWindowsFilesystem(canonical))
|
|
5292
|
+
!(synchronous ? external_node_fs_namespaceObject.statSync(windows_path_alias_pathForWindowsFilesystem(canonical))
|
|
5293
|
+
: yield* wait(promises_namespaceObject.stat(windows_path_alias_pathForWindowsFilesystem(canonical)))).isDirectory())
|
|
5273
5294
|
return undefined;
|
|
5274
5295
|
if (isSymlink && !isPathInside(rootCanonicalPath, canonical) && !isPathInside(canonical, rootCanonicalPath)) {
|
|
5275
5296
|
throw new errors_FsSafeError("outside-workspace", `symlink prefix resolves outside the root ancestry: ${formatErrorDetail(candidate)}`);
|
|
@@ -5298,9 +5319,10 @@ function rawPathRelativeToCanonicalRoot(candidate, rootCanonicalPath, options =
|
|
|
5298
5319
|
}
|
|
5299
5320
|
return undefined;
|
|
5300
5321
|
}
|
|
5301
|
-
function root_path_existing_pathExists(targetPath) {
|
|
5322
|
+
function* root_path_existing_pathExists(targetPath, synchronous) {
|
|
5302
5323
|
try {
|
|
5303
|
-
return external_node_fs_namespaceObject.lstatSync(windows_path_alias_pathForWindowsFilesystem(targetPath), { throwIfNoEntry: false })
|
|
5324
|
+
return (synchronous ? external_node_fs_namespaceObject.lstatSync(windows_path_alias_pathForWindowsFilesystem(targetPath), { throwIfNoEntry: false })
|
|
5325
|
+
: yield* wait(promises_namespaceObject.lstat(windows_path_alias_pathForWindowsFilesystem(targetPath)))) !== undefined;
|
|
5304
5326
|
}
|
|
5305
5327
|
catch (error) {
|
|
5306
5328
|
if (path_isNotFoundPathError(error)) {
|
|
@@ -5310,17 +5332,20 @@ function root_path_existing_pathExists(targetPath) {
|
|
|
5310
5332
|
}
|
|
5311
5333
|
}
|
|
5312
5334
|
async function resolvePathViaExistingAncestor(targetPath) {
|
|
5313
|
-
return
|
|
5335
|
+
return root_path_existing_runRootTraversal(resolveExistingAncestorProcedure(targetPath, "native", synchronousRootTraversal));
|
|
5314
5336
|
}
|
|
5315
|
-
function
|
|
5337
|
+
function* ordinaryExists(targetPath) {
|
|
5316
5338
|
return external_node_fs_namespaceObject.existsSync(windows_path_alias_pathForWindowsFilesystem(targetPath));
|
|
5317
5339
|
}
|
|
5318
5340
|
function resolvePathViaExistingAncestorSync(targetPath) {
|
|
5319
5341
|
return resolveExistingAncestor(targetPath, "ordinary");
|
|
5320
5342
|
}
|
|
5321
5343
|
function resolveExistingAncestor(targetPath, mode, preserveRawSegments = false, remainingHops = 64) {
|
|
5322
|
-
|
|
5323
|
-
|
|
5344
|
+
return atomic_io_runSync(resolveExistingAncestorProcedure(targetPath, mode, true, preserveRawSegments, remainingHops));
|
|
5345
|
+
}
|
|
5346
|
+
function* resolveExistingAncestorProcedure(targetPath, mode, synchronous, preserveRawSegments = false, remainingHops = 64) {
|
|
5347
|
+
const exists = (pathname) => mode === "native" || preserveRawSegments
|
|
5348
|
+
? root_path_existing_pathExists(pathname, synchronous) : ordinaryExists(pathname);
|
|
5324
5349
|
windows_path_alias_assertNoWindowsPathAlias(targetPath);
|
|
5325
5350
|
const normalized = windows_path_alias_resolvePathPreservingWindowsRoot(targetPath);
|
|
5326
5351
|
windows_path_alias_assertNoWindowsPathAlias(normalized);
|
|
@@ -5328,22 +5353,23 @@ function resolveExistingAncestor(targetPath, mode, preserveRawSegments = false,
|
|
|
5328
5353
|
let cursor = candidate;
|
|
5329
5354
|
const filesystemRoot = external_node_path_namespaceObject.parse(candidate).root;
|
|
5330
5355
|
while (cursor !== filesystemRoot &&
|
|
5331
|
-
!exists(cursor)) {
|
|
5356
|
+
!(yield* exists(cursor))) {
|
|
5332
5357
|
cursor = external_node_path_namespaceObject.dirname(cursor);
|
|
5333
5358
|
}
|
|
5334
|
-
if (!exists(cursor)) {
|
|
5359
|
+
if (!(yield* exists(cursor))) {
|
|
5335
5360
|
return normalized;
|
|
5336
5361
|
}
|
|
5337
5362
|
let rawResolvedAncestor;
|
|
5338
5363
|
try {
|
|
5339
|
-
rawResolvedAncestor =
|
|
5364
|
+
rawResolvedAncestor = synchronous ? realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(cursor))
|
|
5365
|
+
: yield* wait(realpath_realpathNative(windows_path_alias_pathForWindowsFilesystem(cursor)));
|
|
5340
5366
|
}
|
|
5341
5367
|
catch (error) {
|
|
5342
5368
|
if (!preserveRawSegments)
|
|
5343
5369
|
return normalized;
|
|
5344
5370
|
if (!path_isNotFoundPathError(error))
|
|
5345
5371
|
throw error;
|
|
5346
|
-
rawResolvedAncestor = resolveSymlinkHopPath(cursor, mode, false, remainingHops);
|
|
5372
|
+
rawResolvedAncestor = yield* resolveSymlinkHopPath(cursor, mode, false, remainingHops, synchronous);
|
|
5347
5373
|
}
|
|
5348
5374
|
windows_path_alias_assertNoWindowsPathAlias(rawResolvedAncestor);
|
|
5349
5375
|
const resolvedAncestor = windows_path_alias_resolvePathPreservingWindowsRoot(rawResolvedAncestor);
|
|
@@ -5359,10 +5385,10 @@ function resolveExistingAncestor(targetPath, mode, preserveRawSegments = false,
|
|
|
5359
5385
|
windows_path_alias_assertNoWindowsPathAlias(resolved);
|
|
5360
5386
|
return resolved;
|
|
5361
5387
|
}
|
|
5362
|
-
function resolveSymlinkHopPath(symlinkPath, mode, rejectUnresolved, remainingHops = 64) {
|
|
5388
|
+
function* resolveSymlinkHopPath(symlinkPath, mode, rejectUnresolved, remainingHops = 64, synchronous = true) {
|
|
5363
5389
|
try {
|
|
5364
|
-
const
|
|
5365
|
-
|
|
5390
|
+
const rawRealPath = synchronous ? realpath_realpathSync.native(symlinkPath)
|
|
5391
|
+
: yield* wait(realpath_realpathNative(symlinkPath));
|
|
5366
5392
|
windows_path_alias_assertNoWindowsPathAlias(rawRealPath, "filesystem", "resolved symlink path uses a Windows filesystem namespace alias");
|
|
5367
5393
|
const realPath = windows_path_alias_resolvePathPreservingWindowsRoot(rawRealPath);
|
|
5368
5394
|
windows_path_alias_assertNoWindowsPathAlias(realPath, "filesystem", "resolved symlink path uses a Windows filesystem namespace alias");
|
|
@@ -5376,14 +5402,14 @@ function resolveSymlinkHopPath(symlinkPath, mode, rejectUnresolved, remainingHop
|
|
|
5376
5402
|
throw error;
|
|
5377
5403
|
if (remainingHops <= 0)
|
|
5378
5404
|
throw new errors_FsSafeError("symlink", "too many unresolved symlink hops");
|
|
5379
|
-
const linkTarget = external_node_fs_namespaceObject.readlinkSync(symlinkPath);
|
|
5405
|
+
const linkTarget = synchronous ? external_node_fs_namespaceObject.readlinkSync(symlinkPath) : yield* wait(promises_namespaceObject.readlink(symlinkPath));
|
|
5380
5406
|
windows_path_alias_assertNoWindowsPathAlias(linkTarget, "filesystem", "symlink target uses a Windows filesystem namespace alias");
|
|
5381
5407
|
const linkDir = windows_path_alias_resolvePathPreservingWindowsRoot(external_node_path_namespaceObject.dirname(symlinkPath));
|
|
5382
5408
|
// Keep parent segments until the kernel has resolved the existing prefix.
|
|
5383
5409
|
const targetPath = external_node_path_namespaceObject.isAbsolute(linkTarget) ? linkTarget
|
|
5384
5410
|
: external_node_path_namespaceObject.parse(linkTarget).root ? windows_path_alias_resolvePathFromBasePreservingWindowsRoot(linkDir, linkTarget)
|
|
5385
5411
|
: `${linkDir}${external_node_path_namespaceObject.sep}${linkTarget}`;
|
|
5386
|
-
const resolved =
|
|
5412
|
+
const resolved = yield* resolveExistingAncestorProcedure(targetPath, mode, synchronous, true, remainingHops - 1);
|
|
5387
5413
|
windows_path_alias_assertNoWindowsPathAlias(resolved, "filesystem", "resolved symlink path uses a Windows filesystem namespace alias");
|
|
5388
5414
|
return resolved;
|
|
5389
5415
|
}
|
|
@@ -5511,7 +5537,7 @@ async function runAsync(procedure) {
|
|
|
5511
5537
|
}
|
|
5512
5538
|
return step.value;
|
|
5513
5539
|
}
|
|
5514
|
-
function
|
|
5540
|
+
function atomic_io_runSync(procedure) {
|
|
5515
5541
|
let step = procedure.next();
|
|
5516
5542
|
// Sync adapters retain their ordinary return values; this driver never reads then.
|
|
5517
5543
|
while (!step.done)
|
|
@@ -6462,21 +6488,21 @@ function probeTemporaryEntry(directory) {
|
|
|
6462
6488
|
const owner = new AtomicTempOwner(external_node_path_namespaceObject.join(directory, name), io);
|
|
6463
6489
|
try {
|
|
6464
6490
|
owner.start();
|
|
6465
|
-
owner.adopt(
|
|
6491
|
+
owner.adopt(atomic_io_runSync(writeTempFile(io, {
|
|
6466
6492
|
tempPath: owner.pathname,
|
|
6467
6493
|
content: "",
|
|
6468
6494
|
mode: 0o600,
|
|
6469
6495
|
sync: false,
|
|
6470
6496
|
onIdentity: owner.onIdentity,
|
|
6471
6497
|
})));
|
|
6472
|
-
|
|
6498
|
+
atomic_io_runSync(owner.assertCurrent());
|
|
6473
6499
|
const observed = probeEntry(directory, name, new Set(external_node_fs_namespaceObject.readdirSync(directory)));
|
|
6474
|
-
|
|
6500
|
+
atomic_io_runSync(owner.assertCurrent());
|
|
6475
6501
|
return observed;
|
|
6476
6502
|
}
|
|
6477
6503
|
finally {
|
|
6478
6504
|
// Failed cleanup invalidates the observation; the existing owner retains its exit retry.
|
|
6479
|
-
|
|
6505
|
+
atomic_io_runSync(owner.finish({ throwOnCleanupError: true }));
|
|
6480
6506
|
}
|
|
6481
6507
|
}
|
|
6482
6508
|
function probeDirectory(directory, allowTemporaryProbe, preferredName) {
|
|
@@ -9137,6 +9163,8 @@ function captureRootPathObservedDirectory(observation, observed, publicPath, can
|
|
|
9137
9163
|
|
|
9138
9164
|
|
|
9139
9165
|
|
|
9166
|
+
|
|
9167
|
+
|
|
9140
9168
|
const ROOT_PATH_ALIAS_POLICIES = {
|
|
9141
9169
|
strict: Object.freeze({
|
|
9142
9170
|
allowFinalSymlinkForUnlink: false,
|
|
@@ -9148,36 +9176,38 @@ const ROOT_PATH_ALIAS_POLICIES = {
|
|
|
9148
9176
|
}),
|
|
9149
9177
|
};
|
|
9150
9178
|
async function root_path_resolveRootPath(params) {
|
|
9151
|
-
return resolveRootPathInternal(params);
|
|
9179
|
+
return root_path_existing_runRootTraversal(resolveRootPathInternal(params));
|
|
9152
9180
|
}
|
|
9153
9181
|
async function resolveRootPathWithCanonicalRootObservation(params, observeRoot) {
|
|
9154
|
-
return resolveRootPathInternal(params, { observeRoot });
|
|
9182
|
+
return runRootTraversal(resolveRootPathInternal(params, { observeRoot }));
|
|
9155
9183
|
}
|
|
9156
9184
|
async function resolveRootPathWithObservation(params, request) {
|
|
9157
9185
|
const observation = { request };
|
|
9158
|
-
const resolved =
|
|
9186
|
+
const resolved = synchronousRootTraversal
|
|
9187
|
+
? atomic_io_runSync(resolveRootPathInternal(params, { observation }))
|
|
9188
|
+
: await root_path_existing_runRootTraversal(resolveRootPathInternal(params, { observation }));
|
|
9159
9189
|
return observation.receipt ? { resolved, receipt: observation.receipt } : { resolved };
|
|
9160
9190
|
}
|
|
9161
9191
|
// Removal receipts are separate from metadata observations and canonical-root
|
|
9162
|
-
// callbacks;
|
|
9192
|
+
// callbacks; retain their synchronous admission and mutation-fence owner.
|
|
9163
9193
|
async function resolveRootPathForRemoval(params, receipts) {
|
|
9164
|
-
return resolveRootPathInternal(params, { removalReceipts: receipts });
|
|
9194
|
+
return atomic_io_runSync(resolveRootPathInternal(params, { removalReceipts: receipts }, true));
|
|
9165
9195
|
}
|
|
9166
9196
|
function root_path_resolveRootPathSync(params) {
|
|
9167
|
-
return resolveRootPathInternal(params, { mode: "ordinary" });
|
|
9197
|
+
return atomic_io_runSync(resolveRootPathInternal(params, { mode: "ordinary" }, true));
|
|
9168
9198
|
}
|
|
9169
9199
|
function resolveRootPathSyncWithCanonicalRootObservation(params, observeRoot) {
|
|
9170
|
-
return resolveRootPathInternal(params, { mode: "ordinary", observeRoot });
|
|
9200
|
+
return runSync(resolveRootPathInternal(params, { mode: "ordinary", observeRoot }, true));
|
|
9171
9201
|
}
|
|
9172
|
-
function resolveRootPathInternal(params, options = {}) {
|
|
9202
|
+
function* resolveRootPathInternal(params, options = {}, synchronous = synchronousRootTraversal) {
|
|
9173
9203
|
try {
|
|
9174
|
-
return traverseRootPath(params, options);
|
|
9204
|
+
return yield* traverseRootPath(params, options, synchronous);
|
|
9175
9205
|
}
|
|
9176
9206
|
catch (error) {
|
|
9177
9207
|
throw sanitizeRootPathError(error);
|
|
9178
9208
|
}
|
|
9179
9209
|
}
|
|
9180
|
-
function prepareRootTraversal(params, rootPath, rootCanonicalPath, absolutePath, rawAbsolutePath) {
|
|
9210
|
+
function* prepareRootTraversal(params, rootPath, rootCanonicalPath, absolutePath, rawAbsolutePath, synchronous) {
|
|
9181
9211
|
let raw = rawAbsolutePath;
|
|
9182
9212
|
let trustedAbsolutePath = false;
|
|
9183
9213
|
// Even a metadata lookup on a foreign share contacts that host, including the
|
|
@@ -9193,7 +9223,7 @@ function prepareRootTraversal(params, rootPath, rootCanonicalPath, absolutePath,
|
|
|
9193
9223
|
else {
|
|
9194
9224
|
const canonical = admitRawPathInsideRoot(rootCanonicalPath, raw, params.rootIdentity);
|
|
9195
9225
|
const relative = canonical?.relativePath
|
|
9196
|
-
?? rawPathRelativeToCanonicalRoot(raw, rootCanonicalPath, params);
|
|
9226
|
+
?? (yield* rawPathRelativeToCanonicalRoot(raw, rootCanonicalPath, params, synchronous));
|
|
9197
9227
|
if (relative === undefined) {
|
|
9198
9228
|
throw pathEscapeError({ rootPath, absolutePath: raw, boundaryLabel: params.boundaryLabel });
|
|
9199
9229
|
}
|
|
@@ -9374,27 +9404,28 @@ function assertDirectoryBeforeMoreSegments(stat, pathname, isLast) {
|
|
|
9374
9404
|
throw Object.assign(new Error(`Path component is not a directory: ${pathname}`), { code: "ENOTDIR" });
|
|
9375
9405
|
}
|
|
9376
9406
|
}
|
|
9377
|
-
function assertResolvedLinkDirectory(pathname, isLast) {
|
|
9407
|
+
function* assertResolvedLinkDirectory(pathname, isLast, synchronous) {
|
|
9378
9408
|
if (isLast)
|
|
9379
9409
|
return;
|
|
9380
|
-
const stat = external_node_fs_namespaceObject.statSync(windows_path_alias_pathForWindowsFilesystem(pathname))
|
|
9410
|
+
const stat = synchronous ? external_node_fs_namespaceObject.statSync(windows_path_alias_pathForWindowsFilesystem(pathname))
|
|
9411
|
+
: yield* wait(promises_namespaceObject.stat(windows_path_alias_pathForWindowsFilesystem(pathname)));
|
|
9381
9412
|
assertDirectoryBeforeMoreSegments(stat, pathname, isLast);
|
|
9382
9413
|
}
|
|
9383
|
-
// Both
|
|
9384
|
-
//
|
|
9385
|
-
function traverseRootPath(params, { mode = "native", observation: observationOutput, observeRoot, removalReceipts }) {
|
|
9414
|
+
// Both drivers share containment policy. Observation receipts and platform-specific
|
|
9415
|
+
// native guards retain their existing synchronous owners.
|
|
9416
|
+
function* traverseRootPath(params, { mode = "native", observation: observationOutput, observeRoot, removalReceipts }, synchronous) {
|
|
9386
9417
|
const input = captureValidRootPathInputs(params);
|
|
9387
9418
|
const rawAbsolutePath = absolutePathWithRawSegments(input.absolutePath);
|
|
9388
9419
|
const rootPath = windows_path_alias_resolvePathPreservingWindowsRoot(input.rootPath);
|
|
9389
9420
|
const absolutePath = windows_path_alias_resolvePathPreservingWindowsRoot(rawAbsolutePath);
|
|
9390
9421
|
const rootCanonicalPath = input.rootCanonicalPath
|
|
9391
9422
|
? windows_path_alias_resolvePathPreservingWindowsRoot(input.rootCanonicalPath)
|
|
9392
|
-
:
|
|
9423
|
+
: yield* resolveExistingAncestorProcedure(rootPath, mode, synchronous);
|
|
9393
9424
|
windows_path_alias_assertNoWindowsPathAlias(rootPath);
|
|
9394
9425
|
windows_path_alias_assertNoWindowsPathAlias(absolutePath);
|
|
9395
9426
|
windows_path_alias_assertNoWindowsPathAlias(rootCanonicalPath);
|
|
9396
9427
|
observeRoot?.(rootCanonicalPath);
|
|
9397
|
-
const context = createLexicalTraversalContext(prepareRootTraversal(input, rootPath, rootCanonicalPath, absolutePath, rawAbsolutePath));
|
|
9428
|
+
const context = createLexicalTraversalContext(yield* prepareRootTraversal(input, rootPath, rootCanonicalPath, absolutePath, rawAbsolutePath, synchronous));
|
|
9398
9429
|
const { state } = context;
|
|
9399
9430
|
const observation = createLexicalTraversalObservation(context, observationOutput?.request);
|
|
9400
9431
|
for (let idx = 0; idx < state.segments.length; idx += 1) {
|
|
@@ -9431,7 +9462,8 @@ function traverseRootPath(params, { mode = "native", observation: observationOut
|
|
|
9431
9462
|
}
|
|
9432
9463
|
stat = isNativeDirectoryObservationGuard(observed)
|
|
9433
9464
|
? undefined
|
|
9434
|
-
: observed?.stat ?? external_node_fs_namespaceObject.lstatSync(state.lexicalCursor)
|
|
9465
|
+
: observed?.stat ?? (synchronous ? external_node_fs_namespaceObject.lstatSync(state.lexicalCursor)
|
|
9466
|
+
: yield* wait(promises_namespaceObject.lstat(state.lexicalCursor)));
|
|
9435
9467
|
}
|
|
9436
9468
|
}
|
|
9437
9469
|
catch (error) {
|
|
@@ -9494,12 +9526,12 @@ function traverseRootPath(params, { mode = "native", observation: observationOut
|
|
|
9494
9526
|
}
|
|
9495
9527
|
if (observation?.enabled)
|
|
9496
9528
|
disableLexicalTraversalObservation(context, observation);
|
|
9497
|
-
const linkCanonical = resolveSymlinkHopPath(state.lexicalCursor, mode, context.resolveParams.rejectUnresolvedSymlinks);
|
|
9529
|
+
const linkCanonical = yield* resolveSymlinkHopPath(state.lexicalCursor, mode, context.resolveParams.rejectUnresolvedSymlinks, 64, synchronous);
|
|
9498
9530
|
applyResolvedSymlinkHop(context, linkCanonical);
|
|
9499
9531
|
if (context.resolveParams.rejectSymlinks === true) {
|
|
9500
9532
|
throw new errors_FsSafeError("symlink", "symlink path component not allowed");
|
|
9501
9533
|
}
|
|
9502
|
-
assertResolvedLinkDirectory(linkCanonical, isLast);
|
|
9534
|
+
yield* assertResolvedLinkDirectory(linkCanonical, isLast, synchronous);
|
|
9503
9535
|
}
|
|
9504
9536
|
const completeObservation = observation?.enabled === true && observation.directoryGuard !== undefined &&
|
|
9505
9537
|
observation.targetPath === state.canonicalCursor && observation.target !== undefined;
|
|
@@ -9507,7 +9539,7 @@ function traverseRootPath(params, { mode = "native", observation: observationOut
|
|
|
9507
9539
|
? isNativeDirectoryObservationGuard(observation.target)
|
|
9508
9540
|
? "directory"
|
|
9509
9541
|
: toResolvedKind(observation.target.stat)
|
|
9510
|
-
:
|
|
9542
|
+
: yield* getPathKind(state.canonicalCursor, state.preserveFinalSymlink, synchronous);
|
|
9511
9543
|
if (completeObservation && observationOutput) {
|
|
9512
9544
|
observationOutput.receipt = {
|
|
9513
9545
|
kind: observation.request.kind,
|
|
@@ -9520,12 +9552,12 @@ function traverseRootPath(params, { mode = "native", observation: observationOut
|
|
|
9520
9552
|
}
|
|
9521
9553
|
return finalizeLexicalResolution(context, kind);
|
|
9522
9554
|
}
|
|
9523
|
-
function
|
|
9555
|
+
function* getPathKind(absolutePath, preserveFinalSymlink, synchronous) {
|
|
9524
9556
|
try {
|
|
9525
9557
|
const operationPath = windows_path_alias_pathForWindowsFilesystem(absolutePath);
|
|
9526
9558
|
const stat = preserveFinalSymlink
|
|
9527
|
-
? external_node_fs_namespaceObject.lstatSync(operationPath)
|
|
9528
|
-
: external_node_fs_namespaceObject.statSync(operationPath);
|
|
9559
|
+
? synchronous ? external_node_fs_namespaceObject.lstatSync(operationPath) : yield* wait(promises_namespaceObject.lstat(operationPath))
|
|
9560
|
+
: synchronous ? external_node_fs_namespaceObject.statSync(operationPath) : yield* wait(promises_namespaceObject.stat(operationPath));
|
|
9529
9561
|
return toResolvedKind(stat);
|
|
9530
9562
|
}
|
|
9531
9563
|
catch (error) {
|
|
@@ -12589,7 +12621,6 @@ function replayPinnedInput(fd, input) {
|
|
|
12589
12621
|
})() };
|
|
12590
12622
|
}
|
|
12591
12623
|
const pinned_write_input_isUint8Array = external_node_util_namespaceObject.types.isUint8Array;
|
|
12592
|
-
const SMALL_BUFFER_BYTES = 64 * 1024;
|
|
12593
12624
|
function streamChunkBytes(chunk) {
|
|
12594
12625
|
if (Buffer.isBuffer(chunk))
|
|
12595
12626
|
return chunk;
|
|
@@ -12604,16 +12635,6 @@ async function writePinnedInput(target, input, maxBytes, assertBeforeMutation) {
|
|
|
12604
12635
|
await writeCopyFileToFd(typeof target === "number" ? target : target.fd, input, maxBytes, assertBeforeMutation);
|
|
12605
12636
|
return;
|
|
12606
12637
|
}
|
|
12607
|
-
if (typeof target === "number" && input.kind === "buffer" &&
|
|
12608
|
-
input.stageBeforePublish !== false && !assertBeforeMutation) {
|
|
12609
|
-
const data = typeof input.data === "string" ? Buffer.from(input.data, input.encoding ?? "utf8") : input.data;
|
|
12610
|
-
if (data.byteLength <= SMALL_BUFFER_BYTES) {
|
|
12611
|
-
if (maxBytes !== undefined && data.byteLength > maxBytes) {
|
|
12612
|
-
throw new errors_FsSafeError("too-large", `file exceeds limit of ${maxBytes} bytes (got at least ${data.byteLength})`);
|
|
12613
|
-
}
|
|
12614
|
-
return writeAllToFile(target, data, { synchronous: true });
|
|
12615
|
-
}
|
|
12616
|
-
}
|
|
12617
12638
|
let bytes = 0;
|
|
12618
12639
|
const write = async (data) => {
|
|
12619
12640
|
bytes += data.byteLength;
|
|
@@ -13105,8 +13126,8 @@ function assertNativeStaging(binding) {
|
|
|
13105
13126
|
binding.createStagedFile,
|
|
13106
13127
|
binding.stagedFileMatches,
|
|
13107
13128
|
binding.removeStagedFile,
|
|
13108
|
-
binding.
|
|
13109
|
-
binding.
|
|
13129
|
+
binding.renameReplaceAsync,
|
|
13130
|
+
binding.renameNoReplaceAsync,
|
|
13110
13131
|
].some((fn) => typeof fn !== "function")) {
|
|
13111
13132
|
throw new errors_FsSafeError("helper-unavailable", "native retained-directory staging is unavailable");
|
|
13112
13133
|
}
|
|
@@ -13126,7 +13147,7 @@ class NativeStagedFile {
|
|
|
13126
13147
|
#verifyMode;
|
|
13127
13148
|
#state = { status: "open", publication: NOT_PUBLISHED };
|
|
13128
13149
|
#receipt;
|
|
13129
|
-
#
|
|
13150
|
+
#publicationTask;
|
|
13130
13151
|
#rejectFinalSymlink = false;
|
|
13131
13152
|
#unsupportedNoReplace;
|
|
13132
13153
|
#fallbackCleanup;
|
|
@@ -13317,7 +13338,7 @@ class NativeStagedFile {
|
|
|
13317
13338
|
if (this.#private)
|
|
13318
13339
|
assertDarwinCreationAcl(this.#owner.parentFd, "file");
|
|
13319
13340
|
try {
|
|
13320
|
-
state.fileFd = this.#owner.binding.createStagedFile(this.#owner.parentFd, this.#owner.name);
|
|
13341
|
+
state.fileFd = await this.#owner.binding.createStagedFile(this.#owner.parentFd, this.#owner.name);
|
|
13321
13342
|
}
|
|
13322
13343
|
catch (error) {
|
|
13323
13344
|
annotateReadOnlyOpenError(error, external_node_path_namespaceObject.join(this.#owner.directory.realPath, this.#owner.name));
|
|
@@ -13366,7 +13387,14 @@ class NativeStagedFile {
|
|
|
13366
13387
|
async assertCurrent() {
|
|
13367
13388
|
this.#assertCurrent();
|
|
13368
13389
|
}
|
|
13369
|
-
|
|
13390
|
+
publish(basename, options, onPublished) {
|
|
13391
|
+
if (this.#publicationTask)
|
|
13392
|
+
return Promise.reject(stagedFailure("file", new errors_FsSafeError("helper-failed", "staged file publication is pending"), { phase: "publish", publication: this.#state.status === "closed" ? this.#state.receipt.publication : this.#state.publication }));
|
|
13393
|
+
// Claim the operation before yielding so cleanup cannot recycle a worker's fds.
|
|
13394
|
+
return this.#publicationTask = Promise.resolve().then(() => this.#publish(basename, options, onPublished))
|
|
13395
|
+
.finally(() => { this.#publicationTask = undefined; });
|
|
13396
|
+
}
|
|
13397
|
+
async #publish(basename, options, onPublished) {
|
|
13370
13398
|
const overwrite = options?.overwrite;
|
|
13371
13399
|
try {
|
|
13372
13400
|
const state = this.#open();
|
|
@@ -13383,10 +13411,10 @@ class NativeStagedFile {
|
|
|
13383
13411
|
}
|
|
13384
13412
|
try {
|
|
13385
13413
|
if (overwrite) {
|
|
13386
|
-
this.#owner.binding.
|
|
13414
|
+
await this.#owner.binding.renameReplaceAsync(this.#owner.parentFd, this.#owner.name, this.#owner.parentFd, basename);
|
|
13387
13415
|
}
|
|
13388
13416
|
else {
|
|
13389
|
-
this.#owner.binding.
|
|
13417
|
+
await this.#owner.binding.renameNoReplaceAsync(this.#owner.parentFd, this.#owner.name, this.#owner.parentFd, basename);
|
|
13390
13418
|
}
|
|
13391
13419
|
}
|
|
13392
13420
|
catch (error) {
|
|
@@ -13441,14 +13469,13 @@ class NativeStagedFile {
|
|
|
13441
13469
|
};
|
|
13442
13470
|
if (this.#owner.sync === false)
|
|
13443
13471
|
return verify();
|
|
13444
|
-
|
|
13472
|
+
return Promise.resolve().then(async () => {
|
|
13445
13473
|
if ((this.#owner.mode & 0o600) !== 0o600 || (stagedMode & ~this.#owner.mode) !== 0) {
|
|
13446
13474
|
await (this.#owner.strictFileSync ? syncFile(fd) : syncFileBestEffort(fd));
|
|
13447
13475
|
}
|
|
13448
13476
|
await syncFileBestEffort(this.#owner.parentFd);
|
|
13449
13477
|
return verify();
|
|
13450
|
-
})
|
|
13451
|
-
return this.#publicationFlush;
|
|
13478
|
+
});
|
|
13452
13479
|
}
|
|
13453
13480
|
#finalize() {
|
|
13454
13481
|
if (this.#state.status === "closed") {
|
|
@@ -13503,9 +13530,9 @@ class NativeStagedFile {
|
|
|
13503
13530
|
return this.#state;
|
|
13504
13531
|
}
|
|
13505
13532
|
async cleanup() {
|
|
13506
|
-
// Native descriptors
|
|
13507
|
-
if (this.#
|
|
13508
|
-
await this.#
|
|
13533
|
+
// Native descriptors stay owned through the rename and all durability fences.
|
|
13534
|
+
if (this.#publicationTask)
|
|
13535
|
+
await this.#publicationTask.catch(() => { });
|
|
13509
13536
|
const closed = this.#finalize();
|
|
13510
13537
|
if (closed.error) {
|
|
13511
13538
|
throw closed.error;
|
|
@@ -13603,7 +13630,7 @@ var native_pinned_write_disposeResources = (undefined && undefined.__disposeReso
|
|
|
13603
13630
|
|
|
13604
13631
|
|
|
13605
13632
|
const writeCapabilities = ["openBeneath", "mkdirBeneath", "renameNoReplace", "renameReplace"];
|
|
13606
|
-
const posixWriteCapabilities = [...writeCapabilities, "createStagedFile", "stagedFileMatches", "removeStagedFile"];
|
|
13633
|
+
const posixWriteCapabilities = [...writeCapabilities, "createStagedFile", "stagedFileMatches", "removeStagedFile", "renameReplaceAsync", "renameNoReplaceAsync"];
|
|
13607
13634
|
function pinnedWriteCapabilities(params) {
|
|
13608
13635
|
const windows = process.platform === "win32";
|
|
13609
13636
|
const capabilities = windows ? [...writeCapabilities, "fstatIdentity"] : posixWriteCapabilities;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lousy-agents/agent-shell",
|
|
3
|
-
"version": "5.23.
|
|
3
|
+
"version": "5.23.2",
|
|
4
4
|
"description": "A flight recorder for npm script execution",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"typecheck": "tsc --noEmit"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@openclaw/fs-safe": "0.27.
|
|
40
|
+
"@openclaw/fs-safe": "0.27.1",
|
|
41
41
|
"zod": "4.6.7"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|