@arikusi/deepseek-mcp-server 1.1.0 → 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/CHANGELOG.md +52 -1
- package/README.md +72 -18
- package/dist/config.d.ts +7 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +16 -11
- package/dist/config.js.map +1 -1
- package/dist/cost.d.ts +30 -13
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +58 -19
- package/dist/cost.js.map +1 -1
- package/dist/deepseek-client.d.ts +8 -0
- package/dist/deepseek-client.d.ts.map +1 -1
- package/dist/deepseek-client.js +90 -48
- package/dist/deepseek-client.js.map +1 -1
- package/dist/errors.d.ts +71 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +74 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -614
- package/dist/index.js.map +1 -1
- package/dist/prompts/advanced.d.ts +8 -0
- package/dist/prompts/advanced.d.ts.map +1 -0
- package/dist/prompts/advanced.js +187 -0
- package/dist/prompts/advanced.js.map +1 -0
- package/dist/prompts/core.d.ts +8 -0
- package/dist/prompts/core.d.ts.map +1 -0
- package/dist/prompts/core.js +188 -0
- package/dist/prompts/core.js.map +1 -0
- package/dist/prompts/function-calling.d.ts +7 -0
- package/dist/prompts/function-calling.d.ts.map +1 -0
- package/dist/prompts/function-calling.js +87 -0
- package/dist/prompts/function-calling.js.map +1 -0
- package/dist/prompts/index.d.ts +7 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +13 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/schemas.d.ts +59 -20
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +9 -2
- package/dist/schemas.js.map +1 -1
- package/dist/server.d.ts +9 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +16 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/deepseek-chat.d.ts +8 -0
- package/dist/tools/deepseek-chat.d.ts.map +1 -0
- package/dist/tools/deepseek-chat.js +184 -0
- package/dist/tools/deepseek-chat.js.map +1 -0
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +9 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/types.d.ts +94 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +20 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/deepseek-client.js
CHANGED
|
@@ -4,6 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import OpenAI from 'openai';
|
|
6
6
|
import { getConfig } from './config.js';
|
|
7
|
+
import { ApiError } from './errors.js';
|
|
8
|
+
import { hasReasoningContent, getErrorMessage } from './types.js';
|
|
9
|
+
/** Parameters that are incompatible with thinking mode */
|
|
10
|
+
const THINKING_INCOMPATIBLE_PARAMS = [
|
|
11
|
+
'temperature',
|
|
12
|
+
'top_p',
|
|
13
|
+
'frequency_penalty',
|
|
14
|
+
'presence_penalty',
|
|
15
|
+
];
|
|
7
16
|
export class DeepSeekClient {
|
|
8
17
|
client;
|
|
9
18
|
constructor() {
|
|
@@ -15,41 +24,83 @@ export class DeepSeekClient {
|
|
|
15
24
|
maxRetries: config.maxRetries,
|
|
16
25
|
});
|
|
17
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Build request params shared between streaming and non-streaming
|
|
29
|
+
*/
|
|
30
|
+
buildRequestParams(params, stream) {
|
|
31
|
+
const isThinkingEnabled = params.thinking?.type === 'enabled';
|
|
32
|
+
// Filter incompatible params when thinking mode is active
|
|
33
|
+
if (isThinkingEnabled) {
|
|
34
|
+
const filtered = [];
|
|
35
|
+
for (const key of THINKING_INCOMPATIBLE_PARAMS) {
|
|
36
|
+
if (params[key] !== undefined) {
|
|
37
|
+
filtered.push(key);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (filtered.length > 0) {
|
|
41
|
+
console.error(`[DeepSeek MCP] Warning: Thinking mode active, ignoring incompatible params: ${filtered.join(', ')}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const requestParams = {
|
|
45
|
+
model: params.model,
|
|
46
|
+
messages: params.messages,
|
|
47
|
+
temperature: isThinkingEnabled ? undefined : (params.temperature ?? 1.0),
|
|
48
|
+
max_tokens: params.max_tokens,
|
|
49
|
+
top_p: isThinkingEnabled ? undefined : params.top_p,
|
|
50
|
+
frequency_penalty: isThinkingEnabled ? undefined : params.frequency_penalty,
|
|
51
|
+
presence_penalty: isThinkingEnabled ? undefined : params.presence_penalty,
|
|
52
|
+
stop: params.stop,
|
|
53
|
+
stream,
|
|
54
|
+
};
|
|
55
|
+
// Pass thinking config via extra_body (DeepSeek extension)
|
|
56
|
+
if (params.thinking) {
|
|
57
|
+
requestParams.extra_body = {
|
|
58
|
+
...requestParams.extra_body,
|
|
59
|
+
thinking: params.thinking,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
// Pass response_format for JSON mode
|
|
63
|
+
if (params.response_format) {
|
|
64
|
+
requestParams.response_format = params.response_format;
|
|
65
|
+
}
|
|
66
|
+
if (params.tools?.length) {
|
|
67
|
+
requestParams.tools = params.tools;
|
|
68
|
+
}
|
|
69
|
+
if (params.tool_choice !== undefined) {
|
|
70
|
+
requestParams.tool_choice =
|
|
71
|
+
params.tool_choice;
|
|
72
|
+
}
|
|
73
|
+
return requestParams;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Wrap caught errors with appropriate custom error class
|
|
77
|
+
*/
|
|
78
|
+
wrapError(error, context) {
|
|
79
|
+
if (error instanceof ApiError)
|
|
80
|
+
throw error;
|
|
81
|
+
const message = getErrorMessage(error);
|
|
82
|
+
const cause = error instanceof Error ? error : undefined;
|
|
83
|
+
throw new ApiError(`${context}: ${message}`, { cause });
|
|
84
|
+
}
|
|
18
85
|
/**
|
|
19
86
|
* Create a chat completion (non-streaming)
|
|
20
87
|
*/
|
|
21
88
|
async createChatCompletion(params) {
|
|
22
89
|
try {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
model: params.model,
|
|
27
|
-
messages: params.messages,
|
|
28
|
-
temperature: params.temperature ?? 1.0,
|
|
29
|
-
max_tokens: params.max_tokens,
|
|
30
|
-
top_p: params.top_p,
|
|
31
|
-
frequency_penalty: params.frequency_penalty,
|
|
32
|
-
presence_penalty: params.presence_penalty,
|
|
33
|
-
stop: params.stop,
|
|
34
|
-
stream: false,
|
|
35
|
-
};
|
|
36
|
-
if (params.tools?.length) {
|
|
37
|
-
requestParams.tools = params.tools;
|
|
38
|
-
}
|
|
39
|
-
if (params.tool_choice !== undefined) {
|
|
40
|
-
requestParams.tool_choice = params.tool_choice;
|
|
41
|
-
}
|
|
42
|
-
const response = await this.client.chat.completions.create(requestParams);
|
|
90
|
+
const requestParams = this.buildRequestParams(params, false);
|
|
91
|
+
const rawResponse = await this.client.chat.completions.create(requestParams);
|
|
92
|
+
const response = rawResponse;
|
|
43
93
|
const choice = response.choices[0];
|
|
44
94
|
if (!choice) {
|
|
45
|
-
throw new
|
|
95
|
+
throw new ApiError('No response from DeepSeek API');
|
|
46
96
|
}
|
|
47
97
|
// Extract reasoning content if available (for deepseek-reasoner)
|
|
48
|
-
const reasoning_content =
|
|
98
|
+
const reasoning_content = hasReasoningContent(choice.message)
|
|
49
99
|
? choice.message.reasoning_content
|
|
50
100
|
: undefined;
|
|
51
101
|
// Extract tool_calls if present
|
|
52
|
-
const tool_calls = choice.message.tool_calls
|
|
102
|
+
const tool_calls = choice.message.tool_calls
|
|
103
|
+
?.map((tc) => ({
|
|
53
104
|
id: tc.id,
|
|
54
105
|
type: 'function',
|
|
55
106
|
function: {
|
|
@@ -65,6 +116,8 @@ export class DeepSeekClient {
|
|
|
65
116
|
prompt_tokens: response.usage?.prompt_tokens || 0,
|
|
66
117
|
completion_tokens: response.usage?.completion_tokens || 0,
|
|
67
118
|
total_tokens: response.usage?.total_tokens || 0,
|
|
119
|
+
prompt_cache_hit_tokens: response.usage?.prompt_cache_hit_tokens,
|
|
120
|
+
prompt_cache_miss_tokens: response.usage?.prompt_cache_miss_tokens,
|
|
68
121
|
},
|
|
69
122
|
finish_reason: choice.finish_reason || 'stop',
|
|
70
123
|
tool_calls: tool_calls?.length ? tool_calls : undefined,
|
|
@@ -72,7 +125,7 @@ export class DeepSeekClient {
|
|
|
72
125
|
}
|
|
73
126
|
catch (error) {
|
|
74
127
|
console.error('DeepSeek API Error:', error);
|
|
75
|
-
|
|
128
|
+
this.wrapError(error, 'DeepSeek API Error');
|
|
76
129
|
}
|
|
77
130
|
}
|
|
78
131
|
/**
|
|
@@ -81,25 +134,7 @@ export class DeepSeekClient {
|
|
|
81
134
|
*/
|
|
82
135
|
async createStreamingChatCompletion(params) {
|
|
83
136
|
try {
|
|
84
|
-
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
-
const requestParams = {
|
|
87
|
-
model: params.model,
|
|
88
|
-
messages: params.messages,
|
|
89
|
-
temperature: params.temperature ?? 1.0,
|
|
90
|
-
max_tokens: params.max_tokens,
|
|
91
|
-
top_p: params.top_p,
|
|
92
|
-
frequency_penalty: params.frequency_penalty,
|
|
93
|
-
presence_penalty: params.presence_penalty,
|
|
94
|
-
stop: params.stop,
|
|
95
|
-
stream: true,
|
|
96
|
-
};
|
|
97
|
-
if (params.tools?.length) {
|
|
98
|
-
requestParams.tools = params.tools;
|
|
99
|
-
}
|
|
100
|
-
if (params.tool_choice !== undefined) {
|
|
101
|
-
requestParams.tool_choice = params.tool_choice;
|
|
102
|
-
}
|
|
137
|
+
const requestParams = this.buildRequestParams(params, true);
|
|
103
138
|
const stream = await this.client.chat.completions.create(requestParams);
|
|
104
139
|
let fullContent = '';
|
|
105
140
|
let reasoningContent = '';
|
|
@@ -113,7 +148,8 @@ export class DeepSeekClient {
|
|
|
113
148
|
// Tool calls accumulation (index-based)
|
|
114
149
|
const toolCallsMap = new Map();
|
|
115
150
|
// Collect all chunks
|
|
116
|
-
for await (const
|
|
151
|
+
for await (const rawChunk of stream) {
|
|
152
|
+
const chunk = rawChunk;
|
|
117
153
|
const choice = chunk.choices[0];
|
|
118
154
|
if (!choice)
|
|
119
155
|
continue;
|
|
@@ -122,8 +158,8 @@ export class DeepSeekClient {
|
|
|
122
158
|
fullContent += choice.delta.content;
|
|
123
159
|
}
|
|
124
160
|
// Collect reasoning content (for deepseek-reasoner)
|
|
125
|
-
if (
|
|
126
|
-
reasoningContent += choice.delta.reasoning_content
|
|
161
|
+
if (choice.delta && hasReasoningContent(choice.delta)) {
|
|
162
|
+
reasoningContent += choice.delta.reasoning_content;
|
|
127
163
|
}
|
|
128
164
|
// Accumulate tool_calls deltas
|
|
129
165
|
if (choice.delta?.tool_calls) {
|
|
@@ -157,7 +193,13 @@ export class DeepSeekClient {
|
|
|
157
193
|
}
|
|
158
194
|
// Get usage info (usually in last chunk)
|
|
159
195
|
if (chunk.usage) {
|
|
160
|
-
usage =
|
|
196
|
+
usage = {
|
|
197
|
+
prompt_tokens: chunk.usage.prompt_tokens,
|
|
198
|
+
completion_tokens: chunk.usage.completion_tokens,
|
|
199
|
+
total_tokens: chunk.usage.total_tokens,
|
|
200
|
+
prompt_cache_hit_tokens: chunk.usage.prompt_cache_hit_tokens,
|
|
201
|
+
prompt_cache_miss_tokens: chunk.usage.prompt_cache_miss_tokens,
|
|
202
|
+
};
|
|
161
203
|
}
|
|
162
204
|
}
|
|
163
205
|
// Convert tool calls map to sorted array
|
|
@@ -177,7 +219,7 @@ export class DeepSeekClient {
|
|
|
177
219
|
}
|
|
178
220
|
catch (error) {
|
|
179
221
|
console.error('DeepSeek Streaming API Error:', error);
|
|
180
|
-
|
|
222
|
+
this.wrapError(error, 'DeepSeek Streaming API Error');
|
|
181
223
|
}
|
|
182
224
|
}
|
|
183
225
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepseek-client.js","sourceRoot":"","sources":["../src/deepseek-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"deepseek-client.js","sourceRoot":"","sources":["../src/deepseek-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAmB,MAAM,aAAa,CAAC;AASxD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElE,0DAA0D;AAC1D,MAAM,4BAA4B,GAAG;IACnC,aAAa;IACb,OAAO;IACP,mBAAmB;IACnB,kBAAkB;CACV,CAAC;AAEX,MAAM,OAAO,cAAc;IACjB,MAAM,CAAS;IAEvB;QACE,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAE3B,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC;YACvB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,MAAM,CAAC,cAAc;YAC9B,UAAU,EAAE,MAAM,CAAC,UAAU;SAC9B,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,kBAAkB,CACxB,MAA4B,EAC5B,MAAe;QAEf,MAAM,iBAAiB,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,KAAK,SAAS,CAAC;QAE9D,0DAA0D;QAC1D,IAAI,iBAAiB,EAAE,CAAC;YACtB,MAAM,QAAQ,GAAa,EAAE,CAAC;YAC9B,KAAK,MAAM,GAAG,IAAI,4BAA4B,EAAE,CAAC;gBAC/C,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,SAAS,EAAE,CAAC;oBAC9B,QAAQ,CAAC,IAAI,CAAC,GAAG,CA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
/**
|
|
2
|
+
* Custom Error Classes
|
|
3
|
+
* Structured error hierarchy for DeepSeek MCP Server
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Base error class for all DeepSeek MCP errors
|
|
7
|
+
*/
|
|
8
|
+
export declare class BaseError extends Error {
|
|
9
|
+
constructor(message: string, options?: ErrorOptions);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Configuration validation error
|
|
13
|
+
* Thrown when config validation fails (replaces process.exit)
|
|
14
|
+
*/
|
|
15
|
+
export declare class ConfigError extends BaseError {
|
|
16
|
+
readonly issues: Array<{
|
|
17
|
+
path: string;
|
|
18
|
+
message: string;
|
|
19
|
+
}>;
|
|
20
|
+
constructor(message: string, issues?: Array<{
|
|
21
|
+
path: string;
|
|
22
|
+
message: string;
|
|
23
|
+
}>, options?: ErrorOptions);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* DeepSeek API error
|
|
27
|
+
* Wraps errors from the DeepSeek/OpenAI API
|
|
28
|
+
*/
|
|
29
|
+
export declare class ApiError extends BaseError {
|
|
30
|
+
readonly statusCode?: number;
|
|
31
|
+
readonly retryable: boolean;
|
|
32
|
+
constructor(message: string, options?: ErrorOptions & {
|
|
33
|
+
statusCode?: number;
|
|
34
|
+
retryable?: boolean;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Rate limit error (429)
|
|
39
|
+
*/
|
|
40
|
+
export declare class RateLimitError extends ApiError {
|
|
41
|
+
constructor(message: string, options?: ErrorOptions);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Authentication error (401)
|
|
45
|
+
*/
|
|
46
|
+
export declare class AuthenticationError extends ApiError {
|
|
47
|
+
constructor(message: string, options?: ErrorOptions);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Input validation error
|
|
51
|
+
*/
|
|
52
|
+
export declare class ValidationError extends BaseError {
|
|
53
|
+
readonly zodErrors?: Array<{
|
|
54
|
+
path: string;
|
|
55
|
+
message: string;
|
|
56
|
+
}>;
|
|
57
|
+
constructor(message: string, zodErrors?: Array<{
|
|
58
|
+
path: string;
|
|
59
|
+
message: string;
|
|
60
|
+
}>, options?: ErrorOptions);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Network/connection error
|
|
64
|
+
*/
|
|
65
|
+
export declare class ConnectionError extends BaseError {
|
|
66
|
+
readonly retryable: boolean;
|
|
67
|
+
constructor(message: string, options?: ErrorOptions & {
|
|
68
|
+
retryable?: boolean;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;gBACtB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAIpD;AAED;;;GAGG;AACH,qBAAa,WAAY,SAAQ,SAAS;IACxC,SAAgB,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;gBAG/D,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAM,EACrD,OAAO,CAAC,EAAE,YAAY;CAKzB;AAED;;;GAGG;AACH,qBAAa,QAAS,SAAQ,SAAS;IACrC,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpC,SAAgB,SAAS,EAAE,OAAO,CAAC;gBAGjC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,YAAY,GAAG;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;CAMxE;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,QAAQ;gBAC9B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAGpD;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,QAAQ;gBACnC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAGpD;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,SAAgB,SAAS,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;gBAGnE,OAAO,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,EACpD,OAAO,CAAC,EAAE,YAAY;CAKzB;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,SAAgB,SAAS,EAAE,OAAO,CAAC;gBAEvB,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;CAI9E"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Error Classes
|
|
3
|
+
* Structured error hierarchy for DeepSeek MCP Server
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Base error class for all DeepSeek MCP errors
|
|
7
|
+
*/
|
|
8
|
+
export class BaseError extends Error {
|
|
9
|
+
constructor(message, options) {
|
|
10
|
+
super(message, options);
|
|
11
|
+
this.name = this.constructor.name;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Configuration validation error
|
|
16
|
+
* Thrown when config validation fails (replaces process.exit)
|
|
17
|
+
*/
|
|
18
|
+
export class ConfigError extends BaseError {
|
|
19
|
+
issues;
|
|
20
|
+
constructor(message, issues = [], options) {
|
|
21
|
+
super(message, options);
|
|
22
|
+
this.issues = issues;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* DeepSeek API error
|
|
27
|
+
* Wraps errors from the DeepSeek/OpenAI API
|
|
28
|
+
*/
|
|
29
|
+
export class ApiError extends BaseError {
|
|
30
|
+
statusCode;
|
|
31
|
+
retryable;
|
|
32
|
+
constructor(message, options) {
|
|
33
|
+
super(message, options);
|
|
34
|
+
this.statusCode = options?.statusCode;
|
|
35
|
+
this.retryable = options?.retryable ?? false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Rate limit error (429)
|
|
40
|
+
*/
|
|
41
|
+
export class RateLimitError extends ApiError {
|
|
42
|
+
constructor(message, options) {
|
|
43
|
+
super(message, { ...options, statusCode: 429, retryable: true });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Authentication error (401)
|
|
48
|
+
*/
|
|
49
|
+
export class AuthenticationError extends ApiError {
|
|
50
|
+
constructor(message, options) {
|
|
51
|
+
super(message, { ...options, statusCode: 401, retryable: false });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Input validation error
|
|
56
|
+
*/
|
|
57
|
+
export class ValidationError extends BaseError {
|
|
58
|
+
zodErrors;
|
|
59
|
+
constructor(message, zodErrors, options) {
|
|
60
|
+
super(message, options);
|
|
61
|
+
this.zodErrors = zodErrors;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Network/connection error
|
|
66
|
+
*/
|
|
67
|
+
export class ConnectionError extends BaseError {
|
|
68
|
+
retryable;
|
|
69
|
+
constructor(message, options) {
|
|
70
|
+
super(message, options);
|
|
71
|
+
this.retryable = options?.retryable ?? true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
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,CAAC;IACpE,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5B,SAAS,CAA4C;IAErE,YACE,OAAe,EACf,SAAoD,EACpD,OAAsB;QAEtB,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAC5B,SAAS,CAAU;IAEnC,YAAY,OAAe,EAAE,OAAgD;QAC3E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,IAAI,CAAC;IAC9C,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* DeepSeek MCP Server
|
|
4
4
|
* Model Context Protocol server for DeepSeek API integration
|
|
5
|
-
*
|
|
6
|
-
* This server exposes DeepSeek's chat and reasoning models as MCP tools
|
|
7
|
-
* that can be used by Claude Code and other MCP clients.
|
|
8
5
|
*/
|
|
9
6
|
export {};
|
|
10
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;GAGG"}
|