@@ -14,6 +14,7 @@ export const STOP_REQUEST_SCHEMA = 'priority/runtime-stop-request@v1';
1414export const BLOCKER_SCHEMA = 'priority/runtime-blocker@v1' ;
1515export const SCHEDULER_DECISION_SCHEMA = 'priority/runtime-scheduler-decision@v1' ;
1616export const WORKER_CHECKOUT_SCHEMA = 'priority/runtime-worker-checkout@v1' ;
17+ export const WORKER_READY_SCHEMA = 'priority/runtime-worker-ready@v1' ;
1718export const DEFAULT_RUNTIME_DIR = path . join ( 'tests' , 'results' , '_agent' , 'runtime' ) ;
1819export const DEFAULT_LEASE_SCOPE = 'workspace' ;
1920export const ACTIONS = new Set ( [ 'status' , 'step' , 'stop' , 'resume' ] ) ;
@@ -280,6 +281,7 @@ export function createRuntimeAdapter(adapter = {}) {
280281 releaseLease : adapter . releaseLease ,
281282 planStep : typeof adapter . planStep === 'function' ? adapter . planStep : null ,
282283 prepareWorker : typeof adapter . prepareWorker === 'function' ? adapter . prepareWorker : null ,
284+ bootstrapWorker : typeof adapter . bootstrapWorker === 'function' ? adapter . bootstrapWorker : null ,
283285 resolveRepository :
284286 typeof adapter . resolveRepository === 'function'
285287 ? adapter . resolveRepository
@@ -309,6 +311,19 @@ function summarizeWorker(workerRecord) {
309311 } ;
310312}
311313
314+ function summarizeWorkerReady ( workerReadyRecord ) {
315+ if ( ! workerReadyRecord ) return null ;
316+ return {
317+ laneId : workerReadyRecord . laneId ,
318+ checkoutPath : workerReadyRecord . checkoutPath ,
319+ status : workerReadyRecord . status ,
320+ bootstrapCommand : workerReadyRecord . bootstrapCommand ,
321+ preparedAt : workerReadyRecord . preparedAt ,
322+ readyAt : workerReadyRecord . readyAt ,
323+ refreshed : Boolean ( workerReadyRecord . refreshed )
324+ } ;
325+ }
326+
312327function normalizeWorkerRecord ( worker , now ) {
313328 if ( ! worker || typeof worker !== 'object' ) return null ;
314329 const checkoutPath = normalizeText ( worker . checkoutPath ) || null ;
@@ -337,6 +352,36 @@ function normalizeWorkerRecord(worker, now) {
337352 } ;
338353}
339354
355+ function normalizeWorkerReadyRecord ( workerReady , now ) {
356+ if ( ! workerReady || typeof workerReady !== 'object' ) return null ;
357+ const laneId = normalizeText ( workerReady . laneId ) || null ;
358+ const checkoutPath = normalizeText ( workerReady . checkoutPath ) || null ;
359+ const status = normalizeText ( workerReady . status ) . toLowerCase ( ) || 'ready' ;
360+ const source = normalizeText ( workerReady . source ) || null ;
361+ const reason = normalizeText ( workerReady . reason ) || null ;
362+ const bootstrapCommand = Array . isArray ( workerReady . bootstrapCommand )
363+ ? workerReady . bootstrapCommand . map ( ( entry ) => String ( entry ) )
364+ : [ ] ;
365+ const bootstrapExitCode = Number . isInteger ( workerReady . bootstrapExitCode ) ? workerReady . bootstrapExitCode : 0 ;
366+ const preparedAt = normalizeText ( workerReady . preparedAt ) || toIso ( now ) ;
367+ const readyAt = normalizeText ( workerReady . readyAt ) || toIso ( now ) ;
368+ const artifacts = workerReady . artifacts && typeof workerReady . artifacts === 'object' ? workerReady . artifacts : { } ;
369+ return {
370+ schema : WORKER_READY_SCHEMA ,
371+ laneId,
372+ checkoutPath,
373+ status,
374+ source,
375+ reason,
376+ bootstrapCommand,
377+ bootstrapExitCode,
378+ preparedAt,
379+ readyAt,
380+ refreshed : workerReady . refreshed === true || status === 'reused' ,
381+ artifacts
382+ } ;
383+ }
384+
340385function buildActiveLaneSummary ( laneRecord ) {
341386 if ( ! laneRecord ) return null ;
342387 return {
@@ -348,6 +393,7 @@ function buildActiveLaneSummary(laneRecord) {
348393 prUrl : laneRecord . prUrl ,
349394 blockerClass : laneRecord . blocker ?. blockerClass ?? 'none' ,
350395 worker : summarizeWorker ( laneRecord . worker ) ,
396+ workerReady : summarizeWorkerReady ( laneRecord . workerReady ) ,
351397 updatedAt : laneRecord . updatedAt
352398 } ;
353399}
@@ -434,6 +480,7 @@ function buildLaneRecord(options, now) {
434480 `lane-${ sanitizeSegment ( options . branch || 'active' ) } ` ;
435481 const blockerClass = options . blockerClass || 'none' ;
436482 const worker = normalizeWorkerRecord ( options . worker , now ) ;
483+ const workerReady = normalizeWorkerReadyRecord ( options . workerReady , now ) ;
437484 return {
438485 schema : LANE_SCHEMA ,
439486 laneId,
@@ -452,6 +499,7 @@ function buildLaneRecord(options, now) {
452499 observedAt : toIso ( now )
453500 } ,
454501 worker,
502+ workerReady,
455503 createdAt : toIso ( now ) ,
456504 updatedAt : toIso ( now )
457505 } ;
@@ -682,6 +730,8 @@ async function runStepAction(context) {
682730 blockerPath,
683731 workerPath : laneRecord ?. worker ?. checkoutPath ?? null ,
684732 workerArtifactPath : laneRecord ?. worker ?. artifacts ?. lanePath ?? null ,
733+ workerReadyPath : laneRecord ?. workerReady ?. artifacts ?. latestPath ?? null ,
734+ workerReadyArtifactPath : laneRecord ?. workerReady ?. artifacts ?. lanePath ?? null ,
685735 statePath : runtimePaths . statePath ,
686736 eventsPath : runtimePaths . eventsPath
687737 }
@@ -705,6 +755,7 @@ async function runStepAction(context) {
705755 report . outcome = outcome ;
706756 report . turnPath = turnPath ;
707757 report . worker = summarizeWorker ( laneRecord ?. worker ) ;
758+ report . workerReady = summarizeWorkerReady ( laneRecord ?. workerReady ) ;
708759 report . state = state ;
709760 } finally {
710761 const leaseId = report . lease ?. acquire ?. leaseId ?? null ;
0 commit comments