@namzu/deepseek 2.2.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @namzu/deepseek
2
2
 
3
+ ## 2.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 1ed55ae: A reply the service stopped with a content filter or safety block now sets `refusal: {}` on its finish chunk next to `finishReason: 'content_filter'` (OpenAI Chat Completions and Codex, DeepSeek, HTTP in both dialects, OpenRouter, Bedrock, Google including a blocked prompt, Zen). The finish reason is unchanged. `@namzu/sdk` reads the field to tell a declined request from an empty reply and no longer retries it as an empty completion; nothing else changes for these drivers.
8
+
9
+ ## 2.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - dd0f7eb: Reasoning effort now works on the native driver: it is sent as `reasoning_effort` (the vendor's documented field), so `NAMZU_EFFORT_LEVEL=max` no longer errors. `minimal` goes to `low`, `medium` and `xhigh` to `high`, `ultra` to `max` (the vendor's own mapping), and a level the model's `effort.supported_levels` lacks falls to the nearest offered one. `none` turns thinking off; `reasoningEffortLevelsFor` and `reasoningEffortDefaultFor` publish the menu and default. New export `resolveDeepSeekEffort`; `assertEffortUnsupported` is deprecated and no longer called. A call that sets `temperature` and friends with an effort other than `none` is still refused.
14
+ - dd0f7eb: `deepseek-flash`, the vendor's current Flash id, is now in the catalogue and accepts images; `deepseek-v4-pro` stays text only, and `deepseek-v4-flash` and `deepseek-v4-flash-vision-exp` stay as the legacy names the vendor still serves. The driver reads `context_window` and `max_output_tokens` from the models endpoint when the vendor returns them and falls back to the documented 1,000,000 / 384,000, so compaction is measured against the real window instead of a 64,000-token guess. An image sent to a model that does not take one now names `deepseek-flash` in the error. The documented numbers are offered only on the vendor's own host (a custom `baseURL` gets what the listing reports), and `DEEPSEEK_CAPABILITIES` no longer declares `maxOutputTokens` driver-wide; the summary trigger is unchanged at 967,000 because the reserve is capped at 20,000 anyway.
15
+
3
16
  ## 2.2.0
4
17
 
5
18
  ### Minor Changes
package/README.md CHANGED
@@ -50,11 +50,11 @@ registerDeepSeek() // once, at startup
50
50
  const { provider } = ProviderRegistry.create({
51
51
  type: 'deepseek',
52
52
  apiKey: process.env.DEEPSEEK_API_KEY ?? '',
53
- model: 'deepseek-v4-flash',
53
+ model: 'deepseek-flash',
54
54
  })
55
55
 
56
56
  for await (const chunk of provider.chatStream({
57
- model: 'deepseek-v4-flash',
57
+ model: 'deepseek-flash',
58
58
  messages: [{ role: 'user', content: 'Is 91 prime?' }],
59
59
  })) {
60
60
  if (chunk.delta.reasoning?.text) process.stderr.write(chunk.delta.reasoning.text)
@@ -62,13 +62,29 @@ for await (const chunk of provider.chatStream({
62
62
  }
63
63
  ```
64
64
 
65
- The built-in catalogue offers `deepseek-v4-flash`, `deepseek-v4-pro`, and
66
- `deepseek-v4-flash-vision-exp`. `deepseek-chat` and `deepseek-reasoner` were
65
+ The built-in catalogue offers `deepseek-flash` (the current Flash model, which
66
+ takes images), `deepseek-v4-pro` (text only), and the legacy names
67
+ `deepseek-v4-flash` and `deepseek-v4-flash-vision-exp`, which the vendor still
68
+ serves from the Flash model. `deepseek-chat` and `deepseek-reasoner` were
67
69
  discontinued on 2026-07-24 and are not aliases.
68
70
 
71
+ ## Context window
72
+
73
+ The vendor documents a 1M-token context and a 384K-token output cap for every
74
+ current model (one row for `deepseek-flash` and `deepseek-v4-pro` on
75
+ https://api-docs.deepseek.com/quick_start/pricing). The driver asks the models
76
+ endpoint first and uses its `context_window` and `max_output_tokens` when the
77
+ vendor returns them; those two fields are optional there, so the documented
78
+ limits are only the fallback for the ids the driver lists, and only on the vendor's own host: behind a custom `baseURL` the driver
79
+ offers just what the listing reports. The runtime measures
80
+ compaction against that window, so the first summary is due at 967,000 tokens,
81
+ not at the 32,000 that a 64,000-token guess produced. An id the driver neither
82
+ lists nor was told about is left to the SDK's table, which keeps a conservative
83
+ 64,000 for it.
84
+
69
85
  ## Image input
70
86
 
71
- Only `deepseek-v4-flash-vision-exp` accepts images. User attachments are sent
87
+ `deepseek-flash` and the legacy `deepseek-v4-flash-vision-exp` accept images. User attachments are sent
72
88
  as ordered `image_url` data-URL parts. Images returned by tools keep their
73
89
  `role: "tool"` result and follow it in a separate user image message, so the
74
90
  tool-call/result sequence remains valid. PNG, JPEG, WebP and GIF are accepted.
@@ -91,9 +107,24 @@ portable assistant/tool history and omits the foreign native reasoning field.
91
107
 
92
108
  Turn it off per call with `thinking: { type: 'disabled' }`.
93
109
 
94
- Two parameters are **refused** rather than sent, because the vendor accepts
95
- them and applies neither: `effort`, and the sampling parameters while thinking
96
- is on. Both refusals can be opted out of in the driver configuration.
110
+ ### Effort
111
+
112
+ Effort rides on `reasoning_effort`, the field the vendor documents, beside
113
+ `thinking`. The vendor offers `low`, `high` and `max` (default `high`); the
114
+ models endpoint's `effort.supported_levels` and `default_level` are read once
115
+ per session and published through `reasoningEffortLevelsFor` and
116
+ `reasoningEffortDefaultFor` (plus `none`, which turns thinking off). Namzu's
117
+ wider vocabulary goes through the vendor's own mapping: `minimal` to `low`,
118
+ `medium` and `xhigh` to `high`, `ultra` to `max`. If the model's menu lacks the
119
+ mapped level, the nearest offered one is sent, the lower one on a tie
120
+ (`resolveDeepSeekEffort` says which). `none` is sent as
121
+ `thinking: { type: 'disabled' }`, and an explicit `thinking: disabled` wins over
122
+ a level, as it does at the vendor. Without `maxTokens` the vendor's default
123
+ output is 64K in thinking mode and 128K at `max`.
124
+
125
+ The sampling parameters (`temperature`, `topP` and the two penalties) are
126
+ **refused** while thinking is on, because the vendor accepts them and applies
127
+ none; `samplingInThinkingMode: 'ignore'` sends them anyway.
97
128
 
98
129
  ## Documentation
99
130
 
package/dist/client.d.ts CHANGED
@@ -11,7 +11,7 @@ export declare const DEEPSEEK_CAPABILITIES: ProviderCapabilities;
11
11
  * below that turns on "thinking is enabled" has to read it this way, or it
12
12
  * applies to explicit callers only and misses the common case entirely.
13
13
  */
14
- export declare function thinkingEnabled(thinking: ThinkingConfig | undefined): boolean;
14
+ export declare function thinkingEnabled(thinking: ThinkingConfig | undefined, effort?: ReasoningEffort): boolean;
15
15
  /**
16
16
  * Refuse a sampling parameter that thinking mode will discard.
17
17
  *
@@ -39,8 +39,33 @@ export declare function assertSamplingUsable(params: ChatCompletionParams, mode:
39
39
  * The vendor's Anthropic-format endpoint does take `reasoning.effort`. A
40
40
  * driver built on that wire could honour this; this one is built on Chat
41
41
  * Completions and says so.
42
+ *
43
+ * @deprecated The driver now carries effort on `reasoning_effort`, the field
44
+ * the vendor's Chat Completions reference documents (the field measured here
45
+ * earlier was `thinking.effort`, which the vendor never defined). Nothing in
46
+ * this package calls it any more; use {@link resolveDeepSeekEffort}.
42
47
  */
43
48
  export declare function assertEffortUnsupported(params: ChatCompletionParams): void;
49
+ /** The effort levels the vendor's pages list, in the order they rank. */
50
+ declare const VENDOR_EFFORT_ORDER: readonly ["low", "high", "max"];
51
+ type VendorEffort = (typeof VENDOR_EFFORT_ORDER)[number];
52
+ export interface DeepSeekEffortResolution {
53
+ /** `none` turns thinking off; otherwise the level sent as `reasoning_effort`. */
54
+ readonly level: VendorEffort | 'none';
55
+ /** True when the level asked for is not the level sent. */
56
+ readonly mapped: boolean;
57
+ }
58
+ /**
59
+ * Turn a requested effort into the one this model offers.
60
+ *
61
+ * `none` is thinking off. A level the model offers is sent as is. Any other
62
+ * level goes through the vendor's documented mapping (`medium` and `xhigh`
63
+ * to `high`, `minimal` to `low`, `ultra` to `max`); if the model's menu lacks
64
+ * that target, the nearest offered level is used, the lower one on a tie, and
65
+ * `mapped` says so. It never throws: a level this model does not offer must
66
+ * degrade to its neighbour rather than fail a run that asked for more thought.
67
+ */
68
+ export declare function resolveDeepSeekEffort(requested: ReasoningEffort, offered?: readonly string[]): DeepSeekEffortResolution;
44
69
  export declare function toDeepSeekMessages(messages: ChatCompletionParams['messages'], targetRoute: ProviderRoute): ChatCompletionMessageParam[];
45
70
  export declare function toDeepSeekTools(params: ChatCompletionParams): ChatCompletionTool[] | undefined;
46
71
  export declare class DeepSeekProvider implements LLMProvider {
@@ -50,13 +75,38 @@ export declare class DeepSeekProvider implements LLMProvider {
50
75
  private client;
51
76
  private defaultModel?;
52
77
  private samplingMode;
78
+ private vendorLimits;
79
+ private readonly documentedLimits;
53
80
  constructor(config: DeepSeekConfig);
54
81
  private resolveModel;
55
- /** This Chat Completions endpoint explicitly carries no effort control. */
56
- reasoningEffortLevelsFor(_model: string): readonly ReasoningEffort[];
82
+ /** Last models-endpoint answer, once a turn has fetched it; the sync menus read this. */
83
+ private vendorSnapshot;
84
+ /**
85
+ * `none` (thinking off) plus the levels the models endpoint lists for the
86
+ * model, or the vendor's documented low, high and max until it has been read.
87
+ */
88
+ reasoningEffortLevelsFor(model: string): readonly ReasoningEffort[];
89
+ /** The level a request without one runs at: the endpoint's `default_level`, else `high`. */
90
+ reasoningEffortDefaultFor(model: string): ReasoningEffort;
57
91
  chatStream(params: ChatCompletionParams): AsyncIterable<StreamChunk>;
92
+ /**
93
+ * What the vendor's models endpoint says about each model it lists. The
94
+ * endpoint may leave `context_window` and `max_output_tokens` out (both are
95
+ * optional there), so an absent field is simply not an answer. A failed
96
+ * request is not cached: the next turn asks again.
97
+ */
98
+ private fetchVendorLimits;
99
+ /**
100
+ * The window the runtime measures compaction against: what the vendor's
101
+ * models endpoint reports for the id when it reports one, else the
102
+ * documented limit of a model this driver lists, else `undefined` rather
103
+ * than a guess, which leaves the SDK's table to answer for it. The vendor
104
+ * answers first and the built-in table is only the fallback.
105
+ */
106
+ resolveContextWindow(model: string, signal?: AbortSignal): Promise<number | undefined>;
58
107
  probeCredential(signal?: AbortSignal): Promise<void>;
59
108
  listModels(signal?: AbortSignal): Promise<ModelInfo[]>;
60
109
  healthCheck(): Promise<boolean>;
61
110
  }
111
+ export {};
62
112
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,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AC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAMpD,UAAU,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IA8BtD,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAQrC"}
package/dist/client.js CHANGED
@@ -1,5 +1,14 @@
1
1
  import { ProviderRequestError, attributionHeaders, isCallerAbortError, isProviderRequestError, providerVendorError, toToolResultBlocks, } from '@namzu/sdk';
2
2
  import OpenAI from 'openai';
3
+ /**
4
+ * What the vendor documents for every current model: a 1M-token context and a
5
+ * 384K-token output cap (https://api-docs.deepseek.com/quick_start/pricing,
6
+ * one row for `deepseek-flash` and `deepseek-v4-pro`; the retired
7
+ * `deepseek-v4-flash` and `deepseek-v4-flash-vision-exp` names are served by
8
+ * the Flash model at the same limits).
9
+ */
10
+ const CONTEXT_WINDOW_TOKENS = 1_000_000;
11
+ const MAX_OUTPUT_TOKENS = 384_000;
3
12
  /** Driver-level mapping capabilities; model input support is listed separately. */
4
13
  export const DEEPSEEK_CAPABILITIES = {
5
14
  supportsTools: true,
@@ -12,11 +21,32 @@ export const DEEPSEEK_CAPABILITIES = {
12
21
  supportsToolResultDocuments: false,
13
22
  };
14
23
  const DEFAULT_BASE_URL = 'https://api.deepseek.com';
24
+ /**
25
+ * The documented 1M / 384K only describe the vendor's own service. A gateway
26
+ * behind a custom `baseURL` may serve the same id at a smaller window, so
27
+ * there the documented numbers are not offered and only what the listing
28
+ * reports counts.
29
+ */
30
+ function isVendorBaseUrl(baseURL) {
31
+ if (!baseURL)
32
+ return true;
33
+ try {
34
+ return new URL(baseURL).hostname === new URL(DEFAULT_BASE_URL).hostname;
35
+ }
36
+ catch {
37
+ return false;
38
+ }
39
+ }
40
+ /** The current Flash id; it accepts images (https://api-docs.deepseek.com/quick_start/pricing). */
41
+ const CURRENT_FLASH_MODEL = 'deepseek-flash';
42
+ /** A retired name the vendor still serves; it routes to the Flash model, images included. */
15
43
  const VISION_MODEL = 'deepseek-v4-flash-vision-exp';
44
+ const IMAGE_MODELS = new Set([CURRENT_FLASH_MODEL, VISION_MODEL]);
16
45
  const TEXT_MODALITIES = Object.freeze(['text']);
17
46
  const VISION_MODALITIES = Object.freeze(['text', 'image']);
18
47
  const IMAGE_MEDIA_TYPES = new Set(['image/png', 'image/jpeg', 'image/webp', 'image/gif']);
19
48
  const KNOWN_MODELS = Object.freeze([
49
+ { id: CURRENT_FLASH_MODEL, name: 'DeepSeek-V4.1-Flash', inputModalities: VISION_MODALITIES },
20
50
  { id: 'deepseek-v4-flash', name: 'DeepSeek-V4-Flash', inputModalities: TEXT_MODALITIES },
21
51
  { id: 'deepseek-v4-pro', name: 'DeepSeek-V4-Pro', inputModalities: TEXT_MODALITIES },
22
52
  {
@@ -91,8 +121,9 @@ const SAMPLING_FIELDS = ['temperature', 'topP', 'frequencyPenalty', 'presencePen
91
121
  * below that turns on "thinking is enabled" has to read it this way, or it
92
122
  * applies to explicit callers only and misses the common case entirely.
93
123
  */
94
- export function thinkingEnabled(thinking) {
95
- return thinking?.type !== 'disabled';
124
+ export function thinkingEnabled(thinking, effort) {
125
+ // `none` is thinking off, and the driver sends it as `thinking: disabled`.
126
+ return thinking?.type !== 'disabled' && effort !== 'none';
96
127
  }
97
128
  /**
98
129
  * Refuse a sampling parameter that thinking mode will discard.
@@ -110,7 +141,7 @@ export function thinkingEnabled(thinking) {
110
141
  export function assertSamplingUsable(params, mode) {
111
142
  if (mode === 'ignore')
112
143
  return;
113
- if (!thinkingEnabled(params.thinking))
144
+ if (!thinkingEnabled(params.thinking, params.effort))
114
145
  return;
115
146
  const set = SAMPLING_FIELDS.filter((f) => params[f] !== undefined);
116
147
  if (set.length === 0)
@@ -130,12 +161,67 @@ export function assertSamplingUsable(params, mode) {
130
161
  * The vendor's Anthropic-format endpoint does take `reasoning.effort`. A
131
162
  * driver built on that wire could honour this; this one is built on Chat
132
163
  * Completions and says so.
164
+ *
165
+ * @deprecated The driver now carries effort on `reasoning_effort`, the field
166
+ * the vendor's Chat Completions reference documents (the field measured here
167
+ * earlier was `thinking.effort`, which the vendor never defined). Nothing in
168
+ * this package calls it any more; use {@link resolveDeepSeekEffort}.
133
169
  */
134
170
  export function assertEffortUnsupported(params) {
135
171
  if (params.effort === undefined)
136
172
  return;
137
173
  throw new Error(`DeepSeekProvider: \`effort\` is not carried by this endpoint. The vendor's Chat Completions wire validates \`thinking.type\` and ignores any effort sent beside it, so passing one through would change nothing and report success. Use \`thinking: { type: 'adaptive' | 'enabled' | 'disabled' }\` to steer this driver.`);
138
174
  }
175
+ /** The effort levels the vendor's pages list, in the order they rank. */
176
+ const VENDOR_EFFORT_ORDER = ['low', 'high', 'max'];
177
+ /** The menu used until the models endpoint says otherwise (levels low, high, max; default high). */
178
+ const DEFAULT_EFFORT_LEVELS = VENDOR_EFFORT_ORDER;
179
+ const DEFAULT_EFFORT = 'high';
180
+ /**
181
+ * The vendor's own mapping of Namzu's wider vocabulary onto what it accepts
182
+ * (https://api-docs.deepseek.com/guides/thinking_mode, "effort mapping").
183
+ */
184
+ const VENDOR_EFFORT_ALIASES = {
185
+ minimal: 'low',
186
+ low: 'low',
187
+ medium: 'high',
188
+ high: 'high',
189
+ xhigh: 'high',
190
+ max: 'max',
191
+ ultra: 'max',
192
+ };
193
+ /**
194
+ * Turn a requested effort into the one this model offers.
195
+ *
196
+ * `none` is thinking off. A level the model offers is sent as is. Any other
197
+ * level goes through the vendor's documented mapping (`medium` and `xhigh`
198
+ * to `high`, `minimal` to `low`, `ultra` to `max`); if the model's menu lacks
199
+ * that target, the nearest offered level is used, the lower one on a tie, and
200
+ * `mapped` says so. It never throws: a level this model does not offer must
201
+ * degrade to its neighbour rather than fail a run that asked for more thought.
202
+ */
203
+ export function resolveDeepSeekEffort(requested, offered = DEFAULT_EFFORT_LEVELS) {
204
+ if (requested === 'none')
205
+ return { level: 'none', mapped: false };
206
+ const menu = VENDOR_EFFORT_ORDER.filter((level) => offered.includes(level));
207
+ if (menu.length === 0)
208
+ return { level: VENDOR_EFFORT_ALIASES[requested], mapped: true };
209
+ if (menu.includes(requested)) {
210
+ return { level: requested, mapped: false };
211
+ }
212
+ const target = VENDOR_EFFORT_ALIASES[requested];
213
+ const wanted = VENDOR_EFFORT_ORDER.indexOf(target);
214
+ let best = menu[0];
215
+ let bestDistance = Number.POSITIVE_INFINITY;
216
+ for (const level of menu) {
217
+ const distance = Math.abs(VENDOR_EFFORT_ORDER.indexOf(level) - wanted);
218
+ if (distance < bestDistance) {
219
+ best = level;
220
+ bestDistance = distance;
221
+ }
222
+ }
223
+ return { level: best, mapped: true };
224
+ }
139
225
  function sameRoute(left, right) {
140
226
  return (left.providerId === right.providerId &&
141
227
  left.model === right.model &&
@@ -335,10 +421,45 @@ function assertDeepSeekRichContent(messages, model) {
335
421
  acceptImage(block.mediaType);
336
422
  }
337
423
  }
338
- if (hasImage && model !== VISION_MODEL) {
339
- throw new Error(`DeepSeekProvider: model '${model}' does not accept image input. Select '${VISION_MODEL}' or remove the images.`);
424
+ if (hasImage && !IMAGE_MODELS.has(model)) {
425
+ throw new Error(`DeepSeekProvider: model '${model}' does not accept image input. Select '${CURRENT_FLASH_MODEL}' or remove the images.`);
340
426
  }
341
427
  }
428
+ const positiveInteger = (value) => typeof value === 'number' && Number.isSafeInteger(value) && value > 0 ? value : undefined;
429
+ /** `context_window` and `max_output_tokens` on a models-endpoint entry, when present and sane. */
430
+ function readVendorLimits(entries) {
431
+ const out = new Map();
432
+ for (const entry of entries) {
433
+ if (typeof entry !== 'object' || entry === null)
434
+ continue;
435
+ const record = entry;
436
+ if (typeof record.id !== 'string')
437
+ continue;
438
+ const contextWindow = positiveInteger(record.context_window);
439
+ const maxOutputTokens = positiveInteger(record.max_output_tokens);
440
+ const effort = typeof record.effort === 'object' && record.effort !== null
441
+ ? record.effort
442
+ : undefined;
443
+ const effortLevels = Array.isArray(effort?.supported_levels)
444
+ ? effort.supported_levels.filter((level) => typeof level === 'string')
445
+ : undefined;
446
+ const effortDefault = typeof effort?.default_level === 'string' ? effort.default_level : undefined;
447
+ if (contextWindow === undefined &&
448
+ maxOutputTokens === undefined &&
449
+ (effortLevels === undefined || effortLevels.length === 0))
450
+ continue;
451
+ out.set(record.id, {
452
+ ...(contextWindow !== undefined ? { contextWindow } : {}),
453
+ ...(maxOutputTokens !== undefined ? { maxOutputTokens } : {}),
454
+ ...(effortLevels !== undefined && effortLevels.length > 0 ? { effortLevels } : {}),
455
+ ...(effortDefault !== undefined ? { effortDefault } : {}),
456
+ });
457
+ }
458
+ return out;
459
+ }
460
+ function isKnownModel(model) {
461
+ return KNOWN_MODELS.some((candidate) => candidate.id === model);
462
+ }
342
463
  function inputModalitiesFor(model) {
343
464
  return KNOWN_MODELS.find((candidate) => candidate.id === model)?.inputModalities;
344
465
  }
@@ -366,6 +487,8 @@ export class DeepSeekProvider {
366
487
  client;
367
488
  defaultModel;
368
489
  samplingMode;
490
+ vendorLimits;
491
+ documentedLimits;
369
492
  constructor(config) {
370
493
  if (!config.apiKey) {
371
494
  throw new Error('DeepSeek API key is required. Set DEEPSEEK_API_KEY env variable.');
@@ -384,6 +507,7 @@ export class DeepSeekProvider {
384
507
  };
385
508
  this.client = new OpenAI(clientOptions);
386
509
  this.defaultModel = config.model;
510
+ this.documentedLimits = isVendorBaseUrl(config.baseURL);
387
511
  this.samplingMode = config.samplingInThinkingMode ?? 'refuse';
388
512
  }
389
513
  resolveModel(params) {
@@ -393,16 +517,30 @@ export class DeepSeekProvider {
393
517
  }
394
518
  return model;
395
519
  }
396
- /** This Chat Completions endpoint explicitly carries no effort control. */
397
- reasoningEffortLevelsFor(_model) {
398
- return [];
520
+ /** Last models-endpoint answer, once a turn has fetched it; the sync menus read this. */
521
+ vendorSnapshot;
522
+ /**
523
+ * `none` (thinking off) plus the levels the models endpoint lists for the
524
+ * model, or the vendor's documented low, high and max until it has been read.
525
+ */
526
+ reasoningEffortLevelsFor(model) {
527
+ const listed = this.vendorSnapshot?.get(model)?.effortLevels;
528
+ const levels = VENDOR_EFFORT_ORDER.filter((level) => (listed ?? DEFAULT_EFFORT_LEVELS).includes(level));
529
+ return ['none', ...(levels.length > 0 ? levels : DEFAULT_EFFORT_LEVELS)];
530
+ }
531
+ /** The level a request without one runs at: the endpoint's `default_level`, else `high`. */
532
+ reasoningEffortDefaultFor(model) {
533
+ const stated = this.vendorSnapshot?.get(model)?.effortDefault;
534
+ return stated !== undefined && VENDOR_EFFORT_ORDER.includes(stated)
535
+ ? stated
536
+ : DEFAULT_EFFORT;
399
537
  }
400
538
  async *chatStream(params) {
401
539
  const model = this.resolveModel(params);
402
540
  const providerRoute = resolveDeepSeekRoute(model, params.providerRoute);
403
- assertEffortUnsupported(params);
404
541
  assertSamplingUsable(params, this.samplingMode);
405
- const sampling = thinkingEnabled(params.thinking)
542
+ const thinkingOn = thinkingEnabled(params.thinking, params.effort);
543
+ const sampling = thinkingOn
406
544
  ? {}
407
545
  : {
408
546
  temperature: params.temperature,
@@ -435,7 +573,27 @@ export class DeepSeekProvider {
435
573
  // Cast back to `typeof body` rather than to the SDK's parameter type: the
436
574
  // extra key rides along at runtime, and the literal `stream: true`
437
575
  // survives, which is what keeps the streaming overload selected.
438
- const withThinking = (params.thinking ? { ...body, thinking: { type: params.thinking.type } } : body);
576
+ //
577
+ // Effort rides on `reasoning_effort`, a sibling of `thinking`. An explicit
578
+ // `thinking.type` wins at the vendor, so `disabled` sends no level, and
579
+ // `none` is sent as `thinking: disabled` so the switch does not depend on
580
+ // that precedence. A level the model does not offer is mapped before it
581
+ // is sent (see `resolveDeepSeekEffort`).
582
+ const offered = this.vendorSnapshot?.get(model)?.effortLevels;
583
+ const resolved = params.effort !== undefined ? resolveDeepSeekEffort(params.effort, offered) : undefined;
584
+ const thinkingField = params.thinking?.type === 'disabled' || resolved?.level === 'none'
585
+ ? { type: 'disabled' }
586
+ : params.thinking
587
+ ? { type: params.thinking.type }
588
+ : undefined;
589
+ const effortField = resolved !== undefined && resolved.level !== 'none' && thinkingField?.type !== 'disabled'
590
+ ? { reasoning_effort: resolved.level }
591
+ : {};
592
+ const withThinking = {
593
+ ...body,
594
+ ...(thinkingField ? { thinking: thinkingField } : {}),
595
+ ...effortField,
596
+ };
439
597
  let stream;
440
598
  try {
441
599
  stream = await this.client.chat.completions.create(withThinking, {
@@ -521,6 +679,7 @@ export class DeepSeekProvider {
521
679
  ...(replayState !== undefined ? { replayState } : {}),
522
680
  delta: { content: delta?.content ?? undefined, toolCalls },
523
681
  finishReason,
682
+ ...(finishReason === 'content_filter' ? { refusal: {} } : {}),
524
683
  usage,
525
684
  };
526
685
  }
@@ -558,6 +717,46 @@ export class DeepSeekProvider {
558
717
  throw providerVendorError({ providerId: 'deepseek', error: err });
559
718
  }
560
719
  }
720
+ /**
721
+ * What the vendor's models endpoint says about each model it lists. The
722
+ * endpoint may leave `context_window` and `max_output_tokens` out (both are
723
+ * optional there), so an absent field is simply not an answer. A failed
724
+ * request is not cached: the next turn asks again.
725
+ */
726
+ fetchVendorLimits(signal) {
727
+ if (this.vendorLimits)
728
+ return this.vendorLimits;
729
+ const request = this.client.models.list(signal ? { signal } : undefined).then((page) => {
730
+ const limits = readVendorLimits(page.data);
731
+ this.vendorSnapshot = limits;
732
+ return limits;
733
+ });
734
+ this.vendorLimits = request;
735
+ request.catch(() => {
736
+ if (this.vendorLimits === request)
737
+ this.vendorLimits = undefined;
738
+ });
739
+ return request;
740
+ }
741
+ /**
742
+ * The window the runtime measures compaction against: what the vendor's
743
+ * models endpoint reports for the id when it reports one, else the
744
+ * documented limit of a model this driver lists, else `undefined` rather
745
+ * than a guess, which leaves the SDK's table to answer for it. The vendor
746
+ * answers first and the built-in table is only the fallback.
747
+ */
748
+ async resolveContextWindow(model, signal) {
749
+ signal?.throwIfAborted();
750
+ let reported;
751
+ try {
752
+ reported = (await this.fetchVendorLimits(signal)).get(model)?.contextWindow;
753
+ }
754
+ catch {
755
+ // The listing is a refinement; a turn must not fail because it is down.
756
+ signal?.throwIfAborted();
757
+ }
758
+ return (reported ?? (this.documentedLimits && isKnownModel(model) ? CONTEXT_WINDOW_TOKENS : undefined));
759
+ }
561
760
  async probeCredential(signal) {
562
761
  signal?.throwIfAborted();
563
762
  await this.client.models.list(signal ? { signal } : undefined);
@@ -570,6 +769,7 @@ export class DeepSeekProvider {
570
769
  const models = new Map();
571
770
  for (const model of page.data)
572
771
  models.set(model.id, { id: model.id, name: model.id });
772
+ const vendor = readVendorLimits(page.data);
573
773
  // The preview model is part of the source adapter's verified default
574
774
  // catalogue but may lag the account listing endpoint. A successful list
575
775
  // therefore augments rather than erases the known selectable catalogue.
@@ -578,8 +778,14 @@ export class DeepSeekProvider {
578
778
  }
579
779
  return [...models.values()].map((model) => {
580
780
  const inputModalities = inputModalitiesFor(model.id);
781
+ const known = this.documentedLimits && isKnownModel(model.id);
782
+ const reported = vendor.get(model.id);
783
+ const contextWindow = reported?.contextWindow ?? (known ? CONTEXT_WINDOW_TOKENS : undefined);
784
+ const maxOutputTokens = reported?.maxOutputTokens ?? (known ? MAX_OUTPUT_TOKENS : undefined);
581
785
  return {
582
786
  ...model,
787
+ ...(contextWindow !== undefined ? { contextWindow } : {}),
788
+ ...(maxOutputTokens !== undefined ? { maxOutputTokens } : {}),
583
789
  ...(inputModalities !== undefined ? { inputModalities } : {}),
584
790
  supportsToolUse: true,
585
791
  supportsStreaming: true,
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAiBA,OAAO,EACN,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,GAClB,MAAM,YAAY,CAAA;AACnB,OAAO,MAAM,MAAM,QAAQ,CAAA;AAQ3B,mFAAmF;AACnF,MAAM,CAAC,MAAM,qBAAqB,GAAyB;IAC1D,aAAa,EAAE,IAAI;IACnB,iBAAiB,EAAE,IAAI;IACvB,uBAAuB,EAAE,IAAI;IAC7B,8BAA8B,EAAE,IAAI;I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CAAA;IACH,CAAC;IAED,KAAK,CAAC,WAAW;QAChB,IAAI,CAAC;YACJ,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAA;YAC/B,OAAO,IAAI,CAAA;QACZ,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,KAAK,CAAA;QACb,CAAC;IACF,CAAC;CACD"}
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ declare module '@namzu/sdk' {
14
14
  * Pass `{ replace: true }` to override.
15
15
  */
16
16
  export declare function registerDeepSeek(options?: RegisterOptions): void;
17
- export { DEEPSEEK_CAPABILITIES, DeepSeekProvider, assertEffortUnsupported, assertSamplingUsable, thinkingEnabled, toDeepSeekMessages, toDeepSeekTools, } from './client.js';
17
+ export { DEEPSEEK_CAPABILITIES, DeepSeekProvider, assertEffortUnsupported, assertSamplingUsable, resolveDeepSeekEffort, thinkingEnabled, toDeepSeekMessages, toDeepSeekTools, } from './client.js';
18
+ export type { DeepSeekEffortResolution } from './client.js';
18
19
  export type { DeepSeekConfig, DeepSeekProviderConfig } from './types.js';
19
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,YAAY,CAAA;AAEnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAKxD,OAAO,QAAQ,YAAY,CAAC;IAC3B,UAAU,sBAAsB;QAC/B,QAAQ,EAAE,sBAAsB,CAAA;KAChC;CACD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,IAAI,CAEhE;AAED,OAAO,EACN,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,eAAe,GACf,MAAM,aAAa,CAAA;AACpB,YAAY,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,YAAY,CAAA;AAEnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAKxD,OAAO,QAAQ,YAAY,CAAC;IAC3B,UAAU,sBAAsB;QAC/B,QAAQ,EAAE,sBAAsB,CAAA;KAChC;CACD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,IAAI,CAEhE;AAED,OAAO,EACN,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,eAAe,GACf,MAAM,aAAa,CAAA;AACpB,YAAY,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAC3D,YAAY,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA"}
package/dist/index.js CHANGED
@@ -11,5 +11,5 @@ import { DEEPSEEK_CAPABILITIES, DeepSeekProvider } from './client.js';
11
11
  export function registerDeepSeek(options) {
12
12
  ProviderRegistry.register('deepseek', DeepSeekProvider, DEEPSEEK_CAPABILITIES, options);
13
13
  }
14
- export { DEEPSEEK_CAPABILITIES, DeepSeekProvider, assertEffortUnsupported, assertSamplingUsable, thinkingEnabled, toDeepSeekMessages, toDeepSeekTools, } from './client.js';
14
+ export { DEEPSEEK_CAPABILITIES, DeepSeekProvider, assertEffortUnsupported, assertSamplingUsable, resolveDeepSeekEffort, thinkingEnabled, toDeepSeekMessages, toDeepSeekTools, } from './client.js';
15
15
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAwB,MAAM,YAAY,CAAA;AACnE,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAYrE;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAyB;IACzD,gBAAgB,CAAC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,OAAO,CAAC,CAAA;AACxF,CAAC;AAED,OAAO,EACN,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,eAAe,GACf,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAwB,MAAM,YAAY,CAAA;AACnE,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAYrE;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAyB;IACzD,gBAAgB,CAAC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,OAAO,CAAC,CAAA;AACxF,CAAC;AAED,OAAO,EACN,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,eAAe,GACf,MAAM,aAAa,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@namzu/deepseek",
3
- "version": "2.2.0",
3
+ "version": "2.3.1",
4
4
  "description": "DeepSeek LLM provider for @namzu/sdk. Chat Completions with streaming, tool use, and thinking mode mapped onto the kernel's reasoning blocks.",
5
5
  "license": "FSL-1.1-MIT",
6
6
  "engines": {
@@ -57,7 +57,7 @@
57
57
  "@types/node": "^22.19.17",
58
58
  "typescript": "^5.5.0",
59
59
  "vitest": "^4.1.11",
60
- "@namzu/sdk": "^57.0.0"
60
+ "@namzu/sdk": "^60.1.0"
61
61
  },
62
62
  "scripts": {
63
63
  "build": "tsc --build",
package/src/client.ts CHANGED
@@ -31,6 +31,16 @@ import type {
31
31
  } from 'openai/resources/chat/completions'
32
32
  import type { DeepSeekConfig } from './types.js'
33
33
 
34
+ /**
35
+ * What the vendor documents for every current model: a 1M-token context and a
36
+ * 384K-token output cap (https://api-docs.deepseek.com/quick_start/pricing,
37
+ * one row for `deepseek-flash` and `deepseek-v4-pro`; the retired
38
+ * `deepseek-v4-flash` and `deepseek-v4-flash-vision-exp` names are served by
39
+ * the Flash model at the same limits).
40
+ */
41
+ const CONTEXT_WINDOW_TOKENS = 1_000_000
42
+ const MAX_OUTPUT_TOKENS = 384_000
43
+
34
44
  /** Driver-level mapping capabilities; model input support is listed separately. */
35
45
  export const DEEPSEEK_CAPABILITIES: ProviderCapabilities = {
36
46
  supportsTools: true,
@@ -44,11 +54,31 @@ export const DEEPSEEK_CAPABILITIES: ProviderCapabilities = {
44
54
  }
45
55
 
46
56
  const DEFAULT_BASE_URL = 'https://api.deepseek.com'
57
+
58
+ /**
59
+ * The documented 1M / 384K only describe the vendor's own service. A gateway
60
+ * behind a custom `baseURL` may serve the same id at a smaller window, so
61
+ * there the documented numbers are not offered and only what the listing
62
+ * reports counts.
63
+ */
64
+ function isVendorBaseUrl(baseURL: string | undefined): boolean {
65
+ if (!baseURL) return true
66
+ try {
67
+ return new URL(baseURL).hostname === new URL(DEFAULT_BASE_URL).hostname
68
+ } catch {
69
+ return false
70
+ }
71
+ }
72
+ /** The current Flash id; it accepts images (https://api-docs.deepseek.com/quick_start/pricing). */
73
+ const CURRENT_FLASH_MODEL = 'deepseek-flash'
74
+ /** A retired name the vendor still serves; it routes to the Flash model, images included. */
47
75
  const VISION_MODEL = 'deepseek-v4-flash-vision-exp'
76
+ const IMAGE_MODELS: ReadonlySet<string> = new Set([CURRENT_FLASH_MODEL, VISION_MODEL])
48
77
  const TEXT_MODALITIES = Object.freeze(['text'] as const)
49
78
  const VISION_MODALITIES = Object.freeze(['text', 'image'] as const)
50
79
  const IMAGE_MEDIA_TYPES = new Set(['image/png', 'image/jpeg', 'image/webp', 'image/gif'])
51
80
  const KNOWN_MODELS = Object.freeze([
81
+ { id: CURRENT_FLASH_MODEL, name: 'DeepSeek-V4.1-Flash', inputModalities: VISION_MODALITIES },
52
82
  { id: 'deepseek-v4-flash', name: 'DeepSeek-V4-Flash', inputModalities: TEXT_MODALITIES },
53
83
  { id: 'deepseek-v4-pro', name: 'DeepSeek-V4-Pro', inputModalities: TEXT_MODALITIES },
54
84
  {
@@ -158,8 +188,12 @@ const SAMPLING_FIELDS = ['temperature', 'topP', 'frequencyPenalty', 'presencePen
158
188
  * below that turns on "thinking is enabled" has to read it this way, or it
159
189
  * applies to explicit callers only and misses the common case entirely.
160
190
  */
161
- export function thinkingEnabled(thinking: ThinkingConfig | undefined): boolean {
162
- return thinking?.type !== 'disabled'
191
+ export function thinkingEnabled(
192
+ thinking: ThinkingConfig | undefined,
193
+ effort?: ReasoningEffort,
194
+ ): boolean {
195
+ // `none` is thinking off, and the driver sends it as `thinking: disabled`.
196
+ return thinking?.type !== 'disabled' && effort !== 'none'
163
197
  }
164
198
 
165
199
  /**
@@ -180,7 +214,7 @@ export function assertSamplingUsable(
180
214
  mode: 'refuse' | 'ignore',
181
215
  ): void {
182
216
  if (mode === 'ignore') return
183
- if (!thinkingEnabled(params.thinking)) return
217
+ if (!thinkingEnabled(params.thinking, params.effort)) return
184
218
  const set = SAMPLING_FIELDS.filter((f) => params[f] !== undefined)
185
219
  if (set.length === 0) return
186
220
  throw new Error(
@@ -201,6 +235,11 @@ export function assertSamplingUsable(
201
235
  * The vendor's Anthropic-format endpoint does take `reasoning.effort`. A
202
236
  * driver built on that wire could honour this; this one is built on Chat
203
237
  * Completions and says so.
238
+ *
239
+ * @deprecated The driver now carries effort on `reasoning_effort`, the field
240
+ * the vendor's Chat Completions reference documents (the field measured here
241
+ * earlier was `thinking.effort`, which the vendor never defined). Nothing in
242
+ * this package calls it any more; use {@link resolveDeepSeekEffort}.
204
243
  */
205
244
  export function assertEffortUnsupported(params: ChatCompletionParams): void {
206
245
  if (params.effort === undefined) return
@@ -209,6 +248,69 @@ export function assertEffortUnsupported(params: ChatCompletionParams): void {
209
248
  )
210
249
  }
211
250
 
251
+ /** The effort levels the vendor's pages list, in the order they rank. */
252
+ const VENDOR_EFFORT_ORDER = ['low', 'high', 'max'] as const
253
+ type VendorEffort = (typeof VENDOR_EFFORT_ORDER)[number]
254
+
255
+ /** The menu used until the models endpoint says otherwise (levels low, high, max; default high). */
256
+ const DEFAULT_EFFORT_LEVELS: readonly VendorEffort[] = VENDOR_EFFORT_ORDER
257
+ const DEFAULT_EFFORT: VendorEffort = 'high'
258
+
259
+ /**
260
+ * The vendor's own mapping of Namzu's wider vocabulary onto what it accepts
261
+ * (https://api-docs.deepseek.com/guides/thinking_mode, "effort mapping").
262
+ */
263
+ const VENDOR_EFFORT_ALIASES: Readonly<Record<Exclude<ReasoningEffort, 'none'>, VendorEffort>> = {
264
+ minimal: 'low',
265
+ low: 'low',
266
+ medium: 'high',
267
+ high: 'high',
268
+ xhigh: 'high',
269
+ max: 'max',
270
+ ultra: 'max',
271
+ }
272
+
273
+ export interface DeepSeekEffortResolution {
274
+ /** `none` turns thinking off; otherwise the level sent as `reasoning_effort`. */
275
+ readonly level: VendorEffort | 'none'
276
+ /** True when the level asked for is not the level sent. */
277
+ readonly mapped: boolean
278
+ }
279
+
280
+ /**
281
+ * Turn a requested effort into the one this model offers.
282
+ *
283
+ * `none` is thinking off. A level the model offers is sent as is. Any other
284
+ * level goes through the vendor's documented mapping (`medium` and `xhigh`
285
+ * to `high`, `minimal` to `low`, `ultra` to `max`); if the model's menu lacks
286
+ * that target, the nearest offered level is used, the lower one on a tie, and
287
+ * `mapped` says so. It never throws: a level this model does not offer must
288
+ * degrade to its neighbour rather than fail a run that asked for more thought.
289
+ */
290
+ export function resolveDeepSeekEffort(
291
+ requested: ReasoningEffort,
292
+ offered: readonly string[] = DEFAULT_EFFORT_LEVELS,
293
+ ): DeepSeekEffortResolution {
294
+ if (requested === 'none') return { level: 'none', mapped: false }
295
+ const menu = VENDOR_EFFORT_ORDER.filter((level) => offered.includes(level))
296
+ if (menu.length === 0) return { level: VENDOR_EFFORT_ALIASES[requested], mapped: true }
297
+ if ((menu as readonly string[]).includes(requested)) {
298
+ return { level: requested as VendorEffort, mapped: false }
299
+ }
300
+ const target = VENDOR_EFFORT_ALIASES[requested]
301
+ const wanted = VENDOR_EFFORT_ORDER.indexOf(target)
302
+ let best: VendorEffort = menu[0] as VendorEffort
303
+ let bestDistance = Number.POSITIVE_INFINITY
304
+ for (const level of menu) {
305
+ const distance = Math.abs(VENDOR_EFFORT_ORDER.indexOf(level) - wanted)
306
+ if (distance < bestDistance) {
307
+ best = level
308
+ bestDistance = distance
309
+ }
310
+ }
311
+ return { level: best, mapped: true }
312
+ }
313
+
212
314
  /**
213
315
  * Adapter-private state for one completed reasoning response.
214
316
  *
@@ -453,13 +555,64 @@ function assertDeepSeekRichContent(
453
555
  if (block.type === 'image') acceptImage(block.mediaType)
454
556
  }
455
557
  }
456
- if (hasImage && model !== VISION_MODEL) {
558
+ if (hasImage && !IMAGE_MODELS.has(model)) {
457
559
  throw new Error(
458
- `DeepSeekProvider: model '${model}' does not accept image input. Select '${VISION_MODEL}' or remove the images.`,
560
+ `DeepSeekProvider: model '${model}' does not accept image input. Select '${CURRENT_FLASH_MODEL}' or remove the images.`,
459
561
  )
460
562
  }
461
563
  }
462
564
 
565
+ interface VendorLimits {
566
+ readonly contextWindow?: number
567
+ readonly maxOutputTokens?: number
568
+ /** `effort.supported_levels` and `effort.default_level` from the models endpoint. */
569
+ readonly effortLevels?: readonly string[]
570
+ readonly effortDefault?: string
571
+ }
572
+
573
+ const positiveInteger = (value: unknown): number | undefined =>
574
+ typeof value === 'number' && Number.isSafeInteger(value) && value > 0 ? value : undefined
575
+
576
+ /** `context_window` and `max_output_tokens` on a models-endpoint entry, when present and sane. */
577
+ function readVendorLimits(entries: readonly unknown[]): Map<string, VendorLimits> {
578
+ const out = new Map<string, VendorLimits>()
579
+ for (const entry of entries) {
580
+ if (typeof entry !== 'object' || entry === null) continue
581
+ const record = entry as Record<string, unknown>
582
+ if (typeof record.id !== 'string') continue
583
+ const contextWindow = positiveInteger(record.context_window)
584
+ const maxOutputTokens = positiveInteger(record.max_output_tokens)
585
+ const effort =
586
+ typeof record.effort === 'object' && record.effort !== null
587
+ ? (record.effort as Record<string, unknown>)
588
+ : undefined
589
+ const effortLevels = Array.isArray(effort?.supported_levels)
590
+ ? (effort.supported_levels as unknown[]).filter(
591
+ (level): level is string => typeof level === 'string',
592
+ )
593
+ : undefined
594
+ const effortDefault =
595
+ typeof effort?.default_level === 'string' ? effort.default_level : undefined
596
+ if (
597
+ contextWindow === undefined &&
598
+ maxOutputTokens === undefined &&
599
+ (effortLevels === undefined || effortLevels.length === 0)
600
+ )
601
+ continue
602
+ out.set(record.id, {
603
+ ...(contextWindow !== undefined ? { contextWindow } : {}),
604
+ ...(maxOutputTokens !== undefined ? { maxOutputTokens } : {}),
605
+ ...(effortLevels !== undefined && effortLevels.length > 0 ? { effortLevels } : {}),
606
+ ...(effortDefault !== undefined ? { effortDefault } : {}),
607
+ })
608
+ }
609
+ return out
610
+ }
611
+
612
+ function isKnownModel(model: string): boolean {
613
+ return KNOWN_MODELS.some((candidate) => candidate.id === model)
614
+ }
615
+
463
616
  function inputModalitiesFor(model: string): readonly ModelInputModality[] | undefined {
464
617
  return KNOWN_MODELS.find((candidate) => candidate.id === model)?.inputModalities
465
618
  }
@@ -489,6 +642,8 @@ export class DeepSeekProvider implements LLMProvider {
489
642
  private client: OpenAI
490
643
  private defaultModel?: string
491
644
  private samplingMode: 'refuse' | 'ignore'
645
+ private vendorLimits: Promise<Map<string, VendorLimits>> | undefined
646
+ private readonly documentedLimits: boolean
492
647
 
493
648
  constructor(config: DeepSeekConfig) {
494
649
  if (!config.apiKey) {
@@ -507,6 +662,7 @@ export class DeepSeekProvider implements LLMProvider {
507
662
 
508
663
  this.client = new OpenAI(clientOptions)
509
664
  this.defaultModel = config.model
665
+ this.documentedLimits = isVendorBaseUrl(config.baseURL)
510
666
  this.samplingMode = config.samplingInThinkingMode ?? 'refuse'
511
667
  }
512
668
 
@@ -520,18 +676,36 @@ export class DeepSeekProvider implements LLMProvider {
520
676
  return model
521
677
  }
522
678
 
523
- /** This Chat Completions endpoint explicitly carries no effort control. */
524
- reasoningEffortLevelsFor(_model: string): readonly ReasoningEffort[] {
525
- return []
679
+ /** Last models-endpoint answer, once a turn has fetched it; the sync menus read this. */
680
+ private vendorSnapshot: Map<string, VendorLimits> | undefined
681
+
682
+ /**
683
+ * `none` (thinking off) plus the levels the models endpoint lists for the
684
+ * model, or the vendor's documented low, high and max until it has been read.
685
+ */
686
+ reasoningEffortLevelsFor(model: string): readonly ReasoningEffort[] {
687
+ const listed = this.vendorSnapshot?.get(model)?.effortLevels
688
+ const levels = VENDOR_EFFORT_ORDER.filter((level) =>
689
+ (listed ?? DEFAULT_EFFORT_LEVELS).includes(level),
690
+ )
691
+ return ['none', ...(levels.length > 0 ? levels : DEFAULT_EFFORT_LEVELS)]
692
+ }
693
+
694
+ /** The level a request without one runs at: the endpoint's `default_level`, else `high`. */
695
+ reasoningEffortDefaultFor(model: string): ReasoningEffort {
696
+ const stated = this.vendorSnapshot?.get(model)?.effortDefault
697
+ return stated !== undefined && (VENDOR_EFFORT_ORDER as readonly string[]).includes(stated)
698
+ ? (stated as ReasoningEffort)
699
+ : DEFAULT_EFFORT
526
700
  }
527
701
 
528
702
  async *chatStream(params: ChatCompletionParams): AsyncIterable<StreamChunk> {
529
703
  const model = this.resolveModel(params)
530
704
  const providerRoute = resolveDeepSeekRoute(model, params.providerRoute)
531
- assertEffortUnsupported(params)
532
705
  assertSamplingUsable(params, this.samplingMode)
706
+ const thinkingOn = thinkingEnabled(params.thinking, params.effort)
533
707
 
534
- const sampling = thinkingEnabled(params.thinking)
708
+ const sampling = thinkingOn
535
709
  ? {}
536
710
  : {
537
711
  temperature: params.temperature,
@@ -566,9 +740,30 @@ export class DeepSeekProvider implements LLMProvider {
566
740
  // Cast back to `typeof body` rather than to the SDK's parameter type: the
567
741
  // extra key rides along at runtime, and the literal `stream: true`
568
742
  // survives, which is what keeps the streaming overload selected.
569
- const withThinking = (
570
- params.thinking ? { ...body, thinking: { type: params.thinking.type } } : body
571
- ) as typeof body
743
+ //
744
+ // Effort rides on `reasoning_effort`, a sibling of `thinking`. An explicit
745
+ // `thinking.type` wins at the vendor, so `disabled` sends no level, and
746
+ // `none` is sent as `thinking: disabled` so the switch does not depend on
747
+ // that precedence. A level the model does not offer is mapped before it
748
+ // is sent (see `resolveDeepSeekEffort`).
749
+ const offered = this.vendorSnapshot?.get(model)?.effortLevels
750
+ const resolved =
751
+ params.effort !== undefined ? resolveDeepSeekEffort(params.effort, offered) : undefined
752
+ const thinkingField =
753
+ params.thinking?.type === 'disabled' || resolved?.level === 'none'
754
+ ? { type: 'disabled' as const }
755
+ : params.thinking
756
+ ? { type: params.thinking.type }
757
+ : undefined
758
+ const effortField =
759
+ resolved !== undefined && resolved.level !== 'none' && thinkingField?.type !== 'disabled'
760
+ ? { reasoning_effort: resolved.level }
761
+ : {}
762
+ const withThinking = {
763
+ ...body,
764
+ ...(thinkingField ? { thinking: thinkingField } : {}),
765
+ ...effortField,
766
+ } as typeof body
572
767
 
573
768
  let stream: Awaited<ReturnType<typeof this.client.chat.completions.create>>
574
769
  try {
@@ -676,6 +871,7 @@ export class DeepSeekProvider implements LLMProvider {
676
871
  ...(replayState !== undefined ? { replayState } : {}),
677
872
  delta: { content: delta?.content ?? undefined, toolCalls },
678
873
  finishReason,
874
+ ...(finishReason === 'content_filter' ? { refusal: {} } : {}),
679
875
  usage,
680
876
  }
681
877
  } catch (parseErr) {
@@ -709,6 +905,47 @@ export class DeepSeekProvider implements LLMProvider {
709
905
  }
710
906
  }
711
907
 
908
+ /**
909
+ * What the vendor's models endpoint says about each model it lists. The
910
+ * endpoint may leave `context_window` and `max_output_tokens` out (both are
911
+ * optional there), so an absent field is simply not an answer. A failed
912
+ * request is not cached: the next turn asks again.
913
+ */
914
+ private fetchVendorLimits(signal?: AbortSignal): Promise<Map<string, VendorLimits>> {
915
+ if (this.vendorLimits) return this.vendorLimits
916
+ const request = this.client.models.list(signal ? { signal } : undefined).then((page) => {
917
+ const limits = readVendorLimits(page.data)
918
+ this.vendorSnapshot = limits
919
+ return limits
920
+ })
921
+ this.vendorLimits = request
922
+ request.catch(() => {
923
+ if (this.vendorLimits === request) this.vendorLimits = undefined
924
+ })
925
+ return request
926
+ }
927
+
928
+ /**
929
+ * The window the runtime measures compaction against: what the vendor's
930
+ * models endpoint reports for the id when it reports one, else the
931
+ * documented limit of a model this driver lists, else `undefined` rather
932
+ * than a guess, which leaves the SDK's table to answer for it. The vendor
933
+ * answers first and the built-in table is only the fallback.
934
+ */
935
+ async resolveContextWindow(model: string, signal?: AbortSignal): Promise<number | undefined> {
936
+ signal?.throwIfAborted()
937
+ let reported: number | undefined
938
+ try {
939
+ reported = (await this.fetchVendorLimits(signal)).get(model)?.contextWindow
940
+ } catch {
941
+ // The listing is a refinement; a turn must not fail because it is down.
942
+ signal?.throwIfAborted()
943
+ }
944
+ return (
945
+ reported ?? (this.documentedLimits && isKnownModel(model) ? CONTEXT_WINDOW_TOKENS : undefined)
946
+ )
947
+ }
948
+
712
949
  async probeCredential(signal?: AbortSignal): Promise<void> {
713
950
  signal?.throwIfAborted()
714
951
  await this.client.models.list(signal ? { signal } : undefined)
@@ -721,6 +958,7 @@ export class DeepSeekProvider implements LLMProvider {
721
958
  signal?.throwIfAborted()
722
959
  const models = new Map<string, { id: string; name: string }>()
723
960
  for (const model of page.data) models.set(model.id, { id: model.id, name: model.id })
961
+ const vendor = readVendorLimits(page.data)
724
962
  // The preview model is part of the source adapter's verified default
725
963
  // catalogue but may lag the account listing endpoint. A successful list
726
964
  // therefore augments rather than erases the known selectable catalogue.
@@ -729,8 +967,14 @@ export class DeepSeekProvider implements LLMProvider {
729
967
  }
730
968
  return [...models.values()].map((model) => {
731
969
  const inputModalities = inputModalitiesFor(model.id)
970
+ const known = this.documentedLimits && isKnownModel(model.id)
971
+ const reported = vendor.get(model.id)
972
+ const contextWindow = reported?.contextWindow ?? (known ? CONTEXT_WINDOW_TOKENS : undefined)
973
+ const maxOutputTokens = reported?.maxOutputTokens ?? (known ? MAX_OUTPUT_TOKENS : undefined)
732
974
  return {
733
975
  ...model,
976
+ ...(contextWindow !== undefined ? { contextWindow } : {}),
977
+ ...(maxOutputTokens !== undefined ? { maxOutputTokens } : {}),
734
978
  ...(inputModalities !== undefined ? { inputModalities } : {}),
735
979
  supportsToolUse: true,
736
980
  supportsStreaming: true,
package/src/index.ts CHANGED
@@ -28,8 +28,10 @@ export {
28
28
  DeepSeekProvider,
29
29
  assertEffortUnsupported,
30
30
  assertSamplingUsable,
31
+ resolveDeepSeekEffort,
31
32
  thinkingEnabled,
32
33
  toDeepSeekMessages,
33
34
  toDeepSeekTools,
34
35
  } from './client.js'
36
+ export type { DeepSeekEffortResolution } from './client.js'
35
37
  export type { DeepSeekConfig, DeepSeekProviderConfig } from './types.js'