@n8n/instance-ai 1.12.3 → 1.13.0
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/dist/agent/apply-agent-thinking.d.ts +2 -0
- package/dist/agent/apply-agent-thinking.js +41 -0
- package/dist/agent/apply-agent-thinking.js.map +1 -0
- package/dist/agent/instance-agent.js +10 -2
- package/dist/agent/instance-agent.js.map +1 -1
- package/dist/agent/sanitize-mcp-schemas.js +133 -125
- package/dist/agent/sanitize-mcp-schemas.js.map +1 -1
- package/dist/agent/shared-prompts.d.ts +0 -1
- package/dist/agent/shared-prompts.js +4 -11
- package/dist/agent/shared-prompts.js.map +1 -1
- package/dist/agent/sub-agent-debriefing.d.ts +4 -4
- package/dist/agent/system-prompt.js +3 -10
- package/dist/agent/system-prompt.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/debug/run-debug-buffer.d.ts +63 -0
- package/dist/debug/run-debug-buffer.js +177 -0
- package/dist/debug/run-debug-buffer.js.map +1 -0
- package/dist/debug/sanitize-debug-snapshot.d.ts +2 -0
- package/dist/debug/sanitize-debug-snapshot.js +88 -0
- package/dist/debug/sanitize-debug-snapshot.js.map +1 -0
- package/dist/error-formatting.js +3 -5
- package/dist/error-formatting.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/knowledge-base/build-templates-index.d.ts +1 -0
- package/dist/knowledge-base/build-templates-index.js +18 -2
- package/dist/knowledge-base/build-templates-index.js.map +1 -1
- package/dist/knowledge-base/materialize-knowledge-base.d.ts +2 -3
- package/dist/knowledge-base/materialize-knowledge-base.js +10 -7
- package/dist/knowledge-base/materialize-knowledge-base.js.map +1 -1
- package/dist/mcp/mcp-client-manager.d.ts +1 -1
- package/dist/mcp/mcp-client-manager.js +13 -9
- package/dist/mcp/mcp-client-manager.js.map +1 -1
- package/dist/runtime/memory-task-registry.d.ts +8 -0
- package/dist/runtime/memory-task-registry.js +42 -0
- package/dist/runtime/memory-task-registry.js.map +1 -0
- package/dist/runtime/resumable-stream-executor.d.ts +3 -0
- package/dist/runtime/resumable-stream-executor.js +171 -90
- package/dist/runtime/resumable-stream-executor.js.map +1 -1
- package/dist/runtime/run-state-registry.d.ts +2 -0
- package/dist/runtime/run-state-registry.js +3 -0
- package/dist/runtime/run-state-registry.js.map +1 -1
- package/dist/runtime/stream-runner.d.ts +3 -0
- package/dist/runtime/stream-runner.js +3 -0
- package/dist/runtime/stream-runner.js.map +1 -1
- package/dist/skills/materialize-runtime-skills.d.ts +3 -3
- package/dist/skills/materialize-runtime-skills.js +1 -1
- package/dist/skills/materialize-runtime-skills.js.map +1 -1
- package/dist/source-map-filter.js +0 -1
- package/dist/source-map-filter.js.map +1 -1
- package/dist/storage/terminal-outcome-storage.d.ts +2 -2
- package/dist/storage/workflow-loop-storage.d.ts +75 -4
- package/dist/stream/map-chunk.js +198 -237
- package/dist/stream/map-chunk.js.map +1 -1
- package/dist/stream/output-redaction.js +2 -2
- package/dist/stream/output-redaction.js.map +1 -1
- package/dist/stream/usage-accumulator.d.ts +90 -0
- package/dist/stream/usage-accumulator.js +89 -0
- package/dist/stream/usage-accumulator.js.map +1 -0
- package/dist/stream/work-summary-accumulator.d.ts +6 -6
- package/dist/tools/attachments/parse-file.tool.js +1 -1
- package/dist/tools/attachments/parse-file.tool.js.map +1 -1
- package/dist/tools/credentials.tool.js +4 -1
- package/dist/tools/credentials.tool.js.map +1 -1
- package/dist/tools/data-tables.tool.js +5 -2
- package/dist/tools/data-tables.tool.js.map +1 -1
- package/dist/tools/evals/column-ref-utils.d.ts +1 -2
- package/dist/tools/evals/column-ref-utils.js +19 -18
- package/dist/tools/evals/column-ref-utils.js.map +1 -1
- package/dist/tools/evals/describe-metric-for-workflow.service.js +7 -25
- package/dist/tools/evals/describe-metric-for-workflow.service.js.map +1 -1
- package/dist/tools/evals/detect-tool-refs.service.js +2 -1
- package/dist/tools/evals/detect-tool-refs.service.js.map +1 -1
- package/dist/tools/evals/eval-data-requirements.service.js +10 -9
- package/dist/tools/evals/eval-data-requirements.service.js.map +1 -1
- package/dist/tools/evals/evals.tool.js +2 -2
- package/dist/tools/evals/evals.tool.js.map +1 -1
- package/dist/tools/evals/extract-rows-from-history.service.js +8 -8
- package/dist/tools/evals/extract-rows-from-history.service.js.map +1 -1
- package/dist/tools/evals/generate-sample-rows.service.d.ts +2 -2
- package/dist/tools/evals/generate-sample-rows.service.js +30 -49
- package/dist/tools/evals/generate-sample-rows.service.js.map +1 -1
- package/dist/tools/evals/generate-tool-ref-pin-data.service.js +10 -23
- package/dist/tools/evals/generate-tool-ref-pin-data.service.js.map +1 -1
- package/dist/tools/evals/metric-catalog.js +3 -3
- package/dist/tools/evals/metric-catalog.js.map +1 -1
- package/dist/tools/executions.tool.js +10 -2
- package/dist/tools/executions.tool.js.map +1 -1
- package/dist/tools/filesystem/create-tools-from-mcp-server.d.ts +1 -1
- package/dist/tools/filesystem/create-tools-from-mcp-server.js +8 -10
- package/dist/tools/filesystem/create-tools-from-mcp-server.js.map +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/nodes/node-search-engine.js +21 -42
- package/dist/tools/nodes/node-search-engine.js.map +1 -1
- package/dist/tools/nodes/node-search-engine.types.d.ts +2 -0
- package/dist/tools/nodes/preferred-chat-model.d.ts +1 -0
- package/dist/tools/nodes/preferred-chat-model.js +19 -0
- package/dist/tools/nodes/preferred-chat-model.js.map +1 -0
- package/dist/tools/nodes/suggested-nodes-data.js +13 -3
- package/dist/tools/nodes/suggested-nodes-data.js.map +1 -1
- package/dist/tools/nodes.tool.js +32 -7
- package/dist/tools/nodes.tool.js.map +1 -1
- package/dist/tools/orchestration/complete-checkpoint.tool.js +3 -5
- package/dist/tools/orchestration/complete-checkpoint.tool.js.map +1 -1
- package/dist/tools/orchestration/eval-data-agent.tool.js +2 -1
- package/dist/tools/orchestration/eval-data-agent.tool.js.map +1 -1
- package/dist/tools/orchestration/eval-setup-agent.prompt.d.ts +1 -1
- package/dist/tools/orchestration/eval-setup-agent.prompt.js +3 -3
- package/dist/tools/orchestration/report-verification-verdict.tool.d.ts +2 -2
- package/dist/tools/orchestration/report-verification-verdict.tool.js +1 -1
- package/dist/tools/orchestration/report-verification-verdict.tool.js.map +1 -1
- package/dist/tools/orchestration/verify-built-workflow.tool.js +320 -307
- package/dist/tools/orchestration/verify-built-workflow.tool.js.map +1 -1
- package/dist/tools/research.tool.js +1 -1
- package/dist/tools/research.tool.js.map +1 -1
- package/dist/tools/shared/ask-user.tool.d.ts +4 -4
- package/dist/tools/shared/ask-user.tool.js +6 -1
- package/dist/tools/shared/ask-user.tool.js.map +1 -1
- package/dist/tools/tool-ids.d.ts +0 -1
- package/dist/tools/tool-ids.js +0 -1
- package/dist/tools/tool-ids.js.map +1 -1
- package/dist/tools/workflows/build-workflow.tool.d.ts +4 -22
- package/dist/tools/workflows/build-workflow.tool.js +373 -317
- package/dist/tools/workflows/build-workflow.tool.js.map +1 -1
- package/dist/tools/workflows/classify-node-destructiveness.service.d.ts +7 -0
- package/dist/tools/workflows/classify-node-destructiveness.service.js +307 -0
- package/dist/tools/workflows/classify-node-destructiveness.service.js.map +1 -0
- package/dist/tools/workflows/generate-simulation-fixtures.service.d.ts +8 -0
- package/dist/tools/workflows/generate-simulation-fixtures.service.js +95 -0
- package/dist/tools/workflows/generate-simulation-fixtures.service.js.map +1 -0
- package/dist/tools/workflows/plan-verification-simulation.d.ts +15 -0
- package/dist/tools/workflows/plan-verification-simulation.js +32 -0
- package/dist/tools/workflows/plan-verification-simulation.js.map +1 -0
- package/dist/tools/workflows/resolve-credentials.d.ts +0 -2
- package/dist/tools/workflows/resolve-credentials.js +0 -13
- package/dist/tools/workflows/resolve-credentials.js.map +1 -1
- package/dist/tools/workflows/setup-workflow.service.js +259 -215
- package/dist/tools/workflows/setup-workflow.service.js.map +1 -1
- package/dist/tools/workflows/validate-workflow.service.js +81 -66
- package/dist/tools/workflows/validate-workflow.service.js.map +1 -1
- package/dist/tools/workflows/workflow-build-context.d.ts +33 -0
- package/dist/tools/workflows/workflow-build-context.js +80 -0
- package/dist/tools/workflows/workflow-build-context.js.map +1 -0
- package/dist/tools/workflows/workflow-build-remediation.d.ts +11 -0
- package/dist/tools/workflows/workflow-build-remediation.js +89 -0
- package/dist/tools/workflows/workflow-build-remediation.js.map +1 -0
- package/dist/tools/workflows/workflow-build-reporting.d.ts +19 -0
- package/dist/tools/workflows/workflow-build-reporting.js +78 -0
- package/dist/tools/workflows/workflow-build-reporting.js.map +1 -0
- package/dist/tools/workflows/workflow-build-routing.d.ts +2 -0
- package/dist/tools/workflows/workflow-build-routing.js +83 -0
- package/dist/tools/workflows/workflow-build-routing.js.map +1 -0
- package/dist/tools/workflows/workflow-build-telemetry.d.ts +18 -0
- package/dist/tools/workflows/workflow-build-telemetry.js +33 -0
- package/dist/tools/workflows/workflow-build-telemetry.js.map +1 -0
- package/dist/tools/workflows/workflow-file-bindings.d.ts +28 -0
- package/dist/tools/workflows/workflow-file-bindings.js +104 -0
- package/dist/tools/workflows/workflow-file-bindings.js.map +1 -0
- package/dist/tools/workflows/workflow-json-utils.d.ts +3 -0
- package/dist/tools/workflows/workflow-json-utils.js +54 -5
- package/dist/tools/workflows/workflow-json-utils.js.map +1 -1
- package/dist/tools/workflows/workflow-source-compiler.d.ts +19 -0
- package/dist/tools/workflows/workflow-source-compiler.js +217 -0
- package/dist/tools/workflows/workflow-source-compiler.js.map +1 -0
- package/dist/tools/workflows/workflow-validation-warnings.d.ts +14 -0
- package/dist/tools/workflows/workflow-validation-warnings.js +28 -0
- package/dist/tools/workflows/workflow-validation-warnings.js.map +1 -0
- package/dist/tools/workflows.tool.js +107 -99
- package/dist/tools/workflows.tool.js.map +1 -1
- package/dist/tracing/langsmith-tracing.js +7 -7
- package/dist/tracing/langsmith-tracing.js.map +1 -1
- package/dist/tracing/trace-payloads.d.ts +2 -1
- package/dist/tracing/trace-payloads.js +152 -114
- package/dist/tracing/trace-payloads.js.map +1 -1
- package/dist/types.d.ts +24 -4
- package/dist/types.js.map +1 -1
- package/dist/utils/eval-agents.d.ts +0 -3
- package/dist/utils/eval-agents.js +3 -11
- package/dist/utils/eval-agents.js.map +1 -1
- package/dist/utils/generate-validated-json.d.ts +16 -0
- package/dist/utils/generate-validated-json.js +38 -0
- package/dist/utils/generate-validated-json.js.map +1 -0
- package/dist/utils/stream-helpers.d.ts +0 -1
- package/dist/utils/stream-helpers.js +5 -8
- package/dist/utils/stream-helpers.js.map +1 -1
- package/dist/workflow-builder/build-failure-tracker.js +25 -1
- package/dist/workflow-builder/build-failure-tracker.js.map +1 -1
- package/dist/workflow-builder/index.d.ts +0 -4
- package/dist/workflow-builder/index.js +1 -11
- package/dist/workflow-builder/index.js.map +1 -1
- package/dist/workflow-loop/guidance.js +14 -15
- package/dist/workflow-loop/guidance.js.map +1 -1
- package/dist/workflow-loop/runtime.js +1 -0
- package/dist/workflow-loop/runtime.js.map +1 -1
- package/dist/workflow-loop/verification-obligation.js +8 -1
- package/dist/workflow-loop/verification-obligation.js.map +1 -1
- package/dist/workflow-loop/workflow-loop-controller.js +17 -1
- package/dist/workflow-loop/workflow-loop-controller.js.map +1 -1
- package/dist/workflow-loop/workflow-loop-state.d.ts +90 -6
- package/dist/workflow-loop/workflow-loop-state.js +13 -1
- package/dist/workflow-loop/workflow-loop-state.js.map +1 -1
- package/dist/workspace/builder-templates-service.d.ts +5 -5
- package/dist/workspace/builder-templates-service.js +17 -14
- package/dist/workspace/builder-templates-service.js.map +1 -1
- package/dist/workspace/create-workspace.js +8 -1
- package/dist/workspace/create-workspace.js.map +1 -1
- package/dist/workspace/prebaked-workspace-bundle.d.ts +2 -2
- package/dist/workspace/prebaked-workspace-bundle.js +5 -5
- package/dist/workspace/prebaked-workspace-bundle.js.map +1 -1
- package/dist/workspace/sandbox-setup.d.ts +1 -1
- package/dist/workspace/sandbox-setup.js +10 -37
- package/dist/workspace/sandbox-setup.js.map +1 -1
- package/dist/workspace/snapshot-manager.d.ts +1 -1
- package/dist/workspace/template-telemetry.js +2 -5
- package/dist/workspace/template-telemetry.js.map +1 -1
- package/dist/workspace/workspace-files.d.ts +1 -1
- package/dist/workspace/workspace-files.js +3 -3
- package/dist/workspace/workspace-files.js.map +1 -1
- package/dist/workspace/workspace-manifest.js +2 -2
- package/dist/workspace/workspace-manifest.js.map +1 -1
- package/dist/workspace/workspace-paths.d.ts +4 -0
- package/dist/workspace/workspace-paths.js +25 -0
- package/dist/workspace/workspace-paths.js.map +1 -0
- package/knowledge-base/reference/open-ai-output-shape.md +79 -0
- package/knowledge-base/reference/workflow-builder-guardrails.md +15 -0
- package/package.json +13 -12
- package/skills/planned-task-runtime/SKILL.md +3 -2
- package/skills/planning/SKILL.md +5 -0
- package/skills/post-build-flow/SKILL.md +25 -9
- package/skills/workflow-builder/SKILL.md +89 -134
- package/dist/tools/workflows/submit-workflow-identity.d.ts +0 -39
- package/dist/tools/workflows/submit-workflow-identity.js +0 -181
- package/dist/tools/workflows/submit-workflow-identity.js.map +0 -1
- package/dist/tools/workflows/submit-workflow.tool.d.ts +0 -223
- package/dist/tools/workflows/submit-workflow.tool.js +0 -491
- package/dist/tools/workflows/submit-workflow.tool.js.map +0 -1
- package/dist/workflow-builder/extract-code.d.ts +0 -5
- package/dist/workflow-builder/extract-code.js +0 -105
- package/dist/workflow-builder/extract-code.js.map +0 -1
- package/dist/workflow-builder/parse-validate.d.ts +0 -10
- package/dist/workflow-builder/parse-validate.js +0 -50
- package/dist/workflow-builder/parse-validate.js.map +0 -1
- package/dist/workflow-builder/patch-code.d.ts +0 -14
- package/dist/workflow-builder/patch-code.js +0 -117
- package/dist/workflow-builder/patch-code.js.map +0 -1
- package/dist/workflow-builder/types.d.ts +0 -11
- package/dist/workflow-builder/types.js +0 -3
- package/dist/workflow-builder/types.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-credentials.js","sourceRoot":"","sources":["../../../src/tools/workflows/resolve-credentials.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"resolve-credentials.js","sourceRoot":"","sources":["../../../src/tools/workflows/resolve-credentials.ts"],"names":[],"mappings":";;AA8BA,gDAeC;AAuBD,gDAqGC;AA3IM,KAAK,UAAU,kBAAkB,CACvC,iBAAuE;IAEvE,MAAM,GAAG,GAAkB,IAAI,GAAG,EAAE,CAAC;IACrC,IAAI,CAAC;QACJ,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,IAAI,EAAE,CAAC;QAChD,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;YAC7B,MAAM,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACzC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YAChE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7B,CAAC;IACF,CAAC;IAAC,MAAM,CAAC;IAET,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC;AAuBM,KAAK,UAAU,kBAAkB,CACvC,IAAkB,EAClB,UAA8B,EAC9B,GAAsB,EACtB,oBAAoC;IAEpC,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,MAAM,wBAAwB,GAAG,IAAI,GAAG,EAAU,CAAC;IACnD,MAAM,uBAAuB,GAA6B,EAAE,CAAC;IAG7D,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAmC,CAAC;IACvE,IAAI,UAAU,EAAE,CAAC;QAChB,IAAI,CAAC;YACJ,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,eAAe,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;YACzE,KAAK,MAAM,YAAY,IAAI,Q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
41
41
|
}
|
|
42
42
|
catch (error) {
|
|
43
|
-
context.logger
|
|
43
|
+
context.logger.warn('[setup-workflow] getNodeCredentialTypes threw during credential validation', {
|
|
44
44
|
nodeType: node.type,
|
|
45
45
|
typeVersion,
|
|
46
46
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -86,21 +86,7 @@ async function stripStaleCredentialsFromNode(context, node, preserveTypes) {
|
|
|
86
86
|
async function stripStaleCredentialsFromWorkflow(context, json) {
|
|
87
87
|
await Promise.all((json.nodes ?? []).map(async (node) => await stripStaleCredentialsFromNode(context, node)));
|
|
88
88
|
}
|
|
89
|
-
async function
|
|
90
|
-
if (!node.name)
|
|
91
|
-
return [];
|
|
92
|
-
if (node.disabled)
|
|
93
|
-
return [];
|
|
94
|
-
const typeVersion = node.typeVersion ?? 1;
|
|
95
|
-
const parameters = node.parameters ?? {};
|
|
96
|
-
const nodeDesc = await context.nodeService
|
|
97
|
-
.getDescription(node.type, typeVersion)
|
|
98
|
-
.catch(() => undefined);
|
|
99
|
-
const isTrigger = nodeDesc?.group?.includes('trigger') ?? false;
|
|
100
|
-
const isTestable = isTrigger &&
|
|
101
|
-
((nodeDesc?.webhooks !== undefined && nodeDesc.webhooks.length > 0) ||
|
|
102
|
-
nodeDesc?.polling === true ||
|
|
103
|
-
nodeDesc?.triggerPanel !== undefined);
|
|
89
|
+
async function computeParameterIssues(context, node, parameters, typeVersion) {
|
|
104
90
|
let parameterIssues = {};
|
|
105
91
|
if (context.nodeService.getParameterIssues) {
|
|
106
92
|
parameterIssues = await context.nodeService
|
|
@@ -119,27 +105,32 @@ async function buildSetupRequests(context, node, triggerTestResult, cache, workf
|
|
|
119
105
|
}
|
|
120
106
|
}
|
|
121
107
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
108
|
+
return parameterIssues;
|
|
109
|
+
}
|
|
110
|
+
function buildEditableParameters(parameterIssues, nodeDesc) {
|
|
111
|
+
if (Object.keys(parameterIssues).length === 0 || !nodeDesc?.properties)
|
|
112
|
+
return undefined;
|
|
113
|
+
const editableParameters = [];
|
|
114
|
+
for (const paramName of Object.keys(parameterIssues)) {
|
|
115
|
+
const prop = nodeDesc.properties.find((p) => p.name === paramName);
|
|
116
|
+
if (!prop)
|
|
117
|
+
continue;
|
|
118
|
+
editableParameters.push({
|
|
119
|
+
name: prop.name,
|
|
120
|
+
displayName: prop.displayName,
|
|
121
|
+
type: prop.type,
|
|
122
|
+
...(prop.required !== undefined ? { required: prop.required } : {}),
|
|
123
|
+
...(prop.default !== undefined ? { default: prop.default } : {}),
|
|
124
|
+
...(prop.options
|
|
125
|
+
? {
|
|
126
|
+
options: prop.options,
|
|
127
|
+
}
|
|
128
|
+
: {}),
|
|
129
|
+
});
|
|
142
130
|
}
|
|
131
|
+
return editableParameters;
|
|
132
|
+
}
|
|
133
|
+
async function resolveCredentialTypes(context, node, parameters, typeVersion, nodeDesc) {
|
|
143
134
|
let credentialTypes = [];
|
|
144
135
|
if (context.nodeService.getNodeCredentialTypes) {
|
|
145
136
|
credentialTypes = await context.nodeService
|
|
@@ -167,156 +158,202 @@ async function buildSetupRequests(context, node, triggerTestResult, cache, workf
|
|
|
167
158
|
credentialTypes = [parameters.nodeCredentialType];
|
|
168
159
|
}
|
|
169
160
|
}
|
|
161
|
+
return credentialTypes;
|
|
162
|
+
}
|
|
163
|
+
async function resolveCredentialState(context, node, credentialType, cache, workflowId) {
|
|
164
|
+
const cacheKey = listCacheKey(workflowId, credentialType);
|
|
165
|
+
let listPromise = cache?.lists.get(cacheKey);
|
|
166
|
+
if (!listPromise) {
|
|
167
|
+
listPromise = context.credentialService
|
|
168
|
+
.list({ type: credentialType, ...(workflowId ? { workflowId } : {}) })
|
|
169
|
+
.then((creds) => creds.map((c) => ({ id: c.id, name: c.name })));
|
|
170
|
+
cache?.lists.set(cacheKey, listPromise);
|
|
171
|
+
}
|
|
172
|
+
const sortedCreds = await listPromise;
|
|
173
|
+
const existingCredentials = sortedCreds.map((c) => ({ id: c.id, name: c.name }));
|
|
174
|
+
const existingOnNode = node.credentials?.[credentialType];
|
|
175
|
+
const isAutoApplied = !existingOnNode?.id && existingCredentials.length === 1;
|
|
176
|
+
const credToTest = existingOnNode?.id ?? (isAutoApplied ? existingCredentials[0]?.id : undefined);
|
|
177
|
+
if (!credToTest)
|
|
178
|
+
return { existingCredentials, isAutoApplied };
|
|
179
|
+
let testabilityPromise = cache?.testability.get(credentialType);
|
|
180
|
+
if (!testabilityPromise) {
|
|
181
|
+
testabilityPromise = context.credentialService.isTestable
|
|
182
|
+
? context.credentialService.isTestable(credentialType).catch(() => true)
|
|
183
|
+
: Promise.resolve(true);
|
|
184
|
+
cache?.testability.set(credentialType, testabilityPromise);
|
|
185
|
+
}
|
|
186
|
+
const canTest = await testabilityPromise;
|
|
187
|
+
if (!canTest)
|
|
188
|
+
return { existingCredentials, isAutoApplied };
|
|
189
|
+
let testPromise = cache?.tests.get(credToTest);
|
|
190
|
+
if (!testPromise) {
|
|
191
|
+
testPromise = context.credentialService.test(credToTest).catch((testError) => ({
|
|
192
|
+
success: false,
|
|
193
|
+
message: testError instanceof Error ? testError.message : 'Test failed',
|
|
194
|
+
}));
|
|
195
|
+
cache?.tests.set(credToTest, testPromise);
|
|
196
|
+
}
|
|
197
|
+
const credentialTestResult = await testPromise;
|
|
198
|
+
return { existingCredentials, isAutoApplied, credentialTestResult };
|
|
199
|
+
}
|
|
200
|
+
function buildRequestCredentials(nodeCredentials, isAutoApplied, credentialType, existingCredentials) {
|
|
201
|
+
const autoCredential = isAutoApplied && credentialType && existingCredentials.length > 0
|
|
202
|
+
? { [credentialType]: { id: existingCredentials[0].id, name: existingCredentials[0].name } }
|
|
203
|
+
: undefined;
|
|
204
|
+
if (nodeCredentials && Object.keys(nodeCredentials).length > 0) {
|
|
205
|
+
return {
|
|
206
|
+
credentials: (autoCredential
|
|
207
|
+
? { ...nodeCredentials, ...autoCredential }
|
|
208
|
+
: nodeCredentials),
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
return autoCredential ? { credentials: autoCredential } : {};
|
|
212
|
+
}
|
|
213
|
+
async function resolveAppliedCredentialState(context, node, credentialType, cache, workflowId, nodeCredentials) {
|
|
214
|
+
if (!credentialType) {
|
|
215
|
+
return { existingCredentials: [], isAutoApplied: false };
|
|
216
|
+
}
|
|
217
|
+
const state = await resolveCredentialState(context, node, credentialType, cache, workflowId);
|
|
218
|
+
if (state.isAutoApplied && nodeCredentials) {
|
|
219
|
+
nodeCredentials[credentialType] = {
|
|
220
|
+
id: state.existingCredentials[0].id,
|
|
221
|
+
name: state.existingCredentials[0].name,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
return state;
|
|
225
|
+
}
|
|
226
|
+
async function buildRequestForCredentialType(context, node, credentialType, cache, workflowId, nodeCtx) {
|
|
227
|
+
const nodeCredentials = node.credentials
|
|
228
|
+
? Object.fromEntries(Object.entries(node.credentials)
|
|
229
|
+
.filter(([, v]) => v.id !== undefined)
|
|
230
|
+
.map(([k, v]) => [k, { id: v.id, name: v.name }]))
|
|
231
|
+
: undefined;
|
|
232
|
+
const { existingCredentials, isAutoApplied, credentialTestResult } = await resolveAppliedCredentialState(context, node, credentialType, cache, workflowId, nodeCredentials);
|
|
233
|
+
const { isTrigger, isTestable, hasParamIssues } = nodeCtx;
|
|
234
|
+
if (!credentialType && !isTrigger && !hasParamIssues)
|
|
235
|
+
return null;
|
|
236
|
+
if (!credentialType && isTrigger && !isTestable && !hasParamIssues)
|
|
237
|
+
return null;
|
|
238
|
+
let needsAction = false;
|
|
239
|
+
if (credentialType) {
|
|
240
|
+
const existingOnNode = node.credentials?.[credentialType];
|
|
241
|
+
const hasValidCredential = existingOnNode?.id !== undefined &&
|
|
242
|
+
(credentialTestResult === undefined || credentialTestResult.success);
|
|
243
|
+
needsAction = !hasValidCredential;
|
|
244
|
+
}
|
|
245
|
+
if (hasParamIssues) {
|
|
246
|
+
needsAction = true;
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
node: {
|
|
250
|
+
name: nodeCtx.nodeName,
|
|
251
|
+
type: node.type,
|
|
252
|
+
typeVersion: nodeCtx.typeVersion,
|
|
253
|
+
parameters: nodeCtx.parameters,
|
|
254
|
+
position: nodeCtx.nodePosition,
|
|
255
|
+
id: nodeCtx.nodeId,
|
|
256
|
+
...buildRequestCredentials(nodeCredentials, isAutoApplied, credentialType, existingCredentials),
|
|
257
|
+
},
|
|
258
|
+
...(credentialType ? { credentialType } : {}),
|
|
259
|
+
...(existingCredentials.length > 0 ? { existingCredentials } : {}),
|
|
260
|
+
isTrigger,
|
|
261
|
+
...(isTestable ? { isTestable } : {}),
|
|
262
|
+
...(isAutoApplied ? { isAutoApplied } : {}),
|
|
263
|
+
...(credentialTestResult ? { credentialTestResult } : {}),
|
|
264
|
+
...(nodeCtx.triggerTestResult ? { triggerTestResult: nodeCtx.triggerTestResult } : {}),
|
|
265
|
+
...(hasParamIssues ? { parameterIssues: nodeCtx.parameterIssues } : {}),
|
|
266
|
+
...(nodeCtx.editableParameters && nodeCtx.editableParameters.length > 0
|
|
267
|
+
? { editableParameters: nodeCtx.editableParameters }
|
|
268
|
+
: {}),
|
|
269
|
+
needsAction,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
async function buildSetupRequests(context, node, triggerTestResult, cache, workflowId) {
|
|
273
|
+
if (!node.name)
|
|
274
|
+
return [];
|
|
275
|
+
if (node.disabled)
|
|
276
|
+
return [];
|
|
277
|
+
const typeVersion = node.typeVersion ?? 1;
|
|
278
|
+
const parameters = node.parameters ?? {};
|
|
279
|
+
const nodeDesc = await context.nodeService
|
|
280
|
+
.getDescription(node.type, typeVersion)
|
|
281
|
+
.catch(() => undefined);
|
|
282
|
+
const isTrigger = nodeDesc?.group?.includes('trigger') ?? false;
|
|
283
|
+
const isTestable = isTrigger &&
|
|
284
|
+
((nodeDesc?.webhooks !== undefined && nodeDesc.webhooks.length > 0) ||
|
|
285
|
+
nodeDesc?.polling === true ||
|
|
286
|
+
nodeDesc?.triggerPanel !== undefined);
|
|
287
|
+
const parameterIssues = await computeParameterIssues(context, node, parameters, typeVersion);
|
|
288
|
+
const editableParameters = buildEditableParameters(parameterIssues, nodeDesc);
|
|
289
|
+
const credentialTypes = await resolveCredentialTypes(context, node, parameters, typeVersion, nodeDesc);
|
|
170
290
|
const nodeId = node.id ?? (0, nanoid_1.nanoid)();
|
|
171
291
|
const nodePosition = node.position ?? [0, 0];
|
|
172
292
|
const hasParamIssues = Object.keys(parameterIssues).length > 0;
|
|
173
293
|
const requests = [];
|
|
174
294
|
const processedCredTypes = credentialTypes.length > 0 ? credentialTypes : [undefined];
|
|
295
|
+
const nodeCtx = {
|
|
296
|
+
nodeName: node.name,
|
|
297
|
+
isTrigger,
|
|
298
|
+
isTestable,
|
|
299
|
+
hasParamIssues,
|
|
300
|
+
parameterIssues,
|
|
301
|
+
editableParameters,
|
|
302
|
+
triggerTestResult,
|
|
303
|
+
nodeId,
|
|
304
|
+
nodePosition,
|
|
305
|
+
typeVersion,
|
|
306
|
+
parameters,
|
|
307
|
+
};
|
|
175
308
|
for (const credentialType of processedCredTypes) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
const credToTest = existingOnNode?.id ?? (isAutoApplied ? existingCredentials[0]?.id : undefined);
|
|
206
|
-
if (credToTest) {
|
|
207
|
-
let testabilityPromise = cache?.testability.get(credentialType);
|
|
208
|
-
if (!testabilityPromise) {
|
|
209
|
-
testabilityPromise = context.credentialService.isTestable
|
|
210
|
-
? context.credentialService.isTestable(credentialType).catch(() => true)
|
|
211
|
-
: Promise.resolve(true);
|
|
212
|
-
cache?.testability.set(credentialType, testabilityPromise);
|
|
213
|
-
}
|
|
214
|
-
const canTest = await testabilityPromise;
|
|
215
|
-
if (canTest) {
|
|
216
|
-
let testPromise = cache?.tests.get(credToTest);
|
|
217
|
-
if (!testPromise) {
|
|
218
|
-
testPromise = context.credentialService.test(credToTest).catch((testError) => ({
|
|
219
|
-
success: false,
|
|
220
|
-
message: testError instanceof Error ? testError.message : 'Test failed',
|
|
221
|
-
}));
|
|
222
|
-
cache?.tests.set(credToTest, testPromise);
|
|
223
|
-
}
|
|
224
|
-
credentialTestResult = await testPromise;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
if (!credentialType && !isTrigger && !hasParamIssues)
|
|
229
|
-
continue;
|
|
230
|
-
if (!credentialType && isTrigger && !isTestable && !hasParamIssues)
|
|
309
|
+
const request = await buildRequestForCredentialType(context, node, credentialType, cache, workflowId, nodeCtx);
|
|
310
|
+
if (request)
|
|
311
|
+
requests.push(request);
|
|
312
|
+
}
|
|
313
|
+
return requests;
|
|
314
|
+
}
|
|
315
|
+
function addConnectionEdge(mainOutgoing, nonMainIncoming, sourceName, connType, conn) {
|
|
316
|
+
if (typeof conn !== 'object' || conn === null || !('node' in conn))
|
|
317
|
+
return;
|
|
318
|
+
const destName = conn.node;
|
|
319
|
+
if (connType === 'main') {
|
|
320
|
+
const existing = mainOutgoing.get(sourceName) ?? [];
|
|
321
|
+
if (!existing.includes(destName))
|
|
322
|
+
existing.push(destName);
|
|
323
|
+
mainOutgoing.set(sourceName, existing);
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
const existing = nonMainIncoming.get(destName) ?? [];
|
|
327
|
+
if (!existing.includes(sourceName))
|
|
328
|
+
existing.push(sourceName);
|
|
329
|
+
nonMainIncoming.set(destName, existing);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
function addSourceConnections(sourceName, nodeConns, mainOutgoing, nonMainIncoming) {
|
|
333
|
+
for (const [connType, outputs] of Object.entries(nodeConns)) {
|
|
334
|
+
if (!Array.isArray(outputs))
|
|
231
335
|
continue;
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
const
|
|
236
|
-
(
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
if (hasParamIssues) {
|
|
240
|
-
needsAction = true;
|
|
336
|
+
for (const slot of outputs) {
|
|
337
|
+
if (!Array.isArray(slot))
|
|
338
|
+
continue;
|
|
339
|
+
for (const conn of slot) {
|
|
340
|
+
addConnectionEdge(mainOutgoing, nonMainIncoming, sourceName, connType, conn);
|
|
341
|
+
}
|
|
241
342
|
}
|
|
242
|
-
const request = {
|
|
243
|
-
node: {
|
|
244
|
-
name: node.name,
|
|
245
|
-
type: node.type,
|
|
246
|
-
typeVersion,
|
|
247
|
-
parameters,
|
|
248
|
-
position: nodePosition,
|
|
249
|
-
id: nodeId,
|
|
250
|
-
...(nodeCredentials && Object.keys(nodeCredentials).length > 0
|
|
251
|
-
? {
|
|
252
|
-
credentials: isAutoApplied && credentialType && existingCredentials.length > 0
|
|
253
|
-
? {
|
|
254
|
-
...nodeCredentials,
|
|
255
|
-
[credentialType]: {
|
|
256
|
-
id: existingCredentials[0].id,
|
|
257
|
-
name: existingCredentials[0].name,
|
|
258
|
-
},
|
|
259
|
-
}
|
|
260
|
-
: nodeCredentials,
|
|
261
|
-
}
|
|
262
|
-
: isAutoApplied && credentialType && existingCredentials.length > 0
|
|
263
|
-
? {
|
|
264
|
-
credentials: {
|
|
265
|
-
[credentialType]: {
|
|
266
|
-
id: existingCredentials[0].id,
|
|
267
|
-
name: existingCredentials[0].name,
|
|
268
|
-
},
|
|
269
|
-
},
|
|
270
|
-
}
|
|
271
|
-
: {}),
|
|
272
|
-
},
|
|
273
|
-
...(credentialType ? { credentialType } : {}),
|
|
274
|
-
...(existingCredentials.length > 0 ? { existingCredentials } : {}),
|
|
275
|
-
isTrigger,
|
|
276
|
-
...(isTestable ? { isTestable } : {}),
|
|
277
|
-
...(isAutoApplied ? { isAutoApplied } : {}),
|
|
278
|
-
...(credentialTestResult ? { credentialTestResult } : {}),
|
|
279
|
-
...(triggerTestResult ? { triggerTestResult } : {}),
|
|
280
|
-
...(hasParamIssues ? { parameterIssues } : {}),
|
|
281
|
-
...(editableParameters && editableParameters.length > 0 ? { editableParameters } : {}),
|
|
282
|
-
needsAction,
|
|
283
|
-
};
|
|
284
|
-
requests.push(request);
|
|
285
343
|
}
|
|
286
|
-
return requests;
|
|
287
344
|
}
|
|
288
|
-
function
|
|
345
|
+
function buildConnectionAdjacency(connections) {
|
|
289
346
|
const mainOutgoing = new Map();
|
|
290
347
|
const nonMainIncoming = new Map();
|
|
291
348
|
for (const [sourceName, nodeConns] of Object.entries(connections)) {
|
|
292
349
|
if (typeof nodeConns !== 'object' || nodeConns === null)
|
|
293
350
|
continue;
|
|
294
|
-
|
|
295
|
-
if (!Array.isArray(outputs))
|
|
296
|
-
continue;
|
|
297
|
-
for (const slot of outputs) {
|
|
298
|
-
if (!Array.isArray(slot))
|
|
299
|
-
continue;
|
|
300
|
-
for (const conn of slot) {
|
|
301
|
-
if (typeof conn !== 'object' || conn === null || !('node' in conn))
|
|
302
|
-
continue;
|
|
303
|
-
const destName = conn.node;
|
|
304
|
-
if (connType === 'main') {
|
|
305
|
-
const existing = mainOutgoing.get(sourceName) ?? [];
|
|
306
|
-
if (!existing.includes(destName))
|
|
307
|
-
existing.push(destName);
|
|
308
|
-
mainOutgoing.set(sourceName, existing);
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
const existing = nonMainIncoming.get(destName) ?? [];
|
|
312
|
-
if (!existing.includes(sourceName))
|
|
313
|
-
existing.push(sourceName);
|
|
314
|
-
nonMainIncoming.set(destName, existing);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
351
|
+
addSourceConnections(sourceName, nodeConns, mainOutgoing, nonMainIncoming);
|
|
319
352
|
}
|
|
353
|
+
return { mainOutgoing, nonMainIncoming };
|
|
354
|
+
}
|
|
355
|
+
function sortByExecutionOrder(requests, connections) {
|
|
356
|
+
const { mainOutgoing, nonMainIncoming } = buildConnectionAdjacency(connections);
|
|
320
357
|
const triggerRequests = requests
|
|
321
358
|
.filter((r) => r.isTrigger)
|
|
322
359
|
.sort((a, b) => a.node.position[0] - b.node.position[0]);
|
|
@@ -441,6 +478,51 @@ async function applyNodeParameters(context, workflowId, nodeParameters) {
|
|
|
441
478
|
}
|
|
442
479
|
return result;
|
|
443
480
|
}
|
|
481
|
+
async function applyCredentialsToNode(context, node, nodeName, credsMap, result) {
|
|
482
|
+
let nodeSucceeded = true;
|
|
483
|
+
for (const [credType, credId] of Object.entries(credsMap)) {
|
|
484
|
+
try {
|
|
485
|
+
const cred = await context.credentialService.get(credId);
|
|
486
|
+
if (cred) {
|
|
487
|
+
node.credentials = {
|
|
488
|
+
...node.credentials,
|
|
489
|
+
[credType]: { id: cred.id, name: cred.name },
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
else {
|
|
493
|
+
nodeSucceeded = false;
|
|
494
|
+
result.failed.push({
|
|
495
|
+
nodeName,
|
|
496
|
+
error: `Credential ${credId} (type: ${credType}) not found — it may have been deleted`,
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
catch (error) {
|
|
501
|
+
nodeSucceeded = false;
|
|
502
|
+
result.failed.push({
|
|
503
|
+
nodeName,
|
|
504
|
+
error: `Failed to resolve credential ${credId} (type: ${credType}): ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
return nodeSucceeded;
|
|
509
|
+
}
|
|
510
|
+
function applyParametersToNode(node, nodeName, params, result) {
|
|
511
|
+
try {
|
|
512
|
+
node.parameters = {
|
|
513
|
+
...(node.parameters ?? {}),
|
|
514
|
+
...params,
|
|
515
|
+
};
|
|
516
|
+
return true;
|
|
517
|
+
}
|
|
518
|
+
catch (error) {
|
|
519
|
+
result.failed.push({
|
|
520
|
+
nodeName,
|
|
521
|
+
error: `Failed to merge parameters: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
522
|
+
});
|
|
523
|
+
return false;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
444
526
|
async function applyNodeChanges(context, workflowId, nodeCredentials, nodeParameters) {
|
|
445
527
|
const result = { applied: [], failed: [] };
|
|
446
528
|
const workflowJson = await context.workflowService.getAsWorkflowJSON(workflowId);
|
|
@@ -448,52 +530,14 @@ async function applyNodeChanges(context, workflowId, nodeCredentials, nodeParame
|
|
|
448
530
|
for (const node of workflowJson.nodes) {
|
|
449
531
|
if (!node.name)
|
|
450
532
|
continue;
|
|
451
|
-
const
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
try {
|
|
456
|
-
const cred = await context.credentialService.get(credId);
|
|
457
|
-
if (cred) {
|
|
458
|
-
node.credentials = {
|
|
459
|
-
...node.credentials,
|
|
460
|
-
[credType]: { id: cred.id, name: cred.name },
|
|
461
|
-
};
|
|
462
|
-
}
|
|
463
|
-
else {
|
|
464
|
-
nodeSucceeded = false;
|
|
465
|
-
result.failed.push({
|
|
466
|
-
nodeName: node.name,
|
|
467
|
-
error: `Credential ${credId} (type: ${credType}) not found — it may have been deleted`,
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
catch (error) {
|
|
472
|
-
nodeSucceeded = false;
|
|
473
|
-
result.failed.push({
|
|
474
|
-
nodeName: node.name,
|
|
475
|
-
error: `Failed to resolve credential ${credId} (type: ${credType}): ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
if (nodeSucceeded)
|
|
480
|
-
appliedNodes.add(node.name);
|
|
533
|
+
const nodeName = node.name;
|
|
534
|
+
const credsMap = nodeCredentials?.[nodeName];
|
|
535
|
+
if (credsMap && (await applyCredentialsToNode(context, node, nodeName, credsMap, result))) {
|
|
536
|
+
appliedNodes.add(nodeName);
|
|
481
537
|
}
|
|
482
|
-
const params = nodeParameters?.[
|
|
483
|
-
if (params) {
|
|
484
|
-
|
|
485
|
-
node.parameters = {
|
|
486
|
-
...(node.parameters ?? {}),
|
|
487
|
-
...params,
|
|
488
|
-
};
|
|
489
|
-
appliedNodes.add(node.name);
|
|
490
|
-
}
|
|
491
|
-
catch (error) {
|
|
492
|
-
result.failed.push({
|
|
493
|
-
nodeName: node.name,
|
|
494
|
-
error: `Failed to merge parameters: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
495
|
-
});
|
|
496
|
-
}
|
|
538
|
+
const params = nodeParameters?.[nodeName];
|
|
539
|
+
if (params && applyParametersToNode(node, nodeName, params, result)) {
|
|
540
|
+
appliedNodes.add(nodeName);
|
|
497
541
|
}
|
|
498
542
|
const appliedTypes = new Set(credsMap ? Object.keys(credsMap) : []);
|
|
499
543
|
await stripStaleCredentialsFromNode(context, node, appliedTypes);
|