@pentoshi/clai 4.13.1 → 4.14.1

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 (344) hide show
  1. package/CONTRIBUTING.md +9 -4
  2. package/MCP.md +182 -0
  3. package/PROVIDERS.md +69 -0
  4. package/README.md +19 -6
  5. package/dist/agent/runner.js +1 -1
  6. package/dist/agent/runner.js.map +1 -1
  7. package/dist/agent/stream-recovery.d.ts +1 -1
  8. package/dist/agent/stream-recovery.js +10 -4
  9. package/dist/agent/stream-recovery.js.map +1 -1
  10. package/dist/agent/turn/mcp-agent-tools.d.ts +4 -2
  11. package/dist/agent/turn/mcp-agent-tools.js +15 -6
  12. package/dist/agent/turn/mcp-agent-tools.js.map +1 -1
  13. package/dist/agent/turn/tool-call-preparation.d.ts +2 -1
  14. package/dist/agent/turn/tool-call-preparation.js +20 -4
  15. package/dist/agent/turn/tool-call-preparation.js.map +1 -1
  16. package/dist/agent/turn/tool-execution/single-tool.js +1 -1
  17. package/dist/agent/turn/tool-execution/single-tool.js.map +1 -1
  18. package/dist/app/commands/catalog.js +1 -0
  19. package/dist/app/commands/catalog.js.map +1 -1
  20. package/dist/classic/app/action-handlers.js +2 -1
  21. package/dist/classic/app/action-handlers.js.map +1 -1
  22. package/dist/classic/app/app-wiring.js +2 -0
  23. package/dist/classic/app/app-wiring.js.map +1 -1
  24. package/dist/classic/bootstrap/runtime-view.d.ts +6 -0
  25. package/dist/classic/bootstrap/runtime-view.js +46 -0
  26. package/dist/classic/bootstrap/runtime-view.js.map +1 -0
  27. package/dist/classic/bootstrap/terminal-session.d.ts +3 -0
  28. package/dist/classic/bootstrap/terminal-session.js +3 -0
  29. package/dist/classic/bootstrap/terminal-session.js.map +1 -1
  30. package/dist/classic/chrome/composer-controller.d.ts +2 -1
  31. package/dist/classic/chrome/composer-controller.js +36 -19
  32. package/dist/classic/chrome/composer-controller.js.map +1 -1
  33. package/dist/classic/chrome/composer-frame.js +1 -1
  34. package/dist/classic/chrome/composer-frame.js.map +1 -1
  35. package/dist/classic/input/input-router.d.ts +2 -1
  36. package/dist/classic/input/input-router.js +9 -0
  37. package/dist/classic/input/input-router.js.map +1 -1
  38. package/dist/classic/input/key-event.d.ts +3 -0
  39. package/dist/classic/input/key-event.js.map +1 -1
  40. package/dist/classic/input/paste-burst.js +5 -0
  41. package/dist/classic/input/paste-burst.js.map +1 -1
  42. package/dist/classic/input/raw-decoder.d.ts +1 -0
  43. package/dist/classic/input/raw-decoder.js +15 -10
  44. package/dist/classic/input/raw-decoder.js.map +1 -1
  45. package/dist/classic/input/terminal-sequences.d.ts +0 -1
  46. package/dist/classic/input/terminal-sequences.js +0 -1
  47. package/dist/classic/input/terminal-sequences.js.map +1 -1
  48. package/dist/commands/providers.js +2 -0
  49. package/dist/commands/providers.js.map +1 -1
  50. package/dist/index.js +7 -1
  51. package/dist/index.js.map +1 -1
  52. package/dist/llm/adapters/mistral-messages.d.ts +1 -0
  53. package/dist/llm/adapters/mistral-messages.js +56 -0
  54. package/dist/llm/adapters/mistral-messages.js.map +1 -0
  55. package/dist/llm/capabilities.js +63 -1
  56. package/dist/llm/capabilities.js.map +1 -1
  57. package/dist/llm/capability/state.d.ts +1 -1
  58. package/dist/llm/capability/tool-dialect.js +8 -1
  59. package/dist/llm/capability/tool-dialect.js.map +1 -1
  60. package/dist/llm/capability/vision-patterns.js +6 -0
  61. package/dist/llm/capability/vision-patterns.js.map +1 -1
  62. package/dist/llm/capability/vision-registry.js +11 -1
  63. package/dist/llm/capability/vision-registry.js.map +1 -1
  64. package/dist/llm/catalog-context.d.ts +6 -0
  65. package/dist/llm/catalog-context.js +15 -0
  66. package/dist/llm/catalog-context.js.map +1 -0
  67. package/dist/llm/catalog-facts.d.ts +2 -0
  68. package/dist/llm/catalog-facts.js.map +1 -1
  69. package/dist/llm/cline-model-catalog.d.ts +4 -0
  70. package/dist/llm/cline-model-catalog.js +197 -0
  71. package/dist/llm/cline-model-catalog.js.map +1 -0
  72. package/dist/llm/cline.d.ts +1 -0
  73. package/dist/llm/cline.js +69 -17
  74. package/dist/llm/cline.js.map +1 -1
  75. package/dist/llm/free-model-limits.d.ts +1 -0
  76. package/dist/llm/free-model-limits.js +101 -0
  77. package/dist/llm/free-model-limits.js.map +1 -0
  78. package/dist/llm/free.js +136 -103
  79. package/dist/llm/free.js.map +1 -1
  80. package/dist/llm/http.d.ts +2 -1
  81. package/dist/llm/http.js +3 -1
  82. package/dist/llm/http.js.map +1 -1
  83. package/dist/llm/mistral-models.d.ts +2 -0
  84. package/dist/llm/mistral-models.js +23 -0
  85. package/dist/llm/mistral-models.js.map +1 -0
  86. package/dist/llm/mistral.d.ts +2 -0
  87. package/dist/llm/mistral.js +129 -0
  88. package/dist/llm/mistral.js.map +1 -0
  89. package/dist/llm/profile/layer-merge.js +3 -3
  90. package/dist/llm/profile/layer-merge.js.map +1 -1
  91. package/dist/llm/provider-identity.js +5 -0
  92. package/dist/llm/provider-identity.js.map +1 -1
  93. package/dist/llm/provider-info-text.js +26 -0
  94. package/dist/llm/provider-info-text.js.map +1 -1
  95. package/dist/llm/provider-model-layers.js +45 -0
  96. package/dist/llm/provider-model-layers.js.map +1 -1
  97. package/dist/llm/provider-profile-layers.js +25 -0
  98. package/dist/llm/provider-profile-layers.js.map +1 -1
  99. package/dist/llm/provider-profiles.js +28 -4
  100. package/dist/llm/provider-profiles.js.map +1 -1
  101. package/dist/llm/qoder/qoder-catalog.d.ts +15 -0
  102. package/dist/llm/qoder/qoder-catalog.js +56 -0
  103. package/dist/llm/qoder/qoder-catalog.js.map +1 -0
  104. package/dist/llm/qoder/qoder-http.d.ts +13 -0
  105. package/dist/llm/qoder/qoder-http.js +55 -0
  106. package/dist/llm/qoder/qoder-http.js.map +1 -0
  107. package/dist/llm/qoder/qoder-queue.d.ts +15 -0
  108. package/dist/llm/qoder/qoder-queue.js +169 -0
  109. package/dist/llm/qoder/qoder-queue.js.map +1 -0
  110. package/dist/llm/qoder/qoder-response.d.ts +19 -0
  111. package/dist/llm/qoder/qoder-response.js +98 -0
  112. package/dist/llm/qoder/qoder-response.js.map +1 -0
  113. package/dist/llm/qoder/qoder-stream.d.ts +23 -0
  114. package/dist/llm/qoder/qoder-stream.js +75 -0
  115. package/dist/llm/qoder/qoder-stream.js.map +1 -0
  116. package/dist/llm/qoder/qoder.d.ts +4 -4
  117. package/dist/llm/qoder/qoder.js +71 -189
  118. package/dist/llm/qoder/qoder.js.map +1 -1
  119. package/dist/llm/quota-signals.d.ts +1 -0
  120. package/dist/llm/quota-signals.js +8 -0
  121. package/dist/llm/quota-signals.js.map +1 -1
  122. package/dist/llm/reasoning-capability.js +1 -0
  123. package/dist/llm/reasoning-capability.js.map +1 -1
  124. package/dist/llm/request-plan.js +15 -6
  125. package/dist/llm/request-plan.js.map +1 -1
  126. package/dist/llm/router.js +1 -1
  127. package/dist/llm/router.js.map +1 -1
  128. package/dist/llm/routing/attempt-complete.js +4 -3
  129. package/dist/llm/routing/attempt-complete.js.map +1 -1
  130. package/dist/llm/routing/attempt-request.d.ts +5 -1
  131. package/dist/llm/routing/attempt-request.js +22 -2
  132. package/dist/llm/routing/attempt-request.js.map +1 -1
  133. package/dist/llm/routing/attempt-stream.js +4 -3
  134. package/dist/llm/routing/attempt-stream.js.map +1 -1
  135. package/dist/llm/routing/error-classification.js +2 -0
  136. package/dist/llm/routing/error-classification.js.map +1 -1
  137. package/dist/llm/routing/failure-report.d.ts +1 -1
  138. package/dist/llm/routing/failure-report.js +11 -5
  139. package/dist/llm/routing/failure-report.js.map +1 -1
  140. package/dist/llm/routing/provider-selection.js +3 -0
  141. package/dist/llm/routing/provider-selection.js.map +1 -1
  142. package/dist/llm/tool-protocol.d.ts +1 -1
  143. package/dist/llm/tool-protocol.js +4 -1
  144. package/dist/llm/tool-protocol.js.map +1 -1
  145. package/dist/llm/wire/chat-body.js +51 -28
  146. package/dist/llm/wire/chat-body.js.map +1 -1
  147. package/dist/llm/wire/effort-preflight.js +4 -1
  148. package/dist/llm/wire/effort-preflight.js.map +1 -1
  149. package/dist/llm/wire/mistral-content.d.ts +19 -0
  150. package/dist/llm/wire/mistral-content.js +106 -0
  151. package/dist/llm/wire/mistral-content.js.map +1 -0
  152. package/dist/llm/wire/mistral-model-catalog.d.ts +2 -0
  153. package/dist/llm/wire/mistral-model-catalog.js +73 -0
  154. package/dist/llm/wire/mistral-model-catalog.js.map +1 -0
  155. package/dist/llm/wire/openai-complete.js +10 -4
  156. package/dist/llm/wire/openai-complete.js.map +1 -1
  157. package/dist/llm/wire/openai-stream.js +38 -16
  158. package/dist/llm/wire/openai-stream.js.map +1 -1
  159. package/dist/llm/wire/response-errors.d.ts +1 -0
  160. package/dist/llm/wire/response-errors.js +1 -1
  161. package/dist/llm/wire/response-errors.js.map +1 -1
  162. package/dist/mcp/auth/device.d.ts +7 -3
  163. package/dist/mcp/auth/device.js +55 -32
  164. package/dist/mcp/auth/device.js.map +1 -1
  165. package/dist/mcp/auth/http.d.ts +12 -0
  166. package/dist/mcp/auth/http.js +62 -0
  167. package/dist/mcp/auth/http.js.map +1 -0
  168. package/dist/mcp/auth/loopback.d.ts +9 -1
  169. package/dist/mcp/auth/loopback.js +80 -8
  170. package/dist/mcp/auth/loopback.js.map +1 -1
  171. package/dist/mcp/auth/metadata.d.ts +2 -3
  172. package/dist/mcp/auth/metadata.js +25 -25
  173. package/dist/mcp/auth/metadata.js.map +1 -1
  174. package/dist/mcp/auth/provider.d.ts +1 -0
  175. package/dist/mcp/auth/provider.js +215 -42
  176. package/dist/mcp/auth/provider.js.map +1 -1
  177. package/dist/mcp/auth/registration.d.ts +2 -3
  178. package/dist/mcp/auth/registration.js +10 -14
  179. package/dist/mcp/auth/registration.js.map +1 -1
  180. package/dist/mcp/auth/token-exchange.d.ts +5 -3
  181. package/dist/mcp/auth/token-exchange.js +15 -15
  182. package/dist/mcp/auth/token-exchange.js.map +1 -1
  183. package/dist/mcp/auth/token-store.d.ts +1 -1
  184. package/dist/mcp/auth/token-store.js +105 -54
  185. package/dist/mcp/auth/token-store.js.map +1 -1
  186. package/dist/mcp/auth/types.d.ts +11 -2
  187. package/dist/mcp/catalog.d.ts +11 -0
  188. package/dist/mcp/catalog.js +58 -0
  189. package/dist/mcp/catalog.js.map +1 -0
  190. package/dist/mcp/client.d.ts +10 -1
  191. package/dist/mcp/client.js +93 -29
  192. package/dist/mcp/client.js.map +1 -1
  193. package/dist/mcp/coerce.js +4 -4
  194. package/dist/mcp/coerce.js.map +1 -1
  195. package/dist/mcp/config-file.js +53 -10
  196. package/dist/mcp/config-file.js.map +1 -1
  197. package/dist/mcp/discovery.js +2 -0
  198. package/dist/mcp/discovery.js.map +1 -1
  199. package/dist/mcp/jsonrpc.js +28 -18
  200. package/dist/mcp/jsonrpc.js.map +1 -1
  201. package/dist/mcp/manager.d.ts +17 -0
  202. package/dist/mcp/manager.js +211 -29
  203. package/dist/mcp/manager.js.map +1 -1
  204. package/dist/mcp/results.js +25 -10
  205. package/dist/mcp/results.js.map +1 -1
  206. package/dist/mcp/runtime.d.ts +6 -6
  207. package/dist/mcp/runtime.js +168 -60
  208. package/dist/mcp/runtime.js.map +1 -1
  209. package/dist/mcp/schema-compact.js +3 -29
  210. package/dist/mcp/schema-compact.js.map +1 -1
  211. package/dist/mcp/storage-lock.d.ts +1 -0
  212. package/dist/mcp/storage-lock.js +80 -0
  213. package/dist/mcp/storage-lock.js.map +1 -0
  214. package/dist/mcp/transport-http.d.ts +13 -2
  215. package/dist/mcp/transport-http.js +245 -77
  216. package/dist/mcp/transport-http.js.map +1 -1
  217. package/dist/mcp/transport-stdio.d.ts +5 -2
  218. package/dist/mcp/transport-stdio.js +96 -52
  219. package/dist/mcp/transport-stdio.js.map +1 -1
  220. package/dist/mcp/transport.d.ts +9 -1
  221. package/dist/mcp/transport.js +38 -0
  222. package/dist/mcp/transport.js.map +1 -1
  223. package/dist/mcp/types.d.ts +8 -2
  224. package/dist/mcp/types.js +1 -5
  225. package/dist/mcp/types.js.map +1 -1
  226. package/dist/mcp/validation.js +81 -12
  227. package/dist/mcp/validation.js.map +1 -1
  228. package/dist/noninteractive/stream-renderer.d.ts +1 -0
  229. package/dist/noninteractive/stream-renderer.js +13 -0
  230. package/dist/noninteractive/stream-renderer.js.map +1 -1
  231. package/dist/session-runtime/child-bridge.d.ts +10 -4
  232. package/dist/session-runtime/child-bridge.js +34 -6
  233. package/dist/session-runtime/child-bridge.js.map +1 -1
  234. package/dist/session-runtime/client.d.ts +3 -2
  235. package/dist/session-runtime/client.js +22 -9
  236. package/dist/session-runtime/client.js.map +1 -1
  237. package/dist/session-runtime/host.d.ts +4 -0
  238. package/dist/session-runtime/host.js +108 -16
  239. package/dist/session-runtime/host.js.map +1 -1
  240. package/dist/session-runtime/launch.d.ts +1 -0
  241. package/dist/session-runtime/launch.js +3 -1
  242. package/dist/session-runtime/launch.js.map +1 -1
  243. package/dist/session-runtime/start-runtime.d.ts +12 -0
  244. package/dist/session-runtime/start-runtime.js +69 -0
  245. package/dist/session-runtime/start-runtime.js.map +1 -0
  246. package/dist/session-runtime/store.js +1 -0
  247. package/dist/session-runtime/store.js.map +1 -1
  248. package/dist/session-runtime/terminal-options.d.ts +4 -0
  249. package/dist/session-runtime/terminal-options.js +49 -0
  250. package/dist/session-runtime/terminal-options.js.map +1 -0
  251. package/dist/session-runtime/types.d.ts +38 -1
  252. package/dist/session-runtime/view-manager.d.ts +38 -0
  253. package/dist/session-runtime/view-manager.js +189 -0
  254. package/dist/session-runtime/view-manager.js.map +1 -0
  255. package/dist/session-runtime/view-services.d.ts +14 -0
  256. package/dist/session-runtime/view-services.js +83 -0
  257. package/dist/session-runtime/view-services.js.map +1 -0
  258. package/dist/session-runtime/view-terminal.d.ts +29 -0
  259. package/dist/session-runtime/view-terminal.js +51 -0
  260. package/dist/session-runtime/view-terminal.js.map +1 -0
  261. package/dist/store/config/endpoints.js +1 -0
  262. package/dist/store/config/endpoints.js.map +1 -1
  263. package/dist/store/config.js +2 -0
  264. package/dist/store/config.js.map +1 -1
  265. package/dist/store/rtk-usage.d.ts +1 -0
  266. package/dist/store/rtk-usage.js +8 -3
  267. package/dist/store/rtk-usage.js.map +1 -1
  268. package/dist/tools/definitions/aggregate.js +4 -1
  269. package/dist/tools/definitions/aggregate.js.map +1 -1
  270. package/dist/tools/rtk/binary.d.ts +2 -2
  271. package/dist/tools/rtk/binary.js +12 -4
  272. package/dist/tools/rtk/binary.js.map +1 -1
  273. package/dist/tools/rtk/rewrite.js +13 -3
  274. package/dist/tools/rtk/rewrite.js.map +1 -1
  275. package/dist/tui-v2/bootstrap/runtime-view.d.ts +6 -0
  276. package/dist/tui-v2/bootstrap/runtime-view.js +54 -0
  277. package/dist/tui-v2/bootstrap/runtime-view.js.map +1 -0
  278. package/dist/tui-v2/components/composer/composer-input-box.d.ts +6 -1
  279. package/dist/tui-v2/components/composer/composer-input-box.js +27 -18
  280. package/dist/tui-v2/components/composer/composer-input-box.js.map +1 -1
  281. package/dist/tui-v2/components/composer/paste-chip.d.ts +3 -2
  282. package/dist/tui-v2/components/composer/paste-chip.js +17 -48
  283. package/dist/tui-v2/components/composer/paste-chip.js.map +1 -1
  284. package/dist/tui-v2/composer/composer-cursor.d.ts +3 -0
  285. package/dist/tui-v2/composer/composer-cursor.js +21 -0
  286. package/dist/tui-v2/composer/composer-cursor.js.map +1 -0
  287. package/dist/tui-v2/composer/composer-editor.js +91 -100
  288. package/dist/tui-v2/composer/composer-editor.js.map +1 -1
  289. package/dist/tui-v2/composer/composer-highlight.d.ts +6 -1
  290. package/dist/tui-v2/composer/composer-highlight.js +9 -2
  291. package/dist/tui-v2/composer/composer-highlight.js.map +1 -1
  292. package/dist/tui-v2/composer/composer-wheel.js +2 -1
  293. package/dist/tui-v2/composer/composer-wheel.js.map +1 -1
  294. package/dist/tui-v2/composer/expand-paste.d.ts +4 -0
  295. package/dist/tui-v2/composer/expand-paste.js +34 -0
  296. package/dist/tui-v2/composer/expand-paste.js.map +1 -0
  297. package/dist/tui-v2/composer/paste-hit-test.d.ts +28 -0
  298. package/dist/tui-v2/composer/paste-hit-test.js +25 -0
  299. package/dist/tui-v2/composer/paste-hit-test.js.map +1 -0
  300. package/dist/tui-v2/composer/use-draft-actions.js +3 -1
  301. package/dist/tui-v2/composer/use-draft-actions.js.map +1 -1
  302. package/dist/tui-v2/input/paste-burst-guard.js +3 -0
  303. package/dist/tui-v2/input/paste-burst-guard.js.map +1 -1
  304. package/dist/types.d.ts +4 -3
  305. package/dist/types.js +1 -0
  306. package/dist/types.js.map +1 -1
  307. package/dist/ui/mentions.js +12 -1
  308. package/dist/ui/mentions.js.map +1 -1
  309. package/dist/ui-core/actions/action-id.d.ts +1 -1
  310. package/dist/ui-core/actions/action-id.js +1 -0
  311. package/dist/ui-core/actions/action-id.js.map +1 -1
  312. package/dist/ui-core/actions/format-shortcuts.js +3 -2
  313. package/dist/ui-core/actions/format-shortcuts.js.map +1 -1
  314. package/dist/ui-core/actions/keymap.js +2 -0
  315. package/dist/ui-core/actions/keymap.js.map +1 -1
  316. package/dist/ui-core/bootstrap/composition-root.d.ts +4 -1
  317. package/dist/ui-core/bootstrap/composition-root.js +33 -14
  318. package/dist/ui-core/bootstrap/composition-root.js.map +1 -1
  319. package/dist/ui-core/commands/mcp-commands.js +3 -3
  320. package/dist/ui-core/commands/mcp-commands.js.map +1 -1
  321. package/dist/ui-core/commands/pickers/search-reasoning.js +21 -6
  322. package/dist/ui-core/commands/pickers/search-reasoning.js.map +1 -1
  323. package/dist/ui-core/commands/rtk-commands.js +3 -3
  324. package/dist/ui-core/commands/rtk-commands.js.map +1 -1
  325. package/dist/ui-core/commands/session-commands.js +1 -1
  326. package/dist/ui-core/commands/session-commands.js.map +1 -1
  327. package/dist/ui-core/composer/completion.d.ts +1 -0
  328. package/dist/ui-core/composer/completion.js +31 -3
  329. package/dist/ui-core/composer/completion.js.map +1 -1
  330. package/dist/ui-core/composer/composer-height.d.ts +1 -1
  331. package/dist/ui-core/composer/composer-height.js +26 -3
  332. package/dist/ui-core/composer/composer-height.js.map +1 -1
  333. package/dist/ui-core/composer/paste-placeholder.d.ts +10 -0
  334. package/dist/ui-core/composer/paste-placeholder.js +60 -12
  335. package/dist/ui-core/composer/paste-placeholder.js.map +1 -1
  336. package/dist/ui-core/input/paste-burst.d.ts +2 -1
  337. package/dist/ui-core/input/paste-burst.js +20 -0
  338. package/dist/ui-core/input/paste-burst.js.map +1 -1
  339. package/dist/ui-core/state/transcript-store.d.ts +7 -0
  340. package/dist/ui-core/state/transcript-store.js +53 -0
  341. package/dist/ui-core/state/transcript-store.js.map +1 -1
  342. package/dist/version.generated.d.ts +2 -2
  343. package/dist/version.generated.js +2 -2
  344. package/package.json +3 -2
package/CONTRIBUTING.md CHANGED
@@ -37,7 +37,8 @@ The tests use fixtures, isolated storage, and a mocked browser launcher; provide
37
37
  | `npm run test:host -- test/environment` | Check environment behavior under the host's locale and timezone. |
38
38
  | `npm run test:classic:pty` | Run the provider-independent POSIX terminal smoke test; requires Python 3. |
39
39
  | `npm run test:bun` | Run native OpenTUI, buffered PTY input, and parity checks through Bun. |
40
- | `npm run test:bun:session` | Verify complete UTF-8 input delivery through Bun's real PTY buffer. |
40
+ | `npm run test:bun:session` | Verify complete UTF-8 input delivery through Bun's real PTY buffer and independent native terminal views. |
41
+ | `npm run test:deterministic -- test/mcp` | Check MCP transports, tool catalogs, authentication, and concurrent credential/config storage with local fixtures. |
41
42
  | `npm run embed-prompts:check` | Check that embedded prompts match their source Markdown. |
42
43
  | `npm run release:verify` | Validate dependency pins, lockfile, and release metadata. |
43
44
  | `npm run compile` | Build native release binaries through Bun. |
@@ -62,7 +63,7 @@ For dependency changes, update `package.json` and `package-lock.json` together a
62
63
  | `src/classic/` | React and Ink UI and its terminal lifecycle. |
63
64
  | `src/tui-v2/` | OpenTUI components and native terminal integration. |
64
65
  | `src/noninteractive/` | One-shot output and stdout/stderr policy. |
65
- | `src/session-runtime/` | Durable agent hosts, shared attachments, discovery, and reattachment. |
66
+ | `src/session-runtime/` | Durable agent hosts, independent terminal views, discovery, and reattachment. |
66
67
  | `src/interactive-session/` | Conversation-owned terminal sessions and transports. |
67
68
  | `src/store/` | Configuration, history, prompt journals, plans, and retained subagent state. |
68
69
  | `src/tools/`, `src/safety/` | Tool implementation, classification, permissions, and engagement policy. |
@@ -71,10 +72,14 @@ For dependency changes, update `package.json` and `package-lock.json` together a
71
72
  | `test/`, `scripts/`, `.github/workflows/` | Regression tests, tooling, and CI/release workflows. |
72
73
  | `bin/`, `install/`, `manifests/` | npm launchers, platform installers, and distribution templates. |
73
74
 
74
- Keep `src/app/` and `src/ui-core/` renderer-neutral: do not import Ink, OpenTUI, renderer-specific components, or write directly to the terminal there. Put terminal access in bootstrap or port modules so both interfaces share session, command, transcript, safety, and persistence behavior. Classic source files are subject to a 400-line architecture guard.
75
+ Keep `src/app/` and `src/ui-core/` renderer-neutral: do not import Ink, OpenTUI, renderer-specific components, or write directly to the terminal there. Put terminal access in bootstrap or port modules so both interfaces share session, command, transcript, safety, and persistence behavior. Classic source files are subject to a 500-line architecture guard.
75
76
 
76
77
  Use strict TypeScript, explicit `.js` extensions for relative ESM imports, and focused modules that follow the surrounding style. Handle failures explicitly. Changes to persistence, compaction, or attachment behavior must preserve conversation records and avoid starting duplicate agent writers.
77
78
 
79
+ Durable sessions run one agent and one persistence owner. Each attachment renders through private terminal streams with its own size, composer, scrolling, overlays, and input routing. Transcript views share immutable conversation data while retaining local display preferences. Detaching a view disposes only its renderer and UI state; the shared session continues. Runtime capability negotiation preserves attachment to agents launched by older versions.
80
+
81
+ MCP connections retain a stable catalog for each agent turn. Native requests use fixed MCP control tools; discovery and selected schemas travel in conversation context, with large catalogs deferred to paginated search. Preserve schema constraints, confirmation policy, request deadlines, and complete artifact-backed outputs when changing this path. OAuth connection recovery must remain silent; interactive authentication belongs to an explicit setup or sign-in action. Storage tests include separate processes sharing one config and rotating one OAuth refresh token.
82
+
78
83
  Distribution manifests under `manifests/` are templates. The release workflow generates published metadata; placeholder hashes in those templates are not installation artifacts.
79
84
 
80
85
  ## Validation and pull requests
@@ -83,7 +88,7 @@ For behavior changes, add or update meaningful regression coverage and run the f
83
88
 
84
89
  For documentation-only changes, check examples against current CLI help, validate links and formatting, and check any issue-template YAML. A full local application suite is unnecessary unless the change affects code, runtime prompts, or generated artifacts.
85
90
 
86
- CI currently covers Node 22 and 24 on Linux, Bun OpenTUI conformance, Classic on macOS, and process/privilege behavior on macOS and Windows. The [workflow](.github/workflows/ci.yml) is the source of truth for required checks. All relevant remote checks must pass.
91
+ CI currently covers Node 22 and 24 on Linux, Bun OpenTUI conformance, Classic on macOS, and process/privilege and MCP behavior on macOS and Windows. The [workflow](.github/workflows/ci.yml) is the source of truth for required checks. All relevant remote checks must pass.
87
92
 
88
93
  Open a pull request against `main` with:
89
94
 
package/MCP.md ADDED
@@ -0,0 +1,182 @@
1
+ # MCP servers in clai
2
+
3
+ MCP connects clai to tools supplied by local programs and remote services. Both Classic and OpenTUI share the same connections, tool selection, confirmation rules, and sign-in flows. Connecting a server discovers its tools; selecting it makes those tools available to the current conversation.
4
+
5
+ ## Quick setup
6
+
7
+ Open `/mcp` and choose a server from the catalog, or choose **add MCP server** and paste one named JSON server definition. Catalog entries prompt for required keys or start sign-in when needed. Custom definitions are merged into the project's `.clai/mcp.json`, preserving existing servers. Catalog entries with keys entered during setup are saved in user configuration rather than the project file.
8
+
9
+ Activate a configured server in a prompt:
10
+
11
+ ```text
12
+ @mcp:docs Find the API documentation for this project.
13
+ ```
14
+
15
+ Submitting an `@mcp:<server>` mention retains that selection for follow-up prompts, including `continue` after an interruption. Clearing or editing the draft does not disable tools used by the running turn. Selecting another server changes the selection for subsequent prompts; use `/mcp off` to turn it off explicitly or `/mcp all` to enable all ready servers. Read-only tools are available in ask mode. Tools that change external state follow the usual confirmation policy in agent mode.
16
+
17
+ | Command | Purpose |
18
+ | --- | --- |
19
+ | `/mcp` | Open the server picker, including setup and sign-in actions. |
20
+ | `/mcp add` | Paste one server's JSON configuration. |
21
+ | `/mcp add <catalog-name>` | Set up a server from the built-in catalog. |
22
+ | `/mcp list` | Inspect discovered servers, their sources, and connection details. |
23
+ | `/mcp status` | Show the current selection and connection status. |
24
+ | `/mcp tools [server]` | Browse available tools in the UI. |
25
+ | `/mcp login <server>` | Start OAuth sign-in explicitly. |
26
+ | `/mcp reconnect <server>` | Reconnect one server and load its current tools. |
27
+ | `/mcp stop <server>` | Stop a connection for this session and remove its tools from requests. |
28
+ | `/mcp start <server>` | Reconnect a stopped server. |
29
+ | `/mcp refresh` | Reload configuration and reconnect configured servers. |
30
+
31
+ ## Transports and credentials
32
+
33
+ ### Local programs
34
+
35
+ Stdio servers run as child processes, exchanging MCP messages over stdin and stdout. Install the server's required runtime or executable first. Arguments are passed separately, with no shell interpolation.
36
+
37
+ ```json
38
+ {
39
+ "servers": {
40
+ "docs": {
41
+ "type": "stdio",
42
+ "command": "npx",
43
+ "args": ["-y", "your-mcp-server", "--root", "${workspaceFolder}"],
44
+ "env": {
45
+ "SERVICE_API_KEY": "${env:SERVICE_API_KEY}"
46
+ },
47
+ "connectTimeoutMs": 30000,
48
+ "timeoutMs": 60000
49
+ }
50
+ }
51
+ }
52
+ ```
53
+
54
+ Commands such as `npx` and `uvx` resolve through the process environment, including Windows command shims. Set `cwd` when a server needs a particular working directory. Environment credentials stay in the server process and are redacted from supported configuration displays.
55
+
56
+ ### Remote services with API keys
57
+
58
+ Streamable HTTP is the default for a URL. Use `auth.kind: "bearer"` for a bearer token, or `auth.kind: "header"` for a service-specific key header:
59
+
60
+ ```json
61
+ {
62
+ "servers": {
63
+ "tickets": {
64
+ "url": "https://service.example.com/mcp",
65
+ "auth": {
66
+ "kind": "bearer",
67
+ "token": "${env:SERVICE_TOKEN}"
68
+ }
69
+ },
70
+ "search": {
71
+ "url": "https://search.example.com/mcp",
72
+ "auth": {
73
+ "kind": "header",
74
+ "headers": {
75
+ "X-API-Key": "${env:SEARCH_API_KEY}"
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }
81
+ ```
82
+
83
+ Top-level `headers` are also accepted. Use `auth.kind: "none"` to disable OAuth discovery for a public service. For a legacy HTTP+SSE endpoint, set `type: "sse"`. clai can try the alternate HTTP/SSE transport when the endpoint rejects the initial transport with a compatibility status.
84
+
85
+ ### OAuth sign-in
86
+
87
+ A remote server without an explicit auth block uses OAuth discovery when authentication is required. Connection startup and tool calls can reuse or refresh stored credentials, but do not launch a fresh interactive sign-in. Choose the sign-in row in `/mcp`, run `/mcp login <server>`, or complete a catalog server's setup to authorize access.
88
+
89
+ On a desktop, clai can open the authorization page and receive its local callback automatically. The sign-in dialog also shows the URL and accepts a complete callback URL, so browser launching is optional.
90
+
91
+ Over SSH or on a machine without a browser:
92
+
93
+ 1. Start `/mcp login <server>` and open the displayed link on your phone or computer.
94
+ 2. Complete sign-in. If the final localhost page cannot load, copy its full URL from the browser's address bar.
95
+ 3. Paste that URL into clai's sign-in dialog, including `code` and `state`. clai verifies that it belongs to the pending request and exchanges the code using PKCE.
96
+
97
+ When the authorization server advertises device-code sign-in, clai shows a verification URL and a user code instead. Open the URL on any device, approve access, and clai completes sign-in automatically. The server must supply this flow; it cannot be synthesized for servers that only offer browser redirects.
98
+
99
+ Some services require a registered OAuth client rather than dynamic registration:
100
+
101
+ ```json
102
+ {
103
+ "servers": {
104
+ "workspace": {
105
+ "url": "https://service.example.com/mcp",
106
+ "auth": {
107
+ "kind": "oauth",
108
+ "clientId": "${env:MCP_CLIENT_ID}",
109
+ "clientSecret": "${env:MCP_CLIENT_SECRET}",
110
+ "scopes": ["read", "write"],
111
+ "callbackPort": 8765,
112
+ "tokenEndpointAuthMethod": "client_secret_basic"
113
+ }
114
+ }
115
+ }
116
+ }
117
+ ```
118
+
119
+ Use the service's registered redirect URI `http://127.0.0.1:8765/callback` with this example. Omit `clientSecret` for a public client. Supported token endpoint methods are `none`, `client_secret_basic`, and `client_secret_post`; clai also uses the authorization server's advertised method when possible. `authorizationServer` and `resource` can be set when the service requires explicit discovery or audience settings.
120
+
121
+ OAuth credentials are scoped by resource, authorization server, and configured client identity. Expanding requested scopes requires authorization for the new grant. Refreshes are coordinated across terminals so rotating refresh tokens are consumed once. Credentials are retained in restricted local files under `~/.clai/mcp-oauth/` and mirrored to the OS keyring when available. Existing `mcp-oauth.json` credentials remain readable and are migrated as used. These local files contain plaintext secrets; POSIX permissions are `0600` for files and `0700` for directories.
122
+
123
+ ## Configuration compatibility
124
+
125
+ clai reads JSON and JSONC configuration. It accepts `servers`, `mcpServers`, a bare server map, and OpenCode-style `mcp` maps. A pasted definition may also use a top-level `name` alongside its server fields.
126
+
127
+ | Compatible field | clai behavior |
128
+ | --- | --- |
129
+ | `type: "local"` | Stdio transport. |
130
+ | `type: "remote"` or `"streamable-http"` | Streamable HTTP transport. |
131
+ | `command: ["npx", "-y", "server"]` | First entry is the executable; remaining entries are arguments. |
132
+ | `environment` | Alias for a stdio server's `env`. |
133
+ | `enabled: false` | Disable the server; `disabled: true` is also accepted. |
134
+ | `timeout` | Alias for `timeoutMs`, in milliseconds. |
135
+ | `oauth: false` | Disable OAuth discovery. |
136
+ | `oauth: {"clientId": "…", "scope": "read"}` | Compatible OAuth configuration; native `auth` takes precedence. |
137
+
138
+ `tools` can restrict a server to an array of tool names. `${env:NAME}` and `${workspaceFolder}` are resolved before connecting; missing variables appear as configuration errors in `/mcp list`.
139
+
140
+ Configuration is discovered in this precedence order:
141
+
142
+ 1. Files listed by `CLAI_MCP_CONFIG`, separated by the OS path delimiter (`:` on POSIX, `;` on Windows).
143
+ 2. Project `.clai/mcp.json`, `.mcp.json`, repository `.github/mcp.json`, and `.vscode/mcp.json`.
144
+ 3. User clai configuration, then supported Copilot, Claude, and VS Code user configurations.
145
+
146
+ Within the same source category, the nearest project directory wins. Duplicate names and equivalent server connections are shown as shadowed entries. To reuse another tool's configuration explicitly, point `CLAI_MCP_CONFIG` at that file; clai does not rewrite the source merely by reading it.
147
+
148
+ ## Context use and caching
149
+
150
+ Native provider requests use a fixed MCP control interface. Selecting a server or updating its catalog keeps that interface stable; the current selection and catalog are supplied through conversation context. Each turn retains the tool contracts it started with. Enabling a server during a turn also retains its newly discovered tools for that turn, so background draft updates cannot make a valid parallel batch lose its targets. Server notifications update the catalog for subsequent turns; existing retained contracts are preserved.
151
+
152
+ MCP discovery, selection changes, reconnects, and authentication results are appended after the existing conversation. They do not replace the leading system instructions, native tool definitions, or previously submitted messages. This preserves the reusable request prefix within the same provider, model, and session. Actual cache hits depend on the provider's support and cache lifetime; compaction or a model change can establish a different prefix.
153
+
154
+ Small catalogs include compact descriptions and schemas. When the catalog exceeds its inline budget, clai defers schemas to `mcp.tools`, which searches names and descriptions and returns bounded pages. Discovery returns the original schemas and full descriptions, including field instructions, examples, and tool prerequisites. Exact tool names are prioritized over incidental description matches. The agent can narrow a query to one server, follow a cursor, and call any selected tool through `mcp.call`. A cursor is invalidated when its catalog or query changes, so paging cannot silently skip tools.
155
+
156
+ Discovery labels each tool as active, inactive with its exact enable action, or changed during the current turn. In ask mode, mutating tools are marked unavailable; selecting servers and signing in require agent mode or the user's `/mcp` commands. The agent is instructed to inspect full details before using unfamiliar tools, reuse unchanged schemas and identifiers returned by earlier calls, follow documented dependencies, and send required fields as correctly typed JSON values. A changed schema or safety contract requires a new turn; discovering a tool does not silently select its server.
157
+
158
+ Schema constraints, references, alternatives, and definitions are retained. Long descriptions are shortened for model context. Large tool results and oversized catalog pages use output artifacts, allowing the agent to read further detail while keeping the full output available to the transcript and UI. Structured results, images, and resource links are preserved through the MCP result path.
159
+
160
+ MCP servers must be trusted before their tools are used. Their descriptions and results are treated as external data, and mutation confirmations apply to the actual target tool. An in-flight call is rejected if its schema or safety annotations change underneath the retained catalog.
161
+
162
+ ## Troubleshooting
163
+
164
+ | Symptom | Action or behavior |
165
+ | --- | --- |
166
+ | Server is invalid | Check `/mcp list` for missing environment variables, malformed fields, or the winning config source. |
167
+ | Executable cannot start | Install its runtime, check `PATH` and `cwd`, then use `/mcp reconnect <server>`. |
168
+ | First connection is slow | Increase `connectTimeoutMs` if package installation or startup needs more than the default 30 seconds. |
169
+ | A tool exceeds its deadline | Increase `timeoutMs` for that server; the default is 60 seconds. Timed-out requests are cancelled, not automatically replayed. |
170
+ | Server returns 401 | Use `/mcp login <server>` for OAuth, or correct its API key/header configuration. |
171
+ | `mcp.call` rejects a target locally | Follow the specific target or argument error. Use the exact name and JSON object from `mcp.tools`; enabling a server again does not repair malformed arguments or an unknown tool name. |
172
+ | OAuth registration is unavailable | Configure the service's registered `clientId`, or use a supported token/key authentication method. |
173
+ | Browser callback cannot reach the SSH host | Paste the complete final callback URL into the sign-in dialog. |
174
+ | Server redirects the MCP endpoint | Set `url` to the final endpoint. Transport redirects are refused to avoid forwarding credentials elsewhere. |
175
+ | Connection disappears | clai shares one reconnect among simultaneous failures. Read-only or idempotent calls can retry once; an ambiguous write is reported without replaying it, while the connection is repaired for later calls. |
176
+ | HTTP session expires | clai reinitializes the session before retrying the call rejected by the server. |
177
+ | Streamed HTTP response disconnects | When the server supplies event IDs, clai resumes using `Last-Event-ID` over GET rather than replaying the original POST. |
178
+ | Tool catalog changes during a turn | Inspect the current schema with `mcp.tools` and retry in a new turn. |
179
+
180
+ The MCP integration advertises the client capabilities it implements, including workspace roots. Unsupported server requests receive a protocol error promptly instead of leaving a tool call waiting indefinitely.
181
+
182
+ For the underlying protocols, see the [MCP transport specification](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports), [MCP authorization specification](https://modelcontextprotocol.io/specification/2025-06-18/basic/authorization), and [OAuth device authorization grant](https://www.rfc-editor.org/rfc/rfc8628).
package/PROVIDERS.md CHANGED
@@ -35,6 +35,19 @@ clai use chatgpt
35
35
 
36
36
  `/model` uses the account-visible catalog where available, including model context limits and supported reasoning levels. `/usage` shows subscription limits, reset times, and credits when the account reports them. These account allowances are separate from session token totals. OpenAI API credentials use the separate `openai` integration.
37
37
 
38
+ ### Cline
39
+
40
+ ```sh
41
+ clai auth cline
42
+ clai use cline
43
+ ```
44
+
45
+ Cline's catalog supplies its recommended, free, and Cline Pass model IDs. clai uses capabilities reported directly by Cline, then fills missing context limits, output limits, vision, tool support, and reasoning controls from the [Models.dev catalog](https://models.dev). This follows [Cline's catalog integration](https://github.com/cline/cline/tree/main/sdk/packages/llms/src/catalog). Exact Cline Pass entries take precedence over OpenRouter entries; aliases are matched only when the model slug identifies one entry unambiguously. New catalog models can acquire their capabilities without a clai update.
46
+
47
+ Use `/context` to inspect the selected model's input budget. When a catalog reports both a total context window and a smaller input limit, clai uses the smaller limit for that budget. `/effort` shows published effort levels, **on/off** for models with only a reasoning toggle, or an informational notice when reasoning has no adjustable controls. Models declared not to support reasoning offer only **off**. Streamed reasoning remains available when the model returns it.
48
+
49
+ Model lists are cached separately for each credential for 30 minutes. Supplemental metadata is cached for 30 minutes, with a one-minute cooldown for missing-model refreshes and failed lookups. Cline credentials are sent only to Cline; the supplemental catalog lookup is public. Cached listings retain their capabilities during temporary outages, and discovered numeric limits are retained locally for later sessions. If neither source publishes a usable limit, clai keeps its existing model-table or 200,000-token fallback; ambiguous aliases do not receive guessed capabilities.
50
+
38
51
  ### Qoder
39
52
 
40
53
  ```sh
@@ -46,6 +59,8 @@ clai use qoder
46
59
 
47
60
  Select reasoning with `/effort`, for example `/effort xhigh`. clai sends Qoder's native thinking controls using the selected effort and renders streamed reasoning when the model provides it. Model capabilities and account limits still determine what is available.
48
61
 
62
+ `/models` retrieves Qoder's account-visible catalog, with cached or bundled choices if discovery is unavailable. When Qoder queues a model request, clai displays the queue status and resumes the request when the model becomes available. The default queue wait limit is one hour; `QODER_MODEL_QUEUE_MAX_WAIT_MS` sets a different limit in milliseconds. Cancelling the turn stops the wait and releases the queue lease. Reported input, output, cache, and reasoning usage feeds the session totals.
63
+
49
64
  ### Freebuff
50
65
 
51
66
  Freebuff sign-in and model discovery are supported. Generation first requests a server session with a zero wallet-spend limit. Admission can be refused because of server compatibility, account restrictions, concurrent-session limits, quota, or model availability; successful sign-in and a visible model catalog do not establish inference access.
@@ -80,6 +95,7 @@ An environment credential is also used directly when no stored credentials take
80
95
  | GLM / Zhipu | `glm` | `GLM_API_KEY`, `ZHIPU_API_KEY`, or `ZAI_API_KEY` |
81
96
  | Kimi / Moonshot | `kimi` | `KIMI_API_KEY` or `MOONSHOT_API_KEY` |
82
97
  | MiniMax | `minimax` | `MINIMAX_API_KEY` |
98
+ | Mistral | `mistral` | `MISTRAL_API_KEY` |
83
99
  | Xiaomi MiMo | `mimo` | `MIMO_API_KEY` |
84
100
  | NVIDIA NIM | `nvidia` | `NVIDIA_API_KEY` |
85
101
  | OpenAI | `openai` | `OPENAI_API_KEY` |
@@ -102,6 +118,41 @@ An environment credential is also used directly when no stored credentials take
102
118
 
103
119
  For model choice, use `/model` or `clai model <name>`. Use the `/provider` picker's custom-provider option to add an OpenAI-compatible endpoint.
104
120
 
121
+ ### Keyless Free
122
+
123
+ The `free` integration discovers free models from two gateways: `free-1/<model>` uses [OpenCode Zen](https://opencode.ai/docs/zen/), and `free-2/<model>` uses [Kilo](https://kilo.ai/docs/gateway/api-reference). Model availability can change independently at each gateway. Zen's Jev decision models use the separate System One API and are omitted from the chat model picker.
124
+
125
+ Kilo's model catalog supplies context and output limits directly. Zen's model list currently omits those limits, so clai fills missing values from the exact model entry in the OpenCode provider catalog on [Models.dev](https://github.com/anomalyco/models.dev#api). Discovery follows live model IDs, including newly added models, without a clai update or a hardcoded limit entry. Values reported by the gateway take precedence. The two sources keep separate limits even when model names match; older unprefixed Zen model selections also use the discovered limits.
126
+
127
+ Discovered limits are cached for 30 minutes and retained locally for later sessions. A newly discovered Zen model ID can trigger an earlier metadata refresh; retries for unpublished limits or failed lookups have a one-minute cooldown. When discovery is unavailable, clai keeps previously learned limits, then uses its model table or the 200,000-token default if no limit is known. A 200k context can also be an actual gateway limit, rather than a fallback. Use `/context` to inspect the selected session's context budget.
128
+
129
+ Agent turns retry temporary HTTP 429 failures up to four times, with visible waits of 5, 8, 10, and 15 seconds. This includes gateway responses that report an unavailable upstream endpoint. Shorter provider retry hints can shorten a wait. Standalone requests allow three retries by default.
130
+
131
+ Retries preserve the conversation and tool definitions; cancelling the turn cancels the wait. Explicit billing or insufficient account quota errors require an account or provider change. If the gateway remains unavailable after the retry budget, select another model with `/model` or provider with `/provider`. Cross-provider fallback follows `/fallback` and `/freeonly` settings.
132
+
133
+ ### Mistral
134
+
135
+ Create an API key in [Mistral Studio](https://console.mistral.ai/api-keys), then configure clai:
136
+
137
+ ```sh
138
+ clai set mistral
139
+ clai use mistral
140
+ ```
141
+
142
+ Alternatively, set `MISTRAL_API_KEY` in your environment. The default model is `mistral-small-latest`. `/model` discovers the chat models and aliases available to your account through [`/v1/models`](https://docs.mistral.ai/api/endpoint/models), including compatible fine-tuned models. Context limits, image input, function calling, and model temperature defaults follow the returned metadata. Embedding, OCR, moderation, and dedicated audio models are excluded from the chat picker.
143
+
144
+ `/effort` shows the model's advertised or documented controls. The current adjustable Mistral models expose `off` and `high`; Mistral-hosted GLM 5.3 exposes `low`, `high`, and `max` and always reasons. Models without documented or advertised effort controls do not offer guessed settings. Native thinking streams into clai's reasoning display separately from the answer. Thinking chunks, signatures, and their order are retained in session history and replayed on compatible turns. Aliases resolving to the same model version share replay compatibility; a model or endpoint change omits incompatible reasoning while retaining the transcript. See [Mistral's reasoning guide](https://docs.mistral.ai/studio/conversations/reasoning).
145
+
146
+ clai sends a stable, hashed `prompt_cache_key` for each session and preserves the shared conversation prefix. Subagents and auxiliary requests have separate affinity. Cached-input and reasoning-token counts use provider usage fields when available. [Prompt-cache hits depend on Mistral finding a compatible cached prefix](https://docs.mistral.ai/studio/conversations/advanced/prompt-caching); a cache key cannot guarantee a hit.
147
+
148
+ The default endpoint is `https://api.mistral.ai/v1`. To select [regional inference](https://docs.mistral.ai/inference/regional-inference), set `MISTRAL_BASE_URL` or save an endpoint:
149
+
150
+ ```sh
151
+ clai set mistral --url https://api.eu.mistral.ai/v1
152
+ ```
153
+
154
+ `https://api.us.mistral.ai/v1` selects the US endpoint. Availability is discovered against the selected endpoint, and model catalogs are cached separately by endpoint and credential. Mistral uses clai's existing key rotation, request cancellation, stream validation, local tools, and subagent lifecycle.
155
+
105
156
  ### Local and configurable endpoints
106
157
 
107
158
  Ollama uses `OLLAMA_HOST` or an explicitly saved URL:
@@ -120,6 +171,24 @@ clai set modal --url https://your-deployment.example.com --from-env MODAL_CREDEN
120
171
 
121
172
  Here, `MODAL_CREDENTIAL` contains `token-id:token-secret`. Alternatively, supply both native Modal environment variables and configure the endpoint URL separately. `MODAL_BASE_URL` is also supported. Lightning, TokenRouter, and Token Harbor support configured endpoints and the corresponding `LIGHTNING_BASE_URL`, `TOKENROUTER_BASE_URL`, and `TOKENHARBOR_BASE_URL` variables.
122
173
 
174
+ ## Prompt caching
175
+
176
+ clai keeps leading instructions, tool definitions, and previously submitted conversation content stable as a session grows. MCP discovery, server selection, tool results, and working memory are appended to the conversation. Cache controls do not change the stored transcript or add filler to the prompt. Providers that accept session affinity receive a stable identity; subagents and auxiliary requests use separate identities.
177
+
178
+ ### Cline
179
+
180
+ Cline requests retain the same task header and hashed `session_id` across tool rounds, subsequent prompts, and a resumed session. Claude and Qwen routes receive a request-level cache hint without moving flags between earlier user messages. Tool results and images remain in their original order, and reasoning replay preserves compatible artifacts. Cache reads and writes reported by the gateway feed `/usage`.
181
+
182
+ ### Token Harbor
183
+
184
+ Claude requests use explicit content-block cache marks for the system instructions and growing conversation, with at most four marks. Earlier boundaries remain reachable across large parallel tool batches and image turns; empty assistant tails do not prevent marking the preceding content. Other model families use the gateway's caching behavior without Claude-specific fields. See [Token Harbor's prompt-caching guide](https://status.tokenharbor.ai/docs/api/prompt-caching).
185
+
186
+ clai bypasses Token Harbor's exact-response lookup so agent requests receive fresh generations. This still allows upstream prompt caching, which reuses input processing rather than replaying an old answer. Cache read and creation counts are parsed from both OpenAI-compatible and Anthropic-shaped usage responses.
187
+
188
+ ### Interpreting cache usage
189
+
190
+ Use `/usage` to inspect reported cached input and cache writes. An initial cacheable request establishes an entry; later requests can reuse the unchanged portion. A model or endpoint change, credential rotation, provider fallback, compaction, an expired cache, or a prompt below the model's minimum cacheable length can require fresh processing. Stable prefixes improve reuse, while cache availability and actual hit rates remain controlled by the upstream provider.
191
+
123
192
  ## Credential management and fallback
124
193
 
125
194
  - Repeating `clai set <provider>` adds credentials, up to 10 per provider. `--stdin` reads a credential from standard input; `--skip-ping` saves it without provider validation.
package/README.md CHANGED
@@ -4,7 +4,7 @@ clai is a terminal AI assistant for software development, debugging, shell tasks
4
4
 
5
5
  Use a hosted API, an account sign-in, or a local Ollama model. Interactive sessions support live reattachment from multiple terminals on the same machine, so you can reconnect over SSH and continue working with the same agent.
6
6
 
7
- - **Persistent sessions:** streaming output and agent work continue after a terminal disconnect or `/minimise`; type from any attached terminal.
7
+ - **Persistent sessions:** streaming output and agent work continue after a terminal disconnect or `/minimise`; each attached terminal keeps its own size, draft, and scrolling.
8
8
  - **Three working modes:** ask questions, execute tasks, or review a plan before implementation.
9
9
  - **Provider flexibility:** multiple credentials, automatic key rotation, and optional fallback between configured providers.
10
10
  - **Tools and integrations:** file editing, shell commands, background jobs, interactive terminals, web search, MCP servers, and Agent Skills.
@@ -107,19 +107,23 @@ Run `/minimise` inside the interactive console to return to your shell while the
107
107
  | `clai -c` or `clai --continue` | Prefer the latest session for the current directory, with a saved-session fallback when none matches. |
108
108
  | `clai history` or `/history` | Find saved sessions and see whether an agent is running, attached, or detached. |
109
109
 
110
- Reattaching to a live session opens its existing UI. Resuming a saved session restores its conversation and transcript. Bare `--resume` also uses the original working directory if it still exists. Resume flags apply to interactive sessions; prompts supplied on the command line run separately.
110
+ Reattaching to a live session opens a terminal view of the running agent. Resuming a saved session restores its conversation and transcript. Bare `--resume` also uses the original working directory if it still exists. Resume flags apply to interactive sessions; prompts supplied on the command line run separately.
111
111
 
112
112
  ### SSH and multiple terminals
113
113
 
114
114
  After an SSH disconnect, reconnect to the same machine as the same OS user and run `clai --resume`. To share a particular live session, run `clai --resume <id>` in another terminal or SSH connection.
115
115
 
116
- Every attachment sees the same live screen and can type immediately, including prompts and shortcuts. Attachments share one composer and one running agent. The screen fits the smallest attached terminal. Closing or minimising one attachment keeps the agent and the other attachments running.
116
+ Every attachment receives the same live conversation and can type immediately, including prompts and shortcuts. Each terminal has its own screen dimensions, draft, scroll position, selection, and panels. Resizing a phone or scrolling on a laptop affects that view alone. Submitted prompts and agent actions belong to one shared session; attaching another terminal does not start another agent or model request.
117
+
118
+ For example, start clai on a cloud VM, then connect from Termux on a phone over SSH and run `clai --resume`. The phone renders the conversation at its own width while the original terminal keeps its layout. Each attachment can choose `--classic` or `--tui`; narrow terminals use Classic automatically when OpenTUI's minimum size is unavailable. Closing or minimising one attachment keeps the agent and the other attachments running.
119
+
120
+ Independent views apply to runtimes started with v4.14.0 or later. Agents already running under an older version retain their existing terminal behavior until saved and restarted with the updated executable.
117
121
 
118
122
  Durable sessions require an interactive terminal, a compatible PTY transport, and history enabled. Private mode and `--no-history` use foreground sessions. Saved history remains available after the live process ends; an active process still depends on its host machine remaining running.
119
123
 
120
124
  ### History and context
121
125
 
122
- `/new` starts a fresh session and saves the previous one. If work is still running, it remains in its previous session. `/save <name>` names a session, and `/prompts` browses sent prompts with their timestamps and provider, model, and effort metadata.
126
+ `/new` starts a fresh session and saves the previous one. If work is still running or another terminal is attached, that session remains available to its agent and other viewers. `/save <name>` names a session, and `/prompts` browses sent prompts with their timestamps and provider, model, and effort metadata.
123
127
 
124
128
  Context compaction reduces what the model receives while retaining recent requests, plans, task state, and available research findings. It does not erase the saved chat transcript. Use `/compact` to compact manually, `/context` to inspect context size, and `/output` to read retained tool output.
125
129
 
@@ -155,6 +159,7 @@ API, keyless, and local integrations:
155
159
  | GLM / Zhipu | `glm` | `GLM_API_KEY`, `ZHIPU_API_KEY`, or `ZAI_API_KEY` |
156
160
  | Kimi / Moonshot | `kimi` | `KIMI_API_KEY` or `MOONSHOT_API_KEY` |
157
161
  | MiniMax | `minimax` | `MINIMAX_API_KEY` |
162
+ | Mistral | `mistral` | `MISTRAL_API_KEY`; optional `MISTRAL_BASE_URL` for regional endpoints. |
158
163
  | Xiaomi MiMo | `mimo` | `MIMO_API_KEY` |
159
164
  | NVIDIA NIM | `nvidia` | `NVIDIA_API_KEY` |
160
165
  | OpenAI | `openai` | `OPENAI_API_KEY` |
@@ -183,6 +188,7 @@ Use `clai set <provider>` for a hidden-input credential prompt, or `--from-env <
183
188
  - `/set` manages up to 10 credentials per provider, including disabled keys and the active key. Applicable authentication, quota, rate-limit, and server failures can trigger rotation.
184
189
  - `/fallback on` enables cross-provider fallback; it is off by default. `/freeonly on` filters fallback using clai's provider categories. Check the selected model and account's billing terms when controlling spending.
185
190
  - `/effort` configures reasoning where supported. Qoder uses the selected effort, including `xhigh`, and displays thinking when returned by the model.
191
+ - Cline discovers context and output limits and reasoning controls from live catalogs, including new models. `/context` shows the input budget; `/effort` offers the published levels or an on/off toggle. See [Cline setup and discovery](PROVIDERS.md#cline).
186
192
  - `/usage` shows reported token and cache usage across main turns, subagents, and auxiliary requests. Supported account providers also expose quota or subscription information. Token totals are not a billing invoice.
187
193
 
188
194
  The [provider guide](PROVIDERS.md) covers authentication, environment variables, endpoint configuration, and provider-specific behavior. Model catalogs and account access can change; use `/model` and the provider's own dashboard for availability.
@@ -209,7 +215,7 @@ When an approval prompt appears, `Ctrl+O` opens the complete pending operation,
209
215
 
210
216
  The agent can keep development servers and long commands running as background jobs. Use `/jobs` to inspect them and `/output` to browse output. Conversation-owned interactive terminals support REPLs, debuggers, and database consoles across model turns.
211
217
 
212
- `/rtk on` optionally compresses eligible foreground shell output through [rtk](https://github.com/rtk-ai/rtk). It is off by default; `/rtk install`, `/rtk update`, and `/rtk status` manage the integration.
218
+ `/rtk on` optionally compresses eligible foreground shell output through [rtk](https://github.com/rtk-ai/rtk). It is off by default; `/rtk install`, `/rtk update`, and `/rtk status` manage the integration. `/rtk` reports executions and estimated token savings for the current conversation. Each session has its own RTK tracking database, shared by its attachments and retained when resumed; unrelated RTK activity is excluded.
213
219
 
214
220
  ### Authorized security testing
215
221
 
@@ -237,12 +243,17 @@ clai selects its interface using the OS where it runs. Native Windows uses Class
237
243
 
238
244
  Standard terminals can handle ordinary text input and output. Modified keys, mouse motion/hover, and clipboard integration vary by terminal and configuration. If `Shift+Enter` is not distinguishable from `Enter`, use `Ctrl+N` or `Alt+Enter` for a newline. Use `clai --classic` if OpenTUI cannot start, and `F5` or `/redraw` to repaint a scrambled screen.
239
245
 
246
+ Large pastes collapse into a line or character count inside the composer while retaining the full text for submission. In both interfaces, place the cursor near a shortened block and press `Ctrl+E` to expand just that block for editing. `Alt+E` also works. When no shortened block is present, `Ctrl+E` moves to the end of the current line. In OpenTUI, hovering over an inline placeholder opens a preview that stays visible while the pointer remains inside the composer; double-clicking the placeholder or preview also expands it. Pasted transcripts remain one draft, including when a terminal sends unbracketed text in bursts over SSH. Press `Enter` after the paste has finished to submit it.
247
+
248
+ Type `/` at the start of the draft or after a space to browse commands. Use the arrow keys to select, `Tab` to complete, and `Enter` to run the command. A leading command retains its arguments, such as `/model model-name`; an inline command runs while preserving the surrounding draft. Completed commands also run after the suggestion menu is dismissed. Unknown leading commands show a local warning, and paths such as `/tmp/notes.txt` remain ordinary prompts.
249
+
240
250
  ### Keyboard shortcuts
241
251
 
242
252
  | Action | Shortcut |
243
253
  | --- | --- |
244
254
  | Send prompt | `Enter` |
245
255
  | Insert newline | `Shift+Enter`, `Alt+Enter`, or `Ctrl+N` |
256
+ | Expand shortened paste nearest the cursor | `Ctrl+E` or `Alt+E` |
246
257
  | Cancel current turn | `Esc` |
247
258
  | Interrupt; press again to quit | `Ctrl+C` |
248
259
  | Cycle mode | `Shift+Tab` |
@@ -300,7 +311,9 @@ Useful CLI flags:
300
311
 
301
312
  Place project notes in `.clai/context.md` in the working directory to supply architecture, conventions, or testing context. Project skills live under `.clai/skills/` as `SKILL.md` playbooks; `/skills list` shows discovered skills and `/skills refresh` rescans them.
302
313
 
303
- MCP servers can expose local or remote tools. Tools are disabled by default; activate a server with an `@mcp:<server>` prompt mention or enable all configured servers with `/mcp all`. `/mcp` also supports configuration, connection status, authentication, and logs.
314
+ MCP servers can expose local or remote tools. Tools are disabled by default; activate a server with an `@mcp:<server>` prompt mention or enable all configured servers with `/mcp all`. Submitted selections remain available for follow-up prompts until changed or disabled with `/mcp off`. `/mcp` also supports configuration, connection status, authentication, and tool discovery.
315
+
316
+ Use the picker to add a catalog server or paste its JSON configuration. API keys, OAuth browser sign-in, device codes, and pasted callbacks over SSH are supported. Large tool catalogs are searched on demand, keeping schemas out of repeated model requests. See the [MCP guide](MCP.md) for setup, authentication, configuration compatibility, and troubleshooting.
304
317
 
305
318
  Example `.clai/mcp.json`:
306
319
 
@@ -145,7 +145,7 @@ export async function runAgentTurn(prompt, options = {}) {
145
145
  await mcpRuntime.ensureReady();
146
146
  }
147
147
  if (mcpRuntime && mcpMentioned)
148
- mcpRuntime.applyMentionSelection(prompt);
148
+ mcpRuntime.commitMentionSelection(prompt);
149
149
  mcpLease = mcpRuntime?.beginTurn();
150
150
  const maxSteps = options.maxSteps ?? 70;
151
151
  const confirmPort = options.confirm ?? stdioConfirmPort;
@@ -1 +1 @@
1
- {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/agent/runner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAWzD,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,GACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAMjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EACL,iBAAiB,EACjB,wB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CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QACpD,IAAI,OAAO,EAAE,CAAC;YACZ,UAAU,EAAE,CAAC;YACb,OAAO,UAAU,CAAC,EAAE,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;QACtC,CAAC;QACD,eAAe,CAAC,OAAO,EAAE,CAAC;QAC1B,MAAM,GAAG,GAAG,UAAU,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/E,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YACvB,IAAI,CAAC;gBACH,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,CAAC;YAC1D,CAAC;YAAC,MAAM,CAAC;YACT,CAAC;QACH,CAAC;QACD,IAAI,CAAC;YACH,IAAI,EAAE,YAAY;YAClB,OAAO,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAChE,CAAC,CAAC;QACH,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,QAAQ,EAAE,OAAO,EAAE,CAAC;IACtB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAc,EACd,UAA2B,EAAE;IAE7B,OAAO,CAAC,MAAM,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;AACtD,CAAC"}
@@ -1,4 +1,4 @@
1
- export type StreamFailureKind = "aborted" | "content-policy" | "empty" | "context-overflow" | "rate-limit" | "server" | "network" | "stall" | "auth" | "not-found" | "unknown";
1
+ export type StreamFailureKind = "aborted" | "content-policy" | "non-retriable" | "empty" | "context-overflow" | "rate-limit" | "server" | "network" | "stall" | "auth" | "not-found" | "unknown";
2
2
  export interface StreamRecoveryState {
3
3
  empty: number;
4
4
  rateLimit: number;
@@ -1,5 +1,6 @@
1
1
  import { ProviderError, STREAM_STALL_MARKER } from "../llm/http.js";
2
2
  import { rateLimitWaitMsFor } from "../llm/key-rotation.js";
3
+ import { isHardQuotaError } from "../llm/quota-signals.js";
3
4
  import { isContentPolicyError } from "../llm/reasoning-errors.js";
4
5
  import { isEmptyCompletionError } from "../llm/router.js";
5
6
  import { SERVER_ERROR_MAX_ATTEMPTS, serverErrorAttemptsFor, } from "../llm/routing/error-classification.js";
@@ -20,10 +21,9 @@ export const FREE_STREAM_RECOVERY_LIMITS = {
20
21
  ...DEFAULT_STREAM_RECOVERY_LIMITS,
21
22
  maxServer: 0,
22
23
  maxServerAttempts: 0,
23
- maxRateLimit: 0,
24
24
  maxNetwork: 1,
25
25
  maxStall: 1,
26
- maxTotal: 1,
26
+ maxTotal: DEFAULT_STREAM_RECOVERY_LIMITS.maxRateLimit + 1,
27
27
  };
28
28
  const EMPTY_NUDGE = "Your previous response was empty. Continue the task now: emit your next tool call, " +
29
29
  "or give your final answer if every required step is already complete and verified. " +
@@ -46,6 +46,8 @@ function errorText(error) {
46
46
  .toLowerCase();
47
47
  }
48
48
  export function classifyStreamFailure(error) {
49
+ if (error instanceof ProviderError && error.retryable === false)
50
+ return "non-retriable";
49
51
  const status = errorStatus(error);
50
52
  const msg = errorText(error);
51
53
  if (/\babort(ed)?\b|operation was aborted|the operation was cancelled/.test(msg)) {
@@ -57,6 +59,8 @@ export function classifyStreamFailure(error) {
57
59
  /\b413\b|input limit|context length|context window|maximum context|too large|reduce the length|exceeded the provider input|prompt is too long|token limit/.test(msg)) {
58
60
  return "context-overflow";
59
61
  }
62
+ if (isHardQuotaError(error))
63
+ return "non-retriable";
60
64
  if (status === 429 ||
61
65
  /\b429\b|rate limit|rate-limited|too many requests|retry after|quota exceeded/.test(msg)) {
62
66
  return "rate-limit";
@@ -162,7 +166,9 @@ export function planStreamRecovery(input) {
162
166
  forceCompact: false,
163
167
  allowModelFallback: false,
164
168
  };
165
- if (kind === "aborted" || kind === "content-policy")
169
+ if (kind === "aborted" || kind === "content-policy" || kind === "non-retriable")
170
+ return giveUp;
171
+ if (input.error instanceof ProviderError && input.error.retryable === false)
166
172
  return giveUp;
167
173
  if (state.total >= limits.maxTotal)
168
174
  return giveUp;
@@ -198,7 +204,7 @@ export function planStreamRecovery(input) {
198
204
  forceCompact: false,
199
205
  allowModelFallback: true,
200
206
  notice: n === 0
201
- ? `provider rate limited — retrying in ${Math.ceil(delayMs / 1000)}s and trying alternates`
207
+ ? `provider rate limited — retrying in ${Math.ceil(delayMs / 1000)}s`
202
208
  : undefined,
203
209
  };
204
210
  }