import type { Application, Request, Response } from 'express'; import type { HistoricalPeriodsSnapshot, HistoricalStatsSnapshot, StatsSnapshot } from './stats-manager.js'; export interface DaemonAdminRouteOptions { app: Application; /** * Lazily resolve ManagerDaemon 实例;可能为 null(例如初始化早期或关闭中)。 */ getManagerDaemon: () => unknown | null; /** * 返回当前 HTTP 服务器标识(通常为 host:port)。 */ getServerId: () => string; /** * 返回当前虚拟路由构建产物;用于 Providers 运行时视图。 */ getVirtualRouterArtifacts: () => unknown | null; /** * Return the config path used to bootstrap this server instance (best-effort). * Control-plane mutate uses this path as the single write target. */ getConfigPath?: () => string | null; /** * Deprecated: daemon-admin 不再使用 apikey 鉴权(改为密码登录)。 */ getExpectedApiKey?: () => string | undefined; /** * Return the bind host used by current HTTP server instance. * Daemon-admin auth policy baseline for non-local requests. */ getServerHost?: () => string; /** * 触发服务重新读取 config 并重建 runtime(不退出进程)。 */ restartRuntimeFromDisk?: () => Promise<{ reloadedAt: number; configPath: string; warnings?: string[]; }>; /** * 返回当前进程的 token/usage 统计(session + historical)。 * 由 HTTP server 负责组装;daemon-admin 仅展示。 */ getStatsSnapshot?: () => { session: StatsSnapshot; historical: HistoricalStatsSnapshot; periods?: HistoricalPeriodsSnapshot; }; } export declare function isLocalRequest(req: Request): boolean; export declare function isLoopbackBindHost(hostRaw: unknown): boolean; export declare function isDaemonAdminAuthRequired(req: Request): boolean; export declare function isDaemonAdminApiKeyConfigured(req: Request): boolean; export declare function isDaemonAdminApiKeyAuthenticated(req: Request): boolean; export declare function isDaemonAdminAuthenticated(req: Request): boolean; export declare function rejectNonLocal(req: Request, res: Response): boolean; export declare function rejectNonLocalOrUnauthorizedAdmin(req: Request, res: Response): boolean; export declare function registerDaemonAdminRoutes(options: DaemonAdminRouteOptions): void;