@kodax-ai/kodax 0.7.75 → 0.7.77

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 (115) hide show
  1. package/CHANGELOG.md +595 -358
  2. package/LICENSE +158 -158
  3. package/README.md +1613 -1549
  4. package/README_CN.md +946 -895
  5. package/config-templates/config.example.jsonc +33 -33
  6. package/config-templates/integrations/a2a.example.jsonc +98 -98
  7. package/config-templates/integrations/extensions.example.jsonc +7 -7
  8. package/config-templates/integrations/mcp.example.jsonc +16 -16
  9. package/dist/builtin/code-review/SKILL.md +22 -22
  10. package/dist/builtin/skill-creator/scripts/aggregate-benchmark.d.ts +46 -46
  11. package/dist/builtin/skill-creator/scripts/analyze-benchmark.d.ts +46 -46
  12. package/dist/builtin/skill-creator/scripts/compare-runs.d.ts +62 -62
  13. package/dist/builtin/skill-creator/scripts/generate-review.d.ts +33 -33
  14. package/dist/builtin/skill-creator/scripts/grade-evals.d.ts +73 -73
  15. package/dist/builtin/skill-creator/scripts/improve-description.d.ts +23 -23
  16. package/dist/builtin/skill-creator/scripts/init-skill.d.ts +14 -14
  17. package/dist/builtin/skill-creator/scripts/install-skill.d.ts +29 -29
  18. package/dist/builtin/skill-creator/scripts/package-skill.d.ts +38 -38
  19. package/dist/builtin/skill-creator/scripts/quick-validate.d.ts +8 -8
  20. package/dist/builtin/skill-creator/scripts/run-eval.d.ts +66 -66
  21. package/dist/builtin/skill-creator/scripts/run-loop.d.ts +49 -49
  22. package/dist/builtin/skill-creator/scripts/run-trigger-eval.d.ts +58 -58
  23. package/dist/chunks/agent-NGSWFE73.js +2 -0
  24. package/dist/chunks/argument-completer-WGGZPEEO.js +2 -0
  25. package/dist/chunks/chunk-27QLRH3D.js +5 -0
  26. package/dist/chunks/chunk-2MQPVY6P.js +770 -0
  27. package/dist/chunks/chunk-3DD4QEBH.js +22 -0
  28. package/dist/chunks/chunk-6WAPVAGQ.js +74 -0
  29. package/dist/chunks/chunk-AOENDSVN.js +448 -0
  30. package/dist/chunks/{chunk-G5VW55T4.js → chunk-EH7AOMJ7.js} +1 -1
  31. package/dist/chunks/{chunk-N6M2LYEP.js → chunk-FNW2XUL5.js} +9 -9
  32. package/dist/chunks/chunk-FSXI4MAV.js +78 -0
  33. package/dist/chunks/{chunk-4PVSDE5L.js → chunk-HORNWBYR.js} +1 -1
  34. package/dist/chunks/chunk-HV2GMZUZ.js +343 -0
  35. package/dist/chunks/chunk-IQT4RPCE.js +46 -0
  36. package/dist/chunks/{chunk-SB75RNNR.js → chunk-JS2BHGJP.js} +2 -2
  37. package/dist/chunks/chunk-OAMKECRG.js +381 -0
  38. package/dist/chunks/{chunk-OJQQRLZJ.js → chunk-ON2WG2LG.js} +2 -2
  39. package/dist/chunks/{chunk-QRBWNYFV.js → chunk-RUGAAHTF.js} +17 -17
  40. package/dist/chunks/chunk-TGCG7U2W.js +37 -0
  41. package/dist/chunks/chunk-XSA37BVM.js +5 -0
  42. package/dist/chunks/compaction-config-BE7VYWH6.js +2 -0
  43. package/dist/chunks/{construction-bootstrap-3TQWTHSQ.js → construction-bootstrap-RPRL3L7R.js} +1 -1
  44. package/dist/chunks/dist-FDSOIR35.js +2 -0
  45. package/dist/chunks/dist-ZZBNVTKU.js +2 -0
  46. package/dist/chunks/host-QAKQVC4A.js +2 -0
  47. package/dist/chunks/run-manager-N4UFWA2D.js +2 -0
  48. package/dist/chunks/{utils-HMVP6XPH.js → utils-AUHCI4D5.js} +1 -1
  49. package/dist/index.d.ts +17 -16
  50. package/dist/index.js +2 -2
  51. package/dist/kodax_bootstrap.js +25 -25
  52. package/dist/kodax_cli.js +1276 -1229
  53. package/dist/provider-capabilities.json +392 -334
  54. package/dist/runtime-worker.js +1162 -1115
  55. package/dist/sdk-a2a.d.ts +12 -11
  56. package/dist/sdk-a2a.js +1 -1
  57. package/dist/sdk-agent.d.ts +56 -21
  58. package/dist/sdk-agent.js +1 -1
  59. package/dist/sdk-coding.d.ts +120 -21
  60. package/dist/sdk-coding.js +1 -1
  61. package/dist/sdk-experimental-memory.d.ts +14 -597
  62. package/dist/sdk-experimental-memory.js +1 -1
  63. package/dist/sdk-llm.d.ts +218 -6
  64. package/dist/sdk-llm.js +1 -1
  65. package/dist/sdk-mcp.js +1 -1
  66. package/dist/sdk-media.d.ts +1 -1
  67. package/dist/sdk-media.js +1 -1
  68. package/dist/sdk-repl.d.ts +15 -14
  69. package/dist/sdk-repl.js +1 -1
  70. package/dist/sdk-runtime.d.ts +34 -18
  71. package/dist/sdk-runtime.js +1 -1
  72. package/dist/sdk-session.d.ts +7 -6
  73. package/dist/sdk-session.js +1 -1
  74. package/dist/sdk-skills.js +1 -1
  75. package/dist/semantic-worker.js +14 -14
  76. package/dist/types-chunks/{base.d-ChvpaKjZ.d.ts → base.d-4e74xDdy.d.ts} +13 -1
  77. package/dist/types-chunks/{bash-prefix-extractor.d-r1beOESM.d.ts → bash-prefix-extractor.d-pZdu6qt7.d.ts} +197 -5
  78. package/dist/types-chunks/{capability-learning.d-DPrYxRjF.d.ts → capability-learning.d-CVsdHw4j.d.ts} +1 -1
  79. package/dist/types-chunks/{capsule.d-zeqV4IQX.d.ts → capsule.d-CxCm1KZz.d.ts} +2 -2
  80. package/dist/types-chunks/{commands.d-DUxnK2TU.d.ts → commands.d-BccESAMV.d.ts} +5 -5
  81. package/dist/types-chunks/{guardrail.d-qjuKJZ31.d.ts → guardrail.d-B0PwAZVR.d.ts} +3 -3
  82. package/dist/types-chunks/{guardrail.d-CWYD1bdL.d.ts → guardrail.d-CJx9RRd3.d.ts} +1 -1
  83. package/dist/types-chunks/{history-retrieval.d-BKTJIrVd.d.ts → history-retrieval.d-B__aEN62.d.ts} +2 -2
  84. package/dist/types-chunks/{public-api.d-CX4B11qY.d.ts → public-api.d--fF88JrC.d.ts} +3 -3
  85. package/dist/types-chunks/{run-manager.d-B9fEIjZk.d.ts → run-manager.d-B47hIqnI.d.ts} +1 -1
  86. package/dist/types-chunks/{sdk-session-B0fhAOPa.d.ts → sdk-session-CLWf8Adb.d.ts} +3 -3
  87. package/dist/types-chunks/{side-query.d-DWTMsndP.d.ts → side-query.d-5JvXhuOZ.d.ts} +22 -10
  88. package/dist/types-chunks/types-LanCEDj8.d.ts +623 -0
  89. package/dist/types-chunks/{types.d-DEctY20M.d.ts → types.d-CODuyyqy.d.ts} +2 -2
  90. package/dist/types-chunks/{types.d-Bm_y6YuM.d.ts → types.d-DCsKM8aT.d.ts} +4 -4
  91. package/dist/types-chunks/{types.d-CSmF0t0n.d.ts → types.d-DIpZJKUl.d.ts} +15 -0
  92. package/dist/types-chunks/{types.d-sRLugmjy.d.ts → types.d-RdWRfUEs.d.ts} +47 -4
  93. package/dist/types-chunks/{utils.d-D0wPxz8y.d.ts → utils.d-CDduqbFw.d.ts} +5 -5
  94. package/docs/SDK_EMBEDDER_GUIDE.md +197 -68
  95. package/package.json +2 -1
  96. package/scripts/kodax-bin.cjs +28 -28
  97. package/scripts/production-env.cjs +25 -25
  98. package/dist/chunks/agent-LVZJB2GQ.js +0 -2
  99. package/dist/chunks/argument-completer-GHWEWPVQ.js +0 -2
  100. package/dist/chunks/chunk-5WSOB34U.js +0 -329
  101. package/dist/chunks/chunk-6YUDR7WN.js +0 -5
  102. package/dist/chunks/chunk-6ZMKX3XF.js +0 -74
  103. package/dist/chunks/chunk-737LI7OS.js +0 -369
  104. package/dist/chunks/chunk-BN3W2DQY.js +0 -5
  105. package/dist/chunks/chunk-DEHOFNQA.js +0 -427
  106. package/dist/chunks/chunk-F7AIEHSS.js +0 -46
  107. package/dist/chunks/chunk-OGL227XV.js +0 -37
  108. package/dist/chunks/chunk-Q65EAOX6.js +0 -78
  109. package/dist/chunks/chunk-QSMXI4MH.js +0 -770
  110. package/dist/chunks/chunk-UJRRZINL.js +0 -22
  111. package/dist/chunks/compaction-config-L2YZK7Q3.js +0 -2
  112. package/dist/chunks/dist-D3EPVAOZ.js +0 -2
  113. package/dist/chunks/dist-ZJFTZJ55.js +0 -2
  114. package/dist/chunks/host-KHDXYFVG.js +0 -2
  115. package/dist/chunks/run-manager-CD24OO4V.js +0 -2
package/README.md CHANGED
@@ -1,1558 +1,1622 @@
1
- <p align="center">
2
- <picture>
3
- <source media="(prefers-color-scheme: dark)" srcset="assets/logo-dark.svg">
4
- <source media="(prefers-color-scheme: light)" srcset="assets/logo-light.svg">
5
- <img src="assets/logo-light.svg" alt="KodaX" width="640">
6
- </picture>
7
- </p>
8
-
9
- <p align="center">
10
- <b>Source-available AI coding agent on every LLM you can reach.</b><br>
11
- Anthropic · OpenAI · DeepSeek · Kimi · Zhipu · MiniMax · MiMo · Ark · Qwen · Gemini · Codex.<br>
12
- REPL · CLI · library · Node-free single binary.
13
- </p>
14
-
15
- <p align="center">
16
- <a href="https://www.npmjs.com/package/@kodax-ai/kodax"><img alt="npm version" src="https://img.shields.io/npm/v/@kodax-ai/kodax?style=flat-square&color=cb3837"></a>
17
- <a href="LICENSE"><img alt="license" src="https://img.shields.io/badge/license-KAI--FCL_1.0-orange?style=flat-square"></a>
18
- <a href="https://github.com/icetomoyo/KodaX/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/icetomoyo/KodaX?style=flat-square&logo=github&color=f1c40f"></a>
19
- <a href="https://github.com/icetomoyo/KodaX/actions"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/icetomoyo/KodaX/release.yml?style=flat-square&label=release"></a>
20
- <img alt="providers" src="https://img.shields.io/badge/LLMs-16_aliases_+_custom-2ecc71?style=flat-square">
21
- </p>
22
-
23
- <p align="center">
24
- <a href="#install-in-30-seconds">Install</a> ·
25
- <a href="#four-ways-to-use-kodax">Usage</a> ·
26
- <a href="#sdk-usage">SDK</a> ·
27
- <a href="CHANGELOG.md">Changelog</a> ·
28
- <a href="docs/FEATURE_LIST.md">Roadmap</a> ·
29
- <a href="https://github.com/icetomoyo/KodaX/discussions">Discussions</a> ·
30
- <a href="README_CN.md">中文 README</a>
31
- </p>
32
-
33
- <p align="center">
34
- <img src="kodax-hd.gif" alt="KodaX in action" width="880">
35
- </p>
36
-
37
- ---
38
-
39
- ## Install in 30 seconds
40
-
41
- ```bash
42
- npm i -g @kodax-ai/kodax
43
-
44
- # Pick any one you have an API key for:
45
- export ZHIPU_API_KEY=... # or ANTHROPIC_API_KEY / OPENAI_API_KEY / KIMI_API_KEY /
46
- # MINIMAX_API_KEY / MIMO_API_KEY / ARK_API_KEY / QWEN_API_KEY /
47
- # QWEN_TOKEN_API_KEY /
48
- # DEEPSEEK_API_KEY / GEMINI_API_KEY
49
-
50
- kodax
51
- ```
52
-
53
- That's it. You're in the REPL — ask anything in natural language. If this is a
54
- new machine with no provider selection or supported API-key environment
55
- variable, the bare `kodax` launch opens a metadata-only setup flow first. It
56
- never asks for the key itself; after choosing a provider/model, set the named
57
- environment variable, restart the terminal, and run `kodax` again. Use
58
- `kodax setup` to rerun that flow explicitly.
59
-
60
- > **No-Node target machines:** download a Bun-compiled single binary for Windows / macOS / Linux × x64 + arm64 from the [GitHub Releases](https://github.com/icetomoyo/KodaX/releases) page. See [docs/release.md](docs/release.md) for the build pipeline.
61
-
62
- ---
63
-
64
- ## Four ways to use KodaX
65
-
66
- | Form | Command / Import | When to use it |
67
- |---|---|---|
68
- | **REPL** | `kodax` | Interactive multi-turn coding session with streaming UI, permissions, slash commands |
69
- | **CLI** | `kodax -p "your task"` | One-shot scripted task, CI runs, batch processing |
70
- | **Library** | `import { runKodaX } from '@kodax-ai/kodax'` | Embed in your own tool / agent / web service |
71
- | **Single binary** | `./kodax` | Distribute to machines that don't have Node installed |
72
-
73
- ---
74
-
75
- ## Why KodaX
76
-
77
- <table>
78
- <tr>
79
- <td width="33%" align="center" valign="top">
80
- <h3>🇨🇳 6 China-native LLMs</h3>
81
- <sub>Zhipu · Kimi · MiniMax · MiMo · Ark · Qwen</sub>
82
- <br><br>
83
- First-class adapters with cross-provider <a href="benchmark/EVAL_GUIDELINES.md">prompt-eval calibration</a> on a canonical 5-alias panel — not OpenAI-compat shims.
84
- </td>
85
- <td width="33%" align="center" valign="top">
86
- <h3>📦 Single-file binary</h3>
87
- <sub>Bun --compile · Win / macOS / Linux · x64 + arm64</sub>
88
- <br><br>
89
- No Node required on the target machine. Drop one file, run anywhere — restricted envs, CI runners, air-gapped boxes.
90
- </td>
91
- <td width="33%" align="center" valign="top">
92
- <h3>🌳 Branchable session lineage</h3>
93
- <sub>Fork · rewind · parallel edit</sub>
94
- <br><br>
95
- Conversation history is a DAG, not a list. Powers the upcoming <b>KodaX Space</b> desktop app.
96
- </td>
97
- </tr>
98
- <tr>
99
- <td align="center" valign="top">
100
- <h3>🤖 Multi-agent by default</h3>
101
- <sub>V2 Worker single-loop + Sidecar Verifier + async children</sub>
102
- <br><br>
103
- <code>spawn_agent</code>, <code>send_message</code>, <code>followup_task</code>, <code>interrupt_agent</code>, multi-instance auto-coordination with content-hash safety net.
104
- </td>
105
- <td align="center" valign="top">
106
- <h3>🧩 Skills + self-construction</h3>
107
- <sub>Markdown skills, NL triggers</sub>
108
- <br><br>
109
- 5-stage self-modification staircase (scaffold → validate → stage → test → activate) gated by an 8-invariant admission contract.
110
- </td>
111
- <td align="center" valign="top">
112
- <h3>🛠 50+ built-in tools</h3>
113
- <sub>File · shell · search · MCP · ACP</sub>
114
- <br><br>
115
- Repo intelligence, semantic search, git worktree, web fetch — all addressable through one clean tool surface.
116
- </td>
117
- </tr>
118
- </table>
119
-
120
- ## How KodaX compares
121
-
122
- | Feature | **KodaX** | Claude Code | Aider | Codex CLI | Cursor | Cline |
123
- |---|---|---|---|---|---|---|
124
- | Source license | ⚠️ KAI-FCL, non-commercial | ❌ Source-available | ✅ Apache&nbsp;2.0 | ✅ Apache&nbsp;2.0 | ❌ Proprietary | ✅ Apache&nbsp;2.0 |
125
- | Node-free single binary | ✅ Bun | ❌ Node | ❌ Python | ✅ Rust | ❌ Electron | ❌ Extension |
126
- | Native China providers<br><sub>(Zhipu · Kimi · MiniMax · MiMo · Ark · Qwen)</sub> | ✅ 6 native | ❌ | ⚠ via LiteLLM | ❌ OpenAI-first | ❌ no provider menu | ⚠ Kimi / Qwen / DeepSeek |
127
- | Branchable session lineage | ✅ fork & rewind | ⚠ routines / sessions | ❌ | ❌ | ❌ | ⚠ checkpoints |
128
- | Multi-agent + MCP + 50+ tools | ✅ all three | ✅ all three | ⚠ tools, no MCP | ✅ all three | ⚠ Composer + MCP | ✅ all three |
129
-
130
- <sub>Data verified May 2026 against public docs ([Claude Code](https://github.com/anthropics/claude-code) · [Aider](https://aider.chat/docs/llms.html) · [Codex CLI](https://github.com/openai/codex) · [Cursor](https://cursor.com) · [Cline](https://github.com/cline/cline)). ⚠ = partial / requires extra setup / not first-class. Corrections welcome via PR.</sub>
131
-
132
- ## Detailed Setup
133
-
134
- > The `npm i -g @kodax-ai/kodax` one-liner above is the fastest path. This section is for building from source, configuring custom providers, or using KodaX as a library.
135
-
136
- ### 1. Build the CLI from source
137
-
138
- ```bash
139
- git clone https://github.com/icetomoyo/KodaX.git
140
- cd KodaX
141
- npm install
142
- npm run build
143
- npm link
144
- ```
145
-
146
- ### 2. Configure a provider
147
-
148
- KodaX reads API keys from environment variables. For built-in providers, the fastest path is:
149
-
150
- ```bash
151
- # Interactive metadata-only provider/model setup (does not collect a key)
152
- kodax setup
153
- ```
154
-
155
- The command tells you the exact environment-variable name to set and exits so
156
- you can restart the terminal. You can also configure it directly:
157
-
158
- ```bash
159
- # macOS / Linux
160
- export ZHIPU_API_KEY=your_api_key
161
-
162
- # PowerShell
163
- $env:ZHIPU_API_KEY="your_api_key"
164
- ```
165
-
166
- For Qwen Token Plan, select `qwen-token-plan` and use its separate credential;
167
- `QWEN_API_KEY` does not authenticate this route:
168
-
169
- ```bash
170
- export QWEN_TOKEN_API_KEY=your_api_key
171
- kodax --provider qwen-token-plan
172
- ```
173
-
174
- For CLI defaults, create `~/.kodax/config.json`:
175
-
176
- ```json
177
- {
178
- "provider": "zhipu-coding",
179
- "effort": "auto"
180
- }
181
- ```
182
-
183
- If you need a custom base URL or an OpenAI/Anthropic-compatible endpoint, define a custom provider in the same config file:
184
-
185
- ```json
186
- {
187
- "provider": "my-openai-compatible",
188
- "customProviders": [
189
- {
190
- "name": "my-openai-compatible",
191
- "protocol": "openai",
192
- "baseUrl": "https://example.com/v1",
193
- "apiKeyEnv": "MY_LLM_API_KEY",
194
- "model": "my-model",
195
- "userAgentMode": "compat",
196
- "reasoning": {
197
- "efforts": ["off", "low", "medium", "high", "max"],
198
- "default": "high"
199
- }
200
- }
201
- ]
202
- }
203
- ```
204
-
205
- `userAgentMode` defaults to `"compat"`, which sends `KodaX` instead of the official SDK User-Agent. Switch it to `"sdk"` only when your gateway expects the upstream SDK header.
206
- For custom reasoning models, `reasoning: { efforts, default }` is the preferred v0.7.57 shape; use `"reasoning": "none"` for models without thinking capability. SDK hosts should render effort pickers from `reasoningProfile.supportedEfforts` / `defaultEffort` rather than assuming a fixed five-option ladder.
207
-
208
- #### OpenAI-compatible reasoning providers
209
-
210
- Some OpenAI-compatible reasoning models require KodaX to replay the previous assistant turn's `reasoning_content` on later requests. DeepSeek V4 thinking mode is the known load-bearing case. Built-in DeepSeek already opts in; custom providers must say so explicitly:
211
-
212
- ```json
213
- {
214
- "customProviders": [
215
- {
216
- "name": "my-deepseek-v4",
217
- "protocol": "openai",
218
- "baseUrl": "https://example.com/v1",
219
- "apiKeyEnv": "MY_DEEPSEEK_API_KEY",
220
- "model": "deepseek-v4-flash",
221
- "reasoningPreset": "deepseek-v4-openai",
222
- "replayReasoningContent": true
223
- }
224
- ]
225
- }
226
- ```
227
-
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="assets/logo-dark.svg">
4
+ <source media="(prefers-color-scheme: light)" srcset="assets/logo-light.svg">
5
+ <img src="assets/logo-light.svg" alt="KodaX" width="640">
6
+ </picture>
7
+ </p>
8
+
9
+ <p align="center">
10
+ <b>Source-available AI coding agent on every LLM you can reach.</b><br>
11
+ Anthropic · OpenAI · DeepSeek · Kimi · Zhipu · MiniMax · MiMo · Ark · Qwen · Gemini · Codex.<br>
12
+ REPL · CLI · library · Node-free single binary.
13
+ </p>
14
+
15
+ <p align="center">
16
+ <a href="https://www.npmjs.com/package/@kodax-ai/kodax"><img alt="npm version" src="https://img.shields.io/npm/v/@kodax-ai/kodax?style=flat-square&color=cb3837"></a>
17
+ <a href="LICENSE"><img alt="license" src="https://img.shields.io/badge/license-KAI--FCL_1.0-orange?style=flat-square"></a>
18
+ <a href="https://github.com/icetomoyo/KodaX/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/icetomoyo/KodaX?style=flat-square&logo=github&color=f1c40f"></a>
19
+ <a href="https://github.com/icetomoyo/KodaX/actions"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/icetomoyo/KodaX/release.yml?style=flat-square&label=release"></a>
20
+ <img alt="providers" src="https://img.shields.io/badge/LLMs-16_aliases_+_custom-2ecc71?style=flat-square">
21
+ </p>
22
+
23
+ <p align="center">
24
+ <a href="#install-in-30-seconds">Install</a> ·
25
+ <a href="#four-ways-to-use-kodax">Usage</a> ·
26
+ <a href="#sdk-usage">SDK</a> ·
27
+ <a href="CHANGELOG.md">Changelog</a> ·
28
+ <a href="docs/FEATURE_LIST.md">Roadmap</a> ·
29
+ <a href="https://github.com/icetomoyo/KodaX/discussions">Discussions</a> ·
30
+ <a href="README_CN.md">中文 README</a>
31
+ </p>
32
+
33
+ <p align="center">
34
+ <img src="kodax-hd.gif" alt="KodaX in action" width="880">
35
+ </p>
36
+
37
+ ---
38
+
39
+ ## Install in 30 seconds
40
+
41
+ ```bash
42
+ npm i -g @kodax-ai/kodax
43
+
44
+ # Pick any one you have an API key for:
45
+ export ZHIPU_API_KEY=... # or ANTHROPIC_API_KEY / OPENAI_API_KEY / KIMI_API_KEY /
46
+ # MINIMAX_API_KEY / MIMO_API_KEY / ARK_API_KEY / QWEN_API_KEY /
47
+ # QWEN_TOKEN_API_KEY /
48
+ # DEEPSEEK_API_KEY / GEMINI_API_KEY
49
+
50
+ kodax
51
+ ```
52
+
53
+ That's it. You're in the REPL — ask anything in natural language. If this is a
54
+ new machine with no provider selection or supported API-key environment
55
+ variable, the bare `kodax` launch opens a metadata-only setup flow first. It
56
+ never asks for the key itself; after choosing a provider/model, set the named
57
+ environment variable, restart the terminal, and run `kodax` again. Use
58
+ `kodax setup` to rerun that flow explicitly.
59
+
60
+ > **No-Node target machines:** download a Bun-compiled single binary for Windows / macOS / Linux × x64 + arm64 from the [GitHub Releases](https://github.com/icetomoyo/KodaX/releases) page. See [docs/release.md](docs/release.md) for the build pipeline.
61
+
62
+ ---
63
+
64
+ ## Four ways to use KodaX
65
+
66
+ | Form | Command / Import | When to use it |
67
+ |---|---|---|
68
+ | **REPL** | `kodax` | Interactive multi-turn coding session with streaming UI, permissions, slash commands |
69
+ | **CLI** | `kodax -p "your task"` | One-shot scripted task, CI runs, batch processing |
70
+ | **Library** | `import { runKodaX } from '@kodax-ai/kodax'` | Embed in your own tool / agent / web service |
71
+ | **Single binary** | `./kodax` | Distribute to machines that don't have Node installed |
72
+
73
+ ---
74
+
75
+ ## Why KodaX
76
+
77
+ <table>
78
+ <tr>
79
+ <td width="33%" align="center" valign="top">
80
+ <h3>🇨🇳 6 China-native LLMs</h3>
81
+ <sub>Zhipu · Kimi · MiniMax · MiMo · Ark · Qwen</sub>
82
+ <br><br>
83
+ First-class adapters with cross-provider <a href="benchmark/EVAL_GUIDELINES.md">prompt-eval calibration</a> on a canonical 5-alias panel — not OpenAI-compat shims.
84
+ </td>
85
+ <td width="33%" align="center" valign="top">
86
+ <h3>📦 Single-file binary</h3>
87
+ <sub>Bun --compile · Win / macOS / Linux · x64 + arm64</sub>
88
+ <br><br>
89
+ No Node required on the target machine. Drop one file, run anywhere — restricted envs, CI runners, air-gapped boxes.
90
+ </td>
91
+ <td width="33%" align="center" valign="top">
92
+ <h3>🌳 Branchable session lineage</h3>
93
+ <sub>Fork · rewind · parallel edit</sub>
94
+ <br><br>
95
+ Conversation history is a DAG, not a list. Powers the upcoming <b>KodaX Space</b> desktop app.
96
+ </td>
97
+ </tr>
98
+ <tr>
99
+ <td align="center" valign="top">
100
+ <h3>🤖 Multi-agent by default</h3>
101
+ <sub>V2 Worker single-loop + Sidecar Verifier + async children</sub>
102
+ <br><br>
103
+ <code>spawn_agent</code>, <code>send_message</code>, <code>followup_task</code>, <code>interrupt_agent</code>, multi-instance auto-coordination with content-hash safety net.
104
+ </td>
105
+ <td align="center" valign="top">
106
+ <h3>🧩 Skills + self-construction</h3>
107
+ <sub>Markdown skills, NL triggers</sub>
108
+ <br><br>
109
+ 5-stage self-modification staircase (scaffold → validate → stage → test → activate) gated by an 8-invariant admission contract.
110
+ </td>
111
+ <td align="center" valign="top">
112
+ <h3>🛠 50+ built-in tools</h3>
113
+ <sub>File · shell · search · MCP · ACP</sub>
114
+ <br><br>
115
+ Repo intelligence, semantic search, git worktree, web fetch — all addressable through one clean tool surface.
116
+ </td>
117
+ </tr>
118
+ </table>
119
+
120
+ ## How KodaX compares
121
+
122
+ | Feature | **KodaX** | Claude Code | Aider | Codex CLI | Cursor | Cline |
123
+ |---|---|---|---|---|---|---|
124
+ | Source license | ⚠️ KAI-FCL, non-commercial | ❌ Source-available | ✅ Apache&nbsp;2.0 | ✅ Apache&nbsp;2.0 | ❌ Proprietary | ✅ Apache&nbsp;2.0 |
125
+ | Node-free single binary | ✅ Bun | ❌ Node | ❌ Python | ✅ Rust | ❌ Electron | ❌ Extension |
126
+ | Native China providers<br><sub>(Zhipu · Kimi · MiniMax · MiMo · Ark · Qwen)</sub> | ✅ 6 native | ❌ | ⚠ via LiteLLM | ❌ OpenAI-first | ❌ no provider menu | ⚠ Kimi / Qwen / DeepSeek |
127
+ | Branchable session lineage | ✅ fork & rewind | ⚠ routines / sessions | ❌ | ❌ | ❌ | ⚠ checkpoints |
128
+ | Multi-agent + MCP + 50+ tools | ✅ all three | ✅ all three | ⚠ tools, no MCP | ✅ all three | ⚠ Composer + MCP | ✅ all three |
129
+
130
+ <sub>Data verified May 2026 against public docs ([Claude Code](https://github.com/anthropics/claude-code) · [Aider](https://aider.chat/docs/llms.html) · [Codex CLI](https://github.com/openai/codex) · [Cursor](https://cursor.com) · [Cline](https://github.com/cline/cline)). ⚠ = partial / requires extra setup / not first-class. Corrections welcome via PR.</sub>
131
+
132
+ ## Detailed Setup
133
+
134
+ > The `npm i -g @kodax-ai/kodax` one-liner above is the fastest path. This section is for building from source, configuring custom providers, or using KodaX as a library.
135
+
136
+ ### 1. Build the CLI from source
137
+
138
+ ```bash
139
+ git clone https://github.com/icetomoyo/KodaX.git
140
+ cd KodaX
141
+ npm install
142
+ npm run build
143
+ npm link
144
+ ```
145
+
146
+ ### 2. Configure a provider
147
+
148
+ KodaX reads API keys from environment variables. For built-in providers, the fastest path is:
149
+
150
+ ```bash
151
+ # Interactive metadata-only provider/model setup (does not collect a key)
152
+ kodax setup
153
+ ```
154
+
155
+ The command tells you the exact environment-variable name to set and exits so
156
+ you can restart the terminal. You can also configure it directly:
157
+
158
+ ```bash
159
+ # macOS / Linux
160
+ export ZHIPU_API_KEY=your_api_key
161
+
162
+ # PowerShell
163
+ $env:ZHIPU_API_KEY="your_api_key"
164
+ ```
165
+
166
+ For Qwen Token Plan, select `qwen-token-plan` and use its separate credential;
167
+ `QWEN_API_KEY` does not authenticate this route:
168
+
169
+ ```bash
170
+ export QWEN_TOKEN_API_KEY=your_api_key
171
+ kodax --provider qwen-token-plan
172
+ ```
173
+
174
+ For CLI defaults, create `~/.kodax/config.json`:
175
+
176
+ ```json
177
+ {
178
+ "provider": "zhipu-coding",
179
+ "effort": "auto"
180
+ }
181
+ ```
182
+
183
+ If you need a custom base URL or an OpenAI/Anthropic-compatible endpoint, define a custom provider in the same config file:
184
+
185
+ ```json
186
+ {
187
+ "provider": "my-openai-compatible",
188
+ "customProviders": [
189
+ {
190
+ "name": "my-openai-compatible",
191
+ "protocol": "openai",
192
+ "baseUrl": "https://example.com/v1",
193
+ "apiKeyEnv": "MY_LLM_API_KEY",
194
+ "model": "my-model",
195
+ "userAgentMode": "compat",
196
+ "reasoning": {
197
+ "efforts": ["off", "low", "medium", "high", "max"],
198
+ "default": "high"
199
+ }
200
+ }
201
+ ]
202
+ }
203
+ ```
204
+
205
+ `userAgentMode` defaults to `"compat"`, which sends `KodaX` instead of the official SDK User-Agent. Switch it to `"sdk"` only when your gateway expects the upstream SDK header.
206
+ For custom reasoning models, `reasoning: { efforts, default }` is the preferred v0.7.57 shape; use `"reasoning": "none"` for models without thinking capability. SDK hosts should render effort pickers from `reasoningProfile.supportedEfforts` / `defaultEffort` rather than assuming a fixed five-option ladder.
207
+
208
+ #### OpenAI-compatible reasoning providers
209
+
210
+ Some OpenAI-compatible reasoning models require KodaX to replay the previous assistant turn's `reasoning_content` on later requests. DeepSeek V4 thinking mode is the known load-bearing case. Built-in DeepSeek already opts in; custom providers must say so explicitly:
211
+
212
+ ```json
213
+ {
214
+ "customProviders": [
215
+ {
216
+ "name": "my-deepseek-v4",
217
+ "protocol": "openai",
218
+ "baseUrl": "https://example.com/v1",
219
+ "apiKeyEnv": "MY_DEEPSEEK_API_KEY",
220
+ "model": "deepseek-v4-flash",
221
+ "reasoningPreset": "deepseek-v4-openai",
222
+ "replayReasoningContent": true
223
+ }
224
+ ]
225
+ }
226
+ ```
227
+
228
228
  Keep `replayReasoningContent` unset or `false` for OpenAI proper and gateways that reject unknown assistant-message fields. If one gateway routes mixed models, prefer per-model overrides:
229
-
230
- ```json
231
- {
232
- "models": [
233
- { "id": "deepseek-v4-flash", "replayReasoningContent": true },
234
- { "id": "gpt-5", "replayReasoningContent": false }
235
- ]
229
+
230
+ ```json
231
+ {
232
+ "models": [
233
+ { "id": "deepseek-v4-flash", "replayReasoningContent": true },
234
+ { "id": "gpt-5", "replayReasoningContent": false }
235
+ ]
236
236
  }
237
237
  ```
238
238
 
239
- Sidecar verifier judge calls use provider-level forced tool choice when supported. If a compatible endpoint rejects the `tool_choice` parameter, KodaX retries that verifier request once without forced tool choice and still fails open rather than blocking the main Worker.
240
-
241
- #### Opting a custom provider into image / vision input (FEATURE_134 v0.7.40)
242
-
243
- If your custom provider's underlying model supports image input (vision), add a `capabilityProfile.multimodalSupport: "image-input"` block so KodaX does not artificially block multimodal requests at the SA-path policy gate. Built-in vision-capable aliases (Anthropic, OpenAI, Anthropic-/OpenAI-compatible aliases such as DeepSeek, Kimi, Qwen, Zhipu, MiniMax, MiMo, Ark, plus Gemini-CLI via the CLI's `@<path>` file-include syntax) already ship with this flag enabled by default; Codex-CLI and custom providers need to opt in when their underlying model supports image input.
244
-
245
- ```json
246
- {
247
- "customProviders": [
248
- {
249
- "name": "my-vision-provider",
250
- "protocol": "openai",
251
- "baseUrl": "https://example.com/v1",
252
- "apiKeyEnv": "MY_LLM_API_KEY",
253
- "model": "my-vision-model",
254
- "capabilityProfile": {
255
- "transport": "native-api",
256
- "conversationSemantics": "full-history",
257
- "mcpSupport": "none",
258
- "contextFidelity": "full",
259
- "toolCallingFidelity": "full",
260
- "sessionSupport": "full",
261
- "longRunningSupport": "full",
262
- "multimodalSupport": "image-input",
263
- "evidenceSupport": "full"
264
- }
265
- }
266
- ]
267
- }
268
- ```
269
-
270
- The serializer layer (`packages/llm/src/providers/anthropic.ts:770` for Anthropic-compat, `openai.ts:904` for OpenAI-compat) forwards image blocks automatically through base-class inheritance. The flag only gates whether KodaX's policy layer pre-rejects multimodal requests — the model-level vision contract remains your upstream provider's responsibility. If the model is actually text-only, you'll see the real upstream API error instead of a KodaX-side rejection.
271
-
272
- ### 3. Start in REPL or run a one-shot task
273
-
274
- ```bash
275
- # Interactive REPL
276
- kodax
277
-
278
- # Then ask naturally inside the REPL
279
- Read package.json and summarize the architecture
280
- /mode
281
- /help
282
-
283
- # One-shot CLI usage
284
- kodax "Review this repository and summarize the architecture"
285
- kodax --session review "Find the riskiest parts of src/"
286
- kodax --session review "Give me concrete fix suggestions"
287
- ```
288
-
289
- ### 4. Use it as a library
290
-
291
- Library usage still expects API keys from environment variables. If you want custom provider names or base URLs in code, register them explicitly:
292
-
293
- ```typescript
294
- import { registerCustomProviders, runKodaX } from '@kodax-ai/kodax';
295
-
296
- registerCustomProviders([
297
- {
298
- name: 'my-openai-compatible',
299
- protocol: 'openai',
300
- baseUrl: 'https://example.com/v1',
301
- apiKeyEnv: 'MY_LLM_API_KEY',
302
- model: 'my-model',
303
- userAgentMode: 'compat',
304
- },
305
- ]);
306
-
307
- const result = await runKodaX(
308
- {
309
- provider: 'my-openai-compatible',
310
- effort: 'auto',
311
- },
312
- 'Explain this codebase'
313
- );
314
- ```
315
-
316
- > **Embedding KodaX inside another app?** (KodaX Space, IDE extensions, custom CLIs)
317
- > See [docs/SDK_EMBEDDER_GUIDE.md](docs/SDK_EMBEDDER_GUIDE.md) for the runtime-mutation
318
- > surface (`startKodaX` + `RunningSession`), MCP popout manager API (`McpManager`),
319
- > Skill `` !`cmd` `` host hook, and per-app data dir namespacing (`getAppDataDir`).
320
-
321
- ## Runtime SDK and daemon
322
-
323
- SDK hosts can use `@kodax-ai/kodax/runtime` in three forms: inline embedded for
324
- lowest latency, Worker-hosted embedded for private state plus hard V8 disposal,
325
- or a local daemon shared by REPL, Space, IDE adapters, and custom SDK clients.
326
- All three expose the same `KodaXRuntime` services.
239
+ If a custom endpoint is confirmed to support cache-affinity routing, set
240
+ `"promptCacheAffinity": true`. Anthropic-compatible requests then receive the
241
+ opaque logical-context key as `metadata.user_id`; OpenAI-compatible requests
242
+ receive `prompt_cache_key`. The default is `false` because some strict
243
+ compatible gateways reject unknown request fields. Do not enable it solely
244
+ because an endpoint claims protocol compatibility.
327
245
 
328
- ```ts
329
- import { createKodaXRuntime } from '@kodax-ai/kodax/runtime';
330
-
331
- const isolated = await createKodaXRuntime({
332
- mode: 'embedded',
333
- isolation: 'worker',
334
- requirements: { hardDispose: true },
335
- });
336
- ```
337
-
338
- Inline is private and lowest-overhead; Worker is private and hard-disposable;
339
- daemon is process-isolated and shared. `runtime.close()` closes private
340
- inline/Worker ownership, but only detaches one daemon client. Contradictory
341
- isolation options fail instead of silently selecting a weaker mode. Worker
342
- isolation is a V8 fault boundary, not a security sandbox.
343
-
344
- Because a daemon is intentionally persistent, tests that auto-start one must
345
- also run `kodax daemon stop --home <dir> --profile <name>` (or send authenticated
346
- `runtime.shutdown`) before deleting their temporary home. A remaining Node
347
- process is not safe to kill by name alone; verify its command line and owner.
348
-
349
- ```bash
350
- kodax daemon start
351
- kodax daemon stop --profile default
352
- kodax --runtime-mode daemon
353
- kodax -p "Review this repository" --runtime-mode daemon
354
- ```
355
-
356
- All CLI task forms now use the same Runtime path: interactive REPL, positional
357
- prompts, slash-command prompts, and `kodax -p`. Select the persistent default in
358
- `~/.kodax/config.json`:
359
-
360
- ```json
361
- {
362
- "runtimeMode": "daemon"
363
- }
364
- ```
365
-
366
- Resolution order is explicit CLI/SDK option > environment variable >
367
- `config.json` > built-in default (`embedded`). `KODAX_RUNTIME_MODE=daemon` is a
368
- temporary environment override. The same rule applies to other paired settings,
369
- for example `provider` ↔ `KODAX_PROVIDER` and `effort` ↔ `KODAX_EFFORT`.
370
- JSON names stay camelCase while environment names use `KODAX_UPPER_SNAKE_CASE`.
371
-
372
- By default, daemon state, config, and runtime session storage use the exact
373
- resolved `KODAX_HOME` (normally `<OS user home>/.kodax`), so CLI and SDK clients
374
- converge on the same local daemon even when `KODAX_HOME` is an arbitrary custom
375
- directory. The high-level `createKodaXRuntime({ mode: 'daemon' })` API starts or
376
- reuses that daemon unless you pass an explicit endpoint/transport or
377
- `autoStartDaemon: false`. An explicit `--home <dir>` or `homeDir` selects the
378
- isolated `<dir>/.kodax` namespace for tests, CI, or project-local experiments.
379
-
380
- **v0.7.71 packaged Electron patch:** packaged/asar Electron hosts can use daemon
381
- auto-start without relaunching the GUI. `ELECTRON_RUN_AS_NODE` is limited to a
382
- bootstrap-only child exec boundary and removed before daemon or ordinary user
383
- child code loads. The default-enabled Electron `RunAsNode` fuse is required;
384
- hosts that disable it must start the daemon through ordinary Node/KodaX CLI and
385
- connect in attach-only mode. For SDK calls, `homeDir` is the CLI-style base
386
- directory that owns `.kodax`, not the `.kodax` path itself.
387
-
388
- **v0.7.75 Windows GUI stabilization candidate:** Runtime Worker-reachable
389
- non-interactive subprocesses request hidden Windows consoles across memory/Git,
390
- provider CLI/ACP, LSP, clipboard, worktree, review, extension-command,
391
- checkpoint, and sandbox paths. Explicit editor, terminal, and PTY behavior is
392
- unchanged. The SDK bundle includes a static child-process audit and a packaged
393
- Electron 20-query console-visibility regression. Product-level packaged KodaX
394
- Space verification remains useful but does not gate SDK packaging or
395
- publication.
396
-
397
- The same candidate distinguishes optional post-completion offers from
398
- clarification required to finish the current request, emits budget-approval
399
- state only for eligible Sidecar revisions, and preserves structured blocked
400
- reasons across embedded and daemon Runtime boundaries.
246
+ Sidecar verifier judge calls use provider-level forced tool choice when supported. If a compatible endpoint rejects the `tool_choice` parameter, KodaX retries that verifier request once without forced tool choice and still fails open rather than blocking the main Worker.
247
+
248
+ #### Opting a custom provider into image / vision input (FEATURE_134 v0.7.40)
249
+
250
+ If your custom provider's underlying model supports image input (vision), add a `capabilityProfile.multimodalSupport: "image-input"` block so KodaX does not artificially block multimodal requests at the SA-path policy gate. Built-in vision-capable aliases (Anthropic, OpenAI, Anthropic-/OpenAI-compatible aliases such as DeepSeek, Kimi, Qwen, Zhipu, MiniMax, MiMo, Ark, plus Gemini-CLI via the CLI's `@<path>` file-include syntax) already ship with this flag enabled by default; Codex-CLI and custom providers need to opt in when their underlying model supports image input.
251
+
252
+ ```json
253
+ {
254
+ "customProviders": [
255
+ {
256
+ "name": "my-vision-provider",
257
+ "protocol": "openai",
258
+ "baseUrl": "https://example.com/v1",
259
+ "apiKeyEnv": "MY_LLM_API_KEY",
260
+ "model": "my-vision-model",
261
+ "capabilityProfile": {
262
+ "transport": "native-api",
263
+ "conversationSemantics": "full-history",
264
+ "mcpSupport": "none",
265
+ "contextFidelity": "full",
266
+ "toolCallingFidelity": "full",
267
+ "sessionSupport": "full",
268
+ "longRunningSupport": "full",
269
+ "multimodalSupport": "image-input",
270
+ "evidenceSupport": "full"
271
+ }
272
+ }
273
+ ]
274
+ }
275
+ ```
276
+
277
+ The serializer layer (`packages/llm/src/providers/anthropic.ts:770` for Anthropic-compat, `openai.ts:904` for OpenAI-compat) forwards image blocks automatically through base-class inheritance. The flag only gates whether KodaX's policy layer pre-rejects multimodal requests — the model-level vision contract remains your upstream provider's responsibility. If the model is actually text-only, you'll see the real upstream API error instead of a KodaX-side rejection.
278
+
279
+ ### 3. Start in REPL or run a one-shot task
280
+
281
+ ```bash
282
+ # Interactive REPL
283
+ kodax
284
+
285
+ # Then ask naturally inside the REPL
286
+ Read package.json and summarize the architecture
287
+ /mode
288
+ /help
289
+
290
+ # One-shot CLI usage
291
+ kodax "Review this repository and summarize the architecture"
292
+ kodax --session review "Find the riskiest parts of src/"
293
+ kodax --session review "Give me concrete fix suggestions"
294
+ ```
295
+
296
+ ### 4. Use it as a library
297
+
298
+ Library usage still expects API keys from environment variables. If you want custom provider names or base URLs in code, register them explicitly:
299
+
300
+ ```typescript
301
+ import { registerCustomProviders, runKodaX } from '@kodax-ai/kodax';
302
+
303
+ registerCustomProviders([
304
+ {
305
+ name: 'my-openai-compatible',
306
+ protocol: 'openai',
307
+ baseUrl: 'https://example.com/v1',
308
+ apiKeyEnv: 'MY_LLM_API_KEY',
309
+ model: 'my-model',
310
+ userAgentMode: 'compat',
311
+ },
312
+ ]);
313
+
314
+ const result = await runKodaX(
315
+ {
316
+ provider: 'my-openai-compatible',
317
+ effort: 'auto',
318
+ },
319
+ 'Explain this codebase'
320
+ );
321
+ ```
322
+
323
+ > **Embedding KodaX inside another app?** (KodaX Space, IDE extensions, custom CLIs)
324
+ > See [docs/SDK_EMBEDDER_GUIDE.md](docs/SDK_EMBEDDER_GUIDE.md) for the runtime-mutation
325
+ > surface (`startKodaX` + `RunningSession`), MCP popout manager API (`McpManager`),
326
+ > Skill `` !`cmd` `` host hook, and per-app data dir namespacing (`getAppDataDir`).
327
+
328
+ ## Runtime SDK and daemon
329
+
330
+ SDK hosts can use `@kodax-ai/kodax/runtime` in three forms: inline embedded for
331
+ lowest latency, Worker-hosted embedded for private state plus hard V8 disposal,
332
+ or a local daemon shared by REPL, Space, IDE adapters, and custom SDK clients.
333
+ All three expose the same `KodaXRuntime` services.
334
+
335
+ ```ts
336
+ import { createKodaXRuntime } from '@kodax-ai/kodax/runtime';
337
+
338
+ const isolated = await createKodaXRuntime({
339
+ mode: 'embedded',
340
+ isolation: 'worker',
341
+ requirements: { hardDispose: true },
342
+ });
343
+ ```
344
+
345
+ Inline is private and lowest-overhead; Worker is private and hard-disposable;
346
+ daemon is process-isolated and shared. `runtime.close()` closes private
347
+ inline/Worker ownership, but only detaches one daemon client. Contradictory
348
+ isolation options fail instead of silently selecting a weaker mode. Worker
349
+ isolation is a V8 fault boundary, not a security sandbox.
350
+
351
+ Because a daemon is intentionally persistent, tests that auto-start one must
352
+ also run `kodax daemon stop --home <dir> --profile <name>` (or send authenticated
353
+ `runtime.shutdown`) before deleting their temporary home. A remaining Node
354
+ process is not safe to kill by name alone; verify its command line and owner.
355
+
356
+ ```bash
357
+ kodax daemon start
358
+ kodax daemon stop --profile default
359
+ kodax --runtime-mode daemon
360
+ kodax -p "Review this repository" --runtime-mode daemon
361
+ ```
362
+
363
+ All CLI task forms now use the same Runtime path: interactive REPL, positional
364
+ prompts, slash-command prompts, and `kodax -p`. Select the persistent default in
365
+ `~/.kodax/config.json`:
366
+
367
+ ```json
368
+ {
369
+ "runtimeMode": "daemon"
370
+ }
371
+ ```
372
+
373
+ Resolution order is explicit CLI/SDK option > environment variable >
374
+ `config.json` > built-in default (`embedded`). `KODAX_RUNTIME_MODE=daemon` is a
375
+ temporary environment override. The same rule applies to other paired settings,
376
+ for example `provider` ↔ `KODAX_PROVIDER` and `effort` ↔ `KODAX_EFFORT`.
377
+ JSON names stay camelCase while environment names use `KODAX_UPPER_SNAKE_CASE`.
378
+
379
+ By default, daemon state, config, and runtime session storage use the exact
380
+ resolved `KODAX_HOME` (normally `<OS user home>/.kodax`), so CLI and SDK clients
381
+ converge on the same local daemon even when `KODAX_HOME` is an arbitrary custom
382
+ directory. The high-level `createKodaXRuntime({ mode: 'daemon' })` API starts or
383
+ reuses that daemon unless you pass an explicit endpoint/transport or
384
+ `autoStartDaemon: false`. An explicit `--home <dir>` or `homeDir` selects the
385
+ isolated `<dir>/.kodax` namespace for tests, CI, or project-local experiments.
386
+
387
+ **v0.7.71 packaged Electron patch:** packaged/asar Electron hosts can use daemon
388
+ auto-start without relaunching the GUI. `ELECTRON_RUN_AS_NODE` is limited to a
389
+ bootstrap-only child exec boundary and removed before daemon or ordinary user
390
+ child code loads. The default-enabled Electron `RunAsNode` fuse is required;
391
+ hosts that disable it must start the daemon through ordinary Node/KodaX CLI and
392
+ connect in attach-only mode. For SDK calls, `homeDir` is the CLI-style base
393
+ directory that owns `.kodax`, not the `.kodax` path itself.
394
+
395
+ **v0.7.75 Windows GUI stabilization candidate:** Runtime Worker-reachable
396
+ non-interactive subprocesses request hidden Windows consoles across memory/Git,
397
+ provider CLI/ACP, LSP, clipboard, worktree, review, extension-command,
398
+ checkpoint, and sandbox paths. Explicit editor, terminal, and PTY behavior is
399
+ unchanged. The SDK bundle includes a static child-process audit and a packaged
400
+ Electron 20-query console-visibility regression. Product-level packaged KodaX
401
+ Space verification remains useful but does not gate SDK packaging or
402
+ publication.
403
+
404
+ The same candidate distinguishes optional post-completion offers from
405
+ clarification required to finish the current request, emits budget-approval
406
+ state only for eligible Sidecar revisions, and preserves structured blocked
407
+ reasons across embedded and daemon Runtime boundaries.
408
+
409
+ **v0.7.76 Kimi Code catalog refresh:** `kimi-code` now defaults to the official
410
+ `k3-256k` Model ID and sends it unchanged. `kimi-for-coding` remains selectable
411
+ for K2.7 Code, alongside `kimi-for-coding-highspeed` and the 1M `k3` tier. K3
412
+ supports `low` / `high` / `max` reasoning with `high` as default; the 256K
413
+ route supports image input but not video input.
414
+
415
+ **v0.7.77 release-ready candidate:** AMA now chooses and composes six named
416
+ problem-solving patterns through the existing Actor control plane instead of
417
+ using a fixed topology or hidden Workflow. Optional strategy metadata becomes
418
+ a bounded, fact-only `PatternTrace`; the existing Sidecar remains the only
419
+ terminal-answer quality judge. Governed memory can also react sparsely after a
420
+ tool failure, verification failure, or committed compaction and place at most
421
+ three prompt-safe, low-authority evidence items before the next Action-LLM
422
+ request. The default path adds no selector model call; SDK hosts may opt into
423
+ `memoryRecallRunner` in process. Public `kimi` also gains the 1M `kimi-k3`
424
+ route while retaining K2.7 Code as its default. See the
425
+ [v0.7.77 design](docs/features/v0.7.77.md) and
426
+ [release checklist](docs/release.md#v0777-release-ready-candidate-verification).
427
+ The frozen F274/F275 paid evaluation completed with `recommend-ship` from the
428
+ final F274 Layer 2/Layer 3 reviews and the F275 pilot review, followed by a
429
+ joint `SHIP` decision for the deterministic contracts. Semantic memory
430
+ selection remains experimental and host opt-in; no task-quality, token, or
431
+ latency improvement is claimed.
432
+
433
+ The same candidate adds an opt-in, host-configurable Shell Execution Contract.
434
+ Runtime Session settings or an individual Run can select `pwsh`, Windows
435
+ PowerShell, `cmd`, `bash`, `zsh`, or an explicit Git Bash executable; KodaX
436
+ resolves the shell environment in the effective project cwd and then executes
437
+ the command through that same interpreter. Resolved environments are isolated
438
+ by contract and cwd, expire after a bounded TTL, and can be explicitly
439
+ refreshed. Provider credentials and execution-control variables are removed
440
+ before profile/setup code and again before the command starts. When
441
+ `shellExecution` is absent, established command behavior is unchanged. See
442
+ [SDK Embedder Guide section 28](docs/SDK_EMBEDDER_GUIDE.md#28-host-configurable-shell-execution-contract-v0777)
443
+ and the [Issue 214 regression guide](docs/test-guides/ISSUE_214_v0.7.77_REGRESSION_GUIDE.md).
444
+
445
+ Kimi Code requests also receive a stable, opaque prompt-cache affinity key
446
+ derived from the logical Runtime context. It is reused across Runs, retries,
447
+ fallback, resume, and compaction; recursive child Agents receive distinct keys
448
+ based on their canonical Agent path rather than their temporary transcript
449
+ Session. Public Kimi and official OpenAI use the corresponding
450
+ `prompt_cache_key` field, while other compatible gateways remain opt-in because
451
+ some reject unknown request fields. This improves routing stability but cannot
452
+ override Provider TTL or cache sharding. See the
453
+ [Issue 215 regression guide](docs/test-guides/ISSUE_215_v0.7.77_REGRESSION_GUIDE.md).
454
+ Codex CLI cache reads/writes and Gemini CLI cache reads now flow through the
455
+ CLI bridge and Runtime diagnostics without estimation. A reported `0` remains
456
+ distinct from an unreported field; see the
457
+ [Issue 216 regression guide](docs/test-guides/ISSUE_216_v0.7.77_REGRESSION_GUIDE.md).
458
+ The bridge also starts the first native CLI turn fresh, resumes only a native
459
+ session ID reported by that CLI, creates fresh ACP sessions for stateless
460
+ calls, recreates a closed pseudo transport, and validates the process exit even
461
+ after a terminal CLI event. User cancellation stays quiet, while hard/idle
462
+ timeout aborts remain failures eligible for Runtime recovery, and a CLI that
463
+ reports success but never exits is terminated at its configured deadline; see the
464
+ [Issue 217 regression guide](docs/test-guides/ISSUE_217_v0.7.77_REGRESSION_GUIDE.md).
401
465
 
402
466
  One daemon owns many sessions. Different sessions may run concurrently; starts
403
467
  within the same session are queued so that only one run is active for that
404
468
  session. Multiple `kodax` processes can attach to the same daemon and open or
405
- observe the same session. FEATURE_269 adds atomic snapshot-plus-stream joining,
406
- durable idempotent mutations, revision-safe settings and grants, transport-safe
407
- AskUser/permission responses, run-scoped credential and Host Tool bridges, and
408
- one daemon/inline Coder owner fence. In-flight external effects are never
409
- blindly replayed after a crash; clients receive explicit interrupted/unknown
410
- terminal facts and resync when `runtimeId` changes.
411
-
412
- Space and IDE hosts should require these capabilities through the Runtime SDK.
413
- Partner remains on its private inline Runtime and must use a distinct product
414
- data/session root. A missing daemon capability is an error, not permission to
415
- silently fall back to inline Coder.
416
-
417
- For the full host-integration contract, including inline/Worker/daemon selection,
418
- multi-client permission handling, config/catalog/MCP admin APIs, artifacts,
419
- context diagnostics, and daemon protocol schemas, see
420
- [docs/SDK_EMBEDDER_GUIDE.md §17](docs/SDK_EMBEDDER_GUIDE.md#17-runtime-sdk-worker-isolation-and-local-daemon-feature_253-feature_257).
421
-
422
- The Space/IDE shared-daemon contract is documented in
423
- [SDK Embedder Guide section 23](docs/SDK_EMBEDDER_GUIDE.md#23-shared-coder-daemon-for-space-and-ide-hosts-feature_269-v0769).
424
-
425
- **v0.7.72–v0.7.73 Runtime permission contract:** Auto Mode is owned by the Runtime session,
426
- not by a UI hook. It reuses its LLM/rules guardrail across turns, classifies
427
- before the shared permission bridge, and persists an automatic fallback to
428
- rules. The same session settings can select a classifier model and bounded
429
- timeout; `auto` defaults to LLM classification and fails with a recoverable
430
- configuration error when no effective classifier model exists, rather than
431
- silently falling back. Runtime permission prompts now offer opaque, exact
432
- allow-once/session/persistent grant suggestions; persistent grants are
433
- daemon-owned and revisioned. Host plan exit is exposed only when the host
434
- supplies an approval callback. See the [Runtime Auto Mode integration guide](docs/SDK_EMBEDDER_GUIDE.md#24-runtime-owned-auto-mode-and-plan-approval-bridges-v0772v0773).
435
-
436
- ## Repo Intelligence
437
-
438
- KodaX ships with built-in repo intelligence (`repo_overview`, `module_context`, `symbol_context`, `process_context`, `impact_estimate`, and related tools) that helps the coding agent understand large codebases without ad-hoc grep/glob exploration.
439
-
440
- Use `/repo-intel status` in the REPL to inspect the active engine. The former standalone `repointel` host skill has been removed; repo intelligence is built into KodaX and requires no external installation.
441
-
442
- ```bash
443
- # Pick a runtime mode (auto | full | light | off)
444
- kodax --repo-intelligence full --repo-intelligence-trace
445
- ```
446
-
447
- ## Architecture
448
-
449
- KodaX uses a **monorepo architecture** with npm workspaces. Source layout currently has 4 workspace packages; published as a single bundled npm package `@kodax-ai/kodax` with 11 SDK subpath exports (`/agent`, `/llm`, `/coding`, `/media`, `/repl`, `/skills`, `/mcp`, `/session`, `/runtime`, `/a2a`, `/experimental-memory`; ADR-024 + ADR-032 + ADR-038, with ADR-036 consolidation):
450
-
451
- ```
452
- KodaX/
453
- ├── packages/ # 4 workspace packages (FEATURE_194 v0.7.43)
454
- │ ├── llm/ # @kodax-ai/llm - LLM abstraction (16 built-in provider aliases)
455
- │ │ └── providers/ # Anthropic, OpenAI, DeepSeek, Kimi, MiMo, MiniMax, Zhipu, Ark, …
456
- │ │
457
- │ ├── agent/ # @kodax-ai/agent - Generic Agent framework
458
- │ │ ├── actors/ # Runtime-owned Actor tree, scheduler, mailbox, events
459
- │ │ ├── session-lineage/ # branchable session tree (inline v0.7.43)
460
- │ │ ├── capabilities/
461
- │ │ │ ├── mcp/ # MCP integration (inline v0.7.43)
462
- │ │ │ └── skills/ # Skills standard implementation + builtin (inline v0.7.43)
463
- │ │ └── tracing/ # tracing / observability (inline v0.7.43)
464
- │ │
465
- │ ├── coding/ # @kodax-ai/coding - Coding Agent (tools + prompts)
466
- │ │ ├── tools/ # 50+ tools: read, write, edit, bash, glob, grep, undo,
467
- │ │ │ # spawn_agent, send_message, followup_task, wait_agent,
468
- │ │ │ # ask_user_question, repo-intelligence, …
469
- │ │ └── repo-intelligence/ # incl. protocol.ts (inline v0.7.43)
470
- │ │
471
- │ └── repl/ # @kodax-ai/repl - Interactive terminal UI (Ink TUI)
472
- │
473
- ├── src/ # CLI entry + SDK subpath entries
474
- │ ├── kodax_cli.ts # Main CLI entry point (bin: `kodax`)
475
- │ └── sdk-*.ts # SDK subpath re-exports → @kodax-ai/kodax/{agent,llm,coding,media,repl,skills,mcp,session,runtime,a2a,experimental-memory}
476
- │
477
- └── package.json # Root workspace config; release.mjs rewrites name + injects subpath exports
478
- ```
479
-
480
- ### Package Dependencies
481
-
482
- ```
483
- ┌──────────────────┐
484
- │ kodax (root) │
485
- │ CLI Entry │
486
- └────────┬─────────┘
487
- │
488
- ┌──────────────┴──────────────┐
489
- │ │
490
- ▼ ▼
491
- ┌──────────────┐ ┌────────────────┐
492
- │@kodax-ai/repl│ │@kodax-ai/coding│
493
- │ UI Layer │ │ Tools+Prompts │
494
- └──────┬───────┘ └──────┬─────────┘
495
- │ │
496
- │ ┌──────────────┴──────────────┐
497
- │ │ │
498
- ▼ ▼ ▼
499
- ┌──────────────┐ ┌──────────────────────────┐ ┌──────────────┐
500
- │@kodax-ai/ │ │@kodax-ai/agent │ │@kodax-ai/llm │
501
- │coding (via │ │Runner + fan-out + │ │LLM Abstract │
502
- │above) │ │idle-yield + session- │ │(16 aliases) │
503
- │ │ │lineage + skills + mcp + │ │ │
504
- │ │ │tracing (FEATURE_194) │ │ │
505
- └──────────────┘ └──────────────────────────┘ └──────────────┘
506
- ```
507
-
508
- ### Package Overview
509
-
510
- Source-side workspace package names (`@kodax-ai/*`). npm consumers install the single bundled `@kodax-ai/kodax` package and import from SDK subpaths — see [Source-side vs npm-published surface](#source-side-vs-npm-published-surface) and [SDK Usage](#sdk-usage) below.
511
-
512
- | Workspace package | Purpose | Key Dependencies |
513
- |---------|---------|------------------|
514
- | `@kodax-ai/llm` | LLM abstraction (16 built-in provider aliases + custom registration) | @anthropic-ai/sdk, openai |
515
- | `@kodax-ai/agent` | Generic Agent framework — Runner, fan-out, idle-yield, media/input artifacts, session-lineage, capabilities (mcp + skills), tracing (ADR-036 v0.7.43 consolidation; subpaths: `/media`, `/session-lineage`, `/capabilities/mcp`, `/capabilities/skills`, `/tracing`) | @kodax-ai/llm, js-tiktoken, fflate, jimp, yaml |
516
- | `@kodax-ai/coding` | Coding Agent — 50+ tools (incl. canonical Actor collaboration tools) + role prompts + auto-continue + repo-intelligence protocol | @kodax-ai/llm, @kodax-ai/agent |
517
- | `@kodax-ai/repl` | Complete interactive terminal UI (Ink/React, permission modes, commands, streaming) | @kodax-ai/coding, ink, react |
518
-
519
- ### Source-side vs npm-published surface
520
-
521
- KodaX has two layers that consumers should understand separately:
522
-
523
- - **Source-side**: 4 workspace packages above (what developers see when reading the repo).
524
- - **npm-published**: a single bundled package `@kodax-ai/kodax` with 11 SDK subpaths (what SDK consumers `import` from). The subpaths are split into two roles:
525
- - **Full-package subpaths** (`/agent`, `/llm`, `/coding`, `/repl`) — each one maps 1:1 to a source workspace and exposes its complete public API.
526
- - **Integration and narrow subpaths** (`/media`, `/skills`, `/mcp`, `/session`, `/runtime`, `/a2a`, `/experimental-memory`) — focused host surfaces. `/a2a` composes the neutral F258 plane with the Runtime facade; it does not add A2A wire types to `/agent`.
527
-
528
- | Source package | npm subpath | Type | What you get | Example consumer |
529
- |---|---|---|---|---|
530
- | `packages/llm` | `@kodax-ai/kodax/llm` | Full package | 16-alias LLM abstraction (108 exports) | Standalone LLM clients |
531
- | `packages/agent` | `@kodax-ai/kodax/agent` | Full package | Runner / fan-out / external-agent plane / session-lineage / capabilities / tracing (331 exports) | Custom agent frameworks |
532
- | `packages/agent` | `@kodax-ai/kodax/skills` | **Narrow subset** | Skills system only — `SkillRegistry` / `loadFullSkill` / `expandSkillForLLM` / ... (26 exports = pre-v0.7.43 `@kodax-ai/skills` complete API) | Skill loaders, IDE plugins |
533
- | `packages/agent` | `@kodax-ai/kodax/mcp` | **Narrow subset** | MCP only — `McpCapabilityProvider` / `createMcpTransport` / `searchMcpCatalog` / ... (23 exports) | MCP server hosts |
534
- | `packages/agent` | `@kodax-ai/kodax/media` | **Narrow subset** | Structured image/file/video input-artifact helpers (22 exports) | Desktop hosts and multimodal clients |
535
- | `packages/agent` | `@kodax-ai/kodax/experimental-memory` | **Experimental subset** | Thin F228-backed `MemoryAgent` / `MemorySession` contracts for scoped recall, deliberate query, observations, and outcomes | SDK hosts explicitly evaluating FEATURE_260 |
536
- | `packages/coding` | `@kodax-ai/kodax/coding` | Full package | Coding agent + 50+ tools + repo-intelligence (505 exports) | Build a Claude Code-shape product |
537
- | `packages/repl` | `@kodax-ai/kodax/repl` | Full package | Ink TUI + permission modes + commands (217 exports) | Terminal-UI consumers |
538
- | `packages/repl` | `@kodax-ai/kodax/session` | **Narrow subset** | Session management only — `listSessions` / `loadFullTranscript` / `appendClientNotice` / `forkSession` / `compactSession` / `watchSessions` / ... (17 exports) | IDE plugins and desktop hosts reading session history |
539
- | `src` | `@kodax-ai/kodax/runtime` | Host API | Embedded/Worker/daemon runtime facade, sessions/runs/events/permissions/catalog/MCP/artifacts/diagnostics/external agents, daemon protocol schema (10 exports) | SDK hosts, Space/IDE clients, daemon clients |
540
- | `src` | `@kodax-ai/kodax/a2a` | Integration edge | A2A 1.0 Agent Card discovery, JSON-RPC/SSE F258 executor, safe fetch policy, and authenticated Runtime-backed Agent server | Agent orchestrators and KodaX hosts |
541
-
542
- **Rule of thumb**: if you need Runner / Agent / fan-out, import from `/agent`. If you only need skills or mcp APIs, import from `/skills` or `/mcp` to get a smaller bundle. The narrow subsets are subsets of the full packages — they do **not** expose extra symbols.
543
-
544
- **Dynamic Workflows (FEATURE_217, v0.7.49)**: the domain-neutral workflow runtime is part of `/agent` — `import { createWorkflowRuntime, runWorkflow, WorkflowAbortError, WorkflowLimitError } from '@kodax-ai/kodax/agent'`. The coding-side integration (agent backend + built-in workflows + saved-workflow discovery/generation: `createCodingWorkflowBackend`, `runWorkflowFromOptions`, `parallelInvestigation`, `discoverSavedWorkflows`, `generateWorkflowFromOptions`, …) is part of `/coding`. FEATURE_217 is the v0.7.49 home for the full Dynamic Workflow product loop: `/workflow create <request>` generates restricted scripts, `/workflow save <runId> <name>` stores `.workflow.json` rerunnable workflows, generated/saved scripts coordinate agents through `WorkflowApi`, run lifecycle state stays observable, opt-in `isolation:"worktree"` routes selected children to parent-managed worktrees, and all file/shell effects still pass through agent tools and the existing permission gates. There is **no** separate `@kodax-ai/kodax/agent/workflow` root-package subpath; source-package consumers of `@kodax-ai/agent` can still use that package's `./workflow` subpath.
545
-
546
- **Workflow Process Surface (FEATURE_229, v0.7.50)**: workflow progress is now a reusable Agent-layer process contract rather than private REPL text. SDK hosts can subscribe to `WorkflowProcessEvent`/poll `WorkflowProcessSnapshot`, use `createWorkflowRunManager` and `createWorkflowLifecycleController` for stop/pause/resume/result/artifact/delete/prune/identity/preflight controls, and receive ANSI-free provenance fields (`source`, `sourceRunId`, `sourceWorkflowName`, `savedWorkflowName`, `revisionOf`) plus `resultSummary`. `/coding` owns the coding workflow backend and run graph, `/repl` renders the same snapshots, and the terminal UI is not the hidden source of truth. `KodaXEvents` callbacks also take an optional metadata arg (`KodaXToolEventMeta` / `KodaXActivityEventMeta` / `KodaXWorkflowEventMeta`) so a host can attribute every child-agent tool/thinking/progress event to its workflow run and child id without a second event protocol, and generated/saved workflow scripts pass `validateRestrictedWorkflowSource` (compile + source-policy check) plus a generator repair/smoke loop before they run. See [docs/ADR.md ADR-040](docs/ADR.md) for the layering rationale.
547
-
548
- **Host Reads Persisted History (FEATURE_230 + FEATURE_234, v0.7.51; v0.7.63 hardening)**: additive closures for hosts that read persisted state. **Durable tool transcript replay** — a resumed session now replays the tool cards the assistant used instead of degrading to text-only. `messages` / `lineage` stay canonical; `SessionData.uiHistory` becomes a bounded, sanitized, terminal-only replay cache. The SDK transcript contract is explicit: `loadSession()` = active model context, `loadFullTranscript()` = append-order host scrollback with typed entries (`message` / `compaction` / `branch_summary` / `rewind_marker` / `client_notice` / `task_result`) plus clone provenance (`logicalId` / `sourceEntryId`), `uiHistory` = optional replay cache, and tool cards can always be reconstructed from canonical messages. Hosts can persist local slash output with `appendClientNotice()` without entering model context, and workflow/child completions expose structured `taskResults[]` instead of requiring `<task-completed>` parsing. `rewind_marker` is an audit entry for host scrollback only and is excluded from model-context messages. **Workflow run host attribution** — `WorkflowProcessTrackerOptions` / `WorkflowProcessSnapshot` gain a host-owned opaque `hostMetadata?: Record<string, string>` that the SDK stores, persists to `run.json`, and echoes back (including after a restart) without interpreting it, so a host can map a run to the session/surface that launched it with zero side table. Unstamped/legacy runs honestly echo `hostMetadata === undefined`. See [docs/features/v0.7.51.md](docs/features/v0.7.51.md).
549
-
550
- **Inline Workflow Authoring (FEATURE_246, v0.7.58; F270 update in v0.7.72)**: the Worker can author and run a workflow inline via the model-callable `run_workflow` tool when Workflow intent is explicit. It scouts the codebase first, bakes concrete findings into child prompts, and runs the script through the sandbox, static-validation, and postcondition-verification pipeline. F270 retires AMAW and complexity-driven activation; AMA keeps explicit `/workflow`, named/SDK, and natural-language Workflow requests. Workflow child Agents now run on the unified Actor control plane. See [docs/features/v0.7.58.md](docs/features/v0.7.58.md), [docs/features/v0.7.72.md](docs/features/v0.7.72.md), and ADR-044/046/047/048/049/055.
551
-
552
- **Historical Workflow Activation Tiers (FEATURE_248 + FEATURE_249, v0.7.59; superseded by F270 in v0.7.72)**: v0.7.59 introduced AMAW and explicit-request AMA behavior. F270 retires AMAW and its complexity-driven directive. SA remains solo; AMA is the single adaptive multi-Agent mode and activates Workflow only from explicit Workflow intent. See [docs/features/v0.7.59.md](docs/features/v0.7.59.md) and [docs/features/v0.7.72.md](docs/features/v0.7.72.md).
553
-
554
- **Progressive Disclosure on the Managed Tool Path (FEATURE_250, v0.7.60; current policy corrected in v0.7.74)**: the deferred-tool mechanism applies to the managed AMA path as well as SA. The current deferred set contains exactly 11 tools: six repo-intelligence tools, four web/code discovery tools, and `run_workflow`. Their `input_schema` remains directly callable while `tool_search` provides the full description on demand. The five fixed `mcp_*` facades and the `get_goal` / `create_goal` / `update_goal` lifecycle tools stay resident with their complete contracts. The v0.7.74 goal correction adds only about 109 estimated schema tokens versus the former hints (`get_goal` is actually 12 tokens smaller when resident), removes a discovery round trip, and changes no tool schema, handler, permission, goal state, or compaction-protection behavior. See [docs/features/v0.7.60.md](docs/features/v0.7.60.md) and [docs/features/v0.7.74.md](docs/features/v0.7.74.md#feature_250-v0774-correction-resident-goal-lifecycle-tools).
555
-
556
- **Context-Efficient Tool Results + Workflow Quality Preflight (FEATURE_251 + FEATURE_252, v0.7.61; corrected 2026-07-14)**: local tools collect complete output and apply only contract-equivalent normalization that is strictly shorter; command-specific lossy Bash filters are off by default, and compound Bash uses no semantic adapter. One owner evaluates the complete parallel-result batch against the final provider request: it solves the largest final input `Pmax` for which `Pmax + output reserve + max(2048, 3% of Pmax) <= context window`, then admits only the remaining physical capacity. Results stay verbatim whenever they fit; only real overflow persists the complete value and emits `KODAX_RESULT_INCOMPLETE`. History keeps the same physical-capacity safety rule: no default lossy microcompaction below capacity, summary-first at pressure, and typed failure without silent deletion when a recoverable request cannot be formed. FEATURE_272 supersedes FEATURE_251 only for the default major-compaction trigger. FEATURE_252's deterministic pre-start workflow contract lint is unchanged. See [docs/features/v0.7.61.md](docs/features/v0.7.61.md) and [docs/ADR.md ADR-050](docs/ADR.md).
557
-
558
- **Reliable Always-On Context Compaction (FEATURE_272, v0.7.74)**: automatic major compaction cannot be disabled. Its percentage trigger defaults to 75% and clamps to 15-90%; optional `triggerTokens` is inactive when omitted/zero, otherwise the smaller percentage, absolute, and physical-capacity threshold wins. The protected raw tail is 20% of that effective trigger. One transaction summarizes the complete eligible prefix, preserves every genuine user request through an exact ledger, and emits success only after a physically valid token reduction and awaited durable commit. Before raw bodies are evicted, the Session owner durably flushes their exact lineage; stable entry IDs merge the sidecar and slim Session without duplicates. Root and persistent child Agents can recover omitted user/assistant/tool details through bounded `session_history_search` → `session_history_read`, with children isolated to hidden worker Sessions and never granted root-history access. SDK/Runtime clients use revision-bound `transcriptSearch`, pages, and lossless chunks. Hidden reasoning, system instructions, and synthetic checkpoints are excluded from model search. See [the feature design](docs/features/v0.7.74.md), [SDK guide §25](docs/SDK_EMBEDDER_GUIDE.md#25-always-on-context-compaction-and-bounded-transcript-recovery-v0774), and [ADR-057](docs/ADR.md#adr-057-large-compaction-is-an-always-on-context-scoped-full-coverage-transaction).
559
-
560
- **Mailbox-Driven Agent Coordination (FEATURE_273, v0.7.74)**: `wait_agent` is now a true model-facing mailbox yield with one bounded `timeout_ms`, not an Actor progress/event reader. It wakes for scoped Agent messages or completions, root user input, interruption, or timeout; progress remains available to UI/SDK snapshot, replay, and long-poll consumers without resampling the parent model. The tool returns only a wake acknowledgement, while authenticated Agent evidence and structured task metadata enter the next safe model boundary once. Unacknowledged root completions survive a hard restart, same-process Runtime rebuilds deduplicate by child turn ID, and acknowledged or legacy historical completions are not replayed. Use `list_agents` for tree state and `agent_output` for a targeted known result. See [the feature design](docs/features/v0.7.74.md#feature_273-mailbox-driven-agent-wait-and-telemetrycontrol-separation), [SDK guide §26](docs/SDK_EMBEDDER_GUIDE.md#26-agent-mailbox-control-versus-sdk-event-telemetry-v0774), and [ADR-058](docs/ADR.md#adr-058-model-agent-wait-is-mailbox-control-not-event-telemetry).
561
-
562
- **Active-Run Interrupt Input (v0.7.74)**: embedded Runtime and the shared daemon advertise `interruptInput:1`. `runtime.runs.submitInput()` queues an immutable, ordered input for the current active Actor Run; all inputs admitted before one safe Runner boundary are delivered FIFO as separate user messages in the next LLM request, without creating continuation Runs. Queued/delivered state is visible in typed Run snapshots/events, delivery is acknowledged against the exact consumed IDs, and terminal cleanup prevents undelivered input from leaking into later Runs.
563
-
564
- **External Agent SDK Plane (FEATURE_258, v0.7.67)**: `/agent` exports the protocol-neutral executor, registration, policy, credential-broker, artifact-policy, catalog, and durable task contracts. `/runtime` exposes the installed plane through `admin.agentRegistrations`, `agents`, and `agentTasks`, with the same DTO service methods over embedded and daemon clients. Executor factories are host functions: install them in an inline owner or while creating a new in-process daemon owner; they cannot be injected through an existing daemon connection or across a Runtime Worker boundary. Plane shutdown is terminal: pending waits and all later service calls reject. Restricted Workflow scripts preserve validated `phase` and external `target` routing. See the [complete owner/consumer recipes and safety contract](docs/SDK_EMBEDDER_GUIDE.md#18-external-agent-executor-plane-feature_258-v0767).
565
-
566
- **Cost-Disciplined Workflow SDK (FEATURE_259, v0.7.67)**: SDK callers configure run-scoped `modelTiers` and `workflow.maxConcurrency`, while workflow authors express semantic `fast` / `balanced` / `deep` intent. Terminal workflow events expose resolved tier/source/fallback/usage/duration facts, and each durable `run.json` contains an `efficiencyReport` with token coverage, role/tier starts, packet-read topology, review waves, and quality-gate outcomes. See the [routing and telemetry contract](docs/SDK_EMBEDDER_GUIDE.md#20-cost-disciplined-workflow-routing-and-telemetry-feature_259-v0767).
567
-
568
- **Paged Session Listing (FEATURE_261, v0.7.67)**: both `/session` `listSessions()` and `runtime.sessions.list()` accept an exact `surface` filter and opaque continuation `cursor`; each returned summary carries the cursor for the next page. Filtering happens before the page limit, so a host does not need to over-fetch mixed surfaces. See the [pagination recipes](docs/SDK_EMBEDDER_GUIDE.md#19-session-surface-filtering-and-cursor-pagination-feature_261-v0767).
569
-
570
- **Experimental Memory Agent SDK (FEATURE_260, v0.7.68)**: `/experimental-memory` exposes the thin agent-layer `MemoryAgent` and scoped `MemorySession` lifecycle over the existing governed F228 plane. Passive recall is zero-wait; `query()` is read-only and deliberate; durable changes still require the proposal/preview/fingerprint/apply path. The Action LLM remains the final decision maker, recalled content stays low-authority, and safety/scope gates remain deterministic. See the [direct session and boundary guide](docs/SDK_EMBEDDER_GUIDE.md#21-experimental-governed-memory--experimental-memory-feature_260-v0768).
571
-
572
- **Bidirectional A2A 1.0 (FEATURE_267, v0.7.69)**: `/a2a` discovers allowed Agent Cards and installs a JSON-RPC/SSE executor through the existing F258 plane. Configured outbound Agents are also registered automatically as `external:<name>` in embedded CLI and user-daemon Runtimes, so the main Agent can orchestrate them without host code. One `a2a.json` may hold many outbound registrations and at most one inbound server, which publishes either the Runtime default or one validated `~/.kodax/agents/*.md` Agent behind an authenticated Runtime facade. The built-in listener is loopback-only; public deployment uses `handle()` behind host-owned TLS and authorization. A2A 0.3, gRPC, HTTP+JSON, push notifications, and automatic public exposure are not advertised. See the [client/server recipes and security boundaries](docs/SDK_EMBEDDER_GUIDE.md#22-bidirectional-a2a-10--a2a-feature_267-v0769).
573
-
574
- **A2A interoperability and authentication hardening** keeps a discovered
575
- interface on the trusted Agent Card origin and sends credentials only when one
576
- complete Card/Skill security requirement is satisfiable. The no-code client
577
- supports HTTP Bearer compatibility and OAuth 2.0 Client Credentials; for OAuth,
578
- an external Authorization Server issues short-lived access tokens and KodaX
579
- caches them only in memory. Inbound `a2a serve` can validate RFC 9068 JWT access
580
- tokens from an external issuer/JWKS, but never signs or issues production
581
- tokens itself. It resolves its provider from CLI, then environment, config, and
582
- the built-in default; a Markdown Agent can pin its own provider. Input
583
- continuation resumes the original Runtime run, task history and retention are
584
- bounded with stable cursor pagination, and authenticated SSE is correlated
585
- before falling back to polling after an early normal EOF. Only direct remote
586
- artifacts, broker-staged outputs, and outputs from a successfully admitted
587
- Skill script can be published; ordinary workspace writes and local paths stay
588
- private.
589
-
590
- This authentication and per-Agent activation hardening is a post-release
591
- closure of the v0.7.69 F267/F268 design and ships in the v0.7.71 patch; it is
592
- not a claim that older v0.7.69 binaries contained the
593
- later OAuth profiles.
594
-
595
- **v0.7.70 MCP discovery hardening** uses exact capability IDs and revisioned
596
- cursors while admitting results against real physical capacity. Compact CJK
597
- queries are segmented, and a cross-language lexical zero match either returns a
598
- lossless bounded grouped inventory or one concise retry in the catalog language.
599
- Partial provider failure remains explicit rather than disappearing into an
600
- apparently complete result.
601
-
602
- The complete built-in path is available without writing TypeScript:
603
-
604
- ```bash
605
- # Call another A2A Agent
606
- kodax a2a add research https://agent.example/.well-known/agent-card.json --effect read
607
- kodax a2a test research
608
- kodax a2a call research "Summarize this topic"
609
-
610
- # Stage an OAuth-protected Agent, then hot-activate/deactivate it
611
- export RESEARCH_A2A_CLIENT_SECRET='provisioned-by-your-authorization-server'
612
- # PowerShell: $env:RESEARCH_A2A_CLIENT_SECRET='provisioned-by-your-authorization-server'
613
- # PowerShell: run the command on one line or replace each trailing \ with a backtick.
614
- kodax a2a add reviewer https://reviewer.example/.well-known/agent-card.json \
615
- --disabled --effect read --oauth-scheme enterprise-oauth \
616
- --oauth-issuer https://identity.example/ \
617
- --oauth-token-url https://identity.example/oauth/token \
618
- --oauth-client-id kodax-reviewer \
619
- --oauth-client-secret-env RESEARCH_A2A_CLIENT_SECRET \
620
- --oauth-scope a2a.invoke --oauth-resource https://reviewer.example/
621
- kodax a2a enable reviewer
622
- kodax a2a disable reviewer # blocks new dispatch; does not cancel in-flight tasks
623
-
624
- # Expose the Runtime default Agent, or pass a name from ~/.kodax/agents/*.md
625
- export KODAX_A2A_TOKEN='replace-with-a-long-random-token'
626
- # PowerShell: $env:KODAX_A2A_TOKEN='replace-with-a-long-random-token'
627
- kodax a2a expose # or: kodax a2a expose document-agent
628
- kodax a2a serve # loopback http://127.0.0.1:8765
629
- ```
630
-
631
- MCP, A2A, and Extension declarations live in one user file per domain under
632
- `~/.kodax/integrations/`. Use `kodax config template <mcp|a2a|extensions>`,
633
- `kodax integrations migrate --apply`, and the `kodax mcp`, `kodax a2a`, or
634
- `kodax extensions` commands to manage them. Migration imports only legacy
635
- `config.json#mcpServers` and `config.json#extensions`; A2A has no legacy source.
636
- It never overwrites an existing destination. The first MCP/Extension mutation
637
- can stage legacy entries. Remove legacy keys only with
638
- `--apply --cleanup-legacy`, after reviewing destination files and
639
- literal-secret warnings. Running
640
- CLI/daemon hosts retain the
641
- last valid revision, atomically replace the complete MCP provider, reconcile
642
- Extensions per entry, and hot-register outbound A2A Agents. Each A2A entry has
643
- a desired `enabled` switch; `kodax a2a list` shows configuration, while the
644
- owning Runtime is authoritative for live applied registrations. Disabled
645
- entries are not fetched during automatic reconciliation and, after the owning
646
- Runtime applies the revision, cannot accept new dispatch. The mutation command
647
- itself is not cross-process acknowledgement. `a2a add --disabled` still checks
648
- the Card by default unless `--no-test` is supplied, while `a2a test` performs
649
- discovery/security planning without requesting an OAuth token. The fixed
650
- `KODAX_A2A_TOKEN` example is an operator-provisioned compatibility credential;
651
- KodaX does not generate or issue it. Disabled entries remain available for
652
- later re-enable. `a2a serve` loads
653
- its configured MCP/Extension capability surface before listening and pins that
654
- execution authority; it hot-reloads publication, authentication, and limits.
655
-
656
- A2A configuration migration and retained task ownership are separate. If a
657
- v0.7.70 task store must remain addressable after the realm-aware upgrade, stop
658
- the A2A server, run `kodax a2a migrate-tasks` to inspect the exact-owner plan,
659
- then apply it with `--apply --confirm-server-stopped`. OAuth migration also
660
- requires the known historical `--subject`; normal serving never guesses or
661
- dual-reads a legacy owner key.
662
-
663
- Agent, Skill, Extension-tool authority, workspace, tool-policy, or task-store
664
- changes require an explicit server restart. Managed
665
- A2A contexts default to `~/kodax_a2a_server_workspace/<runtime-profile>/contexts/`.
666
- Exact Skill scripts require the opt-in isolated policy and a passing
667
- `kodax sandbox doctor` (`kodax sandbox setup` performs the explicit Windows
668
- one-time provisioning).
669
-
670
- ---
671
-
672
- ## Features
673
-
674
- - **Modular Architecture** - Use as CLI, as a library, or as a Node-free single binary
675
- - **16 Built-in Provider Aliases** - Anthropic, OpenAI, DeepSeek, Kimi, Kimi Code, Qwen, Qwen Token Plan, Zhipu, Zhipu Coding, Zai Coding, MiniMax Coding, MiMo Coding, MiMo, Ark Coding, Gemini CLI, Codex CLI - plus user-defined OpenAI/Anthropic-compatible providers
676
- - **Dynamic Workflows + SDK Process Surface** - Generate/reuse capability-routed workflows, observe live progress through `WorkflowProcessSnapshot`, and control workflow lifecycle from SDK hosts without parsing REPL output
677
- - **V2 Worker single-loop + Sidecar Verifier (default)** - Single-agent main loop with an out-of-band Sidecar Verifier as Stop-hook (claudecode-shape; FEATURE_184 v0.7.42, ADR-030). Verifier returns accept/revise/blocked verdict on Worker text-only termination. The pre-v0.7.43 V1 chain is retired, `emit_handoff` is deleted, accept-verdict UI silently passes through, and content-aware gating skips trivial-chat sidecar calls. Adaptive child steering uses the canonical Actor collaboration tools with idle-yield waiting; specialist routing uses `spawn_agent(agent_id=...)`.
678
- - **Reasoning Effort** - Effort-first control (`off/auto/low/medium/high` plus model-supported extras) across providers
679
- - **Streaming Output** - Real-time response display
680
- - **Session Management** - JSONL format with branchable session lineage tree
681
- - **Skills System** - Natural language triggering, extensible, role-projected in AMA
682
- - **Repo Intelligence** - Built-in full/light repository intelligence with native KodaX auto-injection lane
683
- - **Rich Tool Surface** - 50+ built-in tools across file ops, shell, search, repo intelligence, MCP capabilities, git worktree, and agent control
684
- - **Permission Control** - 3 permission modes with pattern-based control
685
- - **Standalone Binary** - `bun --compile` releases for Win/macOS/Linux x64+arm64, no Node.js required on target machines
686
- - **Cross-Platform** - Windows/macOS/Linux
687
- - **TypeScript Native** - Full type safety and IDE support
688
-
689
- ---
690
-
691
- ## Installation
692
-
693
- ### As CLI Tool
694
-
695
- ```bash
696
- # Clone repository
697
- git clone https://github.com/icetomoyo/KodaX.git
698
- cd KodaX
699
-
700
- # Install dependencies (includes workspace packages)
701
- npm install
702
-
703
- # Build the monorepo
704
- npm run build
705
-
706
- # Link globally (development mode)
707
- npm link
708
-
709
- # Now you can use 'kodax' anywhere
710
- kodax "your task"
711
- ```
712
-
713
- ### As Standalone Binary (no Node required on target)
714
-
715
- KodaX can be packaged into a single executable + a small `builtin/` sidecar directory using `bun --compile`. The target machine does **not** need Node.js or any other runtime.
716
-
717
- Supported targets: `win-x64`, `linux-x64`, `linux-arm64`, `darwin-x64`, `darwin-arm64`. Win7 / pre-glibc-2.27 distros / LoongArch are not supported.
718
-
719
- **Build locally**:
720
-
721
- ```bash
722
- # Install Bun once on your build machine
723
- npm i -g bun # or scoop/brew/curl install — see docs/release.md
724
-
725
- npm run build:binary # Current host platform (fastest)
726
- npm run build:binary:all # All five targets in sequence
727
- node scripts/build-binary.mjs --target=linux-arm64 # Specific target
728
- ```
729
-
730
- Output lives under `dist/binary/<target>/`:
731
-
732
- ```
733
- dist/binary/linux-x64/
734
- ├── kodax # ~60 MB Bun-compiled executable
735
- ├── builtin/ # Sidecar built-in skills
736
- ├── provider-capabilities.json
737
- ├── semantic-worker.js # Repo-intelligence Worker
738
- ├── runtime-worker.js # SDK Runtime Worker
739
- └── constructed-handler-worker.js # Constructed-tool Worker
740
- ```
741
-
742
- Smoke-test: `dist/binary/<host>/kodax --version`.
743
-
744
- **Automated release**: pushing a `v*` git tag triggers `.github/workflows/release.yml`, which builds all five targets on native runners, runs smoke tests, and publishes a GitHub Release with archives + SHA256SUMS. Use the `workflow_dispatch` button in the Actions UI to test the pipeline without tagging.
745
-
746
- See [docs/release.md](docs/release.md) for full details on build flags, archive layout, troubleshooting, and the build-time `KODAX_BUNDLED` / `KODAX_VERSION` defines.
747
-
748
- ### As Library
749
-
750
- ```bash
751
- npm install @kodax-ai/kodax
752
- ```
753
-
754
- ```typescript
755
- import { runKodaX } from '@kodax-ai/kodax';
756
-
757
- process.env.ZHIPU_API_KEY = process.env.ZHIPU_API_KEY ?? 'your_api_key';
758
-
759
- const result = await runKodaX({
760
- provider: 'zhipu-coding',
761
- effort: 'auto',
762
- events: {
763
- onTextDelta: (text) => process.stdout.write(text),
764
- onComplete: () => console.log('\nDone!'),
765
- },
766
- }, 'your task');
767
-
768
- console.log(result.lastText);
769
- ```
770
-
771
- #### SDK Subpath Imports (v0.7.39+)
772
-
773
- For smaller surface and tree-shake-friendly imports, the SDK is also exposed via subpath exports — pick only the package(s) you need:
774
-
775
- ```typescript
776
- import { Runner } from '@kodax-ai/kodax/agent'; // agent runtime
777
- import { getProvider } from '@kodax-ai/kodax/llm'; // LLM abstraction (16 aliases)
778
- import { runKodaX } from '@kodax-ai/kodax/coding'; // coding tools + prompts
779
- import { createImageArtifactFromPath } from '@kodax-ai/kodax/media'; // input artifacts
780
- import { SkillRegistry } from '@kodax-ai/kodax/skills'; // zero-dep skill loader
781
- import { loadConfig } from '@kodax-ai/kodax/repl'; // REPL config / session helpers
782
- import { createMcpManager } from '@kodax-ai/kodax/mcp'; // MCP popout manager (v0.7.42)
783
- import { listSessions } from '@kodax-ai/kodax/session'; // session history helpers
784
- import { createKodaXRuntime } from '@kodax-ai/kodax/runtime'; // embedded/daemon runtime API
785
- import { createKodaXA2AServer } from '@kodax-ai/kodax/a2a'; // A2A 1.0 client/server edge
786
- ```
787
-
788
- All 12 SDK entries (root + 11 subpaths) share internal code via ESM chunk splitting — importing from `/agent` does not pull in `/repl`'s Ink + React surface.
789
-
790
- For the complete host-facing contract — including embedded/Worker/daemon ownership,
791
- external-agent registration and task control, session cursor pagination, workflow
792
- model-tier routing, and efficiency telemetry — see the
793
- [SDK Embedder Integration Guide](docs/SDK_EMBEDDER_GUIDE.md).
794
-
795
- > **ESM-only.** The SDK is published as ES Modules. In a CommonJS context (Electron main process, legacy Webpack CJS bundles, `require()`-based code) you must use `await import(...)` instead of `require()`. See [docs/SDK_EMBEDDER_GUIDE.md §5](docs/SDK_EMBEDDER_GUIDE.md#5-consuming-from-a-commonjs-context-electron-main-cjs-bundles) for the canonical recipe + the technical reason most subpaths cannot ship a dual ESM/CJS build.
796
-
797
- For CLI users, provider defaults live in `~/.kodax/config.json`. For library users, API keys are still read from environment variables; if you need custom base URLs or provider aliases, use `registerCustomProviders()` as shown above.
798
-
799
- ---
800
-
801
- ## Usage
802
-
803
- ### REPL Quickstart
804
-
805
- Running `kodax` with no prompt starts the interactive REPL.
806
-
807
- ```bash
808
- kodax
809
- ```
810
-
811
- Inside the REPL you can type normal requests or slash commands:
812
-
813
- ```text
814
- Read package.json and summarize the architecture
815
- /model
816
- /mode
817
- /help
818
- ```
819
-
820
- ### CLI Quickstart
821
-
822
- ```bash
823
- # Set API key
824
- export ZHIPU_API_KEY=your_api_key
825
-
826
- # Basic usage
827
- kodax "Help me create a TypeScript project"
828
-
829
- # Choose a provider explicitly
830
- kodax --provider openai --model gpt-5.4 "Create a REST API"
831
-
832
- # Use higher reasoning effort
833
- kodax --effort high "Review this architecture"
834
- ```
835
-
836
- ### Session Workflows
837
-
838
- Use a session when you want memory across turns. Without a session, each CLI call is independent.
839
-
840
- ```bash
841
- # No memory: two separate calls
842
- kodax "Read src/auth.ts"
843
- kodax "Summarize it"
844
-
845
- # With memory: same session
846
- kodax --session my-project "Read package.json"
847
- kodax --session my-project "Summarize it"
848
- kodax --session my-project "How should I fix the first issue?"
849
-
850
- # Session management
851
- kodax -r # Search, page, and select a non-empty session
852
- kodax -r <session-id> # Resume a known session directly
853
- kodax -r "Review runtime" # Resume a unique exact title; duplicates open the picker
854
- kodax --session list # List up to 50 non-empty sessions
855
- kodax --session cleanup-acp # Preview strictly matched empty ACP-test pollution
856
- ```
857
-
858
- Bare `-r` opens an interactive picker with incremental search, arrow/PageUp/PageDown
859
- navigation, Tab completion, full selected-session ID display, and Enter-to-resume.
860
- An explicit value checks the complete session ID first, then an exact
861
- case-insensitive title; duplicate titles open a narrowed picker instead of
862
- silently choosing one. The picker loads before the full CLI, so session listing
863
- remains responsive. After selection it hands terminal input to the resumed
864
- REPL; Esc releases the picker's stdin ownership and immediately returns to the
865
- invoking shell. Session replay preserves each recorded message/event timestamp.
866
-
867
- Cleanup is preview-only unless
868
- `--apply-session-cleanup` is also provided; matching sessions are archived rather
869
- than permanently deleted.
870
-
871
- ### Session Patterns
872
-
873
- ```bash
874
- # ❌ No memory: two independent calls
875
- kodax "Read src/auth.ts" # Agent reads and responds
876
- kodax "Summarize it" # Agent doesn't know what to summarize
877
-
878
- # ✅ With memory: same session
879
- kodax --session auth-review "Read src/auth.ts"
880
- kodax --session auth-review "Summarize it" # Agent knows to summarize auth.ts
881
- kodax --session auth-review "How to fix first issue" # Agent has context
882
- ```
883
-
884
- ### Workflow Examples
885
-
886
- ```bash
887
- # Code review (multi-turn conversation)
888
- kodax --session review "Review src/ directory"
889
- kodax --session review "Focus on security issues"
890
- kodax --session review "Give me fix suggestions"
891
-
892
- # Project development (continuous session)
893
- kodax --session todo-app "Create a Todo application"
894
- kodax --session todo-app "Add delete functionality"
895
- kodax --session todo-app "Write tests"
896
- ```
897
-
898
- ### CLI Reference
899
-
900
- ```text
901
- kodax Start the interactive REPL
902
- -h, --help [topic] Show help or topic help
903
- -p, --print <text> Run a single task and exit
904
- -c, --continue Continue the most recent non-empty conversation in this directory
905
- -r, --resume [value] Resume by ID/exact title, or open the searchable picker
906
- -m, --provider Provider to use
907
- --model <name> Override the model
908
- --reasoning <mode> off | auto | quick | balanced | deep
909
- -t, --thinking Compatibility alias for --reasoning auto
910
- -s, --session <op> Session ID or legacy session operation
911
- -j, --parallel Enable parallel tool execution
912
- --max-iter <n> Max iterations
913
- ```
914
-
915
- ### Permission Control
916
-
917
- KodaX provides 3 permission modes for fine-grained control:
918
-
919
- | Mode | Description | Tools Need Confirmation |
920
- |------|-------------|------------------------|
921
- | `plan` | Read-only planning mode | All modification tools blocked |
922
- | `accept-edits` | Auto-accept file edits | bash only |
923
- | `auto` | Runtime-owned LLM/rules classification within the project boundary | Only explicit classifier escalation |
924
-
925
- ```bash
926
- # In REPL, use /mode command
927
- /mode plan # Switch to plan mode (read-only)
928
- /mode accept-edits # Switch to accept-edits mode
929
- /mode auto # Switch to Runtime-owned Auto Mode
930
- /auto # Alias for auto
931
-
932
- # Check current mode
933
- /mode
934
- ```
935
-
936
- **Features:**
937
- - In `accept-edits` mode, choosing "always" can persist safe Bash allow-patterns
938
- - Plan mode includes system prompt context for LLM awareness
939
- - Permanent protection zones: `.kodax/`, `~/.kodax/`, paths outside project
940
- - Pattern-based permission: Allow specific Bash commands (e.g., `Bash(npm install)`)
941
- - Unified diff display for write/edit operations
942
- - Auto Mode runs guardrail classification before the permission UI; a safe
943
- allow verdict does not create a pending approval request. The session records
944
- an automatic LLM-to-rules fallback for later turns.
945
- - Shift-Tab cycles `Plan -> Edits -> Auto`; Shift+Enter inserts a newline. Auto
946
- immediately displays `Auto[LLM]` or `Auto[RULES]`, and rapid mode changes are
947
- persisted in input order. `Auto[RULES]` is a valid sticky fallback/manual
948
- state; use `/auto-engine llm` to opt back into LLM classification.
949
- - Runtime-backed prompts can offer exact `allow once`, `allow this session`,
950
- and `always allow` choices. Return the Runtime-issued opaque suggestion;
951
- never derive or widen a permission rule from the displayed command or path.
952
- Persistent grants are daemon-owned, revisioned, and can be listed/revoked
953
- through `runtime.permissions` by an authorized SDK host. Dynamic shell
954
- commands deliberately receive no persistent-grant suggestion.
955
-
956
- `kodax -c` skips zero-message ACP/bootstrap placeholders even when they are
957
- newer than the last real conversation. The same newest non-empty rule applies
958
- to Ink, classic, one-shot CLI, and coding-runtime auto-resume; an explicit
959
- session ID always wins. Interactive resume also restores the saved workspace
960
- runtime before relative shell commands or the next model turn.
961
-
962
- ### CLI Help Topics
963
-
964
- Get detailed help for specific topics:
965
-
966
- ```bash
967
- # Basic help
968
- kodax -h
969
- kodax --help
970
-
971
- # Detailed topic help
972
- kodax -h sessions # Session management details
973
- kodax -h init # Long-running project initialization
974
- kodax -h project # Project mode / harness workflow
975
- kodax -h auto # Auto-continue mode
976
- kodax -h provider # LLM provider configuration
977
- kodax -h thinking # Thinking/reasoning effort and compatibility modes
978
- kodax -h team # Multi-agent parallel execution
979
- kodax -h print # Print configuration
980
- ```
981
-
982
- ### Environment Variables
983
-
984
- KodaX recognizes a number of environment variables for tuning runtime behavior. The most commonly used ones are listed below; for the full list, search the repo for `process.env.KODAX_`.
985
-
986
- #### `KODAX_MAX_OUTPUT_TOKENS`
987
-
988
- Overrides the per-turn `max_tokens` value sent to **every** provider (Anthropic, OpenAI, Zhipu, Kimi, MiniMax, Qwen, DeepSeek, MiMo, Gemini, Codex, …). Set to a positive integer; unset or non-numeric values are ignored. This is an **explicit user intent**: when set, it wins over the provider's model descriptor cap, over the provider config default, and over the global `KODAX_MAX_TOKENS` fallback. RST defense is handled at the provider config layer (`streamMaxDurationMs` watchdog + non-streaming fallback in `packages/llm/src/providers/registry.ts`), so this variable is purely an output-budget knob.
989
-
990
- ```bash
991
- # Allow up to 48K output tokens per turn (use a higher cap when generating long files)
992
- export KODAX_MAX_OUTPUT_TOKENS=48000
993
- kodax "generate the full implementation"
994
-
995
- # Unset to restore default behavior
996
- unset KODAX_MAX_OUTPUT_TOKENS
997
- ```
998
-
999
- Precedence used by every provider's `getEffectiveMaxOutputTokens()` (see `packages/llm/src/providers/base.ts`):
1000
-
1001
- 1. One-shot per-request override (agent-loop escalation / context-overflow recovery — internal)
1002
- 2. **`KODAX_MAX_OUTPUT_TOKENS`** (this variable, explicit user intent)
1003
- 3. Active model descriptor's `maxOutputTokens` (FEATURE_098 per-model cap)
1004
- 4. Provider config default
1005
- 5. Global `KODAX_MAX_TOKENS` fallback
1006
-
1007
- Related variables: `KODAX_MAX_TOKENS` (global fallback when no provider/model cap applies), `KODAX_ESCALATED_MAX_OUTPUT_TOKENS` (escalation budget used by the agent loop when a turn returns `stop_reason: max_tokens`).
1008
-
1009
- > **Retired in v0.7.42**: `KODAX_RST_PRONE_PROVIDERS` and `KODAX_WRITE_TURN_MAX_TOKENS` (the v0.7.28 P2b write-turn cap mechanism) are no longer recognized. The 2026-04 bench measured RST as time-based (zhipu-coding 308s server kill window), not payload-size-based, so the cap was retired in favor of the per-provider `streamMaxDurationMs` watchdog + non-streaming fallback chain (configured in `registry.ts`). Existing env exports become silent no-ops; remove them from shell profiles when convenient.
1010
-
1011
- #### Sidecar verifier diagnostics
1012
-
1013
- Use these when diagnosing Worker text-only completion stalls or custom provider verifier behavior:
1014
-
1015
- ```bash
1016
- export KODAX_VERIFIER_LOG=1
1017
- export KODAX_VERIFIER_PROVIDER=anthropic
1018
- export KODAX_VERIFIER_MODEL=claude-haiku-4-5-20251001
1019
- ```
1020
-
1021
- - `KODAX_VERIFIER_LOG=1` shows verifier gate/elapsed/trace information and is equivalent to `"verifierLog": true` in `~/.kodax/config.json`.
1022
- - `KODAX_VERIFIER_PROVIDER` + `KODAX_VERIFIER_MODEL` route the verifier to a separate provider/model instead of inheriting the main Worker model. Set both together.
1023
- - `KODAX_VERIFIER_ALWAYS=1` forces the verifier to fire on every text-only completion for debugging/regression sweeps.
1024
-
1025
- SDK/headless hosts can observe actionable Sidecar Verifier messages via
1026
- `KodaXEvents.onSidecarMessage`; JSONL output emits the same payload as
1027
- `sidecar.message`. Only `revise` and `blocked` verdicts are surfaced; `accept`
1028
- stays silent.
1029
-
1030
- ## Advanced Library Usage
1031
-
1032
- #### Simple Mode (runKodaX)
1033
-
1034
- ```typescript
1035
- import { runKodaX, KodaXEvents } from '@kodax-ai/kodax';
1036
-
1037
- const events: KodaXEvents = {
1038
- onTextDelta: (text) => process.stdout.write(text),
1039
- onThinkingDelta: (text) => console.log(`Thinking delta: ${text.length} chars`),
1040
- onToolResult: (result) => console.log(`Tool ${result.name}: ${result.content.slice(0, 100)}`),
1041
- onSidecarMessage: (event) => console.log(`[sidecar:${event.verdict}] ${event.content}`),
1042
- onComplete: () => console.log('\nDone!'),
1043
- onError: (e) => console.error(e.message),
1044
- };
1045
-
1046
- const result = await runKodaX({
1047
- provider: 'zhipu-coding',
1048
- effort: 'auto',
1049
- events,
1050
- }, 'What is 1+1?');
1051
-
1052
- console.log(result.lastText);
1053
- ```
1054
-
1055
- #### Continuous Session (KodaXClient)
1056
-
1057
- ```typescript
1058
- import { KodaXClient } from '@kodax-ai/kodax';
1059
-
1060
- const client = new KodaXClient({
1061
- provider: 'zhipu-coding',
1062
- effort: 'auto',
1063
- events: {
1064
- onTextDelta: (t) => process.stdout.write(t),
1065
- },
1066
- });
1067
-
1068
- // First message
1069
- await client.send('Read package.json');
1070
-
1071
- // Continue same session
1072
- await client.send('Summarize it');
1073
-
1074
- console.log(client.getSessionId());
1075
- ```
1076
-
1077
- #### Custom Session Storage
1078
-
1079
- ```typescript
1080
- import { runKodaX, KodaXSessionStorage, KodaXMessage } from '@kodax-ai/kodax';
1081
-
1082
- class MyDatabaseStorage implements KodaXSessionStorage {
1083
- async save(id: string, data: { messages: KodaXMessage[]; title: string; gitRoot: string }) {
1084
- // Save to your database
1085
- }
1086
- async load(id: string) {
1087
- // Load from your database
1088
- return null;
1089
- }
1090
- }
1091
-
1092
- await runKodaX({
1093
- provider: 'zhipu-coding',
1094
- session: {
1095
- id: 'my-session-123',
1096
- storage: new MyDatabaseStorage(),
1097
- },
1098
- events: { ... },
1099
- }, 'task');
1100
- ```
1101
-
1102
- ### Library Modes Comparison
1103
-
1104
- | Feature | runKodaX | KodaXClient |
1105
- |---------|----------|-------------|
1106
- | **Message Memory** | ❌ No | ✅ Yes |
1107
- | **Call Style** | Function | Class instance |
1108
- | **Context** | Independent each time | Accumulates |
1109
- | **Use Case** | Single tasks, batch processing | Interactive dialogue, multi-step tasks |
1110
-
1111
- ---
1112
-
1113
- ## SDK Usage
1114
-
1115
- KodaX ships as a single npm package `@kodax-ai/kodax` with 11 SDK subpath exports (ADR-024 v0.7.39 + ADR-032 v0.7.42 + ADR-038 v0.7.49 + v0.7.56 `/media` + v0.7.64 `/runtime` + v0.7.68 `/experimental-memory` + v0.7.69 `/a2a`). Each subpath is tree-shake-friendly so consumers pull only what they need:
1116
-
1117
- ```bash
1118
- npm install @kodax-ai/kodax
1119
- ```
1120
-
1121
- ```typescript
1122
- import { runKodaX } from '@kodax-ai/kodax'; // root: CLI helpers + runKodaX
1123
- import { Runner, runFanOut } from '@kodax-ai/kodax/agent'; // generic Agent framework
1124
- import { getProvider } from '@kodax-ai/kodax/llm'; // 16-alias LLM abstraction
1125
- import { KODAX_TOOLS } from '@kodax-ai/kodax/coding'; // tools + prompts + agent loop
1126
- import { createImageArtifactFromPath } from '@kodax-ai/kodax/media'; // input artifact helpers
1127
- import { runInkInteractiveMode } from '@kodax-ai/kodax/repl'; // Ink TUI entrypoint
1128
- import { SkillRegistry } from '@kodax-ai/kodax/skills'; // zero-dep skill loader
1129
- import { createMcpManager } from '@kodax-ai/kodax/mcp'; // MCP popout manager (v0.7.42)
1130
- import { listSessions } from '@kodax-ai/kodax/session'; // session history helpers
1131
- import { createKodaXRuntime } from '@kodax-ai/kodax/runtime'; // embedded/daemon runtime API
1132
- import { createKodaXA2AServer } from '@kodax-ai/kodax/a2a'; // A2A 1.0 client/server edge
1133
- import { createMemoryAgent } from '@kodax-ai/kodax/experimental-memory'; // opt-in experimental memory SDK
1134
- ```
1135
-
1136
- > The SDK is **ESM-only**. CommonJS consumers (Electron main / Webpack CJS / `require()` callers) must use `await import('@kodax-ai/kodax/...')` — see [docs/SDK_EMBEDDER_GUIDE.md §5](docs/SDK_EMBEDDER_GUIDE.md#5-consuming-from-a-commonjs-context-electron-main-cjs-bundles).
1137
-
1138
- ### `@kodax-ai/kodax/llm` — LLM Abstraction
1139
-
1140
- 16 built-in provider aliases (Anthropic, OpenAI, DeepSeek, Kimi, Kimi-Code, Qwen, Qwen-Token-Plan, Zhipu, Zhipu-Coding, Zai-Coding, MiniMax-Coding, MiMo, MiMo-Coding, Ark-Coding, Gemini-CLI, Codex-CLI) + custom provider registration.
1141
-
1142
- ```typescript
1143
- import { getProvider, KodaXBaseProvider } from '@kodax-ai/kodax/llm';
1144
-
1145
- const provider = getProvider('anthropic');
1146
- const stream = await provider.streamCompletion(
1147
- [{ role: 'user', content: 'Hello!' }],
1148
- { onTextDelta: (text) => process.stdout.write(text) }
1149
- );
1150
-
1151
- for await (const result of stream) {
1152
- if (result.type === 'text') { /* … */ }
1153
- else if (result.type === 'tool_use') { /* … */ }
1154
- }
1155
- ```
1156
-
1157
- **Key Features**: unified provider interface · streaming · reasoning effort (`off/auto/low/medium/high` plus model-supported extras) · per-provider retry + error handling · zero business-logic dependencies.
1158
-
1159
- ### `@kodax-ai/kodax/agent` — Agent Framework (standalone-consumable)
1160
-
1161
- ADR-021 standalone-consumable: `@kodax-ai/agent` has **zero inbound `@kodax-ai/coding` dependency** — you can wire any tool surface on top of it.
1162
-
1163
- ```typescript
1164
- import {
1165
- Runner,
1166
- runFanOut,
1167
- runWithIdleYield,
1168
- createAgentActorController,
1169
- generateSessionId,
1170
- estimateTokens,
1171
- DefaultSummaryCompaction,
1172
- } from '@kodax-ai/kodax/agent';
1173
-
1174
- // Bounded-concurrency fan-out with abort + structured progress events (v0.7.39 FEATURE_120)
1175
- const result = await runFanOut({
1176
- bundles: [{ id: 'a', task: 'audit-foo' }, { id: 'b', task: 'audit-bar' }],
1177
- maxParallel: 4,
1178
- run: async (bundle) => doWork(bundle),
1179
- });
1180
-
1181
- // Runtime-owned Actor identity tree (inject an executor before starting Turns)
1182
- const actors = await createAgentActorController();
1183
- const tree = actors.list('/root');
1184
-
1185
- // Pluggable compaction policy (FEATURE_081)
1186
- const policy = new DefaultSummaryCompaction({ thresholdRatio: 0.8, keepRecent: 10 });
1187
- ```
1188
-
1189
- `DefaultSummaryCompaction` is a standalone agent-layer primitive for custom
1190
- loops. It does not replace or disable KodaX's always-on coding-runtime policy
1191
- described under FEATURE_272 above.
1192
-
1193
- **Key Features**: `Runner` + per-step lifecycle · `runFanOut` (bounded-concurrency + abort + progress events) · `runWithIdleYield` (chat-while-waiting) · `AgentActorController` / `AgentTurnScheduler` · session-id generation · tiktoken-based token estimation · `CompactionPolicy` interface.
1194
-
1195
- ### `@kodax-ai/kodax/skills` — Skills System
1196
-
1197
- Zero external dependencies. Markdown-based skill files with natural-language triggers and variable resolution.
1198
-
1199
- ```typescript
1200
- import {
1201
- SkillRegistry,
1202
- discoverSkills,
1203
- executeSkill,
1204
- type SkillContext,
1205
- } from '@kodax-ai/kodax/skills';
1206
-
1207
- const skills = await discoverSkills(['/path/to/skills']);
1208
- const registry = new SkillRegistry();
1209
- await registry.registerSkills(skills);
1210
-
1211
- const result = await executeSkill({
1212
- skillId: 'code-review',
1213
- arguments: { target: 'src/' },
1214
- workingDirectory: process.cwd(),
1215
- });
1216
- ```
1217
-
1218
- **Key Features**: zero deps · markdown-based skill files · natural-language triggering · variable resolution · built-in skills included.
1219
-
1220
- ### `@kodax-ai/kodax/coding` — Coding Agent
1221
-
1222
- Complete coding agent: 50+ tools (`read`/`write`/`edit`/`bash`/`grep`/`glob` plus `spawn_agent`/`send_message`/`followup_task`/`wait_agent`/`interrupt_agent`/`list_agents`/`agent_output`) + Worker role prompt + Sidecar Verifier (out-of-band Stop-hook) + agent loop + auto-continue + session management.
1223
-
1224
- ```typescript
1225
- import { runKodaX, KodaXClient, KODAX_TOOLS } from '@kodax-ai/kodax/coding';
1226
-
1227
- // Single-task helper
1228
- const result = await runKodaX({
1229
- provider: 'zhipu-coding',
1230
- effort: 'auto',
1231
- events: { onTextDelta: (text) => process.stdout.write(text) },
1232
- }, 'Read package.json and explain the dependencies');
1233
-
1234
- // Continuous session
1235
- const client = new KodaXClient({
1236
- provider: 'anthropic',
1237
- effort: 'auto',
1238
- events: { /* … */ },
1239
- });
1240
- await client.send('Create a new file');
1241
- await client.send('Add a function to it'); // Has context from previous message
1242
- ```
1243
-
1244
- **Key Features**: 50+ built-in tools (see [Tools](#tools)) · V2 Worker single-loop + Sidecar Verifier (FEATURE_184 v0.7.42 / V1 chain fully retired by FEATURE_193 v0.7.43) · Runtime-owned Actor collaboration and safe-boundary steering (FEATURE_270, v0.7.72) · idle-yield waiting · specialist routing via `spawn_agent(agent_id=...)` · auto-continue · session lineage.
1245
-
1246
- ### `@kodax-ai/kodax/repl` — Interactive Terminal UI
1247
-
1248
- Ink/React-based interactive REPL. Permission modes, command system, themed streaming display.
1249
-
1250
- ```typescript
1251
- import { runInkInteractiveMode } from '@kodax-ai/kodax/repl';
1252
-
1253
- // Usually used via the `kodax` bin command; can be embedded:
1254
- // - Interactive terminal UI (Ink components)
1255
- // - Permission control (auto/plan/accept-edits modes)
1256
- // - Command system (/help, /mode, /clear, /status, …)
1257
- // - Skills integration
1258
- // - Theme support
1259
- await runInkInteractiveMode({ provider: 'zhipu-coding', effort: 'auto' });
1260
- ```
1261
-
1262
- **Key Features**: Ink-based React components · 3 permission modes (auto / plan / accept-edits) · built-in commands · real-time streaming display · context-usage indicator.
1263
-
1264
- ### Package Dependency Graph (workspace internal)
1265
-
1266
- ```
1267
- @kodax-ai/llm (zero business-logic deps)
1268
- ↓
1269
- @kodax-ai/agent (depends @kodax-ai/llm; ADR-021 standalone-consumable;
1270
- inlines session-lineage + capabilities/{mcp,skills} +
1271
- tracing per ADR-036 v0.7.43)
1272
- ↓
1273
- @kodax-ai/coding (depends llm + agent; inlines repo-intelligence/protocol per ADR-036)
1274
- ↓
1275
- @kodax-ai/repl (depends coding + ink + react)
1276
- ```
1277
-
1278
- **Subpath Recommendations**:
1279
-
1280
- | Use Case | Subpath | Why |
1281
- |----------|---------|-----|
1282
- | Only need LLM abstraction | `@kodax-ai/kodax/llm` | Minimal deps; 16 built-in aliases |
1283
- | Building custom agent | `@kodax-ai/kodax/agent` | Runner + fan-out + idle-yield + session-lineage + capabilities |
1284
- | Coding tasks | `@kodax-ai/kodax/coding` | Complete coding agent + tools |
1285
- | Terminal app | `@kodax-ai/kodax/repl` | Full interactive experience |
1286
- | Runtime host / daemon client | `@kodax-ai/kodax/runtime` | Sessions, runs, events, permissions, catalog, MCP, artifacts, diagnostics |
1287
- | Experimental governed memory | `@kodax-ai/kodax/experimental-memory` | Scoped `MemoryAgent` / `MemorySession` recall and outcome contracts |
1288
-
1289
- ---
1290
-
1291
- | Provider | Environment Variable | Reasoning Support | Default Model |
1292
- |----------|----------------------|-------------------|---------------|
1293
- | anthropic | `ANTHROPIC_API_KEY` | Native | claude-sonnet-4-6 (`claude-opus-4-6` / `claude-haiku-4-5` via `/model`) |
1294
- | openai | `OPENAI_API_KEY` | Native | gpt-5.3-codex (`gpt-5.4` / `gpt-5.3-codex-spark` via `/model`) |
1295
- | kimi | `KIMI_API_KEY` | Native | kimi-k2.7-code (262,144-token context; `kimi-k2.7-code-highspeed` / `kimi-k2.6` / `kimi-k2.5` via `/model`) |
1296
- | kimi-code | `KIMI_CODE_API_KEY` | Native | kimi-for-coding (`k3-256k` for Moderato / `k3` 1M for Allegretto+ / `kimi-for-coding-highspeed` via `/model`; both K3 choices use upstream `k3`) |
1297
- | qwen | `QWEN_API_KEY` | Native | qwen3.5-plus |
1298
- | qwen-token-plan | `QWEN_TOKEN_API_KEY` | Native | qwen3.8-max-preview (Anthropic-compat; `qwen3.7-max` / `qwen3.7-plus` / `qwen3.6-flash` / `glm-5.2` / `deepseek-v4-pro` via `/model`; all 1M context; image input on Qwen 3.8 / 3.7 Plus / 3.6 Flash) |
1299
- | zhipu | `ZHIPU_API_KEY` | Native | glm-5 (`glm-5.2` 1M ctx / `glm-5.1` / `glm-5-turbo` via `/model`) |
1300
- | zhipu-coding | `ZHIPU_CODING_API_KEY` | Native | glm-5.2 (1M ctx; legacy `glm-5.1` and `glm-5-turbo` remain selectable via `/model`) |
1301
- | zai-coding | `ZAI_CODING_API_KEY` | Native | glm-5.2 (Zhipu Coding Plan overseas mirror via `api.z.ai`, Anthropic-compat — same model lineup as `zhipu-coding`, served from outside CN) |
1302
- | minimax-coding | `MINIMAX_CODING_API_KEY` | Native | MiniMax-M3 (Frontier Coding, native multimodal + 1M ctx; legacy `MiniMax-M2.7` / `MiniMax-M2.7-highspeed` remain selectable via `/model`) |
1303
- | mimo | `MIMO_API_KEY` | Native | mimo-v2.5-pro (Xiaomi MiMo pay-per-token, Anthropic-compat) |
1304
- | mimo-coding | `MIMO_CODING_API_KEY` | Native | mimo-v2.5-pro (Xiaomi Token Plan, Anthropic-compat) |
1305
- | ark-coding | `ARK_CODING_API_KEY` | Native | glm-5.2 (Volcengine Ark Coding Plan — GLM-5.2 (alias: `glm-latest`) · Kimi K2.7 Code / K2.6 · MiniMax M3 / M2.7 · DeepSeek V4 Pro / V4 Flash · Doubao Seed 2.0 Code / Pro / Lite · Doubao Seed Code) |
1306
- | deepseek | `DEEPSEEK_API_KEY` | Native | deepseek-v4-flash (`deepseek-v4-pro` via `/model`) |
1307
- | gemini-cli | `GEMINI_API_KEY` | Prompt-only / CLI bridge | (via gemini CLI) |
1308
- | codex-cli | `OPENAI_API_KEY` | Prompt-only / CLI bridge | (via codex CLI) |
1309
-
1310
- > **Custom providers**: any OpenAI- or Anthropic-compatible endpoint can be added via `customProviders[]` in `~/.kodax/config.json` (CLI) or `registerCustomProviders()` (library). See the [Quick Start](#2-configure-a-provider) for the configuration shape.
1311
-
1312
- ### Examples
1313
-
1314
- ```bash
1315
- # Use Zhipu Coding
1316
- kodax --provider zhipu-coding --thinking "Help me optimize this code"
1317
-
1318
- # Use OpenAI
1319
- export OPENAI_API_KEY=your_key
1320
- kodax --provider openai "Create a REST API"
1321
-
1322
- # Resume last session
1323
- kodax --session resume
1324
-
1325
- # List all sessions
1326
- kodax --session list
1327
-
1328
- # Parallel tool execution
1329
- kodax --parallel "Read package.json and tsconfig.json"
1330
-
1331
- # Adaptive multi-agent (AMA) mode — V2 Worker single-loop with Actor collaboration
1332
- kodax --agent-mode ama "Analyze code structure, check test coverage, find bugs"
1333
- ```
1334
-
1335
- ---
1336
-
1337
- ## Tools
1338
-
1339
- KodaX ships 50+ built-in tools, grouped below. They are registered as a single flat tool surface to the LLM; the categories here are just for navigation.
1340
-
1341
- ### File operations
1342
- | Tool | Description |
1343
- |------|-------------|
1344
- | `read` | Read file contents (supports offset/limit) |
1345
- | `write` | Write a new file or fully rewrite an existing one |
1346
- | `edit` | Exact string replacement (supports `replace_all`) |
1347
- | `multi_edit` | Atomic batch of independent edits to one file |
1348
- | `insert_after_anchor` | Insert content after a unique anchor without rewriting the file |
1349
- | `undo` | Revert the last file modification |
1350
-
1351
- ### Shell & search
1352
- | Tool | Description |
1353
- |------|-------------|
1354
- | `bash` | Execute a shell command (supports `run_in_background`; complete capture with recoverable capacity fallback) |
1355
- | `glob` | Find files by pattern |
1356
- | `grep` | Regex content search (context lines, multiline, file-type filter, pagination) |
1357
- | `code_search` | Lower-noise code search (extension-provider aware) |
1358
- | `semantic_lookup` | Symbol/module/process-aware search backed by repo intelligence |
1359
- | `web_search` | Discovery-oriented web search with trust + freshness signals |
1360
- | `web_fetch` | Fetch a specific URL with provenance hints |
1361
-
1362
- ### Repo Intelligence (working tools)
1363
- | Tool | Description |
1364
- |------|-------------|
1365
- | `repo_overview` | Summarize structure, key areas, entry hints, intelligence snapshot |
1366
- | `changed_scope` | Which files/areas/categories the current diff touches |
1367
- | `changed_diff` | Paged diff slice for a single file |
1368
- | `changed_diff_bundle` | Paged diff slices for multiple files in one call |
1369
- | `module_context` | Module capsule (deps, entries, symbols, tests, docs) |
1370
- | `symbol_context` | Definition + probable callers/callees + alternatives |
1371
- | `process_context` | Approximate static execution capsule for an entry |
1372
- | `impact_estimate` | Blast radius for a symbol/path/module |
1373
-
1374
- ### MCP capabilities (when MCP servers are configured)
1375
- | Tool | Description |
1376
- |------|-------------|
1377
- | `mcp_search` / `mcp_describe` / `mcp_call` | Discover and invoke MCP tools through the shared capability runtime |
1378
- | `mcp_read_resource` / `mcp_get_prompt` | Read MCP resources and prompts |
1379
-
1380
- ### Git worktree
1381
- | Tool | Description |
1382
- |------|-------------|
1383
- | `worktree_create` | Create a new worktree on an isolated branch for safe agent work |
1384
- | `worktree_remove` | Remove a worktree (with safety checks) |
1385
-
1386
- ### Agent control & UX
1387
- | Tool | Description |
1388
- |------|-------------|
1389
- | `spawn_agent` | Create a named child Actor and start its first Turn under inherited capabilities, session capacity, and root work budget. |
1390
- | `send_message` | Commit bounded information to an Actor mailbox without starting a new Turn. |
1391
- | `followup_task` | Join a running Actor at a safe boundary or atomically start a new Turn for an idle Actor. |
1392
- | `wait_agent` | Yield on scoped mailbox/user/interruption/timeout activity; returns a wake acknowledgement and never uses Actor progress as a model wake source. |
1393
- | `interrupt_agent` | Request interruption of an active Turn while preserving Actor identity. |
1394
- | `list_agents` | Inspect the caller-visible Actor subtree and Turn states. |
1395
- | `agent_output` | Read bounded durable output for an authorized Actor/Turn. |
1396
- | `ask_user_question` | Single/multi-select or free-text prompt back to the user |
1397
- | `exit_plan_mode` | Present a finalized plan only when the active REPL/host supplied an approval callback |
1398
- | `run_workflow` | Author and run a deterministic Workflow protocol in AMA only when Workflow intent is explicit; complexity alone never activates it. Child Agents share the Actor control plane. Async / idle-yield. (FEATURE_246; FEATURE_270 v0.7.72) |
1399
- | `emit_managed_protocol` | Internal managed-task protocol side-channel for role payloads (verdict). V2 Worker single-loop + Sidecar Verifier is the default since v0.7.42 (FEATURE_184); V1 chain retired in v0.7.43 (FEATURE_193). |
1400
-
1401
- ---
1402
-
1403
- ## Skills System
1404
-
1405
- KodaX includes a built-in Skills system that can be triggered by natural language:
1406
-
1407
- ```bash
1408
- # Natural language triggering (no explicit /skill needed)
1409
- kodax "帮我审查代码" # Triggers code-review skill
1410
- kodax "写测试用例" # Triggers tdd skill
1411
- kodax "提交代码" # Triggers git-workflow skill
1412
-
1413
- # Explicit skill command
1414
- kodax /skill:code-review
1415
- ```
1416
-
1417
- Built-in skills include:
1418
- - **code-review** - Code review and quality analysis
1419
- - **tdd** - Test-driven development workflow
1420
- - **git-workflow** - Git commit and workflow automation
1421
-
1422
- Skills are stored in `~/.kodax/skills/` and can be extended with custom skills.
1423
-
1424
- ---
1425
-
1426
- ## Commands (CLI)
1427
-
1428
- Commands are `/xxx` shortcuts in CLI:
1429
-
1430
- ```bash
1431
- kodax /review src/auth.ts
1432
- kodax /test
1433
- ```
1434
-
1435
- Commands are stored in `~/.kodax/commands/`:
1436
- - `.md` files → Prompt commands (content used as prompt)
1437
- - `.ts/.js` files → Programmable commands
1438
-
1439
- ---
1440
-
1441
- ## API Exports
1442
-
1443
- ```typescript
1444
- // Main functions
1445
- export { runKodaX, KodaXClient };
1446
-
1447
- // Types
1448
- export type {
1449
- KodaXEvents, KodaXOptions, KodaXResult,
1450
- KodaXMessage, KodaXContentBlock,
1451
- KodaXSessionStorage, KodaXToolDefinition
1452
- };
1453
-
1454
- // Tools
1455
- export { KODAX_TOOLS, KODAX_TOOL_REQUIRED_PARAMS, executeTool };
1456
-
1457
- // Providers
1458
- export { getProvider, KODAX_PROVIDERS, KodaXBaseProvider };
1459
-
1460
- // Utilities
1461
- export {
1462
- estimateTokens,
1463
- getGitRoot, getGitContext, getEnvContext, getProjectSnapshot,
1464
- checkPromiseSignal
1465
- };
1466
- ```
1467
-
1468
- ---
1469
-
1470
- ## Development
1471
-
1472
- ```bash
1473
- # Development mode (using tsx)
1474
- npm run dev "your task"
1475
-
1476
- # Build
1477
- npm run build
1478
-
1479
- # Optional: only build workspace packages
1480
- npm run build:packages
1481
-
1482
- # Build standalone binary (current platform / all platforms)
1483
- npm run build:binary
1484
- npm run build:binary:all
1485
-
1486
- # Run tests
1487
- npm test
1488
-
1489
- # Eval-driven development tests (provider matrices, identity round-trip, etc.)
1490
- npm run test:eval
1491
-
1492
- # Clean
1493
- npm run clean
1494
- ```
1495
-
1496
- ### Repo Intelligence cache directories
1497
-
1498
- KodaX uses one repo-intelligence cache root with separate built-in engine profiles:
1499
-
1500
- - `.agent/repo-intelligence/`
1501
- - Full-engine repo-intelligence artifacts and existing task-engine snapshots.
1502
- - `.agent/repo-intelligence/light/`
1503
- - Light-mode heuristic index artifacts.
1504
-
1505
- They are intentionally separated so:
1506
-
1507
- - full and light profiles can be rebuilt independently.
1508
- - light-mode confidence/capability state cannot be mistaken for full-engine state.
1509
- - future cache migrations can delete one profile without corrupting the other.
1510
-
1511
- `.agent/repo-intelligence/` is local generated state and should not be committed.
1512
-
1513
- ---
1514
-
1515
- ## Code Style
1516
-
1517
- ### Comment Guidelines
1518
-
1519
- KodaX uses an **English-first** comment style with selective Chinese brief notes for complex logic.
1520
-
1521
- | Situation | Style | Example |
1522
- |-----------|-------|---------|
1523
- | Import/Export | English only | `// Import dependencies` |
1524
- | Simple constants | English only | `// Max retry count` |
1525
- | Simple logic | English only | `// Return if null` |
1526
- | **Business rules** | English + Chinese | `// Skip tool_result - 跳过工具结果块` |
1527
- | **Platform compatibility** | English + Chinese | `// Windows path handling - Windows 路径处理` |
1528
- | **Performance optimization** | English + Chinese | `// Debounce to prevent flicker - 防抖避免闪烁` |
1529
-
1530
- ---
1531
-
1532
- ## Documentation
1533
-
1534
- - [README_CN.md](README_CN.md) - Chinese Documentation
1535
- - [docs/SDK_EMBEDDER_GUIDE.md](docs/SDK_EMBEDDER_GUIDE.md) - SDK hosting, shared Runtime daemon, Auto Mode, v0.7.74 compaction/history recovery, Agent telemetry, and active-run input contracts
1536
- - [docs/release.md](docs/release.md) - Standalone binary build & release pipeline
1537
- - [docs/PRD.md](docs/PRD.md) - Product Requirements
1538
- - [docs/ADR.md](docs/ADR.md) - Architecture Decisions
1539
- - [docs/HLD.md](docs/HLD.md) - High-Level Design
1540
- - [docs/DD.md](docs/DD.md) - Detailed Design
1541
- - [docs/FEATURE_LIST.md](docs/FEATURE_LIST.md) - Feature Tracking
1542
- - [docs/test-guides/](docs/test-guides/) - Feature-specific test guides
1543
- - [CHANGELOG.md](CHANGELOG.md) - Version History (v0.7.0+; [archive](docs/CHANGELOG_ARCHIVE.md) for older)
1544
-
1545
- ---
1546
-
1547
- ## License
1548
-
1549
- [KodaX-AI Fair Core License (KAI-FCL) 1.0](LICENSE) - Copyright 2026 [icetomoyo](mailto:icetomoyo@gmail.com).
1550
-
1551
- KAI-FCL is source-available / fair-core, not OSI open source. Commercial,
1552
- enterprise, managed deployment, paid service, or customer redistribution use
1553
- requires KodaX-AI authorization and a valid entitlement where required.
1554
-
1555
- Official KodaX 0.7.70 and later distributions use KAI-FCL or accompanying
1556
- KodaX-AI customer terms. Historical tags, archives, binaries, npm packages, or
1557
- other copies already distributed with Apache-2.0 notices remain Apache-2.0 for
1558
- those specific copies.
469
+ observe the same session. FEATURE_269 adds atomic snapshot-plus-stream joining,
470
+ durable idempotent mutations, revision-safe settings and grants, transport-safe
471
+ AskUser/permission responses, run-scoped credential and Host Tool bridges, and
472
+ one daemon/inline Coder owner fence. In-flight external effects are never
473
+ blindly replayed after a crash; clients receive explicit interrupted/unknown
474
+ terminal facts and resync when `runtimeId` changes.
475
+
476
+ Space and IDE hosts should require these capabilities through the Runtime SDK.
477
+ Partner remains on its private inline Runtime and must use a distinct product
478
+ data/session root. A missing daemon capability is an error, not permission to
479
+ silently fall back to inline Coder.
480
+
481
+ For the full host-integration contract, including inline/Worker/daemon selection,
482
+ multi-client permission handling, config/catalog/MCP admin APIs, artifacts,
483
+ context diagnostics, and daemon protocol schemas, see
484
+ [docs/SDK_EMBEDDER_GUIDE.md §17](docs/SDK_EMBEDDER_GUIDE.md#17-runtime-sdk-worker-isolation-and-local-daemon-feature_253-feature_257).
485
+
486
+ The Space/IDE shared-daemon contract is documented in
487
+ [SDK Embedder Guide section 23](docs/SDK_EMBEDDER_GUIDE.md#23-shared-coder-daemon-for-space-and-ide-hosts-feature_269-v0769).
488
+
489
+ **v0.7.72–v0.7.73 Runtime permission contract:** Auto Mode is owned by the Runtime session,
490
+ not by a UI hook. It reuses its LLM/rules guardrail across turns, classifies
491
+ before the shared permission bridge, and persists an automatic fallback to
492
+ rules. The same session settings can select a classifier model and bounded
493
+ timeout; `auto` defaults to LLM classification and fails with a recoverable
494
+ configuration error when no effective classifier model exists, rather than
495
+ silently falling back. Runtime permission prompts now offer opaque, exact
496
+ allow-once/session/persistent grant suggestions; persistent grants are
497
+ daemon-owned and revisioned. Host plan exit is exposed only when the host
498
+ supplies an approval callback. See the [Runtime Auto Mode integration guide](docs/SDK_EMBEDDER_GUIDE.md#24-runtime-owned-auto-mode-and-plan-approval-bridges-v0772v0773).
499
+
500
+ ## Repo Intelligence
501
+
502
+ KodaX ships with built-in repo intelligence (`repo_overview`, `module_context`, `symbol_context`, `process_context`, `impact_estimate`, and related tools) that helps the coding agent understand large codebases without ad-hoc grep/glob exploration.
503
+
504
+ Use `/repo-intel status` in the REPL to inspect the active engine. The former standalone `repointel` host skill has been removed; repo intelligence is built into KodaX and requires no external installation.
505
+
506
+ ```bash
507
+ # Pick a runtime mode (auto | full | light | off)
508
+ kodax --repo-intelligence full --repo-intelligence-trace
509
+ ```
510
+
511
+ ## Architecture
512
+
513
+ KodaX uses a **monorepo architecture** with npm workspaces. Source layout currently has 4 workspace packages; published as a single bundled npm package `@kodax-ai/kodax` with 11 SDK subpath exports (`/agent`, `/llm`, `/coding`, `/media`, `/repl`, `/skills`, `/mcp`, `/session`, `/runtime`, `/a2a`, `/experimental-memory`; ADR-024 + ADR-032 + ADR-038, with ADR-036 consolidation):
514
+
515
+ ```
516
+ KodaX/
517
+ ├── packages/ # 4 workspace packages (FEATURE_194 v0.7.43)
518
+ │ ├── llm/ # @kodax-ai/llm - LLM abstraction (16 built-in provider aliases)
519
+ │ │ └── providers/ # Anthropic, OpenAI, DeepSeek, Kimi, MiMo, MiniMax, Zhipu, Ark, …
520
+ │ │
521
+ │ ├── agent/ # @kodax-ai/agent - Generic Agent framework
522
+ │ │ ├── actors/ # Runtime-owned Actor tree, scheduler, mailbox, events
523
+ │ │ ├── session-lineage/ # branchable session tree (inline v0.7.43)
524
+ │ │ ├── capabilities/
525
+ │ │ │ ├── mcp/ # MCP integration (inline v0.7.43)
526
+ │ │ │ └── skills/ # Skills standard implementation + builtin (inline v0.7.43)
527
+ │ │ └── tracing/ # tracing / observability (inline v0.7.43)
528
+ │ │
529
+ │ ├── coding/ # @kodax-ai/coding - Coding Agent (tools + prompts)
530
+ │ │ ├── tools/ # 50+ tools: read, write, edit, bash, glob, grep, undo,
531
+ │ │ │ # spawn_agent, send_message, followup_task, wait_agent,
532
+ │ │ │ # ask_user_question, repo-intelligence, …
533
+ │ │ └── repo-intelligence/ # incl. protocol.ts (inline v0.7.43)
534
+ │ │
535
+ │ └── repl/ # @kodax-ai/repl - Interactive terminal UI (Ink TUI)
536
+ │
537
+ ├── src/ # CLI entry + SDK subpath entries
538
+ │ ├── kodax_cli.ts # Main CLI entry point (bin: `kodax`)
539
+ │ └── sdk-*.ts # SDK subpath re-exports → @kodax-ai/kodax/{agent,llm,coding,media,repl,skills,mcp,session,runtime,a2a,experimental-memory}
540
+ │
541
+ └── package.json # Root workspace config; release.mjs rewrites name + injects subpath exports
542
+ ```
543
+
544
+ ### Package Dependencies
545
+
546
+ ```
547
+ ┌──────────────────┐
548
+ │ kodax (root) │
549
+ │ CLI Entry │
550
+ └────────┬─────────┘
551
+ │
552
+ ┌──────────────┴──────────────┐
553
+ │ │
554
+ ▼ ▼
555
+ ┌──────────────┐ ┌────────────────┐
556
+ │@kodax-ai/repl│ │@kodax-ai/coding│
557
+ │ UI Layer │ │ Tools+Prompts │
558
+ └──────┬───────┘ └──────┬─────────┘
559
+ │ │
560
+ │ ┌──────────────┴──────────────┐
561
+ │ │ │
562
+ ▼ ▼ ▼
563
+ ┌──────────────┐ ┌──────────────────────────┐ ┌──────────────┐
564
+ │@kodax-ai/ │ │@kodax-ai/agent │ │@kodax-ai/llm │
565
+ │coding (via │ │Runner + fan-out + │ │LLM Abstract │
566
+ │above) │ │idle-yield + session- │ │(16 aliases) │
567
+ │ │ │lineage + skills + mcp + │ │ │
568
+ │ │ │tracing (FEATURE_194) │ │ │
569
+ └──────────────┘ └──────────────────────────┘ └──────────────┘
570
+ ```
571
+
572
+ ### Package Overview
573
+
574
+ Source-side workspace package names (`@kodax-ai/*`). npm consumers install the single bundled `@kodax-ai/kodax` package and import from SDK subpaths — see [Source-side vs npm-published surface](#source-side-vs-npm-published-surface) and [SDK Usage](#sdk-usage) below.
575
+
576
+ | Workspace package | Purpose | Key Dependencies |
577
+ |---------|---------|------------------|
578
+ | `@kodax-ai/llm` | LLM abstraction (16 built-in provider aliases + custom registration) | @anthropic-ai/sdk, openai |
579
+ | `@kodax-ai/agent` | Generic Agent framework — Runner, fan-out, idle-yield, media/input artifacts, session-lineage, capabilities (mcp + skills), tracing (ADR-036 v0.7.43 consolidation; subpaths: `/media`, `/session-lineage`, `/capabilities/mcp`, `/capabilities/skills`, `/tracing`) | @kodax-ai/llm, js-tiktoken, fflate, jimp, yaml |
580
+ | `@kodax-ai/coding` | Coding Agent — 50+ tools (incl. canonical Actor collaboration tools) + role prompts + auto-continue + repo-intelligence protocol | @kodax-ai/llm, @kodax-ai/agent |
581
+ | `@kodax-ai/repl` | Complete interactive terminal UI (Ink/React, permission modes, commands, streaming) | @kodax-ai/coding, ink, react |
582
+
583
+ ### Source-side vs npm-published surface
584
+
585
+ KodaX has two layers that consumers should understand separately:
586
+
587
+ - **Source-side**: 4 workspace packages above (what developers see when reading the repo).
588
+ - **npm-published**: a single bundled package `@kodax-ai/kodax` with 11 SDK subpaths (what SDK consumers `import` from). The subpaths are split into two roles:
589
+ - **Full-package subpaths** (`/agent`, `/llm`, `/coding`, `/repl`) — each one maps 1:1 to a source workspace and exposes its complete public API.
590
+ - **Integration and narrow subpaths** (`/media`, `/skills`, `/mcp`, `/session`, `/runtime`, `/a2a`, `/experimental-memory`) — focused host surfaces. `/a2a` composes the neutral F258 plane with the Runtime facade; it does not add A2A wire types to `/agent`.
591
+
592
+ | Source package | npm subpath | Type | What you get | Example consumer |
593
+ |---|---|---|---|---|
594
+ | `packages/llm` | `@kodax-ai/kodax/llm` | Full package | 16-alias LLM abstraction (108 exports) | Standalone LLM clients |
595
+ | `packages/agent` | `@kodax-ai/kodax/agent` | Full package | Runner / fan-out / external-agent plane / session-lineage / capabilities / tracing (331 exports) | Custom agent frameworks |
596
+ | `packages/agent` | `@kodax-ai/kodax/skills` | **Narrow subset** | Skills system only — `SkillRegistry` / `loadFullSkill` / `expandSkillForLLM` / ... (26 exports = pre-v0.7.43 `@kodax-ai/skills` complete API) | Skill loaders, IDE plugins |
597
+ | `packages/agent` | `@kodax-ai/kodax/mcp` | **Narrow subset** | MCP only — `McpCapabilityProvider` / `createMcpTransport` / `searchMcpCatalog` / ... (23 exports) | MCP server hosts |
598
+ | `packages/agent` | `@kodax-ai/kodax/media` | **Narrow subset** | Structured image/file/video input-artifact helpers (22 exports) | Desktop hosts and multimodal clients |
599
+ | `packages/agent` | `@kodax-ai/kodax/experimental-memory` | **Experimental subset** | Thin F228-backed `MemoryAgent` / `MemorySession` contracts for scoped recall, deliberate query, observations, and outcomes | SDK hosts explicitly evaluating FEATURE_260 |
600
+ | `packages/coding` | `@kodax-ai/kodax/coding` | Full package | Coding agent + 50+ tools + repo-intelligence (505 exports) | Build a Claude Code-shape product |
601
+ | `packages/repl` | `@kodax-ai/kodax/repl` | Full package | Ink TUI + permission modes + commands (217 exports) | Terminal-UI consumers |
602
+ | `packages/repl` | `@kodax-ai/kodax/session` | **Narrow subset** | Session management only — `listSessions` / `loadFullTranscript` / `appendClientNotice` / `forkSession` / `compactSession` / `watchSessions` / ... (17 exports) | IDE plugins and desktop hosts reading session history |
603
+ | `src` | `@kodax-ai/kodax/runtime` | Host API | Embedded/Worker/daemon runtime facade, sessions/runs/events/permissions/catalog/MCP/artifacts/diagnostics/external agents, daemon protocol schema (10 exports) | SDK hosts, Space/IDE clients, daemon clients |
604
+ | `src` | `@kodax-ai/kodax/a2a` | Integration edge | A2A 1.0 Agent Card discovery, JSON-RPC/SSE F258 executor, safe fetch policy, and authenticated Runtime-backed Agent server | Agent orchestrators and KodaX hosts |
605
+
606
+ **Rule of thumb**: if you need Runner / Agent / fan-out, import from `/agent`. If you only need skills or mcp APIs, import from `/skills` or `/mcp` to get a smaller bundle. The narrow subsets are subsets of the full packages — they do **not** expose extra symbols.
607
+
608
+ **Dynamic Workflows (FEATURE_217, v0.7.49)**: the domain-neutral workflow runtime is part of `/agent` — `import { createWorkflowRuntime, runWorkflow, WorkflowAbortError, WorkflowLimitError } from '@kodax-ai/kodax/agent'`. The coding-side integration (agent backend + built-in workflows + saved-workflow discovery/generation: `createCodingWorkflowBackend`, `runWorkflowFromOptions`, `parallelInvestigation`, `discoverSavedWorkflows`, `generateWorkflowFromOptions`, …) is part of `/coding`. FEATURE_217 is the v0.7.49 home for the full Dynamic Workflow product loop: `/workflow create <request>` generates restricted scripts, `/workflow save <runId> <name>` stores `.workflow.json` rerunnable workflows, generated/saved scripts coordinate agents through `WorkflowApi`, run lifecycle state stays observable, opt-in `isolation:"worktree"` routes selected children to parent-managed worktrees, and all file/shell effects still pass through agent tools and the existing permission gates. There is **no** separate `@kodax-ai/kodax/agent/workflow` root-package subpath; source-package consumers of `@kodax-ai/agent` can still use that package's `./workflow` subpath.
609
+
610
+ **Workflow Process Surface (FEATURE_229, v0.7.50)**: workflow progress is now a reusable Agent-layer process contract rather than private REPL text. SDK hosts can subscribe to `WorkflowProcessEvent`/poll `WorkflowProcessSnapshot`, use `createWorkflowRunManager` and `createWorkflowLifecycleController` for stop/pause/resume/result/artifact/delete/prune/identity/preflight controls, and receive ANSI-free provenance fields (`source`, `sourceRunId`, `sourceWorkflowName`, `savedWorkflowName`, `revisionOf`) plus `resultSummary`. `/coding` owns the coding workflow backend and run graph, `/repl` renders the same snapshots, and the terminal UI is not the hidden source of truth. `KodaXEvents` callbacks also take an optional metadata arg (`KodaXToolEventMeta` / `KodaXActivityEventMeta` / `KodaXWorkflowEventMeta`) so a host can attribute every child-agent tool/thinking/progress event to its workflow run and child id without a second event protocol, and generated/saved workflow scripts pass `validateRestrictedWorkflowSource` (compile + source-policy check) plus a generator repair/smoke loop before they run. See [docs/ADR.md ADR-040](docs/ADR.md) for the layering rationale.
611
+
612
+ **Host Reads Persisted History (FEATURE_230 + FEATURE_234, v0.7.51; v0.7.63 hardening)**: additive closures for hosts that read persisted state. **Durable tool transcript replay** — a resumed session now replays the tool cards the assistant used instead of degrading to text-only. `messages` / `lineage` stay canonical; `SessionData.uiHistory` becomes a bounded, sanitized, terminal-only replay cache. The SDK transcript contract is explicit: `loadSession()` = active model context, `loadFullTranscript()` = append-order host scrollback with typed entries (`message` / `compaction` / `branch_summary` / `rewind_marker` / `client_notice` / `task_result`) plus clone provenance (`logicalId` / `sourceEntryId`), `uiHistory` = optional replay cache, and tool cards can always be reconstructed from canonical messages. Hosts can persist local slash output with `appendClientNotice()` without entering model context, and workflow/child completions expose structured `taskResults[]` instead of requiring `<task-completed>` parsing. `rewind_marker` is an audit entry for host scrollback only and is excluded from model-context messages. **Workflow run host attribution** — `WorkflowProcessTrackerOptions` / `WorkflowProcessSnapshot` gain a host-owned opaque `hostMetadata?: Record<string, string>` that the SDK stores, persists to `run.json`, and echoes back (including after a restart) without interpreting it, so a host can map a run to the session/surface that launched it with zero side table. Unstamped/legacy runs honestly echo `hostMetadata === undefined`. See [docs/features/v0.7.51.md](docs/features/v0.7.51.md).
613
+
614
+ **Inline Workflow Authoring (FEATURE_246, v0.7.58; F270 update in v0.7.72)**: the Worker can author and run a workflow inline via the model-callable `run_workflow` tool when Workflow intent is explicit. It scouts the codebase first, bakes concrete findings into child prompts, and runs the script through the sandbox, static-validation, and postcondition-verification pipeline. F270 retires AMAW and complexity-driven activation; AMA keeps explicit `/workflow`, named/SDK, and natural-language Workflow requests. Workflow child Agents now run on the unified Actor control plane. See [docs/features/v0.7.58.md](docs/features/v0.7.58.md), [docs/features/v0.7.72.md](docs/features/v0.7.72.md), and ADR-044/046/047/048/049/055.
615
+
616
+ **Historical Workflow Activation Tiers (FEATURE_248 + FEATURE_249, v0.7.59; superseded by F270 in v0.7.72)**: v0.7.59 introduced AMAW and explicit-request AMA behavior. F270 retires AMAW and its complexity-driven directive. SA remains solo; AMA is the single adaptive multi-Agent mode and activates Workflow only from explicit Workflow intent. See [docs/features/v0.7.59.md](docs/features/v0.7.59.md) and [docs/features/v0.7.72.md](docs/features/v0.7.72.md).
617
+
618
+ **Progressive Disclosure on the Managed Tool Path (FEATURE_250, v0.7.60; current policy corrected in v0.7.74)**: the deferred-tool mechanism applies to the managed AMA path as well as SA. The current deferred set contains exactly 11 tools: six repo-intelligence tools, four web/code discovery tools, and `run_workflow`. Their `input_schema` remains directly callable while `tool_search` provides the full description on demand. The five fixed `mcp_*` facades and the `get_goal` / `create_goal` / `update_goal` lifecycle tools stay resident with their complete contracts. The v0.7.74 goal correction adds only about 109 estimated schema tokens versus the former hints (`get_goal` is actually 12 tokens smaller when resident), removes a discovery round trip, and changes no tool schema, handler, permission, goal state, or compaction-protection behavior. See [docs/features/v0.7.60.md](docs/features/v0.7.60.md) and [docs/features/v0.7.74.md](docs/features/v0.7.74.md#feature_250-v0774-correction-resident-goal-lifecycle-tools).
619
+
620
+ **Context-Efficient Tool Results + Workflow Quality Preflight (FEATURE_251 + FEATURE_252, v0.7.61; corrected 2026-07-14)**: local tools collect complete output and apply only contract-equivalent normalization that is strictly shorter; command-specific lossy Bash filters are off by default, and compound Bash uses no semantic adapter. One owner evaluates the complete parallel-result batch against the final provider request: it solves the largest final input `Pmax` for which `Pmax + output reserve + max(2048, 3% of Pmax) <= context window`, then admits only the remaining physical capacity. Results stay verbatim whenever they fit; only real overflow persists the complete value and emits `KODAX_RESULT_INCOMPLETE`. History keeps the same physical-capacity safety rule: no default lossy microcompaction below capacity, summary-first at pressure, and typed failure without silent deletion when a recoverable request cannot be formed. FEATURE_272 supersedes FEATURE_251 only for the default major-compaction trigger. FEATURE_252's deterministic pre-start workflow contract lint is unchanged. See [docs/features/v0.7.61.md](docs/features/v0.7.61.md) and [docs/ADR.md ADR-050](docs/ADR.md).
621
+
622
+ **Reliable Always-On Context Compaction (FEATURE_272, v0.7.74)**: automatic major compaction cannot be disabled. Its percentage trigger defaults to 75% and clamps to 15-90%; optional `triggerTokens` is inactive when omitted/zero, otherwise the smaller percentage, absolute, and physical-capacity threshold wins. The protected raw tail is 20% of that effective trigger. One transaction summarizes the complete eligible prefix, preserves every genuine user request through an exact ledger, and emits success only after a physically valid token reduction and awaited durable commit. Before raw bodies are evicted, the Session owner durably flushes their exact lineage; stable entry IDs merge the sidecar and slim Session without duplicates. Root and persistent child Agents can recover omitted user/assistant/tool details through bounded `session_history_search` → `session_history_read`, with children isolated to hidden worker Sessions and never granted root-history access. SDK/Runtime clients use revision-bound `transcriptSearch`, pages, and lossless chunks. Hidden reasoning, system instructions, and synthetic checkpoints are excluded from model search. See [the feature design](docs/features/v0.7.74.md), [SDK guide §25](docs/SDK_EMBEDDER_GUIDE.md#25-always-on-context-compaction-and-bounded-transcript-recovery-v0774), and [ADR-057](docs/ADR.md#adr-057-large-compaction-is-an-always-on-context-scoped-full-coverage-transaction).
623
+
624
+ **Mailbox-Driven Agent Coordination (FEATURE_273, v0.7.74)**: `wait_agent` is now a true model-facing mailbox yield with one bounded `timeout_ms`, not an Actor progress/event reader. It wakes for scoped Agent messages or completions, root user input, interruption, or timeout; progress remains available to UI/SDK snapshot, replay, and long-poll consumers without resampling the parent model. The tool returns only a wake acknowledgement, while authenticated Agent evidence and structured task metadata enter the next safe model boundary once. Unacknowledged root completions survive a hard restart, same-process Runtime rebuilds deduplicate by child turn ID, and acknowledged or legacy historical completions are not replayed. Use `list_agents` for tree state and `agent_output` for a targeted known result. See [the feature design](docs/features/v0.7.74.md#feature_273-mailbox-driven-agent-wait-and-telemetrycontrol-separation), [SDK guide §26](docs/SDK_EMBEDDER_GUIDE.md#26-agent-mailbox-control-versus-sdk-event-telemetry-v0774), and [ADR-058](docs/ADR.md#adr-058-model-agent-wait-is-mailbox-control-not-event-telemetry).
625
+
626
+ **Active-Run Interrupt Input (v0.7.74)**: embedded Runtime and the shared daemon advertise `interruptInput:1`. `runtime.runs.submitInput()` queues an immutable, ordered input for the current active Actor Run; all inputs admitted before one safe Runner boundary are delivered FIFO as separate user messages in the next LLM request, without creating continuation Runs. Queued/delivered state is visible in typed Run snapshots/events, delivery is acknowledged against the exact consumed IDs, and terminal cleanup prevents undelivered input from leaking into later Runs.
627
+
628
+ **External Agent SDK Plane (FEATURE_258, v0.7.67)**: `/agent` exports the protocol-neutral executor, registration, policy, credential-broker, artifact-policy, catalog, and durable task contracts. `/runtime` exposes the installed plane through `admin.agentRegistrations`, `agents`, and `agentTasks`, with the same DTO service methods over embedded and daemon clients. Executor factories are host functions: install them in an inline owner or while creating a new in-process daemon owner; they cannot be injected through an existing daemon connection or across a Runtime Worker boundary. Plane shutdown is terminal: pending waits and all later service calls reject. Restricted Workflow scripts preserve validated `phase` and external `target` routing. See the [complete owner/consumer recipes and safety contract](docs/SDK_EMBEDDER_GUIDE.md#18-external-agent-executor-plane-feature_258-v0767).
629
+
630
+ **Cost-Disciplined Workflow SDK (FEATURE_259, v0.7.67)**: SDK callers configure run-scoped `modelTiers` and `workflow.maxConcurrency`, while workflow authors express semantic `fast` / `balanced` / `deep` intent. Terminal workflow events expose resolved tier/source/fallback/usage/duration facts, and each durable `run.json` contains an `efficiencyReport` with token coverage, role/tier starts, packet-read topology, review waves, and quality-gate outcomes. See the [routing and telemetry contract](docs/SDK_EMBEDDER_GUIDE.md#20-cost-disciplined-workflow-routing-and-telemetry-feature_259-v0767).
631
+
632
+ **Paged Session Listing (FEATURE_261, v0.7.67)**: both `/session` `listSessions()` and `runtime.sessions.list()` accept an exact `surface` filter and opaque continuation `cursor`; each returned summary carries the cursor for the next page. Filtering happens before the page limit, so a host does not need to over-fetch mixed surfaces. See the [pagination recipes](docs/SDK_EMBEDDER_GUIDE.md#19-session-surface-filtering-and-cursor-pagination-feature_261-v0767).
633
+
634
+ **Experimental Memory Agent SDK (FEATURE_260, v0.7.68)**: `/experimental-memory` exposes the thin agent-layer `MemoryAgent` and scoped `MemorySession` lifecycle over the existing governed F228 plane. Passive recall is zero-wait; `query()` is read-only and deliberate; durable changes still require the proposal/preview/fingerprint/apply path. The Action LLM remains the final decision maker, recalled content stays low-authority, and safety/scope gates remain deterministic. See the [direct session and boundary guide](docs/SDK_EMBEDDER_GUIDE.md#21-experimental-governed-memory--experimental-memory-feature_260-v0768).
635
+
636
+ **Bidirectional A2A 1.0 (FEATURE_267, v0.7.69)**: `/a2a` discovers allowed Agent Cards and installs a JSON-RPC/SSE executor through the existing F258 plane. Configured outbound Agents are also registered automatically as `external:<name>` in embedded CLI and user-daemon Runtimes, so the main Agent can orchestrate them without host code. One `a2a.json` may hold many outbound registrations and at most one inbound server, which publishes either the Runtime default or one validated `~/.kodax/agents/*.md` Agent behind an authenticated Runtime facade. The built-in listener is loopback-only; public deployment uses `handle()` behind host-owned TLS and authorization. A2A 0.3, gRPC, HTTP+JSON, push notifications, and automatic public exposure are not advertised. See the [client/server recipes and security boundaries](docs/SDK_EMBEDDER_GUIDE.md#22-bidirectional-a2a-10--a2a-feature_267-v0769).
637
+
638
+ **A2A interoperability and authentication hardening** keeps a discovered
639
+ interface on the trusted Agent Card origin and sends credentials only when one
640
+ complete Card/Skill security requirement is satisfiable. The no-code client
641
+ supports HTTP Bearer compatibility and OAuth 2.0 Client Credentials; for OAuth,
642
+ an external Authorization Server issues short-lived access tokens and KodaX
643
+ caches them only in memory. Inbound `a2a serve` can validate RFC 9068 JWT access
644
+ tokens from an external issuer/JWKS, but never signs or issues production
645
+ tokens itself. It resolves its provider from CLI, then environment, config, and
646
+ the built-in default; a Markdown Agent can pin its own provider. Input
647
+ continuation resumes the original Runtime run, task history and retention are
648
+ bounded with stable cursor pagination, and authenticated SSE is correlated
649
+ before falling back to polling after an early normal EOF. Only direct remote
650
+ artifacts, broker-staged outputs, and outputs from a successfully admitted
651
+ Skill script can be published; ordinary workspace writes and local paths stay
652
+ private.
653
+
654
+ This authentication and per-Agent activation hardening is a post-release
655
+ closure of the v0.7.69 F267/F268 design and ships in the v0.7.71 patch; it is
656
+ not a claim that older v0.7.69 binaries contained the
657
+ later OAuth profiles.
658
+
659
+ **v0.7.70 MCP discovery hardening** uses exact capability IDs and revisioned
660
+ cursors while admitting results against real physical capacity. Compact CJK
661
+ queries are segmented, and a cross-language lexical zero match either returns a
662
+ lossless bounded grouped inventory or one concise retry in the catalog language.
663
+ Partial provider failure remains explicit rather than disappearing into an
664
+ apparently complete result.
665
+
666
+ The complete built-in path is available without writing TypeScript:
667
+
668
+ ```bash
669
+ # Call another A2A Agent
670
+ kodax a2a add research https://agent.example/.well-known/agent-card.json --effect read
671
+ kodax a2a test research
672
+ kodax a2a call research "Summarize this topic"
673
+
674
+ # Stage an OAuth-protected Agent, then hot-activate/deactivate it
675
+ export RESEARCH_A2A_CLIENT_SECRET='provisioned-by-your-authorization-server'
676
+ # PowerShell: $env:RESEARCH_A2A_CLIENT_SECRET='provisioned-by-your-authorization-server'
677
+ # PowerShell: run the command on one line or replace each trailing \ with a backtick.
678
+ kodax a2a add reviewer https://reviewer.example/.well-known/agent-card.json \
679
+ --disabled --effect read --oauth-scheme enterprise-oauth \
680
+ --oauth-issuer https://identity.example/ \
681
+ --oauth-token-url https://identity.example/oauth/token \
682
+ --oauth-client-id kodax-reviewer \
683
+ --oauth-client-secret-env RESEARCH_A2A_CLIENT_SECRET \
684
+ --oauth-scope a2a.invoke --oauth-resource https://reviewer.example/
685
+ kodax a2a enable reviewer
686
+ kodax a2a disable reviewer # blocks new dispatch; does not cancel in-flight tasks
687
+
688
+ # Expose the Runtime default Agent, or pass a name from ~/.kodax/agents/*.md
689
+ export KODAX_A2A_TOKEN='replace-with-a-long-random-token'
690
+ # PowerShell: $env:KODAX_A2A_TOKEN='replace-with-a-long-random-token'
691
+ kodax a2a expose # or: kodax a2a expose document-agent
692
+ kodax a2a serve # loopback http://127.0.0.1:8765
693
+ ```
694
+
695
+ MCP, A2A, and Extension declarations live in one user file per domain under
696
+ `~/.kodax/integrations/`. Use `kodax config template <mcp|a2a|extensions>`,
697
+ `kodax integrations migrate --apply`, and the `kodax mcp`, `kodax a2a`, or
698
+ `kodax extensions` commands to manage them. Migration imports only legacy
699
+ `config.json#mcpServers` and `config.json#extensions`; A2A has no legacy source.
700
+ It never overwrites an existing destination. The first MCP/Extension mutation
701
+ can stage legacy entries. Remove legacy keys only with
702
+ `--apply --cleanup-legacy`, after reviewing destination files and
703
+ literal-secret warnings. Running
704
+ CLI/daemon hosts retain the
705
+ last valid revision, atomically replace the complete MCP provider, reconcile
706
+ Extensions per entry, and hot-register outbound A2A Agents. Each A2A entry has
707
+ a desired `enabled` switch; `kodax a2a list` shows configuration, while the
708
+ owning Runtime is authoritative for live applied registrations. Disabled
709
+ entries are not fetched during automatic reconciliation and, after the owning
710
+ Runtime applies the revision, cannot accept new dispatch. The mutation command
711
+ itself is not cross-process acknowledgement. `a2a add --disabled` still checks
712
+ the Card by default unless `--no-test` is supplied, while `a2a test` performs
713
+ discovery/security planning without requesting an OAuth token. The fixed
714
+ `KODAX_A2A_TOKEN` example is an operator-provisioned compatibility credential;
715
+ KodaX does not generate or issue it. Disabled entries remain available for
716
+ later re-enable. `a2a serve` loads
717
+ its configured MCP/Extension capability surface before listening and pins that
718
+ execution authority; it hot-reloads publication, authentication, and limits.
719
+
720
+ A2A configuration migration and retained task ownership are separate. If a
721
+ v0.7.70 task store must remain addressable after the realm-aware upgrade, stop
722
+ the A2A server, run `kodax a2a migrate-tasks` to inspect the exact-owner plan,
723
+ then apply it with `--apply --confirm-server-stopped`. OAuth migration also
724
+ requires the known historical `--subject`; normal serving never guesses or
725
+ dual-reads a legacy owner key.
726
+
727
+ Agent, Skill, Extension-tool authority, workspace, tool-policy, or task-store
728
+ changes require an explicit server restart. Managed
729
+ A2A contexts default to `~/kodax_a2a_server_workspace/<runtime-profile>/contexts/`.
730
+ Exact Skill scripts require the opt-in isolated policy and a passing
731
+ `kodax sandbox doctor` (`kodax sandbox setup` performs the explicit Windows
732
+ one-time provisioning).
733
+
734
+ ---
735
+
736
+ ## Features
737
+
738
+ - **Modular Architecture** - Use as CLI, as a library, or as a Node-free single binary
739
+ - **16 Built-in Provider Aliases** - Anthropic, OpenAI, DeepSeek, Kimi, Kimi Code, Qwen, Qwen Token Plan, Zhipu, Zhipu Coding, Zai Coding, MiniMax Coding, MiMo Coding, MiMo, Ark Coding, Gemini CLI, Codex CLI - plus user-defined OpenAI/Anthropic-compatible providers
740
+ - **Dynamic Workflows + SDK Process Surface** - Generate/reuse capability-routed workflows, observe live progress through `WorkflowProcessSnapshot`, and control workflow lifecycle from SDK hosts without parsing REPL output
741
+ - **V2 Worker single-loop + Sidecar Verifier (default)** - Single-agent main loop with an out-of-band Sidecar Verifier as Stop-hook (claudecode-shape; FEATURE_184 v0.7.42, ADR-030). Verifier returns accept/revise/blocked verdict on Worker text-only termination. The pre-v0.7.43 V1 chain is retired, `emit_handoff` is deleted, accept-verdict UI silently passes through, and content-aware gating skips trivial-chat sidecar calls. Adaptive child steering uses the canonical Actor collaboration tools with idle-yield waiting; specialist routing uses `spawn_agent(agent_id=...)`.
742
+ - **Reasoning Effort** - Effort-first control (`off/auto/low/medium/high` plus model-supported extras) across providers
743
+ - **Streaming Output** - Real-time response display
744
+ - **Session Management** - JSONL format with branchable session lineage tree
745
+ - **Skills System** - Natural language triggering, extensible, role-projected in AMA
746
+ - **Repo Intelligence** - Built-in full/light repository intelligence with native KodaX auto-injection lane
747
+ - **Rich Tool Surface** - 50+ built-in tools across file ops, shell, search, repo intelligence, MCP capabilities, git worktree, and agent control
748
+ - **Permission Control** - 3 permission modes with pattern-based control
749
+ - **Standalone Binary** - `bun --compile` releases for Win/macOS/Linux x64+arm64, no Node.js required on target machines
750
+ - **Cross-Platform** - Windows/macOS/Linux
751
+ - **TypeScript Native** - Full type safety and IDE support
752
+
753
+ ---
754
+
755
+ ## Installation
756
+
757
+ ### As CLI Tool
758
+
759
+ ```bash
760
+ # Clone repository
761
+ git clone https://github.com/icetomoyo/KodaX.git
762
+ cd KodaX
763
+
764
+ # Install dependencies (includes workspace packages)
765
+ npm install
766
+
767
+ # Build the monorepo
768
+ npm run build
769
+
770
+ # Link globally (development mode)
771
+ npm link
772
+
773
+ # Now you can use 'kodax' anywhere
774
+ kodax "your task"
775
+ ```
776
+
777
+ ### As Standalone Binary (no Node required on target)
778
+
779
+ KodaX can be packaged into a single executable + a small `builtin/` sidecar directory using `bun --compile`. The target machine does **not** need Node.js or any other runtime.
780
+
781
+ Supported targets: `win-x64`, `linux-x64`, `linux-arm64`, `darwin-x64`, `darwin-arm64`. Win7 / pre-glibc-2.27 distros / LoongArch are not supported.
782
+
783
+ **Build locally**:
784
+
785
+ ```bash
786
+ # Install Bun once on your build machine
787
+ npm i -g bun # or scoop/brew/curl install — see docs/release.md
788
+
789
+ npm run build:binary # Current host platform (fastest)
790
+ npm run build:binary:all # All five targets in sequence
791
+ node scripts/build-binary.mjs --target=linux-arm64 # Specific target
792
+ ```
793
+
794
+ Output lives under `dist/binary/<target>/`:
795
+
796
+ ```
797
+ dist/binary/linux-x64/
798
+ ├── kodax # ~60 MB Bun-compiled executable
799
+ ├── builtin/ # Sidecar built-in skills
800
+ ├── provider-capabilities.json
801
+ ├── semantic-worker.js # Repo-intelligence Worker
802
+ ├── runtime-worker.js # SDK Runtime Worker
803
+ └── constructed-handler-worker.js # Constructed-tool Worker
804
+ ```
805
+
806
+ Smoke-test: `dist/binary/<host>/kodax --version`.
807
+
808
+ **Automated release**: pushing a `v*` git tag triggers `.github/workflows/release.yml`, which builds all five targets on native runners, runs smoke tests, and publishes a GitHub Release with archives + SHA256SUMS. Use the `workflow_dispatch` button in the Actions UI to test the pipeline without tagging.
809
+
810
+ See [docs/release.md](docs/release.md) for full details on build flags, archive layout, troubleshooting, and the build-time `KODAX_BUNDLED` / `KODAX_VERSION` defines.
811
+
812
+ ### As Library
813
+
814
+ ```bash
815
+ npm install @kodax-ai/kodax
816
+ ```
817
+
818
+ ```typescript
819
+ import { runKodaX } from '@kodax-ai/kodax';
820
+
821
+ process.env.ZHIPU_API_KEY = process.env.ZHIPU_API_KEY ?? 'your_api_key';
822
+
823
+ const result = await runKodaX({
824
+ provider: 'zhipu-coding',
825
+ effort: 'auto',
826
+ events: {
827
+ onTextDelta: (text) => process.stdout.write(text),
828
+ onComplete: () => console.log('\nDone!'),
829
+ },
830
+ }, 'your task');
831
+
832
+ console.log(result.lastText);
833
+ ```
834
+
835
+ #### SDK Subpath Imports (v0.7.39+)
836
+
837
+ For smaller surface and tree-shake-friendly imports, the SDK is also exposed via subpath exports — pick only the package(s) you need:
838
+
839
+ ```typescript
840
+ import { Runner } from '@kodax-ai/kodax/agent'; // agent runtime
841
+ import { getProvider } from '@kodax-ai/kodax/llm'; // LLM abstraction (16 aliases)
842
+ import { runKodaX } from '@kodax-ai/kodax/coding'; // coding tools + prompts
843
+ import { createImageArtifactFromPath } from '@kodax-ai/kodax/media'; // input artifacts
844
+ import { SkillRegistry } from '@kodax-ai/kodax/skills'; // zero-dep skill loader
845
+ import { loadConfig } from '@kodax-ai/kodax/repl'; // REPL config / session helpers
846
+ import { createMcpManager } from '@kodax-ai/kodax/mcp'; // MCP popout manager (v0.7.42)
847
+ import { listSessions } from '@kodax-ai/kodax/session'; // session history helpers
848
+ import { createKodaXRuntime } from '@kodax-ai/kodax/runtime'; // embedded/daemon runtime API
849
+ import { createKodaXA2AServer } from '@kodax-ai/kodax/a2a'; // A2A 1.0 client/server edge
850
+ ```
851
+
852
+ All 12 SDK entries (root + 11 subpaths) share internal code via ESM chunk splitting — importing from `/agent` does not pull in `/repl`'s Ink + React surface.
853
+
854
+ For the complete host-facing contract — including embedded/Worker/daemon ownership,
855
+ external-agent registration and task control, session cursor pagination, workflow
856
+ model-tier routing, and efficiency telemetry — see the
857
+ [SDK Embedder Integration Guide](docs/SDK_EMBEDDER_GUIDE.md).
858
+
859
+ > **ESM-only.** The SDK is published as ES Modules. In a CommonJS context (Electron main process, legacy Webpack CJS bundles, `require()`-based code) you must use `await import(...)` instead of `require()`. See [docs/SDK_EMBEDDER_GUIDE.md §5](docs/SDK_EMBEDDER_GUIDE.md#5-consuming-from-a-commonjs-context-electron-main-cjs-bundles) for the canonical recipe + the technical reason most subpaths cannot ship a dual ESM/CJS build.
860
+
861
+ For CLI users, provider defaults live in `~/.kodax/config.json`. For library users, API keys are still read from environment variables; if you need custom base URLs or provider aliases, use `registerCustomProviders()` as shown above.
862
+
863
+ ---
864
+
865
+ ## Usage
866
+
867
+ ### REPL Quickstart
868
+
869
+ Running `kodax` with no prompt starts the interactive REPL.
870
+
871
+ ```bash
872
+ kodax
873
+ ```
874
+
875
+ Inside the REPL you can type normal requests or slash commands:
876
+
877
+ ```text
878
+ Read package.json and summarize the architecture
879
+ /model
880
+ /mode
881
+ /help
882
+ ```
883
+
884
+ ### CLI Quickstart
885
+
886
+ ```bash
887
+ # Set API key
888
+ export ZHIPU_API_KEY=your_api_key
889
+
890
+ # Basic usage
891
+ kodax "Help me create a TypeScript project"
892
+
893
+ # Choose a provider explicitly
894
+ kodax --provider openai --model gpt-5.4 "Create a REST API"
895
+
896
+ # Use higher reasoning effort
897
+ kodax --effort high "Review this architecture"
898
+ ```
899
+
900
+ ### Session Workflows
901
+
902
+ Use a session when you want memory across turns. Without a session, each CLI call is independent.
903
+
904
+ ```bash
905
+ # No memory: two separate calls
906
+ kodax "Read src/auth.ts"
907
+ kodax "Summarize it"
908
+
909
+ # With memory: same session
910
+ kodax --session my-project "Read package.json"
911
+ kodax --session my-project "Summarize it"
912
+ kodax --session my-project "How should I fix the first issue?"
913
+
914
+ # Session management
915
+ kodax -r # Search, page, and select a non-empty session
916
+ kodax -r <session-id> # Resume a known session directly
917
+ kodax -r "Review runtime" # Resume a unique exact title; duplicates open the picker
918
+ kodax --session list # List up to 50 non-empty sessions
919
+ kodax --session cleanup-acp # Preview strictly matched empty ACP-test pollution
920
+ ```
921
+
922
+ Bare `-r` opens an interactive picker with incremental search, arrow/PageUp/PageDown
923
+ navigation, Tab completion, full selected-session ID display, and Enter-to-resume.
924
+ An explicit value checks the complete session ID first, then an exact
925
+ case-insensitive title; duplicate titles open a narrowed picker instead of
926
+ silently choosing one. The picker loads before the full CLI, so session listing
927
+ remains responsive. After selection it hands terminal input to the resumed
928
+ REPL; Esc releases the picker's stdin ownership and immediately returns to the
929
+ invoking shell. Session replay preserves each recorded message/event timestamp.
930
+
931
+ Cleanup is preview-only unless
932
+ `--apply-session-cleanup` is also provided; matching sessions are archived rather
933
+ than permanently deleted.
934
+
935
+ ### Session Patterns
936
+
937
+ ```bash
938
+ # ❌ No memory: two independent calls
939
+ kodax "Read src/auth.ts" # Agent reads and responds
940
+ kodax "Summarize it" # Agent doesn't know what to summarize
941
+
942
+ # ✅ With memory: same session
943
+ kodax --session auth-review "Read src/auth.ts"
944
+ kodax --session auth-review "Summarize it" # Agent knows to summarize auth.ts
945
+ kodax --session auth-review "How to fix first issue" # Agent has context
946
+ ```
947
+
948
+ ### Workflow Examples
949
+
950
+ ```bash
951
+ # Code review (multi-turn conversation)
952
+ kodax --session review "Review src/ directory"
953
+ kodax --session review "Focus on security issues"
954
+ kodax --session review "Give me fix suggestions"
955
+
956
+ # Project development (continuous session)
957
+ kodax --session todo-app "Create a Todo application"
958
+ kodax --session todo-app "Add delete functionality"
959
+ kodax --session todo-app "Write tests"
960
+ ```
961
+
962
+ ### CLI Reference
963
+
964
+ ```text
965
+ kodax Start the interactive REPL
966
+ -h, --help [topic] Show help or topic help
967
+ -p, --print <text> Run a single task and exit
968
+ -c, --continue Continue the most recent non-empty conversation in this directory
969
+ -r, --resume [value] Resume by ID/exact title, or open the searchable picker
970
+ -m, --provider Provider to use
971
+ --model <name> Override the model
972
+ --reasoning <mode> off | auto | quick | balanced | deep
973
+ -t, --thinking Compatibility alias for --reasoning auto
974
+ -s, --session <op> Session ID or legacy session operation
975
+ -j, --parallel Enable parallel tool execution
976
+ --max-iter <n> Max iterations
977
+ ```
978
+
979
+ ### Permission Control
980
+
981
+ KodaX provides 3 permission modes for fine-grained control:
982
+
983
+ | Mode | Description | Tools Need Confirmation |
984
+ |------|-------------|------------------------|
985
+ | `plan` | Read-only planning mode | All modification tools blocked |
986
+ | `accept-edits` | Auto-accept file edits | bash only |
987
+ | `auto` | Runtime-owned LLM/rules classification within the project boundary | Only explicit classifier escalation |
988
+
989
+ ```bash
990
+ # In REPL, use /mode command
991
+ /mode plan # Switch to plan mode (read-only)
992
+ /mode accept-edits # Switch to accept-edits mode
993
+ /mode auto # Switch to Runtime-owned Auto Mode
994
+ /auto # Alias for auto
995
+
996
+ # Check current mode
997
+ /mode
998
+ ```
999
+
1000
+ **Features:**
1001
+ - In `accept-edits` mode, choosing "always" can persist safe Bash allow-patterns
1002
+ - Plan mode includes system prompt context for LLM awareness
1003
+ - Permanent protection zones: `.kodax/`, `~/.kodax/`, paths outside project
1004
+ - Pattern-based permission: Allow specific Bash commands (e.g., `Bash(npm install)`)
1005
+ - Unified diff display for write/edit operations
1006
+ - Auto Mode runs guardrail classification before the permission UI; a safe
1007
+ allow verdict does not create a pending approval request. The session records
1008
+ an automatic LLM-to-rules fallback for later turns.
1009
+ - Shift-Tab cycles `Plan -> Edits -> Auto`; Shift+Enter inserts a newline. Auto
1010
+ immediately displays `Auto[LLM]` or `Auto[RULES]`, and rapid mode changes are
1011
+ persisted in input order. `Auto[RULES]` is a valid sticky fallback/manual
1012
+ state; use `/auto-engine llm` to opt back into LLM classification.
1013
+ - Runtime-backed prompts can offer exact `allow once`, `allow this session`,
1014
+ and `always allow` choices. Return the Runtime-issued opaque suggestion;
1015
+ never derive or widen a permission rule from the displayed command or path.
1016
+ Persistent grants are daemon-owned, revisioned, and can be listed/revoked
1017
+ through `runtime.permissions` by an authorized SDK host. Dynamic shell
1018
+ commands deliberately receive no persistent-grant suggestion.
1019
+
1020
+ `kodax -c` skips zero-message ACP/bootstrap placeholders even when they are
1021
+ newer than the last real conversation. The same newest non-empty rule applies
1022
+ to Ink, classic, one-shot CLI, and coding-runtime auto-resume; an explicit
1023
+ session ID always wins. Interactive resume also restores the saved workspace
1024
+ runtime before relative shell commands or the next model turn.
1025
+
1026
+ ### CLI Help Topics
1027
+
1028
+ Get detailed help for specific topics:
1029
+
1030
+ ```bash
1031
+ # Basic help
1032
+ kodax -h
1033
+ kodax --help
1034
+
1035
+ # Detailed topic help
1036
+ kodax -h sessions # Session management details
1037
+ kodax -h init # Long-running project initialization
1038
+ kodax -h project # Project mode / harness workflow
1039
+ kodax -h auto # Auto-continue mode
1040
+ kodax -h provider # LLM provider configuration
1041
+ kodax -h thinking # Thinking/reasoning effort and compatibility modes
1042
+ kodax -h team # Multi-agent parallel execution
1043
+ kodax -h print # Print configuration
1044
+ ```
1045
+
1046
+ ### Environment Variables
1047
+
1048
+ KodaX recognizes a number of environment variables for tuning runtime behavior. The most commonly used ones are listed below; for the full list, search the repo for `process.env.KODAX_`.
1049
+
1050
+ #### `KODAX_MAX_OUTPUT_TOKENS`
1051
+
1052
+ Overrides the per-turn `max_tokens` value sent to **every** provider (Anthropic, OpenAI, Zhipu, Kimi, MiniMax, Qwen, DeepSeek, MiMo, Gemini, Codex, …). Set to a positive integer; unset or non-numeric values are ignored. This is an **explicit user intent**: when set, it wins over the provider's model descriptor cap, over the provider config default, and over the global `KODAX_MAX_TOKENS` fallback. RST defense is handled at the provider config layer (`streamMaxDurationMs` watchdog + non-streaming fallback in `packages/llm/src/providers/registry.ts`), so this variable is purely an output-budget knob.
1053
+
1054
+ ```bash
1055
+ # Allow up to 48K output tokens per turn (use a higher cap when generating long files)
1056
+ export KODAX_MAX_OUTPUT_TOKENS=48000
1057
+ kodax "generate the full implementation"
1058
+
1059
+ # Unset to restore default behavior
1060
+ unset KODAX_MAX_OUTPUT_TOKENS
1061
+ ```
1062
+
1063
+ Precedence used by every provider's `getEffectiveMaxOutputTokens()` (see `packages/llm/src/providers/base.ts`):
1064
+
1065
+ 1. One-shot per-request override (agent-loop escalation / context-overflow recovery — internal)
1066
+ 2. **`KODAX_MAX_OUTPUT_TOKENS`** (this variable, explicit user intent)
1067
+ 3. Active model descriptor's `maxOutputTokens` (FEATURE_098 per-model cap)
1068
+ 4. Provider config default
1069
+ 5. Global `KODAX_MAX_TOKENS` fallback
1070
+
1071
+ Related variables: `KODAX_MAX_TOKENS` (global fallback when no provider/model cap applies), `KODAX_ESCALATED_MAX_OUTPUT_TOKENS` (escalation budget used by the agent loop when a turn returns `stop_reason: max_tokens`).
1072
+
1073
+ > **Retired in v0.7.42**: `KODAX_RST_PRONE_PROVIDERS` and `KODAX_WRITE_TURN_MAX_TOKENS` (the v0.7.28 P2b write-turn cap mechanism) are no longer recognized. The 2026-04 bench measured RST as time-based (zhipu-coding 308s server kill window), not payload-size-based, so the cap was retired in favor of the per-provider `streamMaxDurationMs` watchdog + non-streaming fallback chain (configured in `registry.ts`). Existing env exports become silent no-ops; remove them from shell profiles when convenient.
1074
+
1075
+ #### Sidecar verifier diagnostics
1076
+
1077
+ Use these when diagnosing Worker text-only completion stalls or custom provider verifier behavior:
1078
+
1079
+ ```bash
1080
+ export KODAX_VERIFIER_LOG=1
1081
+ export KODAX_VERIFIER_PROVIDER=anthropic
1082
+ export KODAX_VERIFIER_MODEL=claude-haiku-4-5-20251001
1083
+ ```
1084
+
1085
+ - `KODAX_VERIFIER_LOG=1` shows verifier gate/elapsed/trace information and is equivalent to `"verifierLog": true` in `~/.kodax/config.json`.
1086
+ - `KODAX_VERIFIER_PROVIDER` + `KODAX_VERIFIER_MODEL` route the verifier to a separate provider/model instead of inheriting the main Worker model. Set both together.
1087
+ - `KODAX_VERIFIER_ALWAYS=1` forces the verifier to fire on every text-only completion for debugging/regression sweeps.
1088
+
1089
+ SDK/headless hosts can observe actionable Sidecar Verifier messages via
1090
+ `KodaXEvents.onSidecarMessage`; JSONL output emits the same payload as
1091
+ `sidecar.message`. Only `revise` and `blocked` verdicts are surfaced; `accept`
1092
+ stays silent.
1093
+
1094
+ ## Advanced Library Usage
1095
+
1096
+ #### Simple Mode (runKodaX)
1097
+
1098
+ ```typescript
1099
+ import { runKodaX, KodaXEvents } from '@kodax-ai/kodax';
1100
+
1101
+ const events: KodaXEvents = {
1102
+ onTextDelta: (text) => process.stdout.write(text),
1103
+ onThinkingDelta: (text) => console.log(`Thinking delta: ${text.length} chars`),
1104
+ onToolResult: (result) => console.log(`Tool ${result.name}: ${result.content.slice(0, 100)}`),
1105
+ onSidecarMessage: (event) => console.log(`[sidecar:${event.verdict}] ${event.content}`),
1106
+ onComplete: () => console.log('\nDone!'),
1107
+ onError: (e) => console.error(e.message),
1108
+ };
1109
+
1110
+ const result = await runKodaX({
1111
+ provider: 'zhipu-coding',
1112
+ effort: 'auto',
1113
+ events,
1114
+ }, 'What is 1+1?');
1115
+
1116
+ console.log(result.lastText);
1117
+ ```
1118
+
1119
+ #### Continuous Session (KodaXClient)
1120
+
1121
+ ```typescript
1122
+ import { KodaXClient } from '@kodax-ai/kodax';
1123
+
1124
+ const client = new KodaXClient({
1125
+ provider: 'zhipu-coding',
1126
+ effort: 'auto',
1127
+ events: {
1128
+ onTextDelta: (t) => process.stdout.write(t),
1129
+ },
1130
+ });
1131
+
1132
+ // First message
1133
+ await client.send('Read package.json');
1134
+
1135
+ // Continue same session
1136
+ await client.send('Summarize it');
1137
+
1138
+ console.log(client.getSessionId());
1139
+ ```
1140
+
1141
+ #### Custom Session Storage
1142
+
1143
+ ```typescript
1144
+ import { runKodaX, KodaXSessionStorage, KodaXMessage } from '@kodax-ai/kodax';
1145
+
1146
+ class MyDatabaseStorage implements KodaXSessionStorage {
1147
+ async save(id: string, data: { messages: KodaXMessage[]; title: string; gitRoot: string }) {
1148
+ // Save to your database
1149
+ }
1150
+ async load(id: string) {
1151
+ // Load from your database
1152
+ return null;
1153
+ }
1154
+ }
1155
+
1156
+ await runKodaX({
1157
+ provider: 'zhipu-coding',
1158
+ session: {
1159
+ id: 'my-session-123',
1160
+ storage: new MyDatabaseStorage(),
1161
+ },
1162
+ events: { ... },
1163
+ }, 'task');
1164
+ ```
1165
+
1166
+ ### Library Modes Comparison
1167
+
1168
+ | Feature | runKodaX | KodaXClient |
1169
+ |---------|----------|-------------|
1170
+ | **Message Memory** | ❌ No | ✅ Yes |
1171
+ | **Call Style** | Function | Class instance |
1172
+ | **Context** | Independent each time | Accumulates |
1173
+ | **Use Case** | Single tasks, batch processing | Interactive dialogue, multi-step tasks |
1174
+
1175
+ ---
1176
+
1177
+ ## SDK Usage
1178
+
1179
+ KodaX ships as a single npm package `@kodax-ai/kodax` with 11 SDK subpath exports (ADR-024 v0.7.39 + ADR-032 v0.7.42 + ADR-038 v0.7.49 + v0.7.56 `/media` + v0.7.64 `/runtime` + v0.7.68 `/experimental-memory` + v0.7.69 `/a2a`). Each subpath is tree-shake-friendly so consumers pull only what they need:
1180
+
1181
+ ```bash
1182
+ npm install @kodax-ai/kodax
1183
+ ```
1184
+
1185
+ ```typescript
1186
+ import { runKodaX } from '@kodax-ai/kodax'; // root: CLI helpers + runKodaX
1187
+ import { Runner, runFanOut } from '@kodax-ai/kodax/agent'; // generic Agent framework
1188
+ import { getProvider } from '@kodax-ai/kodax/llm'; // 16-alias LLM abstraction
1189
+ import { KODAX_TOOLS } from '@kodax-ai/kodax/coding'; // tools + prompts + agent loop
1190
+ import { createImageArtifactFromPath } from '@kodax-ai/kodax/media'; // input artifact helpers
1191
+ import { runInkInteractiveMode } from '@kodax-ai/kodax/repl'; // Ink TUI entrypoint
1192
+ import { SkillRegistry } from '@kodax-ai/kodax/skills'; // zero-dep skill loader
1193
+ import { createMcpManager } from '@kodax-ai/kodax/mcp'; // MCP popout manager (v0.7.42)
1194
+ import { listSessions } from '@kodax-ai/kodax/session'; // session history helpers
1195
+ import { createKodaXRuntime } from '@kodax-ai/kodax/runtime'; // embedded/daemon runtime API
1196
+ import { createKodaXA2AServer } from '@kodax-ai/kodax/a2a'; // A2A 1.0 client/server edge
1197
+ import { createMemoryAgent } from '@kodax-ai/kodax/experimental-memory'; // opt-in experimental memory SDK
1198
+ ```
1199
+
1200
+ > The SDK is **ESM-only**. CommonJS consumers (Electron main / Webpack CJS / `require()` callers) must use `await import('@kodax-ai/kodax/...')` — see [docs/SDK_EMBEDDER_GUIDE.md §5](docs/SDK_EMBEDDER_GUIDE.md#5-consuming-from-a-commonjs-context-electron-main-cjs-bundles).
1201
+
1202
+ ### `@kodax-ai/kodax/llm` — LLM Abstraction
1203
+
1204
+ 16 built-in provider aliases (Anthropic, OpenAI, DeepSeek, Kimi, Kimi-Code, Qwen, Qwen-Token-Plan, Zhipu, Zhipu-Coding, Zai-Coding, MiniMax-Coding, MiMo, MiMo-Coding, Ark-Coding, Gemini-CLI, Codex-CLI) + custom provider registration.
1205
+
1206
+ ```typescript
1207
+ import { getProvider, KodaXBaseProvider } from '@kodax-ai/kodax/llm';
1208
+
1209
+ const provider = getProvider('anthropic');
1210
+ const stream = await provider.streamCompletion(
1211
+ [{ role: 'user', content: 'Hello!' }],
1212
+ { onTextDelta: (text) => process.stdout.write(text) }
1213
+ );
1214
+
1215
+ for await (const result of stream) {
1216
+ if (result.type === 'text') { /* … */ }
1217
+ else if (result.type === 'tool_use') { /* … */ }
1218
+ }
1219
+ ```
1220
+
1221
+ **Key Features**: unified provider interface · streaming · reasoning effort (`off/auto/low/medium/high` plus model-supported extras) · per-provider retry + error handling · zero business-logic dependencies.
1222
+
1223
+ ### `@kodax-ai/kodax/agent` — Agent Framework (standalone-consumable)
1224
+
1225
+ ADR-021 standalone-consumable: `@kodax-ai/agent` has **zero inbound `@kodax-ai/coding` dependency** — you can wire any tool surface on top of it.
1226
+
1227
+ ```typescript
1228
+ import {
1229
+ Runner,
1230
+ runFanOut,
1231
+ runWithIdleYield,
1232
+ createAgentActorController,
1233
+ generateSessionId,
1234
+ estimateTokens,
1235
+ DefaultSummaryCompaction,
1236
+ } from '@kodax-ai/kodax/agent';
1237
+
1238
+ // Bounded-concurrency fan-out with abort + structured progress events (v0.7.39 FEATURE_120)
1239
+ const result = await runFanOut({
1240
+ bundles: [{ id: 'a', task: 'audit-foo' }, { id: 'b', task: 'audit-bar' }],
1241
+ maxParallel: 4,
1242
+ run: async (bundle) => doWork(bundle),
1243
+ });
1244
+
1245
+ // Runtime-owned Actor identity tree (inject an executor before starting Turns)
1246
+ const actors = await createAgentActorController();
1247
+ const tree = actors.list('/root');
1248
+
1249
+ // Pluggable compaction policy (FEATURE_081)
1250
+ const policy = new DefaultSummaryCompaction({ thresholdRatio: 0.8, keepRecent: 10 });
1251
+ ```
1252
+
1253
+ `DefaultSummaryCompaction` is a standalone agent-layer primitive for custom
1254
+ loops. It does not replace or disable KodaX's always-on coding-runtime policy
1255
+ described under FEATURE_272 above.
1256
+
1257
+ **Key Features**: `Runner` + per-step lifecycle · `runFanOut` (bounded-concurrency + abort + progress events) · `runWithIdleYield` (chat-while-waiting) · `AgentActorController` / `AgentTurnScheduler` · session-id generation · tiktoken-based token estimation · `CompactionPolicy` interface.
1258
+
1259
+ ### `@kodax-ai/kodax/skills` — Skills System
1260
+
1261
+ Zero external dependencies. Markdown-based skill files with natural-language triggers and variable resolution.
1262
+
1263
+ ```typescript
1264
+ import {
1265
+ SkillRegistry,
1266
+ discoverSkills,
1267
+ executeSkill,
1268
+ type SkillContext,
1269
+ } from '@kodax-ai/kodax/skills';
1270
+
1271
+ const skills = await discoverSkills(['/path/to/skills']);
1272
+ const registry = new SkillRegistry();
1273
+ await registry.registerSkills(skills);
1274
+
1275
+ const result = await executeSkill({
1276
+ skillId: 'code-review',
1277
+ arguments: { target: 'src/' },
1278
+ workingDirectory: process.cwd(),
1279
+ });
1280
+ ```
1281
+
1282
+ **Key Features**: zero deps · markdown-based skill files · natural-language triggering · variable resolution · built-in skills included.
1283
+
1284
+ ### `@kodax-ai/kodax/coding` — Coding Agent
1285
+
1286
+ Complete coding agent: 50+ tools (`read`/`write`/`edit`/`bash`/`grep`/`glob` plus `spawn_agent`/`send_message`/`followup_task`/`wait_agent`/`interrupt_agent`/`list_agents`/`agent_output`) + Worker role prompt + Sidecar Verifier (out-of-band Stop-hook) + agent loop + auto-continue + session management.
1287
+
1288
+ ```typescript
1289
+ import { runKodaX, KodaXClient, KODAX_TOOLS } from '@kodax-ai/kodax/coding';
1290
+
1291
+ // Single-task helper
1292
+ const result = await runKodaX({
1293
+ provider: 'zhipu-coding',
1294
+ effort: 'auto',
1295
+ events: { onTextDelta: (text) => process.stdout.write(text) },
1296
+ }, 'Read package.json and explain the dependencies');
1297
+
1298
+ // Continuous session
1299
+ const client = new KodaXClient({
1300
+ provider: 'anthropic',
1301
+ effort: 'auto',
1302
+ events: { /* … */ },
1303
+ });
1304
+ await client.send('Create a new file');
1305
+ await client.send('Add a function to it'); // Has context from previous message
1306
+ ```
1307
+
1308
+ **Key Features**: 50+ built-in tools (see [Tools](#tools)) · V2 Worker single-loop + Sidecar Verifier (FEATURE_184 v0.7.42 / V1 chain fully retired by FEATURE_193 v0.7.43) · Runtime-owned Actor collaboration and safe-boundary steering (FEATURE_270, v0.7.72) · idle-yield waiting · specialist routing via `spawn_agent(agent_id=...)` · auto-continue · session lineage.
1309
+
1310
+ ### `@kodax-ai/kodax/repl` — Interactive Terminal UI
1311
+
1312
+ Ink/React-based interactive REPL. Permission modes, command system, themed streaming display.
1313
+
1314
+ ```typescript
1315
+ import { runInkInteractiveMode } from '@kodax-ai/kodax/repl';
1316
+
1317
+ // Usually used via the `kodax` bin command; can be embedded:
1318
+ // - Interactive terminal UI (Ink components)
1319
+ // - Permission control (auto/plan/accept-edits modes)
1320
+ // - Command system (/help, /mode, /clear, /status, …)
1321
+ // - Skills integration
1322
+ // - Theme support
1323
+ await runInkInteractiveMode({ provider: 'zhipu-coding', effort: 'auto' });
1324
+ ```
1325
+
1326
+ **Key Features**: Ink-based React components · 3 permission modes (auto / plan / accept-edits) · built-in commands · real-time streaming display · context-usage indicator.
1327
+
1328
+ ### Package Dependency Graph (workspace internal)
1329
+
1330
+ ```
1331
+ @kodax-ai/llm (zero business-logic deps)
1332
+ ↓
1333
+ @kodax-ai/agent (depends @kodax-ai/llm; ADR-021 standalone-consumable;
1334
+ inlines session-lineage + capabilities/{mcp,skills} +
1335
+ tracing per ADR-036 v0.7.43)
1336
+ ↓
1337
+ @kodax-ai/coding (depends llm + agent; inlines repo-intelligence/protocol per ADR-036)
1338
+ ↓
1339
+ @kodax-ai/repl (depends coding + ink + react)
1340
+ ```
1341
+
1342
+ **Subpath Recommendations**:
1343
+
1344
+ | Use Case | Subpath | Why |
1345
+ |----------|---------|-----|
1346
+ | Only need LLM abstraction | `@kodax-ai/kodax/llm` | Minimal deps; 16 built-in aliases |
1347
+ | Building custom agent | `@kodax-ai/kodax/agent` | Runner + fan-out + idle-yield + session-lineage + capabilities |
1348
+ | Coding tasks | `@kodax-ai/kodax/coding` | Complete coding agent + tools |
1349
+ | Terminal app | `@kodax-ai/kodax/repl` | Full interactive experience |
1350
+ | Runtime host / daemon client | `@kodax-ai/kodax/runtime` | Sessions, runs, events, permissions, catalog, MCP, artifacts, diagnostics |
1351
+ | Experimental governed memory | `@kodax-ai/kodax/experimental-memory` | Scoped `MemoryAgent` / `MemorySession` recall and outcome contracts |
1352
+
1353
+ ---
1354
+
1355
+ | Provider | Environment Variable | Reasoning Support | Default Model |
1356
+ |----------|----------------------|-------------------|---------------|
1357
+ | anthropic | `ANTHROPIC_API_KEY` | Native | claude-sonnet-4-6 (`claude-opus-4-6` / `claude-haiku-4-5` via `/model`) |
1358
+ | openai | `OPENAI_API_KEY` | Native | gpt-5.3-codex (`gpt-5.4` / `gpt-5.3-codex-spark` via `/model`) |
1359
+ | kimi | `KIMI_API_KEY` | Native | kimi-k2.7-code (262,144-token context; `kimi-k3` 1M / `kimi-k2.7-code-highspeed` / `kimi-k2.6` / `kimi-k2.5` via `/model`) |
1360
+ | kimi-code | `KIMI_CODE_API_KEY` | Native | k3-256k (Moderato+, 256K, direct upstream ID; `k3` 1M / `kimi-for-coding` K2.7 Code / `kimi-for-coding-highspeed` via `/model`) |
1361
+ | qwen | `QWEN_API_KEY` | Native | qwen3.5-plus |
1362
+ | qwen-token-plan | `QWEN_TOKEN_API_KEY` | Native | qwen3.8-max-preview (Anthropic-compat; `qwen3.7-max` / `qwen3.7-plus` / `qwen3.6-flash` / `glm-5.2` / `deepseek-v4-pro` via `/model`; all 1M context; image input on Qwen 3.8 / 3.7 Plus / 3.6 Flash) |
1363
+ | zhipu | `ZHIPU_API_KEY` | Native | glm-5 (`glm-5.2` 1M ctx / `glm-5.1` / `glm-5-turbo` via `/model`) |
1364
+ | zhipu-coding | `ZHIPU_CODING_API_KEY` | Native | glm-5.2 (1M ctx; legacy `glm-5.1` and `glm-5-turbo` remain selectable via `/model`) |
1365
+ | zai-coding | `ZAI_CODING_API_KEY` | Native | glm-5.2 (Zhipu Coding Plan overseas mirror via `api.z.ai`, Anthropic-compat — same model lineup as `zhipu-coding`, served from outside CN) |
1366
+ | minimax-coding | `MINIMAX_CODING_API_KEY` | Native | MiniMax-M3 (Frontier Coding, native multimodal + 1M ctx; legacy `MiniMax-M2.7` / `MiniMax-M2.7-highspeed` remain selectable via `/model`) |
1367
+ | mimo | `MIMO_API_KEY` | Native | mimo-v2.5-pro (Xiaomi MiMo pay-per-token, Anthropic-compat) |
1368
+ | mimo-coding | `MIMO_CODING_API_KEY` | Native | mimo-v2.5-pro (Xiaomi Token Plan, Anthropic-compat) |
1369
+ | ark-coding | `ARK_CODING_API_KEY` | Native | glm-5.2 (Volcengine Ark Coding Plan — GLM-5.2 (alias: `glm-latest`) · Kimi K2.7 Code / K2.6 · MiniMax M3 / M2.7 · DeepSeek V4 Pro / V4 Flash · Doubao Seed 2.0 Code / Pro / Lite · Doubao Seed Code) |
1370
+ | deepseek | `DEEPSEEK_API_KEY` | Native | deepseek-v4-flash (`deepseek-v4-pro` via `/model`) |
1371
+ | gemini-cli | `GEMINI_API_KEY` | Prompt-only / CLI bridge | (via gemini CLI) |
1372
+ | codex-cli | `OPENAI_API_KEY` | Prompt-only / CLI bridge | (via codex CLI) |
1373
+
1374
+ > **Custom providers**: any OpenAI- or Anthropic-compatible endpoint can be added via `customProviders[]` in `~/.kodax/config.json` (CLI) or `registerCustomProviders()` (library). See the [Quick Start](#2-configure-a-provider) for the configuration shape.
1375
+
1376
+ ### Examples
1377
+
1378
+ ```bash
1379
+ # Use Zhipu Coding
1380
+ kodax --provider zhipu-coding --thinking "Help me optimize this code"
1381
+
1382
+ # Use OpenAI
1383
+ export OPENAI_API_KEY=your_key
1384
+ kodax --provider openai "Create a REST API"
1385
+
1386
+ # Resume last session
1387
+ kodax --session resume
1388
+
1389
+ # List all sessions
1390
+ kodax --session list
1391
+
1392
+ # Parallel tool execution
1393
+ kodax --parallel "Read package.json and tsconfig.json"
1394
+
1395
+ # Adaptive multi-agent (AMA) mode — V2 Worker single-loop with Actor collaboration
1396
+ kodax --agent-mode ama "Analyze code structure, check test coverage, find bugs"
1397
+ ```
1398
+
1399
+ ---
1400
+
1401
+ ## Tools
1402
+
1403
+ KodaX ships 50+ built-in tools, grouped below. They are registered as a single flat tool surface to the LLM; the categories here are just for navigation.
1404
+
1405
+ ### File operations
1406
+ | Tool | Description |
1407
+ |------|-------------|
1408
+ | `read` | Read file contents (supports offset/limit) |
1409
+ | `write` | Write a new file or fully rewrite an existing one |
1410
+ | `edit` | Exact string replacement (supports `replace_all`) |
1411
+ | `multi_edit` | Atomic batch of independent edits to one file |
1412
+ | `insert_after_anchor` | Insert content after a unique anchor without rewriting the file |
1413
+ | `undo` | Revert the last file modification |
1414
+
1415
+ ### Shell & search
1416
+ | Tool | Description |
1417
+ |------|-------------|
1418
+ | `bash` | Execute a shell command (supports `run_in_background`; complete capture with recoverable capacity fallback) |
1419
+ | `glob` | Find files by pattern |
1420
+ | `grep` | Regex content search (context lines, multiline, file-type filter, pagination) |
1421
+ | `code_search` | Lower-noise code search (extension-provider aware) |
1422
+ | `semantic_lookup` | Symbol/module/process-aware search backed by repo intelligence |
1423
+ | `web_search` | Discovery-oriented web search with trust + freshness signals |
1424
+ | `web_fetch` | Fetch a specific URL with provenance hints |
1425
+
1426
+ ### Repo Intelligence (working tools)
1427
+ | Tool | Description |
1428
+ |------|-------------|
1429
+ | `repo_overview` | Summarize structure, key areas, entry hints, intelligence snapshot |
1430
+ | `changed_scope` | Which files/areas/categories the current diff touches |
1431
+ | `changed_diff` | Paged diff slice for a single file |
1432
+ | `changed_diff_bundle` | Paged diff slices for multiple files in one call |
1433
+ | `module_context` | Module capsule (deps, entries, symbols, tests, docs) |
1434
+ | `symbol_context` | Definition + probable callers/callees + alternatives |
1435
+ | `process_context` | Approximate static execution capsule for an entry |
1436
+ | `impact_estimate` | Blast radius for a symbol/path/module |
1437
+
1438
+ ### MCP capabilities (when MCP servers are configured)
1439
+ | Tool | Description |
1440
+ |------|-------------|
1441
+ | `mcp_search` / `mcp_describe` / `mcp_call` | Discover and invoke MCP tools through the shared capability runtime |
1442
+ | `mcp_read_resource` / `mcp_get_prompt` | Read MCP resources and prompts |
1443
+
1444
+ ### Git worktree
1445
+ | Tool | Description |
1446
+ |------|-------------|
1447
+ | `worktree_create` | Create a new worktree on an isolated branch for safe agent work |
1448
+ | `worktree_remove` | Remove a worktree (with safety checks) |
1449
+
1450
+ ### Agent control & UX
1451
+ | Tool | Description |
1452
+ |------|-------------|
1453
+ | `spawn_agent` | Create a named child Actor and start its first Turn under inherited capabilities, session capacity, and root work budget. |
1454
+ | `send_message` | Commit bounded information to an Actor mailbox without starting a new Turn. |
1455
+ | `followup_task` | Join a running Actor at a safe boundary or atomically start a new Turn for an idle Actor. |
1456
+ | `wait_agent` | Yield on scoped mailbox/user/interruption/timeout activity; returns a wake acknowledgement and never uses Actor progress as a model wake source. |
1457
+ | `interrupt_agent` | Request interruption of an active Turn while preserving Actor identity. |
1458
+ | `list_agents` | Inspect the caller-visible Actor subtree and Turn states. |
1459
+ | `agent_output` | Read bounded durable output for an authorized Actor/Turn. |
1460
+ | `ask_user_question` | Single/multi-select or free-text prompt back to the user |
1461
+ | `exit_plan_mode` | Present a finalized plan only when the active REPL/host supplied an approval callback |
1462
+ | `run_workflow` | Author and run a deterministic Workflow protocol in AMA only when Workflow intent is explicit; complexity alone never activates it. Child Agents share the Actor control plane. Async / idle-yield. (FEATURE_246; FEATURE_270 v0.7.72) |
1463
+ | `emit_managed_protocol` | Internal managed-task protocol side-channel for role payloads (verdict). V2 Worker single-loop + Sidecar Verifier is the default since v0.7.42 (FEATURE_184); V1 chain retired in v0.7.43 (FEATURE_193). |
1464
+
1465
+ ---
1466
+
1467
+ ## Skills System
1468
+
1469
+ KodaX includes a built-in Skills system that can be triggered by natural language:
1470
+
1471
+ ```bash
1472
+ # Natural language triggering (no explicit /skill needed)
1473
+ kodax "帮我审查代码" # Triggers code-review skill
1474
+ kodax "写测试用例" # Triggers tdd skill
1475
+ kodax "提交代码" # Triggers git-workflow skill
1476
+
1477
+ # Explicit skill command
1478
+ kodax /skill:code-review
1479
+ ```
1480
+
1481
+ Built-in skills include:
1482
+ - **code-review** - Code review and quality analysis
1483
+ - **tdd** - Test-driven development workflow
1484
+ - **git-workflow** - Git commit and workflow automation
1485
+
1486
+ Skills are stored in `~/.kodax/skills/` and can be extended with custom skills.
1487
+
1488
+ ---
1489
+
1490
+ ## Commands (CLI)
1491
+
1492
+ Commands are `/xxx` shortcuts in CLI:
1493
+
1494
+ ```bash
1495
+ kodax /review src/auth.ts
1496
+ kodax /test
1497
+ ```
1498
+
1499
+ Commands are stored in `~/.kodax/commands/`:
1500
+ - `.md` files → Prompt commands (content used as prompt)
1501
+ - `.ts/.js` files → Programmable commands
1502
+
1503
+ ---
1504
+
1505
+ ## API Exports
1506
+
1507
+ ```typescript
1508
+ // Main functions
1509
+ export { runKodaX, KodaXClient };
1510
+
1511
+ // Types
1512
+ export type {
1513
+ KodaXEvents, KodaXOptions, KodaXResult,
1514
+ KodaXMessage, KodaXContentBlock,
1515
+ KodaXSessionStorage, KodaXToolDefinition
1516
+ };
1517
+
1518
+ // Tools
1519
+ export { KODAX_TOOLS, KODAX_TOOL_REQUIRED_PARAMS, executeTool };
1520
+
1521
+ // Providers
1522
+ export { getProvider, KODAX_PROVIDERS, KodaXBaseProvider };
1523
+
1524
+ // Utilities
1525
+ export {
1526
+ estimateTokens,
1527
+ getGitRoot, getGitContext, getEnvContext, getProjectSnapshot,
1528
+ checkPromiseSignal
1529
+ };
1530
+ ```
1531
+
1532
+ ---
1533
+
1534
+ ## Development
1535
+
1536
+ ```bash
1537
+ # Development mode (using tsx)
1538
+ npm run dev "your task"
1539
+
1540
+ # Build
1541
+ npm run build
1542
+
1543
+ # Optional: only build workspace packages
1544
+ npm run build:packages
1545
+
1546
+ # Build standalone binary (current platform / all platforms)
1547
+ npm run build:binary
1548
+ npm run build:binary:all
1549
+
1550
+ # Run tests
1551
+ npm test
1552
+
1553
+ # Eval-driven development tests (provider matrices, identity round-trip, etc.)
1554
+ npm run test:eval
1555
+
1556
+ # Clean
1557
+ npm run clean
1558
+ ```
1559
+
1560
+ ### Repo Intelligence cache directories
1561
+
1562
+ KodaX uses one repo-intelligence cache root with separate built-in engine profiles:
1563
+
1564
+ - `.agent/repo-intelligence/`
1565
+ - Full-engine repo-intelligence artifacts and existing task-engine snapshots.
1566
+ - `.agent/repo-intelligence/light/`
1567
+ - Light-mode heuristic index artifacts.
1568
+
1569
+ They are intentionally separated so:
1570
+
1571
+ - full and light profiles can be rebuilt independently.
1572
+ - light-mode confidence/capability state cannot be mistaken for full-engine state.
1573
+ - future cache migrations can delete one profile without corrupting the other.
1574
+
1575
+ `.agent/repo-intelligence/` is local generated state and should not be committed.
1576
+
1577
+ ---
1578
+
1579
+ ## Code Style
1580
+
1581
+ ### Comment Guidelines
1582
+
1583
+ KodaX uses an **English-first** comment style with selective Chinese brief notes for complex logic.
1584
+
1585
+ | Situation | Style | Example |
1586
+ |-----------|-------|---------|
1587
+ | Import/Export | English only | `// Import dependencies` |
1588
+ | Simple constants | English only | `// Max retry count` |
1589
+ | Simple logic | English only | `// Return if null` |
1590
+ | **Business rules** | English + Chinese | `// Skip tool_result - 跳过工具结果块` |
1591
+ | **Platform compatibility** | English + Chinese | `// Windows path handling - Windows 路径处理` |
1592
+ | **Performance optimization** | English + Chinese | `// Debounce to prevent flicker - 防抖避免闪烁` |
1593
+
1594
+ ---
1595
+
1596
+ ## Documentation
1597
+
1598
+ - [README_CN.md](README_CN.md) - Chinese Documentation
1599
+ - [docs/SDK_EMBEDDER_GUIDE.md](docs/SDK_EMBEDDER_GUIDE.md) - SDK hosting, shared Runtime daemon, Auto Mode, v0.7.74 compaction/history recovery, Agent telemetry, and active-run input contracts
1600
+ - [docs/release.md](docs/release.md) - Standalone binary build & release pipeline
1601
+ - [docs/PRD.md](docs/PRD.md) - Product Requirements
1602
+ - [docs/ADR.md](docs/ADR.md) - Architecture Decisions
1603
+ - [docs/HLD.md](docs/HLD.md) - High-Level Design
1604
+ - [docs/DD.md](docs/DD.md) - Detailed Design
1605
+ - [docs/FEATURE_LIST.md](docs/FEATURE_LIST.md) - Feature Tracking
1606
+ - [docs/test-guides/](docs/test-guides/) - Feature-specific test guides
1607
+ - [CHANGELOG.md](CHANGELOG.md) - Version History (v0.7.0+; [archive](docs/CHANGELOG_ARCHIVE.md) for older)
1608
+
1609
+ ---
1610
+
1611
+ ## License
1612
+
1613
+ [KodaX-AI Fair Core License (KAI-FCL) 1.0](LICENSE) - Copyright 2026 [icetomoyo](mailto:icetomoyo@gmail.com).
1614
+
1615
+ KAI-FCL is source-available / fair-core, not OSI open source. Commercial,
1616
+ enterprise, managed deployment, paid service, or customer redistribution use
1617
+ requires KodaX-AI authorization and a valid entitlement where required.
1618
+
1619
+ Official KodaX 0.7.70 and later distributions use KAI-FCL or accompanying
1620
+ KodaX-AI customer terms. Historical tags, archives, binaries, npm packages, or
1621
+ other copies already distributed with Apache-2.0 notices remain Apache-2.0 for
1622
+ those specific copies.