refactor: drop redundant credentials cache and unused deps

- stream: passively rebuild stale/missing models cache on request
- oauth: read identity from pi's auth.json instead of self-managed cache
- deps: remove unused js-tiktoken; move esbuild to devDependencies
This commit is contained in:
Simon Shi
2026-06-16 13:38:55 +08:00
parent c9413961d2
commit 032cf51904
4 changed files with 56 additions and 38 deletions
+8 -1
View File
@@ -9,7 +9,7 @@ import type {
} from "@earendil-works/pi-ai";
import * as PiAi from "@earendil-works/pi-ai";
import { buildAuthHeaders, getMachineId } from "./cosy.js";
import { getCachedModelConfig } from "./models.js";
import { getCachedModelConfig, isCacheStale, updateQoderModelsCache } from "./models.js";
import { getCachedCredentials } from "./oauth.js";
import { qoderEncodeBody } from "./qoder-encoding.js";
import { ThinkingTagParser } from "./thinking-parser.js";
@@ -90,6 +90,13 @@ export function streamQoder(
const email = cachedCreds?.email || "user@qoder.com";
const machineID = cachedCreds?.machineID || getMachineId();
// Passively rebuild the models cache if it's missing or stale.
// Login/refresh are the only other rebuild triggers, so without this a
// deleted cache file never gets recreated while the token stays valid.
if (isCacheStale()) {
updateQoderModelsCache(accessToken, userID, name, email).catch(() => {});
}
const qoderModel = model.id;
const modelConfig = getCachedModelConfig(qoderModel) || {
key: qoderModel,