Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/@ant/computer-use-input/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines 24 to +36
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Don't flip isSupported on for Linux yet.

Line 31 feeds the Linux backend into loadBackend(), and line 41 turns that into isSupported = true. That widens the public support contract before Linux is declared ready.

Suggested change
 function loadBackend(): InputBackend | null {
   try {
     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
 }

As per coding guidelines, packages/@ant/computer-use-*/**/*.{ts,tsx}: Computer Use feature (CHICAGO_MCP flag) supports macOS and Windows; Linux backend implementation is pending.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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
function loadBackend(): InputBackend | null {
try {
if (process.platform === 'darwin') {
return require('./backends/darwin.js') as InputBackend
} else if (process.platform === 'win32') {
return require('./backends/win32.js') as InputBackend
}
} catch {
return null
}
return null
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/`@ant/computer-use-input/src/index.ts around lines 24 - 36, The
loadBackend() function is currently returning a Linux backend which then causes
the module-level isSupported flag to be set true for Linux; remove Linux from
the publicly supported set until the backend is ready by either (A) deleting or
commenting out the Linux branch in loadBackend() so it returns null on Linux, or
(B) leave loadBackend() but change the isSupported determination so only
process.platform === 'darwin' or 'win32' (not 'linux') set isSupported = true;
update references to loadBackend and isSupported accordingly so Linux remains
unsupported publicly.

}

const backend = loadBackend()
Expand Down
20 changes: 13 additions & 7 deletions packages/@ant/computer-use-swift/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +21 to +33
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Keep the Linux branch out of this loader for now.

Lines 27-28 expand this package's contract to Linux, but the current Computer Use support matrix still treats that backend as unfinished. Shipping the branch here makes direct consumers think @ant/computer-use-swift is ready on Linux when it is not.

Suggested change
 function loadBackend() {
   try {
     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
 }

As per coding guidelines, packages/@ant/computer-use-*/**/*.{ts,tsx}: Computer Use feature (CHICAGO_MCP flag) supports macOS and Windows; Linux backend implementation is pending.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/`@ant/computer-use-swift/src/index.ts around lines 21 - 33, The
loader function loadBackend currently returns a Linux backend when
process.platform === 'linux', which exposes unfinished Linux support; remove the
linux branch and any require('./backends/linux.js') reference so loadBackend
only checks darwin and win32 (returning null otherwise), ensuring unimplemented
backends are not advertised; update the function (and remove any import/require
references to backends/linux.js) so loadBackend returns null for
non-darwin/win32 platforms.

}

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[] })) },
Expand All @@ -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') },
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2434,7 +2434,7 @@ async function run(): Promise<CommanderCommand> {
// shipped without incident; chicago places itself correctly.
if (
feature('CHICAGO_MCP') &&
getPlatform() === 'macos' &&
getPlatform() !== 'unknown' &&
!getIsNonInteractiveSession()
Comment on lines 2436 to 2438
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Use an explicit platform allowlist here.

Line 2437 now includes wsl as well as linux. The backend loaders only switch on process.platform, so WSL will implicitly take the Linux backend path whether or not that is actually supported.

Suggested change
       if (
         feature('CHICAGO_MCP') &&
-        getPlatform() !== 'unknown' &&
+        (getPlatform() === 'macos' || getPlatform() === 'windows') &&
         !getIsNonInteractiveSession()
       ) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main.tsx` around lines 2436 - 2438, The condition using getPlatform() !==
'unknown' is too broad and lets WSL fall through to the Linux backend; change
the guard around feature('CHICAGO_MCP') so it uses an explicit platform
allowlist instead of != 'unknown' (e.g. check getPlatform() is one of the
supported values such as 'linux' or 'darwin') and keep the
getIsNonInteractiveSession() check; update the expression surrounding
feature('CHICAGO_MCP') / getPlatform() / getIsNonInteractiveSession() so WSL (or
other unsupported values returned by getPlatform()) is excluded and only
explicitly supported platforms reach the backend loaders.

) {
try {
Expand Down
3 changes: 0 additions & 3 deletions src/utils/computerUse/swiftLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ let cached: ComputerUseAPI | undefined
* Non-darwin platforms should use src/utils/computerUse/platforms/ instead.
*/
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
// eslint-disable-next-line @typescript-eslint/no-require-imports
const mod = require('@ant/computer-use-swift')
Expand Down