MCPcopy
hub / github.com/superagent-ai/grok-cli / wrapHostBrowserCommand

Function wrapHostBrowserCommand

src/tools/bash.ts:502–522  ·  view source on GitHub ↗
(command: string)

Source from the content-addressed store, hash-verified

500}
501
502export 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
524function shellQuote(value: string): string {
525 return `'${value.replace(/'/g, `'\\''`)}'`;

Callers 2

bash.test.tsFile · 0.90
prepareCommandMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected