@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
@@ -4,9 +4,11 @@
4
4
  */
5
5
  import { LSPClient } from "./client.js";
6
6
  import { BUILTIN_LSP_SERVERS } from "./servers.js";
7
- import { execSync } from "node:child_process";
7
+ import { accessSync, constants, statSync } from "node:fs";
8
+ import { delimiter, join } from "node:path";
8
9
  import { pathToFileURL } from "node:url";
9
10
  import { rootUriToPath } from "./root-path.js";
11
+ import { commandCandidateNames } from "../utils/exec.js";
10
12
  export class LSPServerManager {
11
13
  servers = new Map();
12
14
  rootUri;
@@ -43,7 +45,7 @@ export class LSPServerManager {
43
45
  if (!managed)
44
46
  return undefined;
45
47
  // Check if command is available
46
- if (!this.isCommandAvailable(managed.config.command)) {
48
+ if (!isCommandAvailable(managed.config.command)) {
47
49
  managed.state = "error";
48
50
  managed.error = `${managed.config.command} not found. Install: ${managed.config.installHint}`;
49
51
  return undefined;
@@ -101,17 +103,45 @@ export class LSPServerManager {
101
103
  server.client = undefined;
102
104
  }
103
105
  }
104
- isCommandAvailable(command) {
105
- try {
106
- execSync(`which ${command} 2>/dev/null || where ${command} 2>nul`, {
107
- encoding: "utf-8",
108
- timeout: 5000,
109
- });
110
- return true;
106
+ }
107
+ export function isCommandAvailable(command, env = process.env) {
108
+ const trimmed = command.trim();
109
+ if (!trimmed)
110
+ return false;
111
+ const hasPathSeparator = trimmed.includes("/") || trimmed.includes("\\");
112
+ // A bare command with whitespace is not executable via spawn(command, args)
113
+ // anyway. Reject it up front so a configured command can never be interpreted
114
+ // as shell syntax such as `pylsp; touch /tmp/pwned`.
115
+ if (!hasPathSeparator && /\s/.test(trimmed))
116
+ return false;
117
+ if (hasPathSeparator) {
118
+ return candidateCommandNames(trimmed, env).some(isExecutableFile);
119
+ }
120
+ for (const dir of (env.PATH ?? "").split(delimiter)) {
121
+ if (!dir)
122
+ continue;
123
+ for (const name of candidateCommandNames(trimmed, env)) {
124
+ if (isExecutableFile(join(dir, name)))
125
+ return true;
111
126
  }
112
- catch {
127
+ }
128
+ return false;
129
+ }
130
+ function candidateCommandNames(command, env) {
131
+ return commandCandidateNames(command, env);
132
+ }
133
+ function isExecutableFile(filePath) {
134
+ try {
135
+ const st = statSync(filePath);
136
+ if (!st.isFile())
113
137
  return false;
138
+ if (process.platform !== "win32") {
139
+ accessSync(filePath, constants.X_OK);
114
140
  }
141
+ return true;
142
+ }
143
+ catch {
144
+ return false;
115
145
  }
116
146
  }
117
147
  // Singleton
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Built-in model catalog (source A) — the official provider templates shipped
3
+ * with the app. Migrated from the renderer's hardcoded ProviderMeta[] arrays
4
+ * (ImageGenConnectionsPanel / VideoGenConnectionsPanel) and enriched with
5
+ * `paramsDoc` + `shape`. See docs/superpowers/specs/2026-06-11-model-catalog-design.md.
6
+ *
7
+ * Adding a same-shaped provider = add a CatalogEntry here (or a user entry in
8
+ * ~/.code-shell/model-catalog.user.json) — no UI / adapter changes, as long as
9
+ * its adapterKind points at an already-wired adapter.
10
+ */
11
+ import type { CatalogEntry } from "./types.js";
12
+ export declare const BUILTIN_CATALOG: CatalogEntry[];
@@ -0,0 +1,407 @@
1
+ /**
2
+ * Built-in model catalog (source A) — the official provider templates shipped
3
+ * with the app. Migrated from the renderer's hardcoded ProviderMeta[] arrays
4
+ * (ImageGenConnectionsPanel / VideoGenConnectionsPanel) and enriched with
5
+ * `paramsDoc` + `shape`. See docs/superpowers/specs/2026-06-11-model-catalog-design.md.
6
+ *
7
+ * Adding a same-shaped provider = add a CatalogEntry here (or a user entry in
8
+ * ~/.code-shell/model-catalog.user.json) — no UI / adapter changes, as long as
9
+ * its adapterKind points at an already-wired adapter.
10
+ */
11
+ import { paramSpecsFromCapability } from "../llm/capabilities/param-specs.js";
12
+ /**
13
+ * Build a text model preset, projecting its params from the capability layer
14
+ * (rules.ts) so reasoning knobs aren't re-hand-written. `params` is omitted
15
+ * when the model has none, matching the "absent → no knobs" contract.
16
+ */
17
+ function textPreset(kind, value, label, ctx) {
18
+ const params = paramSpecsFromCapability(kind, value);
19
+ return {
20
+ value,
21
+ ...(label ? { label } : {}),
22
+ ...(ctx !== undefined ? { maxContextTokens: ctx } : {}),
23
+ ...(params.length > 0 ? { params } : {}),
24
+ };
25
+ }
26
+ /**
27
+ * OpenRouter normalizes reasoning to a unified effort enum across providers
28
+ * (xhigh|high|medium|low|minimal|none). We write OpenRouter presets' params
29
+ * EXPLICITLY (not via paramSpecsFromCapability) because the capability layer's
30
+ * OpenRouter catch-all would slap reasoning onto *every* model — including ones
31
+ * that don't support it. A reasoning OpenRouter preset opts in by listing this.
32
+ */
33
+ const OPENROUTER_REASONING = {
34
+ name: "reasoning",
35
+ label: "思考强度",
36
+ control: "enum",
37
+ options: ["minimal", "low", "medium", "high", "xhigh"],
38
+ default: "medium",
39
+ doc: "Reasoning effort — how hard the model thinks before answering.",
40
+ wire: { field: "reasoning.effort" },
41
+ };
42
+ /**
43
+ * Zhipu GLM params (OpenAI-compatible endpoint, but with GLM-specific wire
44
+ * fields). Promoted from the user catalog after live-verifying glm-5.2 / 5.1 /
45
+ * 5 / 5-turbo / 4.7 / 4.6 against open.bigmodel.cn (2026-06-23). Written
46
+ * explicitly because the capability layer has no GLM rules.
47
+ */
48
+ const ZHIPU_PARAMS = [
49
+ {
50
+ name: "reasoning_effort",
51
+ label: "推理强度",
52
+ control: "enum",
53
+ options: ["max", "xhigh", "high", "medium", "low", "minimal", "none"],
54
+ default: "max",
55
+ doc: "控制模型推理程度;thinking 开启时生效。GLM-5.2 支持,none/minimal 放弃思考,low/medium 映射为 high,xhigh 映射为 max。",
56
+ wire: { field: "reasoning_effort" },
57
+ },
58
+ {
59
+ name: "thinking_type",
60
+ label: "思维链",
61
+ control: "enum",
62
+ options: ["enabled", "disabled"],
63
+ default: "enabled",
64
+ doc: "控制是否开启思维链;GLM-5.2 开启后为强制思考。",
65
+ wire: { field: "thinking.type" },
66
+ },
67
+ {
68
+ name: "temperature",
69
+ label: "Temperature",
70
+ control: "number",
71
+ min: 0,
72
+ max: 1,
73
+ default: 1,
74
+ doc: "采样温度,控制输出随机性,范围 0.0 到 1.0。",
75
+ wire: { field: "temperature" },
76
+ },
77
+ {
78
+ name: "top_p",
79
+ label: "Top P",
80
+ control: "number",
81
+ min: 0.01,
82
+ max: 1,
83
+ default: 0.95,
84
+ doc: "核采样参数,范围 0.01 到 1.0;官方建议不要与 temperature 同时调整。",
85
+ wire: { field: "top_p" },
86
+ },
87
+ {
88
+ name: "max_tokens",
89
+ label: "最大输出 Tokens",
90
+ control: "number",
91
+ min: 1,
92
+ max: 131072,
93
+ default: 4096,
94
+ doc: "模型输出最大 token 数量,GLM-5.2 最大 131072。",
95
+ wire: { field: "max_tokens" },
96
+ },
97
+ ];
98
+ /** Zhipu GLM preset — shared ZHIPU_PARAMS, with per-model context window. */
99
+ function glmPreset(value, label, ctx) {
100
+ return { value, label, maxContextTokens: ctx, params: ZHIPU_PARAMS };
101
+ }
102
+ /** OpenRouter preset with explicit params (no capability-layer projection). */
103
+ function orPreset(value, label, params, ctx) {
104
+ return {
105
+ value,
106
+ label,
107
+ ...(ctx !== undefined ? { maxContextTokens: ctx } : {}),
108
+ ...(params && params.length > 0 ? { params } : {}),
109
+ };
110
+ }
111
+ export const BUILTIN_CATALOG = [
112
+ // ─── text (LLM) ───
113
+ {
114
+ id: "openai",
115
+ tag: "text",
116
+ adapterKind: "openai",
117
+ protocol: "openai-compat",
118
+ displayName: "OpenAI",
119
+ description: "OpenAI chat models (GPT-5 系列、GPT-4o 等)。需要 OpenAI key。",
120
+ defaultBaseUrl: "https://api.openai.com/v1",
121
+ defaultModel: "gpt-5.5",
122
+ signupUrl: "https://platform.openai.com/api-keys",
123
+ needsKey: true,
124
+ // Verified live (2026-06-23) against this account's key: gpt-5.5 / 5.4 /
125
+ // 5.4-mini returned text; o4-mini reachable; o3 reachable (slow). New OpenAI
126
+ // models reject `max_tokens` — must use `max_completion_tokens` (handled by
127
+ // the client). gpt-5.5-pro is 404 on /chat/completions (not a chat model).
128
+ modelPresets: [
129
+ textPreset("openai", "gpt-5.5", "GPT-5.5", 1_050_000),
130
+ textPreset("openai", "gpt-5.4", "GPT-5.4", 1_050_000),
131
+ textPreset("openai", "gpt-5.4-mini", "GPT-5.4 Mini", 400_000),
132
+ textPreset("openai", "gpt-5.4-nano", "GPT-5.4 Nano", 400_000),
133
+ textPreset("openai", "o4-mini", "o4-mini", 200_000),
134
+ textPreset("openai", "o3", "o3", 200_000),
135
+ textPreset("openai", "gpt-4o", "GPT-4o", 128_000),
136
+ textPreset("openai", "gpt-4o-mini", "GPT-4o mini", 128_000),
137
+ ],
138
+ },
139
+ {
140
+ id: "anthropic",
141
+ tag: "text",
142
+ adapterKind: "anthropic",
143
+ protocol: "anthropic-style",
144
+ displayName: "Anthropic",
145
+ description: "Claude 模型(Opus / Sonnet / Haiku)。需要 Anthropic key。",
146
+ defaultBaseUrl: "https://api.anthropic.com/v1",
147
+ defaultModel: "claude-opus-4-8",
148
+ signupUrl: "https://console.anthropic.com/settings/keys",
149
+ needsKey: true,
150
+ modelPresets: [
151
+ textPreset("anthropic", "claude-opus-4-8", "Claude Opus 4.8", 1_000_000),
152
+ textPreset("anthropic", "claude-opus-4-7", "Claude Opus 4.7", 1_000_000),
153
+ textPreset("anthropic", "claude-sonnet-4-6", "Claude Sonnet 4.6", 1_000_000),
154
+ textPreset("anthropic", "claude-haiku-4-5", "Claude Haiku 4.5", 200_000),
155
+ ],
156
+ },
157
+ {
158
+ id: "openrouter",
159
+ tag: "text",
160
+ adapterKind: "openrouter",
161
+ protocol: "openai-compat",
162
+ displayName: "OpenRouter",
163
+ description: "通过 OpenRouter 路由多家模型;统一 reasoning 配置。需要 OpenRouter key。",
164
+ defaultBaseUrl: "https://openrouter.ai/api/v1",
165
+ defaultModel: "~anthropic/claude-opus-latest",
166
+ signupUrl: "https://openrouter.ai/keys",
167
+ needsKey: true,
168
+ // Two kinds of entries per family:
169
+ // - "~vendor/model-latest" router aliases — OpenRouter resolves them
170
+ // server-side to the newest version, so the slug never goes stale (vs.
171
+ // dated slugs like anthropic/claude-opus-4.8-20260528). Verified live
172
+ // 2026-07-02: ~anthropic/claude-opus-latest→opus-4.8,
173
+ // ~anthropic/claude-sonnet-latest→sonnet-5, ~google/gemini-pro-latest→
174
+ // gemini-3.1-pro. (~openai/gpt-latest is NOT a real alias — it 400s —
175
+ // so it's dropped; pin a concrete openai slug instead.)
176
+ // - concrete versioned slugs — so the picker can select a SPECIFIC
177
+ // version (e.g. Opus 4.7-fast) instead of only "latest". Every concrete
178
+ // slug + context window below verified live 2026-07-02 against this
179
+ // account's OpenRouter key.
180
+ // Explicit params (not capability-projected): reasoning models opt into
181
+ // OPENROUTER_REASONING; non-reasoning ones (deepseek-chat V3, llama-4)
182
+ // omit params — no catch-all forcing reasoning onto a model that lacks it.
183
+ modelPresets: [
184
+ // Anthropic (Claude) — alias + concrete versions
185
+ orPreset("~anthropic/claude-opus-latest", "Claude Opus (latest)", [OPENROUTER_REASONING], 1_000_000),
186
+ orPreset("~anthropic/claude-sonnet-latest", "Claude Sonnet (latest)", [OPENROUTER_REASONING], 1_000_000),
187
+ orPreset("anthropic/claude-opus-4.8", "Claude Opus 4.8", [OPENROUTER_REASONING], 1_000_000),
188
+ orPreset("anthropic/claude-opus-4.8-fast", "Claude Opus 4.8 (fast)", [OPENROUTER_REASONING], 1_000_000),
189
+ orPreset("anthropic/claude-opus-4.7", "Claude Opus 4.7", [OPENROUTER_REASONING], 1_000_000),
190
+ orPreset("anthropic/claude-opus-4.7-fast", "Claude Opus 4.7 (fast)", [OPENROUTER_REASONING], 1_000_000),
191
+ orPreset("anthropic/claude-sonnet-5", "Claude Sonnet 5", [OPENROUTER_REASONING], 1_000_000),
192
+ orPreset("anthropic/claude-sonnet-4.6", "Claude Sonnet 4.6", [OPENROUTER_REASONING], 1_000_000),
193
+ orPreset("anthropic/claude-fable-5", "Claude Fable 5", [OPENROUTER_REASONING], 1_000_000),
194
+ // OpenAI (GPT) — concrete only (no working ~latest alias). Led by 5.5 to
195
+ // match the direct-OpenAI default (state.json model = gpt-5.5).
196
+ orPreset("openai/gpt-5.5", "GPT-5.5", [OPENROUTER_REASONING], 1_050_000),
197
+ orPreset("openai/gpt-5.5-pro", "GPT-5.5 Pro", [OPENROUTER_REASONING], 1_050_000),
198
+ orPreset("openai/gpt-5.4", "GPT-5.4", [OPENROUTER_REASONING], 1_050_000),
199
+ orPreset("openai/gpt-5.4-mini", "GPT-5.4 Mini", [OPENROUTER_REASONING], 400_000),
200
+ orPreset("openai/gpt-5.1-codex-max", "GPT-5.1 Codex Max", [OPENROUTER_REASONING], 400_000),
201
+ // Google (Gemini) — alias + concrete
202
+ orPreset("~google/gemini-pro-latest", "Gemini Pro (latest)", [OPENROUTER_REASONING], 1_048_576),
203
+ orPreset("google/gemini-3-flash-preview", "Gemini 3 Flash (preview)", [OPENROUTER_REASONING], 1_048_576),
204
+ orPreset("google/gemini-2.5-pro", "Gemini 2.5 Pro", [OPENROUTER_REASONING], 1_048_576),
205
+ orPreset("google/gemini-2.5-flash", "Gemini 2.5 Flash", [OPENROUTER_REASONING], 1_048_576),
206
+ // xAI (Grok)
207
+ orPreset("x-ai/grok-4.3", "Grok 4.3", [OPENROUTER_REASONING], 1_000_000),
208
+ orPreset("x-ai/grok-4.20", "Grok 4.20", [OPENROUTER_REASONING], 2_000_000),
209
+ // DeepSeek — V4 reasoning + V3 chat (non-reasoning)
210
+ orPreset("deepseek/deepseek-v4-pro", "DeepSeek V4 Pro", [OPENROUTER_REASONING], 1_048_576),
211
+ orPreset("deepseek/deepseek-v4-flash", "DeepSeek V4 Flash", [OPENROUTER_REASONING], 1_048_576),
212
+ orPreset("deepseek/deepseek-chat", "DeepSeek V3 (chat)", undefined, 131_072),
213
+ // Zhipu (GLM) — glm-5.1 (65k ctx) omitted: below the catalog's ≥100k
214
+ // context floor; glm-5.2 (1M) and glm-5 (202k) cover the family.
215
+ orPreset("z-ai/glm-5.2", "GLM 5.2 (Z.ai)", [OPENROUTER_REASONING], 1_048_576),
216
+ orPreset("z-ai/glm-5", "GLM 5 (Z.ai)", [OPENROUTER_REASONING], 202_752),
217
+ // Qwen
218
+ orPreset("qwen/qwen3.7-max", "Qwen3.7 Max", [OPENROUTER_REASONING], 1_000_000),
219
+ orPreset("qwen/qwen3-coder", "Qwen3 Coder", [OPENROUTER_REASONING], 262_144),
220
+ // Meta Llama (non-reasoning)
221
+ orPreset("meta-llama/llama-4-maverick", "Llama 4 Maverick", undefined, 1_048_576),
222
+ orPreset("meta-llama/llama-4-scout", "Llama 4 Scout", undefined, 327_680),
223
+ ],
224
+ },
225
+ {
226
+ id: "deepseek",
227
+ tag: "text",
228
+ adapterKind: "deepseek",
229
+ protocol: "openai-compat",
230
+ displayName: "DeepSeek",
231
+ description: "DeepSeek 模型。需要 DeepSeek key。",
232
+ defaultBaseUrl: "https://api.deepseek.com/v1",
233
+ defaultModel: "deepseek-v4-flash",
234
+ signupUrl: "https://platform.deepseek.com/api_keys",
235
+ needsKey: true,
236
+ modelPresets: [
237
+ textPreset("deepseek", "deepseek-v4-flash", "DeepSeek V4 Flash", 1_000_000),
238
+ textPreset("deepseek", "deepseek-v4-pro", "DeepSeek V4 Pro", 1_000_000),
239
+ ],
240
+ },
241
+ {
242
+ id: "zhipu",
243
+ tag: "text",
244
+ adapterKind: "openai",
245
+ protocol: "openai-compat",
246
+ displayName: "Zhipu GLM",
247
+ description: "智谱 GLM 系列(OpenAI 兼容端点)。适合 Coding Agent 与长上下文任务。需要智谱 key。",
248
+ defaultBaseUrl: "https://open.bigmodel.cn/api/paas/v4",
249
+ defaultModel: "glm-5.2",
250
+ signupUrl: "https://open.bigmodel.cn/",
251
+ needsKey: true,
252
+ // All slugs verified live (2026-06-23) against open.bigmodel.cn: glm-5.2 /
253
+ // 5.1 / 5 / 5-turbo / 4.7 / 4.6 each returned a successful chat completion.
254
+ modelPresets: [
255
+ glmPreset("glm-5.2", "GLM-5.2", 1_000_000),
256
+ glmPreset("glm-5.1", "GLM-5.1", 1_000_000),
257
+ glmPreset("glm-5", "GLM-5", 1_000_000),
258
+ glmPreset("glm-5-turbo", "GLM-5 Turbo", 1_000_000),
259
+ glmPreset("glm-4.7", "GLM-4.7", 200_000),
260
+ glmPreset("glm-4.6", "GLM-4.6", 200_000),
261
+ ],
262
+ },
263
+ {
264
+ id: "google",
265
+ tag: "text",
266
+ adapterKind: "google",
267
+ protocol: "openai-compat",
268
+ displayName: "Google Gemini",
269
+ description: "Gemini 文本模型(OpenAI-compat 端点)。需要 Google key。",
270
+ defaultBaseUrl: "https://generativelanguage.googleapis.com/v1beta/openai",
271
+ defaultModel: "gemini-3.5-flash",
272
+ signupUrl: "https://aistudio.google.com/apikey",
273
+ needsKey: true,
274
+ modelPresets: [
275
+ textPreset("google", "gemini-3.5-flash", "Gemini 3.5 Flash", 1_048_576),
276
+ textPreset("google", "gemini-3.1-flash-lite", "Gemini 3.1 Flash Lite", 1_048_576),
277
+ textPreset("google", "gemini-2.5-pro", "Gemini 2.5 Pro", 1_048_576),
278
+ textPreset("google", "gemini-2.5-flash", "Gemini 2.5 Flash", 1_048_576),
279
+ ],
280
+ },
281
+ {
282
+ id: "ollama",
283
+ tag: "text",
284
+ adapterKind: "ollama",
285
+ protocol: "openai-compat",
286
+ displayName: "Ollama",
287
+ description: "本地 Ollama 模型,无需 key。",
288
+ defaultBaseUrl: "http://localhost:11434/v1",
289
+ defaultModel: "llama3.1",
290
+ needsKey: false,
291
+ modelPresets: [
292
+ textPreset("ollama", "llama3.1", "Llama 3.1"),
293
+ textPreset("ollama", "qwen2.5-coder", "Qwen Coder"),
294
+ textPreset("ollama", "deepseek-r1", "DeepSeek R1"),
295
+ ],
296
+ },
297
+ {
298
+ id: "custom",
299
+ tag: "text",
300
+ adapterKind: "openai",
301
+ protocol: "openai-compat",
302
+ displayName: "Custom (OpenAI-compatible)",
303
+ description: "任意 OpenAI 兼容端点;baseUrl/model 由连接自带。",
304
+ defaultBaseUrl: "",
305
+ needsKey: true,
306
+ modelPresets: [],
307
+ },
308
+ // ─── image ───
309
+ {
310
+ id: "openai-images",
311
+ tag: "image",
312
+ adapterKind: "openai",
313
+ shape: "generic-sync",
314
+ displayName: "OpenAI Images (gpt-image)",
315
+ description: "OpenAI 图像 API。需要 OpenAI key;baseUrl 默认官方端点。",
316
+ defaultBaseUrl: "https://api.openai.com/v1",
317
+ defaultModel: "gpt-image-2",
318
+ // Live-verified 2026-07-02 against this account's OpenAI key (GET /v1/models):
319
+ // gpt-image-2 (current), gpt-image-1.5, gpt-image-1, gpt-image-1-mini.
320
+ modelPresets: [
321
+ { value: "gpt-image-2", label: "GPT Image 2" },
322
+ { value: "gpt-image-1.5", label: "GPT Image 1.5" },
323
+ { value: "gpt-image-1", label: "GPT Image 1" },
324
+ { value: "gpt-image-1-mini", label: "GPT Image 1 mini" },
325
+ ],
326
+ signupUrl: "https://platform.openai.com/api-keys",
327
+ test: true,
328
+ paramsDoc: "OpenAI 图像:支持 size (1024x1024 | 1536x1024 | 1024x1536 | auto)、quality (low | medium | high | auto)。" +
329
+ "支持图生图:传 referenceImages(工作区图片路径,最多 16 张)即按这些图编辑/再创作(走 /images/edits)。",
330
+ },
331
+ {
332
+ id: "google-images",
333
+ tag: "image",
334
+ adapterKind: "google",
335
+ shape: "generic-sync",
336
+ displayName: "Gemini Images (Nano Banana)",
337
+ description: "Gemini 图像生成。可直接用你已有的 Google key;OpenAI 兼容 baseUrl(/v1beta/openai)也会被自动规范到原生端点。",
338
+ defaultBaseUrl: "https://generativelanguage.googleapis.com/v1beta",
339
+ defaultModel: "gemini-3.1-flash-image",
340
+ modelPresets: [
341
+ { value: "gemini-3.1-flash-image", label: "Nano Banana 2 (3.1)" },
342
+ { value: "gemini-2.5-flash-image", label: "Nano Banana (2.5)" },
343
+ ],
344
+ signupUrl: "https://aistudio.google.com/apikey",
345
+ test: true,
346
+ paramsDoc: "Gemini 图像 (Nano Banana):size 会被映射到最接近的支持比例;quality 参数对该后端无效(忽略)。" +
347
+ "支持图生图/多图融合:传 referenceImages(工作区图片路径)作为参考图一起喂给模型。",
348
+ },
349
+ // ─── video ───
350
+ {
351
+ id: "fal-video",
352
+ tag: "video",
353
+ adapterKind: "fal",
354
+ shape: "fal-queue",
355
+ displayName: "fal.ai (Kling / 即梦 Seedance 等)",
356
+ description: "通过 fal.ai 统一 API 调用 Kling、即梦(Seedance,字节同源)等视频模型。需要 fal key;" +
357
+ "「默认模型」决定底层模型与文生/图生(传图自动切图生)。即梦 = fal 上的 bytedance/seedance 模型,选它即可。",
358
+ defaultBaseUrl: "https://queue.fal.run",
359
+ defaultModel: "fal-ai/kling-video/v3/pro/text-to-video",
360
+ signupUrl: "https://fal.ai/dashboard/keys",
361
+ test: false,
362
+ modelPresets: [
363
+ { value: "bytedance/seedance-2.0/text-to-video", label: "即梦 Seedance 2.0 · 文生视频" },
364
+ { value: "bytedance/seedance-2.0/image-to-video", label: "即梦 Seedance 2.0 · 图生视频" },
365
+ { value: "fal-ai/kling-video/v3/pro/text-to-video", label: "Kling v3 Pro · 文生视频" },
366
+ { value: "fal-ai/kling-video/v3/pro/image-to-video", label: "Kling v3 Pro · 图生视频" },
367
+ ],
368
+ paramsDoc: "fal 视频:用 model 选底层模型(文生 vs 图生)。传 image/images(本地路径自动上传)→ 用图生视频模型;1 张=图生视频,2+ 张=参考生视频(最多 9,prompt 里用 @Image1/@Image2 引用)。" +
369
+ "续接/参考视频:传 videos(http/https URL,非本地路径;最多 3)续接已有视频,prompt 里用 @Video1/@Video2 引用(如「从 @Video1 结尾继续」);需用 Seedance 模型(走 reference-to-video,Kling 不支持)。异步后台生成。",
370
+ },
371
+ // ─── audio (speech-to-text / 语音输入听写) ───
372
+ {
373
+ id: "openai-transcribe",
374
+ tag: "audio",
375
+ adapterKind: "openai",
376
+ shape: "generic-sync",
377
+ displayName: "OpenAI 语音转写 (Whisper / gpt-4o-transcribe)",
378
+ description: "OpenAI 兼容 /audio/transcriptions,用于语音输入听写。可复用 OpenAI key。",
379
+ defaultBaseUrl: "https://api.openai.com/v1",
380
+ defaultModel: "gpt-4o-transcribe",
381
+ signupUrl: "https://platform.openai.com/api-keys",
382
+ test: false,
383
+ modelPresets: [
384
+ { value: "gpt-4o-transcribe", label: "gpt-4o-transcribe" },
385
+ { value: "gpt-4o-mini-transcribe", label: "gpt-4o-mini-transcribe" },
386
+ { value: "whisper-1", label: "Whisper (whisper-1)" },
387
+ ],
388
+ paramsDoc: "语音转写:录音(webm/opus)→ 文字,填进输入框。换 baseUrl+model 可指向 Groq/本地 whisper.cpp。",
389
+ },
390
+ {
391
+ id: "groq-transcribe",
392
+ tag: "audio",
393
+ adapterKind: "openai",
394
+ shape: "generic-sync",
395
+ displayName: "Groq 语音转写 (whisper-large-v3-turbo)",
396
+ description: "Groq 的 OpenAI 兼容 /audio/transcriptions,极快且便宜。需要 Groq key。",
397
+ defaultBaseUrl: "https://api.groq.com/openai/v1",
398
+ defaultModel: "whisper-large-v3-turbo",
399
+ signupUrl: "https://console.groq.com/keys",
400
+ test: false,
401
+ modelPresets: [
402
+ { value: "whisper-large-v3-turbo", label: "whisper-large-v3-turbo" },
403
+ { value: "whisper-large-v3", label: "whisper-large-v3" },
404
+ ],
405
+ paramsDoc: "语音转写(Groq):同 OpenAI /audio/transcriptions 形状,换 baseUrl+model。",
406
+ },
407
+ ];
@@ -0,0 +1,20 @@
1
+ /**
2
+ * genInstancesFromConnections — bridge unified modelConnections (tag=image or
3
+ * video) + credentials into the GenInstance shape the image/video runtime
4
+ * resolvers (resolveImageProvider / resolveVideoProvider) consume. Lets
5
+ * image/video flow through the unified credentials store; key comes from the
6
+ * referenced credential. Connections whose catalogId doesn't resolve are
7
+ * skipped. See docs/.../2026-06-15-unified-model-catalog-design.md §6.
8
+ */
9
+ import { type ModelInstance, type Credential } from "./resolve.js";
10
+ import type { CatalogEntry } from "./index.js";
11
+ /** The shape image/video resolvers expect (mirrors generate-image GenInstance). */
12
+ export interface GenRuntimeInstance {
13
+ id: string;
14
+ kind: string;
15
+ baseUrl: string;
16
+ apiKey?: string;
17
+ defaultModel?: string;
18
+ catalogId: string;
19
+ }
20
+ export declare function genInstancesFromConnections(connections: ModelInstance[], credentials: Credential[], catalog: CatalogEntry[], tag: "image" | "video" | "audio"): GenRuntimeInstance[];
@@ -0,0 +1,28 @@
1
+ /**
2
+ * genInstancesFromConnections — bridge unified modelConnections (tag=image or
3
+ * video) + credentials into the GenInstance shape the image/video runtime
4
+ * resolvers (resolveImageProvider / resolveVideoProvider) consume. Lets
5
+ * image/video flow through the unified credentials store; key comes from the
6
+ * referenced credential. Connections whose catalogId doesn't resolve are
7
+ * skipped. See docs/.../2026-06-15-unified-model-catalog-design.md §6.
8
+ */
9
+ import { resolveInstance } from "./resolve.js";
10
+ export function genInstancesFromConnections(connections, credentials, catalog, tag) {
11
+ const out = [];
12
+ for (const inst of connections) {
13
+ if (inst.tag !== tag)
14
+ continue;
15
+ const resolved = resolveInstance(inst, credentials, catalog);
16
+ if (!resolved)
17
+ continue;
18
+ out.push({
19
+ id: inst.id,
20
+ kind: resolved.adapterKind,
21
+ baseUrl: resolved.baseUrl,
22
+ ...(resolved.apiKey !== undefined ? { apiKey: resolved.apiKey } : {}),
23
+ defaultModel: inst.model || resolved.entry.defaultModel,
24
+ catalogId: inst.catalogId,
25
+ });
26
+ }
27
+ return out;
28
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Model catalog assembly — merge built-in (A) + user (B) templates.
3
+ *
4
+ * - A: {@link BUILTIN_CATALOG} (ships with the app).
5
+ * - B: ~/.code-shell/model-catalog.user.json (user-added templates).
6
+ * - merge: union by `id`; same id → user B wins (so升级 doesn't clobber the
7
+ * user's overrides/additions).
8
+ *
9
+ * No remote source this version (design doc §5).
10
+ */
11
+ import { type CatalogEntry } from "./types.js";
12
+ export type { CatalogEntry } from "./types.js";
13
+ export { BUILTIN_CATALOG } from "./builtin.js";
14
+ export { saveCatalogEntry, deleteUserCatalogEntry } from "./save-entry.js";
15
+ /** Path to the user catalog file (source B). */
16
+ export declare function userCatalogPath(): string;
17
+ /**
18
+ * Load user-defined catalog entries (source B). Returns [] when the file is
19
+ * absent or invalid — a bad user file must never break the built-in catalog.
20
+ */
21
+ export declare function loadUserCatalog(): CatalogEntry[];
22
+ /**
23
+ * Merged catalog: built-in (A) ∪ user (B), deduped by `id` with user winning.
24
+ * This is the single source the 连接 page renders from and the tool-description
25
+ * injector looks up `paramsDoc` in.
26
+ */
27
+ export declare function getMergedCatalog(): CatalogEntry[];
28
+ /**
29
+ * Look up a catalog entry by id (e.g. an instance's `catalogId`), falling back
30
+ * to the first entry whose `adapterKind` matches `kindFallback`. Since an
31
+ * adapterKind (e.g. "openai") can now back both a text and an image entry,
32
+ * `tagFallback` disambiguates the fallback to the right group.
33
+ */
34
+ export declare function findCatalogEntry(catalog: CatalogEntry[], id: string | undefined, kindFallback?: string, tagFallback?: CatalogEntry["tag"]): CatalogEntry | undefined;
35
+ export type CatalogEntryOrigin = "builtin" | "user" | "user-override-of-builtin";
36
+ /**
37
+ * Per-id provenance of the merged catalog: pure built-in, pure user-added, or a
38
+ * user override of a built-in. Lets the editor UI show 编辑/删除/重置 correctly
39
+ * (only an override can be "reset"; only a user-only entry can be truly deleted).
40
+ */
41
+ export declare function catalogEntryOrigins(): Record<string, CatalogEntryOrigin>;