@open-mercato/core 0.7.1-develop.7193.1.910a5b0a1e → 0.7.1-develop.7194.1.ab4fc81f82
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/.turbo/turbo-build.log +2 -2
- package/AGENTS.md +4 -3
- package/agentic/standalone-guide.md +1 -1
- package/build.mjs +16 -0
- package/dist/generated/entities/action_log/index.js +2 -0
- package/dist/generated/entities/action_log/index.js.map +2 -2
- package/dist/generated/entities/user/index.js +2 -0
- package/dist/generated/entities/user/index.js.map +2 -2
- package/dist/generated/entities/user_task/index.js +14 -0
- package/dist/generated/entities/user_task/index.js.map +2 -2
- package/dist/generated/entities/workflow_definition/index.js +6 -0
- package/dist/generated/entities/workflow_definition/index.js.map +2 -2
- package/dist/generated/entities/workflow_definition_draft/index.js +25 -0
- package/dist/generated/entities/workflow_definition_draft/index.js.map +7 -0
- package/dist/generated/entities/workflow_definition_metric_rollup/index.js +23 -0
- package/dist/generated/entities/workflow_definition_metric_rollup/index.js.map +7 -0
- package/dist/generated/entities/workflow_instance/index.js +4 -0
- package/dist/generated/entities/workflow_instance/index.js.map +2 -2
- package/dist/generated/entities.ids.generated.js +4 -1
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +39 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/helpers/integration/workflowsFixtures.js +477 -2
- package/dist/helpers/integration/workflowsFixtures.js.map +2 -2
- package/dist/helpers/integration/workflowsUi.js +148 -0
- package/dist/helpers/integration/workflowsUi.js.map +7 -0
- package/dist/modules/attachments/lib/createFromBuffer.js +79 -0
- package/dist/modules/attachments/lib/createFromBuffer.js.map +7 -0
- package/dist/modules/audit_logs/data/entities.js +5 -0
- package/dist/modules/audit_logs/data/entities.js.map +2 -2
- package/dist/modules/audit_logs/data/validators.js +1 -0
- package/dist/modules/audit_logs/data/validators.js.map +2 -2
- package/dist/modules/audit_logs/lib/projections.js +2 -1
- package/dist/modules/audit_logs/lib/projections.js.map +2 -2
- package/dist/modules/audit_logs/migrations/Migration20260625120000.js +15 -0
- package/dist/modules/audit_logs/migrations/Migration20260625120000.js.map +7 -0
- package/dist/modules/audit_logs/services/actionLogService.js +3 -0
- package/dist/modules/audit_logs/services/actionLogService.js.map +2 -2
- package/dist/modules/auth/data/entities.js +6 -0
- package/dist/modules/auth/data/entities.js.map +2 -2
- package/dist/modules/auth/lib/executionPrincipal.js +140 -0
- package/dist/modules/auth/lib/executionPrincipal.js.map +7 -0
- package/dist/modules/auth/migrations/Migration20260625050000.js +13 -0
- package/dist/modules/auth/migrations/Migration20260625050000.js.map +7 -0
- package/dist/modules/business_rules/components/InlineRuleEditor.js +154 -0
- package/dist/modules/business_rules/components/InlineRuleEditor.js.map +7 -0
- package/dist/modules/business_rules/data/validators.js +6 -0
- package/dist/modules/business_rules/data/validators.js.map +2 -2
- package/dist/modules/business_rules/lib/rule-engine.js +5 -3
- package/dist/modules/business_rules/lib/rule-engine.js.map +2 -2
- package/dist/modules/catalog/commands/products.js +5 -0
- package/dist/modules/catalog/commands/products.js.map +2 -2
- package/dist/modules/catalog/workflows.js +19 -0
- package/dist/modules/catalog/workflows.js.map +7 -0
- package/dist/modules/customer_accounts/backend/customer_accounts/roles/[id]/page.js +3 -1
- package/dist/modules/customer_accounts/backend/customer_accounts/roles/[id]/page.js.map +2 -2
- package/dist/modules/customer_accounts/cli.js +80 -0
- package/dist/modules/customer_accounts/cli.js.map +7 -0
- package/dist/modules/customer_accounts/lib/customerRoleAclSync.js +59 -0
- package/dist/modules/customer_accounts/lib/customerRoleAclSync.js.map +7 -0
- package/dist/modules/customer_accounts/setup.js +4 -2
- package/dist/modules/customer_accounts/setup.js.map +2 -2
- package/dist/modules/customers/commands/deals.js +4 -0
- package/dist/modules/customers/commands/deals.js.map +2 -2
- package/dist/modules/customers/components/detail/ChangelogEntryRow.js +1 -1
- package/dist/modules/customers/components/detail/ChangelogEntryRow.js.map +2 -2
- package/dist/modules/customers/components/detail/utils.js +2 -0
- package/dist/modules/customers/components/detail/utils.js.map +2 -2
- package/dist/modules/customers/events.js +13 -2
- package/dist/modules/customers/events.js.map +2 -2
- package/dist/modules/customers/lib/link-workflow-task-handler.js +64 -0
- package/dist/modules/customers/lib/link-workflow-task-handler.js.map +7 -0
- package/dist/modules/customers/lib/todoCompatibility.js +1 -1
- package/dist/modules/customers/lib/todoCompatibility.js.map +2 -2
- package/dist/modules/customers/lib/workflowTaskLink.js +9 -0
- package/dist/modules/customers/lib/workflowTaskLink.js.map +7 -0
- package/dist/modules/customers/subscribers/link-workflow-task.js +12 -0
- package/dist/modules/customers/subscribers/link-workflow-task.js.map +7 -0
- package/dist/modules/customers/workflows.js +29 -0
- package/dist/modules/customers/workflows.js.map +7 -0
- package/dist/modules/entities/api/records.js +13 -33
- package/dist/modules/entities/api/records.js.map +3 -3
- package/dist/modules/entities/lib/entityClassification.js +60 -0
- package/dist/modules/entities/lib/entityClassification.js.map +7 -0
- package/dist/modules/sales/commands/documents.js +31 -0
- package/dist/modules/sales/commands/documents.js.map +2 -2
- package/dist/modules/sales/events.js +12 -1
- package/dist/modules/sales/events.js.map +2 -2
- package/dist/modules/sales/workflows.js +12 -1
- package/dist/modules/sales/workflows.js.map +2 -2
- package/dist/modules/seeds/cli.js +199 -0
- package/dist/modules/seeds/cli.js.map +7 -0
- package/dist/modules/seeds/examples/sample-seed.json +26 -0
- package/dist/modules/seeds/index.js +12 -0
- package/dist/modules/seeds/index.js.map +7 -0
- package/dist/modules/workflows/acl.js +96 -0
- package/dist/modules/workflows/acl.js.map +2 -2
- package/dist/modules/workflows/ai-agents.js +50 -0
- package/dist/modules/workflows/ai-agents.js.map +7 -0
- package/dist/modules/workflows/ai-tools/authoring-pack.js +582 -0
- package/dist/modules/workflows/ai-tools/authoring-pack.js.map +7 -0
- package/dist/modules/workflows/ai-tools/types.js +43 -0
- package/dist/modules/workflows/ai-tools/types.js.map +7 -0
- package/dist/modules/workflows/ai-tools.js +10 -0
- package/dist/modules/workflows/ai-tools.js.map +7 -0
- package/dist/modules/workflows/api/command-settings/route.js +137 -0
- package/dist/modules/workflows/api/command-settings/route.js.map +7 -0
- package/dist/modules/workflows/api/commands/route.js +72 -0
- package/dist/modules/workflows/api/commands/route.js.map +7 -0
- package/dist/modules/workflows/api/definitions/[id]/callers/route.js +76 -0
- package/dist/modules/workflows/api/definitions/[id]/callers/route.js.map +7 -0
- package/dist/modules/workflows/api/definitions/[id]/context-schema/route.js +134 -0
- package/dist/modules/workflows/api/definitions/[id]/context-schema/route.js.map +7 -0
- package/dist/modules/workflows/api/definitions/[id]/customize/route.js +5 -1
- package/dist/modules/workflows/api/definitions/[id]/customize/route.js.map +2 -2
- package/dist/modules/workflows/api/definitions/[id]/draft/route.js +286 -0
- package/dist/modules/workflows/api/definitions/[id]/draft/route.js.map +7 -0
- package/dist/modules/workflows/api/definitions/[id]/publish/route.js +207 -0
- package/dist/modules/workflows/api/definitions/[id]/publish/route.js.map +7 -0
- package/dist/modules/workflows/api/definitions/[id]/reset-to-code/route.js +5 -0
- package/dist/modules/workflows/api/definitions/[id]/reset-to-code/route.js.map +2 -2
- package/dist/modules/workflows/api/definitions/[id]/route.js +93 -9
- package/dist/modules/workflows/api/definitions/[id]/route.js.map +3 -3
- package/dist/modules/workflows/api/definitions/[id]/test-step/route.js +210 -0
- package/dist/modules/workflows/api/definitions/[id]/test-step/route.js.map +7 -0
- package/dist/modules/workflows/api/definitions/generate/route.js +233 -0
- package/dist/modules/workflows/api/definitions/generate/route.js.map +7 -0
- package/dist/modules/workflows/api/definitions/route.js +61 -113
- package/dist/modules/workflows/api/definitions/route.js.map +2 -2
- package/dist/modules/workflows/api/definitions/serialize.js +9 -0
- package/dist/modules/workflows/api/definitions/serialize.js.map +2 -2
- package/dist/modules/workflows/api/endpoints/route.js +69 -0
- package/dist/modules/workflows/api/endpoints/route.js.map +7 -0
- package/dist/modules/workflows/api/functions/route.js +73 -0
- package/dist/modules/workflows/api/functions/route.js.map +7 -0
- package/dist/modules/workflows/api/grantable-features/route.js +75 -0
- package/dist/modules/workflows/api/grantable-features/route.js.map +7 -0
- package/dist/modules/workflows/api/instances/[id]/context/route.js +180 -0
- package/dist/modules/workflows/api/instances/[id]/context/route.js.map +7 -0
- package/dist/modules/workflows/api/instances/[id]/rerun-step/route.js +184 -0
- package/dist/modules/workflows/api/instances/[id]/rerun-step/route.js.map +7 -0
- package/dist/modules/workflows/api/instances/[id]/retry/route.js +12 -2
- package/dist/modules/workflows/api/instances/[id]/retry/route.js.map +2 -2
- package/dist/modules/workflows/api/instances/[id]/step-through/route.js +148 -0
- package/dist/modules/workflows/api/instances/[id]/step-through/route.js.map +7 -0
- package/dist/modules/workflows/api/instances/[id]/steps/route.js +123 -0
- package/dist/modules/workflows/api/instances/[id]/steps/route.js.map +7 -0
- package/dist/modules/workflows/api/instances/[id]/would-do/route.js +172 -0
- package/dist/modules/workflows/api/instances/[id]/would-do/route.js.map +7 -0
- package/dist/modules/workflows/api/instances/bulk-replay/route.js +117 -0
- package/dist/modules/workflows/api/instances/bulk-replay/route.js.map +7 -0
- package/dist/modules/workflows/api/instances/failure-queue/route.js +165 -0
- package/dist/modules/workflows/api/instances/failure-queue/route.js.map +7 -0
- package/dist/modules/workflows/api/instances/route.js +94 -3
- package/dist/modules/workflows/api/instances/route.js.map +2 -2
- package/dist/modules/workflows/api/metrics/definitions/route.js +188 -0
- package/dist/modules/workflows/api/metrics/definitions/route.js.map +7 -0
- package/dist/modules/workflows/api/openapi.js +415 -4
- package/dist/modules/workflows/api/openapi.js.map +2 -2
- package/dist/modules/workflows/api/portal/tasks/[id]/complete/route.js +132 -0
- package/dist/modules/workflows/api/portal/tasks/[id]/complete/route.js.map +7 -0
- package/dist/modules/workflows/api/portal/tasks/[id]/route.js +97 -0
- package/dist/modules/workflows/api/portal/tasks/[id]/route.js.map +7 -0
- package/dist/modules/workflows/api/portal/tasks/route.js +126 -0
- package/dist/modules/workflows/api/portal/tasks/route.js.map +7 -0
- package/dist/modules/workflows/api/rule-usage/route.js +80 -0
- package/dist/modules/workflows/api/rule-usage/route.js.map +7 -0
- package/dist/modules/workflows/api/task-settings/route.js +107 -0
- package/dist/modules/workflows/api/task-settings/route.js.map +7 -0
- package/dist/modules/workflows/api/tasks/[id]/claim/route.js +27 -16
- package/dist/modules/workflows/api/tasks/[id]/claim/route.js.map +2 -2
- package/dist/modules/workflows/api/tasks/[id]/complete/route.js +40 -16
- package/dist/modules/workflows/api/tasks/[id]/complete/route.js.map +2 -2
- package/dist/modules/workflows/api/tasks/[id]/reassign/route.js +150 -0
- package/dist/modules/workflows/api/tasks/[id]/reassign/route.js.map +7 -0
- package/dist/modules/workflows/api/tasks/[id]/route.js +39 -6
- package/dist/modules/workflows/api/tasks/[id]/route.js.map +2 -2
- package/dist/modules/workflows/api/tasks/[id]/unclaim/route.js +100 -0
- package/dist/modules/workflows/api/tasks/[id]/unclaim/route.js.map +7 -0
- package/dist/modules/workflows/api/tasks/route.js +37 -6
- package/dist/modules/workflows/api/tasks/route.js.map +2 -2
- package/dist/modules/workflows/api/tasks/serialize.js +83 -0
- package/dist/modules/workflows/api/tasks/serialize.js.map +7 -0
- package/dist/modules/workflows/api/templates/route.js +69 -0
- package/dist/modules/workflows/api/templates/route.js.map +7 -0
- package/dist/modules/workflows/api/work-inbox/next/route.js +129 -0
- package/dist/modules/workflows/api/work-inbox/next/route.js.map +7 -0
- package/dist/modules/workflows/api/work-inbox/route.js +119 -0
- package/dist/modules/workflows/api/work-inbox/route.js.map +7 -0
- package/dist/modules/workflows/backend/config/workflows/page.js +10 -0
- package/dist/modules/workflows/backend/config/workflows/page.js.map +7 -0
- package/dist/modules/workflows/backend/config/workflows/page.meta.js +35 -0
- package/dist/modules/workflows/backend/config/workflows/page.meta.js.map +7 -0
- package/dist/modules/workflows/backend/definitions/[id]/page.js +6 -271
- package/dist/modules/workflows/backend/definitions/[id]/page.js.map +3 -3
- package/dist/modules/workflows/backend/definitions/create/page.js +7 -56
- package/dist/modules/workflows/backend/definitions/create/page.js.map +2 -2
- package/dist/modules/workflows/backend/definitions/create/page.meta.js +1 -1
- package/dist/modules/workflows/backend/definitions/create/page.meta.js.map +2 -2
- package/dist/modules/workflows/backend/definitions/page.js +131 -51
- package/dist/modules/workflows/backend/definitions/page.js.map +2 -2
- package/dist/modules/workflows/backend/definitions/visual-editor/page.js +2606 -677
- package/dist/modules/workflows/backend/definitions/visual-editor/page.js.map +3 -3
- package/dist/modules/workflows/backend/instances/[id]/page.js +532 -421
- package/dist/modules/workflows/backend/instances/[id]/page.js.map +2 -2
- package/dist/modules/workflows/backend/instances/[id]/page.meta.js +1 -1
- package/dist/modules/workflows/backend/instances/[id]/page.meta.js.map +1 -1
- package/dist/modules/workflows/backend/instances/failure-queue/page.js +211 -0
- package/dist/modules/workflows/backend/instances/failure-queue/page.js.map +7 -0
- package/dist/modules/workflows/backend/instances/failure-queue/page.meta.js +20 -0
- package/dist/modules/workflows/backend/instances/failure-queue/page.meta.js.map +7 -0
- package/dist/modules/workflows/backend/instances/page.js +159 -22
- package/dist/modules/workflows/backend/instances/page.js.map +2 -2
- package/dist/modules/workflows/backend/instances/page.meta.js +1 -1
- package/dist/modules/workflows/backend/instances/page.meta.js.map +1 -1
- package/dist/modules/workflows/backend/tasks/[id]/page.js +553 -392
- package/dist/modules/workflows/backend/tasks/[id]/page.js.map +3 -3
- package/dist/modules/workflows/backend/tasks/page.js +8 -250
- package/dist/modules/workflows/backend/tasks/page.js.map +2 -2
- package/dist/modules/workflows/backend/tasks/page.meta.js +1 -0
- package/dist/modules/workflows/backend/tasks/page.meta.js.map +2 -2
- package/dist/modules/workflows/backend/work-inbox/page.js +399 -0
- package/dist/modules/workflows/backend/work-inbox/page.js.map +7 -0
- package/dist/modules/workflows/backend/work-inbox/page.meta.js +19 -0
- package/dist/modules/workflows/backend/work-inbox/page.meta.js.map +7 -0
- package/dist/modules/workflows/cli.js +1 -1
- package/dist/modules/workflows/cli.js.map +2 -2
- package/dist/modules/workflows/commands/tasks.js +81 -0
- package/dist/modules/workflows/commands/tasks.js.map +7 -0
- package/dist/modules/workflows/components/ActivitiesEditor.js +281 -287
- package/dist/modules/workflows/components/ActivitiesEditor.js.map +2 -2
- package/dist/modules/workflows/components/ActivityEditDialog.js +220 -0
- package/dist/modules/workflows/components/ActivityEditDialog.js.map +7 -0
- package/dist/modules/workflows/components/AgentSelector.js +115 -0
- package/dist/modules/workflows/components/AgentSelector.js.map +7 -0
- package/dist/modules/workflows/components/AnnotationEditDialog.js +110 -0
- package/dist/modules/workflows/components/AnnotationEditDialog.js.map +7 -0
- package/dist/modules/workflows/components/BusinessRuleUsagePanel.js +71 -0
- package/dist/modules/workflows/components/BusinessRuleUsagePanel.js.map +7 -0
- package/dist/modules/workflows/components/BusinessRulesSelector.js +151 -93
- package/dist/modules/workflows/components/BusinessRulesSelector.js.map +2 -2
- package/dist/modules/workflows/components/ConfigJsonTextarea.js +85 -0
- package/dist/modules/workflows/components/ConfigJsonTextarea.js.map +7 -0
- package/dist/modules/workflows/components/ContextSchemaEditor.js +150 -0
- package/dist/modules/workflows/components/ContextSchemaEditor.js.map +7 -0
- package/dist/modules/workflows/components/DefinitionErrorHandlerField.js +102 -0
- package/dist/modules/workflows/components/DefinitionErrorHandlerField.js.map +7 -0
- package/dist/modules/workflows/components/DefinitionMetadataDrawer.js +377 -0
- package/dist/modules/workflows/components/DefinitionMetadataDrawer.js.map +7 -0
- package/dist/modules/workflows/components/DefinitionMetricsCells.js +132 -0
- package/dist/modules/workflows/components/DefinitionMetricsCells.js.map +7 -0
- package/dist/modules/workflows/components/DefinitionTriggersEditor.js +307 -216
- package/dist/modules/workflows/components/DefinitionTriggersEditor.js.map +2 -2
- package/dist/modules/workflows/components/EdgeEditDialog.js +11 -18
- package/dist/modules/workflows/components/EdgeEditDialog.js.map +2 -2
- package/dist/modules/workflows/components/EdgeEditDialogCrudForm.js +112 -72
- package/dist/modules/workflows/components/EdgeEditDialogCrudForm.js.map +2 -2
- package/dist/modules/workflows/components/InputDataPanel.js +128 -0
- package/dist/modules/workflows/components/InputDataPanel.js.map +7 -0
- package/dist/modules/workflows/components/InspectorPanel.js +161 -0
- package/dist/modules/workflows/components/InspectorPanel.js.map +7 -0
- package/dist/modules/workflows/components/NodeEditDialog.js +363 -41
- package/dist/modules/workflows/components/NodeEditDialog.js.map +2 -2
- package/dist/modules/workflows/components/NodeEditDialogCrudForm.js +714 -159
- package/dist/modules/workflows/components/NodeEditDialogCrudForm.js.map +2 -2
- package/dist/modules/workflows/components/StepsEditor.js.map +2 -2
- package/dist/modules/workflows/components/TemplateGalleryDialog.js +148 -0
- package/dist/modules/workflows/components/TemplateGalleryDialog.js.map +7 -0
- package/dist/modules/workflows/components/TransitionsEditor.js +80 -74
- package/dist/modules/workflows/components/TransitionsEditor.js.map +2 -2
- package/dist/modules/workflows/components/TriggersDialog.js +53 -0
- package/dist/modules/workflows/components/TriggersDialog.js.map +7 -0
- package/dist/modules/workflows/components/TriggersEditor.js +331 -0
- package/dist/modules/workflows/components/TriggersEditor.js.map +7 -0
- package/dist/modules/workflows/components/WorkflowAiDraftDialog.js +278 -0
- package/dist/modules/workflows/components/WorkflowAiDraftDialog.js.map +7 -0
- package/dist/modules/workflows/components/WorkflowCodeView.js +173 -0
- package/dist/modules/workflows/components/WorkflowCodeView.js.map +7 -0
- package/dist/modules/workflows/components/WorkflowCommandPalette.js +62 -0
- package/dist/modules/workflows/components/WorkflowCommandPalette.js.map +7 -0
- package/dist/modules/workflows/components/WorkflowCompensationGhostEdge.js +70 -0
- package/dist/modules/workflows/components/WorkflowCompensationGhostEdge.js.map +7 -0
- package/dist/modules/workflows/components/WorkflowDataMappingEdge.js +36 -0
- package/dist/modules/workflows/components/WorkflowDataMappingEdge.js.map +7 -0
- package/dist/modules/workflows/components/WorkflowGraph.js +4 -2
- package/dist/modules/workflows/components/WorkflowGraph.js.map +2 -2
- package/dist/modules/workflows/components/WorkflowGraphImpl.js +324 -86
- package/dist/modules/workflows/components/WorkflowGraphImpl.js.map +3 -3
- package/dist/modules/workflows/components/WorkflowIconPicker.js +109 -0
- package/dist/modules/workflows/components/WorkflowIconPicker.js.map +7 -0
- package/dist/modules/workflows/components/WorkflowLegend.js +45 -29
- package/dist/modules/workflows/components/WorkflowLegend.js.map +2 -2
- package/dist/modules/workflows/components/WorkflowNodeCard.js +221 -22
- package/dist/modules/workflows/components/WorkflowNodeCard.js.map +2 -2
- package/dist/modules/workflows/components/WorkflowRouteChips.js +111 -0
- package/dist/modules/workflows/components/WorkflowRouteChips.js.map +7 -0
- package/dist/modules/workflows/components/WorkflowSelector.js +108 -88
- package/dist/modules/workflows/components/WorkflowSelector.js.map +2 -2
- package/dist/modules/workflows/components/WorkflowTransitionEdge.js +61 -11
- package/dist/modules/workflows/components/WorkflowTransitionEdge.js.map +2 -2
- package/dist/modules/workflows/components/WorkflowTransitionLabel.js +15 -5
- package/dist/modules/workflows/components/WorkflowTransitionLabel.js.map +2 -2
- package/dist/modules/workflows/components/fields/ActivityArrayEditor.js +88 -21
- package/dist/modules/workflows/components/fields/ActivityArrayEditor.js.map +2 -2
- package/dist/modules/workflows/components/fields/ActivityConfigFields.js +615 -0
- package/dist/modules/workflows/components/fields/ActivityConfigFields.js.map +7 -0
- package/dist/modules/workflows/components/fields/ActivityTestPanel.js +191 -0
- package/dist/modules/workflows/components/fields/ActivityTestPanel.js.map +7 -0
- package/dist/modules/workflows/components/fields/AgentInvokeConfigField.js +488 -0
- package/dist/modules/workflows/components/fields/AgentInvokeConfigField.js.map +7 -0
- package/dist/modules/workflows/components/fields/AgentReviewOnBreachField.js +61 -0
- package/dist/modules/workflows/components/fields/AgentReviewOnBreachField.js.map +7 -0
- package/dist/modules/workflows/components/fields/BranchingRoutesEditor.js +227 -0
- package/dist/modules/workflows/components/fields/BranchingRoutesEditor.js.map +7 -0
- package/dist/modules/workflows/components/fields/BusinessRuleConditionsEditor.js +37 -4
- package/dist/modules/workflows/components/fields/BusinessRuleConditionsEditor.js.map +2 -2
- package/dist/modules/workflows/components/fields/CommandPicker.js +111 -0
- package/dist/modules/workflows/components/fields/CommandPicker.js.map +7 -0
- package/dist/modules/workflows/components/fields/EndpointPicker.js +235 -0
- package/dist/modules/workflows/components/fields/EndpointPicker.js.map +7 -0
- package/dist/modules/workflows/components/fields/FormFieldArrayEditor.js +2 -2
- package/dist/modules/workflows/components/fields/FormFieldArrayEditor.js.map +2 -2
- package/dist/modules/workflows/components/fields/FunctionPicker.js +55 -0
- package/dist/modules/workflows/components/fields/FunctionPicker.js.map +7 -0
- package/dist/modules/workflows/components/fields/MappingArrayEditor.js +38 -15
- package/dist/modules/workflows/components/fields/MappingArrayEditor.js.map +2 -2
- package/dist/modules/workflows/components/fields/PortFieldArrayEditor.js +206 -0
- package/dist/modules/workflows/components/fields/PortFieldArrayEditor.js.map +7 -0
- package/dist/modules/workflows/components/fields/RolesMultiSelect.js +53 -0
- package/dist/modules/workflows/components/fields/RolesMultiSelect.js.map +7 -0
- package/dist/modules/workflows/components/fields/RouteOrderEditor.js +130 -0
- package/dist/modules/workflows/components/fields/RouteOrderEditor.js.map +7 -0
- package/dist/modules/workflows/components/fields/SchemaBuilderDialog.js +104 -0
- package/dist/modules/workflows/components/fields/SchemaBuilderDialog.js.map +7 -0
- package/dist/modules/workflows/components/fields/StartPreConditionsEditor.js +2 -2
- package/dist/modules/workflows/components/fields/StartPreConditionsEditor.js.map +2 -2
- package/dist/modules/workflows/components/fields/TaskAssignmentField.js +210 -0
- package/dist/modules/workflows/components/fields/TaskAssignmentField.js.map +7 -0
- package/dist/modules/workflows/components/fields/TaskDeadlineFields.js +126 -0
- package/dist/modules/workflows/components/fields/TaskDeadlineFields.js.map +7 -0
- package/dist/modules/workflows/components/fields/TaskDecisionsField.js +218 -0
- package/dist/modules/workflows/components/fields/TaskDecisionsField.js.map +7 -0
- package/dist/modules/workflows/components/fields/TaskEntityBindingsField.js +114 -0
- package/dist/modules/workflows/components/fields/TaskEntityBindingsField.js.map +7 -0
- package/dist/modules/workflows/components/fields/TemplateTextControl.js +64 -0
- package/dist/modules/workflows/components/fields/TemplateTextControl.js.map +7 -0
- package/dist/modules/workflows/components/fields/VariablePickerButton.js +121 -0
- package/dist/modules/workflows/components/fields/VariablePickerButton.js.map +7 -0
- package/dist/modules/workflows/components/fields/ledgerDropTarget.js +35 -0
- package/dist/modules/workflows/components/fields/ledgerDropTarget.js.map +7 -0
- package/dist/modules/workflows/components/fields/useActivityTypeOptions.js +16 -0
- package/dist/modules/workflows/components/fields/useActivityTypeOptions.js.map +7 -0
- package/dist/modules/workflows/components/formConfig.js +39 -10
- package/dist/modules/workflows/components/formConfig.js.map +2 -2
- package/dist/modules/workflows/components/mobile/MobileDefinitionDetail.js.map +2 -2
- package/dist/modules/workflows/components/mobile/MobileMetadataSheet.js.map +2 -2
- package/dist/modules/workflows/components/mobile/MobileTaskForm.js +29 -2
- package/dist/modules/workflows/components/mobile/MobileTaskForm.js.map +2 -2
- package/dist/modules/workflows/components/mobile/MobileVisualEditor.js +64 -65
- package/dist/modules/workflows/components/mobile/MobileVisualEditor.js.map +2 -2
- package/dist/modules/workflows/components/nodes/AnnotationGroupNode.js +64 -0
- package/dist/modules/workflows/components/nodes/AnnotationGroupNode.js.map +7 -0
- package/dist/modules/workflows/components/nodes/AutomatedNode.js +24 -16
- package/dist/modules/workflows/components/nodes/AutomatedNode.js.map +2 -2
- package/dist/modules/workflows/components/nodes/EndNode.js +13 -12
- package/dist/modules/workflows/components/nodes/EndNode.js.map +2 -2
- package/dist/modules/workflows/components/nodes/ErrorOutputHandle.js +29 -0
- package/dist/modules/workflows/components/nodes/ErrorOutputHandle.js.map +7 -0
- package/dist/modules/workflows/components/nodes/IfElseNode.js +51 -0
- package/dist/modules/workflows/components/nodes/IfElseNode.js.map +7 -0
- package/dist/modules/workflows/components/nodes/InvokeAgentNode.js +122 -0
- package/dist/modules/workflows/components/nodes/InvokeAgentNode.js.map +7 -0
- package/dist/modules/workflows/components/nodes/NodeOutcomeRows.js +100 -0
- package/dist/modules/workflows/components/nodes/NodeOutcomeRows.js.map +7 -0
- package/dist/modules/workflows/components/nodes/ParallelForkNode.js +18 -14
- package/dist/modules/workflows/components/nodes/ParallelForkNode.js.map +2 -2
- package/dist/modules/workflows/components/nodes/ParallelJoinNode.js +18 -14
- package/dist/modules/workflows/components/nodes/ParallelJoinNode.js.map +2 -2
- package/dist/modules/workflows/components/nodes/StartNode.js +66 -15
- package/dist/modules/workflows/components/nodes/StartNode.js.map +2 -2
- package/dist/modules/workflows/components/nodes/StickyNoteNode.js +54 -0
- package/dist/modules/workflows/components/nodes/StickyNoteNode.js.map +7 -0
- package/dist/modules/workflows/components/nodes/SubWorkflowNode.js +107 -41
- package/dist/modules/workflows/components/nodes/SubWorkflowNode.js.map +2 -2
- package/dist/modules/workflows/components/nodes/SwitchNode.js +51 -0
- package/dist/modules/workflows/components/nodes/SwitchNode.js.map +7 -0
- package/dist/modules/workflows/components/nodes/TriggerCap.js +65 -0
- package/dist/modules/workflows/components/nodes/TriggerCap.js.map +7 -0
- package/dist/modules/workflows/components/nodes/TriggerNode.js +111 -0
- package/dist/modules/workflows/components/nodes/TriggerNode.js.map +7 -0
- package/dist/modules/workflows/components/nodes/UserTaskNode.js +43 -17
- package/dist/modules/workflows/components/nodes/UserTaskNode.js.map +2 -2
- package/dist/modules/workflows/components/nodes/WaitForConditionNode.js +53 -0
- package/dist/modules/workflows/components/nodes/WaitForConditionNode.js.map +7 -0
- package/dist/modules/workflows/components/nodes/WaitForSignalNode.js +21 -15
- package/dist/modules/workflows/components/nodes/WaitForSignalNode.js.map +2 -2
- package/dist/modules/workflows/components/nodes/WaitForTimerNode.js +21 -15
- package/dist/modules/workflows/components/nodes/WaitForTimerNode.js.map +2 -2
- package/dist/modules/workflows/components/nodes/index.js +14 -0
- package/dist/modules/workflows/components/nodes/index.js.map +2 -2
- package/dist/modules/workflows/components/portal/PortalTaskForm.js +196 -0
- package/dist/modules/workflows/components/portal/PortalTaskForm.js.map +7 -0
- package/dist/modules/workflows/components/run/AgentActivityPanel.js +22 -0
- package/dist/modules/workflows/components/run/AgentActivityPanel.js.map +7 -0
- package/dist/modules/workflows/components/run/RerunStepDialog.js +106 -0
- package/dist/modules/workflows/components/run/RerunStepDialog.js.map +7 -0
- package/dist/modules/workflows/components/run/RunEventBadge.js +30 -0
- package/dist/modules/workflows/components/run/RunEventBadge.js.map +7 -0
- package/dist/modules/workflows/components/run/RunGantt.js +130 -0
- package/dist/modules/workflows/components/run/RunGantt.js.map +7 -0
- package/dist/modules/workflows/components/run/RunStatusBadge.js +82 -0
- package/dist/modules/workflows/components/run/RunStatusBadge.js.map +7 -0
- package/dist/modules/workflows/components/run/RunStepInspector.js +116 -0
- package/dist/modules/workflows/components/run/RunStepInspector.js.map +7 -0
- package/dist/modules/workflows/components/run/WouldDoReport.js +52 -0
- package/dist/modules/workflows/components/run/WouldDoReport.js.map +7 -0
- package/dist/modules/workflows/components/run/useAgentLabels.js +28 -0
- package/dist/modules/workflows/components/run/useAgentLabels.js.map +7 -0
- package/dist/modules/workflows/components/run/useLastRunOverlay.js +89 -0
- package/dist/modules/workflows/components/run/useLastRunOverlay.js.map +7 -0
- package/dist/modules/workflows/components/run/useLiveAgentActions.js +41 -0
- package/dist/modules/workflows/components/run/useLiveAgentActions.js.map +7 -0
- package/dist/modules/workflows/components/run/useLiveRunUpdates.js +57 -0
- package/dist/modules/workflows/components/run/useLiveRunUpdates.js.map +7 -0
- package/dist/modules/workflows/components/settings/CommandSettingsPageClient.js +156 -0
- package/dist/modules/workflows/components/settings/CommandSettingsPageClient.js.map +7 -0
- package/dist/modules/workflows/components/work-inbox/EntityContextPanel.js +72 -0
- package/dist/modules/workflows/components/work-inbox/EntityContextPanel.js.map +7 -0
- package/dist/modules/workflows/components/work-inbox/ReassignTaskDialog.js +156 -0
- package/dist/modules/workflows/components/work-inbox/ReassignTaskDialog.js.map +7 -0
- package/dist/modules/workflows/components/work-inbox/StatusChip.js +46 -0
- package/dist/modules/workflows/components/work-inbox/StatusChip.js.map +7 -0
- package/dist/modules/workflows/components/work-inbox/TaskActionNotice.js +53 -0
- package/dist/modules/workflows/components/work-inbox/TaskActionNotice.js.map +7 -0
- package/dist/modules/workflows/components/work-inbox/TaskFormFields.js +261 -0
- package/dist/modules/workflows/components/work-inbox/TaskFormFields.js.map +7 -0
- package/dist/modules/workflows/components/work-inbox/WorkInboxEmptyState.js +27 -0
- package/dist/modules/workflows/components/work-inbox/WorkInboxEmptyState.js.map +7 -0
- package/dist/modules/workflows/data/activity-config-schemas.js +191 -0
- package/dist/modules/workflows/data/activity-config-schemas.js.map +7 -0
- package/dist/modules/workflows/data/activity-config-warnings.js +42 -0
- package/dist/modules/workflows/data/activity-config-warnings.js.map +7 -0
- package/dist/modules/workflows/data/branching-route-warnings.js +65 -0
- package/dist/modules/workflows/data/branching-route-warnings.js.map +7 -0
- package/dist/modules/workflows/data/entities.js +144 -4
- package/dist/modules/workflows/data/entities.js.map +2 -2
- package/dist/modules/workflows/data/metrics-validators.js +35 -0
- package/dist/modules/workflows/data/metrics-validators.js.map +7 -0
- package/dist/modules/workflows/data/task-primitives.js +14 -0
- package/dist/modules/workflows/data/task-primitives.js.map +7 -0
- package/dist/modules/workflows/data/validators.js +504 -61
- package/dist/modules/workflows/data/validators.js.map +3 -3
- package/dist/modules/workflows/di.js +16 -1
- package/dist/modules/workflows/di.js.map +2 -2
- package/dist/modules/workflows/events.js +66 -8
- package/dist/modules/workflows/events.js.map +2 -2
- package/dist/modules/workflows/examples/oze-residential-install-60-nodes.json +1545 -0
- package/dist/modules/workflows/examples/sales-pipeline-definition.json +35 -35
- package/dist/modules/workflows/examples/templates/lead-to-install.json +160 -0
- package/dist/modules/workflows/examples/templates/order-approval.json +230 -0
- package/dist/modules/workflows/examples/templates/task-escalation.json +110 -0
- package/dist/modules/workflows/examples/templates/webhook-integration.json +113 -0
- package/dist/modules/workflows/extension-points.js +1 -1
- package/dist/modules/workflows/extension-points.js.map +2 -2
- package/dist/modules/workflows/frontend/[orgSlug]/portal/tasks/[id]/page.js +144 -0
- package/dist/modules/workflows/frontend/[orgSlug]/portal/tasks/[id]/page.js.map +7 -0
- package/dist/modules/workflows/frontend/[orgSlug]/portal/tasks/[id]/page.meta.js +12 -0
- package/dist/modules/workflows/frontend/[orgSlug]/portal/tasks/[id]/page.meta.js.map +7 -0
- package/dist/modules/workflows/frontend/[orgSlug]/portal/tasks/page.js +114 -0
- package/dist/modules/workflows/frontend/[orgSlug]/portal/tasks/page.js.map +7 -0
- package/dist/modules/workflows/frontend/[orgSlug]/portal/tasks/page.meta.js +18 -0
- package/dist/modules/workflows/frontend/[orgSlug]/portal/tasks/page.meta.js.map +7 -0
- package/dist/modules/workflows/lib/activity-executor.js +505 -137
- package/dist/modules/workflows/lib/activity-executor.js.map +3 -3
- package/dist/modules/workflows/lib/activity-queue-types.js +3 -1
- package/dist/modules/workflows/lib/activity-queue-types.js.map +2 -2
- package/dist/modules/workflows/lib/activity-registry-bootstrap.js +2 -0
- package/dist/modules/workflows/lib/activity-registry-bootstrap.js.map +7 -0
- package/dist/modules/workflows/lib/activity-registry.js +27 -0
- package/dist/modules/workflows/lib/activity-registry.js.map +7 -0
- package/dist/modules/workflows/lib/activity-types.js +291 -0
- package/dist/modules/workflows/lib/activity-types.js.map +7 -0
- package/dist/modules/workflows/lib/activity-worker-handler.js +456 -32
- package/dist/modules/workflows/lib/activity-worker-handler.js.map +3 -3
- package/dist/modules/workflows/lib/advanced-config.js +31 -0
- package/dist/modules/workflows/lib/advanced-config.js.map +7 -0
- package/dist/modules/workflows/lib/agent-disposition-task.js +198 -0
- package/dist/modules/workflows/lib/agent-disposition-task.js.map +7 -0
- package/dist/modules/workflows/lib/agent-outcome-paths.js +82 -0
- package/dist/modules/workflows/lib/agent-outcome-paths.js.map +7 -0
- package/dist/modules/workflows/lib/agent-result-mapping.js +54 -0
- package/dist/modules/workflows/lib/agent-result-mapping.js.map +7 -0
- package/dist/modules/workflows/lib/agent-review-inspector.js +61 -0
- package/dist/modules/workflows/lib/agent-review-inspector.js.map +7 -0
- package/dist/modules/workflows/lib/agent-review.js +66 -0
- package/dist/modules/workflows/lib/agent-review.js.map +7 -0
- package/dist/modules/workflows/lib/ai-authoring.js +155 -0
- package/dist/modules/workflows/lib/ai-authoring.js.map +7 -0
- package/dist/modules/workflows/lib/ai-draft-runner.js +43 -0
- package/dist/modules/workflows/lib/ai-draft-runner.js.map +7 -0
- package/dist/modules/workflows/lib/annotation-events.js +10 -0
- package/dist/modules/workflows/lib/annotation-events.js.map +7 -0
- package/dist/modules/workflows/lib/branching-routes.js +182 -0
- package/dist/modules/workflows/lib/branching-routes.js.map +7 -0
- package/dist/modules/workflows/lib/breach-routing.js +50 -0
- package/dist/modules/workflows/lib/breach-routing.js.map +7 -0
- package/dist/modules/workflows/lib/bulk-replay.js +101 -0
- package/dist/modules/workflows/lib/bulk-replay.js.map +7 -0
- package/dist/modules/workflows/lib/business-rule-usage.js +91 -0
- package/dist/modules/workflows/lib/business-rule-usage.js.map +7 -0
- package/dist/modules/workflows/lib/caller-graph.js +53 -0
- package/dist/modules/workflows/lib/caller-graph.js.map +7 -0
- package/dist/modules/workflows/lib/code-view-apply.js +86 -0
- package/dist/modules/workflows/lib/code-view-apply.js.map +7 -0
- package/dist/modules/workflows/lib/collect-validation-issues.js +164 -0
- package/dist/modules/workflows/lib/collect-validation-issues.js.map +7 -0
- package/dist/modules/workflows/lib/compensation-ghosts.js +72 -0
- package/dist/modules/workflows/lib/compensation-ghosts.js.map +7 -0
- package/dist/modules/workflows/lib/component-guard.js +7 -0
- package/dist/modules/workflows/lib/component-guard.js.map +7 -0
- package/dist/modules/workflows/lib/condition-handler.js +443 -0
- package/dist/modules/workflows/lib/condition-handler.js.map +7 -0
- package/dist/modules/workflows/lib/context-ledger.js +448 -0
- package/dist/modules/workflows/lib/context-ledger.js.map +7 -0
- package/dist/modules/workflows/lib/crud-form-dialogs-flag.js +8 -0
- package/dist/modules/workflows/lib/crud-form-dialogs-flag.js.map +7 -0
- package/dist/modules/workflows/lib/data-edge-mapping.js +63 -0
- package/dist/modules/workflows/lib/data-edge-mapping.js.map +7 -0
- package/dist/modules/workflows/lib/definition-context-schema.js +56 -0
- package/dist/modules/workflows/lib/definition-context-schema.js.map +7 -0
- package/dist/modules/workflows/lib/definition-edit-safety.js +123 -0
- package/dist/modules/workflows/lib/definition-edit-safety.js.map +7 -0
- package/dist/modules/workflows/lib/definition-error-body.js +33 -0
- package/dist/modules/workflows/lib/definition-error-body.js.map +7 -0
- package/dist/modules/workflows/lib/definition-evaluation.js +79 -0
- package/dist/modules/workflows/lib/definition-evaluation.js.map +7 -0
- package/dist/modules/workflows/lib/definition-grant.js +90 -0
- package/dist/modules/workflows/lib/definition-grant.js.map +7 -0
- package/dist/modules/workflows/lib/definition-json-locations.js +139 -0
- package/dist/modules/workflows/lib/definition-json-locations.js.map +7 -0
- package/dist/modules/workflows/lib/definition-payload.js +31 -0
- package/dist/modules/workflows/lib/definition-payload.js.map +7 -0
- package/dist/modules/workflows/lib/draft-restore.js +49 -0
- package/dist/modules/workflows/lib/draft-restore.js.map +7 -0
- package/dist/modules/workflows/lib/dry-run.js +106 -0
- package/dist/modules/workflows/lib/dry-run.js.map +7 -0
- package/dist/modules/workflows/lib/duration.js +66 -17
- package/dist/modules/workflows/lib/duration.js.map +2 -2
- package/dist/modules/workflows/lib/edge-reattachment.js +79 -0
- package/dist/modules/workflows/lib/edge-reattachment.js.map +7 -0
- package/dist/modules/workflows/lib/edgeFormTransforms.js +7 -11
- package/dist/modules/workflows/lib/edgeFormTransforms.js.map +2 -2
- package/dist/modules/workflows/lib/editor-annotations.js +195 -0
- package/dist/modules/workflows/lib/editor-annotations.js.map +7 -0
- package/dist/modules/workflows/lib/editor-commands.js +103 -0
- package/dist/modules/workflows/lib/editor-commands.js.map +7 -0
- package/dist/modules/workflows/lib/editor-history.js +51 -0
- package/dist/modules/workflows/lib/editor-history.js.map +7 -0
- package/dist/modules/workflows/lib/endpoint-catalog.js +181 -0
- package/dist/modules/workflows/lib/endpoint-catalog.js.map +7 -0
- package/dist/modules/workflows/lib/endpoint-path.js +90 -0
- package/dist/modules/workflows/lib/endpoint-path.js.map +7 -0
- package/dist/modules/workflows/lib/engine-version.js +42 -0
- package/dist/modules/workflows/lib/engine-version.js.map +7 -0
- package/dist/modules/workflows/lib/error-handler.js +132 -0
- package/dist/modules/workflows/lib/error-handler.js.map +7 -0
- package/dist/modules/workflows/lib/error-routing.js +104 -0
- package/dist/modules/workflows/lib/error-routing.js.map +7 -0
- package/dist/modules/workflows/lib/event-logger.js +23 -0
- package/dist/modules/workflows/lib/event-logger.js.map +2 -2
- package/dist/modules/workflows/lib/expression-refs.js +168 -0
- package/dist/modules/workflows/lib/expression-refs.js.map +7 -0
- package/dist/modules/workflows/lib/failure-grouping.js +62 -0
- package/dist/modules/workflows/lib/failure-grouping.js.map +7 -0
- package/dist/modules/workflows/lib/find-definition.js +1 -0
- package/dist/modules/workflows/lib/find-definition.js.map +2 -2
- package/dist/modules/workflows/lib/flow-logic-warnings.js +338 -0
- package/dist/modules/workflows/lib/flow-logic-warnings.js.map +7 -0
- package/dist/modules/workflows/lib/graph-utils.js +328 -77
- package/dist/modules/workflows/lib/graph-utils.js.map +2 -2
- package/dist/modules/workflows/lib/icon-search.js +32 -0
- package/dist/modules/workflows/lib/icon-search.js.map +7 -0
- package/dist/modules/workflows/lib/insert-at-cursor.js +26 -0
- package/dist/modules/workflows/lib/insert-at-cursor.js.map +7 -0
- package/dist/modules/workflows/lib/instance-date-filter.js +28 -0
- package/dist/modules/workflows/lib/instance-date-filter.js.map +7 -0
- package/dist/modules/workflows/lib/interpolation-pipeline.js +271 -0
- package/dist/modules/workflows/lib/interpolation-pipeline.js.map +7 -0
- package/dist/modules/workflows/lib/ledger-drag.js +28 -0
- package/dist/modules/workflows/lib/ledger-drag.js.map +7 -0
- package/dist/modules/workflows/lib/ledger-entry-display.js +66 -0
- package/dist/modules/workflows/lib/ledger-entry-display.js.map +7 -0
- package/dist/modules/workflows/lib/ledger-schema-flatten.js +82 -0
- package/dist/modules/workflows/lib/ledger-schema-flatten.js.map +7 -0
- package/dist/modules/workflows/lib/metrics/definition-metrics.js +110 -0
- package/dist/modules/workflows/lib/metrics/definition-metrics.js.map +7 -0
- package/dist/modules/workflows/lib/metrics/metrics-display.js +26 -0
- package/dist/modules/workflows/lib/metrics/metrics-display.js.map +7 -0
- package/dist/modules/workflows/lib/metrics/rollup-schedule.js +7 -0
- package/dist/modules/workflows/lib/metrics/rollup-schedule.js.map +7 -0
- package/dist/modules/workflows/lib/metrics/rollup-service.js +160 -0
- package/dist/modules/workflows/lib/metrics/rollup-service.js.map +7 -0
- package/dist/modules/workflows/lib/node-config-summary.js +128 -0
- package/dist/modules/workflows/lib/node-config-summary.js.map +7 -0
- package/dist/modules/workflows/lib/node-geometry.js +53 -0
- package/dist/modules/workflows/lib/node-geometry.js.map +7 -0
- package/dist/modules/workflows/lib/node-nudge.js +44 -0
- package/dist/modules/workflows/lib/node-nudge.js.map +7 -0
- package/dist/modules/workflows/lib/node-outcome-rows.js +88 -0
- package/dist/modules/workflows/lib/node-outcome-rows.js.map +7 -0
- package/dist/modules/workflows/lib/node-placement.js +55 -0
- package/dist/modules/workflows/lib/node-placement.js.map +7 -0
- package/dist/modules/workflows/lib/node-type-icons.js +54 -13
- package/dist/modules/workflows/lib/node-type-icons.js.map +2 -2
- package/dist/modules/workflows/lib/nodeFormTransforms.js +329 -19
- package/dist/modules/workflows/lib/nodeFormTransforms.js.map +2 -2
- package/dist/modules/workflows/lib/outcome-routing.js +158 -0
- package/dist/modules/workflows/lib/outcome-routing.js.map +7 -0
- package/dist/modules/workflows/lib/owned-definition.js +107 -0
- package/dist/modules/workflows/lib/owned-definition.js.map +7 -0
- package/dist/modules/workflows/lib/owned-node-changes.js +10 -0
- package/dist/modules/workflows/lib/owned-node-changes.js.map +7 -0
- package/dist/modules/workflows/lib/palette-drag.js +36 -0
- package/dist/modules/workflows/lib/palette-drag.js.map +7 -0
- package/dist/modules/workflows/lib/palette-drop.js +45 -0
- package/dist/modules/workflows/lib/palette-drop.js.map +7 -0
- package/dist/modules/workflows/lib/parallel-handler.js +57 -2
- package/dist/modules/workflows/lib/parallel-handler.js.map +2 -2
- package/dist/modules/workflows/lib/port-contract.js +54 -0
- package/dist/modules/workflows/lib/port-contract.js.map +7 -0
- package/dist/modules/workflows/lib/portal-task-access.js +89 -0
- package/dist/modules/workflows/lib/portal-task-access.js.map +7 -0
- package/dist/modules/workflows/lib/rerun-from-step.js +65 -0
- package/dist/modules/workflows/lib/rerun-from-step.js.map +7 -0
- package/dist/modules/workflows/lib/route-chip-events.js +23 -0
- package/dist/modules/workflows/lib/route-chip-events.js.map +7 -0
- package/dist/modules/workflows/lib/route-chips.js +91 -0
- package/dist/modules/workflows/lib/route-chips.js.map +7 -0
- package/dist/modules/workflows/lib/route-edge.js +17 -0
- package/dist/modules/workflows/lib/route-edge.js.map +7 -0
- package/dist/modules/workflows/lib/route-kinds.js +67 -0
- package/dist/modules/workflows/lib/route-kinds.js.map +7 -0
- package/dist/modules/workflows/lib/route-priority.js +104 -0
- package/dist/modules/workflows/lib/route-priority.js.map +7 -0
- package/dist/modules/workflows/lib/run-duration.js +44 -0
- package/dist/modules/workflows/lib/run-duration.js.map +7 -0
- package/dist/modules/workflows/lib/run-event-tone.js +25 -0
- package/dist/modules/workflows/lib/run-event-tone.js.map +7 -0
- package/dist/modules/workflows/lib/run-execution.js +305 -0
- package/dist/modules/workflows/lib/run-execution.js.map +7 -0
- package/dist/modules/workflows/lib/run-gantt.js +180 -0
- package/dist/modules/workflows/lib/run-gantt.js.map +7 -0
- package/dist/modules/workflows/lib/run-outcome-evidence.js +33 -0
- package/dist/modules/workflows/lib/run-outcome-evidence.js.map +7 -0
- package/dist/modules/workflows/lib/run-outcome.js +48 -0
- package/dist/modules/workflows/lib/run-outcome.js.map +7 -0
- package/dist/modules/workflows/lib/sample-resolver.js +71 -0
- package/dist/modules/workflows/lib/sample-resolver.js.map +7 -0
- package/dist/modules/workflows/lib/seeds.js +1 -1
- package/dist/modules/workflows/lib/seeds.js.map +2 -2
- package/dist/modules/workflows/lib/server-output-contract.js +65 -0
- package/dist/modules/workflows/lib/server-output-contract.js.map +7 -0
- package/dist/modules/workflows/lib/set-variable.js +47 -0
- package/dist/modules/workflows/lib/set-variable.js.map +7 -0
- package/dist/modules/workflows/lib/signal-handler.js +63 -4
- package/dist/modules/workflows/lib/signal-handler.js.map +2 -2
- package/dist/modules/workflows/lib/start-fixtures.js +42 -0
- package/dist/modules/workflows/lib/start-fixtures.js.map +7 -0
- package/dist/modules/workflows/lib/status-colors.js +153 -22
- package/dist/modules/workflows/lib/status-colors.js.map +2 -2
- package/dist/modules/workflows/lib/step-handler.js +529 -53
- package/dist/modules/workflows/lib/step-handler.js.map +3 -3
- package/dist/modules/workflows/lib/step-presentation.js +147 -0
- package/dist/modules/workflows/lib/step-presentation.js.map +7 -0
- package/dist/modules/workflows/lib/step-through.js +26 -0
- package/dist/modules/workflows/lib/step-through.js.map +7 -0
- package/dist/modules/workflows/lib/step-type-conversion.js +167 -0
- package/dist/modules/workflows/lib/step-type-conversion.js.map +7 -0
- package/dist/modules/workflows/lib/subgraph-clipboard.js +114 -0
- package/dist/modules/workflows/lib/subgraph-clipboard.js.map +7 -0
- package/dist/modules/workflows/lib/task-decision-context.js +38 -0
- package/dist/modules/workflows/lib/task-decision-context.js.map +7 -0
- package/dist/modules/workflows/lib/task-decisions.js +49 -0
- package/dist/modules/workflows/lib/task-decisions.js.map +7 -0
- package/dist/modules/workflows/lib/task-entity-access.js +62 -0
- package/dist/modules/workflows/lib/task-entity-access.js.map +7 -0
- package/dist/modules/workflows/lib/task-entity-aliases.js +39 -0
- package/dist/modules/workflows/lib/task-entity-aliases.js.map +7 -0
- package/dist/modules/workflows/lib/task-entity-types.js +36 -0
- package/dist/modules/workflows/lib/task-entity-types.js.map +7 -0
- package/dist/modules/workflows/lib/task-form-registry.js +33 -0
- package/dist/modules/workflows/lib/task-form-registry.js.map +7 -0
- package/dist/modules/workflows/lib/task-form-schema.js +75 -0
- package/dist/modules/workflows/lib/task-form-schema.js.map +7 -0
- package/dist/modules/workflows/lib/task-handler.js +251 -32
- package/dist/modules/workflows/lib/task-handler.js.map +2 -2
- package/dist/modules/workflows/lib/task-inspector-config.js +182 -0
- package/dist/modules/workflows/lib/task-inspector-config.js.map +7 -0
- package/dist/modules/workflows/lib/task-list-query.js +19 -0
- package/dist/modules/workflows/lib/task-list-query.js.map +7 -0
- package/dist/modules/workflows/lib/task-notifications.js +119 -0
- package/dist/modules/workflows/lib/task-notifications.js.map +7 -0
- package/dist/modules/workflows/lib/task-permission-settings.js +43 -0
- package/dist/modules/workflows/lib/task-permission-settings.js.map +7 -0
- package/dist/modules/workflows/lib/task-presets.js +35 -0
- package/dist/modules/workflows/lib/task-presets.js.map +7 -0
- package/dist/modules/workflows/lib/task-quick-action.js +45 -0
- package/dist/modules/workflows/lib/task-quick-action.js.map +7 -0
- package/dist/modules/workflows/lib/task-resolution.js +120 -0
- package/dist/modules/workflows/lib/task-resolution.js.map +7 -0
- package/dist/modules/workflows/lib/task-sla.js +357 -0
- package/dist/modules/workflows/lib/task-sla.js.map +7 -0
- package/dist/modules/workflows/lib/task-visibility-request.js +266 -0
- package/dist/modules/workflows/lib/task-visibility-request.js.map +7 -0
- package/dist/modules/workflows/lib/task-visibility.js +194 -0
- package/dist/modules/workflows/lib/task-visibility.js.map +7 -0
- package/dist/modules/workflows/lib/timer-handler.js +3 -1
- package/dist/modules/workflows/lib/timer-handler.js.map +2 -2
- package/dist/modules/workflows/lib/transition-handler.js +148 -20
- package/dist/modules/workflows/lib/transition-handler.js.map +2 -2
- package/dist/modules/workflows/lib/trigger-node.js +121 -0
- package/dist/modules/workflows/lib/trigger-node.js.map +7 -0
- package/dist/modules/workflows/lib/visual-editor-navigation.js +14 -0
- package/dist/modules/workflows/lib/visual-editor-navigation.js.map +7 -0
- package/dist/modules/workflows/lib/work-inbox/empty-state.js +52 -0
- package/dist/modules/workflows/lib/work-inbox/empty-state.js.map +7 -0
- package/dist/modules/workflows/lib/work-inbox/entity-links.js +63 -0
- package/dist/modules/workflows/lib/work-inbox/entity-links.js.map +7 -0
- package/dist/modules/workflows/lib/work-inbox/navigation.js +11 -0
- package/dist/modules/workflows/lib/work-inbox/navigation.js.map +7 -0
- package/dist/modules/workflows/lib/work-inbox/presentation.js +90 -0
- package/dist/modules/workflows/lib/work-inbox/presentation.js.map +7 -0
- package/dist/modules/workflows/lib/work-inbox/provider.js +118 -0
- package/dist/modules/workflows/lib/work-inbox/provider.js.map +7 -0
- package/dist/modules/workflows/lib/work-inbox/query.js +70 -0
- package/dist/modules/workflows/lib/work-inbox/query.js.map +7 -0
- package/dist/modules/workflows/lib/work-inbox/service.js +56 -0
- package/dist/modules/workflows/lib/work-inbox/service.js.map +7 -0
- package/dist/modules/workflows/lib/work-inbox/user-task-source.js +149 -0
- package/dist/modules/workflows/lib/work-inbox/user-task-source.js.map +7 -0
- package/dist/modules/workflows/lib/workflow-command-enablement.js +57 -0
- package/dist/modules/workflows/lib/workflow-command-enablement.js.map +7 -0
- package/dist/modules/workflows/lib/workflow-command-settings.js +54 -0
- package/dist/modules/workflows/lib/workflow-command-settings.js.map +7 -0
- package/dist/modules/workflows/lib/workflow-executor.js +658 -6
- package/dist/modules/workflows/lib/workflow-executor.js.map +2 -2
- package/dist/modules/workflows/lib/workflow-function-registry.js +40 -0
- package/dist/modules/workflows/lib/workflow-function-registry.js.map +7 -0
- package/dist/modules/workflows/lib/workflow-safe-commands.js +11 -1
- package/dist/modules/workflows/lib/workflow-safe-commands.js.map +2 -2
- package/dist/modules/workflows/lib/workflow-templates.js +69 -0
- package/dist/modules/workflows/lib/workflow-templates.js.map +7 -0
- package/dist/modules/workflows/migrations/Migration20260626214855_workflows.js +15 -0
- package/dist/modules/workflows/migrations/Migration20260626214855_workflows.js.map +7 -0
- package/dist/modules/workflows/migrations/Migration20260626222424_workflows.js +17 -0
- package/dist/modules/workflows/migrations/Migration20260626222424_workflows.js.map +7 -0
- package/dist/modules/workflows/migrations/Migration20260727074335_workflows.js +15 -0
- package/dist/modules/workflows/migrations/Migration20260727074335_workflows.js.map +7 -0
- package/dist/modules/workflows/migrations/Migration20260728104038_workflows.js +13 -0
- package/dist/modules/workflows/migrations/Migration20260728104038_workflows.js.map +7 -0
- package/dist/modules/workflows/migrations/Migration20260728163001_workflows.js +15 -0
- package/dist/modules/workflows/migrations/Migration20260728163001_workflows.js.map +7 -0
- package/dist/modules/workflows/migrations/Migration20260729061736_workflows.js +13 -0
- package/dist/modules/workflows/migrations/Migration20260729061736_workflows.js.map +7 -0
- package/dist/modules/workflows/migrations/Migration20260729192652_workflows.js +12 -0
- package/dist/modules/workflows/migrations/Migration20260729192652_workflows.js.map +7 -0
- package/dist/modules/workflows/migrations/Migration20260730085000_workflows.js +13 -0
- package/dist/modules/workflows/migrations/Migration20260730085000_workflows.js.map +7 -0
- package/dist/modules/workflows/migrations/Migration20260730092706_workflows.js +13 -0
- package/dist/modules/workflows/migrations/Migration20260730092706_workflows.js.map +7 -0
- package/dist/modules/workflows/notifications.js +38 -10
- package/dist/modules/workflows/notifications.js.map +2 -2
- package/dist/modules/workflows/setup.js +81 -1
- package/dist/modules/workflows/setup.js.map +2 -2
- package/dist/modules/workflows/subscribers/task-assigned-notification.js +19 -27
- package/dist/modules/workflows/subscribers/task-assigned-notification.js.map +2 -2
- package/dist/modules/workflows/subscribers/task-deadline-breached-notification.js +24 -0
- package/dist/modules/workflows/subscribers/task-deadline-breached-notification.js.map +7 -0
- package/dist/modules/workflows/subscribers/task-reminder-notification.js +24 -0
- package/dist/modules/workflows/subscribers/task-reminder-notification.js.map +7 -0
- package/dist/modules/workflows/widgets/injection/pending-work/widget.client.js +73 -0
- package/dist/modules/workflows/widgets/injection/pending-work/widget.client.js.map +7 -0
- package/dist/modules/workflows/widgets/injection/pending-work/widget.js +17 -0
- package/dist/modules/workflows/widgets/injection/pending-work/widget.js.map +7 -0
- package/dist/modules/workflows/widgets/injection-table.js +26 -0
- package/dist/modules/workflows/widgets/injection-table.js.map +2 -2
- package/dist/modules/workflows/workers/workflow-activities.worker.js +61 -39
- package/dist/modules/workflows/workers/workflow-activities.worker.js.map +2 -2
- package/dist/modules/workflows/workers/workflow-definition-metric-rollup.worker.js +40 -0
- package/dist/modules/workflows/workers/workflow-definition-metric-rollup.worker.js.map +7 -0
- package/dist/modules/workflows/workers/workflow-instance-bulk-replay.js +43 -0
- package/dist/modules/workflows/workers/workflow-instance-bulk-replay.js.map +7 -0
- package/dist/modules/workflows/workers/workflow-invoke-agent.worker.js +30 -0
- package/dist/modules/workflows/workers/workflow-invoke-agent.worker.js.map +7 -0
- package/generated/entities/action_log/index.ts +1 -0
- package/generated/entities/user/index.ts +1 -0
- package/generated/entities/user_task/index.ts +7 -0
- package/generated/entities/workflow_definition/index.ts +3 -0
- package/generated/entities/workflow_definition_draft/index.ts +11 -0
- package/generated/entities/workflow_definition_metric_rollup/index.ts +10 -0
- package/generated/entities/workflow_instance/index.ts +2 -0
- package/generated/entities.ids.generated.ts +4 -1
- package/generated/entity-fields-registry.ts +39 -0
- package/jest.setup.ts +13 -0
- package/package.json +8 -7
- package/src/helpers/integration/workflowsFixtures.ts +765 -5
- package/src/helpers/integration/workflowsUi.ts +318 -0
- package/src/modules/attachments/lib/createFromBuffer.ts +120 -0
- package/src/modules/audit_logs/data/entities.ts +12 -0
- package/src/modules/audit_logs/data/validators.ts +1 -0
- package/src/modules/audit_logs/lib/projections.ts +5 -1
- package/src/modules/audit_logs/migrations/.snapshot-open-mercato.json +26 -0
- package/src/modules/audit_logs/migrations/Migration20260625120000.ts +15 -0
- package/src/modules/audit_logs/services/actionLogService.ts +3 -0
- package/src/modules/auth/data/entities.ts +21 -0
- package/src/modules/auth/i18n/de.json +31 -0
- package/src/modules/auth/i18n/en.json +31 -0
- package/src/modules/auth/i18n/es.json +31 -0
- package/src/modules/auth/i18n/ko.json +31 -0
- package/src/modules/auth/i18n/pl.json +31 -0
- package/src/modules/auth/lib/executionPrincipal.ts +235 -0
- package/src/modules/auth/migrations/.snapshot-open-mercato.json +16 -0
- package/src/modules/auth/migrations/Migration20260625050000.ts +21 -0
- package/src/modules/business_rules/components/InlineRuleEditor.tsx +231 -0
- package/src/modules/business_rules/data/validators.ts +6 -0
- package/src/modules/business_rules/i18n/de.json +4 -0
- package/src/modules/business_rules/i18n/en.json +4 -0
- package/src/modules/business_rules/i18n/es.json +4 -0
- package/src/modules/business_rules/i18n/ko.json +4 -0
- package/src/modules/business_rules/i18n/pl.json +4 -0
- package/src/modules/business_rules/lib/rule-engine.ts +15 -1
- package/src/modules/catalog/commands/products.ts +12 -0
- package/src/modules/catalog/i18n/de.json +1 -0
- package/src/modules/catalog/i18n/en.json +1 -0
- package/src/modules/catalog/i18n/es.json +1 -0
- package/src/modules/catalog/i18n/ko.json +1 -0
- package/src/modules/catalog/i18n/pl.json +1 -0
- package/src/modules/catalog/workflows.ts +35 -0
- package/src/modules/customer_accounts/AGENTS.md +11 -0
- package/src/modules/customer_accounts/backend/customer_accounts/roles/[id]/page.tsx +2 -0
- package/src/modules/customer_accounts/cli.ts +96 -0
- package/src/modules/customer_accounts/i18n/de.json +5 -0
- package/src/modules/customer_accounts/i18n/en.json +5 -0
- package/src/modules/customer_accounts/i18n/es.json +5 -0
- package/src/modules/customer_accounts/i18n/ko.json +5 -0
- package/src/modules/customer_accounts/i18n/pl.json +5 -0
- package/src/modules/customer_accounts/lib/customerRoleAclSync.ts +92 -0
- package/src/modules/customer_accounts/setup.ts +15 -3
- package/src/modules/customers/commands/deals.ts +5 -0
- package/src/modules/customers/components/detail/ChangelogEntryRow.tsx +4 -2
- package/src/modules/customers/components/detail/utils.ts +2 -0
- package/src/modules/customers/events.ts +21 -3
- package/src/modules/customers/i18n/de.json +4 -0
- package/src/modules/customers/i18n/en.json +4 -0
- package/src/modules/customers/i18n/es.json +4 -0
- package/src/modules/customers/i18n/ko.json +4 -0
- package/src/modules/customers/i18n/pl.json +4 -0
- package/src/modules/customers/lib/link-workflow-task-handler.ts +136 -0
- package/src/modules/customers/lib/todoCompatibility.ts +4 -1
- package/src/modules/customers/lib/workflowTaskLink.ts +23 -0
- package/src/modules/customers/subscribers/link-workflow-task.ts +19 -0
- package/src/modules/customers/workflows.ts +57 -0
- package/src/modules/entities/api/records.ts +18 -62
- package/src/modules/entities/lib/entityClassification.ts +102 -0
- package/src/modules/sales/commands/documents.ts +46 -0
- package/src/modules/sales/events.ts +20 -2
- package/src/modules/sales/i18n/de.json +2 -1
- package/src/modules/sales/i18n/en.json +2 -1
- package/src/modules/sales/i18n/es.json +2 -1
- package/src/modules/sales/i18n/ko.json +2 -1
- package/src/modules/sales/i18n/pl.json +2 -1
- package/src/modules/sales/workflows.ts +12 -1
- package/src/modules/seeds/README.md +86 -0
- package/src/modules/seeds/cli.ts +220 -0
- package/src/modules/seeds/examples/sample-seed.json +26 -0
- package/src/modules/seeds/index.ts +11 -0
- package/src/modules/workflows/AGENTS.md +851 -10
- package/src/modules/workflows/acl.ts +96 -0
- package/src/modules/workflows/ai-agents.ts +80 -0
- package/src/modules/workflows/ai-tools/authoring-pack.ts +798 -0
- package/src/modules/workflows/ai-tools/types.ts +117 -0
- package/src/modules/workflows/ai-tools.ts +20 -0
- package/src/modules/workflows/api/command-settings/route.ts +171 -0
- package/src/modules/workflows/api/commands/route.ts +109 -0
- package/src/modules/workflows/api/definitions/[id]/callers/route.ts +95 -0
- package/src/modules/workflows/api/definitions/[id]/context-schema/route.ts +187 -0
- package/src/modules/workflows/api/definitions/[id]/customize/route.ts +6 -1
- package/src/modules/workflows/api/definitions/[id]/draft/route.ts +395 -0
- package/src/modules/workflows/api/definitions/[id]/publish/route.ts +250 -0
- package/src/modules/workflows/api/definitions/[id]/reset-to-code/route.ts +5 -0
- package/src/modules/workflows/api/definitions/[id]/route.ts +107 -7
- package/src/modules/workflows/api/definitions/[id]/test-step/route.ts +288 -0
- package/src/modules/workflows/api/definitions/generate/route.ts +335 -0
- package/src/modules/workflows/api/definitions/route.ts +88 -113
- package/src/modules/workflows/api/definitions/serialize.ts +9 -0
- package/src/modules/workflows/api/endpoints/route.ts +88 -0
- package/src/modules/workflows/api/functions/route.ts +91 -0
- package/src/modules/workflows/api/grantable-features/route.ts +102 -0
- package/src/modules/workflows/api/instances/[id]/context/route.ts +214 -0
- package/src/modules/workflows/api/instances/[id]/rerun-step/route.ts +226 -0
- package/src/modules/workflows/api/instances/[id]/retry/route.ts +18 -2
- package/src/modules/workflows/api/instances/[id]/step-through/route.ts +195 -0
- package/src/modules/workflows/api/instances/[id]/steps/route.ts +160 -0
- package/src/modules/workflows/api/instances/[id]/would-do/route.ts +216 -0
- package/src/modules/workflows/api/instances/bulk-replay/route.ts +141 -0
- package/src/modules/workflows/api/instances/failure-queue/route.ts +197 -0
- package/src/modules/workflows/api/instances/route.ts +135 -3
- package/src/modules/workflows/api/metrics/definitions/route.ts +262 -0
- package/src/modules/workflows/api/openapi.ts +549 -2
- package/src/modules/workflows/api/portal/tasks/[id]/complete/route.ts +160 -0
- package/src/modules/workflows/api/portal/tasks/[id]/route.ts +124 -0
- package/src/modules/workflows/api/portal/tasks/route.ts +157 -0
- package/src/modules/workflows/api/rule-usage/route.ts +94 -0
- package/src/modules/workflows/api/task-settings/route.ts +138 -0
- package/src/modules/workflows/api/tasks/[id]/claim/route.ts +42 -17
- package/src/modules/workflows/api/tasks/[id]/complete/route.ts +47 -15
- package/src/modules/workflows/api/tasks/[id]/reassign/route.ts +197 -0
- package/src/modules/workflows/api/tasks/[id]/route.ts +57 -6
- package/src/modules/workflows/api/tasks/[id]/unclaim/route.ts +132 -0
- package/src/modules/workflows/api/tasks/route.ts +60 -5
- package/src/modules/workflows/api/tasks/serialize.ts +119 -0
- package/src/modules/workflows/api/templates/route.ts +87 -0
- package/src/modules/workflows/api/work-inbox/next/route.ts +170 -0
- package/src/modules/workflows/api/work-inbox/route.ts +153 -0
- package/src/modules/workflows/backend/config/workflows/page.meta.ts +33 -0
- package/src/modules/workflows/backend/config/workflows/page.tsx +12 -0
- package/src/modules/workflows/backend/definitions/[id]/page.tsx +19 -343
- package/src/modules/workflows/backend/definitions/create/page.meta.ts +1 -1
- package/src/modules/workflows/backend/definitions/create/page.tsx +19 -59
- package/src/modules/workflows/backend/definitions/page.tsx +156 -76
- package/src/modules/workflows/backend/definitions/visual-editor/page.tsx +3129 -584
- package/src/modules/workflows/backend/instances/[id]/page.meta.ts +1 -1
- package/src/modules/workflows/backend/instances/[id]/page.tsx +711 -539
- package/src/modules/workflows/backend/instances/failure-queue/page.meta.ts +16 -0
- package/src/modules/workflows/backend/instances/failure-queue/page.tsx +311 -0
- package/src/modules/workflows/backend/instances/page.meta.ts +1 -1
- package/src/modules/workflows/backend/instances/page.tsx +218 -38
- package/src/modules/workflows/backend/tasks/[id]/page.tsx +639 -400
- package/src/modules/workflows/backend/tasks/page.meta.ts +7 -0
- package/src/modules/workflows/backend/tasks/page.tsx +20 -333
- package/src/modules/workflows/backend/work-inbox/page.meta.ts +15 -0
- package/src/modules/workflows/backend/work-inbox/page.tsx +506 -0
- package/src/modules/workflows/cli.ts +1 -1
- package/src/modules/workflows/commands/tasks.ts +146 -0
- package/src/modules/workflows/components/ActivitiesEditor.tsx +91 -114
- package/src/modules/workflows/components/ActivityEditDialog.tsx +244 -0
- package/src/modules/workflows/components/AgentSelector.tsx +200 -0
- package/src/modules/workflows/components/AnnotationEditDialog.tsx +157 -0
- package/src/modules/workflows/components/BusinessRuleUsagePanel.tsx +106 -0
- package/src/modules/workflows/components/BusinessRulesSelector.tsx +71 -17
- package/src/modules/workflows/components/ConfigJsonTextarea.tsx +111 -0
- package/src/modules/workflows/components/ContextSchemaEditor.tsx +165 -0
- package/src/modules/workflows/components/DefinitionErrorHandlerField.tsx +133 -0
- package/src/modules/workflows/components/DefinitionMetadataDrawer.tsx +456 -0
- package/src/modules/workflows/components/DefinitionMetricsCells.tsx +212 -0
- package/src/modules/workflows/components/DefinitionTriggersEditor.tsx +196 -95
- package/src/modules/workflows/components/EdgeEditDialog.tsx +15 -16
- package/src/modules/workflows/components/EdgeEditDialogCrudForm.tsx +130 -80
- package/src/modules/workflows/components/InputDataPanel.tsx +177 -0
- package/src/modules/workflows/components/InspectorPanel.tsx +250 -0
- package/src/modules/workflows/components/NodeEditDialog.tsx +444 -38
- package/src/modules/workflows/components/NodeEditDialogCrudForm.tsx +848 -178
- package/src/modules/workflows/components/StepsEditor.tsx +9 -2
- package/src/modules/workflows/components/TemplateGalleryDialog.tsx +205 -0
- package/src/modules/workflows/components/TransitionsEditor.tsx +98 -89
- package/src/modules/workflows/components/TriggersDialog.tsx +83 -0
- package/src/modules/workflows/components/TriggersEditor.tsx +363 -0
- package/src/modules/workflows/components/WorkflowAiDraftDialog.tsx +383 -0
- package/src/modules/workflows/components/WorkflowCodeView.tsx +257 -0
- package/src/modules/workflows/components/WorkflowCommandPalette.tsx +82 -0
- package/src/modules/workflows/components/WorkflowCompensationGhostEdge.tsx +78 -0
- package/src/modules/workflows/components/WorkflowDataMappingEdge.tsx +46 -0
- package/src/modules/workflows/components/WorkflowGraph.tsx +54 -1
- package/src/modules/workflows/components/WorkflowGraphImpl.tsx +463 -37
- package/src/modules/workflows/components/WorkflowIconPicker.tsx +144 -0
- package/src/modules/workflows/components/WorkflowLegend.tsx +59 -33
- package/src/modules/workflows/components/WorkflowNodeCard.tsx +355 -28
- package/src/modules/workflows/components/WorkflowRouteChips.tsx +145 -0
- package/src/modules/workflows/components/WorkflowSelector.tsx +33 -14
- package/src/modules/workflows/components/WorkflowTransitionEdge.tsx +83 -10
- package/src/modules/workflows/components/WorkflowTransitionLabel.tsx +13 -2
- package/src/modules/workflows/components/fields/ActivityArrayEditor.tsx +120 -30
- package/src/modules/workflows/components/fields/ActivityConfigFields.tsx +675 -0
- package/src/modules/workflows/components/fields/ActivityTestPanel.tsx +250 -0
- package/src/modules/workflows/components/fields/AgentInvokeConfigField.tsx +580 -0
- package/src/modules/workflows/components/fields/AgentReviewOnBreachField.tsx +88 -0
- package/src/modules/workflows/components/fields/BranchingRoutesEditor.tsx +323 -0
- package/src/modules/workflows/components/fields/BusinessRuleConditionsEditor.tsx +36 -4
- package/src/modules/workflows/components/fields/CommandPicker.tsx +158 -0
- package/src/modules/workflows/components/fields/EndpointPicker.tsx +330 -0
- package/src/modules/workflows/components/fields/FormFieldArrayEditor.tsx +2 -2
- package/src/modules/workflows/components/fields/FunctionPicker.tsx +68 -0
- package/src/modules/workflows/components/fields/MappingArrayEditor.tsx +46 -12
- package/src/modules/workflows/components/fields/PortFieldArrayEditor.tsx +255 -0
- package/src/modules/workflows/components/fields/RolesMultiSelect.tsx +68 -0
- package/src/modules/workflows/components/fields/RouteOrderEditor.tsx +169 -0
- package/src/modules/workflows/components/fields/SchemaBuilderDialog.tsx +139 -0
- package/src/modules/workflows/components/fields/StartPreConditionsEditor.tsx +2 -2
- package/src/modules/workflows/components/fields/TaskAssignmentField.tsx +355 -0
- package/src/modules/workflows/components/fields/TaskDeadlineFields.tsx +172 -0
- package/src/modules/workflows/components/fields/TaskDecisionsField.tsx +294 -0
- package/src/modules/workflows/components/fields/TaskEntityBindingsField.tsx +156 -0
- package/src/modules/workflows/components/fields/TemplateTextControl.tsx +85 -0
- package/src/modules/workflows/components/fields/VariablePickerButton.tsx +177 -0
- package/src/modules/workflows/components/fields/ledgerDropTarget.ts +55 -0
- package/src/modules/workflows/components/fields/useActivityTypeOptions.ts +19 -0
- package/src/modules/workflows/components/formConfig.tsx +84 -10
- package/src/modules/workflows/components/mobile/MobileDefinitionDetail.tsx +5 -0
- package/src/modules/workflows/components/mobile/MobileMetadataSheet.tsx +10 -0
- package/src/modules/workflows/components/mobile/MobileTaskForm.tsx +55 -19
- package/src/modules/workflows/components/mobile/MobileVisualEditor.tsx +49 -40
- package/src/modules/workflows/components/nodes/AnnotationGroupNode.tsx +81 -0
- package/src/modules/workflows/components/nodes/AutomatedNode.tsx +34 -17
- package/src/modules/workflows/components/nodes/EndNode.tsx +15 -14
- package/src/modules/workflows/components/nodes/ErrorOutputHandle.tsx +32 -0
- package/src/modules/workflows/components/nodes/IfElseNode.tsx +64 -0
- package/src/modules/workflows/components/nodes/InvokeAgentNode.tsx +180 -0
- package/src/modules/workflows/components/nodes/NodeOutcomeRows.tsx +143 -0
- package/src/modules/workflows/components/nodes/ParallelForkNode.tsx +28 -15
- package/src/modules/workflows/components/nodes/ParallelJoinNode.tsx +28 -15
- package/src/modules/workflows/components/nodes/StartNode.tsx +78 -18
- package/src/modules/workflows/components/nodes/StickyNoteNode.tsx +65 -0
- package/src/modules/workflows/components/nodes/SubWorkflowNode.tsx +124 -23
- package/src/modules/workflows/components/nodes/SwitchNode.tsx +64 -0
- package/src/modules/workflows/components/nodes/TriggerCap.tsx +103 -0
- package/src/modules/workflows/components/nodes/TriggerNode.tsx +151 -0
- package/src/modules/workflows/components/nodes/UserTaskNode.tsx +67 -22
- package/src/modules/workflows/components/nodes/WaitForConditionNode.tsx +74 -0
- package/src/modules/workflows/components/nodes/WaitForSignalNode.tsx +31 -17
- package/src/modules/workflows/components/nodes/WaitForTimerNode.tsx +31 -16
- package/src/modules/workflows/components/nodes/index.ts +17 -0
- package/src/modules/workflows/components/portal/PortalTaskForm.tsx +280 -0
- package/src/modules/workflows/components/run/AgentActivityPanel.tsx +48 -0
- package/src/modules/workflows/components/run/RerunStepDialog.tsx +133 -0
- package/src/modules/workflows/components/run/RunEventBadge.tsx +37 -0
- package/src/modules/workflows/components/run/RunGantt.tsx +180 -0
- package/src/modules/workflows/components/run/RunStatusBadge.tsx +112 -0
- package/src/modules/workflows/components/run/RunStepInspector.tsx +176 -0
- package/src/modules/workflows/components/run/WouldDoReport.tsx +93 -0
- package/src/modules/workflows/components/run/useAgentLabels.ts +42 -0
- package/src/modules/workflows/components/run/useLastRunOverlay.ts +150 -0
- package/src/modules/workflows/components/run/useLiveAgentActions.ts +70 -0
- package/src/modules/workflows/components/run/useLiveRunUpdates.ts +89 -0
- package/src/modules/workflows/components/settings/CommandSettingsPageClient.tsx +228 -0
- package/src/modules/workflows/components/work-inbox/EntityContextPanel.tsx +179 -0
- package/src/modules/workflows/components/work-inbox/ReassignTaskDialog.tsx +203 -0
- package/src/modules/workflows/components/work-inbox/StatusChip.tsx +61 -0
- package/src/modules/workflows/components/work-inbox/TaskActionNotice.tsx +77 -0
- package/src/modules/workflows/components/work-inbox/TaskFormFields.tsx +322 -0
- package/src/modules/workflows/components/work-inbox/WorkInboxEmptyState.tsx +43 -0
- package/src/modules/workflows/data/activity-config-schemas.ts +249 -0
- package/src/modules/workflows/data/activity-config-warnings.ts +71 -0
- package/src/modules/workflows/data/branching-route-warnings.ts +129 -0
- package/src/modules/workflows/data/entities.ts +397 -4
- package/src/modules/workflows/data/metrics-validators.ts +51 -0
- package/src/modules/workflows/data/task-primitives.ts +36 -0
- package/src/modules/workflows/data/types.ts +81 -2
- package/src/modules/workflows/data/validators.ts +729 -60
- package/src/modules/workflows/di.ts +22 -0
- package/src/modules/workflows/events.ts +68 -8
- package/src/modules/workflows/examples/oze-residential-install-60-nodes.json +1545 -0
- package/src/modules/workflows/examples/sales-pipeline-definition.json +35 -35
- package/src/modules/workflows/examples/templates/lead-to-install.json +160 -0
- package/src/modules/workflows/examples/templates/order-approval.json +230 -0
- package/src/modules/workflows/examples/templates/task-escalation.json +110 -0
- package/src/modules/workflows/examples/templates/webhook-integration.json +113 -0
- package/src/modules/workflows/extension-points.ts +1 -1
- package/src/modules/workflows/frontend/[orgSlug]/portal/tasks/[id]/page.meta.ts +21 -0
- package/src/modules/workflows/frontend/[orgSlug]/portal/tasks/[id]/page.tsx +212 -0
- package/src/modules/workflows/frontend/[orgSlug]/portal/tasks/page.meta.ts +25 -0
- package/src/modules/workflows/frontend/[orgSlug]/portal/tasks/page.tsx +185 -0
- package/src/modules/workflows/i18n/de.json +1083 -24
- package/src/modules/workflows/i18n/en.json +1081 -22
- package/src/modules/workflows/i18n/es.json +1083 -24
- package/src/modules/workflows/i18n/ko.json +1072 -13
- package/src/modules/workflows/i18n/pl.json +1082 -23
- package/src/modules/workflows/lib/activity-executor.ts +855 -186
- package/src/modules/workflows/lib/activity-queue-types.ts +120 -1
- package/src/modules/workflows/lib/activity-registry-bootstrap.ts +7 -0
- package/src/modules/workflows/lib/activity-registry.ts +89 -0
- package/src/modules/workflows/lib/activity-types.ts +415 -0
- package/src/modules/workflows/lib/activity-worker-handler.ts +744 -35
- package/src/modules/workflows/lib/advanced-config.ts +41 -0
- package/src/modules/workflows/lib/agent-disposition-task.ts +343 -0
- package/src/modules/workflows/lib/agent-outcome-paths.ts +153 -0
- package/src/modules/workflows/lib/agent-result-mapping.ts +88 -0
- package/src/modules/workflows/lib/agent-review-inspector.ts +125 -0
- package/src/modules/workflows/lib/agent-review.ts +171 -0
- package/src/modules/workflows/lib/ai-authoring.ts +402 -0
- package/src/modules/workflows/lib/ai-draft-runner.ts +105 -0
- package/src/modules/workflows/lib/annotation-events.ts +15 -0
- package/src/modules/workflows/lib/branching-routes.ts +280 -0
- package/src/modules/workflows/lib/breach-routing.ts +142 -0
- package/src/modules/workflows/lib/bulk-replay.ts +185 -0
- package/src/modules/workflows/lib/business-rule-usage.ts +154 -0
- package/src/modules/workflows/lib/caller-graph.ts +104 -0
- package/src/modules/workflows/lib/code-view-apply.ts +178 -0
- package/src/modules/workflows/lib/collect-validation-issues.ts +239 -0
- package/src/modules/workflows/lib/compensation-ghosts.ts +134 -0
- package/src/modules/workflows/lib/component-guard.ts +13 -0
- package/src/modules/workflows/lib/condition-handler.ts +658 -0
- package/src/modules/workflows/lib/context-ledger.ts +814 -0
- package/src/modules/workflows/lib/crud-form-dialogs-flag.ts +5 -0
- package/src/modules/workflows/lib/data-edge-mapping.ts +112 -0
- package/src/modules/workflows/lib/definition-context-schema.ts +103 -0
- package/src/modules/workflows/lib/definition-edit-safety.ts +228 -0
- package/src/modules/workflows/lib/definition-error-body.ts +43 -0
- package/src/modules/workflows/lib/definition-evaluation.ts +156 -0
- package/src/modules/workflows/lib/definition-grant.ts +211 -0
- package/src/modules/workflows/lib/definition-json-locations.ts +226 -0
- package/src/modules/workflows/lib/definition-payload.ts +81 -0
- package/src/modules/workflows/lib/draft-restore.ts +72 -0
- package/src/modules/workflows/lib/dry-run.ts +203 -0
- package/src/modules/workflows/lib/duration.ts +138 -24
- package/src/modules/workflows/lib/edge-reattachment.ts +186 -0
- package/src/modules/workflows/lib/edgeFormTransforms.ts +15 -14
- package/src/modules/workflows/lib/editor-annotations.ts +301 -0
- package/src/modules/workflows/lib/editor-commands.ts +205 -0
- package/src/modules/workflows/lib/editor-history.ts +151 -0
- package/src/modules/workflows/lib/endpoint-catalog.ts +283 -0
- package/src/modules/workflows/lib/endpoint-path.ts +134 -0
- package/src/modules/workflows/lib/engine-version.ts +67 -0
- package/src/modules/workflows/lib/error-handler.ts +192 -0
- package/src/modules/workflows/lib/error-routing.ts +236 -0
- package/src/modules/workflows/lib/event-logger.ts +27 -0
- package/src/modules/workflows/lib/expression-refs.ts +291 -0
- package/src/modules/workflows/lib/failure-grouping.ts +134 -0
- package/src/modules/workflows/lib/find-definition.ts +4 -0
- package/src/modules/workflows/lib/flow-logic-warnings.ts +591 -0
- package/src/modules/workflows/lib/graph-utils.ts +620 -110
- package/src/modules/workflows/lib/icon-search.ts +65 -0
- package/src/modules/workflows/lib/insert-at-cursor.ts +53 -0
- package/src/modules/workflows/lib/instance-date-filter.ts +56 -0
- package/src/modules/workflows/lib/interpolation-pipeline.ts +351 -0
- package/src/modules/workflows/lib/ledger-drag.ts +61 -0
- package/src/modules/workflows/lib/ledger-entry-display.ts +89 -0
- package/src/modules/workflows/lib/ledger-schema-flatten.ts +137 -0
- package/src/modules/workflows/lib/metrics/definition-metrics.ts +268 -0
- package/src/modules/workflows/lib/metrics/metrics-display.ts +57 -0
- package/src/modules/workflows/lib/metrics/rollup-schedule.ts +26 -0
- package/src/modules/workflows/lib/metrics/rollup-service.ts +292 -0
- package/src/modules/workflows/lib/node-config-summary.ts +235 -0
- package/src/modules/workflows/lib/node-geometry.ts +168 -0
- package/src/modules/workflows/lib/node-nudge.ts +63 -0
- package/src/modules/workflows/lib/node-outcome-rows.ts +195 -0
- package/src/modules/workflows/lib/node-placement.ts +104 -0
- package/src/modules/workflows/lib/node-type-icons.ts +71 -10
- package/src/modules/workflows/lib/nodeFormTransforms.ts +519 -28
- package/src/modules/workflows/lib/outcome-routing.ts +346 -0
- package/src/modules/workflows/lib/owned-definition.ts +188 -0
- package/src/modules/workflows/lib/owned-node-changes.ts +29 -0
- package/src/modules/workflows/lib/palette-drag.ts +68 -0
- package/src/modules/workflows/lib/palette-drop.ts +114 -0
- package/src/modules/workflows/lib/parallel-handler.ts +79 -2
- package/src/modules/workflows/lib/port-contract.ts +107 -0
- package/src/modules/workflows/lib/portal-task-access.ts +220 -0
- package/src/modules/workflows/lib/rerun-from-step.ts +140 -0
- package/src/modules/workflows/lib/route-chip-events.ts +45 -0
- package/src/modules/workflows/lib/route-chips.ts +177 -0
- package/src/modules/workflows/lib/route-edge.ts +57 -0
- package/src/modules/workflows/lib/route-kinds.ts +166 -0
- package/src/modules/workflows/lib/route-priority.ts +197 -0
- package/src/modules/workflows/lib/run-duration.ts +70 -0
- package/src/modules/workflows/lib/run-event-tone.ts +46 -0
- package/src/modules/workflows/lib/run-execution.ts +598 -0
- package/src/modules/workflows/lib/run-gantt.ts +311 -0
- package/src/modules/workflows/lib/run-outcome-evidence.ts +60 -0
- package/src/modules/workflows/lib/run-outcome.ts +142 -0
- package/src/modules/workflows/lib/sample-resolver.ts +113 -0
- package/src/modules/workflows/lib/seeds.ts +3 -1
- package/src/modules/workflows/lib/server-output-contract.ts +120 -0
- package/src/modules/workflows/lib/set-variable.ts +94 -0
- package/src/modules/workflows/lib/signal-handler.ts +134 -4
- package/src/modules/workflows/lib/start-fixtures.ts +93 -0
- package/src/modules/workflows/lib/status-colors.ts +220 -21
- package/src/modules/workflows/lib/step-handler.ts +744 -68
- package/src/modules/workflows/lib/step-presentation.ts +295 -0
- package/src/modules/workflows/lib/step-through.ts +71 -0
- package/src/modules/workflows/lib/step-type-conversion.ts +263 -0
- package/src/modules/workflows/lib/subgraph-clipboard.ts +214 -0
- package/src/modules/workflows/lib/task-decision-context.ts +76 -0
- package/src/modules/workflows/lib/task-decisions.ts +117 -0
- package/src/modules/workflows/lib/task-entity-access.ts +181 -0
- package/src/modules/workflows/lib/task-entity-aliases.ts +77 -0
- package/src/modules/workflows/lib/task-entity-types.ts +66 -0
- package/src/modules/workflows/lib/task-form-registry.ts +123 -0
- package/src/modules/workflows/lib/task-form-schema.ts +129 -0
- package/src/modules/workflows/lib/task-handler.ts +492 -51
- package/src/modules/workflows/lib/task-inspector-config.ts +348 -0
- package/src/modules/workflows/lib/task-list-query.ts +46 -0
- package/src/modules/workflows/lib/task-notifications.ts +218 -0
- package/src/modules/workflows/lib/task-permission-settings.ts +117 -0
- package/src/modules/workflows/lib/task-presets.ts +95 -0
- package/src/modules/workflows/lib/task-quick-action.ts +111 -0
- package/src/modules/workflows/lib/task-resolution.ts +270 -0
- package/src/modules/workflows/lib/task-sla.ts +628 -0
- package/src/modules/workflows/lib/task-visibility-request.ts +668 -0
- package/src/modules/workflows/lib/task-visibility.ts +627 -0
- package/src/modules/workflows/lib/timer-handler.ts +8 -1
- package/src/modules/workflows/lib/transition-handler.ts +228 -20
- package/src/modules/workflows/lib/trigger-node.ts +272 -0
- package/src/modules/workflows/lib/visual-editor-navigation.ts +29 -0
- package/src/modules/workflows/lib/work-inbox/empty-state.ts +150 -0
- package/src/modules/workflows/lib/work-inbox/entity-links.ts +99 -0
- package/src/modules/workflows/lib/work-inbox/navigation.ts +28 -0
- package/src/modules/workflows/lib/work-inbox/presentation.ts +163 -0
- package/src/modules/workflows/lib/work-inbox/provider.ts +390 -0
- package/src/modules/workflows/lib/work-inbox/query.ts +103 -0
- package/src/modules/workflows/lib/work-inbox/service.ts +122 -0
- package/src/modules/workflows/lib/work-inbox/user-task-source.ts +240 -0
- package/src/modules/workflows/lib/workflow-command-enablement.ts +188 -0
- package/src/modules/workflows/lib/workflow-command-settings.ts +124 -0
- package/src/modules/workflows/lib/workflow-executor.ts +1036 -10
- package/src/modules/workflows/lib/workflow-function-registry.ts +44 -0
- package/src/modules/workflows/lib/workflow-safe-commands.ts +42 -1
- package/src/modules/workflows/lib/workflow-templates.ts +91 -0
- package/src/modules/workflows/migrations/.snapshot-open-mercato.json +2321 -698
- package/src/modules/workflows/migrations/Migration20260626214855_workflows.ts +15 -0
- package/src/modules/workflows/migrations/Migration20260626222424_workflows.ts +17 -0
- package/src/modules/workflows/migrations/Migration20260727074335_workflows.ts +15 -0
- package/src/modules/workflows/migrations/Migration20260728104038_workflows.ts +13 -0
- package/src/modules/workflows/migrations/Migration20260728163001_workflows.ts +36 -0
- package/src/modules/workflows/migrations/Migration20260729061736_workflows.ts +13 -0
- package/src/modules/workflows/migrations/Migration20260729192652_workflows.ts +11 -0
- package/src/modules/workflows/migrations/Migration20260730085000_workflows.ts +13 -0
- package/src/modules/workflows/migrations/Migration20260730092706_workflows.ts +13 -0
- package/src/modules/workflows/notifications.ts +40 -10
- package/src/modules/workflows/setup.ts +128 -0
- package/src/modules/workflows/subscribers/task-assigned-notification.ts +36 -45
- package/src/modules/workflows/subscribers/task-deadline-breached-notification.ts +31 -0
- package/src/modules/workflows/subscribers/task-reminder-notification.ts +31 -0
- package/src/modules/workflows/widgets/injection/pending-work/widget.client.tsx +119 -0
- package/src/modules/workflows/widgets/injection/pending-work/widget.ts +27 -0
- package/src/modules/workflows/widgets/injection-table.ts +52 -2
- package/src/modules/workflows/workers/workflow-activities.worker.ts +95 -42
- package/src/modules/workflows/workers/workflow-definition-metric-rollup.worker.ts +71 -0
- package/src/modules/workflows/workers/workflow-instance-bulk-replay.ts +51 -0
- package/src/modules/workflows/workers/workflow-invoke-agent.worker.ts +72 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const WORKFLOW_DRAFT_AGENT_ID = "workflows.workflow_author";
|
|
3
|
+
const WORKFLOW_DRAFT_PROMPT_MAX_LENGTH = 2e3;
|
|
4
|
+
const draftActivitySchema = z.object({
|
|
5
|
+
activityId: z.string().min(1).max(100),
|
|
6
|
+
activityName: z.string().min(1).max(255),
|
|
7
|
+
activityType: z.string().min(1).max(100),
|
|
8
|
+
config: z.record(z.string(), z.unknown())
|
|
9
|
+
});
|
|
10
|
+
const draftStepSchema = z.object({
|
|
11
|
+
stepId: z.string().min(1).max(100),
|
|
12
|
+
stepName: z.string().min(1).max(255),
|
|
13
|
+
stepType: z.string().min(1).max(50),
|
|
14
|
+
description: z.string().max(1e3).optional()
|
|
15
|
+
});
|
|
16
|
+
const draftTransitionSchema = z.object({
|
|
17
|
+
transitionId: z.string().min(1).max(100),
|
|
18
|
+
fromStepId: z.string().min(1).max(100),
|
|
19
|
+
toStepId: z.string().min(1).max(100),
|
|
20
|
+
transitionName: z.string().max(255).optional(),
|
|
21
|
+
trigger: z.string().min(1).max(20),
|
|
22
|
+
activities: z.array(draftActivitySchema).optional()
|
|
23
|
+
});
|
|
24
|
+
const draftContextFieldSchema = z.object({
|
|
25
|
+
name: z.string().min(1),
|
|
26
|
+
type: z.enum(["text", "number", "boolean", "select", "date"]),
|
|
27
|
+
label: z.string().optional(),
|
|
28
|
+
required: z.boolean().optional()
|
|
29
|
+
});
|
|
30
|
+
const workflowDraftGenerationSchema = z.object({
|
|
31
|
+
summary: z.string().min(1).max(400).describe("One plain-language sentence describing what the workflow does"),
|
|
32
|
+
steps: z.array(draftStepSchema).min(2),
|
|
33
|
+
transitions: z.array(draftTransitionSchema).min(1),
|
|
34
|
+
contextSchema: z.object({ input: z.object({ fields: z.array(draftContextFieldSchema) }) }).optional()
|
|
35
|
+
});
|
|
36
|
+
const WORKFLOW_DRAFT_CATALOG_LIMIT = 60;
|
|
37
|
+
function buildWorkflowDraftCatalog(input) {
|
|
38
|
+
return {
|
|
39
|
+
stepTypes: [...input.stepTypes],
|
|
40
|
+
transitionTriggers: [...input.transitionTriggers],
|
|
41
|
+
activityTypes: input.activityTypes.slice(0, WORKFLOW_DRAFT_CATALOG_LIMIT).map((entry) => ({
|
|
42
|
+
id: entry.id,
|
|
43
|
+
...entry.configSchema === void 0 ? {} : { configSchema: entry.configSchema }
|
|
44
|
+
})),
|
|
45
|
+
commands: input.commands.slice(0, WORKFLOW_DRAFT_CATALOG_LIMIT).map((entry) => ({ id: entry.id, ...entry.label ? { description: entry.label } : {} })),
|
|
46
|
+
functions: input.functions.slice(0, WORKFLOW_DRAFT_CATALOG_LIMIT).map((entry) => ({ id: entry.name, ...entry.label ? { description: entry.label } : {} })),
|
|
47
|
+
events: input.events.slice(0, WORKFLOW_DRAFT_CATALOG_LIMIT).map((entry) => entry.id),
|
|
48
|
+
agents: (input.agents ?? []).slice(0, WORKFLOW_DRAFT_CATALOG_LIMIT).map((entry) => ({ id: entry.id, ...entry.label ? { description: entry.label } : {} }))
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function buildWorkflowDraftPrompt(input) {
|
|
52
|
+
const { prompt, catalog } = input;
|
|
53
|
+
const invokeAgentRule = catalog.agents.length > 0 ? "- An INVOKE_AGENT activity MUST set config.agentId to one of the catalog `agents` ids and config.onResult (either { autoApproveThreshold } or { alwaysAsk: true })." : "- Do NOT use the INVOKE_AGENT activity type: this installation has no usable agents, so an agent step cannot be run. Use other activity types instead.";
|
|
54
|
+
return [
|
|
55
|
+
"Author a workflow definition for this request:",
|
|
56
|
+
"",
|
|
57
|
+
prompt.trim(),
|
|
58
|
+
"",
|
|
59
|
+
"Use ONLY the identifiers in this catalog. Never invent a step type, transition trigger, activity type, command id, function name or event name that is not listed here.",
|
|
60
|
+
"",
|
|
61
|
+
JSON.stringify(catalog),
|
|
62
|
+
"",
|
|
63
|
+
"Rules:",
|
|
64
|
+
"- Exactly one START step and at least one END step.",
|
|
65
|
+
"- Every step except END has at least one outgoing transition, and every step except START is reachable.",
|
|
66
|
+
"- Step, transition and activity ids are lowercase letters, numbers, hyphens and underscores only.",
|
|
67
|
+
"- Activities belong to the transition that LEAVES the step whose work they do.",
|
|
68
|
+
"- Reference run context as {{context.<path>}}, and declare every path you reference in contextSchema.input.fields.",
|
|
69
|
+
invokeAgentRule,
|
|
70
|
+
"- Call the workflows.validate_workflow_definition tool on your draft and fix every reported error before you return it.",
|
|
71
|
+
"- Prefer the smallest graph that answers the request."
|
|
72
|
+
].join("\n");
|
|
73
|
+
}
|
|
74
|
+
const WORKFLOW_DRAFT_MAX_REPAIR_ATTEMPTS = 2;
|
|
75
|
+
function buildWorkflowDraftRepairPrompt(input) {
|
|
76
|
+
let rendered;
|
|
77
|
+
try {
|
|
78
|
+
rendered = JSON.stringify(input.rejectedDraft);
|
|
79
|
+
} catch {
|
|
80
|
+
rendered = "(the previous response could not be serialized)";
|
|
81
|
+
}
|
|
82
|
+
return [
|
|
83
|
+
input.previousPrompt,
|
|
84
|
+
"",
|
|
85
|
+
"Your previous answer was rejected by the workflow schema. This was it:",
|
|
86
|
+
"",
|
|
87
|
+
rendered,
|
|
88
|
+
"",
|
|
89
|
+
"Every path below failed validation. Fix exactly these and change nothing else:",
|
|
90
|
+
...input.messages.map((message) => `- ${message}`),
|
|
91
|
+
"",
|
|
92
|
+
"Return the whole corrected workflow, in the same shape as before."
|
|
93
|
+
].join("\n");
|
|
94
|
+
}
|
|
95
|
+
function interpretWorkflowDraftObject(input) {
|
|
96
|
+
const generation = workflowDraftGenerationSchema.safeParse(input.raw);
|
|
97
|
+
if (!generation.success) {
|
|
98
|
+
return {
|
|
99
|
+
ok: false,
|
|
100
|
+
reason: "malformedResponse",
|
|
101
|
+
messages: generation.error.issues.map(
|
|
102
|
+
(issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`
|
|
103
|
+
)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const candidate = {
|
|
107
|
+
steps: generation.data.steps,
|
|
108
|
+
transitions: generation.data.transitions
|
|
109
|
+
};
|
|
110
|
+
if (generation.data.contextSchema) candidate.contextSchema = generation.data.contextSchema;
|
|
111
|
+
const parsed = input.parseDefinition(candidate);
|
|
112
|
+
if (!parsed.ok) return { ok: false, reason: "schemaError", messages: parsed.messages };
|
|
113
|
+
return { ok: true, definition: parsed.definition, summary: generation.data.summary };
|
|
114
|
+
}
|
|
115
|
+
const AI_CHECKPOINT_LABEL_MAX_LENGTH = 64;
|
|
116
|
+
function buildAiCheckpointLabel(prompt, options = { prefix: "AI" }) {
|
|
117
|
+
const maxLength = options.maxLength ?? AI_CHECKPOINT_LABEL_MAX_LENGTH;
|
|
118
|
+
const normalized = prompt.replace(/\s+/g, " ").trim();
|
|
119
|
+
if (!normalized) return options.prefix;
|
|
120
|
+
const budget = Math.max(1, maxLength - options.prefix.length - 2);
|
|
121
|
+
if (normalized.length <= budget) return `${options.prefix}: ${normalized}`;
|
|
122
|
+
const clipped = normalized.slice(0, budget);
|
|
123
|
+
const lastSpace = clipped.lastIndexOf(" ");
|
|
124
|
+
const body = lastSpace > budget / 2 ? clipped.slice(0, lastSpace) : clipped;
|
|
125
|
+
return `${options.prefix}: ${body}\u2026`;
|
|
126
|
+
}
|
|
127
|
+
const UNAVAILABLE_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
128
|
+
"no_provider_configured",
|
|
129
|
+
"api_key_missing",
|
|
130
|
+
"agent_unknown",
|
|
131
|
+
"agent_features_denied",
|
|
132
|
+
"execution_mode_not_supported"
|
|
133
|
+
]);
|
|
134
|
+
function classifyWorkflowDraftFailure(error) {
|
|
135
|
+
if (error && typeof error === "object") {
|
|
136
|
+
const code = error.code;
|
|
137
|
+
if (typeof code === "string" && UNAVAILABLE_ERROR_CODES.has(code)) return "unavailable";
|
|
138
|
+
}
|
|
139
|
+
return "failed";
|
|
140
|
+
}
|
|
141
|
+
export {
|
|
142
|
+
AI_CHECKPOINT_LABEL_MAX_LENGTH,
|
|
143
|
+
WORKFLOW_DRAFT_AGENT_ID,
|
|
144
|
+
WORKFLOW_DRAFT_CATALOG_LIMIT,
|
|
145
|
+
WORKFLOW_DRAFT_MAX_REPAIR_ATTEMPTS,
|
|
146
|
+
WORKFLOW_DRAFT_PROMPT_MAX_LENGTH,
|
|
147
|
+
buildAiCheckpointLabel,
|
|
148
|
+
buildWorkflowDraftCatalog,
|
|
149
|
+
buildWorkflowDraftPrompt,
|
|
150
|
+
buildWorkflowDraftRepairPrompt,
|
|
151
|
+
classifyWorkflowDraftFailure,
|
|
152
|
+
interpretWorkflowDraftObject,
|
|
153
|
+
workflowDraftGenerationSchema
|
|
154
|
+
};
|
|
155
|
+
//# sourceMappingURL=ai-authoring.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/workflows/lib/ai-authoring.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Prompt-to-draft: the pure half (spec \u00A79, \"AI-assisted authoring\").\n *\n * *\"natural language \u2192 draft definition generated against the real catalogs\n * (events, commands, ledger), opened in the Studio with a Problems pass already\n * run. Never auto-published.\"*\n *\n * ## What this module owns\n *\n * The three decisions that must be testable without a model, a canvas or a\n * database: what the request looks like, what a response is allowed to become,\n * and what the resulting undo entry is CALLED.\n *\n * - `buildWorkflowDraftCatalog` shapes the platform's own registries into the\n * compact catalog the prompt carries. Generation targets schemas, not\n * vibes \u2014 an activity type the registry does not know can only be invented,\n * and the catalog is what stops that.\n * - `buildWorkflowDraftPrompt` turns a prompt plus a catalog into the exact\n * request string. Pure, so a change to the instructions is a diff a test can\n * read.\n * - `interpretWorkflowDraftObject` maps a model response onto a definition, or\n * refuses. It NEVER hand-rolls validation: the caller passes the definition\n * parser in, so the Studio, the API route and the tests all reach the one\n * `workflowDefinitionDataSchema`.\n * - `buildAiCheckpointLabel` names the undo entry. Spec \u00A79 asks for a *named\n * checkpoint in the undo stack (\u00A74.5)* \u2014 `lib/editor-history.ts` already\n * carries a translated label per entry, so \"checkpoint\" is a NAMING problem,\n * not a second history.\n * - `classifyWorkflowDraftFailure` decides whether a thrown error means \"there\n * is no model here\" or \"the call failed\". It reads the error's `code`\n * STRUCTURALLY \u2014 the same technique `isGuardrailBlockedError` uses \u2014 so this\n * module never imports the AI runtime and stays loadable in the browser.\n *\n * ## What it deliberately does NOT own\n *\n * Applying. A generated definition reaches the canvas through\n * `evaluateCodeViewDraft` (`lib/code-view-apply.ts`) \u2014 the same four escalating\n * refusals a human-pasted definition passes, because an AI-authored graph has\n * earned exactly as much trust as a pasted one, which is to say none.\n *\n * PURE: zod and plain data only \u2014 no React, no ORM, no DI, no registry imports.\n */\n\nimport { z } from 'zod'\n\n/**\n * The object-mode agent that authors drafts. Declared in the module-root\n * `ai-agents.ts`; resolved by the AI runtime's generated registry, which means\n * it answers `agent_unknown` \u2014 and therefore \"AI authoring is unavailable\" \u2014\n * until `yarn generate` has run.\n */\nexport const WORKFLOW_DRAFT_AGENT_ID = 'workflows.workflow_author'\n\nexport const WORKFLOW_DRAFT_PROMPT_MAX_LENGTH = 2000\n\n// ---------------------------------------------------------------------------\n// The generation contract\n// ---------------------------------------------------------------------------\n\n/**\n * What the model is allowed to produce.\n *\n * Deliberately NARROWER than `workflowDefinitionDataSchema`, in both\n * directions:\n *\n * - It omits identity (`workflowId`, `workflowName`, `version`). Those are the\n * engine's unique key, they are edited in the metadata drawer, and \u2014 this is\n * the load-bearing reason \u2014 they are NOT versioned by the editor's undo\n * stack. Writing them on apply would leave a residue an undo could not\n * remove, which breaks the one thing this feature promises.\n * - It omits `io`, `interpolation`, `errorHandler` and triggers: each is a\n * separate authoring decision with its own inspector, and a first draft that\n * silently rewires a definition's error handling is a worse draft.\n *\n * `activityType` is a plain string rather than the registry-driven enum\n * because this module is pure and must not import the registry. The catalog in\n * the prompt is what steers it, and `workflowDefinitionDataSchema` is what\n * enforces it \u2014 the model's output is re-parsed through the real schema before\n * anything reaches a canvas.\n */\nconst draftActivitySchema = z.object({\n activityId: z.string().min(1).max(100),\n activityName: z.string().min(1).max(255),\n activityType: z.string().min(1).max(100),\n config: z.record(z.string(), z.unknown()),\n})\n\nconst draftStepSchema = z.object({\n stepId: z.string().min(1).max(100),\n stepName: z.string().min(1).max(255),\n stepType: z.string().min(1).max(50),\n description: z.string().max(1000).optional(),\n})\n\nconst draftTransitionSchema = z.object({\n transitionId: z.string().min(1).max(100),\n fromStepId: z.string().min(1).max(100),\n toStepId: z.string().min(1).max(100),\n transitionName: z.string().max(255).optional(),\n trigger: z.string().min(1).max(20),\n activities: z.array(draftActivitySchema).optional(),\n})\n\nconst draftContextFieldSchema = z.object({\n name: z.string().min(1),\n type: z.enum(['text', 'number', 'boolean', 'select', 'date']),\n label: z.string().optional(),\n required: z.boolean().optional(),\n})\n\nexport const workflowDraftGenerationSchema = z.object({\n summary: z\n .string()\n .min(1)\n .max(400)\n .describe('One plain-language sentence describing what the workflow does'),\n steps: z.array(draftStepSchema).min(2),\n transitions: z.array(draftTransitionSchema).min(1),\n contextSchema: z\n .object({ input: z.object({ fields: z.array(draftContextFieldSchema) }) })\n .optional(),\n})\n\nexport type WorkflowDraftGeneration = z.infer<typeof workflowDraftGenerationSchema>\n\n// ---------------------------------------------------------------------------\n// The catalog\n// ---------------------------------------------------------------------------\n\nexport interface WorkflowDraftCatalogEntry {\n id: string\n /** Compact JSON-Schema description of the entry's config, when it has one. */\n configSchema?: unknown\n description?: string\n}\n\nexport interface WorkflowDraftCatalog {\n stepTypes: string[]\n transitionTriggers: string[]\n activityTypes: WorkflowDraftCatalogEntry[]\n commands: WorkflowDraftCatalogEntry[]\n functions: WorkflowDraftCatalogEntry[]\n events: string[]\n /**\n * The agents an `INVOKE_AGENT` activity may target. Empty when the optional\n * `agent_orchestrator` peer is absent or exposes none \u2014 which is exactly when\n * `INVOKE_AGENT` must be forbidden (an agent step with no agent to run can\n * only fail the strict `invokeAgentConfigSchema` later). Fail-closed.\n */\n agents: WorkflowDraftCatalogEntry[]\n}\n\nexport interface WorkflowDraftCatalogInput {\n stepTypes: readonly string[]\n transitionTriggers: readonly string[]\n activityTypes: readonly { id: string; configSchema?: unknown }[]\n commands: readonly { id: string; label?: string }[]\n functions: readonly { name: string; label?: string }[]\n events: readonly { id: string }[]\n /** Usable agents; omitted/empty \u21D2 `INVOKE_AGENT` is fail-closed forbidden. */\n agents?: readonly { id: string; label?: string }[]\n}\n\n/**\n * The number of registry entries of each kind the prompt carries. A tenant with\n * hundreds of registered commands would otherwise spend the whole context\n * window on a catalog, and a truncated catalog is honest \u2014 the model simply has\n * fewer ids to reach for, and every id it does reach for is real.\n */\nexport const WORKFLOW_DRAFT_CATALOG_LIMIT = 60\n\nexport function buildWorkflowDraftCatalog(\n input: WorkflowDraftCatalogInput,\n): WorkflowDraftCatalog {\n return {\n stepTypes: [...input.stepTypes],\n transitionTriggers: [...input.transitionTriggers],\n activityTypes: input.activityTypes\n .slice(0, WORKFLOW_DRAFT_CATALOG_LIMIT)\n .map((entry) => ({\n id: entry.id,\n ...(entry.configSchema === undefined ? {} : { configSchema: entry.configSchema }),\n })),\n commands: input.commands\n .slice(0, WORKFLOW_DRAFT_CATALOG_LIMIT)\n .map((entry) => ({ id: entry.id, ...(entry.label ? { description: entry.label } : {}) })),\n functions: input.functions\n .slice(0, WORKFLOW_DRAFT_CATALOG_LIMIT)\n .map((entry) => ({ id: entry.name, ...(entry.label ? { description: entry.label } : {}) })),\n events: input.events.slice(0, WORKFLOW_DRAFT_CATALOG_LIMIT).map((entry) => entry.id),\n agents: (input.agents ?? [])\n .slice(0, WORKFLOW_DRAFT_CATALOG_LIMIT)\n .map((entry) => ({ id: entry.id, ...(entry.label ? { description: entry.label } : {}) })),\n }\n}\n\n// ---------------------------------------------------------------------------\n// The request\n// ---------------------------------------------------------------------------\n\nexport interface WorkflowDraftPromptInput {\n prompt: string\n catalog: WorkflowDraftCatalog\n}\n\n/**\n * Build the single user message the object-mode agent receives.\n *\n * The catalog travels in the REQUEST rather than through tool calls: the draft\n * agent is declared with an empty tool allowlist, so it has no way to reach\n * tenant data at all. That is the strongest form of \"propose only\" available \u2014\n * not a policy that forbids writes, but a runtime with nothing to write to.\n */\nexport function buildWorkflowDraftPrompt(input: WorkflowDraftPromptInput): string {\n const { prompt, catalog } = input\n const invokeAgentRule =\n catalog.agents.length > 0\n ? '- An INVOKE_AGENT activity MUST set config.agentId to one of the catalog `agents` ids and config.onResult (either { autoApproveThreshold } or { alwaysAsk: true }).'\n : '- Do NOT use the INVOKE_AGENT activity type: this installation has no usable agents, so an agent step cannot be run. Use other activity types instead.'\n return [\n 'Author a workflow definition for this request:',\n '',\n prompt.trim(),\n '',\n 'Use ONLY the identifiers in this catalog. Never invent a step type, transition trigger, activity type, command id, function name or event name that is not listed here.',\n '',\n JSON.stringify(catalog),\n '',\n 'Rules:',\n '- Exactly one START step and at least one END step.',\n '- Every step except END has at least one outgoing transition, and every step except START is reachable.',\n '- Step, transition and activity ids are lowercase letters, numbers, hyphens and underscores only.',\n '- Activities belong to the transition that LEAVES the step whose work they do.',\n '- Reference run context as {{context.<path>}}, and declare every path you reference in contextSchema.input.fields.',\n invokeAgentRule,\n '- Call the workflows.validate_workflow_definition tool on your draft and fix every reported error before you return it.',\n '- Prefer the smallest graph that answers the request.',\n ].join('\\n')\n}\n\n/** How many repair attempts follow a rejected draft before the surface gives up. */\nexport const WORKFLOW_DRAFT_MAX_REPAIR_ATTEMPTS = 2\n\nexport interface WorkflowDraftRepairPromptInput {\n /** The prompt the previous attempt was authored against, catalog and all. */\n previousPrompt: string\n /** Exactly what the model returned, so it can see what it is amending. */\n rejectedDraft: unknown\n /** The validator's own messages, verbatim \u2014 `path: message`. */\n messages: string[]\n}\n\n/**\n * Build the follow-up message for a rejected draft.\n *\n * The validator already produces precise, per-path errors\n * (`transitions.3.activities.0.config.to: SEND_EMAIL activity requires \"to\"`).\n * Handing those to the human as a dead end while the model that can act on them\n * never sees them is the actual defect this repairs: the errors go BACK to the\n * author. The instruction is deliberately narrow \u2014 amend the listed paths and\n * change nothing else \u2014 because a model told to \"try again\" tends to rewrite\n * the graph and lose the parts that were already correct.\n */\nexport function buildWorkflowDraftRepairPrompt(input: WorkflowDraftRepairPromptInput): string {\n let rendered: string\n try {\n rendered = JSON.stringify(input.rejectedDraft)\n } catch {\n rendered = '(the previous response could not be serialized)'\n }\n return [\n input.previousPrompt,\n '',\n 'Your previous answer was rejected by the workflow schema. This was it:',\n '',\n rendered,\n '',\n 'Every path below failed validation. Fix exactly these and change nothing else:',\n ...input.messages.map((message) => `- ${message}`),\n '',\n 'Return the whole corrected workflow, in the same shape as before.',\n ].join('\\n')\n}\n\n// ---------------------------------------------------------------------------\n// The response\n// ---------------------------------------------------------------------------\n\nexport type WorkflowDraftInterpretation<TDefinition> =\n | { ok: true; definition: TDefinition; summary: string }\n | { ok: false; reason: 'malformedResponse'; messages: string[] }\n | { ok: false; reason: 'schemaError'; messages: string[] }\n\nexport interface InterpretWorkflowDraftInput<TDefinition> {\n raw: unknown\n /**\n * The one definition parser. Injected rather than imported so this module\n * stays pure and so no caller can end up on a second validator.\n */\n parseDefinition: (\n value: unknown,\n ) => { ok: true; definition: TDefinition } | { ok: false; messages: string[] }\n}\n\n/**\n * Map a model response onto a workflow definition.\n *\n * Two refusals, in escalating order, mirroring the Code view's gate: the object\n * does not match the generation contract at all (`malformedResponse`), or it\n * does but is not a workflow definition (`schemaError`). Both are NORMAL\n * outcomes a surface renders \u2014 never an exception, and never a partial apply.\n */\nexport function interpretWorkflowDraftObject<TDefinition>(\n input: InterpretWorkflowDraftInput<TDefinition>,\n): WorkflowDraftInterpretation<TDefinition> {\n const generation = workflowDraftGenerationSchema.safeParse(input.raw)\n if (!generation.success) {\n return {\n ok: false,\n reason: 'malformedResponse',\n messages: generation.error.issues.map(\n (issue) => `${issue.path.join('.') || '(root)'}: ${issue.message}`,\n ),\n }\n }\n\n const candidate: Record<string, unknown> = {\n steps: generation.data.steps,\n transitions: generation.data.transitions,\n }\n if (generation.data.contextSchema) candidate.contextSchema = generation.data.contextSchema\n\n const parsed = input.parseDefinition(candidate)\n if (!parsed.ok) return { ok: false, reason: 'schemaError', messages: parsed.messages }\n\n return { ok: true, definition: parsed.definition, summary: generation.data.summary }\n}\n\n// ---------------------------------------------------------------------------\n// The checkpoint name\n// ---------------------------------------------------------------------------\n\nexport const AI_CHECKPOINT_LABEL_MAX_LENGTH = 64\n\n/**\n * Name the undo entry an AI edit pushes.\n *\n * `prefix` is supplied translated by the caller (`useT`), so this stays pure\n * while the label an author reads stays localized. Truncation happens on a word\n * boundary where one is available, because a label cut mid-word reads like a\n * bug rather than an abbreviation.\n */\nexport function buildAiCheckpointLabel(\n prompt: string,\n options: { prefix: string; maxLength?: number } = { prefix: 'AI' },\n): string {\n const maxLength = options.maxLength ?? AI_CHECKPOINT_LABEL_MAX_LENGTH\n const normalized = prompt.replace(/\\s+/g, ' ').trim()\n if (!normalized) return options.prefix\n const budget = Math.max(1, maxLength - options.prefix.length - 2)\n if (normalized.length <= budget) return `${options.prefix}: ${normalized}`\n const clipped = normalized.slice(0, budget)\n const lastSpace = clipped.lastIndexOf(' ')\n const body = lastSpace > budget / 2 ? clipped.slice(0, lastSpace) : clipped\n return `${options.prefix}: ${body}\u2026`\n}\n\n// ---------------------------------------------------------------------------\n// Failure classification\n// ---------------------------------------------------------------------------\n\nexport type WorkflowDraftFailureKind = 'unavailable' | 'failed'\n\n/**\n * Error codes that mean \"there is no model to call here\", as opposed to \"the\n * call went wrong\".\n *\n * `no_provider_configured` / `api_key_missing` come from the AI model factory;\n * `agent_unknown` comes from the agent policy gate and is what a deployment\n * that has not run `yarn generate` answers. All three are the same thing to an\n * author: the feature is not set up, and the canvas is untouched.\n */\nconst UNAVAILABLE_ERROR_CODES = new Set([\n 'no_provider_configured',\n 'api_key_missing',\n 'agent_unknown',\n 'agent_features_denied',\n 'execution_mode_not_supported',\n])\n\n/**\n * Read the failure kind off a thrown value STRUCTURALLY, without importing the\n * AI runtime \u2014 this module is loaded by the browser bundle, and the runtime is\n * server-only and optional.\n */\nexport function classifyWorkflowDraftFailure(error: unknown): WorkflowDraftFailureKind {\n if (error && typeof error === 'object') {\n const code = (error as { code?: unknown }).code\n if (typeof code === 'string' && UNAVAILABLE_ERROR_CODES.has(code)) return 'unavailable'\n }\n return 'failed'\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createLogger } from "@open-mercato/shared/lib/logger";
|
|
2
|
+
const logger = createLogger("workflows");
|
|
3
|
+
async function resolveWorkflowDraftRunner() {
|
|
4
|
+
let runtime;
|
|
5
|
+
let registry;
|
|
6
|
+
try {
|
|
7
|
+
runtime = await import("@open-mercato/ai-assistant/modules/ai_assistant/lib/agent-runtime");
|
|
8
|
+
registry = await import("@open-mercato/ai-assistant/modules/ai_assistant/lib/agent-registry");
|
|
9
|
+
} catch (error) {
|
|
10
|
+
logger.debug("AI assistant runtime is not installed; workflow draft authoring is unavailable", {
|
|
11
|
+
err: error
|
|
12
|
+
});
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const runAiAgentObject = runtime.runAiAgentObject;
|
|
16
|
+
if (typeof runAiAgentObject !== "function") return null;
|
|
17
|
+
return async (input) => {
|
|
18
|
+
if (typeof registry.loadAgentRegistry === "function") await registry.loadAgentRegistry();
|
|
19
|
+
const result = await runAiAgentObject({
|
|
20
|
+
agentId: input.agentId,
|
|
21
|
+
input: input.prompt,
|
|
22
|
+
authContext: input.authContext,
|
|
23
|
+
container: input.container,
|
|
24
|
+
// Object-mode tool loop: the agent's one read-only tool
|
|
25
|
+
// (workflows.validate_workflow_definition) lets it self-correct against
|
|
26
|
+
// the real definition schema before returning. The runtime's `enableTools`
|
|
27
|
+
// branch still finalizes through `Output.object`, so `mode` stays
|
|
28
|
+
// 'generate' and the assertion below is unaffected.
|
|
29
|
+
enableTools: true,
|
|
30
|
+
output: { schemaName: input.schemaName, schema: input.schema, mode: "generate" }
|
|
31
|
+
});
|
|
32
|
+
if (result.mode !== "generate") {
|
|
33
|
+
throw Object.assign(new Error("[internal] Workflow draft agent must run in generate mode"), {
|
|
34
|
+
code: "execution_mode_not_supported"
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return result.object;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
resolveWorkflowDraftRunner
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=ai-draft-runner.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/workflows/lib/ai-draft-runner.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * The one seam between this module and the AI runtime (spec \u00A79).\n *\n * `@open-mercato/ai-assistant` is an OPTIONAL peer of `@open-mercato/core`: a\n * deployment can ship without it, and until `yarn generate` has run the agent\n * registry does not know this module's agent either. So the runtime is reached\n * through a DYNAMIC import inside a try/catch \u2014 the same shape\n * `agent_orchestrator` uses to reach this module's disposition task, and the\n * same rule `packages/core/AGENTS.md` states for an optional peer.\n *\n * Absence is a NORMAL outcome here, not an error: `resolveWorkflowDraftRunner`\n * answers `null`, the route reports \"AI authoring is not available\", and the\n * canvas is untouched. Tests stub THIS module rather than the AI package, so no\n * test path can reach a real model.\n *\n * SERVER ONLY. Never import from a client component.\n */\n\nimport type { AwilixContainer } from 'awilix'\nimport type { ZodTypeAny } from 'zod'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('workflows')\n\nexport interface WorkflowDraftAuthContext {\n tenantId: string | null\n organizationId: string | null\n userId: string\n features: string[]\n isSuperAdmin: boolean\n}\n\nexport interface WorkflowDraftRunnerInput {\n agentId: string\n prompt: string\n schemaName: string\n schema: ZodTypeAny\n authContext: WorkflowDraftAuthContext\n container: AwilixContainer\n}\n\n/** Whatever the model produced, unvalidated \u2014 the caller owns interpretation. */\nexport type WorkflowDraftRunner = (input: WorkflowDraftRunnerInput) => Promise<unknown>\n\ntype AgentRuntimeModule = {\n runAiAgentObject?: (input: Record<string, unknown>) => Promise<{ mode: string; object: unknown }>\n}\n\ntype AgentRegistryModule = {\n loadAgentRegistry?: () => Promise<unknown>\n}\n\n/**\n * Resolve the object-mode runner, or `null` when the AI runtime is not\n * installed. Never throws: a missing optional peer is a configuration fact, not\n * a failure to report as a stack trace.\n */\nexport async function resolveWorkflowDraftRunner(): Promise<WorkflowDraftRunner | null> {\n let runtime: AgentRuntimeModule\n let registry: AgentRegistryModule\n try {\n runtime = (await import(\n '@open-mercato/ai-assistant/modules/ai_assistant/lib/agent-runtime'\n )) as unknown as AgentRuntimeModule\n registry = (await import(\n '@open-mercato/ai-assistant/modules/ai_assistant/lib/agent-registry'\n )) as unknown as AgentRegistryModule\n } catch (error) {\n logger.debug('AI assistant runtime is not installed; workflow draft authoring is unavailable', {\n err: error,\n })\n return null\n }\n\n const runAiAgentObject = runtime.runAiAgentObject\n if (typeof runAiAgentObject !== 'function') return null\n\n return async (input) => {\n // The generated agent registry is what makes this module's agent\n // resolvable; without it the runtime answers `agent_unknown`, which the\n // caller classifies as \"unavailable\".\n if (typeof registry.loadAgentRegistry === 'function') await registry.loadAgentRegistry()\n\n const result = await runAiAgentObject({\n agentId: input.agentId,\n input: input.prompt,\n authContext: input.authContext,\n container: input.container,\n // Object-mode tool loop: the agent's one read-only tool\n // (workflows.validate_workflow_definition) lets it self-correct against\n // the real definition schema before returning. The runtime's `enableTools`\n // branch still finalizes through `Output.object`, so `mode` stays\n // 'generate' and the assertion below is unaffected.\n enableTools: true,\n output: { schemaName: input.schemaName, schema: input.schema, mode: 'generate' },\n })\n\n if (result.mode !== 'generate') {\n throw Object.assign(new Error('[internal] Workflow draft agent must run in generate mode'), {\n code: 'execution_mode_not_supported',\n })\n }\n return result.object\n }\n}\n"],
|
|
5
|
+
"mappings": "AAoBA,SAAS,oBAAoB;AAE7B,MAAM,SAAS,aAAa,WAAW;AAmCvC,eAAsB,6BAAkE;AACtF,MAAI;AACJ,MAAI;AACJ,MAAI;AACF,cAAW,MAAM,OACf,mEACF;AACA,eAAY,MAAM,OAChB,oEACF;AAAA,EACF,SAAS,OAAO;AACd,WAAO,MAAM,kFAAkF;AAAA,MAC7F,KAAK;AAAA,IACP,CAAC;AACD,WAAO;AAAA,EACT;AAEA,QAAM,mBAAmB,QAAQ;AACjC,MAAI,OAAO,qBAAqB,WAAY,QAAO;AAEnD,SAAO,OAAO,UAAU;AAItB,QAAI,OAAO,SAAS,sBAAsB,WAAY,OAAM,SAAS,kBAAkB;AAEvF,UAAM,SAAS,MAAM,iBAAiB;AAAA,MACpC,SAAS,MAAM;AAAA,MACf,OAAO,MAAM;AAAA,MACb,aAAa,MAAM;AAAA,MACnB,WAAW,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAMjB,aAAa;AAAA,MACb,QAAQ,EAAE,YAAY,MAAM,YAAY,QAAQ,MAAM,QAAQ,MAAM,WAAW;AAAA,IACjF,CAAC;AAED,QAAI,OAAO,SAAS,YAAY;AAC9B,YAAM,OAAO,OAAO,IAAI,MAAM,2DAA2D,GAAG;AAAA,QAC1F,MAAM;AAAA,MACR,CAAC;AAAA,IACH;AACA,WAAO,OAAO;AAAA,EAChB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const WORKFLOW_GROUP_TOGGLE_EVENT = "workflow-annotation:toggle-group";
|
|
2
|
+
function requestWorkflowGroupToggle(nodeId) {
|
|
3
|
+
if (typeof window === "undefined") return;
|
|
4
|
+
window.dispatchEvent(new CustomEvent(WORKFLOW_GROUP_TOGGLE_EVENT, { detail: { nodeId } }));
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
WORKFLOW_GROUP_TOGGLE_EVENT,
|
|
8
|
+
requestWorkflowGroupToggle
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=annotation-events.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/workflows/lib/annotation-events.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Window bridge for annotation affordances rendered inside React Flow.\n *\n * Group collapse is toggled from a button inside the node, which React Flow\n * renders in its own transformed plane \u2014 the same reason the node delete button\n * and the route chips announce on `window` instead of bubbling a click the page\n * would have to reconstruct.\n */\n\nexport const WORKFLOW_GROUP_TOGGLE_EVENT = 'workflow-annotation:toggle-group'\n\nexport function requestWorkflowGroupToggle(nodeId: string): void {\n if (typeof window === 'undefined') return\n window.dispatchEvent(new CustomEvent(WORKFLOW_GROUP_TOGGLE_EVENT, { detail: { nodeId } }))\n}\n"],
|
|
5
|
+
"mappings": "AASO,MAAM,8BAA8B;AAEpC,SAAS,2BAA2B,QAAsB;AAC/D,MAAI,OAAO,WAAW,YAAa;AACnC,SAAO,cAAc,IAAI,YAAY,6BAA6B,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;AAC3F;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
const OTHERWISE_ROUTE_PRIORITY = 0;
|
|
2
|
+
const FIRST_CASE_ROUTE_PRIORITY = 100;
|
|
3
|
+
const CASE_ROUTE_PRIORITY_STEP = 10;
|
|
4
|
+
function edgeData(edge) {
|
|
5
|
+
return edge.data ?? {};
|
|
6
|
+
}
|
|
7
|
+
function firstRuleId(preConditions) {
|
|
8
|
+
if (!Array.isArray(preConditions) || preConditions.length === 0) return null;
|
|
9
|
+
const [first] = preConditions;
|
|
10
|
+
if (typeof first === "string") return first;
|
|
11
|
+
if (first && typeof first === "object" && typeof first.ruleId === "string") {
|
|
12
|
+
return first.ruleId;
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
function asGroupCondition(value) {
|
|
17
|
+
if (!value || typeof value !== "object") return null;
|
|
18
|
+
const candidate = value;
|
|
19
|
+
if (typeof candidate.operator !== "string" || !Array.isArray(candidate.rules)) return null;
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
function readCaseValue(condition) {
|
|
23
|
+
const group = asGroupCondition(condition);
|
|
24
|
+
const rules = group ? group.rules : [];
|
|
25
|
+
const [firstRule] = rules;
|
|
26
|
+
if (!firstRule || typeof firstRule !== "object") return void 0;
|
|
27
|
+
const simple = firstRule;
|
|
28
|
+
if (simple.value === void 0 || simple.value === null) return void 0;
|
|
29
|
+
return String(simple.value);
|
|
30
|
+
}
|
|
31
|
+
function readCaseField(condition) {
|
|
32
|
+
const group = asGroupCondition(condition);
|
|
33
|
+
const rules = group ? group.rules : [];
|
|
34
|
+
const [firstRule] = rules;
|
|
35
|
+
if (!firstRule || typeof firstRule !== "object") return void 0;
|
|
36
|
+
const simple = firstRule;
|
|
37
|
+
return typeof simple.field === "string" && simple.field.length > 0 ? simple.field : void 0;
|
|
38
|
+
}
|
|
39
|
+
const BRANCHING_NODE_TYPES = ["ifElse", "switch"];
|
|
40
|
+
function isBranchingNodeType(nodeType) {
|
|
41
|
+
return typeof nodeType === "string" && BRANCHING_NODE_TYPES.includes(nodeType);
|
|
42
|
+
}
|
|
43
|
+
function outgoingRouteEdges(edges, nodeId) {
|
|
44
|
+
return edges.filter((edge) => edge.source === nodeId && edge.type !== "workflowDataMapping");
|
|
45
|
+
}
|
|
46
|
+
function buildCaseCondition(field, caseValue) {
|
|
47
|
+
return {
|
|
48
|
+
operator: "AND",
|
|
49
|
+
rules: [{ field, operator: "==", value: caseValue }]
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function readBranchingRoutes(edges, nodeId) {
|
|
53
|
+
return outgoingRouteEdges(edges, nodeId).map((edge) => {
|
|
54
|
+
const data = edgeData(edge);
|
|
55
|
+
const condition = asGroupCondition(data.condition);
|
|
56
|
+
const ruleId = firstRuleId(data.preConditions);
|
|
57
|
+
const kind = condition || ruleId ? "case" : "otherwise";
|
|
58
|
+
return {
|
|
59
|
+
transitionId: edge.id,
|
|
60
|
+
toStepId: edge.target,
|
|
61
|
+
kind,
|
|
62
|
+
caseLabel: data.caseLabel ?? data.transitionName ?? data.label ?? void 0,
|
|
63
|
+
caseValue: data.caseValue ?? readCaseValue(data.condition),
|
|
64
|
+
mode: ruleId ? "rule" : "inline",
|
|
65
|
+
condition,
|
|
66
|
+
ruleId
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function readSwitchField(edges, nodeId) {
|
|
71
|
+
for (const edge of outgoingRouteEdges(edges, nodeId)) {
|
|
72
|
+
const field = readCaseField(edgeData(edge).condition);
|
|
73
|
+
if (field) return field;
|
|
74
|
+
}
|
|
75
|
+
return "";
|
|
76
|
+
}
|
|
77
|
+
function ensureOtherwiseRoute(routes) {
|
|
78
|
+
if (routes.length === 0) return routes;
|
|
79
|
+
let otherwiseIndex = -1;
|
|
80
|
+
for (let index = routes.length - 1; index >= 0; index -= 1) {
|
|
81
|
+
if (routes[index].kind === "otherwise") {
|
|
82
|
+
otherwiseIndex = index;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const designatedIndex = otherwiseIndex >= 0 ? otherwiseIndex : routes.length - 1;
|
|
87
|
+
return routes.map(
|
|
88
|
+
(route, index) => index === designatedIndex ? { ...route, kind: "otherwise", condition: null, ruleId: null, caseValue: void 0 } : { ...route, kind: "case" }
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
function casePriority(caseIndex) {
|
|
92
|
+
return FIRST_CASE_ROUTE_PRIORITY - caseIndex * CASE_ROUTE_PRIORITY_STEP;
|
|
93
|
+
}
|
|
94
|
+
function applyRoutes(edges, nodeId, routes, options) {
|
|
95
|
+
const normalized = ensureOtherwiseRoute(routes);
|
|
96
|
+
const byTransitionId = new Map(normalized.map((route) => [route.transitionId, route]));
|
|
97
|
+
let caseIndex = 0;
|
|
98
|
+
const priorityByTransitionId = /* @__PURE__ */ new Map();
|
|
99
|
+
for (const route of normalized) {
|
|
100
|
+
if (route.kind === "otherwise") {
|
|
101
|
+
priorityByTransitionId.set(route.transitionId, OTHERWISE_ROUTE_PRIORITY);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
priorityByTransitionId.set(route.transitionId, casePriority(caseIndex));
|
|
105
|
+
caseIndex += 1;
|
|
106
|
+
}
|
|
107
|
+
return edges.map((edge) => {
|
|
108
|
+
if (edge.source !== nodeId) return edge;
|
|
109
|
+
const route = byTransitionId.get(edge.id);
|
|
110
|
+
if (!route) return edge;
|
|
111
|
+
const data = { ...edge.data ?? {} };
|
|
112
|
+
data.priority = priorityByTransitionId.get(route.transitionId) ?? OTHERWISE_ROUTE_PRIORITY;
|
|
113
|
+
if (route.kind === "otherwise") {
|
|
114
|
+
delete data.condition;
|
|
115
|
+
delete data.caseValue;
|
|
116
|
+
data.preConditions = [];
|
|
117
|
+
} else if (route.mode === "rule") {
|
|
118
|
+
delete data.condition;
|
|
119
|
+
data.preConditions = route.ruleId ? [{ ruleId: route.ruleId, required: true }] : [];
|
|
120
|
+
if (route.caseValue !== void 0) data.caseValue = route.caseValue;
|
|
121
|
+
} else {
|
|
122
|
+
const condition = options.resolveCondition(route);
|
|
123
|
+
if (condition) data.condition = condition;
|
|
124
|
+
else delete data.condition;
|
|
125
|
+
data.preConditions = [];
|
|
126
|
+
if (route.caseValue !== void 0) data.caseValue = route.caseValue;
|
|
127
|
+
}
|
|
128
|
+
if (route.caseLabel !== void 0) {
|
|
129
|
+
data.caseLabel = route.caseLabel;
|
|
130
|
+
data.transitionName = route.caseLabel;
|
|
131
|
+
data.label = route.caseLabel;
|
|
132
|
+
}
|
|
133
|
+
return { ...edge, data };
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function applyIfElseRoutes(edges, nodeId, routes) {
|
|
137
|
+
return applyRoutes(edges, nodeId, routes, {
|
|
138
|
+
resolveCondition: (route) => route.condition ?? null
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function applySwitchRoutes(edges, nodeId, value) {
|
|
142
|
+
const field = value.field.trim();
|
|
143
|
+
return applyRoutes(edges, nodeId, value.routes, {
|
|
144
|
+
resolveCondition: (route) => {
|
|
145
|
+
const caseValue = (route.caseValue ?? "").trim();
|
|
146
|
+
if (!field || !caseValue) return null;
|
|
147
|
+
return buildCaseCondition(field, caseValue);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function collectDuplicateCaseValues(routes) {
|
|
152
|
+
const seen = /* @__PURE__ */ new Set();
|
|
153
|
+
const duplicates = /* @__PURE__ */ new Set();
|
|
154
|
+
for (const route of routes) {
|
|
155
|
+
if (route.kind !== "case") continue;
|
|
156
|
+
const caseValue = (route.caseValue ?? "").trim();
|
|
157
|
+
if (!caseValue) continue;
|
|
158
|
+
if (seen.has(caseValue)) duplicates.add(caseValue);
|
|
159
|
+
else seen.add(caseValue);
|
|
160
|
+
}
|
|
161
|
+
return [...duplicates];
|
|
162
|
+
}
|
|
163
|
+
function hasOtherwiseRoute(routes) {
|
|
164
|
+
return routes.some((route) => route.kind === "otherwise");
|
|
165
|
+
}
|
|
166
|
+
export {
|
|
167
|
+
BRANCHING_NODE_TYPES,
|
|
168
|
+
CASE_ROUTE_PRIORITY_STEP,
|
|
169
|
+
FIRST_CASE_ROUTE_PRIORITY,
|
|
170
|
+
OTHERWISE_ROUTE_PRIORITY,
|
|
171
|
+
applyIfElseRoutes,
|
|
172
|
+
applySwitchRoutes,
|
|
173
|
+
buildCaseCondition,
|
|
174
|
+
collectDuplicateCaseValues,
|
|
175
|
+
ensureOtherwiseRoute,
|
|
176
|
+
hasOtherwiseRoute,
|
|
177
|
+
isBranchingNodeType,
|
|
178
|
+
outgoingRouteEdges,
|
|
179
|
+
readBranchingRoutes,
|
|
180
|
+
readSwitchField
|
|
181
|
+
};
|
|
182
|
+
//# sourceMappingURL=branching-routes.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/workflows/lib/branching-routes.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Edge } from '@xyflow/react'\nimport type { ConditionExpression, GroupCondition } from '@open-mercato/core/modules/business_rules/components/utils/conditionValidation'\n\n/**\n * If/Else + Switch route compilation (spec\n * 2026-07-26-workflows-ux-redesign.md section 5.8).\n *\n * Branching nodes are pure transition sugar: the inspectors in this module's\n * editor never invent a storage shape. Everything an author configures becomes\n * an ordinary outgoing transition \u2014 an inline `condition` in the business_rules\n * expression language (or a business-rule reference through `preConditions`),\n * plus a `priority` that makes the engine's existing highest-priority-first\n * evaluation pick cases before the unconditioned \"otherwise\" route.\n *\n * Pure module: no React, no ORM, no DI. The only xyflow dependency is the\n * `Edge` type.\n */\n\nexport const OTHERWISE_ROUTE_PRIORITY = 0\nexport const FIRST_CASE_ROUTE_PRIORITY = 100\nexport const CASE_ROUTE_PRIORITY_STEP = 10\n\nexport type BranchingConditionMode = 'inline' | 'rule'\n\nexport interface BranchingRouteDraft {\n transitionId: string\n toStepId: string\n kind: 'case' | 'otherwise'\n caseLabel?: string\n caseValue?: string\n mode: BranchingConditionMode\n condition?: GroupCondition | null\n ruleId?: string | null\n}\n\nexport interface SwitchRoutesValue {\n field: string\n routes: BranchingRouteDraft[]\n}\n\ninterface EdgeDataLike {\n condition?: unknown\n preConditions?: unknown\n transitionName?: string\n label?: string\n caseLabel?: string\n caseValue?: string\n}\n\nfunction edgeData(edge: Edge): EdgeDataLike {\n return (edge.data ?? {}) as EdgeDataLike\n}\n\nfunction firstRuleId(preConditions: unknown): string | null {\n if (!Array.isArray(preConditions) || preConditions.length === 0) return null\n const [first] = preConditions\n if (typeof first === 'string') return first\n if (first && typeof first === 'object' && typeof (first as { ruleId?: unknown }).ruleId === 'string') {\n return (first as { ruleId: string }).ruleId\n }\n return null\n}\n\nfunction asGroupCondition(value: unknown): GroupCondition | null {\n if (!value || typeof value !== 'object') return null\n const candidate = value as { operator?: unknown; rules?: unknown }\n if (typeof candidate.operator !== 'string' || !Array.isArray(candidate.rules)) return null\n return value as GroupCondition\n}\n\nfunction readCaseValue(condition: unknown): string | undefined {\n const group = asGroupCondition(condition)\n const rules = group ? (group.rules as ConditionExpression[]) : []\n const [firstRule] = rules\n if (!firstRule || typeof firstRule !== 'object') return undefined\n const simple = firstRule as { value?: unknown }\n if (simple.value === undefined || simple.value === null) return undefined\n return String(simple.value)\n}\n\nfunction readCaseField(condition: unknown): string | undefined {\n const group = asGroupCondition(condition)\n const rules = group ? (group.rules as ConditionExpression[]) : []\n const [firstRule] = rules\n if (!firstRule || typeof firstRule !== 'object') return undefined\n const simple = firstRule as { field?: unknown }\n return typeof simple.field === 'string' && simple.field.length > 0 ? simple.field : undefined\n}\n\nexport const BRANCHING_NODE_TYPES = ['ifElse', 'switch'] as const\n\nexport type BranchingNodeType = (typeof BRANCHING_NODE_TYPES)[number]\n\nexport function isBranchingNodeType(nodeType: string | undefined | null): nodeType is BranchingNodeType {\n return typeof nodeType === 'string' && (BRANCHING_NODE_TYPES as readonly string[]).includes(nodeType)\n}\n\nexport function outgoingRouteEdges(edges: Edge[], nodeId: string): Edge[] {\n return edges.filter((edge) => edge.source === nodeId && edge.type !== 'workflowDataMapping')\n}\n\n/**\n * Build the case condition for a Switch route: `field == value`, wrapped in the\n * single-rule AND group the ConditionBuilder and the rule evaluator both speak.\n */\nexport function buildCaseCondition(field: string, caseValue: string): GroupCondition {\n return {\n operator: 'AND',\n rules: [{ field, operator: '==', value: caseValue }],\n }\n}\n\n/**\n * Derive the inspector's view of a branching node's outgoing routes. A route\n * with neither an inline condition nor a business-rule reference IS the\n * otherwise route.\n */\nexport function readBranchingRoutes(edges: Edge[], nodeId: string): BranchingRouteDraft[] {\n return outgoingRouteEdges(edges, nodeId).map((edge) => {\n const data = edgeData(edge)\n const condition = asGroupCondition(data.condition)\n const ruleId = firstRuleId(data.preConditions)\n const kind: BranchingRouteDraft['kind'] = condition || ruleId ? 'case' : 'otherwise'\n return {\n transitionId: edge.id,\n toStepId: edge.target,\n kind,\n caseLabel: data.caseLabel ?? data.transitionName ?? data.label ?? undefined,\n caseValue: data.caseValue ?? readCaseValue(data.condition),\n mode: ruleId ? 'rule' : 'inline',\n condition,\n ruleId,\n }\n })\n}\n\n/**\n * Infer the switched field from the first case route that carries one, so the\n * inspector reopens on the field the author already picked.\n */\nexport function readSwitchField(edges: Edge[], nodeId: string): string {\n for (const edge of outgoingRouteEdges(edges, nodeId)) {\n const field = readCaseField(edgeData(edge).condition)\n if (field) return field\n }\n return ''\n}\n\n/**\n * Guarantee exactly one unconditioned otherwise route. The last route is\n * promoted when the author has not designated one, which is what makes the\n * otherwise route \"auto-created\" as soon as a branching node has routes.\n */\nexport function ensureOtherwiseRoute(routes: BranchingRouteDraft[]): BranchingRouteDraft[] {\n if (routes.length === 0) return routes\n // Scan from the end so a freshly connected branching node \u2014 where every\n // route still reads as unconditioned \u2014 keeps its FIRST connection as the\n // case route and its last as the otherwise.\n let otherwiseIndex = -1\n for (let index = routes.length - 1; index >= 0; index -= 1) {\n if (routes[index].kind === 'otherwise') {\n otherwiseIndex = index\n break\n }\n }\n const designatedIndex = otherwiseIndex >= 0 ? otherwiseIndex : routes.length - 1\n return routes.map((route, index) =>\n index === designatedIndex\n ? { ...route, kind: 'otherwise', condition: null, ruleId: null, caseValue: undefined }\n : { ...route, kind: 'case' },\n )\n}\n\nfunction casePriority(caseIndex: number): number {\n return FIRST_CASE_ROUTE_PRIORITY - caseIndex * CASE_ROUTE_PRIORITY_STEP\n}\n\ninterface ApplyRoutesOptions {\n resolveCondition: (route: BranchingRouteDraft) => GroupCondition | null\n}\n\nfunction applyRoutes(\n edges: Edge[],\n nodeId: string,\n routes: BranchingRouteDraft[],\n options: ApplyRoutesOptions,\n): Edge[] {\n const normalized = ensureOtherwiseRoute(routes)\n const byTransitionId = new Map(normalized.map((route) => [route.transitionId, route]))\n let caseIndex = 0\n const priorityByTransitionId = new Map<string, number>()\n for (const route of normalized) {\n if (route.kind === 'otherwise') {\n priorityByTransitionId.set(route.transitionId, OTHERWISE_ROUTE_PRIORITY)\n continue\n }\n priorityByTransitionId.set(route.transitionId, casePriority(caseIndex))\n caseIndex += 1\n }\n\n return edges.map((edge) => {\n if (edge.source !== nodeId) return edge\n const route = byTransitionId.get(edge.id)\n if (!route) return edge\n\n const data = { ...(edge.data ?? {}) } as Record<string, unknown>\n data.priority = priorityByTransitionId.get(route.transitionId) ?? OTHERWISE_ROUTE_PRIORITY\n\n if (route.kind === 'otherwise') {\n delete data.condition\n delete data.caseValue\n data.preConditions = []\n } else if (route.mode === 'rule') {\n delete data.condition\n data.preConditions = route.ruleId ? [{ ruleId: route.ruleId, required: true }] : []\n if (route.caseValue !== undefined) data.caseValue = route.caseValue\n } else {\n const condition = options.resolveCondition(route)\n if (condition) data.condition = condition\n else delete data.condition\n data.preConditions = []\n if (route.caseValue !== undefined) data.caseValue = route.caseValue\n }\n\n if (route.caseLabel !== undefined) {\n data.caseLabel = route.caseLabel\n data.transitionName = route.caseLabel\n data.label = route.caseLabel\n }\n\n return { ...edge, data }\n })\n}\n\n/**\n * Compile If/Else inspector state onto the node's outgoing edges. Case routes\n * keep whatever inline condition (or business-rule reference) the author chose;\n * the otherwise route is stripped of both.\n */\nexport function applyIfElseRoutes(edges: Edge[], nodeId: string, routes: BranchingRouteDraft[]): Edge[] {\n return applyRoutes(edges, nodeId, routes, {\n resolveCondition: (route) => route.condition ?? null,\n })\n}\n\n/**\n * Compile Switch inspector state onto the node's outgoing edges: every case\n * value becomes a generated `field == value` condition.\n */\nexport function applySwitchRoutes(edges: Edge[], nodeId: string, value: SwitchRoutesValue): Edge[] {\n const field = value.field.trim()\n return applyRoutes(edges, nodeId, value.routes, {\n resolveCondition: (route) => {\n const caseValue = (route.caseValue ?? '').trim()\n if (!field || !caseValue) return null\n return buildCaseCondition(field, caseValue)\n },\n })\n}\n\n/**\n * Case values that appear on more than one route. Duplicates make the second\n * route unreachable, because the engine stops at the first matching priority.\n */\nexport function collectDuplicateCaseValues(routes: BranchingRouteDraft[]): string[] {\n const seen = new Set<string>()\n const duplicates = new Set<string>()\n for (const route of routes) {\n if (route.kind !== 'case') continue\n const caseValue = (route.caseValue ?? '').trim()\n if (!caseValue) continue\n if (seen.has(caseValue)) duplicates.add(caseValue)\n else seen.add(caseValue)\n }\n return [...duplicates]\n}\n\nexport function hasOtherwiseRoute(routes: BranchingRouteDraft[]): boolean {\n return routes.some((route) => route.kind === 'otherwise')\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const SLA_BREACH_TRANSITION_KIND = "slaBreach";
|
|
2
|
+
const SLA_BREACH_SOURCE_HANDLE_ID = "slaBreach";
|
|
3
|
+
function isSlaBreachTransition(transition) {
|
|
4
|
+
return transition?.kind === SLA_BREACH_TRANSITION_KIND;
|
|
5
|
+
}
|
|
6
|
+
function excludeSlaBreachTransitions(transitions) {
|
|
7
|
+
return transitions.filter((transition) => !isSlaBreachTransition(transition));
|
|
8
|
+
}
|
|
9
|
+
function findSlaBreachTransition(definition, stepId) {
|
|
10
|
+
const candidates = (definition?.transitions ?? []).filter(
|
|
11
|
+
(transition) => transition.fromStepId === stepId && isSlaBreachTransition(transition)
|
|
12
|
+
);
|
|
13
|
+
if (candidates.length === 0) return null;
|
|
14
|
+
const ordered = [...candidates].sort((left, right) => (right.priority || 0) - (left.priority || 0));
|
|
15
|
+
return ordered[0] ?? null;
|
|
16
|
+
}
|
|
17
|
+
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
18
|
+
function resolveBreachReassignTarget(reassignTo) {
|
|
19
|
+
const target = typeof reassignTo === "string" ? reassignTo.trim() : "";
|
|
20
|
+
if (!target.length) return null;
|
|
21
|
+
if (UUID_PATTERN.test(target)) return { assignedTo: target, assignedToRoles: null };
|
|
22
|
+
return { assignedTo: null, assignedToRoles: [target] };
|
|
23
|
+
}
|
|
24
|
+
function resolveTaskBreachHandling(definition, stepId, onBreach) {
|
|
25
|
+
const wired = findSlaBreachTransition(definition, stepId);
|
|
26
|
+
if (wired) return { kind: "route", transition: wired };
|
|
27
|
+
const action = onBreach?.action;
|
|
28
|
+
if (action === "route") {
|
|
29
|
+
const bound = (definition?.transitions ?? []).find(
|
|
30
|
+
(transition) => transition.transitionId === onBreach?.transitionId && transition.fromStepId === stepId
|
|
31
|
+
);
|
|
32
|
+
return bound ? { kind: "route", transition: bound } : { kind: "none" };
|
|
33
|
+
}
|
|
34
|
+
if (action === "reassign") {
|
|
35
|
+
const target = resolveBreachReassignTarget(onBreach?.reassignTo);
|
|
36
|
+
return target ? { kind: "reassign", ...target } : { kind: "none" };
|
|
37
|
+
}
|
|
38
|
+
if (action === "notify") return { kind: "notify" };
|
|
39
|
+
return { kind: "none" };
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
SLA_BREACH_SOURCE_HANDLE_ID,
|
|
43
|
+
SLA_BREACH_TRANSITION_KIND,
|
|
44
|
+
excludeSlaBreachTransitions,
|
|
45
|
+
findSlaBreachTransition,
|
|
46
|
+
isSlaBreachTransition,
|
|
47
|
+
resolveBreachReassignTarget,
|
|
48
|
+
resolveTaskBreachHandling
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=breach-routing.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/workflows/lib/breach-routing.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Workflows Module - SLA breach routing (pure)\n *\n * Resolves what happens to a run when a USER_TASK's deadline passes, from the\n * definition alone \u2014 deliberately shaped like `lib/error-routing.ts`, which\n * answers the same kind of question for a failed step:\n *\n * 1. an outgoing transition marked `kind: 'slaBreach'` wins \u2014 the canvas form\n * of \"route the breach\";\n * 2. otherwise the step's `onBreach` action applies (`route` bound to a\n * durable transition id, `reassign`, or `notify`);\n * 3. otherwise nothing routes, which is exactly today's behavior.\n *\n * Every fall-through is FAIL-SAFE: an `onBreach: { action: 'route' }` whose\n * transition no longer exists on this step resolves to `none`, never to\n * \"follow whichever route happens to be valid\". Auto-routing a breach would\n * advance the run past work the author never said could be skipped \u2014 the\n * opposite of what a deadline means.\n *\n * PURE: no ORM, DI, React or registry imports. Engine call sites pass the plain\n * definition JSON.\n */\n\nimport type { TaskOnBreach } from '../data/validators'\n\nexport const SLA_BREACH_TRANSITION_KIND = 'slaBreach'\n\n/**\n * Canvas handle id a USER_TASK node exposes for its SLA-breach output, mirroring\n * `ERROR_SOURCE_HANDLE_ID`. A connection drawn from it compiles to a transition\n * with `kind: 'slaBreach'`.\n */\nexport const SLA_BREACH_SOURCE_HANDLE_ID = 'slaBreach'\n\nexport interface BreachRoutingTransitionLike {\n transitionId?: string\n fromStepId?: string\n toStepId?: string\n kind?: string\n priority?: number\n}\n\nexport interface BreachRoutingDefinitionLike {\n transitions?: BreachRoutingTransitionLike[]\n}\n\nexport type TaskBreachHandling =\n | { kind: 'route'; transition: BreachRoutingTransitionLike }\n | { kind: 'reassign'; assignedTo: string | null; assignedToRoles: string[] | null }\n | { kind: 'notify' }\n | { kind: 'none' }\n\n/**\n * A transition authored as the SLA-breach route. The discriminator is the same\n * additive optional `kind` field error routes use, so every stored definition\n * keeps its current meaning.\n */\nexport function isSlaBreachTransition(\n transition: BreachRoutingTransitionLike | null | undefined\n): boolean {\n return transition?.kind === SLA_BREACH_TRANSITION_KIND\n}\n\n/**\n * SLA-breach routes must never be taken by normal routing \u2014 they are reachable\n * only from a breach, exactly like error routes. Every routing lookup filters\n * through this helper.\n */\nexport function excludeSlaBreachTransitions<T extends BreachRoutingTransitionLike>(\n transitions: T[]\n): T[] {\n return transitions.filter((transition) => !isSlaBreachTransition(transition))\n}\n\n/**\n * Highest-priority outgoing SLA-breach route of a step. Ties keep definition\n * order, mirroring how `findValidTransitions` orders normal routes.\n */\nexport function findSlaBreachTransition(\n definition: BreachRoutingDefinitionLike | null | undefined,\n stepId: string\n): BreachRoutingTransitionLike | null {\n const candidates = (definition?.transitions ?? []).filter(\n (transition) => transition.fromStepId === stepId && isSlaBreachTransition(transition)\n )\n if (candidates.length === 0) return null\n const ordered = [...candidates].sort((left, right) => (right.priority || 0) - (left.priority || 0))\n return ordered[0] ?? null\n}\n\nconst UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i\n\n/**\n * The inspector's \"Reassign to\" field accepts a user id OR a role, which is\n * what its placeholder promises. A UUID addresses one person (`assigned_to`\n * holds a bare user id); anything else is a role NAME, which is the vocabulary\n * `assigned_to_roles` has always spoken.\n */\nexport function resolveBreachReassignTarget(\n reassignTo: string | null | undefined\n): { assignedTo: string | null; assignedToRoles: string[] | null } | null {\n const target = typeof reassignTo === 'string' ? reassignTo.trim() : ''\n if (!target.length) return null\n if (UUID_PATTERN.test(target)) return { assignedTo: target, assignedToRoles: null }\n return { assignedTo: null, assignedToRoles: [target] }\n}\n\n/**\n * The single decision point for a breached task, in precedence order:\n * wired SLA-breach route \u2192 the step's `onBreach` action \u2192 nothing.\n *\n * `none` is both the \"author configured nothing\" case and every malformed\n * configuration, so a definition that predates this feature \u2014 or one whose\n * breach route was deleted \u2014 behaves precisely as it did before.\n */\nexport function resolveTaskBreachHandling(\n definition: BreachRoutingDefinitionLike | null | undefined,\n stepId: string,\n onBreach: TaskOnBreach | null | undefined\n): TaskBreachHandling {\n const wired = findSlaBreachTransition(definition, stepId)\n if (wired) return { kind: 'route', transition: wired }\n\n const action = onBreach?.action\n if (action === 'route') {\n const bound = (definition?.transitions ?? []).find(\n (transition) =>\n transition.transitionId === onBreach?.transitionId &&\n transition.fromStepId === stepId\n )\n return bound ? { kind: 'route', transition: bound } : { kind: 'none' }\n }\n\n if (action === 'reassign') {\n const target = resolveBreachReassignTarget(onBreach?.reassignTo)\n return target ? { kind: 'reassign', ...target } : { kind: 'none' }\n }\n\n if (action === 'notify') return { kind: 'notify' }\n\n return { kind: 'none' }\n}\n"],
|
|
5
|
+
"mappings": "AAyBO,MAAM,6BAA6B;AAOnC,MAAM,8BAA8B;AAyBpC,SAAS,sBACd,YACS;AACT,SAAO,YAAY,SAAS;AAC9B;AAOO,SAAS,4BACd,aACK;AACL,SAAO,YAAY,OAAO,CAAC,eAAe,CAAC,sBAAsB,UAAU,CAAC;AAC9E;AAMO,SAAS,wBACd,YACA,QACoC;AACpC,QAAM,cAAc,YAAY,eAAe,CAAC,GAAG;AAAA,IACjD,CAAC,eAAe,WAAW,eAAe,UAAU,sBAAsB,UAAU;AAAA,EACtF;AACA,MAAI,WAAW,WAAW,EAAG,QAAO;AACpC,QAAM,UAAU,CAAC,GAAG,UAAU,EAAE,KAAK,CAAC,MAAM,WAAW,MAAM,YAAY,MAAM,KAAK,YAAY,EAAE;AAClG,SAAO,QAAQ,CAAC,KAAK;AACvB;AAEA,MAAM,eAAe;AAQd,SAAS,4BACd,YACwE;AACxE,QAAM,SAAS,OAAO,eAAe,WAAW,WAAW,KAAK,IAAI;AACpE,MAAI,CAAC,OAAO,OAAQ,QAAO;AAC3B,MAAI,aAAa,KAAK,MAAM,EAAG,QAAO,EAAE,YAAY,QAAQ,iBAAiB,KAAK;AAClF,SAAO,EAAE,YAAY,MAAM,iBAAiB,CAAC,MAAM,EAAE;AACvD;AAUO,SAAS,0BACd,YACA,QACA,UACoB;AACpB,QAAM,QAAQ,wBAAwB,YAAY,MAAM;AACxD,MAAI,MAAO,QAAO,EAAE,MAAM,SAAS,YAAY,MAAM;AAErD,QAAM,SAAS,UAAU;AACzB,MAAI,WAAW,SAAS;AACtB,UAAM,SAAS,YAAY,eAAe,CAAC,GAAG;AAAA,MAC5C,CAAC,eACC,WAAW,iBAAiB,UAAU,gBACtC,WAAW,eAAe;AAAA,IAC9B;AACA,WAAO,QAAQ,EAAE,MAAM,SAAS,YAAY,MAAM,IAAI,EAAE,MAAM,OAAO;AAAA,EACvE;AAEA,MAAI,WAAW,YAAY;AACzB,UAAM,SAAS,4BAA4B,UAAU,UAAU;AAC/D,WAAO,SAAS,EAAE,MAAM,YAAY,GAAG,OAAO,IAAI,EAAE,MAAM,OAAO;AAAA,EACnE;AAEA,MAAI,WAAW,SAAU,QAAO,EAAE,MAAM,SAAS;AAEjD,SAAO,EAAE,MAAM,OAAO;AACxB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|