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:
unraid
2026-04-04 00:09:51 +08:00
parent 3707c3c0ba
commit ca086b045a
2 changed files with 19 additions and 2 deletions

View File

@@ -414,7 +414,7 @@ export function createCliExecutor(opts: {
d.height,
d.scaleFactor,
)
return drainRunLoop(() =>
const raw = await drainRunLoop(() =>
cu.resolvePrepareCapture(
withoutTerminal(opts.allowedBundleIds),
surrogateHost,
@@ -426,6 +426,14 @@ export function createCliExecutor(opts: {
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,
}
},
/**