@overlordai/server 1.0.143 → 1.0.145
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/database/migrations/014-automations.sql +67 -0
- package/dist/adapters/command-parser.utils.d.ts +1 -0
- package/dist/adapters/command-parser.utils.d.ts.map +1 -1
- package/dist/adapters/command-parser.utils.js +14 -1
- package/dist/adapters/command-parser.utils.js.map +1 -1
- package/dist/adapters/help-text.d.ts.map +1 -1
- package/dist/adapters/help-text.js +2 -1
- package/dist/adapters/help-text.js.map +1 -1
- package/dist/adapters/nlu.service.d.ts.map +1 -1
- package/dist/adapters/nlu.service.js +4 -1
- package/dist/adapters/nlu.service.js.map +1 -1
- package/dist/app.module.d.ts.map +1 -1
- package/dist/app.module.js +2 -0
- package/dist/app.module.js.map +1 -1
- package/dist/automation/automation-executor.d.ts +23 -0
- package/dist/automation/automation-executor.d.ts.map +1 -0
- package/dist/automation/automation-executor.js +365 -0
- package/dist/automation/automation-executor.js.map +1 -0
- package/dist/automation/automation-scheduler.d.ts +21 -0
- package/dist/automation/automation-scheduler.d.ts.map +1 -0
- package/dist/automation/automation-scheduler.js +124 -0
- package/dist/automation/automation-scheduler.js.map +1 -0
- package/dist/automation/automation-template.service.d.ts +30 -0
- package/dist/automation/automation-template.service.d.ts.map +1 -0
- package/dist/automation/automation-template.service.js +66 -0
- package/dist/automation/automation-template.service.js.map +1 -0
- package/dist/automation/automation-trigger.d.ts +13 -0
- package/dist/automation/automation-trigger.d.ts.map +1 -0
- package/dist/automation/automation-trigger.js +96 -0
- package/dist/automation/automation-trigger.js.map +1 -0
- package/dist/automation/automation-validation.d.ts +14 -0
- package/dist/automation/automation-validation.d.ts.map +1 -0
- package/dist/automation/automation-validation.js +66 -0
- package/dist/automation/automation-validation.js.map +1 -0
- package/dist/automation/automation.module.d.ts +3 -0
- package/dist/automation/automation.module.d.ts.map +1 -0
- package/dist/automation/automation.module.js +33 -0
- package/dist/automation/automation.module.js.map +1 -0
- package/dist/automation/automation.service.d.ts +22 -0
- package/dist/automation/automation.service.d.ts.map +1 -0
- package/dist/automation/automation.service.js +232 -0
- package/dist/automation/automation.service.js.map +1 -0
- package/dist/database/repositories/automation.repository.d.ts +87 -0
- package/dist/database/repositories/automation.repository.d.ts.map +1 -0
- package/dist/database/repositories/automation.repository.js +531 -0
- package/dist/database/repositories/automation.repository.js.map +1 -0
- package/dist/database/repositories/task.repository.d.ts +1 -0
- package/dist/database/repositories/task.repository.d.ts.map +1 -1
- package/dist/database/repositories/task.repository.js +4 -2
- package/dist/database/repositories/task.repository.js.map +1 -1
- package/dist/database/repository.module.d.ts.map +1 -1
- package/dist/database/repository.module.js +2 -0
- package/dist/database/repository.module.js.map +1 -1
- package/dist/dispatcher/dispatcher.service.d.ts.map +1 -1
- package/dist/dispatcher/dispatcher.service.js +1 -0
- package/dist/dispatcher/dispatcher.service.js.map +1 -1
- package/dist/dispatcher/task-creation.service.d.ts +3 -3
- package/dist/dispatcher/task-creation.service.d.ts.map +1 -1
- package/dist/dispatcher/task-creation.service.js +14 -5
- package/dist/dispatcher/task-creation.service.js.map +1 -1
- package/dist/events/event-types.d.ts +31 -0
- package/dist/events/event-types.d.ts.map +1 -1
- package/dist/events/event-types.js +4 -0
- package/dist/events/event-types.js.map +1 -1
- package/dist/notifier/notification-consumer.d.ts.map +1 -1
- package/dist/notifier/notification-consumer.js +65 -1
- package/dist/notifier/notification-consumer.js.map +1 -1
- package/dist/notifier/notification-event-listener.d.ts +7 -2
- package/dist/notifier/notification-event-listener.d.ts.map +1 -1
- package/dist/notifier/notification-event-listener.js +56 -2
- package/dist/notifier/notification-event-listener.js.map +1 -1
- package/dist/notifier/notifier.service.d.ts +4 -1
- package/dist/notifier/notifier.service.d.ts.map +1 -1
- package/dist/notifier/notifier.service.js +23 -2
- package/dist/notifier/notifier.service.js.map +1 -1
- package/dist/notifier/template.service.d.ts +1 -1
- package/dist/notifier/template.service.d.ts.map +1 -1
- package/dist/notifier/template.service.js +14 -4
- package/dist/notifier/template.service.js.map +1 -1
- package/dist/web/automation.controller.d.ts +74 -0
- package/dist/web/automation.controller.d.ts.map +1 -0
- package/dist/web/automation.controller.js +539 -0
- package/dist/web/automation.controller.js.map +1 -0
- package/dist/web/frame-handlers/automation-report.handler.d.ts +10 -0
- package/dist/web/frame-handlers/automation-report.handler.d.ts.map +1 -0
- package/dist/web/frame-handlers/automation-report.handler.js +15 -0
- package/dist/web/frame-handlers/automation-report.handler.js.map +1 -0
- package/dist/web/frame-handlers/index.d.ts +1 -0
- package/dist/web/frame-handlers/index.d.ts.map +1 -1
- package/dist/web/frame-handlers/index.js +3 -1
- package/dist/web/frame-handlers/index.js.map +1 -1
- package/dist/web/frame-handlers/stage-confirm.handler.d.ts.map +1 -1
- package/dist/web/frame-handlers/stage-confirm.handler.js +1 -1
- package/dist/web/frame-handlers/stage-confirm.handler.js.map +1 -1
- package/dist/web/task.controller.d.ts +3 -0
- package/dist/web/task.controller.d.ts.map +1 -1
- package/dist/web/web-event.service.d.ts +20 -1
- package/dist/web/web-event.service.d.ts.map +1 -1
- package/dist/web/web-event.service.js +66 -2
- package/dist/web/web-event.service.js.map +1 -1
- package/dist/web/web.module.d.ts.map +1 -1
- package/dist/web/web.module.js +4 -1
- package/dist/web/web.module.js.map +1 -1
- package/dist/web/worker-channel.gateway.d.ts +2 -1
- package/dist/web/worker-channel.gateway.d.ts.map +1 -1
- package/dist/web/worker-channel.gateway.js +5 -2
- package/dist/web/worker-channel.gateway.js.map +1 -1
- package/package.json +5 -4
- package/public/assets/AccessTokensPage-BYuGmkhG.js +1 -0
- package/public/assets/{AdminPage-CxHMuTgJ.js → AdminPage-BResRWph.js} +1 -1
- package/public/assets/{AgentCliPage-DxZUrhjz.js → AgentCliPage-BcDXV12E.js} +1 -1
- package/public/assets/{ApiReferencePage-Cc_-lPFn.js → ApiReferencePage-NaJYMeTA.js} +1 -1
- package/public/assets/{ArchitecturePage-CpXl4jb3.js → ArchitecturePage-D-0d-kgA.js} +1 -1
- package/public/assets/{AuditLogPage-CvG7Kmpn.js → AuditLogPage-BuiWgzsv.js} +1 -1
- package/public/assets/AutomationCreatePage-CbGNlXYx.js +1 -0
- package/public/assets/AutomationDetailPage-C8GfVtsX.js +16 -0
- package/public/assets/AutomationEditPage-C7hl6YxI.js +1 -0
- package/public/assets/AutomationListPage-sjxnTqLB.js +16 -0
- package/public/assets/AutomationRunDetailPage-DYpv-WBg.js +6 -0
- package/public/assets/{BindPlatformPage-DQEP-N9z.js → BindPlatformPage-DS1eO2Me.js} +1 -1
- package/public/assets/BotIntegrationPage-DW13UERh.js +1 -0
- package/public/assets/{BotManage-B1lkaWlW.js → BotManage-CW08edmX.js} +2 -2
- package/public/assets/{BotSetupPage-kJHd4z6w.js → BotSetupPage-B2TIppqV.js} +2 -2
- package/public/assets/{ChangelogPage-QheUxtEJ.js → ChangelogPage-BpJdCfIe.js} +1 -1
- package/public/assets/{CliReferencePage-Dy78S9h1.js → CliReferencePage-wbYT0YSP.js} +1 -1
- package/public/assets/ConfirmStageDialog-Bke18NAb.js +7 -0
- package/public/assets/{DeploymentPage-CaIslw2W.js → DeploymentPage-DqYVYlM2.js} +1 -1
- package/public/assets/{DevWorkflowPage-DjmFkvCo.js → DevWorkflowPage-B1T1aB-L.js} +1 -1
- package/public/assets/DeveloperManage-CwH2nj3C.js +16 -0
- package/public/assets/{DeveloperSetupPage-D3RvWqx0.js → DeveloperSetupPage-B099stPW.js} +1 -1
- package/public/assets/{DocsIndexPage-BHnvOEn8.js → DocsIndexPage-BQJNEB0T.js} +1 -1
- package/public/assets/{DocsLayout-BdWlFJ_G.js → DocsLayout-VgiIORoW.js} +1 -1
- package/public/assets/{DocsPrimitives-BRoBpWHe.js → DocsPrimitives-DStFX1T8.js} +1 -1
- package/public/assets/{EditProjectPage-CepF7mnT.js → EditProjectPage-CSv1LQ0c.js} +2 -2
- package/public/assets/{EmptyState-BIXXLer_.js → EmptyState-CM34MS8q.js} +1 -1
- package/public/assets/{EnvVariablesPage-DxRT4ql6.js → EnvVariablesPage-By_n8jC_.js} +2 -2
- package/public/assets/{HomePage-CkiXfp2H.js → HomePage-BA8S5QIk.js} +1 -1
- package/public/assets/{InfoRow-DXCzjoGj.js → InfoRow-BkLVrW3X.js} +1 -1
- package/public/assets/{InstallationPage-CF8j4Y-C.js → InstallationPage-5aHtmv3w.js} +1 -1
- package/public/assets/{LandingPage-CaYr_-RD.js → LandingPage-XfW3mTgR.js} +7 -12
- package/public/assets/{LocalDevelopmentPage-HIFhYvHJ.js → LocalDevelopmentPage-CEhJ10RY.js} +1 -1
- package/public/assets/{LoginPage-D17Mq8Qe.js → LoginPage-hEkjuwQp.js} +1 -1
- package/public/assets/{MetricBar-DDJWywkw.js → MetricBar-CuVoQPXf.js} +1 -1
- package/public/assets/{NotFoundPage-BTlUFX7F.js → NotFoundPage-CDaJI7W_.js} +1 -1
- package/public/assets/{OnboardingGuide-CTJYul4_.js → OnboardingGuide-xLqRqP0t.js} +1 -1
- package/public/assets/{PermissionsPage-Dj27JR_m.js → PermissionsPage-BGlc6yU2.js} +1 -1
- package/public/assets/{PipelineConfigPage-BTy8cOFI.js → PipelineConfigPage-Bzm1MeK0.js} +1 -1
- package/public/assets/{PipelineEditorPage-CuSW0B-0.js → PipelineEditorPage-DhS-VBVt.js} +2 -2
- package/public/assets/{PlanPage-CMQs2Hiz.js → PlanPage-Mu6msPek.js} +1 -1
- package/public/assets/{ProfilePage-BRxrQCQd.js → ProfilePage-Dk-XPfIf.js} +1 -1
- package/public/assets/{ProjectDetailPage-CRHNrgPt.js → ProjectDetailPage-C8v5ztXD.js} +3 -3
- package/public/assets/ProjectListPage-Ccrl3DtV.js +6 -0
- package/public/assets/PtyTerminal-DCbNmuIT.js +38 -0
- package/public/assets/{QuickAuth-Dx-LoUjm.js → QuickAuth-DAPeXfQS.js} +1 -1
- package/public/assets/RemoveMemberConfirmDialog-gr2WUWrR.js +6 -0
- package/public/assets/ReviewAggregatePage-B1SB4rXq.js +6 -0
- package/public/assets/{ReviewPage-DzNkeQXP.js → ReviewPage-Bde6YvIA.js} +1 -1
- package/public/assets/{Select-DYnPuPlP.js → Select-Bxil-UGQ.js} +1 -1
- package/public/assets/{SettingsPage-YpqaOT8x.js → SettingsPage-nA4hlLlN.js} +1 -1
- package/public/assets/{Skeleton-tFvClhRo.js → Skeleton-DMVGjH__.js} +1 -1
- package/public/assets/{SkillPage-BQto2TJm.js → SkillPage-BqTTImpe.js} +1 -1
- package/public/assets/{TaskDetailPage-BAnCb9zv.js → TaskDetailPage-DPdD57PF.js} +2 -2
- package/public/assets/{TaskGuidePage-Bs-Unzck.js → TaskGuidePage-CQAlhXHL.js} +1 -1
- package/public/assets/TaskListPage-C5tAOuSG.js +1 -0
- package/public/assets/{TaskStatusBadge-BUczBM5S.js → TaskStatusBadge-D5lVjwey.js} +1 -1
- package/public/assets/TerminalHomePage-BX-sHKXF.js +6 -0
- package/public/assets/TokenManage-95LL4o8y.js +1 -0
- package/public/assets/{Tooltip-BTMAbLUj.js → Tooltip-3_9w-Oet.js} +1 -1
- package/public/assets/{TotpSetupPage-B9IghCSA.js → TotpSetupPage-BzyS9OrP.js} +1 -1
- package/public/assets/{WorkerDetailPage-D0Vz2Z_J.js → WorkerDetailPage-BaVeVMvg.js} +1 -1
- package/public/assets/WorkerListPage-zOEHoOtr.js +6 -0
- package/public/assets/{WorkerOperationsPage-Du5dUuwe.js → WorkerOperationsPage-B9A7kFhI.js} +1 -1
- package/public/assets/{WorkerSetupGuidePage-Chgd3lOw.js → WorkerSetupGuidePage-DzTffG6n.js} +1 -1
- package/public/assets/{WorkerSetupPage-DOy5dzpL.js → WorkerSetupPage-B28GH43r.js} +1 -1
- package/public/assets/{agent-type-options-DYVQzNPE.js → agent-type-options-BBcV6_LY.js} +1 -1
- package/public/assets/{arrow-left-BmJhqQxJ.js → arrow-left-BDjYIP3Y.js} +1 -1
- package/public/assets/{arrow-right-za11FMwb.js → arrow-right-DITZLrUG.js} +1 -1
- package/public/assets/{bot-BREu_dZH.js → bot-CJ6g-CgU.js} +1 -1
- package/public/assets/{chevron-down-pInOI1Sz.js → chevron-down-D9VkxIPs.js} +1 -1
- package/public/assets/{chevron-left-9sE-mZhp.js → chevron-left-CWC7W_zG.js} +1 -1
- package/public/assets/{chevron-right-BTVDsZF2.js → chevron-right-BDlNEjPF.js} +1 -1
- package/public/assets/{chevron-up-7pQBLB6e.js → chevron-up-B2_M0Aou.js} +1 -1
- package/public/assets/circle-alert-Cb6RgYCQ.js +6 -0
- package/public/assets/clock-CPiGRQpX.js +6 -0
- package/public/assets/{copy-Ciibu4ij.js → copy-Dz9BK4cr.js} +1 -1
- package/public/assets/{download-C5M-xVQE.js → download-qgK3DePm.js} +1 -1
- package/public/assets/{external-link-DXCE8f-2.js → external-link-kSTql_zg.js} +1 -1
- package/public/assets/{file-text-FxjQforC.js → file-text-moi4pXOm.js} +1 -1
- package/public/assets/{git-fork-BnUjRz81.js → git-fork-FS4LqWZJ.js} +1 -1
- package/public/assets/index-CdJk2QGi.css +1 -0
- package/public/assets/index-DEBRwDiX.js +257 -0
- package/public/assets/{key-DORG2Bvk.js → key-CHc_t6rY.js} +1 -1
- package/public/assets/{loader-circle-Ce741dwH.js → loader-circle-BEHOzbAc.js} +1 -1
- package/public/assets/{pencil-C4ejRMe1.js → pencil-COk9Cf4n.js} +1 -1
- package/public/assets/{play-w6NUT3Ge.js → play-B8L-TpIA.js} +1 -1
- package/public/assets/{plus-CgnoWo2P.js → plus-Bh23dSc7.js} +1 -1
- package/public/assets/{rotate-ccw-DE82XdM1.js → rotate-ccw-CumxDFOW.js} +1 -1
- package/public/assets/{scroll-text-DAbRTvTk.js → scroll-text-yKGiDEH2.js} +1 -1
- package/public/assets/{settings-B6CvfGJs.js → settings-BZ99cVpB.js} +1 -1
- package/public/assets/{skip-forward-kX5fzSWO.js → skip-forward-YMw2gv4i.js} +1 -1
- package/public/assets/{status-colors-DTc6Ynln.js → status-colors-CpxhEwhO.js} +1 -1
- package/public/assets/{task-constants-DFxPkPUs.js → task-constants-BOIiRs7J.js} +1 -1
- package/public/assets/{task.store-VJg4-Qif.js → task.store-B7v0IyXP.js} +1 -1
- package/public/assets/timer--KEJmHJk.js +6 -0
- package/public/assets/{trash-2-BTUlSSX7.js → trash-2-CGFhXY_R.js} +1 -1
- package/public/assets/{useFetch-DLQT-fqN.js → useFetch-_325GIxD.js} +1 -1
- package/public/assets/{users-B6ZPxGEF.js → users-0IqI-VRX.js} +1 -1
- package/public/assets/{wifi-RZmzDeRm.js → wifi-DveQJnOv.js} +1 -1
- package/public/assets/{workflow-C1oJzdp3.js → workflow-BUUDFa4R.js} +1 -1
- package/public/assets/zap-D2T18qt7.js +6 -0
- package/public/index.html +2 -2
- package/public/sw.js +1 -1
- package/public/assets/AccessTokensPage-BSxprw7x.js +0 -1
- package/public/assets/BotIntegrationPage-DP1ipK65.js +0 -1
- package/public/assets/ConfirmStageDialog-rt45LR8Q.js +0 -12
- package/public/assets/DeveloperManage-Ab6SdQEz.js +0 -16
- package/public/assets/ProjectListPage-QM4505IY.js +0 -6
- package/public/assets/PtyTerminal-BxD1WFmu.js +0 -38
- package/public/assets/RemoveMemberConfirmDialog-pg5SnIU8.js +0 -6
- package/public/assets/ReviewAggregatePage-DHUyVVeT.js +0 -11
- package/public/assets/TaskListPage-CL98Ev5l.js +0 -1
- package/public/assets/TerminalHomePage-CgZYHN7Y.js +0 -6
- package/public/assets/TokenManage-BU8KbNvZ.js +0 -1
- package/public/assets/WorkerListPage-B4aOYXSX.js +0 -6
- package/public/assets/index-CTVNJXL0.js +0 -252
- package/public/assets/index-kJfGgL_V.css +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automation-template.service.js","sourceRoot":"","sources":["../../src/automation/automation-template.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAoF;AAEpF,mDAAkH;AAClH,0FAAsF;AACtF,mEAAgE;AAEhE,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAA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,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACrG,CAAC;QACJ,CAAC;QAED,yEAAyE;QACzE,IAAA,6CAAqB,EAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC;YACxC,GAAG,IAAI;YACP,SAAS,EAAE,KAAK;YAChB,SAAS;YACT,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,EAAU;QACf,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;QAC1D,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,0BAAiB,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;QACxE,IAAI,QAAQ,CAAC,SAAS;YAAE,MAAM,IAAI,4BAAmB,CAAC,iCAAiC,CAAC,CAAC;QACzF,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;IAChD,CAAC;CACF,CAAA;AA3DY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,mBAAU,GAAE;qCAEkC,4CAAoB;GADtD,yBAAyB,CA2DrC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AutomationRepository } from '../database/repositories/automation.repository';
|
|
2
|
+
import { TaskRepository } from '../database/repositories/task.repository';
|
|
3
|
+
import { AutomationExecutor } from './automation-executor';
|
|
4
|
+
import { type TaskStatusChangedPayload } from '../events/event-types';
|
|
5
|
+
export declare class AutomationTrigger {
|
|
6
|
+
private readonly automationRepo;
|
|
7
|
+
private readonly taskRepo;
|
|
8
|
+
private readonly executor;
|
|
9
|
+
private readonly logger;
|
|
10
|
+
constructor(automationRepo: AutomationRepository, taskRepo: TaskRepository, executor: AutomationExecutor);
|
|
11
|
+
onTaskStatusChanged(payload: TaskStatusChangedPayload): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=automation-trigger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automation-trigger.d.ts","sourceRoot":"","sources":["../../src/automation/automation-trigger.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAgB,KAAK,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEpF,qBACa,iBAAiB;IAI1B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAL3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsC;gBAG1C,cAAc,EAAE,oBAAoB,EACpC,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,kBAAkB;IAIzC,mBAAmB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;CAsD5E"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var AutomationTrigger_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.AutomationTrigger = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const event_emitter_1 = require("@nestjs/event-emitter");
|
|
16
|
+
const protocol_1 = require("@overlordai/protocol");
|
|
17
|
+
const automation_repository_1 = require("../database/repositories/automation.repository");
|
|
18
|
+
const task_repository_1 = require("../database/repositories/task.repository");
|
|
19
|
+
const automation_executor_1 = require("./automation-executor");
|
|
20
|
+
const event_types_1 = require("../events/event-types");
|
|
21
|
+
let AutomationTrigger = AutomationTrigger_1 = class AutomationTrigger {
|
|
22
|
+
constructor(automationRepo, taskRepo, executor) {
|
|
23
|
+
this.automationRepo = automationRepo;
|
|
24
|
+
this.taskRepo = taskRepo;
|
|
25
|
+
this.executor = executor;
|
|
26
|
+
this.logger = new common_1.Logger(AutomationTrigger_1.name);
|
|
27
|
+
}
|
|
28
|
+
async onTaskStatusChanged(payload) {
|
|
29
|
+
try {
|
|
30
|
+
// 1. Anti-loop guard: Tasks created by automations have a non-null
|
|
31
|
+
// `automationRunId`. We must skip them to prevent infinite cycles
|
|
32
|
+
// where an automation's output task triggers the same (or another)
|
|
33
|
+
// automation, which would create yet another task, and so on.
|
|
34
|
+
const task = this.taskRepo.findById(payload.taskId);
|
|
35
|
+
if (!task || task.automationRunId != null)
|
|
36
|
+
return;
|
|
37
|
+
// 2. Only handle terminal statuses that match supported events
|
|
38
|
+
const eventMap = {
|
|
39
|
+
[protocol_1.TaskStatus.COMPLETED]: 'COMPLETED',
|
|
40
|
+
[protocol_1.TaskStatus.FAILED]: 'FAILED',
|
|
41
|
+
[protocol_1.TaskStatus.CANCELLED]: 'CANCELLED',
|
|
42
|
+
};
|
|
43
|
+
const eventName = eventMap[payload.status];
|
|
44
|
+
if (!eventName)
|
|
45
|
+
return;
|
|
46
|
+
// 3. Find all enabled task_event automations for the task's project
|
|
47
|
+
const automations = this.automationRepo.findEnabledTaskEvent(task.projectKey);
|
|
48
|
+
for (const automation of automations) {
|
|
49
|
+
try {
|
|
50
|
+
// Safety: skip automations from other projects (should not happen with SQL filter, but defensive)
|
|
51
|
+
if (task.projectKey !== automation.projectKey)
|
|
52
|
+
continue;
|
|
53
|
+
const config = automation.triggerConfig;
|
|
54
|
+
// Defensive: ensure config.event is a string before comparing
|
|
55
|
+
if (typeof config.event !== 'string' || config.event !== eventName)
|
|
56
|
+
continue;
|
|
57
|
+
// Match filter: projectKey and taskMode
|
|
58
|
+
const filter = config.filter;
|
|
59
|
+
if (filter?.projectKey && filter.projectKey !== task.projectKey)
|
|
60
|
+
continue;
|
|
61
|
+
if (filter?.taskMode && filter.taskMode !== task.taskMode)
|
|
62
|
+
continue;
|
|
63
|
+
// Execute automation
|
|
64
|
+
await this.executor.execute(automation, {
|
|
65
|
+
trigger: 'task_event',
|
|
66
|
+
event: eventName,
|
|
67
|
+
sourceTaskId: task.id,
|
|
68
|
+
sourceProjectKey: task.projectKey,
|
|
69
|
+
sourceTaskMode: task.taskMode,
|
|
70
|
+
});
|
|
71
|
+
this.logger.log(`Task event triggered automation #${automation.id} from task #${task.id}`);
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
this.logger.error(`Error triggering automation #${automation.id}: ${err}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
this.logger.error(`Error in AutomationTrigger.onTaskStatusChanged: ${err}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
exports.AutomationTrigger = AutomationTrigger;
|
|
84
|
+
__decorate([
|
|
85
|
+
(0, event_emitter_1.OnEvent)(event_types_1.DomainEvents.TASK_STATUS_CHANGED),
|
|
86
|
+
__metadata("design:type", Function),
|
|
87
|
+
__metadata("design:paramtypes", [Object]),
|
|
88
|
+
__metadata("design:returntype", Promise)
|
|
89
|
+
], AutomationTrigger.prototype, "onTaskStatusChanged", null);
|
|
90
|
+
exports.AutomationTrigger = AutomationTrigger = AutomationTrigger_1 = __decorate([
|
|
91
|
+
(0, common_1.Injectable)(),
|
|
92
|
+
__metadata("design:paramtypes", [automation_repository_1.AutomationRepository,
|
|
93
|
+
task_repository_1.TaskRepository,
|
|
94
|
+
automation_executor_1.AutomationExecutor])
|
|
95
|
+
], AutomationTrigger);
|
|
96
|
+
//# sourceMappingURL=automation-trigger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automation-trigger.js","sourceRoot":"","sources":["../../src/automation/automation-trigger.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,yDAAgD;AAChD,mDAAkD;AAClD,0FAAsF;AACtF,8EAA0E;AAC1E,+DAA2D;AAC3D,uDAAoF;AAG7E,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAG5B,YACmB,cAAoC,EACpC,QAAwB,EACxB,QAA4B;QAF5B,mBAAc,GAAd,cAAc,CAAsB;QACpC,aAAQ,GAAR,QAAQ,CAAgB;QACxB,aAAQ,GAAR,QAAQ,CAAoB;QAL9B,WAAM,GAAG,IAAI,eAAM,CAAC,mBAAiB,CAAC,IAAI,CAAC,CAAC;IAM1D,CAAC;IAGE,AAAN,KAAK,CAAC,mBAAmB,CAAC,OAAiC;QACzD,IAAI,CAAC;YACH,mEAAmE;YACnE,qEAAqE;YACrE,sEAAsE;YACtE,iEAAiE;YACjE,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACpD,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,eAAe,IAAI,IAAI;gBAAE,OAAO;YAElD,+DAA+D;YAC/D,MAAM,QAAQ,GAA2B;gBACvC,CAAC,qBAAU,CAAC,SAAS,CAAC,EAAE,WAAW;gBACnC,CAAC,qBAAU,CAAC,MAAM,CAAC,EA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AAC,CAAC;gBAC7F,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,UAAU,CAAC,EAAE,KAAK,GAAG,EAAE,CAAC,CAAC;gBAC7E,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mDAAmD,GAAG,EAAE,CAAC,CAAC;QAC9E,CAAC;IACH,CAAC;CACF,CAAA;AAhEY,8CAAiB;AAUtB;IADL,IAAA,uBAAO,EAAC,0BAAY,CAAC,mBAAmB,CAAC;;;;4DAsDzC;4BA/DU,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;qCAKwB,4CAAoB;QAC1B,gCAAc;QACd,wCAAkB;GANpC,iBAAiB,CAgE7B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate the cron expression using cron-parser.
|
|
3
|
+
* Throws BadRequestException if the expression is invalid.
|
|
4
|
+
*/
|
|
5
|
+
export declare function validateCronExpression(expression: string): void;
|
|
6
|
+
/**
|
|
7
|
+
* Validate triggerConfig structure based on trigger type.
|
|
8
|
+
* - For 'cron': must have a `cron` string, optional `timezone` IANA string.
|
|
9
|
+
* - For 'task_event': must have `event` as COMPLETED/FAILED/CANCELLED, optional `filter` object.
|
|
10
|
+
* - For 'manual': no required config fields.
|
|
11
|
+
* - Unknown triggerType values are rejected.
|
|
12
|
+
*/
|
|
13
|
+
export declare function validateTriggerConfig(triggerType: string, triggerConfig: Record<string, unknown>): void;
|
|
14
|
+
//# sourceMappingURL=automation-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automation-validation.d.ts","sourceRoot":"","sources":["../../src/automation/automation-validation.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAM/D;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACrC,IAAI,CAoCN"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.validateCronExpression = validateCronExpression;
|
|
7
|
+
exports.validateTriggerConfig = validateTriggerConfig;
|
|
8
|
+
const common_1 = require("@nestjs/common");
|
|
9
|
+
const protocol_1 = require("@overlordai/protocol");
|
|
10
|
+
const cron_parser_1 = __importDefault(require("cron-parser"));
|
|
11
|
+
const VALID_TASK_EVENTS = ['COMPLETED', 'FAILED', 'CANCELLED'];
|
|
12
|
+
const KNOWN_TRIGGER_TYPES = Object.values(protocol_1.AutomationTriggerType);
|
|
13
|
+
/**
|
|
14
|
+
* Validate the cron expression using cron-parser.
|
|
15
|
+
* Throws BadRequestException if the expression is invalid.
|
|
16
|
+
*/
|
|
17
|
+
function validateCronExpression(expression) {
|
|
18
|
+
try {
|
|
19
|
+
cron_parser_1.default.parseExpression(expression);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
throw new common_1.BadRequestException(`Invalid cron expression: '${expression}'`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Validate triggerConfig structure based on trigger type.
|
|
27
|
+
* - For 'cron': must have a `cron` string, optional `timezone` IANA string.
|
|
28
|
+
* - For 'task_event': must have `event` as COMPLETED/FAILED/CANCELLED, optional `filter` object.
|
|
29
|
+
* - For 'manual': no required config fields.
|
|
30
|
+
* - Unknown triggerType values are rejected.
|
|
31
|
+
*/
|
|
32
|
+
function validateTriggerConfig(triggerType, triggerConfig) {
|
|
33
|
+
if (triggerType === protocol_1.AutomationTriggerType.CRON) {
|
|
34
|
+
const cron = triggerConfig.cron;
|
|
35
|
+
if (typeof cron !== 'string' || cron.trim().length === 0) {
|
|
36
|
+
throw new common_1.BadRequestException('triggerConfig.cron is required for cron trigger type');
|
|
37
|
+
}
|
|
38
|
+
validateCronExpression(cron);
|
|
39
|
+
if (triggerConfig.timezone !== undefined) {
|
|
40
|
+
if (typeof triggerConfig.timezone !== 'string' || !triggerConfig.timezone.trim()) {
|
|
41
|
+
throw new common_1.BadRequestException('triggerConfig.timezone must be a non-empty string');
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
Intl.DateTimeFormat(undefined, { timeZone: triggerConfig.timezone });
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
throw new common_1.BadRequestException(`triggerConfig.timezone '${triggerConfig.timezone}' is not a valid IANA timezone`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else if (triggerType === protocol_1.AutomationTriggerType.TASK_EVENT) {
|
|
52
|
+
const event = triggerConfig.event;
|
|
53
|
+
if (typeof event !== 'string' || !VALID_TASK_EVENTS.includes(event)) {
|
|
54
|
+
throw new common_1.BadRequestException(`triggerConfig.event must be one of: ${VALID_TASK_EVENTS.join(', ')}`);
|
|
55
|
+
}
|
|
56
|
+
if (triggerConfig.filter !== undefined) {
|
|
57
|
+
if (typeof triggerConfig.filter !== 'object' || triggerConfig.filter === null || Array.isArray(triggerConfig.filter)) {
|
|
58
|
+
throw new common_1.BadRequestException('triggerConfig.filter must be an object');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else if (!KNOWN_TRIGGER_TYPES.includes(triggerType)) {
|
|
63
|
+
throw new common_1.BadRequestException(`Unknown triggerType '${triggerType}'`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=automation-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automation-validation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AC;YACvE,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,IAAI,4BAAmB,CAC3B,2BAA2B,aAAa,CAAC,QAAQ,gCAAgC,CAClF,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;SAAM,IAAI,WAAW,KAAK,gCAAqB,CAAC,UAAU,EAAE,CAAC;QAC5D,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;QAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAE,iBAAuC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3F,MAAM,IAAI,4BAAmB,CAC3B,uCAAuC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACtE,CAAC;QACJ,CAAC;QAED,IAAI,aAAa,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACvC,IAAI,OAAO,aAAa,CAAC,MAAM,KAAK,QAAQ,IAAI,aAAa,CAAC,MAAM,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;gBACrH,MAAM,IAAI,4BAAmB,CAAC,wCAAwC,CAAC,CAAC;YAC1E,CAAC;QACH,CAAC;IACH,CAAC;SAAM,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,4BAAmB,CAAC,wBAAwB,WAAW,GAAG,CAAC,CAAC;IACxE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automation.module.d.ts","sourceRoot":"","sources":["../../src/automation/automation.module.ts"],"names":[],"mappings":"AAQA,qBAWa,gBAAgB;CAAG"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AutomationModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const automation_service_1 = require("./automation.service");
|
|
12
|
+
const automation_scheduler_1 = require("./automation-scheduler");
|
|
13
|
+
const automation_trigger_1 = require("./automation-trigger");
|
|
14
|
+
const automation_executor_1 = require("./automation-executor");
|
|
15
|
+
const automation_template_service_1 = require("./automation-template.service");
|
|
16
|
+
const dispatcher_module_1 = require("../dispatcher/dispatcher.module");
|
|
17
|
+
let AutomationModule = class AutomationModule {
|
|
18
|
+
};
|
|
19
|
+
exports.AutomationModule = AutomationModule;
|
|
20
|
+
exports.AutomationModule = AutomationModule = __decorate([
|
|
21
|
+
(0, common_1.Module)({
|
|
22
|
+
imports: [dispatcher_module_1.DispatcherModule],
|
|
23
|
+
providers: [
|
|
24
|
+
automation_service_1.AutomationService,
|
|
25
|
+
automation_scheduler_1.AutomationScheduler,
|
|
26
|
+
automation_trigger_1.AutomationTrigger,
|
|
27
|
+
automation_executor_1.AutomationExecutor,
|
|
28
|
+
automation_template_service_1.AutomationTemplateService,
|
|
29
|
+
],
|
|
30
|
+
exports: [automation_service_1.AutomationService, automation_template_service_1.AutomationTemplateService, automation_executor_1.AutomationExecutor],
|
|
31
|
+
})
|
|
32
|
+
], AutomationModule);
|
|
33
|
+
//# sourceMappingURL=automation.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automation.module.js","sourceRoot":"","sources":["../../src/automation/automation.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6DAAyD;AACzD,iEAA6D;AAC7D,6DAAyD;AACzD,+DAA2D;AAC3D,+EAA0E;AAC1E,uEAAmE;AAa5D,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAAG,CAAA;AAAnB,4CAAgB;2BAAhB,gBAAgB;IAX5B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,oCAAgB,CAAC;QAC3B,SAAS,EAAE;YACT,sCAAiB;YACjB,0CAAmB;YACnB,sCAAiB;YACjB,wCAAkB;YAClB,uDAAyB;SAC1B;QACD,OAAO,EAAE,CAAC,sCAAiB,EAAE,uDAAyB,EAAE,wCAAkB,CAAC;KAC5E,CAAC;GACW,gBAAgB,CAAG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Automation, AutomationRun, CreateAutomationRequest, UpdateAutomationRequest, ListAutomationsQuery } from '@overlordai/protocol';
|
|
2
|
+
import { AutomationRepository } from '../database/repositories/automation.repository';
|
|
3
|
+
import { ProjectRepository } from '../database/repositories/project.repository';
|
|
4
|
+
import { AutomationScheduler } from './automation-scheduler';
|
|
5
|
+
import { AutomationExecutor } from './automation-executor';
|
|
6
|
+
export declare class AutomationService {
|
|
7
|
+
private readonly automationRepo;
|
|
8
|
+
private readonly projectRepo;
|
|
9
|
+
private readonly scheduler;
|
|
10
|
+
private readonly executor;
|
|
11
|
+
private readonly logger;
|
|
12
|
+
constructor(automationRepo: AutomationRepository, projectRepo: ProjectRepository, scheduler: AutomationScheduler, executor: AutomationExecutor);
|
|
13
|
+
create(request: CreateAutomationRequest, createdBy: number): Promise<Automation>;
|
|
14
|
+
update(id: number, request: UpdateAutomationRequest): Promise<Automation>;
|
|
15
|
+
delete(id: number): Promise<void>;
|
|
16
|
+
enable(id: number): Promise<Automation>;
|
|
17
|
+
disable(id: number): Promise<Automation>;
|
|
18
|
+
trigger(id: number): Promise<AutomationRun>;
|
|
19
|
+
findById(id: number): Automation | null;
|
|
20
|
+
findByProject(projectKey: string, query?: ListAutomationsQuery): Automation[];
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=automation.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automation.service.d.ts","sourceRoot":"","sources":["../../src/automation/automation.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAsB,uBAAuB,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAElK,OAAO,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAM3D,qBACa,iBAAiB;IAI1B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAN3B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsC;gBAG1C,cAAc,EAAE,oBAAoB,EACpC,WAAW,EAAE,iBAAiB,EAC9B,SAAS,EAAE,mBAAmB,EAC9B,QAAQ,EAAE,kBAAkB;IAGzC,MAAM,CAAC,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IA0DhF,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,UAAU,CAAC;IA0FzE,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBjC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAoBvC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAcxC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAOjD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAIvC,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,oBAAoB,GAAG,UAAU,EAAE;CAI9E"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var AutomationService_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.AutomationService = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const protocol_1 = require("@overlordai/protocol");
|
|
16
|
+
const automation_repository_1 = require("../database/repositories/automation.repository");
|
|
17
|
+
const project_repository_1 = require("../database/repositories/project.repository");
|
|
18
|
+
const automation_scheduler_1 = require("./automation-scheduler");
|
|
19
|
+
const automation_executor_1 = require("./automation-executor");
|
|
20
|
+
const automation_validation_1 = require("./automation-validation");
|
|
21
|
+
const VALID_TRIGGER_TYPES = Object.values(protocol_1.AutomationTriggerType);
|
|
22
|
+
const VALID_EXECUTION_MODES = Object.values(protocol_1.AutomationExecutionMode);
|
|
23
|
+
let AutomationService = AutomationService_1 = class AutomationService {
|
|
24
|
+
constructor(automationRepo, projectRepo, scheduler, executor) {
|
|
25
|
+
this.automationRepo = automationRepo;
|
|
26
|
+
this.projectRepo = projectRepo;
|
|
27
|
+
this.scheduler = scheduler;
|
|
28
|
+
this.executor = executor;
|
|
29
|
+
this.logger = new common_1.Logger(AutomationService_1.name);
|
|
30
|
+
}
|
|
31
|
+
async create(request, createdBy) {
|
|
32
|
+
// Validate project exists
|
|
33
|
+
const project = this.projectRepo.findByKey(request.projectKey);
|
|
34
|
+
if (!project) {
|
|
35
|
+
throw new common_1.NotFoundException(`Project '${request.projectKey}' not found`);
|
|
36
|
+
}
|
|
37
|
+
// Validate enum values
|
|
38
|
+
if (!VALID_TRIGGER_TYPES.includes(request.triggerType)) {
|
|
39
|
+
throw new common_1.BadRequestException(`Invalid triggerType '${request.triggerType}'. Must be one of: ${VALID_TRIGGER_TYPES.join(', ')}`);
|
|
40
|
+
}
|
|
41
|
+
if (!VALID_EXECUTION_MODES.includes(request.executionMode)) {
|
|
42
|
+
throw new common_1.BadRequestException(`Invalid executionMode '${request.executionMode}'. Must be one of: ${VALID_EXECUTION_MODES.join(', ')}`);
|
|
43
|
+
}
|
|
44
|
+
// Validate triggerConfig structure based on triggerType
|
|
45
|
+
(0, automation_validation_1.validateTriggerConfig)(request.triggerType, request.triggerConfig);
|
|
46
|
+
// Validate template exists if templateId is provided
|
|
47
|
+
if (request.templateId != null) {
|
|
48
|
+
const template = this.automationRepo.findTemplateById(request.templateId);
|
|
49
|
+
if (!template) {
|
|
50
|
+
throw new common_1.BadRequestException(`Template #${request.templateId} not found`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const automation = this.automationRepo.create({
|
|
54
|
+
projectKey: request.projectKey,
|
|
55
|
+
name: request.name,
|
|
56
|
+
description: request.description,
|
|
57
|
+
triggerType: request.triggerType,
|
|
58
|
+
triggerConfig: request.triggerConfig,
|
|
59
|
+
executionMode: request.executionMode,
|
|
60
|
+
taskConfig: (request.taskConfig ?? {}),
|
|
61
|
+
templateId: request.templateId,
|
|
62
|
+
createdBy,
|
|
63
|
+
enabled: true,
|
|
64
|
+
});
|
|
65
|
+
// Register cron job if applicable — rollback on failure
|
|
66
|
+
if (automation.triggerType === protocol_1.AutomationTriggerType.CRON && automation.enabled) {
|
|
67
|
+
const config = automation.triggerConfig;
|
|
68
|
+
try {
|
|
69
|
+
await this.scheduler.registerJob(automation.id, config);
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
this.automationRepo.delete(automation.id);
|
|
73
|
+
throw err;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
this.logger.log(`Automation #${automation.id} created by developer #${createdBy}`);
|
|
77
|
+
return automation;
|
|
78
|
+
}
|
|
79
|
+
async update(id, request) {
|
|
80
|
+
const existing = this.automationRepo.findById(id);
|
|
81
|
+
if (!existing)
|
|
82
|
+
throw new common_1.NotFoundException(`Automation #${id} not found`);
|
|
83
|
+
// Validate enum values if provided
|
|
84
|
+
if (request.triggerType !== undefined && !VALID_TRIGGER_TYPES.includes(request.triggerType)) {
|
|
85
|
+
throw new common_1.BadRequestException(`Invalid triggerType '${request.triggerType}'. Must be one of: ${VALID_TRIGGER_TYPES.join(', ')}`);
|
|
86
|
+
}
|
|
87
|
+
if (request.executionMode !== undefined && !VALID_EXECUTION_MODES.includes(request.executionMode)) {
|
|
88
|
+
throw new common_1.BadRequestException(`Invalid executionMode '${request.executionMode}'. Must be one of: ${VALID_EXECUTION_MODES.join(', ')}`);
|
|
89
|
+
}
|
|
90
|
+
// Validate triggerConfig if either triggerType or triggerConfig is being updated
|
|
91
|
+
const effectiveTriggerType = request.triggerType ?? existing.triggerType;
|
|
92
|
+
if (request.triggerConfig !== undefined) {
|
|
93
|
+
(0, automation_validation_1.validateTriggerConfig)(effectiveTriggerType, request.triggerConfig);
|
|
94
|
+
}
|
|
95
|
+
else if (request.triggerType !== undefined && request.triggerType !== existing.triggerType) {
|
|
96
|
+
// triggerType changed but triggerConfig not provided — validate existing config against new type
|
|
97
|
+
(0, automation_validation_1.validateTriggerConfig)(request.triggerType, existing.triggerConfig);
|
|
98
|
+
}
|
|
99
|
+
const oldTriggerType = existing.triggerType;
|
|
100
|
+
const newTriggerType = request.triggerType ?? oldTriggerType;
|
|
101
|
+
// Option C: do all scheduling changes FIRST, then persist to DB only on success.
|
|
102
|
+
// This ensures the DB is never left in a state where triggerConfig changed but
|
|
103
|
+
// the cron schedule did not (or vice versa).
|
|
104
|
+
if (existing.enabled) {
|
|
105
|
+
const isLeavingCron = oldTriggerType === protocol_1.AutomationTriggerType.CRON && newTriggerType !== protocol_1.AutomationTriggerType.CRON;
|
|
106
|
+
const isEnteringCron = newTriggerType === protocol_1.AutomationTriggerType.CRON;
|
|
107
|
+
const isUpdatingCron = oldTriggerType === protocol_1.AutomationTriggerType.CRON && newTriggerType === protocol_1.AutomationTriggerType.CRON;
|
|
108
|
+
const cronConfigChanged = isUpdatingCron && (request.triggerConfig !== undefined || request.triggerType !== undefined);
|
|
109
|
+
if (isLeavingCron) {
|
|
110
|
+
// Switching away from cron — remove old job. MUST succeed before DB update,
|
|
111
|
+
// otherwise the old cron keeps firing while DB says it's no longer cron.
|
|
112
|
+
await this.scheduler.removeJob(id);
|
|
113
|
+
}
|
|
114
|
+
else if (cronConfigChanged) {
|
|
115
|
+
// Updating the cron schedule — remove old repeatable FIRST, then register new.
|
|
116
|
+
// BullMQ repeatables are keyed by (name + pattern), so adding a new pattern
|
|
117
|
+
// without removing the old one leaves BOTH schedules active.
|
|
118
|
+
const newConfig = (request.triggerConfig ?? existing.triggerConfig);
|
|
119
|
+
const oldConfig = existing.triggerConfig;
|
|
120
|
+
await this.scheduler.removeJob(id);
|
|
121
|
+
try {
|
|
122
|
+
await this.scheduler.registerJob(id, newConfig);
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
// New schedule failed — restore the old one so the automation keeps running.
|
|
126
|
+
this.logger.warn(`Automation #${id}: registerJob failed after removeJob, restoring old schedule`);
|
|
127
|
+
try {
|
|
128
|
+
await this.scheduler.registerJob(id, oldConfig);
|
|
129
|
+
}
|
|
130
|
+
catch (restoreErr) {
|
|
131
|
+
// Restoration also failed — the automation has no active cron job.
|
|
132
|
+
// onModuleInit reconciliation will re-register from DB on next restart.
|
|
133
|
+
this.logger.error(`Automation #${id}: failed to restore old cron schedule — will self-heal on restart: ${restoreErr instanceof Error ? restoreErr.message : String(restoreErr)}`);
|
|
134
|
+
}
|
|
135
|
+
throw err;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else if (isEnteringCron) {
|
|
139
|
+
// Entering cron from another trigger type — just register.
|
|
140
|
+
const newConfig = (request.triggerConfig ?? existing.triggerConfig);
|
|
141
|
+
await this.scheduler.registerJob(id, newConfig);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const data = {};
|
|
145
|
+
if (request.name !== undefined)
|
|
146
|
+
data.name = request.name;
|
|
147
|
+
if (request.description !== undefined)
|
|
148
|
+
data.description = request.description;
|
|
149
|
+
if (request.triggerType !== undefined)
|
|
150
|
+
data.triggerType = request.triggerType;
|
|
151
|
+
if (request.triggerConfig !== undefined)
|
|
152
|
+
data.triggerConfig = request.triggerConfig;
|
|
153
|
+
if (request.executionMode !== undefined)
|
|
154
|
+
data.executionMode = request.executionMode;
|
|
155
|
+
if (request.taskConfig !== undefined)
|
|
156
|
+
data.taskConfig = request.taskConfig;
|
|
157
|
+
// Clear nextRunAt when switching away from cron trigger type
|
|
158
|
+
if (request.triggerType !== undefined && oldTriggerType === protocol_1.AutomationTriggerType.CRON && newTriggerType !== protocol_1.AutomationTriggerType.CRON) {
|
|
159
|
+
data.nextRunAt = null;
|
|
160
|
+
}
|
|
161
|
+
const updated = this.automationRepo.update(id, data);
|
|
162
|
+
if (!updated)
|
|
163
|
+
throw new common_1.NotFoundException(`Automation #${id} not found`);
|
|
164
|
+
return updated;
|
|
165
|
+
}
|
|
166
|
+
async delete(id) {
|
|
167
|
+
const existing = this.automationRepo.findById(id);
|
|
168
|
+
if (!existing)
|
|
169
|
+
throw new common_1.NotFoundException(`Automation #${id} not found`);
|
|
170
|
+
const activeRun = this.automationRepo.findActiveRun(id);
|
|
171
|
+
if (activeRun) {
|
|
172
|
+
throw new common_1.ConflictException('Cannot delete automation with active runs. Cancel active runs first.');
|
|
173
|
+
}
|
|
174
|
+
if (existing.enabled && existing.triggerType === protocol_1.AutomationTriggerType.CRON) {
|
|
175
|
+
await this.scheduler.removeJob(id);
|
|
176
|
+
}
|
|
177
|
+
this.automationRepo.delete(id);
|
|
178
|
+
this.logger.log(`Automation #${id} deleted`);
|
|
179
|
+
}
|
|
180
|
+
async enable(id) {
|
|
181
|
+
const automation = this.automationRepo.findById(id);
|
|
182
|
+
if (!automation)
|
|
183
|
+
throw new common_1.NotFoundException(`Automation #${id} not found`);
|
|
184
|
+
const updated = this.automationRepo.update(id, { enabled: true });
|
|
185
|
+
if (!updated)
|
|
186
|
+
throw new common_1.NotFoundException(`Automation #${id} not found`);
|
|
187
|
+
if (updated.triggerType === protocol_1.AutomationTriggerType.CRON) {
|
|
188
|
+
const config = updated.triggerConfig;
|
|
189
|
+
try {
|
|
190
|
+
await this.scheduler.registerJob(id, config);
|
|
191
|
+
}
|
|
192
|
+
catch (err) {
|
|
193
|
+
this.automationRepo.update(id, { enabled: false });
|
|
194
|
+
throw err;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return updated;
|
|
198
|
+
}
|
|
199
|
+
async disable(id) {
|
|
200
|
+
const automation = this.automationRepo.findById(id);
|
|
201
|
+
if (!automation)
|
|
202
|
+
throw new common_1.NotFoundException(`Automation #${id} not found`);
|
|
203
|
+
if (automation.triggerType === protocol_1.AutomationTriggerType.CRON) {
|
|
204
|
+
await this.scheduler.removeJob(id);
|
|
205
|
+
}
|
|
206
|
+
const updated = this.automationRepo.update(id, { enabled: false, nextRunAt: null });
|
|
207
|
+
if (!updated)
|
|
208
|
+
throw new common_1.NotFoundException(`Automation #${id} not found`);
|
|
209
|
+
return updated;
|
|
210
|
+
}
|
|
211
|
+
async trigger(id) {
|
|
212
|
+
const automation = this.automationRepo.findById(id);
|
|
213
|
+
if (!automation)
|
|
214
|
+
throw new common_1.NotFoundException(`Automation #${id} not found`);
|
|
215
|
+
return this.executor.execute(automation, { trigger: 'manual', triggeredAt: new Date().toISOString() });
|
|
216
|
+
}
|
|
217
|
+
findById(id) {
|
|
218
|
+
return this.automationRepo.findById(id);
|
|
219
|
+
}
|
|
220
|
+
findByProject(projectKey, query) {
|
|
221
|
+
return this.automationRepo.findByProject(projectKey, query);
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
exports.AutomationService = AutomationService;
|
|
225
|
+
exports.AutomationService = AutomationService = AutomationService_1 = __decorate([
|
|
226
|
+
(0, common_1.Injectable)(),
|
|
227
|
+
__metadata("design:paramtypes", [automation_repository_1.AutomationRepository,
|
|
228
|
+
project_repository_1.ProjectRepository,
|
|
229
|
+
automation_scheduler_1.AutomationScheduler,
|
|
230
|
+
automation_executor_1.AutomationExecutor])
|
|
231
|
+
], AutomationService);
|
|
232
|
+
//# sourceMappingURL=automation.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automation.service.js","sourceRoot":"","sources":["../../src/automation/automation.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAA+G;AAE/G,mDAAsF;AACtF,0FAAsF;AACtF,oFAAgF;AAChF,iEAA6D;AAC7D,+DAA2D;AAC3D,mEAAwF;AAExF,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,gCAAqB,CAAa,CAAC;AAC7E,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC,kCAAuB,CAAa,CAAC;AAG1E,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAG5B,YACmB,cAAoC,EACpC,WAA8B,EAC9B,S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,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAU;QACtB,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACpD,IAAI,CAAC,UAAU;YAAE,MAAM,IAAI,0BAAiB,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC;QAE5E,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACzG,CAAC;IAED,QAAQ,CAAC,EAAU;QACjB,OAAO,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,aAAa,CAAC,UAAkB,EAAE,KAA4B;QAC5D,OAAO,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAC9D,CAAC;CAEF,CAAA;AAhOY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;qCAKwB,4CAAoB;QACvB,sCAAiB;QACnB,0CAAmB;QACpB,wCAAkB;GAPpC,iBAAiB,CAgO7B"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { Automation, AutomationRun, AutomationTemplate, PaginatedResult, ListAutomationsQuery, ListAutomationRunsQuery } from '@overlordai/protocol';
|
|
2
|
+
import { DatabaseService } from '../database.service';
|
|
3
|
+
export declare class AutomationRepository {
|
|
4
|
+
private readonly db;
|
|
5
|
+
constructor(db: DatabaseService);
|
|
6
|
+
private findAutomations;
|
|
7
|
+
create(data: {
|
|
8
|
+
projectKey: string;
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
triggerType: string;
|
|
12
|
+
triggerConfig: Record<string, unknown>;
|
|
13
|
+
executionMode: string;
|
|
14
|
+
taskConfig: Record<string, unknown>;
|
|
15
|
+
templateId?: number;
|
|
16
|
+
createdBy: number;
|
|
17
|
+
enabled?: boolean;
|
|
18
|
+
nextRunAt?: string;
|
|
19
|
+
}): Automation;
|
|
20
|
+
findById(id: number): Automation | null;
|
|
21
|
+
findByProject(projectKey: string, opts?: ListAutomationsQuery): Automation[];
|
|
22
|
+
findAll(opts?: ListAutomationsQuery): Automation[];
|
|
23
|
+
findByProjects(projectKeys: string[], opts?: ListAutomationsQuery): Automation[];
|
|
24
|
+
findEnabledCron(): Automation[];
|
|
25
|
+
findEnabledTaskEvent(projectKey?: string): Automation[];
|
|
26
|
+
update(id: number, data: Partial<{
|
|
27
|
+
name: string;
|
|
28
|
+
description: string;
|
|
29
|
+
triggerType: string;
|
|
30
|
+
triggerConfig: Record<string, unknown>;
|
|
31
|
+
executionMode: string;
|
|
32
|
+
taskConfig: Record<string, unknown>;
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
lastRunAt: string | null;
|
|
35
|
+
nextRunAt: string | null;
|
|
36
|
+
}>): Automation | null;
|
|
37
|
+
delete(id: number): boolean;
|
|
38
|
+
createRun(data: {
|
|
39
|
+
automationId: number;
|
|
40
|
+
triggerType: string;
|
|
41
|
+
triggerContext: Record<string, unknown>;
|
|
42
|
+
status?: string;
|
|
43
|
+
}): AutomationRun;
|
|
44
|
+
findRunById(id: number): AutomationRun | null;
|
|
45
|
+
findActiveRun(automationId: number): AutomationRun | null;
|
|
46
|
+
updateRun(id: number, data: Partial<{
|
|
47
|
+
taskId: number;
|
|
48
|
+
status: string;
|
|
49
|
+
hasFindings: boolean;
|
|
50
|
+
findings: unknown[] | null;
|
|
51
|
+
inboxStatus: string;
|
|
52
|
+
startedAt: string;
|
|
53
|
+
completedAt: string;
|
|
54
|
+
}>): AutomationRun | null;
|
|
55
|
+
private buildRunFilters;
|
|
56
|
+
findRunsForInbox(query: ListAutomationRunsQuery, projectKeys?: string[] | null): PaginatedResult<AutomationRun>;
|
|
57
|
+
countRunsForInbox(query: ListAutomationRunsQuery, projectKeys?: string[] | null): number;
|
|
58
|
+
batchUpdateInboxStatus(ids: number[], status: string): number;
|
|
59
|
+
findStaleRuns(): AutomationRun[];
|
|
60
|
+
cleanupExpiredRuns(): number;
|
|
61
|
+
createTemplate(data: {
|
|
62
|
+
name: string;
|
|
63
|
+
description: string;
|
|
64
|
+
category: string;
|
|
65
|
+
triggerType: string;
|
|
66
|
+
triggerConfig: Record<string, unknown>;
|
|
67
|
+
executionMode: string;
|
|
68
|
+
taskDescription: string;
|
|
69
|
+
taskConfig: Record<string, unknown>;
|
|
70
|
+
isBuiltin?: boolean;
|
|
71
|
+
createdBy?: number;
|
|
72
|
+
projectKey?: string;
|
|
73
|
+
}): AutomationTemplate;
|
|
74
|
+
findTemplateById(id: number): AutomationTemplate | null;
|
|
75
|
+
findTemplates(query: {
|
|
76
|
+
category?: string;
|
|
77
|
+
isBuiltin?: boolean;
|
|
78
|
+
projectKey?: string;
|
|
79
|
+
}): AutomationTemplate[];
|
|
80
|
+
findTemplatesForProjects(query: {
|
|
81
|
+
category?: string;
|
|
82
|
+
isBuiltin?: boolean;
|
|
83
|
+
projectKeys?: string[] | null;
|
|
84
|
+
}): AutomationTemplate[];
|
|
85
|
+
deleteTemplate(id: number): boolean;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=automation.repository.d.ts.map
|