import type { AgentFn, Role, StartStep } from "@uncaged/nerve-core"; import type { LlmExtractorConfig } from "@uncaged/nerve-workflow-utils"; import { createRole, decorateRole, withDryRun, onFail } from "@uncaged/nerve-workflow-utils"; import { z } from "zod"; import { committerPrompt } from "./prompt.js"; export const committerMetaSchema = z.object({ committed: z .boolean() .describe("true if branch created, changes committed, and pushed successfully"), }); export type CommitterMeta = z.infer; export function createCommitterRole( adapter: AgentFn, extract: LlmExtractorConfig, ): Role { const inner = createRole( adapter, async (start: StartStep) => committerPrompt({ threadId: start.meta.threadId }), committerMetaSchema, extract, ); return decorateRole(inner, [ withDryRun({ label: "committer", meta: { committed: true } as CommitterMeta }), onFail({ label: "committer", meta: { committed: false } as CommitterMeta }), ]) as Role; }