@cjhyy/code-shell-core 0.5.0-rc.2 → 0.6.0-rc.10

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 (396) hide show
  1. package/README.md +13 -10
  2. package/dist/agent/agent-definition-registry.d.ts +3 -0
  3. package/dist/agent/agent-definition-registry.js +3 -1
  4. package/dist/agent/agent-definition.d.ts +15 -0
  5. package/dist/agent/agent-definition.js +27 -3
  6. package/dist/arena/context/context-tools.js +47 -4
  7. package/dist/arena/ledger.js +9 -1
  8. package/dist/arena/strategies/utils.d.ts +1 -4
  9. package/dist/arena/strategies/utils.js +7 -84
  10. package/dist/automation/cron-expr.d.ts +10 -0
  11. package/dist/automation/cron-expr.js +23 -5
  12. package/dist/automation/runner.d.ts +21 -4
  13. package/dist/automation/runner.js +48 -12
  14. package/dist/automation/scheduler.d.ts +38 -0
  15. package/dist/automation/scheduler.js +89 -12
  16. package/dist/automation/store.js +5 -2
  17. package/dist/capability-control/disabled-lists.d.ts +25 -0
  18. package/dist/capability-control/disabled-lists.js +57 -0
  19. package/dist/capability-control/overlay.d.ts +15 -0
  20. package/dist/capability-control/overlay.js +27 -0
  21. package/dist/cc-orchestrator/agent-adapter.d.ts +50 -0
  22. package/dist/cc-orchestrator/agent-adapter.js +133 -0
  23. package/dist/cc-orchestrator/cc-capability.d.ts +19 -0
  24. package/dist/cc-orchestrator/cc-capability.js +53 -0
  25. package/dist/cc-orchestrator/codex-session-discovery.d.ts +24 -0
  26. package/dist/cc-orchestrator/codex-session-discovery.js +191 -0
  27. package/dist/cc-orchestrator/codex-session-history.d.ts +25 -0
  28. package/dist/cc-orchestrator/codex-session-history.js +187 -0
  29. package/dist/cc-orchestrator/external-agent-changes.d.ts +19 -0
  30. package/dist/cc-orchestrator/external-agent-changes.js +214 -0
  31. package/dist/cc-orchestrator/external-agent-driver.d.ts +18 -0
  32. package/dist/cc-orchestrator/external-agent-driver.js +69 -0
  33. package/dist/cc-orchestrator/index.d.ts +8 -0
  34. package/dist/cc-orchestrator/index.js +8 -0
  35. package/dist/cc-orchestrator/relevance-judge.d.ts +15 -0
  36. package/dist/cc-orchestrator/relevance-judge.js +29 -0
  37. package/dist/cc-orchestrator/session-discovery.d.ts +46 -0
  38. package/dist/cc-orchestrator/session-discovery.js +125 -0
  39. package/dist/cc-orchestrator/session-history.d.ts +19 -0
  40. package/dist/cc-orchestrator/session-history.js +67 -0
  41. package/dist/cli/agent-server-stdio.d.ts +15 -1
  42. package/dist/cli/agent-server-stdio.js +115 -17
  43. package/dist/cli/agent-server-tcp.js +40 -26
  44. package/dist/context/compaction.d.ts +86 -0
  45. package/dist/context/compaction.js +279 -0
  46. package/dist/context/manager.d.ts +18 -0
  47. package/dist/context/manager.js +181 -48
  48. package/dist/context/token-counter.js +13 -0
  49. package/dist/cost-tracker.js +5 -61
  50. package/dist/credentials/cipher.d.ts +49 -0
  51. package/dist/credentials/cipher.js +45 -0
  52. package/dist/credentials/cookie-jar.d.ts +24 -0
  53. package/dist/credentials/cookie-jar.js +40 -0
  54. package/dist/credentials/index.d.ts +7 -0
  55. package/dist/credentials/index.js +5 -0
  56. package/dist/credentials/inject-credential-tool.d.ts +20 -0
  57. package/dist/credentials/inject-credential-tool.js +130 -0
  58. package/dist/credentials/store.d.ts +72 -0
  59. package/dist/credentials/store.js +184 -0
  60. package/dist/credentials/types.d.ts +56 -0
  61. package/dist/credentials/use-credential-tool.d.ts +29 -0
  62. package/dist/credentials/use-credential-tool.js +205 -0
  63. package/dist/credentials/use-gate.d.ts +56 -0
  64. package/dist/credentials/use-gate.js +52 -0
  65. package/dist/data/model-metadata.d.ts +77 -0
  66. package/dist/data/model-metadata.js +56 -0
  67. package/dist/data/model-metadata.json +216 -0
  68. package/dist/data/openrouter-models.d.ts +18 -7
  69. package/dist/data/openrouter-models.js +35 -8
  70. package/dist/engine/aux-key.d.ts +10 -0
  71. package/dist/engine/aux-key.js +11 -0
  72. package/dist/engine/dynamic-tool-defs.d.ts +19 -0
  73. package/dist/engine/dynamic-tool-defs.js +36 -0
  74. package/dist/engine/engine.d.ts +280 -141
  75. package/dist/engine/engine.js +1193 -245
  76. package/dist/engine/friendly-error.d.ts +18 -0
  77. package/dist/engine/friendly-error.js +63 -0
  78. package/dist/engine/goal.d.ts +145 -0
  79. package/dist/engine/goal.js +144 -0
  80. package/dist/engine/image-policy.d.ts +13 -0
  81. package/dist/engine/image-policy.js +24 -0
  82. package/dist/engine/model-connections-pool.d.ts +17 -0
  83. package/dist/engine/model-connections-pool.js +67 -0
  84. package/dist/engine/model-facade.d.ts +10 -0
  85. package/dist/engine/model-facade.js +15 -0
  86. package/dist/engine/patch-orphaned-tools.js +3 -0
  87. package/dist/engine/query.js +2 -0
  88. package/dist/engine/resolve-llm-config.d.ts +16 -0
  89. package/dist/engine/resolve-llm-config.js +44 -0
  90. package/dist/engine/runtime.d.ts +2 -0
  91. package/dist/engine/runtime.js +27 -1
  92. package/dist/engine/sandbox-cache-key.d.ts +10 -0
  93. package/dist/engine/sandbox-cache-key.js +9 -0
  94. package/dist/engine/sandbox-config.d.ts +31 -0
  95. package/dist/engine/sandbox-config.js +38 -0
  96. package/dist/engine/session-usage.d.ts +31 -0
  97. package/dist/engine/session-usage.js +81 -0
  98. package/dist/engine/steer-queue.d.ts +33 -0
  99. package/dist/engine/steer-queue.js +26 -0
  100. package/dist/engine/streaming-tool-queue.d.ts +12 -0
  101. package/dist/engine/streaming-tool-queue.js +50 -10
  102. package/dist/engine/turn-loop.d.ts +94 -4
  103. package/dist/engine/turn-loop.js +432 -54
  104. package/dist/engine/types.d.ts +175 -0
  105. package/dist/engine/types.js +13 -0
  106. package/dist/external-agents/config.d.ts +2 -0
  107. package/dist/external-agents/config.js +15 -0
  108. package/dist/external-agents/types.d.ts +31 -0
  109. package/dist/external-agents/types.js +1 -0
  110. package/dist/git/utils.d.ts +12 -0
  111. package/dist/git/utils.js +38 -6
  112. package/dist/git/worktree.d.ts +48 -0
  113. package/dist/git/worktree.js +86 -10
  114. package/dist/hooks/goal-stop-hook.d.ts +28 -0
  115. package/dist/hooks/goal-stop-hook.js +186 -9
  116. package/dist/hooks/registry.d.ts +8 -0
  117. package/dist/hooks/registry.js +19 -0
  118. package/dist/hooks/shell-runner.js +10 -21
  119. package/dist/index.d.ts +51 -7
  120. package/dist/index.js +62 -5
  121. package/dist/llm/capabilities/param-specs.d.ts +14 -0
  122. package/dist/llm/capabilities/param-specs.js +62 -0
  123. package/dist/llm/capabilities/rules.js +5 -1
  124. package/dist/llm/capabilities/types.d.ts +10 -0
  125. package/dist/llm/client-base.d.ts +28 -1
  126. package/dist/llm/client-base.js +119 -13
  127. package/dist/llm/model-cache.js +4 -2
  128. package/dist/llm/model-pool.d.ts +21 -0
  129. package/dist/llm/model-pool.js +21 -1
  130. package/dist/llm/provider-auth.d.ts +41 -0
  131. package/dist/llm/provider-auth.js +76 -0
  132. package/dist/llm/provider-catalog.d.ts +4 -0
  133. package/dist/llm/providers/anthropic.js +64 -14
  134. package/dist/llm/providers/openai.d.ts +36 -0
  135. package/dist/llm/providers/openai.js +257 -51
  136. package/dist/llm/reasoning-setting.d.ts +3 -3
  137. package/dist/llm/reasoning-setting.js +9 -1
  138. package/dist/llm/stream-watchdog.js +5 -1
  139. package/dist/llm/token-counter.js +9 -2
  140. package/dist/llm/types.d.ts +4 -0
  141. package/dist/logging/sanitize-messages.js +22 -0
  142. package/dist/lsp/manager.d.ts +1 -1
  143. package/dist/lsp/manager.js +40 -10
  144. package/dist/model-catalog/builtin.d.ts +12 -0
  145. package/dist/model-catalog/builtin.js +412 -0
  146. package/dist/model-catalog/gen-connections.d.ts +20 -0
  147. package/dist/model-catalog/gen-connections.js +28 -0
  148. package/dist/model-catalog/index.d.ts +41 -0
  149. package/dist/model-catalog/index.js +90 -0
  150. package/dist/model-catalog/params.d.ts +20 -0
  151. package/dist/model-catalog/params.js +45 -0
  152. package/dist/model-catalog/resolve.d.ts +48 -0
  153. package/dist/model-catalog/resolve.js +33 -0
  154. package/dist/model-catalog/save-entry.d.ts +32 -0
  155. package/dist/model-catalog/save-entry.js +104 -0
  156. package/dist/model-catalog/types.d.ts +561 -0
  157. package/dist/model-catalog/types.js +93 -0
  158. package/dist/model-catalog/upsert.d.ts +9 -0
  159. package/dist/model-catalog/upsert.js +8 -0
  160. package/dist/onboarding.d.ts +12 -82
  161. package/dist/onboarding.js +61 -326
  162. package/dist/plugins/gitOps.d.ts +19 -0
  163. package/dist/plugins/gitOps.js +73 -4
  164. package/dist/plugins/installer/checkUpdate.d.ts +16 -0
  165. package/dist/plugins/installer/checkUpdate.js +32 -0
  166. package/dist/plugins/installer/codex/convertCommands.d.ts +19 -0
  167. package/dist/plugins/installer/codex/convertCommands.js +46 -0
  168. package/dist/plugins/installer/codex/convertMcp.d.ts +5 -2
  169. package/dist/plugins/installer/codex/convertMcp.js +45 -5
  170. package/dist/plugins/installer/install.js +25 -1
  171. package/dist/plugins/installer/installFromArchive.d.ts +43 -0
  172. package/dist/plugins/installer/installFromArchive.js +134 -0
  173. package/dist/plugins/installer/installFromSource.js +8 -2
  174. package/dist/plugins/installer/loadPluginAgents.js +6 -2
  175. package/dist/plugins/installer/loadPluginMcp.d.ts +9 -2
  176. package/dist/plugins/installer/loadPluginMcp.js +35 -2
  177. package/dist/plugins/installer/pruneDisabled.d.ts +24 -0
  178. package/dist/plugins/installer/pruneDisabled.js +73 -0
  179. package/dist/plugins/installer/types.d.ts +5 -2
  180. package/dist/plugins/installer/types.js +1 -0
  181. package/dist/plugins/installer/uninstall.js +4 -0
  182. package/dist/plugins/installer/unzip.d.ts +14 -0
  183. package/dist/plugins/installer/unzip.js +82 -0
  184. package/dist/plugins/installer/update.d.ts +14 -0
  185. package/dist/plugins/installer/update.js +53 -21
  186. package/dist/plugins/loadPluginHooks.d.ts +47 -1
  187. package/dist/plugins/loadPluginHooks.js +73 -1
  188. package/dist/plugins/marketplaceManager.d.ts +7 -0
  189. package/dist/plugins/marketplaceManager.js +20 -0
  190. package/dist/plugins/pluginCommandHook.js +4 -18
  191. package/dist/plugins/pluginContent.d.ts +30 -0
  192. package/dist/plugins/pluginContent.js +83 -0
  193. package/dist/plugins/pluginInstaller.d.ts +13 -0
  194. package/dist/plugins/pluginInstaller.js +42 -8
  195. package/dist/plugins/schemas.js +1 -0
  196. package/dist/plugins/types.d.ts +6 -0
  197. package/dist/preset/index.d.ts +11 -1
  198. package/dist/preset/index.js +115 -6
  199. package/dist/product/types.d.ts +1 -1
  200. package/dist/prompt/composer.d.ts +32 -0
  201. package/dist/prompt/composer.js +75 -21
  202. package/dist/prompt/instruction-scanner.js +5 -3
  203. package/dist/prompt/section-loader.js +1 -0
  204. package/dist/prompt/sections/base.md +2 -0
  205. package/dist/prompt/sections/browser.md +10 -0
  206. package/dist/prompt/sections/coding.md +4 -0
  207. package/dist/protocol/chat-session-manager.d.ts +9 -2
  208. package/dist/protocol/chat-session-manager.js +38 -0
  209. package/dist/protocol/chat-session.d.ts +69 -1
  210. package/dist/protocol/chat-session.js +102 -4
  211. package/dist/protocol/client.d.ts +31 -0
  212. package/dist/protocol/client.js +44 -0
  213. package/dist/protocol/server.d.ts +120 -7
  214. package/dist/protocol/server.js +753 -51
  215. package/dist/protocol/transport.js +3 -2
  216. package/dist/protocol/types.d.ts +60 -0
  217. package/dist/protocol/types.js +16 -0
  218. package/dist/quota/credentials.d.ts +3 -0
  219. package/dist/quota/credentials.js +80 -0
  220. package/dist/quota/index.d.ts +36 -0
  221. package/dist/quota/index.js +155 -0
  222. package/dist/quota/types.d.ts +48 -0
  223. package/dist/quota/types.js +13 -0
  224. package/dist/review/review-prompt.d.ts +28 -0
  225. package/dist/review/review-prompt.js +81 -0
  226. package/dist/run/FileRunStore.js +8 -3
  227. package/dist/run/RunApprovalBackend.js +25 -5
  228. package/dist/run/RunManager.d.ts +12 -0
  229. package/dist/run/RunManager.js +35 -0
  230. package/dist/run/factory.d.ts +1 -1
  231. package/dist/runtime/background-shell.d.ts +139 -0
  232. package/dist/runtime/background-shell.js +509 -0
  233. package/dist/runtime/output-clean.d.ts +24 -0
  234. package/dist/runtime/output-clean.js +41 -0
  235. package/dist/runtime/ring-file.d.ts +64 -0
  236. package/dist/runtime/ring-file.js +174 -0
  237. package/dist/runtime/safe-spawn.js +98 -39
  238. package/dist/runtime/spawn-common.d.ts +159 -0
  239. package/dist/runtime/spawn-common.js +404 -0
  240. package/dist/runtime/truncate-output.d.ts +22 -0
  241. package/dist/runtime/truncate-output.js +49 -0
  242. package/dist/runtime/utf8-cut.d.ts +11 -0
  243. package/dist/runtime/utf8-cut.js +23 -0
  244. package/dist/services/auto-dream.d.ts +4 -0
  245. package/dist/services/auto-dream.js +26 -26
  246. package/dist/services/diagnostics.d.ts +1 -2
  247. package/dist/services/diagnostics.js +12 -7
  248. package/dist/services/extract-memories.d.ts +14 -1
  249. package/dist/services/extract-memories.js +45 -6
  250. package/dist/services/memory-orchestrator.d.ts +21 -0
  251. package/dist/services/memory-orchestrator.js +125 -50
  252. package/dist/services/session-memory.js +24 -12
  253. package/dist/session/file-history.d.ts +124 -1
  254. package/dist/session/file-history.js +222 -6
  255. package/dist/session/memory.d.ts +116 -2
  256. package/dist/session/memory.js +250 -28
  257. package/dist/session/session-manager.d.ts +40 -0
  258. package/dist/session/session-manager.js +119 -3
  259. package/dist/session/simple-diff.d.ts +23 -0
  260. package/dist/session/simple-diff.js +84 -0
  261. package/dist/session/transcript.d.ts +29 -1
  262. package/dist/session/transcript.js +56 -2
  263. package/dist/session/undo-target.d.ts +67 -0
  264. package/dist/session/undo-target.js +144 -0
  265. package/dist/settings/disk-defaults.d.ts +9 -2
  266. package/dist/settings/disk-defaults.js +11 -2
  267. package/dist/settings/feature-flags.d.ts +64 -0
  268. package/dist/settings/feature-flags.js +61 -0
  269. package/dist/settings/manager.d.ts +68 -1
  270. package/dist/settings/manager.js +266 -29
  271. package/dist/settings/migrate-config.d.ts +45 -0
  272. package/dist/settings/migrate-config.js +125 -0
  273. package/dist/settings/schema-export.d.ts +25 -0
  274. package/dist/settings/schema-export.js +38 -0
  275. package/dist/settings/schema.d.ts +1186 -771
  276. package/dist/settings/schema.js +268 -97
  277. package/dist/skills/scanner.d.ts +9 -0
  278. package/dist/skills/scanner.js +30 -2
  279. package/dist/stt/resolve-transcribe.d.ts +31 -0
  280. package/dist/stt/resolve-transcribe.js +108 -0
  281. package/dist/stt/transcribe.d.ts +51 -0
  282. package/dist/stt/transcribe.js +65 -0
  283. package/dist/tool-system/browser-bridge.d.ts +226 -0
  284. package/dist/tool-system/browser-bridge.js +163 -0
  285. package/dist/tool-system/builtin/agent-heartbeat.d.ts +49 -0
  286. package/dist/tool-system/builtin/agent-heartbeat.js +89 -0
  287. package/dist/tool-system/builtin/agent-notifications.d.ts +12 -3
  288. package/dist/tool-system/builtin/agent-notifications.js +9 -3
  289. package/dist/tool-system/builtin/agent-output-file.d.ts +38 -0
  290. package/dist/tool-system/builtin/agent-output-file.js +72 -0
  291. package/dist/tool-system/builtin/agent-registry.d.ts +12 -0
  292. package/dist/tool-system/builtin/agent-registry.js +8 -0
  293. package/dist/tool-system/builtin/agent.d.ts +21 -1
  294. package/dist/tool-system/builtin/agent.js +489 -42
  295. package/dist/tool-system/builtin/apply-patch/applier.js +66 -8
  296. package/dist/tool-system/builtin/apply-patch/backup-targets.d.ts +10 -0
  297. package/dist/tool-system/builtin/apply-patch/backup-targets.js +30 -0
  298. package/dist/tool-system/builtin/apply-patch/index.js +0 -15
  299. package/dist/tool-system/builtin/background-jobs.d.ts +76 -0
  300. package/dist/tool-system/builtin/background-jobs.js +124 -0
  301. package/dist/tool-system/builtin/background-shell-tools.d.ts +20 -0
  302. package/dist/tool-system/builtin/background-shell-tools.js +108 -0
  303. package/dist/tool-system/builtin/background-work.d.ts +67 -0
  304. package/dist/tool-system/builtin/background-work.js +86 -0
  305. package/dist/tool-system/builtin/bash-output-style.d.ts +32 -0
  306. package/dist/tool-system/builtin/bash-output-style.js +40 -0
  307. package/dist/tool-system/builtin/bash.d.ts +5 -2
  308. package/dist/tool-system/builtin/bash.js +101 -64
  309. package/dist/tool-system/builtin/browser-tools.d.ts +33 -0
  310. package/dist/tool-system/builtin/browser-tools.js +312 -0
  311. package/dist/tool-system/builtin/cancel-goal.d.ts +31 -0
  312. package/dist/tool-system/builtin/cancel-goal.js +64 -0
  313. package/dist/tool-system/builtin/check-quota.d.ts +15 -0
  314. package/dist/tool-system/builtin/check-quota.js +34 -0
  315. package/dist/tool-system/builtin/config.js +7 -0
  316. package/dist/tool-system/builtin/cron.d.ts +7 -0
  317. package/dist/tool-system/builtin/cron.js +64 -4
  318. package/dist/tool-system/builtin/drive-claude-code.d.ts +30 -0
  319. package/dist/tool-system/builtin/drive-claude-code.js +157 -0
  320. package/dist/tool-system/builtin/edit-model-catalog.d.ts +3 -0
  321. package/dist/tool-system/builtin/edit-model-catalog.js +104 -0
  322. package/dist/tool-system/builtin/edit.js +20 -16
  323. package/dist/tool-system/builtin/eol.d.ts +29 -0
  324. package/dist/tool-system/builtin/eol.js +37 -0
  325. package/dist/tool-system/builtin/file-cache.d.ts +6 -0
  326. package/dist/tool-system/builtin/file-cache.js +8 -0
  327. package/dist/tool-system/builtin/generate-image.d.ts +35 -0
  328. package/dist/tool-system/builtin/generate-image.js +278 -50
  329. package/dist/tool-system/builtin/generate-video.d.ts +55 -0
  330. package/dist/tool-system/builtin/generate-video.js +364 -0
  331. package/dist/tool-system/builtin/glob.js +0 -7
  332. package/dist/tool-system/builtin/grep.d.ts +9 -0
  333. package/dist/tool-system/builtin/grep.js +106 -11
  334. package/dist/tool-system/builtin/image-providers.d.ts +86 -0
  335. package/dist/tool-system/builtin/image-providers.js +190 -0
  336. package/dist/tool-system/builtin/image-uploader.d.ts +33 -0
  337. package/dist/tool-system/builtin/image-uploader.js +74 -0
  338. package/dist/tool-system/builtin/index.d.ts +10 -2
  339. package/dist/tool-system/builtin/index.js +251 -27
  340. package/dist/tool-system/builtin/mcp-tools.js +23 -3
  341. package/dist/tool-system/builtin/memory.js +45 -7
  342. package/dist/tool-system/builtin/notebook-edit.js +0 -7
  343. package/dist/tool-system/builtin/powershell.js +8 -2
  344. package/dist/tool-system/builtin/read.js +10 -10
  345. package/dist/tool-system/builtin/repl.js +4 -1
  346. package/dist/tool-system/builtin/skill.js +9 -0
  347. package/dist/tool-system/builtin/sleep.js +8 -2
  348. package/dist/tool-system/builtin/tool-search.js +25 -7
  349. package/dist/tool-system/builtin/video-providers.d.ts +154 -0
  350. package/dist/tool-system/builtin/video-providers.js +235 -0
  351. package/dist/tool-system/builtin/web-fetch.js +12 -2
  352. package/dist/tool-system/builtin/web-search.js +21 -7
  353. package/dist/tool-system/builtin/worktree.d.ts +2 -1
  354. package/dist/tool-system/builtin/worktree.js +31 -4
  355. package/dist/tool-system/builtin/write.js +0 -6
  356. package/dist/tool-system/context.d.ts +164 -6
  357. package/dist/tool-system/executor.d.ts +3 -1
  358. package/dist/tool-system/executor.js +197 -90
  359. package/dist/tool-system/investigation-guard.js +1 -1
  360. package/dist/tool-system/mcp-manager.d.ts +42 -4
  361. package/dist/tool-system/mcp-manager.js +203 -20
  362. package/dist/tool-system/mcp-stdio-diagnostics.d.ts +9 -0
  363. package/dist/tool-system/mcp-stdio-diagnostics.js +93 -0
  364. package/dist/tool-system/path-policy.d.ts +5 -0
  365. package/dist/tool-system/path-policy.js +307 -8
  366. package/dist/tool-system/permission.d.ts +39 -2
  367. package/dist/tool-system/permission.js +283 -70
  368. package/dist/tool-system/plan-mode-allowlist.d.ts +13 -2
  369. package/dist/tool-system/plan-mode-allowlist.js +24 -2
  370. package/dist/tool-system/registry.d.ts +1 -0
  371. package/dist/tool-system/registry.js +16 -2
  372. package/dist/tool-system/sandbox/index.d.ts +8 -0
  373. package/dist/tool-system/sandbox/index.js +7 -2
  374. package/dist/tool-system/sandbox/off.js +7 -1
  375. package/dist/tool-system/validate-tool-metadata.d.ts +36 -0
  376. package/dist/tool-system/validate-tool-metadata.js +63 -0
  377. package/dist/types.d.ts +252 -7
  378. package/dist/updater.js +20 -9
  379. package/dist/utils/envUtils.d.ts +0 -9
  380. package/dist/utils/envUtils.js +3 -28
  381. package/dist/utils/exec.d.ts +48 -0
  382. package/dist/utils/exec.js +154 -0
  383. package/dist/utils/json.d.ts +12 -0
  384. package/dist/utils/json.js +92 -0
  385. package/dist/utils/theme.d.ts +1 -1
  386. package/dist/utils/theme.js +1 -1
  387. package/dist/utils/toolDisplay.js +0 -1
  388. package/package.json +13 -7
  389. package/dist/agent/coordinator.d.ts +0 -49
  390. package/dist/agent/coordinator.js +0 -77
  391. package/dist/settings/manager.test.js +0 -73
  392. package/dist/tool-system/builtin/remote-trigger.d.ts +0 -6
  393. package/dist/tool-system/builtin/remote-trigger.js +0 -54
  394. package/dist/tool-system/builtin/send-message.d.ts +0 -6
  395. package/dist/tool-system/builtin/send-message.js +0 -47
  396. /package/dist/{settings/manager.test.d.ts → credentials/types.js} +0 -0
@@ -17,7 +17,7 @@
17
17
  * when no sandbox is available.
18
18
  */
19
19
  import { accessSync, constants, realpathSync } from "node:fs";
20
- import { homedir } from "node:os";
20
+ import { homedir, tmpdir } from "node:os";
21
21
  import { SandboxUnavailableError } from "../../exceptions.js";
22
22
  /**
23
23
  * Detect which sandbox mechanisms are available on the current host. Used by
@@ -111,9 +111,14 @@ function warnAutoDowngrade() {
111
111
  `Set sandbox.mode=off in settings.json to silence, or CODE_SHELL_SANDBOX_QUIET=1.\n`);
112
112
  }
113
113
  export function defaultSandboxConfig(mode = "auto") {
114
+ // Temp roots are writable so tool-result spillover / scratch files land
115
+ // somewhere. POSIX: the canonical /tmp family. Windows has no OS sandbox
116
+ // backend (auto → off), so writableRoots is effectively unused there, but
117
+ // keep it host-correct by using the platform temp dir instead of /tmp.
118
+ const tmpRoots = process.platform === "win32" ? [tmpdir()] : ["/tmp", "/private/tmp", "/var/tmp"];
114
119
  return {
115
120
  mode,
116
- writableRoots: ["${workspace}", "/tmp", "/private/tmp", "/var/tmp"],
121
+ writableRoots: ["${workspace}", ...tmpRoots],
117
122
  deniedReads: [
118
123
  "~/.ssh",
119
124
  "~/.aws",
@@ -1,8 +1,14 @@
1
+ import { resolveShellInvocation } from "../../runtime/spawn-common.js";
1
2
  export function createOffBackend() {
2
3
  return {
3
4
  name: "off",
4
5
  wrap(command, opts) {
5
- return { file: opts.shell, args: ["-c", command] };
6
+ // "off" = no sandboxing; just run the command through the shell. Delegate
7
+ // to resolveShellInvocation for the PLATFORM-CORRECT flag instead of a
8
+ // hardcoded POSIX `-c`: on Windows cmd.exe needs `/c` (a bare `-c` is taken
9
+ // as a filename and cmd hangs in interactive mode until timeout — the
10
+ // "Bash never runs on Windows" beta regression). POSIX still gets `-c`.
11
+ return resolveShellInvocation(command, opts.shell);
6
12
  },
7
13
  };
8
14
  }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Registration-time guard for tool path-policy metadata.
3
+ *
4
+ * A tool's `pathPolicy[].arg` names the input field that carries a file path
5
+ * (or, for apply_patch, the patch text). ToolExecutor reads `args[policy.arg]`
6
+ * to find the targets it must run through the path-permission layer. If that
7
+ * arg name is a typo (e.g. `"pat"` instead of `"path"`), the lookup yields
8
+ * `undefined`, the executor finds zero targets, and the tool runs with NO path
9
+ * protection and no error — a silent security failure (assessment §4.1).
10
+ *
11
+ * This validator catches that drift at registration time by asserting every
12
+ * declared `pathPolicy.arg` exists in the tool's `inputSchema.properties`.
13
+ */
14
+ import type { RegisteredTool, ToolDefinition } from "../types.js";
15
+ /** A tool-shaped object carrying the fields this validator inspects. */
16
+ type ToolLike = Pick<RegisteredTool, "name" | "inputSchema"> & Partial<Pick<RegisteredTool, "pathPolicy">>;
17
+ export interface ToolMetadataIssue {
18
+ tool: string;
19
+ arg: string;
20
+ reason: string;
21
+ }
22
+ /**
23
+ * Check a single tool's path-policy metadata against its schema. Returns one
24
+ * issue per `pathPolicy.arg` that is not a declared input property. Tools
25
+ * without a pathPolicy produce no issues.
26
+ */
27
+ export declare function findToolMetadataIssues(tool: ToolLike): ToolMetadataIssue[];
28
+ /**
29
+ * Assert a tool's path-policy metadata is consistent with its schema. Throws on
30
+ * the first drift. Call at registration time so a typo fails loud instead of
31
+ * silently disabling path protection.
32
+ */
33
+ export declare function validateToolMetadata(tool: ToolLike): void;
34
+ /** Validate a batch; returns every issue across all tools (does not throw). */
35
+ export declare function collectToolMetadataIssues(tools: ReadonlyArray<ToolLike | ToolDefinition>): ToolMetadataIssue[];
36
+ export {};
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Registration-time guard for tool path-policy metadata.
3
+ *
4
+ * A tool's `pathPolicy[].arg` names the input field that carries a file path
5
+ * (or, for apply_patch, the patch text). ToolExecutor reads `args[policy.arg]`
6
+ * to find the targets it must run through the path-permission layer. If that
7
+ * arg name is a typo (e.g. `"pat"` instead of `"path"`), the lookup yields
8
+ * `undefined`, the executor finds zero targets, and the tool runs with NO path
9
+ * protection and no error — a silent security failure (assessment §4.1).
10
+ *
11
+ * This validator catches that drift at registration time by asserting every
12
+ * declared `pathPolicy.arg` exists in the tool's `inputSchema.properties`.
13
+ */
14
+ /**
15
+ * Return the set of property names declared in a JSON-schema-ish object's
16
+ * `properties`. Tolerant of missing/malformed schema (returns empty set), so a
17
+ * tool with no declared properties is treated as "declares nothing" rather
18
+ * than throwing — the caller decides how to react.
19
+ */
20
+ function schemaPropertyNames(inputSchema) {
21
+ const props = inputSchema?.properties;
22
+ if (!props || typeof props !== "object")
23
+ return new Set();
24
+ return new Set(Object.keys(props));
25
+ }
26
+ /**
27
+ * Check a single tool's path-policy metadata against its schema. Returns one
28
+ * issue per `pathPolicy.arg` that is not a declared input property. Tools
29
+ * without a pathPolicy produce no issues.
30
+ */
31
+ export function findToolMetadataIssues(tool) {
32
+ const policies = tool.pathPolicy;
33
+ if (!policies || policies.length === 0)
34
+ return [];
35
+ const declared = schemaPropertyNames(tool.inputSchema);
36
+ const issues = [];
37
+ for (const policy of policies) {
38
+ if (!declared.has(policy.arg)) {
39
+ issues.push({
40
+ tool: tool.name,
41
+ arg: policy.arg,
42
+ reason: `pathPolicy.arg "${policy.arg}" is not a property of inputSchema (path-permission enforcement would silently no-op)`,
43
+ });
44
+ }
45
+ }
46
+ return issues;
47
+ }
48
+ /**
49
+ * Assert a tool's path-policy metadata is consistent with its schema. Throws on
50
+ * the first drift. Call at registration time so a typo fails loud instead of
51
+ * silently disabling path protection.
52
+ */
53
+ export function validateToolMetadata(tool) {
54
+ const issues = findToolMetadataIssues(tool);
55
+ if (issues.length > 0) {
56
+ const first = issues[0];
57
+ throw new Error(`Invalid tool metadata for "${first.tool}": ${first.reason}`);
58
+ }
59
+ }
60
+ /** Validate a batch; returns every issue across all tools (does not throw). */
61
+ export function collectToolMetadataIssues(tools) {
62
+ return tools.flatMap((t) => findToolMetadataIssues(t));
63
+ }
package/dist/types.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Core type definitions for the code-shell orchestration framework.
3
3
  */
4
+ import type { GoalConfig } from "./engine/goal.js";
4
5
  export interface ContentBlock {
5
6
  type: "text" | "tool_use" | "tool_result" | "image" | "reasoning";
6
7
  text?: string;
@@ -52,8 +53,44 @@ export interface ToolResult {
52
53
  contentBlocks?: ContentBlock[];
53
54
  error?: string;
54
55
  isError?: boolean;
56
+ /**
57
+ * Set by tools that execute under the sandbox (Bash / background shell /
58
+ * worktree) so the UI can show whether THIS call was isolated. `backend`
59
+ * "off" means the command ran un-sandboxed (we surface it explicitly so the
60
+ * user sees "未隔离" rather than guessing from an absent badge); "seatbelt"
61
+ * / "bwrap" mean OS-level isolation applied. `network` is the policy that
62
+ * was in force (absent when off). Tools that don't touch the sandbox leave
63
+ * this undefined and the UI renders no badge.
64
+ */
65
+ sandbox?: {
66
+ backend: "off" | "seatbelt" | "bwrap";
67
+ network?: "allow" | "deny";
68
+ };
55
69
  }
56
70
  export type ToolSource = "builtin" | "mcp";
71
+ export type ToolPathPolicyOperation = "read" | "write" | {
72
+ /** Argument whose value decides whether this invocation reads or writes. */
73
+ fromArg: string;
74
+ /** Values that classify the operation as a read. */
75
+ readValues?: string[];
76
+ /** Values that classify the operation as a write. */
77
+ writeValues?: string[];
78
+ /** Fallback when the argument is absent or does not match either list. */
79
+ default: "read" | "write";
80
+ };
81
+ export type ToolPathPolicy = {
82
+ kind: "arg";
83
+ /** Argument containing a file or directory path. */
84
+ arg: string;
85
+ operation: ToolPathPolicyOperation;
86
+ /** Use ctx.cwd when the argument is omitted. Useful for Glob/Grep roots. */
87
+ defaultToCwd?: boolean;
88
+ } | {
89
+ kind: "apply_patch";
90
+ /** Argument containing the V4A patch text. */
91
+ arg: string;
92
+ operation: "write";
93
+ };
57
94
  export interface RegisteredTool {
58
95
  name: string;
59
96
  description: string;
@@ -63,6 +100,18 @@ export interface RegisteredTool {
63
100
  permissionDefault: PermissionDecision;
64
101
  isConcurrencySafe?: boolean;
65
102
  isReadOnly?: boolean;
103
+ /**
104
+ * Declarative file-path safety metadata. ToolExecutor enforces this before
105
+ * dispatching the tool, so file access cannot depend on each tool handler
106
+ * remembering to call path-policy manually.
107
+ */
108
+ pathPolicy?: ToolPathPolicy[];
109
+ /**
110
+ * Explicitly marks a path-looking tool as intentionally outside the file
111
+ * policy layer. Used by tests/audits so new file tools fail closed unless
112
+ * they either declare pathPolicy or document an exemption.
113
+ */
114
+ pathPolicyExempt?: boolean;
66
115
  /**
67
116
  * Override the default tool execution timeout (ms).
68
117
  * Falls back to DEFAULT_TOOL_TIMEOUT_MS (120s) if unset.
@@ -70,7 +119,7 @@ export interface RegisteredTool {
70
119
  */
71
120
  timeoutMs?: number;
72
121
  }
73
- export type TranscriptEventType = "message" | "tool_use" | "tool_result" | "summary" | "content_replace" | "file_history" | "plan_operation" | "session_meta" | "turn_boundary" | "goal_progress" | "error";
122
+ export type TranscriptEventType = "message" | "tool_use" | "tool_result" | "summary" | "content_replace" | "file_history" | "plan_operation" | "session_meta" | "subagent" | "turn_boundary" | "goal_progress" | "turn_stopped" | "error";
74
123
  export interface TranscriptEvent {
75
124
  id: string;
76
125
  type: TranscriptEventType;
@@ -96,8 +145,28 @@ export interface SessionState {
96
145
  startedAt: number;
97
146
  model: string;
98
147
  provider: string;
148
+ /**
149
+ * Legacy/model-scoped usage summary. Some flows reset this accounting window
150
+ * (for example model switches), so it must not drive whole-session metrics.
151
+ */
99
152
  tokenUsage: TokenUsage;
153
+ /**
154
+ * Monotonic prompt-cache counters for the whole session. These only increase
155
+ * from session start and are separate from the resettable tokenUsage window.
156
+ * Optional on legacy state.json files; SessionManager normalizes them on load.
157
+ */
158
+ cumulativePromptTokens?: number;
159
+ cumulativeCacheReadTokens?: number;
160
+ cumulativeCacheCreationTokens?: number;
100
161
  turnCount: number;
162
+ /**
163
+ * Conversation-turn counter where ONE user message = one turn (incremented in
164
+ * engine.run before the message hits the LLM). Distinct from `turnCount`,
165
+ * which counts turn-loop iterations (a single user message can span many).
166
+ * Tags file-history snapshots so turn-level `/undo` can revert exactly what
167
+ * the last user message changed. Absent on legacy sessions → treated as 0.
168
+ */
169
+ turnSeq?: number;
101
170
  invokedSkills: string[];
102
171
  /**
103
172
  * Owning parent session for a sub-agent run; `null` explicitly marks a
@@ -114,8 +183,25 @@ export interface SessionState {
114
183
  status: SessionStatus;
115
184
  /** Short summary derived from the first user message */
116
185
  summary?: string;
186
+ /**
187
+ * LLM-generated one-line title (auxModel, after the first turn). Distinct from
188
+ * `summary` (the raw first-message fallback). Persisted so the sidebar shows
189
+ * it after a localStorage wipe / disk rebuild — without this it lived only in
190
+ * the renderer's localStorage index and was lost on reset.
191
+ */
192
+ title?: string;
117
193
  /** Persisted cost tracking state (survives process restart). */
118
194
  costState?: Record<string, unknown>;
195
+ /**
196
+ * Active persistent goal (CC `/goal` style). Set once, it survives across
197
+ * messages AND manual interrupts until the judge says it's met or the user
198
+ * clears it. Absent → no active goal. When a run supplies a new goal it
199
+ * REPLACES this (one active goal per session). The judge's `met` verdict and
200
+ * `agent/goalClear` both clear it. Persisted so it survives resume/refresh;
201
+ * on resume the objective carries over but the run-scoped turn/token/time
202
+ * baselines reset (matching CC). See engine.run goal-resolution.
203
+ */
204
+ activeGoal?: GoalConfig;
119
205
  }
120
206
  export interface TokenUsage {
121
207
  promptTokens: number;
@@ -155,6 +241,8 @@ export interface PermissionRule {
155
241
  reason?: string;
156
242
  }
157
243
  export interface ApprovalRequest {
244
+ /** Originating engine session. Hosts use this only to route the prompt UI. */
245
+ sessionId?: string;
158
246
  toolName: string;
159
247
  args: Record<string, unknown>;
160
248
  description: string;
@@ -168,11 +256,22 @@ export interface ApprovalRequest {
168
256
  * survives restart for the current project. Not committed.
169
257
  */
170
258
  export type ApprovalScope = "once" | "session" | "project";
259
+ /**
260
+ * Path granularity for a remembered file-tool grant (Write/Edit). Narrows the
261
+ * remembered rule so "allow Write src/foo.ts for this session" doesn't become
262
+ * "allow Write to ANY path".
263
+ * "file" — only this exact file
264
+ * "dir" — this file's directory and its subdirectories
265
+ * "tool" — every path (the legacy tool-wide behavior)
266
+ * Omitted → "tool" (back-compat). Ignored for non-file tools.
267
+ */
268
+ export type ApprovalPathScope = "file" | "dir" | "tool";
171
269
  export type ApprovalResult = {
172
270
  approved: true;
173
271
  permanent?: boolean;
174
272
  always?: boolean;
175
273
  scope?: ApprovalScope;
274
+ pathScope?: ApprovalPathScope;
176
275
  /** Used by AskUserQuestion to carry the user's free-text answer. */ answer?: string;
177
276
  } | {
178
277
  approved: false;
@@ -206,6 +305,10 @@ export type StreamEvent = {
206
305
  type: "stream_request_start";
207
306
  turnNumber: number;
208
307
  agentId?: string;
308
+ } | {
309
+ type: "steer_injected";
310
+ text: string;
311
+ id?: string;
209
312
  } | {
210
313
  type: "text_delta";
211
314
  text: string;
@@ -234,10 +337,22 @@ export type StreamEvent = {
234
337
  agentId?: string;
235
338
  } | {
236
339
  type: "goal_progress";
237
- status: "not_met" | "met" | "exhausted";
340
+ status: "not_met" | "met" | "exhausted" | "approaching_limit";
238
341
  round: number;
239
342
  gaps?: string;
343
+ /** For "approaching_limit": turns left before the maxTurns cap (TODO 3.1). */
344
+ turnsRemaining?: number;
345
+ /** For "approaching_limit": consecutive blocks left before maxStopBlocks (TODO 3.1). */
346
+ stopBlocksRemaining?: number;
347
+ /** For "approaching_limit": which ceiling is closest — drives UI copy + extend default. */
348
+ nearest?: "turns" | "stopBlocks";
240
349
  agentId?: string;
350
+ } | {
351
+ type: "goal_set";
352
+ objective: string;
353
+ replaced: boolean;
354
+ } | {
355
+ type: "goal_cleared";
241
356
  } | {
242
357
  type: "error";
243
358
  error: string;
@@ -249,6 +364,12 @@ export type StreamEvent = {
249
364
  type: "task_update";
250
365
  tasks: TaskInfo[];
251
366
  agentId?: string;
367
+ } | {
368
+ type: "memory_recalled";
369
+ name: string;
370
+ scope: "user" | "dream";
371
+ location: "global" | "project";
372
+ agentId?: string;
252
373
  } | {
253
374
  type: "thinking_delta";
254
375
  text: string;
@@ -259,6 +380,12 @@ export type StreamEvent = {
259
380
  name?: string;
260
381
  description: string;
261
382
  agentType?: string;
383
+ } | {
384
+ type: "agent_backgrounded";
385
+ agentId: string;
386
+ name?: string;
387
+ description: string;
388
+ agentType?: string;
262
389
  } | {
263
390
  type: "agent_end";
264
391
  agentId: string;
@@ -267,18 +394,61 @@ export type StreamEvent = {
267
394
  text?: string;
268
395
  error?: string;
269
396
  agentType?: string;
397
+ } | {
398
+ type: "agent_heartbeat";
399
+ agentIds: string[];
400
+ ts: number;
270
401
  } | {
271
402
  type: "tool_summary";
272
403
  summary: string;
273
404
  } | {
274
405
  type: "context_compact";
275
- strategy: "micro" | "summary" | "window" | "snip" | "emergency";
406
+ strategy: "micro" | "summary" | "window" | "snip" | "emergency" | "compacted";
276
407
  before: number;
277
408
  after: number;
278
409
  agentId?: string;
279
410
  } | {
280
411
  type: "usage_update";
281
412
  promptTokens: number;
413
+ /**
414
+ * Provider-reported prompt-cache counts, forwarded so the UI can show a
415
+ * cache hit rate in the context-ring tooltip. Present only when the LLM
416
+ * response carried them (authoritative-usage emits); omitted on the
417
+ * message-estimate emits that fire between LLM calls. See
418
+ * docs/todo/prompt-cache-optimization.md.
419
+ */
420
+ cacheReadTokens?: number;
421
+ cacheCreationTokens?: number;
422
+ /**
423
+ * Prompt-cache metrics for the current turn only. These are reset at the
424
+ * start of each turn-loop iteration and sum every LLM response in that
425
+ * turn, including max-token continuations.
426
+ */
427
+ singleTurnPromptTokens?: number;
428
+ singleTurnCacheReadTokens?: number;
429
+ singleTurnCacheCreationTokens?: number;
430
+ singleTurnCacheHitRate?: number;
431
+ /**
432
+ * Whole-session monotonic prompt-cache counters/rate. Unlike the legacy
433
+ * session* fields below, these are not derived from the resettable
434
+ * tokenUsage accounting window.
435
+ */
436
+ cumulativePromptTokens?: number;
437
+ cumulativeCacheReadTokens?: number;
438
+ cumulativeCacheCreationTokens?: number;
439
+ cumulativeCacheHitRate?: number;
440
+ /**
441
+ * SESSION-CUMULATIVE cache counts (sum across every LLM response this
442
+ * session, across runs and turns), emitted from the engine's turn
443
+ * boundary off the persisted session.state.tokenUsage. Distinct from the
444
+ * per-response cacheReadTokens/cacheCreationTokens above: those drive the
445
+ * live context reading, these drive the "本会话累计命中率" tooltip. Reset
446
+ * to 0 on a model switch. Present only on the cumulative (turn-boundary)
447
+ * emit; omitted on per-response / estimate emits.
448
+ */
449
+ sessionCacheReadTokens?: number;
450
+ sessionCacheCreationTokens?: number;
451
+ sessionPromptTokens?: number;
282
452
  agentId?: string;
283
453
  } | {
284
454
  type: "background_agent_completed";
@@ -286,6 +456,15 @@ export type StreamEvent = {
286
456
  name?: string;
287
457
  description: string;
288
458
  status: "completed" | "failed";
459
+ /**
460
+ * What kind of background work this was. Lets UIs localize the
461
+ * completion toast (e.g. a shell shows "命令完成" not the raw English
462
+ * description, which is written for the agent's wakeup notification).
463
+ * Absent for legacy sub-agent notifications (treated as "agent").
464
+ */
465
+ workKind?: "agent" | "shell" | "video" | "cc";
466
+ /** For workKind === "shell": the command that ran (for a friendly label). */
467
+ command?: string;
289
468
  /** Final assistant text (status === "completed" only). */
290
469
  finalText?: string;
291
470
  /** Error message (status === "failed" only). */
@@ -317,6 +496,23 @@ export interface LLMConfig {
317
496
  apiKey?: string;
318
497
  baseUrl?: string;
319
498
  maxTokens?: number;
499
+ /** Per-model context window size used by hosts to seed Engine.maxContextTokens. */
500
+ maxContextTokens?: number;
501
+ /**
502
+ * Shell command whose stdout is the auth token (TODO 7.2). Resolved at
503
+ * client-build time when `apiKey` is absent. The trimmed first line of
504
+ * stdout becomes the bearer token.
505
+ */
506
+ authCommand?: string;
507
+ /**
508
+ * Extra HTTP headers for every request to this model's provider (TODO 7.2).
509
+ * A value `$ENV_VAR` is resolved from the environment at build time.
510
+ */
511
+ httpHeaders?: Record<string, string>;
512
+ /** OpenAI `service_tier` request param, passed through verbatim (TODO 7.2). */
513
+ serviceTier?: string;
514
+ /** OpenAI reasoning `summary` control ("auto"|"concise"|"detailed") (TODO 7.2). */
515
+ reasoningSummary?: string;
320
516
  /**
321
517
  * Default reasoning/thinking setting for this model. Per-call
322
518
  * `options.reasoning` (e.g. summarize sub-calls) overrides this.
@@ -331,6 +527,12 @@ export interface LLMConfig {
331
527
  * ("openai" or "anthropic") that picks which client class to use.
332
528
  */
333
529
  providerKind?: string;
530
+ /**
531
+ * Catalog-driven extra request-body fields (temperature/top_p/thinking etc),
532
+ * already wire-mapped from the connection's paramValues. Merged into the
533
+ * request body, each key filtered by the model's rejectedParams.
534
+ */
535
+ extraBody?: Record<string, unknown>;
334
536
  }
335
537
  /**
336
538
  * ClientDefaults — runtime knobs that apply regardless of which model is
@@ -347,11 +549,16 @@ export interface ClientDefaults {
347
549
  /** Max retry attempts for transient errors. Default 3. */
348
550
  retryMaxAttempts?: number;
349
551
  /**
350
- * OpenAI-style detail hint sent on every image_url part. Anthropic
351
- * ignores this. Defaults to "high" (OpenAI's own default) when
352
- * unset; "low" is 85-tokens-per-image fixed.
552
+ * Provider-agnostic image clarity level. Drives the renderer-side
553
+ * downscale (long-edge cap: low→~1024 / standard→~1568 / high→~2576)
554
+ * so BOTH providers save tokens before send. On the OpenAI path it
555
+ * also maps to the wire `detail` hint (low→low, standard/high→high);
556
+ * Anthropic has no such param and saves purely via the downscale.
557
+ * Defaults to "high" (full fidelity) when unset.
558
+ *
559
+ * Legacy "original" values from older settings are migrated to "high".
353
560
  */
354
- imageDetail?: "low" | "high" | "original";
561
+ imageDetail?: "low" | "standard" | "high";
355
562
  }
356
563
  export interface LLMResponse {
357
564
  text: string;
@@ -377,6 +584,28 @@ export interface MCPServerConfig {
377
584
  url?: string;
378
585
  transport?: MCPTransport;
379
586
  headers?: Record<string, string>;
587
+ /**
588
+ * (stdio) NAMES of env vars to forward from the parent process to the
589
+ * spawned server. The value is read from `process.env` at connect time —
590
+ * the secret itself is never stored in config. Explicit `env` overrides.
591
+ */
592
+ envVars?: string[];
593
+ /**
594
+ * (HTTP) NAME of an env var whose value is sent as
595
+ * `Authorization: Bearer <value>`. Read from `process.env` at connect time.
596
+ */
597
+ bearerTokenEnvVar?: string;
598
+ /**
599
+ * (HTTP) Map of header-name → env-var-NAME. Each header's value is read
600
+ * from the named env var at connect time, keeping secrets out of config.
601
+ */
602
+ envHeaders?: Record<string, string>;
603
+ /**
604
+ * (HTTP) id of a stored credential (CredentialStore) to use as the Bearer
605
+ * token. Resolved at connect time via a resolver passed to buildHttpHeaders;
606
+ * the secret is never stored in the MCP config. Wins over bearerTokenEnvVar.
607
+ */
608
+ credentialRef?: string;
380
609
  /**
381
610
  * Toggle a server off without deleting its config (mirrors Codex's
382
611
  * `enabled` field). Absent or `true` → connected; only the literal
@@ -386,6 +615,21 @@ export interface MCPServerConfig {
386
615
  */
387
616
  enabled?: boolean;
388
617
  }
618
+ /**
619
+ * User-supplied supplement for a PLUGIN-provided MCP server, keyed by the
620
+ * server's `<plugin>:<server>` name. Stored globally under
621
+ * `settings.mcpServerOverrides` and layered onto the plugin's config at merge
622
+ * time (see mergePluginMcpServers). Only env/credential fields are allowed —
623
+ * command/args/url/transport stay owned by the plugin manifest so a plugin
624
+ * update is never shadowed by a stale user copy.
625
+ */
626
+ export interface MCPServerOverride {
627
+ env?: Record<string, string>;
628
+ envVars?: string[];
629
+ credentialRef?: string;
630
+ bearerTokenEnvVar?: string;
631
+ envHeaders?: Record<string, string>;
632
+ }
389
633
  /**
390
634
  * Shell-hook configuration entry from settings.json. Each entry binds
391
635
  * a hook event to a shell command. The command runs as a child process
@@ -429,6 +673,7 @@ export interface Settings {
429
673
  maxTokens: number;
430
674
  compactAtRatio: number;
431
675
  summarizeAtRatio: number;
676
+ microcompactFloorRatio: number;
432
677
  };
433
678
  session: {
434
679
  storageDir: string;
package/dist/updater.js CHANGED
@@ -33,6 +33,7 @@ import { dirname, join, resolve } from "node:path";
33
33
  import { readFileSync } from "node:fs";
34
34
  import { fileURLToPath } from "node:url";
35
35
  import { promisify } from "node:util";
36
+ import { resolveShellInvocation } from "./runtime/spawn-common.js";
36
37
  import { gt } from "./utils/semver.js";
37
38
  const execFileAsync = promisify(execFile);
38
39
  const PACKAGE_NAME = "@cjhyy/code-shell";
@@ -282,7 +283,7 @@ function launchDetachedInstall(version) {
282
283
  try {
283
284
  // Avoid `mkdirSync recursive` failures if dir exists.
284
285
  try {
285
- const fs = require("node:fs");
286
+ const fs = createRequire(import.meta.url ?? __filename)("node:fs");
286
287
  fs.mkdirSync(configDir(), { recursive: true });
287
288
  fs.writeFileSync(lockPath, String(process.pid), { encoding: "utf8", flag: "wx" });
288
289
  }
@@ -290,7 +291,7 @@ function launchDetachedInstall(version) {
290
291
  if (errnoCode(err) === "EEXIST") {
291
292
  // Lock held — check freshness; if stale, take over.
292
293
  try {
293
- const fs = require("node:fs");
294
+ const fs = createRequire(import.meta.url ?? __filename)("node:fs");
294
295
  const s = fs.statSync(lockPath);
295
296
  if (Date.now() - s.mtimeMs < LOCK_TIMEOUT_MS)
296
297
  return; // fresh — back off
@@ -309,7 +310,7 @@ function launchDetachedInstall(version) {
309
310
  catch {
310
311
  return;
311
312
  }
312
- const fs = require("node:fs");
313
+ const fs = createRequire(import.meta.url ?? __filename)("node:fs");
313
314
  const logFd = fs.openSync(getUpdateLogPath(), "a");
314
315
  try {
315
316
  fs.writeSync(logFd, `\n[${new Date().toISOString()}] code-shell auto-update: installing ${PACKAGE_NAME}@${version} (pid=${process.pid})\n`);
@@ -318,13 +319,23 @@ function launchDetachedInstall(version) {
318
319
  // ignore
319
320
  }
320
321
  // Wrap install + lock cleanup in a tiny shell so the lock file is removed
321
- // even if npm fails. `-c` style runs as a single child, detached from us.
322
- const cmd = [
323
- `npm install -g ${PACKAGE_NAME}@${shellEscape(version)}`,
324
- `; rm -f ${shellEscape(lockPath)}`,
325
- ].join(" ");
322
+ // even if npm fails. Cross-platform: POSIX sequences with `; rm -f`, Windows
323
+ // cmd.exe with `& del /f /q` (no `sh`/`rm` there). resolveShellInvocation
324
+ // picks the shell binary + flag (/c vs -c) per platform.
325
+ const isWin = process.platform === "win32";
326
+ // cmd.exe doesn't understand POSIX single-quote escaping. version is a semver
327
+ // from npm (no shell metachars) so it needs no quoting on cmd; the lock path
328
+ // gets double quotes (cmd-native). POSIX keeps shellEscape on both.
329
+ const installPkg = isWin
330
+ ? `npm install -g ${PACKAGE_NAME}@${version}`
331
+ : `npm install -g ${PACKAGE_NAME}@${shellEscape(version)}`;
332
+ const cleanup = isWin
333
+ ? `& del /f /q "${lockPath}"`
334
+ : `; rm -f ${shellEscape(lockPath)}`;
335
+ const cmd = `${installPkg} ${cleanup}`;
336
+ const { file: shellFile, args: shellArgs } = resolveShellInvocation(cmd);
326
337
  try {
327
- const child = spawn("sh", ["-c", cmd], {
338
+ const child = spawn(shellFile, shellArgs, {
328
339
  detached: true,
329
340
  stdio: ["ignore", logFd, logFd],
330
341
  cwd: homedir(),
@@ -36,16 +36,7 @@ export declare function getDefaultVertexRegion(): string;
36
36
  * Check if bash commands should maintain project working directory.
37
37
  */
38
38
  export declare function shouldMaintainProjectWorkingDir(): boolean;
39
- /**
40
- * Check if running on Homespace (ant-internal cloud environment).
41
- */
42
- export declare function isRunningOnHomespace(): boolean;
43
39
  /**
44
40
  * Get the Vertex AI region for a specific model.
45
41
  */
46
42
  export declare function getVertexRegionForModel(model: string | undefined): string | undefined;
47
- /**
48
- * Stub: Check if running inside a protected namespace.
49
- * Always returns false in Code Shell (Anthropic-internal feature).
50
- */
51
- export declare function isInProtectedNamespace(): boolean;