feat(v2): AI tool support, native binding fallback, and Execute SQL expression toggle - #26
Merged
Merged
Conversation
- Add usableAsTool: true so the node is available as an AI agent tool - Fix native binding loader to try/catch instead of existsSync, allowing graceful fallback to system bindings on non-musl hosts - Add Allow Expressions in Query (Unsafe) toggle to Execute SQL, off by default to preserve existing safe behavior - Fix updateDisplayOptions shallow merge so field-level displayOptions conditions are preserved alongside operation-level conditions
There was a problem hiding this comment.
Pull request overview
This PR enhances the v2 SQLite node to better integrate with n8n AI Agent tooling, improve cross-platform native binding loading, and add an opt-in path for evaluating expressions inside Execute SQL queries.
Changes:
- Mark the node as AI-agent tool compatible (
usableAsTool: true) so operations can be wired into AI Agent nodes. - Make native binding loading resilient by trying the bundled musl x64 binding and falling back gracefully when it can’t be loaded.
- Add an Allow Expressions in Query (Unsafe) toggle for Execute SQL (default off) and fix
updateDisplayOptionsto preserve field-level display conditions.
Reviewed changes
Copilot reviewed 7 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates docs with screenshots and new sections for Execute SQL, unsafe expressions, and AI tool usage. |
| package.json | Bumps package version to 1.1.0. |
| nodes/SqliteNode/v2/transport/index.ts | Changes native binding load to try/catch fallback behavior. |
| nodes/SqliteNode/v2/helpers/utils.ts | Fixes shallow-merge bug by deep-merging displayOptions.show/hide. |
| nodes/SqliteNode/v2/actions/versionDescription.ts | Marks v2 node description as usableAsTool. |
| nodes/SqliteNode/v2/actions/database/executeQuery.operation.ts | Adds unsafe-expression toggle and a separate expression-enabled query field. |
| nodes/SqliteNode/SqliteNode.node.ts | Marks the versioned node’s base description as usableAsTool. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+37
to
+42
| if (fs.existsSync(nativeBinding)) { | ||
| try { | ||
| return new Database(dbPath, { nativeBinding }); | ||
| } catch {} | ||
| } | ||
| return new Database(dbPath); |
Comment on lines
+17
to
+24
| { | ||
| displayName: 'Allow Expressions in Query (Unsafe)', | ||
| name: 'allowExpressions', | ||
| type: 'boolean', | ||
| default: false, | ||
| noDataExpression: true, | ||
| description: 'Whether to allow n8n expressions inside the SQL query. When enabled, expressions like {{ $JSON.value }} are evaluated before the query is sent to SQLite. Only enable this with trusted data, passing unsanitized user input into the query string can lead to SQL injection.', | ||
| }, |
Comment on lines
68
to
+72
| for (let i = 0; i < items.length; i++) { | ||
| const rawQuery = this.getNodeParameter('query', i) as string; | ||
| const allowExpressions = this.getNodeParameter('allowExpressions', i, false) as boolean; | ||
| const rawQuery = allowExpressions | ||
| ? (this.getNodeParameter('queryExpression', i) as string) | ||
| : (this.getNodeParameter('query', i) as string); |
Comment on lines
12
to
16
| export function updateDisplayOptions( | ||
| displayOptions: { show?: Record<string, unknown[]>; hide?: Record<string, unknown[]> }, | ||
| properties: INodeProperties[], | ||
| ): INodeProperties[] { | ||
| return properties.map((p) => ({ |
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
usableAsTool: true) so all 6 operations can be wired directly into an n8n AI Agent node, closing [Feature Req] Make Available as a Tool Call #17fs.existsSync, allowing graceful fallback to system bindings on non-musl and non-x64 hosts (ARM64, glibc Linux, macOS), closing Bug: "unsupported relocation type 7" on ARM64 (aarch64) due to hardcoded x64 binary #24updateDisplayOptionsthat was silently dropping field-leveldisplayOptionsconditions (affecteddataMode-dependent fields in Insert, Update, and Upsert)Details
AI tool support (#17)
Adding
usableAsTool: trueto the node description makes all 6 operations available in the n8n AI Agent tool picker. Execute SQL is the most flexible option for agents. The structured operations (Select, Insert, Update, Delete, Upsert) are useful when limiting the scope of what the agent can do.Native binding fallback (fixes #24)
The previous code used
fs.existsSyncto decide whether to load the bundled musl x64 binary. This caused a fatal crash on ARM64 because the file exists on disk but cannot be loaded. The fix wraps the load attempt in try/catch and falls back tobetter-sqlite3's own binding resolution, which handles architecture detection correctly.Allow Expressions in Query (Unsafe)
Expressions in the SQL query field were blocked by
noDataExpression: trueas a safeguard against expression-based injection. The new toggle keeps that safeguard on by default and lets users opt in explicitly when they need dynamic query construction.Test plan
npm test