import {z} from 'zod' export type GetApiV1AgentConfigurationsAgentIdDomeConfigsArgs = {agent_id: string, team_id: string}; export type GetApiV1AgentConfigurationsAgentIdDomeConfigsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const agentDomeConfigResponse = z.object({id: z.string(), status: z.string().optional(), agent_id: z.string().nullable().optional(), config_body: z.record(z.string(), z.unknown()).optional(), dome_instance_url: z.string().nullable().optional(), created_at: z.number().int(), created_by: z.string(), updated_at: z.number().int().nullable().optional(), updated_by: z.string().nullable().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 Agent Dome Config * * GET /v1/agent-configurations/{agent_id}/dome-configs */ export const getApiV1AgentConfigurationsAgentIdDomeConfigs = async (args: GetApiV1AgentConfigurationsAgentIdDomeConfigsArgs, options: GetApiV1AgentConfigurationsAgentIdDomeConfigsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.team_id != null) query.append("team_id", String(args.team_id)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/agent-configurations/${encodeURIComponent(String(args.agent_id))}/dome-configs${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(agentDomeConfigResponse, await res.json()) };