@deepstrike/sdk 0.2.71 → 0.2.72

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 (77) hide show
  1. package/README.md +27 -3
  2. package/dist/advanced/public.d.ts +4 -0
  3. package/dist/advanced/public.js +2 -0
  4. package/dist/agent-facade.d.ts +19 -6
  5. package/dist/agent-facade.js +118 -20
  6. package/dist/agent-ir.d.ts +11 -5
  7. package/dist/agent-ir.js +42 -26
  8. package/dist/canonical-prefix-allowlist.d.ts +6 -0
  9. package/dist/canonical-prefix-allowlist.js +30 -0
  10. package/dist/evals/public.d.ts +50 -0
  11. package/dist/evals/public.js +25 -0
  12. package/dist/guardrail.d.ts +4 -1
  13. package/dist/handoff-target.d.ts +2 -0
  14. package/dist/handoff-target.js +7 -1
  15. package/dist/index.d.ts +10 -16
  16. package/dist/index.js +5 -7
  17. package/dist/kernel.d.ts +2 -2
  18. package/dist/knowledge/public.d.ts +2 -0
  19. package/dist/knowledge/public.js +1 -1
  20. package/dist/knowledge/source.d.ts +7 -0
  21. package/dist/knowledge/source.js +20 -1
  22. package/dist/memory/protocols.d.ts +2 -2
  23. package/dist/projection-pairs.d.ts +43 -0
  24. package/dist/projection-pairs.js +9 -0
  25. package/dist/providers/anthropic-adapter.d.ts +2 -2
  26. package/dist/providers/anthropic.d.ts +4 -4
  27. package/dist/providers/base.d.ts +5 -5
  28. package/dist/providers/content-normalization.d.ts +4 -4
  29. package/dist/providers/gemini-adapter.d.ts +2 -2
  30. package/dist/providers/gemini.d.ts +3 -3
  31. package/dist/providers/ollama-adapter.d.ts +2 -2
  32. package/dist/providers/ollama.d.ts +2 -2
  33. package/dist/providers/openai-chat.d.ts +4 -4
  34. package/dist/providers/openai-responses-adapter.d.ts +2 -2
  35. package/dist/providers/openai-responses.d.ts +2 -2
  36. package/dist/providers/openai.d.ts +4 -4
  37. package/dist/providers/protocol-adapter.d.ts +2 -2
  38. package/dist/providers/protocol-capabilities.d.ts +1 -0
  39. package/dist/providers/protocol-capabilities.js +3 -0
  40. package/dist/providers/public.d.ts +4 -2
  41. package/dist/providers/public.js +2 -1
  42. package/dist/providers/replay-validator.d.ts +3 -3
  43. package/dist/runtime/archive.d.ts +7 -7
  44. package/dist/runtime/canonical-kernel-step.d.ts +2 -2
  45. package/dist/runtime/context-manager.d.ts +56 -0
  46. package/dist/runtime/context-manager.js +112 -0
  47. package/dist/runtime/eval.d.ts +2 -2
  48. package/dist/runtime/kernel-step.d.ts +5 -5
  49. package/dist/runtime/provider-replay.d.ts +2 -2
  50. package/dist/runtime/public.d.ts +22 -0
  51. package/dist/runtime/public.js +11 -0
  52. package/dist/runtime/replay-fixture.d.ts +3 -3
  53. package/dist/runtime/replay-fixture.js +1 -1
  54. package/dist/runtime/replay-provider.d.ts +4 -4
  55. package/dist/runtime/replay-provider.js +1 -1
  56. package/dist/runtime/runner.d.ts +17 -5
  57. package/dist/runtime/runner.js +110 -37
  58. package/dist/runtime/session-log.d.ts +1 -1
  59. package/dist/runtime/session-repair.d.ts +2 -2
  60. package/dist/runtime/workflow-control-flow.d.ts +1 -1
  61. package/dist/runtime/workflow-control-flow.js +16 -2
  62. package/dist/runtime-classification.d.ts +161 -0
  63. package/dist/runtime-classification.js +66 -0
  64. package/dist/runtime-language.d.ts +32 -0
  65. package/dist/runtime-language.js +51 -0
  66. package/dist/skill.d.ts +31 -5
  67. package/dist/types/agent.d.ts +17 -4
  68. package/dist/types.d.ts +22 -12
  69. package/dist/workflow/definition.d.ts +19 -0
  70. package/dist/workflow/definition.js +29 -0
  71. package/dist/workflow/public.d.ts +3 -1
  72. package/dist/workflow/public.js +1 -0
  73. package/package.json +16 -2
  74. package/dist/compat/anthropic/mcp.d.ts +0 -15
  75. package/dist/compat/anthropic/mcp.js +0 -10
  76. package/dist/compat/openai/agent.d.ts +0 -34
  77. package/dist/compat/openai/agent.js +0 -24
@@ -1,5 +1,5 @@
1
1
  import type { CanonicalKernelInstance, CanonicalRestoreCost } from "../kernel.js";
2
- import type { ProviderMessage } from "../types.js";
2
+ import type { ModelMessage } from "../types.js";
3
3
  import { type InstalledCheckpoint, type KernelJournal } from "./kernel-journal.js";
4
4
  import { type KernelObservation, type KernelRunnerAction } from "./kernel-step.js";
5
5
  export declare const MAX_CHAIN_POSITION = 1000000000000;
@@ -120,7 +120,7 @@ export declare class CanonicalRunnerRuntime {
120
120
  isTerminal(): boolean;
121
121
  recoveryContentBytes(): number;
122
122
  preservedRefs(): string[];
123
- drainNewMessages(): ProviderMessage[];
123
+ drainNewMessages(): ModelMessage[];
124
124
  drainHostObservations(): KernelObservationLike[];
125
125
  terminal(): Record<string, unknown> | undefined;
126
126
  localSubagentsSpawned(): number;
@@ -0,0 +1,56 @@
1
+ export type ContextItemKind = "core" | "task" | "skill" | "memory" | "knowledge" | "workflow";
2
+ export type ContextItemScope = "run" | "session" | "step" | "turn";
3
+ export interface ContextItem {
4
+ id: string;
5
+ kind: ContextItemKind;
6
+ content: string;
7
+ scope: ContextItemScope;
8
+ priority: number;
9
+ tokenCost?: number;
10
+ confidence?: number;
11
+ expiresAt?: number;
12
+ pinned?: boolean;
13
+ source: {
14
+ type: string;
15
+ id?: string;
16
+ };
17
+ }
18
+ export interface ContextManagerOptions {
19
+ maxTokens: number;
20
+ responseReserveTokens?: number;
21
+ now?: () => number;
22
+ onEvent?: (event: ContextLedgerEvent) => void;
23
+ }
24
+ export type ContextLedgerEventKind = "context_added" | "context_removed" | "context_expired" | "context_selected";
25
+ export interface ContextLedgerEvent {
26
+ kind: ContextLedgerEventKind;
27
+ itemId?: string;
28
+ source?: ContextItem["source"];
29
+ fingerprint: string;
30
+ at: number;
31
+ }
32
+ export interface ContextSnapshot {
33
+ items: ContextItem[];
34
+ selected: ContextItem[];
35
+ usedTokens: number;
36
+ availableTokens: number;
37
+ fingerprint: string;
38
+ }
39
+ export declare function estimateContextTokens(content: string): number;
40
+ /** Host-side context budget and lifecycle manager. Kernel context remains the execution authority. */
41
+ export declare class ContextManager {
42
+ private readonly items;
43
+ private readonly now;
44
+ private readonly budget;
45
+ private readonly onEvent?;
46
+ constructor(options: ContextManagerOptions);
47
+ upsert(item: ContextItem): void;
48
+ remove(id: string): void;
49
+ expire(now?: number): string[];
50
+ select(now?: number): ContextItem[];
51
+ snapshot(now?: number): ContextSnapshot;
52
+ fingerprint(now?: number): string;
53
+ private selectWithoutEvents;
54
+ private emit;
55
+ private fingerprintOf;
56
+ }
@@ -0,0 +1,112 @@
1
+ import { createHash } from "node:crypto";
2
+ export function estimateContextTokens(content) {
3
+ return Math.max(1, Math.ceil(content.length / 4));
4
+ }
5
+ /** Host-side context budget and lifecycle manager. Kernel context remains the execution authority. */
6
+ export class ContextManager {
7
+ items = new Map();
8
+ now;
9
+ budget;
10
+ onEvent;
11
+ constructor(options) {
12
+ if (!Number.isSafeInteger(options.maxTokens) || options.maxTokens < 1)
13
+ throw new RangeError("maxTokens must be a safe integer >= 1");
14
+ const reserve = options.responseReserveTokens ?? 0;
15
+ if (!Number.isSafeInteger(reserve) || reserve < 0 || reserve >= options.maxTokens)
16
+ throw new RangeError("responseReserveTokens must be >= 0 and lower than maxTokens");
17
+ this.budget = options.maxTokens - reserve;
18
+ this.now = options.now ?? Date.now;
19
+ this.onEvent = options.onEvent;
20
+ }
21
+ upsert(item) {
22
+ const tokenCost = item.tokenCost ?? estimateContextTokens(item.content);
23
+ if (!Number.isSafeInteger(tokenCost) || tokenCost < 1)
24
+ throw new RangeError(`context item "${item.id}" has invalid tokenCost`);
25
+ this.items.set(item.id, { ...item, tokenCost });
26
+ this.emit({ kind: "context_added", itemId: item.id, source: item.source });
27
+ }
28
+ remove(id) {
29
+ const item = this.items.get(id);
30
+ if (!item)
31
+ return;
32
+ this.items.delete(id);
33
+ this.emit({ kind: "context_removed", itemId: id, source: item.source });
34
+ }
35
+ expire(now = this.now()) {
36
+ const removed = [];
37
+ for (const [id, item] of this.items) {
38
+ if (item.expiresAt !== undefined && item.expiresAt <= now && !item.pinned) {
39
+ this.items.delete(id);
40
+ removed.push(id);
41
+ this.emit({ kind: "context_expired", itemId: id, source: item.source });
42
+ }
43
+ }
44
+ return removed;
45
+ }
46
+ select(now = this.now()) {
47
+ this.expire(now);
48
+ const selected = this.selectWithoutEvents();
49
+ this.emit({ kind: "context_selected" });
50
+ return selected;
51
+ }
52
+ snapshot(now = this.now()) {
53
+ this.expire(now);
54
+ const items = [...this.items.values()];
55
+ const selected = this.select(now);
56
+ const usedTokens = selected.reduce((sum, item) => sum + (item.tokenCost ?? estimateContextTokens(item.content)), 0);
57
+ return {
58
+ items,
59
+ selected,
60
+ usedTokens,
61
+ availableTokens: Math.max(0, this.budget - usedTokens),
62
+ fingerprint: this.fingerprint(now),
63
+ };
64
+ }
65
+ fingerprint(now = this.now()) {
66
+ this.expire(now);
67
+ return this.fingerprintOf(this.selectWithoutEvents());
68
+ }
69
+ selectWithoutEvents() {
70
+ const candidates = [...this.items.values()].sort((left, right) => Number(Boolean(right.pinned)) - Number(Boolean(left.pinned))
71
+ || right.priority - left.priority
72
+ || (right.confidence ?? 0) - (left.confidence ?? 0)
73
+ || left.id.localeCompare(right.id));
74
+ const selected = [];
75
+ let usedTokens = 0;
76
+ for (const item of candidates) {
77
+ const cost = item.tokenCost ?? estimateContextTokens(item.content);
78
+ if (usedTokens + cost > this.budget && !item.pinned)
79
+ continue;
80
+ selected.push(item);
81
+ usedTokens += cost;
82
+ }
83
+ return selected;
84
+ }
85
+ emit(event) {
86
+ try {
87
+ this.onEvent?.({ ...event, fingerprint: this.fingerprintOf(this.selectWithoutEvents()), at: this.now() });
88
+ }
89
+ catch {
90
+ // Ledger observers are diagnostic only; a faulty sink must never reject context admission.
91
+ }
92
+ }
93
+ fingerprintOf(selected) {
94
+ const hash = createHash("sha256");
95
+ for (const item of selected) {
96
+ hash.update(JSON.stringify({
97
+ id: item.id,
98
+ kind: item.kind,
99
+ content: item.content,
100
+ scope: item.scope,
101
+ priority: item.priority,
102
+ tokenCost: item.tokenCost ?? estimateContextTokens(item.content),
103
+ confidence: item.confidence ?? null,
104
+ expiresAt: item.expiresAt ?? null,
105
+ pinned: Boolean(item.pinned),
106
+ source: { type: item.source.type, id: item.source.id ?? null },
107
+ }));
108
+ hash.update("\n");
109
+ }
110
+ return `ctx-${hash.digest("hex")}`;
111
+ }
112
+ }
@@ -9,7 +9,7 @@
9
9
  * The judge is a single LLM call: build the eval prompt → stream → parse verdict. No retry loop,
10
10
  * no skill extraction, no loop state. Use `AttemptLoop` if you want the retry/refine flow.
11
11
  */
12
- import type { LLMProvider, ProviderMessage } from "../types.js";
12
+ import type { LLMProvider, ModelMessage } from "../types.js";
13
13
  export interface Criterion {
14
14
  /** The criterion text the judge evaluates against. */
15
15
  text: string;
@@ -52,7 +52,7 @@ export interface JudgeArgs {
52
52
  * Exposed in case a caller wants to render the prompt without calling the LLM (e.g., dry-run cost
53
53
  * estimation, fixture generation). For the common case, use `judge()`.
54
54
  */
55
- export declare function buildEvalMessages(goal: string, criteria: Criterion[], result: string): ProviderMessage[];
55
+ export declare function buildEvalMessages(goal: string, criteria: Criterion[], result: string): ModelMessage[];
56
56
  /** Parse a Verdict from raw judge-LLM text. Throws on schema mismatch. */
57
57
  export declare function parseVerdict(text: string): Verdict;
58
58
  /** The JSON Schema the kernel expects judge output to conform to. */
@@ -1,4 +1,4 @@
1
- import type { EntropySample, ProviderMessage, RenderedContext, TaskUpdate, ToolCall, ToolExecutionResult, ToolSchema } from "../types.js";
1
+ import type { EntropySample, ModelMessage, RenderedContext, TaskUpdate, ToolCall, ToolExecutionResult, ToolSchema } from "../types.js";
2
2
  import type { SkillMetadata } from "../skills/loader.js";
3
3
  import type { RollbackReason } from "./session-log.js";
4
4
  export declare const CANONICAL_CONTENT_PARTS_PREFIX = "[[deepstrike-content-parts]]";
@@ -15,7 +15,7 @@ export interface KernelLoopResult {
15
15
  termination: string;
16
16
  turnsUsed: number;
17
17
  totalTokensUsed: number;
18
- finalMessage?: ProviderMessage;
18
+ finalMessage?: ModelMessage;
19
19
  /** ③ loop-agent: the kernel-adjudicated after-round decision (absent on non-loop runs). */
20
20
  paceDecision?: PaceDecision;
21
21
  }
@@ -76,7 +76,7 @@ export type KernelRunnerAction = {
76
76
  } | {
77
77
  kind: "archive_page_out";
78
78
  effectId: string;
79
- archived?: ProviderMessage[];
79
+ archived?: ModelMessage[];
80
80
  handleId?: string;
81
81
  payload?: {
82
82
  content: string;
@@ -213,7 +213,7 @@ export declare function archivePresentationFromObservations(observations: readon
213
213
  };
214
214
  export declare function toolSchemaToKernel(schema: ToolSchema): Record<string, unknown>;
215
215
  export declare function skillMetadataToKernel(skill: SkillMetadata): Record<string, unknown>;
216
- export declare function messageToKernelMessage(message: ProviderMessage): Record<string, unknown>;
216
+ export declare function messageToKernelMessage(message: ModelMessage): Record<string, unknown>;
217
217
  export declare function toolResultToKernel(result: ToolExecutionResult): Record<string, unknown>;
218
218
  export declare function taskUpdateToKernel(update: TaskUpdate): Record<string, unknown>;
219
219
  export declare function capabilityTool(schema: ToolSchema): Record<string, unknown>;
@@ -223,5 +223,5 @@ export declare function capabilityCommandMount(capability: Record<string, unknow
223
223
  export declare function capabilityCommandUnmount(capabilityKind: string, id: string): Record<string, unknown>;
224
224
  /** Camel-case an `entropy_sample` kernel observation into the SDK's `EntropySample`. */
225
225
  export declare function entropySampleFromObservation(obs: KernelObservation): EntropySample;
226
- export declare function kernelMessageToSdk(raw: Record<string, unknown>): ProviderMessage;
226
+ export declare function kernelMessageToSdk(raw: Record<string, unknown>): ModelMessage;
227
227
  export declare function renderedContextToSdk(raw: Record<string, unknown>): RenderedContext;
@@ -1,10 +1,10 @@
1
- import type { LLMProvider, ProviderMessage, ProviderDescriptor, ProviderReplay, RenderedContext, ReplayabilityAssessment, ToolCall } from "../types.js";
1
+ import type { LLMProvider, ModelMessage, ProviderDescriptor, ProviderReplay, RenderedContext, ReplayabilityAssessment, ToolCall } from "../types.js";
2
2
  import type { SessionEvent } from "./session-log.js";
3
3
  export declare class ProviderReplayProtocolMismatchError extends Error {
4
4
  readonly code: "provider_replay_protocol_mismatch";
5
5
  constructor(provider: string, storedProtocol: string, resolvedProtocol: string);
6
6
  }
7
- export declare function assistantReplayKey(message: Pick<ProviderMessage, "content" | "toolCalls">): string;
7
+ export declare function assistantReplayKey(message: Pick<ModelMessage, "content" | "toolCalls">): string;
8
8
  /**
9
9
  * A stored replay may only be seeded into a provider speaking the same wire
10
10
  * protocol. On a cross-protocol fallback (provider A -> provider B) the
@@ -0,0 +1,22 @@
1
+ /** Runtime subpath: host execution primitives intentionally outside the root quick-start API. */
2
+ export { RuntimeRunner, collectText } from "./runner.js";
3
+ export { ContextManager, estimateContextTokens } from "./context-manager.js";
4
+ export type { ContextItem, ContextItemKind, ContextItemScope, ContextLedgerEvent, ContextLedgerEventKind, ContextManagerOptions, ContextSnapshot, } from "./context-manager.js";
5
+ export type { RuntimeOptions } from "./runner.js";
6
+ export { runAgent, runFanout } from "./facade.js";
7
+ export type { RunAgentOptions, RunFanoutOptions } from "./facade.js";
8
+ export { InMemorySessionLog, FileSessionLog } from "./session-log.js";
9
+ export type { SessionLog, SessionEvent, SessionEventKind } from "./session-log.js";
10
+ export { projectAgentRun, projectAgentContext, projectAgentCapabilities, projectAgentGovernance, projectAgentDelegation } from "../agent-ir.js";
11
+ export type { AgentDescriptor } from "../agent-ir.js";
12
+ export { FileKernelJournal, InMemoryKernelJournal, JournalCasConflictError, JournalIntegrityError, JournalIoError, } from "./kernel-journal.js";
13
+ export type { CheckpointCandidate, InstalledCheckpoint, JournalAppendReceipt, JournalEntry, JournalHead, JournalPruneReceipt, JournalRecordInput, KernelJournal, } from "./kernel-journal.js";
14
+ export { diagnoseKernelJournal } from "./kernel-doctor.js";
15
+ export type { KernelJournalDiagnosis } from "./kernel-doctor.js";
16
+ export type { ContextPrepared } from "./context.js";
17
+ export { createContextPreparationAdapter, createNativeContextPreparationAdapter } from "./context.js";
18
+ export type { ContextPrepareJson, ContextVerifyJson, ContextProviderPreparationRequest } from "./context.js";
19
+ export { createEvolutionRuntimeAdapter, createNativeEvolutionRuntimeAdapter, EvolutionRuntime } from "./evolution.js";
20
+ export type { EvolutionStore } from "./evolution.js";
21
+ export { FULL_FOOTPRINT_USAGE_ACCOUNTING_POLICY, providerAttemptToRecord } from "./execution-evidence.js";
22
+ export type { InvocationOutcome, ModelInvocation, ProviderAttempt, ProviderAttemptRecord, ProviderAttemptStatus, UsageAccountingPolicy, ModelUsageSettlement } from "./execution-evidence.js";
@@ -0,0 +1,11 @@
1
+ /** Runtime subpath: host execution primitives intentionally outside the root quick-start API. */
2
+ export { RuntimeRunner, collectText } from "./runner.js";
3
+ export { ContextManager, estimateContextTokens } from "./context-manager.js";
4
+ export { runAgent, runFanout } from "./facade.js";
5
+ export { InMemorySessionLog, FileSessionLog } from "./session-log.js";
6
+ export { projectAgentRun, projectAgentContext, projectAgentCapabilities, projectAgentGovernance, projectAgentDelegation } from "../agent-ir.js";
7
+ export { FileKernelJournal, InMemoryKernelJournal, JournalCasConflictError, JournalIntegrityError, JournalIoError, } from "./kernel-journal.js";
8
+ export { diagnoseKernelJournal } from "./kernel-doctor.js";
9
+ export { createContextPreparationAdapter, createNativeContextPreparationAdapter } from "./context.js";
10
+ export { createEvolutionRuntimeAdapter, createNativeEvolutionRuntimeAdapter, EvolutionRuntime } from "./evolution.js";
11
+ export { FULL_FOOTPRINT_USAGE_ACCOUNTING_POLICY, providerAttemptToRecord } from "./execution-evidence.js";
@@ -6,13 +6,13 @@
6
6
  * pulls the assistant turns in order, so the fixture is just "a prior session log + the messages
7
7
  * the LLM produced". No new on-disk format.
8
8
  */
9
- import type { ProviderMessage } from "../types.js";
9
+ import type { ModelMessage } from "../types.js";
10
10
  import type { SessionEvent } from "./session-log.js";
11
11
  /**
12
12
  * Extract the ordered list of assistant Messages from a recorded session log.
13
13
  *
14
14
  * Walks `llm_completed` events (which is what the runner appends for every LLM call) and produces
15
- * one ProviderMessage per event. Pass the result directly to `new ReplayProvider(messages)`.
15
+ * one ModelMessage per event. Pass the result directly to `new ReplayProvider(messages)`.
16
16
  *
17
17
  * Accepts both wire shapes the SDK uses interchangeably:
18
18
  * - in-memory: `{ toolCalls }` (camelCase)
@@ -23,4 +23,4 @@ import type { SessionEvent } from "./session-log.js";
23
23
  */
24
24
  export declare function extractRecordedMessages(events: Array<{
25
25
  event: SessionEvent;
26
- } | SessionEvent>): ProviderMessage[];
26
+ } | SessionEvent>): ModelMessage[];
@@ -10,7 +10,7 @@
10
10
  * Extract the ordered list of assistant Messages from a recorded session log.
11
11
  *
12
12
  * Walks `llm_completed` events (which is what the runner appends for every LLM call) and produces
13
- * one ProviderMessage per event. Pass the result directly to `new ReplayProvider(messages)`.
13
+ * one ModelMessage per event. Pass the result directly to `new ReplayProvider(messages)`.
14
14
  *
15
15
  * Accepts both wire shapes the SDK uses interchangeably:
16
16
  * - in-memory: `{ toolCalls }` (camelCase)
@@ -17,14 +17,14 @@
17
17
  * from the original run). That's the point of replay-for-benchmarking: prompt may differ across
18
18
  * variants, response is pinned, so a cost Δ purely reflects the prompt change.
19
19
  * - `outputTokens` is estimated from `message.content.length / 4`; provider usage belongs to
20
- * the session measurement plane, never to the public ProviderMessage mirror.
20
+ * the session measurement plane, never to the public ModelMessage mirror.
21
21
  * - `cacheReadInputTokens` / `cacheCreationInputTokens` are emitted as 0 — replay has no real
22
22
  * cache state. Mechanisms whose Δ depends on cache behavior must validate with a live A/B too.
23
23
  *
24
24
  * Tokenizer: by default a `chars/4` estimator (±20% for English; worse for code/JSON). For tighter
25
25
  * numbers plug `opts.tokenizer = tiktokenEncoder` or similar.
26
26
  */
27
- import type { LLMProvider, ProviderMessage, ProviderDescriptor, ProviderRunState, RenderedContext, StreamEvent, ToolSchema } from "../types.js";
27
+ import type { LLMProvider, ModelMessage, ProviderDescriptor, ProviderRunState, RenderedContext, StreamEvent, ToolSchema } from "../types.js";
28
28
  export interface ReplayProviderOpts {
29
29
  /**
30
30
  * Maps a rendered-context text payload to a token count. Defaults to `chars / 4`.
@@ -54,7 +54,7 @@ export declare class ReplayProvider implements LLMProvider {
54
54
  * @param messages Ordered list of assistant messages to replay (one per LLM call).
55
55
  * @param opts Optional tokenizer / descriptor / wrap-around behavior.
56
56
  */
57
- constructor(messages: ReadonlyArray<ProviderMessage>, opts?: ReplayProviderOpts);
57
+ constructor(messages: ReadonlyArray<ModelMessage>, opts?: ReplayProviderOpts);
58
58
  descriptor(): ProviderDescriptor;
59
59
  /** Number of messages consumed so far. */
60
60
  consumed(): number;
@@ -62,7 +62,7 @@ export declare class ReplayProvider implements LLMProvider {
62
62
  remaining(): number;
63
63
  /** Reset the cursor — useful for re-running the same fixture in a fresh session. */
64
64
  reset(): void;
65
- complete(_context: RenderedContext, _tools: ToolSchema[]): Promise<ProviderMessage>;
65
+ complete(_context: RenderedContext, _tools: ToolSchema[]): Promise<ModelMessage>;
66
66
  stream(context: RenderedContext, tools: ToolSchema[], _extensions?: Record<string, unknown>, _state?: ProviderRunState, _signal?: AbortSignal): AsyncIterable<StreamEvent>;
67
67
  private pull;
68
68
  private estimateInputTokens;
@@ -17,7 +17,7 @@
17
17
  * from the original run). That's the point of replay-for-benchmarking: prompt may differ across
18
18
  * variants, response is pinned, so a cost Δ purely reflects the prompt change.
19
19
  * - `outputTokens` is estimated from `message.content.length / 4`; provider usage belongs to
20
- * the session measurement plane, never to the public ProviderMessage mirror.
20
+ * the session measurement plane, never to the public ModelMessage mirror.
21
21
  * - `cacheReadInputTokens` / `cacheCreationInputTokens` are emitted as 0 — replay has no real
22
22
  * cache state. Mechanisms whose Δ depends on cache behavior must validate with a live A/B too.
23
23
  *
@@ -1,6 +1,8 @@
1
- import type { LLMProvider, ProviderMessage, ContentPart, ToolSchema, StreamEvent, ToolSuspendEvent, PermissionRequestEvent, PermissionResponse, AsyncSummarizer, MemorySummarizer, EntropySample, EntropyWatchOptions } from "../types.js";
1
+ import type { LLMProvider, ModelMessage, ContentPart, ToolSchema, StreamEvent, ToolSuspendEvent, PermissionRequestEvent, PermissionResponse, AsyncSummarizer, MemorySummarizer, EntropySample, EntropyWatchOptions } from "../types.js";
2
2
  import type { MemoryStore, MemoryRecord, MemoryRecall, MemoryScope, MemoryQuery } from "../memory/protocols.js";
3
3
  import type { KnowledgeSource } from "../knowledge/source.js";
4
+ import type { Skill } from "../skill.js";
5
+ import type { ContextManager } from "./context-manager.js";
4
6
  import type { RuntimeSignalUrgency, SignalSource } from "../signals/types.js";
5
7
  import type { SessionLog, SessionEvent } from "./session-log.js";
6
8
  import type { KernelJournal } from "./kernel-journal.js";
@@ -9,6 +11,7 @@ import type { ExecutionPlane } from "./execution-plane.js";
9
11
  import type { RunGroup } from "./run-group.js";
10
12
  import { type MemoryPolicy, type ResourceQuota } from "../kernel.js";
11
13
  import type { AgentRunSpec, MilestoneCheckResult, MilestoneContract, MilestonePolicy, WorkflowSpec, WorkflowOutcome } from "../types/agent.js";
14
+ import type { AgentCapabilityFilter } from "../types/agent.js";
12
15
  export declare function stableSemanticArchiveName(effectId: string): string;
13
16
  import { type SubAgentOrchestrator } from "./sub-agent-orchestrator.js";
14
17
  import { type ReducerRegistry } from "./reducers.js";
@@ -95,6 +98,8 @@ export interface KernelReliabilityOptions {
95
98
  export type OperationCancellationReason = "user" | "deadline" | "lease_lost" | "host_shutdown";
96
99
  export interface RuntimeOptions {
97
100
  provider: LLMProvider;
101
+ /** Host-owned capability ceiling applied to the root run before skills or run profiles narrow it further. */
102
+ capabilityFilter?: AgentCapabilityFilter;
98
103
  /** Host-owned artifact set identity captured in operation genesis. */
99
104
  artifactSetDigest?: string;
100
105
  /** M4/G5: cumulative token cap for this run (the kernel's `max_total_tokens`). A workflow node's
@@ -150,7 +155,11 @@ export interface RuntimeOptions {
150
155
  * behavior difference. */
151
156
  nudges?: NudgeRule[];
152
157
  initialMemory?: string[];
158
+ /** Optional host ledger that admits dynamic context before kernel insertion. */
159
+ contextManager?: ContextManager;
153
160
  skillDir?: string;
161
+ /** Inline skill catalog. Metadata is exposed at run start; content is loaded only on activation. */
162
+ skillCatalog?: Skill[];
154
163
  /** Host-layer allowlist over the `skillDir` catalog by skill NAME. When set, only scanned skills
155
164
  * whose name is listed are fed to the kernel via `set_available_skills` (the manifest layer
156
165
  * intersects onto this host baseline in `applyManifest`). Absent ⇒ zero behavior difference (all
@@ -398,6 +407,8 @@ export declare class RuntimeRunner {
398
407
  * run — guards against re-pushing a duplicate entry if the model calls `skill(name)` again for
399
408
  * an already-active skill (loading is idempotent; the knowledge push should be too). */
400
409
  private knowledgePushedSkills;
410
+ /** Host mirror of kernel skill lease expiry, used only to clear ContextManager overlays. */
411
+ private skillLeaseExpirations;
401
412
  private nextArchiveStart;
402
413
  private pendingPageOutArchives;
403
414
  private activePageOutArchive;
@@ -488,7 +499,7 @@ export declare class RuntimeRunner {
488
499
  * K1: `opts.key` gives the entry identity — a same-key push upserts (applied at the next
489
500
  * compaction/renewal boundary, where the cached system[1] block is rewritten anyway) instead
490
501
  * of appending a duplicate. `opts.pinned` exempts the entry from the knowledge-budget sweep. */
491
- pushKnowledge(message: ProviderMessage, tokens?: number, opts?: {
502
+ pushKnowledge(message: ModelMessage, tokens?: number, opts?: {
492
503
  key?: string;
493
504
  pinned?: boolean;
494
505
  }): Promise<void>;
@@ -500,6 +511,7 @@ export declare class RuntimeRunner {
500
511
  * drops at the next compaction/renewal boundary. A later `skill(name)` call re-activates and
501
512
  * re-pins fresh content. Errs-open: not-active is a kernel-side no-op. */
502
513
  deactivateSkill(name: string): Promise<void>;
514
+ private expireSkillContext;
503
515
  /**
504
516
  * G3: run one workflow node, enforcing its `output_schema` (if any). Without a schema this is a
505
517
  * plain `orchestrator.run`. With one, the node's agent is instructed to emit conforming JSON, its
@@ -603,14 +615,14 @@ export declare class RuntimeRunner {
603
615
  * message exists. A tail assistant tool_call with nothing after it is a genuinely PENDING tool the
604
616
  * run stopped in front of (the wake/recovery case), which must stay unpaired so wake executes it.
605
617
  * Pure. */
606
- export declare function pairOrphanToolCalls(messages: ProviderMessage[]): ProviderMessage[];
618
+ export declare function pairOrphanToolCalls(messages: ModelMessage[]): ModelMessage[];
607
619
  export declare function replayMessages(events: Array<{
608
620
  seq: number;
609
621
  event: SessionEvent;
610
- }>, maxBytes?: number): ProviderMessage[];
622
+ }>, maxBytes?: number): ModelMessage[];
611
623
  export declare function replayMessagesAsync(events: Array<{
612
624
  seq: number;
613
625
  event: SessionEvent;
614
- }>, maxBytes?: number, loadArchive?: (archiveRef: string) => Promise<ProviderMessage[]>): Promise<ProviderMessage[]>;
626
+ }>, maxBytes?: number, loadArchive?: (archiveRef: string) => Promise<ModelMessage[]>): Promise<ModelMessage[]>;
615
627
  /** Collect all text_delta events from a run into a single string. */
616
628
  export declare function collectText(stream: AsyncIterable<StreamEvent>): Promise<string>;