nolo-cli 0.1.10 → 0.1.12

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 (232) hide show
  1. package/README.md +0 -32
  2. package/agentRuntimeCommands.ts +1 -1
  3. package/client/compactDialog.ts +2 -5
  4. package/commandRegistry.ts +2 -2
  5. package/machineCommands.ts +28 -3
  6. package/package.json +5 -25
  7. package/ai/agent/_executeModel.ts +0 -118
  8. package/ai/agent/agentSlice.ts +0 -525
  9. package/ai/agent/appWorkingMemory.ts +0 -126
  10. package/ai/agent/avatarUtils.ts +0 -24
  11. package/ai/agent/buildEditingContext.ts +0 -373
  12. package/ai/agent/buildSystemPrompt.ts +0 -532
  13. package/ai/agent/cleanAgentMessages.ts +0 -140
  14. package/ai/agent/cliChatClient.ts +0 -119
  15. package/ai/agent/contextCompiler.ts +0 -107
  16. package/ai/agent/contextLayerContract.ts +0 -44
  17. package/ai/agent/createAgentSchema.ts +0 -234
  18. package/ai/agent/executeToolCall.ts +0 -58
  19. package/ai/agent/fetchAgentContexts.ts +0 -42
  20. package/ai/agent/generatePrompt.ts +0 -3
  21. package/ai/agent/getFullChatContextKeys.ts +0 -168
  22. package/ai/agent/hooks/fetchPublicAgents.ts +0 -133
  23. package/ai/agent/hooks/useAgentConfig.ts +0 -61
  24. package/ai/agent/hooks/useAgentDialog.ts +0 -35
  25. package/ai/agent/hooks/useAgentFormValidation.ts +0 -202
  26. package/ai/agent/hooks/usePublicAgents.ts +0 -473
  27. package/ai/agent/persistMessageWithFixedId.ts +0 -37
  28. package/ai/agent/planSlice.ts +0 -259
  29. package/ai/agent/referenceUtils.ts +0 -229
  30. package/ai/agent/runAgentBackground.ts +0 -238
  31. package/ai/agent/runAgentClientLoop.ts +0 -138
  32. package/ai/agent/runtimeGuidance.ts +0 -97
  33. package/ai/agent/runtimeServerBase.ts +0 -37
  34. package/ai/agent/server/fetchPublicAgents.ts +0 -128
  35. package/ai/agent/startParallelAgentStreams.ts +0 -424
  36. package/ai/agent/startupProtocol.ts +0 -53
  37. package/ai/agent/streamAgentChatTurn.ts +0 -1278
  38. package/ai/agent/streamAgentChatTurnUtils.ts +0 -738
  39. package/ai/agent/types.ts +0 -71
  40. package/ai/agent/utils/imageOutput.ts +0 -33
  41. package/ai/agent/utils/sortUtils.ts +0 -250
  42. package/ai/agent/web/referencePickerUtils.ts +0 -146
  43. package/ai/ai.locale.ts +0 -1079
  44. package/ai/chat/accumulateToolCallChunks.ts +0 -95
  45. package/ai/chat/fetchUtils.native.ts +0 -276
  46. package/ai/chat/fetchUtils.ts +0 -153
  47. package/ai/chat/parseApiError.ts +0 -64
  48. package/ai/chat/parseMultilineSSE.ts +0 -95
  49. package/ai/chat/sendOpenAICompletionsRequest.native.ts +0 -682
  50. package/ai/chat/sendOpenAICompletionsRequest.ts +0 -703
  51. package/ai/chat/sendOpenAIResponseRequest.ts +0 -491
  52. package/ai/chat/shouldUseServerProxy.ts +0 -18
  53. package/ai/chat/sseClient.native.ts +0 -91
  54. package/ai/chat/sseClient.ts +0 -67
  55. package/ai/chat/streamReader.native.ts +0 -31
  56. package/ai/chat/streamReader.ts +0 -62
  57. package/ai/chat/updateTotalUsage.ts +0 -72
  58. package/ai/context/buildReferenceContext.ts +0 -437
  59. package/ai/context/calculateContextUsage.ts +0 -133
  60. package/ai/context/retention.ts +0 -165
  61. package/ai/context/tokenUtils.ts +0 -78
  62. package/ai/index.ts +0 -1
  63. package/ai/llm/calculateGeminiImageTokens.ts +0 -57
  64. package/ai/llm/deepinfra.ts +0 -28
  65. package/ai/llm/fireworks.ts +0 -50
  66. package/ai/llm/generateRequestBody.ts +0 -165
  67. package/ai/llm/getModelContextWindow.ts +0 -84
  68. package/ai/llm/getNoloKey.ts +0 -31
  69. package/ai/llm/getPricing.ts +0 -199
  70. package/ai/llm/hooks/useModelPricing.ts +0 -75
  71. package/ai/llm/imagePricing.ts +0 -40
  72. package/ai/llm/isResponseAPIModel.ts +0 -13
  73. package/ai/llm/mimo.ts +0 -71
  74. package/ai/llm/mistral.ts +0 -22
  75. package/ai/llm/modelAvatar.ts +0 -427
  76. package/ai/llm/models.ts +0 -45
  77. package/ai/llm/openrouterModels.ts +0 -269
  78. package/ai/llm/providers.ts +0 -306
  79. package/ai/llm/reasoningModels.ts +0 -28
  80. package/ai/llm/types.ts +0 -59
  81. package/ai/llm/usageRequestOptions.ts +0 -59
  82. package/ai/memory/capture.ts +0 -148
  83. package/ai/memory/consolidate.ts +0 -104
  84. package/ai/memory/delete.ts +0 -147
  85. package/ai/memory/overlay.ts +0 -84
  86. package/ai/memory/query.ts +0 -38
  87. package/ai/memory/queryShared.ts +0 -160
  88. package/ai/memory/rank.ts +0 -105
  89. package/ai/memory/recentRelationshipRecap.ts +0 -249
  90. package/ai/memory/remember.ts +0 -167
  91. package/ai/memory/runtime.ts +0 -76
  92. package/ai/memory/store.ts +0 -20
  93. package/ai/memory/storeShared.ts +0 -76
  94. package/ai/memory/types.ts +0 -46
  95. package/ai/memory/understanding.ts +0 -349
  96. package/ai/memory/understandingGreeting.ts +0 -264
  97. package/ai/messages/type.ts +0 -20
  98. package/ai/policy/personalizationDialog.ts +0 -333
  99. package/ai/policy/runtimePolicy.ts +0 -440
  100. package/ai/policy/selfUpdateFields.ts +0 -48
  101. package/ai/policy/types.ts +0 -64
  102. package/ai/skills/referenceRuntime.ts +0 -274
  103. package/ai/skills/skillDiagnostics.ts +0 -251
  104. package/ai/skills/skillDocBuilder.ts +0 -139
  105. package/ai/skills/skillDocProtocol.ts +0 -434
  106. package/ai/skills/skillReferenceSummary.ts +0 -63
  107. package/ai/skills/skillSummaryMarker.ts +0 -26
  108. package/ai/token/calculatePrice.ts +0 -544
  109. package/ai/token/db.ts +0 -98
  110. package/ai/token/externalToolCost.ts +0 -330
  111. package/ai/token/hooks/useRecords.ts +0 -65
  112. package/ai/token/missingUsageEstimate.ts +0 -42
  113. package/ai/token/modelUsageQuery.ts +0 -252
  114. package/ai/token/normalizeUsage.ts +0 -84
  115. package/ai/token/openaiImageGenerationUsage.ts +0 -56
  116. package/ai/token/prepareTokenUsageData.ts +0 -88
  117. package/ai/token/query.ts +0 -88
  118. package/ai/token/queryUserTokens.ts +0 -59
  119. package/ai/token/resolveBillingTarget.ts +0 -52
  120. package/ai/token/saveTokenRecord.ts +0 -53
  121. package/ai/token/serverDialogProjection.ts +0 -78
  122. package/ai/token/serverTokenWriter.ts +0 -143
  123. package/ai/token/stats.ts +0 -21
  124. package/ai/token/tokenThunks.ts +0 -24
  125. package/ai/token/types.ts +0 -93
  126. package/ai/tools/agent/agentTools.ts +0 -176
  127. package/ai/tools/agent/agentUpdateShared.ts +0 -311
  128. package/ai/tools/agent/callAgentTool.ts +0 -139
  129. package/ai/tools/agent/createAgentTool.ts +0 -512
  130. package/ai/tools/agent/createDialogTool.ts +0 -69
  131. package/ai/tools/agent/createSkillAgentTool.ts +0 -62
  132. package/ai/tools/agent/parallelBudget.ts +0 -221
  133. package/ai/tools/agent/presets/appBuilderPreset.ts +0 -145
  134. package/ai/tools/agent/runLlmTool.ts +0 -96
  135. package/ai/tools/agent/runStreamingAgentTool.ts +0 -73
  136. package/ai/tools/agent/skillAgentArgs.ts +0 -106
  137. package/ai/tools/agent/skillAgentPreset.ts +0 -89
  138. package/ai/tools/agent/streamParallelAgentsTool.ts +0 -122
  139. package/ai/tools/agent/updateAgentTool.ts +0 -96
  140. package/ai/tools/agent/updateSelfTool.ts +0 -113
  141. package/ai/tools/amazonProductScraperTool.ts +0 -86
  142. package/ai/tools/apifyActorClient.ts +0 -45
  143. package/ai/tools/appEditGuard.ts +0 -372
  144. package/ai/tools/appReadSnapshot.ts +0 -153
  145. package/ai/tools/appTools.ts +0 -1549
  146. package/ai/tools/applyEditTool.ts +0 -256
  147. package/ai/tools/applyLineEditsTool.ts +0 -312
  148. package/ai/tools/browserTools/click.ts +0 -33
  149. package/ai/tools/browserTools/closeSession.ts +0 -29
  150. package/ai/tools/browserTools/common.ts +0 -27
  151. package/ai/tools/browserTools/openSession.ts +0 -48
  152. package/ai/tools/browserTools/readContent.ts +0 -38
  153. package/ai/tools/browserTools/selectOption.ts +0 -46
  154. package/ai/tools/browserTools/typeText.ts +0 -42
  155. package/ai/tools/category/createCategoryTool.ts +0 -66
  156. package/ai/tools/category/queryContentsByCategoryTool.ts +0 -69
  157. package/ai/tools/category/updateContentCategoryTool.ts +0 -75
  158. package/ai/tools/cfBrowserTools.ts +0 -319
  159. package/ai/tools/cfSpeechToTextTool.ts +0 -49
  160. package/ai/tools/checkEnvTool.ts +0 -65
  161. package/ai/tools/cloudflareCrawlTool.ts +0 -289
  162. package/ai/tools/codeSearchTool.ts +0 -111
  163. package/ai/tools/codeTools.ts +0 -101
  164. package/ai/tools/createDocTool.ts +0 -132
  165. package/ai/tools/createPlanTool.ts +0 -999
  166. package/ai/tools/createSkillDocTool.ts +0 -155
  167. package/ai/tools/createWorkflowTool.ts +0 -154
  168. package/ai/tools/deepseekOcrTool.ts +0 -34
  169. package/ai/tools/delayTool.ts +0 -31
  170. package/ai/tools/deleteSpacesTool.ts +0 -325
  171. package/ai/tools/deleteSpacesToolModel.ts +0 -159
  172. package/ai/tools/devReloadUtils.ts +0 -29
  173. package/ai/tools/dialogMessageSearch.ts +0 -137
  174. package/ai/tools/doctorSkillTool.ts +0 -72
  175. package/ai/tools/ecommerceScraperTool.ts +0 -86
  176. package/ai/tools/emailTools.ts +0 -549
  177. package/ai/tools/evalSkillTool.ts +0 -92
  178. package/ai/tools/exaSearchTool.ts +0 -64
  179. package/ai/tools/execBashTool.ts +0 -379
  180. package/ai/tools/executeSqlTool.ts +0 -192
  181. package/ai/tools/fetchWebpageSupport.ts +0 -309
  182. package/ai/tools/fetchWebpageTool.ts +0 -84
  183. package/ai/tools/geminiImagePreviewTool.ts +0 -361
  184. package/ai/tools/generateDocxTool.ts +0 -215
  185. package/ai/tools/googleSearchScraperTool.ts +0 -106
  186. package/ai/tools/importDataTool.ts +0 -133
  187. package/ai/tools/importSkillTool.ts +0 -162
  188. package/ai/tools/index.ts +0 -1858
  189. package/ai/tools/listFilesTool.ts +0 -82
  190. package/ai/tools/listUserSpacesTool.ts +0 -113
  191. package/ai/tools/modelUsageTools.ts +0 -142
  192. package/ai/tools/olmOcrTool.ts +0 -34
  193. package/ai/tools/openaiImageTool.ts +0 -218
  194. package/ai/tools/paddleOcrTool.ts +0 -34
  195. package/ai/tools/prepareTools.ts +0 -23
  196. package/ai/tools/readDocTool.ts +0 -84
  197. package/ai/tools/readFileTool.ts +0 -211
  198. package/ai/tools/readTool.ts +0 -163
  199. package/ai/tools/readXPostTool.ts +0 -233
  200. package/ai/tools/rememberMemoryTool.ts +0 -84
  201. package/ai/tools/remotionVideoTool.ts +0 -151
  202. package/ai/tools/searchDialogMessagesTool.ts +0 -222
  203. package/ai/tools/searchRepoTool.ts +0 -115
  204. package/ai/tools/searchWorkspaceTool.ts +0 -259
  205. package/ai/tools/skillFollowup.ts +0 -86
  206. package/ai/tools/surfWeatherTool.ts +0 -169
  207. package/ai/tools/table/addTableRowTool.ts +0 -217
  208. package/ai/tools/table/createTableTool.ts +0 -315
  209. package/ai/tools/table/rowTools.ts +0 -366
  210. package/ai/tools/table/schemaTools.ts +0 -244
  211. package/ai/tools/table/shareTableTool.ts +0 -148
  212. package/ai/tools/table/toolShared.ts +0 -129
  213. package/ai/tools/toolApiClient.ts +0 -198
  214. package/ai/tools/toolNameAliases.ts +0 -57
  215. package/ai/tools/toolResultError.ts +0 -42
  216. package/ai/tools/toolRunSlice.ts +0 -303
  217. package/ai/tools/toolSchemaCompatibility.ts +0 -53
  218. package/ai/tools/toolVisibility.ts +0 -4
  219. package/ai/tools/types.ts +0 -20
  220. package/ai/tools/uiAskChoiceTool.ts +0 -104
  221. package/ai/tools/updateContentTitleTool.ts +0 -84
  222. package/ai/tools/updateDocTool.ts +0 -105
  223. package/ai/tools/updateUserPreferenceProfileTool.ts +0 -145
  224. package/ai/tools/whisperTool.ts +0 -77
  225. package/ai/tools/writeFileTool.ts +0 -210
  226. package/ai/tools/youtubeScraperTool.ts +0 -116
  227. package/ai/tools/ziweiChartTool.ts +0 -678
  228. package/ai/types.ts +0 -55
  229. package/ai/workflow/workflowExecutor.ts +0 -323
  230. package/ai/workflow/workflowSlice.ts +0 -73
  231. package/ai/workflow/workflowTypes.ts +0 -106
  232. package/connector-experimental/index.ts +0 -5
@@ -1,427 +0,0 @@
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
- }
package/ai/llm/models.ts DELETED
@@ -1,45 +0,0 @@
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
- ];