@noetic-tools/types 2.2.0 → 3.0.0

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.
@@ -2,13 +2,13 @@ import type { ZodType } from 'zod';
2
2
  import type { ItemSchemaRegistry } from '../schemas/item.js';
3
3
  import type { Channel, ChannelHandle, ExternalChannel } from './channel.js';
4
4
  import type { LLMResponse, ModelParams, StepMeta, TokenUsage } from './common.js';
5
+ import type { ContextData, ContextLayer, ProjectionPolicy, StorageAdapter } from './context-layer.js';
5
6
  import type { ItemLog } from './context-parts/item-log.js';
6
7
  import type { LastLayerUsage } from './context-parts/layer-usage.js';
7
8
  import type { DetachedHandle } from './detached.js';
8
9
  import type { FsAdapter } from './fs-adapter.js';
9
10
  import type { HarnessResponse, StreamEvent, StreamingItem } from './harness-result.js';
10
11
  import type { ExecuteInput } from './items.js';
11
- import type { ContextMemory, MemoryLayer, ProjectionPolicy, StorageAdapter } from './memory.js';
12
12
  import type { Span, TraceExporter } from './observability.js';
13
13
  import type { ShellAdapter } from './shell-adapter.js';
14
14
  import type { SteeringDecision } from './steering.js';
@@ -47,7 +47,7 @@ interface ContextCallModelRequestBase {
47
47
  interface ContextCallModelRequestWithTools extends ContextCallModelRequestBase {
48
48
  tools: Tool[];
49
49
  ctx: Context;
50
- layers?: MemoryLayer[];
50
+ layers?: ContextLayer[];
51
51
  allowedToolNames?: string[];
52
52
  }
53
53
  interface ContextCallModelRequestWithoutTools extends ContextCallModelRequestBase {
@@ -84,8 +84,10 @@ export interface RestoreContextOptions {
84
84
  parent?: Context;
85
85
  /** Opaque per-execution state, same as `createContext({ state })`. */
86
86
  state?: unknown;
87
- /** Memory layers for the restored context. Defaults to the harness's configured layers. */
88
- memory?: MemoryLayer[];
87
+ /** Context layers for the restored context. Defaults to the harness's configured layers. */
88
+ context?: ContextLayer[];
89
+ /** @deprecated Renamed to `context`. */
90
+ memory?: ContextLayer[];
89
91
  }
90
92
  export interface ContextRerenderRequest {
91
93
  layerId: string;
@@ -102,10 +104,10 @@ export interface ContextRecallLayerOutput {
102
104
  items: import('./items.js').Item[];
103
105
  tokenCount: number;
104
106
  }
105
- export type ContextStep<TMemory = ContextMemory, I = unknown, O = unknown> = {
107
+ export type ContextStep<TContext = ContextData, I = unknown, O = unknown> = {
106
108
  readonly kind: 'run';
107
109
  readonly id: string;
108
- readonly execute: (input: I, ctx: Context<TMemory>) => Promise<O>;
110
+ readonly execute: (input: I, ctx: Context<TContext>) => Promise<O>;
109
111
  } | {
110
112
  readonly kind: 'llm';
111
113
  readonly id: string;
@@ -113,8 +115,8 @@ export type ContextStep<TMemory = ContextMemory, I = unknown, O = unknown> = {
113
115
  } | {
114
116
  readonly kind: 'loop';
115
117
  readonly id: string;
116
- readonly steps: ReadonlyArray<ContextStep<TMemory, I, O>>;
117
- readonly prepareNext?: (output: O, verdict: unknown, ctx: Context<TMemory>) => I;
118
+ readonly steps: ReadonlyArray<ContextStep<TContext, I, O>>;
119
+ readonly prepareNext?: (output: O, verdict: unknown, ctx: Context<TContext>) => I;
118
120
  } | {
119
121
  readonly kind: string;
120
122
  readonly id: string;
@@ -138,7 +140,7 @@ export interface ContextHarness {
138
140
  getTextStream(scope?: unknown): AsyncIterable<string>;
139
141
  getReasoningStream(scope?: unknown): AsyncIterable<string>;
140
142
  getFullStream(scope?: unknown): AsyncIterable<StreamEvent>;
141
- run<I, O>(step: ContextStep<ContextMemory, I, O>, input: I, ctx: Context): Promise<O>;
143
+ run<I, O>(step: ContextStep<ContextData, I, O>, input: I, ctx: Context): Promise<O>;
142
144
  detachedSpawn<I, O>(step: unknown, input: I, parentCtx: Context, overrides?: ContextDetachedSpawnOverrides): DetachedHandle<O>;
143
145
  createContext(opts?: {
144
146
  parent?: Context;
@@ -146,20 +148,22 @@ export interface ContextHarness {
146
148
  state?: unknown;
147
149
  threadId?: string;
148
150
  resourceId?: string;
149
- memory?: MemoryLayer[];
151
+ context?: ContextLayer[];
152
+ /** @deprecated Renamed to `context`. */
153
+ memory?: ContextLayer[];
150
154
  cwdInit?: string;
151
155
  }): Context;
152
156
  setRootCwd(nextCwd: string): void;
153
157
  getLayerState<T>(executionId: string, layerId: string): T | undefined;
154
158
  setLayerState<T>(executionId: string, layerId: string, state: T): void;
155
- beforeToolCall(layers: MemoryLayer[], toolName: string, toolArgs: unknown, ctx: Context): Promise<SteeringDecision>;
156
- afterModelCall(layers: MemoryLayer[], response: LLMResponse, ctx: Context): Promise<SteeringDecision>;
157
- runAppendPipeline(layers: MemoryLayer[], items: import('./items.js').Item[], ctx: Context): Promise<ContextAppendPipelineResult>;
158
- recallLayers(layers: MemoryLayer[], input: string, ctx: Context): Promise<ContextRecallLayerOutput[]>;
159
- recallLayersAtomic(layers: MemoryLayer[], input: string, ctx: Context, budgets: Map<string, number>): Promise<ContextRecallLayerOutput[]>;
160
- recallLayersEventual(layers: MemoryLayer[], input: string, ctx: Context, budgets: Map<string, number>): Promise<ContextRecallLayerOutput[]>;
161
- projectHistory(layers: MemoryLayer[], items: ReadonlyArray<import('./items.js').Item>, ctx: Context): Promise<ReadonlyArray<import('./items.js').Item>>;
162
- storeLayers(layers: MemoryLayer[], response: LLMResponse, ctx: Context): Promise<void>;
159
+ beforeToolCall(layers: ContextLayer[], toolName: string, toolArgs: unknown, ctx: Context): Promise<SteeringDecision>;
160
+ afterModelCall(layers: ContextLayer[], response: LLMResponse, ctx: Context): Promise<SteeringDecision>;
161
+ runAppendPipeline(layers: ContextLayer[], items: import('./items.js').Item[], ctx: Context): Promise<ContextAppendPipelineResult>;
162
+ recallLayers(layers: ContextLayer[], input: string, ctx: Context): Promise<ContextRecallLayerOutput[]>;
163
+ recallLayersAtomic(layers: ContextLayer[], input: string, ctx: Context, budgets: Map<string, number>): Promise<ContextRecallLayerOutput[]>;
164
+ recallLayersEventual(layers: ContextLayer[], input: string, ctx: Context, budgets: Map<string, number>): Promise<ContextRecallLayerOutput[]>;
165
+ projectHistory(layers: ContextLayer[], items: ReadonlyArray<import('./items.js').Item>, ctx: Context): Promise<ReadonlyArray<import('./items.js').Item>>;
166
+ storeLayers(layers: ContextLayer[], response: LLMResponse, ctx: Context): Promise<void>;
163
167
  previewRequestItems(scope?: unknown): Promise<ReadonlyArray<import('./items.js').Item>>;
164
168
  /**
165
169
  * Internal-sender channel write. Resolves immediately unless the target
@@ -173,13 +177,15 @@ export interface ContextHarness {
173
177
  }): Promise<T>;
174
178
  tryRecv<T>(channel: Channel<T>, ctx: Context): T | null;
175
179
  getChannelHandle<T>(channel: ExternalChannel<T>, executionId: string): ChannelHandle<T>;
176
- initLayers(layers: MemoryLayer[], ctx: Context, storage: StorageAdapter): Promise<void>;
177
- disposeLayers(layers: MemoryLayer[], ctx: Context): Promise<void>;
180
+ /** Read-side counterpart to `getChannelHandle` — see `AgentHarnessContract.getChannelStream`. */
181
+ getChannelStream<T>(channel: ExternalChannel<T>, executionId: string): AsyncIterable<T>;
182
+ initLayers(layers: ContextLayer[], ctx: Context, storage: StorageAdapter): Promise<void>;
183
+ disposeLayers(layers: ContextLayer[], ctx: Context): Promise<void>;
178
184
  checkpoint(ctx: Context): Promise<void>;
179
185
  restore(executionId: string, opts?: RestoreContextOptions): Promise<Context | null>;
180
186
  /**
181
187
  * Cancel an execution: abort `ctx` and every live descendant context, then
182
- * run memory-layer teardown (`onComplete` with `outcome: 'aborted'`, then
188
+ * run context-layer teardown (`onComplete` with `outcome: 'aborted'`, then
183
189
  * `dispose`) bottom-up. A no-op on an already-cancelled context.
184
190
  */
185
191
  cancel(ctx: Context, reason?: string): Promise<void>;
@@ -190,17 +196,17 @@ export interface ContextHarness {
190
196
  getStatus(scope?: unknown): ContextHarnessStatus;
191
197
  getQueueSize(scope?: unknown): number;
192
198
  seedSessionHistory(threadId: string, items: ReadonlyArray<import('./items.js').Item>): void;
193
- executeRerender(requests: ContextRerenderRequest[], layers: MemoryLayer[], ctx: Context, budgets: Map<string, number>, query?: string): Promise<ContextRecallLayerOutput[]>;
199
+ executeRerender(requests: ContextRerenderRequest[], layers: ContextLayer[], ctx: Context, budgets: Map<string, number>, query?: string): Promise<ContextRecallLayerOutput[]>;
194
200
  }
195
201
  /** @public Execution context threaded through every step, carrying state, metrics, and channels. */
196
- export interface Context<TMemory = ContextMemory, TState = unknown> {
202
+ export interface Context<TContext = ContextData, TState = unknown> {
197
203
  readonly id: string;
198
204
  readonly stepCount: number;
199
205
  readonly tokens: TokenUsage;
200
206
  readonly elapsed: number;
201
207
  readonly cost: number;
202
208
  state: TState;
203
- readonly parent: Context<ContextMemory> | null;
209
+ readonly parent: Context<ContextData> | null;
204
210
  readonly depth: number;
205
211
  readonly span: Span;
206
212
  readonly threadId: string;
@@ -222,9 +228,17 @@ export interface Context<TMemory = ContextMemory, TState = unknown> {
222
228
  * agent `cd` propagates to subsequent tool calls.
223
229
  */
224
230
  readonly cwdState: CwdState;
225
- readonly layers?: MemoryLayer[];
226
- /** Layer provides keyed by layer ID. Access data/functions via `ctx.memory['layerId'].prop`. */
227
- readonly memory: TMemory;
231
+ readonly layers?: ContextLayer[];
232
+ /** Layer provides keyed by layer ID. Access data/functions via `ctx.context['layerId'].prop`. */
233
+ readonly context: TContext;
234
+ /**
235
+ * @deprecated Renamed to `context`. Reads through to the same object.
236
+ *
237
+ * Required, not optional: pre-rename code does `ctx.memory['layerId']`, and an
238
+ * optional field would make that a `possibly undefined` compile error — which
239
+ * is exactly the break this alias exists to prevent.
240
+ */
241
+ readonly memory: TContext;
228
242
  /** Unified tool set collected from all LLM steps in the step tree before execution. */
229
243
  readonly unifiedTools?: ReadonlyArray<Tool>;
230
244
  /** Runtime item schema registry active for this context. */
@@ -256,7 +270,7 @@ export interface Context<TMemory = ContextMemory, TState = unknown> {
256
270
  * Aborting rejects operations blocked on the context (channel `recv` waiters,
257
271
  * parked back-pressure senders) with `cancelled`, cuts short the in-flight
258
272
  * model call or sub-harness turn, and makes the next step boundary throw
259
- * `cancelled`. Memory-layer teardown is NOT run — use
273
+ * `cancelled`. Context-layer teardown is NOT run — use
260
274
  * `harness.cancel(ctx, reason)` for that.
261
275
  */
262
276
  abort(reason?: string): void;
@@ -34,7 +34,7 @@ export interface HarnessResponse {
34
34
  };
35
35
  readonly cost?: number;
36
36
  readonly text: string;
37
- /** Per-memory-layer context window breakdown captured at the last callModel of this execution. */
37
+ /** Per-context-layer context window breakdown captured at the last callModel of this execution. */
38
38
  readonly lastLayerUsage?: LastLayerUsage;
39
39
  }
40
40
  /** @public An Item snapshot with a completion flag, emitted from getItemStream(). */
@@ -97,9 +97,9 @@ export interface FunctionCallOutputItem {
97
97
  readonly callId: string;
98
98
  readonly output: string;
99
99
  }
100
- /** @public Item produced by an extension schema registered by a tool, memory layer, or harness. */
100
+ /** @public Item produced by an extension schema registered by a tool, context layer, or harness. */
101
101
  export type ExtensionItem = ItemBase & Record<string, unknown>;
102
- /** @public Developer-role message item refined by a memory-layer extension schema. */
102
+ /** @public Developer-role message item refined by a context-layer extension schema. */
103
103
  export type DeveloperMessageExtensionItem = InputMessageItem & {
104
104
  readonly role: 'developer';
105
105
  } & Record<string, unknown>;
@@ -111,7 +111,7 @@ export type ToolResultExtensionItem = FunctionCallOutputItem & Record<string, un
111
111
  export interface ItemSchemaExtensions {
112
112
  /** Harness-wide schemas. Any item matching one of these schemas is accepted. */
113
113
  readonly items?: ReadonlyArray<ZodTypeAny>;
114
- /** Schemas for memory-layer developer message items. */
114
+ /** Schemas for context-layer developer message items. */
115
115
  readonly developerMessages?: ReadonlyArray<ZodTypeAny>;
116
116
  /** Schemas for tool call items emitted by the model or a harness adapter. */
117
117
  readonly toolCalls?: ReadonlyArray<ZodTypeAny>;
@@ -11,8 +11,8 @@ export interface Span {
11
11
  export interface TraceExporter {
12
12
  export(spans: Span[]): Promise<void>;
13
13
  }
14
- /** @public Diagnostic span recording a single memory layer hook invocation and its outcome. */
15
- export interface MemoryTraceSpan {
14
+ /** @public Diagnostic span recording a single context layer hook invocation and its outcome. */
15
+ export interface LayerTraceSpan {
16
16
  layerId: string;
17
17
  hook: 'init' | 'recall' | 'store' | 'onSpawn' | 'onReturn' | 'onComplete' | 'dispose';
18
18
  durationMs: number;
@@ -5,7 +5,7 @@
5
5
  * `StepLLM.output`: instead of JSON-parsing the assistant text once at turn
6
6
  * end, a codec is fed each text delta as it streams and produces a typed
7
7
  * value when the turn finishes. OpenUI Lang is one dialect; the contract
8
- * lives here — next to `MemoryLayer` and `SubHarness` — so `core` and
8
+ * lives here — next to `ContextLayer` and `SubHarness` — so `core` and
9
9
  * dialect packages both depend on it without forming a cycle.
10
10
  */
11
11
  /**
@@ -5,7 +5,7 @@
5
5
  * `StepLLM.output`: instead of JSON-parsing the assistant text once at turn
6
6
  * end, a codec is fed each text delta as it streams and produces a typed
7
7
  * value when the turn finishes. OpenUI Lang is one dialect; the contract
8
- * lives here — next to `MemoryLayer` and `SubHarness` — so `core` and
8
+ * lives here — next to `ContextLayer` and `SubHarness` — so `core` and
9
9
  * dialect packages both depend on it without forming a cycle.
10
10
  */
11
11
  /**
@@ -2,11 +2,11 @@ import type { ZodType } from 'zod';
2
2
  import type { Channel, ChannelHandle, ExternalChannel } from './channel.js';
3
3
  import type { LLMResponse, ModelParams, ServerToolSpec } from './common.js';
4
4
  import type { Context, CwdState, RestoreContextOptions } from './context.js';
5
+ import type { ContextData, ContextLayer, ProjectionPolicy, StorageAdapter } from './context-layer.js';
5
6
  import type { DetachedHandle } from './detached.js';
6
7
  import type { FsAdapter } from './fs-adapter.js';
7
8
  import type { HarnessResponse, StreamEvent, StreamingItem } from './harness-result.js';
8
9
  import type { ExecuteInput, Item, ItemSchemaExtensions } from './items.js';
9
- import type { ContextMemory, MemoryLayer, ProjectionPolicy, StorageAdapter } from './memory.js';
10
10
  import type { Span, TraceExporter } from './observability.js';
11
11
  import type { ShellAdapter } from './shell-adapter.js';
12
12
  import type { SteeringDecision } from './steering.js';
@@ -18,7 +18,7 @@ export interface AgentHooks {
18
18
  beforeStep?: (step: Step, ctx: Context) => Promise<void>;
19
19
  afterStep?: (step: Step, result: unknown, ctx: Context) => Promise<void>;
20
20
  }
21
- /** @public Top-level configuration object that defines an agent's model, tools, memory, and behavior. */
21
+ /** @public Top-level configuration object that defines an agent's model, tools, context, and behavior. */
22
22
  export interface AgentConfig<TParams extends Record<string, unknown> = Record<string, unknown>> {
23
23
  name: string;
24
24
  storage?: StorageAdapter;
@@ -84,7 +84,7 @@ interface CallModelRequestBase {
84
84
  interface CallModelRequestWithTools extends CallModelRequestBase {
85
85
  tools: Tool[];
86
86
  ctx: Context;
87
- layers?: MemoryLayer[];
87
+ layers?: ContextLayer[];
88
88
  /** When set, restricts which tools the model may invoke for this call. */
89
89
  allowedToolNames?: string[];
90
90
  }
@@ -102,8 +102,10 @@ export interface ExecuteOptions {
102
102
  threadId?: string;
103
103
  resourceId?: string;
104
104
  state?: unknown;
105
- /** Memory layers to apply to the execution context. Overrides harness-level memory if provided. */
106
- memory?: MemoryLayer[];
105
+ /** Context layers to apply to the execution context. Overrides harness-level layers if provided. */
106
+ context?: ContextLayer[];
107
+ /** @deprecated Renamed to `context`. */
108
+ memory?: ContextLayer[];
107
109
  /** Override the harness's default delivery mode for this message only. */
108
110
  deliveryMode?: DeliveryMode;
109
111
  /**
@@ -130,7 +132,7 @@ export type HarnessStatus = {
130
132
  export interface SessionScope {
131
133
  threadId?: string;
132
134
  }
133
- /** @public Type-level contract for the agent runtime. Used for type annotations throughout the interpreter, memory layers, and context. Implemented by `AgentHarness`. */
135
+ /** @public Type-level contract for the agent runtime. Used for type annotations throughout the interpreter, context layers, and context. Implemented by `AgentHarness`. */
134
136
  export interface AgentHarnessContract<TParams extends Record<string, unknown> = Record<string, unknown>> {
135
137
  readonly config: AgentConfig<TParams>;
136
138
  /** Filesystem adapter for virtual or real filesystem access. */
@@ -182,7 +184,7 @@ export interface AgentHarnessContract<TParams extends Record<string, unknown> =
182
184
  * already exist. Replaces any previously-accumulated items for the session.
183
185
  */
184
186
  seedSessionHistory(threadId: string, items: ReadonlyArray<Item>): void;
185
- run<I, O>(step: Step<ContextMemory, I, O>, input: I, ctx: Context): Promise<O>;
187
+ run<I, O>(step: Step<ContextData, I, O>, input: I, ctx: Context): Promise<O>;
186
188
  /**
187
189
  * Launch `step` as a fire-and-forget background execution.
188
190
  *
@@ -194,11 +196,11 @@ export interface AgentHarnessContract<TParams extends Record<string, unknown> =
194
196
  *
195
197
  * @param step Step to execute in a fresh child context.
196
198
  * @param input Initial input passed to `step`.
197
- * @param parentCtx Parent context (the child inherits memory layers and,
199
+ * @param parentCtx Parent context (the child inherits context layers and,
198
200
  * by default, threadId/resourceId).
199
201
  * @param overrides Optional: override threadId or resourceId on the child.
200
202
  */
201
- detachedSpawn<I, O>(step: Step<ContextMemory, I, O>, input: I, parentCtx: Context, overrides?: {
203
+ detachedSpawn<I, O>(step: Step<ContextData, I, O>, input: I, parentCtx: Context, overrides?: {
202
204
  threadId?: string;
203
205
  resourceId?: string;
204
206
  /** Override the child's initial cwd. Used by worktree isolation to root the child at the worktree path. */
@@ -210,7 +212,9 @@ export interface AgentHarnessContract<TParams extends Record<string, unknown> =
210
212
  state?: unknown;
211
213
  threadId?: string;
212
214
  resourceId?: string;
213
- memory?: MemoryLayer[];
215
+ context?: ContextLayer[];
216
+ /** @deprecated Renamed to `context`. */
217
+ memory?: ContextLayer[];
214
218
  /** Override the new context's initial cwd. */
215
219
  cwdInit?: string;
216
220
  }): Context;
@@ -230,20 +234,31 @@ export interface AgentHarnessContract<TParams extends Record<string, unknown> =
230
234
  }): Promise<T>;
231
235
  tryRecv<T>(channel: Channel<T>, ctx: Context): T | null;
232
236
  getChannelHandle<T>(channel: ExternalChannel<T>, executionId: string): ChannelHandle<T>;
233
- initLayers(layers: MemoryLayer[], ctx: Context, storage: StorageAdapter): Promise<void>;
234
- recallLayers(layers: MemoryLayer[], input: string, ctx: Context): Promise<RecallLayerOutput[]>;
237
+ /**
238
+ * Read-side counterpart to `getChannelHandle`: subscribe to values the agent
239
+ * sends on an external channel. Delivery is CHANNEL-scoped (state is keyed
240
+ * by channel name per harness) — `executionId` bounds only the
241
+ * subscription's lifetime: the iterable ends when that root execution
242
+ * completes (success, failure, or cancellation), draining buffered values
243
+ * first. An id no execution runs under never closes, giving a
244
+ * harness-lifetime stream ended via `iterator.return()`. The returned
245
+ * iterable owns a single iterator; subscribe again for a second consumer.
246
+ */
247
+ getChannelStream<T>(channel: ExternalChannel<T>, executionId: string): AsyncIterable<T>;
248
+ initLayers(layers: ContextLayer[], ctx: Context, storage: StorageAdapter): Promise<void>;
249
+ recallLayers(layers: ContextLayer[], input: string, ctx: Context): Promise<RecallLayerOutput[]>;
235
250
  /** Recall only atomic layers (or all layers when the harness forces atomic recall). Blocks until complete. */
236
- recallLayersAtomic(layers: MemoryLayer[], input: string, ctx: Context, budgets: Map<string, number>): Promise<RecallLayerOutput[]>;
251
+ recallLayersAtomic(layers: ContextLayer[], input: string, ctx: Context, budgets: Map<string, number>): Promise<RecallLayerOutput[]>;
237
252
  /** Recall eventual layers from cache (non-blocking); returns nothing when the harness forces atomic recall. */
238
- recallLayersEventual(layers: MemoryLayer[], input: string, ctx: Context, budgets: Map<string, number>): Promise<RecallLayerOutput[]>;
253
+ recallLayersEventual(layers: ContextLayer[], input: string, ctx: Context, budgets: Map<string, number>): Promise<RecallLayerOutput[]>;
239
254
  /**
240
255
  * Compute the items that would be sent to the model on the next turn for a
241
- * session — its accumulated history plus the harness's memory-layer recall
256
+ * session — its accumulated history plus the harness's context-layer recall
242
257
  * outputs assembled in the same order `executeLLM` produces.
243
258
  */
244
259
  previewRequestItems(scope?: SessionScope): Promise<ReadonlyArray<Item>>;
245
- storeLayers(layers: MemoryLayer[], response: LLMResponse, ctx: Context): Promise<void>;
246
- disposeLayers(layers: MemoryLayer[], ctx: Context): Promise<void>;
260
+ storeLayers(layers: ContextLayer[], response: LLMResponse, ctx: Context): Promise<void>;
261
+ disposeLayers(layers: ContextLayer[], ctx: Context): Promise<void>;
247
262
  checkpoint(ctx: Context): Promise<void>;
248
263
  /**
249
264
  * Rebuild a `Context` from a persisted snapshot. `opts` carries the wiring
@@ -253,7 +268,7 @@ export interface AgentHarnessContract<TParams extends Record<string, unknown> =
253
268
  restore(executionId: string, opts?: RestoreContextOptions): Promise<Context | null>;
254
269
  /**
255
270
  * Cancel an execution. Aborts `ctx` and — cascading down the execution tree —
256
- * every live fork path and spawn child, then runs memory-layer teardown
271
+ * every live fork path and spawn child, then runs context-layer teardown
257
272
  * (`onComplete` with `outcome: 'aborted'`, then `dispose`) bottom-up.
258
273
  *
259
274
  * Blocked channel operations reject with `cancelled`, the in-flight model
@@ -267,27 +282,27 @@ export interface AgentHarnessContract<TParams extends Record<string, unknown> =
267
282
  createSpan(name: string, parent: Span | null): Span;
268
283
  getLayerState<T>(executionId: string, layerId: string): T | undefined;
269
284
  setLayerState<T>(executionId: string, layerId: string, state: T): void;
270
- beforeToolCall(layers: MemoryLayer[], toolName: string, toolArgs: unknown, ctx: Context): Promise<SteeringDecision>;
271
- afterModelCall(layers: MemoryLayer[], response: LLMResponse, ctx: Context): Promise<SteeringDecision>;
285
+ beforeToolCall(layers: ContextLayer[], toolName: string, toolArgs: unknown, ctx: Context): Promise<SteeringDecision>;
286
+ afterModelCall(layers: ContextLayer[], response: LLMResponse, ctx: Context): Promise<SteeringDecision>;
272
287
  /**
273
288
  * Project the history items through every layer's `projectHistory` hook in
274
289
  * slot order. Pure read-side projection — `itemLog` is never mutated.
275
290
  * Returns the input unchanged if no layer registers the hook.
276
291
  */
277
- projectHistory(layers: MemoryLayer[], items: ReadonlyArray<Item>, ctx: Context): Promise<ReadonlyArray<Item>>;
292
+ projectHistory(layers: ContextLayer[], items: ReadonlyArray<Item>, ctx: Context): Promise<ReadonlyArray<Item>>;
278
293
  /**
279
294
  * Run items through the onItemAppend pipeline before appending.
280
295
  * Each layer can filter, transform, or inject items.
281
296
  * Returns final items to append and any re-render requests.
282
297
  */
283
- runAppendPipeline(layers: MemoryLayer[], items: Item[], ctx: Context): Promise<AppendPipelineResult>;
298
+ runAppendPipeline(layers: ContextLayer[], items: Item[], ctx: Context): Promise<AppendPipelineResult>;
284
299
  /**
285
300
  * Execute re-render based on collected requests.
286
301
  * Determines which layers need re-recall based on scope and runs them.
287
302
  */
288
- executeRerender(requests: RerenderRequest[], layers: MemoryLayer[], ctx: Context, budgets: Map<string, number>, query?: string): Promise<RecallLayerOutput[]>;
303
+ executeRerender(requests: RerenderRequest[], layers: ContextLayer[], ctx: Context, budgets: Map<string, number>, query?: string): Promise<RecallLayerOutput[]>;
289
304
  }
290
- /** @public Output from a single memory layer's recall phase, including items and token budget used. */
305
+ /** @public Output from a single context layer's recall phase, including items and token budget used. */
291
306
  export interface RecallLayerOutput {
292
307
  layerId: string;
293
308
  items: Item[];
@@ -1,5 +1,5 @@
1
1
  import type { LLMResponse } from './common.js';
2
- import type { ExecutionContext, MemoryScope } from './memory-context.js';
2
+ import type { ContextScope, ExecutionContext } from './context-scope.js';
3
3
  /** @public Enumeration of actions a steering rule can take on a tool call or model response. */
4
4
  export declare const SteeringAction: {
5
5
  Allow: string;
@@ -77,7 +77,7 @@ export interface SteeringConfig {
77
77
  rules: SteeringRule[];
78
78
  maxLedgerEntries?: number;
79
79
  maxRetries?: number;
80
- scope?: MemoryScope;
80
+ scope?: ContextScope;
81
81
  }
82
82
  /** @public Mutable runtime state maintained by the steering layer across an execution. */
83
83
  export interface SteeringState {