Files
magpie/internal/provider/factory_models_test.go
T
yetone 0337ce4bc7 factory: Haiku 5.5 and Mistral Large 4, in droid 0.240.0's picker, are offered, and moved users get plugin 0.1.25 (JL on Discord)
JL (Windows, droid 0.240.0, Factory desktop 0.197.1, magpie 0.1.1226,
opencode-factory-auth 0.1.24): droid and Factory desktop offer
claude-haiku-5-5; droid through magpie couldn't pick it.

droid's models are the registry bundled in its npm binary
(@factory/cli-<platform> 0.240.0, bin/droid). Against 0.233.0's registry,
0.240.0 adds claude-haiku-5-5, mistral-large-4 and gpt-6-astra-ultrafast.
The plugin (magpie-community/plugins e4023d9, published as 0.1.25, npm view
checked) now offers Haiku 5.5 (Anthropic Messages, 872000/128000, efforts
low..max) and Mistral Large 4 (chat completions, x-api-provider mistral,
Droid Core, 524288/64000, images). GPT-6 Astra Ultra Fast stays out: droid
offers it only once the user accepts Factory's high-cost terms.

- migrate_factory.go: the mover's min is 0.1.25, so keepMovedCurrent
  updates moved users (JL is on the plugin).
- factory.go: the built-in had the same gap; its table gets the same two
  rows for users who haven't moved.
- factory_pool_rest_test.go: the plugin's Core list, copied from its
  usage, gains Mistral Large 4.
- TestFactoryDroid0240Models is new; its fixture is droid 0.240.0's
  registry bytes (the same as the plugin's models.test.mjs). It fails with
  the Haiku 5.5 row removed.

Run, under a temp HOME: go test -tags nogui ./... with the machine at load
35-190 (other sessions). Every package passed except five that hit the
10m timeout mid-test (agent, gateway, library, plugin, provider, in
tests that don't touch Factory). Rerun with -timeout 40m: provider ok;
gateway still timed out at load ~130 (TestCodexHeardWithinItsIdleTimeout
failed on its timing, unrelated); -run 'Factory|Moved' on gateway ok.
agent, library and plugin were not rerun to the end; this change
doesn't touch them. gofmt -l clean; GOOS=linux and GOOS=windows go vet
-tags nogui on internal/provider and internal/gateway ok.
Not tried against Factory itself (no Factory account here); droid was read,
not run.
2026-10-14 05:11:19 +08:00

79 lines
2.8 KiB
Go

// 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")
}
}