@oriro/orirocli 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +35 -5
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1798,6 +1798,9 @@ function useRouters(ids) {
|
|
|
1798
1798
|
if (applied.length > 0) savePool(oriroDir(), applied);
|
|
1799
1799
|
return { applied, unknown };
|
|
1800
1800
|
}
|
|
1801
|
+
function registeredRouters() {
|
|
1802
|
+
return Object.values(readReg());
|
|
1803
|
+
}
|
|
1801
1804
|
function resolvePool() {
|
|
1802
1805
|
const reg = readReg();
|
|
1803
1806
|
return loadPool(oriroDir()).map((id) => reg[id]).filter((r) => Boolean(r));
|
|
@@ -3759,15 +3762,42 @@ function registerRoutersCommand(program2) {
|
|
|
3759
3762
|
process.stdout.write(` ${accent(r.id.padEnd(22))} ${r.displayName.padEnd(24)} ${tier}
|
|
3760
3763
|
`);
|
|
3761
3764
|
}
|
|
3765
|
+
const custom = registeredRouters().filter((r) => !ROUTER_CATALOG.some((c) => c.id === r.id));
|
|
3766
|
+
if (custom.length) {
|
|
3767
|
+
process.stdout.write(`
|
|
3768
|
+
${accent("your custom routers")}
|
|
3769
|
+
`);
|
|
3770
|
+
for (const r of custom) {
|
|
3771
|
+
const type = r.apiKey && r.apiKey !== KEYLESS_SENTINEL ? dim("BYOK") : fgHex(PALETTE.success, "keyless");
|
|
3772
|
+
process.stdout.write(` ${accent(r.id.padEnd(22))} ${dim(r.baseUrl.padEnd(40))} ${type}
|
|
3773
|
+
`);
|
|
3774
|
+
}
|
|
3775
|
+
}
|
|
3762
3776
|
const pool = resolvePool();
|
|
3763
3777
|
info(pool.length ? `active pool: ${pool.map((p) => p.id).join(", ")}` : "active pool: empty \u2192 using the keyless floor");
|
|
3764
3778
|
});
|
|
3765
|
-
routers.command("add <
|
|
3766
|
-
|
|
3767
|
-
if (
|
|
3779
|
+
routers.command("add <name>").description("live-validate a router and add it to the pool \u2014 a catalog name, OR any custom endpoint via --url").option("-k, --key <key>", "API key (BYOK) \u2014 omit for a keyless free router").option("-m, --model <id>", "model id to run (REQUIRED for a custom --url router)").option("--url <baseUrl>", "add ANY custom free/BYOK router by its OpenAI-compatible base URL (the part BEFORE /chat/completions)").option("--api <api>", "custom router API: 'openai' (default) or 'google'", "openai").action(async (name, opts) => {
|
|
3780
|
+
let entry;
|
|
3781
|
+
if (opts.url) {
|
|
3782
|
+
if (!opts.model) die("a custom --url router needs --model <id> (the model to run on that endpoint)");
|
|
3783
|
+
const baseUrl = opts.url.replace(/\/(?:chat\/completions)\/?$/i, "").replace(/\/$/, "");
|
|
3784
|
+
entry = {
|
|
3785
|
+
id: name,
|
|
3786
|
+
displayName: name,
|
|
3787
|
+
baseUrl,
|
|
3788
|
+
api: opts.api === "google" ? "google-generative-ai" : "openai-completions",
|
|
3789
|
+
freeModels: [opts.model],
|
|
3790
|
+
keyless: !opts.key,
|
|
3791
|
+
tier: "free",
|
|
3792
|
+
kind: "chat"
|
|
3793
|
+
};
|
|
3794
|
+
} else {
|
|
3795
|
+
entry = routerById(name);
|
|
3796
|
+
if (!entry) die(`unknown router '${name}' \u2014 run \`oriro routers list\`, or add any custom endpoint with: oriro routers add <name> --url <baseUrl> --model <id> [--key <key>]`);
|
|
3797
|
+
}
|
|
3768
3798
|
const res = await addRouter(entry, { ...opts.key ? { key: opts.key } : {}, ...opts.model ? { modelId: opts.model } : {} });
|
|
3769
|
-
if (!res.ok) die(`could not add '${
|
|
3770
|
-
ok(`added ${accent(
|
|
3799
|
+
if (!res.ok) die(`could not add '${name}': ${res.validation.error ?? "validation failed"}`);
|
|
3800
|
+
ok(`added ${accent(name)} (${res.validation.latencyMs}ms, model ${res.validation.model}${opts.key ? ", BYOK" : ", keyless"}) \u2192 active pool`);
|
|
3771
3801
|
});
|
|
3772
3802
|
routers.command("use <slugs...>").description("set the active router pool (ids must be added first)").action((slugs) => {
|
|
3773
3803
|
const { applied, unknown } = useRouters(slugs);
|