import {z} from 'zod' export type CreateApiApiV1AgentsSellerServicesArgs = {body: {name: string, description: string, tags: Array, type: 'API' | 'WEB_PAGE' | 'MCP_SERVER_REMOTE' | 'MCP_SERVER_LOCAL' | 'FETCH_AGENT', price: string, priceModel: 'PAY_PER_USE' | 'SUBSCRIPTION' | 'PAY_PER_MB' | 'CUSTOM', minimumTokenAmount: string, mcpServerUrl?: string | undefined, openApiSpecUrl?: string | undefined, websiteUrl?: string | undefined, fetchAgentProfileUrl?: string | undefined, humanIdentityRequirement: {individual: Array, organization: Array}, termsOfService?: ({url?: string | undefined, required?: boolean | undefined}) | undefined, acceptedTokens?: (Array<'kya' | 'pay' | 'kya-pay'>) | undefined, maxTokenTTLSeconds?: number | undefined}}; export type CreateApiApiV1AgentsSellerServicesOptions = {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 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's Service * * POST /api/v1/agents/seller-services */ export const createApiApiV1AgentsSellerServices = async (args: CreateApiApiV1AgentsSellerServicesArgs, options?: CreateApiApiV1AgentsSellerServicesOptions) => { const {baseUrl = "https://api.skyfire.xyz", fetch: fetchFn = fetch, sec0} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") 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: "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(sellerService, await res.json()) };