import { type AdminIngressStatusResponse, type AdminSyncStatusResponse, type BulkWriteInput, type BulkWriteResponse, type BackendStatusResponse, type AckResponse, type CommitForkInput, type CommitForkResponse, type CreateForkInput, type DeleteFileInput, type DeadLetterItem, type DeadLetterFeedResponse, type DeleteWebhookOptions, type DiscardForkInput, type EventFeedResponse, type ExportJsonResponse, type ExportOptions, type FileQueryResponse, type FileReadResponse, type FilesystemEvent, type GetEventsOptions, type GetAdminIngressStatusOptions, type GetAdminSyncStatusOptions, type GetOperationsOptions, type GetSyncDeadLettersOptions, type GetSyncIngressStatusOptions, type GetSyncStatusOptions, type GetWebhookDeadLettersOptions, type ListWebhooksOptions, type ListTreeOptions, type OperationFeedResponse, type OperationStatusResponse, type QueuedResponse, type ResourceAtEventResult, type ReadFileInput, type QueryFilesOptions, type RegisterWebhookInput, type RegisterWebhookResponse, type RelayFileReadCacheOptions, type Subscription, type SyncIngressStatusResponse, type SyncProviderStatus, type SyncStatusResponse, type TreeResponse, type WriteFileInput, type WriteQueuedResponse, type IngestWebhookInput, type WritebackItem, type WebhookDeliveryDeadLetterFeedResponse, type WebhookSubscription, type AckWritebackInput, type AckWritebackResponse, type SweepWritebackDraftsInput, type SweepWritebackDraftsResponse, type ChangeEvent, type ChangeLogQueryResult, type ChangeStreamConnection, type ChangeStreamConnectionOptions, type SubscribeOptions, type WaitForDataOptions } from "./types.js"; import type { ForkHandle } from "@relayfile/core"; /** * Bearer token or token factory used for Relayfile API requests. * * When you mint JWTs for Relayfile, the server expects claims like: * `{ workspace_id: "ws_123", agent_name: "review-bot", aud: ["relayfile"] }` */ export type AccessTokenProvider = string | (() => string | Promise); export interface RelayFileRetryOptions { maxRetries?: number; baseDelayMs?: number; maxDelayMs?: number; jitterRatio?: number; } export interface RelayFileChangeLogOptions { /** * Local retained-change cache TTL in milliseconds. * * This mirrors the backend retention window opportunistically for delivered * or replayed events; durable change-log retention remains a server-side * responsibility. */ retentionMs?: number; /** Maximum number of retained change entries to keep per workspace locally. */ maxEntries?: number; } /** Default base URL for the hosted Relayfile API */ export declare const DEFAULT_RELAYFILE_BASE_URL = "https://api.relayfile.dev"; export interface RelayFileClientOptions { /** API base URL. Defaults to https://api.relayfile.dev */ baseUrl?: string; /** * Bearer token or token factory for SDK requests. * * Relayfile-authenticated JWTs should include `workspace_id`, `agent_name`, * and `aud` containing `relayfile`. */ token: AccessTokenProvider; fetchImpl?: typeof fetch; userAgent?: string; retry?: RelayFileRetryOptions; changeLog?: RelayFileChangeLogOptions; /** * Client-side file read cache with in-flight deduplication. * Enabled by default. Set to `false` to disable. * Active change streams automatically evict paths on remote mutations. */ readCache?: false | RelayFileReadCacheOptions; } type WebSocketEventName = "event" | "error" | "open" | "close"; type WebSocketHandlerMap = { event: (event: FilesystemEvent) => void; error: (event: Event | Error) => void; open: (event: Event) => void; close: (event: CloseEvent) => void; }; export interface WebSocketConnection { close(code?: number, reason?: string): void; on(event: TEventName, handler: WebSocketHandlerMap[TEventName]): () => void; } export interface ConnectWebSocketOptions { token?: string; from?: "now" | "legacy"; cursor?: string; paths?: string[]; onEvent?: (event: FilesystemEvent) => void; } interface ProactiveRequestContext { workspaceId: string; token?: string; } export declare class RelayFileClient { private readonly baseUrl; private readonly tokenProvider; private readonly fetchImpl; private readonly userAgent?; private readonly retryOptions; constructor(options: RelayFileClientOptions); /** * Resolve the current access token via the configured token provider. * * Components that need a fresh JWT for out-of-band auth (the WebSocket * upgrade handshake, signed URLs, downstream services that proxy Relayfile * tokens) should call this on every connection rather than caching the * value, so token rotation/refresh propagates without restart. * * Always returns a Promise so callers don't need to special-case the * sync-vs-async tokenProvider shapes. */ getToken(): Promise; /** * Return the normalized API base URL this client was constructed with. * * onWrite/sync consumers use this so an explicit RelayFileClient remains the * source of truth for both HTTP and WebSocket traffic instead of letting a * process-level env override silently redirect only the WS side. */ getBaseUrl(): string; listTree(workspaceId: string, options?: ListTreeOptions): Promise; readFile(workspaceId: string, path: string, correlationId?: string, signal?: AbortSignal): Promise; readFile(input: ReadFileInput): Promise; queryFiles(workspaceId: string, options?: QueryFilesOptions): Promise; writeFile(input: WriteFileInput): Promise; bulkWrite(input: BulkWriteInput): Promise; deleteFile(input: DeleteFileInput): Promise; createFork(input: CreateForkInput): Promise; discardFork(input: DiscardForkInput): Promise; commitFork(input: CommitForkInput): Promise; getEvents(workspaceId: string, options?: GetEventsOptions): Promise; subscribe(globs: string[], onChange: (event: ChangeEvent) => void, options?: SubscribeOptions): Subscription; open(options: ChangeStreamConnectionOptions): ChangeStreamConnection; getResourceAtEvent(eventId: string, context?: ProactiveRequestContext): Promise; listChangesSince(isoTimestamp: string, context?: ProactiveRequestContext): Promise; listLastNChanges(limit: number, context?: ProactiveRequestContext): Promise; exportWorkspace(options: ExportOptions): Promise; connectWebSocket(workspaceId: string, options?: ConnectWebSocketOptions): WebSocketConnection; getOp(workspaceId: string, opId: string, correlationId?: string, signal?: AbortSignal): Promise; listOps(workspaceId: string, options?: GetOperationsOptions): Promise; replayOp(workspaceId: string, opId: string, correlationId?: string, signal?: AbortSignal): Promise; replayAdminEnvelope(envelopeId: string, correlationId?: string, signal?: AbortSignal): Promise; replayAdminOp(opId: string, correlationId?: string, signal?: AbortSignal): Promise; getBackendStatus(correlationId?: string, signal?: AbortSignal): Promise; getAdminIngressStatus(optionsOrCorrelationId?: GetAdminIngressStatusOptions | string, signal?: AbortSignal): Promise; getAdminSyncStatus(optionsOrCorrelationId?: GetAdminSyncStatusOptions | string, signal?: AbortSignal): Promise; getSyncStatus(workspaceId: string, options?: GetSyncStatusOptions): Promise; /** * Wait until a provider is safe to read from the data plane. * * Cloud-managed syncs report first-sync completion through `ready: true` or * `status: "ready"`. OSS self-host `/sync/status` uses `healthy` for provider * health, including empty freshly filtered provider rows, so this method only * treats OSS `healthy` as data-ready after processed-ingest progress appears * on the status row (`cursor` or `watermarkTs`). For custom OSS ingest flows, * gate on your own ingest completion when you need stronger domain-specific * proof than provider progress. */ waitForData(workspaceId: string, provider: string, options?: WaitForDataOptions): Promise; getSyncIngressStatus(workspaceId: string, options?: GetSyncIngressStatusOptions): Promise; getSyncDeadLetters(workspaceId: string, options?: GetSyncDeadLettersOptions): Promise; getSyncDeadLetter(workspaceId: string, envelopeId: string, correlationId?: string, signal?: AbortSignal): Promise; replaySyncDeadLetter(workspaceId: string, envelopeId: string, correlationId?: string, signal?: AbortSignal): Promise; ackSyncDeadLetter(workspaceId: string, envelopeId: string, correlationId?: string, signal?: AbortSignal): Promise; triggerSyncRefresh(workspaceId: string, provider: string, reason?: string, correlationId?: string, signal?: AbortSignal): Promise; ingestWebhook(input: IngestWebhookInput): Promise; registerWebhook(input: RegisterWebhookInput): Promise; listWebhooks(workspaceId: string, options?: ListWebhooksOptions): Promise; deleteWebhook(workspaceId: string, subscriptionId: string, options?: DeleteWebhookOptions): Promise; getWebhookDeadLetters(workspaceId: string, options?: GetWebhookDeadLettersOptions): Promise; replayWebhookDeadLetter(workspaceId: string, deliveryId: string, correlationId?: string, signal?: AbortSignal): Promise; listPendingWritebacks(workspaceId: string, correlationId?: string, signal?: AbortSignal): Promise; ackWriteback(input: AckWritebackInput): Promise; /** * One-time residue sweep for accumulated writeback drafts (issue #242). * Dry run unless `apply` is true; classification-exempt service-side. */ sweepWritebackDrafts(input: SweepWritebackDraftsInput): Promise; private cacheWireChangeEvent; private primeReplayCache; private resolveWorkspaceId; private request; private performRequest; private shouldRetryStatus; private shouldRetryError; private computeRetryDelayMs; private parseRetryAfterMs; private sleep; private readPayload; private throwForError; } export {};