A self-improving RLM agent for coding workflows and long-running autonomous tasks.
Rust
prioritize prime inference in login (#386)
kt84d7825e65e0
diff --git a/packages/coding-agent/test/oauth-selector.test.ts b/packages/coding-agent/test/oauth-selector.test.tsindex e5e6e7be0f..fbce958bdd 100644--- a/packages/coding-agent/test/oauth-selector.test.ts+++ b/packages/coding-agent/test/oauth-selector.test.ts@@ -1,7 +1,7 @@import { setKeybindings } from "@earendil-works/pi-tui";import stripAnsi from "strip-ansi";import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";-import { AuthStorage } from "../src/core/auth-storage.js";+import { type AuthStatus, AuthStorage } from "../src/core/auth-storage.js";import { KeybindingsManager } from "../src/core/keybindings.js";import { PRIME_INFERENCE_PROVIDER_ID } from "../src/core/prime-inference-auth.js";import { BUILT_IN_PROVIDER_DISPLAY_NAMES } from "../src/core/provider-display-names.js";@@ -60,20 +60,40 @@ describe("OAuthSelectorComponent", () => {]);});- it("puts Prime Inference first within the same authentication state", () => {- const selector = new OAuthSelectorComponent(- "login",- AuthStorage.inMemory(),- [- { id: "anthropic", name: "Anthropic", authType: "api_key" },- { id: PRIME_INFERENCE_PROVIDER_ID, name: "Prime Inference", authType: "api_key" },- ],- () => {},- () => {},- );-- const output = stripAnsi(selector.render(120).join("\n"));- expect(output.indexOf("Prime Inference")).toBeLessThan(output.indexOf("Anthropic"));+ it("sorts Prime Inference first within every login auth-state group", () => {+ const cases: Array<{ status: AuthStatus; configuredProviderLeads: boolean }> = [+ { status: { configured: true, source: "environment" }, configuredProviderLeads: false },+ { status: { configured: false, source: "stale", label: "expired" }, configuredProviderLeads: true },+ { status: { configured: false }, configuredProviderLeads: true },+ ];++ for (const { status, configuredProviderLeads } of cases) {+ const selector = new OAuthSelectorComponent(+ "login",+ AuthStorage.inMemory(),+ [+ { id: "anthropic", name: "Anthropic", authType: "api_key" },+ { id: PRIME_INFERENCE_PROVIDER_ID, name: "Prime Inference", authType: "api_key" },+ { id: "openai", name: "OpenAI", authType: "api_key" },+ ],+ () => {},+ () => {},+ (providerId) =>+ providerId === "openai" ? { configured: true, source: "environment", label: "OPENAI_API_KEY" } : status,+ );++ const output = stripAnsi(selector.render(120).join("\n"));+ const primeIndex = output.indexOf("Prime Inference");+ const anthropicIndex = output.indexOf("Anthropic");+ const openAiIndex = output.indexOf("OpenAI");++ expect(primeIndex).toBeLessThan(anthropicIndex);+ if (configuredProviderLeads) {+ expect(openAiIndex).toBeLessThan(primeIndex);+ } else {+ expect(primeIndex).toBeLessThan(openAiIndex);+ }+ }});it("preserves auth type when selecting duplicate provider ids", () => {