@deepstrike/sdk 0.2.4 → 0.2.6

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 (35) hide show
  1. package/README.md +305 -69
  2. package/dist/collaboration/modes/creator-verifier.d.ts +0 -3
  3. package/dist/collaboration/modes/creator-verifier.js +2 -6
  4. package/dist/governance.d.ts +36 -0
  5. package/dist/governance.js +22 -0
  6. package/dist/index.d.ts +14 -6
  7. package/dist/index.js +5 -1
  8. package/dist/kernel.d.ts +43 -0
  9. package/dist/memory/agent.d.ts +66 -0
  10. package/dist/memory/agent.js +151 -0
  11. package/dist/memory/protocols.d.ts +56 -0
  12. package/dist/runtime/execution-plane.d.ts +6 -9
  13. package/dist/runtime/execution-plane.js +53 -25
  14. package/dist/runtime/kernel-event-log.d.ts +26 -0
  15. package/dist/runtime/kernel-event-log.js +220 -0
  16. package/dist/runtime/kernel-primitives-dashboard.d.ts +44 -0
  17. package/dist/runtime/kernel-primitives-dashboard.js +135 -0
  18. package/dist/runtime/kernel-step.d.ts +25 -1
  19. package/dist/runtime/kernel-step.js +12 -3
  20. package/dist/runtime/large-result-spool.d.ts +84 -0
  21. package/dist/runtime/large-result-spool.js +167 -0
  22. package/dist/runtime/os-profile.d.ts +30 -0
  23. package/dist/runtime/os-profile.js +71 -0
  24. package/dist/runtime/os-snapshot.d.ts +35 -0
  25. package/dist/runtime/os-snapshot.js +128 -0
  26. package/dist/runtime/runner.d.ts +79 -9
  27. package/dist/runtime/runner.js +463 -135
  28. package/dist/runtime/session-log.d.ts +118 -4
  29. package/dist/runtime/session-log.js +15 -4
  30. package/dist/runtime/sub-agent-orchestrator.d.ts +2 -2
  31. package/dist/runtime/sub-agent-orchestrator.js +14 -23
  32. package/dist/types/agent.d.ts +12 -3
  33. package/dist/types/agent.js +18 -0
  34. package/dist/types.d.ts +22 -0
  35. package/package.json +2 -2
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Large result spool (Layer 1 of 5-layer compression pyramid).
3
+ *
4
+ * When a single tool result exceeds 50KB, write the full content to disk
5
+ * and keep only a 2KB preview in the message. Zero API overhead.
6
+ *
7
+ * Design principles:
8
+ * - Kernel defines policy (thresholds)
9
+ * - SDK performs I/O (disk write/read)
10
+ * - Model can retrieve full content via Read tool when needed
11
+ */
12
+ import * as crypto from 'crypto';
13
+ import * as fs from 'fs/promises';
14
+ import * as path from 'path';
15
+ export const DEFAULT_SPOOL_CONFIG = {
16
+ spoolThresholdBytes: 50 * 1024, // 50KB
17
+ previewTokens: 500, // ~2KB
18
+ totalMessageLimitBytes: 200 * 1024, // 200KB
19
+ };
20
+ /**
21
+ * Large result spool manager.
22
+ */
23
+ export class LargeResultSpool {
24
+ config;
25
+ spoolDir;
26
+ activeWrites = new Map();
27
+ constructor(config = {}) {
28
+ this.config = { ...DEFAULT_SPOOL_CONFIG, ...config };
29
+ this.spoolDir = config.spoolDir ?? '.spool';
30
+ }
31
+ /**
32
+ * Check if a tool result needs spooling.
33
+ */
34
+ needsSpool(result) {
35
+ return result.output.length > this.config.spoolThresholdBytes;
36
+ }
37
+ /**
38
+ * Hash content for spool reference.
39
+ */
40
+ hashContent(content) {
41
+ return crypto.createHash('sha256').update(content).digest('hex');
42
+ }
43
+ /**
44
+ * Get spool file path for a hash.
45
+ */
46
+ getSpoolPath(hash) {
47
+ return path.join(this.spoolDir, `${hash}.txt`);
48
+ }
49
+ /**
50
+ * Write large result to disk.
51
+ */
52
+ async writeToDisk(content, hash) {
53
+ const spoolPath = this.getSpoolPath(hash);
54
+ let promise = this.activeWrites.get(spoolPath);
55
+ if (!promise) {
56
+ promise = (async () => {
57
+ try {
58
+ await fs.mkdir(this.spoolDir, { recursive: true });
59
+ await fs.writeFile(spoolPath, content, 'utf-8');
60
+ return spoolPath;
61
+ }
62
+ finally {
63
+ this.activeWrites.delete(spoolPath);
64
+ }
65
+ })();
66
+ this.activeWrites.set(spoolPath, promise);
67
+ }
68
+ return promise;
69
+ }
70
+ /**
71
+ * Generate preview for a tool result.
72
+ */
73
+ generatePreview(content) {
74
+ const previewTokens = Math.min(this.config.previewTokens, content.length / 4);
75
+ const preview = content.substring(0, previewTokens);
76
+ const omitted = content.length - previewTokens;
77
+ return `[tool_result_spooled]
78
+ size: ${content.length} bytes
79
+ preview: first ${previewTokens} chars
80
+ omitted: ${omitted} chars
81
+ [full content available via Read tool]
82
+ `;
83
+ }
84
+ /**
85
+ * Process a tool result: spool if large, return spooled result.
86
+ */
87
+ async processToolResult(result) {
88
+ if (!this.needsSpool(result)) {
89
+ return {
90
+ originalOutput: result.output,
91
+ preview: result.output,
92
+ spoolRef: '',
93
+ wasSpooled: false
94
+ };
95
+ }
96
+ // Hash the content
97
+ const hash = this.hashContent(result.output);
98
+ // Write to disk
99
+ const spoolRef = await this.writeToDisk(result.output, hash);
100
+ // Generate preview
101
+ const preview = this.generatePreview(result.output);
102
+ return {
103
+ originalOutput: result.output,
104
+ preview,
105
+ spoolRef,
106
+ wasSpooled: true
107
+ };
108
+ }
109
+ /**
110
+ * Persist a kernel-spooled tool output to disk. Returns the on-disk path ref.
111
+ */
112
+ async persistOutput(callId, content) {
113
+ const hash = this.hashContent(content);
114
+ const spoolPath = this.getSpoolPath(`${callId}-${hash.slice(0, 16)}`);
115
+ let promise = this.activeWrites.get(spoolPath);
116
+ if (!promise) {
117
+ promise = (async () => {
118
+ try {
119
+ await fs.mkdir(this.spoolDir, { recursive: true });
120
+ await fs.writeFile(spoolPath, content, 'utf-8');
121
+ return spoolPath;
122
+ }
123
+ finally {
124
+ this.activeWrites.delete(spoolPath);
125
+ }
126
+ })();
127
+ this.activeWrites.set(spoolPath, promise);
128
+ }
129
+ return promise;
130
+ }
131
+ /**
132
+ * Read a spooled result back from disk.
133
+ */
134
+ async readSpooledResult(spoolRef) {
135
+ try {
136
+ const content = await fs.readFile(spoolRef, 'utf-8');
137
+ return content;
138
+ }
139
+ catch (error) {
140
+ throw new Error(`Failed to read spooled result: ${error}`);
141
+ }
142
+ }
143
+ /**
144
+ * Clean up old spool files (optional maintenance).
145
+ */
146
+ async cleanup(maxAgeMs) {
147
+ const limit = maxAgeMs ?? this.config.maxAgeMs ?? 7 * 24 * 60 * 60 * 1000;
148
+ try {
149
+ const files = await fs.readdir(this.spoolDir);
150
+ let count = 0;
151
+ const now = Date.now();
152
+ for (const file of files) {
153
+ const filePath = path.join(this.spoolDir, file);
154
+ const stats = await fs.stat(filePath);
155
+ if (now - stats.mtimeMs > limit) {
156
+ await fs.unlink(filePath);
157
+ count++;
158
+ }
159
+ }
160
+ return count;
161
+ }
162
+ catch (error) {
163
+ // Ignore if directory doesn't exist or other file error
164
+ return 0;
165
+ }
166
+ }
167
+ }
@@ -0,0 +1,30 @@
1
+ import type { GovernancePolicy } from "../governance.js";
2
+ export type OsProfileId = "native";
3
+ export interface NativeOsProfile {
4
+ id: OsProfileId;
5
+ attentionPolicy: {
6
+ maxQueueSize?: number;
7
+ };
8
+ governancePolicy: GovernancePolicy;
9
+ }
10
+ /** Default attention policy for native profile smoke tests. */
11
+ export declare const DEFAULT_NATIVE_ATTENTION_POLICY: {
12
+ maxQueueSize: number;
13
+ };
14
+ /** Permissive governance policy for native runs that do not need AskUser. */
15
+ export declare const DEFAULT_NATIVE_GOVERNANCE_POLICY: GovernancePolicy;
16
+ /** Default restrictive sandbox policy template requiring confirmation for modification/execution. */
17
+ export declare const DEFAULT_SANDBOX_POLICY: GovernancePolicy;
18
+ /** Resolve a named OS profile into concrete kernel-owned policy defaults. */
19
+ export declare function osProfile(profile?: OsProfileId | NativeOsProfile): NativeOsProfile;
20
+ /** Assert that a runtime is using a valid native microkernel policy profile. */
21
+ export declare function assertNativeProfile(profile?: OsProfileId | NativeOsProfile): NativeOsProfile;
22
+ /**
23
+ * Validates the declarative policies statically to prevent runtime crashes when loaded into the microkernel.
24
+ */
25
+ export declare function validateDeclarativePolicy(govPolicy?: GovernancePolicy, attentionPolicy?: {
26
+ maxQueueSize?: number;
27
+ }): {
28
+ valid: boolean;
29
+ errors: string[];
30
+ };
@@ -0,0 +1,71 @@
1
+ /** Default attention policy for native profile smoke tests. */
2
+ export const DEFAULT_NATIVE_ATTENTION_POLICY = { maxQueueSize: 64 };
3
+ /** Permissive governance policy for native runs that do not need AskUser. */
4
+ export const DEFAULT_NATIVE_GOVERNANCE_POLICY = {
5
+ rules: [{ pattern: "*", action: "allow" }],
6
+ };
7
+ /** Default restrictive sandbox policy template requiring confirmation for modification/execution. */
8
+ export const DEFAULT_SANDBOX_POLICY = {
9
+ rules: [
10
+ { pattern: "read_file", action: "allow" },
11
+ { pattern: "write_file", action: "ask_user" },
12
+ { pattern: "run_command", action: "ask_user" },
13
+ { pattern: "*", action: "deny" },
14
+ ],
15
+ };
16
+ /** Resolve a named OS profile into concrete kernel-owned policy defaults. */
17
+ export function osProfile(profile = "native") {
18
+ if (typeof profile !== "string")
19
+ return profile;
20
+ if (profile !== "native")
21
+ throw new Error(`Unsupported OS profile: ${profile}`);
22
+ return {
23
+ id: "native",
24
+ attentionPolicy: DEFAULT_NATIVE_ATTENTION_POLICY,
25
+ governancePolicy: DEFAULT_NATIVE_GOVERNANCE_POLICY,
26
+ };
27
+ }
28
+ /** Assert that a runtime is using a valid native microkernel policy profile. */
29
+ export function assertNativeProfile(profile = "native") {
30
+ const resolved = osProfile(profile);
31
+ if (resolved.id !== "native") {
32
+ throw new Error(`Unsupported OS profile: ${resolved.id}`);
33
+ }
34
+ const validation = validateDeclarativePolicy(resolved.governancePolicy, resolved.attentionPolicy);
35
+ if (!validation.valid) {
36
+ throw new Error(`Invalid native OS profile: ${validation.errors.join("; ")}`);
37
+ }
38
+ return resolved;
39
+ }
40
+ /**
41
+ * Validates the declarative policies statically to prevent runtime crashes when loaded into the microkernel.
42
+ */
43
+ export function validateDeclarativePolicy(govPolicy, attentionPolicy) {
44
+ const errors = [];
45
+ if (govPolicy) {
46
+ if (!Array.isArray(govPolicy.rules)) {
47
+ errors.push("GovernancePolicy rules must be an array");
48
+ }
49
+ else {
50
+ govPolicy.rules.forEach((rule, idx) => {
51
+ if (!rule.pattern || typeof rule.pattern !== "string") {
52
+ errors.push(`Rule[${idx}] pattern is missing or not a string`);
53
+ }
54
+ if (!["allow", "deny", "ask_user"].includes(rule.action)) {
55
+ errors.push(`Rule[${idx}] action '${rule.action}' is invalid. Allowed: allow, deny, ask_user`);
56
+ }
57
+ });
58
+ }
59
+ }
60
+ if (attentionPolicy) {
61
+ if (attentionPolicy.maxQueueSize !== undefined) {
62
+ if (typeof attentionPolicy.maxQueueSize !== "number" || attentionPolicy.maxQueueSize <= 0) {
63
+ errors.push("AttentionPolicy maxQueueSize must be a positive integer");
64
+ }
65
+ }
66
+ }
67
+ return {
68
+ valid: errors.length === 0,
69
+ errors,
70
+ };
71
+ }
@@ -0,0 +1,35 @@
1
+ import type { SessionEvent } from "./session-log.js";
2
+ export interface OsSnapshot {
3
+ lastSuspend?: {
4
+ turn: number;
5
+ reason: string;
6
+ pending_calls: string[];
7
+ };
8
+ lastResumedTurn?: number;
9
+ processByAgent: Array<{
10
+ turn: number;
11
+ agent_id: string;
12
+ parent_session_id: string;
13
+ state: string;
14
+ }>;
15
+ budgetExceeded: Array<{
16
+ turn: number;
17
+ budget: string;
18
+ }>;
19
+ signals: Array<{
20
+ turn: number;
21
+ signal_id: string;
22
+ disposition: string;
23
+ queue_depth: number;
24
+ }>;
25
+ pageOutCount: number;
26
+ pageInCount: number;
27
+ spoolCount: number;
28
+ toolGatedCount: number;
29
+ memoryWrittenCount: number;
30
+ memoryQueriedCount: number;
31
+ memoryValidationFailedCount: number;
32
+ memoryRetrievalResultCount: number;
33
+ }
34
+ export declare function rebuildOsSnapshotFromSessionEvents(events: SessionEvent[]): OsSnapshot;
35
+ export declare function sessionLogHasRequiredCategories(events: SessionEvent[]): boolean;
@@ -0,0 +1,128 @@
1
+ import { categoryForKind, primitiveForKind } from "./kernel-event-log.js";
2
+ const KERNEL_KINDS = new Set([
3
+ "compressed",
4
+ "page_out",
5
+ "page_in",
6
+ "large_result_spooled",
7
+ "capability_changed",
8
+ "context_renewed",
9
+ "suspended",
10
+ "resumed",
11
+ "tool_gated",
12
+ "signal_disposed",
13
+ "budget_exceeded",
14
+ "checkpoint_taken",
15
+ "rollbacked",
16
+ "agent_process_changed",
17
+ "milestone_advanced",
18
+ "milestone_blocked",
19
+ "milestone_evidence",
20
+ "memory_written",
21
+ "memory_queried",
22
+ "memory_validation_failed",
23
+ ]);
24
+ export function rebuildOsSnapshotFromSessionEvents(events) {
25
+ const snap = {
26
+ processByAgent: [],
27
+ budgetExceeded: [],
28
+ signals: [],
29
+ pageOutCount: 0,
30
+ pageInCount: 0,
31
+ spoolCount: 0,
32
+ toolGatedCount: 0,
33
+ memoryWrittenCount: 0,
34
+ memoryQueriedCount: 0,
35
+ memoryValidationFailedCount: 0,
36
+ memoryRetrievalResultCount: 0,
37
+ };
38
+ const index = new Map();
39
+ for (const event of events) {
40
+ if (event.kind === "memory_retrieval_result") {
41
+ snap.memoryRetrievalResultCount += 1;
42
+ continue;
43
+ }
44
+ if (!KERNEL_KINDS.has(event.kind) && event.kind !== "suspended" && event.kind !== "resumed") {
45
+ continue;
46
+ }
47
+ switch (event.kind) {
48
+ case "suspended":
49
+ snap.lastSuspend = {
50
+ turn: event.turn,
51
+ reason: event.reason,
52
+ pending_calls: event.pending_calls ?? [],
53
+ };
54
+ break;
55
+ case "resumed":
56
+ snap.lastResumedTurn = event.turn;
57
+ break;
58
+ case "tool_gated":
59
+ snap.toolGatedCount += 1;
60
+ break;
61
+ case "agent_process_changed": {
62
+ const record = {
63
+ turn: event.turn,
64
+ agent_id: event.agent_id,
65
+ parent_session_id: event.parent_session_id,
66
+ state: event.state ?? "running",
67
+ };
68
+ const idx = index.get(event.agent_id);
69
+ if (idx !== undefined)
70
+ snap.processByAgent[idx] = record;
71
+ else {
72
+ index.set(event.agent_id, snap.processByAgent.length);
73
+ snap.processByAgent.push(record);
74
+ }
75
+ break;
76
+ }
77
+ case "budget_exceeded":
78
+ snap.budgetExceeded.push({ turn: event.turn, budget: event.budget });
79
+ break;
80
+ case "signal_disposed":
81
+ snap.signals.push({
82
+ turn: event.turn,
83
+ signal_id: event.signal_id,
84
+ disposition: event.disposition,
85
+ queue_depth: event.queue_depth,
86
+ });
87
+ break;
88
+ case "page_out":
89
+ snap.pageOutCount += 1;
90
+ break;
91
+ case "page_in":
92
+ snap.pageInCount += 1;
93
+ break;
94
+ case "large_result_spooled":
95
+ snap.spoolCount += 1;
96
+ break;
97
+ case "memory_written":
98
+ snap.memoryWrittenCount += 1;
99
+ break;
100
+ case "memory_queried":
101
+ snap.memoryQueriedCount += 1;
102
+ break;
103
+ case "memory_validation_failed":
104
+ snap.memoryValidationFailedCount += 1;
105
+ break;
106
+ default:
107
+ break;
108
+ }
109
+ }
110
+ return snap;
111
+ }
112
+ export function sessionLogHasRequiredCategories(events) {
113
+ for (const event of events) {
114
+ if (!KERNEL_KINDS.has(event.kind))
115
+ continue;
116
+ const cat = event.category;
117
+ if (!cat)
118
+ return false;
119
+ if (cat !== categoryForKind(event.kind))
120
+ return false;
121
+ const prim = event.primitive;
122
+ if (prim !== undefined) {
123
+ if (prim !== primitiveForKind(event.kind))
124
+ return false;
125
+ }
126
+ }
127
+ return true;
128
+ }
@@ -1,12 +1,19 @@
1
- import type { LLMProvider, Message, ToolSchema, StreamEvent, ToolSuspendEvent, AsyncSummarizer } from "../types.js";
2
- import type { DreamStore } from "../memory/protocols.js";
1
+ import type { LLMProvider, Message, ToolSchema, StreamEvent, ToolSuspendEvent, PermissionRequestEvent, PermissionResponse, AsyncSummarizer, DreamSummarizer } from "../types.js";
2
+ import type { DreamStore, MemoryEntry, MemoryQuery, MemoryWriteRequest } from "../memory/protocols.js";
3
3
  import type { KnowledgeSource } from "../knowledge/source.js";
4
4
  import type { SignalSource } from "../signals/types.js";
5
5
  import type { SessionLog, SessionEvent } from "./session-log.js";
6
6
  import type { ArchiveStore } from "./archive.js";
7
7
  import type { ExecutionPlane } from "./execution-plane.js";
8
+ import { type MemoryPolicy, type ResourceQuota } from "../kernel.js";
8
9
  import type { AgentRunSpec, MilestoneCheckResult, MilestoneContract, MilestonePolicy } from "../types/agent.js";
9
10
  import { type SubAgentOrchestrator } from "./sub-agent-orchestrator.js";
11
+ import { type GovernancePolicy } from "../governance.js";
12
+ import { type NativeOsProfile, type OsProfileId } from "./os-profile.js";
13
+ import { LargeResultSpool } from "./large-result-spool.js";
14
+ export interface SchedulerBudget {
15
+ maxWallMs?: number;
16
+ }
10
17
  export interface RuntimeOptions {
11
18
  provider: LLMProvider;
12
19
  sessionLog: SessionLog;
@@ -22,18 +29,51 @@ export interface RuntimeOptions {
22
29
  knowledgeSource?: KnowledgeSource;
23
30
  signalSource?: SignalSource;
24
31
  extensions?: Record<string, unknown>;
25
- governance?: {
26
- setTime?(nowMs: bigint): void;
27
- evaluate(name: string, argsJson: string): {
28
- kind: string;
29
- reason?: string;
30
- retryAfterMs?: number;
31
- };
32
+ /** Named or concrete OS profile. Defaults to the native microkernel profile. */
33
+ osProfile?: OsProfileId | NativeOsProfile;
34
+ /**
35
+ * Declarative governance policy loaded into the kernel (`load_governance_policy`).
36
+ * The kernel enforces deny/veto/rate-limit/param-constraint before tools execute;
37
+ * AskUser calls surface as `tool_gated` and run through `onPermissionRequest`.
38
+ */
39
+ governancePolicy?: GovernancePolicy;
40
+ /**
41
+ * Enable in-kernel signal routing (`set_attention_policy`). When set, inbound
42
+ * signals are dispatched through the kernel attention policy (dedup + disposition
43
+ * + queue) and surface as `signal_disposed` observations, instead of the legacy
44
+ * SDK-side router. `maxQueueSize` defaults to 64.
45
+ */
46
+ attentionPolicy?: {
47
+ maxQueueSize?: number;
32
48
  };
49
+ /**
50
+ * Optional scheduler budget overrides. `maxWallMs` is the wall-clock run budget
51
+ * in milliseconds; when set, the kernel terminates the run when exceeded.
52
+ * Other axes (maxTurns, maxTokens) are set via RuntimeOptions directly.
53
+ */
54
+ schedulerBudget?: SchedulerBudget;
55
+ /**
56
+ * Optional declarative resource quotas (`set_resource_quota`). Bounds spawn concurrency /
57
+ * nesting depth and memory-write rate at the kernel's single syscall trap. When unset, spawn
58
+ * and memory-write syscalls are admitted unconditionally (pre-M2 behavior).
59
+ */
60
+ resourceQuota?: ResourceQuota;
61
+ /**
62
+ * Optional long-term memory policy (`set_memory_policy`). Tunes the kernel's memory subsystem
63
+ * (retrieval top-k, stale-warning age, write validation, memory path). Unset leaves the kernel
64
+ * defaults. Enabling memory still requires `dreamStore` + `agentId`.
65
+ */
66
+ memoryPolicy?: MemoryPolicy;
33
67
  tokenizer?: string;
34
68
  enablePlanTool?: boolean;
69
+ /**
70
+ * Persist full tool outputs when the kernel emits `large_result_spooled`.
71
+ * Defaults to `.spool/` under the process cwd.
72
+ */
73
+ resultSpool?: LargeResultSpool;
35
74
  compressionStore?: ArchiveStore;
36
75
  onToolSuspend?: (event: ToolSuspendEvent) => Promise<unknown> | unknown;
76
+ onPermissionRequest?: (event: PermissionRequestEvent) => Promise<PermissionResponse | boolean> | PermissionResponse | boolean;
37
77
  /** Default: terminate — stop with milestone_pending when a phase needs evaluation. */
38
78
  milestonePolicy?: MilestonePolicy;
39
79
  /** Optional external verifier when milestonePolicy is not auto_pass. */
@@ -59,6 +99,13 @@ export interface RuntimeOptions {
59
99
  };
60
100
  /** Optional system prompt injected into the dream synthesis call. */
61
101
  dreamSystemPrompt?: string;
102
+ /** Custom LLM provider used for background memory consolidation (dream loop). */
103
+ dreamProvider?: LLMProvider;
104
+ /**
105
+ * Optional LLM summarizer for semantic page_out events. When unset, `dreamProvider`
106
+ * (or the runtime provider) is used to produce long-term summaries for DreamStore.
107
+ */
108
+ dreamSummarizer?: DreamSummarizer;
62
109
  /**
63
110
  * Optional async LLM summarizer. When provided, a background call is fired
64
111
  * after each compression event to produce a richer semantic summary.
@@ -66,6 +113,8 @@ export interface RuntimeOptions {
66
113
  * on the next wake() in place of the rule-based summary.
67
114
  */
68
115
  asyncSummarizer?: AsyncSummarizer;
116
+ /** Enable real-time CLI diagnostics dashboard grouped by the three kernel primitives (Syscall, Sched, Mm) */
117
+ enableDiagnosticsDashboard?: boolean;
69
118
  }
70
119
  export declare class RuntimeRunner {
71
120
  private readonly opts;
@@ -74,9 +123,25 @@ export declare class RuntimeRunner {
74
123
  private pendingObservations;
75
124
  private currentSessionId;
76
125
  private nextArchiveStart;
126
+ /** Full tool outputs keyed by call_id until Layer-1 spool observations are logged. */
127
+ private pendingSpoolOutputs;
128
+ /** Local cache of paged-out/archived messages for priority memory retrieval. */
129
+ private localPageOutCache;
130
+ private dashboard;
77
131
  constructor(opts: RuntimeOptions);
78
132
  /** Host configuration (for coordinator / sub-agent spawn). */
79
133
  get hostOptions(): RuntimeOptions;
134
+ writeMemory(memory: MemoryWriteRequest, opts?: {
135
+ sessionId?: string;
136
+ agentId?: string;
137
+ }): Promise<void>;
138
+ queryMemory(query: MemoryQuery, opts?: {
139
+ sessionId?: string;
140
+ agentId?: string;
141
+ }): Promise<MemoryEntry[]>;
142
+ private logMemoryRetrievalResult;
143
+ private createSyscallRuntime;
144
+ private appendMemorySyscallObservations;
80
145
  /** Mount a tool capability on the currently-running kernel runtime. No-op if not running. */
81
146
  mountTool(schema: ToolSchema): void;
82
147
  /** Mount a skill capability on the currently-running kernel runtime. No-op if not running. */
@@ -85,6 +150,8 @@ export declare class RuntimeRunner {
85
150
  mountMarker(kind: string, id: string, description: string): void;
86
151
  /** Unmount a capability by kind + id from the active run. No-op if not running. */
87
152
  unmountCapability(kind: string, id: string): void;
153
+ /** Phase 4: satisfy kernel page-in requests before meta-tool execution. */
154
+ private applyKernelPageIn;
88
155
  /** Push content into the Knowledge slot (memory retrievals, skill definitions, artifacts). */
89
156
  pushKnowledge(message: Message, tokens?: number): void;
90
157
  /**
@@ -106,8 +173,11 @@ export declare class RuntimeRunner {
106
173
  }): AsyncIterable<StreamEvent>;
107
174
  wake(sessionId: string, extensions?: Record<string, unknown>): AsyncIterable<StreamEvent>;
108
175
  dream(agentId: string, nowMs?: number): AsyncIterable<StreamEvent>;
176
+ /** Resolve in-kernel AskUser suspend; returns resume lists and stream events to yield. */
177
+ private resolveKernelSuspend;
109
178
  private execute;
110
179
  private appendObservations;
180
+ private archiveSemanticPageOut;
111
181
  private upgradeCompressedSummary;
112
182
  }
113
183
  export declare function replayMessages(events: Array<{