diff --git a/internal/gateway/factory_pool_rest_test.go b/internal/gateway/factory_pool_rest_test.go index 74c784426..c091e206a 100644 --- a/internal/gateway/factory_pool_rest_test.go +++ b/internal/gateway/factory_pool_rest_test.go @@ -31,7 +31,7 @@ func TestFactoryStandardOutLeavesCore(t *testing.T) { // the factory plugin's limitWindows on limits(100, 1), as it answers // usage (packages/factory/index.mjs, 0.1.x), its windows' ends moved // to now - core := `["glm-5.3","glm-5.3-flash","glm-5.2","kimi-k3","deepseek-v4.1-flash","qwen3.8-max","minimax-m3","minimax-m2.7","mistral-medium-3.5","nemotron-3-ultra"]` + core := `["glm-5.3","glm-5.3-flash","glm-5.2","kimi-k3","deepseek-v4.1-flash","qwen3.8-max","minimax-m3","minimax-m2.7","mistral-large-4","mistral-medium-3.5","nemotron-3-ultra"]` pluginUsage := func(std, coreUsed int) []byte { return []byte(`{"windows":[` + `{"name":"5 hours","used":` + strconv.Itoa(std) + `,"span":18000,"resetsAt":"` + soon + `","notModels":` + core + `},` + diff --git a/internal/provider/factory.go b/internal/provider/factory.go index 18c61ae4d..37d0ecdf9 100644 --- a/internal/provider/factory.go +++ b/internal/provider/factory.go @@ -586,6 +586,9 @@ type factoryModel struct { // picks it client side). Gemini's are the ones droid 0.231.0's CLI registry // still offers (provider google); 2.5 and Gemini 3 Pro Image are // availableInCLI false there, and stay out. They go to /api/llm/g. +// Haiku 5.5 and Mistral Large 4 are droid 0.240.0's; GPT-6 Astra Ultra +// Fast, new there too, stays out, as droid offers it only once the user +// has accepted Factory's high-cost terms for it. var factoryModels = []factoryModel{ {"claude-fable-5.1", "Fable 5.1", Anthropic, "anthropic", 867000, 128000, []string{"low", "medium", "high", "xhigh", "max"}, true}, {"claude-fable-5", "Fable 5", Anthropic, "anthropic", 867000, 128000, []string{"low", "medium", "high", "xhigh", "max"}, true}, @@ -595,6 +598,7 @@ var factoryModels = []factoryModel{ {"claude-sonnet-5-5", "Sonnet 5.5", Anthropic, "anthropic", 872000, 128000, []string{"low", "medium", "high", "xhigh", "max"}, true}, {"claude-sonnet-5", "Sonnet 5", Anthropic, "anthropic", 872000, 128000, []string{"low", "medium", "high", "xhigh", "max"}, true}, {"claude-sonnet-4-6", "Sonnet 4.6", Anthropic, "anthropic", 931000, 64000, []string{"low", "medium", "high", "max"}, true}, + {"claude-haiku-5-5", "Haiku 5.5", Anthropic, "anthropic", 872000, 128000, []string{"low", "medium", "high", "xhigh", "max"}, true}, {"claude-haiku-4-5-20251001", "Haiku 4.5", Anthropic, "anthropic", 0, 0, []string{"low", "medium", "high"}, true}, {"gpt-6-sol", "GPT-6 Sol", Responses, "openai", 1050000, 128000, []string{"none", "low", "medium", "high", "xhigh", "max"}, true}, {"gpt-6-astra", "GPT-6 Astra", Responses, "openai", 1050000, 128000, []string{"low", "medium", "high", "xhigh", "max"}, true}, @@ -624,6 +628,7 @@ var factoryModels = []factoryModel{ {"qwen3.8-max", "Qwen3.8 Max", Chat, "fireworks", 262144, 131072, []string{"low", "medium", "xhigh"}, false}, {"minimax-m3", "MiniMax M3", Chat, "fireworks", 512000, 64000, []string{"high"}, true}, {"minimax-m2.7", "MiniMax M2.7", Anthropic, "fireworks", 196600, 64000, []string{"high"}, false}, + {"mistral-large-4", "Mistral Large 4", Chat, "mistral", 524288, 64000, []string{"high"}, true}, {"mistral-medium-3.5", "Mistral Medium 3.5", Chat, "mistral", 256000, 64000, []string{"high"}, true}, {"nemotron-3-ultra", "Nemotron 3 Ultra", Chat, "baseten", 202000, 65536, []string{"high"}, false}, } diff --git a/internal/provider/factory_models_test.go b/internal/provider/factory_models_test.go new file mode 100644 index 000000000..9458773d3 --- /dev/null +++ b/internal/provider/factory_models_test.go @@ -0,0 +1,78 @@ +// PLUGIN-SERVED (see AGENTS.md): a moved Factory's models are the plugin's +// (@magpie-community/opencode-factory-auth, packages/factory/models.test.mjs +// checks the same fixture there); this is the built-in's table. + +package provider + +import ( + "encoding/json" + "os" + "regexp" + "slices" + "strconv" + "strings" + "testing" +) + +// JL on Discord (droid 0.240.0): droid offers Haiku 5.5, a Factory account +// through magpie didn't. The fixture is droid 0.240.0's own registry +// entries (@factory/cli-darwin-arm64, bin/droid), byte for byte. +func TestFactoryDroid0240Models(t *testing.T) { + raw, err := os.ReadFile("testdata/factory_droid_0.240.0_models.txt") + if err != nil { + t.Fatal(err) + } + src := string(raw) + entry := func(id string) string { + for _, l := range strings.Split(src, "\n") { + if strings.HasPrefix(l, `"`+id+`":{id:"`+id+`",`) { + return l + } + } + t.Fatalf("%s is not in the fixture", id) + return "" + } + limits := func(text string) (int, int) { + re := regexp.MustCompile(`contextLimits:R\(\{maxInputTokens:(\d+),maxOutputTokens:(\d+)\}\)`) + m := re.FindStringSubmatch(text) + if m == nil { + name := regexp.MustCompile(`contextLimits:(\w+),`).FindStringSubmatch(text)[1] + m = regexp.MustCompile(`(?m)^` + name + `=te\(\{[^}]*maxInputTokens:(\d+),maxOutputTokens:(\d+)\}\)`).FindStringSubmatch(src) + } + c, _ := strconv.Atoi(m[1]) + o, _ := strconv.Atoi(m[2]) + return c, o + } + for _, c := range []struct { + id string + api Protocol + }{{"claude-haiku-5-5", Anthropic}, {"mistral-large-4", Chat}} { + text := entry(c.id) + m, ok := factoryModelOf(c.id) + if !ok { + t.Fatalf("%s isn't offered", c.id) + } + if name := regexp.MustCompile(`,name:"([^"]+)"`).FindStringSubmatch(text)[1]; m.name != name { + t.Errorf("%s name %q, droid %q", c.id, m.name, name) + } + if ctx, out := limits(text); m.context != ctx || m.output != out { + t.Errorf("%s limits %d/%d, droid %d/%d", c.id, m.context, m.output, ctx, out) + } + var efforts []string + json.Unmarshal([]byte(regexp.MustCompile(`reasoningEffort:\{supported:(\[[^\]]*\])`).FindStringSubmatch(text)[1]), &efforts) + efforts = slices.DeleteFunc(efforts, func(e string) bool { return e == "off" }) + if !slices.Equal(m.efforts, efforts) { + t.Errorf("%s efforts %v, droid %v", c.id, m.efforts, efforts) + } + if m.api != c.api || !m.images { + t.Errorf("%s api %s images %v", c.id, m.api, m.images) + } + } + if !strings.Contains(entry("mistral-large-4"), `billingPool:"core"`) || !factoryCore("mistral-large-4") || factoryCore("claude-haiku-5-5") { + t.Error("Mistral Large 4 is Droid Core's, Haiku 5.5 Standard's") + } + // offered only after the user accepts Factory's high-cost terms + if _, ok := factoryModelOf("gpt-6-astra-ultrafast"); ok || !strings.Contains(entry("gpt-6-astra-ultrafast"), `explicitOptInRequirement:{kind:"high_cost"`) { + t.Error("GPT-6 Astra Ultra Fast is opt-in in droid and stays out") + } +} diff --git a/internal/provider/migrate_factory.go b/internal/provider/migrate_factory.go index c18a546b1..924384eb9 100644 --- a/internal/provider/migrate_factory.go +++ b/internal/provider/migrate_factory.go @@ -13,7 +13,7 @@ import ( func init() { movers["factory"] = &mover{ pkg: "@magpie-community/opencode-factory-auth", - min: "0.1.24", // a session continued after Claude Code compaction, whose restored context opens with the invoked-skills reminder (plugins #66); Claude Code's streamed context_management left out, which Factory's streaming route refuses (plugins #71); Claude Code's skill list sent alone as a system message, as text blocks or a string, gets update-config's line Factory takes (plugins #72); Claude Code 2.1.280's restored-context turn after /compact (plugins #68); pi's compaction and branch summary openings reworded (#1316); hook notifications kept in Claude Code compaction context only stop changed-file quoting, summaries quoted like tool output, a cut after a hunk separator (plugins #42); Claude Code compaction/runtime metadata and quoted session summaries (#1132); pi's opening sentence cut to its first half (#952); DeepSeek V4.1 Flash, Kimi K3 and GLM-5.2 offering none, so reasoning turned off stops their thinking (#899); requests saying droid 0.233.0 (JL: every model 403); Claude Code 2.1.288's runtime context as a system message of text blocks (#658); a tool whose input_schema has anyOf/oneOf/allOf at its root (Codex's automation_update) wrapped for Claude models (#646); a failure's status and its sign-in mark as the built-in's; Claude 5's system-role metadata as Factory takes it; Claude Code's standalone model-switch system updates; tool results quoting Claude Code's fixed phrases, and Claude Code's directory updates carrying a model; the sign-in renewed ahead of time through auth.refresh; Claude Code with a global CLAUDE.md or a SessionStart hook, and Claude Desktop's model line (#634) + min: "0.1.25", // Haiku 5.5 and Mistral Large 4, in droid 0.240.0's picker (JL); a session continued after Claude Code compaction, whose restored context opens with the invoked-skills reminder (plugins #66); Claude Code's streamed context_management left out, which Factory's streaming route refuses (plugins #71); Claude Code's skill list sent alone as a system message, as text blocks or a string, gets update-config's line Factory takes (plugins #72); Claude Code 2.1.280's restored-context turn after /compact (plugins #68); pi's compaction and branch summary openings reworded (#1316); hook notifications kept in Claude Code compaction context only stop changed-file quoting, summaries quoted like tool output, a cut after a hunk separator (plugins #42); Claude Code compaction/runtime metadata and quoted session summaries (#1132); pi's opening sentence cut to its first half (#952); DeepSeek V4.1 Flash, Kimi K3 and GLM-5.2 offering none, so reasoning turned off stops their thinking (#899); requests saying droid 0.233.0 (JL: every model 403); Claude Code 2.1.288's runtime context as a system message of text blocks (#658); a tool whose input_schema has anyOf/oneOf/allOf at its root (Codex's automation_update) wrapped for Claude models (#646); a failure's status and its sign-in mark as the built-in's; Claude 5's system-role metadata as Factory takes it; Claude Code's standalone model-switch system updates; tool results quoting Claude Code's fixed phrases, and Claude Code's directory updates carrying a model; the sign-in renewed ahead of time through auth.refresh; Claude Code with a global CLAUDE.md or a SessionStart hook, and Claude Desktop's model line (#634) agents: []string{"factory"}, out: func() ([]Moving, error) { ls := factoryLogins() diff --git a/internal/provider/testdata/factory_droid_0.240.0_models.txt b/internal/provider/testdata/factory_droid_0.240.0_models.txt new file mode 100644 index 000000000..d54bf01dd --- /dev/null +++ b/internal/provider/testdata/factory_droid_0.240.0_models.txt @@ -0,0 +1,9 @@ +// Excerpts, byte for byte, of droid 0.240.0 (@factory/cli-darwin-arm64@0.240.0, +// bin/droid, its bundled model registry): the picker order, the context +// helpers, and the entries of the models new since 0.233.0. +var y=["auto","auto-fast","claude-fable-5.1","claude-fable-5","claude-opus-5-5","claude-opus-5-5-fast","claude-opus-5","claude-opus-5-fast","claude-opus-4-8","claude-opus-4-8-fast","claude-opus-4-7","claude-opus-4-7-fast","claude-opus-4-6","claude-opus-4-6-fast","claude-opus-4-5-20251101","claude-sonnet-5-5","claude-sonnet-5","claude-sonnet-4-6","claude-sonnet-4-5-20250929","claude-haiku-5-5","claude-haiku-4-5-20251001","gpt-6.1-sol","gpt-6-astra","gpt-6-astra-ultrafast","gpt-6-sol","gpt-6-luna","gpt-5.6-sol","gpt-5.6-sol-fast","gpt-5.6-terra","gpt-5.6-luna","gpt-5.5","gpt-5.5-fast","gpt-5.5-pro","gpt-5.4","gpt-5.4-fast","gpt-5.4-mini","gpt-5.4-mini-fast","gpt-5.3-codex","gpt-5.3-codex-fast","gpt-5.2","garnet-07-15","gemini-3.1-pro-preview","gemini-3.8-flash","gemini-3.7-flash","gemini-3.6-flash","gemini-3.5-flash","gemini-3-flash-preview","inkling","mistral-large-4","mistral-medium-3.5","glm-5.3-flash","glm-5.3","glm-5.2","glm-5.2-fast","kimi-k3","qwen3.8-max","nemotron-3-ultra","deepseek-v4.1-flash","deepseek-v4-flash-0731","deepseek-v4-pro","minimax-m3","grok-4.7","grok-4.6","grok-4.5","atlas-07-21","aster-07-15","minimax-m2.7","kimi-k2.5","gpt-5.2-codex","glm-5.1","glm-5","glm-4.7","gpt-5.1-codex-max"]; +ce=te({thinkingConsumesContext:!1,maxInputTokens:872000,maxOutputTokens:128000}) +function P(o,t){return R({maxInputTokens:o-t,maxOutputTokens:t})} +"claude-haiku-5-5":{id:"claude-haiku-5-5",name:"Haiku 5.5",shortName:"Haiku 5.5",provider:"anthropic",apiProviders:X,apiProviderConfig:{anthropic:{modelId:"claude-haiku-5-5"},vertex_anthropic:{modelId:"claude-haiku-5-5"},bedrock_anthropic:{modelId:"anthropic.claude-haiku-5-5"},azure_anthropic:{modelId:"claude-haiku-5-5"}},routingConfig:g.HAIKU_5_5,featureFlag:J.ClaudeHaiku55,reasoningEffort:{supported:["off","low","medium","high","xhigh","max"],default:"medium"},tier:"standard",pdf:!0,contextLimits:ce,thinking:(o)=>U(o,!0),compactThroughLatestSignedThinking:!0,supportsMidConversationToolChanges:!0,supportsMidConversationEffortChanges:!0,disabledForPilots:!1,cost:{tokenMultiplier:0.04,outputTokenMultiplier:5},matchPatterns:[/haiku[^a-z0-9]*5[.-]?5/i,/claude-haiku-5-5/i],newUntil:new Date("2026-10-12T00:00:00Z")} +"mistral-large-4":{id:"mistral-large-4",name:"Mistral Large 4",shortName:"Mistral Large 4",provider:"factory",apiModelProvider:"generic-chat-completion-api",apiProviders:["mistral"],apiProviderConfig:{mistral:{...Tt,modelId:"mistral-large-4"}},reasoningEffort:{supported:["off","high"],default:"high"},chatCompletionRequest:We(),tier:"standard",billingPool:"core",featureFlag:J.MistralLarge4,images:!0,pdf:!1,contextLimits:R({maxInputTokens:524288,maxOutputTokens:64000}),disabledForPilots:!1,cost:{tokenMultiplier:0.544,cacheReadTokenMultiplier:0.103,outputTokenMultiplier:3.08,promotions:[{discount:0.5,startsAt:new Date("2026-10-06T00:00:00Z"),expiresAt:new Date("2026-10-20T00:00:00Z"),label:"50% off, launch discount"}]},usesUSBasedInference:!1,regionOverrides:{eu:{apiProviders:["mistral"]},us:S},matchPatterns:[/mistral[^a-z0-9]*large[^a-z0-9]*4(?![.\d])/i],newUntil:new Date("2026-10-11T00:00:00Z")} +"gpt-6-astra-ultrafast":{id:"gpt-6-astra-ultrafast",name:"GPT-6 Astra Ultra Fast",shortName:"GPT-6 Astra Ultra Fast",provider:"openai",systemPromptReminders:["astra-autonomy"],apiProviders:["openai"],apiProviderConfig:{openai:{modelId:"gpt-6-astra"}},reasoningEffort:{supported:["low","medium","high","xhigh","max"],default:"medium"},tier:"premium",featureFlag:J.Gpt6AstraUltrafast,explicitOptInRequirement:{kind:"high_cost",modelFamily:"gpt-6-astra-ultrafast",tosVersion:gse},pdf:!0,supportsVerbosity:!0,supportsMidConversationToolChanges:!0,contextLimits:M,apiRequest:xi,disabledForPilots:!0,cost:{tokenMultiplier:24,outputTokenMultiplier:5},regionOverrides:{eu:{apiProviders:[]}},matchPatterns:[/gpt[^a-z0-9]*6[^a-z0-9]*astra[^a-z0-9]*ultra[^a-z0-9]*fast/i],newUntil:new Date("2026-10-05T00:00:00Z")}