muse-agent-example/web/旅程环境.ts
zizi ae02fd1732 前端:工作台页面、事件标签与旅程用例
- 上下文清单、任务列表与详情、恢复控制、运行观察、创作对话与消息流、正式变更决策面板、正文写作与候选审阅、资料研究等页面同步本轮后端能力。
- 事件标签表补齐后端事件类型;查询键与生成客户端随 HTTP 契约重新生成。
- 依赖调整后 lockfile 同步;交互用例与浏览器旅程 spec 一并更新。
- 证据:make 前端检查(lint + typecheck + Pi 工具桥 tsc)exit 0;make 前端测试 37 文件 / 120 用例通过。
2026-09-18 01:15:07 +08:00

32 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { accessSync, constants } from "node:fs";
import { isAbsolute } from "node:path";
/** 仅核对具名隔离环境;不启动服务、安装浏览器或读取口令内容。 */
export function 核对旅程环境(env: NodeJS.ProcessEnv) {
if (env.MUSE_ISOLATED_TEST_ENVIRONMENT !== "1")
throw new Error(
"真实旅程需要 MUSE_ISOLATED_TEST_ENVIRONMENT=1 明确确认隔离测试环境。",
);
if (!env.MUSE_WORKBENCH_URL)
throw new Error("真实旅程需要明确 MUSE_WORKBENCH_URL,不使用默认后端。");
const url = new URL(env.MUSE_WORKBENCH_URL);
if (
!["http:", "https:"].includes(url.protocol) ||
url.username ||
url.password
)
throw new Error("工作台URL必须为无内嵌凭据的HTTP(S)地址。");
for (const name of [
"MUSE_BROWSER_EXECUTABLE",
"MUSE_AUTHOR_PASSWORD_FILE",
] as const) {
const file = env[name];
if (!file || !isAbsolute(file))
throw new Error(`真实旅程需要具名绝对路径 ${name}。`);
accessSync(
file,
name === "MUSE_BROWSER_EXECUTABLE" ? constants.X_OK : constants.R_OK,
);
}
}