@deepstrike/sdk 0.2.8 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  export { RuntimeRunner, collectText } from "./runtime/runner.js";
2
2
  export type { RuntimeOptions, SchedulerBudget } from "./runtime/runner.js";
3
3
  export type { MemoryPolicy, MemoryWriteRateLimit, ResourceQuota } from "./kernel.js";
4
- export { createTournament, createLoopUntilDone } from "./kernel.js";
5
- export type { TournamentMatch, TournamentAction, StopConditionSpec, RoundReport, LoopAction, } from "./kernel.js";
6
4
  export { KernelPrimitivesDashboard } from "./runtime/kernel-primitives-dashboard.js";
7
5
  export { FilteredExecutionPlane } from "./runtime/filtered-plane.js";
8
6
  export { SubAgentOrchestrator, defaultSubAgentOrchestrator, spawnStandalone } from "./runtime/sub-agent-orchestrator.js";
package/dist/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  // ── Runtime (Layer 1.5) ────────────────────────────────────────────────────
2
2
  export { RuntimeRunner, collectText } from "./runtime/runner.js";
3
- export { createTournament, createLoopUntilDone } from "./kernel.js";
4
3
  export { KernelPrimitivesDashboard } from "./runtime/kernel-primitives-dashboard.js";
5
4
  export { FilteredExecutionPlane } from "./runtime/filtered-plane.js";
6
5
  export { SubAgentOrchestrator, defaultSubAgentOrchestrator, spawnStandalone } from "./runtime/sub-agent-orchestrator.js";
package/dist/kernel.d.ts CHANGED
@@ -147,54 +147,6 @@ export interface KernelRuntimeInstance {
147
147
  drainNewMessages(): Message[];
148
148
  preservedRefs(): string[];
149
149
  }
150
- /** One pairwise match-up in a tournament round. */
151
- export interface TournamentMatch {
152
- id: number;
153
- left: string;
154
- right: string;
155
- }
156
- /** Discriminated action returned by {@link TournamentInstance} methods. */
157
- export interface TournamentAction {
158
- kind: "judgeRound" | "done";
159
- /** `judgeRound`: 1-based round number. */
160
- round?: number;
161
- /** `judgeRound`: run one fresh-context judge per match (parallelisable). */
162
- matches?: TournamentMatch[];
163
- /** `done`: the winning entrant id. */
164
- winner?: string;
165
- /** `done`: number of rounds played. */
166
- roundsUsed?: number;
167
- }
168
- interface TournamentInstance {
169
- start(): TournamentAction;
170
- feedRound(winners: string[]): TournamentAction;
171
- isDone(): boolean;
172
- }
173
- /** A single loop stop predicate. `maxRounds` is required when `kind === "maxRounds"`. */
174
- export interface StopConditionSpec {
175
- kind: "noNewFindings" | "noErrors" | "maxRounds";
176
- maxRounds?: number;
177
- }
178
- /** What the SDK reports after running a loop round's worker. */
179
- export interface RoundReport {
180
- newFindings: number;
181
- errors: number;
182
- }
183
- /** Discriminated action returned by {@link LoopUntilDoneInstance} methods. */
184
- export interface LoopAction {
185
- kind: "spawn" | "done";
186
- /** `spawn`: 1-based round number to run. */
187
- round?: number;
188
- /** `done`: number of rounds run. */
189
- roundsUsed?: number;
190
- /** `done`: which condition fired. */
191
- reason?: "noNewFindings" | "noErrors" | "maxRounds";
192
- }
193
- interface LoopUntilDoneInstance {
194
- start(): LoopAction;
195
- feed(report: RoundReport): LoopAction;
196
- isDone(): boolean;
197
- }
198
150
  interface KernelModule {
199
151
  Governance: new (defaultAction?: "allow" | "deny" | "ask_user") => GovernanceInstance;
200
152
  KernelRuntime: new (policy: {
@@ -208,12 +160,6 @@ interface KernelModule {
208
160
  extractSkillOnPass?: boolean;
209
161
  }) => EvalPipelineInstance;
210
162
  IdlePipeline: new (agentId: string) => IdlePipelineInstance;
211
- Tournament: new (entrants: string[]) => TournamentInstance;
212
- LoopUntilDone: new (conditions: StopConditionSpec[]) => LoopUntilDoneInstance;
213
163
  }
214
- /** Create a single-elimination tournament (pairwise comparative judging). Throws if `entrants` is empty. */
215
- export declare function createTournament(entrants: string[]): TournamentInstance;
216
- /** Create a loop-until-done state machine. A `maxRounds` backstop is injected if none is given. */
217
- export declare function createLoopUntilDone(conditions: StopConditionSpec[]): LoopUntilDoneInstance;
218
164
  export declare function getKernel(): KernelModule;
219
165
  export {};
package/dist/kernel.js CHANGED
@@ -2,14 +2,6 @@ import { createRequire } from "module";
2
2
  import { existsSync } from "node:fs";
3
3
  import { dirname, join } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
- /** Create a single-elimination tournament (pairwise comparative judging). Throws if `entrants` is empty. */
6
- export function createTournament(entrants) {
7
- return new (getKernel().Tournament)(entrants);
8
- }
9
- /** Create a loop-until-done state machine. A `maxRounds` backstop is injected if none is given. */
10
- export function createLoopUntilDone(conditions) {
11
- return new (getKernel().LoopUntilDone)(conditions);
12
- }
13
5
  const cjsRequire = createRequire(import.meta.url);
14
6
  let cachedKernel;
15
7
  function resolveCoreModule() {
@@ -276,15 +276,17 @@ export class RuntimeRunner {
276
276
  // W0-ABI resume: skip nodes already completed before an interruption.
277
277
  ...(opts?.resumedCompleted?.length ? { resumed_completed: opts.resumedCompleted } : {}),
278
278
  });
279
+ const collectNodes = (obs) => obs.find(o => o.kind === "workflow_batch_spawned")
280
+ ?.nodes ?? [];
281
+ const findDone = (obs) => obs.find(o => o.kind === "workflow_completed");
282
+ let done = findDone(observations);
283
+ if (done)
284
+ return { completed: done.completed ?? [], failed: done.failed ?? [] };
285
+ let nodes = collectNodes(observations);
279
286
  for (;;) {
280
- const done = observations.find(o => o.kind === "workflow_completed");
281
- if (done)
282
- return { completed: done.completed ?? [], failed: done.failed ?? [] };
283
- const batch = observations.find(o => o.kind === "workflow_batch_spawned");
284
- const nodes = batch?.nodes ?? [];
285
287
  if (nodes.length === 0)
286
288
  return { completed: [], failed: [] }; // nothing to run (e.g. all gated)
287
- // Run the batch's nodes in parallel — each is independent within a round.
289
+ // Run the currently-runnable nodes in parallel — each is independent within a round.
288
290
  const results = await Promise.all(nodes.map(node => orchestrator.run({
289
291
  parentOpts: this.opts,
290
292
  parentSessionId,
@@ -293,13 +295,23 @@ export class RuntimeRunner {
293
295
  sessionLog: this.opts.sessionLog,
294
296
  ...(this.opts.subAgentHarness ? { harness: this.opts.subAgentHarness } : {}),
295
297
  })));
296
- // Feed completions back; the draining feed yields the next batch or completion.
297
- observations = [];
298
+ // Feed completions back one at a time. The kernel's run-queue executor may spawn a node's
299
+ // dependents the moment *that* node completes (per-node unblock), so each feed can emit its
300
+ // own `workflow_batch_spawned`; ACCUMULATE them across the round rather than keeping only the
301
+ // last feed's (the old code overwrote `observations` per feed and dropped nodes unblocked by
302
+ // earlier completions — stalling uneven DAGs). Completion and new spawns are mutually
303
+ // exclusive per feed, so a `workflow_completed` only arrives once nothing remains to run.
304
+ const nextNodes = [];
305
+ done = undefined;
298
306
  for (const result of results) {
299
- observations = kernelApply(runtime, this.pendingObservations, {
307
+ const obs = kernelApply(runtime, this.pendingObservations, {
300
308
  kind: "sub_agent_completed",
301
309
  result: subAgentResultToKernel(result),
302
310
  });
311
+ nextNodes.push(...collectNodes(obs));
312
+ const d = findDone(obs);
313
+ if (d)
314
+ done = d;
303
315
  // Persist node completion for resume recovery.
304
316
  await this.opts.sessionLog.append(parentSessionId, buildWorkflowNodeCompletedEvent({
305
317
  turn: runtime.turn(),
@@ -307,6 +319,10 @@ export class RuntimeRunner {
307
319
  termination: result.result.termination,
308
320
  }));
309
321
  }
322
+ if (done && nextNodes.length === 0) {
323
+ return { completed: done.completed ?? [], failed: done.failed ?? [] };
324
+ }
325
+ nodes = nextNodes;
310
326
  }
311
327
  }
312
328
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepstrike/sdk",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "DeepStrike Node.js SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -20,7 +20,7 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@anthropic-ai/sdk": "^0.99.0",
23
- "@deepstrike/core": "0.2.8",
23
+ "@deepstrike/core": "0.2.9",
24
24
  "@google/generative-ai": "^0.24.1",
25
25
  "openai": "^5.23.2"
26
26
  },