agent-web-os 0.4.0 → 0.4.1

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/node.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  attachBrowserBashSessionRuntimeAdapter,
5
5
  createBrowserBashSession,
6
6
  posixPath
7
- } from "./chunk-ZZTRZYH2.js";
7
+ } from "./chunk-KBWDWVKH.js";
8
8
  import {
9
9
  ESBUILD_WASM_BINARY_CDN,
10
10
  ESBUILD_WASM_BROWSER_CDN,
@@ -14565,21 +14565,22 @@ ${importMap}`);
14565
14565
 
14566
14566
  // src/server-bridge.ts
14567
14567
  var globalBridge = null;
14568
+ var almostnodeModule = null;
14568
14569
  var almostnodePromise = null;
14569
- function loadAlmostnode() {
14570
- if (!almostnodePromise) {
14571
- almostnodePromise = import("./server-bridge-DZUJDQIT.js");
14572
- }
14573
- return almostnodePromise;
14574
- }
14575
14570
  async function getServerBridge() {
14571
+ if (!almostnodeModule) {
14572
+ if (!almostnodePromise) {
14573
+ almostnodePromise = import("./server-bridge-DZUJDQIT.js");
14574
+ }
14575
+ almostnodeModule = await almostnodePromise;
14576
+ }
14576
14577
  if (!globalBridge) {
14577
- const mod = await loadAlmostnode();
14578
- globalBridge = mod.getServerBridge();
14578
+ globalBridge = almostnodeModule.getServerBridge();
14579
14579
  }
14580
14580
  return globalBridge;
14581
14581
  }
14582
14582
  function resetServerBridge() {
14583
+ almostnodeModule?.resetServerBridge();
14583
14584
  globalBridge = null;
14584
14585
  }
14585
14586
 
@@ -15092,11 +15093,7 @@ var AlmostNodeSession = class {
15092
15093
  const cacheKey = `${root}\0${specifier}`;
15093
15094
  const cached = this.resolveBarePkgEntryCache.get(cacheKey);
15094
15095
  if (cached !== void 0) return cached;
15095
- const result = this._resolveBarePkgEntry(specifier, root);
15096
- this.resolveBarePkgEntryCache.set(cacheKey, result);
15097
- return result;
15098
- }
15099
- _resolveBarePkgEntry(specifier, root) {
15096
+ let result = null;
15100
15097
  let pkgName;
15101
15098
  let subPath;
15102
15099
  if (specifier.startsWith("@")) {
@@ -15126,38 +15123,56 @@ var AlmostNodeSession = class {
15126
15123
  if (pkgJson?.exports && typeof pkgJson.exports === "object") {
15127
15124
  const exportsMap = pkgJson.exports;
15128
15125
  const entry = this.resolveExportsEntry(exportsMap, `./${subPath}`) ?? this.resolveWildcardExports(exportsMap, subPath);
15129
- if (entry) return `/node_modules/${pkgName}/${stripDotSlash(entry)}`;
15130
- }
15131
- const candidates = [
15132
- `/node_modules/${pkgName}/${subPath}`,
15133
- `/node_modules/${pkgName}/${subPath}.js`,
15134
- `/node_modules/${pkgName}/${subPath}.mjs`,
15135
- `/node_modules/${pkgName}/${subPath}/index.js`,
15136
- `/node_modules/${pkgName}/${subPath}/index.mjs`
15137
- ];
15138
- for (const candidate of candidates) {
15139
- if (this.vfs.existsSync(`${root}${candidate}`)) return candidate;
15126
+ if (entry) {
15127
+ result = `/node_modules/${pkgName}/${stripDotSlash(entry)}`;
15128
+ }
15129
+ }
15130
+ if (!result) {
15131
+ const candidates = [
15132
+ `/node_modules/${pkgName}/${subPath}`,
15133
+ `/node_modules/${pkgName}/${subPath}.js`,
15134
+ `/node_modules/${pkgName}/${subPath}.mjs`,
15135
+ `/node_modules/${pkgName}/${subPath}/index.js`,
15136
+ `/node_modules/${pkgName}/${subPath}/index.mjs`
15137
+ ];
15138
+ for (const candidate of candidates) {
15139
+ if (this.vfs.existsSync(`${root}${candidate}`)) {
15140
+ result = candidate;
15141
+ break;
15142
+ }
15143
+ }
15140
15144
  }
15141
- return `/node_modules/${pkgName}/${subPath}`;
15145
+ result ??= `/node_modules/${pkgName}/${subPath}`;
15146
+ this.resolveBarePkgEntryCache.set(cacheKey, result);
15147
+ return result;
15142
15148
  }
15143
15149
  if (pkgJson?.exports && typeof pkgJson.exports === "object") {
15144
15150
  const entry = this.resolveExportsEntry(pkgJson.exports, ".");
15145
- if (entry) return `/node_modules/${pkgName}/${stripDotSlash(entry)}`;
15151
+ if (entry) {
15152
+ result = `/node_modules/${pkgName}/${stripDotSlash(entry)}`;
15153
+ }
15146
15154
  }
15147
- if (typeof pkgJson?.module === "string") {
15148
- return `/node_modules/${pkgName}/${stripDotSlash(pkgJson.module)}`;
15155
+ if (!result && typeof pkgJson?.module === "string") {
15156
+ result = `/node_modules/${pkgName}/${stripDotSlash(pkgJson.module)}`;
15149
15157
  }
15150
- if (typeof pkgJson?.main === "string") {
15151
- return `/node_modules/${pkgName}/${stripDotSlash(pkgJson.main)}`;
15158
+ if (!result && typeof pkgJson?.main === "string") {
15159
+ result = `/node_modules/${pkgName}/${stripDotSlash(pkgJson.main)}`;
15152
15160
  }
15153
- const fallbacks = [
15154
- `/node_modules/${pkgName}/index.js`,
15155
- `/node_modules/${pkgName}/index.mjs`
15156
- ];
15157
- for (const fb of fallbacks) {
15158
- if (this.vfs.existsSync(`${root}${fb}`)) return fb;
15161
+ if (!result) {
15162
+ const fallbacks = [
15163
+ `/node_modules/${pkgName}/index.js`,
15164
+ `/node_modules/${pkgName}/index.mjs`
15165
+ ];
15166
+ for (const fallbackPath of fallbacks) {
15167
+ if (this.vfs.existsSync(`${root}${fallbackPath}`)) {
15168
+ result = fallbackPath;
15169
+ break;
15170
+ }
15171
+ }
15159
15172
  }
15160
- return `/node_modules/${pkgName}/index.js`;
15173
+ result ??= `/node_modules/${pkgName}/index.js`;
15174
+ this.resolveBarePkgEntryCache.set(cacheKey, result);
15175
+ return result;
15161
15176
  }
15162
15177
  resolveExportsEntry(exports, key) {
15163
15178
  const entry = exports[key];
@@ -16677,6 +16692,8 @@ async function enableNode(session) {
16677
16692
  return session;
16678
16693
  }
16679
16694
  const almostNodeSession = new AlmostNodeSession(session.fs);
16695
+ const executeNode = almostNodeSession.executeNode.bind(almostNodeSession);
16696
+ const executeNpm = almostNodeSession.executeNpm.bind(almostNodeSession);
16680
16697
  almostNodeSession.setBinCommandRegistrar((name, handler) => {
16681
16698
  session.bash.registerCommand(Dx(name, handler));
16682
16699
  });
@@ -16687,10 +16704,10 @@ async function enableNode(session) {
16687
16704
  dispose: () => almostNodeSession.dispose()
16688
16705
  });
16689
16706
  session.bash.registerCommand(
16690
- Dx("node", async (args, ctx) => almostNodeSession.executeNode(args, ctx))
16707
+ Dx("node", executeNode)
16691
16708
  );
16692
16709
  session.bash.registerCommand(
16693
- Dx("npm", async (args, ctx) => almostNodeSession.executeNpm(args, ctx))
16710
+ Dx("npm", executeNpm)
16694
16711
  );
16695
16712
  enabledNodeSessions.add(session);
16696
16713
  return session;