import type { FactoryRuleHandler, FactoryRuleSource, FactoryStageRuleContext, FactoryToolResultRuleContext } from '../rules/types.js'; import type { BoardTransitionPolicy } from './transition-policy.js'; type BoardPhaseHandlers = Partial>>; type ReadonlyBoardPhaseHandlers = Readonly; /** Runs when an agent seated on this board completes the named tool. */ export type BoardToolResultRuleHandler = FactoryRuleHandler; export type BoardToolRule = { readonly onResult: BoardToolResultRuleHandler; }; export type BoardToolRules = Readonly>; type ReadonlyFactoryBoardRules = Readonly; onExit?: FactoryRuleHandler; }>>>>>>; /** * What a phase means to the runtime. * - `resting`: nobody is seated; a card waits for a person or an event. * - `working`: an agent in `role` carries the card; a person's move in arms autonomy. * - `terminal`: the card is finished; sessions stop and held resources are released. */ export type BoardPhaseKind = 'resting' | 'working' | 'terminal'; type BoardPhaseBase = { readonly title: string; readonly next?: PhaseId; readonly outcomes?: Readonly>; readonly onEnter?: ReadonlyBoardPhaseHandlers; readonly onExit?: ReadonlyBoardPhaseHandlers; }; export type BoardPhaseDefinition = (BoardPhaseBase & { readonly kind: 'resting'; readonly role?: never; }) | (BoardPhaseBase & { readonly kind: 'working'; readonly role: string; }) | (BoardPhaseBase & { readonly kind: 'terminal'; readonly role?: never; }); export interface BoardTransition { readonly outcome: string | null; readonly to: PhaseId; } export interface BoardDefinition { readonly id: BoardId; readonly title: string; readonly initialPhase: PhaseId; readonly phases: Readonly>>; readonly transitions: Readonly[]>>; readonly rules: ReadonlyFactoryBoardRules; /** Tool-result rules keyed by tool name; empty when the board declares none. */ readonly tools: BoardToolRules; readonly transitionPolicy?: BoardTransitionPolicy; allowsTransition(from: PhaseId, to: PhaseId): boolean; /** Declared kind of a phase, or undefined when the board has no such phase. */ phaseKind(phase: string): BoardPhaseKind | undefined; isWorking(phase: string): boolean; isTerminal(phase: string): boolean; /** Role seated in a working phase; undefined for resting/terminal/unknown phases. */ roleForPhase(phase: string): string | undefined; /** First working phase, in declaration order, carried by `role`. */ phaseForRole(role: string): PhaseId | undefined; } type BoardConfig>> = { id: BoardId; title: string; initialPhase: keyof Phases & string; phases: Phases; tools?: Record; transitionPolicy?: BoardTransitionPolicy; }; export declare class BoardDefinitionError extends Error { name: string; } export declare function defineBoard>>(config: BoardConfig): BoardDefinition; export {}; //# sourceMappingURL=define-board.d.ts.map