agent-web-os 0.1.9 → 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 +164 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -9
- package/dist/index.d.ts +13 -9
- package/dist/index.js +164 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -166,15 +166,17 @@ declare class AlmostNodeSession {
|
|
|
166
166
|
private resolveNpmBinPath;
|
|
167
167
|
private resolveGlobalBinPath;
|
|
168
168
|
/**
|
|
169
|
-
*
|
|
170
|
-
* the browser runtime. lru-cache v11's CJS unconditionally calls
|
|
171
|
-
* `require("node:diagnostics_channel").tracingChannel()` at the
|
|
172
|
-
* module scope. If that throws inside the browser WASM sandbox the
|
|
173
|
-
* entire module fails and `exports.LRUCache` is never assigned,
|
|
174
|
-
* leading to "TypeError: LRUCache is not a constructor".
|
|
169
|
+
* Replace lru-cache CJS entry points with a browser-safe implementation.
|
|
175
170
|
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
171
|
+
* lru-cache v11's minified CJS uses `require("node:diagnostics_channel")`
|
|
172
|
+
* and private class fields (`static #t`) which can fail inside the browser
|
|
173
|
+
* WASM runtime's `eval()` context, leaving `exports.LRUCache` undefined
|
|
174
|
+
* ("TypeError: LRUCache is not a constructor").
|
|
175
|
+
*
|
|
176
|
+
* The fix: overwrite the CJS entry with a clean Map-based LRU cache that
|
|
177
|
+
* covers the full API surface used by lru-cache consumers (hosted-git-info,
|
|
178
|
+
* path-scurry, glob, etc.) without any diagnostics_channel dependency or
|
|
179
|
+
* private class fields.
|
|
178
180
|
*/
|
|
179
181
|
private patchLruCacheInNodeModules;
|
|
180
182
|
private registerGlobalBinCommands;
|
|
@@ -249,6 +251,8 @@ declare function createBrowserBashSession(options?: BrowserBashSessionOptions):
|
|
|
249
251
|
/** Execute a bash command and return a ToolResult */
|
|
250
252
|
declare function executeBrowserBash(session: BrowserBashSession, command: string, options?: ExecuteBrowserBashOptions): Promise<ToolResult>;
|
|
251
253
|
|
|
254
|
+
declare const AGENT_WEB_OS_VERSION = "0.1.11";
|
|
255
|
+
|
|
252
256
|
type ServerBridge = {
|
|
253
257
|
initServiceWorker(): Promise<void>;
|
|
254
258
|
registerServer(server: unknown, port: number): void;
|
|
@@ -258,4 +262,4 @@ type ServerBridge = {
|
|
|
258
262
|
declare const getServerBridge: () => ServerBridge;
|
|
259
263
|
declare const resetServerBridge: () => void;
|
|
260
264
|
|
|
261
|
-
export { AlmostNodeSession, type AlmostNodeSessionVfs, type BrowserBashSession, DEFAULT_BASH_SHELL_ENV, ObservableInMemoryFs, type ObservableInMemoryFsChangeEvent, type ObservableInMemoryFsChangeEventName, type ObservableInMemoryFsOptions, type ServerBridge, type ToolResult, assertObservableInMemoryFs, createAlmostNodeSession, createBrowserBashSession, executeBrowserBash, getServerBridge, resetServerBridge };
|
|
265
|
+
export { AGENT_WEB_OS_VERSION, AlmostNodeSession, type AlmostNodeSessionVfs, type BrowserBashSession, DEFAULT_BASH_SHELL_ENV, ObservableInMemoryFs, type ObservableInMemoryFsChangeEvent, type ObservableInMemoryFsChangeEventName, type ObservableInMemoryFsOptions, type ServerBridge, type ToolResult, assertObservableInMemoryFs, createAlmostNodeSession, createBrowserBashSession, executeBrowserBash, getServerBridge, resetServerBridge };
|
package/dist/index.d.ts
CHANGED
|
@@ -166,15 +166,17 @@ declare class AlmostNodeSession {
|
|
|
166
166
|
private resolveNpmBinPath;
|
|
167
167
|
private resolveGlobalBinPath;
|
|
168
168
|
/**
|
|
169
|
-
*
|
|
170
|
-
* the browser runtime. lru-cache v11's CJS unconditionally calls
|
|
171
|
-
* `require("node:diagnostics_channel").tracingChannel()` at the
|
|
172
|
-
* module scope. If that throws inside the browser WASM sandbox the
|
|
173
|
-
* entire module fails and `exports.LRUCache` is never assigned,
|
|
174
|
-
* leading to "TypeError: LRUCache is not a constructor".
|
|
169
|
+
* Replace lru-cache CJS entry points with a browser-safe implementation.
|
|
175
170
|
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
171
|
+
* lru-cache v11's minified CJS uses `require("node:diagnostics_channel")`
|
|
172
|
+
* and private class fields (`static #t`) which can fail inside the browser
|
|
173
|
+
* WASM runtime's `eval()` context, leaving `exports.LRUCache` undefined
|
|
174
|
+
* ("TypeError: LRUCache is not a constructor").
|
|
175
|
+
*
|
|
176
|
+
* The fix: overwrite the CJS entry with a clean Map-based LRU cache that
|
|
177
|
+
* covers the full API surface used by lru-cache consumers (hosted-git-info,
|
|
178
|
+
* path-scurry, glob, etc.) without any diagnostics_channel dependency or
|
|
179
|
+
* private class fields.
|
|
178
180
|
*/
|
|
179
181
|
private patchLruCacheInNodeModules;
|
|
180
182
|
private registerGlobalBinCommands;
|
|
@@ -249,6 +251,8 @@ declare function createBrowserBashSession(options?: BrowserBashSessionOptions):
|
|
|
249
251
|
/** Execute a bash command and return a ToolResult */
|
|
250
252
|
declare function executeBrowserBash(session: BrowserBashSession, command: string, options?: ExecuteBrowserBashOptions): Promise<ToolResult>;
|
|
251
253
|
|
|
254
|
+
declare const AGENT_WEB_OS_VERSION = "0.1.11";
|
|
255
|
+
|
|
252
256
|
type ServerBridge = {
|
|
253
257
|
initServiceWorker(): Promise<void>;
|
|
254
258
|
registerServer(server: unknown, port: number): void;
|
|
@@ -258,4 +262,4 @@ type ServerBridge = {
|
|
|
258
262
|
declare const getServerBridge: () => ServerBridge;
|
|
259
263
|
declare const resetServerBridge: () => void;
|
|
260
264
|
|
|
261
|
-
export { AlmostNodeSession, type AlmostNodeSessionVfs, type BrowserBashSession, DEFAULT_BASH_SHELL_ENV, ObservableInMemoryFs, type ObservableInMemoryFsChangeEvent, type ObservableInMemoryFsChangeEventName, type ObservableInMemoryFsOptions, type ServerBridge, type ToolResult, assertObservableInMemoryFs, createAlmostNodeSession, createBrowserBashSession, executeBrowserBash, getServerBridge, resetServerBridge };
|
|
265
|
+
export { AGENT_WEB_OS_VERSION, AlmostNodeSession, type AlmostNodeSessionVfs, type BrowserBashSession, DEFAULT_BASH_SHELL_ENV, ObservableInMemoryFs, type ObservableInMemoryFsChangeEvent, type ObservableInMemoryFsChangeEventName, type ObservableInMemoryFsOptions, type ServerBridge, type ToolResult, assertObservableInMemoryFs, createAlmostNodeSession, createBrowserBashSession, executeBrowserBash, getServerBridge, resetServerBridge };
|
package/dist/index.js
CHANGED
|
@@ -55288,37 +55288,176 @@ var AlmostNodeSession = class {
|
|
|
55288
55288
|
return null;
|
|
55289
55289
|
}
|
|
55290
55290
|
/**
|
|
55291
|
-
*
|
|
55292
|
-
* the browser runtime. lru-cache v11's CJS unconditionally calls
|
|
55293
|
-
* `require("node:diagnostics_channel").tracingChannel()` at the
|
|
55294
|
-
* module scope. If that throws inside the browser WASM sandbox the
|
|
55295
|
-
* entire module fails and `exports.LRUCache` is never assigned,
|
|
55296
|
-
* leading to "TypeError: LRUCache is not a constructor".
|
|
55291
|
+
* Replace lru-cache CJS entry points with a browser-safe implementation.
|
|
55297
55292
|
*
|
|
55298
|
-
*
|
|
55299
|
-
*
|
|
55293
|
+
* lru-cache v11's minified CJS uses `require("node:diagnostics_channel")`
|
|
55294
|
+
* and private class fields (`static #t`) which can fail inside the browser
|
|
55295
|
+
* WASM runtime's `eval()` context, leaving `exports.LRUCache` undefined
|
|
55296
|
+
* ("TypeError: LRUCache is not a constructor").
|
|
55297
|
+
*
|
|
55298
|
+
* The fix: overwrite the CJS entry with a clean Map-based LRU cache that
|
|
55299
|
+
* covers the full API surface used by lru-cache consumers (hosted-git-info,
|
|
55300
|
+
* path-scurry, glob, etc.) without any diagnostics_channel dependency or
|
|
55301
|
+
* private class fields.
|
|
55300
55302
|
*/
|
|
55301
55303
|
patchLruCacheInNodeModules(nodeModulesDir) {
|
|
55302
|
-
const
|
|
55303
|
-
|
|
55304
|
-
|
|
55305
|
-
|
|
55306
|
-
|
|
55307
|
-
|
|
55308
|
-
|
|
55309
|
-
|
|
55310
|
-
|
|
55311
|
-
|
|
55304
|
+
const lruCacheShim = `"use strict";
|
|
55305
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55306
|
+
exports.LRUCache = void 0;
|
|
55307
|
+
var LRUCache = (function () {
|
|
55308
|
+
function LRUCache(options) {
|
|
55309
|
+
if (typeof options === "number") options = { max: options };
|
|
55310
|
+
if (!options) options = {};
|
|
55311
|
+
this._max = options.max || Infinity;
|
|
55312
|
+
this._maxSize = options.maxSize || 0;
|
|
55313
|
+
this._sizeCalculation = options.sizeCalculation || null;
|
|
55314
|
+
this._dispose = options.dispose || null;
|
|
55315
|
+
this._allowStale = !!options.allowStale;
|
|
55316
|
+
this._ttl = options.ttl || 0;
|
|
55317
|
+
this._noUpdateTTL = !!options.noUpdateTTL;
|
|
55318
|
+
this._map = new Map();
|
|
55319
|
+
this._order = [];
|
|
55320
|
+
this._sizes = new Map();
|
|
55321
|
+
this._totalSize = 0;
|
|
55322
|
+
this._timers = new Map();
|
|
55323
|
+
}
|
|
55324
|
+
Object.defineProperty(LRUCache.prototype, "size", { get: function () { return this._map.size; } });
|
|
55325
|
+
Object.defineProperty(LRUCache.prototype, "max", { get: function () { return this._max; } });
|
|
55326
|
+
Object.defineProperty(LRUCache.prototype, "maxSize", { get: function () { return this._maxSize; } });
|
|
55327
|
+
Object.defineProperty(LRUCache.prototype, "calculatedSize", { get: function () { return this._totalSize; } });
|
|
55328
|
+
LRUCache.prototype._touch = function (key) {
|
|
55329
|
+
var idx = this._order.indexOf(key);
|
|
55330
|
+
if (idx > -1) this._order.splice(idx, 1);
|
|
55331
|
+
this._order.push(key);
|
|
55332
|
+
};
|
|
55333
|
+
LRUCache.prototype._evict = function () {
|
|
55334
|
+
while (this._order.length > 0 && (this._map.size > this._max || (this._maxSize > 0 && this._totalSize > this._maxSize))) {
|
|
55335
|
+
var oldest = this._order.shift();
|
|
55336
|
+
if (oldest !== undefined && this._map.has(oldest)) {
|
|
55337
|
+
var val = this._map.get(oldest);
|
|
55338
|
+
this._map.delete(oldest);
|
|
55339
|
+
if (this._sizes.has(oldest)) { this._totalSize -= this._sizes.get(oldest); this._sizes.delete(oldest); }
|
|
55340
|
+
if (this._timers.has(oldest)) { clearTimeout(this._timers.get(oldest)); this._timers.delete(oldest); }
|
|
55341
|
+
if (this._dispose) this._dispose(val, oldest, "evict");
|
|
55342
|
+
}
|
|
55343
|
+
}
|
|
55344
|
+
};
|
|
55345
|
+
LRUCache.prototype._isStale = function (key) {
|
|
55346
|
+
return false; // TTL timers handle expiry via delete
|
|
55347
|
+
};
|
|
55348
|
+
LRUCache.prototype.set = function (key, value, options) {
|
|
55349
|
+
if (value === undefined) { this.delete(key); return this; }
|
|
55350
|
+
var opts = options || {};
|
|
55351
|
+
var size = 0;
|
|
55352
|
+
if (this._maxSize > 0) {
|
|
55353
|
+
size = opts.size || 0;
|
|
55354
|
+
if (!size && this._sizeCalculation) size = this._sizeCalculation(value, key);
|
|
55355
|
+
if (size > this._maxSize) return this;
|
|
55356
|
+
}
|
|
55357
|
+
if (this._map.has(key)) {
|
|
55358
|
+
var old = this._map.get(key);
|
|
55359
|
+
if (this._sizes.has(key)) { this._totalSize -= this._sizes.get(key); }
|
|
55360
|
+
if (this._timers.has(key)) { clearTimeout(this._timers.get(key)); this._timers.delete(key); }
|
|
55361
|
+
if (this._dispose && !opts.noDisposeOnSet) this._dispose(old, key, "set");
|
|
55362
|
+
}
|
|
55363
|
+
this._map.set(key, value);
|
|
55364
|
+
this._touch(key);
|
|
55365
|
+
if (this._maxSize > 0 && size > 0) { this._sizes.set(key, size); this._totalSize += size; }
|
|
55366
|
+
var ttl = opts.ttl !== undefined ? opts.ttl : this._ttl;
|
|
55367
|
+
if (ttl > 0) {
|
|
55368
|
+
var self = this;
|
|
55369
|
+
this._timers.set(key, setTimeout(function () { self.delete(key); }, ttl));
|
|
55370
|
+
}
|
|
55371
|
+
this._evict();
|
|
55372
|
+
return this;
|
|
55373
|
+
};
|
|
55374
|
+
LRUCache.prototype.get = function (key, options) {
|
|
55375
|
+
if (!this._map.has(key)) return undefined;
|
|
55376
|
+
var value = this._map.get(key);
|
|
55377
|
+
this._touch(key);
|
|
55378
|
+
return value;
|
|
55379
|
+
};
|
|
55380
|
+
LRUCache.prototype.peek = function (key) {
|
|
55381
|
+
return this._map.get(key);
|
|
55382
|
+
};
|
|
55383
|
+
LRUCache.prototype.has = function (key) {
|
|
55384
|
+
return this._map.has(key);
|
|
55385
|
+
};
|
|
55386
|
+
LRUCache.prototype.delete = function (key) {
|
|
55387
|
+
if (!this._map.has(key)) return false;
|
|
55388
|
+
var val = this._map.get(key);
|
|
55389
|
+
this._map.delete(key);
|
|
55390
|
+
var idx = this._order.indexOf(key);
|
|
55391
|
+
if (idx > -1) this._order.splice(idx, 1);
|
|
55392
|
+
if (this._sizes.has(key)) { this._totalSize -= this._sizes.get(key); this._sizes.delete(key); }
|
|
55393
|
+
if (this._timers.has(key)) { clearTimeout(this._timers.get(key)); this._timers.delete(key); }
|
|
55394
|
+
if (this._dispose) this._dispose(val, key, "delete");
|
|
55395
|
+
return true;
|
|
55396
|
+
};
|
|
55397
|
+
LRUCache.prototype.clear = function () {
|
|
55398
|
+
var self = this;
|
|
55399
|
+
if (this._dispose) {
|
|
55400
|
+
this._map.forEach(function (val, key) { self._dispose(val, key, "delete"); });
|
|
55401
|
+
}
|
|
55402
|
+
this._timers.forEach(function (t) { clearTimeout(t); });
|
|
55403
|
+
this._map.clear();
|
|
55404
|
+
this._order.length = 0;
|
|
55405
|
+
this._sizes.clear();
|
|
55406
|
+
this._totalSize = 0;
|
|
55407
|
+
this._timers.clear();
|
|
55408
|
+
};
|
|
55409
|
+
LRUCache.prototype.keys = function () { return this._map.keys(); };
|
|
55410
|
+
LRUCache.prototype.values = function () { return this._map.values(); };
|
|
55411
|
+
LRUCache.prototype.entries = function () { return this._map.entries(); };
|
|
55412
|
+
LRUCache.prototype.find = function (fn, options) {
|
|
55413
|
+
for (var it = this._map.entries(), r; !(r = it.next()).done;) {
|
|
55414
|
+
if (fn(r.value[1], r.value[0], this)) return this.get(r.value[0], options);
|
|
55415
|
+
}
|
|
55416
|
+
};
|
|
55417
|
+
LRUCache.prototype.forEach = function (fn, thisArg) {
|
|
55418
|
+
var self = this;
|
|
55419
|
+
this._map.forEach(function (val, key) { fn.call(thisArg || self, val, key, self); });
|
|
55420
|
+
};
|
|
55421
|
+
LRUCache.prototype.dump = function () { return []; };
|
|
55422
|
+
LRUCache.prototype.load = function (arr) {
|
|
55423
|
+
this.clear();
|
|
55424
|
+
for (var i = 0; i < arr.length; i++) { this.set(arr[i][0], arr[i][1].value, arr[i][1]); }
|
|
55425
|
+
};
|
|
55426
|
+
LRUCache.prototype.pop = function () {
|
|
55427
|
+
if (this._order.length === 0) return undefined;
|
|
55428
|
+
var oldest = this._order[0];
|
|
55429
|
+
var val = this._map.get(oldest);
|
|
55430
|
+
this.delete(oldest);
|
|
55431
|
+
return val;
|
|
55432
|
+
};
|
|
55433
|
+
LRUCache.prototype.purgeStale = function () { return false; };
|
|
55434
|
+
LRUCache.prototype.getRemainingTTL = function (key) { return this._map.has(key) ? Infinity : 0; };
|
|
55435
|
+
LRUCache.prototype.info = function (key) {
|
|
55436
|
+
if (!this._map.has(key)) return undefined;
|
|
55437
|
+
return { value: this._map.get(key) };
|
|
55438
|
+
};
|
|
55439
|
+
LRUCache.prototype[Symbol.iterator] = function () { return this._map.entries(); };
|
|
55440
|
+
LRUCache.prototype[Symbol.toStringTag] = "LRUCache";
|
|
55441
|
+
return LRUCache;
|
|
55442
|
+
})();
|
|
55443
|
+
exports.LRUCache = LRUCache;
|
|
55444
|
+
`;
|
|
55445
|
+
const patchDir = (lruDir) => {
|
|
55446
|
+
const cjsPaths = [
|
|
55447
|
+
normalizePath(posixPath.join(lruDir, "dist", "commonjs", "index.min.js")),
|
|
55448
|
+
normalizePath(posixPath.join(lruDir, "dist", "commonjs", "index.js"))
|
|
55449
|
+
];
|
|
55450
|
+
for (const p of cjsPaths) {
|
|
55451
|
+
if (this._vfs.existsSync(p)) {
|
|
55452
|
+
this._vfs.writeFileSync(p, lruCacheShim);
|
|
55453
|
+
}
|
|
55312
55454
|
}
|
|
55313
55455
|
};
|
|
55314
55456
|
const walkNodeModules = (nmDir) => {
|
|
55315
55457
|
if (!this._vfs.existsSync(nmDir)) return;
|
|
55316
55458
|
for (const entry of this._vfs.readdirSync(nmDir)) {
|
|
55317
55459
|
if (entry === "lru-cache") {
|
|
55318
|
-
|
|
55319
|
-
patchFile(cjsEntry);
|
|
55320
|
-
const cjsIndex = normalizePath(posixPath.join(nmDir, "lru-cache", "dist", "commonjs", "index.js"));
|
|
55321
|
-
patchFile(cjsIndex);
|
|
55460
|
+
patchDir(normalizePath(posixPath.join(nmDir, "lru-cache")));
|
|
55322
55461
|
}
|
|
55323
55462
|
const nestedNm = normalizePath(posixPath.join(nmDir, entry, "node_modules"));
|
|
55324
55463
|
if (this._vfs.existsSync(nestedNm)) {
|
|
@@ -56459,9 +56598,12 @@ async function executeBrowserBash(session, command, options2 = {}) {
|
|
|
56459
56598
|
}
|
|
56460
56599
|
|
|
56461
56600
|
// src/index.ts
|
|
56601
|
+
var AGENT_WEB_OS_VERSION = "0.1.11";
|
|
56602
|
+
console.log(`[agent-web-os] v${AGENT_WEB_OS_VERSION}`);
|
|
56462
56603
|
var getServerBridge2 = getServerBridge;
|
|
56463
56604
|
var resetServerBridge2 = resetServerBridge;
|
|
56464
56605
|
export {
|
|
56606
|
+
AGENT_WEB_OS_VERSION,
|
|
56465
56607
|
AlmostNodeSession,
|
|
56466
56608
|
Ju as Bash,
|
|
56467
56609
|
DEFAULT_BASH_SHELL_ENV,
|