@yeaft/webchat-agent 1.0.479 → 1.0.481

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "1.0.479",
3
+ "version": "1.0.481",
4
4
  "description": "Remote worker agent for Yeaft Web Code Agent — connects the native Yeaft engine, CLI providers, and workbench tools",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -6,6 +6,8 @@ import ctx from '../context.js';
6
6
  import { resolveAndValidatePath, BINARY_EXTENSIONS } from './utils.js';
7
7
  import { sendWorkbenchResult } from './request-routing.js';
8
8
 
9
+ export const MAX_WORKBENCH_PREVIEW_BYTES = 20 * 1024 * 1024;
10
+
9
11
  export async function handleReadFile(msg) {
10
12
  const { conversationId, filePath, requestId, _requestUserId, _requestClientId } = msg;
11
13
  console.log('[Agent] handleReadFile received:', { filePath, conversationId, workDir: msg.workDir });
@@ -18,7 +20,18 @@ export async function handleReadFile(msg) {
18
20
  const mimeType = BINARY_EXTENSIONS[ext];
19
21
 
20
22
  if (mimeType) {
21
- // Binary file: read as Buffer, send base64
23
+ const fileStat = await stat(resolved);
24
+ if (!msg.download && fileStat.size > MAX_WORKBENCH_PREVIEW_BYTES) {
25
+ const error = new Error(`File is too large to preview (${(fileStat.size / 1024 / 1024).toFixed(1)} MB). The preview limit is 20 MB.`);
26
+ error.code = 'FILE_PREVIEW_TOO_LARGE';
27
+ error.details = {
28
+ sizeBytes: fileStat.size,
29
+ limitBytes: MAX_WORKBENCH_PREVIEW_BYTES,
30
+ };
31
+ throw error;
32
+ }
33
+ // Binary file: read as Buffer, send base64. Downloads bypass only the
34
+ // rendering limit; the WebSocket transport still enforces its own cap.
22
35
  const buffer = await readFile(resolved);
23
36
  console.log('[Agent] Sending binary file_content:', { filePath: resolved, size: buffer.length, mimeType, conversationId });
24
37
  sendWorkbenchResult(ctx, msg, {
@@ -79,7 +92,9 @@ export async function handleReadFile(msg) {
79
92
  filePath,
80
93
  requestedFilePath: filePath,
81
94
  content: '',
82
- error: e.message
95
+ error: e.message,
96
+ errorCode: e.code || null,
97
+ errorDetails: e.details || null
83
98
  });
84
99
  }
85
100
  }