11import { URL } from "node:url" ;
2- import { readFileSync } from "node:fs" ;
32import { timingSafeEqual , randomBytes } from "node:crypto" ;
43import { FEATURE_FLAG_SPEC } from "./settings.js" ;
54import { TYPE_FILE , renderMirrorText , parseHumanEdits } from "./mirror.js" ;
@@ -8,7 +7,7 @@ import { computeHeat } from "./heat.js";
87import { describeStreamFailure , resolveRoute } from "./dream.js" ;
98import { describeLocalRuntime , publicRuntimeStatus } from "./runtime/loader.js" ;
109import { hostModulesDir , provisionRuntime } from "./runtime/provision.js" ;
11- import { classify , fetchLatestVersion } from "./version-check.js" ;
10+ import { classify , fetchLatestVersion , PACKAGE_VERSION } from "./version-check.js" ;
1211
1312// headers:少数端点(/export 附件下载)需要追加 Content-Disposition 等响应头。
1413function sendJson ( res , status , payload , headers = { } ) {
@@ -25,16 +24,8 @@ function sendAttachment(res, status, contentType, filename, body) {
2524 res . end ( body ) ;
2625}
2726
28- // 导出 JSON 的 version 字段:读插件根的 package.json(src/ 与 lib/ 都在根下
29- // 一层,相对 import.meta.url 解析一致)。读取失败(打包/受限环境)降级为
30- // "unknown",导出本身仍然可用。
31- const PACKAGE_VERSION = ( ( ) => {
32- try {
33- return JSON . parse ( readFileSync ( new URL ( "../package.json" , import . meta. url ) , "utf8" ) ) . version ?? "unknown" ;
34- } catch {
35- return "unknown" ;
36- }
37- } ) ( ) ;
27+ // 版本号统一从 version-check.js 取(同一份读 package.json 逻辑,读取失败
28+ // 同样降级 "unknown")——/info 与 /version-check 两个路由共用,不再各写一份。
3829
3930// Defaults for the standalone external API — keep in step with the schema
4031// defaults in config.js (externalApiPort / externalApiHost).
0 commit comments