diff --git a/internal/plugin/host.js b/internal/plugin/host.js index 4902ccfe0..62ac23b46 100644 --- a/internal/plugin/host.js +++ b/internal/plugin/host.js @@ -3168,7 +3168,12 @@ async function load({ provider, account, proxy }) { // "credits"), span? (seconds the window runs), model? (a // word in the ids of the only models it counts), models? / notModels? // (the ids it counts, or all but these; a bare id and its id@size -// count as one), aside? (using it up doesn't +// count as one), family? (the model family a model's own window +// belongs to: "Gemini"), pool? (the group of models sharing one +// allowance: "Gemini", "Claude & GPT"; on the group's own windows, +// with no family, and on each of its models' — the GUI shows the +// group's windows in place of its models', as for magpie's built-in +// Antigravity), aside? (using it up doesn't // stop the account), runsOutAt? (ISO or ms: when the soonest // credits left in it are lost, apart from its reset, as WorkBuddy's // packages end) / runsOut? (how many are lost then), balance? @@ -3235,6 +3240,8 @@ async function usageOf(provider, account, signal) { model: text(w?.model), models: ids(w?.models), notModels: ids(w?.notModels), + family: text(w?.family), + pool: text(w?.pool), aside: !!w?.aside, runsOutAt: when(w?.runsOutAt), runsOut: Math.max(0, num(w?.runsOut)), diff --git a/internal/provider/plugin_usage_pool_host_test.go b/internal/provider/plugin_usage_pool_host_test.go new file mode 100644 index 000000000..3430f1de5 --- /dev/null +++ b/internal/provider/plugin_usage_pool_host_test.go @@ -0,0 +1,57 @@ +package provider + +import ( + "os" + "path/filepath" + "slices" + "testing" +) + +// plugins#935 (mk311): the Antigravity plugin groups its models' windows +// into the pools they share ("Gemini", "Claude & GPT"), as the built-in +// did, but host.js passed neither a window's family nor its pool on (the +// Go side, quotaOfPlugin, already read them: TestPluginWindowsKeepPoolAndFamily +// hands it a plugin.Usage past the host), so the card showed every +// model's window and two "7 days" with no pool named. testdata/antigravity-plugin-usage-935.json is what the plugin +// (0.1.0) sends for the reporter's figures: each Gemini model 85.1% left +// resetting at 20:31 +08, Claude and GPT-OSS 100% resetting 11-11 00:24:47 +// +08, and a 7 days at 91.8% left. Through the host, the card is each +// pool's 5 hours and 7 days in place of its models'. +func TestPluginAntigravityPoolsReachTheCard(t *testing.T) { + ws, err := os.ReadFile("testdata/antigravity-plugin-usage-935.json") + if err != nil { + t.Fatal(err) + } + windows := filepath.Join(t.TempDir(), "windows.json") + if err := os.WriteFile(windows, []byte(`{"a@fake": `+string(ws)+`}`), 0o600); err != nil { + t.Fatal(err) + } + q := fakePluginUsage(t, windows)["a@fake"] + if len(q.Windows) != 17 { + t.Fatalf("windows: %d, want 17: %+v", len(q.Windows), q.Windows) + } + for _, w := range q.Windows { + if w.Pool == "" { + t.Errorf("%q has no pool", w.Name) + } + if (w.Model != "") != (w.Family != "") { + t.Errorf("%q: model %q, family %q", w.Name, w.Model, w.Family) + } + } + var lines []string + for _, w := range PooledWindows(q.Windows) { + lines = append(lines, w.Name) + } + want := []string{"Gemini · 7 days", "Gemini · 5 hours", "Claude & GPT · 7 days", "Claude & GPT · 5 hours"} + if !slices.Equal(lines, want) { + t.Errorf("the card's lines: %q, want %q", lines, want) + } + // the Claude & GPT pool's windows hold its models, and only them + for _, w := range q.Windows { + if w.PoolWindow() && w.Pool == "Claude & GPT" { + if !w.CountsIn(q.Windows, "gpt-oss-120b-medium") || !w.CountsIn(q.Windows, "claude-opus-4-6-thinking") || w.CountsIn(q.Windows, "gemini-3.8-flash") { + t.Errorf("%s counts the wrong models", w.LineName()) + } + } + } +} diff --git a/internal/provider/testdata/antigravity-plugin-usage-935.json b/internal/provider/testdata/antigravity-plugin-usage-935.json new file mode 100644 index 000000000..59b4a18bb --- /dev/null +++ b/internal/provider/testdata/antigravity-plugin-usage-935.json @@ -0,0 +1 @@ +[{"name":"Claude Opus 4.6 (Thinking)","used":0,"model":"claude-opus-4-6-thinking","family":"Claude","models":["claude-opus-4-6-thinking"],"resetsAt":"2026-11-10T16:24:47Z","pool":"Claude & GPT"},{"name":"Claude Sonnet 4.6 (Thinking)","used":0,"model":"claude-sonnet-4-6-thinking","family":"Claude","models":["claude-sonnet-4-6-thinking"],"resetsAt":"2026-11-10T16:24:47Z","pool":"Claude & GPT"},{"name":"gemini-2.5-flash","used":14.900000000000002,"model":"gemini-2.5-flash","family":"Gemini","models":["gemini-2.5-flash"],"resetsAt":"2026-11-10T12:31:00Z","pool":"Gemini"},{"name":"gemini-2.5-flash-lite","used":14.900000000000002,"model":"gemini-2.5-flash-lite","family":"Gemini","models":["gemini-2.5-flash-lite"],"resetsAt":"2026-11-10T12:31:00Z","pool":"Gemini"},{"name":"Gemini 3 Flash","used":14.900000000000002,"model":"gemini-3-flash","family":"Gemini","models":["gemini-3-flash"],"resetsAt":"2026-11-10T12:31:00Z","pool":"Gemini"},{"name":"Gemini 3.1 Flash Image","used":14.900000000000002,"model":"gemini-3.1-flash-image","family":"Gemini","models":["gemini-3.1-flash-image"],"resetsAt":"2026-11-10T12:31:00Z","pool":"Gemini"},{"name":"Gemini 3.1 Flash Lite","used":14.900000000000002,"model":"gemini-3.1-flash-lite","family":"Gemini","models":["gemini-3.1-flash-lite"],"resetsAt":"2026-11-10T12:31:00Z","pool":"Gemini"},{"name":"Gemini 3.5 Flash Lite","used":14.900000000000002,"model":"gemini-3.5-flash-lite","family":"Gemini","models":["gemini-3.5-flash-lite"],"resetsAt":"2026-11-10T12:31:00Z","pool":"Gemini"},{"name":"Gemini 3.8 Flash (High)","used":14.900000000000002,"model":"gemini-3.8-flash-high","family":"Gemini","models":["gemini-3.8-flash-high","gemini-3.8-flash"],"resetsAt":"2026-11-10T12:31:00Z","pool":"Gemini"},{"name":"Gemini 3.8 Flash (Low)","used":14.900000000000002,"model":"gemini-3.8-flash-low","family":"Gemini","models":["gemini-3.8-flash-low","gemini-3.8-flash"],"resetsAt":"2026-11-10T12:31:00Z","pool":"Gemini"},{"name":"Gemini 3.8 Flash (Medium)","used":14.900000000000002,"model":"gemini-3.8-flash-medium","family":"Gemini","models":["gemini-3.8-flash-medium","gemini-3.8-flash"],"resetsAt":"2026-11-10T12:31:00Z","pool":"Gemini"},{"name":"gemini-3.8-flash-tiered","used":14.900000000000002,"model":"gemini-3.8-flash-tiered","family":"Gemini","models":["gemini-3.8-flash-tiered"],"resetsAt":"2026-11-10T12:31:00Z","pool":"Gemini"},{"name":"GPT-OSS 120B (Medium)","used":0,"model":"gpt-oss-120b-medium","family":"GPT-OSS","models":["gpt-oss-120b-medium"],"resetsAt":"2026-11-10T16:24:47Z","pool":"Claude & GPT"},{"name":"7 days","pool":"Gemini","used":8.199999999999996,"aside":true,"span":604800,"resetsAt":"2026-11-15T00:00:00Z"},{"name":"5 hours","pool":"Gemini","used":14.900000000000002,"aside":true,"span":18000,"resetsAt":"2026-11-10T12:31:00Z"},{"name":"7 days","pool":"Claude & GPT","used":0,"aside":true,"span":604800,"resetsAt":"2026-11-17T11:30:00Z"},{"name":"5 hours","pool":"Claude & GPT","used":0,"aside":true,"span":18000,"resetsAt":"2026-11-10T16:24:47Z"}] diff --git a/site/public/docs/ja/plugins.html b/site/public/docs/ja/plugins.html index 1bbb0ccf4..6eb7ecc22 100644 --- a/site/public/docs/ja/plugins.html +++ b/site/public/docs/ja/plugins.html @@ -554,6 +554,7 @@ magpie quota # acme · Pro · 5h 37% amount: 370, limit: 1000, unit: "credits", // its own count, when it counts amounts model: "opus", // counts only models whose ids hold this word models: [], notModels: [], // or exactly these ids, or all but these + family: "Gemini", pool: "Gemini", // a model's family, and the group sharing its allowance: the card shows a pool's own windows (no model, no family) in place of its models' aside: false, // true: using it up doesn't stop the account runsOutAt: "2026-10-05T00:00:00Z", runsOut: 120, // when the soonest credits left are lost, and how many balance: 6291, // a prepaid wallet: what is left, in unit; no used or limit diff --git a/site/public/docs/plugins.html b/site/public/docs/plugins.html index d606c0fff..f92bbeb57 100644 --- a/site/public/docs/plugins.html +++ b/site/public/docs/plugins.html @@ -554,6 +554,7 @@ magpie quota # acme · Pro · 5h 37% amount: 370, limit: 1000, unit: "credits", // its own count, when it counts amounts model: "opus", // counts only models whose ids hold this word models: [], notModels: [], // or exactly these ids, or all but these + family: "Gemini", pool: "Gemini", // a model's family, and the group sharing its allowance: the card shows a pool's own windows (no model, no family) in place of its models' aside: false, // true: using it up doesn't stop the account runsOutAt: "2026-10-05T00:00:00Z", runsOut: 120, // when the soonest credits left are lost, and how many balance: 6291, // a prepaid wallet: what is left, in unit; no used or limit diff --git a/site/public/docs/zh/plugins.html b/site/public/docs/zh/plugins.html index f816dce30..f73a70603 100644 --- a/site/public/docs/zh/plugins.html +++ b/site/public/docs/zh/plugins.html @@ -554,6 +554,7 @@ magpie quota # acme · Pro · 5h 37% amount: 370, limit: 1000, unit: "credits", // 按数量计时,窗口自己的用量 model: "opus", // 只统计 id 含这个词的模型 models: [], notModels: [], // 或恰好这些 id,或除这些外的全部 + family: "Gemini", pool: "Gemini", // 模型所属系列,和共用一份额度的分组:卡片显示分组自己的窗口(不带 model 和 family),代替其中各模型的 aside: false, // true:用完也不影响账号使用 runsOutAt: "2026-10-05T00:00:00Z", runsOut: 120, // 剩余额度中最早作废的一笔何时作废、作废多少 balance: 6291, // 预付钱包:剩余多少(按 unit 计),不写 used 和 limit diff --git a/site/public/llms-full.txt b/site/public/llms-full.txt index 53711c8a1..f5b888bb0 100644 --- a/site/public/llms-full.txt +++ b/site/public/llms-full.txt @@ -4245,6 +4245,7 @@ throw Object.assign(new Error("Acme refused the sign-in; sign in again"), { sign amount: 370, limit: 1000, unit: "credits", // its own count, when it counts amounts model: "opus", // counts only models whose ids hold this word models: [], notModels: [], // or exactly these ids, or all but these + family: "Gemini", pool: "Gemini", // a model's family, and the group sharing its allowance: the card shows a pool's own windows (no model, no family) in place of its models' aside: false, // true: using it up doesn't stop the account runsOutAt: "2026-10-05T00:00:00Z", runsOut: 120, // when the soonest credits left are lost, and how many balance: 6291, // a prepaid wallet: what is left, in unit; no used or limit