mirror of
https://github.com/Routstr/routstrd.git
synced 2026-07-30 15:46:14 +00:00
Add 'refresh' CLI command to refresh models and integrations
- Added 'routstrd refresh' command that: - Calls /v1/models?refresh=true to refresh routstr21 models - Calls runIntegrationsForClients() for all registered clients - Fixed type signature in refreshModelsAndIntegrations (returns any[] not void) - Imports getClientsList and runIntegrationsForClients in cli.ts
This commit is contained in:
+30
-1
@@ -26,7 +26,8 @@ import {
|
||||
type RoutstrdConfig,
|
||||
} from "./utils/config";
|
||||
import { logger } from "./utils/logger";
|
||||
import { setupIntegration } from "./integrations";
|
||||
import { setupIntegration, runIntegrationsForClients } from "./integrations";
|
||||
import { getClientsList } from "./utils/clients";
|
||||
import * as QRCode from "qrcode";
|
||||
import { normalizeNostrPubkey, npubFromPubkey, npubFromSecretKey } from "./utils/nip98";
|
||||
import { generateSecretKey, nip19 } from "nostr-tools";
|
||||
@@ -485,6 +486,34 @@ program
|
||||
await handleDaemonCommand("/ping");
|
||||
});
|
||||
|
||||
// Refresh - refresh models and integrations
|
||||
program
|
||||
.command("refresh")
|
||||
.description("Refresh routstr21 models and client integrations")
|
||||
.action(async () => {
|
||||
await ensureDaemonRunning();
|
||||
const config = await loadConfig();
|
||||
|
||||
// Refresh models via daemon API
|
||||
console.log("Refreshing routstr21 models...");
|
||||
const result = await callDaemon("/v1/models?refresh=true");
|
||||
if (result.error) {
|
||||
console.log(`Model refresh failed: ${result.error}`);
|
||||
process.exit(1);
|
||||
}
|
||||
console.log("Models refreshed.");
|
||||
|
||||
// Refresh integrations for all clients
|
||||
const clients = await getClientsList();
|
||||
if (clients.length > 0) {
|
||||
console.log(`Refreshing ${clients.length} client integration(s)...`);
|
||||
await runIntegrationsForClients(clients, config);
|
||||
console.log("Client integrations refreshed.");
|
||||
} else {
|
||||
console.log("No clients to refresh.");
|
||||
}
|
||||
});
|
||||
|
||||
// Models - list routstr21 models
|
||||
program
|
||||
.command("models")
|
||||
|
||||
@@ -18,7 +18,7 @@ export { CLIENT_INTEGRATIONS, CLIENT_CONFIGS, runIntegrationsForClients } from "
|
||||
* Used both on initial daemon startup and in the recurring scheduled job.
|
||||
*/
|
||||
export async function refreshModelsAndIntegrations(
|
||||
getRoutstr21Models: (force?: boolean) => Promise<void>,
|
||||
getRoutstr21Models: (force?: boolean) => Promise<any[]>,
|
||||
config: RoutstrdConfig,
|
||||
label: string = "Scheduled",
|
||||
): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user