@@ -92,6 +92,7 @@ type LocalManagedDeploymentAuthority =
9292 | {
9393 readonly kind : 'active' ;
9494 readonly lifecycleMode : 'on_demand' | 'supervised' ;
95+ readonly deploymentRoot : string ;
9596 readonly target : LocalServiceTarget ;
9697 }
9798 | { readonly kind : 'transition' } ;
@@ -205,6 +206,7 @@ export function createDesktopLocalRuntimeHostRemoteAccess(input: {
205206 return {
206207 kind : 'active' ,
207208 lifecycleMode : authority . record . lifecycle . mode ,
209+ deploymentRoot : authority . record . deploymentRoot ,
208210 target : requireServiceTarget (
209211 {
210212 schemaVersion : 2 ,
@@ -223,15 +225,24 @@ export function createDesktopLocalRuntimeHostRemoteAccess(input: {
223225 } ) ;
224226
225227 const adoptCommittedSetup = async (
226- setup : LocalServiceSetupPending ,
228+ setup : LocalServiceSetupPending | LocalServiceLegacyHandoff ,
227229 ) : Promise <
228230 | { readonly kind : 'absent' | 'transition' }
229231 | { readonly kind : 'managed' ; readonly managed : LocalServiceManaged }
230232 > => {
231233 const authority = await resolveManagedDeploymentAuthority ( setup . rootId ) ;
232234 if ( ! authority ) return { kind : 'absent' } ;
233235 if ( authority . kind === 'transition' ) return authority ;
234- const managed = managedLifecycle ( authority . target ) ;
236+ const target =
237+ setup . schemaVersion === 1
238+ ? {
239+ ...authority . target ,
240+ operator : createRuntimeHostLegacyPosixOperatorCommand (
241+ join ( authority . deploymentRoot , 'operator' ) ,
242+ ) ,
243+ }
244+ : authority . target ;
245+ const managed = managedLifecycle ( target ) ;
235246 await writeDocument ( lifecyclePath , managed ) ;
236247 return { kind : 'managed' , managed } ;
237248 } ;
@@ -472,7 +483,7 @@ export function createDesktopLocalRuntimeHostRemoteAccess(input: {
472483 | { readonly kind : 'complete' ; readonly managed : LocalServiceManaged }
473484 > => {
474485 const pending = pendingSetup ( legacy ) ;
475- const authority = await adoptCommittedSetup ( pending ) ;
486+ const authority = await adoptCommittedSetup ( legacy ) ;
476487 if ( authority . kind === 'managed' ) {
477488 return { kind : 'complete' , managed : authority . managed } ;
478489 }
@@ -487,7 +498,7 @@ export function createDesktopLocalRuntimeHostRemoteAccess(input: {
487498 ) ;
488499 if ( retirement . kind === 'active_tasks' ) return { kind : 'active_tasks' } ;
489500 if ( retirement . kind === 'not_owned' ) {
490- const raced = await adoptCommittedSetup ( pending ) ;
501+ const raced = await adoptCommittedSetup ( legacy ) ;
491502 if ( raced . kind === 'managed' ) {
492503 return { kind : 'complete' , managed : raced . managed } ;
493504 }
@@ -857,7 +868,7 @@ export function createDesktopLocalRuntimeHostRemoteAccess(input: {
857868 const pending = await readLifecycle ( lifecyclePath , input . rootPath , input . rootId ) ;
858869 if ( pending ?. state !== 'setupPending' && pending ?. state !== 'handoff' ) return false ;
859870 const current = pendingSetup ( pending ) ;
860- const authority = await adoptCommittedSetup ( current ) ;
871+ const authority = await adoptCommittedSetup ( pending ) ;
861872 if ( authority . kind === 'absent' ) return false ;
862873 if ( authority . kind === 'managed' ) return true ;
863874 if ( pending . state === 'handoff' ) await writeDocument ( lifecyclePath , current ) ;
@@ -882,7 +893,7 @@ export function createDesktopLocalRuntimeHostRemoteAccess(input: {
882893 return ;
883894 }
884895 if ( lifecycle . state === 'handoff' || lifecycle . state === 'setupPending' ) {
885- const committed = await adoptCommittedSetup ( pendingSetup ( lifecycle ) ) ;
896+ const committed = await adoptCommittedSetup ( lifecycle ) ;
886897 if ( committed . kind === 'managed' ) return ;
887898 if ( ! supported ( input . directPeerAvailable ) ) return ;
888899 if ( lifecycle . state === 'handoff' ) await recoverLegacyHandoff ( lifecycle ) ;
0 commit comments