@@ -272,6 +272,8 @@ function getTaskRunStateString(
272272export class AgentServer {
273273 private config : AgentServerConfig ;
274274 private sessionReadyBootMs ?: number ;
275+ private sessionInitMs ?: number ;
276+ private barrierReleasedAtMs ?: number ;
275277 private logger : Logger ;
276278 private server : ServerType | null = null ;
277279 private session : ActiveSession | null = null ;
@@ -394,6 +396,7 @@ export class AgentServer {
394396 status : "ok" ,
395397 hasSession : ! ! this . session ,
396398 bootMs : this . sessionReadyBootMs ,
399+ sessionInitMs : this . sessionInitMs ,
397400 } ) ;
398401 } ) ;
399402
@@ -1297,8 +1300,10 @@ export class AgentServer {
12971300 } ) ;
12981301
12991302 this . sessionReadyBootMs = Math . round ( process . uptime ( ) * 1000 ) ;
1303+ this . sessionInitMs = Math . max ( 0 , Date . now ( ) - this . barrierReleasedAtMs ! ) ;
13001304 this . logger . debug ( "Session initialized successfully" , {
13011305 bootMs : this . sessionReadyBootMs ,
1306+ sessionInitMs : this . sessionInitMs ,
13021307 } ) ;
13031308 this . logger . debug (
13041309 `Agent version: ${ this . config . version ?? packageJson . version } ` ,
@@ -2222,7 +2227,10 @@ export class AgentServer {
22222227
22232228 private async waitForRepoReady ( ) : Promise < void > {
22242229 const readyFile = this . config . repoReadyFile ;
2225- if ( ! readyFile ) return ;
2230+ if ( ! readyFile ) {
2231+ this . barrierReleasedAtMs = Date . now ( ) ;
2232+ return ;
2233+ }
22262234
22272235 const REPO_READY_TIMEOUT_MS = 5 * 60_000 ;
22282236 const POLL_MS = 100 ;
@@ -2232,6 +2240,7 @@ export class AgentServer {
22322240 for ( ; ; ) {
22332241 try {
22342242 await access ( readyFile ) ;
2243+ this . barrierReleasedAtMs = Date . now ( ) ;
22352244 this . logger . debug ( "Repo-ready barrier released" , {
22362245 readyFile,
22372246 waitedMs : Date . now ( ) - startedAt ,
@@ -2249,6 +2258,7 @@ export class AgentServer {
22492258 }
22502259 }
22512260 if ( Date . now ( ) - startedAt > REPO_READY_TIMEOUT_MS ) {
2261+ this . barrierReleasedAtMs = Date . now ( ) ;
22522262 this . logger . warn ( "Repo-ready barrier timed out; proceeding" , {
22532263 readyFile,
22542264 waitedMs : Date . now ( ) - startedAt ,
0 commit comments