mirror of
https://github.com/Routstr/routstrd.git
synced 2026-10-05 20:38:22 +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,
|
type RoutstrdConfig,
|
||||||
} from "./utils/config";
|
} from "./utils/config";
|
||||||
import { logger } from "./utils/logger";
|
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 * as QRCode from "qrcode";
|
||||||
import { normalizeNostrPubkey, npubFromPubkey, npubFromSecretKey } from "./utils/nip98";
|
import { normalizeNostrPubkey, npubFromPubkey, npubFromSecretKey } from "./utils/nip98";
|
||||||
import { generateSecretKey, nip19 } from "nostr-tools";
|
import { generateSecretKey, nip19 } from "nostr-tools";
|
||||||
@@ -485,6 +486,34 @@ program
|
|||||||
await handleDaemonCommand("/ping");
|
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
|
// Models - list routstr21 models
|
||||||
program
|
program
|
||||||
.command("models")
|
.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.
|
* Used both on initial daemon startup and in the recurring scheduled job.
|
||||||
*/
|
*/
|
||||||
export async function refreshModelsAndIntegrations(
|
export async function refreshModelsAndIntegrations(
|
||||||
getRoutstr21Models: (force?: boolean) => Promise<void>,
|
getRoutstr21Models: (force?: boolean) => Promise<any[]>,
|
||||||
config: RoutstrdConfig,
|
config: RoutstrdConfig,
|
||||||
label: string = "Scheduled",
|
label: string = "Scheduled",
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user