agent-web-os 0.1.7 → 0.1.8

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
@@ -163,6 +163,18 @@ declare class AlmostNodeSession {
163
163
  private resolveBinFromPackageJson;
164
164
  private resolveNpmBinPath;
165
165
  private resolveGlobalBinPath;
166
+ /**
167
+ * Patch lru-cache installations so the CJS entry doesn't crash in
168
+ * the browser runtime. lru-cache v11's CJS unconditionally calls
169
+ * `require("node:diagnostics_channel").tracingChannel()` at the
170
+ * module scope. If that throws inside the browser WASM sandbox the
171
+ * entire module fails and `exports.LRUCache` is never assigned,
172
+ * leading to "TypeError: LRUCache is not a constructor".
173
+ *
174
+ * The fix: wrap the `require("node:diagnostics_channel")` call in a
175
+ * try/catch with a no-op fallback so LRUCache initialises safely.
176
+ */
177
+ private patchLruCacheInNodeModules;
166
178
  private registerGlobalBinCommands;
167
179
  private resolveAndRegisterBinCommands;
168
180
  private trackOperation;
package/dist/index.d.ts CHANGED
@@ -163,6 +163,18 @@ declare class AlmostNodeSession {
163
163
  private resolveBinFromPackageJson;
164
164
  private resolveNpmBinPath;
165
165
  private resolveGlobalBinPath;
166
+ /**
167
+ * Patch lru-cache installations so the CJS entry doesn't crash in
168
+ * the browser runtime. lru-cache v11's CJS unconditionally calls
169
+ * `require("node:diagnostics_channel").tracingChannel()` at the
170
+ * module scope. If that throws inside the browser WASM sandbox the
171
+ * entire module fails and `exports.LRUCache` is never assigned,
172
+ * leading to "TypeError: LRUCache is not a constructor".
173
+ *
174
+ * The fix: wrap the `require("node:diagnostics_channel")` call in a
175
+ * try/catch with a no-op fallback so LRUCache initialises safely.
176
+ */
177
+ private patchLruCacheInNodeModules;
166
178
  private registerGlobalBinCommands;
167
179
  private resolveAndRegisterBinCommands;
168
180
  private trackOperation;
package/dist/index.js CHANGED
@@ -55283,6 +55283,58 @@ var AlmostNodeSession = class {
55283
55283
  }
55284
55284
  return null;
55285
55285
  }
55286
+ /**
55287
+ * Patch lru-cache installations so the CJS entry doesn't crash in
55288
+ * the browser runtime. lru-cache v11's CJS unconditionally calls
55289
+ * `require("node:diagnostics_channel").tracingChannel()` at the
55290
+ * module scope. If that throws inside the browser WASM sandbox the
55291
+ * entire module fails and `exports.LRUCache` is never assigned,
55292
+ * leading to "TypeError: LRUCache is not a constructor".
55293
+ *
55294
+ * The fix: wrap the `require("node:diagnostics_channel")` call in a
55295
+ * try/catch with a no-op fallback so LRUCache initialises safely.
55296
+ */
55297
+ patchLruCacheInNodeModules(nodeModulesDir) {
55298
+ const patchFile = (filePath) => {
55299
+ if (!this._vfs.existsSync(filePath)) return;
55300
+ const src = this._vfs.readFileSync(filePath, "utf8");
55301
+ if (!src.includes('require("node:diagnostics_channel")')) return;
55302
+ const patched = src.replace(
55303
+ 'require("node:diagnostics_channel")',
55304
+ '(function(){try{var _dc=require("node:diagnostics_channel");var _ch=_dc.channel("lru-cache:_test");if(typeof _dc.tracingChannel==="function")_dc.tracingChannel("lru-cache:_test");return _dc}catch(_e){return{channel:function(){return{hasSubscribers:false,publish:function(){},subscribe:function(){},unsubscribe:function(){}}},tracingChannel:function(){return{hasSubscribers:false,subscribe:function(){},unsubscribe:function(){}}}}}})()'
55305
+ );
55306
+ if (patched !== src) {
55307
+ this._vfs.writeFileSync(filePath, patched);
55308
+ }
55309
+ };
55310
+ const walkNodeModules = (nmDir) => {
55311
+ if (!this._vfs.existsSync(nmDir)) return;
55312
+ for (const entry of this._vfs.readdirSync(nmDir)) {
55313
+ if (entry === "lru-cache") {
55314
+ const cjsEntry = normalizePath(posixPath.join(nmDir, "lru-cache", "dist", "commonjs", "index.min.js"));
55315
+ patchFile(cjsEntry);
55316
+ const cjsIndex = normalizePath(posixPath.join(nmDir, "lru-cache", "dist", "commonjs", "index.js"));
55317
+ patchFile(cjsIndex);
55318
+ }
55319
+ const nestedNm = normalizePath(posixPath.join(nmDir, entry, "node_modules"));
55320
+ if (this._vfs.existsSync(nestedNm)) {
55321
+ walkNodeModules(nestedNm);
55322
+ }
55323
+ if (entry.startsWith("@")) {
55324
+ const scopeDir = normalizePath(posixPath.join(nmDir, entry));
55325
+ if (this._vfs.existsSync(scopeDir)) {
55326
+ for (const scopedEntry of this._vfs.readdirSync(scopeDir)) {
55327
+ const nestedNm2 = normalizePath(posixPath.join(scopeDir, scopedEntry, "node_modules"));
55328
+ if (this._vfs.existsSync(nestedNm2)) {
55329
+ walkNodeModules(nestedNm2);
55330
+ }
55331
+ }
55332
+ }
55333
+ }
55334
+ }
55335
+ };
55336
+ walkNodeModules(nodeModulesDir);
55337
+ }
55286
55338
  async registerGlobalBinCommands(packageName) {
55287
55339
  if (!this.binCommandRegistrar) return;
55288
55340
  const pkgJsonPath = normalizePath(posixPath.join(GLOBAL_NODE_MODULES_ROOT, packageName, "package.json"));
@@ -55805,6 +55857,7 @@ var AlmostNodeSession = class {
55805
55857
  }
55806
55858
  }
55807
55859
  }
55860
+ this.patchLruCacheInNodeModules(GLOBAL_NODE_MODULES_ROOT);
55808
55861
  result = { stdout, stderr: "", exitCode: 0 };
55809
55862
  } else {
55810
55863
  const packageJsonResult = await this.readPackageJson(cwd);
@@ -55836,6 +55889,8 @@ var AlmostNodeSession = class {
55836
55889
  `;
55837
55890
  }
55838
55891
  }
55892
+ const localNodeModules = normalizePath(posixPath.join(cwd, "node_modules"));
55893
+ this.patchLruCacheInNodeModules(localNodeModules);
55839
55894
  result = { stdout, stderr: "", exitCode: 0 };
55840
55895
  }
55841
55896
  } catch (error) {