What a ported Antigravity needs from the host, kept generic:
- The gateway puts the request's reasoning effort on a plugin's fetch as
X-Magpie-Effort (provider.EffortHeader), so a plugin that serves one
model at several levels can pick the level. host.js strips it with the
other magpie-only headers, so the vendor never sees it.
- A plugin's usage window may name a Pool and a Family; quotaOfPlugin
passes them through, so PooledWindows names a shared pool
("Gemini · 7 days") as it does for the built-in.
Run (WSL magpie-desktop; mote unreachable, kex reset):
- TestPluginToldTheEffort: xhigh, low and none reach the plugin; the
vendor gets no X-Magpie-Effort. Red with the MAGPIE_ONLY entry removed
by hand (the vendor saw the header).
- TestPluginWindowsKeepPoolAndFamily, TestPluginToldTheSession: pass.
- Full suite: in the next commit's body (run at the head of both).
46 lines
1.8 KiB
Go
46 lines
1.8 KiB
Go
package provider
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/yetone/magpie/internal/plugin"
|
|
)
|
|
|
|
// A plugin's usage says the pool a window is of and the family a model's
|
|
// window belongs to, as Antigravity's plugin says them: the pool's own
|
|
// windows are pools (PoolWindow) holding the models put in them, and a page
|
|
// of text names them with their pool in place of the models' own, as the
|
|
// built-in's quota did.
|
|
func TestPluginWindowsKeepPoolAndFamily(t *testing.T) {
|
|
week := float64(7 * 24 * 3600)
|
|
q := quotaOfPlugin(SubscriptionQuota{Provider: "antigravity", User: "a@gmail.com"}, plugin.Usage{Windows: []plugin.UsageWindow{
|
|
{Name: "Gemini 3.8 Flash", Model: "gemini-3.8-flash", Family: "gemini", Pool: "Gemini", Used: fptr(20), Span: week},
|
|
{Name: "Claude Sonnet 4.6", Model: "claude-sonnet-4-6", Family: "claude", Used: fptr(5)},
|
|
{Name: "7 days", Pool: "Gemini", Used: fptr(20), Span: week, Aside: true},
|
|
}})
|
|
if len(q.Windows) != 3 {
|
|
t.Fatalf("windows %+v", q.Windows)
|
|
}
|
|
m, c, p := q.Windows[0], q.Windows[1], q.Windows[2]
|
|
if m.Pool != "Gemini" || m.Family != "gemini" || c.Pool != "" || c.Family != "claude" || p.Pool != "Gemini" || p.Family != "" {
|
|
t.Fatalf("pool/family %q/%q %q/%q %q/%q", m.Pool, m.Family, c.Pool, c.Family, p.Pool, p.Family)
|
|
}
|
|
if !p.PoolWindow() || m.PoolWindow() {
|
|
t.Fatalf("PoolWindow: pool %v, model %v", p.PoolWindow(), m.PoolWindow())
|
|
}
|
|
if ms := PoolMembers(q.Windows, p); len(ms) != 1 || ms[0].Model != "gemini-3.8-flash" {
|
|
t.Fatalf("members %+v", ms)
|
|
}
|
|
var names []string
|
|
for _, w := range PooledWindows(q.Windows) {
|
|
names = append(names, w.Name)
|
|
}
|
|
if len(names) != 2 || names[0] != "Claude Sonnet 4.6" || names[1] != "Gemini · 7 days" {
|
|
t.Fatalf("pooled %q", names)
|
|
}
|
|
if p.Span != 7*24*time.Hour {
|
|
t.Fatalf("span %v", p.Span)
|
|
}
|
|
}
|