@@ -94,6 +94,12 @@ export type PlaybookAgentPick = {
9494 identityMismatch : boolean ;
9595} ;
9696
97+ export type PlaybookReadiness =
98+ | { status : "ready" ; playbookId : string ; remoteAgentId : string }
99+ | { status : "missing" ; playbookId : string ; reason : "not_provisioned" }
100+ | { status : "unknown" ; playbookId : string ; reason : "not_checked" | "check_failed" }
101+ | { status : "blocked" ; playbookId : string ; reason : "identity_mismatch" ; message : string } ;
102+
97103// ---------------------------------------------------------------------------
98104// Identity-mismatch error
99105// ---------------------------------------------------------------------------
@@ -135,6 +141,21 @@ export function pickPlaybookAgent(
135141 return { agent, duplicates, identityMismatch : false } ;
136142}
137143
144+ // The single source of the pick-to-readiness mapping, so identity-drift
145+ // handling lives in one place.
146+ export function readinessFromPick ( pick : PlaybookAgentPick , playbookId : string ) : PlaybookReadiness {
147+ if ( pick . identityMismatch ) {
148+ return {
149+ status : "blocked" ,
150+ playbookId,
151+ reason : "identity_mismatch" ,
152+ message : playbookIdentityMismatchMessage ( playbookId ) ,
153+ } ;
154+ }
155+ if ( ! pick . agent ) return { status : "missing" , playbookId, reason : "not_provisioned" } ;
156+ return { status : "ready" , playbookId, remoteAgentId : pick . agent . id } ;
157+ }
158+
138159// ---------------------------------------------------------------------------
139160// Dependency contract (concrete types, no generics)
140161// ---------------------------------------------------------------------------
0 commit comments