/** * BootStatus union + transitions (API §2). The provider's boot state machine: * `connecting → ready` (with the resolved runtime) or `connecting → error`. The * reducer is the single transition table children render behind. */ import type { ShellRuntime } from '../session.context.js' export type BootStatus = 'connecting' | 'ready' | 'error' export interface BootState { readonly status: BootStatus readonly error: unknown readonly runtime: ShellRuntime | null } export type BootAction = | { readonly type: 'connecting' } | { readonly type: 'ready'; readonly runtime: ShellRuntime } | { readonly type: 'error'; readonly error: unknown } export const INITIAL_BOOT: BootState = { status: 'connecting', error: undefined, runtime: null } export function bootReducer(state: BootState, action: BootAction): BootState { switch (action.type) { case 'connecting': return state.status === 'connecting' && state.runtime === null ? state : INITIAL_BOOT case 'ready': return { status: 'ready', error: undefined, runtime: action.runtime } case 'error': return { status: 'error', error: action.error, runtime: null } } }