@elizaos/plugin-workflow 2.0.0-beta.1 → 2.0.3-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +28 -26
- package/dist/actions/eval-code.d.ts +12 -0
- package/dist/actions/eval-code.d.ts.map +1 -0
- package/dist/actions/eval-code.js +59 -0
- package/dist/actions/eval-code.js.map +1 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +1 -0
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/workflow.d.ts +7 -0
- package/dist/actions/workflow.d.ts.map +1 -1
- package/dist/actions/workflow.js +462 -10
- package/dist/actions/workflow.js.map +1 -1
- package/dist/db/schema.d.ts +196 -0
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +23 -0
- package/dist/db/schema.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -64
- package/dist/index.js.map +1 -1
- package/dist/lib/automations-builder.d.ts.map +1 -1
- package/dist/lib/automations-builder.js +10 -35
- package/dist/lib/automations-builder.js.map +1 -1
- package/dist/lib/automations-types.d.ts +2 -2
- package/dist/lib/automations-types.d.ts.map +1 -1
- package/dist/lib/automations-types.js.map +1 -1
- package/dist/lib/index.d.ts +0 -2
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +1 -2
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/workflow-clarification.d.ts +2 -2
- package/dist/lib/workflow-clarification.d.ts.map +1 -1
- package/dist/lib/workflow-clarification.js +15 -11
- package/dist/lib/workflow-clarification.js.map +1 -1
- package/dist/plugin-routes.d.ts.map +1 -1
- package/dist/plugin-routes.js +6 -0
- package/dist/plugin-routes.js.map +1 -1
- package/dist/providers/activeWorkflows.js +2 -2
- package/dist/providers/activeWorkflows.js.map +1 -1
- package/dist/providers/workflowStatus.js +1 -1
- package/dist/providers/workflowStatus.js.map +1 -1
- package/dist/routes/workflow-routes.d.ts.map +1 -1
- package/dist/routes/workflow-routes.js +68 -2
- package/dist/routes/workflow-routes.js.map +1 -1
- package/dist/routes/workflows.d.ts.map +1 -1
- package/dist/routes/workflows.js +5 -1
- package/dist/routes/workflows.js.map +1 -1
- package/dist/services/embedded-workflow-service.d.ts +74 -17
- package/dist/services/embedded-workflow-service.d.ts.map +1 -1
- package/dist/services/embedded-workflow-service.js +343 -149
- package/dist/services/embedded-workflow-service.js.map +1 -1
- package/dist/services/smithers-runtime.d.ts +47 -0
- package/dist/services/smithers-runtime.d.ts.map +1 -0
- package/dist/services/smithers-runtime.js +444 -0
- package/dist/services/smithers-runtime.js.map +1 -0
- package/dist/services/workflow-credential-store.js +1 -1
- package/dist/services/workflow-credential-store.js.map +1 -1
- package/dist/services/workflow-dispatch.d.ts +31 -1
- package/dist/services/workflow-dispatch.d.ts.map +1 -1
- package/dist/services/workflow-dispatch.js +75 -10
- package/dist/services/workflow-dispatch.js.map +1 -1
- package/dist/services/workflow-service.d.ts +27 -1
- package/dist/services/workflow-service.d.ts.map +1 -1
- package/dist/services/workflow-service.js +133 -11
- package/dist/services/workflow-service.js.map +1 -1
- package/dist/trigger-routes.d.ts +2 -18
- package/dist/trigger-routes.d.ts.map +1 -1
- package/dist/trigger-routes.js +11 -39
- package/dist/trigger-routes.js.map +1 -1
- package/dist/types/index.d.ts +82 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/workflow-contracts.d.ts +118 -0
- package/dist/types/workflow-contracts.d.ts.map +1 -0
- package/dist/types/workflow-contracts.js +2 -0
- package/dist/types/workflow-contracts.js.map +1 -0
- package/dist/utils/catalog.js +2 -2
- package/dist/utils/catalog.js.map +1 -1
- package/dist/utils/clarification.d.ts +1 -1
- package/dist/utils/clarification.d.ts.map +1 -1
- package/dist/utils/clarification.js +15 -4
- package/dist/utils/clarification.js.map +1 -1
- package/dist/utils/context.js +1 -1
- package/dist/utils/context.js.map +1 -1
- package/dist/utils/evaluation-samples.d.ts +6 -0
- package/dist/utils/evaluation-samples.d.ts.map +1 -0
- package/dist/utils/evaluation-samples.js +216 -0
- package/dist/utils/evaluation-samples.js.map +1 -0
- package/dist/utils/execution-diagnostics.d.ts +26 -0
- package/dist/utils/execution-diagnostics.d.ts.map +1 -0
- package/dist/utils/execution-diagnostics.js +159 -0
- package/dist/utils/execution-diagnostics.js.map +1 -0
- package/dist/utils/generation.d.ts.map +1 -1
- package/dist/utils/generation.js +134 -19
- package/dist/utils/generation.js.map +1 -1
- package/dist/utils/host-capabilities.d.ts.map +1 -1
- package/dist/utils/host-capabilities.js +20 -5
- package/dist/utils/host-capabilities.js.map +1 -1
- package/dist/utils/inferSyntheticOutputSchema.js +3 -3
- package/dist/utils/inferSyntheticOutputSchema.js.map +1 -1
- package/dist/utils/outputSchema.js +1 -1
- package/dist/utils/outputSchema.js.map +1 -1
- package/dist/utils/validateAndRepair.js +10 -10
- package/dist/utils/validateAndRepair.js.map +1 -1
- package/dist/utils/workflow-prompts/draftIntent.d.ts +1 -1
- package/dist/utils/workflow-prompts/draftIntent.d.ts.map +1 -1
- package/dist/utils/workflow-prompts/draftIntent.js +1 -1
- package/dist/utils/workflow-prompts/keywordExtraction.d.ts +1 -1
- package/dist/utils/workflow-prompts/keywordExtraction.d.ts.map +1 -1
- package/dist/utils/workflow-prompts/keywordExtraction.js +1 -1
- package/dist/utils/workflow-prompts/workflowGeneration.d.ts +1 -1
- package/dist/utils/workflow-prompts/workflowGeneration.d.ts.map +1 -1
- package/dist/utils/workflow-prompts/workflowGeneration.js +4 -4
- package/dist/utils/workflow-prompts/workflowMatching.d.ts +1 -1
- package/dist/utils/workflow-prompts/workflowMatching.d.ts.map +1 -1
- package/dist/utils/workflow-prompts/workflowMatching.js +1 -1
- package/dist/utils/workflow.d.ts +1 -0
- package/dist/utils/workflow.d.ts.map +1 -1
- package/dist/utils/workflow.js +44 -8
- package/dist/utils/workflow.js.map +1 -1
- package/package.json +27 -8
- package/registry-entry.json +25 -0
- package/src/actions/eval-code.ts +81 -0
- package/src/actions/index.ts +1 -0
- package/src/actions/workflow.ts +518 -10
- package/src/db/schema.ts +31 -0
- package/src/index.ts +9 -82
- package/src/lib/automations-builder.ts +11 -35
- package/src/lib/automations-types.ts +1 -2
- package/src/lib/index.ts +0 -8
- package/src/lib/workflow-clarification.ts +18 -13
- package/src/plugin-routes.ts +6 -0
- package/src/providers/activeWorkflows.ts +2 -2
- package/src/providers/workflowStatus.ts +1 -1
- package/src/routes/workflow-routes.ts +100 -2
- package/src/routes/workflows.ts +5 -1
- package/src/services/embedded-workflow-service.ts +447 -172
- package/src/services/smithers-runtime.ts +526 -0
- package/src/services/workflow-credential-store.ts +1 -1
- package/src/services/workflow-dispatch.ts +116 -13
- package/src/services/workflow-service.ts +186 -10
- package/src/trigger-routes.ts +12 -70
- package/src/types/index.ts +94 -2
- package/src/types/workflow-contracts.ts +166 -0
- package/src/utils/catalog.ts +2 -2
- package/src/utils/clarification.ts +19 -5
- package/src/utils/context.ts +1 -1
- package/src/utils/evaluation-samples.ts +239 -0
- package/src/utils/execution-diagnostics.ts +192 -0
- package/src/utils/generation.ts +224 -32
- package/src/utils/host-capabilities.ts +21 -5
- package/src/utils/inferSyntheticOutputSchema.ts +3 -3
- package/src/utils/outputSchema.ts +1 -1
- package/src/utils/validateAndRepair.ts +10 -10
- package/src/utils/workflow-prompts/draftIntent.ts +1 -1
- package/src/utils/workflow-prompts/keywordExtraction.ts +1 -1
- package/src/utils/workflow-prompts/workflowGeneration.ts +4 -4
- package/src/utils/workflow-prompts/workflowMatching.ts +1 -1
- package/src/utils/workflow.ts +56 -8
- package/dist/lib/legacy-task-migration.d.ts +0 -20
- package/dist/lib/legacy-task-migration.d.ts.map +0 -1
- package/dist/lib/legacy-task-migration.js +0 -110
- package/dist/lib/legacy-task-migration.js.map +0 -1
- package/dist/lib/legacy-text-trigger-migration.d.ts +0 -18
- package/dist/lib/legacy-text-trigger-migration.d.ts.map +0 -1
- package/dist/lib/legacy-text-trigger-migration.js +0 -131
- package/dist/lib/legacy-text-trigger-migration.js.map +0 -1
- package/src/lib/legacy-task-migration.ts +0 -143
- package/src/lib/legacy-text-trigger-migration.ts +0 -178
|
@@ -157,12 +157,12 @@ function applyAuthenticationBackfill(
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
const authOpts = credDef.displayOptions?.show?.authentication;
|
|
160
|
-
if (
|
|
160
|
+
if (authOpts?.length !== 1) {
|
|
161
161
|
return;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
const requiredAuth = authOpts[0];
|
|
165
|
-
const params =
|
|
165
|
+
const params = node.parameters as Record<string, unknown>;
|
|
166
166
|
if (typeof params.authentication === 'string' && params.authentication.length > 0) {
|
|
167
167
|
return; // LLM already set it
|
|
168
168
|
}
|
|
@@ -180,7 +180,7 @@ function applyAuthenticationBackfill(
|
|
|
180
180
|
/** Build name → node map for upstream-graph walk. */
|
|
181
181
|
function buildUpstreamMap(workflow: WorkflowDefinition): Map<string, string[]> {
|
|
182
182
|
const upstream = new Map<string, string[]>();
|
|
183
|
-
for (const fromName of Object.keys(workflow.connections
|
|
183
|
+
for (const fromName of Object.keys(workflow.connections)) {
|
|
184
184
|
const outputs = workflow.connections[fromName];
|
|
185
185
|
for (const outputType of Object.keys(outputs)) {
|
|
186
186
|
const branches = outputs[outputType];
|
|
@@ -213,8 +213,8 @@ function knownOutputFieldsForNode(node: WorkflowNode): string[] | null {
|
|
|
213
213
|
|
|
214
214
|
// 2. Static output-schema catalog (Gmail non-simple, Slack, Discord etc.)
|
|
215
215
|
if (
|
|
216
|
-
typeof node.parameters
|
|
217
|
-
typeof node.parameters
|
|
216
|
+
typeof node.parameters.resource === 'string' &&
|
|
217
|
+
typeof node.parameters.operation === 'string'
|
|
218
218
|
) {
|
|
219
219
|
const schema = loadOutputSchema(node.type, node.parameters.resource, node.parameters.operation);
|
|
220
220
|
if (schema) {
|
|
@@ -399,7 +399,7 @@ function applyAggregationSourceFieldFix(
|
|
|
399
399
|
} // unknowable schema → skip
|
|
400
400
|
|
|
401
401
|
for (const entry of values) {
|
|
402
|
-
if (typeof entry
|
|
402
|
+
if (typeof entry.field !== 'string' || entry.field.length === 0) {
|
|
403
403
|
continue;
|
|
404
404
|
}
|
|
405
405
|
if (fields.includes(entry.field)) {
|
|
@@ -441,11 +441,11 @@ function applyRequiredParameterPreflight(
|
|
|
441
441
|
if (!def) {
|
|
442
442
|
continue;
|
|
443
443
|
}
|
|
444
|
-
for (const prop of def.properties
|
|
444
|
+
for (const prop of def.properties) {
|
|
445
445
|
if (!prop.required) {
|
|
446
446
|
continue;
|
|
447
447
|
}
|
|
448
|
-
const params =
|
|
448
|
+
const params = node.parameters as Record<string, unknown>;
|
|
449
449
|
if (params[prop.name] === undefined || params[prop.name] === '') {
|
|
450
450
|
clarifications.push(
|
|
451
451
|
`${node.name} (${node.type}) is missing required parameter "${prop.name}" ${CATALOG_CLARIFICATION_SUFFIX}`
|
|
@@ -488,7 +488,7 @@ function deduplicateNodeNames(workflow: WorkflowDefinition, repairs: Repair[]):
|
|
|
488
488
|
// Update connections referencing the old name? The original was first
|
|
489
489
|
// — connections pointing at oldName still resolve to the original.
|
|
490
490
|
// Rewrite outgoing connections key on duplicate node.
|
|
491
|
-
if (workflow.connections
|
|
491
|
+
if (workflow.connections[oldName]) {
|
|
492
492
|
// Outgoing connections for the duplicate: move under new name only
|
|
493
493
|
// when the original doesn't already own them. Heuristic: if both
|
|
494
494
|
// the dup and original happen to share outgoing edges, leave as-is
|
|
@@ -552,7 +552,7 @@ export function validateAndRepair(
|
|
|
552
552
|
const repairs: Repair[] = [];
|
|
553
553
|
const errors: ValidationError[] = [];
|
|
554
554
|
|
|
555
|
-
if (!workflow
|
|
555
|
+
if (!workflow.nodes || !Array.isArray(workflow.nodes)) {
|
|
556
556
|
return { workflow, repairs, errors };
|
|
557
557
|
}
|
|
558
558
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const DRAFT_INTENT_SYSTEM_PROMPT = `
|
|
1
|
+
export const DRAFT_INTENT_SYSTEM_PROMPT = `Determine what the user wants to do with this workflow draft. A draft has been generated and shown to the user as a preview.
|
|
2
2
|
|
|
3
3
|
Your job: determine what the user wants to do based on their message. The user may write in ANY language — interpret the meaning, not specific keywords.
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const KEYWORD_EXTRACTION_SYSTEM_PROMPT = `
|
|
1
|
+
export const KEYWORD_EXTRACTION_SYSTEM_PROMPT = `Extract relevant search terms for finding workflow nodes.
|
|
2
2
|
|
|
3
3
|
Given a user prompt describing an workflow, extract up to 5 concise keywords or phrases that best represent the core actions, services, or data transformations involved.
|
|
4
4
|
|
|
@@ -228,7 +228,7 @@ Workflow-level settings, e.g. timezone, error workflow, execution options.
|
|
|
228
228
|
|
|
229
229
|
## **Prompt Example for AI**
|
|
230
230
|
|
|
231
|
-
>
|
|
231
|
+
> Given the user's intent, generate a workflow as a JSON object.
|
|
232
232
|
> Use the following structure:
|
|
233
233
|
> - \`nodes\`: List of nodes, each with \`id\`, \`name\`, \`type\`, \`typeVersion\`, \`position\`, \`parameters\`, and optional \`credentials\`.
|
|
234
234
|
> - \`connections\`: Object mapping node names to their output connections.
|
|
@@ -399,7 +399,7 @@ When the runtime gives you a Discord guild id or channel id, write it verbatim a
|
|
|
399
399
|
|
|
400
400
|
**Display-name → id resolution is mandatory when a fact line covers it.** When the user names a server, channel, chat, or contact by display name (e.g. *Cozy Devs*, *#general*, *#alerts*), search the \`## Runtime Facts\` block for a matching entry and use the id from that fact line verbatim. Compare names case-insensitively and ignore a leading \`#\` on channel names. Never emit a placeholder, a guessed id, or the display name itself as the parameter value when a fact line resolves it. If the user said *"Cozy Devs"* and a fact reads \`Discord guild "Cozy Devs" (id 1234567890) channels: #general (id 9876543210), …\`, then \`guildId\` is \`"1234567890"\` and \`channelId\` for *#general* is \`"9876543210"\` — no exceptions.
|
|
401
401
|
|
|
402
|
-
If a fact is genuinely missing AND the runtime did not provide it, do NOT guess. Emit a structured \`ClarificationRequest\` in \`_meta.requiresClarification\` (see "Handling
|
|
402
|
+
If a fact is genuinely missing AND the runtime did not provide it, do NOT guess. Emit a structured \`ClarificationRequest\` in \`_meta.requiresClarification\` (see "Handling Partial or Ambiguous Prompts" below) and stop populating the dependent node parameter rather than emitting a placeholder.
|
|
403
403
|
|
|
404
404
|
---
|
|
405
405
|
|
|
@@ -418,7 +418,7 @@ If neither applies, you MUST NOT invent a field name from training data. Pick th
|
|
|
418
418
|
|
|
419
419
|
---
|
|
420
420
|
|
|
421
|
-
## **Handling
|
|
421
|
+
## **Handling Partial or Ambiguous Prompts**
|
|
422
422
|
|
|
423
423
|
The workflow will be shown to the user as a preview before deployment. Use the \`_meta\` field to communicate assumptions, suggestions, and clarification needs.
|
|
424
424
|
|
|
@@ -524,5 +524,5 @@ Prompt: "send me a daily reminder on Discord" (Runtime Facts lists user's Discor
|
|
|
524
524
|
|
|
525
525
|
---
|
|
526
526
|
|
|
527
|
-
**IMPORTANT**: Always generate a complete, valid workflow even if assumptions are made. Never leave placeholders or
|
|
527
|
+
**IMPORTANT**: Always generate a complete, valid workflow even if assumptions are made. Never leave placeholders or partial nodes. The \`requiresClarification\` questions will be shown to the user alongside the preview — they can then refine their request.
|
|
528
528
|
`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const WORKFLOW_MATCHING_SYSTEM_PROMPT = `
|
|
1
|
+
export const WORKFLOW_MATCHING_SYSTEM_PROMPT = `Match the user's request to the most appropriate workflow from their available workflows.
|
|
2
2
|
|
|
3
3
|
Consider:
|
|
4
4
|
- Keywords and phrases in the workflow name that match the request
|
package/src/utils/workflow.ts
CHANGED
|
@@ -171,7 +171,7 @@ export function validateNodeParameters(workflow: WorkflowDefinition): string[] {
|
|
|
171
171
|
continue;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
const value = node.parameters
|
|
174
|
+
const value = node.parameters[prop.name];
|
|
175
175
|
if (value === undefined || value === null || value === '') {
|
|
176
176
|
const label = prop.displayName || prop.name;
|
|
177
177
|
// Include the catalog property description in parentheses when
|
|
@@ -257,7 +257,7 @@ function isPropertyVisible(prop: NodeProperty, parameters: Record<string, unknow
|
|
|
257
257
|
if (!Array.isArray(allowedValues)) {
|
|
258
258
|
continue;
|
|
259
259
|
}
|
|
260
|
-
const paramValue = parameters
|
|
260
|
+
const paramValue = parameters[key];
|
|
261
261
|
if (!allowedValues.includes(paramValue)) {
|
|
262
262
|
return false;
|
|
263
263
|
}
|
|
@@ -270,7 +270,7 @@ function isPropertyVisible(prop: NodeProperty, parameters: Record<string, unknow
|
|
|
270
270
|
if (!Array.isArray(hiddenValues)) {
|
|
271
271
|
continue;
|
|
272
272
|
}
|
|
273
|
-
const paramValue = parameters
|
|
273
|
+
const paramValue = parameters[key];
|
|
274
274
|
if (hiddenValues.includes(paramValue)) {
|
|
275
275
|
return false;
|
|
276
276
|
}
|
|
@@ -280,6 +280,10 @@ function isPropertyVisible(prop: NodeProperty, parameters: Record<string, unknow
|
|
|
280
280
|
return true;
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
284
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
285
|
+
}
|
|
286
|
+
|
|
283
287
|
export function validateNodeInputs(workflow: WorkflowDefinition): string[] {
|
|
284
288
|
const warnings: string[] = [];
|
|
285
289
|
|
|
@@ -398,8 +402,8 @@ export function validateOutputReferences(workflow: WorkflowDefinition): OutputRe
|
|
|
398
402
|
schemaCache.set(sourceName, null);
|
|
399
403
|
return null;
|
|
400
404
|
}
|
|
401
|
-
const resource = (sourceNode.parameters
|
|
402
|
-
const operation = (sourceNode.parameters
|
|
405
|
+
const resource = (sourceNode.parameters.resource as string) || '';
|
|
406
|
+
const operation = (sourceNode.parameters.operation as string) || '';
|
|
403
407
|
const schemaResult = isTriggerNode(sourceNode.type)
|
|
404
408
|
? loadTriggerOutputSchema(sourceNode.type, sourceNode.parameters as Record<string, unknown>)
|
|
405
409
|
: loadOutputSchema(sourceNode.type, resource, operation);
|
|
@@ -442,8 +446,8 @@ export function validateOutputReferences(workflow: WorkflowDefinition): OutputRe
|
|
|
442
446
|
|
|
443
447
|
const exists = fieldExistsInSchema(expr.path, cached.schema);
|
|
444
448
|
if (!exists) {
|
|
445
|
-
const resource = (cached.node.parameters
|
|
446
|
-
const operation = (cached.node.parameters
|
|
449
|
+
const resource = (cached.node.parameters.resource as string) || '';
|
|
450
|
+
const operation = (cached.node.parameters.operation as string) || '';
|
|
447
451
|
invalidRefs.push({
|
|
448
452
|
nodeName: node.name,
|
|
449
453
|
expression: expr.fullExpression,
|
|
@@ -483,6 +487,8 @@ export function correctOptionParameters(workflow: WorkflowDefinition): number {
|
|
|
483
487
|
corrections++;
|
|
484
488
|
}
|
|
485
489
|
|
|
490
|
+
corrections += normalizeSetNodeAssignments(node);
|
|
491
|
+
|
|
486
492
|
const validVersions = Array.isArray(nodeDef.version) ? nodeDef.version : [nodeDef.version];
|
|
487
493
|
if (node.typeVersion && !validVersions.includes(node.typeVersion)) {
|
|
488
494
|
const maxVersion = Math.max(...validVersions);
|
|
@@ -523,6 +529,48 @@ export function correctOptionParameters(workflow: WorkflowDefinition): number {
|
|
|
523
529
|
return corrections;
|
|
524
530
|
}
|
|
525
531
|
|
|
532
|
+
export function normalizeWorkflowNodeParameterShapes(workflow: WorkflowDefinition): number {
|
|
533
|
+
let corrections = 0;
|
|
534
|
+
for (const node of workflow.nodes) {
|
|
535
|
+
corrections += normalizeSetNodeAssignments(node);
|
|
536
|
+
}
|
|
537
|
+
return corrections;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
function normalizeSetNodeAssignments(node: WorkflowDefinition['nodes'][0]): number {
|
|
541
|
+
if (node.type !== 'workflows-nodes-base.set' || !isRecord(node.parameters)) {
|
|
542
|
+
return 0;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
const assignmentContainer = node.parameters.assignments;
|
|
546
|
+
if (!isRecord(assignmentContainer)) {
|
|
547
|
+
return 0;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
if (Array.isArray(assignmentContainer.assignments)) {
|
|
551
|
+
return 0;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
const generatedValues = assignmentContainer.values;
|
|
555
|
+
if (!Array.isArray(generatedValues)) {
|
|
556
|
+
return 0;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
const assignments = generatedValues.filter(isRecord).map((entry) => ({
|
|
560
|
+
name: entry.name,
|
|
561
|
+
value: entry.value,
|
|
562
|
+
...(entry.type !== undefined ? { type: entry.type } : {}),
|
|
563
|
+
}));
|
|
564
|
+
|
|
565
|
+
assignmentContainer.assignments = assignments;
|
|
566
|
+
delete assignmentContainer.values;
|
|
567
|
+
logger.warn(
|
|
568
|
+
{ src: 'plugin:workflow:correctOptions' },
|
|
569
|
+
`Node "${node.name}": assignments.values → assignments.assignments`
|
|
570
|
+
);
|
|
571
|
+
return 1;
|
|
572
|
+
}
|
|
573
|
+
|
|
526
574
|
function fixOptionValue(node: WorkflowDefinition['nodes'][0], prop: NodeProperty): number {
|
|
527
575
|
const currentValue = node.parameters[prop.name];
|
|
528
576
|
if (currentValue === undefined) {
|
|
@@ -821,7 +869,7 @@ export function injectMissingCredentialBlocks(
|
|
|
821
869
|
// workflows nodes typically gate credentials by `displayOptions.show.authentication`
|
|
822
870
|
// (e.g. discord's discordBotApi shows when authentication=botToken).
|
|
823
871
|
const auth =
|
|
824
|
-
typeof node.parameters
|
|
872
|
+
typeof node.parameters.authentication === 'string'
|
|
825
873
|
? (node.parameters.authentication as string)
|
|
826
874
|
: null;
|
|
827
875
|
const candidate = def.credentials.find((c) => {
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Idempotent migration: legacy `workbench-task` Task records → workflows
|
|
3
|
-
*
|
|
4
|
-
* Walks every Task tagged `workbench-task` for the running agent and, for
|
|
5
|
-
* each task that has not already been converted, deploys a one-node workflow
|
|
6
|
-
* built around `workflows-nodes-base.respondToEvent`. The original task is
|
|
7
|
-
* mutated in place to record `metadata.migratedToWorkflowId` so subsequent
|
|
8
|
-
* boots skip it.
|
|
9
|
-
*
|
|
10
|
-
* Designed to run on every plugin init; per-task try/catch keeps a single
|
|
11
|
-
* failed conversion from aborting the loop. The function never throws.
|
|
12
|
-
*/
|
|
13
|
-
import { type IAgentRuntime } from '@elizaos/core';
|
|
14
|
-
export interface LegacyTaskMigrationSummary {
|
|
15
|
-
migrated: number;
|
|
16
|
-
skipped: number;
|
|
17
|
-
failed: number;
|
|
18
|
-
}
|
|
19
|
-
export declare function migrateLegacyWorkbenchTasks(runtime: IAgentRuntime): Promise<LegacyTaskMigrationSummary>;
|
|
20
|
-
//# sourceMappingURL=legacy-task-migration.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-task-migration.d.ts","sourceRoot":"","sources":["../../src/lib/legacy-task-migration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAqB,MAAM,eAAe,CAAC;AAQtE,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AA+BD,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,0BAA0B,CAAC,CAoFrC"}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Idempotent migration: legacy `workbench-task` Task records → workflows
|
|
3
|
-
*
|
|
4
|
-
* Walks every Task tagged `workbench-task` for the running agent and, for
|
|
5
|
-
* each task that has not already been converted, deploys a one-node workflow
|
|
6
|
-
* built around `workflows-nodes-base.respondToEvent`. The original task is
|
|
7
|
-
* mutated in place to record `metadata.migratedToWorkflowId` so subsequent
|
|
8
|
-
* boots skip it.
|
|
9
|
-
*
|
|
10
|
-
* Designed to run on every plugin init; per-task try/catch keeps a single
|
|
11
|
-
* failed conversion from aborting the loop. The function never throws.
|
|
12
|
-
*/
|
|
13
|
-
import { logger } from '@elizaos/core';
|
|
14
|
-
import { WORKFLOW_SERVICE_TYPE } from '../services/workflow-service';
|
|
15
|
-
const WORKBENCH_TASK_TAG = 'workbench-task';
|
|
16
|
-
const RESPOND_TO_EVENT_NODE_TYPE = 'workflows-nodes-base.respondToEvent';
|
|
17
|
-
function readWorkflowService(runtime) {
|
|
18
|
-
const svc = runtime.getService(WORKFLOW_SERVICE_TYPE);
|
|
19
|
-
return svc ?? null;
|
|
20
|
-
}
|
|
21
|
-
function buildRespondToEventWorkflow(task) {
|
|
22
|
-
const displayName = task.name?.trim().length ? task.name : 'Workbench Task';
|
|
23
|
-
const instructions = task.description?.trim().length ? task.description : displayName;
|
|
24
|
-
return {
|
|
25
|
-
name: displayName,
|
|
26
|
-
nodes: [
|
|
27
|
-
{
|
|
28
|
-
id: 'respond-to-event',
|
|
29
|
-
name: 'Respond To Event',
|
|
30
|
-
type: RESPOND_TO_EVENT_NODE_TYPE,
|
|
31
|
-
typeVersion: 1,
|
|
32
|
-
position: [0, 0],
|
|
33
|
-
parameters: {
|
|
34
|
-
instructions,
|
|
35
|
-
displayName,
|
|
36
|
-
wakeMode: 'inject_now',
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
connections: {},
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
export async function migrateLegacyWorkbenchTasks(runtime) {
|
|
44
|
-
const summary = { migrated: 0, skipped: 0, failed: 0 };
|
|
45
|
-
const service = readWorkflowService(runtime);
|
|
46
|
-
if (!service) {
|
|
47
|
-
logger.debug({ src: 'plugin:workflow:migration:workbench' }, 'WorkflowService not registered; skipping workbench-task migration');
|
|
48
|
-
return summary;
|
|
49
|
-
}
|
|
50
|
-
let tasks;
|
|
51
|
-
try {
|
|
52
|
-
tasks = await runtime.getTasks({
|
|
53
|
-
agentIds: [runtime.agentId],
|
|
54
|
-
tags: [WORKBENCH_TASK_TAG],
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
catch (err) {
|
|
58
|
-
logger.warn({
|
|
59
|
-
src: 'plugin:workflow:migration:workbench',
|
|
60
|
-
err: err instanceof Error ? err.message : String(err),
|
|
61
|
-
}, 'Failed to list workbench-tagged tasks; aborting migration');
|
|
62
|
-
return summary;
|
|
63
|
-
}
|
|
64
|
-
for (const task of tasks) {
|
|
65
|
-
if (!task.id) {
|
|
66
|
-
summary.skipped += 1;
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
const metadata = (task.metadata ?? {});
|
|
70
|
-
if (typeof metadata.migratedToWorkflowId === 'string') {
|
|
71
|
-
summary.skipped += 1;
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
try {
|
|
75
|
-
const draft = buildRespondToEventWorkflow(task);
|
|
76
|
-
const deployed = await service.deployWorkflow(draft, runtime.agentId);
|
|
77
|
-
if (!deployed.id) {
|
|
78
|
-
// Deploy returned without a workflow id (typically: missing
|
|
79
|
-
// credentials). Treat as a failure rather than marking the task
|
|
80
|
-
// migrated — we want to retry on a future boot.
|
|
81
|
-
summary.failed += 1;
|
|
82
|
-
logger.warn({
|
|
83
|
-
src: 'plugin:workflow:migration:workbench',
|
|
84
|
-
taskId: task.id,
|
|
85
|
-
taskName: task.name,
|
|
86
|
-
}, 'deployWorkflow returned no id; will retry on next boot');
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
await runtime.updateTask(task.id, {
|
|
90
|
-
metadata: {
|
|
91
|
-
...metadata,
|
|
92
|
-
migratedToWorkflowId: deployed.id,
|
|
93
|
-
migratedAt: Date.now(),
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
summary.migrated += 1;
|
|
97
|
-
}
|
|
98
|
-
catch (err) {
|
|
99
|
-
summary.failed += 1;
|
|
100
|
-
logger.warn({
|
|
101
|
-
src: 'plugin:workflow:migration:workbench',
|
|
102
|
-
taskId: task.id,
|
|
103
|
-
taskName: task.name,
|
|
104
|
-
err: err instanceof Error ? err.message : String(err),
|
|
105
|
-
}, 'Failed to migrate workbench task to workflow');
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return summary;
|
|
109
|
-
}
|
|
110
|
-
//# sourceMappingURL=legacy-task-migration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-task-migration.js","sourceRoot":"","sources":["../../src/lib/legacy-task-migration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAsB,MAAM,EAAa,MAAM,eAAe,CAAC;AAEtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAGrE,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AAC5C,MAAM,0BAA0B,GAAG,qCAAqC,CAAC;AAQzE,SAAS,mBAAmB,CAAC,OAAsB;IACjD,MAAM,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,qBAAqB,CAA2B,CAAC;IAChF,OAAO,GAAG,IAAI,IAAI,CAAC;AACrB,CAAC;AAED,SAAS,2BAA2B,CAAC,IAAU;IAC7C,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAC5E,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC;IAEtF,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE;YACL;gBACE,EAAE,EAAE,kBAAkB;gBACtB,IAAI,EAAE,kBAAkB;gBACxB,IAAI,EAAE,0BAA0B;gBAChC,WAAW,EAAE,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AM,CAAC,GAAG,CAAC;aACtD,EACD,8CAA8C,CAC/C,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Idempotent migration: legacy `kind: "text"` trigger Tasks → workflow triggers
|
|
3
|
-
*
|
|
4
|
-
* Walks every TRIGGER_DISPATCH task for the running agent. For each task whose
|
|
5
|
-
* stored `metadata.trigger.kind` is `"text"` (or omitted, which is the legacy
|
|
6
|
-
* default), deploy a one-node workflow built around
|
|
7
|
-
* `workflows-nodes-base.respondToEvent` and rewrite the trigger metadata so
|
|
8
|
-
* `kind = "workflow"` plus a pointer to the new workflow. A `migratedFromText`
|
|
9
|
-
* marker prevents double-conversion on subsequent boots.
|
|
10
|
-
*/
|
|
11
|
-
import { type IAgentRuntime } from '@elizaos/core';
|
|
12
|
-
export interface LegacyTextTriggerMigrationSummary {
|
|
13
|
-
migrated: number;
|
|
14
|
-
skipped: number;
|
|
15
|
-
failed: number;
|
|
16
|
-
}
|
|
17
|
-
export declare function migrateLegacyTextTriggers(runtime: IAgentRuntime): Promise<LegacyTextTriggerMigrationSummary>;
|
|
18
|
-
//# sourceMappingURL=legacy-text-trigger-migration.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legacy-text-trigger-migration.d.ts","sourceRoot":"","sources":["../../src/lib/legacy-text-trigger-migration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,eAAe,CAAC;AAQvB,MAAM,WAAW,iCAAiC;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AA+CD,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,iCAAiC,CAAC,CAmG5C"}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Idempotent migration: legacy `kind: "text"` trigger Tasks → workflow triggers
|
|
3
|
-
*
|
|
4
|
-
* Walks every TRIGGER_DISPATCH task for the running agent. For each task whose
|
|
5
|
-
* stored `metadata.trigger.kind` is `"text"` (or omitted, which is the legacy
|
|
6
|
-
* default), deploy a one-node workflow built around
|
|
7
|
-
* `workflows-nodes-base.respondToEvent` and rewrite the trigger metadata so
|
|
8
|
-
* `kind = "workflow"` plus a pointer to the new workflow. A `migratedFromText`
|
|
9
|
-
* marker prevents double-conversion on subsequent boots.
|
|
10
|
-
*/
|
|
11
|
-
import { logger, } from '@elizaos/core';
|
|
12
|
-
import { WORKFLOW_SERVICE_TYPE } from '../services/workflow-service';
|
|
13
|
-
const TRIGGER_TASK_NAME = 'TRIGGER_DISPATCH';
|
|
14
|
-
const RESPOND_TO_EVENT_NODE_TYPE = 'workflows-nodes-base.respondToEvent';
|
|
15
|
-
function readWorkflowService(runtime) {
|
|
16
|
-
const svc = runtime.getService(WORKFLOW_SERVICE_TYPE);
|
|
17
|
-
return svc ?? null;
|
|
18
|
-
}
|
|
19
|
-
function readTriggerFromMetadata(task) {
|
|
20
|
-
const trigger = task.metadata?.trigger;
|
|
21
|
-
if (!trigger || typeof trigger !== 'object' || Array.isArray(trigger))
|
|
22
|
-
return null;
|
|
23
|
-
if (typeof trigger.triggerId !== 'string')
|
|
24
|
-
return null;
|
|
25
|
-
return trigger;
|
|
26
|
-
}
|
|
27
|
-
function buildRespondToEventWorkflow(trigger, fallbackName) {
|
|
28
|
-
const displayName = typeof trigger.displayName === 'string' && trigger.displayName.trim().length > 0
|
|
29
|
-
? trigger.displayName
|
|
30
|
-
: fallbackName;
|
|
31
|
-
const instructions = typeof trigger.instructions === 'string' && trigger.instructions.trim().length > 0
|
|
32
|
-
? trigger.instructions
|
|
33
|
-
: displayName;
|
|
34
|
-
return {
|
|
35
|
-
name: displayName,
|
|
36
|
-
nodes: [
|
|
37
|
-
{
|
|
38
|
-
id: 'respond-to-event',
|
|
39
|
-
name: 'Respond To Event',
|
|
40
|
-
type: RESPOND_TO_EVENT_NODE_TYPE,
|
|
41
|
-
typeVersion: 1,
|
|
42
|
-
position: [0, 0],
|
|
43
|
-
parameters: {
|
|
44
|
-
instructions,
|
|
45
|
-
displayName,
|
|
46
|
-
wakeMode: 'inject_now',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
connections: {},
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
export async function migrateLegacyTextTriggers(runtime) {
|
|
54
|
-
const summary = { migrated: 0, skipped: 0, failed: 0 };
|
|
55
|
-
const service = readWorkflowService(runtime);
|
|
56
|
-
if (!service) {
|
|
57
|
-
logger.debug({ src: 'plugin:workflow:migration:text-trigger' }, 'WorkflowService not registered; skipping text-trigger migration');
|
|
58
|
-
return summary;
|
|
59
|
-
}
|
|
60
|
-
let tasks;
|
|
61
|
-
try {
|
|
62
|
-
tasks = await runtime.getTasksByName(TRIGGER_TASK_NAME);
|
|
63
|
-
}
|
|
64
|
-
catch (err) {
|
|
65
|
-
logger.warn({
|
|
66
|
-
src: 'plugin:workflow:migration:text-trigger',
|
|
67
|
-
err: err instanceof Error ? err.message : String(err),
|
|
68
|
-
}, 'Failed to list trigger dispatch tasks; aborting migration');
|
|
69
|
-
return summary;
|
|
70
|
-
}
|
|
71
|
-
for (const task of tasks) {
|
|
72
|
-
if (!task.id || task.agentId !== runtime.agentId) {
|
|
73
|
-
summary.skipped += 1;
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
const metadata = task.metadata ?? {};
|
|
77
|
-
if (metadata.migratedFromText === true) {
|
|
78
|
-
summary.skipped += 1;
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
const trigger = readTriggerFromMetadata(task);
|
|
82
|
-
if (!trigger) {
|
|
83
|
-
summary.skipped += 1;
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
// `kind` is optional in the legacy schema; absence implies "text".
|
|
87
|
-
const isTextKind = trigger.kind === 'text' || trigger.kind === undefined;
|
|
88
|
-
if (!isTextKind) {
|
|
89
|
-
summary.skipped += 1;
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
try {
|
|
93
|
-
const draft = buildRespondToEventWorkflow(trigger, task.name ?? 'Trigger');
|
|
94
|
-
const deployed = await service.deployWorkflow(draft, runtime.agentId);
|
|
95
|
-
if (!deployed.id) {
|
|
96
|
-
summary.failed += 1;
|
|
97
|
-
logger.warn({
|
|
98
|
-
src: 'plugin:workflow:migration:text-trigger',
|
|
99
|
-
taskId: task.id,
|
|
100
|
-
triggerId: trigger.triggerId,
|
|
101
|
-
}, 'deployWorkflow returned no id; will retry on next boot');
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
const updatedTrigger = {
|
|
105
|
-
...trigger,
|
|
106
|
-
kind: 'workflow',
|
|
107
|
-
workflowId: deployed.id,
|
|
108
|
-
workflowName: deployed.name,
|
|
109
|
-
};
|
|
110
|
-
const nextMetadata = {
|
|
111
|
-
...metadata,
|
|
112
|
-
trigger: updatedTrigger,
|
|
113
|
-
migratedFromText: true,
|
|
114
|
-
migratedAt: Date.now(),
|
|
115
|
-
};
|
|
116
|
-
await runtime.updateTask(task.id, { metadata: nextMetadata });
|
|
117
|
-
summary.migrated += 1;
|
|
118
|
-
}
|
|
119
|
-
catch (err) {
|
|
120
|
-
summary.failed += 1;
|
|
121
|
-
logger.warn({
|
|
122
|
-
src: 'plugin:workflow:migration:text-trigger',
|
|
123
|
-
taskId: task.id,
|
|
124
|
-
triggerId: trigger.triggerId,
|
|
125
|
-
err: err instanceof Error ? err.message : String(err),
|
|
126
|
-
}, 'Failed to migrate text trigger to workflow trigger');
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return summary;
|
|
130
|
-
}
|
|
131
|
-
//# sourceMappingURL=legacy-text-trigger-migration.js.map
|
|
@@ -1 +0,0 @@
|
|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