- frontend: src/features/{agent,recipes,discover,settings,usage,plugins,setup,logs,dashboard}; src/ui reduced to primitives; src/components retired; agent trees merged (lib/agent + hooks/agent + app/agent/_components -> features/agent) - controller: RouteRegistrar type across modules, core/validation.ts body helpers, studio provider routes split out - shared API route helpers (app/api/_lib/route-helpers.ts), themes data/API split, lib/types consolidated to recipes.ts + system.ts - structure validator rewritten to enforce the new layering Verified: check:quality (incl. production build), controller integration 49/49, frontend e2e 155/155, contracts check.
Showing the changes to controller/src/modules/system (4 of 334 files). Show all
Unified · Split
| @@ -1,9 +1,8 @@ | ||
| 1 | −import type { Hono } from "hono"; | |
| 2 | 1 | import { spawn, spawnSync } from "node:child_process"; |
| 3 | 2 | import { unlinkSync } from "node:fs"; |
| 4 | 3 | import { createInterface } from "node:readline"; |
| 5 | 4 | import { PassThrough } from "node:stream"; |
| 6 | −import type { AppContext } from "../../types/context"; | |
| 5 | +import type { RouteRegistrar } from "../../http/route-registrar"; | |
| 7 | 6 | import { badRequest, notFound } from "../../core/errors"; |
| 8 | 7 | import { observeControllerFunction } from "../../core/function-observability"; |
| 9 | 8 | import { streamAsyncStrings, buildSseHeaders, withSseHeartbeat } from "../../http/sse"; |
| @@ -21,7 +20,7 @@ import { · 11 unmodified lines | ||
| 21 | 20 | tailFileLines, |
| 22 | 21 | } from "../../core/log-files"; |
| 23 | 22 | |
| 24 | −export const registerLogsRoutes = (app: Hono, context: AppContext): void => { | |
| 23 | +export const registerLogsRoutes: RouteRegistrar = (app, context) => { | |
| 25 | 24 | let lastCleanupAt = 0; |
| 26 | 25 | |
| 27 | 26 | const maybeCleanup = (): void => { |
| @@ -1,6 +1,6 @@ | ||
| 1 | −import type { Hono } from "hono"; | |
| 2 | 1 | import { performance } from "node:perf_hooks"; |
| 3 | 2 | import { observeControllerFunction } from "../../core/function-observability"; |
| 3 | +import type { RouteRegistrar } from "../../http/route-registrar"; | |
| 4 | 4 | import type { AppContext } from "../../types/context"; |
| 5 | 5 | import { getGpuInfo } from "./platform/gpu"; |
| 6 | 6 | import { fetchInference } from "../../services/inference/inference-client"; |
| @@ -241,7 +241,7 @@ const buildCurrentMetrics = async (context: AppContext): Promise<Record<string, · 234 unmodified lines | ||
| 241 | 241 | }; |
| 242 | 242 | }; |
| 243 | 243 | |
| 244 | −export const registerMonitoringRoutes = (app: Hono, context: AppContext): void => { | |
| 244 | +export const registerMonitoringRoutes: RouteRegistrar = (app, context) => { | |
| 245 | 245 | app.get("/metrics", async (_ctx) => { |
| 246 | 246 | const current = await observeControllerFunction( |
| 247 | 247 | context, |
| @@ -1,11 +1,11 @@ | ||
| 1 | −import type { Hono } from "hono"; | |
| 2 | 1 | import { connect } from "node:net"; |
| 3 | 2 | import { hostname } from "node:os"; |
| 4 | 3 | import { existsSync, readFileSync } from "node:fs"; |
| 5 | 4 | import { join, resolve, sep } from "node:path"; |
| 6 | −import type { AppContext } from "../../types/context"; | |
| 5 | +import type { RouteRegistrar } from "../../http/route-registrar"; | |
| 7 | 6 | import type { SystemConfigResponse } from "../models/types"; |
| 8 | 7 | import { badRequest, notFound } from "../../core/errors"; |
| 8 | +import { parseJsonObjectBody } from "../../core/validation"; | |
| 9 | 9 | import { observeControllerFunction } from "../../core/function-observability"; |
| 10 | 10 | import { estimateWeightsSizeBytes } from "../models/model-browser"; |
| 11 | 11 | import { getGpuInfo } from "./platform/gpu"; |
| @@ -21,7 +21,7 @@ import { · 9 unmodified lines | ||
| 21 | 21 | SYSTEM_SERVICE_CHECK_HOST, |
| 22 | 22 | } from "./configs"; |
| 23 | 23 | |
| 24 | −export const registerSystemRoutes = (app: Hono, context: AppContext): void => { | |
| 24 | +export const registerSystemRoutes: RouteRegistrar = (app, context) => { | |
| 25 | 25 | const checkService = ( |
| 26 | 26 | host: string, |
| 27 | 27 | port: number, |
| @@ -87,10 +87,7 @@ export const registerSystemRoutes = (app: Hono, context: AppContext): void => { · 59 unmodified lines | ||
| 87 | 87 | }); |
| 88 | 88 | |
| 89 | 89 | app.post("/vram-calculator", async (ctx) => { |
| 90 | − const body = await ctx.req.json().catch(() => ({})); | |
| 91 | − if (!body || typeof body !== "object") { | |
| 92 | − throw badRequest("Invalid payload"); | |
| 93 | − } | |
| 90 | + const body = await parseJsonObjectBody(ctx); | |
| 94 | 91 | |
| 95 | 92 | const model = typeof body["model"] === "string" ? body["model"].trim() : ""; |
| 96 | 93 | const contextLength = Number(body["context_length"] ?? 0); |
| @@ -1,5 +1,5 @@ | ||
| 1 | −import type { Hono } from "hono"; | |
| 2 | 1 | import { observeControllerFunction } from "../../core/function-observability"; |
| 2 | +import type { RouteRegistrar } from "../../http/route-registrar"; | |
| 3 | 3 | import type { AppContext } from "../../types/context"; |
| 4 | 4 | import { getUsageFromPiSessions } from "./usage/pi-sessions"; |
| 5 | 5 | import { emptyResponse } from "./usage/usage-utilities"; |
| @@ -20,7 +20,7 @@ const collectKnownModels = async (context: AppContext): Promise<Set<string>> => · 14 unmodified lines | ||
| 20 | 20 | return knownModels; |
| 21 | 21 | }; |
| 22 | 22 | |
| 23 | −export const registerUsageRoutes = (app: Hono, context: AppContext): void => { | |
| 23 | +export const registerUsageRoutes: RouteRegistrar = (app, context) => { | |
| 24 | 24 | app.get("/usage", async (ctx) => { |
| 25 | 25 | try { |
| 26 | 26 | const knownModels = await observeControllerFunction(context, "usage.collectKnownModels", () => |