@deepstrike/sdk 0.2.39 → 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.
- package/README.md +61 -31
- package/dist/collaboration/contract.d.ts +2 -2
- package/dist/collaboration/contract.js +2 -2
- package/dist/collaboration/handoff.d.ts +2 -14
- package/dist/collaboration/handoff.js +1 -17
- package/dist/collaboration/harness.d.ts +16 -47
- package/dist/collaboration/harness.js +57 -158
- package/dist/collaboration/index.d.ts +2 -2
- package/dist/collaboration/index.js +1 -2
- package/dist/collaboration/modes/creator-verifier.js +42 -6
- package/dist/collaboration/pool.d.ts +8 -0
- package/dist/collaboration/pool.js +56 -3
- package/dist/harness/harness.d.ts +97 -97
- package/dist/harness/harness.js +190 -144
- package/dist/harness/judge.d.ts +3 -2
- package/dist/harness/judge.js +7 -3
- package/dist/harness/public.d.ts +5 -3
- package/dist/harness/public.js +3 -2
- package/dist/index.d.ts +22 -7
- package/dist/index.js +8 -1
- package/dist/kernel.d.ts +12 -39
- package/dist/memory/agent.d.ts +8 -41
- package/dist/memory/agent.js +34 -117
- package/dist/memory/extraction.d.ts +4 -0
- package/dist/memory/extraction.js +79 -0
- package/dist/memory/in-memory-store.d.ts +28 -15
- package/dist/memory/in-memory-store.js +74 -25
- package/dist/memory/protocols.d.ts +56 -56
- package/dist/memory/protocols.js +1 -0
- package/dist/memory/public.d.ts +3 -1
- package/dist/memory/public.js +1 -0
- package/dist/memory/ranking.d.ts +33 -0
- package/dist/memory/ranking.js +77 -0
- package/dist/memory/retention.d.ts +17 -0
- package/dist/memory/retention.js +54 -0
- package/dist/os/public.d.ts +3 -3
- package/dist/os/public.js +1 -1
- package/dist/providers/base.d.ts +8 -0
- package/dist/providers/base.js +0 -0
- package/dist/providers/gemini.js +12 -0
- package/dist/providers/ollama.js +3 -1
- package/dist/providers/openai-responses.js +9 -2
- package/dist/providers/profiles.d.ts +5 -3
- package/dist/providers/profiles.js +3 -3
- package/dist/runtime/context-policy.d.ts +35 -0
- package/dist/runtime/context-policy.js +66 -0
- package/dist/runtime/eval.d.ts +6 -2
- package/dist/runtime/eval.js +2 -2
- package/dist/runtime/event-stream.d.ts +9 -0
- package/dist/runtime/event-stream.js +25 -11
- package/dist/runtime/execution-plane.d.ts +5 -1
- package/dist/runtime/execution-plane.js +9 -3
- package/dist/runtime/facade.js +2 -1
- package/dist/runtime/kernel-event-log.d.ts +0 -2
- package/dist/runtime/kernel-event-log.js +61 -13
- package/dist/runtime/kernel-primitives-dashboard.js +1 -1
- package/dist/runtime/kernel-rebuild.d.ts +13 -0
- package/dist/runtime/kernel-rebuild.js +75 -0
- package/dist/runtime/kernel-step.d.ts +157 -8
- package/dist/runtime/kernel-step.js +220 -7
- package/dist/runtime/kernel-transaction-log.d.ts +61 -0
- package/dist/runtime/kernel-transaction-log.js +149 -0
- package/dist/runtime/large-result-spool.d.ts +3 -1
- package/dist/runtime/large-result-spool.js +24 -5
- package/dist/runtime/loop-driver.d.ts +1 -1
- package/dist/runtime/loop-driver.js +2 -7
- package/dist/runtime/mcp-proxy-plane.d.ts +1 -0
- package/dist/runtime/mcp-proxy-plane.js +23 -6
- package/dist/runtime/os-profile.d.ts +9 -10
- package/dist/runtime/os-profile.js +14 -10
- package/dist/runtime/os-snapshot.d.ts +19 -0
- package/dist/runtime/os-snapshot.js +33 -3
- package/dist/runtime/process-sandbox-plane.js +16 -11
- package/dist/runtime/reaction-checkpoint.d.ts +51 -0
- package/dist/runtime/reaction-checkpoint.js +83 -0
- package/dist/runtime/reactive-session.d.ts +9 -3
- package/dist/runtime/reactive-session.js +44 -14
- package/dist/runtime/reliability.d.ts +48 -0
- package/dist/runtime/reliability.js +86 -0
- package/dist/runtime/remote-vpc-plane.js +4 -3
- package/dist/runtime/run-group.d.ts +38 -35
- package/dist/runtime/run-group.js +97 -54
- package/dist/runtime/runner.d.ts +117 -78
- package/dist/runtime/runner.js +1516 -1197
- package/dist/runtime/session-log.d.ts +71 -12
- package/dist/runtime/session-log.js +192 -32
- package/dist/runtime/session-repair.d.ts +11 -7
- package/dist/runtime/session-repair.js +11 -8
- package/dist/runtime/sub-agent-orchestrator.d.ts +6 -2
- package/dist/runtime/sub-agent-orchestrator.js +45 -18
- package/dist/signals/gateway.d.ts +23 -10
- package/dist/signals/gateway.js +81 -17
- package/dist/signals/scheduled.js +0 -1
- package/dist/signals/types.d.ts +21 -13
- package/dist/skills/loader.js +12 -2
- package/dist/tools/index.d.ts +2 -0
- package/dist/types/agent.d.ts +40 -1
- package/dist/types/agent.js +61 -1
- package/dist/types.d.ts +6 -1
- package/dist/workflow/public.d.ts +2 -3
- package/dist/workflow/public.js +0 -1
- package/package.json +2 -2
package/dist/harness/harness.js
CHANGED
|
@@ -1,166 +1,212 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
101
|
-
let
|
|
102
|
-
let
|
|
103
|
-
let
|
|
104
|
-
let
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
|
133
|
-
|
|
134
|
-
lastIterations = d.iterations;
|
|
135
|
-
lastTotalTokens = d.totalTokens;
|
|
136
|
-
lastStatus = d.status;
|
|
159
|
+
else {
|
|
160
|
+
yield event;
|
|
137
161
|
}
|
|
138
162
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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: "
|
|
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 };
|
package/dist/harness/judge.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { LLMProvider } from "../types.js";
|
|
2
2
|
import { getKernel } from "../kernel.js";
|
|
3
|
-
import type {
|
|
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`.
|
|
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;
|
package/dist/harness/judge.js
CHANGED
|
@@ -15,13 +15,17 @@ export class VerdictFnJudge {
|
|
|
15
15
|
export class LlmEvalJudge {
|
|
16
16
|
evalProvider;
|
|
17
17
|
extractSkillOnPass;
|
|
18
|
-
constructor(evalProvider, extractSkillOnPass =
|
|
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
|
|
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`.
|
|
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;
|
package/dist/harness/public.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type {
|
|
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 {
|
|
6
|
+
export type { VerdictDetail, JudgeArgs } from "../runtime/eval.js";
|
package/dist/harness/public.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
// `@deepstrike/sdk/harness` —
|
|
2
|
-
export {
|
|
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 {
|
|
12
|
-
export type {
|
|
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 {
|
|
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,
|
|
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 {};
|