@noetic-tools/types 1.4.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.
- package/dist/types/context.d.ts +27 -1
- package/dist/types/memory.d.ts +22 -0
- package/dist/types/runtime.d.ts +7 -2
- package/package.json +1 -1
package/dist/types/context.d.ts
CHANGED
|
@@ -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;
|
package/dist/types/memory.d.ts
CHANGED
|
@@ -113,6 +113,21 @@ export interface StorageAdapter {
|
|
|
113
113
|
set<T>(key: string, value: T): Promise<void>;
|
|
114
114
|
delete(key: string): Promise<void>;
|
|
115
115
|
list(prefix: string): Promise<string[]>;
|
|
116
|
+
/**
|
|
117
|
+
* Batch read. Anything that lists a prefix and then reads each key is an N+1 —
|
|
118
|
+
* one round trip per key on a network- or database-backed adapter, which is
|
|
119
|
+
* exactly what a resume path cannot afford. Implement this and the round trips
|
|
120
|
+
* collapse to one.
|
|
121
|
+
*
|
|
122
|
+
* Optional so existing adapters keep working: callers MUST NOT depend on it
|
|
123
|
+
* directly — go through `storageGetMany`, which falls back to a parallel
|
|
124
|
+
* `get` sweep when a backend has not implemented it.
|
|
125
|
+
*
|
|
126
|
+
* Keys with no stored value are ABSENT from the returned map. The map is never
|
|
127
|
+
* sparse-with-nulls, so `map.size < keys.length` is the normal way to see that
|
|
128
|
+
* something was missing.
|
|
129
|
+
*/
|
|
130
|
+
getMany?<T>(keys: string[]): Promise<Map<string, T>>;
|
|
116
131
|
}
|
|
117
132
|
/** @public Scope-namespaced storage interface provided to memory layer init hooks. */
|
|
118
133
|
export interface ScopedStorage {
|
|
@@ -120,6 +135,13 @@ export interface ScopedStorage {
|
|
|
120
135
|
set<T>(key: string, value: T): Promise<void>;
|
|
121
136
|
delete(key: string): Promise<void>;
|
|
122
137
|
list(prefix?: string): Promise<string[]>;
|
|
138
|
+
/**
|
|
139
|
+
* Batch read, always available — the scoped wrapper supplies the fallback so a
|
|
140
|
+
* layer never has to check. Returned keys are scope-relative (the namespace
|
|
141
|
+
* prefix is stripped, as with `list`), and missing keys are absent rather than
|
|
142
|
+
* null.
|
|
143
|
+
*/
|
|
144
|
+
getMany<T>(keys: string[]): Promise<Map<string, T>>;
|
|
123
145
|
}
|
|
124
146
|
/** @public Parameters passed to a memory layer's `init` hook. */
|
|
125
147
|
export interface InitParams {
|
package/dist/types/runtime.d.ts
CHANGED
|
@@ -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
|
-
|
|
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": "1.
|
|
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",
|