import {z} from 'zod' export type CreateApiV2TeamsTeamIdAgentsArgs = {teamId: string, body: {name: string, thread_id?: (string | null) | undefined, source_build_id?: (string | null) | undefined, automation_id?: (string | null) | undefined, build?: ({name: string, config: {version: 'v2', data: {models: {agent: {model: 'claude-sonnet-5' | 'claude-sonnet-5[1m]' | 'claude-opus-4-8' | 'claude-opus-4-8[1m]' | 'd1-max' | 'duvo-1-max' | 'duvo-1-max-sonnet-1m' | 'duvo-1-max-sonnet-4.5' | 'duvo-1-max-sonnet-4.5-1m' | 'duvo-1-max-opus' | 'duvo-1-max-opus-4.5' | 'gpt-4.1' | 'gpt-4o' | 'gpt-4o-mini' | 'gpt-5' | 'gpt-5.1' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-20250514[1m]' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5-20250929[1m]' | 'claude-sonnet-4-6' | 'claude-sonnet-4-6[1m]' | 'claude-opus-4-1-20250805' | 'claude-opus-4-5-20251101' | 'claude-opus-4-6' | 'claude-opus-4-6[1m]' | 'claude-opus-4-7' | 'claude-opus-4-7[1m]'}, browsing: {provider: 'google' | 'anthropic', model: 'gemini-2.5-pro' | 'gemini-2.5-flash' | 'gemini-3-pro-preview' | 'claude-haiku-4-5' | 'claude-sonnet-4-5' | 'claude-opus-4-1'}}, input: string | Array<{role: 'system' | 'user' | 'assistant', content: string | Array<{type: 'input_text', text: string} | {type: 'input_image', detail?: ('low' | 'high' | 'auto' | null) | undefined, file_id?: (string | null) | undefined, url?: (string | null) | undefined} | {type: 'input_file', file_id: string}>, type?: ('message' | null) | undefined}>, files?: (Array | null) | undefined, skills?: (Array | null) | undefined, plugins?: (Array | null) | undefined, subAgents?: (Array | null) | undefined, options?: ({browserProvider?: ('browserbase' | 'browser-use') | undefined, evaluationSchemaId?: string | undefined, benchmarkExpectedOutcomes?: Array<{description: string, criteria: string}> | undefined} | {[key: string]: unknown}) | undefined}}}) | undefined}}; export type CreateApiV2TeamsTeamIdAgentsOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiV2TeamsTeamIdAgentsResponse = z.object({agent: z.object({id: z.string(), name: z.string(), slack_enabled: z.boolean().nullable(), microsoft_teams_enabled: z.boolean().nullable(), agentic_memory_enabled: z.boolean().nullable(), team_id: z.string().nullable(), thread_id: z.string().nullable(), folder_id: z.string().nullable().optional(), automation_id: z.string().nullable().optional(), created_at: z.string().nullable(), updated_at: z.string().nullable(), created_by: z.object({id: z.string(), name: z.string().nullable(), email: z.string()}).nullable().optional(), updated_by: z.object({id: z.string(), name: z.string().nullable(), email: z.string()}).nullable().optional()}), build: z.object({id: z.string(), copilot_id: z.string(), agent_id: z.string(), name: z.string(), revision_name: z.string().nullable().optional(), revision_description: z.string().nullable().optional(), config: z.union([z.object({version: z.literal("v1"), data: z.object({model: z.string(), temperature: z.number().gte(0).lte(2).nullable().optional(), max_output_tokens: z.number().gt(0).nullable().optional(), top_p: z.number().gte(0).lte(1).nullable().optional(), store: z.boolean().nullable().optional(), tools: z.unknown(), input: z.union([z.string(), z.array(z.object({role: z.enum(["system", "user", "assistant"]), content: z.union([z.string(), z.array(z.union([z.object({type: z.literal("input_text"), text: z.string()}), z.object({type: z.literal("input_image"), detail: z.enum(["low", "high", "auto"]).nullable().optional(), file_id: z.string().nullable().optional(), url: z.string().nullable().optional()}), z.object({type: z.literal("input_file"), file_id: z.string()})]))]), type: z.literal("message").nullable().optional()}))]), text: z.object({format: z.union([z.object({type: z.literal("text")}), z.object({type: z.literal("json_object")})]).nullable().optional()}).nullable().optional(), files: z.array(z.string()).nullable(), skills: z.array(z.string()).nullable()})}), z.object({version: z.literal("v2"), data: z.object({models: z.object({agent: z.object({model: z.enum(["claude-sonnet-5", "claude-sonnet-5[1m]", "claude-opus-4-8", "claude-opus-4-8[1m]", "d1-max", "duvo-1-max", "duvo-1-max-sonnet-1m", "duvo-1-max-sonnet-4.5", "duvo-1-max-sonnet-4.5-1m", "duvo-1-max-opus", "duvo-1-max-opus-4.5", "gpt-4.1", "gpt-4o", "gpt-4o-mini", "gpt-5", "gpt-5.1", "claude-sonnet-4-20250514", "claude-sonnet-4-20250514[1m]", "claude-sonnet-4-5-20250929", "claude-sonnet-4-5-20250929[1m]", "claude-sonnet-4-6", "claude-sonnet-4-6[1m]", "claude-opus-4-1-20250805", "claude-opus-4-5-20251101", "claude-opus-4-6", "claude-opus-4-6[1m]", "claude-opus-4-7", "claude-opus-4-7[1m]"])}), browsing: z.object({provider: z.enum(["google", "anthropic"]), model: z.enum(["gemini-2.5-pro", "gemini-2.5-flash", "gemini-3-pro-preview", "claude-haiku-4-5", "claude-sonnet-4-5", "claude-opus-4-1"])})}), input: z.union([z.string(), z.array(z.object({role: z.enum(["system", "user", "assistant"]), content: z.union([z.string(), z.array(z.union([z.object({type: z.literal("input_text"), text: z.string()}), z.object({type: z.literal("input_image"), detail: z.enum(["low", "high", "auto"]).nullable().optional(), file_id: z.string().nullable().optional(), url: z.string().nullable().optional()}), z.object({type: z.literal("input_file"), file_id: z.string()})]))]), type: z.literal("message").nullable().optional()}))]), files: z.array(z.string()).nullable(), skills: z.array(z.string()).nullable(), plugins: z.array(z.string()).nullable(), subAgents: z.array(z.string()).nullable(), options: z.object({browserProvider: z.enum(["browserbase", "browser-use"]).optional(), evaluationSchemaId: z.string().optional(), benchmarkExpectedOutcomes: z.array(z.object({description: z.string(), criteria: z.string()})).optional()}).and(z.record(z.string(), z.unknown())).optional()})})]).nullable(), status: z.string().nullable(), revision_number: z.number().nullable(), parent_build_id: z.string().nullable(), created_by: z.string().nullable(), created_by_name: z.string().nullable().optional(), created_at: z.string().nullable(), updated_at: z.string().nullable(), schedules: z.array(z.object({id: z.string(), build_id: z.string(), agent_id: z.string(), user_id: z.string(), enabled: z.boolean(), frequency: z.enum(["every_5_minutes", "every_15_minutes", "hourly", "daily", "workday", "weekly", "monthly", "custom"]), time: z.string().nullable(), timezone: z.string(), day: z.string().nullable(), day_of_month: z.number().nullable(), cron: z.string().nullable(), source: z.string().nullable(), task: z.string().nullable(), recurring: z.boolean().nullable(), auto_disabled_at: z.string().nullable(), auto_disabled_reason: z.string().nullable(), consecutive_missing_connection_failures: z.number().int().gte(0).lte(9007199254740991), first_missing_connection_failure_at: z.string().nullable(), last_missing_connection_failure_at: z.string().nullable(), created_at: z.string(), updated_at: z.string(), user_name: z.string().nullable().optional(), user_email: z.string().nullable().optional()})).optional()}).optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Create Agent * * POST /v2/teams/{teamId}/agents */ export const createApiV2TeamsTeamIdAgents = async (args: CreateApiV2TeamsTeamIdAgentsArgs, options?: CreateApiV2TeamsTeamIdAgentsOptions) => { const {baseUrl = "https://api.duvo.ai", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/teams/${encodeURIComponent(String(args.teamId))}/agents${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(createApiV2TeamsTeamIdAgentsResponse, await res.json()) };