/** Shared authoring data boundaries for player-defined ClawClaw modules. */ export interface Position { readonly x: number; readonly y: number; } export interface PlayerRef { readonly seat: number; readonly name: string; } export interface GamePlayerActivity { readonly kind: 'idle' | 'moving' | 'task'; readonly task_name?: string; readonly remaining_secs?: number; readonly target_x?: number; readonly target_y?: number; } export type GameTaskKind = 'ordinary' | 'fake_shrimp' | 'sabotage' | 'emergency'; export interface GameTaskAvailability { readonly state: 'ready' | 'cooldown' | 'blocked' | 'in_progress' | 'completed' | 'unknown'; readonly reason?: 'sabotage_cooldown' | 'emergency_active' | 'sabotage_state_unavailable' | 'task_state_unavailable' | 'player_state_unavailable' | 'not_assigned' | 'not_alive' | 'not_wandering' | 'emergency_inactive' | 'task_in_progress' | 'task_completed'; /** Authoritative shared cooldown, not an SDK wall-clock estimate. */ readonly remaining_secs?: number; } export interface GameTask { /** Stable task identity when the backend provides one. */ readonly task_id?: string; /** Player-facing task name accepted by the task Action. */ readonly name: string; readonly room: string; readonly x: number; readonly y: number; readonly is_fake_shrimp: boolean; readonly status?: 'normal' | 'in_progress' | 'completed'; readonly task_note?: string; /** CCL read projection; does not change the underlying assignment or execution status. */ readonly kind?: GameTaskKind; readonly availability?: Readonly; } export interface GameSelf { readonly player?: Readonly; readonly x?: number; readonly y?: number; readonly room?: string; readonly role?: string; readonly faction?: string; readonly is_alive?: boolean; readonly completed_task_count?: number; readonly kill_cooldown_secs?: number; readonly kills_remaining?: number | null; readonly activity?: Readonly; readonly crab_teammates?: readonly Readonly[]; /** Complete current assignments, including cooldown/blocked tasks and execution/completion facts. */ readonly tasks?: readonly Readonly[]; } export interface VisiblePlayer extends Position { readonly player: Readonly; readonly room: string; readonly distance?: number; readonly is_alive?: boolean; } export interface VisibleCorpse extends Position { /** Stable corpse identity. A corpse may not yet be identifiable as a player. */ readonly corpse_id: string; readonly player?: Readonly; readonly room: string; readonly distance?: number; } export type GameKiller = | Readonly<{ readonly kind: 'player'; readonly player: Readonly }> | Readonly<{ readonly kind: 'system'; readonly name: string }>; export interface KnownPlayer extends PlayerRef { readonly known_status: Readonly<{ readonly is_alive?: boolean; readonly death_cause?: 'killed' | 'exiled'; readonly killer?: GameKiller; readonly reported_in_current_meeting?: boolean; }>; readonly tier?: string; readonly tier_display?: string; } export interface GameEmergency { readonly active: boolean; readonly task_name?: string; readonly room?: string; readonly x?: number; readonly y?: number; readonly remaining_secs?: number | null; } export interface GameCrabSabotage { readonly status: | 'ready' | 'cooldown_charged' | 'emergency_active'; readonly cooldown_remaining_secs?: number; } export interface GameMeeting { readonly active: boolean; readonly sub_phase?: string; readonly caller?: Readonly; readonly speech_order?: readonly Readonly[]; readonly current_speaker?: Readonly; readonly deadline_at_ms?: number; readonly server_time_ms?: number; readonly speeches?: Readonly>; readonly speech_skipped?: readonly number[]; readonly votes_submitted?: readonly number[]; } export interface GameOctopusTime { readonly active: boolean; readonly remaining_secs?: number; } export type GameWinner = | Readonly<{ readonly kind: 'faction'; readonly faction: 'lobster' | 'crab'; }> | Readonly<{ readonly kind: 'neutral'; readonly faction: 'neutral'; readonly player: Readonly; readonly role: 'neutral_octopus' | 'neutral_paradise_fish'; }>; /** * The authoritative, current-player GameSync snapshot. * * It is the only public business-state schema. It is not the Runtime lifecycle * state and it is not an omniscient view of the match. */ export interface GameState { readonly game_id: string; readonly tick: number; /** May be absent only on a degraded frame accepted by the current Runtime. */ readonly phase?: 'preparing' | 'wandering' | 'meeting' | 'game_over'; readonly you?: Readonly; readonly players?: readonly Readonly[]; readonly visible_players?: readonly Readonly[]; readonly visible_corpses?: readonly Readonly[]; readonly task_progress?: Readonly<{ completed: number; goal: number }>; readonly emergency?: Readonly; readonly crab_sabotage?: Readonly; readonly meeting?: Readonly; readonly octopus_time?: Readonly; readonly winner?: Readonly; readonly settlement?: Readonly>; } export interface VisualPosition { readonly x: number; readonly y: number; readonly room: string | null; } export interface VisualPlayer extends VisualPosition { readonly id: string; readonly name?: string; readonly seat?: number; /** True only for the player whose Agent owns this observation stream. */ readonly observer: boolean; readonly alive?: boolean; } export interface VisualCorpse extends VisualPosition { readonly id: string; readonly playerId?: string; readonly name?: string; readonly seat?: number; } /** Visual facts derived from one player-visible Game State. It is not a second State. */ export interface VisualObservation { /** The observer and every other player currently visible to the observer. */ readonly players: readonly VisualPlayer[]; readonly corpses: readonly VisualCorpse[]; /** False means absence cannot be interpreted as leaving the field of view. */ readonly visibleSetComplete: boolean; } /** * One persisted Game State frame plus its visual observation. * * Perception and Trigger receive this same immutable observation boundary and * may compute concurrently. It contains no output from either module family. */ export interface ObservationFrame { /** Stable Source identity of the persisted State frame. */ readonly frameKey: string; /** CCL State History sequence. It is not the game tick. */ readonly frameSeq: number; readonly tick: number; readonly timeMs: number; readonly tickDelta: number | null; readonly continuousFromPrevious: boolean; /** The authoritative player-visible State for this frame. */ readonly gameState: Readonly; /** A derived, visual-only projection of `gameState`; never an independent State. */ readonly observation: Readonly; } export interface GameEvent { readonly eventId: string; readonly epochId?: number; readonly type: string; readonly occurredAt: string; readonly payload: Readonly>; } export interface BehaviorScope { readonly sessionId: string; readonly segmentId: string; } /** Runtime-owned terminal result of a short Behavior delegated by a long Behavior. */ export interface BehaviorDelegatedBehaviorResult { readonly activationId: string; readonly behavior: string; readonly outcome: 'completed' | 'failed' | 'cancelled' | 'replaced'; readonly reason: string; readonly summary?: string; } /** One-shot input delivered when a long Behavior resumes after delegated work. */ export interface BehaviorContinuation { readonly delegatedBehavior: Readonly; } interface BehaviorDecisionActionBase { readonly thinking_content?: string; } /** One credential-free Action proposed by a Behavior Decision. */ export type BehaviorDecisionAction = | (BehaviorDecisionActionBase & { readonly action: 'move'; readonly target: string; readonly target_x?: never; readonly target_y?: never; readonly stop_on_player?: boolean; }) | (BehaviorDecisionActionBase & { readonly action: 'move'; readonly target?: never; readonly target_x: number; readonly target_y: number; readonly stop_on_player?: boolean; }) | (BehaviorDecisionActionBase & { readonly action: 'kill'; readonly target_seat: number }) | (BehaviorDecisionActionBase & { readonly action: 'speech'; readonly text: string }) | (BehaviorDecisionActionBase & { readonly action: 'task'; readonly task_name?: string }) | (BehaviorDecisionActionBase & { readonly action: 'report' }) | (BehaviorDecisionActionBase & { readonly action: 'think' }); export type BehaviorDecisionFrameStatus = 'pending' | 'completed' | 'not_computed' | 'failed'; /** * One activation-local Runtime frame and the Decision result known so far. * `actions` is an array for a completed Decision (including an empty array) * and null when no Decision result exists. */ export interface BehaviorDecisionFrame { readonly epochId: number; readonly tick: number; readonly instanceGeneration: number; readonly status: BehaviorDecisionFrameStatus; readonly actions: readonly Readonly[] | null; readonly reason?: string; } /** The input envelope shared by finite and continuous Behaviors. */ export interface BehaviorInput< TInput extends Readonly> = Readonly>, > { /** Local cadence metadata; backend tick and observation age remain authoritative. */ readonly cycle?: ProcessingCycleInfo; readonly epochId: number; readonly scope: Readonly; /** Runtime-observed time for this accepted input, suitable for deterministic logic. */ readonly nowMs: number; readonly gameState: Readonly; readonly events: readonly Readonly[]; readonly input: Readonly; /** * One immutable snapshot of the current Activation's latest 100 Decision frames. * Current Runtime owners always provide it; optional keeps older author test fixtures source-compatible. */ readonly decisionHistory?: readonly Readonly[]; /** Present for the first committed decision after delegated short work ends. */ readonly continuation?: Readonly; } /** Local call timing and the provenance of the latest backend observation; not a State-history API. */ export type ProcessingCycleInfo = Readonly>;