feat: add @uncaged/workflow-agent-builtin package
Built-in role agent that uses workflow config models directly, with its own tool-calling run loop. No external agent dependency. - OpenAI-compatible chat completion client with tool_calls support - P0 toolkit: read_file, write_file, run_command - Integrates via createAgent factory from workflow-agent-kit - CAS detail recording for each turn - Path sandboxing and shell opt-in (UWF_BUILTIN_ALLOW_SHELL)
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
|
||||
import type { AgentContext } from "@uncaged/workflow-agent-kit";
|
||||
|
||||
import { buildBuiltinPrompt } from "../src/prompt.js";
|
||||
|
||||
function minimalContext(overrides: Partial<AgentContext> = {}): AgentContext {
|
||||
return {
|
||||
threadId: "00000000000000000000000000" as AgentContext["threadId"],
|
||||
role: "developer",
|
||||
store: {} as AgentContext["store"],
|
||||
workflow: {
|
||||
name: "test",
|
||||
roles: {
|
||||
developer: {
|
||||
goal: "Ship the fix",
|
||||
capabilities: ["file-edit"],
|
||||
procedure: ["Edit files"],
|
||||
output: "A patch",
|
||||
frontmatter: "schema-hash",
|
||||
},
|
||||
},
|
||||
conditions: {},
|
||||
graph: {},
|
||||
},
|
||||
start: { workflow: "wf-hash", prompt: "Fix the bug" },
|
||||
steps: [],
|
||||
outputFormatInstruction: "---\nstatus: done\n---",
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
describe("buildBuiltinPrompt", () => {
|
||||
test("includes output format, task, and role goal", () => {
|
||||
const prompt = buildBuiltinPrompt(minimalContext());
|
||||
expect(prompt).toContain("status: done");
|
||||
expect(prompt).toContain("## Goal");
|
||||
expect(prompt).toContain("Ship the fix");
|
||||
expect(prompt).toContain("## Task");
|
||||
expect(prompt).toContain("Fix the bug");
|
||||
});
|
||||
|
||||
test("includes history when steps exist", () => {
|
||||
const prompt = buildBuiltinPrompt(
|
||||
minimalContext({
|
||||
steps: [
|
||||
{
|
||||
role: "planner",
|
||||
output: { plan: "step 1" },
|
||||
agent: "uwf-builtin",
|
||||
detail: "detail-hash",
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
expect(prompt).toContain("## Previous Steps");
|
||||
expect(prompt).toContain("planner");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user