fix(tools): preserve complete bounded presentations

This commit is contained in:
Tianyi Cui
2026-07-22 00:55:59 +08:00
parent 0dfd9545a6
commit 63d48593cc
9 changed files with 52 additions and 23 deletions

View File

@@ -86,6 +86,7 @@ describe('buildWindow', () => {
it('caps output at a custom maxBytes', async () => {
const result = await buildWindow(whole('aaaa\nbbbb\ncccc'), { offset: 1, limit: 10, maxLineLength: 2000, maxBytes: 9 }, 'f')
expect(result.lines.map(l => l.text)).toEqual(['aaaa', 'bbbb'])
expect(result.totalLines).toBe(3)
expect(result.truncatedByBytes).toBe(true)
})
})
@@ -105,6 +106,7 @@ describe('buildWindow', () => {
it('caps output bytes mid-stream', async () => {
const big = Array.from({ length: 2000 }, () => 'y'.repeat(100)).join('\n')
const result = await buildWindow(chunked(big, 512), READ_ALL, 'f')
expect(result.totalLines).toBe(2000)
expect(result.truncatedByBytes).toBe(true)
})

View File

@@ -572,6 +572,9 @@ describe('read caps are plugin config', () => {
const { ctx, fs } = await setupWith({ readMaxBytes: 9 })
fs.files.set('key:a.txt', 'aaaa\nbbbb\ncccc')
const result = await call(ctx, 'read', { file_path: 'a.txt' })
expect(result.isError).toBe(false)
if (result.isError) throw new Error('expected read success')
expect(result.value).toMatchObject({ totalLines: 3 })
expect(text(result)).toContain('Output capped.')
expect(text(result)).not.toContain('cccc')
})