import { a as getSmartRouter } from '../shared/ccjk.DuzJZlgj.mjs';
import 'node:fs';
import 'node:fs/promises';
import 'node:os';
import '../shared/ccjk.bQ7Dh1g4.mjs';

async function brainConfigCommand(options) {
  try {
    const router = getSmartRouter();
    if (options.show) {
      const config = router.getConfig();
      console.log("\n\u2699\uFE0F  Current Brain Configuration:\n");
      console.log(`  \u80FD\u529B\u504F\u597D: ${config.capabilityPreference}/5`);
      console.log(`  \u81EA\u52A8Subagent\u9608\u503C: ${config.autoSubagentThreshold}/10`);
      console.log(`  \u6700\u5927\u5E76\u884CAgent: ${config.maxParallelAgents}`);
      console.log(`  \u9065\u6D4B: ${config.enableTelemetry ? "\u542F\u7528" : "\u7981\u7528"}`);
      console.log(`  \u663E\u793A\u51B3\u7B56\u7406\u7531: ${config.showReasoning ? "\u542F\u7528" : "\u7981\u7528"}`);
      console.log();
      return;
    }
    if (options.reset) {
      router.updateConfig({
        capabilityPreference: 2,
        autoSubagentThreshold: 7,
        maxParallelAgents: 3,
        enableTelemetry: true,
        showReasoning: true
      });
      console.log("\u2705 Configuration reset to defaults");
      return;
    }
    const updates = {};
    if (options.preference !== void 0) {
      if (options.preference < 1 || options.preference > 5) {
        console.error("\u274C Preference must be between 1 and 5");
        process.exit(1);
      }
      updates.capabilityPreference = options.preference;
    }
    if (options.threshold !== void 0) {
      if (options.threshold < 1 || options.threshold > 10) {
        console.error("\u274C Threshold must be between 1 and 10");
        process.exit(1);
      }
      updates.autoSubagentThreshold = options.threshold;
    }
    if (options.maxAgents !== void 0) {
      if (options.maxAgents < 1 || options.maxAgents > 10) {
        console.error("\u274C Max agents must be between 1 and 10");
        process.exit(1);
      }
      updates.maxParallelAgents = options.maxAgents;
    }
    if (options.telemetry !== void 0) {
      updates.enableTelemetry = options.telemetry === "on";
    }
    if (options.reasoning !== void 0) {
      updates.showReasoning = options.reasoning === "on";
    }
    if (Object.keys(updates).length === 0) {
      console.log("No configuration changes specified. Use --show to see current config.");
      return;
    }
    router.updateConfig(updates);
    console.log("\u2705 Configuration updated:");
    for (const [key, value] of Object.entries(updates)) {
      console.log(`  ${key}: ${value}`);
    }
  } catch (error) {
    console.error("\u274C Error:", error instanceof Error ? error.message : String(error));
    process.exit(1);
  }
}

export { brainConfigCommand };
