import {z} from 'zod' export type GetApiLocalSandboxGoogleCloudSandboxIdDumpArgs = {sandbox_id: string}; export type GetApiLocalSandboxGoogleCloudSandboxIdDumpOptions = {baseUrl?: string | undefined, HTTPBearer?: string | undefined, fetch?: typeof fetch | undefined}; export const sandboxMCPServer = z.enum(["jira", "github", "salesforce", "hubspot", "notion", "airtable", "linear", "asana", "google_sheets", "google_drive", "google_docs", "gmail", "google_calendar", "google_forms", "clickup", "close", "monday", "motion", "onedrive", "microsoft_teams", "outlook_mail", "cal.com", "quickbooks", "moneybird", "dropbox", "shopify", "woocommerce", "outlook_calendar", "resend", "wordpress", "mem0", "supabase", "slack", "confluence", "discord", "snowflake", "postgres", "mongodb", "youtube", "googleworkspaceatlas", "huggingface", "mock_notion", "arxiv_latex", "calculator", "clinicaltrialsgov", "fetch", "met_museum", "open_library", "osm", "pubmed", "us_weather", "duckduckgo", "whois", "wikipedia", "scholarly", "howtocook", "yahoo_finance", "12306", "youtube_transcript", "weather", "twelvedata", "national_parks", "lara_translate", "e2b", "context7", "alchemy", "weights_and_biases", "oxylabs", "google_maps", "brave_search", "exa", "serper"]); export const bigQueryDataset = z.object({id: z.string(), description: z.string().nullable().optional(), location: z.string().optional(), created_at: z.string().nullable().optional(), updated_at: z.string().nullable().optional()}); export const bigQueryFieldOutput: z.ZodType = z.object({name: z.string(), type: z.string(), mode: z.string().nullable().optional(), description: z.string().nullable().optional(), fields: z.array(z.lazy(() => bigQueryFieldOutput)).nullable().optional()}); export const bigQueryTableOutput = z.object({dataset_id: z.string(), id: z.string(), description: z.string().nullable().optional(), fields: z.array(bigQueryFieldOutput).nullable().optional(), row_count: z.string().nullable().optional(), created_at: z.string().nullable().optional()}); export const lifecycleRule = z.object({action: z.string(), action_storage_class: z.string().nullable().optional(), age_days: z.number().int().nullable().optional(), created_before: z.string().nullable().optional(), is_live: z.boolean().nullable().optional(), num_newer_versions: z.number().int().nullable().optional()}); export const storageBucket = z.object({name: z.string(), location: z.string().optional(), storage_class: z.string().optional(), versioning_enabled: z.boolean().optional(), lifecycle_rules: z.array(lifecycleRule).nullable().optional(), created_at: z.string().nullable().optional(), updated_at: z.string().nullable().optional()}); export const storageObject = z.object({bucket: z.string(), name: z.string(), content_type: z.string().nullable().optional(), size: z.string().nullable().optional(), content: z.string().nullable().optional(), md5_hash: z.string().nullable().optional(), created_at: z.string().nullable().optional(), updated_at: z.string().nullable().optional()}); export const logEntry = z.object({log_name: z.string(), message: z.string().nullable().optional(), json_data: z.record(z.string(), z.unknown()).nullable().optional(), severity: z.string().optional(), timestamp: z.string().nullable().optional(), resource_type: z.string().nullable().optional(), resource_labels: z.record(z.string(), z.string()).nullable().optional()}); export const logSink = z.object({name: z.string(), filter: z.string().nullable().optional(), description: z.string().nullable().optional(), created_at: z.string().nullable().optional(), updated_at: z.string().nullable().optional()}); export const logBucket = z.object({name: z.string(), location: z.string().optional(), retention_days: z.number().int().optional(), description: z.string().nullable().optional(), created_at: z.string().nullable().optional(), updated_at: z.string().nullable().optional()}); export const computeInstance = z.object({name: z.string(), zone: z.string(), machine_type: z.string().optional(), status: z.string().optional(), description: z.string().nullable().optional(), labels: z.record(z.string(), z.string()).nullable().optional(), created_at: z.string().nullable().optional()}); export const googleCloudDataOutput = z.object({datasets: z.array(bigQueryDataset).nullable().optional(), tables: z.array(bigQueryTableOutput).nullable().optional(), buckets: z.array(storageBucket).nullable().optional(), objects: z.array(storageObject).nullable().optional(), log_entries: z.array(logEntry).nullable().optional(), log_sinks: z.array(logSink).nullable().optional(), log_buckets: z.array(logBucket).nullable().optional(), instances: z.array(computeInstance).nullable().optional()}); export const dumpSandboxResponseGoogleCloudData = z.object({sandbox_id: z.string(), server_name: sandboxMCPServer, dumped_at: z.string(), data: googleCloudDataOutput}); 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 }; /** * Export google_cloud sandbox data * * GET /local-sandbox/google_cloud/{sandbox_id}/dump */ export const getApiLocalSandboxGoogleCloudSandboxIdDump = async (args: GetApiLocalSandboxGoogleCloudSandboxIdDumpArgs, options?: GetApiLocalSandboxGoogleCloudSandboxIdDumpOptions) => { const {baseUrl = "https://api.klavis.ai", fetch: fetchFn = fetch, HTTPBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (HTTPBearer !== undefined) headers.set('authorization', `Bearer ${HTTPBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/local-sandbox/google_cloud/${encodeURIComponent(String(args.sandbox_id))}/dump${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(dumpSandboxResponseGoogleCloudData, await res.json()) };