(url: string)
| 427 | } |
| 428 | |
| 429 | export async function openInChrome(url: string): Promise<boolean> { |
| 430 | const currentPlatform = getPlatform() |
| 431 | |
| 432 | // Detect the best available browser |
| 433 | const browser = await detectAvailableBrowser() |
| 434 | |
| 435 | if (!browser) { |
| 436 | logForDebugging('[Claude in Chrome] No compatible browser found') |
| 437 | return false |
| 438 | } |
| 439 | |
| 440 | const config = CHROMIUM_BROWSERS[browser] |
| 441 | |
| 442 | switch (currentPlatform) { |
| 443 | case 'macos': { |
| 444 | const { code } = await execFileNoThrow('open', [ |
| 445 | '-a', |
| 446 | config.macos.appName, |
| 447 | url, |
| 448 | ]) |
| 449 | return code === 0 |
| 450 | } |
| 451 | case 'windows': { |
| 452 | // Use rundll32 to avoid cmd.exe metacharacter issues with URLs containing & | > < |
| 453 | const { code } = await execFileNoThrow('rundll32', ['url,OpenURL', url]) |
| 454 | return code === 0 |
| 455 | } |
| 456 | case 'wsl': |
| 457 | case 'linux': { |
| 458 | for (const binary of config.linux.binaries) { |
| 459 | const { code } = await execFileNoThrow(binary, [url]) |
| 460 | if (code === 0) { |
| 461 | return true |
| 462 | } |
| 463 | } |
| 464 | return false |
| 465 | } |
| 466 | default: |
| 467 | return false |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | /** |
| 472 | * Get the socket directory path (Unix only) |
no test coverage detected