11import { describe , it , expect , vi , beforeEach , afterEach } from 'vitest' ;
22
3- import { Logger , LogLevel , LoggerListener } from '../../../utils/logger.js' ;
3+ import { Logger } from '../../../utils/logger.js' ;
44import { agentMessageTool } from '../agentMessage.js' ;
55import { agentStartTool } from '../agentStart.js' ;
6- import { AgentTracker , AgentState } from '../AgentTracker.js' ;
6+ import { AgentTracker } from '../AgentTracker.js' ;
77
88// Mock the toolAgent function
99vi . mock ( '../../../core/toolAgent/toolAgentCore.js' , ( ) => ( {
@@ -12,33 +12,6 @@ vi.mock('../../../core/toolAgent/toolAgentCore.js', () => ({
1212 . mockResolvedValue ( { result : 'Test result' , interactions : 1 } ) ,
1313} ) ) ;
1414
15- // Create a real implementation of the log capture function
16- const createLogCaptureListener = ( agentState : AgentState ) : LoggerListener => {
17- return ( logger , logLevel , lines ) => {
18- // Only capture log, warn, and error levels (not debug or info)
19- if (
20- logLevel === LogLevel . log ||
21- logLevel === LogLevel . warn ||
22- logLevel === LogLevel . error
23- ) {
24- // Only capture logs from the agent and its immediate tools (not deeper than that)
25- if ( logger . nesting <= 1 ) {
26- const logPrefix =
27- logLevel === LogLevel . warn
28- ? '[WARN] '
29- : logLevel === LogLevel . error
30- ? '[ERROR] '
31- : '' ;
32-
33- // Add each line to the capturedLogs array
34- lines . forEach ( ( line ) => {
35- agentState . capturedLogs . push ( `${ logPrefix } ${ line } ` ) ;
36- } ) ;
37- }
38- }
39- } ;
40- } ;
41-
4215describe ( 'Log Capture in AgentTracker' , ( ) => {
4316 let agentTracker : AgentTracker ;
4417 let logger : Logger ;
@@ -78,20 +51,14 @@ describe('Log Capture in AgentTracker', () => {
7851
7952 if ( ! agentState ) return ; // TypeScript guard
8053
81- // Create a tool logger that is a child of the agent logger
82- const toolLogger = new Logger ( {
83- name : 'tool-logger' ,
84- parent : context . logger ,
85- } ) ;
86-
8754 // For testing purposes, manually add logs to the agent state
8855 // In a real scenario, these would be added by the log listener
8956 agentState . capturedLogs = [
9057 'This log message should be captured' ,
9158 '[WARN] This warning message should be captured' ,
9259 '[ERROR] This error message should be captured' ,
9360 'This tool log message should be captured' ,
94- '[WARN] This tool warning message should be captured'
61+ '[WARN] This tool warning message should be captured' ,
9562 ] ;
9663
9764 // Check that the right messages were captured
0 commit comments