@deepstrike/wasm 0.2.36 → 0.2.38
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 +2 -2
- package/dist/index.js +1 -1
- package/dist/runtime/facade.js +11 -7
- package/dist/runtime/kernel-event-log.d.ts +0 -6
- package/dist/runtime/kernel-event-log.js +57 -62
- package/dist/runtime/kernel-step.d.ts +17 -0
- package/dist/runtime/kernel-step.js +12 -0
- package/dist/runtime/os-snapshot.d.ts +0 -1
- package/dist/runtime/os-snapshot.js +0 -19
- package/dist/runtime/runner.d.ts +22 -3
- package/dist/runtime/runner.js +192 -25
- package/dist/runtime/session-log.d.ts +30 -54
- package/dist/runtime/session-repair.d.ts +29 -6
- package/dist/runtime/session-repair.js +37 -8
- package/dist/runtime/sub-agent-orchestrator.d.ts +7 -0
- package/dist/runtime/sub-agent-orchestrator.js +33 -3
- package/dist/runtime/types/agent.d.ts +36 -1
- package/dist/runtime/types/agent.js +54 -1
- package/dist/runtime/workflow-control-flow.d.ts +10 -2
- package/dist/runtime/workflow-control-flow.js +27 -6
- package/dist/types.d.ts +34 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { FilteredExecutionPlane } from "./runtime/filtered-plane.js";
|
|
|
5
5
|
export { SubAgentOrchestrator, defaultSubAgentOrchestrator, spawnStandalone } from "./runtime/sub-agent-orchestrator.js";
|
|
6
6
|
export type { SubAgentRunContext } from "./runtime/sub-agent-orchestrator.js";
|
|
7
7
|
export type { AgentCapabilityFilter, AgentIdentity, AgentIsolation, AgentRunSpec, AgentProcessChangedObservation, ContextInheritance, KernelAgentRole, LoopResult, MilestoneCheckResult, MilestoneContract, MilestonePhase, MilestonePolicy, SubAgentResult, TerminationReason, WorkflowSpec, WorkflowNodeSpec, WorkflowTaskSpec, WorkflowSpawnInfo, } from "./runtime/types/agent.js";
|
|
8
|
-
export { workflowSpecToKernel, workflowNodeSpecToKernel, submitWorkflowNodesToKernel, submitWorkflowToKernel, submitWorkflowNodesTool, startWorkflowTool, fanoutSynthesize, generateAndFilter, verifyRules } from "./runtime/types/agent.js";
|
|
8
|
+
export { workflowSpecToKernel, workflowNodeSpecToKernel, submitWorkflowNodesToKernel, submitWorkflowToKernel, submitWorkflowNodesTool, startWorkflowTool, fanoutSynthesize, generateAndFilter, genEval, verifyRules } from "./runtime/types/agent.js";
|
|
9
9
|
export { loopInstruction, classifyInstruction, judgeGoal, extractLoopContinue, extractClassifyBranch, extractJudgeWinner, } from "./runtime/workflow-control-flow.js";
|
|
10
10
|
export { Governance } from "./governance.js";
|
|
11
11
|
export type { GovernanceVerdict } from "./governance.js";
|
|
@@ -25,4 +25,4 @@ export { ScheduledPrompt } from "./signals/index.js";
|
|
|
25
25
|
export type { RuntimeSignal, SignalSource } from "./signals/index.js";
|
|
26
26
|
export { PermissionManager, PermissionMode } from "./safety/index.js";
|
|
27
27
|
export type { PermissionDecision } from "./safety/index.js";
|
|
28
|
-
export type { Message, ToolCall, ToolResult, ToolSchema, RenderedContext, ProviderRunState, StreamEvent, TextDelta, ThinkingDelta, ToolCallEvent, ToolResultEvent, ToolAuditFailedEvent, DoneEvent, ErrorEvent, PermissionRequestEvent, PermissionResolvedEvent, PermissionResponse, LLMProvider, CacheBreakpointStrategy, } from "./types.js";
|
|
28
|
+
export type { Message, ToolCall, ToolResult, ToolSchema, RenderedContext, ProviderRunState, StreamEvent, TextDelta, ThinkingDelta, ToolCallEvent, ToolResultEvent, ToolAuditFailedEvent, DoneEvent, ErrorEvent, PermissionRequestEvent, PermissionResolvedEvent, PermissionResponse, EntropySample, EntropySampleEvent, EntropyAlertEvent, EntropyWatchOptions, LLMProvider, CacheBreakpointStrategy, } from "./types.js";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { RuntimeRunner, collectText, runAgent, runFanout, InMemorySessionLog, LocalExecutionPlane, DEFAULT_NATIVE_ATTENTION_POLICY, DEFAULT_NATIVE_GOVERNANCE_POLICY, DEFAULT_SANDBOX_POLICY, assertNativeProfile, osProfile, validateDeclarativePolicy, ReplayProvider, extractRecordedMessages, judge, buildEvalMessages, parseVerdict, verdictOutputSchema, } from "./runtime/index.js";
|
|
2
2
|
export { FilteredExecutionPlane } from "./runtime/filtered-plane.js";
|
|
3
3
|
export { SubAgentOrchestrator, defaultSubAgentOrchestrator, spawnStandalone } from "./runtime/sub-agent-orchestrator.js";
|
|
4
|
-
export { workflowSpecToKernel, workflowNodeSpecToKernel, submitWorkflowNodesToKernel, submitWorkflowToKernel, submitWorkflowNodesTool, startWorkflowTool, fanoutSynthesize, generateAndFilter, verifyRules } from "./runtime/types/agent.js";
|
|
4
|
+
export { workflowSpecToKernel, workflowNodeSpecToKernel, submitWorkflowNodesToKernel, submitWorkflowToKernel, submitWorkflowNodesTool, startWorkflowTool, fanoutSynthesize, generateAndFilter, genEval, verifyRules } from "./runtime/types/agent.js";
|
|
5
5
|
export { loopInstruction, classifyInstruction, judgeGoal, extractLoopContinue, extractClassifyBranch, extractJudgeWinner, } from "./runtime/workflow-control-flow.js";
|
|
6
6
|
export { Governance } from "./governance.js";
|
|
7
7
|
export { AnthropicProvider } from "./providers/anthropic.js";
|
package/dist/runtime/facade.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { RuntimeRunner, collectText } from "./runner.js";
|
|
4
4
|
import { LocalExecutionPlane } from "./execution-plane.js";
|
|
5
5
|
import { InMemorySessionLog } from "./session-log.js";
|
|
6
|
+
import { fanoutSynthesize } from "./types/agent.js";
|
|
6
7
|
/** Run a single agent to completion and return its final text. */
|
|
7
8
|
export async function runAgent(opts) {
|
|
8
9
|
const plane = opts.executionPlane ??
|
|
@@ -26,13 +27,16 @@ export async function runFanout(opts) {
|
|
|
26
27
|
maxTokens: opts.maxTokens ?? 32_000,
|
|
27
28
|
...(opts.maxTurns !== undefined ? { maxTurns: opts.maxTurns } : {}),
|
|
28
29
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
// W-N8: build the spec via the ONE fanout template (it pins the pattern's isolation /
|
|
31
|
+
// context-inheritance choices — read-only system-only workers, full-context synthesizer — which
|
|
32
|
+
// this facade used to silently drop), then apply the caller's role overrides on top.
|
|
33
|
+
const spec = fanoutSynthesize(opts.tasks, opts.synthesize);
|
|
34
|
+
if (opts.workerRole) {
|
|
35
|
+
for (const node of spec.nodes.slice(0, opts.tasks.length))
|
|
36
|
+
node.role = opts.workerRole;
|
|
37
|
+
}
|
|
38
|
+
if (opts.synthesisRole)
|
|
39
|
+
spec.nodes[spec.nodes.length - 1].role = opts.synthesisRole;
|
|
36
40
|
const outcome = await runner.runWorkflow(spec, opts.sessionId ? { sessionId: opts.sessionId } : undefined);
|
|
37
41
|
const synthesisId = `wf-node${opts.tasks.length}`;
|
|
38
42
|
const lastCompleted = outcome.completed[outcome.completed.length - 1];
|
|
@@ -3,12 +3,6 @@ import type { SessionEvent } from "./session-log.js";
|
|
|
3
3
|
/** Agent OS kernel event category (Phase 5). */
|
|
4
4
|
export type KernelEventCategory = "syscall" | "sched" | "mm" | "proc" | "ipc";
|
|
5
5
|
export declare function categoryForKind(kind: string): KernelEventCategory;
|
|
6
|
-
export declare function withCategory<T extends {
|
|
7
|
-
kind: string;
|
|
8
|
-
}>(event: T): T & {
|
|
9
|
-
category: KernelEventCategory;
|
|
10
|
-
primitive: KernelPrimitive;
|
|
11
|
-
};
|
|
12
6
|
type CompressionAction = Extract<SessionEvent, {
|
|
13
7
|
kind: "compressed";
|
|
14
8
|
}>["action"];
|
|
@@ -22,33 +22,16 @@ export function categoryForKind(kind) {
|
|
|
22
22
|
return "sched";
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
export function withCategory(event) {
|
|
26
|
-
const category = categoryForKind(event.kind);
|
|
27
|
-
return {
|
|
28
|
-
...event,
|
|
29
|
-
category,
|
|
30
|
-
primitive: primitiveForCategory(category),
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
25
|
export function kernelObservationToSessionEvent(obs, turn, opts = {}) {
|
|
34
26
|
const t = obs.turn ?? turn;
|
|
35
27
|
const compressionAction = opts.compressionAction ?? (() => undefined);
|
|
36
28
|
switch (obs.kind) {
|
|
37
|
-
case "page_out":
|
|
38
|
-
return withCategory({
|
|
39
|
-
kind: "page_out",
|
|
40
|
-
turn: t,
|
|
41
|
-
action: compressionAction(obs.action),
|
|
42
|
-
summary: obs.summary,
|
|
43
|
-
tier_hint: obs.tier_hint ?? "durable",
|
|
44
|
-
message_count: Array.isArray(obs.archived) ? obs.archived.length : 0,
|
|
45
|
-
});
|
|
46
29
|
case "compressed": {
|
|
47
30
|
const latest = opts.latestSeq ?? -1;
|
|
48
31
|
const start = opts.nextArchiveStart ?? 0;
|
|
49
32
|
if (latest < start)
|
|
50
33
|
return null;
|
|
51
|
-
return
|
|
34
|
+
return {
|
|
52
35
|
kind: "compressed",
|
|
53
36
|
turn: t,
|
|
54
37
|
archived_seq_range: [start, latest],
|
|
@@ -57,24 +40,24 @@ export function kernelObservationToSessionEvent(obs, turn, opts = {}) {
|
|
|
57
40
|
summary_tokens: obs.summary ? Math.max(1, Math.ceil(obs.summary.length / 4)) : undefined,
|
|
58
41
|
archive_ref: opts.archiveRef,
|
|
59
42
|
preserved_refs: opts.preservedRefs ?? [],
|
|
60
|
-
}
|
|
43
|
+
};
|
|
61
44
|
}
|
|
62
45
|
case "renewed":
|
|
63
|
-
return
|
|
46
|
+
return {
|
|
64
47
|
kind: "context_renewed",
|
|
65
48
|
turn: t,
|
|
66
49
|
sprint: obs.sprint ?? 0,
|
|
67
50
|
handoff_ref: "",
|
|
68
|
-
}
|
|
51
|
+
};
|
|
69
52
|
case "rollbacked":
|
|
70
|
-
return
|
|
53
|
+
return {
|
|
71
54
|
kind: "rollbacked",
|
|
72
55
|
turn: t,
|
|
73
56
|
checkpoint_history_len: obs.checkpoint_history_len ?? 0,
|
|
74
57
|
reason: obs.reason,
|
|
75
|
-
}
|
|
58
|
+
};
|
|
76
59
|
case "capability_changed":
|
|
77
|
-
return
|
|
60
|
+
return {
|
|
78
61
|
kind: "capability_changed",
|
|
79
62
|
turn: t,
|
|
80
63
|
added: obs.added ?? [],
|
|
@@ -84,36 +67,48 @@ export function kernelObservationToSessionEvent(obs, turn, opts = {}) {
|
|
|
84
67
|
...(obs.version != null && { version: obs.version }),
|
|
85
68
|
...(obs.mounted_by != null && { mounted_by: obs.mounted_by }),
|
|
86
69
|
...(obs.mount_reason != null && { mount_reason: obs.mount_reason }),
|
|
87
|
-
}
|
|
70
|
+
};
|
|
88
71
|
case "milestone_advanced":
|
|
89
|
-
return
|
|
72
|
+
return {
|
|
90
73
|
kind: "milestone_advanced",
|
|
91
74
|
turn: t,
|
|
92
75
|
phase_id: obs.phase_id ?? "",
|
|
93
76
|
capabilities_unlocked: obs.capabilities_unlocked ?? [],
|
|
94
|
-
}
|
|
77
|
+
};
|
|
95
78
|
case "milestone_blocked":
|
|
96
|
-
return
|
|
79
|
+
return {
|
|
97
80
|
kind: "milestone_blocked",
|
|
98
81
|
turn: t,
|
|
99
82
|
phase_id: obs.phase_id ?? "",
|
|
100
83
|
reason: typeof obs.reason === "string" ? obs.reason : "",
|
|
101
|
-
}
|
|
102
|
-
case "milestone_evidence":
|
|
103
|
-
return withCategory({
|
|
104
|
-
kind: "milestone_evidence",
|
|
105
|
-
turn: t,
|
|
106
|
-
phase_id: obs.phase_id ?? "",
|
|
107
|
-
evidence: obs.evidence ?? [],
|
|
108
|
-
});
|
|
84
|
+
};
|
|
109
85
|
case "checkpoint_taken":
|
|
110
|
-
return
|
|
86
|
+
return {
|
|
111
87
|
kind: "checkpoint_taken",
|
|
112
88
|
turn: t,
|
|
113
89
|
history_len: obs.history_len ?? 0,
|
|
114
|
-
}
|
|
90
|
+
};
|
|
91
|
+
case "entropy_sample":
|
|
92
|
+
return {
|
|
93
|
+
kind: "entropy_sample",
|
|
94
|
+
turn: t,
|
|
95
|
+
score: obs.score ?? 0,
|
|
96
|
+
score_version: obs.score_version ?? 0,
|
|
97
|
+
rho: obs.rho ?? 0,
|
|
98
|
+
repeat_pressure: obs.repeat_pressure ?? 0,
|
|
99
|
+
failure_rate: obs.failure_rate ?? 0,
|
|
100
|
+
rollbacks_in_window: obs.rollbacks_in_window ?? 0,
|
|
101
|
+
window_turns: obs.window_turns ?? 0,
|
|
102
|
+
};
|
|
103
|
+
case "entropy_alert":
|
|
104
|
+
return {
|
|
105
|
+
kind: "entropy_alert",
|
|
106
|
+
turn: t,
|
|
107
|
+
score: obs.score ?? 0,
|
|
108
|
+
threshold: obs.threshold ?? 0,
|
|
109
|
+
};
|
|
115
110
|
case "agent_process_changed":
|
|
116
|
-
return
|
|
111
|
+
return {
|
|
117
112
|
kind: "agent_process_changed",
|
|
118
113
|
turn: t,
|
|
119
114
|
agent_id: obs.agent_id ?? "",
|
|
@@ -126,47 +121,47 @@ export function kernelObservationToSessionEvent(obs, turn, opts = {}) {
|
|
|
126
121
|
...(obs.result_termination
|
|
127
122
|
? { result_termination: obs.result_termination }
|
|
128
123
|
: {}),
|
|
129
|
-
}
|
|
124
|
+
};
|
|
130
125
|
case "tool_gated":
|
|
131
|
-
return
|
|
126
|
+
return {
|
|
132
127
|
kind: "tool_gated",
|
|
133
128
|
turn: t,
|
|
134
129
|
call_id: obs.call_id ?? "",
|
|
135
130
|
tool: obs.tool ?? "",
|
|
136
131
|
reason: typeof obs.reason === "string" ? obs.reason : "",
|
|
137
|
-
}
|
|
132
|
+
};
|
|
138
133
|
case "signal_disposed":
|
|
139
|
-
return
|
|
134
|
+
return {
|
|
140
135
|
kind: "signal_disposed",
|
|
141
136
|
turn: t,
|
|
142
137
|
signal_id: obs.signal_id ?? "",
|
|
143
138
|
disposition: obs.disposition ?? "",
|
|
144
139
|
queue_depth: obs.queue_depth ?? 0,
|
|
145
|
-
}
|
|
140
|
+
};
|
|
146
141
|
case "budget_exceeded":
|
|
147
|
-
return
|
|
142
|
+
return {
|
|
148
143
|
kind: "budget_exceeded",
|
|
149
144
|
turn: t,
|
|
150
145
|
budget: obs.budget ?? "",
|
|
151
|
-
}
|
|
146
|
+
};
|
|
152
147
|
case "suspended":
|
|
153
|
-
return
|
|
148
|
+
return {
|
|
154
149
|
kind: "suspended",
|
|
155
150
|
turn: t,
|
|
156
151
|
reason: typeof obs.reason === "string" ? obs.reason : "",
|
|
157
152
|
pending_calls: obs.pending_calls ?? [],
|
|
158
|
-
}
|
|
153
|
+
};
|
|
159
154
|
case "resumed":
|
|
160
|
-
return
|
|
155
|
+
return {
|
|
161
156
|
kind: "resumed",
|
|
162
157
|
turn: t,
|
|
163
158
|
approved: obs.approved ?? [],
|
|
164
159
|
denied: obs.denied ?? [],
|
|
165
|
-
}
|
|
160
|
+
};
|
|
166
161
|
case "page_in_requested":
|
|
167
162
|
return null;
|
|
168
163
|
case "large_result_spooled":
|
|
169
|
-
return
|
|
164
|
+
return {
|
|
170
165
|
kind: "large_result_spooled",
|
|
171
166
|
turn: t,
|
|
172
167
|
call_id: obs.call_id ?? "",
|
|
@@ -174,49 +169,49 @@ export function kernelObservationToSessionEvent(obs, turn, opts = {}) {
|
|
|
174
169
|
original_size: obs.original_size ?? 0,
|
|
175
170
|
preview_size: obs.preview_size ?? 0,
|
|
176
171
|
spool_ref: opts.spoolRef,
|
|
177
|
-
}
|
|
172
|
+
};
|
|
178
173
|
case "memory_written":
|
|
179
|
-
return
|
|
174
|
+
return {
|
|
180
175
|
kind: "memory_written",
|
|
181
176
|
turn: t,
|
|
182
177
|
memory_id: obs.memory_id ?? "",
|
|
183
178
|
memory_kind: obs.memory_kind ?? "",
|
|
184
179
|
size_bytes: obs.size_bytes ?? 0,
|
|
185
|
-
}
|
|
180
|
+
};
|
|
186
181
|
case "memory_queried":
|
|
187
|
-
return
|
|
182
|
+
return {
|
|
188
183
|
kind: "memory_queried",
|
|
189
184
|
turn: t,
|
|
190
185
|
query_context: obs.query_context ?? "",
|
|
191
186
|
requested_k: obs.requested_k ?? 0,
|
|
192
187
|
requires_async_response: obs.requires_async_response ?? false,
|
|
193
|
-
}
|
|
188
|
+
};
|
|
194
189
|
case "memory_validation_failed":
|
|
195
|
-
return
|
|
190
|
+
return {
|
|
196
191
|
kind: "memory_validation_failed",
|
|
197
192
|
turn: t,
|
|
198
193
|
memory_id: obs.memory_id ?? "",
|
|
199
194
|
error: obs.error ?? "",
|
|
200
|
-
}
|
|
195
|
+
};
|
|
201
196
|
case "workflow_batch_spawned": {
|
|
202
197
|
const nodes = obs.nodes ?? [];
|
|
203
|
-
return
|
|
198
|
+
return {
|
|
204
199
|
kind: "workflow_batch_spawned",
|
|
205
200
|
turn: t,
|
|
206
201
|
node_count: nodes.length,
|
|
207
202
|
node_ids: nodes.map((n) => n.agent_id ?? ""),
|
|
208
|
-
}
|
|
203
|
+
};
|
|
209
204
|
}
|
|
210
205
|
case "workflow_completed": {
|
|
211
206
|
const completed = obs.completed ?? [];
|
|
212
207
|
const failed = obs.failed ?? [];
|
|
213
|
-
return
|
|
208
|
+
return {
|
|
214
209
|
kind: "workflow_completed",
|
|
215
210
|
turn: t,
|
|
216
211
|
completed,
|
|
217
212
|
failed,
|
|
218
213
|
total_nodes: completed.length + failed.length,
|
|
219
|
-
}
|
|
214
|
+
};
|
|
220
215
|
}
|
|
221
216
|
default:
|
|
222
217
|
return null;
|
|
@@ -28,10 +28,19 @@ export interface KernelRuntimeHandle {
|
|
|
28
28
|
drainNewMessages(): Message[];
|
|
29
29
|
preservedRefs(): string[];
|
|
30
30
|
}
|
|
31
|
+
export interface PaceDecision {
|
|
32
|
+
action: "continue" | "sleep" | "stop";
|
|
33
|
+
delayMs?: number;
|
|
34
|
+
reason: string;
|
|
35
|
+
/** Set when the kernel trap coerced the model's proposal (clamped delay / forced stop). */
|
|
36
|
+
coercedFrom?: string;
|
|
37
|
+
}
|
|
31
38
|
export interface KernelLoopResult {
|
|
32
39
|
termination: string;
|
|
33
40
|
turnsUsed: number;
|
|
34
41
|
totalTokensUsed: number;
|
|
42
|
+
/** ③ loop-agent: the kernel-adjudicated after-round decision (absent on non-loop runs). */
|
|
43
|
+
paceDecision?: PaceDecision;
|
|
35
44
|
}
|
|
36
45
|
export type KernelRunnerAction = {
|
|
37
46
|
kind: "call_provider";
|
|
@@ -106,6 +115,14 @@ export interface KernelObservation {
|
|
|
106
115
|
}>;
|
|
107
116
|
completed?: string[];
|
|
108
117
|
failed?: string[];
|
|
118
|
+
score?: number;
|
|
119
|
+
score_version?: number;
|
|
120
|
+
rho?: number;
|
|
121
|
+
repeat_pressure?: number;
|
|
122
|
+
failure_rate?: number;
|
|
123
|
+
rollbacks_in_window?: number;
|
|
124
|
+
window_turns?: number;
|
|
125
|
+
threshold?: number;
|
|
109
126
|
}
|
|
110
127
|
export declare function toolSchemaToKernel(schema: ToolSchema): Record<string, unknown>;
|
|
111
128
|
export declare function skillMetadataToKernel(skill: SkillMetadata): Record<string, unknown>;
|
|
@@ -159,12 +159,24 @@ function mapKernelAction(raw) {
|
|
|
159
159
|
};
|
|
160
160
|
case "done": {
|
|
161
161
|
const result = raw.result ?? {};
|
|
162
|
+
const pace = result.pace_decision;
|
|
162
163
|
return {
|
|
163
164
|
kind: "done",
|
|
164
165
|
result: {
|
|
165
166
|
termination: String(result.termination ?? "error"),
|
|
166
167
|
turnsUsed: Number(result.turns_used ?? 0),
|
|
167
168
|
totalTokensUsed: Number(result.total_tokens_used ?? 0),
|
|
169
|
+
// ③ loop-agent: the kernel-adjudicated after-round decision (absent on non-loop runs).
|
|
170
|
+
...(pace
|
|
171
|
+
? {
|
|
172
|
+
paceDecision: {
|
|
173
|
+
action: (pace.action ?? "stop"),
|
|
174
|
+
delayMs: pace.delay_ms,
|
|
175
|
+
reason: pace.reason ?? "",
|
|
176
|
+
coercedFrom: pace.coerced_from,
|
|
177
|
+
},
|
|
178
|
+
}
|
|
179
|
+
: {}),
|
|
168
180
|
},
|
|
169
181
|
};
|
|
170
182
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { categoryForKind, primitiveForKind } from "./kernel-event-log.js";
|
|
2
1
|
const KERNEL_KINDS = new Set([
|
|
3
2
|
"compressed",
|
|
4
3
|
"page_out",
|
|
@@ -16,7 +15,6 @@ const KERNEL_KINDS = new Set([
|
|
|
16
15
|
"agent_process_changed",
|
|
17
16
|
"milestone_advanced",
|
|
18
17
|
"milestone_blocked",
|
|
19
|
-
"milestone_evidence",
|
|
20
18
|
]);
|
|
21
19
|
export function rebuildOsSnapshotFromSessionEvents(events) {
|
|
22
20
|
const snap = {
|
|
@@ -89,20 +87,3 @@ export function rebuildOsSnapshotFromSessionEvents(events) {
|
|
|
89
87
|
}
|
|
90
88
|
return snap;
|
|
91
89
|
}
|
|
92
|
-
export function sessionLogHasRequiredCategories(events) {
|
|
93
|
-
for (const event of events) {
|
|
94
|
-
if (!KERNEL_KINDS.has(event.kind))
|
|
95
|
-
continue;
|
|
96
|
-
const cat = event.category;
|
|
97
|
-
if (!cat)
|
|
98
|
-
return false;
|
|
99
|
-
if (cat !== categoryForKind(event.kind))
|
|
100
|
-
return false;
|
|
101
|
-
const prim = event.primitive;
|
|
102
|
-
if (prim !== undefined) {
|
|
103
|
-
if (prim !== primitiveForKind(event.kind))
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return true;
|
|
108
|
-
}
|
package/dist/runtime/runner.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LLMProvider, Message, StreamEvent, PermissionRequestEvent, PermissionResponse, DreamSummarizer } from "../types.js";
|
|
1
|
+
import type { LLMProvider, Message, StreamEvent, PermissionRequestEvent, PermissionResponse, EntropySample, EntropyWatchOptions, DreamSummarizer } from "../types.js";
|
|
2
2
|
import type { ToolSuspendEvent } from "./execution-plane.js";
|
|
3
3
|
import type { DreamStore, DreamResult } from "../memory/index.js";
|
|
4
4
|
import type { KnowledgeSource } from "../knowledge/index.js";
|
|
@@ -6,6 +6,7 @@ import type { SignalSource, RuntimeSignal } from "../signals/index.js";
|
|
|
6
6
|
import type { SessionLog, SessionEvent } from "./session-log.js";
|
|
7
7
|
import type { ExecutionPlane } from "./execution-plane.js";
|
|
8
8
|
import { type GovernancePolicy } from "../governance.js";
|
|
9
|
+
import { type RecoveredNodeCompletion } from "./session-repair.js";
|
|
9
10
|
import type { AgentRunSpec, SubAgentResult, MilestonePolicy, MilestoneContract, MilestoneCheckResult, WorkflowSpec } from "./types/agent.js";
|
|
10
11
|
import { type SubAgentOrchestrator } from "./sub-agent-orchestrator.js";
|
|
11
12
|
import { type ReducerRegistry } from "./reducers.js";
|
|
@@ -121,6 +122,10 @@ export interface RuntimeOptions {
|
|
|
121
122
|
* warn-once observation + oldest unpinned non-skill entries evicted at the next boundary.
|
|
122
123
|
* Pinned/skill entries are exempt. `0` disables. Default: kernel's 0.25. */
|
|
123
124
|
knowledgeBudgetRatio?: number;
|
|
125
|
+
/** Opt-in kernel entropy watch: threshold alerting over the per-turn session-entropy score
|
|
126
|
+
* (`entropy_sample` events stream unconditionally regardless). See the Node SDK's
|
|
127
|
+
* `entropyWatch` for the canonical documentation. Absent ⇒ disabled (kernel default). */
|
|
128
|
+
entropyWatch?: EntropyWatchOptions;
|
|
124
129
|
/** K3: default lease (in turns) for every skill activation — auto-deactivates after N turns
|
|
125
130
|
* (toolset re-widens, knowledge pin boundary-swept). Absent ⇒ permanent (default). */
|
|
126
131
|
skillLeaseTurns?: number;
|
|
@@ -191,6 +196,8 @@ export declare class RuntimeRunner {
|
|
|
191
196
|
* run — guards against re-pushing a duplicate entry if the model calls `skill(name)` again for
|
|
192
197
|
* an already-active skill (loading is idempotent; the knowledge push should be too). */
|
|
193
198
|
private knowledgePushedSkills;
|
|
199
|
+
/** Most recent kernel entropy sample of the active/last run (see `latestEntropy`). */
|
|
200
|
+
private lastEntropySample;
|
|
194
201
|
/** K4: the active run's goal, kept for the renewal-boundary memory re-query. */
|
|
195
202
|
private currentGoal;
|
|
196
203
|
private nextArchiveStart;
|
|
@@ -207,6 +214,9 @@ export declare class RuntimeRunner {
|
|
|
207
214
|
* the kernel disposition ladder: `"normal"` queues (default), `"high"` soft-interrupts, `"critical"`
|
|
208
215
|
* preempts. */
|
|
209
216
|
injectNote(text: string, urgency?: RuntimeSignal["urgency"]): void;
|
|
217
|
+
/** The most recent kernel session-entropy sample (one per completed turn), or `null` before the
|
|
218
|
+
* first boundary. A pull companion to the streamed `entropy_sample` events. */
|
|
219
|
+
latestEntropy(): EntropySample | null;
|
|
210
220
|
/** Injected-note drain shared with the main loop's per-turn poll: injected notes first (FIFO), then
|
|
211
221
|
* the configured `signalSource` — one code path so the two inbound channels never drift. */
|
|
212
222
|
private nextInboundSignal;
|
|
@@ -281,7 +291,15 @@ export declare class RuntimeRunner {
|
|
|
281
291
|
private bootstrapWorkflowKernel;
|
|
282
292
|
runWorkflow(spec: WorkflowSpec, opts?: {
|
|
283
293
|
resumedCompleted?: string[];
|
|
294
|
+
/** W-1: recovered completions WITH control signals (classify branch / loop stop) — lowered to
|
|
295
|
+
* the kernel's `resumed_results` so control flow replays faithfully. Supersedes
|
|
296
|
+
* `resumedCompleted` for ids present in both. */
|
|
297
|
+
resumedResults?: RecoveredNodeCompletion[];
|
|
284
298
|
resumedSubmissions?: Record<string, unknown>[][];
|
|
299
|
+
/** R3-1: original base index per submission batch (parallel to resumedSubmissions). */
|
|
300
|
+
resumedSubmissionBases?: number[];
|
|
301
|
+
/** W-1: recovered node outputs (agent id → output text) to pre-seed the driver's outputs map. */
|
|
302
|
+
resumedOutputs?: Map<string, string>;
|
|
285
303
|
/** Standalone session id when bootstrapping (no active parent run). Defaults to a fresh uuid. */
|
|
286
304
|
sessionId?: string;
|
|
287
305
|
}): Promise<{
|
|
@@ -325,8 +343,9 @@ export declare class RuntimeRunner {
|
|
|
325
343
|
private driveWorkflow;
|
|
326
344
|
/**
|
|
327
345
|
* Resume a workflow from the parent session's completed nodes.
|
|
328
|
-
* Reads the session log, extracts completed workflow node
|
|
329
|
-
* calls runWorkflow
|
|
346
|
+
* Reads the session log, extracts completed workflow node records (with their W-1 control
|
|
347
|
+
* signals + outputs), and calls runWorkflow so the kernel skips those nodes, replays control
|
|
348
|
+
* flow (classify prune / loop stop), and the driver re-seeds its outputs map.
|
|
330
349
|
*/
|
|
331
350
|
resumeWorkflow(spec: WorkflowSpec, opts?: {
|
|
332
351
|
sessionId?: string;
|