mirror of
https://github.com/Routstr/routstrd.git
synced 2026-07-30 15:46:14 +00:00
fix: sync bootstrapped providers into store so providers list is complete
After bootstrapProviders runs, newly discovered URLs (e.g. privateprovider.xyz) were only known to the ModelManager cache and never written into the store's baseUrlsList. This caused `providers list` and `models -m <id>` to show different sets of providers. Now the bootstrap step merges any new URLs into the store so both commands draw from the same source of truth. Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4
parent
5771a47054
commit
622afb04a5
+1
-1
@@ -52,7 +52,7 @@ async function main(): Promise<void> {
|
||||
// Create shared ProviderManager for consistent failure tracking across all requests
|
||||
const providerManager = new ProviderManager(providerRegistry, store);
|
||||
const { ensureProvidersBootstrapped, getRoutstr21Models, getModelProviders } =
|
||||
createModelService(modelManager);
|
||||
createModelService(modelManager, store);
|
||||
|
||||
const walletClient = createCocodClient({ cocodPath: config.cocodPath });
|
||||
const walletAdapter = await createWalletAdapter({
|
||||
|
||||
+18
-2
@@ -1,4 +1,4 @@
|
||||
import { ModelManager } from "@routstr/sdk";
|
||||
import { ModelManager, type SdkStore } from "@routstr/sdk";
|
||||
import type { ExposedModel } from "./types";
|
||||
import { logger } from "../utils/logger";
|
||||
|
||||
@@ -16,7 +16,7 @@ export type ModelWithProviders = ExposedModel & {
|
||||
providers: ModelProviderInfo[];
|
||||
};
|
||||
|
||||
export function createModelService(modelManager: ModelManager) {
|
||||
export function createModelService(modelManager: ModelManager, store: SdkStore) {
|
||||
let providerBootstrapPromise: Promise<void> | null = null;
|
||||
|
||||
const ensureProvidersBootstrapped = (): Promise<void> => {
|
||||
@@ -26,6 +26,22 @@ export function createModelService(modelManager: ModelManager) {
|
||||
const providers = await modelManager.bootstrapProviders(false);
|
||||
logger.log(`Bootstrapped ${providers.length} providers`);
|
||||
await modelManager.fetchModels(providers);
|
||||
|
||||
// Sync discovered providers into the store so `providers list` reflects
|
||||
// the same set that the model manager knows about.
|
||||
const { baseUrlsList, setBaseUrlsList } = store.getState();
|
||||
const existing = new Set(baseUrlsList);
|
||||
const merged = [
|
||||
...baseUrlsList,
|
||||
...providers.filter((url) => !existing.has(url)),
|
||||
];
|
||||
if (merged.length !== baseUrlsList.length) {
|
||||
setBaseUrlsList(merged);
|
||||
logger.log(
|
||||
`Synced ${merged.length - baseUrlsList.length} new provider(s) into store`,
|
||||
);
|
||||
}
|
||||
|
||||
logger.log("Provider bootstrap complete.");
|
||||
})().catch((error) => {
|
||||
logger.error("Provider bootstrap failed:", error);
|
||||
|
||||
Reference in New Issue
Block a user