Skip to content

Commit 522a1a3

Browse files
yi7503yi7503claude
authored
feat: enable Computer Use on Windows and Linux (#145)
Remove macOS-only guards so Computer Use works cross-platform: - main.tsx: allow CHICAGO_MCP on any known platform (not just macos) - swiftLoader.ts: remove darwin-only throw, let the backend handle it - computer-use-input: dispatch to darwin/win32/linux backends - computer-use-swift: rename loadDarwin→loadBackend, dispatch all platforms Co-authored-by: yi7503 <yi7503@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0da5ec0 commit 522a1a3

4 files changed

Lines changed: 22 additions & 13 deletions

File tree

packages/@ant/computer-use-input/src/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,18 @@ export interface InputBackend {
2222
}
2323

2424
function loadBackend(): InputBackend | null {
25-
if (process.platform !== 'darwin') return null
2625
try {
27-
return require('./backends/darwin.js') as InputBackend
26+
if (process.platform === 'darwin') {
27+
return require('./backends/darwin.js') as InputBackend
28+
} else if (process.platform === 'win32') {
29+
return require('./backends/win32.js') as InputBackend
30+
} else if (process.platform === 'linux') {
31+
return require('./backends/linux.js') as InputBackend
32+
}
2833
} catch {
2934
return null
3035
}
36+
return null
3137
}
3238

3339
const backend = loadBackend()

packages/@ant/computer-use-swift/src/index.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,25 @@ export type {
1818

1919
import type { ResolvePrepareCaptureResult } from './backends/darwin.js'
2020

21-
function loadDarwin() {
22-
if (process.platform !== 'darwin') return null
21+
function loadBackend() {
2322
try {
24-
return require('./backends/darwin.js')
23+
if (process.platform === 'darwin') {
24+
return require('./backends/darwin.js')
25+
} else if (process.platform === 'win32') {
26+
return require('./backends/win32.js')
27+
} else if (process.platform === 'linux') {
28+
return require('./backends/linux.js')
29+
}
2530
} catch {
2631
return null
2732
}
33+
return null
2834
}
2935

30-
const darwin = loadDarwin()
36+
const backend = loadBackend()
3137

3238
export class ComputerUseAPI {
33-
apps = darwin?.apps ?? {
39+
apps = backend?.apps ?? {
3440
async prepareDisplay() { return { activated: '', hidden: [] } },
3541
async previewHideSet() { return [] },
3642
async findWindowDisplays(ids: string[]) { return ids.map((b: string) => ({ bundleId: b, displayIds: [] as number[] })) },
@@ -42,12 +48,12 @@ export class ComputerUseAPI {
4248
async unhide() {},
4349
}
4450

45-
display = darwin?.display ?? {
51+
display = backend?.display ?? {
4652
getSize() { throw new Error('@ant/computer-use-swift: macOS only') },
4753
listAll() { throw new Error('@ant/computer-use-swift: macOS only') },
4854
}
4955

50-
screenshot = darwin?.screenshot ?? {
56+
screenshot = backend?.screenshot ?? {
5157
async captureExcluding() { throw new Error('@ant/computer-use-swift: macOS only') },
5258
async captureRegion() { throw new Error('@ant/computer-use-swift: macOS only') },
5359
}

src/main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2434,7 +2434,7 @@ async function run(): Promise<CommanderCommand> {
24342434
// shipped without incident; chicago places itself correctly.
24352435
if (
24362436
feature('CHICAGO_MCP') &&
2437-
getPlatform() === 'macos' &&
2437+
getPlatform() !== 'unknown' &&
24382438
!getIsNonInteractiveSession()
24392439
) {
24402440
try {

src/utils/computerUse/swiftLoader.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ let cached: ComputerUseAPI | undefined
77
* Non-darwin platforms should use src/utils/computerUse/platforms/ instead.
88
*/
99
export function requireComputerUseSwift(): ComputerUseAPI {
10-
if (process.platform !== 'darwin') {
11-
throw new Error('@ant/computer-use-swift is macOS-only. Use platforms/ for cross-platform.')
12-
}
1310
if (cached) return cached
1411
// eslint-disable-next-line @typescript-eslint/no-require-imports
1512
const mod = require('@ant/computer-use-swift')

0 commit comments

Comments
 (0)