@xyne/workflow-sdk 3.2.38 → 3.2.39
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/connectors/builtin/builtin-connector.d.ts +1 -0
- package/dist/connectors/builtin/builtin-connector.d.ts.map +1 -1
- package/dist/connectors/builtin/builtin-connector.js +1 -0
- package/dist/connectors/builtin/builtin-connector.js.map +1 -1
- package/dist/connectors/core/base-connector.d.ts +5 -0
- package/dist/connectors/core/base-connector.d.ts.map +1 -1
- package/dist/connectors/core/base-connector.js +5 -0
- package/dist/connectors/core/base-connector.js.map +1 -1
- package/dist/connectors/core/connector-registry.d.ts.map +1 -1
- package/dist/connectors/core/connector-registry.js +7 -11
- package/dist/connectors/core/connector-registry.js.map +1 -1
- package/dist/router/workflow-router.d.ts.map +1 -1
- package/dist/router/workflow-router.js +22 -5
- package/dist/router/workflow-router.js.map +1 -1
- package/dist/runtime/workflow-runtime.d.ts +8 -5
- package/dist/runtime/workflow-runtime.d.ts.map +1 -1
- package/dist/runtime/workflow-runtime.js +20 -5
- package/dist/runtime/workflow-runtime.js.map +1 -1
- package/dist/steps/base-step.d.ts +1 -0
- package/dist/steps/base-step.d.ts.map +1 -1
- package/dist/steps/base-step.js +1 -0
- package/dist/steps/base-step.js.map +1 -1
- package/dist/steps/step-descriptor.d.ts +2 -0
- package/dist/steps/step-descriptor.d.ts.map +1 -1
- package/dist/steps/step-descriptor.js +1 -0
- package/dist/steps/step-descriptor.js.map +1 -1
- package/dist/triggers/base-trigger.d.ts +1 -0
- package/dist/triggers/base-trigger.d.ts.map +1 -1
- package/dist/triggers/base-trigger.js +1 -0
- package/dist/triggers/base-trigger.js.map +1 -1
- package/dist/triggers/trigger-descriptor.d.ts +2 -0
- package/dist/triggers/trigger-descriptor.d.ts.map +1 -1
- package/dist/triggers/trigger-descriptor.js +1 -0
- package/dist/triggers/trigger-descriptor.js.map +1 -1
- package/dist/triggers/webhook-trigger.d.ts +22 -3
- package/dist/triggers/webhook-trigger.d.ts.map +1 -1
- package/dist/triggers/webhook-trigger.js +23 -2
- package/dist/triggers/webhook-trigger.js.map +1 -1
- package/package.json +1 -1
- package/dist/runtime/execution-event-bus.d.ts +0 -38
- package/dist/runtime/execution-event-bus.d.ts.map +0 -1
- package/dist/runtime/execution-event-bus.js +0 -87
- package/dist/runtime/execution-event-bus.js.map +0 -1
- package/dist/steps/builtin/code.step.d.ts +0 -99
- package/dist/steps/builtin/code.step.d.ts.map +0 -1
- package/dist/steps/builtin/code.step.js +0 -152
- package/dist/steps/builtin/code.step.js.map +0 -1
- package/dist/steps/builtin/conditional.step.d.ts +0 -182
- package/dist/steps/builtin/conditional.step.d.ts.map +0 -1
- package/dist/steps/builtin/conditional.step.js +0 -82
- package/dist/steps/builtin/conditional.step.js.map +0 -1
- package/dist/steps/builtin/dedup.step.d.ts +0 -65
- package/dist/steps/builtin/dedup.step.d.ts.map +0 -1
- package/dist/steps/builtin/dedup.step.js +0 -61
- package/dist/steps/builtin/dedup.step.js.map +0 -1
- package/dist/steps/builtin/http-request.step.d.ts +0 -1020
- package/dist/steps/builtin/http-request.step.d.ts.map +0 -1
- package/dist/steps/builtin/http-request.step.js +0 -491
- package/dist/steps/builtin/http-request.step.js.map +0 -1
- package/dist/steps/builtin/loop.step.d.ts +0 -100
- package/dist/steps/builtin/loop.step.d.ts.map +0 -1
- package/dist/steps/builtin/loop.step.js +0 -73
- package/dist/steps/builtin/loop.step.js.map +0 -1
- package/dist/steps/builtin/map.step.d.ts +0 -148
- package/dist/steps/builtin/map.step.d.ts.map +0 -1
- package/dist/steps/builtin/map.step.js +0 -111
- package/dist/steps/builtin/map.step.js.map +0 -1
- package/dist/steps/builtin/parallel.step.d.ts +0 -246
- package/dist/steps/builtin/parallel.step.d.ts.map +0 -1
- package/dist/steps/builtin/parallel.step.js +0 -175
- package/dist/steps/builtin/parallel.step.js.map +0 -1
- package/dist/steps/builtin/ssrf-guard.d.ts +0 -9
- package/dist/steps/builtin/ssrf-guard.d.ts.map +0 -1
- package/dist/steps/builtin/ssrf-guard.js +0 -115
- package/dist/steps/builtin/ssrf-guard.js.map +0 -1
- package/dist/steps/builtin/switch.step.d.ts +0 -235
- package/dist/steps/builtin/switch.step.d.ts.map +0 -1
- package/dist/steps/builtin/switch.step.js +0 -101
- package/dist/steps/builtin/switch.step.js.map +0 -1
- package/dist/steps/builtin/wait.step.d.ts +0 -1072
- package/dist/steps/builtin/wait.step.d.ts.map +0 -1
- package/dist/steps/builtin/wait.step.js +0 -254
- package/dist/steps/builtin/wait.step.js.map +0 -1
- package/dist/steps/step-registry.d.ts +0 -62
- package/dist/steps/step-registry.d.ts.map +0 -1
- package/dist/steps/step-registry.js +0 -103
- package/dist/steps/step-registry.js.map +0 -1
- package/dist/triggers/builtin/default-cron-trigger.d.ts +0 -44
- package/dist/triggers/builtin/default-cron-trigger.d.ts.map +0 -1
- package/dist/triggers/builtin/default-cron-trigger.js +0 -31
- package/dist/triggers/builtin/default-cron-trigger.js.map +0 -1
- package/dist/triggers/builtin/default-event-trigger.d.ts +0 -32
- package/dist/triggers/builtin/default-event-trigger.d.ts.map +0 -1
- package/dist/triggers/builtin/default-event-trigger.js +0 -21
- package/dist/triggers/builtin/default-event-trigger.js.map +0 -1
- package/dist/triggers/builtin/default-manual-trigger.d.ts +0 -45
- package/dist/triggers/builtin/default-manual-trigger.d.ts.map +0 -1
- package/dist/triggers/builtin/default-manual-trigger.js +0 -51
- package/dist/triggers/builtin/default-manual-trigger.js.map +0 -1
- package/dist/triggers/builtin/default-webhook-trigger.d.ts +0 -72
- package/dist/triggers/builtin/default-webhook-trigger.d.ts.map +0 -1
- package/dist/triggers/builtin/default-webhook-trigger.js +0 -91
- package/dist/triggers/builtin/default-webhook-trigger.js.map +0 -1
- package/dist/triggers/builtin/default-webhook-v2-trigger.d.ts +0 -29
- package/dist/triggers/builtin/default-webhook-v2-trigger.d.ts.map +0 -1
- package/dist/triggers/builtin/default-webhook-v2-trigger.js +0 -38
- package/dist/triggers/builtin/default-webhook-v2-trigger.js.map +0 -1
- package/dist/triggers/trigger-registry.d.ts +0 -48
- package/dist/triggers/trigger-registry.d.ts.map +0 -1
- package/dist/triggers/trigger-registry.js +0 -83
- package/dist/triggers/trigger-registry.js.map +0 -1
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ExecutionEventBus — in-memory pub/sub for execution stream events.
|
|
3
|
-
*
|
|
4
|
-
* The executor emits events at state transitions (step started/completed/failed,
|
|
5
|
-
* execution paused/completed/failed). The SSE route subscribes per-executionId
|
|
6
|
-
* and streams them to the client.
|
|
7
|
-
*/
|
|
8
|
-
export class ExecutionEventBus {
|
|
9
|
-
listeners = new Map();
|
|
10
|
-
/**
|
|
11
|
-
* Subscribe to events for a specific execution.
|
|
12
|
-
* Returns an unsubscribe function.
|
|
13
|
-
*/
|
|
14
|
-
subscribe(executionId, cb) {
|
|
15
|
-
let set = this.listeners.get(executionId);
|
|
16
|
-
if (!set) {
|
|
17
|
-
set = new Set();
|
|
18
|
-
this.listeners.set(executionId, set);
|
|
19
|
-
}
|
|
20
|
-
set.add(cb);
|
|
21
|
-
return () => {
|
|
22
|
-
set.delete(cb);
|
|
23
|
-
if (set.size === 0) {
|
|
24
|
-
this.listeners.delete(executionId);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Emit an event to all listeners for the given execution.
|
|
30
|
-
*/
|
|
31
|
-
emit(executionId, event) {
|
|
32
|
-
const set = this.listeners.get(executionId);
|
|
33
|
-
if (!set)
|
|
34
|
-
return;
|
|
35
|
-
for (const cb of set) {
|
|
36
|
-
try {
|
|
37
|
-
cb(event);
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
// Never let a listener error break the executor
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
export function createEventChannel() {
|
|
46
|
-
const queue = [];
|
|
47
|
-
let resolve = null;
|
|
48
|
-
let done = false;
|
|
49
|
-
return {
|
|
50
|
-
push(value) {
|
|
51
|
-
if (done)
|
|
52
|
-
return;
|
|
53
|
-
if (resolve) {
|
|
54
|
-
const r = resolve;
|
|
55
|
-
resolve = null;
|
|
56
|
-
r({ value, done: false });
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
queue.push(value);
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
end() {
|
|
63
|
-
done = true;
|
|
64
|
-
if (resolve) {
|
|
65
|
-
const r = resolve;
|
|
66
|
-
resolve = null;
|
|
67
|
-
r({ value: undefined, done: true });
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
[Symbol.asyncIterator]() {
|
|
71
|
-
return {
|
|
72
|
-
next() {
|
|
73
|
-
if (queue.length > 0) {
|
|
74
|
-
return Promise.resolve({ value: queue.shift(), done: false });
|
|
75
|
-
}
|
|
76
|
-
if (done) {
|
|
77
|
-
return Promise.resolve({ value: undefined, done: true });
|
|
78
|
-
}
|
|
79
|
-
return new Promise((r) => {
|
|
80
|
-
resolve = r;
|
|
81
|
-
});
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
//# sourceMappingURL=execution-event-bus.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"execution-event-bus.js","sourceRoot":"","sources":["../../src/runtime/execution-event-bus.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,MAAM,OAAO,iBAAiB;IACX,SAAS,GAAG,IAAI,GAAG,EAA8B,CAAC;IAEnE;;;OAGG;IACH,SAAS,CAAC,WAAmB,EAAE,EAAiB;QAC9C,IAAI,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC1C,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;YAChB,IAAI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AE,CAAC;gBACZ,MAAM,CAAC,GAAG,OAAO,CAAC;gBAClB,OAAO,GAAG,IAAI,CAAC;gBACf,CAAC,CAAC,EAAE,KAAK,EAAE,SAAc,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;QAED,CAAC,MAAM,CAAC,aAAa,CAAC;YACpB,OAAO;gBACL,IAAI;oBACF,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBACrB,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;oBACjE,CAAC;oBACD,IAAI,IAAI,EAAE,CAAC;wBACT,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,SAAc,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;oBAChE,CAAC;oBACD,OAAO,IAAI,OAAO,CAAoB,CAAC,CAAC,EAAE,EAAE;wBAC1C,OAAO,GAAG,CAAC,CAAC;oBACd,CAAC,CAAC,CAAC;gBACL,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CODE step — sandboxed JavaScript execution.
|
|
3
|
-
*
|
|
4
|
-
* Runs user-provided JS in the host-configured code-execution sandbox — the same
|
|
5
|
-
* isolated E2B / Docker backend the `run_code` agent tool uses — NOT in the
|
|
6
|
-
* workflow process. `node:vm` is not a security boundary (a constructor-chain
|
|
7
|
-
* escape reaches the host runtime and thus OS-level access), so this step
|
|
8
|
-
* requires a real sandbox and FAILS CLOSED when none is configured rather than
|
|
9
|
-
* falling back to in-process evaluation.
|
|
10
|
-
*
|
|
11
|
-
* The code receives:
|
|
12
|
-
* - `$input` — the previous step's output (or {} if first step)
|
|
13
|
-
* - `$context` — read-only snapshot of the workflow context
|
|
14
|
-
*
|
|
15
|
-
* Must return a JSON-serializable value.
|
|
16
|
-
*/
|
|
17
|
-
import { z } from 'zod';
|
|
18
|
-
import { BaseActionStep } from '../base-step.js';
|
|
19
|
-
import type { StepExecutionContext } from '../base-step.js';
|
|
20
|
-
import { BuiltinStepType } from '../../types/known-types.js';
|
|
21
|
-
import type { StepCategory } from '../../types/categories.js';
|
|
22
|
-
export declare const CodeStepConfigSchema: z.ZodObject<{
|
|
23
|
-
code: z.ZodString;
|
|
24
|
-
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
25
|
-
outputFields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
26
|
-
name: z.ZodString;
|
|
27
|
-
type: z.ZodEnum<["string", "number", "boolean", "object", "array"]>;
|
|
28
|
-
}, "strip", z.ZodTypeAny, {
|
|
29
|
-
type: "string" | "number" | "boolean" | "object" | "array";
|
|
30
|
-
name: string;
|
|
31
|
-
}, {
|
|
32
|
-
type: "string" | "number" | "boolean" | "object" | "array";
|
|
33
|
-
name: string;
|
|
34
|
-
}>, "many">>;
|
|
35
|
-
}, "strip", z.ZodTypeAny, {
|
|
36
|
-
code: string;
|
|
37
|
-
timeoutMs: number;
|
|
38
|
-
outputFields?: {
|
|
39
|
-
type: "string" | "number" | "boolean" | "object" | "array";
|
|
40
|
-
name: string;
|
|
41
|
-
}[] | undefined;
|
|
42
|
-
}, {
|
|
43
|
-
code: string;
|
|
44
|
-
timeoutMs?: number | undefined;
|
|
45
|
-
outputFields?: {
|
|
46
|
-
type: "string" | "number" | "boolean" | "object" | "array";
|
|
47
|
-
name: string;
|
|
48
|
-
}[] | undefined;
|
|
49
|
-
}>;
|
|
50
|
-
export type CodeStepConfig = z.infer<typeof CodeStepConfigSchema>;
|
|
51
|
-
export interface CodeStepOutput extends Record<string, unknown> {
|
|
52
|
-
result: unknown;
|
|
53
|
-
}
|
|
54
|
-
export declare class CodeStep extends BaseActionStep<typeof CodeStepConfigSchema, CodeStepOutput> {
|
|
55
|
-
readonly type = BuiltinStepType.CODE;
|
|
56
|
-
readonly name = "Code";
|
|
57
|
-
readonly description = "Execute sandboxed JavaScript code";
|
|
58
|
-
readonly configSchema: z.ZodObject<{
|
|
59
|
-
code: z.ZodString;
|
|
60
|
-
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
61
|
-
outputFields: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
62
|
-
name: z.ZodString;
|
|
63
|
-
type: z.ZodEnum<["string", "number", "boolean", "object", "array"]>;
|
|
64
|
-
}, "strip", z.ZodTypeAny, {
|
|
65
|
-
type: "string" | "number" | "boolean" | "object" | "array";
|
|
66
|
-
name: string;
|
|
67
|
-
}, {
|
|
68
|
-
type: "string" | "number" | "boolean" | "object" | "array";
|
|
69
|
-
name: string;
|
|
70
|
-
}>, "many">>;
|
|
71
|
-
}, "strip", z.ZodTypeAny, {
|
|
72
|
-
code: string;
|
|
73
|
-
timeoutMs: number;
|
|
74
|
-
outputFields?: {
|
|
75
|
-
type: "string" | "number" | "boolean" | "object" | "array";
|
|
76
|
-
name: string;
|
|
77
|
-
}[] | undefined;
|
|
78
|
-
}, {
|
|
79
|
-
code: string;
|
|
80
|
-
timeoutMs?: number | undefined;
|
|
81
|
-
outputFields?: {
|
|
82
|
-
type: "string" | "number" | "boolean" | "object" | "array";
|
|
83
|
-
name: string;
|
|
84
|
-
}[] | undefined;
|
|
85
|
-
}>;
|
|
86
|
-
readonly outputSchema: z.ZodObject<{
|
|
87
|
-
result: z.ZodUnknown;
|
|
88
|
-
}, "strip", z.ZodTypeAny, {
|
|
89
|
-
result?: unknown;
|
|
90
|
-
}, {
|
|
91
|
-
result?: unknown;
|
|
92
|
-
}>;
|
|
93
|
-
readonly category: StepCategory;
|
|
94
|
-
readonly icon = "code";
|
|
95
|
-
decorateConfigSchema(jsonSchema: Record<string, unknown>): Record<string, unknown>;
|
|
96
|
-
resolveOutputJsonSchema(config: Record<string, unknown>): Record<string, unknown>;
|
|
97
|
-
execute(config: CodeStepConfig, ctx: StepExecutionContext): Promise<CodeStepOutput>;
|
|
98
|
-
}
|
|
99
|
-
//# sourceMappingURL=code.step.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code.step.d.ts","sourceRoot":"","sources":["../../../src/steps/builtin/code.step.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAG5D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAS9D,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAI/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAIlE,MAAM,WAAW,cAAe,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC7D,MAAM,EAAE,OAAO,CAAC;CACjB;AA+CD,qBAAa,QAAS,SAAQ,cAAc,CAC1C,OAAO,oBAAoB,EAC3B,cAAc,CACf;IACC,SAAkB,IAAI,wBAAwB;IAC9C,SAAkB,IAAI,UAAU;IAChC,SAAkB,WAAW,uCAAuC;IACpE,SAAkB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;OAAwB;IACtD,SAAkB,YAAY;;;;;;OAAwB;IACtD,SAAkB,QAAQ,EAAE,YAAY,CAAU;IAClD,SAAkB,IAAI,UAAU;IAEvB,oBAAoB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAWlF,uBAAuB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAiB3E,OAAO,CACpB,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,oBAAoB,GACxB,OAAO,CAAC,cAAc,CAAC;CA4D3B"}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CODE step — sandboxed JavaScript execution.
|
|
3
|
-
*
|
|
4
|
-
* Runs user-provided JS in the host-configured code-execution sandbox — the same
|
|
5
|
-
* isolated E2B / Docker backend the `run_code` agent tool uses — NOT in the
|
|
6
|
-
* workflow process. `node:vm` is not a security boundary (a constructor-chain
|
|
7
|
-
* escape reaches the host runtime and thus OS-level access), so this step
|
|
8
|
-
* requires a real sandbox and FAILS CLOSED when none is configured rather than
|
|
9
|
-
* falling back to in-process evaluation.
|
|
10
|
-
*
|
|
11
|
-
* The code receives:
|
|
12
|
-
* - `$input` — the previous step's output (or {} if first step)
|
|
13
|
-
* - `$context` — read-only snapshot of the workflow context
|
|
14
|
-
*
|
|
15
|
-
* Must return a JSON-serializable value.
|
|
16
|
-
*/
|
|
17
|
-
import { z } from 'zod';
|
|
18
|
-
import { BaseActionStep } from '../base-step.js';
|
|
19
|
-
import { bindSandboxSession } from '../../sandbox/types.js';
|
|
20
|
-
import { BuiltinStepType } from '../../types/known-types.js';
|
|
21
|
-
// ─── Config ───
|
|
22
|
-
const OutputFieldSchema = z.object({
|
|
23
|
-
name: z.string().min(1).describe('Field name in the returned object'),
|
|
24
|
-
type: z.enum(['string', 'number', 'boolean', 'object', 'array']).describe('Data type of this field'),
|
|
25
|
-
});
|
|
26
|
-
export const CodeStepConfigSchema = z.object({
|
|
27
|
-
code: z.string().min(1).describe('JavaScript code to execute. Must return a value. Has access to $input (previous step output) and $context (workflow context)'),
|
|
28
|
-
timeoutMs: z.number().int().positive().default(5000).describe('Maximum execution time in milliseconds'),
|
|
29
|
-
outputFields: z.array(OutputFieldSchema).optional().describe('Declared output fields — describes the shape of the return value for downstream steps'),
|
|
30
|
-
});
|
|
31
|
-
const CodeStepOutputSchema = z.object({
|
|
32
|
-
result: z.unknown(),
|
|
33
|
-
});
|
|
34
|
-
// Sentinel delimiting the JSON return value on stdout. The program appends it
|
|
35
|
-
// last, after any user console output, so `lastIndexOf` recovers the result
|
|
36
|
-
// even if the user logged text that resembles the marker.
|
|
37
|
-
const RESULT_MARKER = '__XYNE_CODE_RESULT__';
|
|
38
|
-
// Wrap the user code into a self-contained Node (CommonJS) program that injects
|
|
39
|
-
// $input/$context, runs the code, and prints the JSON result after the marker.
|
|
40
|
-
// $input/$context are embedded via JSON.parse of a JSON-encoded string so no
|
|
41
|
-
// input value can break out into code. User code is written to a file (never a
|
|
42
|
-
// shell argument), so it needs no escaping.
|
|
43
|
-
function buildProgram(code, $input, $context, timeoutMs) {
|
|
44
|
-
const inputLit = JSON.stringify(JSON.stringify($input));
|
|
45
|
-
const contextLit = JSON.stringify(JSON.stringify($context));
|
|
46
|
-
return [
|
|
47
|
-
`const $input = JSON.parse(${inputLit});`,
|
|
48
|
-
`const $context = JSON.parse(${contextLit});`,
|
|
49
|
-
`const __timer = setTimeout(() => { process.stderr.write("Code step timed out after ${timeoutMs}ms"); process.exit(1); }, ${timeoutMs});`,
|
|
50
|
-
`if (__timer.unref) __timer.unref();`,
|
|
51
|
-
`Promise.resolve().then(async () => {`,
|
|
52
|
-
code,
|
|
53
|
-
`}).then((r) => {`,
|
|
54
|
-
` clearTimeout(__timer);`,
|
|
55
|
-
` let out;`,
|
|
56
|
-
` try { out = JSON.stringify(r === undefined ? null : r); }`,
|
|
57
|
-
` catch (_e) { process.stderr.write("Return value is not JSON-serializable"); process.exit(1); return; }`,
|
|
58
|
-
` process.stdout.write("\\n${RESULT_MARKER}" + out);`,
|
|
59
|
-
`}, (e) => {`,
|
|
60
|
-
` clearTimeout(__timer);`,
|
|
61
|
-
` process.stderr.write(String(e && e.stack ? e.stack : e));`,
|
|
62
|
-
` process.exit(1);`,
|
|
63
|
-
`});`,
|
|
64
|
-
].join('\n');
|
|
65
|
-
}
|
|
66
|
-
// ─── Step ───
|
|
67
|
-
export class CodeStep extends BaseActionStep {
|
|
68
|
-
type = BuiltinStepType.CODE;
|
|
69
|
-
name = 'Code';
|
|
70
|
-
description = 'Execute sandboxed JavaScript code';
|
|
71
|
-
configSchema = CodeStepConfigSchema;
|
|
72
|
-
outputSchema = CodeStepOutputSchema;
|
|
73
|
-
category = 'data';
|
|
74
|
-
icon = 'code';
|
|
75
|
-
decorateConfigSchema(jsonSchema) {
|
|
76
|
-
const props = jsonSchema['properties'];
|
|
77
|
-
if (props?.['code']) {
|
|
78
|
-
props['code'] = { ...props['code'], format: 'code' };
|
|
79
|
-
}
|
|
80
|
-
if (props?.['outputFields']) {
|
|
81
|
-
props['outputFields'] = { ...props['outputFields'], format: 'output-fields' };
|
|
82
|
-
}
|
|
83
|
-
return jsonSchema;
|
|
84
|
-
}
|
|
85
|
-
resolveOutputJsonSchema(config) {
|
|
86
|
-
const fields = config['outputFields'];
|
|
87
|
-
if (!fields || fields.length === 0) {
|
|
88
|
-
return { type: 'object', properties: { result: {} } };
|
|
89
|
-
}
|
|
90
|
-
const resultProps = {};
|
|
91
|
-
for (const f of fields) {
|
|
92
|
-
resultProps[f.name] = { type: f.type };
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
type: 'object',
|
|
96
|
-
properties: {
|
|
97
|
-
result: { type: 'object', properties: resultProps },
|
|
98
|
-
},
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
async execute(config, ctx) {
|
|
102
|
-
// Build $input from the most recent step output
|
|
103
|
-
const stepEntries = Object.values(ctx.workflow.steps);
|
|
104
|
-
const lastStep = stepEntries[stepEntries.length - 1];
|
|
105
|
-
const $input = lastStep?.output ?? {};
|
|
106
|
-
// Build read-only context snapshot
|
|
107
|
-
const $context = {
|
|
108
|
-
trigger: ctx.workflow.trigger,
|
|
109
|
-
steps: Object.fromEntries(Object.entries(ctx.workflow.steps).map(([k, v]) => [k, { ...v }])),
|
|
110
|
-
};
|
|
111
|
-
// Fail closed: JS runs only inside the isolated sandbox, never in-process.
|
|
112
|
-
if (!ctx.sandbox) {
|
|
113
|
-
throw new Error('Code step execution failed: no code-execution sandbox is configured. '
|
|
114
|
-
+ 'The CODE step runs JavaScript in an isolated sandbox and does not fall '
|
|
115
|
-
+ 'back to in-process execution. Configure a sandbox backend (e.g. '
|
|
116
|
-
+ 'SANDBOX_BACKEND / E2B_API_KEY) to enable CODE steps.');
|
|
117
|
-
}
|
|
118
|
-
const program = buildProgram(config.code, $input, $context, config.timeoutMs);
|
|
119
|
-
const scriptPath = `/tmp/xyne-code-${ctx.runtime.executionId}-${ctx.runtime.stepId}.cjs`;
|
|
120
|
-
const scope = ctx.runtime.attributes;
|
|
121
|
-
const handle = await ctx.sandbox.create(scope ? { scope } : {});
|
|
122
|
-
try {
|
|
123
|
-
const session = bindSandboxSession(ctx.sandbox, handle);
|
|
124
|
-
await session.writeFiles([
|
|
125
|
-
{ path: scriptPath, bytes: new TextEncoder().encode(program) },
|
|
126
|
-
]);
|
|
127
|
-
const res = await session.bash(`node ${scriptPath}`, {
|
|
128
|
-
timeoutMs: config.timeoutMs,
|
|
129
|
-
});
|
|
130
|
-
const markerAt = res.stdout.lastIndexOf(RESULT_MARKER);
|
|
131
|
-
if (markerAt === -1) {
|
|
132
|
-
const detail = res.stderr.trim() ||
|
|
133
|
-
res.stdout.trim() ||
|
|
134
|
-
`exited with code ${res.exitCode ?? 'unknown'}`;
|
|
135
|
-
throw new Error(`Code step execution failed: ${detail}`);
|
|
136
|
-
}
|
|
137
|
-
// Surface anything the user logged before the result to the step log.
|
|
138
|
-
const logged = res.stdout.slice(0, markerAt).trim();
|
|
139
|
-
if (logged)
|
|
140
|
-
ctx.log.info(logged);
|
|
141
|
-
const payload = res.stdout.slice(markerAt + RESULT_MARKER.length).trim();
|
|
142
|
-
const result = JSON.parse(payload);
|
|
143
|
-
return { result };
|
|
144
|
-
}
|
|
145
|
-
finally {
|
|
146
|
-
await ctx.sandbox.destroy(handle).catch(() => {
|
|
147
|
-
/* best-effort teardown */
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
//# sourceMappingURL=code.step.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code.step.js","sourceRoot":"","sources":["../../../src/steps/builtin/code.step.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG7D,iBAAiB;AAEjB,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,mCAAmC,CAAC;IACrE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,yBAAyB,CAAC;CACrG,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,8HAA8H,CAAC;IAChK,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,wCAAwC,CAAC;IACvG,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,QAAQ,EAA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ACH,CAAC;CACF"}
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CONDITIONAL step — branch on a recursive {@link Condition} AST.
|
|
3
|
-
*
|
|
4
|
-
* BaseControlFlowStep with two branches: `if_true` and `if_false`.
|
|
5
|
-
*
|
|
6
|
-
* evaluator.evaluate(config.condition, ctx.workflow)
|
|
7
|
-
* true → walk `if_true` → output.branch = 'if_true'
|
|
8
|
-
* false → walk `if_false` → output.branch = 'if_false'
|
|
9
|
-
* (no-op when `if_false` is omitted → output.branch = 'none')
|
|
10
|
-
*
|
|
11
|
-
* The condition evaluator + variable resolver already understand `{{...}}`
|
|
12
|
-
* refs and the operator catalog, so a leaf condition like
|
|
13
|
-
*
|
|
14
|
-
* { variable: 'steps.fetch.output.status', operator: '==', value: 200 }
|
|
15
|
-
*
|
|
16
|
-
* works without any per-step parsing here.
|
|
17
|
-
*
|
|
18
|
-
* Pause/resume inside either branch is handled by the executor's
|
|
19
|
-
* `walkBranchSteps` — same mechanism the PARALLEL and LOOP steps rely on.
|
|
20
|
-
*/
|
|
21
|
-
import { z } from 'zod';
|
|
22
|
-
import { BaseControlFlowStep } from '../base-step.js';
|
|
23
|
-
import type { ControlFlowExecutionContext, BranchStepOutputs } from '../base-step.js';
|
|
24
|
-
import { BuiltinStepType } from '../../types/known-types.js';
|
|
25
|
-
import type { WorkflowStepConfig } from '../../types/workflow-config.js';
|
|
26
|
-
export declare const ConditionalStepConfigSchema: z.ZodObject<{
|
|
27
|
-
condition: z.ZodType<import("../../types/workflow-config.js").Condition, z.ZodTypeDef, import("../../types/workflow-config.js").Condition>;
|
|
28
|
-
if_true: z.ZodArray<z.ZodObject<{
|
|
29
|
-
id: z.ZodString;
|
|
30
|
-
type: z.ZodString;
|
|
31
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
32
|
-
id: z.ZodString;
|
|
33
|
-
type: z.ZodString;
|
|
34
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
35
|
-
id: z.ZodString;
|
|
36
|
-
type: z.ZodString;
|
|
37
|
-
}, z.ZodTypeAny, "passthrough">>, "many">;
|
|
38
|
-
if_false: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
39
|
-
id: z.ZodString;
|
|
40
|
-
type: z.ZodString;
|
|
41
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
42
|
-
id: z.ZodString;
|
|
43
|
-
type: z.ZodString;
|
|
44
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
45
|
-
id: z.ZodString;
|
|
46
|
-
type: z.ZodString;
|
|
47
|
-
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
48
|
-
}, "strip", z.ZodTypeAny, {
|
|
49
|
-
condition: import("../../types/workflow-config.js").Condition;
|
|
50
|
-
if_true: z.objectOutputType<{
|
|
51
|
-
id: z.ZodString;
|
|
52
|
-
type: z.ZodString;
|
|
53
|
-
}, z.ZodTypeAny, "passthrough">[];
|
|
54
|
-
if_false?: z.objectOutputType<{
|
|
55
|
-
id: z.ZodString;
|
|
56
|
-
type: z.ZodString;
|
|
57
|
-
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
58
|
-
}, {
|
|
59
|
-
condition: import("../../types/workflow-config.js").Condition;
|
|
60
|
-
if_true: z.objectInputType<{
|
|
61
|
-
id: z.ZodString;
|
|
62
|
-
type: z.ZodString;
|
|
63
|
-
}, z.ZodTypeAny, "passthrough">[];
|
|
64
|
-
if_false?: z.objectInputType<{
|
|
65
|
-
id: z.ZodString;
|
|
66
|
-
type: z.ZodString;
|
|
67
|
-
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
68
|
-
}>;
|
|
69
|
-
export type ConditionalStepConfig = z.infer<typeof ConditionalStepConfigSchema>;
|
|
70
|
-
export interface ConditionalStepOutput extends Record<string, unknown> {
|
|
71
|
-
/** Which branch executed. `'none'` when condition was false and `if_false` was omitted. */
|
|
72
|
-
branch: 'if_true' | 'if_false' | 'none';
|
|
73
|
-
/** The boolean result of evaluating the condition. */
|
|
74
|
-
evaluated: boolean;
|
|
75
|
-
/**
|
|
76
|
-
* The taken branch's top-level steps, keyed by branch key (`if_true`/`if_false`)
|
|
77
|
-
* then step id — referenced as `…output.branches.<key>.steps.<id>.output.<field>`.
|
|
78
|
-
* Only the taken branch is populated (`{}` when `branch === 'none'`). The harness
|
|
79
|
-
* types both branches from `getBranches`.
|
|
80
|
-
*/
|
|
81
|
-
branches: Record<string, {
|
|
82
|
-
steps: BranchStepOutputs;
|
|
83
|
-
}>;
|
|
84
|
-
}
|
|
85
|
-
export declare class ConditionalStep extends BaseControlFlowStep<typeof ConditionalStepConfigSchema, ConditionalStepOutput> {
|
|
86
|
-
readonly type = BuiltinStepType.CONDITIONAL;
|
|
87
|
-
readonly name = "Conditional";
|
|
88
|
-
readonly description = "Branch execution based on a condition";
|
|
89
|
-
readonly configSchema: z.ZodObject<{
|
|
90
|
-
condition: z.ZodType<import("../../types/workflow-config.js").Condition, z.ZodTypeDef, import("../../types/workflow-config.js").Condition>;
|
|
91
|
-
if_true: z.ZodArray<z.ZodObject<{
|
|
92
|
-
id: z.ZodString;
|
|
93
|
-
type: z.ZodString;
|
|
94
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
95
|
-
id: z.ZodString;
|
|
96
|
-
type: z.ZodString;
|
|
97
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
98
|
-
id: z.ZodString;
|
|
99
|
-
type: z.ZodString;
|
|
100
|
-
}, z.ZodTypeAny, "passthrough">>, "many">;
|
|
101
|
-
if_false: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
102
|
-
id: z.ZodString;
|
|
103
|
-
type: z.ZodString;
|
|
104
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
105
|
-
id: z.ZodString;
|
|
106
|
-
type: z.ZodString;
|
|
107
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
108
|
-
id: z.ZodString;
|
|
109
|
-
type: z.ZodString;
|
|
110
|
-
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
111
|
-
}, "strip", z.ZodTypeAny, {
|
|
112
|
-
condition: import("../../types/workflow-config.js").Condition;
|
|
113
|
-
if_true: z.objectOutputType<{
|
|
114
|
-
id: z.ZodString;
|
|
115
|
-
type: z.ZodString;
|
|
116
|
-
}, z.ZodTypeAny, "passthrough">[];
|
|
117
|
-
if_false?: z.objectOutputType<{
|
|
118
|
-
id: z.ZodString;
|
|
119
|
-
type: z.ZodString;
|
|
120
|
-
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
121
|
-
}, {
|
|
122
|
-
condition: import("../../types/workflow-config.js").Condition;
|
|
123
|
-
if_true: z.objectInputType<{
|
|
124
|
-
id: z.ZodString;
|
|
125
|
-
type: z.ZodString;
|
|
126
|
-
}, z.ZodTypeAny, "passthrough">[];
|
|
127
|
-
if_false?: z.objectInputType<{
|
|
128
|
-
id: z.ZodString;
|
|
129
|
-
type: z.ZodString;
|
|
130
|
-
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
131
|
-
}>;
|
|
132
|
-
readonly outputSchema: z.ZodObject<{
|
|
133
|
-
branch: z.ZodEnum<["if_true", "if_false", "none"]>;
|
|
134
|
-
evaluated: z.ZodBoolean;
|
|
135
|
-
branches: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
136
|
-
steps: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
137
|
-
output: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
138
|
-
}, "strip", z.ZodTypeAny, {
|
|
139
|
-
output: Record<string, unknown>;
|
|
140
|
-
}, {
|
|
141
|
-
output: Record<string, unknown>;
|
|
142
|
-
}>>;
|
|
143
|
-
}, "strip", z.ZodTypeAny, {
|
|
144
|
-
steps: Record<string, {
|
|
145
|
-
output: Record<string, unknown>;
|
|
146
|
-
}>;
|
|
147
|
-
}, {
|
|
148
|
-
steps: Record<string, {
|
|
149
|
-
output: Record<string, unknown>;
|
|
150
|
-
}>;
|
|
151
|
-
}>>;
|
|
152
|
-
}, "strip", z.ZodTypeAny, {
|
|
153
|
-
branch: "none" | "if_true" | "if_false";
|
|
154
|
-
evaluated: boolean;
|
|
155
|
-
branches: Record<string, {
|
|
156
|
-
steps: Record<string, {
|
|
157
|
-
output: Record<string, unknown>;
|
|
158
|
-
}>;
|
|
159
|
-
}>;
|
|
160
|
-
}, {
|
|
161
|
-
branch: "none" | "if_true" | "if_false";
|
|
162
|
-
evaluated: boolean;
|
|
163
|
-
branches: Record<string, {
|
|
164
|
-
steps: Record<string, {
|
|
165
|
-
output: Record<string, unknown>;
|
|
166
|
-
}>;
|
|
167
|
-
}>;
|
|
168
|
-
}>;
|
|
169
|
-
readonly category: "control";
|
|
170
|
-
readonly icon = "fork";
|
|
171
|
-
readonly declaredOutputs: readonly [{
|
|
172
|
-
readonly key: "if_true";
|
|
173
|
-
readonly label: "When true";
|
|
174
|
-
}, {
|
|
175
|
-
readonly key: "if_false";
|
|
176
|
-
readonly label: "When false";
|
|
177
|
-
}];
|
|
178
|
-
/** Allows config-validator to recursively validate nested branches. */
|
|
179
|
-
getBranches(config: Record<string, unknown>): Record<string, WorkflowStepConfig[]>;
|
|
180
|
-
execute(config: ConditionalStepConfig, ctx: ControlFlowExecutionContext): Promise<ConditionalStepOutput>;
|
|
181
|
-
}
|
|
182
|
-
//# sourceMappingURL=conditional.step.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conditional.step.d.ts","sourceRoot":"","sources":["../../../src/steps/builtin/conditional.step.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAsB,MAAM,iBAAiB,CAAC;AAC1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,C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"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CONDITIONAL step — branch on a recursive {@link Condition} AST.
|
|
3
|
-
*
|
|
4
|
-
* BaseControlFlowStep with two branches: `if_true` and `if_false`.
|
|
5
|
-
*
|
|
6
|
-
* evaluator.evaluate(config.condition, ctx.workflow)
|
|
7
|
-
* true → walk `if_true` → output.branch = 'if_true'
|
|
8
|
-
* false → walk `if_false` → output.branch = 'if_false'
|
|
9
|
-
* (no-op when `if_false` is omitted → output.branch = 'none')
|
|
10
|
-
*
|
|
11
|
-
* The condition evaluator + variable resolver already understand `{{...}}`
|
|
12
|
-
* refs and the operator catalog, so a leaf condition like
|
|
13
|
-
*
|
|
14
|
-
* { variable: 'steps.fetch.output.status', operator: '==', value: 200 }
|
|
15
|
-
*
|
|
16
|
-
* works without any per-step parsing here.
|
|
17
|
-
*
|
|
18
|
-
* Pause/resume inside either branch is handled by the executor's
|
|
19
|
-
* `walkBranchSteps` — same mechanism the PARALLEL and LOOP steps rely on.
|
|
20
|
-
*/
|
|
21
|
-
import { z } from 'zod';
|
|
22
|
-
import { BaseControlFlowStep, collectBranchSteps } from '../base-step.js';
|
|
23
|
-
import { BuiltinStepType } from '../../types/known-types.js';
|
|
24
|
-
import { ConditionSchema } from '../../types/workflow-config.js';
|
|
25
|
-
import { ConditionEvaluator } from '../../engine/condition-evaluator.js';
|
|
26
|
-
// ─── Config ───
|
|
27
|
-
export const ConditionalStepConfigSchema = z.object({
|
|
28
|
-
condition: ConditionSchema
|
|
29
|
-
.describe('Recursive condition tree. Leaf nodes reference {{variables}} and apply operators; `all`/`any` compose children.'),
|
|
30
|
-
if_true: z.array(z.object({ id: z.string(), type: z.string() }).passthrough()).describe('Steps to execute when the condition resolves true'),
|
|
31
|
-
if_false: z.array(z.object({ id: z.string(), type: z.string() }).passthrough()).optional().describe('Steps to execute when the condition resolves false. Omit to no-op on the false branch.'),
|
|
32
|
-
});
|
|
33
|
-
const ConditionalStepOutputSchema = z.object({
|
|
34
|
-
branch: z.enum(['if_true', 'if_false', 'none']),
|
|
35
|
-
evaluated: z.boolean(),
|
|
36
|
-
branches: z.record(z.object({ steps: z.record(z.object({ output: z.record(z.unknown()) })) })),
|
|
37
|
-
});
|
|
38
|
-
// ─── Step ───
|
|
39
|
-
export class ConditionalStep extends BaseControlFlowStep {
|
|
40
|
-
type = BuiltinStepType.CONDITIONAL;
|
|
41
|
-
name = 'Conditional';
|
|
42
|
-
description = 'Branch execution based on a condition';
|
|
43
|
-
configSchema = ConditionalStepConfigSchema;
|
|
44
|
-
outputSchema = ConditionalStepOutputSchema;
|
|
45
|
-
category = 'control';
|
|
46
|
-
icon = 'fork';
|
|
47
|
-
declaredOutputs = [
|
|
48
|
-
{ key: 'if_true', label: 'When true' },
|
|
49
|
-
{ key: 'if_false', label: 'When false' },
|
|
50
|
-
];
|
|
51
|
-
/** Allows config-validator to recursively validate nested branches. */
|
|
52
|
-
getBranches(config) {
|
|
53
|
-
return {
|
|
54
|
-
if_true: (config['if_true'] ?? []),
|
|
55
|
-
if_false: (config['if_false'] ?? []),
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
async execute(config, ctx) {
|
|
59
|
-
const evaluator = new ConditionEvaluator();
|
|
60
|
-
const evaluated = evaluator.evaluate(config.condition, ctx.workflow);
|
|
61
|
-
if (evaluated) {
|
|
62
|
-
const branchSteps = config.if_true;
|
|
63
|
-
await ctx.walkBranch(branchSteps, ctx.workflow, 'if_true');
|
|
64
|
-
return {
|
|
65
|
-
branch: 'if_true',
|
|
66
|
-
evaluated: true,
|
|
67
|
-
branches: { if_true: { steps: collectBranchSteps(branchSteps, ctx.workflow) } },
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
if (config.if_false && config.if_false.length > 0) {
|
|
71
|
-
const branchSteps = config.if_false;
|
|
72
|
-
await ctx.walkBranch(branchSteps, ctx.workflow, 'if_false');
|
|
73
|
-
return {
|
|
74
|
-
branch: 'if_false',
|
|
75
|
-
evaluated: false,
|
|
76
|
-
branches: { if_false: { steps: collectBranchSteps(branchSteps, ctx.workflow) } },
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
return { branch: 'none', evaluated: false, branches: {} };
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
//# sourceMappingURL=conditional.step.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conditional.step.js","sourceRoot":"","sources":["../../../src/steps/builtin/conditional.step.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAEzE,iBAAiB;AAEjB,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,SAAS,EAAE,eAAe;SACvB,QAAQ,CAAC,iHAAiH,CAAC;IAC9H,OAAO,EAAE,CAAC,CAAC,KAAK,CACd,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAC7D,CAAC,QAAQ,CAAC,mDAAmD,CAAC;IAC/D,QAAQ,EAAE,CAAC,CAAC,KAAK,CACf,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAC7D,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wFAAwF,CAAC;CAChH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