import type { Command } from "commander"; import { runAcpClientInteractive } from "../acp/client.js"; import { readSecretFromFile } from "../acp/secret-file.js"; import { serveAcpGateway } from "../acp/server.js"; import { defaultRuntime } from "../runtime.js"; import { formatDocsLink } from "../terminal/links.js"; import { theme } from "../terminal/theme.js"; import { inheritOptionFromParent } from "./command-options.js"; function resolveSecretOption(params: { direct?: string; file?: string; directFlag: string; fileFlag: string; label: string; }) { const direct = params.direct?.trim(); const file = params.file?.trim(); if (direct && file) { throw new Error(`Use either ${params.directFlag} or ${params.fileFlag} for ${params.label}.`); } if (file) { return readSecretFromFile(file, params.label); } return direct || undefined; } function warnSecretCliFlag(flag: "--token" | "--password") { defaultRuntime.error( `Warning: ${flag} can be exposed via process listings. Prefer ${flag}-file or environment variables.`, ); } export function registerAcpCli(program: Command) { const acp = program.command("acp").description("Run an ACP bridge backed by the Gateway"); acp .option("--url ", "Gateway WebSocket URL (defaults to gateway.remote.url when configured)") .option("--token ", "Gateway token (if required)") .option("--token-file ", "Read gateway token from file") .option("--password ", "Gateway password (if required)") .option("--password-file ", "Read gateway password from file") .option("--session ", "Default session key (e.g. agent:main:main)") .option("--session-label