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

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,205 @@
1
+ /**
2
+ * UseCredential 工具(凭证模块第二期 §3-§5)。
3
+ *
4
+ * 对 AI 暴露**一个统一工具**取用已存凭证(token / link / cookie 同构,描述只说「凭证」)。
5
+ * - 无 `id` → 返回脱敏清单(权威实时源,兜底动态描述的滞后)。
6
+ * - 有 `id` → 过 CredentialUseGate(默认问 / 本会话记住 / 全自动)后:
7
+ * - token/link → `{ kind: "value", value }`
8
+ * - cookie → 就地写临时 cookies.txt(0600),返回 `{ kind: "cookie", cookiesFile, count }`
9
+ *
10
+ * 取值全部 core 直读 CredentialStore(cookie 值第二期已进库),无跨进程。
11
+ * 集中在 core/src/credentials/ 下,只经 ToolDefinition 注册 + ToolContext.askUser 耦合 core,
12
+ * 满足设计稿 §1「可整块外移」约束。
13
+ */
14
+ import { writeFileSync, existsSync, readdirSync, statSync, rmSync } from "node:fs";
15
+ import { join } from "node:path";
16
+ import { tmpdir } from "node:os";
17
+ import { randomUUID } from "node:crypto";
18
+ import { CredentialStore } from "./store.js";
19
+ import { formatNetscapeCookies, parseCookieJar } from "./cookie-jar.js";
20
+ import { credentialUseGate, } from "./use-gate.js";
21
+ import { SettingsManager } from "../settings/manager.js";
22
+ import { logger } from "../logging/logger.js";
23
+ const TOOL_NAME = "UseCredential";
24
+ const COOKIE_FILE_PREFIX = "codeshell-cred-cookie-";
25
+ const COOKIE_FILE_MAX_AGE_MS = 30 * 60 * 1000; // 30min 启动 sweep 上限
26
+ const BASE_DESCRIPTION = "Use a stored credential (token / API key / login cookie) to run a command. " +
27
+ "Call with NO arguments first to list available credentials (id + label + type); " +
28
+ "then call again with `id` to fetch one. Token/link credentials return their secret " +
29
+ "value; cookie credentials are materialized to a temporary Netscape cookies.txt file " +
30
+ "(use it as `yt-dlp --cookies <cookiesFile>` / `curl -b <cookiesFile>`). " +
31
+ "Each use is gated by a quick user approval unless auto-approve is on.";
32
+ export const useCredentialToolDef = {
33
+ name: TOOL_NAME,
34
+ description: BASE_DESCRIPTION,
35
+ inputSchema: {
36
+ type: "object",
37
+ properties: {
38
+ id: {
39
+ type: "string",
40
+ description: "Credential id to fetch. Omit to list all available credentials.",
41
+ },
42
+ purpose: {
43
+ type: "string",
44
+ description: "Short reason you need it (shown in the approval prompt).",
45
+ },
46
+ },
47
+ },
48
+ };
49
+ /**
50
+ * 动态描述:在基础描述末尾附当前可用凭证清单(镜像 generateVideoToolDefFor)。
51
+ * 空时回退基础描述。AI 一搜出/一看到就知道有哪些可用,减少无谓的无参列举调用。
52
+ */
53
+ export function useCredentialToolDefFor(cwd) {
54
+ try {
55
+ const list = new CredentialStore(cwd).listMasked();
56
+ if (list.length === 0)
57
+ return useCredentialToolDef;
58
+ const names = list.map((c) => `${c.id} (${c.type})`).join(", ");
59
+ return {
60
+ ...useCredentialToolDef,
61
+ description: `${BASE_DESCRIPTION}\nCurrently available: ${names}.`,
62
+ };
63
+ }
64
+ catch {
65
+ return useCredentialToolDef;
66
+ }
67
+ }
68
+ /**
69
+ * 启动期清理上次遗留的临时 cookies.txt(沿用 sweepStaleLeases 思路:扫同目录、按 mtime)。
70
+ * 不引入 lease 对象/定时器 —— 文件用完靠进程退出 + 这个轻量 sweep。
71
+ */
72
+ export function sweepStaleCredentialCookies(now = Date.now()) {
73
+ const dir = tmpdir();
74
+ try {
75
+ if (!existsSync(dir))
76
+ return;
77
+ for (const f of readdirSync(dir)) {
78
+ if (!f.startsWith(COOKIE_FILE_PREFIX))
79
+ continue;
80
+ const p = join(dir, f);
81
+ try {
82
+ if (now - statSync(p).mtimeMs > COOKIE_FILE_MAX_AGE_MS)
83
+ rmSync(p, { force: true });
84
+ }
85
+ catch {
86
+ /* skip */
87
+ }
88
+ }
89
+ }
90
+ catch {
91
+ /* best-effort */
92
+ }
93
+ }
94
+ /** 内存会话 allow 集:每个 Engine 一份(从 ctx.sessionId 键)。纯内存,关进程即忘。 */
95
+ const sessionAllowByEngine = new Map();
96
+ function sessionAllowFor(ctx) {
97
+ // 无 sessionId(headless / 临时 ToolContext / 某些子代理)绝不能共享一个
98
+ // 全局 "__nosession__" 桶 —— 否则一个上下文里「本会话记住」的批准会被
99
+ // 任意其它无 sessionId 的上下文复用,造成跨会话凭证串台。这种情况下返回
100
+ // 一个一次性 Set(不入 map):取用本身正常,但「记住」对它失效,每次重新过门。
101
+ if (!ctx?.sessionId)
102
+ return new Set();
103
+ const key = ctx.sessionId;
104
+ let set = sessionAllowByEngine.get(key);
105
+ if (!set) {
106
+ set = new Set();
107
+ sessionAllowByEngine.set(key, set);
108
+ }
109
+ return set;
110
+ }
111
+ // CredentialStore only distinguishes "full" (user+project) from "project"
112
+ // (project-only). An "isolated" engine is at least as restrictive as project,
113
+ // so it maps to "project" — it must never read the host user's ~/.code-shell.
114
+ function credentialScope(scope) {
115
+ return scope === "full" || scope === undefined ? "full" : "project";
116
+ }
117
+ function readAutoApprove(cwd, scope) {
118
+ try {
119
+ // A project/isolated engine must read autoApprove from its own scope, not
120
+ // the host user's ~/.code-shell — otherwise a host `credentialUse.autoApprove`
121
+ // would silently auto-approve credential use inside an isolated engine.
122
+ const s = new SettingsManager(cwd, scope === "full" ? "full" : "project").get();
123
+ return s.credentialUse?.autoApprove === true;
124
+ }
125
+ catch {
126
+ return false;
127
+ }
128
+ }
129
+ export async function useCredentialTool(args, ctx) {
130
+ const cwd = ctx?.cwd ?? process.cwd();
131
+ const store = new CredentialStore(cwd);
132
+ const scope = credentialScope(ctx?.settingsScope);
133
+ const id = typeof args.id === "string" ? args.id.trim() : "";
134
+ const purpose = typeof args.purpose === "string" ? args.purpose : undefined;
135
+ // 无 id → 清单(脱敏,权威实时源)。按 engine scope 过滤:project/isolated
136
+ // 引擎不得列出宿主 user 层凭证。
137
+ if (!id) {
138
+ const credentials = store
139
+ .listMasked(scope)
140
+ .map((c) => ({ id: c.id, label: c.label, type: c.type }));
141
+ return json({ kind: "list", credentials });
142
+ }
143
+ const cred = store.resolve(id, scope);
144
+ if (!cred) {
145
+ return json({ kind: "error", error: `凭证不存在: "${id}"。调用本工具(无参)可列出可用凭证。` });
146
+ }
147
+ // 取值前过门
148
+ const ask = ctx?.askUser
149
+ ? (q, opts) => ctx.askUser(q, opts)
150
+ : undefined;
151
+ const decision = await credentialUseGate({ id: cred.id, label: cred.label, purpose }, {
152
+ autoApprove: readAutoApprove(cwd, scope),
153
+ credentialAutoUse: cred.autoUseByAI === true,
154
+ sessionAllow: sessionAllowFor(ctx),
155
+ ask,
156
+ });
157
+ if (!decision.allowed) {
158
+ const msg = decision.reason === "no-ui"
159
+ ? "无法取用凭证:当前无审批 UI(headless),且未开启 credentialUse.autoApprove。"
160
+ : `用户拒绝取用凭证「${cred.label}」。可回退 yt-dlp --cookies-from-browser 或提示用户。`;
161
+ return json({ kind: "error", error: msg });
162
+ }
163
+ // token/link → 直接返回值
164
+ if (cred.type === "token" || cred.type === "link") {
165
+ if (!cred.secret)
166
+ return json({ kind: "error", error: `凭证「${cred.label}」没有可用的值。` });
167
+ return json({ kind: "value", value: cred.secret });
168
+ }
169
+ // cookie → 就地写临时 cookies.txt
170
+ if (cred.type === "cookie") {
171
+ const jar = parseCookieJar(cred.secret);
172
+ if (jar.length === 0) {
173
+ return json({
174
+ kind: "error",
175
+ error: `凭证「${cred.label}」的 cookie 为空或已失效,请在凭证页对该账号点「重拓」(重新登录后重新拓取)。`,
176
+ });
177
+ }
178
+ // Unique per write: id + pid alone collides when two concurrent UseCredential
179
+ // calls (the tool is concurrency-safe) materialize the same credential in the
180
+ // same process — the second write would clobber the first and a caller could
181
+ // read another account's cookies. A random component makes each file distinct.
182
+ // Prefix is unchanged so the 30-min startup sweep still matches & cleans them.
183
+ const file = join(tmpdir(), `${COOKIE_FILE_PREFIX}${safe(cred.id)}-${process.pid}-${randomUUID()}.txt`);
184
+ try {
185
+ writeFileSync(file, formatNetscapeCookies(jar), { mode: 0o600 });
186
+ }
187
+ catch (e) {
188
+ logger.warn(`UseCredential: failed to write cookies.txt: ${String(e)}`);
189
+ return json({ kind: "error", error: `写临时 cookie 文件失败: ${String(e)}` });
190
+ }
191
+ return json({ kind: "cookie", cookiesFile: file, count: jar.length });
192
+ }
193
+ return json({ kind: "error", error: `未知凭证类型: ${cred.type}` });
194
+ }
195
+ /** 文件名安全化(凭证 id 用了 `__`,这里只挡路径分隔符/控制字符)。 */
196
+ function safe(s) {
197
+ return s.replace(/[^a-zA-Z0-9_.-]/g, "_");
198
+ }
199
+ function json(r) {
200
+ return JSON.stringify(r);
201
+ }
202
+ /** 测试钩子:清空会话 allow 集(避免跨用例污染)。 */
203
+ export function __resetCredentialSessionAllowForTests() {
204
+ sessionAllowByEngine.clear();
205
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * CredentialUseGate — 凭证取用前的轻量三档审批(凭证模块第二期 §5)。
3
+ *
4
+ * AI 的 `UseCredential` 工具在把某条凭证的值/cookies.txt 交给命令**之前**过这道门:
5
+ * 1. **全自动**:settings `credentialUse.autoApprove === true` → 直接放行,不弹。
6
+ * 2. **本会话记住**:用户上次选了「本会话记住」→ 该凭证 id 进内存 allow 集 → 后续放行。
7
+ * 3. **默认弹审批**:经 `askUser`(InteractiveApprovalBackend)问一次。
8
+ *
9
+ * 关键决策(见设计稿 §5 + memory project_permission_session_cache):
10
+ * - 本会话记住**按凭证 id 键**,不按工具名 —— 否则一次批准会放行对无关凭证的取用。
11
+ * - 会话 allow 集是**纯内存**(关 app 即忘),由 Engine 持有并注入,故 gate 本身无模块级单例,
12
+ * 多 Engine 并发互不干扰、可整块外移。
13
+ *
14
+ * 边界:gate 只依赖 `askUser`(既有审批后端)+ 一个内存 Set + settings 读取,不耦合 core 其它部分。
15
+ */
16
+ /** AI 取用一条凭证的请求(供审批文案 + 记忆键)。 */
17
+ export interface CredentialUseRequest {
18
+ /** 凭证 id(记忆键)。 */
19
+ id: string;
20
+ /** 展示名(审批文案)。 */
21
+ label: string;
22
+ /** 可选用途(审批文案)。 */
23
+ purpose?: string;
24
+ }
25
+ export type CredentialUseDecision = {
26
+ allowed: true;
27
+ } | {
28
+ allowed: false;
29
+ reason: "denied" | "no-ui";
30
+ };
31
+ /** 本会话已批准的凭证 id 集(纯内存,Engine 持有并跨 turn 复用)。 */
32
+ export type SessionCredentialAllow = Set<string>;
33
+ /** 审批问询函数(对接 ToolContext.askUser;返回用户所选 label)。 */
34
+ export type CredentialAskFn = (question: string, opts: {
35
+ header?: string;
36
+ options: {
37
+ label: string;
38
+ description: string;
39
+ tone?: "ok" | "danger" | "neutral";
40
+ }[];
41
+ optionsOnly: true;
42
+ }) => Promise<string>;
43
+ export interface CredentialUseGateDeps {
44
+ /** settings `credentialUse.autoApprove`(全局总闸)。 */
45
+ autoApprove: boolean;
46
+ /** 该凭证自身的逐条「AI 可自动取用」标志(Credential.autoUseByAI);命中即放行。 */
47
+ credentialAutoUse?: boolean;
48
+ /** 本会话 allow 集(内存,可变;gate 命中「本会话记住」时写入)。 */
49
+ sessionAllow: SessionCredentialAllow;
50
+ /** 审批问询(undefined → 无 UI,headless 直接拒)。 */
51
+ ask?: CredentialAskFn;
52
+ }
53
+ /**
54
+ * 过门并返回是否放行。命中「本会话记住」会写入 `deps.sessionAllow`。
55
+ */
56
+ export declare function credentialUseGate(req: CredentialUseRequest, deps: CredentialUseGateDeps): Promise<CredentialUseDecision>;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * CredentialUseGate — 凭证取用前的轻量三档审批(凭证模块第二期 §5)。
3
+ *
4
+ * AI 的 `UseCredential` 工具在把某条凭证的值/cookies.txt 交给命令**之前**过这道门:
5
+ * 1. **全自动**:settings `credentialUse.autoApprove === true` → 直接放行,不弹。
6
+ * 2. **本会话记住**:用户上次选了「本会话记住」→ 该凭证 id 进内存 allow 集 → 后续放行。
7
+ * 3. **默认弹审批**:经 `askUser`(InteractiveApprovalBackend)问一次。
8
+ *
9
+ * 关键决策(见设计稿 §5 + memory project_permission_session_cache):
10
+ * - 本会话记住**按凭证 id 键**,不按工具名 —— 否则一次批准会放行对无关凭证的取用。
11
+ * - 会话 allow 集是**纯内存**(关 app 即忘),由 Engine 持有并注入,故 gate 本身无模块级单例,
12
+ * 多 Engine 并发互不干扰、可整块外移。
13
+ *
14
+ * 边界:gate 只依赖 `askUser`(既有审批后端)+ 一个内存 Set + settings 读取,不耦合 core 其它部分。
15
+ */
16
+ const ALLOW_ONCE = "允许本次";
17
+ const ALLOW_SESSION = "本会话都允许";
18
+ const DENY = "拒绝";
19
+ /**
20
+ * 过门并返回是否放行。命中「本会话记住」会写入 `deps.sessionAllow`。
21
+ */
22
+ export async function credentialUseGate(req, deps) {
23
+ // 1. 全自动(全局总闸,或该凭证逐条开了「AI 可自动取用」)
24
+ if (deps.autoApprove || deps.credentialAutoUse)
25
+ return { allowed: true };
26
+ // 2. 本会话记住
27
+ if (deps.sessionAllow.has(req.id))
28
+ return { allowed: true };
29
+ // 3. 默认弹审批
30
+ if (!deps.ask)
31
+ return { allowed: false, reason: "no-ui" };
32
+ const purpose = req.purpose?.trim();
33
+ const question = purpose
34
+ ? `AI 想用凭证「${req.label}」(${purpose}),是否允许?`
35
+ : `AI 想用凭证「${req.label}」,是否允许?`;
36
+ const choice = await deps.ask(question, {
37
+ header: "凭证取用",
38
+ options: [
39
+ { label: ALLOW_ONCE, description: "仅本次取用该凭证", tone: "ok" },
40
+ { label: ALLOW_SESSION, description: "本会话内该凭证不再询问(关 app 后失效)", tone: "ok" },
41
+ { label: DENY, description: "拒绝本次取用", tone: "danger" },
42
+ ],
43
+ optionsOnly: true,
44
+ });
45
+ if (choice === ALLOW_SESSION) {
46
+ deps.sessionAllow.add(req.id);
47
+ return { allowed: true };
48
+ }
49
+ if (choice === ALLOW_ONCE)
50
+ return { allowed: true };
51
+ return { allowed: false, reason: "denied" };
52
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Hand-maintained model metadata for direct-provider models and onboarding
3
+ * picker tuning, extracted out of onboarding.ts so updating a model's
4
+ * max-output / context-window or the picker vendor list is a data edit
5
+ * (model-metadata.json) rather than a code change.
6
+ *
7
+ * Scope: only what the build-time OpenRouter snapshot does NOT cover —
8
+ * direct-provider ids (no "vendor/" prefix) for the metadata tables, plus the
9
+ * curated OpenRouter vendor ordering for the picker. OpenRouter "vendor/model"
10
+ * ids get their context/max-output from the snapshot (see data/openrouter-*).
11
+ *
12
+ * Loaded with createRequire so the bundled JSON ships in dist (the build copies
13
+ * src/data/*.json → dist/data/), matching static-catalogs.ts.
14
+ */
15
+ export interface OpenRouterVendor {
16
+ prefix: string;
17
+ take: number;
18
+ }
19
+ /** Per-1M-token pricing (USD). Mirrors cost-tracker's ModelPricing. */
20
+ export interface ModelPricing {
21
+ input: number;
22
+ output: number;
23
+ cacheRead: number;
24
+ cacheWrite: number;
25
+ }
26
+ /**
27
+ * Onboarding provider catalog entry. Pure data — the onboarding flow's logic
28
+ * (key validation, model registration, env detection) lives in onboarding.ts
29
+ * and consumes this shape. Lives here so the catalog is a data edit.
30
+ */
31
+ export interface ProviderDef {
32
+ id: string;
33
+ name: string;
34
+ envKey: string;
35
+ provider: string;
36
+ baseUrl: string;
37
+ keyUrl: string;
38
+ keyPrefix: string;
39
+ /**
40
+ * The catalog of model IDs to register for this provider. The first entry
41
+ * doubles as the zero-config default — auto-activated when the user boots
42
+ * with just an env key (no onboarding). Users override in the wizard or via
43
+ * `/model`.
44
+ */
45
+ models: string[];
46
+ /** When true, skip API key prompt (e.g. local providers like Ollama). */
47
+ noKey?: boolean;
48
+ }
49
+ /** Known max output tokens for direct-provider models (id → tokens). */
50
+ export declare const KNOWN_MAX_OUTPUT: Record<string, number>;
51
+ /** Known context window sizes for direct-provider models (id → tokens). */
52
+ export declare const KNOWN_CONTEXT_WINDOWS: Record<string, number>;
53
+ /**
54
+ * Curated vendors and how many of their newest models to surface in the
55
+ * onboarding picker. Order matters — first vendors appear first.
56
+ */
57
+ export declare const OPENROUTER_VENDORS: readonly OpenRouterVendor[];
58
+ /**
59
+ * Model-id prefix → env var holding a Vertex region override. First matching
60
+ * prefix wins (order matters); the resolver reads `process.env[name]` and falls
61
+ * back to the default region when unset. Consumed by envUtils.getVertexRegionForModel.
62
+ */
63
+ export declare const VERTEX_REGION_OVERRIDES: ReadonlyArray<readonly [string, string]>;
64
+ /**
65
+ * Per-model pricing for direct-provider ids (USD per 1M tokens), resolved to
66
+ * full ModelPricing (input/output from data, cacheRead/cacheWrite derived).
67
+ * OpenRouter vendor/model ids price from the build-time snapshot instead.
68
+ */
69
+ export declare const MODEL_PRICING: Record<string, ModelPricing>;
70
+ /** Fallback pricing for models absent from MODEL_PRICING and the snapshot. */
71
+ export declare const DEFAULT_PRICING: ModelPricing;
72
+ /**
73
+ * Onboarding provider catalog. First entry (openrouter) doubles as the
74
+ * zero-config default; each entry's models[0] is that provider's default pick.
75
+ * Consumed by onboarding.ts (key validation / model registration / env detect).
76
+ */
77
+ export declare const PROVIDERS: readonly ProviderDef[];
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Hand-maintained model metadata for direct-provider models and onboarding
3
+ * picker tuning, extracted out of onboarding.ts so updating a model's
4
+ * max-output / context-window or the picker vendor list is a data edit
5
+ * (model-metadata.json) rather than a code change.
6
+ *
7
+ * Scope: only what the build-time OpenRouter snapshot does NOT cover —
8
+ * direct-provider ids (no "vendor/" prefix) for the metadata tables, plus the
9
+ * curated OpenRouter vendor ordering for the picker. OpenRouter "vendor/model"
10
+ * ids get their context/max-output from the snapshot (see data/openrouter-*).
11
+ *
12
+ * Loaded with createRequire so the bundled JSON ships in dist (the build copies
13
+ * src/data/*.json → dist/data/), matching static-catalogs.ts.
14
+ */
15
+ import { createRequire } from "node:module";
16
+ const requireJson = createRequire(import.meta.url);
17
+ const METADATA = requireJson("./model-metadata.json");
18
+ /**
19
+ * Derive a full ModelPricing from an [input, output] pair, applying the
20
+ * standard cache-price heuristic (read = 10% of input, write = 125% of input).
21
+ * This is the same derivation the old `pricing()` helper in cost-tracker used;
22
+ * the previously-explicit Anthropic cacheRead/cacheWrite values equalled this
23
+ * heuristic exactly, so moving every entry to a pair causes zero value drift.
24
+ */
25
+ function pricingFromPair([input, output]) {
26
+ return { input, output, cacheRead: input * 0.1, cacheWrite: input * 1.25 };
27
+ }
28
+ /** Known max output tokens for direct-provider models (id → tokens). */
29
+ export const KNOWN_MAX_OUTPUT = METADATA.knownMaxOutput;
30
+ /** Known context window sizes for direct-provider models (id → tokens). */
31
+ export const KNOWN_CONTEXT_WINDOWS = METADATA.knownContextWindows;
32
+ /**
33
+ * Curated vendors and how many of their newest models to surface in the
34
+ * onboarding picker. Order matters — first vendors appear first.
35
+ */
36
+ export const OPENROUTER_VENDORS = METADATA.openRouterVendors;
37
+ /**
38
+ * Model-id prefix → env var holding a Vertex region override. First matching
39
+ * prefix wins (order matters); the resolver reads `process.env[name]` and falls
40
+ * back to the default region when unset. Consumed by envUtils.getVertexRegionForModel.
41
+ */
42
+ export const VERTEX_REGION_OVERRIDES = METADATA.vertexRegionOverrides;
43
+ /**
44
+ * Per-model pricing for direct-provider ids (USD per 1M tokens), resolved to
45
+ * full ModelPricing (input/output from data, cacheRead/cacheWrite derived).
46
+ * OpenRouter vendor/model ids price from the build-time snapshot instead.
47
+ */
48
+ export const MODEL_PRICING = Object.fromEntries(Object.entries(METADATA.pricing).map(([id, pair]) => [id, pricingFromPair(pair)]));
49
+ /** Fallback pricing for models absent from MODEL_PRICING and the snapshot. */
50
+ export const DEFAULT_PRICING = pricingFromPair(METADATA.pricingDefault);
51
+ /**
52
+ * Onboarding provider catalog. First entry (openrouter) doubles as the
53
+ * zero-config default; each entry's models[0] is that provider's default pick.
54
+ * Consumed by onboarding.ts (key validation / model registration / env detect).
55
+ */
56
+ export const PROVIDERS = METADATA.providers;
@@ -0,0 +1,216 @@
1
+ {
2
+ "_comment": "Hand-maintained metadata for direct-provider models (ids without a 'vendor/' prefix) and onboarding picker tuning. OpenRouter 'vendor/model' ids get their metadata from the build-time openrouter snapshot instead; these tables only cover what the snapshot doesn't. Edit this file (no code change) when a vendor ships a new direct-provider model or you want to tune the picker. Consumed by data/model-metadata.ts.",
3
+ "knownMaxOutput": {
4
+ "anthropic/claude-opus-4.7": 32000,
5
+ "anthropic/claude-opus-4-7": 32000,
6
+ "claude-opus-4-7": 32000,
7
+ "anthropic/claude-sonnet-4.6": 16000,
8
+ "anthropic/claude-sonnet-4-6": 16000,
9
+ "claude-sonnet-4-6": 16000,
10
+ "anthropic/claude-haiku-4.5": 8192,
11
+ "anthropic/claude-haiku-4-5": 8192,
12
+ "claude-haiku-4-5": 8192,
13
+ "openai/gpt-5": 32000,
14
+ "openai/gpt-5-mini": 32000,
15
+ "openai/gpt-5-nano": 16000,
16
+ "gpt-5": 32000,
17
+ "gpt-5-mini": 32000,
18
+ "gpt-5-nano": 16000,
19
+ "openai/gpt-4o": 16384,
20
+ "gpt-4o": 16384,
21
+ "openai/o4-mini": 100000,
22
+ "o4-mini": 100000,
23
+ "openai/o3": 100000,
24
+ "o3": 100000,
25
+ "google/gemini-2.5-pro": 65536,
26
+ "google/gemini-2.5-flash": 65536,
27
+ "gemini-2.5-pro": 65536,
28
+ "gemini-2.5-flash": 65536,
29
+ "gemini-2.0-flash": 8192,
30
+ "deepseek/deepseek-v3.2": 8192,
31
+ "deepseek/deepseek-r1": 8192,
32
+ "deepseek-v4-flash": 8192,
33
+ "deepseek-v4-pro": 65536,
34
+ "deepseek-chat": 8192,
35
+ "qwen/qwen3-coder": 16384,
36
+ "meta-llama/llama-4-maverick": 32000
37
+ },
38
+ "knownContextWindows": {
39
+ "deepseek-v4-pro": 1000000,
40
+ "deepseek-v4-flash": 1000000,
41
+ "deepseek-chat": 1000000,
42
+ "deepseek/deepseek-chat": 1000000,
43
+ "deepseek/deepseek-v4-pro": 1000000,
44
+ "deepseek/deepseek-v4-flash": 1000000
45
+ },
46
+ "openRouterVendors": [
47
+ { "prefix": "anthropic/", "take": 4 },
48
+ { "prefix": "openai/", "take": 5 },
49
+ { "prefix": "google/", "take": 3 },
50
+ { "prefix": "deepseek/", "take": 3 },
51
+ { "prefix": "x-ai/", "take": 2 },
52
+ { "prefix": "qwen/", "take": 2 },
53
+ { "prefix": "meta-llama/", "take": 2 },
54
+ { "prefix": "mistralai/", "take": 1 }
55
+ ],
56
+ "vertexRegionOverrides": [
57
+ ["claude-haiku-4-5", "VERTEX_REGION_CLAUDE_HAIKU_4_5"],
58
+ ["claude-3-5-haiku", "VERTEX_REGION_CLAUDE_3_5_HAIKU"],
59
+ ["claude-3-5-sonnet", "VERTEX_REGION_CLAUDE_3_5_SONNET"],
60
+ ["claude-3-7-sonnet", "VERTEX_REGION_CLAUDE_3_7_SONNET"],
61
+ ["claude-opus-4-1", "VERTEX_REGION_CLAUDE_4_1_OPUS"],
62
+ ["claude-opus-4", "VERTEX_REGION_CLAUDE_4_0_OPUS"],
63
+ ["claude-sonnet-4-6", "VERTEX_REGION_CLAUDE_4_6_SONNET"],
64
+ ["claude-sonnet-4-5", "VERTEX_REGION_CLAUDE_4_5_SONNET"],
65
+ ["claude-sonnet-4", "VERTEX_REGION_CLAUDE_4_0_SONNET"]
66
+ ],
67
+ "_pricingComment": "Per-1M-token USD pricing [input, output] for direct-provider models (no vendor/ snapshot). cacheRead/cacheWrite are derived by the loader: cacheRead = input*0.1, cacheWrite = input*1.25 (matches the original pricing() helper; verified the prior explicit Anthropic cacheRead/cacheWrite equalled this heuristic exactly). 'default' is the fallback for unknown models. OpenRouter vendor/model ids price from the build-time snapshot, not here.",
68
+ "pricingDefault": [3, 15],
69
+ "pricing": {
70
+ "claude-opus-4.6": [15, 75],
71
+ "claude-opus-4-6": [15, 75],
72
+ "claude-opus-4.5": [15, 75],
73
+ "claude-opus-4.1": [15, 75],
74
+ "claude-opus-4": [15, 75],
75
+ "claude-sonnet-4.6": [3, 15],
76
+ "claude-sonnet-4-6": [3, 15],
77
+ "claude-sonnet-4.5": [3, 15],
78
+ "claude-sonnet-4": [3, 15],
79
+ "claude-3.7-sonnet": [3, 15],
80
+ "claude-3-7-sonnet": [3, 15],
81
+ "claude-3.5-haiku": [0.8, 4],
82
+ "claude-haiku-4.5": [1, 5],
83
+ "claude-haiku-4-5": [1, 5],
84
+ "gpt-5.4": [5, 20],
85
+ "gpt-5.4-mini": [1.5, 6],
86
+ "gpt-5.4-pro": [10, 40],
87
+ "gpt-5": [5, 20],
88
+ "gpt-4o": [2.5, 10],
89
+ "gpt-4o-mini": [0.15, 0.6],
90
+ "gpt-4.1": [2, 8],
91
+ "gpt-4.1-mini": [0.4, 1.6],
92
+ "o4-mini": [1.1, 4.4],
93
+ "o3": [10, 40],
94
+ "o3-mini": [1.1, 4.4],
95
+ "gemini-2.5-pro": [1.25, 10],
96
+ "gemini-2.5-pro-preview": [1.25, 10],
97
+ "gemini-2.5-flash": [0.15, 0.6],
98
+ "gemini-3.1-pro-preview": [2, 10],
99
+ "gemini-3-flash-preview": [0.15, 0.6],
100
+ "gemini-2.0-flash": [0.1, 0.4],
101
+ "deepseek-v4-flash": [0.126, 0.252],
102
+ "deepseek-v4-pro": [0.5, 2],
103
+ "deepseek-v3.2": [0.14, 0.28],
104
+ "deepseek-chat": [0.14, 0.28],
105
+ "deepseek-r1": [0.55, 2.19],
106
+ "deepseek-reasoner": [0.55, 2.19],
107
+ "qwen3-coder": [0.3, 0.6],
108
+ "qwen3-235b-a22b": [0.3, 1.2],
109
+ "qwen3-30b-a3b": [0.1, 0.3],
110
+ "qwen3-max": [0.5, 2],
111
+ "llama-4-maverick": [0.2, 0.8],
112
+ "llama-4-scout": [0.15, 0.4],
113
+ "devstral-medium": [0.5, 1.5],
114
+ "mistral-large": [2, 6],
115
+ "devstral-small": [0.1, 0.3]
116
+ },
117
+ "_providersComment": "Onboarding provider catalog (consumed by onboarding.ts). First entry (openrouter) doubles as the zero-config default; its model list is ordered so models[0] is the default pick. 'provider' is the adapterKind. Edit this (no code change) to add/retune a provider in the first-run wizard. name 文案随之在此(原 onboarding hardcoded 中文).",
118
+ "providers": [
119
+ {
120
+ "id": "openrouter",
121
+ "name": "OpenRouter (推荐 — 支持所有模型)",
122
+ "envKey": "OPENROUTER_API_KEY",
123
+ "provider": "openai",
124
+ "baseUrl": "https://openrouter.ai/api/v1",
125
+ "keyUrl": "https://openrouter.ai/keys",
126
+ "keyPrefix": "sk-or-",
127
+ "models": [
128
+ "anthropic/claude-sonnet-4.6",
129
+ "anthropic/claude-opus-4.7",
130
+ "anthropic/claude-haiku-4.5",
131
+ "openai/gpt-5",
132
+ "openai/gpt-5-mini",
133
+ "openai/gpt-4o",
134
+ "openai/o4-mini",
135
+ "openai/o3",
136
+ "google/gemini-2.5-pro",
137
+ "google/gemini-2.5-flash",
138
+ "deepseek/deepseek-chat",
139
+ "deepseek/deepseek-reasoner",
140
+ "qwen/qwen3-coder",
141
+ "meta-llama/llama-4-maverick"
142
+ ]
143
+ },
144
+ {
145
+ "id": "anthropic",
146
+ "name": "Anthropic (直连 Claude API)",
147
+ "envKey": "ANTHROPIC_API_KEY",
148
+ "provider": "anthropic",
149
+ "baseUrl": "https://api.anthropic.com",
150
+ "keyUrl": "https://console.anthropic.com/settings/keys",
151
+ "keyPrefix": "sk-ant-",
152
+ "models": ["claude-sonnet-4-6", "claude-opus-4-7", "claude-haiku-4-5"]
153
+ },
154
+ {
155
+ "id": "openai",
156
+ "name": "OpenAI",
157
+ "envKey": "OPENAI_API_KEY",
158
+ "provider": "openai",
159
+ "baseUrl": "https://api.openai.com/v1",
160
+ "keyUrl": "https://platform.openai.com/api-keys",
161
+ "keyPrefix": "sk-",
162
+ "models": ["gpt-5", "gpt-5-mini", "gpt-5-nano", "gpt-4o", "o4-mini", "o3"]
163
+ },
164
+ {
165
+ "id": "deepseek",
166
+ "name": "DeepSeek (官方直连)",
167
+ "envKey": "DEEPSEEK_API_KEY",
168
+ "provider": "openai",
169
+ "baseUrl": "https://api.deepseek.com/v1",
170
+ "keyUrl": "https://platform.deepseek.com/api_keys",
171
+ "keyPrefix": "sk-",
172
+ "models": ["deepseek-v4-pro", "deepseek-v4-flash", "deepseek-chat"]
173
+ },
174
+ {
175
+ "id": "zai",
176
+ "name": "Z.AI (GLM 官方)",
177
+ "envKey": "ZAI_API_KEY",
178
+ "provider": "openai",
179
+ "baseUrl": "https://api.z.ai/api/paas/v4",
180
+ "keyUrl": "https://z.ai/manage-apikey/apikey-list",
181
+ "keyPrefix": "",
182
+ "models": ["glm-5.1", "glm-4.6", "glm-4.5-air"]
183
+ },
184
+ {
185
+ "id": "gemini",
186
+ "name": "Google Gemini (官方直连)",
187
+ "envKey": "GEMINI_API_KEY",
188
+ "provider": "openai",
189
+ "baseUrl": "https://generativelanguage.googleapis.com/v1beta/openai",
190
+ "keyUrl": "https://aistudio.google.com/apikey",
191
+ "keyPrefix": "",
192
+ "models": ["gemini-2.5-pro", "gemini-2.5-flash", "gemini-2.0-flash"]
193
+ },
194
+ {
195
+ "id": "ollama",
196
+ "name": "Ollama (本地,无需 Key)",
197
+ "envKey": "",
198
+ "provider": "openai",
199
+ "baseUrl": "http://localhost:11434/v1",
200
+ "keyUrl": "https://ollama.com/library",
201
+ "keyPrefix": "",
202
+ "models": ["llama3.1", "qwen2.5-coder", "deepseek-r1", "mistral", "gemma3"],
203
+ "noKey": true
204
+ },
205
+ {
206
+ "id": "custom",
207
+ "name": "自定义 (任何 OpenAI 兼容 API)",
208
+ "envKey": "",
209
+ "provider": "openai",
210
+ "baseUrl": "",
211
+ "keyUrl": "",
212
+ "keyPrefix": "",
213
+ "models": []
214
+ }
215
+ ]
216
+ }