trellis
Version:
Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications
49 lines • 1.7 kB
TypeScript
/**
* Trellis Realtime — Blob Client (browser-safe)
*
* Fetch-based client for the relay's content-addressed blob HTTP surface.
* No Node deps — safe under the `trellis/realtime` browser export condition.
*
* Blobs are dumb bytes keyed by hash: no graph sync, no subscriptions, no
* permission filtering. "Trellis owns semantics, the relay moves bytes."
*
* @module trellis/realtime
*/
export interface BlobClientOptions {
/**
* Base URL of the relay HTTP origin (e.g. `http://localhost:8231`).
* Trailing slash is stripped.
*/
baseUrl: string;
/**
* When true, re-hash GET responses with `crypto.subtle.digest` and reject
* mismatches (corruption / MITM). Default false.
*/
verify?: boolean;
/** Injectable fetch for tests. Default: global `fetch`. */
fetch?: typeof fetch;
}
export interface BlobClient {
/** GET /blob/:hash → bytes, or null on 404. */
get(hash: string): Promise<ArrayBuffer | null>;
/** HEAD /blob/:hash → existence. */
has(hash: string): Promise<boolean>;
/** PUT /blob → server-computed hash. Optional name/type for shared listing. */
put(bytes: ArrayBuffer | Uint8Array | Blob, meta?: {
name?: string;
contentType?: string;
}): Promise<string>;
/** GET /blob → list hashes currently on the relay. */
list(): Promise<Array<{
hash: string;
size: number;
name?: string;
contentType?: string;
uploadedAt?: number;
}>>;
}
/**
* Create a browser-safe content-addressed blob client.
*/
export declare function createBlobClient(opts: BlobClientOptions): BlobClient;
//# sourceMappingURL=blob-client.d.ts.map