import {z} from 'zod' export type GetApiApiV1AgentsSellerServicesOptions = {baseUrl?: string | undefined, sec0?: string | undefined, fetch?: typeof fetch | undefined}; export const sellerService = z.object({id: z.string(), name: z.string(), description: z.string(), tags: z.array(z.string()), type: z.enum(["API", "WEB_PAGE", "VERIFIED_DOMAIN", "MCP_SERVER_LOCAL", "MCP_SERVER_REMOTE", "FETCH_AGENT"]), price: z.string(), priceModel: z.enum(["PAY_PER_USE", "SUBSCRIPTION", "PAY_PER_MB", "CUSTOM"]), minimumTokenAmount: z.string(), humanIdentityRequirement: z.object({identityLevels: z.array(z.string()).optional(), organization: z.array(z.string()).optional(), individual: z.array(z.string()).optional()}), openApiSpecUrl: z.string().optional(), websiteUrl: z.string().optional(), fetchAgentProfileUrl: z.string().optional(), mcpServerUrl: z.string().optional(), termsOfService: z.object({url: z.string().optional(), required: z.boolean().optional()}).optional(), acceptedTokens: z.array(z.enum(["kya", "pay", "kya-pay"])).optional(), maxTokenTTLSeconds: z.number().optional(), seller: z.object({id: z.string().optional(), name: z.string().optional(), identityLevel: z.string().optional()}), createdAt: z.string(), updatedAt: z.string(), active: z.boolean(), approved: z.boolean()}); export const getApiApiV1AgentsSellerServicesResponse = z.object({data: z.array(sellerService)}); 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's Services - All * * GET /api/v1/agents/seller-services */ export const getApiApiV1AgentsSellerServices = async (options?: GetApiApiV1AgentsSellerServicesOptions) => { const {baseUrl = "https://api.skyfire.xyz", fetch: fetchFn = fetch, sec0} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (sec0 !== undefined) headers.set("skyfire-api-key", sec0) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/agents/seller-services${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(getApiApiV1AgentsSellerServicesResponse, await res.json()) };