@oomol-lab/open-flow 0.1.0-beta.73 → 0.1.0-beta.74
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/LICENSE +36 -0
- package/NOTICE +7 -0
- package/README.md +40 -0
- package/dist/browser/{createResourceDialog-BWJkjiOO.js → createResourceDialog-DI9pL-Yr.js} +2 -2
- package/dist/browser/{dialog-CUy_fwx9.js → dialog-BYJGvItc.js} +54 -19
- package/dist/browser/{flowChanges-CgSnSqqP.js → flowChanges-RL-H4CjD.js} +306 -48
- package/dist/browser/{flowWorkspace-Bf7H-r0t.js → flowWorkspace-BkDsETj0.js} +20745 -20186
- package/dist/browser/preview.css +73 -3
- package/dist/browser/preview.js +21410 -20607
- package/dist/browser/{typeScriptSession-B0hC-C8y.js → typeScriptSession-CSRwWmZm.js} +1 -1
- package/dist/browser/ui.css +72 -2
- package/dist/browser/workbench.css +73 -3
- package/dist/browser/workbench.js +14 -76
- package/dist/browser/{workbenchSelect-C3e4J93X.js → workbenchSelect-BcWPWGzw.js} +1 -1
- package/dist/command/index.js +34 -34
- package/dist/common/authoring.d.ts +1 -1
- package/dist/common/authoringFields.d.ts +1 -1
- package/dist/common/authoringSchema.d.ts +28 -4
- package/dist/common/connector-proxy.d.ts +1 -1
- package/dist/common/control-api-conformance.d.ts +1 -1
- package/dist/common/control-api-conformance.js +61 -24
- package/dist/common/control-api.d.ts +4 -3
- package/dist/common/control-api.js +59 -22
- package/dist/common/control-requests.d.ts +2 -1
- package/dist/common/control-requests.js +204 -42
- package/dist/common/cron-trigger.d.ts +1 -1
- package/dist/common/decision.d.ts +1 -1
- package/dist/common/draftOperations.d.ts +1 -1
- package/dist/common/engine-contract.d.ts +3 -2
- package/dist/common/event-source-definition.d.ts +1 -1
- package/dist/common/flow-agent.d.ts +1 -1
- package/dist/{browser → common}/flow-authoring-node.d.ts +3 -3
- package/dist/{browser → common}/flow-authoring.js +75 -23
- package/dist/{browser → common}/flow-change-schema.d.ts +177 -6
- package/dist/{browser → common}/flow-change.d.ts +35 -15
- package/dist/{browser → common}/flow-change.js +77 -25
- package/dist/common/flow-connectionUsage.d.ts +1 -1
- package/dist/common/flow-encoding.d.ts +1 -1
- package/dist/common/flow-encoding.js +34 -16
- package/dist/common/flow-errorHandling.d.ts +1 -1
- package/dist/common/flow-graph.d.ts +1 -1
- package/dist/common/flow-modules.d.ts +1 -1
- package/dist/common/flow-promptTemplate.d.ts +1 -1
- package/dist/common/flow-retry.d.ts +1 -1
- package/dist/common/flow-semantics.d.ts +1 -1
- package/dist/common/flow-semantics.js +151 -32
- package/dist/common/flow-workflowFile.d.ts +1 -1
- package/dist/common/flowInspection.d.ts +3 -3
- package/dist/common/integration-trigger.d.ts +1 -1
- package/dist/common/licenses.md +118 -1
- package/dist/common/liveDetails.d.ts +1 -1
- package/dist/common/mcp.d.ts +2 -1
- package/dist/common/mcp.js +59 -22
- package/dist/common/openapi.d.ts +1 -1
- package/dist/common/poll-trigger.d.ts +1 -1
- package/dist/common/run-results.d.ts +8 -1
- package/dist/common/runtime-contract.d.ts +8 -2
- package/dist/common/runtime-contract.js +22 -5
- package/dist/common/scheduler-checkpoint.d.ts +1 -1
- package/dist/common/scheduler-dependencies.d.ts +1 -1
- package/dist/common/scheduler-node-execution.d.ts +1 -1
- package/dist/common/scheduler.d.ts +2 -2
- package/dist/common/scheduler.js +31 -12
- package/dist/common/trigger-catalog.d.ts +1 -1
- package/dist/common/trigger-config-options.d.ts +1 -1
- package/dist/common/trigger-config.d.ts +1 -1
- package/dist/common/trigger-contract.d.ts +2 -2
- package/dist/common/trigger-localization.d.ts +1 -1
- package/dist/common/webhook-response.d.ts +1 -1
- package/dist/common/webhook-trigger.d.ts +1 -1
- package/dist/common/workflow.d.ts +17 -1
- package/dist/common/workflow.js +68 -22
- package/dist/index.d.ts +6 -3
- package/package.json +7 -6
- package/src/base/common/json.ts +90 -0
- package/src/canvas/common/commands.ts +15 -0
- package/src/connector/common/actionSchema.ts +168 -0
- package/src/connector/common/proxy.ts +44 -0
- package/src/control/common/api.ts +1505 -0
- package/src/control/common/authoring.ts +912 -0
- package/src/control/common/authoringCondition.ts +110 -0
- package/src/control/common/authoringDiagnosticFields.ts +136 -0
- package/src/control/common/authoringExamples.ts +192 -0
- package/src/control/common/authoringFields.ts +53 -0
- package/src/control/common/authoringLlm.ts +70 -0
- package/src/control/common/authoringOpenApi.ts +129 -0
- package/src/control/common/authoringSchema.ts +404 -0
- package/src/control/common/authoringTools.ts +123 -0
- package/src/control/common/authoringTriggers.ts +26 -0
- package/src/control/common/checkDecoders.ts +65 -0
- package/src/control/common/conformance.ts +1989 -0
- package/src/control/common/connectorDecoders.ts +370 -0
- package/src/control/common/connectorQueries.ts +61 -0
- package/src/control/common/decoding.ts +60 -0
- package/src/control/common/draftOperations.ts +61 -0
- package/src/control/common/errors.ts +114 -0
- package/src/control/common/eventSourceSchemas.ts +13 -0
- package/src/control/common/eventSources.ts +186 -0
- package/src/control/common/flowDecoders.ts +153 -0
- package/src/control/common/flowInspection.ts +181 -0
- package/src/control/common/flowNotifications.ts +37 -0
- package/src/control/common/liveDetails.ts +124 -0
- package/src/control/common/mcp.ts +241 -0
- package/src/control/common/mcpConformance.ts +142 -0
- package/src/control/common/providerAccess.ts +28 -0
- package/src/control/common/providerIconSprite.ts +42 -0
- package/src/control/common/publicationDecoders.ts +98 -0
- package/src/control/common/random.ts +16 -0
- package/src/control/common/requests.ts +112 -0
- package/src/control/common/resultQuery.ts +8 -0
- package/src/control/common/results.ts +176 -0
- package/src/control/common/revisionDecoders.ts +52 -0
- package/src/control/common/runDecoders.ts +240 -0
- package/src/control/common/triggerCatalog.ts +89 -0
- package/src/control/common/triggerDecoders.ts +175 -0
- package/src/decision/common/decision.ts +168 -0
- package/src/event-source/common/catalog.generated.json +65 -0
- package/src/event-source/common/definition.ts +66 -0
- package/src/event-source/common/index.ts +99 -0
- package/src/execution/common/checkpoint.ts +311 -0
- package/src/execution/common/dependencies.ts +440 -0
- package/src/execution/common/engineContract.ts +80 -0
- package/src/execution/common/events.ts +328 -0
- package/src/execution/common/node-execution.ts +467 -0
- package/src/execution/common/runLifecycle.ts +250 -0
- package/src/execution/common/runtime.ts +563 -0
- package/src/execution/common/scheduler.ts +696 -0
- package/src/execution/common/wait.ts +36 -0
- package/src/flow/common/agent.ts +305 -0
- package/src/flow/common/authoring.ts +30 -0
- package/src/flow/common/change.ts +1036 -0
- package/src/flow/common/changeSchema.ts +783 -0
- package/src/flow/common/codePermissions.ts +2 -0
- package/src/flow/common/condition.ts +265 -0
- package/src/flow/common/connectionUsage.ts +131 -0
- package/src/flow/common/edgeChanges.ts +35 -0
- package/src/flow/common/encoding.ts +437 -0
- package/src/flow/common/errorHandling.ts +34 -0
- package/src/flow/common/graph.ts +892 -0
- package/src/flow/common/inputValue.ts +16 -0
- package/src/flow/common/json.ts +8 -0
- package/src/flow/common/moduleChanges.ts +31 -0
- package/src/flow/common/modules.ts +292 -0
- package/src/flow/common/nodeChanges.ts +762 -0
- package/src/flow/common/portChanges.ts +36 -0
- package/src/flow/common/promptTemplate.ts +15 -0
- package/src/flow/common/retry.ts +20 -0
- package/src/flow/common/schema.ts +162 -0
- package/src/flow/common/schemaCompare.ts +176 -0
- package/src/flow/common/schemaComparer.ts +178 -0
- package/src/flow/common/schemaKeywords.ts +53 -0
- package/src/flow/common/semantics.ts +474 -0
- package/src/flow/common/sourceField.ts +35 -0
- package/src/flow/common/triggerScheduleSchema.ts +8 -0
- package/src/flow/common/wait.ts +30 -0
- package/src/flow/common/webhookMethod.ts +7 -0
- package/src/flow/common/webhookResponse.ts +75 -0
- package/src/flow/common/workflowFile.ts +97 -0
- package/src/json-schema-subset/checker/array.ts +142 -0
- package/src/json-schema-subset/checker/cache.ts +57 -0
- package/src/json-schema-subset/checker/checker.ts +230 -0
- package/src/json-schema-subset/checker/enumAndConst.ts +113 -0
- package/src/json-schema-subset/checker/equals.ts +93 -0
- package/src/json-schema-subset/checker/numeric/checker.ts +50 -0
- package/src/json-schema-subset/checker/numeric/float.ts +121 -0
- package/src/json-schema-subset/checker/numeric/index.ts +1 -0
- package/src/json-schema-subset/checker/numeric/integer.ts +119 -0
- package/src/json-schema-subset/checker/numeric/integerNormalizer.ts +72 -0
- package/src/json-schema-subset/checker/object.ts +354 -0
- package/src/json-schema-subset/checker/range.ts +91 -0
- package/src/json-schema-subset/checker/string.ts +60 -0
- package/src/json-schema-subset/checker/tools/index.ts +3 -0
- package/src/json-schema-subset/checker/tools/mark.ts +82 -0
- package/src/json-schema-subset/checker/tools/quantum.ts +106 -0
- package/src/json-schema-subset/checker/tools/range.ts +210 -0
- package/src/json-schema-subset/checker/validator.ts +23 -0
- package/src/json-schema-subset/compiler/array.ts +163 -0
- package/src/json-schema-subset/compiler/combination.ts +109 -0
- package/src/json-schema-subset/compiler/common.ts +99 -0
- package/src/json-schema-subset/compiler/compiler.ts +188 -0
- package/src/json-schema-subset/compiler/enumAndConst.ts +75 -0
- package/src/json-schema-subset/compiler/index.ts +11 -0
- package/src/json-schema-subset/compiler/object.ts +411 -0
- package/src/json-schema-subset/compiler/primitive.ts +144 -0
- package/src/json-schema-subset/compiler/utils.ts +24 -0
- package/src/json-schema-subset/compiler/wrapper.ts +192 -0
- package/src/json-schema-subset/error.ts +55 -0
- package/src/json-schema-subset/expression/calculator.ts +442 -0
- package/src/json-schema-subset/expression/combination.ts +49 -0
- package/src/json-schema-subset/expression/expression.ts +191 -0
- package/src/json-schema-subset/expression/index.ts +25 -0
- package/src/json-schema-subset/expression/result.ts +88 -0
- package/src/json-schema-subset/expression/types.ts +36 -0
- package/src/json-schema-subset/extends/extendsContext.ts +89 -0
- package/src/json-schema-subset/extends/index.ts +2 -0
- package/src/json-schema-subset/extends/types.ts +12 -0
- package/src/json-schema-subset/global.ts +60 -0
- package/src/json-schema-subset/index.ts +8 -0
- package/src/json-schema-subset/preprocessing.ts +74 -0
- package/src/json-schema-subset/types.ts +8 -0
- package/src/json-schema-subset/utils.ts +95 -0
- package/src/localization/common/languages.ts +118 -0
- package/src/localization/common/timeZone.ts +25 -0
- package/src/openapi/common/authBindings.ts +12 -0
- package/src/openapi/common/openapi.ts +459 -0
- package/src/trigger/common/config.ts +56 -0
- package/src/trigger/common/configOptions.ts +15 -0
- package/src/trigger/common/configSchema.ts +8 -0
- package/src/trigger/common/contract.ts +132 -0
- package/src/trigger/common/cron.ts +151 -0
- package/src/trigger/common/integration.ts +498 -0
- package/src/trigger/common/poll.ts +187 -0
- package/src/trigger/common/webhook.ts +412 -0
- package/src/trigger/providers/airtable/locales/fr.json +18 -0
- package/src/trigger/providers/airtable/locales/ja.json +18 -0
- package/src/trigger/providers/airtable/locales/ko.json +18 -0
- package/src/trigger/providers/airtable/locales/ru.json +18 -0
- package/src/trigger/providers/airtable/locales/zh-CN.json +18 -0
- package/src/trigger/providers/airtable/locales/zh-TW.json +18 -0
- package/src/trigger/providers/asana/locales/fr.json +15 -0
- package/src/trigger/providers/asana/locales/ja.json +15 -0
- package/src/trigger/providers/asana/locales/ko.json +15 -0
- package/src/trigger/providers/asana/locales/ru.json +15 -0
- package/src/trigger/providers/asana/locales/zh-CN.json +15 -0
- package/src/trigger/providers/asana/locales/zh-TW.json +15 -0
- package/src/trigger/providers/calendly/locales/fr.json +16 -0
- package/src/trigger/providers/calendly/locales/ja.json +16 -0
- package/src/trigger/providers/calendly/locales/ko.json +16 -0
- package/src/trigger/providers/calendly/locales/ru.json +16 -0
- package/src/trigger/providers/calendly/locales/zh-CN.json +16 -0
- package/src/trigger/providers/calendly/locales/zh-TW.json +16 -0
- package/src/trigger/providers/catalog.generated.json +4996 -0
- package/src/trigger/providers/clickup/locales/fr.json +16 -0
- package/src/trigger/providers/clickup/locales/ja.json +16 -0
- package/src/trigger/providers/clickup/locales/ko.json +16 -0
- package/src/trigger/providers/clickup/locales/ru.json +16 -0
- package/src/trigger/providers/clickup/locales/zh-CN.json +16 -0
- package/src/trigger/providers/clickup/locales/zh-TW.json +16 -0
- package/src/trigger/providers/definitions.ts +19 -0
- package/src/trigger/providers/feishu/locales/fr.json +20 -0
- package/src/trigger/providers/feishu/locales/ja.json +20 -0
- package/src/trigger/providers/feishu/locales/ko.json +20 -0
- package/src/trigger/providers/feishu/locales/ru.json +20 -0
- package/src/trigger/providers/feishu/locales/zh-CN.json +20 -0
- package/src/trigger/providers/feishu/locales/zh-TW.json +20 -0
- package/src/trigger/providers/fieldDescriptions.ts +392 -0
- package/src/trigger/providers/fieldLabels.ts +256 -0
- package/src/trigger/providers/fireflies/locales/fr.json +17 -0
- package/src/trigger/providers/fireflies/locales/ja.json +17 -0
- package/src/trigger/providers/fireflies/locales/ko.json +17 -0
- package/src/trigger/providers/fireflies/locales/ru.json +17 -0
- package/src/trigger/providers/fireflies/locales/zh-CN.json +17 -0
- package/src/trigger/providers/fireflies/locales/zh-TW.json +17 -0
- package/src/trigger/providers/github/locales/fr.json +30 -0
- package/src/trigger/providers/github/locales/ja.json +30 -0
- package/src/trigger/providers/github/locales/ko.json +30 -0
- package/src/trigger/providers/github/locales/ru.json +30 -0
- package/src/trigger/providers/github/locales/zh-CN.json +30 -0
- package/src/trigger/providers/github/locales/zh-TW.json +30 -0
- package/src/trigger/providers/gitlab/locales/fr.json +18 -0
- package/src/trigger/providers/gitlab/locales/ja.json +18 -0
- package/src/trigger/providers/gitlab/locales/ko.json +18 -0
- package/src/trigger/providers/gitlab/locales/ru.json +18 -0
- package/src/trigger/providers/gitlab/locales/zh-CN.json +18 -0
- package/src/trigger/providers/gitlab/locales/zh-TW.json +18 -0
- package/src/trigger/providers/gmail/locales/fr.json +18 -0
- package/src/trigger/providers/gmail/locales/ja.json +18 -0
- package/src/trigger/providers/gmail/locales/ko.json +18 -0
- package/src/trigger/providers/gmail/locales/ru.json +18 -0
- package/src/trigger/providers/gmail/locales/zh-CN.json +18 -0
- package/src/trigger/providers/gmail/locales/zh-TW.json +18 -0
- package/src/trigger/providers/google-calendar/locales/fr.json +15 -0
- package/src/trigger/providers/google-calendar/locales/ja.json +15 -0
- package/src/trigger/providers/google-calendar/locales/ko.json +15 -0
- package/src/trigger/providers/google-calendar/locales/ru.json +15 -0
- package/src/trigger/providers/google-calendar/locales/zh-CN.json +15 -0
- package/src/trigger/providers/google-calendar/locales/zh-TW.json +15 -0
- package/src/trigger/providers/google-drive/locales/fr.json +48 -0
- package/src/trigger/providers/google-drive/locales/ja.json +48 -0
- package/src/trigger/providers/google-drive/locales/ko.json +48 -0
- package/src/trigger/providers/google-drive/locales/ru.json +48 -0
- package/src/trigger/providers/google-drive/locales/zh-CN.json +48 -0
- package/src/trigger/providers/google-drive/locales/zh-TW.json +48 -0
- package/src/trigger/providers/google-sheets/locales/fr.json +19 -0
- package/src/trigger/providers/google-sheets/locales/ja.json +19 -0
- package/src/trigger/providers/google-sheets/locales/ko.json +19 -0
- package/src/trigger/providers/google-sheets/locales/ru.json +19 -0
- package/src/trigger/providers/google-sheets/locales/zh-CN.json +19 -0
- package/src/trigger/providers/google-sheets/locales/zh-TW.json +19 -0
- package/src/trigger/providers/intercom/locales/fr.json +17 -0
- package/src/trigger/providers/intercom/locales/ja.json +17 -0
- package/src/trigger/providers/intercom/locales/ko.json +17 -0
- package/src/trigger/providers/intercom/locales/ru.json +17 -0
- package/src/trigger/providers/intercom/locales/zh-CN.json +17 -0
- package/src/trigger/providers/intercom/locales/zh-TW.json +17 -0
- package/src/trigger/providers/jira/locales/fr.json +17 -0
- package/src/trigger/providers/jira/locales/ja.json +17 -0
- package/src/trigger/providers/jira/locales/ko.json +17 -0
- package/src/trigger/providers/jira/locales/ru.json +17 -0
- package/src/trigger/providers/jira/locales/zh-CN.json +17 -0
- package/src/trigger/providers/jira/locales/zh-TW.json +17 -0
- package/src/trigger/providers/linear/locales/fr.json +13 -0
- package/src/trigger/providers/linear/locales/ja.json +13 -0
- package/src/trigger/providers/linear/locales/ko.json +13 -0
- package/src/trigger/providers/linear/locales/ru.json +13 -0
- package/src/trigger/providers/linear/locales/zh-CN.json +13 -0
- package/src/trigger/providers/linear/locales/zh-TW.json +13 -0
- package/src/trigger/providers/locales/fr.ts +71 -0
- package/src/trigger/providers/locales/ja.ts +71 -0
- package/src/trigger/providers/locales/ko.ts +71 -0
- package/src/trigger/providers/locales/ru.ts +71 -0
- package/src/trigger/providers/locales/zh-CN.ts +71 -0
- package/src/trigger/providers/locales/zh-TW.ts +71 -0
- package/src/trigger/providers/localization.ts +59 -0
- package/src/trigger/providers/notion/locales/fr.json +16 -0
- package/src/trigger/providers/notion/locales/ja.json +16 -0
- package/src/trigger/providers/notion/locales/ko.json +16 -0
- package/src/trigger/providers/notion/locales/ru.json +16 -0
- package/src/trigger/providers/notion/locales/zh-CN.json +16 -0
- package/src/trigger/providers/notion/locales/zh-TW.json +16 -0
- package/src/trigger/providers/one-drive/locales/fr.json +16 -0
- package/src/trigger/providers/one-drive/locales/ja.json +16 -0
- package/src/trigger/providers/one-drive/locales/ko.json +16 -0
- package/src/trigger/providers/one-drive/locales/ru.json +16 -0
- package/src/trigger/providers/one-drive/locales/zh-CN.json +16 -0
- package/src/trigger/providers/one-drive/locales/zh-TW.json +16 -0
- package/src/trigger/providers/outlook/locales/fr.json +18 -0
- package/src/trigger/providers/outlook/locales/ja.json +18 -0
- package/src/trigger/providers/outlook/locales/ko.json +18 -0
- package/src/trigger/providers/outlook/locales/ru.json +18 -0
- package/src/trigger/providers/outlook/locales/zh-CN.json +18 -0
- package/src/trigger/providers/outlook/locales/zh-TW.json +18 -0
- package/src/trigger/providers/pandadoc/locales/fr.json +12 -0
- package/src/trigger/providers/pandadoc/locales/ja.json +12 -0
- package/src/trigger/providers/pandadoc/locales/ko.json +12 -0
- package/src/trigger/providers/pandadoc/locales/ru.json +12 -0
- package/src/trigger/providers/pandadoc/locales/zh-CN.json +12 -0
- package/src/trigger/providers/pandadoc/locales/zh-TW.json +12 -0
- package/src/trigger/providers/pipedrive/locales/fr.json +15 -0
- package/src/trigger/providers/pipedrive/locales/ja.json +15 -0
- package/src/trigger/providers/pipedrive/locales/ko.json +15 -0
- package/src/trigger/providers/pipedrive/locales/ru.json +15 -0
- package/src/trigger/providers/pipedrive/locales/zh-CN.json +15 -0
- package/src/trigger/providers/pipedrive/locales/zh-TW.json +15 -0
- package/src/trigger/providers/remote.ts +163 -0
- package/src/trigger/providers/resend/locales/fr.json +16 -0
- package/src/trigger/providers/resend/locales/ja.json +16 -0
- package/src/trigger/providers/resend/locales/ko.json +16 -0
- package/src/trigger/providers/resend/locales/ru.json +16 -0
- package/src/trigger/providers/resend/locales/zh-CN.json +16 -0
- package/src/trigger/providers/resend/locales/zh-TW.json +16 -0
- package/src/trigger/providers/sentry/locales/fr.json +19 -0
- package/src/trigger/providers/sentry/locales/ja.json +19 -0
- package/src/trigger/providers/sentry/locales/ko.json +19 -0
- package/src/trigger/providers/sentry/locales/ru.json +19 -0
- package/src/trigger/providers/sentry/locales/zh-CN.json +19 -0
- package/src/trigger/providers/sentry/locales/zh-TW.json +19 -0
- package/src/trigger/providers/shopify/locales/fr.json +18 -0
- package/src/trigger/providers/shopify/locales/ja.json +18 -0
- package/src/trigger/providers/shopify/locales/ko.json +18 -0
- package/src/trigger/providers/shopify/locales/ru.json +18 -0
- package/src/trigger/providers/shopify/locales/zh-CN.json +18 -0
- package/src/trigger/providers/shopify/locales/zh-TW.json +18 -0
- package/src/trigger/providers/slack/locales/fr.json +18 -0
- package/src/trigger/providers/slack/locales/ja.json +18 -0
- package/src/trigger/providers/slack/locales/ko.json +18 -0
- package/src/trigger/providers/slack/locales/ru.json +18 -0
- package/src/trigger/providers/slack/locales/zh-CN.json +18 -0
- package/src/trigger/providers/slack/locales/zh-TW.json +18 -0
- package/src/trigger/providers/slackbot/locales/fr.json +23 -0
- package/src/trigger/providers/slackbot/locales/ja.json +23 -0
- package/src/trigger/providers/slackbot/locales/ko.json +23 -0
- package/src/trigger/providers/slackbot/locales/ru.json +23 -0
- package/src/trigger/providers/slackbot/locales/zh-CN.json +23 -0
- package/src/trigger/providers/slackbot/locales/zh-TW.json +23 -0
- package/src/trigger/providers/source-events.ts +25 -0
- package/src/trigger/providers/stripe/locales/fr.json +17 -0
- package/src/trigger/providers/stripe/locales/ja.json +17 -0
- package/src/trigger/providers/stripe/locales/ko.json +17 -0
- package/src/trigger/providers/stripe/locales/ru.json +17 -0
- package/src/trigger/providers/stripe/locales/zh-CN.json +17 -0
- package/src/trigger/providers/stripe/locales/zh-TW.json +17 -0
- package/src/trigger/providers/tally/locales/fr.json +12 -0
- package/src/trigger/providers/tally/locales/ja.json +12 -0
- package/src/trigger/providers/tally/locales/ko.json +12 -0
- package/src/trigger/providers/tally/locales/ru.json +12 -0
- package/src/trigger/providers/tally/locales/zh-CN.json +12 -0
- package/src/trigger/providers/tally/locales/zh-TW.json +12 -0
- package/src/trigger/providers/telegram/locales/fr.json +17 -0
- package/src/trigger/providers/telegram/locales/ja.json +17 -0
- package/src/trigger/providers/telegram/locales/ko.json +17 -0
- package/src/trigger/providers/telegram/locales/ru.json +17 -0
- package/src/trigger/providers/telegram/locales/zh-CN.json +17 -0
- package/src/trigger/providers/telegram/locales/zh-TW.json +17 -0
- package/src/trigger/providers/typeform/locales/fr.json +12 -0
- package/src/trigger/providers/typeform/locales/ja.json +12 -0
- package/src/trigger/providers/typeform/locales/ko.json +12 -0
- package/src/trigger/providers/typeform/locales/ru.json +12 -0
- package/src/trigger/providers/typeform/locales/zh-CN.json +12 -0
- package/src/trigger/providers/typeform/locales/zh-TW.json +12 -0
- package/src/trigger/providers/vercel/locales/fr.json +18 -0
- package/src/trigger/providers/vercel/locales/ja.json +18 -0
- package/src/trigger/providers/vercel/locales/ko.json +18 -0
- package/src/trigger/providers/vercel/locales/ru.json +18 -0
- package/src/trigger/providers/vercel/locales/zh-CN.json +18 -0
- package/src/trigger/providers/vercel/locales/zh-TW.json +18 -0
- package/src/trigger/providers/woocommerce/locales/fr.json +19 -0
- package/src/trigger/providers/woocommerce/locales/ja.json +19 -0
- package/src/trigger/providers/woocommerce/locales/ko.json +19 -0
- package/src/trigger/providers/woocommerce/locales/ru.json +19 -0
- package/src/trigger/providers/woocommerce/locales/zh-CN.json +19 -0
- package/src/trigger/providers/woocommerce/locales/zh-TW.json +19 -0
- package/src/trigger/providers/zendesk/locales/fr.json +15 -0
- package/src/trigger/providers/zendesk/locales/ja.json +15 -0
- package/src/trigger/providers/zendesk/locales/ko.json +15 -0
- package/src/trigger/providers/zendesk/locales/ru.json +15 -0
- package/src/trigger/providers/zendesk/locales/zh-CN.json +15 -0
- package/src/trigger/providers/zendesk/locales/zh-TW.json +15 -0
- package/src/trigger/providers/zoom/locales/fr.json +17 -0
- package/src/trigger/providers/zoom/locales/ja.json +17 -0
- package/src/trigger/providers/zoom/locales/ko.json +17 -0
- package/src/trigger/providers/zoom/locales/ru.json +17 -0
- package/src/trigger/providers/zoom/locales/zh-CN.json +17 -0
- package/src/trigger/providers/zoom/locales/zh-TW.json +17 -0
- package/src/types/index.ts +112 -0
- package/src/workflow/common/workflow.ts +273 -0
- package/dist/browser/lib-DrKav3HG.js +0 -11403
- /package/dist/{browser → common}/flow-authoring-edge.d.ts +0 -0
- /package/dist/{browser → common}/flow-authoring-module.d.ts +0 -0
- /package/dist/{browser → common}/flow-authoring.d.ts +0 -0
- /package/dist/{browser → common}/flow-input-value.d.ts +0 -0
- /package/dist/{browser → common}/webhook-method.d.ts +0 -0
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
import type { AgentConfig } from '../../flow/common/agent.ts'
|
|
2
|
+
import type { Graph, GraphNode, InputMapping, InputPortDefinition, JsonValue, TriggerNode } from '../../flow/common/change.ts'
|
|
3
|
+
import type { WebhookResponseSnapshot } from '../../flow/common/webhookResponse.ts'
|
|
4
|
+
import type { FlowRunCheckpoint } from './checkpoint.ts'
|
|
5
|
+
import type { Dependencies } from './dependencies.ts'
|
|
6
|
+
import type { AgentCheckpoint, AgentResult } from './runtime.ts'
|
|
7
|
+
import type { FlowRunOptions, SchedulerEvent, SchedulerFailure, TaskInvocation } from './scheduler.ts'
|
|
8
|
+
|
|
9
|
+
import * as Effect from 'effect/Effect'
|
|
10
|
+
import { z } from 'zod'
|
|
11
|
+
import { agentInput } from '../../flow/common/agent.ts'
|
|
12
|
+
import { isTriggerNode, supportsNodeRetry, portsByHandle } from '../../flow/common/change.ts'
|
|
13
|
+
import { nodeInputMappings, selectConditionBranches } from '../../flow/common/condition.ts'
|
|
14
|
+
import { nodeInputPorts as nodePorts, isResolutionNode, nodeOutputPorts, resolutionOutputPorts } from '../../flow/common/graph.ts'
|
|
15
|
+
import { inputValue } from '../../flow/common/inputValue.ts'
|
|
16
|
+
import { matchesSchema } from '../../flow/common/schema.ts'
|
|
17
|
+
import { validWebhookStatus, webhookHeaderValues, encodeWebhookBody } from '../../flow/common/webhookResponse.ts'
|
|
18
|
+
|
|
19
|
+
interface NodeExecutionContext {
|
|
20
|
+
readonly createId: FlowRunOptions['createId']
|
|
21
|
+
readonly emit: (event: SchedulerEvent) => Effect.Effect<void, Error>
|
|
22
|
+
readonly invokeTask: FlowRunOptions['invokeTask']
|
|
23
|
+
readonly projectFailure: FlowRunOptions['projectFailure']
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class PortValidationError extends Error {}
|
|
27
|
+
|
|
28
|
+
export type ExecutableNode = Exclude<GraphNode, TriggerNode>
|
|
29
|
+
|
|
30
|
+
export function usesPending(graph: Graph, nodeId: string): boolean {
|
|
31
|
+
return (
|
|
32
|
+
graph.edges.some((edge) => edge.source == nodeId && edge.sourceHandle == 'pending') ||
|
|
33
|
+
Object.values(graph.nodes).some(
|
|
34
|
+
(node) =>
|
|
35
|
+
!isTriggerNode(node) &&
|
|
36
|
+
Object.values(nodeInputMappings(node)).some(
|
|
37
|
+
(mapping) =>
|
|
38
|
+
mapping.kind == 'sources' && mapping.sources.some((source) => source.kind == 'node' && source.nodeId == nodeId && source.output == 'pending'),
|
|
39
|
+
),
|
|
40
|
+
)
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export class NodeValidationError extends PortValidationError {
|
|
45
|
+
readonly code: 'node.input-invalid' | 'node.output-invalid' | 'webhook.response-status-invalid' | 'webhook.response-headers-invalid'
|
|
46
|
+
constructor(code: NodeValidationError['code'], error: unknown) {
|
|
47
|
+
super(error instanceof Error ? error.message : String(error))
|
|
48
|
+
this.code = code
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function nodeFailure(error: unknown, project: FlowRunOptions['projectFailure']): SchedulerFailure {
|
|
53
|
+
if (error instanceof NodeValidationError) return { code: error.code, message: error.message, catchable: true }
|
|
54
|
+
return project?.(error) ?? { code: 'node.failed', message: error instanceof Error ? error.message : String(error) }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function invokeWithRetry(context: NodeExecutionContext, node: ExecutableNode, invocation: TaskInvocation): Effect.Effect<unknown, Error> {
|
|
58
|
+
const retry = supportsNodeRetry(node) ? node.retry : undefined
|
|
59
|
+
const attempt = (index: number): Effect.Effect<unknown, Error> =>
|
|
60
|
+
Effect.suspend(() =>
|
|
61
|
+
context.invokeTask(index == 0 ? invocation : { ...invocation, invocationId: context.createId() }).pipe(
|
|
62
|
+
Effect.catch((error) => {
|
|
63
|
+
const failure = nodeFailure(error, context.projectFailure)
|
|
64
|
+
if (retry == null || index >= retry.maxRetries || failure.retryable !== true) return Effect.fail(error)
|
|
65
|
+
return Effect.gen(function* () {
|
|
66
|
+
yield* context.emit({
|
|
67
|
+
type: 'node.log',
|
|
68
|
+
level: 'warn',
|
|
69
|
+
runId: invocation.runId,
|
|
70
|
+
nodeId: invocation.nodeId,
|
|
71
|
+
jobId: invocation.jobId,
|
|
72
|
+
message: `Attempt ${index + 1}/${retry.maxRetries + 1} failed (${failure.code}): ${failure.message}. Retrying attempt ${index + 2}/${retry.maxRetries + 1} in ${retry.intervalMs} ms.`,
|
|
73
|
+
})
|
|
74
|
+
yield* Effect.sleep(retry.intervalMs)
|
|
75
|
+
return yield* attempt(index + 1)
|
|
76
|
+
})
|
|
77
|
+
}),
|
|
78
|
+
),
|
|
79
|
+
)
|
|
80
|
+
return attempt(0)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function nodeTitle(node: GraphNode): string | undefined {
|
|
84
|
+
if (node.name != null) return node.name
|
|
85
|
+
switch (node.kind) {
|
|
86
|
+
case 'condition':
|
|
87
|
+
return
|
|
88
|
+
case 'outputs':
|
|
89
|
+
return 'Workflow Outputs'
|
|
90
|
+
case 'value':
|
|
91
|
+
return 'Fixed Values'
|
|
92
|
+
case 'task':
|
|
93
|
+
return node.task.name
|
|
94
|
+
case 'approval':
|
|
95
|
+
return 'Approval'
|
|
96
|
+
case 'wait':
|
|
97
|
+
return 'Wait'
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function nodeKind(
|
|
102
|
+
node: ExecutableNode,
|
|
103
|
+
):
|
|
104
|
+
| 'agent'
|
|
105
|
+
| 'approval'
|
|
106
|
+
| 'condition'
|
|
107
|
+
| 'connector'
|
|
108
|
+
| 'decision'
|
|
109
|
+
| 'javascript'
|
|
110
|
+
| 'openapi'
|
|
111
|
+
| 'llm'
|
|
112
|
+
| 'value'
|
|
113
|
+
| 'wait'
|
|
114
|
+
| 'outputs'
|
|
115
|
+
| 'workflow'
|
|
116
|
+
| 'webhook-response' {
|
|
117
|
+
if (node.kind != 'task') return node.kind
|
|
118
|
+
return 'moduleId' in node.task ? 'javascript' : node.task.executor.kind
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function jsonValue(value: unknown, description: string, depth = 0): JsonValue {
|
|
122
|
+
if (depth > 64) throw new Error(`${description} exceeds the maximum JSON depth.`)
|
|
123
|
+
if (value === null || typeof value == 'boolean' || typeof value == 'string') return value
|
|
124
|
+
if (typeof value == 'number' && Number.isFinite(value)) return value
|
|
125
|
+
if (Array.isArray(value)) return value.map((item) => jsonValue(item, description, depth + 1))
|
|
126
|
+
if (value == null || typeof value != 'object') throw new Error(`${description} must be an object.`)
|
|
127
|
+
const source = value as Readonly<Record<string, unknown>>
|
|
128
|
+
return Object.fromEntries(Object.entries(source).map(([key, item]) => [key, jsonValue(item, description, depth + 1)]))
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export const agentCheckpointSchema = z.strictObject({
|
|
132
|
+
state: z.json(),
|
|
133
|
+
callId: z.string().min(1),
|
|
134
|
+
toolId: z.string().min(1),
|
|
135
|
+
input: z.record(z.string(), z.json()),
|
|
136
|
+
rounds: z.number().int().nonnegative(),
|
|
137
|
+
version: z.literal(1),
|
|
138
|
+
})
|
|
139
|
+
const agentResultSchema = z.union([
|
|
140
|
+
z.strictObject({ kind: z.literal('completed'), output: z.json() }),
|
|
141
|
+
z.strictObject({ kind: z.literal('suspended'), checkpoint: agentCheckpointSchema }),
|
|
142
|
+
])
|
|
143
|
+
|
|
144
|
+
export function jsonEqual(left: JsonValue, right: JsonValue): boolean {
|
|
145
|
+
if (left === right) return true
|
|
146
|
+
if (left == null || right == null || typeof left != 'object' || typeof right != 'object') return false
|
|
147
|
+
if (Array.isArray(left) || Array.isArray(right)) {
|
|
148
|
+
return Array.isArray(left) && Array.isArray(right) && left.length == right.length && left.every((value, index) => jsonEqual(value, right[index]!))
|
|
149
|
+
}
|
|
150
|
+
const leftEntries = Object.entries(left)
|
|
151
|
+
const rightEntries = Object.entries(right)
|
|
152
|
+
const rightRecord = right as Readonly<Record<string, JsonValue>>
|
|
153
|
+
return (
|
|
154
|
+
leftEntries.length == rightEntries.length && leftEntries.every(([key, value]) => Object.hasOwn(rightRecord, key) && jsonEqual(value, rightRecord[key]!))
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function outputRecord(value: unknown, nodeId: string): Readonly<Record<string, JsonValue>> {
|
|
159
|
+
if (value === undefined) return {}
|
|
160
|
+
if (value == null || typeof value != 'object' || Array.isArray(value)) throw new Error(`Node "${nodeId}" must return an object.`)
|
|
161
|
+
return value as Readonly<Record<string, JsonValue>>
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function agentConfig(node: ExecutableNode): AgentConfig | undefined {
|
|
165
|
+
const task = node.kind == 'task' && 'executor' in node.task ? node.task : undefined
|
|
166
|
+
return task?.executor.kind == 'agent' ? task.executor : undefined
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function agentNotice(node: ExecutableNode, values: Readonly<Record<string, JsonValue>>) {
|
|
170
|
+
const notification = agentConfig(node)?.notification
|
|
171
|
+
if (notification == null) return undefined
|
|
172
|
+
return {
|
|
173
|
+
messageHandle: notification.messageHandle,
|
|
174
|
+
input: Object.fromEntries(
|
|
175
|
+
notification.inputDefinitions.flatMap((port) => {
|
|
176
|
+
if (!('handle' in port) || port.handle == notification.messageHandle) return []
|
|
177
|
+
const source = notification.inputs[port.handle]
|
|
178
|
+
return [[port.handle, source == null ? (port.value ?? null) : agentInput(source, values)]]
|
|
179
|
+
}),
|
|
180
|
+
),
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function agentApproval(config: AgentConfig, checkpoint: AgentCheckpoint, inputs: Readonly<Record<string, JsonValue>>): JsonValue {
|
|
185
|
+
const tool = config.tools.find((item) => item.id == checkpoint.toolId)
|
|
186
|
+
if (tool == null || !tool.approval || checkpoint.rounds > config.maxRounds) throw new Error('Agent pause does not match its tool declaration.')
|
|
187
|
+
for (const port of tool.inputs) {
|
|
188
|
+
const value = checkpoint.input[port.handle]
|
|
189
|
+
if (value === undefined || (!(value === null && port.nullable) && !matchesSchema(value, port.jsonSchema)))
|
|
190
|
+
throw new Error('Agent pause arguments are invalid.')
|
|
191
|
+
if (port.source.kind != 'model' && !jsonEqual(value, agentInput(port.source, inputs))) throw new Error('Agent pause changed fixed arguments.')
|
|
192
|
+
}
|
|
193
|
+
if (Object.keys(checkpoint.input).length != tool.inputs.length) throw new Error('Agent pause contains undeclared arguments.')
|
|
194
|
+
return {
|
|
195
|
+
callId: checkpoint.callId,
|
|
196
|
+
toolId: tool.id,
|
|
197
|
+
...(tool.kind == 'workflow' ? { kind: 'workflow', flowId: tool.flowId } : { action: tool.action }),
|
|
198
|
+
...(tool.connectionId == null ? {} : { connectionId: tool.connectionId }),
|
|
199
|
+
input: checkpoint.input,
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export function validateOutputs(nodeId: string, node: ExecutableNode, value: unknown): Readonly<Record<string, JsonValue>> {
|
|
204
|
+
const raw = outputRecord(value, nodeId)
|
|
205
|
+
const discardUndeclared = node.kind == 'task' && 'executor' in node.task && (node.task.executor.kind == 'connector' || node.task.executor.kind == 'workflow')
|
|
206
|
+
const ports =
|
|
207
|
+
node.kind == 'outputs'
|
|
208
|
+
? nodePorts(node)
|
|
209
|
+
: isResolutionNode(node)
|
|
210
|
+
? resolutionOutputPorts(node)
|
|
211
|
+
: node.kind == 'task'
|
|
212
|
+
? portsByHandle(node.task.outputs)
|
|
213
|
+
: node.kind == 'value'
|
|
214
|
+
? portsByHandle(node.values)
|
|
215
|
+
: {}
|
|
216
|
+
const outputs = outputRecord(
|
|
217
|
+
jsonValue(
|
|
218
|
+
Object.fromEntries(Object.entries(raw).map(([handle, item]) => [handle, Object.hasOwn(ports, handle) && item === undefined ? null : item])),
|
|
219
|
+
`Node "${nodeId}" outputs`,
|
|
220
|
+
),
|
|
221
|
+
nodeId,
|
|
222
|
+
)
|
|
223
|
+
const complete =
|
|
224
|
+
node.kind == 'condition' || isResolutionNode(node) ? outputs : { ...Object.fromEntries(Object.keys(ports).map((handle) => [handle, null])), ...outputs }
|
|
225
|
+
const validated: [string, JsonValue][] = []
|
|
226
|
+
for (const [handle, output] of Object.entries(complete)) {
|
|
227
|
+
const port = ports[handle]
|
|
228
|
+
if (port == null) {
|
|
229
|
+
if (discardUndeclared) continue
|
|
230
|
+
throw new PortValidationError(`Node "${nodeId}" output "${handle}" does not match its declaration.`)
|
|
231
|
+
}
|
|
232
|
+
if (!(output === null && port.nullable) && !matchesSchema(output, port.jsonSchema))
|
|
233
|
+
throw new PortValidationError(`Node "${nodeId}" output "${handle}" does not match its declaration.`)
|
|
234
|
+
validated.push([handle, output])
|
|
235
|
+
}
|
|
236
|
+
return Object.fromEntries(validated)
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export type NodeResult =
|
|
240
|
+
| { readonly kind: 'calling'; readonly childRunId: string; readonly input: Readonly<Record<string, JsonValue>> }
|
|
241
|
+
| {
|
|
242
|
+
readonly kind: 'completed'
|
|
243
|
+
readonly releasedHandles?: readonly string[]
|
|
244
|
+
readonly outputs: Readonly<Record<string, JsonValue>>
|
|
245
|
+
readonly response?: WebhookResponseSnapshot
|
|
246
|
+
}
|
|
247
|
+
| { readonly kind: 'suspended'; readonly value: JsonValue; readonly agent: FlowRunCheckpoint['agents'][string] }
|
|
248
|
+
|
|
249
|
+
export function resolveNodeInputs(
|
|
250
|
+
nodeId: string,
|
|
251
|
+
node: ExecutableNode,
|
|
252
|
+
dependencies: Pick<Dependencies, 'input'>,
|
|
253
|
+
bindingValues: Readonly<Record<string, string>>,
|
|
254
|
+
launchInputs?: Readonly<Record<string, JsonValue>>,
|
|
255
|
+
): Readonly<Record<string, JsonValue>> {
|
|
256
|
+
const resolveInput = (
|
|
257
|
+
mapping: InputMapping | undefined,
|
|
258
|
+
port: InputPortDefinition,
|
|
259
|
+
supplied: JsonValue | undefined,
|
|
260
|
+
description: string,
|
|
261
|
+
required = false,
|
|
262
|
+
): JsonValue => {
|
|
263
|
+
let value = inputValue(mapping, supplied === undefined ? port.value : supplied)
|
|
264
|
+
if (mapping?.kind == 'sources') {
|
|
265
|
+
const values = mapping.sources.flatMap((source) => {
|
|
266
|
+
if (source.kind == 'binding') return Object.hasOwn(bindingValues, source.bindingId) ? [bindingValues[source.bindingId]!] : []
|
|
267
|
+
const result = dependencies.input(nodeId, source.nodeId)
|
|
268
|
+
const outputs = source.system ? result?.systemOutputs : result?.outputs
|
|
269
|
+
if (outputs == null || !Object.hasOwn(outputs, source.output)) return []
|
|
270
|
+
const output = outputs[source.output]!
|
|
271
|
+
if (source.field === undefined || output === null) return [output]
|
|
272
|
+
return output != null && typeof output === 'object' && !Array.isArray(output) && Object.hasOwn(output, source.field)
|
|
273
|
+
? [(output as Readonly<Record<string, JsonValue>>)[source.field]!]
|
|
274
|
+
: []
|
|
275
|
+
})
|
|
276
|
+
if (values.length > 1) throw new Error(`${description} has multiple available sources.`)
|
|
277
|
+
if (required && values.length == 0) throw new Error(`${description} Source has no value.`)
|
|
278
|
+
value = values[0] ?? null
|
|
279
|
+
}
|
|
280
|
+
if (required && value === undefined) throw new Error(`${description} is incomplete.`)
|
|
281
|
+
if (value === undefined) value = null
|
|
282
|
+
if (!(value === null && port.nullable) && !matchesSchema(value, port.jsonSchema))
|
|
283
|
+
throw new PortValidationError(`${description} does not match its declared schema.`)
|
|
284
|
+
return value
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const mappings = nodeInputMappings(node)
|
|
288
|
+
return Object.fromEntries(
|
|
289
|
+
Object.entries(nodePorts(node)).map(([handle, port]) => [
|
|
290
|
+
handle,
|
|
291
|
+
resolveInput(mappings[handle], port, launchInputs?.[handle], `Node "${nodeId}" input "${handle}"`, node.kind == 'condition'),
|
|
292
|
+
]),
|
|
293
|
+
)
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export function executeNode(
|
|
297
|
+
context: NodeExecutionContext,
|
|
298
|
+
input: {
|
|
299
|
+
readonly nodeId: string
|
|
300
|
+
readonly node: ExecutableNode
|
|
301
|
+
readonly jobId: string
|
|
302
|
+
readonly nodeInputs: Readonly<Record<string, JsonValue>>
|
|
303
|
+
readonly flowId: string
|
|
304
|
+
readonly runId: string
|
|
305
|
+
readonly graph: Graph
|
|
306
|
+
readonly dependencies: Pick<Dependencies, 'input'>
|
|
307
|
+
readonly previousIds: readonly string[]
|
|
308
|
+
readonly saved?: FlowRunCheckpoint['agents'][string]
|
|
309
|
+
readonly workflowRunId?: string
|
|
310
|
+
readonly resolution?: 'approve' | 'reject'
|
|
311
|
+
},
|
|
312
|
+
): Effect.Effect<NodeResult, Error> {
|
|
313
|
+
const { nodeId, node, jobId, nodeInputs, flowId, runId, graph, dependencies, previousIds, saved, workflowRunId, resolution } = input
|
|
314
|
+
const config = agentConfig(node)
|
|
315
|
+
const nodeRemainingMs = saved?.remainingMs ?? node.timeoutMs
|
|
316
|
+
const startedAt = performance.now()
|
|
317
|
+
const execution = Effect.gen(function* () {
|
|
318
|
+
const kind = nodeKind(node)
|
|
319
|
+
const title = nodeTitle(node)
|
|
320
|
+
const projectedInputs = Object.fromEntries(
|
|
321
|
+
Object.entries(nodeInputs).filter(([handle]) => {
|
|
322
|
+
if (node.kind == 'task' && 'executor' in node.task && node.task?.executor.kind == 'openapi' && handle.startsWith('auth.')) return false
|
|
323
|
+
const mapping = nodeInputMappings(node)[handle]
|
|
324
|
+
return mapping?.kind != 'sources' || mapping.sources.every((source) => source.kind != 'binding')
|
|
325
|
+
}),
|
|
326
|
+
)
|
|
327
|
+
if (resolution == null && workflowRunId == null)
|
|
328
|
+
yield* context.emit({
|
|
329
|
+
inputs: projectedInputs,
|
|
330
|
+
jobId,
|
|
331
|
+
nodeId,
|
|
332
|
+
nodeKind: kind,
|
|
333
|
+
...(title == null ? {} : { nodeTitle: title }),
|
|
334
|
+
runId,
|
|
335
|
+
type: 'node.started',
|
|
336
|
+
})
|
|
337
|
+
let outputs: Readonly<Record<string, JsonValue>>
|
|
338
|
+
switch (node.kind) {
|
|
339
|
+
case 'webhook-response': {
|
|
340
|
+
const status = nodeInputs.statusCode
|
|
341
|
+
if (!validWebhookStatus(status)) return yield* Effect.fail(new NodeValidationError('webhook.response-status-invalid', 'Invalid HTTP response status.'))
|
|
342
|
+
const headers = webhookHeaderValues(nodeInputs.headers)
|
|
343
|
+
if (headers == null) return yield* Effect.fail(new NodeValidationError('webhook.response-headers-invalid', 'Invalid HTTP response headers.'))
|
|
344
|
+
return { kind: 'completed' as const, outputs: {}, response: { ...encodeWebhookBody(nodeInputs.body!), status, headers } }
|
|
345
|
+
}
|
|
346
|
+
case 'outputs': {
|
|
347
|
+
outputs = nodeInputs
|
|
348
|
+
break
|
|
349
|
+
}
|
|
350
|
+
case 'condition': {
|
|
351
|
+
return { kind: 'completed' as const, outputs: {}, releasedHandles: selectConditionBranches(node, nodeInputs) }
|
|
352
|
+
}
|
|
353
|
+
case 'value': {
|
|
354
|
+
outputs = Object.fromEntries(node.values.map((port) => [port.handle, port.value ?? null]))
|
|
355
|
+
break
|
|
356
|
+
}
|
|
357
|
+
case 'task': {
|
|
358
|
+
const additional = new Set((node.additionalInputs ?? []).map((port) => port.handle))
|
|
359
|
+
const result = yield* invokeWithRetry(context, node, {
|
|
360
|
+
...(workflowRunId == null ? {} : { workflowRunId }),
|
|
361
|
+
additionalInputs: Object.fromEntries(Object.entries(nodeInputs).filter(([handle]) => additional.has(handle))),
|
|
362
|
+
blockId: 'moduleId' in node.task ? node.task.moduleId : nodeId,
|
|
363
|
+
flowId,
|
|
364
|
+
input: Object.fromEntries(
|
|
365
|
+
Object.entries(nodeInputs).filter(([handle]) => {
|
|
366
|
+
if (additional.has(handle)) return false
|
|
367
|
+
const task = 'executor' in node.task ? node.task : undefined
|
|
368
|
+
if (task?.executor.kind != 'openapi') return true
|
|
369
|
+
const mapping = node.inputs[handle]
|
|
370
|
+
return (
|
|
371
|
+
mapping?.kind != 'unset' &&
|
|
372
|
+
(mapping != null || task.inputs.some((port) => 'handle' in port && port.handle == handle && port.value !== undefined))
|
|
373
|
+
)
|
|
374
|
+
}),
|
|
375
|
+
),
|
|
376
|
+
invocationId: saved?.invocationId ?? (config == null ? context.createId() : jobId),
|
|
377
|
+
...(resolution == null || saved == null ? {} : { agent: { action: resolution, checkpoint: saved.checkpoint } }),
|
|
378
|
+
jobId,
|
|
379
|
+
nodeId,
|
|
380
|
+
runId,
|
|
381
|
+
...('moduleId' in node.task
|
|
382
|
+
? {
|
|
383
|
+
capabilities: node.task.capabilities ?? [],
|
|
384
|
+
moduleId: node.task.moduleId,
|
|
385
|
+
getPrevious: () => {
|
|
386
|
+
return previousIds.map((previousId) => {
|
|
387
|
+
const previous = graph.nodes[previousId]!
|
|
388
|
+
const previousResult = dependencies.input(nodeId, previousId)!
|
|
389
|
+
const systemOutputs = previousResult.systemOutputs
|
|
390
|
+
return Object.assign(
|
|
391
|
+
{
|
|
392
|
+
id: previousId,
|
|
393
|
+
name: nodeTitle(previous) ?? previousId,
|
|
394
|
+
outputs: previousResult.outputs,
|
|
395
|
+
outputDefs: Object.entries(nodeOutputPorts(previous)).map(([handle, definition]) =>
|
|
396
|
+
Object.assign(
|
|
397
|
+
{
|
|
398
|
+
handle,
|
|
399
|
+
jsonSchema: definition.jsonSchema,
|
|
400
|
+
nullable: definition.nullable,
|
|
401
|
+
},
|
|
402
|
+
definition.description == null ? {} : { description: definition.description },
|
|
403
|
+
),
|
|
404
|
+
),
|
|
405
|
+
},
|
|
406
|
+
systemOutputs == null ? {} : { systemOutputs },
|
|
407
|
+
)
|
|
408
|
+
})
|
|
409
|
+
},
|
|
410
|
+
}
|
|
411
|
+
: { kind: 'managed' as const }),
|
|
412
|
+
})
|
|
413
|
+
if ('executor' in node.task && node.task.executor.kind == 'workflow') {
|
|
414
|
+
const response = z
|
|
415
|
+
.discriminatedUnion('kind', [
|
|
416
|
+
z.strictObject({ kind: z.literal('calling'), childRunId: z.string().min(1) }),
|
|
417
|
+
z.strictObject({ kind: z.literal('completed'), outputs: z.record(z.string(), z.json()) }),
|
|
418
|
+
])
|
|
419
|
+
.parse(result)
|
|
420
|
+
if (response.kind == 'calling') return { kind: 'calling' as const, childRunId: response.childRunId, input: nodeInputs }
|
|
421
|
+
outputs = response.outputs
|
|
422
|
+
} else if (config != null) {
|
|
423
|
+
const response: AgentResult = agentResultSchema.parse(result)
|
|
424
|
+
if (response.kind == 'suspended') {
|
|
425
|
+
const checkpoint = response.checkpoint
|
|
426
|
+
const value = agentApproval(config, checkpoint, nodeInputs)
|
|
427
|
+
const left = nodeRemainingMs == null ? undefined : nodeRemainingMs - (performance.now() - startedAt)
|
|
428
|
+
if (left != null && left <= 0) throw new Error(`Node "${nodeId}" timed out.`)
|
|
429
|
+
return {
|
|
430
|
+
kind: 'suspended' as const,
|
|
431
|
+
value,
|
|
432
|
+
agent: {
|
|
433
|
+
invocationId: saved?.invocationId ?? jobId,
|
|
434
|
+
input: nodeInputs,
|
|
435
|
+
...(left == null ? {} : { remainingMs: left }),
|
|
436
|
+
checkpoint,
|
|
437
|
+
},
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
outputs = { output: response.output }
|
|
441
|
+
} else if ('executor' in node.task && node.task.executor.kind == 'connector' && node.task.executor.outputMode == 'value') {
|
|
442
|
+
outputs = { output: jsonValue(result, `Node "${nodeId}" output`) }
|
|
443
|
+
} else
|
|
444
|
+
outputs = yield* Effect.try({
|
|
445
|
+
try: () => outputRecord(result, nodeId),
|
|
446
|
+
catch: (error) => new NodeValidationError('node.output-invalid', error),
|
|
447
|
+
})
|
|
448
|
+
break
|
|
449
|
+
}
|
|
450
|
+
case 'approval':
|
|
451
|
+
case 'wait':
|
|
452
|
+
return yield* Effect.fail(new Error('Resolution jobs are handled by the Scheduler suspension boundary.'))
|
|
453
|
+
}
|
|
454
|
+
return yield* Effect.try({
|
|
455
|
+
try: () => ({ kind: 'completed' as const, outputs: validateOutputs(nodeId, node, outputs) }),
|
|
456
|
+
catch: (error) => new NodeValidationError('node.output-invalid', error),
|
|
457
|
+
})
|
|
458
|
+
})
|
|
459
|
+
return nodeRemainingMs == null
|
|
460
|
+
? execution
|
|
461
|
+
: execution.pipe(
|
|
462
|
+
Effect.timeoutOrElse({
|
|
463
|
+
duration: nodeRemainingMs,
|
|
464
|
+
orElse: () => Effect.fail(new Error(`Node "${nodeId}" timed out.`)),
|
|
465
|
+
}),
|
|
466
|
+
)
|
|
467
|
+
}
|