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.cjs +55 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +55 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -61100,6 +61100,58 @@ var AlmostNodeSession = class {
|
|
|
61100
61100
|
}
|
|
61101
61101
|
return null;
|
|
61102
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
|
+
}
|
|
61103
61155
|
async registerGlobalBinCommands(packageName) {
|
|
61104
61156
|
if (!this.binCommandRegistrar) return;
|
|
61105
61157
|
const pkgJsonPath = normalizePath(posixPath.join(GLOBAL_NODE_MODULES_ROOT, packageName, "package.json"));
|
|
@@ -61622,6 +61674,7 @@ var AlmostNodeSession = class {
|
|
|
61622
61674
|
}
|
|
61623
61675
|
}
|
|
61624
61676
|
}
|
|
61677
|
+
this.patchLruCacheInNodeModules(GLOBAL_NODE_MODULES_ROOT);
|
|
61625
61678
|
result = { stdout, stderr: "", exitCode: 0 };
|
|
61626
61679
|
} else {
|
|
61627
61680
|
const packageJsonResult = await this.readPackageJson(cwd);
|
|
@@ -61653,6 +61706,8 @@ var AlmostNodeSession = class {
|
|
|
61653
61706
|
`;
|
|
61654
61707
|
}
|
|
61655
61708
|
}
|
|
61709
|
+
const localNodeModules = normalizePath(posixPath.join(cwd, "node_modules"));
|
|
61710
|
+
this.patchLruCacheInNodeModules(localNodeModules);
|
|
61656
61711
|
result = { stdout, stderr: "", exitCode: 0 };
|
|
61657
61712
|
}
|
|
61658
61713
|
} catch (error) {
|