tachibot-mcp 2.35.1 → 2.37.0

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 (40) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +21 -4
  3. package/dist/src/cli/trace.js +194 -0
  4. package/dist/src/config/model-constants.js +79 -39
  5. package/dist/src/config/model-defaults.js +3 -3
  6. package/dist/src/config/model-preferences.js +12 -11
  7. package/dist/src/config/timeout-config.js +22 -0
  8. package/dist/src/config.js +1 -1
  9. package/dist/src/modes/architect.js +1 -1
  10. package/dist/src/optimization/model-router.js +12 -6
  11. package/dist/src/sequential-thinking.js +3 -0
  12. package/dist/src/server-main.js +56 -6
  13. package/dist/src/server.js +10 -0
  14. package/dist/src/tools/gemini-tools.js +20 -6
  15. package/dist/src/tools/grok-enhanced.js +0 -1
  16. package/dist/src/tools/grok-tools.js +10 -2
  17. package/dist/src/tools/jury-tool.js +2 -2
  18. package/dist/src/tools/openai-tools.js +161 -74
  19. package/dist/src/tools/openrouter-tools.js +16 -9
  20. package/dist/src/tools/perplexity-tools.js +2 -2
  21. package/dist/src/tools/planner-tools.js +2 -2
  22. package/dist/src/tools/provider-catalog.js +1 -1
  23. package/dist/src/tools/registry.js +9 -4
  24. package/dist/src/utils/api-keys.js +72 -7
  25. package/dist/src/utils/client-render.js +35 -0
  26. package/dist/src/utils/format-constants.js +2 -1
  27. package/dist/src/utils/judge-runner.js +3 -1
  28. package/dist/src/utils/openai-transport.js +60 -0
  29. package/dist/src/utils/openrouter-gateway.js +3 -1
  30. package/dist/src/utils/provider-lock.js +105 -0
  31. package/dist/src/utils/trace-bus.js +150 -0
  32. package/dist/src/utils/trace-open.js +69 -0
  33. package/dist/src/utils/trace-page.js +157 -0
  34. package/dist/src/utils/trace-server.js +215 -0
  35. package/dist/src/workflows/tool-mapper.js +9 -5
  36. package/docs/API_KEYS.md +34 -0
  37. package/docs/CONFIGURATION.md +24 -0
  38. package/docs/TOOLS_REFERENCE.md +4 -4
  39. package/docs/plans/2026-11-13-azure-foundry-backend.md +182 -0
  40. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,41 @@ All notable changes to TachiBot MCP will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.37.0] - 2026-12-04
9
+
10
+ ### Changed
11
+ - **GPT-6.2 Astra is the OpenAI default.** `gpt-6.2-astra` (Nov 17, 2026; $8/$40) replaces `gpt-6-astra` ($10/$50) and falls back to it when a key has no 6.2 access.
12
+ - **The mid tier moves to `gpt-6.2-sol`** (same $2/$10 as `gpt-6.1-sol`, which is now its fallback). It runs `openai_search`, `openai_explain`, the jury's GPT juror, the planner's critique step and the judge escalation.
13
+ - **Code tasks move to `gpt-6.1-terra`** ($1/$5, half the price of `gpt-5.6-terra`, which is now its fallback).
14
+ - **Gemini 4 Carbon is the reasoning and judge default.** Google deprecated `gemini-4-argon` on Dec 1, 2026 and serves it with `gemini-4-carbon` from Dec 15. Carbon costs $4/$20, the price Argon moved to on Dec 1. `TACHI_GEMINI_PRO_MODEL` still overrides the choice.
15
+ - **`gemini-4-neon` and `gemini-4-hydrogen` are known models** with prices, and Neon shares Carbon's fallback to `gemini-3.1-pro-preview`. No tool uses them by default.
16
+ - `openai_reason` and `openai_code_review` accept the three new ids in their `model` parameter.
17
+ - **Azure users: add the new ids to `AZURE_OPENAI_DEPLOYMENTS`.** The tools now ask for `gpt-6.2-astra`, `gpt-6.2-sol` and `gpt-6.1-terra`. A mapping that lists only the old ids sends the new ones to Azure unmapped, so each call fails over to an older deployment with a `[degraded: …]` banner. Not verified against a live Azure resource.
18
+
19
+ ### Fixed
20
+ - **Cost tracking priced `gemini-4-argon` at its expired intro rate** ($2/$10). It now uses $4/$20.
21
+ - **Cost tracking had no price for `grok-4.7`, `grok-4.6` or `gemini-3.8-flash`.**
22
+ - **`openai_search` had no model fallback.** A key without access to the current sol tier got an error instead of search. It now falls back through the same chain as the other OpenAI tools (`gpt-6.2-sol` → `gpt-6.1-sol` → `gpt-6-sol`) and says so in the answer. `TACHI_MODEL_FALLBACK=off` still disables it.
23
+ - **The judge named the wrong model after a double fallback.** When Gemini was down and the OpenAI escalation itself fell back, the verdict was credited to the model that was asked, not the one that answered.
24
+
25
+ ### Removed
26
+ - **`grok-build-0.1` is no longer offered.** xAI stopped serving it on Nov 19, 2026.
27
+
28
+ ## [2.36.0] - 2026-11-26
29
+
30
+ ### Added
31
+ - **Azure OpenAI transport (experimental).** Set `TACHI_OPENAI_TRANSPORT=azure` with `AZURE_OPENAI_ENDPOINT` and `AZURE_OPENAI_API_KEY` (or `AZURE_OPENAI_AD_TOKEN`), and the OpenAI tools call your Azure resource's v1 endpoint instead of api.openai.com. Every other provider works as before. `AZURE_OPENAI_DEPLOYMENTS="gpt-6-astra=corp-astra,..."` maps model ids to deployment names. Ambient `AZURE_OPENAI_*` variables alone never switch the transport. **Not yet verified against a live Azure resource** (tests use a mocked endpoint).
32
+ - **Azure-only mode: `TACHI_PROVIDER_LOCK=azure`.** Only the Azure-backed OpenAI tools and the keyless tools register, whatever other keys are set. A `fetch` to any origin other than the Azure resource or loopback is refused before it is sent, and redirects are refused. `openai_search` needs `AZURE_ALLOW_WEB_SEARCH=1`, because Azure web search uses Bing grounding, which leaves the tenant's compliance boundary. The guard covers `fetch` only; it is not an OS-level firewall. Tools that need a Gemini judge (`jury`, `diff_review`, `plan_critique`) are not available in this mode yet. See [docs/API_KEYS.md](docs/API_KEYS.md).
33
+ - **Azure fails closed.** Once Azure is selected, a missing endpoint or credential, a non-https endpoint or a mistyped value gives no transport at all, never a fall-through to api.openai.com on a leftover `OPENAI_API_KEY`. A mistyped lock value, or a lock without a usable Azure config, stops the server at startup.
34
+ - **Live trace view.** `TACHIBOT_TRACE_UI=1` shows tool calls, model calls and `nextThought` steps as they happen, in a browser page or a terminal pane (`tachibot trace`). Local only (`127.0.0.1`, per-process token). See [docs/CONFIGURATION.md](docs/CONFIGURATION.md#live-trace-view).
35
+ - **`TACHI_REASONING_TIMEOUT_MS`** overrides the request timeout for OpenAI and Grok reasoning calls.
36
+
37
+ ### Changed
38
+ - **Reasoning calls get longer timeouts**, scaled by effort: 300s at high, 600s at xhigh and for Grok, 900s at max. The old flat 180s cut real `gpt-6-astra` xhigh runs short and fell back to a smaller model.
39
+ - **The OpenAI fallback chain has an overall time budget** of twice one attempt's timeout, so a slow chain can't run for the sum of every model's timeout.
40
+ - **A 401 or a content-filter stop ends the OpenAI fallback chain.** Another model is not asked to answer what a policy rejected.
41
+ - **Larger output budgets for the Kimi and MiniMax tools** (8K–12K tokens, up from 3K–4.5K). Decompositions and long answers were being cut off mid-task.
42
+
8
43
  ## [2.35.1] - 2026-10-15
9
44
 
10
45
  ### Changed
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ### Multi-Model AI Orchestration Platform
6
6
 
7
- [![Version](https://img.shields.io/badge/version-2.34.0-blue.svg)](https://www.npmjs.com/package/tachibot-mcp)
7
+ [![Version](https://img.shields.io/badge/version-2.37.0-blue.svg)](https://www.npmjs.com/package/tachibot-mcp)
8
8
  [![Tools](https://img.shields.io/badge/tools-67_active-brightgreen.svg)](#-tool-ecosystem-67-tools)
9
9
  [![License](https://img.shields.io/badge/license-AGPL--3.0-green.svg)](LICENSE)
10
10
  [![Node](https://img.shields.io/badge/node-%3E%3D22.0.0-brightgreen.svg)](https://nodejs.org)
@@ -12,7 +12,7 @@
12
12
 
13
13
  **67 AI tools. 11 providers. One protocol.**
14
14
 
15
- Orchestrate Perplexity, Grok 4.6, GPT-6 Astra, Gemini, Qwen, Kimi K3, and MiniMax M3
15
+ Orchestrate Perplexity, Grok 4.7, GPT-6.2 Astra, Gemini, Qwen, Kimi K3, and MiniMax M3
16
16
  from Claude Code, Claude Desktop, Cursor, or any MCP client.
17
17
 
18
18
  [Get Started](#-quick-start) · [View Tools](#-tool-ecosystem-67-tools) · [Documentation](https://tachibot.com/docs)
@@ -30,6 +30,23 @@ from Claude Code, Claude Desktop, Cursor, or any MCP client.
30
30
 
31
31
  ## What's New
32
32
 
33
+ ### v2.37.0
34
+ - **GPT-6.2 Astra is the OpenAI default.** `gpt-6.2-astra` ($8/$40) replaces `gpt-6-astra` ($10/$50) and falls back to it when a key has no 6.2 access.
35
+ - **The mid tier moves to `gpt-6.2-sol`** at the same $2/$10. It runs `openai_search`, `openai_explain`, the jury's GPT juror, the planner's critique step and the judge escalation.
36
+ - **Code tasks move to `gpt-6.1-terra`** ($1/$5), half the price of `gpt-5.6-terra`, which stays as its fallback.
37
+ - **Gemini 4 Carbon is the reasoning and judge default.** Google deprecated `gemini-4-argon` on Dec 1, 2026 and serves it with `gemini-4-carbon` from Dec 15. `TACHI_GEMINI_PRO_MODEL` still overrides the choice.
38
+ - **Fixes:** cost tracking priced `gemini-4-argon` at its expired intro rate and had no price for `grok-4.7`, `grok-4.6` or `gemini-3.8-flash`.
39
+ - **`grok-build-0.1` is no longer offered.** xAI stopped serving it on Nov 19, 2026.
40
+ - Tool count unchanged at 67.
41
+
42
+ ### v2.36.0
43
+ - **Azure OpenAI (experimental).** Set `TACHI_OPENAI_TRANSPORT=azure` plus `AZURE_OPENAI_ENDPOINT` and a key, and the OpenAI tools call your Azure resource instead of api.openai.com. Every other provider works as before. `AZURE_OPENAI_DEPLOYMENTS` maps model ids to your deployment names. Not yet verified against a live Azure resource.
44
+ - **Azure-only mode.** `TACHI_PROVIDER_LOCK=azure` registers only the Azure-backed OpenAI tools and the keyless tools, and refuses any `fetch` to another origin. Web search is off unless you set `AZURE_ALLOW_WEB_SEARCH=1`. `jury`, `diff_review` and `plan_critique` are not available in this mode yet. See the [API Keys Guide](docs/API_KEYS.md).
45
+ - **Live trace view.** `TACHIBOT_TRACE_UI=1` shows tool calls, model calls and thinking steps as they happen, in a browser page or a terminal pane (`tachibot trace`). Local only. See [Configuration](docs/CONFIGURATION.md#live-trace-view).
46
+ - **Longer timeouts for reasoning calls**, scaled by effort (up to 900s at max), so high-effort runs no longer fall back to a smaller model. Override with `TACHI_REASONING_TIMEOUT_MS`.
47
+ - **Larger output budgets for the Kimi and MiniMax tools**, which were cutting long answers off.
48
+ - Tool count unchanged at 67.
49
+
33
50
  ### v2.35.1
34
51
  - **The planner's code analysis runs on DeepSeek V4 Pro** instead of Qwen3-Coder-Next, the one small model in the council. That adds a sixth lab. Set `TACHI_PLANNER_TIER=standard` for the cheaper lineup.
35
52
  - **The jury's GPT juror is pinned to `gpt-6.1-sol`.** It had been silently getting the cheap `gpt-6-luna` default. Override with `TACHI_JURY_OPENAI_MODEL`.
@@ -183,9 +200,9 @@ Skills automatically adapt to your configured API keys. Even with just 1-2 provi
183
200
 
184
201
  ### Multi-Model Intelligence
185
202
  - **67 AI Tools** across 11 providers — Perplexity, Grok, GPT-6, Gemini, Qwen, Kimi, MiniMax, DeepSeek, GLM (Zhipu), StepFun, TypeSafe Jev, plus free local models (Ollama / LM Studio / llama.cpp / vLLM)
186
- - **Gemini 4 Argon** (`gemini-4-argon`, GA Oct 13 2026) — reasoning/judge default; set `TACHI_GEMINI_PRO_MODEL=gemini-3.1-pro-preview` to roll back. Flash/search tier is `gemini-3.8-flash`
203
+ - **Gemini 4 Carbon** (`gemini-4-carbon`, GA Nov 10 2026) — reasoning/judge default (Argon was deprecated Dec 1 2026); set `TACHI_GEMINI_PRO_MODEL=gemini-3.1-pro-preview` to roll back. Flash/search tier is `gemini-3.8-flash`
187
204
  - **Multi-Model Council** — planner_maker synthesizes plans from six labs into bite-sized TDD steps. Code analysis runs on DeepSeek V4 Pro; set `TACHI_PLANNER_TIER=standard` for the cheaper Qwen3-Coder-Next lineup
188
- - **Jury** — the GPT juror runs on `gpt-6.1-sol`; override with `TACHI_JURY_OPENAI_MODEL` (e.g. `gpt-6-astra`)
205
+ - **Jury** — the GPT juror runs on `gpt-6.2-sol`; override with `TACHI_JURY_OPENAI_MODEL` (e.g. `gpt-6.2-astra`)
189
206
  - **Smart Routing** — Automatic model selection for optimal results
190
207
  - **OpenRouter Gateway** — Optional single API key for all providers
191
208
 
@@ -0,0 +1,194 @@
1
+ /**
2
+ * `tachibot trace [--pid <pid>]` — live text view of a running tachibot's trace
3
+ * stream, for any terminal pane. Finds the server through the 0600 registry
4
+ * written by trace-server.ts (newest live one, or the given pid) and follows
5
+ * the SSE stream; reconnects to the newest server if the current one exits.
6
+ *
7
+ * Append-only output (no screen redraw) so it works in every terminal and
8
+ * scrollback stays intact.
9
+ */
10
+ import fs from 'node:fs';
11
+ import http from 'node:http';
12
+ import path from 'node:path';
13
+ import { getTraceRegistryDir } from '../utils/trace-server.js';
14
+ const c = {
15
+ reset: '\x1b[0m', dim: '\x1b[2m', bold: '\x1b[1m',
16
+ blue: '\x1b[34m', green: '\x1b[32m', red: '\x1b[31m', yellow: '\x1b[33m', magenta: '\x1b[35m',
17
+ };
18
+ /**
19
+ * Event text is model/tool output, i.e. untrusted: drop C0/C1 control characters (ESC, BEL,
20
+ * CSI…) so it cannot emit escape sequences into the viewer's terminal, and the bidi /
21
+ * zero-width format characters that reorder or hide text on screen. Tab/newline are kept
22
+ * here and collapsed by oneLine; the renderer's own colour codes are added afterwards.
23
+ */
24
+ function safe(s) {
25
+ return String(s ?? '').replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u200B-\u200F\u202A-\u202E\u2066-\u2069\uFEFF]/g, '');
26
+ }
27
+ /** Finished spans are kept so a late child still indents under them — up to this many. */
28
+ const MAX_TRACKED_SPANS = 5000;
29
+ function oneLine(s, max) {
30
+ const line = safe(s).replace(/\s+/g, ' ').trim();
31
+ return line.length > max ? `${line.slice(0, Math.max(0, max - 1))}…` : line;
32
+ }
33
+ function secs(ms) {
34
+ return ms === undefined ? '' : `${(ms / 1000).toFixed(1)}s`;
35
+ }
36
+ /**
37
+ * Every reconnect replays the server's buffer. Returns a predicate that is true the first
38
+ * time an event is seen, so a reconnect does not print the whole history again.
39
+ */
40
+ export function createReplayFilter(max = 20000) {
41
+ const seen = new Set();
42
+ return (e) => {
43
+ const key = `${e.type}:${e.id}`;
44
+ if (seen.has(key))
45
+ return false;
46
+ seen.add(key);
47
+ if (seen.size > max)
48
+ seen.delete(seen.values().next().value);
49
+ return true;
50
+ };
51
+ }
52
+ /** Stateful renderer: tracks span depth so children indent under their tool. */
53
+ export function createTraceRenderer(width = () => process.stdout.columns || 100) {
54
+ const depth = new Map();
55
+ return (raw) => {
56
+ const e = {
57
+ ...raw,
58
+ name: oneLine(raw.name, 200),
59
+ ...(raw.model !== undefined && { model: oneLine(raw.model, 200) }),
60
+ ...(raw.degradedTo !== undefined && { degradedTo: oneLine(raw.degradedTo, 200) }),
61
+ };
62
+ const d = e.parentId !== undefined ? (depth.get(e.parentId) ?? 0) + 1 : 0;
63
+ if (e.type === 'span.start') {
64
+ depth.set(e.id, d);
65
+ // bound memory on a long-running view: forget the oldest span (Map keeps insertion order)
66
+ if (depth.size > MAX_TRACKED_SPANS)
67
+ depth.delete(depth.keys().next().value);
68
+ }
69
+ const pad = ' '.repeat(d);
70
+ const room = Math.max(20, width() - pad.length - 30);
71
+ const time = new Date(e.ts).toLocaleTimeString();
72
+ if (e.type === 'usage') {
73
+ const n = (v) => (typeof v === 'number' && Number.isFinite(v) ? String(v) : '?');
74
+ const reasoning = typeof e.tokensReasoning === 'number' ? ` (${n(e.tokensReasoning)} reasoning)` : '';
75
+ return `${pad}${c.dim}∑ tokens ${n(e.tokensIn)} in / ${n(e.tokensOut)} out${reasoning}${c.reset}`;
76
+ }
77
+ if (e.type === 'thought') {
78
+ const who = e.model ? ` ${c.dim}(${e.model})${c.reset}` : '';
79
+ return `${pad}${c.magenta}◆ thought ${Number(e.thoughtNumber) || 0}${c.reset}${who} ${oneLine(e.input, room)}`;
80
+ }
81
+ if (e.type === 'span.start') {
82
+ return e.kind === 'tool'
83
+ ? `${pad}${c.bold}${c.blue}▶ ${e.name}${c.reset} ${c.dim}${time}${c.reset}`
84
+ : `${pad}${c.dim}… ${e.name}${c.reset}`;
85
+ }
86
+ // span.end
87
+ if (e.error) {
88
+ return `${pad}${c.red}✗ ${e.name}${c.reset} ${c.dim}${secs(e.ms)}${c.reset} ${c.red}${oneLine(e.error, room)}${c.reset}`;
89
+ }
90
+ const fallback = e.degradedTo ? ` ${c.yellow}↳ fell back to ${e.degradedTo}${c.reset}` : '';
91
+ if (e.kind === 'tool') {
92
+ return `${pad}${c.green}■ ${e.name}${c.reset} ${c.dim}done ${secs(e.ms)}${c.reset}\n${pad} ${c.dim}${oneLine(e.output, room)}${c.reset}`;
93
+ }
94
+ return `${pad}${c.green}✓ ${e.name}${c.reset} ${c.dim}${secs(e.ms)}${c.reset}${fallback}`;
95
+ };
96
+ }
97
+ function alive(pid) {
98
+ try {
99
+ process.kill(pid, 0);
100
+ return true;
101
+ }
102
+ catch (err) {
103
+ return err.code === 'EPERM';
104
+ }
105
+ }
106
+ /** Newest live registry entry, or the one for `pid`. Stale files are removed. */
107
+ export function findTraceServer(pid, dir = getTraceRegistryDir()) {
108
+ let files;
109
+ try {
110
+ files = fs.readdirSync(dir).filter((f) => f.endsWith('.json'));
111
+ }
112
+ catch {
113
+ return undefined;
114
+ }
115
+ const entries = [];
116
+ for (const f of files) {
117
+ const file = path.join(dir, f);
118
+ try {
119
+ const entry = JSON.parse(fs.readFileSync(file, 'utf8'));
120
+ if (!alive(entry.pid)) {
121
+ fs.rmSync(file, { force: true });
122
+ continue;
123
+ }
124
+ entries.push(entry);
125
+ }
126
+ catch {
127
+ // half-written or foreign file — ignore
128
+ }
129
+ }
130
+ if (pid !== undefined)
131
+ return entries.find((e) => e.pid === pid);
132
+ return entries.sort((a, b) => b.startedAt - a.startedAt)[0];
133
+ }
134
+ function follow(entry, render, isNew = () => true) {
135
+ return new Promise((resolve) => {
136
+ const req = http.get({ host: '127.0.0.1', port: entry.port, path: `/events?t=${entry.token}`, headers: { Host: `127.0.0.1:${entry.port}` } }, (res) => {
137
+ if (res.statusCode !== 200) {
138
+ res.resume();
139
+ resolve();
140
+ return;
141
+ }
142
+ let buf = '';
143
+ res.setEncoding('utf8');
144
+ res.on('data', (chunk) => {
145
+ buf += chunk;
146
+ let i;
147
+ while ((i = buf.indexOf('\n\n')) >= 0) {
148
+ const frame = buf.slice(0, i);
149
+ buf = buf.slice(i + 2);
150
+ if (!frame.startsWith('data: '))
151
+ continue;
152
+ try {
153
+ const event = JSON.parse(frame.slice(6));
154
+ if (isNew(event))
155
+ console.log(render(event));
156
+ }
157
+ catch {
158
+ // malformed frame — skip
159
+ }
160
+ }
161
+ });
162
+ res.on('end', resolve);
163
+ res.on('error', () => resolve());
164
+ });
165
+ req.on('error', () => resolve());
166
+ });
167
+ }
168
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
169
+ export async function runTraceCli(argv) {
170
+ const pidArg = argv.indexOf('--pid');
171
+ let pid = pidArg >= 0 ? Number(argv[pidArg + 1]) : undefined;
172
+ if (pid !== undefined && !Number.isInteger(pid))
173
+ pid = undefined;
174
+ console.log(`${c.bold}TachiBot trace${c.reset} ${c.dim}— waiting for a tachibot with TACHIBOT_TRACE_UI=1… (Ctrl+C to quit)${c.reset}`);
175
+ let lastPid;
176
+ let isNew = createReplayFilter();
177
+ for (;;) {
178
+ // a pinned pid is followed until it exits, then we fall back to the newest server
179
+ const entry = findTraceServer(pid) ?? (pid !== undefined ? findTraceServer() : undefined);
180
+ if (!entry) {
181
+ await sleep(1500);
182
+ continue;
183
+ }
184
+ if (entry.pid !== lastPid) {
185
+ console.log(`${c.dim}── connected to pid ${Number(entry.pid)} (${safe(entry.cwd)}) ──${c.reset}`);
186
+ lastPid = entry.pid;
187
+ isNew = createReplayFilter(); // event ids are per server process
188
+ }
189
+ await follow(entry, createTraceRenderer(), isNew);
190
+ if (pid !== undefined && !alive(pid))
191
+ pid = undefined;
192
+ await sleep(1000);
193
+ }
194
+ }
@@ -6,7 +6,12 @@
6
6
  // =============================================================================
7
7
  // OPENAI MODELS (provider-based naming)
8
8
  // =============================================================================
9
- // GPT-6 Astra released Sep 3, 2026 - CURRENT DEFAULT. `gpt-6-astra`: $10/$50 (cached $1),
9
+ // GPT-6.2 Astra + Sol released Nov 17, 2026 - CURRENT DEFAULT + mid tier. `gpt-6.2-astra`: $8/$40
10
+ // (cached $0.40) — 20% below gpt-6-astra; `gpt-6.2-sol`: $2/$10 (same as 6.1-sol). GPT-6.1 Terra
11
+ // (Oct 26, 2026): `gpt-6.1-terra` $1/$5 — half of gpt-5.6-terra. All three verified live Dec 4, 2026
12
+ // through callOpenAI (Responses API, effort low and max on Astra, no temperature). Same param
13
+ // rules as gpt-6-astra below. Each falls back to its predecessor.
14
+ // GPT-6 Astra released Sep 3, 2026 - previous default. `gpt-6-astra`: $10/$50 (cached $1),
10
15
  // 1.05M ctx, 128K out. Verified live Sep 14, 2026 against /v1/models and /v1/responses:
11
16
  // reasoning.effort accepts ONLY low|medium|high|xhigh|max ("none"/"minimal" are a 400, so
12
17
  // callOpenAI maps them to "low"), and temperature must stay at the default — sending 0.7 is
@@ -20,30 +25,36 @@
20
25
  // "Pro" is not an API model: flagship + reasoning.effort (the $30/$180 gpt-5.5-pro tier is gone).
21
26
  // GPT-5.5 (Apr 23, 2026) kept as fallback. OpenRouter uses prefix: openai/gpt-6-astra etc.
22
27
  export const OPENAI_MODELS = {
23
- // GPT-6 Astra (Sep 3, 2026 - CURRENT)
24
- DEFAULT: "gpt-6-astra", // Flagship: computer use, coding, science. $10/$50 (2x sol input)
25
- ASTRA: "gpt-6-astra", // Explicit alias
26
- // GPT-6 mid/budget tiers (Sep 2026). No gpt-6-terra exists — TERRA stays on 5.6.
27
- SOL: "gpt-6.1-sol", // GPT-6.1 mid tier (Sep 29, 2026 DevDay): $2/$10, replaced gpt-6-sol. Astra's first fallback
28
- SOL_6_0: "gpt-6-sol", // Previous mid tier (Sep 14, 2026): $2/$10 — 6.1-sol's fallback
29
- TERRA: "gpt-5.6-terra", // Balanced: gpt-5.5-level at $2/$12 (Jul 30, 2026 cut: -20%)
28
+ // GPT-6.2 Astra (Nov 17, 2026 - CURRENT)
29
+ DEFAULT: "gpt-6.2-astra", // Flagship: $8/$40 (cached $0.40), 1.05M ctx / 128K out
30
+ ASTRA: "gpt-6.2-astra", // Explicit alias
31
+ ASTRA_6_0: "gpt-6-astra", // Previous flagship (Sep 3, 2026): $10/$50 — 6.2-astra's first fallback
32
+ // GPT-6 mid/budget tiers. No gpt-6-terra exists — the terra line went 5.6 -> 6.1.
33
+ SOL: "gpt-6.2-sol", // GPT-6.2 mid tier (Nov 17, 2026): $2/$10, replaced gpt-6.1-sol
34
+ SOL_6_1: "gpt-6.1-sol", // Previous mid tier (Sep 29, 2026): $2/$10 — 6.2-sol's fallback
35
+ SOL_6_0: "gpt-6-sol", // Older mid tier (Sep 14, 2026): $2/$10 — 6.1-sol's fallback
36
+ TERRA: "gpt-6.1-terra", // Fast lower-cost tier (Oct 26, 2026): $1/$5 — powers `code`
37
+ TERRA_5_6: "gpt-5.6-terra", // Previous terra: $2/$12 — 6.1-terra's fallback and the chain's last resort
30
38
  LUNA: "gpt-6-luna", // GPT-6 budget tier (Sep 14, 2026): $0.10/$0.50 (was gpt-5.6-luna $0.20/$1.20).
31
39
  // Now ~9x cheaper than terra, not 2.5x — worth routing to it
32
40
  // far more aggressively. (Weak long-context recall: avoid huge inputs.)
33
41
  MINI: "gpt-6-luna", // "mini" tier successor (was gpt-5.4-mini)
34
- PRO: "gpt-6-astra", // No pro API model — Astra + reasoning.effort xhigh/max (was gpt-5.5-pro $30/$180)
42
+ PRO: "gpt-6.2-astra", // No pro API model — Astra + reasoning.effort xhigh/max (was gpt-5.5-pro $30/$180)
35
43
  // GPT-5.5 (Apr 2026) - fallback
36
44
  FALLBACK_5_5: "gpt-5.5",
37
45
  // Aliases for backward compatibility
38
- THINKING: "gpt-6-astra", // "Thinking" = flagship with high reasoning effort
39
- FULL: "gpt-6-astra", // Map old FULL to DEFAULT
40
- CODEX: "gpt-5.6-terra", // Coding workhorse tier
46
+ THINKING: "gpt-6.2-astra", // "Thinking" = flagship with high reasoning effort
47
+ FULL: "gpt-6.2-astra", // Map old FULL to DEFAULT
48
+ CODEX: "gpt-6.1-terra", // Coding workhorse tier
41
49
  CODEX_MINI: "gpt-6-luna", // Cheapest tier
42
- CODEX_MAX: "gpt-6-astra", // Map old codex-max to flagship (use high effort)
50
+ CODEX_MAX: "gpt-6.2-astra", // Map old codex-max to flagship (use high effort)
43
51
  INSTANT: "gpt-6-luna", // Fast tier
44
52
  };
45
53
  // OpenRouter model ID mapping (add prefix when using OpenRouter gateway)
46
54
  export const OPENROUTER_PREFIX_MAP = {
55
+ "gpt-6.2-astra": "openai/",
56
+ "gpt-6.2-sol": "openai/",
57
+ "gpt-6.1-terra": "openai/",
47
58
  "gpt-6-astra": "openai/",
48
59
  "gpt-6.1-sol": "openai/",
49
60
  "gpt-6-sol": "openai/",
@@ -72,30 +83,38 @@ export const OPENAI_REASONING = {
72
83
  // =============================================================================
73
84
  // GEMINI MODELS (Google)
74
85
  // =============================================================================
75
- // Gemini 4 Argon GA'd Oct 13, 2026 — the new PRO/reasoning/judge default (verified live 2026-10-14:
76
- // chat + google_search grounding). $2/$10 intro through Nov 30, 2026, then $4/$20 (thinking tokens bill
77
- // as output). 1M ctx in, but only 32K out (3.x Pro/Flash allow 65K) — no current caller asks for >18K.
78
- // Swap back without a code change: TACHI_GEMINI_PRO_MODEL=gemini-3.1-pro-preview (read lazily, so the
86
+ // Gemini 4 Carbon GA'd Nov 10, 2026 — the PRO/reasoning/judge default since Dec 4, 2026 (verified live
87
+ // that day through callGemini). $4/$20, cached $0.20 (intro $2/$10 ended Nov 30). 1M ctx, 65K out.
88
+ // Siblings: gemini-4-neon (Nov 18, $3/$15, the faster co-flagship) and gemini-4-hydrogen (Nov 12,
89
+ // $1.50/$7.50, Google's general-purpose default and the migration target from 3.8 Flash).
90
+ // Gemini 4 Argon (GA Oct 13, 2026) was the default until then. Google deprecated it Dec 1, 2026:
91
+ // from Dec 15, 2026 API requests for gemini-4-argon are served by gemini-4-carbon at Carbon rates.
92
+ // $4/$20 since Dec 1; 1M ctx in, 32K out.
93
+ // Swap the Pro model without a code change: TACHI_GEMINI_PRO_MODEL=gemini-3.1-pro-preview (read lazily, so the
79
94
  // value from .env is honored even though this module loads before dotenv runs).
80
- // Gemini 3.7 Flash GA'd Aug 13, 2026 — the new workhorse/FLASH/search tier, 1M ctx,
81
- // $0.75/$3.75 intro pricing through Dec 31, 2026 (then $1.50/$7.50). 3.6 Flash
95
+ // Gemini 3.8 Flash (Sep 2, 2026) is the FLASH/search tier: $0.75/$3.75 through Dec 31, 2026, then
96
+ // $1.50/$7.50 from Jan 1, 2027 — the same price as gemini-4-hydrogen, so re-evaluate FLASH then.
97
+ // Gemini 3.7 Flash GA'd Aug 13, 2026; Google now serves requests for it with 3.8 Flash. 3.6 Flash
82
98
  // (Jul 21, 2026, $1.50/$7.50) stays live as the fallback. Gemini 3.5 Flash-Lite
83
99
  // shipped the same day ($0.30/$2.50) and replaces 3.1-flash-lite as the cheap tier.
84
100
  // Gemini 3.5 Pro STILL has not shipped (missed its June window; "testing with partners",
85
101
  // Gemini 4 pre-training underway — reverified via ai.google.dev Aug 29, 2026), so the
86
- // reasoning default stayed on gemini-3.1-pro-preview until Argon (it is Argon's fallback now).
87
- export const GEMINI_PRO_DEFAULT = "gemini-4-argon";
88
- /** Active Gemini Pro-tier model: TACHI_GEMINI_PRO_MODEL override, else Gemini 4 Argon. */
102
+ // reasoning default stayed on gemini-3.1-pro-preview until Argon (it is the Gemini 4 fallback now).
103
+ export const GEMINI_PRO_DEFAULT = "gemini-4-carbon";
104
+ /** Active Gemini Pro-tier model: TACHI_GEMINI_PRO_MODEL override, else Gemini 4 Carbon. */
89
105
  export function getGeminiProModel() {
90
106
  return process.env.TACHI_GEMINI_PRO_MODEL?.trim() || GEMINI_PRO_DEFAULT;
91
107
  }
92
108
  export const GEMINI_MODELS = {
93
109
  // Pro tier — getters so the env override is read at call time, not at import time
94
110
  get GEMINI_3_PRO() { return getGeminiProModel(); }, // Legacy key name: "the default Pro model"
95
- GEMINI_4_ARGON: "gemini-4-argon", // Oct 13, 2026 GA: frontier reasoning, 1M in / 32K out, $2/$10 → $4/$20 Dec 1
96
- GEMINI_3_1_PRO: "gemini-3.1-pro-preview", // Previous Pro default (Mar 2026), 65K out — Argon's fallback
111
+ GEMINI_4_CARBON: "gemini-4-carbon", // Nov 10, 2026 GA - CURRENT Pro default: flagship reasoning, 1M ctx / 65K out, $4/$20
112
+ GEMINI_4_NEON: "gemini-4-neon", // Nov 18, 2026 GA: faster co-flagship, 1M ctx / 65K out, $3/$15
113
+ GEMINI_4_HYDROGEN: "gemini-4-hydrogen", // Nov 12, 2026 GA: general-purpose tier, 1M ctx / 65K out, $1.50/$7.50
114
+ GEMINI_4_ARGON: "gemini-4-argon", // DEPRECATED Dec 1, 2026 (served by Carbon from Dec 15): 1M in / 32K out, $4/$20
115
+ GEMINI_3_1_PRO: "gemini-3.1-pro-preview", // Older Pro default (Mar 2026), 65K out — the Gemini 4 fallback
97
116
  GEMINI_3_8_FLASH: "gemini-3.8-flash", // Sep 2, 2026 - CURRENT flash/search tier, 1M ctx, $0.75/$3.75 (verified 2026-09-29)
98
- GEMINI_3_7_FLASH: "gemini-3.7-flash", // GA Aug 13, 2026 - previous flash tier (fallback), $0.75/$3.75 intro
117
+ GEMINI_3_7_FLASH: "gemini-3.7-flash", // GA Aug 13, 2026 - previous flash tier; Google serves it with 3.8 Flash now
99
118
  GEMINI_3_6_FLASH: "gemini-3.6-flash", // GA Jul 21, 2026 - previous flash tier (fallback), $1.50/$7.50
100
119
  GEMINI_3_5_FLASH: "gemini-3.5-flash", // GA May 19, 2026 - previous flash tier (fallback)
101
120
  GEMINI_3_FLASH: "gemini-3-flash-preview", // Legacy fast frontier (kept for model-router)
@@ -135,7 +154,7 @@ export const GROK_MODELS = {
135
154
  // 1M context, $1.25/$2.50, lowest verified hallucination rate.
136
155
  _4_3: "grok-4.3", // Fallback: 1M ctx, $1.25/$2.50, reasoning.effort low|high
137
156
  _4_3_LATEST: "grok-4.3-latest", // Rolling alias for newest 4.3 snapshot
138
- _BUILD: "grok-build-0.1", // Coding specialist (May 29, 2026): 256k ctx, fast agentic coding
157
+ _BUILD: "grok-build-0.1", // [RETIRED Nov 19, 2026 — no longer served] key kept for back-compat, do NOT call
139
158
  // Grok 4.20 models (Mar 10, 2026) - LEGACY keys. Deprecated keys now resolve to the current flagship (4.5).
140
159
  _4_20_REASONING: "grok-4.7", // [deprecated key] → grok-4.7 (was grok-4.20-0309-reasoning)
141
160
  _4_20_NON_REASONING: "grok-4.7", // [deprecated key] → grok-4.7 (was grok-4.20-0309-non-reasoning)
@@ -247,6 +266,9 @@ export const DEFAULT_WORKFLOW_SETTINGS = {
247
266
  // When new models release, update ONLY this section!
248
267
  // All tools automatically use the new models.
249
268
  // ============================================================================
269
+ // UPDATED Dec 4, 2026: OpenAI default gpt-6-astra -> gpt-6.2-astra, SOL gpt-6.1-sol -> gpt-6.2-sol (Nov 17),
270
+ // TERRA gpt-5.6-terra -> gpt-6.1-terra (Oct 26); Gemini Pro gemini-4-argon -> gemini-4-carbon (Argon
271
+ // deprecated Dec 1, served by Carbon from Dec 15); grok-build-0.1 retired by xAI Nov 19. Grok 4.7 unchanged.
250
272
  // UPDATED Oct 14, 2026: Gemini Pro 3.1-pro-preview -> gemini-4-argon (Oct 13 GA; env-switchable);
251
273
  // OpenAI SOL gpt-6-sol -> gpt-6.1-sol (Sep 29); openai_search terra -> 6.1-sol; grok_search 4.6 -> 4.7;
252
274
  // StepFun 3.7-flash -> step-5-preview (Oct 8); ERNIE removed (Baidu left OpenRouter Oct 8).
@@ -259,15 +281,15 @@ export const DEFAULT_WORKFLOW_SETTINGS = {
259
281
  // StepFun 3.7, ERNIE 4.5 VL, Qwen Coder-Next, Perplexity Sonar.
260
282
  export const CURRENT_MODELS = {
261
283
  openai: {
262
- default: OPENAI_MODELS.DEFAULT, // gpt-6-astra - flagship (Sep 3, 2026), $10/$50
284
+ default: OPENAI_MODELS.DEFAULT, // gpt-6.2-astra - flagship (Nov 17, 2026), $8/$40
263
285
  reason: OPENAI_MODELS.DEFAULT, // Deep reasoning (astra + effort=xhigh)
264
286
  brainstorm: OPENAI_MODELS.DEFAULT, // Creative ideation (astra + effort=medium)
265
- code: OPENAI_MODELS.TERRA, // Code tasks (gpt-5.6-terra - 5.5-level at $2/$12)
266
- explain: OPENAI_MODELS.SOL, // openai_explain pins gpt-6.1-sol at low effort ($2/$10)
267
- search: OPENAI_MODELS.SOL, // Web search: $10/1k call fee is flat across tiers; gpt-6.1-sol
268
- // ($2/$10) beat terra on a fresh-news query (2026-10-14).
269
- // Premium: the 5.5-pro tier ($30/$180) is gone — astra + effort=max replaces it at $10/$50
270
- premium: OPENAI_MODELS.PRO, // Expert mode (gpt-6-astra + reasoning.effort=max)
287
+ code: OPENAI_MODELS.TERRA, // Code tasks (gpt-6.1-terra, $1/$5)
288
+ explain: OPENAI_MODELS.SOL, // openai_explain pins gpt-6.2-sol at low effort ($2/$10)
289
+ search: OPENAI_MODELS.SOL, // Web search: $10/1k call fee is flat across tiers; the sol tier
290
+ // ($2/$10) beat 5.6-terra on a fresh-news query (2026-10-14, on 6.1-sol).
291
+ // Premium: the 5.5-pro tier ($30/$180) is gone — astra + effort=max replaces it at $8/$40
292
+ premium: OPENAI_MODELS.PRO, // Expert mode (gpt-6.2-astra + reasoning.effort=max)
271
293
  },
272
294
  grok: {
273
295
  reason: GROK_MODELS._4_7, // grok-4.7 (Sep 21, 2026 flagship, reasoning effort)
@@ -283,7 +305,7 @@ export const CURRENT_MODELS = {
283
305
  architect: GROK_MODELS._4_7, // grok-4.7 with high reasoning.effort (agentic swarm behaviour)
284
306
  },
285
307
  gemini: {
286
- get default() { return GEMINI_MODELS.GEMINI_3_PRO; }, // gemini-4-argon unless TACHI_GEMINI_PRO_MODEL
308
+ get default() { return GEMINI_MODELS.GEMINI_3_PRO; }, // gemini-4-carbon unless TACHI_GEMINI_PRO_MODEL
287
309
  },
288
310
  perplexity: {
289
311
  search: PERPLEXITY_MODELS.SONAR, // $1/$1 per M (cheapest)
@@ -450,6 +472,9 @@ export const DEFAULT_WORKFLOW_TOOL = "openai_brainstorm";
450
472
  // Used in tool outputs, usage stats, logs - keeps display consistent
451
473
  export const MODEL_DISPLAY_NAMES = {
452
474
  // OpenAI
475
+ "gpt-6.2-astra": "gpt-6.2-astra",
476
+ "gpt-6.2-sol": "gpt-6.2-sol",
477
+ "gpt-6.1-terra": "gpt-6.1-terra",
453
478
  "gpt-6-astra": "gpt-6-astra",
454
479
  "gpt-6.1-sol": "gpt-6.1-sol",
455
480
  "gpt-6-sol": "gpt-6-sol",
@@ -464,8 +489,12 @@ export const MODEL_DISPLAY_NAMES = {
464
489
  "gpt-5.4-mini": "gpt-5.4-mini",
465
490
  "gpt-5.4-pro": "gpt-5.4-pro",
466
491
  // Gemini
492
+ "gemini-4-carbon": "gemini-4-carbon",
493
+ "gemini-4-neon": "gemini-4-neon",
494
+ "gemini-4-hydrogen": "gemini-4-hydrogen",
467
495
  "gemini-4-argon": "gemini-4-argon",
468
496
  "gemini-3.1-pro-preview": "gemini-3.1-pro",
497
+ "gemini-3.8-flash": "gemini-3.8-flash",
469
498
  "gemini-3.7-flash": "gemini-3.7-flash",
470
499
  "gemini-3.6-flash": "gemini-3.6-flash",
471
500
  "gemini-3.5-flash-lite": "gemini-3.5-flash-lite",
@@ -473,6 +502,8 @@ export const MODEL_DISPLAY_NAMES = {
473
502
  "gemini-3-flash-preview": "gemini-3-flash",
474
503
  "gemini-3.1-flash-lite": "gemini-3.1-flash-lite",
475
504
  // Grok (xAI)
505
+ "grok-4.7": "grok-4.7",
506
+ "grok-4.6": "grok-4.6",
476
507
  "grok-4.5": "grok-4.5",
477
508
  "grok-4.3": "grok-4.3",
478
509
  "grok-4.3-latest": "grok-4.3",
@@ -520,8 +551,11 @@ export function getModelDisplayName(modelId) {
520
551
  // Model pricing per 1K tokens (input/output average) for cost tracking
521
552
  export const MODEL_PRICING = {
522
553
  // OpenAI
523
- "gpt-6-astra": 0.030, // ($10 + $50) / 2 / 1000 (Sep 3, 2026 - current default)
524
- "gpt-6.1-sol": 0.006, // ($2 + $10) / 2 / 1000 (Sep 29, 2026 - SOL tier)
554
+ "gpt-6.2-astra": 0.024, // ($8 + $40) / 2 / 1000 (Nov 17, 2026 - current default)
555
+ "gpt-6.2-sol": 0.006, // ($2 + $10) / 2 / 1000 (Nov 17, 2026 - SOL tier)
556
+ "gpt-6.1-terra": 0.003, // ($1 + $5) / 2 / 1000 (Oct 26, 2026 - TERRA tier)
557
+ "gpt-6-astra": 0.030, // ($10 + $50) / 2 / 1000 (Sep 3, 2026 - fallback)
558
+ "gpt-6.1-sol": 0.006, // ($2 + $10) / 2 / 1000 (Sep 29, 2026 - fallback)
525
559
  "gpt-6-sol": 0.006, // ($2 + $10) / 2 / 1000 (Sep 14, 2026 - fallback)
526
560
  "gpt-6-luna": 0.0003, // ($0.10 + $0.50) / 2 / 1000 (Sep 14, 2026 - LUNA/MINI tier)
527
561
  "gpt-5.6-sol": 0.0175, // ($5 + $30) / 2 / 1000 (unchanged in the Jul 30 cut)
@@ -533,7 +567,11 @@ export const MODEL_PRICING = {
533
567
  "gpt-5.4-mini": 0.002625, // ($0.75 + $4.50) / 2 / 1000 (Mar 17, 2026)
534
568
  "gpt-5.4-pro": 0.105, // ($30 + $180) / 2 / 1000 (Mar 2026)
535
569
  // Gemini
536
- "gemini-4-argon": 0.006, // ($2 + $10) / 2 / 1000 intro through Nov 30, 2026 — $4/$20 (0.012) from Dec 1
570
+ "gemini-4-carbon": 0.012, // ($4 + $20) / 2 / 1000 (Nov 10, 2026 - current Pro default)
571
+ "gemini-4-neon": 0.009, // ($3 + $15) / 2 / 1000 (Nov 18, 2026)
572
+ "gemini-4-hydrogen": 0.0045, // ($1.50 + $7.50) / 2 / 1000 (Nov 12, 2026)
573
+ "gemini-4-argon": 0.012, // ($4 + $20) / 2 / 1000 since Dec 1, 2026 (deprecated; Carbon serves it from Dec 15)
574
+ "gemini-3.8-flash": 0.00225, // ($0.75 + $3.75) / 2 / 1000 through Dec 31, 2026 — $1.50/$7.50 (0.0045) from Jan 1, 2027
537
575
  "gemini-3.1-pro-preview": 0.007, // ($2 + $12) / 2 / 1000
538
576
  "gemini-3.7-flash": 0.00225, // ($0.75 + $3.75) / 2 / 1000 intro through Dec 31, 2026 (then $1.50/$7.50)
539
577
  "gemini-3.6-flash": 0.0045, // ($1.50 + $7.50) / 2 / 1000 (GA Jul 21, 2026 - fallback)
@@ -542,10 +580,12 @@ export const MODEL_PRICING = {
542
580
  "gemini-3-flash-preview": 0.00175, // ($0.50 + $3) / 2 / 1000 (legacy)
543
581
  "gemini-3.1-flash-lite": 0.001, // Cheapest/fastest in 3.1 series (Mar 2026)
544
582
  // Grok
545
- "grok-4.5": 0.004, // ($2 + $6) / 2 / 1000 (Jul 8, 2026 flagship)
583
+ "grok-4.7": 0.004, // ($2 + $6) / 2 / 1000 (Sep 21, 2026 flagship)
584
+ "grok-4.6": 0.004, // ($2 + $6) / 2 / 1000 (Aug 2026)
585
+ "grok-4.5": 0.004, // ($2 + $6) / 2 / 1000 (Jul 8, 2026)
546
586
  "grok-4.3": 0.001875, // ($1.25 + $2.50) / 2 / 1000 (Apr 30, 2026 - fallback)
547
587
  "grok-4.3-latest": 0.001875,
548
- "grok-build-0.1": 0.001875, // Coding specialist (estimate, same tier)
588
+ "grok-build-0.1": 0.001875, // Retired Nov 19, 2026 (kept so old usage records still price)
549
589
  "grok-4.20-0309-reasoning": 0.004, // ($2 + $6) / 2 / 1000 (legacy)
550
590
  "grok-4.20-0309-non-reasoning": 0.004, // ($2 + $6) / 2 / 1000 (legacy)
551
591
  "grok-4.20-multi-agent-0309": 0.004, // ($2 + $6) / 2 / 1000 (legacy)
@@ -16,10 +16,10 @@ import { GEMINI_MODELS, OPENAI_MODELS, GROK_MODELS, PERPLEXITY_MODELS, KIMI_MODE
16
16
  */
17
17
  const MODELS = {
18
18
  // Google Gemini
19
- get GEMINI() { return GEMINI_MODELS.GEMINI_3_PRO; }, // gemini-4-argon unless TACHI_GEMINI_PRO_MODEL (read per call)
19
+ get GEMINI() { return GEMINI_MODELS.GEMINI_3_PRO; }, // gemini-4-carbon unless TACHI_GEMINI_PRO_MODEL (read per call)
20
20
  // OpenAI (GPT-6 Astra)
21
- OPENAI: OPENAI_MODELS.THINKING, // gpt-6-astra (default - most capable, agentic)
22
- OPENAI_REASON: OPENAI_MODELS.THINKING, // gpt-6-astra (deep reasoning)
21
+ OPENAI: OPENAI_MODELS.THINKING, // gpt-6.2-astra (default - most capable, agentic)
22
+ OPENAI_REASON: OPENAI_MODELS.THINKING, // gpt-6.2-astra (deep reasoning)
23
23
  // xAI Grok
24
24
  GROK: GROK_MODELS._4_3, // grok-4.3 (Apr 2026 flagship, 1M ctx, $1.25/$2.50)
25
25
  // Perplexity
@@ -2,7 +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
+ import { hasGrokApiKey, hasOpenAIApiKey, hasGeminiApiKey, hasPerplexityApiKey, hasOpenRouterApiKey, hasDeepSeekApiKey } from "../utils/api-keys.js";
6
6
  /**
7
7
  * Default model configurations with user preferences
8
8
  */
@@ -49,7 +49,7 @@ export class ModelPreferencesManager {
49
49
  */
50
50
  loadModelOverrides() {
51
51
  // GPT-5 configuration (assumes OpenAI key)
52
- if (process.env.OPENAI_API_KEY) {
52
+ if (hasOpenAIApiKey()) {
53
53
  this.preferences.modelOverrides["gpt5"] = {
54
54
  enabled: process.env.DISABLE_GPT5 !== "true",
55
55
  priority: parseInt(process.env.GPT5_PRIORITY || "0"),
@@ -79,7 +79,7 @@ export class ModelPreferencesManager {
79
79
  };
80
80
  }
81
81
  // GPT-5 reasoning configuration
82
- if (process.env.OPENAI_API_KEY) {
82
+ if (hasOpenAIApiKey()) {
83
83
  this.preferences.modelOverrides["gpt5_reason"] = {
84
84
  enabled: process.env.ENABLE_GPT5 === "true",
85
85
  priority: parseInt(process.env.GPT5_REASON_PRIORITY || "1"),
@@ -94,7 +94,7 @@ export class ModelPreferencesManager {
94
94
  };
95
95
  }
96
96
  // DeepSeek R1
97
- if (process.env.DEEPSEEK_API_KEY) {
97
+ if (hasDeepSeekApiKey()) {
98
98
  this.preferences.modelOverrides["deepseek_r1"] = {
99
99
  enabled: process.env.ENABLE_DEEPSEEK_R1 === "true",
100
100
  priority: parseInt(process.env.DEEPSEEK_R1_PRIORITY || "3"),
@@ -103,7 +103,7 @@ export class ModelPreferencesManager {
103
103
  };
104
104
  }
105
105
  // Qwen models via OpenRouter
106
- if (process.env.OPENROUTER_API_KEY) {
106
+ if (hasOpenRouterApiKey()) {
107
107
  this.preferences.modelOverrides["qwen_coder"] = {
108
108
  enabled: true,
109
109
  priority: parseInt(process.env.QWEN_CODER_PRIORITY || "4"),
@@ -124,11 +124,12 @@ export class ModelPreferencesManager {
124
124
  initializeModels() {
125
125
  // Check which APIs are available
126
126
  const hasGrok = hasGrokApiKey();
127
- const hasOpenAI = !!process.env.OPENAI_API_KEY;
128
- const hasGemini = !!process.env.GOOGLE_API_KEY;
129
- const hasPerplexity = !!process.env.PERPLEXITY_API_KEY;
130
- const hasOpenRouter = !!process.env.OPENROUTER_API_KEY;
131
- const hasDeepSeek = !!process.env.DEEPSEEK_API_KEY;
127
+ const hasOpenAI = hasOpenAIApiKey();
128
+ // via api-keys.ts so the provider lock is honoured
129
+ const hasGemini = hasGeminiApiKey();
130
+ const hasPerplexity = hasPerplexityApiKey();
131
+ const hasOpenRouter = hasOpenRouterApiKey();
132
+ const hasDeepSeek = hasDeepSeekApiKey();
132
133
  // Set up available models with default configs
133
134
  if (hasGrok) {
134
135
  this.availableModels.set("grok_reason", {
@@ -350,7 +351,7 @@ export class ModelPreferencesManager {
350
351
  getRecommendations() {
351
352
  const recommendations = [];
352
353
  const hasGrok = hasGrokApiKey();
353
- const hasOpenAI = !!process.env.OPENAI_API_KEY;
354
+ const hasOpenAI = hasOpenAIApiKey();
354
355
  if (hasGrok && !this.preferences.enableExpensiveModels) {
355
356
  recommendations.push("You have Grok API access. Enable ENABLE_EXPENSIVE_MODELS=true to use Grok Heavy (256k context).");
356
357
  }