@deepstrike/sdk 0.1.5 → 0.1.8
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 +31 -20
- package/dist/agent.d.ts +2 -1
- package/dist/agent.js +18 -20
- package/dist/governance.d.ts +17 -0
- package/dist/governance.js +34 -0
- package/dist/harness/harness.js +4 -9
- package/dist/index.d.ts +15 -4
- package/dist/index.js +11 -8
- package/dist/kernel.d.ts +149 -0
- package/dist/kernel.js +9 -0
- package/dist/memory/protocols.d.ts +2 -1
- package/dist/memory/protocols.js +0 -1
- package/dist/providers/anthropic.d.ts +11 -2
- package/dist/providers/anthropic.js +46 -10
- package/dist/providers/base.d.ts +3 -0
- package/dist/providers/base.js +79 -0
- package/dist/providers/catalog.d.ts +14 -0
- package/dist/providers/catalog.js +45 -0
- package/dist/providers/deepseek.d.ts +9 -0
- package/dist/providers/deepseek.js +64 -0
- package/dist/providers/gemini.d.ts +14 -0
- package/dist/providers/gemini.js +142 -0
- package/dist/providers/kimi.d.ts +7 -0
- package/dist/providers/kimi.js +8 -0
- package/dist/providers/minimax.d.ts +7 -0
- package/dist/providers/minimax.js +10 -0
- package/dist/providers/openai-chat.d.ts +27 -0
- package/dist/providers/openai-chat.js +41 -0
- package/dist/providers/openai-responses.d.ts +42 -0
- package/dist/providers/openai-responses.js +220 -0
- package/dist/providers/openai.d.ts +4 -36
- package/dist/providers/openai.js +12 -121
- package/dist/providers/profiles.d.ts +342 -0
- package/dist/providers/profiles.js +190 -0
- package/dist/providers/qwen.d.ts +18 -0
- package/dist/providers/qwen.js +103 -0
- package/dist/runtime/server.d.ts +7 -0
- package/dist/runtime/server.js +37 -0
- package/dist/safety/permissions.d.ts +1 -0
- package/dist/safety/permissions.js +3 -0
- package/dist/signals/gateway.js +4 -0
- package/dist/signals/scheduled.js +4 -0
- package/dist/signals/types.d.ts +10 -1
- package/dist/types.d.ts +17 -2
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -16,13 +16,15 @@ Pre-built native addons are available for the following platforms:
|
|
|
16
16
|
|
|
17
17
|
| Platform | Package |
|
|
18
18
|
| -------- | ------- |
|
|
19
|
-
| Linux x64 (glibc) | `@deepstrike/core-linux-x64-gnu` |
|
|
20
|
-
| Linux ARM64 (glibc) | `@deepstrike/core-linux-arm64-gnu` |
|
|
21
19
|
| macOS x64 | `@deepstrike/core-darwin-x64` |
|
|
22
20
|
| macOS ARM64 (Apple Silicon) | `@deepstrike/core-darwin-arm64` |
|
|
21
|
+
| Linux x64 (glibc) | `@deepstrike/core-linux-x64-gnu` |
|
|
22
|
+
| Linux x64 (musl / Alpine) | `@deepstrike/core-linux-x64-musl` |
|
|
23
|
+
| Linux ARM64 (glibc) | `@deepstrike/core-linux-arm64-gnu` |
|
|
24
|
+
| Linux ARM64 (musl / Alpine) | `@deepstrike/core-linux-arm64-musl` |
|
|
23
25
|
| Windows x64 | `@deepstrike/core-win32-x64-msvc` |
|
|
24
26
|
|
|
25
|
-
The correct platform package is selected and installed automatically via `optionalDependencies`.
|
|
27
|
+
The correct platform package is selected and installed automatically via `optionalDependencies`. No postinstall download is required.
|
|
26
28
|
|
|
27
29
|
> **Note:** `@deepstrike/core` is the low-level native addon package and is not intended for direct use. It is an internal dependency automatically managed by `@deepstrike/sdk`. Direct installation is only relevant when building from Rust source.
|
|
28
30
|
|
|
@@ -31,13 +33,9 @@ The correct platform package is selected and installed automatically via `option
|
|
|
31
33
|
## Quick start
|
|
32
34
|
|
|
33
35
|
```typescript
|
|
34
|
-
import { Agent,
|
|
36
|
+
import { Agent, OpenAIResponsesProvider, tool } from "@deepstrike/sdk"
|
|
35
37
|
|
|
36
|
-
const provider = new
|
|
37
|
-
apiKey: process.env.OPENAI_API_KEY,
|
|
38
|
-
model: "gpt-5-mini",
|
|
39
|
-
baseUrl: "https://api.openai.com/v1",
|
|
40
|
-
})
|
|
38
|
+
const provider = new OpenAIResponsesProvider(process.env.OPENAI_API_KEY!, "gpt-5-mini")
|
|
41
39
|
|
|
42
40
|
const add = tool("add", "Add two numbers.", {
|
|
43
41
|
type: "object",
|
|
@@ -49,7 +47,7 @@ const agent = new Agent(provider, { maxTokens: 4096 })
|
|
|
49
47
|
agent.register(add)
|
|
50
48
|
|
|
51
49
|
const result = await agent.run("What is 17 + 28?")
|
|
52
|
-
console.log(result)
|
|
50
|
+
console.log(result)
|
|
53
51
|
```
|
|
54
52
|
|
|
55
53
|
Streaming:
|
|
@@ -69,16 +67,29 @@ for await (const event of agent.runStreaming("Summarize README.md")) {
|
|
|
69
67
|
|
|
70
68
|
| Class | Backend | Notes |
|
|
71
69
|
|-------|---------|-------|
|
|
72
|
-
| `
|
|
70
|
+
| `OpenAIChatProvider` | OpenAI Chat Completions API | SSE tool-call accumulation |
|
|
71
|
+
| `OpenAIProvider` | OpenAI Chat Completions API | Compatibility alias for `OpenAIChatProvider` |
|
|
72
|
+
| `OpenAIResponsesProvider` | OpenAI Responses API | Native `previous_response_id` continuation |
|
|
73
73
|
| `AnthropicProvider` | Anthropic API | Native SSE, `ThinkingDelta` support |
|
|
74
74
|
| `QwenProvider` | DashScope | `enable_thinking` via extensions |
|
|
75
|
-
| `DeepSeekProvider` | DeepSeek API |
|
|
76
|
-
| `MiniMaxProvider` | MiniMax API |
|
|
75
|
+
| `DeepSeekProvider` | DeepSeek API | V4 thinking controls + reasoning replay across tool turns |
|
|
76
|
+
| `MiniMaxProvider` | MiniMax API | Anthropic-compatible M2.7/M2.5 path |
|
|
77
77
|
| `OllamaProvider` | Local Ollama | `http://localhost:11434` default |
|
|
78
|
-
| `KimiProvider` | Moonshot API | |
|
|
78
|
+
| `KimiProvider` | Moonshot API | K2.6 default; K2.5 also supported |
|
|
79
79
|
|
|
80
80
|
All providers accept `RetryConfig` for exponential backoff and share a `CircuitBreaker`.
|
|
81
81
|
|
|
82
|
+
OpenAI can also be selected through the provider catalog:
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { createProvider } from "@deepstrike/sdk"
|
|
86
|
+
|
|
87
|
+
const provider = createProvider({
|
|
88
|
+
model: "openai/gpt-5-mini",
|
|
89
|
+
apiKey: process.env.OPENAI_API_KEY!,
|
|
90
|
+
})
|
|
91
|
+
```
|
|
92
|
+
|
|
82
93
|
---
|
|
83
94
|
|
|
84
95
|
## Agent options
|
|
@@ -106,9 +117,8 @@ const agent = new Agent(provider, {
|
|
|
106
117
|
import { tool, readFile } from "@deepstrike/sdk"
|
|
107
118
|
|
|
108
119
|
agent.register(tool("search", "Search.", schema, async (args) => ...))
|
|
109
|
-
agent.register(readFile
|
|
120
|
+
agent.register(readFile) // built-in: read files from disk
|
|
110
121
|
agent.unregister("search")
|
|
111
|
-
agent.blockTool("bash") // governance veto
|
|
112
122
|
```
|
|
113
123
|
|
|
114
124
|
---
|
|
@@ -211,6 +221,9 @@ const gov = new Governance("allow")
|
|
|
211
221
|
gov.addPermissionRule("danger.*", "deny")
|
|
212
222
|
gov.blockTool("rm_rf")
|
|
213
223
|
gov.setRateLimit("api_call", 10, 60_000)
|
|
224
|
+
gov.requireParam("write_file", "path")
|
|
225
|
+
gov.allowParamValues("set_mode", "mode", ["read", "write"])
|
|
226
|
+
gov.limitParamRange("sleep", "seconds", 0, 10)
|
|
214
227
|
|
|
215
228
|
const agent = new Agent(provider, { maxTokens: 4096, governance: gov })
|
|
216
229
|
// Every tool call goes through: Permission → Veto → RateLimit → Constraint → Audit
|
|
@@ -224,12 +237,10 @@ const agent = new Agent(provider, { maxTokens: 4096, governance: gov })
|
|
|
224
237
|
import { SignalGateway, ScheduledPrompt } from "@deepstrike/sdk"
|
|
225
238
|
|
|
226
239
|
const gw = new SignalGateway()
|
|
227
|
-
const rx = gw.subscribe()
|
|
228
|
-
|
|
229
240
|
gw.schedule(new ScheduledPrompt("standup", Date.now() + 3600_000))
|
|
230
|
-
gw.ingest({ kind: "interrupt",
|
|
241
|
+
gw.ingest({ kind: "interrupt", urgency: "critical", payload: {} })
|
|
231
242
|
|
|
232
|
-
const agent = new Agent(provider, { maxTokens: 4096, signalSource:
|
|
243
|
+
const agent = new Agent(provider, { maxTokens: 4096, signalSource: gw })
|
|
233
244
|
// kind="interrupt" → immediately stops the running agent
|
|
234
245
|
|
|
235
246
|
agent.interrupt() // also works directly
|
package/dist/agent.d.ts
CHANGED
|
@@ -34,11 +34,12 @@ export interface AgentOptions {
|
|
|
34
34
|
*/
|
|
35
35
|
agentId?: string;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* SDK Governance instance or any object implementing
|
|
38
38
|
* `evaluate(toolName: string, argsJson: string): { kind: string; reason?: string; retryAfterMs?: number }`.
|
|
39
39
|
* When provided, every tool call is evaluated through the full pipeline.
|
|
40
40
|
*/
|
|
41
41
|
governance?: {
|
|
42
|
+
setTime?(nowMs: bigint): void;
|
|
42
43
|
evaluate(toolName: string, argsJson: string): {
|
|
43
44
|
kind: string;
|
|
44
45
|
reason?: string;
|
package/dist/agent.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { executeTools } from "./tools/index.js";
|
|
2
2
|
import { readSkillFile, scanSkillDir } from "./skills/loader.js";
|
|
3
|
-
|
|
4
|
-
async function loadKernel() {
|
|
5
|
-
const mod = await import("@deepstrike/core");
|
|
6
|
-
// CJS modules imported via ESM dynamic import expose exports under `.default`
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
-
return mod.default ?? mod;
|
|
9
|
-
}
|
|
3
|
+
import { getKernel } from "./kernel.js";
|
|
10
4
|
export class Agent {
|
|
11
5
|
provider;
|
|
12
6
|
options;
|
|
@@ -66,12 +60,13 @@ export class Agent {
|
|
|
66
60
|
if (this.knowledgeSource) {
|
|
67
61
|
await this.knowledgeSource.init();
|
|
68
62
|
}
|
|
69
|
-
const kernel =
|
|
63
|
+
const kernel = getKernel();
|
|
70
64
|
const ext = { ...this.extensions, ...(extensions ?? {}) };
|
|
65
|
+
const providerState = this.provider.createRunState?.();
|
|
71
66
|
const sm = new kernel.LoopStateMachine({
|
|
72
67
|
maxTokens: this.options.maxTokens,
|
|
73
68
|
maxTurns: this.options.maxTurns ?? 25,
|
|
74
|
-
timeoutMs: this.options.timeoutMs,
|
|
69
|
+
timeoutMs: this.options.timeoutMs === undefined ? undefined : BigInt(this.options.timeoutMs),
|
|
75
70
|
});
|
|
76
71
|
// Per-run SignalRouter — dedup state never leaks between runs.
|
|
77
72
|
const router = new kernel.SignalRouter(256);
|
|
@@ -123,16 +118,14 @@ export class Agent {
|
|
|
123
118
|
if (this.signalSource) {
|
|
124
119
|
const sig = await this.signalSource.nextSignal();
|
|
125
120
|
if (sig) {
|
|
126
|
-
const sigAny = sig;
|
|
127
121
|
const kernelSig = {
|
|
128
122
|
id: crypto.randomUUID(),
|
|
129
|
-
source:
|
|
130
|
-
signalType:
|
|
131
|
-
urgency:
|
|
132
|
-
|
|
133
|
-
summary: String(sig.payload?.goal ?? sig.kind),
|
|
123
|
+
source: sig.source ?? "custom",
|
|
124
|
+
signalType: sig.signalType ?? "event",
|
|
125
|
+
urgency: normalizeSignalUrgency(sig),
|
|
126
|
+
summary: String(sig.payload?.goal ?? sig.kind ?? "signal"),
|
|
134
127
|
payload: JSON.stringify(sig.payload ?? {}),
|
|
135
|
-
dedupeKey:
|
|
128
|
+
dedupeKey: sig.dedupeKey,
|
|
136
129
|
timestampMs: Date.now(),
|
|
137
130
|
};
|
|
138
131
|
const disposition = router.ingest(kernelSig, action.kind === "execute_tools");
|
|
@@ -164,7 +157,7 @@ export class Agent {
|
|
|
164
157
|
const tools = (action.tools ?? []);
|
|
165
158
|
let turnTokens = 0;
|
|
166
159
|
try {
|
|
167
|
-
for await (const evt of this.provider.stream(messages, tools, Object.keys(ext).length ? ext : undefined)) {
|
|
160
|
+
for await (const evt of this.provider.stream(messages, tools, Object.keys(ext).length ? ext : undefined, providerState)) {
|
|
168
161
|
if (evt.type === "usage") {
|
|
169
162
|
turnTokens = evt.totalTokens;
|
|
170
163
|
continue;
|
|
@@ -193,6 +186,7 @@ export class Agent {
|
|
|
193
186
|
const deniedResults = [];
|
|
194
187
|
for (const c of allCalls) {
|
|
195
188
|
if (this.options.governance) {
|
|
189
|
+
this.options.governance.setTime?.(BigInt(Date.now()));
|
|
196
190
|
const verdict = this.options.governance.evaluate(c.name, c.arguments);
|
|
197
191
|
if (verdict.kind === "deny") {
|
|
198
192
|
const msg = `permission denied: ${c.name} — ${verdict.reason ?? ""}`;
|
|
@@ -270,7 +264,7 @@ export class Agent {
|
|
|
270
264
|
const result = action.result;
|
|
271
265
|
this._turn = sm.turn;
|
|
272
266
|
this._pressure = sm.pressure();
|
|
273
|
-
const status = result?.termination
|
|
267
|
+
const status = result?.termination ?? "error";
|
|
274
268
|
const iterations = result ? Math.max(1, result.turnsUsed) : 0;
|
|
275
269
|
if (this.options.dreamStore && this.options.agentId && sessionMsgs.length > 1) {
|
|
276
270
|
try {
|
|
@@ -304,7 +298,7 @@ export class Agent {
|
|
|
304
298
|
async dream(agentId, nowMs = Date.now()) {
|
|
305
299
|
if (!this.dreamStore)
|
|
306
300
|
throw new Error("dreamStore not configured on AgentOptions");
|
|
307
|
-
const kernel =
|
|
301
|
+
const kernel = getKernel();
|
|
308
302
|
const sessions = await this.dreamStore.loadSessions(agentId);
|
|
309
303
|
const existingMemories = await this.dreamStore.loadMemories(agentId);
|
|
310
304
|
if (!sessions.length) {
|
|
@@ -337,7 +331,8 @@ export class Agent {
|
|
|
337
331
|
throw new Error(`unexpected action after feedTrigger: ${action1.kind}`);
|
|
338
332
|
}
|
|
339
333
|
let synthesisText = "";
|
|
340
|
-
|
|
334
|
+
const providerState = this.provider.createRunState?.();
|
|
335
|
+
for await (const evt of this.provider.stream((action1.messages ?? []), [], undefined, providerState)) {
|
|
341
336
|
if (evt.type === "text_delta")
|
|
342
337
|
synthesisText += evt.delta;
|
|
343
338
|
}
|
|
@@ -378,3 +373,6 @@ function tryParseJson(s) {
|
|
|
378
373
|
return null;
|
|
379
374
|
}
|
|
380
375
|
}
|
|
376
|
+
function normalizeSignalUrgency(sig) {
|
|
377
|
+
return sig.urgency;
|
|
378
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { GovernanceVerdict } from "./kernel.js";
|
|
2
|
+
type GovernanceDefaultAction = "allow" | "deny" | "ask_user";
|
|
3
|
+
type GovernanceRuleAction = "allow" | "deny" | "ask_user";
|
|
4
|
+
export declare class Governance {
|
|
5
|
+
private readonly inner;
|
|
6
|
+
constructor(defaultAction?: GovernanceDefaultAction);
|
|
7
|
+
setIdentity(agentId: string, sessionId: string): void;
|
|
8
|
+
addPermissionRule(pattern: string, action: GovernanceRuleAction): void;
|
|
9
|
+
blockTool(name: string): void;
|
|
10
|
+
setRateLimit(toolName: string, maxCalls: number, windowMs: number): void;
|
|
11
|
+
requireParam(toolName: string, paramPath: string): void;
|
|
12
|
+
allowParamValues(toolName: string, paramPath: string, allowedValues: string[]): void;
|
|
13
|
+
limitParamRange(toolName: string, paramPath: string, min?: number, max?: number): void;
|
|
14
|
+
setTime(nowMs: number | bigint): void;
|
|
15
|
+
evaluate(toolName: string, argsJson: string): GovernanceVerdict;
|
|
16
|
+
}
|
|
17
|
+
export type { GovernanceVerdict };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getKernel } from "./kernel.js";
|
|
2
|
+
export class Governance {
|
|
3
|
+
inner;
|
|
4
|
+
constructor(defaultAction = "allow") {
|
|
5
|
+
this.inner = new (getKernel().Governance)(defaultAction);
|
|
6
|
+
}
|
|
7
|
+
setIdentity(agentId, sessionId) {
|
|
8
|
+
this.inner.setIdentity(agentId, sessionId);
|
|
9
|
+
}
|
|
10
|
+
addPermissionRule(pattern, action) {
|
|
11
|
+
this.inner.addPermissionRule(pattern, action);
|
|
12
|
+
}
|
|
13
|
+
blockTool(name) {
|
|
14
|
+
this.inner.blockTool(name);
|
|
15
|
+
}
|
|
16
|
+
setRateLimit(toolName, maxCalls, windowMs) {
|
|
17
|
+
this.inner.setRateLimit(toolName, maxCalls, BigInt(windowMs));
|
|
18
|
+
}
|
|
19
|
+
requireParam(toolName, paramPath) {
|
|
20
|
+
this.inner.requireParam(toolName, paramPath);
|
|
21
|
+
}
|
|
22
|
+
allowParamValues(toolName, paramPath, allowedValues) {
|
|
23
|
+
this.inner.allowParamValues(toolName, paramPath, allowedValues);
|
|
24
|
+
}
|
|
25
|
+
limitParamRange(toolName, paramPath, min, max) {
|
|
26
|
+
this.inner.limitParamRange(toolName, paramPath, min, max);
|
|
27
|
+
}
|
|
28
|
+
setTime(nowMs) {
|
|
29
|
+
this.inner.setTime(typeof nowMs === "bigint" ? nowMs : BigInt(nowMs));
|
|
30
|
+
}
|
|
31
|
+
evaluate(toolName, argsJson) {
|
|
32
|
+
return this.inner.evaluate(toolName, argsJson);
|
|
33
|
+
}
|
|
34
|
+
}
|
package/dist/harness/harness.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { writeFile } from "fs/promises";
|
|
2
2
|
import path from "path";
|
|
3
|
-
|
|
4
|
-
async function loadKernel() {
|
|
5
|
-
const mod = await import("@deepstrike/core");
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7
|
-
return mod.default ?? mod;
|
|
8
|
-
}
|
|
3
|
+
import { getKernel } from "../kernel.js";
|
|
9
4
|
async function runOnce(agent, req) {
|
|
10
5
|
let text = "";
|
|
11
6
|
let done;
|
|
@@ -57,7 +52,7 @@ export class HarnessLoop {
|
|
|
57
52
|
this.skillDir = options.skillDir;
|
|
58
53
|
}
|
|
59
54
|
async *runStreaming(request) {
|
|
60
|
-
const kernel =
|
|
55
|
+
const kernel = getKernel();
|
|
61
56
|
const pipeline = new kernel.EvalPipeline({ extractSkillOnPass: true });
|
|
62
57
|
const criteria = request.criteria ?? [];
|
|
63
58
|
// history tracks the full conversation; agent sees only the current goal message
|
|
@@ -111,8 +106,8 @@ export class HarnessLoop {
|
|
|
111
106
|
details: doneAction.details ?? [],
|
|
112
107
|
};
|
|
113
108
|
if (verdict.passed) {
|
|
114
|
-
if (doneAction.
|
|
115
|
-
const { name, description, whenToUse, content } = doneAction.
|
|
109
|
+
if (doneAction.skillCandidate && this.skillDir) {
|
|
110
|
+
const { name, description, whenToUse, content } = doneAction.skillCandidate;
|
|
116
111
|
const fm = ["---", `name: ${name}`, `description: ${description}`,
|
|
117
112
|
whenToUse ? `when_to_use: ${whenToUse}` : null, "---", ""]
|
|
118
113
|
.filter(Boolean).join("\n");
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
export { Agent } from "./agent.js";
|
|
2
2
|
export type { AgentOptions } from "./agent.js";
|
|
3
3
|
export { AnthropicProvider } from "./providers/anthropic.js";
|
|
4
|
-
export {
|
|
4
|
+
export { OpenAIChatProvider, OpenAIProvider } from "./providers/openai.js";
|
|
5
|
+
export { DeepSeekProvider } from "./providers/deepseek.js";
|
|
6
|
+
export { KimiProvider } from "./providers/kimi.js";
|
|
7
|
+
export { QwenProvider } from "./providers/qwen.js";
|
|
8
|
+
export { GeminiProvider } from "./providers/gemini.js";
|
|
9
|
+
export { MiniMaxProvider } from "./providers/minimax.js";
|
|
5
10
|
export { OllamaProvider } from "./providers/ollama.js";
|
|
6
11
|
export { CircuitBreaker, normalizeToolCall } from "./providers/base.js";
|
|
12
|
+
export { OpenAIChatAdapter } from "./providers/openai-chat.js";
|
|
13
|
+
export { OpenAIResponsesAdapter, OpenAIResponsesProvider } from "./providers/openai-responses.js";
|
|
14
|
+
export type { OpenAIResponsesRunState } from "./providers/openai-responses.js";
|
|
15
|
+
export { endpointProfiles, modelProfiles, getModelProfile } from "./providers/profiles.js";
|
|
16
|
+
export { createProvider } from "./providers/catalog.js";
|
|
17
|
+
export type { CreateProviderOptions, EndpointProfileId } from "./providers/catalog.js";
|
|
7
18
|
export { tool, executeTools, readFile } from "./tools/index.js";
|
|
8
19
|
export type { RegisteredTool } from "./tools/index.js";
|
|
9
20
|
export { scanSkillDir, readSkillFile } from "./skills/loader.js";
|
|
@@ -18,6 +29,6 @@ export { SignalGateway } from "./signals/gateway.js";
|
|
|
18
29
|
export type { RuntimeSignal, SignalSource } from "./signals/types.js";
|
|
19
30
|
export { PermissionManager, PermissionMode } from "./safety/permissions.js";
|
|
20
31
|
export type { PermissionDecision, Permission } from "./safety/permissions.js";
|
|
21
|
-
export
|
|
22
|
-
export type {
|
|
23
|
-
export type { Message, ToolCall, ToolResult, ToolSchema, ContentPart, TextPart, ImagePart, AudioPart, StreamEvent, TextDelta, ThinkingDelta, ToolCallEvent, ToolResultEvent, DoneEvent, ErrorEvent, PermissionRequestEvent, LLMProvider, RetryConfig, TokenUsage, ProviderToolSpec, } from "./types.js";
|
|
32
|
+
export { Governance } from "./governance.js";
|
|
33
|
+
export type { GovernanceVerdict } from "./governance.js";
|
|
34
|
+
export type { Message, ToolCall, ToolResult, ToolSchema, ContentPart, TextPart, ImagePart, AudioPart, StreamEvent, TextDelta, ThinkingDelta, ToolCallEvent, ToolResultEvent, DoneEvent, ErrorEvent, PermissionRequestEvent, LLMProvider, RetryConfig, TokenUsage, ProviderToolSpec, ProviderRunState, } from "./types.js";
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
export { Agent } from "./agent.js";
|
|
2
2
|
export { AnthropicProvider } from "./providers/anthropic.js";
|
|
3
|
-
export {
|
|
3
|
+
export { OpenAIChatProvider, OpenAIProvider } from "./providers/openai.js";
|
|
4
|
+
export { DeepSeekProvider } from "./providers/deepseek.js";
|
|
5
|
+
export { KimiProvider } from "./providers/kimi.js";
|
|
6
|
+
export { QwenProvider } from "./providers/qwen.js";
|
|
7
|
+
export { GeminiProvider } from "./providers/gemini.js";
|
|
8
|
+
export { MiniMaxProvider } from "./providers/minimax.js";
|
|
4
9
|
export { OllamaProvider } from "./providers/ollama.js";
|
|
5
10
|
export { CircuitBreaker, normalizeToolCall } from "./providers/base.js";
|
|
11
|
+
export { OpenAIChatAdapter } from "./providers/openai-chat.js";
|
|
12
|
+
export { OpenAIResponsesAdapter, OpenAIResponsesProvider } from "./providers/openai-responses.js";
|
|
13
|
+
export { endpointProfiles, modelProfiles, getModelProfile } from "./providers/profiles.js";
|
|
14
|
+
export { createProvider } from "./providers/catalog.js";
|
|
6
15
|
export { tool, executeTools, readFile } from "./tools/index.js";
|
|
7
16
|
export { scanSkillDir, readSkillFile } from "./skills/loader.js";
|
|
8
17
|
export { WorkingMemory } from "./memory/working.js";
|
|
@@ -10,10 +19,4 @@ export { SinglePassHarness, EvalLoopHarness, HarnessLoop } from "./harness/harne
|
|
|
10
19
|
export { ScheduledPrompt } from "./signals/scheduled.js";
|
|
11
20
|
export { SignalGateway } from "./signals/gateway.js";
|
|
12
21
|
export { PermissionManager, PermissionMode } from "./safety/permissions.js";
|
|
13
|
-
|
|
14
|
-
// @deepstrike/core is a CJS native addon; static ESM named re-export doesn't work,
|
|
15
|
-
// so we load it via createRequire and re-export with proper types preserved.
|
|
16
|
-
import { createRequire } from "module";
|
|
17
|
-
const _cjsRequire = createRequire(import.meta.url);
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
-
export const Governance = _cjsRequire("@deepstrike/core").Governance;
|
|
22
|
+
export { Governance } from "./governance.js";
|
package/dist/kernel.d.ts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { Message, ToolCall, ToolResult, ToolSchema } from "./types.js";
|
|
2
|
+
import type { SkillMetadata } from "./skills/loader.js";
|
|
3
|
+
export interface GovernanceVerdict {
|
|
4
|
+
kind: "allow" | "deny" | "rate_limited" | "ask_user";
|
|
5
|
+
reason?: string;
|
|
6
|
+
retryAfterMs?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface GovernanceInstance {
|
|
9
|
+
setIdentity(agentId: string, sessionId: string): void;
|
|
10
|
+
addPermissionRule(pattern: string, action: "allow" | "deny" | "ask_user"): void;
|
|
11
|
+
blockTool(name: string): void;
|
|
12
|
+
setRateLimit(toolName: string, maxCalls: number, windowMs: bigint): void;
|
|
13
|
+
requireParam(toolName: string, paramPath: string): void;
|
|
14
|
+
allowParamValues(toolName: string, paramPath: string, allowedValues: string[]): void;
|
|
15
|
+
limitParamRange(toolName: string, paramPath: string, min?: number, max?: number): void;
|
|
16
|
+
setTime(nowMs: bigint): void;
|
|
17
|
+
evaluate(toolName: string, argsJson: string): GovernanceVerdict;
|
|
18
|
+
}
|
|
19
|
+
export interface RuntimeSignal {
|
|
20
|
+
id: string;
|
|
21
|
+
source: "cron" | "gateway" | "heartbeat" | "custom";
|
|
22
|
+
signalType: "event" | "job" | "alert";
|
|
23
|
+
urgency: "low" | "normal" | "high" | "critical";
|
|
24
|
+
summary: string;
|
|
25
|
+
payload: string;
|
|
26
|
+
dedupeKey?: string;
|
|
27
|
+
timestampMs: number;
|
|
28
|
+
}
|
|
29
|
+
export interface LoopAction {
|
|
30
|
+
kind: "call_llm" | "execute_tools" | "done";
|
|
31
|
+
messages?: Message[];
|
|
32
|
+
tools?: ToolSchema[];
|
|
33
|
+
calls?: ToolCall[];
|
|
34
|
+
result?: {
|
|
35
|
+
termination: string;
|
|
36
|
+
turnsUsed: number;
|
|
37
|
+
totalTokensUsed: bigint;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
interface LoopObservation {
|
|
41
|
+
kind: "compressed";
|
|
42
|
+
action?: string;
|
|
43
|
+
rhoAfter?: number;
|
|
44
|
+
}
|
|
45
|
+
interface LoopStateMachineInstance {
|
|
46
|
+
setAvailableSkills(skills: SkillMetadata[]): void;
|
|
47
|
+
setMemoryEnabled(enabled: boolean): void;
|
|
48
|
+
setKnowledgeEnabled(enabled: boolean): void;
|
|
49
|
+
addSystemMessage(content: string, tokens: number): void;
|
|
50
|
+
addMemoryMessage(content: string, tokens: number): void;
|
|
51
|
+
setTools(tools: ToolSchema[]): void;
|
|
52
|
+
start(task: {
|
|
53
|
+
goal: string;
|
|
54
|
+
criteria: string[];
|
|
55
|
+
}): LoopAction;
|
|
56
|
+
feedLlmResponse(message: Message): LoopAction;
|
|
57
|
+
feedToolResults(results: ToolResult[]): LoopAction;
|
|
58
|
+
feedTimeout(): LoopAction;
|
|
59
|
+
isTerminal(): boolean;
|
|
60
|
+
readonly turn: number;
|
|
61
|
+
pressure(): number;
|
|
62
|
+
takeObservations(): LoopObservation[];
|
|
63
|
+
}
|
|
64
|
+
interface SignalRouterInstance {
|
|
65
|
+
ingest(signal: RuntimeSignal, isRunning: boolean): string;
|
|
66
|
+
next(): RuntimeSignal | null;
|
|
67
|
+
}
|
|
68
|
+
interface NativeCriterion {
|
|
69
|
+
text: string;
|
|
70
|
+
required: boolean;
|
|
71
|
+
weight?: number;
|
|
72
|
+
}
|
|
73
|
+
interface EvalPipelineAction {
|
|
74
|
+
kind: "evaluate" | "done";
|
|
75
|
+
messages?: Message[];
|
|
76
|
+
passed?: boolean;
|
|
77
|
+
overallScore?: number;
|
|
78
|
+
feedback?: string;
|
|
79
|
+
details?: Array<{
|
|
80
|
+
criterion: string;
|
|
81
|
+
passed: boolean;
|
|
82
|
+
score: number;
|
|
83
|
+
feedback: string;
|
|
84
|
+
}>;
|
|
85
|
+
skillCandidate?: {
|
|
86
|
+
name: string;
|
|
87
|
+
description: string;
|
|
88
|
+
whenToUse?: string;
|
|
89
|
+
content: string;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
interface EvalPipelineInstance {
|
|
93
|
+
feedOutcome(goal: string, criteria: NativeCriterion[], result: string, attempt: number): EvalPipelineAction;
|
|
94
|
+
feedEvalResult(content: string): EvalPipelineAction;
|
|
95
|
+
reset(): void;
|
|
96
|
+
}
|
|
97
|
+
interface IdlePipelineAction {
|
|
98
|
+
kind: "synthesize_insights" | "commit_memories" | "noop" | "aborted";
|
|
99
|
+
messages?: Message[];
|
|
100
|
+
curationResult?: {
|
|
101
|
+
toAdd?: Array<{
|
|
102
|
+
text: string;
|
|
103
|
+
score: number;
|
|
104
|
+
metadata: string;
|
|
105
|
+
}>;
|
|
106
|
+
toRemoveIndices?: number[];
|
|
107
|
+
stats?: {
|
|
108
|
+
insightsProcessed?: number;
|
|
109
|
+
duplicatesRemoved?: number;
|
|
110
|
+
conflictsResolved?: number;
|
|
111
|
+
entriesAdded?: number;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
runResult?: {
|
|
115
|
+
sessionsProcessed: number;
|
|
116
|
+
insightsExtracted: number;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
interface IdlePipelineInstance {
|
|
120
|
+
feedTrigger(sessions: Array<{
|
|
121
|
+
sessionId: string;
|
|
122
|
+
agentId: string;
|
|
123
|
+
messages: Message[];
|
|
124
|
+
metadata: string;
|
|
125
|
+
createdAtMs: number;
|
|
126
|
+
updatedAtMs: number;
|
|
127
|
+
}>, existingMemories: Array<{
|
|
128
|
+
text: string;
|
|
129
|
+
score: number;
|
|
130
|
+
metadata: string;
|
|
131
|
+
}>, nowMs: number): IdlePipelineAction;
|
|
132
|
+
feedSynthesisResult(content: string): IdlePipelineAction;
|
|
133
|
+
}
|
|
134
|
+
interface KernelModule {
|
|
135
|
+
Governance: new (defaultAction?: "allow" | "deny" | "ask_user") => GovernanceInstance;
|
|
136
|
+
LoopStateMachine: new (policy: {
|
|
137
|
+
maxTokens: number;
|
|
138
|
+
maxTurns?: number;
|
|
139
|
+
maxTotalTokens?: bigint;
|
|
140
|
+
timeoutMs?: bigint;
|
|
141
|
+
}) => LoopStateMachineInstance;
|
|
142
|
+
SignalRouter: new (maxQueueSize: number) => SignalRouterInstance;
|
|
143
|
+
EvalPipeline: new (options?: {
|
|
144
|
+
extractSkillOnPass?: boolean;
|
|
145
|
+
}) => EvalPipelineInstance;
|
|
146
|
+
IdlePipeline: new (agentId: string) => IdlePipelineInstance;
|
|
147
|
+
}
|
|
148
|
+
export declare function getKernel(): KernelModule;
|
|
149
|
+
export {};
|
package/dist/kernel.js
ADDED
package/dist/memory/protocols.js
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import type { Message, ToolSchema, StreamEvent, LLMProvider } from "../types.js";
|
|
2
|
+
interface AnthropicProviderOptions {
|
|
3
|
+
baseURL?: string;
|
|
4
|
+
authMode?: "api-key" | "bearer";
|
|
5
|
+
}
|
|
2
6
|
export declare class AnthropicProvider implements LLMProvider {
|
|
3
|
-
|
|
7
|
+
protected readonly model: string;
|
|
4
8
|
private client;
|
|
5
9
|
private circuit;
|
|
6
10
|
private maxRetries;
|
|
7
11
|
private baseDelay;
|
|
12
|
+
private nativeAssistantBlocks;
|
|
8
13
|
constructor(apiKey: string, model?: string, retry?: {
|
|
9
14
|
maxRetries: number;
|
|
10
15
|
baseDelay: number;
|
|
11
|
-
});
|
|
16
|
+
}, options?: AnthropicProviderOptions);
|
|
12
17
|
private buildTools;
|
|
13
18
|
complete(messages: Message[], tools: ToolSchema[]): Promise<Message>;
|
|
14
19
|
stream(messages: Message[], tools: ToolSchema[], extensions?: Record<string, unknown>): AsyncIterable<StreamEvent>;
|
|
20
|
+
private buildMessages;
|
|
21
|
+
private rememberNativeBlocks;
|
|
22
|
+
private assistantReplayKey;
|
|
15
23
|
}
|
|
24
|
+
export {};
|