import { type ArtifactUri } from '@xopcai/endpoint-tools-protocol'; export declare const SANDBOX_ARTIFACT_MAX_BYTES: number; export interface ArtifactMetadata { artifactUri: ArtifactUri; sha256: string; size: number; mimeType: string; createdAt: number; } export interface PresignedUploadSlot { slotId: string; uploadUrl: string; expiresAt: number; maxBytes: number; } export interface PresignedDownloadGrant { artifactUri: ArtifactUri; downloadUrl: string; expectedSha256: string; expectedSize: number; mimeType: string; expiresAt: number; } /** * Pluggable artifact broker port (ADR 0004): * - Standalone / dev Gateway uses `LocalGatewayArtifactBroker` (content-addressed disk + HTTP presigned tokens). * - `xopc-cloud` injects an S3 / R2 / OSS presigned-URL broker without changing Agent tools. */ export interface ArtifactBroker { createUploadSlot(params?: { maxBytes?: number; ttlMs?: number; endpointId?: string; }): Promise; finalizeUpload(slotId: string, reported: { artifactUri: string; sha256: string; size: number; mimeType: string; }): Promise; createDownloadGrant(artifactUri: string, params?: { ttlMs?: number; endpointId?: string; }): Promise; getMetadata(artifactUri: string): Promise; } export declare class ArtifactBrokerError extends Error { readonly code: 'ARTIFACT_TOKEN_INVALID' | 'ARTIFACT_TOKEN_EXPIRED' | 'ARTIFACT_TOO_LARGE' | 'ARTIFACT_UPLOAD_INCOMPLETE' | 'ARTIFACT_INTEGRITY_MISMATCH' | 'ARTIFACT_NOT_FOUND'; constructor(code: 'ARTIFACT_TOKEN_INVALID' | 'ARTIFACT_TOKEN_EXPIRED' | 'ARTIFACT_TOO_LARGE' | 'ARTIFACT_UPLOAD_INCOMPLETE' | 'ARTIFACT_INTEGRITY_MISMATCH' | 'ARTIFACT_NOT_FOUND', message: string); } export declare class LocalGatewayArtifactBroker implements ArtifactBroker { private readonly options; private readonly casDir; private readonly stagingDir; private readonly metaDir; private readonly uploadSlotsById; private readonly uploadSlotsByToken; private readonly downloadGrantsByToken; private readonly metadataCache; constructor(options: { rootDir: string; resolveBaseUrl: (context?: { endpointId?: string; }) => string; }); private pruneExpired; private blobPath; private metaPath; createUploadSlot(params?: { maxBytes?: number; ttlMs?: number; endpointId?: string; }): Promise; /** * Called by the Gateway HTTP `PUT /api/endpoint-artifacts/presigned/:token` route. * Consumes the one-time upload token and records the server-verified SHA-256 digest. */ receivePresignedUpload(params: { token: string; bytes: Uint8Array; mimeType?: string; now?: number; }): Promise<{ sha256: string; size: number; }>; getUploadSlotMaxBytes(token: string, now?: number): number | undefined; finalizeUpload(slotId: string, reported: { artifactUri: string; sha256: string; size: number; mimeType: string; }): Promise; getMetadata(rawUri: string): Promise; createDownloadGrant(rawUri: string, params?: { ttlMs?: number; endpointId?: string; }): Promise; readPresignedDownload(token: string, now?: number): Promise<{ bytes: Buffer; metadata: ArtifactMetadata; }>; clearStaging(): Promise; }