@noetic-tools/types 2.1.1 → 2.3.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/deprecated.d.ts +39 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/schemas/item.d.ts +1 -1
- package/dist/schemas/item.js +1 -1
- package/dist/schemas/workflow.d.ts +297 -0
- package/dist/schemas/workflow.js +401 -0
- package/dist/types/{memory.d.ts → context-layer.d.ts} +50 -50
- package/dist/types/{memory.js → context-layer.js} +1 -1
- package/dist/types/{memory-context.d.ts → context-scope.d.ts} +8 -8
- package/dist/types/context-scope.js +1 -0
- package/dist/types/context.d.ts +40 -28
- package/dist/types/harness-result.d.ts +1 -1
- package/dist/types/items.d.ts +3 -3
- package/dist/types/observability.d.ts +2 -2
- package/dist/types/output-codec.d.ts +1 -1
- package/dist/types/output-codec.js +1 -1
- package/dist/types/runtime.d.ts +28 -24
- package/dist/types/steering.d.ts +2 -2
- package/dist/types/step.d.ts +44 -44
- package/dist/types/sub-harness.d.ts +1 -1
- package/dist/types/sub-harness.js +1 -1
- package/dist/types/tool-context.d.ts +10 -3
- package/dist/types/tool.d.ts +8 -8
- package/dist/util/message-helpers.d.ts +2 -2
- package/dist/util/message-helpers.js +2 -2
- package/package.json +3 -3
- /package/dist/{types/memory-context.js → deprecated.js} +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deprecated aliases from the "memory layer" era of the framework.
|
|
3
|
+
*
|
|
4
|
+
* The layer system assembles the model's *context window* — recall, budget
|
|
5
|
+
* allocation, history projection, the item-append pipeline — so it is named
|
|
6
|
+
* after context, not memory. Every name below still resolves to its
|
|
7
|
+
* replacement; nothing here changes behaviour.
|
|
8
|
+
*
|
|
9
|
+
* These are scheduled for removal in the next major of `@noetic-tools/types`.
|
|
10
|
+
*/
|
|
11
|
+
import type { ContextConfig, ContextData, ContextLayer, ContextLayerHooks, InferContext, InferContextShape } from './types/context-layer.js';
|
|
12
|
+
import type { ContextScope, LayerCallModelRequest } from './types/context-scope.js';
|
|
13
|
+
import type { LayerTraceSpan } from './types/observability.js';
|
|
14
|
+
import type { ToolContextDeclaration } from './types/tool.js';
|
|
15
|
+
import type { ToolContext } from './types/tool-context.js';
|
|
16
|
+
/** @public @deprecated Renamed to {@link ContextLayer}. */
|
|
17
|
+
export type MemoryLayer<TState = unknown> = ContextLayer<TState>;
|
|
18
|
+
/** @public @deprecated Renamed to {@link ContextLayerHooks}. */
|
|
19
|
+
export type MemoryHooks<TState = unknown> = ContextLayerHooks<TState>;
|
|
20
|
+
/** @public @deprecated Renamed to {@link ContextConfig}. */
|
|
21
|
+
export type MemoryConfig<TLayers extends readonly ContextLayer[] = readonly ContextLayer[]> = ContextConfig<TLayers>;
|
|
22
|
+
/** @public @deprecated Renamed to {@link ContextData}. */
|
|
23
|
+
export type ContextMemory = ContextData;
|
|
24
|
+
/** @public @deprecated Renamed to {@link InferContext}. */
|
|
25
|
+
export type InferMemory<T extends {
|
|
26
|
+
readonly _shape: unknown;
|
|
27
|
+
}> = InferContext<T>;
|
|
28
|
+
/** @public @deprecated Renamed to {@link InferContextShape}. */
|
|
29
|
+
export type InferMemoryShape<T extends readonly ContextLayer[]> = InferContextShape<T>;
|
|
30
|
+
/** @public @deprecated Renamed to {@link ContextScope}. */
|
|
31
|
+
export type MemoryScope = ContextScope;
|
|
32
|
+
/** @public @deprecated Renamed to {@link LayerCallModelRequest}. */
|
|
33
|
+
export type MemoryCallModelRequest = LayerCallModelRequest;
|
|
34
|
+
/** @public @deprecated Renamed to {@link LayerTraceSpan}. */
|
|
35
|
+
export type MemoryTraceSpan = LayerTraceSpan;
|
|
36
|
+
/** @public @deprecated Renamed to {@link ToolContext}. */
|
|
37
|
+
export type ToolMemory = ToolContext;
|
|
38
|
+
/** @public @deprecated Renamed to {@link ToolContextDeclaration}. */
|
|
39
|
+
export type ToolMemoryDeclaration<TState = unknown> = ToolContextDeclaration<TState>;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,21 +2,23 @@
|
|
|
2
2
|
* @noetic-tools/types — foundational type contracts and primitives shared
|
|
3
3
|
* across the Noetic framework.
|
|
4
4
|
*/
|
|
5
|
+
export * from './deprecated.js';
|
|
5
6
|
export * from './errors/noetic-config-error.js';
|
|
6
7
|
export * from './errors/noetic-error.js';
|
|
7
8
|
export * from './schemas/item.js';
|
|
9
|
+
export * from './schemas/workflow.js';
|
|
8
10
|
export * from './types/channel.js';
|
|
9
11
|
export * from './types/common.js';
|
|
10
12
|
export * from './types/context.js';
|
|
13
|
+
export * from './types/context-layer.js';
|
|
11
14
|
export * from './types/context-parts/item-log.js';
|
|
12
15
|
export * from './types/context-parts/layer-usage.js';
|
|
16
|
+
export * from './types/context-scope.js';
|
|
13
17
|
export * from './types/detached.js';
|
|
14
18
|
export * from './types/error.js';
|
|
15
19
|
export * from './types/fs-adapter.js';
|
|
16
20
|
export * from './types/harness-result.js';
|
|
17
21
|
export * from './types/items.js';
|
|
18
|
-
export * from './types/memory.js';
|
|
19
|
-
export * from './types/memory-context.js';
|
|
20
22
|
export * from './types/observability.js';
|
|
21
23
|
export * from './types/output-codec.js';
|
|
22
24
|
export * from './types/runtime.js';
|
package/dist/index.js
CHANGED
|
@@ -2,21 +2,23 @@
|
|
|
2
2
|
* @noetic-tools/types — foundational type contracts and primitives shared
|
|
3
3
|
* across the Noetic framework.
|
|
4
4
|
*/
|
|
5
|
+
export * from './deprecated.js';
|
|
5
6
|
export * from './errors/noetic-config-error.js';
|
|
6
7
|
export * from './errors/noetic-error.js';
|
|
7
8
|
export * from './schemas/item.js';
|
|
9
|
+
export * from './schemas/workflow.js';
|
|
8
10
|
export * from './types/channel.js';
|
|
9
11
|
export * from './types/common.js';
|
|
10
12
|
export * from './types/context.js';
|
|
13
|
+
export * from './types/context-layer.js';
|
|
11
14
|
export * from './types/context-parts/item-log.js';
|
|
12
15
|
export * from './types/context-parts/layer-usage.js';
|
|
16
|
+
export * from './types/context-scope.js';
|
|
13
17
|
export * from './types/detached.js';
|
|
14
18
|
export * from './types/error.js';
|
|
15
19
|
export * from './types/fs-adapter.js';
|
|
16
20
|
export * from './types/harness-result.js';
|
|
17
21
|
export * from './types/items.js';
|
|
18
|
-
export * from './types/memory.js';
|
|
19
|
-
export * from './types/memory-context.js';
|
|
20
22
|
export * from './types/observability.js';
|
|
21
23
|
export * from './types/output-codec.js';
|
|
22
24
|
export * from './types/runtime.js';
|
package/dist/schemas/item.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare const ItemSchema: z.ZodCustom<Item, Item>;
|
|
|
24
24
|
type ItemSchemaCategory = keyof Required<ItemSchemaExtensions>;
|
|
25
25
|
export declare function mergeExtensions(a: ItemSchemaExtensions | undefined, b: ItemSchemaExtensions | undefined): ItemSchemaExtensions;
|
|
26
26
|
/**
|
|
27
|
-
* @public Runtime item validator with optional tool,
|
|
27
|
+
* @public Runtime item validator with optional tool, context-layer, and harness extension schemas.
|
|
28
28
|
*
|
|
29
29
|
* Extension schemas are pure shape validators (gate, not normalizer): on
|
|
30
30
|
* match the original value is returned unchanged, including fields the schema
|
package/dist/schemas/item.js
CHANGED
|
@@ -97,7 +97,7 @@ function schemaMismatch(category) {
|
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
|
-
* @public Runtime item validator with optional tool,
|
|
100
|
+
* @public Runtime item validator with optional tool, context-layer, and harness extension schemas.
|
|
101
101
|
*
|
|
102
102
|
* Extension schemas are pure shape validators (gate, not normalizer): on
|
|
103
103
|
* match the original value is returned unchanged, including fields the schema
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for JSON-serialisable workflow definitions.
|
|
3
|
+
*
|
|
4
|
+
* A `WorkflowDocument` is a portable, JSON-safe representation of a noetic
|
|
5
|
+
* step tree. It covers every step kind. The `run` node carries its body as a
|
|
6
|
+
* code STRING (not an in-process closure) dispatched through a subprocess
|
|
7
|
+
* adapter, keeping the document JSON-safe. The hydrator in
|
|
8
|
+
* `@noetic-tools/core` (`builders/workflow-hydrator.ts`) converts a validated
|
|
9
|
+
* document back into live `Step` objects via the existing builders.
|
|
10
|
+
*/
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
import type { SubHarnessKind } from '../types/sub-harness.js';
|
|
13
|
+
interface UntilAnyPredicate {
|
|
14
|
+
kind: 'any';
|
|
15
|
+
predicates: UntilPredicate[];
|
|
16
|
+
}
|
|
17
|
+
interface UntilAllPredicate {
|
|
18
|
+
kind: 'all';
|
|
19
|
+
predicates: UntilPredicate[];
|
|
20
|
+
}
|
|
21
|
+
/** @public Discriminated union of named until predicates usable in JSON workflows. */
|
|
22
|
+
export type UntilPredicate = {
|
|
23
|
+
kind: 'maxSteps';
|
|
24
|
+
n: number;
|
|
25
|
+
} | {
|
|
26
|
+
kind: 'maxCost';
|
|
27
|
+
usd: number;
|
|
28
|
+
} | {
|
|
29
|
+
kind: 'maxDuration';
|
|
30
|
+
ms: number;
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'noToolCalls';
|
|
33
|
+
} | {
|
|
34
|
+
kind: 'outputContains';
|
|
35
|
+
marker: string;
|
|
36
|
+
} | {
|
|
37
|
+
kind: 'outputEquals';
|
|
38
|
+
sentinel: string;
|
|
39
|
+
} | {
|
|
40
|
+
kind: 'converged';
|
|
41
|
+
threshold?: number;
|
|
42
|
+
} | UntilAnyPredicate | UntilAllPredicate;
|
|
43
|
+
/** @public Zod schema validating a named `until` predicate (including `any`/`all` combinators). */
|
|
44
|
+
export declare const UntilPredicateSchema: z.ZodType<UntilPredicate>;
|
|
45
|
+
/** @public ESM literal enum for merge strategies. */
|
|
46
|
+
export declare const MergeStrategy: {
|
|
47
|
+
readonly Last: 'last';
|
|
48
|
+
readonly First: 'first';
|
|
49
|
+
readonly Concat: 'concat';
|
|
50
|
+
};
|
|
51
|
+
/** @public Named merge strategy for fork nodes. */
|
|
52
|
+
export type MergeStrategy = (typeof MergeStrategy)[keyof typeof MergeStrategy];
|
|
53
|
+
/** @public Zod schema for the named merge strategy used by `fork` nodes. */
|
|
54
|
+
export declare const MergeStrategySchema: z.ZodEnum<{
|
|
55
|
+
concat: "concat";
|
|
56
|
+
first: "first";
|
|
57
|
+
last: "last";
|
|
58
|
+
}>;
|
|
59
|
+
declare const ModelParamsSchema: z.ZodObject<{
|
|
60
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
topP: z.ZodOptional<z.ZodNumber>;
|
|
62
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
63
|
+
stopSequences: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
/**
|
|
66
|
+
* A uniform tool entry on an `llm` node. Every entry is an object keyed by
|
|
67
|
+
* `type`:
|
|
68
|
+
* - A CLIENT tool is `{ type: "<registered-tool-name>" }`. The hydrator
|
|
69
|
+
* resolves `type` against the tool registry; `parameters` (if present) is
|
|
70
|
+
* ignored — client tools receive their call args from the model at runtime.
|
|
71
|
+
* - A SERVER tool is `{ type: "openrouter:web_search" | "openrouter:web_fetch",
|
|
72
|
+
* parameters?: {...} }`. The provider executes it; `parameters` keys are
|
|
73
|
+
* camelCase (e.g. `maxResults`, `searchContextSize`) — the SDK re-serialises
|
|
74
|
+
* them and silently drops unknown keys.
|
|
75
|
+
*
|
|
76
|
+
* Server vs client is decided by the `type` value (a reserved `openrouter:*`
|
|
77
|
+
* server-tool literal vs an arbitrary tool name), not by the entry's shape.
|
|
78
|
+
*/
|
|
79
|
+
declare const LlmToolEntrySchema: z.ZodObject<{
|
|
80
|
+
type: z.ZodString;
|
|
81
|
+
parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
82
|
+
}, z.core.$strip>;
|
|
83
|
+
/** Retry policy for a `run` node, mirroring `RetryPolicy` in `@noetic-tools/types`. */
|
|
84
|
+
declare const RetryPolicySchema: z.ZodObject<{
|
|
85
|
+
maxAttempts: z.ZodNumber;
|
|
86
|
+
backoff: z.ZodEnum<{
|
|
87
|
+
exponential: "exponential";
|
|
88
|
+
fixed: "fixed";
|
|
89
|
+
linear: "linear";
|
|
90
|
+
}>;
|
|
91
|
+
initialDelay: z.ZodNumber;
|
|
92
|
+
maxDelay: z.ZodOptional<z.ZodNumber>;
|
|
93
|
+
}, z.core.$strip>;
|
|
94
|
+
declare const HarnessSettingsSchema: z.ZodObject<{
|
|
95
|
+
model: z.ZodOptional<z.ZodString>;
|
|
96
|
+
permissionMode: z.ZodOptional<z.ZodEnum<{
|
|
97
|
+
acceptEdits: "acceptEdits";
|
|
98
|
+
bypassPermissions: "bypassPermissions";
|
|
99
|
+
default: "default";
|
|
100
|
+
plan: "plan";
|
|
101
|
+
}>>;
|
|
102
|
+
maxTurns: z.ZodOptional<z.ZodNumber>;
|
|
103
|
+
allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
104
|
+
extra: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
105
|
+
}, z.core.$strip>;
|
|
106
|
+
declare const HarnessSessionPolicySchema: z.ZodObject<{
|
|
107
|
+
reuse: z.ZodOptional<z.ZodString>;
|
|
108
|
+
onComplete: z.ZodOptional<z.ZodEnum<{
|
|
109
|
+
destroy: "destroy";
|
|
110
|
+
detach: "detach";
|
|
111
|
+
stop: "stop";
|
|
112
|
+
}>>;
|
|
113
|
+
}, z.core.$strip>;
|
|
114
|
+
interface WorkflowNodeBase {
|
|
115
|
+
id: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* A reference to a streaming `OutputCodec` for an `llm` node's structured
|
|
119
|
+
* output. The hydrator resolves `library` from `HydrationContext.uiLibraries`
|
|
120
|
+
* to a live codec (e.g. `openUi(myLibrary)` from `@noetic-tools/openui`), the
|
|
121
|
+
* same registry-resolution pattern sub-harness nodes use for adapters. Kept a
|
|
122
|
+
* *reference* because a codec is a runtime object, not JSON-expressible.
|
|
123
|
+
*/
|
|
124
|
+
export interface OutputCodecRef {
|
|
125
|
+
/** The codec dialect. Only `'openui'` is defined today. */
|
|
126
|
+
codec: 'openui';
|
|
127
|
+
/** Registry key resolved from `HydrationContext.uiLibraries`. */
|
|
128
|
+
library: string;
|
|
129
|
+
}
|
|
130
|
+
export interface LlmWorkflowNode extends WorkflowNodeBase {
|
|
131
|
+
kind: 'llm';
|
|
132
|
+
model?: string;
|
|
133
|
+
instructions: string;
|
|
134
|
+
/**
|
|
135
|
+
* Tool entries. Every entry is an object `{ type, parameters? }`. A CLIENT
|
|
136
|
+
* tool is `{ type: "<registered-tool-name>" }` (resolved from the registry);
|
|
137
|
+
* a SERVER tool is `{ type: "openrouter:web_search" | "openrouter:web_fetch",
|
|
138
|
+
* parameters?: {...} }` (executed by the provider). Client vs server is
|
|
139
|
+
* decided by the `type` value.
|
|
140
|
+
*/
|
|
141
|
+
tools?: z.infer<typeof LlmToolEntrySchema>[];
|
|
142
|
+
params?: z.infer<typeof ModelParamsSchema>;
|
|
143
|
+
/** Streaming output-codec reference, resolved from `HydrationContext.uiLibraries`. */
|
|
144
|
+
output?: OutputCodecRef;
|
|
145
|
+
}
|
|
146
|
+
export interface ToolWorkflowNode extends WorkflowNodeBase {
|
|
147
|
+
kind: 'tool';
|
|
148
|
+
toolName: string;
|
|
149
|
+
args?: Record<string, unknown>;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* A node that runs a serialised code body. Unlike the programmatic `step.run`
|
|
153
|
+
* (which carries a closure), the JSON form carries `execute` as a code STRING.
|
|
154
|
+
* The code is never eval'd in-process (Cloudflare Workers forbid eval); it is
|
|
155
|
+
* dispatched through a subprocess adapter (`ctx.subprocess`, or a named adapter
|
|
156
|
+
* resolved by ref). Execution therefore requires a subprocess adapter capable
|
|
157
|
+
* of running the code and returning its stdout.
|
|
158
|
+
*/
|
|
159
|
+
export interface RunWorkflowNode extends WorkflowNodeBase {
|
|
160
|
+
kind: 'run';
|
|
161
|
+
/** Source code executed in the subprocess. Receives the step input on stdin. */
|
|
162
|
+
execute: string;
|
|
163
|
+
/** Optional retry policy applied to the step. */
|
|
164
|
+
retry?: z.infer<typeof RetryPolicySchema>;
|
|
165
|
+
/** Named subprocess adapter ref; defaults to `ctx.subprocess` when omitted. */
|
|
166
|
+
subprocess?: string;
|
|
167
|
+
}
|
|
168
|
+
export interface BranchRoute {
|
|
169
|
+
match: string;
|
|
170
|
+
target: WorkflowNode;
|
|
171
|
+
}
|
|
172
|
+
export interface BranchWorkflowNode extends WorkflowNodeBase {
|
|
173
|
+
kind: 'branch';
|
|
174
|
+
routes: BranchRoute[];
|
|
175
|
+
default?: WorkflowNode;
|
|
176
|
+
}
|
|
177
|
+
export interface ForkWorkflowNode extends WorkflowNodeBase {
|
|
178
|
+
kind: 'fork';
|
|
179
|
+
mode: 'race' | 'all' | 'settle';
|
|
180
|
+
/**
|
|
181
|
+
* Static fan-out: one child per entry. Mutually exclusive with `each` —
|
|
182
|
+
* supply exactly one.
|
|
183
|
+
*/
|
|
184
|
+
paths?: WorkflowNode[];
|
|
185
|
+
/**
|
|
186
|
+
* Dynamic fan-out: instantiate this body template once per item of a
|
|
187
|
+
* runtime-produced array (data-dependent N). Mutually exclusive with `paths`.
|
|
188
|
+
*/
|
|
189
|
+
each?: WorkflowNode;
|
|
190
|
+
/**
|
|
191
|
+
* Selector key into the fork input (parsed as JSON) locating the array to
|
|
192
|
+
* fan out over. When omitted, the input string itself is parsed as a JSON
|
|
193
|
+
* array. Only meaningful with `each`.
|
|
194
|
+
*/
|
|
195
|
+
over?: string;
|
|
196
|
+
merge?: MergeStrategy;
|
|
197
|
+
concurrency?: number;
|
|
198
|
+
}
|
|
199
|
+
export interface SpawnWorkflowNode extends WorkflowNodeBase {
|
|
200
|
+
kind: 'spawn';
|
|
201
|
+
child: WorkflowNode;
|
|
202
|
+
timeout?: number;
|
|
203
|
+
/**
|
|
204
|
+
* Memory layers the child runs with, by registered name (resolved from
|
|
205
|
+
* `HydrationContext.layers`, like `provide`). Omit to inherit the parent's
|
|
206
|
+
* layers — the default spawn behaviour. Naming layers here REPLACES the
|
|
207
|
+
* inherited set for the child, so list every layer the child needs.
|
|
208
|
+
*/
|
|
209
|
+
layers?: string[];
|
|
210
|
+
}
|
|
211
|
+
export interface ProvideWorkflowNode extends WorkflowNodeBase {
|
|
212
|
+
kind: 'provide';
|
|
213
|
+
child: WorkflowNode;
|
|
214
|
+
layers: string[];
|
|
215
|
+
}
|
|
216
|
+
export interface LoopWorkflowNode extends WorkflowNodeBase {
|
|
217
|
+
kind: 'loop';
|
|
218
|
+
body: WorkflowNode;
|
|
219
|
+
until: UntilPredicate;
|
|
220
|
+
maxIterations?: number;
|
|
221
|
+
}
|
|
222
|
+
export interface SequenceWorkflowNode extends WorkflowNodeBase {
|
|
223
|
+
kind: 'sequence';
|
|
224
|
+
steps: WorkflowNode[];
|
|
225
|
+
}
|
|
226
|
+
export interface EveryWorkflowNode extends WorkflowNodeBase {
|
|
227
|
+
kind: 'every';
|
|
228
|
+
step: WorkflowNode;
|
|
229
|
+
ms: number;
|
|
230
|
+
onError?: 'continue' | 'fail';
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* A node that delegates a turn to a coding-agent harness. `kind` is the harness
|
|
234
|
+
* id (e.g. `claude-code`); the hydrator resolves the matching adapter from the
|
|
235
|
+
* workflow's harness registry.
|
|
236
|
+
*/
|
|
237
|
+
export interface SubHarnessWorkflowNode extends WorkflowNodeBase {
|
|
238
|
+
kind: SubHarnessKind;
|
|
239
|
+
prompt: string;
|
|
240
|
+
instructions?: string;
|
|
241
|
+
settings?: z.infer<typeof HarnessSettingsSchema>;
|
|
242
|
+
session?: z.infer<typeof HarnessSessionPolicySchema>;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* A node that runs another workflow document as a sub-step. The document is
|
|
246
|
+
* either inline or a named reference resolved from `HydrationContext.workflows`
|
|
247
|
+
* at execution time. Supply exactly one of `document` / `ref`.
|
|
248
|
+
*/
|
|
249
|
+
export interface SubflowWorkflowNode extends WorkflowNodeBase {
|
|
250
|
+
kind: 'subflow';
|
|
251
|
+
/** Inline sub-workflow. Mutually exclusive with `ref`. */
|
|
252
|
+
document?: WorkflowDocument;
|
|
253
|
+
/** Named sub-workflow resolved from `HydrationContext.workflows`. Mutually exclusive with `document`. */
|
|
254
|
+
ref?: string;
|
|
255
|
+
/** Literal input passed to the sub-workflow; defaults to the node's runtime input. */
|
|
256
|
+
input?: string;
|
|
257
|
+
}
|
|
258
|
+
/** @public Discriminated union of all JSON-serialisable workflow node kinds. */
|
|
259
|
+
export type WorkflowNode = LlmWorkflowNode | ToolWorkflowNode | RunWorkflowNode | BranchWorkflowNode | ForkWorkflowNode | SpawnWorkflowNode | ProvideWorkflowNode | LoopWorkflowNode | SequenceWorkflowNode | EveryWorkflowNode | SubflowWorkflowNode | SubHarnessWorkflowNode;
|
|
260
|
+
/** @public Zod schema validating a single `WorkflowNode` (any JSON-safe kind). */
|
|
261
|
+
export declare const WorkflowNodeSchema: z.ZodType<WorkflowNode>;
|
|
262
|
+
/** @public Top-level envelope for a JSON workflow definition. */
|
|
263
|
+
export interface WorkflowDocument {
|
|
264
|
+
version: 1;
|
|
265
|
+
root: WorkflowNode;
|
|
266
|
+
}
|
|
267
|
+
/** @public Zod schema validating a complete `WorkflowDocument`. */
|
|
268
|
+
export declare const WorkflowDocumentSchema: z.ZodType<WorkflowDocument>;
|
|
269
|
+
/** Validates a candidate workflow document. Throws `ZodError` on invalid input. */
|
|
270
|
+
export declare function validateWorkflow(input: unknown): WorkflowDocument;
|
|
271
|
+
/** Walks a workflow tree depth-first, yielding each node. */
|
|
272
|
+
export declare function walkWorkflow(node: WorkflowNode): Iterable<WorkflowNode>;
|
|
273
|
+
/** A flattened, JSON-safe view of a workflow tree: its nodes and parent→child edges. */
|
|
274
|
+
export interface WorkflowGraph {
|
|
275
|
+
nodes: Array<{
|
|
276
|
+
id: string;
|
|
277
|
+
kind: WorkflowNode['kind'];
|
|
278
|
+
}>;
|
|
279
|
+
edges: Array<{
|
|
280
|
+
from: string;
|
|
281
|
+
to: string;
|
|
282
|
+
}>;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Flattens a workflow tree into a node + edge list — the static "potential
|
|
286
|
+
* paths" of the DAG, suitable for attaching to a trace span so observers can
|
|
287
|
+
* reconstruct the declared graph independent of which branches actually ran.
|
|
288
|
+
* `subflow` refs are leaves: their target documents resolve at hydration time.
|
|
289
|
+
*/
|
|
290
|
+
export declare function workflowGraph(root: WorkflowNode): WorkflowGraph;
|
|
291
|
+
/**
|
|
292
|
+
* Returns the maximum depth of a workflow tree.
|
|
293
|
+
* Leaf nodes (`llm`, `tool`) have depth 0. Structural nodes add +1.
|
|
294
|
+
* A `subflow` ref counts as a leaf — depth does not see through named refs.
|
|
295
|
+
*/
|
|
296
|
+
export declare function workflowDepth(node: WorkflowNode): number;
|
|
297
|
+
export {};
|