import {z} from 'zod' export type GetApiAgentsDeploymentsDeploymentIdArgs = {'Cartesia-Version': '2026-03-01', deployment_id: string}; export type GetApiAgentsDeploymentsDeploymentIdOptions = {baseUrl?: string | undefined, APIKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const deployment = z.object({id: z.string(), agent_id: z.string(), version_id: z.string(), status: z.string(), is_pinned: z.boolean(), is_live: z.boolean(), env_var_collection_id: z.string().nullable().optional(), source_code_file_id: z.string().nullable().optional(), git_commit_hash: z.string().nullable().optional(), created_at: z.string(), updated_at: z.string(), build_completed_at: z.string().nullable().optional(), build_error: z.string().nullable().optional(), build_logs: z.string().nullable().optional(), build_started_at: z.string().nullable().optional(), deployment_started_at: z.string().nullable().optional(), deployment_completed_at: z.string().nullable().optional(), deployment_error: z.string().nullable().optional(), region: z.string().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 }; /** * Get Deployment * * GET /agents/deployments/{deployment_id} */ export const getApiAgentsDeploymentsDeploymentId = async (args: GetApiAgentsDeploymentsDeploymentIdArgs, options?: GetApiAgentsDeploymentsDeploymentIdOptions) => { const {baseUrl = "https://api.cartesia.ai", fetch: fetchFn = fetch, APIKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['Cartesia-Version'] != null) headers.set("Cartesia-Version", String(args['Cartesia-Version'])) if (APIKeyAuth !== undefined) headers.set('authorization', `Bearer ${APIKeyAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/agents/deployments/${encodeURIComponent(String(args.deployment_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(deployment, await res.json()) };