feat: unify Docker entrypoint

This commit is contained in:
Pi Web Agent
2026-06-29 11:27:47 +00:00
parent 4a1136eac2
commit bd28c93cfe
35 changed files with 2316 additions and 118 deletions
+3 -1
View File
@@ -434,7 +434,8 @@ export interface TerminalCommandRunFilter {
export type PiWebServiceComponent = "web" | "sessiond";
export type PiWebStatusSeverity = "info" | "warning" | "error";
export type PiWebInstallationKind = "pi-package" | "npm-global" | "local" | "unknown";
export type PiWebInstallationKind = "pi-package" | "npm-global" | "local" | "docker" | "unknown";
export type PiWebDockerMode = "runtime" | "dev";
export interface PiWebInstallationInfo {
kind: PiWebInstallationKind;
@@ -442,6 +443,7 @@ export interface PiWebInstallationInfo {
source?: string;
scope?: "user" | "project";
npmRoot?: string;
dockerMode?: PiWebDockerMode;
}
export interface PiWebComponentStatus {
+42
View File
@@ -0,0 +1,42 @@
import { describe, expect, it } from "vitest";
import { parsePiWebComponentStatus, parsePiWebInstallationInfo, parsePiWebVersionResponse } from "./piWebStatusParsing.js";
describe("PI WEB shared status parsing", () => {
it("parses Docker installation metadata", () => {
expect(parsePiWebInstallationInfo({ kind: "docker", path: "/srv/pi-web-docker", dockerMode: "runtime" })).toEqual({
kind: "docker",
path: "/srv/pi-web-docker",
dockerMode: "runtime",
});
expect(parsePiWebInstallationInfo({ kind: "docker", path: "/workspace/pi-web", dockerMode: "dev" })).toEqual({
kind: "docker",
path: "/workspace/pi-web",
dockerMode: "dev",
});
});
it("ignores invalid optional Docker modes without rejecting component status", () => {
expect(parsePiWebComponentStatus({
component: "web",
label: "Web/UI",
runtimeVersion: "1.0.0",
stale: false,
available: true,
installation: { kind: "docker", path: "/workspace/pi-web", dockerMode: "hidden" },
})?.installation).toEqual({ kind: "docker", path: "/workspace/pi-web" });
});
it("parses version responses that include Docker runtime and development components", () => {
const parsed = parsePiWebVersionResponse({
packageName: "@jmfederico/pi-web",
generatedAt: "now",
components: {
web: { component: "web", label: "Web/UI", runtimeVersion: "1.0.0", stale: false, available: true, installation: { kind: "docker", path: "/srv/pi-web-docker", dockerMode: "runtime" } },
sessiond: { component: "sessiond", label: "Session daemon", runtimeVersion: "1.0.0", stale: false, available: true, installation: { kind: "docker", path: "/workspace/pi-web", dockerMode: "dev" } },
},
});
expect(parsed?.components.web.installation).toEqual({ kind: "docker", path: "/srv/pi-web-docker", dockerMode: "runtime" });
expect(parsed?.components.sessiond.installation).toEqual({ kind: "docker", path: "/workspace/pi-web", dockerMode: "dev" });
});
});
+3 -1
View File
@@ -69,13 +69,15 @@ export function parsePiWebInstallationInfo(value: unknown): PiWebInstallationInf
const source = value["source"];
const scope = value["scope"];
const npmRoot = value["npmRoot"];
if (kind !== "pi-package" && kind !== "npm-global" && kind !== "local" && kind !== "unknown") return undefined;
const dockerMode = value["dockerMode"];
if (kind !== "pi-package" && kind !== "npm-global" && kind !== "local" && kind !== "docker" && kind !== "unknown") return undefined;
return {
kind,
...(typeof path === "string" ? { path } : {}),
...(typeof source === "string" ? { source } : {}),
...(scope === "user" || scope === "project" ? { scope } : {}),
...(typeof npmRoot === "string" ? { npmRoot } : {}),
...(dockerMode === "runtime" || dockerMode === "dev" ? { dockerMode } : {}),
};
}