diff --git a/assets/malo-browser/icon.png b/assets/malo-browser/icon.png new file mode 100644 index 00000000..1141de8d Binary files /dev/null and b/assets/malo-browser/icon.png differ diff --git a/external_plugins/malo-browser/.codex-plugin/plugin.json b/external_plugins/malo-browser/.codex-plugin/plugin.json new file mode 100644 index 00000000..c3c41ca7 --- /dev/null +++ b/external_plugins/malo-browser/.codex-plugin/plugin.json @@ -0,0 +1,34 @@ +{ + "name": "malo-browser", + "version": "0.2.0", + "description": "Agent browser runtime and scripted web demo tool: a daemon hands out port leases with isolated, profile-backed browser sessions that agents drive through 27 session tools (snapshots with iframe content, typed input, login handoff, network capture), plus a visible Electron stage, hidden 1080p30 recording with evidence files, a director console and a loopback control API.", + "author": { + "name": "Lumos-789", + "url": "https://github.com/Lumos-789" + }, + "homepage": "https://github.com/Lumos-789/malo-browser", + "repository": "https://github.com/Lumos-789/malo-browser", + "license": "MIT", + "keywords": [ + "agent-browser", + "browser-automation", + "browser", + "electron", + "agent", + "daemon", + "demo", + "codex" + ], + "skills": "./skills/", + "interface": { + "displayName": "Malo Browser", + "shortDescription": "An agent browser runtime with a scripted demo tool", + "longDescription": "Malo Browser is an agent browser runtime: its daemon hands out loopback port leases, each lease hosts isolated, profile-backed browser sessions with persistent login state, and agents drive them through 27 session tools - structured snapshots with iframe content, clicks, typed input, assertions, login handoff windows and network capture. The same app runs a scripted Electron stage for live web demos with hidden 1920x1080@30fps recording, evidence files, a director console and a loopback control API.", + "developerName": "Lumos-789", + "category": "Developer Tools", + "capabilities": [ + "Read", + "Run commands" + ] + } +} diff --git a/external_plugins/malo-browser/.zcode-plugin/plugin.json b/external_plugins/malo-browser/.zcode-plugin/plugin.json new file mode 100644 index 00000000..711dfd01 --- /dev/null +++ b/external_plugins/malo-browser/.zcode-plugin/plugin.json @@ -0,0 +1,27 @@ +{ + "name": "malo-browser", + "version": "0.2.0", + "description": "Agent browser runtime and scripted web demo tool: a daemon hands out port leases with isolated, profile-backed browser sessions that agents drive through 27 session tools (snapshots with iframe content, typed input, login handoff, network capture), plus a visible Electron stage, hidden 1080p30 recording with evidence files, a director console and a loopback control API.", + "description_i18n": { + "en": "Agent browser runtime and scripted web demo tool: a daemon hands out port leases with isolated, profile-backed browser sessions that agents drive through 27 session tools (snapshots with iframe content, typed input, login handoff, network capture), plus a visible Electron stage, hidden 1080p30 recording with evidence files, a director console and a loopback control API.", + "zh-CN": "agent 浏览器运行时兼脚本化网页演示工具:守护进程按端口发放租约,提供隔离且可复用登录态的 session,agent 用 27 个 session 工具驱动(含 iframe 内容的快照、逐字输入、登录交接、网络抓包);另有可见的 Electron 演示舞台、无头 1080p30 录制与证据文件、导演控制台与本地控制 API。" + }, + "author": { + "name": "Lumos-789", + "url": "https://github.com/Lumos-789" + }, + "homepage": "https://github.com/Lumos-789/malo-browser", + "repository": "https://github.com/Lumos-789/malo-browser", + "license": "MIT", + "keywords": [ + "agent-browser", + "browser-automation", + "electron", + "browser", + "agent", + "daemon", + "demo", + "recording" + ], + "skills": "skills" +} diff --git a/external_plugins/malo-browser/CHANGELOG.md b/external_plugins/malo-browser/CHANGELOG.md new file mode 100644 index 00000000..8f9303df --- /dev/null +++ b/external_plugins/malo-browser/CHANGELOG.md @@ -0,0 +1,471 @@ +# Changelog + +## 0.2.0 + +一次完整 review 后的修复与补齐:运行时的稳定性、边界与 agent 工具层。含三处契约变更,见末尾。 + +会话生命周期 + +- **会话关闭时页面真的被销毁。**此前只关窗口,页面视图连同渲染进程一直活到 daemon 退出 + (实测 0 会话时仍挂着 4 个渲染进程约 460MB)。匿名会话的磁盘数据因此也能在关闭时清掉。 +- **页面在会话之外被销毁时会话自行收尾。**典型是经 CDP 调试口关掉页面目标:此前关会话的流程 + 会在中途抛错、走不到关窗口,窗口成僵尸,daemon 退出时给已死页面换宿主抛未捕获异常(2026-11-26 + 日志里的致命错误)。现在记一条 `page.destroyed`、归还名额,之后访问它得到带原因的 404。 +- **daemon 不再因为某个会话里的未捕获异常整体退出。**异常连同完整栈记进日志,其余 agent 的会话 + 不受影响;录制、跑场景这些一次性进程照旧出错即退出。 +- **窗口显示给人的会话所属租约到期宽限。**此前「窗口显示给人看就不回收」只在会话层,租约层 + 5 分钟没请求就连同人正在用的窗口一起收走。新增 `--visible-grace-seconds`(默认 1800,0 = 不宽限)。 +- Python 客户端默认起后台线程续租(按 TTL 的三分之一),`release()` 时停;心跳失败后的调用带原因 + 报「租约已失效」。 + +边界 + +- **CDP 调试口。**启动时醒目告警(它没有鉴权:本机任何进程连上都能操作这个 daemon 的全部会话与 + 已登录档案),`/health` 暴露 `debug_port`;客户端的 `open_session` 不再默认要求调试口,必须显式传。 + 这条通道保持可用但不再是无感默认。 +- **登录态导入 `domains` 必填。**不填等于把源浏览器里所有站点的登录态整包搬进来,不再是默认值。 +- **`focus: true` 默认拒绝。**daemon 以 `--allow-focus` 启动才接受;窗口默认只以不抢焦点的方式出现。 +- **登录态档案。**上限 64 → 256(本机已用 43);启动时清掉闲置 profile 的网页缓存 + (`--profile-cache-idle-hours`,默认 72;实测数据目录 3.3G 里 95% 是缓存);可选按天数过期删除 + (`--profile-ttl-days`,默认关);`profiles` 新增 `prune`(默认只预览,`apply=true` 才删); + 登记文件损坏时明确报错;profile 的互斥锁与「创建中」登记改为全 daemon 一份,跨租约并发 + 清理 / 创建同名档案不再竞态;清理时分区目录删不干净报 `E_PROFILE_CLEAR_FAILED` 且保留登记。 +- **会话级权限白名单。**创建会话时给 `permissions` 逐项放开 11 项页面权限(剪贴板、全屏、定位、 + 通知、摄像头麦克风等),其余默认拒绝;能打开外部应用、读写文件系统、抓屏、碰硬件的权限不可放开。 + +Agent 工具 + +- **iframe 内容可见可操作。**`snapshot.frames` 列出所有看得见的 iframe(带序号与位置)并在层数、 + 数量上限内返回嵌套内容——同源、跨域(独立进程)、多层嵌套都读得到。`click` / `fill` / `hover` / + `select` / `focus` / `scroll` / `scroll_into_view` / `wait_for` / `upload_file` / `extract` / `assert` + 新增 `frame` 与 `frame_url`,在指定 iframe 里操作,坐标自动换算到顶层视口。同源 iframe 里可以 + 上传文件,跨域的明确拒绝。 +- **人工交接按钮。**watch 窗口的工具条新增「完成 / 暂停 / 停止」:完成由 `wait_for {"human":true}` + 或 watch 模式的 `login` 取走;暂停、停止期间动页面的工具返回 409(`E_PAUSED_BY_HUMAN` / + `E_STOPPED_BY_HUMAN`),观察类不受影响。会话摘要带 `human` 状态。 +- **按键。**命名键(回车、Tab、方向键、F1–F12 等)补齐虚拟键码,只认 keyCode 的页面收得到; + 可打印键带 Shift 语义;修饰键位掩码的含义写进工具说明。新增 `type`:逐字符发按键事件。 +- **滚轮。**落点从视口左上角 (10,10) 改为视口中心(后台页面左侧的固定导航栏不再被误滚),可用 + x / y 指定落点;返回前等滚动位置稳定。 +- **`snapshot`。**新增 `widgets` 分区(tab、option、menuitem、switch 等靠 role 表达语义的组件)与 + `sections` 参数(只采集点名的分区);`interactive[].rect` 的 x/y 改为中心点,另给 `left` / `top`。 +- **弹窗。**`window.open` 仍不开新窗口,但目标地址记进事件并随触发它的动作结果返回 + (`popup.url` / `popup.adopted`);创建会话时给 `popup=adopt` 可让弹窗地址在当前页面打开。 +- **事件留档。**会话事件同时追加到 `artifacts/events.jsonl`(写满 5 MiB 后只补一条截停标记), + 创建会话的响应带 `events_log`;`events` 分页返回 `next_after` 游标与 `dropped` 断档数。 +- `history` 动作改用 `navigationHistory`(原接口已弃用)。 + +客户端与工程 + +- Python 客户端:`session.call` 按工具在 daemon 侧的最长等待推算超时(此前固定 120 秒,人机登录 + 一定客户端先超时),读超时不再混进「连不上」;日志走 stderr;`daemon_args` / `MALO_DAEMON_ARGS` + 在冷启动时追加 daemon 参数;本仓比运行中的 daemon 新且它没有租约时自动重启让新代码生效。 + 新增离线用例 `npm run test:client`。 +- `malo-smoke` 默认自起临时数据目录的隔离 daemon,跑完即停;不再碰正式的 `~/.malo-browser`。 + 新增实验页与 iframe 页,覆盖上述全部行为。 +- 会话核心 `browser-session.ts` 从 1833 行拆到 526 行:导航、观察、快照、提取、断言、登录、动作 + 各自成模块。 +- daemon 日志的租约行带 agent 名;技能说明与两份插件清单改为 agent 运行时打头;工具参考拆成 + `docs/malo-tools.md`。 + +契约变更 + +- `snapshot` 的 `interactive[].rect`:`x` / `y` 由左上角改为元素**中心**(与 `extract mode=rect` + 一致);左上角改用 `left` / `top`。 +- `POST /v1/profiles/:name/import` 的 `domains` 由可选改为必填。 +- `watch` / `login` 的 `focus: true` 默认被拒绝(400),需要 daemon 以 `--allow-focus` 启动。 + +验证:399 单元测试、19 条客户端离线用例、typecheck、隔离 daemon 真浏览器 smoke、工具条 smoke 全绿。 + +## 0.1.18 + +- **租约按持有者隔离。**`POST /v1/leases` 新增可选 `holder`(1-128 字符):带了它的 + 请求只和「同 `agent_id` + 同 `holder`」的租约复用。此前同 agent 名的多个进程共用 + 一个租约,先跑完的 `release` 会把并行进程的会话一起放掉。Python 客户端 + `acquire_lease` 自动带进程级 holder,并要求 daemon 具备 `lease.holder` 能力 + (`features` 新增该项);不带 holder 的调用沿用按 agent 名复用,两者互不接管。 +- **并发冷启动只拉起一个 daemon。**客户端 `ensure_daemon` 加数据目录级启动锁, + 就绪判据从「端口开着」改为「broker.json 的 token 被运行中的 daemon 认」——端口被 + 别的进程占着、文件里是陈旧 token 时明确报错并给出排查命令,不再拉起也不复用。 + daemon 侧加 Electron 单实例锁,多出来的进程在碰任何存储之前退出。此前 N 个进程 + 同时冷启动会拉起 N 个 Electron、N-1 个因端口冲突退出。 +- **长操作不再被回收腰斩。**租约上还有请求在处理中时到期不回收而是续一期;有操作 + 正在进行、或窗口显示给人看的 session 不被空闲回收。关闭 session 时进行中的操作 + 立刻以 `E_SESSION_NOT_FOUND` 失败,不挂在已销毁的页面上。此前一条跑得比 TTL 长的 + 请求会让连接直接断开、客户端拿不到任何诊断。 +- **人关掉窗口不结束会话。**页面视图换一个隐藏窗口接着托管,事件流记一条 + `window.closed`,下次 `watch` 原样弹回。此前窗口销毁后 `watch` 静默无效,还回报 + `window: "shown"`。窗口只在第一次显示时居中,之后位置归人管(拖动过的不被拉回)。 +- **工具条按需创建。**agent 驱动的隐藏会话不再预建工具条渲染进程,到第一次给人看 + 时才建,页面视口不变。 +- **限额与启动清扫。**每 lease 默认 session 数 4→16(`--max-sessions`),新增 daemon + 全局上限 `--max-sessions-total`(默认 64),`GET /v1/state` 带 `session_budget`。 + 每次启动清掉上次运行遗留的匿名 partition 与超过 `--artifact-ttl-hours`(默认 168) + 的租约目录:匿名 partition 在会话关闭时仍被 Chromium 握着、进程退出前又写回来, + 此前无界累积。profile 的 partition 永不触碰。 +- `GET /v1/sessions` 的会话摘要新增 `visible`(窗口此刻是否显示在屏幕上)。 + +## 0.1.17 + +- **`.codex-plugin/plugin.json` 描述对齐 `.zcode-plugin`。**Codex 清单的 description + 停在 agent runtime 加入前的措辞(没提 profile 持久登录态、26 个 session 工具与 + 网络抓包),`interface.shortDescription` / `longDescription` 同步补上 daemon 的 + 隔离会话与工具数。 +- **防漂移测试:**`.codex-plugin` 的 description 必须与 `.zcode-plugin` 逐字相同, + 且其中的 session 工具数 === MALO_TOOLS 长度。运行时无改动。 + +## 0.1.16 + +- **extract `max_chars` 上限三处对齐:0-2000000。**0.1.13 回流时 dispatch(tools.ts + readInteger)与 session 钳制(browser-session)已提到 2M,MALO_TOOLS 清单滞留 + 20000——超 20k 的调用在清单层是非法值而实现允许。清单改 2000000 对齐,默认 4000 + 不变。 +- **两道防漂移测试:**① extract 清单上限 === dispatch 校验上限(上限值原样放行、 + 越界 400 报错点名同一上界);② `.zcode-plugin` 三处 description(英文 / + i18n.en / i18n.zh-CN)的 session 工具数 === MALO_TOOLS 长度——0.1.14 新增 drag + 后曾漏改 25→26,靠发版前 review 才抓到。 +- **publicLease 双份实现合并:**daemon.ts 与 broker-server.ts 的同形函数留 + broker-server 一份导出,daemon 改 import(依赖方向不变,签名收窄为 + version/features/leaseTtlSeconds 结构参数)。 + +## 0.1.15 + +- 新图标:1-bit 黑白像素家族视觉——马喽背影坐在 CRT 前看浏览器窗口;六插件共享 + 同一像素家族。无代码改动。 + +## 0.1.14 + +- **fill 落地链:回执以元素真实值为准,不再报假成功。**判例是 ep014 抖音发布页作品 + 标题框——受控组件吞掉合成输入,fill 两次回 `filled 19 chars` 而值从未落地。现在 + 正路(click 聚焦 + selectAll/Backspace + CDP insertText)打完先回读元素值: + 没落地换 JS `el.focus()` 重打;再不行用原生 value setter + `input`/`change` 事件 + 注入(React/Vue 受控组件的标准通路,绕过输入管线);三层之后仍不符报 + `E_FILL_NOT_LANDED`(HTTP 400,非敏感字段带期望/实际值证据)。密码框的值比对在 + 页面内完成只回 boolean——校验可用且明文永不回传(extract/assert 的脱敏口径不变)。 + `verify:false` 显式关闭校验,留给会改写输入的页面。 +- **新增 `drag` action:按下 → 插值移动 → 释放。**滑块/裁切框这类监听 pointer/mouse + 序列的自定义组件靠逐步事件驱动,一步跳到位不触发;`from_x/from_y/to_x/to_y` 四坐标 + + `steps`(1-100,默认 12,步进带间隔),CDP `Input.dispatchMouseEvent` 全程左键。 +- **`click` 支持按可见文本定位:`text` + `nth`。**子串匹配、最内层可见元素优先(父容器 + 因包含子文本也会命中,点叶子才准);与 `selector` 同给时 selector 是搜索范围。专治 + 无类名无 id 的裸 span(判例:抖音内容管理的「编辑作品」入口)。 +- **`extract` 新增 `mode: "rect"`。**返回元素盒子,`x/y` 为中心点可直接喂给 + click/drag;`left/top/width/height` 齐全。此前 rect 只有 snapshot 的 interactive + 才带,非交互元素(裸 span/滑块轨道)取不到坐标。 +- **fixture 增「发布实验室」**:覆盖层吞点击的受控输入(fill 兜底链靶场)、pointer + 滑块(drag 靶场)、裸 span 按钮(click text 靶场);smoke 补五段断言(兜底落地 + 19/30 计数、不可填元素 E_FILL_NOT_LANDED 负控、裸 span 点击、rect 提取、拖到 80% + 档)。单测 291 绿(+3:drag CDP 序列、drag/extract rect manifest、text/verify 路由)。 + +## 0.1.13 + +- **可见窗口一律带原生标题栏,行为一致。**演示舞台(scene 演示 / phase0 spike)与 + 录制窗此前是无边框窗口,与本轮定下的桌面准则冲突——「只要前台就要有框、Dock + 能选到」。现在 `StageWindow` 默认 `frame: true`(显式传 `frame: false` 才无框, + 全仓无人再传),phase0 舞台同样改带框;`watch` / `login` 人工接管窗、Director + 窗原本就有框,不受影响。录制与截图产物只取页面内容,是否有框不影响画面。 + 动态 Dock(0.1.9)对演示舞台 `inactive` / `focused` 模式同样生效。 +- **回流部署端 0.1.8 的 daemon 改进(tools/common 仓先行两 commit,此前未回流)。** + - 租约按活动续期:lease 收到任何已鉴权请求即续期,长批任务不会跑到 TTL 被收走 + 端口;`--idle-exit-seconds=`(默认 1800,0=不退出)让无租约且无请求的 daemon + 自行退出并清理 broker.json。 + - 版本能力握手:`/health`(broker 与 lease 两级)返回 `version` + `features` + (由 observe schema 推导),客户端可在启动前判断能力(如 + `observe.screenshot_clip`)。lease `/health` 保持不鉴权且不泄露 + `lease_id` / `agent_id`(沿用 0.1.12 审查定谳的信息最小化口径)。 + - `--proxy-server=`:app ready 前挂 Chromium 浏览器级代理开关,daemon 各 + session / partition 生效。 + - `extract` 的 `max_chars` 上限 20 000 → 2 000 000(部署端并行会话先行改动, + 随本轮回流;`observe` 的 20 000 上限不变)。 + - `observe` 的 `clip_selector`(只截某个元素,0.1.8 前部署端先行功能)回流: + `observe(mode=screenshot, clip_selector)` 与 `GET /observe?clip_selector=` 均可, + 返回 `screenshot_clip` 实裁矩形;选择器不存在/尺寸 0 → `E_SELECTOR_NOT_FOUND` + 不静默退回整屏。业务侧(yewu-shot)依赖 `/health` 的 + `observe.screenshot_clip` 能力位做启动前校验,此前源码仓缺此功能导致能力位为空。 + +## 0.1.12 + +- **登录态导入的坏帧不再能炸掉 daemon。**`POST /v1/profiles/:name/import` 连接源 CDP + 的 WebSocket 后,一条非 JSON 文本帧或二进制帧会在 `onmessage` 里抛 `SyntaxError` 并 + 升级为进程级 uncaughtException——daemon 的 fatal 处理走 `app.exit(2)`,整个进程连同 + 所有 lease/session 一起下桌。现在坏帧只废掉本次 import:以 + `E_IMPORT_SOURCE_UNREACHABLE`(502)reject 并关闭连接,进程存活。 +- **`webSocketDebuggerUrl` 连接前补回环复核。**该地址来自源端点 `/json/version` 响应, + 此前只校验了 HTTP `cdp_url` 的回环边界就直接连 WS,「loopback only」安全边界在 WS + 这一跳有个缺口。现在与 `cdp_url` 同口径复核 hostname,非 + 127.0.0.1 / localhost / ::1 直接 400 `E_BAD_REQUEST` 拒绝,且不发起 WS 连接。 +- **`clearProfile` 与并发 `create` 同名 profile 的竞态消除。**此前 clearProfile 入口读 + 一次 `activeCount` 后,在 clearStorageData / clearCache / 删分区目录 / 删记录的 await + 窗口里穿插同名 create,新 session 会落进正被清空的分区、profiles.json 记录被删、磁盘 + 留孤儿分区。现在按 profile 名做进程内互斥:clear 的「占用检查+清理」关键段与 create + 的「登记占用」段共用同一把锁,create 在启动 BrowserSession 之前先登记「即将占用」, + clear 因此看得见还没 touch 的并发 create(报 `E_PROFILE_LOCKED`),create 失败即撤销 + 登记不空拒后续 clear。 +- **`extract` 的 `attributes` 逐项校验、fail-loud。**此前非字符串条目被 filter 静默 + 丢弃,与同文件 `domains` / `url_prefixes` / `upload_file.files` 的逐项 400 口径不一致; + 现在任一非字符串/空串条目直接 400 `E_BAD_REQUEST` 并点名非法项。 + +## 0.1.11 + +- **文档与实现对齐(无行为变化)。**`SKILL.md` 不再把 login 的自动隐藏写到 `watch` + 头上——`watch` 窗口保持可见直到显式再调 `watch`(`show:false`)收起,`login` + 成功才自动隐藏(`keep_visible: true` 例外),与两版 README 一致;`docs/malo-browser.md` + 登录交接规则里的同款失实一并改正,并补上 0.1.8 起存在的 + `POST /v1/profiles/:name/import`(说明 + curl 示例);`README_CN.md` 补译英文版 + 0.1.8 起就有的「Profile 登录态导入」整章(参数、返回字段、错误码、隐私边界); + `login-import.ts` 去掉两个无外部消费者的 `export` 修饰符。 + +## 0.1.10 + +- **`POST /v1/profiles/:name/import` 的 `domains` 改为逐项校验、fail-loud。**此前 + `[""]` / `[123]` 这类非法条目会被静默过滤成空数组,而空数组在域过滤层等于「匹配 + 所有域」——即调用方以为只迁指定域的 cookie,实际全量导入了所有域(隐私边界被击穿)。 + 现在任一非法条目直接 400 `E_BAD_REQUEST` 并点名非法项;`domains` 传非数组或空数组 + 仍报 400。同时把 `.zcode-plugin` / `.codex-plugin` manifest 与 `package-lock.json` + 根版本从滞留的 0.1.7 同步到当前版本,`SKILL.md` 动作工具枚举补上 0.1.7 新增的 + `upload_file`。 + +## 0.1.9 + +- **Human-visible windows now get a Dock icon while they are on screen.** The daemon + keeps running as an accessory app exactly as before (no Dock icon, no focus stealing, + no programmatic activation), but the moment a session window is shown for a human + (`watch` / login handoff) the macOS Dock icon appears, so a window buried behind + other apps can be raised again by clicking it; the icon disappears once no visible + window is left. Offscreen and ghost windows never surface an icon and recordings + stay fully headless. The only focus change is the one the user makes by clicking + the Dock icon. + +## 0.1.8 + +- **New profile login import: `POST /v1/profiles/:name/import`.** Seeds a persistent + profile with cookies read live from another Chromium's DevTools endpoint + (`cdp_url`, loopback `http://` only), so a logged-in daily Chrome hands its login + state to a malo profile without re-typing credentials. The daemon connects to the + source browser-level WebSocket, calls `Storage.getCookies`, and writes each cookie + through the Electron cookie store of the target partition — this crosses the + Chrome/Electron keychain encryption boundary that makes raw profile-file copies + unreadable. Optional `domains` allowlist filters which cookies move (equal, + subdomain, or parent matches); `session_cookie_ttl_days` (default 180) re-stamps + session cookies as persistent so imported logins survive daemon restarts (`0` keeps + them session-only). The response reports + `cookies_total / cookies_matched / cookies_written / cookies_failed` with up to 20 + per-cookie errors (e.g. `__Host-` prefix rejections). Import merges, never clears; + only cookies move (localStorage / IndexedDB stay in the source). Source unreachable + → 502 `E_IMPORT_SOURCE_UNREACHABLE`; zero matched cookies → 400 `E_IMPORT_EMPTY`. + +## 0.1.7 + +- **New `upload_file` tool.** Sets files on an `input[type=file]` through CDP + `DOM.setFileInputFiles`, so the input may stay visually hidden; a site whose upload + button opens a native picker still needs that button clicked first. `selector` must + match an input and `files` are absolute paths on the host running the browser. A + missing selector fails as `E_SELECTOR_NOT_FOUND` (400 on the lease endpoint) like the + other action tools, and the tool is allowed inside `run_steps`. The manifest now + declares 25 session tools. + +## 0.1.6 + +Full review pass; every item below was reproduced before fixing. + +### Isolation and security + +- **Shared-profile sessions no longer cross-wire downloads or network state.** Electron + keeps one `webRequest` listener and one permission handler per session, and + `will-download` fires for every webContents in the partition. Two sessions on the same + `profile` used to fight over `setSavePath` (a download started in A could land in B's + `downloads/`) and the newer session silently disabled the older one's failure + tracking. Handlers are now installed once per Electron session and dispatched by + webContents id (`src/main/malo/partition-hooks.ts`); a download with no owner is + cancelled. +- **The demo stage now blocks redirects, not just navigations.** Server-side 3xx emits + `will-redirect`, which was never hooked, so an allowlisted origin could 302 to an + arbitrary one and the remaining steps ran there. Both events share one gate now. +- **`goto` obeys the scene allowlist.** `webContents.loadURL` does not emit + `will-navigate`, so tool-initiated navigation was unchecked; the runner now asks the + host policy first (`assertNavigationAllowed`). +- **`${env:NAME}` is limited to `SCENE_*`.** A third-party scene could interpolate any + `process.env` value (cloud keys, tokens) into a URL or form field, and the allowlist + was declared by that same scene. All three interpolation implementations share the + same rule now (the third one, `interpolateScene`, had no guard at all). +- **`demo://` validates the scene id.** The protocol handler used the URL segment as the + containment root, so `demo://scene/..%2Fprivate%2Fcredential.json` served files one + level above the scenes root. It now applies `SCENE_ID_PATTERN`, and a 404 no longer + echoes the resolved filesystem path to the page. +- **`--data-dir=~/.malo-browser` actually expands `~`** instead of creating a literal `~` + directory (`--out` and `--scenes` too). +- Data dir and session dirs are created 0700; run reports, failure screenshots and + encoded takes are 0600 (the legacy evidence writer was 0644). +- `GET /health` on a lease endpoint no longer enumerates `lease_id` / `agent_id` + without a token. + +### Recording and evidence + +- **A rejected take no longer claims "no video was written"** while a playable mp4 sits + on disk: the failed-evidence warning names the file and says it failed self-checks. +- Frame temp dirs (`-frames`, `-seq`) are cleaned even when encoding is + rejected, so a failed take stops leaving hundreds of JPEGs behind. +- `ffmpeg` / `ffprobe` now run with timeouts (120s metadata probe, 250ms/frame encode, + 20min ceiling) and are killed instead of hanging `stop()` forever. Whole-file decode + passes (blackdetect, ssim) scale their timeout with the video length, so a long take + is not failed by a flat cap; a buffer overflow reports itself instead of posing as a + timeout. +- `capture.timeline_frames` reports the encoder's slot count instead of duplicating + `video.frames`. +- The `steps_completed` / `steps_within_take` checks only consider steps executed inside + the take; borrowing the whole scene's step list could pass a take that ran nothing. +- A failed evidence write no longer leaves the recorder stuck in "recording". + +### Demo pipeline + +- **Director shortcuts can no longer kill the app.** Every shortcut rejection used to + reach the process-level `unhandledRejection` handler, which calls `app.exit()`; a + routine "no scene loaded" or "nothing to step back to" ended the session. Shortcuts now + surface the error in the UI. +- **`goto` / `login` no longer break every later visual step.** Navigation drops the + injected overlay, and only load/switch re-injected it, so `goto` → `click` failed with + `TypeError: … reading 'click'`. The overlay is now installed on demand (and re-injected + after navigation as a best-effort step, so a landing page that redirects again cannot + fail the take); `reset` / `stop` / `prev` recover too. +- `recorder.start` refuses while a scene is still loading instead of recording a + half-initialised page. +- `runner.load()` is awaited, removing the load/start race that surfaced as + "场景尚未就绪" on slow or redirected scenes. +- A failed `scene.load` no longer leaks an untracked `BaseWindow`. +- The documented-but-rejected scene fields now parse: `fill.target_text`, + `press.modifiers`, and x/y coordinates for `click` / `fill` / `highlight` / + `spotlight` / `mask` (and `target_text` survives normalization instead of being + dropped). +- `scroll.behavior: smooth` is implemented; `annotate.position` now places the label + where it says. +- Director step indexing uses one convention (last executed step), so a paused run no + longer shows the completed step as both "current" and "next"; `app.error` no longer + inherits a stale step index and screenshot. +- Blackout state is cleared on scene load and on a same-URL scene switch; leaving + fullscreen re-applies the active scene's viewport instead of the pre-fullscreen one. + +### Tools + +- Action errors no longer carry the code twice + (`E_SELECTOR_NOT_FOUND: E_SELECTOR_NOT_FOUND: …`). +- A selector with invalid syntax is `E_BAD_REQUEST` (400) on every tool instead of a + misleading `E_STEP_TIMEOUT` (504). +- `extract` with an invalid selector is a 4xx instead of HTTP 200 with `count: 0` and an + undeclared `error` field. +- `assert value` on a password input is rejected; comparing the redacted literal made + `value: "[redacted]"` pass regardless of the real value. +- `press` validates the key name instead of reporting success for `Enterr`. +- `run_steps` rejects `login` (it can open a handoff window and type credentials) as the + docs always claimed, and the docs now also list `close`. +- `network_capture` recovers after a failed `Network.disable` instead of being stuck. +- `ProfileStore` writes recover after one failed write instead of failing forever. + +### Docs and packaging + +- README/README_CN corrected where they contradicted the code: download policy (the agent + runtime accepts downloads into the session dir, it does not need a scene policy), + password redaction (`snapshot` returns `""` + `sensitive`, `[redacted]` is the + interactive text), failed-step screenshots (only `assert`), `--data-dir=~`, and the + scene-variable/`SCENE_` rule. +- `docs/malo-browser.md`: mutually exclusive login success heuristic, partition dir + without the `persist:` prefix, updated `run_steps` blocklist, new permission/mode notes. +- The published field contract `schemas/scene.schema.json` accepts the same step fields + as the runtime (`target_text`, `modifiers`, coordinate targets), and a unit test now + fails when the two schemas drift apart — that drift is how the fields became + documented-but-rejected in the first place. +- `SKILL.md`: `EADDRINUSE` advice distinguishes control / broker / lease, invalid + selector is `E_BAD_REQUEST`, added `E_NAV_BLOCKED` and the `SCENE_` rule. +- `package.json` `files` now ships `docs/` and `schemas/`, which the bundled skill links + to (the DSH bundle is still installed from the prebuilt Release tarball because `out/` + is gitignored); `scripts/pack-dsh-bundle.sh` stages the same two directories. +- `package-lock.json` root version caught up with `package.json`. + +Tests: 232 → 254. + +## 0.1.5 + +- `scripts/pack-dsh-bundle.sh` builds and packs the prebuilt DSH bundle attached + to the GitHub release. The DSH plugin is installed from that asset, because + `out/` is gitignored and a source install would leave `index.js` pointing at a + compiled entry that does not exist yet. + +- Added the `network_capture` and `responses` session tools: subscribe to URL prefixes, + navigate/interact, then poll the captured XHR/fetch response bodies. Capture reuses the + page driver's single CDP attach (no second debugger, no focus change); the Network + domain is enabled lazily with 64 MiB/8 MiB response buffers and disabled when the + subscription clears. +- Records keep every response's metadata in one 500-entry window, while bodies are kept + only for subscribed hits up to 200 records and a 16 MiB budget. Each body is capped at + 1 MiB (`body_truncated`); base64 payloads report `body_error: "binary"` instead of a + lossy UTF-8 decode, and queued bodies report `"pending"`. Query envelopes use + `has_more`, not `truncated`, so they cannot be confused with `body_truncated`. +- Capture state is session-private and in memory only: bodies never reach logs, evidence, + traces or run reports, and `MaloNetworkInfo` is unchanged. A capture subsystem failure + surfaces as `E_CAPTURE_UNAVAILABLE` (`ok: false`) instead of an empty list. + +## 0.1.4 + +- `--mode=record` now leaves failed evidence for every pre-encode throw, including + opening the stage. An unreachable page writes `/