/** * @fabric-harness/sdk/cloudflare — minimal Cloudflare helpers bundled * directly into the SDK so that lite-mode agents on Cloudflare Workers * can use R2-backed filesystem sources with a single install. * * For the full Cloudflare Workers + Sandbox + Durable Object session * store surface, install `@fabric-harness/cloudflare` separately. */ import type { FilesystemSource } from './filesystem-source.js'; export interface CloudflareR2ObjectBodyLike { arrayBuffer(): Promise; } export interface CloudflareR2ListResultLike { objects: Array<{ key: string; size?: number; uploaded?: Date | string; customMetadata?: Record; }>; truncated?: boolean; cursor?: string; } export interface CloudflareR2BucketLike { get(key: string): Promise; list?(options?: { prefix?: string; cursor?: string; limit?: number; }): Promise; } export interface R2FilesystemSourceOptions { /** Prefix to enumerate in the bucket, for example `knowledge-base/`. */ prefix?: string; /** Optional stable source name used in logs/telemetry. */ name?: string; /** Remove this prefix from mounted file paths. Defaults to `prefix`. */ stripPrefix?: string; /** Include only selected object keys. */ include?: (key: string) => boolean; /** Max list page size when the runtime supports it. */ pageSize?: number; } /** * Read Cloudflare R2 objects as a Fabric filesystem source. Mount it * with `withFilesystemSources()` (or `getVirtualSandbox(...)`) so * agents can grep/read R2-backed knowledge bases through the normal * sandbox tools. * * ```ts * import { defineAgent, getVirtualSandbox } from '@fabric-harness/sdk'; * import { r2FilesystemSource } from '@fabric-harness/sdk/cloudflare'; * * export default defineAgent({ * run: async ({ init, payload, env }) => { * const sandbox = getVirtualSandbox(r2FilesystemSource(env.SUPPORT_KB)); * const session = await (await init({ sandbox })).session(); * const message = typeof payload === 'object' && payload && 'message' in payload ? String((payload as { message: unknown }).message ?? '') : ''; * return { reply: await session.prompt(message) }; * }, * }); * ``` */ export declare function r2FilesystemSource(bucket: CloudflareR2BucketLike, options?: R2FilesystemSourceOptions): FilesystemSource; //# sourceMappingURL=cloudflare-source.d.ts.map