export type MindosServerRouteContract = {
  id: string;
  method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS';
  path: string;
  auth: 'public' | 'required';
};

export type MindosServerContract = {
  service: 'mindos';
  protocolVersion: 1;
  routes: MindosServerRouteContract[];
};

export const MINDOS_SERVER_ROUTES: MindosServerRouteContract[] = [
  { id: 'health', method: 'GET', path: '/api/health', auth: 'public' },
  { id: 'files', method: 'GET', path: '/api/files', auth: 'required' },
  { id: 'recent-files', method: 'GET', path: '/api/recent-files', auth: 'required' },
  { id: 'tree-version', method: 'GET', path: '/api/tree-version', auth: 'required' },
  { id: 'file.read', method: 'GET', path: '/api/file', auth: 'required' },
  { id: 'file.write', method: 'POST', path: '/api/file', auth: 'required' },
  { id: 'extract-pdf', method: 'POST', path: '/api/extract-pdf', auth: 'required' },
  { id: 'extract-docx', method: 'POST', path: '/api/extract-docx', auth: 'required' },
  { id: 'file.raw', method: 'GET', path: '/api/file/raw', auth: 'required' },
  { id: 'search', method: 'GET', path: '/api/search', auth: 'required' },
  { id: 'search.prewarm', method: 'GET', path: '/api/search/prewarm', auth: 'required' },
  { id: 'a2a', method: 'POST', path: '/api/a2a', auth: 'required' },
  { id: 'a2a.options', method: 'OPTIONS', path: '/api/a2a', auth: 'public' },
  { id: 'a2a.agents', method: 'GET', path: '/api/a2a/agents', auth: 'required' },
  { id: 'a2a.delegations', method: 'GET', path: '/api/a2a/delegations', auth: 'required' },
  { id: 'a2a.discover', method: 'POST', path: '/api/a2a/discover', auth: 'required' },
  { id: 'acp.config', method: 'GET', path: '/api/acp/config', auth: 'required' },
  { id: 'acp.config.update', method: 'POST', path: '/api/acp/config', auth: 'required' },
  { id: 'acp.config.delete', method: 'DELETE', path: '/api/acp/config', auth: 'required' },
  { id: 'acp.detect', method: 'GET', path: '/api/acp/detect', auth: 'required' },
  { id: 'acp.install', method: 'POST', path: '/api/acp/install', auth: 'required' },
  { id: 'acp.registry', method: 'GET', path: '/api/acp/registry', auth: 'required' },
  { id: 'acp.session', method: 'GET', path: '/api/acp/session', auth: 'required' },
  { id: 'acp.session.action', method: 'POST', path: '/api/acp/session', auth: 'required' },
  { id: 'acp.session.close', method: 'DELETE', path: '/api/acp/session', auth: 'required' },
  { id: 'backlinks', method: 'GET', path: '/api/backlinks', auth: 'required' },
  { id: 'graph', method: 'GET', path: '/api/graph', auth: 'required' },
  { id: 'agent-activity', method: 'GET', path: '/api/agent-activity', auth: 'required' },
  { id: 'assistants', method: 'GET', path: '/api/assistants', auth: 'required' },
  { id: 'assistants.create', method: 'POST', path: '/api/assistants', auth: 'required' },
  { id: 'assistants.delete', method: 'DELETE', path: '/api/assistants', auth: 'required' },
  { id: 'agent-capabilities', method: 'GET', path: '/api/agent-capabilities', auth: 'required' },
  { id: 'agent-runtimes', method: 'GET', path: '/api/agent-runtimes', auth: 'required' },
  { id: 'agent-runtimes.codex.threads', method: 'GET', path: '/api/agent-runtimes/codex/threads', auth: 'required' },
  { id: 'agent-runtimes.codex.thread', method: 'GET', path: '/api/agent-runtimes/codex/threads/[threadId]', auth: 'required' },
  { id: 'agent-runtimes.codex.thread.fork', method: 'POST', path: '/api/agent-runtimes/codex/threads/[threadId]/fork', auth: 'required' },
  { id: 'agent-runtimes.codex.thread.archive', method: 'POST', path: '/api/agent-runtimes/codex/threads/[threadId]/archive', auth: 'required' },
  { id: 'agent-runtimes.codex.thread.unarchive', method: 'POST', path: '/api/agent-runtimes/codex/threads/[threadId]/unarchive', auth: 'required' },
  { id: 'bootstrap', method: 'GET', path: '/api/bootstrap', auth: 'required' },
  { id: 'connect', method: 'GET', path: '/api/connect', auth: 'required' },
  { id: 'embedding', method: 'GET', path: '/api/embedding', auth: 'required' },
  { id: 'embedding.action', method: 'POST', path: '/api/embedding', auth: 'required' },
  { id: 'channels.verify', method: 'POST', path: '/api/channels/verify', auth: 'required' },
  { id: 'im.activity', method: 'GET', path: '/api/im/activity', auth: 'required' },
  { id: 'im.config', method: 'GET', path: '/api/im/config', auth: 'required' },
  { id: 'im.config.update', method: 'PUT', path: '/api/im/config', auth: 'required' },
  { id: 'im.config.delete', method: 'DELETE', path: '/api/im/config', auth: 'required' },
  { id: 'im.status', method: 'GET', path: '/api/im/status', auth: 'required' },
  { id: 'im.test', method: 'POST', path: '/api/im/test', auth: 'required' },
  { id: 'im.webhook-status', method: 'GET', path: '/api/im/webhook-status', auth: 'required' },
  { id: 'im.feishu.oauth', method: 'GET', path: '/api/im/feishu/oauth', auth: 'required' },
  { id: 'im.feishu.oauth.callback', method: 'GET', path: '/api/im/feishu/oauth/callback', auth: 'public' },
  { id: 'im.feishu.long-connection', method: 'GET', path: '/api/im/feishu/long-connection', auth: 'required' },
  { id: 'im.feishu.long-connection.start', method: 'POST', path: '/api/im/feishu/long-connection', auth: 'required' },
  { id: 'im.feishu.long-connection.stop', method: 'DELETE', path: '/api/im/feishu/long-connection', auth: 'required' },
  { id: 'monitoring', method: 'GET', path: '/api/monitoring', auth: 'required' },
  { id: 'update-status', method: 'GET', path: '/api/update-status', auth: 'required' },
  { id: 'update-check', method: 'GET', path: '/api/update-check', auth: 'required' },
  { id: 'restart', method: 'POST', path: '/api/restart', auth: 'required' },
  { id: 'update', method: 'POST', path: '/api/update', auth: 'required' },
  { id: 'uninstall', method: 'POST', path: '/api/uninstall', auth: 'required' },
  { id: 'init', method: 'POST', path: '/api/init', auth: 'required' },
  { id: 'sync', method: 'GET', path: '/api/sync', auth: 'required' },
  { id: 'sync.action', method: 'POST', path: '/api/sync', auth: 'required' },
  { id: 'inbox', method: 'GET', path: '/api/inbox', auth: 'required' },
  { id: 'inbox.save', method: 'POST', path: '/api/inbox', auth: 'required' },
  { id: 'inbox.archive', method: 'DELETE', path: '/api/inbox', auth: 'required' },
  { id: 'setup.check-path', method: 'POST', path: '/api/setup/check-path', auth: 'required' },
  { id: 'setup.check-port', method: 'POST', path: '/api/setup/check-port', auth: 'required' },
  { id: 'setup.generate-token', method: 'POST', path: '/api/setup/generate-token', auth: 'required' },
  { id: 'setup.ls', method: 'POST', path: '/api/setup/ls', auth: 'required' },
  { id: 'setup', method: 'GET', path: '/api/setup', auth: 'required' },
  { id: 'setup.apply', method: 'POST', path: '/api/setup', auth: 'required' },
  { id: 'setup.guide-state', method: 'PATCH', path: '/api/setup', auth: 'required' },
  { id: 'workflows', method: 'GET', path: '/api/workflows', auth: 'required' },
  { id: 'workflows.create', method: 'POST', path: '/api/workflows', auth: 'required' },
  { id: 'ask.stream', method: 'POST', path: '/api/ask', auth: 'required' },
  { id: 'ask-sessions', method: 'GET', path: '/api/ask-sessions', auth: 'required' },
  { id: 'ask-sessions.save', method: 'POST', path: '/api/ask-sessions', auth: 'required' },
  { id: 'ask-sessions.delete', method: 'DELETE', path: '/api/ask-sessions', auth: 'required' },
  { id: 'space-overview', method: 'GET', path: '/api/space-overview', auth: 'required' },
  { id: 'git', method: 'GET', path: '/api/git', auth: 'required' },
  { id: 'settings', method: 'GET', path: '/api/settings', auth: 'required' },
  { id: 'settings.update', method: 'POST', path: '/api/settings', auth: 'required' },
  { id: 'settings.reset-token', method: 'POST', path: '/api/settings/reset-token', auth: 'required' },
  { id: 'settings.test-key', method: 'POST', path: '/api/settings/test-key', auth: 'required' },
  { id: 'settings.list-models', method: 'POST', path: '/api/settings/list-models', auth: 'required' },
  { id: 'mcp.status', method: 'GET', path: '/api/mcp/status', auth: 'required' },
  { id: 'mcp.token.reveal', method: 'POST', path: '/api/mcp/token/reveal', auth: 'required' },
  { id: 'mcp.agents', method: 'GET', path: '/api/mcp/agents', auth: 'required' },
  { id: 'mcp.tools', method: 'GET', path: '/api/mcp/tools', auth: 'required' },
  { id: 'mcp.direct-tools', method: 'POST', path: '/api/mcp/direct-tools', auth: 'required' },
  { id: 'mcp.install', method: 'POST', path: '/api/mcp/install', auth: 'required' },
  { id: 'mcp.install-skill', method: 'POST', path: '/api/mcp/install-skill', auth: 'required' },
  { id: 'mcp.restart', method: 'POST', path: '/api/mcp/restart', auth: 'required' },
  { id: 'mcp.uninstall', method: 'POST', path: '/api/mcp/uninstall', auth: 'required' },
  { id: 'skills', method: 'GET', path: '/api/skills', auth: 'required' },
  { id: 'skills.action', method: 'POST', path: '/api/skills', auth: 'required' },
  { id: 'changes', method: 'GET', path: '/api/changes', auth: 'required' },
  { id: 'changes.mark-seen', method: 'POST', path: '/api/changes', auth: 'required' },
  { id: 'agents.custom.create', method: 'POST', path: '/api/agents/custom', auth: 'required' },
  { id: 'agents.custom.update', method: 'PUT', path: '/api/agents/custom', auth: 'required' },
  { id: 'agents.custom.delete', method: 'DELETE', path: '/api/agents/custom', auth: 'required' },
  { id: 'agents.custom.detect', method: 'POST', path: '/api/agents/custom/detect', auth: 'required' },
  { id: 'agents.copy-skill', method: 'POST', path: '/api/agents/copy-skill', auth: 'required' },
];

export function getMindosServerContract(): MindosServerContract {
  return {
    service: 'mindos',
    protocolVersion: 1,
    routes: MINDOS_SERVER_ROUTES,
  };
}
