(command: string)
| 500 | } |
| 501 | |
| 502 | export function wrapHostBrowserCommand(command: string): string { |
| 503 | const normalized = command |
| 504 | .replace(/\bbunx\s+agent-browser\b/g, "__grok_ab") |
| 505 | .replace(/\bnpx(?:\s+-y)?\s+agent-browser\b/g, "__grok_ab") |
| 506 | .replace(/\bagent-browser\b/g, "__grok_ab"); |
| 507 | return [ |
| 508 | "__grok_ab() {", |
| 509 | " if command -v agent-browser >/dev/null 2>&1; then", |
| 510 | ' command agent-browser "$@"', |
| 511 | " elif command -v bunx >/dev/null 2>&1; then", |
| 512 | ' bunx agent-browser "$@"', |
| 513 | " elif command -v npx >/dev/null 2>&1; then", |
| 514 | ' npx -y agent-browser "$@"', |
| 515 | " else", |
| 516 | ' echo "agent-browser: not found (no bunx/npx fallback)" >&2', |
| 517 | " return 127", |
| 518 | " fi", |
| 519 | "}", |
| 520 | normalized, |
| 521 | ].join("\n"); |
| 522 | } |
| 523 | |
| 524 | function shellQuote(value: string): string { |
| 525 | return `'${value.replace(/'/g, `'\\''`)}'`; |
no outgoing calls
no test coverage detected