agent-web-os 0.1.15 → 0.1.17
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.cjs +417 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -2
- package/dist/index.d.ts +28 -2
- package/dist/index.js +417 -36
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6028,6 +6028,7 @@ __export(index_exports, {
|
|
|
6028
6028
|
createBrowserBashSession: () => createBrowserBashSession,
|
|
6029
6029
|
defineCommand: () => Dx,
|
|
6030
6030
|
executeBrowserBash: () => executeBrowserBash,
|
|
6031
|
+
executeFd: () => executeFd,
|
|
6031
6032
|
getServerBridge: () => getServerBridge2,
|
|
6032
6033
|
resetServerBridge: () => resetServerBridge2
|
|
6033
6034
|
});
|
|
@@ -43532,7 +43533,7 @@ function trackCall(method, path2) {
|
|
|
43532
43533
|
}
|
|
43533
43534
|
}
|
|
43534
43535
|
function createFsShim(vfs2, getCwd) {
|
|
43535
|
-
const
|
|
43536
|
+
const resolvePath2 = (pathLike) => toPath(pathLike, getCwd);
|
|
43536
43537
|
const constants8 = {
|
|
43537
43538
|
F_OK: 0,
|
|
43538
43539
|
R_OK: 4,
|
|
@@ -43543,7 +43544,7 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43543
43544
|
readFile(pathLike, encodingOrOptions) {
|
|
43544
43545
|
return new Promise((resolve5, reject) => {
|
|
43545
43546
|
try {
|
|
43546
|
-
const path2 =
|
|
43547
|
+
const path2 = resolvePath2(pathLike);
|
|
43547
43548
|
let encoding;
|
|
43548
43549
|
if (typeof encodingOrOptions === "string") {
|
|
43549
43550
|
encoding = encodingOrOptions;
|
|
@@ -43563,7 +43564,7 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43563
43564
|
writeFile(pathLike, data2) {
|
|
43564
43565
|
return new Promise((resolve5, reject) => {
|
|
43565
43566
|
try {
|
|
43566
|
-
vfs2.writeFileSync(
|
|
43567
|
+
vfs2.writeFileSync(resolvePath2(pathLike), data2);
|
|
43567
43568
|
resolve5();
|
|
43568
43569
|
} catch (err2) {
|
|
43569
43570
|
reject(err2);
|
|
@@ -43573,7 +43574,7 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43573
43574
|
stat(pathLike) {
|
|
43574
43575
|
return new Promise((resolve5, reject) => {
|
|
43575
43576
|
try {
|
|
43576
|
-
const path2 = typeof pathLike === "string" ? pathLike :
|
|
43577
|
+
const path2 = typeof pathLike === "string" ? pathLike : resolvePath2(pathLike);
|
|
43577
43578
|
resolve5(vfs2.statSync(path2));
|
|
43578
43579
|
} catch (err2) {
|
|
43579
43580
|
reject(err2);
|
|
@@ -43581,12 +43582,12 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43581
43582
|
});
|
|
43582
43583
|
},
|
|
43583
43584
|
lstat(pathLike) {
|
|
43584
|
-
return this.stat(
|
|
43585
|
+
return this.stat(resolvePath2(pathLike));
|
|
43585
43586
|
},
|
|
43586
43587
|
readdir(pathLike, options2) {
|
|
43587
43588
|
return new Promise((resolve5, reject) => {
|
|
43588
43589
|
try {
|
|
43589
|
-
const path2 =
|
|
43590
|
+
const path2 = resolvePath2(pathLike);
|
|
43590
43591
|
const entries = vfs2.readdirSync(path2);
|
|
43591
43592
|
const opts = typeof options2 === "string" ? {} : options2;
|
|
43592
43593
|
if (opts?.withFileTypes) {
|
|
@@ -43615,7 +43616,7 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43615
43616
|
mkdir(pathLike, options2) {
|
|
43616
43617
|
return new Promise((resolve5, reject) => {
|
|
43617
43618
|
try {
|
|
43618
|
-
vfs2.mkdirSync(
|
|
43619
|
+
vfs2.mkdirSync(resolvePath2(pathLike), options2);
|
|
43619
43620
|
resolve5();
|
|
43620
43621
|
} catch (err2) {
|
|
43621
43622
|
reject(err2);
|
|
@@ -43625,7 +43626,7 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43625
43626
|
unlink(pathLike) {
|
|
43626
43627
|
return new Promise((resolve5, reject) => {
|
|
43627
43628
|
try {
|
|
43628
|
-
vfs2.unlinkSync(
|
|
43629
|
+
vfs2.unlinkSync(resolvePath2(pathLike));
|
|
43629
43630
|
resolve5();
|
|
43630
43631
|
} catch (err2) {
|
|
43631
43632
|
reject(err2);
|
|
@@ -43684,7 +43685,7 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43684
43685
|
};
|
|
43685
43686
|
return {
|
|
43686
43687
|
readFileSync(pathLike, encodingOrOptions) {
|
|
43687
|
-
const path2 =
|
|
43688
|
+
const path2 = resolvePath2(pathLike);
|
|
43688
43689
|
let encoding;
|
|
43689
43690
|
if (typeof encodingOrOptions === "string") {
|
|
43690
43691
|
encoding = encodingOrOptions;
|
|
@@ -43712,18 +43713,18 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43712
43713
|
entry.position = bytes.length;
|
|
43713
43714
|
return;
|
|
43714
43715
|
}
|
|
43715
|
-
const path2 =
|
|
43716
|
+
const path2 = resolvePath2(pathLike);
|
|
43716
43717
|
vfs2.writeFileSync(path2, data2);
|
|
43717
43718
|
},
|
|
43718
43719
|
existsSync(pathLike) {
|
|
43719
|
-
return vfs2.existsSync(
|
|
43720
|
+
return vfs2.existsSync(resolvePath2(pathLike));
|
|
43720
43721
|
},
|
|
43721
43722
|
mkdirSync(pathLike, options2) {
|
|
43722
|
-
const path2 =
|
|
43723
|
+
const path2 = resolvePath2(pathLike);
|
|
43723
43724
|
vfs2.mkdirSync(path2, options2);
|
|
43724
43725
|
},
|
|
43725
43726
|
readdirSync(pathLike, options2) {
|
|
43726
|
-
const path2 =
|
|
43727
|
+
const path2 = resolvePath2(pathLike);
|
|
43727
43728
|
trackCall("readdirSync", path2);
|
|
43728
43729
|
const entries = vfs2.readdirSync(path2);
|
|
43729
43730
|
const opts = typeof options2 === "string" ? { encoding: options2 } : options2;
|
|
@@ -43753,7 +43754,7 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43753
43754
|
},
|
|
43754
43755
|
statSync(pathLike) {
|
|
43755
43756
|
const origPath = typeof pathLike === "string" ? pathLike : String(pathLike);
|
|
43756
|
-
const path2 =
|
|
43757
|
+
const path2 = resolvePath2(pathLike);
|
|
43757
43758
|
trackCall("statSync", path2);
|
|
43758
43759
|
const result = vfs2.statSync(path2);
|
|
43759
43760
|
if (path2.includes("_generated")) {
|
|
@@ -43763,7 +43764,7 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43763
43764
|
return result;
|
|
43764
43765
|
},
|
|
43765
43766
|
lstatSync(pathLike) {
|
|
43766
|
-
return vfs2.lstatSync(
|
|
43767
|
+
return vfs2.lstatSync(resolvePath2(pathLike));
|
|
43767
43768
|
},
|
|
43768
43769
|
fstatSync(fd2) {
|
|
43769
43770
|
const entry = fdMap.get(fd2);
|
|
@@ -43776,7 +43777,7 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43776
43777
|
return vfs2.statSync(entry.path);
|
|
43777
43778
|
},
|
|
43778
43779
|
openSync(pathLike, flags, _mode) {
|
|
43779
|
-
const path2 =
|
|
43780
|
+
const path2 = resolvePath2(pathLike);
|
|
43780
43781
|
const flagStr = typeof flags === "number" ? "r" : flags;
|
|
43781
43782
|
const exists = vfs2.existsSync(path2);
|
|
43782
43783
|
const isWriteMode = flagStr.includes("w") || flagStr.includes("a");
|
|
@@ -43896,12 +43897,12 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43896
43897
|
mkdtempSync(prefix) {
|
|
43897
43898
|
const suffix = Math.random().toString(36).slice(2, 8);
|
|
43898
43899
|
const tempDir = `${prefix}${suffix}`;
|
|
43899
|
-
const resolvedPath2 =
|
|
43900
|
+
const resolvedPath2 = resolvePath2(tempDir);
|
|
43900
43901
|
vfs2.mkdirSync(resolvedPath2, { recursive: true });
|
|
43901
43902
|
return resolvedPath2;
|
|
43902
43903
|
},
|
|
43903
43904
|
rmSync(pathLike, options2) {
|
|
43904
|
-
const path2 =
|
|
43905
|
+
const path2 = resolvePath2(pathLike);
|
|
43905
43906
|
if (!vfs2.existsSync(path2)) {
|
|
43906
43907
|
if (options2?.force) return;
|
|
43907
43908
|
throw createNodeError("ENOENT", "rm", path2);
|
|
@@ -43923,54 +43924,54 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43923
43924
|
}
|
|
43924
43925
|
},
|
|
43925
43926
|
unlinkSync(pathLike) {
|
|
43926
|
-
const path2 =
|
|
43927
|
+
const path2 = resolvePath2(pathLike);
|
|
43927
43928
|
if (path2.includes("_generated")) {
|
|
43928
43929
|
console.log(`[fs] unlinkSync(${path2})`);
|
|
43929
43930
|
}
|
|
43930
43931
|
vfs2.unlinkSync(path2);
|
|
43931
43932
|
},
|
|
43932
43933
|
rmdirSync(pathLike) {
|
|
43933
|
-
vfs2.rmdirSync(
|
|
43934
|
+
vfs2.rmdirSync(resolvePath2(pathLike));
|
|
43934
43935
|
},
|
|
43935
43936
|
renameSync(oldPathLike, newPathLike) {
|
|
43936
|
-
vfs2.renameSync(
|
|
43937
|
+
vfs2.renameSync(resolvePath2(oldPathLike), resolvePath2(newPathLike));
|
|
43937
43938
|
},
|
|
43938
43939
|
realpathSync: Object.assign(
|
|
43939
43940
|
function realpathSync(pathLike) {
|
|
43940
|
-
return vfs2.realpathSync(
|
|
43941
|
+
return vfs2.realpathSync(resolvePath2(pathLike));
|
|
43941
43942
|
},
|
|
43942
43943
|
{
|
|
43943
43944
|
native(pathLike) {
|
|
43944
|
-
return vfs2.realpathSync(
|
|
43945
|
+
return vfs2.realpathSync(resolvePath2(pathLike));
|
|
43945
43946
|
}
|
|
43946
43947
|
}
|
|
43947
43948
|
),
|
|
43948
43949
|
accessSync(pathLike, _mode) {
|
|
43949
|
-
vfs2.accessSync(
|
|
43950
|
+
vfs2.accessSync(resolvePath2(pathLike));
|
|
43950
43951
|
},
|
|
43951
43952
|
copyFileSync(srcLike, destLike) {
|
|
43952
|
-
const src =
|
|
43953
|
-
const dest =
|
|
43953
|
+
const src = resolvePath2(srcLike);
|
|
43954
|
+
const dest = resolvePath2(destLike);
|
|
43954
43955
|
const data2 = vfs2.readFileSync(src);
|
|
43955
43956
|
vfs2.writeFileSync(dest, data2);
|
|
43956
43957
|
},
|
|
43957
43958
|
watch(pathLike, optionsOrListener, listener) {
|
|
43958
|
-
return vfs2.watch(
|
|
43959
|
+
return vfs2.watch(resolvePath2(pathLike), optionsOrListener, listener);
|
|
43959
43960
|
},
|
|
43960
43961
|
readFile(pathLike, optionsOrCallback, callback) {
|
|
43961
|
-
const path2 =
|
|
43962
|
+
const path2 = resolvePath2(pathLike);
|
|
43962
43963
|
vfs2.readFile(path2, optionsOrCallback, callback);
|
|
43963
43964
|
},
|
|
43964
43965
|
stat(pathLike, callback) {
|
|
43965
|
-
vfs2.stat(
|
|
43966
|
+
vfs2.stat(resolvePath2(pathLike), callback);
|
|
43966
43967
|
},
|
|
43967
43968
|
lstat(pathLike, callback) {
|
|
43968
|
-
vfs2.lstat(
|
|
43969
|
+
vfs2.lstat(resolvePath2(pathLike), callback);
|
|
43969
43970
|
},
|
|
43970
43971
|
readdir(pathLike, optionsOrCallback, callback) {
|
|
43971
43972
|
const cb2 = typeof optionsOrCallback === "function" ? optionsOrCallback : callback;
|
|
43972
43973
|
const opts = typeof optionsOrCallback === "function" ? void 0 : optionsOrCallback;
|
|
43973
|
-
const path2 =
|
|
43974
|
+
const path2 = resolvePath2(pathLike);
|
|
43974
43975
|
try {
|
|
43975
43976
|
const entries = vfs2.readdirSync(path2);
|
|
43976
43977
|
if (opts?.withFileTypes) {
|
|
@@ -43996,16 +43997,16 @@ function createFsShim(vfs2, getCwd) {
|
|
|
43996
43997
|
}
|
|
43997
43998
|
},
|
|
43998
43999
|
realpath(pathLike, callback) {
|
|
43999
|
-
vfs2.realpath(
|
|
44000
|
+
vfs2.realpath(resolvePath2(pathLike), callback);
|
|
44000
44001
|
},
|
|
44001
44002
|
access(pathLike, modeOrCallback, callback) {
|
|
44002
|
-
vfs2.access(
|
|
44003
|
+
vfs2.access(resolvePath2(pathLike), modeOrCallback, callback);
|
|
44003
44004
|
},
|
|
44004
44005
|
createReadStream(pathLike) {
|
|
44005
|
-
return vfs2.createReadStream(
|
|
44006
|
+
return vfs2.createReadStream(resolvePath2(pathLike));
|
|
44006
44007
|
},
|
|
44007
44008
|
createWriteStream(pathLike) {
|
|
44008
|
-
return vfs2.createWriteStream(
|
|
44009
|
+
return vfs2.createWriteStream(resolvePath2(pathLike));
|
|
44009
44010
|
},
|
|
44010
44011
|
promises: promises4,
|
|
44011
44012
|
constants: constants8
|
|
@@ -62153,6 +62154,7 @@ ${packages.map(([name, version4]) => `+-- ${name}@${version4}`).join("\n")}
|
|
|
62153
62154
|
runtime.runFile(invocation.scriptPath);
|
|
62154
62155
|
}
|
|
62155
62156
|
syncExecution = false;
|
|
62157
|
+
await new Promise((r10) => setTimeout(r10, 0));
|
|
62156
62158
|
const isInteractive = process4.stdin && (process4.stdin.listenerCount("data") > 0 || process4.stdin.listenerCount("keypress") > 0);
|
|
62157
62159
|
const asyncExitCode = isInteractive ? await exitPromise : await Promise.race([
|
|
62158
62160
|
exitPromise,
|
|
@@ -62348,6 +62350,384 @@ function createAlmostNodeSession(fs) {
|
|
|
62348
62350
|
return new AlmostNodeSession(fs);
|
|
62349
62351
|
}
|
|
62350
62352
|
|
|
62353
|
+
// src/fd-command.ts
|
|
62354
|
+
function parseFdArgs(args) {
|
|
62355
|
+
const opts = {
|
|
62356
|
+
glob: false,
|
|
62357
|
+
fixedStrings: false,
|
|
62358
|
+
hidden: false,
|
|
62359
|
+
noIgnore: false,
|
|
62360
|
+
typeFilter: null,
|
|
62361
|
+
extensions: [],
|
|
62362
|
+
excludes: [],
|
|
62363
|
+
maxDepth: Infinity,
|
|
62364
|
+
maxResults: Infinity,
|
|
62365
|
+
ignoreFiles: [],
|
|
62366
|
+
absolutePath: false,
|
|
62367
|
+
fullPath: false,
|
|
62368
|
+
pattern: "",
|
|
62369
|
+
searchPaths: []
|
|
62370
|
+
};
|
|
62371
|
+
const positional = [];
|
|
62372
|
+
let i = 0;
|
|
62373
|
+
while (i < args.length) {
|
|
62374
|
+
const arg = args[i];
|
|
62375
|
+
if (arg === "--") {
|
|
62376
|
+
positional.push(...args.slice(i + 1));
|
|
62377
|
+
break;
|
|
62378
|
+
}
|
|
62379
|
+
if (arg === "--glob" || arg === "-g") {
|
|
62380
|
+
opts.glob = true;
|
|
62381
|
+
i++;
|
|
62382
|
+
continue;
|
|
62383
|
+
}
|
|
62384
|
+
if (arg === "--fixed-strings" || arg === "-F") {
|
|
62385
|
+
opts.fixedStrings = true;
|
|
62386
|
+
i++;
|
|
62387
|
+
continue;
|
|
62388
|
+
}
|
|
62389
|
+
if (arg === "--hidden" || arg === "-H") {
|
|
62390
|
+
opts.hidden = true;
|
|
62391
|
+
i++;
|
|
62392
|
+
continue;
|
|
62393
|
+
}
|
|
62394
|
+
if (arg === "--no-ignore" || arg === "-I") {
|
|
62395
|
+
opts.noIgnore = true;
|
|
62396
|
+
i++;
|
|
62397
|
+
continue;
|
|
62398
|
+
}
|
|
62399
|
+
if (arg === "--absolute-path" || arg === "-a") {
|
|
62400
|
+
opts.absolutePath = true;
|
|
62401
|
+
i++;
|
|
62402
|
+
continue;
|
|
62403
|
+
}
|
|
62404
|
+
if (arg === "--full-path" || arg === "-p") {
|
|
62405
|
+
opts.fullPath = true;
|
|
62406
|
+
i++;
|
|
62407
|
+
continue;
|
|
62408
|
+
}
|
|
62409
|
+
if (arg === "-1") {
|
|
62410
|
+
opts.maxResults = 1;
|
|
62411
|
+
i++;
|
|
62412
|
+
continue;
|
|
62413
|
+
}
|
|
62414
|
+
if (arg === "--type" || arg === "-t") {
|
|
62415
|
+
const val = args[++i];
|
|
62416
|
+
if (val === "f" || val === "file") opts.typeFilter = "f";
|
|
62417
|
+
else if (val === "d" || val === "dir" || val === "directory") opts.typeFilter = "d";
|
|
62418
|
+
i++;
|
|
62419
|
+
continue;
|
|
62420
|
+
}
|
|
62421
|
+
if (arg === "--extension" || arg === "-e") {
|
|
62422
|
+
const ext2 = args[++i];
|
|
62423
|
+
if (ext2) opts.extensions.push(ext2.startsWith(".") ? ext2.slice(1) : ext2);
|
|
62424
|
+
i++;
|
|
62425
|
+
continue;
|
|
62426
|
+
}
|
|
62427
|
+
if (arg === "--exclude" || arg === "-E") {
|
|
62428
|
+
const pat = args[++i];
|
|
62429
|
+
if (pat) opts.excludes.push(pat);
|
|
62430
|
+
i++;
|
|
62431
|
+
continue;
|
|
62432
|
+
}
|
|
62433
|
+
if (arg === "--max-depth" || arg === "-d") {
|
|
62434
|
+
const n10 = Number.parseInt(args[++i] ?? "", 10);
|
|
62435
|
+
if (!Number.isNaN(n10)) opts.maxDepth = n10;
|
|
62436
|
+
i++;
|
|
62437
|
+
continue;
|
|
62438
|
+
}
|
|
62439
|
+
if (arg === "--max-results") {
|
|
62440
|
+
const n10 = Number.parseInt(args[++i] ?? "", 10);
|
|
62441
|
+
if (!Number.isNaN(n10)) opts.maxResults = n10;
|
|
62442
|
+
i++;
|
|
62443
|
+
continue;
|
|
62444
|
+
}
|
|
62445
|
+
if (arg === "--ignore-file") {
|
|
62446
|
+
const p = args[++i];
|
|
62447
|
+
if (p) opts.ignoreFiles.push(p);
|
|
62448
|
+
i++;
|
|
62449
|
+
continue;
|
|
62450
|
+
}
|
|
62451
|
+
if (arg === "--color" || arg === "--colour") {
|
|
62452
|
+
i += 2;
|
|
62453
|
+
continue;
|
|
62454
|
+
}
|
|
62455
|
+
if (arg.startsWith("--color=") || arg.startsWith("--colour=")) {
|
|
62456
|
+
i++;
|
|
62457
|
+
continue;
|
|
62458
|
+
}
|
|
62459
|
+
if (arg === "-L" || arg === "--follow") {
|
|
62460
|
+
i++;
|
|
62461
|
+
continue;
|
|
62462
|
+
}
|
|
62463
|
+
if (arg === "-s" || arg === "--case-sensitive") {
|
|
62464
|
+
i++;
|
|
62465
|
+
continue;
|
|
62466
|
+
}
|
|
62467
|
+
if (arg === "-i" || arg === "--ignore-case") {
|
|
62468
|
+
i++;
|
|
62469
|
+
continue;
|
|
62470
|
+
}
|
|
62471
|
+
if (arg === "-S" || arg === "--smart-case") {
|
|
62472
|
+
i++;
|
|
62473
|
+
continue;
|
|
62474
|
+
}
|
|
62475
|
+
if (arg === "--version" || arg === "-V") {
|
|
62476
|
+
return { error: "__version__" };
|
|
62477
|
+
}
|
|
62478
|
+
if (arg === "--help" || arg === "-h") {
|
|
62479
|
+
return { error: "__help__" };
|
|
62480
|
+
}
|
|
62481
|
+
if (arg.startsWith("-")) {
|
|
62482
|
+
return { error: `Unknown flag: ${arg}` };
|
|
62483
|
+
}
|
|
62484
|
+
positional.push(arg);
|
|
62485
|
+
i++;
|
|
62486
|
+
}
|
|
62487
|
+
if (positional.length > 0) {
|
|
62488
|
+
opts.pattern = positional[0];
|
|
62489
|
+
opts.searchPaths = positional.slice(1);
|
|
62490
|
+
}
|
|
62491
|
+
return { options: opts };
|
|
62492
|
+
}
|
|
62493
|
+
function globToRegex(pattern) {
|
|
62494
|
+
let regex = "";
|
|
62495
|
+
let i = 0;
|
|
62496
|
+
while (i < pattern.length) {
|
|
62497
|
+
const ch2 = pattern[i];
|
|
62498
|
+
if (ch2 === "*") {
|
|
62499
|
+
if (pattern[i + 1] === "*") {
|
|
62500
|
+
regex += ".*";
|
|
62501
|
+
i += 2;
|
|
62502
|
+
if (pattern[i] === "/") i++;
|
|
62503
|
+
continue;
|
|
62504
|
+
}
|
|
62505
|
+
regex += "[^/]*";
|
|
62506
|
+
} else if (ch2 === "?") {
|
|
62507
|
+
regex += "[^/]";
|
|
62508
|
+
} else if (ch2 === "[") {
|
|
62509
|
+
const close2 = pattern.indexOf("]", i + 1);
|
|
62510
|
+
if (close2 !== -1) {
|
|
62511
|
+
regex += pattern.slice(i, close2 + 1);
|
|
62512
|
+
i = close2 + 1;
|
|
62513
|
+
continue;
|
|
62514
|
+
}
|
|
62515
|
+
regex += "\\[";
|
|
62516
|
+
} else if (ch2 === "{") {
|
|
62517
|
+
const close2 = pattern.indexOf("}", i + 1);
|
|
62518
|
+
if (close2 !== -1) {
|
|
62519
|
+
const alternatives = pattern.slice(i + 1, close2).split(",").map((a) => a.trim());
|
|
62520
|
+
regex += `(?:${alternatives.map(escapeRegex).join("|")})`;
|
|
62521
|
+
i = close2 + 1;
|
|
62522
|
+
continue;
|
|
62523
|
+
}
|
|
62524
|
+
regex += "\\{";
|
|
62525
|
+
} else if (".+^$|()\\".includes(ch2)) {
|
|
62526
|
+
regex += `\\${ch2}`;
|
|
62527
|
+
} else {
|
|
62528
|
+
regex += ch2;
|
|
62529
|
+
}
|
|
62530
|
+
i++;
|
|
62531
|
+
}
|
|
62532
|
+
return new RegExp(`^${regex}$`, "i");
|
|
62533
|
+
}
|
|
62534
|
+
function escapeRegex(s10) {
|
|
62535
|
+
return s10.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
62536
|
+
}
|
|
62537
|
+
function parseIgnorePatterns(content) {
|
|
62538
|
+
const matchers = [];
|
|
62539
|
+
for (const raw of content.split("\n")) {
|
|
62540
|
+
const line = raw.trim();
|
|
62541
|
+
if (!line || line.startsWith("#")) continue;
|
|
62542
|
+
if (line.startsWith("!")) continue;
|
|
62543
|
+
let pattern = line;
|
|
62544
|
+
const dirOnly = pattern.endsWith("/");
|
|
62545
|
+
if (dirOnly) pattern = pattern.slice(0, -1);
|
|
62546
|
+
const re = globToRegex(pattern);
|
|
62547
|
+
matchers.push((relPath, isDir) => {
|
|
62548
|
+
if (dirOnly && !isDir) return false;
|
|
62549
|
+
const basename3 = relPath.split("/").pop() ?? relPath;
|
|
62550
|
+
return re.test(basename3) || re.test(relPath);
|
|
62551
|
+
});
|
|
62552
|
+
}
|
|
62553
|
+
return matchers;
|
|
62554
|
+
}
|
|
62555
|
+
async function loadIgnoreFile(fs, filePath) {
|
|
62556
|
+
try {
|
|
62557
|
+
const content = await fs.readFile(filePath);
|
|
62558
|
+
return parseIgnorePatterns(content);
|
|
62559
|
+
} catch {
|
|
62560
|
+
return [];
|
|
62561
|
+
}
|
|
62562
|
+
}
|
|
62563
|
+
function resolvePath(base, rel) {
|
|
62564
|
+
if (rel.startsWith("/")) return normalizePath2(rel);
|
|
62565
|
+
return normalizePath2(`${base}/${rel}`);
|
|
62566
|
+
}
|
|
62567
|
+
function normalizePath2(p) {
|
|
62568
|
+
const parts = p.split("/").filter(Boolean);
|
|
62569
|
+
const result = [];
|
|
62570
|
+
for (const part of parts) {
|
|
62571
|
+
if (part === "..") result.pop();
|
|
62572
|
+
else if (part !== ".") result.push(part);
|
|
62573
|
+
}
|
|
62574
|
+
return `/${result.join("/")}`;
|
|
62575
|
+
}
|
|
62576
|
+
async function executeFd(args, ctx) {
|
|
62577
|
+
const parsed = parseFdArgs(args);
|
|
62578
|
+
if ("error" in parsed) {
|
|
62579
|
+
if (parsed.error === "__version__") {
|
|
62580
|
+
return { stdout: "fd 10.2.0 (just-bash)\n", stderr: "", exitCode: 0 };
|
|
62581
|
+
}
|
|
62582
|
+
if (parsed.error === "__help__") {
|
|
62583
|
+
return {
|
|
62584
|
+
stdout: [
|
|
62585
|
+
"Usage: fd [OPTIONS] [pattern] [path...]",
|
|
62586
|
+
"",
|
|
62587
|
+
"Options:",
|
|
62588
|
+
" -H, --hidden Include hidden files/directories",
|
|
62589
|
+
" -I, --no-ignore Don't respect .gitignore",
|
|
62590
|
+
" -g, --glob Glob-based search",
|
|
62591
|
+
" -F, --fixed-strings Literal string search",
|
|
62592
|
+
" -t, --type <type> Filter by type: f(ile), d(irectory)",
|
|
62593
|
+
" -e, --extension <ext> Filter by extension",
|
|
62594
|
+
" -E, --exclude <pat> Exclude pattern",
|
|
62595
|
+
" -d, --max-depth <n> Maximum search depth",
|
|
62596
|
+
" --max-results <n> Maximum number of results",
|
|
62597
|
+
" -a, --absolute-path Show absolute paths",
|
|
62598
|
+
" -p, --full-path Match against full path",
|
|
62599
|
+
" --ignore-file <f> Additional ignore file",
|
|
62600
|
+
" --color <when> (always off in browser)",
|
|
62601
|
+
" -1 Stop after first result",
|
|
62602
|
+
""
|
|
62603
|
+
].join("\n"),
|
|
62604
|
+
stderr: "",
|
|
62605
|
+
exitCode: 0
|
|
62606
|
+
};
|
|
62607
|
+
}
|
|
62608
|
+
return { stdout: "", stderr: `error: ${parsed.error}
|
|
62609
|
+
`, exitCode: 1 };
|
|
62610
|
+
}
|
|
62611
|
+
const opts = parsed.options;
|
|
62612
|
+
const fs = ctx.fs;
|
|
62613
|
+
const cwd = ctx.cwd ?? "/";
|
|
62614
|
+
const searchRoots = opts.searchPaths.length > 0 ? opts.searchPaths.map((p) => resolvePath(cwd, p)) : [cwd];
|
|
62615
|
+
let matchRegex = null;
|
|
62616
|
+
if (opts.pattern) {
|
|
62617
|
+
if (opts.fixedStrings) {
|
|
62618
|
+
matchRegex = new RegExp(escapeRegex(opts.pattern), "i");
|
|
62619
|
+
} else if (opts.glob) {
|
|
62620
|
+
matchRegex = globToRegex(opts.pattern);
|
|
62621
|
+
} else {
|
|
62622
|
+
try {
|
|
62623
|
+
matchRegex = new RegExp(opts.pattern, "i");
|
|
62624
|
+
} catch {
|
|
62625
|
+
return { stdout: "", stderr: `error: invalid regex: ${opts.pattern}
|
|
62626
|
+
`, exitCode: 1 };
|
|
62627
|
+
}
|
|
62628
|
+
}
|
|
62629
|
+
}
|
|
62630
|
+
const excludeMatchers = opts.excludes.map((p) => globToRegex(p));
|
|
62631
|
+
const ignoreMatchers = [];
|
|
62632
|
+
if (!opts.noIgnore) {
|
|
62633
|
+
for (const root2 of searchRoots) {
|
|
62634
|
+
const gitignorePath = `${root2}/.gitignore`;
|
|
62635
|
+
const loaded = await loadIgnoreFile(fs, gitignorePath);
|
|
62636
|
+
ignoreMatchers.push(...loaded);
|
|
62637
|
+
}
|
|
62638
|
+
}
|
|
62639
|
+
for (const ignoreFile of opts.ignoreFiles) {
|
|
62640
|
+
const absPath = resolvePath(cwd, ignoreFile);
|
|
62641
|
+
const loaded = await loadIgnoreFile(fs, absPath);
|
|
62642
|
+
ignoreMatchers.push(...loaded);
|
|
62643
|
+
}
|
|
62644
|
+
const results = [];
|
|
62645
|
+
let limitReached = false;
|
|
62646
|
+
async function walk(dirPath, rootPath, depth) {
|
|
62647
|
+
if (limitReached) return;
|
|
62648
|
+
if (depth > opts.maxDepth) return;
|
|
62649
|
+
let entries;
|
|
62650
|
+
try {
|
|
62651
|
+
entries = await fs.readdir(dirPath);
|
|
62652
|
+
} catch {
|
|
62653
|
+
return;
|
|
62654
|
+
}
|
|
62655
|
+
for (const entry of entries) {
|
|
62656
|
+
if (limitReached) return;
|
|
62657
|
+
if (!opts.hidden && entry.startsWith(".")) continue;
|
|
62658
|
+
const fullPath = `${dirPath}/${entry}`;
|
|
62659
|
+
let isDir = false;
|
|
62660
|
+
let isFile = false;
|
|
62661
|
+
try {
|
|
62662
|
+
const st2 = await fs.stat(fullPath);
|
|
62663
|
+
isDir = st2.isDirectory;
|
|
62664
|
+
isFile = st2.isFile;
|
|
62665
|
+
} catch {
|
|
62666
|
+
continue;
|
|
62667
|
+
}
|
|
62668
|
+
const relPath = fullPath.slice(rootPath.length + 1) || entry;
|
|
62669
|
+
if (!opts.noIgnore && ignoreMatchers.some((m) => m(relPath, isDir))) continue;
|
|
62670
|
+
const basename3 = entry;
|
|
62671
|
+
if (excludeMatchers.some((re) => re.test(basename3) || re.test(relPath))) continue;
|
|
62672
|
+
if (opts.typeFilter === "f" && !isFile) {
|
|
62673
|
+
if (isDir) await walk(fullPath, rootPath, depth + 1);
|
|
62674
|
+
continue;
|
|
62675
|
+
}
|
|
62676
|
+
if (opts.typeFilter === "d" && !isDir) continue;
|
|
62677
|
+
if (opts.extensions.length > 0) {
|
|
62678
|
+
const dotIdx = entry.lastIndexOf(".");
|
|
62679
|
+
const ext2 = dotIdx >= 0 ? entry.slice(dotIdx + 1) : "";
|
|
62680
|
+
if (!opts.extensions.some((e10) => e10.toLowerCase() === ext2.toLowerCase())) {
|
|
62681
|
+
if (isDir) await walk(fullPath, rootPath, depth + 1);
|
|
62682
|
+
continue;
|
|
62683
|
+
}
|
|
62684
|
+
}
|
|
62685
|
+
if (matchRegex) {
|
|
62686
|
+
const target = opts.fullPath ? relPath : basename3;
|
|
62687
|
+
if (!matchRegex.test(target)) {
|
|
62688
|
+
if (isDir) await walk(fullPath, rootPath, depth + 1);
|
|
62689
|
+
continue;
|
|
62690
|
+
}
|
|
62691
|
+
}
|
|
62692
|
+
const output = opts.absolutePath ? fullPath : relPath;
|
|
62693
|
+
results.push(output);
|
|
62694
|
+
if (results.length >= opts.maxResults) {
|
|
62695
|
+
limitReached = true;
|
|
62696
|
+
return;
|
|
62697
|
+
}
|
|
62698
|
+
if (isDir) {
|
|
62699
|
+
await walk(fullPath, rootPath, depth + 1);
|
|
62700
|
+
}
|
|
62701
|
+
}
|
|
62702
|
+
}
|
|
62703
|
+
for (const root2 of searchRoots) {
|
|
62704
|
+
if (limitReached) break;
|
|
62705
|
+
try {
|
|
62706
|
+
const st2 = await fs.stat(root2);
|
|
62707
|
+
if (!st2.isDirectory) {
|
|
62708
|
+
return { stdout: "", stderr: `error: '${root2}' is not a directory
|
|
62709
|
+
`, exitCode: 1 };
|
|
62710
|
+
}
|
|
62711
|
+
} catch {
|
|
62712
|
+
return { stdout: "", stderr: `error: '${root2}': No such file or directory
|
|
62713
|
+
`, exitCode: 1 };
|
|
62714
|
+
}
|
|
62715
|
+
if (!opts.noIgnore) {
|
|
62716
|
+
const rootGitignore = `${root2}/.gitignore`;
|
|
62717
|
+
const loaded = await loadIgnoreFile(fs, rootGitignore);
|
|
62718
|
+
if (loaded.length > 0) {
|
|
62719
|
+
ignoreMatchers.push(...loaded);
|
|
62720
|
+
}
|
|
62721
|
+
}
|
|
62722
|
+
await walk(root2, root2, 1);
|
|
62723
|
+
}
|
|
62724
|
+
results.sort();
|
|
62725
|
+
if (results.length === 0) {
|
|
62726
|
+
return { stdout: "", stderr: "", exitCode: 1 };
|
|
62727
|
+
}
|
|
62728
|
+
return { stdout: results.join("\n") + "\n", stderr: "", exitCode: 0 };
|
|
62729
|
+
}
|
|
62730
|
+
|
|
62351
62731
|
// src/browser-bash-session.ts
|
|
62352
62732
|
var DEFAULT_BASH_SHELL_ENV = {
|
|
62353
62733
|
LANG: "C.UTF-8",
|
|
@@ -62401,6 +62781,7 @@ function createBrowserBashSession(options2 = {}) {
|
|
|
62401
62781
|
customCommands: [
|
|
62402
62782
|
Dx("node", async (args, ctx) => almostNodeSession.executeNode(args, ctx)),
|
|
62403
62783
|
Dx("npm", async (args, ctx) => almostNodeSession.executeNpm(args, ctx)),
|
|
62784
|
+
Dx("fd", async (args, ctx) => executeFd(args, ctx)),
|
|
62404
62785
|
...options2.customCommands ?? []
|
|
62405
62786
|
]
|
|
62406
62787
|
});
|
|
@@ -62488,7 +62869,7 @@ async function executeBrowserBash(session, command, options2 = {}) {
|
|
|
62488
62869
|
}
|
|
62489
62870
|
|
|
62490
62871
|
// src/index.ts
|
|
62491
|
-
var AGENT_WEB_OS_VERSION = "0.1.
|
|
62872
|
+
var AGENT_WEB_OS_VERSION = "0.1.17";
|
|
62492
62873
|
console.log(`[agent-web-os] v${AGENT_WEB_OS_VERSION}`);
|
|
62493
62874
|
var getServerBridge2 = getServerBridge;
|
|
62494
62875
|
var resetServerBridge2 = resetServerBridge;
|