@ragable/sdk 0.6.23 → 0.7.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.mts CHANGED
@@ -1661,9 +1661,308 @@ declare function formatRetrievalContext(results: ShiftSearchResult[], options?:
1661
1661
  */
1662
1662
  declare function createRagPipeline(client: RagClientForPipeline, options: RagPipelineOptions): RagPipeline;
1663
1663
 
1664
+ interface StorageBucket {
1665
+ id: string;
1666
+ name: string;
1667
+ organizationId: string;
1668
+ status: string;
1669
+ createdAt: string;
1670
+ updatedAt: string;
1671
+ }
1672
+ interface StorageBucketItem {
1673
+ type: "file" | "folder";
1674
+ path: string;
1675
+ name: string;
1676
+ /** File size in bytes (files only). */
1677
+ size?: string | null;
1678
+ contentType?: string | null;
1679
+ updated?: string | null;
1680
+ generation?: string | null;
1681
+ }
1682
+ interface StorageListContentsResult {
1683
+ bucket: string;
1684
+ prefix: string;
1685
+ items: StorageBucketItem[];
1686
+ nextPageToken: string | null;
1687
+ }
1688
+ interface StorageListBucketsParams {
1689
+ /** Filter by name substring. */
1690
+ q?: string;
1691
+ status?: string;
1692
+ sort?: string;
1693
+ }
1694
+ interface StorageListContentsParams {
1695
+ /** Folder prefix to list inside (e.g. `"reports/"`). */
1696
+ prefix?: string;
1697
+ /** Path delimiter — defaults to `"/"` on the server. */
1698
+ delimiter?: string;
1699
+ maxResults?: number;
1700
+ pageToken?: string;
1701
+ }
1702
+ type StorageUploadableFile = Blob | ArrayBuffer | Uint8Array;
1703
+ interface StorageUploadParams {
1704
+ /** Target path inside the bucket (e.g. `"reports/jan.pdf"`). */
1705
+ objectPath: string;
1706
+ file: StorageUploadableFile;
1707
+ /** Optional filename hint for content-type detection. */
1708
+ fileName?: string;
1709
+ contentType?: string;
1710
+ /** HTTP `Cache-Control` header stored with the object. */
1711
+ cacheControl?: string;
1712
+ }
1713
+ interface StorageUploadResult {
1714
+ success: true;
1715
+ path: string;
1716
+ size: string | null;
1717
+ contentType: string | null;
1718
+ generation: string | null;
1719
+ updated: string | null;
1720
+ }
1721
+ interface StorageDownloadParams {
1722
+ objectPath: string;
1723
+ /** When `true`, the response includes `text` if the file fits in `maxTextBytes`. */
1724
+ asText?: boolean;
1725
+ /** Maximum bytes to decode as text (default 1 MB, max 5 MB). */
1726
+ maxTextBytes?: number;
1727
+ }
1728
+ interface StorageDownloadResult {
1729
+ path: string;
1730
+ size: string | null;
1731
+ contentType: string | null;
1732
+ updated: string | null;
1733
+ generation: string | null;
1734
+ /** Always `"base64"`. */
1735
+ encoding: string;
1736
+ /** Full file contents encoded as base64. */
1737
+ contentsBase64: string;
1738
+ /** UTF-8 decoded text when `asText: true` and size ≤ `maxTextBytes`. */
1739
+ text: string | null;
1740
+ textIncluded: boolean;
1741
+ }
1742
+ interface StorageObjectMetadata {
1743
+ name: string;
1744
+ bucket: string;
1745
+ contentType: string | null;
1746
+ size: string | null;
1747
+ updated: string | null;
1748
+ generation: string | null;
1749
+ metadata?: Record<string, string>;
1750
+ [key: string]: unknown;
1751
+ }
1752
+ interface StorageUpdateMetadataParams {
1753
+ objectPath: string;
1754
+ contentType?: string;
1755
+ cacheControl?: string;
1756
+ metadata?: Record<string, string>;
1757
+ }
1758
+ interface StorageCopyMoveParams {
1759
+ sourcePath: string;
1760
+ destinationPath: string;
1761
+ }
1762
+ interface StorageBulkDeleteResult {
1763
+ success: boolean;
1764
+ totalRequested: number;
1765
+ uniquePaths: number;
1766
+ deleted: string[];
1767
+ errors: Array<{
1768
+ path: string;
1769
+ error: string;
1770
+ }>;
1771
+ }
1772
+ interface StorageSignedUploadUrlParams {
1773
+ objectPath: string;
1774
+ /** Expiry in seconds — clamped to [60, 3600] by the server. Default 900. */
1775
+ expiresInSeconds?: number;
1776
+ contentType?: string;
1777
+ }
1778
+ interface StorageSignedUploadUrlResult {
1779
+ url: string;
1780
+ method: string;
1781
+ expiresInSeconds: number;
1782
+ objectPath: string;
1783
+ }
1784
+ interface StorageSignedDownloadUrlParams {
1785
+ objectPath: string;
1786
+ /** Expiry in seconds — clamped to [60, 86400] by the server. Default 900. */
1787
+ expiresInSeconds?: number;
1788
+ }
1789
+ interface StorageSignedDownloadUrlResult {
1790
+ url: string;
1791
+ method: string;
1792
+ expiresInSeconds: number;
1793
+ objectPath: string;
1794
+ }
1795
+ interface StorageBucketCorsEntry {
1796
+ origin?: string[];
1797
+ method?: string[];
1798
+ responseHeader?: string[];
1799
+ maxAgeSeconds?: number;
1800
+ }
1801
+ interface StorageBucketSettings {
1802
+ id: string;
1803
+ logicalName: string;
1804
+ gcpBucketName: string;
1805
+ location: string | null;
1806
+ storageClass: string | null;
1807
+ labels: Record<string, string>;
1808
+ versioningEnabled: boolean;
1809
+ publicAccessPrevention: string | null;
1810
+ uniformBucketLevelAccessEnabled: boolean;
1811
+ cors: StorageBucketCorsEntry[];
1812
+ retentionPolicy: unknown;
1813
+ lifecycleRules: unknown[];
1814
+ updated: string | null;
1815
+ }
1816
+ interface StorageUpdateBucketSettingsParams {
1817
+ labels?: Record<string, string>;
1818
+ storageClass?: string;
1819
+ versioningEnabled?: boolean;
1820
+ publicAccessPrevention?: "inherited" | "enforced";
1821
+ uniformBucketLevelAccessEnabled?: boolean;
1822
+ cors?: StorageBucketCorsEntry[];
1823
+ }
1824
+ /**
1825
+ * Object/file operations scoped to a single bucket.
1826
+ * Obtained via {@link StorageClient.from}.
1827
+ *
1828
+ * @example
1829
+ * const bucket = ragable.storage.from("bucket-id");
1830
+ *
1831
+ * // Upload a file
1832
+ * await bucket.upload({ objectPath: "data/report.pdf", file: pdfBlob });
1833
+ *
1834
+ * // Download and read as text
1835
+ * const { text } = await bucket.download({ objectPath: "data/notes.txt", asText: true });
1836
+ *
1837
+ * // Generate a short-lived public download link
1838
+ * const { url } = await bucket.getSignedDownloadUrl({ objectPath: "data/report.pdf" });
1839
+ */
1840
+ interface StorageBucketClient {
1841
+ /** List objects and sub-folders inside this bucket (optionally under a prefix). */
1842
+ list(params?: StorageListContentsParams): Promise<StorageListContentsResult>;
1843
+ /** Create an empty folder placeholder (GCS folder marker). */
1844
+ createFolder(folderPath: string): Promise<{
1845
+ success: true;
1846
+ folderPath: string;
1847
+ }>;
1848
+ /** Delete a folder and all objects under it. */
1849
+ deleteFolder(folderPath: string): Promise<{
1850
+ success: true;
1851
+ folderPath: string;
1852
+ }>;
1853
+ /** Upload a file to the specified `objectPath`. */
1854
+ upload(params: StorageUploadParams): Promise<StorageUploadResult>;
1855
+ /** Delete a single object. */
1856
+ delete(objectPath: string): Promise<{
1857
+ success: true;
1858
+ path: string;
1859
+ }>;
1860
+ /** Delete up to 1 000 objects in one call. */
1861
+ bulkDelete(objectPaths: string[]): Promise<StorageBulkDeleteResult>;
1862
+ /** Retrieve GCS metadata for an object. */
1863
+ getMetadata(objectPath: string): Promise<StorageObjectMetadata>;
1864
+ /** Update `contentType`, `cacheControl`, or custom `metadata` for an object. */
1865
+ updateMetadata(params: StorageUpdateMetadataParams): Promise<StorageObjectMetadata>;
1866
+ /**
1867
+ * Download an object. Contents are always returned as `contentsBase64`.
1868
+ * Pass `asText: true` to also receive a decoded `text` field (≤ maxTextBytes).
1869
+ */
1870
+ download(params: StorageDownloadParams): Promise<StorageDownloadResult>;
1871
+ /** Copy an object to a new path inside the same bucket. */
1872
+ copy(params: StorageCopyMoveParams): Promise<{
1873
+ success: true;
1874
+ sourcePath: string;
1875
+ destinationPath: string;
1876
+ }>;
1877
+ /** Move (rename) an object inside the same bucket. */
1878
+ move(params: StorageCopyMoveParams): Promise<{
1879
+ success: true;
1880
+ sourcePath: string;
1881
+ destinationPath: string;
1882
+ }>;
1883
+ /**
1884
+ * Generate a signed URL for direct client-side PUT upload (bypasses your server).
1885
+ * Use this when a website needs to upload large files directly to GCS.
1886
+ */
1887
+ getSignedUploadUrl(params: StorageSignedUploadUrlParams): Promise<StorageSignedUploadUrlResult>;
1888
+ /**
1889
+ * Generate a signed URL for direct client-side download.
1890
+ * Useful for serving private files without proxying through your server.
1891
+ */
1892
+ getSignedDownloadUrl(params: StorageSignedDownloadUrlParams): Promise<StorageSignedDownloadUrlResult>;
1893
+ /** Retrieve GCS-level settings for this bucket (CORS, versioning, storage class …). */
1894
+ getSettings(): Promise<StorageBucketSettings>;
1895
+ /** Update GCS-level settings for this bucket. */
1896
+ updateSettings(params: StorageUpdateBucketSettingsParams): Promise<StorageBucketSettings>;
1897
+ }
1898
+ /**
1899
+ * Server-side storage client — access via `ragable.storage`.
1900
+ *
1901
+ * Manages GCS-backed storage buckets for your organisation and exposes typed
1902
+ * helpers for every object-storage operation websites need for durable storage.
1903
+ *
1904
+ * ```ts
1905
+ * import { createClient } from "@ragable/sdk";
1906
+ *
1907
+ * const ragable = createClient({ apiKey: process.env.RAGABLE_API_KEY! });
1908
+ *
1909
+ * // ── Bucket management ───────────────────────────────────────────────────
1910
+ * const buckets = await ragable.storage.buckets.list();
1911
+ * const bucket = await ragable.storage.buckets.create("my-website-assets");
1912
+ *
1913
+ * // ── Object operations (via .from()) ─────────────────────────────────────
1914
+ * const b = ragable.storage.from(bucket.id);
1915
+ *
1916
+ * await b.upload({ objectPath: "pages/index.html", file: htmlBlob, contentType: "text/html" });
1917
+ * const { text } = await b.download({ objectPath: "pages/index.html", asText: true });
1918
+ *
1919
+ * // ── Signed URLs for client-side direct upload/download ──────────────────
1920
+ * const { url } = await b.getSignedUploadUrl({ objectPath: "uploads/photo.jpg", contentType: "image/jpeg" });
1921
+ * ```
1922
+ */
1923
+ declare class StorageClient {
1924
+ private readonly client;
1925
+ /**
1926
+ * Bucket-level CRUD — list, create and delete buckets for this organisation.
1927
+ */
1928
+ readonly buckets: {
1929
+ /**
1930
+ * List all managed storage buckets.
1931
+ *
1932
+ * @param params Optional filter / sort params (`q`, `status`, `sort`).
1933
+ */
1934
+ list(params?: StorageListBucketsParams): Promise<StorageBucket[]>;
1935
+ /**
1936
+ * Create a new managed GCS bucket.
1937
+ *
1938
+ * The `name` must be lowercase alphanumeric + dashes, max 63 chars.
1939
+ */
1940
+ create(name: string): Promise<StorageBucket>;
1941
+ /**
1942
+ * Permanently delete a bucket and **all** its contents.
1943
+ *
1944
+ * @param bucketId The Ragable bucket ID (not the raw GCS bucket name).
1945
+ */
1946
+ delete(bucketId: string): Promise<{
1947
+ success: true;
1948
+ }>;
1949
+ };
1950
+ constructor(client: RagableRequestClient);
1951
+ /**
1952
+ * Returns a {@link StorageBucketClient} scoped to the given bucket ID.
1953
+ *
1954
+ * All object operations (upload, download, list, copy, move, signed URLs, …)
1955
+ * are performed through the returned client.
1956
+ *
1957
+ * @param bucketId The Ragable bucket ID obtained from `buckets.list()` or `buckets.create()`.
1958
+ */
1959
+ from(bucketId: string): StorageBucketClient;
1960
+ }
1961
+
1664
1962
  declare class Ragable {
1665
1963
  readonly shift: ShiftClient;
1666
1964
  readonly agents: AgentsClient;
1965
+ readonly storage: StorageClient;
1667
1966
  readonly infrastructure: {
1668
1967
  shift: ShiftClient;
1669
1968
  };
@@ -1673,4 +1972,4 @@ declare function createClient(options: RagableClientOptions): Ragable;
1673
1972
  declare function createClient<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends object = DefaultAuthUser>(options: RagableBrowserClientOptions): RagableBrowser<Database, AuthUser>;
1674
1973
  declare function createRagableServerClient(options: RagableClientOptions): Ragable;
1675
1974
 
1676
- export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, 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, type AgentSummary, AgentsClient, 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, type CollectionReturnMode, type CollectionRowData, type CollectionRowWithMeta, type CollectionWhere, type ColumnName, type ColumnValue, CookieStorageAdapter, DEFAULT_RAGABLE_API_BASE, type DefaultAuthUser, type DefaultRagableDatabase, type FormatContextOptions, type HttpMethod, type Json, LocalStorageAdapter, MemoryStorageAdapter, type PostgRESTFetch, type PostgRESTFetchParams, PostgrestDeleteReturningBuilder, PostgrestDeleteRootBuilder, PostgrestInsertReturningBuilder, PostgrestInsertRootBuilder, PostgrestInsertSdkErrorReturning, PostgrestInsertSdkErrorRoot, type PostgrestResult, PostgrestSelectBuilder, PostgrestTableApi, PostgrestUpdateReturningBuilder, PostgrestUpdateRootBuilder, type PostgrestUpsertOptions, PostgrestUpsertReturningBuilder, PostgrestUpsertRootBuilder, type RagClientForPipeline, type RagPipeline, type RagPipelineOptions, Ragable, RagableAbortError, RagableAuth, type RagableAuthConfig, RagableBrowser, RagableBrowserAgentsClient, RagableBrowserAuthClient, type RagableBrowserClientOptions, RagableBrowserDatabaseClient, type RagableClientOptions, type RagableDatabase, RagableError, RagableNetworkError, RagableRequestClient, type RagableResult, RagableSdkError, type RagableTableDefinition, type RagableTableNames, RagableTimeoutError, type RequestOptions, type RetrieveParams, type RetryOptions, type RunAgentChatStreamOptions, type RunQuery, type SessionStorage, SessionStorageAdapter, type ShiftAddDocumentParams, ShiftClient, type ShiftCreateIndexParams, type ShiftEntry, type ShiftIndex, type ShiftIngestResponse, type ShiftListEntriesParams, type ShiftListEntriesResponse, type ShiftSearchParams, type ShiftSearchResult, type ShiftUpdateIndexParams, type ShiftUploadFileParams, type ShiftUploadableFile, type SseJsonEvent, type SupabaseCompatSession, type TableInsertRow, type TableRow, type TableUpdatePatch, type Tables, type TablesInsert, type TablesUpdate, Transport, type TransportOptions, type TransportRequest, type WhereInput, type WhereOperatorObject, asPostgrestResponse, assertPostgrestSuccess, bindFetch, collectAssistantTextFromUiSegments, collectionRecordToRowWithMeta, collectionRecordsToRowWithMeta, createBrowserClient, createClient, createRagPipeline, createRagableBrowserClient, createRagableServerClient, detectStorage, effectiveDataAuth, extractErrorMessage, finalizeAgentChatUiTurn, foldAgentStreamIntoUiSegments, formatPostgrestError, formatRetrievalContext, formatSdkError, generateIdempotencyKey, isIncompleteAgentStreamError, normalizeBrowserApiBase, parseAgentStreamAgentInfo, parseAgentStreamDone, parseSseDataLine, parseTransportResponse, readSseStream, runAgentChatStream, runAgentChatStreamForUi, runAgentChatStreamLenient, toRagableResult, unwrapPostgrest };
1975
+ export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, 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, type AgentSummary, AgentsClient, 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, type CollectionReturnMode, type CollectionRowData, type CollectionRowWithMeta, type CollectionWhere, type ColumnName, type ColumnValue, CookieStorageAdapter, DEFAULT_RAGABLE_API_BASE, type DefaultAuthUser, type DefaultRagableDatabase, type FormatContextOptions, type HttpMethod, type Json, LocalStorageAdapter, MemoryStorageAdapter, type PostgRESTFetch, type PostgRESTFetchParams, PostgrestDeleteReturningBuilder, PostgrestDeleteRootBuilder, PostgrestInsertReturningBuilder, PostgrestInsertRootBuilder, PostgrestInsertSdkErrorReturning, PostgrestInsertSdkErrorRoot, type PostgrestResult, PostgrestSelectBuilder, PostgrestTableApi, PostgrestUpdateReturningBuilder, PostgrestUpdateRootBuilder, type PostgrestUpsertOptions, PostgrestUpsertReturningBuilder, PostgrestUpsertRootBuilder, type RagClientForPipeline, type RagPipeline, type RagPipelineOptions, Ragable, RagableAbortError, RagableAuth, type RagableAuthConfig, RagableBrowser, RagableBrowserAgentsClient, RagableBrowserAuthClient, type RagableBrowserClientOptions, RagableBrowserDatabaseClient, type RagableClientOptions, type RagableDatabase, RagableError, RagableNetworkError, RagableRequestClient, type RagableResult, RagableSdkError, type RagableTableDefinition, type RagableTableNames, RagableTimeoutError, type RequestOptions, type RetrieveParams, type RetryOptions, type RunAgentChatStreamOptions, type RunQuery, type SessionStorage, SessionStorageAdapter, type ShiftAddDocumentParams, ShiftClient, type ShiftCreateIndexParams, type ShiftEntry, type ShiftIndex, type ShiftIngestResponse, type ShiftListEntriesParams, type ShiftListEntriesResponse, type ShiftSearchParams, type ShiftSearchResult, type ShiftUpdateIndexParams, type ShiftUploadFileParams, type ShiftUploadableFile, type SseJsonEvent, type StorageBucket, type StorageBucketClient, type StorageBucketCorsEntry, type StorageBucketItem, type StorageBucketSettings, type StorageBulkDeleteResult, StorageClient, type StorageCopyMoveParams, type StorageDownloadParams, type StorageDownloadResult, type StorageListBucketsParams, type StorageListContentsParams, type StorageListContentsResult, type StorageObjectMetadata, type StorageSignedDownloadUrlParams, type StorageSignedDownloadUrlResult, type StorageSignedUploadUrlParams, type StorageSignedUploadUrlResult, type StorageUpdateBucketSettingsParams, type StorageUpdateMetadataParams, type StorageUploadParams, type StorageUploadResult, type StorageUploadableFile, type SupabaseCompatSession, type TableInsertRow, type TableRow, type TableUpdatePatch, type Tables, type TablesInsert, type TablesUpdate, Transport, type TransportOptions, type TransportRequest, type WhereInput, type WhereOperatorObject, asPostgrestResponse, assertPostgrestSuccess, bindFetch, collectAssistantTextFromUiSegments, collectionRecordToRowWithMeta, collectionRecordsToRowWithMeta, createBrowserClient, createClient, createRagPipeline, createRagableBrowserClient, createRagableServerClient, detectStorage, effectiveDataAuth, extractErrorMessage, finalizeAgentChatUiTurn, foldAgentStreamIntoUiSegments, formatPostgrestError, formatRetrievalContext, formatSdkError, generateIdempotencyKey, isIncompleteAgentStreamError, normalizeBrowserApiBase, parseAgentStreamAgentInfo, parseAgentStreamDone, parseSseDataLine, parseTransportResponse, readSseStream, runAgentChatStream, runAgentChatStreamForUi, runAgentChatStreamLenient, toRagableResult, unwrapPostgrest };
package/dist/index.d.ts CHANGED
@@ -1661,9 +1661,308 @@ declare function formatRetrievalContext(results: ShiftSearchResult[], options?:
1661
1661
  */
1662
1662
  declare function createRagPipeline(client: RagClientForPipeline, options: RagPipelineOptions): RagPipeline;
1663
1663
 
1664
+ interface StorageBucket {
1665
+ id: string;
1666
+ name: string;
1667
+ organizationId: string;
1668
+ status: string;
1669
+ createdAt: string;
1670
+ updatedAt: string;
1671
+ }
1672
+ interface StorageBucketItem {
1673
+ type: "file" | "folder";
1674
+ path: string;
1675
+ name: string;
1676
+ /** File size in bytes (files only). */
1677
+ size?: string | null;
1678
+ contentType?: string | null;
1679
+ updated?: string | null;
1680
+ generation?: string | null;
1681
+ }
1682
+ interface StorageListContentsResult {
1683
+ bucket: string;
1684
+ prefix: string;
1685
+ items: StorageBucketItem[];
1686
+ nextPageToken: string | null;
1687
+ }
1688
+ interface StorageListBucketsParams {
1689
+ /** Filter by name substring. */
1690
+ q?: string;
1691
+ status?: string;
1692
+ sort?: string;
1693
+ }
1694
+ interface StorageListContentsParams {
1695
+ /** Folder prefix to list inside (e.g. `"reports/"`). */
1696
+ prefix?: string;
1697
+ /** Path delimiter — defaults to `"/"` on the server. */
1698
+ delimiter?: string;
1699
+ maxResults?: number;
1700
+ pageToken?: string;
1701
+ }
1702
+ type StorageUploadableFile = Blob | ArrayBuffer | Uint8Array;
1703
+ interface StorageUploadParams {
1704
+ /** Target path inside the bucket (e.g. `"reports/jan.pdf"`). */
1705
+ objectPath: string;
1706
+ file: StorageUploadableFile;
1707
+ /** Optional filename hint for content-type detection. */
1708
+ fileName?: string;
1709
+ contentType?: string;
1710
+ /** HTTP `Cache-Control` header stored with the object. */
1711
+ cacheControl?: string;
1712
+ }
1713
+ interface StorageUploadResult {
1714
+ success: true;
1715
+ path: string;
1716
+ size: string | null;
1717
+ contentType: string | null;
1718
+ generation: string | null;
1719
+ updated: string | null;
1720
+ }
1721
+ interface StorageDownloadParams {
1722
+ objectPath: string;
1723
+ /** When `true`, the response includes `text` if the file fits in `maxTextBytes`. */
1724
+ asText?: boolean;
1725
+ /** Maximum bytes to decode as text (default 1 MB, max 5 MB). */
1726
+ maxTextBytes?: number;
1727
+ }
1728
+ interface StorageDownloadResult {
1729
+ path: string;
1730
+ size: string | null;
1731
+ contentType: string | null;
1732
+ updated: string | null;
1733
+ generation: string | null;
1734
+ /** Always `"base64"`. */
1735
+ encoding: string;
1736
+ /** Full file contents encoded as base64. */
1737
+ contentsBase64: string;
1738
+ /** UTF-8 decoded text when `asText: true` and size ≤ `maxTextBytes`. */
1739
+ text: string | null;
1740
+ textIncluded: boolean;
1741
+ }
1742
+ interface StorageObjectMetadata {
1743
+ name: string;
1744
+ bucket: string;
1745
+ contentType: string | null;
1746
+ size: string | null;
1747
+ updated: string | null;
1748
+ generation: string | null;
1749
+ metadata?: Record<string, string>;
1750
+ [key: string]: unknown;
1751
+ }
1752
+ interface StorageUpdateMetadataParams {
1753
+ objectPath: string;
1754
+ contentType?: string;
1755
+ cacheControl?: string;
1756
+ metadata?: Record<string, string>;
1757
+ }
1758
+ interface StorageCopyMoveParams {
1759
+ sourcePath: string;
1760
+ destinationPath: string;
1761
+ }
1762
+ interface StorageBulkDeleteResult {
1763
+ success: boolean;
1764
+ totalRequested: number;
1765
+ uniquePaths: number;
1766
+ deleted: string[];
1767
+ errors: Array<{
1768
+ path: string;
1769
+ error: string;
1770
+ }>;
1771
+ }
1772
+ interface StorageSignedUploadUrlParams {
1773
+ objectPath: string;
1774
+ /** Expiry in seconds — clamped to [60, 3600] by the server. Default 900. */
1775
+ expiresInSeconds?: number;
1776
+ contentType?: string;
1777
+ }
1778
+ interface StorageSignedUploadUrlResult {
1779
+ url: string;
1780
+ method: string;
1781
+ expiresInSeconds: number;
1782
+ objectPath: string;
1783
+ }
1784
+ interface StorageSignedDownloadUrlParams {
1785
+ objectPath: string;
1786
+ /** Expiry in seconds — clamped to [60, 86400] by the server. Default 900. */
1787
+ expiresInSeconds?: number;
1788
+ }
1789
+ interface StorageSignedDownloadUrlResult {
1790
+ url: string;
1791
+ method: string;
1792
+ expiresInSeconds: number;
1793
+ objectPath: string;
1794
+ }
1795
+ interface StorageBucketCorsEntry {
1796
+ origin?: string[];
1797
+ method?: string[];
1798
+ responseHeader?: string[];
1799
+ maxAgeSeconds?: number;
1800
+ }
1801
+ interface StorageBucketSettings {
1802
+ id: string;
1803
+ logicalName: string;
1804
+ gcpBucketName: string;
1805
+ location: string | null;
1806
+ storageClass: string | null;
1807
+ labels: Record<string, string>;
1808
+ versioningEnabled: boolean;
1809
+ publicAccessPrevention: string | null;
1810
+ uniformBucketLevelAccessEnabled: boolean;
1811
+ cors: StorageBucketCorsEntry[];
1812
+ retentionPolicy: unknown;
1813
+ lifecycleRules: unknown[];
1814
+ updated: string | null;
1815
+ }
1816
+ interface StorageUpdateBucketSettingsParams {
1817
+ labels?: Record<string, string>;
1818
+ storageClass?: string;
1819
+ versioningEnabled?: boolean;
1820
+ publicAccessPrevention?: "inherited" | "enforced";
1821
+ uniformBucketLevelAccessEnabled?: boolean;
1822
+ cors?: StorageBucketCorsEntry[];
1823
+ }
1824
+ /**
1825
+ * Object/file operations scoped to a single bucket.
1826
+ * Obtained via {@link StorageClient.from}.
1827
+ *
1828
+ * @example
1829
+ * const bucket = ragable.storage.from("bucket-id");
1830
+ *
1831
+ * // Upload a file
1832
+ * await bucket.upload({ objectPath: "data/report.pdf", file: pdfBlob });
1833
+ *
1834
+ * // Download and read as text
1835
+ * const { text } = await bucket.download({ objectPath: "data/notes.txt", asText: true });
1836
+ *
1837
+ * // Generate a short-lived public download link
1838
+ * const { url } = await bucket.getSignedDownloadUrl({ objectPath: "data/report.pdf" });
1839
+ */
1840
+ interface StorageBucketClient {
1841
+ /** List objects and sub-folders inside this bucket (optionally under a prefix). */
1842
+ list(params?: StorageListContentsParams): Promise<StorageListContentsResult>;
1843
+ /** Create an empty folder placeholder (GCS folder marker). */
1844
+ createFolder(folderPath: string): Promise<{
1845
+ success: true;
1846
+ folderPath: string;
1847
+ }>;
1848
+ /** Delete a folder and all objects under it. */
1849
+ deleteFolder(folderPath: string): Promise<{
1850
+ success: true;
1851
+ folderPath: string;
1852
+ }>;
1853
+ /** Upload a file to the specified `objectPath`. */
1854
+ upload(params: StorageUploadParams): Promise<StorageUploadResult>;
1855
+ /** Delete a single object. */
1856
+ delete(objectPath: string): Promise<{
1857
+ success: true;
1858
+ path: string;
1859
+ }>;
1860
+ /** Delete up to 1 000 objects in one call. */
1861
+ bulkDelete(objectPaths: string[]): Promise<StorageBulkDeleteResult>;
1862
+ /** Retrieve GCS metadata for an object. */
1863
+ getMetadata(objectPath: string): Promise<StorageObjectMetadata>;
1864
+ /** Update `contentType`, `cacheControl`, or custom `metadata` for an object. */
1865
+ updateMetadata(params: StorageUpdateMetadataParams): Promise<StorageObjectMetadata>;
1866
+ /**
1867
+ * Download an object. Contents are always returned as `contentsBase64`.
1868
+ * Pass `asText: true` to also receive a decoded `text` field (≤ maxTextBytes).
1869
+ */
1870
+ download(params: StorageDownloadParams): Promise<StorageDownloadResult>;
1871
+ /** Copy an object to a new path inside the same bucket. */
1872
+ copy(params: StorageCopyMoveParams): Promise<{
1873
+ success: true;
1874
+ sourcePath: string;
1875
+ destinationPath: string;
1876
+ }>;
1877
+ /** Move (rename) an object inside the same bucket. */
1878
+ move(params: StorageCopyMoveParams): Promise<{
1879
+ success: true;
1880
+ sourcePath: string;
1881
+ destinationPath: string;
1882
+ }>;
1883
+ /**
1884
+ * Generate a signed URL for direct client-side PUT upload (bypasses your server).
1885
+ * Use this when a website needs to upload large files directly to GCS.
1886
+ */
1887
+ getSignedUploadUrl(params: StorageSignedUploadUrlParams): Promise<StorageSignedUploadUrlResult>;
1888
+ /**
1889
+ * Generate a signed URL for direct client-side download.
1890
+ * Useful for serving private files without proxying through your server.
1891
+ */
1892
+ getSignedDownloadUrl(params: StorageSignedDownloadUrlParams): Promise<StorageSignedDownloadUrlResult>;
1893
+ /** Retrieve GCS-level settings for this bucket (CORS, versioning, storage class …). */
1894
+ getSettings(): Promise<StorageBucketSettings>;
1895
+ /** Update GCS-level settings for this bucket. */
1896
+ updateSettings(params: StorageUpdateBucketSettingsParams): Promise<StorageBucketSettings>;
1897
+ }
1898
+ /**
1899
+ * Server-side storage client — access via `ragable.storage`.
1900
+ *
1901
+ * Manages GCS-backed storage buckets for your organisation and exposes typed
1902
+ * helpers for every object-storage operation websites need for durable storage.
1903
+ *
1904
+ * ```ts
1905
+ * import { createClient } from "@ragable/sdk";
1906
+ *
1907
+ * const ragable = createClient({ apiKey: process.env.RAGABLE_API_KEY! });
1908
+ *
1909
+ * // ── Bucket management ───────────────────────────────────────────────────
1910
+ * const buckets = await ragable.storage.buckets.list();
1911
+ * const bucket = await ragable.storage.buckets.create("my-website-assets");
1912
+ *
1913
+ * // ── Object operations (via .from()) ─────────────────────────────────────
1914
+ * const b = ragable.storage.from(bucket.id);
1915
+ *
1916
+ * await b.upload({ objectPath: "pages/index.html", file: htmlBlob, contentType: "text/html" });
1917
+ * const { text } = await b.download({ objectPath: "pages/index.html", asText: true });
1918
+ *
1919
+ * // ── Signed URLs for client-side direct upload/download ──────────────────
1920
+ * const { url } = await b.getSignedUploadUrl({ objectPath: "uploads/photo.jpg", contentType: "image/jpeg" });
1921
+ * ```
1922
+ */
1923
+ declare class StorageClient {
1924
+ private readonly client;
1925
+ /**
1926
+ * Bucket-level CRUD — list, create and delete buckets for this organisation.
1927
+ */
1928
+ readonly buckets: {
1929
+ /**
1930
+ * List all managed storage buckets.
1931
+ *
1932
+ * @param params Optional filter / sort params (`q`, `status`, `sort`).
1933
+ */
1934
+ list(params?: StorageListBucketsParams): Promise<StorageBucket[]>;
1935
+ /**
1936
+ * Create a new managed GCS bucket.
1937
+ *
1938
+ * The `name` must be lowercase alphanumeric + dashes, max 63 chars.
1939
+ */
1940
+ create(name: string): Promise<StorageBucket>;
1941
+ /**
1942
+ * Permanently delete a bucket and **all** its contents.
1943
+ *
1944
+ * @param bucketId The Ragable bucket ID (not the raw GCS bucket name).
1945
+ */
1946
+ delete(bucketId: string): Promise<{
1947
+ success: true;
1948
+ }>;
1949
+ };
1950
+ constructor(client: RagableRequestClient);
1951
+ /**
1952
+ * Returns a {@link StorageBucketClient} scoped to the given bucket ID.
1953
+ *
1954
+ * All object operations (upload, download, list, copy, move, signed URLs, …)
1955
+ * are performed through the returned client.
1956
+ *
1957
+ * @param bucketId The Ragable bucket ID obtained from `buckets.list()` or `buckets.create()`.
1958
+ */
1959
+ from(bucketId: string): StorageBucketClient;
1960
+ }
1961
+
1664
1962
  declare class Ragable {
1665
1963
  readonly shift: ShiftClient;
1666
1964
  readonly agents: AgentsClient;
1965
+ readonly storage: StorageClient;
1667
1966
  readonly infrastructure: {
1668
1967
  shift: ShiftClient;
1669
1968
  };
@@ -1673,4 +1972,4 @@ declare function createClient(options: RagableClientOptions): Ragable;
1673
1972
  declare function createClient<Database extends RagableDatabase = DefaultRagableDatabase, AuthUser extends object = DefaultAuthUser>(options: RagableBrowserClientOptions): RagableBrowser<Database, AuthUser>;
1674
1973
  declare function createRagableServerClient(options: RagableClientOptions): Ragable;
1675
1974
 
1676
- export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, 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, type AgentSummary, AgentsClient, 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, type CollectionReturnMode, type CollectionRowData, type CollectionRowWithMeta, type CollectionWhere, type ColumnName, type ColumnValue, CookieStorageAdapter, DEFAULT_RAGABLE_API_BASE, type DefaultAuthUser, type DefaultRagableDatabase, type FormatContextOptions, type HttpMethod, type Json, LocalStorageAdapter, MemoryStorageAdapter, type PostgRESTFetch, type PostgRESTFetchParams, PostgrestDeleteReturningBuilder, PostgrestDeleteRootBuilder, PostgrestInsertReturningBuilder, PostgrestInsertRootBuilder, PostgrestInsertSdkErrorReturning, PostgrestInsertSdkErrorRoot, type PostgrestResult, PostgrestSelectBuilder, PostgrestTableApi, PostgrestUpdateReturningBuilder, PostgrestUpdateRootBuilder, type PostgrestUpsertOptions, PostgrestUpsertReturningBuilder, PostgrestUpsertRootBuilder, type RagClientForPipeline, type RagPipeline, type RagPipelineOptions, Ragable, RagableAbortError, RagableAuth, type RagableAuthConfig, RagableBrowser, RagableBrowserAgentsClient, RagableBrowserAuthClient, type RagableBrowserClientOptions, RagableBrowserDatabaseClient, type RagableClientOptions, type RagableDatabase, RagableError, RagableNetworkError, RagableRequestClient, type RagableResult, RagableSdkError, type RagableTableDefinition, type RagableTableNames, RagableTimeoutError, type RequestOptions, type RetrieveParams, type RetryOptions, type RunAgentChatStreamOptions, type RunQuery, type SessionStorage, SessionStorageAdapter, type ShiftAddDocumentParams, ShiftClient, type ShiftCreateIndexParams, type ShiftEntry, type ShiftIndex, type ShiftIngestResponse, type ShiftListEntriesParams, type ShiftListEntriesResponse, type ShiftSearchParams, type ShiftSearchResult, type ShiftUpdateIndexParams, type ShiftUploadFileParams, type ShiftUploadableFile, type SseJsonEvent, type SupabaseCompatSession, type TableInsertRow, type TableRow, type TableUpdatePatch, type Tables, type TablesInsert, type TablesUpdate, Transport, type TransportOptions, type TransportRequest, type WhereInput, type WhereOperatorObject, asPostgrestResponse, assertPostgrestSuccess, bindFetch, collectAssistantTextFromUiSegments, collectionRecordToRowWithMeta, collectionRecordsToRowWithMeta, createBrowserClient, createClient, createRagPipeline, createRagableBrowserClient, createRagableServerClient, detectStorage, effectiveDataAuth, extractErrorMessage, finalizeAgentChatUiTurn, foldAgentStreamIntoUiSegments, formatPostgrestError, formatRetrievalContext, formatSdkError, generateIdempotencyKey, isIncompleteAgentStreamError, normalizeBrowserApiBase, parseAgentStreamAgentInfo, parseAgentStreamDone, parseSseDataLine, parseTransportResponse, readSseStream, runAgentChatStream, runAgentChatStreamForUi, runAgentChatStreamLenient, toRagableResult, unwrapPostgrest };
1975
+ export { type AgentChatMessage, type AgentChatParams, type AgentChatResult, 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, type AgentSummary, AgentsClient, 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, type CollectionReturnMode, type CollectionRowData, type CollectionRowWithMeta, type CollectionWhere, type ColumnName, type ColumnValue, CookieStorageAdapter, DEFAULT_RAGABLE_API_BASE, type DefaultAuthUser, type DefaultRagableDatabase, type FormatContextOptions, type HttpMethod, type Json, LocalStorageAdapter, MemoryStorageAdapter, type PostgRESTFetch, type PostgRESTFetchParams, PostgrestDeleteReturningBuilder, PostgrestDeleteRootBuilder, PostgrestInsertReturningBuilder, PostgrestInsertRootBuilder, PostgrestInsertSdkErrorReturning, PostgrestInsertSdkErrorRoot, type PostgrestResult, PostgrestSelectBuilder, PostgrestTableApi, PostgrestUpdateReturningBuilder, PostgrestUpdateRootBuilder, type PostgrestUpsertOptions, PostgrestUpsertReturningBuilder, PostgrestUpsertRootBuilder, type RagClientForPipeline, type RagPipeline, type RagPipelineOptions, Ragable, RagableAbortError, RagableAuth, type RagableAuthConfig, RagableBrowser, RagableBrowserAgentsClient, RagableBrowserAuthClient, type RagableBrowserClientOptions, RagableBrowserDatabaseClient, type RagableClientOptions, type RagableDatabase, RagableError, RagableNetworkError, RagableRequestClient, type RagableResult, RagableSdkError, type RagableTableDefinition, type RagableTableNames, RagableTimeoutError, type RequestOptions, type RetrieveParams, type RetryOptions, type RunAgentChatStreamOptions, type RunQuery, type SessionStorage, SessionStorageAdapter, type ShiftAddDocumentParams, ShiftClient, type ShiftCreateIndexParams, type ShiftEntry, type ShiftIndex, type ShiftIngestResponse, type ShiftListEntriesParams, type ShiftListEntriesResponse, type ShiftSearchParams, type ShiftSearchResult, type ShiftUpdateIndexParams, type ShiftUploadFileParams, type ShiftUploadableFile, type SseJsonEvent, type StorageBucket, type StorageBucketClient, type StorageBucketCorsEntry, type StorageBucketItem, type StorageBucketSettings, type StorageBulkDeleteResult, StorageClient, type StorageCopyMoveParams, type StorageDownloadParams, type StorageDownloadResult, type StorageListBucketsParams, type StorageListContentsParams, type StorageListContentsResult, type StorageObjectMetadata, type StorageSignedDownloadUrlParams, type StorageSignedDownloadUrlResult, type StorageSignedUploadUrlParams, type StorageSignedUploadUrlResult, type StorageUpdateBucketSettingsParams, type StorageUpdateMetadataParams, type StorageUploadParams, type StorageUploadResult, type StorageUploadableFile, type SupabaseCompatSession, type TableInsertRow, type TableRow, type TableUpdatePatch, type Tables, type TablesInsert, type TablesUpdate, Transport, type TransportOptions, type TransportRequest, type WhereInput, type WhereOperatorObject, asPostgrestResponse, assertPostgrestSuccess, bindFetch, collectAssistantTextFromUiSegments, collectionRecordToRowWithMeta, collectionRecordsToRowWithMeta, createBrowserClient, createClient, createRagPipeline, createRagableBrowserClient, createRagableServerClient, detectStorage, effectiveDataAuth, extractErrorMessage, finalizeAgentChatUiTurn, foldAgentStreamIntoUiSegments, formatPostgrestError, formatRetrievalContext, formatSdkError, generateIdempotencyKey, isIncompleteAgentStreamError, normalizeBrowserApiBase, parseAgentStreamAgentInfo, parseAgentStreamDone, parseSseDataLine, parseTransportResponse, readSseStream, runAgentChatStream, runAgentChatStreamForUi, runAgentChatStreamLenient, toRagableResult, unwrapPostgrest };