function isSubcommand(value) {
    return value === "hub" || value === "peer" || value === "guest";
}
export function getDPiHelpText(appName = "d-pi") {
    return `D-Pi

Usage:
  ${appName} <command> [args...]

Examples:
  ${appName} hub serve
  ${appName} peer --hub http://127.0.0.1:4317
  ${appName} guest acp --agent claude-guest -- claude acp
  ${appName} --version

Commands:
  hub      Run the D-Pi hub with the remaining arguments
  peer     Run the D-Pi peer with the remaining arguments
  guest    Run a restricted D-Pi guest bridge, including ACP clients
  version  Show D-Pi version and hub protocol version (also: --version, -v)
  help     Show this help
`;
}
export function resolveDPiCommand(args, sourceEnv = process.env) {
    const [subcommand, ...rest] = args;
    if (!isSubcommand(subcommand)) {
        return undefined;
    }
    const env = getDPiCommandEnv(subcommand, rest, sourceEnv);
    return {
        subcommand,
        args: rest,
        ...(env && { env }),
    };
}
function getDPiCommandEnv(subcommand, args, sourceEnv) {
    if (subcommand !== "hub" || args[0] !== "serve" || sourceEnv.PI_HUB_HOST?.trim()) {
        return undefined;
    }
    return { PI_HUB_HOST: "0.0.0.0" };
}
//# sourceMappingURL=index.js.map