1
1
import { describe , it , expect , vi , beforeEach , afterEach } from 'vitest' ;
2
2
3
- import { Logger , LogLevel , LoggerListener } from '../../../utils/logger.js' ;
3
+ import { Logger } from '../../../utils/logger.js' ;
4
4
import { agentMessageTool } from '../agentMessage.js' ;
5
5
import { agentStartTool } from '../agentStart.js' ;
6
- import { AgentTracker , AgentState } from '../AgentTracker.js' ;
6
+ import { AgentTracker } from '../AgentTracker.js' ;
7
7
8
8
// Mock the toolAgent function
9
9
vi . mock ( '../../../core/toolAgent/toolAgentCore.js' , ( ) => ( {
@@ -12,33 +12,6 @@ vi.mock('../../../core/toolAgent/toolAgentCore.js', () => ({
12
12
. mockResolvedValue ( { result : 'Test result' , interactions : 1 } ) ,
13
13
} ) ) ;
14
14
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
-
42
15
describe ( 'Log Capture in AgentTracker' , ( ) => {
43
16
let agentTracker : AgentTracker ;
44
17
let logger : Logger ;
@@ -78,20 +51,14 @@ describe('Log Capture in AgentTracker', () => {
78
51
79
52
if ( ! agentState ) return ; // TypeScript guard
80
53
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
-
87
54
// For testing purposes, manually add logs to the agent state
88
55
// In a real scenario, these would be added by the log listener
89
56
agentState . capturedLogs = [
90
57
'This log message should be captured' ,
91
58
'[WARN] This warning message should be captured' ,
92
59
'[ERROR] This error message should be captured' ,
93
60
'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' ,
95
62
] ;
96
63
97
64
// Check that the right messages were captured
0 commit comments