@ragable/sdk 0.7.8 → 0.7.10

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.mts CHANGED
@@ -981,10 +981,53 @@ type StreamPart = {
981
981
  type: "error";
982
982
  error: unknown;
983
983
  };
984
- interface Message {
985
- role: "system" | "user" | "assistant";
986
- content: string;
984
+ /** Plain text segment inside a multimodal user message. */
985
+ interface TextPart {
986
+ type: "text";
987
+ text: string;
987
988
  }
989
+ /**
990
+ * Image segment inside a multimodal user message. Mirrors Vercel AI SDK's
991
+ * `ImagePart` shape — the discriminator is `"image"` and the data field is
992
+ * `image` (not `image_url`). The SDK converts to the OpenAI `image_url`
993
+ * wire format internally.
994
+ */
995
+ interface ImagePart {
996
+ type: "image";
997
+ /**
998
+ * Accepted forms:
999
+ * - HTTP(S) URL string (`"https://…"`) — passed through; the provider fetches it.
1000
+ * - Data URL string (`"data:image/png;base64,…"`) — passed through.
1001
+ * - Raw base64 string (no `data:` prefix) — `mediaType` then required.
1002
+ * - `Uint8Array` / `ArrayBuffer` — base64-encoded; `mediaType` required.
1003
+ * - `URL` instance — `href` is passed through.
1004
+ */
1005
+ image: string | Uint8Array | ArrayBuffer | URL;
1006
+ /** IANA media type, e.g. `"image/png"`. Required when `image` is binary or a raw base64 string. */
1007
+ mediaType?: string;
1008
+ /** OpenAI-compatible detail hint; forwarded as `image_url.detail`. */
1009
+ detail?: "auto" | "low" | "high";
1010
+ }
1011
+ /**
1012
+ * Content for a user message — either a plain string (back-compat with the
1013
+ * original text-only shape) or an array of text/image parts.
1014
+ */
1015
+ type UserContent = string | Array<TextPart | ImagePart>;
1016
+ /**
1017
+ * Chat message. `user` messages may carry multimodal content; `system` and
1018
+ * `assistant` are text-only (vision models consume images on user turns,
1019
+ * and image *output* isn't supported here).
1020
+ */
1021
+ type Message = {
1022
+ role: "system";
1023
+ content: string;
1024
+ } | {
1025
+ role: "user";
1026
+ content: UserContent;
1027
+ } | {
1028
+ role: "assistant";
1029
+ content: string;
1030
+ };
988
1031
  /**
989
1032
  * OpenAI/Fireworks SSE chunk shape, only the fields we actually consume.
990
1033
  * Kept as a local type so we don't depend on backend internals.
@@ -1794,6 +1837,99 @@ declare class RagableBrowserStorageClient {
1794
1837
  constructor(options: RagableBrowserClientOptions, fetchImpl: typeof fetch);
1795
1838
  from(bucketId: string): BrowserStorageBucketClient;
1796
1839
  }
1840
+ interface MailSendParams {
1841
+ to: string[];
1842
+ cc?: string[];
1843
+ bcc?: string[];
1844
+ subject: string;
1845
+ /** Plain-text body. At least one of `bodyText` / `bodyHtml` is required. */
1846
+ bodyText?: string;
1847
+ /** HTML body. If both are set, sent as multipart/alternative. */
1848
+ bodyHtml?: string;
1849
+ /** RFC 822 Message-ID of the message you're replying to (enables threading). */
1850
+ inReplyToMessageId?: string;
1851
+ /** Existing References header value, chained with In-Reply-To. */
1852
+ referencesHeader?: string;
1853
+ }
1854
+ interface MailSendResult {
1855
+ sentMailMessageId: string;
1856
+ gmailMessageId: string;
1857
+ gmailThreadId: string;
1858
+ fromAddress: string;
1859
+ }
1860
+ interface MailSearchParams {
1861
+ /** Gmail search syntax, e.g. `from:alice is:unread newer_than:7d`. */
1862
+ query?: string;
1863
+ /** 1–50; default 20. */
1864
+ maxResults?: number;
1865
+ pageToken?: string;
1866
+ labelIds?: string[];
1867
+ }
1868
+ interface MailMessagePreview {
1869
+ id: string;
1870
+ threadId: string;
1871
+ snippet: string;
1872
+ labelIds: string[];
1873
+ }
1874
+ interface MailMessageDetail {
1875
+ id: string;
1876
+ threadId: string;
1877
+ receivedAt: number;
1878
+ fromAddress: string;
1879
+ fromName: string | null;
1880
+ to: string[];
1881
+ cc: string[];
1882
+ subject: string;
1883
+ snippet: string;
1884
+ bodyText: string | null;
1885
+ bodyHtml: string | null;
1886
+ messageIdHeader: string | null;
1887
+ referencesHeader: string | null;
1888
+ labelIds: string[];
1889
+ }
1890
+ /**
1891
+ * Send and read email through the Gmail account linked to this Ragable
1892
+ * website (via the IDE Infrastructure → Integrations tab).
1893
+ *
1894
+ * All requests require a Bearer token — either an end-user JWT from this
1895
+ * website's auth group (call `client.auth.signIn(...)` first) or the
1896
+ * data-admin key (server-side use).
1897
+ *
1898
+ * The website MUST have:
1899
+ * 1. A Gmail account linked under Integrations
1900
+ * 2. An auth group linked under Auth
1901
+ *
1902
+ * Otherwise calls return a 412 with a clear error message.
1903
+ */
1904
+ declare class RagableBrowserMailClient {
1905
+ private readonly options;
1906
+ private readonly auth;
1907
+ private readonly fetchImpl;
1908
+ constructor(options: RagableBrowserClientOptions, auth: RagableAuth | null);
1909
+ private requireWebsiteId;
1910
+ private pathTo;
1911
+ /**
1912
+ * Get the Bearer token used to authenticate the call:
1913
+ * 1. End-user access token (preferred when an auth group is configured
1914
+ * and the user has signed in)
1915
+ * 2. `dataStaticKey` from createBrowserClient options
1916
+ * 3. Caller-supplied `getAccessToken()`
1917
+ *
1918
+ * If none is available, throws — server-side use should pass the
1919
+ * data-admin key as `dataStaticKey`.
1920
+ */
1921
+ private getBearerToken;
1922
+ private request;
1923
+ /** Send an email from this website's linked Gmail account. */
1924
+ send(params: MailSendParams): Promise<MailSendResult>;
1925
+ /** Search messages with Gmail query syntax. */
1926
+ search(params?: MailSearchParams): Promise<{
1927
+ messages: MailMessagePreview[];
1928
+ nextPageToken: string | null;
1929
+ }>;
1930
+ /** Fetch a single message in full (headers + decoded text/html body). */
1931
+ getMessage(messageId: string): Promise<MailMessageDetail>;
1932
+ }
1797
1933
  interface AgentConversationMessage {
1798
1934
  role: "user" | "assistant";
1799
1935
  content: string;
@@ -1933,6 +2069,7 @@ declare class RagableBrowser<Database extends RagableDatabase = DefaultRagableDa
1933
2069
  readonly database: RagableBrowserDatabaseClient<Database>;
1934
2070
  readonly db: RagableBrowserDatabaseClient<Database>;
1935
2071
  readonly storage: RagableBrowserStorageClient;
2072
+ readonly mail: RagableBrowserMailClient;
1936
2073
  readonly transport: Transport;
1937
2074
  private readonly _ragableAuth;
1938
2075
  constructor(options: RagableBrowserClientOptions);
@@ -1955,6 +2092,45 @@ declare function parseSseDataLine(line: string): SseJsonEvent | null;
1955
2092
  */
1956
2093
  declare function readSseStream(body: ReadableStream<Uint8Array>): AsyncGenerator<SseJsonEvent, void, undefined>;
1957
2094
 
2095
+ /**
2096
+ * Convert SDK-shape multimodal content to the OpenAI/Fireworks `image_url`
2097
+ * wire format the Ragable inference proxy expects. Keeps the public SDK
2098
+ * types Vercel-AI-SDK-shaped (`{ type: "image", image: ... }`) while the
2099
+ * over-the-wire shape stays OpenAI canonical.
2100
+ */
2101
+
2102
+ /** OpenAI/Fireworks image content part — what flows on the wire. */
2103
+ interface WireImagePart {
2104
+ type: "image_url";
2105
+ image_url: {
2106
+ url: string;
2107
+ detail?: "auto" | "low" | "high";
2108
+ };
2109
+ }
2110
+ type WireTextPart = {
2111
+ type: "text";
2112
+ text: string;
2113
+ };
2114
+ type WireContentPart = WireTextPart | WireImagePart;
2115
+ type WireUserContent = string | WireContentPart[];
2116
+ /**
2117
+ * Convert a single `UserContent` value to wire shape. Strings pass through
2118
+ * unchanged so existing callers keep producing byte-identical request bodies.
2119
+ */
2120
+ declare function toWireUserContent(content: UserContent): WireUserContent;
2121
+ /**
2122
+ * Resolve an `ImagePart.image` value into a URL string suitable for
2123
+ * `image_url.url`. URLs pass through; binary and raw base64 are wrapped
2124
+ * into a data URL.
2125
+ */
2126
+ declare function imagePartToUrl(part: ImagePart): string;
2127
+ /**
2128
+ * Cross-runtime `Uint8Array → base64`. `btoa(String.fromCharCode(...bytes))`
2129
+ * trips the JS call-stack limit on large payloads, so we chunk the binary
2130
+ * string. Works in browser, Node 18+, Edge, and Bun.
2131
+ */
2132
+ declare function bytesToBase64(bytes: Uint8Array): string;
2133
+
1958
2134
  /**
1959
2135
  * Best-effort parser for incomplete JSON streamed token-by-token from an LLM.
1960
2136
  *
@@ -1973,4 +2149,4 @@ declare function tryParsePartialJson(text: string): unknown | undefined;
1973
2149
 
1974
2150
  declare function createClient<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends object = DefaultAuthUser>(options: RagableBrowserClientOptions): RagableBrowser<Database, AuthUser>;
1975
2151
 
1976
- export { type AgentChatMessage, type AgentChatParams, type AgentChatStreamDonePayload, type AgentChatStreamHandlers, type AgentChatStreamResult, type AgentChatStreamUiHandlers, type AgentChatUiAssistantMessage, type AgentChatUiSegment, type AgentChatUiStreamResult, type AgentConversation, type AgentConversationMessage, type AgentConversationSubscription, type AgentPublicChatParams, type AgentStreamAgentInfoEvent, type AgentStreamEvent, AuthBroadcastChannel, type AuthBroadcastMessage, type AuthChangeEvent, type AuthOptions, type AuthSession, type AuthSignUpCredentials, type AuthUpdateUserAttributes, type AuthUserMetadata, type BrowserAuthSession, type BrowserAuthTokens, BrowserCollectionApi, type BrowserCollectionDefinition, type BrowserCollectionFactory, type BrowserCollectionFindParams, type BrowserCollectionRecord, type BrowserCollections, type BrowserDataAuthMode, type BrowserRealtimeNotification, type BrowserRealtimeStatus, type BrowserRealtimeSubscribeParams, type BrowserRealtimeSubscription, type BrowserSqlExecParams, type BrowserSqlExecResult, type BrowserSqlQueryParams, type BrowserSqlQueryResult, BrowserStorageBucketClient, type BrowserStorageBulkDeleteResult, type BrowserStorageDownloadResult, type BrowserStorageItem, type BrowserStorageListResult, type BrowserStorageSignedUrlResult, type BrowserStorageUploadResult, type CollectionReturnMode, type CollectionRowData, type CollectionRowWithMeta, type CollectionWhere, type ColumnName, type ColumnValue, CookieStorageAdapter, DEFAULT_RAGABLE_API_BASE, type DefaultAuthUser, type DefaultRagableDatabase, type FinishReason, type GenerateObjectResult, type GenerateTextResult, type HttpMethod, type Json, type JsonSchema, LocalStorageAdapter, MemoryStorageAdapter, type Message, type PostgRESTFetch, type PostgRESTFetchParams, PostgrestDeleteReturningBuilder, PostgrestDeleteRootBuilder, PostgrestInsertReturningBuilder, PostgrestInsertRootBuilder, PostgrestInsertSdkErrorReturning, PostgrestInsertSdkErrorRoot, type PostgrestResult, PostgrestSelectBuilder, PostgrestTableApi, PostgrestUpdateReturningBuilder, PostgrestUpdateRootBuilder, type PostgrestUpsertOptions, PostgrestUpsertReturningBuilder, PostgrestUpsertRootBuilder, RagableAbortError, RagableAuth, type RagableAuthConfig, RagableBrowser, RagableBrowserAgentsClient, RagableBrowserAiClient, RagableBrowserAuthClient, type RagableBrowserClientOptions, RagableBrowserDatabaseClient, RagableBrowserStorageClient, type RagableDatabase, RagableError, RagableNetworkError, type RagableResult, RagableSdkError, type RagableTableDefinition, type RagableTableNames, RagableTimeoutError, type RequestOptions, type RetryOptions, type RunAgentChatStreamOptions, type RunQuery, type SessionStorage, SessionStorageAdapter, type SseJsonEvent, type StreamObjectParams, type StreamObjectResult, type StreamPart, type StreamTextParams, type StreamTextResult, type SupabaseCompatSession, type TableInsertRow, type TableRow, type TableUpdatePatch, type Tables, type TablesInsert, type TablesUpdate, type TokenUsage, type ToolCallRecord, Transport, type TransportOptions, type TransportRequest, type WhereInput, type WhereOperatorObject, asPostgrestResponse, assertPostgrestSuccess, bindFetch, buildInferenceRequestBody, buildResponseFormat, collectAssistantTextFromUiSegments, collectionRecordToRowWithMeta, collectionRecordsToRowWithMeta, createBrowserClient, createClient, createRagableBrowserClient, createStreamResultFromParts, detectStorage, effectiveDataAuth, extractErrorMessage, finalizeAgentChatUiTurn, foldAgentStreamIntoUiSegments, formatPostgrestError, formatSdkError, generateIdempotencyKey, isIncompleteAgentStreamError, mapAgentEvent, mapFireworksChunk, normalizeBrowserApiBase, parseAgentStreamAgentInfo, parseAgentStreamDone, parseSseDataLine, parseTransportResponse, readSseStream, runAgentChatStream, runAgentChatStreamForUi, runAgentChatStreamLenient, streamObjectFromContext, toRagableResult, tryParsePartialJson, unwrapPostgrest, wrapStreamTextAsObject };
2152
+ export { type AgentChatMessage, type AgentChatParams, type AgentChatStreamDonePayload, type AgentChatStreamHandlers, type AgentChatStreamResult, type AgentChatStreamUiHandlers, type AgentChatUiAssistantMessage, type AgentChatUiSegment, type AgentChatUiStreamResult, type AgentConversation, type AgentConversationMessage, type AgentConversationSubscription, type AgentPublicChatParams, type AgentStreamAgentInfoEvent, type AgentStreamEvent, AuthBroadcastChannel, type AuthBroadcastMessage, type AuthChangeEvent, type AuthOptions, type AuthSession, type AuthSignUpCredentials, type AuthUpdateUserAttributes, type AuthUserMetadata, type BrowserAuthSession, type BrowserAuthTokens, BrowserCollectionApi, type BrowserCollectionDefinition, type BrowserCollectionFactory, type BrowserCollectionFindParams, type BrowserCollectionRecord, type BrowserCollections, type BrowserDataAuthMode, type BrowserRealtimeNotification, type BrowserRealtimeStatus, type BrowserRealtimeSubscribeParams, type BrowserRealtimeSubscription, type BrowserSqlExecParams, type BrowserSqlExecResult, type BrowserSqlQueryParams, type BrowserSqlQueryResult, BrowserStorageBucketClient, type BrowserStorageBulkDeleteResult, type BrowserStorageDownloadResult, type BrowserStorageItem, type BrowserStorageListResult, type BrowserStorageSignedUrlResult, type BrowserStorageUploadResult, type CollectionReturnMode, type CollectionRowData, type CollectionRowWithMeta, type CollectionWhere, type ColumnName, type ColumnValue, CookieStorageAdapter, DEFAULT_RAGABLE_API_BASE, type DefaultAuthUser, type DefaultRagableDatabase, type FinishReason, type GenerateObjectResult, type GenerateTextResult, type HttpMethod, type ImagePart, type Json, type JsonSchema, LocalStorageAdapter, type MailMessageDetail, type MailMessagePreview, type MailSearchParams, type MailSendParams, type MailSendResult, MemoryStorageAdapter, type Message, type PostgRESTFetch, type PostgRESTFetchParams, PostgrestDeleteReturningBuilder, PostgrestDeleteRootBuilder, PostgrestInsertReturningBuilder, PostgrestInsertRootBuilder, PostgrestInsertSdkErrorReturning, PostgrestInsertSdkErrorRoot, type PostgrestResult, PostgrestSelectBuilder, PostgrestTableApi, PostgrestUpdateReturningBuilder, PostgrestUpdateRootBuilder, type PostgrestUpsertOptions, PostgrestUpsertReturningBuilder, PostgrestUpsertRootBuilder, RagableAbortError, RagableAuth, type RagableAuthConfig, RagableBrowser, RagableBrowserAgentsClient, RagableBrowserAiClient, RagableBrowserAuthClient, type RagableBrowserClientOptions, RagableBrowserDatabaseClient, RagableBrowserMailClient, RagableBrowserStorageClient, type RagableDatabase, RagableError, RagableNetworkError, type RagableResult, RagableSdkError, type RagableTableDefinition, type RagableTableNames, RagableTimeoutError, type RequestOptions, type RetryOptions, type RunAgentChatStreamOptions, type RunQuery, type SessionStorage, SessionStorageAdapter, type SseJsonEvent, type StreamObjectParams, type StreamObjectResult, type StreamPart, type StreamTextParams, type StreamTextResult, type SupabaseCompatSession, type TableInsertRow, type TableRow, type TableUpdatePatch, type Tables, type TablesInsert, type TablesUpdate, type TextPart, type TokenUsage, type ToolCallRecord, Transport, type TransportOptions, type TransportRequest, type UserContent, type WhereInput, type WhereOperatorObject, type WireContentPart, type WireImagePart, type WireTextPart, type WireUserContent, asPostgrestResponse, assertPostgrestSuccess, bindFetch, buildInferenceRequestBody, buildResponseFormat, bytesToBase64, collectAssistantTextFromUiSegments, collectionRecordToRowWithMeta, collectionRecordsToRowWithMeta, createBrowserClient, createClient, createRagableBrowserClient, createStreamResultFromParts, detectStorage, effectiveDataAuth, extractErrorMessage, finalizeAgentChatUiTurn, foldAgentStreamIntoUiSegments, formatPostgrestError, formatSdkError, generateIdempotencyKey, imagePartToUrl, isIncompleteAgentStreamError, mapAgentEvent, mapFireworksChunk, normalizeBrowserApiBase, parseAgentStreamAgentInfo, parseAgentStreamDone, parseSseDataLine, parseTransportResponse, readSseStream, runAgentChatStream, runAgentChatStreamForUi, runAgentChatStreamLenient, streamObjectFromContext, toRagableResult, toWireUserContent, tryParsePartialJson, unwrapPostgrest, wrapStreamTextAsObject };
package/dist/index.d.ts CHANGED
@@ -981,10 +981,53 @@ type StreamPart = {
981
981
  type: "error";
982
982
  error: unknown;
983
983
  };
984
- interface Message {
985
- role: "system" | "user" | "assistant";
986
- content: string;
984
+ /** Plain text segment inside a multimodal user message. */
985
+ interface TextPart {
986
+ type: "text";
987
+ text: string;
987
988
  }
989
+ /**
990
+ * Image segment inside a multimodal user message. Mirrors Vercel AI SDK's
991
+ * `ImagePart` shape — the discriminator is `"image"` and the data field is
992
+ * `image` (not `image_url`). The SDK converts to the OpenAI `image_url`
993
+ * wire format internally.
994
+ */
995
+ interface ImagePart {
996
+ type: "image";
997
+ /**
998
+ * Accepted forms:
999
+ * - HTTP(S) URL string (`"https://…"`) — passed through; the provider fetches it.
1000
+ * - Data URL string (`"data:image/png;base64,…"`) — passed through.
1001
+ * - Raw base64 string (no `data:` prefix) — `mediaType` then required.
1002
+ * - `Uint8Array` / `ArrayBuffer` — base64-encoded; `mediaType` required.
1003
+ * - `URL` instance — `href` is passed through.
1004
+ */
1005
+ image: string | Uint8Array | ArrayBuffer | URL;
1006
+ /** IANA media type, e.g. `"image/png"`. Required when `image` is binary or a raw base64 string. */
1007
+ mediaType?: string;
1008
+ /** OpenAI-compatible detail hint; forwarded as `image_url.detail`. */
1009
+ detail?: "auto" | "low" | "high";
1010
+ }
1011
+ /**
1012
+ * Content for a user message — either a plain string (back-compat with the
1013
+ * original text-only shape) or an array of text/image parts.
1014
+ */
1015
+ type UserContent = string | Array<TextPart | ImagePart>;
1016
+ /**
1017
+ * Chat message. `user` messages may carry multimodal content; `system` and
1018
+ * `assistant` are text-only (vision models consume images on user turns,
1019
+ * and image *output* isn't supported here).
1020
+ */
1021
+ type Message = {
1022
+ role: "system";
1023
+ content: string;
1024
+ } | {
1025
+ role: "user";
1026
+ content: UserContent;
1027
+ } | {
1028
+ role: "assistant";
1029
+ content: string;
1030
+ };
988
1031
  /**
989
1032
  * OpenAI/Fireworks SSE chunk shape, only the fields we actually consume.
990
1033
  * Kept as a local type so we don't depend on backend internals.
@@ -1794,6 +1837,99 @@ declare class RagableBrowserStorageClient {
1794
1837
  constructor(options: RagableBrowserClientOptions, fetchImpl: typeof fetch);
1795
1838
  from(bucketId: string): BrowserStorageBucketClient;
1796
1839
  }
1840
+ interface MailSendParams {
1841
+ to: string[];
1842
+ cc?: string[];
1843
+ bcc?: string[];
1844
+ subject: string;
1845
+ /** Plain-text body. At least one of `bodyText` / `bodyHtml` is required. */
1846
+ bodyText?: string;
1847
+ /** HTML body. If both are set, sent as multipart/alternative. */
1848
+ bodyHtml?: string;
1849
+ /** RFC 822 Message-ID of the message you're replying to (enables threading). */
1850
+ inReplyToMessageId?: string;
1851
+ /** Existing References header value, chained with In-Reply-To. */
1852
+ referencesHeader?: string;
1853
+ }
1854
+ interface MailSendResult {
1855
+ sentMailMessageId: string;
1856
+ gmailMessageId: string;
1857
+ gmailThreadId: string;
1858
+ fromAddress: string;
1859
+ }
1860
+ interface MailSearchParams {
1861
+ /** Gmail search syntax, e.g. `from:alice is:unread newer_than:7d`. */
1862
+ query?: string;
1863
+ /** 1–50; default 20. */
1864
+ maxResults?: number;
1865
+ pageToken?: string;
1866
+ labelIds?: string[];
1867
+ }
1868
+ interface MailMessagePreview {
1869
+ id: string;
1870
+ threadId: string;
1871
+ snippet: string;
1872
+ labelIds: string[];
1873
+ }
1874
+ interface MailMessageDetail {
1875
+ id: string;
1876
+ threadId: string;
1877
+ receivedAt: number;
1878
+ fromAddress: string;
1879
+ fromName: string | null;
1880
+ to: string[];
1881
+ cc: string[];
1882
+ subject: string;
1883
+ snippet: string;
1884
+ bodyText: string | null;
1885
+ bodyHtml: string | null;
1886
+ messageIdHeader: string | null;
1887
+ referencesHeader: string | null;
1888
+ labelIds: string[];
1889
+ }
1890
+ /**
1891
+ * Send and read email through the Gmail account linked to this Ragable
1892
+ * website (via the IDE Infrastructure → Integrations tab).
1893
+ *
1894
+ * All requests require a Bearer token — either an end-user JWT from this
1895
+ * website's auth group (call `client.auth.signIn(...)` first) or the
1896
+ * data-admin key (server-side use).
1897
+ *
1898
+ * The website MUST have:
1899
+ * 1. A Gmail account linked under Integrations
1900
+ * 2. An auth group linked under Auth
1901
+ *
1902
+ * Otherwise calls return a 412 with a clear error message.
1903
+ */
1904
+ declare class RagableBrowserMailClient {
1905
+ private readonly options;
1906
+ private readonly auth;
1907
+ private readonly fetchImpl;
1908
+ constructor(options: RagableBrowserClientOptions, auth: RagableAuth | null);
1909
+ private requireWebsiteId;
1910
+ private pathTo;
1911
+ /**
1912
+ * Get the Bearer token used to authenticate the call:
1913
+ * 1. End-user access token (preferred when an auth group is configured
1914
+ * and the user has signed in)
1915
+ * 2. `dataStaticKey` from createBrowserClient options
1916
+ * 3. Caller-supplied `getAccessToken()`
1917
+ *
1918
+ * If none is available, throws — server-side use should pass the
1919
+ * data-admin key as `dataStaticKey`.
1920
+ */
1921
+ private getBearerToken;
1922
+ private request;
1923
+ /** Send an email from this website's linked Gmail account. */
1924
+ send(params: MailSendParams): Promise<MailSendResult>;
1925
+ /** Search messages with Gmail query syntax. */
1926
+ search(params?: MailSearchParams): Promise<{
1927
+ messages: MailMessagePreview[];
1928
+ nextPageToken: string | null;
1929
+ }>;
1930
+ /** Fetch a single message in full (headers + decoded text/html body). */
1931
+ getMessage(messageId: string): Promise<MailMessageDetail>;
1932
+ }
1797
1933
  interface AgentConversationMessage {
1798
1934
  role: "user" | "assistant";
1799
1935
  content: string;
@@ -1933,6 +2069,7 @@ declare class RagableBrowser<Database extends RagableDatabase = DefaultRagableDa
1933
2069
  readonly database: RagableBrowserDatabaseClient<Database>;
1934
2070
  readonly db: RagableBrowserDatabaseClient<Database>;
1935
2071
  readonly storage: RagableBrowserStorageClient;
2072
+ readonly mail: RagableBrowserMailClient;
1936
2073
  readonly transport: Transport;
1937
2074
  private readonly _ragableAuth;
1938
2075
  constructor(options: RagableBrowserClientOptions);
@@ -1955,6 +2092,45 @@ declare function parseSseDataLine(line: string): SseJsonEvent | null;
1955
2092
  */
1956
2093
  declare function readSseStream(body: ReadableStream<Uint8Array>): AsyncGenerator<SseJsonEvent, void, undefined>;
1957
2094
 
2095
+ /**
2096
+ * Convert SDK-shape multimodal content to the OpenAI/Fireworks `image_url`
2097
+ * wire format the Ragable inference proxy expects. Keeps the public SDK
2098
+ * types Vercel-AI-SDK-shaped (`{ type: "image", image: ... }`) while the
2099
+ * over-the-wire shape stays OpenAI canonical.
2100
+ */
2101
+
2102
+ /** OpenAI/Fireworks image content part — what flows on the wire. */
2103
+ interface WireImagePart {
2104
+ type: "image_url";
2105
+ image_url: {
2106
+ url: string;
2107
+ detail?: "auto" | "low" | "high";
2108
+ };
2109
+ }
2110
+ type WireTextPart = {
2111
+ type: "text";
2112
+ text: string;
2113
+ };
2114
+ type WireContentPart = WireTextPart | WireImagePart;
2115
+ type WireUserContent = string | WireContentPart[];
2116
+ /**
2117
+ * Convert a single `UserContent` value to wire shape. Strings pass through
2118
+ * unchanged so existing callers keep producing byte-identical request bodies.
2119
+ */
2120
+ declare function toWireUserContent(content: UserContent): WireUserContent;
2121
+ /**
2122
+ * Resolve an `ImagePart.image` value into a URL string suitable for
2123
+ * `image_url.url`. URLs pass through; binary and raw base64 are wrapped
2124
+ * into a data URL.
2125
+ */
2126
+ declare function imagePartToUrl(part: ImagePart): string;
2127
+ /**
2128
+ * Cross-runtime `Uint8Array → base64`. `btoa(String.fromCharCode(...bytes))`
2129
+ * trips the JS call-stack limit on large payloads, so we chunk the binary
2130
+ * string. Works in browser, Node 18+, Edge, and Bun.
2131
+ */
2132
+ declare function bytesToBase64(bytes: Uint8Array): string;
2133
+
1958
2134
  /**
1959
2135
  * Best-effort parser for incomplete JSON streamed token-by-token from an LLM.
1960
2136
  *
@@ -1973,4 +2149,4 @@ declare function tryParsePartialJson(text: string): unknown | undefined;
1973
2149
 
1974
2150
  declare function createClient<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends object = DefaultAuthUser>(options: RagableBrowserClientOptions): RagableBrowser<Database, AuthUser>;
1975
2151
 
1976
- export { type AgentChatMessage, type AgentChatParams, type AgentChatStreamDonePayload, type AgentChatStreamHandlers, type AgentChatStreamResult, type AgentChatStreamUiHandlers, type AgentChatUiAssistantMessage, type AgentChatUiSegment, type AgentChatUiStreamResult, type AgentConversation, type AgentConversationMessage, type AgentConversationSubscription, type AgentPublicChatParams, type AgentStreamAgentInfoEvent, type AgentStreamEvent, AuthBroadcastChannel, type AuthBroadcastMessage, type AuthChangeEvent, type AuthOptions, type AuthSession, type AuthSignUpCredentials, type AuthUpdateUserAttributes, type AuthUserMetadata, type BrowserAuthSession, type BrowserAuthTokens, BrowserCollectionApi, type BrowserCollectionDefinition, type BrowserCollectionFactory, type BrowserCollectionFindParams, type BrowserCollectionRecord, type BrowserCollections, type BrowserDataAuthMode, type BrowserRealtimeNotification, type BrowserRealtimeStatus, type BrowserRealtimeSubscribeParams, type BrowserRealtimeSubscription, type BrowserSqlExecParams, type BrowserSqlExecResult, type BrowserSqlQueryParams, type BrowserSqlQueryResult, BrowserStorageBucketClient, type BrowserStorageBulkDeleteResult, type BrowserStorageDownloadResult, type BrowserStorageItem, type BrowserStorageListResult, type BrowserStorageSignedUrlResult, type BrowserStorageUploadResult, type CollectionReturnMode, type CollectionRowData, type CollectionRowWithMeta, type CollectionWhere, type ColumnName, type ColumnValue, CookieStorageAdapter, DEFAULT_RAGABLE_API_BASE, type DefaultAuthUser, type DefaultRagableDatabase, type FinishReason, type GenerateObjectResult, type GenerateTextResult, type HttpMethod, type Json, type JsonSchema, LocalStorageAdapter, MemoryStorageAdapter, type Message, type PostgRESTFetch, type PostgRESTFetchParams, PostgrestDeleteReturningBuilder, PostgrestDeleteRootBuilder, PostgrestInsertReturningBuilder, PostgrestInsertRootBuilder, PostgrestInsertSdkErrorReturning, PostgrestInsertSdkErrorRoot, type PostgrestResult, PostgrestSelectBuilder, PostgrestTableApi, PostgrestUpdateReturningBuilder, PostgrestUpdateRootBuilder, type PostgrestUpsertOptions, PostgrestUpsertReturningBuilder, PostgrestUpsertRootBuilder, RagableAbortError, RagableAuth, type RagableAuthConfig, RagableBrowser, RagableBrowserAgentsClient, RagableBrowserAiClient, RagableBrowserAuthClient, type RagableBrowserClientOptions, RagableBrowserDatabaseClient, RagableBrowserStorageClient, type RagableDatabase, RagableError, RagableNetworkError, type RagableResult, RagableSdkError, type RagableTableDefinition, type RagableTableNames, RagableTimeoutError, type RequestOptions, type RetryOptions, type RunAgentChatStreamOptions, type RunQuery, type SessionStorage, SessionStorageAdapter, type SseJsonEvent, type StreamObjectParams, type StreamObjectResult, type StreamPart, type StreamTextParams, type StreamTextResult, type SupabaseCompatSession, type TableInsertRow, type TableRow, type TableUpdatePatch, type Tables, type TablesInsert, type TablesUpdate, type TokenUsage, type ToolCallRecord, Transport, type TransportOptions, type TransportRequest, type WhereInput, type WhereOperatorObject, asPostgrestResponse, assertPostgrestSuccess, bindFetch, buildInferenceRequestBody, buildResponseFormat, collectAssistantTextFromUiSegments, collectionRecordToRowWithMeta, collectionRecordsToRowWithMeta, createBrowserClient, createClient, createRagableBrowserClient, createStreamResultFromParts, detectStorage, effectiveDataAuth, extractErrorMessage, finalizeAgentChatUiTurn, foldAgentStreamIntoUiSegments, formatPostgrestError, formatSdkError, generateIdempotencyKey, isIncompleteAgentStreamError, mapAgentEvent, mapFireworksChunk, normalizeBrowserApiBase, parseAgentStreamAgentInfo, parseAgentStreamDone, parseSseDataLine, parseTransportResponse, readSseStream, runAgentChatStream, runAgentChatStreamForUi, runAgentChatStreamLenient, streamObjectFromContext, toRagableResult, tryParsePartialJson, unwrapPostgrest, wrapStreamTextAsObject };
2152
+ export { type AgentChatMessage, type AgentChatParams, type AgentChatStreamDonePayload, type AgentChatStreamHandlers, type AgentChatStreamResult, type AgentChatStreamUiHandlers, type AgentChatUiAssistantMessage, type AgentChatUiSegment, type AgentChatUiStreamResult, type AgentConversation, type AgentConversationMessage, type AgentConversationSubscription, type AgentPublicChatParams, type AgentStreamAgentInfoEvent, type AgentStreamEvent, AuthBroadcastChannel, type AuthBroadcastMessage, type AuthChangeEvent, type AuthOptions, type AuthSession, type AuthSignUpCredentials, type AuthUpdateUserAttributes, type AuthUserMetadata, type BrowserAuthSession, type BrowserAuthTokens, BrowserCollectionApi, type BrowserCollectionDefinition, type BrowserCollectionFactory, type BrowserCollectionFindParams, type BrowserCollectionRecord, type BrowserCollections, type BrowserDataAuthMode, type BrowserRealtimeNotification, type BrowserRealtimeStatus, type BrowserRealtimeSubscribeParams, type BrowserRealtimeSubscription, type BrowserSqlExecParams, type BrowserSqlExecResult, type BrowserSqlQueryParams, type BrowserSqlQueryResult, BrowserStorageBucketClient, type BrowserStorageBulkDeleteResult, type BrowserStorageDownloadResult, type BrowserStorageItem, type BrowserStorageListResult, type BrowserStorageSignedUrlResult, type BrowserStorageUploadResult, type CollectionReturnMode, type CollectionRowData, type CollectionRowWithMeta, type CollectionWhere, type ColumnName, type ColumnValue, CookieStorageAdapter, DEFAULT_RAGABLE_API_BASE, type DefaultAuthUser, type DefaultRagableDatabase, type FinishReason, type GenerateObjectResult, type GenerateTextResult, type HttpMethod, type ImagePart, type Json, type JsonSchema, LocalStorageAdapter, type MailMessageDetail, type MailMessagePreview, type MailSearchParams, type MailSendParams, type MailSendResult, MemoryStorageAdapter, type Message, type PostgRESTFetch, type PostgRESTFetchParams, PostgrestDeleteReturningBuilder, PostgrestDeleteRootBuilder, PostgrestInsertReturningBuilder, PostgrestInsertRootBuilder, PostgrestInsertSdkErrorReturning, PostgrestInsertSdkErrorRoot, type PostgrestResult, PostgrestSelectBuilder, PostgrestTableApi, PostgrestUpdateReturningBuilder, PostgrestUpdateRootBuilder, type PostgrestUpsertOptions, PostgrestUpsertReturningBuilder, PostgrestUpsertRootBuilder, RagableAbortError, RagableAuth, type RagableAuthConfig, RagableBrowser, RagableBrowserAgentsClient, RagableBrowserAiClient, RagableBrowserAuthClient, type RagableBrowserClientOptions, RagableBrowserDatabaseClient, RagableBrowserMailClient, RagableBrowserStorageClient, type RagableDatabase, RagableError, RagableNetworkError, type RagableResult, RagableSdkError, type RagableTableDefinition, type RagableTableNames, RagableTimeoutError, type RequestOptions, type RetryOptions, type RunAgentChatStreamOptions, type RunQuery, type SessionStorage, SessionStorageAdapter, type SseJsonEvent, type StreamObjectParams, type StreamObjectResult, type StreamPart, type StreamTextParams, type StreamTextResult, type SupabaseCompatSession, type TableInsertRow, type TableRow, type TableUpdatePatch, type Tables, type TablesInsert, type TablesUpdate, type TextPart, type TokenUsage, type ToolCallRecord, Transport, type TransportOptions, type TransportRequest, type UserContent, type WhereInput, type WhereOperatorObject, type WireContentPart, type WireImagePart, type WireTextPart, type WireUserContent, asPostgrestResponse, assertPostgrestSuccess, bindFetch, buildInferenceRequestBody, buildResponseFormat, bytesToBase64, collectAssistantTextFromUiSegments, collectionRecordToRowWithMeta, collectionRecordsToRowWithMeta, createBrowserClient, createClient, createRagableBrowserClient, createStreamResultFromParts, detectStorage, effectiveDataAuth, extractErrorMessage, finalizeAgentChatUiTurn, foldAgentStreamIntoUiSegments, formatPostgrestError, formatSdkError, generateIdempotencyKey, imagePartToUrl, isIncompleteAgentStreamError, mapAgentEvent, mapFireworksChunk, normalizeBrowserApiBase, parseAgentStreamAgentInfo, parseAgentStreamDone, parseSseDataLine, parseTransportResponse, readSseStream, runAgentChatStream, runAgentChatStreamForUi, runAgentChatStreamLenient, streamObjectFromContext, toRagableResult, toWireUserContent, tryParsePartialJson, unwrapPostgrest, wrapStreamTextAsObject };