mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-24 04:47:03 +00:00
feat(web): support local Markdown images in conversation messages (#2215)
* fix(web): resolve relative Markdown assets in file previews * fix(web): harden standalone Markdown asset resolution * fix(web): preserve Markdown URI and image policies * fix(web): route Markdown file links through app history * fix(web): preserve session reference navigation in previews * feat(web): support local Markdown images in conversation messages * fix(cli): bound session file reads * fix(cli): avoid blocking bounded reads on FIFOs * test(cli): run FIFO regression with Bun * fix(hub): preserve legacy session file RPC calls * test(web): update markdown preview fixture context * fix(cli): reject symlinked session files outside workspace
This commit is contained in:
@@ -27,6 +27,7 @@ export type WorkspaceFilePathPolicy = {
|
||||
type WorkspaceReadFileRequest = {
|
||||
cwd?: unknown
|
||||
path?: unknown
|
||||
maxBytes?: unknown
|
||||
}
|
||||
|
||||
type WorkspaceListDirectoryRequest = {
|
||||
@@ -180,7 +181,11 @@ export function registerWorkspaceFileHandlers(
|
||||
if (!stats.isFile()) {
|
||||
throw new Error('Path is not a regular file')
|
||||
}
|
||||
const buffer = await readBoundedRegularFile(resolved.path, MAX_WORKSPACE_FILE_BYTES)
|
||||
const requestedMaxBytes = typeof data.maxBytes === 'number' && Number.isFinite(data.maxBytes) && data.maxBytes > 0
|
||||
? Math.floor(data.maxBytes)
|
||||
: MAX_WORKSPACE_FILE_BYTES
|
||||
const maxBytes = Math.min(requestedMaxBytes, MAX_WORKSPACE_FILE_BYTES)
|
||||
const buffer = await readBoundedRegularFile(resolved.path, maxBytes)
|
||||
return {
|
||||
success: true,
|
||||
content: buffer.toString('base64'),
|
||||
|
||||
Reference in New Issue
Block a user