fix(core): Make n8n-workflow a peer dependency in ai-utilities#26404
Merged
DawidMyslak merged 3 commits intomasterfrom Mar 2, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
cubic analysis
No issues found across 3 files
Linked issue analysis
Linked issue: NODE-4532: SDK n8n-workflow types is incompatible with peer n8n-workflow
| Status | Acceptance criteria | Notes |
|---|---|---|
| ✅ | Move n8n-workflow from dependencies to peerDependencies in @n8n/ai-utilities | Moved n8n-workflow out of dependencies into peerDependencies |
| ✅ | Add n8n-workflow to peerDependencies in @n8n/ai-node-sdk | Added peerDependencies entry for n8n-workflow |
| ✅ | Update pnpm-lock.yaml to reflect peer dependency changes (avoid nested copy) | pnpm-lock updated specifier/version to reflect change |
| Ensure a single host-provided n8n-workflow instance is used at runtime (prevent type mismatches / instanceof failures) | Peer deps added but no runtime/tests to verify single instance |
Architecture diagram
sequenceDiagram
participant Host as n8n (Host Process)
participant Node as Community Node
participant SDK as @n8n/ai-node-sdk
participant Utils as @n8n/ai-utilities
participant Workflow as n8n-workflow (Shared Instance)
Note over Host,Workflow: Runtime Dependency Resolution
Host->>Workflow: Load singleton instance
Host->>Node: Load & Execute Node
Node->>SDK: Call AI helper (e.g. supplyModel)
SDK->>Workflow: CHANGED: Resolve peer dependency
Note right of SDK: Uses Host's version of n8n-workflow
SDK->>Utils: Forward request
Utils->>Workflow: CHANGED: Resolve peer dependency
Note right of Utils: No longer uses internal/nested copy
alt Validation Path
Utils->>Workflow: Perform instanceof check (ISupplyDataFunctions)
Workflow-->>Utils: Match Found (Single Instance)
Utils-->>SDK: Return initialized Model/Memory
SDK-->>Node: Return data
else Type Mismatch Path (Fixed)
Note over Utils,Workflow: Previously: Instanceof would fail here <br/> due to nested n8n-workflow copies
Utils-->>SDK: Error: Invalid type
end
Node-->>Host: Return node execution result
yehorkardash
reviewed
Mar 2, 2026
| "dependencies": { | ||
| "@n8n/ai-utilities": "workspace:*" | ||
| }, | ||
| "peerDependencies": { |
Contributor
There was a problem hiding this comment.
Do we need it here, if ai-utilities defines n8n-workflow dependency?
Contributor
Author
There was a problem hiding this comment.
Ah, since community node templates already declare their own "n8n-workflow": "*" peer dependency independently, you're right - the SDK doesn't need to duplicate that.
…utilities When published to npm, @n8n/ai-utilities had n8n-workflow as a direct dependency, causing npm to install a separate nested copy. Community nodes using @n8n/ai-node-sdk would then have two instances of n8n-workflow — one from the host (n8n) and one nested inside ai-utilities — leading to type mismatches and instanceof failures. Move n8n-workflow to peerDependencies in both @n8n/ai-utilities and @n8n/ai-node-sdk so a single host-provided instance is used throughout. Made-with: Cursor
d056bce to
0a30eff
Compare
…atible-with-peer-n8n
yehorkardash
approved these changes
Mar 2, 2026
…atible-with-peer-n8n
This was referenced Mar 2, 2026
Merged
Tuukkaa
pushed a commit
that referenced
this pull request
Mar 2, 2026
Contributor
|
Got released with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When published to npm,
@n8n/ai-utilitieshadn8n-workflowas a direct dependency, which allowed npm/pnpm to install a separate nested copy. Community nodes using@n8n/ai-node-sdkwould then end up with two instances ofn8n-workflowat runtime — one from the host (n8n) and one nested inside@n8n/ai-utilities— causing type mismatches andinstanceoffailures.This PR moves
n8n-workflowfromdependenciestopeerDependenciesin@n8n/ai-utilities, so a single host-provided instance is used throughout.Related Linear tickets, Github issues, and Community forum posts
https://linear.app/n8n/issue/NODE-4532
Review / Merge checklist
release/backport(if the PR is an urgent fix that needs to be backported)