first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled

This commit is contained in:
2026-03-17 16:22:57 +03:30
commit 3d5eaf9445
15349 changed files with 2847338 additions and 0 deletions
@@ -0,0 +1,141 @@
import { WolframAlphaTool } from '@langchain/community/tools/wolframalpha';
import { mock } from 'jest-mock-extended';
import type {
IExecuteFunctions,
INode,
INodeExecutionData,
ISupplyDataFunctions,
} from 'n8n-workflow';
import { ToolWolframAlpha } from './ToolWolframAlpha.node';
describe('ToolWolframAlpha', () => {
describe('supplyData', () => {
beforeEach(() => {
jest.resetAllMocks();
});
it('should return WolframAlpha tool instance', async () => {
const node = new ToolWolframAlpha();
const supplyDataResult = await node.supplyData.call(
mock<ISupplyDataFunctions>({
getNode: jest.fn(() => mock<INode>({ name: 'test wolfram' })),
getCredentials: jest.fn().mockResolvedValue({ appId: 'test-app-id' }),
}),
);
expect(supplyDataResult.response).toBeInstanceOf(WolframAlphaTool);
});
});
describe('execute', () => {
beforeEach(() => {
jest.resetAllMocks();
});
it('should execute WolframAlpha query and return result', async () => {
const node = new ToolWolframAlpha();
const inputData: INodeExecutionData[] = [
{
json: { query: 'what is 2+2?' },
},
];
const mockExecute = mock<IExecuteFunctions>({
getInputData: jest.fn(() => inputData),
getNode: jest.fn(() => mock<INode>({ name: 'test wolfram' })),
getCredentials: jest.fn().mockResolvedValue({ appId: 'test-app-id' }),
});
// Mock the WolframAlphaTool.invoke method
const mockResult = '4';
WolframAlphaTool.prototype.invoke = jest.fn().mockResolvedValue(mockResult);
const result = await node.execute.call(mockExecute);
expect(result).toEqual([
[
{
json: {
response: mockResult,
},
pairedItem: {
item: 0,
},
},
],
]);
expect(WolframAlphaTool.prototype.invoke).toHaveBeenCalledWith(inputData[0].json);
});
it('should handle multiple input items', async () => {
const node = new ToolWolframAlpha();
const inputData: INodeExecutionData[] = [
{
json: { query: 'what is 5*3?' },
},
{
json: { query: 'what is the square root of 16?' },
},
];
const mockExecute = mock<IExecuteFunctions>({
getInputData: jest.fn(() => inputData),
getNode: jest.fn(() => mock<INode>({ name: 'test wolfram' })),
getCredentials: jest.fn().mockResolvedValue({ appId: 'test-app-id' }),
});
// Mock the WolframAlphaTool.invoke method
WolframAlphaTool.prototype.invoke = jest
.fn()
.mockResolvedValueOnce('15')
.mockResolvedValueOnce('4');
const result = await node.execute.call(mockExecute);
expect(result).toEqual([
[
{
json: {
response: '15',
},
pairedItem: {
item: 0,
},
},
{
json: {
response: '4',
},
pairedItem: {
item: 1,
},
},
],
]);
expect(WolframAlphaTool.prototype.invoke).toHaveBeenCalledTimes(2);
});
it('should handle credentials correctly', async () => {
const node = new ToolWolframAlpha();
const inputData: INodeExecutionData[] = [
{
json: { query: 'test query' },
},
];
const mockExecute = mock<IExecuteFunctions>({
getInputData: jest.fn(() => inputData),
getNode: jest.fn(() => mock<INode>({ name: 'test wolfram' })),
getCredentials: jest.fn().mockResolvedValue({ appId: 'secret-app-id' }),
});
WolframAlphaTool.prototype.invoke = jest.fn().mockResolvedValue('test result');
await node.execute.call(mockExecute);
expect(mockExecute.getCredentials).toHaveBeenCalledWith('wolframAlphaApi');
});
});
});
@@ -0,0 +1,81 @@
import { WolframAlphaTool } from '@langchain/community/tools/wolframalpha';
import {
NodeConnectionTypes,
type IExecuteFunctions,
type INodeExecutionData,
type INodeType,
type INodeTypeDescription,
type ISupplyDataFunctions,
type SupplyData,
} from 'n8n-workflow';
import { logWrapper, getConnectionHintNoticeField } from '@n8n/ai-utilities';
export class ToolWolframAlpha implements INodeType {
description: INodeTypeDescription = {
displayName: 'Wolfram|Alpha',
name: 'toolWolframAlpha',
icon: 'file:wolfram-alpha.svg',
group: ['transform'],
version: 1,
description: "Connects to WolframAlpha's computational intelligence engine.",
defaults: {
name: 'Wolfram Alpha',
},
credentials: [
{
name: 'wolframAlphaApi',
required: true,
},
],
codex: {
categories: ['AI'],
subcategories: {
AI: ['Tools'],
Tools: ['Other Tools'],
},
resources: {
primaryDocumentation: [
{
url: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolwolframalpha/',
},
],
},
},
inputs: [],
outputs: [NodeConnectionTypes.AiTool],
outputNames: ['Tool'],
properties: [getConnectionHintNoticeField([NodeConnectionTypes.AiAgent])],
};
async supplyData(this: ISupplyDataFunctions): Promise<SupplyData> {
const credentials = await this.getCredentials('wolframAlphaApi');
return {
response: logWrapper(new WolframAlphaTool({ appid: credentials.appId as string }), this),
};
}
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const credentials = await this.getCredentials('wolframAlphaApi');
const input = this.getInputData();
const result: INodeExecutionData[] = [];
for (let i = 0; i < input.length; i++) {
const item = input[i];
const tool = new WolframAlphaTool({ appid: credentials.appId as string });
result.push({
json: {
response: await tool.invoke(item.json),
},
pairedItem: {
item: i,
},
});
}
return [result];
}
}
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 39"><path d="m36.971 24.875-7.869 1.673.801 7.825-7.372-3.162L18.469 38l-4.063-6.791-7.373 3.161.802-7.823-7.868-1.677L5.326 19l-5.357-5.872 7.867-1.673-.799-7.825 7.372 3.162 4.06-6.791 4.063 6.791 7.373-3.16-.801 7.824 7.867 1.676-5.357 5.871z" style="fill:#f16850"/><path d="m18.469 11.861-4.06-5.071-7.372-3.163 4.388 5.787z" style="fill:#fd694f"/><path d="m7.836 11.452-7.868 1.674 5.357 5.872 6.306-2.285z" style="fill:#ff3413"/><path d="M11.425 9.414 7.037 3.627l.799 7.825 3.795 5.261z" style="fill:#dc1d23"/><path d="M22.532 6.79 18.469 0l-4.06 6.79 4.06 5.071z" style="fill:#ff9281"/><path d="m31.613 19.001 5.358-5.871-7.867-1.675-3.797 5.258z" style="fill:#ff8b79"/><path d="m25.307 16.713 3.797-5.258.801-7.826-4.392 5.785z" style="fill:#fd694f"/><path d="m25.513 9.414 4.392-5.785-7.373 3.161-4.063 5.071z" style="fill:#ef5240"/><path d="m29.866 22.499 7.104 2.373-5.357-5.871-6.306-2.288z" style="fill:#ff482c"/><path d="m11.631 16.713-6.306 2.285-5.358 5.87 7.105-2.369z" style="fill:#ec2101"/><path d="M18.469 30.586v7.412l4.061-6.789.165-6.645z" style="fill:#d21c22"/><path d="m29.866 22.499-7.171 2.065 6.407 1.982 7.868-1.674z" style="fill:#c90901"/><path d="m22.53 31.209 7.372 3.162-.8-7.825-6.407-1.982z" style="fill:#ec2101"/><path d="m7.072 22.499-7.105 2.369 7.868 1.676 6.408-1.98z" style="fill:#b6171e"/><path d="m14.243 24.564.163 6.644 4.063 6.79v-7.412z" style="fill:#b4151b"/><path d="m7.835 26.544-.802 7.824 7.373-3.16-.163-6.644z" style="fill:#d21c22"/><path d="m25.307 16.713.206-7.299-7.044 2.447v7.102z" style="fill:#e63320"/><path d="m18.469 11.861-7.044-2.447.206 7.299 6.838 2.25z" style="fill:#ff4527"/><path d="m14.243 24.564 4.226 6.022 4.226-6.022-4.226-5.601z" style="fill:#ff9281"/><path d="m18.469 18.963 4.226 5.601 7.171-2.065-4.559-5.786z" style="fill:#fd684d"/><path d="m11.631 16.713-4.559 5.786 7.171 2.065 4.226-5.601z" style="fill:#fd745c"/></svg>

After

Width:  |  Height:  |  Size: 1.9 KiB