mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(core): Expose $agentInfo variable for easy AI workflow (no-changelog) (#14445)
Co-authored-by: Mutasem Aldmour <mutasem@n8n.io>
This commit is contained in:
@@ -787,4 +787,52 @@ describe('WorkflowDataProxy', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('$agentInfo', () => {
|
||||
const fixture = loadFixture('agentInfo');
|
||||
const proxy = getProxyFromFixture(fixture.workflow, fixture.run, 'AI Agent');
|
||||
|
||||
test('$agentInfo should return undefined for non-agent nodes', () => {
|
||||
const nonAgentProxy = getProxyFromFixture(fixture.workflow, fixture.run, 'Calculator');
|
||||
expect(nonAgentProxy.$agentInfo).toBeUndefined();
|
||||
});
|
||||
|
||||
test('$agentInfo should return memoryConnectedToAgent as true if memory is connected', () => {
|
||||
expect(proxy.$agentInfo.memoryConnectedToAgent).toBe(true);
|
||||
});
|
||||
|
||||
test('$agentInfo should return memoryConnectedToAgent as false if no memory is connected', () => {
|
||||
const noMemoryProxy = getProxyFromFixture(fixture.workflow, fixture.run, 'Another Agent');
|
||||
expect(noMemoryProxy.$agentInfo.memoryConnectedToAgent).toBe(false);
|
||||
});
|
||||
|
||||
test('$agentInfo.tools should include connected tools with correct details', () => {
|
||||
const tools = proxy.$agentInfo.tools;
|
||||
// don't show tool connected to other agent
|
||||
expect(tools.length).toEqual(2);
|
||||
expect(tools[0]).toMatchObject({
|
||||
connected: true,
|
||||
name: 'Google Calendar',
|
||||
type: 'Google Calendar',
|
||||
resource: 'Event',
|
||||
operation: 'Create',
|
||||
hasCredentials: false,
|
||||
});
|
||||
expect(tools[1]).toMatchObject({
|
||||
connected: false,
|
||||
name: 'Calculator',
|
||||
type: 'Calculator',
|
||||
resource: null,
|
||||
operation: null,
|
||||
hasCredentials: false,
|
||||
});
|
||||
});
|
||||
|
||||
test('$agentInfo.tools should correctly identify AI-defined fields', () => {
|
||||
const tools = proxy.$agentInfo.tools;
|
||||
expect(tools[0].name).toBe('Google Calendar');
|
||||
expect(tools[0].aiDefinedFields.length).toBe(1);
|
||||
expect(tools[0].aiDefinedFields).toEqual(['Start']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user