feat: add authenticated HWLAB web probe scripts

This commit is contained in:
Codex
2026-06-16 00:44:11 +00:00
parent c552e2e2bc
commit 06c813f35e
4 changed files with 397 additions and 18 deletions
+14
View File
@@ -165,6 +165,20 @@ PW
`playwright` 读取 stdin heredoc,在目标 host/workload 上注入临时 `playwright-cli` wrapper,并把远端 run 目录中的截图/PDF 回传到本机 `--local-dir`,默认 `/tmp`。多步登录、创建 session、发送消息和 trace 截图应写在同一个 heredoc 中,并显式等待登录 API response 与稳定 selector;不要只靠宽泛 input selector 或页面标题判断登录成功。
HWLAB node/lane 的 authenticated Cloud Web Playwright 验收优先使用受控入口,而不是手写 secret 读取和登录脚本:
```bash
bun scripts/cli.ts hwlab nodes web-probe script --node D601 --lane v03 <<'JS'
export default async ({ page, goto, screenshot }) => {
await page.route('**/v1/agent/conversations**', route => setTimeout(() => route.continue(), 3000));
await goto('/workbench');
return { finalUrl: page.url(), screenshot: await screenshot('workbench.png') };
};
JS
```
这个入口由 UniDesk CLI 从 YAML 声明的 bootstrap admin sourceRef 读取凭据、调用同源 `/auth/login` 建立 `hwlab_session`、向自定义脚本传入已认证的 `browser/context/page/baseUrl` 和 artifact helper,并且输出只披露 sourceRef、fingerprint、cookie presence、artifact path/hash 和脚本 JSON 结果。只有非 HWLAB、无需 node/lane sourceRef,或确实需要 `--local-dir` 自动下载截图/PDF 时,才优先使用上面的 `trans <provider> playwright`
### kubectl / logsk3s 诊断)
```bash