diff --git a/packages/grok/index.mjs b/packages/grok/index.mjs index 3df4f2c..e3dd87b 100644 --- a/packages/grok/index.mjs +++ b/packages/grok/index.mjs @@ -225,8 +225,20 @@ function rewrite(body) { // ---- models ------------------------------------------------------------------- +// the levels the built-in offered for grok-4.7 before Grok listed any (its +// maker's, as models.dev has them): kept when the list can't be read, so +// a move leaves an agent's reasoning level where it was +const DEFAULT_EFFORTS = ["low", "medium", "high", "xhigh"] + const DEFAULT_MODELS = { - "grok-4.7": { name: "Grok 4.7", attachment: true, reasoning: true, tool_call: true, modalities: { input: ["text", "image"], output: ["text"] } }, + "grok-4.7": { + name: "Grok 4.7", + attachment: true, + reasoning: true, + tool_call: true, + modalities: { input: ["text", "image"], output: ["text"] }, + variants: Object.fromEntries(DEFAULT_EFFORTS.map((e) => [e, { reasoningEffort: e }])), + }, } // listModels is what the account can use, as the CLI's backend lists it: diff --git a/packages/grok/models.test.mjs b/packages/grok/models.test.mjs new file mode 100644 index 0000000..f5f0081 --- /dev/null +++ b/packages/grok/models.test.mjs @@ -0,0 +1,15 @@ +// grok-4.7 offers the built-in's reasoning levels before Grok lists any: +// magpie keeps the configured model when the models hook fails, and a +// model with no variants lost the levels the built-in had (low…xhigh). +import { expect, test } from "bun:test" +import { GrokAuthPlugin } from "./index.mjs" + +test("the configured grok-4.7 carries the built-in's levels", async () => { + const hooks = await GrokAuthPlugin({ client: { auth: { set: async () => {} } } }) + const cfg = {} + await hooks.config(cfg) + const m = cfg.provider.grok.models["grok-4.7"] + expect(m.reasoning).toBe(true) + expect(Object.keys(m.variants)).toEqual(["low", "medium", "high", "xhigh"]) + expect(m.variants.xhigh).toEqual({ reasoningEffort: "xhigh" }) +}) diff --git a/packages/grok/package.json b/packages/grok/package.json index 21a5740..6844ec9 100644 --- a/packages/grok/package.json +++ b/packages/grok/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-grok-auth", - "version": "0.1.3", + "version": "0.1.4", "description": "OpenCode provider plugin: Grok (SuperGrok / X Premium+) through the Grok Build CLI's sign-in", "type": "module", "main": "./index.mjs",