@hotmeshio/long-tail 0.1.6 → 0.1.8
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/README.md +47 -5
- package/build/api/auth.d.ts +16 -0
- package/build/api/auth.js +53 -0
- package/build/api/bot-accounts.d.ts +137 -0
- package/build/api/bot-accounts.js +302 -0
- package/build/api/controlplane.d.ts +68 -0
- package/build/api/controlplane.js +158 -0
- package/build/api/dba.d.ts +42 -0
- package/build/api/dba.js +95 -0
- package/build/api/escalations.d.ts +271 -0
- package/build/api/escalations.js +892 -0
- package/build/api/exports.d.ts +90 -0
- package/build/api/exports.js +204 -0
- package/build/api/index.d.ts +18 -0
- package/build/api/index.js +54 -0
- package/build/api/insight.d.ts +86 -0
- package/build/api/insight.js +147 -0
- package/build/api/maintenance.d.ts +22 -0
- package/build/api/maintenance.js +43 -0
- package/build/api/mcp-runs.d.ts +43 -0
- package/build/api/mcp-runs.js +89 -0
- package/build/api/mcp.d.ts +160 -0
- package/build/api/mcp.js +320 -0
- package/build/api/namespaces.d.ts +20 -0
- package/build/{routes/escalations/helpers.js → api/namespaces.js} +35 -10
- package/build/api/roles.d.ts +88 -0
- package/build/api/roles.js +217 -0
- package/build/api/settings.d.ts +10 -0
- package/build/api/settings.js +43 -0
- package/build/api/tasks.d.ts +70 -0
- package/build/api/tasks.js +139 -0
- package/build/api/users.d.ts +115 -0
- package/build/api/users.js +228 -0
- package/build/api/workflow-sets.d.ts +77 -0
- package/build/api/workflow-sets.js +170 -0
- package/build/api/workflows.d.ts +158 -0
- package/build/api/workflows.js +407 -0
- package/build/api/yaml-workflows.d.ts +282 -0
- package/build/api/yaml-workflows.js +751 -0
- package/build/examples/types/envelopes.d.ts +27 -0
- package/build/examples/types/index.d.ts +1 -1
- package/build/examples/workers.js +8 -0
- package/build/examples/workflows/assembly-line/activities.d.ts +28 -0
- package/build/examples/workflows/assembly-line/activities.js +53 -0
- package/build/examples/workflows/assembly-line/index.d.ts +17 -0
- package/build/examples/workflows/assembly-line/index.js +60 -0
- package/build/examples/workflows/assembly-line/iterator.d.ts +12 -0
- package/build/examples/workflows/assembly-line/iterator.js +54 -0
- package/build/examples/workflows/assembly-line/reverter.d.ts +18 -0
- package/build/examples/workflows/assembly-line/reverter.js +89 -0
- package/build/examples/workflows/assembly-line/types.d.ts +25 -0
- package/build/examples/workflows/assembly-line/types.js +8 -0
- package/build/examples/workflows/assembly-line/worker.d.ts +13 -0
- package/build/examples/workflows/assembly-line/worker.js +81 -0
- package/build/index.d.ts +4 -0
- package/build/index.js +6 -1
- package/build/lib/db/schemas/004_workflow_sets.sql +29 -0
- package/build/lib/db/schemas/005_unique_graph_topic.sql +7 -0
- package/build/lib/db/schemas/011_system_workflow_configs.sql +7 -0
- package/build/lib/events/callback.d.ts +41 -0
- package/build/lib/events/callback.js +98 -0
- package/build/modules/config.js +1 -1
- package/build/routes/auth.js +37 -36
- package/build/routes/bot-accounts.js +34 -164
- package/build/routes/controlplane.js +20 -60
- package/build/routes/dba.js +18 -28
- package/build/routes/escalations/bulk.js +17 -192
- package/build/routes/escalations/list.js +51 -75
- package/build/routes/escalations/resolve.js +3 -193
- package/build/routes/escalations/single.js +13 -122
- package/build/routes/exports.js +44 -95
- package/build/routes/index.js +2 -0
- package/build/routes/insight.js +46 -88
- package/build/routes/maintenance.js +41 -17
- package/build/routes/mcp-runs.js +52 -60
- package/build/routes/mcp.js +49 -177
- package/build/routes/namespaces.js +9 -20
- package/build/routes/roles.js +23 -97
- package/build/routes/settings.js +37 -25
- package/build/routes/tasks.js +28 -64
- package/build/routes/users.js +24 -113
- package/build/routes/workflow-sets.d.ts +2 -0
- package/build/routes/workflow-sets.js +98 -0
- package/build/routes/workflows/config.js +23 -57
- package/build/routes/workflows/discovery.js +11 -85
- package/build/routes/workflows/invocation.js +28 -90
- package/build/routes/yaml-workflows/cron.js +12 -61
- package/build/routes/yaml-workflows/crud.js +30 -223
- package/build/routes/yaml-workflows/deployment.js +15 -115
- package/build/routes/yaml-workflows/versions.js +20 -58
- package/build/sdk/index.d.ts +338 -0
- package/build/sdk/index.js +299 -0
- package/build/services/controlplane/index.d.ts +1 -2
- package/build/services/controlplane/index.js +3 -3
- package/build/services/controlplane/sql.d.ts +2 -2
- package/build/services/controlplane/sql.js +4 -5
- package/build/services/controlplane/types.d.ts +1 -0
- package/build/services/export/index.js +6 -1
- package/build/services/hotmesh-utils.js +2 -4
- package/build/services/insight/index.d.ts +7 -0
- package/build/services/insight/index.js +30 -0
- package/build/services/mcp/client/tools.js +13 -1
- package/build/services/mcp-runs/sql.js +1 -1
- package/build/services/workflow-invocation.d.ts +15 -2
- package/build/services/workflow-invocation.js +11 -6
- package/build/services/workflow-sets/db.d.ts +16 -0
- package/build/services/workflow-sets/db.js +78 -0
- package/build/services/workflow-sets/index.d.ts +1 -0
- package/build/services/workflow-sets/index.js +11 -0
- package/build/services/workflow-sets/sql.d.ts +6 -0
- package/build/services/workflow-sets/sql.js +24 -0
- package/build/services/yaml-workflow/db-utils.d.ts +1 -0
- package/build/services/yaml-workflow/db-utils.js +4 -0
- package/build/services/yaml-workflow/db.d.ts +5 -0
- package/build/services/yaml-workflow/db.js +17 -0
- package/build/services/yaml-workflow/pipeline/build/wiring.js +14 -1
- package/build/services/yaml-workflow/pipeline/prompts.d.ts +1 -1
- package/build/services/yaml-workflow/pipeline/prompts.js +1 -1
- package/build/services/yaml-workflow/sql.d.ts +2 -1
- package/build/services/yaml-workflow/sql.js +8 -3
- package/build/services/yaml-workflow/types.d.ts +3 -0
- package/build/services/yaml-workflow/workers/callbacks.js +7 -1
- package/build/services/yaml-workflow/workers/register.js +7 -0
- package/build/start/adapters.js +4 -0
- package/build/system/index.js +6 -0
- package/build/system/mcp-servers/knowledge.js +1 -1
- package/build/system/seed/server-definitions.js +2 -1
- package/build/system/workflows/mcp-workflow-builder/activities/index.d.ts +1 -1
- package/build/system/workflows/mcp-workflow-builder/activities/index.js +2 -1
- package/build/system/workflows/mcp-workflow-builder/activities/tool-loader.d.ts +6 -0
- package/build/system/workflows/mcp-workflow-builder/activities/tool-loader.js +26 -0
- package/build/system/workflows/mcp-workflow-builder/index.js +26 -2
- package/build/system/workflows/mcp-workflow-builder/prompts.js +104 -35
- package/build/system/workflows/mcp-workflow-planner/activities/analyze.d.ts +11 -0
- package/build/system/workflows/mcp-workflow-planner/activities/analyze.js +36 -0
- package/build/system/workflows/mcp-workflow-planner/activities/index.d.ts +3 -0
- package/build/system/workflows/mcp-workflow-planner/activities/index.js +12 -0
- package/build/system/workflows/mcp-workflow-planner/activities/persist.d.ts +19 -0
- package/build/system/workflows/mcp-workflow-planner/activities/persist.js +55 -0
- package/build/system/workflows/mcp-workflow-planner/activities/plan.d.ts +10 -0
- package/build/system/workflows/mcp-workflow-planner/activities/plan.js +43 -0
- package/build/system/workflows/mcp-workflow-planner/index.d.ts +7 -0
- package/build/system/workflows/mcp-workflow-planner/index.js +152 -0
- package/build/system/workflows/mcp-workflow-planner/prompts.d.ts +7 -0
- package/build/system/workflows/mcp-workflow-planner/prompts.js +77 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/types/index.d.ts +1 -0
- package/build/types/sdk.d.ts +27 -0
- package/build/types/sdk.js +2 -0
- package/build/types/workflow-set.d.ts +44 -0
- package/build/types/workflow-set.js +5 -0
- package/dashboard/dist/assets/{AdminDashboard-BXkKGkb5.js → AdminDashboard-B15jSEV2.js} +2 -2
- package/dashboard/dist/assets/{AdminDashboard-BXkKGkb5.js.map → AdminDashboard-B15jSEV2.js.map} +1 -1
- package/dashboard/dist/assets/{AvailableEscalationsPage-DcH592mc.js → AvailableEscalationsPage-0V2yvKak.js} +2 -2
- package/dashboard/dist/assets/{AvailableEscalationsPage-DcH592mc.js.map → AvailableEscalationsPage-0V2yvKak.js.map} +1 -1
- package/dashboard/dist/assets/BotPicker-B4UxHcek.js +2 -0
- package/dashboard/dist/assets/{BotPicker-A6LtzyuO.js.map → BotPicker-B4UxHcek.js.map} +1 -1
- package/dashboard/dist/assets/{CollapsibleSection-C7nL2_mv.js → CollapsibleSection-BBexNWVd.js} +2 -2
- package/dashboard/dist/assets/{CollapsibleSection-C7nL2_mv.js.map → CollapsibleSection-BBexNWVd.js.map} +1 -1
- package/dashboard/dist/assets/{ConfirmDeleteModal-CWFwJrSl.js → ConfirmDeleteModal-DlPDJSq_.js} +2 -2
- package/dashboard/dist/assets/{ConfirmDeleteModal-CWFwJrSl.js.map → ConfirmDeleteModal-DlPDJSq_.js.map} +1 -1
- package/dashboard/dist/assets/{CopyableId-DbZ5c3jh.js → CopyableId-BxHW1ahb.js} +2 -2
- package/dashboard/dist/assets/{CopyableId-DbZ5c3jh.js.map → CopyableId-BxHW1ahb.js.map} +1 -1
- package/dashboard/dist/assets/{CredentialsPage-ClWkmLPu.js → CredentialsPage-Bp_Y1Szk.js} +2 -2
- package/dashboard/dist/assets/{CredentialsPage-ClWkmLPu.js.map → CredentialsPage-Bp_Y1Szk.js.map} +1 -1
- package/dashboard/dist/assets/{CustomDurationPicker-CtH2hReF.js → CustomDurationPicker-ByBFqXSO.js} +2 -2
- package/dashboard/dist/assets/{CustomDurationPicker-CtH2hReF.js.map → CustomDurationPicker-ByBFqXSO.js.map} +1 -1
- package/dashboard/dist/assets/{DataTable-CM5ZcpPi.js → DataTable-DyIXg-tQ.js} +2 -2
- package/dashboard/dist/assets/{DataTable-CM5ZcpPi.js.map → DataTable-DyIXg-tQ.js.map} +1 -1
- package/dashboard/dist/assets/{ElapsedCell-CwqavyeC.js → ElapsedCell-BgnA0qpS.js} +2 -2
- package/dashboard/dist/assets/{ElapsedCell-CwqavyeC.js.map → ElapsedCell-BgnA0qpS.js.map} +1 -1
- package/dashboard/dist/assets/{EmptyState-BBn78pmm.js → EmptyState-DlMImvgm.js} +2 -2
- package/dashboard/dist/assets/{EmptyState-BBn78pmm.js.map → EmptyState-DlMImvgm.js.map} +1 -1
- package/dashboard/dist/assets/{EscalationsOverview-BcJ2E3X7.js → EscalationsOverview-D90kdfw1.js} +2 -2
- package/dashboard/dist/assets/{EscalationsOverview-BcJ2E3X7.js.map → EscalationsOverview-D90kdfw1.js.map} +1 -1
- package/dashboard/dist/assets/{EventTable-C1en_KZ0.js → EventTable-BNxtlgNz.js} +2 -2
- package/dashboard/dist/assets/{EventTable-C1en_KZ0.js.map → EventTable-BNxtlgNz.js.map} +1 -1
- package/dashboard/dist/assets/{FilterBar-CZTlrLQT.js → FilterBar-BTiaAhCx.js} +2 -2
- package/dashboard/dist/assets/{FilterBar-CZTlrLQT.js.map → FilterBar-BTiaAhCx.js.map} +1 -1
- package/dashboard/dist/assets/{ListToolbar-Cdbsapig.js → ListToolbar-BUcagSCn.js} +2 -2
- package/dashboard/dist/assets/{ListToolbar-Cdbsapig.js.map → ListToolbar-BUcagSCn.js.map} +1 -1
- package/dashboard/dist/assets/{McpOverview-CSpEJxKa.js → McpOverview-B-tCvz8C.js} +2 -2
- package/dashboard/dist/assets/{McpOverview-CSpEJxKa.js.map → McpOverview-B-tCvz8C.js.map} +1 -1
- package/dashboard/dist/assets/McpQueryDetailPage-DPlF1wYb.js +5 -0
- package/dashboard/dist/assets/McpQueryDetailPage-DPlF1wYb.js.map +1 -0
- package/dashboard/dist/assets/McpQueryPage-Bz7AdcfR.js +2 -0
- package/dashboard/dist/assets/McpQueryPage-Bz7AdcfR.js.map +1 -0
- package/dashboard/dist/assets/{McpRunDetailPage-9xdxgG4d.js → McpRunDetailPage-Di_qpL2V.js} +2 -2
- package/dashboard/dist/assets/{McpRunDetailPage-9xdxgG4d.js.map → McpRunDetailPage-Di_qpL2V.js.map} +1 -1
- package/dashboard/dist/assets/{McpRunsPage-wWLqHsd4.js → McpRunsPage-BBgybBEa.js} +2 -2
- package/dashboard/dist/assets/{McpRunsPage-wWLqHsd4.js.map → McpRunsPage-BBgybBEa.js.map} +1 -1
- package/dashboard/dist/assets/{Modal-kB_P7ZOr.js → Modal-CaJ0gTEa.js} +2 -2
- package/dashboard/dist/assets/{Modal-kB_P7ZOr.js.map → Modal-CaJ0gTEa.js.map} +1 -1
- package/dashboard/dist/assets/OperatorDashboard-DDfMmrmR.js +2 -0
- package/dashboard/dist/assets/{OperatorDashboard-jc0vrgDI.js.map → OperatorDashboard-DDfMmrmR.js.map} +1 -1
- package/dashboard/dist/assets/{PageHeader-NkOeBR05.js → PageHeader-C5D-G5rp.js} +2 -2
- package/dashboard/dist/assets/{PageHeader-NkOeBR05.js.map → PageHeader-C5D-G5rp.js.map} +1 -1
- package/dashboard/dist/assets/{PageHeaderWithStats-ywNhrmFK.js → PageHeaderWithStats-DCa2eZh2.js} +2 -2
- package/dashboard/dist/assets/{PageHeaderWithStats-ywNhrmFK.js.map → PageHeaderWithStats-DCa2eZh2.js.map} +1 -1
- package/dashboard/dist/assets/{PriorityBadge-B2MQbSxy.js → PriorityBadge-DTHq6OUZ.js} +2 -2
- package/dashboard/dist/assets/{PriorityBadge-B2MQbSxy.js.map → PriorityBadge-DTHq6OUZ.js.map} +1 -1
- package/dashboard/dist/assets/{ProcessDetailPage-B7z7IdqE.js → ProcessDetailPage-fC4dhrd0.js} +2 -2
- package/dashboard/dist/assets/{ProcessDetailPage-B7z7IdqE.js.map → ProcessDetailPage-fC4dhrd0.js.map} +1 -1
- package/dashboard/dist/assets/{ProcessesListPage-C-uHadO6.js → ProcessesListPage-CL2MY8uD.js} +2 -2
- package/dashboard/dist/assets/{ProcessesListPage-C-uHadO6.js.map → ProcessesListPage-CL2MY8uD.js.map} +1 -1
- package/dashboard/dist/assets/{RolePill-C1dgC-fK.js → RolePill-kgKPANly.js} +2 -2
- package/dashboard/dist/assets/{RolePill-C1dgC-fK.js.map → RolePill-kgKPANly.js.map} +1 -1
- package/dashboard/dist/assets/{RolesPage-BSxrD1vm.js → RolesPage-Be2lXTHD.js} +2 -2
- package/dashboard/dist/assets/{RolesPage-BSxrD1vm.js.map → RolesPage-Be2lXTHD.js.map} +1 -1
- package/dashboard/dist/assets/{RowActions-lYaHGI-v.js → RowActions-DIzJCwqR.js} +2 -2
- package/dashboard/dist/assets/{RowActions-lYaHGI-v.js.map → RowActions-DIzJCwqR.js.map} +1 -1
- package/dashboard/dist/assets/{StatCard-v2TiITVr.js → StatCard-CRi2Jy6t.js} +2 -2
- package/dashboard/dist/assets/{StatCard-v2TiITVr.js.map → StatCard-CRi2Jy6t.js.map} +1 -1
- package/dashboard/dist/assets/{StatusBadge-DWlxevgG.js → StatusBadge-BETI_8Mr.js} +2 -2
- package/dashboard/dist/assets/{StatusBadge-DWlxevgG.js.map → StatusBadge-BETI_8Mr.js.map} +1 -1
- package/dashboard/dist/assets/{StepIndicator-CRM4ft28.js → StepIndicator-DjpMqCjz.js} +2 -2
- package/dashboard/dist/assets/{StepIndicator-CRM4ft28.js.map → StepIndicator-DjpMqCjz.js.map} +1 -1
- package/dashboard/dist/assets/{StickyPagination-CF0EToEU.js → StickyPagination-BZbExQ9t.js} +2 -2
- package/dashboard/dist/assets/{StickyPagination-CF0EToEU.js.map → StickyPagination-BZbExQ9t.js.map} +1 -1
- package/dashboard/dist/assets/{SwimlaneTimeline-CNlj7fgg.js → SwimlaneTimeline-DZthQyhR.js} +2 -2
- package/dashboard/dist/assets/{SwimlaneTimeline-CNlj7fgg.js.map → SwimlaneTimeline-DZthQyhR.js.map} +1 -1
- package/dashboard/dist/assets/{TagInput-CH8qMGhC.js → TagInput-CukbOfYn.js} +2 -2
- package/dashboard/dist/assets/{TagInput-CH8qMGhC.js.map → TagInput-CukbOfYn.js.map} +1 -1
- package/dashboard/dist/assets/{TaskDetailPage-CdWo-6mu.js → TaskDetailPage-CIZHIKo9.js} +2 -2
- package/dashboard/dist/assets/{TaskDetailPage-CdWo-6mu.js.map → TaskDetailPage-CIZHIKo9.js.map} +1 -1
- package/dashboard/dist/assets/{TaskQueuePill-BPj4ogVG.js → TaskQueuePill-Q7DGoysj.js} +2 -2
- package/dashboard/dist/assets/{TaskQueuePill-BPj4ogVG.js.map → TaskQueuePill-Q7DGoysj.js.map} +1 -1
- package/dashboard/dist/assets/{TasksListPage-CtRkMpKU.js → TasksListPage-CsC9wjb0.js} +2 -2
- package/dashboard/dist/assets/{TasksListPage-CtRkMpKU.js.map → TasksListPage-CsC9wjb0.js.map} +1 -1
- package/dashboard/dist/assets/{TimeAgo-Di1a3X5P.js → TimeAgo-BcOOnJeH.js} +2 -2
- package/dashboard/dist/assets/{TimeAgo-Di1a3X5P.js.map → TimeAgo-BcOOnJeH.js.map} +1 -1
- package/dashboard/dist/assets/{TimestampCell-CqrXql-S.js → TimestampCell-CEMapYDQ.js} +2 -2
- package/dashboard/dist/assets/{TimestampCell-CqrXql-S.js.map → TimestampCell-CEMapYDQ.js.map} +1 -1
- package/dashboard/dist/assets/{UserName-BUFYCnRa.js → UserName-BHoN7iRL.js} +2 -2
- package/dashboard/dist/assets/{UserName-BUFYCnRa.js.map → UserName-BHoN7iRL.js.map} +1 -1
- package/dashboard/dist/assets/{WorkflowExecutionPage-25iusMml.js → WorkflowExecutionPage-DawKl1LT.js} +2 -2
- package/dashboard/dist/assets/{WorkflowExecutionPage-25iusMml.js.map → WorkflowExecutionPage-DawKl1LT.js.map} +1 -1
- package/dashboard/dist/assets/WorkflowPill-CP84Vqeg.js +2 -0
- package/dashboard/dist/assets/{WorkflowPill-DPKOcbf4.js.map → WorkflowPill-CP84Vqeg.js.map} +1 -1
- package/dashboard/dist/assets/{WorkflowsDashboard-BgxslssH.js → WorkflowsDashboard-QrvVFxtQ.js} +2 -2
- package/dashboard/dist/assets/{WorkflowsDashboard-BgxslssH.js.map → WorkflowsDashboard-QrvVFxtQ.js.map} +1 -1
- package/dashboard/dist/assets/{WorkflowsOverview-Doe5L-Re.js → WorkflowsOverview-DuhAi_OY.js} +2 -2
- package/dashboard/dist/assets/{WorkflowsOverview-Doe5L-Re.js.map → WorkflowsOverview-DuhAi_OY.js.map} +1 -1
- package/dashboard/dist/assets/YamlWorkflowsPage-Dc9xw82a.js +2 -0
- package/dashboard/dist/assets/YamlWorkflowsPage-Dc9xw82a.js.map +1 -0
- package/dashboard/dist/assets/{bots-Bi2_O1Ts.js → bots-Dny-rmmI.js} +2 -2
- package/dashboard/dist/assets/{bots-Bi2_O1Ts.js.map → bots-Dny-rmmI.js.map} +1 -1
- package/dashboard/dist/assets/{escalation-Ck1KlLkT.js → escalation-CV0sKNH5.js} +2 -2
- package/dashboard/dist/assets/{escalation-Ck1KlLkT.js.map → escalation-CV0sKNH5.js.map} +1 -1
- package/dashboard/dist/assets/{escalation-columns-ohDsj2eJ.js → escalation-columns-30CKyoWI.js} +2 -2
- package/dashboard/dist/assets/{escalation-columns-ohDsj2eJ.js.map → escalation-columns-30CKyoWI.js.map} +1 -1
- package/dashboard/dist/assets/{helpers-BoD2SgUY.js → helpers-C1-30CzH.js} +2 -2
- package/dashboard/dist/assets/{helpers-BoD2SgUY.js.map → helpers-C1-30CzH.js.map} +1 -1
- package/dashboard/dist/assets/helpers-C1jaRD-d.js +2 -0
- package/dashboard/dist/assets/helpers-C1jaRD-d.js.map +1 -0
- package/dashboard/dist/assets/{index-FuohTtaM.js → index-BUVQ6wmy.js} +3 -3
- package/dashboard/dist/assets/{index-FuohTtaM.js.map → index-BUVQ6wmy.js.map} +1 -1
- package/dashboard/dist/assets/index-CxVB7F4X.js +2 -0
- package/dashboard/dist/assets/{index-Dk2Q51o0.js.map → index-CxVB7F4X.js.map} +1 -1
- package/dashboard/dist/assets/{index-BEtLIsML.js → index-D-oCWCAS.js} +2 -2
- package/dashboard/dist/assets/{index-BEtLIsML.js.map → index-D-oCWCAS.js.map} +1 -1
- package/dashboard/dist/assets/index-D0wPM3Ck.js +2 -0
- package/dashboard/dist/assets/{index-BpT-6WgJ.js.map → index-D0wPM3Ck.js.map} +1 -1
- package/dashboard/dist/assets/{index-Bn2xHDr8.js → index-DHgnkykj.js} +3 -3
- package/dashboard/dist/assets/{index-Bn2xHDr8.js.map → index-DHgnkykj.js.map} +1 -1
- package/dashboard/dist/assets/{index-D3NyVADW.js → index-D_aJBEAG.js} +2 -2
- package/dashboard/dist/assets/index-D_aJBEAG.js.map +1 -0
- package/dashboard/dist/assets/{index-PyCTS05D.css → index-DcIKW-cZ.css} +1 -1
- package/dashboard/dist/assets/{index-CZrJ09p-.js → index-Dd_U4mLm.js} +2 -2
- package/dashboard/dist/assets/{index-CZrJ09p-.js.map → index-Dd_U4mLm.js.map} +1 -1
- package/dashboard/dist/assets/{index-DYyLF-Qb.js → index-DnmZbNxk.js} +8 -8
- package/dashboard/dist/assets/index-DnmZbNxk.js.map +1 -0
- package/dashboard/dist/assets/index-_RBvi7s6.js +2 -0
- package/dashboard/dist/assets/{index-D7zYZOnH.js.map → index-_RBvi7s6.js.map} +1 -1
- package/dashboard/dist/assets/index-n7td8zgX.js +17 -0
- package/dashboard/dist/assets/{index-DOkHXmyf.js.map → index-n7td8zgX.js.map} +1 -1
- package/dashboard/dist/assets/{mcp-CJtYjA7A.js → mcp-CRFr4L9W.js} +2 -2
- package/dashboard/dist/assets/{mcp-CJtYjA7A.js.map → mcp-CRFr4L9W.js.map} +1 -1
- package/dashboard/dist/assets/mcp-query-DHY2mZBQ.js +2 -0
- package/dashboard/dist/assets/mcp-query-DHY2mZBQ.js.map +1 -0
- package/dashboard/dist/assets/{mcp-runs-DUWm9Z4V.js → mcp-runs-BqPHqwAO.js} +2 -2
- package/dashboard/dist/assets/{mcp-runs-DUWm9Z4V.js.map → mcp-runs-BqPHqwAO.js.map} +1 -1
- package/dashboard/dist/assets/{namespaces-BM5P2qmL.js → namespaces-TG1aIpo_.js} +2 -2
- package/dashboard/dist/assets/{namespaces-BM5P2qmL.js.map → namespaces-TG1aIpo_.js.map} +1 -1
- package/dashboard/dist/assets/{roles-lv0shpjJ.js → roles-DhhLTvXg.js} +2 -2
- package/dashboard/dist/assets/{roles-lv0shpjJ.js.map → roles-DhhLTvXg.js.map} +1 -1
- package/dashboard/dist/assets/{settings-Wlq92mRo.js → settings-D9MBzEeB.js} +2 -2
- package/dashboard/dist/assets/{settings-Wlq92mRo.js.map → settings-D9MBzEeB.js.map} +1 -1
- package/dashboard/dist/assets/{tasks-BFGm4PuE.js → tasks-BxmcZoev.js} +2 -2
- package/dashboard/dist/assets/{tasks-BFGm4PuE.js.map → tasks-BxmcZoev.js.map} +1 -1
- package/dashboard/dist/assets/{useEventHooks-DIE6ue4x.js → useEventHooks-BylecvvI.js} +2 -2
- package/dashboard/dist/assets/{useEventHooks-DIE6ue4x.js.map → useEventHooks-BylecvvI.js.map} +1 -1
- package/dashboard/dist/assets/{useYamlActivityEvents-DCwSO73t.js → useYamlActivityEvents-ocmj11e_.js} +2 -2
- package/dashboard/dist/assets/{useYamlActivityEvents-DCwSO73t.js.map → useYamlActivityEvents-ocmj11e_.js.map} +1 -1
- package/dashboard/dist/assets/{users-tA5-K0wA.js → users-Ce5r-JAv.js} +2 -2
- package/dashboard/dist/assets/{users-tA5-K0wA.js.map → users-Ce5r-JAv.js.map} +1 -1
- package/dashboard/dist/assets/{vendor-icons-BiIug1SK.js → vendor-icons-D1DdudfH.js} +93 -73
- package/dashboard/dist/assets/vendor-icons-D1DdudfH.js.map +1 -0
- package/dashboard/dist/assets/{workflows-CfLc15Wr.js → workflows-ykIeVbRJ.js} +2 -2
- package/dashboard/dist/assets/{workflows-CfLc15Wr.js.map → workflows-ykIeVbRJ.js.map} +1 -1
- package/dashboard/dist/assets/yaml-workflows-WypmKYht.js +2 -0
- package/dashboard/dist/assets/yaml-workflows-WypmKYht.js.map +1 -0
- package/dashboard/dist/index.html +3 -3
- package/docs/api/sdk/auth.md +27 -0
- package/docs/api/sdk/bot-accounts.md +243 -0
- package/docs/api/sdk/controlplane.md +103 -0
- package/docs/api/sdk/dba.md +52 -0
- package/docs/api/sdk/escalations.md +374 -0
- package/docs/api/sdk/events.md +68 -0
- package/docs/api/sdk/exports.md +124 -0
- package/docs/api/sdk/insight.md +112 -0
- package/docs/api/sdk/maintenance.md +54 -0
- package/docs/api/sdk/mcp-runs.md +71 -0
- package/docs/api/sdk/mcp.md +250 -0
- package/docs/api/sdk/namespaces.md +43 -0
- package/docs/api/sdk/roles.md +183 -0
- package/docs/api/sdk/settings.md +24 -0
- package/docs/api/sdk/tasks.md +120 -0
- package/docs/api/sdk/users.md +196 -0
- package/docs/api/sdk/workflow-sets.md +135 -0
- package/docs/api/sdk/workflows.md +271 -0
- package/docs/api/sdk/yaml-workflows.md +408 -0
- package/docs/events.md +28 -0
- package/docs/sdk.md +177 -0
- package/docs/story.md +157 -0
- package/package.json +3 -2
- package/build/routes/escalations/helpers.d.ts +0 -5
- package/build/routes/resolve.d.ts +0 -9
- package/build/routes/resolve.js +0 -19
- package/build/routes/yaml-workflows/helpers.d.ts +0 -2
- package/build/routes/yaml-workflows/helpers.js +0 -8
- package/dashboard/dist/assets/BotPicker-A6LtzyuO.js +0 -2
- package/dashboard/dist/assets/McpQueryDetailPage-DhqEI180.js +0 -5
- package/dashboard/dist/assets/McpQueryDetailPage-DhqEI180.js.map +0 -1
- package/dashboard/dist/assets/McpQueryPage-CIiVMlqo.js +0 -2
- package/dashboard/dist/assets/McpQueryPage-CIiVMlqo.js.map +0 -1
- package/dashboard/dist/assets/OperatorDashboard-jc0vrgDI.js +0 -2
- package/dashboard/dist/assets/RunAsSelector-CJDnyp93.js +0 -2
- package/dashboard/dist/assets/RunAsSelector-CJDnyp93.js.map +0 -1
- package/dashboard/dist/assets/WorkflowPill-DPKOcbf4.js +0 -2
- package/dashboard/dist/assets/YamlWorkflowsPage-BliAckJ6.js +0 -2
- package/dashboard/dist/assets/YamlWorkflowsPage-BliAckJ6.js.map +0 -1
- package/dashboard/dist/assets/index-BpT-6WgJ.js +0 -2
- package/dashboard/dist/assets/index-D3NyVADW.js.map +0 -1
- package/dashboard/dist/assets/index-D7zYZOnH.js +0 -2
- package/dashboard/dist/assets/index-DOkHXmyf.js +0 -17
- package/dashboard/dist/assets/index-DYyLF-Qb.js.map +0 -1
- package/dashboard/dist/assets/index-Dk2Q51o0.js +0 -2
- package/dashboard/dist/assets/mcp-query-jQJQrs_7.js +0 -2
- package/dashboard/dist/assets/mcp-query-jQJQrs_7.js.map +0 -1
- package/dashboard/dist/assets/vendor-icons-BiIug1SK.js.map +0 -1
- package/dashboard/dist/assets/yaml-workflows-D7JXNqbM.js +0 -2
- package/dashboard/dist/assets/yaml-workflows-D7JXNqbM.js.map +0 -1
- package/docs/img/01-login.png +0 -0
- package/docs/img/02-dashboard-home.png +0 -0
- package/docs/img/03-processes-list.png +0 -0
- package/docs/img/04-escalations-list.png +0 -0
- package/docs/img/05-mcp-servers.png +0 -0
- package/docs/img/06-mcp-pipelines.png +0 -0
- package/docs/img/07-workflows-list.png +0 -0
- package/docs/img/compilation/01-query-submit.png +0 -0
- package/docs/img/compilation/02-mcp-servers.png +0 -0
- package/docs/img/compilation/03-query-completed.png +0 -0
- package/docs/img/compilation/04-wizard-original.png +0 -0
- package/docs/img/compilation/05-wizard-timeline.png +0 -0
- package/docs/img/compilation/06-wizard-profile.png +0 -0
- package/docs/img/compilation/07-wizard-deploy.png +0 -0
- package/docs/img/compilation/08-wizard-test-modal.png +0 -0
- package/docs/img/compilation/09-wizard-test-compare.png +0 -0
- package/docs/img/compilation/10-wizard-verify.png +0 -0
- /package/docs/api/{dba.md → http/dba.md} +0 -0
- /package/docs/api/{escalations.md → http/escalations.md} +0 -0
- /package/docs/api/{exports.md → http/exports.md} +0 -0
- /package/docs/api/{maintenance.md → http/maintenance.md} +0 -0
- /package/docs/api/{mcp-runs.md → http/mcp-runs.md} +0 -0
- /package/docs/api/{mcp-servers.md → http/mcp-servers.md} +0 -0
- /package/docs/api/{namespaces.md → http/namespaces.md} +0 -0
- /package/docs/api/{roles.md → http/roles.md} +0 -0
- /package/docs/api/{service-accounts.md → http/service-accounts.md} +0 -0
- /package/docs/api/{settings.md → http/settings.md} +0 -0
- /package/docs/api/{tasks.md → http/tasks.md} +0 -0
- /package/docs/api/{users.md → http/users.md} +0 -0
- /package/docs/api/{workflows.md → http/workflows.md} +0 -0
- /package/docs/api/{yaml-workflows.md → http/yaml-workflows.md} +0 -0
|
@@ -0,0 +1,751 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.listYamlWorkflows = listYamlWorkflows;
|
|
37
|
+
exports.createYamlWorkflow = createYamlWorkflow;
|
|
38
|
+
exports.createYamlWorkflowDirect = createYamlWorkflowDirect;
|
|
39
|
+
exports.getAppIds = getAppIds;
|
|
40
|
+
exports.getYamlWorkflow = getYamlWorkflow;
|
|
41
|
+
exports.updateYamlWorkflow = updateYamlWorkflow;
|
|
42
|
+
exports.regenerateYamlWorkflow = regenerateYamlWorkflow;
|
|
43
|
+
exports.deleteYamlWorkflow = deleteYamlWorkflow;
|
|
44
|
+
exports.deployYamlWorkflow = deployYamlWorkflow;
|
|
45
|
+
exports.activateYamlWorkflow = activateYamlWorkflow;
|
|
46
|
+
exports.invokeYamlWorkflow = invokeYamlWorkflow;
|
|
47
|
+
exports.archiveYamlWorkflow = archiveYamlWorkflow;
|
|
48
|
+
exports.getVersionHistory = getVersionHistory;
|
|
49
|
+
exports.getVersionSnapshot = getVersionSnapshot;
|
|
50
|
+
exports.getYamlContent = getYamlContent;
|
|
51
|
+
exports.setCronSchedule = setCronSchedule;
|
|
52
|
+
exports.clearCronSchedule = clearCronSchedule;
|
|
53
|
+
exports.getCronStatus = getCronStatus;
|
|
54
|
+
const yamlDb = __importStar(require("../services/yaml-workflow/db"));
|
|
55
|
+
const yamlGenerator = __importStar(require("../services/yaml-workflow/generator"));
|
|
56
|
+
const yamlDeployer = __importStar(require("../services/yaml-workflow/deployer"));
|
|
57
|
+
const yamlWorkers = __importStar(require("../services/yaml-workflow/workers"));
|
|
58
|
+
const invoke_1 = require("../services/yaml-workflow/invoke");
|
|
59
|
+
const task_1 = require("../services/task");
|
|
60
|
+
const cron_1 = require("../services/cron");
|
|
61
|
+
/** Return true if a Postgres error indicates an invalid/missing ID */
|
|
62
|
+
function isNotFoundError(err) {
|
|
63
|
+
const msg = err?.message ?? '';
|
|
64
|
+
return msg.includes('invalid input syntax for type uuid') || msg.includes('not found');
|
|
65
|
+
}
|
|
66
|
+
// ---------------------------------------------------------------------------
|
|
67
|
+
// CRUD
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
/**
|
|
70
|
+
* List YAML workflows with optional filtering and pagination.
|
|
71
|
+
*
|
|
72
|
+
* Delegates to the DB layer. Returns 404 when a filter references an invalid UUID.
|
|
73
|
+
*
|
|
74
|
+
* @param input.status — lifecycle filter (draft, deployed, active, archived)
|
|
75
|
+
* @param input.graph_topic — filter by the HotMesh subscription topic
|
|
76
|
+
* @param input.app_id — filter by namespace (MCP server name)
|
|
77
|
+
* @param input.search — free-text search across workflow name/description
|
|
78
|
+
* @param input.source_workflow_id — filter by the execution trace this workflow was compiled from
|
|
79
|
+
* @param input.set_id — filter by compositional set membership
|
|
80
|
+
* @param input.limit — max rows to return
|
|
81
|
+
* @param input.offset — pagination offset
|
|
82
|
+
* @returns `{ status: 200, data: YamlWorkflow[] }` matching workflows
|
|
83
|
+
*/
|
|
84
|
+
async function listYamlWorkflows(input) {
|
|
85
|
+
try {
|
|
86
|
+
const result = await yamlDb.listYamlWorkflows({
|
|
87
|
+
status: input.status,
|
|
88
|
+
graph_topic: input.graph_topic,
|
|
89
|
+
app_id: input.app_id,
|
|
90
|
+
search: input.search,
|
|
91
|
+
source_workflow_id: input.source_workflow_id,
|
|
92
|
+
set_id: input.set_id,
|
|
93
|
+
limit: input.limit,
|
|
94
|
+
offset: input.offset,
|
|
95
|
+
});
|
|
96
|
+
return { status: 200, data: result };
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
if (isNotFoundError(err)) {
|
|
100
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
101
|
+
}
|
|
102
|
+
return { status: 500, error: err.message };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Compile an execution trace into a new YAML workflow (draft).
|
|
107
|
+
*
|
|
108
|
+
* Validates that the source execution did not exhaust its tool rounds, checks for
|
|
109
|
+
* topic collisions in the target namespace, then delegates to the LLM-based YAML
|
|
110
|
+
* generator. The resulting YAML, schemas, and activity manifest are persisted as a
|
|
111
|
+
* new draft record. Auto-derived tags are merged with any user-supplied tags.
|
|
112
|
+
*
|
|
113
|
+
* @param input.workflow_id — ID of the source execution trace to compile from
|
|
114
|
+
* @param input.task_queue — HotMesh task queue the source execution ran on
|
|
115
|
+
* @param input.workflow_name — type name of the source workflow
|
|
116
|
+
* @param input.name — tool name for the new workflow (no dashes; used to derive the topic)
|
|
117
|
+
* @param input.description — human-readable description passed to the generator
|
|
118
|
+
* @param input.app_id — target namespace (defaults to "longtail")
|
|
119
|
+
* @param input.subscribes — explicit subscription topic override (otherwise derived from name)
|
|
120
|
+
* @param input.tags — additional tags to merge with auto-derived tags
|
|
121
|
+
* @param input.compilation_feedback — natural-language feedback to steer the LLM compilation
|
|
122
|
+
* @returns `{ status: 201, data: YamlWorkflow }` the newly created draft record
|
|
123
|
+
*/
|
|
124
|
+
async function createYamlWorkflow(input) {
|
|
125
|
+
try {
|
|
126
|
+
const { workflow_id, task_queue, workflow_name, name, description, app_id, subscribes, tags: userTags, compilation_feedback } = input;
|
|
127
|
+
if (!workflow_id || !task_queue || !workflow_name || !name) {
|
|
128
|
+
return { status: 400, error: 'workflow_id, task_queue, workflow_name, and name are required' };
|
|
129
|
+
}
|
|
130
|
+
if (/-/.test(name)) {
|
|
131
|
+
return { status: 400, error: 'Name must not contain dashes. Use underscores or camelCase (e.g. "screenshot_analyze_store").' };
|
|
132
|
+
}
|
|
133
|
+
// Reject compilation of executions that exhausted their tool rounds
|
|
134
|
+
const task = await (0, task_1.getTaskByWorkflowId)(workflow_id);
|
|
135
|
+
if (task) {
|
|
136
|
+
const milestones = task.milestones ?? [];
|
|
137
|
+
const roundsExhausted = milestones.some((m) => m.name === 'rounds_exhausted');
|
|
138
|
+
if (roundsExhausted) {
|
|
139
|
+
return {
|
|
140
|
+
status: 422,
|
|
141
|
+
error: 'Cannot compile: the source execution exhausted its tool rounds without completing the task. Resolve the escalation and resubmit.',
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// Check for topic collision in the target namespace
|
|
146
|
+
const compileAppId = app_id || 'longtail';
|
|
147
|
+
const compileTopic = subscribes || name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
|
|
148
|
+
const conflicting = await yamlDb.checkTopicConflict(compileAppId, compileTopic);
|
|
149
|
+
if (conflicting) {
|
|
150
|
+
return {
|
|
151
|
+
status: 409,
|
|
152
|
+
error: `Topic "${compileTopic}" is already used by workflow "${conflicting}" in namespace "${compileAppId}". Use a different tool name or namespace.`,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
// Generate YAML from execution
|
|
156
|
+
const result = await yamlGenerator.generateYamlFromExecution({
|
|
157
|
+
workflowId: workflow_id,
|
|
158
|
+
taskQueue: task_queue,
|
|
159
|
+
workflowName: workflow_name,
|
|
160
|
+
name,
|
|
161
|
+
description,
|
|
162
|
+
appId: app_id,
|
|
163
|
+
subscribes,
|
|
164
|
+
compilationFeedback: compilation_feedback,
|
|
165
|
+
});
|
|
166
|
+
// Merge auto-derived tags with user-provided tags
|
|
167
|
+
const mergedTags = [...new Set([...(result.tags || []), ...(Array.isArray(userTags) ? userTags : [])])];
|
|
168
|
+
// Store in DB
|
|
169
|
+
const record = await yamlDb.createYamlWorkflow({
|
|
170
|
+
name,
|
|
171
|
+
description,
|
|
172
|
+
app_id: result.appId,
|
|
173
|
+
yaml_content: result.yaml,
|
|
174
|
+
graph_topic: result.graphTopic,
|
|
175
|
+
input_schema: result.inputSchema,
|
|
176
|
+
output_schema: result.outputSchema,
|
|
177
|
+
activity_manifest: result.activityManifest,
|
|
178
|
+
tags: mergedTags,
|
|
179
|
+
source_workflow_id: workflow_id,
|
|
180
|
+
source_workflow_type: workflow_name,
|
|
181
|
+
original_prompt: result.originalPrompt || undefined,
|
|
182
|
+
category: result.category || undefined,
|
|
183
|
+
metadata: {
|
|
184
|
+
input_field_meta: result.inputFieldMeta,
|
|
185
|
+
...(result.validationIssues?.length ? { validation_warnings: result.validationIssues } : {}),
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
return { status: 201, data: record };
|
|
189
|
+
}
|
|
190
|
+
catch (err) {
|
|
191
|
+
if (err.message?.includes('duplicate key') || err.code === '23505') {
|
|
192
|
+
const msg = err.constraint?.includes('app_topic')
|
|
193
|
+
? 'A tool with that topic already exists in this namespace'
|
|
194
|
+
: 'A tool with that name already exists';
|
|
195
|
+
return { status: 409, error: msg };
|
|
196
|
+
}
|
|
197
|
+
return { status: 500, error: err.message };
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Create a YAML workflow directly from user-supplied YAML content (no compilation).
|
|
202
|
+
*
|
|
203
|
+
* Sanitizes the name, app_id, and graph_topic to lowercase alphanumeric characters.
|
|
204
|
+
* Rewrites the `subscribes`, `id`, and `topic` fields inside the YAML to match the
|
|
205
|
+
* sanitized values. Checks for topic collisions before persisting.
|
|
206
|
+
*
|
|
207
|
+
* @param input.name — tool name (sanitized to lowercase alphanumeric, periods, dashes, underscores)
|
|
208
|
+
* @param input.description — human-readable description; also stored as original_prompt
|
|
209
|
+
* @param input.yaml_content — raw HotMesh YAML definition
|
|
210
|
+
* @param input.input_schema — JSON Schema describing the workflow's input (defaults to empty object)
|
|
211
|
+
* @param input.activity_manifest — list of activity declarations (defaults to empty array)
|
|
212
|
+
* @param input.tags — classification tags (defaults to empty array)
|
|
213
|
+
* @param input.app_id — target namespace / MCP server name (defaults to "longtail", sanitized to lowercase alphanumeric)
|
|
214
|
+
* @param input.graph_topic — subscription topic override (defaults to sanitized name; overridden by `subscribes` in YAML if present)
|
|
215
|
+
* @returns `{ status: 200, data: YamlWorkflow }` the persisted workflow record
|
|
216
|
+
*/
|
|
217
|
+
async function createYamlWorkflowDirect(input) {
|
|
218
|
+
try {
|
|
219
|
+
const { name, description, yaml_content, input_schema, activity_manifest, tags, app_id, graph_topic } = input;
|
|
220
|
+
if (!name || !yaml_content) {
|
|
221
|
+
return { status: 400, error: 'name and yaml_content are required' };
|
|
222
|
+
}
|
|
223
|
+
// Sanitize name (tool name): lowercase alphanumeric, periods, dashes, underscores
|
|
224
|
+
const sanitizedName = name.toLowerCase().replace(/[^a-z0-9._-]/g, '');
|
|
225
|
+
// Sanitize app_id (MCP server name): force lowercase alphanumeric only
|
|
226
|
+
const targetAppId = (app_id || 'longtail').toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
227
|
+
// Sanitize graph topic: lowercase alphanumeric, periods, dashes, underscores
|
|
228
|
+
let graphTopic = (graph_topic || sanitizedName).toLowerCase().replace(/[^a-z0-9._-]/g, '');
|
|
229
|
+
const subscribesMatch = yaml_content.match(/subscribes:\s*(.+)/);
|
|
230
|
+
if (subscribesMatch) {
|
|
231
|
+
graphTopic = subscribesMatch[1].trim().replace(/^['"]|['"]$/g, '').toLowerCase().replace(/[^a-z0-9._-]/g, '');
|
|
232
|
+
}
|
|
233
|
+
// Rewrite the subscribes line in the YAML to match the sanitized topic
|
|
234
|
+
let finalYaml = yaml_content;
|
|
235
|
+
const subscribesRewrite = finalYaml.match(/^(\s*subscribes:\s*)(.+)$/m);
|
|
236
|
+
if (subscribesRewrite) {
|
|
237
|
+
finalYaml = finalYaml.replace(subscribesRewrite[0], `${subscribesRewrite[1]}${graphTopic}`);
|
|
238
|
+
}
|
|
239
|
+
// Also rewrite the app id line to match the sanitized app_id
|
|
240
|
+
const appIdRewrite = finalYaml.match(/^(\s*id:\s*)(.+)$/m);
|
|
241
|
+
if (appIdRewrite) {
|
|
242
|
+
finalYaml = finalYaml.replace(appIdRewrite[0], `${appIdRewrite[1]}${targetAppId}`);
|
|
243
|
+
}
|
|
244
|
+
// Rewrite worker topic fields to match the sanitized topic
|
|
245
|
+
finalYaml = finalYaml.replace(/^(\s*topic:\s*)(.+)$/gm, `$1${graphTopic}`);
|
|
246
|
+
// Check for topic collision in the target namespace
|
|
247
|
+
const conflicting = await yamlDb.checkTopicConflict(targetAppId, graphTopic);
|
|
248
|
+
if (conflicting) {
|
|
249
|
+
return {
|
|
250
|
+
status: 409,
|
|
251
|
+
error: `Topic "${graphTopic}" is already used by workflow "${conflicting}" in namespace "${targetAppId}". Use a different tool name or namespace.`,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
const wf = await yamlDb.createYamlWorkflow({
|
|
255
|
+
name: sanitizedName,
|
|
256
|
+
description,
|
|
257
|
+
app_id: targetAppId,
|
|
258
|
+
yaml_content: finalYaml,
|
|
259
|
+
graph_topic: graphTopic,
|
|
260
|
+
input_schema: input_schema || {},
|
|
261
|
+
output_schema: {},
|
|
262
|
+
activity_manifest: activity_manifest || [],
|
|
263
|
+
tags: tags || [],
|
|
264
|
+
original_prompt: description,
|
|
265
|
+
category: 'builder',
|
|
266
|
+
});
|
|
267
|
+
return { status: 200, data: wf };
|
|
268
|
+
}
|
|
269
|
+
catch (err) {
|
|
270
|
+
return { status: 500, error: err.message };
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Retrieve all distinct app_id namespaces that have at least one YAML workflow.
|
|
275
|
+
*
|
|
276
|
+
* @returns `{ status: 200, data: { app_ids: string[] } }` sorted list of namespace identifiers
|
|
277
|
+
*/
|
|
278
|
+
async function getAppIds() {
|
|
279
|
+
try {
|
|
280
|
+
const appIds = await yamlDb.getDistinctAppIds();
|
|
281
|
+
return { status: 200, data: { app_ids: appIds } };
|
|
282
|
+
}
|
|
283
|
+
catch (err) {
|
|
284
|
+
return { status: 500, error: err.message };
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Fetch a single YAML workflow by its primary key.
|
|
289
|
+
*
|
|
290
|
+
* @param input.id — UUID of the workflow record
|
|
291
|
+
* @returns `{ status: 200, data: YamlWorkflow }` the full workflow record, or 404 if not found
|
|
292
|
+
*/
|
|
293
|
+
async function getYamlWorkflow(input) {
|
|
294
|
+
try {
|
|
295
|
+
const wf = await yamlDb.getYamlWorkflow(input.id);
|
|
296
|
+
if (!wf) {
|
|
297
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
298
|
+
}
|
|
299
|
+
return { status: 200, data: wf };
|
|
300
|
+
}
|
|
301
|
+
catch (err) {
|
|
302
|
+
if (isNotFoundError(err)) {
|
|
303
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
304
|
+
}
|
|
305
|
+
return { status: 500, error: err.message };
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Partially update a YAML workflow record.
|
|
310
|
+
*
|
|
311
|
+
* Accepts arbitrary fields beyond `id` and forwards them to the DB update layer.
|
|
312
|
+
*
|
|
313
|
+
* @param input.id — UUID of the workflow to update
|
|
314
|
+
* @param input.[key] — any mutable workflow fields (name, description, yaml_content, tags, etc.)
|
|
315
|
+
* @returns `{ status: 200, data: YamlWorkflow }` the updated record, or 404 if not found
|
|
316
|
+
*/
|
|
317
|
+
async function updateYamlWorkflow(input) {
|
|
318
|
+
try {
|
|
319
|
+
const { id, ...fields } = input;
|
|
320
|
+
const wf = await yamlDb.updateYamlWorkflow(id, fields);
|
|
321
|
+
if (!wf) {
|
|
322
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
323
|
+
}
|
|
324
|
+
return { status: 200, data: wf };
|
|
325
|
+
}
|
|
326
|
+
catch (err) {
|
|
327
|
+
if (isNotFoundError(err)) {
|
|
328
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
329
|
+
}
|
|
330
|
+
return { status: 500, error: err.message };
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Re-compile an existing YAML workflow from its original execution trace.
|
|
335
|
+
*
|
|
336
|
+
* Looks up the source workflow reference, re-runs the LLM-based YAML generator, and
|
|
337
|
+
* overwrites the YAML content, schemas, manifest, and tags in place. When
|
|
338
|
+
* compilation_feedback is provided, the current YAML is passed as priorFailedYaml so
|
|
339
|
+
* the generator can incorporate the feedback. Archived workflows cannot be regenerated.
|
|
340
|
+
*
|
|
341
|
+
* @param input.id — UUID of the workflow to regenerate
|
|
342
|
+
* @param input.task_queue — override the task queue (otherwise resolved from the source task record)
|
|
343
|
+
* @param input.compilation_feedback — natural-language feedback to steer the re-compilation
|
|
344
|
+
* @returns `{ status: 200, data: YamlWorkflow }` the updated record with new YAML content
|
|
345
|
+
*/
|
|
346
|
+
async function regenerateYamlWorkflow(input) {
|
|
347
|
+
try {
|
|
348
|
+
const wf = await yamlDb.getYamlWorkflow(input.id);
|
|
349
|
+
if (!wf) {
|
|
350
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
351
|
+
}
|
|
352
|
+
if (wf.status === 'archived') {
|
|
353
|
+
return { status: 400, error: 'Archived workflows cannot be regenerated' };
|
|
354
|
+
}
|
|
355
|
+
if (!wf.source_workflow_id || !wf.source_workflow_type) {
|
|
356
|
+
return { status: 400, error: 'Missing source workflow reference — cannot regenerate' };
|
|
357
|
+
}
|
|
358
|
+
// Look up task queue from the source task record, or use input override
|
|
359
|
+
let taskQueue = input.task_queue;
|
|
360
|
+
if (!taskQueue) {
|
|
361
|
+
const sourceTask = await (0, task_1.getTaskByWorkflowId)(wf.source_workflow_id);
|
|
362
|
+
taskQueue = sourceTask?.task_queue || 'v1';
|
|
363
|
+
}
|
|
364
|
+
const feedback = input.compilation_feedback;
|
|
365
|
+
const result = await yamlGenerator.generateYamlFromExecution({
|
|
366
|
+
workflowId: wf.source_workflow_id,
|
|
367
|
+
taskQueue,
|
|
368
|
+
workflowName: wf.source_workflow_type,
|
|
369
|
+
name: wf.name,
|
|
370
|
+
description: wf.description || undefined,
|
|
371
|
+
appId: wf.app_id,
|
|
372
|
+
compilationFeedback: feedback || undefined,
|
|
373
|
+
priorFailedYaml: feedback ? wf.yaml_content : undefined,
|
|
374
|
+
});
|
|
375
|
+
const updated = await yamlDb.updateYamlWorkflow(wf.id, {
|
|
376
|
+
app_id: result.appId,
|
|
377
|
+
graph_topic: result.graphTopic,
|
|
378
|
+
yaml_content: result.yaml,
|
|
379
|
+
input_schema: result.inputSchema,
|
|
380
|
+
output_schema: result.outputSchema,
|
|
381
|
+
activity_manifest: result.activityManifest,
|
|
382
|
+
tags: result.tags,
|
|
383
|
+
metadata: { input_field_meta: result.inputFieldMeta },
|
|
384
|
+
});
|
|
385
|
+
return { status: 200, data: updated };
|
|
386
|
+
}
|
|
387
|
+
catch (err) {
|
|
388
|
+
if (isNotFoundError(err)) {
|
|
389
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
390
|
+
}
|
|
391
|
+
return { status: 500, error: err.message };
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Permanently delete a YAML workflow record.
|
|
396
|
+
*
|
|
397
|
+
* Only draft or archived workflows can be deleted. Active or deployed workflows must
|
|
398
|
+
* be archived first.
|
|
399
|
+
*
|
|
400
|
+
* @param input.id — UUID of the workflow to delete
|
|
401
|
+
* @returns `{ status: 200, data: { deleted: true } }` on success, or 400 if the workflow is active/deployed
|
|
402
|
+
*/
|
|
403
|
+
async function deleteYamlWorkflow(input) {
|
|
404
|
+
try {
|
|
405
|
+
const wf = await yamlDb.getYamlWorkflow(input.id);
|
|
406
|
+
if (!wf) {
|
|
407
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
408
|
+
}
|
|
409
|
+
if (wf.status === 'active' || wf.status === 'deployed') {
|
|
410
|
+
return { status: 400, error: 'Cannot delete an active or deployed workflow. Archive it first.' };
|
|
411
|
+
}
|
|
412
|
+
await yamlDb.deleteYamlWorkflow(input.id);
|
|
413
|
+
return { status: 200, data: { deleted: true } };
|
|
414
|
+
}
|
|
415
|
+
catch (err) {
|
|
416
|
+
if (isNotFoundError(err)) {
|
|
417
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
418
|
+
}
|
|
419
|
+
return { status: 500, error: err.message };
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
// ---------------------------------------------------------------------------
|
|
423
|
+
// Deployment
|
|
424
|
+
// ---------------------------------------------------------------------------
|
|
425
|
+
/**
|
|
426
|
+
* Deploy a YAML workflow and all sibling workflows sharing its app_id namespace.
|
|
427
|
+
*
|
|
428
|
+
* Merges and deploys the full app_id YAML, registers HotMesh workers for every
|
|
429
|
+
* non-archived sibling, transitions draft/deployed siblings to active, and marks
|
|
430
|
+
* the app_id content as deployed. Uses the app_version declared in the workflow record.
|
|
431
|
+
*
|
|
432
|
+
* @param input.id — UUID of the workflow to deploy
|
|
433
|
+
* @returns `{ status: 200, data: YamlWorkflow }` the refreshed workflow record after deployment
|
|
434
|
+
*/
|
|
435
|
+
async function deployYamlWorkflow(input) {
|
|
436
|
+
try {
|
|
437
|
+
const wf = await yamlDb.getYamlWorkflow(input.id);
|
|
438
|
+
if (!wf) {
|
|
439
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
440
|
+
}
|
|
441
|
+
// Use the version declared in the YAML (like package.json)
|
|
442
|
+
const deployVersion = wf.app_version || '1';
|
|
443
|
+
// Deploy + activate merged YAML for the full app_id
|
|
444
|
+
const siblings = await yamlDb.listYamlWorkflowsByAppId(wf.app_id);
|
|
445
|
+
await yamlDeployer.deployAppId(wf.app_id, deployVersion);
|
|
446
|
+
// Register workers and mark all non-archived siblings as active
|
|
447
|
+
for (const sibling of siblings) {
|
|
448
|
+
await yamlDb.updateYamlWorkflowVersion(sibling.id, deployVersion);
|
|
449
|
+
await yamlWorkers.registerWorkersForWorkflow(sibling);
|
|
450
|
+
if (sibling.status === 'draft' || sibling.status === 'deployed') {
|
|
451
|
+
await yamlDb.updateYamlWorkflowStatus(sibling.id, 'active');
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
// Mark content as deployed for the entire app_id
|
|
455
|
+
await yamlDb.markAppIdContentDeployed(wf.app_id);
|
|
456
|
+
const updated = await yamlDb.getYamlWorkflow(input.id);
|
|
457
|
+
return { status: 200, data: updated };
|
|
458
|
+
}
|
|
459
|
+
catch (err) {
|
|
460
|
+
if (isNotFoundError(err)) {
|
|
461
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
462
|
+
}
|
|
463
|
+
return {
|
|
464
|
+
status: 500,
|
|
465
|
+
error: err.message,
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Activate a previously deployed YAML workflow and its app_id siblings.
|
|
471
|
+
*
|
|
472
|
+
* Calls the deployer to activate the app_id at its current version, then registers
|
|
473
|
+
* HotMesh workers for all sibling workflows. Siblings in "deployed" status are
|
|
474
|
+
* transitioned to "active". The workflow must already be in deployed or active status.
|
|
475
|
+
*
|
|
476
|
+
* @param input.id — UUID of the workflow to activate
|
|
477
|
+
* @returns `{ status: 200, data: YamlWorkflow }` the refreshed workflow record after activation
|
|
478
|
+
*/
|
|
479
|
+
async function activateYamlWorkflow(input) {
|
|
480
|
+
try {
|
|
481
|
+
const wf = await yamlDb.getYamlWorkflow(input.id);
|
|
482
|
+
if (!wf) {
|
|
483
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
484
|
+
}
|
|
485
|
+
if (wf.status !== 'deployed' && wf.status !== 'active') {
|
|
486
|
+
return { status: 400, error: 'Workflow must be deployed before activation' };
|
|
487
|
+
}
|
|
488
|
+
await yamlDeployer.activateYamlWorkflow(wf.app_id, wf.app_version);
|
|
489
|
+
// Register workers for ALL workflows sharing this app_id
|
|
490
|
+
const siblings = await yamlDb.listYamlWorkflowsByAppId(wf.app_id);
|
|
491
|
+
for (const sibling of siblings) {
|
|
492
|
+
await yamlWorkers.registerWorkersForWorkflow(sibling);
|
|
493
|
+
if (sibling.status === 'deployed') {
|
|
494
|
+
await yamlDb.updateYamlWorkflowStatus(sibling.id, 'active');
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
const updated = await yamlDb.getYamlWorkflow(input.id);
|
|
498
|
+
return { status: 200, data: updated };
|
|
499
|
+
}
|
|
500
|
+
catch (err) {
|
|
501
|
+
if (isNotFoundError(err)) {
|
|
502
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
503
|
+
}
|
|
504
|
+
return { status: 500, error: err.message };
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Invoke an active YAML workflow, executing its DAG pipeline.
|
|
509
|
+
*
|
|
510
|
+
* The workflow must be in "active" status. Delegates to the invoke service which
|
|
511
|
+
* starts the HotMesh execution. Supports both synchronous (wait for result) and
|
|
512
|
+
* asynchronous (fire-and-forget) invocation modes.
|
|
513
|
+
*
|
|
514
|
+
* @param input.id — UUID of the workflow to invoke
|
|
515
|
+
* @param input.data — input payload passed to the workflow's entry point
|
|
516
|
+
* @param input.sync — when true, block until the workflow completes and return its output
|
|
517
|
+
* @param input.timeout — max milliseconds to wait when sync is true
|
|
518
|
+
* @param input.execute_as — override identity for the execution context
|
|
519
|
+
* @param auth — authenticated user context; userId is forwarded to the invoke service
|
|
520
|
+
* @returns `{ status: 200, data: ... }` workflow execution result (sync) or job metadata (async)
|
|
521
|
+
*/
|
|
522
|
+
async function invokeYamlWorkflow(input, auth) {
|
|
523
|
+
try {
|
|
524
|
+
const wf = await yamlDb.getYamlWorkflow(input.id);
|
|
525
|
+
if (!wf) {
|
|
526
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
527
|
+
}
|
|
528
|
+
if (wf.status !== 'active') {
|
|
529
|
+
return { status: 400, error: 'Workflow must be active to invoke' };
|
|
530
|
+
}
|
|
531
|
+
const result = await (0, invoke_1.invokeYamlWorkflow)(wf, {
|
|
532
|
+
data: input.data,
|
|
533
|
+
sync: input.sync,
|
|
534
|
+
timeout: input.timeout,
|
|
535
|
+
execute_as: input.execute_as,
|
|
536
|
+
userId: auth?.userId,
|
|
537
|
+
});
|
|
538
|
+
return { status: 200, data: result };
|
|
539
|
+
}
|
|
540
|
+
catch (err) {
|
|
541
|
+
if (isNotFoundError(err)) {
|
|
542
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
543
|
+
}
|
|
544
|
+
return { status: 500, error: err.message };
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Archive a YAML workflow, removing it from active service.
|
|
549
|
+
*
|
|
550
|
+
* If the workflow is currently active, its HotMesh engine is stopped before
|
|
551
|
+
* transitioning the status to "archived". Archived workflows cannot be invoked
|
|
552
|
+
* or regenerated but can still be viewed or deleted.
|
|
553
|
+
*
|
|
554
|
+
* @param input.id — UUID of the workflow to archive
|
|
555
|
+
* @returns `{ status: 200, data: YamlWorkflow }` the updated record with status "archived"
|
|
556
|
+
*/
|
|
557
|
+
async function archiveYamlWorkflow(input) {
|
|
558
|
+
try {
|
|
559
|
+
const wf = await yamlDb.getYamlWorkflow(input.id);
|
|
560
|
+
if (!wf) {
|
|
561
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
562
|
+
}
|
|
563
|
+
if (wf.status === 'active') {
|
|
564
|
+
await yamlDeployer.stopEngine(wf.app_id);
|
|
565
|
+
}
|
|
566
|
+
const updated = await yamlDb.updateYamlWorkflowStatus(wf.id, 'archived');
|
|
567
|
+
return { status: 200, data: updated };
|
|
568
|
+
}
|
|
569
|
+
catch (err) {
|
|
570
|
+
if (isNotFoundError(err)) {
|
|
571
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
572
|
+
}
|
|
573
|
+
return { status: 500, error: err.message };
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
// ---------------------------------------------------------------------------
|
|
577
|
+
// Versions
|
|
578
|
+
// ---------------------------------------------------------------------------
|
|
579
|
+
/**
|
|
580
|
+
* Retrieve the version history for a YAML workflow.
|
|
581
|
+
*
|
|
582
|
+
* Returns a paginated list of version snapshots ordered by version number.
|
|
583
|
+
*
|
|
584
|
+
* @param input.id — UUID of the workflow
|
|
585
|
+
* @param input.limit — max versions to return (defaults to 20)
|
|
586
|
+
* @param input.offset — pagination offset (defaults to 0)
|
|
587
|
+
* @returns `{ status: 200, data: VersionSnapshot[] }` paginated version history
|
|
588
|
+
*/
|
|
589
|
+
async function getVersionHistory(input) {
|
|
590
|
+
try {
|
|
591
|
+
const limit = input.limit ?? 20;
|
|
592
|
+
const offset = input.offset ?? 0;
|
|
593
|
+
const result = await yamlDb.getVersionHistory(input.id, limit, offset);
|
|
594
|
+
return { status: 200, data: result };
|
|
595
|
+
}
|
|
596
|
+
catch (err) {
|
|
597
|
+
if (isNotFoundError(err)) {
|
|
598
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
599
|
+
}
|
|
600
|
+
return { status: 500, error: err.message };
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Retrieve a specific version snapshot of a YAML workflow.
|
|
605
|
+
*
|
|
606
|
+
* Validates that the version number is a positive integer before querying.
|
|
607
|
+
*
|
|
608
|
+
* @param input.id — UUID of the workflow
|
|
609
|
+
* @param input.version — 1-based version number to retrieve
|
|
610
|
+
* @returns `{ status: 200, data: VersionSnapshot }` the snapshot at the requested version, or 404
|
|
611
|
+
*/
|
|
612
|
+
async function getVersionSnapshot(input) {
|
|
613
|
+
try {
|
|
614
|
+
const version = input.version;
|
|
615
|
+
if (isNaN(version) || version < 1) {
|
|
616
|
+
return { status: 400, error: 'Invalid version number' };
|
|
617
|
+
}
|
|
618
|
+
const snapshot = await yamlDb.getVersionSnapshot(input.id, version);
|
|
619
|
+
if (!snapshot) {
|
|
620
|
+
return { status: 404, error: `Version ${version} not found` };
|
|
621
|
+
}
|
|
622
|
+
return { status: 200, data: snapshot };
|
|
623
|
+
}
|
|
624
|
+
catch (err) {
|
|
625
|
+
if (isNotFoundError(err)) {
|
|
626
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
627
|
+
}
|
|
628
|
+
return { status: 500, error: err.message };
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Retrieve the raw YAML content for a workflow, optionally at a specific version.
|
|
633
|
+
*
|
|
634
|
+
* When a version is provided, fetches from the version snapshot table. Otherwise
|
|
635
|
+
* returns the current yaml_content from the live workflow record.
|
|
636
|
+
*
|
|
637
|
+
* @param input.id — UUID of the workflow
|
|
638
|
+
* @param input.version — optional version number; when omitted, returns the current content
|
|
639
|
+
* @returns `{ status: 200, data: string }` the raw YAML string
|
|
640
|
+
*/
|
|
641
|
+
async function getYamlContent(input) {
|
|
642
|
+
try {
|
|
643
|
+
if (input.version) {
|
|
644
|
+
const snapshot = await yamlDb.getVersionSnapshot(input.id, input.version);
|
|
645
|
+
if (!snapshot) {
|
|
646
|
+
return { status: 404, error: `Version ${input.version} not found` };
|
|
647
|
+
}
|
|
648
|
+
return { status: 200, data: snapshot.yaml_content };
|
|
649
|
+
}
|
|
650
|
+
const wf = await yamlDb.getYamlWorkflow(input.id);
|
|
651
|
+
if (!wf) {
|
|
652
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
653
|
+
}
|
|
654
|
+
return { status: 200, data: wf.yaml_content };
|
|
655
|
+
}
|
|
656
|
+
catch (err) {
|
|
657
|
+
if (isNotFoundError(err)) {
|
|
658
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
659
|
+
}
|
|
660
|
+
return { status: 500, error: err.message };
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
// ---------------------------------------------------------------------------
|
|
664
|
+
// Cron
|
|
665
|
+
// ---------------------------------------------------------------------------
|
|
666
|
+
/**
|
|
667
|
+
* Set or update the cron schedule for a YAML workflow.
|
|
668
|
+
*
|
|
669
|
+
* Persists the schedule in the DB and restarts the in-process cron timer via the
|
|
670
|
+
* cron registry so the change takes effect immediately.
|
|
671
|
+
*
|
|
672
|
+
* @param input.id — UUID of the workflow to schedule
|
|
673
|
+
* @param input.cron_schedule — cron expression (e.g. "0 * * * *")
|
|
674
|
+
* @param input.cron_envelope — optional payload passed to each scheduled invocation
|
|
675
|
+
* @param input.execute_as — optional identity override for scheduled executions
|
|
676
|
+
* @returns `{ status: 200, data: YamlWorkflow }` the updated workflow record with cron fields set
|
|
677
|
+
*/
|
|
678
|
+
async function setCronSchedule(input) {
|
|
679
|
+
try {
|
|
680
|
+
const wf = await yamlDb.getYamlWorkflow(input.id);
|
|
681
|
+
if (!wf) {
|
|
682
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
683
|
+
}
|
|
684
|
+
if (!input.cron_schedule || typeof input.cron_schedule !== 'string') {
|
|
685
|
+
return { status: 400, error: 'cron_schedule is required' };
|
|
686
|
+
}
|
|
687
|
+
const updated = await yamlDb.updateCronSchedule(wf.id, input.cron_schedule.trim(), input.cron_envelope ?? null, input.execute_as ?? null);
|
|
688
|
+
if (updated) {
|
|
689
|
+
await cron_1.cronRegistry.restartYamlCron(updated);
|
|
690
|
+
}
|
|
691
|
+
return { status: 200, data: updated };
|
|
692
|
+
}
|
|
693
|
+
catch (err) {
|
|
694
|
+
if (isNotFoundError(err)) {
|
|
695
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
696
|
+
}
|
|
697
|
+
return { status: 500, error: err.message };
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* Remove the cron schedule from a YAML workflow.
|
|
702
|
+
*
|
|
703
|
+
* Stops the in-process cron timer first, then clears the schedule fields in the DB.
|
|
704
|
+
*
|
|
705
|
+
* @param input.id — UUID of the workflow to unschedule
|
|
706
|
+
* @returns `{ status: 200, data: YamlWorkflow }` the updated workflow record with cron fields cleared
|
|
707
|
+
*/
|
|
708
|
+
async function clearCronSchedule(input) {
|
|
709
|
+
try {
|
|
710
|
+
const wf = await yamlDb.getYamlWorkflow(input.id);
|
|
711
|
+
if (!wf) {
|
|
712
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
713
|
+
}
|
|
714
|
+
await cron_1.cronRegistry.stopYamlCron(wf.id);
|
|
715
|
+
const updated = await yamlDb.clearCronSchedule(wf.id);
|
|
716
|
+
return { status: 200, data: updated };
|
|
717
|
+
}
|
|
718
|
+
catch (err) {
|
|
719
|
+
if (isNotFoundError(err)) {
|
|
720
|
+
return { status: 404, error: 'YAML workflow not found' };
|
|
721
|
+
}
|
|
722
|
+
return { status: 500, error: err.message };
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* List all YAML workflows that have a cron schedule, with their live timer status.
|
|
727
|
+
*
|
|
728
|
+
* Fetches all cron-scheduled workflows from the DB and cross-references with the
|
|
729
|
+
* in-process cron registry to determine which timers are actually running.
|
|
730
|
+
*
|
|
731
|
+
* @returns `{ status: 200, data: { schedules: Array<{ id, name, graph_topic, app_id, cron_schedule, execute_as, active }> } }`
|
|
732
|
+
*/
|
|
733
|
+
async function getCronStatus() {
|
|
734
|
+
try {
|
|
735
|
+
const workflows = await yamlDb.getCronScheduledWorkflows();
|
|
736
|
+
const activeTypes = cron_1.cronRegistry.activeWorkflowTypes;
|
|
737
|
+
const schedules = workflows.map((wf) => ({
|
|
738
|
+
id: wf.id,
|
|
739
|
+
name: wf.name,
|
|
740
|
+
graph_topic: wf.graph_topic,
|
|
741
|
+
app_id: wf.app_id,
|
|
742
|
+
cron_schedule: wf.cron_schedule,
|
|
743
|
+
execute_as: wf.execute_as,
|
|
744
|
+
active: activeTypes.includes(`yaml:${wf.id}`),
|
|
745
|
+
}));
|
|
746
|
+
return { status: 200, data: { schedules } };
|
|
747
|
+
}
|
|
748
|
+
catch (err) {
|
|
749
|
+
return { status: 500, error: err.message };
|
|
750
|
+
}
|
|
751
|
+
}
|