@deepstrike/sdk 0.1.15 → 0.1.16
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/dist/index.d.ts +1 -0
- package/dist/providers/anthropic.js +4 -1
- package/dist/providers/base.d.ts +12 -0
- package/dist/providers/base.js +75 -0
- package/dist/providers/catalog.d.ts +3 -2
- package/dist/providers/catalog.js +61 -13
- package/dist/providers/deepseek.js +1 -1
- package/dist/providers/gemini.d.ts +3 -0
- package/dist/providers/gemini.js +26 -6
- package/dist/providers/glm.d.ts +9 -0
- package/dist/providers/glm.js +21 -0
- package/dist/providers/kimi.js +2 -0
- package/dist/providers/minimax.js +5 -0
- package/dist/providers/openai-responses.js +9 -0
- package/dist/providers/openai.js +52 -6
- package/dist/providers/profiles.d.ts +1304 -242
- package/dist/providers/profiles.js +429 -26
- package/dist/providers/qwen.d.ts +3 -1
- package/dist/providers/qwen.js +43 -13
- package/dist/runtime/provider-replay.js +30 -1
- package/package.json +2 -2
package/dist/providers/qwen.js
CHANGED
|
@@ -5,16 +5,19 @@ import { OpenAIChatAdapter } from "./openai-chat.js";
|
|
|
5
5
|
import { endpointProfiles } from "./profiles.js";
|
|
6
6
|
const QWEN_BASE = endpointProfiles["qwen.dashscope"].baseURL;
|
|
7
7
|
const QWEN_POLICIES = {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"qwen3-
|
|
14
|
-
"qwen3-
|
|
15
|
-
"qwen3-
|
|
16
|
-
"qwen3-
|
|
17
|
-
"qwen3-
|
|
8
|
+
"qwen3.7-max-preview": { maxTurns: 45 },
|
|
9
|
+
"qwen3.7-plus-preview": { maxTurns: 40 },
|
|
10
|
+
"qwen3.6-max-preview": { maxTurns: 40 },
|
|
11
|
+
"qwen3.6-plus": { maxTurns: 35 },
|
|
12
|
+
"qwen3.6-flash": { maxTurns: 20 },
|
|
13
|
+
"qwen3.6-35b-a3b": { maxTurns: 25 },
|
|
14
|
+
"qwen3.6-27b": { maxTurns: 25 },
|
|
15
|
+
"qwen3.5-plus": { maxTurns: 35 },
|
|
16
|
+
"qwen3.5-flash": { maxTurns: 20 },
|
|
17
|
+
"qwen3.5-397b-a17b": { maxTurns: 35 },
|
|
18
|
+
"qwen3.5-122b-a10b": { maxTurns: 25 },
|
|
19
|
+
"qwen3.5-35b-a3b": { maxTurns: 20 },
|
|
20
|
+
"qwen3.5-27b": { maxTurns: 20 },
|
|
18
21
|
};
|
|
19
22
|
export class QwenProvider {
|
|
20
23
|
model;
|
|
@@ -23,7 +26,7 @@ export class QwenProvider {
|
|
|
23
26
|
maxRetries;
|
|
24
27
|
baseDelay;
|
|
25
28
|
chat = new OpenAIChatAdapter();
|
|
26
|
-
constructor(apiKey, model = "
|
|
29
|
+
constructor(apiKey, model = "qwen3.6-plus", retry = { maxRetries: 3, baseDelay: 1000 }, baseURL = QWEN_BASE) {
|
|
27
30
|
this.model = model;
|
|
28
31
|
this.client = withServerRuntimeGuard(() => new OpenAI({ apiKey, baseURL }));
|
|
29
32
|
this.circuit = new CircuitBreaker();
|
|
@@ -33,6 +36,17 @@ export class QwenProvider {
|
|
|
33
36
|
runtimePolicy() {
|
|
34
37
|
return QWEN_POLICIES[this.model] ?? {};
|
|
35
38
|
}
|
|
39
|
+
peekProviderReplay(message) {
|
|
40
|
+
const fields = this.chat.peekReplayFields(message);
|
|
41
|
+
if (!fields || !("reasoning_content" in fields))
|
|
42
|
+
return undefined;
|
|
43
|
+
return { reasoning_content: String(fields.reasoning_content ?? "") };
|
|
44
|
+
}
|
|
45
|
+
seedProviderReplay(message, replay) {
|
|
46
|
+
if (replay.reasoning_content !== undefined) {
|
|
47
|
+
this.chat.rememberReplayFields(message, { reasoning_content: replay.reasoning_content });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
36
50
|
async complete(context, tools, extensions) {
|
|
37
51
|
if (this.circuit.isOpen())
|
|
38
52
|
throw new Error("Circuit breaker open");
|
|
@@ -66,6 +80,8 @@ export class QwenProvider {
|
|
|
66
80
|
const msgs = this.chat.buildMessages(context);
|
|
67
81
|
const toolCallBufs = {};
|
|
68
82
|
const emittedToolCallIndexes = new Set();
|
|
83
|
+
let reasoningContent = "";
|
|
84
|
+
let finalText = "";
|
|
69
85
|
const extraBody = this.thinkingExtraBody(extensions);
|
|
70
86
|
const stream = await this.client.chat.completions.create({
|
|
71
87
|
...this.requestExtensions(extensions),
|
|
@@ -86,10 +102,14 @@ export class QwenProvider {
|
|
|
86
102
|
if (!choice)
|
|
87
103
|
continue;
|
|
88
104
|
const delta = choice.delta;
|
|
89
|
-
if (delta.reasoning_content)
|
|
105
|
+
if (delta.reasoning_content) {
|
|
106
|
+
reasoningContent += String(delta.reasoning_content);
|
|
90
107
|
yield { type: "thinking_delta", delta: delta.reasoning_content };
|
|
91
|
-
|
|
108
|
+
}
|
|
109
|
+
if (delta.content) {
|
|
110
|
+
finalText += String(delta.content);
|
|
92
111
|
yield { type: "text_delta", delta: delta.content };
|
|
112
|
+
}
|
|
93
113
|
for (const tc of delta.tool_calls ?? []) {
|
|
94
114
|
const idx = tc.index;
|
|
95
115
|
if (!toolCallBufs[idx])
|
|
@@ -99,6 +119,10 @@ export class QwenProvider {
|
|
|
99
119
|
toolCallBufs[idx].argsBuf += tc.function?.arguments ?? "";
|
|
100
120
|
}
|
|
101
121
|
if (choice.finish_reason === "tool_calls") {
|
|
122
|
+
const toolCalls = Object.values(toolCallBufs).map(tb => ({
|
|
123
|
+
id: tb.id, name: tb.name, arguments: tb.argsBuf || "{}",
|
|
124
|
+
}));
|
|
125
|
+
this.chat.rememberReplayFields({ content: finalText, toolCalls }, { reasoning_content: reasoningContent });
|
|
102
126
|
for (const [index, tb] of Object.entries(toolCallBufs)) {
|
|
103
127
|
const idx = Number(index);
|
|
104
128
|
if (emittedToolCallIndexes.has(idx))
|
|
@@ -115,6 +139,12 @@ export class QwenProvider {
|
|
|
115
139
|
}
|
|
116
140
|
}
|
|
117
141
|
}
|
|
142
|
+
const toolCalls = Object.values(toolCallBufs).map(tb => ({
|
|
143
|
+
id: tb.id, name: tb.name, arguments: tb.argsBuf || "{}",
|
|
144
|
+
}));
|
|
145
|
+
if (toolCalls.length || reasoningContent) {
|
|
146
|
+
this.chat.rememberReplayFields({ content: finalText, toolCalls }, { reasoning_content: reasoningContent });
|
|
147
|
+
}
|
|
118
148
|
for (const [index, tb] of Object.entries(toolCallBufs)) {
|
|
119
149
|
const idx = Number(index);
|
|
120
150
|
if (emittedToolCallIndexes.has(idx))
|
|
@@ -1,7 +1,36 @@
|
|
|
1
|
+
function sortObjectKeys(val) {
|
|
2
|
+
if (val === null || typeof val !== "object") {
|
|
3
|
+
return val;
|
|
4
|
+
}
|
|
5
|
+
if (Array.isArray(val)) {
|
|
6
|
+
return val.map(sortObjectKeys);
|
|
7
|
+
}
|
|
8
|
+
const sortedKeys = Object.keys(val).sort();
|
|
9
|
+
const result = {};
|
|
10
|
+
for (const key of sortedKeys) {
|
|
11
|
+
result[key] = sortObjectKeys(val[key]);
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
1
15
|
export function assistantReplayKey(message) {
|
|
16
|
+
const toolCalls = (message.toolCalls ?? []).map(tc => {
|
|
17
|
+
let normalizedArgs = tc.arguments;
|
|
18
|
+
try {
|
|
19
|
+
const parsed = typeof tc.arguments === "string" ? JSON.parse(tc.arguments) : tc.arguments;
|
|
20
|
+
normalizedArgs = JSON.stringify(sortObjectKeys(parsed));
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
// fallback
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
id: tc.id,
|
|
27
|
+
name: tc.name,
|
|
28
|
+
arguments: normalizedArgs,
|
|
29
|
+
};
|
|
30
|
+
});
|
|
2
31
|
return JSON.stringify({
|
|
3
32
|
content: message.content,
|
|
4
|
-
toolCalls
|
|
33
|
+
toolCalls,
|
|
5
34
|
});
|
|
6
35
|
}
|
|
7
36
|
export function seedProviderReplayFromEvents(provider, events) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepstrike/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "DeepStrike Node.js SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@anthropic-ai/sdk": "^0.39.0",
|
|
20
|
-
"@deepstrike/core": "0.1.
|
|
20
|
+
"@deepstrike/core": "0.1.16",
|
|
21
21
|
"@google/generative-ai": "^0.24.1",
|
|
22
22
|
"openai": "^4.77.0"
|
|
23
23
|
},
|