@noetic-tools/types 2.0.0 → 2.1.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.
@@ -61,6 +61,32 @@ export interface ContextDetachedSpawnOverrides {
61
61
  resourceId?: string;
62
62
  cwdInit?: string;
63
63
  }
64
+ /**
65
+ * @public Caller-supplied wiring forwarded to the `createContext` call that
66
+ * `harness.restore()` makes internally.
67
+ *
68
+ * A snapshot recovers the item log, layer state, cwd, and identity — it cannot
69
+ * recover the live objects a host attached when it built the original context
70
+ * (event broadcasters, queues, per-host state). Pass the same wiring here that
71
+ * was passed to `createContext` originally, or the resumed run silently loses
72
+ * it.
73
+ *
74
+ * Snapshot-owned fields (`items`, `threadId`, `resourceId`, `cwdInit`) are
75
+ * deliberately absent: they always come from the persisted snapshot, so
76
+ * accepting them here would only offer a value that gets ignored.
77
+ *
78
+ * Anything a host attaches *after* construction — `Object.assign`ed fields,
79
+ * abort registration — stays the host's responsibility and can be applied to
80
+ * the context `restore()` returns.
81
+ */
82
+ export interface RestoreContextOptions {
83
+ /** Live parent context, when the restored execution hangs under one. */
84
+ parent?: Context;
85
+ /** Opaque per-execution state, same as `createContext({ state })`. */
86
+ state?: unknown;
87
+ /** Memory layers for the restored context. Defaults to the harness's configured layers. */
88
+ memory?: MemoryLayer[];
89
+ }
64
90
  export interface ContextRerenderRequest {
65
91
  layerId: string;
66
92
  slot: number;
@@ -150,7 +176,7 @@ export interface ContextHarness {
150
176
  initLayers(layers: MemoryLayer[], ctx: Context, storage: StorageAdapter): Promise<void>;
151
177
  disposeLayers(layers: MemoryLayer[], ctx: Context): Promise<void>;
152
178
  checkpoint(ctx: Context): Promise<void>;
153
- restore(executionId: string): Promise<Context | null>;
179
+ restore(executionId: string, opts?: RestoreContextOptions): Promise<Context | null>;
154
180
  cancel(ctx: Context, reason?: string): Promise<void>;
155
181
  /** Trace exporter spans are flushed to. Defaults to a no-op exporter. */
156
182
  readonly traceExporter: TraceExporter;
@@ -1,7 +1,7 @@
1
1
  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
- import type { Context, CwdState } from './context.js';
4
+ import type { Context, CwdState, RestoreContextOptions } from './context.js';
5
5
  import type { DetachedHandle } from './detached.js';
6
6
  import type { FsAdapter } from './fs-adapter.js';
7
7
  import type { HarnessResponse, StreamEvent, StreamingItem } from './harness-result.js';
@@ -245,7 +245,12 @@ export interface AgentHarnessContract<TParams extends Record<string, unknown> =
245
245
  storeLayers(layers: MemoryLayer[], response: LLMResponse, ctx: Context): Promise<void>;
246
246
  disposeLayers(layers: MemoryLayer[], ctx: Context): Promise<void>;
247
247
  checkpoint(ctx: Context): Promise<void>;
248
- restore(executionId: string): Promise<Context | null>;
248
+ /**
249
+ * Rebuild a `Context` from a persisted snapshot. `opts` carries the wiring
250
+ * the host attached when it created the original context — without it a
251
+ * decorated context is silently replaced by a bare one on resume.
252
+ */
253
+ restore(executionId: string, opts?: RestoreContextOptions): Promise<Context | null>;
249
254
  cancel(ctx: Context, reason?: string): Promise<void>;
250
255
  /** Trace exporter spans are flushed to. Defaults to a no-op exporter. */
251
256
  readonly traceExporter: TraceExporter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noetic-tools/types",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "type": "module",
5
5
  "description": "Foundational type contracts and primitives shared across the Noetic framework (items, LLM config, adapters, steering, errors).",
6
6
  "license": "Apache-2.0",