@noetic-tools/core 1.0.0 → 1.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.
@@ -46,7 +46,8 @@ const AllPredicateSchema = z.object({
46
46
  predicates: z.array(UntilPredicateRef).min(1),
47
47
  });
48
48
  /** @public Zod schema validating a named `until` predicate (including `any`/`all` combinators). */
49
- export const UntilPredicateSchema = z.union([
49
+ export const UntilPredicateSchema = z
50
+ .union([
50
51
  MaxStepsPredicateSchema,
51
52
  MaxCostPredicateSchema,
52
53
  MaxDurationPredicateSchema,
@@ -56,7 +57,11 @@ export const UntilPredicateSchema = z.union([
56
57
  ConvergedPredicateSchema,
57
58
  AnyPredicateSchema,
58
59
  AllPredicateSchema,
59
- ]);
60
+ ])
61
+ .meta({
62
+ id: 'UntilPredicate',
63
+ title: 'UntilPredicate',
64
+ });
60
65
  //#endregion
61
66
  //#region Merge Strategy
62
67
  /** @public ESM literal enum for merge strategies. */
@@ -158,7 +163,8 @@ const EveryNodeSchema = z.object({
158
163
  .optional(),
159
164
  });
160
165
  /** @public Zod schema validating a single `WorkflowNode` (any of the 9 JSON-safe kinds). */
161
- export const WorkflowNodeSchema = z.discriminatedUnion('kind', [
166
+ export const WorkflowNodeSchema = z
167
+ .discriminatedUnion('kind', [
162
168
  LlmNodeSchema,
163
169
  ToolNodeSchema,
164
170
  BranchNodeSchema,
@@ -168,11 +174,21 @@ export const WorkflowNodeSchema = z.discriminatedUnion('kind', [
168
174
  LoopNodeSchema,
169
175
  SequenceNodeSchema,
170
176
  EveryNodeSchema,
171
- ]);
177
+ ])
178
+ .meta({
179
+ id: 'WorkflowNode',
180
+ title: 'WorkflowNode',
181
+ });
172
182
  /** @public Zod schema validating a complete `WorkflowDocument`. */
173
- export const WorkflowDocumentSchema = z.object({
183
+ export const WorkflowDocumentSchema = z
184
+ .object({
174
185
  version: z.literal(1),
175
186
  root: WorkflowNodeSchema,
187
+ })
188
+ .meta({
189
+ id: 'WorkflowDocument',
190
+ title: 'WorkflowDocument',
191
+ description: 'A portable, JSON-safe representation of a Noetic step tree.',
176
192
  });
177
193
  //#endregion
178
194
  //#region Helpers
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noetic-tools/core",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "description": "Step primitives, interpreter, runtime, and memory layer contract for Noetic agents.",
6
6
  "license": "Apache-2.0",
@@ -40,10 +40,12 @@
40
40
  "types": "./dist/internal-test.d.ts",
41
41
  "default": "./dist/internal-test.js"
42
42
  },
43
+ "./schema": "./schema/noetic-workflow.schema.json",
43
44
  "./package.json": "./package.json"
44
45
  },
45
46
  "files": [
46
47
  "dist",
48
+ "schema",
47
49
  "README.md",
48
50
  "LICENSE"
49
51
  ],
@@ -71,8 +73,9 @@
71
73
  },
72
74
  "scripts": {
73
75
  "build": "bunx tsc -p tsconfig.build.json && bun scripts/add-js-extensions.ts",
76
+ "gen:schema": "bun scripts/generate-workflow-schema.ts",
74
77
  "verify:esm": "bun scripts/verify-node-esm.ts",
75
- "prepublishOnly": "rm -rf dist && bun run build && bun run verify:esm && bun scripts/pin-workspace-deps.ts && bun scripts/strip-dev-conditions.ts",
78
+ "prepublishOnly": "rm -rf dist && bun run gen:schema && bun run build && bun run verify:esm && bun scripts/pin-workspace-deps.ts && bun scripts/strip-dev-conditions.ts",
76
79
  "test": "bun test",
77
80
  "test:coverage": "bun test --coverage --coverage-reporter=text --coverage-reporter=lcov",
78
81
  "test:ci": "bun test --coverage --coverage-reporter=lcov",
@@ -0,0 +1,523 @@
1
+ {
2
+ "$id": "https://noetic.tools/schema/noetic-workflow.schema.json",
3
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
4
+ "type": "object",
5
+ "properties": {
6
+ "version": {
7
+ "type": "number",
8
+ "const": 1
9
+ },
10
+ "root": {
11
+ "$ref": "#/$defs/WorkflowNode"
12
+ }
13
+ },
14
+ "required": [
15
+ "version",
16
+ "root"
17
+ ],
18
+ "additionalProperties": false,
19
+ "title": "WorkflowDocument",
20
+ "description": "A portable, JSON-safe representation of a Noetic step tree.",
21
+ "$defs": {
22
+ "WorkflowNode": {
23
+ "oneOf": [
24
+ {
25
+ "type": "object",
26
+ "properties": {
27
+ "kind": {
28
+ "type": "string",
29
+ "const": "llm"
30
+ },
31
+ "id": {
32
+ "type": "string",
33
+ "minLength": 1
34
+ },
35
+ "model": {
36
+ "type": "string"
37
+ },
38
+ "instructions": {
39
+ "type": "string"
40
+ },
41
+ "tools": {
42
+ "type": "array",
43
+ "items": {
44
+ "type": "string"
45
+ }
46
+ },
47
+ "params": {
48
+ "type": "object",
49
+ "properties": {
50
+ "temperature": {
51
+ "type": "number",
52
+ "minimum": 0
53
+ },
54
+ "topP": {
55
+ "type": "number",
56
+ "minimum": 0,
57
+ "maximum": 1
58
+ },
59
+ "maxTokens": {
60
+ "type": "integer",
61
+ "exclusiveMinimum": 0,
62
+ "maximum": 9007199254740991
63
+ },
64
+ "stopSequences": {
65
+ "type": "array",
66
+ "items": {
67
+ "type": "string"
68
+ }
69
+ }
70
+ },
71
+ "additionalProperties": false
72
+ }
73
+ },
74
+ "required": [
75
+ "kind",
76
+ "id",
77
+ "instructions"
78
+ ],
79
+ "additionalProperties": false
80
+ },
81
+ {
82
+ "type": "object",
83
+ "properties": {
84
+ "kind": {
85
+ "type": "string",
86
+ "const": "tool"
87
+ },
88
+ "id": {
89
+ "type": "string",
90
+ "minLength": 1
91
+ },
92
+ "toolName": {
93
+ "type": "string",
94
+ "minLength": 1
95
+ },
96
+ "args": {
97
+ "type": "object",
98
+ "propertyNames": {
99
+ "type": "string"
100
+ },
101
+ "additionalProperties": {}
102
+ }
103
+ },
104
+ "required": [
105
+ "kind",
106
+ "id",
107
+ "toolName"
108
+ ],
109
+ "additionalProperties": false
110
+ },
111
+ {
112
+ "type": "object",
113
+ "properties": {
114
+ "kind": {
115
+ "type": "string",
116
+ "const": "branch"
117
+ },
118
+ "id": {
119
+ "type": "string",
120
+ "minLength": 1
121
+ },
122
+ "routes": {
123
+ "minItems": 1,
124
+ "type": "array",
125
+ "items": {
126
+ "type": "object",
127
+ "properties": {
128
+ "match": {
129
+ "type": "string",
130
+ "minLength": 1
131
+ },
132
+ "target": {
133
+ "$ref": "#/$defs/WorkflowNode"
134
+ }
135
+ },
136
+ "required": [
137
+ "match",
138
+ "target"
139
+ ],
140
+ "additionalProperties": false
141
+ }
142
+ },
143
+ "default": {
144
+ "$ref": "#/$defs/WorkflowNode"
145
+ }
146
+ },
147
+ "required": [
148
+ "kind",
149
+ "id",
150
+ "routes"
151
+ ],
152
+ "additionalProperties": false
153
+ },
154
+ {
155
+ "type": "object",
156
+ "properties": {
157
+ "kind": {
158
+ "type": "string",
159
+ "const": "fork"
160
+ },
161
+ "id": {
162
+ "type": "string",
163
+ "minLength": 1
164
+ },
165
+ "mode": {
166
+ "type": "string",
167
+ "enum": [
168
+ "race",
169
+ "all",
170
+ "settle"
171
+ ]
172
+ },
173
+ "paths": {
174
+ "minItems": 1,
175
+ "type": "array",
176
+ "items": {
177
+ "$ref": "#/$defs/WorkflowNode"
178
+ }
179
+ },
180
+ "merge": {
181
+ "type": "string",
182
+ "enum": [
183
+ "last",
184
+ "first",
185
+ "concat"
186
+ ]
187
+ },
188
+ "concurrency": {
189
+ "type": "integer",
190
+ "exclusiveMinimum": 0,
191
+ "maximum": 9007199254740991
192
+ }
193
+ },
194
+ "required": [
195
+ "kind",
196
+ "id",
197
+ "mode",
198
+ "paths"
199
+ ],
200
+ "additionalProperties": false
201
+ },
202
+ {
203
+ "type": "object",
204
+ "properties": {
205
+ "kind": {
206
+ "type": "string",
207
+ "const": "spawn"
208
+ },
209
+ "id": {
210
+ "type": "string",
211
+ "minLength": 1
212
+ },
213
+ "child": {
214
+ "$ref": "#/$defs/WorkflowNode"
215
+ },
216
+ "timeout": {
217
+ "type": "number",
218
+ "exclusiveMinimum": 0
219
+ }
220
+ },
221
+ "required": [
222
+ "kind",
223
+ "id",
224
+ "child"
225
+ ],
226
+ "additionalProperties": false
227
+ },
228
+ {
229
+ "type": "object",
230
+ "properties": {
231
+ "kind": {
232
+ "type": "string",
233
+ "const": "provide"
234
+ },
235
+ "id": {
236
+ "type": "string",
237
+ "minLength": 1
238
+ },
239
+ "child": {
240
+ "$ref": "#/$defs/WorkflowNode"
241
+ },
242
+ "layers": {
243
+ "minItems": 1,
244
+ "type": "array",
245
+ "items": {
246
+ "type": "string",
247
+ "minLength": 1
248
+ }
249
+ }
250
+ },
251
+ "required": [
252
+ "kind",
253
+ "id",
254
+ "child",
255
+ "layers"
256
+ ],
257
+ "additionalProperties": false
258
+ },
259
+ {
260
+ "type": "object",
261
+ "properties": {
262
+ "kind": {
263
+ "type": "string",
264
+ "const": "loop"
265
+ },
266
+ "id": {
267
+ "type": "string",
268
+ "minLength": 1
269
+ },
270
+ "body": {
271
+ "$ref": "#/$defs/WorkflowNode"
272
+ },
273
+ "until": {
274
+ "$ref": "#/$defs/UntilPredicate"
275
+ },
276
+ "maxIterations": {
277
+ "type": "integer",
278
+ "exclusiveMinimum": 0,
279
+ "maximum": 9007199254740991
280
+ }
281
+ },
282
+ "required": [
283
+ "kind",
284
+ "id",
285
+ "body",
286
+ "until"
287
+ ],
288
+ "additionalProperties": false
289
+ },
290
+ {
291
+ "type": "object",
292
+ "properties": {
293
+ "kind": {
294
+ "type": "string",
295
+ "const": "sequence"
296
+ },
297
+ "id": {
298
+ "type": "string",
299
+ "minLength": 1
300
+ },
301
+ "steps": {
302
+ "minItems": 1,
303
+ "type": "array",
304
+ "items": {
305
+ "$ref": "#/$defs/WorkflowNode"
306
+ }
307
+ }
308
+ },
309
+ "required": [
310
+ "kind",
311
+ "id",
312
+ "steps"
313
+ ],
314
+ "additionalProperties": false
315
+ },
316
+ {
317
+ "type": "object",
318
+ "properties": {
319
+ "kind": {
320
+ "type": "string",
321
+ "const": "every"
322
+ },
323
+ "id": {
324
+ "type": "string",
325
+ "minLength": 1
326
+ },
327
+ "step": {
328
+ "$ref": "#/$defs/WorkflowNode"
329
+ },
330
+ "ms": {
331
+ "type": "number",
332
+ "minimum": 0
333
+ },
334
+ "onError": {
335
+ "type": "string",
336
+ "enum": [
337
+ "continue",
338
+ "fail"
339
+ ]
340
+ }
341
+ },
342
+ "required": [
343
+ "kind",
344
+ "id",
345
+ "step",
346
+ "ms"
347
+ ],
348
+ "additionalProperties": false
349
+ }
350
+ ],
351
+ "title": "WorkflowNode"
352
+ },
353
+ "UntilPredicate": {
354
+ "anyOf": [
355
+ {
356
+ "type": "object",
357
+ "properties": {
358
+ "kind": {
359
+ "type": "string",
360
+ "const": "maxSteps"
361
+ },
362
+ "n": {
363
+ "type": "integer",
364
+ "exclusiveMinimum": 0,
365
+ "maximum": 9007199254740991
366
+ }
367
+ },
368
+ "required": [
369
+ "kind",
370
+ "n"
371
+ ],
372
+ "additionalProperties": false
373
+ },
374
+ {
375
+ "type": "object",
376
+ "properties": {
377
+ "kind": {
378
+ "type": "string",
379
+ "const": "maxCost"
380
+ },
381
+ "usd": {
382
+ "type": "number",
383
+ "exclusiveMinimum": 0
384
+ }
385
+ },
386
+ "required": [
387
+ "kind",
388
+ "usd"
389
+ ],
390
+ "additionalProperties": false
391
+ },
392
+ {
393
+ "type": "object",
394
+ "properties": {
395
+ "kind": {
396
+ "type": "string",
397
+ "const": "maxDuration"
398
+ },
399
+ "ms": {
400
+ "type": "number",
401
+ "exclusiveMinimum": 0
402
+ }
403
+ },
404
+ "required": [
405
+ "kind",
406
+ "ms"
407
+ ],
408
+ "additionalProperties": false
409
+ },
410
+ {
411
+ "type": "object",
412
+ "properties": {
413
+ "kind": {
414
+ "type": "string",
415
+ "const": "noToolCalls"
416
+ }
417
+ },
418
+ "required": [
419
+ "kind"
420
+ ],
421
+ "additionalProperties": false
422
+ },
423
+ {
424
+ "type": "object",
425
+ "properties": {
426
+ "kind": {
427
+ "type": "string",
428
+ "const": "outputContains"
429
+ },
430
+ "marker": {
431
+ "type": "string",
432
+ "minLength": 1
433
+ }
434
+ },
435
+ "required": [
436
+ "kind",
437
+ "marker"
438
+ ],
439
+ "additionalProperties": false
440
+ },
441
+ {
442
+ "type": "object",
443
+ "properties": {
444
+ "kind": {
445
+ "type": "string",
446
+ "const": "outputEquals"
447
+ },
448
+ "sentinel": {
449
+ "type": "string",
450
+ "minLength": 1
451
+ }
452
+ },
453
+ "required": [
454
+ "kind",
455
+ "sentinel"
456
+ ],
457
+ "additionalProperties": false
458
+ },
459
+ {
460
+ "type": "object",
461
+ "properties": {
462
+ "kind": {
463
+ "type": "string",
464
+ "const": "converged"
465
+ },
466
+ "threshold": {
467
+ "type": "number",
468
+ "minimum": 0,
469
+ "maximum": 1
470
+ }
471
+ },
472
+ "required": [
473
+ "kind"
474
+ ],
475
+ "additionalProperties": false
476
+ },
477
+ {
478
+ "type": "object",
479
+ "properties": {
480
+ "kind": {
481
+ "type": "string",
482
+ "const": "any"
483
+ },
484
+ "predicates": {
485
+ "minItems": 1,
486
+ "type": "array",
487
+ "items": {
488
+ "$ref": "#/$defs/UntilPredicate"
489
+ }
490
+ }
491
+ },
492
+ "required": [
493
+ "kind",
494
+ "predicates"
495
+ ],
496
+ "additionalProperties": false
497
+ },
498
+ {
499
+ "type": "object",
500
+ "properties": {
501
+ "kind": {
502
+ "type": "string",
503
+ "const": "all"
504
+ },
505
+ "predicates": {
506
+ "minItems": 1,
507
+ "type": "array",
508
+ "items": {
509
+ "$ref": "#/$defs/UntilPredicate"
510
+ }
511
+ }
512
+ },
513
+ "required": [
514
+ "kind",
515
+ "predicates"
516
+ ],
517
+ "additionalProperties": false
518
+ }
519
+ ],
520
+ "title": "UntilPredicate"
521
+ }
522
+ }
523
+ }