/** @jsxImportSource smithers-orchestrator */
import { createSmithers, Sequence, Task } from "smithers-orchestrator";
import { ToolLoopAgent as Agent } from "ai";
import { anthropic } from "@ai-sdk/anthropic";
import { z } from "zod";
const { Workflow, smithers, outputs } = createSmithers({
research: z.object({
summary: z.string(),
keyPoints: z.array(z.string()),
}),
output: z.object({
title: z.string(),
body: z.string(),
}),
});
const researcher = new Agent({
model: anthropic("claude-sonnet-4-20250514"),
instructions: "You are an expert research assistant.",
});
const writer = new Agent({
model: anthropic("claude-sonnet-4-20250514"),
instructions: "You are a concise technical writer.",
});
export default smithers((ctx) => {
const research = ctx.outputMaybe(outputs.research, { nodeId: "research" });
return (
<Workflow name="research-report">
<Sequence>
<Task id="research" output={outputs.research} agent={researcher}>
{`Research the following topic and return a summary with key points.\n\nTopic: ${ctx.input.topic}`}
</Task>
{research ? (
<Task id="report" output={outputs.output} agent={writer}>
{`Write a concise report.\n\nSummary: ${research.summary}\nKey points: ${research.keyPoints.join(", ")}`}
</Task>
) : null}
</Sequence>
</Workflow>
);
});