Files
magpie/internal/provider/migrate_factory.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

68 lines
3.9 KiB
Go

package provider
import (
"encoding/json"
"errors"
"time"
)
// Factory's accounts on @magpie-community/opencode-factory-auth, as its
// device sign-in keeps one: the WorkOS pair as access and refresh (the
// refresh token rotates, so it moves rather than being copied), the org
// and region droid needs beside them.
func init() {
movers["factory"] = &mover{
pkg: "@magpie-community/opencode-factory-auth",
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()
// no refresh of the built-in's runs while the pairs are read
factoryMu.Lock()
defer factoryMu.Unlock()
var out []Moving
for _, l := range ls {
c := l.creds
out = append(out, Moving{User: l.User, First: l.Active, On: l.On, Lapsed: l.Lapsed != "", Plan: l.Plan, Auth: map[string]any{
"type": "oauth",
"access": c.Access,
"refresh": c.Refresh,
"expires": c.ExpiresAt,
"orgId": c.Org,
"email": c.Email,
"userId": c.UserID,
"activeOrganizationId": c.Active,
"region": c.Region,
"premBaseHost": c.Prem,
"accountId": l.User,
}})
}
return out, nil
},
back: func(ls []savedLogin, user string, auth map[string]any) ([]savedLogin, string, error) {
access := str(auth["access"])
if access == "" {
return ls, "", errors.New("Factory: an unreadable plugin sign-in")
}
if user == "" {
user = firstNonEmpty(str(auth["accountId"]), str(auth["email"]), str(auth["userId"]))
}
i := backInto(&ls, "factory", user)
c, _ := factorySaved(ls[i])
c.Access, c.Refresh, c.ExpiresAt = access, str(auth["refresh"]), num(auth["expires"])
c.Org = firstNonEmpty(str(auth["orgId"]), c.Org)
c.Active = firstNonEmpty(str(auth["activeOrganizationId"]), c.Active)
c.Email = firstNonEmpty(str(auth["email"]), c.Email)
c.UserID = firstNonEmpty(str(auth["userId"]), c.UserID)
c.Region = firstNonEmpty(str(auth["region"]), c.Region)
c.Prem = firstNonEmpty(str(auth["premBaseHost"]), c.Prem)
b, err := json.Marshal(c)
if err != nil {
return ls, "", err
}
ls[i].Auth, ls[i].Lapsed, ls[i].Seen = b, "", time.Now().UTC().Truncate(time.Second)
return ls, ls[i].User, nil
},
}
}