@fluxbase/sdk 2026.1.14-rc.3 → 2026.1.14-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -2373,6 +2373,19 @@ interface SyncChatbotsResult {
2373
2373
  errors: SyncError[];
2374
2374
  dry_run: boolean;
2375
2375
  }
2376
+ /**
2377
+ * Response from chatbot lookup by name (smart namespace resolution)
2378
+ */
2379
+ interface AIChatbotLookupResponse {
2380
+ /** The chatbot if found (unique or resolved from default namespace) */
2381
+ chatbot?: AIChatbotSummary;
2382
+ /** True if multiple chatbots with this name exist in different namespaces */
2383
+ ambiguous: boolean;
2384
+ /** List of namespaces where the chatbot exists (when ambiguous) */
2385
+ namespaces?: string[];
2386
+ /** Error message if lookup failed */
2387
+ error?: string;
2388
+ }
2376
2389
  /**
2377
2390
  * AI chat message role
2378
2391
  */
@@ -9928,6 +9941,11 @@ interface AIChatOptions {
9928
9941
  reconnectAttempts?: number;
9929
9942
  /** Reconnect delay in ms */
9930
9943
  reconnectDelay?: number;
9944
+ /** @internal Lookup function for smart namespace resolution */
9945
+ _lookupChatbot?: (name: string) => Promise<{
9946
+ data: AIChatbotLookupResponse | null;
9947
+ error: Error | null;
9948
+ }>;
9931
9949
  }
9932
9950
  /**
9933
9951
  * AI Chat client for WebSocket-based chat with AI chatbots
@@ -9986,7 +10004,12 @@ declare class FluxbaseAIChat {
9986
10004
  * Start a new chat session with a chatbot
9987
10005
  *
9988
10006
  * @param chatbot - Chatbot name
9989
- * @param namespace - Optional namespace (defaults to 'default')
10007
+ * @param namespace - Optional namespace. If not provided and a lookup function is available,
10008
+ * performs smart resolution:
10009
+ * - If exactly one chatbot with this name exists, uses it
10010
+ * - If multiple exist, tries "default" namespace
10011
+ * - If ambiguous and not in default, throws error with available namespaces
10012
+ * If no lookup function, falls back to "default" namespace.
9990
10013
  * @param conversationId - Optional conversation ID to resume
9991
10014
  * @param impersonateUserId - Optional user ID to impersonate (admin only)
9992
10015
  * @returns Promise resolving to conversation ID
@@ -10066,13 +10089,39 @@ declare class FluxbaseAI {
10066
10089
  data: AIChatbotSummary | null;
10067
10090
  error: Error | null;
10068
10091
  }>;
10092
+ /**
10093
+ * Lookup a chatbot by name with smart namespace resolution
10094
+ *
10095
+ * Resolution logic:
10096
+ * 1. If exactly one chatbot with this name exists -> returns it
10097
+ * 2. If multiple exist -> tries "default" namespace first
10098
+ * 3. If multiple exist and none in "default" -> returns ambiguous=true with namespaces list
10099
+ *
10100
+ * @param name - Chatbot name
10101
+ * @returns Promise resolving to { data, error } tuple with lookup result
10102
+ *
10103
+ * @example
10104
+ * ```typescript
10105
+ * // Lookup chatbot by name
10106
+ * const { data, error } = await ai.lookupChatbot('sql-assistant')
10107
+ * if (data?.chatbot) {
10108
+ * console.log(`Found in namespace: ${data.chatbot.namespace}`)
10109
+ * } else if (data?.ambiguous) {
10110
+ * console.log(`Chatbot exists in: ${data.namespaces?.join(', ')}`)
10111
+ * }
10112
+ * ```
10113
+ */
10114
+ lookupChatbot(name: string): Promise<{
10115
+ data: AIChatbotLookupResponse | null;
10116
+ error: Error | null;
10117
+ }>;
10069
10118
  /**
10070
10119
  * Create a new AI chat connection
10071
10120
  *
10072
10121
  * @param options - Chat connection options
10073
10122
  * @returns FluxbaseAIChat instance
10074
10123
  */
10075
- createChat(options: Omit<AIChatOptions, "wsUrl">): FluxbaseAIChat;
10124
+ createChat(options: Omit<AIChatOptions, "wsUrl" | "_lookupChatbot">): FluxbaseAIChat;
10076
10125
  /**
10077
10126
  * List the authenticated user's conversations
10078
10127
  *
@@ -11908,4 +11957,4 @@ declare function isBoolean(value: unknown): value is boolean;
11908
11957
  */
11909
11958
  declare function assertType<T>(value: unknown, validator: (v: unknown) => v is T, errorMessage?: string): asserts value is T;
11910
11959
 
11911
- export { type AIChatClientMessage, type AIChatEvent, type AIChatEventType, type AIChatMessageRole, type AIChatOptions, type AIChatServerMessage, type AIChatbot, type AIChatbotSummary, type AIConversation, type AIConversationMessage, type AIProvider, type AIProviderType, type AIUsageStats, type AIUserConversationDetail, type AIUserConversationSummary, type AIUserMessage, type AIUserQueryResult, type AIUserUsageStats, type APIKey, APIKeysManager, type AcceptInvitationRequest, type AcceptInvitationResponse, type AdminAuthResponse, type AdminBucket, type AdminListBucketsResponse, type AdminListObjectsResponse, type AdminLoginRequest, type AdminMeResponse, type AdminRefreshRequest, type AdminRefreshResponse, type AdminSetupRequest, type AdminSetupStatusResponse, type AdminStorageObject, type AdminUser, type AppSettings, AppSettingsManager, type ApplyMigrationRequest, type ApplyPendingRequest, type AuthConfig, type AuthResponse, type AuthResponseData, type AuthSession, type AuthSettings, AuthSettingsManager, type AuthenticationSettings, type Branch, type BranchActivity, type BranchPoolStats, type BranchStatus, type BranchType, type BroadcastCallback, type BroadcastMessage, type BundleOptions, type BundleResult, type CaptchaConfig, type CaptchaProvider, type ChatbotSpec, type ChunkedUploadSession, type ClientKey, ClientKeysManager, type Column, type CreateAIProviderRequest, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateBranchOptions, type CreateClientKeyRequest, type CreateClientKeyResponse, type CreateColumnRequest, type CreateFunctionRequest, type CreateInvitationRequest, type CreateInvitationResponse, type CreateMigrationRequest, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateUserSettingRequest, type CreateWebhookRequest, DDLManager, type DataCloneMode, type DataResponse, type DeleteAPIKeyResponse, type DeleteClientKeyResponse, type DeleteOAuthProviderResponse, type DeleteTableResponse, type DeleteUserResponse, type DeleteWebhookResponse, type DownloadOptions, type DownloadProgress, type EdgeFunction, type EdgeFunctionExecution, type EmailProviderSettings, type EmailSettingOverride, type EmailSettings, EmailSettingsManager, type EmailTemplate, EmailTemplateManager, type EmailTemplateType, type EmbedRequest, type EmbedResponse, type EnableRealtimeRequest, type EnableRealtimeResponse, type EnrichedUser, type ExecutionLog, type ExecutionLogCallback, type ExecutionLogConfig, type ExecutionLogEvent, type ExecutionLogLevel, ExecutionLogsChannel, type ExecutionType, type FeatureSettings, type FileObject, type FilterOperator, FluxbaseAI, FluxbaseAIChat, FluxbaseAdmin, FluxbaseAdminAI, FluxbaseAdminFunctions, FluxbaseAdminJobs, FluxbaseAdminMigrations, FluxbaseAdminRPC, FluxbaseAdminRealtime, FluxbaseAdminStorage, FluxbaseAuth, type FluxbaseAuthResponse, FluxbaseBranching, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseGraphQL, FluxbaseJobs, FluxbaseManagement, FluxbaseOAuth, FluxbaseRPC, FluxbaseRealtime, type FluxbaseResponse, FluxbaseSettings, FluxbaseStorage, FluxbaseVector, type FunctionInvokeOptions, type FunctionSpec, type GetImpersonationResponse, type GraphQLError, type GraphQLErrorLocation, type GraphQLRequestOptions, type GraphQLResponse, type HealthResponse, type HttpMethod, type ImageFitMode, type ImageFormat, type ImpersonateAnonRequest, type ImpersonateServiceRequest, type ImpersonateUserRequest, ImpersonationManager, type ImpersonationSession, type ImpersonationTargetUser, type ImpersonationType, type IntrospectionDirective, type IntrospectionEnumValue, type IntrospectionField, type IntrospectionInputValue, type IntrospectionSchema, type IntrospectionType, type IntrospectionTypeRef, type Invitation, InvitationsManager, type InviteUserRequest, type InviteUserResponse, type ListAPIKeysResponse, type ListBranchesOptions, type ListBranchesResponse, type ListClientKeysResponse, type ListConversationsOptions, type ListConversationsResult, type ListEmailTemplatesResponse, type ListImpersonationSessionsOptions, type ListImpersonationSessionsResponse, type ListInvitationsOptions, type ListInvitationsResponse, type ListOAuthProvidersResponse, type ListOptions, type ListRealtimeTablesResponse, type ListSchemasResponse, type ListSystemSettingsResponse, type ListTablesResponse, type ListUsersOptions, type ListUsersResponse, type ListWebhookDeliveriesResponse, type ListWebhooksResponse, type MailgunSettings, type Migration, type MigrationExecution, type OAuthLogoutOptions, type OAuthLogoutResponse, type OAuthProvider, OAuthProviderManager, type OAuthProviderPublic, type OrderBy, type OrderDirection, type PostgresChangesConfig, type PostgrestError, type PostgrestResponse, type PresenceCallback, type PresenceState, QueryBuilder, type QueryFilter, type RPCExecution, type RPCExecutionFilters, type RPCExecutionLog, type RPCExecutionStatus, type RPCInvokeResponse, type RPCProcedure, type RPCProcedureSpec, type RPCProcedureSummary, type RealtimeBroadcastPayload, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeChannelConfig, type RealtimeMessage, type RealtimePostgresChangesPayload, type RealtimePresencePayload, type RealtimeTableStatus, type RequestOptions, type ResetUserPasswordResponse, type ResumableDownloadData, type ResumableDownloadOptions, type ResumableUploadOptions, type ResumableUploadProgress, type RevokeAPIKeyResponse, type RevokeClientKeyResponse, type RevokeInvitationResponse, type RollbackMigrationRequest, type SAMLLoginOptions, type SAMLLoginResponse, type SAMLProvider, type SAMLProvidersResponse, type SAMLSession, type SESSettings, type SMTPSettings, type Schema, SchemaQueryBuilder, type SecuritySettings, type SendEmailRequest, type SendGridSettings, type SessionResponse, SettingsClient, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type SignedUrlResponse, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, type StreamDownloadData, type StreamUploadOptions, type SupabaseAuthResponse, type SupabaseResponse, type SyncChatbotsOptions, type SyncChatbotsResult, type SyncError, type SyncFunctionsOptions, type SyncFunctionsResult, type SyncMigrationsOptions, type SyncMigrationsResult, type SyncRPCOptions, type SyncRPCResult, type SystemSetting, SystemSettingsManager, type Table, type TestEmailSettingsResponse, type TestEmailTemplateRequest, type TestWebhookResponse, type TransformOptions, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAIProviderRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateClientKeyRequest, type UpdateConversationOptions, type UpdateEmailProviderSettingsRequest, type UpdateEmailTemplateRequest, type UpdateFunctionRequest, type UpdateMigrationRequest, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateRPCProcedureRequest, type UpdateRealtimeConfigRequest, type UpdateSystemSettingRequest, type UpdateUserAttributes, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type UploadProgress, type UpsertOptions, type User, type UserResponse, type UserSetting, type UserSettingWithSource, type ValidateInvitationResponse, type VectorMetric, type VectorOrderOptions, type VectorSearchOptions, type VectorSearchResult, type VoidResponse, type WeakPassword, type Webhook, type WebhookDelivery, WebhooksManager, assertType, bundleCode, createClient, denoExternalPlugin, hasPostgrestError, isArray, isAuthError, isAuthSuccess, isBoolean, isFluxbaseError, isFluxbaseSuccess, isNumber, isObject, isPostgrestSuccess, isString, loadImportMap };
11960
+ export { type AIChatClientMessage, type AIChatEvent, type AIChatEventType, type AIChatMessageRole, type AIChatOptions, type AIChatServerMessage, type AIChatbot, type AIChatbotLookupResponse, type AIChatbotSummary, type AIConversation, type AIConversationMessage, type AIProvider, type AIProviderType, type AIUsageStats, type AIUserConversationDetail, type AIUserConversationSummary, type AIUserMessage, type AIUserQueryResult, type AIUserUsageStats, type APIKey, APIKeysManager, type AcceptInvitationRequest, type AcceptInvitationResponse, type AdminAuthResponse, type AdminBucket, type AdminListBucketsResponse, type AdminListObjectsResponse, type AdminLoginRequest, type AdminMeResponse, type AdminRefreshRequest, type AdminRefreshResponse, type AdminSetupRequest, type AdminSetupStatusResponse, type AdminStorageObject, type AdminUser, type AppSettings, AppSettingsManager, type ApplyMigrationRequest, type ApplyPendingRequest, type AuthConfig, type AuthResponse, type AuthResponseData, type AuthSession, type AuthSettings, AuthSettingsManager, type AuthenticationSettings, type Branch, type BranchActivity, type BranchPoolStats, type BranchStatus, type BranchType, type BroadcastCallback, type BroadcastMessage, type BundleOptions, type BundleResult, type CaptchaConfig, type CaptchaProvider, type ChatbotSpec, type ChunkedUploadSession, type ClientKey, ClientKeysManager, type Column, type CreateAIProviderRequest, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateBranchOptions, type CreateClientKeyRequest, type CreateClientKeyResponse, type CreateColumnRequest, type CreateFunctionRequest, type CreateInvitationRequest, type CreateInvitationResponse, type CreateMigrationRequest, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateUserSettingRequest, type CreateWebhookRequest, DDLManager, type DataCloneMode, type DataResponse, type DeleteAPIKeyResponse, type DeleteClientKeyResponse, type DeleteOAuthProviderResponse, type DeleteTableResponse, type DeleteUserResponse, type DeleteWebhookResponse, type DownloadOptions, type DownloadProgress, type EdgeFunction, type EdgeFunctionExecution, type EmailProviderSettings, type EmailSettingOverride, type EmailSettings, EmailSettingsManager, type EmailTemplate, EmailTemplateManager, type EmailTemplateType, type EmbedRequest, type EmbedResponse, type EnableRealtimeRequest, type EnableRealtimeResponse, type EnrichedUser, type ExecutionLog, type ExecutionLogCallback, type ExecutionLogConfig, type ExecutionLogEvent, type ExecutionLogLevel, ExecutionLogsChannel, type ExecutionType, type FeatureSettings, type FileObject, type FilterOperator, FluxbaseAI, FluxbaseAIChat, FluxbaseAdmin, FluxbaseAdminAI, FluxbaseAdminFunctions, FluxbaseAdminJobs, FluxbaseAdminMigrations, FluxbaseAdminRPC, FluxbaseAdminRealtime, FluxbaseAdminStorage, FluxbaseAuth, type FluxbaseAuthResponse, FluxbaseBranching, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseGraphQL, FluxbaseJobs, FluxbaseManagement, FluxbaseOAuth, FluxbaseRPC, FluxbaseRealtime, type FluxbaseResponse, FluxbaseSettings, FluxbaseStorage, FluxbaseVector, type FunctionInvokeOptions, type FunctionSpec, type GetImpersonationResponse, type GraphQLError, type GraphQLErrorLocation, type GraphQLRequestOptions, type GraphQLResponse, type HealthResponse, type HttpMethod, type ImageFitMode, type ImageFormat, type ImpersonateAnonRequest, type ImpersonateServiceRequest, type ImpersonateUserRequest, ImpersonationManager, type ImpersonationSession, type ImpersonationTargetUser, type ImpersonationType, type IntrospectionDirective, type IntrospectionEnumValue, type IntrospectionField, type IntrospectionInputValue, type IntrospectionSchema, type IntrospectionType, type IntrospectionTypeRef, type Invitation, InvitationsManager, type InviteUserRequest, type InviteUserResponse, type ListAPIKeysResponse, type ListBranchesOptions, type ListBranchesResponse, type ListClientKeysResponse, type ListConversationsOptions, type ListConversationsResult, type ListEmailTemplatesResponse, type ListImpersonationSessionsOptions, type ListImpersonationSessionsResponse, type ListInvitationsOptions, type ListInvitationsResponse, type ListOAuthProvidersResponse, type ListOptions, type ListRealtimeTablesResponse, type ListSchemasResponse, type ListSystemSettingsResponse, type ListTablesResponse, type ListUsersOptions, type ListUsersResponse, type ListWebhookDeliveriesResponse, type ListWebhooksResponse, type MailgunSettings, type Migration, type MigrationExecution, type OAuthLogoutOptions, type OAuthLogoutResponse, type OAuthProvider, OAuthProviderManager, type OAuthProviderPublic, type OrderBy, type OrderDirection, type PostgresChangesConfig, type PostgrestError, type PostgrestResponse, type PresenceCallback, type PresenceState, QueryBuilder, type QueryFilter, type RPCExecution, type RPCExecutionFilters, type RPCExecutionLog, type RPCExecutionStatus, type RPCInvokeResponse, type RPCProcedure, type RPCProcedureSpec, type RPCProcedureSummary, type RealtimeBroadcastPayload, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeChannelConfig, type RealtimeMessage, type RealtimePostgresChangesPayload, type RealtimePresencePayload, type RealtimeTableStatus, type RequestOptions, type ResetUserPasswordResponse, type ResumableDownloadData, type ResumableDownloadOptions, type ResumableUploadOptions, type ResumableUploadProgress, type RevokeAPIKeyResponse, type RevokeClientKeyResponse, type RevokeInvitationResponse, type RollbackMigrationRequest, type SAMLLoginOptions, type SAMLLoginResponse, type SAMLProvider, type SAMLProvidersResponse, type SAMLSession, type SESSettings, type SMTPSettings, type Schema, SchemaQueryBuilder, type SecuritySettings, type SendEmailRequest, type SendGridSettings, type SessionResponse, SettingsClient, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type SignedUrlResponse, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, type StreamDownloadData, type StreamUploadOptions, type SupabaseAuthResponse, type SupabaseResponse, type SyncChatbotsOptions, type SyncChatbotsResult, type SyncError, type SyncFunctionsOptions, type SyncFunctionsResult, type SyncMigrationsOptions, type SyncMigrationsResult, type SyncRPCOptions, type SyncRPCResult, type SystemSetting, SystemSettingsManager, type Table, type TestEmailSettingsResponse, type TestEmailTemplateRequest, type TestWebhookResponse, type TransformOptions, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAIProviderRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateClientKeyRequest, type UpdateConversationOptions, type UpdateEmailProviderSettingsRequest, type UpdateEmailTemplateRequest, type UpdateFunctionRequest, type UpdateMigrationRequest, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateRPCProcedureRequest, type UpdateRealtimeConfigRequest, type UpdateSystemSettingRequest, type UpdateUserAttributes, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type UploadProgress, type UpsertOptions, type User, type UserResponse, type UserSetting, type UserSettingWithSource, type ValidateInvitationResponse, type VectorMetric, type VectorOrderOptions, type VectorSearchOptions, type VectorSearchResult, type VoidResponse, type WeakPassword, type Webhook, type WebhookDelivery, WebhooksManager, assertType, bundleCode, createClient, denoExternalPlugin, hasPostgrestError, isArray, isAuthError, isAuthSuccess, isBoolean, isFluxbaseError, isFluxbaseSuccess, isNumber, isObject, isPostgrestSuccess, isString, loadImportMap };
package/dist/index.d.ts CHANGED
@@ -2373,6 +2373,19 @@ interface SyncChatbotsResult {
2373
2373
  errors: SyncError[];
2374
2374
  dry_run: boolean;
2375
2375
  }
2376
+ /**
2377
+ * Response from chatbot lookup by name (smart namespace resolution)
2378
+ */
2379
+ interface AIChatbotLookupResponse {
2380
+ /** The chatbot if found (unique or resolved from default namespace) */
2381
+ chatbot?: AIChatbotSummary;
2382
+ /** True if multiple chatbots with this name exist in different namespaces */
2383
+ ambiguous: boolean;
2384
+ /** List of namespaces where the chatbot exists (when ambiguous) */
2385
+ namespaces?: string[];
2386
+ /** Error message if lookup failed */
2387
+ error?: string;
2388
+ }
2376
2389
  /**
2377
2390
  * AI chat message role
2378
2391
  */
@@ -9928,6 +9941,11 @@ interface AIChatOptions {
9928
9941
  reconnectAttempts?: number;
9929
9942
  /** Reconnect delay in ms */
9930
9943
  reconnectDelay?: number;
9944
+ /** @internal Lookup function for smart namespace resolution */
9945
+ _lookupChatbot?: (name: string) => Promise<{
9946
+ data: AIChatbotLookupResponse | null;
9947
+ error: Error | null;
9948
+ }>;
9931
9949
  }
9932
9950
  /**
9933
9951
  * AI Chat client for WebSocket-based chat with AI chatbots
@@ -9986,7 +10004,12 @@ declare class FluxbaseAIChat {
9986
10004
  * Start a new chat session with a chatbot
9987
10005
  *
9988
10006
  * @param chatbot - Chatbot name
9989
- * @param namespace - Optional namespace (defaults to 'default')
10007
+ * @param namespace - Optional namespace. If not provided and a lookup function is available,
10008
+ * performs smart resolution:
10009
+ * - If exactly one chatbot with this name exists, uses it
10010
+ * - If multiple exist, tries "default" namespace
10011
+ * - If ambiguous and not in default, throws error with available namespaces
10012
+ * If no lookup function, falls back to "default" namespace.
9990
10013
  * @param conversationId - Optional conversation ID to resume
9991
10014
  * @param impersonateUserId - Optional user ID to impersonate (admin only)
9992
10015
  * @returns Promise resolving to conversation ID
@@ -10066,13 +10089,39 @@ declare class FluxbaseAI {
10066
10089
  data: AIChatbotSummary | null;
10067
10090
  error: Error | null;
10068
10091
  }>;
10092
+ /**
10093
+ * Lookup a chatbot by name with smart namespace resolution
10094
+ *
10095
+ * Resolution logic:
10096
+ * 1. If exactly one chatbot with this name exists -> returns it
10097
+ * 2. If multiple exist -> tries "default" namespace first
10098
+ * 3. If multiple exist and none in "default" -> returns ambiguous=true with namespaces list
10099
+ *
10100
+ * @param name - Chatbot name
10101
+ * @returns Promise resolving to { data, error } tuple with lookup result
10102
+ *
10103
+ * @example
10104
+ * ```typescript
10105
+ * // Lookup chatbot by name
10106
+ * const { data, error } = await ai.lookupChatbot('sql-assistant')
10107
+ * if (data?.chatbot) {
10108
+ * console.log(`Found in namespace: ${data.chatbot.namespace}`)
10109
+ * } else if (data?.ambiguous) {
10110
+ * console.log(`Chatbot exists in: ${data.namespaces?.join(', ')}`)
10111
+ * }
10112
+ * ```
10113
+ */
10114
+ lookupChatbot(name: string): Promise<{
10115
+ data: AIChatbotLookupResponse | null;
10116
+ error: Error | null;
10117
+ }>;
10069
10118
  /**
10070
10119
  * Create a new AI chat connection
10071
10120
  *
10072
10121
  * @param options - Chat connection options
10073
10122
  * @returns FluxbaseAIChat instance
10074
10123
  */
10075
- createChat(options: Omit<AIChatOptions, "wsUrl">): FluxbaseAIChat;
10124
+ createChat(options: Omit<AIChatOptions, "wsUrl" | "_lookupChatbot">): FluxbaseAIChat;
10076
10125
  /**
10077
10126
  * List the authenticated user's conversations
10078
10127
  *
@@ -11908,4 +11957,4 @@ declare function isBoolean(value: unknown): value is boolean;
11908
11957
  */
11909
11958
  declare function assertType<T>(value: unknown, validator: (v: unknown) => v is T, errorMessage?: string): asserts value is T;
11910
11959
 
11911
- export { type AIChatClientMessage, type AIChatEvent, type AIChatEventType, type AIChatMessageRole, type AIChatOptions, type AIChatServerMessage, type AIChatbot, type AIChatbotSummary, type AIConversation, type AIConversationMessage, type AIProvider, type AIProviderType, type AIUsageStats, type AIUserConversationDetail, type AIUserConversationSummary, type AIUserMessage, type AIUserQueryResult, type AIUserUsageStats, type APIKey, APIKeysManager, type AcceptInvitationRequest, type AcceptInvitationResponse, type AdminAuthResponse, type AdminBucket, type AdminListBucketsResponse, type AdminListObjectsResponse, type AdminLoginRequest, type AdminMeResponse, type AdminRefreshRequest, type AdminRefreshResponse, type AdminSetupRequest, type AdminSetupStatusResponse, type AdminStorageObject, type AdminUser, type AppSettings, AppSettingsManager, type ApplyMigrationRequest, type ApplyPendingRequest, type AuthConfig, type AuthResponse, type AuthResponseData, type AuthSession, type AuthSettings, AuthSettingsManager, type AuthenticationSettings, type Branch, type BranchActivity, type BranchPoolStats, type BranchStatus, type BranchType, type BroadcastCallback, type BroadcastMessage, type BundleOptions, type BundleResult, type CaptchaConfig, type CaptchaProvider, type ChatbotSpec, type ChunkedUploadSession, type ClientKey, ClientKeysManager, type Column, type CreateAIProviderRequest, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateBranchOptions, type CreateClientKeyRequest, type CreateClientKeyResponse, type CreateColumnRequest, type CreateFunctionRequest, type CreateInvitationRequest, type CreateInvitationResponse, type CreateMigrationRequest, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateUserSettingRequest, type CreateWebhookRequest, DDLManager, type DataCloneMode, type DataResponse, type DeleteAPIKeyResponse, type DeleteClientKeyResponse, type DeleteOAuthProviderResponse, type DeleteTableResponse, type DeleteUserResponse, type DeleteWebhookResponse, type DownloadOptions, type DownloadProgress, type EdgeFunction, type EdgeFunctionExecution, type EmailProviderSettings, type EmailSettingOverride, type EmailSettings, EmailSettingsManager, type EmailTemplate, EmailTemplateManager, type EmailTemplateType, type EmbedRequest, type EmbedResponse, type EnableRealtimeRequest, type EnableRealtimeResponse, type EnrichedUser, type ExecutionLog, type ExecutionLogCallback, type ExecutionLogConfig, type ExecutionLogEvent, type ExecutionLogLevel, ExecutionLogsChannel, type ExecutionType, type FeatureSettings, type FileObject, type FilterOperator, FluxbaseAI, FluxbaseAIChat, FluxbaseAdmin, FluxbaseAdminAI, FluxbaseAdminFunctions, FluxbaseAdminJobs, FluxbaseAdminMigrations, FluxbaseAdminRPC, FluxbaseAdminRealtime, FluxbaseAdminStorage, FluxbaseAuth, type FluxbaseAuthResponse, FluxbaseBranching, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseGraphQL, FluxbaseJobs, FluxbaseManagement, FluxbaseOAuth, FluxbaseRPC, FluxbaseRealtime, type FluxbaseResponse, FluxbaseSettings, FluxbaseStorage, FluxbaseVector, type FunctionInvokeOptions, type FunctionSpec, type GetImpersonationResponse, type GraphQLError, type GraphQLErrorLocation, type GraphQLRequestOptions, type GraphQLResponse, type HealthResponse, type HttpMethod, type ImageFitMode, type ImageFormat, type ImpersonateAnonRequest, type ImpersonateServiceRequest, type ImpersonateUserRequest, ImpersonationManager, type ImpersonationSession, type ImpersonationTargetUser, type ImpersonationType, type IntrospectionDirective, type IntrospectionEnumValue, type IntrospectionField, type IntrospectionInputValue, type IntrospectionSchema, type IntrospectionType, type IntrospectionTypeRef, type Invitation, InvitationsManager, type InviteUserRequest, type InviteUserResponse, type ListAPIKeysResponse, type ListBranchesOptions, type ListBranchesResponse, type ListClientKeysResponse, type ListConversationsOptions, type ListConversationsResult, type ListEmailTemplatesResponse, type ListImpersonationSessionsOptions, type ListImpersonationSessionsResponse, type ListInvitationsOptions, type ListInvitationsResponse, type ListOAuthProvidersResponse, type ListOptions, type ListRealtimeTablesResponse, type ListSchemasResponse, type ListSystemSettingsResponse, type ListTablesResponse, type ListUsersOptions, type ListUsersResponse, type ListWebhookDeliveriesResponse, type ListWebhooksResponse, type MailgunSettings, type Migration, type MigrationExecution, type OAuthLogoutOptions, type OAuthLogoutResponse, type OAuthProvider, OAuthProviderManager, type OAuthProviderPublic, type OrderBy, type OrderDirection, type PostgresChangesConfig, type PostgrestError, type PostgrestResponse, type PresenceCallback, type PresenceState, QueryBuilder, type QueryFilter, type RPCExecution, type RPCExecutionFilters, type RPCExecutionLog, type RPCExecutionStatus, type RPCInvokeResponse, type RPCProcedure, type RPCProcedureSpec, type RPCProcedureSummary, type RealtimeBroadcastPayload, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeChannelConfig, type RealtimeMessage, type RealtimePostgresChangesPayload, type RealtimePresencePayload, type RealtimeTableStatus, type RequestOptions, type ResetUserPasswordResponse, type ResumableDownloadData, type ResumableDownloadOptions, type ResumableUploadOptions, type ResumableUploadProgress, type RevokeAPIKeyResponse, type RevokeClientKeyResponse, type RevokeInvitationResponse, type RollbackMigrationRequest, type SAMLLoginOptions, type SAMLLoginResponse, type SAMLProvider, type SAMLProvidersResponse, type SAMLSession, type SESSettings, type SMTPSettings, type Schema, SchemaQueryBuilder, type SecuritySettings, type SendEmailRequest, type SendGridSettings, type SessionResponse, SettingsClient, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type SignedUrlResponse, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, type StreamDownloadData, type StreamUploadOptions, type SupabaseAuthResponse, type SupabaseResponse, type SyncChatbotsOptions, type SyncChatbotsResult, type SyncError, type SyncFunctionsOptions, type SyncFunctionsResult, type SyncMigrationsOptions, type SyncMigrationsResult, type SyncRPCOptions, type SyncRPCResult, type SystemSetting, SystemSettingsManager, type Table, type TestEmailSettingsResponse, type TestEmailTemplateRequest, type TestWebhookResponse, type TransformOptions, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAIProviderRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateClientKeyRequest, type UpdateConversationOptions, type UpdateEmailProviderSettingsRequest, type UpdateEmailTemplateRequest, type UpdateFunctionRequest, type UpdateMigrationRequest, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateRPCProcedureRequest, type UpdateRealtimeConfigRequest, type UpdateSystemSettingRequest, type UpdateUserAttributes, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type UploadProgress, type UpsertOptions, type User, type UserResponse, type UserSetting, type UserSettingWithSource, type ValidateInvitationResponse, type VectorMetric, type VectorOrderOptions, type VectorSearchOptions, type VectorSearchResult, type VoidResponse, type WeakPassword, type Webhook, type WebhookDelivery, WebhooksManager, assertType, bundleCode, createClient, denoExternalPlugin, hasPostgrestError, isArray, isAuthError, isAuthSuccess, isBoolean, isFluxbaseError, isFluxbaseSuccess, isNumber, isObject, isPostgrestSuccess, isString, loadImportMap };
11960
+ export { type AIChatClientMessage, type AIChatEvent, type AIChatEventType, type AIChatMessageRole, type AIChatOptions, type AIChatServerMessage, type AIChatbot, type AIChatbotLookupResponse, type AIChatbotSummary, type AIConversation, type AIConversationMessage, type AIProvider, type AIProviderType, type AIUsageStats, type AIUserConversationDetail, type AIUserConversationSummary, type AIUserMessage, type AIUserQueryResult, type AIUserUsageStats, type APIKey, APIKeysManager, type AcceptInvitationRequest, type AcceptInvitationResponse, type AdminAuthResponse, type AdminBucket, type AdminListBucketsResponse, type AdminListObjectsResponse, type AdminLoginRequest, type AdminMeResponse, type AdminRefreshRequest, type AdminRefreshResponse, type AdminSetupRequest, type AdminSetupStatusResponse, type AdminStorageObject, type AdminUser, type AppSettings, AppSettingsManager, type ApplyMigrationRequest, type ApplyPendingRequest, type AuthConfig, type AuthResponse, type AuthResponseData, type AuthSession, type AuthSettings, AuthSettingsManager, type AuthenticationSettings, type Branch, type BranchActivity, type BranchPoolStats, type BranchStatus, type BranchType, type BroadcastCallback, type BroadcastMessage, type BundleOptions, type BundleResult, type CaptchaConfig, type CaptchaProvider, type ChatbotSpec, type ChunkedUploadSession, type ClientKey, ClientKeysManager, type Column, type CreateAIProviderRequest, type CreateAPIKeyRequest, type CreateAPIKeyResponse, type CreateBranchOptions, type CreateClientKeyRequest, type CreateClientKeyResponse, type CreateColumnRequest, type CreateFunctionRequest, type CreateInvitationRequest, type CreateInvitationResponse, type CreateMigrationRequest, type CreateOAuthProviderRequest, type CreateOAuthProviderResponse, type CreateSchemaRequest, type CreateSchemaResponse, type CreateTableRequest, type CreateTableResponse, type CreateUserSettingRequest, type CreateWebhookRequest, DDLManager, type DataCloneMode, type DataResponse, type DeleteAPIKeyResponse, type DeleteClientKeyResponse, type DeleteOAuthProviderResponse, type DeleteTableResponse, type DeleteUserResponse, type DeleteWebhookResponse, type DownloadOptions, type DownloadProgress, type EdgeFunction, type EdgeFunctionExecution, type EmailProviderSettings, type EmailSettingOverride, type EmailSettings, EmailSettingsManager, type EmailTemplate, EmailTemplateManager, type EmailTemplateType, type EmbedRequest, type EmbedResponse, type EnableRealtimeRequest, type EnableRealtimeResponse, type EnrichedUser, type ExecutionLog, type ExecutionLogCallback, type ExecutionLogConfig, type ExecutionLogEvent, type ExecutionLogLevel, ExecutionLogsChannel, type ExecutionType, type FeatureSettings, type FileObject, type FilterOperator, FluxbaseAI, FluxbaseAIChat, FluxbaseAdmin, FluxbaseAdminAI, FluxbaseAdminFunctions, FluxbaseAdminJobs, FluxbaseAdminMigrations, FluxbaseAdminRPC, FluxbaseAdminRealtime, FluxbaseAdminStorage, FluxbaseAuth, type FluxbaseAuthResponse, FluxbaseBranching, FluxbaseClient, type FluxbaseClientOptions, type FluxbaseError, FluxbaseFetch, FluxbaseFunctions, FluxbaseGraphQL, FluxbaseJobs, FluxbaseManagement, FluxbaseOAuth, FluxbaseRPC, FluxbaseRealtime, type FluxbaseResponse, FluxbaseSettings, FluxbaseStorage, FluxbaseVector, type FunctionInvokeOptions, type FunctionSpec, type GetImpersonationResponse, type GraphQLError, type GraphQLErrorLocation, type GraphQLRequestOptions, type GraphQLResponse, type HealthResponse, type HttpMethod, type ImageFitMode, type ImageFormat, type ImpersonateAnonRequest, type ImpersonateServiceRequest, type ImpersonateUserRequest, ImpersonationManager, type ImpersonationSession, type ImpersonationTargetUser, type ImpersonationType, type IntrospectionDirective, type IntrospectionEnumValue, type IntrospectionField, type IntrospectionInputValue, type IntrospectionSchema, type IntrospectionType, type IntrospectionTypeRef, type Invitation, InvitationsManager, type InviteUserRequest, type InviteUserResponse, type ListAPIKeysResponse, type ListBranchesOptions, type ListBranchesResponse, type ListClientKeysResponse, type ListConversationsOptions, type ListConversationsResult, type ListEmailTemplatesResponse, type ListImpersonationSessionsOptions, type ListImpersonationSessionsResponse, type ListInvitationsOptions, type ListInvitationsResponse, type ListOAuthProvidersResponse, type ListOptions, type ListRealtimeTablesResponse, type ListSchemasResponse, type ListSystemSettingsResponse, type ListTablesResponse, type ListUsersOptions, type ListUsersResponse, type ListWebhookDeliveriesResponse, type ListWebhooksResponse, type MailgunSettings, type Migration, type MigrationExecution, type OAuthLogoutOptions, type OAuthLogoutResponse, type OAuthProvider, OAuthProviderManager, type OAuthProviderPublic, type OrderBy, type OrderDirection, type PostgresChangesConfig, type PostgrestError, type PostgrestResponse, type PresenceCallback, type PresenceState, QueryBuilder, type QueryFilter, type RPCExecution, type RPCExecutionFilters, type RPCExecutionLog, type RPCExecutionStatus, type RPCInvokeResponse, type RPCProcedure, type RPCProcedureSpec, type RPCProcedureSummary, type RealtimeBroadcastPayload, type RealtimeCallback, type RealtimeChangePayload, RealtimeChannel, type RealtimeChannelConfig, type RealtimeMessage, type RealtimePostgresChangesPayload, type RealtimePresencePayload, type RealtimeTableStatus, type RequestOptions, type ResetUserPasswordResponse, type ResumableDownloadData, type ResumableDownloadOptions, type ResumableUploadOptions, type ResumableUploadProgress, type RevokeAPIKeyResponse, type RevokeClientKeyResponse, type RevokeInvitationResponse, type RollbackMigrationRequest, type SAMLLoginOptions, type SAMLLoginResponse, type SAMLProvider, type SAMLProvidersResponse, type SAMLSession, type SESSettings, type SMTPSettings, type Schema, SchemaQueryBuilder, type SecuritySettings, type SendEmailRequest, type SendGridSettings, type SessionResponse, SettingsClient, type SignInCredentials, type SignInWith2FAResponse, type SignUpCredentials, type SignedUrlOptions, type SignedUrlResponse, type StartImpersonationResponse, type StopImpersonationResponse, StorageBucket, type StorageObject, type StreamDownloadData, type StreamUploadOptions, type SupabaseAuthResponse, type SupabaseResponse, type SyncChatbotsOptions, type SyncChatbotsResult, type SyncError, type SyncFunctionsOptions, type SyncFunctionsResult, type SyncMigrationsOptions, type SyncMigrationsResult, type SyncRPCOptions, type SyncRPCResult, type SystemSetting, SystemSettingsManager, type Table, type TestEmailSettingsResponse, type TestEmailTemplateRequest, type TestWebhookResponse, type TransformOptions, type TwoFactorEnableResponse, type TwoFactorSetupResponse, type TwoFactorStatusResponse, type TwoFactorVerifyRequest, type UpdateAIProviderRequest, type UpdateAPIKeyRequest, type UpdateAppSettingsRequest, type UpdateAuthSettingsRequest, type UpdateAuthSettingsResponse, type UpdateClientKeyRequest, type UpdateConversationOptions, type UpdateEmailProviderSettingsRequest, type UpdateEmailTemplateRequest, type UpdateFunctionRequest, type UpdateMigrationRequest, type UpdateOAuthProviderRequest, type UpdateOAuthProviderResponse, type UpdateRPCProcedureRequest, type UpdateRealtimeConfigRequest, type UpdateSystemSettingRequest, type UpdateUserAttributes, type UpdateUserRoleRequest, type UpdateWebhookRequest, type UploadOptions, type UploadProgress, type UpsertOptions, type User, type UserResponse, type UserSetting, type UserSettingWithSource, type ValidateInvitationResponse, type VectorMetric, type VectorOrderOptions, type VectorSearchOptions, type VectorSearchResult, type VoidResponse, type WeakPassword, type Webhook, type WebhookDelivery, WebhooksManager, assertType, bundleCode, createClient, denoExternalPlugin, hasPostgrestError, isArray, isAuthError, isAuthSuccess, isBoolean, isFluxbaseError, isFluxbaseSuccess, isNumber, isObject, isPostgrestSuccess, isString, loadImportMap };
package/dist/index.js CHANGED
@@ -9600,23 +9600,50 @@ var FluxbaseAIChat = class {
9600
9600
  * Start a new chat session with a chatbot
9601
9601
  *
9602
9602
  * @param chatbot - Chatbot name
9603
- * @param namespace - Optional namespace (defaults to 'default')
9603
+ * @param namespace - Optional namespace. If not provided and a lookup function is available,
9604
+ * performs smart resolution:
9605
+ * - If exactly one chatbot with this name exists, uses it
9606
+ * - If multiple exist, tries "default" namespace
9607
+ * - If ambiguous and not in default, throws error with available namespaces
9608
+ * If no lookup function, falls back to "default" namespace.
9604
9609
  * @param conversationId - Optional conversation ID to resume
9605
9610
  * @param impersonateUserId - Optional user ID to impersonate (admin only)
9606
9611
  * @returns Promise resolving to conversation ID
9607
9612
  */
9608
9613
  async startChat(chatbot, namespace, conversationId, impersonateUserId) {
9609
- return new Promise((resolve, reject) => {
9610
- if (!this.isConnected()) {
9611
- reject(new Error("Not connected to AI chat"));
9612
- return;
9614
+ if (!this.isConnected()) {
9615
+ throw new Error("Not connected to AI chat");
9616
+ }
9617
+ let resolvedNamespace = namespace;
9618
+ if (!resolvedNamespace && this.options._lookupChatbot) {
9619
+ const { data, error } = await this.options._lookupChatbot(chatbot);
9620
+ if (error) {
9621
+ throw new Error(`Failed to lookup chatbot: ${error.message}`);
9622
+ }
9623
+ if (!data) {
9624
+ throw new Error(`Chatbot '${chatbot}' not found`);
9625
+ }
9626
+ if (data.ambiguous) {
9627
+ throw new Error(
9628
+ `Chatbot '${chatbot}' exists in multiple namespaces: ${data.namespaces?.join(", ")}. Please specify the namespace explicitly.`
9629
+ );
9613
9630
  }
9631
+ if (data.chatbot) {
9632
+ resolvedNamespace = data.chatbot.namespace;
9633
+ } else if (data.error) {
9634
+ throw new Error(data.error);
9635
+ }
9636
+ }
9637
+ if (!resolvedNamespace) {
9638
+ resolvedNamespace = "default";
9639
+ }
9640
+ return new Promise((resolve, reject) => {
9614
9641
  this.pendingStartResolve = resolve;
9615
9642
  this.pendingStartReject = reject;
9616
9643
  const message = {
9617
9644
  type: "start_chat",
9618
9645
  chatbot,
9619
- namespace: namespace || "default",
9646
+ namespace: resolvedNamespace,
9620
9647
  conversation_id: conversationId,
9621
9648
  impersonate_user_id: impersonateUserId
9622
9649
  };
@@ -9688,13 +9715,20 @@ var FluxbaseAIChat = class {
9688
9715
  case "content":
9689
9716
  if (message.conversation_id && message.delta) {
9690
9717
  const current = this.accumulatedContent.get(message.conversation_id) || "";
9691
- this.accumulatedContent.set(message.conversation_id, current + message.delta);
9718
+ this.accumulatedContent.set(
9719
+ message.conversation_id,
9720
+ current + message.delta
9721
+ );
9692
9722
  this.options.onContent?.(message.delta, message.conversation_id);
9693
9723
  }
9694
9724
  break;
9695
9725
  case "progress":
9696
9726
  if (message.step && message.message && message.conversation_id) {
9697
- this.options.onProgress?.(message.step, message.message, message.conversation_id);
9727
+ this.options.onProgress?.(
9728
+ message.step,
9729
+ message.message,
9730
+ message.conversation_id
9731
+ );
9698
9732
  }
9699
9733
  break;
9700
9734
  case "query_result":
@@ -9715,11 +9749,17 @@ var FluxbaseAIChat = class {
9715
9749
  break;
9716
9750
  case "error":
9717
9751
  if (this.pendingStartReject) {
9718
- this.pendingStartReject(new Error(message.error || "Unknown error"));
9752
+ this.pendingStartReject(
9753
+ new Error(message.error || "Unknown error")
9754
+ );
9719
9755
  this.pendingStartResolve = null;
9720
9756
  this.pendingStartReject = null;
9721
9757
  }
9722
- this.options.onError?.(message.error || "Unknown error", message.code, message.conversation_id);
9758
+ this.options.onError?.(
9759
+ message.error || "Unknown error",
9760
+ message.code,
9761
+ message.conversation_id
9762
+ );
9723
9763
  break;
9724
9764
  }
9725
9765
  this.emitEvent(event);
@@ -9769,9 +9809,7 @@ var FluxbaseAI = class {
9769
9809
  */
9770
9810
  async listChatbots() {
9771
9811
  try {
9772
- const response = await this.fetch.get(
9773
- "/api/v1/ai/chatbots"
9774
- );
9812
+ const response = await this.fetch.get("/api/v1/ai/chatbots");
9775
9813
  return { data: response.chatbots || [], error: null };
9776
9814
  } catch (error) {
9777
9815
  return { data: null, error };
@@ -9785,7 +9823,41 @@ var FluxbaseAI = class {
9785
9823
  */
9786
9824
  async getChatbot(id) {
9787
9825
  try {
9788
- const data = await this.fetch.get(`/api/v1/ai/chatbots/${id}`);
9826
+ const data = await this.fetch.get(
9827
+ `/api/v1/ai/chatbots/${id}`
9828
+ );
9829
+ return { data, error: null };
9830
+ } catch (error) {
9831
+ return { data: null, error };
9832
+ }
9833
+ }
9834
+ /**
9835
+ * Lookup a chatbot by name with smart namespace resolution
9836
+ *
9837
+ * Resolution logic:
9838
+ * 1. If exactly one chatbot with this name exists -> returns it
9839
+ * 2. If multiple exist -> tries "default" namespace first
9840
+ * 3. If multiple exist and none in "default" -> returns ambiguous=true with namespaces list
9841
+ *
9842
+ * @param name - Chatbot name
9843
+ * @returns Promise resolving to { data, error } tuple with lookup result
9844
+ *
9845
+ * @example
9846
+ * ```typescript
9847
+ * // Lookup chatbot by name
9848
+ * const { data, error } = await ai.lookupChatbot('sql-assistant')
9849
+ * if (data?.chatbot) {
9850
+ * console.log(`Found in namespace: ${data.chatbot.namespace}`)
9851
+ * } else if (data?.ambiguous) {
9852
+ * console.log(`Chatbot exists in: ${data.namespaces?.join(', ')}`)
9853
+ * }
9854
+ * ```
9855
+ */
9856
+ async lookupChatbot(name) {
9857
+ try {
9858
+ const data = await this.fetch.get(
9859
+ `/api/v1/ai/chatbots/by-name/${encodeURIComponent(name)}`
9860
+ );
9789
9861
  return { data, error: null };
9790
9862
  } catch (error) {
9791
9863
  return { data: null, error };
@@ -9800,7 +9872,8 @@ var FluxbaseAI = class {
9800
9872
  createChat(options) {
9801
9873
  return new FluxbaseAIChat({
9802
9874
  ...options,
9803
- wsUrl: `${this.wsBaseUrl}/ai/ws`
9875
+ wsUrl: `${this.wsBaseUrl}/ai/ws`,
9876
+ _lookupChatbot: (name) => this.lookupChatbot(name)
9804
9877
  });
9805
9878
  }
9806
9879
  /**
@@ -9826,8 +9899,10 @@ var FluxbaseAI = class {
9826
9899
  const params = new URLSearchParams();
9827
9900
  if (options?.chatbot) params.set("chatbot", options.chatbot);
9828
9901
  if (options?.namespace) params.set("namespace", options.namespace);
9829
- if (options?.limit !== void 0) params.set("limit", String(options.limit));
9830
- if (options?.offset !== void 0) params.set("offset", String(options.offset));
9902
+ if (options?.limit !== void 0)
9903
+ params.set("limit", String(options.limit));
9904
+ if (options?.offset !== void 0)
9905
+ params.set("offset", String(options.offset));
9831
9906
  const queryString = params.toString();
9832
9907
  const path = `/api/v1/ai/conversations${queryString ? `?${queryString}` : ""}`;
9833
9908
  const response = await this.fetch.get(path);