@elizaos/plugin-workflow 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -0
- package/auto-enable.ts +18 -0
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +2 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/workflow.d.ts +23 -0
- package/dist/actions/workflow.d.ts.map +1 -0
- package/dist/actions/workflow.js +425 -0
- package/dist/actions/workflow.js.map +1 -0
- package/dist/data/defaultNodes.json +9887 -0
- package/dist/data/schemaIndex.json +1 -0
- package/dist/data/triggerSchemaIndex.json +1 -0
- package/dist/db/index.d.ts +2 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +2 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/schema.d.ts +588 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +59 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +126 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/automations-builder.d.ts +21 -0
- package/dist/lib/automations-builder.d.ts.map +1 -0
- package/dist/lib/automations-builder.js +557 -0
- package/dist/lib/automations-builder.js.map +1 -0
- package/dist/lib/automations-types.d.ts +153 -0
- package/dist/lib/automations-types.d.ts.map +1 -0
- package/dist/lib/automations-types.js +191 -0
- package/dist/lib/automations-types.js.map +1 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +3 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/legacy-task-migration.d.ts +20 -0
- package/dist/lib/legacy-task-migration.d.ts.map +1 -0
- package/dist/lib/legacy-task-migration.js +110 -0
- package/dist/lib/legacy-task-migration.js.map +1 -0
- package/dist/lib/legacy-text-trigger-migration.d.ts +18 -0
- package/dist/lib/legacy-text-trigger-migration.d.ts.map +1 -0
- package/dist/lib/legacy-text-trigger-migration.js +131 -0
- package/dist/lib/legacy-text-trigger-migration.js.map +1 -0
- package/dist/lib/workflow-clarification.d.ts +113 -0
- package/dist/lib/workflow-clarification.d.ts.map +1 -0
- package/dist/lib/workflow-clarification.js +425 -0
- package/dist/lib/workflow-clarification.js.map +1 -0
- package/dist/plugin-routes.d.ts +9 -0
- package/dist/plugin-routes.d.ts.map +1 -0
- package/dist/plugin-routes.js +147 -0
- package/dist/plugin-routes.js.map +1 -0
- package/dist/providers/activeWorkflows.d.ts +11 -0
- package/dist/providers/activeWorkflows.d.ts.map +1 -0
- package/dist/providers/activeWorkflows.js +72 -0
- package/dist/providers/activeWorkflows.js.map +1 -0
- package/dist/providers/index.d.ts +4 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +4 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/pendingDraft.d.ts +9 -0
- package/dist/providers/pendingDraft.d.ts.map +1 -0
- package/dist/providers/pendingDraft.js +48 -0
- package/dist/providers/pendingDraft.js.map +1 -0
- package/dist/providers/workflowStatus.d.ts +3 -0
- package/dist/providers/workflowStatus.d.ts.map +1 -0
- package/dist/providers/workflowStatus.js +69 -0
- package/dist/providers/workflowStatus.js.map +1 -0
- package/dist/register-routes.d.ts +2 -0
- package/dist/register-routes.d.ts.map +1 -0
- package/dist/register-routes.js +6 -0
- package/dist/register-routes.js.map +1 -0
- package/dist/routes/_helpers.d.ts +11 -0
- package/dist/routes/_helpers.d.ts.map +1 -0
- package/dist/routes/_helpers.js +22 -0
- package/dist/routes/_helpers.js.map +1 -0
- package/dist/routes/automations.d.ts +19 -0
- package/dist/routes/automations.d.ts.map +1 -0
- package/dist/routes/automations.js +32 -0
- package/dist/routes/automations.js.map +1 -0
- package/dist/routes/embedded-webhooks.d.ts +3 -0
- package/dist/routes/embedded-webhooks.d.ts.map +1 -0
- package/dist/routes/embedded-webhooks.js +47 -0
- package/dist/routes/embedded-webhooks.js.map +1 -0
- package/dist/routes/executions.d.ts +3 -0
- package/dist/routes/executions.d.ts.map +1 -0
- package/dist/routes/executions.js +58 -0
- package/dist/routes/executions.js.map +1 -0
- package/dist/routes/index.d.ts +4 -0
- package/dist/routes/index.d.ts.map +1 -0
- package/dist/routes/index.js +14 -0
- package/dist/routes/index.js.map +1 -0
- package/dist/routes/nodes.d.ts +3 -0
- package/dist/routes/nodes.d.ts.map +1 -0
- package/dist/routes/nodes.js +168 -0
- package/dist/routes/nodes.js.map +1 -0
- package/dist/routes/validation.d.ts +3 -0
- package/dist/routes/validation.d.ts.map +1 -0
- package/dist/routes/validation.js +41 -0
- package/dist/routes/validation.js.map +1 -0
- package/dist/routes/workflow-routes.d.ts +27 -0
- package/dist/routes/workflow-routes.d.ts.map +1 -0
- package/dist/routes/workflow-routes.js +326 -0
- package/dist/routes/workflow-routes.js.map +1 -0
- package/dist/routes/workflows.d.ts +3 -0
- package/dist/routes/workflows.d.ts.map +1 -0
- package/dist/routes/workflows.js +252 -0
- package/dist/routes/workflows.js.map +1 -0
- package/dist/schemas/draftIntent.d.ts +22 -0
- package/dist/schemas/draftIntent.d.ts.map +1 -0
- package/dist/schemas/draftIntent.js +22 -0
- package/dist/schemas/draftIntent.js.map +1 -0
- package/dist/schemas/feasibility.d.ts +13 -0
- package/dist/schemas/feasibility.d.ts.map +1 -0
- package/dist/schemas/feasibility.js +9 -0
- package/dist/schemas/feasibility.js.map +1 -0
- package/dist/schemas/index.d.ts +5 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +5 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/keywordExtraction.d.ts +14 -0
- package/dist/schemas/keywordExtraction.d.ts.map +1 -0
- package/dist/schemas/keywordExtraction.js +12 -0
- package/dist/schemas/keywordExtraction.js.map +1 -0
- package/dist/schemas/workflowMatching.d.ts +36 -0
- package/dist/schemas/workflowMatching.d.ts.map +1 -0
- package/dist/schemas/workflowMatching.js +30 -0
- package/dist/schemas/workflowMatching.js.map +1 -0
- package/dist/services/embedded-workflow-service.d.ts +106 -0
- package/dist/services/embedded-workflow-service.d.ts.map +1 -0
- package/dist/services/embedded-workflow-service.js +1900 -0
- package/dist/services/embedded-workflow-service.js.map +1 -0
- package/dist/services/index.d.ts +5 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +5 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/workflow-credential-store.d.ts +27 -0
- package/dist/services/workflow-credential-store.d.ts.map +1 -0
- package/dist/services/workflow-credential-store.js +92 -0
- package/dist/services/workflow-credential-store.js.map +1 -0
- package/dist/services/workflow-dispatch.d.ts +41 -0
- package/dist/services/workflow-dispatch.d.ts.map +1 -0
- package/dist/services/workflow-dispatch.js +86 -0
- package/dist/services/workflow-dispatch.js.map +1 -0
- package/dist/services/workflow-service.d.ts +63 -0
- package/dist/services/workflow-service.d.ts.map +1 -0
- package/dist/services/workflow-service.js +492 -0
- package/dist/services/workflow-service.js.map +1 -0
- package/dist/trigger-routes.d.ts +153 -0
- package/dist/trigger-routes.d.ts.map +1 -0
- package/dist/trigger-routes.js +424 -0
- package/dist/trigger-routes.js.map +1 -0
- package/dist/types/index.d.ts +457 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +59 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/catalog.d.ts +16 -0
- package/dist/utils/catalog.d.ts.map +1 -0
- package/dist/utils/catalog.js +211 -0
- package/dist/utils/catalog.js.map +1 -0
- package/dist/utils/clarification.d.ts +17 -0
- package/dist/utils/clarification.d.ts.map +1 -0
- package/dist/utils/clarification.js +46 -0
- package/dist/utils/clarification.js.map +1 -0
- package/dist/utils/context.d.ts +4 -0
- package/dist/utils/context.d.ts.map +1 -0
- package/dist/utils/context.js +18 -0
- package/dist/utils/context.js.map +1 -0
- package/dist/utils/credentialResolver.d.ts +22 -0
- package/dist/utils/credentialResolver.d.ts.map +1 -0
- package/dist/utils/credentialResolver.js +146 -0
- package/dist/utils/credentialResolver.js.map +1 -0
- package/dist/utils/generation.d.ts +36 -0
- package/dist/utils/generation.d.ts.map +1 -0
- package/dist/utils/generation.js +701 -0
- package/dist/utils/generation.js.map +1 -0
- package/dist/utils/host-capabilities.d.ts +27 -0
- package/dist/utils/host-capabilities.d.ts.map +1 -0
- package/dist/utils/host-capabilities.js +59 -0
- package/dist/utils/host-capabilities.js.map +1 -0
- package/dist/utils/inferSyntheticOutputSchema.d.ts +20 -0
- package/dist/utils/inferSyntheticOutputSchema.d.ts.map +1 -0
- package/dist/utils/inferSyntheticOutputSchema.js +151 -0
- package/dist/utils/inferSyntheticOutputSchema.js.map +1 -0
- package/dist/utils/outputSchema.d.ts +26 -0
- package/dist/utils/outputSchema.d.ts.map +1 -0
- package/dist/utils/outputSchema.js +297 -0
- package/dist/utils/outputSchema.js.map +1 -0
- package/dist/utils/validateAndRepair.d.ts +41 -0
- package/dist/utils/validateAndRepair.d.ts.map +1 -0
- package/dist/utils/validateAndRepair.js +483 -0
- package/dist/utils/validateAndRepair.js.map +1 -0
- package/dist/utils/workflow-prompts/actionResponse.d.ts +2 -0
- package/dist/utils/workflow-prompts/actionResponse.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/actionResponse.js +17 -0
- package/dist/utils/workflow-prompts/actionResponse.js.map +1 -0
- package/dist/utils/workflow-prompts/draftIntent.d.ts +2 -0
- package/dist/utils/workflow-prompts/draftIntent.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/draftIntent.js +23 -0
- package/dist/utils/workflow-prompts/draftIntent.js.map +1 -0
- package/dist/utils/workflow-prompts/feasibilityCheck.d.ts +2 -0
- package/dist/utils/workflow-prompts/feasibilityCheck.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/feasibilityCheck.js +21 -0
- package/dist/utils/workflow-prompts/feasibilityCheck.js.map +1 -0
- package/dist/utils/workflow-prompts/fieldCorrection.d.ts +3 -0
- package/dist/utils/workflow-prompts/fieldCorrection.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/fieldCorrection.js +20 -0
- package/dist/utils/workflow-prompts/fieldCorrection.js.map +1 -0
- package/dist/utils/workflow-prompts/index.d.ts +8 -0
- package/dist/utils/workflow-prompts/index.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/index.js +8 -0
- package/dist/utils/workflow-prompts/index.js.map +1 -0
- package/dist/utils/workflow-prompts/keywordExtraction.d.ts +2 -0
- package/dist/utils/workflow-prompts/keywordExtraction.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/keywordExtraction.js +21 -0
- package/dist/utils/workflow-prompts/keywordExtraction.js.map +1 -0
- package/dist/utils/workflow-prompts/parameterCorrection.d.ts +3 -0
- package/dist/utils/workflow-prompts/parameterCorrection.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/parameterCorrection.js +29 -0
- package/dist/utils/workflow-prompts/parameterCorrection.js.map +1 -0
- package/dist/utils/workflow-prompts/workflowGeneration.d.ts +2 -0
- package/dist/utils/workflow-prompts/workflowGeneration.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/workflowGeneration.js +529 -0
- package/dist/utils/workflow-prompts/workflowGeneration.js.map +1 -0
- package/dist/utils/workflow-prompts/workflowMatching.d.ts +2 -0
- package/dist/utils/workflow-prompts/workflowMatching.d.ts.map +1 -0
- package/dist/utils/workflow-prompts/workflowMatching.js +23 -0
- package/dist/utils/workflow-prompts/workflowMatching.js.map +1 -0
- package/dist/utils/workflow.d.ts +62 -0
- package/dist/utils/workflow.d.ts.map +1 -0
- package/dist/utils/workflow.js +712 -0
- package/dist/utils/workflow.js.map +1 -0
- package/package.json +87 -0
- package/src/actions/index.ts +1 -0
- package/src/actions/workflow.ts +494 -0
- package/src/data/defaultNodes.json +9887 -0
- package/src/data/schemaIndex.json +1 -0
- package/src/data/triggerSchemaIndex.json +1 -0
- package/src/db/index.ts +8 -0
- package/src/db/schema.ts +94 -0
- package/src/index.ts +179 -0
- package/src/lib/automations-builder.ts +679 -0
- package/src/lib/automations-types.ts +391 -0
- package/src/lib/index.ts +8 -0
- package/src/lib/legacy-task-migration.ts +143 -0
- package/src/lib/legacy-text-trigger-migration.ts +178 -0
- package/src/lib/workflow-clarification.ts +497 -0
- package/src/plugin-routes.ts +164 -0
- package/src/providers/activeWorkflows.ts +81 -0
- package/src/providers/index.ts +3 -0
- package/src/providers/pendingDraft.ts +55 -0
- package/src/providers/workflowStatus.ts +88 -0
- package/src/register-routes.ts +6 -0
- package/src/routes/_helpers.ts +27 -0
- package/src/routes/automations.ts +46 -0
- package/src/routes/embedded-webhooks.ts +64 -0
- package/src/routes/executions.ts +75 -0
- package/src/routes/index.ts +16 -0
- package/src/routes/nodes.ts +211 -0
- package/src/routes/validation.ts +51 -0
- package/src/routes/workflow-routes.ts +469 -0
- package/src/routes/workflows.ts +310 -0
- package/src/schemas/draftIntent.ts +21 -0
- package/src/schemas/feasibility.ts +8 -0
- package/src/schemas/index.ts +4 -0
- package/src/schemas/keywordExtraction.ts +11 -0
- package/src/schemas/workflowMatching.ts +29 -0
- package/src/services/embedded-workflow-service.ts +2224 -0
- package/src/services/index.ts +17 -0
- package/src/services/workflow-credential-store.ts +132 -0
- package/src/services/workflow-dispatch.ts +121 -0
- package/src/services/workflow-service.ts +839 -0
- package/src/trigger-routes.ts +714 -0
- package/src/types/index.ts +562 -0
- package/src/utils/catalog.ts +260 -0
- package/src/utils/clarification.ts +52 -0
- package/src/utils/context.ts +22 -0
- package/src/utils/credentialResolver.ts +234 -0
- package/src/utils/generation.ts +987 -0
- package/src/utils/host-capabilities.ts +81 -0
- package/src/utils/inferSyntheticOutputSchema.ts +163 -0
- package/src/utils/outputSchema.ts +372 -0
- package/src/utils/validateAndRepair.ts +610 -0
- package/src/utils/workflow-prompts/actionResponse.ts +16 -0
- package/src/utils/workflow-prompts/draftIntent.ts +22 -0
- package/src/utils/workflow-prompts/feasibilityCheck.ts +20 -0
- package/src/utils/workflow-prompts/fieldCorrection.ts +20 -0
- package/src/utils/workflow-prompts/index.ts +10 -0
- package/src/utils/workflow-prompts/keywordExtraction.ts +20 -0
- package/src/utils/workflow-prompts/parameterCorrection.ts +29 -0
- package/src/utils/workflow-prompts/workflowGeneration.ts +528 -0
- package/src/utils/workflow-prompts/workflowMatching.ts +22 -0
- package/src/utils/workflow.ts +895 -0
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
import type { EventPayload } from '@elizaos/core';
|
|
2
|
+
import type {
|
|
3
|
+
INode,
|
|
4
|
+
INodeCredentialsDetails,
|
|
5
|
+
INodeProperties,
|
|
6
|
+
INodeTypeDescription,
|
|
7
|
+
IWorkflowSettings,
|
|
8
|
+
} from '@elizaos/workflows';
|
|
9
|
+
|
|
10
|
+
// Core workflow types
|
|
11
|
+
|
|
12
|
+
export interface WorkflowDefinition {
|
|
13
|
+
name: string;
|
|
14
|
+
nodes: WorkflowNode[];
|
|
15
|
+
connections: WorkflowConnections;
|
|
16
|
+
active?: boolean;
|
|
17
|
+
settings?: Partial<IWorkflowSettings>;
|
|
18
|
+
tags?: WorkflowTag[];
|
|
19
|
+
meta?: Record<string, unknown>;
|
|
20
|
+
id?: string;
|
|
21
|
+
createdAt?: string;
|
|
22
|
+
updatedAt?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Metadata generated by LLM (not sent to workflow API)
|
|
25
|
+
* Used internally for preview and clarification
|
|
26
|
+
*/
|
|
27
|
+
_meta?: WorkflowMeta;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Workflow metadata for internal use
|
|
32
|
+
* Generated by LLM, used for preview and clarification
|
|
33
|
+
* NOT sent to workflow API
|
|
34
|
+
*/
|
|
35
|
+
export interface WorkflowMeta {
|
|
36
|
+
assumptions?: string[];
|
|
37
|
+
suggestions?: string[];
|
|
38
|
+
/**
|
|
39
|
+
* Accepts either legacy free-text strings (one question per item) or
|
|
40
|
+
* structured ClarificationRequest objects. Hosts that consume this field
|
|
41
|
+
* should run it through `coerceClarificationRequests` to normalize.
|
|
42
|
+
*/
|
|
43
|
+
requiresClarification?: Array<string | ClarificationRequest>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A structured request for additional information from the user before
|
|
48
|
+
* a workflow can be deployed. Lets the host render a quick-pick UI and
|
|
49
|
+
* patch the draft at the named param path on resolution, instead of
|
|
50
|
+
* regenerating the workflow with the LLM.
|
|
51
|
+
*/
|
|
52
|
+
export interface ClarificationRequest {
|
|
53
|
+
/**
|
|
54
|
+
* Semantic category of the missing value. Determines how the host
|
|
55
|
+
* renders the picker (channel/server/recipient pickers vs. free text).
|
|
56
|
+
*/
|
|
57
|
+
kind: 'target_channel' | 'target_server' | 'recipient' | 'value' | 'free_text';
|
|
58
|
+
/**
|
|
59
|
+
* Connector platform this clarification belongs to (e.g. 'discord',
|
|
60
|
+
* 'slack', 'telegram', 'gmail'). Drives catalog source selection.
|
|
61
|
+
*/
|
|
62
|
+
platform?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Narrowing scope for catalog lookups. For Discord channel pickers,
|
|
65
|
+
* `scope.guildId` constrains the channel list to a single guild.
|
|
66
|
+
*/
|
|
67
|
+
scope?: { guildId?: string };
|
|
68
|
+
/**
|
|
69
|
+
* Short, user-facing question rendered above the picker.
|
|
70
|
+
*/
|
|
71
|
+
question: string;
|
|
72
|
+
/**
|
|
73
|
+
* JSON-style path into the draft workflow that points at the parameter
|
|
74
|
+
* the user's choice should populate. Supports dot and bracketed-string
|
|
75
|
+
* segments, e.g. `nodes["Discord Send"].parameters.channelId`.
|
|
76
|
+
*/
|
|
77
|
+
paramPath: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface WorkflowNode
|
|
81
|
+
extends Omit<INode, 'id' | 'parameters' | 'credentials' | 'position'> {
|
|
82
|
+
id?: string;
|
|
83
|
+
position: [number, number];
|
|
84
|
+
parameters: Record<string, unknown>;
|
|
85
|
+
credentials?: Record<string, WorkflowCredentialReference>;
|
|
86
|
+
color?: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface WorkflowCredentialReference extends Omit<INodeCredentialsDetails, 'id'> {
|
|
90
|
+
id: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface WorkflowConnections {
|
|
94
|
+
[nodeName: string]: {
|
|
95
|
+
[outputType: string]: Array<
|
|
96
|
+
Array<{
|
|
97
|
+
node: string;
|
|
98
|
+
type: string;
|
|
99
|
+
index: number;
|
|
100
|
+
}>
|
|
101
|
+
>;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// workflow API response types
|
|
106
|
+
|
|
107
|
+
export interface WorkflowDefinitionResponse extends WorkflowDefinition {
|
|
108
|
+
id: string;
|
|
109
|
+
createdAt: string;
|
|
110
|
+
updatedAt: string;
|
|
111
|
+
versionId: string;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface WorkflowCredential {
|
|
115
|
+
id: string;
|
|
116
|
+
name: string;
|
|
117
|
+
type: string;
|
|
118
|
+
data?: Record<string, unknown>;
|
|
119
|
+
isResolvable?: boolean;
|
|
120
|
+
createdAt: string;
|
|
121
|
+
updatedAt: string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export interface WorkflowExecution {
|
|
125
|
+
id: string;
|
|
126
|
+
finished: boolean;
|
|
127
|
+
mode:
|
|
128
|
+
| 'cli'
|
|
129
|
+
| 'error'
|
|
130
|
+
| 'integrated'
|
|
131
|
+
| 'internal'
|
|
132
|
+
| 'manual'
|
|
133
|
+
| 'retry'
|
|
134
|
+
| 'trigger'
|
|
135
|
+
| 'webhook'
|
|
136
|
+
| 'evaluation'
|
|
137
|
+
| 'chat';
|
|
138
|
+
retryOf?: string | null;
|
|
139
|
+
retrySuccessId?: string | null;
|
|
140
|
+
startedAt: string;
|
|
141
|
+
stoppedAt?: string | null;
|
|
142
|
+
workflowId: string;
|
|
143
|
+
status: 'canceled' | 'crashed' | 'error' | 'new' | 'running' | 'success' | 'unknown' | 'waiting';
|
|
144
|
+
waitTill?: string | null;
|
|
145
|
+
customData?: Record<string, unknown>;
|
|
146
|
+
data?: {
|
|
147
|
+
resultData?: {
|
|
148
|
+
runData?: Record<string, unknown[]>;
|
|
149
|
+
lastNodeExecuted?: string;
|
|
150
|
+
error?: {
|
|
151
|
+
message: string;
|
|
152
|
+
stack?: string;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
executionData?: {
|
|
156
|
+
contextData?: Record<string, unknown>;
|
|
157
|
+
nodeExecutionStack?: unknown[];
|
|
158
|
+
waitingExecution?: Record<string, unknown>;
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface WorkflowTag {
|
|
164
|
+
id: string;
|
|
165
|
+
name: string;
|
|
166
|
+
createdAt: string;
|
|
167
|
+
updatedAt: string;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Node catalog types (from workflows-intelligence)
|
|
171
|
+
|
|
172
|
+
export interface NodeDefinition
|
|
173
|
+
extends Omit<
|
|
174
|
+
INodeTypeDescription,
|
|
175
|
+
| 'credentials'
|
|
176
|
+
| 'group'
|
|
177
|
+
| 'icon'
|
|
178
|
+
| 'iconUrl'
|
|
179
|
+
| 'inputs'
|
|
180
|
+
| 'outputs'
|
|
181
|
+
| 'polling'
|
|
182
|
+
| 'properties'
|
|
183
|
+
| 'triggerPanel'
|
|
184
|
+
| 'webhooks'
|
|
185
|
+
> {
|
|
186
|
+
icon?: string;
|
|
187
|
+
iconUrl?: string;
|
|
188
|
+
group: string[];
|
|
189
|
+
defaults: {
|
|
190
|
+
name: string;
|
|
191
|
+
color?: string;
|
|
192
|
+
};
|
|
193
|
+
inputs: string[] | string;
|
|
194
|
+
outputs: string[] | string;
|
|
195
|
+
credentials?: Array<{
|
|
196
|
+
name: string;
|
|
197
|
+
required: boolean;
|
|
198
|
+
displayOptions?: unknown;
|
|
199
|
+
}>;
|
|
200
|
+
properties: NodeProperty[];
|
|
201
|
+
webhooks?: Array<Record<string, unknown>>;
|
|
202
|
+
polling?: boolean;
|
|
203
|
+
triggerPanel?: unknown;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export interface NodePropertyOption {
|
|
207
|
+
name: string;
|
|
208
|
+
value?: string | number | boolean;
|
|
209
|
+
displayName?: string;
|
|
210
|
+
description?: string;
|
|
211
|
+
[key: string]: unknown;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface NodePropertyCollection {
|
|
215
|
+
name: string;
|
|
216
|
+
displayName?: string;
|
|
217
|
+
values: NodeProperty[];
|
|
218
|
+
[key: string]: unknown;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export interface NodeProperty
|
|
222
|
+
extends Omit<INodeProperties, 'default' | 'displayOptions' | 'options' | 'routing' | 'type'> {
|
|
223
|
+
type: string;
|
|
224
|
+
default: unknown;
|
|
225
|
+
options?: Array<NodePropertyOption | NodePropertyCollection>;
|
|
226
|
+
displayOptions?: unknown;
|
|
227
|
+
placeholder?: string;
|
|
228
|
+
hint?: string;
|
|
229
|
+
routing?: unknown;
|
|
230
|
+
[key: string]: unknown;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export interface NodeSearchResult {
|
|
234
|
+
node: NodeDefinition;
|
|
235
|
+
score: number;
|
|
236
|
+
matchReason: string;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export interface IntegrationFilterResult {
|
|
240
|
+
remaining: NodeSearchResult[];
|
|
241
|
+
removed: NodeSearchResult[];
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Workflow generation types
|
|
245
|
+
|
|
246
|
+
export interface KeywordExtractionResult {
|
|
247
|
+
keywords: string[];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Result of semantic workflow matching
|
|
252
|
+
*/
|
|
253
|
+
export interface WorkflowMatchResult {
|
|
254
|
+
matchedWorkflowId: string | null;
|
|
255
|
+
confidence: 'high' | 'medium' | 'low' | 'none';
|
|
256
|
+
matches: Array<{
|
|
257
|
+
id: string;
|
|
258
|
+
name: string;
|
|
259
|
+
score: number;
|
|
260
|
+
}>;
|
|
261
|
+
reason: string;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export interface WorkflowValidationResult {
|
|
265
|
+
valid: boolean;
|
|
266
|
+
errors: string[];
|
|
267
|
+
warnings: string[];
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Credential provider types
|
|
271
|
+
|
|
272
|
+
export const WORKFLOW_CREDENTIAL_PROVIDER_TYPE = 'workflow_credential_provider';
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Result of a credential resolution attempt by an external provider.
|
|
276
|
+
*/
|
|
277
|
+
export type CredentialProviderResult =
|
|
278
|
+
| { status: 'credential_data'; data: Record<string, unknown> }
|
|
279
|
+
| { status: 'needs_auth'; authUrl: string }
|
|
280
|
+
| null;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* External credential provider interface.
|
|
284
|
+
*
|
|
285
|
+
* Hosts (e.g. eliza-cloud) can register a service implementing this interface
|
|
286
|
+
* to automatically resolve credentials (via OAuth, API keys, etc.).
|
|
287
|
+
* The plugin works without one — it's an optional enhancement.
|
|
288
|
+
*
|
|
289
|
+
* Register on runtime as service type 'workflow_credential_provider'.
|
|
290
|
+
*/
|
|
291
|
+
export interface CredentialProvider {
|
|
292
|
+
resolve(userId: string, credType: string): Promise<CredentialProviderResult>;
|
|
293
|
+
checkCredentialTypes?(credTypes: string[]): CheckCredentialTypesResult;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export interface CheckCredentialTypesResult {
|
|
297
|
+
supported: string[];
|
|
298
|
+
unsupported: string[];
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export interface FeasibilityResult {
|
|
302
|
+
feasible: boolean;
|
|
303
|
+
reason: string;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Type guard to check if a service implements CredentialProvider
|
|
308
|
+
*/
|
|
309
|
+
export function isCredentialProvider(service: unknown): service is CredentialProvider {
|
|
310
|
+
if (!service || typeof service !== 'object') {
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
return typeof (service as Record<string, unknown>).resolve === 'function';
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Runtime context provider types
|
|
317
|
+
|
|
318
|
+
export const WORKFLOW_RUNTIME_CONTEXT_PROVIDER_TYPE = 'workflow_runtime_context_provider';
|
|
319
|
+
|
|
320
|
+
export interface RuntimeContextSupportedCredential {
|
|
321
|
+
credType: string;
|
|
322
|
+
friendlyName: string;
|
|
323
|
+
nodeTypes: string[];
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Optional runtime-supplied context the host injects into the workflow-generation
|
|
328
|
+
* prompt. The plugin treats this as advisory information for the LLM:
|
|
329
|
+
* - `supportedCredentials` becomes a "## Available Credentials" section so the
|
|
330
|
+
* LLM only references credential types the host can actually resolve.
|
|
331
|
+
* - `facts` becomes a "## Runtime Facts" section with real values (Discord
|
|
332
|
+
* guilds/channels, the user's Gmail email, etc.) so the LLM substitutes
|
|
333
|
+
* them verbatim instead of emitting `{{YOUR_…}}` placeholders.
|
|
334
|
+
*
|
|
335
|
+
* The plugin works without a provider — both sections are simply omitted.
|
|
336
|
+
*/
|
|
337
|
+
export interface RuntimeContext {
|
|
338
|
+
/**
|
|
339
|
+
* Optional. When omitted (or empty), the generation prompt simply
|
|
340
|
+
* skips the "## Available Credentials" section. Implementers can
|
|
341
|
+
* return only what they have without fabricating empty arrays.
|
|
342
|
+
*/
|
|
343
|
+
supportedCredentials?: RuntimeContextSupportedCredential[];
|
|
344
|
+
/**
|
|
345
|
+
* Optional. When omitted (or empty), the generation prompt simply
|
|
346
|
+
* skips the "## Runtime Facts" section.
|
|
347
|
+
*/
|
|
348
|
+
facts?: string[];
|
|
349
|
+
/**
|
|
350
|
+
* Optional bias hint for keyword extraction. Lowercase provider tags the
|
|
351
|
+
* host knows it can satisfy (e.g. `["gmail", "discord"]`). When present,
|
|
352
|
+
* keyword extraction nudges the LLM toward these providers and away from
|
|
353
|
+
* generic fallbacks (e.g. emit `gmail` not `imap`, `discord` not
|
|
354
|
+
* `webhook`). Always optional — older hosts that omit it keep working.
|
|
355
|
+
*/
|
|
356
|
+
preferredProviders?: string[];
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Originating-conversation routing context. Hosts pass this when the workflow
|
|
361
|
+
* is being generated from inside a platform conversation (e.g. a Discord DM),
|
|
362
|
+
* so the LLM can target "this channel" / "back to me" without the user having
|
|
363
|
+
* to name an ID. The host typically derives it from the inbound message's
|
|
364
|
+
* `MessageMetadata` and surfaces it as a fact line ("This workflow was
|
|
365
|
+
* prompted from Discord channel #foo (id 123) in Bar (id 456)…").
|
|
366
|
+
*
|
|
367
|
+
* All fields are optional. Hosts only fill the platform block that matches
|
|
368
|
+
* the trigger source. `resolvedNames` lets the host pass human names for the
|
|
369
|
+
* channel / server (when available) so the prompt can reference them in
|
|
370
|
+
* natural language.
|
|
371
|
+
*/
|
|
372
|
+
export interface TriggerContext {
|
|
373
|
+
/** Source platform — `"discord" | "telegram" | "slack" | "gmail" | …` */
|
|
374
|
+
source?: string;
|
|
375
|
+
discord?: { channelId?: string; guildId?: string; threadId?: string };
|
|
376
|
+
telegram?: { chatId?: string | number; threadId?: string | number };
|
|
377
|
+
slack?: { channelId?: string; teamId?: string };
|
|
378
|
+
resolvedNames?: { channel?: string; server?: string };
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export interface RuntimeContextProviderInput {
|
|
382
|
+
userId: string;
|
|
383
|
+
relevantNodes: NodeDefinition[];
|
|
384
|
+
relevantCredTypes: string[];
|
|
385
|
+
/**
|
|
386
|
+
* Optional originating-conversation context. Forward-compatible: hosts that
|
|
387
|
+
* don't know about it simply omit the field.
|
|
388
|
+
*/
|
|
389
|
+
triggerContext?: TriggerContext;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
export interface RuntimeContextProvider {
|
|
393
|
+
getRuntimeContext(input: RuntimeContextProviderInput): Promise<RuntimeContext>;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Type guard to check if a service implements RuntimeContextProvider.
|
|
398
|
+
*/
|
|
399
|
+
export function isRuntimeContextProvider(service: unknown): service is RuntimeContextProvider {
|
|
400
|
+
if (!service || typeof service !== 'object') {
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
return typeof (service as Record<string, unknown>).getRuntimeContext === 'function';
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// Credential store types
|
|
407
|
+
|
|
408
|
+
export const WORKFLOW_CREDENTIAL_STORE_TYPE = 'workflow_credential_store';
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Runtime event emitted by the host (e.g. agent connector routes) when a
|
|
412
|
+
* connector is disconnected. WorkflowCredentialStore subscribes to this in
|
|
413
|
+
* `start()` and purges its cached credential ids for the supplied credTypes,
|
|
414
|
+
* so the next workflow generation surfaces `needs_auth` instead of returning
|
|
415
|
+
* a stale id.
|
|
416
|
+
*
|
|
417
|
+
* Payload shape kept minimal and serializable so any host can emit without
|
|
418
|
+
* pulling in plugin-workflow types — `userId` + `credTypes` is enough for
|
|
419
|
+
* the store to do its job. `connectorName` is informational for subscribers
|
|
420
|
+
* that want richer context.
|
|
421
|
+
*/
|
|
422
|
+
export const CONNECTOR_DISCONNECTED_EVENT = 'connector_disconnected';
|
|
423
|
+
|
|
424
|
+
export interface ConnectorDisconnectedPayload extends EventPayload {
|
|
425
|
+
/** Owner of the credentials to purge — typically `runtime.agentId`. */
|
|
426
|
+
userId: string;
|
|
427
|
+
/**
|
|
428
|
+
* Workflow credential type ids tied to the disconnected connector
|
|
429
|
+
* (e.g. `['gmailOAuth2', 'gmailOAuth2Api']`). Empty list ⇒ no-op.
|
|
430
|
+
*/
|
|
431
|
+
credTypes: readonly string[];
|
|
432
|
+
/** Connector name (e.g. `'gmail'`). Informational. */
|
|
433
|
+
connectorName?: string;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export interface CredentialMapping {
|
|
437
|
+
credType: string;
|
|
438
|
+
workflowCredentialId: string;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
export interface WorkflowCredentialStoreApi {
|
|
442
|
+
get(userId: string, credType: string): Promise<string | null>;
|
|
443
|
+
set(userId: string, credType: string, workflowCredId: string): Promise<void>;
|
|
444
|
+
listByUser(userId: string): Promise<CredentialMapping[]>;
|
|
445
|
+
/**
|
|
446
|
+
* Forget the cached workflows credential id for (userId, credType). The next
|
|
447
|
+
* resolution falls back to credProvider so a disconnect-then-prompt flow
|
|
448
|
+
* surfaces `needs_auth` instead of reusing stale credentials.
|
|
449
|
+
*
|
|
450
|
+
* Optional: external/custom credential-store implementations that pre-date
|
|
451
|
+
* this method continue to satisfy the interface; hosts that need to cascade
|
|
452
|
+
* a disconnect must check for the method (`store.delete?.(userId, credType)`)
|
|
453
|
+
* before calling.
|
|
454
|
+
*/
|
|
455
|
+
delete?(userId: string, credType: string): Promise<void>;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// Credential resolution types
|
|
459
|
+
|
|
460
|
+
export interface CredentialResolutionResult {
|
|
461
|
+
workflow: WorkflowDefinition;
|
|
462
|
+
missingConnections: MissingConnection[];
|
|
463
|
+
injectedCredentials: Map<string, string>; // credType -> workflowCredId
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
export interface MissingConnection {
|
|
467
|
+
credType: string;
|
|
468
|
+
authUrl?: string;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// Plugin configuration types
|
|
472
|
+
|
|
473
|
+
export interface WorkflowPluginConfig {
|
|
474
|
+
apiKey: string;
|
|
475
|
+
host: string;
|
|
476
|
+
credentials?: Record<string, string>; // credType -> workflowCredId (for local pre-configured mode)
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// Draft/preview/confirm types
|
|
480
|
+
|
|
481
|
+
export interface WorkflowDraft {
|
|
482
|
+
workflow: WorkflowDefinition;
|
|
483
|
+
prompt: string;
|
|
484
|
+
userId: string;
|
|
485
|
+
createdAt: number;
|
|
486
|
+
/** ID of the message that created this draft — used to prevent same-turn auto-confirm. */
|
|
487
|
+
originMessageId?: string;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
export interface DraftIntentResult {
|
|
491
|
+
intent: 'confirm' | 'cancel' | 'modify' | 'new' | 'show_preview';
|
|
492
|
+
modificationRequest?: string;
|
|
493
|
+
reason: string;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
export interface WorkflowCreationResult {
|
|
497
|
+
id: string;
|
|
498
|
+
name: string;
|
|
499
|
+
active: boolean;
|
|
500
|
+
nodeCount: number;
|
|
501
|
+
missingCredentials: MissingConnection[];
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
// Error types
|
|
505
|
+
|
|
506
|
+
export class WorkflowApiError extends Error {
|
|
507
|
+
constructor(
|
|
508
|
+
message: string,
|
|
509
|
+
public statusCode?: number,
|
|
510
|
+
public response?: unknown
|
|
511
|
+
) {
|
|
512
|
+
super(message);
|
|
513
|
+
this.name = 'WorkflowApiError';
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
export class UnsupportedIntegrationError extends Error {
|
|
518
|
+
constructor(
|
|
519
|
+
public unsupportedServices: string[],
|
|
520
|
+
public availableServices: string[]
|
|
521
|
+
) {
|
|
522
|
+
super(`Unsupported integrations: ${unsupportedServices.join(', ')}`);
|
|
523
|
+
this.name = 'UnsupportedIntegrationError';
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// Output schema validation types
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* JSON schema content from workflows output schemas
|
|
531
|
+
*/
|
|
532
|
+
export interface SchemaContent {
|
|
533
|
+
type: string;
|
|
534
|
+
properties?: Record<string, unknown>;
|
|
535
|
+
items?: SchemaContent;
|
|
536
|
+
[key: string]: unknown;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Expression reference found in node parameters
|
|
541
|
+
*/
|
|
542
|
+
export interface ExpressionRef {
|
|
543
|
+
fullExpression: string; // "{{ $json.sender }}"
|
|
544
|
+
field: string; // "sender" or "from.value[0].address"
|
|
545
|
+
path: string[]; // ["sender"] or ["from", "value", "0", "address"]
|
|
546
|
+
paramPath: string; // Parameter path where expression was found
|
|
547
|
+
sourceNodeName?: string; // Node name from $('NodeName') syntax, undefined for $json refs
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Invalid output reference detected during validation
|
|
552
|
+
*/
|
|
553
|
+
export interface OutputRefValidation {
|
|
554
|
+
nodeName: string; // Node with invalid reference
|
|
555
|
+
expression: string; // The full expression
|
|
556
|
+
field: string; // Referenced field
|
|
557
|
+
sourceNodeName: string; // Upstream node
|
|
558
|
+
sourceNodeType: string; // Upstream node type
|
|
559
|
+
resource: string; // Resource parameter
|
|
560
|
+
operation: string; // Operation parameter
|
|
561
|
+
availableFields: string[]; // Valid fields from schema
|
|
562
|
+
}
|