@cleocode/adapters 2026.9.20 → 2026.9.21

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 (56) hide show
  1. package/dist/cant-context.d.ts +7 -5
  2. package/dist/cant-context.d.ts.map +1 -1
  3. package/dist/index.js +501 -328
  4. package/dist/index.js.map +3 -3
  5. package/dist/providers/claude-code/adapter.d.ts.map +1 -1
  6. package/dist/providers/claude-code/spawn.d.ts +2 -2
  7. package/dist/providers/claude-code/spawn.d.ts.map +1 -1
  8. package/dist/providers/claude-sdk/spawn.d.ts +1 -1
  9. package/dist/providers/codex/adapter.d.ts.map +1 -1
  10. package/dist/providers/codex/spawn.d.ts +1 -1
  11. package/dist/providers/codex/spawn.d.ts.map +1 -1
  12. package/dist/providers/gemini-cli/adapter.d.ts.map +1 -1
  13. package/dist/providers/gemini-cli/spawn.d.ts +1 -1
  14. package/dist/providers/gemini-cli/spawn.d.ts.map +1 -1
  15. package/dist/providers/kimi/adapter.d.ts.map +1 -1
  16. package/dist/providers/kimi/spawn.d.ts.map +1 -1
  17. package/dist/providers/opencode/adapter.d.ts.map +1 -1
  18. package/dist/providers/opencode/spawn.d.ts +3 -2
  19. package/dist/providers/opencode/spawn.d.ts.map +1 -1
  20. package/dist/providers/pi/adapter.d.ts +1 -1
  21. package/dist/providers/pi/adapter.d.ts.map +1 -1
  22. package/dist/providers/pi/spawn.d.ts +3 -3
  23. package/dist/providers/pi/spawn.d.ts.map +1 -1
  24. package/dist/providers/shared/agent-spawn-wrapper.d.ts +5 -0
  25. package/dist/providers/shared/agent-spawn-wrapper.d.ts.map +1 -1
  26. package/dist/providers/shared/cli-spawn.d.ts +28 -0
  27. package/dist/providers/shared/cli-spawn.d.ts.map +1 -0
  28. package/dist/providers/shared/credentials.d.ts +2 -2
  29. package/dist/providers/shared/credentials.d.ts.map +1 -1
  30. package/dist/providers/shared/prompt-file.d.ts +32 -0
  31. package/dist/providers/shared/prompt-file.d.ts.map +1 -0
  32. package/package.json +5 -5
  33. package/src/__tests__/agent-spawn-wrapper-win32.test.ts +42 -0
  34. package/src/__tests__/cant-context.test.ts +89 -37
  35. package/src/__tests__/cli-spawn-win32.test.ts +105 -0
  36. package/src/__tests__/spawn-prompt-file.test.ts +37 -0
  37. package/src/cant-context.ts +11 -15
  38. package/src/providers/claude-code/adapter.ts +6 -11
  39. package/src/providers/claude-code/spawn.ts +11 -25
  40. package/src/providers/claude-sdk/spawn.ts +1 -1
  41. package/src/providers/codex/adapter.ts +6 -11
  42. package/src/providers/codex/spawn.ts +17 -31
  43. package/src/providers/gemini-cli/adapter.ts +6 -11
  44. package/src/providers/gemini-cli/spawn.ts +13 -18
  45. package/src/providers/kimi/adapter.ts +6 -11
  46. package/src/providers/kimi/spawn.ts +3 -11
  47. package/src/providers/opencode/__tests__/spawn-prompt-delivery.test.ts +123 -0
  48. package/src/providers/opencode/adapter.ts +6 -11
  49. package/src/providers/opencode/spawn.ts +23 -25
  50. package/src/providers/pi/adapter.ts +8 -18
  51. package/src/providers/pi/spawn.ts +15 -33
  52. package/src/providers/shared/__tests__/credentials-cleo-home.test.ts +42 -0
  53. package/src/providers/shared/agent-spawn-wrapper.ts +22 -2
  54. package/src/providers/shared/cli-spawn.ts +41 -0
  55. package/src/providers/shared/credentials.ts +6 -5
  56. package/src/providers/shared/prompt-file.ts +44 -0
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Private temp files for spawn-adapter prompts.
3
+ *
4
+ * Prompts used to be written to a literal `/tmp/<provider>-spawn-<id>.txt`.
5
+ * Windows has no `/tmp`, so every spawn failed there, and on macOS the path
6
+ * ignored `$TMPDIR` and the per-user sandbox temp. Each prompt now lives in a
7
+ * fresh `mkdtemp` directory under `os.tmpdir()`, removed with the file (T12606).
8
+ *
9
+ * @task T12606
10
+ */
11
+
12
+ import { mkdtemp, rm, writeFile } from 'node:fs/promises';
13
+ import { tmpdir } from 'node:os';
14
+ import { dirname, join } from 'node:path';
15
+
16
+ /**
17
+ * Write a prompt to `prompt.txt` inside a new private temp directory.
18
+ *
19
+ * @param prefix - Directory-name prefix identifying the provider, e.g. `claude-spawn`.
20
+ * @param prompt - Prompt text.
21
+ * @returns Absolute path of the written prompt file.
22
+ * @example
23
+ * ```ts
24
+ * const file = await writeSpawnPromptFile('codex-spawn', prompt);
25
+ * // …spawn the child with `file`, then on exit:
26
+ * await removeSpawnPromptFile(file);
27
+ * ```
28
+ */
29
+ export async function writeSpawnPromptFile(prefix: string, prompt: string): Promise<string> {
30
+ const dir = await mkdtemp(join(tmpdir(), `cleo-${prefix}-`));
31
+ const file = join(dir, 'prompt.txt');
32
+ await writeFile(file, prompt, 'utf-8');
33
+ return file;
34
+ }
35
+
36
+ /**
37
+ * Remove a prompt file written by {@link writeSpawnPromptFile} and its directory.
38
+ * Never throws: cleanup failure must not mask the spawn outcome.
39
+ *
40
+ * @param file - Path returned by {@link writeSpawnPromptFile}.
41
+ */
42
+ export async function removeSpawnPromptFile(file: string): Promise<void> {
43
+ await rm(dirname(file), { recursive: true, force: true }).catch(() => undefined);
44
+ }