agent-web-os 0.1.4 → 0.1.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.
package/dist/index.d.cts CHANGED
@@ -130,14 +130,6 @@ declare class AlmostNodeSession {
130
130
  * package directory directly.
131
131
  */
132
132
  private resolveBarePkgEntryCache;
133
- /**
134
- * Packages whose imports are handled by the browser import map.
135
- * These are NOT rewritten to /node_modules/... paths.
136
- * Now empty: react/react-dom are served from node_modules via our
137
- * CJS→ESM shim, which supports the actual installed version rather
138
- * than the outdated esm.sh CDN pinned in almostnode's import map.
139
- */
140
- private importMapPackages;
141
133
  private parseCachedPackageJson;
142
134
  private transformTextWithCache;
143
135
  private resolveBarePkgEntry;
@@ -171,7 +163,6 @@ declare class AlmostNodeSession {
171
163
  private resolveBinFromPackageJson;
172
164
  private resolveNpmBinPath;
173
165
  private resolveGlobalBinPath;
174
- private extractBinNames;
175
166
  private registerGlobalBinCommands;
176
167
  private resolveAndRegisterBinCommands;
177
168
  private trackOperation;
package/dist/index.d.ts CHANGED
@@ -130,14 +130,6 @@ declare class AlmostNodeSession {
130
130
  * package directory directly.
131
131
  */
132
132
  private resolveBarePkgEntryCache;
133
- /**
134
- * Packages whose imports are handled by the browser import map.
135
- * These are NOT rewritten to /node_modules/... paths.
136
- * Now empty: react/react-dom are served from node_modules via our
137
- * CJS→ESM shim, which supports the actual installed version rather
138
- * than the outdated esm.sh CDN pinned in almostnode's import map.
139
- */
140
- private importMapPackages;
141
133
  private parseCachedPackageJson;
142
134
  private transformTextWithCache;
143
135
  private resolveBarePkgEntry;
@@ -171,7 +163,6 @@ declare class AlmostNodeSession {
171
163
  private resolveBinFromPackageJson;
172
164
  private resolveNpmBinPath;
173
165
  private resolveGlobalBinPath;
174
- private extractBinNames;
175
166
  private registerGlobalBinCommands;
176
167
  private resolveAndRegisterBinCommands;
177
168
  private trackOperation;
package/dist/index.js CHANGED
@@ -36543,19 +36543,6 @@ function assertObservableInMemoryFs(value) {
36543
36543
  }
36544
36544
  return value;
36545
36545
  }
36546
- function formatChangeEventForLog(event) {
36547
- const previousPathSuffix = event.previousPath ? ` (from ${event.previousPath})` : "";
36548
- return `[ObservableInMemoryFs] ${event.event} ${event.entryType} ${event.path}${previousPathSuffix}`;
36549
- }
36550
- function normalizeEntryType(stat) {
36551
- if (stat.isDirectory) {
36552
- return "directory";
36553
- }
36554
- if (stat.isSymbolicLink) {
36555
- return "symlink";
36556
- }
36557
- return "file";
36558
- }
36559
36546
  async function readPathState(fs, path2) {
36560
36547
  const exists = await fs.exists(path2);
36561
36548
  if (!exists) {
@@ -36568,35 +36555,19 @@ async function readPathState(fs, path2) {
36568
36555
  };
36569
36556
  }
36570
36557
  const stat = await fs.lstat(path2);
36558
+ const entryType = stat.isDirectory ? "directory" : stat.isSymbolicLink ? "symlink" : "file";
36571
36559
  return {
36572
36560
  exists: true,
36573
- entryType: normalizeEntryType(stat)
36561
+ entryType
36574
36562
  };
36575
36563
  }
36576
36564
  function mapAddEvent(entryType) {
36577
36565
  return entryType === "directory" ? "addDir" : "add";
36578
36566
  }
36579
- function mapUnlinkEvent(entryType) {
36580
- return entryType === "directory" ? "unlinkDir" : "unlink";
36581
- }
36582
36567
  function normalizeFsPathForLogScope(fsPath) {
36583
36568
  const normalized = posixPath.normalize(fsPath);
36584
36569
  return normalized === "." ? "/" : normalized;
36585
36570
  }
36586
- function createWorkspacePathFilter(workspaceRoot) {
36587
- const normalizedWorkspaceRoot = normalizeFsPathForLogScope(workspaceRoot);
36588
- return (fsPath) => {
36589
- const normalizedPath = normalizeFsPathForLogScope(fsPath);
36590
- if (normalizedPath !== normalizedWorkspaceRoot && !normalizedPath.startsWith(`${normalizedWorkspaceRoot}/`)) {
36591
- return false;
36592
- }
36593
- const relativePath = posixPath.relative(normalizedWorkspaceRoot, normalizedPath);
36594
- if (!relativePath || relativePath === ".") {
36595
- return true;
36596
- }
36597
- return relativePath.split("/").every((segment) => segment.length > 0 && !segment.startsWith("."));
36598
- };
36599
- }
36600
36571
  var ObservableInMemoryFs = class extends Ir {
36601
36572
  listeners;
36602
36573
  lazyPaths = /* @__PURE__ */ new Set();
@@ -36608,7 +36579,18 @@ var ObservableInMemoryFs = class extends Ir {
36608
36579
  constructor(options2) {
36609
36580
  super();
36610
36581
  this.consoleLogChanges = options2?.consoleLogChanges ?? false;
36611
- this.isLoggableWorkspacePath = createWorkspacePathFilter(options2?.workspaceRoot ?? "/");
36582
+ const normalizedWorkspaceRoot = normalizeFsPathForLogScope(options2?.workspaceRoot ?? "/");
36583
+ this.isLoggableWorkspacePath = (fsPath) => {
36584
+ const normalizedPath = normalizeFsPathForLogScope(fsPath);
36585
+ if (normalizedPath !== normalizedWorkspaceRoot && !normalizedPath.startsWith(`${normalizedWorkspaceRoot}/`)) {
36586
+ return false;
36587
+ }
36588
+ const relativePath = posixPath.relative(normalizedWorkspaceRoot, normalizedPath);
36589
+ if (!relativePath || relativePath === ".") {
36590
+ return true;
36591
+ }
36592
+ return relativePath.split("/").every((segment) => segment.length > 0 && !segment.startsWith("."));
36593
+ };
36612
36594
  }
36613
36595
  isPathLazy(filePath) {
36614
36596
  return this.lazyPaths.has(normalizeFsPathForLogScope(filePath));
@@ -36680,7 +36662,7 @@ var ObservableInMemoryFs = class extends Ir {
36680
36662
  emit(event, options2) {
36681
36663
  const shouldConsoleLog = options2?.shouldConsoleLog ?? this.shouldConsoleLogChangeEvent(event);
36682
36664
  if (this.consoleLogChanges && shouldConsoleLog && !this.areConsoleLogsSuppressed()) {
36683
- console.log(formatChangeEventForLog(event));
36665
+ console.log(`[ObservableInMemoryFs] ${event.event} ${event.entryType} ${event.path}${event.previousPath ? ` (from ${event.previousPath})` : ""}`);
36684
36666
  }
36685
36667
  if (!this.listeners) {
36686
36668
  return;
@@ -36757,7 +36739,7 @@ var ObservableInMemoryFs = class extends Ir {
36757
36739
  return;
36758
36740
  }
36759
36741
  this.emit({
36760
- event: mapUnlinkEvent(previous.entryType),
36742
+ event: previous.entryType === "directory" ? "unlinkDir" : "unlink",
36761
36743
  path: path2,
36762
36744
  entryType: previous.entryType
36763
36745
  }, options2);
@@ -54772,6 +54754,66 @@ var AlmostNodeSession = class {
54772
54754
  constructor(fs) {
54773
54755
  this.fs = fs;
54774
54756
  this._vfs.mkdirSync(ALMOSTNODE_INTERNAL_ROOT, { recursive: true });
54757
+ this._vfs.mkdirSync("/node_modules/constants", { recursive: true });
54758
+ this._vfs.writeFileSync("/node_modules/constants/package.json", JSON.stringify({
54759
+ name: "constants",
54760
+ version: "0.0.1",
54761
+ main: "index.js"
54762
+ }));
54763
+ this._vfs.writeFileSync("/node_modules/constants/index.js", [
54764
+ "// Node.js `constants` shim (os.constants + fs.constants)",
54765
+ "var os = require('os');",
54766
+ "var constants = {};",
54767
+ "if (os.constants) {",
54768
+ " if (os.constants.signals) Object.assign(constants, os.constants.signals);",
54769
+ " if (os.constants.errno) Object.assign(constants, os.constants.errno);",
54770
+ " if (os.constants.priority) Object.assign(constants, os.constants.priority);",
54771
+ "}",
54772
+ "// Common fs.constants used by npm packages",
54773
+ "constants.O_RDONLY = 0;",
54774
+ "constants.O_WRONLY = 1;",
54775
+ "constants.O_RDWR = 2;",
54776
+ "constants.O_CREAT = 64;",
54777
+ "constants.O_EXCL = 128;",
54778
+ "constants.O_TRUNC = 512;",
54779
+ "constants.O_APPEND = 1024;",
54780
+ "constants.O_DIRECTORY = 65536;",
54781
+ "constants.O_NOFOLLOW = 131072;",
54782
+ "constants.O_SYNC = 1052672;",
54783
+ "constants.O_SYMLINK = 2097152;",
54784
+ "constants.O_NONBLOCK = 2048;",
54785
+ "constants.S_IFMT = 61440;",
54786
+ "constants.S_IFREG = 32768;",
54787
+ "constants.S_IFDIR = 16384;",
54788
+ "constants.S_IFCHR = 8192;",
54789
+ "constants.S_IFBLK = 24576;",
54790
+ "constants.S_IFIFO = 4096;",
54791
+ "constants.S_IFLNK = 40960;",
54792
+ "constants.S_IFSOCK = 49152;",
54793
+ "constants.S_IRWXU = 448;",
54794
+ "constants.S_IRUSR = 256;",
54795
+ "constants.S_IWUSR = 128;",
54796
+ "constants.S_IXUSR = 64;",
54797
+ "constants.S_IRWXG = 56;",
54798
+ "constants.S_IRGRP = 32;",
54799
+ "constants.S_IWGRP = 16;",
54800
+ "constants.S_IXGRP = 8;",
54801
+ "constants.S_IRWXO = 7;",
54802
+ "constants.S_IROTH = 4;",
54803
+ "constants.S_IWOTH = 2;",
54804
+ "constants.S_IXOTH = 1;",
54805
+ "constants.F_OK = 0;",
54806
+ "constants.R_OK = 4;",
54807
+ "constants.W_OK = 2;",
54808
+ "constants.X_OK = 1;",
54809
+ "constants.COPYFILE_EXCL = 1;",
54810
+ "constants.COPYFILE_FICLONE = 2;",
54811
+ "constants.COPYFILE_FICLONE_FORCE = 4;",
54812
+ "constants.UV_FS_COPYFILE_EXCL = 1;",
54813
+ "constants.UV_FS_COPYFILE_FICLONE = 2;",
54814
+ "constants.UV_FS_COPYFILE_FICLONE_FORCE = 4;",
54815
+ "module.exports = constants;"
54816
+ ].join("\n"));
54775
54817
  this.disposeObservableSubscription = this.fs.subscribe((event) => {
54776
54818
  void this.trackOperation((async () => {
54777
54819
  if (!this.initialized || this.suppressObservableMirrorCount > 0) {
@@ -54844,14 +54886,6 @@ var AlmostNodeSession = class {
54844
54886
  * package directory directly.
54845
54887
  */
54846
54888
  resolveBarePkgEntryCache = /* @__PURE__ */ new Map();
54847
- /**
54848
- * Packages whose imports are handled by the browser import map.
54849
- * These are NOT rewritten to /node_modules/... paths.
54850
- * Now empty: react/react-dom are served from node_modules via our
54851
- * CJS→ESM shim, which supports the actual installed version rather
54852
- * than the outdated esm.sh CDN pinned in almostnode's import map.
54853
- */
54854
- importMapPackages = /* @__PURE__ */ new Set();
54855
54889
  parseCachedPackageJson(packageJsonPath, raw) {
54856
54890
  const cached = this.parsedPackageJsonCache.get(packageJsonPath);
54857
54891
  if (cached && cached.raw === raw) {
@@ -54900,7 +54934,6 @@ var AlmostNodeSession = class {
54900
54934
  subPath = specifier.slice(slashIdx + 1);
54901
54935
  }
54902
54936
  }
54903
- if (this.importMapPackages.has(pkgName)) return null;
54904
54937
  const nodeModulesPath = `${root2}/node_modules/${pkgName}`;
54905
54938
  const pkgJsonPath = `${nodeModulesPath}/package.json`;
54906
54939
  let pkgJson = null;
@@ -55207,16 +55240,6 @@ var AlmostNodeSession = class {
55207
55240
  }
55208
55241
  return null;
55209
55242
  }
55210
- extractBinNames(pkgJson) {
55211
- if (typeof pkgJson.bin === "string") {
55212
- const name = typeof pkgJson.name === "string" ? pkgJson.name.split("/").pop() ?? "" : "";
55213
- return name ? [name] : [];
55214
- }
55215
- if (typeof pkgJson.bin === "object" && pkgJson.bin !== null) {
55216
- return Object.keys(pkgJson.bin);
55217
- }
55218
- return [];
55219
- }
55220
55243
  async registerGlobalBinCommands(packageName) {
55221
55244
  if (!this.binCommandRegistrar) return;
55222
55245
  const pkgJsonPath = normalizePath(posixPath.join(GLOBAL_NODE_MODULES_ROOT, packageName, "package.json"));
@@ -55225,7 +55248,15 @@ var AlmostNodeSession = class {
55225
55248
  const raw = this._vfs.readFileSync(pkgJsonPath, "utf8");
55226
55249
  const pkgJson = this.parseCachedPackageJson(pkgJsonPath, raw);
55227
55250
  if (!pkgJson) return;
55228
- const binNames = this.extractBinNames(pkgJson);
55251
+ let binNames;
55252
+ if (typeof pkgJson.bin === "string") {
55253
+ const name = typeof pkgJson.name === "string" ? pkgJson.name.split("/").pop() ?? "" : "";
55254
+ binNames = name ? [name] : [];
55255
+ } else if (typeof pkgJson.bin === "object" && pkgJson.bin !== null) {
55256
+ binNames = Object.keys(pkgJson.bin);
55257
+ } else {
55258
+ binNames = [];
55259
+ }
55229
55260
  for (const binName of binNames) {
55230
55261
  if (this.registeredBinCommands.has(binName)) continue;
55231
55262
  this.registeredBinCommands.add(binName);