refactor: three-phase context (Moderator/Agent/Extract) + extractPrompt + unified ExtractFn

- ModeratorContext → AgentContext → ExtractContext progressive types
- ThreadContext is now alias for AgentContext
- RoleDefinition adds extractPrompt field
- ExtractFn = (schema, ctx: ExtractContext) => Promise<T>
- createWorkflow takes ExtractFn, engine loop: moderator → agent → extract
- Remove ExtractConfig, extractMetaOrThrow, extract-meta.ts

小橘 <xiaoju@shazhou.work>
This commit is contained in:
2026-05-07 01:05:31 +00:00
parent 99a137422c
commit d472de1247
19 changed files with 137 additions and 152 deletions
+7 -4
View File
@@ -1,4 +1,4 @@
import { createWorkflow, END, type RoleDefinition } from "@uncaged/workflow";
import { createExtract, createWorkflow, END, type RoleDefinition } from "@uncaged/workflow";
import * as z from "zod/v4";
type Roles = {
@@ -26,12 +26,15 @@ export const descriptor = {
const greeter: RoleDefinition<Roles["greeter"]> = {
description: "Generates a greeting",
systemPrompt: "You greet the user briefly.",
extractPrompt: "Extract the greeting string produced for the user.",
schema: greeterMetaSchema,
};
const extract = {
provider: { baseUrl: "http://127.0.0.1:9", apiKey: "", model: "" },
} as const;
const extract = createExtract({
baseUrl: "http://127.0.0.1:9",
apiKey: "",
model: "",
});
export const run = createWorkflow<Roles>(
{