const DEFAULT_CAPABILITIES = {
  prompts: true,
  skills: true,
  resources: true,
  attachments: true,
  reasoningCycle: true,
  contextStats: true,
  startupInfo: true
};
const COMMAND_CAPABILITY_GATES = [
  {
    capability: "prompts",
    commands: ["prompts", "sysprompt"]
  },
  {
    capability: "skills",
    commands: ["skills"]
  },
  {
    capability: "reasoningCycle",
    commands: ["reasoning"]
  },
  {
    capability: "contextStats",
    commands: ["context", "ctx", "tokens"]
  }
];
function normalizeCommandName(command) {
  return command.trim().toLowerCase();
}
function getTuiCapabilities(agent) {
  const mergedCapabilities = {
    ...DEFAULT_CAPABILITIES,
    ...agent.capabilities
  };
  return {
    ...mergedCapabilities,
    skills: mergedCapabilities.skills === false ? false : Boolean(agent.skillManager),
    ...agent.capabilities?.supportedCommands ? {
      supportedCommands: agent.capabilities.supportedCommands.map(normalizeCommandName)
    } : {}
  };
}
function isCommandSupported(agent, command, definition) {
  const capabilities = getTuiCapabilities(agent);
  const supportedCommands = capabilities.supportedCommands;
  const candidates = /* @__PURE__ */ new Set([normalizeCommandName(command)]);
  if (definition?.name) {
    candidates.add(normalizeCommandName(definition.name));
  }
  for (const alias of definition?.aliases ?? []) {
    candidates.add(normalizeCommandName(alias));
  }
  for (const gate of COMMAND_CAPABILITY_GATES) {
    if (capabilities[gate.capability] === false && gate.commands.some((candidate) => candidates.has(candidate))) {
      return false;
    }
  }
  if (!supportedCommands) {
    return true;
  }
  return Array.from(candidates).some((candidate) => supportedCommands.includes(candidate));
}
function isCommandDefinitionSupported(agent, definition) {
  return isCommandSupported(agent, definition.name, definition);
}
function supportsPrompts(agent) {
  return getTuiCapabilities(agent).prompts ?? true;
}
function supportsSkills(agent) {
  return getTuiCapabilities(agent).skills ?? true;
}
function supportsResources(agent) {
  return getTuiCapabilities(agent).resources ?? true;
}
function supportsAttachments(agent) {
  return getTuiCapabilities(agent).attachments ?? true;
}
function supportsReasoningCycle(agent) {
  return getTuiCapabilities(agent).reasoningCycle ?? true;
}
function supportsContextStats(agent) {
  return getTuiCapabilities(agent).contextStats ?? true;
}
function supportsStartupInfo(agent) {
  return getTuiCapabilities(agent).startupInfo ?? true;
}
export {
  getTuiCapabilities,
  isCommandDefinitionSupported,
  isCommandSupported,
  supportsAttachments,
  supportsContextStats,
  supportsPrompts,
  supportsReasoningCycle,
  supportsResources,
  supportsSkills,
  supportsStartupInfo
};
