tachibot-mcp 2.28.0 → 2.30.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 (46) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +16 -7
  3. package/dist/src/config/model-constants.js +51 -24
  4. package/dist/src/modes/challenger.js +2 -2
  5. package/dist/src/modes/scout.js +3 -3
  6. package/dist/src/optimization/model-router.js +34 -17
  7. package/dist/src/profiles/balanced.js +2 -1
  8. package/dist/src/profiles/code_focus.js +2 -1
  9. package/dist/src/profiles/full.js +2 -1
  10. package/dist/src/profiles/heavy_coding.js +2 -1
  11. package/dist/src/profiles/minimal.js +2 -1
  12. package/dist/src/profiles/research_power.js +2 -1
  13. package/dist/src/tools/diff-review-tool.js +14 -6
  14. package/dist/src/tools/gemini-tools.js +104 -46
  15. package/dist/src/tools/grok-enhanced.js +5 -3
  16. package/dist/src/tools/grok-search-lite-tool.js +21 -7
  17. package/dist/src/tools/grok-tools.js +9 -4
  18. package/dist/src/tools/jury-tool.js +69 -28
  19. package/dist/src/tools/openai-tools.js +26 -13
  20. package/dist/src/tools/openrouter-tools.js +6 -6
  21. package/dist/src/tools/plan-critique-tool.js +12 -5
  22. package/dist/src/tools/planner-tools.js +5 -2
  23. package/dist/src/tools/workflow-runner.js +1 -1
  24. package/dist/src/utils/judge-constants.js +83 -0
  25. package/dist/src/utils/judge-runner.js +58 -0
  26. package/dist/src/utils/provider-failure.js +18 -0
  27. package/dist/src/utils/provider-router.js +4 -4
  28. package/dist/src/utils/smart-api-client.js +3 -3
  29. package/dist/src/workflows/custom-workflows.js +8 -2
  30. package/dist/src/workflows/tool-mapper.js +34 -12
  31. package/docs/superpowers/plans/2026-08-12-kitchen-architecture.md +1600 -0
  32. package/docs/superpowers/plans/2026-08-12-openrouter-spec-table.md +1201 -0
  33. package/docs/superpowers/plans/2026-08-12-prompt-approach-repair.md +2059 -0
  34. package/docs/superpowers/plans/2026-08-12-provider-catalogs.md +1519 -0
  35. package/docs/superpowers/plans/2026-08-14-mcp-compliance-and-tool-surface.md +3035 -0
  36. package/package.json +1 -1
  37. package/profiles/balanced.json +2 -1
  38. package/profiles/code_focus.json +2 -1
  39. package/profiles/full.json +2 -1
  40. package/profiles/heavy_coding.json +2 -1
  41. package/profiles/minimal.json +2 -1
  42. package/profiles/research_power.json +2 -1
  43. package/skills/landing/SKILL.md +110 -0
  44. package/skills/release/SKILL.md +135 -0
  45. package/smithery.yaml +1 -1
  46. package/tools.config.json +65 -17
package/CHANGELOG.md CHANGED
@@ -5,6 +5,50 @@ 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.30.0] - 2026-08-14
9
+
10
+ Ten defects found by an MCP-compliance audit. Every one was verified against source or the live xAI API before being fixed; each carries a regression test.
11
+
12
+ ### Fixed
13
+ - **`grok_search` was not searching.** It ran on `grok-4.5`, which never invokes the `web_search` tool on xAI's Agent Tools API — so it answered from training data while rendering a source footer and a "Search used up to N sources" line computed locally from `max_search_results`, not from actual usage. Probed 2026-08-14: asked the date, `grok-4.5` returned "October 10, 2025" with zero `web_search_call` entries; `grok-4.6` returned the correct date with two search calls and a citation. Repointed to `grok-4.6` (added to `GROK_MODELS`/`GrokModel`; same $2/$6 and 500K context as 4.5). The new test asserts *grounding* — presence of a `web_search_call` and ≥1 annotation — never the answer text, because a plausible ungrounded answer is exactly what hid this.
14
+ - **13 `console.log` calls corrupted the JSON-RPC stream.** stdout is the protocol channel on a stdio-transport MCP server. Sites in `provider-router.ts` (fired on every routed provider call), `smart-api-client.ts`, `scout.ts`, `challenger.ts`, `custom-workflows.ts` now use `console.error`. Guarded by a test that also rejects `console.info`, `console.debug` and `process.stdout.write`.
15
+ - **`create_workflow` silently destroyed user files.** `saveWorkflow()` checked `existsSync` on the *directory* and then wrote the *file* unguarded, so a name collision overwrote existing YAML with no warning. Now refuses unless `overwrite: true` is passed, and the success message reports the real `.tachibot/workflows/` path instead of `.tachi/workflows/`.
16
+ - **Eight prompt maps injected the literal string "undefined".** The `||` fallback sat *inside* the index (`approachPrompts[args.approach || 'analytical']`), so it only rescued an empty value — any unknown one still resolved to `undefined` and landed in the system prompt. Fixed in `grok_reason`, `grok_code`, `kimi_thinking`, `qwen_reason`, `deepseek_reason`, `glm_reason`, `stepfun_reason`, `ernie_reason`. Same class as 2.28.x's OpenAI fix.
17
+ - **`tool-mapper` ran the wrong model.** Its `qwen_algo` case called `QWQ_32B` with a generic prompt instead of Qwen3.8-Max with the algorithm-engineer protocol, and `qwq_reason` lost its 4-persona deliberation entirely — so a workflow step got a materially different tool than the MCP tool of the same name. Both now delegate to the real tool objects.
18
+ - **`planner_maker` emitted an invalid tool call.** Its `qwen_coder` step sent `{task, code, requirements}`, but that schema has no `requirements`, requires `query`, and `requirements` is not an input alias — so every agent execution of that step failed Zod validation.
19
+
20
+ ### Changed
21
+ - Test suite 130 → 158 (157 passing, 1 opt-in live probe). The live grok grounding probe now requires `RUN_LIVE_TESTS=1` in addition to a key, so an ordinary `npm test` no longer fires a billed API call.
22
+
23
+ ### Notes
24
+ - Golden snapshot unchanged: no tool name, description, or input schema moved. This release is behavior-only.
25
+ - `grok-4.6` is the current latest Grok, verified against `GET /v1/models`. There is no `grok-4.7` or `grok-5`.
26
+
27
+ ## [2.29.0] - 2026-08-12
28
+
29
+ ### Fixed
30
+ - **Failed jurors were synthesized as real opinions.** Every provider helper catches internally and RETURNS a marker string (`[Grok error: ...]`, `[OpenRouter timeout: ...]`) rather than throwing, so `jury`'s drop filter only ever caught typed throws from `callLocal`. A quota-limited juror reached the judge as a considered perspective. New `utils/provider-failure.ts` detects the markers; verified against all nine real provider error strings with no false positives on realistic answers.
31
+ - **The judge was told the wrong juror count.** The prompt interpolated `validJurors.length` while showing `liveJurors`, presenting a short-handed panel as full and miscalibrating every consensus claim. Counts now come from what the judge is actually shown, and dropped jurors are declared to it.
32
+ - **`grok_search_lite` advertised a model it wasn't using.** `grok-4-1-fast-non-reasoning` was retired by xAI, and the retirement is invisible: the API returns HTTP 200 and silently serves `grok-4.3`, disclosing the swap only in `response.model` (which the codebase discards). Nothing threw, so no fallback could fire. The tool billed $1.25/$2.50 while claiming $0.20/$0.50 and "~10x cheaper" in three user-visible places. Now points at `grok-4.3` explicitly with corrected claims — zero behaviour change, since 4.3 was already what ran.
33
+ - **`continue_focus` was unprofileable.** Emitted by the server but absent from `ToolsConfig` and all six profiles, so it could not be disabled by any profile including `minimal`, and was invisible to every count. Registered in all six (behaviour-preserving); `full` now reports 66, matching the emitted contract exactly.
34
+ - **The literal string `"undefined"` could be injected into reasoning prompts.** Five sites indexed a closed prompt map with the fallback inside the brackets (`modePrompts[x || 'default']`), so any value not in the map missed the lookup silently. Only `openai_reason` was reachable — its `mode` is a free string per the tool-param rule, which is precisely what removed the enum guard protecting the others.
35
+ - **`gemini-tools.ts` depended on import order for its API key.** It read `process.env` at module scope under a comment claiming "dotenv is loaded in server.ts before any imports" — false: `server.ts` is a 12-line dispatcher with no dotenv call, and `server-main.ts`'s `override: true` runs in its module body, after the whole static graph. It worked only because `grok-tools.js` calls `config()` eleven lines earlier in `registry.ts`. Now self-sufficient.
36
+
37
+ ### Added
38
+ - **Judge fallback chain (`utils/judge-runner.ts`).** A single Gemini failure used to destroy an entire panel *after* every juror had run and billed. Judges now escalate: retry with backoff (honouring Google's `RetryInfo.retryDelay`) → degrade Pro→Flash → escalate to `gpt-5.6-sol` → return raw unsynthesized perspectives with an explicit warning. Wired into `jury`, `diff_review`, and `plan_critique`. Verified live against a real quota outage: Pro 429 ×3 → Flash 429 → sol answered in 7.5s.
39
+ - **`callGemini` retains the API error body**, which it previously discarded in favour of `statusText`. Google puts the useful part there — which quota was hit, and a `retryDelay` when the limit is transient rather than a plan cap.
40
+ - **`max` reasoning effort** for OpenAI. `gpt-5.6` accepts `none|low|medium|high|xhigh|max`, but `OPENAI_REASONING` stopped at `xhigh` and the zod enum rejected `max`, so nothing could request the top tier. The 180s timeout branch now covers it.
41
+
42
+ ### Changed
43
+ - **Judge prompts rewritten** (`utils/judge-constants.ts`, shared by `jury` and `gemini_judge`, which carried drifting copies). Jurors are anonymized so the judge weighs reasoning rather than brand; the "You are Gemini 3 Pro" persona is gone (stale, and an invitation to self-preference bias); six stacked reasoning frameworks are replaced by decomposition into sub-claims tagged AGREED/CONTESTED/UNVERIFIED plus one adversarial pass; the impossible self-consistency instruction is removed (it requires sampling repeatedly, which one call cannot do); and the judge is told it cannot verify factual claims rather than being graded on "accuracy" it has no means to assess.
44
+ - **OpenAI pricing corrected** for the Jul 30 2026 cut: terra $2.50/$15 → $2/$12, luna $1/$6 → $0.20/$1.20. `MODEL_COSTS` had luna 5x over reality, skewing cost-aware routing.
45
+ - **`optimization/model-router.ts` refreshed.** Its `ModelTier` enum was routing live workflow traffic to Mar-2026 models (`gpt-5.4`, `gpt-5.4-pro`, `gemini-3-flash-preview`), and no current model appeared in its cost table, so every one fell through to a flat $0.001 estimate.
46
+ - **`openai_reason` runs `xhigh`** (was `high`). `max` is deliberately not the default — OpenAI recommends reserving it for hardest-case work.
47
+ - **`openai_search` moves to `gpt-5.6-terra`** (was `sol`). Web search bills a flat $10/1k calls regardless of model, so the model is the only cost lever, and it was set to the most expensive option. All 5.6 tiers support `web_search` identically.
48
+
49
+ ### Verified, not changed
50
+ - **Gemini 3.1 Pro is still the newest Pro model** — no 3.5 Pro or 4 has shipped. Confirmed against Google's live docs by two independent sources plus a direct `models.list` probe (HTTP 200, exact id match). Grok 4.5 likewise remains flagship. No Codex-specific OpenAI model exists; the `CODEX*` constants are legacy aliases.
51
+
8
52
  ## [2.28.0] - 2026-08-03
9
53
 
10
54
  ### Added
package/README.md CHANGED
@@ -4,18 +4,18 @@
4
4
 
5
5
  ### Multi-Model AI Orchestration Platform
6
6
 
7
- [![Version](https://img.shields.io/badge/version-2.28.0-blue.svg)](https://www.npmjs.com/package/tachibot-mcp)
8
- [![Tools](https://img.shields.io/badge/tools-65_active-brightgreen.svg)](#-tool-ecosystem-65-tools)
7
+ [![Version](https://img.shields.io/badge/version-2.30.0-blue.svg)](https://www.npmjs.com/package/tachibot-mcp)
8
+ [![Tools](https://img.shields.io/badge/tools-66_active-brightgreen.svg)](#-tool-ecosystem-66-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)
11
11
  [![MCP](https://img.shields.io/badge/MCP-Compatible-purple.svg)](https://modelcontextprotocol.io)
12
12
 
13
- **65 AI tools. 12 providers. One protocol.**
13
+ **66 AI tools. 12 providers. One protocol.**
14
14
 
15
- Orchestrate Perplexity, Grok 4.5, GPT-5.6, Gemini, Qwen, Kimi K3, and MiniMax M3
15
+ Orchestrate Perplexity, Grok 4.6, GPT-5.6, Gemini, Qwen, Kimi K3, and MiniMax M3
16
16
  from Claude Code, Claude Desktop, Cursor, or any MCP client.
17
17
 
18
- [Get Started](#-quick-start) · [View Tools](#-tool-ecosystem-65-tools) · [Documentation](https://tachibot.com/docs)
18
+ [Get Started](#-quick-start) · [View Tools](#-tool-ecosystem-66-tools) · [Documentation](https://tachibot.com/docs)
19
19
 
20
20
  <br>
21
21
 
@@ -30,6 +30,15 @@ from Claude Code, Claude Desktop, Cursor, or any MCP client.
30
30
 
31
31
  ## What's New
32
32
 
33
+ ### v2.30.0
34
+ - **`grok_search` was not searching.** It ran on `grok-4.5`, which never invokes the `web_search` tool on xAI's Agent Tools API — so it answered from training data while still rendering a source footer and a "Search used up to N sources" cost line computed locally from `max_search_results`, not from real usage. Probed Aug 14: asked today's date, `grok-4.5` replied *"October 10, 2025"* with zero `web_search_call` entries; **`grok-4.6` replied correctly with two search calls and a citation.** `grok_search` now runs `grok-4.6` (same $2/$6 and 500K context as 4.5). The regression test asserts *grounding* — a `web_search_call` and ≥1 annotation — never the answer text, because a plausible ungrounded answer is precisely what hid this.
35
+ - **Correction to the v2.27.0 note below:** `grok_search_lite` never ran on `grok-4-1-fast` at $0.20/$0.50. xAI retired that id and silently served `grok-4.3` — HTTP 200, the swap disclosed only in the response body's `model` field, so nothing threw and no fallback fired. The advertised "~10x cheaper" was really ~1.6x, and `grok-4.3` does not invoke web search either.
36
+ - **13 `console.log` calls were corrupting the MCP protocol stream.** stdout is the JSON-RPC channel on a stdio server; diagnostics now go to stderr, guarded by a test that also rejects `console.info`, `console.debug` and `process.stdout.write`.
37
+ - **`create_workflow` silently destroyed existing workflow files** — the existence check guarded the *directory*, not the *file*. It now refuses to clobber unless `overwrite: true`, and reports the real `.tachibot/workflows/` path instead of `.tachi/workflows/`.
38
+ - **Eight prompt maps injected the literal string `"undefined"`** into system prompts for any unrecognised `approach`/`task`, because the `||` fallback sat *inside* the index. Fixed across `grok_reason`, `grok_code`, `kimi_thinking`, `qwen_reason`, `deepseek_reason`, `glm_reason`, `stepfun_reason`, `ernie_reason`.
39
+ - **Workflow steps ran the wrong model** — the `qwen_algo` step called QwQ-32B with a generic prompt instead of Qwen3.8-Max, and `qwq_reason` lost its 4-persona deliberation entirely. Both now delegate to the real tools. Separately, `planner_maker`'s `qwen_coder` step sent a parameter the schema rejects, so every execution of it failed validation.
40
+ - Test suite **130 → 158**. The live search probe is now opt-in behind `RUN_LIVE_TESTS=1`, so an ordinary `npm test` no longer makes a billed API call.
41
+
33
42
  ### v2.28.0
34
43
  - **Qwen3.8 Max** (Aug 3, `qwen/qwen3.8-max`) — Alibaba's new flagship, GA the same day, now powers `qwen_algo`, `qwen_reason`, and the `qwen_reason` juror. **1M context (up from 262K)**, multimodal (text+image+video in), and the first Qwen exposing **configurable reasoning effort**. $2/$6 per M.
35
44
  - **Measured on a range-query algorithm problem**, 3.8 Max was the only one of five Qwen candidates to surface both the offline-vs-online tradeoff and the strict-inequality-with-duplicates edge case. The outgoing `qwen3-235b-a22b-thinking-2507` was correct but shallow; `qwen3.7-max` cost 1.6x for twice the wall time; `qwen3-max-thinking` was rejected outright — it returns zero reasoning tokens.
@@ -64,7 +73,7 @@ from Claude Code, Claude Desktop, Cursor, or any MCP client.
64
73
  - **One-click Claude Desktop install** &mdash; download the `.mcpb` from the latest release and double-click. No JSON editing.
65
74
  - **`doctor`** &mdash; shows which keys are set, which tools are visible vs hidden and why, and what to try first.
66
75
 
67
- #### New tools & skills (65 tools · 19 skills)
76
+ #### New tools & skills (66 tools · 19 skills)
68
77
  - `debug_triage` &mdash; ranked root-cause hypotheses with the cheapest discriminating check for each (Grok 4.3)
69
78
  - `spec_writer` &mdash; loose request → reviewable spec: user stories, Given/When/Then, out-of-scope, open questions (GPT-5.5)
70
79
  - `diff_review` / `plan_critique` / `testgen` / `security_review` &mdash; multi-model diff review, adversarial plan red-team, test generation, OWASP/CWE audit
@@ -212,7 +221,7 @@ See [Installation Guide](docs/INSTALLATION_BOTH.md) for detailed instructions.
212
221
 
213
222
  ---
214
223
 
215
- ## Tool Ecosystem (65 Tools)
224
+ ## Tool Ecosystem (66 Tools)
216
225
 
217
226
  ### Research & Search (6)
218
227
  `perplexity_ask` &#183; `perplexity_reason` &#183; `grok_search` &#183; `grok_search_lite` &#183; `openai_search` &#183; `gemini_search`
@@ -7,15 +7,20 @@
7
7
  // OPENAI MODELS (provider-based naming)
8
8
  // =============================================================================
9
9
  // GPT-5.6 released Jul 9, 2026 - CURRENT. Three durable tiers replace the pro/mini split:
10
- // sol (flagship $5/$30) / terra (balanced $2.50/$15) / luna (fast $1/$6). All 1.05M ctx, 128K out.
10
+ // sol (flagship $5/$30) / terra (balanced $2/$12) / luna (fast $0.20/$1.20). 1.05M ctx, 128K out.
11
+ // Jul 30, 2026 price cut: luna -80%, terra -20%, sol unchanged. Verified Aug 12, 2026.
12
+ // No Codex-specific API model exists (no gpt-5.6-codex / codex-max) — the CODEX* aliases
13
+ // below are legacy names repointed onto the sol/terra/luna tiers.
11
14
  // "Pro" is no longer a model: sol + reasoning.effort (the $30/$180 gpt-5.5-pro tier is gone).
12
15
  // GPT-5.5 (Apr 23, 2026) kept as fallback. OpenRouter uses prefix: openai/gpt-5.6-sol etc.
13
16
  export const OPENAI_MODELS = {
14
17
  // GPT-5.6 tiers (Jul 9, 2026 - CURRENT)
15
18
  DEFAULT: "gpt-5.6-sol", // Flagship: coding/agentic SOTA, 54% more token-efficient than 5.5
16
19
  SOL: "gpt-5.6-sol", // Explicit tier alias (also aliased "gpt-5.6" server-side)
17
- TERRA: "gpt-5.6-terra", // Balanced: matches gpt-5.5 at half price ($2.50/$15)
18
- LUNA: "gpt-5.6-luna", // Fast/cheap: $1/$6 (weaker long-context recall — avoid huge inputs)
20
+ TERRA: "gpt-5.6-terra", // Balanced: gpt-5.5-level at $2/$12 (Jul 30, 2026 cut: -20%)
21
+ LUNA: "gpt-5.6-luna", // Fast/cheap: $0.20/$1.20 after the Jul 30, 2026 -80% cut.
22
+ // Now ~9x cheaper than terra, not 2.5x — worth routing to it
23
+ // far more aggressively. (Weak long-context recall: avoid huge inputs.)
19
24
  MINI: "gpt-5.6-luna", // "mini" tier successor (was gpt-5.4-mini)
20
25
  PRO: "gpt-5.6-sol", // Pro tier eliminated in 5.6 — sol + reasoning.effort xhigh (was gpt-5.5-pro $30/$180)
21
26
  // GPT-5.5 (Apr 2026) - fallback
@@ -38,13 +43,17 @@ export const OPENROUTER_PREFIX_MAP = {
38
43
  "gpt-5.4-mini": "openai/",
39
44
  };
40
45
  // OpenAI Reasoning Effort Levels (for models that support it)
41
- // Use with gpt-5.5: none=fast, low/medium=balanced, high/xhigh="thinking" mode
46
+ // All three GPT-5.6 tiers (sol/terra/luna) accept the full range; medium is the API default.
42
47
  export const OPENAI_REASONING = {
43
48
  NONE: "none", // No extra reasoning (fastest, allows temperature)
44
- LOW: "low", // Light reasoning
45
- MEDIUM: "medium", // Balanced reasoning (default)
49
+ LOW: "low", // Light reasoning — right for grounded web-search lookups
50
+ MEDIUM: "medium", // Balanced reasoning (API default)
46
51
  HIGH: "high", // Strong reasoning ("thinking" mode)
47
- XHIGH: "xhigh", // Maximum reasoning (most thorough, slowest)
52
+ XHIGH: "xhigh", // Very thorough
53
+ MAX: "max", // Ceiling (verified Aug 12, 2026 against OpenAI model docs — this tier
54
+ // was missing here, so nothing in the codebase could request it and the
55
+ // "premium" path topped out one level below what sol actually offers).
56
+ // Reserve for hardest quality-first tasks; compare against xhigh first.
48
57
  };
49
58
  // =============================================================================
50
59
  // GEMINI MODELS (Google)
@@ -75,15 +84,20 @@ export const PERPLEXITY_MODELS = {
75
84
  SONAR_PRO: "sonar-pro", // Advanced search
76
85
  SONAR_REASONING: "sonar-reasoning-pro", // Reasoning model (expensive - avoid)
77
86
  };
78
- // Grok Models (xAI) - Re-verified 2026-07-27 against docs.x.ai: Grok 4.5 is still the flagship.
79
- // NEXT BUMP CANDIDATE: Grok 4.6 (2T params) was confirmed by Musk on Jul 18, finished pre-training
80
- // the week of Jul 20, and was given a "~2 weeks" ETA — so expect it early Aug 2026, with 4.7 ~2 weeks
81
- // behind it. Nothing is official yet (no ID, pricing, or context window). Check before bumping.
87
+ // Grok Models (xAI) - Re-verified 2026-08-14 against GET /v1/models: Grok 4.6 has shipped and is
88
+ // the current latest. Catalog: grok-4.20-0309-* (x3), grok-4.3, grok-4.5, grok-4.6, grok-build-0.1,
89
+ // plus grok-imagine image/video. grok-4.7 and grok-5 do NOT exist yet.
82
90
  // Also verified absent: grok-code-fast-2 (unannounced) and grok-build-0.2 (docs still list 0.1 only).
83
91
  export const GROK_MODELS = {
84
- // Grok 4.5 (Jul 8, 2026) - CURRENT FLAGSHIP ("Opus-class")
92
+ // Grok 4.6 (Aug 2026) - CURRENT LATEST — verified against /v1/models on 2026-08-14.
93
+ // 500K ctx, $2/$6 (same as 4.5), cached input $0.50/M (vs 4.5's $0.30/M). No `-latest` alias yet.
94
+ // CRITICAL for search: 4.6 actually invokes web_search on the Agent Tools API; 4.5 does NOT
95
+ // (returns ungrounded training-data answers with zero web_search_call entries).
96
+ _4_6: "grok-4.6", // Latest: 500K ctx, $2/$6, cached $0.50/M
97
+ // Grok 4.5 (Jul 8, 2026) - previous flagship ("Opus-class")
85
98
  // 500K context (SMALLER than 4.3's 1M — fine for tools, mind huge inputs), $2/$6,
86
99
  // configurable reasoning effort. EU API access landed Jul 17, 2026 — 4.3 kept as quota/region fallback.
100
+ // WARNING: does not invoke web_search on /v1/responses — do not pin search paths to it.
87
101
  _4_5: "grok-4.5", // Flagship: 500K ctx, $2/$6, reasoning.effort low|high
88
102
  // Grok 4.3 (Apr 30, 2026) - previous flagship, kept as FALLBACK
89
103
  // 1M context, $1.25/$2.50, lowest verified hallucination rate.
@@ -95,8 +109,15 @@ export const GROK_MODELS = {
95
109
  _4_20_NON_REASONING: "grok-4.5", // [deprecated key] → grok-4.5 (was grok-4.20-0309-non-reasoning)
96
110
  _4_20_MULTI_AGENT: "grok-4.5", // [deprecated key] → grok-4.5 (architect uses high reasoning.effort)
97
111
  // Grok 4.1 fast models (Nov 2025) - BEST VALUE (10x cheaper)
98
- _4_1_FAST_REASONING: "grok-4-1-fast-reasoning", // Fast reasoning: 2M context, $0.20/$0.50
99
- _4_1_FAST_NON_REASONING: "grok-4-1-fast-non-reasoning", // Tool-calling optimized: 2M context, $0.20/$0.50
112
+ // RETIRED by xAI — verified Aug 12, 2026. DO NOT WIRE THESE TO ANYTHING.
113
+ // The retirement is invisible at runtime: xAI answers a request for these ids with
114
+ // HTTP 200 and silently serves grok-4.3, disclosing the swap only in the response
115
+ // body's `model` field. Nothing throws, so no fallback or try/catch can detect it —
116
+ // you just quietly pay grok-4.3 rates ($1.25/$2.50) while believing you pay $0.20/$0.50.
117
+ // Kept only so existing references resolve to a real (substituted) model rather than
118
+ // breaking; grok_search_lite was moved off them and onto _4_3 explicitly.
119
+ _4_1_FAST_REASONING: "grok-4-1-fast-reasoning", // [RETIRED → serves grok-4.3]
120
+ _4_1_FAST_NON_REASONING: "grok-4-1-fast-non-reasoning", // [RETIRED → serves grok-4.3]
100
121
  // Grok 4 fast models (2025) - Still good
101
122
  CODE_FAST: "grok-code-fast-1", // Coding specialist: 256K→2M, $0.20/$1.50, 92 tok/sec
102
123
  _4_FAST_REASONING: "grok-4-fast-reasoning", // Cheap reasoning: 2M→4M, $0.20/$0.50
@@ -195,19 +216,25 @@ export const CURRENT_MODELS = {
195
216
  default: OPENAI_MODELS.DEFAULT, // gpt-5.6-sol - flagship, agentic/coding SOTA (Jul 2026)
196
217
  reason: OPENAI_MODELS.DEFAULT, // Deep reasoning (sol + effort=high)
197
218
  brainstorm: OPENAI_MODELS.DEFAULT, // Creative ideation (sol + effort=medium)
198
- code: OPENAI_MODELS.TERRA, // Code tasks (gpt-5.6-terra - 5.5-level at half price)
199
- explain: OPENAI_MODELS.LUNA, // Explanations (gpt-5.6-luna - $1/$6, fast)
200
- search: OPENAI_MODELS.DEFAULT, // Web search (sol + web_search tool)
201
- // Premium: the 5.5-pro tier ($30/$180) is gone — sol + effort=xhigh replaces it at $5/$30
202
- premium: OPENAI_MODELS.PRO, // Expert mode (gpt-5.6-sol - crank reasoning effort)
219
+ code: OPENAI_MODELS.TERRA, // Code tasks (gpt-5.6-terra - 5.5-level at $2/$12)
220
+ explain: OPENAI_MODELS.LUNA, // Explanations (gpt-5.6-luna - $0.20/$1.20, fast)
221
+ search: OPENAI_MODELS.TERRA, // Web search: $10/1k call fee is flat across tiers,
222
+ // so terra ($2/$12) does grounded lookup at 2.5x less
223
+ // token cost than sol. All 5.6 tiers support web_search.
224
+ // Premium: the 5.5-pro tier ($30/$180) is gone — sol + effort=max replaces it at $5/$30
225
+ premium: OPENAI_MODELS.PRO, // Expert mode (gpt-5.6-sol + reasoning.effort=max)
203
226
  },
204
227
  grok: {
205
228
  reason: GROK_MODELS._4_5, // grok-4.5 (Jul 2026 flagship, high reasoning effort)
206
229
  code: GROK_MODELS._4_5, // grok-4.5 (flagship quality, tool-calling)
207
230
  debug: GROK_MODELS._4_5, // grok-4.5 (flagship debugging)
208
231
  brainstorm: GROK_MODELS._4_5, // grok-4.5 (500K context)
209
- search: GROK_MODELS._4_5, // grok-4.5 flagship synthesis over live search
210
- search_lite: GROK_MODELS._4_1_FAST_NON_REASONING, // grok-4-1-fast: $0.20/$0.50, 2M ctx, tool-calling optimized — 10x cheaper search
232
+ search: GROK_MODELS._4_6, // grok-4.6: the ONLY current model verified (2026-08-14) to
233
+ // actually invoke web_search on /v1/responses — grok-4.5
234
+ // silently answers from training data with zero searches
235
+ search_lite: GROK_MODELS._4_3, // grok-4.3: $1.25/$2.50, 1M ctx — ~1.6x/2.4x cheaper than
236
+ // grok-4.5 search. Was _4_1_FAST_NON_REASONING until that id
237
+ // was retired (xAI silently served 4.3 for it anyway).
211
238
  architect: GROK_MODELS._4_5, // grok-4.5 with high reasoning.effort (agentic swarm behaviour)
212
239
  },
213
240
  gemini: {
@@ -441,9 +468,9 @@ export function getModelDisplayName(modelId) {
441
468
  // Model pricing per 1K tokens (input/output average) for cost tracking
442
469
  export const MODEL_PRICING = {
443
470
  // OpenAI
444
- "gpt-5.6-sol": 0.0175, // ($5 + $30) / 2 / 1000 (Jul 9, 2026)
445
- "gpt-5.6-terra": 0.00875, // ($2.50 + $15) / 2 / 1000 (Jul 9, 2026)
446
- "gpt-5.6-luna": 0.0035, // ($1 + $6) / 2 / 1000 (Jul 9, 2026)
471
+ "gpt-5.6-sol": 0.0175, // ($5 + $30) / 2 / 1000 (unchanged in the Jul 30 cut)
472
+ "gpt-5.6-terra": 0.007, // ($2 + $12) / 2 / 1000 (Jul 30, 2026 cut: -20%)
473
+ "gpt-5.6-luna": 0.0007, // ($0.20 + $1.20) / 2 / 1000 (Jul 30, 2026 cut: -80%)
447
474
  "gpt-5.5": 0.0175, // ($5 + $30) / 2 / 1000 (Apr 23, 2026 - fallback)
448
475
  "gpt-5.5-pro": 0.105, // ($30 + $180) / 2 / 1000 (Apr 23, 2026 - tier removed in 5.6)
449
476
  "gpt-5.4": 0.00875, // ($2.50 + $15) / 2 / 1000 (Mar 2026 - legacy)
@@ -443,7 +443,7 @@ Write concrete, specific analysis. Do NOT include brackets or placeholders.`;
443
443
  try {
444
444
  // Add date context to query
445
445
  const dateAwareQuery = `[Current date: ${currentDate}] Verify this claim: "${claim.text}". Is it factually accurate? Provide evidence.`;
446
- console.log(`[Challenger] Fact-checking with date context: ${currentDate}`);
446
+ console.error(`[Challenger] Fact-checking with date context: ${currentDate}`);
447
447
  // Use SmartAPIClient with retry logic
448
448
  const timeoutConfig = getSmartTimeout(PROVIDER_PERPLEXITY, 'batch');
449
449
  const response = await smartAPIClient.callWithRetries(() => this.queryModel('sonar-pro', dateAwareQuery, 1000, 0.3), {
@@ -485,7 +485,7 @@ Write concrete, specific analysis. Do NOT include brackets or placeholders.`;
485
485
  // Skip if no programming-specific domains were found
486
486
  // This prevents false positives where generic words triggered technical detection
487
487
  if (domains.length === 0) {
488
- console.log(`Skipping doc verification for claim (no programming domains found): ${claim.text.substring(0, 50)}...`);
488
+ console.error(`Skipping doc verification for claim (no programming domains found): ${claim.text.substring(0, 50)}...`);
489
489
  continue;
490
490
  }
491
491
  // Use Grok search with domain restrictions
@@ -106,7 +106,7 @@ export class Scout {
106
106
  // Get current date and prepend to query for temporal context
107
107
  const currentDate = getCurrentDate();
108
108
  const dateAwareQuery = `[Current date: ${currentDate}] ${query}`;
109
- console.log(`[Scout] Date-aware query: ${dateAwareQuery}`);
109
+ console.error(`[Scout] Date-aware query: ${dateAwareQuery}`);
110
110
  // Create progress stream
111
111
  const progressStream = createProgressStream(4);
112
112
  progressStream.start(`Scout (${options.variant || 'research_scout'})`);
@@ -350,7 +350,7 @@ export class Scout {
350
350
  const startTime = Date.now();
351
351
  try {
352
352
  const enhancedQuery = `Provide comprehensive, current information about: ${query}. Include latest updates, key facts, and reliable sources.`;
353
- console.log(`[Scout] Starting deep search for query: ${query}`);
353
+ console.error(`[Scout] Starting deep search for query: ${query}`);
354
354
  // Build provider list for failover
355
355
  const providers = [];
356
356
  if (this.perplexityApiKey) {
@@ -398,7 +398,7 @@ export class Scout {
398
398
  return null;
399
399
  }
400
400
  const searchDuration = Date.now() - startTime;
401
- console.log(`[Scout] Deep search completed in ${searchDuration}ms using ${result.provider}`);
401
+ console.error(`[Scout] Deep search completed in ${searchDuration}ms using ${result.provider}`);
402
402
  return {
403
403
  facts,
404
404
  sources: this.extractSources(result.result) || [],
@@ -2,32 +2,49 @@
2
2
  * Smart Model Router - Optimized model selection based on query complexity
3
3
  * Part of Phase 1A implementation for cost optimization
4
4
  */
5
+ // Tiers refreshed Aug 12, 2026. These were stuck on Mar-2026 models (gpt-5.4,
6
+ // gpt-5.4-pro, gemini-3-flash-preview) — the workflow engine was routing live traffic to
7
+ // a legacy lineup, and estimateCost() fell through to its flat $0.001 default for every
8
+ // current model because none of them were in MODEL_COSTS below.
5
9
  export var ModelTier;
6
10
  (function (ModelTier) {
7
- // Tier 0: Cheapest - Gemini 3 Flash Preview (Dec 2025)
8
- ModelTier["ULTRA_CHEAP"] = "gemini-3-flash-preview";
11
+ // Tier 0: Cheapest — Gemini 3.5 Flash-Lite ($0.30/$2.50, Jul 21 2026)
12
+ ModelTier["ULTRA_CHEAP"] = "gemini-3.5-flash-lite";
9
13
  // Tier 1: Fast & Efficient
10
- ModelTier["ULTRA_EFFICIENT"] = "gemini-3-flash-preview";
11
- ModelTier["EFFICIENT"] = "gpt-5.4";
12
- // Tier 2: Balanced - GPT-5.4 (best value)
13
- ModelTier["STANDARD"] = "gpt-5.4";
14
- ModelTier["GPT5_MINI"] = "gpt-5.4";
15
- // Tier 3: Advanced ($0.01-$0.05 per request)
14
+ ModelTier["ULTRA_EFFICIENT"] = "gemini-3.6-flash";
15
+ ModelTier["EFFICIENT"] = "gpt-5.6-luna";
16
+ // Tier 2: Balanced — gpt-5.6-terra is gpt-5.5-level at $2/$12
17
+ ModelTier["STANDARD"] = "gpt-5.6-terra";
18
+ ModelTier["GPT5_MINI"] = "gpt-5.6-luna";
19
+ // Tier 3: Advanced
16
20
  ModelTier["WEB_SEARCH"] = "perplexity-sonar-pro";
17
- // Tier 4: Premium (Use with caution - much more expensive)
18
- ModelTier["GPT5_FULL"] = "gpt-5.4-pro";
21
+ // Tier 4: Premium (opt-in only)
22
+ ModelTier["GPT5_FULL"] = "gpt-5.6-sol";
19
23
  })(ModelTier || (ModelTier = {}));
24
+ // Prices are per 1K tokens (0.005 = $5.00 per 1M). Any model missing here silently
25
+ // falls through to estimateCost()'s flat $0.001 default, so every routable tier above
26
+ // MUST have an entry.
20
27
  const MODEL_COSTS = {
21
- // GPT-5.x Models (Mar 2026 pricing) - ACTUAL API MODEL NAMES
22
- "gpt-5.4": { input: 0.0025, output: 0.015, latency: 1500 }, // Most capable (Mar 2026)
23
- "gpt-5.4-mini": { input: 0.00075, output: 0.0045, latency: 800 }, // Fast coding (Mar 17, 2026)
24
- "gpt-5.4-pro": { input: 0.030, output: 0.180, latency: 2500 }, // Premium expert (Mar 2026)
25
- // Gemini 3 models - Dec 2025
26
- "gemini-3-flash-preview": { input: 0.0005, output: 0.003, latency: 500 }, // Fast frontier
27
- "gemini-3.1-pro-preview": { input: 0.002, output: 0.012, latency: 1200 }, // Quality
28
+ // GPT-5.6 family (Jul 9, 2026; terra/luna repriced Jul 30, 2026)
29
+ "gpt-5.6-sol": { input: 0.005, output: 0.030, latency: 2200 }, // Flagship
30
+ "gpt-5.6-terra": { input: 0.002, output: 0.012, latency: 1300 }, // Balanced (-20%)
31
+ "gpt-5.6-luna": { input: 0.0002, output: 0.0012, latency: 700 }, // Cheap (-80%)
32
+ // GPT-5.5 fallback
33
+ "gpt-5.5": { input: 0.005, output: 0.030, latency: 2000 },
34
+ // Legacy GPT-5.4 (kept so historical workflow runs still cost out)
35
+ "gpt-5.4": { input: 0.0025, output: 0.015, latency: 1500 },
36
+ "gpt-5.4-mini": { input: 0.00075, output: 0.0045, latency: 800 },
37
+ "gpt-5.4-pro": { input: 0.030, output: 0.180, latency: 2500 },
38
+ // Gemini
39
+ "gemini-3.6-flash": { input: 0.0015, output: 0.0075, latency: 600 }, // Jul 21, 2026
40
+ "gemini-3.5-flash-lite": { input: 0.0003, output: 0.0025, latency: 400 }, // Jul 21, 2026
41
+ "gemini-3.5-flash": { input: 0.0015, output: 0.009, latency: 600 }, // May 19, 2026
42
+ "gemini-3.1-pro-preview": { input: 0.002, output: 0.012, latency: 1200 }, // Judge/reasoning default
43
+ "gemini-3-flash-preview": { input: 0.0005, output: 0.003, latency: 500 }, // Legacy
28
44
  // Other models
29
45
  qwencoder: { input: 0.00015, output: 0.0006, latency: 1000 },
30
46
  "perplexity-sonar-pro": { input: 0.006, output: 0.006, latency: 2000 },
47
+ sonar: { input: 0.001, output: 0.001, latency: 1500 },
31
48
  };
32
49
  export class SmartModelRouter {
33
50
  constructor() {
@@ -1,8 +1,9 @@
1
1
  export const balancedProfile = {
2
- description: "Balanced set for general use (54 tools)",
2
+ description: "Balanced set for general use (55 tools)",
3
3
  tools: {
4
4
  think: true,
5
5
  focus: true,
6
+ continue_focus: true,
6
7
  tachi: true,
7
8
  doctor: true,
8
9
  nextThought: true,
@@ -1,8 +1,9 @@
1
1
  export const codeFocusProfile = {
2
- description: "Code-heavy work with debugging and analysis (42 tools)",
2
+ description: "Code-heavy work with debugging and analysis (43 tools)",
3
3
  tools: {
4
4
  think: true,
5
5
  focus: true,
6
+ continue_focus: true,
6
7
  tachi: true,
7
8
  doctor: true,
8
9
  nextThought: true,
@@ -1,8 +1,9 @@
1
1
  export const fullProfile = {
2
- description: "Default profile — all tools enabled for maximum capability (65 tools)",
2
+ description: "Default profile — all tools enabled for maximum capability (66 tools)",
3
3
  tools: {
4
4
  think: true,
5
5
  focus: true,
6
+ continue_focus: true,
6
7
  tachi: true,
7
8
  doctor: true,
8
9
  nextThought: true,
@@ -1,9 +1,10 @@
1
1
  export const heavyCodingProfile = {
2
- description: "Heavy coding with all reasoning & code tools (58 tools)",
2
+ description: "Heavy coding with all reasoning & code tools (59 tools)",
3
3
  tools: {
4
4
  // Core reasoning - all enabled
5
5
  think: true,
6
6
  focus: true,
7
+ continue_focus: true,
7
8
  tachi: true,
8
9
  doctor: true,
9
10
  nextThought: true,
@@ -1,8 +1,9 @@
1
1
  export const minimalProfile = {
2
- description: "Minimal essential tools for basic tasks (13 tools)",
2
+ description: "Minimal essential tools for basic tasks (14 tools)",
3
3
  tools: {
4
4
  think: true,
5
5
  focus: true,
6
+ continue_focus: true,
6
7
  tachi: true,
7
8
  doctor: true,
8
9
  nextThought: true,
@@ -1,8 +1,9 @@
1
1
  export const researchPowerProfile = {
2
- description: "Research-focused with Grok search + all Perplexity + brainstorming (36 tools)",
2
+ description: "Research-focused with Grok search + all Perplexity + brainstorming (37 tools)",
3
3
  tools: {
4
4
  think: true,
5
5
  focus: true,
6
+ continue_focus: true,
6
7
  tachi: true,
7
8
  doctor: true,
8
9
  nextThought: true,
@@ -2,14 +2,16 @@
2
2
  * diff_review — multi-model, diff-AWARE code review.
3
3
  * Differs from openai_code_review (whole-file, single model) and jury (free-
4
4
  * text, no code structure): reviewers are scoped to the changed lines, then a
5
- * Gemini judge dedupes and severity-ranks into ONE actionable list.
6
- * Gated on Gemini (judge); panelists self-drop when their key is missing.
5
+ * judge dedupes and severity-ranks into ONE actionable list (Gemini, falling back
6
+ * to gpt-5.6-sol, then to raw unmerged findings — see utils/judge-runner.ts).
7
+ * NOTE: still REGISTERED behind a Gemini key (registry.ts:143) even though the judge
8
+ * can now run on OpenAI — relaxing that gate to (Gemini OR OpenAI) is a follow-up.
7
9
  */
8
10
  import { z } from "zod";
9
11
  import { defineModelTool } from "./factory/define-model-tool.js";
10
12
  import { callOpenRouter, OpenRouterModel } from "./openrouter-tools.js";
11
13
  import { callOpenAI } from "./openai-tools.js";
12
- import { callGemini } from "./gemini-tools.js";
14
+ import { runJudge, judgeAttribution } from "../utils/judge-runner.js";
13
15
  import { hasOpenAIApiKey, hasOpenRouterApiKey } from "../utils/api-keys.js";
14
16
  import { OPENAI_MODELS } from "../config/model-constants.js";
15
17
  import { readFilesIntoContext } from "../utils/file-reader.js";
@@ -88,7 +90,7 @@ function buildPanel() {
88
90
  }
89
91
  export const diffReviewTool = defineModelTool({
90
92
  name: "diff_review",
91
- description: "Multi-model diff-aware code review: 2-3 lab-diverse reviewers (Kimi K3, DeepSeek V4 Pro, GPT-5.6 Sol) scoped to the changed lines, deduplicated and severity-ranked by a Gemini judge. Provide the unified diff in 'diff'.",
93
+ description: "Multi-model diff-aware code review: 2-3 lab-diverse reviewers (Kimi K3, DeepSeek V4 Pro, GPT-5.6 Sol) scoped to the changed lines, deduplicated and severity-ranked by a judge. Provide the unified diff in 'diff'.",
92
94
  parameters: z.object({
93
95
  diff: z.string().describe("Unified diff to review (git diff output) — REQUIRED"),
94
96
  intent: z.string().optional().describe("What the change is SUPPOSED to do (enables intent-mismatch detection)"),
@@ -110,9 +112,15 @@ export const diffReviewTool = defineModelTool({
110
112
  return "Error: all reviewers failed (provider outage or quota). Try again or run `doctor`.";
111
113
  }
112
114
  const judgePrompt = buildDiffJudgePrompt(perspectives, args);
113
- const verdict = await withHeartbeat(() => callGemini(judgePrompt, undefined, `You are Gemini 3 Pro, the presiding code reviewer synthesizing a panel review of one diff. Be decisive; keep only verified findings. ${FORMAT_INSTRUCTION}`, 0.3), reportProgress, 10000);
115
+ const judged = (await withHeartbeat(() => runJudge(judgePrompt, `You are the presiding code reviewer synthesizing a panel review of one diff. Be decisive; keep only verified findings. ${FORMAT_INSTRUCTION}`, 0.3), reportProgress, 10000));
114
116
  const roster = perspectives.map((p) => p.label).join(", ");
115
- return `DIFF REVIEW (${perspectives.length} reviewers: ${roster})\n\n${verdict}`;
117
+ // Reviewers already ran and billed; hand back their raw findings rather than losing
118
+ // the panel because the synthesis step had no judge available.
119
+ if (judged.text === null) {
120
+ const raw = perspectives.map((p) => `=== ${p.label} ===\n${p.text}`).join("\n\n");
121
+ return `DIFF REVIEW (${perspectives.length} reviewers: ${roster})\n\n⚠️ NO MERGE VERDICT — every judge was unavailable (usually quota). Findings below are UNMERGED and NOT deduplicated or severity-ranked; they may contradict each other or misread the diff.\n\n${raw}`;
122
+ }
123
+ return `DIFF REVIEW (${perspectives.length} reviewers: ${roster})\n\n${judgeAttribution(judged)}${judged.text}`;
116
124
  },
117
125
  });
118
126
  export function getAllDiffReviewTools() {