From 89fa8b809ce473bc6a3432af2fe287f2af7fc576 Mon Sep 17 00:00:00 2001 From: Andrew Beal Date: Sun, 15 Feb 2026 23:27:14 +0000 Subject: [PATCH] Rename remaining references to functioncall to toolcall --- AIClasses/AIToolCall.ts | 2 +- AIClasses/BaseAIClass.ts | 18 +- AIClasses/Claude/Claude.ts | 22 +- AIClasses/Gemini/Gemini.ts | 20 +- AIClasses/OpenAI/OpenAI.ts | 22 +- AIClasses/OpenAI/OpenAITypes.ts | 10 +- AIClasses/Schemas/AIToolTypes.ts | 4 +- Conversations/ConversationContent.ts | 12 +- Helpers/ResponseHelper.ts | 24 +-- Services/AIServices/AIToolService.ts | 78 ++++---- Services/AIServices/BaseAgent.ts | 44 ++-- Services/AIServices/ExecutionAgent.ts | 20 +- Services/AIServices/MainAgent.ts | 34 ++-- Services/AIServices/OrchestrationAgent.ts | 76 +++---- Services/AIServices/PlanningAgent.ts | 42 ++-- Services/ConversationFileSystemService.ts | 4 +- Services/StreamingService.ts | 2 +- __tests__/AIClasses/AIToolCall.test.ts | 128 ++++++------ __tests__/AIClasses/BaseAIClass.test.ts | 90 ++++----- __tests__/AIClasses/Claude.test.ts | 102 +++++----- .../CrossProviderIntegration.test.ts | 188 +++++++++--------- __tests__/AIClasses/Gemini.test.ts | 118 +++++------ __tests__/AIClasses/OpenAI.test.ts | 94 ++++----- __tests__/Conversations/Conversation.test.ts | 44 ++-- .../Conversations/ConversationContent.test.ts | 42 ++-- .../Services/AIControllerService.test.ts | 6 +- .../ConversationFileSystemService.test.ts | 46 ++--- __tests__/Services/ExecutionAgent.test.ts | 92 ++++----- .../Services/MultiAgentIntegration.test.ts | 24 +-- __tests__/Services/PlanningAgent.test.ts | 68 +++---- __tests__/Services/StreamingService.test.ts | 10 +- 31 files changed, 743 insertions(+), 743 deletions(-) diff --git a/AIClasses/AIToolCall.ts b/AIClasses/AIToolCall.ts index eb66d51..77c4675 100644 --- a/AIClasses/AIToolCall.ts +++ b/AIClasses/AIToolCall.ts @@ -16,7 +16,7 @@ export class AIToolCall { public toConversationString() { return JSON.stringify({ - functionCall: { + toolCall: { name: this.name, args: this.arguments, id: this.toolId, diff --git a/AIClasses/BaseAIClass.ts b/AIClasses/BaseAIClass.ts index 34e356a..0213270 100644 --- a/AIClasses/BaseAIClass.ts +++ b/AIClasses/BaseAIClass.ts @@ -9,7 +9,7 @@ import type { ConversationContent } from "Conversations/ConversationContent"; import type { Attachment } from "Conversations/Attachment"; import type { SettingsService } from "Services/SettingsService"; import type { StreamingService } from "Services/StreamingService"; -import type { StoredFunctionCall, StoredFunctionResponse } from "AIClasses/Schemas/AIToolTypes"; +import type { StoredToolCall, StoredFunctionResponse } from "AIClasses/Schemas/AIToolTypes"; import { Exception } from "Helpers/Exception"; import { ApiError, ApiErrorType } from "Types/ApiError"; import type { AbortService } from "Services/AbortService"; @@ -109,24 +109,24 @@ export abstract class BaseAIClass implements IAIClass { protected filterConversationContents(conversationContent: ConversationContent[]): ConversationContent[] { return conversationContent.filter((content, index, array) => { - if (!content.content && !content.functionCall && !content.functionResponse && (!content.attachments || content.attachments.length === 0)) { + if (!content.content && !content.toolCall && !content.functionResponse && (!content.attachments || content.attachments.length === 0)) { return false; // Filter out empty content } if (content.functionResponse) { // Filter out 'lone' function responses const previousItem = array[index - 1]; - const hasValidCall = previousItem && previousItem.functionCall && content.toolId === previousItem.toolId; + const hasValidCall = previousItem && previousItem.toolCall && content.toolId === previousItem.toolId; if (!hasValidCall) { Exception.warn(`[Filter Debug] Filtered orphaned function response at index ${index}/${array.length}:\n` + ` ToolId: ${content.toolId}\n` + - ` Previous item has functionCall: ${previousItem?.functionCall ? 'yes' : 'no'}\n` + + ` Previous item has toolCall: ${previousItem?.toolCall ? 'yes' : 'no'}\n` + ` Previous item toolId: ${previousItem?.toolId}\n` + ` Response: ${content.functionResponse}`); } return hasValidCall; } - if (!content.functionCall) { + if (!content.toolCall) { return true; // Keep non-function-calls } @@ -142,7 +142,7 @@ export abstract class BaseAIClass implements IAIClass { ` ToolId: ${content.toolId}\n` + ` Next item has functionResponse: ${nextItem?.functionResponse ? 'yes' : 'no'}\n` + ` Next item toolId: ${nextItem?.toolId}\n` + - ` Call: ${content.functionCall}`); + ` Call: ${content.toolCall}`); } return hasValidResponse; }); @@ -202,10 +202,10 @@ export abstract class BaseAIClass implements IAIClass { * Converts a function call to legacy text format for cross-provider compatibility. * Used when a provider doesn't have the required ID field (e.g., Gemini → Claude/OpenAI). */ - protected convertFunctionCallToText(parsedContent: StoredFunctionCall): string { + protected convertToolCallToText(parsedContent: StoredToolCall): string { const formattedJson = JSON.stringify({ - name: parsedContent.functionCall.name, - args: parsedContent.functionCall.args + name: parsedContent.toolCall.name, + args: parsedContent.toolCall.args }, null, 2); return ` diff --git a/__tests__/AIClasses/OpenAI.test.ts b/__tests__/AIClasses/OpenAI.test.ts index 4e27c38..7874ba4 100644 --- a/__tests__/AIClasses/OpenAI.test.ts +++ b/__tests__/AIClasses/OpenAI.test.ts @@ -146,10 +146,10 @@ describe('OpenAI', () => { expect(result.isComplete).toBe(false); expect(result.shouldContinue).toBe(true); - expect(result.functionCall).toBeDefined(); - expect(result.functionCall?.name).toBe('search_vault_files'); - expect(result.functionCall?.arguments).toEqual({ query: 'test' }); - expect(result.functionCall?.toolId).toBe('call_123'); + expect(result.toolCall).toBeDefined(); + expect(result.toolCall?.name).toBe('search_vault_files'); + expect(result.toolCall?.arguments).toEqual({ query: 'test' }); + expect(result.toolCall?.toolId).toBe('call_123'); }); it('should handle response.done event', () => { @@ -231,7 +231,7 @@ describe('OpenAI', () => { const result = (openai as any).parseStreamChunk(chunk); - expect(result.functionCall).toBeUndefined(); + expect(result.toolCall).toBeUndefined(); expect(exceptionSpy).toHaveBeenCalled(); }); @@ -258,7 +258,7 @@ describe('OpenAI', () => { expect(result.content).toBe(''); expect(result.isComplete).toBe(false); - expect(result.functionCall).toBeUndefined(); + expect(result.toolCall).toBeUndefined(); }); it('should handle response.refusal.delta events', () => { @@ -334,18 +334,18 @@ describe('OpenAI', () => { it('should convert function call to Responses API format', async () => { const conversation = new Conversation(); - const functionCallContent = new ConversationContent({ + const toolCallContent = new ConversationContent({ role: Role.Assistant, content: 'Let me search', - functionCall: JSON.stringify({ - functionCall: { + toolCall: JSON.stringify({ + toolCall: { id: 'call_123', name: 'search_vault_files', args: { query: 'test' } } }) }); - conversation.contents.push(functionCallContent); + conversation.contents.push(toolCallContent); mockStreamingService.streamRequest.mockImplementation(async function* () { yield { content: 'done', isComplete: true }; @@ -378,12 +378,12 @@ describe('OpenAI', () => { it('should convert function response to function_call_output format', async () => { const conversation = new Conversation(); - const functionCallContent = new ConversationContent({ + const toolCallContent = new ConversationContent({ role: Role.Assistant, content: '', displayContent: '', - functionCall: JSON.stringify({ - functionCall: { + toolCall: JSON.stringify({ + toolCall: { id: 'call_123', name: 'search_vault_files', args: { query: 'test' } @@ -391,7 +391,7 @@ describe('OpenAI', () => { }), toolId: 'call_123' }); - conversation.contents.push(functionCallContent); + conversation.contents.push(toolCallContent); const responseContent = JSON.stringify({ id: 'call_123', @@ -432,7 +432,7 @@ describe('OpenAI', () => { const conversation = new Conversation(); const invalidContent = new ConversationContent({ role: Role.Assistant, - functionCall: 'invalid json {' + toolCall: 'invalid json {' }); conversation.contents.push(invalidContent); @@ -457,12 +457,12 @@ describe('OpenAI', () => { const conversation = new Conversation(); - const functionCallContent = new ConversationContent({ + const toolCallContent = new ConversationContent({ role: Role.Assistant, content: '', displayContent: '', - functionCall: JSON.stringify({ - functionCall: { + toolCall: JSON.stringify({ + toolCall: { id: 'call_invalid', name: 'search_vault_files', args: { query: 'test' } @@ -470,7 +470,7 @@ describe('OpenAI', () => { }), toolId: 'call_invalid' }); - conversation.contents.push(functionCallContent); + conversation.contents.push(toolCallContent); const invalidContent = new ConversationContent({ role: Role.User, @@ -522,8 +522,8 @@ describe('OpenAI', () => { // Function call without response (orphaned) const orphanedCall = new ConversationContent({ role: Role.Assistant, - functionCall: JSON.stringify({ - functionCall: { + toolCall: JSON.stringify({ + toolCall: { id: 'call_orphaned', name: 'search_vault_files', args: { query: 'test' } @@ -553,17 +553,17 @@ describe('OpenAI', () => { const conversation = new Conversation(); conversation.contents.push(new ConversationContent({ role: Role.User, content: 'Search for files' })); // Function call with response (not orphaned) - const functionCall = new ConversationContent({ + const toolCall = new ConversationContent({ role: Role.Assistant, - functionCall: JSON.stringify({ - functionCall: { + toolCall: JSON.stringify({ + toolCall: { id: 'call_123', name: 'search_vault_files', args: { query: 'test' } } }) }); - conversation.contents.push(functionCall); + conversation.contents.push(toolCall); // Corresponding function response const responseContent = JSON.stringify({ id: 'call_123', @@ -613,8 +613,8 @@ describe('OpenAI', () => { // Function call as most recent item (should be included) const latestCall = new ConversationContent({ role: Role.Assistant, - functionCall: JSON.stringify({ - functionCall: { + toolCall: JSON.stringify({ + toolCall: { id: 'call_latest', name: 'search_vault_files', args: { query: 'test' } @@ -653,8 +653,8 @@ describe('OpenAI', () => { // Orphaned function call #1 const orphan1 = new ConversationContent({ role: Role.Assistant, - functionCall: JSON.stringify({ - functionCall: { + toolCall: JSON.stringify({ + toolCall: { id: 'call_orphan1', name: 'search_vault_files', args: { query: 'test1' } @@ -666,8 +666,8 @@ describe('OpenAI', () => { // Orphaned function call #2 const orphan2 = new ConversationContent({ role: Role.Assistant, - functionCall: JSON.stringify({ - functionCall: { + toolCall: JSON.stringify({ + toolCall: { id: 'call_orphan2', name: 'read_file', args: { path: 'test.md' } @@ -697,18 +697,18 @@ describe('OpenAI', () => { describe('Responses API Format Edge Cases', () => { it('should handle assistant message with both text and function call', async () => { const conversation = new Conversation(); - const functionCallContent = new ConversationContent({ + const toolCallContent = new ConversationContent({ role: Role.Assistant, content: 'I will search for that.', - functionCall: JSON.stringify({ - functionCall: { + toolCall: JSON.stringify({ + toolCall: { id: 'call_123', name: 'search_vault_files', args: { query: 'test' } } }) }); - conversation.contents.push(functionCallContent); + conversation.contents.push(toolCallContent); mockStreamingService.streamRequest.mockImplementation(async function* () { yield { content: 'done', isComplete: true }; @@ -731,17 +731,17 @@ describe('OpenAI', () => { it('should handle function call with empty text content', async () => { const conversation = new Conversation(); - const functionCallContent = new ConversationContent({ + const toolCallContent = new ConversationContent({ role: Role.Assistant, - functionCall: JSON.stringify({ - functionCall: { + toolCall: JSON.stringify({ + toolCall: { id: 'call_123', name: 'search_vault_files', args: { query: 'test' } } }) }); - conversation.contents.push(functionCallContent); + conversation.contents.push(toolCallContent); mockStreamingService.streamRequest.mockImplementation(async function* () { yield { content: 'done', isComplete: true }; @@ -766,12 +766,12 @@ describe('OpenAI', () => { it('should handle complex function response objects', async () => { const conversation = new Conversation(); - const functionCallContent = new ConversationContent({ + const toolCallContent = new ConversationContent({ role: Role.Assistant, content: '', displayContent: '', - functionCall: JSON.stringify({ - functionCall: { + toolCall: JSON.stringify({ + toolCall: { id: 'call_123', name: 'search_vault_files', args: { query: 'test' } @@ -779,7 +779,7 @@ describe('OpenAI', () => { }), toolId: 'call_123' }); - conversation.contents.push(functionCallContent); + conversation.contents.push(toolCallContent); const complexResponse = { files: ['file1.txt', 'file2.md'], @@ -824,8 +824,8 @@ describe('OpenAI', () => { // First function call conversation.contents.push(new ConversationContent({ role: Role.Assistant, - functionCall: JSON.stringify({ - functionCall: { + toolCall: JSON.stringify({ + toolCall: { id: 'call_1', name: 'search_vault_files', args: { query: 'test' } @@ -847,8 +847,8 @@ describe('OpenAI', () => { conversation.contents.push(new ConversationContent({ role: Role.Assistant, content: 'Let me read that file', - functionCall: JSON.stringify({ - functionCall: { + toolCall: JSON.stringify({ + toolCall: { id: 'call_2', name: 'read_file', args: { path: 'file1.txt' } diff --git a/__tests__/Conversations/Conversation.test.ts b/__tests__/Conversations/Conversation.test.ts index 3816458..eb0e904 100644 --- a/__tests__/Conversations/Conversation.test.ts +++ b/__tests__/Conversations/Conversation.test.ts @@ -66,10 +66,10 @@ describe('Conversation', () => { role: 'user', content: 'Hello', promptContent: '', - functionCall: '', + toolCall: '', timestamp: '2024-01-01T00:00:00.000Z', - isFunctionCall: false, - isFunctionCallResponse: false, + isToolCall: false, + isToolCallResponse: false, isProviderSpecificContent: false } ] @@ -196,10 +196,10 @@ describe('Conversation', () => { role: 'user', content: 'Hello', promptContent: '', - functionCall: '', + toolCall: '', timestamp: '2024-01-01T00:00:00.000Z', - isFunctionCall: false, - isFunctionCallResponse: false, + isToolCall: false, + isToolCallResponse: false, isProviderSpecificContent: false }, { invalid: 'data' } @@ -278,9 +278,9 @@ describe('Conversation', () => { conversation.contents.push(content); const mostRecent = conversation.contents[conversation.contents.length - 1]; - mostRecent.functionCall = 'readFile'; + mostRecent.toolCall = 'readFile'; - expect(conversation.contents[0].functionCall).toBe('readFile'); + expect(conversation.contents[0].toolCall).toBe('readFile'); }); it('should mark most recent content as function call', () => { @@ -289,9 +289,9 @@ describe('Conversation', () => { conversation.contents.push(content); const mostRecent = conversation.contents[conversation.contents.length - 1]; - mostRecent.functionCall = 'readFile'; + mostRecent.toolCall = 'readFile'; - expect(conversation.contents[0].functionCall).toBe('readFile'); + expect(conversation.contents[0].toolCall).toBe('readFile'); }); it('should only update the last content when multiple contents exist', () => { @@ -301,11 +301,11 @@ describe('Conversation', () => { conversation.contents.push(new ConversationContent({ role: Role.Assistant })); const mostRecent = conversation.contents[conversation.contents.length - 1]; - mostRecent.functionCall = 'searchFiles'; + mostRecent.toolCall = 'searchFiles'; - expect(conversation.contents[0].functionCall).toBeUndefined(); - expect(conversation.contents[1].functionCall).toBeUndefined(); - expect(conversation.contents[2].functionCall).toBe('searchFiles'); + expect(conversation.contents[0].toolCall).toBeUndefined(); + expect(conversation.contents[1].toolCall).toBeUndefined(); + expect(conversation.contents[2].toolCall).toBe('searchFiles'); }); it('should do nothing when contents array is empty', () => { @@ -315,7 +315,7 @@ describe('Conversation', () => { expect(() => { const mostRecent = conversation.contents[conversation.contents.length - 1]; if (mostRecent) { - mostRecent.functionCall = 'test'; + mostRecent.toolCall = 'test'; } }).not.toThrow(); expect(conversation.contents).toHaveLength(0); @@ -326,20 +326,20 @@ describe('Conversation', () => { conversation.contents.push(new ConversationContent({ role: Role.Assistant })); const mostRecent = conversation.contents[conversation.contents.length - 1]; - mostRecent.functionCall = ''; + mostRecent.toolCall = ''; - expect(conversation.contents[0].functionCall).toBe(''); + expect(conversation.contents[0].toolCall).toBe(''); }); it('should overwrite existing function call', () => { const conversation = new Conversation(); - const content = new ConversationContent({ role: Role.Assistant, functionCall: 'oldFunction' }); + const content = new ConversationContent({ role: Role.Assistant, toolCall: 'oldFunction' }); conversation.contents.push(content); const mostRecent = conversation.contents[conversation.contents.length - 1]; - mostRecent.functionCall = 'newFunction'; + mostRecent.toolCall = 'newFunction'; - expect(conversation.contents[0].functionCall).toBe('newFunction'); + expect(conversation.contents[0].toolCall).toBe('newFunction'); }); }); @@ -361,14 +361,14 @@ describe('Conversation', () => { mostRecent.content = 'Hi there, how can I help you?'; // Assistant makes a function call - mostRecent.functionCall = 'readFile'; + mostRecent.toolCall = 'readFile'; expect(conversation.contents).toHaveLength(2); expect(conversation.contents[0].role).toBe(Role.User); expect(conversation.contents[0].content).toBe('Hello'); expect(conversation.contents[1].role).toBe(Role.Assistant); expect(conversation.contents[1].content).toBe('Hi there, how can I help you?'); - expect(conversation.contents[1].functionCall).toBe('readFile'); + expect(conversation.contents[1].toolCall).toBe('readFile'); }); it('should maintain conversation metadata', () => { diff --git a/__tests__/Conversations/ConversationContent.test.ts b/__tests__/Conversations/ConversationContent.test.ts index d0135d9..1e2fec5 100644 --- a/__tests__/Conversations/ConversationContent.test.ts +++ b/__tests__/Conversations/ConversationContent.test.ts @@ -10,7 +10,7 @@ describe('ConversationContent', () => { role: Role.User, content: 'Hello', displayContent: 'Hello Display', - functionCall: 'functionCall', + toolCall: 'toolCall', functionResponse: 'functionResponse', timestamp, attachments: [], @@ -21,7 +21,7 @@ describe('ConversationContent', () => { expect(content.role).toBe(Role.User); expect(content.content).toBe('Hello'); expect(content.displayContent).toBe('Hello Display'); - expect(content.functionCall).toBe('functionCall'); + expect(content.toolCall).toBe('toolCall'); expect(content.functionResponse).toBe('functionResponse'); expect(content.timestamp).toBe(timestamp); expect(content.attachments).toEqual([]); @@ -36,7 +36,7 @@ describe('ConversationContent', () => { role: Role.User, content: 'Hello', displayContent: 'Hello Display', - functionCall: 'functionCall', + toolCall: 'toolCall', functionResponse: 'functionResponse', timestamp, attachments: [], @@ -48,7 +48,7 @@ describe('ConversationContent', () => { expect(content.role).toBe(Role.User); expect(content.content).toBe('Hello'); expect(content.displayContent).toBe('Hello Display'); - expect(content.functionCall).toBe('functionCall'); + expect(content.toolCall).toBe('toolCall'); expect(content.functionResponse).toBe('functionResponse'); expect(content.timestamp).toBe(timestamp); expect(content.attachments).toEqual([]); @@ -63,7 +63,7 @@ describe('ConversationContent', () => { expect(content.role).toBe(Role.Assistant); expect(content.content).toBeUndefined(); expect(content.displayContent).toBeUndefined(); - expect(content.functionCall).toBeUndefined(); + expect(content.toolCall).toBeUndefined(); expect(content.functionResponse).toBeUndefined(); expect(content.timestamp).toBeInstanceOf(Date); expect(content.attachments).toEqual([]); @@ -85,13 +85,13 @@ describe('ConversationContent', () => { const content = new ConversationContent({ role: Role.User, content: 'Hello', - functionCall: 'someFunction' + toolCall: 'someFunction' }); expect(content.role).toBe(Role.User); expect(content.content).toBe('Hello'); expect(content.displayContent).toBeUndefined(); - expect(content.functionCall).toBe('someFunction'); + expect(content.toolCall).toBe('someFunction'); expect(content.functionResponse).toBeUndefined(); expect(content.timestamp).toBeInstanceOf(Date); expect(content.attachments).toEqual([]); @@ -106,7 +106,7 @@ describe('ConversationContent', () => { expect(content.role).toBe(Role.User); expect(content.content).toBe('What is the weather?'); - expect(content.functionCall).toBeUndefined(); + expect(content.toolCall).toBeUndefined(); expect(content.functionResponse).toBeUndefined(); }); @@ -123,13 +123,13 @@ describe('ConversationContent', () => { it('should create function call content', () => { const content = new ConversationContent({ role: Role.Assistant, - functionCall: 'readFile', + toolCall: 'readFile', timestamp: new Date(), toolId: 'call-1' }); expect(content.role).toBe(Role.Assistant); - expect(content.functionCall).toBe('readFile'); + expect(content.toolCall).toBe('readFile'); expect(content.functionResponse).toBeUndefined(); expect(content.toolId).toBe('call-1'); }); @@ -146,7 +146,7 @@ describe('ConversationContent', () => { expect(content.role).toBe(Role.User); expect(content.content).toBe('File contents here'); expect(content.functionResponse).toBe('File contents here'); - expect(content.functionCall).toBeUndefined(); + expect(content.toolCall).toBeUndefined(); expect(content.toolId).toBe('call-1'); }); @@ -213,7 +213,7 @@ describe('ConversationContent', () => { timestamp: '2024-01-01T00:00:00.000Z', content: 'Hello', displayContent: 'Hello Display', - functionCall: '', + toolCall: '', functionResponse: '', attachments: [], shouldDisplayContent: true @@ -235,7 +235,7 @@ describe('ConversationContent', () => { const validData = { role: 'assistant', timestamp: '2024-01-01T00:00:00.000Z', - functionCall: 'readFile', + toolCall: 'readFile', toolId: 'tool-123' }; @@ -246,7 +246,7 @@ describe('ConversationContent', () => { const validData = { role: 'assistant', timestamp: '2024-01-01T00:00:00.000Z', - functionCall: 'readFile', + toolCall: 'readFile', thoughtSignature: 'base64Signature==' }; @@ -257,7 +257,7 @@ describe('ConversationContent', () => { const validData = { role: 'assistant', timestamp: '2024-01-01T00:00:00.000Z', - functionCall: 'readFile', + toolCall: 'readFile', toolId: 'tool-123', thoughtSignature: 'base64Signature==' }; @@ -345,11 +345,11 @@ describe('ConversationContent', () => { expect(ConversationContent.isConversationContentData(invalidData)).toBe(false); }); - it('should return false when functionCall is not a string', () => { + it('should return false when toolCall is not a string', () => { const invalidData = { role: 'user', timestamp: '2024-01-01T00:00:00.000Z', - functionCall: null + toolCall: null }; expect(ConversationContent.isConversationContentData(invalidData)).toBe(false); @@ -411,7 +411,7 @@ describe('ConversationContent', () => { timestamp: '', content: '', displayContent: '', - functionCall: '', + toolCall: '', functionResponse: '' }; @@ -441,11 +441,11 @@ describe('ConversationContent', () => { expect(content.displayContent).toBe('modified'); }); - it('should allow functionCall to be modified', () => { + it('should allow toolCall to be modified', () => { const content = new ConversationContent({ role: Role.Assistant }); - content.functionCall = 'readFile'; + content.toolCall = 'readFile'; - expect(content.functionCall).toBe('readFile'); + expect(content.toolCall).toBe('readFile'); }); it('should allow functionResponse to be modified', () => { diff --git a/__tests__/Services/AIControllerService.test.ts b/__tests__/Services/AIControllerService.test.ts index 8bbf195..3ee63cd 100644 --- a/__tests__/Services/AIControllerService.test.ts +++ b/__tests__/Services/AIControllerService.test.ts @@ -190,7 +190,7 @@ describe('AIControllerService - Integration Tests', () => { // First call returns a function call yield { content: 'Let me search', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SearchVaultFiles, { search_terms: ['test'], user_message: 'Searching' }, 'tool-1' @@ -235,7 +235,7 @@ describe('AIControllerService - Integration Tests', () => { if (callCount === 1) { yield { content: '', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SearchVaultFiles, { search_terms: ['notes'], user_message: 'Searching for notes' }, 'tool-1' @@ -349,7 +349,7 @@ describe('AIControllerService - Integration Tests', () => { if (callCount === 1) { yield { content: '', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SearchVaultFiles, { search_terms: ['test'], user_message: 'Searching' }, 'tool-1' diff --git a/__tests__/Services/ConversationFileSystemService.test.ts b/__tests__/Services/ConversationFileSystemService.test.ts index a8b86c4..e8e991b 100644 --- a/__tests__/Services/ConversationFileSystemService.test.ts +++ b/__tests__/Services/ConversationFileSystemService.test.ts @@ -171,7 +171,7 @@ describe('ConversationFileSystemService - Integration Tests', () => { it('should serialize function calls correctly', async () => { const conversation = createTestConversation('With Function Call'); - const functionCall = { + const toolCall = { name: 'test_function', arguments: { arg1: 'value1' } }; @@ -180,7 +180,7 @@ describe('ConversationFileSystemService - Integration Tests', () => { new ConversationContent({ role: Role.Assistant, content: 'Function call', - functionCall: JSON.stringify(functionCall), + toolCall: JSON.stringify(toolCall), timestamp: new Date('2024-01-01T10:02:00Z'), toolId: 'tool_123' }) @@ -189,12 +189,12 @@ describe('ConversationFileSystemService - Integration Tests', () => { await service.saveConversation(conversation); const savedData = mockFileSystemService.writeObjectToFile.mock.calls[0][1]; - const functionCallContent = savedData.contents[2]; + const toolCallContent = savedData.contents[2]; - expect(functionCallContent).toMatchObject({ + expect(toolCallContent).toMatchObject({ role: Role.Assistant, content: 'Function call', - functionCall: JSON.stringify(functionCall), + toolCall: JSON.stringify(toolCall), timestamp: '2024-01-01T10:02:00.000Z', toolId: 'tool_123' }); @@ -368,10 +368,10 @@ describe('ConversationFileSystemService - Integration Tests', () => { role: Role.User, content: 'Message 1', promptContent: '', - functionCall: '', + toolCall: '', timestamp: '2024-01-01T10:00:00.000Z', - isFunctionCall: false, - isFunctionCallResponse: false, + isToolCall: false, + isToolCallResponse: false, isProviderSpecificContent: false } ] @@ -385,10 +385,10 @@ describe('ConversationFileSystemService - Integration Tests', () => { role: Role.User, content: 'Message 2', promptContent: '', - functionCall: '', + toolCall: '', timestamp: '2024-01-02T10:00:00.000Z', - isFunctionCall: false, - isFunctionCallResponse: false, + isToolCall: false, + isToolCallResponse: false, isProviderSpecificContent: false } ] @@ -419,20 +419,20 @@ describe('ConversationFileSystemService - Integration Tests', () => { role: Role.User, content: 'Hello', promptContent: '', - functionCall: '', + toolCall: '', timestamp: '2024-01-01T10:00:00.000Z', - isFunctionCall: false, - isFunctionCallResponse: false, + isToolCall: false, + isToolCallResponse: false, isProviderSpecificContent: false }, { role: Role.Assistant, content: 'Hi!', promptContent: '', - functionCall: '', + toolCall: '', timestamp: '2024-01-01T10:01:00.000Z', - isFunctionCall: false, - isFunctionCallResponse: false, + isToolCall: false, + isToolCallResponse: false, isProviderSpecificContent: false } ] @@ -499,7 +499,7 @@ describe('ConversationFileSystemService - Integration Tests', () => { { role: Role.Assistant, content: 'Calling function', - functionCall: JSON.stringify({ name: 'test_func', arguments: {} }), + toolCall: JSON.stringify({ name: 'test_func', arguments: {} }), timestamp: '2024-01-01T10:00:00.000Z', toolId: 'tool_1', attachments: [], @@ -519,8 +519,8 @@ describe('ConversationFileSystemService - Integration Tests', () => { const conversations = await service.getAllConversations(); - expect(conversations[0].contents[0].functionCall).toBeDefined(); - expect(JSON.parse(conversations[0].contents[0].functionCall!)).toEqual({ + expect(conversations[0].contents[0].toolCall).toBeDefined(); + expect(JSON.parse(conversations[0].contents[0].toolCall!)).toEqual({ name: 'test_func', arguments: {} }); @@ -648,7 +648,7 @@ describe('ConversationFileSystemService - Integration Tests', () => { new ConversationContent({ role: Role.Assistant, content: 'Function', - functionCall: JSON.stringify({ name: 'test', arguments: { arg: 'val' } }), + toolCall: JSON.stringify({ name: 'test', arguments: { arg: 'val' } }), timestamp: new Date('2024-01-01T10:05:00Z'), toolId: 'tool_xyz' }), @@ -678,8 +678,8 @@ describe('ConversationFileSystemService - Integration Tests', () => { // Verify all data preserved expect(reconstructed.title).toBe(original.title); expect(reconstructed.contents).toHaveLength(4); - expect(reconstructed.contents[2].functionCall).toBeDefined(); - expect(JSON.parse(reconstructed.contents[2].functionCall!)).toEqual({ + expect(reconstructed.contents[2].toolCall).toBeDefined(); + expect(JSON.parse(reconstructed.contents[2].toolCall!)).toEqual({ name: 'test', arguments: { arg: 'val' } }); diff --git a/__tests__/Services/ExecutionAgent.test.ts b/__tests__/Services/ExecutionAgent.test.ts index 3c65bf8..b8fa2fa 100644 --- a/__tests__/Services/ExecutionAgent.test.ts +++ b/__tests__/Services/ExecutionAgent.test.ts @@ -85,7 +85,7 @@ describe('ExecutionAgent - Unit Tests', () => { mockAI.streamRequest.mockImplementation(async function* () { yield { content: 'Task completed', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true, @@ -115,7 +115,7 @@ describe('ExecutionAgent - Unit Tests', () => { mockAI.streamRequest.mockImplementation(async function* () { yield { content: 'Task completed', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true, @@ -152,7 +152,7 @@ describe('ExecutionAgent - Unit Tests', () => { mockAI.streamRequest.mockImplementation(async function* () { yield { content: 'Done', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true, @@ -190,7 +190,7 @@ describe('ExecutionAgent - Unit Tests', () => { mockAI.streamRequest.mockImplementation(async function* () { yield { content: 'Task failed', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: false, @@ -220,7 +220,7 @@ describe('ExecutionAgent - Unit Tests', () => { mockAI.streamRequest.mockImplementation(async function* () { yield { content: 'Failed', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: false, @@ -251,15 +251,15 @@ describe('ExecutionAgent - Unit Tests', () => { instruction: 'Search for files with tag #important' }; - let functionCallCount = 0; + let toolCallCount = 0; mockAI.streamRequest.mockImplementation(async function* () { - functionCallCount++; - if (functionCallCount === 1) { + toolCallCount++; + if (toolCallCount === 1) { // Call search function yield { content: 'Searching', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SearchVaultFiles, { search_terms: ['#important'], @@ -273,7 +273,7 @@ describe('ExecutionAgent - Unit Tests', () => { // Complete task yield { content: 'Done', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true, @@ -291,7 +291,7 @@ describe('ExecutionAgent - Unit Tests', () => { expect(mockAIToolService.performAITool).toHaveBeenCalled(); expect(result?.success).toBe(true); - expect(functionCallCount).toBe(2); + expect(toolCallCount).toBe(2); }); it('should call ReadVaultFiles during execution', async () => { @@ -301,14 +301,14 @@ describe('ExecutionAgent - Unit Tests', () => { instruction: 'Read contents of note.md' }; - let functionCallCount = 0; + let toolCallCount = 0; mockAI.streamRequest.mockImplementation(async function* () { - functionCallCount++; - if (functionCallCount === 1) { + toolCallCount++; + if (toolCallCount === 1) { yield { content: 'Reading', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.ReadVaultFiles, { file_paths: ['note.md'], @@ -321,7 +321,7 @@ describe('ExecutionAgent - Unit Tests', () => { } else { yield { content: 'Done', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true, @@ -348,14 +348,14 @@ describe('ExecutionAgent - Unit Tests', () => { instruction: 'Create new file with content' }; - let functionCallCount = 0; + let toolCallCount = 0; mockAI.streamRequest.mockImplementation(async function* () { - functionCallCount++; - if (functionCallCount === 1) { + toolCallCount++; + if (toolCallCount === 1) { yield { content: 'Writing', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.WriteVaultFile, { file_path: 'new-note.md', @@ -369,7 +369,7 @@ describe('ExecutionAgent - Unit Tests', () => { } else { yield { content: 'Done', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true, @@ -396,14 +396,14 @@ describe('ExecutionAgent - Unit Tests', () => { instruction: 'Search, read, and update files' }; - let functionCallCount = 0; + let toolCallCount = 0; mockAI.streamRequest.mockImplementation(async function* () { - functionCallCount++; - if (functionCallCount === 1) { + toolCallCount++; + if (toolCallCount === 1) { yield { content: 'Searching', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SearchVaultFiles, { search_terms: ['TODO'], @@ -413,10 +413,10 @@ describe('ExecutionAgent - Unit Tests', () => { ), isComplete: true }; - } else if (functionCallCount === 2) { + } else if (toolCallCount === 2) { yield { content: 'Reading', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.ReadVaultFiles, { file_paths: ['found.md'], @@ -426,10 +426,10 @@ describe('ExecutionAgent - Unit Tests', () => { ), isComplete: true }; - } else if (functionCallCount === 3) { + } else if (toolCallCount === 3) { yield { content: 'Writing', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.PatchVaultFile, { file_path: 'found.md', @@ -443,7 +443,7 @@ describe('ExecutionAgent - Unit Tests', () => { } else { yield { content: 'Done', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true, @@ -486,7 +486,7 @@ describe('ExecutionAgent - Unit Tests', () => { // Complete on retry yield { content: 'Done', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true, @@ -527,7 +527,7 @@ describe('ExecutionAgent - Unit Tests', () => { // Complete on third attempt yield { content: 'Done', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true, @@ -574,7 +574,7 @@ describe('ExecutionAgent - Unit Tests', () => { } else { yield { content: 'Done', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true, @@ -640,7 +640,7 @@ describe('ExecutionAgent - Unit Tests', () => { // Complete on third attempt (max depth) yield { content: 'Done', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true, @@ -680,7 +680,7 @@ describe('ExecutionAgent - Unit Tests', () => { yield { content: 'Done', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true, @@ -710,7 +710,7 @@ describe('ExecutionAgent - Unit Tests', () => { mockAI.streamRequest.mockImplementation(async function* () { yield { content: 'Done', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true, @@ -747,7 +747,7 @@ describe('ExecutionAgent - Unit Tests', () => { yield { content: 'Done', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true, @@ -783,7 +783,7 @@ describe('ExecutionAgent - Unit Tests', () => { // Invalid: missing description yield { content: 'Done', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true @@ -797,7 +797,7 @@ describe('ExecutionAgent - Unit Tests', () => { // Valid completion yield { content: 'Done', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true, @@ -832,7 +832,7 @@ describe('ExecutionAgent - Unit Tests', () => { // Invalid: success is not boolean yield { content: 'Done', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: 'yes', @@ -846,7 +846,7 @@ describe('ExecutionAgent - Unit Tests', () => { // Valid yield { content: 'Done', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true, @@ -875,14 +875,14 @@ describe('ExecutionAgent - Unit Tests', () => { instruction: 'Do task with updates' }; - let functionCallCount = 0; + let toolCallCount = 0; mockAI.streamRequest.mockImplementation(async function* () { - functionCallCount++; - if (functionCallCount === 1) { + toolCallCount++; + if (toolCallCount === 1) { yield { content: 'Searching', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SearchVaultFiles, { search_terms: ['test'], @@ -895,7 +895,7 @@ describe('ExecutionAgent - Unit Tests', () => { } else { yield { content: 'Done', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true, diff --git a/__tests__/Services/MultiAgentIntegration.test.ts b/__tests__/Services/MultiAgentIntegration.test.ts index fab7ee8..b02723a 100644 --- a/__tests__/Services/MultiAgentIntegration.test.ts +++ b/__tests__/Services/MultiAgentIntegration.test.ts @@ -123,7 +123,7 @@ describe('Multi-Agent Integration Tests', () => { mockAI.streamRequest.mockImplementation(async function* () { yield { content: 'Plan', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SubmitPlan, { steps: [ @@ -159,7 +159,7 @@ describe('Multi-Agent Integration Tests', () => { mockAI.streamRequest.mockImplementation(async function* () { yield { content: 'Replan', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SubmitPlan, { steps: [ @@ -201,7 +201,7 @@ describe('Multi-Agent Integration Tests', () => { mockAI.streamRequest.mockImplementation(async function* () { yield { content: 'Done', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true, @@ -232,7 +232,7 @@ describe('Multi-Agent Integration Tests', () => { mockAI.streamRequest.mockImplementation(async function* () { yield { content: 'Failed', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: false, @@ -264,7 +264,7 @@ describe('Multi-Agent Integration Tests', () => { mockAI.streamRequest.mockImplementation(async function* () { yield { content: 'Done', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true, @@ -400,7 +400,7 @@ describe('Multi-Agent Integration Tests', () => { searchCalled = true; yield { content: 'Searching', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SearchVaultFiles, { search_terms: ['test'], @@ -413,7 +413,7 @@ describe('Multi-Agent Integration Tests', () => { } else { yield { content: 'Plan', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SubmitPlan, { steps: [ @@ -445,13 +445,13 @@ describe('Multi-Agent Integration Tests', () => { }; const callbacks = createMockCallbacks(); - let functionCallCount = 0; + let toolCallCount = 0; mockAI.streamRequest.mockImplementation(async function* () { - functionCallCount++; - if (functionCallCount === 1) { + toolCallCount++; + if (toolCallCount === 1) { yield { content: 'Searching', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SearchVaultFiles, { search_terms: ['test'], @@ -464,7 +464,7 @@ describe('Multi-Agent Integration Tests', () => { } else { yield { content: 'Done', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true, diff --git a/__tests__/Services/PlanningAgent.test.ts b/__tests__/Services/PlanningAgent.test.ts index 4b3ef2b..a37f3ec 100644 --- a/__tests__/Services/PlanningAgent.test.ts +++ b/__tests__/Services/PlanningAgent.test.ts @@ -88,7 +88,7 @@ describe('PlanningAgent - Unit Tests', () => { mockAI.streamRequest.mockImplementation(async function* () { yield { content: 'Creating plan', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SubmitPlan, { steps: [ @@ -135,7 +135,7 @@ describe('PlanningAgent - Unit Tests', () => { mockAI.streamRequest.mockImplementation(async function* () { yield { content: 'Plan', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SubmitPlan, { steps: [ @@ -169,7 +169,7 @@ describe('PlanningAgent - Unit Tests', () => { mockAI.streamRequest.mockImplementation(async function* () { yield { content: 'Replan', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SubmitPlan, { steps: [ @@ -210,7 +210,7 @@ describe('PlanningAgent - Unit Tests', () => { // Invalid: missing required fields yield { content: 'Invalid plan', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SubmitPlan, { steps: [ @@ -228,7 +228,7 @@ describe('PlanningAgent - Unit Tests', () => { // Valid plan yield { content: 'Valid plan', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SubmitPlan, { steps: [ @@ -274,7 +274,7 @@ describe('PlanningAgent - Unit Tests', () => { // Submit plan on retry yield { content: 'Plan ready', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SubmitPlan, { steps: [ @@ -310,15 +310,15 @@ describe('PlanningAgent - Unit Tests', () => { content: 'Search for relevant notes' })); - let functionCallCount = 0; + let toolCallCount = 0; mockAI.streamRequest.mockImplementation(async function* () { - functionCallCount++; - if (functionCallCount === 1) { + toolCallCount++; + if (toolCallCount === 1) { // Ask user question yield { content: 'Question', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.AskUserQuestionPlanning, { question: 'What topic should I search for?', @@ -332,7 +332,7 @@ describe('PlanningAgent - Unit Tests', () => { // Submit plan with user's answer incorporated yield { content: 'Plan with answer', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SubmitPlan, { steps: [ @@ -354,7 +354,7 @@ describe('PlanningAgent - Unit Tests', () => { expect(callbacks.onUserQuestion).toHaveBeenCalledWith('What topic should I search for?'); expect(result).toBeDefined(); - expect(functionCallCount).toBe(2); + expect(toolCallCount).toBe(2); }); it('should handle multiple user questions in planning', async () => { @@ -369,14 +369,14 @@ describe('PlanningAgent - Unit Tests', () => { content: 'Organize files' })); - let functionCallCount = 0; + let toolCallCount = 0; mockAI.streamRequest.mockImplementation(async function* () { - functionCallCount++; - if (functionCallCount === 1) { + toolCallCount++; + if (toolCallCount === 1) { yield { content: 'Q1', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.AskUserQuestionPlanning, { question: 'What file type?', @@ -386,10 +386,10 @@ describe('PlanningAgent - Unit Tests', () => { ), isComplete: true }; - } else if (functionCallCount === 2) { + } else if (toolCallCount === 2) { yield { content: 'Q2', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.AskUserQuestionPlanning, { question: 'Which folder?', @@ -402,7 +402,7 @@ describe('PlanningAgent - Unit Tests', () => { } else { yield { content: 'Plan', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SubmitPlan, { steps: [ @@ -442,7 +442,7 @@ describe('PlanningAgent - Unit Tests', () => { // Invalid: missing question yield { content: 'Invalid', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.AskUserQuestionPlanning, { // Missing question field @@ -456,7 +456,7 @@ describe('PlanningAgent - Unit Tests', () => { // Valid plan yield { content: 'Plan', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SubmitPlan, { steps: [ @@ -496,7 +496,7 @@ describe('PlanningAgent - Unit Tests', () => { searchCalled = true; yield { content: 'Searching', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SearchVaultFiles, { search_terms: ['test'], @@ -509,7 +509,7 @@ describe('PlanningAgent - Unit Tests', () => { } else { yield { content: 'Plan', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SubmitPlan, { steps: [ @@ -548,7 +548,7 @@ describe('PlanningAgent - Unit Tests', () => { readCalled = true; yield { content: 'Reading', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.ReadVaultFiles, { file_paths: ['test.md'], @@ -561,7 +561,7 @@ describe('PlanningAgent - Unit Tests', () => { } else { yield { content: 'Plan', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SubmitPlan, { steps: [ @@ -601,7 +601,7 @@ describe('PlanningAgent - Unit Tests', () => { // Try to write file (not allowed in planning) yield { content: 'Writing', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.WriteVaultFile, { file_path: 'test.md', @@ -615,7 +615,7 @@ describe('PlanningAgent - Unit Tests', () => { // Submit valid plan yield { content: 'Plan', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SubmitPlan, { steps: [ @@ -659,7 +659,7 @@ describe('PlanningAgent - Unit Tests', () => { // Try to complete task (execution agent tool) yield { content: 'Completing', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteTask, { success: true, @@ -672,7 +672,7 @@ describe('PlanningAgent - Unit Tests', () => { } else { yield { content: 'Plan', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SubmitPlan, { steps: [ @@ -711,7 +711,7 @@ describe('PlanningAgent - Unit Tests', () => { // Try to complete step (orchestration agent tool) yield { content: 'Completing', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.CompleteStep, { confirm_completion: true @@ -723,7 +723,7 @@ describe('PlanningAgent - Unit Tests', () => { } else { yield { content: 'Plan', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SubmitPlan, { steps: [ @@ -796,7 +796,7 @@ describe('PlanningAgent - Unit Tests', () => { // Submit plan on third attempt (just before max depth) yield { content: 'Plan', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SubmitPlan, { steps: [ @@ -834,7 +834,7 @@ describe('PlanningAgent - Unit Tests', () => { // Empty plan is valid according to schema yield { content: 'Empty plan', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SubmitPlan, { steps: [] @@ -883,7 +883,7 @@ describe('PlanningAgent - Unit Tests', () => { if (hasRetryMessage) { yield { content: 'Plan', - functionCall: new AIToolCall( + toolCall: new AIToolCall( AITool.SubmitPlan, { steps: [ diff --git a/__tests__/Services/StreamingService.test.ts b/__tests__/Services/StreamingService.test.ts index 20ead2e..bb1b790 100644 --- a/__tests__/Services/StreamingService.test.ts +++ b/__tests__/Services/StreamingService.test.ts @@ -407,7 +407,7 @@ describe('StreamingService', () => { it('should pass function call from parser', async () => { const chunks = [ - 'data: {"content":"","done":false,"functionCall":{"name":"test_func","args":{}}}\n', + 'data: {"content":"","done":false,"toolCall":{"name":"test_func","args":{}}}\n', 'data: {"content":"Done","done":true}\n' ]; @@ -416,12 +416,12 @@ describe('StreamingService', () => { body: createMockStream(chunks) }); - const parserWithFunctionCall = (chunk: string): IStreamChunk => { + const parserWithToolCall = (chunk: string): IStreamChunk => { const data = JSON.parse(chunk); return { content: data.content || '', isComplete: data.done || false, - functionCall: data.functionCall + toolCall: data.toolCall }; }; @@ -429,12 +429,12 @@ describe('StreamingService', () => { for await (const chunk of service.streamRequest( 'https://api.example.com/stream', {}, - parserWithFunctionCall + parserWithToolCall )) { results.push(chunk); } - expect(results[0].functionCall).toEqual({ name: 'test_func', args: {} }); + expect(results[0].toolCall).toEqual({ name: 'test_func', args: {} }); }); });