providers.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import { DEFAULT_AGENT_MCPS } from '../config/agent-mcps';
  2. import { CUSTOM_SKILLS } from './custom-skills';
  3. import { RECOMMENDED_SKILLS } from './skills';
  4. import type { InstallConfig } from './types';
  5. const SCHEMA_URL =
  6. 'https://unpkg.com/oh-my-opencode-slim@latest/oh-my-opencode-slim.schema.json';
  7. // Model mappings by provider - only 4 supported providers
  8. export const MODEL_MAPPINGS = {
  9. openai: {
  10. orchestrator: { model: 'openai/gpt-5.4' },
  11. oracle: { model: 'openai/gpt-5.4', variant: 'high' },
  12. librarian: { model: 'openai/gpt-5.4-mini', variant: 'low' },
  13. explorer: { model: 'openai/gpt-5.4-mini', variant: 'low' },
  14. designer: { model: 'openai/gpt-5.4-mini', variant: 'medium' },
  15. fixer: { model: 'openai/gpt-5.4-mini', variant: 'low' },
  16. },
  17. kimi: {
  18. orchestrator: { model: 'kimi-for-coding/k2p5' },
  19. oracle: { model: 'kimi-for-coding/k2p5', variant: 'high' },
  20. librarian: { model: 'kimi-for-coding/k2p5', variant: 'low' },
  21. explorer: { model: 'kimi-for-coding/k2p5', variant: 'low' },
  22. designer: { model: 'kimi-for-coding/k2p5', variant: 'medium' },
  23. fixer: { model: 'kimi-for-coding/k2p5', variant: 'low' },
  24. },
  25. copilot: {
  26. orchestrator: { model: 'github-copilot/claude-opus-4.6' },
  27. oracle: { model: 'github-copilot/claude-opus-4.6', variant: 'high' },
  28. librarian: { model: 'github-copilot/grok-code-fast-1', variant: 'low' },
  29. explorer: { model: 'github-copilot/grok-code-fast-1', variant: 'low' },
  30. designer: {
  31. model: 'github-copilot/gemini-3.1-pro-preview',
  32. variant: 'medium',
  33. },
  34. fixer: { model: 'github-copilot/claude-sonnet-4.6', variant: 'low' },
  35. },
  36. 'zai-plan': {
  37. orchestrator: { model: 'zai-coding-plan/glm-5' },
  38. oracle: { model: 'zai-coding-plan/glm-5', variant: 'high' },
  39. librarian: { model: 'zai-coding-plan/glm-5', variant: 'low' },
  40. explorer: { model: 'zai-coding-plan/glm-5', variant: 'low' },
  41. designer: { model: 'zai-coding-plan/glm-5', variant: 'medium' },
  42. fixer: { model: 'zai-coding-plan/glm-5', variant: 'low' },
  43. },
  44. } as const;
  45. export function generateLiteConfig(
  46. installConfig: InstallConfig,
  47. ): Record<string, unknown> {
  48. const config: Record<string, unknown> = {
  49. $schema: SCHEMA_URL,
  50. preset: 'openai',
  51. presets: {},
  52. };
  53. const createAgentConfig = (
  54. agentName: string,
  55. modelInfo: { model: string; variant?: string },
  56. ) => {
  57. const isOrchestrator = agentName === 'orchestrator';
  58. const skills = isOrchestrator
  59. ? ['*']
  60. : [
  61. ...RECOMMENDED_SKILLS.filter(
  62. (s) =>
  63. s.allowedAgents.includes('*') ||
  64. s.allowedAgents.includes(agentName),
  65. ).map((s) => s.skillName),
  66. ...CUSTOM_SKILLS.filter(
  67. (s) =>
  68. s.allowedAgents.includes('*') ||
  69. s.allowedAgents.includes(agentName),
  70. ).map((s) => s.name),
  71. ];
  72. if (agentName === 'designer' && !skills.includes('agent-browser')) {
  73. skills.push('agent-browser');
  74. }
  75. return {
  76. model: modelInfo.model,
  77. variant: modelInfo.variant,
  78. skills,
  79. mcps:
  80. DEFAULT_AGENT_MCPS[agentName as keyof typeof DEFAULT_AGENT_MCPS] ?? [],
  81. };
  82. };
  83. const buildPreset = (mappingName: keyof typeof MODEL_MAPPINGS) => {
  84. const mapping = MODEL_MAPPINGS[mappingName];
  85. return Object.fromEntries(
  86. Object.entries(mapping).map(([agentName, modelInfo]) => [
  87. agentName,
  88. createAgentConfig(agentName, modelInfo),
  89. ]),
  90. );
  91. };
  92. // Always use OpenAI as default
  93. (config.presets as Record<string, unknown>).openai = buildPreset('openai');
  94. if (installConfig.hasTmux) {
  95. config.tmux = {
  96. enabled: true,
  97. layout: 'main-vertical',
  98. main_pane_size: 60,
  99. };
  100. }
  101. return config;
  102. }