@@ -11,7 +11,7 @@ export enum AgentStatus {
11
11
}
12
12
13
13
export interface Agent {
14
- id : string ;
14
+ agentId : string ;
15
15
status : AgentStatus ;
16
16
startTime : Date ;
17
17
endTime ?: Date ;
@@ -22,7 +22,7 @@ export interface Agent {
22
22
23
23
// Internal agent state tracking (similar to existing agentStates)
24
24
export interface AgentState {
25
- id : string ;
25
+ agentId : string ;
26
26
goal : string ;
27
27
prompt : string ;
28
28
output : string ;
@@ -45,32 +45,32 @@ export class AgentTracker {
45
45
46
46
// Register a new agent
47
47
public registerAgent ( goal : string ) : string {
48
- const id = uuidv4 ( ) ;
48
+ const agentId = uuidv4 ( ) ;
49
49
50
50
// Create agent tracking entry
51
51
const agent : Agent = {
52
- id ,
52
+ agentId : agentId ,
53
53
status : AgentStatus . RUNNING ,
54
54
startTime : new Date ( ) ,
55
55
goal,
56
56
} ;
57
57
58
- this . agents . set ( id , agent ) ;
59
- return id ;
58
+ this . agents . set ( agentId , agent ) ;
59
+ return agentId ;
60
60
}
61
61
62
62
// Register agent state
63
- public registerAgentState ( id : string , state : AgentState ) : void {
64
- this . agentStates . set ( id , state ) ;
63
+ public registerAgentState ( agentId : string , state : AgentState ) : void {
64
+ this . agentStates . set ( agentId , state ) ;
65
65
}
66
66
67
67
// Update agent status
68
68
public updateAgentStatus (
69
- id : string ,
69
+ agentId : string ,
70
70
status : AgentStatus ,
71
71
metadata ?: { result ?: string ; error ?: string } ,
72
72
) : boolean {
73
- const agent = this . agents . get ( id ) ;
73
+ const agent = this . agents . get ( agentId ) ;
74
74
if ( ! agent ) {
75
75
return false ;
76
76
}
@@ -94,13 +94,13 @@ export class AgentTracker {
94
94
}
95
95
96
96
// Get a specific agent state
97
- public getAgentState ( id : string ) : AgentState | undefined {
98
- return this . agentStates . get ( id ) ;
97
+ public getAgentState ( agentId : string ) : AgentState | undefined {
98
+ return this . agentStates . get ( agentId ) ;
99
99
}
100
100
101
101
// Get a specific agent tracking info
102
- public getAgent ( id : string ) : Agent | undefined {
103
- return this . agents . get ( id ) ;
102
+ public getAgent ( agentId : string ) : Agent | undefined {
103
+ return this . agents . get ( agentId ) ;
104
104
}
105
105
106
106
// Get all agents with optional filtering
@@ -118,12 +118,12 @@ export class AgentTracker {
118
118
* Get list of active agents with their descriptions
119
119
*/
120
120
public getActiveAgents ( ) : Array < {
121
- id : string ;
121
+ agentId : string ;
122
122
description : string ;
123
123
status : AgentStatus ;
124
124
} > {
125
125
return this . getAgents ( AgentStatus . RUNNING ) . map ( ( agent ) => ( {
126
- id : agent . id ,
126
+ agentId : agent . agentId ,
127
127
description : agent . goal ,
128
128
status : agent . status ,
129
129
} ) ) ;
@@ -134,14 +134,14 @@ export class AgentTracker {
134
134
const runningAgents = this . getAgents ( AgentStatus . RUNNING ) ;
135
135
136
136
await Promise . all (
137
- runningAgents . map ( ( agent ) => this . terminateAgent ( agent . id ) ) ,
137
+ runningAgents . map ( ( agent ) => this . terminateAgent ( agent . agentId ) ) ,
138
138
) ;
139
139
}
140
140
141
141
// Terminate a specific agent
142
- public async terminateAgent ( id : string ) : Promise < void > {
142
+ public async terminateAgent ( agentId : string ) : Promise < void > {
143
143
try {
144
- const agentState = this . agentStates . get ( id ) ;
144
+ const agentState = this . agentStates . get ( agentId ) ;
145
145
if ( agentState && ! agentState . aborted ) {
146
146
// Set the agent as aborted and completed
147
147
agentState . aborted = true ;
@@ -152,9 +152,9 @@ export class AgentTracker {
152
152
await agentState . context . shellTracker . cleanup ( ) ;
153
153
await agentState . context . browserTracker . cleanup ( ) ;
154
154
}
155
- this . updateAgentStatus ( id , AgentStatus . TERMINATED ) ;
155
+ this . updateAgentStatus ( agentId , AgentStatus . TERMINATED ) ;
156
156
} catch ( error ) {
157
- this . updateAgentStatus ( id , AgentStatus . ERROR , {
157
+ this . updateAgentStatus ( agentId , AgentStatus . ERROR , {
158
158
error : error instanceof Error ? error . message : String ( error ) ,
159
159
} ) ;
160
160
}
0 commit comments