mirror of
https://github.com/Routstr/routstrd.git
synced 2026-10-06 04:38:23 +00:00
Problem 1 — config overridden on restart:
parseArgs() always returned port=8008 when --port was not passed on the
CLI. index.ts then spread { ...config, port, provider } and saved,
silently overwriting the user's persisted port with 8008 on every daemon
restart.
Fix: parseArgs now returns null when --port is absent. index.ts falls
back to config.port (then 8008 as last resort), so the persisted config
is preserved across restarts.
Problem 2 — fetching models from disabled providers:
The SDK's fetchModels() still makes HTTP requests to every provider in
the list, even disabled ones — it only skips adding their models to the
best-priced map. models.ts passed unfiltered provider lists to
fetchModels in three places (bootstrap, getRoutstr21Models, refresh).
Fix: Added filterDisabled() helper that reads disabledProviders from the
store and strips them before fetchModels is called, preventing wasteful
HTTP requests to providers the user has explicitly disabled.
22 lines
728 B
TypeScript
22 lines
728 B
TypeScript
export function parseArgs(argv: string[]): {
|
|
port: number | null;
|
|
provider: string | null;
|
|
} {
|
|
const portFlagIndex = argv.findIndex((arg) => arg === "--port");
|
|
const providerFlagIndex = argv.findIndex(
|
|
(arg) => arg === "--provider" || arg === "-p",
|
|
);
|
|
|
|
// Only use the CLI flag port if explicitly passed; otherwise fall back to
|
|
// the persisted config so a restart doesn't clobber the user's setting.
|
|
const port =
|
|
portFlagIndex !== -1
|
|
? Number.parseInt(argv[portFlagIndex + 1] || "8008", 10)
|
|
: null;
|
|
const providerValue =
|
|
providerFlagIndex !== -1 ? argv[providerFlagIndex + 1] : undefined;
|
|
const provider = providerValue ? providerValue.trim() : null;
|
|
|
|
return { port, provider };
|
|
}
|