@mtkn/mega-agent 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/artifact/artifact.repository.d.ts +17 -0
- package/dist/artifact/artifact.repository.d.ts.map +1 -0
- package/dist/artifact/artifact.repository.js +66 -0
- package/dist/artifact/artifact.repository.js.map +1 -0
- package/dist/artifact/artifact.service.d.ts +22 -0
- package/dist/artifact/artifact.service.d.ts.map +1 -0
- package/dist/artifact/artifact.service.js +87 -0
- package/dist/artifact/artifact.service.js.map +1 -0
- package/dist/artifact/artifact.types.d.ts +41 -0
- package/dist/artifact/artifact.types.d.ts.map +1 -0
- package/dist/artifact/artifact.types.js +6 -0
- package/dist/artifact/artifact.types.js.map +1 -0
- package/dist/artifact/index.d.ts +6 -0
- package/dist/artifact/index.d.ts.map +1 -0
- package/dist/artifact/index.js +4 -0
- package/dist/artifact/index.js.map +1 -0
- package/dist/chat/chat-memory.integration.d.ts +59 -0
- package/dist/chat/chat-memory.integration.d.ts.map +1 -0
- package/dist/chat/chat-memory.integration.js +148 -0
- package/dist/chat/chat-memory.integration.js.map +1 -0
- package/dist/chat/chat.repository.d.ts +58 -0
- package/dist/chat/chat.repository.d.ts.map +1 -0
- package/dist/chat/chat.repository.js +128 -0
- package/dist/chat/chat.repository.js.map +1 -0
- package/dist/chat/chat.service.d.ts +28 -0
- package/dist/chat/chat.service.d.ts.map +1 -0
- package/dist/chat/chat.service.js +217 -0
- package/dist/chat/chat.service.js.map +1 -0
- package/dist/chat/chat.types.d.ts +198 -0
- package/dist/chat/chat.types.d.ts.map +1 -0
- package/dist/chat/chat.types.js +8 -0
- package/dist/chat/chat.types.js.map +1 -0
- package/dist/chat/index.d.ts +17 -0
- package/dist/chat/index.d.ts.map +1 -0
- package/dist/chat/index.js +16 -0
- package/dist/chat/index.js.map +1 -0
- package/dist/chat/memory-detector.d.ts +53 -0
- package/dist/chat/memory-detector.d.ts.map +1 -0
- package/dist/chat/memory-detector.js +172 -0
- package/dist/chat/memory-detector.js.map +1 -0
- package/dist/chat/prompts/index.d.ts +6 -0
- package/dist/chat/prompts/index.d.ts.map +1 -0
- package/dist/chat/prompts/index.js +6 -0
- package/dist/chat/prompts/index.js.map +1 -0
- package/dist/chat/prompts/system.prompts.d.ts +23 -0
- package/dist/chat/prompts/system.prompts.d.ts.map +1 -0
- package/dist/chat/prompts/system.prompts.js +102 -0
- package/dist/chat/prompts/system.prompts.js.map +1 -0
- package/dist/chat/response-parser.d.ts +24 -0
- package/dist/chat/response-parser.d.ts.map +1 -0
- package/dist/chat/response-parser.js +198 -0
- package/dist/chat/response-parser.js.map +1 -0
- package/dist/chat/response.types.d.ts +90 -0
- package/dist/chat/response.types.d.ts.map +1 -0
- package/dist/chat/response.types.js +6 -0
- package/dist/chat/response.types.js.map +1 -0
- package/dist/common/errors.d.ts +60 -0
- package/dist/common/errors.d.ts.map +1 -0
- package/dist/common/errors.js +105 -0
- package/dist/common/errors.js.map +1 -0
- package/dist/common/index.d.ts +3 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/index.js +3 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/retry.d.ts +23 -0
- package/dist/common/retry.d.ts.map +1 -0
- package/dist/common/retry.js +57 -0
- package/dist/common/retry.js.map +1 -0
- package/dist/create-mega-agent.d.ts +100 -0
- package/dist/create-mega-agent.d.ts.map +1 -0
- package/dist/create-mega-agent.js +153 -0
- package/dist/create-mega-agent.js.map +1 -0
- package/dist/embedding/embedding.service.d.ts +34 -0
- package/dist/embedding/embedding.service.d.ts.map +1 -0
- package/dist/embedding/embedding.service.js +68 -0
- package/dist/embedding/embedding.service.js.map +1 -0
- package/dist/embedding/embedding.types.d.ts +38 -0
- package/dist/embedding/embedding.types.d.ts.map +1 -0
- package/dist/embedding/embedding.types.js +6 -0
- package/dist/embedding/embedding.types.js.map +1 -0
- package/dist/embedding/index.d.ts +9 -0
- package/dist/embedding/index.d.ts.map +1 -0
- package/dist/embedding/index.js +9 -0
- package/dist/embedding/index.js.map +1 -0
- package/dist/embedding/providers/base.provider.d.ts +29 -0
- package/dist/embedding/providers/base.provider.d.ts.map +1 -0
- package/dist/embedding/providers/base.provider.js +19 -0
- package/dist/embedding/providers/base.provider.js.map +1 -0
- package/dist/embedding/providers/index.d.ts +7 -0
- package/dist/embedding/providers/index.d.ts.map +1 -0
- package/dist/embedding/providers/index.js +7 -0
- package/dist/embedding/providers/index.js.map +1 -0
- package/dist/embedding/providers/openai.provider.d.ts +17 -0
- package/dist/embedding/providers/openai.provider.d.ts.map +1 -0
- package/dist/embedding/providers/openai.provider.js +73 -0
- package/dist/embedding/providers/openai.provider.js.map +1 -0
- package/dist/http/chat.controller.d.ts +30 -0
- package/dist/http/chat.controller.d.ts.map +1 -0
- package/dist/http/chat.controller.js +163 -0
- package/dist/http/chat.controller.js.map +1 -0
- package/dist/http/chat.routes.d.ts +5 -0
- package/dist/http/chat.routes.d.ts.map +1 -0
- package/dist/http/chat.routes.js +38 -0
- package/dist/http/chat.routes.js.map +1 -0
- package/dist/http/chat.validation.d.ts +70 -0
- package/dist/http/chat.validation.d.ts.map +1 -0
- package/dist/http/chat.validation.js +28 -0
- package/dist/http/chat.validation.js.map +1 -0
- package/dist/incident/incident.correlator.d.ts +39 -0
- package/dist/incident/incident.correlator.d.ts.map +1 -0
- package/dist/incident/incident.correlator.js +129 -0
- package/dist/incident/incident.correlator.js.map +1 -0
- package/dist/incident/incident.detector.d.ts +62 -0
- package/dist/incident/incident.detector.d.ts.map +1 -0
- package/dist/incident/incident.detector.js +192 -0
- package/dist/incident/incident.detector.js.map +1 -0
- package/dist/incident/incident.repository.d.ts +79 -0
- package/dist/incident/incident.repository.d.ts.map +1 -0
- package/dist/incident/incident.repository.js +216 -0
- package/dist/incident/incident.repository.js.map +1 -0
- package/dist/incident/incident.service.d.ts +71 -0
- package/dist/incident/incident.service.d.ts.map +1 -0
- package/dist/incident/incident.service.js +217 -0
- package/dist/incident/incident.service.js.map +1 -0
- package/dist/incident/incident.types.d.ts +115 -0
- package/dist/incident/incident.types.d.ts.map +1 -0
- package/dist/incident/incident.types.js +6 -0
- package/dist/incident/incident.types.js.map +1 -0
- package/dist/incident/index.d.ts +13 -0
- package/dist/incident/index.d.ts.map +1 -0
- package/dist/incident/index.js +13 -0
- package/dist/incident/index.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/index.d.ts +8 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +9 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/llm.service.d.ts +52 -0
- package/dist/llm/llm.service.d.ts.map +1 -0
- package/dist/llm/llm.service.js +141 -0
- package/dist/llm/llm.service.js.map +1 -0
- package/dist/llm/llm.types.d.ts +77 -0
- package/dist/llm/llm.types.d.ts.map +1 -0
- package/dist/llm/llm.types.js +5 -0
- package/dist/llm/llm.types.js.map +1 -0
- package/dist/llm/providers/anthropic.provider.d.ts +16 -0
- package/dist/llm/providers/anthropic.provider.d.ts.map +1 -0
- package/dist/llm/providers/anthropic.provider.js +118 -0
- package/dist/llm/providers/anthropic.provider.js.map +1 -0
- package/dist/llm/providers/base.provider.d.ts +17 -0
- package/dist/llm/providers/base.provider.d.ts.map +1 -0
- package/dist/llm/providers/base.provider.js +18 -0
- package/dist/llm/providers/base.provider.js.map +1 -0
- package/dist/llm/providers/custom.provider.d.ts +15 -0
- package/dist/llm/providers/custom.provider.d.ts.map +1 -0
- package/dist/llm/providers/custom.provider.js +110 -0
- package/dist/llm/providers/custom.provider.js.map +1 -0
- package/dist/llm/providers/gemini.provider.d.ts +19 -0
- package/dist/llm/providers/gemini.provider.d.ts.map +1 -0
- package/dist/llm/providers/gemini.provider.js +98 -0
- package/dist/llm/providers/gemini.provider.js.map +1 -0
- package/dist/llm/providers/index.d.ts +10 -0
- package/dist/llm/providers/index.d.ts.map +1 -0
- package/dist/llm/providers/index.js +10 -0
- package/dist/llm/providers/index.js.map +1 -0
- package/dist/llm/providers/openai.provider.d.ts +15 -0
- package/dist/llm/providers/openai.provider.d.ts.map +1 -0
- package/dist/llm/providers/openai.provider.js +57 -0
- package/dist/llm/providers/openai.provider.js.map +1 -0
- package/dist/mcp/index.d.ts +13 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +17 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/mcp.client.d.ts +57 -0
- package/dist/mcp/mcp.client.d.ts.map +1 -0
- package/dist/mcp/mcp.client.js +150 -0
- package/dist/mcp/mcp.client.js.map +1 -0
- package/dist/mcp/mcp.service.d.ts +64 -0
- package/dist/mcp/mcp.service.d.ts.map +1 -0
- package/dist/mcp/mcp.service.js +207 -0
- package/dist/mcp/mcp.service.js.map +1 -0
- package/dist/mcp/mcp.types.d.ts +142 -0
- package/dist/mcp/mcp.types.d.ts.map +1 -0
- package/dist/mcp/mcp.types.js +6 -0
- package/dist/mcp/mcp.types.js.map +1 -0
- package/dist/mcp/presets/common-sources.d.ts +28 -0
- package/dist/mcp/presets/common-sources.d.ts.map +1 -0
- package/dist/mcp/presets/common-sources.js +114 -0
- package/dist/mcp/presets/common-sources.js.map +1 -0
- package/dist/mcp/presets/index.d.ts +5 -0
- package/dist/mcp/presets/index.d.ts.map +1 -0
- package/dist/mcp/presets/index.js +5 -0
- package/dist/mcp/presets/index.js.map +1 -0
- package/dist/mcp/source.repository.d.ts +68 -0
- package/dist/mcp/source.repository.d.ts.map +1 -0
- package/dist/mcp/source.repository.js +114 -0
- package/dist/mcp/source.repository.js.map +1 -0
- package/dist/mcp/source.service.d.ts +74 -0
- package/dist/mcp/source.service.d.ts.map +1 -0
- package/dist/mcp/source.service.js +181 -0
- package/dist/mcp/source.service.js.map +1 -0
- package/dist/mcp/transports/http.transport.d.ts +45 -0
- package/dist/mcp/transports/http.transport.d.ts.map +1 -0
- package/dist/mcp/transports/http.transport.js +64 -0
- package/dist/mcp/transports/http.transport.js.map +1 -0
- package/dist/mcp/transports/index.d.ts +7 -0
- package/dist/mcp/transports/index.d.ts.map +1 -0
- package/dist/mcp/transports/index.js +7 -0
- package/dist/mcp/transports/index.js.map +1 -0
- package/dist/mcp/transports/stdio.transport.d.ts +21 -0
- package/dist/mcp/transports/stdio.transport.d.ts.map +1 -0
- package/dist/mcp/transports/stdio.transport.js +29 -0
- package/dist/mcp/transports/stdio.transport.js.map +1 -0
- package/dist/memory/index.d.ts +10 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +10 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/memory.repository.d.ts +62 -0
- package/dist/memory/memory.repository.d.ts.map +1 -0
- package/dist/memory/memory.repository.js +148 -0
- package/dist/memory/memory.repository.js.map +1 -0
- package/dist/memory/memory.service.d.ts +63 -0
- package/dist/memory/memory.service.d.ts.map +1 -0
- package/dist/memory/memory.service.js +263 -0
- package/dist/memory/memory.service.js.map +1 -0
- package/dist/memory/memory.types.d.ts +104 -0
- package/dist/memory/memory.types.d.ts.map +1 -0
- package/dist/memory/memory.types.js +8 -0
- package/dist/memory/memory.types.js.map +1 -0
- package/dist/qdrant/index.d.ts +8 -0
- package/dist/qdrant/index.d.ts.map +1 -0
- package/dist/qdrant/index.js +6 -0
- package/dist/qdrant/index.js.map +1 -0
- package/dist/qdrant/qdrant.service.d.ts +63 -0
- package/dist/qdrant/qdrant.service.d.ts.map +1 -0
- package/dist/qdrant/qdrant.service.js +201 -0
- package/dist/qdrant/qdrant.service.js.map +1 -0
- package/dist/qdrant/qdrant.types.d.ts +55 -0
- package/dist/qdrant/qdrant.types.d.ts.map +1 -0
- package/dist/qdrant/qdrant.types.js +6 -0
- package/dist/qdrant/qdrant.types.js.map +1 -0
- package/dist/tools/core-tools.d.ts +7 -0
- package/dist/tools/core-tools.d.ts.map +1 -0
- package/dist/tools/core-tools.js +52 -0
- package/dist/tools/core-tools.js.map +1 -0
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +3 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/tool-registry.d.ts +51 -0
- package/dist/tools/tool-registry.d.ts.map +1 -0
- package/dist/tools/tool-registry.js +50 -0
- package/dist/tools/tool-registry.js.map +1 -0
- package/dist/workflow/actions/base.action.d.ts +50 -0
- package/dist/workflow/actions/base.action.d.ts.map +1 -0
- package/dist/workflow/actions/base.action.js +59 -0
- package/dist/workflow/actions/base.action.js.map +1 -0
- package/dist/workflow/actions/incident.action.d.ts +13 -0
- package/dist/workflow/actions/incident.action.d.ts.map +1 -0
- package/dist/workflow/actions/incident.action.js +70 -0
- package/dist/workflow/actions/incident.action.js.map +1 -0
- package/dist/workflow/actions/index.d.ts +9 -0
- package/dist/workflow/actions/index.d.ts.map +1 -0
- package/dist/workflow/actions/index.js +11 -0
- package/dist/workflow/actions/index.js.map +1 -0
- package/dist/workflow/actions/notify.action.d.ts +18 -0
- package/dist/workflow/actions/notify.action.d.ts.map +1 -0
- package/dist/workflow/actions/notify.action.js +106 -0
- package/dist/workflow/actions/notify.action.js.map +1 -0
- package/dist/workflow/actions/report.action.d.ts +13 -0
- package/dist/workflow/actions/report.action.d.ts.map +1 -0
- package/dist/workflow/actions/report.action.js +64 -0
- package/dist/workflow/actions/report.action.js.map +1 -0
- package/dist/workflow/index.d.ts +10 -0
- package/dist/workflow/index.d.ts.map +1 -0
- package/dist/workflow/index.js +11 -0
- package/dist/workflow/index.js.map +1 -0
- package/dist/workflow/workflow.repository.d.ts +90 -0
- package/dist/workflow/workflow.repository.d.ts.map +1 -0
- package/dist/workflow/workflow.repository.js +238 -0
- package/dist/workflow/workflow.repository.js.map +1 -0
- package/dist/workflow/workflow.service.d.ts +98 -0
- package/dist/workflow/workflow.service.d.ts.map +1 -0
- package/dist/workflow/workflow.service.js +374 -0
- package/dist/workflow/workflow.service.js.map +1 -0
- package/dist/workflow/workflow.types.d.ts +146 -0
- package/dist/workflow/workflow.types.d.ts.map +1 -0
- package/dist/workflow/workflow.types.js +8 -0
- package/dist/workflow/workflow.types.js.map +1 -0
- package/package.json +67 -0
- package/prisma/schema.prisma +551 -0
- package/scripts/prisma-sync.mjs +187 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Registry
|
|
3
|
+
* Central registry for all tools available to the Agent Loop.
|
|
4
|
+
* Each tool wraps an existing backend service method.
|
|
5
|
+
*/
|
|
6
|
+
let _tools = new Map();
|
|
7
|
+
/** Register a tool */
|
|
8
|
+
export function registerTool(tool) {
|
|
9
|
+
_tools.set(tool.name, tool);
|
|
10
|
+
}
|
|
11
|
+
/** Register multiple tools */
|
|
12
|
+
export function registerTools(tools) {
|
|
13
|
+
for (const tool of tools)
|
|
14
|
+
_tools.set(tool.name, tool);
|
|
15
|
+
}
|
|
16
|
+
/** Get a tool by name */
|
|
17
|
+
export function getTool(name) {
|
|
18
|
+
return _tools.get(name);
|
|
19
|
+
}
|
|
20
|
+
/** Get all registered tools */
|
|
21
|
+
export function getAllTools() {
|
|
22
|
+
return Array.from(_tools.values());
|
|
23
|
+
}
|
|
24
|
+
/** Check if a tool requires approval */
|
|
25
|
+
export function requiresApproval(name) {
|
|
26
|
+
const tool = _tools.get(name);
|
|
27
|
+
return tool?.category === 'write';
|
|
28
|
+
}
|
|
29
|
+
/** Execute a tool */
|
|
30
|
+
export async function executeTool(name, args, userId) {
|
|
31
|
+
const tool = _tools.get(name);
|
|
32
|
+
if (!tool)
|
|
33
|
+
return { toolName: name, success: false, error: `Tool '${name}' not found` };
|
|
34
|
+
try {
|
|
35
|
+
const data = await tool.handler(args, userId);
|
|
36
|
+
return { toolName: name, success: true, data };
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
return { toolName: name, success: false, error: String(err) };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Convert tools to Anthropic tool format */
|
|
43
|
+
export function toAnthropicTools() {
|
|
44
|
+
return getAllTools().map(t => ({
|
|
45
|
+
name: t.name,
|
|
46
|
+
description: t.description,
|
|
47
|
+
input_schema: t.inputSchema,
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=tool-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-registry.js","sourceRoot":"","sources":["../../src/tools/tool-registry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAyBH,IAAI,MAAM,GAAgC,IAAI,GAAG,EAAE,CAAC;AAEpD,sBAAsB;AACtB,MAAM,UAAU,YAAY,CAAC,IAAoB;IAC/C,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAC9B,CAAC;AAED,8BAA8B;AAC9B,MAAM,UAAU,aAAa,CAAC,KAAuB;IACnD,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACxD,CAAC;AAED,yBAAyB;AACzB,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,+BAA+B;AAC/B,MAAM,UAAU,WAAW;IACzB,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,wCAAwC;AACxC,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9B,OAAO,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC;AACpC,CAAC;AAED,qBAAqB;AACrB,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,IAAY,EACZ,IAA6B,EAC7B,MAAc;IAEd,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,IAAI,aAAa,EAAE,CAAC;IAExF,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC9C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACjD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IAChE,CAAC;AACH,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,gBAAgB;IAK9B,OAAO,WAAW,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC7B,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,WAAW,EAAE,CAAC,CAAC,WAAW;QAC1B,YAAY,EAAE,CAAC,CAAC,WAAW;KAC5B,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Action
|
|
3
|
+
* Abstract base class for workflow actions
|
|
4
|
+
*/
|
|
5
|
+
import type { Prisma, PrismaClient } from '@prisma/client';
|
|
6
|
+
import type { LoggerLike, ExecutionContext, WorkflowAction } from '../workflow.types.js';
|
|
7
|
+
export interface ActionExecutionResult {
|
|
8
|
+
success: boolean;
|
|
9
|
+
output?: unknown;
|
|
10
|
+
error?: string;
|
|
11
|
+
metadata?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
export interface BaseActionDependencies {
|
|
14
|
+
logger: LoggerLike;
|
|
15
|
+
prisma: Prisma.TransactionClient | PrismaClient;
|
|
16
|
+
}
|
|
17
|
+
export declare abstract class BaseAction {
|
|
18
|
+
protected logger: LoggerLike;
|
|
19
|
+
protected prisma: Prisma.TransactionClient | PrismaClient;
|
|
20
|
+
constructor(deps: BaseActionDependencies);
|
|
21
|
+
/**
|
|
22
|
+
* Execute the action
|
|
23
|
+
*/
|
|
24
|
+
abstract execute(config: WorkflowAction, context: ExecutionContext): Promise<ActionExecutionResult>;
|
|
25
|
+
/**
|
|
26
|
+
* Get the action type
|
|
27
|
+
*/
|
|
28
|
+
abstract get type(): string;
|
|
29
|
+
/**
|
|
30
|
+
* Validate the action configuration
|
|
31
|
+
*/
|
|
32
|
+
abstract validate(config: WorkflowAction): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Interpolate variables in a string
|
|
35
|
+
*/
|
|
36
|
+
protected interpolateVariables(template: string, context: ExecutionContext): string;
|
|
37
|
+
/**
|
|
38
|
+
* Get a value from context variables
|
|
39
|
+
*/
|
|
40
|
+
protected getContextValue(key: string, context: ExecutionContext): unknown;
|
|
41
|
+
/**
|
|
42
|
+
* Log action start
|
|
43
|
+
*/
|
|
44
|
+
protected logStart(context: ExecutionContext): void;
|
|
45
|
+
/**
|
|
46
|
+
* Log action completion
|
|
47
|
+
*/
|
|
48
|
+
protected logComplete(context: ExecutionContext, result: ActionExecutionResult): void;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=base.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.action.d.ts","sourceRoot":"","sources":["../../../src/workflow/actions/base.action.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,cAAc,EACf,MAAM,sBAAsB,CAAC;AAE9B,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,iBAAiB,GAAG,YAAY,CAAC;CACjD;AAED,8BAAsB,UAAU;IAC9B,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC;IAC7B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,iBAAiB,GAAG,YAAY,CAAC;gBAE9C,IAAI,EAAE,sBAAsB;IAKxC;;OAEG;IACH,QAAQ,CAAC,OAAO,CACd,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,qBAAqB,CAAC;IAEjC;;OAEG;IACH,QAAQ,KAAK,IAAI,IAAI,MAAM,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO;IAElD;;OAEG;IACH,SAAS,CAAC,oBAAoB,CAC5B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,gBAAgB,GACxB,MAAM;IAaT;;OAEG;IACH,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO;IAI1E;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAOnD;;OAEG;IACH,SAAS,CAAC,WAAW,CACnB,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,qBAAqB,GAC5B,IAAI;CAcR"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Action
|
|
3
|
+
* Abstract base class for workflow actions
|
|
4
|
+
*/
|
|
5
|
+
export class BaseAction {
|
|
6
|
+
logger;
|
|
7
|
+
prisma;
|
|
8
|
+
constructor(deps) {
|
|
9
|
+
this.logger = deps.logger;
|
|
10
|
+
this.prisma = deps.prisma;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Interpolate variables in a string
|
|
14
|
+
*/
|
|
15
|
+
interpolateVariables(template, context) {
|
|
16
|
+
let result = template;
|
|
17
|
+
// Replace {{variable}} patterns with context values
|
|
18
|
+
const variablePattern = /\{\{(\w+)\}\}/g;
|
|
19
|
+
result = result.replace(variablePattern, (_, key) => {
|
|
20
|
+
const value = context.variables[key];
|
|
21
|
+
return value !== undefined ? String(value) : `{{${key}}}`;
|
|
22
|
+
});
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Get a value from context variables
|
|
27
|
+
*/
|
|
28
|
+
getContextValue(key, context) {
|
|
29
|
+
return context.variables[key];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Log action start
|
|
33
|
+
*/
|
|
34
|
+
logStart(context) {
|
|
35
|
+
this.logger.debug(`Starting action: ${this.type}`, {
|
|
36
|
+
workflowId: context.workflowId,
|
|
37
|
+
executionId: context.executionId,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Log action completion
|
|
42
|
+
*/
|
|
43
|
+
logComplete(context, result) {
|
|
44
|
+
if (result.success) {
|
|
45
|
+
this.logger.debug(`Action completed: ${this.type}`, {
|
|
46
|
+
workflowId: context.workflowId,
|
|
47
|
+
executionId: context.executionId,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
this.logger.warn(`Action failed: ${this.type}`, {
|
|
52
|
+
workflowId: context.workflowId,
|
|
53
|
+
executionId: context.executionId,
|
|
54
|
+
error: result.error,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=base.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.action.js","sourceRoot":"","sources":["../../../src/workflow/actions/base.action.ts"],"names":[],"mappings":"AAAA;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AAC,UAAU;gBAC9B,WAAW,EAAE,OAAO,CAAC,WAAW;aACjC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,IAAI,CAAC,IAAI,EAAE,EAAE;gBAC9C,UAAU,EAAE,OAAO,CAAC,UAAU;gBAC9B,WAAW,EAAE,OAAO,CAAC,WAAW;gBAChC,KAAK,EAAE,MAAM,CAAC,KAAK;aACpB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Incident Action
|
|
3
|
+
* Create incidents from workflow triggers
|
|
4
|
+
*/
|
|
5
|
+
import type { ExecutionContext, CreateIncidentActionConfig } from '../workflow.types.js';
|
|
6
|
+
import { BaseAction, type ActionExecutionResult, type BaseActionDependencies } from './base.action.js';
|
|
7
|
+
export declare class IncidentAction extends BaseAction {
|
|
8
|
+
constructor(deps: BaseActionDependencies);
|
|
9
|
+
get type(): string;
|
|
10
|
+
validate(config: CreateIncidentActionConfig): boolean;
|
|
11
|
+
execute(config: CreateIncidentActionConfig, context: ExecutionContext): Promise<ActionExecutionResult>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=incident.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"incident.action.d.ts","sourceRoot":"","sources":["../../../src/workflow/actions/incident.action.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,UAAU,EACV,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC5B,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,cAAe,SAAQ,UAAU;gBAChC,IAAI,EAAE,sBAAsB;IAIxC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,QAAQ,CAAC,MAAM,EAAE,0BAA0B,GAAG,OAAO;IAM/C,OAAO,CACX,MAAM,EAAE,0BAA0B,EAClC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,qBAAqB,CAAC;CAmDlC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Incident Action
|
|
3
|
+
* Create incidents from workflow triggers
|
|
4
|
+
*/
|
|
5
|
+
import { BaseAction, } from './base.action.js';
|
|
6
|
+
export class IncidentAction extends BaseAction {
|
|
7
|
+
constructor(deps) {
|
|
8
|
+
super(deps);
|
|
9
|
+
}
|
|
10
|
+
get type() {
|
|
11
|
+
return 'create_incident';
|
|
12
|
+
}
|
|
13
|
+
validate(config) {
|
|
14
|
+
if (!config.severity)
|
|
15
|
+
return false;
|
|
16
|
+
if (!config.title)
|
|
17
|
+
return false;
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
async execute(config, context) {
|
|
21
|
+
this.logStart(context);
|
|
22
|
+
try {
|
|
23
|
+
const title = this.interpolateVariables(config.title, context);
|
|
24
|
+
const description = config.description
|
|
25
|
+
? this.interpolateVariables(config.description, context)
|
|
26
|
+
: undefined;
|
|
27
|
+
// Create real incident via IncidentService
|
|
28
|
+
const { getIncidentServiceDeps, IncidentService } = await import('../../incident/index.js');
|
|
29
|
+
let incidentId;
|
|
30
|
+
if (getIncidentServiceDeps()) {
|
|
31
|
+
const svc = new IncidentService();
|
|
32
|
+
const incident = await svc.createOrUpdate({
|
|
33
|
+
title,
|
|
34
|
+
description,
|
|
35
|
+
severity: config.severity,
|
|
36
|
+
source: 'WORKFLOW',
|
|
37
|
+
category: 'WORKFLOW',
|
|
38
|
+
userId: 1,
|
|
39
|
+
});
|
|
40
|
+
incidentId = incident.incident.id;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
incidentId = `inc-${Date.now()}`;
|
|
44
|
+
this.logger.warn('IncidentService not initialized, using fallback ID');
|
|
45
|
+
}
|
|
46
|
+
const result = {
|
|
47
|
+
success: true,
|
|
48
|
+
output: {
|
|
49
|
+
incidentId,
|
|
50
|
+
severity: config.severity,
|
|
51
|
+
title,
|
|
52
|
+
description,
|
|
53
|
+
tags: config.tags || [],
|
|
54
|
+
createdAt: new Date().toISOString(),
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
this.logComplete(context, result);
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
const result = {
|
|
62
|
+
success: false,
|
|
63
|
+
error: String(error),
|
|
64
|
+
};
|
|
65
|
+
this.logComplete(context, result);
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=incident.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"incident.action.js","sourceRoot":"","sources":["../../../src/workflow/actions/incident.action.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EACL,UAAU,GAGX,MAAM,kBAAkB,CAAC;AAE1B,MAAM,OAAO,cAAe,SAAQ,UAAU;IAC5C,YAAY,IAA4B;QACtC,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAED,IAAI,IAAI;QACN,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,QAAQ,CAAC,MAAkC;QACzC,IAAI,CAAC,MAAM,CAAC,QAAQ;YAAE,OAAO,KAAK,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,KAAK;YAAE,OAAO,KAAK,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,OAAO,CACX,MAAkC,EAClC,OAAyB;QAEzB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAEvB,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAC/D,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW;gBACpC,CAAC,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AC;aACrB,CAAC;YACF,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAClC,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow Actions Index
|
|
3
|
+
* Export all workflow action implementations
|
|
4
|
+
*/
|
|
5
|
+
export { BaseAction, type ActionExecutionResult, type BaseActionDependencies, } from './base.action.js';
|
|
6
|
+
export { NotifyAction } from './notify.action.js';
|
|
7
|
+
export { IncidentAction } from './incident.action.js';
|
|
8
|
+
export { ReportAction } from './report.action.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/workflow/actions/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,UAAU,EACV,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,GAC5B,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow Actions Index
|
|
3
|
+
* Export all workflow action implementations
|
|
4
|
+
*/
|
|
5
|
+
// Base Action
|
|
6
|
+
export { BaseAction, } from './base.action.js';
|
|
7
|
+
// Action Implementations
|
|
8
|
+
export { NotifyAction } from './notify.action.js';
|
|
9
|
+
export { IncidentAction } from './incident.action.js';
|
|
10
|
+
export { ReportAction } from './report.action.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/workflow/actions/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc;AACd,OAAO,EACL,UAAU,GAGX,MAAM,kBAAkB,CAAC;AAE1B,yBAAyB;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notify Action
|
|
3
|
+
* Send notifications via various channels
|
|
4
|
+
*/
|
|
5
|
+
import type { ExecutionContext, NotifyActionConfig } from '../workflow.types.js';
|
|
6
|
+
import { BaseAction, type ActionExecutionResult, type BaseActionDependencies } from './base.action.js';
|
|
7
|
+
export declare class NotifyAction extends BaseAction {
|
|
8
|
+
constructor(deps: BaseActionDependencies);
|
|
9
|
+
get type(): string;
|
|
10
|
+
validate(config: NotifyActionConfig): boolean;
|
|
11
|
+
execute(config: NotifyActionConfig, context: ExecutionContext): Promise<ActionExecutionResult>;
|
|
12
|
+
private sendSlack;
|
|
13
|
+
private sendEmail;
|
|
14
|
+
/** Create in-app notifications as fallback */
|
|
15
|
+
private createDbNotifications;
|
|
16
|
+
private sendWebhook;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=notify.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notify.action.d.ts","sourceRoot":"","sources":["../../../src/workflow/actions/notify.action.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EACL,UAAU,EACV,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC5B,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,YAAa,SAAQ,UAAU;gBAC9B,IAAI,EAAE,sBAAsB;IAIxC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,QAAQ,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO;IAOvC,OAAO,CACX,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,qBAAqB,CAAC;YA4CnB,SAAS;YAQT,SAAS;IAMvB,8CAA8C;YAChC,qBAAqB;YAcrB,WAAW;CAiB1B"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notify Action
|
|
3
|
+
* Send notifications via various channels
|
|
4
|
+
*/
|
|
5
|
+
import { BaseAction, } from './base.action.js';
|
|
6
|
+
export class NotifyAction extends BaseAction {
|
|
7
|
+
constructor(deps) {
|
|
8
|
+
super(deps);
|
|
9
|
+
}
|
|
10
|
+
get type() {
|
|
11
|
+
return 'notify';
|
|
12
|
+
}
|
|
13
|
+
validate(config) {
|
|
14
|
+
if (!config.channel)
|
|
15
|
+
return false;
|
|
16
|
+
if (!config.recipients || config.recipients.length === 0)
|
|
17
|
+
return false;
|
|
18
|
+
if (!config.message && !config.template)
|
|
19
|
+
return false;
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
async execute(config, context) {
|
|
23
|
+
this.logStart(context);
|
|
24
|
+
try {
|
|
25
|
+
const message = config.message
|
|
26
|
+
? this.interpolateVariables(config.message, context)
|
|
27
|
+
: config.template;
|
|
28
|
+
// Route to appropriate channel handler
|
|
29
|
+
switch (config.channel) {
|
|
30
|
+
case 'slack':
|
|
31
|
+
await this.sendSlack(config.recipients, message || '');
|
|
32
|
+
break;
|
|
33
|
+
case 'email':
|
|
34
|
+
await this.sendEmail(config.recipients, message || '');
|
|
35
|
+
break;
|
|
36
|
+
case 'webhook':
|
|
37
|
+
await this.sendWebhook(config.recipients, message || '');
|
|
38
|
+
break;
|
|
39
|
+
default:
|
|
40
|
+
throw new Error(`Unsupported notification channel: ${config.channel}`);
|
|
41
|
+
}
|
|
42
|
+
const result = {
|
|
43
|
+
success: true,
|
|
44
|
+
output: {
|
|
45
|
+
channel: config.channel,
|
|
46
|
+
recipientCount: config.recipients.length,
|
|
47
|
+
sentAt: new Date().toISOString(),
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
this.logComplete(context, result);
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
const result = {
|
|
55
|
+
success: false,
|
|
56
|
+
error: String(error),
|
|
57
|
+
};
|
|
58
|
+
this.logComplete(context, result);
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async sendSlack(recipients, message) {
|
|
63
|
+
// TODO: Implement Slack integration
|
|
64
|
+
this.logger.info('Slack notification (stub)', {
|
|
65
|
+
recipients,
|
|
66
|
+
messageLength: message.length,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
async sendEmail(recipients, message) {
|
|
70
|
+
// Email not yet integrated — log and create DB notification as fallback
|
|
71
|
+
this.logger.warn('Email not integrated, creating DB notification instead', { recipients });
|
|
72
|
+
await this.createDbNotifications(recipients, message, 'email');
|
|
73
|
+
}
|
|
74
|
+
/** Create in-app notifications as fallback */
|
|
75
|
+
async createDbNotifications(recipients, message, channel) {
|
|
76
|
+
try {
|
|
77
|
+
for (const recipient of recipients) {
|
|
78
|
+
const userId = parseInt(recipient, 10);
|
|
79
|
+
if (isNaN(userId))
|
|
80
|
+
continue;
|
|
81
|
+
await this.prisma.notification.create({
|
|
82
|
+
data: { userId, title: `Workflow Notification (${channel})`, message, type: 'SYSTEM', isRead: false },
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
this.logger.error('Failed to create DB notifications', { error: String(err) });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async sendWebhook(recipients, message) {
|
|
91
|
+
for (const url of recipients) {
|
|
92
|
+
try {
|
|
93
|
+
const res = await fetch(url, {
|
|
94
|
+
method: 'POST',
|
|
95
|
+
headers: { 'Content-Type': 'application/json' },
|
|
96
|
+
body: JSON.stringify({ text: message, timestamp: new Date().toISOString() }),
|
|
97
|
+
});
|
|
98
|
+
this.logger.info('Webhook sent', { url, status: res.status });
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
this.logger.error('Webhook failed', { url, error: String(err) });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=notify.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notify.action.js","sourceRoot":"","sources":["../../../src/workflow/actions/notify.action.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,UAAU,GAGX,MAAM,kBAAkB,CAAC;AAE1B,MAAM,OAAO,YAAa,SAAQ,UAAU;IAC1C,YAAY,IAA4B;QACtC,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAED,IAAI,IAAI;QACN,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,QAAQ,CAAC,MAA0B;QACjC,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,OAAO,KAAK,CAAC;QAClC,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QACvE,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ;YAAE,OAAO,KAAK,CAAC;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,OAAO,CACX,MAA0B,EAC1B,OAAyB;QAEzB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAEvB,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO;gBAC5B,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;gBACpD,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;YAEpB,uCAAuC;YACvC,QAAQ,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AE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;iBAC7E,CAAC,CAAC;gBACH,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;YAChE,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Report Action
|
|
3
|
+
* Generate reports from workflow triggers
|
|
4
|
+
*/
|
|
5
|
+
import type { ExecutionContext, GenerateReportActionConfig } from '../workflow.types.js';
|
|
6
|
+
import { BaseAction, type ActionExecutionResult, type BaseActionDependencies } from './base.action.js';
|
|
7
|
+
export declare class ReportAction extends BaseAction {
|
|
8
|
+
constructor(deps: BaseActionDependencies);
|
|
9
|
+
get type(): string;
|
|
10
|
+
validate(config: GenerateReportActionConfig): boolean;
|
|
11
|
+
execute(config: GenerateReportActionConfig, context: ExecutionContext): Promise<ActionExecutionResult>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=report.action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.action.d.ts","sourceRoot":"","sources":["../../../src/workflow/actions/report.action.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,UAAU,EACV,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC5B,MAAM,kBAAkB,CAAC;AAE1B,qBAAa,YAAa,SAAQ,UAAU;gBAC9B,IAAI,EAAE,sBAAsB;IAIxC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,QAAQ,CAAC,MAAM,EAAE,0BAA0B,GAAG,OAAO;IAM/C,OAAO,CACX,MAAM,EAAE,0BAA0B,EAClC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,qBAAqB,CAAC;CA6ClC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Report Action
|
|
3
|
+
* Generate reports from workflow triggers
|
|
4
|
+
*/
|
|
5
|
+
import { BaseAction, } from './base.action.js';
|
|
6
|
+
export class ReportAction extends BaseAction {
|
|
7
|
+
constructor(deps) {
|
|
8
|
+
super(deps);
|
|
9
|
+
}
|
|
10
|
+
get type() {
|
|
11
|
+
return 'generate_report';
|
|
12
|
+
}
|
|
13
|
+
validate(config) {
|
|
14
|
+
if (!config.reportType)
|
|
15
|
+
return false;
|
|
16
|
+
if (!config.title)
|
|
17
|
+
return false;
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
async execute(config, context) {
|
|
21
|
+
this.logStart(context);
|
|
22
|
+
try {
|
|
23
|
+
const title = this.interpolateVariables(config.title, context);
|
|
24
|
+
// Create real artifact via ArtifactService
|
|
25
|
+
const { getArtifactServiceDeps, ArtifactService } = await import('../../artifact/index.js');
|
|
26
|
+
let artifactId;
|
|
27
|
+
if (getArtifactServiceDeps()) {
|
|
28
|
+
const svc = new ArtifactService();
|
|
29
|
+
const artifact = await svc.create({
|
|
30
|
+
userId: 1,
|
|
31
|
+
type: 'REPORT',
|
|
32
|
+
title,
|
|
33
|
+
content: { reportType: config.reportType, format: config.outputFormat || 'json', generatedAt: new Date().toISOString(), data: {} },
|
|
34
|
+
});
|
|
35
|
+
artifactId = artifact.id;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
artifactId = `art-${Date.now()}`;
|
|
39
|
+
this.logger.warn('ArtifactService not initialized, using fallback ID');
|
|
40
|
+
}
|
|
41
|
+
const result = {
|
|
42
|
+
success: true,
|
|
43
|
+
output: {
|
|
44
|
+
artifactId,
|
|
45
|
+
reportType: config.reportType,
|
|
46
|
+
title,
|
|
47
|
+
format: config.outputFormat || 'json',
|
|
48
|
+
createdAt: new Date().toISOString(),
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
this.logComplete(context, result);
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
const result = {
|
|
56
|
+
success: false,
|
|
57
|
+
error: String(error),
|
|
58
|
+
};
|
|
59
|
+
this.logComplete(context, result);
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=report.action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.action.js","sourceRoot":"","sources":["../../../src/workflow/actions/report.action.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EACL,UAAU,GAGX,MAAM,kBAAkB,CAAC;AAE1B,MAAM,OAAO,YAAa,SAAQ,UAAU;IAC1C,YAAY,IAA4B;QACtC,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAED,IAAI,IAAI;QACN,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,QAAQ,CAAC,MAAkC;QACzC,IAAI,CAAC,MAAM,CAAC,UAAU;YAAE,OAAO,KAAK,CAAC;QACrC,IAAI,CAAC,MAAM,CAAC,KAAK;YAAE,OAAO,KAAK,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,OAAO,CACX,MAAkC,EAClC,OAAyB;QAEzB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAEvB,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAE/D,2CAA2C;YAC3C,MAAM,EAAE,sBAAsB,E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AM,CAAC,CAAC;YAClC,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow Service Index
|
|
3
|
+
* Export all workflow service components
|
|
4
|
+
*/
|
|
5
|
+
export type { TriggerConfig, ScheduleTriggerConfig, EventTriggerConfig, ThresholdTriggerConfig, ManualTriggerConfig, WorkflowActionType, BaseActionConfig, NotifyActionConfig, CreateIncidentActionConfig, CreateMemoryActionConfig, GenerateReportActionConfig, ExecuteQueryActionConfig, WebhookActionConfig, WorkflowAction, ActionResult, CreateWorkflowDto, UpdateWorkflowDto, WorkflowListQuery, ExecutionListQuery, ExecutionContext, ExecutionResult, WorkflowServiceDependencies, } from './workflow.types.js';
|
|
6
|
+
export type { LoggerLike as WorkflowLoggerLike } from './workflow.types.js';
|
|
7
|
+
export { AgentWorkflowStatus, TriggerType, ExecutionStatus, type AiWorkflow, type AiWorkflowExecution, } from './workflow.types.js';
|
|
8
|
+
export { WorkflowRepository, initWorkflowRepository, getWorkflowRepositoryDeps, } from './workflow.repository.js';
|
|
9
|
+
export { WorkflowService, initWorkflowService, getWorkflowServiceDeps, } from './workflow.service.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/workflow/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EACV,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,mBAAmB,EACnB,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAG7B,YAAY,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAG5E,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,eAAe,EACf,KAAK,UAAU,EACf,KAAK,mBAAmB,GACzB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow Service Index
|
|
3
|
+
* Export all workflow service components
|
|
4
|
+
*/
|
|
5
|
+
// Re-export Prisma types
|
|
6
|
+
export { AgentWorkflowStatus, TriggerType, ExecutionStatus, } from './workflow.types.js';
|
|
7
|
+
// Repository
|
|
8
|
+
export { WorkflowRepository, initWorkflowRepository, getWorkflowRepositoryDeps, } from './workflow.repository.js';
|
|
9
|
+
// Service
|
|
10
|
+
export { WorkflowService, initWorkflowService, getWorkflowServiceDeps, } from './workflow.service.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workflow/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA+BH,yBAAyB;AACzB,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,eAAe,GAGhB,MAAM,qBAAqB,CAAC;AAE7B,aAAa;AACb,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,0BAA0B,CAAC;AAElC,UAAU;AACV,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow Repository
|
|
3
|
+
* Data access layer for workflow operations
|
|
4
|
+
*/
|
|
5
|
+
import type { AiWorkflow, AiWorkflowExecution, ExecutionStatus } from '@prisma/client';
|
|
6
|
+
import type { CreateWorkflowDto, UpdateWorkflowDto, WorkflowListQuery, ExecutionListQuery, WorkflowServiceDependencies, ActionResult } from './workflow.types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Initialize the Workflow repository with dependencies
|
|
9
|
+
*/
|
|
10
|
+
export declare function initWorkflowRepository(deps: WorkflowServiceDependencies): void;
|
|
11
|
+
/**
|
|
12
|
+
* Get the repository dependencies
|
|
13
|
+
*/
|
|
14
|
+
export declare function getWorkflowRepositoryDeps(): WorkflowServiceDependencies | null;
|
|
15
|
+
export declare class WorkflowRepository {
|
|
16
|
+
private get prisma();
|
|
17
|
+
private get logger();
|
|
18
|
+
/**
|
|
19
|
+
* Create a new workflow
|
|
20
|
+
*/
|
|
21
|
+
createWorkflow(data: CreateWorkflowDto): Promise<AiWorkflow>;
|
|
22
|
+
/**
|
|
23
|
+
* Find workflow by ID
|
|
24
|
+
*/
|
|
25
|
+
findById(id: string): Promise<AiWorkflow | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Find workflow by ID with executions
|
|
28
|
+
*/
|
|
29
|
+
findByIdWithExecutions(id: string, executionLimit?: number): Promise<(AiWorkflow & {
|
|
30
|
+
executions: AiWorkflowExecution[];
|
|
31
|
+
}) | null>;
|
|
32
|
+
/**
|
|
33
|
+
* Find workflows by query
|
|
34
|
+
*/
|
|
35
|
+
findMany(query: WorkflowListQuery): Promise<AiWorkflow[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Count workflows by query
|
|
38
|
+
*/
|
|
39
|
+
count(query: Omit<WorkflowListQuery, 'limit' | 'offset'>): Promise<number>;
|
|
40
|
+
/**
|
|
41
|
+
* Update a workflow
|
|
42
|
+
*/
|
|
43
|
+
updateWorkflow(id: string, data: UpdateWorkflowDto): Promise<AiWorkflow>;
|
|
44
|
+
/**
|
|
45
|
+
* Delete a workflow
|
|
46
|
+
*/
|
|
47
|
+
deleteWorkflow(id: string): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Update workflow status
|
|
50
|
+
*/
|
|
51
|
+
updateStatus(id: string, status: 'WF_ACTIVE' | 'WF_PAUSED' | 'WF_ERROR' | 'WF_DISABLED'): Promise<AiWorkflow>;
|
|
52
|
+
/**
|
|
53
|
+
* Update last run info
|
|
54
|
+
*/
|
|
55
|
+
updateLastRun(id: string, executionId: string, status: ExecutionStatus): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Create a new execution
|
|
58
|
+
*/
|
|
59
|
+
createExecution(workflowId: string, triggerData?: unknown): Promise<AiWorkflowExecution>;
|
|
60
|
+
/**
|
|
61
|
+
* Find execution by ID
|
|
62
|
+
*/
|
|
63
|
+
findExecutionById(id: string): Promise<AiWorkflowExecution | null>;
|
|
64
|
+
/**
|
|
65
|
+
* Find executions by query
|
|
66
|
+
*/
|
|
67
|
+
findExecutions(query: ExecutionListQuery): Promise<AiWorkflowExecution[]>;
|
|
68
|
+
/**
|
|
69
|
+
* Count executions
|
|
70
|
+
*/
|
|
71
|
+
countExecutions(query: Omit<ExecutionListQuery, 'limit' | 'offset'>): Promise<number>;
|
|
72
|
+
/**
|
|
73
|
+
* Complete an execution
|
|
74
|
+
*/
|
|
75
|
+
completeExecution(id: string, status: 'SUCCESS' | 'FAILED' | 'CANCELLED', result: {
|
|
76
|
+
output?: string;
|
|
77
|
+
error?: string;
|
|
78
|
+
actionResults?: ActionResult[];
|
|
79
|
+
duration?: number;
|
|
80
|
+
}): Promise<AiWorkflowExecution>;
|
|
81
|
+
/**
|
|
82
|
+
* Find active workflows by trigger type
|
|
83
|
+
*/
|
|
84
|
+
findActiveByTriggerType(triggerType: 'SCHEDULE' | 'EVENT_TRIGGER' | 'THRESHOLD' | 'MANUAL'): Promise<AiWorkflow[]>;
|
|
85
|
+
/**
|
|
86
|
+
* Find workflows due for execution (scheduled)
|
|
87
|
+
*/
|
|
88
|
+
findDueWorkflows(): Promise<AiWorkflow[]>;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=workflow.repository.d.ts.map
|