feat: add master code queue manager

This commit is contained in:
Codex
2026-05-17 09:48:00 +00:00
parent 48db823e52
commit f775990c90
22 changed files with 2406 additions and 45 deletions
+2 -2
View File
@@ -80,8 +80,8 @@ function parseMicroserviceConfig(value: unknown, index: number): MicroserviceCon
const frontend = asRecord(item.frontend, `${path}.frontend`);
const deployment = item.deployment === undefined ? undefined : asRecord(item.deployment, `${path}.deployment`);
const deploymentMode = deployment === undefined ? "unidesk-direct" : stringFromRecord(deployment, "mode", `${path}.deployment`);
if (deploymentMode !== "unidesk-direct" && deploymentMode !== "k3sctl-managed") {
throw new Error(`${path}.deployment.mode must be unidesk-direct or k3sctl-managed`);
if (deploymentMode !== "unidesk-direct" && deploymentMode !== "k3sctl-managed" && deploymentMode !== "internal-sidecar") {
throw new Error(`${path}.deployment.mode must be unidesk-direct, k3sctl-managed, or internal-sidecar`);
}
return {
id: stringFromRecord(item, "id", path),
@@ -390,6 +390,17 @@ function codeQueueK3sServiceIdForRequest(method: string, targetPath: string): st
return "code-queue-write";
}
function codeQueueMasterControlPath(method: string, targetPath: string): boolean {
const normalizedMethod = method.toUpperCase();
if (targetPath === "/" || targetPath === "/health" || targetPath === "/live" || targetPath === "/logs") return true;
if (targetPath === "/api/queues" || targetPath === "/api/queues/merge") return true;
if (/^\/api\/queues\/[^/]+(?:\/merge)?$/u.test(targetPath)) return true;
if (targetPath === "/api/tasks" || targetPath === "/api/tasks/batch" || targetPath === "/api/tasks/overview" || targetPath === "/api/tasks/stats" || targetPath === "/api/tasks/read-all") return true;
if (/^\/api\/tasks\/[^/]+\/(?:summary|trace-summary|trace-steps|trace-step|transcript|output|prompt|read|retry|move|edit)$/u.test(targetPath)) return true;
if (/^\/api\/tasks\/[^/]+$/u.test(targetPath) && normalizedMethod === "GET") return true;
return false;
}
// ---------------------------------------------------------------------------
// Cache helpers
// ---------------------------------------------------------------------------
@@ -713,6 +724,11 @@ async function fetchMicroserviceUpstreamResponse(
bodyText: string,
abortSignal?: AbortSignal,
): Promise<Response> {
if (service.id === "code-queue" && codeQueueMasterControlPath(method, targetPath)) {
const mgr = microserviceById("code-queue-mgr");
if (mgr !== null) return directMicroserviceResponse(mgr, method, targetPath, proxyOptions, requestHeaders, bodyText, abortSignal);
logger("warn", "code_queue_mgr_missing_fallback_to_d601", { method, targetPath });
}
if (isK3sctlManagedMicroservice(service)) {
return k3sctlAdapterMicroserviceResponse(service, method, targetPath, proxyOptions, requestHeaders, bodyText, abortSignal);
}
+1 -1
View File
@@ -45,7 +45,7 @@ export interface MicroserviceConfig {
timeoutMs: number;
};
deployment: {
mode: "unidesk-direct" | "k3sctl-managed";
mode: "unidesk-direct" | "k3sctl-managed" | "internal-sidecar";
adapterServiceId?: string;
k3sServiceId?: string;
namespace?: string;