@duckflux/runner 0.7.0 → 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.
Files changed (2) hide show
  1. package/dist/main.js +1092 -10
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -126,7 +126,7 @@ async function createHub(config) {
126
126
  var init_eventhub = () => {};
127
127
 
128
128
  // src/main.ts
129
- import { readFileSync as readFileSync3 } from "fs";
129
+ import { readFileSync } from "fs";
130
130
  import { parseArgs } from "util";
131
131
  import { dirname as dirname5, resolve as resolve5 } from "path";
132
132
 
@@ -136,7 +136,6 @@ import { dirname as dirname2 } from "node:path";
136
136
  // ../core/dist/index.js
137
137
  import { createRequire as createRequire2 } from "node:module";
138
138
  import { readFile } from "node:fs/promises";
139
- import { readFileSync } from "node:fs";
140
139
  import { constants } from "node:fs";
141
140
  import { access } from "node:fs/promises";
142
141
  import { resolve } from "node:path";
@@ -25799,6 +25798,549 @@ var require_dist2 = __commonJS((exports, module) => {
25799
25798
  Object.defineProperty(exports, "__esModule", { value: true });
25800
25799
  exports.default = formatsPlugin;
25801
25800
  });
25801
+ var duckflux_schema_default;
25802
+ var init_duckflux_schema = __esm2(() => {
25803
+ duckflux_schema_default = {
25804
+ $schema: "https://json-schema.org/draft/2020-12/schema",
25805
+ $id: "https://raw.githubusercontent.com/duckflux/spec/main/duckflux.schema.json",
25806
+ title: "duckflux Workflow",
25807
+ description: "Schema for duckflux — a minimal, deterministic, runtime-agnostic workflow DSL.",
25808
+ type: "object",
25809
+ required: ["flow"],
25810
+ additionalProperties: false,
25811
+ properties: {
25812
+ id: {
25813
+ type: "string",
25814
+ description: "Unique identifier for the workflow."
25815
+ },
25816
+ name: {
25817
+ type: "string",
25818
+ description: "Human-readable workflow name."
25819
+ },
25820
+ version: {
25821
+ description: "Version identifier for the workflow definition.",
25822
+ oneOf: [
25823
+ { type: "string" },
25824
+ { type: "integer" }
25825
+ ]
25826
+ },
25827
+ defaults: {
25828
+ $ref: "#/$defs/defaults"
25829
+ },
25830
+ inputs: {
25831
+ $ref: "#/$defs/inputs"
25832
+ },
25833
+ participants: {
25834
+ type: "object",
25835
+ description: "Named steps that can be referenced in the flow.",
25836
+ additionalProperties: {
25837
+ $ref: "#/$defs/participant"
25838
+ },
25839
+ not: {
25840
+ anyOf: [
25841
+ { required: ["workflow"] },
25842
+ { required: ["execution"] },
25843
+ { required: ["input"] },
25844
+ { required: ["output"] },
25845
+ { required: ["env"] },
25846
+ { required: ["loop"] },
25847
+ { required: ["event"] }
25848
+ ]
25849
+ }
25850
+ },
25851
+ flow: {
25852
+ $ref: "#/$defs/flowSequence"
25853
+ },
25854
+ output: {
25855
+ $ref: "#/$defs/workflowOutput"
25856
+ }
25857
+ },
25858
+ $defs: {
25859
+ duration: {
25860
+ type: "string",
25861
+ pattern: "^[0-9]+(ms|s|m|h|d)$",
25862
+ description: "Duration string, e.g. '30s', '5m', '2h', '1d'."
25863
+ },
25864
+ celExpression: {
25865
+ type: "string",
25866
+ description: "A Google CEL expression."
25867
+ },
25868
+ defaults: {
25869
+ type: "object",
25870
+ description: "Global defaults applied to all participants.",
25871
+ additionalProperties: false,
25872
+ properties: {
25873
+ timeout: {
25874
+ $ref: "#/$defs/duration"
25875
+ },
25876
+ cwd: {
25877
+ type: "string",
25878
+ description: "Default working directory for exec participants. Supports CEL expressions."
25879
+ }
25880
+ }
25881
+ },
25882
+ inputs: {
25883
+ type: "object",
25884
+ 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.",
25885
+ additionalProperties: {
25886
+ oneOf: [
25887
+ { type: "null" },
25888
+ { $ref: "#/$defs/inputField" }
25889
+ ]
25890
+ }
25891
+ },
25892
+ inputField: {
25893
+ type: "object",
25894
+ description: "JSON Schema field definition with optional 'required: true' shortcut.",
25895
+ properties: {
25896
+ type: {
25897
+ type: "string",
25898
+ enum: ["string", "integer", "number", "boolean", "array", "object"]
25899
+ },
25900
+ description: { type: "string" },
25901
+ default: {},
25902
+ required: { type: "boolean" },
25903
+ format: { type: "string" },
25904
+ enum: { type: "array" },
25905
+ minimum: { type: "number" },
25906
+ maximum: { type: "number" },
25907
+ minLength: { type: "integer" },
25908
+ maxLength: { type: "integer" },
25909
+ pattern: { type: "string" },
25910
+ items: {
25911
+ $ref: "#/$defs/inputField"
25912
+ }
25913
+ },
25914
+ additionalProperties: false
25915
+ },
25916
+ retryConfig: {
25917
+ type: "object",
25918
+ description: "Retry configuration. Only applies when onError is 'retry'.",
25919
+ additionalProperties: false,
25920
+ required: ["max"],
25921
+ properties: {
25922
+ max: {
25923
+ type: "integer",
25924
+ minimum: 1,
25925
+ description: "Maximum number of retry attempts."
25926
+ },
25927
+ backoff: {
25928
+ $ref: "#/$defs/duration",
25929
+ description: "Interval between attempts. Default: 0s."
25930
+ },
25931
+ factor: {
25932
+ type: "number",
25933
+ minimum: 1,
25934
+ description: "Backoff multiplier. Default: 1 (no escalation)."
25935
+ }
25936
+ }
25937
+ },
25938
+ onError: {
25939
+ type: "string",
25940
+ description: "Error handling strategy: 'fail' (default), 'skip', 'retry', or a participant name for redirect.",
25941
+ minLength: 1
25942
+ },
25943
+ onTimeout: {
25944
+ type: "string",
25945
+ description: "Timeout handling strategy: 'fail' (default), 'skip', or a participant name for redirect.",
25946
+ minLength: 1
25947
+ },
25948
+ participantInput: {
25949
+ 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.",
25950
+ oneOf: [
25951
+ { type: "string" },
25952
+ {
25953
+ type: "object",
25954
+ additionalProperties: {
25955
+ type: "string"
25956
+ }
25957
+ }
25958
+ ]
25959
+ },
25960
+ participantOutputSchema: {
25961
+ type: "object",
25962
+ description: "Output schema (JSON Schema fields). Opt-in validation.",
25963
+ additionalProperties: {
25964
+ $ref: "#/$defs/inputField"
25965
+ }
25966
+ },
25967
+ payload: {
25968
+ description: "Event payload. String (CEL expression) or object with CEL expressions as values.",
25969
+ oneOf: [
25970
+ { type: "string" },
25971
+ {
25972
+ type: "object",
25973
+ additionalProperties: {}
25974
+ }
25975
+ ]
25976
+ },
25977
+ participant: {
25978
+ type: "object",
25979
+ required: ["type"],
25980
+ description: "A named, reusable building block of the workflow.",
25981
+ properties: {
25982
+ type: {
25983
+ type: "string",
25984
+ enum: ["exec", "http", "mcp", "workflow", "emit"],
25985
+ description: "Participant type."
25986
+ },
25987
+ as: {
25988
+ type: "string",
25989
+ description: "Human-readable display name."
25990
+ },
25991
+ timeout: {
25992
+ $ref: "#/$defs/duration"
25993
+ },
25994
+ onError: {
25995
+ $ref: "#/$defs/onError"
25996
+ },
25997
+ retry: {
25998
+ $ref: "#/$defs/retryConfig"
25999
+ },
26000
+ input: {
26001
+ $ref: "#/$defs/participantInput"
26002
+ },
26003
+ output: {
26004
+ $ref: "#/$defs/participantOutputSchema"
26005
+ },
26006
+ run: {
26007
+ type: "string",
26008
+ description: "[exec] Shell command to execute."
26009
+ },
26010
+ cwd: {
26011
+ type: "string",
26012
+ description: "[exec] Working directory. Supports CEL expressions."
26013
+ },
26014
+ url: {
26015
+ type: "string",
26016
+ description: "[http] Target URL. Supports CEL expressions."
26017
+ },
26018
+ method: {
26019
+ type: "string",
26020
+ enum: ["GET", "POST", "PUT", "PATCH", "DELETE"],
26021
+ description: "[http] HTTP method."
26022
+ },
26023
+ headers: {
26024
+ type: "object",
26025
+ additionalProperties: { type: "string" },
26026
+ description: "[http] HTTP headers. Values support CEL expressions."
26027
+ },
26028
+ body: {
26029
+ description: "[http] Request body. String or object. Supports CEL expressions.",
26030
+ oneOf: [
26031
+ { type: "string" },
26032
+ { type: "object" }
26033
+ ]
26034
+ },
26035
+ path: {
26036
+ type: "string",
26037
+ description: "[workflow] Path to the sub-workflow YAML file."
26038
+ },
26039
+ server: {
26040
+ type: "string",
26041
+ description: "[mcp] MCP server identifier."
26042
+ },
26043
+ tool: {
26044
+ type: "string",
26045
+ description: "[mcp] MCP tool name to invoke."
26046
+ },
26047
+ event: {
26048
+ type: "string",
26049
+ description: "[emit] Event name to emit."
26050
+ },
26051
+ payload: {
26052
+ $ref: "#/$defs/payload",
26053
+ description: "[emit] Event payload. CEL expression or object with CEL expressions."
26054
+ },
26055
+ ack: {
26056
+ type: "boolean",
26057
+ description: "[emit] If true, wait for delivery acknowledgment. Default: false.",
26058
+ default: false
26059
+ }
26060
+ },
26061
+ additionalProperties: false
26062
+ },
26063
+ inlineParticipant: {
26064
+ type: "object",
26065
+ required: ["type"],
26066
+ 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.",
26067
+ properties: {
26068
+ as: {
26069
+ type: "string",
26070
+ description: "Optional name for inline participants. If provided, must be unique across all participant names. Enables output reference by name."
26071
+ },
26072
+ type: {
26073
+ type: "string",
26074
+ enum: ["exec", "http", "mcp", "workflow", "emit"],
26075
+ description: "Participant type."
26076
+ },
26077
+ when: {
26078
+ $ref: "#/$defs/celExpression",
26079
+ description: "Guard condition. If false, step is skipped."
26080
+ },
26081
+ timeout: {
26082
+ $ref: "#/$defs/duration"
26083
+ },
26084
+ onError: {
26085
+ $ref: "#/$defs/onError"
26086
+ },
26087
+ retry: {
26088
+ $ref: "#/$defs/retryConfig"
26089
+ },
26090
+ input: {
26091
+ $ref: "#/$defs/participantInput"
26092
+ },
26093
+ output: {
26094
+ $ref: "#/$defs/participantOutputSchema"
26095
+ },
26096
+ run: { type: "string" },
26097
+ cwd: { type: "string" },
26098
+ url: { type: "string" },
26099
+ method: { type: "string", enum: ["GET", "POST", "PUT", "PATCH", "DELETE"] },
26100
+ headers: { type: "object", additionalProperties: { type: "string" } },
26101
+ body: { oneOf: [{ type: "string" }, { type: "object" }] },
26102
+ path: { type: "string" },
26103
+ server: { type: "string" },
26104
+ tool: { type: "string" },
26105
+ event: { type: "string" },
26106
+ payload: { $ref: "#/$defs/payload" },
26107
+ ack: { type: "boolean" }
26108
+ },
26109
+ additionalProperties: false
26110
+ },
26111
+ flowSequence: {
26112
+ type: "array",
26113
+ description: "Ordered list of flow steps. Each step's output is implicitly chained as input to the next step.",
26114
+ minItems: 1,
26115
+ items: {
26116
+ $ref: "#/$defs/flowStep"
26117
+ }
26118
+ },
26119
+ flowStep: {
26120
+ description: "A single step in the flow: participant reference (string), control construct, inline participant (named or anonymous), or participant override.",
26121
+ oneOf: [
26122
+ {
26123
+ type: "string",
26124
+ description: "Simple participant reference by name."
26125
+ },
26126
+ { $ref: "#/$defs/loopStep" },
26127
+ { $ref: "#/$defs/parallelStep" },
26128
+ { $ref: "#/$defs/ifStep" },
26129
+ { $ref: "#/$defs/setStep" },
26130
+ { $ref: "#/$defs/waitStep" },
26131
+ { $ref: "#/$defs/inlineParticipant" },
26132
+ { $ref: "#/$defs/participantOverrideStep" }
26133
+ ]
26134
+ },
26135
+ loopStep: {
26136
+ type: "object",
26137
+ required: ["loop"],
26138
+ additionalProperties: false,
26139
+ properties: {
26140
+ loop: {
26141
+ type: "object",
26142
+ additionalProperties: false,
26143
+ required: ["steps"],
26144
+ properties: {
26145
+ as: {
26146
+ type: "string",
26147
+ description: "Renames the loop context variable. Access as <as>.index, <as>.iteration, etc. instead of loop.*"
26148
+ },
26149
+ until: {
26150
+ $ref: "#/$defs/celExpression",
26151
+ description: "CEL condition to break out of the loop."
26152
+ },
26153
+ max: {
26154
+ description: "Maximum iterations. Integer or CEL expression.",
26155
+ oneOf: [
26156
+ { type: "integer", minimum: 1 },
26157
+ { type: "string" }
26158
+ ]
26159
+ },
26160
+ steps: {
26161
+ $ref: "#/$defs/flowSequence"
26162
+ }
26163
+ },
26164
+ anyOf: [
26165
+ { required: ["until"] },
26166
+ { required: ["max"] }
26167
+ ]
26168
+ }
26169
+ }
26170
+ },
26171
+ parallelStep: {
26172
+ type: "object",
26173
+ required: ["parallel"],
26174
+ additionalProperties: false,
26175
+ properties: {
26176
+ parallel: {
26177
+ $ref: "#/$defs/flowSequence",
26178
+ description: "Steps to run concurrently. The chained output after a parallel block is an array of all branch outputs in declaration order."
26179
+ }
26180
+ }
26181
+ },
26182
+ ifStep: {
26183
+ type: "object",
26184
+ required: ["if"],
26185
+ additionalProperties: false,
26186
+ properties: {
26187
+ if: {
26188
+ type: "object",
26189
+ required: ["condition", "then"],
26190
+ additionalProperties: false,
26191
+ properties: {
26192
+ condition: {
26193
+ $ref: "#/$defs/celExpression",
26194
+ description: "CEL expression that determines which branch to take."
26195
+ },
26196
+ then: {
26197
+ $ref: "#/$defs/flowSequence"
26198
+ },
26199
+ else: {
26200
+ $ref: "#/$defs/flowSequence"
26201
+ }
26202
+ }
26203
+ }
26204
+ }
26205
+ },
26206
+ setStep: {
26207
+ type: "object",
26208
+ required: ["set"],
26209
+ additionalProperties: false,
26210
+ properties: {
26211
+ set: {
26212
+ type: "object",
26213
+ description: "Writes values into execution.context. Each key becomes execution.context.<key>. Values are CEL expressions.",
26214
+ minProperties: 1,
26215
+ additionalProperties: {
26216
+ $ref: "#/$defs/celExpression"
26217
+ },
26218
+ not: {
26219
+ anyOf: [
26220
+ { required: ["workflow"] },
26221
+ { required: ["execution"] },
26222
+ { required: ["input"] },
26223
+ { required: ["output"] },
26224
+ { required: ["env"] },
26225
+ { required: ["loop"] },
26226
+ { required: ["event"] }
26227
+ ]
26228
+ }
26229
+ }
26230
+ }
26231
+ },
26232
+ waitStep: {
26233
+ type: "object",
26234
+ required: ["wait"],
26235
+ additionalProperties: false,
26236
+ properties: {
26237
+ wait: {
26238
+ type: "object",
26239
+ additionalProperties: false,
26240
+ properties: {
26241
+ event: {
26242
+ type: "string",
26243
+ description: "Event name to wait for (event mode)."
26244
+ },
26245
+ match: {
26246
+ $ref: "#/$defs/celExpression",
26247
+ description: "CEL condition to match against event payload. 'event' variable contains the payload."
26248
+ },
26249
+ until: {
26250
+ $ref: "#/$defs/celExpression",
26251
+ description: "CEL condition to wait for (polling mode)."
26252
+ },
26253
+ poll: {
26254
+ $ref: "#/$defs/duration",
26255
+ description: "Polling interval for 'until' condition. Default: runtime decides."
26256
+ },
26257
+ timeout: {
26258
+ $ref: "#/$defs/duration",
26259
+ description: "Maximum wait time."
26260
+ },
26261
+ onTimeout: {
26262
+ $ref: "#/$defs/onTimeout",
26263
+ description: "Strategy when timeout is reached: 'fail' (default), 'skip', or participant name."
26264
+ }
26265
+ }
26266
+ }
26267
+ }
26268
+ },
26269
+ participantOverrideStep: {
26270
+ type: "object",
26271
+ description: "A participant reference with flow-level overrides (timeout, onError, when, input, workflow, etc.).",
26272
+ minProperties: 1,
26273
+ maxProperties: 1,
26274
+ not: {
26275
+ anyOf: [
26276
+ { required: ["loop"] },
26277
+ { required: ["parallel"] },
26278
+ { required: ["if"] },
26279
+ { required: ["wait"] },
26280
+ { required: ["set"] },
26281
+ { required: ["type"] }
26282
+ ]
26283
+ },
26284
+ additionalProperties: {
26285
+ type: "object",
26286
+ properties: {
26287
+ when: {
26288
+ $ref: "#/$defs/celExpression",
26289
+ description: "Guard condition. If false, step is skipped."
26290
+ },
26291
+ timeout: {
26292
+ $ref: "#/$defs/duration"
26293
+ },
26294
+ onError: {
26295
+ $ref: "#/$defs/onError"
26296
+ },
26297
+ retry: {
26298
+ $ref: "#/$defs/retryConfig"
26299
+ },
26300
+ input: {
26301
+ $ref: "#/$defs/participantInput"
26302
+ },
26303
+ workflow: {
26304
+ type: "string",
26305
+ description: "Inline sub-workflow path (alternative to defining as participant)."
26306
+ }
26307
+ },
26308
+ additionalProperties: false
26309
+ }
26310
+ },
26311
+ workflowOutput: {
26312
+ description: "Workflow output. Accessed in CEL as workflow.output. String (single CEL expression), object (structured mapping), or object with schema+map.",
26313
+ oneOf: [
26314
+ {
26315
+ type: "string",
26316
+ description: "Single CEL expression mapping."
26317
+ },
26318
+ {
26319
+ type: "object",
26320
+ description: "Structured output mapping (key → CEL expression) or schema+map.",
26321
+ properties: {
26322
+ schema: {
26323
+ type: "object",
26324
+ additionalProperties: {
26325
+ $ref: "#/$defs/inputField"
26326
+ }
26327
+ },
26328
+ map: {
26329
+ type: "object",
26330
+ additionalProperties: {
26331
+ type: "string"
26332
+ }
26333
+ }
26334
+ },
26335
+ additionalProperties: {
26336
+ type: "string"
26337
+ }
26338
+ }
26339
+ ]
26340
+ }
26341
+ }
26342
+ };
26343
+ });
25802
26344
  function validateSchema(workflow) {
25803
26345
  const valid = validate(workflow);
25804
26346
  if (valid) {
@@ -25812,15 +26354,14 @@ function validateSchema(workflow) {
25812
26354
  }
25813
26355
  var import__2020;
25814
26356
  var import_ajv_formats;
25815
- var rawSchema;
25816
26357
  var schema;
25817
26358
  var ajv;
25818
26359
  var validate;
25819
26360
  var init_schema = __esm2(() => {
26361
+ init_duckflux_schema();
25820
26362
  import__2020 = __toESM(require_2020(), 1);
25821
26363
  import_ajv_formats = __toESM(require_dist2(), 1);
25822
- rawSchema = readFileSync(new URL("./schema/duckflux.schema.json", import.meta.url), "utf-8");
25823
- schema = JSON.parse(rawSchema);
26364
+ schema = { ...duckflux_schema_default };
25824
26365
  delete schema.$schema;
25825
26366
  ajv = new import__2020.default({ allErrors: true, strict: false });
25826
26367
  import_ajv_formats.default(ajv);
@@ -27883,7 +28424,6 @@ import { readFile as readFile5 } from "node:fs/promises";
27883
28424
  // ../core/dist/engine/index.js
27884
28425
  import { createRequire as createRequire3 } from "node:module";
27885
28426
  import { readFile as readFile3 } from "node:fs/promises";
27886
- import { readFileSync as readFileSync2 } from "node:fs";
27887
28427
  import { constants as constants2 } from "node:fs";
27888
28428
  import { access as access2 } from "node:fs/promises";
27889
28429
  import { resolve as resolve3 } from "node:path";
@@ -53549,6 +54089,549 @@ var require_dist22 = __commonJS2((exports, module) => {
53549
54089
  Object.defineProperty(exports, "__esModule", { value: true });
53550
54090
  exports.default = formatsPlugin;
53551
54091
  });
54092
+ var duckflux_schema_default2;
54093
+ var init_duckflux_schema2 = __esm3(() => {
54094
+ duckflux_schema_default2 = {
54095
+ $schema: "https://json-schema.org/draft/2020-12/schema",
54096
+ $id: "https://raw.githubusercontent.com/duckflux/spec/main/duckflux.schema.json",
54097
+ title: "duckflux Workflow",
54098
+ description: "Schema for duckflux — a minimal, deterministic, runtime-agnostic workflow DSL.",
54099
+ type: "object",
54100
+ required: ["flow"],
54101
+ additionalProperties: false,
54102
+ properties: {
54103
+ id: {
54104
+ type: "string",
54105
+ description: "Unique identifier for the workflow."
54106
+ },
54107
+ name: {
54108
+ type: "string",
54109
+ description: "Human-readable workflow name."
54110
+ },
54111
+ version: {
54112
+ description: "Version identifier for the workflow definition.",
54113
+ oneOf: [
54114
+ { type: "string" },
54115
+ { type: "integer" }
54116
+ ]
54117
+ },
54118
+ defaults: {
54119
+ $ref: "#/$defs/defaults"
54120
+ },
54121
+ inputs: {
54122
+ $ref: "#/$defs/inputs"
54123
+ },
54124
+ participants: {
54125
+ type: "object",
54126
+ description: "Named steps that can be referenced in the flow.",
54127
+ additionalProperties: {
54128
+ $ref: "#/$defs/participant"
54129
+ },
54130
+ not: {
54131
+ anyOf: [
54132
+ { required: ["workflow"] },
54133
+ { required: ["execution"] },
54134
+ { required: ["input"] },
54135
+ { required: ["output"] },
54136
+ { required: ["env"] },
54137
+ { required: ["loop"] },
54138
+ { required: ["event"] }
54139
+ ]
54140
+ }
54141
+ },
54142
+ flow: {
54143
+ $ref: "#/$defs/flowSequence"
54144
+ },
54145
+ output: {
54146
+ $ref: "#/$defs/workflowOutput"
54147
+ }
54148
+ },
54149
+ $defs: {
54150
+ duration: {
54151
+ type: "string",
54152
+ pattern: "^[0-9]+(ms|s|m|h|d)$",
54153
+ description: "Duration string, e.g. '30s', '5m', '2h', '1d'."
54154
+ },
54155
+ celExpression: {
54156
+ type: "string",
54157
+ description: "A Google CEL expression."
54158
+ },
54159
+ defaults: {
54160
+ type: "object",
54161
+ description: "Global defaults applied to all participants.",
54162
+ additionalProperties: false,
54163
+ properties: {
54164
+ timeout: {
54165
+ $ref: "#/$defs/duration"
54166
+ },
54167
+ cwd: {
54168
+ type: "string",
54169
+ description: "Default working directory for exec participants. Supports CEL expressions."
54170
+ }
54171
+ }
54172
+ },
54173
+ inputs: {
54174
+ type: "object",
54175
+ 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.",
54176
+ additionalProperties: {
54177
+ oneOf: [
54178
+ { type: "null" },
54179
+ { $ref: "#/$defs/inputField" }
54180
+ ]
54181
+ }
54182
+ },
54183
+ inputField: {
54184
+ type: "object",
54185
+ description: "JSON Schema field definition with optional 'required: true' shortcut.",
54186
+ properties: {
54187
+ type: {
54188
+ type: "string",
54189
+ enum: ["string", "integer", "number", "boolean", "array", "object"]
54190
+ },
54191
+ description: { type: "string" },
54192
+ default: {},
54193
+ required: { type: "boolean" },
54194
+ format: { type: "string" },
54195
+ enum: { type: "array" },
54196
+ minimum: { type: "number" },
54197
+ maximum: { type: "number" },
54198
+ minLength: { type: "integer" },
54199
+ maxLength: { type: "integer" },
54200
+ pattern: { type: "string" },
54201
+ items: {
54202
+ $ref: "#/$defs/inputField"
54203
+ }
54204
+ },
54205
+ additionalProperties: false
54206
+ },
54207
+ retryConfig: {
54208
+ type: "object",
54209
+ description: "Retry configuration. Only applies when onError is 'retry'.",
54210
+ additionalProperties: false,
54211
+ required: ["max"],
54212
+ properties: {
54213
+ max: {
54214
+ type: "integer",
54215
+ minimum: 1,
54216
+ description: "Maximum number of retry attempts."
54217
+ },
54218
+ backoff: {
54219
+ $ref: "#/$defs/duration",
54220
+ description: "Interval between attempts. Default: 0s."
54221
+ },
54222
+ factor: {
54223
+ type: "number",
54224
+ minimum: 1,
54225
+ description: "Backoff multiplier. Default: 1 (no escalation)."
54226
+ }
54227
+ }
54228
+ },
54229
+ onError: {
54230
+ type: "string",
54231
+ description: "Error handling strategy: 'fail' (default), 'skip', 'retry', or a participant name for redirect.",
54232
+ minLength: 1
54233
+ },
54234
+ onTimeout: {
54235
+ type: "string",
54236
+ description: "Timeout handling strategy: 'fail' (default), 'skip', or a participant name for redirect.",
54237
+ minLength: 1
54238
+ },
54239
+ participantInput: {
54240
+ 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.",
54241
+ oneOf: [
54242
+ { type: "string" },
54243
+ {
54244
+ type: "object",
54245
+ additionalProperties: {
54246
+ type: "string"
54247
+ }
54248
+ }
54249
+ ]
54250
+ },
54251
+ participantOutputSchema: {
54252
+ type: "object",
54253
+ description: "Output schema (JSON Schema fields). Opt-in validation.",
54254
+ additionalProperties: {
54255
+ $ref: "#/$defs/inputField"
54256
+ }
54257
+ },
54258
+ payload: {
54259
+ description: "Event payload. String (CEL expression) or object with CEL expressions as values.",
54260
+ oneOf: [
54261
+ { type: "string" },
54262
+ {
54263
+ type: "object",
54264
+ additionalProperties: {}
54265
+ }
54266
+ ]
54267
+ },
54268
+ participant: {
54269
+ type: "object",
54270
+ required: ["type"],
54271
+ description: "A named, reusable building block of the workflow.",
54272
+ properties: {
54273
+ type: {
54274
+ type: "string",
54275
+ enum: ["exec", "http", "mcp", "workflow", "emit"],
54276
+ description: "Participant type."
54277
+ },
54278
+ as: {
54279
+ type: "string",
54280
+ description: "Human-readable display name."
54281
+ },
54282
+ timeout: {
54283
+ $ref: "#/$defs/duration"
54284
+ },
54285
+ onError: {
54286
+ $ref: "#/$defs/onError"
54287
+ },
54288
+ retry: {
54289
+ $ref: "#/$defs/retryConfig"
54290
+ },
54291
+ input: {
54292
+ $ref: "#/$defs/participantInput"
54293
+ },
54294
+ output: {
54295
+ $ref: "#/$defs/participantOutputSchema"
54296
+ },
54297
+ run: {
54298
+ type: "string",
54299
+ description: "[exec] Shell command to execute."
54300
+ },
54301
+ cwd: {
54302
+ type: "string",
54303
+ description: "[exec] Working directory. Supports CEL expressions."
54304
+ },
54305
+ url: {
54306
+ type: "string",
54307
+ description: "[http] Target URL. Supports CEL expressions."
54308
+ },
54309
+ method: {
54310
+ type: "string",
54311
+ enum: ["GET", "POST", "PUT", "PATCH", "DELETE"],
54312
+ description: "[http] HTTP method."
54313
+ },
54314
+ headers: {
54315
+ type: "object",
54316
+ additionalProperties: { type: "string" },
54317
+ description: "[http] HTTP headers. Values support CEL expressions."
54318
+ },
54319
+ body: {
54320
+ description: "[http] Request body. String or object. Supports CEL expressions.",
54321
+ oneOf: [
54322
+ { type: "string" },
54323
+ { type: "object" }
54324
+ ]
54325
+ },
54326
+ path: {
54327
+ type: "string",
54328
+ description: "[workflow] Path to the sub-workflow YAML file."
54329
+ },
54330
+ server: {
54331
+ type: "string",
54332
+ description: "[mcp] MCP server identifier."
54333
+ },
54334
+ tool: {
54335
+ type: "string",
54336
+ description: "[mcp] MCP tool name to invoke."
54337
+ },
54338
+ event: {
54339
+ type: "string",
54340
+ description: "[emit] Event name to emit."
54341
+ },
54342
+ payload: {
54343
+ $ref: "#/$defs/payload",
54344
+ description: "[emit] Event payload. CEL expression or object with CEL expressions."
54345
+ },
54346
+ ack: {
54347
+ type: "boolean",
54348
+ description: "[emit] If true, wait for delivery acknowledgment. Default: false.",
54349
+ default: false
54350
+ }
54351
+ },
54352
+ additionalProperties: false
54353
+ },
54354
+ inlineParticipant: {
54355
+ type: "object",
54356
+ required: ["type"],
54357
+ 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.",
54358
+ properties: {
54359
+ as: {
54360
+ type: "string",
54361
+ description: "Optional name for inline participants. If provided, must be unique across all participant names. Enables output reference by name."
54362
+ },
54363
+ type: {
54364
+ type: "string",
54365
+ enum: ["exec", "http", "mcp", "workflow", "emit"],
54366
+ description: "Participant type."
54367
+ },
54368
+ when: {
54369
+ $ref: "#/$defs/celExpression",
54370
+ description: "Guard condition. If false, step is skipped."
54371
+ },
54372
+ timeout: {
54373
+ $ref: "#/$defs/duration"
54374
+ },
54375
+ onError: {
54376
+ $ref: "#/$defs/onError"
54377
+ },
54378
+ retry: {
54379
+ $ref: "#/$defs/retryConfig"
54380
+ },
54381
+ input: {
54382
+ $ref: "#/$defs/participantInput"
54383
+ },
54384
+ output: {
54385
+ $ref: "#/$defs/participantOutputSchema"
54386
+ },
54387
+ run: { type: "string" },
54388
+ cwd: { type: "string" },
54389
+ url: { type: "string" },
54390
+ method: { type: "string", enum: ["GET", "POST", "PUT", "PATCH", "DELETE"] },
54391
+ headers: { type: "object", additionalProperties: { type: "string" } },
54392
+ body: { oneOf: [{ type: "string" }, { type: "object" }] },
54393
+ path: { type: "string" },
54394
+ server: { type: "string" },
54395
+ tool: { type: "string" },
54396
+ event: { type: "string" },
54397
+ payload: { $ref: "#/$defs/payload" },
54398
+ ack: { type: "boolean" }
54399
+ },
54400
+ additionalProperties: false
54401
+ },
54402
+ flowSequence: {
54403
+ type: "array",
54404
+ description: "Ordered list of flow steps. Each step's output is implicitly chained as input to the next step.",
54405
+ minItems: 1,
54406
+ items: {
54407
+ $ref: "#/$defs/flowStep"
54408
+ }
54409
+ },
54410
+ flowStep: {
54411
+ description: "A single step in the flow: participant reference (string), control construct, inline participant (named or anonymous), or participant override.",
54412
+ oneOf: [
54413
+ {
54414
+ type: "string",
54415
+ description: "Simple participant reference by name."
54416
+ },
54417
+ { $ref: "#/$defs/loopStep" },
54418
+ { $ref: "#/$defs/parallelStep" },
54419
+ { $ref: "#/$defs/ifStep" },
54420
+ { $ref: "#/$defs/setStep" },
54421
+ { $ref: "#/$defs/waitStep" },
54422
+ { $ref: "#/$defs/inlineParticipant" },
54423
+ { $ref: "#/$defs/participantOverrideStep" }
54424
+ ]
54425
+ },
54426
+ loopStep: {
54427
+ type: "object",
54428
+ required: ["loop"],
54429
+ additionalProperties: false,
54430
+ properties: {
54431
+ loop: {
54432
+ type: "object",
54433
+ additionalProperties: false,
54434
+ required: ["steps"],
54435
+ properties: {
54436
+ as: {
54437
+ type: "string",
54438
+ description: "Renames the loop context variable. Access as <as>.index, <as>.iteration, etc. instead of loop.*"
54439
+ },
54440
+ until: {
54441
+ $ref: "#/$defs/celExpression",
54442
+ description: "CEL condition to break out of the loop."
54443
+ },
54444
+ max: {
54445
+ description: "Maximum iterations. Integer or CEL expression.",
54446
+ oneOf: [
54447
+ { type: "integer", minimum: 1 },
54448
+ { type: "string" }
54449
+ ]
54450
+ },
54451
+ steps: {
54452
+ $ref: "#/$defs/flowSequence"
54453
+ }
54454
+ },
54455
+ anyOf: [
54456
+ { required: ["until"] },
54457
+ { required: ["max"] }
54458
+ ]
54459
+ }
54460
+ }
54461
+ },
54462
+ parallelStep: {
54463
+ type: "object",
54464
+ required: ["parallel"],
54465
+ additionalProperties: false,
54466
+ properties: {
54467
+ parallel: {
54468
+ $ref: "#/$defs/flowSequence",
54469
+ description: "Steps to run concurrently. The chained output after a parallel block is an array of all branch outputs in declaration order."
54470
+ }
54471
+ }
54472
+ },
54473
+ ifStep: {
54474
+ type: "object",
54475
+ required: ["if"],
54476
+ additionalProperties: false,
54477
+ properties: {
54478
+ if: {
54479
+ type: "object",
54480
+ required: ["condition", "then"],
54481
+ additionalProperties: false,
54482
+ properties: {
54483
+ condition: {
54484
+ $ref: "#/$defs/celExpression",
54485
+ description: "CEL expression that determines which branch to take."
54486
+ },
54487
+ then: {
54488
+ $ref: "#/$defs/flowSequence"
54489
+ },
54490
+ else: {
54491
+ $ref: "#/$defs/flowSequence"
54492
+ }
54493
+ }
54494
+ }
54495
+ }
54496
+ },
54497
+ setStep: {
54498
+ type: "object",
54499
+ required: ["set"],
54500
+ additionalProperties: false,
54501
+ properties: {
54502
+ set: {
54503
+ type: "object",
54504
+ description: "Writes values into execution.context. Each key becomes execution.context.<key>. Values are CEL expressions.",
54505
+ minProperties: 1,
54506
+ additionalProperties: {
54507
+ $ref: "#/$defs/celExpression"
54508
+ },
54509
+ not: {
54510
+ anyOf: [
54511
+ { required: ["workflow"] },
54512
+ { required: ["execution"] },
54513
+ { required: ["input"] },
54514
+ { required: ["output"] },
54515
+ { required: ["env"] },
54516
+ { required: ["loop"] },
54517
+ { required: ["event"] }
54518
+ ]
54519
+ }
54520
+ }
54521
+ }
54522
+ },
54523
+ waitStep: {
54524
+ type: "object",
54525
+ required: ["wait"],
54526
+ additionalProperties: false,
54527
+ properties: {
54528
+ wait: {
54529
+ type: "object",
54530
+ additionalProperties: false,
54531
+ properties: {
54532
+ event: {
54533
+ type: "string",
54534
+ description: "Event name to wait for (event mode)."
54535
+ },
54536
+ match: {
54537
+ $ref: "#/$defs/celExpression",
54538
+ description: "CEL condition to match against event payload. 'event' variable contains the payload."
54539
+ },
54540
+ until: {
54541
+ $ref: "#/$defs/celExpression",
54542
+ description: "CEL condition to wait for (polling mode)."
54543
+ },
54544
+ poll: {
54545
+ $ref: "#/$defs/duration",
54546
+ description: "Polling interval for 'until' condition. Default: runtime decides."
54547
+ },
54548
+ timeout: {
54549
+ $ref: "#/$defs/duration",
54550
+ description: "Maximum wait time."
54551
+ },
54552
+ onTimeout: {
54553
+ $ref: "#/$defs/onTimeout",
54554
+ description: "Strategy when timeout is reached: 'fail' (default), 'skip', or participant name."
54555
+ }
54556
+ }
54557
+ }
54558
+ }
54559
+ },
54560
+ participantOverrideStep: {
54561
+ type: "object",
54562
+ description: "A participant reference with flow-level overrides (timeout, onError, when, input, workflow, etc.).",
54563
+ minProperties: 1,
54564
+ maxProperties: 1,
54565
+ not: {
54566
+ anyOf: [
54567
+ { required: ["loop"] },
54568
+ { required: ["parallel"] },
54569
+ { required: ["if"] },
54570
+ { required: ["wait"] },
54571
+ { required: ["set"] },
54572
+ { required: ["type"] }
54573
+ ]
54574
+ },
54575
+ additionalProperties: {
54576
+ type: "object",
54577
+ properties: {
54578
+ when: {
54579
+ $ref: "#/$defs/celExpression",
54580
+ description: "Guard condition. If false, step is skipped."
54581
+ },
54582
+ timeout: {
54583
+ $ref: "#/$defs/duration"
54584
+ },
54585
+ onError: {
54586
+ $ref: "#/$defs/onError"
54587
+ },
54588
+ retry: {
54589
+ $ref: "#/$defs/retryConfig"
54590
+ },
54591
+ input: {
54592
+ $ref: "#/$defs/participantInput"
54593
+ },
54594
+ workflow: {
54595
+ type: "string",
54596
+ description: "Inline sub-workflow path (alternative to defining as participant)."
54597
+ }
54598
+ },
54599
+ additionalProperties: false
54600
+ }
54601
+ },
54602
+ workflowOutput: {
54603
+ description: "Workflow output. Accessed in CEL as workflow.output. String (single CEL expression), object (structured mapping), or object with schema+map.",
54604
+ oneOf: [
54605
+ {
54606
+ type: "string",
54607
+ description: "Single CEL expression mapping."
54608
+ },
54609
+ {
54610
+ type: "object",
54611
+ description: "Structured output mapping (key → CEL expression) or schema+map.",
54612
+ properties: {
54613
+ schema: {
54614
+ type: "object",
54615
+ additionalProperties: {
54616
+ $ref: "#/$defs/inputField"
54617
+ }
54618
+ },
54619
+ map: {
54620
+ type: "object",
54621
+ additionalProperties: {
54622
+ type: "string"
54623
+ }
54624
+ }
54625
+ },
54626
+ additionalProperties: {
54627
+ type: "string"
54628
+ }
54629
+ }
54630
+ ]
54631
+ }
54632
+ }
54633
+ };
54634
+ });
53552
54635
  function validateSchema2(workflow) {
53553
54636
  const valid = validate2(workflow);
53554
54637
  if (valid) {
@@ -53562,15 +54645,14 @@ function validateSchema2(workflow) {
53562
54645
  }
53563
54646
  var import__20202;
53564
54647
  var import_ajv_formats2;
53565
- var rawSchema2;
53566
54648
  var schema2;
53567
54649
  var ajv2;
53568
54650
  var validate2;
53569
54651
  var init_schema2 = __esm3(() => {
54652
+ init_duckflux_schema2();
53570
54653
  import__20202 = __toESM2(require_20202(), 1);
53571
54654
  import_ajv_formats2 = __toESM2(require_dist22(), 1);
53572
- rawSchema2 = readFileSync2(new URL("./schema/duckflux.schema.json", import.meta.url), "utf-8");
53573
- schema2 = JSON.parse(rawSchema2);
54655
+ schema2 = { ...duckflux_schema_default2 };
53574
54656
  delete schema2.$schema;
53575
54657
  ajv2 = new import__20202.default({ allErrors: true, strict: false });
53576
54658
  import_ajv_formats2.default(ajv2);
@@ -55961,7 +57043,7 @@ async function validateCommand(filePath, cliValues) {
55961
57043
  // src/main.ts
55962
57044
  function getVersion() {
55963
57045
  try {
55964
- const pkg = JSON.parse(readFileSync3(resolve5(dirname5(new URL(import.meta.url).pathname), "../package.json"), "utf-8"));
57046
+ const pkg = JSON.parse(readFileSync(resolve5(dirname5(new URL(import.meta.url).pathname), "../package.json"), "utf-8"));
55965
57047
  return pkg.version ?? "0.0.0";
55966
57048
  } catch {
55967
57049
  return "0.0.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duckflux/runner",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "quack": "dist/main.js"