@eum-agent/llm-provider-deepseek 0.0.0-stage → 1.2.0

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.
package/assets/NOTICE ADDED
@@ -0,0 +1,28 @@
1
+ Vendor marks from lobehub/lobe-icons (@lobehub/icons-static-svg 1.95.1, MIT), except where noted. Each file is named for the catalogue row contributed by its owning provider extension.
2
+
3
+ - zhipu*.svg: the Z glyph from Z.ai's own logo (https://z-cdn.chatglm.cn/z-ai/static/logo.svg), without its dark tile.
4
+ - kimi-coding*.svg: the K filled black, as kimi.com's light-scheme favicon draws it; the lobe-icons original fills it white.
5
+
6
+ The lobe-icons marks are distributed under the MIT License:
7
+
8
+ MIT License
9
+
10
+ Copyright (c) 2023 LobeHub
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ <svg height="24" style="flex:none;line-height:1" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><title>DeepSeek</title><path d="M23.748 4.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.329.14a5.526 5.526 0 01-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365 11.365 0 00-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055 3.055 0 01-.465.137 9.597 9.597 0 00-2.883-.102c-1.885.21-3.39 1.102-4.497 2.623C.082 8.606-.231 10.684.152 12.85c.403 2.284 1.569 4.175 3.36 5.653 1.858 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.133-.284 4.994-1.86.47.234.962.327 1.78.397.63.059 1.236-.03 1.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926 1.096-1.296 2.746-2.642 3.392-7.003.05-.347.007-.565 0-.845-.004-.17.035-.237.23-.256a4.173 4.173 0 001.545-.475c1.396-.763 1.96-2.015 2.093-3.517.02-.23-.004-.467-.247-.588zM11.581 18c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696 4.696 0 011.529-.039c2.132.312 3.946 1.265 5.468 2.774.868.86 1.525 1.887 2.202 2.891.72 1.066 1.494 2.082 2.48 2.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.614zm1-6.44a.306.306 0 01.415-.287.302.302 0 01.2.288.306.306 0 01-.31.307.303.303 0 01-.304-.308zm3.11 1.596c-.2.081-.399.151-.59.16a1.245 1.245 0 01-.798-.254c-.274-.23-.47-.358-.552-.758a1.73 1.73 0 01.016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559 0 01-.254-.078c-.11-.054-.2-.19-.114-.358.028-.054.16-.186.192-.21.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.195-.019.354-.25.452z" fill="#4D6BFE"></path></svg>
package/dist/index.js ADDED
@@ -0,0 +1,386 @@
1
+ //#endregion
2
+ //#region src/catalog.ts
3
+ const catalog = {
4
+ vendors: [{
5
+ kind: "vendor",
6
+ id: "deepseek",
7
+ logo: "data:image/svg+xml,%3Csvg%20height%3D%2224%22%20style%3D%22flex%3Anone%3Bline-height%3A1%22%20viewBox%3D%220%200%2024%2024%22%20width%3D%2224%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Ctitle%3EDeepSeek%3C%2Ftitle%3E%3Cpath%20d%3D%22M23.748%204.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434%201.202-.422%201.84.027%201.436.633%202.58%201.838%203.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.329.14a5.526%205.526%200%2001-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365%2011.365%200%2000-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055%203.055%200%2001-.465.137%209.597%209.597%200%2000-2.883-.102c-1.885.21-3.39%201.102-4.497%202.623C.082%208.606-.231%2010.684.152%2012.85c.403%202.284%201.569%204.175%203.36%205.653%201.858%201.533%203.997%202.284%206.438%202.14%201.482-.085%203.133-.284%204.994-1.86.47.234.962.327%201.78.397.63.059%201.236-.03%201.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926%201.096-1.296%202.746-2.642%203.392-7.003.05-.347.007-.565%200-.845-.004-.17.035-.237.23-.256a4.173%204.173%200%20001.545-.475c1.396-.763%201.96-2.015%202.093-3.517.02-.23-.004-.467-.247-.588zM11.581%2018c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696%204.696%200%20011.529-.039c2.132.312%203.946%201.265%205.468%202.774.868.86%201.525%201.887%202.202%202.891.72%201.066%201.494%202.082%202.48%202.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.614zm1-6.44a.306.306%200%2001.415-.287.302.302%200%2001.2.288.306.306%200%2001-.31.307.303.303%200%2001-.304-.308zm3.11%201.596c-.2.081-.399.151-.59.16a1.245%201.245%200%2001-.798-.254c-.274-.23-.47-.358-.552-.758a1.73%201.73%200%2001.016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559%200%2001-.254-.078c-.11-.054-.2-.19-.114-.358.028-.054.16-.186.192-.21.356-.202.767-.136%201.146.016.352.144.618.408%201.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.195-.019.354-.25.452z%22%20fill%3D%22%234D6BFE%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E",
8
+ name: "DeepSeek",
9
+ region: null,
10
+ market: "domestic",
11
+ catalogKey: "deepseek",
12
+ canListModels: true,
13
+ endpoints: [{
14
+ baseUrl: "https://api.deepseek.com",
15
+ thinkingSwitch: true,
16
+ type: "deepseek",
17
+ endpointId: "openai",
18
+ protocolIds: [
19
+ "openai",
20
+ "openai-responses",
21
+ "anthropic"
22
+ ]
23
+ }]
24
+ }],
25
+ snapshot: { "deepseek": {
26
+ "deepseek-v4-flash": {
27
+ "id": "deepseek-v4-flash",
28
+ "name": "DeepSeek V4 Flash",
29
+ "family": "deepseek-flash",
30
+ "reasoning": true,
31
+ "reasoning_options": [{ "type": "toggle" }, {
32
+ "type": "effort",
33
+ "values": [
34
+ "low",
35
+ "high",
36
+ "max"
37
+ ]
38
+ }],
39
+ "temperature": true,
40
+ "tool_call": true,
41
+ "attachment": true,
42
+ "modalities": {
43
+ "input": ["text", "image"],
44
+ "output": ["text"]
45
+ },
46
+ "limit": {
47
+ "context": 1048576,
48
+ "output": 393216
49
+ },
50
+ "release_date": "2026-10-17"
51
+ },
52
+ "deepseek-flash": {
53
+ "id": "deepseek-flash",
54
+ "name": "DeepSeek V4.1 Flash 1017",
55
+ "family": "deepseek-flash",
56
+ "reasoning": true,
57
+ "reasoning_options": [{ "type": "toggle" }, {
58
+ "type": "effort",
59
+ "values": [
60
+ "low",
61
+ "high",
62
+ "max"
63
+ ]
64
+ }],
65
+ "temperature": true,
66
+ "tool_call": true,
67
+ "attachment": true,
68
+ "modalities": {
69
+ "input": ["text", "image"],
70
+ "output": ["text"]
71
+ },
72
+ "limit": {
73
+ "context": 1048576,
74
+ "output": 393216
75
+ },
76
+ "release_date": "2026-10-17"
77
+ },
78
+ "deepseek-v4-pro": {
79
+ "id": "deepseek-v4-pro",
80
+ "name": "DeepSeek V4 Pro",
81
+ "family": "deepseek-thinking",
82
+ "reasoning": true,
83
+ "reasoning_options": [{ "type": "toggle" }, {
84
+ "type": "effort",
85
+ "values": [
86
+ "low",
87
+ "high",
88
+ "max"
89
+ ]
90
+ }],
91
+ "temperature": true,
92
+ "tool_call": true,
93
+ "attachment": false,
94
+ "modalities": {
95
+ "input": ["text"],
96
+ "output": ["text"]
97
+ },
98
+ "limit": {
99
+ "context": 1048576,
100
+ "output": 393216
101
+ },
102
+ "release_date": "2026-08-13"
103
+ },
104
+ "deepseek-v4-flash-vision-exp": {
105
+ "id": "deepseek-v4-flash-vision-exp",
106
+ "name": "DeepSeek V4 Flash Vision Exp",
107
+ "family": "deepseek-flash",
108
+ "reasoning": true,
109
+ "reasoning_options": [{ "type": "toggle" }, {
110
+ "type": "effort",
111
+ "values": [
112
+ "low",
113
+ "high",
114
+ "max"
115
+ ]
116
+ }],
117
+ "temperature": true,
118
+ "tool_call": true,
119
+ "attachment": true,
120
+ "modalities": {
121
+ "input": ["text", "image"],
122
+ "output": ["text"]
123
+ },
124
+ "limit": {
125
+ "context": 1048576,
126
+ "output": 393216
127
+ },
128
+ "release_date": "2026-10-17"
129
+ }
130
+ } },
131
+ snapshotAt: Date.parse("2026-11-18")
132
+ };
133
+ //#endregion
134
+ //#region src/facts.ts
135
+ const modelFacts = {
136
+ revisions: [],
137
+ presets: [
138
+ "deepseek-v4-flash-vision-exp",
139
+ "deepseek-v4-flash",
140
+ "deepseek-v4-pro",
141
+ "deepseek-flash"
142
+ ].map((model) => ({
143
+ model,
144
+ entry: { outputLimit: {
145
+ ordinary: 16384,
146
+ thinking: 32768
147
+ } }
148
+ }))
149
+ };
150
+ //#endregion
151
+ //#region src/resources.ts
152
+ function failure(detail) {
153
+ const code = detail === "Resource request failed" ? "source-failed" : "invalid-response";
154
+ return Object.assign(new Error(code), {
155
+ name: "ProviderResourceFailure",
156
+ code,
157
+ retryable: false
158
+ });
159
+ }
160
+ async function readResourceSource(input) {
161
+ if (input.sourceId !== "balance" || input.endpointId !== "openai") throw failure("Invalid resource source");
162
+ if (!input.secrets.apiKey) return {
163
+ kind: "unavailable",
164
+ reason: "auth-required"
165
+ };
166
+ const response = await input.queryJSON({
167
+ requestId: "balance",
168
+ headers: { Authorization: `Bearer ${input.secrets.apiKey}` }
169
+ });
170
+ if (response.status === 401) return {
171
+ kind: "unavailable",
172
+ reason: "auth-required"
173
+ };
174
+ if (response.status === 403) return {
175
+ kind: "unavailable",
176
+ reason: "permission-denied"
177
+ };
178
+ if (response.status !== 200) throw failure("Resource request failed");
179
+ const body = response.body;
180
+ if (!body || typeof body.is_available !== "boolean" || !Array.isArray(body.balance_infos)) throw failure("Invalid resource response");
181
+ const resources = [];
182
+ for (const row of body.balance_infos) {
183
+ if (!row || !["CNY", "USD"].includes(row.currency)) throw failure("Invalid resource currency");
184
+ const currency = row.currency;
185
+ for (const [field, id, en, zh] of [
186
+ [
187
+ "total_balance",
188
+ "balance",
189
+ "Available balance",
190
+ "\u53ef\u7528\u4f59\u989d"
191
+ ],
192
+ [
193
+ "granted_balance",
194
+ "granted",
195
+ "Granted balance",
196
+ "\u8d60\u9001\u4f59\u989d"
197
+ ],
198
+ [
199
+ "topped_up_balance",
200
+ "topped-up",
201
+ "Topped-up balance",
202
+ "\u5145\u503c\u4f59\u989d"
203
+ ]
204
+ ]) {
205
+ const value = row[field];
206
+ if (value === void 0) continue;
207
+ if (typeof value !== "string" || !/^-?(0|[1-9]\d*)(\.\d+)?$/.test(value)) throw failure("Invalid resource amount");
208
+ resources.push({
209
+ kind: "balance",
210
+ id: `${id}-${currency}`,
211
+ group: id === "balance" ? "available-balance" : "balance-components",
212
+ labels: {
213
+ "en-US": en,
214
+ "zh-CN": zh
215
+ },
216
+ meaning: /^0(?:\.0+)?$/.test(value) ? "exhausted" : value.startsWith("-") ? "exhausted" : "available",
217
+ valueOrigin: "reported",
218
+ remaining: {
219
+ value: value.includes(".") ? value.replace(/0+$/, "").replace(/\.$/, "").replace(/^-0$/, "0") : value.replace(/^-0$/, "0"),
220
+ unit: {
221
+ kind: "currency",
222
+ code: currency
223
+ }
224
+ },
225
+ ...id === "balance" ? {} : { relationships: [{
226
+ kind: "part-of",
227
+ resourceId: `balance-${currency}`,
228
+ ...row.total_balance === void 0 ? { unavailable: true } : {}
229
+ }] }
230
+ });
231
+ }
232
+ }
233
+ return {
234
+ kind: "ready",
235
+ resources,
236
+ restrictions: [{
237
+ id: "account-unavailable",
238
+ labels: {
239
+ "en-US": "Account unavailable",
240
+ "zh-CN": "\u8d26\u6237\u4e0d\u53ef\u7528"
241
+ },
242
+ active: !body.is_available
243
+ }]
244
+ };
245
+ }
246
+ const resourceCapability = {
247
+ support: "supported",
248
+ applicability: {
249
+ kind: "base-url",
250
+ defaultBaseUrl: "https://api.deepseek.com",
251
+ allowedBaseUrls: [
252
+ "https://api.deepseek.com",
253
+ "https://api.deepseek.com/v1",
254
+ "https://api.deepseek.com/anthropic/v1"
255
+ ]
256
+ },
257
+ sources: [{
258
+ id: "balance",
259
+ labels: {
260
+ "en-US": "Account balance",
261
+ "zh-CN": "\u8d26\u6237\u4f59\u989d"
262
+ },
263
+ optional: false,
264
+ requests: [{
265
+ id: "balance",
266
+ method: "GET",
267
+ url: "https://api.deepseek.com/user/balance"
268
+ }],
269
+ allowedHeaderNames: ["Authorization"]
270
+ }],
271
+ presets: [{
272
+ id: "available-balance",
273
+ labels: {
274
+ "en-US": "Available balance",
275
+ "zh-CN": "\u53ef\u7528\u4f59\u989d"
276
+ },
277
+ sourceId: "balance",
278
+ order: 0,
279
+ recommended: true,
280
+ format: "amount",
281
+ match: { group: "available-balance" }
282
+ }]
283
+ };
284
+ //#endregion
285
+ //#region src/routing.ts
286
+ function connectionConfig(endpoint, protocolId, config, aliases = []) {
287
+ const defaults = Object.values(endpoint.capabilities).find((one) => one.protocolIds.includes(protocolId))?.protocolDefaults?.[protocolId] ?? {};
288
+ const configured = config.baseUrl;
289
+ const canonical = [
290
+ endpoint.defaults?.baseUrl,
291
+ ...Object.values(endpoint.capabilities).flatMap((one) => Object.values(one.protocolDefaults ?? {}).map((value) => value.baseUrl)),
292
+ ...aliases
293
+ ].filter((value) => typeof value === "string");
294
+ const isOfficial = configured === void 0 || typeof configured === "string" && canonical.some((value) => value.replace(/\/+$/, "") === configured.replace(/\/+$/, ""));
295
+ const selected = defaults.baseUrl ?? endpoint.defaults?.baseUrl;
296
+ return {
297
+ ...endpoint.defaults,
298
+ ...defaults,
299
+ ...config,
300
+ ...isOfficial && selected !== void 0 ? { baseUrl: selected } : {}
301
+ };
302
+ }
303
+ //#endregion
304
+ //#region src/type.ts
305
+ const TYPE = "deepseek";
306
+ const endpoints = [{
307
+ id: "openai",
308
+ label: "DeepSeek API",
309
+ resourceCapability,
310
+ capabilities: { chat: {
311
+ protocolIds: [
312
+ "openai",
313
+ "openai-responses",
314
+ "anthropic"
315
+ ],
316
+ listingVia: {
317
+ endpointId: "openai",
318
+ protocolId: "openai"
319
+ },
320
+ defaultProtocolId: "openai-responses",
321
+ protocolDefaults: { anthropic: { baseUrl: "https://api.deepseek.com/anthropic/v1" } }
322
+ } },
323
+ defaults: { baseUrl: "https://api.deepseek.com" },
324
+ credentialGroup: "deepseek"
325
+ }];
326
+ const protocolOptions = {
327
+ openai: {
328
+ reasoningReplay: "reasoning-content",
329
+ thinkingField: true
330
+ },
331
+ "openai-responses": {
332
+ reasoningReplay: "reasoning-content",
333
+ reasoningSummary: false,
334
+ effortCache: false,
335
+ promptCacheKey: false
336
+ },
337
+ anthropic: {
338
+ reasoningReplay: "unsigned-thinking",
339
+ effortCache: false,
340
+ cacheBreakpoints: false,
341
+ thinkingEffort: true,
342
+ thinkingBeta: false,
343
+ thinkingMode: "enabled"
344
+ }
345
+ };
346
+ function deepseekProviderType(support) {
347
+ return {
348
+ type: TYPE,
349
+ listingContractVersion: "capacity-listing-v1",
350
+ modelFacts,
351
+ label: "DeepSeek",
352
+ fields: [{
353
+ key: "apiKey",
354
+ kind: "secret",
355
+ label: "API Key",
356
+ required: true
357
+ }],
358
+ endpoints,
359
+ readResourceSource,
360
+ catalog: support ? {
361
+ ...catalog,
362
+ source: support.catalogueSource("https://models.dev/api.json", "models")
363
+ } : catalog,
364
+ prepareConnection(input) {
365
+ const endpoint = endpoints.find((one) => one.id === input.endpointId);
366
+ if (!endpoint || !Object.values(endpoint.capabilities).some((one) => one.protocolIds.includes(input.protocolId))) throw new Error("unsupported supplier endpoint or protocol");
367
+ return {
368
+ config: connectionConfig(endpoint, input.protocolId, input.config, endpoints.map((one) => one.defaults.baseUrl)),
369
+ options: protocolOptions[input.protocolId] ?? {}
370
+ };
371
+ }
372
+ };
373
+ }
374
+ //#endregion
375
+ //#region src/index.ts
376
+ const TOOL_NAMES = [];
377
+ const plugin = {
378
+ name: "@eum-agent/llm-provider-deepseek",
379
+ requires: ["model-catalogue-sources"],
380
+ apply(ctx) {
381
+ const support = ctx.services.get("model-catalogue-sources");
382
+ ctx.modelProviders.register(deepseekProviderType(support));
383
+ }
384
+ };
385
+ //#endregion
386
+ export { TOOL_NAMES, plugin as default };
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "@eum-agent/llm-provider-deepseek",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "displayName": {
4
+ "en-US": "DeepSeek Model Connection",
5
+ "zh-CN": "模型接入 · DeepSeek"
6
+ },
7
+ "version": "1.2.0",
8
+ "type": "module",
9
+ "description": "DeepSeek model provider using registered OpenAI and Anthropic protocols",
10
+ "license": "MIT",
11
+ "exports": {
12
+ ".": {
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "assets"
19
+ ],
20
+ "devDependencies": {
21
+ "@eum-agent/plugin": "1.2.0"
22
+ },
23
+ "dependencies": {
24
+ "zod": "^4.4.3"
25
+ },
26
+ "yaoguang": {
27
+ "description": {
28
+ "en-US": "DeepSeek model provider using registered OpenAI and Anthropic protocols",
29
+ "zh-CN": "通过已注册的 OpenAI 与 Anthropic 协议接入 DeepSeek 模型"
30
+ },
31
+ "dependencies": {
32
+ "@eum-agent/llm-management": "1.2.0"
33
+ },
34
+ "kind": "extension"
35
+ },
36
+ "scripts": {
37
+ "build": "tsdown",
38
+ "test": "vitest run",
39
+ "typecheck": "tsc --noEmit"
40
+ }
6
41
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.