cc-haha/src/server/__tests__/computer-use-requirements.test.ts
程序员阿江(Relakkes) d9bd75b5e5 fix: stabilize Computer Use dependency installs
Computer Use now rejects Python runtimes below 3.9 before running pip,
keeps Pillow on the Python 3.9-compatible 11.x line, and falls back from
the configured mirror to the default PyPI index when dependency installs
fail.

Constraint: Pillow 11.3 requires Python 3.9+, while user machines may resolve a different Python than expected
Rejected: Downgrade Pillow to the Python 3.8-compatible 10.x line | current product direction assumes modern Python installs
Confidence: high
Scope-risk: narrow
Directive: Keep runtime package ranges aligned with the setup Python minimum before changing either side
Tested: bun test src/server/__tests__/computer-use-api.test.ts src/server/__tests__/computer-use-requirements.test.ts src/server/__tests__/computer-use-python.test.ts src/utils/computerUse/pipInstall.test.ts
Tested: bun run check:server
Tested: bun run check:coverage
Tested: bun run check:policy
Not-tested: Real Windows 10 machine dependency install against the reported user environment
2026-05-22 19:16:45 +08:00

24 lines
985 B
TypeScript

import { describe, expect, test } from 'bun:test'
import darwinRequirements from '../../../runtime/requirements.txt' with { type: 'text' }
import win32Requirements from '../../../runtime/requirements-win.txt' with { type: 'text' }
function findRequirement(requirements: string, packageName: string): string | undefined {
return requirements
.split(/\r?\n/)
.map(line => line.trim())
.find(line => line.startsWith(`${packageName}`))
}
describe('computer use requirements', () => {
test('pins mss to the last Python 3.8-compatible major version', () => {
expect(findRequirement(darwinRequirements, 'mss')).toBe('mss>=9.0.2,<10')
expect(findRequirement(win32Requirements, 'mss')).toBe('mss>=9.0.2,<10')
})
test('pins Pillow to the Python 3.9-compatible 11.x major line', () => {
expect(findRequirement(darwinRequirements, 'Pillow')).toBe('Pillow>=11.3.0,<12')
expect(findRequirement(win32Requirements, 'Pillow')).toBe('Pillow>=11.3.0,<12')
})
})