mirror of
https://github.com/callstack/agent-device.git
synced 2026-09-14 20:06:34 +08:00
be1e1c9931
* feat: add agent-cdp passthrough * docs: narrow agent-cdp memory guidance * chore: pin agent-cdp 1.6.0 * test: cover agent-cdp guidance * fix: preserve agent-cdp passthrough flags * fix: expose CDP wrapper as cdp * docs: move CDP workflow to debugging guide * docs: mention cdp in command reference
33 lines
918 B
TypeScript
33 lines
918 B
TypeScript
import { runCmdStreaming } from '../../utils/exec.ts';
|
|
|
|
const AGENT_CDP_VERSION = '1.6.0';
|
|
export const AGENT_CDP_PACKAGE = `agent-cdp@${AGENT_CDP_VERSION}`;
|
|
const AGENT_CDP_BIN = 'agent-cdp';
|
|
|
|
type AgentCdpCommandOptions = {
|
|
cwd?: string;
|
|
env?: NodeJS.ProcessEnv;
|
|
};
|
|
|
|
export function buildAgentCdpNpmExecArgs(args: string[]): string[] {
|
|
return ['exec', '--yes', '--package', AGENT_CDP_PACKAGE, '--', AGENT_CDP_BIN, ...args];
|
|
}
|
|
|
|
export async function runAgentCdpCommand(
|
|
args: string[],
|
|
options: AgentCdpCommandOptions = {},
|
|
): Promise<number> {
|
|
const result = await runCmdStreaming('npm', buildAgentCdpNpmExecArgs(args), {
|
|
cwd: options.cwd ?? process.cwd(),
|
|
env: options.env ?? process.env,
|
|
allowFailure: true,
|
|
onStdoutChunk: (chunk) => {
|
|
process.stdout.write(chunk);
|
|
},
|
|
onStderrChunk: (chunk) => {
|
|
process.stderr.write(chunk);
|
|
},
|
|
});
|
|
return result.exitCode;
|
|
}
|