@deepstrike/sdk 0.2.70 → 0.2.71

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 CHANGED
@@ -40,11 +40,8 @@ The correct platform package is selected automatically via `optionalDependencies
40
40
 
41
41
  ```typescript
42
42
  import {
43
- FileSessionLog,
44
- LocalExecutionPlane,
45
- RuntimeRunner,
43
+ createAgent,
46
44
  OpenAIResponsesProvider,
47
- collectText,
48
45
  tool,
49
46
  } from "@deepstrike/sdk"
50
47
 
@@ -56,71 +53,66 @@ const add = tool("add", "Add two numbers.", {
56
53
  required: ["x", "y"],
57
54
  }, async ({ x, y }) => String(Number(x) + Number(y)))
58
55
 
59
- const plane = new LocalExecutionPlane().register(add)
60
- const runner = new RuntimeRunner({
56
+ const agent = createAgent({
57
+ name: "math",
61
58
  provider,
62
- executionPlane: plane,
63
- sessionLog: new FileSessionLog(".deepstrike/sessions"),
64
- maxTokens: 4096,
59
+ tools: [add],
65
60
  })
66
61
 
67
- const result = await collectText(runner.run({
68
- sessionId: "math-1",
69
- goal: "What is 17 + 28?",
70
- }))
71
- console.log(result)
62
+ const result = await agent.run("What is 17 + 28?")
63
+ console.log(result.output)
72
64
  ```
73
65
 
74
- Same-session continuity is explicit via `sessionId`:
66
+ Same-session continuity is explicit via `agent.session()`:
75
67
 
76
68
  ```typescript
77
- await collectText(runner.run({ sessionId: "chat-1", goal: "My name is Ada." }))
78
- const reply = await collectText(runner.run({ sessionId: "chat-1", goal: "What is my name?" }))
69
+ const session = agent.session("chat-1")
70
+ await session.run("My name is Ada.")
71
+ const reply = await session.run("What is my name?")
72
+ console.log(reply.output)
79
73
  ```
80
74
 
81
- 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.
75
+ Session persistence and recovery are configured on the Agent; applications use `session.resume()` rather than rebuilding a runner.
82
76
 
83
77
  ### Package layout
84
78
 
85
- 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:
79
+ The root export is the **Agent intent layer** — what you reach for to define and run an Agent, author a tool, or pick a provider. Advanced machinery lives behind subpaths, so the common surface stays small and tree-shakeable:
86
80
 
87
81
  | Import | Contains |
88
82
  |--------|----------|
89
- | `@deepstrike/sdk` | `runAgent` · `runFanout` · `RuntimeRunner` · `tool` · `LocalExecutionPlane` · `InMemorySessionLog`/`FileSessionLog` · `AnthropicProvider`/`OpenAIProvider`/`OpenAIResponsesProvider` · `createProvider` · `Governance` · `AgentPool` · `operationAbortSignal` · core types |
83
+ | `@deepstrike/sdk` | `createAgent` · `Agent`/`RunResult` · `tool` · `AnthropicProvider`/`OpenAIProvider`/`OpenAIResponsesProvider` · `createProvider` · core types |
90
84
  | `@deepstrike/sdk/providers` | backend factories (`deepseek`, `kimi`, `qwen`, `glm`, `minimax`, `gemini`, `ollama`), profiles, `CircuitBreaker` |
91
85
  | `@deepstrike/sdk/workflow` | `SubAgentOrchestrator`, `spawnStandalone`, reducers, contracts, handoff/modes, agent + spec types |
92
86
  | `@deepstrike/sdk/planes` | `WorktreeExecutionPlane`, `ProcessSandboxPlane`, `McpProxyPlane`, `RemoteVpcPlane`, archive/credential stores |
93
87
  | `@deepstrike/sdk/memory` | `MemoryStore`, `WorkingMemory`, `InMemoryMemoryStore`, `rankMemories`, `extractSessionMemories`, `KnowledgeSource` |
94
88
  | `@deepstrike/sdk/harness` | `AttemptLoop`, body/judge/carry policies, `judge` |
95
89
  | `@deepstrike/sdk/os` | profiles, `KernelPrimitivesDashboard`, `primitiveForKind` / `KernelPrimitive`, signals, `PermissionManager`, replay-testing utilities |
90
+ | `@deepstrike/sdk/advanced` | RuntimeRunner, SessionLog, execution planes, kernel diagnostics, and low-level orchestration escape hatches |
96
91
 
97
92
  > **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.30.md`](./MIGRATION-v0.2.30.md).
98
93
 
94
+ The recipes below the Agent section that mention `RuntimeRunner` are advanced implementation examples. Import it from `@deepstrike/sdk/advanced`; application code should use the Agent and Session methods shown above.
95
+
99
96
  ### Recipes — the canonical entry points
100
97
 
101
- 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.
98
+ Most apps start with one executable Agent. Streaming, sessions, memory, delegation, governance, and workflows are exposed from the Agent and Session objects.
102
99
 
103
100
  ```typescript
104
- import { runAgent, runFanout } from "@deepstrike/sdk"
101
+ import { createAgent } from "@deepstrike/sdk"
105
102
 
106
- // 1) Single agent one prompt, one model, the text back.
107
- const answer = await runAgent({ provider, goal: "What is 17 + 28?", tools: [add] })
103
+ const agent = createAgent({ name: "researcher", provider, tools: [add] })
104
+ const answer = await agent.run("What is 17 + 28?")
105
+ console.log(answer.output)
108
106
 
109
- // 2) Parallel fan-out synthesize N workers, then a synthesis pass, over the kernel-gated DAG.
110
- // Bootstraps and tears down its own kernel, so it's safe from a stateless request handler.
111
- const { synthesis } = await runFanout({
112
- provider,
113
- tasks: [
114
- "Summarize the security posture of the auth module",
115
- "Summarize the data-retention posture",
116
- ],
117
- synthesize: "Combine the worker findings into one risk summary.",
118
- })
107
+ for await (const event of agent.stream("Summarize the auth module")) {
108
+ if (event.type === "text_delta") process.stdout.write(event.delta)
109
+ }
119
110
 
120
- // 3) Full control sub-agents, governance, signals, streaming, resume → use RuntimeRunner directly.
111
+ const delegated = await agent.delegate({ goal: "Check the data-retention posture" })
112
+ console.log(delegated.output)
121
113
  ```
122
114
 
123
- `runFanout` is sugar over the **standalone `runWorkflow`** path: with no active `run()`, `runner.runWorkflow(spec)` auto-bootstraps a kernel that owns the DAG (governed · resumable), drives it, and tears it down — exactly what a Vercel/Lambda handler needs. See [Dynamic workflows](#dynamic-workflows). For parallel work you can also give each worker its own `RuntimeRunner`; `RuntimeRunner` carries per-run state, so **never share one instance across concurrent runs** — use a fresh instance per worker (or the `AgentPool` primitive).
115
+ For parallel work and dependency graphs, use `agent.workflow(...)`. Kernel scheduling and run isolation remain internal to the Agent facade.
124
116
 
125
117
  ### Deploying to serverless / bundlers
126
118
 
@@ -308,7 +300,7 @@ Providers take an **options object** and share a `CircuitBreaker`. `extensions`
308
300
  `OpenAIProvider` with an options object — no more positional `baseURL` hole:
309
301
 
310
302
  ```typescript
311
- import { OpenAIProvider } from "@deepstrike/sdk"
303
+ import { OpenAIProvider } from "@deepstrike/sdk/advanced"
312
304
 
313
305
  const provider = new OpenAIProvider({
314
306
  apiKey,
@@ -479,7 +471,7 @@ No configuration is required. Pass a `PayloadStore` through `RuntimeOptions.payl
479
471
  ## Tools
480
472
 
481
473
  ```typescript
482
- import { tool } from "@deepstrike/sdk"
474
+ import { tool } from "@deepstrike/sdk/advanced"
483
475
  import { readFile } from "@deepstrike/sdk/workflow"
484
476
 
485
477
  plane.register(tool("search", "Search.", schema, async (args) => ...))
@@ -646,7 +638,7 @@ Session events: `memory_written`, `memory_queried`, `memory_validation_failed`,
646
638
  Every run loads `governancePolicy` into the kernel via `load_governance_policy`. The kernel enforces rules **before** tools execute:
647
639
 
648
640
  ```typescript
649
- import type { GovernancePolicy } from "@deepstrike/sdk"
641
+ import type { GovernancePolicy } from "@deepstrike/sdk/advanced"
650
642
 
651
643
  const policy: GovernancePolicy = {
652
644
  rules: [
@@ -680,7 +672,7 @@ Default when omitted: allow-all (`DEFAULT_NATIVE_GOVERNANCE_POLICY`).
680
672
  `Governance` wraps the native governance evaluator for SDK-side use (tests, custom gates). It is **not** wired automatically into `RuntimeRunner` — use `governancePolicy` for run-time enforcement.
681
673
 
682
674
  ```typescript
683
- import { Governance } from "@deepstrike/sdk"
675
+ import { Governance } from "@deepstrike/sdk/advanced"
684
676
 
685
677
  const gov = new Governance("allow")
686
678
  gov.addPermissionRule("danger.*", "deny")
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Advanced escape hatch for runtime authors, diagnostics, and compatibility with the
3
+ * implementation-oriented test harness. Ordinary applications should use the root Agent API.
4
+ */
5
+ export * from "../index.js";
6
+ export { RuntimeRunner, collectText } from "../runtime/runner.js";
7
+ export type { RuntimeOptions } from "../runtime/runner.js";
8
+ export { runAgent, runFanout } from "../runtime/facade.js";
9
+ export type { RunAgentOptions, RunFanoutOptions } from "../runtime/facade.js";
10
+ export { LocalExecutionPlane } from "../runtime/execution-plane.js";
11
+ export type { ExecutionPlane, RunContext } from "../runtime/execution-plane.js";
12
+ export { InMemorySessionLog, FileSessionLog } from "../runtime/session-log.js";
13
+ export type { SessionLog, SessionEvent, SessionEventKind } from "../runtime/session-log.js";
14
+ export * from "../types/agent.js";
15
+ export * from "../runtime/run-group.js";
16
+ export * from "../runtime/event-stream.js";
17
+ export * from "../runtime/reliability.js";
18
+ export * from "../runtime/turn-policy.js";
19
+ export * from "../runtime/reactive-session.js";
20
+ export * from "../runtime/reaction-checkpoint.js";
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Advanced escape hatch for runtime authors, diagnostics, and compatibility with the
3
+ * implementation-oriented test harness. Ordinary applications should use the root Agent API.
4
+ */
5
+ export * from "../index.js";
6
+ export { RuntimeRunner, collectText } from "../runtime/runner.js";
7
+ export { runAgent, runFanout } from "../runtime/facade.js";
8
+ export { LocalExecutionPlane } from "../runtime/execution-plane.js";
9
+ export { InMemorySessionLog, FileSessionLog } from "../runtime/session-log.js";
10
+ export * from "../types/agent.js";
11
+ export * from "../runtime/run-group.js";
12
+ export * from "../runtime/event-stream.js";
13
+ export * from "../runtime/reliability.js";
14
+ export * from "../runtime/turn-policy.js";
15
+ export * from "../runtime/reactive-session.js";
16
+ export * from "../runtime/reaction-checkpoint.js";
@@ -0,0 +1,83 @@
1
+ import { type AgentOptions } from "./agent.js";
2
+ import { type SessionLog } from "./runtime/session-log.js";
3
+ import { type ExecutionPlane } from "./runtime/execution-plane.js";
4
+ import { type RuntimeOptions } from "./runtime/runner.js";
5
+ import type { LLMProvider, StreamEvent, TokenUsage } from "./types.js";
6
+ import type { RegisteredTool } from "./tools/index.js";
7
+ import type { MemoryRecord, MemoryRecall, MemoryScope, MemoryStore, MemoryKind } from "./memory/protocols.js";
8
+ import type { WorkflowSpec, WorkflowOutcome, KernelAgentRole } from "./types/agent.js";
9
+ export interface AgentDefinition extends Omit<AgentOptions, "model" | "name"> {
10
+ name?: string;
11
+ provider: LLMProvider;
12
+ tools?: RegisteredTool[];
13
+ executionPlane?: ExecutionPlane;
14
+ sessionLog?: SessionLog;
15
+ maxTokens?: number;
16
+ memoryStore?: MemoryStore;
17
+ memoryScope?: MemoryScope;
18
+ runtimeOptions?: Pick<RuntimeOptions, "memoryPolicy" | "governancePolicy" | "signalSource" | "signalPolicy" | "resourceQuota" | "onPermissionRequest" | "payloadStore" | "runGroup" | "subAgentOrchestrator" | "reducers">;
19
+ }
20
+ export interface AgentRunOptions {
21
+ session?: SessionRef;
22
+ maxTurns?: number;
23
+ signal?: AbortSignal;
24
+ metadata?: Record<string, unknown>;
25
+ onPermissionRequest?: RuntimeOptions["onPermissionRequest"];
26
+ }
27
+ export interface SessionRef {
28
+ id: string;
29
+ }
30
+ export interface RunResult<T = string> {
31
+ output: T;
32
+ runId: string;
33
+ sessionId: string;
34
+ status: "completed" | "partial" | "failed" | "cancelled";
35
+ usage?: TokenUsage;
36
+ }
37
+ export interface AgentSession extends SessionRef {
38
+ run(goal: string, options?: Omit<AgentRunOptions, "session">): Promise<RunResult>;
39
+ stream(goal: string, options?: Omit<AgentRunOptions, "session">): AsyncIterable<StreamEvent>;
40
+ resume(options?: Omit<AgentRunOptions, "session">): AsyncIterable<StreamEvent>;
41
+ interrupt(reason?: "user" | "deadline" | "lease_lost" | "host_shutdown"): void;
42
+ }
43
+ export interface MemoryInput {
44
+ name: string;
45
+ content: string;
46
+ description?: string;
47
+ kind?: MemoryKind;
48
+ confidence?: number;
49
+ pinned?: boolean;
50
+ ttlDays?: number;
51
+ }
52
+ export interface RecallOptions {
53
+ topK?: number;
54
+ kinds?: MemoryKind[];
55
+ minScore?: number;
56
+ }
57
+ export interface DelegationRequest {
58
+ goal: string;
59
+ role?: KernelAgentRole;
60
+ }
61
+ export interface DelegationResult {
62
+ output: string;
63
+ status: "completed" | "partial" | "failed";
64
+ nodeId?: string;
65
+ }
66
+ export interface ExecutableAgent {
67
+ readonly name: string;
68
+ readonly definition: Readonly<AgentDefinition>;
69
+ run(goal: string, options?: AgentRunOptions): Promise<RunResult>;
70
+ stream(goal: string, options?: AgentRunOptions): AsyncIterable<StreamEvent>;
71
+ session(id?: string): AgentSession;
72
+ remember(input: MemoryInput): Promise<MemoryRecord>;
73
+ recall(query: string, options?: RecallOptions): Promise<MemoryRecall[]>;
74
+ delegate(request: DelegationRequest): Promise<DelegationResult>;
75
+ workflow(spec: WorkflowSpec, options?: {
76
+ session?: SessionRef;
77
+ }): Promise<WorkflowOutcome>;
78
+ listen(options?: {
79
+ session?: SessionRef;
80
+ leaseMs?: number;
81
+ }): Promise<RunResult | null>;
82
+ }
83
+ export declare function createAgent(definition: AgentDefinition): ExecutableAgent;
@@ -0,0 +1,219 @@
1
+ import { InMemorySessionLog } from "./runtime/session-log.js";
2
+ import { LocalExecutionPlane } from "./runtime/execution-plane.js";
3
+ import { RuntimeRunner } from "./runtime/runner.js";
4
+ function sessionId(ref) {
5
+ return ref?.id ?? `session-${crypto.randomUUID()}`;
6
+ }
7
+ function statusFromDone(status) {
8
+ if (status === "completed" || status === "done")
9
+ return "completed";
10
+ if (status === "cancelled" || status === "user" || status === "deadline" || status === "lease_lost" || status === "host_shutdown")
11
+ return "cancelled";
12
+ if (status === "failed" || status === "error")
13
+ return "failed";
14
+ return "partial";
15
+ }
16
+ class AgentSessionImpl {
17
+ owner;
18
+ id;
19
+ constructor(owner, id) {
20
+ this.owner = owner;
21
+ this.id = id;
22
+ }
23
+ run(goal, options) {
24
+ return this.owner.run(goal, { ...options, session: { id: this.id } });
25
+ }
26
+ stream(goal, options) {
27
+ return this.owner.stream(goal, { ...options, session: { id: this.id } });
28
+ }
29
+ resume(options) {
30
+ return this.owner.resume(this.id, options);
31
+ }
32
+ interrupt(reason = "user") {
33
+ this.owner.interrupt(reason);
34
+ }
35
+ }
36
+ class ExecutableAgentImpl {
37
+ name;
38
+ definition;
39
+ sessionLog;
40
+ activeRunner = null;
41
+ constructor(definition) {
42
+ if (!definition.provider)
43
+ throw new TypeError("createAgent requires a provider");
44
+ this.definition = Object.freeze({ ...definition });
45
+ this.name = definition.name ?? "agent";
46
+ this.sessionLog = definition.sessionLog ?? new InMemorySessionLog();
47
+ }
48
+ session(id = `session-${crypto.randomUUID()}`) {
49
+ return new AgentSessionImpl(this, id);
50
+ }
51
+ async remember(input) {
52
+ const store = this.definition.memoryStore;
53
+ const scope = this.definition.memoryScope;
54
+ if (!store || !scope)
55
+ throw new Error("agent memory requires memoryStore and memoryScope");
56
+ const now = Date.now();
57
+ const record = {
58
+ record_id: crypto.randomUUID(),
59
+ scope,
60
+ name: input.name,
61
+ kind: input.kind ?? "reference",
62
+ content: input.content,
63
+ description: input.description ?? "",
64
+ provenance: { author: "host", trust: "user_asserted", evidence_refs: [] },
65
+ created_at: now,
66
+ updated_at: now,
67
+ recall_count: 0,
68
+ confidence: input.confidence ?? 1,
69
+ links: [],
70
+ pinned: input.pinned ?? false,
71
+ ...(input.ttlDays !== undefined ? { ttl_days: input.ttlDays } : {}),
72
+ };
73
+ await store.put(this.name, record);
74
+ return record;
75
+ }
76
+ async recall(query, options = {}) {
77
+ const store = this.definition.memoryStore;
78
+ const scope = this.definition.memoryScope;
79
+ if (!store || !scope)
80
+ throw new Error("agent memory requires memoryStore and memoryScope");
81
+ const request = {
82
+ scope,
83
+ query,
84
+ top_k: options.topK ?? 8,
85
+ kinds: options.kinds ?? [],
86
+ ...(options.minScore !== undefined ? { min_score: options.minScore } : {}),
87
+ };
88
+ return store.search(this.name, request);
89
+ }
90
+ async delegate(request) {
91
+ const spec = {
92
+ nodes: [{
93
+ task: { goal: request.goal },
94
+ role: request.role ?? "explore",
95
+ isolation: "read_only",
96
+ contextInheritance: "system_only",
97
+ }],
98
+ };
99
+ const outcome = await this.workflow(spec);
100
+ const node = outcome.nodeOutcomes[0];
101
+ const nodeId = node?.nodeId;
102
+ return {
103
+ output: nodeId ? outcome.outputs[nodeId] ?? "" : "",
104
+ status: node?.status === "completed" ? "completed" : node?.status === "failed" ? "failed" : "partial",
105
+ ...(nodeId ? { nodeId } : {}),
106
+ };
107
+ }
108
+ async workflow(spec, options = {}) {
109
+ const runner = this.createRunner({});
110
+ this.activeRunner = runner;
111
+ try {
112
+ return await runner.runWorkflow(spec, { sessionId: sessionId(options.session) });
113
+ }
114
+ finally {
115
+ this.activeRunner = null;
116
+ }
117
+ }
118
+ async listen(options = {}) {
119
+ const source = this.definition.runtimeOptions?.signalSource;
120
+ if (!source)
121
+ throw new Error("agent signals require runtimeOptions.signalSource");
122
+ const claim = await source.claimSignal(this.name, options.leaseMs);
123
+ if (!claim)
124
+ return null;
125
+ const payload = claim.signal.payload;
126
+ const goal = typeof payload.goal === "string"
127
+ ? payload.goal
128
+ : typeof payload.summary === "string"
129
+ ? payload.summary
130
+ : JSON.stringify(payload);
131
+ try {
132
+ const result = await this.run(goal, options.session ? { session: options.session } : {});
133
+ await source.ackSignal(claim);
134
+ return result;
135
+ }
136
+ catch (error) {
137
+ await source.nackSignal(claim);
138
+ throw error;
139
+ }
140
+ }
141
+ stream(goal, options = {}) {
142
+ const session = sessionId(options.session);
143
+ const runner = this.createRunner(options);
144
+ this.activeRunner = runner;
145
+ const abort = () => runner.interrupt("user");
146
+ if (options.signal) {
147
+ if (options.signal.aborted)
148
+ runner.interrupt("user");
149
+ else
150
+ options.signal.addEventListener("abort", abort, { once: true });
151
+ }
152
+ const stream = runner.run({ sessionId: session, goal });
153
+ return this.clearRunnerAfter(stream, options.signal, abort);
154
+ }
155
+ async run(goal, options = {}) {
156
+ const session = sessionId(options.session);
157
+ const events = [];
158
+ for await (const event of this.stream(goal, { ...options, session: { id: session } }))
159
+ events.push(event);
160
+ const done = [...events].reverse().find(event => event.type === "done");
161
+ const error = [...events].reverse().find(event => event.type === "error");
162
+ const persisted = await this.sessionLog.read(session);
163
+ const started = [...persisted].reverse().find(entry => entry.event.kind === "run_started");
164
+ const usageEvent = [...events].reverse().find(event => event.type === "usage");
165
+ const output = events.filter(event => event.type === "text_delta").map(event => String(event.delta ?? "")).join("");
166
+ return {
167
+ output,
168
+ runId: started?.event.kind === "run_started" ? started.event.run_id : `run-${crypto.randomUUID()}`,
169
+ sessionId: session,
170
+ status: error ? "failed" : statusFromDone(done?.status ?? "partial"),
171
+ ...(usageEvent?.totalTokens !== undefined ? {
172
+ usage: {
173
+ inputTokens: usageEvent.inputTokens ?? 0,
174
+ outputTokens: usageEvent.outputTokens ?? 0,
175
+ totalTokens: usageEvent.totalTokens,
176
+ },
177
+ } : {}),
178
+ };
179
+ }
180
+ async *resume(id, options = {}) {
181
+ const runner = this.createRunner(options);
182
+ this.activeRunner = runner;
183
+ yield* this.clearRunnerAfter(runner.wake(id), options.signal, () => runner.interrupt("user"));
184
+ }
185
+ interrupt(reason = "user") {
186
+ this.activeRunner?.interrupt(reason);
187
+ }
188
+ createRunner(options) {
189
+ const plane = this.definition.executionPlane
190
+ ?? (this.definition.tools ?? []).reduce((current, currentTool) => current.register(currentTool), new LocalExecutionPlane());
191
+ const runtime = {
192
+ provider: this.definition.provider,
193
+ executionPlane: plane,
194
+ sessionLog: this.sessionLog,
195
+ maxTokens: this.definition.maxTokens ?? 32_000,
196
+ ...(this.definition.instructions ? { systemPrompt: this.definition.instructions } : {}),
197
+ ...(options.maxTurns !== undefined ? { maxTurns: options.maxTurns } : {}),
198
+ ...(this.definition.memoryStore ? { memoryStore: this.definition.memoryStore } : {}),
199
+ ...(this.definition.memoryScope ? { memoryScope: this.definition.memoryScope } : {}),
200
+ agentId: this.name,
201
+ ...(this.definition.runtimeOptions ?? {}),
202
+ ...(options.onPermissionRequest ? { onPermissionRequest: options.onPermissionRequest } : {}),
203
+ };
204
+ return new RuntimeRunner(runtime);
205
+ }
206
+ async *clearRunnerAfter(stream, signal, abort) {
207
+ try {
208
+ yield* stream;
209
+ }
210
+ finally {
211
+ if (signal && abort)
212
+ signal.removeEventListener("abort", abort);
213
+ this.activeRunner = null;
214
+ }
215
+ }
216
+ }
217
+ export function createAgent(definition) {
218
+ return new ExecutableAgentImpl(definition);
219
+ }
package/dist/index.d.ts CHANGED
@@ -1,19 +1,11 @@
1
- export { runAgent, runFanout } from "./runtime/facade.js";
2
- export { runLoop, LoopDriver, foldLoopState } from "./runtime/loop-driver.js";
3
- export type { LoopSpec, LoopOutcome } from "./runtime/loop-driver.js";
4
- export type { RunAgentOptions, RunFanoutOptions } from "./runtime/facade.js";
5
- export { RuntimeRunner, collectText } from "./runtime/runner.js";
6
- export type { RuntimeOptions, KernelReliabilityOptions, OperationCancellationReason, PromptBudget, SchedulerPolicy } from "./runtime/runner.js";
7
- export { PayloadStore } from "./runtime/payload-store.js";
8
- export type { PayloadStoreConfig } from "./runtime/payload-store.js";
1
+ export { createAgent } from "./agent-facade.js";
2
+ export type { AgentDefinition, AgentRunOptions, AgentSession, DelegationRequest, DelegationResult, ExecutableAgent, MemoryInput, RecallOptions, RunResult, SessionRef, } from "./agent-facade.js";
3
+ export { collectText } from "./runtime/runner.js";
9
4
  export type { InstructionProfile, NudgeRule, NudgeTrigger } from "./harness/public.js";
10
5
  export type { SignalPolicy } from "./runtime/os-profile.js";
11
6
  export { DEFAULT_CONTEXT_POLICY, PPM_SCALE, contextPolicy, normalizeContextPolicy, ratioToPpm, } from "./runtime/context-policy.js";
12
7
  export type { ContextPolicyOverrides, ContextPolicy, ContextPolicyWire, ContextPressureThresholds, } from "./runtime/context-policy.js";
13
- export { LocalExecutionPlane } from "./runtime/execution-plane.js";
14
- export type { ExecutionPlane, RunContext } from "./runtime/execution-plane.js";
15
- export { InMemorySessionLog, FileSessionLog } from "./runtime/session-log.js";
16
- export type { SessionLog, SessionEvent, SessionEventKind } from "./runtime/session-log.js";
8
+ export type { SessionEvent, SessionEventKind } from "./runtime/session-log.js";
17
9
  export { SESSION_EVENT_KINDS } from "./runtime/session-log.js";
18
10
  export { CANONICAL_CONTENT_PARTS_PREFIX, encodeCanonicalContentParts, decodeCanonicalContentParts, } from "./runtime/kernel-step.js";
19
11
  export { FileKernelJournal, InMemoryKernelJournal, JournalCasConflictError, JournalIntegrityError, JournalIoError, } from "./runtime/kernel-journal.js";
@@ -25,7 +17,6 @@ export type { RunGroup, GroupBudgetStore, GroupLedger, GroupCharge, GroupMember,
25
17
  export { InMemoryEventStream, isVisibleTo } from "./runtime/event-stream.js";
26
18
  export type { EventStream, EventStreamOptions, BlackboardEvent, EventViewer } from "./runtime/event-stream.js";
27
19
  export type { ObserverFailure, ObserverErrorHandler } from "./runtime/reliability.js";
28
- export { ManagedTaskScope, operationAbortSignal } from "./runtime/reliability.js";
29
20
  export type { OperationContext, BackgroundTaskFailure, BackgroundTaskErrorHandler } from "./runtime/reliability.js";
30
21
  export { reactByMention, directorDriven, roundRobin, firstNonEmpty, union } from "./runtime/turn-policy.js";
31
22
  export type { TurnPolicy, PeerView } from "./runtime/turn-policy.js";
@@ -54,11 +45,10 @@ export type { VerifiableCommand, CheckVerdict, VerifiableForkManifest, ForkPlan,
54
45
  export { createEvolutionRuntimeAdapter, createNativeEvolutionRuntimeAdapter, EvolutionRuntime } from "./runtime/evolution.js";
55
46
  export type { ActivationBinding, ArtifactKind, ArtifactManifest, ArtifactRef, ArtifactSet, ArtifactVersion, ContextEntryRef, ContextEntrySource, ContextExecutionInput, ContextPreparationRequest, ContextPlan, ContextPlanAction, ContextSelection, ContextState, EvaluationContextBinding, EvaluationFact, EvaluationGate, EvaluationMetric, EvaluationRun, EvolutionBundle, EvolutionProposal, EvolutionReport, EvolutionVerdict, EvolutionViolation, PromotionDecision, PromotionOutcome, EvolutionStore, } from "./runtime/evolution.js";
56
47
  export type { GovernancePolicy, GovernanceConstraint } from "./governance.js";
57
- export { AgentPool } from "./collaboration/pool.js";
58
48
  export { Agent } from "./agent.js";
59
49
  export type { AgentOptions, AgentMemory, MemoryReference, ModelRef, ModelRequirement } from "./agent.js";
60
50
  export { lowerAgent, normalizeAgent } from "./agent-ir.js";
61
- export type { AgentCapabilityIR, AgentDefinition, AgentLoweringInputs, AgentMemoryIR, AgentSpec, AgentToolDefinition, AgentToolIR } from "./agent-ir.js";
51
+ export type { AgentCapabilityIR, AgentLoweringInputs, AgentMemoryIR, AgentSpec, AgentToolDefinition, AgentToolIR } from "./agent-ir.js";
62
52
  export type { Guardrail } from "./guardrail.js";
63
53
  export type { MCPServer, McpTransport } from "./mcp-server.js";
64
54
  export type { Knowledge, KnowledgeSourceRef } from "./knowledge/public.js";
package/dist/index.js CHANGED
@@ -11,15 +11,10 @@
11
11
  // ║ @deepstrike/sdk/os — profiles, diagnostics, signals, replay tests ║
12
12
  // ╚══════════════════════════════════════════════════════════════════════════╝
13
13
  // ── Start here: the canonical entry points ─────────────────────────────────
14
- export { runAgent, runFanout } from "./runtime/facade.js";
15
14
  // ③ dynamic loop agents: self-pacing rounds over the kernel pacing trap.
16
- export { runLoop, LoopDriver, foldLoopState } from "./runtime/loop-driver.js";
17
- export { RuntimeRunner, collectText } from "./runtime/runner.js";
18
- export { PayloadStore } from "./runtime/payload-store.js";
15
+ export { createAgent } from "./agent-facade.js";
16
+ export { collectText } from "./runtime/runner.js";
19
17
  export { DEFAULT_CONTEXT_POLICY, PPM_SCALE, contextPolicy, normalizeContextPolicy, ratioToPpm, } from "./runtime/context-policy.js";
20
- // ── Execution plane + session log (the defaults) ────────────────────────────
21
- export { LocalExecutionPlane } from "./runtime/execution-plane.js";
22
- export { InMemorySessionLog, FileSessionLog } from "./runtime/session-log.js";
23
18
  // Registered session-event vocabulary (F9/S3; manifest-pinned by sdk-conformance, P7-S4)
24
19
  export { SESSION_EVENT_KINDS } from "./runtime/session-log.js";
25
20
  // ── content-parts-v1 registered encoding (F14/B5; byte-pinned by sdk-conformance) ──
@@ -29,7 +24,6 @@ export { FileKernelJournal, InMemoryKernelJournal, JournalCasConflictError, Jour
29
24
  export { diagnoseKernelJournal } from "./runtime/kernel-doctor.js";
30
25
  export { InMemoryGroupBudgetStore, GroupBudgetScope } from "./runtime/run-group.js";
31
26
  export { InMemoryEventStream, isVisibleTo } from "./runtime/event-stream.js";
32
- export { ManagedTaskScope, operationAbortSignal } from "./runtime/reliability.js";
33
27
  export { reactByMention, directorDriven, roundRobin, firstNonEmpty, union } from "./runtime/turn-policy.js";
34
28
  export { ReactiveSession, readRecentTool } from "./runtime/reactive-session.js";
35
29
  export { InMemoryReactionCheckpointStore, ReactionInProgressError } from "./runtime/reaction-checkpoint.js";
@@ -50,7 +44,6 @@ export { VERIFIABLE_REPORT_SCHEMA, VERIFIABLE_FORK_SCHEMA, assertVerifiableRepor
50
44
  export { createEvolutionRuntimeAdapter, createNativeEvolutionRuntimeAdapter, EvolutionRuntime } from "./runtime/evolution.js";
51
45
  // ── Multi-agent primitive ───────────────────────────────────────────────────
52
46
  // Parallel fan-out / sub-agent delegation. The full orchestration layer is in `@deepstrike/sdk/workflow`.
53
- export { AgentPool } from "./collaboration/pool.js";
54
47
  // ── Ecosystem Surface Contract (spc_001) ────────────────────────────────────
55
48
  export { Agent } from "./agent.js";
56
49
  export { lowerAgent, normalizeAgent } from "./agent-ir.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepstrike/sdk",
3
- "version": "0.2.70",
3
+ "version": "0.2.71",
4
4
  "description": "DeepStrike Node.js SDK",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -34,6 +34,10 @@
34
34
  "./os": {
35
35
  "types": "./dist/os/public.d.ts",
36
36
  "import": "./dist/os/public.js"
37
+ },
38
+ "./advanced": {
39
+ "types": "./dist/advanced/public.d.ts",
40
+ "import": "./dist/advanced/public.js"
37
41
  }
38
42
  },
39
43
  "typesVersions": {
@@ -55,6 +59,9 @@
55
59
  ],
56
60
  "os": [
57
61
  "./dist/os/public.d.ts"
62
+ ],
63
+ "advanced": [
64
+ "./dist/advanced/public.d.ts"
58
65
  ]
59
66
  }
60
67
  },
@@ -73,7 +80,7 @@
73
80
  },
74
81
  "dependencies": {
75
82
  "@anthropic-ai/sdk": "^0.99.0",
76
- "@deepstrike/core": "0.2.70",
83
+ "@deepstrike/core": "0.2.71",
77
84
  "@google/generative-ai": "^0.24.1",
78
85
  "openai": "^7.5.0"
79
86
  },