Skip to content

The fastest browser for AI agents to run browser automation, built for sharing your logged-in browser state with your AI agents, like Codex or Claude Code, without disturbing you. Zero cost, zero config.

docs: clarify snapshot ref notation

Autebf353b24389d
diff --git a/docs/runtime-v2-architecture.md b/docs/runtime-v2-architecture.md
index 7e827c5..b1591ed 100644
--- a/docs/runtime-v2-architecture.md
+++ b/docs/runtime-v2-architecture.md
@@ -68,9 +68,11 @@ CDP session、事件缓冲、dialog 状态和 Network domain 状态都按 target
### 3.3 Page-scoped refs
-原生 snapshot 返回的 ref 仍使用 `@N` 形式。运行时按 targetId 保存 ref map:
+原生 snapshot 把 ref 显示为 `[ref=N, ...]`。Page 动作接受 `ref=N` 或 `@N`,但
+不接受包含方括号的完整注解。运行时按 targetId 保存 ref map:
- `page.click('@21')` 只在该 Page 的 map 中解析。
+- `page.click('ref=21')` 与上面的写法等价。
- 新进程第一次使用 ref 时,如果该 Page 没有 map,运行时会先对该 Page 重拍
snapshot。
- ref 不存在时直接报错,不会切到其他页面寻找同号 ref。
diff --git a/package/ego-browser/src/ref-map.test.mjs b/package/ego-browser/src/ref-map.test.mjs
new file mode 100644
index 0000000..323e438
--- /dev/null
+++ b/package/ego-browser/src/ref-map.test.mjs
@@ -0,0 +1,11 @@
+import test from "node:test";
+import assert from "node:assert/strict";
+
+import { parseRef } from "../dist/src/ref-map.js";
+
+test("parseRef accepts action forms but not the full snapshot annotation", () => {
+ assert.equal(parseRef("@21"), "21");
+ assert.equal(parseRef("ref=21"), "21");
+ assert.equal(parseRef("21"), "21");
+ assert.equal(parseRef("[ref=21]"), null);
+});
diff --git a/skills/ego-browser/SKILL.md b/skills/ego-browser/SKILL.md
index 5221322..7311609 100644
--- a/skills/ego-browser/SKILL.md
+++ b/skills/ego-browser/SKILL.md
@@ -128,12 +128,12 @@ Use `page.snapshot()` first for ordinary DOM pages. It returns full-page semanti
```js
const text = await page.snapshot();
console.log(text);
-// After inspecting the output, use a real @N from it with this same Page.
+// For a node shown as [ref=21, ...], pass @21 or ref=21 without the brackets.
```
Page actions accept these selectors:
-- `@N` refs such as `@21`
+- refs such as `@21`, or the `ref=21` portion displayed by snapshot
- stable `loc=css:`, `loc=role:`, and `loc=href:` values returned by snapshot
- `xpath=...`
- raw CSS selectors