@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
package/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # @elizaos/plugin-workflow
2
+
3
+ In-process workflow engine for elizaOS agents. Generate and deploy automation workflows from natural language using a RAG pipeline. The plugin embeds its own execution engine — workflows run in the agent process, no separate sidecar.
4
+
5
+ Built on shared workflow type contracts from `@elizaos/workflows`. Supports the bundled node catalog used by the in-process runtime for routing decisions, with intelligent credential resolution and lifecycle management.
6
+
7
+ ## Configuration
8
+
9
+ No workflow-specific env vars are required. The plugin's `EmbeddedWorkflowService` runs CRUD + execution + scheduler + webhook handling locally inside the agent, persisted to the agent's Postgres schema.
10
+
11
+ ## Plugin Components
12
+
13
+ | Component | Purpose |
14
+ |---|---|
15
+ | `EmbeddedWorkflowService` | In-process workflow execution engine (CRUD + node runtime + scheduler + webhooks). |
16
+ | `WorkflowService` | Public service surface used by the agent's `WORKFLOW` umbrella action. Routes to the embedded workflows engine. |
17
+ | `WorkflowCredentialStore` | Stores workflow-scoped credentials (encrypted at rest). |
18
+ | `workflowStatusProvider` | Exposes engine status to the planner. |
19
+ | `activeWorkflowsProvider` | Lists active workflows for context. |
20
+ | `pendingDraftProvider` | Surfaces an in-progress draft so the agent can clarify before persisting. |
21
+ | Routes | Mounted at `/api/workflow/*` on the agent's HTTP server. |
22
+
23
+ The `WORKFLOW` umbrella action lives in `@elizaos/agent` and dispatches op-based commands (`create`, `update`, `activate`, `run`, `delete`, …) to this plugin's services.
24
+
25
+ ## RAG Pipeline (workflow generation from natural language)
26
+
27
+ 1. **Extract keywords** from the user request.
28
+ 2. **Match** against existing workflows (RAG over the workflow store) — return a match if one exists.
29
+ 3. **Generate** a new workflow definition if no match — LLM produces a node graph against the catalog from `src/data/`.
30
+ 4. **Validate & repair** node parameters / credentials / connections.
31
+ 5. **Synthesize output schemas** for downstream nodes.
32
+ 6. **Position** nodes for the visual editor.
33
+
34
+ ## Credential Resolution
35
+
36
+ Credentials are resolved at workflow-execution time. The plugin checks:
37
+ 1. Plugin-level `workflows.credentials` config map (deterministic).
38
+ 2. Cached secrets via the agent's secret service.
39
+ 3. Stored credentials via `WorkflowCredentialStore`.
40
+ 4. LLM-driven `request_credential` resolution (prompts the user).
41
+
42
+ ## Routes
43
+
44
+ All routes mount at `/api/workflow/`:
45
+
46
+ - `GET /api/workflow/status` — engine + plugin status
47
+ - `GET /api/workflow/workflows` — list
48
+ - `POST /api/workflow/workflows` — create
49
+ - `GET /api/workflow/workflows/:id`
50
+ - `PUT /api/workflow/workflows/:id`
51
+ - `DELETE /api/workflow/workflows/:id`
52
+ - `POST /api/workflow/workflows/:id/run` — trigger execution
53
+ - `GET /api/workflow/executions/:id` — execution status / result
54
+ - `POST /api/workflow/executions/:id/cancel`
55
+ - Webhook endpoints for trigger nodes are exposed dynamically per workflow.
56
+
57
+ ## Development
58
+
59
+ ```bash
60
+ bun install
61
+ bun run build
62
+ bun run typecheck
63
+ bun run test
64
+ bun run lint
65
+ ```
66
+
67
+ Lint/format is [Biome 2.x](https://biomejs.dev). TypeScript 6+. ESM only.
68
+
69
+ ## License
70
+
71
+ MIT.
package/auto-enable.ts ADDED
@@ -0,0 +1,18 @@
1
+ // Auto-enable check for @elizaos/plugin-workflow.
2
+ //
3
+ // Plugin manifest entry-point — referenced by package.json's
4
+ // `elizaos.plugin.autoEnableModule`. Keep this module light: config reads
5
+ // only, no service init, no transitive imports of the full plugin runtime.
6
+ import type { PluginAutoEnableContext } from '@elizaos/core';
7
+
8
+ /**
9
+ * Default-on: enable workflows in-process unless the user's config has
10
+ * `workflow.enabled === false` as a master switch. The central engine
11
+ * additionally honors `plugins.entries.workflow.enabled === false`.
12
+ */
13
+ export function shouldEnable(ctx: PluginAutoEnableContext): boolean {
14
+ const workflow = (ctx.config as Record<string, unknown> | undefined)?.workflow as
15
+ | Record<string, unknown>
16
+ | undefined;
17
+ return workflow?.enabled !== false;
18
+ }
@@ -0,0 +1,2 @@
1
+ export { workflowAction } from './workflow';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { workflowAction } from './workflow';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * WORKFLOW — single umbrella action for workflow lifecycle ops.
3
+ *
4
+ * Action-based dispatch (provide `action` parameter):
5
+ * create — generate + deploy a new workflow from a seed prompt
6
+ * modify — load a deployed workflow into the draft editor by id
7
+ * activate — activate a workflow by id
8
+ * deactivate — deactivate a workflow by id
9
+ * toggle_active — explicit active=true|false (preferred when scripting)
10
+ * delete — permanently delete a workflow by id
11
+ * executions — fetch recent executions for a workflow id
12
+ *
13
+ * All actions talk to the in-process `WorkflowService` via
14
+ * `runtime.getService(WORKFLOW_SERVICE_TYPE)`. There is no HTTP boundary.
15
+ *
16
+ * Trigger CRUD (create/update/delete/run a scheduled trigger, including
17
+ * promoting a task into a workflow) lives in the agent-side `TRIGGER` action,
18
+ * which uses agent-internal trigger helpers that this plugin cannot import
19
+ * without a dependency cycle.
20
+ */
21
+ import { type Action } from '@elizaos/core';
22
+ export declare const workflowAction: Action;
23
+ //# sourceMappingURL=workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/actions/workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EACL,KAAK,MAAM,EAQZ,MAAM,eAAe,CAAC;AAsSvB,eAAO,MAAM,cAAc,EAAE,MAyK5B,CAAC"}
@@ -0,0 +1,425 @@
1
+ /**
2
+ * WORKFLOW — single umbrella action for workflow lifecycle ops.
3
+ *
4
+ * Action-based dispatch (provide `action` parameter):
5
+ * create — generate + deploy a new workflow from a seed prompt
6
+ * modify — load a deployed workflow into the draft editor by id
7
+ * activate — activate a workflow by id
8
+ * deactivate — deactivate a workflow by id
9
+ * toggle_active — explicit active=true|false (preferred when scripting)
10
+ * delete — permanently delete a workflow by id
11
+ * executions — fetch recent executions for a workflow id
12
+ *
13
+ * All actions talk to the in-process `WorkflowService` via
14
+ * `runtime.getService(WORKFLOW_SERVICE_TYPE)`. There is no HTTP boundary.
15
+ *
16
+ * Trigger CRUD (create/update/delete/run a scheduled trigger, including
17
+ * promoting a task into a workflow) lives in the agent-side `TRIGGER` action,
18
+ * which uses agent-internal trigger helpers that this plugin cannot import
19
+ * without a dependency cycle.
20
+ */
21
+ import { logger, } from '@elizaos/core';
22
+ import { WORKFLOW_SERVICE_TYPE } from '../services/workflow-service';
23
+ const WORKFLOW_ACTION = 'WORKFLOW';
24
+ const WORKFLOW_OPS = [
25
+ 'create',
26
+ 'modify',
27
+ 'activate',
28
+ 'deactivate',
29
+ 'toggle_active',
30
+ 'delete',
31
+ 'executions',
32
+ ];
33
+ const WORKFLOW_CONTEXTS = ['automation', 'tasks', 'agent_internal'];
34
+ function readString(value) {
35
+ return typeof value === 'string' && value.trim() ? value.trim() : undefined;
36
+ }
37
+ function readNumber(value) {
38
+ if (typeof value === 'number' && Number.isFinite(value))
39
+ return value;
40
+ if (typeof value === 'string' && value.trim()) {
41
+ const parsed = Number(value);
42
+ if (Number.isFinite(parsed))
43
+ return parsed;
44
+ }
45
+ return undefined;
46
+ }
47
+ function readBoolean(value) {
48
+ if (typeof value === 'boolean')
49
+ return value;
50
+ if (typeof value === 'string') {
51
+ const v = value.trim().toLowerCase();
52
+ if (v === 'true' || v === '1' || v === 'yes' || v === 'on')
53
+ return true;
54
+ if (v === 'false' || v === '0' || v === 'no' || v === 'off')
55
+ return false;
56
+ }
57
+ return undefined;
58
+ }
59
+ function readOp(value) {
60
+ const s = readString(value)?.toLowerCase();
61
+ if (!s)
62
+ return undefined;
63
+ if (WORKFLOW_OPS.includes(s))
64
+ return s;
65
+ return undefined;
66
+ }
67
+ function getWorkflowService(runtime) {
68
+ return runtime.getService(WORKFLOW_SERVICE_TYPE) ?? null;
69
+ }
70
+ function resolveAgentId(runtime) {
71
+ return runtime.agentId ?? runtime.character?.id ?? '00000000-0000-0000-0000-000000000000';
72
+ }
73
+ function summarizeWorkflow(workflow) {
74
+ return {
75
+ id: String(workflow.id ?? ''),
76
+ name: String(workflow.name ?? ''),
77
+ active: Boolean(workflow.active),
78
+ };
79
+ }
80
+ async function handleCreate(runtime, service, params, message, callback) {
81
+ const seedPrompt = readString(params.seedPrompt);
82
+ const name = readString(params.name);
83
+ if (!seedPrompt) {
84
+ return {
85
+ success: false,
86
+ text: 'seedPrompt parameter is required to generate a workflow.',
87
+ };
88
+ }
89
+ try {
90
+ const draft = await service.generateWorkflowDraft(seedPrompt, {
91
+ userId: String(message.entityId ?? resolveAgentId(runtime)),
92
+ });
93
+ if (name) {
94
+ draft.name = name;
95
+ }
96
+ const deployed = await service.deployWorkflow(draft, resolveAgentId(runtime));
97
+ if (!deployed.id) {
98
+ const missing = (deployed.missingCredentials ?? []).map((c) => c.credType).join(', ');
99
+ const text = missing
100
+ ? `Workflow generated but missing credentials: ${missing}.`
101
+ : 'Workflow generation produced no deployable result.';
102
+ return { success: false, text, data: { missingCredentials: deployed.missingCredentials } };
103
+ }
104
+ const text = `Created workflow "${deployed.name}".`;
105
+ if (callback) {
106
+ await callback({
107
+ text,
108
+ action: WORKFLOW_ACTION,
109
+ metadata: { workflowId: deployed.id, workflowName: deployed.name },
110
+ });
111
+ }
112
+ return {
113
+ success: true,
114
+ text,
115
+ values: { workflowId: deployed.id, workflowName: deployed.name },
116
+ data: { workflow: summarizeWorkflow(deployed) },
117
+ };
118
+ }
119
+ catch (err) {
120
+ const message = err instanceof Error ? err.message : String(err);
121
+ logger.warn({ src: 'plugin:workflow:action:create' }, message);
122
+ return { success: false, text: message };
123
+ }
124
+ }
125
+ async function handleModify(service, params, callback) {
126
+ const workflowId = readString(params.workflowId);
127
+ if (!workflowId) {
128
+ return { success: false, text: 'workflowId is required to modify a workflow.' };
129
+ }
130
+ try {
131
+ const existing = await service.getWorkflow(workflowId);
132
+ const text = `Loaded workflow "${existing.name}" for editing.`;
133
+ if (callback) {
134
+ await callback({
135
+ text,
136
+ action: WORKFLOW_ACTION,
137
+ metadata: { workflowId, workflowName: existing.name },
138
+ });
139
+ }
140
+ return {
141
+ success: true,
142
+ text,
143
+ values: { workflowId, workflowName: existing.name },
144
+ data: { workflow: existing, awaitingUserInput: true },
145
+ };
146
+ }
147
+ catch {
148
+ return { success: false, text: `Workflow not found: ${workflowId}` };
149
+ }
150
+ }
151
+ async function handleToggleActive(service, params, desiredActive, callback) {
152
+ const workflowId = readString(params.workflowId);
153
+ if (!workflowId) {
154
+ return { success: false, text: 'workflowId parameter is required.' };
155
+ }
156
+ const explicitActive = desiredActive ?? readBoolean(params.active);
157
+ if (explicitActive === undefined) {
158
+ return {
159
+ success: false,
160
+ text: 'active parameter is required (true or false).',
161
+ };
162
+ }
163
+ let existing;
164
+ try {
165
+ existing = await service.getWorkflow(workflowId);
166
+ }
167
+ catch {
168
+ return { success: false, text: `Workflow not found: ${workflowId}` };
169
+ }
170
+ try {
171
+ if (explicitActive) {
172
+ await service.activateWorkflow(workflowId);
173
+ }
174
+ else {
175
+ await service.deactivateWorkflow(workflowId);
176
+ }
177
+ }
178
+ catch (err) {
179
+ const msg = err instanceof Error ? err.message : String(err);
180
+ logger.warn({ src: 'plugin:workflow:action:toggle_active' }, msg);
181
+ return { success: false, text: msg };
182
+ }
183
+ const refreshed = await service.getWorkflow(workflowId);
184
+ const text = explicitActive
185
+ ? `Activated workflow "${existing.name}".`
186
+ : `Deactivated workflow "${existing.name}".`;
187
+ if (callback) {
188
+ await callback({
189
+ text,
190
+ action: WORKFLOW_ACTION,
191
+ metadata: { workflowId, active: explicitActive },
192
+ });
193
+ }
194
+ return {
195
+ success: true,
196
+ text,
197
+ values: { workflowId, active: explicitActive },
198
+ data: { workflow: summarizeWorkflow(refreshed) },
199
+ };
200
+ }
201
+ async function handleDeleteWorkflow(service, params, callback) {
202
+ const workflowId = readString(params.workflowId);
203
+ if (!workflowId) {
204
+ return { success: false, text: 'workflowId parameter is required.' };
205
+ }
206
+ let existing;
207
+ try {
208
+ existing = await service.getWorkflow(workflowId);
209
+ }
210
+ catch {
211
+ return { success: false, text: `Workflow not found: ${workflowId}` };
212
+ }
213
+ try {
214
+ await service.deleteWorkflow(workflowId);
215
+ }
216
+ catch (err) {
217
+ const msg = err instanceof Error ? err.message : String(err);
218
+ logger.warn({ src: 'plugin:workflow:action:delete' }, msg);
219
+ return { success: false, text: msg };
220
+ }
221
+ const text = `Deleted workflow "${existing.name}".`;
222
+ if (callback) {
223
+ await callback({
224
+ text,
225
+ action: WORKFLOW_ACTION,
226
+ metadata: { workflowId, workflowName: existing.name },
227
+ });
228
+ }
229
+ return {
230
+ success: true,
231
+ text,
232
+ data: { workflowId, workflowName: existing.name },
233
+ };
234
+ }
235
+ async function handleExecutions(service, params, callback) {
236
+ const workflowId = readString(params.workflowId);
237
+ if (!workflowId) {
238
+ return { success: false, text: 'workflowId is required to fetch executions.' };
239
+ }
240
+ const limit = readNumber(params.limit) ?? 10;
241
+ try {
242
+ const response = await service.listExecutions({ workflowId, limit });
243
+ const executions = response.data ?? [];
244
+ const text = executions.length === 0
245
+ ? `No executions found for workflow ${workflowId}.`
246
+ : `Fetched ${executions.length} executions for workflow ${workflowId}.`;
247
+ if (callback) {
248
+ await callback({
249
+ text,
250
+ action: WORKFLOW_ACTION,
251
+ metadata: { workflowId, count: executions.length },
252
+ });
253
+ }
254
+ return {
255
+ success: true,
256
+ text,
257
+ values: { workflowId, count: executions.length },
258
+ data: { executions },
259
+ };
260
+ }
261
+ catch (err) {
262
+ const msg = err instanceof Error ? err.message : String(err);
263
+ logger.warn({ src: 'plugin:workflow:action:executions' }, msg);
264
+ return { success: false, text: msg };
265
+ }
266
+ }
267
+ export const workflowAction = {
268
+ name: WORKFLOW_ACTION,
269
+ contexts: [...WORKFLOW_CONTEXTS],
270
+ contextGate: { anyOf: [...WORKFLOW_CONTEXTS] },
271
+ roleGate: { minRole: 'OWNER' },
272
+ similes: [
273
+ 'CREATE_WORKFLOW',
274
+ 'DELETE_WORKFLOW',
275
+ 'TOGGLE_WORKFLOW_ACTIVE',
276
+ 'ACTIVATE_WORKFLOW',
277
+ 'DEACTIVATE_WORKFLOW',
278
+ 'ENABLE_WORKFLOW',
279
+ 'DISABLE_WORKFLOW',
280
+ 'PAUSE_WORKFLOW',
281
+ 'RESUME_WORKFLOW',
282
+ 'MODIFY_WORKFLOW',
283
+ 'UPDATE_WORKFLOW',
284
+ 'EDIT_WORKFLOW',
285
+ 'EDIT_EXISTING_WORKFLOW',
286
+ 'UPDATE_EXISTING_WORKFLOW',
287
+ 'CHANGE_EXISTING_WORKFLOW',
288
+ 'LOAD_WORKFLOW_FOR_EDIT',
289
+ 'GET_WORKFLOW_EXECUTIONS',
290
+ 'GET_EXECUTIONS',
291
+ 'SHOW_EXECUTIONS',
292
+ 'EXECUTION_HISTORY',
293
+ 'WORKFLOW_RUNS',
294
+ 'WORKFLOW_EXECUTIONS',
295
+ ],
296
+ description: 'Manage workflows. Action-based dispatch - provide an `action` parameter:\n' +
297
+ ' create, modify, activate, deactivate, toggle_active, delete, executions.\n' +
298
+ 'For creating/updating scheduled triggers (including promoting a task to a workflow), use the TRIGGER action.',
299
+ descriptionCompressed: 'manage workflows; action-based dispatch (create modify activate deactivate toggle_active delete executions)',
300
+ parameters: [
301
+ {
302
+ name: 'action',
303
+ description: 'Operation: create, modify, activate, deactivate, toggle_active, delete, executions.',
304
+ required: true,
305
+ schema: { type: 'string', enum: [...WORKFLOW_OPS] },
306
+ },
307
+ {
308
+ name: 'workflowId',
309
+ description: 'Workflow id.',
310
+ required: false,
311
+ schema: { type: 'string' },
312
+ },
313
+ {
314
+ name: 'workflowName',
315
+ description: 'Workflow name fragment for fuzzy matching.',
316
+ required: false,
317
+ schema: { type: 'string' },
318
+ },
319
+ {
320
+ name: 'seedPrompt',
321
+ description: 'Natural-language description for action=create.',
322
+ required: false,
323
+ schema: { type: 'string' },
324
+ },
325
+ {
326
+ name: 'name',
327
+ description: 'Optional explicit name for created workflow.',
328
+ required: false,
329
+ schema: { type: 'string' },
330
+ },
331
+ {
332
+ name: 'active',
333
+ description: 'Target state for action=toggle_active (true to activate).',
334
+ required: false,
335
+ schema: { type: 'boolean' },
336
+ },
337
+ {
338
+ name: 'limit',
339
+ description: 'Max executions to return for action=executions (default 10).',
340
+ required: false,
341
+ schema: { type: 'number' },
342
+ },
343
+ ],
344
+ validate: async (runtime, _message, _state) => {
345
+ return getWorkflowService(runtime) !== null;
346
+ },
347
+ handler: async (runtime, message, _state, options, callback) => {
348
+ const params = (options?.parameters ?? {});
349
+ const op = readOp(params.action ?? params.op);
350
+ if (!op) {
351
+ return {
352
+ success: false,
353
+ text: `action parameter is required (one of: ${WORKFLOW_OPS.join(', ')}).`,
354
+ };
355
+ }
356
+ const service = getWorkflowService(runtime);
357
+ if (!service) {
358
+ return { success: false, text: 'Workflow service is not registered.' };
359
+ }
360
+ switch (op) {
361
+ case 'create':
362
+ return handleCreate(runtime, service, params, message, callback);
363
+ case 'modify':
364
+ return handleModify(service, params, callback);
365
+ case 'activate':
366
+ return handleToggleActive(service, params, true, callback);
367
+ case 'deactivate':
368
+ return handleToggleActive(service, params, false, callback);
369
+ case 'toggle_active':
370
+ return handleToggleActive(service, params, undefined, callback);
371
+ case 'delete':
372
+ return handleDeleteWorkflow(service, params, callback);
373
+ case 'executions':
374
+ return handleExecutions(service, params, callback);
375
+ }
376
+ },
377
+ examples: [
378
+ [
379
+ {
380
+ name: '{{name1}}',
381
+ content: {
382
+ text: 'Create a workflow that posts daily summaries to Slack at 5pm.',
383
+ source: 'chat',
384
+ },
385
+ },
386
+ {
387
+ name: '{{agentName}}',
388
+ content: {
389
+ text: 'Generating the workflow.',
390
+ actions: ['WORKFLOW'],
391
+ thought: 'New workflow from a natural-language seed maps to WORKFLOW op=create with seedPrompt set.',
392
+ },
393
+ },
394
+ ],
395
+ [
396
+ {
397
+ name: '{{name1}}',
398
+ content: { text: 'Pause the daily summary workflow.', source: 'chat' },
399
+ },
400
+ {
401
+ name: '{{agentName}}',
402
+ content: {
403
+ text: 'Deactivating the workflow.',
404
+ actions: ['WORKFLOW'],
405
+ thought: 'Pause/disable maps to WORKFLOW op=deactivate (or toggle_active with active=false) on the matching workflowId.',
406
+ },
407
+ },
408
+ ],
409
+ [
410
+ {
411
+ name: '{{name1}}',
412
+ content: { text: 'Show me the last 5 executions of workflow wf-123.', source: 'chat' },
413
+ },
414
+ {
415
+ name: '{{agentName}}',
416
+ content: {
417
+ text: 'Fetching recent executions.',
418
+ actions: ['WORKFLOW'],
419
+ thought: 'Execution history maps to WORKFLOW op=executions with workflowId=wf-123 and limit=5.',
420
+ },
421
+ },
422
+ ],
423
+ ],
424
+ };
425
+ //# sourceMappingURL=workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../src/actions/workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAML,MAAM,GAGP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,qBAAqB,EAAwB,MAAM,8BAA8B,CAAC;AAO3F,MAAM,eAAe,GAAG,UAAU,CAAC;AAEnC,MAAM,YAAY,GAAG;IACnB,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,eAAe;IACf,QAAQ;IACR,YAAY;CACJ,CAAC;AAGX,MAAM,iBAAiB,GAAG,CAAC,YAAY,EAAE,OAAO,EAAE,gBAAgB,CAAU,CAAC;AAa7E,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9E,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACtE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAG,MAAM,CAAC,KA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