@yeaft/webchat-agent 1.0.654 → 1.0.656

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.654",
3
+ "version": "1.0.656",
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",
@@ -8,7 +8,8 @@ import { resolveAndValidatePath, BINARY_EXTENSIONS, VIDEO_EXTENSIONS } from './u
8
8
  import { resolveWorkItemPath } from './work-item-path.js';
9
9
  import { sendWorkbenchResult } from './request-routing.js';
10
10
 
11
- export const MAX_WORKBENCH_PREVIEW_BYTES = 20 * 1024 * 1024;
11
+ export const MAX_WORKBENCH_PREVIEW_BYTES = 100 * 1024 * 1024;
12
+ const MAX_RESPONSE_IMAGE_PREVIEW_BYTES = 20 * 1024 * 1024;
12
13
  export const WORKBENCH_FILE_CHUNK_BYTES = 1024 * 1024;
13
14
  export const WORKBENCH_VIDEO_CHUNK_BYTES = 1024 * 1024;
14
15
 
@@ -24,11 +25,11 @@ export function isBinaryFileContent(buffer) {
24
25
  }
25
26
  }
26
27
 
27
- function assertPreviewSize(size) {
28
- if (size <= MAX_WORKBENCH_PREVIEW_BYTES) return;
29
- const error = new Error(`File is too large to transfer (${(size / 1024 / 1024).toFixed(1)} MB). The file limit is 20 MB.`);
28
+ function assertPreviewSize(size, limitBytes) {
29
+ if (size <= limitBytes) return;
30
+ const error = new Error(`File is too large to transfer (${(size / 1024 / 1024).toFixed(1)} MB). The file limit is ${limitBytes / 1024 / 1024} MB.`);
30
31
  error.code = 'FILE_PREVIEW_TOO_LARGE';
31
- error.details = { sizeBytes: size, limitBytes: MAX_WORKBENCH_PREVIEW_BYTES };
32
+ error.details = { sizeBytes: size, limitBytes };
32
33
  throw error;
33
34
  }
34
35
 
@@ -219,10 +220,13 @@ export async function handleReadFile(msg) {
219
220
  error.code = 'VIDEO_STREAM_REQUIRED';
220
221
  throw error;
221
222
  }
222
- let mimeType = BINARY_EXTENSIONS[ext];
223
+ // Automatic response images retain their smaller preview budget.
224
+ const limitBytes = msg.responseImagePreview ? MAX_RESPONSE_IMAGE_PREVIEW_BYTES : MAX_WORKBENCH_PREVIEW_BYTES;
225
+ // Downloads use byte-preserving chunks even for large UTF-8 text files.
226
+ let mimeType = BINARY_EXTENSIONS[ext] || (msg.download === true ? 'application/octet-stream' : undefined);
223
227
  const fileStat = await stat(resolved);
224
228
  if (!fileStat.isFile()) throw new Error('Path is not a regular file.');
225
- if (mimeType) assertPreviewSize(fileStat.size);
229
+ if (mimeType) assertPreviewSize(fileStat.size, limitBytes);
226
230
  // Keep the existing text-file size behavior. Unknown binary files are
227
231
  // classified from a bounded prefix before allocating their full contents.
228
232
  if (!mimeType) {
@@ -238,14 +242,14 @@ export async function handleReadFile(msg) {
238
242
  catch { invalidUtf8 = true; }
239
243
  if (invalidUtf8 || prefix.some(byte => byte === 0 || (byte < 32 && ![9, 10, 12, 13].includes(byte)))) {
240
244
  mimeType = 'application/octet-stream';
241
- assertPreviewSize(fileStat.size);
245
+ assertPreviewSize(fileStat.size, limitBytes);
242
246
  }
243
247
  } finally { await handle.close(); }
244
248
  }
245
249
  const buffer = await readFile(resolved);
246
250
  if (!mimeType && isBinaryFileContent(buffer)) mimeType = 'application/octet-stream';
247
251
  if (mimeType) {
248
- assertPreviewSize(buffer.length);
252
+ assertPreviewSize(buffer.length, limitBytes);
249
253
  console.log('[Agent] Sending binary file_content:', { filePath: resolved, size: buffer.length, mimeType, conversationId });
250
254
  await sendBinaryFile(msg, {
251
255
  conversationId,