import { Annotation } from '@langchain/langgraph';
/**
 * State annotation for the feature-agent graph.
 *
 * Uses LangGraph's Annotation API to define state channels.
 * The `messages` channel uses a reducer to accumulate messages
 * from all nodes as the graph executes.
 */
export const FeatureAgentAnnotation = Annotation.Root({
    featureId: (Annotation),
    repositoryPath: (Annotation),
    specDir: (Annotation),
    worktreePath: (Annotation),
    currentNode: (Annotation),
    error: Annotation({
        reducer: (prev, next) => (next !== undefined ? next : prev),
        default: () => null,
    }),
    approvalMode: Annotation({
        reducer: (prev, next) => next ?? prev,
        default: () => undefined,
    }),
    messages: Annotation({
        reducer: (prev, next) => [...prev, ...next],
        default: () => [],
    }),
});
