- Role: (start, messages) → (ctx: ThreadContext) - AgentFn prompt callbacks: (start) → (ctx) - ModeratorContext → ThreadContext - 13 files updated across knowledge-extraction and solve-issue workflows 小橘 <xiaoju@shazhou.work>
31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
import type { AgentFn, Role, ThreadContext } 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<typeof committerMetaSchema>;
|
|
|
|
export function createCommitterRole(
|
|
adapter: AgentFn,
|
|
extract: LlmExtractorConfig,
|
|
): Role<CommitterMeta> {
|
|
const inner = createRole(
|
|
adapter,
|
|
async (ctx: ThreadContext) => committerPrompt({ threadId: ctx.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<CommitterMeta>;
|
|
}
|