/** * Standalone Cursor GenerateImage RPC/media helper (R4 / C-IMAGE foundation). * * Integration signature: * await generateCursorImage({ * accessToken, * description, // trimmed length 1..4000 * modelId, // nonempty * timeoutMs, * maxDecodedBytes, * artifactRoot, * signal?, // aborts only the unary op; late completion ignored * callUnaryRpc?, // inject in tests; default lazily uses callCursorUnaryRpc * url?, * headers?, * }) * * Injected `callUnaryRpc` SHOULD honor `signal` by closing only that unary channel. * The lazy default threads `signal` into `callCursorUnaryRpc`, which aborts only that * unary bridge/channel, cleans the abort listener on close, ignores late completion, * and does not retry. * * Never logs description, token, base64, raw body, or image bytes. */ export declare const RUN_GENERATE_IMAGE_RPC_PATH = "/aiserver.v1.AiService/RunGenerateImage"; export declare const ACCEPTED_IMAGE_MIME_TYPES: readonly ["image/png", "image/jpeg", "image/webp"]; export type AcceptedImageMimeType = (typeof ACCEPTED_IMAGE_MIME_TYPES)[number]; export type CursorGenerateImageErrorCode = "CAPABILITY_DISABLED" | "PERMISSION_DENIED" | "MODEL_RESTRICTED" | "RPC_TIMEOUT" | "RPC_ERROR" | "INVALID_MIME" | "INVALID_BASE64" | "IMAGE_TOO_LARGE" | "PERSIST_FAILED" | "ABORTED"; export declare class CursorGenerateImageError extends Error { readonly code: CursorGenerateImageErrorCode; constructor(code: CursorGenerateImageErrorCode, message: string); } export interface CursorUnaryRpcCallOptions { accessToken: string; rpcPath: string; requestBody: Uint8Array; url?: string; timeoutMs?: number; headers?: Record; signal?: AbortSignal; } export type CursorUnaryRpcCaller = (options: CursorUnaryRpcCallOptions) => Promise<{ body: Uint8Array; exitCode: number; timedOut: boolean; }>; export interface GenerateCursorImageOptions { accessToken: string; description: string; modelId: string; timeoutMs: number; maxDecodedBytes: number; artifactRoot: string; signal?: AbortSignal; /** Injected unary caller; required for tests. Default lazily uses `callCursorUnaryRpc`. */ callUnaryRpc?: CursorUnaryRpcCaller; url?: string; headers?: Record; } export interface GenerateCursorImageAttachment { type: "file"; mime: AcceptedImageMimeType; url: string; filename: string; } export interface GenerateCursorImageResult { output: string; path: string; mimeType: AcceptedImageMimeType; sizeBytes: number; sha256: string; base64: string; attachment: GenerateCursorImageAttachment; } export interface RunGenerateImageSuccess { kind: "success"; imageData: string; mimeType: string; } export interface RunGenerateImageFailure { kind: "error"; error: string; modelRestricted: boolean; } export type RunGenerateImageDecoded = RunGenerateImageSuccess | RunGenerateImageFailure; declare function decodeConnectUnaryBody(payload: Uint8Array): Uint8Array; /** * Encode aiserver.v1.RunGenerateImageRequest. * Fields: description=1, reference_images=2 (MVP: omitted/empty), model_id=3, max_mode=4 (false omitted). */ export declare function encodeRunGenerateImageRequest(args: { description: string; modelId: string; maxMode?: boolean; }): Uint8Array; /** Decode aiserver.v1.RunGenerateImageResponse (raw or Connect-framed). */ export declare function decodeRunGenerateImageResponse(payload: Uint8Array): RunGenerateImageDecoded; /** Encode a success response for fixtures/tests. */ export declare function encodeRunGenerateImageSuccessResponse(args: { imageData: string; mimeType: string; }): Uint8Array; /** Encode an error response for fixtures/tests. */ export declare function encodeRunGenerateImageErrorResponse(args: { error: string; modelRestricted?: boolean; }): Uint8Array; /** * Strict standard base64: alphabet + padding only, length multiple of 4, * exact round-trip, nonzero decoded bytes. */ export declare function decodeStrictImageBase64(value: string): Buffer; export declare function generateCursorImage(options: GenerateCursorImageOptions): Promise; export declare const __test: { encodeRunGenerateImageRequest: typeof encodeRunGenerateImageRequest; encodeRunGenerateImageSuccessResponse: typeof encodeRunGenerateImageSuccessResponse; encodeRunGenerateImageErrorResponse: typeof encodeRunGenerateImageErrorResponse; decodeRunGenerateImageResponse: typeof decodeRunGenerateImageResponse; decodeStrictImageBase64: typeof decodeStrictImageBase64; decodeConnectUnaryBody: typeof decodeConnectUnaryBody; writeStringField(field: number, value: string): number[]; readWireTags(bytes: Uint8Array): Array<{ field: number; wireType: number; }>; }; export {};