la-machina-engine 0.7.8 → 0.7.10

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
@@ -2132,18 +2132,38 @@ function canSpawnProcesses() {
2132
2132
  spawnCache = probeSpawn();
2133
2133
  return spawnCache;
2134
2134
  }
2135
+ function probeSpawnFromProcess(proc) {
2136
+ if (proc == null || typeof proc !== "object") return false;
2137
+ const p = proc;
2138
+ if (typeof p.getBuiltinModule === "function") {
2139
+ try {
2140
+ const cp = p.getBuiltinModule("node:child_process");
2141
+ if (cp && typeof cp.spawn === "function") return true;
2142
+ } catch {
2143
+ }
2144
+ }
2145
+ if (typeof p.dlopen === "function") return true;
2146
+ return false;
2147
+ }
2135
2148
  function probeSpawn() {
2149
+ if (isCloudflareWorkers()) return false;
2136
2150
  if (typeof globalThis.process === "undefined" || globalThis.process.versions == null || typeof globalThis.process.versions.node !== "string") {
2137
2151
  return false;
2138
2152
  }
2139
2153
  try {
2140
2154
  const req = eval("require");
2141
- if (typeof req !== "function") return false;
2142
- const cp = req("node:child_process");
2143
- return typeof cp.spawn === "function";
2155
+ if (typeof req === "function") {
2156
+ const cp = req("node:child_process");
2157
+ if (typeof cp.spawn === "function") return true;
2158
+ }
2144
2159
  } catch {
2145
- return false;
2146
2160
  }
2161
+ return probeSpawnFromProcess(globalThis.process);
2162
+ }
2163
+ function isCloudflareWorkers() {
2164
+ const nav = globalThis.navigator;
2165
+ const ua = typeof nav?.userAgent === "string" ? nav.userAgent : "";
2166
+ return ua.includes("Cloudflare-Workers");
2147
2167
  }
2148
2168
  function hasProcessLifecycle() {
2149
2169
  return typeof process !== "undefined" && typeof process.on === "function" && typeof process.removeListener === "function" && canSpawnProcesses();
@@ -2152,6 +2172,9 @@ function _resetRuntimeCachesForTests() {
2152
2172
  runtimeCache = null;
2153
2173
  spawnCache = null;
2154
2174
  }
2175
+ function _probeSpawnFromProcessForTests(proc) {
2176
+ return probeSpawnFromProcess(proc);
2177
+ }
2155
2178
 
2156
2179
  // src/tools/capabilityStub.ts
2157
2180
  init_cjs_shims();
@@ -4787,8 +4810,8 @@ init_contract();
4787
4810
  var _spawn = null;
4788
4811
  async function getSpawn() {
4789
4812
  if (_spawn === null) {
4790
- const cp2 = await import("child_process");
4791
- _spawn = cp2.spawn;
4813
+ const cp = await import("child_process");
4814
+ _spawn = cp.spawn;
4792
4815
  }
4793
4816
  return _spawn;
4794
4817
  }
@@ -5455,12 +5478,12 @@ async function runRipgrep(input, ctx) {
5455
5478
  args.push("--max-count", String(MAX_MATCHES_PER_FILE));
5456
5479
  args.push("--", input.pattern);
5457
5480
  if (input.path) args.push(input.path);
5458
- const cp2 = getChildProcessSync() ?? await getChildProcessAsync();
5459
- if (cp2 === null) {
5481
+ const cp = getChildProcessSync() ?? await getChildProcessAsync();
5482
+ if (cp === null) {
5460
5483
  return { content: "ripgrep not available in this runtime", isError: true };
5461
5484
  }
5462
5485
  return new Promise((resolve) => {
5463
- const child = cp2.spawn("rg", args, {
5486
+ const child = cp.spawn("rg", args, {
5464
5487
  stdio: ["ignore", "pipe", "pipe"],
5465
5488
  timeout: 3e4
5466
5489
  });
@@ -9609,9 +9632,9 @@ var R2StorageAdapter = class {
9609
9632
  results.push(name);
9610
9633
  }
9611
9634
  }
9612
- for (const cp2 of resp.CommonPrefixes ?? []) {
9613
- if (!cp2.Prefix) continue;
9614
- const name = cp2.Prefix.slice(prefix.length).replace(/\/$/, "");
9635
+ for (const cp of resp.CommonPrefixes ?? []) {
9636
+ if (!cp.Prefix) continue;
9637
+ const name = cp.Prefix.slice(prefix.length).replace(/\/$/, "");
9615
9638
  if (name) results.push(name);
9616
9639
  }
9617
9640
  continuationToken = resp.IsTruncated ? resp.NextContinuationToken : void 0;