mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-04 07:33:18 +00:00
OpenCode v2 keeps its credentials in its own database and no longer writes the v1 credential file. The Codex usage source only knew the v1 stores, so on a v2 host it kept reporting the last file login it ever saw, with that file's expiry date, instead of the ChatGPT login the host actually uses. Read the active OpenAI credential from the OpenCode v2 database when it holds one, and keep the v1 file as the source for installations without that database. The database wins when both exist, because the file login is the one that goes stale. Report the v2 store with the same OpenCode harness and refresh command as the v1 file store, so a rejected or expired login still names opencode. Cover discovery, store precedence, expiry, token rotation and read-only access with tests against real temporary SQLite databases. Related to getpaseo/paseo#8645
22 lines
612 B
TypeScript
22 lines
612 B
TypeScript
import { z } from "zod";
|
|
|
|
export const routeSchema = z.discriminatedUnion("store", [
|
|
z.object({ store: z.enum(["codex", "opencode", "pi"]), path: z.string().min(1) }).strict(),
|
|
z
|
|
.object({
|
|
store: z.literal("opencode-db"),
|
|
path: z.string().min(1),
|
|
credentialId: z.string().min(1),
|
|
})
|
|
.strict(),
|
|
z
|
|
.object({
|
|
store: z.literal("omp"),
|
|
path: z.string().min(1),
|
|
credentialId: z.number().int().positive(),
|
|
})
|
|
.strict(),
|
|
]);
|
|
export const inputSchema = z.object({ route: routeSchema }).strict();
|
|
export type CodexUsageInput = z.infer<typeof inputSchema>;
|