(args: { id: string; path: string; fileName?: string | null })
| 28 | |
| 29 | |
| 30 | async function registerGeneratedImageFromPath(args: { id: string; path: string; fileName?: string | null }): Promise<ReturnType<typeof registerGeneratedImage> | null> { |
| 31 | try { |
| 32 | const info = await lstat(args.path); |
| 33 | if (!info.isFile()) { |
| 34 | throw new Error('Path is not a regular file'); |
| 35 | } |
| 36 | const maxImageBytes = 25 * 1024 * 1024; |
| 37 | if (info.size > maxImageBytes) { |
| 38 | throw new Error('Image is too large to display inline'); |
| 39 | } |
| 40 | const bytes = await readFile(args.path); |
| 41 | const mimeType = detectImageMimeType(bytes); |
| 42 | if (!mimeType) { |
| 43 | throw new Error('Unsupported image content'); |
| 44 | } |
| 45 | return registerGeneratedImage({ |
| 46 | id: args.id, |
| 47 | path: args.path, |
| 48 | fileName: args.fileName, |
| 49 | mimeType, |
| 50 | bytes |
| 51 | }); |
| 52 | } catch (error) { |
| 53 | logger.debug('[CodexRemoteLauncher] Failed to register generated image:', error instanceof Error ? error.message : String(error)); |
| 54 | return null; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | type HappyServer = Awaited<ReturnType<typeof buildHapiMcpBridge>>['server']; |
| 59 | type QueuedMessage = { message: string; mode: EnhancedMode; isolate: boolean; hash: string }; |
no test coverage detected