@agentproto/driver-agent-cli 2.6.0 → 2.6.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.
@@ -713,6 +713,22 @@ function listProcesses() {
713
713
  });
714
714
  });
715
715
  }
716
+ function isWindowsBatchFile(exe, deps) {
717
+ if ((process.platform) !== "win32") return false;
718
+ return /\.(?:bat|cmd)$/i.test(exe);
719
+ }
720
+ function windowsBatchShellOption(exe, deps) {
721
+ if (isWindowsBatchFile(exe)) return { shell: true };
722
+ return {};
723
+ }
724
+ function resolveWindowsBatchSpawn(bin, args, deps) {
725
+ if ((process.platform) !== "win32") return void 0;
726
+ if (!isWindowsBatchFile(bin)) return void 0;
727
+ const stem = basename(bin).replace(/\.(?:bat|cmd)$/i, "");
728
+ if (stem !== "npx" && stem !== "npm") return void 0;
729
+ join(dirname(bin), "node_modules", "npm", "bin", `${stem}-cli.js`);
730
+ return void 0;
731
+ }
716
732
  function defaultToolchainWritePaths() {
717
733
  const home = homedir();
718
734
  return [
@@ -784,12 +800,12 @@ async function wrapAgentCliSpawn(bin, args, opts) {
784
800
 
785
801
  // src/protocol/print-arm.ts
786
802
  function printModelMismatch(requested, reported) {
787
- const basename2 = (id) => {
803
+ const basename3 = (id) => {
788
804
  const noSuffix = id.split("@")[0] ?? id;
789
805
  const segs = noSuffix.split("/");
790
806
  return (segs[segs.length - 1] ?? noSuffix).trim().toLowerCase();
791
807
  };
792
- return basename2(requested) !== basename2(reported);
808
+ return basename3(requested) !== basename3(reported);
793
809
  }
794
810
  var DEFAULT_OUTPUT = ["--output-format", "stream-json"];
795
811
  var DEFAULT_PRE_PROMPT = ["--no-interactive"];
@@ -835,7 +851,12 @@ function createPrintSession(opts) {
835
851
  const child = spawn(execBin, execArgs, {
836
852
  cwd: opts.cwd,
837
853
  env: opts.env,
838
- stdio: ["ignore", "pipe", "pipe"]
854
+ stdio: ["ignore", "pipe", "pipe"],
855
+ // Win32: only reached for a `.cmd`/`.bat` bin that
856
+ // `resolveWindowsBatchSpawn` couldn't rewrite to its node entry
857
+ // (see `win32-spawn.ts` — Node refuses direct batch spawning,
858
+ // CVE-2024-27980, the recap-10 `spawn EINVAL`). POSIX: `{}`.
859
+ ...windowsBatchShellOption(execBin)
839
860
  });
840
861
  activeChild = child;
841
862
  let spawnFailure;
@@ -2042,6 +2063,9 @@ function createAgentCliRuntime(definition) {
2042
2063
  }
2043
2064
  const spawnBin = npxFast?.bin ?? resolvedBin;
2044
2065
  const spawnArgs = npxFast?.args ?? composed.binArgs;
2066
+ const batchRewrite = resolveWindowsBatchSpawn(spawnBin);
2067
+ const finalBin = batchRewrite?.bin ?? spawnBin;
2068
+ const finalArgs = batchRewrite?.args ?? spawnArgs;
2045
2069
  if (opts?.additionalReadPaths?.length) {
2046
2070
  env.AGENTPROTO_ADDITIONAL_READ_PATHS = JSON.stringify(opts.additionalReadPaths);
2047
2071
  }
@@ -2097,8 +2121,8 @@ function createAgentCliRuntime(definition) {
2097
2121
  if (definition.protocol === "print") {
2098
2122
  const printModel = config?.options?.model;
2099
2123
  return createPrintSession({
2100
- bin: spawnBin,
2101
- baseArgs: spawnArgs,
2124
+ bin: finalBin,
2125
+ baseArgs: finalArgs,
2102
2126
  cwd,
2103
2127
  env,
2104
2128
  ...opts?.resumeSessionId ? { resumeSessionId: opts.resumeSessionId } : {},
@@ -2116,8 +2140,8 @@ function createAgentCliRuntime(definition) {
2116
2140
  const stderrBuf = [];
2117
2141
  if (definition.protocol !== "proprietary") {
2118
2142
  const [execBin, execArgs] = await wrapAgentCliSpawn(
2119
- spawnBin,
2120
- spawnArgs,
2143
+ finalBin,
2144
+ finalArgs,
2121
2145
  {
2122
2146
  mode: opts?.commandSandbox,
2123
2147
  cwd,
@@ -2133,7 +2157,12 @@ function createAgentCliRuntime(definition) {
2133
2157
  cwd,
2134
2158
  env,
2135
2159
  stdio: ["pipe", "pipe", "pipe"],
2136
- signal: opts?.signal
2160
+ signal: opts?.signal,
2161
+ // Win32: a `.cmd`/`.bat` bin that `resolveWindowsBatchSpawn`
2162
+ // couldn't rewrite to its node entry needs the shell — Node
2163
+ // refuses to spawn batch files directly (CVE-2024-27980, the
2164
+ // recap-10 `spawn EINVAL`). POSIX: `{}` — unchanged.
2165
+ ...windowsBatchShellOption(execBin)
2137
2166
  });
2138
2167
  child = spawned;
2139
2168
  let spawnFailure;
@@ -2351,5 +2380,5 @@ function derivedModelRefusalError(definition, requested, reason) {
2351
2380
  }
2352
2381
 
2353
2382
  export { LEGACY_GATEWAY_MODE_IDS, LEGACY_POSTURE_MODE_IDS, RuntimeConfigError, agentCliFrontmatterSchema, agentCliSupportsHostContextIsolation, applyModelCommand, autoAllowPermissionHandler, composeSpawn, createAcpProtocolArm, createAgentCliRuntime, createArmSessionControls, createJcodeMapperState, createMastraMapperState, createPrintSession, createProprietaryProtocolArm, defineAgentCli, hostContextExcludes, inferLegacyModeKind, isLegacyExtractedModeId, isModelSwitchAcknowledgement, mapJcodeEvent, mapMastraEvent, parseModelSwitchCommand, planModePermissionHandler, promptTurn, resolveContinuationStrategy, runtimeConfigSchema, toFileBasedMcpServers };
2354
- //# sourceMappingURL=chunk-SCR7UF3T.mjs.map
2355
- //# sourceMappingURL=chunk-SCR7UF3T.mjs.map
2383
+ //# sourceMappingURL=chunk-EZROBN7Q.mjs.map
2384
+ //# sourceMappingURL=chunk-EZROBN7Q.mjs.map