@xyne/workflow-sdk 3.2.36 → 3.2.38
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/agents/agent-step.d.ts +2 -2
- package/dist/agents/host-agent-step.d.ts +1 -1
- package/dist/builder/index.d.ts +2 -2
- package/dist/builder/index.d.ts.map +1 -1
- package/dist/builder/index.js +1 -1
- package/dist/builder/index.js.map +1 -1
- package/dist/client/events-client.d.ts +57 -0
- package/dist/client/events-client.d.ts.map +1 -0
- package/dist/client/events-client.js +107 -0
- package/dist/client/events-client.js.map +1 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/sse.d.ts +30 -0
- package/dist/client/sse.d.ts.map +1 -0
- package/dist/client/sse.js +76 -0
- package/dist/client/sse.js.map +1 -0
- package/dist/client/types.d.ts +31 -6
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/url.d.ts +11 -0
- package/dist/client/url.d.ts.map +1 -0
- package/dist/client/url.js +28 -0
- package/dist/client/url.js.map +1 -0
- package/dist/client/workflow-client.d.ts +1 -1
- package/dist/client/workflow-client.d.ts.map +1 -1
- package/dist/client/workflow-client.js +32 -20
- package/dist/client/workflow-client.js.map +1 -1
- package/dist/common/citation-ref.d.ts +4 -4
- package/dist/common/credentials.d.ts +107 -0
- package/dist/common/credentials.d.ts.map +1 -1
- package/dist/common/credentials.js +67 -0
- package/dist/common/credentials.js.map +1 -1
- package/dist/common/index.d.ts +2 -2
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +2 -2
- package/dist/common/index.js.map +1 -1
- package/dist/connectors/builtin/builtin-connector.d.ts +32 -0
- package/dist/connectors/builtin/builtin-connector.d.ts.map +1 -0
- package/dist/connectors/builtin/builtin-connector.js +62 -0
- package/dist/connectors/builtin/builtin-connector.js.map +1 -0
- package/dist/connectors/builtin/credentials.d.ts +18 -0
- package/dist/connectors/builtin/credentials.d.ts.map +1 -0
- package/dist/connectors/builtin/credentials.js +50 -0
- package/dist/connectors/builtin/credentials.js.map +1 -0
- package/dist/connectors/builtin/steps/code.step.d.ts +99 -0
- package/dist/connectors/builtin/steps/code.step.d.ts.map +1 -0
- package/dist/connectors/builtin/steps/code.step.js +152 -0
- package/dist/connectors/builtin/steps/code.step.js.map +1 -0
- package/dist/connectors/builtin/steps/conditional.step.d.ts +182 -0
- package/dist/connectors/builtin/steps/conditional.step.d.ts.map +1 -0
- package/dist/connectors/builtin/steps/conditional.step.js +82 -0
- package/dist/connectors/builtin/steps/conditional.step.js.map +1 -0
- package/dist/connectors/builtin/steps/dedup.step.d.ts +65 -0
- package/dist/connectors/builtin/steps/dedup.step.d.ts.map +1 -0
- package/dist/connectors/builtin/steps/dedup.step.js +61 -0
- package/dist/connectors/builtin/steps/dedup.step.js.map +1 -0
- package/dist/connectors/builtin/steps/http-request.step.d.ts +1027 -0
- package/dist/connectors/builtin/steps/http-request.step.d.ts.map +1 -0
- package/dist/connectors/builtin/steps/http-request.step.js +497 -0
- package/dist/connectors/builtin/steps/http-request.step.js.map +1 -0
- package/dist/connectors/builtin/steps/loop.step.d.ts +100 -0
- package/dist/connectors/builtin/steps/loop.step.d.ts.map +1 -0
- package/dist/connectors/builtin/steps/loop.step.js +73 -0
- package/dist/connectors/builtin/steps/loop.step.js.map +1 -0
- package/dist/connectors/builtin/steps/map.step.d.ts +148 -0
- package/dist/connectors/builtin/steps/map.step.d.ts.map +1 -0
- package/dist/connectors/builtin/steps/map.step.js +111 -0
- package/dist/connectors/builtin/steps/map.step.js.map +1 -0
- package/dist/connectors/builtin/steps/parallel.step.d.ts +246 -0
- package/dist/connectors/builtin/steps/parallel.step.d.ts.map +1 -0
- package/dist/connectors/builtin/steps/parallel.step.js +175 -0
- package/dist/connectors/builtin/steps/parallel.step.js.map +1 -0
- package/dist/connectors/builtin/steps/ssrf-guard.d.ts +9 -0
- package/dist/connectors/builtin/steps/ssrf-guard.d.ts.map +1 -0
- package/dist/connectors/builtin/steps/ssrf-guard.js +115 -0
- package/dist/connectors/builtin/steps/ssrf-guard.js.map +1 -0
- package/dist/connectors/builtin/steps/switch.step.d.ts +235 -0
- package/dist/connectors/builtin/steps/switch.step.d.ts.map +1 -0
- package/dist/connectors/builtin/steps/switch.step.js +101 -0
- package/dist/connectors/builtin/steps/switch.step.js.map +1 -0
- package/dist/connectors/builtin/steps/wait.step.d.ts +1072 -0
- package/dist/connectors/builtin/steps/wait.step.d.ts.map +1 -0
- package/dist/connectors/builtin/steps/wait.step.js +254 -0
- package/dist/connectors/builtin/steps/wait.step.js.map +1 -0
- package/dist/connectors/builtin/triggers/default-cron-trigger.d.ts +44 -0
- package/dist/connectors/builtin/triggers/default-cron-trigger.d.ts.map +1 -0
- package/dist/connectors/builtin/triggers/default-cron-trigger.js +31 -0
- package/dist/connectors/builtin/triggers/default-cron-trigger.js.map +1 -0
- package/dist/connectors/builtin/triggers/default-event-trigger.d.ts +32 -0
- package/dist/connectors/builtin/triggers/default-event-trigger.d.ts.map +1 -0
- package/dist/connectors/builtin/triggers/default-event-trigger.js +21 -0
- package/dist/connectors/builtin/triggers/default-event-trigger.js.map +1 -0
- package/dist/connectors/builtin/triggers/default-manual-trigger.d.ts +45 -0
- package/dist/connectors/builtin/triggers/default-manual-trigger.d.ts.map +1 -0
- package/dist/connectors/builtin/triggers/default-manual-trigger.js +51 -0
- package/dist/connectors/builtin/triggers/default-manual-trigger.js.map +1 -0
- package/dist/connectors/builtin/triggers/default-webhook-v2-trigger.d.ts +31 -0
- package/dist/connectors/builtin/triggers/default-webhook-v2-trigger.d.ts.map +1 -0
- package/dist/connectors/builtin/triggers/default-webhook-v2-trigger.js +40 -0
- package/dist/connectors/builtin/triggers/default-webhook-v2-trigger.js.map +1 -0
- package/dist/connectors/core/base-connector.d.ts +45 -0
- package/dist/connectors/core/base-connector.d.ts.map +1 -0
- package/dist/connectors/core/base-connector.js +3 -0
- package/dist/connectors/core/base-connector.js.map +1 -0
- package/dist/connectors/core/connector-registry.d.ts +130 -0
- package/dist/connectors/core/connector-registry.d.ts.map +1 -0
- package/dist/connectors/core/connector-registry.js +357 -0
- package/dist/connectors/core/connector-registry.js.map +1 -0
- package/dist/connectors/core/credentials.d.ts +104 -0
- package/dist/connectors/core/credentials.d.ts.map +1 -0
- package/dist/connectors/core/credentials.js +67 -0
- package/dist/connectors/core/credentials.js.map +1 -0
- package/dist/connectors/core/index.d.ts +7 -0
- package/dist/connectors/core/index.d.ts.map +1 -0
- package/dist/connectors/core/index.js +5 -0
- package/dist/connectors/core/index.js.map +1 -0
- package/dist/engine/available-context.d.ts +3 -4
- package/dist/engine/available-context.d.ts.map +1 -1
- package/dist/engine/available-context.js +17 -13
- package/dist/engine/available-context.js.map +1 -1
- package/dist/engine/config-validator.d.ts +13 -5
- package/dist/engine/config-validator.d.ts.map +1 -1
- package/dist/engine/config-validator.js +89 -11
- package/dist/engine/config-validator.js.map +1 -1
- package/dist/engine/credential-resolver.d.ts +42 -0
- package/dist/engine/credential-resolver.d.ts.map +1 -0
- package/dist/engine/credential-resolver.js +63 -0
- package/dist/engine/credential-resolver.js.map +1 -0
- package/dist/engine/workflow-executor.d.ts +15 -9
- package/dist/engine/workflow-executor.d.ts.map +1 -1
- package/dist/engine/workflow-executor.js +31 -40
- package/dist/engine/workflow-executor.js.map +1 -1
- package/dist/events/in-memory-adapter.d.ts +15 -0
- package/dist/events/in-memory-adapter.d.ts.map +1 -0
- package/dist/events/in-memory-adapter.js +50 -0
- package/dist/events/in-memory-adapter.js.map +1 -0
- package/dist/events/types.d.ts +154 -0
- package/dist/events/types.d.ts.map +1 -0
- package/dist/events/types.js +34 -0
- package/dist/events/types.js.map +1 -0
- package/dist/index.d.ts +50 -31
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -16
- package/dist/index.js.map +1 -1
- package/dist/ingest/body.d.ts +18 -0
- package/dist/ingest/body.d.ts.map +1 -0
- package/dist/ingest/body.js +47 -0
- package/dist/ingest/body.js.map +1 -0
- package/dist/ingest/filter.d.ts +11 -0
- package/dist/ingest/filter.d.ts.map +1 -0
- package/dist/ingest/filter.js +23 -0
- package/dist/ingest/filter.js.map +1 -0
- package/dist/ingest/headers.d.ts +3 -0
- package/dist/ingest/headers.d.ts.map +1 -0
- package/dist/ingest/headers.js +11 -0
- package/dist/ingest/headers.js.map +1 -0
- package/dist/ingest/types.d.ts +50 -0
- package/dist/ingest/types.d.ts.map +1 -0
- package/dist/ingest/types.js +9 -0
- package/dist/ingest/types.js.map +1 -0
- package/dist/persistence/in-memory-adapter.d.ts +4 -8
- package/dist/persistence/in-memory-adapter.d.ts.map +1 -1
- package/dist/persistence/in-memory-adapter.js +8 -25
- package/dist/persistence/in-memory-adapter.js.map +1 -1
- package/dist/persistence/types.d.ts +5 -19
- package/dist/persistence/types.d.ts.map +1 -1
- package/dist/router/types.d.ts +31 -3
- package/dist/router/types.d.ts.map +1 -1
- package/dist/router/workflow-router.d.ts +4 -3
- package/dist/router/workflow-router.d.ts.map +1 -1
- package/dist/router/workflow-router.js +258 -63
- package/dist/router/workflow-router.js.map +1 -1
- package/dist/runtime/types.d.ts +36 -56
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/runtime/workflow-runtime.d.ts +70 -46
- package/dist/runtime/workflow-runtime.d.ts.map +1 -1
- package/dist/runtime/workflow-runtime.js +217 -141
- package/dist/runtime/workflow-runtime.js.map +1 -1
- package/dist/steps/base-step.d.ts +23 -0
- package/dist/steps/base-step.d.ts.map +1 -1
- package/dist/steps/base-step.js +22 -0
- package/dist/steps/base-step.js.map +1 -1
- package/dist/steps/step-descriptor.d.ts +52 -0
- package/dist/steps/step-descriptor.d.ts.map +1 -0
- package/dist/steps/step-descriptor.js +32 -0
- package/dist/steps/step-descriptor.js.map +1 -0
- package/dist/testing/authz-conformance.d.ts.map +1 -1
- package/dist/testing/authz-conformance.js +6 -7
- package/dist/testing/authz-conformance.js.map +1 -1
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1 -0
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/mock-step-context.d.ts +1 -0
- package/dist/testing/mock-step-context.d.ts.map +1 -1
- package/dist/testing/mock-step-context.js +1 -0
- package/dist/testing/mock-step-context.js.map +1 -1
- package/dist/testing/test-connector.d.ts +40 -0
- package/dist/testing/test-connector.d.ts.map +1 -0
- package/dist/testing/test-connector.js +39 -0
- package/dist/testing/test-connector.js.map +1 -0
- package/dist/triggers/api-trigger.d.ts +15 -0
- package/dist/triggers/api-trigger.d.ts.map +1 -0
- package/dist/triggers/api-trigger.js +14 -0
- package/dist/triggers/api-trigger.js.map +1 -0
- package/dist/triggers/base-trigger.d.ts +29 -0
- package/dist/triggers/base-trigger.d.ts.map +1 -1
- package/dist/triggers/base-trigger.js +16 -0
- package/dist/triggers/base-trigger.js.map +1 -1
- package/dist/triggers/trigger-descriptor.d.ts +42 -0
- package/dist/triggers/trigger-descriptor.d.ts.map +1 -0
- package/dist/triggers/trigger-descriptor.js +29 -0
- package/dist/triggers/trigger-descriptor.js.map +1 -0
- package/dist/triggers/webhook-trigger.d.ts +31 -38
- package/dist/triggers/webhook-trigger.d.ts.map +1 -1
- package/dist/triggers/webhook-trigger.js +19 -6
- package/dist/triggers/webhook-trigger.js.map +1 -1
- package/dist/types/known-types.d.ts +0 -1
- package/dist/types/known-types.d.ts.map +1 -1
- package/dist/types/known-types.js +0 -1
- package/dist/types/known-types.js.map +1 -1
- package/dist/types/validation.d.ts +3 -1
- package/dist/types/validation.d.ts.map +1 -1
- package/dist/types/validation.js +2 -0
- package/dist/types/validation.js.map +1 -1
- package/dist/types/workflow-config.d.ts +23 -0
- package/dist/types/workflow-config.d.ts.map +1 -1
- package/dist/types/workflow-config.js +8 -0
- package/dist/types/workflow-config.js.map +1 -1
- package/dist/util/credential-slot-schema.d.ts +20 -0
- package/dist/util/credential-slot-schema.d.ts.map +1 -0
- package/dist/util/credential-slot-schema.js +30 -0
- package/dist/util/credential-slot-schema.js.map +1 -0
- package/dist/util/event-channel.d.ts +25 -0
- package/dist/util/event-channel.d.ts.map +1 -0
- package/dist/util/event-channel.js +61 -0
- package/dist/util/event-channel.js.map +1 -0
- package/package.json +1 -1
- package/dist/common/expression-eval.d.ts +0 -35
- package/dist/common/expression-eval.d.ts.map +0 -1
- package/dist/common/expression-eval.js +0 -214
- package/dist/common/expression-eval.js.map +0 -1
- package/dist/common/principal.d.ts +0 -45
- package/dist/common/principal.d.ts.map +0 -1
- package/dist/common/principal.js +0 -9
- package/dist/common/principal.js.map +0 -1
- package/dist/steps/builtin/transform.step.d.ts +0 -247
- package/dist/steps/builtin/transform.step.d.ts.map +0 -1
- package/dist/steps/builtin/transform.step.js +0 -135
- package/dist/steps/builtin/transform.step.js.map +0 -1
- package/dist/types/attachment.d.ts +0 -23
- package/dist/types/attachment.d.ts.map +0 -1
- package/dist/types/attachment.js +0 -2
- package/dist/types/attachment.js.map +0 -1
- package/dist/types/resume-payload.d.ts +0 -34
- package/dist/types/resume-payload.d.ts.map +0 -1
- package/dist/types/resume-payload.js +0 -12
- package/dist/types/resume-payload.js.map +0 -1
- package/dist/util/executable-check.d.ts +0 -42
- package/dist/util/executable-check.d.ts.map +0 -1
- package/dist/util/executable-check.js +0 -115
- package/dist/util/executable-check.js.map +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The credential types the built-in connector offers.
|
|
3
|
+
*
|
|
4
|
+
* These are the connector-less shapes an HTTP request can authenticate with — a
|
|
5
|
+
* token, a username/password, a header, or a client-credentials exchange. They
|
|
6
|
+
* belong to `builtin` because that is the connector whose step uses them; a
|
|
7
|
+
* provider connector declares its own instead.
|
|
8
|
+
*
|
|
9
|
+
* Each type is named `BUILTIN_<SHAPE>`. A host backfilling credentials stored
|
|
10
|
+
* before types existed maps each old shape to the type of the same name.
|
|
11
|
+
*/
|
|
12
|
+
export declare const BUILTIN_BEARER: import("../core/credentials.js").CredentialDefinition<"builtin">;
|
|
13
|
+
export declare const BUILTIN_BASIC: import("../core/credentials.js").CredentialDefinition<"builtin">;
|
|
14
|
+
export declare const BUILTIN_CUSTOM_HEADER: import("../core/credentials.js").CredentialDefinition<"builtin">;
|
|
15
|
+
export declare const BUILTIN_OAUTH2_CLIENT_CREDENTIALS: import("../core/credentials.js").CredentialDefinition<"builtin">;
|
|
16
|
+
/** Every shape an HTTP request can authenticate with. */
|
|
17
|
+
export declare const BUILTIN_CREDENTIALS: readonly [import("../core/credentials.js").CredentialDefinition<"builtin">, import("../core/credentials.js").CredentialDefinition<"builtin">, import("../core/credentials.js").CredentialDefinition<"builtin">, import("../core/credentials.js").CredentialDefinition<"builtin">];
|
|
18
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../src/connectors/builtin/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,eAAO,MAAM,cAAc,kEAMzB,CAAC;AAEH,eAAO,MAAM,aAAa,kEAMxB,CAAC;AAEH,eAAO,MAAM,qBAAqB,kEAMhC,CAAC;AAEH,eAAO,MAAM,iCAAiC,kEAM5C,CAAC;AAEH,yDAAyD;AACzD,eAAO,MAAM,mBAAmB,mRAKtB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The credential types the built-in connector offers.
|
|
3
|
+
*
|
|
4
|
+
* These are the connector-less shapes an HTTP request can authenticate with — a
|
|
5
|
+
* token, a username/password, a header, or a client-credentials exchange. They
|
|
6
|
+
* belong to `builtin` because that is the connector whose step uses them; a
|
|
7
|
+
* provider connector declares its own instead.
|
|
8
|
+
*
|
|
9
|
+
* Each type is named `BUILTIN_<SHAPE>`. A host backfilling credentials stored
|
|
10
|
+
* before types existed maps each old shape to the type of the same name.
|
|
11
|
+
*/
|
|
12
|
+
import { defineCredential } from '../core/credentials.js';
|
|
13
|
+
import { CredentialAuthType } from '../../common/credentials.js';
|
|
14
|
+
const BUILTIN = 'builtin';
|
|
15
|
+
export const BUILTIN_BEARER = defineCredential({
|
|
16
|
+
connectorId: BUILTIN,
|
|
17
|
+
credType: 'BUILTIN_BEARER',
|
|
18
|
+
label: 'Bearer Token',
|
|
19
|
+
description: 'A single token sent as an Authorization: Bearer header.',
|
|
20
|
+
authType: CredentialAuthType.Bearer,
|
|
21
|
+
});
|
|
22
|
+
export const BUILTIN_BASIC = defineCredential({
|
|
23
|
+
connectorId: BUILTIN,
|
|
24
|
+
credType: 'BUILTIN_BASIC',
|
|
25
|
+
label: 'Basic Auth',
|
|
26
|
+
description: 'A username and password (HTTP Basic auth).',
|
|
27
|
+
authType: CredentialAuthType.Basic,
|
|
28
|
+
});
|
|
29
|
+
export const BUILTIN_CUSTOM_HEADER = defineCredential({
|
|
30
|
+
connectorId: BUILTIN,
|
|
31
|
+
credType: 'BUILTIN_CUSTOM_HEADER',
|
|
32
|
+
label: 'Custom Header',
|
|
33
|
+
description: 'A custom header name and value.',
|
|
34
|
+
authType: CredentialAuthType.CustomHeader,
|
|
35
|
+
});
|
|
36
|
+
export const BUILTIN_OAUTH2_CLIENT_CREDENTIALS = defineCredential({
|
|
37
|
+
connectorId: BUILTIN,
|
|
38
|
+
credType: 'BUILTIN_OAUTH2_CLIENT_CREDENTIALS',
|
|
39
|
+
label: 'OAuth 2.0 Client Credentials',
|
|
40
|
+
description: 'Client ID and secret exchanged for a token on each request.',
|
|
41
|
+
authType: CredentialAuthType.OAuth2ClientCredentials,
|
|
42
|
+
});
|
|
43
|
+
/** Every shape an HTTP request can authenticate with. */
|
|
44
|
+
export const BUILTIN_CREDENTIALS = [
|
|
45
|
+
BUILTIN_BEARER,
|
|
46
|
+
BUILTIN_BASIC,
|
|
47
|
+
BUILTIN_CUSTOM_HEADER,
|
|
48
|
+
BUILTIN_OAUTH2_CLIENT_CREDENTIALS,
|
|
49
|
+
];
|
|
50
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,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,CAAC"}
|
|
@@ -0,0 +1,99 @@
|
|
|
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 '../../../steps/base-step.js';
|
|
19
|
+
import type { StepExecutionContext } from '../../../steps/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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code.step.d.ts","sourceRoot":"","sources":["../../../../src/connectors/builtin/steps/code.step.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAGxE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AASjE,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"}
|
|
@@ -0,0 +1,152 @@
|
|
|
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 '../../../steps/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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code.step.js","sourceRoot":"","sources":["../../../../src/connectors/builtin/steps/code.step.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,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,IA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CAAC,EAAE,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;YACpD,IAAI,MAAM;gBAAE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAEjC,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;YACzE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAY,CAAC;YAC9C,OAAO,EAAE,MAAM,EAAE,CAAC;QACpB,CAAC;gBAAS,CAAC;YACT,MAAM,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;gBAC3C,0BAA0B;YAC5B,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,182 @@
|
|
|
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 '../../../steps/base-step.js';
|
|
23
|
+
import type { ControlFlowExecutionContext, BranchStepOutputs } from '../../../steps/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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditional.step.d.ts","sourceRoot":"","sources":["../../../../src/connectors/builtin/steps/conditional.step.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAsB,MAAM,6BAA6B,CAAC;AACtF,OAAO,KAAK,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAClG,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAM5E,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAStC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAIhF,MAAM,WAAW,qBAAsB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACpE,2FAA2F;IAC3F,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,MAAM,CAAC;IACxC,sDAAsD;IACtD,SAAS,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,iBAAiB,CAAA;KAAE,CAAC,CAAC;CACxD;AAUD,qBAAa,eAAgB,SAAQ,mBAAmB,CACtD,OAAO,2BAA2B,EAClC,qBAAqB,CACtB;IACC,SAAkB,IAAI,+BAA+B;IACrD,SAAkB,IAAI,iBAAiB;IACvC,SAAkB,WAAW,2CAA2C;IACxE,SAAkB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAA+B;IAC7D,SAAkB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAA+B;IAC7D,SAAkB,QAAQ,EAAG,SAAS,CAAU;IAChD,SAAkB,IAAI,UAAU;IAChC,SAAkB,eAAe;;;;;;OAGtB;IAEX,uEAAuE;IAC9D,WAAW,CAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,MAAM,CAAC,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAOxB,OAAO,CACpB,MAAM,EAAE,qBAAqB,EAC7B,GAAG,EAAE,2BAA2B,GAC/B,OAAO,CAAC,qBAAqB,CAAC;CA0BlC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
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 '../../../steps/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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditional.step.js","sourceRoot":"","sources":["../../../../src/connectors/builtin/steps/conditional.step.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtF,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAE5E,iBAAiB;AAEjB,MAAM,CAAC,MAA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