Skip to content

Commit b269e01

Browse files
committed
fix: support OpenRouter reasoning effort compatibility
1 parent b3cbdfa commit b269e01

12 files changed

Lines changed: 679 additions & 70 deletions

File tree

src/client/core.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { CancellationToken } from 'vscode';
22
import { safeStringify } from '../json';
33
import { logger } from '../logger';
4+
import type { ChatCompletionRequestBody } from '../provider/thinking';
45
import type {
5-
DeepSeekRequest,
66
DeepSeekStreamChunk,
77
DeepSeekToolCall,
88
DeepSeekUsage,
@@ -25,7 +25,7 @@ export class DeepSeekClient {
2525
* Parses SSE chunks and dispatches callbacks for content, thinking, and tool calls.
2626
*/
2727
async streamChatCompletion(
28-
request: DeepSeekRequest,
28+
request: ChatCompletionRequestBody,
2929
callbacks: StreamCallbacks,
3030
cancellationToken?: CancellationToken,
3131
): Promise<void> {
@@ -81,7 +81,9 @@ export class DeepSeekClient {
8181
break;
8282
}
8383

84-
buffer += decoder.decode(value, { stream: true });
84+
const decoded = decoder.decode(value, { stream: true });
85+
callbacks.onRawResponseData?.(decoded);
86+
buffer += decoded;
8587

8688
const lines = buffer.split('\n');
8789
buffer = lines.pop() || '';

src/client/error/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ export class DeepSeekRequestError extends Error {
3838
readonly diagnosticMessage: string;
3939
readonly baseUrl?: string;
4040
readonly status?: number;
41+
readonly statusText?: string;
4142
readonly code?: string;
43+
readonly serverMessage?: string;
44+
readonly responseText?: string;
4245

4346
constructor(options: {
4447
message: string;
@@ -47,7 +50,10 @@ export class DeepSeekRequestError extends Error {
4750
diagnosticMessage?: string;
4851
baseUrl?: string;
4952
status?: number;
53+
statusText?: string;
5054
code?: string;
55+
serverMessage?: string;
56+
responseText?: string;
5157
cause?: unknown;
5258
}) {
5359
super(options.message, { cause: options.cause });
@@ -57,7 +63,10 @@ export class DeepSeekRequestError extends Error {
5763
this.diagnosticMessage = options.diagnosticMessage ?? options.message;
5864
this.baseUrl = options.baseUrl;
5965
this.status = options.status;
66+
this.statusText = options.statusText;
6067
this.code = options.code;
68+
this.serverMessage = options.serverMessage;
69+
this.responseText = options.responseText;
6170
}
6271
}
6372

@@ -79,7 +88,10 @@ export async function createHttpError(
7988
kind: 'http',
8089
baseUrl,
8190
status: response.status,
91+
statusText: response.statusText,
8292
code: `HTTP_${response.status}`,
93+
serverMessage,
94+
responseText,
8395
diagnosticMessage: joinDiagnosticParts(
8496
`kind=http`,
8597
`status=${response.status}`,

src/client/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { DeepSeekRequest } from '../types';
1+
import type { ChatCompletionRequestBody } from '../provider/thinking';
22

33
export interface ErrorActionUrls {
44
configureApiKey?: string;
@@ -7,7 +7,7 @@ export interface ErrorActionUrls {
77

88
export interface RequestErrorContext {
99
baseUrl: string;
10-
request: DeepSeekRequest;
10+
request: ChatCompletionRequestBody;
1111
}
1212

1313
export interface ErrorActionLink {

0 commit comments

Comments
 (0)