{"version":3,"file":"transition.cjs","names":["DOOM_MINOR_MODE_CATALOG_SERVICE"],"sources":["../../src/schemas/transition.ts"],"sourcesContent":["import type { Context } from '@deepseek-ai/cordis';\nimport {\n  DOOM_MINOR_MODE_CATALOG_SERVICE,\n  type MinorModeActionRequest,\n  type MinorModeCatalogService,\n  type MinorModeCatalogSnapshot,\n} from './mode.ts';\n\nexport type TransitionAxis = 'domains' | 'major-mode' | 'minor-mode' | 'profile';\n\nexport type TransitionDisposition = 'live' | 'reload' | 'relaunch' | 'sync-required';\n\nexport type TransitionExecutionStrategy = 'pi-reload' | 'process-relaunch';\n\nexport type TransitionOutcome = 'applied' | 'queued' | 'unchanged' | 'rejected' | 'stale';\n\nexport type TransitionSource = 'voice' | 'command' | 'leader' | 'ui' | 'system';\n\n/** Runtime identities captured when a transition enters the serialized queue. */\nexport interface TransitionGeneration {\n  readonly sessionId: string;\n  readonly hostGeneration: string;\n  readonly configGeneration?: string;\n}\n\nexport interface TransitionSelectionSnapshot {\n  readonly domains: readonly string[];\n  readonly majorMode: string;\n  readonly layers: readonly string[];\n  readonly profile?: string;\n  readonly compositionFingerprint?: string;\n  readonly parentActivation?: readonly string[];\n  readonly childActivation?: readonly string[];\n  readonly minorModes?: MinorModeCatalogSnapshot;\n}\n\nexport interface DomainTransitionTarget {\n  readonly axis: 'domains';\n  readonly domains: readonly string[];\n}\n\nexport interface MajorModeTransitionTarget {\n  readonly axis: 'major-mode';\n  readonly majorMode: string;\n}\n\nexport interface MinorModeTransitionTarget {\n  readonly axis: 'minor-mode';\n  readonly action: MinorModeActionRequest;\n  readonly requesterSource: string;\n}\n\nexport interface ProfileTransitionTarget {\n  readonly axis: 'profile';\n  readonly profile: string;\n}\n\nexport type TransitionTarget =\n  | DomainTransitionTarget\n  | MajorModeTransitionTarget\n  | MinorModeTransitionTarget\n  | ProfileTransitionTarget;\n\nexport interface DoomTransitionRequest {\n  readonly sessionId: string;\n  readonly hostGeneration: string;\n  readonly operationId: string;\n  readonly source: TransitionSource;\n  readonly target: TransitionTarget;\n  readonly signal?: AbortSignal;\n}\n\nexport type TransitionSynchronization =\n  | { readonly kind: 'launcher' }\n  /**\n   * A launcher session whose Pi entry resolves its composition on every load.\n   *\n   * Pi freezes the CLI extension list at construction, so a session handed a\n   * fingerprint-named bundle cannot change composition without a new process.\n   * One entry that reads the selection when its factory runs lifts that limit:\n   * the list Pi holds never changes, and a reload composes again. Such a\n   * session is never `sync-required`, because the entry falls back to the\n   * individual extension paths when no aggregate has been built yet.\n   */\n  | { readonly kind: 'launcher-composed' }\n  | {\n      readonly kind: 'synchronized';\n      readonly resolutionAvailable: boolean;\n      readonly availableCompositionFingerprints: readonly string[];\n    };\n\nexport type TransitionDiagnosticCode =\n  | 'transition.live.minor-mode'\n  | 'transition.no-change'\n  | 'transition.reload.domains'\n  | 'transition.reload.major-mode'\n  | 'transition.reload.profile'\n  | 'transition.rejected.aborted'\n  | 'transition.rejected.duplicate'\n  | 'transition.rejected.execution'\n  | 'transition.rejected.unavailable'\n  | 'transition.relaunch.extension-closure'\n  | 'transition.stale.generation'\n  | 'transition.stale.config'\n  | 'transition.stale.session'\n  | 'transition.sync-required.artifact'\n  | 'transition.sync-required.resolution';\n\nexport interface DoomTransitionPlan {\n  readonly operationId: string;\n  readonly axis: TransitionAxis;\n  readonly disposition: TransitionDisposition;\n  readonly strategy?: TransitionExecutionStrategy;\n  readonly previous: TransitionSelectionSnapshot;\n  readonly candidate: TransitionSelectionSnapshot;\n  readonly diagnostics: readonly TransitionDiagnosticCode[];\n  readonly reloadHandoffRequired: boolean;\n  readonly externalRelaunchRequired: boolean;\n}\n\nexport interface DoomTransitionResult extends DoomTransitionPlan {\n  readonly outcome: TransitionOutcome;\n}\n\nexport type StructuralTransitionExecution = (\n  request: DoomTransitionRequest,\n  plan: DoomTransitionPlan,\n) => Promise<TransitionOutcome>;\n\n/** Cordis service name the DoomPi host publishes its transition coordinator under. */\nexport const DOOM_TRANSITION_SERVICE = 'doom/transition';\n/** Cordis service name the DoomPi host publishes its minor-mode catalog under. */\nexport const MINOR_MODE_CATALOG_SERVICE = DOOM_MINOR_MODE_CATALOG_SERVICE;\n\n/**\n * The session-scoped object that serializes structural transitions.\n *\n * Declared here rather than beside its implementation because the packages that\n * drive the selection axes resolve it from the session and must not depend on\n * the host that builds it. plan() is deliberately synchronous and the result\n * carries live values, so this contract is an in-process handle, not a wire\n * protocol.\n */\nexport interface DoomTransitionCoordinator {\n  readonly sessionId: string;\n  readonly hostGeneration: string;\n  plan(request: DoomTransitionRequest): DoomTransitionPlan;\n  execute(\n    request: DoomTransitionRequest,\n    executeStructural?: StructuralTransitionExecution,\n  ): Promise<DoomTransitionResult>;\n  attachMinorModeCatalog(catalog: MinorModeCatalogHost): () => void;\n  dispose(): void;\n}\n\n/** The session-scoped minor-mode registry the coordinator routes actions through. */\nexport type MinorModeCatalogHost = MinorModeCatalogService;\n\n/**\n * Typed reads of the two host services off the session's cordis registry.\n *\n * Optional reads use Cordis's public `ctx.get()` surface. Hard consumers should\n * declare the corresponding service name with `ctx.inject()` before reading it.\n */\nexport function readDoomTransitionCoordinator(root: Context): DoomTransitionCoordinator | undefined {\n  return root.get(DOOM_TRANSITION_SERVICE) as DoomTransitionCoordinator | undefined;\n}\n\nexport function readMinorModeCatalogHost(root: Context): MinorModeCatalogHost | undefined {\n  return root.get(MINOR_MODE_CATALOG_SERVICE) as MinorModeCatalogHost | undefined;\n}\n\n/**\n * The coordinator for an injected Cordis context.\n */\nexport function requireDoomTransitionCoordinator(context: Context): DoomTransitionCoordinator {\n  const coordinator = readDoomTransitionCoordinator(context);\n  if (!coordinator) throw new Error('Doom transition coordinator is unavailable. Load the DoomPi parent runtime.');\n  return coordinator;\n}\n"],"mappings":"8BAkIa,EAA0B,kBAE1B,EAA6BA,EAAAA,gCAgC1C,SAAgB,EAA8B,EAAsD,CAClG,OAAO,EAAK,IAAI,CAAuB,CACzC,CAEA,SAAgB,EAAyB,EAAiD,CACxF,OAAO,EAAK,IAAI,CAA0B,CAC5C,CAKA,SAAgB,EAAiC,EAA6C,CAC5F,IAAM,EAAc,EAA8B,CAAO,EACzD,GAAI,CAAC,EAAa,MAAU,MAAM,6EAA6E,EAC/G,OAAO,CACT"}