@wjarka/cezarion 0.14.2-pr403.631 → 0.14.2-pr403.636.2

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.
Files changed (49) hide show
  1. package/README.md +17 -1
  2. package/dist/delegation/transport.d.ts +50 -50
  3. package/dist/runs/agent-tmpdir.d.ts +44 -4
  4. package/dist/runs/agent-tmpdir.js +209 -31
  5. package/dist/runs/agent-tmpdir.js.map +1 -1
  6. package/dist/server/server.d.ts +1207 -1207
  7. package/package.json +3 -3
  8. package/web/dist/assets/agent-accounts-lH0uqc5U.js +1 -0
  9. package/web/dist/assets/{alert-dialog-D462fSLz.js → alert-dialog-4-bC0tiB.js} +11 -11
  10. package/web/dist/assets/{collapsible-CnnwtcIx.js → collapsible-DuhzznQs.js} +1 -1
  11. package/web/dist/assets/{commit-list-wrisAzf7.js → commit-list-C0UZwCMj.js} +1 -1
  12. package/web/dist/assets/{compare-variants-CrzqJGR6.js → compare-variants-Ds76o54C.js} +1 -1
  13. package/web/dist/assets/{diff-controls-BytucirW.js → diff-controls-Cz_oKS6S.js} +1 -1
  14. package/web/dist/assets/dropdown-menu-DRsTa4Jc.js +1 -0
  15. package/web/dist/assets/{git-toolbar-BtyvMcSw.js → git-toolbar-B5I5F0B6.js} +1 -1
  16. package/web/dist/assets/github-IdC6aneV.js +1 -0
  17. package/web/dist/assets/index-B3VVlXqd.js +7 -0
  18. package/web/dist/assets/index-DPOGn7D5.css +1 -0
  19. package/web/dist/assets/{markdown-CiblnXIm.js → markdown-DY-rA5uY.js} +1 -1
  20. package/web/dist/assets/pill-_Wk1VfdB.js +1 -0
  21. package/web/dist/assets/{project-router-CGCiwPxm.js → project-router-Cb5YDX_u.js} +1 -1
  22. package/web/dist/assets/{prompt-templates-BQthKse9.js → prompt-templates-B1hqHiqw.js} +1 -1
  23. package/web/dist/assets/repo-git-B_Lft6FU.js +1 -0
  24. package/web/dist/assets/{run-diff-BmyuiI9l.js → run-diff-BYpiBhK-.js} +2 -2
  25. package/web/dist/assets/run-header-C_G_7iro.js +1 -0
  26. package/web/dist/assets/skills-ChzvcN-I.js +1 -0
  27. package/web/dist/assets/{tab-link-CVVHvUYC.js → tab-link-CIpL_y6a.js} +1 -1
  28. package/web/dist/assets/task-changes-DaaJtw6K.js +1 -0
  29. package/web/dist/assets/{task-commits-nzLlokeO.js → task-commits-BRmSC_ST.js} +1 -1
  30. package/web/dist/assets/{task-files-Bxbc8DvD.js → task-files-Bml-_Jf8.js} +2 -2
  31. package/web/dist/assets/task-thread-h7tX2jt8.js +9 -0
  32. package/web/dist/assets/{textarea-DLwc8cdo.js → textarea-D0TUpZFn.js} +1 -1
  33. package/web/dist/assets/thread-loading-DG-FuEXf.js +1 -0
  34. package/web/dist/assets/{token-metrics-HEJ_HYHI.js → token-metrics-KPNHIhUC.js} +1 -1
  35. package/web/dist/assets/workflows-BukyfBOw.js +11 -0
  36. package/web/dist/index.html +12 -12
  37. package/web/dist/assets/agent-accounts-CAvfK32A.js +0 -1
  38. package/web/dist/assets/dropdown-menu-CaZoVoYa.js +0 -1
  39. package/web/dist/assets/github-ohhUt_-V.js +0 -1
  40. package/web/dist/assets/index-C9rpAOko.js +0 -7
  41. package/web/dist/assets/index-ej5Q0Ss0.css +0 -1
  42. package/web/dist/assets/pill-BCqO0w_C.js +0 -1
  43. package/web/dist/assets/repo-git-Gt4i-uUU.js +0 -1
  44. package/web/dist/assets/run-header-BjYLL-_t.js +0 -1
  45. package/web/dist/assets/skills-gdBaaVf2.js +0 -1
  46. package/web/dist/assets/task-changes-DLqjOwGU.js +0 -1
  47. package/web/dist/assets/task-thread-vjo4diXV.js +0 -9
  48. package/web/dist/assets/thread-loading-7xLQnmXV.js +0 -1
  49. package/web/dist/assets/workflows-BYKsCaP3.js +0 -11
package/README.md CHANGED
@@ -599,7 +599,7 @@ Useful environment variables:
599
599
  | `GITHUB_TOKEN` | Fallback for GitHub reads/PRs when `gh` isn't authenticated. |
600
600
  | `CEZ_ENV_PASSTHROUGH=A,B` | Forward these extra host env vars to spawned agents. By default agents get a least-privilege env (safe shell/toolchain vars + the backend's own auth + `GITHUB_TOKEN` + `CEZ_*`), not your full environment — use this to add a var an agent needs. |
601
601
  | `CEZ_AGENT_ENV_FULL=1` | Escape hatch: give spawned agents the full host environment (pre-hardening behavior). Off by default; only set it if you understand that this hands every host secret to the agent process. |
602
- | `CEZ_AGENT_TMPDIR=0` | Stop giving each task its own temp directory and hand agents the host `TMPDIR` again (pre-#785 behavior). On by default: every run gets `TMPDIR`/`TEMP`/`TMP` pointing at `.ai/cezar/tmp/<task-id>`, created and write-probed before the agent spawns and reaped when the run ends, so concurrent tasks stop sharing one directory and a task refuses to start rather than run against a temp directory that silently swallows its shell output (see Troubleshooting below). Only an exact `0` disables it, and it disables the whole thing — the pre-spawn check included, so this stays an escape hatch you can actually take. |
602
+ | `CEZ_AGENT_TMPDIR=0` | Stop giving each task its own temp directory and hand agents the host `TMPDIR` again (pre-#785 behavior). On by default: every run gets `TMPDIR`/`TEMP`/`TMP` pointing at `.ai/cezar/tmp/<task-id>`, created and write-probed before the agent spawns and reaped when the run ends — and kept short enough for unix-socket paths: a checkout so deep that `.ai/cezar/tmp/<task-id>` would cross the kernel's socket-path limit resolves it to a `cez-agent-…` directory under the system temp dir instead (#387). So concurrent tasks stop sharing one directory and a task refuses to start rather than run against a temp directory that silently swallows its shell output (see Troubleshooting below). Only an exact `0` disables it, and it disables the whole thing — the pre-spawn check included, so this stays an escape hatch you can actually take. |
603
603
  | `CEZ_REDACT_SECRETS=0` | Disable scrubbing of credential values/token shapes from the on-disk state (the NDJSON transcript and the free-text fields of `runs.json`). On by default; leave it on. Controller-generated delegation tokens are always scrubbed. Best-effort defense-in-depth, not a guarantee: it catches known token shapes and the values of your own secret-named env vars, so a credential in neither category can still get through. |
604
604
  | `CEZ_TITLE_UPDATES=0` | Turn off the live task-title refresh (namer re-runs on each turn end). The Settings → Agents toggle overrides this default. |
605
605
  | `CEZ_AUTONAME=0` | Disable ALL LLM task naming (creation + live) — titles stay heuristic (`437: /om-auto-review-pr`). Under `CEZ_DRY_RUN=1` naming is already off unless forced with `CEZ_AUTONAME=1`. |
@@ -636,6 +636,22 @@ per-task directory and pre-spawn check alike — and hands agents the host
636
636
  `TMPDIR` again, which is the way out if the check itself is wrong on your
637
637
  platform.
638
638
 
639
+ ### Troubleshooting: tools inside a task fail with a socket-path error
640
+
641
+ **Symptom.** Inside a task, `npm install`, `npm run typecheck`, or another tool
642
+ dies with `listen EINVAL` or a "socket path too long" / `ENAMETOOLONG` error —
643
+ with `TMPDIR=/tmp` set by hand, the same commands succeed. Tools like `tsx` bind
644
+ *named* unix sockets under `TMPDIR` (its IPC server builds
645
+ `<tmpdir>/tsx-<uid>/<pid>.pipe`), and the kernel caps a socket path at 104–108
646
+ bytes — a temp directory near that length leaves no room for the name.
647
+
648
+ **Fix.** Since #387 cezar keeps each task's temp directory at most 78 bytes. A
649
+ checkout deep enough to push `.ai/cezar/tmp/<task-id>` past that limit gets a
650
+ short `cez-agent-…` directory under the system temp directory instead — still
651
+ per-task, still write-probed before the agent spawns, still reaped when the run
652
+ ends. Checkouts whose path already fits keep the repo-local directory.
653
+ `CEZ_AGENT_TMPDIR=0` reverts the whole mechanism to the host `TMPDIR`.
654
+
639
655
  ---
640
656
 
641
657
  ## Coding agent backends
@@ -286,6 +286,18 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
286
286
  } & {
287
287
  "/:workerId": {
288
288
  $get: {
289
+ output: {
290
+ error: string;
291
+ code?: "invalid_input" | undefined;
292
+ };
293
+ outputFormat: "json";
294
+ status: 400;
295
+ input: {
296
+ param: {
297
+ workerId: string;
298
+ };
299
+ };
300
+ } | {
289
301
  output: {
290
302
  workerId: string;
291
303
  parentRunId: string;
@@ -362,7 +374,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
362
374
  workerId: string;
363
375
  };
364
376
  };
365
- } | {
377
+ };
378
+ };
379
+ } & {
380
+ "/:workerId/collect": {
381
+ $post: {
366
382
  output: {
367
383
  error: string;
368
384
  code?: "invalid_input" | undefined;
@@ -373,12 +389,10 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
373
389
  param: {
374
390
  workerId: string;
375
391
  };
392
+ } & {
393
+ json: Record<string, never>;
376
394
  };
377
- };
378
- };
379
- } & {
380
- "/:workerId/collect": {
381
- $post: {
395
+ } | {
382
396
  output: {
383
397
  workerId: string;
384
398
  parentRunId: string;
@@ -480,7 +494,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
480
494
  } & {
481
495
  json: Record<string, never>;
482
496
  };
483
- } | {
497
+ };
498
+ };
499
+ } & {
500
+ "/:workerId/steer": {
501
+ $post: {
484
502
  output: {
485
503
  error: string;
486
504
  code?: "invalid_input" | undefined;
@@ -492,13 +510,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
492
510
  workerId: string;
493
511
  };
494
512
  } & {
495
- json: Record<string, never>;
513
+ json: {
514
+ text: string;
515
+ };
496
516
  };
497
- };
498
- };
499
- } & {
500
- "/:workerId/steer": {
501
- $post: {
517
+ } | {
502
518
  output: {
503
519
  workerId: string;
504
520
  state: "delivered" | "queued";
@@ -514,7 +530,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
514
530
  text: string;
515
531
  };
516
532
  };
517
- } | {
533
+ };
534
+ };
535
+ } & {
536
+ "/:workerId/stop": {
537
+ $post: {
518
538
  output: {
519
539
  error: string;
520
540
  code?: "invalid_input" | undefined;
@@ -526,15 +546,9 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
526
546
  workerId: string;
527
547
  };
528
548
  } & {
529
- json: {
530
- text: string;
531
- };
549
+ json: Record<string, never>;
532
550
  };
533
- };
534
- };
535
- } & {
536
- "/:workerId/stop": {
537
- $post: {
551
+ } | {
538
552
  output: {
539
553
  workerId: string;
540
554
  state: "stopping" | "terminated";
@@ -548,7 +562,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
548
562
  } & {
549
563
  json: Record<string, never>;
550
564
  };
551
- } | {
565
+ };
566
+ };
567
+ } & {
568
+ "/:workerId/destroy": {
569
+ $post: {
552
570
  output: {
553
571
  error: string;
554
572
  code?: "invalid_input" | undefined;
@@ -562,11 +580,7 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
562
580
  } & {
563
581
  json: Record<string, never>;
564
582
  };
565
- };
566
- };
567
- } & {
568
- "/:workerId/destroy": {
569
- $post: {
583
+ } | {
570
584
  output: {
571
585
  workerId: string;
572
586
  state: "complete" | "incomplete";
@@ -589,20 +603,6 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
589
603
  } & {
590
604
  json: Record<string, never>;
591
605
  };
592
- } | {
593
- output: {
594
- error: string;
595
- code?: "invalid_input" | undefined;
596
- };
597
- outputFormat: "json";
598
- status: 400;
599
- input: {
600
- param: {
601
- workerId: string;
602
- };
603
- } & {
604
- json: Record<string, never>;
605
- };
606
606
  } | {
607
607
  output: {
608
608
  workerId: string;
@@ -632,13 +632,11 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
632
632
  "/:workerId/diff": {
633
633
  $get: {
634
634
  output: {
635
- workerId: string;
636
- baselineSha: string;
637
- diff: string;
638
- truncated: boolean;
635
+ error: string;
636
+ code?: "invalid_input" | undefined;
639
637
  };
640
638
  outputFormat: "json";
641
- status: 200;
639
+ status: 400;
642
640
  input: {
643
641
  param: {
644
642
  workerId: string;
@@ -646,11 +644,13 @@ export declare function createDelegationApp(routes: DelegationRoutes): import("h
646
644
  };
647
645
  } | {
648
646
  output: {
649
- error: string;
650
- code?: "invalid_input" | undefined;
647
+ workerId: string;
648
+ baselineSha: string;
649
+ diff: string;
650
+ truncated: boolean;
651
651
  };
652
652
  outputFormat: "json";
653
- status: 400;
653
+ status: 200;
654
654
  input: {
655
655
  param: {
656
656
  workerId: string;
@@ -1,5 +1,25 @@
1
1
  /** Where a run's agent-scoped temp directory lives. */
2
2
  export declare function agentTmpDir(dataDir: string, runId: string): string;
3
+ /**
4
+ * The longest a per-run temp directory may be so that tools binding named
5
+ * unix sockets under it still work (#387), measured in UTF-8 bytes — the
6
+ * kernel bounds the encoded path, not the JavaScript character count.
7
+ * `sockaddr_un.sun_path` holds 108 bytes on Linux and 104 on macOS, NUL
8
+ * included; the longest name a known tool lays down under TMPDIR is tsx's IPC
9
+ * socket, `<tmpdir>/tsx-<uid>/<pid>.pipe`, ~22 bytes (Chrome's
10
+ * `SingletonSocket` is 16). A 78-byte ceiling leaves ≥25 bytes of headroom on
11
+ * the tighter platform — past anything these tools generate — while keeping
12
+ * ordinary checkouts on their repo-local scratch: only a genuinely deep path,
13
+ * like the 100-character directories #387 reports, moves to the fallback.
14
+ */
15
+ export declare const MAX_SOCKET_SAFE_DIR_LENGTH = 78;
16
+ /**
17
+ * The temp directory this run should use: the repo-local per-run directory
18
+ * when it is short enough for unix-socket paths, and a short directory under
19
+ * the OS temp root when it is not (#387). Pure resolution — nothing is
20
+ * created, nothing is probed; `agentTmpEnv` owns the side effects.
21
+ */
22
+ export declare function resolveAgentTmpDir(dataDir: string, runId: string): string;
3
23
  /**
4
24
  * The preflight's failure. Named so the spawn path can tell it apart from an
5
25
  * ordinary crash and turn it into the run's `error` — the same treatment
@@ -17,12 +37,19 @@ export declare function agentTmpDirEnabled(env?: NodeJS.ProcessEnv): boolean;
17
37
  * directory actually accepts writes. Throws `AgentTempDirError` when it does
18
38
  * not — callers turn that into the run's error rather than spawning.
19
39
  *
40
+ * The directory is `resolveAgentTmpDir`'s call: repo-local when that path is
41
+ * short enough for unix-socket paths, a digest-named directory under the OS
42
+ * temp root when the checkout is too deep for one (#387). In the shared OS
43
+ * root the directory is created private to this user (0700); repo-local
44
+ * scratch already sits inside the user's own tree and keeps the default mode
45
+ * it always had.
46
+ *
20
47
  * All three spellings are set, on every platform: a tool that reads `TMP` (or
21
48
  * `TEMP`) would otherwise keep following the host value straight back to the
22
49
  * exhausted directory this exists to escape.
23
50
  *
24
- * Returns `{}` under the opt-out, without probing anything: the hatch turns the
25
- * whole feature off, preflight included, so it stays an escape someone can
51
+ * Returns `{}` under the opt-out, without probing anything: the hatch turns
52
+ * the whole feature off, preflight included, so it stays an escape someone can
26
53
  * actually take.
27
54
  */
28
55
  export declare function agentTmpEnv(dataDir: string, runId: string, env?: NodeJS.ProcessEnv): Record<string, string>;
@@ -30,12 +57,25 @@ export declare function agentTmpEnv(dataDir: string, runId: string, env?: NodeJS
30
57
  * Reap one run's directory. Scratch, not an artifact: nothing reads it once the
31
58
  * agent is gone, and a Continue re-creates it through `agentTmpEnv`. Never
32
59
  * throws — reaping must not break a terminal transition.
60
+ *
61
+ * Both locations are tried because the resolution depends on the length of
62
+ * `dataDir`, which a Continue or a re-base can change between mint and reap;
63
+ * removing a name that was never minted is a no-op, so trying both is pure
64
+ * safety.
33
65
  */
34
66
  export declare function removeAgentTmpDir(dataDir: string, runId: string): void;
35
67
  /**
36
68
  * Remove every per-run directory that is not in `keepRunIds` — the startup
37
69
  * sweep, so a crash (which never reaches the terminal-transition reap) cannot
38
- * accumulate them forever. Confined to `<dataDir>/tmp`; sibling run state is
39
- * never enumerated, let alone touched. Returns the ids actually reaped.
70
+ * accumulate them forever. Two confined roots are swept and nothing else:
71
+ *
72
+ * - `<dataDir>/tmp`, where entries ARE the run ids (reports the ids reaped);
73
+ * - the OS temp root's `cez-agent-<12 hex>` directories (#387), where the
74
+ * name digests the dataDir and is not reversible to a run id (reports the
75
+ * directory names reaped). The pattern is exact — prefix, lowercase hex,
76
+ * fixed length, directories only — and a directory is removed only when
77
+ * its `.cez-owner` marker names THIS dataDir and none of this dataDir's
78
+ * kept runs claims it, so another project's scratch in the shared root is
79
+ * never touched.
40
80
  */
41
81
  export declare function sweepAgentTmpDirs(dataDir: string, keepRunIds: Iterable<string>): string[];
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Task-scoped temp directory for spawned agents (#785).
2
+ * Task-scoped temp directory for spawned agents (#785, length-capped by #387).
3
3
  *
4
4
  * Every agent used to inherit the host's `TMPDIR`/`TEMP`/`TMP` verbatim — they
5
5
  * ride in on `buildChildEnv`'s base allowlist — so every run on the machine
@@ -12,7 +12,7 @@
12
12
  * the agent reads back an empty result with a bogus exit status. Nothing in the
13
13
  * cockpit says anything is wrong.
14
14
  *
15
- * Two properties fix that, and this module owns both:
15
+ * Three properties fix that, and this module owns all of them:
16
16
  *
17
17
  * 1. **Isolation** — each run gets `<dataDir>/tmp/<runId>`, on the same disk
18
18
  * as the run's own state rather than a shared tmpfs, reaped when the run
@@ -21,15 +21,28 @@
21
21
  * 2. **Fail loud** — the directory is write-probed before the backend spawns.
22
22
  * A run that cannot get a working temp directory fails immediately with a
23
23
  * named, actionable error instead of spawning an agent that will run blind.
24
+ * 3. **Short enough to bind** (#387) — tools bind *named* unix sockets under
25
+ * `TMPDIR` (tsx's IPC server lays down `<tmpdir>/tsx-<uid>/<pid>.pipe`,
26
+ * Chrome a `SingletonSocket`), and the kernel caps a socket path at
27
+ * `sun_path` — 108 bytes on Linux, 104 on macOS, NUL included. A checkout
28
+ * deep enough (Cezar's own nested task worktrees land past 100 chars)
29
+ * pushed every such bind past the cap and broke `npm install` and
30
+ * typechecking inside the run. A directory that would land too deep
31
+ * resolves instead to a short digest-named directory under the OS temp
32
+ * root — still per-run, still probed, still reaped. A repo whose own path
33
+ * already fits keeps today's directory, byte for byte.
24
34
  *
25
- * `CEZ_AGENT_TMPDIR=0` opts out of BOTH — cezar keeps its hands off the temp
26
- * directory entirely and the pre-#785 behaviour is back, byte for byte. That is
27
- * deliberate: an escape hatch that still imposed the preflight would be a hatch
28
- * you cannot actually escape through, and this repo's graceful-degradation rule
29
- * says a new check must never become the only way to run.
35
+ * `CEZ_AGENT_TMPDIR=0` opts out of ALL THREE — cezar keeps its hands off the
36
+ * temp directory entirely and the pre-#785 behaviour is back, byte for byte.
37
+ * That is deliberate: an escape hatch that still imposed the preflight would be
38
+ * a hatch you cannot actually escape through, and this repo's
39
+ * graceful-degradation rule says a new check must never become the only way to
40
+ * run.
30
41
  */
31
- import { existsSync, mkdirSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
32
- import { join } from 'node:path';
42
+ import { createHash } from 'node:crypto';
43
+ import { existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
44
+ import { tmpdir } from 'node:os';
45
+ import { basename, join } from 'node:path';
33
46
  /** Run ids are uuids; anything else must never reach a recursive `rmSync`.
34
47
  *
35
48
  * `.` and `..` are excluded explicitly, not as pedantry: they match the
@@ -48,6 +61,103 @@ export function agentTmpDir(dataDir, runId) {
48
61
  function agentTmpRoot(dataDir) {
49
62
  return join(dataDir, 'tmp');
50
63
  }
64
+ /**
65
+ * The longest a per-run temp directory may be so that tools binding named
66
+ * unix sockets under it still work (#387), measured in UTF-8 bytes — the
67
+ * kernel bounds the encoded path, not the JavaScript character count.
68
+ * `sockaddr_un.sun_path` holds 108 bytes on Linux and 104 on macOS, NUL
69
+ * included; the longest name a known tool lays down under TMPDIR is tsx's IPC
70
+ * socket, `<tmpdir>/tsx-<uid>/<pid>.pipe`, ~22 bytes (Chrome's
71
+ * `SingletonSocket` is 16). A 78-byte ceiling leaves ≥25 bytes of headroom on
72
+ * the tighter platform — past anything these tools generate — while keeping
73
+ * ordinary checkouts on their repo-local scratch: only a genuinely deep path,
74
+ * like the 100-character directories #387 reports, moves to the fallback.
75
+ */
76
+ export const MAX_SOCKET_SAFE_DIR_LENGTH = 78;
77
+ /** The OS temp root, symlink-resolved: `bind(2)` bounds the path the kernel
78
+ * walks, so the check must measure what the path resolves to, not what it
79
+ * says (macOS hands out `/var/folders/...` through a `/private/var` symlink). */
80
+ function osTempRoot() {
81
+ try {
82
+ return realpathSync(tmpdir());
83
+ }
84
+ catch {
85
+ return tmpdir();
86
+ }
87
+ }
88
+ const FALLBACK_PREFIX = 'cez-agent-';
89
+ const FALLBACK_NAME_LENGTH = 12;
90
+ /** The marker file inside a fallback directory naming the dataDir that minted
91
+ * it. The directory name digests `dataDir:runId` and is not reversible, so
92
+ * without this marker a sweep could not tell its own stale directories from
93
+ * another project's live ones in the shared root — and would delete them. */
94
+ const OWNER_FILE = '.cez-owner';
95
+ function dataDirOwner(dataDir) {
96
+ return createHash('sha256').update(`cez-agent-owner:${dataDir}`).digest('hex').slice(0, 16);
97
+ }
98
+ /**
99
+ * Write the ownership marker. `'wx'` never follows an existing name: an agent
100
+ * that replaced a previous marker with a symlink must not turn this rewrite
101
+ * into an arbitrary-file write. An existing marker is verified by content —
102
+ * a mismatch means the directory's ownership is no longer what the digest
103
+ * name promises, and the spawn refuses rather than guess.
104
+ */
105
+ function writeOwnerMarker(dir, dataDir) {
106
+ const marker = join(dir, OWNER_FILE);
107
+ const expected = dataDirOwner(dataDir);
108
+ try {
109
+ writeFileSync(marker, expected, { encoding: 'utf8', flag: 'wx' });
110
+ }
111
+ catch (err) {
112
+ if (err.code !== 'EEXIST')
113
+ throw err;
114
+ let actual = '';
115
+ try {
116
+ actual = readFileSync(marker, 'utf8').trim();
117
+ }
118
+ catch {
119
+ // unreadable marker (symlink to nowhere, wrong type): verify below.
120
+ }
121
+ if (actual !== expected) {
122
+ throw new AgentTempDirError(dir, new Error('ownership marker was replaced — remove the directory to re-mint it'));
123
+ }
124
+ }
125
+ }
126
+ /**
127
+ * Where the fallback lives for this dataDir+run pair. The name digests the
128
+ * dataDir in, because the OS temp root is SHARED: a name derived from the run
129
+ * id alone would let one repo's reap delete another repo's live scratch when
130
+ * two run ids happen to share their leading characters. The name alone cannot
131
+ * make the sweep safe — a digest is not reversible, so a sweep could not tell
132
+ * its own stale directories from another project's live ones — which is why
133
+ * every fallback directory also carries the `.cez-owner` marker.
134
+ */
135
+ function fallbackTmpDir(dataDir, runId) {
136
+ const digest = createHash('sha256').update(`${dataDir}:${runId}`).digest('hex');
137
+ return join(osTempRoot(), FALLBACK_PREFIX + digest.slice(0, FALLBACK_NAME_LENGTH));
138
+ }
139
+ /**
140
+ * The temp directory this run should use: the repo-local per-run directory
141
+ * when it is short enough for unix-socket paths, and a short directory under
142
+ * the OS temp root when it is not (#387). Pure resolution — nothing is
143
+ * created, nothing is probed; `agentTmpEnv` owns the side effects.
144
+ */
145
+ export function resolveAgentTmpDir(dataDir, runId) {
146
+ const local = agentTmpDir(dataDir, runId);
147
+ if (Buffer.byteLength(local, 'utf8') <= MAX_SOCKET_SAFE_DIR_LENGTH)
148
+ return local;
149
+ const fallback = fallbackTmpDir(dataDir, runId);
150
+ if (Buffer.byteLength(fallback, 'utf8') <= MAX_SOCKET_SAFE_DIR_LENGTH)
151
+ return fallback;
152
+ // Nothing fits — a host TMPDIR so long that even the OS-root candidate
153
+ // crosses the cap. Minting either would hand the agent a temp directory
154
+ // that cannot serve unix sockets: the silent failure #387 is about. Fail
155
+ // the spawn with the named error instead; the remedy names the escape.
156
+ throw new AgentTempDirError(Buffer.byteLength(fallback) < Buffer.byteLength(local) ? fallback : local, new Error(`no socket-safe temp directory exists — repo-local path is `
157
+ + `${Buffer.byteLength(local)} bytes and the OS temp root candidate is `
158
+ + `${Buffer.byteLength(fallback)} bytes, both past the `
159
+ + `${MAX_SOCKET_SAFE_DIR_LENGTH}-byte unix socket budget`));
160
+ }
51
161
  /** `errno` → the phrasing a human recognises from their shell. */
52
162
  const REASONS = {
53
163
  EDQUOT: 'Disk quota exceeded',
@@ -110,20 +220,33 @@ function probeWritable(dir) {
110
220
  * directory actually accepts writes. Throws `AgentTempDirError` when it does
111
221
  * not — callers turn that into the run's error rather than spawning.
112
222
  *
223
+ * The directory is `resolveAgentTmpDir`'s call: repo-local when that path is
224
+ * short enough for unix-socket paths, a digest-named directory under the OS
225
+ * temp root when the checkout is too deep for one (#387). In the shared OS
226
+ * root the directory is created private to this user (0700); repo-local
227
+ * scratch already sits inside the user's own tree and keeps the default mode
228
+ * it always had.
229
+ *
113
230
  * All three spellings are set, on every platform: a tool that reads `TMP` (or
114
231
  * `TEMP`) would otherwise keep following the host value straight back to the
115
232
  * exhausted directory this exists to escape.
116
233
  *
117
- * Returns `{}` under the opt-out, without probing anything: the hatch turns the
118
- * whole feature off, preflight included, so it stays an escape someone can
234
+ * Returns `{}` under the opt-out, without probing anything: the hatch turns
235
+ * the whole feature off, preflight included, so it stays an escape someone can
119
236
  * actually take.
120
237
  */
121
238
  export function agentTmpEnv(dataDir, runId, env = process.env) {
122
239
  if (!agentTmpDirEnabled(env))
123
240
  return {};
124
- const dir = agentTmpDir(dataDir, runId);
241
+ const local = agentTmpDir(dataDir, runId);
242
+ const dir = resolveAgentTmpDir(dataDir, runId);
125
243
  try {
126
- mkdirSync(dir, { recursive: true });
244
+ mkdirSync(dir, dir === local ? { recursive: true } : { recursive: true, mode: 0o700 });
245
+ // In the shared OS root the directory carries its ownership marker, so a
246
+ // startup sweep from another project can tell it apart from stale
247
+ // scratch (the sweep skips anything whose marker is missing or foreign).
248
+ if (dir !== local)
249
+ writeOwnerMarker(dir, dataDir);
127
250
  }
128
251
  catch (err) {
129
252
  throw new AgentTempDirError(dir, err);
@@ -135,44 +258,99 @@ export function agentTmpEnv(dataDir, runId, env = process.env) {
135
258
  * Reap one run's directory. Scratch, not an artifact: nothing reads it once the
136
259
  * agent is gone, and a Continue re-creates it through `agentTmpEnv`. Never
137
260
  * throws — reaping must not break a terminal transition.
261
+ *
262
+ * Both locations are tried because the resolution depends on the length of
263
+ * `dataDir`, which a Continue or a re-base can change between mint and reap;
264
+ * removing a name that was never minted is a no-op, so trying both is pure
265
+ * safety.
138
266
  */
139
267
  export function removeAgentTmpDir(dataDir, runId) {
140
268
  if (!safeRunId(runId))
141
269
  return;
142
- try {
143
- rmSync(agentTmpDir(dataDir, runId), { recursive: true, force: true });
144
- }
145
- catch {
146
- // best-effort; the startup sweep picks up whatever survives.
270
+ for (const dir of [agentTmpDir(dataDir, runId), fallbackTmpDir(dataDir, runId)]) {
271
+ try {
272
+ rmSync(dir, { recursive: true, force: true });
273
+ }
274
+ catch {
275
+ // best-effort; the startup sweep picks up whatever survives.
276
+ }
147
277
  }
148
278
  }
149
279
  /**
150
280
  * Remove every per-run directory that is not in `keepRunIds` — the startup
151
281
  * sweep, so a crash (which never reaches the terminal-transition reap) cannot
152
- * accumulate them forever. Confined to `<dataDir>/tmp`; sibling run state is
153
- * never enumerated, let alone touched. Returns the ids actually reaped.
282
+ * accumulate them forever. Two confined roots are swept and nothing else:
283
+ *
284
+ * - `<dataDir>/tmp`, where entries ARE the run ids (reports the ids reaped);
285
+ * - the OS temp root's `cez-agent-<12 hex>` directories (#387), where the
286
+ * name digests the dataDir and is not reversible to a run id (reports the
287
+ * directory names reaped). The pattern is exact — prefix, lowercase hex,
288
+ * fixed length, directories only — and a directory is removed only when
289
+ * its `.cez-owner` marker names THIS dataDir and none of this dataDir's
290
+ * kept runs claims it, so another project's scratch in the shared root is
291
+ * never touched.
154
292
  */
155
293
  export function sweepAgentTmpDirs(dataDir, keepRunIds) {
156
- const root = agentTmpRoot(dataDir);
157
- if (!existsSync(root))
158
- return [];
159
294
  const keep = new Set(keepRunIds);
160
295
  const reaped = [];
161
296
  let entries;
297
+ const root = agentTmpRoot(dataDir);
298
+ if (existsSync(root)) {
299
+ try {
300
+ entries = readdirSync(root, { withFileTypes: true })
301
+ .filter((e) => e.isDirectory())
302
+ .map((e) => e.name);
303
+ }
304
+ catch {
305
+ entries = [];
306
+ }
307
+ for (const name of entries) {
308
+ if (keep.has(name) || !safeRunId(name))
309
+ continue;
310
+ try {
311
+ rmSync(join(root, name), { recursive: true, force: true });
312
+ reaped.push(name);
313
+ }
314
+ catch {
315
+ // best-effort: a locked directory is retried on the next boot.
316
+ }
317
+ }
318
+ }
319
+ // The #387 fallback location, in the shared OS temp root. Kept narrow on
320
+ // purpose: exact prefix, 12 lowercase-hex name, directories only, and
321
+ // ownership — a directory is removed only when its `.cez-owner` marker
322
+ // names THIS dataDir (a marker that is missing or foreign is another
323
+ // project's, or unknown, and is never ours to remove) and none of this
324
+ // dataDir's kept runs claims it.
325
+ const owner = dataDirOwner(dataDir);
326
+ const claimed = new Set([...keep].filter(safeRunId).map((id) => basename(fallbackTmpDir(dataDir, id))));
327
+ const osRoot = osTempRoot();
328
+ let fallbackEntries;
162
329
  try {
163
- entries = readdirSync(root, { withFileTypes: true })
164
- .filter((e) => e.isDirectory())
165
- .map((e) => e.name);
330
+ fallbackEntries = readdirSync(osRoot, { withFileTypes: true });
166
331
  }
167
332
  catch {
168
- return [];
333
+ return reaped;
169
334
  }
170
- for (const name of entries) {
171
- if (keep.has(name) || !safeRunId(name))
335
+ for (const entry of fallbackEntries) {
336
+ if (!entry.isDirectory() || !entry.name.startsWith(FALLBACK_PREFIX))
337
+ continue;
338
+ if (!/^[0-9a-f]{12}$/.test(entry.name.slice(FALLBACK_PREFIX.length)))
339
+ continue;
340
+ let entryOwner;
341
+ try {
342
+ entryOwner = readFileSync(join(osRoot, entry.name, OWNER_FILE), 'utf8').trim();
343
+ }
344
+ catch {
345
+ continue; // no readable marker: unknown ownership is never ours to remove.
346
+ }
347
+ if (entryOwner !== owner)
348
+ continue;
349
+ if (claimed.has(entry.name))
172
350
  continue;
173
351
  try {
174
- rmSync(join(root, name), { recursive: true, force: true });
175
- reaped.push(name);
352
+ rmSync(join(osRoot, entry.name), { recursive: true, force: true });
353
+ reaped.push(entry.name);
176
354
  }
177
355
  catch {
178
356
  // best-effort: a locked directory is retried on the next boot.
@@ -1 +1 @@
1
- {"version":3,"file":"agent-tmpdir.js","sourceRoot":"","sources":["../../src/runs/agent-tmpdir.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;8EAK8E;AAC9E,SAAS,SAAS,CAAC,EAAU;IAC3B,OAAO,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,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