mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-22 16:25:51 +00:00
fix: resolve Windows Computer Use request_access and screenshot errors
Two root causes fixed:
1. swiftLoader.ts: require('@ant/computer-use-swift') returns a module
with { ComputerUseAPI } class, not an instance. macOS native .node
exports a plain object. Fixed by detecting class export and calling
new ComputerUseAPI().
2. executor.ts resolvePrepareCapture: toolCalls.ts expects result to have
{ hidden: string[], displayId: number } fields. Our ComputerUseAPI
returns { base64, width, height } only. Fixed by backfilling missing
fields with defaults.
Verified: request_access → screenshot → left_click all work on Windows.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -414,7 +414,7 @@ export function createCliExecutor(opts: {
|
|||||||
d.height,
|
d.height,
|
||||||
d.scaleFactor,
|
d.scaleFactor,
|
||||||
)
|
)
|
||||||
return drainRunLoop(() =>
|
const raw = await drainRunLoop(() =>
|
||||||
cu.resolvePrepareCapture(
|
cu.resolvePrepareCapture(
|
||||||
withoutTerminal(opts.allowedBundleIds),
|
withoutTerminal(opts.allowedBundleIds),
|
||||||
surrogateHost,
|
surrogateHost,
|
||||||
@@ -426,6 +426,14 @@ export function createCliExecutor(opts: {
|
|||||||
opts.doHide,
|
opts.doHide,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
// Ensure the result has fields expected by toolCalls.ts (hidden, displayId).
|
||||||
|
// macOS native returns these from Swift; our cross-platform ComputerUseAPI
|
||||||
|
// returns {base64, width, height} — fill in the missing fields.
|
||||||
|
return {
|
||||||
|
...raw,
|
||||||
|
hidden: (raw as any).hidden ?? [],
|
||||||
|
displayId: (raw as any).displayId ?? opts.preferredDisplayId ?? d.displayId,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -13,8 +13,17 @@ let cached: ComputerUseAPI | undefined
|
|||||||
* these in drainRunLoop().
|
* these in drainRunLoop().
|
||||||
*/
|
*/
|
||||||
export function requireComputerUseSwift(): ComputerUseAPI {
|
export function requireComputerUseSwift(): ComputerUseAPI {
|
||||||
|
if (cached) return cached
|
||||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||||
return (cached ??= require('@ant/computer-use-swift') as ComputerUseAPI)
|
const mod = require('@ant/computer-use-swift')
|
||||||
|
// macOS native .node exports a plain object with apps/display/screenshot directly.
|
||||||
|
// Our cross-platform package exports { ComputerUseAPI } class — needs instantiation.
|
||||||
|
if (mod.ComputerUseAPI && typeof mod.ComputerUseAPI === 'function') {
|
||||||
|
cached = new mod.ComputerUseAPI() as ComputerUseAPI
|
||||||
|
} else {
|
||||||
|
cached = mod as ComputerUseAPI
|
||||||
|
}
|
||||||
|
return cached
|
||||||
}
|
}
|
||||||
|
|
||||||
export type { ComputerUseAPI }
|
export type { ComputerUseAPI }
|
||||||
|
|||||||
Reference in New Issue
Block a user