- 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 | import { spawn, spawnSync } from "node:child_process"; | 1 | import { spawn, spawnSync } from "node:child_process"; |
| 3 | import { unlinkSync } from "node:fs"; | 2 | import { unlinkSync } from "node:fs"; |
| 4 | import { createInterface } from "node:readline"; | 3 | import { createInterface } from "node:readline"; |
| 5 | import { PassThrough } from "node:stream"; | 4 | import { PassThrough } from "node:stream"; |
| 6 | import type { AppContext } from "../../types/context"; | 5 | import type { RouteRegistrar } from "../../http/route-registrar"; |
| 7 | import { badRequest, notFound } from "../../core/errors"; | 6 | import { badRequest, notFound } from "../../core/errors"; |
| 8 | import { observeControllerFunction } from "../../core/function-observability"; | 7 | import { observeControllerFunction } from "../../core/function-observability"; |
| 9 | import { streamAsyncStrings, buildSseHeaders, withSseHeartbeat } from "../../http/sse"; | 8 | import { streamAsyncStrings, buildSseHeaders, withSseHeartbeat } from "../../http/sse"; |
| @@ -21,7 +20,7 @@ import { · 11 unmodified lines | |||
| 21 | tailFileLines, | 20 | tailFileLines, |
| 22 | } from "../../core/log-files"; | 21 | } from "../../core/log-files"; |
| 23 | 22 | ||
| 24 | export const registerLogsRoutes = (app: Hono, context: AppContext): void => { | 23 | export const registerLogsRoutes: RouteRegistrar = (app, context) => { |
| 25 | let lastCleanupAt = 0; | 24 | let lastCleanupAt = 0; |
| 26 | 25 | ||
| 27 | const maybeCleanup = (): void => { | 26 | const maybeCleanup = (): void => { |
| @@ -1,6 +1,6 @@ | |||
| 1 | import type { Hono } from "hono"; | ||
| 2 | import { performance } from "node:perf_hooks"; | 1 | import { performance } from "node:perf_hooks"; |
| 3 | import { observeControllerFunction } from "../../core/function-observability"; | 2 | import { observeControllerFunction } from "../../core/function-observability"; |
| 3 | import type { RouteRegistrar } from "../../http/route-registrar"; | ||
| 4 | import type { AppContext } from "../../types/context"; | 4 | import type { AppContext } from "../../types/context"; |
| 5 | import { getGpuInfo } from "./platform/gpu"; | 5 | import { getGpuInfo } from "./platform/gpu"; |
| 6 | import { fetchInference } from "../../services/inference/inference-client"; | 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 | app.get("/metrics", async (_ctx) => { | 245 | app.get("/metrics", async (_ctx) => { |
| 246 | const current = await observeControllerFunction( | 246 | const current = await observeControllerFunction( |
| 247 | context, | 247 | context, |
| @@ -1,11 +1,11 @@ | |||
| 1 | import type { Hono } from "hono"; | ||
| 2 | import { connect } from "node:net"; | 1 | import { connect } from "node:net"; |
| 3 | import { hostname } from "node:os"; | 2 | import { hostname } from "node:os"; |
| 4 | import { existsSync, readFileSync } from "node:fs"; | 3 | import { existsSync, readFileSync } from "node:fs"; |
| 5 | import { join, resolve, sep } from "node:path"; | 4 | import { join, resolve, sep } from "node:path"; |
| 6 | import type { AppContext } from "../../types/context"; | 5 | import type { RouteRegistrar } from "../../http/route-registrar"; |
| 7 | import type { SystemConfigResponse } from "../models/types"; | 6 | import type { SystemConfigResponse } from "../models/types"; |
| 8 | import { badRequest, notFound } from "../../core/errors"; | 7 | import { badRequest, notFound } from "../../core/errors"; |
| 8 | import { parseJsonObjectBody } from "../../core/validation"; | ||
| 9 | import { observeControllerFunction } from "../../core/function-observability"; | 9 | import { observeControllerFunction } from "../../core/function-observability"; |
| 10 | import { estimateWeightsSizeBytes } from "../models/model-browser"; | 10 | import { estimateWeightsSizeBytes } from "../models/model-browser"; |
| 11 | import { getGpuInfo } from "./platform/gpu"; | 11 | import { getGpuInfo } from "./platform/gpu"; |
| @@ -21,7 +21,7 @@ import { · 9 unmodified lines | |||
| 21 | SYSTEM_SERVICE_CHECK_HOST, | 21 | SYSTEM_SERVICE_CHECK_HOST, |
| 22 | } from "./configs"; | 22 | } from "./configs"; |
| 23 | 23 | ||
| 24 | export const registerSystemRoutes = (app: Hono, context: AppContext): void => { | 24 | export const registerSystemRoutes: RouteRegistrar = (app, context) => { |
| 25 | const checkService = ( | 25 | const checkService = ( |
| 26 | host: string, | 26 | host: string, |
| 27 | port: number, | 27 | port: number, |
| @@ -87,10 +87,7 @@ export const registerSystemRoutes = (app: Hono, context: AppContext): void => { · 59 unmodified lines | |||
| 87 | }); | 87 | }); |
| 88 | 88 | ||
| 89 | app.post("/vram-calculator", async (ctx) => { | 89 | app.post("/vram-calculator", async (ctx) => { |
| 90 | const body = await ctx.req.json().catch(() => ({})); | 90 | const body = await parseJsonObjectBody(ctx); |
| 91 | if (!body || typeof body !== "object") { | ||
| 92 | throw badRequest("Invalid payload"); | ||
| 93 | } | ||
| 94 | 91 | ||
| 95 | const model = typeof body["model"] === "string" ? body["model"].trim() : ""; | 92 | const model = typeof body["model"] === "string" ? body["model"].trim() : ""; |
| 96 | const contextLength = Number(body["context_length"] ?? 0); | 93 | const contextLength = Number(body["context_length"] ?? 0); |
| @@ -1,5 +1,5 @@ | |||
| 1 | import type { Hono } from "hono"; | ||
| 2 | import { observeControllerFunction } from "../../core/function-observability"; | 1 | import { observeControllerFunction } from "../../core/function-observability"; |
| 2 | import type { RouteRegistrar } from "../../http/route-registrar"; | ||
| 3 | import type { AppContext } from "../../types/context"; | 3 | import type { AppContext } from "../../types/context"; |
| 4 | import { getUsageFromPiSessions } from "./usage/pi-sessions"; | 4 | import { getUsageFromPiSessions } from "./usage/pi-sessions"; |
| 5 | import { emptyResponse } from "./usage/usage-utilities"; | 5 | import { emptyResponse } from "./usage/usage-utilities"; |
| @@ -20,7 +20,7 @@ const collectKnownModels = async (context: AppContext): Promise<Set<string>> => · 14 unmodified lines | |||
| 20 | return knownModels; | 20 | return knownModels; |
| 21 | }; | 21 | }; |
| 22 | 22 | ||
| 23 | export const registerUsageRoutes = (app: Hono, context: AppContext): void => { | 23 | export const registerUsageRoutes: RouteRegistrar = (app, context) => { |
| 24 | app.get("/usage", async (ctx) => { | 24 | app.get("/usage", async (ctx) => { |
| 25 | try { | 25 | try { |
| 26 | const knownModels = await observeControllerFunction(context, "usage.collectKnownModels", () => | 26 | const knownModels = await observeControllerFunction(context, "usage.collectKnownModels", () => |