@agentfield/sdk 0.1.141-rc.6 → 0.1.141

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.js CHANGED
@@ -209,19 +209,30 @@ function providerUnavailable(provider, binary) {
209
209
  function isWindowsBatchFile(command) {
210
210
  return process.platform === "win32" && WINDOWS_BATCH_EXTENSIONS.has(path5__default.extname(command).toLowerCase());
211
211
  }
212
- function quoteCmdToken(value) {
213
- return `"${value.replace(/"/g, '""')}"`;
212
+ function batchProbeInvocation(command) {
213
+ const env = { ...process.env };
214
+ const tokens = command.map((value, index) => {
215
+ const name = `${BATCH_PROBE_ENV_PREFIX}${index}`;
216
+ env[name] = value;
217
+ return `"%${name}%"`;
218
+ });
219
+ return {
220
+ file: process.env.ComSpec ?? "cmd.exe",
221
+ // /s strips only the outermost quote pair, leaving each "%VAR%" quoted.
222
+ // /v:off keeps ! in a path literal even if delayed expansion is enabled.
223
+ args: ["/d", "/v:off", "/s", "/c", `"${tokens.join(" ")}"`],
224
+ env
225
+ };
214
226
  }
215
227
  async function defaultVersionProbe(command) {
216
228
  const { execFile } = await import('child_process');
217
229
  return new Promise((resolve3, reject) => {
218
230
  const batch = isWindowsBatchFile(command[0]);
219
- const file = batch ? process.env.ComSpec ?? "cmd.exe" : command[0];
220
- const args = batch ? ["/d", "/s", "/c", `"${command.map(quoteCmdToken).join(" ")}"`] : command.slice(1);
231
+ const { file, args, env } = batch ? batchProbeInvocation(command) : { file: command[0], args: command.slice(1), env: process.env };
221
232
  execFile(
222
233
  file,
223
234
  args,
224
- { timeout: 2e3, windowsHide: true, windowsVerbatimArguments: batch },
235
+ { timeout: 2e3, windowsHide: true, windowsVerbatimArguments: batch, env },
225
236
  (error, stdout, stderr) => {
226
237
  if (error) {
227
238
  reject(error);
@@ -303,7 +314,7 @@ async function harnessDoctor(providers, options = {}) {
303
314
  }
304
315
  return reports;
305
316
  }
306
- var PROVIDER_SPECS, SUPPORTED_PROVIDER_NAMES, HarnessProviderUnavailable, WINDOWS_BATCH_EXTENSIONS;
317
+ var PROVIDER_SPECS, SUPPORTED_PROVIDER_NAMES, HarnessProviderUnavailable, WINDOWS_BATCH_EXTENSIONS, BATCH_PROBE_ENV_PREFIX;
307
318
  var init_availability = __esm({
308
319
  "src/harness/availability.ts"() {
309
320
  PROVIDER_SPECS = {
@@ -385,6 +396,7 @@ var init_availability = __esm({
385
396
  }
386
397
  };
387
398
  WINDOWS_BATCH_EXTENSIONS = /* @__PURE__ */ new Set([".bat", ".cmd"]);
399
+ BATCH_PROBE_ENV_PREFIX = "AGENTFIELD_PROBE_ARG_";
388
400
  }
389
401
  });
390
402