import type { ChatThread as Thread, ChatMessage as Message, ChatThreadStats as ThreadStats, ChatThreadWorkspaceStats as ThreadWorkspaceStats } from "../_internal/types.gen"; import type { RequestOptions } from "../base-client"; import { RequestBuilder } from "../request-builder"; /** Attributes accepted when sending a message to a thread. */ export type SendMessageAttributes = { role?: "user" | "assistant" | "system" | "tool"; metadata?: Record; }; /** Attributes accepted when updating a thread (PATCH semantics). */ export type UpdateThreadAttributes = { title?: string; context_summary?: string; metadata?: Record; [key: string]: unknown; }; /** * Admin-level threads namespace — cross-workspace thread management. * * Provides ISV administrators with visibility and control over chat threads * across all workspaces. Supports listing, inspection, moderation, and * lifecycle management (archive, fork, export, summarize, complete). * * @param rb - The `RequestBuilder` instance bound to the authenticated admin client. * @returns An object containing all admin thread-management methods. * * @example * ```typescript * const admin = new GptAdmin({ apiKey: 'sk_srv_...' }); * const threads = await admin.threads.list({ page: 1, pageSize: 25 }); * console.log(`Total threads returned: ${threads.length}`); * ``` */ export declare function createThreadsNamespace(rb: RequestBuilder): { /** * Lists threads with optional pagination. * * Returns threads across all workspaces accessible to the admin key. * * @param options - Optional pagination and request options. * @returns A promise resolving to an array of thread objects. * * @example * ```typescript * const admin = new GptAdmin({ apiKey: 'sk_srv_...' }); * const threads = await admin.threads.list({ page: 1, pageSize: 50 }); * ``` */ list: (options?: { page?: number; pageSize?: number; } & RequestOptions) => Promise; /** * Fetches a single thread by its ID. * * @param id - The UUID of the thread to retrieve. * @param options - Optional request options. * @returns A promise resolving to the full thread object. * * @example * ```typescript * const admin = new GptAdmin({ apiKey: 'sk_srv_...' }); * const thread = await admin.threads.get('thr_01HXYZ...'); * console.log(thread); * ``` */ get: (id: string, options?: RequestOptions) => Promise; /** * Updates one or more attributes of a thread (PATCH semantics). * * @param id - The UUID of the thread to update. * @param attributes - Partial thread attributes to apply. * @param options - Optional request options. * @returns A promise resolving to the updated thread object. * * @example * ```typescript * const admin = new GptAdmin({ apiKey: 'sk_srv_...' }); * const updated = await admin.threads.update('thr_01HXYZ...', { title: 'Reviewed' }); * ``` */ update: (id: string, attributes: UpdateThreadAttributes, options?: RequestOptions) => Promise; /** * Permanently deletes a thread and all its messages. * * @param id - The UUID of the thread to delete. * @param options - Optional request options. * @returns A promise resolving to `true` on success. * * @example * ```typescript * const admin = new GptAdmin({ apiKey: 'sk_srv_...' }); * await admin.threads.delete('thr_01HXYZ...'); * ``` */ delete: (id: string, options?: RequestOptions) => Promise; /** * Full-text search threads by title or context summary. * * @param query - The search query string. * @param options - Optional request options. * @returns A promise resolving to an array of matching thread objects. * * @example * ```typescript * const admin = new GptAdmin({ apiKey: 'sk_srv_...' }); * const results = await admin.threads.search('invoice review'); * ``` */ search: (query: string, options?: RequestOptions) => Promise; /** * Archives a thread, soft-deleting it from default listings. * * @param id - The UUID of the thread to archive. * @param options - Optional request options. * @returns A promise resolving to the updated thread object. * * @example * ```typescript * const admin = new GptAdmin({ apiKey: 'sk_srv_...' }); * await admin.threads.archive('thr_01HXYZ...'); * ``` */ archive: (id: string, options?: RequestOptions) => Promise; /** * Restores a previously archived thread. * * @param id - The UUID of the archived thread to restore. * @param options - Optional request options. * @returns A promise resolving to the restored thread object. * * @example * ```typescript * const admin = new GptAdmin({ apiKey: 'sk_srv_...' }); * await admin.threads.unarchive('thr_01HXYZ...'); * ``` */ unarchive: (id: string, options?: RequestOptions) => Promise; /** * Generates an AI summary of the thread's conversation history. * * @param id - The UUID of the thread to summarize. * @param options - Optional request options. * @returns A promise resolving to the thread with a populated summary. * * @example * ```typescript * const admin = new GptAdmin({ apiKey: 'sk_srv_...' }); * const thread = await admin.threads.summarize('thr_01HXYZ...'); * ``` */ summarize: (id: string, options?: RequestOptions) => Promise; /** * Forks a thread, creating a new copy with all messages. * * @param id - The UUID of the thread to fork. * @param options - Optional request options. * @returns A promise resolving to the newly created fork. * * @example * ```typescript * const admin = new GptAdmin({ apiKey: 'sk_srv_...' }); * const fork = await admin.threads.fork('thr_01HXYZ...'); * ``` */ fork: (id: string, title?: string, options?: RequestOptions) => Promise; /** * Exports a thread and its messages in JSON, Markdown, or plain text. * * @param id - The UUID of the thread to export. * @param format - Export format: `'json'` (default), `'markdown'`, or `'text'`. * @param options - Optional request options. * @returns A promise resolving to the export payload. * * @example * ```typescript * const admin = new GptAdmin({ apiKey: 'sk_srv_...' }); * const exported = await admin.threads.export('thr_01HXYZ...', 'markdown'); * ``` */ export: (id: string, format?: "json" | "markdown" | "text", options?: RequestOptions) => Promise; /** * Triggers AI inference on a thread without a new user message. * * @param id - The UUID of the thread to complete. * @param options - Optional request options. * @returns A promise resolving to the updated thread after the AI response is saved. * * @example * ```typescript * const admin = new GptAdmin({ apiKey: 'sk_srv_...' }); * const thread = await admin.threads.complete('thr_01HXYZ...'); * ``` */ complete: (id: string, options?: RequestOptions) => Promise; /** * Returns platform-wide chat statistics (admin only). * * @param options - Optional request options. * @returns A promise resolving to platform-level thread/message stats. * * @example * ```typescript * const admin = new GptAdmin({ apiKey: 'sk_srv_...' }); * const stats = await admin.threads.platformStats(); * console.log(`Total threads: ${stats.total_threads}`); * ``` */ platformStats: (options?: RequestOptions) => Promise; /** * Returns workspace-scoped chat statistics. * * @param options - Optional request options. * @returns A promise resolving to workspace-level thread/message stats. * * @example * ```typescript * const admin = new GptAdmin({ apiKey: 'sk_srv_...' }); * const stats = await admin.threads.workspaceStats(); * ``` */ workspaceStats: (options?: RequestOptions) => Promise; /** * Sub-namespace for managing messages within a thread. */ messages: { /** * Lists all messages in a thread. * * @param threadId - The UUID of the thread. * @param options - Optional request options. * @returns A promise resolving to an array of message objects. * * @example * ```typescript * const admin = new GptAdmin({ apiKey: 'sk_srv_...' }); * const messages = await admin.threads.messages.list('thr_01HXYZ...'); * ``` */ list: (threadId: string, options?: RequestOptions) => Promise; /** * Sends a message to a thread and triggers AI processing. * * @param threadId - The UUID of the thread. * @param content - The message content to send. * @param attributes - Optional extra attributes (role, metadata, attachments). * @param options - Optional request options. * @returns A promise resolving to the thread with the AI response. * * @example * ```typescript * const admin = new GptAdmin({ apiKey: 'sk_srv_...' }); * const result = await admin.threads.messages.send('thr_01HXYZ...', 'Analyze this data'); * ``` */ send: (threadId: string, content: string, attributes?: SendMessageAttributes, options?: RequestOptions) => Promise; }; }; //# sourceMappingURL=threads.d.ts.map