import { parseInput } from "../utils/inputParsing.js";
import { executeCommand } from "../interactive-commands/commands.js";
function isStyledOutput(result) {
  return typeof result === "object" && result !== null && "styledType" in result && "styledData" in result && "fallbackText" in result;
}
function createSendMessageMarker(text) {
  return { __sendMessage: true, text };
}
function isSendMessageMarker(result) {
  return typeof result === "object" && result !== null && "__sendMessage" in result && result.__sendMessage === true && "text" in result && typeof result.text === "string";
}
class CommandService {
  /**
   * Parses input and determines if it's a command or prompt
   */
  parseInput(input) {
    return parseInput(input);
  }
  /**
   * Executes a command and returns the result
   */
  async executeCommand(command, args, agent, sessionId, configFilePath) {
    const result = await executeCommand(command, args, agent, sessionId, configFilePath);
    if (isSendMessageMarker(result)) {
      return { type: "sendMessage", messageToSend: result.text };
    }
    if (typeof result === "string") {
      return { type: "output", output: result };
    }
    if (isStyledOutput(result)) {
      return { type: "styled", styled: result };
    }
    return { type: "handled" };
  }
}
export {
  CommandService,
  createSendMessageMarker,
  isSendMessageMarker,
  isStyledOutput
};
