@koalaauto/agentchannel 3.38.2 → 3.38.3

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.
@@ -49,8 +49,10 @@ export interface ClaudePermInput {
49
49
  hide?: string[];
50
50
  /** macOS: patterns programs must write in the user's temp folder (default: macTempPatterns()) */
51
51
  tempPatterns?: string[];
52
- /** the run's private TMPDIR: writable (Claude Code keeps its sandbox's network bridge there) */
52
+ /** the run's private TMPDIR: writable */
53
53
  tmpDir?: string;
54
+ /** Claude Code's own temporary directory for the run (claudeTempDir()): writable */
55
+ claudeTmpDir?: string;
54
56
  /** tests: take the roots as given (no real-path lookup on this machine) */
55
57
  exists?: boolean;
56
58
  }
@@ -71,6 +73,16 @@ export declare function sandboxNetwork(hubHost: string | undefined, netAllow?: s
71
73
  * runner commits after the run.
72
74
  */
73
75
  export declare function claudePermOptions(perm: Perm, o: ClaudePermInput): Partial<Options>;
76
+ /**
77
+ * Claude Code's own temporary directory for one sandboxed run, handed to it as CLAUDE_CODE_TMPDIR: a sandboxed command's output is a
78
+ * file there, and it is the command's TMPDIR. Left to itself, Claude Code on macOS ignores TMPDIR and uses /tmp/claude-<uid>, which
79
+ * the policy hides (scope.ts; other Claude Code sessions' output is there too): a command could write its output but not stat it, so
80
+ * node aborted as it started (exit 134, no message) and cat said "stdout: Operation not permitted" (2026-11-14, a Mac runner: 24 of
81
+ * 104 commands of its task runs, every `ach reply` of its mention runs). Private (mkdtemp: 0700, a random name) and short: macOS's
82
+ * own temp folder is a long path, and Claude Code keeps its sandbox's sockets here. Removed when the run ends. Undefined on Windows
83
+ * (no sandbox) or when it cannot be made.
84
+ */
85
+ export declare function claudeTempDir(platform?: NodeJS.Platform, base?: string): string | undefined;
74
86
  /** Error text of a result message (C9): never the word "success" for a failed run. */
75
87
  export declare function resultError(m: {
76
88
  subtype?: string;
@@ -1,4 +1,6 @@
1
- import { homedir } from 'node:os';
1
+ import { mkdtempSync, realpathSync, rmSync } from 'node:fs';
2
+ import { homedir, tmpdir } from 'node:os';
3
+ import { join } from 'node:path';
2
4
  import { toolDenied } from './paths.js';
3
5
  import { macTempPatterns, readable, systemPaths } from './scope.js';
4
6
  import { spawnGroup } from './procgroup.js';
@@ -155,10 +157,11 @@ export function claudePermOptions(perm, o) {
155
157
  const tempPatterns = o.tempPatterns ?? macTempPatterns();
156
158
  const systemRoots = o.systemRoots ?? sys.read;
157
159
  const systemDeny = o.systemDeny ?? sys.deny;
160
+ const tmpRoots = [o.tmpDir, o.claudeTmpDir].filter((d) => !!d);
158
161
  const pol = {
159
162
  home,
160
163
  cwd: o.cwd,
161
- readRoots: [...(o.readRoots ?? []), ...(o.tmpDir ? [o.tmpDir] : [])],
164
+ readRoots: [...(o.readRoots ?? []), ...tmpRoots],
162
165
  systemRoots,
163
166
  hide,
164
167
  writeRoots: perm === 'workdir' ? [o.cwd] : [],
@@ -176,10 +179,10 @@ export function claudePermOptions(perm, o) {
176
179
  filesystem: {
177
180
  // by real path: macOS checks where a path really is (/var/folders is /private/var/folders), and a write under the
178
181
  // link's spelling was refused (live test)
179
- allowWrite: [...(o.exists ? (x) => x : readable)([...(perm === 'workdir' ? [o.cwd] : []), ...(o.tmpDir ? [o.tmpDir] : [])]), ...tempPatterns],
182
+ allowWrite: [...(o.exists ? (x) => x : readable)([...(perm === 'workdir' ? [o.cwd] : []), ...tmpRoots]), ...tempPatterns],
180
183
  // a deny more specific than an allow stays denied (Homebrew's var inside /opt/homebrew)
181
184
  denyRead: [...hide, ...systemDeny, ...denyRead],
182
- allowRead: [...(o.exists ? (x) => x : readable)([o.cwd, ...(o.readRoots ?? []), ...(o.tmpDir ? [o.tmpDir] : []), ...systemRoots]), ...tempPatterns],
185
+ allowRead: [...(o.exists ? (x) => x : readable)([o.cwd, ...(o.readRoots ?? []), ...tmpRoots, ...systemRoots]), ...tempPatterns],
183
186
  },
184
187
  network: sandboxNetwork(hubHost, o.netAllow),
185
188
  };
@@ -195,6 +198,26 @@ export function claudePermOptions(perm, o) {
195
198
  return { ...common, permissionMode: 'dontAsk' };
196
199
  return { ...common, permissionMode: 'acceptEdits', canUseTool: workdirCanUseTool(pol) };
197
200
  }
201
+ /**
202
+ * Claude Code's own temporary directory for one sandboxed run, handed to it as CLAUDE_CODE_TMPDIR: a sandboxed command's output is a
203
+ * file there, and it is the command's TMPDIR. Left to itself, Claude Code on macOS ignores TMPDIR and uses /tmp/claude-<uid>, which
204
+ * the policy hides (scope.ts; other Claude Code sessions' output is there too): a command could write its output but not stat it, so
205
+ * node aborted as it started (exit 134, no message) and cat said "stdout: Operation not permitted" (2026-11-14, a Mac runner: 24 of
206
+ * 104 commands of its task runs, every `ach reply` of its mention runs). Private (mkdtemp: 0700, a random name) and short: macOS's
207
+ * own temp folder is a long path, and Claude Code keeps its sandbox's sockets here. Removed when the run ends. Undefined on Windows
208
+ * (no sandbox) or when it cannot be made.
209
+ */
210
+ export function claudeTempDir(platform = process.platform, base = platform === 'darwin' ? '/tmp' : tmpdir()) {
211
+ if (platform === 'win32')
212
+ return undefined;
213
+ try {
214
+ // by its real path, as the sandbox checks it (/tmp is /private/tmp on macOS)
215
+ return realpathSync(mkdtempSync(join(base, 'ach-')));
216
+ }
217
+ catch {
218
+ return undefined;
219
+ }
220
+ }
198
221
  /** Error text of a result message (C9): never the word "success" for a failed run. */
199
222
  export function resultError(m) {
200
223
  const errs = (m.errors ?? []).filter(Boolean).join('; ');
@@ -295,6 +318,8 @@ export class ClaudeAdapter {
295
318
  },
296
319
  ],
297
320
  };
321
+ // a full run is not sandboxed: Claude Code's usual temporary folder serves it
322
+ const claudeTmp = opts.perm === 'full' ? undefined : claudeTempDir();
298
323
  const permOptions = claudePermOptions(opts.perm, {
299
324
  cwd: opts.cwd,
300
325
  hub: opts.hub,
@@ -303,11 +328,12 @@ export class ClaudeAdapter {
303
328
  denyReadPaths: opts.denyReadPaths,
304
329
  home: opts.realHome ?? opts.env.HOME,
305
330
  tmpDir: opts.tmpDir,
331
+ claudeTmpDir: claudeTmp,
306
332
  netAllow: opts.netAllow,
307
333
  });
308
334
  const options = {
309
335
  cwd: opts.cwd,
310
- env: opts.env,
336
+ env: claudeTmp ? { ...opts.env, CLAUDE_CODE_TMPDIR: claudeTmp } : opts.env,
311
337
  abortController,
312
338
  ...(opts.resume ? { resume: opts.resume } : {}),
313
339
  ...(this.o.model ? { model: this.o.model } : {}),
@@ -385,6 +411,13 @@ export class ClaudeAdapter {
385
411
  }
386
412
  finally {
387
413
  opts.signal.removeEventListener('abort', onAbort);
414
+ try {
415
+ if (claudeTmp)
416
+ rmSync(claudeTmp, { recursive: true, force: true });
417
+ }
418
+ catch {
419
+ /* left to the system's temp cleanup */
420
+ }
388
421
  }
389
422
  if (!finalText)
390
423
  finalText = lastText.join('\n');
@@ -1,4 +1,4 @@
1
- export declare const VERSION = "3.38.2";
1
+ export declare const VERSION = "3.38.3";
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.38.2';
1
+ export const VERSION = '3.38.3';
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.38.2",
3
+ "version": "3.38.3",
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",