Modules/Taskboard/server/subrouter/token.mjs
Шурупов Илья Викторович 1bd22f1a8e Taskboard: Python task server and skills
2026-11-01 12:19:53 +03:00

19 lines
675 B
JavaScript

import { adapters, loadAccounts, updateAccount } from "@subrouter/cli";
const provider = "anthropic";
const file = await loadAccounts();
const pool = file.providers?.[provider];
const account = pool?.accounts?.[pool.activeIndex ?? 0];
if (!account) {
process.stderr.write("subrouter has no anthropic account; run: npx @subrouter/cli login anthropic\n");
process.exit(1);
}
const match = { ...account };
const persist = (update) => updateAccount({ provider, match, update });
const token = await adapters.anthropic.getApiKey({ account, persist });
if (token instanceof Error) {
process.stderr.write(`${token.message}\n`);
process.exit(1);
}
process.stdout.write(token);