/** * Asset API - WebSocket-based asset serving * * Handles asset requests from the Connect web UI: * - asset.list - List all assets * - asset.get - Get asset bytes (streamed) * - asset.preview - Get preview metadata + thumbnail * - asset.group - Get assets by group * - view.get - Get ViewSpec */ import { AssetManifest, AssetPreview, ViewSpec, ClientAssetManifest } from './assets.js'; export interface AssetRequest { type: 'asset.list' | 'asset.get' | 'asset.preview' | 'asset.group' | 'view.get' | 'view.list'; requestId: string; assetId?: string; groupId?: string; viewId?: string; } export interface AssetListResponse { type: 'asset.list'; requestId: string; assets: ClientAssetManifest[]; } export interface AssetGetResponse { type: 'asset.get'; requestId: string; assetId: string; data: string; mime: string; size: number; } export interface AssetPreviewResponse { type: 'asset.preview'; requestId: string; assetId: string; manifest: ClientAssetManifest; preview: AssetPreview | null; } export interface AssetGroupResponse { type: 'asset.group'; requestId: string; groupId: string; assets: ClientAssetManifest[]; previews: (AssetPreview | null)[]; } export interface ViewGetResponse { type: 'view.get'; requestId: string; view: ViewSpec | null; } export interface ViewListResponse { type: 'view.list'; requestId: string; views: ViewSpec[]; } export interface AssetErrorResponse { type: 'asset.error'; requestId: string; error: string; } export type AssetResponse = AssetListResponse | AssetGetResponse | AssetPreviewResponse | AssetGroupResponse | ViewGetResponse | ViewListResponse | AssetErrorResponse; export declare function registerView(view: ViewSpec): void; export declare function getView(viewId: string): ViewSpec | undefined; export declare function getAllViews(): ViewSpec[]; /** * Handle asset request from WebSocket */ export declare function handleAssetRequest(request: AssetRequest): Promise; /** * Build gallery state for WebSocket broadcast * This replaces the old extractFilesFromOutput approach */ export interface GalleryState { assets: AssetManifest[]; previews: Map; groups: Map; views: ViewSpec[]; } export declare function buildGalleryState(): GalleryState; /** * Convert gallery state to WebSocket message format * Strips absolute paths from assets for client safety */ export declare function galleryStateToMessage(state: GalleryState): { type: 'gallery_state'; assets: ClientAssetManifest[]; previews: { [key: string]: AssetPreview; }; groups: { [key: string]: string[]; }; views: ViewSpec[]; };