agent-web-os 0.1.10 → 0.1.11
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 +162 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -9
- package/dist/index.d.ts +11 -9
- package/dist/index.js +162 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -61106,37 +61106,176 @@ var AlmostNodeSession = class {
|
|
|
61106
61106
|
return null;
|
|
61107
61107
|
}
|
|
61108
61108
|
/**
|
|
61109
|
-
*
|
|
61110
|
-
* the browser runtime. lru-cache v11's CJS unconditionally calls
|
|
61111
|
-
* `require("node:diagnostics_channel").tracingChannel()` at the
|
|
61112
|
-
* module scope. If that throws inside the browser WASM sandbox the
|
|
61113
|
-
* entire module fails and `exports.LRUCache` is never assigned,
|
|
61114
|
-
* leading to "TypeError: LRUCache is not a constructor".
|
|
61109
|
+
* Replace lru-cache CJS entry points with a browser-safe implementation.
|
|
61115
61110
|
*
|
|
61116
|
-
*
|
|
61117
|
-
*
|
|
61111
|
+
* lru-cache v11's minified CJS uses `require("node:diagnostics_channel")`
|
|
61112
|
+
* and private class fields (`static #t`) which can fail inside the browser
|
|
61113
|
+
* WASM runtime's `eval()` context, leaving `exports.LRUCache` undefined
|
|
61114
|
+
* ("TypeError: LRUCache is not a constructor").
|
|
61115
|
+
*
|
|
61116
|
+
* The fix: overwrite the CJS entry with a clean Map-based LRU cache that
|
|
61117
|
+
* covers the full API surface used by lru-cache consumers (hosted-git-info,
|
|
61118
|
+
* path-scurry, glob, etc.) without any diagnostics_channel dependency or
|
|
61119
|
+
* private class fields.
|
|
61118
61120
|
*/
|
|
61119
61121
|
patchLruCacheInNodeModules(nodeModulesDir) {
|
|
61120
|
-
const
|
|
61121
|
-
|
|
61122
|
-
|
|
61123
|
-
|
|
61124
|
-
|
|
61125
|
-
|
|
61126
|
-
|
|
61127
|
-
|
|
61128
|
-
|
|
61129
|
-
|
|
61122
|
+
const lruCacheShim = `"use strict";
|
|
61123
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61124
|
+
exports.LRUCache = void 0;
|
|
61125
|
+
var LRUCache = (function () {
|
|
61126
|
+
function LRUCache(options) {
|
|
61127
|
+
if (typeof options === "number") options = { max: options };
|
|
61128
|
+
if (!options) options = {};
|
|
61129
|
+
this._max = options.max || Infinity;
|
|
61130
|
+
this._maxSize = options.maxSize || 0;
|
|
61131
|
+
this._sizeCalculation = options.sizeCalculation || null;
|
|
61132
|
+
this._dispose = options.dispose || null;
|
|
61133
|
+
this._allowStale = !!options.allowStale;
|
|
61134
|
+
this._ttl = options.ttl || 0;
|
|
61135
|
+
this._noUpdateTTL = !!options.noUpdateTTL;
|
|
61136
|
+
this._map = new Map();
|
|
61137
|
+
this._order = [];
|
|
61138
|
+
this._sizes = new Map();
|
|
61139
|
+
this._totalSize = 0;
|
|
61140
|
+
this._timers = new Map();
|
|
61141
|
+
}
|
|
61142
|
+
Object.defineProperty(LRUCache.prototype, "size", { get: function () { return this._map.size; } });
|
|
61143
|
+
Object.defineProperty(LRUCache.prototype, "max", { get: function () { return this._max; } });
|
|
61144
|
+
Object.defineProperty(LRUCache.prototype, "maxSize", { get: function () { return this._maxSize; } });
|
|
61145
|
+
Object.defineProperty(LRUCache.prototype, "calculatedSize", { get: function () { return this._totalSize; } });
|
|
61146
|
+
LRUCache.prototype._touch = function (key) {
|
|
61147
|
+
var idx = this._order.indexOf(key);
|
|
61148
|
+
if (idx > -1) this._order.splice(idx, 1);
|
|
61149
|
+
this._order.push(key);
|
|
61150
|
+
};
|
|
61151
|
+
LRUCache.prototype._evict = function () {
|
|
61152
|
+
while (this._order.length > 0 && (this._map.size > this._max || (this._maxSize > 0 && this._totalSize > this._maxSize))) {
|
|
61153
|
+
var oldest = this._order.shift();
|
|
61154
|
+
if (oldest !== undefined && this._map.has(oldest)) {
|
|
61155
|
+
var val = this._map.get(oldest);
|
|
61156
|
+
this._map.delete(oldest);
|
|
61157
|
+
if (this._sizes.has(oldest)) { this._totalSize -= this._sizes.get(oldest); this._sizes.delete(oldest); }
|
|
61158
|
+
if (this._timers.has(oldest)) { clearTimeout(this._timers.get(oldest)); this._timers.delete(oldest); }
|
|
61159
|
+
if (this._dispose) this._dispose(val, oldest, "evict");
|
|
61160
|
+
}
|
|
61161
|
+
}
|
|
61162
|
+
};
|
|
61163
|
+
LRUCache.prototype._isStale = function (key) {
|
|
61164
|
+
return false; // TTL timers handle expiry via delete
|
|
61165
|
+
};
|
|
61166
|
+
LRUCache.prototype.set = function (key, value, options) {
|
|
61167
|
+
if (value === undefined) { this.delete(key); return this; }
|
|
61168
|
+
var opts = options || {};
|
|
61169
|
+
var size = 0;
|
|
61170
|
+
if (this._maxSize > 0) {
|
|
61171
|
+
size = opts.size || 0;
|
|
61172
|
+
if (!size && this._sizeCalculation) size = this._sizeCalculation(value, key);
|
|
61173
|
+
if (size > this._maxSize) return this;
|
|
61174
|
+
}
|
|
61175
|
+
if (this._map.has(key)) {
|
|
61176
|
+
var old = this._map.get(key);
|
|
61177
|
+
if (this._sizes.has(key)) { this._totalSize -= this._sizes.get(key); }
|
|
61178
|
+
if (this._timers.has(key)) { clearTimeout(this._timers.get(key)); this._timers.delete(key); }
|
|
61179
|
+
if (this._dispose && !opts.noDisposeOnSet) this._dispose(old, key, "set");
|
|
61180
|
+
}
|
|
61181
|
+
this._map.set(key, value);
|
|
61182
|
+
this._touch(key);
|
|
61183
|
+
if (this._maxSize > 0 && size > 0) { this._sizes.set(key, size); this._totalSize += size; }
|
|
61184
|
+
var ttl = opts.ttl !== undefined ? opts.ttl : this._ttl;
|
|
61185
|
+
if (ttl > 0) {
|
|
61186
|
+
var self = this;
|
|
61187
|
+
this._timers.set(key, setTimeout(function () { self.delete(key); }, ttl));
|
|
61188
|
+
}
|
|
61189
|
+
this._evict();
|
|
61190
|
+
return this;
|
|
61191
|
+
};
|
|
61192
|
+
LRUCache.prototype.get = function (key, options) {
|
|
61193
|
+
if (!this._map.has(key)) return undefined;
|
|
61194
|
+
var value = this._map.get(key);
|
|
61195
|
+
this._touch(key);
|
|
61196
|
+
return value;
|
|
61197
|
+
};
|
|
61198
|
+
LRUCache.prototype.peek = function (key) {
|
|
61199
|
+
return this._map.get(key);
|
|
61200
|
+
};
|
|
61201
|
+
LRUCache.prototype.has = function (key) {
|
|
61202
|
+
return this._map.has(key);
|
|
61203
|
+
};
|
|
61204
|
+
LRUCache.prototype.delete = function (key) {
|
|
61205
|
+
if (!this._map.has(key)) return false;
|
|
61206
|
+
var val = this._map.get(key);
|
|
61207
|
+
this._map.delete(key);
|
|
61208
|
+
var idx = this._order.indexOf(key);
|
|
61209
|
+
if (idx > -1) this._order.splice(idx, 1);
|
|
61210
|
+
if (this._sizes.has(key)) { this._totalSize -= this._sizes.get(key); this._sizes.delete(key); }
|
|
61211
|
+
if (this._timers.has(key)) { clearTimeout(this._timers.get(key)); this._timers.delete(key); }
|
|
61212
|
+
if (this._dispose) this._dispose(val, key, "delete");
|
|
61213
|
+
return true;
|
|
61214
|
+
};
|
|
61215
|
+
LRUCache.prototype.clear = function () {
|
|
61216
|
+
var self = this;
|
|
61217
|
+
if (this._dispose) {
|
|
61218
|
+
this._map.forEach(function (val, key) { self._dispose(val, key, "delete"); });
|
|
61219
|
+
}
|
|
61220
|
+
this._timers.forEach(function (t) { clearTimeout(t); });
|
|
61221
|
+
this._map.clear();
|
|
61222
|
+
this._order.length = 0;
|
|
61223
|
+
this._sizes.clear();
|
|
61224
|
+
this._totalSize = 0;
|
|
61225
|
+
this._timers.clear();
|
|
61226
|
+
};
|
|
61227
|
+
LRUCache.prototype.keys = function () { return this._map.keys(); };
|
|
61228
|
+
LRUCache.prototype.values = function () { return this._map.values(); };
|
|
61229
|
+
LRUCache.prototype.entries = function () { return this._map.entries(); };
|
|
61230
|
+
LRUCache.prototype.find = function (fn, options) {
|
|
61231
|
+
for (var it = this._map.entries(), r; !(r = it.next()).done;) {
|
|
61232
|
+
if (fn(r.value[1], r.value[0], this)) return this.get(r.value[0], options);
|
|
61233
|
+
}
|
|
61234
|
+
};
|
|
61235
|
+
LRUCache.prototype.forEach = function (fn, thisArg) {
|
|
61236
|
+
var self = this;
|
|
61237
|
+
this._map.forEach(function (val, key) { fn.call(thisArg || self, val, key, self); });
|
|
61238
|
+
};
|
|
61239
|
+
LRUCache.prototype.dump = function () { return []; };
|
|
61240
|
+
LRUCache.prototype.load = function (arr) {
|
|
61241
|
+
this.clear();
|
|
61242
|
+
for (var i = 0; i < arr.length; i++) { this.set(arr[i][0], arr[i][1].value, arr[i][1]); }
|
|
61243
|
+
};
|
|
61244
|
+
LRUCache.prototype.pop = function () {
|
|
61245
|
+
if (this._order.length === 0) return undefined;
|
|
61246
|
+
var oldest = this._order[0];
|
|
61247
|
+
var val = this._map.get(oldest);
|
|
61248
|
+
this.delete(oldest);
|
|
61249
|
+
return val;
|
|
61250
|
+
};
|
|
61251
|
+
LRUCache.prototype.purgeStale = function () { return false; };
|
|
61252
|
+
LRUCache.prototype.getRemainingTTL = function (key) { return this._map.has(key) ? Infinity : 0; };
|
|
61253
|
+
LRUCache.prototype.info = function (key) {
|
|
61254
|
+
if (!this._map.has(key)) return undefined;
|
|
61255
|
+
return { value: this._map.get(key) };
|
|
61256
|
+
};
|
|
61257
|
+
LRUCache.prototype[Symbol.iterator] = function () { return this._map.entries(); };
|
|
61258
|
+
LRUCache.prototype[Symbol.toStringTag] = "LRUCache";
|
|
61259
|
+
return LRUCache;
|
|
61260
|
+
})();
|
|
61261
|
+
exports.LRUCache = LRUCache;
|
|
61262
|
+
`;
|
|
61263
|
+
const patchDir = (lruDir) => {
|
|
61264
|
+
const cjsPaths = [
|
|
61265
|
+
normalizePath(posixPath.join(lruDir, "dist", "commonjs", "index.min.js")),
|
|
61266
|
+
normalizePath(posixPath.join(lruDir, "dist", "commonjs", "index.js"))
|
|
61267
|
+
];
|
|
61268
|
+
for (const p of cjsPaths) {
|
|
61269
|
+
if (this._vfs.existsSync(p)) {
|
|
61270
|
+
this._vfs.writeFileSync(p, lruCacheShim);
|
|
61271
|
+
}
|
|
61130
61272
|
}
|
|
61131
61273
|
};
|
|
61132
61274
|
const walkNodeModules = (nmDir) => {
|
|
61133
61275
|
if (!this._vfs.existsSync(nmDir)) return;
|
|
61134
61276
|
for (const entry of this._vfs.readdirSync(nmDir)) {
|
|
61135
61277
|
if (entry === "lru-cache") {
|
|
61136
|
-
|
|
61137
|
-
patchFile(cjsEntry);
|
|
61138
|
-
const cjsIndex = normalizePath(posixPath.join(nmDir, "lru-cache", "dist", "commonjs", "index.js"));
|
|
61139
|
-
patchFile(cjsIndex);
|
|
61278
|
+
patchDir(normalizePath(posixPath.join(nmDir, "lru-cache")));
|
|
61140
61279
|
}
|
|
61141
61280
|
const nestedNm = normalizePath(posixPath.join(nmDir, entry, "node_modules"));
|
|
61142
61281
|
if (this._vfs.existsSync(nestedNm)) {
|
|
@@ -62277,7 +62416,7 @@ async function executeBrowserBash(session, command, options2 = {}) {
|
|
|
62277
62416
|
}
|
|
62278
62417
|
|
|
62279
62418
|
// src/index.ts
|
|
62280
|
-
var AGENT_WEB_OS_VERSION = "0.1.
|
|
62419
|
+
var AGENT_WEB_OS_VERSION = "0.1.11";
|
|
62281
62420
|
console.log(`[agent-web-os] v${AGENT_WEB_OS_VERSION}`);
|
|
62282
62421
|
var getServerBridge2 = getServerBridge;
|
|
62283
62422
|
var resetServerBridge2 = resetServerBridge;
|