import type { FactoryGithubEventName, FactoryGithubRuleContext, FactoryGitLabEventName, FactoryGitLabRuleContext, FactoryIncidentioEventName, FactoryIncidentioRuleContext, FactoryJiraEventName, FactoryJiraRuleContext, FactoryLinearEventName, FactoryLinearRuleContext, 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>; /** * A board's handler for one integration event. `null` switches the integration default off * for cards on this board only. */ type BoardEventHandlerMap = Readonly | null>>>; /** * How cards on this board react to integration events, keyed by integration then event. * Consulted for events bound to a card on this board, after any handler the deployment set * explicitly on the integration and before the integration default. */ export interface BoardEventRules { readonly github?: BoardEventHandlerMap; readonly gitlab?: BoardEventHandlerMap; readonly linear?: BoardEventHandlerMap; readonly jira?: BoardEventHandlerMap; readonly incidentio?: BoardEventHandlerMap; } export type BoardEventIntegration = keyof BoardEventRules; 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; } /** * Terminal phases a card moves to when its tracked source (issue or follow-up) closes. * `completed` is used when the source was completed, `canceled` when it was canceled or not planned. */ export type BoardSourceClosed = Readonly<{ completed: PhaseId; canceled: 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; /** Integration event handlers for cards on this board; empty when the board declares none. */ readonly events: BoardEventRules; readonly transitionPolicy?: BoardTransitionPolicy; /** Where source-closed rules move a card; absent when the board opts out of auto-closing. */ readonly sourceClosed?: BoardSourceClosed; 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; events?: BoardEventRules; transitionPolicy?: BoardTransitionPolicy; sourceClosed?: { completed: keyof Phases & string; canceled: keyof Phases & string; }; }; export declare class BoardDefinitionError extends Error { name: string; } export declare function defineBoard>>(config: BoardConfig): BoardDefinition; export {}; //# sourceMappingURL=define-board.d.ts.map