22 lines
696 B
TypeScript

import { execSync } from 'child_process';
import { ABResult } from '../types';
/**
* Run an agent-browser CLI command.
* This is the core interface to browser automation — all engine modules use this.
*/
export function ab(cmd: string, options: { timeout?: number; verbose?: boolean } = {}): ABResult {
const fullCmd = `agent-browser ${cmd}`;
try {
const result = execSync(fullCmd, {
encoding: 'utf8',
timeout: options.timeout || 30000,
stdio: ['pipe', 'pipe', 'pipe'],
});
return { success: true, output: result.trim() };
} catch (err: any) {
const stderr = err.stderr?.toString() || err.message;
return { success: false, error: stderr };
}
}