@koalaauto/agentchannel 3.36.5 → 3.36.6

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.
@@ -70,6 +70,11 @@ export type Run = (file: string, args: string[], opts: {
70
70
  env: NodeJS.ProcessEnv;
71
71
  cwd?: string;
72
72
  }) => Promise<RunResult>;
73
+ /**
74
+ * A program's output as text: UTF-8, else (Windows programs write in the console code page) GBK, the code page of the Chinese
75
+ * Windows machines this runs on (echo-duck-pr's check showed cmd's GBK message as U+FFFD), else UTF-8 with replacements.
76
+ */
77
+ export declare function decodeOutput(b: Buffer | string | undefined): string;
73
78
  export declare const defaultRun: Run;
74
79
  export declare function onPath(name: string, env: NodeJS.ProcessEnv): string | undefined;
75
80
  export declare function pkgFor(distro: string[] | undefined): PkgManager | undefined;
@@ -87,6 +92,12 @@ export declare function sdkCodexBinary(platform?: NodeJS.Platform, arch?: string
87
92
  export declare function codexOnPath(env: NodeJS.ProcessEnv, platform?: NodeJS.Platform): string[] | undefined;
88
93
  /** What a failed sandbox start said, as a problem. */
89
94
  export declare function classify(stderr: string, host: Host): SandboxProblem;
95
+ /**
96
+ * The Windows probe as a node one-liner (exit codes as probeScript: 3 the work directory is not writable, 4 the outside write
97
+ * worked). Not `cmd /c` with a quoted path: Codex quotes each argument the MSVC way (\"), which cmd does not read, and the
98
+ * probe failed with cmd's "filename syntax is incorrect" (echo-duck-pr, 3.36.5). Paths go as plain arguments, no quotes inside.
99
+ */
100
+ export declare const WIN_PROBE_SCRIPT: string;
90
101
  export interface ProbeOptions {
91
102
  env?: NodeJS.ProcessEnv;
92
103
  platform?: NodeJS.Platform;
@@ -8,10 +8,29 @@ import { fileURLToPath } from 'node:url';
8
8
  import { codexSandboxOverrides } from './adapters/codex.js';
9
9
  import { linkWindowsSandbox, unlinkWindowsSandbox, WINDOWS_ELEVATED_CONFIG } from './codexhome.js';
10
10
  import { toolchainReadRoots } from './adapters/paths.js';
11
+ /**
12
+ * A program's output as text: UTF-8, else (Windows programs write in the console code page) GBK, the code page of the Chinese
13
+ * Windows machines this runs on (echo-duck-pr's check showed cmd's GBK message as U+FFFD), else UTF-8 with replacements.
14
+ */
15
+ export function decodeOutput(b) {
16
+ if (b == null)
17
+ return '';
18
+ if (typeof b === 'string')
19
+ return b;
20
+ try {
21
+ return new TextDecoder('utf-8', { fatal: true }).decode(b);
22
+ }
23
+ catch { }
24
+ try {
25
+ return new TextDecoder('gbk', { fatal: true }).decode(b);
26
+ }
27
+ catch { }
28
+ return b.toString('utf8');
29
+ }
11
30
  export const defaultRun = (file, args, opts) => new Promise((res) => {
12
- execFile(file, args, { env: opts.env, cwd: opts.cwd, timeout: 20_000, encoding: 'utf8', maxBuffer: 1 << 20 }, (err, stdout, stderr) => {
31
+ execFile(file, args, { env: opts.env, cwd: opts.cwd, timeout: 20_000, encoding: 'buffer', maxBuffer: 1 << 20 }, (err, stdout, stderr) => {
13
32
  const code = err ? (typeof err.code === 'number' ? err.code : err.code === 'ENOENT' ? 127 : 1) : 0;
14
- res({ code, stdout: String(stdout ?? ''), stderr: String(stderr ?? '') || (err?.code === 'ENOENT' ? `${file}: not found` : '') });
33
+ res({ code, stdout: decodeOutput(stdout), stderr: decodeOutput(stderr) || (err?.code === 'ENOENT' ? `${file}: not found` : '') });
15
34
  });
16
35
  });
17
36
  export function onPath(name, env) {
@@ -156,6 +175,13 @@ function probeScript() {
156
175
  return ('touch "$1/ok" || exit 3; w=0; if touch "$2" 2>/dev/null; then w=4; fi; if [ -n "$3" ] && cat "$3" >/dev/null 2>&1; then exit 7; fi; ' +
157
176
  'if [ -n "$4" ] && ! "$4" -e 0 >/dev/null 2>&1; then exit 8; fi; if [ -n "$5" ] && ! "$5" --version >/dev/null 2>&1; then exit 9; fi; exit $w');
158
177
  }
178
+ /**
179
+ * The Windows probe as a node one-liner (exit codes as probeScript: 3 the work directory is not writable, 4 the outside write
180
+ * worked). Not `cmd /c` with a quoted path: Codex quotes each argument the MSVC way (\"), which cmd does not read, and the
181
+ * probe failed with cmd's "filename syntax is incorrect" (echo-duck-pr, 3.36.5). Paths go as plain arguments, no quotes inside.
182
+ */
183
+ export const WIN_PROBE_SCRIPT = "const[k,o]=process.argv.slice(1);const f=require('fs');try{f.writeFileSync(k,'')}catch{process.exit(3)}" +
184
+ "try{f.writeFileSync(o,'')}catch{process.exit(0)}process.exit(4)";
159
185
  /** A Codex home like a worker run's (prepareCodexHome): the user's own config.toml is not read, so it cannot switch the profile off. */
160
186
  function probeCodexHome(realCodexHome, platform) {
161
187
  const d = mkdtempSync(join(tmpdir(), 'ach-sandbox-codex-'));
@@ -223,7 +249,7 @@ async function probe(tool, o) {
223
249
  codex = o.codex ?? codexCommand(env);
224
250
  if (!codex)
225
251
  return { tool, ok: true, unverified: true, detail: 'Codex was not found' };
226
- const cmd = platform === 'win32' ? ['cmd', '/c', `type nul > "${join(dir, 'ok')}" && (type nul > "${outside}" && exit 4 || exit 0)`] : sh;
252
+ const cmd = platform === 'win32' ? [process.execPath, '-e', WIN_PROBE_SCRIPT, join(dir, 'ok'), outside] : sh;
227
253
  if (canary)
228
254
  writeFileSync(canary, 'probe\n', { mode: 0o600 });
229
255
  codexHome = probeCodexHome(o.codexHome, platform);
@@ -1,4 +1,4 @@
1
- export declare const VERSION = "3.36.5";
1
+ export declare const VERSION = "3.36.6";
2
2
  /** The npm package (scripts/release.mjs keeps it and VERSION in step with package.json). */
3
3
  export declare const PKG_NAME = "@koalaauto/agentchannel";
4
4
  /**
@@ -1,4 +1,4 @@
1
- export const VERSION = '3.36.5';
1
+ export const VERSION = '3.36.6';
2
2
  /** The npm package (scripts/release.mjs keeps it and VERSION in step with package.json). */
3
3
  export const PKG_NAME = '@koalaauto/agentchannel';
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koalaauto/agentchannel",
3
- "version": "3.36.5",
3
+ "version": "3.36.6",
4
4
  "description": "Hand work between your team's agents (Claude Code, Codex) and follow it in one panel: the ach CLI, MCP server and runner for AgentChannel v2",
5
5
  "keywords": [
6
6
  "agentchannel",