tachibot-mcp 2.0.6 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/.env.example +5 -2
  2. package/dist/src/config/model-constants.js +83 -73
  3. package/dist/src/config/model-preferences.js +5 -4
  4. package/dist/src/config.js +2 -1
  5. package/dist/src/mcp-client.js +3 -3
  6. package/dist/src/modes/scout.js +2 -1
  7. package/dist/src/optimization/model-router.js +19 -16
  8. package/dist/src/orchestrator-instructions.js +1 -1
  9. package/dist/src/orchestrator-lite.js +1 -1
  10. package/dist/src/orchestrator.js +1 -1
  11. package/dist/src/profiles/balanced.js +1 -2
  12. package/dist/src/profiles/code_focus.js +1 -2
  13. package/dist/src/profiles/full.js +1 -2
  14. package/dist/src/profiles/minimal.js +1 -2
  15. package/dist/src/profiles/research_power.js +1 -2
  16. package/dist/src/server.js +13 -12
  17. package/dist/src/tools/gemini-tools.js +15 -16
  18. package/dist/src/tools/grok-enhanced.js +18 -17
  19. package/dist/src/tools/grok-tools.js +21 -20
  20. package/dist/src/tools/openai-tools.js +28 -61
  21. package/dist/src/tools/tool-router.js +53 -52
  22. package/dist/src/tools/unified-ai-provider.js +1 -1
  23. package/dist/src/tools/workflow-runner.js +16 -0
  24. package/dist/src/tools/workflow-validator-tool.js +1 -1
  25. package/dist/src/utils/api-keys.js +20 -0
  26. package/dist/src/validators/interpolation-validator.js +4 -0
  27. package/dist/src/validators/tool-registry-validator.js +1 -1
  28. package/dist/src/validators/tool-types.js +0 -1
  29. package/dist/src/workflows/custom-workflows.js +4 -3
  30. package/dist/src/workflows/engine/VariableInterpolator.js +30 -3
  31. package/dist/src/workflows/engine/WorkflowExecutionEngine.js +2 -2
  32. package/dist/src/workflows/engine/WorkflowOutputFormatter.js +27 -4
  33. package/dist/src/workflows/fallback-strategies.js +2 -2
  34. package/dist/src/workflows/model-router.js +20 -11
  35. package/dist/src/workflows/tool-mapper.js +41 -14
  36. package/docs/API_KEYS.md +7 -7
  37. package/docs/TOOLS_REFERENCE.md +1 -37
  38. package/package.json +1 -1
  39. package/profiles/balanced.json +1 -2
  40. package/profiles/code_focus.json +1 -2
  41. package/profiles/debug_intensive.json +0 -1
  42. package/profiles/full.json +2 -3
  43. package/profiles/minimal.json +1 -2
  44. package/profiles/research_power.json +1 -2
  45. package/profiles/workflow_builder.json +1 -2
  46. package/tools.config.json +15 -3
  47. package/workflows/code-architecture-review.yaml +5 -3
  48. package/workflows/creative-brainstorm-yaml.yaml +1 -1
  49. package/workflows/pingpong.yaml +5 -3
  50. package/workflows/system/README.md +1 -1
  51. package/workflows/system/verifier.yaml +8 -5
  52. package/workflows/ultra-creative-brainstorm.yaml +3 -3
package/.env.example CHANGED
@@ -22,8 +22,11 @@ TACHIBOT_PROFILE=balanced
22
22
  # Perplexity API (for web search, research, reasoning)
23
23
  PERPLEXITY_API_KEY=
24
24
 
25
- # Grok API (for code analysis, debugging, architecture)
26
- GROK_API_KEY=
25
+ # Grok/xAI API (for code analysis, debugging, architecture)
26
+ # Get from: https://console.x.ai/
27
+ XAI_API_KEY=
28
+ # Legacy alias (both work):
29
+ # GROK_API_KEY=
27
30
 
28
31
  # OpenAI API (for GPT-5, analysis, comparison)
29
32
  OPENAI_API_KEY=
@@ -2,12 +2,22 @@
2
2
  * Centralized Model Names and Constants
3
3
  * Use these constants instead of hardcoded strings in workflows and tools
4
4
  */
5
- // OpenAI GPT-5.1 Models (November 2025)
6
- export const GPT51_MODELS = {
7
- FULL: "gpt-5.1", // Full reasoning model ($1.25/$10 per 1M tokens)
8
- CODEX_MINI: "gpt-5.1-codex-mini", // Coding optimized, cost-efficient ($0.25/$2 per 1M tokens) - DEFAULT
9
- CODEX: "gpt-5.1-codex", // Advanced coding ($1.25/$10 per 1M tokens)
5
+ // OpenAI GPT-5 Models (November 2025) - Optimized for Claude Code MCP
6
+ // Verified via Perplexity + OpenAI API docs
7
+ // Strategy: Use codex for code (80%), flagship for reasoning, pro for orchestration
8
+ // NOTE: Codex models use /v1/responses endpoint, non-codex use /v1/chat/completions
9
+ export const GPT5_MODELS = {
10
+ // General purpose (use /v1/chat/completions)
11
+ FULL: "gpt-5.1", // Flagship: reasoning/fallback ($10/$30, 2M context)
12
+ PRO: "gpt-5-pro", // Premium: complex orchestration ($20/$60, 4M context, 2x cost)
13
+ // Code specialized (use /v1/responses endpoint!)
14
+ CODEX_MINI: "gpt-5.1-codex-mini", // Workhorse: 70-80% of code tasks ($2/$6, 256K) ⚡ CHEAP!
15
+ CODEX: "gpt-5.1-codex", // Power: complex code tasks ($15/$45, 1M context)
16
+ CODEX_MAX: "gpt-5.1-codex-max", // Frontier: BEST for deep analysis & multi-file refactoring (pricing TBD)
17
+ // REMOVED: MINI (redundant - codex-mini better for code), NANO (too weak)
10
18
  };
19
+ // Backward compatibility alias
20
+ export const GPT51_MODELS = GPT5_MODELS;
11
21
  // GPT-5.1 Reasoning Effort Levels
12
22
  export const GPT51_REASONING = {
13
23
  NONE: "none", // No extra reasoning (fastest, cheapest)
@@ -17,12 +27,15 @@ export const GPT51_REASONING = {
17
27
  };
18
28
  // OpenAI GPT-4 Models (Legacy - mapped to GPT-5.1)
19
29
  export const GPT4_MODELS = {
20
- O_MINI: "gpt-5.1-codex-mini", // Cost-efficient
21
- O: "gpt-5.1", // Current best
30
+ O_MINI: "gpt-5-mini", // Cost-efficient (mapped to GPT-5 mini)
31
+ O: "gpt-5.1", // Current best (mapped to GPT-5.1 flagship)
22
32
  _1_MINI: "gpt-4.1-mini", // Best value with 1M context
23
33
  };
24
34
  // Google Gemini Models (2025)
25
35
  export const GEMINI_MODELS = {
36
+ // Gemini 3 (November 2025 - Latest)
37
+ GEMINI_3_PRO: "gemini-3-pro-preview", // Latest with enhanced structured outputs & multimodal, 1M context
38
+ // Gemini 2.5 (Previous generation)
26
39
  FLASH: "gemini-2.5-flash", // Latest fast model
27
40
  PRO: "gemini-2.5-pro", // Most advanced reasoning
28
41
  FLASH_LITE: "gemini-2.5-flash-lite", // Cost-effective
@@ -32,12 +45,12 @@ export const PERPLEXITY_MODELS = {
32
45
  SONAR_PRO: "sonar-pro", // Main search model
33
46
  SONAR_REASONING: "sonar-reasoning-pro", // Reasoning model
34
47
  };
35
- // Grok Models (xAI) - Updated 2025-11-21 with Grok 4.1
48
+ // Grok Models (xAI) - Updated 2025-11-22 with correct API model names
36
49
  export const GROK_MODELS = {
37
50
  // Grok 4.1 models (Nov 2025) - LATEST & BEST
38
- _4_1: "grok-4.1", // Latest: 2M context, $0.20/$0.50, enhanced reasoning & creativity
39
- _4_1_FAST: "grok-4.1-fast", // Tool-calling optimized: 2M context, $0.20/$0.50, agentic workflows
40
- // Previous fast models (2025) - Still good
51
+ _4_1_FAST_REASONING: "grok-4-1-fast-reasoning", // Latest: 2M context, $0.20/$0.50, enhanced reasoning
52
+ _4_1_FAST_NON_REASONING: "grok-4-1-fast-non-reasoning", // Tool-calling optimized: 2M context, $0.20/$0.50
53
+ // Grok 4 fast models (2025) - Still good
41
54
  CODE_FAST: "grok-code-fast-1", // Coding specialist: 256K→2M, $0.20/$1.50, 92 tok/sec
42
55
  _4_FAST_REASONING: "grok-4-fast-reasoning", // Cheap reasoning: 2M→4M, $0.20/$0.50
43
56
  _4_FAST: "grok-4-fast-non-reasoning", // Fast general: 2M→4M, $0.20/$0.50
@@ -65,154 +78,151 @@ export const DEFAULT_WORKFLOW_SETTINGS = {
65
78
  retries: 3,
66
79
  timeout: 30000, // 30 seconds
67
80
  };
68
- // Tool-specific defaults for ALL tools
81
+ // ============================================================================
82
+ // CURRENT_MODELS - SINGLE BUMP POINT FOR MODEL VERSIONS
83
+ // ============================================================================
84
+ // When new models release, update ONLY this section!
85
+ // All tools automatically use the new models.
86
+ // ============================================================================
87
+ export const CURRENT_MODELS = {
88
+ openai: {
89
+ reason: GPT5_MODELS.PRO, // Deep reasoning
90
+ brainstorm: GPT5_MODELS.FULL, // Creative ideation
91
+ code: GPT5_MODELS.CODEX_MINI, // Code tasks (cheap & fast)
92
+ explain: GPT5_MODELS.CODEX_MINI, // Explanations
93
+ },
94
+ grok: {
95
+ reason: GROK_MODELS._4_1_FAST_REASONING,
96
+ code: GROK_MODELS._4_1_FAST_NON_REASONING,
97
+ debug: GROK_MODELS._4_1_FAST_NON_REASONING,
98
+ brainstorm: GROK_MODELS._4_1_FAST_REASONING,
99
+ search: GROK_MODELS._4_1_FAST_REASONING,
100
+ architect: GROK_MODELS._4_1_FAST_REASONING,
101
+ },
102
+ gemini: {
103
+ default: GEMINI_MODELS.GEMINI_3_PRO,
104
+ },
105
+ perplexity: {
106
+ search: PERPLEXITY_MODELS.SONAR_PRO,
107
+ reason: PERPLEXITY_MODELS.SONAR_REASONING,
108
+ },
109
+ openrouter: {
110
+ kimi: KIMI_MODELS.K2_THINKING,
111
+ }
112
+ };
113
+ // Tool-specific defaults - References CURRENT_MODELS for easy bumping
69
114
  export const TOOL_DEFAULTS = {
70
- // OpenAI GPT-5.1 tools
71
- openai_gpt5_reason: {
72
- model: GPT51_MODELS.FULL,
115
+ // OpenAI tools
116
+ openai_reason: {
117
+ model: CURRENT_MODELS.openai.reason,
73
118
  reasoning_effort: GPT51_REASONING.HIGH,
74
119
  maxTokens: 4000,
75
120
  temperature: 0.7,
76
121
  },
77
122
  openai_brainstorm: {
78
- model: GPT51_MODELS.CODEX_MINI,
123
+ model: CURRENT_MODELS.openai.brainstorm,
79
124
  reasoning_effort: GPT51_REASONING.MEDIUM,
80
125
  maxTokens: 2000,
81
126
  temperature: 0.9,
82
127
  },
83
- openai_compare: {
84
- model: GPT51_MODELS.CODEX_MINI,
85
- reasoning_effort: GPT51_REASONING.LOW,
86
- maxTokens: 2000,
87
- temperature: 0.7,
88
- },
89
128
  openai_code_review: {
90
- model: GPT51_MODELS.CODEX_MINI,
129
+ model: CURRENT_MODELS.openai.code,
91
130
  reasoning_effort: GPT51_REASONING.MEDIUM,
92
131
  maxTokens: 2000,
93
132
  temperature: 0.3,
94
133
  },
95
134
  openai_explain: {
96
- model: GPT51_MODELS.CODEX_MINI,
135
+ model: CURRENT_MODELS.openai.explain,
97
136
  reasoning_effort: GPT51_REASONING.LOW,
98
137
  maxTokens: 1500,
99
138
  temperature: 0.7,
100
139
  },
101
140
  // Gemini tools
102
- gemini_query: {
103
- model: GEMINI_MODELS.PRO,
104
- maxTokens: 2048,
105
- temperature: 0.7,
106
- },
107
141
  gemini_brainstorm: {
108
- model: GEMINI_MODELS.PRO,
142
+ model: CURRENT_MODELS.gemini.default,
109
143
  maxTokens: 2048,
110
144
  temperature: 0.9,
111
145
  },
112
146
  gemini_analyze_code: {
113
- model: GEMINI_MODELS.PRO,
147
+ model: CURRENT_MODELS.gemini.default,
114
148
  maxTokens: 2048,
115
149
  temperature: 0.3,
116
150
  },
117
151
  gemini_analyze_text: {
118
- model: GEMINI_MODELS.PRO,
152
+ model: CURRENT_MODELS.gemini.default,
119
153
  maxTokens: 2048,
120
154
  temperature: 0.5,
121
155
  },
122
156
  // Perplexity tools
123
157
  perplexity_ask: {
124
- model: PERPLEXITY_MODELS.SONAR_PRO,
158
+ model: CURRENT_MODELS.perplexity.search,
125
159
  maxTokens: 2000,
126
160
  temperature: 0.7,
127
161
  },
128
162
  perplexity_reason: {
129
- model: PERPLEXITY_MODELS.SONAR_REASONING,
163
+ model: CURRENT_MODELS.perplexity.reason,
130
164
  maxTokens: 4000,
131
165
  temperature: 0.7,
132
166
  },
133
167
  perplexity_research: {
134
- model: PERPLEXITY_MODELS.SONAR_PRO,
168
+ model: CURRENT_MODELS.perplexity.search,
135
169
  maxTokens: 3000,
136
170
  temperature: 0.7,
137
171
  },
138
- // Grok tools - UPDATED 2025-11-21 with Grok 4.1
139
- grok: {
140
- model: GROK_MODELS._4_1, // Latest: Enhanced reasoning & creativity
141
- maxTokens: 4000,
142
- temperature: 0.7,
143
- },
172
+ // Grok tools
144
173
  grok_reason: {
145
- model: GROK_MODELS._4_1, // Latest: Enhanced reasoning with lower hallucination
174
+ model: CURRENT_MODELS.grok.reason,
146
175
  maxTokens: 8000,
147
176
  temperature: 0.7,
148
177
  },
149
178
  grok_code: {
150
- model: GROK_MODELS._4_1_FAST, // Tool-calling optimized, better than code-fast-1
179
+ model: CURRENT_MODELS.grok.code,
151
180
  maxTokens: 4000,
152
181
  temperature: 0.3,
153
182
  },
154
183
  grok_search: {
155
- model: GROK_MODELS._4_1, // Latest with enhanced reasoning
184
+ model: CURRENT_MODELS.grok.search,
156
185
  maxTokens: 3000,
157
186
  temperature: 0.7,
158
187
  },
159
188
  grok_brainstorm: {
160
- model: GROK_MODELS._4_1, // Latest: Enhanced creativity & emotional intelligence
189
+ model: CURRENT_MODELS.grok.brainstorm,
161
190
  maxTokens: 4000,
162
191
  temperature: 0.9,
163
192
  },
164
193
  grok_architect: {
165
- model: GROK_MODELS._4_1, // Latest: Enhanced architecture reasoning
194
+ model: CURRENT_MODELS.grok.architect,
166
195
  maxTokens: 4000,
167
196
  temperature: 0.6,
168
197
  },
169
198
  grok_debug: {
170
- model: GROK_MODELS._4_1_FAST, // Tool-calling optimized for debugging
199
+ model: CURRENT_MODELS.grok.debug,
171
200
  maxTokens: 3000,
172
201
  temperature: 0.3,
173
202
  },
174
- // Qwen tools (via OpenRouter)
203
+ // OpenRouter tools
175
204
  qwen_coder: {
176
205
  maxTokens: 4000,
177
206
  temperature: 0.5,
178
207
  },
179
- // Kimi tools (via OpenRouter)
180
208
  kimi_thinking: {
181
- model: KIMI_MODELS.K2_THINKING,
182
- maxTokens: 16000, // Large for detailed reasoning chains
183
- temperature: 0.7, // Higher for creative reasoning
209
+ model: CURRENT_MODELS.openrouter.kimi,
210
+ maxTokens: 16000,
211
+ temperature: 0.7,
184
212
  },
185
- // Meta tools (think, focus, code_reviewer, etc.)
213
+ // Meta tools
186
214
  think: {
187
- model: GPT51_MODELS.FULL,
215
+ model: CURRENT_MODELS.openai.reason,
188
216
  reasoning_effort: GPT51_REASONING.HIGH,
189
217
  maxTokens: 500,
190
218
  temperature: 0.7,
191
219
  },
192
220
  focus: {
193
- model: GPT51_MODELS.CODEX_MINI,
221
+ model: CURRENT_MODELS.openai.code,
194
222
  reasoning_effort: GPT51_REASONING.LOW,
195
223
  maxTokens: 2000,
196
224
  temperature: 0.8,
197
225
  },
198
- code_reviewer: {
199
- model: GPT51_MODELS.CODEX_MINI,
200
- reasoning_effort: GPT51_REASONING.MEDIUM,
201
- maxTokens: 2000,
202
- temperature: 0.5,
203
- },
204
- test_architect: {
205
- model: GPT51_MODELS.CODEX_MINI,
206
- reasoning_effort: GPT51_REASONING.MEDIUM,
207
- maxTokens: 2000,
208
- temperature: 0.6,
209
- },
210
- documentation_writer: {
211
- model: GPT51_MODELS.CODEX_MINI,
212
- reasoning_effort: GPT51_REASONING.LOW,
213
- maxTokens: 2000,
214
- temperature: 0.7,
215
- },
216
226
  };
217
227
  // Default tool to use in workflows if not specified
218
228
  export const DEFAULT_WORKFLOW_TOOL = "openai_brainstorm";
@@ -2,6 +2,7 @@
2
2
  * Model Preferences Configuration
3
3
  * Allows users to set their preferred models based on available API tokens
4
4
  */
5
+ import { hasGrokApiKey } from "../utils/api-keys.js";
5
6
  /**
6
7
  * Default model configurations with user preferences
7
8
  */
@@ -37,7 +38,7 @@ export class ModelPreferencesManager {
37
38
  this.preferences.enableExpensiveModels = true;
38
39
  }
39
40
  if (preferO3) {
40
- this.preferences.primaryReasoning = "openai_gpt5_reason";
41
+ this.preferences.primaryReasoning = "openai_reason";
41
42
  this.preferences.enableExpensiveModels = true;
42
43
  }
43
44
  // Load model-specific overrides from environment
@@ -63,7 +64,7 @@ export class ModelPreferencesManager {
63
64
  };
64
65
  }
65
66
  // Grok configuration
66
- if (process.env.GROK_API_KEY) {
67
+ if (hasGrokApiKey()) {
67
68
  this.preferences.modelOverrides["grok_reason"] = {
68
69
  enabled: true,
69
70
  priority: parseInt(process.env.GROK_PRIORITY || "2"),
@@ -122,7 +123,7 @@ export class ModelPreferencesManager {
122
123
  */
123
124
  initializeModels() {
124
125
  // Check which APIs are available
125
- const hasGrok = !!process.env.GROK_API_KEY;
126
+ const hasGrok = hasGrokApiKey();
126
127
  const hasOpenAI = !!process.env.OPENAI_API_KEY;
127
128
  const hasGemini = !!process.env.GOOGLE_API_KEY;
128
129
  const hasPerplexity = !!process.env.PERPLEXITY_API_KEY;
@@ -348,7 +349,7 @@ export class ModelPreferencesManager {
348
349
  */
349
350
  getRecommendations() {
350
351
  const recommendations = [];
351
- const hasGrok = !!process.env.GROK_API_KEY;
352
+ const hasGrok = hasGrokApiKey();
352
353
  const hasOpenAI = !!process.env.OPENAI_API_KEY;
353
354
  if (hasGrok && !this.preferences.enableExpensiveModels) {
354
355
  recommendations.push("You have Grok API access. Enable ENABLE_EXPENSIVE_MODELS=true to use Grok Heavy (256k context).");
@@ -1,5 +1,6 @@
1
1
  import { config } from 'dotenv';
2
2
  import { TechnicalDomain } from './reasoning-chain.js';
3
+ import { getGrokApiKey } from './utils/api-keys.js';
3
4
  import * as path from 'path';
4
5
  import { fileURLToPath } from 'url';
5
6
  // Get the directory of the current module
@@ -72,7 +73,7 @@ export function loadConfig() {
72
73
  gemini: process.env.GOOGLE_API_KEY,
73
74
  deepseek: process.env.DEEPSEEK_API_KEY,
74
75
  perplexity: process.env.PERPLEXITY_API_KEY,
75
- grok: process.env.GROK_API_KEY,
76
+ grok: getGrokApiKey(),
76
77
  qwen: process.env.QWEN_API_KEY,
77
78
  },
78
79
  preferences: {
@@ -10,7 +10,7 @@ export class MCPClient {
10
10
  this.availableTools = new Set([
11
11
  'mcp__gemini__gemini-brainstorm',
12
12
  'mcp__perplexity-ask__perplexity_research',
13
- 'mcp__openai-mcp__openai_gpt5_reason',
13
+ 'mcp__openai-mcp__openai_reason',
14
14
  'mcp__openai-mcp__openai_brainstorm',
15
15
  'mcp__think-mcp-server__think',
16
16
  'mcp__devlog-search__search_devlogs',
@@ -55,7 +55,7 @@ export class MCPClient {
55
55
  content: params.prompt || params.query
56
56
  }]
57
57
  };
58
- case 'mcp__openai-mcp__openai_gpt5_reason':
58
+ case 'mcp__openai-mcp__openai_reason':
59
59
  return {
60
60
  query: params.prompt || params.query,
61
61
  context: params.context
@@ -77,7 +77,7 @@ export class MCPClient {
77
77
  const descriptions = {
78
78
  'mcp__gemini__gemini-brainstorm': 'Creative brainstorming with Gemini',
79
79
  'mcp__perplexity-ask__perplexity_research': 'Deep research with citations',
80
- 'mcp__openai-mcp__openai_gpt5_reason': 'Mathematical/logical reasoning (GPT-5-mini)',
80
+ 'mcp__openai-mcp__openai_reason': 'Mathematical/logical reasoning (GPT-5-mini)',
81
81
  'mcp__openai-mcp__openai_brainstorm': 'Alternative perspective generation',
82
82
  'mcp__think-mcp-server__think': 'Reflective thinking scratchpad'
83
83
  };
@@ -1,5 +1,6 @@
1
1
  import { ModelRouter } from '../workflows/model-router.js';
2
2
  import { getScoutModels, getDefaultModels } from '../config/model-defaults.js';
3
+ import { getGrokApiKey } from '../utils/api-keys.js';
3
4
  import { createProgressStream } from '../utils/progress-stream.js';
4
5
  import { providerRouter } from '../utils/provider-router.js';
5
6
  import { getSmartTimeout } from '../config/timeout-config.js';
@@ -66,7 +67,7 @@ export class Scout {
66
67
  };
67
68
  // Load configuration from environment
68
69
  this.defaultSearchProvider = process.env.DEFAULT_SEARCH_PROVIDER || 'perplexity';
69
- this.grokApiKey = process.env.GROK_API_KEY || process.env.XAI_API_KEY;
70
+ this.grokApiKey = getGrokApiKey();
70
71
  this.perplexityApiKey = process.env.PERPLEXITY_API_KEY;
71
72
  this.modelRouter = new ModelRouter();
72
73
  // Load model configurations
@@ -4,27 +4,30 @@
4
4
  */
5
5
  export var ModelTier;
6
6
  (function (ModelTier) {
7
- // Tier 0: NEW! GPT-5 Nano - CHEAPEST OPTION
8
- ModelTier["ULTRA_CHEAP"] = "gpt-5-nano";
7
+ // Tier 0: Cheapest - GPT-5.1 Codex Mini
8
+ ModelTier["ULTRA_CHEAP"] = "gpt-5.1-codex-mini";
9
9
  // Tier 1: Ultra Fast & Cheap (< $0.001 per request)
10
10
  ModelTier["ULTRA_EFFICIENT"] = "gemini-2.5-flash";
11
- ModelTier["EFFICIENT"] = "gpt-5-mini";
11
+ ModelTier["EFFICIENT"] = "gpt-5.1-codex-mini";
12
12
  // Tier 2: Balanced ($0.001-$0.01 per request)
13
- ModelTier["STANDARD"] = "gpt-5";
14
- ModelTier["GPT5_MINI"] = "gpt-5-mini";
13
+ ModelTier["STANDARD"] = "gpt-5.1-codex";
14
+ ModelTier["GPT5_MINI"] = "gpt-5.1-codex-mini";
15
15
  // Tier 3: Advanced ($0.01-$0.05 per request)
16
16
  ModelTier["WEB_SEARCH"] = "perplexity-sonar-pro";
17
17
  // Tier 4: Premium (Use with caution)
18
- ModelTier["GPT5_FULL"] = "gpt-5";
18
+ ModelTier["GPT5_FULL"] = "gpt-5.1";
19
19
  })(ModelTier || (ModelTier = {}));
20
20
  const MODEL_COSTS = {
21
- // GPT-5 Models (Nov 2025 pricing)
22
- "gpt-5-nano": { input: 0.00005, output: 0.0004, latency: 400 }, // CHEAPEST!
23
- "gpt-5-mini": { input: 0.00025, output: 0.002, latency: 800 },
24
- "gpt-5": { input: 0.00125, output: 0.01, latency: 2000 },
25
- // Existing models
21
+ // GPT-5.1 Models (Nov 2025 pricing) - ACTUAL API MODEL NAMES
22
+ "gpt-5.1-codex-mini": { input: 0.002, output: 0.006, latency: 800 }, // CHEAPEST!
23
+ "gpt-5.1-codex": { input: 0.015, output: 0.045, latency: 1500 },
24
+ "gpt-5.1": { input: 0.010, output: 0.030, latency: 2000 },
25
+ "gpt-5-pro": { input: 0.020, output: 0.060, latency: 3000 },
26
+ // Gemini models
26
27
  "gemini-2.5-flash": { input: 0.000075, output: 0.0003, latency: 500 },
27
28
  "gemini-2.5-pro": { input: 0.00015, output: 0.0006, latency: 1000 },
29
+ "gemini-3-pro-preview": { input: 0.0002, output: 0.0008, latency: 800 },
30
+ // Other models
28
31
  qwencoder: { input: 0.00015, output: 0.0006, latency: 1000 },
29
32
  "perplexity-sonar-pro": { input: 0.006, output: 0.006, latency: 2000 },
30
33
  };
@@ -94,18 +97,18 @@ export class SmartModelRouter {
94
97
  * Select optimal model based on context
95
98
  */
96
99
  selectModel(context) {
97
- // Rule 1: Simple queries → GPT-5 Nano (CHEAPEST!)
100
+ // Rule 1: Simple queries → GPT-5.1 Codex Mini (CHEAPEST!)
98
101
  if (context.complexity === "simple" && context.costSensitive !== false) {
99
102
  // Check if GPT-5 is enabled
100
103
  const gpt5Enabled = process.env.ENABLE_GPT5 !== "false";
101
104
  if (gpt5Enabled) {
102
105
  return {
103
- primary: ModelTier.ULTRA_CHEAP, // gpt-5-nano
106
+ primary: ModelTier.ULTRA_CHEAP, // gpt-5.1-codex-mini
104
107
  fallback: ModelTier.ULTRA_EFFICIENT, // gemini-2.5-flash
105
- estimatedCost: 0.000008, // Even cheaper than gemini!
106
- estimatedLatency: 400,
108
+ estimatedCost: 0.002,
109
+ estimatedLatency: 800,
107
110
  requiresConfirmation: false,
108
- reasoning: "Simple query - using GPT-5 Nano (cheapest option)",
111
+ reasoning: "Simple query - using GPT-5.1 Codex Mini (cheapest option)",
109
112
  };
110
113
  }
111
114
  else {
@@ -67,7 +67,7 @@ export class InstructionOrchestrator {
67
67
  const toolMap = {
68
68
  'gemini_brainstorm': 'mcp__gemini__gemini-brainstorm',
69
69
  'perplexity_research': 'mcp__perplexity-ask__perplexity_research',
70
- 'openai_reason': 'mcp__openai-mcp__openai_gpt5_reason',
70
+ 'openai_reason': 'mcp__openai-mcp__openai_reason',
71
71
  'openai_brainstorm': 'mcp__openai-mcp__openai_brainstorm',
72
72
  'think': 'mcp__think-mcp-server__think',
73
73
  };
@@ -81,7 +81,7 @@ export class FocusOrchestratorLite {
81
81
  const toolMap = {
82
82
  'gemini_brainstorm': 'mcp__gemini__gemini-brainstorm',
83
83
  'perplexity_research': 'mcp__perplexity-ask__perplexity_research',
84
- 'openai_reason': 'mcp__openai-mcp__openai_gpt5_reason',
84
+ 'openai_reason': 'mcp__openai-mcp__openai_reason',
85
85
  'openai_brainstorm': 'mcp__openai-mcp__openai_brainstorm',
86
86
  'think': 'mcp__think-mcp-server__think',
87
87
  };
@@ -88,7 +88,7 @@ export class FocusOrchestrator {
88
88
  const toolMap = {
89
89
  'gemini_brainstorm': 'mcp__gemini__gemini-brainstorm',
90
90
  'perplexity_research': 'mcp__perplexity-ask__perplexity_research',
91
- 'openai_reason': 'mcp__openai-mcp__openai_gpt5_reason',
91
+ 'openai_reason': 'mcp__openai-mcp__openai_reason',
92
92
  'openai_brainstorm': 'mcp__openai-mcp__openai_brainstorm',
93
93
  'think': 'mcp__think-mcp-server__think',
94
94
  };
@@ -13,8 +13,7 @@ export const balancedProfile = {
13
13
  grok_architect: false,
14
14
  grok_brainstorm: false,
15
15
  grok_search: true,
16
- openai_gpt5_reason: true,
17
- openai_compare: false,
16
+ openai_reason: true,
18
17
  openai_brainstorm: true,
19
18
  openai_code_review: false,
20
19
  openai_explain: false,
@@ -13,8 +13,7 @@ export const codeFocusProfile = {
13
13
  grok_architect: false,
14
14
  grok_brainstorm: false,
15
15
  grok_search: false,
16
- openai_gpt5_reason: false,
17
- openai_compare: false,
16
+ openai_reason: false,
18
17
  openai_brainstorm: false,
19
18
  openai_code_review: true,
20
19
  openai_explain: false,
@@ -13,8 +13,7 @@ export const fullProfile = {
13
13
  grok_architect: true,
14
14
  grok_brainstorm: true,
15
15
  grok_search: true,
16
- openai_gpt5_reason: true,
17
- openai_compare: true,
16
+ openai_reason: true,
18
17
  openai_brainstorm: true,
19
18
  openai_code_review: true,
20
19
  openai_explain: true,
@@ -13,8 +13,7 @@ export const minimalProfile = {
13
13
  grok_architect: false,
14
14
  grok_brainstorm: false,
15
15
  grok_search: false,
16
- openai_gpt5_reason: false,
17
- openai_compare: false,
16
+ openai_reason: false,
18
17
  openai_brainstorm: false,
19
18
  openai_code_review: false,
20
19
  openai_explain: false,
@@ -13,8 +13,7 @@ export const researchPowerProfile = {
13
13
  grok_architect: false,
14
14
  grok_brainstorm: false,
15
15
  grok_search: true,
16
- openai_gpt5_reason: false,
17
- openai_compare: false,
16
+ openai_reason: false,
18
17
  openai_brainstorm: true,
19
18
  openai_code_review: false,
20
19
  openai_explain: false,
@@ -20,16 +20,17 @@ const envResult = dotenvConfig({
20
20
  path: envPath,
21
21
  override: true // Force override of existing env vars
22
22
  });
23
+ // Import centralized API key utilities
24
+ import { hasGrokApiKey, hasOpenAIApiKey, hasPerplexityApiKey, hasGeminiApiKey, hasOpenRouterApiKey } from "./utils/api-keys.js";
23
25
  // Debug: Log API key status (for troubleshooting)
24
26
  if (process.env.DEBUG === 'true') {
25
27
  console.error('[ENV] Loaded from:', envPath);
26
28
  console.error('[ENV] API Keys present:', {
27
- OPENROUTER: !!process.env.OPENROUTER_API_KEY,
28
- PERPLEXITY: !!process.env.PERPLEXITY_API_KEY,
29
- OPENAI: !!process.env.OPENAI_API_KEY,
30
- GEMINI: !!process.env.GOOGLE_API_KEY,
31
- GROK: !!process.env.GROK_API_KEY,
32
- ANTHROPIC: !!process.env.ANTHROPIC_API_KEY
29
+ OPENROUTER: hasOpenRouterApiKey(),
30
+ PERPLEXITY: hasPerplexityApiKey(),
31
+ OPENAI: hasOpenAIApiKey(),
32
+ GEMINI: hasGeminiApiKey(),
33
+ GROK: hasGrokApiKey()
33
34
  });
34
35
  }
35
36
  import { FastMCP, UserError } from "fastmcp";
@@ -364,7 +365,7 @@ if (isGrokAvailable()) {
364
365
  });
365
366
  console.error(`✅ Registered ${grokTools.length} Grok tools (custom API)`);
366
367
  }
367
- // Register all OpenAI tools (includes gpt5_analyze, gpt5_reason, openai_compare, etc.)
368
+ // Register all OpenAI tools (includes openai_reason, openai_brainstorm, etc.)
368
369
  if (isOpenAIAvailable()) {
369
370
  const openaiTools = getAllOpenAITools();
370
371
  openaiTools.forEach(tool => {
@@ -441,11 +442,11 @@ async function initializeServer() {
441
442
  console.error(`Focus-Deep: ${canRunFocusDeep().quality} quality`);
442
443
  // API Key Status (quick check)
443
444
  const apiStatus = {
444
- OpenRouter: !!process.env.OPENROUTER_API_KEY,
445
- Perplexity: !!process.env.PERPLEXITY_API_KEY,
446
- OpenAI: !!process.env.OPENAI_API_KEY,
447
- Gemini: !!process.env.GOOGLE_API_KEY,
448
- Grok: !!process.env.GROK_API_KEY
445
+ OpenRouter: hasOpenRouterApiKey(),
446
+ Perplexity: hasPerplexityApiKey(),
447
+ OpenAI: hasOpenAIApiKey(),
448
+ Gemini: hasGeminiApiKey(),
449
+ Grok: hasGrokApiKey()
449
450
  };
450
451
  const configured = Object.entries(apiStatus).filter(([_, v]) => v).map(([k, _]) => k);
451
452
  if (configured.length > 0) {