agent-web-os 0.1.6 → 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.cjs CHANGED
@@ -60651,6 +60651,29 @@ var AlmostNodeSession = class {
60651
60651
  "/node_modules/stream/promises/index.js",
60652
60652
  "var stream = require('stream');\nmodule.exports = stream.promises || {};"
60653
60653
  );
60654
+ this._vfs.mkdirSync("/node_modules/stream/web", { recursive: true });
60655
+ this._vfs.writeFileSync("/node_modules/stream/web/package.json", JSON.stringify({
60656
+ name: "stream-web",
60657
+ version: "0.0.1",
60658
+ main: "index.js"
60659
+ }));
60660
+ this._vfs.writeFileSync("/node_modules/stream/web/index.js", [
60661
+ "// Web Streams API shim \u2014 re-exports browser globals",
60662
+ "module.exports = {",
60663
+ " ReadableStream: typeof ReadableStream !== 'undefined' ? ReadableStream : undefined,",
60664
+ " ReadableStreamDefaultReader: typeof ReadableStreamDefaultReader !== 'undefined' ? ReadableStreamDefaultReader : undefined,",
60665
+ " ReadableStreamBYOBReader: typeof ReadableStreamBYOBReader !== 'undefined' ? ReadableStreamBYOBReader : undefined,",
60666
+ " ReadableStreamDefaultController: typeof ReadableStreamDefaultController !== 'undefined' ? ReadableStreamDefaultController : undefined,",
60667
+ " ReadableByteStreamController: typeof ReadableByteStreamController !== 'undefined' ? ReadableByteStreamController : undefined,",
60668
+ " WritableStream: typeof WritableStream !== 'undefined' ? WritableStream : undefined,",
60669
+ " WritableStreamDefaultWriter: typeof WritableStreamDefaultWriter !== 'undefined' ? WritableStreamDefaultWriter : undefined,",
60670
+ " WritableStreamDefaultController: typeof WritableStreamDefaultController !== 'undefined' ? WritableStreamDefaultController : undefined,",
60671
+ " TransformStream: typeof TransformStream !== 'undefined' ? TransformStream : undefined,",
60672
+ " TransformStreamDefaultController: typeof TransformStreamDefaultController !== 'undefined' ? TransformStreamDefaultController : undefined,",
60673
+ " ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy !== 'undefined' ? ByteLengthQueuingStrategy : undefined,",
60674
+ " CountQueuingStrategy: typeof CountQueuingStrategy !== 'undefined' ? CountQueuingStrategy : undefined,",
60675
+ "};"
60676
+ ].join("\n"));
60654
60677
  this.disposeObservableSubscription = this.fs.subscribe((event) => {
60655
60678
  void this.trackOperation((async () => {
60656
60679
  if (!this.initialized || this.suppressObservableMirrorCount > 0) {
@@ -61077,6 +61100,58 @@ var AlmostNodeSession = class {
61077
61100
  }
61078
61101
  return null;
61079
61102
  }
61103
+ /**
61104
+ * Patch lru-cache installations so the CJS entry doesn't crash in
61105
+ * the browser runtime. lru-cache v11's CJS unconditionally calls
61106
+ * `require("node:diagnostics_channel").tracingChannel()` at the
61107
+ * module scope. If that throws inside the browser WASM sandbox the
61108
+ * entire module fails and `exports.LRUCache` is never assigned,
61109
+ * leading to "TypeError: LRUCache is not a constructor".
61110
+ *
61111
+ * The fix: wrap the `require("node:diagnostics_channel")` call in a
61112
+ * try/catch with a no-op fallback so LRUCache initialises safely.
61113
+ */
61114
+ patchLruCacheInNodeModules(nodeModulesDir) {
61115
+ const patchFile = (filePath) => {
61116
+ if (!this._vfs.existsSync(filePath)) return;
61117
+ const src = this._vfs.readFileSync(filePath, "utf8");
61118
+ if (!src.includes('require("node:diagnostics_channel")')) return;
61119
+ const patched = src.replace(
61120
+ 'require("node:diagnostics_channel")',
61121
+ '(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(){}}}}}})()'
61122
+ );
61123
+ if (patched !== src) {
61124
+ this._vfs.writeFileSync(filePath, patched);
61125
+ }
61126
+ };
61127
+ const walkNodeModules = (nmDir) => {
61128
+ if (!this._vfs.existsSync(nmDir)) return;
61129
+ for (const entry of this._vfs.readdirSync(nmDir)) {
61130
+ if (entry === "lru-cache") {
61131
+ const cjsEntry = normalizePath(posixPath.join(nmDir, "lru-cache", "dist", "commonjs", "index.min.js"));
61132
+ patchFile(cjsEntry);
61133
+ const cjsIndex = normalizePath(posixPath.join(nmDir, "lru-cache", "dist", "commonjs", "index.js"));
61134
+ patchFile(cjsIndex);
61135
+ }
61136
+ const nestedNm = normalizePath(posixPath.join(nmDir, entry, "node_modules"));
61137
+ if (this._vfs.existsSync(nestedNm)) {
61138
+ walkNodeModules(nestedNm);
61139
+ }
61140
+ if (entry.startsWith("@")) {
61141
+ const scopeDir = normalizePath(posixPath.join(nmDir, entry));
61142
+ if (this._vfs.existsSync(scopeDir)) {
61143
+ for (const scopedEntry of this._vfs.readdirSync(scopeDir)) {
61144
+ const nestedNm2 = normalizePath(posixPath.join(scopeDir, scopedEntry, "node_modules"));
61145
+ if (this._vfs.existsSync(nestedNm2)) {
61146
+ walkNodeModules(nestedNm2);
61147
+ }
61148
+ }
61149
+ }
61150
+ }
61151
+ }
61152
+ };
61153
+ walkNodeModules(nodeModulesDir);
61154
+ }
61080
61155
  async registerGlobalBinCommands(packageName) {
61081
61156
  if (!this.binCommandRegistrar) return;
61082
61157
  const pkgJsonPath = normalizePath(posixPath.join(GLOBAL_NODE_MODULES_ROOT, packageName, "package.json"));
@@ -61599,6 +61674,7 @@ var AlmostNodeSession = class {
61599
61674
  }
61600
61675
  }
61601
61676
  }
61677
+ this.patchLruCacheInNodeModules(GLOBAL_NODE_MODULES_ROOT);
61602
61678
  result = { stdout, stderr: "", exitCode: 0 };
61603
61679
  } else {
61604
61680
  const packageJsonResult = await this.readPackageJson(cwd);
@@ -61630,6 +61706,8 @@ var AlmostNodeSession = class {
61630
61706
  `;
61631
61707
  }
61632
61708
  }
61709
+ const localNodeModules = normalizePath(posixPath.join(cwd, "node_modules"));
61710
+ this.patchLruCacheInNodeModules(localNodeModules);
61633
61711
  result = { stdout, stderr: "", exitCode: 0 };
61634
61712
  }
61635
61713
  } catch (error) {