@noetic-tools/core 3.2.0 → 5.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.
- package/dist/adapters/in-memory-subprocess/manifest-persistence.d.ts +1 -1
- package/dist/adapters/in-memory-subprocess/types.d.ts +1 -1
- package/dist/adapters/openrouter.d.ts +2 -2
- package/dist/adapters/openrouter.js +2 -2
- package/dist/builders/context-builder.d.ts +11 -0
- package/dist/builders/context-builder.js +15 -0
- package/dist/builders/context-option.d.ts +23 -0
- package/dist/builders/context-option.js +22 -0
- package/dist/builders/control-flow-builders.d.ts +19 -19
- package/dist/builders/every.d.ts +4 -4
- package/dist/builders/layer-provides-builders.d.ts +1 -1
- package/dist/builders/layer-provides-builders.js +1 -1
- package/dist/builders/loop-builder.d.ts +3 -3
- package/dist/builders/provide-builder.d.ts +14 -7
- package/dist/builders/provide-builder.js +15 -4
- package/dist/builders/spawn-builder.d.ts +8 -6
- package/dist/builders/spawn-builder.js +7 -2
- package/dist/builders/step-builders.d.ts +19 -20
- package/dist/builders/tool-builder.d.ts +9 -5
- package/dist/builders/tool-builder.js +3 -2
- package/dist/builders/workflow-hydrator.d.ts +17 -4
- package/dist/builders/workflow-hydrator.js +87 -8
- package/dist/builders/workflow-step.d.ts +61 -0
- package/dist/builders/workflow-step.js +126 -0
- package/dist/conditions/conditions.d.ts +17 -17
- package/dist/conditions/conditions.js +1 -1
- package/dist/deprecated.d.ts +30 -0
- package/dist/deprecated.js +28 -0
- package/dist/harness/agent-harness.d.ts +42 -26
- package/dist/harness/agent-harness.js +68 -21
- package/dist/harness/deps/{memory.d.ts → context.d.ts} +2 -2
- package/dist/harness/deps/{memory.js → context.js} +1 -1
- package/dist/harness/deps/types.d.ts +1 -1
- package/dist/harness/model-schema.d.ts +2 -2
- package/dist/index.d.ts +21 -17
- package/dist/index.js +14 -8
- package/dist/interpreter/action-deps.d.ts +3 -3
- package/dist/interpreter/action-deps.js +2 -2
- package/dist/interpreter/action-types.d.ts +1 -1
- package/dist/interpreter/collect-tools.d.ts +1 -1
- package/dist/interpreter/execute-action.d.ts +10 -10
- package/dist/interpreter/execute-action.js +13 -13
- package/dist/interpreter/execute-control.d.ts +4 -4
- package/dist/interpreter/execute-control.js +1 -1
- package/dist/interpreter/execute-sub-harness.d.ts +1 -1
- package/dist/interpreter/execute.d.ts +3 -3
- package/dist/interpreter/execute.js +78 -31
- package/dist/interpreter/step-dispatcher.d.ts +3 -3
- package/dist/interpreter/sub-harness-events.d.ts +2 -2
- package/dist/interpreter/typeguards.d.ts +4 -4
- package/dist/patterns/dynamic-workflow.d.ts +7 -4
- package/dist/patterns/dynamic-workflow.js +2 -0
- package/dist/patterns/interview.d.ts +2 -2
- package/dist/patterns/plans.d.ts +5 -5
- package/dist/patterns/ralph-wiggum.d.ts +2 -2
- package/dist/patterns/react.d.ts +7 -5
- package/dist/patterns/react.js +6 -4
- package/dist/portable/builders.js +2 -0
- package/dist/portable/context-layers.d.ts +8 -0
- package/dist/portable/context-layers.js +8 -0
- package/dist/portable.d.ts +2 -2
- package/dist/portable.js +2 -2
- package/dist/runtime/channel-store.d.ts +33 -0
- package/dist/runtime/channel-store.js +297 -11
- package/dist/runtime/context-deps.d.ts +2 -2
- package/dist/runtime/context-deps.js +1 -1
- package/dist/runtime/context-impl.d.ts +10 -8
- package/dist/runtime/context-impl.js +11 -7
- package/dist/runtime/context-type-deps.d.ts +1 -1
- package/dist/runtime/durable/checkpoint-store.d.ts +1 -1
- package/dist/runtime/durable/harness-checkpoints.d.ts +2 -3
- package/dist/runtime/durable/harness-checkpoints.js +2 -3
- package/dist/runtime/durable/step-ledger.d.ts +1 -1
- package/dist/runtime/durable/step-ledger.js +1 -1
- package/dist/runtime/in-memory-storage.d.ts +1 -1
- package/dist/runtime/session-runner.d.ts +1 -1
- package/dist/runtime/step-registry.d.ts +3 -3
- package/dist/runtime/{tool-memory.d.ts → tool-context.d.ts} +1 -2
- package/dist/runtime/{tool-memory.js → tool-context.js} +5 -2
- package/dist/runtime/tool-ui.d.ts +1 -1
- package/dist/runtime/tool-ui.js +1 -1
- package/dist/schemas/workflow.d.ts +5 -279
- package/dist/schemas/workflow.js +4 -376
- package/dist/types/mutable-context.d.ts +2 -2
- package/dist/types/step-registrar.d.ts +1 -1
- package/dist/unstable.d.ts +5 -5
- package/dist/unstable.js +3 -3
- package/dist/until/predicates.d.ts +1 -1
- package/package.json +4 -4
- package/schema/noetic-workflow.schema.json +28 -0
- package/dist/builders/memory-builder.d.ts +0 -11
- package/dist/builders/memory-builder.js +0 -15
- package/dist/patterns/flow.d.ts +0 -2
- package/dist/patterns/flow.js +0 -1
- package/dist/portable/memory-layers.d.ts +0 -8
- package/dist/portable/memory-layers.js +0 -8
package/dist/schemas/workflow.js
CHANGED
|
@@ -1,378 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
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
|
-
* `builders/workflow-hydrator.ts` converts a validated document back into live
|
|
9
|
-
* `Step` objects via the existing builders.
|
|
2
|
+
* The JSON workflow schema lives in `@noetic-tools/types` so the memory
|
|
3
|
+
* package (which must not import core) can validate workflow documents.
|
|
4
|
+
* This barrel keeps core's public and intra-core import paths unchanged.
|
|
10
5
|
*/
|
|
11
|
-
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region Until Predicate Schemas
|
|
14
|
-
const MaxStepsPredicateSchema = z.object({
|
|
15
|
-
kind: z.literal('maxSteps'),
|
|
16
|
-
n: z.number().int().positive(),
|
|
17
|
-
});
|
|
18
|
-
const MaxCostPredicateSchema = z.object({
|
|
19
|
-
kind: z.literal('maxCost'),
|
|
20
|
-
usd: z.number().positive(),
|
|
21
|
-
});
|
|
22
|
-
const MaxDurationPredicateSchema = z.object({
|
|
23
|
-
kind: z.literal('maxDuration'),
|
|
24
|
-
ms: z.number().positive(),
|
|
25
|
-
});
|
|
26
|
-
const NoToolCallsPredicateSchema = z.object({
|
|
27
|
-
kind: z.literal('noToolCalls'),
|
|
28
|
-
});
|
|
29
|
-
const OutputContainsPredicateSchema = z.object({
|
|
30
|
-
kind: z.literal('outputContains'),
|
|
31
|
-
marker: z.string().min(1),
|
|
32
|
-
});
|
|
33
|
-
const OutputEqualsPredicateSchema = z.object({
|
|
34
|
-
kind: z.literal('outputEquals'),
|
|
35
|
-
sentinel: z.string().min(1),
|
|
36
|
-
});
|
|
37
|
-
const ConvergedPredicateSchema = z.object({
|
|
38
|
-
kind: z.literal('converged'),
|
|
39
|
-
threshold: z.number().min(0).max(1).optional(),
|
|
40
|
-
});
|
|
41
|
-
const UntilPredicateRef = z.lazy(() => UntilPredicateSchema);
|
|
42
|
-
const AnyPredicateSchema = z.object({
|
|
43
|
-
kind: z.literal('any'),
|
|
44
|
-
predicates: z.array(UntilPredicateRef).min(1),
|
|
45
|
-
});
|
|
46
|
-
const AllPredicateSchema = z.object({
|
|
47
|
-
kind: z.literal('all'),
|
|
48
|
-
predicates: z.array(UntilPredicateRef).min(1),
|
|
49
|
-
});
|
|
50
|
-
/** @public Zod schema validating a named `until` predicate (including `any`/`all` combinators). */
|
|
51
|
-
export const UntilPredicateSchema = z
|
|
52
|
-
.union([
|
|
53
|
-
MaxStepsPredicateSchema,
|
|
54
|
-
MaxCostPredicateSchema,
|
|
55
|
-
MaxDurationPredicateSchema,
|
|
56
|
-
NoToolCallsPredicateSchema,
|
|
57
|
-
OutputContainsPredicateSchema,
|
|
58
|
-
OutputEqualsPredicateSchema,
|
|
59
|
-
ConvergedPredicateSchema,
|
|
60
|
-
AnyPredicateSchema,
|
|
61
|
-
AllPredicateSchema,
|
|
62
|
-
])
|
|
63
|
-
.meta({
|
|
64
|
-
id: 'UntilPredicate',
|
|
65
|
-
title: 'UntilPredicate',
|
|
66
|
-
});
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region Merge Strategy
|
|
69
|
-
/** @public ESM literal enum for merge strategies. */
|
|
70
|
-
export const MergeStrategy = {
|
|
71
|
-
Last: 'last',
|
|
72
|
-
First: 'first',
|
|
73
|
-
Concat: 'concat',
|
|
74
|
-
};
|
|
75
|
-
/** @public Zod schema for the named merge strategy used by `fork` nodes. */
|
|
76
|
-
export const MergeStrategySchema = z.enum([
|
|
77
|
-
'last',
|
|
78
|
-
'first',
|
|
79
|
-
'concat',
|
|
80
|
-
]);
|
|
81
|
-
//#endregion
|
|
82
|
-
//#region Model Params
|
|
83
|
-
const ModelParamsSchema = z.object({
|
|
84
|
-
temperature: z.number().min(0).optional(),
|
|
85
|
-
topP: z.number().min(0).max(1).optional(),
|
|
86
|
-
maxTokens: z.number().int().positive().optional(),
|
|
87
|
-
stopSequences: z.array(z.string()).optional(),
|
|
88
|
-
});
|
|
89
|
-
//#endregion
|
|
90
|
-
//#region Tool Entries
|
|
91
|
-
/**
|
|
92
|
-
* A uniform tool entry on an `llm` node. Every entry is an object keyed by
|
|
93
|
-
* `type`:
|
|
94
|
-
* - A CLIENT tool is `{ type: "<registered-tool-name>" }`. The hydrator
|
|
95
|
-
* resolves `type` against the tool registry; `parameters` (if present) is
|
|
96
|
-
* ignored — client tools receive their call args from the model at runtime.
|
|
97
|
-
* - A SERVER tool is `{ type: "openrouter:web_search" | "openrouter:web_fetch",
|
|
98
|
-
* parameters?: {...} }`. The provider executes it; `parameters` keys are
|
|
99
|
-
* camelCase (e.g. `maxResults`, `searchContextSize`) — the SDK re-serialises
|
|
100
|
-
* them and silently drops unknown keys.
|
|
101
|
-
*
|
|
102
|
-
* Server vs client is decided by the `type` value (a reserved `openrouter:*`
|
|
103
|
-
* server-tool literal vs an arbitrary tool name), not by the entry's shape.
|
|
104
|
-
*/
|
|
105
|
-
const LlmToolEntrySchema = z.object({
|
|
106
|
-
type: z.string().min(1),
|
|
107
|
-
parameters: z.record(z.string(), z.unknown()).optional(),
|
|
108
|
-
});
|
|
109
|
-
//#endregion
|
|
110
|
-
//#region Retry Policy
|
|
111
|
-
/** Retry policy for a `run` node, mirroring `RetryPolicy` in `@noetic-tools/types`. */
|
|
112
|
-
const RetryPolicySchema = z.object({
|
|
113
|
-
maxAttempts: z.number().int().positive(),
|
|
114
|
-
backoff: z.enum([
|
|
115
|
-
'fixed',
|
|
116
|
-
'linear',
|
|
117
|
-
'exponential',
|
|
118
|
-
]),
|
|
119
|
-
initialDelay: z.number().nonnegative(),
|
|
120
|
-
maxDelay: z.number().nonnegative().optional(),
|
|
121
|
-
});
|
|
122
|
-
//#endregion
|
|
123
|
-
//#region SubHarness Settings
|
|
124
|
-
const HarnessSettingsSchema = z.object({
|
|
125
|
-
model: z.string().optional(),
|
|
126
|
-
permissionMode: z
|
|
127
|
-
.enum([
|
|
128
|
-
'default',
|
|
129
|
-
'plan',
|
|
130
|
-
'acceptEdits',
|
|
131
|
-
'bypassPermissions',
|
|
132
|
-
])
|
|
133
|
-
.optional(),
|
|
134
|
-
maxTurns: z.number().int().positive().optional(),
|
|
135
|
-
allowedTools: z.array(z.string()).optional(),
|
|
136
|
-
extra: z.record(z.string(), z.unknown()).optional(),
|
|
137
|
-
});
|
|
138
|
-
const HarnessSessionPolicySchema = z.object({
|
|
139
|
-
reuse: z.string().min(1).optional(),
|
|
140
|
-
onComplete: z
|
|
141
|
-
.enum([
|
|
142
|
-
'stop',
|
|
143
|
-
'detach',
|
|
144
|
-
'destroy',
|
|
145
|
-
])
|
|
146
|
-
.optional(),
|
|
147
|
-
});
|
|
148
|
-
//#endregion
|
|
149
|
-
//#region Workflow Node Schema
|
|
150
|
-
const WorkflowNodeRef = z.lazy(() => WorkflowNodeSchema);
|
|
151
|
-
const SHARED_FIELDS = {
|
|
152
|
-
id: z.string().min(1),
|
|
153
|
-
};
|
|
154
|
-
const OutputCodecRefSchema = z.object({
|
|
155
|
-
codec: z.literal('openui'),
|
|
156
|
-
library: z.string().min(1),
|
|
157
|
-
});
|
|
158
|
-
const LlmNodeSchema = z.object({
|
|
159
|
-
kind: z.literal('llm'),
|
|
160
|
-
...SHARED_FIELDS,
|
|
161
|
-
model: z.string().optional(),
|
|
162
|
-
instructions: z.string(),
|
|
163
|
-
tools: z.array(LlmToolEntrySchema).optional(),
|
|
164
|
-
params: ModelParamsSchema.optional(),
|
|
165
|
-
output: OutputCodecRefSchema.optional(),
|
|
166
|
-
});
|
|
167
|
-
const ToolNodeSchema = z.object({
|
|
168
|
-
kind: z.literal('tool'),
|
|
169
|
-
...SHARED_FIELDS,
|
|
170
|
-
toolName: z.string().min(1),
|
|
171
|
-
args: z.record(z.string(), z.unknown()).optional(),
|
|
172
|
-
});
|
|
173
|
-
const RunNodeSchema = z.object({
|
|
174
|
-
kind: z.literal('run'),
|
|
175
|
-
...SHARED_FIELDS,
|
|
176
|
-
execute: z.string().min(1),
|
|
177
|
-
retry: RetryPolicySchema.optional(),
|
|
178
|
-
subprocess: z.string().min(1).optional(),
|
|
179
|
-
});
|
|
180
|
-
const BranchRouteSchema = z.object({
|
|
181
|
-
match: z.string().min(1),
|
|
182
|
-
target: z.lazy(() => WorkflowNodeSchema),
|
|
183
|
-
});
|
|
184
|
-
const BranchNodeSchema = z.object({
|
|
185
|
-
kind: z.literal('branch'),
|
|
186
|
-
...SHARED_FIELDS,
|
|
187
|
-
routes: z.array(BranchRouteSchema).min(1),
|
|
188
|
-
default: WorkflowNodeRef.optional(),
|
|
189
|
-
});
|
|
190
|
-
const ForkNodeSchema = z
|
|
191
|
-
.object({
|
|
192
|
-
kind: z.literal('fork'),
|
|
193
|
-
...SHARED_FIELDS,
|
|
194
|
-
mode: z.enum([
|
|
195
|
-
'race',
|
|
196
|
-
'all',
|
|
197
|
-
'settle',
|
|
198
|
-
]),
|
|
199
|
-
paths: z.array(WorkflowNodeRef).min(1).optional(),
|
|
200
|
-
each: WorkflowNodeRef.optional(),
|
|
201
|
-
over: z.string().min(1).optional(),
|
|
202
|
-
merge: MergeStrategySchema.optional(),
|
|
203
|
-
concurrency: z.number().int().positive().optional(),
|
|
204
|
-
})
|
|
205
|
-
.refine((node) => (node.paths === undefined) !== (node.each === undefined), {
|
|
206
|
-
message: "fork node requires exactly one of 'paths' (static) or 'each' (dynamic).",
|
|
207
|
-
});
|
|
208
|
-
const SpawnNodeSchema = z.object({
|
|
209
|
-
kind: z.literal('spawn'),
|
|
210
|
-
...SHARED_FIELDS,
|
|
211
|
-
child: WorkflowNodeRef,
|
|
212
|
-
timeout: z.number().positive().optional(),
|
|
213
|
-
layers: z.array(z.string().min(1)).min(1).optional(),
|
|
214
|
-
});
|
|
215
|
-
const ProvideNodeSchema = z.object({
|
|
216
|
-
kind: z.literal('provide'),
|
|
217
|
-
...SHARED_FIELDS,
|
|
218
|
-
child: WorkflowNodeRef,
|
|
219
|
-
layers: z.array(z.string().min(1)).min(1),
|
|
220
|
-
});
|
|
221
|
-
const LoopNodeSchema = z.object({
|
|
222
|
-
kind: z.literal('loop'),
|
|
223
|
-
...SHARED_FIELDS,
|
|
224
|
-
body: WorkflowNodeRef,
|
|
225
|
-
until: UntilPredicateSchema,
|
|
226
|
-
maxIterations: z.number().int().positive().optional(),
|
|
227
|
-
});
|
|
228
|
-
const SequenceNodeSchema = z.object({
|
|
229
|
-
kind: z.literal('sequence'),
|
|
230
|
-
...SHARED_FIELDS,
|
|
231
|
-
steps: z.array(WorkflowNodeRef).min(1),
|
|
232
|
-
});
|
|
233
|
-
const EveryNodeSchema = z.object({
|
|
234
|
-
kind: z.literal('every'),
|
|
235
|
-
...SHARED_FIELDS,
|
|
236
|
-
step: WorkflowNodeRef,
|
|
237
|
-
ms: z.number().nonnegative(),
|
|
238
|
-
onError: z
|
|
239
|
-
.enum([
|
|
240
|
-
'continue',
|
|
241
|
-
'fail',
|
|
242
|
-
])
|
|
243
|
-
.optional(),
|
|
244
|
-
});
|
|
245
|
-
/** Builds the schema for a single harness node kind (`claude-code`, `codex`, …). */
|
|
246
|
-
function subHarnessNodeSchema(kind) {
|
|
247
|
-
return z.object({
|
|
248
|
-
kind: z.literal(kind),
|
|
249
|
-
...SHARED_FIELDS,
|
|
250
|
-
prompt: z.string().min(1),
|
|
251
|
-
instructions: z.string().optional(),
|
|
252
|
-
settings: HarnessSettingsSchema.optional(),
|
|
253
|
-
session: HarnessSessionPolicySchema.optional(),
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
const ClaudeCodeNodeSchema = subHarnessNodeSchema('claude-code');
|
|
257
|
-
const CodexNodeSchema = subHarnessNodeSchema('codex');
|
|
258
|
-
const OpencodeNodeSchema = subHarnessNodeSchema('opencode');
|
|
259
|
-
const PiNodeSchema = subHarnessNodeSchema('pi');
|
|
260
|
-
/** @public Zod schema validating a single `WorkflowNode` (any JSON-safe kind). */
|
|
261
|
-
export const WorkflowNodeSchema = z
|
|
262
|
-
.discriminatedUnion('kind', [
|
|
263
|
-
LlmNodeSchema,
|
|
264
|
-
ToolNodeSchema,
|
|
265
|
-
RunNodeSchema,
|
|
266
|
-
BranchNodeSchema,
|
|
267
|
-
ForkNodeSchema,
|
|
268
|
-
SpawnNodeSchema,
|
|
269
|
-
ProvideNodeSchema,
|
|
270
|
-
LoopNodeSchema,
|
|
271
|
-
SequenceNodeSchema,
|
|
272
|
-
EveryNodeSchema,
|
|
273
|
-
ClaudeCodeNodeSchema,
|
|
274
|
-
CodexNodeSchema,
|
|
275
|
-
OpencodeNodeSchema,
|
|
276
|
-
PiNodeSchema,
|
|
277
|
-
])
|
|
278
|
-
.meta({
|
|
279
|
-
id: 'WorkflowNode',
|
|
280
|
-
title: 'WorkflowNode',
|
|
281
|
-
});
|
|
282
|
-
/** @public Zod schema validating a complete `WorkflowDocument`. */
|
|
283
|
-
export const WorkflowDocumentSchema = z
|
|
284
|
-
.object({
|
|
285
|
-
version: z.literal(1),
|
|
286
|
-
root: WorkflowNodeSchema,
|
|
287
|
-
})
|
|
288
|
-
.meta({
|
|
289
|
-
id: 'WorkflowDocument',
|
|
290
|
-
title: 'WorkflowDocument',
|
|
291
|
-
description: 'A portable, JSON-safe representation of a Noetic step tree.',
|
|
292
|
-
});
|
|
293
|
-
//#endregion
|
|
294
|
-
//#region Helpers
|
|
295
|
-
/** Returns the direct child nodes of a workflow node. Leaf nodes return an empty array. */
|
|
296
|
-
function childNodes(node) {
|
|
297
|
-
switch (node.kind) {
|
|
298
|
-
case 'sequence':
|
|
299
|
-
return node.steps;
|
|
300
|
-
case 'fork':
|
|
301
|
-
if (node.each) {
|
|
302
|
-
return [
|
|
303
|
-
node.each,
|
|
304
|
-
];
|
|
305
|
-
}
|
|
306
|
-
return node.paths ?? [];
|
|
307
|
-
case 'spawn':
|
|
308
|
-
case 'provide':
|
|
309
|
-
return [
|
|
310
|
-
node.child,
|
|
311
|
-
];
|
|
312
|
-
case 'loop':
|
|
313
|
-
return [
|
|
314
|
-
node.body,
|
|
315
|
-
];
|
|
316
|
-
case 'every':
|
|
317
|
-
return [
|
|
318
|
-
node.step,
|
|
319
|
-
];
|
|
320
|
-
case 'branch': {
|
|
321
|
-
const children = node.routes.map((r) => r.target);
|
|
322
|
-
if (node.default) {
|
|
323
|
-
children.push(node.default);
|
|
324
|
-
}
|
|
325
|
-
return children;
|
|
326
|
-
}
|
|
327
|
-
default:
|
|
328
|
-
return [];
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
/** Validates a candidate workflow document. Throws `ZodError` on invalid input. */
|
|
332
|
-
export function validateWorkflow(input) {
|
|
333
|
-
return WorkflowDocumentSchema.parse(input);
|
|
334
|
-
}
|
|
335
|
-
/** Walks a workflow tree depth-first, yielding each node. */
|
|
336
|
-
export function* walkWorkflow(node) {
|
|
337
|
-
yield node;
|
|
338
|
-
for (const child of childNodes(node)) {
|
|
339
|
-
yield* walkWorkflow(child);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
/**
|
|
343
|
-
* Flattens a workflow tree into a node + edge list — the static "potential
|
|
344
|
-
* paths" of the DAG, suitable for attaching to a trace span so observers can
|
|
345
|
-
* reconstruct the declared graph independent of which branches actually ran.
|
|
346
|
-
*/
|
|
347
|
-
export function workflowGraph(root) {
|
|
348
|
-
const nodes = [];
|
|
349
|
-
const edges = [];
|
|
350
|
-
for (const node of walkWorkflow(root)) {
|
|
351
|
-
nodes.push({
|
|
352
|
-
id: node.id,
|
|
353
|
-
kind: node.kind,
|
|
354
|
-
});
|
|
355
|
-
for (const child of childNodes(node)) {
|
|
356
|
-
edges.push({
|
|
357
|
-
from: node.id,
|
|
358
|
-
to: child.id,
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
return {
|
|
363
|
-
nodes,
|
|
364
|
-
edges,
|
|
365
|
-
};
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* Returns the maximum depth of a workflow tree.
|
|
369
|
-
* Leaf nodes (`llm`, `tool`) have depth 0. Structural nodes add +1.
|
|
370
|
-
*/
|
|
371
|
-
export function workflowDepth(node) {
|
|
372
|
-
const children = childNodes(node);
|
|
373
|
-
if (children.length === 0) {
|
|
374
|
-
return 0;
|
|
375
|
-
}
|
|
376
|
-
return 1 + Math.max(0, ...children.map(workflowDepth));
|
|
377
|
-
}
|
|
378
|
-
//#endregion
|
|
6
|
+
export { MergeStrategy, MergeStrategySchema, UntilPredicateSchema, validateWorkflow, WorkflowDocumentSchema, WorkflowNodeSchema, walkWorkflow, workflowDepth, workflowGraph, } from '@noetic-tools/types';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ContextData } from '@noetic-tools/context';
|
|
2
2
|
import type { Context, StepMeta, TokenUsage } from '@noetic-tools/types';
|
|
3
3
|
/**
|
|
4
4
|
* Internal-only interface for interpreter code that needs to mutate Context fields.
|
|
5
5
|
* NOT exported from the package public API.
|
|
6
6
|
*/
|
|
7
|
-
export interface MutableContext extends Context<
|
|
7
|
+
export interface MutableContext extends Context<ContextData> {
|
|
8
8
|
stepCount: number;
|
|
9
9
|
tokens: TokenUsage;
|
|
10
10
|
cost: number;
|
|
@@ -21,7 +21,7 @@ import type { Step } from '@noetic-tools/types';
|
|
|
21
21
|
* typically call the runtime's underlying `registerStep` function.
|
|
22
22
|
*/
|
|
23
23
|
export interface StepRegistrar {
|
|
24
|
-
register<
|
|
24
|
+
register<TContext, I, O>(step: Step<TContext, I, O>): void;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* @public
|
package/dist/unstable.d.ts
CHANGED
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
* Unstable exports for framework extenders.
|
|
4
4
|
*
|
|
5
5
|
* Symbols exported from this module may change in any minor release.
|
|
6
|
-
* They are intended for authors of custom
|
|
6
|
+
* They are intended for authors of custom context layers, runtime backends,
|
|
7
7
|
* and other framework extensions. Do not depend on them in application code.
|
|
8
8
|
*/
|
|
9
|
-
/** @unstable Budget allocation algorithm for
|
|
9
|
+
/** @unstable Budget allocation algorithm for context layer token budgets. */
|
|
10
10
|
/** @unstable Layer state store type for managing per-layer state during execution. */
|
|
11
|
-
export type { BudgetAllocation, BudgetLimits, LayerStateStore } from '@noetic-tools/
|
|
11
|
+
export type { BudgetAllocation, BudgetLimits, LayerStateStore } from '@noetic-tools/context';
|
|
12
12
|
/** @unstable Budget allocation and checking utilities. */
|
|
13
13
|
/** @unstable Factory for creating layer state stores. */
|
|
14
|
-
/** @unstable View assembly algorithm that converges
|
|
14
|
+
/** @unstable View assembly algorithm that converges context layer outputs into the LLM context. */
|
|
15
15
|
/** @unstable Factory for creating scoped storage wrappers around a StorageAdapter. */
|
|
16
|
-
export { allocateBudgets, assembleView, checkBudget, createLayerStateStore, createScopedStorage, } from '@noetic-tools/
|
|
16
|
+
export { allocateBudgets, assembleView, checkBudget, createLayerStateStore, createScopedStorage, } from '@noetic-tools/context';
|
|
17
17
|
/** @unstable Unsafe cast utility for bridging internal type boundaries. */
|
|
18
18
|
export { frameworkCast } from '@noetic-tools/types';
|
|
19
19
|
/**
|
package/dist/unstable.js
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* Unstable exports for framework extenders.
|
|
4
4
|
*
|
|
5
5
|
* Symbols exported from this module may change in any minor release.
|
|
6
|
-
* They are intended for authors of custom
|
|
6
|
+
* They are intended for authors of custom context layers, runtime backends,
|
|
7
7
|
* and other framework extensions. Do not depend on them in application code.
|
|
8
8
|
*/
|
|
9
9
|
/** @unstable Budget allocation and checking utilities. */
|
|
10
10
|
/** @unstable Factory for creating layer state stores. */
|
|
11
|
-
/** @unstable View assembly algorithm that converges
|
|
11
|
+
/** @unstable View assembly algorithm that converges context layer outputs into the LLM context. */
|
|
12
12
|
/** @unstable Factory for creating scoped storage wrappers around a StorageAdapter. */
|
|
13
|
-
export { allocateBudgets, assembleView, checkBudget, createLayerStateStore, createScopedStorage, } from '@noetic-tools/
|
|
13
|
+
export { allocateBudgets, assembleView, checkBudget, createLayerStateStore, createScopedStorage, } from '@noetic-tools/context';
|
|
14
14
|
/** @unstable Unsafe cast utility for bridging internal type boundaries. */
|
|
15
15
|
export { frameworkCast } from '@noetic-tools/types';
|
|
16
16
|
/**
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noetic-tools/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Step primitives, interpreter, runtime, and
|
|
5
|
+
"description": "Step primitives, interpreter, runtime, and context layer contract for Noetic agents.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@noetic-tools/
|
|
70
|
-
"@noetic-tools/types": "^
|
|
69
|
+
"@noetic-tools/context": "^1.0.0",
|
|
70
|
+
"@noetic-tools/types": "^3.0.0",
|
|
71
71
|
"@openrouter/agent": "^0.6.0",
|
|
72
72
|
"zod": "^4.0.0"
|
|
73
73
|
},
|
|
@@ -455,6 +455,34 @@
|
|
|
455
455
|
],
|
|
456
456
|
"additionalProperties": false
|
|
457
457
|
},
|
|
458
|
+
{
|
|
459
|
+
"type": "object",
|
|
460
|
+
"properties": {
|
|
461
|
+
"kind": {
|
|
462
|
+
"type": "string",
|
|
463
|
+
"const": "subflow"
|
|
464
|
+
},
|
|
465
|
+
"id": {
|
|
466
|
+
"type": "string",
|
|
467
|
+
"minLength": 1
|
|
468
|
+
},
|
|
469
|
+
"document": {
|
|
470
|
+
"$ref": "#"
|
|
471
|
+
},
|
|
472
|
+
"ref": {
|
|
473
|
+
"type": "string",
|
|
474
|
+
"minLength": 1
|
|
475
|
+
},
|
|
476
|
+
"input": {
|
|
477
|
+
"type": "string"
|
|
478
|
+
}
|
|
479
|
+
},
|
|
480
|
+
"required": [
|
|
481
|
+
"kind",
|
|
482
|
+
"id"
|
|
483
|
+
],
|
|
484
|
+
"additionalProperties": false
|
|
485
|
+
},
|
|
458
486
|
{
|
|
459
487
|
"type": "object",
|
|
460
488
|
"properties": {
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { MemoryConfig, MemoryLayer } from '@noetic-tools/memory';
|
|
2
|
-
/**
|
|
3
|
-
* Creates a type-safe memory configuration from a tuple of memory layers.
|
|
4
|
-
* The returned config preserves literal layer types for compile-time inference
|
|
5
|
-
* via `InferMemory<typeof config>`.
|
|
6
|
-
*
|
|
7
|
-
* @public
|
|
8
|
-
* @param layers - Tuple of memory layers to include in the configuration.
|
|
9
|
-
* @returns A `MemoryConfig` carrying the inferred memory shape as a phantom type.
|
|
10
|
-
*/
|
|
11
|
-
export declare function memory<const T extends readonly MemoryLayer[]>(layers: T): MemoryConfig<T>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { frameworkCast } from '@noetic-tools/types';
|
|
2
|
-
/**
|
|
3
|
-
* Creates a type-safe memory configuration from a tuple of memory layers.
|
|
4
|
-
* The returned config preserves literal layer types for compile-time inference
|
|
5
|
-
* via `InferMemory<typeof config>`.
|
|
6
|
-
*
|
|
7
|
-
* @public
|
|
8
|
-
* @param layers - Tuple of memory layers to include in the configuration.
|
|
9
|
-
* @returns A `MemoryConfig` carrying the inferred memory shape as a phantom type.
|
|
10
|
-
*/
|
|
11
|
-
export function memory(layers) {
|
|
12
|
-
return frameworkCast({
|
|
13
|
-
layers,
|
|
14
|
-
});
|
|
15
|
-
}
|
package/dist/patterns/flow.d.ts
DELETED
package/dist/patterns/flow.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { FlowSchema, flowDepth, validateFlow, walkFlow } from '@noetic-tools/memory';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** @public */
|
|
2
|
-
/** @public */
|
|
3
|
-
/** @public */
|
|
4
|
-
/** @public */
|
|
5
|
-
/** @public */
|
|
6
|
-
/** @public */
|
|
7
|
-
/** @public */
|
|
8
|
-
export { durableTaskState, historyWindow, observationalMemory, planMemory, temporalMemory, toolMemoryLayer, workingMemory, } from '@noetic-tools/memory';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** @public */
|
|
2
|
-
/** @public */
|
|
3
|
-
/** @public */
|
|
4
|
-
/** @public */
|
|
5
|
-
/** @public */
|
|
6
|
-
/** @public */
|
|
7
|
-
/** @public */
|
|
8
|
-
export { durableTaskState, historyWindow, observationalMemory, planMemory, temporalMemory, toolMemoryLayer, workingMemory, } from '@noetic-tools/memory';
|