@synova-cloud/sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +475 -0
- package/dist/index.cjs +630 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +564 -0
- package/dist/index.d.ts +564 -0
- package/dist/index.js +620 -0
- package/dist/index.js.map +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors/index.ts","../src/utils/http.ts","../src/resources/prompts.ts","../src/resources/models.ts","../src/resources/files.ts","../src/client.ts"],"names":[],"mappings":";;;AAKO,IAAM,WAAA,GAAN,cAA0B,KAAA,CAAM;AAAA,EACrC,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,GAAA,CAAA,MAAA,CAAW,SAAS,CAAA;AAAA,EAClD;AACF;AAKO,IAAM,cAAA,GAAN,cAA6B,WAAA,CAAY;AAAA,EACrC,IAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EAET,YAAY,QAAA,EAA6B;AACvC,IAAA,KAAA,CAAM,SAAS,OAAO,CAAA;AACtB,IAAA,IAAA,CAAK,IAAA,GAAO,gBAAA;AACZ,IAAA,IAAA,CAAK,OAAO,QAAA,CAAS,IAAA;AACrB,IAAA,IAAA,CAAK,WAAW,QAAA,CAAS,QAAA;AACzB,IAAA,IAAA,CAAK,YAAY,QAAA,CAAS,SAAA;AAC1B,IAAA,IAAA,CAAK,YAAY,QAAA,CAAS,SAAA;AAAA,EAC5B;AACF;AAKO,IAAM,eAAA,GAAN,cAA8B,WAAA,CAAY;AAAA,EAC/C,WAAA,CAAY,UAAU,4BAAA,EAA8B;AAClD,IAAA,KAAA,CAAM,OAAO,CA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,MAAA,EAAQ,QAAQ,MAAA,IAAU;AAAA,KAC3B,CAAA;AAED,IAAA,IAAA,CAAK,OAAA,GAAU,IAAI,eAAA,CAAgB,IAAA,CAAK,IAAI,CAAA;AAC5C,IAAA,IAAA,CAAK,MAAA,GAAS,IAAI,cAAA,CAAe,IAAA,CAAK,IAAI,CAAA;AAC1C,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAI,aAAA,CAAc,IAAA,CAAK,IAAI,CAAA;AAAA,EAC1C;AACF","file":"index.cjs","sourcesContent":["import type { IApiErrorResponse } from '../types';\n\n/**\n * Base error class for all Synova SDK errors\n */\nexport class SynovaError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'SynovaError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * Error thrown when API returns an error response\n */\nexport class ApiSynovaError extends SynovaError {\n readonly code: string;\n readonly httpCode: number;\n readonly requestId: string;\n readonly timestamp: string;\n\n constructor(response: IApiErrorResponse) {\n super(response.message);\n this.name = 'ApiSynovaError';\n this.code = response.code;\n this.httpCode = response.httpCode;\n this.requestId = response.requestId;\n this.timestamp = response.timestamp;\n }\n}\n\n/**\n * Error thrown when authentication fails\n */\nexport class AuthSynovaError extends SynovaError {\n constructor(message = 'Invalid or missing API key') {\n super(message);\n this.name = 'AuthSynovaError';\n }\n}\n\n/**\n * Error thrown when resource is not found\n */\nexport class NotFoundSynovaError extends SynovaError {\n readonly resourceType: string;\n readonly resourceId: string;\n\n constructor(resourceType: string, resourceId: string) {\n super(`${resourceType} not found: ${resourceId}`);\n this.name = 'NotFoundSynovaError';\n this.resourceType = resourceType;\n this.resourceId = resourceId;\n }\n}\n\n/**\n * Error thrown when rate limit is exceeded\n */\nexport class RateLimitSynovaError extends SynovaError {\n readonly retryAfterMs?: number;\n\n constructor(message = 'Rate limit exceeded', retryAfterMs?: number) {\n super(message);\n this.name = 'RateLimitSynovaError';\n this.retryAfterMs = retryAfterMs;\n }\n}\n\n/**\n * Error thrown when request times out\n */\nexport class TimeoutSynovaError extends SynovaError {\n readonly timeoutMs: number;\n\n constructor(timeoutMs: number) {\n super(`Request timed out after ${timeoutMs}ms`);\n this.name = 'TimeoutSynovaError';\n this.timeoutMs = timeoutMs;\n }\n}\n\n/**\n * Error thrown when network request fails\n */\nexport class NetworkSynovaError extends SynovaError {\n readonly cause?: Error;\n\n constructor(message: string, cause?: Error) {\n super(message);\n this.name = 'NetworkSynovaError';\n this.cause = cause;\n }\n}\n\n/**\n * Error thrown when server returns 5xx error\n */\nexport class ServerSynovaError extends SynovaError {\n readonly httpCode: number;\n readonly retryable: boolean;\n\n constructor(httpCode: number, message?: string) {\n super(message || `Server error: ${httpCode}`);\n this.name = 'ServerSynovaError';\n this.httpCode = httpCode;\n this.retryable = true;\n }\n}\n","import type { IApiErrorResponse, ISynovaLogger, TSynovaRetryStrategy } from '../types';\nimport {\n ApiSynovaError,\n AuthSynovaError,\n NetworkSynovaError,\n NotFoundSynovaError,\n RateLimitSynovaError,\n ServerSynovaError,\n TimeoutSynovaError,\n} from '../errors';\n\nexport interface IRetryOptions {\n maxRetries: number;\n strategy: TSynovaRetryStrategy;\n initialDelayMs: number;\n maxDelayMs: number;\n backoffMultiplier: number;\n}\n\nexport interface IHttpClientConfig {\n baseUrl: string;\n apiKey: string;\n timeout: number;\n retry: IRetryOptions;\n debug: boolean;\n logger: ISynovaLogger;\n}\n\nexport interface IRequestOptions {\n method: 'GET' | 'POST' | 'PUT' | 'DELETE';\n path: string;\n body?: unknown;\n query?: Record<string, string | undefined>;\n}\n\nexport interface IUploadOptions {\n path: string;\n formData: FormData;\n}\n\nexport class HttpClient {\n private readonly config: IHttpClientConfig;\n\n constructor(config: IHttpClientConfig) {\n this.config = config;\n }\n\n async request<T>(options: IRequestOptions): Promise<T> {\n const url = this.buildUrl(options.path, options.query);\n const { maxRetries } = this.config.retry;\n let lastError: Error | null = null;\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n try {\n if (attempt > 0) {\n const delay = this.calculateRetryDelay(attempt, lastError);\n this.log(\n `Retry attempt ${attempt}/${maxRetries} after ${delay}ms (strategy: ${this.config.retry.strategy})`,\n );\n await this.sleep(delay);\n }\n\n return await this.makeRequest<T>(url, options);\n } catch (error) {\n lastError = error as Error;\n\n if (!this.isRetryable(error)) {\n throw error;\n }\n\n if (attempt === maxRetries) {\n throw error;\n }\n\n this.log(`Request failed, will retry: ${(error as Error).message}`);\n }\n }\n\n throw lastError;\n }\n\n async upload<T>(options: IUploadOptions): Promise<T> {\n const url = this.buildUrl(options.path);\n const { maxRetries } = this.config.retry;\n let lastError: Error | null = null;\n\n for (let attempt = 0; attempt <= maxRetries; attempt++) {\n try {\n if (attempt > 0) {\n const delay = this.calculateRetryDelay(attempt, lastError);\n this.log(\n `Retry attempt ${attempt}/${maxRetries} after ${delay}ms (strategy: ${this.config.retry.strategy})`,\n );\n await this.sleep(delay);\n }\n\n return await this.makeUploadRequest<T>(url, options.formData);\n } catch (error) {\n lastError = error as Error;\n\n if (!this.isRetryable(error)) {\n throw error;\n }\n\n if (attempt === maxRetries) {\n throw error;\n }\n\n this.log(`Upload failed, will retry: ${(error as Error).message}`);\n }\n }\n\n throw lastError;\n }\n\n private async makeRequest<T>(url: string, options: IRequestOptions): Promise<T> {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);\n\n this.log(`${options.method} ${url}`);\n\n try {\n const response = await fetch(url, {\n method: options.method,\n headers: {\n Authorization: `Bearer ${this.config.apiKey}`,\n 'Content-Type': 'application/json',\n 'User-Agent': 'synova-cloud-sdk-node/0.1.0',\n },\n body: options.body ? JSON.stringify(options.body) : undefined,\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n await this.handleErrorResponse(response);\n }\n\n const data = (await response.json()) as T;\n this.log(`Response: ${response.status}`);\n return data;\n } catch (error) {\n clearTimeout(timeoutId);\n\n if (error instanceof Error && error.name === 'AbortError') {\n throw new TimeoutSynovaError(this.config.timeout);\n }\n\n if (\n error instanceof ApiSynovaError ||\n error instanceof AuthSynovaError ||\n error instanceof NotFoundSynovaError ||\n error instanceof RateLimitSynovaError ||\n error instanceof ServerSynovaError\n ) {\n throw error;\n }\n\n throw new NetworkSynovaError(\n `Network request failed: ${(error as Error).message}`,\n error as Error,\n );\n }\n }\n\n private async makeUploadRequest<T>(url: string, formData: FormData): Promise<T> {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);\n\n this.log(`POST (upload) ${url}`);\n\n try {\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${this.config.apiKey}`,\n 'User-Agent': 'synova-cloud-sdk-node/0.1.0',\n // Note: Content-Type is not set for FormData - browser/node sets it with boundary\n },\n body: formData,\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n if (!response.ok) {\n await this.handleErrorResponse(response);\n }\n\n const data = (await response.json()) as T;\n this.log(`Response: ${response.status}`);\n return data;\n } catch (error) {\n clearTimeout(timeoutId);\n\n if (error instanceof Error && error.name === 'AbortError') {\n throw new TimeoutSynovaError(this.config.timeout);\n }\n\n if (\n error instanceof ApiSynovaError ||\n error instanceof AuthSynovaError ||\n error instanceof NotFoundSynovaError ||\n error instanceof RateLimitSynovaError ||\n error instanceof ServerSynovaError\n ) {\n throw error;\n }\n\n throw new NetworkSynovaError(\n `Upload request failed: ${(error as Error).message}`,\n error as Error,\n );\n }\n }\n\n private async handleErrorResponse(response: Response): Promise<never> {\n const status = response.status;\n\n // Try to parse error body\n let errorBody: IApiErrorResponse | null = null;\n try {\n errorBody = (await response.json()) as IApiErrorResponse;\n } catch {\n // Ignore JSON parse errors\n }\n\n if (status === 401) {\n throw new AuthSynovaError(errorBody?.message);\n }\n\n if (status === 404) {\n throw new NotFoundSynovaError('Resource', errorBody?.message || 'unknown');\n }\n\n if (status === 429) {\n const retryAfter = response.headers.get('Retry-After');\n const retryAfterMs = retryAfter ? parseInt(retryAfter, 10) * 1000 : undefined;\n throw new RateLimitSynovaError(errorBody?.message, retryAfterMs);\n }\n\n if (status >= 500) {\n throw new ServerSynovaError(status, errorBody?.message);\n }\n\n if (errorBody) {\n throw new ApiSynovaError(errorBody);\n }\n\n throw new ApiSynovaError({\n code: 'UNKNOWN_ERROR',\n httpCode: status,\n message: `HTTP ${status}: ${response.statusText}`,\n requestId: 'unknown',\n timestamp: new Date().toISOString(),\n });\n }\n\n private buildUrl(path: string, query?: Record<string, string | undefined>): string {\n const url = new URL(path, this.config.baseUrl);\n\n if (query) {\n for (const [key, value] of Object.entries(query)) {\n if (value !== undefined) {\n url.searchParams.set(key, value);\n }\n }\n }\n\n return url.toString();\n }\n\n private isRetryable(error: unknown): boolean {\n if (error instanceof RateLimitSynovaError) return true;\n if (error instanceof ServerSynovaError) return true;\n if (error instanceof NetworkSynovaError) return true;\n if (error instanceof TimeoutSynovaError) return true;\n return false;\n }\n\n private calculateRetryDelay(attempt: number, error: Error | null): number {\n const { strategy, initialDelayMs, maxDelayMs, backoffMultiplier } = this.config.retry;\n\n // Use Retry-After header if available (takes priority)\n if (error instanceof RateLimitSynovaError && error.retryAfterMs) {\n return Math.min(error.retryAfterMs, maxDelayMs);\n }\n\n let baseDelay: number;\n\n if (strategy === 'linear') {\n // Linear: initialDelay * attempt (1000, 2000, 3000, ...)\n baseDelay = initialDelayMs * attempt;\n } else {\n // Exponential: initialDelay * multiplier^(attempt-1) (1000, 2000, 4000, ...)\n baseDelay = initialDelayMs * Math.pow(backoffMultiplier, attempt - 1);\n }\n\n // Add jitter (±10%) to prevent thundering herd\n const jitter = baseDelay * 0.1 * (Math.random() * 2 - 1);\n const delay = baseDelay + jitter;\n\n return Math.min(Math.max(delay, 0), maxDelayMs);\n }\n\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n private log(message: string): void {\n if (this.config.debug) {\n this.config.logger.debug(`[Synova SDK] ${message}`);\n }\n }\n}\n","import type { HttpClient } from '../utils/http';\nimport type {\n ISynovaPrompt,\n ISynovaGetPromptOptions,\n ISynovaExecuteOptions,\n ISynovaExecuteResponse,\n} from '../types';\n\nexport class PromptsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Get a prompt by ID (returns version with 'latest' tag)\n *\n * @param promptId - The prompt ID (e.g., 'prm_abc123')\n * @param options - Optional settings\n * @returns The prompt data\n *\n * @example\n * ```ts\n * // Get default (latest) version\n * const prompt = await client.prompts.get('prm_abc123');\n *\n * // Get by specific tag\n * const production = await client.prompts.get('prm_abc123', { tag: 'production' });\n *\n * // Get specific version\n * const v2 = await client.prompts.get('prm_abc123', { version: '2.0.0' });\n * ```\n */\n async get(promptId: string, options?: ISynovaGetPromptOptions): Promise<ISynovaPrompt> {\n // Version takes precedence over tag\n if (options?.version) {\n return this.http.request<ISynovaPrompt>({\n method: 'GET',\n path: `/api/v1/prompts/${promptId}/versions/${options.version}`,\n });\n }\n\n // Tag (defaults to 'latest')\n const tag = options?.tag || 'latest';\n if (tag === 'latest') {\n return this.http.request<ISynovaPrompt>({\n method: 'GET',\n path: `/api/v1/prompts/${promptId}`,\n });\n }\n\n return this.http.request<ISynovaPrompt>({\n method: 'GET',\n path: `/api/v1/prompts/${promptId}/tags/${tag}`,\n });\n }\n\n /**\n * Execute a prompt with 'latest' tag\n *\n * @param promptId - The prompt ID\n * @param options - Execution options including provider, model and variables\n * @returns The execution response\n *\n * @example\n * ```ts\n * const result = await client.prompts.execute('prm_abc123', {\n * provider: 'openai',\n * model: 'gpt-4o',\n * variables: { topic: 'TypeScript' },\n * });\n *\n * if (result.type === 'message') {\n * console.log(result.content);\n * }\n *\n * // Image generation\n * const imageResult = await client.prompts.execute('prm_image123', {\n * provider: 'google',\n * model: 'gemini-2.0-flash-exp',\n * variables: { style: 'modern' },\n * });\n *\n * if (imageResult.type === 'image') {\n * console.log('Generated images:', imageResult.files);\n * }\n * ```\n */\n async execute(promptId: string, options: ISynovaExecuteOptions): Promise<ISynovaExecuteResponse> {\n const body: Record<string, unknown> = {\n provider: options.provider,\n model: options.model,\n };\n\n // Only add optional fields if they are defined\n if (options.variables !== undefined) body.variables = options.variables;\n if (options.messages !== undefined) body.messages = options.messages;\n if (options.tag !== undefined) body.tag = options.tag;\n if (options.version !== undefined) body.version = options.version;\n if (options.metadata !== undefined) body.metadata = options.metadata;\n if (options.parameters !== undefined) body.parameters = options.parameters;\n if (options.responseSchema !== undefined) body.responseSchema = options.responseSchema;\n\n return this.http.request<ISynovaExecuteResponse>({\n method: 'POST',\n path: `/api/v1/prompts/${promptId}/run`,\n body,\n });\n }\n\n /**\n * Execute a prompt by tag\n *\n * @param promptId - The prompt ID\n * @param tag - The tag (e.g., 'latest', 'production', 'staging')\n * @param options - Execution options\n * @returns The execution response\n *\n * @example\n * ```ts\n * const result = await client.prompts.executeByTag('prm_abc123', 'production', {\n * provider: 'openai',\n * model: 'gpt-4o',\n * variables: { topic: 'TypeScript' },\n * });\n * ```\n */\n async executeByTag(\n promptId: string,\n tag: string,\n options: ISynovaExecuteOptions,\n ): Promise<ISynovaExecuteResponse> {\n return this.http.request<ISynovaExecuteResponse>({\n method: 'POST',\n path: `/api/v1/prompts/${promptId}/run`,\n body: {\n tag,\n provider: options.provider,\n model: options.model,\n variables: options.variables,\n messages: options.messages,\n metadata: options.metadata,\n parameters: options.parameters,\n },\n });\n }\n\n /**\n * Execute a prompt by version\n *\n * @param promptId - The prompt ID\n * @param version - The semantic version (e.g., '1.0.0', '2.1.0')\n * @param options - Execution options\n * @returns The execution response\n *\n * @example\n * ```ts\n * const result = await client.prompts.executeByVersion('prm_abc123', '1.2.0', {\n * provider: 'openai',\n * model: 'gpt-4o',\n * variables: { topic: 'TypeScript' },\n * });\n * ```\n */\n async executeByVersion(\n promptId: string,\n version: string,\n options: ISynovaExecuteOptions,\n ): Promise<ISynovaExecuteResponse> {\n return this.http.request<ISynovaExecuteResponse>({\n method: 'POST',\n path: `/api/v1/prompts/${promptId}/run`,\n body: {\n version,\n provider: options.provider,\n model: options.model,\n variables: options.variables,\n messages: options.messages,\n metadata: options.metadata,\n parameters: options.parameters,\n },\n });\n }\n}\n","import type { HttpClient } from '../utils/http';\nimport type { ISynovaModel, ISynovaModelsResponse, ISynovaListModelsOptions } from '../types';\n\ninterface IProviderModelsResponse {\n models: ISynovaModel[];\n}\n\nexport class ModelsResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * List all available models\n *\n * @param options - Optional filters\n * @returns List of providers with their models\n *\n * @example\n * ```ts\n * // Get all models\n * const { providers } = await client.models.list();\n *\n * // Filter by type\n * const imageModels = await client.models.list({ type: 'image' });\n *\n * // Filter by capability\n * const functionCallingModels = await client.models.list({\n * capability: 'function_calling',\n * });\n *\n * // Filter by provider\n * const openaiModels = await client.models.list({ provider: 'openai' });\n * ```\n */\n async list(options?: ISynovaListModelsOptions): Promise<ISynovaModelsResponse> {\n return this.http.request<ISynovaModelsResponse>({\n method: 'GET',\n path: '/api/v1/models',\n query: {\n type: options?.type,\n capability: options?.capability,\n provider: options?.provider,\n },\n });\n }\n\n /**\n * Get models for a specific provider\n *\n * @param provider - Provider ID (e.g., 'openai', 'anthropic')\n * @returns List of models for the provider\n *\n * @example\n * ```ts\n * const { models } = await client.models.getByProvider('openai');\n * ```\n */\n async getByProvider(provider: string): Promise<ISynovaModel[]> {\n const response = await this.http.request<IProviderModelsResponse>({\n method: 'GET',\n path: `/api/v1/models/${provider}`,\n });\n return response.models;\n }\n\n /**\n * Get a specific model\n *\n * @param provider - Provider ID\n * @param model - Model ID\n * @returns Model details\n *\n * @example\n * ```ts\n * const model = await client.models.get('openai', 'gpt-4o');\n * console.log(model.capabilities);\n * console.log(model.limits);\n * ```\n */\n async get(provider: string, model: string): Promise<ISynovaModel> {\n return this.http.request<ISynovaModel>({\n method: 'GET',\n path: `/api/v1/models/${provider}/${model}`,\n });\n }\n}\n","import type { HttpClient } from '../utils/http';\nimport type { ISynovaUploadResponse, ISynovaUploadOptions } from '../types';\n\nexport class FilesResource {\n constructor(private readonly http: HttpClient) {}\n\n /**\n * Upload files for use in prompt execution\n *\n * @param files - Array of File or Blob objects to upload\n * @param options - Upload options including projectId\n * @returns Upload response with file metadata\n *\n * @example\n * ```ts\n * // Upload files\n * const result = await client.files.upload(\n * [file1, file2],\n * { projectId: 'prj_abc123' }\n * );\n *\n * console.log('Uploaded files:', result.data);\n *\n * // Use uploaded file in prompt execution\n * const response = await client.prompts.execute('prm_abc123', {\n * provider: 'openai',\n * model: 'gpt-4o',\n * messages: [\n * {\n * role: 'user',\n * content: 'Describe this image',\n * files: [{ fileId: result.data[0].id }],\n * },\n * ],\n * });\n * ```\n */\n async upload(\n files: (File | Blob)[],\n options: ISynovaUploadOptions,\n ): Promise<ISynovaUploadResponse> {\n const formData = new FormData();\n\n for (const file of files) {\n formData.append('files', file);\n }\n\n formData.append('projectId', options.projectId);\n\n return this.http.upload<ISynovaUploadResponse>({\n path: '/api/v1/files/upload',\n formData,\n });\n }\n}\n","import type { ISynovaConfig, ISynovaLogger } from './types';\nimport type { IRetryOptions } from './utils/http';\nimport { HttpClient } from './utils/http';\nimport { PromptsResource } from './resources/prompts';\nimport { ModelsResource } from './resources/models';\nimport { FilesResource } from './resources/files';\n\nconst DEFAULT_BASE_URL = 'https://api.synova.cloud';\nconst DEFAULT_TIMEOUT = 30000;\n\nconst DEFAULT_RETRY: IRetryOptions = {\n maxRetries: 3,\n strategy: 'exponential',\n initialDelayMs: 1000,\n maxDelayMs: 30000,\n backoffMultiplier: 2,\n};\n\nconst DEFAULT_LOGGER: ISynovaLogger = {\n debug: (message, ...args) => console.debug(message, ...args),\n info: (message, ...args) => console.info(message, ...args),\n warn: (message, ...args) => console.warn(message, ...args),\n error: (messageOrError, ...args) => console.error(messageOrError, ...args),\n};\n\n/**\n * Synova Cloud SDK client\n *\n * @example\n * ```ts\n * import { SynovaCloudSdk } from '@synova-cloud/sdk';\n *\n * const client = new SynovaCloudSdk('your-api-key');\n *\n * // Get a prompt\n * const prompt = await client.prompts.get('prm_abc123');\n *\n * // Execute a prompt\n * const result = await client.prompts.execute('prm_abc123', {\n * provider: 'openai',\n * model: 'gpt-4o',\n * variables: { topic: 'TypeScript' },\n * });\n *\n * // List available models\n * const { providers } = await client.models.list();\n *\n * // Get models for a specific provider\n * const openaiModels = await client.models.getByProvider('openai');\n *\n * // With custom retry config\n * const clientWithRetry = new SynovaCloudSdk('your-api-key', {\n * retry: {\n * maxRetries: 5,\n * strategy: 'linear',\n * initialDelayMs: 500,\n * },\n * });\n * ```\n */\nexport class SynovaCloudSdk {\n readonly prompts: PromptsResource;\n readonly models: ModelsResource;\n readonly files: FilesResource;\n\n private readonly http: HttpClient;\n\n /**\n * Create a new Synova Cloud SDK client\n *\n * @param apiKey - Your Synova API key\n * @param config - Optional configuration\n */\n constructor(apiKey: string, config?: ISynovaConfig) {\n if (!apiKey) {\n throw new Error('API key is required');\n }\n\n this.http = new HttpClient({\n baseUrl: config?.baseUrl ?? DEFAULT_BASE_URL,\n apiKey,\n timeout: config?.timeout ?? DEFAULT_TIMEOUT,\n retry: {\n maxRetries: config?.retry?.maxRetries ?? DEFAULT_RETRY.maxRetries,\n strategy: config?.retry?.strategy ?? DEFAULT_RETRY.strategy,\n initialDelayMs: config?.retry?.initialDelayMs ?? DEFAULT_RETRY.initialDelayMs,\n maxDelayMs: config?.retry?.maxDelayMs ?? DEFAULT_RETRY.maxDelayMs,\n backoffMultiplier: config?.retry?.backoffMultiplier ?? DEFAULT_RETRY.backoffMultiplier,\n },\n debug: config?.debug ?? false,\n logger: config?.logger ?? DEFAULT_LOGGER,\n });\n\n this.prompts = new PromptsResource(this.http);\n this.models = new ModelsResource(this.http);\n this.files = new FilesResource(this.http);\n }\n}\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,564 @@
|
|
|
1
|
+
type TSynovaMessageRole = 'system' | 'user' | 'assistant' | 'tool';
|
|
2
|
+
type TSynovaResponseType = 'message' | 'tool_calls' | 'image' | 'error';
|
|
3
|
+
type TSynovaModelType = 'text' | 'image';
|
|
4
|
+
interface ISynovaLogger {
|
|
5
|
+
debug: (message: string, ...args: unknown[]) => void;
|
|
6
|
+
info: (message: string, ...args: unknown[]) => void;
|
|
7
|
+
warn: (message: string, ...args: unknown[]) => void;
|
|
8
|
+
error: (messageOrError: string | Error, ...args: unknown[]) => void;
|
|
9
|
+
}
|
|
10
|
+
type TSynovaRetryStrategy = 'exponential' | 'linear';
|
|
11
|
+
interface ISynovaRetryConfig {
|
|
12
|
+
/** Maximum retry attempts (default: 3) */
|
|
13
|
+
maxRetries?: number;
|
|
14
|
+
/** Retry strategy: 'exponential' or 'linear' (default: 'exponential') */
|
|
15
|
+
strategy?: TSynovaRetryStrategy;
|
|
16
|
+
/** Initial delay in milliseconds (default: 1000) */
|
|
17
|
+
initialDelayMs?: number;
|
|
18
|
+
/** Maximum delay in milliseconds (default: 30000) */
|
|
19
|
+
maxDelayMs?: number;
|
|
20
|
+
/** Multiplier for exponential backoff (default: 2) */
|
|
21
|
+
backoffMultiplier?: number;
|
|
22
|
+
}
|
|
23
|
+
interface ISynovaConfig {
|
|
24
|
+
/** Base URL for API (default: https://api.synova.cloud) */
|
|
25
|
+
baseUrl?: string;
|
|
26
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
27
|
+
timeout?: number;
|
|
28
|
+
/** Retry configuration */
|
|
29
|
+
retry?: ISynovaRetryConfig;
|
|
30
|
+
/** Enable debug logging (default: false) */
|
|
31
|
+
debug?: boolean;
|
|
32
|
+
/** Custom logger (default: console) */
|
|
33
|
+
logger?: ISynovaLogger;
|
|
34
|
+
}
|
|
35
|
+
interface ISynovaPromptVariable {
|
|
36
|
+
name: string;
|
|
37
|
+
type: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
defaultValue?: string;
|
|
40
|
+
}
|
|
41
|
+
interface ISynovaPrompt {
|
|
42
|
+
promptId: string;
|
|
43
|
+
name: string;
|
|
44
|
+
version: string;
|
|
45
|
+
messages: ISynovaMessage[];
|
|
46
|
+
variables: ISynovaPromptVariable[];
|
|
47
|
+
tags: string[];
|
|
48
|
+
createdAt: string;
|
|
49
|
+
}
|
|
50
|
+
interface ISynovaGetPromptOptions {
|
|
51
|
+
/** Tag to retrieve (e.g., 'latest', 'production') */
|
|
52
|
+
tag?: string;
|
|
53
|
+
/** Version to retrieve (e.g., '1.0.0') */
|
|
54
|
+
version?: string;
|
|
55
|
+
}
|
|
56
|
+
interface ISynovaToolCall {
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
arguments: Record<string, unknown>;
|
|
60
|
+
}
|
|
61
|
+
interface ISynovaToolResult {
|
|
62
|
+
/** ID of the tool call this result responds to */
|
|
63
|
+
toolCallId: string;
|
|
64
|
+
/** Result content (typically JSON stringified) */
|
|
65
|
+
content: string;
|
|
66
|
+
}
|
|
67
|
+
interface ISynovaMessage {
|
|
68
|
+
role: TSynovaMessageRole;
|
|
69
|
+
/** Message content (required for user/assistant, optional for tool) */
|
|
70
|
+
content?: string;
|
|
71
|
+
/** Structured object (for assistant messages with responseSchema) */
|
|
72
|
+
object?: unknown;
|
|
73
|
+
/** Tool call ID (for tool messages) */
|
|
74
|
+
toolCallId?: string;
|
|
75
|
+
/** Tool calls requested by assistant (when role='assistant') */
|
|
76
|
+
toolCalls?: ISynovaToolCall[];
|
|
77
|
+
/** Tool execution results (when role='tool') */
|
|
78
|
+
toolResults?: ISynovaToolResult[];
|
|
79
|
+
/** File attachments (images, PDFs, text files) */
|
|
80
|
+
files?: ISynovaFileAttachment[];
|
|
81
|
+
}
|
|
82
|
+
interface ISynovaExecuteOptions {
|
|
83
|
+
/** LLM provider (e.g., 'openai', 'anthropic', 'google', 'azure_openai', 'deepseek') */
|
|
84
|
+
provider: string;
|
|
85
|
+
/** LLM model to use (e.g., 'gpt-4o', 'claude-sonnet-4-20250514') */
|
|
86
|
+
model: string;
|
|
87
|
+
/** Variables to substitute in prompt template */
|
|
88
|
+
variables?: Record<string, unknown>;
|
|
89
|
+
/** Previous messages for multi-turn conversation */
|
|
90
|
+
messages?: ISynovaMessage[];
|
|
91
|
+
/** Version tag (e.g., 'latest', 'production', 'staging') */
|
|
92
|
+
tag?: string;
|
|
93
|
+
/** Specific version number (e.g., '1.2.0') - takes precedence over tag */
|
|
94
|
+
version?: string;
|
|
95
|
+
/** Custom metadata for tracking/filtering in analytics */
|
|
96
|
+
metadata?: Record<string, string>;
|
|
97
|
+
/** Model parameters (temperature, maxTokens, topP, topK, etc.) */
|
|
98
|
+
parameters?: Record<string, unknown>;
|
|
99
|
+
/** JSON Schema for structured output */
|
|
100
|
+
responseSchema?: Record<string, unknown>;
|
|
101
|
+
}
|
|
102
|
+
interface ISynovaUsage {
|
|
103
|
+
inputTokens: number;
|
|
104
|
+
outputTokens: number;
|
|
105
|
+
totalTokens: number;
|
|
106
|
+
}
|
|
107
|
+
interface ISynovaExecutionError {
|
|
108
|
+
code: string;
|
|
109
|
+
message: string;
|
|
110
|
+
provider?: string;
|
|
111
|
+
retryable: boolean;
|
|
112
|
+
retryAfterMs?: number;
|
|
113
|
+
details?: unknown;
|
|
114
|
+
}
|
|
115
|
+
interface ISynovaFileThumbnails {
|
|
116
|
+
/** Small thumbnail URL (120px width) */
|
|
117
|
+
small?: string;
|
|
118
|
+
/** Medium thumbnail URL (240px width) */
|
|
119
|
+
medium?: string;
|
|
120
|
+
/** Large thumbnail URL (480px width) */
|
|
121
|
+
large?: string;
|
|
122
|
+
}
|
|
123
|
+
interface ISynovaFileAttachment {
|
|
124
|
+
/** Reference to uploaded file by ID */
|
|
125
|
+
fileId?: string;
|
|
126
|
+
/** File URL */
|
|
127
|
+
url?: string;
|
|
128
|
+
/** MIME type (e.g., 'image/png', 'application/pdf') */
|
|
129
|
+
mimeType?: string;
|
|
130
|
+
/** Thumbnail URLs for images */
|
|
131
|
+
thumbnails?: ISynovaFileThumbnails;
|
|
132
|
+
}
|
|
133
|
+
interface ISynovaExecuteResponse {
|
|
134
|
+
type: TSynovaResponseType;
|
|
135
|
+
/** Text content (when type='message') */
|
|
136
|
+
content?: string;
|
|
137
|
+
/** Structured output object (when responseSchema provided) */
|
|
138
|
+
object?: unknown;
|
|
139
|
+
/** Tool calls requested by LLM (when type='tool_calls') */
|
|
140
|
+
toolCalls?: ISynovaToolCall[];
|
|
141
|
+
/** Generated files/images (when type='image') */
|
|
142
|
+
files?: ISynovaFileAttachment[];
|
|
143
|
+
/** Error details (when type='error') */
|
|
144
|
+
error?: ISynovaExecutionError;
|
|
145
|
+
/** Token usage statistics */
|
|
146
|
+
usage?: ISynovaUsage;
|
|
147
|
+
}
|
|
148
|
+
interface ISynovaModelCapabilities {
|
|
149
|
+
text_generation?: boolean;
|
|
150
|
+
function_calling?: boolean;
|
|
151
|
+
vision?: boolean;
|
|
152
|
+
json_mode?: boolean;
|
|
153
|
+
streaming?: boolean;
|
|
154
|
+
reasoning?: boolean;
|
|
155
|
+
extended_thinking?: boolean;
|
|
156
|
+
text_to_image?: boolean;
|
|
157
|
+
image_to_image?: boolean;
|
|
158
|
+
}
|
|
159
|
+
interface ISynovaModelLimits {
|
|
160
|
+
context_window?: number;
|
|
161
|
+
max_output_tokens?: number;
|
|
162
|
+
}
|
|
163
|
+
interface ISynovaModelPricing {
|
|
164
|
+
effective_from: string;
|
|
165
|
+
input?: number;
|
|
166
|
+
output?: number;
|
|
167
|
+
per_image?: number;
|
|
168
|
+
}
|
|
169
|
+
interface ISynovaModel {
|
|
170
|
+
id: string;
|
|
171
|
+
provider: string;
|
|
172
|
+
display_name: string;
|
|
173
|
+
type: TSynovaModelType;
|
|
174
|
+
capabilities: ISynovaModelCapabilities;
|
|
175
|
+
limits: ISynovaModelLimits;
|
|
176
|
+
pricing?: ISynovaModelPricing[];
|
|
177
|
+
deprecated_from?: string;
|
|
178
|
+
}
|
|
179
|
+
interface ISynovaProvider {
|
|
180
|
+
id: string;
|
|
181
|
+
display_name: string;
|
|
182
|
+
models: ISynovaModel[];
|
|
183
|
+
}
|
|
184
|
+
interface ISynovaModelsResponse {
|
|
185
|
+
providers: ISynovaProvider[];
|
|
186
|
+
}
|
|
187
|
+
interface ISynovaListModelsOptions {
|
|
188
|
+
/** Filter by model type */
|
|
189
|
+
type?: TSynovaModelType;
|
|
190
|
+
/** Filter by capability */
|
|
191
|
+
capability?: keyof ISynovaModelCapabilities;
|
|
192
|
+
/** Filter by provider */
|
|
193
|
+
provider?: string;
|
|
194
|
+
}
|
|
195
|
+
interface ISynovaUploadedFile {
|
|
196
|
+
/** File ID */
|
|
197
|
+
id: string;
|
|
198
|
+
/** URL for file access */
|
|
199
|
+
url: string;
|
|
200
|
+
/** Thumbnail URL for preview */
|
|
201
|
+
thumbnailUrl?: string;
|
|
202
|
+
/** Original file name */
|
|
203
|
+
originalName: string;
|
|
204
|
+
/** MIME type (e.g., 'image/png', 'application/pdf') */
|
|
205
|
+
mimeType: string;
|
|
206
|
+
/** File size in bytes */
|
|
207
|
+
size: number;
|
|
208
|
+
/** File category ('image', 'video', 'audio', 'document', 'other') */
|
|
209
|
+
fileCategory: string;
|
|
210
|
+
/** Creation date (ISO 8601) */
|
|
211
|
+
createdAt: string;
|
|
212
|
+
}
|
|
213
|
+
interface ISynovaUploadResponse {
|
|
214
|
+
/** Uploaded files */
|
|
215
|
+
data: ISynovaUploadedFile[];
|
|
216
|
+
}
|
|
217
|
+
interface ISynovaUploadOptions {
|
|
218
|
+
/** Project ID to associate files with */
|
|
219
|
+
projectId: string;
|
|
220
|
+
}
|
|
221
|
+
interface IApiErrorResponse {
|
|
222
|
+
code: string;
|
|
223
|
+
httpCode: number;
|
|
224
|
+
message: string;
|
|
225
|
+
requestId: string;
|
|
226
|
+
timestamp: string;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
interface IRetryOptions {
|
|
230
|
+
maxRetries: number;
|
|
231
|
+
strategy: TSynovaRetryStrategy;
|
|
232
|
+
initialDelayMs: number;
|
|
233
|
+
maxDelayMs: number;
|
|
234
|
+
backoffMultiplier: number;
|
|
235
|
+
}
|
|
236
|
+
interface IHttpClientConfig {
|
|
237
|
+
baseUrl: string;
|
|
238
|
+
apiKey: string;
|
|
239
|
+
timeout: number;
|
|
240
|
+
retry: IRetryOptions;
|
|
241
|
+
debug: boolean;
|
|
242
|
+
logger: ISynovaLogger;
|
|
243
|
+
}
|
|
244
|
+
interface IRequestOptions {
|
|
245
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
246
|
+
path: string;
|
|
247
|
+
body?: unknown;
|
|
248
|
+
query?: Record<string, string | undefined>;
|
|
249
|
+
}
|
|
250
|
+
interface IUploadOptions {
|
|
251
|
+
path: string;
|
|
252
|
+
formData: FormData;
|
|
253
|
+
}
|
|
254
|
+
declare class HttpClient {
|
|
255
|
+
private readonly config;
|
|
256
|
+
constructor(config: IHttpClientConfig);
|
|
257
|
+
request<T>(options: IRequestOptions): Promise<T>;
|
|
258
|
+
upload<T>(options: IUploadOptions): Promise<T>;
|
|
259
|
+
private makeRequest;
|
|
260
|
+
private makeUploadRequest;
|
|
261
|
+
private handleErrorResponse;
|
|
262
|
+
private buildUrl;
|
|
263
|
+
private isRetryable;
|
|
264
|
+
private calculateRetryDelay;
|
|
265
|
+
private sleep;
|
|
266
|
+
private log;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
declare class PromptsResource {
|
|
270
|
+
private readonly http;
|
|
271
|
+
constructor(http: HttpClient);
|
|
272
|
+
/**
|
|
273
|
+
* Get a prompt by ID (returns version with 'latest' tag)
|
|
274
|
+
*
|
|
275
|
+
* @param promptId - The prompt ID (e.g., 'prm_abc123')
|
|
276
|
+
* @param options - Optional settings
|
|
277
|
+
* @returns The prompt data
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* ```ts
|
|
281
|
+
* // Get default (latest) version
|
|
282
|
+
* const prompt = await client.prompts.get('prm_abc123');
|
|
283
|
+
*
|
|
284
|
+
* // Get by specific tag
|
|
285
|
+
* const production = await client.prompts.get('prm_abc123', { tag: 'production' });
|
|
286
|
+
*
|
|
287
|
+
* // Get specific version
|
|
288
|
+
* const v2 = await client.prompts.get('prm_abc123', { version: '2.0.0' });
|
|
289
|
+
* ```
|
|
290
|
+
*/
|
|
291
|
+
get(promptId: string, options?: ISynovaGetPromptOptions): Promise<ISynovaPrompt>;
|
|
292
|
+
/**
|
|
293
|
+
* Execute a prompt with 'latest' tag
|
|
294
|
+
*
|
|
295
|
+
* @param promptId - The prompt ID
|
|
296
|
+
* @param options - Execution options including provider, model and variables
|
|
297
|
+
* @returns The execution response
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* ```ts
|
|
301
|
+
* const result = await client.prompts.execute('prm_abc123', {
|
|
302
|
+
* provider: 'openai',
|
|
303
|
+
* model: 'gpt-4o',
|
|
304
|
+
* variables: { topic: 'TypeScript' },
|
|
305
|
+
* });
|
|
306
|
+
*
|
|
307
|
+
* if (result.type === 'message') {
|
|
308
|
+
* console.log(result.content);
|
|
309
|
+
* }
|
|
310
|
+
*
|
|
311
|
+
* // Image generation
|
|
312
|
+
* const imageResult = await client.prompts.execute('prm_image123', {
|
|
313
|
+
* provider: 'google',
|
|
314
|
+
* model: 'gemini-2.0-flash-exp',
|
|
315
|
+
* variables: { style: 'modern' },
|
|
316
|
+
* });
|
|
317
|
+
*
|
|
318
|
+
* if (imageResult.type === 'image') {
|
|
319
|
+
* console.log('Generated images:', imageResult.files);
|
|
320
|
+
* }
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
323
|
+
execute(promptId: string, options: ISynovaExecuteOptions): Promise<ISynovaExecuteResponse>;
|
|
324
|
+
/**
|
|
325
|
+
* Execute a prompt by tag
|
|
326
|
+
*
|
|
327
|
+
* @param promptId - The prompt ID
|
|
328
|
+
* @param tag - The tag (e.g., 'latest', 'production', 'staging')
|
|
329
|
+
* @param options - Execution options
|
|
330
|
+
* @returns The execution response
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* ```ts
|
|
334
|
+
* const result = await client.prompts.executeByTag('prm_abc123', 'production', {
|
|
335
|
+
* provider: 'openai',
|
|
336
|
+
* model: 'gpt-4o',
|
|
337
|
+
* variables: { topic: 'TypeScript' },
|
|
338
|
+
* });
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
executeByTag(promptId: string, tag: string, options: ISynovaExecuteOptions): Promise<ISynovaExecuteResponse>;
|
|
342
|
+
/**
|
|
343
|
+
* Execute a prompt by version
|
|
344
|
+
*
|
|
345
|
+
* @param promptId - The prompt ID
|
|
346
|
+
* @param version - The semantic version (e.g., '1.0.0', '2.1.0')
|
|
347
|
+
* @param options - Execution options
|
|
348
|
+
* @returns The execution response
|
|
349
|
+
*
|
|
350
|
+
* @example
|
|
351
|
+
* ```ts
|
|
352
|
+
* const result = await client.prompts.executeByVersion('prm_abc123', '1.2.0', {
|
|
353
|
+
* provider: 'openai',
|
|
354
|
+
* model: 'gpt-4o',
|
|
355
|
+
* variables: { topic: 'TypeScript' },
|
|
356
|
+
* });
|
|
357
|
+
* ```
|
|
358
|
+
*/
|
|
359
|
+
executeByVersion(promptId: string, version: string, options: ISynovaExecuteOptions): Promise<ISynovaExecuteResponse>;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
declare class ModelsResource {
|
|
363
|
+
private readonly http;
|
|
364
|
+
constructor(http: HttpClient);
|
|
365
|
+
/**
|
|
366
|
+
* List all available models
|
|
367
|
+
*
|
|
368
|
+
* @param options - Optional filters
|
|
369
|
+
* @returns List of providers with their models
|
|
370
|
+
*
|
|
371
|
+
* @example
|
|
372
|
+
* ```ts
|
|
373
|
+
* // Get all models
|
|
374
|
+
* const { providers } = await client.models.list();
|
|
375
|
+
*
|
|
376
|
+
* // Filter by type
|
|
377
|
+
* const imageModels = await client.models.list({ type: 'image' });
|
|
378
|
+
*
|
|
379
|
+
* // Filter by capability
|
|
380
|
+
* const functionCallingModels = await client.models.list({
|
|
381
|
+
* capability: 'function_calling',
|
|
382
|
+
* });
|
|
383
|
+
*
|
|
384
|
+
* // Filter by provider
|
|
385
|
+
* const openaiModels = await client.models.list({ provider: 'openai' });
|
|
386
|
+
* ```
|
|
387
|
+
*/
|
|
388
|
+
list(options?: ISynovaListModelsOptions): Promise<ISynovaModelsResponse>;
|
|
389
|
+
/**
|
|
390
|
+
* Get models for a specific provider
|
|
391
|
+
*
|
|
392
|
+
* @param provider - Provider ID (e.g., 'openai', 'anthropic')
|
|
393
|
+
* @returns List of models for the provider
|
|
394
|
+
*
|
|
395
|
+
* @example
|
|
396
|
+
* ```ts
|
|
397
|
+
* const { models } = await client.models.getByProvider('openai');
|
|
398
|
+
* ```
|
|
399
|
+
*/
|
|
400
|
+
getByProvider(provider: string): Promise<ISynovaModel[]>;
|
|
401
|
+
/**
|
|
402
|
+
* Get a specific model
|
|
403
|
+
*
|
|
404
|
+
* @param provider - Provider ID
|
|
405
|
+
* @param model - Model ID
|
|
406
|
+
* @returns Model details
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* ```ts
|
|
410
|
+
* const model = await client.models.get('openai', 'gpt-4o');
|
|
411
|
+
* console.log(model.capabilities);
|
|
412
|
+
* console.log(model.limits);
|
|
413
|
+
* ```
|
|
414
|
+
*/
|
|
415
|
+
get(provider: string, model: string): Promise<ISynovaModel>;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
declare class FilesResource {
|
|
419
|
+
private readonly http;
|
|
420
|
+
constructor(http: HttpClient);
|
|
421
|
+
/**
|
|
422
|
+
* Upload files for use in prompt execution
|
|
423
|
+
*
|
|
424
|
+
* @param files - Array of File or Blob objects to upload
|
|
425
|
+
* @param options - Upload options including projectId
|
|
426
|
+
* @returns Upload response with file metadata
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* ```ts
|
|
430
|
+
* // Upload files
|
|
431
|
+
* const result = await client.files.upload(
|
|
432
|
+
* [file1, file2],
|
|
433
|
+
* { projectId: 'prj_abc123' }
|
|
434
|
+
* );
|
|
435
|
+
*
|
|
436
|
+
* console.log('Uploaded files:', result.data);
|
|
437
|
+
*
|
|
438
|
+
* // Use uploaded file in prompt execution
|
|
439
|
+
* const response = await client.prompts.execute('prm_abc123', {
|
|
440
|
+
* provider: 'openai',
|
|
441
|
+
* model: 'gpt-4o',
|
|
442
|
+
* messages: [
|
|
443
|
+
* {
|
|
444
|
+
* role: 'user',
|
|
445
|
+
* content: 'Describe this image',
|
|
446
|
+
* files: [{ fileId: result.data[0].id }],
|
|
447
|
+
* },
|
|
448
|
+
* ],
|
|
449
|
+
* });
|
|
450
|
+
* ```
|
|
451
|
+
*/
|
|
452
|
+
upload(files: (File | Blob)[], options: ISynovaUploadOptions): Promise<ISynovaUploadResponse>;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Synova Cloud SDK client
|
|
457
|
+
*
|
|
458
|
+
* @example
|
|
459
|
+
* ```ts
|
|
460
|
+
* import { SynovaCloudSdk } from '@synova-cloud/sdk';
|
|
461
|
+
*
|
|
462
|
+
* const client = new SynovaCloudSdk('your-api-key');
|
|
463
|
+
*
|
|
464
|
+
* // Get a prompt
|
|
465
|
+
* const prompt = await client.prompts.get('prm_abc123');
|
|
466
|
+
*
|
|
467
|
+
* // Execute a prompt
|
|
468
|
+
* const result = await client.prompts.execute('prm_abc123', {
|
|
469
|
+
* provider: 'openai',
|
|
470
|
+
* model: 'gpt-4o',
|
|
471
|
+
* variables: { topic: 'TypeScript' },
|
|
472
|
+
* });
|
|
473
|
+
*
|
|
474
|
+
* // List available models
|
|
475
|
+
* const { providers } = await client.models.list();
|
|
476
|
+
*
|
|
477
|
+
* // Get models for a specific provider
|
|
478
|
+
* const openaiModels = await client.models.getByProvider('openai');
|
|
479
|
+
*
|
|
480
|
+
* // With custom retry config
|
|
481
|
+
* const clientWithRetry = new SynovaCloudSdk('your-api-key', {
|
|
482
|
+
* retry: {
|
|
483
|
+
* maxRetries: 5,
|
|
484
|
+
* strategy: 'linear',
|
|
485
|
+
* initialDelayMs: 500,
|
|
486
|
+
* },
|
|
487
|
+
* });
|
|
488
|
+
* ```
|
|
489
|
+
*/
|
|
490
|
+
declare class SynovaCloudSdk {
|
|
491
|
+
readonly prompts: PromptsResource;
|
|
492
|
+
readonly models: ModelsResource;
|
|
493
|
+
readonly files: FilesResource;
|
|
494
|
+
private readonly http;
|
|
495
|
+
/**
|
|
496
|
+
* Create a new Synova Cloud SDK client
|
|
497
|
+
*
|
|
498
|
+
* @param apiKey - Your Synova API key
|
|
499
|
+
* @param config - Optional configuration
|
|
500
|
+
*/
|
|
501
|
+
constructor(apiKey: string, config?: ISynovaConfig);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Base error class for all Synova SDK errors
|
|
506
|
+
*/
|
|
507
|
+
declare class SynovaError extends Error {
|
|
508
|
+
constructor(message: string);
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Error thrown when API returns an error response
|
|
512
|
+
*/
|
|
513
|
+
declare class ApiSynovaError extends SynovaError {
|
|
514
|
+
readonly code: string;
|
|
515
|
+
readonly httpCode: number;
|
|
516
|
+
readonly requestId: string;
|
|
517
|
+
readonly timestamp: string;
|
|
518
|
+
constructor(response: IApiErrorResponse);
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Error thrown when authentication fails
|
|
522
|
+
*/
|
|
523
|
+
declare class AuthSynovaError extends SynovaError {
|
|
524
|
+
constructor(message?: string);
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Error thrown when resource is not found
|
|
528
|
+
*/
|
|
529
|
+
declare class NotFoundSynovaError extends SynovaError {
|
|
530
|
+
readonly resourceType: string;
|
|
531
|
+
readonly resourceId: string;
|
|
532
|
+
constructor(resourceType: string, resourceId: string);
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Error thrown when rate limit is exceeded
|
|
536
|
+
*/
|
|
537
|
+
declare class RateLimitSynovaError extends SynovaError {
|
|
538
|
+
readonly retryAfterMs?: number;
|
|
539
|
+
constructor(message?: string, retryAfterMs?: number);
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Error thrown when request times out
|
|
543
|
+
*/
|
|
544
|
+
declare class TimeoutSynovaError extends SynovaError {
|
|
545
|
+
readonly timeoutMs: number;
|
|
546
|
+
constructor(timeoutMs: number);
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* Error thrown when network request fails
|
|
550
|
+
*/
|
|
551
|
+
declare class NetworkSynovaError extends SynovaError {
|
|
552
|
+
readonly cause?: Error;
|
|
553
|
+
constructor(message: string, cause?: Error);
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Error thrown when server returns 5xx error
|
|
557
|
+
*/
|
|
558
|
+
declare class ServerSynovaError extends SynovaError {
|
|
559
|
+
readonly httpCode: number;
|
|
560
|
+
readonly retryable: boolean;
|
|
561
|
+
constructor(httpCode: number, message?: string);
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
export { ApiSynovaError, AuthSynovaError, type ISynovaConfig, type ISynovaExecuteOptions, type ISynovaExecuteResponse, type ISynovaExecutionError, type ISynovaFileAttachment, type ISynovaFileThumbnails, type ISynovaGetPromptOptions, type ISynovaListModelsOptions, type ISynovaLogger, type ISynovaMessage, type ISynovaModel, type ISynovaModelCapabilities, type ISynovaModelLimits, type ISynovaModelPricing, type ISynovaModelsResponse, type ISynovaPrompt, type ISynovaPromptVariable, type ISynovaProvider, type ISynovaRetryConfig, type ISynovaToolCall, type ISynovaToolResult, type ISynovaUploadOptions, type ISynovaUploadResponse, type ISynovaUploadedFile, type ISynovaUsage, NetworkSynovaError, NotFoundSynovaError, RateLimitSynovaError, ServerSynovaError, SynovaCloudSdk, SynovaError, type TSynovaMessageRole, type TSynovaModelType, type TSynovaResponseType, type TSynovaRetryStrategy, TimeoutSynovaError };
|