mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-15 12:55:51 +00:00
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>
This commit is contained in:
@@ -22,12 +22,18 @@ export interface InputBackend {
|
||||
}
|
||||
|
||||
function loadBackend(): InputBackend | null {
|
||||
if (process.platform !== 'darwin') return null
|
||||
try {
|
||||
return require('./backends/darwin.js') as InputBackend
|
||||
if (process.platform === 'darwin') {
|
||||
return require('./backends/darwin.js') as InputBackend
|
||||
} else if (process.platform === 'win32') {
|
||||
return require('./backends/win32.js') as InputBackend
|
||||
} else if (process.platform === 'linux') {
|
||||
return require('./backends/linux.js') as InputBackend
|
||||
}
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
const backend = loadBackend()
|
||||
|
||||
@@ -18,19 +18,25 @@ export type {
|
||||
|
||||
import type { ResolvePrepareCaptureResult } from './backends/darwin.js'
|
||||
|
||||
function loadDarwin() {
|
||||
if (process.platform !== 'darwin') return null
|
||||
function loadBackend() {
|
||||
try {
|
||||
return require('./backends/darwin.js')
|
||||
if (process.platform === 'darwin') {
|
||||
return require('./backends/darwin.js')
|
||||
} else if (process.platform === 'win32') {
|
||||
return require('./backends/win32.js')
|
||||
} else if (process.platform === 'linux') {
|
||||
return require('./backends/linux.js')
|
||||
}
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
const darwin = loadDarwin()
|
||||
const backend = loadBackend()
|
||||
|
||||
export class ComputerUseAPI {
|
||||
apps = darwin?.apps ?? {
|
||||
apps = backend?.apps ?? {
|
||||
async prepareDisplay() { return { activated: '', hidden: [] } },
|
||||
async previewHideSet() { return [] },
|
||||
async findWindowDisplays(ids: string[]) { return ids.map((b: string) => ({ bundleId: b, displayIds: [] as number[] })) },
|
||||
@@ -42,12 +48,12 @@ export class ComputerUseAPI {
|
||||
async unhide() {},
|
||||
}
|
||||
|
||||
display = darwin?.display ?? {
|
||||
display = backend?.display ?? {
|
||||
getSize() { throw new Error('@ant/computer-use-swift: macOS only') },
|
||||
listAll() { throw new Error('@ant/computer-use-swift: macOS only') },
|
||||
}
|
||||
|
||||
screenshot = darwin?.screenshot ?? {
|
||||
screenshot = backend?.screenshot ?? {
|
||||
async captureExcluding() { throw new Error('@ant/computer-use-swift: macOS only') },
|
||||
async captureRegion() { throw new Error('@ant/computer-use-swift: macOS only') },
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user