@deepstrike/wasm 0.2.39 → 0.2.41

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 (48) hide show
  1. package/README.md +14 -13
  2. package/dist/harness/index.d.ts +127 -61
  3. package/dist/harness/index.js +212 -83
  4. package/dist/index.d.ts +13 -6
  5. package/dist/index.js +7 -2
  6. package/dist/memory/extraction.d.ts +4 -0
  7. package/dist/memory/extraction.js +48 -0
  8. package/dist/memory/in-memory-store.d.ts +19 -9
  9. package/dist/memory/in-memory-store.js +68 -23
  10. package/dist/memory/index.d.ts +52 -24
  11. package/dist/memory/ranking.d.ts +32 -0
  12. package/dist/memory/ranking.js +77 -0
  13. package/dist/memory/retention.d.ts +17 -0
  14. package/dist/memory/retention.js +54 -0
  15. package/dist/providers/base.d.ts +5 -0
  16. package/dist/providers/base.js +32 -0
  17. package/dist/runtime/context-policy.d.ts +35 -0
  18. package/dist/runtime/context-policy.js +66 -0
  19. package/dist/runtime/eval.d.ts +2 -0
  20. package/dist/runtime/execution-plane.d.ts +2 -1
  21. package/dist/runtime/execution-plane.js +3 -3
  22. package/dist/runtime/facade.js +2 -1
  23. package/dist/runtime/index.d.ts +13 -4
  24. package/dist/runtime/index.js +6 -1
  25. package/dist/runtime/kernel-event-log.js +46 -13
  26. package/dist/runtime/kernel-rebuild.d.ts +8 -0
  27. package/dist/runtime/kernel-rebuild.js +65 -0
  28. package/dist/runtime/kernel-step.d.ts +139 -7
  29. package/dist/runtime/kernel-step.js +110 -10
  30. package/dist/runtime/kernel-transaction-log.d.ts +61 -0
  31. package/dist/runtime/kernel-transaction-log.js +140 -0
  32. package/dist/runtime/os-profile.d.ts +9 -10
  33. package/dist/runtime/os-profile.js +14 -10
  34. package/dist/runtime/os-snapshot.d.ts +19 -0
  35. package/dist/runtime/os-snapshot.js +16 -3
  36. package/dist/runtime/runner.d.ts +73 -41
  37. package/dist/runtime/runner.js +562 -290
  38. package/dist/runtime/session-log.d.ts +55 -10
  39. package/dist/runtime/session-log.js +60 -3
  40. package/dist/runtime/session-repair.d.ts +11 -7
  41. package/dist/runtime/session-repair.js +11 -8
  42. package/dist/runtime/sub-agent-orchestrator.js +1 -1
  43. package/dist/runtime/types/agent.d.ts +31 -0
  44. package/dist/runtime/types/agent.js +35 -0
  45. package/dist/signals/index.d.ts +21 -1
  46. package/dist/signals/index.js +1 -0
  47. package/dist/types.d.ts +7 -2
  48. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  import type { ToolCall, ToolSchema, StreamEvent, PermissionRequestEvent, PermissionResponse } from "../types.js";
2
2
  import type { RegisteredTool } from "../tools/index.js";
3
- import type { DreamStore } from "../memory/index.js";
3
+ import type { DreamStore, MemoryScope } from "../memory/index.js";
4
4
  import type { KnowledgeSource } from "../knowledge/index.js";
5
5
  import { LargeResultSpool } from "./large-result-spool.js";
6
6
  export interface ToolSuspendEvent {
@@ -12,6 +12,7 @@ export interface ToolSuspendEvent {
12
12
  }
13
13
  export interface RunContext {
14
14
  agentId?: string;
15
+ memoryScope?: MemoryScope;
15
16
  skillContentMap?: Map<string, string>;
16
17
  dreamStore?: DreamStore;
17
18
  knowledgeSource?: KnowledgeSource;
@@ -44,11 +44,11 @@ export class LocalExecutionPlane {
44
44
  for (const c of memoryCalls) {
45
45
  const args = tryParseJson(c.arguments);
46
46
  const topK = typeof args?.top_k === "number" ? args.top_k : 5;
47
- const entries = (ctx.dreamStore && ctx.agentId)
48
- ? await ctx.dreamStore.search(ctx.agentId, String(args?.query ?? ""), topK)
47
+ const entries = (ctx.dreamStore && ctx.agentId && ctx.memoryScope)
48
+ ? await ctx.dreamStore.search(ctx.agentId, { scope: ctx.memoryScope, query: String(args?.query ?? ""), top_k: topK, kinds: [] })
49
49
  : [];
50
50
  const content = entries.length
51
- ? entries.map((e) => `[score=${e.score.toFixed(3)}] ${e.text}`).join("\n---\n")
51
+ ? entries.map(e => `[memory record_id=${e.record.record_id} score=${e.score.toFixed(3)}] ${e.record.content}`).join("\n---\n")
52
52
  : "No relevant memories found.";
53
53
  yield { type: "tool_result", callId: c.id, name: c.name, content, isError: false };
54
54
  }
@@ -39,7 +39,8 @@ export async function runFanout(opts) {
39
39
  spec.nodes[spec.nodes.length - 1].role = opts.synthesisRole;
40
40
  const outcome = await runner.runWorkflow(spec, opts.sessionId ? { sessionId: opts.sessionId } : undefined);
41
41
  const synthesisId = `wf-node${opts.tasks.length}`;
42
- const lastCompleted = outcome.completed[outcome.completed.length - 1];
42
+ const completed = outcome.nodeOutcomes.filter(node => node.status === "completed" || node.status === "completed_partial");
43
+ const lastCompleted = completed[completed.length - 1]?.nodeId;
43
44
  const synthesis = outcome.outputs[synthesisId] ?? (lastCompleted ? outcome.outputs[lastCompleted] : undefined) ?? "";
44
45
  return { synthesis, outputs: outcome.outputs };
45
46
  }
@@ -1,9 +1,16 @@
1
- export type { SessionEvent, SessionLog } from "./session-log.js";
1
+ export type { KernelTransactionEntry, SessionEvent, SessionLog } from "./session-log.js";
2
2
  export { InMemorySessionLog } from "./session-log.js";
3
+ export * from "./kernel-transaction-log.js";
4
+ export { rebuildKernelRuntime } from "./kernel-rebuild.js";
5
+ export type { KernelRebuildResult } from "./kernel-rebuild.js";
6
+ export * from "./context-policy.js";
3
7
  export type { RunContext, ExecutionPlane } from "./execution-plane.js";
4
8
  export { LocalExecutionPlane } from "./execution-plane.js";
5
- export type { MemoryPolicy, MemoryWriteRateLimit, ResourceQuota, RuntimeOptions, SchedulerBudget } from "./runner.js";
9
+ export type { MemoryPolicy, MemoryWriteRateLimit, OperationCancellationReason, PromptBudget, ResourceQuota, RuntimeOptions, SchedulerPolicy } from "./runner.js";
6
10
  export { RuntimeRunner, collectText } from "./runner.js";
11
+ export { readKernelDiagnostics, restoreKernelRuntime, snapshotKernelRuntime } from "./kernel-step.js";
12
+ export type { KernelDiagnostics } from "./kernel-step.js";
13
+ export type { KernelSnapshot } from "./kernel-step.js";
7
14
  export { runAgent, runFanout } from "./facade.js";
8
15
  export type { RunAgentOptions, RunFanoutOptions } from "./facade.js";
9
16
  export { builtinReducers, resolveReducer } from "./reducers.js";
@@ -14,5 +21,7 @@ export type { ReplayProviderOpts } from "./replay-provider.js";
14
21
  export { extractRecordedMessages } from "./replay-fixture.js";
15
22
  export { judge, buildEvalMessages, parseVerdict, verdictOutputSchema } from "./eval.js";
16
23
  export type { Criterion, Verdict, VerdictDetail, JudgeArgs } from "./eval.js";
17
- export { DEFAULT_NATIVE_ATTENTION_POLICY, DEFAULT_NATIVE_GOVERNANCE_POLICY, DEFAULT_SANDBOX_POLICY, assertNativeProfile, osProfile, validateDeclarativePolicy, } from "./os-profile.js";
18
- export type { NativeOsProfile, OsProfileId } from "./os-profile.js";
24
+ export { DEFAULT_NATIVE_SIGNAL_POLICY, DEFAULT_NATIVE_GOVERNANCE_POLICY, DEFAULT_SANDBOX_POLICY, assertNativeProfile, osProfile, validateDeclarativePolicy, } from "./os-profile.js";
25
+ export type { NativeOsProfile, OsProfileId, SignalPolicy } from "./os-profile.js";
26
+ export type { KernelEventCategory, KernelPrimitive } from "./kernel-event-log.js";
27
+ export { primitiveForCategory, primitiveForKind } from "./kernel-event-log.js";
@@ -1,10 +1,15 @@
1
1
  export { InMemorySessionLog } from "./session-log.js";
2
+ export * from "./kernel-transaction-log.js";
3
+ export { rebuildKernelRuntime } from "./kernel-rebuild.js";
4
+ export * from "./context-policy.js";
2
5
  export { LocalExecutionPlane } from "./execution-plane.js";
3
6
  export { RuntimeRunner, collectText } from "./runner.js";
7
+ export { readKernelDiagnostics, restoreKernelRuntime, snapshotKernelRuntime } from "./kernel-step.js";
4
8
  export { runAgent, runFanout } from "./facade.js";
5
9
  export { builtinReducers, resolveReducer } from "./reducers.js";
6
10
  export { getKernel } from "./kernel.js";
7
11
  export { ReplayProvider } from "./replay-provider.js";
8
12
  export { extractRecordedMessages } from "./replay-fixture.js";
9
13
  export { judge, buildEvalMessages, parseVerdict, verdictOutputSchema } from "./eval.js";
10
- export { DEFAULT_NATIVE_ATTENTION_POLICY, DEFAULT_NATIVE_GOVERNANCE_POLICY, DEFAULT_SANDBOX_POLICY, assertNativeProfile, osProfile, validateDeclarativePolicy, } from "./os-profile.js";
14
+ export { DEFAULT_NATIVE_SIGNAL_POLICY, DEFAULT_NATIVE_GOVERNANCE_POLICY, DEFAULT_SANDBOX_POLICY, assertNativeProfile, osProfile, validateDeclarativePolicy, } from "./os-profile.js";
15
+ export { primitiveForCategory, primitiveForKind } from "./kernel-event-log.js";
@@ -16,7 +16,7 @@ export function categoryForKind(kind) {
16
16
  return "mm";
17
17
  case "agent_process_changed":
18
18
  return "proc";
19
- case "signal_disposed":
19
+ case "signal_delivery_disposed":
20
20
  return "ipc";
21
21
  default:
22
22
  return "sched";
@@ -38,7 +38,6 @@ export function kernelObservationToSessionEvent(obs, turn, opts = {}) {
38
38
  action: compressionAction(obs.action),
39
39
  summary: obs.summary,
40
40
  summary_tokens: obs.summary ? Math.max(1, Math.ceil(obs.summary.length / 4)) : undefined,
41
- archive_ref: opts.archiveRef,
42
41
  preserved_refs: opts.preservedRefs ?? [],
43
42
  };
44
43
  }
@@ -130,10 +129,13 @@ export function kernelObservationToSessionEvent(obs, turn, opts = {}) {
130
129
  tool: obs.tool ?? "",
131
130
  reason: typeof obs.reason === "string" ? obs.reason : "",
132
131
  };
133
- case "signal_disposed":
132
+ case "signal_delivery_disposed":
134
133
  return {
135
- kind: "signal_disposed",
134
+ kind: "signal_delivery_disposed",
136
135
  turn: t,
136
+ operation_id: obs.operation_id ?? "",
137
+ delivery_id: obs.delivery_id ?? "",
138
+ attempt: obs.attempt ?? 0,
137
139
  signal_id: obs.signal_id ?? "",
138
140
  disposition: obs.disposition ?? "",
139
141
  queue_depth: obs.queue_depth ?? 0,
@@ -142,8 +144,28 @@ export function kernelObservationToSessionEvent(obs, turn, opts = {}) {
142
144
  return {
143
145
  kind: "budget_exceeded",
144
146
  turn: t,
147
+ operation_id: obs.operation_id ?? "",
148
+ ...(obs.reservation_id ? { reservation_id: obs.reservation_id } : {}),
145
149
  budget: obs.budget ?? "",
146
150
  };
151
+ case "budget_usage_reported":
152
+ return {
153
+ kind: "budget_usage_reported",
154
+ turn: t,
155
+ operation_id: obs.operation_id ?? "",
156
+ reservation_id: obs.reservation_id ?? "",
157
+ tokens: obs.tokens ?? 0,
158
+ subagents: obs.subagents ?? 0,
159
+ rounds: obs.rounds ?? 0,
160
+ };
161
+ case "operation_cancelled":
162
+ return {
163
+ kind: "operation_cancelled",
164
+ turn: t,
165
+ operation_id: obs.operation_id ?? "",
166
+ reason: (obs.reason ?? "user"),
167
+ pending_call_ids: obs.pending_call_ids ?? [],
168
+ };
147
169
  case "suspended":
148
170
  return {
149
171
  kind: "suspended",
@@ -168,21 +190,34 @@ export function kernelObservationToSessionEvent(obs, turn, opts = {}) {
168
190
  tool: obs.tool ?? "",
169
191
  original_size: obs.original_size ?? 0,
170
192
  preview_size: obs.preview_size ?? 0,
171
- spool_ref: opts.spoolRef,
193
+ spool_ref: obs.spool_ref,
194
+ };
195
+ case "page_out_archived":
196
+ return {
197
+ kind: "page_out",
198
+ turn: t,
199
+ action: compressionAction(obs.action),
200
+ summary: obs.summary,
201
+ tier_hint: obs.tier,
202
+ message_count: obs.message_count ?? 0,
203
+ archive_ref: obs.archive_ref,
172
204
  };
173
205
  case "memory_written":
174
206
  return {
175
207
  kind: "memory_written",
176
208
  turn: t,
177
- memory_id: obs.memory_id ?? "",
209
+ record_id: obs.record_id ?? "",
210
+ scope: obs.scope ?? { tenant_id: "", namespace: "" },
178
211
  memory_kind: obs.memory_kind ?? "",
212
+ name: obs.name ?? "",
179
213
  size_bytes: obs.size_bytes ?? 0,
180
214
  };
181
215
  case "memory_queried":
182
216
  return {
183
217
  kind: "memory_queried",
184
218
  turn: t,
185
- query_context: obs.query_context ?? "",
219
+ scope: obs.scope ?? { tenant_id: "", namespace: "" },
220
+ query: obs.query ?? "",
186
221
  requested_k: obs.requested_k ?? 0,
187
222
  requires_async_response: obs.requires_async_response ?? false,
188
223
  };
@@ -190,7 +225,7 @@ export function kernelObservationToSessionEvent(obs, turn, opts = {}) {
190
225
  return {
191
226
  kind: "memory_validation_failed",
192
227
  turn: t,
193
- memory_id: obs.memory_id ?? "",
228
+ record_id: obs.record_id ?? "",
194
229
  error: obs.error ?? "",
195
230
  };
196
231
  case "workflow_batch_spawned": {
@@ -203,14 +238,12 @@ export function kernelObservationToSessionEvent(obs, turn, opts = {}) {
203
238
  };
204
239
  }
205
240
  case "workflow_completed": {
206
- const completed = obs.completed ?? [];
207
- const failed = obs.failed ?? [];
241
+ const nodeOutcomes = obs.node_outcomes ?? [];
208
242
  return {
209
243
  kind: "workflow_completed",
210
244
  turn: t,
211
- completed,
212
- failed,
213
- total_nodes: completed.length + failed.length,
245
+ node_outcomes: nodeOutcomes,
246
+ total_nodes: nodeOutcomes.length,
214
247
  };
215
248
  }
216
249
  default:
@@ -0,0 +1,8 @@
1
+ import type { KernelRuntimeHandle } from "./kernel-step.js";
2
+ import { type KernelOperationCursor, type KernelOperationGenesis, type KernelTransaction } from "./kernel-transaction-log.js";
3
+ export interface KernelRebuildResult {
4
+ runtime: KernelRuntimeHandle;
5
+ cursor: KernelOperationCursor;
6
+ }
7
+ /** Deterministically fold an authoritative stream into a fresh WASM runtime. */
8
+ export declare function rebuildKernelRuntime(runtime: KernelRuntimeHandle, genesis: KernelOperationGenesis, transactions: readonly KernelTransaction[]): Promise<KernelRebuildResult>;
@@ -0,0 +1,65 @@
1
+ import { KernelLogIntegrityError, kernelRecordDigest, verifyKernelTransactionStream, } from "./kernel-transaction-log.js";
2
+ /** Deterministically fold an authoritative stream into a fresh WASM runtime. */
3
+ export async function rebuildKernelRuntime(runtime, genesis, transactions) {
4
+ const cursor = await verifyKernelTransactionStream(genesis, transactions);
5
+ await assertFreshRuntimeMatchesGenesis(runtime, genesis);
6
+ for (const transaction of transactions) {
7
+ const prepared = JSON.parse(runtime.prepareStep(JSON.stringify(transaction.input)));
8
+ const token = prepared.prepare_token;
9
+ try {
10
+ if (prepared.status !== "prepared" || !token) {
11
+ throw new KernelLogIntegrityError(`kernel rebuild step ${transaction.step_seq} was not accepted as a new transition`);
12
+ }
13
+ if (prepared.base_generation !== transaction.base_generation) {
14
+ throw new KernelLogIntegrityError(`kernel rebuild generation diverged at step ${transaction.step_seq}`);
15
+ }
16
+ if (prepared.step.step_seq !== transaction.step_seq) {
17
+ throw new KernelLogIntegrityError(`kernel rebuild step_seq diverged at step ${transaction.step_seq}`);
18
+ }
19
+ if (await kernelRecordDigest(prepared.input) !== transaction.input_digest) {
20
+ throw new KernelLogIntegrityError(`kernel rebuild normalized input diverged at step ${transaction.step_seq}`);
21
+ }
22
+ if (await kernelRecordDigest(prepared.step) !== transaction.step_digest) {
23
+ throw new KernelLogIntegrityError(`kernel rebuild planned step diverged at step ${transaction.step_seq}`);
24
+ }
25
+ const committed = JSON.parse(runtime.commitPrepared(token));
26
+ if (await kernelRecordDigest(committed) !== transaction.step_digest) {
27
+ throw new KernelLogIntegrityError(`kernel rebuild committed step diverged at step ${transaction.step_seq}`);
28
+ }
29
+ }
30
+ catch (error) {
31
+ if (token && prepared.status === "prepared") {
32
+ try {
33
+ runtime.abortPrepared(token);
34
+ }
35
+ catch { /* discard failed runtime */ }
36
+ }
37
+ throw error;
38
+ }
39
+ }
40
+ return { runtime, cursor };
41
+ }
42
+ async function assertFreshRuntimeMatchesGenesis(runtime, genesis) {
43
+ const snapshot = JSON.parse(runtime.snapshot());
44
+ if (snapshot.abi_version !== genesis.abi_version) {
45
+ throw new KernelLogIntegrityError("kernel runtime ABI version does not match operation genesis");
46
+ }
47
+ if (genesis.default_policy_version !== 1) {
48
+ throw new KernelLogIntegrityError("kernel operation uses an unsupported default policy version");
49
+ }
50
+ if (snapshot.operation_id || snapshot.next_step_seq !== 1 || snapshot.accepted_inputs.length !== 0) {
51
+ throw new KernelLogIntegrityError("kernel rebuild requires a fresh runtime");
52
+ }
53
+ if (await kernelRecordDigest(snapshot.initial_policy) !== await kernelRecordDigest(genesis.initial_scheduler_policy)) {
54
+ throw new KernelLogIntegrityError("kernel runtime initial policy does not match operation genesis");
55
+ }
56
+ const defaults = {
57
+ snapshot_version: snapshot.snapshot_version,
58
+ snapshot_input_limit: snapshot.snapshot_input_limit,
59
+ max_input_bytes: snapshot.max_input_bytes,
60
+ snapshot_journal_bytes_limit: snapshot.snapshot_journal_bytes_limit,
61
+ };
62
+ if (await kernelRecordDigest(defaults) !== await kernelRecordDigest(genesis.resolved_runtime_defaults)) {
63
+ throw new KernelLogIntegrityError("kernel runtime defaults do not match operation genesis");
64
+ }
65
+ }
@@ -18,9 +18,15 @@ interface SkillMetadata {
18
18
  * `stable-core ∪ allowedTools`. Absent ⇒ no narrowing (back-compat). */
19
19
  allowedTools?: string[];
20
20
  }
21
- export declare const KERNEL_ABI_VERSION = 1;
21
+ export declare const KERNEL_ABI_VERSION = 2;
22
22
  export interface KernelRuntimeHandle {
23
23
  step(inputJson: string): string;
24
+ prepareStep(inputJson: string): string;
25
+ commitPrepared(prepareToken: string): string;
26
+ abortPrepared(prepareToken: string): void;
27
+ snapshot(): string;
28
+ restore(snapshotJson: string): void;
29
+ diagnostics(): string;
24
30
  isTerminal(): boolean;
25
31
  turn(): number;
26
32
  recoveryContentBytes(): number;
@@ -28,6 +34,52 @@ export interface KernelRuntimeHandle {
28
34
  drainNewMessages(): Message[];
29
35
  preservedRefs(): string[];
30
36
  }
37
+ export type KernelPreparationStatus = "prepared" | "replayed" | "rejected";
38
+ export interface KernelPreparedStep {
39
+ status: KernelPreparationStatus;
40
+ base_generation: number;
41
+ prepare_token?: string;
42
+ input: Record<string, unknown>;
43
+ step: KernelStepJson;
44
+ }
45
+ export interface KernelDiagnostics {
46
+ lifecycle: string;
47
+ next_step_seq: number;
48
+ accepted_input_count: number;
49
+ accepted_input_bytes: number;
50
+ snapshot_input_limit: number;
51
+ snapshot_journal_bytes_limit: number;
52
+ max_input_bytes: number;
53
+ snapshot_overflowed: boolean;
54
+ recorded_event_count: number;
55
+ completed_effect_count: number;
56
+ pending_effect_count: number;
57
+ }
58
+ export declare function readKernelDiagnostics(runtime: KernelRuntimeHandle): KernelDiagnostics;
59
+ export interface KernelSnapshot {
60
+ snapshot_version: 2;
61
+ abi_version: 2;
62
+ initial_policy: {
63
+ max_tokens: number;
64
+ max_turns: number;
65
+ max_total_tokens: string;
66
+ max_wall_ms?: string;
67
+ };
68
+ lifecycle: string;
69
+ operation_id?: string;
70
+ next_step_seq: number;
71
+ snapshot_input_limit: number;
72
+ max_input_bytes: number;
73
+ snapshot_journal_bytes_limit: number;
74
+ accepted_input_bytes: number;
75
+ accepted_inputs: Array<{
76
+ event_id: string;
77
+ [key: string]: unknown;
78
+ }>;
79
+ last_step?: Record<string, unknown>;
80
+ }
81
+ export declare function snapshotKernelRuntime(runtime: KernelRuntimeHandle): KernelSnapshot;
82
+ export declare function restoreKernelRuntime(runtime: KernelRuntimeHandle, snapshot: KernelSnapshot): void;
31
83
  export interface PaceDecision {
32
84
  action: "continue" | "sleep" | "stop";
33
85
  delayMs?: number;
@@ -44,18 +96,66 @@ export interface KernelLoopResult {
44
96
  }
45
97
  export type KernelRunnerAction = {
46
98
  kind: "call_provider";
99
+ effectId: string;
47
100
  context: RenderedContext;
48
101
  tools: ToolSchema[];
49
102
  } | {
50
103
  kind: "execute_tool";
104
+ effectId: string;
51
105
  calls: ToolCall[];
106
+ } | {
107
+ kind: "request_approval";
108
+ effectId: string;
109
+ requests: Array<{
110
+ callId: string;
111
+ tool: string;
112
+ arguments: string;
113
+ reason: string;
114
+ }>;
115
+ } | {
116
+ kind: "spawn_workflow";
117
+ effectId: string;
118
+ nodes: Array<Record<string, unknown>>;
119
+ budget?: Record<string, unknown>;
120
+ } | {
121
+ kind: "preempt_sub_agents";
122
+ effectId: string;
123
+ agentIds: string[];
124
+ reason: string;
125
+ } | {
126
+ kind: "persist_memory";
127
+ effectId: string;
128
+ memory: Record<string, unknown>;
129
+ } | {
130
+ kind: "query_memory";
131
+ effectId: string;
132
+ query: Record<string, unknown>;
133
+ requestedK: number;
134
+ } | {
135
+ kind: "spool_large_result";
136
+ effectId: string;
137
+ callId: string;
138
+ tool: string;
139
+ output: string;
140
+ originalSize: number;
141
+ previewSize: number;
142
+ } | {
143
+ kind: "archive_page_out";
144
+ effectId: string;
145
+ turn: number;
146
+ action: string;
147
+ summary?: string;
148
+ archived: Message[];
149
+ tier: string;
52
150
  } | {
53
151
  kind: "evaluate_milestone";
152
+ effectId: string;
54
153
  phaseId: string;
55
154
  criteria: string[];
56
155
  requiredEvidence?: string[];
57
156
  } | {
58
157
  kind: "done";
158
+ effectId: string;
59
159
  result: KernelLoopResult;
60
160
  };
61
161
  export interface KernelObservation {
@@ -64,7 +164,7 @@ export interface KernelObservation {
64
164
  rho_after?: number;
65
165
  sprint?: number;
66
166
  summary?: string;
67
- archived?: Message[];
167
+ archived_count?: number;
68
168
  turn?: number;
69
169
  checkpoint_history_len?: number;
70
170
  added?: string[];
@@ -88,21 +188,44 @@ export interface KernelObservation {
88
188
  tier_hint?: string;
89
189
  call_id?: string;
90
190
  tool?: string;
191
+ operation_id?: string;
192
+ delivery_id?: string;
193
+ attempt?: number;
91
194
  signal_id?: string;
92
195
  disposition?: string;
93
196
  queue_depth?: number;
94
197
  budget?: string;
198
+ reservation_id?: string;
199
+ tokens?: number;
200
+ subagents?: number;
201
+ rounds?: number;
95
202
  pending_calls?: string[];
203
+ pending_call_ids?: string[];
96
204
  approved?: string[];
97
205
  denied?: string[];
98
206
  original_size?: number;
99
207
  preview_size?: number;
100
- memory_id?: string;
208
+ tier?: string;
209
+ message_count?: number;
210
+ archive_ref?: string;
211
+ spool_ref?: string;
212
+ record_id?: string;
213
+ scope?: {
214
+ tenant_id: string;
215
+ namespace: string;
216
+ };
217
+ name?: string;
101
218
  memory_kind?: string;
102
219
  size_bytes?: number;
103
- query_context?: string;
220
+ query?: string;
104
221
  requested_k?: number;
105
222
  requires_async_response?: boolean;
223
+ recalls?: Array<{
224
+ record_id: string;
225
+ recall_count: number;
226
+ last_recalled_at: number;
227
+ }>;
228
+ recall_count?: number;
106
229
  /** memory_validation_failed (Phase 7). */
107
230
  error?: string;
108
231
  nodes?: Array<{
@@ -113,8 +236,8 @@ export interface KernelObservation {
113
236
  context_inheritance: string;
114
237
  model_hint?: string;
115
238
  }>;
116
- completed?: string[];
117
- failed?: string[];
239
+ node_outcomes?: import("./types/agent.js").KernelWorkflowNodeOutcome[];
240
+ node_index?: number;
118
241
  score?: number;
119
242
  score_version?: number;
120
243
  rho?: number;
@@ -124,6 +247,16 @@ export interface KernelObservation {
124
247
  window_turns?: number;
125
248
  threshold?: number;
126
249
  }
250
+ interface KernelStepJson {
251
+ version: number;
252
+ actions: Array<Record<string, unknown>>;
253
+ observations: KernelObservation[];
254
+ faults?: Array<{
255
+ code?: string;
256
+ message?: string;
257
+ effect_id?: string;
258
+ }>;
259
+ }
127
260
  export declare function toolSchemaToKernel(schema: ToolSchema): Record<string, unknown>;
128
261
  export declare function skillMetadataToKernel(skill: SkillMetadata): Record<string, unknown>;
129
262
  export declare function messageToKernelMessage(message: Message): Record<string, unknown>;
@@ -136,5 +269,4 @@ export declare function kernelApply(runtime: KernelRuntimeHandle, pending: Kerne
136
269
  export declare function kernelAction(runtime: KernelRuntimeHandle, pending: KernelObservation[], event: Record<string, unknown>): KernelRunnerAction;
137
270
  /** Like kernelAction but tolerates zero-action steps (e.g. queued signals). */
138
271
  export declare function kernelMaybeAction(runtime: KernelRuntimeHandle, pending: KernelObservation[], event: Record<string, unknown>): KernelRunnerAction | null;
139
- export declare function forceCompact(runtime: KernelRuntimeHandle, pending: KernelObservation[]): boolean;
140
272
  export {};