History

refactor(repo): adopt src/features convention, controller RouteRegistrar, shared validation

- 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.

seroxdesign committed 5 months ago

Commit c9d1ea51 parent 8d0aacf334 files · +2556 −2495Browse files

Showing the changes to controller/src/modules/system (4 of 334 files). Show all

Unified · Split

4 files
  1. controller/src/modules/system/logs-routes.ts +2 −3
  2. controller/src/modules/system/metrics-routes.ts +2 −2
  3. controller/src/modules/system/routes.ts +4 −7
  4. controller/src/modules/system/usage-routes.ts +2 −2
controller/src/modules/system/logs-routes.ts+2−3
@@ -1,9 +1,8 @@
1−import type { Hono } from "hono";
21 import { spawn, spawnSync } from "node:child_process";
32 import { unlinkSync } from "node:fs";
43 import { createInterface } from "node:readline";
54 import { PassThrough } from "node:stream";
6−import type { AppContext } from "../../types/context";
5+import type { RouteRegistrar } from "../../http/route-registrar";
76 import { badRequest, notFound } from "../../core/errors";
87 import { observeControllerFunction } from "../../core/function-observability";
98 import { streamAsyncStrings, buildSseHeaders, withSseHeartbeat } from "../../http/sse";
@@ -21,7 +20,7 @@ import { · 11 unmodified lines
2120 tailFileLines,
2221 } from "../../core/log-files";
2322
24−export const registerLogsRoutes = (app: Hono, context: AppContext): void => {
23+export const registerLogsRoutes: RouteRegistrar = (app, context) => {
2524 let lastCleanupAt = 0;
2625
2726 const maybeCleanup = (): void => {
controller/src/modules/system/metrics-routes.ts+2−2
@@ -1,6 +1,6 @@
1−import type { Hono } from "hono";
21 import { performance } from "node:perf_hooks";
32 import { observeControllerFunction } from "../../core/function-observability";
3+import type { RouteRegistrar } from "../../http/route-registrar";
44 import type { AppContext } from "../../types/context";
55 import { getGpuInfo } from "./platform/gpu";
66 import { fetchInference } from "../../services/inference/inference-client";
@@ -241,7 +241,7 @@ const buildCurrentMetrics = async (context: AppContext): Promise<Record<string, · 234 unmodified lines
241241 };
242242 };
243243
244−export const registerMonitoringRoutes = (app: Hono, context: AppContext): void => {
244+export const registerMonitoringRoutes: RouteRegistrar = (app, context) => {
245245 app.get("/metrics", async (_ctx) => {
246246 const current = await observeControllerFunction(
247247 context,
controller/src/modules/system/routes.ts+4−7
@@ -1,11 +1,11 @@
1−import type { Hono } from "hono";
21 import { connect } from "node:net";
32 import { hostname } from "node:os";
43 import { existsSync, readFileSync } from "node:fs";
54 import { join, resolve, sep } from "node:path";
6−import type { AppContext } from "../../types/context";
5+import type { RouteRegistrar } from "../../http/route-registrar";
76 import type { SystemConfigResponse } from "../models/types";
87 import { badRequest, notFound } from "../../core/errors";
8+import { parseJsonObjectBody } from "../../core/validation";
99 import { observeControllerFunction } from "../../core/function-observability";
1010 import { estimateWeightsSizeBytes } from "../models/model-browser";
1111 import { getGpuInfo } from "./platform/gpu";
@@ -21,7 +21,7 @@ import { · 9 unmodified lines
2121 SYSTEM_SERVICE_CHECK_HOST,
2222 } from "./configs";
2323
24−export const registerSystemRoutes = (app: Hono, context: AppContext): void => {
24+export const registerSystemRoutes: RouteRegistrar = (app, context) => {
2525 const checkService = (
2626 host: string,
2727 port: number,
@@ -87,10 +87,7 @@ export const registerSystemRoutes = (app: Hono, context: AppContext): void => { · 59 unmodified lines
8787 });
8888
8989 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);
9491
9592 const model = typeof body["model"] === "string" ? body["model"].trim() : "";
9693 const contextLength = Number(body["context_length"] ?? 0);
controller/src/modules/system/usage-routes.ts+2−2
@@ -1,5 +1,5 @@
1−import type { Hono } from "hono";
21 import { observeControllerFunction } from "../../core/function-observability";
2+import type { RouteRegistrar } from "../../http/route-registrar";
33 import type { AppContext } from "../../types/context";
44 import { getUsageFromPiSessions } from "./usage/pi-sessions";
55 import { emptyResponse } from "./usage/usage-utilities";
@@ -20,7 +20,7 @@ const collectKnownModels = async (context: AppContext): Promise<Set<string>> => · 14 unmodified lines
2020 return knownModels;
2121 };
2222
23−export const registerUsageRoutes = (app: Hono, context: AppContext): void => {
23+export const registerUsageRoutes: RouteRegistrar = (app, context) => {
2424 app.get("/usage", async (ctx) => {
2525 try {
2626 const knownModels = await observeControllerFunction(context, "usage.collectKnownModels", () =>

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t