kiki-agent-lite 0.4.2 → 0.5.0

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 (171) hide show
  1. package/dist/docs/en/configuration/config-files.md +32 -19
  2. package/dist/docs/en/configuration/data-locations.md +23 -1
  3. package/dist/docs/en/configuration/env-vars.md +6 -8
  4. package/dist/docs/en/configuration/overrides.md +19 -8
  5. package/dist/docs/en/configuration/providers.md +75 -4
  6. package/dist/docs/en/customization/agents-and-subagents.md +6 -2
  7. package/dist/docs/en/customization/personas.md +36 -2
  8. package/dist/docs/en/customization/plugins.md +41 -1
  9. package/dist/docs/en/customization/prompt-fields.md +4 -0
  10. package/dist/docs/en/features/agent-workflows.md +8 -8
  11. package/dist/docs/en/features/browser-and-computer.md +40 -0
  12. package/dist/docs/en/features/daily.md +10 -10
  13. package/dist/docs/en/features/ecosystem.md +5 -5
  14. package/dist/docs/en/features/extend.md +9 -8
  15. package/dist/docs/en/features/freedom.md +8 -8
  16. package/dist/docs/en/features/index.md +44 -28
  17. package/dist/docs/en/features/long-work.md +9 -9
  18. package/dist/docs/en/features/look.md +5 -5
  19. package/dist/docs/en/features/people.md +6 -6
  20. package/dist/docs/en/features/phone.md +5 -3
  21. package/dist/docs/en/features/spaces.md +7 -7
  22. package/dist/docs/en/features/workbench.md +8 -8
  23. package/dist/docs/en/guides/interface.md +16 -4
  24. package/dist/docs/en/guides/sessions.md +6 -2
  25. package/dist/docs/en/guides/settings.md +15 -2
  26. package/dist/docs/en/reference/command.md +58 -1
  27. package/dist/docs/en/reference/tools.md +25 -5
  28. package/dist/docs/en/server/acp.md +3 -1
  29. package/dist/docs/en/server/mcp.md +5 -1
  30. package/dist/docs/en/server/rest-api.md +115 -4
  31. package/dist/docs/zh/configuration/config-files.md +32 -19
  32. package/dist/docs/zh/configuration/data-locations.md +23 -1
  33. package/dist/docs/zh/configuration/env-vars.md +6 -8
  34. package/dist/docs/zh/configuration/overrides.md +19 -8
  35. package/dist/docs/zh/configuration/providers.md +75 -4
  36. package/dist/docs/zh/customization/agents-and-subagents.md +6 -2
  37. package/dist/docs/zh/customization/personas.md +36 -2
  38. package/dist/docs/zh/customization/plugins.md +41 -1
  39. package/dist/docs/zh/customization/prompt-fields.md +4 -0
  40. package/dist/docs/zh/features/agent-workflows.md +10 -10
  41. package/dist/docs/zh/features/browser-and-computer.md +40 -0
  42. package/dist/docs/zh/features/daily.md +10 -10
  43. package/dist/docs/zh/features/ecosystem.md +5 -5
  44. package/dist/docs/zh/features/extend.md +8 -7
  45. package/dist/docs/zh/features/freedom.md +8 -8
  46. package/dist/docs/zh/features/index.md +44 -28
  47. package/dist/docs/zh/features/long-work.md +8 -8
  48. package/dist/docs/zh/features/look.md +5 -5
  49. package/dist/docs/zh/features/people.md +5 -5
  50. package/dist/docs/zh/features/phone.md +5 -3
  51. package/dist/docs/zh/features/spaces.md +7 -7
  52. package/dist/docs/zh/features/workbench.md +8 -8
  53. package/dist/docs/zh/guides/interface.md +16 -4
  54. package/dist/docs/zh/guides/sessions.md +6 -2
  55. package/dist/docs/zh/guides/settings.md +15 -2
  56. package/dist/docs/zh/reference/command.md +58 -1
  57. package/dist/docs/zh/reference/tools.md +25 -5
  58. package/dist/docs/zh/server/acp.md +3 -1
  59. package/dist/docs/zh/server/mcp.md +5 -1
  60. package/dist/docs/zh/server/rest-api.md +114 -3
  61. package/dist/hostRunner.mjs +92 -1
  62. package/dist/mailbox-worker.mjs +297 -0
  63. package/dist/main.mjs +2 -2
  64. package/dist/native/windows-process-helper.exe +0 -0
  65. package/dist/query-store-worker.mjs +446 -0
  66. package/dist/sqlite-indexer.mjs +223 -401
  67. package/dist/sqlite-query-worker.mjs +226 -249
  68. package/dist/usage-parser-worker.mjs +24 -5
  69. package/dist/web/assets/AppErrorBoundary-BN6IDdP1.js +1 -0
  70. package/dist/web/assets/{LifeMark-CL6-HWDu.js → LifeMark-UBMVaTWr.js} +1 -1
  71. package/dist/web/assets/{NavScopeBoundary-CFCnvZR0.js → NavScopeBoundary-BCryw-UG.js} +1 -1
  72. package/dist/web/assets/{arc-DYDCMlOS.js → arc-C7IAvCCJ.js} +1 -1
  73. package/dist/web/assets/{architectureDiagram-3BPJPVTR-C9Y7T0O2.js → architectureDiagram-3BPJPVTR-CbwFBxn7.js} +1 -1
  74. package/dist/web/assets/{blockDiagram-GPEHLZMM-CdUrp-tD.js → blockDiagram-GPEHLZMM-B20N4t8r.js} +1 -1
  75. package/dist/web/assets/{c4Diagram-AAUBKEIU-PrwvB9IJ.js → c4Diagram-AAUBKEIU-3BYtlcP-.js} +1 -1
  76. package/dist/web/assets/channel-BJs5vJuh.js +1 -0
  77. package/dist/web/assets/{chunk-2J33WTMH-BL56g_Es.js → chunk-2J33WTMH-CpjgczxM.js} +1 -1
  78. package/dist/web/assets/{chunk-4BX2VUAB-DvJD5M9M.js → chunk-4BX2VUAB-BScxUF5G.js} +1 -1
  79. package/dist/web/assets/{chunk-55IACEB6-C8f-nzvx.js → chunk-55IACEB6-CrcLYJXd.js} +1 -1
  80. package/dist/web/assets/{chunk-727SXJPM-DOGkWKkV.js → chunk-727SXJPM-BwlyIOjw.js} +1 -1
  81. package/dist/web/assets/{chunk-AQP2D5EJ-fFOuz7g6.js → chunk-AQP2D5EJ-DKKIRkRv.js} +1 -1
  82. package/dist/web/assets/{chunk-FMBD7UC4-BpeXZ9LM.js → chunk-FMBD7UC4-CVDMj2kX.js} +1 -1
  83. package/dist/web/assets/{chunk-ND2GUHAM-CRUh76fb.js → chunk-ND2GUHAM-CL-PM6r8.js} +1 -1
  84. package/dist/web/assets/{chunk-QZHKN3VN-uNfxaPk0.js → chunk-QZHKN3VN-DPV2KbKZ.js} +1 -1
  85. package/dist/web/assets/classDiagram-4FO5ZUOK-BookeACB.js +1 -0
  86. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-BookeACB.js +1 -0
  87. package/dist/web/assets/client-CXcrCawx.js +3 -0
  88. package/dist/web/assets/connection-C8nwzwXB.js +1 -0
  89. package/dist/web/assets/{cose-bilkent-S5V4N54A-BNkxG-qX.js → cose-bilkent-S5V4N54A-D1CEiQM6.js} +1 -1
  90. package/dist/web/assets/{dagre-BM42HDAG-BerioUei.js → dagre-BM42HDAG-BlFV941E.js} +1 -1
  91. package/dist/web/assets/{diagram-2AECGRRQ-Czv2SR07.js → diagram-2AECGRRQ-BC0ldkFY.js} +1 -1
  92. package/dist/web/assets/{diagram-5GNKFQAL-Uzi1weGK.js → diagram-5GNKFQAL-B22Iej6G.js} +1 -1
  93. package/dist/web/assets/{diagram-KO2AKTUF-W36h_ff3.js → diagram-KO2AKTUF-B75UNw6D.js} +1 -1
  94. package/dist/web/assets/{diagram-LMA3HP47-FG4dDk52.js → diagram-LMA3HP47-CypI7IJM.js} +1 -1
  95. package/dist/web/assets/{diagram-OG6HWLK6-CQoEjIAY.js → diagram-OG6HWLK6-OsXumvcD.js} +1 -1
  96. package/dist/web/assets/{erDiagram-TEJ5UH35-Ck06KVyZ.js → erDiagram-TEJ5UH35-3756GOvS.js} +1 -1
  97. package/dist/web/assets/{export-T_izwEkQ.js → export-Bn8PqPg4.js} +1 -1
  98. package/dist/web/assets/{flowDiagram-I6XJVG4X-C5hgxdFZ.js → flowDiagram-I6XJVG4X-DB6Y_UDg.js} +1 -1
  99. package/dist/web/assets/{ganttDiagram-6RSMTGT7-BS52Pw5_.js → ganttDiagram-6RSMTGT7-CHJeuoAY.js} +1 -1
  100. package/dist/web/assets/{gitGraphDiagram-PVQCEYII-DLlQKZHs.js → gitGraphDiagram-PVQCEYII-Dj85554Y.js} +1 -1
  101. package/dist/web/assets/{highlighted-body-OFNGDK62-Btm6MuZ4.js → highlighted-body-OFNGDK62-DMgPHetp.js} +1 -1
  102. package/dist/web/assets/{index-CZX3qUe2.js → index-0tHq8zh2.js} +1 -1
  103. package/dist/web/assets/index-7ySDqvaN.css +1 -0
  104. package/dist/web/assets/index-B0KPRi1U.js +166 -0
  105. package/dist/web/assets/{index-CRDDqofN.js → index-B599VnpP.js} +1 -1
  106. package/dist/web/assets/{index-Cd62y0wD.js → index-BFK-GypQ.js} +1 -1
  107. package/dist/web/assets/{index-BMWid2q9.js → index-BPX8gmpB.js} +1 -1
  108. package/dist/web/assets/{index-5_yzg61S.js → index-BSGYc1tb.js} +1 -1
  109. package/dist/web/assets/{index-CJ92kLtO.js → index-BTt9Q5iv.js} +1 -1
  110. package/dist/web/assets/{index-B4iu4SJW.js → index-BWzUsoY_.js} +1 -1
  111. package/dist/web/assets/{index-CgcJPsK6.js → index-BYlSV3FO.js} +1 -1
  112. package/dist/web/assets/{index-BkPV0psm.js → index-BpXQ1q-u.js} +1 -1
  113. package/dist/web/assets/{index-Dceu0bqY.js → index-BqPxpGUh.js} +1 -1
  114. package/dist/web/assets/{index-CM-nNfuV.js → index-C6qeLCPw.js} +4 -4
  115. package/dist/web/assets/{index-ByiwExpV.js → index-C7mOS2T4.js} +1 -1
  116. package/dist/web/assets/{index-CG8uIlD7.js → index-C8OFfbEs.js} +1 -1
  117. package/dist/web/assets/{index-B-6LiYTY.js → index-CI7yuMGZ.js} +1 -1
  118. package/dist/web/assets/{index-B2Pu0Iuu.js → index-CJqIcuAl.js} +1 -1
  119. package/dist/web/assets/{index-BECSk4If.js → index-CTRJmDep.js} +1 -1
  120. package/dist/web/assets/{index-Bezli3SF.js → index-CXGCKoId.js} +1 -1
  121. package/dist/web/assets/{index-hG2s2Spn.js → index-CsY571EL.js} +1 -1
  122. package/dist/web/assets/{index-BFcyN2Zw.js → index-CwQG_9rB.js} +1 -1
  123. package/dist/web/assets/{index-BLU8_Um7.js → index-D--cw39y.js} +1 -1
  124. package/dist/web/assets/{index-B9MlqF7J.js → index-D260jsUJ.js} +1 -1
  125. package/dist/web/assets/{index-D_oPSlBL.js → index-DJjmEXx4.js} +1 -1
  126. package/dist/web/assets/{index-BNch_a4L.js → index-DRMjjql1.js} +1 -1
  127. package/dist/web/assets/{index-BeMvPEXs.js → index-DUxOVxHS.js} +1 -1
  128. package/dist/web/assets/{index-Ca607_hK.js → index-DZMkZKhW.js} +1 -1
  129. package/dist/web/assets/{index-BwcG86o3.js → index-DqK8MfQN.js} +1 -1
  130. package/dist/web/assets/{index-DKIysLbI.js → index-DxUmR9aV.js} +1 -1
  131. package/dist/web/assets/{index-Cy8C_eFR.js → index-GK8aa9pT.js} +1 -1
  132. package/dist/web/assets/{index-Bg99yVX_.js → index-bYtKyBMB.js} +1 -1
  133. package/dist/web/assets/{index-eUyF-8Sq.js → index-wxHFHTgD.js} +1 -1
  134. package/dist/web/assets/{infoDiagram-5YYISTIA-CD4XJGFm.js → infoDiagram-5YYISTIA-DeDPIdEH.js} +1 -1
  135. package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-fu5E3_CT.js → ishikawaDiagram-YF4QCWOH-ButuBiBW.js} +1 -1
  136. package/dist/web/assets/{journeyDiagram-JHISSGLW-CXcnKBfJ.js → journeyDiagram-JHISSGLW-Dlbmqm-j.js} +1 -1
  137. package/dist/web/assets/{kanban-definition-UN3LZRKU-BawKH6Pl.js → kanban-definition-UN3LZRKU-tlQK1cOz.js} +1 -1
  138. package/dist/web/assets/{linear-BplJuXph.js → linear-iXuNfUWp.js} +1 -1
  139. package/dist/web/assets/mermaid-GHXKKRXX-sDJax95P.js +624 -0
  140. package/dist/web/assets/{mindmap-definition-RKZ34NQL-DA1SE2uy.js → mindmap-definition-RKZ34NQL-2qPv-mwT.js} +1 -1
  141. package/dist/web/assets/{pieDiagram-4H26LBE5-6i021QeX.js → pieDiagram-4H26LBE5-CrLe1C-O.js} +1 -1
  142. package/dist/web/assets/{quadrantDiagram-W4KKPZXB-CcKSZDMT.js → quadrantDiagram-W4KKPZXB-DfeIFxc0.js} +1 -1
  143. package/dist/web/assets/{requirementDiagram-4Y6WPE33-lYVuWRuD.js → requirementDiagram-4Y6WPE33-BWtjdxie.js} +1 -1
  144. package/dist/web/assets/{sankeyDiagram-5OEKKPKP-4Zfb4_h4.js → sankeyDiagram-5OEKKPKP-B5TxJ6mb.js} +1 -1
  145. package/dist/web/assets/{sequenceDiagram-3UESZ5HK-DqltKmlY.js → sequenceDiagram-3UESZ5HK-Cf92ZCl1.js} +1 -1
  146. package/dist/web/assets/{spaces-CjuXbmxF.js → spaces-DqMTtCXX.js} +1 -1
  147. package/dist/web/assets/{stateDiagram-AJRCARHV-HFdhqxzx.js → stateDiagram-AJRCARHV-NR9I-Q4d.js} +1 -1
  148. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-BiegFWxE.js +1 -0
  149. package/dist/web/assets/{theme-beWE_6f8.js → theme-6OL1RXgY.js} +1 -1
  150. package/dist/web/assets/{timeline-definition-PNZ67QCA-HNRxaB3t.js → timeline-definition-PNZ67QCA-CBAOVMfm.js} +1 -1
  151. package/dist/web/assets/{vennDiagram-CIIHVFJN-DwsCTyaD.js → vennDiagram-CIIHVFJN-C68x6TdS.js} +1 -1
  152. package/dist/web/assets/{wardley-L42UT6IY-BWW2wtVO.js → wardley-L42UT6IY-DuZZr5jm.js} +1 -1
  153. package/dist/web/assets/{wardleyDiagram-YWT4CUSO-C-ktKm7v.js → wardleyDiagram-YWT4CUSO-D6dVGtHd.js} +1 -1
  154. package/dist/web/assets/{xychartDiagram-2RQKCTM6-48AxNW9k.js → xychartDiagram-2RQKCTM6-DYLUhZX4.js} +1 -1
  155. package/dist/web/index.html +2 -2
  156. package/native/auth-native/prebuilds/linux-arm64/auth-native.node +0 -0
  157. package/native/auth-native/prebuilds/linux-x64/auth-native.node +0 -0
  158. package/native/auth-native/prebuilds/win32-arm64/auth-native.node +0 -0
  159. package/native/auth-native/prebuilds/win32-x64/auth-native.node +0 -0
  160. package/package.json +2 -2
  161. package/dist/search-worker.mjs +0 -14177
  162. package/dist/web/assets/AppErrorBoundary-DiGMUg4r.js +0 -1
  163. package/dist/web/assets/channel-Bj_gZ_Lv.js +0 -1
  164. package/dist/web/assets/classDiagram-4FO5ZUOK-ssCwe2R4.js +0 -1
  165. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-ssCwe2R4.js +0 -1
  166. package/dist/web/assets/client-DGj93bGT.js +0 -3
  167. package/dist/web/assets/connection-Bpf-EjrL.js +0 -1
  168. package/dist/web/assets/index-BIebkSEI.css +0 -1
  169. package/dist/web/assets/index-D8z7lcQn.js +0 -166
  170. package/dist/web/assets/mermaid-GHXKKRXX-BO9hkP3Z.js +0 -621
  171. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-Dx28QuZF.js +0 -1
@@ -91,6 +91,23 @@ Endpoints are grouped by resource below. A `:{action}` suffix in a path is the a
91
91
  | `GET /api/meta` | Server version, capability map, `server_id`, experimental flags |
92
92
  | `POST /api/shutdown` | Graceful shutdown (replies 200 first); mounted only on loopback binds |
93
93
 
94
+ ### Mailbox storage upgrade
95
+
96
+ A home with legacy or interrupted mailbox storage starts in maintenance mode before the ordinary engine, plugins, or sessions are bootstrapped. Authenticated `GET /api/meta` returns `storage_mode: "maintenance"`, `storage_status_path: "/api/storage"`, and the usual `server_id` and `server_home_id`; unavailable capabilities are `false`. It uses the existing server address, authentication, host checks, and origin policy. Session endpoints return HTTP `503` until normal startup.
97
+
98
+ | Method and path | Request | Response data |
99
+ | --- | --- | --- |
100
+ | `GET /api/storage` | No body | `StorageMigrationView`; reads status without starting migration or changing authority |
101
+ | `POST /api/storage` | `{ "action": "migrate" }`, `cancel`, `rollback`, `start`, or `retry_cleanup` | Updated `StorageMigrationView`; launches the requested operation |
102
+
103
+ The schemas are exported by `@kiki/protocol`: `storageMigrationViewSchema` and `storageMigrationActionSchema`. A view contains `schemaVersion: 1`, `mode`, `status`, `actions`, `transition`, and optional `operationFailure`. Status supplies `authority`, `phase`, `state`, `progress`, source and backup paths, optional `writer`, `failure`, and `warning`, and `canCancel` / `canRollback`. These status fields also appear in [`kiki storage --json`](../reference/command.md#kiki-storage). A `mailbox.checkpoint_warning` means the SQLite mailbox is usable but historical upgrade progress needs repair before rollback; it does not mark migration as failed or offer another `migrate`.
104
+
105
+ Drive controls from `actions`, not from a guessed combination of phase and state: a durable phase may finish while its worker and locks are still closing. `migrate` resumes preserved progress; `waiting` leaves the old writer in control, so stop that writer and retry when `migrate` is offered. `cancel` stops a cancellable import or normal-start attempt. `rollback` is offered only while the original can be restored without losing new SQLite writes. A malformed action returns envelope code `40001`; an unavailable action returns `40901`. Missing credentials return HTTP `401`.
106
+
107
+ After migration, `start` explicitly requests normal startup. Continue polling the same address: preparation longer than 30 seconds remains `starting`, with `cancel` available rather than an automatic timeout. A failed or cancelled start leaves the upgrade intact and reports `transition.state: "failed"` with the original startup `failure`. While the attempt is closing, `cleanupPending` is `true` and `actions` is empty; another start waits for its cleanup. If cleanup fails, `transition.cleanupFailure` explains it and the only action is `retry_cleanup`; this retries unfinished cleanup without starting the engine again. Once cleanup succeeds, `cleanupPending` becomes `false` and `actions` offers `start` and any available `rollback`.
108
+
109
+ Switch to normal session loading only when `GET /api/meta` reports `storage_mode: "normal"` with the same `server_id` and `server_home_id`. The home, identity, and port stay unchanged; clients do not need to launch another daemon. An interrupted rollback also returns to maintenance and offers `rollback` so it can finish before another migration or normal startup. In normal mode, `GET /api/storage` remains readable and `actions` is empty.
110
+
94
111
  ### Space presets
95
112
 
96
113
  `GET /api/homes/presets` returns `{ items: [{ id, name, color?, description }] }`. Only the `kiki` baseline preset is currently bundled. Create a space from the main space's server with `POST /api/homes`:
@@ -146,6 +163,8 @@ The response uses schema version `1` with independent sources and meters. Each m
146
163
  | `GET /api/config` | Read the global config (secret fields redacted) |
147
164
  | `POST /api/config` | Merge-patch the config; broadcasts `event.config.changed` |
148
165
 
166
+ `request_compression` and `responses_web_socket` are system sections on both calls. Omit a section to leave it unchanged. JSON `null` removes it. A compression object needs `encoding` and `targets`, with optional `min_bytes` and `dictionary`, or `encoding` set to `"off"` and no other fields. `dictionary` applies only to `zstd`. A WebSocket object needs `targets`, or `off: true` and no targets. An incomplete object is rejected and the saved file stays unchanged.
167
+
149
168
  Session-title prompt reads, read-only defaults and field-level save/delete patches are documented under [`session_title`](../configuration/config-files.md#session-title).
150
169
 
151
170
  The `hooks` value accepts a legacy command-rule array or a declarative object with `schemaVersion: 2`. Both reads and saves retain the complete value, including `rules`, `legacy`, `enabled`, `disabled`, and `files`. Nested JSON keys use camelCase (`textFile`, `agentRoles`, `everyCompletedSteps`, `counterScope`, `partitionBy`); TOML uses snake_case. Send the complete hooks array or object when editing it; omit `hooks` to leave it unchanged, or send `[]` to clear it. `null` and unsupported rule shapes return validation code `40001` without changing the saved file. Reading or saving configuration does not execute hook commands. See [Hooks](../customization/hooks.md) for supported events and actions.
@@ -165,12 +184,16 @@ The `hooks` value accepts a legacy command-rule array or a declarative object wi
165
184
  | `POST /api/providers` | Create a provider (201) |
166
185
  | `GET /api/providers/{provider_id}` | Read a provider (reveals the stored key) |
167
186
  | `PATCH /api/providers/{provider_id}` | Change only the supplied provider fields |
187
+
188
+ `GET /api/providers` and `GET /api/providers/{provider_id}` include `request_compression` and `responses_web_socket` when that provider saved them. A partial compression object, `encoding: "off"`, `off: true`, and the saved `targets` order come back as stored. The read does not fill those fields from the system section. `POST /api/providers` and `PATCH /api/providers/{provider_id}` accept the same objects. JSON `null` on PATCH clears that provider field. Omitted fields stay unchanged.
168
189
  | `DELETE /api/providers/{provider_id}` | Delete a provider (204) |
169
190
  | `POST /api/providers/{provider_id}:refresh` | Refresh one provider's model metadata |
170
191
  | `POST /api/providers:{action}` | Collection actions: `refresh` / `refresh_oauth` / `import_catalog` / `import_registry` |
171
192
  | `GET /api/catalog/providers` | Browse the models.dev directory (server-proxied) |
172
193
  | `GET /api/catalog/providers/{catalog_id}` | Read one directory entry |
173
194
 
195
+ Directory reads return the last fetched catalog or bundled snapshot immediately while one background update runs. Successful fetches are fresh for ten minutes; a failed background update leaves the local directory readable and postpones another automatic attempt for ten minutes. Without a local catalog, the read waits for the upstream fetch and reports an error if it fails. Explicit `import_catalog` waits for any required catalog update before validating and saving the selected entry; if upstream is unavailable, it can use the same cached or bundled entry. Directory browsing never fetches model lists from your configured providers; those requests require an explicit `refresh` action.
196
+
174
197
  Model creation accepts an optional `protocol`: `openai`, `openai_responses`, `anthropic`, or `google-genai`. PATCH accepts the same values; omitted `protocol` leaves the model unchanged, and `"protocol": null` clears the local override. Include `base_revision` from the model read to reject concurrent changes without writing. Invalid protocol values return `config.invalid` (business code `40001`) without changing configuration.
175
198
 
176
199
  Model reads expose the saved `protocol` and resolved `effective_protocol` separately. An absent saved value inherits the provider's default format; an absent effective value in the list means no usable requester was materialized. Changing a model's protocol does not write the provider connection, credentials, request identity, or default pointers. See [model request format overrides](../configuration/providers.md#model-request-format-overrides) for configuration examples and endpoint compatibility.
@@ -242,6 +265,8 @@ Attachment does not copy the vendor transcript or send a prompt. The first promp
242
265
 
243
266
  When the session is not live in this process, the snapshot is read from the saved main-agent wire and session metadata. The request does not resume the session or its workspace. `messages` is the newest 100 entries of the current logical context after compaction, undo, and edit, oldest first. `has_more` is true when older logical entries exist, and `message_count` is that logical length. `as_of_seq` and `epoch` are the session journal watermark. Permission mode and plan mode come from the saved runtime records; model and effort come from the saved agent binding. Context-token totals and breakdowns are omitted when this process has not measured them. `in_flight_turn`, `pending_approvals`, and `pending_questions` describe only activity in this process, so a session that is active in another process is not reported as active here.
244
267
 
268
+ Session reads and `event.session.work_changed` expose `executing` separately from `busy`. `busy` includes unfinished work, queued prompts and terminal task results awaiting delivery. `executing` reports current local execution or finite process/media work; it excludes those queues, undelivered terminal results, resident services and agent task rows without an active executor. A cold session reports `executing: false` for this process. Older servers omit the field; omission means unknown. A historical subagent row with `status: "running"` is not current execution evidence.
269
+
245
270
  Snapshot `subagents` roster rows carry an optional `created_at` UTC ISO timestamp for the agent's immutable creation time. A newly created agent has it before its first run starts, including while queued; resuming the same agent, restoring its scope, restarting the server, or switching its model does not change it. A fork that creates a new agent records a new creation time. The separate optional `started_at` identifies the run described by the row and may change on a later run.
246
271
 
247
272
  Model, effort and executor fields prefer the current committed agent metadata over its spawn snapshot, with spawn values used only when current values are unavailable. Effort provenance and executor protocol stay with their selected source; a current binding alone does not prove which model served a request.
@@ -250,6 +275,15 @@ An agent whose saved metadata has no creation time omits `created_at`; treat it
250
275
 
251
276
  For automatic allocation, send `{}` to `POST /api/sessions`. The server creates a distinct directory under `$KIKI_HOME/workspaces/`, registers it, and returns its `workspace_id` and `metadata.cwd` in the session response. Supplying an existing `workspace_id` or `metadata.cwd` keeps the existing targeting behavior; an unknown `workspace_id` is still rejected.
252
277
 
278
+ For retry-safe creation, generate a UUID once and send it as the optional top-level `creation_id`. Keep that ID and the same request body when retrying after a timeout or disconnect. Concurrent matching requests share the creation; completed requests replay the saved result, including after a server restart. Saved failures are also replayed without repeating creation side effects. The resulting session ID is `session_<creation_id>`, with the UUID normalized to lowercase.
279
+
280
+ Creation identities belong to the connected home: clients must keep separate pending requests for each home and connection. Omitting `creation_id` retains ordinary creation without retry deduplication. Cancelling a client wait does not delete a session the server has created.
281
+
282
+ | Creation error code | Recovery |
283
+ | --- | --- |
284
+ | `40948` | The creation identity conflicts. `details.reason` is `body_mismatch` when the same `creation_id` carries a different body, or `session_id_exists` when its mapped session ID is already occupied outside this creation. Keep the pending identity and draft. A collision is not a successful replay; use a new ID only for a deliberately separate creation. |
285
+ | `50006` | The creation outcome is unconfirmed. `details` contains `{ creation_id, session_id, evidence }`. Diagnostic values include `session_present_without_completion`, `session_absent`, `completion_receipt_write_failed`, `session_read_error`, and `receipt_read_error`; clients must also preserve unknown diagnostic values. Keep the draft and creation identity, and inspect the exact session ID. This code never confirms that starting a replacement is safe; the server does not rerun creation or its hooks. |
286
+
253
287
  Set `agent_config.execution` at creation to select a harness independently of a profile:
254
288
 
255
289
  ```json
@@ -343,7 +377,19 @@ Invalid request shapes, empty messages, missing targets and unavailable uploads
343
377
 
344
378
  Read `GET /api/sessions/{session_id}/prompts?admission=durable` to receive `ingress` items. Follow `ingress_next_cursor` as `cursor` until absent, even if a page has no items for the selected agent. Pages scan at most 64 saved requests and return a text preview of at most 1024 characters with `admission_content_truncated: true`. A saved request with no text previews as `[Attachment]`. Use the point-read route for the original. Both reads leave cold agents unloaded. For a child agent, include the same `agent_id` in the submission body and every query or action.
345
379
 
346
- `admission: "admitted"` means the agent accepted the request; `status` reports its saved receipt state, not its current queue position or model consumption. For immediate delivery, optional `delivery_state: "steered"` means the core assigned the message to the target turn; `"queued"` means it is still awaiting delivery, including a pending model-switch boundary. Neither assignment nor admission confirms insertion into a model request; use the delivered transcript frame and subsequent request for that.
380
+ `admission: "admitted"` means the agent accepted the request; `status` reports its saved receipt state, not its current queue position or model consumption. For immediate delivery, optional `delivery_state: "steered"` means the core assigned the message to the target turn; `"queued"` means it was awaiting delivery when that receipt was recorded, including a pending model-switch boundary. Neither assignment nor admission confirms insertion into a model request; use the delivered transcript frame and subsequent request for that. A newer canonical started, steered or terminal prompt takes precedence over an older queued receipt.
381
+
382
+ Optional `delivery_reason` explains the immediate-delivery decision on submit receipts and durable reads. A single-ID `:steer` response also carries `delivery_state` and `delivery_reason`; its existing `steered: true` acknowledges the command, not model consumption. Multi-ID steer acknowledgements omit these single-prompt fields.
383
+
384
+ | `delivery_reason` | Meaning |
385
+ | --- | --- |
386
+ | `target_changed` | The active turn or prompt changed before delivery; the message was left queued. |
387
+ | `steer_rejected` | The core refused insertion into the active turn, such as for incompatible execution controls. |
388
+ | `executor_deferred` | The external executor did not deliver this message into its active run; it remains queued for a later turn. This does not distinguish an unsupported operation from a declined one. |
389
+ | `model_switch_boundary` | Delivery is waiting for the selected model-switch boundary. |
390
+ | `no_active_turn` | No active turn was available; the selected message follows the new-turn path. |
391
+ | `external_retry` | A known external submission was replayed without repeating its immediate-delivery action. |
392
+ | `prompt_no_longer_pending` | The prompt was no longer selectable in the pending queue. This alone proves neither delivery nor that it is still queued; read its canonical state. |
347
393
 
348
394
  `failed` includes `admission_error` and keeps the original content and attachments. Restarted or uncertain submissions become `held` until an explicit `:resume`; the server checks the original receipt before retrying, and a failed receipt lookup does not authorize another launch. Use `:abort` to cancel. `aborted: false` with admission `held` means cancellation still needs reconciliation; `cancelled` confirms it. To edit a saved request, cancel it and submit a new ID.
349
395
 
@@ -451,11 +497,21 @@ These endpoints manage saved browser connections, not the sessions that use them
451
497
 
452
498
  `PUT` takes the same discriminated body as the GUI. A body whose `type` is `agent-browser-profile` needs `name` and accepts `profilePath`, `executablePath`, `headed` and `driverPath`; one whose `type` is `agent-browser-cdp` needs `name` and `endpoint` — either `{ "action": "set", "value": "<CDP http/ws URL>" }` or `{ "action": "keep" }` to leave the stored address unchanged. Both accept `enabled`, which defaults to `true`. A new CDP connection without `set` is rejected. A stored CDP address reads back masked; revealing it is an explicit `POST /api/secrets:reveal` whose `ref` has `kind: "browser_endpoint"`. A body whose `type` is `ego-lite` needs `name` and accepts optional `cliPath`, `profileId`, and `serverName`. It has no endpoint.
453
499
 
500
+ A `kimi-webbridge` body needs `name`, accepts `enabled` and optional `driverPath`, and rejects `endpoint`. It uses the Kimi HTTP daemon at `http://127.0.0.1:10086` on the server; it does not start the CDP driver. Legacy saved CDP entries whose id is exactly `kimi-webbridge` use this HTTP route by default without rewriting the saved type; see [`webbridge_preset_route`](../configuration/config-files.md#browser-control). Other CDP ids keep their CDP route.
501
+
502
+ A `webbridge-command` body needs `name`, accepts `enabled` (default `true`), and rejects both `endpoint` and `driverPath`. It sends extension commands to the fixed local `/command` endpoint without starting agent-browser. Its catalog reports `contextIsolation: "extension-command-session"`. Each caller has a separate command session; tab identities are `wb:<decimal id>`, not DevTools target IDs. Page actions, tab selection and close apply only to the tab that caller's last navigate opened. Kiki does not find a different tab by URL, including when two tabs share a URL. Window and frame methods are unavailable. Disconnect releases Kiki's binding without closing tabs; the explicit `agent_browser_end_session` page operation closes that caller's command session.
503
+
504
+ The existing `kimi-webbridge` HTTP bridge's catalog reports `contextIsolation: "main-frame-only"`: window creation and non-main frames are unsupported. Tab selection uses the exact id returned by the tab list and verifies the selected id; switching to another tab is rejected when duplicate URLs prevent an unambiguous selection. When a command was sent but its response is lost or unreadable, status is `unconfirmed` with `failure.reason: "outcome_unknown"`. The command is not replayed. `:check` only checks bridge health; if it returns `idle`, reconnect, select the tab, and observe it before deciding the next action. An explicit negative acknowledgement is a finished `failed` result instead.
505
+
454
506
  Execution actions fail closed: without the `native_browser` experimental flag `:connect` returns envelope code `40001` with `details.code: "browser.disabled"` and `details.reason: "feature_disabled"`, while a switched-off connection returns `details.reason: "connection_disabled"`. Klient exposes the same surface as `rest.browser.list()`, `upsert(id, input)`, `remove(id)`, `setDefault(browser?)`, `status(id)`, `tabs(id)`, `catalog(id, { includeSchema })`, `check(id)`, `connect(id)`, and `disconnect(id)`.
455
507
 
456
508
  ### Browser setup presets
457
509
 
458
- Presets are `kimi-webbridge`, `independent-browser`, `codex-browser`, and `ego-lite`. `kimi-webbridge` and `independent-browser` manage local components, while `codex-browser` lists matching endpoint names as unverified candidates (`candidates`, up to 20 entries) and saves an explicitly selected pipe. The name prefix is shared with desktop app tools, so discovery does not verify an extension connection. An empty list alone does not establish that the extension is disabled. Kiki does not install the external app. `kimi-webbridge` connects and opens one fixed local bridge and does not take a candidate list. Codex pipes and independent-browser profiles are separate connection styles; they do not create extra Kimi WebBridge instances. `ego-lite` uses `controlSurface: "external-app"` and `sourceUrl` `https://lite.ego.app/download?auto=1`. Its status does not launch `nodejs`. `ready` is reported only after a check prints `kiki-ego-ready`. Other reasons are `ego_installed`, `ego_onboarding`, and `ego_choose_cli`. `:prepare` rejects this preset. `:connect` runs the check and, when it succeeds and the id is absent, saves connection id `ego-lite` without changing the allowed set or the default browser.
510
+ Presets are `kimi-webbridge`, `independent-browser`, `codex-browser`, and `ego-lite`. `kimi-webbridge` and `independent-browser` manage local components, while `codex-browser` lists matching endpoint names as unverified candidates (`candidates`, up to 20 entries) and saves an explicitly selected pipe. The name prefix is shared with desktop app tools, so discovery does not verify an extension connection. An empty list alone does not establish that the extension is disabled. Kiki does not install the external app. `kimi-webbridge` connects and opens one fixed local bridge and does not take a candidate list. After the extension probe succeeds, it creates an endpoint-free `webbridge-command` connection if that id is free and returns `connectionId: "webbridge-command"` plus `connection` runtime state. If another type already occupies the id, it returns `reason: "connection_conflict"` without replacing that row or any existing `kimi-webbridge` connection. Codex pipes and independent-browser profiles are separate connection styles; they do not create extra Kimi WebBridge instances.
511
+
512
+ `ego-lite` uses `controlSurface: "external-app"` and `sourceUrl` `https://lite.ego.app/download?auto=1`. Status reads share one background detection. While it runs, GET returns `state: "preparing"`, `reason: "ego_detecting"`, and a `detect` step in `running`; the other presets remain available. Poll again to read the outcome. Discovery and any automatic CLI check share a five-second deadline; a timeout returns `failed` with `reason: "ego_detection_failed"` and its error. Completed results stay fresh for 30 seconds from completion. `:cancel` stops the active detection, and disabling the source stops it without changing browser permissions.
513
+
514
+ An existing saved Ego connection or a recognized Citro installation can be checked automatically with `nodejs`; an unrelated executable found only on PATH requires an explicit check. `ready` is reported only after a check prints `kiki-ego-ready`. Other reasons are `ego_installed`, `ego_onboarding`, and `ego_choose_cli`. `:prepare` rejects this preset. `:connect` runs the check and, when it succeeds and the id is absent, saves connection id `ego-lite` without changing the allowed set or the default browser.
459
515
 
460
516
  | Method and path | Description |
461
517
  | --- | --- |
@@ -554,13 +610,21 @@ The peer-thread endpoints support cross-session collaboration: a thread is addre
554
610
  | Method and path | Description |
555
611
  | --- | --- |
556
612
  | `GET /api/threads` | List addressable threads, filterable by `workspace_id`; cursor pagination |
557
- | `POST /api/threads:read` | Read a thread's completed turns with their recorded origin, optionally continuing from a `cursor` |
613
+ | `POST /api/threads:read` | Read a thread's completed turns with their recorded origin, optionally continuing from a `cursor`; preparation can return an incomplete page with an opaque continuation |
558
614
  | `POST /api/threads:send` | Durably accept a message for another thread (requires a non-empty `idempotency_key`; a key maps to a single message) |
559
615
  | `POST /api/threads:wait` | Long-poll for activity on up to 8 threads, `timeout_ms` capped at 60 seconds |
560
616
  | `GET /api/workspaces/{workspace_id}/thread-communication` | Read the persisted override and effective thread-communication state for the workspace |
561
617
  | `PUT /api/workspaces/{workspace_id}/thread-communication` | Persist the workspace's enable/disable override |
562
618
  | `DELETE /api/workspaces/{workspace_id}/thread-communication` | Clear the override |
563
619
 
620
+ #### ThreadRead continuation
621
+
622
+ A `POST /api/threads:read` response can contain `turns: []`, `incomplete: "history_preparing"`, and an opaque `next_cursor` while the local history projection is preparing. This is an incomplete preparation page, not proof that the thread has no conversation. Repeat the request with `next_cursor`, keeping the same thread and bridge scope. The preparation cursor binds its projection generation and fixed source watermark while retaining the original older-turn boundary; once preparation completes, ended-turn pages keep the existing default `limit` of 20, 1–100 range, and chronological order.
623
+
624
+ Local turn `input` and `output` fields of at most 4,096 UTF-16 units remain inline. Longer fields return a preview and a field-specific entry in `content_refs`. Send that entry as `content_ref` with the same thread to receive `view.segment`; keep the preview and append each segment's `value`, following `next` until it is absent. Each segment contains at most 16,384 UTF-16 units, and its reference starts after the text already returned. Reading segments does not resume the thread.
625
+
626
+ Existing read cursors remain accepted for compatibility. A history rewrite explicitly invalidates affected cursors, as does a generation change; when the server reports an invalid cursor, restart from the first page rather than treating the thread as empty.
627
+
564
628
  #### Communication history
565
629
 
566
630
  `GET /api/threads/messages` reads accepted cross-thread messages without resuming sessions. It excludes ordinary user input, external REST/Klient sends, and parent–subagent exchanges. Reads remain available for archived sessions and when new peer sends are disabled.
@@ -600,7 +664,7 @@ For `undeliverable` records, `reason_code` is a stable localization key and `rea
600
664
 
601
665
  Klient provides `klient.rest.threads.messages(query, options)` with these snake_case wire shapes. `klient.global.threads.messages({ workspaceId, sessionId, peerSessionId, cursor, limit })` provides the same read using camelCase shapes over HTTP, IPC, and memory transports.
602
666
 
603
- Peer messages are no longer evicted by the mailbox's former 512-message limit. The first upgraded mailbox owner resumes a checkpointed backfill of records still present in the mailbox; messages already evicted by older versions are not reconstructed from session wires. Restart older processes sharing the same Kiki home before relying on the new retention behavior.
667
+ Peer messages are no longer evicted by the mailbox's former 512-message limit. The [mailbox storage upgrade](#mailbox-storage-upgrade) backfills records still present in the old mailbox before switching authority; messages already evicted by older versions are not reconstructed from session wires. Close older writers and complete that upgrade before using the home with Kiki 0.5.x.
604
668
 
605
669
  ### Room conversation entries
606
670
 
@@ -646,6 +710,53 @@ Pages are sorted by score descending, then path; an empty query lists the root d
646
710
  | `GET /api/files/{file_id}` | Download (binary; errors use real HTTP statuses) |
647
711
  | `DELETE /api/files/{file_id}` | Delete |
648
712
 
713
+ ### IM account and channel bindings
714
+
715
+ [Two-way messaging](../features/phone.md) binds each input or output channel to a session. A Persona is optional; changing or clearing it does not move the session's bindings.
716
+
717
+ | Method and path | Description |
718
+ | --- | --- |
719
+ | `GET /api/im/sessions` | Snapshot of policy, instances, discoveries, bindings, strangers and voice fallbacks |
720
+ | `GET /api/im/sessions/catalog` | Personas and sessions available as binding targets |
721
+ | `PUT /api/im/sessions/policy` | Set `allowed`, `default_enabled`, and optional `allow_channel_borrowing` (default `false`) |
722
+ | `POST /api/im/sessions/instances/{id}/listen` | Set `{ listening: true \| false }`; retry a stopped listener with `true` |
723
+ | `POST /api/im/sessions/discoveries/{id}/confirm` | Bind to `target`; optional `rebind`, `input_enabled`, `output_enabled`, `busy`, `reply`, `mobile_interactions`, `also_home` |
724
+ | `PATCH /api/im/sessions/bindings/{id}` | Update this binding's target, direction switches or options |
725
+ | `DELETE /api/im/sessions/bindings/{id}` | Remove this IM binding |
726
+ | `GET /api/im/sessions/targets/{session_id}/channels` | Read output channels and candidates with their actual media capabilities |
727
+ | `PUT /api/im/sessions/targets/{session_id}/notify/{channel_id}` | Bind a notification output or change its session switch with `{ enabled: boolean }` |
728
+ | `DELETE /api/im/sessions/targets/{session_id}/notify/{channel_id}` | Remove only this session's notification binding |
729
+ | `GET /api/sessions/{session_id}/optional-capabilities` | Read authoritative capability rows, including `send_message` |
730
+ | `POST /api/sessions/{session_id}/optional-capabilities` | Set `{ id: "send_message", choice: "on" \| "off" \| "inherit" }`; applies at the next step without restarting |
731
+
732
+ A `target` is `{ kind: "session", session_id }`, or the compatible `{ kind: "persona", persona_id }` shortcut to that Persona's home session. PATCH also accepts legacy `session_id`, but not together with `target`; `also_home` belongs only to confirmation. Reconfirming preserves existing `enabled`, `session_enabled`, `input_enabled` and `output_enabled` unless explicitly changed. `session_enabled: null` follows `policy.default_enabled`; a direction set to `null` removes that direction override. Both directions still require the binding and session allowance to be enabled.
733
+
734
+ For groups, confirmation and PATCH accept `binding_scope: "sender" | "topic" | "chat"`; omission matches only the original sender. `topic_id: "0"` means there is no topic: choose `"chat"` for the whole group or `"sender"` for the original sender; `"topic"` returns business code `40001` / `topic_scope_unavailable`. Choosing `"topic"` or `"chat"` outside a group returns `40001` / `group_binding_scope_required`. A stored no-topic `"topic"` binding still matches only its original sender; it does not widen to the group.
735
+
736
+ PATCH changes a binding in place. If broadening its scope overlaps another enabled input binding, send `rebind: true`; a rejected or failed save keeps the previous binding and pending replies. Explicitly enabling a direction the connection does not support returns `40001` / `input_unsupported` or `output_unsupported`. These errors are business codes in an HTTP 200 envelope; identity conflicts use business code `40949`. Topic/chat scopes share a session across members while preserving real sender IDs and isolating their pending interactions.
737
+
738
+ New topic/chat group bindings default to `group_policy: { wake: "mention_or_reply" }`. Confirmation and PATCH accept `group_policy: { wake: "always" | "mention_or_reply" | "manual", prefixes?: string[] }`: `always` wakes on every message, `mention_or_reply` wakes on a real mention, a reply to a known self message, or a literal configured prefix, and `manual` records without waking. Existing sender-scoped bindings with no policy keep every-message wake.
739
+
740
+ Mention/reply detection requires adapter metadata. Built-in Telegram provides real message IDs, timestamps, sender/chat names, entity-based mentions and reply IDs; update IDs remain separate event deduplication keys. Other transports without those fields can use prefixes or `always` instead.
741
+
742
+ Choose a group binding's scope and wake rule in Notifications & messages. To change them through REST, use confirmation or `PATCH /api/im/sessions/bindings/{id}`. For a transport without mention/reply metadata, set `{ "group_policy": { "wake": "mention_or_reply", "prefixes": ["Kiki:"] } }` to use a prefix, or `{ "group_policy": { "wake": "always" } }` to wake on every message.
743
+
744
+ An enabled inbound group binding keeps a bounded, persistent received timeline per account, chat and topic. Quiet messages do not start a model turn. A triggered prompt includes recent unconsumed background and up to four quoted ancestors as untrusted external data; accepted submission advances only its captured background watermark, without deleting the timeline or losing newer arrivals. The main agent can use [ReadMessageHistory](../reference/tools.md#im-chat-history) for explicit local searches or optional platform backfill. Disabling input stops both collection and reads for that binding.
745
+
746
+ An input identity belongs to one session at a time. Moving a binding to another session without `rebind: true` returns business code `40949`, `msg: "im_identity_already_bound"`, and `details` containing `existing_binding_id`, `previous_session_id`, `target_session_id` and `variant_key`. Show these identities for confirmation, then repeat the request with `rebind: true`; cancelling sends no mutation. Old interaction tickets cannot act on the new session, and old reply watchers expire on transfer. The mobile `:target` command lists targets but requires confirmation in Kiki to transfer them. A legacy binding with a missing session stays visible as `pending_reanchor: true`, retaining its old identity and Persona provenance without routing until explicitly reanchored.
747
+
748
+ The output response contains `internal_enabled: true` and `channels`. Each channel has `id`, `kind` (`internal`, `im`, `notify`), `enabled`, `capabilities`, and optional `bound`; `bound: false` is a candidate, not a session binding. `internal` stays enabled; the legacy internal-switch endpoint rejects `{ enabled: false }`. Klient exposes `rest.imSessions.channelViews`, `setNotificationChannel` and `removeNotificationChannel`.
749
+
750
+ Binding channels does not grant `SendMessage`. Ordinary reply threads default to off; `[optionalCapabilities.defaults] send_message = true` changes the global default, while a session choice of `on` works even when the default is off. Persona message mode retains its implicit-on behavior; explicit session `off` and hard tool-policy denies take precedence. Turning the tool off neither unbinds channels nor hides ordinary final replies.
751
+
752
+ With the tool admitted, omit `channel`/`channels` to send only to enabled bound outputs, including `internal`; explicit IDs select one or more outputs. Borrowing an unbound channel requires `allow_channel_borrowing: true` and an enabled, authorized target. `to: "user"`, `to: "@Bot"` and Room routing retain their recipient meaning; channel IDs cannot be combined with Room or `@Bot` routing. Per-channel receipts distinguish `delivered`, `partial`, `unsupported`, `failed` and `unknown`, and mark borrowed targets. Notification outputs currently carry text only. Inspect partial or unknown receipts instead of resending automatically; an accepted provider response does not prove a person received the message.
753
+
754
+ An instance's `listening` records the requested state. Its `adapter` is `missing`, `running`, `shared` or `stopped`; optional `connection` is `starting`, `reconnecting`, `auth_expired` or `stopped`. Normal running omits `connection`. For `auth_expired`, renew authorization through setup; for a stopped connection, retry listening explicitly. Optional `connection_detail` contains a finite `code` (`transport_error`, `http_error`, `api_error`, `invalid_response`, `auth_expired`, `loop_failed`) and optional numeric `http_status`, `ret`, `errcode`, `failure_count`, `retry_in_ms`. A successful reconnect clears that detail; an absent detail does not identify a failure cause.
755
+
756
+ Channel identity uses `chat_id`, `sender_id`, and `topic_id` (`"0"` for no topic). Optional `chat_kind` is `private` or `group`; do not infer it from a title when absent. The current WeChat connection supports private contacts only. Confirming a group returns business `code: 40001`, `msg: "unsupported_wechat_group"`, preserving the discovery without creating a persona home or changing a binding.
757
+
758
+ If an older Feishu thread binding has no reply context, send a new message from the same sender in that thread to restore delivery of still-pending approvals and questions. Unsupported WeChat group bindings remain unsent; disable or remove them rather than retrying them as private chats. A blocked binding does not prevent delivery to other channels.
759
+
649
760
  ### Global search and misc
650
761
 
651
762
  | Method and path | Description |
@@ -237,18 +237,19 @@ api_key = "YOUR_API_KEY"
237
237
 
238
238
  ## `providers`
239
239
 
240
- `providers` 表的每一项定义一个 API 供应商,以唯一名称为 key。供应商的 `api_key` 放在 [`credentials.toml`](#供应商凭证),CLI **不会**从 shell 环境变量自动取后备值——在终端里 `export KIMI_API_KEY` 不会让供应商自动获得密钥,请写在 `credentials.toml` 里。
240
+ `providers` 表的每一项定义一个 API 供应商,以唯一名称为 key。可以把 API 密钥存入 [`credentials.toml`](#供应商凭证),也可以在 `config.toml` 中设置 `api_key_env`,读取 Kiki 进程里的指定环境变量。没有这个显式引用时,在 shell 中导出密钥变量不会生效。
241
241
 
242
242
  | 字段 | 类型 | 必填 | 说明 |
243
243
  | --- | --- | --- | --- |
244
244
  | `type` | `string` | 是 | 供应商类型:`kimi`、`anthropic`、`openai`、`openai_responses`、`google-genai`、`vertexai` |
245
245
  | `api_key` | `string` | 否 | API 密钥。存放在 `credentials.toml`;仅当 `credentials.toml` 中没有该供应商的值时,才使用 `config.toml` 里的值 |
246
+ | `api_key_env` | `string` | 否 | 非空的环境变量名,不是密钥值。存放在 `config.toml`;仅当 `api_key` 为空时读取。见[凭证优先级与示例](./overrides.md#供应商凭证) |
246
247
  | `base_url` | `string` | 否 | API 基础 URL |
247
248
  | `oauth` | `table` | 否 | OAuth 凭据引用(`storage`、`key` 两个字段),由登录流程自动注入,通常无需手写 |
248
- | `env` | `table<string, string>` | 否 | 供应商凭证的备用来源,详见下文 |
249
+ | `env` | `table<string, string>` | 否 | 供应商环境值,详见下文 |
249
250
  | `custom_headers` | `table<string, string>` | 否 | 每次请求附加的自定义 HTTP 头 |
250
251
 
251
- **`env` 子表**:可以把供应商惯用的键名(如 `KIMI_API_KEY`)写在 `[providers.<name>.env]` 里,作为 `api_key` / `base_url` 的备用来源。这个子表**只在配置文件里读取**,不会修改 shell 环境:
252
+ **`env` 子表**:可以把供应商惯用的键名(如 `KIMI_API_KEY`)写在 `[providers.<name>.env]` 里,作为 `api_key` / `base_url` 的备用来源。对于 `api_key_env` 指定的变量,此表中的同名值优先于进程环境,包括显式空值。这个子表**只在配置文件里读取**,不会修改 shell 环境:
252
253
 
253
254
  ```toml
254
255
  [providers.kimi.env]
@@ -256,7 +257,7 @@ KIMI_API_KEY = "sk-xxx"
256
257
  KIMI_BASE_URL = "https://api.moonshot.ai/v1"
257
258
  ```
258
259
 
259
- 优先级:`api_key` 字段 > `env` 子表键 > 两者都缺时启动报错。`type = "vertexai"` 可以不填 `api_key`,只要 env 子表同时写了 `GOOGLE_CLOUD_PROJECT` 和 `GOOGLE_CLOUD_LOCATION`。如果同时还填了 `api_key`,该密钥仍会发送。见 [Vertex AI](./providers.md#vertexai)。
260
+ `api_key_env` 指定的变量缺失或为空时,不会再尝试其他凭证变量。完整解析顺序见[配置覆盖](./overrides.md#供应商凭证)。`type = "vertexai"` 可以不填 `api_key`,只要 env 子表同时写了 `GOOGLE_CLOUD_PROJECT` 和 `GOOGLE_CLOUD_LOCATION`。如果同时还设置了 API 密钥,该密钥仍会发送。见 [Vertex AI](./providers.md#vertexai)。
260
261
 
261
262
  ## `models`
262
263
 
@@ -522,6 +523,8 @@ confirm = false
522
523
  | --- | --- | --- | --- |
523
524
  | `max_steps_per_turn` | `integer` | — | 单轮最大步数;不设或设为 `0` 则无上限 |
524
525
  | `max_attempts_per_step` | `integer` | `5` | 单步失败后的最大总尝试次数(含首次尝试) |
526
+ | `thinking_only_continuation` | `boolean` | `true` | 模型正常结束且只有非空思考时,显式发送一次 `Continue.` User 消息 |
527
+ | `zero_output_continuation` | `boolean` | `false` | 正常结束且没有思考文本、可见正文和工具调用时,显式发送一次 `Continue.` User 消息 |
525
528
  | `reserved_context_size` | `integer` | `50000` | 自动压缩点以上为模型输出预留的 token 数 |
526
529
  | `auto_compact` | `string` | — | 全局默认自动压缩点,按模型可用窗口写百分比,如 `"85%"`。全局不接受 token 数;模型、profile、会话用正整数 token |
527
530
  | `compaction_trigger_ratio` | `number` | `0.85` | 旧版触发比例,仅在各层都没有设置 `auto_compact` 时使用 |
@@ -532,7 +535,13 @@ confirm = false
532
535
 
533
536
  `max_steps_per_turn` 可被环境变量 `KIKI_LOOP_MAX_STEPS_PER_TURN` 覆盖,`max_attempts_per_step` 可被 `KIKI_LOOP_MAX_ATTEMPTS_PER_STEP` 覆盖,优先级均高于配置文件。
534
537
 
535
- 重试仅针对瞬时故障——连接错误、超时、HTTP 429 限流,以及所有 HTTP 500–599 服务端错误。账户额度耗尽或余额不足导致的 429 不会重试,会立即失败:在充值之前重试不可能成功。
538
+ 重试仅针对瞬时故障——连接错误、超时、HTTP 429 限流,以及符合重试条件的 HTTP 500–599 服务端错误。已有部分输出、安全拒绝或额度耗尽时会停止,不重放请求。
539
+
540
+ 当供应商确认模型正常结束,且只有非空思考、没有正文、工具调用或拒绝时,Kiki 会保留思考及原始签名,每轮最多显式发送一条 `Continue.` User 消息。网关的精确 `antigravity_thinking_only` 事件也可触发续接,但 Kiki 必须实际保留了思考,并确认没有其它输出、外部信息检索(grounding)或拒绝。取消、缺少终态事件、流中断、token 上限导致的停止均不符合条件。续接算一次真实模型请求,用量单独记录。第二次仍为空或请求失败时停止本轮;这次续接即使遇到 HTTP 429 或临时服务端错误,也不重试。
541
+
542
+ 设置 `[loop_control] thinking_only_continuation = false` 可关闭这条自动消息,从下一个 step 边界起生效。拒绝尾部 Model 消息的 Google 模型仍保留原有的原始快照重试,它与显式续接共用每轮一次的恢复预算,不受该设置关闭。Google `CONTINUATION` 终态仍需此 SDK 无法发送的 continuation token。
543
+
544
+ 未配置或设为 `false` 时,`zero_output_continuation` 保持关闭。设为 `[loop_control] zero_output_continuation = true` 后,供应商确认正常结束,且思考文本、可见回答和工具调用都为空时,Kiki 会在同一轮发送一条 `Continue.` User 消息。附在空思考上的签名不是思考内容,并保留在对话里。非空的 redacted 思考数据算输出。非空思考文本仍走 `thinking_only_continuation`。子 Agent 使用同一规则;开关关闭时,没有内容的子任务完成仍失败,第二次仍为空也会停止本轮。token 用量不参与判断。该选择从下一个 step 边界起生效。这次续接是同一轮里的一次模型请求,不按连接错误或限流重试。取消、供应商错误,以及没有正常停止终态的流,仍走原有路径。
536
545
 
537
546
  ### 连续性提醒设置
538
547
 
@@ -576,7 +585,7 @@ history = ["as I said", "earlier", "之前", "我说过"]
576
585
 
577
586
  ## `retry`
578
587
 
579
- `retry` 可为指定的单步错误定制总尝试次数与固定退避时间。默认情况下,可重试的单步最多尝试 5 次,重试前依次等待 2、4、8、16 秒,并加入最多 25% 的随机抖动(总计 30–37.5 秒)。provider 返回的 `Retry-After` 值或命中策略的固定 `backoff` 会替代对应的默认等待时间。本节及每条策略都是严格配置:未知字段会被拒绝,不会静默忽略。
588
+ `retry` 可为指定的单步错误定制总尝试次数与固定退避时间。默认情况下,可重试的单步最多尝试 5 次,重试前依次等待 2、4、8、16 秒,并加入最多 25% 的随机抖动(总计 30–37.5 秒)。provider 返回的 `Retry-After` 值或命中策略的固定 `backoff` 会替代对应的默认等待时间。策略还可限定精确的模型和 provider 配置键,避免一个 provider 的临时故障改变其它渠道的重试行为。本节及每条策略都是严格配置:未知字段会被拒绝,不会静默忽略。
580
589
 
581
590
  | 字段 | 类型 | 默认值 | 说明 |
582
591
  | --- | --- | --- | --- |
@@ -587,27 +596,28 @@ history = ["as I said", "earlier", "之前", "我说过"]
587
596
 
588
597
  | 字段 | 类型 | 必填 | 说明 |
589
598
  | --- | --- | --- | --- |
590
- | `match` | `string` | 是 | 与错误码和错误名称匹配的正则表达式(按模式匹配文本的规则) |
599
+ | `match` | `string` | 是 | 与错误码和错误名称匹配的 JavaScript 正则表达式(按模式匹配文本的规则);`(?i)` 等内联修饰符无效,该策略会被忽略并产生配置警告 |
600
+ | `models` | `array<string>` | 否 | 精确的规范 `[models]` 配置键;仅绑定模型在列表中时生效 |
601
+ | `providers` | `array<string>` | 否 | 精确的 `[providers]` 配置键;仅绑定 provider 在列表中时生效 |
591
602
  | `max_attempts` | `integer` | 否 | 命中错误的最大总尝试次数(含首次尝试);优先于本节的总预算 |
592
603
  | `backoff` | `integer` | 否 | 每次重试前固定等待的毫秒数;provider 返回的 retry-after 提示仍优先 |
593
604
  | `retry` | `boolean` | 否 | 默认为 `true`。`false` 可抑制 Kiki 内建判定原本会重试的错误;`true` 不能强制重试被判定为不可重试的错误 |
594
605
 
595
- 策略从上到下检查,因此应把更具体的正则表达式放在更宽泛的规则之前:
606
+ 策略从上到下检查。`models` 或 `providers` 不包含当前绑定时会跳过该策略,余下策略中首个 `match` 命中错误的策略生效;同时设置两个 selector(选择条件)时必须全部命中。省略两个 selector 时保持原有的全局逐错误行为。
596
607
 
597
- ```toml
598
- [retry]
599
- max_attempts = 4
608
+ 下面的配置只为一个原生 Google GenAI Argon 绑定的 HTTP 429 提供最多 20 次总尝试;其它模型和 provider 仍使用默认的 5 次:
600
609
 
610
+ ```toml
601
611
  [[retry.policies]]
602
612
  match = '^provider\.rate_limit$'
603
- max_attempts = 6
604
- backoff = 1000
605
-
606
- [[retry.policies]]
607
- match = '^provider\.'
608
- retry = false
613
+ models = ['gemini-4-argon']
614
+ providers = ['google-native']
615
+ max_attempts = 20
616
+ backoff = 15000
609
617
  ```
610
618
 
619
+ 请把 `gemini-4-argon` 和 `google-native` 替换成 `[models]` 与 `[providers]` 表中的精确配置键。仅当 provider 未返回 `Retry-After` 时才使用 `backoff`。该策略不会让 HTTP 400、额度耗尽、部分输出或已经执行的失败变成可重试;`retry = true` 不会越过 Kiki 的不可重试判定。
620
+
611
621
  ## `transcript_memory`
612
622
 
613
623
  `transcript_memory` 控制服务端把多少转录历史留在内存里。三个字段都是可选的:省略即使用默认值。
@@ -822,16 +832,19 @@ disabled = ["EnterPlanMode", "ExitPlanMode", "mcp__github__*"]
822
832
 
823
833
  ## `browser_control`
824
834
 
825
- `browser_control` 存放由[浏览器控制](../guides/settings.md#浏览器控制)管理的浏览器连接,以及新会话默认项。设置页是受支持的编辑入口:它按连接保存条目、保存后读回结果再显示,且保存从不启动浏览器。
835
+ `browser_control` 存放由[浏览器控制](../guides/settings.md#浏览器控制)管理的浏览器连接,以及新会话默认项。设置页是受支持的编辑入口:它按连接保存条目、保存后读回结果再显示,且保存从不启动浏览器。要新增 HTTP 桥连接,点击「添加浏览器」,将「接法」选为「Kimi WebBridge」。
826
836
 
827
837
  | 字段 | 类型 | 说明 |
828
838
  | --- | --- | --- |
829
839
  | `default_browser` | `string` | 之后创建的会话使用的连接 id;未设置时调用必须自己指定连接 |
830
840
  | `allowed_browsers` | `string[]` | Agent 可以使用的连接 id。不写这一项时沿用原先的默认。空列表仍允许列出和发现 |
831
841
  | `disabled_sources` | `string[]` | 已关闭的来源:`kimi-webbridge`、`independent-browser`、`codex-browser`、`ego-lite`。关闭来源不会清空 `allowed_browsers` |
842
+ | `webbridge_preset_route` | `boolean` | 默认 `true`:将旧版保存为 `agent-browser-cdp`、id 恰为 `kimi-webbridge` 的条目接到 Kimi HTTP 桥;设为 `false` 则让该条目继续走 CDP 驱动 |
832
843
  | `connections` | `table` | 每条连接一个条目,以连接的固定 id 为 key |
833
844
 
834
- 每个条目通过 `type`(`agent-browser-profile` 或 `agent-browser-cdp`)、`name`、`enabled` 以及该接法所需字段描述一条连接;每种接法的字段见设置页。字段与接法不符的条目会被拒绝,已保存的文件保持不变。存入的 CDP 地址按凭据对待:页面显示掩码,只有显式请求时才读取明文。
845
+ 每个条目包含 `name`、`enabled` 与 `type`。类型为 `agent-browser-profile`、`agent-browser-cdp`、`codex-extension`、`ego-lite`、`kimi-webbridge` 或 `webbridge-command`;各类型字段见[浏览器连接 API](../server/rest-api.md#浏览器连接)。字段与类型不符时会被拒绝,已保存的文件保持不变。存入的 CDP 地址按凭据对待:页面显示掩码,只有显式请求时才读取明文。`webbridge-command` 只接受 `name` 和 `enabled`,使用固定的本地命令桥,归 `kimi-webbridge` 来源开关控制。它没有 endpoint 或驱动路径;CDP 条目不会被改成此类型。
846
+
847
+ `kimi-webbridge` 类型使用服务器本机 `http://127.0.0.1:10086` 的 HTTP 桥接程序,不接受 endpoint;这不是 CDP 地址。上述旧 id 兼容路由不改写保存条目,也不影响其他 CDP id。显式 `kimi-webbridge` 类型始终使用 HTTP,不受 `webbridge_preset_route = false` 影响。
835
848
 
836
849
  ## `computer_control`
837
850
 
@@ -54,6 +54,8 @@ $KIKI_HOME (默认 ~/.kiki)
54
54
  │ └── <key>-<suffix>.json
55
55
  ├── sessions/ # 会话数据(详见下文)
56
56
  │ └── <workDirKey>/<sessionId>/
57
+ ├── store/
58
+ │ └── thread-mailbox-sqlite-v1/ # 持久消息邮箱与升级恢复副本
57
59
  ├── server/
58
60
  │ └── events/ # 有界的客户端事件重放日志
59
61
  ├── bin/
@@ -89,7 +91,7 @@ $KIKI_HOME (默认 ~/.kiki)
89
91
 
90
92
  - **`state.json`**:会话标题、`lastPrompt`、创建/更新时间、`forkedFrom` 等元数据。
91
93
  - **`upcoming-goals.json`**:由 `/goal next <objective>` 创建的 TUI 专属队列。它不属于 Agent 对话;只有当前目标完成并提升后续目标后,才会进入 Agent 对话。
92
- - **`agents/main/wire.jsonl`**:main agent 的完整通信记录,用于会话恢复和回放。
94
+ - **`agents/main/wire.jsonl`**:main agent 的完整通信记录,用于会话恢复和回放。[`kiki session seal`](../reference/command.md#kiki-session) 会把这个文件留在原地,因此它的大小不会下降;[`kiki session unseal`](../reference/command.md#kiki-session) 去掉封存,不修改该文件。
93
95
  - **`agents/main/plans/`**:Plan 模式下写入的计划文件,按计划 id 命名(`<id>.md`)。
94
96
  - **`agents/agent-0/` 等**:subagent 实例目录,各自含 `wire.jsonl`。
95
97
  - **`logs/kimi-code.log`**:该会话的诊断日志,只有发生诊断事件时才存在。
@@ -104,6 +106,26 @@ $KIKI_HOME (默认 ~/.kiki)
104
106
 
105
107
  这项保留策略不会删除 `sessions/`、Agent 的 `wire.jsonl` 或媒体原件。游标超出保留窗口的客户端会通过快照/reset 恢复,而不是补播旧事件序列,见 [断线恢复](../server/rest-api.md#断线恢复)。如需手动清理旧日志,先停止所有使用该数据根目录的 Kiki 服务,再仅清理 `server/events/` 并重启。不要在 writer 运行时删除或截断这些日志。
106
108
 
109
+ ## 持久消息邮箱
110
+
111
+ `store/thread-mailbox-sqlite-v1/` 保存线程间消息、投递状态、幂等回执、活动游标和工作区覆盖设置。这些记录是持久原件,不像搜索和查询缓存,不能靠删除后重建来恢复。`authority.json` 指定当前使用的 `mailbox-<migrationId>.sqlite`;数据库打开时,旁边的 `-wal` 和 `-shm` 文件也要保留。请用 [`kiki storage backup`](../reference/command.md#kiki-storage) 创建一致的 SQLite 副本,不要只复制正在使用的 `.sqlite` 文件。
112
+
113
+ 0.5.x 升级将检查点保存在 `migration.json`,源数据备份放在 `recovery/<migrationId>/sources/`,移走的原目录放在 `recovery/<migrationId>/originals/`。原来的 `store/thread-mailbox-v3`、`store/thread-mailbox-v1` 和 `store/agent-collaboration-mailbox-v2` 目录名会变成阻止旧版本写入的占位文件。请保留这些文件,也不要让旧二进制程序使用恢复副本作为可写邮箱。用 `kiki storage status` 查看恢复状态,用 `kiki storage migrate` 续接;需要回退时,遵循 [storage 命令的回退规则](../reference/command.md#kiki-storage),不要手动移回原目录。
114
+
115
+ ## 会话与用量查询缓存
116
+
117
+ `cache/query-store-sqlite-v1/index.sqlite` 保存会话列表、用量事实和线程轮次查询使用的 SQLite 缓存。Kiki 会按需从会话元数据、用量事实日志和对话历史重建这些视图。数据库打开时,旁边可能还有 `-wal` 和 `-shm` 文件。
118
+
119
+ 如果缓存损坏,先停止所有使用该数据根目录的 Kiki 进程,备份后仅移除 `cache/query-store-sqlite-v1/`,再重新启动。历史较多时,重建可能需要多次请求;准备完成前,Usage 会显示覆盖不完整。请保留 `cache/usage-facts-v1/`、`sessions/` 和 `store/`,恢复所需的日志与记录存放在这些目录中。旧的 `cache/query-store-v*/` 目录与 SQLite 缓存分开,新后端不会导入它们。
120
+
121
+ ## 全文搜索索引
122
+
123
+ 全文搜索使用 `search-index-v2/index.sqlite` 中的 SQLite 索引。Kiki 会复用兼容的索引,或从会话元数据与对话历史重建已识别的旧版搜索索引;重建期间,结果可能不完整。缓存重建不会改动历史原件。旧 MiniDb `search-index/` 目录保持原样,既不导入,也不作为故障回退。请保留 `sessions/` 和 `store/`:搜索缓存重建与 mailbox 消息存储升级各有自己的流程。
124
+
125
+ 在 0.5 迁移系列中,`config.toml` 里显式设置的 `search_backend = "minidb"` 或 `KIKI_SEARCH_BACKEND=minidb` 是 SQLite 的已弃用别名,并会产生迁移警告。请在升级到退役该值的 0.6 前删除旧设置,或改为 `sqlite`。环境变量优先于 `search_backend`;Kiki 不会改写这两处设置。旧 `search_worker` 实验开关已移除,SQLite 始终通过写入子进程与查询工作线程隔离数据库工作。
126
+
127
+ 搜索默认可用。`[search] enabled = false`、`KIKI_SEARCH_DISABLED=1` 或桌面端显式设置的 `desktop_search = false` 会保持关闭;搜索关闭时,迁移别名不会启动工作线程或重建缓存。`[search] index_subagents = true` 可将 subagent 内容纳入索引,默认关闭。这些设置在重启 Kiki 后生效。搜索默认匹配用户、助手正文与会话标题;只有显式请求时才包含工具结果输出。思考内容、工具名和工具调用参数不参与搜索。
128
+
107
129
  ## 内置工具缓存
108
130
 
109
131
  `Grep` 工具第一次需要 ripgrep 时,CLI 可自动下载 `rg` 并缓存到 `bin/rg`(Windows 为 `bin/rg.exe`)。终端界面的文件引用补全使用 `fd`;需要时 CLI 会在后台自动下载并缓存到 `bin/fd`(Windows 为 `bin/fd.exe`)。之后的运行会直接复用缓存的二进制。`rg` 优先使用系统 `PATH`,再使用缓存;`fd` 优先检查托管缓存,再回退到系统 `fd` / `fdfind`。删除 `bin/` 目录会在下次需要时触发重新下载。
@@ -4,12 +4,10 @@ Kiki 通过环境变量控制少数运行时行为——迁移数据目录,以
4
4
 
5
5
  Kiki 自有运行时开关统一使用 `KIKI_*` 前缀。`KIMI_API_KEY` 和 `KIMI_BASE_URL` 等供应商凭证键属于上游生态,单独在下文说明。以本页列出的确切变量名为准。
6
6
 
7
- ::: warning 重要:API 密钥不在这里配置
8
- `KIMI_API_KEY`、`ANTHROPIC_API_KEY`、`OPENAI_API_KEY` 等密钥变量**不会**从 shell 环境变量自动读取。在终端里 `export KIMI_API_KEY=xxx` 不会让任何供应商获得密钥——必须写在配置文件的 `[providers.<name>]` 段或其 `[providers.<name>.env]` 子表里。API 密钥放在配套的 `credentials.toml` 里,`config.toml` 不会存明文凭证。
7
+ ::: warning 注意
8
+ 供应商的 API 密钥变量**不会**自动读取。要使用环境变量,在 `config.toml` 的供应商表里设置 `api_key_env = "YOUR_PROVIDER_KEY"`,并把该变量传给 Kiki 进程。见[凭证优先级与示例](./overrides.md#供应商凭证)。保存的密钥值仍放在 `credentials.toml`;环境引用只保存变量名。
9
9
 
10
- 唯一的例外是 `KIKI_MODEL_*` 系列,它是一个显式通道,*确实*会从 shell 读取凭证——详见[用环境变量定义模型](#用环境变量定义模型-kiki-model)。
11
-
12
- 背景说明见[配置覆盖:供应商凭证](./overrides.md#供应商凭证)。
10
+ 独立的 `KIKI_MODEL_*` 系列也能提供临时模型与密钥——详见[用环境变量定义模型](#用环境变量定义模型-kiki-model)。
13
11
  :::
14
12
 
15
13
  ## 核心路径
@@ -36,7 +34,7 @@ export KIKI_HOME="/path/to/custom/kiki"
36
34
 
37
35
  ## 供应商凭证键
38
36
 
39
- 下面这些键名不从 shell 读取。它们写在 `[providers.<name>.env]` 子表里,作为 `api_key` / `base_url` 的备用来源。密钥键放进配套的 `credentials.toml`,非密钥的 `*_BASE_URL` 键留在 `config.toml`。
37
+ 下面是 `[providers.<name>.env]` 子表惯用的键名,作为 `api_key` / `base_url` 的备用来源。密钥键放进配套的 `credentials.toml`,非密钥的 `*_BASE_URL` 键留在 `config.toml`。要改从进程环境读取 API 密钥,请用 [`api_key_env`](./overrides.md#供应商凭证) 显式引用变量名。
40
38
 
41
39
  ```toml
42
40
  # ~/.kiki/credentials/credentials.toml
@@ -68,7 +66,7 @@ KIMI_BASE_URL = "https://api.moonshot.ai/v1"
68
66
  | `GOOGLE_CLOUD_LOCATION` | Vertex AI,与 `GOOGLE_CLOUD_PROJECT` 一起设置 | 无 |
69
67
 
70
68
  ::: warning
71
- `GOOGLE_APPLICATION_CREDENTIALS`(服务账号 JSON 路径)是唯一走系统环境变量的例外——它由 Google SDK 自身通过 ADC 流程读取,CLI 不参与。其他所有键名都必须写在 `[providers.<name>.env]` 子表里——密钥键在 `credentials.toml`,`*_BASE_URL` 键在 `config.toml`。
69
+ `GOOGLE_APPLICATION_CREDENTIALS`(服务账号 JSON 路径)由 Google SDK 自身通过标准 ADC 流程读取。项目、位置和基础 URL 仍来自供应商的配置子表;`api_key_env` 只允许读取指定的 API 密钥,不会同时启用其他 shell 变量。
72
70
  :::
73
71
 
74
72
  供应商类型与字段的完整说明见[平台与模型](./providers.md)。
@@ -146,7 +144,7 @@ kiki
146
144
  | `KIKI_MCP_TOOL_TIMEOUT_MS` | 所有 MCP server 的全局默认单次工具调用超时(毫秒);优先级高于 `config.toml` 的 `[mcp] tool_timeout_ms`,但低于 `mcp.json` 中单个 server 的 `toolTimeoutMs`(默认 `60000`) | `1` 到 `2147483647` 的整数;非法值被忽略 |
147
145
  | `KIKI_LOOP_MAX_STEPS_PER_TURN` | Agent 单轮最大步数;优先级高于 `config.toml` 的 `[loop_control] max_steps_per_turn`(不设或 `0` 表示无上限) | 非负整数;非法值被忽略 |
148
146
  | `KIKI_LOOP_MAX_ATTEMPTS_PER_STEP` | 单步失败后的最大总尝试次数(含首次尝试);优先级高于 `config.toml` 的 `[loop_control] max_attempts_per_step`(默认 `5`) | 非负整数;非法值被忽略 |
149
- | `KIKI_INFINITE_RETRY` | 让所有失败的 LLM 请求无限重试(包括轮次内步骤和 compaction 等后台操作)而不是终止任务;重试等待按指数退避(32 秒封顶)并尊重服务端 `Retry-After` 头,等待期间中断仍立即生效。适用于端点可能短暂故障的长时间无人值守评测 | 真值:`1`/`true`/`yes`/`on`;假值:`0`/`false`/`no`/`off` |
147
+ | `KIKI_INFINITE_RETRY` | 无限重试失败的 LLM 请求,涵盖轮次内步骤、compaction、HTTP 400/404 和额度错误。等待按指数退避(32 秒封顶)并尊重 `Retry-After`。取消、本地准入拒绝、已观察到的输出或工具执行、`retry = false`、单次请求的 `retry: 'never'` 仍阻止重试;一次性 [`Continue.` 请求](./config-files.md#loop-control)也不会重试。上下文溢出仍走上下文恢复。适用于端点可能短暂故障的长时间无人值守评测 | 真值:`1`/`true`/`yes`/`on`;假值:`0`/`false`/`no`/`off` |
150
148
  | `KIKI_TOKEN_COUNTING_STRATEGY` | 对外上报的上下文 token 计数(上下文大小显示);优先级高于 `config.toml` 的 `[token_counting] strategy`(默认 `measured+estimated`) | `measured+estimated`、`measured`、`estimated`(不区分大小写);非法值被忽略 |
151
149
  | `NB_SEARCH_CONFIG` | 内置搜索与抓取模块的 canonical JSON 配置路径;Kiki 的 `[nb_search]` patch 在它之后应用 | 文件路径 |
152
150
  | `NB_SEARCH_HOME` | 内置搜索与抓取模块的数据目录 | 目录路径 |
@@ -25,7 +25,7 @@ Kiki 有三个地方可以影响运行参数:配置文件、命令行选项、
25
25
  少数环境变量明确覆盖特定配置字段,例如 `KIKI_BACKGROUND_KEEP_ALIVE_ON_EXIT` 的优先级高于 `[background].keep_alive_on_exit`。这类例外在[环境变量](./env-vars.md)和[配置文件](./config-files.md)对应字段里都有标注。
26
26
 
27
27
  ::: warning
28
- **普通运行参数不会从 shell 环境变量取后备值。** 供应商的 `api_key` / `base_url` 只从配置文件读取——密钥在 `credentials.toml`,其余在 `config.toml`——不会回退到 shell 里 `export` 的变量。唯一的例外是显式的 `KIKI_MODEL_*` 通道——详见[用环境变量定义模型](./env-vars.md#用环境变量定义模型-kiki-model)。
28
+ **普通运行参数不会从 shell 环境变量取后备值。** 供应商只有在你通过 `api_key_env` 显式指定变量名时才读取 shell 密钥,具体规则见下文。独立的 `KIKI_MODEL_*` 通道也能提供临时模型与密钥——详见[用环境变量定义模型](./env-vars.md#用环境变量定义模型-kiki-model)。
29
29
  :::
30
30
 
31
31
  CLI 从 `KIKI_HOME`(默认 `~/.kiki`)读取用户级配置,并从 `<项目根目录>/.kiki/local.toml` 读取项目级设置。旧的 `.kimi-code/local.toml` 路径不会读取。需要在不同项目间隔离配置时,用 `KIKI_HOME` 指向不同的数据目录——见下文[典型场景](#典型场景)。
@@ -36,15 +36,26 @@ CLI 从 `KIKI_HOME`(默认 `~/.kiki`)读取用户级配置,并从 `<项目
36
36
 
37
37
  供应商的 API 密钥存放在数据根目录下的 `credentials/credentials.toml`。Kiki 把两个文件当作一份文档读取,同一条 TOML 路径上 `credentials.toml` 的值优先;`config.toml` 不会保存明文凭证。文件位置、权限以及首次加载迁移见[供应商凭证](./config-files.md#供应商凭证)。
38
38
 
39
- 对单个供应商,凭证按以下顺序解析:
39
+ 模型自身的 API 密钥或 OAuth 引用优先于供应商凭证。对于使用 API 密钥的供应商,其余来源按以下顺序解析:
40
40
 
41
- 1. `[providers.<name>].api_key` — 存放在 `credentials.toml` 里的密钥,优先级最高
42
- 2. `[providers.<name>.env]` 子表里的对应键(`KIMI_API_KEY`、`ANTHROPIC_API_KEY` 等)— `api_key` 为空时才读这里;这些密钥值同样存放在 `credentials.toml`
43
- 3. 两者都缺 → 启动报错,提示该供应商缺少凭证
41
+ 1. `[providers.<name>].api_key`——已保存的密钥;非空值优先于环境来源。
42
+ 2. 已设置 `api_key_env` 时,若 `[providers.<name>.env]` 中存在同名项,就读该项;否则读取 Kiki 进程的同名环境变量。子表中的显式空值不会回退到进程环境。变量缺失或为空白时,API 密钥仍为未配置状态,也不会改试其他变量。
43
+ 3. 未设置 `api_key_env` 时,沿用供应商类型在 `[providers.<name>.env]` 中的原有密钥键(`KIMI_API_KEY`、`ANTHROPIC_API_KEY` 等)。这些已保存的密钥值同样放在 `credentials.toml` 中,不会隐式回退到 shell。
44
44
 
45
- `base_url` 的解析方式相同:先读 `[providers.<name>].base_url`,再读 `[providers.<name>.env]` 里的 `*_BASE_URL` 键。`base_url` 不是密钥,仍留在 `config.toml`。
45
+ 若要把密钥保留在环境中,只在 `config.toml` 中保存变量名:
46
46
 
47
- > `[providers.<name>.env]` 子表只是配置文件里的一段 TOML,不会真正写入 shell 环境变量。仅当对应的直接字段(`api_key` / `base_url`)为空时,CLI 才会查这里。
47
+ ```toml
48
+ [providers.gateway]
49
+ type = "openai"
50
+ base_url = "https://api.example.com/v1"
51
+ api_key_env = "YOUR_PROVIDER_KEY"
52
+ ```
53
+
54
+ 从已经设置 `YOUR_PROVIDER_KEY` 的进程启动 Kiki。通过快捷方式启动的桌面应用不一定继承终端里的变量。已有供应商若要改用环境密钥,请先清除 `api_key`,否则仍优先使用已保存的密钥。Kiki 不会把解析出的环境值复制到凭证存储。供应商就绪状态、模型请求和模型发现使用同一解析规则;就绪只表示有可用值,不表示远端服务已接受该密钥。
55
+
56
+ 供应商的 OAuth 引用仍走原有令牌流程。与已保存的密钥一样,解析成功的环境密钥不能与同一供应商层的 OAuth 同时使用。
57
+
58
+ `base_url` 保持原规则:先读 `[providers.<name>].base_url`,再读 `[providers.<name>.env]` 中的 `*_BASE_URL` 键。它不是密钥,仍留在 `config.toml`。`env` 子表不会向 shell 环境写入值。
48
59
 
49
60
  完整的凭证键名列表见[环境变量:供应商凭证键](./env-vars.md#供应商凭证键)。
50
61
 
@@ -107,7 +118,7 @@ profile 绑定时——新建主会话、新建 subagent、切换模型,或原
107
118
  KIKI_HOME="$PWD/.kiki-sandbox" kiki
108
119
  ```
109
120
 
110
- **一次性使用测试密钥**——由于供应商凭证只从配置文件读,把测试密钥写进 `credentials.toml`:
121
+ **在配置文件中保存测试密钥**——把密钥写进 `credentials.toml`。若只想通过环境传入密钥,使用上文的 `api_key_env` 示例:
111
122
 
112
123
  ```toml
113
124
  # ~/.kiki/credentials/credentials.toml