@kodax-ai/kodax 0.7.76 → 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 -380
  2. package/LICENSE +158 -158
  3. package/README.md +1608 -1550
  4. package/README_CN.md +942 -896
  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-PXKSE54E.js → chunk-EH7AOMJ7.js} +1 -1
  31. package/dist/chunks/{chunk-SMT2JSM3.js → chunk-FNW2XUL5.js} +9 -9
  32. package/dist/chunks/chunk-FSXI4MAV.js +78 -0
  33. package/dist/chunks/{chunk-RDXRM3UI.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-4PWPNCNK.js → chunk-JS2BHGJP.js} +2 -2
  37. package/dist/chunks/chunk-OAMKECRG.js +381 -0
  38. package/dist/chunks/{chunk-HS3XHF3R.js → chunk-ON2WG2LG.js} +2 -2
  39. package/dist/chunks/{chunk-HGT6WQ24.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-5F5KF2BZ.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-X3TEH6IO.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 -362
  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-7X5CFET2.js +0 -2
  99. package/dist/chunks/argument-completer-3NHIKB4N.js +0 -2
  100. package/dist/chunks/chunk-7FJNLJLF.js +0 -369
  101. package/dist/chunks/chunk-COQYLD4U.js +0 -5
  102. package/dist/chunks/chunk-D3T24FJW.js +0 -78
  103. package/dist/chunks/chunk-EI4JBQKL.js +0 -46
  104. package/dist/chunks/chunk-IDCGNQ4H.js +0 -5
  105. package/dist/chunks/chunk-KAY2XLCP.js +0 -74
  106. package/dist/chunks/chunk-OD6LVXU6.js +0 -329
  107. package/dist/chunks/chunk-OSF3H4RR.js +0 -22
  108. package/dist/chunks/chunk-TGMBHGZO.js +0 -427
  109. package/dist/chunks/chunk-VWSLC2WO.js +0 -770
  110. package/dist/chunks/chunk-Y3AMP22L.js +0 -37
  111. package/dist/chunks/compaction-config-7J2XE35D.js +0 -2
  112. package/dist/chunks/dist-2RA7LSH3.js +0 -2
  113. package/dist/chunks/dist-URKXBOC6.js +0 -2
  114. package/dist/chunks/host-RKZ2OGFT.js +0 -2
  115. package/dist/chunks/run-manager-7RM4HEH6.js +0 -2
package/README.md CHANGED
@@ -1,1564 +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.
327
-
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.
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.
401
245
 
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
+
402
409
  **v0.7.76 Kimi Code catalog refresh:** `kimi-code` now defaults to the official
403
410
  `k3-256k` Model ID and sends it unchanged. `kimi-for-coding` remains selectable
404
411
  for K2.7 Code, alongside `kimi-for-coding-highspeed` and the 1M `k3` tier. K3
405
412
  supports `low` / `high` / `max` reasoning with `high` as default; the 256K
406
413
  route supports image input but not video input.
407
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).
465
+
408
466
  One daemon owns many sessions. Different sessions may run concurrently; starts
409
467
  within the same session are queued so that only one run is active for that
410
468
  session. Multiple `kodax` processes can attach to the same daemon and open or
411
- observe the same session. FEATURE_269 adds atomic snapshot-plus-stream joining,
412
- durable idempotent mutations, revision-safe settings and grants, transport-safe
413
- AskUser/permission responses, run-scoped credential and Host Tool bridges, and
414
- one daemon/inline Coder owner fence. In-flight external effects are never
415
- blindly replayed after a crash; clients receive explicit interrupted/unknown
416
- terminal facts and resync when `runtimeId` changes.
417
-
418
- Space and IDE hosts should require these capabilities through the Runtime SDK.
419
- Partner remains on its private inline Runtime and must use a distinct product
420
- data/session root. A missing daemon capability is an error, not permission to
421
- silently fall back to inline Coder.
422
-
423
- For the full host-integration contract, including inline/Worker/daemon selection,
424
- multi-client permission handling, config/catalog/MCP admin APIs, artifacts,
425
- context diagnostics, and daemon protocol schemas, see
426
- [docs/SDK_EMBEDDER_GUIDE.md §17](docs/SDK_EMBEDDER_GUIDE.md#17-runtime-sdk-worker-isolation-and-local-daemon-feature_253-feature_257).
427
-
428
- The Space/IDE shared-daemon contract is documented in
429
- [SDK Embedder Guide section 23](docs/SDK_EMBEDDER_GUIDE.md#23-shared-coder-daemon-for-space-and-ide-hosts-feature_269-v0769).
430
-
431
- **v0.7.72–v0.7.73 Runtime permission contract:** Auto Mode is owned by the Runtime session,
432
- not by a UI hook. It reuses its LLM/rules guardrail across turns, classifies
433
- before the shared permission bridge, and persists an automatic fallback to
434
- rules. The same session settings can select a classifier model and bounded
435
- timeout; `auto` defaults to LLM classification and fails with a recoverable
436
- configuration error when no effective classifier model exists, rather than
437
- silently falling back. Runtime permission prompts now offer opaque, exact
438
- allow-once/session/persistent grant suggestions; persistent grants are
439
- daemon-owned and revisioned. Host plan exit is exposed only when the host
440
- 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).
441
-
442
- ## Repo Intelligence
443
-
444
- 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.
445
-
446
- 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.
447
-
448
- ```bash
449
- # Pick a runtime mode (auto | full | light | off)
450
- kodax --repo-intelligence full --repo-intelligence-trace
451
- ```
452
-
453
- ## Architecture
454
-
455
- 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):
456
-
457
- ```
458
- KodaX/
459
- ├── packages/ # 4 workspace packages (FEATURE_194 v0.7.43)
460
- │ ├── llm/ # @kodax-ai/llm - LLM abstraction (16 built-in provider aliases)
461
- │ │ └── providers/ # Anthropic, OpenAI, DeepSeek, Kimi, MiMo, MiniMax, Zhipu, Ark, …
462
- │ │
463
- │ ├── agent/ # @kodax-ai/agent - Generic Agent framework
464
- │ │ ├── actors/ # Runtime-owned Actor tree, scheduler, mailbox, events
465
- │ │ ├── session-lineage/ # branchable session tree (inline v0.7.43)
466
- │ │ ├── capabilities/
467
- │ │ │ ├── mcp/ # MCP integration (inline v0.7.43)
468
- │ │ │ └── skills/ # Skills standard implementation + builtin (inline v0.7.43)
469
- │ │ └── tracing/ # tracing / observability (inline v0.7.43)
470
- │ │
471
- │ ├── coding/ # @kodax-ai/coding - Coding Agent (tools + prompts)
472
- │ │ ├── tools/ # 50+ tools: read, write, edit, bash, glob, grep, undo,
473
- │ │ │ # spawn_agent, send_message, followup_task, wait_agent,
474
- │ │ │ # ask_user_question, repo-intelligence, …
475
- │ │ └── repo-intelligence/ # incl. protocol.ts (inline v0.7.43)
476
- │ │
477
- │ └── repl/ # @kodax-ai/repl - Interactive terminal UI (Ink TUI)
478
-
479
- ├── src/ # CLI entry + SDK subpath entries
480
- │ ├── kodax_cli.ts # Main CLI entry point (bin: `kodax`)
481
- │ └── sdk-*.ts # SDK subpath re-exports → @kodax-ai/kodax/{agent,llm,coding,media,repl,skills,mcp,session,runtime,a2a,experimental-memory}
482
-
483
- └── package.json # Root workspace config; release.mjs rewrites name + injects subpath exports
484
- ```
485
-
486
- ### Package Dependencies
487
-
488
- ```
489
- ┌──────────────────┐
490
- │ kodax (root) │
491
- │ CLI Entry │
492
- └────────┬─────────┘
493
-
494
- ┌──────────────┴──────────────┐
495
- │ │
496
- ▼ ▼
497
- ┌──────────────┐ ┌────────────────┐
498
- │@kodax-ai/repl│ │@kodax-ai/coding│
499
- │ UI Layer │ │ Tools+Prompts │
500
- └──────┬───────┘ └──────┬─────────┘
501
- │ │
502
- │ ┌──────────────┴──────────────┐
503
- │ │ │
504
- ▼ ▼ ▼
505
- ┌──────────────┐ ┌──────────────────────────┐ ┌──────────────┐
506
- │@kodax-ai/ │ │@kodax-ai/agent │ │@kodax-ai/llm │
507
- │coding (via │ │Runner + fan-out + │ │LLM Abstract │
508
- │above) │ │idle-yield + session- │ │(16 aliases) │
509
- │ │ │lineage + skills + mcp + │ │ │
510
- │ │ │tracing (FEATURE_194) │ │ │
511
- └──────────────┘ └──────────────────────────┘ └──────────────┘
512
- ```
513
-
514
- ### Package Overview
515
-
516
- 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.
517
-
518
- | Workspace package | Purpose | Key Dependencies |
519
- |---------|---------|------------------|
520
- | `@kodax-ai/llm` | LLM abstraction (16 built-in provider aliases + custom registration) | @anthropic-ai/sdk, openai |
521
- | `@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 |
522
- | `@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 |
523
- | `@kodax-ai/repl` | Complete interactive terminal UI (Ink/React, permission modes, commands, streaming) | @kodax-ai/coding, ink, react |
524
-
525
- ### Source-side vs npm-published surface
526
-
527
- KodaX has two layers that consumers should understand separately:
528
-
529
- - **Source-side**: 4 workspace packages above (what developers see when reading the repo).
530
- - **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:
531
- - **Full-package subpaths** (`/agent`, `/llm`, `/coding`, `/repl`) — each one maps 1:1 to a source workspace and exposes its complete public API.
532
- - **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`.
533
-
534
- | Source package | npm subpath | Type | What you get | Example consumer |
535
- |---|---|---|---|---|
536
- | `packages/llm` | `@kodax-ai/kodax/llm` | Full package | 16-alias LLM abstraction (108 exports) | Standalone LLM clients |
537
- | `packages/agent` | `@kodax-ai/kodax/agent` | Full package | Runner / fan-out / external-agent plane / session-lineage / capabilities / tracing (331 exports) | Custom agent frameworks |
538
- | `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 |
539
- | `packages/agent` | `@kodax-ai/kodax/mcp` | **Narrow subset** | MCP only — `McpCapabilityProvider` / `createMcpTransport` / `searchMcpCatalog` / ... (23 exports) | MCP server hosts |
540
- | `packages/agent` | `@kodax-ai/kodax/media` | **Narrow subset** | Structured image/file/video input-artifact helpers (22 exports) | Desktop hosts and multimodal clients |
541
- | `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 |
542
- | `packages/coding` | `@kodax-ai/kodax/coding` | Full package | Coding agent + 50+ tools + repo-intelligence (505 exports) | Build a Claude Code-shape product |
543
- | `packages/repl` | `@kodax-ai/kodax/repl` | Full package | Ink TUI + permission modes + commands (217 exports) | Terminal-UI consumers |
544
- | `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 |
545
- | `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 |
546
- | `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 |
547
-
548
- **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.
549
-
550
- **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.
551
-
552
- **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.
553
-
554
- **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).
555
-
556
- **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.
557
-
558
- **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).
559
-
560
- **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).
561
-
562
- **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).
563
-
564
- **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).
565
-
566
- **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).
567
-
568
- **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.
569
-
570
- **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).
571
-
572
- **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).
573
-
574
- **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).
575
-
576
- **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).
577
-
578
- **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).
579
-
580
- **A2A interoperability and authentication hardening** keeps a discovered
581
- interface on the trusted Agent Card origin and sends credentials only when one
582
- complete Card/Skill security requirement is satisfiable. The no-code client
583
- supports HTTP Bearer compatibility and OAuth 2.0 Client Credentials; for OAuth,
584
- an external Authorization Server issues short-lived access tokens and KodaX
585
- caches them only in memory. Inbound `a2a serve` can validate RFC 9068 JWT access
586
- tokens from an external issuer/JWKS, but never signs or issues production
587
- tokens itself. It resolves its provider from CLI, then environment, config, and
588
- the built-in default; a Markdown Agent can pin its own provider. Input
589
- continuation resumes the original Runtime run, task history and retention are
590
- bounded with stable cursor pagination, and authenticated SSE is correlated
591
- before falling back to polling after an early normal EOF. Only direct remote
592
- artifacts, broker-staged outputs, and outputs from a successfully admitted
593
- Skill script can be published; ordinary workspace writes and local paths stay
594
- private.
595
-
596
- This authentication and per-Agent activation hardening is a post-release
597
- closure of the v0.7.69 F267/F268 design and ships in the v0.7.71 patch; it is
598
- not a claim that older v0.7.69 binaries contained the
599
- later OAuth profiles.
600
-
601
- **v0.7.70 MCP discovery hardening** uses exact capability IDs and revisioned
602
- cursors while admitting results against real physical capacity. Compact CJK
603
- queries are segmented, and a cross-language lexical zero match either returns a
604
- lossless bounded grouped inventory or one concise retry in the catalog language.
605
- Partial provider failure remains explicit rather than disappearing into an
606
- apparently complete result.
607
-
608
- The complete built-in path is available without writing TypeScript:
609
-
610
- ```bash
611
- # Call another A2A Agent
612
- kodax a2a add research https://agent.example/.well-known/agent-card.json --effect read
613
- kodax a2a test research
614
- kodax a2a call research "Summarize this topic"
615
-
616
- # Stage an OAuth-protected Agent, then hot-activate/deactivate it
617
- export RESEARCH_A2A_CLIENT_SECRET='provisioned-by-your-authorization-server'
618
- # PowerShell: $env:RESEARCH_A2A_CLIENT_SECRET='provisioned-by-your-authorization-server'
619
- # PowerShell: run the command on one line or replace each trailing \ with a backtick.
620
- kodax a2a add reviewer https://reviewer.example/.well-known/agent-card.json \
621
- --disabled --effect read --oauth-scheme enterprise-oauth \
622
- --oauth-issuer https://identity.example/ \
623
- --oauth-token-url https://identity.example/oauth/token \
624
- --oauth-client-id kodax-reviewer \
625
- --oauth-client-secret-env RESEARCH_A2A_CLIENT_SECRET \
626
- --oauth-scope a2a.invoke --oauth-resource https://reviewer.example/
627
- kodax a2a enable reviewer
628
- kodax a2a disable reviewer # blocks new dispatch; does not cancel in-flight tasks
629
-
630
- # Expose the Runtime default Agent, or pass a name from ~/.kodax/agents/*.md
631
- export KODAX_A2A_TOKEN='replace-with-a-long-random-token'
632
- # PowerShell: $env:KODAX_A2A_TOKEN='replace-with-a-long-random-token'
633
- kodax a2a expose # or: kodax a2a expose document-agent
634
- kodax a2a serve # loopback http://127.0.0.1:8765
635
- ```
636
-
637
- MCP, A2A, and Extension declarations live in one user file per domain under
638
- `~/.kodax/integrations/`. Use `kodax config template <mcp|a2a|extensions>`,
639
- `kodax integrations migrate --apply`, and the `kodax mcp`, `kodax a2a`, or
640
- `kodax extensions` commands to manage them. Migration imports only legacy
641
- `config.json#mcpServers` and `config.json#extensions`; A2A has no legacy source.
642
- It never overwrites an existing destination. The first MCP/Extension mutation
643
- can stage legacy entries. Remove legacy keys only with
644
- `--apply --cleanup-legacy`, after reviewing destination files and
645
- literal-secret warnings. Running
646
- CLI/daemon hosts retain the
647
- last valid revision, atomically replace the complete MCP provider, reconcile
648
- Extensions per entry, and hot-register outbound A2A Agents. Each A2A entry has
649
- a desired `enabled` switch; `kodax a2a list` shows configuration, while the
650
- owning Runtime is authoritative for live applied registrations. Disabled
651
- entries are not fetched during automatic reconciliation and, after the owning
652
- Runtime applies the revision, cannot accept new dispatch. The mutation command
653
- itself is not cross-process acknowledgement. `a2a add --disabled` still checks
654
- the Card by default unless `--no-test` is supplied, while `a2a test` performs
655
- discovery/security planning without requesting an OAuth token. The fixed
656
- `KODAX_A2A_TOKEN` example is an operator-provisioned compatibility credential;
657
- KodaX does not generate or issue it. Disabled entries remain available for
658
- later re-enable. `a2a serve` loads
659
- its configured MCP/Extension capability surface before listening and pins that
660
- execution authority; it hot-reloads publication, authentication, and limits.
661
-
662
- A2A configuration migration and retained task ownership are separate. If a
663
- v0.7.70 task store must remain addressable after the realm-aware upgrade, stop
664
- the A2A server, run `kodax a2a migrate-tasks` to inspect the exact-owner plan,
665
- then apply it with `--apply --confirm-server-stopped`. OAuth migration also
666
- requires the known historical `--subject`; normal serving never guesses or
667
- dual-reads a legacy owner key.
668
-
669
- Agent, Skill, Extension-tool authority, workspace, tool-policy, or task-store
670
- changes require an explicit server restart. Managed
671
- A2A contexts default to `~/kodax_a2a_server_workspace/<runtime-profile>/contexts/`.
672
- Exact Skill scripts require the opt-in isolated policy and a passing
673
- `kodax sandbox doctor` (`kodax sandbox setup` performs the explicit Windows
674
- one-time provisioning).
675
-
676
- ---
677
-
678
- ## Features
679
-
680
- - **Modular Architecture** - Use as CLI, as a library, or as a Node-free single binary
681
- - **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
682
- - **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
683
- - **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=...)`.
684
- - **Reasoning Effort** - Effort-first control (`off/auto/low/medium/high` plus model-supported extras) across providers
685
- - **Streaming Output** - Real-time response display
686
- - **Session Management** - JSONL format with branchable session lineage tree
687
- - **Skills System** - Natural language triggering, extensible, role-projected in AMA
688
- - **Repo Intelligence** - Built-in full/light repository intelligence with native KodaX auto-injection lane
689
- - **Rich Tool Surface** - 50+ built-in tools across file ops, shell, search, repo intelligence, MCP capabilities, git worktree, and agent control
690
- - **Permission Control** - 3 permission modes with pattern-based control
691
- - **Standalone Binary** - `bun --compile` releases for Win/macOS/Linux x64+arm64, no Node.js required on target machines
692
- - **Cross-Platform** - Windows/macOS/Linux
693
- - **TypeScript Native** - Full type safety and IDE support
694
-
695
- ---
696
-
697
- ## Installation
698
-
699
- ### As CLI Tool
700
-
701
- ```bash
702
- # Clone repository
703
- git clone https://github.com/icetomoyo/KodaX.git
704
- cd KodaX
705
-
706
- # Install dependencies (includes workspace packages)
707
- npm install
708
-
709
- # Build the monorepo
710
- npm run build
711
-
712
- # Link globally (development mode)
713
- npm link
714
-
715
- # Now you can use 'kodax' anywhere
716
- kodax "your task"
717
- ```
718
-
719
- ### As Standalone Binary (no Node required on target)
720
-
721
- 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.
722
-
723
- Supported targets: `win-x64`, `linux-x64`, `linux-arm64`, `darwin-x64`, `darwin-arm64`. Win7 / pre-glibc-2.27 distros / LoongArch are not supported.
724
-
725
- **Build locally**:
726
-
727
- ```bash
728
- # Install Bun once on your build machine
729
- npm i -g bun # or scoop/brew/curl install — see docs/release.md
730
-
731
- npm run build:binary # Current host platform (fastest)
732
- npm run build:binary:all # All five targets in sequence
733
- node scripts/build-binary.mjs --target=linux-arm64 # Specific target
734
- ```
735
-
736
- Output lives under `dist/binary/<target>/`:
737
-
738
- ```
739
- dist/binary/linux-x64/
740
- ├── kodax # ~60 MB Bun-compiled executable
741
- ├── builtin/ # Sidecar built-in skills
742
- ├── provider-capabilities.json
743
- ├── semantic-worker.js # Repo-intelligence Worker
744
- ├── runtime-worker.js # SDK Runtime Worker
745
- └── constructed-handler-worker.js # Constructed-tool Worker
746
- ```
747
-
748
- Smoke-test: `dist/binary/<host>/kodax --version`.
749
-
750
- **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.
751
-
752
- 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.
753
-
754
- ### As Library
755
-
756
- ```bash
757
- npm install @kodax-ai/kodax
758
- ```
759
-
760
- ```typescript
761
- import { runKodaX } from '@kodax-ai/kodax';
762
-
763
- process.env.ZHIPU_API_KEY = process.env.ZHIPU_API_KEY ?? 'your_api_key';
764
-
765
- const result = await runKodaX({
766
- provider: 'zhipu-coding',
767
- effort: 'auto',
768
- events: {
769
- onTextDelta: (text) => process.stdout.write(text),
770
- onComplete: () => console.log('\nDone!'),
771
- },
772
- }, 'your task');
773
-
774
- console.log(result.lastText);
775
- ```
776
-
777
- #### SDK Subpath Imports (v0.7.39+)
778
-
779
- For smaller surface and tree-shake-friendly imports, the SDK is also exposed via subpath exports — pick only the package(s) you need:
780
-
781
- ```typescript
782
- import { Runner } from '@kodax-ai/kodax/agent'; // agent runtime
783
- import { getProvider } from '@kodax-ai/kodax/llm'; // LLM abstraction (16 aliases)
784
- import { runKodaX } from '@kodax-ai/kodax/coding'; // coding tools + prompts
785
- import { createImageArtifactFromPath } from '@kodax-ai/kodax/media'; // input artifacts
786
- import { SkillRegistry } from '@kodax-ai/kodax/skills'; // zero-dep skill loader
787
- import { loadConfig } from '@kodax-ai/kodax/repl'; // REPL config / session helpers
788
- import { createMcpManager } from '@kodax-ai/kodax/mcp'; // MCP popout manager (v0.7.42)
789
- import { listSessions } from '@kodax-ai/kodax/session'; // session history helpers
790
- import { createKodaXRuntime } from '@kodax-ai/kodax/runtime'; // embedded/daemon runtime API
791
- import { createKodaXA2AServer } from '@kodax-ai/kodax/a2a'; // A2A 1.0 client/server edge
792
- ```
793
-
794
- 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.
795
-
796
- For the complete host-facing contract — including embedded/Worker/daemon ownership,
797
- external-agent registration and task control, session cursor pagination, workflow
798
- model-tier routing, and efficiency telemetry — see the
799
- [SDK Embedder Integration Guide](docs/SDK_EMBEDDER_GUIDE.md).
800
-
801
- > **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.
802
-
803
- 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.
804
-
805
- ---
806
-
807
- ## Usage
808
-
809
- ### REPL Quickstart
810
-
811
- Running `kodax` with no prompt starts the interactive REPL.
812
-
813
- ```bash
814
- kodax
815
- ```
816
-
817
- Inside the REPL you can type normal requests or slash commands:
818
-
819
- ```text
820
- Read package.json and summarize the architecture
821
- /model
822
- /mode
823
- /help
824
- ```
825
-
826
- ### CLI Quickstart
827
-
828
- ```bash
829
- # Set API key
830
- export ZHIPU_API_KEY=your_api_key
831
-
832
- # Basic usage
833
- kodax "Help me create a TypeScript project"
834
-
835
- # Choose a provider explicitly
836
- kodax --provider openai --model gpt-5.4 "Create a REST API"
837
-
838
- # Use higher reasoning effort
839
- kodax --effort high "Review this architecture"
840
- ```
841
-
842
- ### Session Workflows
843
-
844
- Use a session when you want memory across turns. Without a session, each CLI call is independent.
845
-
846
- ```bash
847
- # No memory: two separate calls
848
- kodax "Read src/auth.ts"
849
- kodax "Summarize it"
850
-
851
- # With memory: same session
852
- kodax --session my-project "Read package.json"
853
- kodax --session my-project "Summarize it"
854
- kodax --session my-project "How should I fix the first issue?"
855
-
856
- # Session management
857
- kodax -r # Search, page, and select a non-empty session
858
- kodax -r <session-id> # Resume a known session directly
859
- kodax -r "Review runtime" # Resume a unique exact title; duplicates open the picker
860
- kodax --session list # List up to 50 non-empty sessions
861
- kodax --session cleanup-acp # Preview strictly matched empty ACP-test pollution
862
- ```
863
-
864
- Bare `-r` opens an interactive picker with incremental search, arrow/PageUp/PageDown
865
- navigation, Tab completion, full selected-session ID display, and Enter-to-resume.
866
- An explicit value checks the complete session ID first, then an exact
867
- case-insensitive title; duplicate titles open a narrowed picker instead of
868
- silently choosing one. The picker loads before the full CLI, so session listing
869
- remains responsive. After selection it hands terminal input to the resumed
870
- REPL; Esc releases the picker's stdin ownership and immediately returns to the
871
- invoking shell. Session replay preserves each recorded message/event timestamp.
872
-
873
- Cleanup is preview-only unless
874
- `--apply-session-cleanup` is also provided; matching sessions are archived rather
875
- than permanently deleted.
876
-
877
- ### Session Patterns
878
-
879
- ```bash
880
- # ❌ No memory: two independent calls
881
- kodax "Read src/auth.ts" # Agent reads and responds
882
- kodax "Summarize it" # Agent doesn't know what to summarize
883
-
884
- # ✅ With memory: same session
885
- kodax --session auth-review "Read src/auth.ts"
886
- kodax --session auth-review "Summarize it" # Agent knows to summarize auth.ts
887
- kodax --session auth-review "How to fix first issue" # Agent has context
888
- ```
889
-
890
- ### Workflow Examples
891
-
892
- ```bash
893
- # Code review (multi-turn conversation)
894
- kodax --session review "Review src/ directory"
895
- kodax --session review "Focus on security issues"
896
- kodax --session review "Give me fix suggestions"
897
-
898
- # Project development (continuous session)
899
- kodax --session todo-app "Create a Todo application"
900
- kodax --session todo-app "Add delete functionality"
901
- kodax --session todo-app "Write tests"
902
- ```
903
-
904
- ### CLI Reference
905
-
906
- ```text
907
- kodax Start the interactive REPL
908
- -h, --help [topic] Show help or topic help
909
- -p, --print <text> Run a single task and exit
910
- -c, --continue Continue the most recent non-empty conversation in this directory
911
- -r, --resume [value] Resume by ID/exact title, or open the searchable picker
912
- -m, --provider Provider to use
913
- --model <name> Override the model
914
- --reasoning <mode> off | auto | quick | balanced | deep
915
- -t, --thinking Compatibility alias for --reasoning auto
916
- -s, --session <op> Session ID or legacy session operation
917
- -j, --parallel Enable parallel tool execution
918
- --max-iter <n> Max iterations
919
- ```
920
-
921
- ### Permission Control
922
-
923
- KodaX provides 3 permission modes for fine-grained control:
924
-
925
- | Mode | Description | Tools Need Confirmation |
926
- |------|-------------|------------------------|
927
- | `plan` | Read-only planning mode | All modification tools blocked |
928
- | `accept-edits` | Auto-accept file edits | bash only |
929
- | `auto` | Runtime-owned LLM/rules classification within the project boundary | Only explicit classifier escalation |
930
-
931
- ```bash
932
- # In REPL, use /mode command
933
- /mode plan # Switch to plan mode (read-only)
934
- /mode accept-edits # Switch to accept-edits mode
935
- /mode auto # Switch to Runtime-owned Auto Mode
936
- /auto # Alias for auto
937
-
938
- # Check current mode
939
- /mode
940
- ```
941
-
942
- **Features:**
943
- - In `accept-edits` mode, choosing "always" can persist safe Bash allow-patterns
944
- - Plan mode includes system prompt context for LLM awareness
945
- - Permanent protection zones: `.kodax/`, `~/.kodax/`, paths outside project
946
- - Pattern-based permission: Allow specific Bash commands (e.g., `Bash(npm install)`)
947
- - Unified diff display for write/edit operations
948
- - Auto Mode runs guardrail classification before the permission UI; a safe
949
- allow verdict does not create a pending approval request. The session records
950
- an automatic LLM-to-rules fallback for later turns.
951
- - Shift-Tab cycles `Plan -> Edits -> Auto`; Shift+Enter inserts a newline. Auto
952
- immediately displays `Auto[LLM]` or `Auto[RULES]`, and rapid mode changes are
953
- persisted in input order. `Auto[RULES]` is a valid sticky fallback/manual
954
- state; use `/auto-engine llm` to opt back into LLM classification.
955
- - Runtime-backed prompts can offer exact `allow once`, `allow this session`,
956
- and `always allow` choices. Return the Runtime-issued opaque suggestion;
957
- never derive or widen a permission rule from the displayed command or path.
958
- Persistent grants are daemon-owned, revisioned, and can be listed/revoked
959
- through `runtime.permissions` by an authorized SDK host. Dynamic shell
960
- commands deliberately receive no persistent-grant suggestion.
961
-
962
- `kodax -c` skips zero-message ACP/bootstrap placeholders even when they are
963
- newer than the last real conversation. The same newest non-empty rule applies
964
- to Ink, classic, one-shot CLI, and coding-runtime auto-resume; an explicit
965
- session ID always wins. Interactive resume also restores the saved workspace
966
- runtime before relative shell commands or the next model turn.
967
-
968
- ### CLI Help Topics
969
-
970
- Get detailed help for specific topics:
971
-
972
- ```bash
973
- # Basic help
974
- kodax -h
975
- kodax --help
976
-
977
- # Detailed topic help
978
- kodax -h sessions # Session management details
979
- kodax -h init # Long-running project initialization
980
- kodax -h project # Project mode / harness workflow
981
- kodax -h auto # Auto-continue mode
982
- kodax -h provider # LLM provider configuration
983
- kodax -h thinking # Thinking/reasoning effort and compatibility modes
984
- kodax -h team # Multi-agent parallel execution
985
- kodax -h print # Print configuration
986
- ```
987
-
988
- ### Environment Variables
989
-
990
- 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_`.
991
-
992
- #### `KODAX_MAX_OUTPUT_TOKENS`
993
-
994
- 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.
995
-
996
- ```bash
997
- # Allow up to 48K output tokens per turn (use a higher cap when generating long files)
998
- export KODAX_MAX_OUTPUT_TOKENS=48000
999
- kodax "generate the full implementation"
1000
-
1001
- # Unset to restore default behavior
1002
- unset KODAX_MAX_OUTPUT_TOKENS
1003
- ```
1004
-
1005
- Precedence used by every provider's `getEffectiveMaxOutputTokens()` (see `packages/llm/src/providers/base.ts`):
1006
-
1007
- 1. One-shot per-request override (agent-loop escalation / context-overflow recovery — internal)
1008
- 2. **`KODAX_MAX_OUTPUT_TOKENS`** (this variable, explicit user intent)
1009
- 3. Active model descriptor's `maxOutputTokens` (FEATURE_098 per-model cap)
1010
- 4. Provider config default
1011
- 5. Global `KODAX_MAX_TOKENS` fallback
1012
-
1013
- 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`).
1014
-
1015
- > **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.
1016
-
1017
- #### Sidecar verifier diagnostics
1018
-
1019
- Use these when diagnosing Worker text-only completion stalls or custom provider verifier behavior:
1020
-
1021
- ```bash
1022
- export KODAX_VERIFIER_LOG=1
1023
- export KODAX_VERIFIER_PROVIDER=anthropic
1024
- export KODAX_VERIFIER_MODEL=claude-haiku-4-5-20251001
1025
- ```
1026
-
1027
- - `KODAX_VERIFIER_LOG=1` shows verifier gate/elapsed/trace information and is equivalent to `"verifierLog": true` in `~/.kodax/config.json`.
1028
- - `KODAX_VERIFIER_PROVIDER` + `KODAX_VERIFIER_MODEL` route the verifier to a separate provider/model instead of inheriting the main Worker model. Set both together.
1029
- - `KODAX_VERIFIER_ALWAYS=1` forces the verifier to fire on every text-only completion for debugging/regression sweeps.
1030
-
1031
- SDK/headless hosts can observe actionable Sidecar Verifier messages via
1032
- `KodaXEvents.onSidecarMessage`; JSONL output emits the same payload as
1033
- `sidecar.message`. Only `revise` and `blocked` verdicts are surfaced; `accept`
1034
- stays silent.
1035
-
1036
- ## Advanced Library Usage
1037
-
1038
- #### Simple Mode (runKodaX)
1039
-
1040
- ```typescript
1041
- import { runKodaX, KodaXEvents } from '@kodax-ai/kodax';
1042
-
1043
- const events: KodaXEvents = {
1044
- onTextDelta: (text) => process.stdout.write(text),
1045
- onThinkingDelta: (text) => console.log(`Thinking delta: ${text.length} chars`),
1046
- onToolResult: (result) => console.log(`Tool ${result.name}: ${result.content.slice(0, 100)}`),
1047
- onSidecarMessage: (event) => console.log(`[sidecar:${event.verdict}] ${event.content}`),
1048
- onComplete: () => console.log('\nDone!'),
1049
- onError: (e) => console.error(e.message),
1050
- };
1051
-
1052
- const result = await runKodaX({
1053
- provider: 'zhipu-coding',
1054
- effort: 'auto',
1055
- events,
1056
- }, 'What is 1+1?');
1057
-
1058
- console.log(result.lastText);
1059
- ```
1060
-
1061
- #### Continuous Session (KodaXClient)
1062
-
1063
- ```typescript
1064
- import { KodaXClient } from '@kodax-ai/kodax';
1065
-
1066
- const client = new KodaXClient({
1067
- provider: 'zhipu-coding',
1068
- effort: 'auto',
1069
- events: {
1070
- onTextDelta: (t) => process.stdout.write(t),
1071
- },
1072
- });
1073
-
1074
- // First message
1075
- await client.send('Read package.json');
1076
-
1077
- // Continue same session
1078
- await client.send('Summarize it');
1079
-
1080
- console.log(client.getSessionId());
1081
- ```
1082
-
1083
- #### Custom Session Storage
1084
-
1085
- ```typescript
1086
- import { runKodaX, KodaXSessionStorage, KodaXMessage } from '@kodax-ai/kodax';
1087
-
1088
- class MyDatabaseStorage implements KodaXSessionStorage {
1089
- async save(id: string, data: { messages: KodaXMessage[]; title: string; gitRoot: string }) {
1090
- // Save to your database
1091
- }
1092
- async load(id: string) {
1093
- // Load from your database
1094
- return null;
1095
- }
1096
- }
1097
-
1098
- await runKodaX({
1099
- provider: 'zhipu-coding',
1100
- session: {
1101
- id: 'my-session-123',
1102
- storage: new MyDatabaseStorage(),
1103
- },
1104
- events: { ... },
1105
- }, 'task');
1106
- ```
1107
-
1108
- ### Library Modes Comparison
1109
-
1110
- | Feature | runKodaX | KodaXClient |
1111
- |---------|----------|-------------|
1112
- | **Message Memory** | ❌ No | ✅ Yes |
1113
- | **Call Style** | Function | Class instance |
1114
- | **Context** | Independent each time | Accumulates |
1115
- | **Use Case** | Single tasks, batch processing | Interactive dialogue, multi-step tasks |
1116
-
1117
- ---
1118
-
1119
- ## SDK Usage
1120
-
1121
- 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:
1122
-
1123
- ```bash
1124
- npm install @kodax-ai/kodax
1125
- ```
1126
-
1127
- ```typescript
1128
- import { runKodaX } from '@kodax-ai/kodax'; // root: CLI helpers + runKodaX
1129
- import { Runner, runFanOut } from '@kodax-ai/kodax/agent'; // generic Agent framework
1130
- import { getProvider } from '@kodax-ai/kodax/llm'; // 16-alias LLM abstraction
1131
- import { KODAX_TOOLS } from '@kodax-ai/kodax/coding'; // tools + prompts + agent loop
1132
- import { createImageArtifactFromPath } from '@kodax-ai/kodax/media'; // input artifact helpers
1133
- import { runInkInteractiveMode } from '@kodax-ai/kodax/repl'; // Ink TUI entrypoint
1134
- import { SkillRegistry } from '@kodax-ai/kodax/skills'; // zero-dep skill loader
1135
- import { createMcpManager } from '@kodax-ai/kodax/mcp'; // MCP popout manager (v0.7.42)
1136
- import { listSessions } from '@kodax-ai/kodax/session'; // session history helpers
1137
- import { createKodaXRuntime } from '@kodax-ai/kodax/runtime'; // embedded/daemon runtime API
1138
- import { createKodaXA2AServer } from '@kodax-ai/kodax/a2a'; // A2A 1.0 client/server edge
1139
- import { createMemoryAgent } from '@kodax-ai/kodax/experimental-memory'; // opt-in experimental memory SDK
1140
- ```
1141
-
1142
- > 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).
1143
-
1144
- ### `@kodax-ai/kodax/llm` — LLM Abstraction
1145
-
1146
- 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.
1147
-
1148
- ```typescript
1149
- import { getProvider, KodaXBaseProvider } from '@kodax-ai/kodax/llm';
1150
-
1151
- const provider = getProvider('anthropic');
1152
- const stream = await provider.streamCompletion(
1153
- [{ role: 'user', content: 'Hello!' }],
1154
- { onTextDelta: (text) => process.stdout.write(text) }
1155
- );
1156
-
1157
- for await (const result of stream) {
1158
- if (result.type === 'text') { /* … */ }
1159
- else if (result.type === 'tool_use') { /* … */ }
1160
- }
1161
- ```
1162
-
1163
- **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.
1164
-
1165
- ### `@kodax-ai/kodax/agent` — Agent Framework (standalone-consumable)
1166
-
1167
- ADR-021 standalone-consumable: `@kodax-ai/agent` has **zero inbound `@kodax-ai/coding` dependency** — you can wire any tool surface on top of it.
1168
-
1169
- ```typescript
1170
- import {
1171
- Runner,
1172
- runFanOut,
1173
- runWithIdleYield,
1174
- createAgentActorController,
1175
- generateSessionId,
1176
- estimateTokens,
1177
- DefaultSummaryCompaction,
1178
- } from '@kodax-ai/kodax/agent';
1179
-
1180
- // Bounded-concurrency fan-out with abort + structured progress events (v0.7.39 FEATURE_120)
1181
- const result = await runFanOut({
1182
- bundles: [{ id: 'a', task: 'audit-foo' }, { id: 'b', task: 'audit-bar' }],
1183
- maxParallel: 4,
1184
- run: async (bundle) => doWork(bundle),
1185
- });
1186
-
1187
- // Runtime-owned Actor identity tree (inject an executor before starting Turns)
1188
- const actors = await createAgentActorController();
1189
- const tree = actors.list('/root');
1190
-
1191
- // Pluggable compaction policy (FEATURE_081)
1192
- const policy = new DefaultSummaryCompaction({ thresholdRatio: 0.8, keepRecent: 10 });
1193
- ```
1194
-
1195
- `DefaultSummaryCompaction` is a standalone agent-layer primitive for custom
1196
- loops. It does not replace or disable KodaX's always-on coding-runtime policy
1197
- described under FEATURE_272 above.
1198
-
1199
- **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.
1200
-
1201
- ### `@kodax-ai/kodax/skills` — Skills System
1202
-
1203
- Zero external dependencies. Markdown-based skill files with natural-language triggers and variable resolution.
1204
-
1205
- ```typescript
1206
- import {
1207
- SkillRegistry,
1208
- discoverSkills,
1209
- executeSkill,
1210
- type SkillContext,
1211
- } from '@kodax-ai/kodax/skills';
1212
-
1213
- const skills = await discoverSkills(['/path/to/skills']);
1214
- const registry = new SkillRegistry();
1215
- await registry.registerSkills(skills);
1216
-
1217
- const result = await executeSkill({
1218
- skillId: 'code-review',
1219
- arguments: { target: 'src/' },
1220
- workingDirectory: process.cwd(),
1221
- });
1222
- ```
1223
-
1224
- **Key Features**: zero deps · markdown-based skill files · natural-language triggering · variable resolution · built-in skills included.
1225
-
1226
- ### `@kodax-ai/kodax/coding` — Coding Agent
1227
-
1228
- 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.
1229
-
1230
- ```typescript
1231
- import { runKodaX, KodaXClient, KODAX_TOOLS } from '@kodax-ai/kodax/coding';
1232
-
1233
- // Single-task helper
1234
- const result = await runKodaX({
1235
- provider: 'zhipu-coding',
1236
- effort: 'auto',
1237
- events: { onTextDelta: (text) => process.stdout.write(text) },
1238
- }, 'Read package.json and explain the dependencies');
1239
-
1240
- // Continuous session
1241
- const client = new KodaXClient({
1242
- provider: 'anthropic',
1243
- effort: 'auto',
1244
- events: { /* … */ },
1245
- });
1246
- await client.send('Create a new file');
1247
- await client.send('Add a function to it'); // Has context from previous message
1248
- ```
1249
-
1250
- **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.
1251
-
1252
- ### `@kodax-ai/kodax/repl` — Interactive Terminal UI
1253
-
1254
- Ink/React-based interactive REPL. Permission modes, command system, themed streaming display.
1255
-
1256
- ```typescript
1257
- import { runInkInteractiveMode } from '@kodax-ai/kodax/repl';
1258
-
1259
- // Usually used via the `kodax` bin command; can be embedded:
1260
- // - Interactive terminal UI (Ink components)
1261
- // - Permission control (auto/plan/accept-edits modes)
1262
- // - Command system (/help, /mode, /clear, /status, …)
1263
- // - Skills integration
1264
- // - Theme support
1265
- await runInkInteractiveMode({ provider: 'zhipu-coding', effort: 'auto' });
1266
- ```
1267
-
1268
- **Key Features**: Ink-based React components · 3 permission modes (auto / plan / accept-edits) · built-in commands · real-time streaming display · context-usage indicator.
1269
-
1270
- ### Package Dependency Graph (workspace internal)
1271
-
1272
- ```
1273
- @kodax-ai/llm (zero business-logic deps)
1274
-
1275
- @kodax-ai/agent (depends @kodax-ai/llm; ADR-021 standalone-consumable;
1276
- inlines session-lineage + capabilities/{mcp,skills} +
1277
- tracing per ADR-036 v0.7.43)
1278
-
1279
- @kodax-ai/coding (depends llm + agent; inlines repo-intelligence/protocol per ADR-036)
1280
-
1281
- @kodax-ai/repl (depends coding + ink + react)
1282
- ```
1283
-
1284
- **Subpath Recommendations**:
1285
-
1286
- | Use Case | Subpath | Why |
1287
- |----------|---------|-----|
1288
- | Only need LLM abstraction | `@kodax-ai/kodax/llm` | Minimal deps; 16 built-in aliases |
1289
- | Building custom agent | `@kodax-ai/kodax/agent` | Runner + fan-out + idle-yield + session-lineage + capabilities |
1290
- | Coding tasks | `@kodax-ai/kodax/coding` | Complete coding agent + tools |
1291
- | Terminal app | `@kodax-ai/kodax/repl` | Full interactive experience |
1292
- | Runtime host / daemon client | `@kodax-ai/kodax/runtime` | Sessions, runs, events, permissions, catalog, MCP, artifacts, diagnostics |
1293
- | Experimental governed memory | `@kodax-ai/kodax/experimental-memory` | Scoped `MemoryAgent` / `MemorySession` recall and outcome contracts |
1294
-
1295
- ---
1296
-
1297
- | Provider | Environment Variable | Reasoning Support | Default Model |
1298
- |----------|----------------------|-------------------|---------------|
1299
- | anthropic | `ANTHROPIC_API_KEY` | Native | claude-sonnet-4-6 (`claude-opus-4-6` / `claude-haiku-4-5` via `/model`) |
1300
- | openai | `OPENAI_API_KEY` | Native | gpt-5.3-codex (`gpt-5.4` / `gpt-5.3-codex-spark` via `/model`) |
1301
- | 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`) |
1302
- | 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`) |
1303
- | qwen | `QWEN_API_KEY` | Native | qwen3.5-plus |
1304
- | 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) |
1305
- | zhipu | `ZHIPU_API_KEY` | Native | glm-5 (`glm-5.2` 1M ctx / `glm-5.1` / `glm-5-turbo` via `/model`) |
1306
- | zhipu-coding | `ZHIPU_CODING_API_KEY` | Native | glm-5.2 (1M ctx; legacy `glm-5.1` and `glm-5-turbo` remain selectable via `/model`) |
1307
- | 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) |
1308
- | 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`) |
1309
- | mimo | `MIMO_API_KEY` | Native | mimo-v2.5-pro (Xiaomi MiMo pay-per-token, Anthropic-compat) |
1310
- | mimo-coding | `MIMO_CODING_API_KEY` | Native | mimo-v2.5-pro (Xiaomi Token Plan, Anthropic-compat) |
1311
- | 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) |
1312
- | deepseek | `DEEPSEEK_API_KEY` | Native | deepseek-v4-flash (`deepseek-v4-pro` via `/model`) |
1313
- | gemini-cli | `GEMINI_API_KEY` | Prompt-only / CLI bridge | (via gemini CLI) |
1314
- | codex-cli | `OPENAI_API_KEY` | Prompt-only / CLI bridge | (via codex CLI) |
1315
-
1316
- > **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.
1317
-
1318
- ### Examples
1319
-
1320
- ```bash
1321
- # Use Zhipu Coding
1322
- kodax --provider zhipu-coding --thinking "Help me optimize this code"
1323
-
1324
- # Use OpenAI
1325
- export OPENAI_API_KEY=your_key
1326
- kodax --provider openai "Create a REST API"
1327
-
1328
- # Resume last session
1329
- kodax --session resume
1330
-
1331
- # List all sessions
1332
- kodax --session list
1333
-
1334
- # Parallel tool execution
1335
- kodax --parallel "Read package.json and tsconfig.json"
1336
-
1337
- # Adaptive multi-agent (AMA) mode — V2 Worker single-loop with Actor collaboration
1338
- kodax --agent-mode ama "Analyze code structure, check test coverage, find bugs"
1339
- ```
1340
-
1341
- ---
1342
-
1343
- ## Tools
1344
-
1345
- 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.
1346
-
1347
- ### File operations
1348
- | Tool | Description |
1349
- |------|-------------|
1350
- | `read` | Read file contents (supports offset/limit) |
1351
- | `write` | Write a new file or fully rewrite an existing one |
1352
- | `edit` | Exact string replacement (supports `replace_all`) |
1353
- | `multi_edit` | Atomic batch of independent edits to one file |
1354
- | `insert_after_anchor` | Insert content after a unique anchor without rewriting the file |
1355
- | `undo` | Revert the last file modification |
1356
-
1357
- ### Shell & search
1358
- | Tool | Description |
1359
- |------|-------------|
1360
- | `bash` | Execute a shell command (supports `run_in_background`; complete capture with recoverable capacity fallback) |
1361
- | `glob` | Find files by pattern |
1362
- | `grep` | Regex content search (context lines, multiline, file-type filter, pagination) |
1363
- | `code_search` | Lower-noise code search (extension-provider aware) |
1364
- | `semantic_lookup` | Symbol/module/process-aware search backed by repo intelligence |
1365
- | `web_search` | Discovery-oriented web search with trust + freshness signals |
1366
- | `web_fetch` | Fetch a specific URL with provenance hints |
1367
-
1368
- ### Repo Intelligence (working tools)
1369
- | Tool | Description |
1370
- |------|-------------|
1371
- | `repo_overview` | Summarize structure, key areas, entry hints, intelligence snapshot |
1372
- | `changed_scope` | Which files/areas/categories the current diff touches |
1373
- | `changed_diff` | Paged diff slice for a single file |
1374
- | `changed_diff_bundle` | Paged diff slices for multiple files in one call |
1375
- | `module_context` | Module capsule (deps, entries, symbols, tests, docs) |
1376
- | `symbol_context` | Definition + probable callers/callees + alternatives |
1377
- | `process_context` | Approximate static execution capsule for an entry |
1378
- | `impact_estimate` | Blast radius for a symbol/path/module |
1379
-
1380
- ### MCP capabilities (when MCP servers are configured)
1381
- | Tool | Description |
1382
- |------|-------------|
1383
- | `mcp_search` / `mcp_describe` / `mcp_call` | Discover and invoke MCP tools through the shared capability runtime |
1384
- | `mcp_read_resource` / `mcp_get_prompt` | Read MCP resources and prompts |
1385
-
1386
- ### Git worktree
1387
- | Tool | Description |
1388
- |------|-------------|
1389
- | `worktree_create` | Create a new worktree on an isolated branch for safe agent work |
1390
- | `worktree_remove` | Remove a worktree (with safety checks) |
1391
-
1392
- ### Agent control & UX
1393
- | Tool | Description |
1394
- |------|-------------|
1395
- | `spawn_agent` | Create a named child Actor and start its first Turn under inherited capabilities, session capacity, and root work budget. |
1396
- | `send_message` | Commit bounded information to an Actor mailbox without starting a new Turn. |
1397
- | `followup_task` | Join a running Actor at a safe boundary or atomically start a new Turn for an idle Actor. |
1398
- | `wait_agent` | Yield on scoped mailbox/user/interruption/timeout activity; returns a wake acknowledgement and never uses Actor progress as a model wake source. |
1399
- | `interrupt_agent` | Request interruption of an active Turn while preserving Actor identity. |
1400
- | `list_agents` | Inspect the caller-visible Actor subtree and Turn states. |
1401
- | `agent_output` | Read bounded durable output for an authorized Actor/Turn. |
1402
- | `ask_user_question` | Single/multi-select or free-text prompt back to the user |
1403
- | `exit_plan_mode` | Present a finalized plan only when the active REPL/host supplied an approval callback |
1404
- | `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) |
1405
- | `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). |
1406
-
1407
- ---
1408
-
1409
- ## Skills System
1410
-
1411
- KodaX includes a built-in Skills system that can be triggered by natural language:
1412
-
1413
- ```bash
1414
- # Natural language triggering (no explicit /skill needed)
1415
- kodax "帮我审查代码" # Triggers code-review skill
1416
- kodax "写测试用例" # Triggers tdd skill
1417
- kodax "提交代码" # Triggers git-workflow skill
1418
-
1419
- # Explicit skill command
1420
- kodax /skill:code-review
1421
- ```
1422
-
1423
- Built-in skills include:
1424
- - **code-review** - Code review and quality analysis
1425
- - **tdd** - Test-driven development workflow
1426
- - **git-workflow** - Git commit and workflow automation
1427
-
1428
- Skills are stored in `~/.kodax/skills/` and can be extended with custom skills.
1429
-
1430
- ---
1431
-
1432
- ## Commands (CLI)
1433
-
1434
- Commands are `/xxx` shortcuts in CLI:
1435
-
1436
- ```bash
1437
- kodax /review src/auth.ts
1438
- kodax /test
1439
- ```
1440
-
1441
- Commands are stored in `~/.kodax/commands/`:
1442
- - `.md` files → Prompt commands (content used as prompt)
1443
- - `.ts/.js` files → Programmable commands
1444
-
1445
- ---
1446
-
1447
- ## API Exports
1448
-
1449
- ```typescript
1450
- // Main functions
1451
- export { runKodaX, KodaXClient };
1452
-
1453
- // Types
1454
- export type {
1455
- KodaXEvents, KodaXOptions, KodaXResult,
1456
- KodaXMessage, KodaXContentBlock,
1457
- KodaXSessionStorage, KodaXToolDefinition
1458
- };
1459
-
1460
- // Tools
1461
- export { KODAX_TOOLS, KODAX_TOOL_REQUIRED_PARAMS, executeTool };
1462
-
1463
- // Providers
1464
- export { getProvider, KODAX_PROVIDERS, KodaXBaseProvider };
1465
-
1466
- // Utilities
1467
- export {
1468
- estimateTokens,
1469
- getGitRoot, getGitContext, getEnvContext, getProjectSnapshot,
1470
- checkPromiseSignal
1471
- };
1472
- ```
1473
-
1474
- ---
1475
-
1476
- ## Development
1477
-
1478
- ```bash
1479
- # Development mode (using tsx)
1480
- npm run dev "your task"
1481
-
1482
- # Build
1483
- npm run build
1484
-
1485
- # Optional: only build workspace packages
1486
- npm run build:packages
1487
-
1488
- # Build standalone binary (current platform / all platforms)
1489
- npm run build:binary
1490
- npm run build:binary:all
1491
-
1492
- # Run tests
1493
- npm test
1494
-
1495
- # Eval-driven development tests (provider matrices, identity round-trip, etc.)
1496
- npm run test:eval
1497
-
1498
- # Clean
1499
- npm run clean
1500
- ```
1501
-
1502
- ### Repo Intelligence cache directories
1503
-
1504
- KodaX uses one repo-intelligence cache root with separate built-in engine profiles:
1505
-
1506
- - `.agent/repo-intelligence/`
1507
- - Full-engine repo-intelligence artifacts and existing task-engine snapshots.
1508
- - `.agent/repo-intelligence/light/`
1509
- - Light-mode heuristic index artifacts.
1510
-
1511
- They are intentionally separated so:
1512
-
1513
- - full and light profiles can be rebuilt independently.
1514
- - light-mode confidence/capability state cannot be mistaken for full-engine state.
1515
- - future cache migrations can delete one profile without corrupting the other.
1516
-
1517
- `.agent/repo-intelligence/` is local generated state and should not be committed.
1518
-
1519
- ---
1520
-
1521
- ## Code Style
1522
-
1523
- ### Comment Guidelines
1524
-
1525
- KodaX uses an **English-first** comment style with selective Chinese brief notes for complex logic.
1526
-
1527
- | Situation | Style | Example |
1528
- |-----------|-------|---------|
1529
- | Import/Export | English only | `// Import dependencies` |
1530
- | Simple constants | English only | `// Max retry count` |
1531
- | Simple logic | English only | `// Return if null` |
1532
- | **Business rules** | English + Chinese | `// Skip tool_result - 跳过工具结果块` |
1533
- | **Platform compatibility** | English + Chinese | `// Windows path handling - Windows 路径处理` |
1534
- | **Performance optimization** | English + Chinese | `// Debounce to prevent flicker - 防抖避免闪烁` |
1535
-
1536
- ---
1537
-
1538
- ## Documentation
1539
-
1540
- - [README_CN.md](README_CN.md) - Chinese Documentation
1541
- - [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
1542
- - [docs/release.md](docs/release.md) - Standalone binary build & release pipeline
1543
- - [docs/PRD.md](docs/PRD.md) - Product Requirements
1544
- - [docs/ADR.md](docs/ADR.md) - Architecture Decisions
1545
- - [docs/HLD.md](docs/HLD.md) - High-Level Design
1546
- - [docs/DD.md](docs/DD.md) - Detailed Design
1547
- - [docs/FEATURE_LIST.md](docs/FEATURE_LIST.md) - Feature Tracking
1548
- - [docs/test-guides/](docs/test-guides/) - Feature-specific test guides
1549
- - [CHANGELOG.md](CHANGELOG.md) - Version History (v0.7.0+; [archive](docs/CHANGELOG_ARCHIVE.md) for older)
1550
-
1551
- ---
1552
-
1553
- ## License
1554
-
1555
- [KodaX-AI Fair Core License (KAI-FCL) 1.0](LICENSE) - Copyright 2026 [icetomoyo](mailto:icetomoyo@gmail.com).
1556
-
1557
- KAI-FCL is source-available / fair-core, not OSI open source. Commercial,
1558
- enterprise, managed deployment, paid service, or customer redistribution use
1559
- requires KodaX-AI authorization and a valid entitlement where required.
1560
-
1561
- Official KodaX 0.7.70 and later distributions use KAI-FCL or accompanying
1562
- KodaX-AI customer terms. Historical tags, archives, binaries, npm packages, or
1563
- other copies already distributed with Apache-2.0 notices remain Apache-2.0 for
1564
- 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.