MCPcopy Create free account
hub / github.com/tiann/hapi / registerGeneratedImageFromPath

Function registerGeneratedImageFromPath

cli/src/codex/codexRemoteLauncher.ts:30–56  ·  view source on GitHub ↗
(args: { id: string; path: string; fileName?: string | null })

Source from the content-addressed store, hash-verified

28
29
30async 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
58type HappyServer = Awaited<ReturnType<typeof buildHapiMcpBridge>>['server'];
59type QueuedMessage = { message: string; mode: EnhancedMode; isolate: boolean; hash: string };

Callers 1

handleCodexEventMethod · 0.85

Calls 3

detectImageMimeTypeFunction · 0.90
registerGeneratedImageFunction · 0.90
debugMethod · 0.80

Tested by

no test coverage detected