providers: a subscription whose models come from its own CLI (Kiro, Devin, Cursor …) has no host, so magpie provider models said its models were fetched "from" nothing; it names the provider. Kiro signed in with Google or GitHub says so, not SocialGoogle. Checked against a real Kiro account: plain and streamed text, a tool call and its result, OpenAI chat with another model, and Claude Code reading a file through Kiro
This commit is contained in:
@@ -157,6 +157,10 @@ func parseKiroWhoami(b []byte) (user, plan string, ok bool) {
|
||||
plan = "Builder ID"
|
||||
case "IamIdentityCenter":
|
||||
plan = "IAM Identity Center"
|
||||
case "SocialGoogle":
|
||||
plan = "Google"
|
||||
case "SocialGithub", "SocialGitHub":
|
||||
plan = "GitHub"
|
||||
default:
|
||||
plan = w.AccountType
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ func TestParseKiroWhoami(t *testing.T) {
|
||||
{`{"account":null}`, "", "", false},
|
||||
{`{"accountType":"ApiKey","email":null}`, "Kiro api key", "API key", true},
|
||||
{`{"accountType":"BuilderId","email":"me@example.com"}`, "me@example.com", "Builder ID", true},
|
||||
{`{"accountType":"SocialGoogle","email":"me@example.com"}`, "me@example.com", "Google", true},
|
||||
{`{"accountType":"IamIdentityCenter","email":"me@corp.example","startUrl":"https://corp.awsapps.com/start"}`, "me@corp.example", "IAM Identity Center", true},
|
||||
{``, "", "", false},
|
||||
{`error`, "", "", false},
|
||||
|
||||
+13
-3
@@ -413,7 +413,7 @@ func providerCmd(args []string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(green.Render("✓"), len(ms), "models from", p.Host())
|
||||
fmt.Println(green.Render("✓"), len(ms), "models from", fetchedFrom(*p))
|
||||
return showProvider(*p)
|
||||
}
|
||||
// `magpie provider <id>`
|
||||
@@ -484,7 +484,7 @@ func announce(id string) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
defer cancel()
|
||||
if ms, err := saved.Fetch(ctx); err == nil {
|
||||
fmt.Println(green.Render("✓"), len(ms), "models from", saved.Host())
|
||||
fmt.Println(green.Render("✓"), len(ms), "models from", fetchedFrom(*saved))
|
||||
}
|
||||
n := len(saved.Exposed())
|
||||
if n == 0 {
|
||||
@@ -545,7 +545,7 @@ func showProvider(p provider.Provider) error {
|
||||
ms := p.Exposed()
|
||||
src := "models.dev"
|
||||
if t, ok := p.Fetched(); ok {
|
||||
src = p.Host() + " · fetched " + ago(t)
|
||||
src = fetchedFrom(p) + " · fetched " + ago(t)
|
||||
}
|
||||
kv("models", fmt.Sprintf("%d exposed of %d %s", len(ms), len(p.Available()), muted.Render("from "+src)))
|
||||
names := p.ModelNames()
|
||||
@@ -769,3 +769,13 @@ func importCmd(args []string) error {
|
||||
}
|
||||
return saveNew(p)
|
||||
}
|
||||
|
||||
// fetchedFrom is where a provider's models were fetched: its API's host, or
|
||||
// for a subscription run through its own CLI (Kiro, Devin, Cursor …), which
|
||||
// has none, its name.
|
||||
func fetchedFrom(p provider.Provider) string {
|
||||
if h := p.Host(); h != "" {
|
||||
return h
|
||||
}
|
||||
return p.Name
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user