@deepstrike/sdk 0.2.28 → 0.2.30
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 +45 -21
- package/dist/harness/public.d.ts +4 -0
- package/dist/harness/public.js +3 -0
- package/dist/index.d.ts +13 -80
- package/dist/index.js +24 -60
- package/dist/memory/public.d.ts +4 -0
- package/dist/memory/public.js +3 -0
- package/dist/os/public.d.ts +18 -0
- package/dist/os/public.js +14 -0
- package/dist/planes/public.d.ts +13 -0
- package/dist/planes/public.js +9 -0
- package/dist/providers/anthropic.d.ts +11 -2
- package/dist/providers/anthropic.js +14 -9
- package/dist/providers/factories.d.ts +31 -0
- package/dist/providers/factories.js +45 -0
- package/dist/providers/openai.d.ts +14 -2
- package/dist/providers/openai.js +11 -6
- package/dist/providers/public.d.ts +10 -0
- package/dist/providers/public.js +11 -0
- package/dist/runtime/facade.js +6 -1
- package/dist/runtime/runner.js +23 -39
- package/dist/workflow/public.d.ts +20 -0
- package/dist/workflow/public.js +15 -0
- package/package.json +54 -2
package/README.md
CHANGED
|
@@ -76,9 +76,25 @@ const reply = await collectText(runner.run({ sessionId: "chat-1", goal: "What is
|
|
|
76
76
|
|
|
77
77
|
Use `InMemorySessionLog` for process-local sessions or `FileSessionLog` when replay should survive restarts. `wake(sessionId)` resumes from the event log without inserting a duplicate `run_started` event.
|
|
78
78
|
|
|
79
|
+
### Package layout (v0.2.30)
|
|
80
|
+
|
|
81
|
+
The root export is the **intent layer** — what you reach for to run an agent, run a workflow, author a tool, or pick a provider (~30 symbols). Advanced machinery lives behind subpaths, so the common surface stays small and tree-shakeable:
|
|
82
|
+
|
|
83
|
+
| Import | Contains |
|
|
84
|
+
|--------|----------|
|
|
85
|
+
| `@deepstrike/sdk` | `runAgent` · `runFanout` · `RuntimeRunner` · `tool` · `LocalExecutionPlane` · `InMemorySessionLog`/`FileSessionLog` · `AnthropicProvider`/`OpenAIProvider`/`OpenAIResponsesProvider` · `createProvider` · `Governance` · `AgentPool` · core types |
|
|
86
|
+
| `@deepstrike/sdk/providers` | backend factories (`deepseek`, `kimi`, `qwen`, `glm`, `minimax`, `gemini`, `ollama`), profiles, `CircuitBreaker` |
|
|
87
|
+
| `@deepstrike/sdk/workflow` | `SubAgentOrchestrator`, `spawnStandalone`, reducers, contracts, handoff/modes, agent + spec types |
|
|
88
|
+
| `@deepstrike/sdk/planes` | `WorktreeExecutionPlane`, `ProcessSandboxPlane`, `McpProxyPlane`, `RemoteVpcPlane`, archive/credential stores |
|
|
89
|
+
| `@deepstrike/sdk/memory` | `DreamStore`, `WorkingMemory`, `InMemoryDreamStore`, `KnowledgeSource` |
|
|
90
|
+
| `@deepstrike/sdk/harness` | `SinglePassHarness`, `EvalLoopHarness`, `HarnessLoop`, `judge` |
|
|
91
|
+
| `@deepstrike/sdk/os` | profiles, `KernelPrimitivesDashboard`, signals, `PermissionManager`, replay-testing utilities |
|
|
92
|
+
|
|
93
|
+
> **Migration from 0.2.x:** the kernel-lowering converters (`*ToKernel`), low-level prompt/eval builders, and the `OpenAIChatProvider` alias are no longer exported from root; backend providers, planes, memory, harness, and OS utilities moved to the subpaths above. See [`MIGRATION-v0.2.300.md`](./MIGRATION-v0.2.300.md).
|
|
94
|
+
|
|
79
95
|
### Recipes — the canonical entry points
|
|
80
96
|
|
|
81
|
-
|
|
97
|
+
Most apps need one of three shapes. Start with the facades and drop down to `RuntimeRunner` only when you need streaming, signals, memory, or governance hooks.
|
|
82
98
|
|
|
83
99
|
```typescript
|
|
84
100
|
import { runAgent, runFanout } from "@deepstrike/sdk"
|
|
@@ -232,36 +248,44 @@ A node's `kind` selects the control-flow shape; the same executor drives them al
|
|
|
232
248
|
|
|
233
249
|
## Providers
|
|
234
250
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
| `OpenAIResponsesProvider` | OpenAI Responses API | Native `previous_response_id` continuation |
|
|
240
|
-
| `AnthropicProvider` | Anthropic API | Native SSE, `ThinkingDelta` support |
|
|
241
|
-
| `QwenProvider` | DashScope | `enable_thinking` via extensions |
|
|
242
|
-
| `DeepSeekProvider` | DeepSeek API | V4 thinking controls + reasoning replay across tool turns |
|
|
243
|
-
| `MiniMaxProvider` | MiniMax API | Anthropic-compatible M2.7/M2.5 path |
|
|
244
|
-
| `OllamaProvider` | Local Ollama | `http://localhost:11434` default |
|
|
245
|
-
| `KimiProvider` | Moonshot API | K2.6 default; K2.5 also supported |
|
|
251
|
+
The root package exports the three base providers — `AnthropicProvider`, `OpenAIProvider`,
|
|
252
|
+
`OpenAIResponsesProvider` — plus `createProvider`. **Every other backend is a factory function** in
|
|
253
|
+
`@deepstrike/sdk/providers`: one per backend, with a `protocol` option where a backend speaks both the
|
|
254
|
+
OpenAI- and Anthropic-compatible wire.
|
|
246
255
|
|
|
247
|
-
|
|
256
|
+
```typescript
|
|
257
|
+
import { deepseek, kimi, minimax } from "@deepstrike/sdk/providers"
|
|
248
258
|
|
|
249
|
-
|
|
259
|
+
const ds = deepseek({ apiKey }) // OpenAI-compatible wire (default)
|
|
260
|
+
const dsA = deepseek({ apiKey, protocol: "anthropic" }) // Anthropic-compatible wire
|
|
261
|
+
const mm = minimax({ apiKey }) // MiniMax defaults to the Anthropic wire
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
| Entry | Import from | Backend |
|
|
265
|
+
|-------|-------------|---------|
|
|
266
|
+
| `OpenAIProvider` | root | OpenAI Chat Completions (and any OpenAI-compatible `/v1`) |
|
|
267
|
+
| `OpenAIResponsesProvider` | root | OpenAI Responses API (`previous_response_id` continuation) |
|
|
268
|
+
| `AnthropicProvider` | root | Anthropic Messages API (`ThinkingDelta` support) |
|
|
269
|
+
| `deepseek` · `kimi` · `qwen` · `glm` · `minimax` · `gemini` · `ollama` | `@deepstrike/sdk/providers` | the respective vendor (factory functions) |
|
|
250
270
|
|
|
251
|
-
|
|
271
|
+
Providers take an **options object** and share a `CircuitBreaker`. `extensions` are forwarded in both
|
|
272
|
+
`complete()` and `stream()`; SDK-owned fields (`model`, `messages`, `tools`, streaming flags) stay protected.
|
|
273
|
+
|
|
274
|
+
**Custom OpenAI-compatible endpoint** (MiMo, DeepSeek, Kimi, Qwen, GLM via their `/v1` base URL): construct
|
|
275
|
+
`OpenAIProvider` with an options object — no more positional `baseURL` hole:
|
|
252
276
|
|
|
253
277
|
```typescript
|
|
254
278
|
import { OpenAIProvider } from "@deepstrike/sdk"
|
|
255
279
|
|
|
256
|
-
const provider = new OpenAIProvider(
|
|
280
|
+
const provider = new OpenAIProvider({
|
|
257
281
|
apiKey,
|
|
258
|
-
"mimo-v2.5-pro",
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
)
|
|
282
|
+
model: "mimo-v2.5-pro",
|
|
283
|
+
baseURL: "https://token-plan-cn.xiaomimimo.com/v1",
|
|
284
|
+
})
|
|
262
285
|
```
|
|
263
286
|
|
|
264
|
-
Prefer a dedicated
|
|
287
|
+
Prefer a dedicated backend class from `@deepstrike/sdk/providers` when one exists — they default the base
|
|
288
|
+
URL and add backend-specific reasoning handling. Any model can also be selected through the catalog: `createProvider` picks the protocol/endpoint for you:
|
|
265
289
|
|
|
266
290
|
```typescript
|
|
267
291
|
import { createProvider } from "@deepstrike/sdk"
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { SinglePassHarness, EvalLoopHarness, HarnessLoop } from "./harness.js";
|
|
2
|
+
export type { HarnessRequest, HarnessOutcome, HarnessLoopOptions, QualityGate, CriterionResult, HarnessEvent, VerdictFn, } from "./harness.js";
|
|
3
|
+
export { judge } from "../runtime/eval.js";
|
|
4
|
+
export type { Criterion, Verdict, VerdictDetail, JudgeArgs } from "../runtime/eval.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,92 +1,25 @@
|
|
|
1
1
|
export { runAgent, runFanout } from "./runtime/facade.js";
|
|
2
2
|
export type { RunAgentOptions, RunFanoutOptions } from "./runtime/facade.js";
|
|
3
3
|
export { RuntimeRunner, collectText } from "./runtime/runner.js";
|
|
4
|
-
export type { RuntimeOptions
|
|
5
|
-
export { builtinReducers, resolveReducer } from "./runtime/reducers.js";
|
|
6
|
-
export type { Reducer, ReducerRegistry, ReducerInput } from "./runtime/reducers.js";
|
|
7
|
-
export { loopInstruction, classifyInstruction, judgeGoal, extractLoopContinue, extractClassifyBranch, extractJudgeWinner, } from "./runtime/workflow-control-flow.js";
|
|
8
|
-
export { WorktreeExecutionPlane, GitWorktreeManager } from "./runtime/worktree-plane.js";
|
|
9
|
-
export type { WorktreeManager } from "./runtime/worktree-plane.js";
|
|
10
|
-
export { FileWorkflowStore } from "./runtime/workflow-store.js";
|
|
11
|
-
export type { MemoryPolicy, MemoryWriteRateLimit, ResourceQuota } from "./kernel.js";
|
|
12
|
-
export { KernelPrimitivesDashboard } from "./runtime/kernel-primitives-dashboard.js";
|
|
13
|
-
export { FilteredExecutionPlane } from "./runtime/filtered-plane.js";
|
|
14
|
-
export { SubAgentOrchestrator, defaultSubAgentOrchestrator, spawnStandalone } from "./runtime/sub-agent-orchestrator.js";
|
|
15
|
-
export type { SubAgentRunContext } from "./runtime/sub-agent-orchestrator.js";
|
|
4
|
+
export type { RuntimeOptions } from "./runtime/runner.js";
|
|
16
5
|
export { LocalExecutionPlane } from "./runtime/execution-plane.js";
|
|
17
6
|
export type { ExecutionPlane, RunContext } from "./runtime/execution-plane.js";
|
|
18
7
|
export { InMemorySessionLog, FileSessionLog } from "./runtime/session-log.js";
|
|
19
8
|
export type { SessionLog, SessionEvent } from "./runtime/session-log.js";
|
|
20
|
-
export {
|
|
21
|
-
export type { ReplayProviderOpts } from "./runtime/replay-provider.js";
|
|
22
|
-
export { extractRecordedMessages } from "./runtime/replay-fixture.js";
|
|
23
|
-
export { judge, buildEvalMessages, parseVerdict, verdictOutputSchema } from "./runtime/eval.js";
|
|
24
|
-
export type { Criterion, Verdict, VerdictDetail, JudgeArgs } from "./runtime/eval.js";
|
|
25
|
-
export { DEFAULT_NATIVE_ATTENTION_POLICY, DEFAULT_NATIVE_GOVERNANCE_POLICY, assertNativeProfile, osProfile, } from "./runtime/os-profile.js";
|
|
26
|
-
export type { NativeOsProfile, OsProfileId } from "./runtime/os-profile.js";
|
|
27
|
-
export { rebuildOsSnapshotFromSessionEvents, sessionLogHasRequiredCategories, } from "./runtime/os-snapshot.js";
|
|
28
|
-
export type { OsSnapshot } from "./runtime/os-snapshot.js";
|
|
29
|
-
export { categoryForKind, kernelObservationToSessionEvent } from "./runtime/kernel-event-log.js";
|
|
30
|
-
export type { KernelEventCategory } from "./runtime/kernel-event-log.js";
|
|
31
|
-
export { NullArchiveStore, FileArchiveStore } from "./runtime/archive.js";
|
|
32
|
-
export type { ArchiveStore } from "./runtime/archive.js";
|
|
33
|
-
export { EnvCredentialVault, InMemoryCredentialVault, ChainedCredentialVault } from "./runtime/credential-vault.js";
|
|
34
|
-
export type { CredentialVault } from "./runtime/credential-vault.js";
|
|
35
|
-
export { ProcessSandboxPlane } from "./runtime/process-sandbox-plane.js";
|
|
36
|
-
export type { SandboxOptions } from "./runtime/process-sandbox-plane.js";
|
|
37
|
-
export { McpProxyPlane } from "./runtime/mcp-proxy-plane.js";
|
|
38
|
-
export type { McpServerConfig } from "./runtime/mcp-proxy-plane.js";
|
|
39
|
-
export { RemoteVpcPlane } from "./runtime/remote-vpc-plane.js";
|
|
40
|
-
export type { RemoteVpcOptions } from "./runtime/remote-vpc-plane.js";
|
|
41
|
-
export { AnthropicProvider } from "./providers/anthropic.js";
|
|
42
|
-
export { OpenAIChatProvider, OpenAIProvider } from "./providers/openai.js";
|
|
43
|
-
export { DeepSeekProvider, DeepSeekAnthropicProvider } from "./providers/deepseek.js";
|
|
44
|
-
export { KimiProvider, KimiAnthropicProvider } from "./providers/kimi.js";
|
|
45
|
-
export { QwenProvider, QwenAnthropicProvider } from "./providers/qwen.js";
|
|
46
|
-
export { GLMProvider, GLMAnthropicProvider } from "./providers/glm.js";
|
|
47
|
-
export { GeminiProvider } from "./providers/gemini.js";
|
|
48
|
-
export { MiniMaxAnthropicProvider, MiniMaxOpenAIProvider } from "./providers/minimax.js";
|
|
49
|
-
export { OllamaProvider } from "./providers/ollama.js";
|
|
50
|
-
export { CircuitBreaker, normalizeToolCall } from "./providers/base.js";
|
|
51
|
-
export { OpenAIChatAdapter } from "./providers/openai-chat.js";
|
|
52
|
-
export { OpenAIResponsesAdapter, OpenAIResponsesProvider } from "./providers/openai-responses.js";
|
|
53
|
-
export type { OpenAIResponsesRunState } from "./providers/openai-responses.js";
|
|
54
|
-
export { endpointProfiles, modelProfiles, getModelProfile } from "./providers/profiles.js";
|
|
55
|
-
export type { ModelProfileId, ProviderId } from "./providers/profiles.js";
|
|
56
|
-
export { createProvider } from "./providers/catalog.js";
|
|
57
|
-
export type { CreateProviderOptions, EndpointProfileId } from "./providers/catalog.js";
|
|
58
|
-
export { ProviderReplayValidationError, DEGRADED_REASONING_PLACEHOLDER } from "./providers/replay-validator.js";
|
|
59
|
-
export { assessProviderReplayability, peekProviderReplay, seedProviderReplayFromEvents, isReplayCompatibleWithProvider, } from "./runtime/provider-replay.js";
|
|
60
|
-
export { tool, streamingTool, executeTools, readFile, validateToolArguments } from "./tools/index.js";
|
|
9
|
+
export { tool, streamingTool } from "./tools/index.js";
|
|
61
10
|
export type { RegisteredTool, ToolExecContext } from "./tools/index.js";
|
|
62
11
|
export { safeTool, ok, fail, ToolError, formatToolError } from "./tools/errors.js";
|
|
63
12
|
export type { ToolEnvelope, ToolEnvelopeOk, ToolEnvelopeFail } from "./tools/errors.js";
|
|
64
|
-
export {
|
|
65
|
-
export type {
|
|
66
|
-
export {
|
|
67
|
-
export {
|
|
68
|
-
export
|
|
69
|
-
export
|
|
70
|
-
export {
|
|
71
|
-
export {
|
|
72
|
-
export type { RuntimeSignal, SignalSource } from "./signals/types.js";
|
|
73
|
-
export { PermissionManager, PermissionMode } from "./safety/permissions.js";
|
|
74
|
-
export type { PermissionDecision, Permission } from "./safety/permissions.js";
|
|
75
|
-
export { Governance, governancePolicyToKernelEvent } from "./governance.js";
|
|
13
|
+
export { AnthropicProvider } from "./providers/anthropic.js";
|
|
14
|
+
export type { AnthropicProviderConfig } from "./providers/anthropic.js";
|
|
15
|
+
export { OpenAIProvider } from "./providers/openai.js";
|
|
16
|
+
export type { OpenAIProviderOptions } from "./providers/openai.js";
|
|
17
|
+
export { OpenAIResponsesProvider } from "./providers/openai-responses.js";
|
|
18
|
+
export { createProvider } from "./providers/catalog.js";
|
|
19
|
+
export type { CreateProviderOptions, EndpointProfileId } from "./providers/catalog.js";
|
|
20
|
+
export { Governance } from "./governance.js";
|
|
76
21
|
export type { GovernanceVerdict, GovernancePolicy, GovernanceConstraint } from "./governance.js";
|
|
77
|
-
export { SinglePassHarness, EvalLoopHarness, HarnessLoop } from "./harness/harness.js";
|
|
78
|
-
export type { HarnessRequest, HarnessOutcome, HarnessLoopOptions, QualityGate, CriterionResult, HarnessEvent, VerdictFn } from "./harness/harness.js";
|
|
79
|
-
export type { Message, ToolCall, ToolResult, ToolSchema, ContentPart, TextPart, ImagePart, AudioPart, StreamEvent, TextDelta, ThinkingDelta, ToolCallEvent, ToolChunk, ToolDeltaEvent, ToolSuspendEvent, ToolResultEvent, ToolAuditFailedEvent, DoneEvent, ErrorEvent, PermissionRequestEvent, PermissionResolvedEvent, PermissionResponse, LLMProvider, RetryConfig, TokenUsage, ProviderToolSpec, ProviderRunState, ProviderReplay, RenderedContext, ReplayabilityAssessment, CacheBreakpointStrategy, } from "./types.js";
|
|
80
|
-
export type { AgentCapabilityFilter, AgentIdentity, AgentIsolation, AgentRunSpec, AgentProcessChangedObservation, ContextInheritance, KernelAgentRole, LoopResult, MilestoneCheckResult, MilestoneContract, MilestonePhase, MilestonePolicy, SubAgentResult, TerminationReason, WorkflowSpec, WorkflowNodeSpec, WorkflowTaskSpec, WorkflowSpawnInfo, } from "./types/agent.js";
|
|
81
|
-
export { agentIdentitySub, agentRunSpecToKernel, milestoneCheckFail, milestoneCheckPass, milestoneCheckResultToKernel, subAgentResultToKernel, workflowSpecToKernel, workflowNodeSpecToKernel, submitWorkflowNodesToKernel, submitWorkflowToKernel, submitWorkflowNodesTool, startWorkflowTool, fanoutSynthesize, generateAndFilter, verifyRules, genEval, } from "./types/agent.js";
|
|
82
|
-
export type { AcceptanceCriterion, VerificationContract, ContractCheckResult, } from "./collaboration/contract.js";
|
|
83
|
-
export { ContractBuilder, formatContractForSystemPrompt, contractToCriteriaStrings, } from "./collaboration/contract.js";
|
|
84
22
|
export { AgentPool } from "./collaboration/pool.js";
|
|
85
|
-
export type {
|
|
86
|
-
export {
|
|
87
|
-
export {
|
|
88
|
-
export type { ContractOutcome, ContractHarnessOptions, Violation } from "./collaboration/harness.js";
|
|
89
|
-
export { HandoffBus } from "./collaboration/handoff.js";
|
|
90
|
-
export type { HandoffArtifact, ContractOutcomeInput } from "./collaboration/handoff.js";
|
|
91
|
-
export { CreatorVerifierMode, OrchestrationMode } from "./collaboration/modes/creator-verifier.js";
|
|
92
|
-
export type { CreatorVerifierMetrics } from "./collaboration/modes/creator-verifier.js";
|
|
23
|
+
export type { RuntimeSignal, SignalSource } from "./signals/types.js";
|
|
24
|
+
export type { Message, ToolCall, ToolResult, ToolSchema, ContentPart, TextPart, ImagePart, AudioPart, StreamEvent, TextDelta, ThinkingDelta, ToolCallEvent, ToolChunk, ToolDeltaEvent, ToolSuspendEvent, ToolResultEvent, ToolAuditFailedEvent, DoneEvent, ErrorEvent, PermissionRequestEvent, PermissionResolvedEvent, PermissionResponse, LLMProvider, RetryConfig, TokenUsage, } from "./types.js";
|
|
25
|
+
export type { WorkflowSpec, WorkflowNodeSpec, } from "./types/agent.js";
|
package/dist/index.js
CHANGED
|
@@ -1,69 +1,33 @@
|
|
|
1
1
|
// ╔══════════════════════════════════════════════════════════════════════════╗
|
|
2
|
-
// ║
|
|
3
|
-
// ║
|
|
4
|
-
// ║
|
|
5
|
-
// ║
|
|
6
|
-
// ║
|
|
7
|
-
// ║
|
|
2
|
+
// ║ @deepstrike/sdk — root surface (v0.2.30). ║
|
|
3
|
+
// ║ ║
|
|
4
|
+
// ║ This is the intent layer: run an agent, run a workflow, author a tool, ║
|
|
5
|
+
// ║ pick a provider. Advanced machinery lives behind subpaths: ║
|
|
6
|
+
// ║ @deepstrike/sdk/providers — backend provider classes + profiles ║
|
|
7
|
+
// ║ @deepstrike/sdk/workflow — orchestration, reducers, contracts, specs ║
|
|
8
|
+
// ║ @deepstrike/sdk/planes — worktree / sandbox / mcp / vpc planes ║
|
|
9
|
+
// ║ @deepstrike/sdk/memory — dream + working memory, knowledge sources ║
|
|
10
|
+
// ║ @deepstrike/sdk/harness — eval harnesses + judge ║
|
|
11
|
+
// ║ @deepstrike/sdk/os — profiles, diagnostics, signals, replay tests ║
|
|
8
12
|
// ╚══════════════════════════════════════════════════════════════════════════╝
|
|
13
|
+
// ── Start here: the canonical entry points ─────────────────────────────────
|
|
9
14
|
export { runAgent, runFanout } from "./runtime/facade.js";
|
|
10
|
-
// ── Runtime (Layer 1.5) ────────────────────────────────────────────────────
|
|
11
15
|
export { RuntimeRunner, collectText } from "./runtime/runner.js";
|
|
12
|
-
|
|
13
|
-
export { loopInstruction, classifyInstruction, judgeGoal, extractLoopContinue, extractClassifyBranch, extractJudgeWinner, } from "./runtime/workflow-control-flow.js";
|
|
14
|
-
export { WorktreeExecutionPlane, GitWorktreeManager } from "./runtime/worktree-plane.js";
|
|
15
|
-
export { FileWorkflowStore } from "./runtime/workflow-store.js";
|
|
16
|
-
export { KernelPrimitivesDashboard } from "./runtime/kernel-primitives-dashboard.js";
|
|
17
|
-
export { FilteredExecutionPlane } from "./runtime/filtered-plane.js";
|
|
18
|
-
export { SubAgentOrchestrator, defaultSubAgentOrchestrator, spawnStandalone } from "./runtime/sub-agent-orchestrator.js";
|
|
16
|
+
// ── Execution plane + session log (the defaults) ────────────────────────────
|
|
19
17
|
export { LocalExecutionPlane } from "./runtime/execution-plane.js";
|
|
20
18
|
export { InMemorySessionLog, FileSessionLog } from "./runtime/session-log.js";
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
export {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export { NullArchiveStore, FileArchiveStore } from "./runtime/archive.js";
|
|
28
|
-
export { EnvCredentialVault, InMemoryCredentialVault, ChainedCredentialVault } from "./runtime/credential-vault.js";
|
|
29
|
-
export { ProcessSandboxPlane } from "./runtime/process-sandbox-plane.js";
|
|
30
|
-
export { McpProxyPlane } from "./runtime/mcp-proxy-plane.js";
|
|
31
|
-
export { RemoteVpcPlane } from "./runtime/remote-vpc-plane.js";
|
|
32
|
-
// ── Providers ─────────────────────────────────────────────────────────────
|
|
19
|
+
// ── Tool authoring ──────────────────────────────────────────────────────────
|
|
20
|
+
export { tool, streamingTool } from "./tools/index.js";
|
|
21
|
+
export { safeTool, ok, fail, ToolError, formatToolError } from "./tools/errors.js";
|
|
22
|
+
// ── Providers (base classes + the universal factory) ────────────────────────
|
|
23
|
+
// Any backend — including a custom OpenAI-compatible endpoint — is reachable via `createProvider`.
|
|
24
|
+
// Backend-specific classes (DeepSeek/Kimi/Qwen/GLM/Gemini/Ollama/MiniMax) live in `@deepstrike/sdk/providers`.
|
|
33
25
|
export { AnthropicProvider } from "./providers/anthropic.js";
|
|
34
|
-
export {
|
|
35
|
-
export {
|
|
36
|
-
export { KimiProvider, KimiAnthropicProvider } from "./providers/kimi.js";
|
|
37
|
-
export { QwenProvider, QwenAnthropicProvider } from "./providers/qwen.js";
|
|
38
|
-
export { GLMProvider, GLMAnthropicProvider } from "./providers/glm.js";
|
|
39
|
-
export { GeminiProvider } from "./providers/gemini.js";
|
|
40
|
-
export { MiniMaxAnthropicProvider, MiniMaxOpenAIProvider } from "./providers/minimax.js";
|
|
41
|
-
export { OllamaProvider } from "./providers/ollama.js";
|
|
42
|
-
export { CircuitBreaker, normalizeToolCall } from "./providers/base.js";
|
|
43
|
-
export { OpenAIChatAdapter } from "./providers/openai-chat.js";
|
|
44
|
-
export { OpenAIResponsesAdapter, OpenAIResponsesProvider } from "./providers/openai-responses.js";
|
|
45
|
-
export { endpointProfiles, modelProfiles, getModelProfile } from "./providers/profiles.js";
|
|
26
|
+
export { OpenAIProvider } from "./providers/openai.js";
|
|
27
|
+
export { OpenAIResponsesProvider } from "./providers/openai-responses.js";
|
|
46
28
|
export { createProvider } from "./providers/catalog.js";
|
|
47
|
-
|
|
48
|
-
export {
|
|
49
|
-
// ──
|
|
50
|
-
|
|
51
|
-
export { safeTool, ok, fail, ToolError, formatToolError } from "./tools/errors.js";
|
|
52
|
-
export { scanSkillDir, readSkillFile } from "./skills/loader.js";
|
|
53
|
-
// ── Memory ─────────────────────────────────────────────────────────────────
|
|
54
|
-
export { WorkingMemory } from "./memory/working.js";
|
|
55
|
-
export { InMemoryDreamStore } from "./memory/in-memory-store.js";
|
|
56
|
-
export { ScheduledPrompt } from "./signals/scheduled.js";
|
|
57
|
-
export { SignalGateway } from "./signals/gateway.js";
|
|
58
|
-
// ── Safety & Governance ────────────────────────────────────────────────────
|
|
59
|
-
export { PermissionManager, PermissionMode } from "./safety/permissions.js";
|
|
60
|
-
export { Governance, governancePolicyToKernelEvent } from "./governance.js";
|
|
61
|
-
// ── Harness ────────────────────────────────────────────────────────────────
|
|
62
|
-
export { SinglePassHarness, EvalLoopHarness, HarnessLoop } from "./harness/harness.js";
|
|
63
|
-
export { agentIdentitySub, agentRunSpecToKernel, milestoneCheckFail, milestoneCheckPass, milestoneCheckResultToKernel, subAgentResultToKernel, workflowSpecToKernel, workflowNodeSpecToKernel, submitWorkflowNodesToKernel, submitWorkflowToKernel, submitWorkflowNodesTool, startWorkflowTool, fanoutSynthesize, generateAndFilter, verifyRules, genEval, } from "./types/agent.js";
|
|
64
|
-
export { ContractBuilder, formatContractForSystemPrompt, contractToCriteriaStrings, } from "./collaboration/contract.js";
|
|
29
|
+
// ── Governance ──────────────────────────────────────────────────────────────
|
|
30
|
+
export { Governance } from "./governance.js";
|
|
31
|
+
// ── Multi-agent primitive ───────────────────────────────────────────────────
|
|
32
|
+
// Parallel fan-out / sub-agent delegation. The full orchestration layer is in `@deepstrike/sdk/workflow`.
|
|
65
33
|
export { AgentPool } from "./collaboration/pool.js";
|
|
66
|
-
export { KERNEL_ROLE_MAP } from "./collaboration/pool.js";
|
|
67
|
-
export { ContractDrivenHarness } from "./collaboration/harness.js";
|
|
68
|
-
export { HandoffBus } from "./collaboration/handoff.js";
|
|
69
|
-
export { CreatorVerifierMode, OrchestrationMode } from "./collaboration/modes/creator-verifier.js";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { WorkingMemory } from "./working.js";
|
|
2
|
+
export { InMemoryDreamStore } from "./in-memory-store.js";
|
|
3
|
+
export type { DreamStore, DreamResult, SessionData, SessionMessage, MemoryEntry, CurationResult, CurationStats, MemoryWriteRequest, MemoryQuery, MemoryRetrieval, MemoryMetadata, MemoryKind, } from "./protocols.js";
|
|
4
|
+
export type { KnowledgeSource } from "../knowledge/source.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { DEFAULT_NATIVE_ATTENTION_POLICY, DEFAULT_NATIVE_GOVERNANCE_POLICY, assertNativeProfile, osProfile, } from "../runtime/os-profile.js";
|
|
2
|
+
export type { NativeOsProfile, OsProfileId } from "../runtime/os-profile.js";
|
|
3
|
+
export { rebuildOsSnapshotFromSessionEvents, sessionLogHasRequiredCategories } from "../runtime/os-snapshot.js";
|
|
4
|
+
export type { OsSnapshot } from "../runtime/os-snapshot.js";
|
|
5
|
+
export type { KernelEventCategory } from "../runtime/kernel-event-log.js";
|
|
6
|
+
export { KernelPrimitivesDashboard } from "../runtime/kernel-primitives-dashboard.js";
|
|
7
|
+
export type { MemoryPolicy, MemoryWriteRateLimit, ResourceQuota } from "../kernel.js";
|
|
8
|
+
export type { SchedulerBudget } from "../runtime/runner.js";
|
|
9
|
+
export { ScheduledPrompt } from "../signals/scheduled.js";
|
|
10
|
+
export { SignalGateway } from "../signals/gateway.js";
|
|
11
|
+
export { PermissionManager, PermissionMode } from "../safety/permissions.js";
|
|
12
|
+
export type { PermissionDecision, Permission } from "../safety/permissions.js";
|
|
13
|
+
export { ReplayProvider } from "../runtime/replay-provider.js";
|
|
14
|
+
export type { ReplayProviderOpts } from "../runtime/replay-provider.js";
|
|
15
|
+
export { extractRecordedMessages } from "../runtime/replay-fixture.js";
|
|
16
|
+
export { ProviderReplayValidationError, DEGRADED_REASONING_PLACEHOLDER } from "../providers/replay-validator.js";
|
|
17
|
+
export { assessProviderReplayability, peekProviderReplay, seedProviderReplayFromEvents, isReplayCompatibleWithProvider, } from "../runtime/provider-replay.js";
|
|
18
|
+
export type { ReplayabilityAssessment } from "../types.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// `@deepstrike/sdk/os` — Agent-OS diagnostics, profiles, signal/permission machinery, replay-testing,
|
|
2
|
+
// and the scheduler/quota/policy types referenced by advanced `RuntimeOptions` fields.
|
|
3
|
+
export { DEFAULT_NATIVE_ATTENTION_POLICY, DEFAULT_NATIVE_GOVERNANCE_POLICY, assertNativeProfile, osProfile, } from "../runtime/os-profile.js";
|
|
4
|
+
export { rebuildOsSnapshotFromSessionEvents, sessionLogHasRequiredCategories } from "../runtime/os-snapshot.js";
|
|
5
|
+
export { KernelPrimitivesDashboard } from "../runtime/kernel-primitives-dashboard.js";
|
|
6
|
+
// Signals + SDK-side permissions.
|
|
7
|
+
export { ScheduledPrompt } from "../signals/scheduled.js";
|
|
8
|
+
export { SignalGateway } from "../signals/gateway.js";
|
|
9
|
+
export { PermissionManager, PermissionMode } from "../safety/permissions.js";
|
|
10
|
+
// Replay-based testing utilities.
|
|
11
|
+
export { ReplayProvider } from "../runtime/replay-provider.js";
|
|
12
|
+
export { extractRecordedMessages } from "../runtime/replay-fixture.js";
|
|
13
|
+
export { ProviderReplayValidationError, DEGRADED_REASONING_PLACEHOLDER } from "../providers/replay-validator.js";
|
|
14
|
+
export { assessProviderReplayability, peekProviderReplay, seedProviderReplayFromEvents, isReplayCompatibleWithProvider, } from "../runtime/provider-replay.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { WorktreeExecutionPlane, GitWorktreeManager } from "../runtime/worktree-plane.js";
|
|
2
|
+
export type { WorktreeManager } from "../runtime/worktree-plane.js";
|
|
3
|
+
export { FilteredExecutionPlane } from "../runtime/filtered-plane.js";
|
|
4
|
+
export { ProcessSandboxPlane } from "../runtime/process-sandbox-plane.js";
|
|
5
|
+
export type { SandboxOptions } from "../runtime/process-sandbox-plane.js";
|
|
6
|
+
export { McpProxyPlane } from "../runtime/mcp-proxy-plane.js";
|
|
7
|
+
export type { McpServerConfig } from "../runtime/mcp-proxy-plane.js";
|
|
8
|
+
export { RemoteVpcPlane } from "../runtime/remote-vpc-plane.js";
|
|
9
|
+
export type { RemoteVpcOptions } from "../runtime/remote-vpc-plane.js";
|
|
10
|
+
export { NullArchiveStore, FileArchiveStore } from "../runtime/archive.js";
|
|
11
|
+
export type { ArchiveStore } from "../runtime/archive.js";
|
|
12
|
+
export { EnvCredentialVault, InMemoryCredentialVault, ChainedCredentialVault } from "../runtime/credential-vault.js";
|
|
13
|
+
export type { CredentialVault } from "../runtime/credential-vault.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// `@deepstrike/sdk/planes` — advanced execution planes, archive stores, and credential vaults.
|
|
2
|
+
// The root package exports `LocalExecutionPlane`; specialized planes live here.
|
|
3
|
+
export { WorktreeExecutionPlane, GitWorktreeManager } from "../runtime/worktree-plane.js";
|
|
4
|
+
export { FilteredExecutionPlane } from "../runtime/filtered-plane.js";
|
|
5
|
+
export { ProcessSandboxPlane } from "../runtime/process-sandbox-plane.js";
|
|
6
|
+
export { McpProxyPlane } from "../runtime/mcp-proxy-plane.js";
|
|
7
|
+
export { RemoteVpcPlane } from "../runtime/remote-vpc-plane.js";
|
|
8
|
+
export { NullArchiveStore, FileArchiveStore } from "../runtime/archive.js";
|
|
9
|
+
export { EnvCredentialVault, InMemoryCredentialVault, ChainedCredentialVault } from "../runtime/credential-vault.js";
|
|
@@ -3,14 +3,23 @@ interface AnthropicProviderOptions {
|
|
|
3
3
|
baseURL?: string;
|
|
4
4
|
authMode?: "api-key" | "bearer";
|
|
5
5
|
}
|
|
6
|
+
/** Options-object form for `AnthropicProvider` — the recommended constructor shape. */
|
|
7
|
+
export interface AnthropicProviderConfig extends AnthropicProviderOptions {
|
|
8
|
+
apiKey: string;
|
|
9
|
+
model?: string;
|
|
10
|
+
retry?: {
|
|
11
|
+
maxRetries: number;
|
|
12
|
+
baseDelay: number;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
6
15
|
export declare class AnthropicProvider implements LLMProvider {
|
|
7
|
-
protected readonly model: string;
|
|
8
16
|
private client;
|
|
9
17
|
private circuit;
|
|
10
18
|
private maxRetries;
|
|
11
19
|
private baseDelay;
|
|
20
|
+
protected readonly model: string;
|
|
12
21
|
private nativeAssistantBlocks;
|
|
13
|
-
constructor(
|
|
22
|
+
constructor(apiKeyOrConfig: string | AnthropicProviderConfig, model?: string, retry?: {
|
|
14
23
|
maxRetries: number;
|
|
15
24
|
baseDelay: number;
|
|
16
25
|
}, options?: AnthropicProviderOptions);
|
|
@@ -13,23 +13,28 @@ const CLAUDE_POLICIES = {
|
|
|
13
13
|
"claude-3-5-haiku-latest": { maxTurns: 15 },
|
|
14
14
|
};
|
|
15
15
|
export class AnthropicProvider {
|
|
16
|
-
model;
|
|
17
16
|
client;
|
|
18
17
|
circuit;
|
|
19
18
|
maxRetries;
|
|
20
19
|
baseDelay;
|
|
20
|
+
model;
|
|
21
21
|
nativeAssistantBlocks = new Map();
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
// Accepts the options object (`new AnthropicProvider({ apiKey, model, baseURL })`) or the legacy
|
|
23
|
+
// positional form (still used by the Anthropic-compatible backend subclasses' `super(...)` calls).
|
|
24
|
+
constructor(apiKeyOrConfig, model = "claude-sonnet-4-6", retry = { maxRetries: 3, baseDelay: 1000 }, options = {}) {
|
|
25
|
+
const c = typeof apiKeyOrConfig === "string"
|
|
26
|
+
? { apiKey: apiKeyOrConfig, model, retry, ...options }
|
|
27
|
+
: { model: "claude-sonnet-4-6", retry: { maxRetries: 3, baseDelay: 1000 }, ...apiKeyOrConfig };
|
|
28
|
+
this.model = c.model ?? "claude-sonnet-4-6";
|
|
24
29
|
this.client = withServerRuntimeGuard(() => new Anthropic({
|
|
25
|
-
...(
|
|
26
|
-
? { authToken: apiKey, apiKey: null }
|
|
27
|
-
: { apiKey, authToken: null }),
|
|
28
|
-
...(
|
|
30
|
+
...(c.authMode === "bearer"
|
|
31
|
+
? { authToken: c.apiKey, apiKey: null }
|
|
32
|
+
: { apiKey: c.apiKey, authToken: null }),
|
|
33
|
+
...(c.baseURL ? { baseURL: c.baseURL } : {}),
|
|
29
34
|
}));
|
|
30
35
|
this.circuit = new CircuitBreaker();
|
|
31
|
-
this.maxRetries = retry
|
|
32
|
-
this.baseDelay = retry
|
|
36
|
+
this.maxRetries = c.retry?.maxRetries ?? 3;
|
|
37
|
+
this.baseDelay = c.retry?.baseDelay ?? 1000;
|
|
33
38
|
}
|
|
34
39
|
runtimePolicy() {
|
|
35
40
|
return CLAUDE_POLICIES[this.model] ?? {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { LLMProvider } from "../types.js";
|
|
2
|
+
/** Options for a backend provider factory. `protocol` only applies to backends with both wires. */
|
|
3
|
+
export interface BackendProviderOptions {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
model?: string;
|
|
6
|
+
/** Override the endpoint base URL (defaults to the backend's profile for the chosen protocol). */
|
|
7
|
+
baseURL?: string;
|
|
8
|
+
retry?: {
|
|
9
|
+
maxRetries: number;
|
|
10
|
+
baseDelay: number;
|
|
11
|
+
};
|
|
12
|
+
/** Wire protocol for dual-protocol backends. Defaults per backend (see each factory). */
|
|
13
|
+
protocol?: "openai" | "anthropic";
|
|
14
|
+
}
|
|
15
|
+
/** DeepSeek. Defaults to the OpenAI-compatible wire (richer reasoning-replay handling). */
|
|
16
|
+
export declare function deepseek(o: BackendProviderOptions): LLMProvider;
|
|
17
|
+
/** Moonshot Kimi. Defaults to the OpenAI-compatible wire. */
|
|
18
|
+
export declare function kimi(o: BackendProviderOptions): LLMProvider;
|
|
19
|
+
/** Alibaba Qwen / DashScope. Defaults to the OpenAI-compatible (DashScope) wire. */
|
|
20
|
+
export declare function qwen(o: BackendProviderOptions): LLMProvider;
|
|
21
|
+
/** Zhipu GLM. Defaults to the OpenAI-compatible wire. */
|
|
22
|
+
export declare function glm(o: BackendProviderOptions): LLMProvider;
|
|
23
|
+
/** MiniMax. Defaults to the Anthropic-compatible wire (the primary M2.x path). */
|
|
24
|
+
export declare function minimax(o: BackendProviderOptions): LLMProvider;
|
|
25
|
+
/** Google Gemini (single wire). */
|
|
26
|
+
export declare function gemini(o: Omit<BackendProviderOptions, "protocol">): LLMProvider;
|
|
27
|
+
/** Local Ollama (single wire, no API key). */
|
|
28
|
+
export declare function ollama(o?: {
|
|
29
|
+
model?: string;
|
|
30
|
+
baseURL?: string;
|
|
31
|
+
}): LLMProvider;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { DeepSeekProvider, DeepSeekAnthropicProvider } from "./deepseek.js";
|
|
2
|
+
import { KimiProvider, KimiAnthropicProvider } from "./kimi.js";
|
|
3
|
+
import { QwenProvider, QwenAnthropicProvider } from "./qwen.js";
|
|
4
|
+
import { GLMProvider, GLMAnthropicProvider } from "./glm.js";
|
|
5
|
+
import { MiniMaxOpenAIProvider, MiniMaxAnthropicProvider } from "./minimax.js";
|
|
6
|
+
import { GeminiProvider } from "./gemini.js";
|
|
7
|
+
import { OllamaProvider } from "./ollama.js";
|
|
8
|
+
/** DeepSeek. Defaults to the OpenAI-compatible wire (richer reasoning-replay handling). */
|
|
9
|
+
export function deepseek(o) {
|
|
10
|
+
return o.protocol === "anthropic"
|
|
11
|
+
? new DeepSeekAnthropicProvider(o.apiKey, o.model, o.retry, o.baseURL)
|
|
12
|
+
: new DeepSeekProvider(o.apiKey, o.model, o.retry, o.baseURL);
|
|
13
|
+
}
|
|
14
|
+
/** Moonshot Kimi. Defaults to the OpenAI-compatible wire. */
|
|
15
|
+
export function kimi(o) {
|
|
16
|
+
return o.protocol === "anthropic"
|
|
17
|
+
? new KimiAnthropicProvider(o.apiKey, o.model, o.retry, o.baseURL)
|
|
18
|
+
: new KimiProvider(o.apiKey, o.model, o.retry, o.baseURL);
|
|
19
|
+
}
|
|
20
|
+
/** Alibaba Qwen / DashScope. Defaults to the OpenAI-compatible (DashScope) wire. */
|
|
21
|
+
export function qwen(o) {
|
|
22
|
+
return o.protocol === "anthropic"
|
|
23
|
+
? new QwenAnthropicProvider(o.apiKey, o.model, o.retry, o.baseURL)
|
|
24
|
+
: new QwenProvider(o.apiKey, o.model, o.retry, o.baseURL);
|
|
25
|
+
}
|
|
26
|
+
/** Zhipu GLM. Defaults to the OpenAI-compatible wire. */
|
|
27
|
+
export function glm(o) {
|
|
28
|
+
return o.protocol === "anthropic"
|
|
29
|
+
? new GLMAnthropicProvider(o.apiKey, o.model, o.retry, o.baseURL)
|
|
30
|
+
: new GLMProvider(o.apiKey, o.model, o.retry, o.baseURL);
|
|
31
|
+
}
|
|
32
|
+
/** MiniMax. Defaults to the Anthropic-compatible wire (the primary M2.x path). */
|
|
33
|
+
export function minimax(o) {
|
|
34
|
+
return o.protocol === "openai"
|
|
35
|
+
? new MiniMaxOpenAIProvider(o.apiKey, o.model, o.retry, o.baseURL)
|
|
36
|
+
: new MiniMaxAnthropicProvider(o.apiKey, o.model, o.retry, o.baseURL);
|
|
37
|
+
}
|
|
38
|
+
/** Google Gemini (single wire). */
|
|
39
|
+
export function gemini(o) {
|
|
40
|
+
return new GeminiProvider(o.apiKey, o.model, o.retry, o.baseURL);
|
|
41
|
+
}
|
|
42
|
+
/** Local Ollama (single wire, no API key). */
|
|
43
|
+
export function ollama(o = {}) {
|
|
44
|
+
return new OllamaProvider(o.model, o.baseURL);
|
|
45
|
+
}
|
|
@@ -3,14 +3,26 @@ import type { Message, ProviderDescriptor, ProviderReplay, ProviderRunState, Ren
|
|
|
3
3
|
import { CircuitBreaker } from "./base.js";
|
|
4
4
|
import { OpenAIChatAdapter } from "./openai-chat.js";
|
|
5
5
|
import type { ReplayabilityAssessment } from "./replay-validator.js";
|
|
6
|
+
/** Options-object form for `OpenAIProvider` — the recommended way to construct an OpenAI-compatible
|
|
7
|
+
* provider (custom `baseURL` no longer needs a positional hole). */
|
|
8
|
+
export interface OpenAIProviderOptions {
|
|
9
|
+
apiKey: string;
|
|
10
|
+
model?: string;
|
|
11
|
+
retry?: {
|
|
12
|
+
maxRetries: number;
|
|
13
|
+
baseDelay: number;
|
|
14
|
+
};
|
|
15
|
+
/** Custom OpenAI-compatible endpoint (MiMo, DeepSeek, Kimi, …). Defaults to the OpenAI API. */
|
|
16
|
+
baseURL?: string;
|
|
17
|
+
}
|
|
6
18
|
export declare class OpenAIChatProvider implements LLMProvider {
|
|
7
|
-
protected readonly model: string;
|
|
8
19
|
protected client: OpenAI;
|
|
9
20
|
protected circuit: CircuitBreaker;
|
|
10
21
|
protected maxRetries: number;
|
|
11
22
|
protected baseDelay: number;
|
|
23
|
+
protected readonly model: string;
|
|
12
24
|
protected readonly chat: OpenAIChatAdapter;
|
|
13
|
-
constructor(
|
|
25
|
+
constructor(apiKeyOrOptions: string | OpenAIProviderOptions, model?: string, retry?: {
|
|
14
26
|
maxRetries: number;
|
|
15
27
|
baseDelay: number;
|
|
16
28
|
}, baseURL?: string);
|
package/dist/providers/openai.js
CHANGED
|
@@ -26,18 +26,23 @@ const OPENAI_POLICIES = {
|
|
|
26
26
|
"o4-mini": { maxTurns: 25 },
|
|
27
27
|
};
|
|
28
28
|
export class OpenAIChatProvider {
|
|
29
|
-
model;
|
|
30
29
|
client;
|
|
31
30
|
circuit;
|
|
32
31
|
maxRetries;
|
|
33
32
|
baseDelay;
|
|
33
|
+
model;
|
|
34
34
|
chat = new OpenAIChatAdapter();
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
// Accepts either the options object (`new OpenAIProvider({ apiKey, model, baseURL })`) or the legacy
|
|
36
|
+
// positional form (still used by the backend subclasses' `super(...)` calls).
|
|
37
|
+
constructor(apiKeyOrOptions, model = "gpt-4o", retry = { maxRetries: 3, baseDelay: 1000 }, baseURL = "https://api.openai.com/v1") {
|
|
38
|
+
const o = typeof apiKeyOrOptions === "string"
|
|
39
|
+
? { apiKey: apiKeyOrOptions, model, retry, baseURL }
|
|
40
|
+
: { model: "gpt-4o", retry: { maxRetries: 3, baseDelay: 1000 }, baseURL: "https://api.openai.com/v1", ...apiKeyOrOptions };
|
|
41
|
+
this.model = o.model;
|
|
42
|
+
this.client = withServerRuntimeGuard(() => new OpenAI({ apiKey: o.apiKey, baseURL: o.baseURL }));
|
|
38
43
|
this.circuit = new CircuitBreaker();
|
|
39
|
-
this.maxRetries = retry.maxRetries;
|
|
40
|
-
this.baseDelay = retry.baseDelay;
|
|
44
|
+
this.maxRetries = o.retry.maxRetries;
|
|
45
|
+
this.baseDelay = o.retry.baseDelay;
|
|
41
46
|
}
|
|
42
47
|
runtimePolicy() {
|
|
43
48
|
return OPENAI_POLICIES[this.model] ?? {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { deepseek, kimi, qwen, glm, minimax, gemini, ollama } from "./factories.js";
|
|
2
|
+
export type { BackendProviderOptions } from "./factories.js";
|
|
3
|
+
export { OpenAIChatProvider } from "./openai.js";
|
|
4
|
+
export { CircuitBreaker } from "./base.js";
|
|
5
|
+
export { OpenAIResponsesAdapter } from "./openai-responses.js";
|
|
6
|
+
export type { OpenAIResponsesRunState } from "./openai-responses.js";
|
|
7
|
+
export { OpenAIChatAdapter } from "./openai-chat.js";
|
|
8
|
+
export { endpointProfiles, modelProfiles, getModelProfile } from "./profiles.js";
|
|
9
|
+
export type { ModelProfileId, ProviderId } from "./profiles.js";
|
|
10
|
+
export type { ProviderRunState, ProviderToolSpec, ProviderReplay, RenderedContext, CacheBreakpointStrategy } from "../types.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// `@deepstrike/sdk/providers` — backend provider factories, profiles, and provider-authoring types.
|
|
2
|
+
// The root package exports `createProvider` + the 3 base providers (Anthropic / OpenAI / OpenAIResponses);
|
|
3
|
+
// every other backend is a factory here. One function per backend (with a `protocol` option where a
|
|
4
|
+
// backend speaks both wires) replaces the old dual `<Backend>Provider`/`<Backend>AnthropicProvider` classes.
|
|
5
|
+
export { deepseek, kimi, qwen, glm, minimax, gemini, ollama } from "./factories.js";
|
|
6
|
+
// `OpenAIChatProvider` is the base OpenAI-compatible class advanced users compose/extend directly.
|
|
7
|
+
export { OpenAIChatProvider } from "./openai.js";
|
|
8
|
+
export { CircuitBreaker } from "./base.js";
|
|
9
|
+
export { OpenAIResponsesAdapter } from "./openai-responses.js";
|
|
10
|
+
export { OpenAIChatAdapter } from "./openai-chat.js";
|
|
11
|
+
export { endpointProfiles, modelProfiles, getModelProfile } from "./profiles.js";
|
package/dist/runtime/facade.js
CHANGED
|
@@ -58,6 +58,11 @@ export async function runFanout(opts) {
|
|
|
58
58
|
],
|
|
59
59
|
};
|
|
60
60
|
const outcome = await runner.runWorkflow(spec, opts.sessionId ? { sessionId: opts.sessionId } : undefined);
|
|
61
|
+
// The synthesis node is the last spec node; the kernel ids nodes `wf-node{index}`. Prefer that id,
|
|
62
|
+
// but fall back to the last completed node's output so a kernel id-scheme change can't silently
|
|
63
|
+
// return an empty synthesis.
|
|
61
64
|
const synthesisId = `wf-node${opts.tasks.length}`;
|
|
62
|
-
|
|
65
|
+
const lastCompleted = outcome.completed[outcome.completed.length - 1];
|
|
66
|
+
const synthesis = outcome.outputs[synthesisId] ?? (lastCompleted ? outcome.outputs[lastCompleted] : undefined) ?? "";
|
|
67
|
+
return { synthesis, outputs: outcome.outputs };
|
|
63
68
|
}
|
package/dist/runtime/runner.js
CHANGED
|
@@ -147,51 +147,34 @@ export class RuntimeRunner {
|
|
|
147
147
|
* every policy from the first spawn. No config ⇒ the native-profile defaults (铁律: defaults only).
|
|
148
148
|
*/
|
|
149
149
|
applyKernelPolicies(runtime) {
|
|
150
|
+
// K2: lower governance / attention / scheduler / quota in ONE `configure_run` event instead of
|
|
151
|
+
// the previous 2–4 separate `set_*` / `load_governance_policy` events. The kernel applies each
|
|
152
|
+
// present field via the same path its granular event uses; absent fields are left untouched.
|
|
153
|
+
// (Requires the 0.2.30 core that ships `configure_run`.)
|
|
150
154
|
const osProfile = assertNativeProfile(this.opts.osProfile ?? "native");
|
|
151
155
|
const attentionPolicy = this.opts.attentionPolicy ?? osProfile.attentionPolicy;
|
|
152
156
|
const governancePolicy = this.opts.governancePolicy ?? osProfile.governancePolicy;
|
|
153
|
-
//
|
|
154
|
-
//
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
});
|
|
163
|
-
// Set optional wall-clock budget override.
|
|
164
|
-
if (this.opts.schedulerBudget) {
|
|
165
|
-
kernelApply(runtime, this.pendingObservations, {
|
|
166
|
-
kind: "set_scheduler_budget",
|
|
167
|
-
...(this.opts.schedulerBudget.maxWallMs !== undefined
|
|
168
|
-
? { max_wall_ms: this.opts.schedulerBudget.maxWallMs }
|
|
169
|
-
: {}),
|
|
170
|
-
});
|
|
157
|
+
// Strip the event `kind` off the governance event — `configure_run.config.governance` carries the
|
|
158
|
+
// bare policy fields (default_action / rules / vetoed_tools / rate_limits / constraints).
|
|
159
|
+
const { kind: _govKind, ...governance } = governancePolicyToKernelEvent(governancePolicy);
|
|
160
|
+
const config = { governance };
|
|
161
|
+
if (attentionPolicy.maxQueueSize !== undefined) {
|
|
162
|
+
config.attention_max_queue_size = attentionPolicy.maxQueueSize;
|
|
163
|
+
}
|
|
164
|
+
if (this.opts.schedulerBudget?.maxWallMs !== undefined) {
|
|
165
|
+
config.scheduler_max_wall_ms = this.opts.schedulerBudget.maxWallMs;
|
|
171
166
|
}
|
|
172
|
-
// Install optional resource quotas at the syscall trap (M2). Maps the ergonomic camelCase
|
|
173
|
-
// option onto the kernel's snake_case quota shape; the write-rate window is the serde tuple
|
|
174
|
-
// `[maxWrites, windowMs]`. Omitting the option leaves spawn / memory writes unbounded.
|
|
175
167
|
if (this.opts.resourceQuota) {
|
|
176
168
|
const q = this.opts.resourceQuota;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
...(q.memoryWritesPerWindow !== undefined
|
|
185
|
-
? {
|
|
186
|
-
memory_writes_per_window: [
|
|
187
|
-
q.memoryWritesPerWindow.maxWrites,
|
|
188
|
-
q.memoryWritesPerWindow.windowMs,
|
|
189
|
-
],
|
|
190
|
-
}
|
|
191
|
-
: {}),
|
|
192
|
-
},
|
|
193
|
-
});
|
|
169
|
+
config.resource_quota = {
|
|
170
|
+
...(q.maxConcurrentSubagents !== undefined ? { max_concurrent_subagents: q.maxConcurrentSubagents } : {}),
|
|
171
|
+
...(q.maxSpawnDepth !== undefined ? { max_spawn_depth: q.maxSpawnDepth } : {}),
|
|
172
|
+
...(q.memoryWritesPerWindow !== undefined
|
|
173
|
+
? { memory_writes_per_window: [q.memoryWritesPerWindow.maxWrites, q.memoryWritesPerWindow.windowMs] }
|
|
174
|
+
: {}),
|
|
175
|
+
};
|
|
194
176
|
}
|
|
177
|
+
kernelApply(runtime, this.pendingObservations, { kind: "configure_run", config });
|
|
195
178
|
}
|
|
196
179
|
async appendMemorySyscallObservations(sessionId, observations) {
|
|
197
180
|
if (!sessionId)
|
|
@@ -503,7 +486,8 @@ export class RuntimeRunner {
|
|
|
503
486
|
agent_id: this.opts.agentId,
|
|
504
487
|
}).catch(() => { });
|
|
505
488
|
this.applyKernelPolicies(runtime);
|
|
506
|
-
|
|
489
|
+
// K1: no explicit `start_run` — the host `load_workflow` (fired next by `runWorkflow`) self-bootstraps
|
|
490
|
+
// the run on the 0.2.30 core, matching the agent-reachable `submit_workflow` path.
|
|
507
491
|
return runtime;
|
|
508
492
|
}
|
|
509
493
|
/**
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { SubAgentOrchestrator, defaultSubAgentOrchestrator, spawnStandalone } from "../runtime/sub-agent-orchestrator.js";
|
|
2
|
+
export type { SubAgentRunContext } from "../runtime/sub-agent-orchestrator.js";
|
|
3
|
+
export { builtinReducers, resolveReducer } from "../runtime/reducers.js";
|
|
4
|
+
export type { Reducer, ReducerRegistry, ReducerInput } from "../runtime/reducers.js";
|
|
5
|
+
export { FileWorkflowStore } from "../runtime/workflow-store.js";
|
|
6
|
+
export { submitWorkflowNodesTool, startWorkflowTool, generateAndFilter, verifyRules, genEval, milestoneCheckPass, milestoneCheckFail, } from "../types/agent.js";
|
|
7
|
+
export type { AgentCapabilityFilter, AgentIdentity, AgentIsolation, AgentRunSpec, AgentProcessChangedObservation, ContextInheritance, KernelAgentRole, LoopResult, MilestoneCheckResult, MilestoneContract, MilestonePhase, MilestonePolicy, SubAgentResult, TerminationReason, WorkflowSpawnInfo, WorkflowTaskSpec, } from "../types/agent.js";
|
|
8
|
+
export type { AcceptanceCriterion, VerificationContract, ContractCheckResult } from "../collaboration/contract.js";
|
|
9
|
+
export { ContractBuilder, formatContractForSystemPrompt, contractToCriteriaStrings } from "../collaboration/contract.js";
|
|
10
|
+
export type { AgentRole, IsolatedVerifierContext, CoordinatorConfig } from "../collaboration/pool.js";
|
|
11
|
+
export { ContractDrivenHarness } from "../collaboration/harness.js";
|
|
12
|
+
export type { ContractOutcome, ContractHarnessOptions, Violation } from "../collaboration/harness.js";
|
|
13
|
+
export { HandoffBus } from "../collaboration/handoff.js";
|
|
14
|
+
export type { HandoffArtifact, ContractOutcomeInput } from "../collaboration/handoff.js";
|
|
15
|
+
export { CreatorVerifierMode, OrchestrationMode } from "../collaboration/modes/creator-verifier.js";
|
|
16
|
+
export type { CreatorVerifierMetrics } from "../collaboration/modes/creator-verifier.js";
|
|
17
|
+
export { scanSkillDir, readSkillFile } from "../skills/loader.js";
|
|
18
|
+
export type { SkillMetadata } from "../skills/loader.js";
|
|
19
|
+
export { executeTools, readFile, validateToolArguments } from "../tools/index.js";
|
|
20
|
+
export type { ToolExecContext } from "../tools/index.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// `@deepstrike/sdk/workflow` — multi-agent orchestration: the sub-agent host, reducers, spec builders,
|
|
2
|
+
// workflow node tools, agent/milestone types, and the collaboration (contract/handoff/mode) layer.
|
|
3
|
+
// The root package exports `runFanout`, `AgentPool`, `WorkflowSpec`/`WorkflowNodeSpec`; the advanced
|
|
4
|
+
// machinery lives here.
|
|
5
|
+
export { SubAgentOrchestrator, defaultSubAgentOrchestrator, spawnStandalone } from "../runtime/sub-agent-orchestrator.js";
|
|
6
|
+
export { builtinReducers, resolveReducer } from "../runtime/reducers.js";
|
|
7
|
+
export { FileWorkflowStore } from "../runtime/workflow-store.js";
|
|
8
|
+
export { submitWorkflowNodesTool, startWorkflowTool, generateAndFilter, verifyRules, genEval, milestoneCheckPass, milestoneCheckFail, } from "../types/agent.js";
|
|
9
|
+
export { ContractBuilder, formatContractForSystemPrompt, contractToCriteriaStrings } from "../collaboration/contract.js";
|
|
10
|
+
export { ContractDrivenHarness } from "../collaboration/harness.js";
|
|
11
|
+
export { HandoffBus } from "../collaboration/handoff.js";
|
|
12
|
+
export { CreatorVerifierMode, OrchestrationMode } from "../collaboration/modes/creator-verifier.js";
|
|
13
|
+
// Skills loader + lower-level tool execution helpers.
|
|
14
|
+
export { scanSkillDir, readSkillFile } from "../skills/loader.js";
|
|
15
|
+
export { executeTools, readFile, validateToolArguments } from "../tools/index.js";
|
package/package.json
CHANGED
|
@@ -1,10 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepstrike/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.30",
|
|
4
4
|
"description": "DeepStrike Node.js SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./providers": {
|
|
14
|
+
"types": "./dist/providers/public.d.ts",
|
|
15
|
+
"import": "./dist/providers/public.js"
|
|
16
|
+
},
|
|
17
|
+
"./workflow": {
|
|
18
|
+
"types": "./dist/workflow/public.d.ts",
|
|
19
|
+
"import": "./dist/workflow/public.js"
|
|
20
|
+
},
|
|
21
|
+
"./planes": {
|
|
22
|
+
"types": "./dist/planes/public.d.ts",
|
|
23
|
+
"import": "./dist/planes/public.js"
|
|
24
|
+
},
|
|
25
|
+
"./memory": {
|
|
26
|
+
"types": "./dist/memory/public.d.ts",
|
|
27
|
+
"import": "./dist/memory/public.js"
|
|
28
|
+
},
|
|
29
|
+
"./harness": {
|
|
30
|
+
"types": "./dist/harness/public.d.ts",
|
|
31
|
+
"import": "./dist/harness/public.js"
|
|
32
|
+
},
|
|
33
|
+
"./os": {
|
|
34
|
+
"types": "./dist/os/public.d.ts",
|
|
35
|
+
"import": "./dist/os/public.js"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"typesVersions": {
|
|
39
|
+
"*": {
|
|
40
|
+
"providers": [
|
|
41
|
+
"./dist/providers/public.d.ts"
|
|
42
|
+
],
|
|
43
|
+
"workflow": [
|
|
44
|
+
"./dist/workflow/public.d.ts"
|
|
45
|
+
],
|
|
46
|
+
"planes": [
|
|
47
|
+
"./dist/planes/public.d.ts"
|
|
48
|
+
],
|
|
49
|
+
"memory": [
|
|
50
|
+
"./dist/memory/public.d.ts"
|
|
51
|
+
],
|
|
52
|
+
"harness": [
|
|
53
|
+
"./dist/harness/public.d.ts"
|
|
54
|
+
],
|
|
55
|
+
"os": [
|
|
56
|
+
"./dist/os/public.d.ts"
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
},
|
|
8
60
|
"files": [
|
|
9
61
|
"dist",
|
|
10
62
|
"README.md"
|
|
@@ -20,7 +72,7 @@
|
|
|
20
72
|
},
|
|
21
73
|
"dependencies": {
|
|
22
74
|
"@anthropic-ai/sdk": "^0.99.0",
|
|
23
|
-
"@deepstrike/core": "0.2.
|
|
75
|
+
"@deepstrike/core": "0.2.30",
|
|
24
76
|
"@google/generative-ai": "^0.24.1",
|
|
25
77
|
"openai": "^5.23.2"
|
|
26
78
|
},
|