@deepstrike/sdk 0.2.38 → 0.2.40

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.
Files changed (102) hide show
  1. package/README.md +61 -31
  2. package/dist/collaboration/contract.d.ts +2 -2
  3. package/dist/collaboration/contract.js +2 -2
  4. package/dist/collaboration/handoff.d.ts +2 -14
  5. package/dist/collaboration/handoff.js +1 -17
  6. package/dist/collaboration/harness.d.ts +16 -47
  7. package/dist/collaboration/harness.js +57 -158
  8. package/dist/collaboration/index.d.ts +2 -2
  9. package/dist/collaboration/index.js +1 -2
  10. package/dist/collaboration/modes/creator-verifier.js +42 -6
  11. package/dist/collaboration/pool.d.ts +8 -0
  12. package/dist/collaboration/pool.js +56 -3
  13. package/dist/harness/harness.d.ts +97 -97
  14. package/dist/harness/harness.js +190 -144
  15. package/dist/harness/judge.d.ts +3 -2
  16. package/dist/harness/judge.js +7 -3
  17. package/dist/harness/public.d.ts +5 -3
  18. package/dist/harness/public.js +3 -2
  19. package/dist/index.d.ts +22 -7
  20. package/dist/index.js +8 -1
  21. package/dist/kernel.d.ts +12 -39
  22. package/dist/memory/agent.d.ts +8 -41
  23. package/dist/memory/agent.js +34 -117
  24. package/dist/memory/extraction.d.ts +4 -0
  25. package/dist/memory/extraction.js +79 -0
  26. package/dist/memory/in-memory-store.d.ts +28 -15
  27. package/dist/memory/in-memory-store.js +74 -25
  28. package/dist/memory/protocols.d.ts +56 -56
  29. package/dist/memory/protocols.js +1 -0
  30. package/dist/memory/public.d.ts +3 -1
  31. package/dist/memory/public.js +1 -0
  32. package/dist/memory/ranking.d.ts +33 -0
  33. package/dist/memory/ranking.js +77 -0
  34. package/dist/memory/retention.d.ts +17 -0
  35. package/dist/memory/retention.js +54 -0
  36. package/dist/os/public.d.ts +3 -3
  37. package/dist/os/public.js +1 -1
  38. package/dist/providers/base.d.ts +8 -0
  39. package/dist/providers/base.js +0 -0
  40. package/dist/providers/gemini.js +12 -0
  41. package/dist/providers/ollama.js +3 -1
  42. package/dist/providers/openai-responses.js +9 -2
  43. package/dist/providers/profiles.d.ts +5 -3
  44. package/dist/providers/profiles.js +3 -3
  45. package/dist/runtime/context-policy.d.ts +35 -0
  46. package/dist/runtime/context-policy.js +66 -0
  47. package/dist/runtime/eval.d.ts +6 -2
  48. package/dist/runtime/eval.js +2 -2
  49. package/dist/runtime/event-stream.d.ts +9 -0
  50. package/dist/runtime/event-stream.js +25 -11
  51. package/dist/runtime/execution-plane.d.ts +5 -1
  52. package/dist/runtime/execution-plane.js +9 -3
  53. package/dist/runtime/facade.js +2 -1
  54. package/dist/runtime/kernel-event-log.d.ts +0 -2
  55. package/dist/runtime/kernel-event-log.js +61 -13
  56. package/dist/runtime/kernel-primitives-dashboard.js +1 -1
  57. package/dist/runtime/kernel-rebuild.d.ts +13 -0
  58. package/dist/runtime/kernel-rebuild.js +75 -0
  59. package/dist/runtime/kernel-step.d.ts +157 -8
  60. package/dist/runtime/kernel-step.js +220 -7
  61. package/dist/runtime/kernel-transaction-log.d.ts +61 -0
  62. package/dist/runtime/kernel-transaction-log.js +149 -0
  63. package/dist/runtime/large-result-spool.d.ts +3 -1
  64. package/dist/runtime/large-result-spool.js +24 -5
  65. package/dist/runtime/loop-driver.d.ts +1 -1
  66. package/dist/runtime/loop-driver.js +2 -7
  67. package/dist/runtime/mcp-proxy-plane.d.ts +1 -0
  68. package/dist/runtime/mcp-proxy-plane.js +23 -6
  69. package/dist/runtime/os-profile.d.ts +9 -10
  70. package/dist/runtime/os-profile.js +14 -10
  71. package/dist/runtime/os-snapshot.d.ts +19 -0
  72. package/dist/runtime/os-snapshot.js +33 -3
  73. package/dist/runtime/process-sandbox-plane.js +16 -11
  74. package/dist/runtime/reaction-checkpoint.d.ts +51 -0
  75. package/dist/runtime/reaction-checkpoint.js +83 -0
  76. package/dist/runtime/reactive-session.d.ts +9 -3
  77. package/dist/runtime/reactive-session.js +44 -14
  78. package/dist/runtime/reliability.d.ts +48 -0
  79. package/dist/runtime/reliability.js +86 -0
  80. package/dist/runtime/remote-vpc-plane.js +4 -3
  81. package/dist/runtime/run-group.d.ts +38 -35
  82. package/dist/runtime/run-group.js +97 -54
  83. package/dist/runtime/runner.d.ts +117 -78
  84. package/dist/runtime/runner.js +1516 -1197
  85. package/dist/runtime/session-log.d.ts +71 -12
  86. package/dist/runtime/session-log.js +192 -32
  87. package/dist/runtime/session-repair.d.ts +11 -7
  88. package/dist/runtime/session-repair.js +11 -8
  89. package/dist/runtime/sub-agent-orchestrator.d.ts +6 -2
  90. package/dist/runtime/sub-agent-orchestrator.js +45 -18
  91. package/dist/signals/gateway.d.ts +23 -10
  92. package/dist/signals/gateway.js +81 -17
  93. package/dist/signals/scheduled.js +0 -1
  94. package/dist/signals/types.d.ts +21 -13
  95. package/dist/skills/loader.js +12 -2
  96. package/dist/tools/index.d.ts +2 -0
  97. package/dist/types/agent.d.ts +40 -1
  98. package/dist/types/agent.js +61 -1
  99. package/dist/types.d.ts +6 -1
  100. package/dist/workflow/public.d.ts +2 -3
  101. package/dist/workflow/public.js +0 -1
  102. package/package.json +2 -2
@@ -1,166 +1,212 @@
1
- import { collectText } from "../runtime/runner.js";
2
- import { writeFile } from "fs/promises";
3
- import path from "path";
4
- import { HybridJudge, VerdictFnJudge, LlmEvalJudge } from "./judge.js";
5
- async function runOnce(runner, req) {
6
- let text = "";
7
- let done;
8
- const sessionId = crypto.randomUUID();
9
- for await (const evt of runner.run({ sessionId, goal: req.goal, criteria: req.criteria?.map(c => c.text), extensions: req.extensions })) {
10
- if (evt.type === "text_delta")
11
- text += evt.delta;
12
- else if (evt.type === "done")
13
- done = evt;
14
- }
15
- return { result: text, passed: false, iterations: done?.iterations ?? 0, totalTokens: done?.totalTokens ?? 0, status: done?.status ?? "error" };
16
- }
17
- export class SinglePassHarness {
1
+ /** Adapts RuntimeRunner to the body slot without giving the loop knowledge of kernel events. */
2
+ export class RuntimeAttemptBody {
18
3
  runner;
19
4
  constructor(runner) {
20
5
  this.runner = runner;
21
6
  }
22
- async run(request) {
23
- return { ...await runOnce(this.runner, request), passed: true };
24
- }
25
- async *stream(request) {
26
- yield* this.runner.run({ sessionId: crypto.randomUUID(), goal: request.goal, criteria: request.criteria?.map(c => c.text), extensions: request.extensions });
27
- }
28
- }
29
- /**
30
- * @deprecated I3.4 (A1): prefer {@link HarnessLoop} with `verdictFn` for host-defined judgment.
31
- * `EvalLoopHarness.stream()` does NOT honor the `gate` passed via `request.gate` (only `.run()`
32
- * does), which is a long-standing footgun for streaming hosts. `HarnessLoop` runs the eval loop
33
- * uniformly across both stream and run, accepts an optional `verdictFn` for short-circuiting the
34
- * built-in LLM eval, and otherwise mirrors `EvalLoopHarness`'s behavior. New code should use
35
- * `HarnessLoop`; existing call sites can migrate by switching the class + (if applicable)
36
- * passing a `verdictFn` for the same gate logic. Slated for removal in a future major. */
37
- export class EvalLoopHarness {
38
- runner;
39
- gate;
40
- maxAttempts;
41
- constructor(runner, gate, maxAttempts = 3) {
42
- this.runner = runner;
43
- this.gate = gate;
44
- this.maxAttempts = maxAttempts;
45
- }
46
- async run(request) {
47
- let outcome = { result: "", passed: false, iterations: 0, totalTokens: 0, status: "error" };
48
- for (let i = 0; i < this.maxAttempts; i++) {
49
- outcome = await runOnce(this.runner, request);
50
- if (await this.gate.evaluate(request, outcome))
51
- return { ...outcome, passed: true };
7
+ async *run(context) {
8
+ if (context.contextInput)
9
+ this.runner.injectNote(context.contextInput);
10
+ let result = "";
11
+ let done;
12
+ const submittedNodes = [];
13
+ for await (const event of this.runner.run({
14
+ sessionId: context.sessionId,
15
+ goal: context.goal,
16
+ criteria: (context.criteria ?? []).map(criterion => criterion.text),
17
+ extensions: context.extensions,
18
+ ...(context.attempt === 1 && context.inheritEvents
19
+ ? { inheritEvents: context.inheritEvents }
20
+ : {}),
21
+ })) {
22
+ if (event.type === "text_delta") {
23
+ const text = event.delta;
24
+ result += text;
25
+ yield { type: "token", text };
26
+ }
27
+ else if (event.type === "tool_call") {
28
+ const call = event;
29
+ yield { type: "tool_call", id: call.id, name: call.name };
30
+ }
31
+ else if (event.type === "tool_delta") {
32
+ const delta = event;
33
+ yield {
34
+ type: "tool_delta",
35
+ callId: delta.callId,
36
+ ...(delta.delta !== undefined ? { delta: delta.delta } : {}),
37
+ ...(delta.chunk !== undefined ? { chunk: delta.chunk } : {}),
38
+ };
39
+ }
40
+ else if (event.type === "tool_suspend") {
41
+ const suspended = event;
42
+ yield {
43
+ type: "tool_suspend",
44
+ callId: suspended.callId,
45
+ suspensionId: suspended.suspensionId,
46
+ ...(suspended.payload !== undefined ? { payload: suspended.payload } : {}),
47
+ };
48
+ }
49
+ else if (event.type === "tool_result") {
50
+ const toolResult = event;
51
+ yield {
52
+ type: "tool_result",
53
+ callId: toolResult.callId,
54
+ content: toolResult.content,
55
+ isError: toolResult.isError,
56
+ };
57
+ }
58
+ else if (event.type === "workflow_nodes_submitted") {
59
+ const nodes = event.nodes;
60
+ submittedNodes.push(...nodes);
61
+ yield { type: "workflow_nodes_submitted", nodes };
62
+ }
63
+ else if (event.type === "error") {
64
+ yield { type: "body_error", message: String(event.message ?? "run failed") };
65
+ }
66
+ else if (event.type === "done") {
67
+ done = event;
68
+ }
52
69
  }
53
- return outcome;
54
- }
55
- async *stream(request) {
56
- yield* this.runner.run({ sessionId: crypto.randomUUID(), goal: request.goal, criteria: request.criteria?.map(c => c.text), extensions: request.extensions });
70
+ yield {
71
+ type: "body_done",
72
+ runStatus: done?.status ?? "error",
73
+ result,
74
+ turns: done?.iterations ?? 0,
75
+ totalTokens: done?.totalTokens ?? 0,
76
+ ...(submittedNodes.length > 0 ? { submittedNodes } : {}),
77
+ };
57
78
  }
58
79
  }
59
- export class HarnessLoop {
60
- runner;
61
- maxAttempts;
62
- skillDir;
63
- /** How each attempt is judged. Hybrid (host verdictFn → LLM eval) when a verdictFn is supplied,
64
- * otherwise the built-in LLM eval. The loop just calls `this.judge.judge(...)`. */
65
- judge;
66
- constructor(runner, evalProvider, options = {}) {
67
- this.runner = runner;
68
- this.maxAttempts = options.maxAttempts ?? 3;
69
- this.skillDir = options.skillDir;
70
- const llmJudge = new LlmEvalJudge(evalProvider);
71
- this.judge = options.verdictFn
72
- ? new HybridJudge(new VerdictFnJudge(options.verdictFn), llmJudge)
73
- : llmJudge;
80
+ /** Default: retain the transcript and deliver judge feedback through the runner's signal input. */
81
+ export const continueSession = context => ({
82
+ sessionId: context.rootSessionId,
83
+ goal: context.goal,
84
+ ...(context.previousVerdict?.feedback
85
+ ? { contextInput: context.previousVerdict.feedback }
86
+ : {}),
87
+ });
88
+ /** Explicit isolation policy preserving the old fresh-session + goal-feedback behavior. */
89
+ export const freshWithFeedback = context => ({
90
+ sessionId: context.attempt === 1 ? context.rootSessionId : crypto.randomUUID(),
91
+ goal: context.previousVerdict?.feedback
92
+ ? `${context.goal}\n\n[Attempt ${context.attempt - 1} feedback: ${context.previousVerdict.feedback}]`
93
+ : context.goal,
94
+ });
95
+ export function freshWithDigest(digest) {
96
+ return async (context) => ({
97
+ sessionId: context.attempt === 1 ? context.rootSessionId : crypto.randomUUID(),
98
+ goal: context.previousVerdict
99
+ ? `${context.goal}\n\n[Prior attempt digest: ${await digest(context.previousVerdict, context.attempt - 1)}]`
100
+ : context.goal,
101
+ });
102
+ }
103
+ function isRunError(status) {
104
+ const normalized = status.toLocaleLowerCase();
105
+ return normalized === "error" || normalized === "invalid_arg" || normalized === "user_abort";
106
+ }
107
+ /** One attempt engine. Body, judgment, carry, and stopping are independent policy slots. */
108
+ export class AttemptLoop {
109
+ options;
110
+ carry;
111
+ constructor(options) {
112
+ this.options = options;
113
+ if (!Number.isInteger(options.stop.maxAttempts) || options.stop.maxAttempts < 1) {
114
+ throw new Error("AttemptLoop stop.maxAttempts must be a positive integer");
115
+ }
116
+ if (options.stop.maxTotalTokens !== undefined && options.stop.maxTotalTokens < 0) {
117
+ throw new Error("AttemptLoop stop.maxTotalTokens must be non-negative");
118
+ }
119
+ this.carry = options.carry ?? continueSession;
74
120
  }
75
121
  async run(request) {
76
- let last;
77
- // R3-1: collect nodes the agent submitted while running under the harness, so dynamic fan-out
78
- // works in harness mode too (not just the plain streaming path).
79
- const submittedNodes = [];
80
- for await (const evt of this.stream(request)) {
81
- last = evt;
82
- if (evt.type === "workflow_nodes_submitted")
83
- submittedNodes.push(...evt.nodes);
122
+ let outcome;
123
+ for await (const event of this.stream(request)) {
124
+ if (event.type === "completed")
125
+ outcome = event.outcome;
84
126
  }
85
- const done = last?.type === "done" ? last : undefined;
86
- return {
87
- result: "",
88
- passed: done?.verdict.passed ?? false,
89
- iterations: done?.iterations ?? 0,
90
- totalTokens: done?.totalTokens ?? 0,
91
- status: done?.status ?? "error",
92
- overallScore: done?.verdict.overallScore,
93
- feedback: done?.verdict.feedback,
94
- details: done?.verdict.details,
95
- ...(submittedNodes.length ? { submittedNodes } : {}),
96
- };
127
+ if (!outcome)
128
+ throw new Error("AttemptLoop ended without an outcome");
129
+ return outcome;
97
130
  }
98
131
  async *stream(request) {
132
+ const rootSessionId = request.sessionId ?? crypto.randomUUID();
99
133
  const criteria = request.criteria ?? [];
100
- let currentGoal = request.goal;
101
- let lastIterations = 0;
102
- let lastTotalTokens = 0;
103
- let lastStatus = "error";
104
- let lastResult = "";
105
- for (let attempt = 1; attempt <= this.maxAttempts; attempt++) {
106
- const sessionId = crypto.randomUUID();
107
- for await (const evt of this.runner.run({ sessionId, goal: currentGoal, criteria: criteria.map(c => c.text), extensions: request.extensions })) {
108
- if (evt.type === "text_delta") {
109
- lastResult += evt.delta;
110
- yield { type: "token", text: evt.delta };
111
- }
112
- else if (evt.type === "tool_call") {
113
- const tc = evt;
114
- yield { type: "tool_call", id: tc.id, name: tc.name };
115
- }
116
- else if (evt.type === "tool_delta") {
117
- const td = evt;
118
- yield { type: "tool_delta", callId: td.callId, ...(td.delta ? { delta: td.delta } : {}), ...(td.chunk ? { chunk: td.chunk } : {}) };
119
- }
120
- else if (evt.type === "tool_suspend") {
121
- const ts = evt;
122
- yield { type: "tool_suspend", callId: ts.callId, suspensionId: ts.suspensionId, ...(ts.payload ? { payload: ts.payload } : {}) };
123
- }
124
- else if (evt.type === "tool_result") {
125
- const tr = evt;
126
- yield { type: "tool_result", callId: tr.callId, content: tr.content, isError: tr.isError };
127
- }
128
- else if (evt.type === "workflow_nodes_submitted") {
129
- const ws = evt;
130
- yield { type: "workflow_nodes_submitted", nodes: ws.nodes };
134
+ const submittedNodes = [];
135
+ let totalTokens = 0;
136
+ let totalTurns = 0;
137
+ let previousVerdict;
138
+ for (let attempt = 1; attempt <= this.options.stop.maxAttempts; attempt++) {
139
+ const prepared = await this.carry({
140
+ rootSessionId,
141
+ goal: request.goal,
142
+ attempt,
143
+ previousVerdict,
144
+ });
145
+ let terminal;
146
+ for await (const event of this.options.body.run({
147
+ ...request,
148
+ sessionId: prepared.sessionId,
149
+ goal: prepared.goal,
150
+ criteria,
151
+ attempt,
152
+ ...(prepared.contextInput ? { contextInput: prepared.contextInput } : {}),
153
+ })) {
154
+ if (event.type === "body_done") {
155
+ terminal = event;
156
+ if (event.submittedNodes)
157
+ submittedNodes.push(...event.submittedNodes);
131
158
  }
132
- else if (evt.type === "done") {
133
- const d = evt;
134
- lastIterations = d.iterations;
135
- lastTotalTokens = d.totalTokens;
136
- lastStatus = d.status;
159
+ else {
160
+ yield event;
137
161
  }
138
162
  }
139
- yield { type: "supervising" };
140
- // I3.2 (A2/A3): the judge Strategy encapsulates "host verdictFn short-circuit → built-in LLM
141
- // eval". HarnessLoop's judge always terminates in LlmEvalJudge, so a verdict is guaranteed.
142
- const judged = await this.judge.judge({ goal: request.goal, criteria, attempt, result: lastResult });
143
- const verdict = judged?.verdict;
144
- const skillCandidate = judged?.skillCandidate;
145
- if (!verdict)
146
- throw new Error("HarnessLoop: judge produced no verdict");
163
+ if (!terminal)
164
+ throw new Error("AttemptBody ended without body_done");
165
+ totalTokens += terminal.totalTokens;
166
+ totalTurns += terminal.turns;
167
+ const base = {
168
+ runStatus: terminal.runStatus,
169
+ result: terminal.result,
170
+ attempts: attempt,
171
+ turns: totalTurns,
172
+ totalTokens,
173
+ ...(submittedNodes.length > 0 ? { submittedNodes } : {}),
174
+ };
175
+ if (isRunError(terminal.runStatus)) {
176
+ yield { type: "completed", outcome: { outcome: "run_error", ...base } };
177
+ return;
178
+ }
179
+ yield { type: "judging", attempt };
180
+ const judged = await this.options.judge.judge({
181
+ goal: request.goal,
182
+ criteria,
183
+ attempt,
184
+ result: terminal.result,
185
+ });
186
+ if (!judged)
187
+ throw new Error("AttemptLoop judge produced no verdict");
188
+ const verdict = judged.verdict;
147
189
  if (verdict.passed) {
148
- if (skillCandidate && this.skillDir) {
149
- const { name, description, whenToUse, content } = skillCandidate;
150
- const fm = ["---", `name: ${name}`, `description: ${description}`,
151
- whenToUse ? `when_to_use: ${whenToUse}` : null, "---", ""]
152
- .filter(Boolean).join("\n");
153
- await writeFile(path.join(this.skillDir, `${name}.md`), fm + content, "utf8");
154
- }
155
- yield { type: "done", verdict, iterations: lastIterations, totalTokens: lastTotalTokens, status: lastStatus };
190
+ const outcome = { outcome: "passed", ...base, verdict };
191
+ await this.options.onPass?.({ outcome, judgeResult: judged });
192
+ yield { type: "completed", outcome };
193
+ return;
194
+ }
195
+ previousVerdict = verdict;
196
+ const tokenLimitReached = this.options.stop.maxTotalTokens !== undefined
197
+ && totalTokens >= this.options.stop.maxTotalTokens;
198
+ if (this.options.stop.stopOnFailedVerdict || attempt === this.options.stop.maxAttempts || tokenLimitReached) {
199
+ yield {
200
+ type: "completed",
201
+ outcome: {
202
+ outcome: this.options.stop.stopOnFailedVerdict ? "failed_judge" : "exhausted",
203
+ ...base,
204
+ verdict,
205
+ },
206
+ };
156
207
  return;
157
208
  }
158
- yield { type: "revising", verdict };
159
- currentGoal = `${request.goal}\n\n[Attempt ${attempt} feedback: ${verdict.feedback}]`;
160
- lastResult = "";
209
+ yield { type: "retrying", attempt, verdict };
161
210
  }
162
- yield { type: "max_attempts_reached" };
163
211
  }
164
212
  }
165
- // Re-export collectText so harness callers can use it without knowing runner internals.
166
- export { collectText };
@@ -1,6 +1,7 @@
1
1
  import type { LLMProvider } from "../types.js";
2
2
  import { getKernel } from "../kernel.js";
3
- import type { Criterion, Verdict, VerdictFn } from "./harness.js";
3
+ import type { VerdictFn } from "./harness.js";
4
+ import type { Criterion, Verdict } from "../runtime/eval.js";
4
5
  export type SkillCandidate = ReturnType<ReturnType<typeof getKernel>["parseVerdict"]>["skillCandidate"];
5
6
  export interface JudgeContext {
6
7
  goal: string;
@@ -32,7 +33,7 @@ export declare class LlmEvalJudge implements AttemptJudge {
32
33
  constructor(evalProvider: LLMProvider, extractSkillOnPass?: boolean);
33
34
  judge(ctx: JudgeContext): Promise<JudgeResult>;
34
35
  }
35
- /** Try `primary`; if it defers (`undefined`), use `fallback`. Models HarnessLoop's
36
+ /** Try `primary`; if it defers (`undefined`), use `fallback`.
36
37
  * "verdictFn short-circuits, else built-in LLM eval" hybrid judgment. */
37
38
  export declare class HybridJudge implements AttemptJudge {
38
39
  private readonly primary;
@@ -15,13 +15,17 @@ export class VerdictFnJudge {
15
15
  export class LlmEvalJudge {
16
16
  evalProvider;
17
17
  extractSkillOnPass;
18
- constructor(evalProvider, extractSkillOnPass = true) {
18
+ constructor(evalProvider, extractSkillOnPass = false) {
19
19
  this.evalProvider = evalProvider;
20
20
  this.extractSkillOnPass = extractSkillOnPass;
21
21
  }
22
22
  async judge(ctx) {
23
23
  const kernel = getKernel();
24
- const evalMsgs = kernel.buildEvalMessages(ctx.goal, ctx.criteria, ctx.result, ctx.attempt, this.extractSkillOnPass);
24
+ const evalMsgs = kernel.buildEvalMessages(ctx.goal, ctx.criteria.map(criterion => ({
25
+ text: criterion.text,
26
+ required: criterion.required ?? true,
27
+ weight: criterion.weight,
28
+ })), ctx.result, ctx.attempt, this.extractSkillOnPass);
25
29
  const evalContext = {
26
30
  systemText: evalMsgs.filter((m) => m.role === "system").map((m) => m.content).join("\n\n"),
27
31
  turns: evalMsgs.filter((m) => m.role !== "system"),
@@ -43,7 +47,7 @@ export class LlmEvalJudge {
43
47
  };
44
48
  }
45
49
  }
46
- /** Try `primary`; if it defers (`undefined`), use `fallback`. Models HarnessLoop's
50
+ /** Try `primary`; if it defers (`undefined`), use `fallback`.
47
51
  * "verdictFn short-circuits, else built-in LLM eval" hybrid judgment. */
48
52
  export class HybridJudge {
49
53
  primary;
@@ -1,4 +1,6 @@
1
- export { SinglePassHarness, EvalLoopHarness, HarnessLoop } from "./harness.js";
2
- export type { HarnessRequest, HarnessOutcome, HarnessLoopOptions, QualityGate, CriterionResult, HarnessEvent, VerdictFn, } from "./harness.js";
1
+ export { AttemptLoop, RuntimeAttemptBody, continueSession, freshWithFeedback, freshWithDigest, } from "./harness.js";
2
+ export type { AttemptRequest, AttemptBodyContext, AttemptProgressEvent, AttemptBodyTerminal, AttemptBodyEvent, AttemptBody, PreparedAttempt, CarryPolicy, StopPolicy, AttemptOutcomeKind, AttemptOutcome, AttemptLoopEvent, AttemptLoopOptions, VerdictFn, Criterion, Verdict, } from "./harness.js";
3
+ export { VerdictFnJudge, LlmEvalJudge, HybridJudge } from "./judge.js";
4
+ export type { AttemptJudge, JudgeContext, JudgeResult, SkillCandidate } from "./judge.js";
3
5
  export { judge } from "../runtime/eval.js";
4
- export type { Criterion, Verdict, VerdictDetail, JudgeArgs } from "../runtime/eval.js";
6
+ export type { VerdictDetail, JudgeArgs } from "../runtime/eval.js";
@@ -1,3 +1,4 @@
1
- // `@deepstrike/sdk/harness` — the evaluation framework: single-pass / eval-loop harnesses and the judge.
2
- export { SinglePassHarness, EvalLoopHarness, HarnessLoop } from "./harness.js";
1
+ // `@deepstrike/sdk/harness` — one attempt engine with independent body/judge/carry/stop policies.
2
+ export { AttemptLoop, RuntimeAttemptBody, continueSession, freshWithFeedback, freshWithDigest, } from "./harness.js";
3
+ export { VerdictFnJudge, LlmEvalJudge, HybridJudge } from "./judge.js";
3
4
  export { judge } from "../runtime/eval.js";
package/dist/index.d.ts CHANGED
@@ -3,19 +3,33 @@ export { runLoop, LoopDriver, foldLoopState } from "./runtime/loop-driver.js";
3
3
  export type { LoopSpec, LoopOutcome } from "./runtime/loop-driver.js";
4
4
  export type { RunAgentOptions, RunFanoutOptions } from "./runtime/facade.js";
5
5
  export { RuntimeRunner, collectText } from "./runtime/runner.js";
6
- export type { RuntimeOptions } from "./runtime/runner.js";
6
+ export type { RuntimeOptions, KernelReliabilityOptions, OperationCancellationReason, PromptBudget, SchedulerPolicy } from "./runtime/runner.js";
7
+ export type { SignalPolicy } from "./runtime/os-profile.js";
8
+ export { readKernelDiagnostics, restoreKernelRuntime, snapshotKernelRuntime } from "./runtime/kernel-step.js";
9
+ export type { KernelDiagnostics, KernelSnapshot } from "./runtime/kernel-step.js";
10
+ export { rebuildKernelRuntime } from "./runtime/kernel-rebuild.js";
11
+ export type { KernelRebuildResult } from "./runtime/kernel-rebuild.js";
12
+ export { CONTEXT_POLICY_VERSION, DEFAULT_CONTEXT_POLICY_V1, PPM_SCALE, contextPolicyV1, normalizeContextPolicyV1, ratioToPpm, } from "./runtime/context-policy.js";
13
+ export type { ContextPolicyOverridesV1, ContextPolicyV1, ContextPolicyWireV1, ContextPressureThresholdsV1, } from "./runtime/context-policy.js";
7
14
  export { LocalExecutionPlane } from "./runtime/execution-plane.js";
8
15
  export type { ExecutionPlane, RunContext } from "./runtime/execution-plane.js";
9
16
  export { InMemorySessionLog, FileSessionLog } from "./runtime/session-log.js";
10
- export type { SessionLog, SessionEvent } from "./runtime/session-log.js";
11
- export { InMemoryGroupBudgetStore, SessionLogGroupBudgetStore } from "./runtime/run-group.js";
12
- export type { RunGroup, GroupBudgetStore, GroupLedger, GroupCharge, GroupMember } from "./runtime/run-group.js";
17
+ export type { KernelTransactionEntry, SessionLog, SessionEvent } from "./runtime/session-log.js";
18
+ export { KERNEL_LOG_RECORD_VERSION, KernelLogConflictError, KernelLogIntegrityError, canonicalKernelJson, createKernelOperationGenesis, createKernelTransaction, kernelRecordDigest, verifyKernelOperationGenesis, verifyKernelTransaction, verifyKernelTransactionStream, verifyKernelTransactionSuccessor, } from "./runtime/kernel-transaction-log.js";
19
+ export type { DurableAppendReceipt, KernelGenesisReceipt, KernelOperationCursor, KernelOperationGenesis, KernelOperationGenesisBody, KernelTransaction, KernelTransactionBody, } from "./runtime/kernel-transaction-log.js";
20
+ export { InMemoryGroupBudgetStore, GroupBudgetScope } from "./runtime/run-group.js";
21
+ export type { RunGroup, GroupBudgetStore, GroupLedger, GroupCharge, GroupMember, GroupBudgetRequest, GroupBudgetReservation, } from "./runtime/run-group.js";
13
22
  export { InMemoryEventStream, isVisibleTo } from "./runtime/event-stream.js";
14
- export type { EventStream, BlackboardEvent, EventViewer } from "./runtime/event-stream.js";
23
+ export type { EventStream, EventStreamOptions, BlackboardEvent, EventViewer } from "./runtime/event-stream.js";
24
+ export type { ObserverFailure, ObserverErrorHandler } from "./runtime/reliability.js";
25
+ export { ManagedTaskScope } from "./runtime/reliability.js";
26
+ export type { OperationContext, BackgroundTaskFailure, BackgroundTaskErrorHandler } from "./runtime/reliability.js";
15
27
  export { reactByMention, directorDriven, roundRobin, firstNonEmpty, union } from "./runtime/turn-policy.js";
16
28
  export type { TurnPolicy, PeerView } from "./runtime/turn-policy.js";
17
29
  export { ReactiveSession, readRecentTool } from "./runtime/reactive-session.js";
18
30
  export type { ReactiveSessionOptions, ReactivePeerSpec, EmitEvent, Reaction, ReactorTurn, ReactorContext } from "./runtime/reactive-session.js";
31
+ export { InMemoryReactionCheckpointStore, ReactionInProgressError } from "./runtime/reaction-checkpoint.js";
32
+ export type { ReactionCheckpointClaim, ReactionCheckpointClaimResult, ReactionCheckpointReceipt, ReactionCheckpointStore, ReactionRecord, } from "./runtime/reaction-checkpoint.js";
19
33
  export { tool, streamingTool } from "./tools/index.js";
20
34
  export type { RegisteredTool, ToolExecContext } from "./tools/index.js";
21
35
  export { safeTool, ok, fail, ToolError, formatToolError } from "./tools/errors.js";
@@ -26,10 +40,11 @@ export { OpenAIProvider } from "./providers/openai.js";
26
40
  export type { OpenAIProviderOptions } from "./providers/openai.js";
27
41
  export { OpenAIResponsesProvider } from "./providers/openai-responses.js";
28
42
  export { createProvider } from "./providers/catalog.js";
43
+ export { UnsupportedModalityError } from "./providers/base.js";
29
44
  export type { CreateProviderOptions, EndpointProfileId } from "./providers/catalog.js";
30
45
  export { Governance } from "./governance.js";
31
46
  export type { GovernanceVerdict, GovernancePolicy, GovernanceConstraint } from "./governance.js";
32
47
  export { AgentPool } from "./collaboration/pool.js";
33
- export type { RuntimeSignal, SignalSource } from "./signals/types.js";
48
+ export type { RuntimeSignal, SignalClaim, SignalDeliveryReceipt, SignalSource, } from "./signals/types.js";
34
49
  export type { Message, ToolCall, ToolResult, ToolSchema, ContentPart, TextPart, ImagePart, AudioPart, StreamEvent, TextDelta, ThinkingDelta, ToolCallEvent, ToolChunk, ToolDeltaEvent, ToolSuspendEvent, ToolResultEvent, ToolAuditFailedEvent, DoneEvent, ErrorEvent, PermissionRequestEvent, PermissionResolvedEvent, PermissionResponse, EntropySample, EntropySampleEvent, EntropyAlertEvent, EntropyWatchOptions, LLMProvider, RetryConfig, TokenUsage, } from "./types.js";
35
- export type { WorkflowSpec, WorkflowNodeSpec, } from "./types/agent.js";
50
+ export type { WorkflowSpec, WorkflowNodeSpec, WorkflowDependencyPolicy, WorkflowNodeStatus, WorkflowNodeOutcome, WorkflowOutcome, } from "./types/agent.js";
package/dist/index.js CHANGED
@@ -15,13 +15,19 @@ export { runAgent, runFanout } from "./runtime/facade.js";
15
15
  // ③ dynamic loop agents: self-pacing rounds over the kernel pacing trap.
16
16
  export { runLoop, LoopDriver, foldLoopState } from "./runtime/loop-driver.js";
17
17
  export { RuntimeRunner, collectText } from "./runtime/runner.js";
18
+ export { readKernelDiagnostics, restoreKernelRuntime, snapshotKernelRuntime } from "./runtime/kernel-step.js";
19
+ export { rebuildKernelRuntime } from "./runtime/kernel-rebuild.js";
20
+ export { CONTEXT_POLICY_VERSION, DEFAULT_CONTEXT_POLICY_V1, PPM_SCALE, contextPolicyV1, normalizeContextPolicyV1, ratioToPpm, } from "./runtime/context-policy.js";
18
21
  // ── Execution plane + session log (the defaults) ────────────────────────────
19
22
  export { LocalExecutionPlane } from "./runtime/execution-plane.js";
20
23
  export { InMemorySessionLog, FileSessionLog } from "./runtime/session-log.js";
21
- export { InMemoryGroupBudgetStore, SessionLogGroupBudgetStore } from "./runtime/run-group.js";
24
+ export { KERNEL_LOG_RECORD_VERSION, KernelLogConflictError, KernelLogIntegrityError, canonicalKernelJson, createKernelOperationGenesis, createKernelTransaction, kernelRecordDigest, verifyKernelOperationGenesis, verifyKernelTransaction, verifyKernelTransactionStream, verifyKernelTransactionSuccessor, } from "./runtime/kernel-transaction-log.js";
25
+ export { InMemoryGroupBudgetStore, GroupBudgetScope } from "./runtime/run-group.js";
22
26
  export { InMemoryEventStream, isVisibleTo } from "./runtime/event-stream.js";
27
+ export { ManagedTaskScope } from "./runtime/reliability.js";
23
28
  export { reactByMention, directorDriven, roundRobin, firstNonEmpty, union } from "./runtime/turn-policy.js";
24
29
  export { ReactiveSession, readRecentTool } from "./runtime/reactive-session.js";
30
+ export { InMemoryReactionCheckpointStore, ReactionInProgressError } from "./runtime/reaction-checkpoint.js";
25
31
  // ── Tool authoring ──────────────────────────────────────────────────────────
26
32
  export { tool, streamingTool } from "./tools/index.js";
27
33
  export { safeTool, ok, fail, ToolError, formatToolError } from "./tools/errors.js";
@@ -32,6 +38,7 @@ export { AnthropicProvider } from "./providers/anthropic.js";
32
38
  export { OpenAIProvider } from "./providers/openai.js";
33
39
  export { OpenAIResponsesProvider } from "./providers/openai-responses.js";
34
40
  export { createProvider } from "./providers/catalog.js";
41
+ export { UnsupportedModalityError } from "./providers/base.js";
35
42
  // ── Governance ──────────────────────────────────────────────────────────────
36
43
  export { Governance } from "./governance.js";
37
44
  // ── Multi-agent primitive ───────────────────────────────────────────────────
package/dist/kernel.d.ts CHANGED
@@ -70,10 +70,15 @@ export interface RuntimeSignal {
70
70
  summary: string;
71
71
  payload: string;
72
72
  dedupeKey?: string;
73
+ recipient?: string;
74
+ deadlineMs?: number;
75
+ coalesceKey?: string;
76
+ coalescedCount?: number;
73
77
  timestampMs: number;
74
78
  }
79
+ export type SignalRouterLifecycle = "ready" | "running" | "suspended" | "done";
75
80
  interface SignalRouterInstance {
76
- ingest(signal: RuntimeSignal, isRunning: boolean): string;
81
+ ingest(signal: RuntimeSignal, lifecycle: SignalRouterLifecycle): string;
77
82
  next(): RuntimeSignal | null;
78
83
  }
79
84
  interface NativeCriterion {
@@ -98,45 +103,14 @@ export interface Verdict {
98
103
  content: string;
99
104
  };
100
105
  }
101
- interface IdlePipelineAction {
102
- kind: "synthesize_insights" | "commit_memories" | "noop" | "aborted";
103
- messages?: Message[];
104
- curationResult?: {
105
- toAdd?: Array<{
106
- text: string;
107
- score: number;
108
- metadata: string;
109
- }>;
110
- toRemoveIndices?: number[];
111
- stats?: {
112
- insightsProcessed?: number;
113
- duplicatesRemoved?: number;
114
- conflictsResolved?: number;
115
- entriesAdded?: number;
116
- };
117
- };
118
- runResult?: {
119
- sessionsProcessed: number;
120
- insightsExtracted: number;
121
- };
122
- }
123
- interface IdlePipelineInstance {
124
- feedTrigger(sessions: Array<{
125
- sessionId: string;
126
- agentId: string;
127
- messages: Message[];
128
- metadata: string;
129
- createdAtMs: number;
130
- updatedAtMs: number;
131
- }>, existingMemories: Array<{
132
- text: string;
133
- score: number;
134
- metadata: string;
135
- }>, nowMs: number): IdlePipelineAction;
136
- feedSynthesisResult(content: string): IdlePipelineAction;
137
- }
138
106
  export interface KernelRuntimeInstance {
139
107
  step(inputJson: string): string;
108
+ prepareStep(inputJson: string): string;
109
+ commitPrepared(prepareToken: string): string;
110
+ abortPrepared(prepareToken: string): void;
111
+ snapshot(): string;
112
+ restore(snapshotJson: string): void;
113
+ diagnostics(): string;
140
114
  isTerminal(): boolean;
141
115
  turn(): number;
142
116
  /** L1 (RunGroup): cumulative sub-agent spawns this run, for charging the group ledger at run end. */
@@ -158,7 +132,6 @@ interface KernelModule {
158
132
  buildEvalMessages(goal: string, criteria: NativeCriterion[], result: string, attempt: number, extractSkillOnPass: boolean): Message[];
159
133
  parseVerdict(content: string): Verdict;
160
134
  verdictOutputSchema(extractSkillOnPass: boolean): string;
161
- IdlePipeline: new (agentId: string) => IdlePipelineInstance;
162
135
  }
163
136
  export declare function getKernel(): KernelModule;
164
137
  export {};