/** * [ref] A9 域模块 —— sandbox-image-pool 控制面(IMAGE-API-DESIGN.md)。 * * 路由:P2 bake 作业面 `/v1/images/bakes*`(提交/列表/详情/事件 SSE/取消/claim/ingest)与 P1 镜像索引 * `/v1/images*`(digests/profile/select)。**bakes 段必须排在 images 段之前**——P1 的单段 profile 正则会把 * `bakes` 当成 profile 吞掉(注释原文见路由体内),两段的先后由本文件内部顺序保住。 * * 单域独占状态:`bakeSubmitLimiter`(per-principal 提交限速),按 server 实例存活于 `ctx.local.images`。 * 本域另收编了原先散在 `server.ts` 模块级的镜像面私产:路由正则、bake 视图投影、claim 应答、ingest 行摄取、 * bake SSE 包装、以及两个导出的状态/错误码映射(`server.ts` 保留 re-export,导出面不变)。 */ import type { IncomingMessage, ServerResponse } from "node:http"; import { RateLimiter } from "../../observability/rate-limit.js"; import type { BakeState, BakeErrorCode } from "../../plugins/store-contracts.js"; import type { FlatServiceDeps } from "../server.js"; import type { RouteCtx, RouteMatch, RouteIdsOf } from "../route-ctx.js"; /** 单域独占状态(lens1 §C2 的 12 条之一)。每个 server 实例一份——模块级会把限速状态跨实例串味 * (一个进程里建几十个 server 的测试会互相污染)。 */ export interface ImagesLocal { bakeSubmitLimiter: RateLimiter; } export declare function createImagesLocal(deps: FlatServiceDeps): ImagesLocal; /** build.sh's 8-value `state` → the COARSE 4-value lifecycle the SSE reader polls for terminality (§P2.3). Every * NON-terminal state maps to `running` (a PUSHING/VERIFYING state must NOT truncate the stream before `done`). */ export declare function coarseStatusForState(state: BakeState): "running" | "done" | "failed"; /** build.sh's structured exit code → the center band-composer UI's terminal `errorCode` (§P2.14 #2). null for an * uncategorized failure (then `error` free-text + `exitCode` drive the UI). 10=dup-tag, 124=timeout, 507=disk. */ export declare function errorCodeForExit(exitCode: number | null | undefined, cancelled: boolean): BakeErrorCode; /** 路由体 = 从 `server.ts` 的 `handle()` 里**整段剪切**过来的原文(唯一改动:统一去缩进两格)。裸 `return;` * 的语义原样 =「本域已应答」;走到函数尾才是「没匹配上」,置 `miss.fell` 交回装配器继续下一个域。 * 跨域的东西(deps / 助手 / 单域状态 / 每请求量)一律在首行解构出来,于是下面每一行都逐字不变。 */ export declare function handleImages(req: IncomingMessage, res: ServerResponse, match: RouteMatch, ctx: RouteCtx): Promise; export declare const IMAGES_ROUTES: readonly [{ readonly id: "images-index"; readonly path: "/v1/images"; readonly methods: readonly ["GET"]; }, { readonly id: "image-bake-submit"; readonly path: "/v1/images/bakes"; readonly methods: readonly ["POST"]; }, { readonly id: "image-bake-claim-next"; readonly path: "/v1/images/bakes/claim"; readonly methods: readonly ["POST"]; }, { readonly id: "image-select"; readonly path: "/v1/images/select"; readonly methods: readonly ["POST"]; }, { readonly id: "image-register"; readonly path: "/v1/images/register"; readonly methods: readonly ["POST"]; }, { readonly id: "image-bake-events"; readonly pattern: RegExp; readonly label: "/v1/images/bakes/:id/events"; readonly methods: readonly ["GET"]; }, { readonly id: "image-bake-cancel"; readonly pattern: RegExp; readonly label: "/v1/images/bakes/:id/cancel"; readonly methods: readonly ["POST"]; }, { readonly id: "image-bake-claim"; readonly pattern: RegExp; readonly label: "/v1/images/bakes/:id/claim"; readonly methods: readonly ["POST"]; }, { readonly id: "image-bake-ingest"; readonly pattern: RegExp; readonly label: "/v1/images/bakes/:id/ingest"; readonly methods: readonly ["POST"]; }, { readonly id: "image-bake-detail"; readonly pattern: RegExp; readonly label: "/v1/images/bakes/:id"; readonly methods: readonly ["GET"]; }, { readonly id: "image-by-digest"; readonly pattern: RegExp; readonly label: "/v1/images/digests/:digest"; readonly methods: readonly ["GET"]; }, { readonly id: "image-by-profile"; readonly pattern: RegExp; readonly label: "/v1/images/:profile"; readonly methods: readonly ["GET"]; }]; /** 本域可分派行的 `id` 闭集 —— handler 的 `switch` 按它判穷尽(漏一口 = 编译红)。 */ export type ImagesRouteId = RouteIdsOf; //# sourceMappingURL=images.d.ts.map