File size: 1,014 Bytes
ea7a2bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { afterEach, describe, expect, test } from 'bun:test'
import {
  CYBER_RISK_MITIGATION_REMINDER,
  FileReadTool,
} from './FileReadTool.js'

const ENV_KEY = 'CLAUDE_CODE_EVAL_DISABLE_FILE_READ_MALWARE_REMINDER'
const previous = process.env[ENV_KEY]

afterEach(() => {
  if (previous === undefined) {
    delete process.env[ENV_KEY]
  } else {
    process.env[ENV_KEY] = previous
  }
})

describe('FileReadTool eval harness rendering', () => {
  test('suppresses the malware reminder when source-native eval disables it', () => {
    process.env[ENV_KEY] = '1'
    const block = FileReadTool.mapToolResultToToolResultBlockParam(
      {
        type: 'text',
        file: {
          filePath: 'public/README.md',
          content: '# Demo\n',
          numLines: 1,
          startLine: 1,
          totalLines: 1,
        },
      },
      'tooluse_123',
    )

    expect(JSON.stringify(block)).not.toContain(CYBER_RISK_MITIGATION_REMINDER)
    expect(JSON.stringify(block)).toContain('# Demo')
  })
})