import {z} from 'zod' export type AmigoLibPydanticBaseModelStrippedNonemptyString1 = string; export type LLMType = 'openai_gpt-5.2-2025-12-11' | 'openai_gpt-5.4-nano-2026-03-17' | 'openai_gpt-5.4-mini-2026-03-17' | 'openai_gpt-5.5-2026-04-23' | 'openai_gpt-5.6-sol' | 'openai_gpt-5.6-terra' | 'openai_gpt-5.6-luna' | 'openai_gpt-6-luna' | 'openai_decisions_gpt-6-luna' | 'google_gemini-3.5-flash' | 'google_gemini-3.5-flash-lite'; export type LLMConfigInput = {llm_name: LLMType, params?: {[key: string]: unknown} | undefined}; export type VersionSetInput = {agent_version_number: number | null, service_hierarchical_state_machine_version_number: number | null, llm_model_preferences: {[key: string]: LLMConfigInput}}; export type StrippedNonemptyStringAZAZ02 = string; export type StrippedNonemptyStringWS = string; export type SrcAppEndpointsServiceCreateServiceRequest = {service_hierarchical_state_machine_id: string, agent_id: string, name: AmigoLibPydanticBaseModelStrippedNonemptyString1, description: AmigoLibPydanticBaseModelStrippedNonemptyString1, is_active: boolean, release_version_set?: (VersionSetInput | null) | undefined, keyterms: Array, tags: {[key: string]: StrippedNonemptyStringWS | null}}; export type CreateApiV1OrganizationServiceArgs = {organization: string, 'x-mongo-cluster-name'?: (string | null) | undefined, 'Sec-WebSocket-Protocol'?: Array | undefined, body: SrcAppEndpointsServiceCreateServiceRequest}; export type CreateApiV1OrganizationServiceOptions = {baseUrl?: string | undefined, BearerAuthorization?: string | undefined, BearerAuthorizationOrganization?: string | undefined, Basic?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; export const srcAppEndpointsServiceCreateServiceResponse = z.object({id: z.string()}); 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 a service * * POST /v1/{organization}/service/ */ export const createApiV1OrganizationService = async (args: CreateApiV1OrganizationServiceArgs, options?: CreateApiV1OrganizationServiceOptions) => { const {baseUrl = "https://api.amigo.ai", fetch: fetchFn = fetch, BearerAuthorization, BearerAuthorizationOrganization, Basic} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['x-mongo-cluster-name'] != null) headers.set("x-mongo-cluster-name", String(args['x-mongo-cluster-name'])) if (args['Sec-WebSocket-Protocol'] != null) headers.set("Sec-WebSocket-Protocol", args['Sec-WebSocket-Protocol'].join(',')) if (BearerAuthorization !== undefined) headers.set('authorization', `Bearer ${BearerAuthorization}`) if (BearerAuthorizationOrganization !== undefined) headers.set("X-ORG-ID", BearerAuthorizationOrganization) if (Basic !== undefined) headers.set('authorization', `Basic ${btoa(`${Basic.username}:${Basic.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/${encodeURIComponent(String(args.organization))}/service/${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(srcAppEndpointsServiceCreateServiceResponse, await res.json()) };