@deepstrike/sdk 0.1.12 → 0.1.14
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/README.md +82 -52
- package/dist/collaboration/harness.js +6 -1
- package/dist/collaboration/modes/creator-verifier.d.ts +2 -2
- package/dist/collaboration/modes/creator-verifier.js +2 -2
- package/dist/collaboration/pool.d.ts +4 -35
- package/dist/collaboration/pool.js +18 -44
- package/dist/harness/harness.d.ts +19 -7
- package/dist/harness/harness.js +27 -22
- package/dist/index.d.ts +19 -7
- package/dist/index.js +15 -3
- package/dist/kernel.d.ts +1 -0
- package/dist/kernel.js +10 -1
- package/dist/memory/protocols.d.ts +0 -4
- package/dist/providers/anthropic.d.ts +7 -2
- package/dist/providers/anthropic.js +48 -9
- package/dist/providers/base.d.ts +1 -0
- package/dist/providers/base.js +6 -0
- package/dist/providers/deepseek.d.ts +4 -2
- package/dist/providers/deepseek.js +49 -1
- package/dist/providers/gemini.d.ts +4 -2
- package/dist/providers/gemini.js +24 -5
- package/dist/providers/kimi.d.ts +3 -1
- package/dist/providers/kimi.js +10 -0
- package/dist/providers/minimax.d.ts +3 -1
- package/dist/providers/minimax.js +8 -0
- package/dist/providers/ollama.d.ts +5 -2
- package/dist/providers/ollama.js +63 -7
- package/dist/providers/openai-responses.d.ts +4 -2
- package/dist/providers/openai-responses.js +23 -3
- package/dist/providers/openai.d.ts +4 -2
- package/dist/providers/openai.js +44 -3
- package/dist/providers/profiles.d.ts +502 -6
- package/dist/providers/profiles.js +225 -82
- package/dist/providers/qwen.d.ts +5 -2
- package/dist/providers/qwen.js +59 -11
- package/dist/runtime/credential-vault.d.ts +18 -0
- package/dist/runtime/credential-vault.js +33 -0
- package/dist/runtime/execution-plane.d.ts +38 -0
- package/dist/runtime/execution-plane.js +146 -0
- package/dist/runtime/mcp-proxy-plane.d.ts +51 -0
- package/dist/runtime/mcp-proxy-plane.js +204 -0
- package/dist/runtime/process-sandbox-plane.d.ts +32 -0
- package/dist/runtime/process-sandbox-plane.js +109 -0
- package/dist/runtime/remote-vpc-plane.d.ts +48 -0
- package/dist/runtime/remote-vpc-plane.js +82 -0
- package/dist/runtime/runner.d.ts +49 -0
- package/dist/runtime/runner.js +364 -0
- package/dist/runtime/session-log.d.ts +67 -0
- package/dist/runtime/session-log.js +84 -0
- package/dist/tools/index.d.ts +7 -2
- package/dist/tools/index.js +83 -0
- package/dist/types.d.ts +52 -1
- package/package.json +3 -2
- package/dist/agent.d.ts +0 -88
- package/dist/agent.js +0 -430
package/dist/providers/ollama.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import { normalizeToolCall } from "./base.js";
|
|
1
|
+
import { normalizeToolCall, omitExtensionKeys } from "./base.js";
|
|
2
|
+
// Prefix-based policy for local models (first match wins)
|
|
3
|
+
const OLLAMA_PREFIX_POLICIES = [
|
|
4
|
+
["deepseek-r1", { maxTurns: 40 }],
|
|
5
|
+
["qwq", { maxTurns: 35 }],
|
|
6
|
+
["llama3.3", { maxTurns: 25 }],
|
|
7
|
+
["llama3.2", { maxTurns: 20 }],
|
|
8
|
+
["llama3.1", { maxTurns: 20 }],
|
|
9
|
+
["llama3", { maxTurns: 20 }],
|
|
10
|
+
["mistral", { maxTurns: 20 }],
|
|
11
|
+
["gemma2", { maxTurns: 20 }],
|
|
12
|
+
["phi4", { maxTurns: 20 }],
|
|
13
|
+
["phi3", { maxTurns: 15 }],
|
|
14
|
+
["codellama", { maxTurns: 20 }],
|
|
15
|
+
];
|
|
2
16
|
export class OllamaProvider {
|
|
3
17
|
model;
|
|
4
18
|
baseUrl;
|
|
@@ -6,6 +20,14 @@ export class OllamaProvider {
|
|
|
6
20
|
this.model = model;
|
|
7
21
|
this.baseUrl = baseUrl;
|
|
8
22
|
}
|
|
23
|
+
runtimePolicy() {
|
|
24
|
+
const m = this.model.toLowerCase();
|
|
25
|
+
for (const [prefix, policy] of OLLAMA_PREFIX_POLICIES) {
|
|
26
|
+
if (m.startsWith(prefix))
|
|
27
|
+
return policy;
|
|
28
|
+
}
|
|
29
|
+
return { maxTurns: 20 };
|
|
30
|
+
}
|
|
9
31
|
toOllamaMessages(context) {
|
|
10
32
|
const result = [];
|
|
11
33
|
if (context.systemText)
|
|
@@ -22,11 +44,26 @@ export class OllamaProvider {
|
|
|
22
44
|
}
|
|
23
45
|
return result;
|
|
24
46
|
}
|
|
25
|
-
|
|
47
|
+
buildTools(tools) {
|
|
48
|
+
return tools.map(t => ({
|
|
49
|
+
type: "function",
|
|
50
|
+
function: { name: t.name, description: t.description, parameters: JSON.parse(t.parameters) },
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
requestExtensions(extensions) {
|
|
54
|
+
return omitExtensionKeys(extensions, ["model", "messages", "tools", "stream"]);
|
|
55
|
+
}
|
|
56
|
+
async complete(context, tools, extensions) {
|
|
26
57
|
const resp = await fetch(`${this.baseUrl}/api/chat`, {
|
|
27
58
|
method: "POST",
|
|
28
59
|
headers: { "Content-Type": "application/json" },
|
|
29
|
-
body: JSON.stringify({
|
|
60
|
+
body: JSON.stringify({
|
|
61
|
+
...this.requestExtensions(extensions),
|
|
62
|
+
model: this.model,
|
|
63
|
+
messages: this.toOllamaMessages(context),
|
|
64
|
+
...(tools.length ? { tools: this.buildTools(tools) } : {}),
|
|
65
|
+
stream: false,
|
|
66
|
+
}),
|
|
30
67
|
});
|
|
31
68
|
if (!resp.ok)
|
|
32
69
|
throw new Error(`Ollama error: ${resp.status}`);
|
|
@@ -37,13 +74,20 @@ export class OllamaProvider {
|
|
|
37
74
|
const resp = await fetch(`${this.baseUrl}/api/chat`, {
|
|
38
75
|
method: "POST",
|
|
39
76
|
headers: { "Content-Type": "application/json" },
|
|
40
|
-
body: JSON.stringify({
|
|
77
|
+
body: JSON.stringify({
|
|
78
|
+
...this.requestExtensions(extensions),
|
|
79
|
+
model: this.model,
|
|
80
|
+
messages: this.toOllamaMessages(context),
|
|
81
|
+
...(tools.length ? { tools: this.buildTools(tools) } : {}),
|
|
82
|
+
stream: true,
|
|
83
|
+
}),
|
|
41
84
|
});
|
|
42
85
|
if (!resp.ok)
|
|
43
86
|
throw new Error(`Ollama error: ${resp.status}`);
|
|
44
87
|
const reader = resp.body.getReader();
|
|
45
88
|
const decoder = new TextDecoder();
|
|
46
89
|
let buf = "";
|
|
90
|
+
const pendingToolCalls = new Map();
|
|
47
91
|
while (true) {
|
|
48
92
|
const { done, value } = await reader.read();
|
|
49
93
|
if (done)
|
|
@@ -59,13 +103,25 @@ export class OllamaProvider {
|
|
|
59
103
|
if (chunk.message?.content)
|
|
60
104
|
yield { type: "text_delta", delta: chunk.message.content };
|
|
61
105
|
for (const tc of chunk.message?.tool_calls ?? []) {
|
|
62
|
-
const norm = normalizeToolCall(
|
|
63
|
-
if (norm)
|
|
64
|
-
|
|
106
|
+
const norm = normalizeToolCall("", tc.function.name, tc.function.arguments);
|
|
107
|
+
if (!norm)
|
|
108
|
+
continue;
|
|
109
|
+
const args = JSON.parse(norm.arguments);
|
|
110
|
+
const key = `${norm.name}:${norm.arguments}`;
|
|
111
|
+
if (!pendingToolCalls.has(key)) {
|
|
112
|
+
pendingToolCalls.set(key, {
|
|
113
|
+
id: `call_${pendingToolCalls.size + 1}`,
|
|
114
|
+
name: norm.name,
|
|
115
|
+
arguments: args,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
65
118
|
}
|
|
66
119
|
}
|
|
67
120
|
catch { /* skip malformed lines */ }
|
|
68
121
|
}
|
|
69
122
|
}
|
|
123
|
+
for (const tc of pendingToolCalls.values()) {
|
|
124
|
+
yield { type: "tool_call", id: tc.id, name: tc.name, arguments: tc.arguments };
|
|
125
|
+
}
|
|
70
126
|
}
|
|
71
127
|
}
|
|
@@ -35,8 +35,10 @@ export declare class OpenAIResponsesProvider implements LLMProvider {
|
|
|
35
35
|
maxRetries: number;
|
|
36
36
|
baseDelay: number;
|
|
37
37
|
}, baseURL?: string);
|
|
38
|
+
runtimePolicy(): import("../types.js").RuntimePolicy;
|
|
38
39
|
createRunState(): OpenAIResponsesRunState;
|
|
39
|
-
complete(context: RenderedContext, tools: ToolSchema[]): Promise<Message>;
|
|
40
|
-
stream(context: RenderedContext, tools: ToolSchema[],
|
|
40
|
+
complete(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>): Promise<Message>;
|
|
41
|
+
stream(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>, state?: ProviderRunState): AsyncIterable<StreamEvent>;
|
|
42
|
+
private requestExtensions;
|
|
41
43
|
private asRunState;
|
|
42
44
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import OpenAI from "openai";
|
|
2
2
|
import { withServerRuntimeGuard } from "../runtime/server.js";
|
|
3
|
-
import { CircuitBreaker } from "./base.js";
|
|
3
|
+
import { CircuitBreaker, omitExtensionKeys } from "./base.js";
|
|
4
4
|
import { normalizeToolCall } from "./base.js";
|
|
5
5
|
export class OpenAIResponsesAdapter {
|
|
6
6
|
buildTools(tools) {
|
|
@@ -113,10 +113,23 @@ export class OpenAIResponsesProvider {
|
|
|
113
113
|
this.maxRetries = retry.maxRetries;
|
|
114
114
|
this.baseDelay = retry.baseDelay;
|
|
115
115
|
}
|
|
116
|
+
runtimePolicy() {
|
|
117
|
+
const table = {
|
|
118
|
+
"gpt-4.1": { maxTurns: 35 },
|
|
119
|
+
"gpt-4.1-mini": { maxTurns: 20 },
|
|
120
|
+
"gpt-4.1-nano": { maxTurns: 15 },
|
|
121
|
+
"gpt-5": { maxTurns: 50 },
|
|
122
|
+
"gpt-5-mini": { maxTurns: 25 },
|
|
123
|
+
"o3": { maxTurns: 50 },
|
|
124
|
+
"o3-mini": { maxTurns: 25 },
|
|
125
|
+
"o4-mini": { maxTurns: 25 },
|
|
126
|
+
};
|
|
127
|
+
return table[this.model] ?? {};
|
|
128
|
+
}
|
|
116
129
|
createRunState() {
|
|
117
130
|
return { coveredMessageCount: 0 };
|
|
118
131
|
}
|
|
119
|
-
async complete(context, tools) {
|
|
132
|
+
async complete(context, tools, extensions) {
|
|
120
133
|
if (this.circuit.isOpen())
|
|
121
134
|
throw new Error("Circuit breaker open");
|
|
122
135
|
let lastErr;
|
|
@@ -124,6 +137,7 @@ export class OpenAIResponsesProvider {
|
|
|
124
137
|
try {
|
|
125
138
|
const instructions = this.responses.buildInstructions(context);
|
|
126
139
|
const resp = await this.client.responses.create({
|
|
140
|
+
...this.requestExtensions(extensions),
|
|
127
141
|
model: this.model,
|
|
128
142
|
input: this.responses.buildInput(context),
|
|
129
143
|
...(instructions ? { instructions } : {}),
|
|
@@ -147,11 +161,12 @@ export class OpenAIResponsesProvider {
|
|
|
147
161
|
}
|
|
148
162
|
throw lastErr;
|
|
149
163
|
}
|
|
150
|
-
async *stream(context, tools,
|
|
164
|
+
async *stream(context, tools, extensions, state) {
|
|
151
165
|
const runState = this.asRunState(state);
|
|
152
166
|
const functionCalls = new Map();
|
|
153
167
|
const instructions = this.responses.buildInstructions(context);
|
|
154
168
|
const stream = await this.client.responses.create({
|
|
169
|
+
...this.requestExtensions(extensions),
|
|
155
170
|
model: this.model,
|
|
156
171
|
input: this.responses.buildInput(context, runState),
|
|
157
172
|
...(instructions ? { instructions } : {}),
|
|
@@ -204,6 +219,11 @@ export class OpenAIResponsesProvider {
|
|
|
204
219
|
}
|
|
205
220
|
}
|
|
206
221
|
}
|
|
222
|
+
requestExtensions(extensions) {
|
|
223
|
+
return omitExtensionKeys(extensions, [
|
|
224
|
+
"model", "input", "instructions", "tools", "stream", "previous_response_id",
|
|
225
|
+
]);
|
|
226
|
+
}
|
|
207
227
|
asRunState(state) {
|
|
208
228
|
if (!state)
|
|
209
229
|
return this.createRunState();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import OpenAI from "openai";
|
|
2
|
-
import type { Message, RenderedContext, ToolSchema, StreamEvent, LLMProvider } from "../types.js";
|
|
2
|
+
import type { Message, RenderedContext, ToolSchema, StreamEvent, LLMProvider, RuntimePolicy } from "../types.js";
|
|
3
3
|
import { CircuitBreaker } from "./base.js";
|
|
4
4
|
import { OpenAIChatAdapter } from "./openai-chat.js";
|
|
5
5
|
export declare class OpenAIChatProvider implements LLMProvider {
|
|
@@ -13,7 +13,9 @@ export declare class OpenAIChatProvider implements LLMProvider {
|
|
|
13
13
|
maxRetries: number;
|
|
14
14
|
baseDelay: number;
|
|
15
15
|
}, baseURL?: string);
|
|
16
|
-
|
|
16
|
+
runtimePolicy(): RuntimePolicy;
|
|
17
|
+
complete(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>): Promise<Message>;
|
|
17
18
|
stream(context: RenderedContext, tools: ToolSchema[], extensions?: Record<string, unknown>): AsyncIterable<StreamEvent>;
|
|
19
|
+
protected requestExtensions(extensions?: Record<string, unknown>): Record<string, unknown>;
|
|
18
20
|
}
|
|
19
21
|
export { OpenAIChatProvider as OpenAIProvider };
|
package/dist/providers/openai.js
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import OpenAI from "openai";
|
|
2
2
|
import { withServerRuntimeGuard } from "../runtime/server.js";
|
|
3
|
-
import { CircuitBreaker } from "./base.js";
|
|
3
|
+
import { CircuitBreaker, omitExtensionKeys } from "./base.js";
|
|
4
4
|
import { OpenAIChatAdapter } from "./openai-chat.js";
|
|
5
|
+
const OPENAI_POLICIES = {
|
|
6
|
+
"gpt-4o": { maxTurns: 25 },
|
|
7
|
+
"gpt-4o-mini": { maxTurns: 15 },
|
|
8
|
+
"gpt-4.1": { maxTurns: 35 },
|
|
9
|
+
"gpt-4.1-mini": { maxTurns: 20 },
|
|
10
|
+
"gpt-4.1-nano": { maxTurns: 15 },
|
|
11
|
+
"gpt-5": { maxTurns: 50 },
|
|
12
|
+
"gpt-5-mini": { maxTurns: 25 },
|
|
13
|
+
"o1": { maxTurns: 50 },
|
|
14
|
+
"o1-mini": { maxTurns: 25 },
|
|
15
|
+
"o3": { maxTurns: 50 },
|
|
16
|
+
"o3-mini": { maxTurns: 25 },
|
|
17
|
+
"o4-mini": { maxTurns: 25 },
|
|
18
|
+
};
|
|
5
19
|
export class OpenAIChatProvider {
|
|
6
20
|
model;
|
|
7
21
|
client;
|
|
@@ -16,7 +30,10 @@ export class OpenAIChatProvider {
|
|
|
16
30
|
this.maxRetries = retry.maxRetries;
|
|
17
31
|
this.baseDelay = retry.baseDelay;
|
|
18
32
|
}
|
|
19
|
-
|
|
33
|
+
runtimePolicy() {
|
|
34
|
+
return OPENAI_POLICIES[this.model] ?? {};
|
|
35
|
+
}
|
|
36
|
+
async complete(context, tools, extensions) {
|
|
20
37
|
if (this.circuit.isOpen())
|
|
21
38
|
throw new Error("Circuit breaker open");
|
|
22
39
|
const msgs = this.chat.buildMessages(context);
|
|
@@ -24,6 +41,7 @@ export class OpenAIChatProvider {
|
|
|
24
41
|
for (let i = 0; i < this.maxRetries; i++) {
|
|
25
42
|
try {
|
|
26
43
|
const resp = await this.client.chat.completions.create({
|
|
44
|
+
...this.requestExtensions(extensions),
|
|
27
45
|
model: this.model,
|
|
28
46
|
messages: msgs,
|
|
29
47
|
...(tools.length ? { tools: this.chat.buildTools(tools) } : {}),
|
|
@@ -45,7 +63,9 @@ export class OpenAIChatProvider {
|
|
|
45
63
|
async *stream(context, tools, extensions) {
|
|
46
64
|
const msgs = this.chat.buildMessages(context);
|
|
47
65
|
const toolCallBufs = {};
|
|
66
|
+
const emittedToolCallIndexes = new Set();
|
|
48
67
|
const stream = await this.client.chat.completions.create({
|
|
68
|
+
...this.requestExtensions(extensions),
|
|
49
69
|
model: this.model,
|
|
50
70
|
messages: msgs,
|
|
51
71
|
...(tools.length ? { tools: this.chat.buildTools(tools) } : {}),
|
|
@@ -73,7 +93,10 @@ export class OpenAIChatProvider {
|
|
|
73
93
|
toolCallBufs[idx].argsBuf += tc.function?.arguments ?? "";
|
|
74
94
|
}
|
|
75
95
|
if (choice.finish_reason === "tool_calls") {
|
|
76
|
-
for (const tb of Object.
|
|
96
|
+
for (const [index, tb] of Object.entries(toolCallBufs)) {
|
|
97
|
+
const idx = Number(index);
|
|
98
|
+
if (emittedToolCallIndexes.has(idx))
|
|
99
|
+
continue;
|
|
77
100
|
let args = {};
|
|
78
101
|
try {
|
|
79
102
|
args = JSON.parse(tb.argsBuf || "{}");
|
|
@@ -81,12 +104,30 @@ export class OpenAIChatProvider {
|
|
|
81
104
|
catch {
|
|
82
105
|
args = {};
|
|
83
106
|
}
|
|
107
|
+
emittedToolCallIndexes.add(idx);
|
|
84
108
|
yield { type: "tool_call", id: tb.id, name: tb.name, arguments: args };
|
|
85
109
|
}
|
|
86
110
|
}
|
|
87
111
|
}
|
|
112
|
+
for (const [index, tb] of Object.entries(toolCallBufs)) {
|
|
113
|
+
const idx = Number(index);
|
|
114
|
+
if (emittedToolCallIndexes.has(idx))
|
|
115
|
+
continue;
|
|
116
|
+
let args = {};
|
|
117
|
+
try {
|
|
118
|
+
args = JSON.parse(tb.argsBuf || "{}");
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
args = {};
|
|
122
|
+
}
|
|
123
|
+
emittedToolCallIndexes.add(idx);
|
|
124
|
+
yield { type: "tool_call", id: tb.id, name: tb.name, arguments: args };
|
|
125
|
+
}
|
|
88
126
|
if (totalTokens > 0)
|
|
89
127
|
yield { type: "usage", totalTokens };
|
|
90
128
|
}
|
|
129
|
+
requestExtensions(extensions) {
|
|
130
|
+
return omitExtensionKeys(extensions, ["model", "messages", "tools", "stream", "stream_options"]);
|
|
131
|
+
}
|
|
91
132
|
}
|
|
92
133
|
export { OpenAIChatProvider as OpenAIProvider };
|