@agentfield/sdk 0.1.142-rc.7 → 0.1.142-rc.8

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
@@ -218,8 +218,9 @@ function batchProbeInvocation(command) {
218
218
  });
219
219
  return {
220
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.
221
+ // /s removes the outer quote pair of the fixed template, so each "%VAR%"
222
+ // expansion stays quoted.
223
+ // /v:off disables delayed ! expansion; /d disables AutoRun.
223
224
  args: ["/d", "/v:off", "/s", "/c", `"${tokens.join(" ")}"`],
224
225
  env
225
226
  };
@@ -227,20 +228,40 @@ function batchProbeInvocation(command) {
227
228
  async function defaultVersionProbe(command) {
228
229
  const { execFile } = await import('child_process');
229
230
  return new Promise((resolve3, reject) => {
230
- const batch = isWindowsBatchFile(command[0]);
231
- const { file, args, env } = batch ? batchProbeInvocation(command) : { file: command[0], args: command.slice(1), env: process.env };
232
- execFile(
233
- file,
234
- args,
235
- { timeout: 2e3, windowsHide: true, windowsVerbatimArguments: batch, env },
236
- (error, stdout, stderr) => {
237
- if (error) {
238
- reject(error);
239
- return;
231
+ const onProbeOutput = (error, stdout, stderr) => {
232
+ if (error) {
233
+ reject(error);
234
+ return;
235
+ }
236
+ const output = String(stdout || stderr).trim();
237
+ resolve3(output ? output.split(/\r?\n/, 1)[0] : "unknown");
238
+ };
239
+ if (isWindowsBatchFile(command[0])) {
240
+ for (const value of command) {
241
+ for (let index = 0; index < value.length; index += 1) {
242
+ const codePoint = value.charCodeAt(index);
243
+ if (codePoint === 34 || codePoint < 32) {
244
+ reject(new TypeError(
245
+ `Windows batch probe values must not contain double quotes or control characters; offending code point ${codePoint} in ${JSON.stringify(value)}`
246
+ ));
247
+ return;
248
+ }
240
249
  }
241
- const output = String(stdout || stderr).trim();
242
- resolve3(output ? output.split(/\r?\n/, 1)[0] : "unknown");
243
250
  }
251
+ const { file, args, env } = batchProbeInvocation(command);
252
+ execFile(
253
+ file,
254
+ args,
255
+ { timeout: 2e3, windowsHide: true, windowsVerbatimArguments: true, env },
256
+ onProbeOutput
257
+ );
258
+ return;
259
+ }
260
+ execFile(
261
+ command[0],
262
+ command.slice(1),
263
+ { timeout: 2e3, windowsHide: true, windowsVerbatimArguments: false },
264
+ onProbeOutput
244
265
  );
245
266
  });
246
267
  }