Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(models): 补齐 Grok 4.7 与 Pi 配置支持 (#4839)
Dashb95e506a2ad5
diff --git a/apps/desktop/src/main/maker-host/__tests__/activeCatalogDiscovery.test.ts b/apps/desktop/src/main/maker-host/__tests__/activeCatalogDiscovery.test.tsindex 49543e5623..90c2bef9b0 100644--- a/apps/desktop/src/main/maker-host/__tests__/activeCatalogDiscovery.test.ts+++ b/apps/desktop/src/main/maker-host/__tests__/activeCatalogDiscovery.test.ts@@ -322,8 +322,15 @@ describe('active-catalog discovered augment', () => {'grok-4.3','grok-4.5','grok-4.6',+ 'grok-4.7','grok-build-0.1',]);+ for (const agent of ['claude-code', 'codex', 'pi'] as const) {+ const id = agent === 'pi' ? 'grok-4.7' : 'xai/grok-4.7';+ expect(xai?.models[agent]?.find(model => model.id === id)).toMatchObject({+ efforts: ['low', 'medium', 'high', 'xhigh'], defaultEffort: 'high',+ });+ }expect(xai?.models.pi).not.toEqual(xai?.models['claude-code']);expect(xai?.models['claude-code']?.find((model) => model.id === 'xai/grok-4.6')).toMatchObject({efforts: ['low', 'medium', 'high', 'xhigh'],@@ -349,8 +356,15 @@ describe('active-catalog discovered augment', () => {'grok-4.3','grok-4.5','grok-4.6',+ 'grok-4.7','grok-build-0.1',]);+ for (const agent of ['claude-code', 'codex', 'pi'] as const) {+ const id = agent === 'pi' ? 'grok-4.7' : 'xai/grok-4.7';+ expect(xai?.models[agent]?.find(model => model.id === id)).toMatchObject({+ efforts: ['low', 'medium', 'high', 'xhigh'], defaultEffort: 'high',+ });+ }expect(xai?.models.pi?.find((model) => model.id === 'grok-4.6')).toMatchObject({contextWindow: 500_000,supportsImageInput: true,@@ -494,8 +508,15 @@ describe('active-catalog discovered augment', () => {'grok-4.3','grok-4.5','grok-4.6',+ 'grok-4.7','grok-build-0.1',]);+ for (const agent of ['claude-code', 'codex', 'pi'] as const) {+ const id = agent === 'pi' ? 'grok-4.7' : 'xai/grok-4.7';+ expect(xai?.models[agent]?.find(model => model.id === id)).toMatchObject({+ efforts: ['low', 'medium', 'high', 'xhigh'], defaultEffort: 'high',+ });+ }});it('xAI 媒体发现按官方存在性收敛,实报资料覆盖目录默认', () => {diff --git a/apps/desktop/src/main/maker-host/__tests__/catalogDerivedModels.test.ts b/apps/desktop/src/main/maker-host/__tests__/catalogDerivedModels.test.tsindex de90236532..a0dfc05f1f 100644--- a/apps/desktop/src/main/maker-host/__tests__/catalogDerivedModels.test.ts+++ b/apps/desktop/src/main/maker-host/__tests__/catalogDerivedModels.test.ts@@ -357,6 +357,7 @@ describe('deriveAvailableModels — dynamic-first catalog contract', () => {const cc = deriveAvailableModels(BUNDLED_CATALOG, 'claude-code');const codex = deriveAvailableModels(BUNDLED_CATALOG, 'codex');expect(cc.map((m) => m.id)).toEqual([+ 'xai/grok-4.7','xai/grok-4.6','xai/grok-4.5','xai/grok-4.3',@@ -368,6 +369,7 @@ describe('deriveAvailableModels — dynamic-first catalog contract', () => {'xai/grok-code-fast',]);expect(codex.map((m) => m.id)).toEqual([+ 'xai/grok-4.7','xai/grok-4.6','xai/grok-4.5','xai/grok-4.3',@@ -425,6 +427,7 @@ describe('deriveAvailableModels — dynamic-first catalog contract', () => {expect(ids).toEqual(['claude-opus-4-8','chatgpt/gpt-5.5',+ 'xai/grok-4.7','xai/grok-4.6','xai/grok-4.5','xai/grok-4.3',diff --git a/apps/desktop/src/main/maker-host/__tests__/piNativeProviders.test.ts b/apps/desktop/src/main/maker-host/__tests__/piNativeProviders.test.tsindex e084788524..44e38b9382 100644--- a/apps/desktop/src/main/maker-host/__tests__/piNativeProviders.test.ts+++ b/apps/desktop/src/main/maker-host/__tests__/piNativeProviders.test.ts@@ -1220,6 +1220,35 @@ describe('buildPiNativeProvidersFromConfigs', () => {expect(openai.models.pi?.some((model) => model.id.endsWith('[1m]'))).toBe(false);});+ it('materializes Grok 4.7 from the catalog when the pinned Pi binary has no entry', () => {+ const { providers } = buildPiSubscriptionNativeProviders(+ BUNDLED_CATALOG, 'http://127.0.0.1:4567/',+ new Map([['xai', new Map()]]), new Map([['xai', new Set<string>()]]),+ );+ const xai = providers.find(provider => provider.id === 'xai')!;+ expect(xai.models.find(model => model.id === 'grok-4.7')).toMatchObject({+ wireId: 'grok-4.7', api: 'openai-responses', contextWindow: 500_000,+ cost: { input: 2, output: 6, cacheRead: 0.5, cacheWrite: 0,+ tiers: [{ inputTokensAbove: 199_999, input: 4, output: 12, cacheRead: 1, cacheWrite: 0 }] },+ maxTokens: 500_000, reasoning: true, input: ['text', 'image'],+ thinkingLevelMap: { low: 'low', medium: 'medium', high: 'high', xhigh: 'xhigh', max: null },+ });+ });++ it('fills partial Pi tier rates from the base cost without mutating the catalog', () => {+ const catalog = structuredClone(BUNDLED_CATALOG);+ const model = catalog.providers.find(provider => provider.id === 'xai')!+ .models.pi!.find(model => model.id === 'grok-4.7')!;+ model.cost = { input: 2, output: 6, cacheRead: 0.5,+ tiers: [{ inputTokensAbove: 199_999, output: 12 }] };+ const { providers } = buildPiSubscriptionNativeProviders(catalog, 'http://127.0.0.1:4567/');+ const cost = providers.find(provider => provider.id === 'xai')!.models+ .find(model => model.id === 'grok-4.7')!.cost!;+ expect(cost.tiers).toEqual([{ inputTokensAbove: 199_999,+ input: 2, output: 12, cacheRead: 0.5, cacheWrite: 0 }]);+ expect(model.cost.tiers).toEqual([{ inputTokensAbove: 199_999, output: 12 }]);+ });+it('publishes SuperGrok catalog models missing from this PI binary as catalog additions', () => {const catalog = JSON.parse(JSON.stringify(BUNDLED_CATALOG)) as Catalog;const xai = catalog.providers.find((provider) => provider.id === 'xai');diff --git a/apps/desktop/src/main/maker-host/pi-host.ts b/apps/desktop/src/main/maker-host/pi-host.tsindex 0a3a11fdd5..d6db358d2f 100644--- a/apps/desktop/src/main/maker-host/pi-host.ts+++ b/apps/desktop/src/main/maker-host/pi-host.ts@@ -56,6 +56,7 @@ import {import { providerCatalogForPi, providerModelRecord } from '@cindy/model-providers';import type {Catalog,+ ModelCost,CustomProviderConfig,PiModelApi,PiReasoningEffort,@@ -505,12 +506,7 @@ export async function readPiBundledModels(return catalog;}-function catalogCostForPiNative(cost: {- input?: number;- output?: number;- cacheRead?: number;- cacheWrite?: number;-} | undefined): { input: number; output: number; cacheRead: number; cacheWrite: number } | undefined {+function catalogCostForPiNative(cost: ModelCost | undefined): PiNativeModelSpec['cost'] {if (!cost ||(typeof cost.input !== 'number' &&@@ -525,6 +521,13 @@ function catalogCostForPiNative(cost: {output: cost.output ?? 0,cacheRead: cost.cacheRead ?? 0,cacheWrite: cost.cacheWrite ?? 0,+ ...(cost.tiers ? { tiers: cost.tiers.map(tier => ({+ inputTokensAbove: tier.inputTokensAbove,+ input: tier.input ?? cost.input ?? 0,+ output: tier.output ?? cost.output ?? 0,+ cacheRead: tier.cacheRead ?? cost.cacheRead ?? 0,+ cacheWrite: tier.cacheWrite ?? cost.cacheWrite ?? 0,+ })) } : {}),};}diff --git a/docs/model-catalog-history.md b/docs/model-catalog-history.mdindex 4618eacfef..4a8dd88baa 100644--- a/docs/model-catalog-history.md+++ b/docs/model-catalog-history.md@@ -3,6 +3,30 @@> 参考记录,不是当前配置或部署状态。当前维护规则见 [模型配置与下发](dev-rules/model-catalog-maintenance.md)。> 下列文字记录各批次当时的事实,不能相互当作后续状态的证明。引用时须带日期、来源和验证范围。+## Grok 4.7 / Pi(2026-09-22)++新增 `xai/grok-4.7` 公共资料、Claude Code / Codex 路由及独立 Pi 成员 `grok-4.7`。+三个引擎均提供 low / medium / high / xhigh,默认 high;旧型号、用户覆盖和既有任务不迁移。+Pi 沿用 Responses 与现有模型装配,不升级二进制。通用供应商生成器补缺该型号,后续上游+已有同 ID 时保留上游定义,显式合法默认档在转换中保留。++依据 [官方模型说明](https://docs.x.ai/developers/grok-4-7)(核验日 2026-09-22):+500K 上下文、文字与图片输入,无独立文本输出限制,公共 Registry 不声明 maxOutputTokens。+Pi 需要有限 maxTokens,因此以共享+窗口 500K 为上限,实际请求仍按输入占用裁剪;不是额外承诺 500K 输入加 500K 输出。+[参考价格](https://docs.x.ai/developers/pricing)按 200K 输入分档,USD/MTok 的输入/缓存读/输出+分别为 2/0.5/6 和 4/1/12;Pi 的严格大于阈值写成 199999,对齐 Registry 的 >=200000。+Fast 未进入公共 API 目录。Pi 成员的 cost.tiers 随目录下发,Desktop 装配时完整保留分档。++Server 本次 revision 为 `2026-09-22T00:00:00.000Z`,客户端为同日 `.001Z`:延续既有+快照差异,客户端此前多出 13 个公共型号、8 个接入条目,另有一处公共思考能力补项。+本次只同步 Grok 4.7 的完整公共定义与接入条目,保留两侧既有数据,不伪造整表同版本一致。+其余差异尚未整表归并;本次修改不能宣称已完成所有模型目录的统一。++本地验证包括 Pi 0.85.1 真二进制接模拟 Responses 服务:图片、工具调用、四档参数、恢复+历史后的加密推理状态和稳定缓存键。Server 的 V1–V5 投影分别验证路由、默认档和价格。+这些是本地验收,不代表真实 SuperGrok 账号准入、付费生成或生产部署。+## 价格与缓存写入计量核对(2026-09-11)本轮遍历 Registry 及 Pi 目录的价格来源,同时读取 Global / CN 的匿名网关模型目录。diff --git a/packages/maker-core/src/agents/pi/__tests__/pi-agent.integration.test.ts b/packages/maker-core/src/agents/pi/__tests__/pi-agent.integration.test.tsindex 50b1dd581e..30e1fc24c2 100644--- a/packages/maker-core/src/agents/pi/__tests__/pi-agent.integration.test.ts+++ b/packages/maker-core/src/agents/pi/__tests__/pi-agent.integration.test.ts@@ -28,6 +28,7 @@ import { fileURLToPath } from 'node:url';import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';import { PiAgent } from '../index.js';+import { providerCatalogForPi, BUNDLED_CATALOG } from '@cindy/model-providers';import { TurnPermissionPolicyUnsupportedError, type AgentDeps, type AgentSessionHandle } from '../../base-agent.js';import type { AgentEvent } from '../../../types/events.js';import type { Logger } from '../../../interfaces/logger.js';@@ -1015,6 +1016,95 @@ describe.skipIf(!piAvailable)('PiAgent integration (real pi binary + fake gatewa},);+ it('runs Grok 4.7 with all efforts, image input and encrypted tool history after resume',+ { timeout: 60_000 }, async () => {+ const row = providerCatalogForPi().providers.xai.find(model => model.id === 'grok-4.7')!;+ const api = row.api;+ if (api !== 'openai-responses') throw new Error(`Unexpected Grok 4.7 API: ${api}`);+ const catalog = BUNDLED_CATALOG.providers.find(provider => provider.id === 'xai')!+ .models.pi!.find(model => model.id === row.id)!;+ const deps = buildDeps();+ deps.capabilityAdditions = { availableModels: [{+ id: row.id, displayName: row.name, contextWindow: catalog.contextWindow,+ maxOutputTokens: catalog.maxOutput, supportsImageInput: true,+ efforts: catalog.efforts, defaultEffort: catalog.defaultEffort,+ }] };+ deps.resolvePiNativeProviders = async () => ({+ providers: [{+ id: 'xai', sourceProviderId: 'xai', name: 'xAI',+ baseUrl: `${endpoint}/v1`, inheritModels: true,+ models: [{ ...row, api, input: row.input.filter((kind): kind is 'text' | 'image' => kind === 'text' || kind === 'image'),+ cost: { ...row.cost, input: row.cost?.input ?? 0, output: row.cost?.output ?? 0,+ cacheRead: row.cost?.cacheRead ?? 0, cacheWrite: row.cost?.cacheWrite ?? 0 },+ baseUrl: `${endpoint}/v1`, wireId: row.id }],+ }], env: {},+ });+ const agent = new PiAgent(deps);+ const workingDir = mkdtempSync(path.join(tmpdir(), 'pi-grok47-'));+ let handle: AgentSessionHandle | undefined;+ const before = seenRequests.length;+ const reasoning = { type: 'reasoning', id: 'rs_grok47', summary: [], encrypted_content: 'opaque-grok47-state' };+ const tool = { type: 'function_call', id: 'fc_grok47', call_id: 'call_grok47', name: 'read',+ arguments: JSON.stringify({ path: path.join(workingDir, 'proof.txt') }), status: 'completed' };+ const response = { id: 'resp_grok47', object: 'response', model: row.id, status: 'completed',+ output: [reasoning, tool], usage: { input_tokens: 10, output_tokens: 10, total_tokens: 20 } };+ const stream = [+ { type: 'response.created', response: { ...response, output: [], status: 'in_progress' } },+ { type: 'response.output_item.added', output_index: 0, item: { ...reasoning, encrypted_content: null } },+ { type: 'response.output_item.done', output_index: 0, item: reasoning },+ { type: 'response.output_item.added', output_index: 1, item: { ...tool, arguments: '', status: 'in_progress' } },+ { type: 'response.function_call_arguments.delta', output_index: 1, delta: tool.arguments },+ { type: 'response.output_item.done', output_index: 1, item: tool },+ { type: 'response.completed', response },+ ];+ try {+ writeFileSync(path.join(workingDir, 'proof.txt'), 'GROK47_TOOL_OK');+ const imagePath = path.join(workingDir, 'pixel.png');+ writeFileSync(imagePath, Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+M8AAAMBAQDJ/pLvAAAAAElFTkSuQmCC', 'base64'));+ handle = await agent.startSession({ sessionId: 'grok47-native', workingDir,+ model: row.id, providerId: 'xai', effort: 'high', permissionMode: 'bypassPermissions' });+ const send = async (image = false) => {+ const events: AgentEvent[] = [];+ const done = (async () => { for await (const event of handle!.events()) {+ events.push(event); if (event.type === 'done') break;+ } })();+ await handle!.send({ type: 'user', content: image+ ? [{ type: 'text', text: 'Read proof.txt and inspect this image.' }, { type: 'image', path: imagePath }]+ : 'Continue.' });+ await done;+ expect(events.filter(event => event.type === 'error')).toEqual([]);+ };+ scriptedResponses.push(sse(stream.map((data, sequence_number) => ({ event: data.type, data: { ...data, sequence_number } }))),+ responsesStreamBody('tool complete', row.id));+ await send(true);+ const first = seenRequests.slice(before).map(request => JSON.parse(request.body));+ expect(first).toHaveLength(2);+ expect(first[0]).toMatchObject({ model: row.id, reasoning: { effort: 'high' } });+ expect(JSON.stringify(first[0].input)).toContain('data:image/png;base64,');+ expect(first[1].input).toEqual(expect.arrayContaining([expect.objectContaining(reasoning),+ expect.objectContaining({ type: 'function_call_output', call_id: tool.call_id, output: expect.stringContaining('GROK47_TOOL_OK') })]));+ const resumeSessionId = handle.id;+ await handle.close();+ handle = await agent.startSession({ sessionId: 'grok47-native', workingDir, model: row.id,+ providerId: 'xai', resumeSessionId, effort: 'high', permissionMode: 'bypassPermissions' });+ for (const effort of ['low', 'medium', 'high', 'xhigh'] as const) {+ await handle.setEffort!(effort);+ scriptedResponses.push(responsesStreamBody(`reply ${effort}`, row.id));+ await send();+ const request = JSON.parse(seenRequests.at(-1)!.body);+ expect(request.reasoning.effort).toBe(effort);+ expect(request.input).toEqual(expect.arrayContaining([expect.objectContaining(reasoning)]));+ expect(request.prompt_cache_key).toBe(first[0].prompt_cache_key);+ }+ expect(first[0].prompt_cache_key).toEqual(expect.any(String));+ expect(seenRequests.slice(before).every(request => request.url === '/v1/responses')).toBe(true);+ } finally {+ await handle?.close();+ scriptedResponses.length = 0;+ rmSync(workingDir, { recursive: true, force: true });+ }+ });+it('accepts a turn permission policy in ask, rejects it in Full Access, and honors steer cancellation before RPC',{ timeout: 60_000 },diff --git a/packages/model-providers/catalog/model-registry.json b/packages/model-providers/catalog/model-registry.jsonindex 1a47ab3aa7..872b34476e 100644--- a/packages/model-providers/catalog/model-registry.json+++ b/packages/model-providers/catalog/model-registry.json@@ -1,6 +1,6 @@{"schemaVersion": 5,- "updatedAt": "2026-09-14T00:00:00.001Z",+ "updatedAt": "2026-09-22T00:00:00.001Z","models": [{"id": "openai/gpt-5.6-sol",@@ -768,6 +768,22 @@"nativeApi": "anthropic-messages","modelRef": "anthropic/claude-haiku-4-5"},+ {+ "id": "xai/grok-4.7",+ "name": "Grok 4.7",+ "status": "active",+ "sortOrder": 47,+ "routes": [+ {+ "providerId": "xai",+ "modelId": "xai/grok-4.7",+ "agents": ["claude-code", "codex"],+ "referencePriceGroup": "global"+ }+ ],+ "nativeApi": "openai-responses",+ "modelRef": "xai/grok-4.7"+ },{"id": "xai/grok-4.6","name": "Grok 4.6",@@ -3597,6 +3613,58 @@}]},+ {+ "id": "xai/grok-4.7",+ "aliases": [],+ "defaults": {+ "name": "Grok 4.7",+ "group": "grok",+ "contextWindow": 500000,+ "efforts": [+ "low",+ "medium",+ "high",+ "xhigh"+ ],+ "defaultEffort": "high",+ "supportsImageInput": true+ },+ "referencePriceGroups": [+ {+ "id": "global",+ "prices": [+ {+ "currency": "USD",+ "variant": "standard",+ "inputPerMtok": 2,+ "outputPerMtok": 6,+ "cacheReadPerMtok": 0.5,+ "maxInputTokens": 200000,+ "effectiveFrom": "2026-09-21",+ "source": {+ "kind": "provider-official",+ "url": "https://docs.x.ai/developers/pricing",+ "verifiedAt": "2026-09-22"+ }+ },+ {+ "currency": "USD",+ "variant": "standard",+ "inputPerMtok": 4,+ "outputPerMtok": 12,+ "cacheReadPerMtok": 1,+ "minInputTokens": 200000,+ "effectiveFrom": "2026-09-21",+ "source": {+ "kind": "provider-official",+ "url": "https://docs.x.ai/developers/pricing",+ "verifiedAt": "2026-09-22"+ }+ }+ ]+ }+ ]+ },{"id": "xai/grok-4.6","aliases": [],diff --git a/packages/model-providers/catalog/provider-models.json b/packages/model-providers/catalog/provider-models.jsonindex 29a8923683..028a2c155a 100644--- a/packages/model-providers/catalog/provider-models.json+++ b/packages/model-providers/catalog/provider-models.json@@ -1,6 +1,6 @@{"schemaVersion": 1,- "generatedAt": "2026-09-12T00:00:00.000Z",+ "generatedAt": "2026-09-22T00:00:00.000Z","source": "pi","providers": {"amazon-bedrock": [@@ -54884,6 +54884,60 @@}}},+ {+ "id": "grok-4.7",+ "name": "Grok 4.7",+ "upstream": "https://api.x.ai/v1",+ "contextWindow": 500000,+ "maxOutput": 500000,+ "modalities": {+ "input": [+ "text",+ "image"+ ],+ "output": [+ "text"+ ]+ },+ "supportsImageInput": true,+ "reasoning": true,+ "efforts": [+ "low",+ "medium",+ "high",+ "xhigh"+ ],+ "defaultEffort": "high",+ "cost": {+ "input": 2,+ "output": 6,+ "cacheRead": 0.5,+ "cacheWrite": 0,+ "tiers": [+ {+ "inputTokensAbove": 199999,+ "input": 4,+ "output": 12,+ "cacheRead": 1,+ "cacheWrite": 0+ }+ ]+ },+ "execution": {+ "pi": {+ "api": "openai-responses",+ "thinkingLevelMap": {+ "off": null,+ "minimal": null,+ "low": "low",+ "medium": "medium",+ "high": "high",+ "xhigh": "xhigh",+ "max": null+ }+ }+ }+ },{"id": "grok-build-0.1","name": "Grok Build 0.1",diff --git a/packages/model-providers/catalog/providers.json b/packages/model-providers/catalog/providers.jsonindex 2918814078..67067df43c 100644--- a/packages/model-providers/catalog/providers.json+++ b/packages/model-providers/catalog/providers.json@@ -64,6 +64,22 @@},"models": {"claude-code": [+ {+ "id": "xai/grok-4.7",+ "name": "Grok 4.7",+ "group": "grok",+ "sortOrder": 47,+ "contextWindow": 500000,+ "efforts": [+ "low",+ "medium",+ "high",+ "xhigh"+ ],+ "defaultEffort": "high",+ "status": "active",+ "supportsImageInput": true+ },{"id": "xai/grok-4.6","name": "Grok 4.6",@@ -171,6 +187,22 @@}],"codex": [+ {+ "id": "xai/grok-4.7",+ "name": "Grok 4.7",+ "group": "grok",+ "sortOrder": 47,+ "contextWindow": 500000,+ "efforts": [+ "low",+ "medium",+ "high",+ "xhigh"+ ],+ "defaultEffort": "high",+ "status": "active",+ "supportsImageInput": true+ },{"id": "xai/grok-4.6","name": "Grok 4.6",@@ -278,6 +310,39 @@}],"pi": [+ {+ "id": "grok-4.7",+ "name": "Grok 4.7",+ "piApi": "openai-responses",+ "group": "grok",+ "sortOrder": 47,+ "contextWindow": 500000,+ "maxOutput": 500000,+ "efforts": [+ "low",+ "medium",+ "high",+ "xhigh"+ ],+ "defaultEffort": "high",+ "status": "active",+ "supportsImageInput": true,+ "cost": {+ "input": 2,+ "output": 6,+ "cacheRead": 0.5,+ "cacheWrite": 0,+ "tiers": [+ {+ "inputTokensAbove": 199999,+ "input": 4,+ "output": 12,+ "cacheRead": 1,+ "cacheWrite": 0+ }+ ]+ }+ },{"id": "grok-4.3","name": "Grok 4.3",diff --git a/packages/model-providers/src/__tests__/catalog.test.ts b/packages/model-providers/src/__tests__/catalog.test.tsindex a1fe8a0a32..827de75a66 100644--- a/packages/model-providers/src/__tests__/catalog.test.ts+++ b/packages/model-providers/src/__tests__/catalog.test.ts@@ -30,6 +30,7 @@ const DYNAMIC_PROVIDER_IDS = ["anthropic", "openai", "xd"] as const;/** xAI 随包 fallback 元数据清单。 */const EXPECTED_XAI_IDS = [+ "xai/grok-4.7","xai/grok-4.6","xai/grok-4.5","xai/grok-4.3",@@ -44,6 +45,7 @@ const EXPECTED_XAI_PI_IDS = ["grok-4.3","grok-4.5","grok-4.6",+ "grok-4.7","grok-build-0.1",];diff --git a/packages/model-providers/src/__tests__/modelDefaultEffort.test.ts b/packages/model-providers/src/__tests__/modelDefaultEffort.test.tsindex c770fa6208..9ae7d69984 100644--- a/packages/model-providers/src/__tests__/modelDefaultEffort.test.ts+++ b/packages/model-providers/src/__tests__/modelDefaultEffort.test.ts@@ -77,11 +77,12 @@ describe("medium-first defaults", () => {rawRegistry as unknown as ModelRegistry,)) {if (!model.efforts?.length) continue;- // Kimi Code documents max as K2.8 Preview's default, unlike our+ // Grok 4.7 uses official high; Kimi Code uses max, unlike our// medium-first fallback for models without this official default.expect(model.defaultEffort, model.id).toBe(model.id === "moonshotai/kimi-k2.8-preview"? "max"+ : model.id === "xai/grok-4.7" ? "high": defaultEffortForCapabilities(model.efforts),);for (const override of Object.values(model.perAgent ?? {})) {diff --git a/packages/model-providers/src/__tests__/piCatalogCorrections.test.ts b/packages/model-providers/src/__tests__/piCatalogCorrections.test.tsindex 16ff1b5093..f59235ae94 100644--- a/packages/model-providers/src/__tests__/piCatalogCorrections.test.ts+++ b/packages/model-providers/src/__tests__/piCatalogCorrections.test.ts@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest';import {applyKnownXaiCorrections,+ applyGrok47CatalogAddition,preferredDefaultEffort,} from '../../../../tools/pi/xai-catalog-corrections.mjs';import { applyAstraCatalogAdditions } from '../../../../tools/pi/openai-catalog-corrections.mjs';@@ -9,8 +10,40 @@ import { providerCatalogForPi } from '../providerModelCatalog.js';const piCatalog = providerCatalogForPi();import { BUNDLED_CATALOG } from '../catalog.js';import { modelProtocolComparison } from '../modelProtocol.js';+import { toCindyProviderModel } from '../../../../tools/pi/catalog-format.mjs';describe('Pi xAI catalog corrections', () => {+ it('adds Grok 4.7 reproducibly and preserves newer upstream definitions', () => {+ const providers = applyGrok47CatalogAddition({});+ const model = providers.xai[0];+ expect(toCindyProviderModel(model)).toMatchObject({+ id: 'grok-4.7', contextWindow: 500_000, maxOutput: 500_000,+ supportsImageInput: true,+ efforts: ['low', 'medium', 'high', 'xhigh'], defaultEffort: 'high',+ execution: { pi: { api: 'openai-responses', thinkingLevelMap: { xhigh: 'xhigh' } } },+ });+ expect(piCatalog.providers.xai.find(row => row.id === model.id)).toMatchObject({+ api: model.api, contextWindow: model.contextWindow, maxTokens: model.maxTokens,+ thinkingLevelMap: model.thinkingLevelMap, cost: model.cost,+ });+ expect(applyGrok47CatalogAddition(providers)).toEqual(providers);+ expect(toCindyProviderModel({ ...model, defaultEffort: 'max' }).defaultEffort).toBe('medium');+ const future = { ...model, contextWindow: 600_000 };+ expect(applyGrok47CatalogAddition({ xai: [future] }).xai).toEqual([future]);+ const { defaultEffort: _default, ...upstream } = future;+ const imported = applyGrok47CatalogAddition({ xai: [upstream] });+ expect(imported.xai).toEqual([{ ...upstream, defaultEffort: 'high' }]);+ expect(toCindyProviderModel(imported.xai[0]).defaultEffort).toBe('high');+ expect(upstream).not.toHaveProperty('defaultEffort');+ expect(applyGrok47CatalogAddition(imported)).toEqual(imported);+ const explicit = { ...upstream, defaultEffort: 'xhigh' };+ expect(applyGrok47CatalogAddition({ xai: [explicit] }).xai).toEqual([explicit]);+ for (const agent of ['claude-code', 'codex', 'pi'] as const) {+ expect(BUNDLED_CATALOG.providers.find(row => row.id === 'xai')?.models[agent]+ ?.find(row => row.id === (agent === 'pi' ? 'grok-4.7' : 'xai/grok-4.7')))+ .toMatchObject({ efforts: ['low', 'medium', 'high', 'xhigh'], defaultEffort: 'high' });+ }+ });it('keeps official Grok 4.6 xhigh + default high when pi.dev still ships no thinking map', () => {const stale = [{diff --git a/packages/model-providers/src/__tests__/providerModelCatalog.test.ts b/packages/model-providers/src/__tests__/providerModelCatalog.test.tsindex 7d183b5c3d..be3ebcf67f 100644--- a/packages/model-providers/src/__tests__/providerModelCatalog.test.ts+++ b/packages/model-providers/src/__tests__/providerModelCatalog.test.ts@@ -132,9 +132,10 @@ it('keeps generated defaults consistent with Cindy model preferences', async ()const { PROVIDER_MODEL_CATALOG } = await import('../providerModelCatalog.js');const { defaultEffortForCapabilities } = await import('../effortResolution.js');for (const model of Object.values(PROVIDER_MODEL_CATALOG.providers).flat()) {- // K2.8's official default is max; other imported models keep the generic preference.+ // Explicit official defaults: K2.8 max and Grok 4.7 high.const expected = model.id === 'kimi-for-coding' && model.upstream === 'https://api.kimi.com/coding'- ? 'max' : defaultEffortForCapabilities(model.efforts);+ ? 'max' : model.id === 'grok-4.7' && model.upstream === 'https://api.x.ai/v1'+ ? 'high' : defaultEffortForCapabilities(model.efforts);expect(model.defaultEffort, model.id).toBe(expected);}});diff --git a/packages/model-providers/src/types.ts b/packages/model-providers/src/types.tsindex 420fc7d36e..019f199025 100644--- a/packages/model-providers/src/types.ts+++ b/packages/model-providers/src/types.ts@@ -263,6 +263,14 @@ export interface ModelCost {output?: number;cacheRead?: number;cacheWrite?: number;+ /** Pi-compatible rates used when input tokens strictly exceed this threshold. */+ tiers?: Array<{+ inputTokensAbove: number;+ input?: number;+ output?: number;+ cacheRead?: number;+ cacheWrite?: number;+ }>;}/**diff --git a/tools/pi/catalog-format.d.mts b/tools/pi/catalog-format.d.mtsindex e0d6f2d5f6..232fd57fc0 100644--- a/tools/pi/catalog-format.d.mts+++ b/tools/pi/catalog-format.d.mts@@ -9,6 +9,7 @@ export interface PiImportModel {maxTokens?: number;input?: string[];reasoning?: boolean;+ defaultEffort?: string;thinkingLevelMap?: Record<string, string | null>;cost?: Record<string, unknown>;headers?: Record<string, string>;diff --git a/tools/pi/catalog-format.mjs b/tools/pi/catalog-format.mjsindex 31d6590c12..553df82dfa 100644--- a/tools/pi/catalog-format.mjs+++ b/tools/pi/catalog-format.mjs@@ -50,8 +50,12 @@ export function toCindyProviderModel(row) {supportsImageInput: row.input?.includes("image") ?? false,reasoning: row.reasoning === true,efforts,- // Same product preference as defaultEffortForCapabilities; guarded by the import test.- defaultEffort: ["medium", "high", "low", "xhigh", "max", "minimal", "ultra"].find(effort => efforts.includes(effort)) ?? null,+ // Preserve a supported explicit default; otherwise use Cindy's generic preference.+ defaultEffort: efforts.includes(row.defaultEffort)+ ? row.defaultEffort+ : (["medium", "high", "low", "xhigh", "max", "minimal", "ultra"].find(+ (effort) => efforts.includes(effort),+ ) ?? null),...(Object.keys(cost).length ? { cost } : {}),execution: {pi: {diff --git a/tools/pi/sync-model-catalog.mjs b/tools/pi/sync-model-catalog.mjsindex 06549dbd40..9a61504630 100644--- a/tools/pi/sync-model-catalog.mjs+++ b/tools/pi/sync-model-catalog.mjs@@ -18,6 +18,7 @@ const PI_CATALOG_BASE = "https://pi.dev/api/models/providers";import {applyKnownXaiCorrections,applyPinnedXaiAdditions,+ applyGrok47CatalogAddition,} from "./xai-catalog-corrections.mjs";import {applyAstraCatalogAdditions,@@ -49,7 +50,9 @@ function catalogEntries(providerId, value) {async function main() {const providers = {};const previous = JSON.parse(await fs.readFile(SNAPSHOT_PATH, "utf8"));- const PROVIDER_IDS = Object.keys(previous.providers).filter(id => id !== '.manifest').sort();+ const PROVIDER_IDS = Object.keys(previous.providers)+ .filter((id) => id !== ".manifest")+ .sort();let newestModified = 0;const inputIndex = process.argv.indexOf("--input");const inputPath = inputIndex >= 0 ? process.argv[inputIndex + 1] : undefined;@@ -76,16 +79,14 @@ async function main() {throw new Error(`Input catalog lacks provider '${providerId}'`);}for (const providerId of Object.keys(input)) {- if (providerId === '.manifest') continue;+ if (providerId === ".manifest") continue;if (!(providerId in input))throw new Error(`Input catalog lacks provider '${providerId}'`);providers[providerId] = catalogEntries(providerId, input[providerId]);}} else {// Refresh the complete imported catalog, including channels not curated as GUI presets.- const providerIds = [- ...new Set(PROVIDER_IDS),- ].sort();+ const providerIds = [...new Set(PROVIDER_IDS)].sort();for (const providerId of providerIds) {const response = await fetch(`${PI_CATALOG_BASE}/${encodeURIComponent(providerId)}`,@@ -107,6 +108,7 @@ async function main() {}}if (providers.xai) providers.xai = applyKnownXaiCorrections(providers.xai);+ applyGrok47CatalogAddition(providers);applyAstraCatalogAdditions(providers);if (bundlePath) {applyPinnedAstraCorrections(providers, sourceVersion);diff --git a/tools/pi/xai-catalog-corrections.d.mts b/tools/pi/xai-catalog-corrections.d.mtsindex b47f7803f8..7a7b9e5565 100644--- a/tools/pi/xai-catalog-corrections.d.mts+++ b/tools/pi/xai-catalog-corrections.d.mts@@ -21,3 +21,7 @@ export function applyPinnedXaiAdditions(providers: Record<string, import('./catalog-format.mjs').PiImportModel[]>,version?: string,): void;++export function applyGrok47CatalogAddition(+ providers: Record<string, import('./catalog-format.mjs').PiImportModel[]>,+): Record<string, import('./catalog-format.mjs').PiImportModel[]>;diff --git a/tools/pi/xai-catalog-corrections.mjs b/tools/pi/xai-catalog-corrections.mjsindex 13efd10a6b..85a324b1ed 100644--- a/tools/pi/xai-catalog-corrections.mjs+++ b/tools/pi/xai-catalog-corrections.mjs@@ -8,17 +8,17 @@// with no thinkingLevelMap; re-sync must keep this overlay.export const XAI_THINKING_CORRECTIONS = {- 'grok-4.6': {+ "grok-4.6": {thinkingLevelMap: {off: null,minimal: null,- low: 'low',- medium: 'medium',- high: 'high',- xhigh: 'xhigh',+ low: "low",+ medium: "medium",+ high: "high",+ xhigh: "xhigh",max: null,},- defaultEffort: 'high',+ defaultEffort: "high",supportsReasoningEffort: true,},};@@ -38,40 +38,107 @@ export function applyKnownXaiCorrections(models) {});}-export function preferredDefaultEffort(modelId, efforts, fallbackDefaultEffort) {+export function preferredDefaultEffort(+ modelId,+ efforts,+ fallbackDefaultEffort,+) {const requested = XAI_THINKING_CORRECTIONS[modelId]?.defaultEffort;if (requested && efforts.includes(requested)) return requested;return fallbackDefaultEffort(efforts);}+// Official contract verified 2026-09-22:+// https://docs.x.ai/developers/grok-4-7+// https://docs.x.ai/developers/pricing+// No separate text output limit; Pi's finite maxTokens is bounded by the shared+// 500k context, and its serializer reserves space for the input on each request.+// Add only when absent; upstream capabilities and explicit defaults remain authoritative.+// Pi rows may omit Cindy's defaultEffort extension, so keep the official default then.+export function applyGrok47CatalogAddition(providers) {+ const existing = providers.xai?.find((row) => row.id === "grok-4.7");+ if (existing) {+ if (existing.defaultEffort == null) {+ providers.xai = providers.xai.map((row) =>+ row === existing ? { ...row, defaultEffort: "high" } : row,+ );+ }+ return providers;+ }+ providers.xai = [+ ...(providers.xai ?? []),+ {+ id: "grok-4.7",+ name: "Grok 4.7",+ provider: "xai",+ api: "openai-responses",+ baseUrl: "https://api.x.ai/v1",+ reasoning: true,+ input: ["text", "image"],+ contextWindow: 500_000,+ maxTokens: 500_000,+ defaultEffort: "high",+ thinkingLevelMap: {+ off: null,+ minimal: null,+ low: "low",+ medium: "medium",+ high: "high",+ xhigh: "xhigh",+ max: null,+ },+ cost: {+ input: 2,+ output: 6,+ cacheRead: 0.5,+ cacheWrite: 0,+ tiers: [+ {+ inputTokensAbove: 199_999,+ input: 4,+ output: 12,+ cacheRead: 1,+ cacheWrite: 0,+ },+ ],+ },+ },+ ];+ return providers;+}+// Preserve Cindy's already shipped model addition when importing its older pinned binary.export function applyPinnedXaiAdditions(providers, version) {- if (version !== "0.85.1" || providers.xai?.some(row => row.id === "grok-build-0.1")) return;- providers.xai = [...(providers.xai ?? []), {- "id": "grok-build-0.1",- "name": "Grok Build 0.1",- "api": "openai-responses",- "provider": "xai",- "baseUrl": "https://api.x.ai/v1",- "compat": {- "supportsLongCacheRetention": false- },- "reasoning": true,- "input": [- "text",- "image"- ],- "cost": {- "input": 1,- "output": 2,- "cacheRead": 0.2,- "cacheWrite": 0- },- "contextWindow": 256000,- "maxTokens": 256000,- "thinkingLevelMap": {- "off": null,- "minimal": null- }-} ];+ if (+ version !== "0.85.1" ||+ providers.xai?.some((row) => row.id === "grok-build-0.1")+ )+ return;+ providers.xai = [+ ...(providers.xai ?? []),+ {+ id: "grok-build-0.1",+ name: "Grok Build 0.1",+ api: "openai-responses",+ provider: "xai",+ baseUrl: "https://api.x.ai/v1",+ compat: {+ supportsLongCacheRetention: false,+ },+ reasoning: true,+ input: ["text", "image"],+ cost: {+ input: 1,+ output: 2,+ cacheRead: 0.2,+ cacheWrite: 0,+ },+ contextWindow: 256000,+ maxTokens: 256000,+ thinkingLevelMap: {+ off: null,+ minimal: null,+ },+ },+ ];}