@excitedjs/agent-runtime-claude-code 0.2.0-alpha.g0ddd418597ca

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 (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -0
  3. package/dist/args.d.ts +71 -0
  4. package/dist/args.d.ts.map +1 -0
  5. package/dist/args.js +87 -0
  6. package/dist/args.js.map +1 -0
  7. package/dist/config.d.ts +71 -0
  8. package/dist/config.d.ts.map +1 -0
  9. package/dist/config.js +86 -0
  10. package/dist/config.js.map +1 -0
  11. package/dist/diagnostic.d.ts +12 -0
  12. package/dist/diagnostic.d.ts.map +1 -0
  13. package/dist/diagnostic.js +25 -0
  14. package/dist/diagnostic.js.map +1 -0
  15. package/dist/index.d.ts +18 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +18 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/internal/completion-body.d.ts +38 -0
  20. package/dist/internal/completion-body.d.ts.map +1 -0
  21. package/dist/internal/completion-body.js +62 -0
  22. package/dist/internal/completion-body.js.map +1 -0
  23. package/dist/internal/config-validate.d.ts +23 -0
  24. package/dist/internal/config-validate.d.ts.map +1 -0
  25. package/dist/internal/config-validate.js +122 -0
  26. package/dist/internal/config-validate.js.map +1 -0
  27. package/dist/internal/os.d.ts +30 -0
  28. package/dist/internal/os.d.ts.map +1 -0
  29. package/dist/internal/os.js +81 -0
  30. package/dist/internal/os.js.map +1 -0
  31. package/dist/internal/turn-render.d.ts +22 -0
  32. package/dist/internal/turn-render.d.ts.map +1 -0
  33. package/dist/internal/turn-render.js +40 -0
  34. package/dist/internal/turn-render.js.map +1 -0
  35. package/dist/mcp-config.d.ts +19 -0
  36. package/dist/mcp-config.d.ts.map +1 -0
  37. package/dist/mcp-config.js +22 -0
  38. package/dist/mcp-config.js.map +1 -0
  39. package/dist/provider-ref.d.ts +8 -0
  40. package/dist/provider-ref.d.ts.map +1 -0
  41. package/dist/provider-ref.js +8 -0
  42. package/dist/provider-ref.js.map +1 -0
  43. package/dist/provider.d.ts +60 -0
  44. package/dist/provider.d.ts.map +1 -0
  45. package/dist/provider.js +110 -0
  46. package/dist/provider.js.map +1 -0
  47. package/dist/rpc.d.ts +45 -0
  48. package/dist/rpc.d.ts.map +1 -0
  49. package/dist/rpc.js +212 -0
  50. package/dist/rpc.js.map +1 -0
  51. package/dist/runtime.d.ts +174 -0
  52. package/dist/runtime.d.ts.map +1 -0
  53. package/dist/runtime.js +464 -0
  54. package/dist/runtime.js.map +1 -0
  55. package/dist/stream.d.ts +96 -0
  56. package/dist/stream.d.ts.map +1 -0
  57. package/dist/stream.js +289 -0
  58. package/dist/stream.js.map +1 -0
  59. package/dist/supervisor.d.ts +17 -0
  60. package/dist/supervisor.d.ts.map +1 -0
  61. package/dist/supervisor.js +170 -0
  62. package/dist/supervisor.js.map +1 -0
  63. package/dist/types.d.ts +133 -0
  64. package/dist/types.d.ts.map +1 -0
  65. package/dist/types.js +7 -0
  66. package/dist/types.js.map +1 -0
  67. package/package.json +53 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 excitedjs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # @excitedjs/agent-runtime-claude-code
2
+
3
+ The built-in **Claude Code** Agent Runtime provider for
4
+ [Dreamux](https://github.com/excitedjs/dreamux), published behind the stable
5
+ `builtin:claude-code` alias.
6
+
7
+ It implements the public `AgentRuntimeProvider` contract from
8
+ [`@excitedjs/dreamux-types`](../../dreamux-types) against a resident `claude`
9
+ stream-json child: process supervision, the stream-json wire protocol (line
10
+ framing, turn aggregation, control-request replies), per-turn idle-deadline
11
+ handling, MCP config translation (`--mcp-config`), teammate completion delivery
12
+ as a plain user turn, and Claude Code doctor diagnostics.
13
+
14
+ ## Boundary
15
+
16
+ This package depends on `@excitedjs/dreamux-types` **only**. It never imports
17
+ `@excitedjs/dreamux` core. Everything host-specific — per-dispatcher paths, the
18
+ durable state sink, the process `PATH` seeded from the host package bins — is
19
+ supplied by the Dreamux host through the neutral `AgentRuntimeCreateContext` and
20
+ the provider factory options. The package owns only Claude Code engine mechanics
21
+ and its own runtime config parsing; it reconstructs no Dreamux host
22
+ layout/path/log contracts. Generic OS/validation/turn helpers it needs are
23
+ vendored under `src/internal/`.
24
+
25
+ ## Loading
26
+
27
+ Dreamux core resolves `builtin:claude-code` to this package and constructs the
28
+ provider through its own core-owned adapter, which maps core's host-shaped create
29
+ context onto the neutral one and supplies the host contracts. The package also
30
+ default-exports a generic provider-loader factory, so
31
+ `loadExternalAgentRuntimeProviders({ refs: ['builtin:claude-code'] })` can load it
32
+ through the same package-loader path as external `npm:` providers.
package/dist/args.d.ts ADDED
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Pure Claude Code CLI/MCP argument translation (issue #110 PR6).
3
+ *
4
+ * This is the concrete proof that the AgentRuntimeProvider abstraction is not
5
+ * "Codex renamed": the same Dreamux `AgentRuntimeMcpServer[]` descriptors that
6
+ * the Codex runtime turns into `-c mcp_servers.*` TOML CLI flags are here turned
7
+ * into Claude Code's native MCP config — a JSON document loaded via
8
+ * `claude --mcp-config <file>`. Two runtimes, one descriptor contract, two
9
+ * completely different process argument shapes.
10
+ *
11
+ * Pure functions only — no IO, no process spawning — so they are fully unit
12
+ * testable without a live `claude` binary.
13
+ */
14
+ import type { AgentRuntimeSkillSource } from '@excitedjs/dreamux-types';
15
+ import type { DispatcherClaudeCodeConfig } from './config.js';
16
+ /**
17
+ * The skill-source `layout` Claude Code can translate into `--add-dir`: `path`
18
+ * is a directory that contains a `.claude/skills` tree (claude's native skill
19
+ * discovery location for added directories). Sources with any other layout —
20
+ * e.g. the bundled Dreamux `skill-dir` sources, which are flat skill folders
21
+ * with no `.claude/skills` parent — are NOT add-dir compatible and emit nothing,
22
+ * so today's bundled skills feed codex only (claude-code's existing behavior of
23
+ * injecting no bundled skills is preserved). The mapping is implemented for
24
+ * compatible / external sources. Kept as a plain string because
25
+ * `@excitedjs/dreamux-types` is declaration-only.
26
+ */
27
+ export declare const CLAUDE_SKILLS_PARENT_LAYOUT = "claude-skills-parent";
28
+ export interface ClaudeCodeResidentArgsInput {
29
+ config: DispatcherClaudeCodeConfig;
30
+ /** Path to the generated Claude Code MCP config document. */
31
+ mcpConfigPath: string;
32
+ /** Resume an existing Claude Code session, when one is known (spawn-time). */
33
+ resumeSessionId?: string | null;
34
+ /**
35
+ * Launcher-supplied dispatcher/role system-prompt content. Claude Code applies
36
+ * it as an APPEND (per its `systemPrompt` capability) via
37
+ * `--append-system-prompt`, layered on top of the engine's own system prompt.
38
+ * Omitted/empty for launches that supply none (e.g. teammates).
39
+ */
40
+ systemPromptContent?: string;
41
+ /**
42
+ * Role-gated bundled/external skill sources core selected (issue #209 slice
43
+ * 6). Claude Code translates the add-dir-compatible ones (see
44
+ * {@link CLAUDE_SKILLS_PARENT_LAYOUT}) into `--add-dir <path>` flags so claude
45
+ * discovers their `.claude/skills`. Omitted/empty for launches with none.
46
+ */
47
+ skillSources?: readonly AgentRuntimeSkillSource[];
48
+ }
49
+ /**
50
+ * The `--add-dir` flag pairs for the add-dir-compatible skill sources, deduped
51
+ * by path and preserving first-seen order. Pure: compatibility is decided from
52
+ * the source `layout`, never by touching the filesystem.
53
+ */
54
+ export declare function claudeCodeSkillAddDirArgs(skillSources: readonly AgentRuntimeSkillSource[] | undefined): string[];
55
+ /**
56
+ * Build the `claude` CLI args for the *resident* stream-json transport (issue
57
+ * #120). Unlike the retired one-shot `claude --print <prompt>`, this launches a
58
+ * long-lived process that keeps stdin/stdout open: `--input-format stream-json`
59
+ * consumes NDJSON `user` messages on stdin (one per turn) until EOF, and
60
+ * `--output-format stream-json --verbose` streams `init` / `assistant` /
61
+ * `result` envelopes on stdout. The prompt is therefore NOT a CLI argument —
62
+ * each turn is written to stdin as a `user` message line (see
63
+ * `claude-code/stream.ts`).
64
+ *
65
+ * It reads its MCP servers from the JSON config (`--mcp-config`), optionally
66
+ * resumes a prior session at spawn time (`--resume`, used both for operator
67
+ * resume and for re-spawn after an unexpected exit), and threads the operator's
68
+ * model / permission mode / extra args through.
69
+ */
70
+ export declare function claudeCodeResidentArgs(input: ClaudeCodeResidentArgsInput): string[];
71
+ //# sourceMappingURL=args.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAExE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAE9D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,yBAAyB,CAAC;AAElE,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,0BAA0B,CAAC;IACnC,6DAA6D;IAC7D,aAAa,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,YAAY,CAAC,EAAE,SAAS,uBAAuB,EAAE,CAAC;CACnD;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,SAAS,uBAAuB,EAAE,GAAG,SAAS,GAC3D,MAAM,EAAE,CASV;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,2BAA2B,GAAG,MAAM,EAAE,CAoCnF"}
package/dist/args.js ADDED
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Pure Claude Code CLI/MCP argument translation (issue #110 PR6).
3
+ *
4
+ * This is the concrete proof that the AgentRuntimeProvider abstraction is not
5
+ * "Codex renamed": the same Dreamux `AgentRuntimeMcpServer[]` descriptors that
6
+ * the Codex runtime turns into `-c mcp_servers.*` TOML CLI flags are here turned
7
+ * into Claude Code's native MCP config — a JSON document loaded via
8
+ * `claude --mcp-config <file>`. Two runtimes, one descriptor contract, two
9
+ * completely different process argument shapes.
10
+ *
11
+ * Pure functions only — no IO, no process spawning — so they are fully unit
12
+ * testable without a live `claude` binary.
13
+ */
14
+ /**
15
+ * The skill-source `layout` Claude Code can translate into `--add-dir`: `path`
16
+ * is a directory that contains a `.claude/skills` tree (claude's native skill
17
+ * discovery location for added directories). Sources with any other layout —
18
+ * e.g. the bundled Dreamux `skill-dir` sources, which are flat skill folders
19
+ * with no `.claude/skills` parent — are NOT add-dir compatible and emit nothing,
20
+ * so today's bundled skills feed codex only (claude-code's existing behavior of
21
+ * injecting no bundled skills is preserved). The mapping is implemented for
22
+ * compatible / external sources. Kept as a plain string because
23
+ * `@excitedjs/dreamux-types` is declaration-only.
24
+ */
25
+ export const CLAUDE_SKILLS_PARENT_LAYOUT = 'claude-skills-parent';
26
+ /**
27
+ * The `--add-dir` flag pairs for the add-dir-compatible skill sources, deduped
28
+ * by path and preserving first-seen order. Pure: compatibility is decided from
29
+ * the source `layout`, never by touching the filesystem.
30
+ */
31
+ export function claudeCodeSkillAddDirArgs(skillSources) {
32
+ const paths = [
33
+ ...new Set((skillSources ?? [])
34
+ .filter((s) => s.layout === CLAUDE_SKILLS_PARENT_LAYOUT)
35
+ .map((s) => s.path)),
36
+ ];
37
+ return paths.flatMap((path) => ['--add-dir', path]);
38
+ }
39
+ /**
40
+ * Build the `claude` CLI args for the *resident* stream-json transport (issue
41
+ * #120). Unlike the retired one-shot `claude --print <prompt>`, this launches a
42
+ * long-lived process that keeps stdin/stdout open: `--input-format stream-json`
43
+ * consumes NDJSON `user` messages on stdin (one per turn) until EOF, and
44
+ * `--output-format stream-json --verbose` streams `init` / `assistant` /
45
+ * `result` envelopes on stdout. The prompt is therefore NOT a CLI argument —
46
+ * each turn is written to stdin as a `user` message line (see
47
+ * `claude-code/stream.ts`).
48
+ *
49
+ * It reads its MCP servers from the JSON config (`--mcp-config`), optionally
50
+ * resumes a prior session at spawn time (`--resume`, used both for operator
51
+ * resume and for re-spawn after an unexpected exit), and threads the operator's
52
+ * model / permission mode / extra args through.
53
+ */
54
+ export function claudeCodeResidentArgs(input) {
55
+ const args = [
56
+ '--print',
57
+ '--input-format',
58
+ 'stream-json',
59
+ '--output-format',
60
+ 'stream-json',
61
+ '--verbose',
62
+ '--mcp-config',
63
+ input.mcpConfigPath,
64
+ ];
65
+ // Role-gated skills: add each compatible source dir so claude discovers its
66
+ // `.claude/skills`. Present on every (re)spawn — start and resume both rebuild
67
+ // these args — so skills survive a crash-respawn (issue #209 slice 6).
68
+ args.push(...claudeCodeSkillAddDirArgs(input.skillSources));
69
+ if (input.config.permission_mode !== null) {
70
+ args.push('--permission-mode', input.config.permission_mode);
71
+ }
72
+ if (input.config.model !== null) {
73
+ args.push('--model', input.config.model);
74
+ }
75
+ if (input.systemPromptContent !== undefined &&
76
+ input.systemPromptContent !== '') {
77
+ args.push('--append-system-prompt', input.systemPromptContent);
78
+ }
79
+ if (input.resumeSessionId !== undefined &&
80
+ input.resumeSessionId !== null &&
81
+ input.resumeSessionId !== '') {
82
+ args.push('--resume', input.resumeSessionId);
83
+ }
84
+ args.push(...input.config.extra_args);
85
+ return args;
86
+ }
87
+ //# sourceMappingURL=args.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,sBAAsB,CAAC;AAwBlE;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACvC,YAA4D;IAE5D,MAAM,KAAK,GAAG;QACZ,GAAG,IAAI,GAAG,CACR,CAAC,YAAY,IAAI,EAAE,CAAC;aACjB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,2BAA2B,CAAC;aACvD,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CACtB;KACF,CAAC;IACF,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;AACtD,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAkC;IACvE,MAAM,IAAI,GAAG;QACX,SAAS;QACT,gBAAgB;QAChB,aAAa;QACb,iBAAiB;QACjB,aAAa;QACb,WAAW;QACX,cAAc;QACd,KAAK,CAAC,aAAa;KACpB,CAAC;IACF,4EAA4E;IAC5E,+EAA+E;IAC/E,uEAAuE;IACvE,IAAI,CAAC,IAAI,CAAC,GAAG,yBAAyB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;IAC5D,IAAI,KAAK,CAAC,MAAM,CAAC,eAAe,KAAK,IAAI,EAAE,CAAC;QAC1C,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAC/D,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QAChC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC;IACD,IACE,KAAK,CAAC,mBAAmB,KAAK,SAAS;QACvC,KAAK,CAAC,mBAAmB,KAAK,EAAE,EAChC,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACjE,CAAC;IACD,IACE,KAAK,CAAC,eAAe,KAAK,SAAS;QACnC,KAAK,CAAC,eAAe,KAAK,IAAI;QAC9B,KAAK,CAAC,eAAe,KAAK,EAAE,EAC5B,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IAC/C,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACtC,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Builtin `builtin:claude-code` runtime config: schema type, defaults, reader,
3
+ * and the typed accessor.
4
+ *
5
+ * Owned by the `@excitedjs/agent-runtime-claude-code` package (issue #209). It
6
+ * depends only on the shared neutral validation primitives
7
+ * (`@excitedjs/dreamux-utils`) and the package's own provider ref
8
+ * (`./provider-ref`); it never imports `@excitedjs/dreamux` core. Core re-exports
9
+ * these symbols through its `config/config.ts` (via the package's light
10
+ * `./config` subpath) so the non-builtin callers (doctor, tests) keep their
11
+ * import paths, and the cold-start config path never pulls in the runtime engine.
12
+ */
13
+ /**
14
+ * Builtin Claude Code runtime settings under a named `agents[].config` entry
15
+ * whose `provider` is `builtin:claude-code` (issue #110 PR6), referenced by a
16
+ * dispatcher via `dispatchers[].agentRuntime`.
17
+ *
18
+ * Deliberately distinct from `DispatcherCodexConfig`: Claude Code runs as a
19
+ * resident headless stream-json process (`claude --print --input-format
20
+ * stream-json …`, issue #120) with no `initialize` handshake, so there is no
21
+ * handshake timeout, approval policy, or sandbox mode here. `bin` is the Claude
22
+ * Code binary; `model` / `permission_mode` map to `--model` / `--permission-mode`;
23
+ * `remote_control` enables Claude Code Remote Control at resident-session
24
+ * startup; `extra_args` / `extra_env` are passed through. `model` and
25
+ * `permission_mode` are `null` when the operator does not pin them (Claude
26
+ * Code's own defaults apply). `turn_timeout_ms` is a per-turn *idle /
27
+ * inactivity* window (issue #120 anti-hang, made idle-based in issue #156): it
28
+ * is reset on every inbound stream line, so it bounds the max time the
29
+ * still-alive child may emit *no* stream activity — not the total turn duration.
30
+ * A child silent for the whole window is failed and reaped/re-spawned (rather
31
+ * than wedging the serial turn queue and, behind it, TeamMate completion
32
+ * delivery), while a long but actively-streaming turn never trips it.
33
+ */
34
+ export interface DispatcherClaudeCodeConfig {
35
+ bin: string;
36
+ model: string | null;
37
+ permission_mode: string | null;
38
+ remote_control: boolean;
39
+ extra_args: string[];
40
+ extra_env: Record<string, string>;
41
+ turn_timeout_ms: number;
42
+ }
43
+ /** Default `dispatchers[].runtime.config.bin` for `builtin:claude-code`. */
44
+ export declare const DEFAULT_CLAUDE_CODE_BIN = "claude";
45
+ /**
46
+ * Default per-turn *idle* window for the resident `builtin:claude-code` child
47
+ * (ms). This is the max time the child may emit no stream activity before the
48
+ * turn is failed and the child reaped (issue #120 anti-hang, idle-based since
49
+ * issue #156) — it is reset on every stream line, so it does not cap a long but
50
+ * actively-streaming turn. Operators can override via
51
+ * `dispatchers[].runtime.config.turn_timeout_ms`.
52
+ */
53
+ export declare const DEFAULT_CLAUDE_CODE_TURN_TIMEOUT_MS = 600000;
54
+ /** Permission modes accepted for `builtin:claude-code` (Claude Code `--permission-mode`). */
55
+ export declare const ALLOWED_CLAUDE_CODE_PERMISSION_MODES: Set<string>;
56
+ export declare function defaultDispatcherClaudeCodeConfig(): DispatcherClaudeCodeConfig;
57
+ export declare function readDispatcherClaudeCodeConfig(rawClaude: Record<string, unknown>, file: string, prefix: string): DispatcherClaudeCodeConfig;
58
+ /**
59
+ * Typed accessor for a dispatcher's resolved claude-code runtime config. Typed
60
+ * structurally (not against `DispatcherConfig`) so this module never imports
61
+ * the host config type — a full `DispatcherConfig` still satisfies it at the
62
+ * call sites.
63
+ */
64
+ export declare function dispatcherClaudeCodeConfig(dispatcher: {
65
+ id: string;
66
+ runtime: {
67
+ provider: string;
68
+ config: unknown;
69
+ };
70
+ }): DispatcherClaudeCodeConfig;
71
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAYH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,0BAA0B;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,cAAc,EAAE,OAAO,CAAC;IACxB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,4EAA4E;AAC5E,eAAO,MAAM,uBAAuB,WAAW,CAAC;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,mCAAmC,SAAU,CAAC;AAE3D,6FAA6F;AAC7F,eAAO,MAAM,oCAAoC,aAK/C,CAAC;AAEH,wBAAgB,iCAAiC,IAAI,0BAA0B,CAU9E;AAED,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,0BAA0B,CAgE5B;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE;IACrD,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC;CAChD,GAAG,0BAA0B,CAO7B"}
package/dist/config.js ADDED
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Builtin `builtin:claude-code` runtime config: schema type, defaults, reader,
3
+ * and the typed accessor.
4
+ *
5
+ * Owned by the `@excitedjs/agent-runtime-claude-code` package (issue #209). It
6
+ * depends only on the shared neutral validation primitives
7
+ * (`@excitedjs/dreamux-utils`) and the package's own provider ref
8
+ * (`./provider-ref`); it never imports `@excitedjs/dreamux` core. Core re-exports
9
+ * these symbols through its `config/config.ts` (via the package's light
10
+ * `./config` subpath) so the non-builtin callers (doctor, tests) keep their
11
+ * import paths, and the cold-start config path never pulls in the runtime engine.
12
+ */
13
+ import { BUILTIN_CLAUDE_CODE_PROVIDER_REF } from './provider-ref.js';
14
+ import { readOptionalBoolean, readOptionalString, rejectUnknownKeys, requirePositiveInt, requireStringArray, requireStringRecord, } from '@excitedjs/dreamux-utils';
15
+ /** Default `dispatchers[].runtime.config.bin` for `builtin:claude-code`. */
16
+ export const DEFAULT_CLAUDE_CODE_BIN = 'claude';
17
+ /**
18
+ * Default per-turn *idle* window for the resident `builtin:claude-code` child
19
+ * (ms). This is the max time the child may emit no stream activity before the
20
+ * turn is failed and the child reaped (issue #120 anti-hang, idle-based since
21
+ * issue #156) — it is reset on every stream line, so it does not cap a long but
22
+ * actively-streaming turn. Operators can override via
23
+ * `dispatchers[].runtime.config.turn_timeout_ms`.
24
+ */
25
+ export const DEFAULT_CLAUDE_CODE_TURN_TIMEOUT_MS = 600_000;
26
+ /** Permission modes accepted for `builtin:claude-code` (Claude Code `--permission-mode`). */
27
+ export const ALLOWED_CLAUDE_CODE_PERMISSION_MODES = new Set([
28
+ 'default',
29
+ 'acceptEdits',
30
+ 'plan',
31
+ 'bypassPermissions',
32
+ ]);
33
+ export function defaultDispatcherClaudeCodeConfig() {
34
+ return {
35
+ bin: DEFAULT_CLAUDE_CODE_BIN,
36
+ model: null,
37
+ permission_mode: null,
38
+ remote_control: false,
39
+ extra_args: [],
40
+ extra_env: {},
41
+ turn_timeout_ms: DEFAULT_CLAUDE_CODE_TURN_TIMEOUT_MS,
42
+ };
43
+ }
44
+ export function readDispatcherClaudeCodeConfig(rawClaude, file, prefix) {
45
+ rejectUnknownKeys(rawClaude, new Set([
46
+ 'bin',
47
+ 'model',
48
+ 'permission_mode',
49
+ 'remote_control',
50
+ 'extra_args',
51
+ 'extra_env',
52
+ 'turn_timeout_ms',
53
+ ]), file, prefix);
54
+ const defaults = defaultDispatcherClaudeCodeConfig();
55
+ const bin = readOptionalString(rawClaude, 'bin', file, prefix) ?? defaults.bin;
56
+ if (bin.trim() === '') {
57
+ throw new Error(`dreamux config error in ${file}: ${prefix}bin must be a non-empty string`);
58
+ }
59
+ const permissionMode = readOptionalString(rawClaude, 'permission_mode', file, prefix);
60
+ if (permissionMode !== null &&
61
+ !ALLOWED_CLAUDE_CODE_PERMISSION_MODES.has(permissionMode)) {
62
+ throw new Error(`dreamux config error in ${file}: ${prefix}permission_mode='${permissionMode}' is not one of ${Array.from(ALLOWED_CLAUDE_CODE_PERMISSION_MODES).join(' | ')}`);
63
+ }
64
+ return {
65
+ bin,
66
+ model: readOptionalString(rawClaude, 'model', file, prefix),
67
+ permission_mode: permissionMode,
68
+ remote_control: readOptionalBoolean(rawClaude, 'remote_control', defaults.remote_control, file, prefix),
69
+ extra_args: requireStringArray(rawClaude, 'extra_args', defaults.extra_args, file, prefix),
70
+ extra_env: requireStringRecord(rawClaude, 'extra_env', defaults.extra_env, file, prefix),
71
+ turn_timeout_ms: requirePositiveInt(rawClaude, 'turn_timeout_ms', defaults.turn_timeout_ms, file, prefix),
72
+ };
73
+ }
74
+ /**
75
+ * Typed accessor for a dispatcher's resolved claude-code runtime config. Typed
76
+ * structurally (not against `DispatcherConfig`) so this module never imports
77
+ * the host config type — a full `DispatcherConfig` still satisfies it at the
78
+ * call sites.
79
+ */
80
+ export function dispatcherClaudeCodeConfig(dispatcher) {
81
+ if (dispatcher.runtime.provider !== BUILTIN_CLAUDE_CODE_PROVIDER_REF) {
82
+ throw new Error(`dispatcher '${dispatcher.id}' runtime provider ${JSON.stringify(dispatcher.runtime.provider)} is not wired to Claude Code`);
83
+ }
84
+ return dispatcher.runtime.config;
85
+ }
86
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The `builtin:claude-code` self-reported doctor surface (issue #146 fold;
3
+ * relocated into the owning package by the issue #209 cleanup).
4
+ *
5
+ * Claude Code has no host-managed home/auth/version state Dreamux owns, so it
6
+ * only declares its bin check; the internal diagnostic is a neutral pass. Runs
7
+ * entirely against the neutral `@excitedjs/dreamux-types` diagnostic context.
8
+ */
9
+ import type { AgentRuntimeDiagnostic } from '@excitedjs/dreamux-types';
10
+ import { type DispatcherClaudeCodeConfig } from './config.js';
11
+ export declare const claudeCodeAgentRuntimeDiagnostic: AgentRuntimeDiagnostic<DispatcherClaudeCodeConfig>;
12
+ //# sourceMappingURL=diagnostic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostic.d.ts","sourceRoot":"","sources":["../src/diagnostic.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAEV,sBAAsB,EAGvB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,KAAK,0BAA0B,EAEhC,MAAM,aAAa,CAAC;AAWrB,eAAO,MAAM,gCAAgC,EAAE,sBAAsB,CAAC,0BAA0B,CAkB7F,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { DEFAULT_CLAUDE_CODE_BIN, } from './config.js';
2
+ function claudeBinCheckName(scope) {
3
+ return scope === 'managedService'
4
+ ? 'managed service Claude Code binary'
5
+ : 'claude-code binary';
6
+ }
7
+ export const claudeCodeAgentRuntimeDiagnostic = {
8
+ binChecks(context) {
9
+ return [
10
+ {
11
+ name: claudeBinCheckName(context.scope),
12
+ bin: context.config.bin || DEFAULT_CLAUDE_CODE_BIN,
13
+ args: ['--help'],
14
+ },
15
+ ];
16
+ },
17
+ async runDiagnostic() {
18
+ return {
19
+ ok: true,
20
+ detail: 'Claude Code runtime has no host-managed home state',
21
+ errors: [],
22
+ };
23
+ },
24
+ };
25
+ //# sourceMappingURL=diagnostic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostic.js","sourceRoot":"","sources":["../src/diagnostic.ts"],"names":[],"mappings":"AAeA,OAAO,EAEL,uBAAuB,GACxB,MAAM,aAAa,CAAC;AAKrB,SAAS,kBAAkB,CAAC,KAAuC;IACjE,OAAO,KAAK,KAAK,gBAAgB;QAC/B,CAAC,CAAC,oCAAoC;QACtC,CAAC,CAAC,oBAAoB,CAAC;AAC3B,CAAC;AAED,MAAM,CAAC,MAAM,gCAAgC,GAC3C;IACE,SAAS,CAAC,OAAO;QACf,OAAO;YACL;gBACE,IAAI,EAAE,kBAAkB,CAAC,OAAO,CAAC,KAAK,CAAC;gBACvC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,uBAAuB;gBAClD,IAAI,EAAE,CAAC,QAAQ,CAAC;aACjB;SACF,CAAC;IACJ,CAAC;IACD,KAAK,CAAC,aAAa;QACjB,OAAO;YACL,EAAE,EAAE,IAAI;YACR,MAAM,EAAE,oDAAoD;YAC5D,MAAM,EAAE,EAAE;SACX,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * `@excitedjs/agent-runtime-claude-code` — the built-in Claude Code Agent
3
+ * Runtime provider for Dreamux (alias `builtin:claude-code`). Implements the
4
+ * `@excitedjs/dreamux-types` `AgentRuntimeProvider` contract; never imports
5
+ * `@excitedjs/dreamux` core.
6
+ */
7
+ export { default, createClaudeCodeAgentRuntimeProvider, dispatcherClaudeCodeConfig, CLAUDE_CODE_AGENT_RUNTIME_CAPABILITIES, type ClaudeCodeAgentRuntimeProviderOptions, type ClaudeCodeProviderFactoryContext, } from './provider.js';
8
+ export { ClaudeCodeRuntime, type ClaudeCodeRuntimeDeps, } from './runtime.js';
9
+ export { createDefaultClaudeCodeSession, type ClaudeCodeSession, type ClaudeCodeSessionFactory, type ClaudeCodeSessionSpec, type TurnOutcome, type TurnSubmitOptions, } from './supervisor.js';
10
+ export { ClaudeCodeStreamRpc, type ClaudeCodeStreamRpcOptions, } from './rpc.js';
11
+ export { LineBuffer, TurnAggregator, assistantText, parseLine, buildUserMessage, buildRemoteControlEnable, buildCanUseToolAllow, buildControlAck, } from './stream.js';
12
+ export type { JsonObject, ParsedLine, ResultEnvelope, } from './types.js';
13
+ export { claudeCodeMcpConfig, stringifyClaudeCodeMcpConfig, type ClaudeCodeMcpConfig, } from './mcp-config.js';
14
+ export { claudeCodeResidentArgs, claudeCodeSkillAddDirArgs, CLAUDE_SKILLS_PARENT_LAYOUT, type ClaudeCodeResidentArgsInput, } from './args.js';
15
+ export { type DispatcherClaudeCodeConfig, readDispatcherClaudeCodeConfig, defaultDispatcherClaudeCodeConfig, DEFAULT_CLAUDE_CODE_BIN, DEFAULT_CLAUDE_CODE_TURN_TIMEOUT_MS, ALLOWED_CLAUDE_CODE_PERMISSION_MODES, } from './config.js';
16
+ export { BUILTIN_CLAUDE_CODE_PROVIDER_REF } from './provider-ref.js';
17
+ export { claudeCodeAgentRuntimeDiagnostic } from './diagnostic.js';
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,OAAO,EACP,oCAAoC,EACpC,0BAA0B,EAC1B,sCAAsC,EACtC,KAAK,qCAAqC,EAC1C,KAAK,gCAAgC,GACtC,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,iBAAiB,EACjB,KAAK,qBAAqB,GAC3B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,8BAA8B,EAC9B,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,KAAK,iBAAiB,GACvB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,mBAAmB,EACnB,KAAK,0BAA0B,GAChC,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,UAAU,EACV,cAAc,EACd,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,UAAU,EACV,UAAU,EACV,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,mBAAmB,EACnB,4BAA4B,EAC5B,KAAK,mBAAmB,GACzB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,2BAA2B,EAC3B,KAAK,2BAA2B,GACjC,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,KAAK,0BAA0B,EAC/B,8BAA8B,EAC9B,iCAAiC,EACjC,uBAAuB,EACvB,mCAAmC,EACnC,oCAAoC,GACrC,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAGrE,OAAO,EAAE,gCAAgC,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * `@excitedjs/agent-runtime-claude-code` — the built-in Claude Code Agent
3
+ * Runtime provider for Dreamux (alias `builtin:claude-code`). Implements the
4
+ * `@excitedjs/dreamux-types` `AgentRuntimeProvider` contract; never imports
5
+ * `@excitedjs/dreamux` core.
6
+ */
7
+ export { default, createClaudeCodeAgentRuntimeProvider, dispatcherClaudeCodeConfig, CLAUDE_CODE_AGENT_RUNTIME_CAPABILITIES, } from './provider.js';
8
+ export { ClaudeCodeRuntime, } from './runtime.js';
9
+ export { createDefaultClaudeCodeSession, } from './supervisor.js';
10
+ export { ClaudeCodeStreamRpc, } from './rpc.js';
11
+ export { LineBuffer, TurnAggregator, assistantText, parseLine, buildUserMessage, buildRemoteControlEnable, buildCanUseToolAllow, buildControlAck, } from './stream.js';
12
+ export { claudeCodeMcpConfig, stringifyClaudeCodeMcpConfig, } from './mcp-config.js';
13
+ export { claudeCodeResidentArgs, claudeCodeSkillAddDirArgs, CLAUDE_SKILLS_PARENT_LAYOUT, } from './args.js';
14
+ export { readDispatcherClaudeCodeConfig, defaultDispatcherClaudeCodeConfig, DEFAULT_CLAUDE_CODE_BIN, DEFAULT_CLAUDE_CODE_TURN_TIMEOUT_MS, ALLOWED_CLAUDE_CODE_PERMISSION_MODES, } from './config.js';
15
+ export { BUILTIN_CLAUDE_CODE_PROVIDER_REF } from './provider-ref.js';
16
+ // The claude-code doctor surface now lives in this package (issue #209 cleanup).
17
+ export { claudeCodeAgentRuntimeDiagnostic } from './diagnostic.js';
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,OAAO,EACP,oCAAoC,EACpC,0BAA0B,EAC1B,sCAAsC,GAGvC,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,iBAAiB,GAElB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,8BAA8B,GAM/B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,mBAAmB,GAEpB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,UAAU,EACV,cAAc,EACd,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,GAChB,MAAM,aAAa,CAAC;AAQrB,OAAO,EACL,mBAAmB,EACnB,4BAA4B,GAE7B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,2BAA2B,GAE5B,MAAM,WAAW,CAAC;AAEnB,OAAO,EAEL,8BAA8B,EAC9B,iCAAiC,EACjC,uBAAuB,EACvB,mCAAmC,EACnC,oCAAoC,GACrC,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAErE,iFAAiF;AACjF,OAAO,EAAE,gCAAgC,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Neutral completion-body resolution for the Claude Code runtime.
3
+ *
4
+ * A teammate completion is delivered back to the dispatcher as turn text. When
5
+ * the result is short it is inlined verbatim; when it overflows the inline
6
+ * budget the full result is spilled to an owner-only 0600 file under the
7
+ * host-supplied spill directory and only the path is inlined, so a large result
8
+ * never floods the dispatcher's context window.
9
+ *
10
+ * Vendored from the host's neutral `agent-runtime/completion-body.ts` so this
11
+ * package never imports `@excitedjs/dreamux` core. The spill directory is
12
+ * supplied by the host through the create context's path context, so this
13
+ * module owns no Dreamux layout contract — only the safe filename shape inside
14
+ * that directory.
15
+ */
16
+ import type { CompletionEnvelope } from '@excitedjs/dreamux-types';
17
+ export declare const COMPLETION_INLINE_BUDGET_DEFAULT = 32000;
18
+ export declare const COMPLETION_INLINE_BUDGET_MAX = 160000;
19
+ export type ResolvedCompletionBody = {
20
+ kind: 'inline';
21
+ text: string;
22
+ } | {
23
+ kind: 'spilled';
24
+ path: string;
25
+ };
26
+ /**
27
+ * Resolve the effective inline budget from the environment: unset/blank or
28
+ * non-positive falls back to the default; values above the upper bound are
29
+ * clamped; a non-integer value falls back to the default.
30
+ */
31
+ export declare function completionInlineBudget(env?: NodeJS.ProcessEnv): number;
32
+ /**
33
+ * Decide whether a completion result is inlined or spilled. Spilling writes the
34
+ * FULL result to a 0600 file (async fs only) under the host-supplied
35
+ * `spillDir`, then returns the path; the caller inlines only that path.
36
+ */
37
+ export declare function resolveCompletionBody(completion: CompletionEnvelope, spillDir: string): Promise<ResolvedCompletionBody>;
38
+ //# sourceMappingURL=completion-body.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completion-body.d.ts","sourceRoot":"","sources":["../../src/internal/completion-body.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAInE,eAAO,MAAM,gCAAgC,QAAS,CAAC;AACvD,eAAO,MAAM,4BAA4B,SAAU,CAAC;AAGpD,MAAM,MAAM,sBAAsB,GAC9B;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAgBtC;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,GAAE,MAAM,CAAC,UAAmC,GAC9C,MAAM,CAUR;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,UAAU,EAAE,kBAAkB,EAC9B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,sBAAsB,CAAC,CAUjC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Neutral completion-body resolution for the Claude Code runtime.
3
+ *
4
+ * A teammate completion is delivered back to the dispatcher as turn text. When
5
+ * the result is short it is inlined verbatim; when it overflows the inline
6
+ * budget the full result is spilled to an owner-only 0600 file under the
7
+ * host-supplied spill directory and only the path is inlined, so a large result
8
+ * never floods the dispatcher's context window.
9
+ *
10
+ * Vendored from the host's neutral `agent-runtime/completion-body.ts` so this
11
+ * package never imports `@excitedjs/dreamux` core. The spill directory is
12
+ * supplied by the host through the create context's path context, so this
13
+ * module owns no Dreamux layout contract — only the safe filename shape inside
14
+ * that directory.
15
+ */
16
+ import { chmod, writeFile } from 'node:fs/promises';
17
+ import { join } from 'node:path';
18
+ import { ensureOwnerOnlyDir } from './os.js';
19
+ export const COMPLETION_INLINE_BUDGET_DEFAULT = 32_000;
20
+ export const COMPLETION_INLINE_BUDGET_MAX = 160_000;
21
+ const COMPLETION_INLINE_BUDGET_ENV = 'TASK_MAX_OUTPUT_LENGTH';
22
+ /** Sanitize a name into a safe single path segment. */
23
+ function safeSegment(name) {
24
+ return name.replace(/[^A-Za-z0-9._-]/g, '_');
25
+ }
26
+ /** Spill file for an overflowing completion result, inside `spillDir`. */
27
+ function completionOutputPath(spillDir, source, id) {
28
+ return join(spillDir, `teammate-${safeSegment(source)}-${safeSegment(id)}.output`);
29
+ }
30
+ /**
31
+ * Resolve the effective inline budget from the environment: unset/blank or
32
+ * non-positive falls back to the default; values above the upper bound are
33
+ * clamped; a non-integer value falls back to the default.
34
+ */
35
+ export function completionInlineBudget(env = globalThis.process.env) {
36
+ const raw = env[COMPLETION_INLINE_BUDGET_ENV]?.trim();
37
+ if (raw === undefined || raw === '' || !/^\d+$/.test(raw)) {
38
+ return COMPLETION_INLINE_BUDGET_DEFAULT;
39
+ }
40
+ const parsed = Number(raw);
41
+ if (parsed <= 0) {
42
+ return COMPLETION_INLINE_BUDGET_DEFAULT;
43
+ }
44
+ return Math.min(parsed, COMPLETION_INLINE_BUDGET_MAX);
45
+ }
46
+ /**
47
+ * Decide whether a completion result is inlined or spilled. Spilling writes the
48
+ * FULL result to a 0600 file (async fs only) under the host-supplied
49
+ * `spillDir`, then returns the path; the caller inlines only that path.
50
+ */
51
+ export async function resolveCompletionBody(completion, spillDir) {
52
+ const budget = completionInlineBudget();
53
+ if (completion.result.length <= budget) {
54
+ return { kind: 'inline', text: completion.result };
55
+ }
56
+ const path = completionOutputPath(spillDir, completion.source, completion.id);
57
+ await ensureOwnerOnlyDir(spillDir);
58
+ await writeFile(path, completion.result, { mode: 0o600 });
59
+ await chmod(path, 0o600);
60
+ return { kind: 'spilled', path };
61
+ }
62
+ //# sourceMappingURL=completion-body.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completion-body.js","sourceRoot":"","sources":["../../src/internal/completion-body.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC;AACvD,MAAM,CAAC,MAAM,4BAA4B,GAAG,OAAO,CAAC;AACpD,MAAM,4BAA4B,GAAG,wBAAwB,CAAC;AAM9D,uDAAuD;AACvD,SAAS,WAAW,CAAC,IAAY;IAC/B,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;AAC/C,CAAC;AAED,0EAA0E;AAC1E,SAAS,oBAAoB,CAC3B,QAAgB,EAChB,MAAc,EACd,EAAU;IAEV,OAAO,IAAI,CAAC,QAAQ,EAAE,YAAY,WAAW,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;AACrF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAyB,UAAU,CAAC,OAAO,CAAC,GAAG;IAE/C,MAAM,GAAG,GAAG,GAAG,CAAC,4BAA4B,CAAC,EAAE,IAAI,EAAE,CAAC;IACtD,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1D,OAAO,gCAAgC,CAAC;IAC1C,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3B,IAAI,MAAM,IAAI,CAAC,EAAE,CAAC;QAChB,OAAO,gCAAgC,CAAC;IAC1C,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,4BAA4B,CAAC,CAAC;AACxD,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,UAA8B,EAC9B,QAAgB;IAEhB,MAAM,MAAM,GAAG,sBAAsB,EAAE,CAAC;IACxC,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,EAAE,CAAC;QACvC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,CAAC;IACrD,CAAC;IACD,MAAM,IAAI,GAAG,oBAAoB,CAAC,QAAQ,EAAE,UAAU,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC;IAC9E,MAAM,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1D,MAAM,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACzB,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AACnC,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Neutral config validation primitives.
3
+ *
4
+ * Extracted from `config/config.ts` so that per-runtime config readers (each
5
+ * builtin's `agent-runtime/builtin/<name>/config.ts`) can validate their own
6
+ * config blocks without importing `config/config.ts` — importing the host
7
+ * config module from a builtin would re-form the builtin -> config import
8
+ * cycle. These helpers are runtime-agnostic: they only know about JSON shapes
9
+ * and produce `dreamux config error in <file>: ...` messages.
10
+ */
11
+ export declare function isPlainObject(v: unknown): v is Record<string, unknown>;
12
+ export declare function describeType(v: unknown): string;
13
+ export declare function rejectUnknownKeys(obj: Record<string, unknown>, allowed: Set<string>, file: string, prefix: string): void;
14
+ export declare function requireNonEmptyString(obj: Record<string, unknown>, key: string, file: string, prefix?: string): string;
15
+ export declare function readOptionalString(obj: Record<string, unknown>, key: string, file: string, prefix?: string): string | null;
16
+ export declare function readOptionalBoolean(obj: Record<string, unknown>, key: string, fallback: boolean, file: string, prefix?: string): boolean;
17
+ export declare function requireStringArray(obj: Record<string, unknown>, key: string, fallback: string[], file: string, prefix?: string): string[];
18
+ export declare function requireStringRecord(obj: Record<string, unknown>, key: string, fallback: Record<string, string>, file: string, prefix?: string): Record<string, string>;
19
+ export declare function requirePositiveInt(obj: Record<string, unknown>, key: string, fallback: number, file: string, prefix?: string): number;
20
+ export declare function readProviderConfigObject(rawConfig: unknown, file: string, name: string, options?: {
21
+ allowMissing?: boolean;
22
+ }): Record<string, unknown>;
23
+ //# sourceMappingURL=config-validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-validate.d.ts","sourceRoot":"","sources":["../../src/internal/config-validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEtE;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAI/C;AAED,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,EACpB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,IAAI,CAgBN;AAuBD,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,MAAM,SAAK,GACV,MAAM,CAMR;AAED,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,MAAM,SAAK,GACV,MAAM,GAAG,IAAI,CAIf;AAED,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,OAAO,EACjB,IAAI,EAAE,MAAM,EACZ,MAAM,SAAK,GACV,OAAO,CAOT;AAED,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAAE,EAClB,IAAI,EAAE,MAAM,EACZ,MAAM,SAAK,GACV,MAAM,EAAE,CAgBV;AAED,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,IAAI,EAAE,MAAM,EACZ,MAAM,SAAK,GACV,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkBxB;AAgBD,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,MAAM,SAAK,GACV,MAAM,CASR;AAED,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,OAAO,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAO,GACvC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQzB"}