Files
edubox/server/lib/agent-version.ts
T
EduBox Dev e946b22a42 feat(agent): v0.3.9 sync, UI details, self-update, centralized version
- Add agent/server startup sync (sync/sync_response)
- Centralize agent version in agent/VERSION + expose /api/agent/version
- Display agent version, nodeId and server version in local UI
- Add agent self-update detection/download/restart via helper scripts
- Run start/stop/delete/reset handlers in goroutines to avoid WebSocket blocking
- Update dashboard download links and SUIVI_VPN_ONDEMAND.md
- Document Podman stays installer-managed, not agent-updated
2026-06-27 21:11:20 +00:00

56 lines
1.5 KiB
TypeScript

import fs from "fs";
import path from "path";
const BIN_NAME = "studioE5-agent";
function findVersionFile(): string | null {
// Try a few common paths relative to the server workspace and Next.js build output.
const candidates = [
path.join(process.cwd(), "..", "agent", "VERSION"),
path.join(process.cwd(), "..", "..", "agent", "VERSION"),
path.join(process.cwd(), "agent", "VERSION"),
path.join(__dirname, "..", "..", "..", "agent", "VERSION"),
path.join(__dirname, "..", "..", "agent", "VERSION"),
"/app/agent-version",
];
for (const candidate of candidates) {
if (fs.existsSync(candidate)) {
return candidate;
}
}
return null;
}
export function getAgentVersion(): string {
const versionFile = findVersionFile();
if (versionFile) {
return fs.readFileSync(versionFile, "utf-8").trim();
}
// Fallback used when the agent workspace is not mounted (should not happen).
return "0.3.9";
}
export interface AgentDownloadUrls {
windows: string;
windowsZip: string;
linux: string;
mac: string;
}
export function getAgentDownloadUrls(version: string): AgentDownloadUrls {
return {
windows: `/${BIN_NAME}-v${version}.exe`,
windowsZip: `/${BIN_NAME}-v${version}-windows.zip`,
linux: `/${BIN_NAME}-v${version}`,
mac: `/${BIN_NAME}-v${version}-mac`,
};
}
export function getAgentVersionInfo() {
const version = getAgentVersion();
return {
version,
downloadUrls: getAgentDownloadUrls(version),
};
}