import type { RequestInit, RequestInfo } from "./internal/builtin-types.js"; import type { PromiseOrValue, MergedRequestInit, FinalizedRequestInit } from "./internal/types.js"; export type { Logger, LogLevel } from "./internal/utils/log.js"; import * as Opts from "./internal/request-options.js"; import * as Errors from "./core/error.js"; import * as Uploads from "./core/uploads.js"; import * as API from "./resources/index.js"; import { APIPromise } from "./core/api-promise.js"; import { APIResponseAgent, Agent, AgentCreateParams, AgentListParams, AgentListResponse, AgentUpdateParams, Agents, CreateAgent } from "./resources/agents.js"; import { APIResponseBatchFileUpload, APIResponseBatchGetFiles, APIResponseFileChunkStatus, APIResponseFileChunkTask, APIResponseFileDetail, APIResponseFileList, APIResponseFileParse, APIResponseFileURL, BatchFileUpload, BatchGetFiles, File, FileBatchGetParams, FileBatchUploadParams, FileChunkStatus, FileChunkTask, FileCreateChunkTaskParams, FileDetail, FileGetPresignedURLParams, FileListParams, FileParse, FileParseContentParams, FileURL, FileUpdateParams, FileUploadParams, Files } from "./resources/files.js"; import { APIResponseTranslation, MessageTranslationTranslateParams, MessageTranslationUpdateParams, MessageTranslations, TranslateTrigger } from "./resources/message-translations.js"; import { APIResponseMessage, CreateMessageRequest, Message, MessageCountParams, MessageCountResponse, MessageCreateParams, MessageDeleteBatchParams, MessageDeleteBatchResponse, MessageListParams, MessageListResponse, MessageRepiesParams, Messages } from "./resources/messages.js"; import { APIResponse, CreateModel, Model, ModelCreateParams, ModelListParams, ModelListResponse, ModelRetrieveParams, ModelUpdateParams, Models } from "./resources/models.js"; import { APIResponsePermission, CreatePermission, Permission, PermissionCreateParams, PermissionListParams, PermissionListResponse, PermissionUpdateParams, Permissions } from "./resources/permissions.js"; import { APIResponseProvider, CreateProviderRequest, Provider, ProviderCreateParams, ProviderListParams, ProviderListResponse, ProviderUpdateParams, Providers } from "./resources/providers.js"; import { APIResponseSessionGroup, SessionGroup, SessionGroupCreateParams, SessionGroupListResponse, SessionGroupUpdateParams, SessionGroups } from "./resources/session-groups.js"; import { APIResponseSession, APIResponseSessionList, Session, SessionBatchUpdateParams, SessionCreateParams, SessionListGroupedByAgentParams, SessionListGroupedByAgentResponse, SessionListParams, SessionUpdateParams, Sessions, UpdateSessionRequest } from "./resources/sessions.js"; import { APIResponseTopic, Topic, TopicCreateParams, TopicListParams, TopicListResponse, TopicUpdateParams, Topics } from "./resources/topics.js"; import { APIResponseKnowledgeBase, APIResponseKnowledgeBaseDelete, APIResponseKnowledgeBaseFileOperation, APIResponseKnowledgeBaseList, APIResponseMoveKnowledgeBaseFiles, CreateKnowledgeBaseRequest, KBAPIResponseFileList, KBFile, KnowledgeBase, KnowledgeBaseCreateParams, KnowledgeBaseFileOperationResult, KnowledgeBaseListItem, KnowledgeBaseListParams, KnowledgeBaseUpdateParams, KnowledgeBases, MoveKnowledgeBaseFilesResult, UpdateKnowledgeBaseRequest } from "./resources/knowledge-bases/knowledge-bases.js"; import { APIResponseRole, CreateRoleRequest, Role, RoleCreateParams, RoleListParams, RoleListResponse, RoleUpdateParams, Roles } from "./resources/roles/roles.js"; import { APIResponseBase, APIResponseUser, APIResponseVoid, UserCreateParams, UserListParams, UserListResponse, UserUpdateParams, UserWithRoles, Users } from "./resources/users/users.js"; import { type Fetch } from "./internal/builtin-types.js"; import { HeadersLike, NullableHeaders } from "./internal/headers.js"; import { FinalRequestOptions, RequestOptions } from "./internal/request-options.js"; import { type LogLevel, type Logger } from "./internal/utils/log.js"; export interface ClientOptions { /** * Defaults to process.env['LOBEHUB_API_KEY']. */ apiKey?: string | undefined; /** * Override the default base URL for the API, e.g., "https://api.example.com/v2/" * * Defaults to process.env['LOBEHUB_SIT_BASE_URL']. */ baseURL?: string | null | undefined; /** * The maximum amount of time (in milliseconds) that the client should wait for a response * from the server before timing out a single request. * * Note that request timeouts are retried by default, so in a worst-case scenario you may wait * much longer than this timeout before the promise succeeds or fails. * * @unit milliseconds */ timeout?: number | undefined; /** * Additional `RequestInit` options to be passed to `fetch` calls. * Properties will be overridden by per-request `fetchOptions`. */ fetchOptions?: MergedRequestInit | undefined; /** * Specify a custom `fetch` function implementation. * * If not provided, we expect that `fetch` is defined globally. */ fetch?: Fetch | undefined; /** * The maximum number of times that the client will retry a request in case of a * temporary failure, like a network error or a 5XX error from the server. * * @default 2 */ maxRetries?: number | undefined; /** * Default headers to include with every request to the API. * * These can be removed in individual requests by explicitly setting the * header to `null` in request options. */ defaultHeaders?: HeadersLike | undefined; /** * Default query parameters to include with every request to the API. * * These can be removed in individual requests by explicitly setting the * param to `undefined` in request options. */ defaultQuery?: Record | undefined; /** * Set the log level. * * Defaults to process.env['LOBEHUB_SIT_LOG'] or 'warn' if it isn't set. */ logLevel?: LogLevel | undefined; /** * Set the logger. * * Defaults to globalThis.console. */ logger?: Logger | undefined; } /** * API Client for interfacing with the Lobehub Sit API. */ export declare class LobehubSit { #private; apiKey: string; baseURL: string; maxRetries: number; timeout: number; logger: Logger | undefined; logLevel: LogLevel | undefined; fetchOptions: MergedRequestInit | undefined; private fetch; protected idempotencyHeader?: string; private _options; /** * API Client for interfacing with the Lobehub Sit API. * * @param {string | undefined} [opts.apiKey=process.env['LOBEHUB_API_KEY'] ?? undefined] * @param {string} [opts.baseURL=process.env['LOBEHUB_SIT_BASE_URL'] ?? /api/v1] - Override the default base URL for the API. * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out. * @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls. * @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation. * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request. * @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API. * @param {Record} opts.defaultQuery - Default query parameters to include with every request to the API. */ constructor({ baseURL, apiKey, ...opts }?: ClientOptions); /** * Create a new client instance re-using the same options given to the current client with optional overriding. */ withOptions(options: Partial): this; protected defaultQuery(): Record | undefined; protected validateHeaders({ values, nulls }: NullableHeaders): void; protected authHeaders(opts: FinalRequestOptions): Promise; /** * Basic re-implementation of `qs.stringify` for primitive types. */ protected stringifyQuery(query: Record): string; private getUserAgent; protected defaultIdempotencyKey(): string; protected makeStatusError(status: number, error: Object, message: string | undefined, headers: Headers): Errors.APIError; buildURL(path: string, query: Record | null | undefined, defaultBaseURL?: string | undefined): string; /** * Used as a callback for mutating the given `FinalRequestOptions` object. */ protected prepareOptions(options: FinalRequestOptions): Promise; /** * Used as a callback for mutating the given `RequestInit` object. * * This is useful for cases where you want to add certain headers based off of * the request properties, e.g. `method` or `url`. */ protected prepareRequest(request: RequestInit, { url, options }: { url: string; options: FinalRequestOptions; }): Promise; get(path: string, opts?: PromiseOrValue): APIPromise; post(path: string, opts?: PromiseOrValue): APIPromise; patch(path: string, opts?: PromiseOrValue): APIPromise; put(path: string, opts?: PromiseOrValue): APIPromise; delete(path: string, opts?: PromiseOrValue): APIPromise; private methodRequest; request(options: PromiseOrValue, remainingRetries?: number | null): APIPromise; private makeRequest; fetchWithTimeout(url: RequestInfo, init: RequestInit | undefined, ms: number, controller: AbortController): Promise; private shouldRetry; private retryRequest; private calculateDefaultRetryTimeoutMillis; buildRequest(inputOptions: FinalRequestOptions, { retryCount }?: { retryCount?: number; }): Promise<{ req: FinalizedRequestInit; url: string; timeout: number; }>; private buildHeaders; private buildBody; static LobehubSit: typeof LobehubSit; static DEFAULT_TIMEOUT: number; static LobehubSitError: typeof Errors.LobehubSitError; static APIError: typeof Errors.APIError; static APIConnectionError: typeof Errors.APIConnectionError; static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError; static APIUserAbortError: typeof Errors.APIUserAbortError; static NotFoundError: typeof Errors.NotFoundError; static ConflictError: typeof Errors.ConflictError; static RateLimitError: typeof Errors.RateLimitError; static BadRequestError: typeof Errors.BadRequestError; static AuthenticationError: typeof Errors.AuthenticationError; static InternalServerError: typeof Errors.InternalServerError; static PermissionDeniedError: typeof Errors.PermissionDeniedError; static UnprocessableEntityError: typeof Errors.UnprocessableEntityError; static toFile: typeof Uploads.toFile; users: API.Users; agents: API.Agents; files: API.Files; messages: API.Messages; messageTranslations: API.MessageTranslations; models: API.Models; permissions: API.Permissions; providers: API.Providers; roles: API.Roles; sessionGroups: API.SessionGroups; sessions: API.Sessions; topics: API.Topics; knowledgeBases: API.KnowledgeBases; } export declare namespace LobehubSit { export type RequestOptions = Opts.RequestOptions; export { Users as Users, type APIResponseBase as APIResponseBase, type APIResponseUser as APIResponseUser, type APIResponseVoid as APIResponseVoid, type UserWithRoles as UserWithRoles, type UserListResponse as UserListResponse, type UserCreateParams as UserCreateParams, type UserUpdateParams as UserUpdateParams, type UserListParams as UserListParams, }; export { Agents as Agents, type Agent as Agent, type APIResponseAgent as APIResponseAgent, type CreateAgent as CreateAgent, type AgentListResponse as AgentListResponse, type AgentCreateParams as AgentCreateParams, type AgentUpdateParams as AgentUpdateParams, type AgentListParams as AgentListParams, }; export { Files as Files, type APIResponseBatchFileUpload as APIResponseBatchFileUpload, type APIResponseBatchGetFiles as APIResponseBatchGetFiles, type APIResponseFileChunkStatus as APIResponseFileChunkStatus, type APIResponseFileChunkTask as APIResponseFileChunkTask, type APIResponseFileDetail as APIResponseFileDetail, type APIResponseFileList as APIResponseFileList, type APIResponseFileParse as APIResponseFileParse, type APIResponseFileURL as APIResponseFileURL, type BatchFileUpload as BatchFileUpload, type BatchGetFiles as BatchGetFiles, type File as File, type FileChunkStatus as FileChunkStatus, type FileChunkTask as FileChunkTask, type FileDetail as FileDetail, type FileParse as FileParse, type FileURL as FileURL, type FileUpdateParams as FileUpdateParams, type FileListParams as FileListParams, type FileBatchGetParams as FileBatchGetParams, type FileBatchUploadParams as FileBatchUploadParams, type FileCreateChunkTaskParams as FileCreateChunkTaskParams, type FileGetPresignedURLParams as FileGetPresignedURLParams, type FileParseContentParams as FileParseContentParams, type FileUploadParams as FileUploadParams, }; export { Messages as Messages, type APIResponseMessage as APIResponseMessage, type CreateMessageRequest as CreateMessageRequest, type Message as Message, type MessageListResponse as MessageListResponse, type MessageCountResponse as MessageCountResponse, type MessageDeleteBatchResponse as MessageDeleteBatchResponse, type MessageCreateParams as MessageCreateParams, type MessageListParams as MessageListParams, type MessageCountParams as MessageCountParams, type MessageDeleteBatchParams as MessageDeleteBatchParams, type MessageRepiesParams as MessageRepiesParams, }; export { MessageTranslations as MessageTranslations, type APIResponseTranslation as APIResponseTranslation, type TranslateTrigger as TranslateTrigger, type MessageTranslationUpdateParams as MessageTranslationUpdateParams, type MessageTranslationTranslateParams as MessageTranslationTranslateParams, }; export { Models as Models, type APIResponse as APIResponse, type CreateModel as CreateModel, type Model as Model, type ModelListResponse as ModelListResponse, type ModelCreateParams as ModelCreateParams, type ModelRetrieveParams as ModelRetrieveParams, type ModelUpdateParams as ModelUpdateParams, type ModelListParams as ModelListParams, }; export { Permissions as Permissions, type APIResponsePermission as APIResponsePermission, type CreatePermission as CreatePermission, type Permission as Permission, type PermissionListResponse as PermissionListResponse, type PermissionCreateParams as PermissionCreateParams, type PermissionUpdateParams as PermissionUpdateParams, type PermissionListParams as PermissionListParams, }; export { Providers as Providers, type APIResponseProvider as APIResponseProvider, type CreateProviderRequest as CreateProviderRequest, type Provider as Provider, type ProviderListResponse as ProviderListResponse, type ProviderCreateParams as ProviderCreateParams, type ProviderUpdateParams as ProviderUpdateParams, type ProviderListParams as ProviderListParams, }; export { Roles as Roles, type APIResponseRole as APIResponseRole, type CreateRoleRequest as CreateRoleRequest, type Role as Role, type RoleListResponse as RoleListResponse, type RoleCreateParams as RoleCreateParams, type RoleUpdateParams as RoleUpdateParams, type RoleListParams as RoleListParams, }; export { SessionGroups as SessionGroups, type APIResponseSessionGroup as APIResponseSessionGroup, type SessionGroup as SessionGroup, type SessionGroupListResponse as SessionGroupListResponse, type SessionGroupCreateParams as SessionGroupCreateParams, type SessionGroupUpdateParams as SessionGroupUpdateParams, }; export { Sessions as Sessions, type APIResponseSession as APIResponseSession, type APIResponseSessionList as APIResponseSessionList, type Session as Session, type UpdateSessionRequest as UpdateSessionRequest, type SessionListGroupedByAgentResponse as SessionListGroupedByAgentResponse, type SessionCreateParams as SessionCreateParams, type SessionUpdateParams as SessionUpdateParams, type SessionListParams as SessionListParams, type SessionBatchUpdateParams as SessionBatchUpdateParams, type SessionListGroupedByAgentParams as SessionListGroupedByAgentParams, }; export { Topics as Topics, type APIResponseTopic as APIResponseTopic, type Topic as Topic, type TopicListResponse as TopicListResponse, type TopicCreateParams as TopicCreateParams, type TopicUpdateParams as TopicUpdateParams, type TopicListParams as TopicListParams, }; export { KnowledgeBases as KnowledgeBases, type APIResponseKnowledgeBase as APIResponseKnowledgeBase, type APIResponseKnowledgeBaseDelete as APIResponseKnowledgeBaseDelete, type APIResponseKnowledgeBaseFileOperation as APIResponseKnowledgeBaseFileOperation, type APIResponseKnowledgeBaseList as APIResponseKnowledgeBaseList, type APIResponseMoveKnowledgeBaseFiles as APIResponseMoveKnowledgeBaseFiles, type CreateKnowledgeBaseRequest as CreateKnowledgeBaseRequest, type KBAPIResponseFileList as KBAPIResponseFileList, type KBFile as KBFile, type KnowledgeBase as KnowledgeBase, type KnowledgeBaseFileOperationResult as KnowledgeBaseFileOperationResult, type KnowledgeBaseListItem as KnowledgeBaseListItem, type MoveKnowledgeBaseFilesResult as MoveKnowledgeBaseFilesResult, type UpdateKnowledgeBaseRequest as UpdateKnowledgeBaseRequest, type KnowledgeBaseCreateParams as KnowledgeBaseCreateParams, type KnowledgeBaseUpdateParams as KnowledgeBaseUpdateParams, type KnowledgeBaseListParams as KnowledgeBaseListParams, }; } //# sourceMappingURL=client.d.ts.map