@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.
Files changed (294) hide show
  1. package/README.md +71 -0
  2. package/auto-enable.ts +18 -0
  3. package/dist/actions/index.d.ts +2 -0
  4. package/dist/actions/index.d.ts.map +1 -0
  5. package/dist/actions/index.js +2 -0
  6. package/dist/actions/index.js.map +1 -0
  7. package/dist/actions/workflow.d.ts +23 -0
  8. package/dist/actions/workflow.d.ts.map +1 -0
  9. package/dist/actions/workflow.js +425 -0
  10. package/dist/actions/workflow.js.map +1 -0
  11. package/dist/data/defaultNodes.json +9887 -0
  12. package/dist/data/schemaIndex.json +1 -0
  13. package/dist/data/triggerSchemaIndex.json +1 -0
  14. package/dist/db/index.d.ts +2 -0
  15. package/dist/db/index.d.ts.map +1 -0
  16. package/dist/db/index.js +2 -0
  17. package/dist/db/index.js.map +1 -0
  18. package/dist/db/schema.d.ts +588 -0
  19. package/dist/db/schema.d.ts.map +1 -0
  20. package/dist/db/schema.js +59 -0
  21. package/dist/db/schema.js.map +1 -0
  22. package/dist/index.d.ts +34 -0
  23. package/dist/index.d.ts.map +1 -0
  24. package/dist/index.js +126 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/lib/automations-builder.d.ts +21 -0
  27. package/dist/lib/automations-builder.d.ts.map +1 -0
  28. package/dist/lib/automations-builder.js +557 -0
  29. package/dist/lib/automations-builder.js.map +1 -0
  30. package/dist/lib/automations-types.d.ts +153 -0
  31. package/dist/lib/automations-types.d.ts.map +1 -0
  32. package/dist/lib/automations-types.js +191 -0
  33. package/dist/lib/automations-types.js.map +1 -0
  34. package/dist/lib/index.d.ts +3 -0
  35. package/dist/lib/index.d.ts.map +1 -0
  36. package/dist/lib/index.js +3 -0
  37. package/dist/lib/index.js.map +1 -0
  38. package/dist/lib/legacy-task-migration.d.ts +20 -0
  39. package/dist/lib/legacy-task-migration.d.ts.map +1 -0
  40. package/dist/lib/legacy-task-migration.js +110 -0
  41. package/dist/lib/legacy-task-migration.js.map +1 -0
  42. package/dist/lib/legacy-text-trigger-migration.d.ts +18 -0
  43. package/dist/lib/legacy-text-trigger-migration.d.ts.map +1 -0
  44. package/dist/lib/legacy-text-trigger-migration.js +131 -0
  45. package/dist/lib/legacy-text-trigger-migration.js.map +1 -0
  46. package/dist/lib/workflow-clarification.d.ts +113 -0
  47. package/dist/lib/workflow-clarification.d.ts.map +1 -0
  48. package/dist/lib/workflow-clarification.js +425 -0
  49. package/dist/lib/workflow-clarification.js.map +1 -0
  50. package/dist/plugin-routes.d.ts +9 -0
  51. package/dist/plugin-routes.d.ts.map +1 -0
  52. package/dist/plugin-routes.js +147 -0
  53. package/dist/plugin-routes.js.map +1 -0
  54. package/dist/providers/activeWorkflows.d.ts +11 -0
  55. package/dist/providers/activeWorkflows.d.ts.map +1 -0
  56. package/dist/providers/activeWorkflows.js +72 -0
  57. package/dist/providers/activeWorkflows.js.map +1 -0
  58. package/dist/providers/index.d.ts +4 -0
  59. package/dist/providers/index.d.ts.map +1 -0
  60. package/dist/providers/index.js +4 -0
  61. package/dist/providers/index.js.map +1 -0
  62. package/dist/providers/pendingDraft.d.ts +9 -0
  63. package/dist/providers/pendingDraft.d.ts.map +1 -0
  64. package/dist/providers/pendingDraft.js +48 -0
  65. package/dist/providers/pendingDraft.js.map +1 -0
  66. package/dist/providers/workflowStatus.d.ts +3 -0
  67. package/dist/providers/workflowStatus.d.ts.map +1 -0
  68. package/dist/providers/workflowStatus.js +69 -0
  69. package/dist/providers/workflowStatus.js.map +1 -0
  70. package/dist/register-routes.d.ts +2 -0
  71. package/dist/register-routes.d.ts.map +1 -0
  72. package/dist/register-routes.js +6 -0
  73. package/dist/register-routes.js.map +1 -0
  74. package/dist/routes/_helpers.d.ts +11 -0
  75. package/dist/routes/_helpers.d.ts.map +1 -0
  76. package/dist/routes/_helpers.js +22 -0
  77. package/dist/routes/_helpers.js.map +1 -0
  78. package/dist/routes/automations.d.ts +19 -0
  79. package/dist/routes/automations.d.ts.map +1 -0
  80. package/dist/routes/automations.js +32 -0
  81. package/dist/routes/automations.js.map +1 -0
  82. package/dist/routes/embedded-webhooks.d.ts +3 -0
  83. package/dist/routes/embedded-webhooks.d.ts.map +1 -0
  84. package/dist/routes/embedded-webhooks.js +47 -0
  85. package/dist/routes/embedded-webhooks.js.map +1 -0
  86. package/dist/routes/executions.d.ts +3 -0
  87. package/dist/routes/executions.d.ts.map +1 -0
  88. package/dist/routes/executions.js +58 -0
  89. package/dist/routes/executions.js.map +1 -0
  90. package/dist/routes/index.d.ts +4 -0
  91. package/dist/routes/index.d.ts.map +1 -0
  92. package/dist/routes/index.js +14 -0
  93. package/dist/routes/index.js.map +1 -0
  94. package/dist/routes/nodes.d.ts +3 -0
  95. package/dist/routes/nodes.d.ts.map +1 -0
  96. package/dist/routes/nodes.js +168 -0
  97. package/dist/routes/nodes.js.map +1 -0
  98. package/dist/routes/validation.d.ts +3 -0
  99. package/dist/routes/validation.d.ts.map +1 -0
  100. package/dist/routes/validation.js +41 -0
  101. package/dist/routes/validation.js.map +1 -0
  102. package/dist/routes/workflow-routes.d.ts +27 -0
  103. package/dist/routes/workflow-routes.d.ts.map +1 -0
  104. package/dist/routes/workflow-routes.js +326 -0
  105. package/dist/routes/workflow-routes.js.map +1 -0
  106. package/dist/routes/workflows.d.ts +3 -0
  107. package/dist/routes/workflows.d.ts.map +1 -0
  108. package/dist/routes/workflows.js +252 -0
  109. package/dist/routes/workflows.js.map +1 -0
  110. package/dist/schemas/draftIntent.d.ts +22 -0
  111. package/dist/schemas/draftIntent.d.ts.map +1 -0
  112. package/dist/schemas/draftIntent.js +22 -0
  113. package/dist/schemas/draftIntent.js.map +1 -0
  114. package/dist/schemas/feasibility.d.ts +13 -0
  115. package/dist/schemas/feasibility.d.ts.map +1 -0
  116. package/dist/schemas/feasibility.js +9 -0
  117. package/dist/schemas/feasibility.js.map +1 -0
  118. package/dist/schemas/index.d.ts +5 -0
  119. package/dist/schemas/index.d.ts.map +1 -0
  120. package/dist/schemas/index.js +5 -0
  121. package/dist/schemas/index.js.map +1 -0
  122. package/dist/schemas/keywordExtraction.d.ts +14 -0
  123. package/dist/schemas/keywordExtraction.d.ts.map +1 -0
  124. package/dist/schemas/keywordExtraction.js +12 -0
  125. package/dist/schemas/keywordExtraction.js.map +1 -0
  126. package/dist/schemas/workflowMatching.d.ts +36 -0
  127. package/dist/schemas/workflowMatching.d.ts.map +1 -0
  128. package/dist/schemas/workflowMatching.js +30 -0
  129. package/dist/schemas/workflowMatching.js.map +1 -0
  130. package/dist/services/embedded-workflow-service.d.ts +106 -0
  131. package/dist/services/embedded-workflow-service.d.ts.map +1 -0
  132. package/dist/services/embedded-workflow-service.js +1900 -0
  133. package/dist/services/embedded-workflow-service.js.map +1 -0
  134. package/dist/services/index.d.ts +5 -0
  135. package/dist/services/index.d.ts.map +1 -0
  136. package/dist/services/index.js +5 -0
  137. package/dist/services/index.js.map +1 -0
  138. package/dist/services/workflow-credential-store.d.ts +27 -0
  139. package/dist/services/workflow-credential-store.d.ts.map +1 -0
  140. package/dist/services/workflow-credential-store.js +92 -0
  141. package/dist/services/workflow-credential-store.js.map +1 -0
  142. package/dist/services/workflow-dispatch.d.ts +41 -0
  143. package/dist/services/workflow-dispatch.d.ts.map +1 -0
  144. package/dist/services/workflow-dispatch.js +86 -0
  145. package/dist/services/workflow-dispatch.js.map +1 -0
  146. package/dist/services/workflow-service.d.ts +63 -0
  147. package/dist/services/workflow-service.d.ts.map +1 -0
  148. package/dist/services/workflow-service.js +492 -0
  149. package/dist/services/workflow-service.js.map +1 -0
  150. package/dist/trigger-routes.d.ts +153 -0
  151. package/dist/trigger-routes.d.ts.map +1 -0
  152. package/dist/trigger-routes.js +424 -0
  153. package/dist/trigger-routes.js.map +1 -0
  154. package/dist/types/index.d.ts +457 -0
  155. package/dist/types/index.d.ts.map +1 -0
  156. package/dist/types/index.js +59 -0
  157. package/dist/types/index.js.map +1 -0
  158. package/dist/utils/catalog.d.ts +16 -0
  159. package/dist/utils/catalog.d.ts.map +1 -0
  160. package/dist/utils/catalog.js +211 -0
  161. package/dist/utils/catalog.js.map +1 -0
  162. package/dist/utils/clarification.d.ts +17 -0
  163. package/dist/utils/clarification.d.ts.map +1 -0
  164. package/dist/utils/clarification.js +46 -0
  165. package/dist/utils/clarification.js.map +1 -0
  166. package/dist/utils/context.d.ts +4 -0
  167. package/dist/utils/context.d.ts.map +1 -0
  168. package/dist/utils/context.js +18 -0
  169. package/dist/utils/context.js.map +1 -0
  170. package/dist/utils/credentialResolver.d.ts +22 -0
  171. package/dist/utils/credentialResolver.d.ts.map +1 -0
  172. package/dist/utils/credentialResolver.js +146 -0
  173. package/dist/utils/credentialResolver.js.map +1 -0
  174. package/dist/utils/generation.d.ts +36 -0
  175. package/dist/utils/generation.d.ts.map +1 -0
  176. package/dist/utils/generation.js +701 -0
  177. package/dist/utils/generation.js.map +1 -0
  178. package/dist/utils/host-capabilities.d.ts +27 -0
  179. package/dist/utils/host-capabilities.d.ts.map +1 -0
  180. package/dist/utils/host-capabilities.js +59 -0
  181. package/dist/utils/host-capabilities.js.map +1 -0
  182. package/dist/utils/inferSyntheticOutputSchema.d.ts +20 -0
  183. package/dist/utils/inferSyntheticOutputSchema.d.ts.map +1 -0
  184. package/dist/utils/inferSyntheticOutputSchema.js +151 -0
  185. package/dist/utils/inferSyntheticOutputSchema.js.map +1 -0
  186. package/dist/utils/outputSchema.d.ts +26 -0
  187. package/dist/utils/outputSchema.d.ts.map +1 -0
  188. package/dist/utils/outputSchema.js +297 -0
  189. package/dist/utils/outputSchema.js.map +1 -0
  190. package/dist/utils/validateAndRepair.d.ts +41 -0
  191. package/dist/utils/validateAndRepair.d.ts.map +1 -0
  192. package/dist/utils/validateAndRepair.js +483 -0
  193. package/dist/utils/validateAndRepair.js.map +1 -0
  194. package/dist/utils/workflow-prompts/actionResponse.d.ts +2 -0
  195. package/dist/utils/workflow-prompts/actionResponse.d.ts.map +1 -0
  196. package/dist/utils/workflow-prompts/actionResponse.js +17 -0
  197. package/dist/utils/workflow-prompts/actionResponse.js.map +1 -0
  198. package/dist/utils/workflow-prompts/draftIntent.d.ts +2 -0
  199. package/dist/utils/workflow-prompts/draftIntent.d.ts.map +1 -0
  200. package/dist/utils/workflow-prompts/draftIntent.js +23 -0
  201. package/dist/utils/workflow-prompts/draftIntent.js.map +1 -0
  202. package/dist/utils/workflow-prompts/feasibilityCheck.d.ts +2 -0
  203. package/dist/utils/workflow-prompts/feasibilityCheck.d.ts.map +1 -0
  204. package/dist/utils/workflow-prompts/feasibilityCheck.js +21 -0
  205. package/dist/utils/workflow-prompts/feasibilityCheck.js.map +1 -0
  206. package/dist/utils/workflow-prompts/fieldCorrection.d.ts +3 -0
  207. package/dist/utils/workflow-prompts/fieldCorrection.d.ts.map +1 -0
  208. package/dist/utils/workflow-prompts/fieldCorrection.js +20 -0
  209. package/dist/utils/workflow-prompts/fieldCorrection.js.map +1 -0
  210. package/dist/utils/workflow-prompts/index.d.ts +8 -0
  211. package/dist/utils/workflow-prompts/index.d.ts.map +1 -0
  212. package/dist/utils/workflow-prompts/index.js +8 -0
  213. package/dist/utils/workflow-prompts/index.js.map +1 -0
  214. package/dist/utils/workflow-prompts/keywordExtraction.d.ts +2 -0
  215. package/dist/utils/workflow-prompts/keywordExtraction.d.ts.map +1 -0
  216. package/dist/utils/workflow-prompts/keywordExtraction.js +21 -0
  217. package/dist/utils/workflow-prompts/keywordExtraction.js.map +1 -0
  218. package/dist/utils/workflow-prompts/parameterCorrection.d.ts +3 -0
  219. package/dist/utils/workflow-prompts/parameterCorrection.d.ts.map +1 -0
  220. package/dist/utils/workflow-prompts/parameterCorrection.js +29 -0
  221. package/dist/utils/workflow-prompts/parameterCorrection.js.map +1 -0
  222. package/dist/utils/workflow-prompts/workflowGeneration.d.ts +2 -0
  223. package/dist/utils/workflow-prompts/workflowGeneration.d.ts.map +1 -0
  224. package/dist/utils/workflow-prompts/workflowGeneration.js +529 -0
  225. package/dist/utils/workflow-prompts/workflowGeneration.js.map +1 -0
  226. package/dist/utils/workflow-prompts/workflowMatching.d.ts +2 -0
  227. package/dist/utils/workflow-prompts/workflowMatching.d.ts.map +1 -0
  228. package/dist/utils/workflow-prompts/workflowMatching.js +23 -0
  229. package/dist/utils/workflow-prompts/workflowMatching.js.map +1 -0
  230. package/dist/utils/workflow.d.ts +62 -0
  231. package/dist/utils/workflow.d.ts.map +1 -0
  232. package/dist/utils/workflow.js +712 -0
  233. package/dist/utils/workflow.js.map +1 -0
  234. package/package.json +87 -0
  235. package/src/actions/index.ts +1 -0
  236. package/src/actions/workflow.ts +494 -0
  237. package/src/data/defaultNodes.json +9887 -0
  238. package/src/data/schemaIndex.json +1 -0
  239. package/src/data/triggerSchemaIndex.json +1 -0
  240. package/src/db/index.ts +8 -0
  241. package/src/db/schema.ts +94 -0
  242. package/src/index.ts +179 -0
  243. package/src/lib/automations-builder.ts +679 -0
  244. package/src/lib/automations-types.ts +391 -0
  245. package/src/lib/index.ts +8 -0
  246. package/src/lib/legacy-task-migration.ts +143 -0
  247. package/src/lib/legacy-text-trigger-migration.ts +178 -0
  248. package/src/lib/workflow-clarification.ts +497 -0
  249. package/src/plugin-routes.ts +164 -0
  250. package/src/providers/activeWorkflows.ts +81 -0
  251. package/src/providers/index.ts +3 -0
  252. package/src/providers/pendingDraft.ts +55 -0
  253. package/src/providers/workflowStatus.ts +88 -0
  254. package/src/register-routes.ts +6 -0
  255. package/src/routes/_helpers.ts +27 -0
  256. package/src/routes/automations.ts +46 -0
  257. package/src/routes/embedded-webhooks.ts +64 -0
  258. package/src/routes/executions.ts +75 -0
  259. package/src/routes/index.ts +16 -0
  260. package/src/routes/nodes.ts +211 -0
  261. package/src/routes/validation.ts +51 -0
  262. package/src/routes/workflow-routes.ts +469 -0
  263. package/src/routes/workflows.ts +310 -0
  264. package/src/schemas/draftIntent.ts +21 -0
  265. package/src/schemas/feasibility.ts +8 -0
  266. package/src/schemas/index.ts +4 -0
  267. package/src/schemas/keywordExtraction.ts +11 -0
  268. package/src/schemas/workflowMatching.ts +29 -0
  269. package/src/services/embedded-workflow-service.ts +2224 -0
  270. package/src/services/index.ts +17 -0
  271. package/src/services/workflow-credential-store.ts +132 -0
  272. package/src/services/workflow-dispatch.ts +121 -0
  273. package/src/services/workflow-service.ts +839 -0
  274. package/src/trigger-routes.ts +714 -0
  275. package/src/types/index.ts +562 -0
  276. package/src/utils/catalog.ts +260 -0
  277. package/src/utils/clarification.ts +52 -0
  278. package/src/utils/context.ts +22 -0
  279. package/src/utils/credentialResolver.ts +234 -0
  280. package/src/utils/generation.ts +987 -0
  281. package/src/utils/host-capabilities.ts +81 -0
  282. package/src/utils/inferSyntheticOutputSchema.ts +163 -0
  283. package/src/utils/outputSchema.ts +372 -0
  284. package/src/utils/validateAndRepair.ts +610 -0
  285. package/src/utils/workflow-prompts/actionResponse.ts +16 -0
  286. package/src/utils/workflow-prompts/draftIntent.ts +22 -0
  287. package/src/utils/workflow-prompts/feasibilityCheck.ts +20 -0
  288. package/src/utils/workflow-prompts/fieldCorrection.ts +20 -0
  289. package/src/utils/workflow-prompts/index.ts +10 -0
  290. package/src/utils/workflow-prompts/keywordExtraction.ts +20 -0
  291. package/src/utils/workflow-prompts/parameterCorrection.ts +29 -0
  292. package/src/utils/workflow-prompts/workflowGeneration.ts +528 -0
  293. package/src/utils/workflow-prompts/workflowMatching.ts +22 -0
  294. 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
+ ];