Skip to content

fix(core,playground): 规划阶段校验 actionSpace、报告模板注入兜底、Playground 默认本机监听#2520

Open
FinnJov wants to merge 4 commits into
web-infra-dev:mainfrom
FinnJov:fix/core-planning-and-report-build
Open

fix(core,playground): 规划阶段校验 actionSpace、报告模板注入兜底、Playground 默认本机监听#2520
FinnJov wants to merge 4 commits into
web-infra-dev:mainfrom
FinnJov:fix/core-planning-and-report-build

Conversation

@FinnJov
Copy link
Copy Markdown

@FinnJov FinnJov commented May 22, 2026

概述

本 PR 包含 4 个相互独立的修复(本地代码审计结论),每个 commit 一个 scope,便于分开 review。

1. fix(core) — 规划阶段校验 actionSpace

  • 新增 assertPlannedActionInActionSpace,并在 llm-planningbuildYamlFlowFromPlans 中使用。
  • 改前: LLM 可能返回当前设备不支持的 action 名;buildYamlFlowFromPlansconsole.warn 并跳过;要到 TaskBuilder 执行阶段才失败,且可能多消耗规划轮次。
  • 改后: 非法 action 类型立即抛错,错误信息中会列出当前 actionSpace 内可用 action。
  • 已在 llm-planning.test.ts 增加单测。

2. fix(core) — 报告 HTML 模板注入

  • apps/report/dist/index.html 不存在:保持原有 warn 并跳过注入(monorepo 中 @midscene/report 依赖 @midscene/core,须先 build core,不能在此处 hard fail)。
  • 若模板 存在 但注入后 dist 仍含 REPLACE_ME_WITH_REPORT_HTML构建失败并给出明确错误,避免把坏报告打进产物。
  • 增加 core → report 的 Nx dependsOn(会与 report → core 形成循环构建依赖)。

3. fix(playground) — 默认监听地址

  • Playground 默认由 0.0.0.0 改为 127.0.0.1,降低局域网误暴露未鉴权 /execute 等接口的风险。
  • 可选放开:
    • MIDSCENE_PLAYGROUND_ALLOW_REMOTE=1 → 监听 0.0.0.0
    • MIDSCENE_PLAYGROUND_HOST=<host> → 自定义绑定地址
  • 文档: 本次 更新 apps/site/docs 站点文档;变量说明见根目录 .env.example。如需中英文站点补充,可另开 doc PR。

4. chore(workflow) — Windows 开发体验

  • 根目录 cleanrm -rf 改为跨平台 scripts/clean.mjs
  • 新增 .env.example.gitignore 中增加 !.env.example),列出 MIDSCENE_MODEL_* 与 Playground 相关 env。

测试说明

  • 对改动文件执行 npx biome check(7 个文件,无问题)
  • packages/corepnpm exec vitest run tests/unit-test/llm-planning.test.ts(53 passed)
  • pnpm run build(建议 merge 前跑全量构建)
  • npx nx test @midscene/core(可选;Windows 上部分超时用例与本次改动无关)

给 Reviewer 的说明

  • 行为变更: buildYamlFlowFromPlans 对未知 action 由「warn 并跳过」改为 抛错(与 TaskBuilder 行为一致)。
  • Playground 环境变量仅在 .env.example 中说明,未改文档站,有意控制 PR 体积。

付焦方(Fu Jiaofang) added 4 commits May 22, 2026 13:57
Add assertPlannedActionInActionSpace and use it in llm-planning and
buildYamlFlowFromPlans so invalid action types throw during planning
instead of after extra LLM rounds or at TaskBuilder execution.
…s placeholder

Keep warn-and-skip when apps/report/dist is missing (core builds before
report in the monorepo graph). Throw only if index.html is present yet
dist still contains REPLACE_ME_WITH_REPORT_HTML after injection.
Listen on localhost unless MIDSCENE_PLAYGROUND_ALLOW_REMOTE=1 or
MIDSCENE_PLAYGROUND_HOST is set, reducing accidental LAN exposure of
unauthenticated /execute APIs.
Replace rm -rf clean with scripts/clean.mjs for Windows. Add .env.example
(unignored via !.env.example) with MIDSCENE_MODEL_* and playground env hints.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant