@@ -36,6 +36,7 @@ import { runtimeHintValues } from '../session-runtime.ts';
3636import { closeDaemonServers } from './server-shutdown.ts' ;
3737import type { DaemonInvokeFn } from '../daemon-request.ts' ;
3838import type { SessionRef , SessionState } from '../session-state.ts' ;
39+ import type { RuntimeHintValues } from '@agent-device/contracts/application-lifecycle-runtime' ;
3940import { createDaemonIdleReap } from './daemon-idle-reap.ts' ;
4041import { createSessionIdleExpiry } from './daemon-session-idle-expiry.ts' ;
4142import { resolveSessionIdleExpiryMs } from '../session-idle-expiry.ts' ;
@@ -137,7 +138,10 @@ export async function teardownDaemonSessionForShutdown(params: {
137138 sessionStore : SessionStore ;
138139 stateDir ?: string ;
139140 stderr : WritableOutput ;
140- finalizeApplicationLifecycle ?: ( session : SessionState ) => Promise < void > ;
141+ finalizeApplicationLifecycle ?: (
142+ session : SessionState ,
143+ runtimeHints : RuntimeHintValues ,
144+ ) => Promise < void > ;
141145 beforeDelete ?: ( session : SessionState ) => Promise < void > ;
142146 afterSuccessfulTeardown ?: ( session : SessionState ) => Promise < void > ;
143147} ) : Promise < void > {
@@ -150,7 +154,11 @@ export async function teardownDaemonSessionForShutdown(params: {
150154 beforeDelete,
151155 afterSuccessfulTeardown,
152156 } = params ;
153- const session = sessionStore . resolveCurrent ( ref ) ?? ref . session ;
157+ const current = sessionStore . resolveCurrent ( ref ) ;
158+ const session = current ?? ref . session ;
159+ const runtimeHints = runtimeHintValues (
160+ current ? sessionStore . getRuntimeHints ( ref . address ) : undefined ,
161+ ) ;
154162 const timeoutMs = resolveDaemonSessionTeardownTimeoutMs ( session ) ;
155163 // The ownership-fenced app-log side effect must settle while this process
156164 // still owns the daemon lock. It is intentionally outside the generic
@@ -182,7 +190,8 @@ export async function teardownDaemonSessionForShutdown(params: {
182190 session,
183191 stderr,
184192 resource : 'lifecycle' ,
185- teardown : async ( ) => await finalizeApplicationLifecycle ( sessionAfterAppLog ) ,
193+ teardown : async ( ) =>
194+ await finalizeApplicationLifecycle ( sessionAfterAppLog , runtimeHints ) ,
186195 } )
187196 : true ;
188197 return genericTeardownSucceeded && lifecycleTeardownSucceeded ;
@@ -458,13 +467,12 @@ export async function startDaemonRuntime(
458467
459468 const teardownDaemonSession = async ( ref : SessionRef ) : Promise < void > => {
460469 const session = sessionStore . resolveCurrent ( ref ) ?? ref . session ;
461- const runtimeHints = runtimeHintValues ( sessionStore . getRuntimeHints ( ref . address ) ) ;
462470 try {
463471 await teardownDaemonSessionForShutdown ( {
464472 ref,
465473 sessionStore,
466474 stderr,
467- finalizeApplicationLifecycle : async ( sessionToFinalize ) =>
475+ finalizeApplicationLifecycle : async ( sessionToFinalize , runtimeHints ) =>
468476 await finalizeDaemonSessionApplicationLifecycle ( {
469477 gateway : deviceRuntimeGateway ,
470478 scope : createDaemonRecoveryPlatformScope ( ) ,
0 commit comments