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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (387) 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 +56 -0
  45. package/dist/context/compaction.js +186 -0
  46. package/dist/context/manager.js +25 -4
  47. package/dist/cost-tracker.js +5 -61
  48. package/dist/credentials/cipher.d.ts +49 -0
  49. package/dist/credentials/cipher.js +45 -0
  50. package/dist/credentials/cookie-jar.d.ts +24 -0
  51. package/dist/credentials/cookie-jar.js +40 -0
  52. package/dist/credentials/index.d.ts +7 -0
  53. package/dist/credentials/index.js +5 -0
  54. package/dist/credentials/inject-credential-tool.d.ts +20 -0
  55. package/dist/credentials/inject-credential-tool.js +130 -0
  56. package/dist/credentials/store.d.ts +72 -0
  57. package/dist/credentials/store.js +184 -0
  58. package/dist/credentials/types.d.ts +56 -0
  59. package/dist/credentials/use-credential-tool.d.ts +29 -0
  60. package/dist/credentials/use-credential-tool.js +205 -0
  61. package/dist/credentials/use-gate.d.ts +56 -0
  62. package/dist/credentials/use-gate.js +52 -0
  63. package/dist/data/model-metadata.d.ts +77 -0
  64. package/dist/data/model-metadata.js +56 -0
  65. package/dist/data/model-metadata.json +216 -0
  66. package/dist/data/openrouter-models.d.ts +18 -7
  67. package/dist/data/openrouter-models.js +35 -8
  68. package/dist/engine/aux-key.d.ts +10 -0
  69. package/dist/engine/aux-key.js +11 -0
  70. package/dist/engine/dynamic-tool-defs.d.ts +19 -0
  71. package/dist/engine/dynamic-tool-defs.js +36 -0
  72. package/dist/engine/engine.d.ts +267 -138
  73. package/dist/engine/engine.js +957 -191
  74. package/dist/engine/friendly-error.d.ts +18 -0
  75. package/dist/engine/friendly-error.js +63 -0
  76. package/dist/engine/goal.d.ts +145 -0
  77. package/dist/engine/goal.js +144 -0
  78. package/dist/engine/image-policy.d.ts +13 -0
  79. package/dist/engine/image-policy.js +24 -0
  80. package/dist/engine/model-connections-pool.d.ts +17 -0
  81. package/dist/engine/model-connections-pool.js +66 -0
  82. package/dist/engine/model-facade.d.ts +10 -0
  83. package/dist/engine/model-facade.js +25 -0
  84. package/dist/engine/patch-orphaned-tools.js +3 -0
  85. package/dist/engine/resolve-llm-config.d.ts +16 -0
  86. package/dist/engine/resolve-llm-config.js +44 -0
  87. package/dist/engine/runtime.js +2 -1
  88. package/dist/engine/sandbox-cache-key.d.ts +10 -0
  89. package/dist/engine/sandbox-cache-key.js +9 -0
  90. package/dist/engine/sandbox-config.d.ts +31 -0
  91. package/dist/engine/sandbox-config.js +38 -0
  92. package/dist/engine/session-usage.d.ts +19 -0
  93. package/dist/engine/session-usage.js +25 -0
  94. package/dist/engine/steer-queue.d.ts +32 -0
  95. package/dist/engine/steer-queue.js +26 -0
  96. package/dist/engine/streaming-tool-queue.d.ts +12 -0
  97. package/dist/engine/streaming-tool-queue.js +50 -10
  98. package/dist/engine/turn-loop.d.ts +67 -3
  99. package/dist/engine/turn-loop.js +292 -41
  100. package/dist/engine/types.d.ts +175 -0
  101. package/dist/engine/types.js +13 -0
  102. package/dist/external-agents/config.d.ts +2 -0
  103. package/dist/external-agents/config.js +15 -0
  104. package/dist/external-agents/types.d.ts +31 -0
  105. package/dist/external-agents/types.js +1 -0
  106. package/dist/git/utils.js +11 -6
  107. package/dist/git/worktree.d.ts +48 -0
  108. package/dist/git/worktree.js +86 -10
  109. package/dist/hooks/goal-stop-hook.d.ts +28 -0
  110. package/dist/hooks/goal-stop-hook.js +186 -9
  111. package/dist/hooks/registry.d.ts +8 -0
  112. package/dist/hooks/registry.js +19 -0
  113. package/dist/hooks/shell-runner.js +10 -21
  114. package/dist/index.d.ts +49 -6
  115. package/dist/index.js +60 -4
  116. package/dist/llm/capabilities/param-specs.d.ts +14 -0
  117. package/dist/llm/capabilities/param-specs.js +62 -0
  118. package/dist/llm/capabilities/rules.js +4 -0
  119. package/dist/llm/capabilities/types.d.ts +10 -0
  120. package/dist/llm/client-base.d.ts +28 -1
  121. package/dist/llm/client-base.js +119 -13
  122. package/dist/llm/model-cache.js +4 -2
  123. package/dist/llm/model-pool.d.ts +14 -0
  124. package/dist/llm/model-pool.js +13 -0
  125. package/dist/llm/provider-auth.d.ts +41 -0
  126. package/dist/llm/provider-auth.js +76 -0
  127. package/dist/llm/provider-catalog.d.ts +4 -0
  128. package/dist/llm/providers/anthropic.js +64 -14
  129. package/dist/llm/providers/openai.d.ts +36 -0
  130. package/dist/llm/providers/openai.js +257 -51
  131. package/dist/llm/reasoning-setting.d.ts +3 -3
  132. package/dist/llm/reasoning-setting.js +9 -1
  133. package/dist/llm/stream-watchdog.js +5 -1
  134. package/dist/llm/token-counter.js +9 -2
  135. package/dist/llm/types.d.ts +4 -0
  136. package/dist/logging/sanitize-messages.js +22 -0
  137. package/dist/lsp/manager.d.ts +1 -1
  138. package/dist/lsp/manager.js +40 -10
  139. package/dist/model-catalog/builtin.d.ts +12 -0
  140. package/dist/model-catalog/builtin.js +407 -0
  141. package/dist/model-catalog/gen-connections.d.ts +20 -0
  142. package/dist/model-catalog/gen-connections.js +28 -0
  143. package/dist/model-catalog/index.d.ts +41 -0
  144. package/dist/model-catalog/index.js +90 -0
  145. package/dist/model-catalog/params.d.ts +20 -0
  146. package/dist/model-catalog/params.js +45 -0
  147. package/dist/model-catalog/resolve.d.ts +48 -0
  148. package/dist/model-catalog/resolve.js +33 -0
  149. package/dist/model-catalog/save-entry.d.ts +32 -0
  150. package/dist/model-catalog/save-entry.js +104 -0
  151. package/dist/model-catalog/types.d.ts +561 -0
  152. package/dist/model-catalog/types.js +93 -0
  153. package/dist/model-catalog/upsert.d.ts +9 -0
  154. package/dist/model-catalog/upsert.js +8 -0
  155. package/dist/onboarding.d.ts +12 -82
  156. package/dist/onboarding.js +61 -326
  157. package/dist/plugins/gitOps.d.ts +19 -0
  158. package/dist/plugins/gitOps.js +73 -4
  159. package/dist/plugins/installer/checkUpdate.d.ts +16 -0
  160. package/dist/plugins/installer/checkUpdate.js +32 -0
  161. package/dist/plugins/installer/codex/convertCommands.d.ts +19 -0
  162. package/dist/plugins/installer/codex/convertCommands.js +46 -0
  163. package/dist/plugins/installer/codex/convertMcp.d.ts +5 -2
  164. package/dist/plugins/installer/codex/convertMcp.js +45 -5
  165. package/dist/plugins/installer/install.js +25 -1
  166. package/dist/plugins/installer/installFromArchive.d.ts +43 -0
  167. package/dist/plugins/installer/installFromArchive.js +134 -0
  168. package/dist/plugins/installer/installFromSource.js +8 -2
  169. package/dist/plugins/installer/loadPluginAgents.js +6 -2
  170. package/dist/plugins/installer/loadPluginMcp.d.ts +9 -2
  171. package/dist/plugins/installer/loadPluginMcp.js +35 -2
  172. package/dist/plugins/installer/pruneDisabled.d.ts +24 -0
  173. package/dist/plugins/installer/pruneDisabled.js +73 -0
  174. package/dist/plugins/installer/types.d.ts +5 -2
  175. package/dist/plugins/installer/types.js +1 -0
  176. package/dist/plugins/installer/uninstall.js +4 -0
  177. package/dist/plugins/installer/unzip.d.ts +14 -0
  178. package/dist/plugins/installer/unzip.js +82 -0
  179. package/dist/plugins/installer/update.d.ts +14 -0
  180. package/dist/plugins/installer/update.js +53 -21
  181. package/dist/plugins/loadPluginHooks.d.ts +47 -1
  182. package/dist/plugins/loadPluginHooks.js +73 -1
  183. package/dist/plugins/marketplaceManager.d.ts +7 -0
  184. package/dist/plugins/marketplaceManager.js +20 -0
  185. package/dist/plugins/pluginCommandHook.js +4 -18
  186. package/dist/plugins/pluginContent.d.ts +30 -0
  187. package/dist/plugins/pluginContent.js +83 -0
  188. package/dist/plugins/pluginInstaller.d.ts +13 -0
  189. package/dist/plugins/pluginInstaller.js +42 -8
  190. package/dist/plugins/schemas.js +1 -0
  191. package/dist/plugins/types.d.ts +6 -0
  192. package/dist/preset/index.d.ts +7 -1
  193. package/dist/preset/index.js +96 -6
  194. package/dist/product/types.d.ts +1 -1
  195. package/dist/prompt/composer.d.ts +27 -0
  196. package/dist/prompt/composer.js +67 -21
  197. package/dist/prompt/instruction-scanner.js +5 -3
  198. package/dist/prompt/section-loader.js +1 -0
  199. package/dist/prompt/sections/base.md +1 -0
  200. package/dist/prompt/sections/browser.md +10 -0
  201. package/dist/prompt/sections/coding.md +4 -0
  202. package/dist/protocol/chat-session-manager.d.ts +8 -2
  203. package/dist/protocol/chat-session-manager.js +36 -0
  204. package/dist/protocol/chat-session.d.ts +65 -0
  205. package/dist/protocol/chat-session.js +94 -2
  206. package/dist/protocol/client.d.ts +27 -0
  207. package/dist/protocol/client.js +38 -0
  208. package/dist/protocol/server.d.ts +112 -0
  209. package/dist/protocol/server.js +586 -16
  210. package/dist/protocol/transport.js +3 -2
  211. package/dist/protocol/types.d.ts +46 -0
  212. package/dist/protocol/types.js +16 -0
  213. package/dist/quota/credentials.d.ts +3 -0
  214. package/dist/quota/credentials.js +80 -0
  215. package/dist/quota/index.d.ts +36 -0
  216. package/dist/quota/index.js +155 -0
  217. package/dist/quota/types.d.ts +48 -0
  218. package/dist/quota/types.js +13 -0
  219. package/dist/review/review-prompt.d.ts +28 -0
  220. package/dist/review/review-prompt.js +81 -0
  221. package/dist/run/FileRunStore.js +8 -3
  222. package/dist/run/RunApprovalBackend.js +25 -5
  223. package/dist/run/RunManager.d.ts +12 -0
  224. package/dist/run/RunManager.js +35 -0
  225. package/dist/run/factory.d.ts +1 -1
  226. package/dist/runtime/background-shell.d.ts +139 -0
  227. package/dist/runtime/background-shell.js +495 -0
  228. package/dist/runtime/output-clean.d.ts +24 -0
  229. package/dist/runtime/output-clean.js +41 -0
  230. package/dist/runtime/ring-file.d.ts +64 -0
  231. package/dist/runtime/ring-file.js +174 -0
  232. package/dist/runtime/safe-spawn.js +15 -34
  233. package/dist/runtime/spawn-common.d.ts +148 -0
  234. package/dist/runtime/spawn-common.js +303 -0
  235. package/dist/runtime/truncate-output.d.ts +22 -0
  236. package/dist/runtime/truncate-output.js +49 -0
  237. package/dist/runtime/utf8-cut.d.ts +11 -0
  238. package/dist/runtime/utf8-cut.js +23 -0
  239. package/dist/services/auto-dream.d.ts +4 -0
  240. package/dist/services/auto-dream.js +26 -26
  241. package/dist/services/diagnostics.d.ts +1 -2
  242. package/dist/services/diagnostics.js +12 -7
  243. package/dist/services/extract-memories.d.ts +14 -1
  244. package/dist/services/extract-memories.js +45 -6
  245. package/dist/services/memory-orchestrator.d.ts +21 -0
  246. package/dist/services/memory-orchestrator.js +125 -50
  247. package/dist/services/session-memory.js +24 -12
  248. package/dist/session/file-history.d.ts +124 -1
  249. package/dist/session/file-history.js +222 -6
  250. package/dist/session/memory.d.ts +116 -2
  251. package/dist/session/memory.js +250 -28
  252. package/dist/session/session-manager.d.ts +40 -0
  253. package/dist/session/session-manager.js +113 -3
  254. package/dist/session/simple-diff.d.ts +23 -0
  255. package/dist/session/simple-diff.js +84 -0
  256. package/dist/session/transcript.d.ts +25 -1
  257. package/dist/session/transcript.js +35 -2
  258. package/dist/session/undo-target.d.ts +67 -0
  259. package/dist/session/undo-target.js +144 -0
  260. package/dist/settings/disk-defaults.d.ts +9 -2
  261. package/dist/settings/disk-defaults.js +11 -2
  262. package/dist/settings/feature-flags.d.ts +64 -0
  263. package/dist/settings/feature-flags.js +61 -0
  264. package/dist/settings/manager.d.ts +68 -1
  265. package/dist/settings/manager.js +266 -29
  266. package/dist/settings/migrate-config.d.ts +45 -0
  267. package/dist/settings/migrate-config.js +125 -0
  268. package/dist/settings/schema-export.d.ts +25 -0
  269. package/dist/settings/schema-export.js +38 -0
  270. package/dist/settings/schema.d.ts +1186 -771
  271. package/dist/settings/schema.js +268 -97
  272. package/dist/skills/scanner.d.ts +9 -0
  273. package/dist/skills/scanner.js +30 -2
  274. package/dist/stt/resolve-transcribe.d.ts +31 -0
  275. package/dist/stt/resolve-transcribe.js +108 -0
  276. package/dist/stt/transcribe.d.ts +51 -0
  277. package/dist/stt/transcribe.js +65 -0
  278. package/dist/tool-system/browser-bridge.d.ts +226 -0
  279. package/dist/tool-system/browser-bridge.js +163 -0
  280. package/dist/tool-system/builtin/agent-heartbeat.d.ts +49 -0
  281. package/dist/tool-system/builtin/agent-heartbeat.js +89 -0
  282. package/dist/tool-system/builtin/agent-notifications.d.ts +12 -3
  283. package/dist/tool-system/builtin/agent-notifications.js +9 -3
  284. package/dist/tool-system/builtin/agent-output-file.d.ts +38 -0
  285. package/dist/tool-system/builtin/agent-output-file.js +72 -0
  286. package/dist/tool-system/builtin/agent-registry.d.ts +12 -0
  287. package/dist/tool-system/builtin/agent-registry.js +8 -0
  288. package/dist/tool-system/builtin/agent.d.ts +21 -1
  289. package/dist/tool-system/builtin/agent.js +489 -42
  290. package/dist/tool-system/builtin/apply-patch/applier.js +66 -8
  291. package/dist/tool-system/builtin/apply-patch/backup-targets.d.ts +10 -0
  292. package/dist/tool-system/builtin/apply-patch/backup-targets.js +30 -0
  293. package/dist/tool-system/builtin/apply-patch/index.js +0 -15
  294. package/dist/tool-system/builtin/background-jobs.d.ts +76 -0
  295. package/dist/tool-system/builtin/background-jobs.js +124 -0
  296. package/dist/tool-system/builtin/background-shell-tools.d.ts +20 -0
  297. package/dist/tool-system/builtin/background-shell-tools.js +108 -0
  298. package/dist/tool-system/builtin/background-work.d.ts +67 -0
  299. package/dist/tool-system/builtin/background-work.js +86 -0
  300. package/dist/tool-system/builtin/bash-output-style.d.ts +32 -0
  301. package/dist/tool-system/builtin/bash-output-style.js +40 -0
  302. package/dist/tool-system/builtin/bash.d.ts +5 -2
  303. package/dist/tool-system/builtin/bash.js +98 -62
  304. package/dist/tool-system/builtin/browser-tools.d.ts +33 -0
  305. package/dist/tool-system/builtin/browser-tools.js +312 -0
  306. package/dist/tool-system/builtin/cancel-goal.d.ts +31 -0
  307. package/dist/tool-system/builtin/cancel-goal.js +64 -0
  308. package/dist/tool-system/builtin/check-quota.d.ts +15 -0
  309. package/dist/tool-system/builtin/check-quota.js +34 -0
  310. package/dist/tool-system/builtin/config.js +7 -0
  311. package/dist/tool-system/builtin/cron.d.ts +7 -0
  312. package/dist/tool-system/builtin/cron.js +55 -3
  313. package/dist/tool-system/builtin/drive-claude-code.d.ts +30 -0
  314. package/dist/tool-system/builtin/drive-claude-code.js +157 -0
  315. package/dist/tool-system/builtin/edit-model-catalog.d.ts +3 -0
  316. package/dist/tool-system/builtin/edit-model-catalog.js +94 -0
  317. package/dist/tool-system/builtin/edit.js +20 -16
  318. package/dist/tool-system/builtin/eol.d.ts +29 -0
  319. package/dist/tool-system/builtin/eol.js +37 -0
  320. package/dist/tool-system/builtin/file-cache.d.ts +6 -0
  321. package/dist/tool-system/builtin/file-cache.js +8 -0
  322. package/dist/tool-system/builtin/generate-image.d.ts +35 -0
  323. package/dist/tool-system/builtin/generate-image.js +278 -50
  324. package/dist/tool-system/builtin/generate-video.d.ts +55 -0
  325. package/dist/tool-system/builtin/generate-video.js +361 -0
  326. package/dist/tool-system/builtin/glob.js +0 -7
  327. package/dist/tool-system/builtin/grep.js +6 -8
  328. package/dist/tool-system/builtin/image-providers.d.ts +86 -0
  329. package/dist/tool-system/builtin/image-providers.js +190 -0
  330. package/dist/tool-system/builtin/image-uploader.d.ts +33 -0
  331. package/dist/tool-system/builtin/image-uploader.js +74 -0
  332. package/dist/tool-system/builtin/index.d.ts +7 -1
  333. package/dist/tool-system/builtin/index.js +249 -25
  334. package/dist/tool-system/builtin/mcp-tools.js +23 -3
  335. package/dist/tool-system/builtin/memory.js +45 -7
  336. package/dist/tool-system/builtin/notebook-edit.js +0 -7
  337. package/dist/tool-system/builtin/powershell.js +4 -1
  338. package/dist/tool-system/builtin/read.js +10 -10
  339. package/dist/tool-system/builtin/repl.js +4 -1
  340. package/dist/tool-system/builtin/skill.js +9 -0
  341. package/dist/tool-system/builtin/sleep.js +3 -2
  342. package/dist/tool-system/builtin/tool-search.js +25 -7
  343. package/dist/tool-system/builtin/video-providers.d.ts +154 -0
  344. package/dist/tool-system/builtin/video-providers.js +235 -0
  345. package/dist/tool-system/builtin/web-fetch.js +12 -2
  346. package/dist/tool-system/builtin/web-search.js +21 -7
  347. package/dist/tool-system/builtin/worktree.d.ts +2 -1
  348. package/dist/tool-system/builtin/worktree.js +31 -4
  349. package/dist/tool-system/builtin/write.js +0 -6
  350. package/dist/tool-system/context.d.ts +154 -6
  351. package/dist/tool-system/executor.d.ts +3 -1
  352. package/dist/tool-system/executor.js +172 -88
  353. package/dist/tool-system/investigation-guard.js +1 -1
  354. package/dist/tool-system/mcp-manager.d.ts +42 -4
  355. package/dist/tool-system/mcp-manager.js +186 -20
  356. package/dist/tool-system/path-policy.d.ts +5 -0
  357. package/dist/tool-system/path-policy.js +307 -8
  358. package/dist/tool-system/permission.d.ts +36 -1
  359. package/dist/tool-system/permission.js +281 -69
  360. package/dist/tool-system/plan-mode-allowlist.d.ts +13 -2
  361. package/dist/tool-system/plan-mode-allowlist.js +24 -2
  362. package/dist/tool-system/registry.d.ts +1 -0
  363. package/dist/tool-system/registry.js +16 -2
  364. package/dist/tool-system/sandbox/index.d.ts +8 -0
  365. package/dist/tool-system/sandbox/index.js +7 -2
  366. package/dist/tool-system/validate-tool-metadata.d.ts +36 -0
  367. package/dist/tool-system/validate-tool-metadata.js +63 -0
  368. package/dist/types.d.ts +217 -6
  369. package/dist/updater.js +20 -9
  370. package/dist/utils/envUtils.d.ts +0 -9
  371. package/dist/utils/envUtils.js +3 -28
  372. package/dist/utils/exec.d.ts +40 -0
  373. package/dist/utils/exec.js +144 -0
  374. package/dist/utils/json.d.ts +12 -0
  375. package/dist/utils/json.js +92 -0
  376. package/dist/utils/theme.d.ts +1 -1
  377. package/dist/utils/theme.js +1 -1
  378. package/dist/utils/toolDisplay.js +0 -1
  379. package/package.json +13 -7
  380. package/dist/agent/coordinator.d.ts +0 -49
  381. package/dist/agent/coordinator.js +0 -77
  382. package/dist/settings/manager.test.js +0 -73
  383. package/dist/tool-system/builtin/remote-trigger.d.ts +0 -6
  384. package/dist/tool-system/builtin/remote-trigger.js +0 -54
  385. package/dist/tool-system/builtin/send-message.d.ts +0 -6
  386. package/dist/tool-system/builtin/send-message.js +0 -47
  387. /package/dist/{settings/manager.test.d.ts → credentials/types.js} +0 -0
@@ -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;
@@ -98,6 +147,14 @@ export interface SessionState {
98
147
  provider: string;
99
148
  tokenUsage: TokenUsage;
100
149
  turnCount: number;
150
+ /**
151
+ * Conversation-turn counter where ONE user message = one turn (incremented in
152
+ * engine.run before the message hits the LLM). Distinct from `turnCount`,
153
+ * which counts turn-loop iterations (a single user message can span many).
154
+ * Tags file-history snapshots so turn-level `/undo` can revert exactly what
155
+ * the last user message changed. Absent on legacy sessions → treated as 0.
156
+ */
157
+ turnSeq?: number;
101
158
  invokedSkills: string[];
102
159
  /**
103
160
  * Owning parent session for a sub-agent run; `null` explicitly marks a
@@ -114,8 +171,25 @@ export interface SessionState {
114
171
  status: SessionStatus;
115
172
  /** Short summary derived from the first user message */
116
173
  summary?: string;
174
+ /**
175
+ * LLM-generated one-line title (auxModel, after the first turn). Distinct from
176
+ * `summary` (the raw first-message fallback). Persisted so the sidebar shows
177
+ * it after a localStorage wipe / disk rebuild — without this it lived only in
178
+ * the renderer's localStorage index and was lost on reset.
179
+ */
180
+ title?: string;
117
181
  /** Persisted cost tracking state (survives process restart). */
118
182
  costState?: Record<string, unknown>;
183
+ /**
184
+ * Active persistent goal (CC `/goal` style). Set once, it survives across
185
+ * messages AND manual interrupts until the judge says it's met or the user
186
+ * clears it. Absent → no active goal. When a run supplies a new goal it
187
+ * REPLACES this (one active goal per session). The judge's `met` verdict and
188
+ * `agent/goalClear` both clear it. Persisted so it survives resume/refresh;
189
+ * on resume the objective carries over but the run-scoped turn/token/time
190
+ * baselines reset (matching CC). See engine.run goal-resolution.
191
+ */
192
+ activeGoal?: GoalConfig;
119
193
  }
120
194
  export interface TokenUsage {
121
195
  promptTokens: number;
@@ -168,11 +242,22 @@ export interface ApprovalRequest {
168
242
  * survives restart for the current project. Not committed.
169
243
  */
170
244
  export type ApprovalScope = "once" | "session" | "project";
245
+ /**
246
+ * Path granularity for a remembered file-tool grant (Write/Edit). Narrows the
247
+ * remembered rule so "allow Write src/foo.ts for this session" doesn't become
248
+ * "allow Write to ANY path".
249
+ * "file" — only this exact file
250
+ * "dir" — this file's directory and its subdirectories
251
+ * "tool" — every path (the legacy tool-wide behavior)
252
+ * Omitted → "tool" (back-compat). Ignored for non-file tools.
253
+ */
254
+ export type ApprovalPathScope = "file" | "dir" | "tool";
171
255
  export type ApprovalResult = {
172
256
  approved: true;
173
257
  permanent?: boolean;
174
258
  always?: boolean;
175
259
  scope?: ApprovalScope;
260
+ pathScope?: ApprovalPathScope;
176
261
  /** Used by AskUserQuestion to carry the user's free-text answer. */ answer?: string;
177
262
  } | {
178
263
  approved: false;
@@ -206,6 +291,10 @@ export type StreamEvent = {
206
291
  type: "stream_request_start";
207
292
  turnNumber: number;
208
293
  agentId?: string;
294
+ } | {
295
+ type: "steer_injected";
296
+ text: string;
297
+ id?: string;
209
298
  } | {
210
299
  type: "text_delta";
211
300
  text: string;
@@ -234,10 +323,22 @@ export type StreamEvent = {
234
323
  agentId?: string;
235
324
  } | {
236
325
  type: "goal_progress";
237
- status: "not_met" | "met" | "exhausted";
326
+ status: "not_met" | "met" | "exhausted" | "approaching_limit";
238
327
  round: number;
239
328
  gaps?: string;
329
+ /** For "approaching_limit": turns left before the maxTurns cap (TODO 3.1). */
330
+ turnsRemaining?: number;
331
+ /** For "approaching_limit": consecutive blocks left before maxStopBlocks (TODO 3.1). */
332
+ stopBlocksRemaining?: number;
333
+ /** For "approaching_limit": which ceiling is closest — drives UI copy + extend default. */
334
+ nearest?: "turns" | "stopBlocks";
240
335
  agentId?: string;
336
+ } | {
337
+ type: "goal_set";
338
+ objective: string;
339
+ replaced: boolean;
340
+ } | {
341
+ type: "goal_cleared";
241
342
  } | {
242
343
  type: "error";
243
344
  error: string;
@@ -249,6 +350,12 @@ export type StreamEvent = {
249
350
  type: "task_update";
250
351
  tasks: TaskInfo[];
251
352
  agentId?: string;
353
+ } | {
354
+ type: "memory_recalled";
355
+ name: string;
356
+ scope: "user" | "dream";
357
+ location: "global" | "project";
358
+ agentId?: string;
252
359
  } | {
253
360
  type: "thinking_delta";
254
361
  text: string;
@@ -259,6 +366,12 @@ export type StreamEvent = {
259
366
  name?: string;
260
367
  description: string;
261
368
  agentType?: string;
369
+ } | {
370
+ type: "agent_backgrounded";
371
+ agentId: string;
372
+ name?: string;
373
+ description: string;
374
+ agentType?: string;
262
375
  } | {
263
376
  type: "agent_end";
264
377
  agentId: string;
@@ -267,6 +380,10 @@ export type StreamEvent = {
267
380
  text?: string;
268
381
  error?: string;
269
382
  agentType?: string;
383
+ } | {
384
+ type: "agent_heartbeat";
385
+ agentIds: string[];
386
+ ts: number;
270
387
  } | {
271
388
  type: "tool_summary";
272
389
  summary: string;
@@ -279,6 +396,27 @@ export type StreamEvent = {
279
396
  } | {
280
397
  type: "usage_update";
281
398
  promptTokens: number;
399
+ /**
400
+ * Provider-reported prompt-cache counts, forwarded so the UI can show a
401
+ * cache hit rate in the context-ring tooltip. Present only when the LLM
402
+ * response carried them (authoritative-usage emits); omitted on the
403
+ * message-estimate emits that fire between LLM calls. See
404
+ * docs/todo/prompt-cache-optimization.md.
405
+ */
406
+ cacheReadTokens?: number;
407
+ cacheCreationTokens?: number;
408
+ /**
409
+ * SESSION-CUMULATIVE cache counts (sum across every LLM response this
410
+ * session, across runs and turns), emitted from the engine's turn
411
+ * boundary off the persisted session.state.tokenUsage. Distinct from the
412
+ * per-response cacheReadTokens/cacheCreationTokens above: those drive the
413
+ * live context reading, these drive the "本会话累计命中率" tooltip. Reset
414
+ * to 0 on a model switch. Present only on the cumulative (turn-boundary)
415
+ * emit; omitted on per-response / estimate emits.
416
+ */
417
+ sessionCacheReadTokens?: number;
418
+ sessionCacheCreationTokens?: number;
419
+ sessionPromptTokens?: number;
282
420
  agentId?: string;
283
421
  } | {
284
422
  type: "background_agent_completed";
@@ -286,6 +424,15 @@ export type StreamEvent = {
286
424
  name?: string;
287
425
  description: string;
288
426
  status: "completed" | "failed";
427
+ /**
428
+ * What kind of background work this was. Lets UIs localize the
429
+ * completion toast (e.g. a shell shows "命令完成" not the raw English
430
+ * description, which is written for the agent's wakeup notification).
431
+ * Absent for legacy sub-agent notifications (treated as "agent").
432
+ */
433
+ workKind?: "agent" | "shell" | "video" | "cc";
434
+ /** For workKind === "shell": the command that ran (for a friendly label). */
435
+ command?: string;
289
436
  /** Final assistant text (status === "completed" only). */
290
437
  finalText?: string;
291
438
  /** Error message (status === "failed" only). */
@@ -317,6 +464,21 @@ export interface LLMConfig {
317
464
  apiKey?: string;
318
465
  baseUrl?: string;
319
466
  maxTokens?: number;
467
+ /**
468
+ * Shell command whose stdout is the auth token (TODO 7.2). Resolved at
469
+ * client-build time when `apiKey` is absent. The trimmed first line of
470
+ * stdout becomes the bearer token.
471
+ */
472
+ authCommand?: string;
473
+ /**
474
+ * Extra HTTP headers for every request to this model's provider (TODO 7.2).
475
+ * A value `$ENV_VAR` is resolved from the environment at build time.
476
+ */
477
+ httpHeaders?: Record<string, string>;
478
+ /** OpenAI `service_tier` request param, passed through verbatim (TODO 7.2). */
479
+ serviceTier?: string;
480
+ /** OpenAI reasoning `summary` control ("auto"|"concise"|"detailed") (TODO 7.2). */
481
+ reasoningSummary?: string;
320
482
  /**
321
483
  * Default reasoning/thinking setting for this model. Per-call
322
484
  * `options.reasoning` (e.g. summarize sub-calls) overrides this.
@@ -331,6 +493,12 @@ export interface LLMConfig {
331
493
  * ("openai" or "anthropic") that picks which client class to use.
332
494
  */
333
495
  providerKind?: string;
496
+ /**
497
+ * Catalog-driven extra request-body fields (temperature/top_p/thinking etc),
498
+ * already wire-mapped from the connection's paramValues. Merged into the
499
+ * request body, each key filtered by the model's rejectedParams.
500
+ */
501
+ extraBody?: Record<string, unknown>;
334
502
  }
335
503
  /**
336
504
  * ClientDefaults — runtime knobs that apply regardless of which model is
@@ -347,11 +515,16 @@ export interface ClientDefaults {
347
515
  /** Max retry attempts for transient errors. Default 3. */
348
516
  retryMaxAttempts?: number;
349
517
  /**
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.
518
+ * Provider-agnostic image clarity level. Drives the renderer-side
519
+ * downscale (long-edge cap: low→~1024 / standard→~1568 / high→~2576)
520
+ * so BOTH providers save tokens before send. On the OpenAI path it
521
+ * also maps to the wire `detail` hint (low→low, standard/high→high);
522
+ * Anthropic has no such param and saves purely via the downscale.
523
+ * Defaults to "high" (full fidelity) when unset.
524
+ *
525
+ * Legacy "original" values from older settings are migrated to "high".
353
526
  */
354
- imageDetail?: "low" | "high" | "original";
527
+ imageDetail?: "low" | "standard" | "high";
355
528
  }
356
529
  export interface LLMResponse {
357
530
  text: string;
@@ -377,6 +550,28 @@ export interface MCPServerConfig {
377
550
  url?: string;
378
551
  transport?: MCPTransport;
379
552
  headers?: Record<string, string>;
553
+ /**
554
+ * (stdio) NAMES of env vars to forward from the parent process to the
555
+ * spawned server. The value is read from `process.env` at connect time —
556
+ * the secret itself is never stored in config. Explicit `env` overrides.
557
+ */
558
+ envVars?: string[];
559
+ /**
560
+ * (HTTP) NAME of an env var whose value is sent as
561
+ * `Authorization: Bearer <value>`. Read from `process.env` at connect time.
562
+ */
563
+ bearerTokenEnvVar?: string;
564
+ /**
565
+ * (HTTP) Map of header-name → env-var-NAME. Each header's value is read
566
+ * from the named env var at connect time, keeping secrets out of config.
567
+ */
568
+ envHeaders?: Record<string, string>;
569
+ /**
570
+ * (HTTP) id of a stored credential (CredentialStore) to use as the Bearer
571
+ * token. Resolved at connect time via a resolver passed to buildHttpHeaders;
572
+ * the secret is never stored in the MCP config. Wins over bearerTokenEnvVar.
573
+ */
574
+ credentialRef?: string;
380
575
  /**
381
576
  * Toggle a server off without deleting its config (mirrors Codex's
382
577
  * `enabled` field). Absent or `true` → connected; only the literal
@@ -386,6 +581,21 @@ export interface MCPServerConfig {
386
581
  */
387
582
  enabled?: boolean;
388
583
  }
584
+ /**
585
+ * User-supplied supplement for a PLUGIN-provided MCP server, keyed by the
586
+ * server's `<plugin>:<server>` name. Stored globally under
587
+ * `settings.mcpServerOverrides` and layered onto the plugin's config at merge
588
+ * time (see mergePluginMcpServers). Only env/credential fields are allowed —
589
+ * command/args/url/transport stay owned by the plugin manifest so a plugin
590
+ * update is never shadowed by a stale user copy.
591
+ */
592
+ export interface MCPServerOverride {
593
+ env?: Record<string, string>;
594
+ envVars?: string[];
595
+ credentialRef?: string;
596
+ bearerTokenEnvVar?: string;
597
+ envHeaders?: Record<string, string>;
598
+ }
389
599
  /**
390
600
  * Shell-hook configuration entry from settings.json. Each entry binds
391
601
  * a hook event to a shell command. The command runs as a child process
@@ -429,6 +639,7 @@ export interface Settings {
429
639
  maxTokens: number;
430
640
  compactAtRatio: number;
431
641
  summarizeAtRatio: number;
642
+ microcompactFloorRatio: number;
432
643
  };
433
644
  session: {
434
645
  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;
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { homedir } from 'os';
5
5
  import { join } from 'path';
6
+ import { VERTEX_REGION_OVERRIDES } from '../data/model-metadata.js';
6
7
  // Memoize cache for getClaudeConfigHomeDir
7
8
  let _configHomeDirCache = null;
8
9
  let _configHomeDirCacheKey = undefined;
@@ -93,27 +94,8 @@ export function getDefaultVertexRegion() {
93
94
  export function shouldMaintainProjectWorkingDir() {
94
95
  return isEnvTruthy(process.env.CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR);
95
96
  }
96
- /**
97
- * Check if running on Homespace (ant-internal cloud environment).
98
- */
99
- export function isRunningOnHomespace() {
100
- return (process.env.USER_TYPE === 'ant' &&
101
- isEnvTruthy(process.env.COO_RUNNING_ON_HOMESPACE));
102
- }
103
- /**
104
- * Model prefix → env var for Vertex region overrides.
105
- */
106
- const VERTEX_REGION_OVERRIDES = [
107
- ['claude-haiku-4-5', 'VERTEX_REGION_CLAUDE_HAIKU_4_5'],
108
- ['claude-3-5-haiku', 'VERTEX_REGION_CLAUDE_3_5_HAIKU'],
109
- ['claude-3-5-sonnet', 'VERTEX_REGION_CLAUDE_3_5_SONNET'],
110
- ['claude-3-7-sonnet', 'VERTEX_REGION_CLAUDE_3_7_SONNET'],
111
- ['claude-opus-4-1', 'VERTEX_REGION_CLAUDE_4_1_OPUS'],
112
- ['claude-opus-4', 'VERTEX_REGION_CLAUDE_4_0_OPUS'],
113
- ['claude-sonnet-4-6', 'VERTEX_REGION_CLAUDE_4_6_SONNET'],
114
- ['claude-sonnet-4-5', 'VERTEX_REGION_CLAUDE_4_5_SONNET'],
115
- ['claude-sonnet-4', 'VERTEX_REGION_CLAUDE_4_0_SONNET'],
116
- ];
97
+ // VERTEX_REGION_OVERRIDES now lives in data/model-metadata.json (imported above)
98
+ // so adding a model's region env var is a data edit, not a code change.
117
99
  /**
118
100
  * Get the Vertex AI region for a specific model.
119
101
  */
@@ -126,10 +108,3 @@ export function getVertexRegionForModel(model) {
126
108
  }
127
109
  return getDefaultVertexRegion();
128
110
  }
129
- /**
130
- * Stub: Check if running inside a protected namespace.
131
- * Always returns false in Code Shell (Anthropic-internal feature).
132
- */
133
- export function isInProtectedNamespace() {
134
- return false;
135
- }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Cross-platform executable resolution.
3
+ *
4
+ * Node's `child_process.spawn`/`execFile` on Windows do NOT walk PATHEXT for a
5
+ * bare command name unless `shell:true` — so `execFile("git", …)` finds
6
+ * `git.exe` but NOT a `git.cmd`/`gh.cmd` shim (common for tools installed via
7
+ * scoop/npm/chocolatey). On POSIX a bare name in PATH works fine.
8
+ *
9
+ * `resolveExecutable` does an explicit PATH × PATHEXT lookup on Windows and
10
+ * returns the first existing match's absolute path; on POSIX (or when nothing
11
+ * is found) it returns the command unchanged, so callers can always pass the
12
+ * result straight to execFile/spawn.
13
+ */
14
+ /**
15
+ * The names to probe for `command` on the current platform: the bare name on
16
+ * POSIX (or when it already has an extension), plus each PATHEXT variant
17
+ * (command.exe / .cmd / .bat …) on Windows.
18
+ */
19
+ export declare function commandCandidateNames(command: string, env?: NodeJS.ProcessEnv): string[];
20
+ export declare function resolveExecutable(command: string, env?: NodeJS.ProcessEnv): string;
21
+ /** Test seam: drop the resolution cache. */
22
+ export declare function _clearExecutableCache(): void;
23
+ /**
24
+ * Find `command` as a real, runnable executable. Unlike {@link resolveExecutable}
25
+ * (which returns the bare name unchanged when nothing is found, so spawn can
26
+ * surface its own ENOENT), this returns the absolute path if a binary exists or
27
+ * `null` if it genuinely cannot be found — works on POSIX too (probes PATH).
28
+ * Use it to *detect* a missing tool up front (e.g. is git installed?).
29
+ */
30
+ export declare function findExecutable(command: string, env?: NodeJS.ProcessEnv): string | null;
31
+ /** Set (or clear, with null/"") the user-configured git binary path. */
32
+ export declare function setGitPathOverride(path: string | null | undefined): void;
33
+ /**
34
+ * The git command to spawn: the user override if set, else `git` resolved
35
+ * through PATH×PATHEXT. Always returns something spawnable (callers still get
36
+ * a structured spawn-failure if it's wrong).
37
+ */
38
+ export declare function resolveGit(env?: NodeJS.ProcessEnv): string;
39
+ /** Is a usable git binary available (override path, or git on PATH)? */
40
+ export declare function isGitAvailable(env?: NodeJS.ProcessEnv): boolean;