@elizaos/plugin-workflow 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -0
- package/auto-enable.ts +18 -0
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +2 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/workflow.d.ts +23 -0
- package/dist/actions/workflow.d.ts.map +1 -0
- package/dist/actions/workflow.js +425 -0
- package/dist/actions/workflow.js.map +1 -0
- package/dist/data/defaultNodes.json +9887 -0
- package/dist/data/schemaIndex.json +1 -0
- package/dist/data/triggerSchemaIndex.json +1 -0
- package/dist/db/index.d.ts +2 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +2 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/schema.d.ts +588 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +59 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +126 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/automations-builder.d.ts +21 -0
- package/dist/lib/automations-builder.d.ts.map +1 -0
- package/dist/lib/automations-builder.js +557 -0
- package/dist/lib/automations-builder.js.map +1 -0
- package/dist/lib/automations-types.d.ts +153 -0
- package/dist/lib/automations-types.d.ts.map +1 -0
- package/dist/lib/automations-types.js +191 -0
- package/dist/lib/automations-types.js.map +1 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +3 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/legacy-task-migration.d.ts +20 -0
- package/dist/lib/legacy-task-migration.d.ts.map +1 -0
- package/dist/lib/legacy-task-migration.js +110 -0
- package/dist/lib/legacy-task-migration.js.map +1 -0
- package/dist/lib/legacy-text-trigger-migration.d.ts +18 -0
- package/dist/lib/legacy-text-trigger-migration.d.ts.map +1 -0
- package/dist/lib/legacy-text-trigger-migration.js +131 -0
- package/dist/lib/legacy-text-trigger-migration.js.map +1 -0
- package/dist/lib/workflow-clarification.d.ts +113 -0
- package/dist/lib/workflow-clarification.d.ts.map +1 -0
- package/dist/lib/workflow-clarification.js +425 -0
- package/dist/lib/workflow-clarification.js.map +1 -0
- package/dist/plugin-routes.d.ts +9 -0
- package/dist/plugin-routes.d.ts.map +1 -0
- package/dist/plugin-routes.js +147 -0
- package/dist/plugin-routes.js.map +1 -0
- package/dist/providers/activeWorkflows.d.ts +11 -0
- package/dist/providers/activeWorkflows.d.ts.map +1 -0
- package/dist/providers/activeWorkflows.js +72 -0
- package/dist/providers/activeWorkflows.js.map +1 -0
- package/dist/providers/index.d.ts +4 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +4 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/pendingDraft.d.ts +9 -0
- package/dist/providers/pendingDraft.d.ts.map +1 -0
- package/dist/providers/pendingDraft.js +48 -0
- package/dist/providers/pendingDraft.js.map +1 -0
- package/dist/providers/workflowStatus.d.ts +3 -0
- package/dist/providers/workflowStatus.d.ts.map +1 -0
- package/dist/providers/workflowStatus.js +69 -0
- package/dist/providers/workflowStatus.js.map +1 -0
- package/dist/register-routes.d.ts +2 -0
- package/dist/register-routes.d.ts.map +1 -0
- package/dist/register-routes.js +6 -0
- package/dist/register-routes.js.map +1 -0
- package/dist/routes/_helpers.d.ts +11 -0
- package/dist/routes/_helpers.d.ts.map +1 -0
- package/dist/routes/_helpers.js +22 -0
- package/dist/routes/_helpers.js.map +1 -0
- package/dist/routes/automations.d.ts +19 -0
- package/dist/routes/automations.d.ts.map +1 -0
- package/dist/routes/automations.js +32 -0
- package/dist/routes/automations.js.map +1 -0
- package/dist/routes/embedded-webhooks.d.ts +3 -0
- package/dist/routes/embedded-webhooks.d.ts.map +1 -0
- package/dist/routes/embedded-webhooks.js +47 -0
- package/dist/routes/embedded-webhooks.js.map +1 -0
- package/dist/routes/executions.d.ts +3 -0
- package/dist/routes/executions.d.ts.map +1 -0
- package/dist/routes/executions.js +58 -0
- package/dist/routes/executions.js.map +1 -0
- package/dist/routes/index.d.ts +4 -0
- package/dist/routes/index.d.ts.map +1 -0
- package/dist/routes/index.js +14 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routes/nodes.d.ts +3 -0
- package/dist/routes/nodes.d.ts.map +1 -0
- package/dist/routes/nodes.js +168 -0
- package/dist/routes/nodes.js.map +1 -0
- package/dist/routes/validation.d.ts +3 -0
- package/dist/routes/validation.d.ts.map +1 -0
- package/dist/routes/validation.js +41 -0
- package/dist/routes/validation.js.map +1 -0
- package/dist/routes/workflow-routes.d.ts +27 -0
- package/dist/routes/workflow-routes.d.ts.map +1 -0
- package/dist/routes/workflow-routes.js +326 -0
- package/dist/routes/workflow-routes.js.map +1 -0
- package/dist/routes/workflows.d.ts +3 -0
- package/dist/routes/workflows.d.ts.map +1 -0
- package/dist/routes/workflows.js +252 -0
- package/dist/routes/workflows.js.map +1 -0
- package/dist/schemas/draftIntent.d.ts +22 -0
- package/dist/schemas/draftIntent.d.ts.map +1 -0
- package/dist/schemas/draftIntent.js +22 -0
- package/dist/schemas/draftIntent.js.map +1 -0
- package/dist/schemas/feasibility.d.ts +13 -0
- package/dist/schemas/feasibility.d.ts.map +1 -0
- package/dist/schemas/feasibility.js +9 -0
- package/dist/schemas/feasibility.js.map +1 -0
- package/dist/schemas/index.d.ts +5 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +5 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/keywordExtraction.d.ts +14 -0
- package/dist/schemas/keywordExtraction.d.ts.map +1 -0
- package/dist/schemas/keywordExtraction.js +12 -0
- package/dist/schemas/keywordExtraction.js.map +1 -0
- package/dist/schemas/workflowMatching.d.ts +36 -0
- package/dist/schemas/workflowMatching.d.ts.map +1 -0
- package/dist/schemas/workflowMatching.js +30 -0
- package/dist/schemas/workflowMatching.js.map +1 -0
- package/dist/services/embedded-workflow-service.d.ts +106 -0
- package/dist/services/embedded-workflow-service.d.ts.map +1 -0
- package/dist/services/embedded-workflow-service.js +1900 -0
- package/dist/services/embedded-workflow-service.js.map +1 -0
- package/dist/services/index.d.ts +5 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +5 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/workflow-credential-store.d.ts +27 -0
- package/dist/services/workflow-credential-store.d.ts.map +1 -0
- package/dist/services/workflow-credential-store.js +92 -0
- package/dist/services/workflow-credential-store.js.map +1 -0
- package/dist/services/workflow-dispatch.d.ts +41 -0
- package/dist/services/workflow-dispatch.d.ts.map +1 -0
- package/dist/services/workflow-dispatch.js +86 -0
- package/dist/services/workflow-dispatch.js.map +1 -0
- package/dist/services/workflow-service.d.ts +63 -0
- package/dist/services/workflow-service.d.ts.map +1 -0
- package/dist/services/workflow-service.js +492 -0
- package/dist/services/workflow-service.js.map +1 -0
- package/dist/trigger-routes.d.ts +153 -0
- package/dist/trigger-routes.d.ts.map +1 -0
- package/dist/trigger-routes.js +424 -0
- package/dist/trigger-routes.js.map +1 -0
- package/dist/types/index.d.ts +457 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +59 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/catalog.d.ts +16 -0
- package/dist/utils/catalog.d.ts.map +1 -0
- package/dist/utils/catalog.js +211 -0
- package/dist/utils/catalog.js.map +1 -0
- package/dist/utils/clarification.d.ts +17 -0
- package/dist/utils/clarification.d.ts.map +1 -0
- package/dist/utils/clarification.js +46 -0
- package/dist/utils/clarification.js.map +1 -0
- package/dist/utils/context.d.ts +4 -0
- package/dist/utils/context.d.ts.map +1 -0
- package/dist/utils/context.js +18 -0
- package/dist/utils/context.js.map +1 -0
- package/dist/utils/credentialResolver.d.ts +22 -0
- package/dist/utils/credentialResolver.d.ts.map +1 -0
- package/dist/utils/credentialResolver.js +146 -0
- package/dist/utils/credentialResolver.js.map +1 -0
- package/dist/utils/generation.d.ts +36 -0
- package/dist/utils/generation.d.ts.map +1 -0
- package/dist/utils/generation.js +701 -0
- package/dist/utils/generation.js.map +1 -0
- package/dist/utils/host-capabilities.d.ts +27 -0
- package/dist/utils/host-capabilities.d.ts.map +1 -0
- package/dist/utils/host-capabilities.js +59 -0
- package/dist/utils/host-capabilities.js.map +1 -0
- package/dist/utils/inferSyntheticOutputSchema.d.ts +20 -0
- package/dist/utils/inferSyntheticOutputSchema.d.ts.map +1 -0
- package/dist/utils/inferSyntheticOutputSchema.js +151 -0
- package/dist/utils/inferSyntheticOutputSchema.js.map +1 -0
- package/dist/utils/outputSchema.d.ts +26 -0
- package/dist/utils/outputSchema.d.ts.map +1 -0
- package/dist/utils/outputSchema.js +297 -0
- package/dist/utils/outputSchema.js.map +1 -0
- package/dist/utils/validateAndRepair.d.ts +41 -0
- package/dist/utils/validateAndRepair.d.ts.map +1 -0
- package/dist/utils/validateAndRepair.js +483 -0
- package/dist/utils/validateAndRepair.js.map +1 -0
- package/dist/utils/workflow-prompts/actionResponse.d.ts +2 -0
- package/dist/utils/workflow-prompts/actionResponse.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/actionResponse.js +17 -0
- package/dist/utils/workflow-prompts/actionResponse.js.map +1 -0
- package/dist/utils/workflow-prompts/draftIntent.d.ts +2 -0
- package/dist/utils/workflow-prompts/draftIntent.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/draftIntent.js +23 -0
- package/dist/utils/workflow-prompts/draftIntent.js.map +1 -0
- package/dist/utils/workflow-prompts/feasibilityCheck.d.ts +2 -0
- package/dist/utils/workflow-prompts/feasibilityCheck.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/feasibilityCheck.js +21 -0
- package/dist/utils/workflow-prompts/feasibilityCheck.js.map +1 -0
- package/dist/utils/workflow-prompts/fieldCorrection.d.ts +3 -0
- package/dist/utils/workflow-prompts/fieldCorrection.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/fieldCorrection.js +20 -0
- package/dist/utils/workflow-prompts/fieldCorrection.js.map +1 -0
- package/dist/utils/workflow-prompts/index.d.ts +8 -0
- package/dist/utils/workflow-prompts/index.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/index.js +8 -0
- package/dist/utils/workflow-prompts/index.js.map +1 -0
- package/dist/utils/workflow-prompts/keywordExtraction.d.ts +2 -0
- package/dist/utils/workflow-prompts/keywordExtraction.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/keywordExtraction.js +21 -0
- package/dist/utils/workflow-prompts/keywordExtraction.js.map +1 -0
- package/dist/utils/workflow-prompts/parameterCorrection.d.ts +3 -0
- package/dist/utils/workflow-prompts/parameterCorrection.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/parameterCorrection.js +29 -0
- package/dist/utils/workflow-prompts/parameterCorrection.js.map +1 -0
- package/dist/utils/workflow-prompts/workflowGeneration.d.ts +2 -0
- package/dist/utils/workflow-prompts/workflowGeneration.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/workflowGeneration.js +529 -0
- package/dist/utils/workflow-prompts/workflowGeneration.js.map +1 -0
- package/dist/utils/workflow-prompts/workflowMatching.d.ts +2 -0
- package/dist/utils/workflow-prompts/workflowMatching.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/workflowMatching.js +23 -0
- package/dist/utils/workflow-prompts/workflowMatching.js.map +1 -0
- package/dist/utils/workflow.d.ts +62 -0
- package/dist/utils/workflow.d.ts.map +1 -0
- package/dist/utils/workflow.js +712 -0
- package/dist/utils/workflow.js.map +1 -0
- package/package.json +87 -0
- package/src/actions/index.ts +1 -0
- package/src/actions/workflow.ts +494 -0
- package/src/data/defaultNodes.json +9887 -0
- package/src/data/schemaIndex.json +1 -0
- package/src/data/triggerSchemaIndex.json +1 -0
- package/src/db/index.ts +8 -0
- package/src/db/schema.ts +94 -0
- package/src/index.ts +179 -0
- package/src/lib/automations-builder.ts +679 -0
- package/src/lib/automations-types.ts +391 -0
- package/src/lib/index.ts +8 -0
- package/src/lib/legacy-task-migration.ts +143 -0
- package/src/lib/legacy-text-trigger-migration.ts +178 -0
- package/src/lib/workflow-clarification.ts +497 -0
- package/src/plugin-routes.ts +164 -0
- package/src/providers/activeWorkflows.ts +81 -0
- package/src/providers/index.ts +3 -0
- package/src/providers/pendingDraft.ts +55 -0
- package/src/providers/workflowStatus.ts +88 -0
- package/src/register-routes.ts +6 -0
- package/src/routes/_helpers.ts +27 -0
- package/src/routes/automations.ts +46 -0
- package/src/routes/embedded-webhooks.ts +64 -0
- package/src/routes/executions.ts +75 -0
- package/src/routes/index.ts +16 -0
- package/src/routes/nodes.ts +211 -0
- package/src/routes/validation.ts +51 -0
- package/src/routes/workflow-routes.ts +469 -0
- package/src/routes/workflows.ts +310 -0
- package/src/schemas/draftIntent.ts +21 -0
- package/src/schemas/feasibility.ts +8 -0
- package/src/schemas/index.ts +4 -0
- package/src/schemas/keywordExtraction.ts +11 -0
- package/src/schemas/workflowMatching.ts +29 -0
- package/src/services/embedded-workflow-service.ts +2224 -0
- package/src/services/index.ts +17 -0
- package/src/services/workflow-credential-store.ts +132 -0
- package/src/services/workflow-dispatch.ts +121 -0
- package/src/services/workflow-service.ts +839 -0
- package/src/trigger-routes.ts +714 -0
- package/src/types/index.ts +562 -0
- package/src/utils/catalog.ts +260 -0
- package/src/utils/clarification.ts +52 -0
- package/src/utils/context.ts +22 -0
- package/src/utils/credentialResolver.ts +234 -0
- package/src/utils/generation.ts +987 -0
- package/src/utils/host-capabilities.ts +81 -0
- package/src/utils/inferSyntheticOutputSchema.ts +163 -0
- package/src/utils/outputSchema.ts +372 -0
- package/src/utils/validateAndRepair.ts +610 -0
- package/src/utils/workflow-prompts/actionResponse.ts +16 -0
- package/src/utils/workflow-prompts/draftIntent.ts +22 -0
- package/src/utils/workflow-prompts/feasibilityCheck.ts +20 -0
- package/src/utils/workflow-prompts/fieldCorrection.ts +20 -0
- package/src/utils/workflow-prompts/index.ts +10 -0
- package/src/utils/workflow-prompts/keywordExtraction.ts +20 -0
- package/src/utils/workflow-prompts/parameterCorrection.ts +29 -0
- package/src/utils/workflow-prompts/workflowGeneration.ts +528 -0
- package/src/utils/workflow-prompts/workflowMatching.ts +22 -0
- package/src/utils/workflow.ts +895 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import type { IAgentRuntime, Route, RouteRequest, RouteResponse } from '@elizaos/core';
|
|
2
|
+
import {
|
|
3
|
+
EMBEDDED_WORKFLOW_SERVICE_TYPE,
|
|
4
|
+
type EmbeddedWorkflowService,
|
|
5
|
+
} from '../services/embedded-workflow-service';
|
|
6
|
+
import type { NodeSearchResult } from '../types/index';
|
|
7
|
+
import { isCredentialProvider, WORKFLOW_CREDENTIAL_PROVIDER_TYPE } from '../types/index';
|
|
8
|
+
import {
|
|
9
|
+
filterNodesByIntegrationSupport,
|
|
10
|
+
getAllNodes,
|
|
11
|
+
getNodeDefinition,
|
|
12
|
+
searchNodes,
|
|
13
|
+
} from '../utils/catalog';
|
|
14
|
+
import { validateLimit } from './_helpers';
|
|
15
|
+
|
|
16
|
+
function getRegisteredEmbeddedNodes(runtime: IAgentRuntime): Set<string> | null {
|
|
17
|
+
const service = runtime.getService(
|
|
18
|
+
EMBEDDED_WORKFLOW_SERVICE_TYPE
|
|
19
|
+
) as EmbeddedWorkflowService | null;
|
|
20
|
+
const names = service?.getRegisteredNodeTypes?.();
|
|
21
|
+
return names?.length ? new Set(names) : null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function filterEmbeddedResults(
|
|
25
|
+
results: NodeSearchResult[],
|
|
26
|
+
runtime: IAgentRuntime
|
|
27
|
+
): NodeSearchResult[] {
|
|
28
|
+
const registered = getRegisteredEmbeddedNodes(runtime);
|
|
29
|
+
return registered ? results.filter((result) => registered.has(result.node.name)) : results;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* GET /nodes?q=gmail,email&limit=20
|
|
34
|
+
*/
|
|
35
|
+
async function listNodes(
|
|
36
|
+
req: RouteRequest,
|
|
37
|
+
res: RouteResponse,
|
|
38
|
+
runtime: IAgentRuntime
|
|
39
|
+
): Promise<void> {
|
|
40
|
+
try {
|
|
41
|
+
const q = req.query?.q as string | undefined;
|
|
42
|
+
const limit = validateLimit(req.query?.limit, 20, 100);
|
|
43
|
+
|
|
44
|
+
if (!q) {
|
|
45
|
+
res.status(400).json({
|
|
46
|
+
success: false,
|
|
47
|
+
error: 'q parameter is required (comma-separated keywords)',
|
|
48
|
+
});
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const keywords = q
|
|
53
|
+
.split(',')
|
|
54
|
+
.map((k) => k.trim())
|
|
55
|
+
.filter(Boolean);
|
|
56
|
+
const results = filterEmbeddedResults(searchNodes(keywords, limit), runtime);
|
|
57
|
+
|
|
58
|
+
res.json({
|
|
59
|
+
success: true,
|
|
60
|
+
data: results.map(formatSearchResult),
|
|
61
|
+
});
|
|
62
|
+
} catch (error) {
|
|
63
|
+
res.status(500).json({
|
|
64
|
+
success: false,
|
|
65
|
+
error: 'failed_to_search_nodes',
|
|
66
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* GET /nodes/available
|
|
73
|
+
* Full catalog split by cloud integration support.
|
|
74
|
+
* Returns { supported, unsupported, utility }.
|
|
75
|
+
*/
|
|
76
|
+
async function listAvailableNodes(
|
|
77
|
+
_req: RouteRequest,
|
|
78
|
+
res: RouteResponse,
|
|
79
|
+
runtime: IAgentRuntime
|
|
80
|
+
): Promise<void> {
|
|
81
|
+
try {
|
|
82
|
+
const registered = getRegisteredEmbeddedNodes(runtime);
|
|
83
|
+
const catalog = registered
|
|
84
|
+
? getAllNodes().filter((node) => registered.has(node.name))
|
|
85
|
+
: getAllNodes();
|
|
86
|
+
const allResults: NodeSearchResult[] = catalog
|
|
87
|
+
.filter((n) => n.name && n.displayName)
|
|
88
|
+
.map((node) => ({ node, score: 0, matchReason: 'catalog' }));
|
|
89
|
+
|
|
90
|
+
const rawProvider = runtime.getService(WORKFLOW_CREDENTIAL_PROVIDER_TYPE);
|
|
91
|
+
const credProvider = isCredentialProvider(rawProvider) ? rawProvider : null;
|
|
92
|
+
|
|
93
|
+
if (!credProvider?.checkCredentialTypes) {
|
|
94
|
+
const utility = allResults.filter((r) => !r.node.credentials?.length);
|
|
95
|
+
const services = allResults.filter((r) => (r.node.credentials?.length ?? 0) > 0);
|
|
96
|
+
res.json({
|
|
97
|
+
success: true,
|
|
98
|
+
data: {
|
|
99
|
+
supported: services.map(formatCatalogNode),
|
|
100
|
+
unsupported: [],
|
|
101
|
+
utility: utility.map(formatCatalogNode),
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const credTypes = new Set<string>();
|
|
108
|
+
for (const { node } of allResults) {
|
|
109
|
+
for (const cred of node.credentials ?? []) {
|
|
110
|
+
credTypes.add(cred.name);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const checkResult = credProvider.checkCredentialTypes([...credTypes]);
|
|
115
|
+
const supportedSet = new Set(checkResult.supported);
|
|
116
|
+
const { remaining, removed } = filterNodesByIntegrationSupport(allResults, supportedSet);
|
|
117
|
+
|
|
118
|
+
const utility = remaining.filter((r) => !r.node.credentials?.length);
|
|
119
|
+
const supported = remaining.filter((r) => (r.node.credentials?.length ?? 0) > 0);
|
|
120
|
+
|
|
121
|
+
res.json({
|
|
122
|
+
success: true,
|
|
123
|
+
data: {
|
|
124
|
+
supported: supported.map(formatCatalogNode),
|
|
125
|
+
unsupported: removed.map((r) => ({
|
|
126
|
+
...formatCatalogNode(r),
|
|
127
|
+
missingCredentials: r.node.credentials?.map((c) => c.name) ?? [],
|
|
128
|
+
})),
|
|
129
|
+
utility: utility.map(formatCatalogNode),
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
} catch (error) {
|
|
133
|
+
res.status(500).json({
|
|
134
|
+
success: false,
|
|
135
|
+
error: 'failed_to_list_nodes',
|
|
136
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* GET /nodes/:type
|
|
143
|
+
* Full node definition (properties/schema) for the visual editor.
|
|
144
|
+
*/
|
|
145
|
+
async function getNode(
|
|
146
|
+
req: RouteRequest,
|
|
147
|
+
res: RouteResponse,
|
|
148
|
+
runtime: IAgentRuntime
|
|
149
|
+
): Promise<void> {
|
|
150
|
+
try {
|
|
151
|
+
const type = req.params?.type;
|
|
152
|
+
if (!type) {
|
|
153
|
+
res.status(400).json({ success: false, error: 'node_type_required' });
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const registered = getRegisteredEmbeddedNodes(runtime);
|
|
158
|
+
if (registered && !registered.has(type)) {
|
|
159
|
+
res.status(404).json({ success: false, error: `node_type_not_available: ${type}` });
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const definition = getNodeDefinition(type);
|
|
164
|
+
if (!definition) {
|
|
165
|
+
res.status(404).json({ success: false, error: `node_type_not_found: ${type}` });
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
res.json({ success: true, data: definition });
|
|
170
|
+
} catch (error) {
|
|
171
|
+
res.status(500).json({
|
|
172
|
+
success: false,
|
|
173
|
+
error: 'failed_to_get_node',
|
|
174
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** For search results — includes score and matchReason. */
|
|
180
|
+
function formatSearchResult(r: NodeSearchResult) {
|
|
181
|
+
return {
|
|
182
|
+
name: r.node.name,
|
|
183
|
+
displayName: r.node.displayName,
|
|
184
|
+
description: r.node.description,
|
|
185
|
+
icon: r.node.icon,
|
|
186
|
+
iconUrl: r.node.iconUrl,
|
|
187
|
+
group: r.node.group,
|
|
188
|
+
credentials: r.node.credentials,
|
|
189
|
+
score: r.score,
|
|
190
|
+
matchReason: r.matchReason,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** For catalog listings — no search metadata. */
|
|
195
|
+
function formatCatalogNode(r: NodeSearchResult) {
|
|
196
|
+
return {
|
|
197
|
+
name: r.node.name,
|
|
198
|
+
displayName: r.node.displayName,
|
|
199
|
+
description: r.node.description,
|
|
200
|
+
icon: r.node.icon,
|
|
201
|
+
iconUrl: r.node.iconUrl,
|
|
202
|
+
group: r.node.group,
|
|
203
|
+
credentials: r.node.credentials,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export const nodeRoutes: Route[] = [
|
|
208
|
+
{ type: 'GET', path: '/nodes/available', handler: listAvailableNodes },
|
|
209
|
+
{ type: 'GET', path: '/nodes/:type', handler: getNode },
|
|
210
|
+
{ type: 'GET', path: '/nodes', handler: listNodes },
|
|
211
|
+
];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { IAgentRuntime, Route, RouteRequest, RouteResponse } from '@elizaos/core';
|
|
2
|
+
import type { WorkflowDefinition } from '../types/index';
|
|
3
|
+
import { validateNodeInputs, validateNodeParameters, validateWorkflow } from '../utils/workflow';
|
|
4
|
+
|
|
5
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
6
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function isWorkflowDefinition(value: unknown): value is WorkflowDefinition {
|
|
10
|
+
return isRecord(value) && Array.isArray(value.nodes) && isRecord(value.connections);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* POST /workflows/validate
|
|
15
|
+
* Validate a workflow without deploying.
|
|
16
|
+
*
|
|
17
|
+
* Body: { nodes: [...], connections: {...}, ... }
|
|
18
|
+
*/
|
|
19
|
+
async function validate(
|
|
20
|
+
req: RouteRequest,
|
|
21
|
+
res: RouteResponse,
|
|
22
|
+
_runtime: IAgentRuntime
|
|
23
|
+
): Promise<void> {
|
|
24
|
+
try {
|
|
25
|
+
if (!isWorkflowDefinition(req.body)) {
|
|
26
|
+
res.status(400).json({ success: false, error: 'nodes and connections are required' });
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const workflow = req.body;
|
|
30
|
+
|
|
31
|
+
const result = validateWorkflow(workflow);
|
|
32
|
+
const paramWarnings = validateNodeParameters(workflow);
|
|
33
|
+
const inputWarnings = validateNodeInputs(workflow);
|
|
34
|
+
|
|
35
|
+
res.json({
|
|
36
|
+
valid: result.valid,
|
|
37
|
+
errors: result.errors,
|
|
38
|
+
warnings: [...result.warnings, ...paramWarnings, ...inputWarnings],
|
|
39
|
+
});
|
|
40
|
+
} catch (error) {
|
|
41
|
+
res.status(500).json({
|
|
42
|
+
success: false,
|
|
43
|
+
error: 'failed_to_validate_workflow',
|
|
44
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const validationRoutes: Route[] = [
|
|
50
|
+
{ type: 'POST', path: '/workflows/validate', handler: validate },
|
|
51
|
+
];
|