Format reorganized provider modules

Co-authored-by: Simon Shi <simonsmh@users.noreply.github.com>
This commit is contained in:
Cursor Agent
2026-08-31 17:11:43 +00:00
co-authored by Simon Shi
parent 9d88e995ee
commit 11249d12c4
7 changed files with 11 additions and 26 deletions
+1 -1
View File
@@ -2,9 +2,9 @@ import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { homedir } from "node:os";
import { join } from "node:path";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { updateQoderModelsCache } from "../catalog.js";
import { autoLoginQoderFromEnvironment, getCachedCredentials, getQoderPatForMode } from "../auth/oauth.js";
import { credentialsFromPat } from "../auth/pat.js";
import { updateQoderModelsCache } from "../catalog.js";
import { loadLiveFixture } from "./live-fixture.js";
const AUTH_FILE = join(homedir(), ".pi", "agent", "auth.json");
+1 -4
View File
@@ -43,10 +43,7 @@ function parseExpiresAt(s?: string, expiresInSeconds?: number): number {
return Date.now() + 30 * 24 * 60 * 60 * 1000; // default 30 days
}
export async function interactiveLogin(
callbacks: OAuthLoginCallbacks,
mode: QoderMode,
): Promise<OAuthCredentials> {
export async function interactiveLogin(callbacks: OAuthLoginCallbacks, mode: QoderMode): Promise<OAuthCredentials> {
const region = getQoderRegionConfig(mode);
// pi drives this via its built-in LoginDialog, which wires onPrompt/onAuth/
// onProgress to a focused input. We must use those callbacks directly rather
+1 -1
View File
@@ -3,8 +3,8 @@ import { homedir } from "node:os";
import { dirname, join } from "node:path";
import type { OAuthCredentials, OAuthLoginCallbacks } from "@earendil-works/pi-ai";
import * as PiCodingAgent from "@earendil-works/pi-coding-agent";
import { getMachineId } from "../cosy.js";
import { updateQoderModelsCache } from "../catalog.js";
import { getMachineId } from "../cosy.js";
import { getQoderRefreshURL, getQoderRegionConfig, type QoderMode } from "../region.js";
import { interactiveLogin } from "./login.js";
import { credentialsFromPat, decodePatRefresh, fetchUserInfo, isPatRefresh } from "./pat.js";
+1 -6
View File
@@ -1,11 +1,6 @@
import type { OAuthCredentials } from "@earendil-works/pi-ai";
import { getMachineId, QODER_CLIENT_TYPE, QODER_OPENAPI_COSY_VERSION } from "../cosy.js";
import {
getQoderExchangeURL,
getQoderRegionConfig,
getQoderUserInfoURL,
type QoderMode,
} from "../region.js";
import { getQoderExchangeURL, getQoderRegionConfig, getQoderUserInfoURL, type QoderMode } from "../region.js";
const UA = "pi-provider-qoder";
+2 -9
View File
@@ -3,12 +3,7 @@ import { homedir } from "node:os";
import { dirname, join } from "node:path";
import type { ThinkingLevel, ThinkingLevelMap } from "@earendil-works/pi-ai";
import { buildAuthHeaders } from "./cosy.js";
import {
getQoderBaseUrl,
getQoderModelListURL,
getQoderRegionConfig,
type QoderMode,
} from "./region.js";
import { getQoderBaseUrl, getQoderModelListURL, getQoderRegionConfig, type QoderMode } from "./region.js";
export const ZERO_COST = Object.freeze({ input: 0, output: 0, cacheRead: 0, cacheWrite: 0 });
@@ -525,9 +520,7 @@ export function getCachedModelConfig(modelId: string, mode: QoderMode): QoderMod
// Read old cache shapes without preserving their raw-key aliases.
const legacyEntry = Object.values(data?.configs || {}).find(
(entry) =>
entry &&
typeof entry === "object" &&
toQoderModelId((entry as QoderModelEntry).display_name) === modelId,
entry && typeof entry === "object" && toQoderModelId((entry as QoderModelEntry).display_name) === modelId,
) as QoderModelEntry | undefined;
if (legacyEntry) {
return withMaxContextAsDefault(legacyEntry);
+3 -3
View File
@@ -1,15 +1,15 @@
import type { Api, Model, OAuthCredentials } from "@earendil-works/pi-ai";
import type { ExtensionAPI, ProviderConfig } from "@earendil-works/pi-coding-agent";
import { getCachedModels, isCacheStale, staticCnModels, staticModels, updateQoderModelsCache } from "./catalog.js";
import { getQoderBaseUrl, getQoderRegionConfig, QODER_MODES, type QoderMode } from "./region.js";
import {
autoLoginQoderFromEnvironment,
getCachedCredentials,
loginQoderForMode,
refreshQoderTokenForMode,
} from "./auth/oauth.js";
import { streamQoder } from "./protocol/stream.js";
import { fetchQoderUsageForMode } from "./auth/usage.js";
import { getCachedModels, isCacheStale, staticCnModels, staticModels, updateQoderModelsCache } from "./catalog.js";
import { streamQoder } from "./protocol/stream.js";
import { getQoderBaseUrl, getQoderRegionConfig, QODER_MODES, type QoderMode } from "./region.js";
// pi supports a `fetchUsage` hook on the oauth config at runtime, but it is not
// part of the published ProviderConfig type. Declare the extension locally.
+2 -2
View File
@@ -12,9 +12,9 @@ import {
type ThinkingContent,
type ToolCall,
} from "@earendil-works/pi-ai";
import { buildAuthHeaders, getMachineId } from "../cosy.js";
import { getCachedModelConfig, MAX_OUTPUT_TOKENS } from "../catalog.js";
import { resolveQoderIdentity } from "../auth/oauth.js";
import { getCachedModelConfig, MAX_OUTPUT_TOKENS } from "../catalog.js";
import { buildAuthHeaders, getMachineId } from "../cosy.js";
import { getQoderChatURL, getQoderRegionConfig } from "../region.js";
import { qoderEncodeBody } from "./encoding.js";
import { stripThinkingTags, ThinkingTagParser } from "./thinking.js";