@noetic-tools/types 0.1.1 → 0.2.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
CHANGED
|
@@ -8,7 +8,7 @@ import type { DetachedHandle } from './detached.js';
|
|
|
8
8
|
import type { FsAdapter } from './fs-adapter.js';
|
|
9
9
|
import type { HarnessResponse, StreamEvent, StreamingItem } from './harness-result.js';
|
|
10
10
|
import type { ExecuteInput } from './items.js';
|
|
11
|
-
import type { ContextMemory, MemoryLayer, StorageAdapter } from './memory.js';
|
|
11
|
+
import type { ContextMemory, MemoryLayer, ProjectionPolicy, StorageAdapter } from './memory.js';
|
|
12
12
|
import type { Span } from './observability.js';
|
|
13
13
|
import type { ShellAdapter } from './shell-adapter.js';
|
|
14
14
|
import type { SteeringDecision } from './steering.js';
|
|
@@ -98,6 +98,8 @@ export interface ContextHarness {
|
|
|
98
98
|
readonly config: {
|
|
99
99
|
readonly name: string;
|
|
100
100
|
readonly params: Record<string, unknown>;
|
|
101
|
+
/** Harness-wide default projection policy; a step's `projection` overrides it. */
|
|
102
|
+
readonly projection?: ProjectionPolicy;
|
|
101
103
|
};
|
|
102
104
|
readonly fs: FsAdapter;
|
|
103
105
|
readonly shell: ShellAdapter;
|
|
@@ -128,6 +130,8 @@ export interface ContextHarness {
|
|
|
128
130
|
afterModelCall(layers: MemoryLayer[], response: LLMResponse, ctx: Context): Promise<SteeringDecision>;
|
|
129
131
|
runAppendPipeline(layers: MemoryLayer[], items: import('./items.js').Item[], ctx: Context): Promise<ContextAppendPipelineResult>;
|
|
130
132
|
recallLayers(layers: MemoryLayer[], input: string, ctx: Context): Promise<ContextRecallLayerOutput[]>;
|
|
133
|
+
recallLayersAtomic(layers: MemoryLayer[], input: string, ctx: Context, budgets: Map<string, number>): Promise<ContextRecallLayerOutput[]>;
|
|
134
|
+
recallLayersEventual(layers: MemoryLayer[], input: string, ctx: Context, budgets: Map<string, number>): Promise<ContextRecallLayerOutput[]>;
|
|
131
135
|
projectHistory(layers: MemoryLayer[], items: ReadonlyArray<import('./items.js').Item>, ctx: Context): Promise<ReadonlyArray<import('./items.js').Item>>;
|
|
132
136
|
storeLayers(layers: MemoryLayer[], response: LLMResponse, ctx: Context): Promise<void>;
|
|
133
137
|
previewRequestItems(scope?: unknown): Promise<ReadonlyArray<import('./items.js').Item>>;
|
package/dist/types/memory.d.ts
CHANGED
|
@@ -288,6 +288,26 @@ export interface MemoryLayer<TState = unknown> {
|
|
|
288
288
|
hooks: MemoryHooks<TState>;
|
|
289
289
|
/** Per-hook timeout overrides in ms. */
|
|
290
290
|
timeouts?: Partial<LayerTimeouts>;
|
|
291
|
+
/**
|
|
292
|
+
* What to do when this layer's `init` hook throws.
|
|
293
|
+
* - `'throw'` (default): surface the error and abort the execution — memory is
|
|
294
|
+
* load-bearing, and silent disabling hides failures (and, for the steering
|
|
295
|
+
* layer, would fail *open*).
|
|
296
|
+
* - `'disable'`: log a diagnostic and run the execution without this layer
|
|
297
|
+
* (its `recall`/`store`/etc. are skipped). Opt in only for non-critical layers.
|
|
298
|
+
*/
|
|
299
|
+
onInitError?: 'throw' | 'disable';
|
|
300
|
+
/**
|
|
301
|
+
* Recall mode controlling whether this layer's `recall()` blocks the model call.
|
|
302
|
+
* - `'atomic'` (default): recall runs synchronously in the hot path; the
|
|
303
|
+
* harness waits for it before assembling the view.
|
|
304
|
+
* - `'eventual'`: recall is served from cache and never blocks; the cache
|
|
305
|
+
* refreshes after `store()` produces new state, so the next turn sees it.
|
|
306
|
+
*
|
|
307
|
+
* A harness configured with `forceAtomicRecall` treats every layer as atomic,
|
|
308
|
+
* ignoring this field.
|
|
309
|
+
*/
|
|
310
|
+
recallMode?: 'atomic' | 'eventual';
|
|
291
311
|
/** Typed functions and data exposed to code steps via `ctx.memory['layerId']` and automatically as LLM tools. */
|
|
292
312
|
provides?: LayerProvides;
|
|
293
313
|
/** Optional item schemas contributed by this layer, primarily for developer-role memory items. */
|
package/dist/types/runtime.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ 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';
|
|
8
8
|
import type { ExecuteInput, Item, ItemSchemaExtensions } from './items.js';
|
|
9
|
-
import type { ContextMemory, MemoryLayer, StorageAdapter } from './memory.js';
|
|
9
|
+
import type { ContextMemory, MemoryLayer, ProjectionPolicy, StorageAdapter } from './memory.js';
|
|
10
10
|
import type { Span } from './observability.js';
|
|
11
11
|
import type { ShellAdapter } from './shell-adapter.js';
|
|
12
12
|
import type { SteeringDecision } from './steering.js';
|
|
@@ -28,6 +28,10 @@ export interface AgentConfig<TParams extends Record<string, unknown> = Record<st
|
|
|
28
28
|
itemSchemas?: ItemSchemaExtensions;
|
|
29
29
|
/** Whether unknown extension item types must match a registered schema. Defaults to true. */
|
|
30
30
|
strictItemSchemas?: boolean;
|
|
31
|
+
/** Default projection policy for all LLM steps. Individual steps override via `step.projection`. */
|
|
32
|
+
projection?: ProjectionPolicy;
|
|
33
|
+
/** When true, every layer is recalled atomically regardless of its `recallMode` (no eventual/cached recall). */
|
|
34
|
+
forceAtomicRecall?: boolean;
|
|
31
35
|
}
|
|
32
36
|
/** @public How a message submitted during an active turn is delivered to the model.
|
|
33
37
|
*
|
|
@@ -199,6 +203,10 @@ export interface AgentHarnessContract<TParams extends Record<string, unknown> =
|
|
|
199
203
|
getChannelHandle<T>(channel: ExternalChannel<T>, executionId: string): ChannelHandle<T>;
|
|
200
204
|
initLayers(layers: MemoryLayer[], ctx: Context, storage: StorageAdapter): Promise<void>;
|
|
201
205
|
recallLayers(layers: MemoryLayer[], input: string, ctx: Context): Promise<RecallLayerOutput[]>;
|
|
206
|
+
/** Recall only atomic layers (or all layers when the harness forces atomic recall). Blocks until complete. */
|
|
207
|
+
recallLayersAtomic(layers: MemoryLayer[], input: string, ctx: Context, budgets: Map<string, number>): Promise<RecallLayerOutput[]>;
|
|
208
|
+
/** Recall eventual layers from cache (non-blocking); returns nothing when the harness forces atomic recall. */
|
|
209
|
+
recallLayersEventual(layers: MemoryLayer[], input: string, ctx: Context, budgets: Map<string, number>): Promise<RecallLayerOutput[]>;
|
|
202
210
|
/**
|
|
203
211
|
* Compute the items that would be sent to the model on the next turn for a
|
|
204
212
|
* session — its accumulated history plus the harness's memory-layer recall
|
package/dist/types/step.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Channel } from './channel.js';
|
|
|
3
3
|
import type { ModelParams, RetryPolicy, StepMeta } from './common.js';
|
|
4
4
|
import type { Context } from './context.js';
|
|
5
5
|
import type { NoeticError } from './error.js';
|
|
6
|
-
import type { ContextMemory, MemoryConfig, MemoryLayer } from './memory.js';
|
|
6
|
+
import type { ContextMemory, MemoryConfig, MemoryLayer, ProjectionPolicy } from './memory.js';
|
|
7
7
|
import type { SubprocessAdapter } from './subprocess-adapter.js';
|
|
8
8
|
import type { Tool } from './tool.js';
|
|
9
9
|
/**
|
|
@@ -99,6 +99,8 @@ export interface StepLLM<TMemory = ContextMemory, _I = unknown, O = unknown> {
|
|
|
99
99
|
params?: ModelParams;
|
|
100
100
|
/** Controls framework event emission for this step. Defaults to `true`. Set `false` to suppress all framework events. A filter function receives `(eventType, data)` and returns `boolean`. */
|
|
101
101
|
emit?: boolean | ((eventType: string, data: Record<string, unknown>) => boolean);
|
|
102
|
+
/** Projection policy for this step's context window. Overrides the harness-level default. */
|
|
103
|
+
projection?: ProjectionPolicy;
|
|
102
104
|
}
|
|
103
105
|
/** @public A step that invokes a single tool directly, bypassing the LLM. */
|
|
104
106
|
export interface StepTool<_TMemory = ContextMemory, I = unknown, O = unknown> {
|
|
@@ -9,6 +9,22 @@ export declare function isOutputText(part: {
|
|
|
9
9
|
type: 'output_text';
|
|
10
10
|
text: string;
|
|
11
11
|
};
|
|
12
|
+
/** True for any content part carrying a string `text` field (input_text, output_text, …). */
|
|
13
|
+
export declare function isTextPart(part: {
|
|
14
|
+
type: string;
|
|
15
|
+
}): part is {
|
|
16
|
+
type: string;
|
|
17
|
+
text: string;
|
|
18
|
+
};
|
|
19
|
+
/** Extracts assistant/output text from items for memory buffering (one string per message). */
|
|
20
|
+
export declare function collectOutputText(items: ReadonlyArray<Item>): string[];
|
|
21
|
+
/**
|
|
22
|
+
* Extracts text from INPUT items for memory buffering: concatenates the text
|
|
23
|
+
* content parts of message items (user `input_text` and any text parts) and
|
|
24
|
+
* appends the `output` of `function_call_output` (tool result) items. Empty
|
|
25
|
+
* strings are dropped.
|
|
26
|
+
*/
|
|
27
|
+
export declare function collectInputText(items: ReadonlyArray<Item>): string[];
|
|
12
28
|
export declare function createMessage(text: string, role: 'user' | 'developer'): InputMessageItem;
|
|
13
29
|
export declare function extractAssistantText(items: ReadonlyArray<Item>): string;
|
|
14
30
|
/** Naive token estimate: ~4 chars per token */
|
|
@@ -21,6 +21,47 @@ export function isUserMessage(item) {
|
|
|
21
21
|
export function isOutputText(part) {
|
|
22
22
|
return part.type === 'output_text';
|
|
23
23
|
}
|
|
24
|
+
/** True for any content part carrying a string `text` field (input_text, output_text, …). */
|
|
25
|
+
export function isTextPart(part) {
|
|
26
|
+
return 'text' in part && typeof part.text === 'string';
|
|
27
|
+
}
|
|
28
|
+
/** Extracts assistant/output text from items for memory buffering (one string per message). */
|
|
29
|
+
export function collectOutputText(items) {
|
|
30
|
+
return items
|
|
31
|
+
.filter((i) => i.type === 'message')
|
|
32
|
+
.map((i) => i.content
|
|
33
|
+
.filter(isOutputText)
|
|
34
|
+
.map((c) => c.text)
|
|
35
|
+
.join(''))
|
|
36
|
+
.filter((t) => t.length > 0);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Extracts text from INPUT items for memory buffering: concatenates the text
|
|
40
|
+
* content parts of message items (user `input_text` and any text parts) and
|
|
41
|
+
* appends the `output` of `function_call_output` (tool result) items. Empty
|
|
42
|
+
* strings are dropped.
|
|
43
|
+
*/
|
|
44
|
+
export function collectInputText(items) {
|
|
45
|
+
const texts = [];
|
|
46
|
+
for (const item of items) {
|
|
47
|
+
if (item.type === 'message') {
|
|
48
|
+
let text = '';
|
|
49
|
+
for (const part of item.content) {
|
|
50
|
+
if (isTextPart(part)) {
|
|
51
|
+
text += part.text;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (text.length > 0) {
|
|
55
|
+
texts.push(text);
|
|
56
|
+
}
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (item.type === 'function_call_output' && item.output.length > 0) {
|
|
60
|
+
texts.push(item.output);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return texts;
|
|
64
|
+
}
|
|
24
65
|
export function createMessage(text, role) {
|
|
25
66
|
return {
|
|
26
67
|
id: crypto.randomUUID(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noetic-tools/types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.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",
|