@duckflux/core 0.6.8 → 0.7.1

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.
@@ -26165,8 +26165,552 @@ var require_dist2 = __commonJS((exports, module) => {
26165
26165
  exports.default = formatsPlugin;
26166
26166
  });
26167
26167
 
26168
+ // src/parser/schema/duckflux.schema.json
26169
+ var duckflux_schema_default;
26170
+ var init_duckflux_schema = __esm(() => {
26171
+ duckflux_schema_default = {
26172
+ $schema: "https://json-schema.org/draft/2020-12/schema",
26173
+ $id: "https://raw.githubusercontent.com/duckflux/spec/main/duckflux.schema.json",
26174
+ title: "duckflux Workflow",
26175
+ description: "Schema for duckflux — a minimal, deterministic, runtime-agnostic workflow DSL.",
26176
+ type: "object",
26177
+ required: ["flow"],
26178
+ additionalProperties: false,
26179
+ properties: {
26180
+ id: {
26181
+ type: "string",
26182
+ description: "Unique identifier for the workflow."
26183
+ },
26184
+ name: {
26185
+ type: "string",
26186
+ description: "Human-readable workflow name."
26187
+ },
26188
+ version: {
26189
+ description: "Version identifier for the workflow definition.",
26190
+ oneOf: [
26191
+ { type: "string" },
26192
+ { type: "integer" }
26193
+ ]
26194
+ },
26195
+ defaults: {
26196
+ $ref: "#/$defs/defaults"
26197
+ },
26198
+ inputs: {
26199
+ $ref: "#/$defs/inputs"
26200
+ },
26201
+ participants: {
26202
+ type: "object",
26203
+ description: "Named steps that can be referenced in the flow.",
26204
+ additionalProperties: {
26205
+ $ref: "#/$defs/participant"
26206
+ },
26207
+ not: {
26208
+ anyOf: [
26209
+ { required: ["workflow"] },
26210
+ { required: ["execution"] },
26211
+ { required: ["input"] },
26212
+ { required: ["output"] },
26213
+ { required: ["env"] },
26214
+ { required: ["loop"] },
26215
+ { required: ["event"] }
26216
+ ]
26217
+ }
26218
+ },
26219
+ flow: {
26220
+ $ref: "#/$defs/flowSequence"
26221
+ },
26222
+ output: {
26223
+ $ref: "#/$defs/workflowOutput"
26224
+ }
26225
+ },
26226
+ $defs: {
26227
+ duration: {
26228
+ type: "string",
26229
+ pattern: "^[0-9]+(ms|s|m|h|d)$",
26230
+ description: "Duration string, e.g. '30s', '5m', '2h', '1d'."
26231
+ },
26232
+ celExpression: {
26233
+ type: "string",
26234
+ description: "A Google CEL expression."
26235
+ },
26236
+ defaults: {
26237
+ type: "object",
26238
+ description: "Global defaults applied to all participants.",
26239
+ additionalProperties: false,
26240
+ properties: {
26241
+ timeout: {
26242
+ $ref: "#/$defs/duration"
26243
+ },
26244
+ cwd: {
26245
+ type: "string",
26246
+ description: "Default working directory for exec participants. Supports CEL expressions."
26247
+ }
26248
+ }
26249
+ },
26250
+ inputs: {
26251
+ type: "object",
26252
+ description: "Workflow input parameters. Accessed in CEL as workflow.inputs.<field>. Each key is a parameter name. Value can be null (string, no schema), or a JSON Schema object for validation.",
26253
+ additionalProperties: {
26254
+ oneOf: [
26255
+ { type: "null" },
26256
+ { $ref: "#/$defs/inputField" }
26257
+ ]
26258
+ }
26259
+ },
26260
+ inputField: {
26261
+ type: "object",
26262
+ description: "JSON Schema field definition with optional 'required: true' shortcut.",
26263
+ properties: {
26264
+ type: {
26265
+ type: "string",
26266
+ enum: ["string", "integer", "number", "boolean", "array", "object"]
26267
+ },
26268
+ description: { type: "string" },
26269
+ default: {},
26270
+ required: { type: "boolean" },
26271
+ format: { type: "string" },
26272
+ enum: { type: "array" },
26273
+ minimum: { type: "number" },
26274
+ maximum: { type: "number" },
26275
+ minLength: { type: "integer" },
26276
+ maxLength: { type: "integer" },
26277
+ pattern: { type: "string" },
26278
+ items: {
26279
+ $ref: "#/$defs/inputField"
26280
+ }
26281
+ },
26282
+ additionalProperties: false
26283
+ },
26284
+ retryConfig: {
26285
+ type: "object",
26286
+ description: "Retry configuration. Only applies when onError is 'retry'.",
26287
+ additionalProperties: false,
26288
+ required: ["max"],
26289
+ properties: {
26290
+ max: {
26291
+ type: "integer",
26292
+ minimum: 1,
26293
+ description: "Maximum number of retry attempts."
26294
+ },
26295
+ backoff: {
26296
+ $ref: "#/$defs/duration",
26297
+ description: "Interval between attempts. Default: 0s."
26298
+ },
26299
+ factor: {
26300
+ type: "number",
26301
+ minimum: 1,
26302
+ description: "Backoff multiplier. Default: 1 (no escalation)."
26303
+ }
26304
+ }
26305
+ },
26306
+ onError: {
26307
+ type: "string",
26308
+ description: "Error handling strategy: 'fail' (default), 'skip', 'retry', or a participant name for redirect.",
26309
+ minLength: 1
26310
+ },
26311
+ onTimeout: {
26312
+ type: "string",
26313
+ description: "Timeout handling strategy: 'fail' (default), 'skip', or a participant name for redirect.",
26314
+ minLength: 1
26315
+ },
26316
+ participantInput: {
26317
+ description: "Explicit input mapping. String for direct passthrough, object for structured mapping. Values are CEL expressions. Merged with implicit I/O chain input at runtime.",
26318
+ oneOf: [
26319
+ { type: "string" },
26320
+ {
26321
+ type: "object",
26322
+ additionalProperties: {
26323
+ type: "string"
26324
+ }
26325
+ }
26326
+ ]
26327
+ },
26328
+ participantOutputSchema: {
26329
+ type: "object",
26330
+ description: "Output schema (JSON Schema fields). Opt-in validation.",
26331
+ additionalProperties: {
26332
+ $ref: "#/$defs/inputField"
26333
+ }
26334
+ },
26335
+ payload: {
26336
+ description: "Event payload. String (CEL expression) or object with CEL expressions as values.",
26337
+ oneOf: [
26338
+ { type: "string" },
26339
+ {
26340
+ type: "object",
26341
+ additionalProperties: {}
26342
+ }
26343
+ ]
26344
+ },
26345
+ participant: {
26346
+ type: "object",
26347
+ required: ["type"],
26348
+ description: "A named, reusable building block of the workflow.",
26349
+ properties: {
26350
+ type: {
26351
+ type: "string",
26352
+ enum: ["exec", "http", "mcp", "workflow", "emit"],
26353
+ description: "Participant type."
26354
+ },
26355
+ as: {
26356
+ type: "string",
26357
+ description: "Human-readable display name."
26358
+ },
26359
+ timeout: {
26360
+ $ref: "#/$defs/duration"
26361
+ },
26362
+ onError: {
26363
+ $ref: "#/$defs/onError"
26364
+ },
26365
+ retry: {
26366
+ $ref: "#/$defs/retryConfig"
26367
+ },
26368
+ input: {
26369
+ $ref: "#/$defs/participantInput"
26370
+ },
26371
+ output: {
26372
+ $ref: "#/$defs/participantOutputSchema"
26373
+ },
26374
+ run: {
26375
+ type: "string",
26376
+ description: "[exec] Shell command to execute."
26377
+ },
26378
+ cwd: {
26379
+ type: "string",
26380
+ description: "[exec] Working directory. Supports CEL expressions."
26381
+ },
26382
+ url: {
26383
+ type: "string",
26384
+ description: "[http] Target URL. Supports CEL expressions."
26385
+ },
26386
+ method: {
26387
+ type: "string",
26388
+ enum: ["GET", "POST", "PUT", "PATCH", "DELETE"],
26389
+ description: "[http] HTTP method."
26390
+ },
26391
+ headers: {
26392
+ type: "object",
26393
+ additionalProperties: { type: "string" },
26394
+ description: "[http] HTTP headers. Values support CEL expressions."
26395
+ },
26396
+ body: {
26397
+ description: "[http] Request body. String or object. Supports CEL expressions.",
26398
+ oneOf: [
26399
+ { type: "string" },
26400
+ { type: "object" }
26401
+ ]
26402
+ },
26403
+ path: {
26404
+ type: "string",
26405
+ description: "[workflow] Path to the sub-workflow YAML file."
26406
+ },
26407
+ server: {
26408
+ type: "string",
26409
+ description: "[mcp] MCP server identifier."
26410
+ },
26411
+ tool: {
26412
+ type: "string",
26413
+ description: "[mcp] MCP tool name to invoke."
26414
+ },
26415
+ event: {
26416
+ type: "string",
26417
+ description: "[emit] Event name to emit."
26418
+ },
26419
+ payload: {
26420
+ $ref: "#/$defs/payload",
26421
+ description: "[emit] Event payload. CEL expression or object with CEL expressions."
26422
+ },
26423
+ ack: {
26424
+ type: "boolean",
26425
+ description: "[emit] If true, wait for delivery acknowledgment. Default: false.",
26426
+ default: false
26427
+ }
26428
+ },
26429
+ additionalProperties: false
26430
+ },
26431
+ inlineParticipant: {
26432
+ type: "object",
26433
+ required: ["type"],
26434
+ description: "An inline participant definition in the flow. 'as' is optional — if omitted, the participant is anonymous and its output is only accessible via the implicit I/O chain.",
26435
+ properties: {
26436
+ as: {
26437
+ type: "string",
26438
+ description: "Optional name for inline participants. If provided, must be unique across all participant names. Enables output reference by name."
26439
+ },
26440
+ type: {
26441
+ type: "string",
26442
+ enum: ["exec", "http", "mcp", "workflow", "emit"],
26443
+ description: "Participant type."
26444
+ },
26445
+ when: {
26446
+ $ref: "#/$defs/celExpression",
26447
+ description: "Guard condition. If false, step is skipped."
26448
+ },
26449
+ timeout: {
26450
+ $ref: "#/$defs/duration"
26451
+ },
26452
+ onError: {
26453
+ $ref: "#/$defs/onError"
26454
+ },
26455
+ retry: {
26456
+ $ref: "#/$defs/retryConfig"
26457
+ },
26458
+ input: {
26459
+ $ref: "#/$defs/participantInput"
26460
+ },
26461
+ output: {
26462
+ $ref: "#/$defs/participantOutputSchema"
26463
+ },
26464
+ run: { type: "string" },
26465
+ cwd: { type: "string" },
26466
+ url: { type: "string" },
26467
+ method: { type: "string", enum: ["GET", "POST", "PUT", "PATCH", "DELETE"] },
26468
+ headers: { type: "object", additionalProperties: { type: "string" } },
26469
+ body: { oneOf: [{ type: "string" }, { type: "object" }] },
26470
+ path: { type: "string" },
26471
+ server: { type: "string" },
26472
+ tool: { type: "string" },
26473
+ event: { type: "string" },
26474
+ payload: { $ref: "#/$defs/payload" },
26475
+ ack: { type: "boolean" }
26476
+ },
26477
+ additionalProperties: false
26478
+ },
26479
+ flowSequence: {
26480
+ type: "array",
26481
+ description: "Ordered list of flow steps. Each step's output is implicitly chained as input to the next step.",
26482
+ minItems: 1,
26483
+ items: {
26484
+ $ref: "#/$defs/flowStep"
26485
+ }
26486
+ },
26487
+ flowStep: {
26488
+ description: "A single step in the flow: participant reference (string), control construct, inline participant (named or anonymous), or participant override.",
26489
+ oneOf: [
26490
+ {
26491
+ type: "string",
26492
+ description: "Simple participant reference by name."
26493
+ },
26494
+ { $ref: "#/$defs/loopStep" },
26495
+ { $ref: "#/$defs/parallelStep" },
26496
+ { $ref: "#/$defs/ifStep" },
26497
+ { $ref: "#/$defs/setStep" },
26498
+ { $ref: "#/$defs/waitStep" },
26499
+ { $ref: "#/$defs/inlineParticipant" },
26500
+ { $ref: "#/$defs/participantOverrideStep" }
26501
+ ]
26502
+ },
26503
+ loopStep: {
26504
+ type: "object",
26505
+ required: ["loop"],
26506
+ additionalProperties: false,
26507
+ properties: {
26508
+ loop: {
26509
+ type: "object",
26510
+ additionalProperties: false,
26511
+ required: ["steps"],
26512
+ properties: {
26513
+ as: {
26514
+ type: "string",
26515
+ description: "Renames the loop context variable. Access as <as>.index, <as>.iteration, etc. instead of loop.*"
26516
+ },
26517
+ until: {
26518
+ $ref: "#/$defs/celExpression",
26519
+ description: "CEL condition to break out of the loop."
26520
+ },
26521
+ max: {
26522
+ description: "Maximum iterations. Integer or CEL expression.",
26523
+ oneOf: [
26524
+ { type: "integer", minimum: 1 },
26525
+ { type: "string" }
26526
+ ]
26527
+ },
26528
+ steps: {
26529
+ $ref: "#/$defs/flowSequence"
26530
+ }
26531
+ },
26532
+ anyOf: [
26533
+ { required: ["until"] },
26534
+ { required: ["max"] }
26535
+ ]
26536
+ }
26537
+ }
26538
+ },
26539
+ parallelStep: {
26540
+ type: "object",
26541
+ required: ["parallel"],
26542
+ additionalProperties: false,
26543
+ properties: {
26544
+ parallel: {
26545
+ $ref: "#/$defs/flowSequence",
26546
+ description: "Steps to run concurrently. The chained output after a parallel block is an array of all branch outputs in declaration order."
26547
+ }
26548
+ }
26549
+ },
26550
+ ifStep: {
26551
+ type: "object",
26552
+ required: ["if"],
26553
+ additionalProperties: false,
26554
+ properties: {
26555
+ if: {
26556
+ type: "object",
26557
+ required: ["condition", "then"],
26558
+ additionalProperties: false,
26559
+ properties: {
26560
+ condition: {
26561
+ $ref: "#/$defs/celExpression",
26562
+ description: "CEL expression that determines which branch to take."
26563
+ },
26564
+ then: {
26565
+ $ref: "#/$defs/flowSequence"
26566
+ },
26567
+ else: {
26568
+ $ref: "#/$defs/flowSequence"
26569
+ }
26570
+ }
26571
+ }
26572
+ }
26573
+ },
26574
+ setStep: {
26575
+ type: "object",
26576
+ required: ["set"],
26577
+ additionalProperties: false,
26578
+ properties: {
26579
+ set: {
26580
+ type: "object",
26581
+ description: "Writes values into execution.context. Each key becomes execution.context.<key>. Values are CEL expressions.",
26582
+ minProperties: 1,
26583
+ additionalProperties: {
26584
+ $ref: "#/$defs/celExpression"
26585
+ },
26586
+ not: {
26587
+ anyOf: [
26588
+ { required: ["workflow"] },
26589
+ { required: ["execution"] },
26590
+ { required: ["input"] },
26591
+ { required: ["output"] },
26592
+ { required: ["env"] },
26593
+ { required: ["loop"] },
26594
+ { required: ["event"] }
26595
+ ]
26596
+ }
26597
+ }
26598
+ }
26599
+ },
26600
+ waitStep: {
26601
+ type: "object",
26602
+ required: ["wait"],
26603
+ additionalProperties: false,
26604
+ properties: {
26605
+ wait: {
26606
+ type: "object",
26607
+ additionalProperties: false,
26608
+ properties: {
26609
+ event: {
26610
+ type: "string",
26611
+ description: "Event name to wait for (event mode)."
26612
+ },
26613
+ match: {
26614
+ $ref: "#/$defs/celExpression",
26615
+ description: "CEL condition to match against event payload. 'event' variable contains the payload."
26616
+ },
26617
+ until: {
26618
+ $ref: "#/$defs/celExpression",
26619
+ description: "CEL condition to wait for (polling mode)."
26620
+ },
26621
+ poll: {
26622
+ $ref: "#/$defs/duration",
26623
+ description: "Polling interval for 'until' condition. Default: runtime decides."
26624
+ },
26625
+ timeout: {
26626
+ $ref: "#/$defs/duration",
26627
+ description: "Maximum wait time."
26628
+ },
26629
+ onTimeout: {
26630
+ $ref: "#/$defs/onTimeout",
26631
+ description: "Strategy when timeout is reached: 'fail' (default), 'skip', or participant name."
26632
+ }
26633
+ }
26634
+ }
26635
+ }
26636
+ },
26637
+ participantOverrideStep: {
26638
+ type: "object",
26639
+ description: "A participant reference with flow-level overrides (timeout, onError, when, input, workflow, etc.).",
26640
+ minProperties: 1,
26641
+ maxProperties: 1,
26642
+ not: {
26643
+ anyOf: [
26644
+ { required: ["loop"] },
26645
+ { required: ["parallel"] },
26646
+ { required: ["if"] },
26647
+ { required: ["wait"] },
26648
+ { required: ["set"] },
26649
+ { required: ["type"] }
26650
+ ]
26651
+ },
26652
+ additionalProperties: {
26653
+ type: "object",
26654
+ properties: {
26655
+ when: {
26656
+ $ref: "#/$defs/celExpression",
26657
+ description: "Guard condition. If false, step is skipped."
26658
+ },
26659
+ timeout: {
26660
+ $ref: "#/$defs/duration"
26661
+ },
26662
+ onError: {
26663
+ $ref: "#/$defs/onError"
26664
+ },
26665
+ retry: {
26666
+ $ref: "#/$defs/retryConfig"
26667
+ },
26668
+ input: {
26669
+ $ref: "#/$defs/participantInput"
26670
+ },
26671
+ workflow: {
26672
+ type: "string",
26673
+ description: "Inline sub-workflow path (alternative to defining as participant)."
26674
+ }
26675
+ },
26676
+ additionalProperties: false
26677
+ }
26678
+ },
26679
+ workflowOutput: {
26680
+ description: "Workflow output. Accessed in CEL as workflow.output. String (single CEL expression), object (structured mapping), or object with schema+map.",
26681
+ oneOf: [
26682
+ {
26683
+ type: "string",
26684
+ description: "Single CEL expression mapping."
26685
+ },
26686
+ {
26687
+ type: "object",
26688
+ description: "Structured output mapping (key → CEL expression) or schema+map.",
26689
+ properties: {
26690
+ schema: {
26691
+ type: "object",
26692
+ additionalProperties: {
26693
+ $ref: "#/$defs/inputField"
26694
+ }
26695
+ },
26696
+ map: {
26697
+ type: "object",
26698
+ additionalProperties: {
26699
+ type: "string"
26700
+ }
26701
+ }
26702
+ },
26703
+ additionalProperties: {
26704
+ type: "string"
26705
+ }
26706
+ }
26707
+ ]
26708
+ }
26709
+ }
26710
+ };
26711
+ });
26712
+
26168
26713
  // src/parser/schema.ts
26169
- import { readFileSync } from "node:fs";
26170
26714
  function validateSchema(workflow) {
26171
26715
  const valid = validate(workflow);
26172
26716
  if (valid) {
@@ -26178,12 +26722,12 @@ function validateSchema(workflow) {
26178
26722
  }));
26179
26723
  return { valid: false, errors };
26180
26724
  }
26181
- var import__2020, import_ajv_formats, rawSchema, schema, ajv, validate;
26725
+ var import__2020, import_ajv_formats, schema, ajv, validate;
26182
26726
  var init_schema = __esm(() => {
26727
+ init_duckflux_schema();
26183
26728
  import__2020 = __toESM(require_2020(), 1);
26184
26729
  import_ajv_formats = __toESM(require_dist2(), 1);
26185
- rawSchema = readFileSync(new URL("./schema/duckflux.schema.json", import.meta.url), "utf-8");
26186
- schema = JSON.parse(rawSchema);
26730
+ schema = { ...duckflux_schema_default };
26187
26731
  delete schema.$schema;
26188
26732
  ajv = new import__2020.default({ allErrors: true, strict: false });
26189
26733
  import_ajv_formats.default(ajv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duckflux/core",
3
- "version": "0.6.8",
3
+ "version": "0.7.1",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {