@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,492 @@
1
+ import { logger, Service } from '@elizaos/core';
2
+ import { isCredentialProvider, isRuntimeContextProvider, UnsupportedIntegrationError, WORKFLOW_CREDENTIAL_PROVIDER_TYPE, WORKFLOW_CREDENTIAL_STORE_TYPE, WORKFLOW_RUNTIME_CONTEXT_PROVIDER_TYPE, WorkflowApiError, } from '../types/index';
3
+ import { filterNodesByIntegrationSupport, searchNodes } from '../utils/catalog';
4
+ import { CATALOG_CLARIFICATION_SUFFIX, isCatalogClarification } from '../utils/clarification';
5
+ import { getUserTagName } from '../utils/context';
6
+ import { resolveCredentials } from '../utils/credentialResolver';
7
+ import { assessFeasibility, collectExistingNodeDefinitions, correctFieldReferences, correctParameterNames, extractKeywords, fixWorkflowErrors, generateWorkflow, modifyWorkflow, } from '../utils/generation';
8
+ import { validateAndRepair } from '../utils/validateAndRepair';
9
+ import { correctOptionParameters, detectUnknownParameters, ensureExpressionPrefix, injectMissingCredentialBlocks, normalizeTriggerSimpleParam, positionNodes, validateNodeInputs, validateNodeParameters, validateOutputReferences, validateWorkflow, } from '../utils/workflow';
10
+ import { EMBEDDED_WORKFLOW_SERVICE_TYPE, EmbeddedWorkflowService, } from './embedded-workflow-service';
11
+ export const WORKFLOW_SERVICE_TYPE = 'workflow';
12
+ function isWorkflowCredentialStoreApi(service) {
13
+ return (service !== null &&
14
+ typeof service === 'object' &&
15
+ typeof service.get === 'function' &&
16
+ typeof service.set === 'function');
17
+ }
18
+ /**
19
+ * Workflow Service - Orchestrates the RAG pipeline for workflow generation.
20
+ *
21
+ * generateWorkflowDraft(): keywords → node search → LLM generation → validation → positioning
22
+ * deployWorkflow(): credential resolution → in-process runtime → tagging
23
+ */
24
+ export class WorkflowService extends Service {
25
+ static serviceType = WORKFLOW_SERVICE_TYPE;
26
+ capabilityDescription = 'Generate and deploy workflows from natural language using RAG pipeline. ' +
27
+ 'Supports workflow CRUD, execution management, and credential resolution.';
28
+ apiClient = null;
29
+ serviceConfig = null;
30
+ static async start(runtime) {
31
+ logger.info({ src: 'plugin:workflow:service:main' }, 'Starting Workflow Service...');
32
+ // Get optional pre-configured credentials from character.settings.workflows
33
+ // Note: runtime.getSetting() only returns primitives — nested objects must be read directly
34
+ const workflowSettings = runtime.character?.settings?.workflows;
35
+ const credentials = workflowSettings?.credentials;
36
+ const service = new WorkflowService(runtime);
37
+ const embedded = runtime.getService(EMBEDDED_WORKFLOW_SERVICE_TYPE) ??
38
+ (await EmbeddedWorkflowService.start(runtime));
39
+ service.serviceConfig = {
40
+ apiKey: 'embedded',
41
+ host: 'in-process',
42
+ backend: 'embedded',
43
+ credentials,
44
+ };
45
+ service.apiClient = embedded;
46
+ logger.info({ src: 'plugin:workflow:service:main' }, `Workflow Service started - connected to ${service.serviceConfig.host}`);
47
+ if (credentials) {
48
+ const configured = Object.entries(credentials)
49
+ .filter(([, v]) => v)
50
+ .map(([k]) => k);
51
+ if (configured.length > 0) {
52
+ logger.info({ src: 'plugin:workflow:service:main' }, `Pre-configured credentials: ${configured.join(', ')}`);
53
+ }
54
+ }
55
+ return service;
56
+ }
57
+ async stop() {
58
+ logger.info({ src: 'plugin:workflow:service:main' }, 'Stopping Workflow Service...');
59
+ this.apiClient = null;
60
+ this.serviceConfig = null;
61
+ logger.info({ src: 'plugin:workflow:service:main' }, 'Workflow Service stopped');
62
+ }
63
+ filterForEmbeddedBackend(results) {
64
+ if (this.serviceConfig?.backend !== 'embedded') {
65
+ return results;
66
+ }
67
+ const registered = this.apiClient?.getRegisteredNodeTypes?.();
68
+ if (!registered?.length) {
69
+ return results;
70
+ }
71
+ const registeredSet = new Set(registered);
72
+ return results.filter((result) => registeredSet.has(result.node.name));
73
+ }
74
+ resolveDeployTarget(workflow) {
75
+ const client = this.getClient();
76
+ const config = this.getConfig();
77
+ if (config.backend !== 'embedded') {
78
+ return { client, config, routedToFallback: false };
79
+ }
80
+ const support = client.supportsWorkflow?.(workflow);
81
+ if (!support || support.supported) {
82
+ return { client, config, routedToFallback: false };
83
+ }
84
+ throw new WorkflowApiError(`Embedded workflow runtime does not support node type(s): ${support.missing.join(', ')}`, 400);
85
+ }
86
+ injectCatalogClarifications(workflow) {
87
+ const paramWarnings = validateNodeParameters(workflow);
88
+ const inputWarnings = validateNodeInputs(workflow);
89
+ const catalogWarnings = [...paramWarnings, ...inputWarnings];
90
+ if (!workflow._meta) {
91
+ workflow._meta = {};
92
+ }
93
+ // Strip previous catalog-derived clarifications to avoid stale duplicates
94
+ // across regeneration cycles (generate → modify → modify). Mixed-shape
95
+ // arrays (legacy strings + structured ClarificationRequest) are both
96
+ // supported via isCatalogClarification.
97
+ const nonCatalog = (workflow._meta.requiresClarification || []).filter((c) => !isCatalogClarification(c));
98
+ if (catalogWarnings.length > 0) {
99
+ logger.warn({ src: 'plugin:workflow:service:main' }, `Catalog validation: ${catalogWarnings.join(', ')}`);
100
+ const clarifications = catalogWarnings.map((w) => `${w} ${CATALOG_CLARIFICATION_SUFFIX}`);
101
+ workflow._meta.requiresClarification = [...nonCatalog, ...clarifications];
102
+ }
103
+ else {
104
+ workflow._meta.requiresClarification = nonCatalog.length > 0 ? nonCatalog : undefined;
105
+ }
106
+ }
107
+ getClient() {
108
+ if (!this.apiClient) {
109
+ throw new Error('Workflow Service not initialized');
110
+ }
111
+ return this.apiClient;
112
+ }
113
+ getConfig() {
114
+ if (!this.serviceConfig) {
115
+ throw new Error('Workflow Service not initialized');
116
+ }
117
+ return this.serviceConfig;
118
+ }
119
+ /**
120
+ * Query the optional `workflow_runtime_context_provider` service for runtime
121
+ * facts to inject into the workflow-generation prompt. The host runtime
122
+ * uses this to surface real Discord guild/channel IDs, the user's Gmail
123
+ * email, and which credential types it can resolve. Returns `undefined`
124
+ * when no provider is registered or the call throws — generation proceeds
125
+ * with the baseline prompt.
126
+ */
127
+ async fetchRuntimeContext(nodeDefs, userId, triggerContext) {
128
+ const raw = this.runtime.getService(WORKFLOW_RUNTIME_CONTEXT_PROVIDER_TYPE);
129
+ const provider = isRuntimeContextProvider(raw) ? raw : null;
130
+ if (!provider) {
131
+ return undefined;
132
+ }
133
+ const relevantCredTypes = [
134
+ ...new Set(nodeDefs.flatMap((n) => (n.credentials ?? []).map((c) => c.name))),
135
+ ];
136
+ try {
137
+ return await provider.getRuntimeContext({
138
+ userId,
139
+ relevantNodes: nodeDefs,
140
+ relevantCredTypes,
141
+ ...(triggerContext ? { triggerContext } : {}),
142
+ });
143
+ }
144
+ catch (err) {
145
+ logger.warn({
146
+ src: 'plugin:workflow:service:main',
147
+ err: err instanceof Error ? err.message : String(err),
148
+ }, 'RuntimeContextProvider threw — generating without runtime facts');
149
+ return undefined;
150
+ }
151
+ }
152
+ async generateWorkflowDraft(prompt, opts) {
153
+ logger.info({ src: 'plugin:workflow:service:main' }, 'Generating workflow draft from prompt');
154
+ // Fetch host-supplied bias hints early (before keyword extraction) so the
155
+ // LLM is told which providers the host already knows it can satisfy.
156
+ // We pass empty `relevantNodes` / `relevantCredTypes` here because we do
157
+ // not yet have searchNodes results — `preferredProviders` is derived from
158
+ // the host's connector config alone (independent of node search). The
159
+ // full runtime context (with credentials + facts) is fetched again later
160
+ // once we have the filtered node list.
161
+ const earlyContext = await this.fetchRuntimeContext([], opts?.userId ?? 'local');
162
+ const preferredProviders = earlyContext?.preferredProviders;
163
+ const keywords = await extractKeywords(this.runtime, prompt, preferredProviders);
164
+ logger.debug({ src: 'plugin:workflow:service:main' }, `Extracted keywords: ${keywords.join(', ')}${preferredProviders?.length ? ` (with bias: ${preferredProviders.join(', ')})` : ''}`);
165
+ let relevantNodes = this.filterForEmbeddedBackend(searchNodes(keywords, 15));
166
+ logger.debug({ src: 'plugin:workflow:service:main' }, `Found ${relevantNodes.length} relevant nodes`);
167
+ if (relevantNodes.length === 0) {
168
+ throw new Error('No relevant workflows nodes found for the given prompt. Please be more specific about the integrations you want to use (e.g., Gmail, Slack, Stripe).');
169
+ }
170
+ // ── Integration availability check ──
171
+ const rawProvider = this.runtime.getService(WORKFLOW_CREDENTIAL_PROVIDER_TYPE);
172
+ const credProvider = isCredentialProvider(rawProvider) ? rawProvider : null;
173
+ if (credProvider?.checkCredentialTypes) {
174
+ const credTypes = new Set();
175
+ for (const { node } of relevantNodes) {
176
+ for (const cred of node.credentials ?? []) {
177
+ credTypes.add(cred.name);
178
+ }
179
+ }
180
+ if (credTypes.size > 0) {
181
+ const checkResult = credProvider.checkCredentialTypes([...credTypes]);
182
+ if (checkResult.unsupported.length > 0) {
183
+ const supportedSet = new Set(checkResult.supported);
184
+ const { remaining, removed } = filterNodesByIntegrationSupport(relevantNodes, supportedSet);
185
+ const remainingServiceNodes = remaining.filter((r) => r.node.credentials?.length);
186
+ if (remainingServiceNodes.length === 0) {
187
+ throw new UnsupportedIntegrationError([...new Set(removed.map((r) => r.node.displayName))], []);
188
+ }
189
+ const feasibility = await assessFeasibility(this.runtime, prompt, removed, remaining);
190
+ if (!feasibility.feasible) {
191
+ throw new UnsupportedIntegrationError([...new Set(removed.map((r) => r.node.displayName))], [...new Set(remainingServiceNodes.map((r) => r.node.displayName))]);
192
+ }
193
+ logger.debug({ src: 'plugin:workflow:service:main' }, `Feasibility OK: ${feasibility.reason}. Proceeding with ${remaining.length} nodes.`);
194
+ relevantNodes = remaining;
195
+ }
196
+ }
197
+ }
198
+ // ── End integration check ──
199
+ const finalNodeDefs = relevantNodes.map((r) => r.node);
200
+ const runtimeContext = await this.fetchRuntimeContext(finalNodeDefs, opts?.userId ?? 'local', opts?.triggerContext);
201
+ let workflow = await generateWorkflow(this.runtime, prompt, finalNodeDefs, runtimeContext);
202
+ logger.debug({ src: 'plugin:workflow:service:main' }, `Generated workflow with ${workflow.nodes?.length || 0} nodes`);
203
+ // Safety net: even with the MANDATORY INVARIANT prompt rule, the LLM
204
+ // sometimes omits the `credentials` block on credentialed nodes. Inject
205
+ // it deterministically based on the node's catalog definition + the
206
+ // host's supported cred types so resolveCredentials can mint the
207
+ // credential server-side instead of falling back to a manual UI step.
208
+ const injectedCreds = injectMissingCredentialBlocks(workflow, finalNodeDefs, runtimeContext);
209
+ if (injectedCreds > 0) {
210
+ logger.debug({ src: 'plugin:workflow:service:main' }, `Injected ${injectedCreds} missing credentials block(s) (LLM omitted)`);
211
+ }
212
+ // Layer 1+3 (Session 21): deterministic pre-deploy validation pass with
213
+ // bounded LLM-retry. Catches typeVersion hallucinations, missing
214
+ // parameters.authentication, output-field case mismatches (Subject vs
215
+ // subject), node-name collisions, and dangling connection edges. When
216
+ // an error can't be auto-fixed deterministically, fixWorkflowErrors
217
+ // sends a surgical fix prompt to the LLM. Cap at 3 retries to bound
218
+ // worst-case cost.
219
+ //
220
+ // Fetch the live workflow runtime's node-type registry once per deploy so
221
+ // typeVersion clamping intersects catalog ∩ runtime — necessary
222
+ // because the bundled `defaultNodes.json` can be ahead of the user's
223
+ // actually-installed workflows binary (e.g. catalog says Gmail v2.2 but
224
+ // runtime only ships up to v2.1).
225
+ const generateClient = this.getClient();
226
+ const runtimeVersions = (await generateClient.getRuntimeNodeTypeVersions()) ?? undefined;
227
+ for (let attempt = 0; attempt < 3; attempt++) {
228
+ const repairResult = validateAndRepair(workflow, finalNodeDefs, runtimeContext, runtimeVersions);
229
+ workflow = repairResult.workflow;
230
+ if (repairResult.errors.length === 0) {
231
+ break;
232
+ }
233
+ if (attempt === 2) {
234
+ logger.warn({
235
+ src: 'plugin:workflow:service:main',
236
+ errors: repairResult.errors,
237
+ }, `validateAndRepair: ${repairResult.errors.length} unrecoverable error(s) after 3 retries — proceeding to deploy with _meta.errors`);
238
+ workflow._meta = workflow._meta ?? {};
239
+ const errorLines = repairResult.errors.map((e) => `${e.node}: ${e.detail}${e.availableFields?.length ? ` (available: ${e.availableFields.join(', ')})` : ''}`);
240
+ const existing = workflow._meta.requiresClarification ?? [];
241
+ workflow._meta.requiresClarification = [...existing, ...errorLines];
242
+ break;
243
+ }
244
+ try {
245
+ workflow = await fixWorkflowErrors(this.runtime, workflow, repairResult.errors, finalNodeDefs);
246
+ }
247
+ catch (err) {
248
+ logger.warn({
249
+ src: 'plugin:workflow:service:main',
250
+ err: err instanceof Error ? err.message : String(err),
251
+ }, 'fixWorkflowErrors threw — exiting retry loop');
252
+ break;
253
+ }
254
+ }
255
+ normalizeTriggerSimpleParam(workflow);
256
+ const optionFixes = correctOptionParameters(workflow);
257
+ if (optionFixes > 0) {
258
+ logger.debug({ src: 'plugin:workflow:service:main' }, `Corrected ${optionFixes} invalid option parameter(s)`);
259
+ }
260
+ const unknownParams = detectUnknownParameters(workflow);
261
+ if (unknownParams.length > 0) {
262
+ logger.debug({ src: 'plugin:workflow:service:main' }, `Found ${unknownParams.length} node(s) with unknown parameters, auto-correcting...`);
263
+ workflow = await correctParameterNames(this.runtime, workflow, unknownParams);
264
+ }
265
+ const invalidRefs = validateOutputReferences(workflow);
266
+ if (invalidRefs.length > 0) {
267
+ logger.debug({ src: 'plugin:workflow:service:main' }, `Found ${invalidRefs.length} invalid field reference(s), auto-correcting...`);
268
+ workflow = await correctFieldReferences(this.runtime, workflow, invalidRefs);
269
+ }
270
+ const exprPrefixed = ensureExpressionPrefix(workflow);
271
+ if (exprPrefixed > 0) {
272
+ logger.debug({ src: 'plugin:workflow:service:main' }, `Prefixed ${exprPrefixed} expression value(s) with "="`);
273
+ }
274
+ const validationResult = validateWorkflow(workflow);
275
+ if (!validationResult.valid) {
276
+ logger.error({ src: 'plugin:workflow:service:main' }, `Validation errors: ${validationResult.errors.join(', ')}`);
277
+ throw new Error(`Generated workflow is invalid: ${validationResult.errors[0]}`);
278
+ }
279
+ if (validationResult.warnings.length > 0) {
280
+ logger.warn({ src: 'plugin:workflow:service:main' }, `Validation warnings: ${validationResult.warnings.join(', ')}`);
281
+ }
282
+ this.injectCatalogClarifications(workflow);
283
+ return positionNodes(workflow);
284
+ }
285
+ async modifyWorkflowDraft(existingWorkflow, modificationRequest, opts) {
286
+ logger.info({ src: 'plugin:workflow:service:main' }, `Modifying workflow draft: ${modificationRequest.slice(0, 100)}`);
287
+ // Get definitions for nodes already in the workflow
288
+ const existingDefs = collectExistingNodeDefinitions(existingWorkflow);
289
+ // Search for new nodes the modification might need
290
+ const keywords = await extractKeywords(this.runtime, modificationRequest);
291
+ const searchResults = this.filterForEmbeddedBackend(searchNodes(keywords, 10));
292
+ const newDefs = searchResults.map((r) => r.node);
293
+ // Deduplicate: merge existing + new, preferring existing (already in workflow)
294
+ const seenNames = new Set(existingDefs.map((d) => d.name));
295
+ const combinedDefs = [...existingDefs];
296
+ for (const def of newDefs) {
297
+ if (!seenNames.has(def.name)) {
298
+ seenNames.add(def.name);
299
+ combinedDefs.push(def);
300
+ }
301
+ }
302
+ logger.debug({ src: 'plugin:workflow:service:main' }, `Modify context: ${existingDefs.length} existing + ${newDefs.length} searched → ${combinedDefs.length} unique node defs`);
303
+ const runtimeContext = await this.fetchRuntimeContext(combinedDefs, opts?.userId ?? 'local', opts?.triggerContext);
304
+ let workflow = await modifyWorkflow(this.runtime, existingWorkflow, modificationRequest, combinedDefs, runtimeContext);
305
+ // Safety net: same deterministic credential-block injection as
306
+ // generateWorkflowDraft. Modification regenerations are equally prone
307
+ // to dropping the credentials block.
308
+ const injectedCreds = injectMissingCredentialBlocks(workflow, combinedDefs, runtimeContext);
309
+ if (injectedCreds > 0) {
310
+ logger.debug({ src: 'plugin:workflow:service:main' }, `Injected ${injectedCreds} missing credentials block(s) on modify (LLM omitted)`);
311
+ }
312
+ // Layer 1+3 (Session 21): mirror the validate-and-repair retry loop on
313
+ // the modify path. Modifications can drift in the same ways generations
314
+ // do (typeVersion hallucination, missing authentication, etc.) so the
315
+ // gate must run here too. Same runtime-version intersect as the
316
+ // generate path — fetch once, reuse across all 3 retry attempts.
317
+ const modifyClient = this.getClient();
318
+ const runtimeVersionsForModify = (await modifyClient.getRuntimeNodeTypeVersions()) ?? undefined;
319
+ for (let attempt = 0; attempt < 3; attempt++) {
320
+ const repairResult = validateAndRepair(workflow, combinedDefs, runtimeContext, runtimeVersionsForModify);
321
+ workflow = repairResult.workflow;
322
+ if (repairResult.errors.length === 0) {
323
+ break;
324
+ }
325
+ if (attempt === 2) {
326
+ logger.warn({
327
+ src: 'plugin:workflow:service:main',
328
+ errors: repairResult.errors,
329
+ }, `validateAndRepair (modify): ${repairResult.errors.length} unrecoverable error(s) after 3 retries`);
330
+ workflow._meta = workflow._meta ?? {};
331
+ const errorLines = repairResult.errors.map((e) => `${e.node}: ${e.detail}${e.availableFields?.length ? ` (available: ${e.availableFields.join(', ')})` : ''}`);
332
+ const existing = workflow._meta.requiresClarification ?? [];
333
+ workflow._meta.requiresClarification = [...existing, ...errorLines];
334
+ break;
335
+ }
336
+ try {
337
+ workflow = await fixWorkflowErrors(this.runtime, workflow, repairResult.errors, combinedDefs);
338
+ }
339
+ catch (err) {
340
+ logger.warn({
341
+ src: 'plugin:workflow:service:main',
342
+ err: err instanceof Error ? err.message : String(err),
343
+ }, 'fixWorkflowErrors (modify) threw — exiting retry loop');
344
+ break;
345
+ }
346
+ }
347
+ normalizeTriggerSimpleParam(workflow);
348
+ const optionFixes = correctOptionParameters(workflow);
349
+ if (optionFixes > 0) {
350
+ logger.debug({ src: 'plugin:workflow:service:main' }, `Corrected ${optionFixes} invalid option parameter(s) in modified workflow`);
351
+ }
352
+ const unknownParams = detectUnknownParameters(workflow);
353
+ if (unknownParams.length > 0) {
354
+ logger.debug({ src: 'plugin:workflow:service:main' }, `Found ${unknownParams.length} node(s) with unknown parameters in modified workflow, auto-correcting...`);
355
+ workflow = await correctParameterNames(this.runtime, workflow, unknownParams);
356
+ }
357
+ const invalidRefs = validateOutputReferences(workflow);
358
+ if (invalidRefs.length > 0) {
359
+ logger.debug({ src: 'plugin:workflow:service:main' }, `Found ${invalidRefs.length} invalid field reference(s) in modified workflow, auto-correcting...`);
360
+ workflow = await correctFieldReferences(this.runtime, workflow, invalidRefs);
361
+ }
362
+ const exprPrefixed = ensureExpressionPrefix(workflow);
363
+ if (exprPrefixed > 0) {
364
+ logger.debug({ src: 'plugin:workflow:service:main' }, `Prefixed ${exprPrefixed} expression value(s) with "=" in modified workflow`);
365
+ }
366
+ const validationResult = validateWorkflow(workflow);
367
+ if (!validationResult.valid) {
368
+ logger.error({ src: 'plugin:workflow:service:main' }, `Modified workflow validation errors: ${validationResult.errors.join(', ')}`);
369
+ throw new Error(`Modified workflow is invalid: ${validationResult.errors[0]}`);
370
+ }
371
+ this.injectCatalogClarifications(workflow);
372
+ return positionNodes(workflow);
373
+ }
374
+ async deployWorkflow(workflow, userId) {
375
+ logger.info({ src: 'plugin:workflow:service:main' }, `Deploying workflow "${workflow.name}" for user ${userId}`);
376
+ const deployTarget = this.resolveDeployTarget(workflow);
377
+ const { config, client } = deployTarget;
378
+ const rawCredStore = this.runtime.getService(WORKFLOW_CREDENTIAL_STORE_TYPE);
379
+ const credStore = isWorkflowCredentialStoreApi(rawCredStore) ? rawCredStore : null;
380
+ const rawProvider = this.runtime.getService(WORKFLOW_CREDENTIAL_PROVIDER_TYPE);
381
+ const credProvider = isCredentialProvider(rawProvider) ? rawProvider : null;
382
+ // Compute tag name once - reused for credentials and workflow tagging
383
+ const tagName = await getUserTagName(this.runtime, userId);
384
+ const credentialResult = await resolveCredentials(workflow, userId, config, credStore ?? null, credProvider, client, tagName);
385
+ // Block deploy if any credential is unresolved
386
+ if (credentialResult.missingConnections.length > 0) {
387
+ return {
388
+ id: '',
389
+ name: workflow.name,
390
+ active: false,
391
+ nodeCount: workflow.nodes.length,
392
+ missingCredentials: credentialResult.missingConnections,
393
+ };
394
+ }
395
+ // Determine if this is an update (existing workflow) or create (new workflow).
396
+ // If update fails (workflow deleted on workflows), fallback to create.
397
+ let deployedWorkflow;
398
+ let wasUpdate = false;
399
+ if (workflow.id) {
400
+ try {
401
+ deployedWorkflow = await client.updateWorkflow(workflow.id, credentialResult.workflow);
402
+ wasUpdate = true;
403
+ }
404
+ catch {
405
+ logger.warn({ src: 'plugin:workflow:service:main' }, `Update failed for workflow ${workflow.id}, creating new workflow instead`);
406
+ const { id: _, ...rest } = credentialResult.workflow;
407
+ deployedWorkflow = await client.createWorkflow(rest);
408
+ }
409
+ }
410
+ else {
411
+ deployedWorkflow = await client.createWorkflow(credentialResult.workflow);
412
+ }
413
+ logger.info({ src: 'plugin:workflow:service:main' }, `Workflow ${wasUpdate ? 'updated' : 'created'}: ${deployedWorkflow.id}`);
414
+ // Activate (publish) the workflow immediately after creation/update
415
+ let active = false;
416
+ try {
417
+ await client.activateWorkflow(deployedWorkflow.id);
418
+ active = true;
419
+ logger.info({ src: 'plugin:workflow:service:main' }, `Workflow ${deployedWorkflow.id} activated`);
420
+ }
421
+ catch (error) {
422
+ logger.warn({ src: 'plugin:workflow:service:main' }, `Failed to activate workflow: ${error instanceof Error ? error.message : String(error)}`);
423
+ }
424
+ // Only tag new workflows (existing ones should already have tags)
425
+ if (userId && !wasUpdate) {
426
+ try {
427
+ const userTag = await client.getOrCreateTag(tagName);
428
+ await client.updateWorkflowTags(deployedWorkflow.id, [userTag.id]);
429
+ logger.debug({ src: 'plugin:workflow:service:main' }, `Tagged workflow ${deployedWorkflow.id} with "${tagName}"`);
430
+ }
431
+ catch (error) {
432
+ logger.warn({ src: 'plugin:workflow:service:main' }, `Failed to tag workflow: ${error instanceof Error ? error.message : String(error)}`);
433
+ }
434
+ }
435
+ return {
436
+ id: deployedWorkflow.id,
437
+ name: deployedWorkflow.name,
438
+ active,
439
+ nodeCount: deployedWorkflow.nodes?.length || 0,
440
+ missingCredentials: credentialResult.missingConnections,
441
+ };
442
+ }
443
+ async listWorkflows(userId) {
444
+ const client = this.getClient();
445
+ if (userId) {
446
+ const tagName = await getUserTagName(this.runtime, userId);
447
+ const tagsResponse = await client.listTags();
448
+ const userTag = tagsResponse.data.find((t) => t.name === tagName);
449
+ if (!userTag) {
450
+ return []; // No workflows for this user
451
+ }
452
+ // Get all workflows and filter by tag
453
+ const workflowsResponse = await client.listWorkflows();
454
+ return workflowsResponse.data.filter((w) => w.tags?.some((t) => t.id === userTag.id));
455
+ }
456
+ const response = await client.listWorkflows();
457
+ return response.data;
458
+ }
459
+ async activateWorkflow(workflowId) {
460
+ const client = this.getClient();
461
+ await client.activateWorkflow(workflowId);
462
+ logger.info({ src: 'plugin:workflow:service:main' }, `Workflow ${workflowId} activated`);
463
+ }
464
+ async deactivateWorkflow(workflowId) {
465
+ const client = this.getClient();
466
+ await client.deactivateWorkflow(workflowId);
467
+ logger.info({ src: 'plugin:workflow:service:main' }, `Workflow ${workflowId} deactivated`);
468
+ }
469
+ async deleteWorkflow(workflowId) {
470
+ const client = this.getClient();
471
+ await client.deleteWorkflow(workflowId);
472
+ logger.info({ src: 'plugin:workflow:service:main' }, `Workflow ${workflowId} deleted`);
473
+ }
474
+ async getWorkflow(workflowId) {
475
+ const client = this.getClient();
476
+ return client.getWorkflow(workflowId);
477
+ }
478
+ async getWorkflowExecutions(workflowId, limit) {
479
+ const client = this.getClient();
480
+ const response = await client.listExecutions({ workflowId, limit });
481
+ return response.data;
482
+ }
483
+ async listExecutions(params) {
484
+ const client = this.getClient();
485
+ return client.listExecutions(params);
486
+ }
487
+ async getExecutionDetail(executionId) {
488
+ const client = this.getClient();
489
+ return client.getExecution(executionId);
490
+ }
491
+ }
492
+ //# sourceMappingURL=workflow-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-service.js","sourceRoot":"","sources":["../../src/services/workflow-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,MAAM,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAWpE,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,2BAA2B,EAC3B,iCAAiC,EACjC,8BAA8B,EAC9B,sCAAsC,EACtC,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,+BAA+B,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAC9F,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EACL,iBAAiB,EACjB,8BAA8B,EAC9B,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,6BAA6B,EAC7B,2BAA2B,EAC3B,aAAa,EACb,kBAAkB,E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