@kodax-ai/kodax 0.7.76 → 0.7.78

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 (130) hide show
  1. package/CHANGELOG.md +758 -371
  2. package/LICENSE +158 -158
  3. package/README.md +1702 -1508
  4. package/README_CN.md +1019 -869
  5. package/config-templates/config.example.jsonc +86 -4
  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-ASP4MS3X.js +2 -0
  24. package/dist/chunks/argument-completer-JYQ7FX3W.js +2 -0
  25. package/dist/chunks/chunk-2CFHBKRE.js +5 -0
  26. package/dist/chunks/chunk-35PPHOQ2.js +292 -0
  27. package/dist/chunks/chunk-43QNNDHR.js +29 -0
  28. package/dist/chunks/chunk-5BNQXXGY.js +1 -0
  29. package/dist/chunks/chunk-5GO6FH7L.js +458 -0
  30. package/dist/chunks/chunk-5NDCSFOP.js +78 -0
  31. package/dist/chunks/chunk-6FOJVETH.js +22 -0
  32. package/dist/chunks/chunk-6XM4B6K2.js +48 -0
  33. package/dist/chunks/chunk-6YZUE6NC.js +240 -0
  34. package/dist/chunks/{chunk-RDXRM3UI.js → chunk-7OEBJGHK.js} +1 -1
  35. package/dist/chunks/chunk-KQLQYHWU.js +386 -0
  36. package/dist/chunks/chunk-NXO6GWSY.js +46 -0
  37. package/dist/chunks/chunk-T2XZTLYE.js +316 -0
  38. package/dist/chunks/chunk-TQDBTTIM.js +348 -0
  39. package/dist/chunks/{chunk-SMT2JSM3.js → chunk-UID7BLAB.js} +9 -9
  40. package/dist/chunks/chunk-VAT2QYXM.js +765 -0
  41. package/dist/chunks/chunk-YAZQTC2L.js +5 -0
  42. package/dist/chunks/chunk-YVRYHC4C.js +655 -0
  43. package/dist/chunks/{chunk-PXKSE54E.js → chunk-Z3KFRTSB.js} +1 -1
  44. package/dist/chunks/compaction-config-BQSSIWK5.js +2 -0
  45. package/dist/chunks/{construction-bootstrap-5F5KF2BZ.js → construction-bootstrap-VQLQGWPY.js} +1 -1
  46. package/dist/chunks/dist-BFT5YIGU.js +2 -0
  47. package/dist/chunks/dist-PCFE24YP.js +2 -0
  48. package/dist/chunks/host-UTFXCYYM.js +2 -0
  49. package/dist/chunks/run-manager-PJU3WIFJ.js +2 -0
  50. package/dist/chunks/utils-SID4HW2Q.js +2 -0
  51. package/dist/index.d.ts +21 -19
  52. package/dist/index.js +6 -6
  53. package/dist/kodax_bootstrap.js +25 -25
  54. package/dist/kodax_cli.js +1787 -1341
  55. package/dist/kodax_resume.js +17 -17
  56. package/dist/provider-capabilities.json +392 -362
  57. package/dist/runtime-worker.js +1707 -1279
  58. package/dist/sandbox-workspace-session.js +563 -0
  59. package/dist/sdk-a2a.d.ts +18 -17
  60. package/dist/sdk-a2a.js +8 -8
  61. package/dist/sdk-agent.d.ts +320 -70
  62. package/dist/sdk-agent.js +1 -1
  63. package/dist/sdk-coding.d.ts +135 -168
  64. package/dist/sdk-coding.js +1 -1
  65. package/dist/sdk-experimental-memory.d.ts +14 -597
  66. package/dist/sdk-experimental-memory.js +1 -1
  67. package/dist/sdk-llm.d.ts +219 -6
  68. package/dist/sdk-llm.js +1 -1
  69. package/dist/sdk-mcp.js +1 -1
  70. package/dist/sdk-media.d.ts +1 -1
  71. package/dist/sdk-media.js +1 -1
  72. package/dist/sdk-repl.d.ts +70 -27
  73. package/dist/sdk-repl.js +2 -2
  74. package/dist/sdk-runtime.d.ts +212 -149
  75. package/dist/sdk-runtime.js +1 -1
  76. package/dist/sdk-sandbox.d.ts +93 -0
  77. package/dist/sdk-sandbox.js +2 -0
  78. package/dist/sdk-session.d.ts +8 -8
  79. package/dist/sdk-session.js +1 -1
  80. package/dist/sdk-skills.d.ts +2 -2
  81. package/dist/sdk-skills.js +1 -1
  82. package/dist/semantic-worker.js +15 -15
  83. package/dist/types-chunks/{base.d-ChvpaKjZ.d.ts → base.d-4e74xDdy.d.ts} +13 -1
  84. package/dist/types-chunks/{bash-prefix-extractor.d-r1beOESM.d.ts → bash-prefix-extractor.d-uAe2Oqda.d.ts} +319 -9
  85. package/dist/types-chunks/{capability-learning.d-DPrYxRjF.d.ts → capability-learning.d-CVsdHw4j.d.ts} +1 -1
  86. package/dist/types-chunks/{capsule.d-zeqV4IQX.d.ts → capsule.d-BlSv9l3V.d.ts} +2 -2
  87. package/dist/types-chunks/{guardrail.d-CWYD1bdL.d.ts → guardrail.d-BRE_ErEj.d.ts} +1 -1
  88. package/dist/types-chunks/{guardrail.d-qjuKJZ31.d.ts → guardrail.d-CXDYRgZ3.d.ts} +201 -35
  89. package/dist/types-chunks/{history-retrieval.d-BKTJIrVd.d.ts → history-retrieval.d-DtCy7x64.d.ts} +2 -2
  90. package/dist/types-chunks/{integration-config.d-ojG4swOP.d.ts → integration-config.d-BNowXE8k.d.ts} +23 -8
  91. package/dist/types-chunks/{public-api.d-CX4B11qY.d.ts → public-api.d-B3AohsxN.d.ts} +37 -8
  92. package/dist/types-chunks/{commands.d-DUxnK2TU.d.ts → repl.d-Ie_ZXb_U.d.ts} +89 -78
  93. package/dist/types-chunks/{side-query.d-DWTMsndP.d.ts → resolver.d-iAQ9ocLB.d.ts} +23 -74
  94. package/dist/types-chunks/{run-manager.d-B9fEIjZk.d.ts → run-manager.d-D1twIhF9.d.ts} +1 -1
  95. package/dist/types-chunks/{sdk-session-B0fhAOPa.d.ts → sdk-session-DB9KksIx.d.ts} +3 -3
  96. package/dist/types-chunks/side-query.d-DTuLPcC5.d.ts +77 -0
  97. package/dist/types-chunks/types-D3g6XUQr.d.ts +662 -0
  98. package/dist/types-chunks/{types.d-sRLugmjy.d.ts → types.d-BA-Jwpfs.d.ts} +506 -11
  99. package/dist/types-chunks/{types.d-DEctY20M.d.ts → types.d-BH0ZkTGf.d.ts} +2 -2
  100. package/dist/types-chunks/{types.d-DCQVBqVn.d.ts → types.d-BbtGlKZu.d.ts} +25 -3
  101. package/dist/types-chunks/{types.d-CSmF0t0n.d.ts → types.d-DIpZJKUl.d.ts} +15 -0
  102. package/dist/types-chunks/{types.d-Bm_y6YuM.d.ts → types.d-DVDTIfB_.d.ts} +4 -4
  103. package/dist/types-chunks/{utils.d-D0wPxz8y.d.ts → utils.d-CVp6bFl9.d.ts} +23 -7
  104. package/docs/SDK_EMBEDDER_GUIDE.md +592 -119
  105. package/package.json +9 -1
  106. package/scripts/kodax-bin.cjs +28 -28
  107. package/scripts/production-env.cjs +25 -25
  108. package/dist/chunks/agent-7X5CFET2.js +0 -2
  109. package/dist/chunks/argument-completer-3NHIKB4N.js +0 -2
  110. package/dist/chunks/chunk-4PWPNCNK.js +0 -158
  111. package/dist/chunks/chunk-7FJNLJLF.js +0 -369
  112. package/dist/chunks/chunk-COQYLD4U.js +0 -5
  113. package/dist/chunks/chunk-D3T24FJW.js +0 -78
  114. package/dist/chunks/chunk-EI4JBQKL.js +0 -46
  115. package/dist/chunks/chunk-HGT6WQ24.js +0 -321
  116. package/dist/chunks/chunk-HS3XHF3R.js +0 -622
  117. package/dist/chunks/chunk-IDCGNQ4H.js +0 -5
  118. package/dist/chunks/chunk-KAY2XLCP.js +0 -74
  119. package/dist/chunks/chunk-OD6LVXU6.js +0 -329
  120. package/dist/chunks/chunk-OSF3H4RR.js +0 -22
  121. package/dist/chunks/chunk-TGMBHGZO.js +0 -427
  122. package/dist/chunks/chunk-VWSLC2WO.js +0 -770
  123. package/dist/chunks/chunk-Y3AMP22L.js +0 -37
  124. package/dist/chunks/compaction-config-7J2XE35D.js +0 -2
  125. package/dist/chunks/dist-2RA7LSH3.js +0 -2
  126. package/dist/chunks/dist-URKXBOC6.js +0 -2
  127. package/dist/chunks/host-RKZ2OGFT.js +0 -2
  128. package/dist/chunks/run-manager-7RM4HEH6.js +0 -2
  129. package/dist/chunks/utils-X3TEH6IO.js +0 -2
  130. package/dist/types-chunks/center-types.d-BBT122uJ.d.ts +0 -91
package/README.md CHANGED
@@ -1,1564 +1,1758 @@
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
-
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 (`kodax setup --help` lists all):
45
+ export ZHIPU_API_KEY=... # ANTHROPIC_API_KEY / OPENAI_API_KEY / DEEPSEEK_API_KEY /
46
+ # KIMI_API_KEY / KIMI_CODE_API_KEY / QWEN_API_KEY /
47
+ # QWEN_TOKEN_API_KEY / ZHIPU_CODING_API_KEY /
48
+ # ZAI_CODING_API_KEY / MINIMAX_CODING_API_KEY /
49
+ # MIMO_API_KEY / MIMO_CODING_API_KEY / ARK_CODING_API_KEY
50
+
51
+ kodax
52
+ ```
53
+
54
+ That's it. You're in the REPL ask anything in natural language. On a new
55
+ machine with no selected provider, bare interactive `kodax` opens setup first,
56
+ even if a supported credential environment variable already exists. Setup
57
+ checks core, MCP, Extensions, and A2A active files plus all annotated templates
58
+ without overwriting existing files. It never asks for the key itself; after
59
+ choosing a provider/model, set the named environment variable, restart the
60
+ terminal, and run `kodax` again. Use `kodax setup` to rerun the flow,
61
+ `kodax setup --custom` for a guided custom provider, and `kodax setup --help`
62
+ (or REPL `/setup --help`) for paths, provider variables, commands, and
63
+ shortcuts. Interactive setup also checks the optional ASRT sandbox once:
64
+ Windows may show a one-time UAC prompt; macOS/Linux report any required
65
+ Seatbelt/bubblewrap dependencies. Declining or missing a dependency does not
66
+ break ordinary permission handling, and normal startup will not keep reminding
67
+ you.
68
+
69
+ > **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.
70
+
71
+ ---
72
+
73
+ ## Four ways to use KodaX
74
+
75
+ | Form | Command / Import | When to use it |
76
+ |---|---|---|
77
+ | **REPL** | `kodax` | Interactive multi-turn coding session with streaming UI, permissions, slash commands |
78
+ | **CLI** | `kodax -p "your task"` | One-shot scripted task, CI runs, batch processing |
79
+ | **Library** | `import { runKodaX } from '@kodax-ai/kodax'` | Embed in your own tool / agent / web service |
80
+ | **Single binary** | `./kodax` | Distribute to machines that don't have Node installed |
81
+
82
+ ---
83
+
84
+ ## Why KodaX
85
+
86
+ <table>
87
+ <tr>
88
+ <td width="33%" align="center" valign="top">
89
+ <h3>🇨🇳 6 China-native LLMs</h3>
90
+ <sub>Zhipu · Kimi · MiniMax · MiMo · Ark · Qwen</sub>
91
+ <br><br>
92
+ 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.
93
+ </td>
94
+ <td width="33%" align="center" valign="top">
95
+ <h3>📦 Single-file binary</h3>
96
+ <sub>Bun --compile · Win / macOS / Linux · x64 + arm64</sub>
97
+ <br><br>
98
+ No Node required on the target machine. Drop one file, run anywhere — restricted envs, CI runners, air-gapped boxes.
99
+ </td>
100
+ <td width="33%" align="center" valign="top">
101
+ <h3>🌳 Branchable session lineage</h3>
102
+ <sub>Fork · rewind · parallel edit</sub>
103
+ <br><br>
104
+ Conversation history is a DAG, not a list. Powers the upcoming <b>KodaX Space</b> desktop app.
105
+ </td>
106
+ </tr>
107
+ <tr>
108
+ <td align="center" valign="top">
109
+ <h3>🤖 Multi-agent by default</h3>
110
+ <sub>V2 Worker single-loop + Sidecar Verifier + async children</sub>
111
+ <br><br>
112
+ <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.
113
+ </td>
114
+ <td align="center" valign="top">
115
+ <h3>🧩 Skills + self-construction</h3>
116
+ <sub>Markdown skills, NL triggers</sub>
117
+ <br><br>
118
+ 5-stage self-modification staircase (scaffold → validate → stage → test → activate) gated by an 8-invariant admission contract.
119
+ </td>
120
+ <td align="center" valign="top">
121
+ <h3>🛠 50+ built-in tools</h3>
122
+ <sub>File · shell · search · MCP · ACP</sub>
123
+ <br><br>
124
+ Repo intelligence, semantic search, git worktree, web fetch all addressable through one clean tool surface.
125
+ </td>
126
+ </tr>
127
+ </table>
128
+
129
+ ## How KodaX compares
130
+
131
+ | Feature | **KodaX** | Claude Code | Aider | Codex CLI | Cursor | Cline |
132
+ |---|---|---|---|---|---|---|
133
+ | Source license | ⚠️ KAI-FCL, non-commercial | ❌ Source-available | ✅ Apache&nbsp;2.0 | ✅ Apache&nbsp;2.0 | ❌ Proprietary | ✅ Apache&nbsp;2.0 |
134
+ | Node-free single binary | Bun | Node | Python | Rust | Electron | Extension |
135
+ | Native China providers<br><sub>(Zhipu · Kimi · MiniMax · MiMo · Ark · Qwen)</sub> | ✅ 6 native | ❌ | ⚠ via LiteLLM | ❌ OpenAI-first | ❌ no provider menu | ⚠ Kimi / Qwen / DeepSeek |
136
+ | Branchable session lineage | fork & rewind | ⚠ routines / sessions | ❌ | ❌ | ❌ | ⚠ checkpoints |
137
+ | Multi-agent + MCP + 50+ tools | ✅ all three | ✅ all three | ⚠ tools, no MCP | ✅ all three | ⚠ Composer + MCP | ✅ all three |
138
+
139
+ <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>
140
+
141
+ ## Detailed Setup
142
+
143
+ > 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.
144
+
145
+ ### 1. Build the CLI from source
146
+
147
+ ```bash
148
+ git clone https://github.com/icetomoyo/KodaX.git
149
+ cd KodaX
150
+ npm install
151
+ npm run build
152
+ npm link
153
+ ```
154
+
155
+ ### 2. Configure a provider
156
+
157
+ KodaX reads API keys from environment variables. For built-in providers, the fastest path is:
158
+
150
159
  ```bash
151
160
  # Interactive metadata-only provider/model setup (does not collect a key)
152
161
  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
162
 
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:
163
+ # Guided custom OpenAI/Anthropic-compatible provider
164
+ kodax setup --custom
229
165
 
230
- ```json
231
- {
232
- "models": [
233
- { "id": "deepseek-v4-flash", "replayReasoningContent": true },
234
- { "id": "gpt-5", "replayReasoningContent": false }
235
- ]
236
- }
166
+ # Complete guide; does not change files
167
+ kodax setup --help
237
168
  ```
238
169
 
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
- });
170
+ Setup checks these active files and matching `*.example.jsonc` references:
171
+
172
+ - `~/.kodax/config.json` and `~/.kodax/config.example.jsonc`
173
+ - `~/.kodax/integrations/mcp.json`
174
+ - `~/.kodax/integrations/extensions.json`
175
+ - `~/.kodax/integrations/a2a.json`
176
+
177
+ The core active file remains strict JSON. The first line of the annotated
178
+ `config.example.jsonc` points to all split files and documents every supported
179
+ core setting. Setup preserves existing files and stages readable legacy
180
+ `config.json#mcpServers` / `config.json#extensions` before creating empty
181
+ authoritative split files. It tells you the exact environment-variable name to
182
+ set and exits so you can restart the terminal. Existing active files are
183
+ validated first; an invalid file is reported without creating or overwriting
184
+ configuration. You can also configure it directly:
185
+
186
+ ```bash
187
+ # macOS / Linux
188
+ export ZHIPU_API_KEY=your_api_key
189
+
190
+ # PowerShell
191
+ $env:ZHIPU_API_KEY="your_api_key"
336
192
  ```
337
193
 
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.
194
+ ### 2.1 Activate the optional sandbox
343
195
 
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.
196
+ `kodax setup` and first-run setup check sandbox readiness. You can inspect or
197
+ activate it explicitly:
348
198
 
349
199
  ```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
200
+ kodax sandbox doctor
201
+ kodax sandbox setup
354
202
  ```
355
203
 
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`:
204
+ - Windows uses a restricted sandbox account and network policy. A normal
205
+ terminal is sufficient; approve the one-time UAC prompt.
206
+ - macOS uses Seatbelt/`sandbox-exec` and requires ripgrep
207
+ (`brew install ripgrep`).
208
+ - Linux uses bubblewrap and requires `bubblewrap`, `socat`, and `ripgrep`
209
+ (install them with your distro's `apt`, `dnf`, or `pacman`).
210
+
211
+ KodaX never runs `sudo` or a package manager automatically. If the sandbox is
212
+ not active, deterministic safe operations and Auto[LLM] decisions keep the
213
+ same permission behavior; only OS-level containment is absent. Ordinary runs
214
+ do not repeatedly prompt for setup. In the REPL, `/sandbox` refreshes readiness
215
+ and diagnostics without activating the backend or requesting elevation.
216
+ Per-command sandbox routing remains internal and is not shown in normal command
217
+ history. SDK embedders can use the same capability independently through
218
+ `@kodax-ai/kodax/sandbox`; see the
219
+ [SDK sandbox guide](docs/SDK_EMBEDDER_GUIDE.md#30-standalone-sandbox-sdk-v0778).
359
220
 
360
- ```json
361
- {
362
- "runtimeMode": "daemon"
221
+ For Qwen Token Plan, select `qwen-token-plan` and use its separate credential;
222
+ `QWEN_API_KEY` does not authenticate this route:
223
+
224
+ ```bash
225
+ export QWEN_TOKEN_API_KEY=your_api_key
226
+ kodax --provider qwen-token-plan
227
+ ```
228
+
229
+ For CLI defaults, create `~/.kodax/config.json`:
230
+
231
+ ```json
232
+ {
233
+ "provider": "zhipu-coding",
234
+ "effort": "auto"
235
+ }
236
+ ```
237
+
238
+ If you need a custom base URL or an OpenAI/Anthropic-compatible endpoint, define a custom provider in the same config file:
239
+
240
+ ```json
241
+ {
242
+ "provider": "my-openai-compatible",
243
+ "customProviders": [
244
+ {
245
+ "name": "my-openai-compatible",
246
+ "protocol": "openai",
247
+ "baseUrl": "https://example.com/v1",
248
+ "apiKeyEnv": "MY_LLM_API_KEY",
249
+ "model": "my-model",
250
+ "userAgentMode": "compat",
251
+ "reasoning": {
252
+ "efforts": ["off", "low", "medium", "high", "max"],
253
+ "default": "high"
254
+ }
255
+ }
256
+ ]
257
+ }
258
+ ```
259
+
260
+ `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.
261
+ 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.
262
+
263
+ #### OpenAI-compatible reasoning providers
264
+
265
+ 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:
266
+
267
+ ```json
268
+ {
269
+ "customProviders": [
270
+ {
271
+ "name": "my-deepseek-v4",
272
+ "protocol": "openai",
273
+ "baseUrl": "https://example.com/v1",
274
+ "apiKeyEnv": "MY_DEEPSEEK_API_KEY",
275
+ "model": "deepseek-v4-flash",
276
+ "reasoningPreset": "deepseek-v4-openai",
277
+ "replayReasoningContent": true
278
+ }
279
+ ]
280
+ }
281
+ ```
282
+
283
+ 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:
284
+
285
+ ```json
286
+ {
287
+ "models": [
288
+ { "id": "deepseek-v4-flash", "replayReasoningContent": true },
289
+ { "id": "gpt-5", "replayReasoningContent": false }
290
+ ]
363
291
  }
364
292
  ```
365
293
 
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.
294
+ If a custom endpoint is confirmed to support cache-affinity routing, set
295
+ `"promptCacheAffinity": true`. Anthropic-compatible requests then receive the
296
+ opaque logical-context key as `metadata.user_id`; OpenAI-compatible requests
297
+ receive `prompt_cache_key`. The default is `false` because some strict
298
+ compatible gateways reject unknown request fields. Do not enable it solely
299
+ because an endpoint claims protocol compatibility.
401
300
 
301
+ 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.
302
+
303
+ #### Opting a custom provider into image / vision input (FEATURE_134 v0.7.40)
304
+
305
+ 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.
306
+
307
+ ```json
308
+ {
309
+ "customProviders": [
310
+ {
311
+ "name": "my-vision-provider",
312
+ "protocol": "openai",
313
+ "baseUrl": "https://example.com/v1",
314
+ "apiKeyEnv": "MY_LLM_API_KEY",
315
+ "model": "my-vision-model",
316
+ "capabilityProfile": {
317
+ "transport": "native-api",
318
+ "conversationSemantics": "full-history",
319
+ "mcpSupport": "none",
320
+ "contextFidelity": "full",
321
+ "toolCallingFidelity": "full",
322
+ "sessionSupport": "full",
323
+ "longRunningSupport": "full",
324
+ "multimodalSupport": "image-input",
325
+ "evidenceSupport": "full"
326
+ }
327
+ }
328
+ ]
329
+ }
330
+ ```
331
+
332
+ 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.
333
+
334
+ ### 3. Start in REPL or run a one-shot task
335
+
336
+ ```bash
337
+ # Interactive REPL
338
+ kodax
339
+
340
+ # Then ask naturally inside the REPL
341
+ Read package.json and summarize the architecture
342
+ /mode
343
+ /help
344
+
345
+ # One-shot CLI usage
346
+ kodax "Review this repository and summarize the architecture"
347
+ kodax --session review "Find the riskiest parts of src/"
348
+ kodax --session review "Give me concrete fix suggestions"
349
+ ```
350
+
351
+ ### 4. Use it as a library
352
+
353
+ Library usage still expects API keys from environment variables. If you want custom provider names or base URLs in code, register them explicitly:
354
+
355
+ ```typescript
356
+ import { registerCustomProviders, runKodaX } from '@kodax-ai/kodax';
357
+
358
+ registerCustomProviders([
359
+ {
360
+ name: 'my-openai-compatible',
361
+ protocol: 'openai',
362
+ baseUrl: 'https://example.com/v1',
363
+ apiKeyEnv: 'MY_LLM_API_KEY',
364
+ model: 'my-model',
365
+ userAgentMode: 'compat',
366
+ },
367
+ ]);
368
+
369
+ const result = await runKodaX(
370
+ {
371
+ provider: 'my-openai-compatible',
372
+ effort: 'auto',
373
+ },
374
+ 'Explain this codebase'
375
+ );
376
+ ```
377
+
378
+ > **Embedding KodaX inside another app?** (KodaX Space, IDE extensions, custom CLIs)
379
+ > See [docs/SDK_EMBEDDER_GUIDE.md](docs/SDK_EMBEDDER_GUIDE.md) for the runtime-mutation
380
+ > surface (`startKodaX` + `RunningSession`), MCP popout manager API (`McpManager`),
381
+ > Skill `` !`cmd` `` host hook, and per-app data dir namespacing (`getAppDataDir`).
382
+
383
+ ## Runtime SDK and daemon
384
+
385
+ SDK hosts can use `@kodax-ai/kodax/runtime` in three forms: inline embedded for
386
+ lowest latency, Worker-hosted embedded for private state plus hard V8 disposal,
387
+ or a local daemon shared by REPL, Space, IDE adapters, and custom SDK clients.
388
+ All three expose the same `KodaXRuntime` services.
389
+
390
+ ```ts
391
+ import { createKodaXRuntime } from '@kodax-ai/kodax/runtime';
392
+
393
+ const isolated = await createKodaXRuntime({
394
+ mode: 'embedded',
395
+ isolation: 'worker',
396
+ requirements: { hardDispose: true },
397
+ });
398
+ ```
399
+
400
+ Inline is private and lowest-overhead; Worker is private and hard-disposable;
401
+ daemon is process-isolated and shared. `runtime.close()` closes private
402
+ inline/Worker ownership, but only detaches one daemon client. Contradictory
403
+ isolation options fail instead of silently selecting a weaker mode. Worker
404
+ isolation is a V8 fault boundary, not a security sandbox.
405
+
406
+ Because a daemon is intentionally persistent, tests that auto-start one must
407
+ also run `kodax daemon stop --home <dir> --profile <name>` (or send authenticated
408
+ `runtime.shutdown`) before deleting their temporary home. A remaining Node
409
+ process is not safe to kill by name alone; verify its command line and owner.
410
+
411
+ ```bash
412
+ kodax daemon start
413
+ kodax daemon stop --profile default
414
+ kodax --runtime-mode daemon
415
+ kodax -p "Review this repository" --runtime-mode daemon
416
+ ```
417
+
418
+ All CLI task forms now use the same Runtime path: interactive REPL, positional
419
+ prompts, slash-command prompts, and `kodax -p`. Select the persistent default in
420
+ `~/.kodax/config.json`:
421
+
422
+ ```json
423
+ {
424
+ "runtimeMode": "daemon"
425
+ }
426
+ ```
427
+
428
+ Resolution order is explicit CLI/SDK option > environment variable >
429
+ `config.json` > built-in default (`embedded`). `KODAX_RUNTIME_MODE=daemon` is a
430
+ temporary environment override. The same rule applies to other paired settings,
431
+ for example `provider` ↔ `KODAX_PROVIDER` and `effort` ↔ `KODAX_EFFORT`.
432
+ JSON names stay camelCase while environment names use `KODAX_UPPER_SNAKE_CASE`.
433
+
434
+ By default, daemon state, config, and runtime session storage use the exact
435
+ resolved `KODAX_HOME` (normally `<OS user home>/.kodax`), so CLI and SDK clients
436
+ converge on the same local daemon even when `KODAX_HOME` is an arbitrary custom
437
+ directory. The high-level `createKodaXRuntime({ mode: 'daemon' })` API starts or
438
+ reuses that daemon unless you pass an explicit endpoint/transport or
439
+ `autoStartDaemon: false`. An explicit `--home <dir>` or `homeDir` selects the
440
+ isolated `<dir>/.kodax` namespace for tests, CI, or project-local experiments.
441
+
442
+ **v0.7.71 packaged Electron patch:** packaged/asar Electron hosts can use daemon
443
+ auto-start without relaunching the GUI. `ELECTRON_RUN_AS_NODE` is limited to a
444
+ bootstrap-only child exec boundary and removed before daemon or ordinary user
445
+ child code loads. The default-enabled Electron `RunAsNode` fuse is required;
446
+ hosts that disable it must start the daemon through ordinary Node/KodaX CLI and
447
+ connect in attach-only mode. For SDK calls, `homeDir` is the CLI-style base
448
+ directory that owns `.kodax`, not the `.kodax` path itself.
449
+
450
+ **v0.7.75 Windows GUI stabilization candidate:** Runtime Worker-reachable
451
+ non-interactive subprocesses request hidden Windows consoles across memory/Git,
452
+ provider CLI/ACP, LSP, clipboard, worktree, review, extension-command,
453
+ checkpoint, and sandbox paths. Explicit editor, terminal, and PTY behavior is
454
+ unchanged. The SDK bundle includes a static child-process audit and a packaged
455
+ Electron 20-query console-visibility regression. Product-level packaged KodaX
456
+ Space verification remains useful but does not gate SDK packaging or
457
+ publication.
458
+
459
+ The same candidate distinguishes optional post-completion offers from
460
+ clarification required to finish the current request, emits budget-approval
461
+ state only for eligible Sidecar revisions, and preserves structured blocked
462
+ reasons across embedded and daemon Runtime boundaries.
463
+
402
464
  **v0.7.76 Kimi Code catalog refresh:** `kimi-code` now defaults to the official
403
465
  `k3-256k` Model ID and sends it unchanged. `kimi-for-coding` remains selectable
404
466
  for K2.7 Code, alongside `kimi-for-coding-highspeed` and the 1M `k3` tier. K3
405
467
  supports `low` / `high` / `max` reasoning with `high` as default; the 256K
406
468
  route supports image input but not video input.
407
469
 
470
+ **v0.7.77 release:** AMA now chooses and composes six named
471
+ problem-solving patterns through the existing Actor control plane instead of
472
+ using a fixed topology or hidden Workflow. Optional strategy metadata becomes
473
+ a bounded, fact-only `PatternTrace`; the existing Sidecar remains the only
474
+ terminal-answer quality judge. Governed memory can also react sparsely after a
475
+ tool failure, verification failure, or committed compaction and place at most
476
+ three prompt-safe, low-authority evidence items before the next Action-LLM
477
+ request. The default path adds no selector model call; SDK hosts may opt into
478
+ `memoryRecallRunner` in process. Public `kimi` also gains the 1M `kimi-k3`
479
+ route while retaining K2.7 Code as its default. See the
480
+ [v0.7.77 design](docs/features/v0.7.77.md) and
481
+ [release checklist](docs/release.md#v0777-release-ready-candidate-verification).
482
+ The frozen F274/F275 paid evaluation completed with `recommend-ship` from the
483
+ final F274 Layer 2/Layer 3 reviews and the F275 pilot review, followed by a
484
+ joint `SHIP` decision for the deterministic contracts. Semantic memory
485
+ selection remains experimental and host opt-in; no task-quality, token, or
486
+ latency improvement is claimed.
487
+
488
+ **v0.7.78 evidence-gated learning, setup, and permission/sandbox release:**
489
+ Background learning is Memory-first. Only repeated independently verified
490
+ evidence, or an explicit preserve-as-Skill request with verified terminal
491
+ evidence, can admit a low-risk declarative Skill to a bounded immutable
492
+ project canary; three exact-revision uses and independently verified success
493
+ are required before automatic project trust. Every revision remains visible
494
+ and reversible in `/learn`. Protected/formal Skills, global promotion, and
495
+ Extension authoring remain explicit user actions.
496
+
497
+ First-run setup now creates and validates the split core/MCP/Extensions/A2A
498
+ files and annotated templates without overwriting existing configuration or
499
+ collecting secrets. Auto[LLM] admits precisely modeled ordinary reads and
500
+ workspace/temp mutations before classifier latency, retries classifier
501
+ infrastructure failure once, then falls back at the Accept-edits boundary
502
+ without switching to rules. ASRT is optional execution containment rather
503
+ than permission authority; `/sandbox` is the explicit diagnostic surface, and
504
+ SDK hosts can use the standalone `/sandbox` subpath without a silent
505
+ unsandboxed fallback. KodaX's workspace containment denies reads from common
506
+ home credential paths and the complete resolved agent home without turning
507
+ ordinary external reads into an allowlist. See the
508
+ [v0.7.78 design](docs/features/v0.7.78.md), the
509
+ [release checklist](docs/release.md#v0778-release-verification), and
510
+ [SDK guide sections 29–30](docs/SDK_EMBEDDER_GUIDE.md#29-evidence-gated-background-skill-learning-feature_263-v0778).
511
+
512
+ The release closure also preserves intent across adjacent surfaces: static
513
+ Skill instructions load in Edit/Plan without granting later side effects,
514
+ dynamic Skill commands require an explicit host-controlled executor, root AMA
515
+ uses the governed `memory_intent` lifecycle (including explicit intent captured
516
+ before a later cancellation), Workflow Actor waits remain
517
+ unbounded unless the workflow sets a deadline, and Runtime Auto capability v4
518
+ advertises `fallbackPersistsEngine:false` across embedded, Worker, and daemon
519
+ hosts. Actor ownership additionally uses Runtime identity rather than PID alone,
520
+ so PID reuse cannot pin a crashed owner. The resume Session picker also renders
521
+ timestamps in the host's local timezone.
522
+
523
+ The v0.7.77 release also adds an opt-in, host-configurable Shell Execution Contract.
524
+ Runtime Session settings or an individual Run can select `pwsh`, Windows
525
+ PowerShell, `cmd`, `bash`, `zsh`, or an explicit Git Bash executable; KodaX
526
+ resolves the shell environment in the effective project cwd and then executes
527
+ the command through that same interpreter. Resolved environments are isolated
528
+ by contract and cwd, expire after a bounded TTL, and can be explicitly
529
+ refreshed. Provider credentials and execution-control variables are removed
530
+ before profile/setup code and again before the command starts. When
531
+ `shellExecution` is absent, established command behavior is unchanged. See
532
+ [SDK Embedder Guide section 28](docs/SDK_EMBEDDER_GUIDE.md#28-host-configurable-shell-execution-contract-v0777)
533
+ and the [Issue 214 regression guide](docs/test-guides/ISSUE_214_v0.7.77_REGRESSION_GUIDE.md).
534
+
535
+ Kimi Code requests also receive a stable, opaque prompt-cache affinity key
536
+ derived from the logical Runtime context. It is reused across Runs, retries,
537
+ fallback, resume, and compaction; recursive child Agents receive distinct keys
538
+ based on their canonical Agent path rather than their temporary transcript
539
+ Session. Public Kimi and official OpenAI use the corresponding
540
+ `prompt_cache_key` field, while other compatible gateways remain opt-in because
541
+ some reject unknown request fields. This improves routing stability but cannot
542
+ override Provider TTL or cache sharding. See the
543
+ [Issue 215 regression guide](docs/test-guides/ISSUE_215_v0.7.77_REGRESSION_GUIDE.md).
544
+ Codex CLI cache reads/writes and Gemini CLI cache reads now flow through the
545
+ CLI bridge and Runtime diagnostics without estimation. A reported `0` remains
546
+ distinct from an unreported field; see the
547
+ [Issue 216 regression guide](docs/test-guides/ISSUE_216_v0.7.77_REGRESSION_GUIDE.md).
548
+ The bridge also starts the first native CLI turn fresh, resumes only a native
549
+ session ID reported by that CLI, creates fresh ACP sessions for stateless
550
+ calls, recreates a closed pseudo transport, and validates the process exit even
551
+ after a terminal CLI event. User cancellation stays quiet, while hard/idle
552
+ timeout aborts remain failures eligible for Runtime recovery, and a CLI that
553
+ reports success but never exits is terminated at its configured deadline; see the
554
+ [Issue 217 regression guide](docs/test-guides/ISSUE_217_v0.7.77_REGRESSION_GUIDE.md).
555
+
408
556
  One daemon owns many sessions. Different sessions may run concurrently; starts
409
557
  within the same session are queued so that only one run is active for that
410
558
  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,
559
+ observe the same session. FEATURE_269 adds atomic snapshot-plus-stream joining,
560
+ durable idempotent mutations, revision-safe settings and grants, transport-safe
561
+ AskUser/permission responses, run-scoped credential and Host Tool bridges, and
562
+ one daemon/inline Coder owner fence. In-flight external effects are never
563
+ blindly replayed after a crash; clients receive explicit interrupted/unknown
564
+ terminal facts and resync when `runtimeId` changes.
565
+
566
+ Space and IDE hosts should require these capabilities through the Runtime SDK.
567
+ Partner remains on its private inline Runtime and must use a distinct product
568
+ data/session root. A missing daemon capability is an error, not permission to
569
+ silently fall back to inline Coder.
570
+
571
+ For the full host-integration contract, including inline/Worker/daemon selection,
572
+ multi-client permission handling, config/catalog/MCP admin APIs, artifacts,
573
+ context diagnostics, and daemon protocol schemas, see
574
+ [docs/SDK_EMBEDDER_GUIDE.md §17](docs/SDK_EMBEDDER_GUIDE.md#17-runtime-sdk-worker-isolation-and-local-daemon-feature_253-feature_257).
575
+
576
+ The Space/IDE shared-daemon contract is documented in
577
+ [SDK Embedder Guide section 23](docs/SDK_EMBEDDER_GUIDE.md#23-shared-coder-daemon-for-space-and-ide-hosts-feature_269-v0769).
578
+
579
+ **v0.7.72–v0.7.73 Runtime permission contract:** Auto Mode is owned by the Runtime session,
432
580
  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
581
+ before the shared permission bridge, and persists explicit engine selection.
582
+ The same session settings can select a classifier model and bounded
435
583
  timeout; `auto` defaults to LLM classification and fails with a recoverable
436
584
  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}
585
+ silently falling back. In v0.7.78, classifier failures retry once and then use
586
+ the Accept-edits safety boundary; they never change the engine to rules.
587
+ Runtime permission prompts offer opaque, exact
588
+ allow-once/session/persistent grant suggestions; persistent grants are
589
+ daemon-owned and revisioned. Host plan exit is exposed only when the host
590
+ 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).
591
+
592
+ ## Repo Intelligence
593
+
594
+ 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.
595
+
596
+ 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.
597
+
598
+ ```bash
599
+ # Pick a runtime mode (auto | full | light | off)
600
+ kodax --repo-intelligence full --repo-intelligence-trace
601
+ ```
602
+
603
+ ## Architecture
604
+
605
+ 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 12 SDK subpath exports (`/agent`, `/llm`, `/coding`, `/media`, `/repl`, `/skills`, `/mcp`, `/session`, `/runtime`, `/sandbox`, `/a2a`, `/experimental-memory`; ADR-024 + ADR-032 + ADR-038, with ADR-036 consolidation):
606
+
607
+ ```
608
+ KodaX/
609
+ ├── packages/ # 4 workspace packages (FEATURE_194 v0.7.43)
610
+ ├── llm/ # @kodax-ai/llm - LLM abstraction (16 built-in provider aliases)
611
+ │ └── providers/ # Anthropic, OpenAI, DeepSeek, Kimi, MiMo, MiniMax, Zhipu, Ark, …
612
+ │ │
613
+ │ ├── agent/ # @kodax-ai/agent - Generic Agent framework
614
+ │ │ ├── actors/ # Runtime-owned Actor tree, scheduler, mailbox, events
615
+ │ │ ├── session-lineage/ # branchable session tree (inline v0.7.43)
616
+ │ │ ├── capabilities/
617
+ │ │ │ ├── mcp/ # MCP integration (inline v0.7.43)
618
+ │ │ │ └── skills/ # Skills standard implementation + builtin (inline v0.7.43)
619
+ │ └── tracing/ # tracing / observability (inline v0.7.43)
620
+ │ │
621
+ ├── coding/ # @kodax-ai/coding - Coding Agent (tools + prompts)
622
+ │ │ ├── tools/ # 50+ tools: read, write, edit, bash, glob, grep, undo,
623
+ │ │ # spawn_agent, send_message, followup_task, wait_agent,
624
+ │ │ │ # ask_user_question, repo-intelligence, …
625
+ └── repo-intelligence/ # incl. protocol.ts (inline v0.7.43)
626
+
627
+ │ └── repl/ # @kodax-ai/repl - Interactive terminal UI (Ink TUI)
628
+
629
+ ├── src/ # CLI entry + SDK subpath entries
630
+ │ ├── kodax_cli.ts # Main CLI entry point (bin: `kodax`)
631
+ │ └── sdk-*.ts # SDK subpath re-exports → @kodax-ai/kodax/{agent,llm,coding,media,repl,skills,mcp,session,runtime,sandbox,a2a,experimental-memory}
482
632
 
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 |
633
+ └── package.json # Publish-shaped exports; release.mjs only toggles private during pack/publish
634
+ ```
635
+
636
+ ### Package Dependencies
637
+
638
+ ```
639
+ ┌──────────────────┐
640
+ │ kodax (root) │
641
+ │ CLI Entry │
642
+ └────────┬─────────┘
643
+
644
+ ┌──────────────┴──────────────┐
645
+ │ │
646
+ ▼ ▼
647
+ ┌──────────────┐ ┌────────────────┐
648
+ │@kodax-ai/repl│ │@kodax-ai/coding│
649
+ │ UI Layer │ │ Tools+Prompts │
650
+ └──────┬───────┘ └──────┬─────────┘
651
+ │ │
652
+ │ ┌──────────────┴──────────────┐
653
+ │ │ │
654
+ ▼ ▼ ▼
655
+ ┌──────────────┐ ┌──────────────────────────┐ ┌──────────────┐
656
+ │@kodax-ai/ │ │@kodax-ai/agent │ │@kodax-ai/llm │
657
+ │coding (via │ │Runner + fan-out + │ │LLM Abstract │
658
+ │above) │ │idle-yield + session- │ │(16 aliases) │
659
+ │ │ │lineage + skills + mcp + │ │ │
660
+ │ │ │tracing (FEATURE_194) │ │ │
661
+ └──────────────┘ └──────────────────────────┘ └──────────────┘
662
+ ```
663
+
664
+ ### Package Overview
665
+
666
+ 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.
667
+
668
+ | Workspace package | Purpose | Key Dependencies |
669
+ |---------|---------|------------------|
670
+ | `@kodax-ai/llm` | LLM abstraction (16 built-in provider aliases + custom registration) | @anthropic-ai/sdk, openai |
671
+ | `@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 |
672
+ | `@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 |
673
+ | `@kodax-ai/repl` | Complete interactive terminal UI (Ink/React, permission modes, commands, streaming) | @kodax-ai/coding, ink, react |
674
+
675
+ ### Source-side vs npm-published surface
676
+
677
+ KodaX has two layers that consumers should understand separately:
678
+
679
+ - **Source-side**: 4 workspace packages above (what developers see when reading the repo).
680
+ - **npm-published**: a single bundled package `@kodax-ai/kodax` with 12 SDK subpaths (what SDK consumers `import` from). The subpaths are split into two roles:
681
+ - **Full-package subpaths** (`/agent`, `/llm`, `/coding`, `/repl`) — each one maps 1:1 to a source workspace and exposes its complete public API.
682
+ - **Integration and narrow subpaths** (`/media`, `/skills`, `/mcp`, `/session`, `/runtime`, `/sandbox`, `/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`.
683
+
684
+ | Source package | npm subpath | Type | What you get | Example consumer |
685
+ |---|---|---|---|---|
686
+ | `packages/llm` | `@kodax-ai/kodax/llm` | Full package | 16-alias LLM abstraction (108 exports) | Standalone LLM clients |
687
+ | `packages/agent` | `@kodax-ai/kodax/agent` | Full package | Runner / fan-out / external-agent plane / session-lineage / capabilities / tracing (331 exports) | Custom agent frameworks |
688
+ | `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 |
689
+ | `packages/agent` | `@kodax-ai/kodax/mcp` | **Narrow subset** | MCP only — `McpCapabilityProvider` / `createMcpTransport` / `searchMcpCatalog` / ... (23 exports) | MCP server hosts |
690
+ | `packages/agent` | `@kodax-ai/kodax/media` | **Narrow subset** | Structured image/file/video input-artifact helpers (22 exports) | Desktop hosts and multimodal clients |
691
+ | `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 |
692
+ | `packages/coding` | `@kodax-ai/kodax/coding` | Full package | Coding agent + 50+ tools + repo-intelligence (505 exports) | Build a Claude Code-shape product |
693
+ | `packages/repl` | `@kodax-ai/kodax/repl` | Full package | Ink TUI + permission modes + commands (217 exports) | Terminal-UI consumers |
544
694
  | `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
695
  | `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 |
696
+ | `src` | `@kodax-ai/kodax/sandbox` | Host API | Explicit ASRT capability/doctor/setup and host-owned contained command execution; unavailability never means silent ordinary execution | SDK hosts that need standalone process containment |
546
697
  | `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
-
698
+
699
+ **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.
700
+
701
+ **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.
702
+
703
+ **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.
704
+
705
+ **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).
706
+
707
+ **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.
708
+
709
+ **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).
710
+
711
+ **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).
712
+
713
+ **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).
714
+
715
+ **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).
716
+
717
+ **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).
718
+
719
+ **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.
720
+
721
+ **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).
722
+
723
+ **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).
724
+
725
+ **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).
726
+
727
+ **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).
728
+
729
+ **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 and will not return a port blocked by Fetch-compatible clients; 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).
730
+
731
+ **A2A interoperability and authentication hardening** keeps a discovered
732
+ interface on the trusted Agent Card origin and sends credentials only when one
733
+ complete Card/Skill security requirement is satisfiable. The no-code client
734
+ supports HTTP Bearer compatibility and OAuth 2.0 Client Credentials; for OAuth,
735
+ an external Authorization Server issues short-lived access tokens and KodaX
736
+ caches them only in memory. Inbound `a2a serve` can validate RFC 9068 JWT access
737
+ tokens from an external issuer/JWKS, but never signs or issues production
738
+ tokens itself. It resolves its provider from CLI, then environment, config, and
739
+ the built-in default; a Markdown Agent can pin its own provider. Input
740
+ continuation resumes the original Runtime run, task history and retention are
741
+ bounded with stable cursor pagination, and authenticated SSE is correlated
742
+ before falling back to polling after an early normal EOF. Only direct remote
743
+ artifacts, broker-staged outputs, and outputs from a successfully admitted
744
+ Skill script can be published; ordinary workspace writes and local paths stay
745
+ private.
746
+
747
+ This authentication and per-Agent activation hardening is a post-release
748
+ closure of the v0.7.69 F267/F268 design and ships in the v0.7.71 patch; it is
749
+ not a claim that older v0.7.69 binaries contained the
750
+ later OAuth profiles.
751
+
752
+ **v0.7.70 MCP discovery hardening** uses exact capability IDs and revisioned
753
+ cursors while admitting results against real physical capacity. Compact CJK
754
+ queries are segmented, and a cross-language lexical zero match either returns a
755
+ lossless bounded grouped inventory or one concise retry in the catalog language.
756
+ Partial provider failure remains explicit rather than disappearing into an
757
+ apparently complete result.
758
+
759
+ The complete built-in path is available without writing TypeScript:
760
+
761
+ ```bash
762
+ # Call another A2A Agent
763
+ kodax a2a add research https://agent.example/.well-known/agent-card.json --effect read
764
+ kodax a2a test research
765
+ kodax a2a call research "Summarize this topic"
766
+
767
+ # Stage an OAuth-protected Agent, then hot-activate/deactivate it
768
+ export RESEARCH_A2A_CLIENT_SECRET='provisioned-by-your-authorization-server'
769
+ # PowerShell: $env:RESEARCH_A2A_CLIENT_SECRET='provisioned-by-your-authorization-server'
770
+ # PowerShell: run the command on one line or replace each trailing \ with a backtick.
771
+ kodax a2a add reviewer https://reviewer.example/.well-known/agent-card.json \
772
+ --disabled --effect read --oauth-scheme enterprise-oauth \
773
+ --oauth-issuer https://identity.example/ \
774
+ --oauth-token-url https://identity.example/oauth/token \
775
+ --oauth-client-id kodax-reviewer \
776
+ --oauth-client-secret-env RESEARCH_A2A_CLIENT_SECRET \
777
+ --oauth-scope a2a.invoke --oauth-resource https://reviewer.example/
778
+ kodax a2a enable reviewer
779
+ kodax a2a disable reviewer # blocks new dispatch; does not cancel in-flight tasks
780
+
781
+ # Expose the Runtime default Agent, or pass a name from ~/.kodax/agents/*.md
782
+ export KODAX_A2A_TOKEN='replace-with-a-long-random-token'
783
+ # PowerShell: $env:KODAX_A2A_TOKEN='replace-with-a-long-random-token'
784
+ kodax a2a expose # or: kodax a2a expose document-agent
785
+ kodax a2a serve # loopback http://127.0.0.1:8765
786
+ ```
787
+
637
788
  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
+ `~/.kodax/integrations/`. Use `kodax config paths`,
790
+ `kodax config template <core|mcp|a2a|extensions>`,
791
+ `kodax integrations migrate --apply`, and the `kodax mcp`, `kodax a2a`, or
792
+ `kodax extensions` commands to manage them. Migration imports only legacy
793
+ `config.json#mcpServers` and `config.json#extensions`; A2A has no legacy source.
794
+ It never overwrites an existing destination. The first MCP/Extension mutation
795
+ can stage legacy entries. Remove legacy keys only with
796
+ `--apply --cleanup-legacy`, after reviewing destination files and
797
+ literal-secret warnings. Running
798
+ CLI/daemon hosts retain the
799
+ last valid revision, atomically replace the complete MCP provider, reconcile
800
+ Extensions per entry, and hot-register outbound A2A Agents. Each A2A entry has
801
+ a desired `enabled` switch; `kodax a2a list` shows configuration, while the
802
+ owning Runtime is authoritative for live applied registrations. Disabled
803
+ entries are not fetched during automatic reconciliation and, after the owning
804
+ Runtime applies the revision, cannot accept new dispatch. The mutation command
805
+ itself is not cross-process acknowledgement. `a2a add --disabled` still checks
806
+ the Card by default unless `--no-test` is supplied, while `a2a test` performs
807
+ discovery/security planning without requesting an OAuth token. The fixed
808
+ `KODAX_A2A_TOKEN` example is an operator-provisioned compatibility credential;
809
+ KodaX does not generate or issue it. Disabled entries remain available for
810
+ later re-enable. `a2a serve` loads
811
+ its configured MCP/Extension capability surface before listening and pins that
812
+ execution authority; it hot-reloads publication, authentication, and limits.
813
+
814
+ A2A configuration migration and retained task ownership are separate. If a
815
+ v0.7.70 task store must remain addressable after the realm-aware upgrade, stop
816
+ the A2A server, run `kodax a2a migrate-tasks` to inspect the exact-owner plan,
817
+ then apply it with `--apply --confirm-server-stopped`. OAuth migration also
818
+ requires the known historical `--subject`; normal serving never guesses or
819
+ dual-reads a legacy owner key.
820
+
821
+ Agent, Skill, Extension-tool authority, workspace, tool-policy, or task-store
822
+ changes require an explicit server restart. Managed
823
+ A2A contexts default to `~/kodax_a2a_server_workspace/<runtime-profile>/contexts/`.
824
+ Exact Skill scripts require the opt-in isolated policy and a passing
825
+ `kodax sandbox doctor` (`kodax sandbox setup` performs the explicit Windows
826
+ one-time provisioning).
827
+
828
+ ---
829
+
830
+ ## Features
831
+
832
+ - **Modular Architecture** - Use as CLI, as a library, or as a Node-free single binary
833
+ - **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
834
+ - **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
835
+ - **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=...)`.
836
+ - **Reasoning Effort** - Effort-first control (`off/auto/low/medium/high` plus model-supported extras) across providers
837
+ - **Streaming Output** - Real-time response display
838
+ - **Session Management** - JSONL format with branchable session lineage tree
839
+ - **Skills System** - Natural language triggering, extensible, role-projected in AMA
840
+ - **Repo Intelligence** - Built-in full/light repository intelligence with native KodaX auto-injection lane
841
+ - **Rich Tool Surface** - 50+ built-in tools across file ops, shell, search, repo intelligence, MCP capabilities, git worktree, and agent control
842
+ - **Permission Control** - 3 permission modes with pattern-based control
843
+ - **Standalone Binary** - `bun --compile` releases for Win/macOS/Linux x64+arm64, no Node.js required on target machines
844
+ - **Cross-Platform** - Windows/macOS/Linux
845
+ - **TypeScript Native** - Full type safety and IDE support
846
+
847
+ ---
848
+
849
+ ## Installation
850
+
851
+ ### As CLI Tool
852
+
853
+ ```bash
854
+ # Clone repository
855
+ git clone https://github.com/icetomoyo/KodaX.git
856
+ cd KodaX
857
+
858
+ # Install dependencies (includes workspace packages)
859
+ npm install
860
+
861
+ # Build the monorepo
862
+ npm run build
863
+
864
+ # Link globally (development mode)
865
+ npm link
866
+
867
+ # Now you can use 'kodax' anywhere
868
+ kodax "your task"
869
+ ```
870
+
871
+ ### As Standalone Binary (no Node required on target)
872
+
873
+ 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.
874
+
875
+ Supported targets: `win-x64`, `linux-x64`, `linux-arm64`, `darwin-x64`, `darwin-arm64`. Win7 / pre-glibc-2.27 distros / LoongArch are not supported.
876
+
877
+ **Build locally**:
878
+
879
+ ```bash
880
+ # Install Bun once on your build machine
881
+ npm i -g bun # or scoop/brew/curl install — see docs/release.md
882
+
883
+ npm run build:binary # Current host platform (fastest)
884
+ npm run build:binary:all # All five targets in sequence
885
+ node scripts/build-binary.mjs --target=linux-arm64 # Specific target
886
+ ```
887
+
888
+ Output lives under `dist/binary/<target>/`:
889
+
890
+ ```
891
+ dist/binary/linux-x64/
892
+ ├── kodax # ~60 MB Bun-compiled executable
893
+ ├── builtin/ # Sidecar built-in skills
894
+ ├── provider-capabilities.json
895
+ ├── semantic-worker.js # Repo-intelligence Worker
896
+ ├── runtime-worker.js # SDK Runtime Worker
897
+ └── constructed-handler-worker.js # Constructed-tool Worker
898
+ ```
899
+
900
+ Smoke-test: `dist/binary/<host>/kodax --version`.
901
+
902
+ **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.
903
+
904
+ 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.
905
+
906
+ ### As Library
907
+
908
+ ```bash
909
+ npm install @kodax-ai/kodax
910
+ ```
911
+
912
+ ```typescript
913
+ import { runKodaX } from '@kodax-ai/kodax';
914
+
915
+ process.env.ZHIPU_API_KEY = process.env.ZHIPU_API_KEY ?? 'your_api_key';
916
+
917
+ const result = await runKodaX({
918
+ provider: 'zhipu-coding',
919
+ effort: 'auto',
920
+ events: {
921
+ onTextDelta: (text) => process.stdout.write(text),
922
+ onComplete: () => console.log('\nDone!'),
923
+ },
924
+ }, 'your task');
925
+
926
+ console.log(result.lastText);
927
+ ```
928
+
929
+ #### SDK Subpath Imports (v0.7.39+)
930
+
931
+ For smaller surface and tree-shake-friendly imports, the SDK is also exposed via subpath exports — pick only the package(s) you need:
932
+
933
+ ```typescript
934
+ import { Runner } from '@kodax-ai/kodax/agent'; // agent runtime
935
+ import { getProvider } from '@kodax-ai/kodax/llm'; // LLM abstraction (16 aliases)
936
+ import { runKodaX } from '@kodax-ai/kodax/coding'; // coding tools + prompts
937
+ import { createImageArtifactFromPath } from '@kodax-ai/kodax/media'; // input artifacts
938
+ import { SkillRegistry } from '@kodax-ai/kodax/skills'; // zero-dep skill loader
939
+ import { loadConfig } from '@kodax-ai/kodax/repl'; // REPL config / session helpers
940
+ import { createMcpManager } from '@kodax-ai/kodax/mcp'; // MCP popout manager (v0.7.42)
789
941
  import { listSessions } from '@kodax-ai/kodax/session'; // session history helpers
790
942
  import { createKodaXRuntime } from '@kodax-ai/kodax/runtime'; // embedded/daemon runtime API
943
+ import { runKodaXSandboxed } from '@kodax-ai/kodax/sandbox'; // standalone ASRT containment
791
944
  import { createKodaXA2AServer } from '@kodax-ai/kodax/a2a'; // A2A 1.0 client/server edge
945
+ import { createMemoryAgent } from '@kodax-ai/kodax/experimental-memory'; // opt-in memory SDK
792
946
  ```
793
947
 
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
948
+ All 13 SDK entries (root + 12 subpaths) share internal code via ESM chunk splitting — importing from `/agent` does not pull in `/repl`'s Ink + React surface.
949
+
950
+ For the complete host-facing contract — including embedded/Worker/daemon ownership,
951
+ external-agent registration and task control, session cursor pagination, workflow
952
+ model-tier routing, and efficiency telemetry — see the
953
+ [SDK Embedder Integration Guide](docs/SDK_EMBEDDER_GUIDE.md).
954
+
955
+ > **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.
956
+
957
+ 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.
958
+
959
+ ---
960
+
961
+ ## Usage
962
+
963
+ ### REPL Quickstart
964
+
965
+ Running `kodax` with no prompt starts the interactive REPL.
966
+
967
+ ```bash
968
+ kodax
969
+ ```
970
+
971
+ Inside the REPL you can type normal requests or slash commands:
972
+
973
+ ```text
974
+ Read package.json and summarize the architecture
975
+ /model
976
+ /mode
977
+ /help
978
+ ```
979
+
980
+ ### CLI Quickstart
981
+
982
+ ```bash
983
+ # Set API key
984
+ export ZHIPU_API_KEY=your_api_key
985
+
986
+ # Basic usage
987
+ kodax "Help me create a TypeScript project"
988
+
989
+ # Choose a provider explicitly
990
+ kodax --provider openai --model gpt-5.4 "Create a REST API"
991
+
992
+ # Use higher reasoning effort
993
+ kodax --effort high "Review this architecture"
994
+ ```
995
+
996
+ ### Session Workflows
997
+
998
+ Use a session when you want memory across turns. Without a session, each CLI call is independent.
999
+
1000
+ ```bash
1001
+ # No memory: two separate calls
1002
+ kodax "Read src/auth.ts"
1003
+ kodax "Summarize it"
1004
+
1005
+ # With memory: same session
1006
+ kodax --session my-project "Read package.json"
1007
+ kodax --session my-project "Summarize it"
1008
+ kodax --session my-project "How should I fix the first issue?"
1009
+
1010
+ # Session management
1011
+ kodax -r # Search, page, and select a non-empty session
1012
+ kodax -r <session-id> # Resume a known session directly
1013
+ kodax -r "Review runtime" # Resume a unique exact title; duplicates open the picker
1014
+ kodax --session list # List up to 50 non-empty sessions
1015
+ kodax --session cleanup-acp # Preview strictly matched empty ACP-test pollution
1016
+ ```
1017
+
1018
+ Bare `-r` opens an interactive picker with incremental search, arrow/PageUp/PageDown
1019
+ navigation, Tab completion, full selected-session ID display, and Enter-to-resume.
1020
+ An explicit value checks the complete session ID first, then an exact
1021
+ case-insensitive title; duplicate titles open a narrowed picker instead of
1022
+ silently choosing one. The picker loads before the full CLI, so session listing
1023
+ remains responsive. After selection it hands terminal input to the resumed
1024
+ REPL; Esc releases the picker's stdin ownership and immediately returns to the
1025
+ invoking shell. Session replay preserves each recorded message/event timestamp.
1026
+
1027
+ Cleanup is preview-only unless
1028
+ `--apply-session-cleanup` is also provided; matching sessions are archived rather
1029
+ than permanently deleted.
1030
+
1031
+ ### Session Patterns
1032
+
1033
+ ```bash
1034
+ # ❌ No memory: two independent calls
1035
+ kodax "Read src/auth.ts" # Agent reads and responds
1036
+ kodax "Summarize it" # Agent doesn't know what to summarize
1037
+
1038
+ # ✅ With memory: same session
1039
+ kodax --session auth-review "Read src/auth.ts"
1040
+ kodax --session auth-review "Summarize it" # Agent knows to summarize auth.ts
1041
+ kodax --session auth-review "How to fix first issue" # Agent has context
1042
+ ```
1043
+
1044
+ ### Workflow Examples
1045
+
1046
+ ```bash
1047
+ # Code review (multi-turn conversation)
1048
+ kodax --session review "Review src/ directory"
1049
+ kodax --session review "Focus on security issues"
1050
+ kodax --session review "Give me fix suggestions"
1051
+
1052
+ # Project development (continuous session)
1053
+ kodax --session todo-app "Create a Todo application"
1054
+ kodax --session todo-app "Add delete functionality"
1055
+ kodax --session todo-app "Write tests"
1056
+ ```
1057
+
1058
+ ### CLI Reference
1059
+
1060
+ ```text
1061
+ kodax Start the interactive REPL
1062
+ -h, --help [topic] Show help or topic help
1063
+ -p, --print <text> Run a single task and exit
1064
+ -c, --continue Continue the most recent non-empty conversation in this directory
1065
+ -r, --resume [value] Resume by ID/exact title, or open the searchable picker
1066
+ -m, --provider Provider to use
1067
+ --model <name> Override the model
1068
+ --reasoning <mode> off | auto | quick | balanced | deep
1069
+ -t, --thinking Compatibility alias for --reasoning auto
1070
+ -s, --session <op> Session ID or legacy session operation
1071
+ -j, --parallel Enable parallel tool execution
1072
+ --max-iter <n> Max iterations
1073
+ ```
1074
+
1075
+ ### Permission Control
1076
+
1077
+ KodaX provides 3 permission modes for fine-grained control:
1078
+
1079
+ | Mode | Description | Tools Need Confirmation |
1080
+ |------|-------------|------------------------|
1081
+ | `plan` | Read-only planning mode | All modification tools blocked |
1082
+ | `accept-edits` | Auto-accept file edits | bash only |
1083
+ | `auto` | Runtime-owned LLM/rules classification within the project boundary | Only explicit classifier escalation |
1084
+
1085
+ ```bash
1086
+ # In REPL, use /mode command
1087
+ /mode plan # Switch to plan mode (read-only)
1088
+ /mode accept-edits # Switch to accept-edits mode
1089
+ /mode auto # Switch to Runtime-owned Auto Mode
1090
+ /auto # Alias for auto
1091
+
1092
+ # Check current mode
1093
+ /mode
1094
+ ```
1095
+
1096
+ **Features:**
1097
+ - In `accept-edits` mode, choosing "always" can persist safe Bash allow-patterns
1098
+ - Plan mode includes system prompt context for LLM awareness
1099
+ - Sensitive/protected or unresolved targets enter Auto[LLM]/approval review;
1100
+ ordinary reads outside the project are allowed
1101
+ - Pattern-based permission: Allow specific Bash commands (e.g., `Bash(npm install)`)
1102
+ - Unified diff display for write/edit operations
1103
+ - Auto Mode first admits exactly modeled safe reads and workspace/temp
1104
+ mutations without classifier latency. Remaining actions are reviewed against
1105
+ bounded user intent and exact operation facts; a safe verdict creates no
1106
+ pending approval request. Classifier failures retry once, then use the
1107
+ Accept-edits safety boundary rather than silently switching to Auto[rules].
1108
+ - Shift-Tab cycles `Plan -> Edits -> Auto`; Shift+Enter inserts a newline. Auto
1109
+ immediately displays `Auto[LLM]` or `Auto[RULES]`, and rapid mode changes are
1110
+ persisted in input order. `Auto[RULES]` remains an explicit/manual engine;
1111
+ use `/auto-engine llm` to select LLM classification.
1112
+ - Runtime-backed prompts can offer exact `allow once`, `allow this session`,
1113
+ and `always allow` choices. Return the Runtime-issued opaque suggestion;
1114
+ never derive or widen a permission rule from the displayed command or path.
1115
+ Persistent grants are daemon-owned, revisioned, and can be listed/revoked
1116
+ through `runtime.permissions` by an authorized SDK host. Dynamic shell
1117
+ commands deliberately receive no persistent-grant suggestion.
1118
+
1119
+ `kodax -c` skips zero-message ACP/bootstrap placeholders even when they are
1120
+ newer than the last real conversation. The same newest non-empty rule applies
1121
+ to Ink, classic, one-shot CLI, and coding-runtime auto-resume; an explicit
1122
+ session ID always wins. Interactive resume also restores the saved workspace
1123
+ runtime before relative shell commands or the next model turn.
1124
+
1125
+ ### CLI Help Topics
1126
+
1127
+ Get detailed help for specific topics:
1128
+
1129
+ ```bash
1130
+ # Basic help
1131
+ kodax -h
1132
+ kodax --help
1133
+
1134
+ # Detailed topic help
1135
+ kodax -h sessions # Session management details
1136
+ kodax -h init # Long-running project initialization
1137
+ kodax -h project # Project mode / harness workflow
1138
+ kodax -h auto # Auto-continue mode
1139
+ kodax -h provider # LLM provider configuration
1140
+ kodax -h thinking # Thinking/reasoning effort and compatibility modes
1141
+ kodax -h team # Multi-agent parallel execution
1142
+ kodax -h print # Print configuration
1143
+ ```
1144
+
1145
+ ### Environment Variables
1146
+
1147
+ 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_`.
1148
+
1149
+ #### `KODAX_MAX_OUTPUT_TOKENS`
1150
+
1151
+ 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.
1152
+
1153
+ ```bash
1154
+ # Allow up to 48K output tokens per turn (use a higher cap when generating long files)
1155
+ export KODAX_MAX_OUTPUT_TOKENS=48000
1156
+ kodax "generate the full implementation"
1157
+
1158
+ # Unset to restore default behavior
1159
+ unset KODAX_MAX_OUTPUT_TOKENS
1160
+ ```
1161
+
1162
+ Precedence used by every provider's `getEffectiveMaxOutputTokens()` (see `packages/llm/src/providers/base.ts`):
1163
+
1164
+ 1. One-shot per-request override (agent-loop escalation / context-overflow recovery — internal)
1165
+ 2. **`KODAX_MAX_OUTPUT_TOKENS`** (this variable, explicit user intent)
1166
+ 3. Active model descriptor's `maxOutputTokens` (FEATURE_098 per-model cap)
1167
+ 4. Provider config default
1168
+ 5. Global `KODAX_MAX_TOKENS` fallback
1169
+
1170
+ 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`).
1171
+
1172
+ > **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.
1173
+
1174
+ #### Sidecar verifier diagnostics
1175
+
1176
+ Use these when diagnosing Worker text-only completion stalls or custom provider verifier behavior:
1177
+
1178
+ ```bash
1179
+ export KODAX_VERIFIER_LOG=1
1180
+ export KODAX_VERIFIER_PROVIDER=anthropic
1181
+ export KODAX_VERIFIER_MODEL=claude-haiku-4-5-20251001
1182
+ ```
1183
+
1184
+ - `KODAX_VERIFIER_LOG=1` shows verifier gate/elapsed/trace information and is equivalent to `"verifierLog": true` in `~/.kodax/config.json`.
1185
+ - `KODAX_VERIFIER_PROVIDER` + `KODAX_VERIFIER_MODEL` route the verifier to a separate provider/model instead of inheriting the main Worker model. Set both together.
1186
+ - `KODAX_VERIFIER_ALWAYS=1` forces the verifier to fire on every text-only completion for debugging/regression sweeps.
1187
+
1188
+ SDK/headless hosts can observe actionable Sidecar Verifier messages via
1189
+ `KodaXEvents.onSidecarMessage`; JSONL output emits the same payload as
1190
+ `sidecar.message`. Only `revise` and `blocked` verdicts are surfaced; `accept`
1191
+ stays silent.
1192
+
1193
+ ## Advanced Library Usage
1194
+
1195
+ #### Simple Mode (runKodaX)
1196
+
1197
+ ```typescript
1198
+ import { runKodaX, KodaXEvents } from '@kodax-ai/kodax';
1199
+
1200
+ const events: KodaXEvents = {
1201
+ onTextDelta: (text) => process.stdout.write(text),
1202
+ onThinkingDelta: (text) => console.log(`Thinking delta: ${text.length} chars`),
1203
+ onToolResult: (result) => console.log(`Tool ${result.name}: ${result.content.slice(0, 100)}`),
1204
+ onSidecarMessage: (event) => console.log(`[sidecar:${event.verdict}] ${event.content}`),
1205
+ onComplete: () => console.log('\nDone!'),
1206
+ onError: (e) => console.error(e.message),
1207
+ };
1208
+
1209
+ const result = await runKodaX({
1210
+ provider: 'zhipu-coding',
1211
+ effort: 'auto',
1212
+ events,
1213
+ }, 'What is 1+1?');
1214
+
1215
+ console.log(result.lastText);
1216
+ ```
1217
+
1218
+ #### Continuous Session (KodaXClient)
1219
+
1220
+ ```typescript
1221
+ import { KodaXClient } from '@kodax-ai/kodax';
1222
+
1223
+ const client = new KodaXClient({
1224
+ provider: 'zhipu-coding',
1225
+ effort: 'auto',
1226
+ events: {
1227
+ onTextDelta: (t) => process.stdout.write(t),
1228
+ },
1229
+ });
1230
+
1231
+ // First message
1232
+ await client.send('Read package.json');
1233
+
1234
+ // Continue same session
1235
+ await client.send('Summarize it');
1236
+
1237
+ console.log(client.getSessionId());
1238
+ ```
1239
+
1240
+ #### Custom Session Storage
1241
+
1242
+ ```typescript
1243
+ import { runKodaX, KodaXSessionStorage, KodaXMessage } from '@kodax-ai/kodax';
1244
+
1245
+ class MyDatabaseStorage implements KodaXSessionStorage {
1246
+ async save(id: string, data: { messages: KodaXMessage[]; title: string; gitRoot: string }) {
1247
+ // Save to your database
1248
+ }
1249
+ async load(id: string) {
1250
+ // Load from your database
1251
+ return null;
1252
+ }
1253
+ }
1254
+
1255
+ await runKodaX({
1256
+ provider: 'zhipu-coding',
1257
+ session: {
1258
+ id: 'my-session-123',
1259
+ storage: new MyDatabaseStorage(),
1260
+ },
1261
+ events: { ... },
1262
+ }, 'task');
1263
+ ```
1264
+
1265
+ ### Library Modes Comparison
1266
+
1267
+ | Feature | runKodaX | KodaXClient |
1268
+ |---------|----------|-------------|
1269
+ | **Message Memory** | No | Yes |
1270
+ | **Call Style** | Function | Class instance |
1271
+ | **Context** | Independent each time | Accumulates |
1272
+ | **Use Case** | Single tasks, batch processing | Interactive dialogue, multi-step tasks |
1273
+
1274
+ ---
1275
+
1276
+ ## SDK Usage
1277
+
1278
+ KodaX ships as a single npm package `@kodax-ai/kodax` with 12 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` + v0.7.78 `/sandbox`). Each subpath is tree-shake-friendly so consumers pull only what they need:
1279
+
1280
+ ```bash
1281
+ npm install @kodax-ai/kodax
1282
+ ```
1283
+
1284
+ ```typescript
1285
+ import { runKodaX } from '@kodax-ai/kodax'; // root: CLI helpers + runKodaX
1286
+ import { Runner, runFanOut } from '@kodax-ai/kodax/agent'; // generic Agent framework
1287
+ import { getProvider } from '@kodax-ai/kodax/llm'; // 16-alias LLM abstraction
1288
+ import { KODAX_TOOLS } from '@kodax-ai/kodax/coding'; // tools + prompts + agent loop
1289
+ import { createImageArtifactFromPath } from '@kodax-ai/kodax/media'; // input artifact helpers
1290
+ import { runInkInteractiveMode } from '@kodax-ai/kodax/repl'; // Ink TUI entrypoint
1291
+ import { SkillRegistry } from '@kodax-ai/kodax/skills'; // zero-dep skill loader
1135
1292
  import { createMcpManager } from '@kodax-ai/kodax/mcp'; // MCP popout manager (v0.7.42)
1136
1293
  import { listSessions } from '@kodax-ai/kodax/session'; // session history helpers
1137
1294
  import { createKodaXRuntime } from '@kodax-ai/kodax/runtime'; // embedded/daemon runtime API
1295
+ import { runKodaXSandboxed } from '@kodax-ai/kodax/sandbox'; // explicit standalone containment
1138
1296
  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
-
1297
+ import { createMemoryAgent } from '@kodax-ai/kodax/experimental-memory'; // opt-in experimental memory SDK
1298
+ ```
1299
+
1300
+ > 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).
1301
+
1302
+ ### `@kodax-ai/kodax/llm` — LLM Abstraction
1303
+
1304
+ 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.
1305
+
1306
+ ```typescript
1307
+ import { getProvider, KodaXBaseProvider } from '@kodax-ai/kodax/llm';
1308
+
1309
+ const provider = getProvider('anthropic');
1310
+ const stream = await provider.streamCompletion(
1311
+ [{ role: 'user', content: 'Hello!' }],
1312
+ { onTextDelta: (text) => process.stdout.write(text) }
1313
+ );
1314
+
1315
+ for await (const result of stream) {
1316
+ if (result.type === 'text') { /* … */ }
1317
+ else if (result.type === 'tool_use') { /* … */ }
1318
+ }
1319
+ ```
1320
+
1321
+ **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.
1322
+
1323
+ ### `@kodax-ai/kodax/agent` — Agent Framework (standalone-consumable)
1324
+
1325
+ ADR-021 standalone-consumable: `@kodax-ai/agent` has **zero inbound `@kodax-ai/coding` dependency** — you can wire any tool surface on top of it.
1326
+
1327
+ ```typescript
1328
+ import {
1329
+ Runner,
1330
+ runFanOut,
1331
+ runWithIdleYield,
1332
+ createAgentActorController,
1333
+ generateSessionId,
1334
+ estimateTokens,
1335
+ DefaultSummaryCompaction,
1336
+ } from '@kodax-ai/kodax/agent';
1337
+
1338
+ // Bounded-concurrency fan-out with abort + structured progress events (v0.7.39 FEATURE_120)
1339
+ const result = await runFanOut({
1340
+ bundles: [{ id: 'a', task: 'audit-foo' }, { id: 'b', task: 'audit-bar' }],
1341
+ maxParallel: 4,
1342
+ run: async (bundle) => doWork(bundle),
1343
+ });
1344
+
1345
+ // Runtime-owned Actor identity tree (inject an executor before starting Turns)
1346
+ const actors = await createAgentActorController();
1347
+ const tree = actors.list('/root');
1348
+
1349
+ // Pluggable compaction policy (FEATURE_081)
1350
+ const policy = new DefaultSummaryCompaction({ thresholdRatio: 0.8, keepRecent: 10 });
1351
+ ```
1352
+
1353
+ `DefaultSummaryCompaction` is a standalone agent-layer primitive for custom
1354
+ loops. It does not replace or disable KodaX's always-on coding-runtime policy
1355
+ described under FEATURE_272 above.
1356
+
1357
+ **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.
1358
+
1359
+ ### `@kodax-ai/kodax/skills` — Skills System
1360
+
1361
+ Zero external dependencies. Markdown-based skill files with natural-language triggers and variable resolution.
1362
+
1363
+ ```typescript
1364
+ import {
1365
+ SkillRegistry,
1366
+ discoverSkills,
1367
+ executeSkill,
1368
+ type SkillContext,
1369
+ } from '@kodax-ai/kodax/skills';
1370
+
1371
+ const skills = await discoverSkills(['/path/to/skills']);
1372
+ const registry = new SkillRegistry();
1373
+ await registry.registerSkills(skills);
1374
+
1375
+ const result = await executeSkill({
1376
+ skillId: 'code-review',
1377
+ arguments: { target: 'src/' },
1378
+ workingDirectory: process.cwd(),
1379
+ });
1380
+ ```
1381
+
1382
+ **Key Features**: zero deps · markdown-based skill files · natural-language triggering · variable resolution · built-in skills included.
1383
+
1384
+ ### `@kodax-ai/kodax/coding` — Coding Agent
1385
+
1386
+ 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.
1387
+
1388
+ ```typescript
1389
+ import { runKodaX, KodaXClient, KODAX_TOOLS } from '@kodax-ai/kodax/coding';
1390
+
1391
+ // Single-task helper
1392
+ const result = await runKodaX({
1393
+ provider: 'zhipu-coding',
1394
+ effort: 'auto',
1395
+ events: { onTextDelta: (text) => process.stdout.write(text) },
1396
+ }, 'Read package.json and explain the dependencies');
1397
+
1398
+ // Continuous session
1399
+ const client = new KodaXClient({
1400
+ provider: 'anthropic',
1401
+ effort: 'auto',
1402
+ events: { /* … */ },
1403
+ });
1404
+ await client.send('Create a new file');
1405
+ await client.send('Add a function to it'); // Has context from previous message
1406
+ ```
1407
+
1408
+ **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.
1409
+
1410
+ ### `@kodax-ai/kodax/repl` — Interactive Terminal UI
1411
+
1412
+ Ink/React-based interactive REPL. Permission modes, command system, themed streaming display.
1413
+
1414
+ ```typescript
1415
+ import { runInkInteractiveMode } from '@kodax-ai/kodax/repl';
1416
+
1417
+ // Usually used via the `kodax` bin command; can be embedded:
1418
+ // - Interactive terminal UI (Ink components)
1419
+ // - Permission control (auto/plan/accept-edits modes)
1420
+ // - Command system (/help, /mode, /clear, /status, …)
1421
+ // - Skills integration
1422
+ // - Theme support
1423
+ await runInkInteractiveMode({ provider: 'zhipu-coding', effort: 'auto' });
1424
+ ```
1425
+
1426
+ **Key Features**: Ink-based React components · 3 permission modes (auto / plan / accept-edits) · built-in commands · real-time streaming display · context-usage indicator.
1427
+
1428
+ ### Package Dependency Graph (workspace internal)
1429
+
1430
+ ```
1431
+ @kodax-ai/llm (zero business-logic deps)
1432
+
1433
+ @kodax-ai/agent (depends @kodax-ai/llm; ADR-021 standalone-consumable;
1434
+ inlines session-lineage + capabilities/{mcp,skills} +
1435
+ tracing per ADR-036 v0.7.43)
1436
+
1437
+ @kodax-ai/coding (depends llm + agent; inlines repo-intelligence/protocol per ADR-036)
1438
+
1439
+ @kodax-ai/repl (depends coding + ink + react)
1440
+ ```
1441
+
1442
+ **Subpath Recommendations**:
1443
+
1444
+ | Use Case | Subpath | Why |
1445
+ |----------|---------|-----|
1446
+ | Only need LLM abstraction | `@kodax-ai/kodax/llm` | Minimal deps; 16 built-in aliases |
1447
+ | Building custom agent | `@kodax-ai/kodax/agent` | Runner + fan-out + idle-yield + session-lineage + capabilities |
1448
+ | Coding tasks | `@kodax-ai/kodax/coding` | Complete coding agent + tools |
1449
+ | Terminal app | `@kodax-ai/kodax/repl` | Full interactive experience |
1450
+ | Runtime host / daemon client | `@kodax-ai/kodax/runtime` | Sessions, runs, events, permissions, catalog, MCP, artifacts, diagnostics |
1451
+ | Experimental governed memory | `@kodax-ai/kodax/experimental-memory` | Scoped `MemoryAgent` / `MemorySession` recall and outcome contracts |
1452
+
1453
+ ---
1454
+
1455
+ | Provider | Environment Variable | Reasoning Support | Default Model |
1456
+ |----------|----------------------|-------------------|---------------|
1457
+ | anthropic | `ANTHROPIC_API_KEY` | Native | claude-sonnet-4-6 (`claude-opus-4-6` / `claude-haiku-4-5` via `/model`) |
1458
+ | openai | `OPENAI_API_KEY` | Native | gpt-5.3-codex (`gpt-5.4` / `gpt-5.3-codex-spark` via `/model`) |
1459
+ | 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`) |
1460
+ | 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`) |
1461
+ | qwen | `QWEN_API_KEY` | Native | qwen3.5-plus |
1462
+ | 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) |
1463
+ | zhipu | `ZHIPU_API_KEY` | Native | glm-5 (`glm-5.2` 1M ctx / `glm-5.1` / `glm-5-turbo` via `/model`) |
1464
+ | zhipu-coding | `ZHIPU_CODING_API_KEY` | Native | glm-5.2 (1M ctx; legacy `glm-5.1` and `glm-5-turbo` remain selectable via `/model`) |
1465
+ | 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) |
1466
+ | 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`) |
1467
+ | mimo | `MIMO_API_KEY` | Native | mimo-v2.5-pro (Xiaomi MiMo pay-per-token, Anthropic-compat) |
1468
+ | mimo-coding | `MIMO_CODING_API_KEY` | Native | mimo-v2.5-pro (Xiaomi Token Plan, Anthropic-compat) |
1469
+ | 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) |
1470
+ | deepseek | `DEEPSEEK_API_KEY` | Native | deepseek-v4-flash (`deepseek-v4-pro` via `/model`) |
1471
+ | gemini-cli | Provider CLI authentication (no KodaX API-key variable) | Prompt-only / CLI bridge | (via gemini CLI) |
1472
+ | codex-cli | Provider CLI authentication (no KodaX API-key variable) | Prompt-only / CLI bridge | (via codex CLI) |
1473
+
1474
+ > **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.
1475
+
1476
+ ### Examples
1477
+
1478
+ ```bash
1479
+ # Use Zhipu Coding
1480
+ kodax --provider zhipu-coding --thinking "Help me optimize this code"
1481
+
1482
+ # Use OpenAI
1483
+ export OPENAI_API_KEY=your_key
1484
+ kodax --provider openai "Create a REST API"
1485
+
1486
+ # Resume last session
1487
+ kodax --session resume
1488
+
1489
+ # List all sessions
1490
+ kodax --session list
1491
+
1492
+ # Parallel tool execution
1493
+ kodax --parallel "Read package.json and tsconfig.json"
1494
+
1495
+ # Adaptive multi-agent (AMA) mode — V2 Worker single-loop with Actor collaboration
1496
+ kodax --agent-mode ama "Analyze code structure, check test coverage, find bugs"
1497
+ ```
1498
+
1499
+ ---
1500
+
1501
+ ## Tools
1502
+
1503
+ 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.
1504
+
1505
+ ### File operations
1506
+ | Tool | Description |
1507
+ |------|-------------|
1508
+ | `read` | Read file contents (supports offset/limit) |
1509
+ | `write` | Write a new file or fully rewrite an existing one |
1510
+ | `edit` | Exact string replacement (supports `replace_all`) |
1511
+ | `multi_edit` | Atomic batch of independent edits to one file |
1512
+ | `insert_after_anchor` | Insert content after a unique anchor without rewriting the file |
1513
+ | `undo` | Revert the last file modification |
1514
+
1515
+ ### Shell & search
1516
+ | Tool | Description |
1517
+ |------|-------------|
1518
+ | `bash` | Execute a shell command (supports `run_in_background`; complete capture with recoverable capacity fallback) |
1519
+ | `glob` | Find files by pattern |
1520
+ | `grep` | Regex content search (context lines, multiline, file-type filter, pagination) |
1521
+ | `code_search` | Lower-noise code search (extension-provider aware) |
1522
+ | `semantic_lookup` | Symbol/module/process-aware search backed by repo intelligence |
1523
+ | `web_search` | Discovery-oriented web search with trust + freshness signals |
1524
+ | `web_fetch` | Fetch a specific URL with provenance hints |
1525
+
1526
+ ### Repo Intelligence (working tools)
1527
+ | Tool | Description |
1528
+ |------|-------------|
1529
+ | `repo_overview` | Summarize structure, key areas, entry hints, intelligence snapshot |
1530
+ | `changed_scope` | Which files/areas/categories the current diff touches |
1531
+ | `changed_diff` | Paged diff slice for a single file |
1532
+ | `changed_diff_bundle` | Paged diff slices for multiple files in one call |
1533
+ | `module_context` | Module capsule (deps, entries, symbols, tests, docs) |
1534
+ | `symbol_context` | Definition + probable callers/callees + alternatives |
1535
+ | `process_context` | Approximate static execution capsule for an entry |
1536
+ | `impact_estimate` | Blast radius for a symbol/path/module |
1537
+
1538
+ ### MCP capabilities (when MCP servers are configured)
1539
+ | Tool | Description |
1540
+ |------|-------------|
1541
+ | `mcp_search` / `mcp_describe` / `mcp_call` | Discover and invoke MCP tools through the shared capability runtime |
1542
+ | `mcp_read_resource` / `mcp_get_prompt` | Read MCP resources and prompts |
1543
+
1544
+ ### Git worktree
1545
+ | Tool | Description |
1546
+ |------|-------------|
1547
+ | `worktree_create` | Create a new worktree on an isolated branch for safe agent work |
1548
+ | `worktree_remove` | Remove a worktree (with safety checks) |
1549
+
1550
+ ### Agent control & UX
1551
+ | Tool | Description |
1552
+ |------|-------------|
1553
+ | `spawn_agent` | Create a named child Actor and start its first Turn under inherited capabilities, session capacity, and root work budget. |
1554
+ | `send_message` | Commit bounded information to an Actor mailbox without starting a new Turn. |
1555
+ | `followup_task` | Join a running Actor at a safe boundary or atomically start a new Turn for an idle Actor. |
1556
+ | `wait_agent` | Yield on scoped mailbox/user/interruption/timeout activity; returns a wake acknowledgement and never uses Actor progress as a model wake source. |
1557
+ | `interrupt_agent` | Request interruption of an active Turn while preserving Actor identity. |
1558
+ | `list_agents` | Inspect the caller-visible Actor subtree and Turn states. |
1559
+ | `agent_output` | Read bounded durable output for an authorized Actor/Turn. |
1560
+ | `ask_user_question` | Single/multi-select or free-text prompt back to the user |
1561
+ | `exit_plan_mode` | Present a finalized plan only when the active REPL/host supplied an approval callback |
1562
+ | `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) |
1563
+ | `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). |
1564
+
1565
+ ---
1566
+
1567
+ ## Skills System
1568
+
1569
+ KodaX includes a built-in Skills system that can be triggered by natural language:
1570
+
1571
+ ```bash
1572
+ # Natural language triggering (no explicit /skill needed)
1573
+ kodax "帮我审查代码" # Triggers code-review skill
1574
+ kodax "写测试用例" # Triggers tdd skill
1575
+ kodax "提交代码" # Triggers git-workflow skill
1576
+
1577
+ # Explicit skill command
1578
+ kodax /skill:code-review
1579
+ ```
1580
+
1581
+ Built-in skills include:
1582
+ - **code-review** - Code review and quality analysis
1583
+ - **tdd** - Test-driven development workflow
1584
+ - **git-workflow** - Git commit and workflow automation
1585
+
1428
1586
  Skills are stored in `~/.kodax/skills/` and can be extended with custom skills.
1587
+ F263 background learning is Memory-first: a single correction does not create
1588
+ a Skill. Repeated independently verified evidence can create a low-risk,
1589
+ immutable project-scoped testing revision for at most three exact-revision
1590
+ uses. Promotion requires independently verified success. Use `/learn` to
1591
+ inspect, disable, rollback, trust, or reject learned revisions. Protected or
1592
+ formal Skills, user-global promotion, and Extension authoring remain explicit
1593
+ user actions.
1429
1594
 
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
1595
+ ### Promote a learned Skill to the user catalog
1487
1596
 
1488
- # Build standalone binary (current platform / all platforms)
1489
- npm run build:binary
1490
- npm run build:binary:all
1597
+ Automatic canary activation and user-catalog promotion are different:
1491
1598
 
1492
- # Run tests
1493
- npm test
1599
+ - independently verified canary success changes `testing` to
1600
+ `active_learned` inside the project-scoped Learned Area;
1601
+ - `/learn promote` is an explicit ownership transfer that copies one exact
1602
+ reviewed `ready` or `active_learned` revision into the formal user Skill
1603
+ catalog and changes its lifecycle to `promoted_user`.
1494
1604
 
1495
- # Eval-driven development tests (provider matrices, identity round-trip, etc.)
1496
- npm run test:eval
1605
+ Inspect the revision first, then promote it by name, slug, or exact capability
1606
+ ID:
1497
1607
 
1498
- # Clean
1499
- npm run clean
1608
+ ```text
1609
+ /learn show normalize-release-notes
1610
+ /learn promote normalize-release-notes --scope user
1500
1611
  ```
1501
1612
 
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.
1613
+ `--scope user` is the only supported scope and may be omitted. Invalid scopes,
1614
+ unknown options, duplicate scope options, and extra operands fail without
1615
+ changing the catalog. Promotion writes to the configured KodaX user Skill
1616
+ directory—normally `~/.kodax/skills/<slug>/SKILL.md`—and never overwrites
1617
+ different formal Skill content.
1518
1618
 
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 - 防抖避免闪烁` |
1619
+ Use `/learn promote --help`, `/learn help promote`, or
1620
+ `/help learn promote` for the dedicated command reference. In the Ink Learning
1621
+ Center, open `/learn`, select an `active_learned` Skill, and choose
1622
+ **Promote to user catalog**.
1535
1623
 
1536
1624
  ---
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.
1625
+
1626
+ ## Commands (CLI)
1627
+
1628
+ Commands are `/xxx` shortcuts in CLI:
1629
+
1630
+ ```bash
1631
+ kodax /review src/auth.ts
1632
+ kodax /test
1633
+ ```
1634
+
1635
+ Commands are stored in `~/.kodax/commands/`:
1636
+ - `.md` files → Prompt commands (content used as prompt)
1637
+ - `.ts/.js` files Programmable commands
1638
+
1639
+ ---
1640
+
1641
+ ## API Exports
1642
+
1643
+ ```typescript
1644
+ // Main functions
1645
+ export { runKodaX, KodaXClient };
1646
+
1647
+ // Types
1648
+ export type {
1649
+ KodaXEvents, KodaXOptions, KodaXResult,
1650
+ KodaXMessage, KodaXContentBlock,
1651
+ KodaXSessionStorage, KodaXToolDefinition
1652
+ };
1653
+
1654
+ // Tools
1655
+ export { KODAX_TOOLS, KODAX_TOOL_REQUIRED_PARAMS, executeTool };
1656
+
1657
+ // Providers
1658
+ export { getProvider, KODAX_PROVIDERS, KodaXBaseProvider };
1659
+
1660
+ // Utilities
1661
+ export {
1662
+ estimateTokens,
1663
+ getGitRoot, getGitContext, getEnvContext, getProjectSnapshot,
1664
+ checkPromiseSignal
1665
+ };
1666
+ ```
1667
+
1668
+ ---
1669
+
1670
+ ## Development
1671
+
1672
+ ```bash
1673
+ # Development mode (using tsx)
1674
+ npm run dev "your task"
1675
+
1676
+ # Build
1677
+ npm run build
1678
+
1679
+ # Optional: only build workspace packages
1680
+ npm run build:packages
1681
+
1682
+ # Build standalone binary (current platform / all platforms)
1683
+ npm run build:binary
1684
+ npm run build:binary:all
1685
+
1686
+ # Run tests
1687
+ npm test
1688
+
1689
+ # Eval-driven development tests (provider matrices, identity round-trip, etc.)
1690
+ npm run test:eval
1691
+
1692
+ # Clean
1693
+ npm run clean
1694
+ ```
1695
+
1696
+ ### Repo Intelligence cache directories
1697
+
1698
+ KodaX uses one repo-intelligence cache root with separate built-in engine profiles:
1699
+
1700
+ - `.agent/repo-intelligence/`
1701
+ - Full-engine repo-intelligence artifacts and existing task-engine snapshots.
1702
+ - `.agent/repo-intelligence/light/`
1703
+ - Light-mode heuristic index artifacts.
1704
+
1705
+ They are intentionally separated so:
1706
+
1707
+ - full and light profiles can be rebuilt independently.
1708
+ - light-mode confidence/capability state cannot be mistaken for full-engine state.
1709
+ - future cache migrations can delete one profile without corrupting the other.
1710
+
1711
+ `.agent/repo-intelligence/` is local generated state and should not be committed.
1712
+
1713
+ ---
1714
+
1715
+ ## Code Style
1716
+
1717
+ ### Comment Guidelines
1718
+
1719
+ KodaX uses an **English-first** comment style with selective Chinese brief notes for complex logic.
1720
+
1721
+ | Situation | Style | Example |
1722
+ |-----------|-------|---------|
1723
+ | Import/Export | English only | `// Import dependencies` |
1724
+ | Simple constants | English only | `// Max retry count` |
1725
+ | Simple logic | English only | `// Return if null` |
1726
+ | **Business rules** | English + Chinese | `// Skip tool_result - 跳过工具结果块` |
1727
+ | **Platform compatibility** | English + Chinese | `// Windows path handling - Windows 路径处理` |
1728
+ | **Performance optimization** | English + Chinese | `// Debounce to prevent flicker - 防抖避免闪烁` |
1729
+
1730
+ ---
1731
+
1732
+ ## Documentation
1733
+
1734
+ - [README_CN.md](README_CN.md) - Chinese Documentation
1735
+ - [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
1736
+ - [docs/release.md](docs/release.md) - Standalone binary build & release pipeline
1737
+ - [docs/PRD.md](docs/PRD.md) - Product Requirements
1738
+ - [docs/ADR.md](docs/ADR.md) - Architecture Decisions
1739
+ - [docs/HLD.md](docs/HLD.md) - High-Level Design
1740
+ - [docs/DD.md](docs/DD.md) - Detailed Design
1741
+ - [docs/FEATURE_LIST.md](docs/FEATURE_LIST.md) - Feature Tracking
1742
+ - [docs/test-guides/](docs/test-guides/) - Feature-specific test guides
1743
+ - [CHANGELOG.md](CHANGELOG.md) - Version History (v0.7.0+; [archive](docs/CHANGELOG_ARCHIVE.md) for older)
1744
+
1745
+ ---
1746
+
1747
+ ## License
1748
+
1749
+ [KodaX-AI Fair Core License (KAI-FCL) 1.0](LICENSE) - Copyright 2026 [icetomoyo](mailto:icetomoyo@gmail.com).
1750
+
1751
+ KAI-FCL is source-available / fair-core, not OSI open source. Commercial,
1752
+ enterprise, managed deployment, paid service, or customer redistribution use
1753
+ requires KodaX-AI authorization and a valid entitlement where required.
1754
+
1755
+ Official KodaX 0.7.70 and later distributions use KAI-FCL or accompanying
1756
+ KodaX-AI customer terms. Historical tags, archives, binaries, npm packages, or
1757
+ other copies already distributed with Apache-2.0 notices remain Apache-2.0 for
1758
+ those specific copies.