mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 16:25: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 {
|
function loadBackend(): InputBackend | null {
|
||||||
if (process.platform !== 'darwin') return null
|
|
||||||
try {
|
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 {
|
} catch {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const backend = loadBackend()
|
const backend = loadBackend()
|
||||||
|
|||||||
@@ -18,19 +18,25 @@ export type {
|
|||||||
|
|
||||||
import type { ResolvePrepareCaptureResult } from './backends/darwin.js'
|
import type { ResolvePrepareCaptureResult } from './backends/darwin.js'
|
||||||
|
|
||||||
function loadDarwin() {
|
function loadBackend() {
|
||||||
if (process.platform !== 'darwin') return null
|
|
||||||
try {
|
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 {
|
} catch {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const darwin = loadDarwin()
|
const backend = loadBackend()
|
||||||
|
|
||||||
export class ComputerUseAPI {
|
export class ComputerUseAPI {
|
||||||
apps = darwin?.apps ?? {
|
apps = backend?.apps ?? {
|
||||||
async prepareDisplay() { return { activated: '', hidden: [] } },
|
async prepareDisplay() { return { activated: '', hidden: [] } },
|
||||||
async previewHideSet() { return [] },
|
async previewHideSet() { return [] },
|
||||||
async findWindowDisplays(ids: string[]) { return ids.map((b: string) => ({ bundleId: b, displayIds: [] as number[] })) },
|
async findWindowDisplays(ids: string[]) { return ids.map((b: string) => ({ bundleId: b, displayIds: [] as number[] })) },
|
||||||
@@ -42,12 +48,12 @@ export class ComputerUseAPI {
|
|||||||
async unhide() {},
|
async unhide() {},
|
||||||
}
|
}
|
||||||
|
|
||||||
display = darwin?.display ?? {
|
display = backend?.display ?? {
|
||||||
getSize() { throw new Error('@ant/computer-use-swift: macOS only') },
|
getSize() { throw new Error('@ant/computer-use-swift: macOS only') },
|
||||||
listAll() { 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 captureExcluding() { throw new Error('@ant/computer-use-swift: macOS only') },
|
||||||
async captureRegion() { throw new Error('@ant/computer-use-swift: macOS only') },
|
async captureRegion() { throw new Error('@ant/computer-use-swift: macOS only') },
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2434,7 +2434,7 @@ async function run(): Promise<CommanderCommand> {
|
|||||||
// shipped without incident; chicago places itself correctly.
|
// shipped without incident; chicago places itself correctly.
|
||||||
if (
|
if (
|
||||||
feature('CHICAGO_MCP') &&
|
feature('CHICAGO_MCP') &&
|
||||||
getPlatform() === 'macos' &&
|
getPlatform() !== 'unknown' &&
|
||||||
!getIsNonInteractiveSession()
|
!getIsNonInteractiveSession()
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -7,9 +7,6 @@ let cached: ComputerUseAPI | undefined
|
|||||||
* Non-darwin platforms should use src/utils/computerUse/platforms/ instead.
|
* Non-darwin platforms should use src/utils/computerUse/platforms/ instead.
|
||||||
*/
|
*/
|
||||||
export function requireComputerUseSwift(): ComputerUseAPI {
|
export function requireComputerUseSwift(): ComputerUseAPI {
|
||||||
if (process.platform !== 'darwin') {
|
|
||||||
throw new Error('@ant/computer-use-swift is macOS-only. Use platforms/ for cross-platform.')
|
|
||||||
}
|
|
||||||
if (cached) return cached
|
if (cached) return cached
|
||||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||||
const mod = require('@ant/computer-use-swift')
|
const mod = require('@ant/computer-use-swift')
|
||||||
|
|||||||
Reference in New Issue
Block a user