feat(FN-3554): expand AI agent interview onboarding flow
Reuses the experimental onboarding modal for both create and edit, makes onboarding mode-aware, and plumbs draft handling through the agent detail view, new agent dialog, and import/export/generation routes. Fusion-Task-Id: FN-3554
This commit is contained in:
@@ -112,8 +112,9 @@ describe("agent-onboarding", () => {
|
||||
).toThrow(/Invalid summary/);
|
||||
});
|
||||
|
||||
it("builds compact onboarding context prompt", () => {
|
||||
it("builds compact onboarding context prompt for create mode", () => {
|
||||
const prompt = createAgentOnboardingSessionPrompt({
|
||||
mode: "create",
|
||||
intent: "Need a reviewer for docs",
|
||||
existingAgents: [{ id: "a1", name: "Alpha", role: "reviewer" }],
|
||||
templates: [{ id: "t1", label: "Reviewer Template", description: "General reviewer" }],
|
||||
@@ -122,6 +123,39 @@ describe("agent-onboarding", () => {
|
||||
expect(prompt).toContain("Need a reviewer for docs");
|
||||
expect(prompt).toContain("a1:Alpha(reviewer)");
|
||||
expect(prompt).toContain("t1:Reviewer Template");
|
||||
expect(prompt).not.toContain("Current agent configuration:");
|
||||
});
|
||||
|
||||
it("appends current agent configuration in edit mode prompt", () => {
|
||||
const prompt = createAgentOnboardingSessionPrompt({
|
||||
mode: "edit",
|
||||
intent: "Improve this agent",
|
||||
existingAgents: [{ id: "a1", name: "Alpha", role: "reviewer" }],
|
||||
templates: [{ id: "t1", label: "Reviewer Template", description: "General reviewer" }],
|
||||
existingAgentConfig: {
|
||||
name: "Alpha",
|
||||
role: "reviewer",
|
||||
title: "Senior Reviewer",
|
||||
instructionsText: "Current instructions",
|
||||
soul: "Calm",
|
||||
memory: "Team context",
|
||||
reportsTo: "mgr-1",
|
||||
skills: ["linting"],
|
||||
model: "openai/gpt-5-mini",
|
||||
thinkingLevel: "low",
|
||||
maxTurns: 40,
|
||||
runtimeHint: "gpu",
|
||||
heartbeatIntervalMs: 30000,
|
||||
heartbeatTimeoutMs: 120000,
|
||||
maxConcurrentRuns: 2,
|
||||
messageResponseMode: "immediate",
|
||||
},
|
||||
});
|
||||
|
||||
expect(prompt).toContain("Current agent configuration:");
|
||||
expect(prompt).toContain("name: Alpha");
|
||||
expect(prompt).toContain("instructionsText: Current instructions");
|
||||
expect(prompt).toContain("messageResponseMode: immediate");
|
||||
});
|
||||
|
||||
it("progresses through start -> question -> response -> final summary", async () => {
|
||||
@@ -168,6 +202,58 @@ describe("agent-onboarding", () => {
|
||||
expect(summary?.templateId).toBe("eng-template");
|
||||
});
|
||||
|
||||
it("defaults onboarding sessions to create mode", async () => {
|
||||
mockCreateFnAgent.mockResolvedValueOnce(
|
||||
createMockAgent([
|
||||
JSON.stringify({
|
||||
type: "question",
|
||||
data: { id: "q1", type: "text", question: "What should this agent do?" },
|
||||
}),
|
||||
]),
|
||||
);
|
||||
|
||||
const sessionId = await startAgentOnboardingSession(
|
||||
"127.0.0.1",
|
||||
{ intent: "create", existingAgents: [], templates: [] },
|
||||
process.cwd(),
|
||||
);
|
||||
|
||||
await waitFor(() => Boolean(getAgentOnboardingSession(sessionId)));
|
||||
expect(getAgentOnboardingSession(sessionId)?.mode).toBe("create");
|
||||
});
|
||||
|
||||
it("stores edit mode sessions and includes current config in agent prompt", async () => {
|
||||
mockCreateFnAgent.mockResolvedValueOnce(
|
||||
createMockAgent([
|
||||
JSON.stringify({
|
||||
type: "question",
|
||||
data: { id: "q1", type: "text", question: "What should change?" },
|
||||
}),
|
||||
]),
|
||||
);
|
||||
|
||||
const sessionId = await startAgentOnboardingSession(
|
||||
"127.0.0.1",
|
||||
{
|
||||
mode: "edit",
|
||||
intent: "Improve this agent",
|
||||
existingAgents: [],
|
||||
templates: [],
|
||||
existingAgentConfig: {
|
||||
name: "Editor",
|
||||
instructionsText: "Current instructions",
|
||||
messageResponseMode: "on-heartbeat",
|
||||
},
|
||||
},
|
||||
process.cwd(),
|
||||
);
|
||||
|
||||
await waitFor(() => Boolean(getAgentOnboardingSession(sessionId)?.currentQuestion));
|
||||
expect(getAgentOnboardingSession(sessionId)?.mode).toBe("edit");
|
||||
expect(getAgentOnboardingSession(sessionId)?.contextPrompt).toContain("Current agent configuration:");
|
||||
expect(getAgentOnboardingSession(sessionId)?.contextPrompt).toContain("name: Editor");
|
||||
});
|
||||
|
||||
it("throws InvalidSessionStateError when responding without an active question", async () => {
|
||||
mockCreateFnAgent.mockResolvedValueOnce(
|
||||
createMockAgent([
|
||||
|
||||
Reference in New Issue
Block a user