nolo-cli 0.1.7 → 0.1.9

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 (247) hide show
  1. package/README.md +107 -5
  2. package/agentRuntimeCommands.ts +464 -0
  3. package/ai/agent/_executeModel.ts +118 -0
  4. package/ai/agent/agentSlice.ts +525 -0
  5. package/ai/agent/appWorkingMemory.ts +126 -0
  6. package/ai/agent/avatarUtils.ts +24 -0
  7. package/ai/agent/buildEditingContext.ts +373 -0
  8. package/ai/agent/buildSystemPrompt.ts +532 -0
  9. package/ai/agent/cleanAgentMessages.ts +140 -0
  10. package/ai/agent/cliChatClient.ts +119 -0
  11. package/ai/agent/cliExecutor.ts +733 -0
  12. package/ai/agent/cliPrompt.ts +10 -0
  13. package/ai/agent/contextCompiler.ts +107 -0
  14. package/ai/agent/contextLayerContract.ts +44 -0
  15. package/ai/agent/createAgentSchema.ts +234 -0
  16. package/ai/agent/executeToolCall.ts +58 -0
  17. package/ai/agent/fetchAgentContexts.ts +42 -0
  18. package/ai/agent/generatePrompt.ts +3 -0
  19. package/ai/agent/getFullChatContextKeys.ts +168 -0
  20. package/ai/agent/hooks/fetchPublicAgents.ts +133 -0
  21. package/ai/agent/hooks/useAgentConfig.ts +61 -0
  22. package/ai/agent/hooks/useAgentDialog.ts +35 -0
  23. package/ai/agent/hooks/useAgentFormValidation.ts +202 -0
  24. package/ai/agent/hooks/usePublicAgents.ts +473 -0
  25. package/ai/agent/machineRunPermissions.ts +95 -0
  26. package/ai/agent/persistMessageWithFixedId.ts +37 -0
  27. package/ai/agent/planSlice.ts +259 -0
  28. package/ai/agent/referenceUtils.ts +229 -0
  29. package/ai/agent/runAgentBackground.ts +238 -0
  30. package/ai/agent/runAgentClientLoop.ts +138 -0
  31. package/ai/agent/runtimeGuidance.ts +97 -0
  32. package/ai/agent/runtimeServerBase.ts +37 -0
  33. package/ai/agent/server/fetchPublicAgents.ts +128 -0
  34. package/ai/agent/startParallelAgentStreams.ts +424 -0
  35. package/ai/agent/startupProtocol.ts +53 -0
  36. package/ai/agent/streamAgentChatTurn.ts +1278 -0
  37. package/ai/agent/streamAgentChatTurnUtils.ts +738 -0
  38. package/ai/agent/types.ts +71 -0
  39. package/ai/agent/utils/imageOutput.ts +33 -0
  40. package/ai/agent/utils/sortUtils.ts +250 -0
  41. package/ai/agent/web/referencePickerUtils.ts +146 -0
  42. package/ai/ai.locale.ts +1075 -0
  43. package/ai/chat/accumulateToolCallChunks.ts +95 -0
  44. package/ai/chat/fetchUtils.native.ts +276 -0
  45. package/ai/chat/fetchUtils.ts +153 -0
  46. package/ai/chat/parseApiError.ts +64 -0
  47. package/ai/chat/parseMultilineSSE.ts +95 -0
  48. package/ai/chat/sendOpenAICompletionsRequest.native.ts +682 -0
  49. package/ai/chat/sendOpenAICompletionsRequest.ts +703 -0
  50. package/ai/chat/sendOpenAIResponseRequest.ts +491 -0
  51. package/ai/chat/shouldUseServerProxy.ts +18 -0
  52. package/ai/chat/sseClient.native.ts +91 -0
  53. package/ai/chat/sseClient.ts +67 -0
  54. package/ai/chat/streamReader.native.ts +31 -0
  55. package/ai/chat/streamReader.ts +62 -0
  56. package/ai/chat/updateTotalUsage.ts +72 -0
  57. package/ai/context/buildReferenceContext.ts +437 -0
  58. package/ai/context/calculateContextUsage.ts +133 -0
  59. package/ai/context/retention.ts +165 -0
  60. package/ai/context/tokenUtils.ts +78 -0
  61. package/ai/index.ts +1 -0
  62. package/ai/llm/calculateGeminiImageTokens.ts +57 -0
  63. package/ai/llm/deepinfra.ts +28 -0
  64. package/ai/llm/fireworks.ts +50 -0
  65. package/ai/llm/generateRequestBody.ts +165 -0
  66. package/ai/llm/getModelContextWindow.ts +84 -0
  67. package/ai/llm/getNoloKey.ts +31 -0
  68. package/ai/llm/getPricing.ts +199 -0
  69. package/ai/llm/hooks/useModelPricing.ts +75 -0
  70. package/ai/llm/imagePricing.ts +40 -0
  71. package/ai/llm/isResponseAPIModel.ts +13 -0
  72. package/ai/llm/mimo.ts +71 -0
  73. package/ai/llm/mistral.ts +22 -0
  74. package/ai/llm/modelAvatar.ts +427 -0
  75. package/ai/llm/models.ts +45 -0
  76. package/ai/llm/openrouterModels.ts +269 -0
  77. package/ai/llm/providers.ts +306 -0
  78. package/ai/llm/reasoningModels.ts +28 -0
  79. package/ai/llm/types.ts +59 -0
  80. package/ai/llm/usageRequestOptions.ts +59 -0
  81. package/ai/memory/capture.ts +148 -0
  82. package/ai/memory/consolidate.ts +104 -0
  83. package/ai/memory/delete.ts +147 -0
  84. package/ai/memory/overlay.ts +84 -0
  85. package/ai/memory/query.ts +38 -0
  86. package/ai/memory/queryShared.ts +160 -0
  87. package/ai/memory/rank.ts +105 -0
  88. package/ai/memory/recentRelationshipRecap.ts +249 -0
  89. package/ai/memory/remember.ts +167 -0
  90. package/ai/memory/runtime.ts +76 -0
  91. package/ai/memory/store.ts +20 -0
  92. package/ai/memory/storeShared.ts +76 -0
  93. package/ai/memory/types.ts +46 -0
  94. package/ai/memory/understanding.ts +349 -0
  95. package/ai/memory/understandingGreeting.ts +264 -0
  96. package/ai/messages/type.ts +20 -0
  97. package/ai/policy/personalizationDialog.ts +333 -0
  98. package/ai/policy/runtimePolicy.ts +440 -0
  99. package/ai/policy/selfUpdateFields.ts +48 -0
  100. package/ai/policy/types.ts +64 -0
  101. package/ai/skills/referenceRuntime.ts +274 -0
  102. package/ai/skills/skillDiagnostics.ts +251 -0
  103. package/ai/skills/skillDocBuilder.ts +139 -0
  104. package/ai/skills/skillDocProtocol.ts +434 -0
  105. package/ai/skills/skillReferenceSummary.ts +63 -0
  106. package/ai/skills/skillSummaryMarker.ts +26 -0
  107. package/ai/token/calculatePrice.ts +544 -0
  108. package/ai/token/db.ts +98 -0
  109. package/ai/token/externalToolCost.ts +330 -0
  110. package/ai/token/hooks/useRecords.ts +65 -0
  111. package/ai/token/missingUsageEstimate.ts +42 -0
  112. package/ai/token/modelUsageQuery.ts +252 -0
  113. package/ai/token/normalizeUsage.ts +84 -0
  114. package/ai/token/openaiImageGenerationUsage.ts +56 -0
  115. package/ai/token/prepareTokenUsageData.ts +88 -0
  116. package/ai/token/query.ts +88 -0
  117. package/ai/token/queryUserTokens.ts +59 -0
  118. package/ai/token/resolveBillingTarget.ts +52 -0
  119. package/ai/token/saveTokenRecord.ts +53 -0
  120. package/ai/token/serverDialogProjection.ts +78 -0
  121. package/ai/token/serverTokenWriter.ts +143 -0
  122. package/ai/token/stats.ts +21 -0
  123. package/ai/token/tokenThunks.ts +24 -0
  124. package/ai/token/types.ts +93 -0
  125. package/ai/tools/agent/agentTools.ts +176 -0
  126. package/ai/tools/agent/agentUpdateShared.ts +311 -0
  127. package/ai/tools/agent/callAgentTool.ts +139 -0
  128. package/ai/tools/agent/createAgentTool.ts +512 -0
  129. package/ai/tools/agent/createDialogTool.ts +69 -0
  130. package/ai/tools/agent/createSkillAgentTool.ts +62 -0
  131. package/ai/tools/agent/parallelBudget.ts +221 -0
  132. package/ai/tools/agent/presets/appBuilderPreset.ts +145 -0
  133. package/ai/tools/agent/runLlmTool.ts +96 -0
  134. package/ai/tools/agent/runStreamingAgentTool.ts +73 -0
  135. package/ai/tools/agent/skillAgentArgs.ts +106 -0
  136. package/ai/tools/agent/skillAgentPreset.ts +89 -0
  137. package/ai/tools/agent/streamParallelAgentsTool.ts +122 -0
  138. package/ai/tools/agent/updateAgentTool.ts +96 -0
  139. package/ai/tools/agent/updateSelfTool.ts +113 -0
  140. package/ai/tools/amazonProductScraperTool.ts +86 -0
  141. package/ai/tools/apifyActorClient.ts +45 -0
  142. package/ai/tools/appEditGuard.ts +372 -0
  143. package/ai/tools/appReadSnapshot.ts +153 -0
  144. package/ai/tools/appTools.ts +1549 -0
  145. package/ai/tools/applyEditTool.ts +256 -0
  146. package/ai/tools/applyLineEditsTool.ts +312 -0
  147. package/ai/tools/browserTools/click.ts +33 -0
  148. package/ai/tools/browserTools/closeSession.ts +29 -0
  149. package/ai/tools/browserTools/common.ts +27 -0
  150. package/ai/tools/browserTools/openSession.ts +48 -0
  151. package/ai/tools/browserTools/readContent.ts +38 -0
  152. package/ai/tools/browserTools/selectOption.ts +46 -0
  153. package/ai/tools/browserTools/typeText.ts +42 -0
  154. package/ai/tools/category/createCategoryTool.ts +66 -0
  155. package/ai/tools/category/queryContentsByCategoryTool.ts +69 -0
  156. package/ai/tools/category/updateContentCategoryTool.ts +75 -0
  157. package/ai/tools/cfBrowserTools.ts +319 -0
  158. package/ai/tools/cfSpeechToTextTool.ts +49 -0
  159. package/ai/tools/checkEnvTool.ts +65 -0
  160. package/ai/tools/cloudflareCrawlTool.ts +289 -0
  161. package/ai/tools/codeSearchTool.ts +111 -0
  162. package/ai/tools/codeTools.ts +101 -0
  163. package/ai/tools/createDocTool.ts +132 -0
  164. package/ai/tools/createPlanTool.ts +999 -0
  165. package/ai/tools/createSkillDocTool.ts +155 -0
  166. package/ai/tools/createWorkflowTool.ts +154 -0
  167. package/ai/tools/deepseekOcrTool.ts +34 -0
  168. package/ai/tools/delayTool.ts +31 -0
  169. package/ai/tools/deleteSpacesTool.ts +325 -0
  170. package/ai/tools/deleteSpacesToolModel.ts +159 -0
  171. package/ai/tools/devReloadUtils.ts +29 -0
  172. package/ai/tools/dialogMessageSearch.ts +137 -0
  173. package/ai/tools/doctorSkillTool.ts +72 -0
  174. package/ai/tools/ecommerceScraperTool.ts +86 -0
  175. package/ai/tools/emailTools.ts +549 -0
  176. package/ai/tools/evalSkillTool.ts +92 -0
  177. package/ai/tools/exaSearchTool.ts +64 -0
  178. package/ai/tools/execBashTool.ts +379 -0
  179. package/ai/tools/executeSqlTool.ts +192 -0
  180. package/ai/tools/fetchWebpageSupport.ts +309 -0
  181. package/ai/tools/fetchWebpageTool.ts +84 -0
  182. package/ai/tools/geminiImagePreviewTool.ts +361 -0
  183. package/ai/tools/generateDocxTool.ts +215 -0
  184. package/ai/tools/googleSearchScraperTool.ts +106 -0
  185. package/ai/tools/importDataTool.ts +133 -0
  186. package/ai/tools/importSkillTool.ts +162 -0
  187. package/ai/tools/index.ts +1858 -0
  188. package/ai/tools/listFilesTool.ts +82 -0
  189. package/ai/tools/listUserSpacesTool.ts +113 -0
  190. package/ai/tools/modelUsageTools.ts +142 -0
  191. package/ai/tools/olmOcrTool.ts +34 -0
  192. package/ai/tools/openaiImageTool.ts +218 -0
  193. package/ai/tools/paddleOcrTool.ts +34 -0
  194. package/ai/tools/prepareTools.ts +23 -0
  195. package/ai/tools/readDocTool.ts +84 -0
  196. package/ai/tools/readFileTool.ts +211 -0
  197. package/ai/tools/readTool.ts +163 -0
  198. package/ai/tools/readXPostTool.ts +233 -0
  199. package/ai/tools/rememberMemoryTool.ts +84 -0
  200. package/ai/tools/remotionVideoTool.ts +151 -0
  201. package/ai/tools/searchDialogMessagesTool.ts +222 -0
  202. package/ai/tools/searchRepoTool.ts +115 -0
  203. package/ai/tools/searchWorkspaceTool.ts +259 -0
  204. package/ai/tools/skillFollowup.ts +86 -0
  205. package/ai/tools/surfWeatherTool.ts +169 -0
  206. package/ai/tools/table/addTableRowTool.ts +217 -0
  207. package/ai/tools/table/createTableTool.ts +315 -0
  208. package/ai/tools/table/rowTools.ts +366 -0
  209. package/ai/tools/table/schemaTools.ts +244 -0
  210. package/ai/tools/table/shareTableTool.ts +148 -0
  211. package/ai/tools/table/toolShared.ts +129 -0
  212. package/ai/tools/toolApiClient.ts +198 -0
  213. package/ai/tools/toolNameAliases.ts +57 -0
  214. package/ai/tools/toolResultError.ts +42 -0
  215. package/ai/tools/toolRunSlice.ts +303 -0
  216. package/ai/tools/toolSchemaCompatibility.ts +53 -0
  217. package/ai/tools/toolVisibility.ts +4 -0
  218. package/ai/tools/types.ts +20 -0
  219. package/ai/tools/uiAskChoiceTool.ts +104 -0
  220. package/ai/tools/updateContentTitleTool.ts +84 -0
  221. package/ai/tools/updateDocTool.ts +105 -0
  222. package/ai/tools/updateUserPreferenceProfileTool.ts +145 -0
  223. package/ai/tools/whisperTool.ts +77 -0
  224. package/ai/tools/writeFileTool.ts +210 -0
  225. package/ai/tools/youtubeScraperTool.ts +116 -0
  226. package/ai/tools/ziweiChartTool.ts +678 -0
  227. package/ai/types.ts +55 -0
  228. package/ai/workflow/workflowExecutor.ts +323 -0
  229. package/ai/workflow/workflowSlice.ts +73 -0
  230. package/ai/workflow/workflowTypes.ts +106 -0
  231. package/client/agentRun.ts +198 -167
  232. package/client/compactDialog.ts +222 -0
  233. package/commandRegistry.ts +14 -0
  234. package/connector-experimental/capabilities.ts +73 -0
  235. package/connector-experimental/codexBinary.ts +41 -0
  236. package/connector-experimental/heartbeatLoop.ts +22 -0
  237. package/connector-experimental/index.ts +5 -0
  238. package/connector-experimental/machineInfo.ts +46 -0
  239. package/connector-experimental/protocol.ts +54 -0
  240. package/connectorWebSocketTarget.ts +29 -0
  241. package/defaultServer.ts +1 -0
  242. package/index.ts +158 -104
  243. package/machineCommands.ts +382 -0
  244. package/package.json +12 -2
  245. package/tui/readlineWorkspace.ts +50 -0
  246. package/tui/session.ts +40 -2
  247. package/updateCommands.ts +70 -5
@@ -0,0 +1,427 @@
1
+ // packages/ai/llm/modelAvatar.ts
2
+ // Maps provider/model name → @lobehub/icons Avatar component.
3
+ // Model-name check runs first so openrouter/deepinfra aggregators work correctly.
4
+
5
+ import { createElement, type CSSProperties, type ComponentType } from "react";
6
+
7
+ export type LobehubAvatarProps = {
8
+ size?: number | string;
9
+ style?: CSSProperties;
10
+ className?: string;
11
+ };
12
+ type AvatarCtor = ComponentType<LobehubAvatarProps>;
13
+ type MonoModule = { default?: ComponentType<{ size?: number | string; style?: CSSProperties }> };
14
+ type AvatarModule = { default?: AvatarCtor };
15
+ type StyleModule = {
16
+ AVATAR_BACKGROUND?: string;
17
+ AVATAR_COLOR?: string;
18
+ AVATAR_ICON_MULTIPLE?: number;
19
+ };
20
+
21
+ type AvatarLoader = () => Promise<{ avatar?: AvatarModule; mono?: MonoModule; style?: StyleModule }>;
22
+
23
+ const scaleSize = (size: number | string, multiple: number) =>
24
+ typeof size === "number" ? size * multiple : `calc(${size} * ${multiple})`;
25
+
26
+ const createAvatarComponent = (
27
+ Mono: ComponentType<{ size?: number | string; style?: CSSProperties }>,
28
+ styleModule: StyleModule
29
+ ): AvatarCtor => {
30
+ const background = styleModule.AVATAR_BACKGROUND ?? "#111";
31
+ const color = styleModule.AVATAR_COLOR ?? "#fff";
32
+ const iconMultiple = styleModule.AVATAR_ICON_MULTIPLE ?? 0.75;
33
+
34
+ const AvatarComponent: AvatarCtor = (rawProps) => {
35
+ const { size = 40, style, className } = rawProps ?? {};
36
+
37
+ return createElement(
38
+ "div",
39
+ {
40
+ "aria-hidden": "true",
41
+ className,
42
+ style: {
43
+ alignItems: "center",
44
+ background,
45
+ borderRadius: "50%",
46
+ color,
47
+ display: "inline-flex",
48
+ flex: "none",
49
+ height: size,
50
+ justifyContent: "center",
51
+ lineHeight: 1,
52
+ overflow: "hidden",
53
+ width: size,
54
+ ...style,
55
+ },
56
+ },
57
+ createElement(Mono, { size: scaleSize(size, iconMultiple), style: { flex: "none" } })
58
+ );
59
+ };
60
+
61
+ return AvatarComponent;
62
+ };
63
+
64
+ // key → lazy import factory
65
+ const MAP: Record<string, AvatarLoader> = {
66
+ // ── 国际大厂 ─────────────────────────────────────
67
+ openai: () =>
68
+ Promise.all([
69
+ import("@lobehub/icons/es/OpenAI/components/Mono"),
70
+ import("@lobehub/icons/es/OpenAI/style"),
71
+ ]).then(([mono, style]) => ({ mono, style })),
72
+ claude: () =>
73
+ Promise.all([
74
+ import("@lobehub/icons/es/Claude/components/Mono"),
75
+ import("@lobehub/icons/es/Claude/style"),
76
+ ]).then(([mono, style]) => ({ mono, style })),
77
+ anthropic: () =>
78
+ Promise.all([
79
+ import("@lobehub/icons/es/Anthropic/components/Mono"),
80
+ import("@lobehub/icons/es/Anthropic/style"),
81
+ ]).then(([mono, style]) => ({ mono, style })),
82
+ gemini: () =>
83
+ Promise.all([
84
+ import("@lobehub/icons/es/Gemini/components/Color"),
85
+ import("@lobehub/icons/es/Gemini/style"),
86
+ ]).then(([mono, style]) => ({ mono, style })),
87
+ google: () =>
88
+ Promise.all([
89
+ import("@lobehub/icons/es/Google/components/Mono"),
90
+ import("@lobehub/icons/es/Google/style"),
91
+ ]).then(([mono, style]) => ({ mono, style })),
92
+ grok: () =>
93
+ Promise.all([
94
+ import("@lobehub/icons/es/Grok/components/Mono"),
95
+ import("@lobehub/icons/es/Grok/style"),
96
+ ]).then(([mono, style]) => ({ mono, style })),
97
+ xai: () =>
98
+ Promise.all([
99
+ import("@lobehub/icons/es/XAI/components/Mono"),
100
+ import("@lobehub/icons/es/XAI/style"),
101
+ ]).then(([mono, style]) => ({ mono, style })),
102
+ mistral: () =>
103
+ Promise.all([
104
+ import("@lobehub/icons/es/Mistral/components/Mono"),
105
+ import("@lobehub/icons/es/Mistral/style"),
106
+ ]).then(([mono, style]) => ({ mono, style })),
107
+ llama: () =>
108
+ Promise.all([
109
+ import("@lobehub/icons/es/Meta/components/Mono"),
110
+ import("@lobehub/icons/es/Meta/style"),
111
+ ]).then(([mono, style]) => ({ mono, style })),
112
+ meta: () =>
113
+ Promise.all([
114
+ import("@lobehub/icons/es/Meta/components/Mono"),
115
+ import("@lobehub/icons/es/Meta/style"),
116
+ ]).then(([mono, style]) => ({ mono, style })),
117
+ perplexity: () =>
118
+ Promise.all([
119
+ import("@lobehub/icons/es/Perplexity/components/Mono"),
120
+ import("@lobehub/icons/es/Perplexity/style"),
121
+ ]).then(([mono, style]) => ({ mono, style })),
122
+ cohere: () =>
123
+ Promise.all([
124
+ import("@lobehub/icons/es/Cohere/components/Mono"),
125
+ import("@lobehub/icons/es/Cohere/style"),
126
+ ]).then(([mono, style]) => ({ mono, style })),
127
+ gemma: () =>
128
+ Promise.all([
129
+ import("@lobehub/icons/es/Gemma/components/Mono"),
130
+ import("@lobehub/icons/es/Gemma/style"),
131
+ ]).then(([mono, style]) => ({ mono, style })),
132
+ copilot: () =>
133
+ Promise.all([
134
+ import("@lobehub/icons/es/Copilot/components/Mono"),
135
+ import("@lobehub/icons/es/Copilot/style"),
136
+ ]).then(([mono, style]) => ({ mono, style })),
137
+
138
+ // ── 中国模型 ─────────────────────────────────────
139
+ glm: () =>
140
+ Promise.all([
141
+ import("@lobehub/icons/es/ChatGLM/components/Mono"),
142
+ import("@lobehub/icons/es/ChatGLM/style"),
143
+ ]).then(([mono, style]) => ({ mono, style })),
144
+ chatglm: () =>
145
+ Promise.all([
146
+ import("@lobehub/icons/es/ChatGLM/components/Mono"),
147
+ import("@lobehub/icons/es/ChatGLM/style"),
148
+ ]).then(([mono, style]) => ({ mono, style })),
149
+ zhipu: () =>
150
+ Promise.all([
151
+ import("@lobehub/icons/es/Zhipu/components/Mono"),
152
+ import("@lobehub/icons/es/Zhipu/style"),
153
+ ]).then(([mono, style]) => ({ mono, style })),
154
+ kimi: () =>
155
+ Promise.all([
156
+ import("@lobehub/icons/es/Kimi/components/Mono"),
157
+ import("@lobehub/icons/es/Kimi/style"),
158
+ ]).then(([mono, style]) => ({ mono, style })),
159
+ moonshot: () =>
160
+ Promise.all([
161
+ import("@lobehub/icons/es/Moonshot/components/Mono"),
162
+ import("@lobehub/icons/es/Moonshot/style"),
163
+ ]).then(([mono, style]) => ({ mono, style })),
164
+ minimax: () =>
165
+ Promise.all([
166
+ import("@lobehub/icons/es/Minimax/components/Mono"),
167
+ import("@lobehub/icons/es/Minimax/style"),
168
+ ]).then(([mono, style]) => ({ mono, style })),
169
+ hailuo: () =>
170
+ Promise.all([
171
+ import("@lobehub/icons/es/Hailuo/components/Mono"),
172
+ import("@lobehub/icons/es/Hailuo/style"),
173
+ ]).then(([mono, style]) => ({ mono, style })),
174
+ doubao: () =>
175
+ Promise.all([
176
+ import("@lobehub/icons/es/Doubao/components/Mono"),
177
+ import("@lobehub/icons/es/Doubao/style"),
178
+ ]).then(([mono, style]) => ({ mono, style })),
179
+ hunyuan: () =>
180
+ Promise.all([
181
+ import("@lobehub/icons/es/Hunyuan/components/Mono"),
182
+ import("@lobehub/icons/es/Hunyuan/style"),
183
+ ]).then(([mono, style]) => ({ mono, style })),
184
+ deepseek: () =>
185
+ Promise.all([
186
+ import("@lobehub/icons/es/DeepSeek/components/Mono"),
187
+ import("@lobehub/icons/es/DeepSeek/style"),
188
+ ]).then(([mono, style]) => ({ mono, style })),
189
+ qwen: () =>
190
+ Promise.all([
191
+ import("@lobehub/icons/es/Qwen/components/Mono"),
192
+ import("@lobehub/icons/es/Qwen/style"),
193
+ ]).then(([mono, style]) => ({ mono, style })),
194
+ wenxin: () =>
195
+ Promise.all([
196
+ import("@lobehub/icons/es/Wenxin/components/Mono"),
197
+ import("@lobehub/icons/es/Wenxin/style"),
198
+ ]).then(([mono, style]) => ({ mono, style })),
199
+ ernie: () =>
200
+ Promise.all([
201
+ import("@lobehub/icons/es/Wenxin/components/Mono"),
202
+ import("@lobehub/icons/es/Wenxin/style"),
203
+ ]).then(([mono, style]) => ({ mono, style })),
204
+ baichuan: () =>
205
+ Promise.all([
206
+ import("@lobehub/icons/es/Baichuan/components/Mono"),
207
+ import("@lobehub/icons/es/Baichuan/style"),
208
+ ]).then(([mono, style]) => ({ mono, style })),
209
+ yi: () =>
210
+ Promise.all([
211
+ import("@lobehub/icons/es/Yi/components/Mono"),
212
+ import("@lobehub/icons/es/Yi/style"),
213
+ ]).then(([mono, style]) => ({ mono, style })),
214
+ zeroone: () =>
215
+ Promise.all([
216
+ import("@lobehub/icons/es/ZeroOne/components/Mono"),
217
+ import("@lobehub/icons/es/ZeroOne/style"),
218
+ ]).then(([mono, style]) => ({ mono, style })),
219
+ internlm: () =>
220
+ Promise.all([
221
+ import("@lobehub/icons/es/InternLM/components/Mono"),
222
+ import("@lobehub/icons/es/InternLM/style"),
223
+ ]).then(([mono, style]) => ({ mono, style })),
224
+ spark: () =>
225
+ Promise.all([
226
+ import("@lobehub/icons/es/Spark/components/Mono"),
227
+ import("@lobehub/icons/es/Spark/style"),
228
+ ]).then(([mono, style]) => ({ mono, style })),
229
+ iflyt: () =>
230
+ Promise.all([
231
+ import("@lobehub/icons/es/Spark/components/Mono"),
232
+ import("@lobehub/icons/es/Spark/style"),
233
+ ]).then(([mono, style]) => ({ mono, style })),
234
+ stepfun: () =>
235
+ Promise.all([
236
+ import("@lobehub/icons/es/Stepfun/components/Mono"),
237
+ import("@lobehub/icons/es/Stepfun/style"),
238
+ ]).then(([mono, style]) => ({ mono, style })),
239
+ step: () =>
240
+ Promise.all([
241
+ import("@lobehub/icons/es/Stepfun/components/Mono"),
242
+ import("@lobehub/icons/es/Stepfun/style"),
243
+ ]).then(([mono, style]) => ({ mono, style })),
244
+ sensenova: () =>
245
+ Promise.all([
246
+ import("@lobehub/icons/es/SenseNova/components/Mono"),
247
+ import("@lobehub/icons/es/SenseNova/style"),
248
+ ]).then(([mono, style]) => ({ mono, style })),
249
+ sensetime: () =>
250
+ Promise.all([
251
+ import("@lobehub/icons/es/SenseNova/components/Mono"),
252
+ import("@lobehub/icons/es/SenseNova/style"),
253
+ ]).then(([mono, style]) => ({ mono, style })),
254
+ qingyan: () =>
255
+ Promise.all([
256
+ import("@lobehub/icons/es/Qingyan/components/Mono"),
257
+ import("@lobehub/icons/es/Qingyan/style"),
258
+ ]).then(([mono, style]) => ({ mono, style })),
259
+ coze: () =>
260
+ Promise.all([
261
+ import("@lobehub/icons/es/Coze/components/Mono"),
262
+ import("@lobehub/icons/es/Coze/style"),
263
+ ]).then(([mono, style]) => ({ mono, style })),
264
+ yuanbao: () =>
265
+ Promise.all([
266
+ import("@lobehub/icons/es/Yuanbao/components/Mono"),
267
+ import("@lobehub/icons/es/Yuanbao/style"),
268
+ ]).then(([mono, style]) => ({ mono, style })),
269
+ tiangong: () =>
270
+ Promise.all([
271
+ import("@lobehub/icons/es/Tiangong/components/Mono"),
272
+ import("@lobehub/icons/es/Tiangong/style"),
273
+ ]).then(([mono, style]) => ({ mono, style })),
274
+ skywork: () =>
275
+ Promise.all([
276
+ import("@lobehub/icons/es/Skywork/components/Mono"),
277
+ import("@lobehub/icons/es/Skywork/style"),
278
+ ]).then(([mono, style]) => ({ mono, style })),
279
+
280
+ // ── 推理/托管平台 ─────────────────────────────────
281
+ groq: () =>
282
+ Promise.all([
283
+ import("@lobehub/icons/es/Groq/components/Mono"),
284
+ import("@lobehub/icons/es/Groq/style"),
285
+ ]).then(([mono, style]) => ({ mono, style })),
286
+ together: () =>
287
+ Promise.all([
288
+ import("@lobehub/icons/es/Together/components/Mono"),
289
+ import("@lobehub/icons/es/Together/style"),
290
+ ]).then(([mono, style]) => ({ mono, style })),
291
+ deepinfra: () =>
292
+ Promise.all([
293
+ import("@lobehub/icons/es/DeepInfra/components/Mono"),
294
+ import("@lobehub/icons/es/DeepInfra/style"),
295
+ ]).then(([mono, style]) => ({ mono, style })),
296
+ fireworks: () =>
297
+ Promise.all([
298
+ import("@lobehub/icons/es/Fireworks/components/Mono"),
299
+ import("@lobehub/icons/es/Fireworks/style"),
300
+ ]).then(([mono, style]) => ({ mono, style })),
301
+ openrouter: () =>
302
+ Promise.all([
303
+ import("@lobehub/icons/es/OpenRouter/components/Mono"),
304
+ import("@lobehub/icons/es/OpenRouter/style"),
305
+ ]).then(([mono, style]) => ({ mono, style })),
306
+ novita: () =>
307
+ Promise.all([
308
+ import("@lobehub/icons/es/Novita/components/Mono"),
309
+ import("@lobehub/icons/es/Novita/style"),
310
+ ]).then(([mono, style]) => ({ mono, style })),
311
+ sambanova: () =>
312
+ Promise.all([
313
+ import("@lobehub/icons/es/SambaNova/components/Mono"),
314
+ import("@lobehub/icons/es/SambaNova/style"),
315
+ ]).then(([mono, style]) => ({ mono, style })),
316
+ cerebras: () =>
317
+ Promise.all([
318
+ import("@lobehub/icons/es/Cerebras/components/Mono"),
319
+ import("@lobehub/icons/es/Cerebras/style"),
320
+ ]).then(([mono, style]) => ({ mono, style })),
321
+ siliconcloud: () =>
322
+ Promise.all([
323
+ import("@lobehub/icons/es/SiliconCloud/components/Mono"),
324
+ import("@lobehub/icons/es/SiliconCloud/style"),
325
+ ]).then(([mono, style]) => ({ mono, style })),
326
+ ollama: () =>
327
+ Promise.all([
328
+ import("@lobehub/icons/es/Ollama/components/Mono"),
329
+ import("@lobehub/icons/es/Ollama/style"),
330
+ ]).then(([mono, style]) => ({ mono, style })),
331
+ lmstudio: () =>
332
+ Promise.all([
333
+ import("@lobehub/icons/es/LmStudio/components/Mono"),
334
+ import("@lobehub/icons/es/LmStudio/style"),
335
+ ]).then(([mono, style]) => ({ mono, style })),
336
+ huggingface: () =>
337
+ Promise.all([
338
+ import("@lobehub/icons/es/HuggingFace/components/Mono"),
339
+ import("@lobehub/icons/es/HuggingFace/style"),
340
+ ]).then(([mono, style]) => ({ mono, style })),
341
+ replicate: () =>
342
+ Promise.all([
343
+ import("@lobehub/icons/es/Replicate/components/Mono"),
344
+ import("@lobehub/icons/es/Replicate/style"),
345
+ ]).then(([mono, style]) => ({ mono, style })),
346
+ };
347
+
348
+ const _cache: Record<string, AvatarCtor | null> = {};
349
+ const _pending: Record<string, Promise<AvatarCtor | null>> = {};
350
+
351
+ async function get(key: string): Promise<AvatarCtor | null> {
352
+ if (key in _cache) return _cache[key] ?? null;
353
+ if (_pending[key]) return _pending[key];
354
+ const factory = MAP[key];
355
+ if (!factory) return null;
356
+ _pending[key] = factory()
357
+ .then(({ avatar, mono, style }) => {
358
+ const builtInAvatar = avatar?.default;
359
+ if (builtInAvatar) {
360
+ _cache[key] = builtInAvatar;
361
+ return builtInAvatar;
362
+ }
363
+
364
+ const Mono = mono?.default;
365
+ const comp = Mono && style ? createAvatarComponent(Mono, style) : null;
366
+ _cache[key] = comp;
367
+ return comp;
368
+ })
369
+ .catch(() => {
370
+ _cache[key] = null;
371
+ return null;
372
+ })
373
+ .finally(() => {
374
+ delete _pending[key];
375
+ });
376
+ return _pending[key];
377
+ }
378
+
379
+ /**
380
+ * Returns a lobehub Avatar React component for the model/provider, or null.
381
+ * Caller should fall back to default bot icon when null is returned.
382
+ */
383
+ export async function getModelAvatarComponent(
384
+ provider?: string,
385
+ model?: string,
386
+ cliProvider?: string
387
+ ): Promise<AvatarCtor | null> {
388
+ const m = (model || "").toLowerCase();
389
+ const p = (provider || "").toLowerCase();
390
+ const cliProviderKey = (cliProvider || "").toLowerCase();
391
+
392
+ if (cliProviderKey === "gemini") return get("gemini");
393
+ if (cliProviderKey === "copilot") return get("copilot");
394
+ if (cliProviderKey === "codex") return get("openai");
395
+ if (cliProviderKey === "claude") return get("claude");
396
+
397
+ // ── 按 model 名称匹配(优先,处理 openrouter/deepinfra 等聚合场景) ──
398
+ if (m.includes("claude")) return get("claude");
399
+ if (m.includes("gpt") || /\bo\d[-/]/.test(m)) return get("openai");
400
+ if (m.includes("gemini") || m.includes("gemma")) return get("gemini");
401
+ if (m.includes("deepseek")) return get("deepseek");
402
+ if (m.includes("qwen")) return get("qwen");
403
+ if (m.includes("grok")) return get("grok");
404
+ if (m.includes("mistral") || m.includes("mixtral")) return get("mistral");
405
+ if (m.includes("llama") || m.includes("meta/")) return get("llama");
406
+ if (m.includes("kimi")) return get("kimi");
407
+ if (m.includes("moonshot")) return get("moonshot");
408
+ if (m.includes("minimax") || m.includes("abab")) return get("minimax");
409
+ if (m.includes("glm") || m.includes("chatglm")) return get("glm");
410
+ if (m.includes("doubao")) return get("doubao");
411
+ if (m.includes("hunyuan")) return get("hunyuan");
412
+ if (m.includes("ernie") || m.includes("wenxin")) return get("wenxin");
413
+ if (m.includes("baichuan")) return get("baichuan");
414
+ if (m.includes("yi-") || /^yi\d/.test(m)) return get("yi");
415
+ if (m.includes("internlm")) return get("internlm");
416
+ if (m.includes("spark")) return get("spark");
417
+ if (m.includes("step-") || m.startsWith("step")) return get("stepfun");
418
+ if (m.includes("sensenova") || m.includes("nova-")) return get("sensenova");
419
+ if (m.includes("tiangong")) return get("tiangong");
420
+ if (m.includes("skywork")) return get("skywork");
421
+ if (m.includes("perplexity")) return get("perplexity");
422
+ if (m.includes("command")) return get("cohere");
423
+
424
+ // ── 按 provider 匹配 ──────────────────────────────
425
+ const providerKey = p.replace(/[-_\s]/g, "").toLowerCase();
426
+ return (await get(providerKey)) ?? (await get(p)) ?? null;
427
+ }
@@ -0,0 +1,45 @@
1
+ // ai/llm/models.ts
2
+
3
+ import type { Model } from "./types";
4
+
5
+ // 导入所有提供商的模型数据
6
+ import { deepSeekModels } from "integrations/deepseek/models";
7
+ import { googleModels } from "integrations/google/models";
8
+ import { openAIModels } from "integrations/openai/models";
9
+ import { deepinfraModels } from "./deepinfra";
10
+ import { openrouterModels } from "./openrouterModels";
11
+ import { fireworksModels } from "./fireworks";
12
+ import { mistralModels } from "./mistral";
13
+ import { mimoModels } from "./mimo";
14
+
15
+ /**
16
+ * @interface ModelWithProvider
17
+ * 扩展基础 Model 类型,增加了 provider 字段,用于UI显示和逻辑处理。
18
+ */
19
+ export interface ModelWithProvider extends Model {
20
+ provider: string;
21
+ }
22
+
23
+ /**
24
+ * 将一组模型打上 provider 标记的纯函数,方便复用和测试
25
+ */
26
+ const withProvider =
27
+ (provider: ModelWithProvider["provider"]) =>
28
+ (models: Model[]): ModelWithProvider[] =>
29
+ models.map((model) => ({ ...model, provider }));
30
+
31
+ /**
32
+ * @const ALL_MODELS
33
+ * 聚合了所有来源的模型数据,并为每个模型附加了其提供商信息。
34
+ * 这是整个应用中模型选择器的唯一数据源。
35
+ */
36
+ export const ALL_MODELS: ModelWithProvider[] = [
37
+ ...withProvider("google")(googleModels),
38
+ ...withProvider("openai")(openAIModels),
39
+ ...withProvider("openrouter")(openrouterModels),
40
+ ...withProvider("deepseek")(deepSeekModels),
41
+ ...withProvider("deepinfra")(deepinfraModels),
42
+ ...withProvider("fireworks")(fireworksModels),
43
+ ...withProvider("mistral")(mistralModels),
44
+ ...withProvider("mimo")(mimoModels),
45
+ ];