Three-role workflow (questioner → answerer → explorer) that iterates over .knowledge/ cards to discover and fill knowledge gaps via BFS. - questioner: createLlmRole, reads card, asks 3 technical questions - answerer: spawnSafe nerve knowledge query, judges answers - explorer: reads code, writes/patches .knowledge cards, runs sync - moderator: BFS queue from message history, stagnation rule Closes #266
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import type { AgentFn, WorkflowDefinition } from "@uncaged/nerve-core";
|
|
import type { LlmExtractorConfig } from "@uncaged/nerve-workflow-utils";
|
|
|
|
import { moderator } from "./moderator.js";
|
|
import type { WorkflowMeta } from "./moderator.js";
|
|
import { createAnswererRole } from "./roles/answerer.js";
|
|
import { createExplorerRole } from "./roles/explorer.js";
|
|
import { createQuestionerRole } from "./roles/questioner.js";
|
|
|
|
export type CreateKnowledgeExtractionDeps = {
|
|
defaultAdapter: AgentFn;
|
|
adapters?: Partial<Record<keyof WorkflowMeta, AgentFn>>;
|
|
extract: LlmExtractorConfig;
|
|
};
|
|
|
|
export function createKnowledgeExtractionWorkflow({
|
|
defaultAdapter,
|
|
adapters,
|
|
extract,
|
|
}: CreateKnowledgeExtractionDeps): WorkflowDefinition<WorkflowMeta> {
|
|
const a = (role: keyof WorkflowMeta) => adapters?.[role] ?? defaultAdapter;
|
|
return {
|
|
name: "knowledge-extraction",
|
|
roles: {
|
|
questioner: createQuestionerRole({ extract }),
|
|
answerer: createAnswererRole({ extract }),
|
|
explorer: createExplorerRole(a("explorer"), { extract }),
|
|
},
|
|
moderator,
|
|
};
|
|
}
|