import { z } from 'zod'; declare const LoginRequestSchema: z.ZodObject<{ email: z.ZodString; password: z.ZodString; }, "strip", z.ZodTypeAny, { email: string; password: string; }, { email: string; password: string; }>; declare const RegisterRequestSchema: z.ZodEffects, { email: string; password: string; password_confirmation: string; }, { email: string; password: string; password_confirmation: string; }>; declare const ApiKeyCreateSchema: z.ZodObject<{ name: z.ZodString; }, "strip", z.ZodTypeAny, { name: string; }, { name: string; }>; declare const ApiKeyAllocateSchema: z.ZodObject<{ amount: z.ZodNumber; description: z.ZodString; }, "strip", z.ZodTypeAny, { amount: number; description: string; }, { amount: number; description: string; }>; declare const ApplicationCreateSchema: z.ZodObject<{ name: z.ZodString; slug: z.ZodOptional; description: z.ZodOptional; }, "strip", z.ZodTypeAny, { name: string; slug?: string | undefined; description?: string | undefined; }, { name: string; slug?: string | undefined; description?: string | undefined; }>; declare const WorkspaceCreateSchema: z.ZodObject<{ name: z.ZodString; slug: z.ZodOptional; }, "strip", z.ZodTypeAny, { name: string; slug?: string | undefined; }, { name: string; slug?: string | undefined; }>; declare const InvitationCreateSchema: z.ZodObject<{ email: z.ZodString; role: z.ZodString; scope_type: z.ZodEnum<["tenant", "workspace"]>; scope_id: z.ZodString; }, "strip", z.ZodTypeAny, { email: string; role: string; scope_type: "tenant" | "workspace"; scope_id: string; }, { email: string; role: string; scope_type: "tenant" | "workspace"; scope_id: string; }>; declare const AgentCreateSchema: z.ZodObject<{ name: z.ZodString; prompt_template: z.ZodString; }, "strip", z.ZodTypeAny, { name: string; prompt_template: string; }, { name: string; prompt_template: string; }>; declare const ThreadCreateSchema: z.ZodObject<{ title: z.ZodOptional; }, "strip", z.ZodTypeAny, { title?: string | undefined; }, { title?: string | undefined; }>; declare const MessageSendSchema: z.ZodObject<{ content: z.ZodString; }, "strip", z.ZodTypeAny, { content: string; }, { content: string; }>; declare const SearchRequestSchema: z.ZodObject<{ query: z.ZodString; top_k: z.ZodDefault; }, "strip", z.ZodTypeAny, { query: string; top_k: number; }, { query: string; top_k?: number | undefined; }>; declare const EmbedRequestSchema: z.ZodObject<{ text: z.ZodString; workspace_id: z.ZodOptional; }, "strip", z.ZodTypeAny, { text: string; workspace_id?: string | undefined; }, { text: string; workspace_id?: string | undefined; }>; declare const DocumentUploadBase64Schema: z.ZodObject<{ filename: z.ZodString; content: z.ZodString; }, "strip", z.ZodTypeAny, { content: string; filename: string; }, { content: string; filename: string; }>; declare const BucketCreateSchema: z.ZodObject<{ name: z.ZodString; type: z.ZodEnum<["public", "private"]>; }, "strip", z.ZodTypeAny, { name: string; type: "public" | "private"; }, { name: string; type: "public" | "private"; }>; declare const PresignedUploadSchema: z.ZodObject<{ filename: z.ZodString; content_type: z.ZodString; }, "strip", z.ZodTypeAny, { filename: string; content_type: string; }, { filename: string; content_type: string; }>; declare const PresignedDownloadSchema: z.ZodObject<{ file_id: z.ZodString; }, "strip", z.ZodTypeAny, { file_id: string; }, { file_id: string; }>; declare const WebhookConfigCreateSchema: z.ZodObject<{ name: z.ZodString; url: z.ZodString; events: z.ZodOptional>; enabled: z.ZodDefault>; secret: z.ZodOptional; tenant_id: z.ZodOptional; tenant_ids: z.ZodOptional>; workspace_ids: z.ZodOptional>; }, "strip", z.ZodTypeAny, { name: string; url: string; enabled: boolean; tenant_id?: string | undefined; workspace_ids?: string[] | undefined; events?: string[] | undefined; secret?: string | undefined; tenant_ids?: string[] | undefined; }, { name: string; url: string; tenant_id?: string | undefined; workspace_ids?: string[] | undefined; events?: string[] | undefined; enabled?: boolean | undefined; secret?: string | undefined; tenant_ids?: string[] | undefined; }>; declare const WebhookConfigUpdateSchema: z.ZodObject<{ name: z.ZodOptional; url: z.ZodOptional; events: z.ZodOptional>; enabled: z.ZodOptional; secret: z.ZodOptional; tenant_ids: z.ZodOptional>; workspace_ids: z.ZodOptional>; }, "strip", z.ZodTypeAny, { name?: string | undefined; url?: string | undefined; workspace_ids?: string[] | undefined; events?: string[] | undefined; enabled?: boolean | undefined; secret?: string | undefined; tenant_ids?: string[] | undefined; }, { name?: string | undefined; url?: string | undefined; workspace_ids?: string[] | undefined; events?: string[] | undefined; enabled?: boolean | undefined; secret?: string | undefined; tenant_ids?: string[] | undefined; }>; declare const AgentUpdateSchema: z.ZodObject<{ name: z.ZodOptional; prompt_template: z.ZodOptional; description: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ name: z.ZodOptional; prompt_template: z.ZodOptional; description: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ name: z.ZodOptional; prompt_template: z.ZodOptional; description: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; declare const AgentTestInputSchema: z.ZodObject<{ input: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ input: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ input: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; declare const AgentImportSchema: z.ZodObject<{ name: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ name: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ name: z.ZodString; }, z.ZodTypeAny, "passthrough">>; declare const AiSearchAdvancedSchema: z.ZodObject<{ query: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ query: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ query: z.ZodString; }, z.ZodTypeAny, "passthrough">>; declare const ConversationCreateSchema: z.ZodObject<{ title: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ title: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ title: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; declare const ConversationUpdateSchema: z.ZodObject<{ title: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ title: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ title: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; declare const MessageCreateSchema: z.ZodObject<{ content: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ content: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ content: z.ZodString; }, z.ZodTypeAny, "passthrough">>; declare const MessageStreamSchema: z.ZodObject<{ content: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ content: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ content: z.ZodString; }, z.ZodTypeAny, "passthrough">>; declare const WalletCreditsUpdateSchema: z.ZodObject<{ amount: z.ZodNumber; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ amount: z.ZodNumber; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ amount: z.ZodNumber; }, z.ZodTypeAny, "passthrough">>; declare const WalletAutoTopUpSchema: z.ZodObject<{ enabled: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ enabled: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ enabled: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; declare const WalletAddonsSchema: z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>; declare const NotificationMethodCreateSchema: z.ZodObject<{ type: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ type: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ type: z.ZodString; }, z.ZodTypeAny, "passthrough">>; declare const NotificationMethodUpdateSchema: z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>; declare const NotificationPreferenceCreateSchema: z.ZodObject<{ event_type: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ event_type: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ event_type: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; declare const NotificationPreferenceUpdateSchema: z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>; declare const BeginUploadSchema: z.ZodObject<{ filename: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ filename: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ filename: z.ZodString; }, z.ZodTypeAny, "passthrough">>; declare const ExtractionBatchCreateSchema: z.ZodObject<{ name: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ name: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ name: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; declare const ExtractionExportCreateSchema: z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>; declare const UserProfileUpdateSchema: z.ZodObject<{ display_name: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ display_name: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ display_name: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; declare const WorkspaceUpdateSchema: z.ZodObject<{ name: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ name: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ name: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; declare const ApplicationUpdateSchema: z.ZodObject<{ name: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ name: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ name: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; declare const MembershipCreateSchema: z.ZodObject<{ user_id: z.ZodOptional; workspace_id: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ user_id: z.ZodOptional; workspace_id: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ user_id: z.ZodOptional; workspace_id: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; declare const SavedSearchCreateSchema: z.ZodObject<{ name: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ name: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ name: z.ZodString; }, z.ZodTypeAny, "passthrough">>; declare const BucketUpdateSchema: z.ZodObject<{ name: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ name: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ name: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; declare const ObjectRegisterSchema: z.ZodObject<{ key: z.ZodString; bucket_id: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ key: z.ZodString; bucket_id: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ key: z.ZodString; bucket_id: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; declare const ThreadUpdateSchema: z.ZodObject<{ title: z.ZodOptional; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ title: z.ZodOptional; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ title: z.ZodOptional; }, z.ZodTypeAny, "passthrough">>; declare const ThreadMessageStreamSchema: z.ZodObject<{ content: z.ZodString; }, "passthrough", z.ZodTypeAny, z.objectOutputType<{ content: z.ZodString; }, z.ZodTypeAny, "passthrough">, z.objectInputType<{ content: z.ZodString; }, z.ZodTypeAny, "passthrough">>; type LoginRequest = z.infer; type RegisterRequest = z.infer; type ApiKeyCreateRequest = z.infer; type ApiKeyAllocateRequest = z.infer; type ApplicationCreateRequest = z.infer; type WorkspaceCreateRequest = z.infer; type InvitationCreateRequest = z.infer; type AgentCreateRequest = z.infer; type ThreadCreateRequest = z.infer; type MessageSendRequest = z.infer; type SearchRequest = z.infer; type EmbedRequest = z.infer; type DocumentUploadBase64Request = z.infer; type BucketCreateRequest = z.infer; type PresignedUploadRequest = z.infer; type PresignedDownloadRequest = z.infer; type WebhookConfigCreateRequest = z.infer; type WebhookConfigUpdateRequest = z.infer; type AgentUpdateRequest = z.infer; type AgentTestInput = z.infer; type AgentImportRequest = z.infer; type AiSearchAdvancedRequest = z.infer; type ConversationCreateRequest = z.infer; type ConversationUpdateRequest = z.infer; type MessageCreateRequest = z.infer; type MessageStreamRequest = z.infer; type WalletCreditsUpdateRequest = z.infer; type WalletAutoTopUpRequest = z.infer; type WalletAddonsRequest = z.infer; type NotificationMethodCreateRequest = z.infer; type NotificationMethodUpdateRequest = z.infer; type NotificationPreferenceCreateRequest = z.infer; type NotificationPreferenceUpdateRequest = z.infer; type BeginUploadRequest = z.infer; type ExtractionBatchCreateRequest = z.infer; type ExtractionExportCreateRequest = z.infer; type UserProfileUpdateRequest = z.infer; type WorkspaceUpdateRequest = z.infer; type ApplicationUpdateRequest = z.infer; type MembershipCreateRequest = z.infer; type SavedSearchCreateRequest = z.infer; type BucketUpdateRequest = z.infer; type ObjectRegisterRequest = z.infer; type ThreadUpdateRequest = z.infer; type ThreadMessageStreamRequest = z.infer; /** * Options for streaming requests */ interface StreamOptions { /** * Signal to abort the stream */ signal?: AbortSignal; /** * Callback for handling errors */ onError?: (error: Error) => void; /** * Maximum stream duration in milliseconds (default: 5 minutes) * Prevents DoS via infinite streams */ timeout?: number; /** * Maximum number of chunks to process (default: 10000) * Prevents memory exhaustion via malicious streams */ maxChunks?: number; /** * Maximum buffer size in bytes (default: 10MB) * Prevents unbounded memory growth */ maxBufferSize?: number; } /** * Parse Server-Sent Events (SSE) stream into typed chunks * Security: Enforces timeout, chunk count, and buffer size limits to prevent DoS */ declare function streamSSE(response: Response, options?: StreamOptions): AsyncIterableIterator; /** * Stream AI thread messages with Server-Sent Events */ interface StreamMessageChunk { type: "content" | "done" | "error"; content?: string; error?: string; metadata?: Record; } /** * Parse streaming message response */ declare function streamMessage(response: Response, options?: StreamOptions): AsyncIterableIterator; /** * Collect full message from stream chunks */ declare function collectStreamedMessage(stream: AsyncIterableIterator): Promise; /** * A "Resource object" representing a webhook_config */ type WebhookConfig = { /** * An attributes object for a webhook_config */ attributes?: { /** * Field included by default. */ application_id: string; /** * Field included by default. */ enabled?: boolean | null | unknown; /** * Field included by default. */ events?: Array | null | unknown; /** * Field included by default. */ inserted_at: unknown; /** * Field included by default. */ name: string; /** * HMAC secret for webhook signature verification. Field included by default. */ secret?: string | null | unknown; /** * Field included by default. */ tenant_id?: string | null | unknown; /** * ISV filter: specific tenant UUIDs to receive events from (null = all). Field included by default. */ tenant_ids?: Array | null | unknown; /** * Field included by default. */ updated_at: unknown; /** * Field included by default. */ url: string; /** * Tenant filter: specific workspace UUIDs to receive events from (null = all). Field included by default. */ workspace_ids?: Array | null | unknown; }; id: string; /** * A relationships object for a webhook_config */ relationships?: { application?: { /** * An identifier for application */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; tenant?: { /** * An identifier for tenant */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; }; type: string; }; /** * A "Resource object" representing a wallet */ type Wallet = { /** * An attributes object for a wallet */ attributes?: { /** * Field included by default. */ accounts?: Array<{ [key: string]: unknown; }> | null | unknown; /** * Field included by default. */ addons?: Array<{ [key: string]: unknown; }> | null | unknown; /** * Optional application context - wallets belong to tenants, not applications. Field included by default. */ application_id?: string | null | unknown; /** * Amount in credits. Field included by default. */ auto_top_up_amount?: number | null | unknown; /** * Field included by default. */ auto_top_up_enabled: boolean; /** * Threshold in credits. Field included by default. */ auto_top_up_threshold?: number | null | unknown; /** * Field included by default. */ credits: number; /** * Field included by default. */ credits_free?: number | null | unknown; /** * Field included by default. */ credits_paid?: number | null | unknown; /** * Total promotional credits ever allocated to this tenant. Field included by default. */ credits_promotional_allocated?: number | null | unknown; /** * Total purchased credits ever allocated to this tenant. Field included by default. */ credits_purchased_allocated?: number | null | unknown; /** * Field included by default. */ credits_subscription?: number | null | unknown; /** * Total subscription credits ever allocated to this tenant. Field included by default. */ credits_subscription_allocated?: number | null | unknown; /** * Field included by default. */ payment_methods?: Array<{ [key: string]: unknown; }> | null | unknown; /** * Field included by default. */ plan_id?: string | null | unknown; /** * Field included by default. */ plan_slug?: string | null | unknown; /** * Field included by default. */ storage_quota_bytes: number; /** * Field included by default. */ storage_used_bytes: number; /** * Daily usage history entries. Field included by default. */ usage_history?: Array<{ [key: string]: unknown; }> | null | unknown; /** * Storage breakdown by workspace (Top 3 + Others). Field included by default. */ workspace_storage?: Array<{ [key: string]: unknown; }> | null | unknown; /** * Usage breakdown by workspace (Top 3 + Others). Field included by default. */ workspace_usage?: Array<{ [key: string]: unknown; }> | null | unknown; }; id: string; /** * A relationships object for a wallet */ relationships?: { plan?: { /** * An identifier for plan */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; }; type: string; }; /** * A "Resource object" representing a message */ type Message = { /** * An attributes object for a message */ attributes?: { [key: string]: never; }; id: string; /** * A relationships object for a message */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a user_profile */ type UserProfile = { /** * An attributes object for a user_profile */ attributes?: { /** * Field included by default. */ avatar_url?: string | null | unknown; /** * Field included by default. */ bio?: string | null | unknown; /** * Field included by default. */ first_name?: string | null | unknown; full_name?: string | null | unknown; /** * Field included by default. */ last_name?: string | null | unknown; /** * Field included by default. */ preferences?: { [key: string]: unknown; } | null | unknown; /** * Field included by default. */ social_links?: { [key: string]: unknown; } | null | unknown; /** * Current system messages (ToS, Welcome, Announcement) with user acknowledgment status */ system_messages?: { [key: string]: unknown; } | null | unknown; /** * Field included by default. */ user_id: string; }; id: string; /** * A relationships object for a user_profile */ relationships?: { user?: { /** * An identifier for user */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; }; type: string; }; /** * A "Resource object" representing a thread */ type Thread = { /** * An attributes object for a thread */ attributes?: { /** * Field included by default. */ archived_at?: unknown; /** * Field included by default. */ context_summary?: string | null | unknown; /** * Field included by default. */ title?: string | null | unknown; }; id: string; /** * A relationships object for a thread */ relationships?: { messages?: { /** * Relationship data for messages */ data?: Array<{ id: string; meta?: { [key: string]: unknown; }; type: string; }>; }; }; type: string; }; /** * A "Resource object" representing a notification_log */ type NotificationLog = { /** * An attributes object for a notification_log */ attributes?: { [key: string]: never; }; id: string; /** * A relationships object for a notification_log */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a token */ type Token = { /** * An attributes object for a token */ attributes?: { /** * Field included by default. */ brand?: string | null | unknown; /** * Field included by default. */ exp_month?: number | null | unknown; /** * Field included by default. */ exp_year?: number | null | unknown; /** * Field included by default. */ last4?: string | null | unknown; /** * Field included by default. */ token?: string | null | unknown; }; id: string; /** * A relationships object for a token */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a notification_method */ type NotificationMethod = { /** * An attributes object for a notification_method */ attributes?: { /** * Configuration for the method, e.g. %{email: 'foo@bar.com'} or %{url: '...'}. Field included by default. */ config: { [key: string]: unknown; }; /** * Field included by default. */ is_primary?: boolean | null | unknown; /** * User-friendly name, e.g. 'Personal Email'. Field included by default. */ name: string; /** * Field included by default. */ type: "email" | "sms" | "slack_webhook" | "generic_webhook"; /** * Field included by default. */ user_id: string; /** * When the last verification token was sent. Field included by default. */ verification_sent_at?: unknown; /** * Field included by default. */ verified_at?: unknown; }; id: string; /** * A relationships object for a notification_method */ relationships?: { user?: { /** * An identifier for user */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; }; type: string; }; /** * A "Resource object" representing a payment_method */ type PaymentMethod = { /** * An attributes object for a payment_method */ attributes?: { /** * Field included by default. */ billing_address?: string | null | unknown; /** * Field included by default. */ billing_city?: string | null | unknown; /** * Field included by default. */ billing_state?: string | null | unknown; /** * Field included by default. */ brand?: string | null | unknown; /** * Field included by default. */ created_at: unknown; /** * Field included by default. */ exp_month?: number | null | unknown; /** * Field included by default. */ exp_year?: number | null | unknown; /** * Field included by default. */ holder_name?: string | null | unknown; /** * Field included by default. */ is_default?: boolean | null | unknown; /** * Field included by default. */ last4?: string | null | unknown; /** * Field included by default. */ nickname?: string | null | unknown; /** * Field included by default. */ provider: "qorpay"; /** * Field included by default. */ provider_token: string; /** * Field included by default. */ type: "card" | "bank_account"; /** * Field included by default. */ updated_at: unknown; /** * Field included by default. */ zip_code?: string | null | unknown; }; id: string; /** * A relationships object for a payment_method */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a saved_search */ type SavedSearch = { /** * An attributes object for a saved_search */ attributes?: { /** * Field included by default. */ executed_at?: string | null | unknown; /** * Field included by default. */ filters?: { [key: string]: unknown; } | null | unknown; /** * Field included by default. */ is_shared?: boolean | null | unknown; /** * Field included by default. */ name: string; /** * Field included by default. */ query: string; /** * Field included by default. */ search_type?: "keyword" | "semantic" | unknown; }; id: string; /** * A relationships object for a saved_search */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a agent_stats */ type AgentStats = { /** * An attributes object for a agent_stats */ attributes?: { /** * Field included by default. */ agent_id: string; /** * Field included by default. */ total_calls: number; /** * Field included by default. */ total_cost: number; /** * Field included by default. */ total_tokens: number; }; id: string; /** * A relationships object for a agent_stats */ relationships?: { agent?: { /** * An identifier for agent */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; }; type: string; }; /** * A "Resource object" representing a plan */ type Plan = { /** * An attributes object for a plan */ attributes?: { /** * Field included by default. */ application_id: string; /** * Field included by default. */ billing_interval: number; /** * Field included by default. */ created_at: unknown; /** * One-time credits granted upon first subscription (Welcome Bonus). Field included by default. */ initial_credits: number; /** * Distinguishes base plans from add-ons. Field included by default. */ is_addon: boolean; /** * Maximum number of renewals for free trial (nil = unlimited). Field included by default. */ max_renewals?: number | null | unknown; /** * Field included by default. */ monthly_credits: number; /** * Field included by default. */ monthly_price: { amount: string; currency: string; }; /** * Field included by default. */ name: string; /** * Field included by default. */ slug: string; /** * Number of 20GB storage blocks included in plan. Field included by default. */ storage_blocks: number; /** * Field included by default. */ storage_days?: number | null | unknown; /** * Field included by default. */ type: "credits" | "storage" | "credits_storage" | "compute" | "seats" | "agents" | "support"; /** * Field included by default. */ updated_at: unknown; }; id: string; /** * A relationships object for a plan */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a application */ type Application = { /** * An attributes object for a application */ attributes?: { acting_tenant_id?: string | null | unknown; /** * Field included by default. */ badge_url?: string | null | unknown; /** * ISV's base URL for email links (verification, password reset, magic links). Field included by default. */ base_url: string; current_scopes?: Array | null | unknown; /** * DEPRECATED: Use Plan.initial_credits instead. Credits allocated to new tenants registering via this application. Field included by default. */ default_free_credits: number; /** * Field included by default. */ description?: string | null | unknown; generated_api_key?: string | null | unknown; /** * When true, user registration requires invitation. Field included by default. */ invite_only: boolean; /** * Field included by default. */ logo_url?: string | null | unknown; /** * Field included by default. */ name: string; /** * OAuth configuration for this application. Field included by default. */ oauth?: { /** * Allowed OAuth callback URLs for this application. Field included by default. */ callback_urls?: Array | null | unknown; /** * Default callback URL if not specified in request. Field included by default. */ default_callback_url?: string | null | unknown; /** * Which OAuth providers are enabled for this app. Field included by default. */ enabled_providers?: Array<"google" | "github" | "salesforce"> | null | unknown; /** * Custom GitHub OAuth client ID (optional). Field included by default. */ github_client_id?: string | null | unknown; /** * Custom GitHub OAuth client secret (optional). Field included by default. */ github_client_secret?: string | null | unknown; /** * Custom Google OAuth client ID (optional). Field included by default. */ google_client_id?: string | null | unknown; /** * Custom Google OAuth client secret (optional). Field included by default. */ google_client_secret?: string | null | unknown; } | null | unknown; /** * When true, password registration withholds JWT until email is verified. Field included by default. */ require_email_verification: boolean; /** * Email sender address (falls back to system default). Field included by default. */ sender_email?: string | null | unknown; /** * Email sender display name (falls back to system default). Field included by default. */ sender_name?: string | null | unknown; /** * Field included by default. */ slug: string; /** * Memorable slug for vanity URLs. Field included by default. */ vanity_slug?: string | null | unknown; }; id: string; /** * A relationships object for a application */ relationships?: { addons?: { /** * Relationship data for addons */ data?: Array<{ id: string; meta?: { [key: string]: unknown; }; type: string; }>; }; credit_packages?: { /** * Relationship data for credit_packages */ data?: Array<{ id: string; meta?: { [key: string]: unknown; }; type: string; }>; }; plans?: { /** * Relationship data for plans */ data?: Array<{ id: string; meta?: { [key: string]: unknown; }; type: string; }>; }; workspaces?: { /** * Relationship data for workspaces */ data?: Array<{ id: string; meta?: { [key: string]: unknown; }; type: string; }>; }; }; type: string; }; /** * A "Resource object" representing a api_key */ type ApiKey = { /** * An attributes object for a api_key */ attributes?: { /** * Required - the application this API key belongs to. Field included by default. */ application_id: string; /** * Credits remaining in current budget period */ budget_remaining?: number | null | unknown; /** * When the current budget period will reset */ budget_resets_at?: unknown; /** * Maximum credits allowed per period (null = unlimited). Field included by default. */ credit_limit?: number | null | unknown; /** * Budget reset period. Field included by default. */ credit_limit_period?: "daily" | "weekly" | "monthly" | "yearly" | "lifetime" | unknown; current_scopes?: Array | null | unknown; /** * Field included by default. */ expires_at?: unknown; /** * The raw API key token. Only returned once upon creation or rotation. */ generated_api_key?: string | null | unknown; /** * Field included by default. */ key_type: "user" | "application" | "system" | "server"; /** * Field included by default. */ last_used_at?: unknown; /** * Field included by default. */ name?: string | null | unknown; /** * Credits used in current period (resets based on period). Field included by default. */ period_credits_used: number; /** * When the current budget period began. Field included by default. */ period_started_at?: unknown; /** * Field included by default. */ prefix: string; /** * Rate limit period in seconds. Field included by default. */ rate_limit_period_seconds: number; /** * Maximum requests allowed per period. Field included by default. */ rate_limit_requests: number; /** * Field included by default. */ scopes?: Array | null | unknown; /** * Field included by default. */ status: "active" | "revoked" | "expired"; /** * Field included by default. */ tenant_id?: string | null | unknown; /** * Field included by default. */ total_credits_used: number; /** * Field included by default. */ total_requests: number; /** * Field included by default. */ user_id?: string | null | unknown; /** * Field included by default. */ workspace_id?: string | null | unknown; }; id: string; /** * A relationships object for a api_key */ relationships?: { account?: { /** * An identifier for account */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; application?: { /** * An identifier for application */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; tenant?: { /** * An identifier for tenant */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; user?: { /** * An identifier for user */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; workspace?: { /** * An identifier for workspace */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; }; type: string; }; /** * A "Resource object" representing a document_stats */ type DocumentStats = { /** * An attributes object for a document_stats */ attributes?: { /** * Field included by default. */ completed?: number | null | unknown; /** * Field included by default. */ duplicate?: number | null | unknown; /** * Field included by default. */ failed?: number | null | unknown; /** * Field included by default. */ processing?: number | null | unknown; /** * Field included by default. */ queued?: number | null | unknown; /** * Field included by default. */ total?: number | null | unknown; }; id: string; /** * A relationships object for a document_stats */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a role */ type Role = { /** * An attributes object for a role */ attributes?: { /** * Field included by default. */ application_id?: string | null | unknown; /** * Field included by default. */ description?: string | null | unknown; /** * Field included by default. */ is_system_default: boolean; /** * Field included by default. */ name: string; /** * Field included by default. */ permissions?: Array | null | unknown; }; id: string; /** * A relationships object for a role */ relationships?: { application?: { /** * An identifier for application */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; }; type: string; }; /** * A "Resource object" representing a tenant_stats */ type TenantStats = { /** * An attributes object for a tenant_stats */ attributes?: { /** * Field included by default. */ credits: { [key: string]: unknown; }; /** * Field included by default. */ documents: { [key: string]: unknown; }; /** * Field included by default. */ failed: { [key: string]: unknown; }; /** * Field included by default. */ files: { [key: string]: unknown; }; /** * Field included by default. */ success: { [key: string]: unknown; }; /** * Field included by default. */ tenant_id: string; }; id: string; /** * A relationships object for a tenant_stats */ relationships?: { tenant?: { /** * An identifier for tenant */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; }; type: string; }; /** * A "Resource object" representing a invoice */ type Invoice = { /** * An attributes object for a invoice */ attributes?: { /** * Field included by default. */ amount_due?: number | null | unknown; /** * Field included by default. */ amount_paid?: number | null | unknown; /** * Field included by default. */ created_at?: unknown; /** * Field included by default. */ currency?: string | null | unknown; /** * Field included by default. */ due_date?: unknown; /** * Field included by default. */ invoice_number?: string | null | unknown; /** * Field included by default. */ line_items?: Array<{ [key: string]: unknown; }> | null | unknown; /** * Field included by default. */ pdf_url?: string | null | unknown; /** * Field included by default. */ status?: "draft" | "open" | "paid" | "void" | unknown; }; id: string; /** * A relationships object for a invoice */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a transaction */ type Transaction = { /** * An attributes object for a transaction */ attributes?: { /** * The amount of the transaction. For monetary transactions, this is in cents. For credit usage, this is in credits. Field included by default. */ amount: number; /** * Field included by default. */ created_at: unknown; /** * Field included by default. */ credits_added?: number | null | unknown; /** * Field included by default. */ credits_used?: number | null | unknown; /** * Field included by default. */ currency?: string | null | unknown; /** * Field included by default. */ description?: string | null | unknown; /** * Field included by default. */ error_message?: string | null | unknown; /** * Field included by default. */ metadata?: { [key: string]: unknown; } | null | unknown; /** * Field included by default. */ operation?: "subscription" | "topup" | "extraction" | "training" | "refund" | "addon" | unknown; /** * Field included by default. */ provider_reference?: string | null | unknown; /** * Field included by default. */ service_id?: string | null | unknown; /** * Field included by default. */ status: "pending" | "success" | "failed" | "refunded" | "voided"; /** * Field included by default. */ tenant_id: string; /** * Field included by default. */ transaction_type?: "credit" | "debit" | unknown; /** * Field included by default. */ type?: "sale" | "auth" | "refund" | "void" | unknown; /** * Field included by default. */ updated_at: unknown; }; id: string; /** * A relationships object for a transaction */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a extraction_result */ type ExtractionResult = { /** * An attributes object for a extraction_result */ attributes?: { /** * Average confidence across all extracted fields. Field included by default. */ avg_confidence?: number | null | unknown; /** * Character count of extracted text */ char_count?: number | null | unknown; /** * Classification confidence score. Field included by default. */ classification_confidence?: number | null | unknown; /** * Field included by default. */ credits_used?: string | null | unknown; /** * Specific document type classification. Field included by default. */ document_type?: string | null | unknown; /** * Document domain classification. Field included by default. */ domain?: string | null | unknown; /** * Error message if extraction failed or had issues. Field included by default. */ error_message?: string | null | unknown; /** * Field included by default. */ extracted_fields?: { [key: string]: unknown; } | null | unknown; /** * Time spent on field mapping (string + semantic matching). Field included by default. */ field_mapping_time_ms?: number | null | unknown; /** * Image height in pixels (for image documents) */ image_height?: number | null | unknown; /** * Image width in pixels (for image documents) */ image_width?: number | null | unknown; /** * Line count of extracted text */ line_count?: number | null | unknown; /** * Time spent on LLM field extraction. Field included by default. */ llm_extraction_time_ms?: number | null | unknown; /** * Municipality extracted from document. Field included by default. */ municipality?: string | null | unknown; ocr_blocks?: Array<{ [key: string]: unknown; }> | null | unknown; /** * Time spent on OCR/text extraction (DocTriage or LlamaParse). Field included by default. */ ocr_extraction_time_ms?: number | null | unknown; /** * Field included by default. */ processing_time_ms?: number | null | unknown; schema_id?: string | null | unknown; /** * Schema revision number used for this extraction. Field included by default. */ schema_revision?: number | null | unknown; /** * The version of the schema/agent used for this extraction. Field included by default. */ schema_version?: string | null | unknown; /** * State/province code. Field included by default. */ state?: string | null | unknown; /** * Field included by default. */ status: "pending" | "completed" | "failed"; /** * Field included by default. */ summary?: { [key: string]: unknown; } | null | unknown; /** * Field included by default. */ used_training_example_ids?: Array | null | unknown; /** * Word count of extracted text */ word_count?: number | null | unknown; }; id: string; /** * A relationships object for a extraction_result */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a tenant */ type Tenant = { /** * An attributes object for a tenant */ attributes?: { /** * Field included by default. */ application_id?: string | null | unknown; /** * Amount of credits to purchase during auto top-up. Field included by default. */ auto_top_up_amount: number; /** * Field included by default. */ auto_top_up_enabled: boolean; /** * The credit package to purchase when auto top-up is triggered. Field included by default. */ auto_top_up_package_id?: string | null | unknown; /** * Credit balance threshold to trigger auto top-up. Field included by default. */ auto_top_up_threshold: number; /** * Field included by default. */ badge_url?: string | null | unknown; credit_balance?: number | null | unknown; /** * Field included by default. */ initial_credits?: number | null | unknown; /** * True for auto-created personal tenants, false for organizations. Field included by default. */ is_personal: boolean; /** * Field included by default. */ kind: "platform" | "isv" | "tenant"; /** * Field included by default. */ logo_url?: string | null | unknown; /** * Field included by default. */ name: string; /** * Subscription tier that gates feature access. Field included by default. */ plan_tier: "free" | "pro" | "business" | "enterprise"; /** * Field included by default. */ slug: string; /** * Cost in credits for training on a single document. Field included by default. */ training_price_credits: number; /** * Training pricing info for this tenant */ training_pricing?: { [key: string]: unknown; } | null | unknown; /** * Memorable slug for vanity URLs. Field included by default. */ vanity_slug?: string | null | unknown; }; id: string; /** * A relationships object for a tenant */ relationships?: { application?: { /** * An identifier for application */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; workspaces?: { /** * Relationship data for workspaces */ data?: Array<{ id: string; meta?: { [key: string]: unknown; }; type: string; }>; }; }; type: string; }; /** * A "Resource object" representing a search_analytics */ type SearchAnalytics = { /** * An attributes object for a search_analytics */ attributes?: { /** * Field included by default. */ avg_latency_ms?: number | null | unknown; /** * Field included by default. */ avg_result_count?: number | null | unknown; /** * Field included by default. */ keyword_searches?: number | null | unknown; /** * Field included by default. */ latency_ms?: number | null | unknown; /** * Field included by default. */ query: string; /** * Field included by default. */ result_count?: number | null | unknown; /** * Field included by default. */ routed_via?: "smart_router" | "explicit" | unknown; /** * Field included by default. */ search_type: "keyword" | "semantic" | "suggest" | "batch"; /** * Field included by default. */ semantic_searches?: number | null | unknown; /** * Field included by default. */ tenant_id: string; /** * Field included by default. */ total_searches?: number | null | unknown; /** * Field included by default. */ user_id?: string | null | unknown; }; id: string; /** * A relationships object for a search_analytics */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a agent_version */ type AgentVersion = { /** * An attributes object for a agent_version */ attributes?: { /** * Field included by default. */ changes_summary?: string | null | unknown; /** * Field included by default. */ created_at: unknown; display_version?: string | null | unknown; /** * Field included by default. */ fields?: Array<{ /** * Field included by default. */ ai_hints?: string | null | unknown; /** * Field included by default. */ description?: string | null | unknown; /** * Whether this field is system-generated (e.g., _ai_suggestions) vs user-defined. Field included by default. */ is_system: boolean; /** * For array fields, specifies the type of items in the array. Field included by default. */ item_type?: "text" | "date" | "datetime" | "time" | "number" | "currency" | "boolean" | "email" | "phone" | "url" | "address" | "timestamp" | "alphanumeric_code" | unknown; /** * Field included by default. */ label?: string | null | unknown; /** * Field included by default. */ name: string; /** * Field included by default. */ order: number; /** * Field included by default. */ required: boolean; /** * Field included by default. */ type: "text" | "date" | "datetime" | "time" | "number" | "currency" | "boolean" | "email" | "phone" | "url" | "array" | "address" | "object" | "timestamp" | "alphanumeric_code"; }> | null | unknown; has_been_used?: boolean | null | unknown; /** * Field included by default. */ is_active: boolean; json_schema?: { [key: string]: unknown; } | null | unknown; /** * Field included by default. */ prompt_template: string; /** * Revision number within this schema version. Increments on prompt/description changes. Field included by default. */ revision: number; /** * Field included by default. */ schema_definition: { [key: string]: unknown; }; /** * Field included by default. */ updated_at: unknown; /** * Field included by default. */ version_number: string; }; id: string; /** * A relationships object for a agent_version */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a training_example */ type TrainingExample = { /** * An attributes object for a training_example */ attributes?: { /** * The AI's confidence score for the original extraction (0.0 - 1.0). Field included by default. */ confidence_score?: number | null | unknown; /** * The user's corrected value. Field included by default. */ corrected_value?: string | null | unknown; /** * Per-field correction reasons: %{field_name => reason_string}. Field included by default. */ correction_reasons?: { [key: string]: unknown; } | null | unknown; /** * Field included by default. */ document_id?: string | null | unknown; /** * The type of document (e.g., 'Invoice', 'Receipt', 'Contract'). Field included by default. */ document_type?: string | null | unknown; /** * Field included by default. */ embedding?: unknown; /** * The field name that was corrected (e.g., 'customer_name', 'total_amount'). Field included by default. */ field_name?: string | null | unknown; /** * Field included by default. */ input_text: string; /** * Field included by default. */ inserted_at: unknown; /** * Whether this example was explicitly confirmed by a user. Field included by default. */ is_confirmed: boolean; /** * The AI's original extraction value before user correction. Field included by default. */ original_value?: string | null | unknown; /** * Field included by default. */ output_json: { [key: string]: unknown; }; similarity?: number | null | unknown; /** * General note about these corrections (e.g., 'Poor OCR quality', 'Non-standard date format'). Field included by default. */ training_note?: string | null | unknown; /** * Field included by default. */ training_session_id?: string | null | unknown; /** * Field included by default. */ updated_at: unknown; /** * Field included by default. */ version_id?: string | null | unknown; /** * Field included by default. */ workspace_id?: string | null | unknown; }; id: string; /** * A relationships object for a training_example */ relationships?: { document?: { /** * An identifier for document */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; training_session?: { /** * An identifier for training_session */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; workspace?: { /** * An identifier for workspace */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; }; type: string; }; /** * A "Resource object" representing a user */ type User = { /** * An attributes object for a user */ attributes?: { current_scopes?: Array | null | unknown; current_workspace_id?: string | null | unknown; /** * Default tenant for billing fallback (set for domain-joined and invitation-registered users). Field included by default. */ default_tenant_id?: string | null | unknown; /** * Field included by default. */ email: string; /** * Field included by default. */ is_app_admin: boolean; /** * Field included by default. */ is_platform_admin: boolean; tenant_id?: string | null | unknown; token?: string | null | unknown; user_tenants?: Array<{ [key: string]: unknown; }> | null | unknown; }; id: string; /** * A relationships object for a user */ relationships?: { notification_methods?: { /** * Relationship data for notification_methods */ data?: Array<{ id: string; meta?: { [key: string]: unknown; }; type: string; }>; }; profile?: { /** * An identifier for profile */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; }; type: string; }; /** * A "Resource object" representing a conversation */ type Conversation = { /** * An attributes object for a conversation */ attributes?: { /** * Structured data providing context for this conversation (e.g., failed prediction results). Field included by default. */ context_data?: { [key: string]: unknown; } | null | unknown; /** * Field included by default. */ tenant_id: string; /** * Field included by default. */ title?: string | null | unknown; }; id: string; /** * A relationships object for a conversation */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a storage_stats */ type StorageStats = { /** * An attributes object for a storage_stats */ attributes?: { /** * Field included by default. */ generated_at?: unknown; /** * Field included by default. */ tenant_id?: string | null | unknown; /** * Field included by default. */ total_buckets?: number | null | unknown; /** * Field included by default. */ total_objects?: number | null | unknown; /** * Field included by default. */ total_storage_bytes?: number | null | unknown; }; id: string; /** * A relationships object for a storage_stats */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a notification_preference */ type NotificationPreference = { /** * An attributes object for a notification_preference */ attributes?: { [key: string]: never; }; id: string; /** * A relationships object for a notification_preference */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a agent_test_result */ type AgentTestResult = { /** * An attributes object for a agent_test_result */ attributes?: { /** * Field included by default. */ agent_version_id: string; /** * Field included by default. */ created_at: unknown; /** * Field included by default. */ document_id: string; /** * Field included by default. */ error_message?: string | null | unknown; /** * Field included by default. */ extracted_data?: { [key: string]: unknown; } | null | unknown; /** * Field included by default. */ status: "pending" | "completed" | "failed"; /** * Field included by default. */ usage?: { [key: string]: unknown; } | null | unknown; }; id: string; /** * A relationships object for a agent_test_result */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a webhook_delivery */ type WebhookDelivery = { /** * An attributes object for a webhook_delivery */ attributes?: { /** * Field included by default. */ attempt_count?: number | null | unknown; /** * Field included by default. */ event_type?: string | null | unknown; /** * Field included by default. */ inserted_at: unknown; /** * Field included by default. */ next_retry_at?: unknown; /** * Field included by default. */ payload: { [key: string]: unknown; }; /** * Field included by default. */ request_headers?: { [key: string]: unknown; } | null | unknown; /** * Field included by default. */ response_body?: string | null | unknown; /** * Field included by default. */ response_status?: number | null | unknown; /** * Field included by default. */ status?: "pending" | "success" | "failed" | "retrying" | unknown; /** * Field included by default. */ updated_at: unknown; /** * Field included by default. */ url: string; /** * Field included by default. */ webhook_config_id: string; }; id: string; /** * A relationships object for a webhook_delivery */ relationships?: { webhook_config?: { /** * An identifier for webhook_config */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; }; type: string; }; /** * A "Resource object" representing a embedding */ type Embedding = { /** * An attributes object for a embedding */ attributes?: { /** * Field included by default. */ billed_credits?: number | null | unknown; /** * Field included by default. */ embedding?: unknown; /** * Field included by default. */ model?: string | null | unknown; /** * Field included by default. */ text?: string | null | unknown; /** * Field included by default. */ usage?: { [key: string]: unknown; } | null | unknown; }; id: string; /** * A relationships object for a embedding */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a object */ type _Object = { /** * An attributes object for a object */ attributes?: { /** * Field included by default. */ content_type: string; /** * Field included by default. */ key: string; /** * Field included by default. */ size_bytes: number; }; id: string; /** * A relationships object for a object */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a extraction_batch */ type ExtractionBatch = { /** * An attributes object for a extraction_batch */ attributes?: { /** * Field included by default. */ name?: string | null | unknown; status?: string | null | unknown; /** * Generate presigned upload URLs for batch */ upload_urls?: Array<{ [key: string]: unknown; }> | null | unknown; /** * Field included by default. */ user_label?: string | null | unknown; }; id: string; /** * A relationships object for a extraction_batch */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a presigned_url */ type PresignedUrl = { /** * An attributes object for a presigned_url */ attributes?: { /** * Field included by default. */ expires_in: number; /** * Field included by default. */ storage_path: string; /** * Field included by default. */ upload_url: string; }; id: string; /** * A relationships object for a presigned_url */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a workspace-membership */ type WorkspaceMembership = { /** * An attributes object for a workspace-membership */ attributes?: { /** * Field included by default. */ created_at: unknown; /** * For inherited members, describes the org role */ inherited_from?: string | null | unknown; /** * Last time user accessed this workspace. Field included by default. */ last_visited_at?: unknown; /** * Workspace permissions in format {app}:{resource}:{action}:{scope}. Field included by default. */ permissions: Array; /** * Effective role: admin, editor, or viewer */ role?: string | null | unknown; role_label?: string | null | unknown; /** * How user got access: :direct (explicit invite) or :inherited (org role) */ source?: string | null | unknown; /** * Field included by default. */ updated_at: unknown; /** * Field included by default. */ user_id: string; /** * Field included by default. */ workspace_id: string; }; id: string; /** * A relationships object for a workspace-membership */ relationships?: { user?: { /** * An identifier for user */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; workspace?: { /** * An identifier for workspace */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; }; type: string; }; /** * A "Resource object" representing a extraction_export */ type ExtractionExport = { /** * An attributes object for a extraction_export */ attributes?: { /** * Field included by default. */ config: { [key: string]: unknown; }; /** * Field included by default. */ error_message?: string | null | unknown; /** * Field included by default. */ expires_at?: unknown; /** * Field included by default. */ file_size_bytes?: number | null | unknown; /** * Field included by default. */ file_url?: string | null | unknown; /** * Field included by default. */ format: "csv" | "json" | "excel" | "markdown"; /** * Field included by default. */ status: "pending" | "processing" | "completed" | "failed"; /** * Field included by default. */ workspace_id: string; }; id: string; /** * A relationships object for a extraction_export */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a bucket */ type Bucket = { /** * An attributes object for a bucket */ attributes?: { /** * Field included by default. */ name: string; /** * Field included by default. */ region?: string | null | unknown; storage_used?: number | null | unknown; /** * Field included by default. */ type: "public" | "private" | "processing"; }; id: string; /** * A relationships object for a bucket */ relationships?: { objects?: { /** * Relationship data for objects */ data?: Array<{ id: string; meta?: { [key: string]: unknown; }; type: string; }>; }; }; type: string; }; /** * A "Resource object" representing a agent */ type Agent = { /** * An attributes object for a agent */ attributes?: { /** * Description of what this agent is good at, used for AI matching. Field included by default. */ capabilities: string; /** * Field included by default. */ description: string; /** * Field included by default. */ name: string; /** * Field included by default. */ slug: string; }; id: string; /** * A relationships object for a agent */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a credit_package */ type CreditPackage = { /** * An attributes object for a credit_package */ attributes?: { /** * Field included by default. */ application_id: string; /** * Field included by default. */ credits: number; /** * Field included by default. */ name: string; /** * Field included by default. */ price: { amount: string; currency: string; }; /** * Field included by default. */ slug: string; }; id: string; /** * A relationships object for a credit_package */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a workspace */ type Workspace = { /** * An attributes object for a workspace */ attributes?: { /** * App type: extract, invoicing, crm, etc. Field included by default. */ app: string; /** * Required - the application this workspace belongs to. Field included by default. */ application_id: string; /** * Field included by default. */ archived_at?: unknown; /** * Field included by default. */ created_at: unknown; /** * When enabled, duplicate files (by SHA256 hash) are rejected. Field included by default. */ deduplicate_uploads: boolean; /** * Field included by default. */ description?: string | null | unknown; /** * Field included by default. */ expires_at?: string | null | unknown; /** * Field included by default. */ is_default: boolean; /** * Timestamp of the last successful folder sweep. Field included by default. */ last_sweep_at?: unknown; /** * Field included by default. */ low_balance_threshold: number; /** * Field included by default. */ name: string; /** * True when all documents have file_hash populated */ ready_for_deduplication?: boolean | null | unknown; /** * Field included by default. */ renewal_params?: { [key: string]: unknown; } | null | unknown; /** * How the user got access: :inherited (from org role) or :direct (explicit invite) */ role_source?: string | null | unknown; /** * Field included by default. */ settings: { /** * Field included by default. */ ai: { /** * The 'Mentor' Agent (System/Specialty) providing domain context. Field included by default. */ base_agent_id?: string | null | unknown; /** * If true, chat interactions automatically update the Custom Agent. Field included by default. */ continuous_learning: boolean; /** * The 'Student' Agent (Custom) learning specific rules. Field included by default. */ custom_agent_id?: string | null | unknown; /** * Explicitly enabled AI features for this workspace. Field included by default. */ enabled_capabilities?: Array | null | unknown; }; /** * Field included by default. */ billing: { /** * Field included by default. */ allow_overdraft: boolean; /** * Maximum overdraft credits allowed per period. Field included by default. */ overdraft_limit?: number | null | unknown; /** * Period for overdraft limit reset (daily, weekly, monthly). Field included by default. */ overdraft_period?: "daily" | "weekly" | "monthly" | unknown; /** * When the current overdraft period began. Field included by default. */ overdraft_period_started_at?: unknown; /** * Credits used from overdraft in current period. Field included by default. */ overdraft_used?: number | null | unknown; }; /** * Field included by default. */ review_train: { /** * Field included by default. */ confidence_threshold: number; }; /** * Field included by default. */ storage: { /** * Field included by default. */ errors: { /** * Field included by default. */ copy_to_local: boolean; /** * Field included by default. */ local_path?: string | null | unknown; }; /** * Field included by default. */ input: { /** * Field included by default. */ local_path?: string | null | unknown; /** * Field included by default. */ source: "local" | "cloud"; }; /** * Field included by default. */ output: { /** * Field included by default. */ copy_to_local: boolean; /** * Field included by default. */ local_path?: string | null | unknown; }; }; /** * Field included by default. */ watcher: { /** * Field included by default. */ claim_expiry_minutes?: number | null | unknown; /** * Configuration for cloud input sources. Field included by default. */ cloud_config?: { /** * Override bucket (defaults to tenant processing bucket). Field included by default. */ bucket?: string | null | unknown; /** * Delete source file instead of moving to processed. Field included by default. */ delete_after_processing: boolean; /** * Override error prefix (defaults to workspaces/{id}/errors/). Field included by default. */ error_prefix?: string | null | unknown; /** * Override input prefix (defaults to workspaces/{id}/input/). Field included by default. */ input_prefix?: string | null | unknown; /** * Field included by default. */ poll_interval_seconds: number; /** * Override processed prefix (defaults to workspaces/{id}/processed/). Field included by default. */ processed_prefix?: string | null | unknown; /** * Field included by default. */ provider: "s3" | "minio" | "gcs"; /** * Use S3 event notifications instead of polling. Field included by default. */ use_s3_events: boolean; } | null | unknown; /** * Field included by default. */ duplicate_action?: "skip" | "move_to_processed" | "move_to_skipped" | unknown; /** * Field included by default. */ enabled: boolean; /** * Field included by default. */ log_retention_days?: number | null | unknown; /** * Field included by default. */ max_retries?: number | null | unknown; /** * Field included by default. */ retry_delay_ms?: number | null | unknown; /** * Field included by default. */ source_type?: "local" | "cloud" | unknown; }; }; /** * Field included by default. */ slug: string; /** * Field included by default. */ tenant_id: string; /** * Field included by default. */ updated_at: unknown; /** * The user's effective role in this workspace: admin, editor, or viewer */ user_role?: string | null | unknown; /** * Memorable slug for vanity URLs. Field included by default. */ vanity_slug?: string | null | unknown; }; id: string; /** * A relationships object for a workspace */ relationships?: { memberships?: { /** * Relationship data for memberships */ data?: Array<{ id: string; meta?: { [key: string]: unknown; }; type: string; }>; }; tenant?: { /** * An identifier for tenant */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; }; type: string; }; /** * A "Resource object" representing a invitation */ type Invitation = { /** * An attributes object for a invitation */ attributes?: { /** * Optional personal message from the inviter. Field included by default. */ custom_message?: string | null | unknown; /** * Field included by default. */ email: string; /** * Field included by default. */ expires_at: string; /** * Field included by default. */ inviter_id: string; /** * Permissions to grant on acceptance. Field included by default. */ permissions: Array; /** * Field included by default. */ role: "admin" | "member" | "editor" | "viewer"; /** * Field included by default. */ scope_id: string; /** * Field included by default. */ scope_type: "tenant" | "workspace"; /** * Field included by default. */ status: "pending" | "accepted" | "expired" | "revoked" | "declined"; /** * Denormalized tenant_id for multi-tenant filtering. Field included by default. */ tenant_id: string; }; id: string; /** * A relationships object for a invitation */ relationships?: { inviter?: { /** * An identifier for inviter */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; }; type: string; }; /** * A "Resource object" representing a agent_usage */ type AgentUsage = { /** * An attributes object for a agent_usage */ attributes?: { /** * Field included by default. */ agent_id?: string | null | unknown; /** * Field included by default. */ is_shared?: boolean | null | unknown; /** * Field included by default. */ is_system?: boolean | null | unknown; /** * Field included by default. */ owner?: { [key: string]: unknown; } | null | unknown; /** * Field included by default. */ using?: Array<{ [key: string]: unknown; }> | null | unknown; /** * Field included by default. */ using_count?: number | null | unknown; }; id: string; /** * A relationships object for a agent_usage */ relationships?: { [key: string]: never; }; type: string; }; /** * A "Resource object" representing a extraction_document */ type ExtractionDocument = { /** * An attributes object for a extraction_document */ attributes?: { /** * Overall classification confidence (0.0 to 1.0). Field included by default. */ classification_confidence?: number | null | unknown; /** * Field included by default. */ uploaded_at?: string | null | unknown; /** * Current processing stage based on storage path. Field included by default. */ stage?: string | null | unknown; /** * Whether this document was returned as a duplicate via find_or_begin_upload. Field included by default. */ deduplicated?: boolean | null | unknown; /** * Schema revision number used for extraction. Field included by default. */ schema_revision?: number | null | unknown; /** * Credits billed for processing this document. Field included by default. */ billed_credits?: number | null | unknown; /** * Field included by default. */ storage_path: string; /** * Line count of extracted text. Field included by default. */ line_count?: number | null | unknown; /** * Image height in pixels (for image documents). Field included by default. */ image_height?: number | null | unknown; /** * SHA256 hash of the file content for deduplication */ file_hash?: string | null | unknown; excluded_by?: string | null | unknown; /** * Character count of extracted text. Field included by default. */ char_count?: number | null | unknown; /** * The S3 bucket where this document is stored. Set during upload/begin_upload. */ bucket_name?: string | null | unknown; deleted_at?: unknown; /** * Classification object containing domain, document_type, municipality, state, and confidence */ classification?: { [key: string]: unknown; } | null | unknown; content?: string | null | unknown; /** * Municipality/agency name extracted from document content. Field included by default. */ municipality?: string | null | unknown; /** * Reason why this document is in the review queue */ queue_reason?: string | null | unknown; /** * Field included by default. */ status?: "queued" | "processing" | "completed" | "failed" | "duplicate" | "cancelled" | "pending_credits" | unknown; /** * Field included by default. */ progress?: number | null | unknown; /** * Timestamp when document was moved to output/error bucket */ moved_at?: unknown; /** * Full path (bucket/key) where document was copied after successful extraction */ output_storage_path?: string | null | unknown; /** * Metadata about the training session for this document (trained_at, user_id, scores) */ training_metadata?: { [key: string]: unknown; } | null | unknown; /** * Field included by default. */ ocr_text?: string | null | unknown; /** * Field included by default. */ upload_url?: string | null | unknown; /** * Field included by default. */ pages?: number | null | unknown; /** * Image width in pixels (for image documents). Field included by default. */ image_width?: number | null | unknown; /** * The review/verification state of the document. Field included by default. */ verification_status?: "unverified" | "partially_verified" | "fully_verified" | unknown; processed_at?: unknown; /** * Field included by default. */ error_message?: string | null | unknown; /** * Field included by default. */ verified_by_user_id?: string | null | unknown; /** * Field included by default. */ file_type: "pdf" | "docx" | "image" | "zip"; /** * Field included by default. */ file_size_bytes?: number | null | unknown; /** * Timestamp when document processing completed (status changed to :completed). Field included by default. */ completed_at?: unknown; /** * The version of the agent/schema used to process this document. Field included by default. */ schema_version?: string | null | unknown; /** * Field included by default. */ presigned_view_url?: string | null | unknown; /** * Field included by default. */ last_verified_at?: unknown; /** * State or province code (2-letter). Field included by default. */ state?: string | null | unknown; /** * Full path (bucket/key) where document was copied after failed extraction */ error_storage_path?: string | null | unknown; /** * Document domain from specialty agent (legal, financial, medical, etc.). Field included by default. */ domain?: string | null | unknown; /** * If true, this document is excluded from training (both creating new examples and being used in retrieval) */ excluded_from_training: boolean; /** * Word count of extracted text. Field included by default. */ word_count?: number | null | unknown; excluded_at?: unknown; /** * Field included by default. */ filename: string; /** * Average confidence score across all extracted fields (0.0 to 1.0). Field included by default. */ avg_confidence?: number | null | unknown; /** * Specific document type from specialty agent (Traffic Citation, Invoice, etc.). Field included by default. */ document_type?: string | null | unknown; }; id: string; /** * A relationships object for a extraction_document */ relationships?: { claim?: { /** * An identifier for claim */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; extraction_result?: { /** * An identifier for extraction_result */ data?: { id: string; meta?: { [key: string]: unknown; }; type: string; } | null; }; extraction_results?: { /** * Relationship data for extraction_results */ data?: Array<{ id: string; meta?: { [key: string]: unknown; }; type: string; }>; }; }; type: string; }; type AuthToken = string | undefined; interface Auth { /** * Which part of the request do we use to send the auth? * * @default 'header' */ in?: "header" | "query" | "cookie"; /** * Header or query parameter name. * * @default 'Authorization' */ name?: string; scheme?: "basic" | "bearer"; type: "apiKey" | "http"; } interface SerializerOptions { /** * @default true */ explode: boolean; style: T; } type ArrayStyle = "form" | "spaceDelimited" | "pipeDelimited"; type ObjectStyle = "form" | "deepObject"; type QuerySerializer = (query: Record) => string; type BodySerializer = (body: any) => any; type QuerySerializerOptionsObject = { allowReserved?: boolean; array?: Partial>; object?: Partial>; }; type QuerySerializerOptions = QuerySerializerOptionsObject & { /** * Per-parameter serialization overrides. When provided, these settings * override the global array/object settings for specific parameter names. */ parameters?: Record; }; type HttpMethod = "connect" | "delete" | "get" | "head" | "options" | "patch" | "post" | "put" | "trace"; type Client$1 = { /** * Returns the final request URL. */ buildUrl: BuildUrlFn; getConfig: () => Config; request: RequestFn; setConfig: (config: Config) => Config; } & { [K in HttpMethod]: MethodFn; } & ([SseFn] extends [never] ? { sse?: never; } : { sse: { [K in HttpMethod]: SseFn; }; }); interface Config$1 { /** * Auth token or a function returning auth token. The resolved value will be * added to the request payload as defined by its `security` array. */ auth?: ((auth: Auth) => Promise | AuthToken) | AuthToken; /** * A function for serializing request body parameter. By default, * {@link JSON.stringify()} will be used. */ bodySerializer?: BodySerializer | null; /** * An object containing any HTTP headers that you want to pre-populate your * `Headers` object with. * * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} */ headers?: RequestInit["headers"] | Record; /** * The request method. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} */ method?: Uppercase; /** * A function for serializing request query parameters. By default, arrays * will be exploded in form style, objects will be exploded in deepObject * style, and reserved characters are percent-encoded. * * This method will have no effect if the native `paramsSerializer()` Axios * API function is used. * * {@link https://swagger.io/docs/specification/serialization/#query View examples} */ querySerializer?: QuerySerializer | QuerySerializerOptions; /** * A function validating request data. This is useful if you want to ensure * the request conforms to the desired shape, so it can be safely sent to * the server. */ requestValidator?: (data: unknown) => Promise; /** * A function transforming response data before it's returned. This is useful * for post-processing data, e.g. converting ISO strings into Date objects. */ responseTransformer?: (data: unknown) => Promise; /** * A function validating response data. This is useful if you want to ensure * the response conforms to the desired shape, so it can be safely passed to * the transformers and returned to the user. */ responseValidator?: (data: unknown) => Promise; } type ServerSentEventsOptions = Omit & Pick & { /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ fetch?: typeof fetch; /** * Implementing clients can call request interceptors inside this hook. */ onRequest?: (url: string, init: RequestInit) => Promise; /** * Callback invoked when a network or parsing error occurs during streaming. * * This option applies only if the endpoint returns a stream of events. * * @param error The error that occurred. */ onSseError?: (error: unknown) => void; /** * Callback invoked when an event is streamed from the server. * * This option applies only if the endpoint returns a stream of events. * * @param event Event streamed from the server. * @returns Nothing (void). */ onSseEvent?: (event: StreamEvent) => void; serializedBody?: RequestInit["body"]; /** * Default retry delay in milliseconds. * * This option applies only if the endpoint returns a stream of events. * * @default 3000 */ sseDefaultRetryDelay?: number; /** * Maximum number of retry attempts before giving up. */ sseMaxRetryAttempts?: number; /** * Maximum retry delay in milliseconds. * * Applies only when exponential backoff is used. * * This option applies only if the endpoint returns a stream of events. * * @default 30000 */ sseMaxRetryDelay?: number; /** * Optional sleep function for retry backoff. * * Defaults to using `setTimeout`. */ sseSleepFn?: (ms: number) => Promise; url: string; }; interface StreamEvent { data: TData; event?: string; id?: string; retry?: number; } type ServerSentEventsResult = { stream: AsyncGenerator ? TData[keyof TData] : TData, TReturn, TNext>; }; type ErrInterceptor = (error: Err, response: Res, request: Req, options: Options) => Err | Promise; type ReqInterceptor = (request: Req, options: Options) => Req | Promise; type ResInterceptor = (response: Res, request: Req, options: Options) => Res | Promise; declare class Interceptors { fns: Array; clear(): void; eject(id: number | Interceptor): void; exists(id: number | Interceptor): boolean; getInterceptorIndex(id: number | Interceptor): number; update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false; use(fn: Interceptor): number; } interface Middleware { error: Interceptors>; request: Interceptors>; response: Interceptors>; } type ResponseStyle = "data" | "fields"; interface Config extends Omit, Config$1 { /** * Base URL for all requests made by this client. */ baseUrl?: T["baseUrl"]; /** * Fetch API implementation. You can use this option to provide a custom * fetch instance. * * @default globalThis.fetch */ fetch?: typeof fetch; /** * Please don't use the Fetch client for Next.js applications. The `next` * options won't have any effect. * * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead. */ next?: never; /** * Return the response data parsed in a specified format. By default, `auto` * will infer the appropriate method from the `Content-Type` response header. * You can override this behavior with any of the {@link Body} methods. * Select `stream` if you don't want to parse response data at all. * * @default 'auto' */ parseAs?: "arrayBuffer" | "auto" | "blob" | "formData" | "json" | "stream" | "text"; /** * Should we return only data or multiple fields (data, error, response, etc.)? * * @default 'fields' */ responseStyle?: ResponseStyle; /** * Throw an error instead of returning it in the response? * * @default false */ throwOnError?: T["throwOnError"]; } interface RequestOptions$1 extends Config<{ responseStyle: TResponseStyle; throwOnError: ThrowOnError; }>, Pick, "onSseError" | "onSseEvent" | "sseDefaultRetryDelay" | "sseMaxRetryAttempts" | "sseMaxRetryDelay"> { /** * Any body that you want to add to your request. * * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} */ body?: unknown; path?: Record; query?: Record; /** * Security mechanism(s) to use for the request. */ security?: ReadonlyArray; url: Url; } interface ResolvedRequestOptions extends RequestOptions$1 { serializedBody?: string; } type RequestResult = ThrowOnError extends true ? Promise ? TData[keyof TData] : TData : { data: TData extends Record ? TData[keyof TData] : TData; request: Request; response: Response; }> : Promise ? TData[keyof TData] : TData) | undefined : ({ data: TData extends Record ? TData[keyof TData] : TData; error: undefined; } | { data: undefined; error: TError extends Record ? TError[keyof TError] : TError; }) & { request: Request; response: Response; }>; interface ClientOptions { baseUrl?: string; responseStyle?: ResponseStyle; throwOnError?: boolean; } type MethodFn = (options: Omit, "method">) => RequestResult; type SseFn = (options: Omit, "method">) => Promise>; type RequestFn = (options: Omit, "method"> & Pick>, "method">) => RequestResult; type BuildUrlFn = ; query?: Record; url: string; }>(options: TData & Options) => string; type Client = Client$1 & { interceptors: Middleware; }; interface TDataShape { body?: unknown; headers?: unknown; path?: unknown; query?: unknown; url: string; } type OmitKeys = Pick>; type Options = OmitKeys, "body" | "path" | "query" | "url"> & ([TData] extends [never] ? unknown : Omit); /** * Base error class for all GPT Core SDK errors */ declare class GptCoreError extends Error { readonly name: string; readonly statusCode?: number; readonly code: string; readonly requestId?: string; readonly headers?: Record; readonly body?: unknown; cause?: Error; constructor(message: string, options?: { statusCode?: number; code?: string; requestId?: string; headers?: Record; body?: unknown; cause?: Error; }); /** * Serialize error to plain object for logging/debugging */ toJSON(): { name: string; message: string; statusCode?: number; code: string; requestId?: string; }; } /** * Authentication errors (401) */ declare class AuthenticationError extends GptCoreError { constructor(message?: string, options?: ConstructorParameters[1]); } /** * Authorization/Permission errors (403) */ declare class AuthorizationError extends GptCoreError { constructor(message?: string, options?: ConstructorParameters[1]); } /** * Resource not found errors (404) */ declare class NotFoundError extends GptCoreError { constructor(message?: string, options?: ConstructorParameters[1]); } /** * Validation errors (400, 422) */ declare class ValidationError extends GptCoreError { readonly errors?: Array<{ field?: string; message: string; }>; constructor(message?: string, errors?: Array<{ field?: string; message: string; }>, options?: ConstructorParameters[1]); } /** * Rate limiting errors (429) */ declare class RateLimitError extends GptCoreError { readonly retryAfter?: number; constructor(message?: string, retryAfter?: number, options?: ConstructorParameters[1]); } /** * Network/connection errors */ declare class NetworkError extends GptCoreError { constructor(message?: string, options?: ConstructorParameters[1]); } /** * Timeout errors */ declare class TimeoutError extends GptCoreError { constructor(message?: string, options?: ConstructorParameters[1]); } /** * Server errors (500+) */ declare class ServerError extends GptCoreError { constructor(message?: string, options?: ConstructorParameters[1]); } /** * Conflict errors (409) */ declare class ConflictError extends GptCoreError { constructor(message?: string, options?: ConstructorParameters[1]); } interface AgentVersionErrorOptions { statusCode?: number; code?: string; requestId?: string; headers?: Record; body?: unknown; cause?: Error; pointer?: string; versionId?: string; agentId?: string; } /** * Base class for all agent-version endpoint errors. Prefer catching the * specific subclass; use this only for "any agent-version error" branches. */ declare class AgentVersionError extends GptCoreError { readonly pointer?: string; readonly versionId?: string; readonly agentId?: string; constructor(message: string, options?: AgentVersionErrorOptions); } declare class VersionAlreadyUsedError extends AgentVersionError { constructor(message?: string, options?: AgentVersionErrorOptions); } declare class VersionInUseCannotDeleteError extends AgentVersionError { constructor(message?: string, options?: AgentVersionErrorOptions); } declare class VersionNotFoundError extends AgentVersionError { constructor(message?: string, options?: AgentVersionErrorOptions); } declare class ReservedFieldError extends AgentVersionError { constructor(message?: string, options?: AgentVersionErrorOptions); } declare class InvalidFieldTypeError extends AgentVersionError { constructor(message?: string, options?: AgentVersionErrorOptions); } declare class MissingFieldNameError extends AgentVersionError { constructor(message?: string, options?: AgentVersionErrorOptions); } declare class SchemaDefinitionInvalidError extends AgentVersionError { constructor(message?: string, options?: AgentVersionErrorOptions); } /** * Parse error response and throw appropriate error class */ declare function handleApiError(error: unknown): never; /** * Retry configuration */ interface RetryConfig { /** Maximum number of retry attempts (default: 3) */ maxRetries: number; /** Initial delay in milliseconds before first retry (default: 1000) */ initialDelay: number; /** Maximum delay in milliseconds between retries (default: 32000) */ maxDelay: number; /** HTTP status codes that trigger retry (default: [429, 500, 502, 503, 504]) */ retryableStatusCodes: number[]; /** * Total timeout in milliseconds across all retry attempts. * Prevents infinite retry loops from malicious Retry-After headers. * Default: 300000 (5 minutes) */ totalTimeout?: number; /** * Maximum value for Retry-After header in seconds. * Prevents DoS via excessive server-requested delays. * Default: 60 seconds */ maxRetryAfter?: number; /** * Optional AbortSignal to cancel retry attempts. * When aborted, the retry loop immediately throws an error. */ signal?: AbortSignal; } /** * Default retry configuration */ declare const DEFAULT_RETRY_CONFIG: RetryConfig; /** * Error thrown when retry total timeout is exceeded */ declare class RetryTimeoutError extends GptCoreError { readonly lastError?: unknown; constructor(message: string, lastError?: unknown); } /** * Retry a function with exponential backoff and circuit breaker */ declare function retryWithBackoff(fn: () => Promise, config?: RetryConfig): Promise; /** * Create a retry wrapper for a client method */ declare function withRetry(fn: (...args: TArgs) => Promise, config?: Partial): (...args: TArgs) => Promise; /** * SDK lifecycle events. * Stripe-style hooks for monitoring request/response/retry cycles. */ interface SdkRequestEvent { /** HTTP method */ method: string; /** Request URL */ url: string; /** Request headers (auth headers redacted) */ headers: Record; /** Timestamp when request was initiated */ timestamp: number; } interface SdkResponseEvent { /** HTTP method */ method: string; /** Request URL */ url: string; /** HTTP status code */ status: number; /** Response headers */ headers: Record; /** Request ID from x-request-id header */ requestId?: string; /** Duration in milliseconds */ duration: number; /** API version from response */ apiVersion?: string; } interface SdkRetryEvent { /** Current retry attempt (1-based) */ attempt: number; /** Maximum retries configured */ maxRetries: number; /** Delay before next retry in ms */ delay: number; /** The error that triggered the retry */ error: unknown; } interface SdkErrorEvent { /** HTTP method */ method: string; /** Request URL */ url: string; /** The error */ error: unknown; /** Duration in milliseconds */ duration: number; } type SdkEvents = { request: SdkRequestEvent; response: SdkResponseEvent; retry: SdkRetryEvent; error: SdkErrorEvent; }; type EventHandler = (event: T) => void; /** * Type-safe event emitter for SDK lifecycle events. */ declare class SdkEventEmitter { private handlers; on(event: K, handler: EventHandler): () => void; off(event: K, handler: EventHandler): void; emit(event: K, data: SdkEvents[K]): void; removeAllListeners(event?: keyof SdkEvents): void; } /** Logger interface matching console API */ interface Logger { debug: (...args: unknown[]) => void; info: (...args: unknown[]) => void; warn: (...args: unknown[]) => void; error: (...args: unknown[]) => void; } /** Log levels */ type LogLevel = "debug" | "info" | "warn" | "error" | "none"; /** Log level priority for comparison */ declare const LOG_LEVELS: Record; /** * Build User-Agent string. * @param sdkVersion - SDK version string (e.g., "0.11.0") * @param appInfo - Optional application info for platform integrators */ declare function buildUserAgent(sdkVersion: string, appInfo?: { name: string; version?: string; url?: string; }): string; /** Valid API key prefixes */ declare const API_KEY_PREFIXES: readonly ["sk_tenant_", "sk_app_", "sk_srv_", "sk_sys_"]; /** * Check if a URL is considered secure for transmitting credentials. * Localhost and 127.0.0.1 are allowed for development. */ declare function isSecureUrl(url: string): boolean; /** * Check if running in a browser environment */ declare function isBrowserEnvironment(): boolean; /** * Validate API key format */ declare function validateApiKey(apiKey: string): { valid: boolean; prefix?: string; warning?: string; }; /** * Security error thrown when HTTPS is required but not used */ declare class InsecureConnectionError extends Error { constructor(message: string); } /** * Error thrown when API key is used in browser without opt-in */ declare class BrowserApiKeyError extends Error { constructor(); } /** * The API version this SDK was built against. * This is the default version sent in all requests. * Override per-client via the `apiVersion` config option. */ declare const DEFAULT_API_VERSION = "2025-12-03"; /** SDK version for User-Agent header */ declare const SDK_VERSION = "0.12.0"; /** Security configuration options */ interface SecurityConfig { /** * Require HTTPS for all requests (except localhost). * When true, throws an error instead of just warning. * Recommended for production environments. * Default: false (warning only) */ requireHttps?: boolean; /** * Warn when using API keys in browser environment. * API keys should only be used server-side. * Default: true * @deprecated Use `dangerouslyAllowBrowser` instead */ warnBrowserApiKey?: boolean; } /** Application info for User-Agent (Stripe-style) */ interface AppInfo { /** Application name */ name: string; /** Application version */ version?: string; /** Application URL */ url?: string; } /** Request options that can be passed to individual namespace methods */ interface RequestOptions { /** AbortSignal for cancellation */ signal?: AbortSignal; /** Idempotency key override */ idempotencyKey?: string; /** Additional headers for this request */ headers?: Record; } interface BaseClientConfig { /** Base URL of the GPT Core API */ baseUrl?: string; /** User JWT token (Bearer auth) */ token?: string; /** Application API key (x-application-key header) */ apiKey?: string; /** Retry configuration, or `false` to disable retries */ retry?: Partial | false; /** * API version date to use for requests (e.g., "2025-12-03"). * Defaults to the version this SDK was built against. * Pin this to a specific date to prevent breaking changes * when upgrading the SDK. */ apiVersion?: string; /** * Security configuration options. * Controls HTTPS enforcement and browser warnings. */ security?: SecurityConfig; /** * Request timeout in milliseconds. * Applies to all requests made by this client. * Default: no timeout (0 = disabled) */ timeout?: number; /** * Custom fetch implementation. * Useful for testing or custom network layers. * Default: globalThis.fetch */ fetch?: typeof fetch; /** * Default headers sent with every request. * Auth headers and Content-Type are not overridden. */ defaultHeaders?: Record; /** * Allow API key usage in browser environments. * By default, using an API key in a browser throws an error. * Set to true to suppress this safety check. * Default: false */ dangerouslyAllowBrowser?: boolean; /** * Log level for SDK operations. * Default: 'warn' */ logLevel?: LogLevel; /** * Custom logger implementation. * Default: console */ logger?: Logger; /** * Application info for User-Agent header (Stripe-style). * Used by platform integrators to identify their app. */ appInfo?: AppInfo; } declare abstract class BaseClient { protected retryConfig: Partial | false; protected config: BaseClientConfig; /** Per-instance client from @hey-api/openapi-ts */ protected clientInstance: Client; /** The effective API version used by this client instance */ readonly apiVersion: string; /** SDK lifecycle event emitter */ readonly events: SdkEventEmitter; /** WeakMap to track request start times without mutating Request objects */ private readonly requestTimings; /** Structured logger */ protected log: { debug: (...args: unknown[]) => void; info: (...args: unknown[]) => void; warn: (...args: unknown[]) => void; error: (...args: unknown[]) => void; }; constructor(config?: BaseClientConfig); /** Get the per-instance client for use in namespace methods */ getClientInstance(): Client; /** Get headers for requests (used by namespaces) */ protected getHeaders(): Record; /** * Unwrap a JSON:API response envelope. * Extracts nested data and flattens JSON:API resources: * { id, type, attributes, relationships } → { id, type, ...attributes, ...relationships } * Also handles arrays of resources. */ protected unwrap(resource: unknown): T; /** * Flatten a single JSON:API resource: { id, type, attributes, relationships } → { id, type, ...attributes, ...relationships } */ private flattenResource; protected handleError(error: unknown): never; /** * Execute an API call with retry logic. * Used by namespace methods to automatically retry on transient failures. */ protected requestWithRetry(fn: () => Promise): Promise; /** * Update the authentication token (e.g., after login or token refresh). * The interceptor reads from this.config dynamically, so changes take effect immediately. */ setToken(token: string): void; /** * Clear the authentication token (e.g., on logout). */ clearToken(): void; } /** * GPT Core Client SDK * * The main entry point for interacting with the GPT Core API. * Provides a namespaced, type-safe interface for all API operations. * * @example * ```typescript * import { GptClient } from '@gpt-core/client'; * * const client = new GptClient({ * baseUrl: 'https://api.gpt-core.com', * apiKey: 'sk_app_...', * }); * * // Authentication * const user = await client.identity.me(); * * // Workspaces * const workspaces = await client.platform.workspaces.mine(); * * // AI Search * const results = await client.ai.search('quarterly earnings'); * * // Documents * const docs = await client.extraction.documents.list(); * ``` */ declare class GptClient extends BaseClient { /** User authentication, profiles, and API key management */ readonly identity: { login: (email: string, password: string, options?: RequestOptions) => Promise; register: (email: string, password: string, passwordConfirmation: string, options?: RequestOptions) => Promise; confirm: (token: string, options?: RequestOptions) => Promise; resendConfirmation: (email: string, options?: RequestOptions) => Promise>; requestMagicLink: (email: string, options?: RequestOptions) => Promise>; magicLinkLogin: (token: string, options?: RequestOptions) => Promise; changePassword: (currentPassword: string, newPassword: string, newPasswordConfirmation: string, options?: RequestOptions) => Promise; resetPassword: (token: string, password: string, passwordConfirmation: string, options?: RequestOptions) => Promise; me: (options?: RequestOptions) => Promise; profile: (options?: RequestOptions) => Promise; updateProfile: (id: string, attributes: Record, options?: RequestOptions) => Promise; acceptTos: (id: string, options?: RequestOptions) => Promise; stats: (options?: RequestOptions) => Promise>; dashboard: (options?: RequestOptions) => Promise>; activity: (options?: RequestOptions) => Promise>; tenants: (options?: RequestOptions) => Promise; apiKeys: { list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; listAll: (options?: RequestOptions) => Promise; active: (options?: RequestOptions) => Promise; get: (id: string, options?: RequestOptions) => Promise; create: (name: string, options?: RequestOptions) => Promise; revoke: (id: string, options?: RequestOptions) => Promise; rotate: (id: string, options?: RequestOptions) => Promise; allocate: (id: string, amount: number, description: string, options?: RequestOptions) => Promise; setBudget: (id: string, budget: number, options?: RequestOptions) => Promise; stats: (options?: RequestOptions) => Promise>; }; }; /** Workspaces, applications, tenants, and invitations */ readonly platform: { workspaces: { list: (options?: RequestOptions) => Promise; create: (name: string, slug?: string, options?: RequestOptions) => Promise; get: (id: string, options?: RequestOptions) => Promise; update: (id: string, attributes: Record, options?: RequestOptions) => Promise; delete: (id: string, options?: RequestOptions) => Promise; mine: (options?: RequestOptions) => Promise; shared: (options?: RequestOptions) => Promise; members: (id: string, options?: RequestOptions) => Promise; allocate: (id: string, amount: number, options?: RequestOptions) => Promise; }; applications: { list: (options?: RequestOptions) => Promise; create: (attributes: { name: string; slug?: string; description?: string; }, options?: RequestOptions) => Promise; get: (id: string, options?: RequestOptions) => Promise; getBySlug: (slug: string, options?: RequestOptions) => Promise; current: (options?: RequestOptions) => Promise; update: (id: string, attributes: Record, options?: RequestOptions) => Promise; delete: (id: string, options?: RequestOptions) => Promise; }; tenants: { list: (options?: RequestOptions) => Promise; get: (id: string, options?: RequestOptions) => Promise; stats: (tenantId: string, options?: RequestOptions) => Promise; }; invitations: { list: (options?: RequestOptions) => Promise; mine: (options?: RequestOptions) => Promise; create: (email: string, role: string, scopeType: "tenant" | "workspace", scopeId: string, options?: RequestOptions) => Promise; accept: (id: string, options?: RequestOptions) => Promise; decline: (id: string, options?: RequestOptions) => Promise; revoke: (id: string, options?: RequestOptions) => Promise; resend: (id: string, options?: RequestOptions) => Promise; }; memberships: { list: (options?: RequestOptions) => Promise; create: (attributes: Record, options?: RequestOptions) => Promise; }; roles: { list: (options?: RequestOptions) => Promise; }; }; /** Agent creation, versioning, training, and testing */ readonly agents: { list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; listAll: (options?: RequestOptions) => Promise; create: (name: string, promptTemplate: string, attributes?: Record, options?: RequestOptions) => Promise; get: (id: string, options?: RequestOptions) => Promise; update: (id: string, attributes: Record, options?: RequestOptions) => Promise; delete: (id: string, options?: RequestOptions) => Promise; test: (id: string, input?: Record, options?: RequestOptions) => Promise; clone: (id: string, options?: RequestOptions) => Promise; export: (id: string, options?: RequestOptions) => Promise>; import: (agentData: Record, options?: RequestOptions) => Promise; validate: (id: string, options?: RequestOptions) => Promise>; stats: (id: string, options?: RequestOptions) => Promise; usage: (id?: string, options?: RequestOptions) => Promise; versions: { list: (options?: RequestOptions) => Promise; get: (id: string, options?: RequestOptions) => Promise; publish: (agentId: string, options?: RequestOptions) => Promise; restore: (agentId: string, versionId?: string, options?: RequestOptions) => Promise; metrics: (id: string, options?: RequestOptions) => Promise>; }; training: { examples: (agentId: string, options?: RequestOptions) => Promise; stats: (agentId: string, options?: RequestOptions) => Promise>; }; }; /** Document upload, processing, results, and exports */ readonly extraction: { documents: { list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; listAll: (options?: RequestOptions) => Promise; get: (id: string, options?: RequestOptions) => Promise; view: (id: string, options?: RequestOptions) => Promise; upload: (file: File | Blob | FormData, options?: RequestOptions) => Promise; beginUpload: (attributes: Record, options?: RequestOptions) => Promise; findOrBeginUpload: (attributes: Record, options?: RequestOptions) => Promise; finishUpload: (id: string, options?: RequestOptions) => Promise; delete: (id: string, options?: RequestOptions) => Promise; bulkDelete: (ids: string[], options?: RequestOptions) => Promise>; reprocess: (id: string, options?: RequestOptions) => Promise; bulkReprocess: (ids: string[], options?: RequestOptions) => Promise>; status: (id: string, options?: RequestOptions) => Promise>; cancel: (id: string, options?: RequestOptions) => Promise; stats: (options?: RequestOptions) => Promise; }; results: { list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; listAll: (options?: RequestOptions) => Promise; get: (id: string, options?: RequestOptions) => Promise; byDocument: (documentId: string, options?: RequestOptions) => Promise; }; batches: { create: (attributes: Record, options?: RequestOptions) => Promise; get: (id: string, options?: RequestOptions) => Promise; }; exports: { list: (workspaceId: string, options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; listAll: (workspaceId: string, options?: RequestOptions) => Promise; create: (workspaceId: string, attributes: Record, options?: RequestOptions) => Promise; }; }; /** Semantic search, embeddings, and AI conversations */ readonly ai: { search: (query: string, topK?: number, options?: RequestOptions) => Promise>; searchAdvanced: (attributes: Record, options?: RequestOptions) => Promise>; embed: (text: string, workspaceId?: string, options?: RequestOptions) => Promise; conversations: { list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; listAll: (options?: RequestOptions) => Promise; create: (attributes?: Record, options?: RequestOptions) => Promise; get: (id: string, options?: RequestOptions) => Promise; update: (id: string, attributes: Record, options?: RequestOptions) => Promise; delete: (id: string, options?: RequestOptions) => Promise; }; messages: { list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; listAll: (options?: RequestOptions) => Promise; create: (attributes: Record, options?: RequestOptions) => Promise; delete: (id: string, options?: RequestOptions) => Promise; stream: (conversationId: string, body: Record, options?: RequestOptions) => Promise>; }; }; /** Wallet, plans, transactions, and payment methods */ readonly billing: { wallet: { get: (options?: RequestOptions) => Promise; updateCredits: (attributes: Record, options?: RequestOptions) => Promise; updatePlan: (planId: string, options?: RequestOptions) => Promise; planPreview: (options?: RequestOptions) => Promise>; autoTopUp: (attributes: Record, options?: RequestOptions) => Promise; addons: (attributes: Record, options?: RequestOptions) => Promise; invoices: { list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; listAll: (options?: RequestOptions) => Promise; }; }; plans: { list: (options?: RequestOptions) => Promise; get: (id: string, options?: RequestOptions) => Promise; getBySlug: (slug: string, options?: RequestOptions) => Promise; }; transactions: { list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; listAll: (options?: RequestOptions) => Promise; get: (id: string, options?: RequestOptions) => Promise; }; creditPackages: { list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; listAll: (options?: RequestOptions) => Promise; get: (id: string, options?: RequestOptions) => Promise; }; paymentMethods: { list: (options?: RequestOptions) => Promise; create: (attributes: Record, options?: RequestOptions) => Promise; get: (id: string, options?: RequestOptions) => Promise; delete: (id: string, options?: RequestOptions) => Promise; setDefault: (id: string, options?: RequestOptions) => Promise; }; }; /** Bucket and object management, presigned URLs */ readonly storage: { buckets: { list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; listAll: (options?: RequestOptions) => Promise; all: (options?: RequestOptions) => Promise; create: (name: string, type: "public" | "private", options?: RequestOptions) => Promise; get: (id: string, options?: RequestOptions) => Promise; update: (id: string, attributes: Record, options?: RequestOptions) => Promise; delete: (id: string, options?: RequestOptions) => Promise; stats: (id: string, options?: RequestOptions) => Promise>; objects: (id: string, options?: RequestOptions) => Promise<_Object[]>; }; objects: { list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise<_Object[]>; listAll: (options?: RequestOptions) => Promise<_Object[]>; get: (id: string, options?: RequestOptions) => Promise<_Object>; delete: (id: string, options?: RequestOptions) => Promise; register: (attributes: Record, options?: RequestOptions) => Promise<_Object>; }; signUpload: (filename: string, contentType: string, options?: RequestOptions) => Promise; signDownload: (fileId: string, options?: RequestOptions) => Promise; stats: (options?: RequestOptions) => Promise; }; /** Webhook configuration, testing, and delivery management */ readonly webhooks: { configs: { list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; listAll: (options?: RequestOptions) => Promise; create: (attributes: WebhookConfigCreateRequest, options?: RequestOptions) => Promise; get: (id: string, options?: RequestOptions) => Promise; update: (id: string, attributes: WebhookConfigUpdateRequest, options?: RequestOptions) => Promise; delete: (id: string, options?: RequestOptions) => Promise; test: (id: string, options?: RequestOptions) => Promise>; rotateSecret: (id: string, options?: RequestOptions) => Promise; stats: (options?: RequestOptions) => Promise>; }; deliveries: { list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; listAll: (options?: RequestOptions) => Promise; get: (id: string, options?: RequestOptions) => Promise; retry: (id: string, options?: RequestOptions) => Promise; stats: (options?: RequestOptions) => Promise>; }; }; /** Full-text, semantic, and saved search operations */ readonly search: { query: (q: string, params?: Record, options?: RequestOptions) => Promise>; semantic: (q: string, params?: Record, options?: RequestOptions) => Promise>; suggest: (q: string, options?: RequestOptions) => Promise>; batch: (queries: Record[], options?: RequestOptions) => Promise>; reindex: (options?: RequestOptions) => Promise>; indexes: (options?: RequestOptions) => Promise[]>; stats: (options?: RequestOptions) => Promise>; health: (options?: RequestOptions) => Promise>; status: (options?: RequestOptions) => Promise>; analytics: (options?: RequestOptions) => Promise; analyticsSummary: (options?: RequestOptions) => Promise>; saved: { list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; listAll: (options?: RequestOptions) => Promise; create: (attributes: Record, options?: RequestOptions) => Promise; delete: (id: string, options?: RequestOptions) => Promise; run: (id: string, options?: RequestOptions) => Promise>; }; }; /** Conversation threads, messaging, and thread management */ readonly threads: { list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; listAll: (options?: RequestOptions) => Promise; create: (title?: string, attributes?: Record, options?: RequestOptions) => Promise; get: (id: string, options?: RequestOptions) => Promise; update: (id: string, attributes: Record, options?: RequestOptions) => Promise; delete: (id: string, options?: RequestOptions) => Promise; archive: (id: string, options?: RequestOptions) => Promise; unarchive: (id: string, options?: RequestOptions) => Promise; export: (id: string, options?: RequestOptions) => Promise>; fork: (id: string, options?: RequestOptions) => Promise; summarize: (id: string, options?: RequestOptions) => Promise>; search: (q: string, options?: RequestOptions) => Promise; stats: (options?: RequestOptions) => Promise>; messages: { list: (threadId: string, options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; listAll: (threadId: string, options?: RequestOptions) => Promise; send: (threadId: string, content: string, attributes?: Record, options?: RequestOptions) => Promise; stream: (threadId: string, body: Record, options?: RequestOptions) => Promise>; }; }; /** Notification logs, methods, and preferences */ readonly communication: { notifications: { logs: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; logsAll: (options?: RequestOptions) => Promise; logById: (id: string, options?: RequestOptions) => Promise; logStats: (options?: RequestOptions) => Promise>; methods: { list: (options?: RequestOptions) => Promise; get: (id: string, options?: RequestOptions) => Promise; create: (attributes: Record, options?: RequestOptions) => Promise; update: (id: string, attributes: Record, options?: RequestOptions) => Promise; delete: (id: string, options?: RequestOptions) => Promise; verify: (id: string, options?: RequestOptions) => Promise; setPrimary: (id: string, options?: RequestOptions) => Promise; }; preferences: { list: (options?: RequestOptions) => Promise; get: (id: string, options?: RequestOptions) => Promise; create: (attributes: Record, options?: RequestOptions) => Promise; update: (id: string, attributes: Record, options?: RequestOptions) => Promise; }; }; }; constructor(config?: BaseClientConfig); /** * Subscribe to SDK lifecycle events. * Returns an unsubscribe function for cleanup. * * @example * ```typescript * const client = new GptClient({ apiKey: 'sk_...' }); * * // Listen for all requests * const unsubscribe = client.on('request', (event) => { * console.log(`${event.method} ${event.url}`); * }); * * // Listen for responses * client.on('response', (event) => { * console.log(`${event.status} in ${event.duration}ms`); * }); * * // Clean up * unsubscribe(); * ``` */ on(event: K, handler: (event: SdkEvents[K]) => void): () => void; } /** * JSON:API pagination links */ interface PaginationLinks { self?: string; first?: string; last?: string; prev?: string | null; next?: string | null; } /** * JSON:API response with pagination */ interface PaginatedResponse { data: T[]; links?: PaginationLinks; meta?: { total_count?: number; page_count?: number; current_page?: number; }; } /** * Options for paginated requests */ interface PaginationOptions { /** * Page size (number of items per page) */ pageSize?: number; /** * Maximum total items to fetch (default: unlimited for paginateAll, 10000 for paginateToArray) */ limit?: number; /** * Maximum number of pages to fetch (default: 500) * Safety limit to prevent infinite pagination loops */ maxPages?: number; /** * Optional logger for warnings. If not provided, falls back to console. */ logger?: { warn: (...args: unknown[]) => void; }; } /** * Async iterator for paginated results. * Security: Enforces max pages limit to prevent infinite pagination loops. */ declare function paginateAll(fetcher: (page: number, pageSize: number) => Promise>, options?: PaginationOptions): AsyncIterableIterator; /** * Helper to collect all paginated results into an array * Security: Enforces default limit to prevent DoS via infinite pagination */ declare function paginateToArray(fetcher: (page: number, pageSize: number) => Promise>, options?: PaginationOptions): Promise; /** * Build headers for SDK requests. * Merges base headers with per-request overrides and idempotency keys. */ declare function buildHeaders(getHeaders: () => Record, options?: RequestOptions): Record; /** * RequestBuilder provides a type-safe way to execute SDK requests * with consistent header merging, error handling, retry, and unwrapping. */ declare class RequestBuilder { private clientInstance; private getHeaders; private unwrap; private requestWithRetry; constructor(clientInstance: Client, getHeaders: () => Record, unwrap: (d: unknown) => T, requestWithRetry: (fn: () => Promise) => Promise); /** * Execute a generated SDK function with full middleware pipeline. * Handles headers, retry, unwrapping, and error conversion. */ execute(fn: (...args: any[]) => Promise, params: Record, options?: RequestOptions): Promise; /** * Execute a delete operation that returns true on success. */ executeDelete(fn: (...args: any[]) => Promise, params: Record, options?: RequestOptions): Promise; /** * Create a paginated fetcher function for listAll operations. * Encapsulates the pattern of calling a generated SDK function with pagination params. * * @param fn - The generated SDK function (e.g., getAgents) * @param queryBuilder - Function that builds the query object with page params * @param options - Request options (headers, signal, etc.) * @returns A fetcher function for use with paginateToArray */ createPaginatedFetcher(fn: (...args: any[]) => Promise, queryBuilder: (page: number, pageSize: number) => Record, options?: RequestOptions): (page: number, pageSize: number) => Promise>; /** * Make a streaming POST request through the client instance, * ensuring all interceptors (auth, events, API version, etc.) fire. * * Uses the client's `post()` method with `parseAs: 'stream'` so the * request/response interceptors execute, then wraps the stream body * into an SSE message iterator. */ streamRequest(url: string, body: unknown, options?: RequestOptions, streamOptions?: StreamOptions): Promise>; } /** * Webhook signature verification for GPT Core webhooks. * * Verifies that incoming webhook payloads are authentic by checking * the HMAC-SHA256 signature in the `X-GptCore-Signature` header. * * @example * ```typescript * import { Webhooks } from '@gpt-core/client'; * * const webhooks = new Webhooks('whsec_your_secret_here'); * * // In your webhook handler: * const isValid = await webhooks.verify(requestBody, signatureHeader); * * // Or construct and verify manually: * const isValid = await Webhooks.verify(requestBody, signatureHeader, 'whsec_your_secret'); * ``` */ /** * Error thrown when webhook signature verification fails. */ declare class WebhookSignatureError extends Error { constructor(message: string); } interface WebhookVerifyOptions { /** * Tolerance in seconds for timestamp verification. * Rejects signatures older than this. * Default: 300 (5 minutes) */ tolerance?: number; /** * Current timestamp in seconds (for testing). * Default: Date.now() / 1000 */ currentTimestamp?: number; } /** * Webhook signature verification utility. * * Create an instance with your webhook secret, then use `.verify()` * to validate incoming webhook payloads. * * @example * ```typescript * const wh = new Webhooks('whsec_your_secret'); * * app.post('/webhooks', async (req, res) => { * const signature = req.headers['x-gptcore-signature']; * const body = req.body; // raw string body * * try { * await wh.verify(body, signature); * // Process the webhook... * res.status(200).send('OK'); * } catch (err) { * res.status(400).send('Invalid signature'); * } * }); * ``` */ declare class Webhooks { private secret; constructor(secret: string); /** * Verify a webhook payload signature. * * @param payload - The raw request body string * @param signatureHeader - The `X-GptCore-Signature` header value * @param options - Optional verification parameters * @throws {WebhookSignatureError} If verification fails */ verify(payload: string, signatureHeader: string, options?: WebhookVerifyOptions): Promise; /** * Static verification method. * The secret should be the raw secret (whsec_ prefix is stripped automatically). * * @param payload - The raw request body string * @param signatureHeader - The `X-GptCore-Signature` header value * @param secret - The webhook signing secret * @param options - Optional verification parameters * @throws {WebhookSignatureError} If verification fails */ static verify(payload: string, signatureHeader: string, secret: string, options?: WebhookVerifyOptions): Promise; } declare function createIdentityNamespace(rb: RequestBuilder): { /** * Authenticate with email and password to receive an access token. * @example * ```typescript * const client = new GptClient({ apiKey: 'sk_tenant_...' }); * const token = await client.identity.login('user@example.com', 'password123'); * console.log(token.access_token); * ``` */ login: (email: string, password: string, options?: RequestOptions) => Promise; /** Register a new user */ register: (email: string, password: string, passwordConfirmation: string, options?: RequestOptions) => Promise; /** Confirm email with token */ confirm: (token: string, options?: RequestOptions) => Promise; /** Resend confirmation email */ resendConfirmation: (email: string, options?: RequestOptions) => Promise>; /** Request magic link */ requestMagicLink: (email: string, options?: RequestOptions) => Promise>; /** Login via magic link token */ magicLinkLogin: (token: string, options?: RequestOptions) => Promise; /** Change password */ changePassword: (currentPassword: string, newPassword: string, newPasswordConfirmation: string, options?: RequestOptions) => Promise; /** Reset password with token */ resetPassword: (token: string, password: string, passwordConfirmation: string, options?: RequestOptions) => Promise; /** * Get the currently authenticated user's details. * @example * ```typescript * const client = new GptClient({ apiKey: 'sk_tenant_...' }); * const user = await client.identity.me(); * console.log(user.email); * ``` */ me: (options?: RequestOptions) => Promise; /** Get current user's profile */ profile: (options?: RequestOptions) => Promise; /** Update user profile */ updateProfile: (id: string, attributes: Record, options?: RequestOptions) => Promise; /** Accept terms of service */ acceptTos: (id: string, options?: RequestOptions) => Promise; /** Get user stats */ stats: (options?: RequestOptions) => Promise>; /** Get user dashboard */ dashboard: (options?: RequestOptions) => Promise>; /** Get user activity */ activity: (options?: RequestOptions) => Promise>; /** Get user's tenants */ tenants: (options?: RequestOptions) => Promise; /** API key management */ apiKeys: { /** List all API keys */ list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; /** List all API keys with automatic pagination */ listAll: (options?: RequestOptions) => Promise; /** List active API keys */ active: (options?: RequestOptions) => Promise; /** Get API key by ID */ get: (id: string, options?: RequestOptions) => Promise; /** * Create a new API key with the given name. * @example * ```typescript * const client = new GptClient({ apiKey: 'sk_tenant_...' }); * const apiKey = await client.identity.apiKeys.create('my-service-key'); * console.log(apiKey.id, apiKey.key); * ``` */ create: (name: string, options?: RequestOptions) => Promise; /** Revoke an API key */ revoke: (id: string, options?: RequestOptions) => Promise; /** Rotate an API key (generates new secret) */ rotate: (id: string, options?: RequestOptions) => Promise; /** Allocate credits to an API key */ allocate: (id: string, amount: number, description: string, options?: RequestOptions) => Promise; /** Set budget for an API key */ setBudget: (id: string, budget: number, options?: RequestOptions) => Promise; /** Get API key statistics */ stats: (options?: RequestOptions) => Promise>; }; }; declare function createPlatformNamespace(rb: RequestBuilder): { workspaces: { /** * List all workspaces accessible to the current user. * @example * ```typescript * const client = new GptClient({ apiKey: 'sk_tenant_...' }); * const workspaces = await client.platform.workspaces.list(); * workspaces.forEach(ws => console.log(ws.name)); * ``` */ list: (options?: RequestOptions) => Promise; /** * Create a new workspace with a name and optional slug. * @example * ```typescript * const client = new GptClient({ apiKey: 'sk_tenant_...' }); * const workspace = await client.platform.workspaces.create('Marketing', 'marketing-team'); * console.log(workspace.id, workspace.slug); * ``` */ create: (name: string, slug?: string, options?: RequestOptions) => Promise; /** Get a workspace by ID */ get: (id: string, options?: RequestOptions) => Promise; /** Update workspace attributes */ update: (id: string, attributes: Record, options?: RequestOptions) => Promise; /** Delete a workspace */ delete: (id: string, options?: RequestOptions) => Promise; /** Get workspaces owned by the current user */ mine: (options?: RequestOptions) => Promise; /** Get workspaces shared with the current user */ shared: (options?: RequestOptions) => Promise; /** Get members of a workspace */ members: (id: string, options?: RequestOptions) => Promise; /** Allocate credits to a workspace */ allocate: (id: string, amount: number, options?: RequestOptions) => Promise; }; applications: { /** List all applications in the current tenant */ list: (options?: RequestOptions) => Promise; /** * Create a new application within the current tenant. * @example * ```typescript * const client = new GptClient({ apiKey: 'sk_tenant_...' }); * const app = await client.platform.applications.create({ name: 'My App' }); * console.log(app.id, app.slug); * ``` */ create: (attributes: { name: string; slug?: string; description?: string; }, options?: RequestOptions) => Promise; /** Get an application by ID */ get: (id: string, options?: RequestOptions) => Promise; /** Get an application by its slug */ getBySlug: (slug: string, options?: RequestOptions) => Promise; /** Get the current application (from API key context) */ current: (options?: RequestOptions) => Promise; /** Update application attributes */ update: (id: string, attributes: Record, options?: RequestOptions) => Promise; /** Delete an application */ delete: (id: string, options?: RequestOptions) => Promise; }; tenants: { /** List all tenants accessible to the current user */ list: (options?: RequestOptions) => Promise; /** Get a tenant by ID */ get: (id: string, options?: RequestOptions) => Promise; /** Get statistics for a tenant */ stats: (tenantId: string, options?: RequestOptions) => Promise; }; invitations: { /** List all invitations */ list: (options?: RequestOptions) => Promise; /** Get invitations sent to the current user */ mine: (options?: RequestOptions) => Promise; /** * Create and send an invitation to join a tenant or workspace. * @param scopeType - Either "tenant" or "workspace" * @param scopeId - ID of the tenant or workspace */ create: (email: string, role: string, scopeType: "tenant" | "workspace", scopeId: string, options?: RequestOptions) => Promise; /** Accept an invitation */ accept: (id: string, options?: RequestOptions) => Promise; /** Decline an invitation */ decline: (id: string, options?: RequestOptions) => Promise; /** Revoke an invitation (sender only) */ revoke: (id: string, options?: RequestOptions) => Promise; /** Resend an invitation email */ resend: (id: string, options?: RequestOptions) => Promise; }; memberships: { /** List workspace memberships */ list: (options?: RequestOptions) => Promise; /** Create a workspace membership */ create: (attributes: Record, options?: RequestOptions) => Promise; }; roles: { /** List available roles */ list: (options?: RequestOptions) => Promise; }; }; declare function createAgentsNamespace(rb: RequestBuilder): { /** * List agents in the current workspace, with optional pagination. * @example * ```typescript * const client = new GptClient({ apiKey: 'sk_tenant_...' }); * const agents = await client.agents.list(); * agents.forEach(a => console.log(a.name)); * ``` */ list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; listAll: (options?: RequestOptions) => Promise; /** * Create a new extraction agent with a name and prompt template. * @example * ```typescript * const client = new GptClient({ apiKey: 'sk_tenant_...' }); * const agent = await client.agents.create('Invoice Parser', 'Extract invoice fields: {{fields}}'); * console.log(agent.id); * ``` */ create: (name: string, promptTemplate: string, attributes?: Record, options?: RequestOptions) => Promise; /** * Get a single agent by its ID. * @example * ```typescript * const client = new GptClient({ apiKey: 'sk_tenant_...' }); * const agent = await client.agents.get('agent_abc123'); * console.log(agent.name, agent.prompt_template); * ``` */ get: (id: string, options?: RequestOptions) => Promise; /** Update agent attributes */ update: (id: string, attributes: Record, options?: RequestOptions) => Promise; /** Delete an agent */ delete: (id: string, options?: RequestOptions) => Promise; /** Test an agent with sample input */ test: (id: string, input?: Record, options?: RequestOptions) => Promise; /** Clone an existing agent */ clone: (id: string, options?: RequestOptions) => Promise; /** Export agent configuration as JSON */ export: (id: string, options?: RequestOptions) => Promise>; /** Import an agent from exported JSON */ import: (agentData: Record, options?: RequestOptions) => Promise; /** Validate agent configuration */ validate: (id: string, options?: RequestOptions) => Promise>; /** Get agent statistics */ stats: (id: string, options?: RequestOptions) => Promise; /** Get agent usage metrics (optionally for a specific agent) */ usage: (id?: string, options?: RequestOptions) => Promise; /** Agent version management — publish, restore, and inspect versions */ versions: { /** List all agent versions */ list: (options?: RequestOptions) => Promise; /** Get a specific agent version by ID */ get: (id: string, options?: RequestOptions) => Promise; /** Publish the current agent configuration as a new version */ publish: (agentId: string, options?: RequestOptions) => Promise; /** Restore an agent to a specific version, or to the latest published version if no versionId is provided */ restore: (agentId: string, versionId?: string, options?: RequestOptions) => Promise; /** Get performance metrics for a specific agent version */ metrics: (id: string, options?: RequestOptions) => Promise>; }; /** Training data management — examples and performance stats */ training: { /** List training examples for an agent */ examples: (agentId: string, options?: RequestOptions) => Promise; /** Get training performance statistics for an agent */ stats: (agentId: string, options?: RequestOptions) => Promise>; }; }; declare function createExtractionNamespace(rb: RequestBuilder): { documents: { /** List documents with optional pagination */ list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; /** List all documents with automatic pagination */ listAll: (options?: RequestOptions) => Promise; /** Get a document by ID */ get: (id: string, options?: RequestOptions) => Promise; /** Get document with full content for viewing */ view: (id: string, options?: RequestOptions) => Promise; /** * Upload a document for extraction processing. * @example * ```typescript * const client = new GptClient({ apiKey: 'sk_tenant_...' }); * const file = new File([buffer], 'invoice.pdf', { type: 'application/pdf' }); * const doc = await client.extraction.documents.upload(file); * console.log(doc.id, doc.status); * ``` */ upload: (file: File | Blob | FormData, options?: RequestOptions) => Promise; /** Begin a multi-part upload for large documents */ beginUpload: (attributes: Record, options?: RequestOptions) => Promise; /** Find existing document or begin new upload (idempotent) */ findOrBeginUpload: (attributes: Record, options?: RequestOptions) => Promise; /** Mark a multi-part upload as complete and trigger processing */ finishUpload: (id: string, options?: RequestOptions) => Promise; /** Delete a document */ delete: (id: string, options?: RequestOptions) => Promise; /** Delete multiple documents in bulk */ bulkDelete: (ids: string[], options?: RequestOptions) => Promise>; /** Reprocess a document with the current agent version */ reprocess: (id: string, options?: RequestOptions) => Promise; /** Reprocess multiple documents in bulk */ bulkReprocess: (ids: string[], options?: RequestOptions) => Promise>; /** Get real-time processing status for a document */ status: (id: string, options?: RequestOptions) => Promise>; /** Cancel processing for a document */ cancel: (id: string, options?: RequestOptions) => Promise; /** Get document processing statistics */ stats: (options?: RequestOptions) => Promise; }; results: { /** * List extraction results, with optional pagination. * @example * ```typescript * const client = new GptClient({ apiKey: 'sk_tenant_...' }); * const results = await client.extraction.results.list(); * results.forEach(r => console.log(r.id, r.extracted_data)); * ``` */ list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; listAll: (options?: RequestOptions) => Promise; /** Get an extraction result by ID */ get: (id: string, options?: RequestOptions) => Promise; /** Get all extraction results for a specific document */ byDocument: (documentId: string, options?: RequestOptions) => Promise; }; batches: { /** Create a batch of documents for processing */ create: (attributes: Record, options?: RequestOptions) => Promise; /** Get a batch by ID */ get: (id: string, options?: RequestOptions) => Promise; }; exports: { /** List exports for a workspace */ list: (workspaceId: string, options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; /** List all exports with automatic pagination */ listAll: (workspaceId: string, options?: RequestOptions) => Promise; /** Create an export job to download results as CSV/JSON */ create: (workspaceId: string, attributes: Record, options?: RequestOptions) => Promise; }; }; declare function createAiNamespace(rb: RequestBuilder): { /** * Perform semantic search across document embeddings. * @param topK - Number of results to return (default: 5) * @example * ```typescript * const client = new GptClient({ apiKey: 'sk_tenant_...' }); * const results = await client.ai.search('What are the payment terms?', 10); * ``` */ search: (query: string, topK?: number, options?: RequestOptions) => Promise>; /** Advanced semantic search with custom parameters */ searchAdvanced: (attributes: Record, options?: RequestOptions) => Promise>; /** Generate embeddings for text */ embed: (text: string, workspaceId?: string, options?: RequestOptions) => Promise; conversations: { /** List conversations with optional pagination */ list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; /** List all conversations with automatic pagination */ listAll: (options?: RequestOptions) => Promise; /** * Create a new AI conversation. * @example * ```typescript * const client = new GptClient({ apiKey: 'sk_tenant_...' }); * const conversation = await client.ai.conversations.create({ title: 'Support Chat' }); * console.log(conversation.id); * ``` */ create: (attributes?: Record, options?: RequestOptions) => Promise; /** Get a conversation by ID */ get: (id: string, options?: RequestOptions) => Promise; /** Update conversation attributes */ update: (id: string, attributes: Record, options?: RequestOptions) => Promise; /** Delete a conversation */ delete: (id: string, options?: RequestOptions) => Promise; }; messages: { /** List messages with optional pagination */ list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; /** List all messages with automatic pagination */ listAll: (options?: RequestOptions) => Promise; /** * Send a message in a conversation. * @example * ```typescript * const client = new GptClient({ apiKey: 'sk_tenant_...' }); * const message = await client.ai.messages.create({ * conversation_id: 'conv_abc123', * content: 'What is the total on this invoice?', * role: 'user', * }); * console.log(message.id, message.content); * ``` */ create: (attributes: Record, options?: RequestOptions) => Promise; /** Delete a message */ delete: (id: string, options?: RequestOptions) => Promise; /** Stream message responses from the AI in real-time */ stream: (conversationId: string, body: Record, options?: RequestOptions) => Promise>; }; }; declare function createBillingNamespace(rb: RequestBuilder): { wallet: { /** * Get the current wallet including credit balance and plan details. * @example * ```typescript * const client = new GptClient({ apiKey: 'sk_tenant_...' }); * const wallet = await client.billing.wallet.get(); * console.log(wallet.credits_remaining); * ``` */ get: (options?: RequestOptions) => Promise; /** Add or adjust credits on the wallet */ updateCredits: (attributes: Record, options?: RequestOptions) => Promise; /** Change the wallet's subscription plan */ updatePlan: (planId: string, options?: RequestOptions) => Promise; /** Preview plan change effects before committing */ planPreview: (options?: RequestOptions) => Promise>; /** Configure automatic credit top-up settings */ autoTopUp: (attributes: Record, options?: RequestOptions) => Promise; /** Manage wallet add-on subscriptions */ addons: (attributes: Record, options?: RequestOptions) => Promise; /** Invoice history for the wallet */ invoices: { /** List invoices with optional pagination */ list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; /** List all invoices with automatic pagination */ listAll: (options?: RequestOptions) => Promise; }; }; /** Subscription plans — list and inspect available plans */ plans: { /** List all available subscription plans */ list: (options?: RequestOptions) => Promise; /** Get a plan by ID */ get: (id: string, options?: RequestOptions) => Promise; /** Get a plan by its URL-friendly slug */ getBySlug: (slug: string, options?: RequestOptions) => Promise; }; /** Credit transactions — view billing history */ transactions: { /** List transactions with optional pagination */ list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; /** List all transactions with automatic pagination */ listAll: (options?: RequestOptions) => Promise; /** Get a transaction by ID */ get: (id: string, options?: RequestOptions) => Promise; }; /** Credit packages — browse and purchase prepaid credit bundles */ creditPackages: { /** List available credit packages with optional pagination */ list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; /** List all credit packages with automatic pagination */ listAll: (options?: RequestOptions) => Promise; /** Get a credit package by ID */ get: (id: string, options?: RequestOptions) => Promise; }; /** Payment methods — manage cards and payment sources */ paymentMethods: { /** List all payment methods */ list: (options?: RequestOptions) => Promise; /** Add a new payment method */ create: (attributes: Record, options?: RequestOptions) => Promise; /** Get a payment method by ID */ get: (id: string, options?: RequestOptions) => Promise; /** Remove a payment method */ delete: (id: string, options?: RequestOptions) => Promise; /** Set a payment method as the default for charges */ setDefault: (id: string, options?: RequestOptions) => Promise; }; }; declare function createStorageNamespace(rb: RequestBuilder): { buckets: { /** List buckets with optional pagination */ list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; /** List all buckets with automatic pagination */ listAll: (options?: RequestOptions) => Promise; /** Get all buckets (no pagination) */ all: (options?: RequestOptions) => Promise; /** * Create a new storage bucket. * @param type - "public" for public access, "private" for restricted access */ create: (name: string, type: "public" | "private", options?: RequestOptions) => Promise; /** Get a bucket by ID */ get: (id: string, options?: RequestOptions) => Promise; /** Update bucket attributes */ update: (id: string, attributes: Record, options?: RequestOptions) => Promise; /** Delete a bucket */ delete: (id: string, options?: RequestOptions) => Promise; /** Get bucket statistics */ stats: (id: string, options?: RequestOptions) => Promise>; /** List objects in a bucket */ objects: (id: string, options?: RequestOptions) => Promise<_Object[]>; }; objects: { /** List objects with optional pagination */ list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise<_Object[]>; /** List all objects with automatic pagination */ listAll: (options?: RequestOptions) => Promise<_Object[]>; /** Get an object by ID */ get: (id: string, options?: RequestOptions) => Promise<_Object>; /** Delete an object */ delete: (id: string, options?: RequestOptions) => Promise; /** Register an object in storage after direct upload */ register: (attributes: Record, options?: RequestOptions) => Promise<_Object>; }; /** * Generate a presigned URL for uploading a file to storage. * @example * ```typescript * const client = new GptClient({ apiKey: 'sk_tenant_...' }); * const { url } = await client.storage.signUpload('report.pdf', 'application/pdf'); * // Use the presigned URL to PUT the file directly * await fetch(url, { method: 'PUT', body: fileBuffer }); * ``` */ signUpload: (filename: string, contentType: string, options?: RequestOptions) => Promise; /** Generate a presigned URL for downloading a file */ signDownload: (fileId: string, options?: RequestOptions) => Promise; /** Get storage statistics */ stats: (options?: RequestOptions) => Promise; }; declare function createWebhooksNamespace(rb: RequestBuilder): { /** Webhook endpoint configurations — manage where events are delivered */ configs: { /** List webhook configurations with optional pagination */ list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; /** List all webhook configurations with automatic pagination */ listAll: (options?: RequestOptions) => Promise; /** * Create a new webhook configuration to receive event notifications. * @example * ```typescript * const client = new GptClient({ apiKey: 'sk_tenant_...' }); * const webhook = await client.webhooks.configs.create({ * url: 'https://example.com/webhooks', * events: ['document.processed', 'document.failed'], * }); * console.log(webhook.id, webhook.signing_secret); * ``` */ create: (attributes: WebhookConfigCreateRequest, options?: RequestOptions) => Promise; /** Get a webhook configuration by ID */ get: (id: string, options?: RequestOptions) => Promise; /** Update a webhook configuration */ update: (id: string, attributes: WebhookConfigUpdateRequest, options?: RequestOptions) => Promise; /** Delete a webhook configuration */ delete: (id: string, options?: RequestOptions) => Promise; /** Send a test event to the webhook endpoint */ test: (id: string, options?: RequestOptions) => Promise>; /** Rotate the signing secret for a webhook configuration */ rotateSecret: (id: string, options?: RequestOptions) => Promise; /** Get webhook configuration statistics */ stats: (options?: RequestOptions) => Promise>; }; /** Webhook delivery history — inspect and retry past deliveries */ deliveries: { /** List webhook deliveries with optional pagination */ list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; /** List all webhook deliveries with automatic pagination */ listAll: (options?: RequestOptions) => Promise; /** Get a specific delivery by ID */ get: (id: string, options?: RequestOptions) => Promise; /** Retry a failed webhook delivery */ retry: (id: string, options?: RequestOptions) => Promise; /** Get delivery statistics */ stats: (options?: RequestOptions) => Promise>; }; }; declare function createSearchNamespace(rb: RequestBuilder): { /** * Search across indexed documents and resources. * @example * ```typescript * const client = new GptClient({ apiKey: 'sk_tenant_...' }); * const results = await client.search.query('invoice total > 1000'); * console.log(results); * ``` */ query: (q: string, params?: Record, options?: RequestOptions) => Promise>; /** Perform semantic (vector-based) search */ semantic: (q: string, params?: Record, options?: RequestOptions) => Promise>; /** Get search suggestions for a query */ suggest: (q: string, options?: RequestOptions) => Promise>; /** Execute multiple searches in a single request */ batch: (queries: Record[], options?: RequestOptions) => Promise>; /** Trigger a full reindex of searchable content */ reindex: (options?: RequestOptions) => Promise>; /** List available search indexes */ indexes: (options?: RequestOptions) => Promise[]>; /** Get search statistics */ stats: (options?: RequestOptions) => Promise>; /** Check search service health */ health: (options?: RequestOptions) => Promise>; /** Get current search service status */ status: (options?: RequestOptions) => Promise>; /** Get search analytics data */ analytics: (options?: RequestOptions) => Promise; /** Get analytics summary */ analyticsSummary: (options?: RequestOptions) => Promise>; /** Saved searches — create reusable search queries that can be run on demand */ saved: { /** List saved searches */ list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; /** List all saved searches with automatic pagination */ listAll: (options?: RequestOptions) => Promise; /** Create a new saved search */ create: (attributes: Record, options?: RequestOptions) => Promise; /** Delete a saved search */ delete: (id: string, options?: RequestOptions) => Promise; /** Execute a saved search and return results */ run: (id: string, options?: RequestOptions) => Promise>; }; }; declare function createThreadsNamespace(rb: RequestBuilder): { /** List threads with optional pagination */ list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; /** List all threads with automatic pagination */ listAll: (options?: RequestOptions) => Promise; /** * Create a new conversation thread. * @example * ```typescript * const client = new GptClient({ apiKey: 'sk_tenant_...' }); * const thread = await client.threads.create('Customer Support'); * console.log(thread.id); * ``` */ create: (title?: string, attributes?: Record, options?: RequestOptions) => Promise; /** Get a thread by ID */ get: (id: string, options?: RequestOptions) => Promise; /** Update thread attributes */ update: (id: string, attributes: Record, options?: RequestOptions) => Promise; /** Delete a thread */ delete: (id: string, options?: RequestOptions) => Promise; /** Archive a thread */ archive: (id: string, options?: RequestOptions) => Promise; /** Unarchive a thread */ unarchive: (id: string, options?: RequestOptions) => Promise; /** Export thread messages as JSON */ export: (id: string, options?: RequestOptions) => Promise>; /** Fork a thread to create a new copy */ fork: (id: string, options?: RequestOptions) => Promise; /** Generate an AI summary of the thread */ summarize: (id: string, options?: RequestOptions) => Promise>; /** Search threads by query */ search: (q: string, options?: RequestOptions) => Promise; /** Get thread statistics */ stats: (options?: RequestOptions) => Promise>; messages: { /** List messages in a thread */ list: (threadId: string, options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; /** List all messages in a thread with automatic pagination */ listAll: (threadId: string, options?: RequestOptions) => Promise; /** * Send a message in a thread. * @example * ```typescript * const client = new GptClient({ apiKey: 'sk_tenant_...' }); * const message = await client.threads.messages.send(threadId, 'Hello!'); * console.log(message.id, message.content); * ``` */ send: (threadId: string, content: string, attributes?: Record, options?: RequestOptions) => Promise; /** Stream message responses in real-time */ stream: (threadId: string, body: Record, options?: RequestOptions) => Promise>; }; }; declare function createCommunicationNamespace(rb: RequestBuilder): { /** Notification system — logs, delivery methods, and user preferences */ notifications: { /** List notification logs with optional pagination */ logs: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; /** List all notification logs with automatic pagination */ logsAll: (options?: RequestOptions) => Promise; /** Get a notification log by ID */ logById: (id: string, options?: RequestOptions) => Promise; /** Get notification log statistics */ logStats: (options?: RequestOptions) => Promise>; /** Notification delivery methods (email, SMS, etc.) */ methods: { /** List notification methods (email, SMS, etc.) */ list: (options?: RequestOptions) => Promise; /** Get a notification method by ID */ get: (id: string, options?: RequestOptions) => Promise; /** Create a new notification method */ create: (attributes: Record, options?: RequestOptions) => Promise; /** Update a notification method */ update: (id: string, attributes: Record, options?: RequestOptions) => Promise; /** Delete a notification method */ delete: (id: string, options?: RequestOptions) => Promise; /** Verify a notification method (sends confirmation) */ verify: (id: string, options?: RequestOptions) => Promise; /** Set a notification method as primary */ setPrimary: (id: string, options?: RequestOptions) => Promise; }; /** User notification preferences — control which events trigger notifications */ preferences: { /** List notification preferences */ list: (options?: RequestOptions) => Promise; /** Get a notification preference by ID */ get: (id: string, options?: RequestOptions) => Promise; /** Create notification preferences for event types */ create: (attributes: Record, options?: RequestOptions) => Promise; /** Update notification preferences */ update: (id: string, attributes: Record, options?: RequestOptions) => Promise; }; }; }; type IdentityAPI = ReturnType; type PlatformAPI = ReturnType; type AgentsAPI = ReturnType; type ExtractionAPI = ReturnType; type AiAPI = ReturnType; type BillingAPI = ReturnType; type StorageAPI = ReturnType; type WebhooksAPI = ReturnType; type SearchAPI = ReturnType; type ThreadsAPI = ReturnType; type CommunicationAPI = ReturnType; export { API_KEY_PREFIXES, type AgentCreateRequest, AgentCreateSchema, type AgentImportRequest, AgentImportSchema, type AgentTestInput, AgentTestInputSchema, type AgentUpdateRequest, AgentUpdateSchema, AgentVersionError, type AgentVersionErrorOptions, type AgentsAPI, type AiAPI, type AiSearchAdvancedRequest, AiSearchAdvancedSchema, type ApiKeyAllocateRequest, ApiKeyAllocateSchema, type ApiKeyCreateRequest, ApiKeyCreateSchema, type AppInfo, type ApplicationCreateRequest, ApplicationCreateSchema, type ApplicationUpdateRequest, ApplicationUpdateSchema, AuthenticationError, AuthorizationError, type BaseClientConfig, type BeginUploadRequest, BeginUploadSchema, type BillingAPI, BrowserApiKeyError, type BucketCreateRequest, BucketCreateSchema, type BucketUpdateRequest, BucketUpdateSchema, type CommunicationAPI, ConflictError, type ConversationCreateRequest, ConversationCreateSchema, type ConversationUpdateRequest, ConversationUpdateSchema, DEFAULT_API_VERSION, DEFAULT_RETRY_CONFIG, type DocumentUploadBase64Request, DocumentUploadBase64Schema, type EmbedRequest, EmbedRequestSchema, type ExtractionAPI, type ExtractionBatchCreateRequest, ExtractionBatchCreateSchema, type ExtractionExportCreateRequest, ExtractionExportCreateSchema, GptClient, GptCoreError, type IdentityAPI, InsecureConnectionError, InvalidFieldTypeError, type InvitationCreateRequest, InvitationCreateSchema, LOG_LEVELS, type LogLevel, type Logger, type LoginRequest, LoginRequestSchema, type MembershipCreateRequest, MembershipCreateSchema, type MessageCreateRequest, MessageCreateSchema, type MessageSendRequest, MessageSendSchema, type MessageStreamRequest, MessageStreamSchema, MissingFieldNameError, NetworkError, NotFoundError, type NotificationMethodCreateRequest, NotificationMethodCreateSchema, type NotificationMethodUpdateRequest, NotificationMethodUpdateSchema, type NotificationPreferenceCreateRequest, NotificationPreferenceCreateSchema, type NotificationPreferenceUpdateRequest, NotificationPreferenceUpdateSchema, type ObjectRegisterRequest, ObjectRegisterSchema, type PaginatedResponse, type PaginationLinks, type PaginationOptions, type PlatformAPI, type PresignedDownloadRequest, PresignedDownloadSchema, type PresignedUploadRequest, PresignedUploadSchema, RateLimitError, type RegisterRequest, RegisterRequestSchema, RequestBuilder, type RequestOptions, ReservedFieldError, type RetryConfig, RetryTimeoutError, SDK_VERSION, type SavedSearchCreateRequest, SavedSearchCreateSchema, SchemaDefinitionInvalidError, type SdkErrorEvent, SdkEventEmitter, type SdkEvents, type SdkRequestEvent, type SdkResponseEvent, type SdkRetryEvent, type SearchAPI, type SearchRequest, SearchRequestSchema, type SecurityConfig, ServerError, type StorageAPI, type StreamMessageChunk, type StreamOptions, type ThreadCreateRequest, ThreadCreateSchema, type ThreadMessageStreamRequest, ThreadMessageStreamSchema, type ThreadUpdateRequest, ThreadUpdateSchema, type ThreadsAPI, TimeoutError, type UserProfileUpdateRequest, UserProfileUpdateSchema, ValidationError, VersionAlreadyUsedError, VersionInUseCannotDeleteError, VersionNotFoundError, type WalletAddonsRequest, WalletAddonsSchema, type WalletAutoTopUpRequest, WalletAutoTopUpSchema, type WalletCreditsUpdateRequest, WalletCreditsUpdateSchema, type WebhookConfigCreateRequest, WebhookConfigCreateSchema, type WebhookConfigUpdateRequest, WebhookConfigUpdateSchema, WebhookSignatureError, type WebhookVerifyOptions, Webhooks, type WebhooksAPI, type WorkspaceCreateRequest, WorkspaceCreateSchema, type WorkspaceUpdateRequest, WorkspaceUpdateSchema, buildHeaders, buildUserAgent, collectStreamedMessage, handleApiError, isBrowserEnvironment, isSecureUrl, paginateAll, paginateToArray, retryWithBackoff, streamMessage, streamSSE, validateApiKey, withRetry };