import { StringEnum } from "@mariozechner/pi-ai"; import { Type, type Static } from "@sinclair/typebox"; export function createBackgroundAgentSchema(availableModels: readonly string[]) { return Type.Object( { preset: Type.String({ description: "Subagent preset name to use for this task" }), task: Type.String({ description: "Task to delegate to the child agent" }), model: Type.Optional( StringEnum(availableModels, { description: "Optional child model override. Must be one of the currently available models.", }), ), cwd: Type.Optional(Type.String({ description: "Optional working directory override" })), }, { description: "Parameters for launching a background_agent run" }, ); } export const BackgroundAgentSchema = createBackgroundAgentSchema([]); export function createBackgroundAgentStatusSchema() { return Type.Object( { runId: Type.Optional(Type.String({ description: "Optional runId to query a single run" })), includeCompleted: Type.Optional(Type.Boolean({ description: "Include completed/finished runs in listing" })), }, { description: "Parameters for background_agent_status tool" }, ); } export const BackgroundAgentStatusSchema = createBackgroundAgentStatusSchema(); export type BackgroundAgentParams = Static; export type BackgroundAgentStatusParams = Static;