Accept lowercase profile types and anchor sides when reading
This commit is contained in:
@@ -78,6 +78,17 @@ export async function encryptCredential(
|
||||
return `v1:${encodeBase64Url(nonce)}:${encodeBase64Url(new Uint8Array(ciphertext))}`;
|
||||
}
|
||||
|
||||
// profiles.json files written before the UPPER_SNAKE switch spell types in lowercase.
|
||||
const OLD_PROFILE_TYPES = new Map<unknown, BotProfile["type"]>([
|
||||
["claude", "CLAUDE"],
|
||||
["codex", "CODEX"],
|
||||
["opencode", "OPENCODE"],
|
||||
]);
|
||||
|
||||
function currentSpelling(type: unknown): unknown {
|
||||
return OLD_PROFILE_TYPES.get(type) ?? type;
|
||||
}
|
||||
|
||||
async function parseProfile(entry: unknown, index: number, masterKey: string): Promise<BotProfile> {
|
||||
const at = `profiles[${index}]`;
|
||||
if (!isMapping(entry)) {
|
||||
@@ -88,7 +99,7 @@ async function parseProfile(entry: unknown, index: number, masterKey: string): P
|
||||
throw new Error(`${at}.${key}: unknown field`);
|
||||
}
|
||||
}
|
||||
const type = field(entry, "type");
|
||||
const type = currentSpelling(field(entry, "type"));
|
||||
const model = field(entry, "model");
|
||||
const token = field(entry, "token");
|
||||
if (type !== "CLAUDE" && type !== "CODEX" && type !== "OPENCODE") {
|
||||
|
||||
Reference in New Issue
Block a user