@xiaoqiong0v0/opencode-browser-tool 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,6 +34,23 @@ export function getProfilesDir() {
34
34
  export function getProfileDir(name) {
35
35
  return resolve(getProfilesDir(), name);
36
36
  }
37
+ // ---- 会话隔离(1.9.0):每会话独立 shell 实例的数据目录 ----
38
+ // 路径: <cacheDir>/sessions/<profile>/<sid>
39
+ // 说明: 需求字面为 sessions/<sid>;此处多一层 <profile>,是为了保住 `profile --set` 的语义 ——
40
+ // 它现在的含义是「影响**后续新会话**的数据根(默认 profile)」,运行中的实例不受影响。
41
+ // 若要严格字面路径,去掉 profile 段即可(会话间隔离不受影响,只是 profile 失去作用)。
42
+ /** 会话数据根目录 */
43
+ export function getSessionsDir() {
44
+ return resolve(getCacheDir(), "sessions");
45
+ }
46
+ /** 某会话的独立 user-data-dir(WebView2 profile:cookie/localStorage/缓存全隔离) */
47
+ export function getSessionDataDir(sid) {
48
+ return resolve(getSessionsDir(), getActiveProfile(), sid);
49
+ }
50
+ /** 某会话的临时产物目录(截图落盘等;不再与其它会话/全局 tmp 共享) */
51
+ export function getSessionTmpDir(sid) {
52
+ return resolve(getSessionDataDir(sid), "tmp");
53
+ }
37
54
  /** 导出目录(用户从 Edge/Chrome 导出的密码 CSV / 书签 HTML) */
38
55
  export function getExportsDir() {
39
56
  return resolve(getCacheDir(), "exports");
@@ -89,9 +106,8 @@ function applyConfigFile(config, filePath) {
89
106
  .replace(/\/\/.*$/gm, "")
90
107
  .replace(/\/\*[\s\S]*?\*\//g, "")
91
108
  .replace(/,\s*}/g, "}");
109
+ // 只读取已知键:旧文件里的 browserType / sessionIsolation 等已移除项会被自然忽略(兼容,不报错)
92
110
  const fileConfig = JSON.parse(json);
93
- if (fileConfig.browserType !== undefined)
94
- config.browserType = fileConfig.browserType;
95
111
  if (fileConfig.browsersPath !== undefined)
96
112
  config.browsersPath = fileConfig.browsersPath;
97
113
  if (fileConfig.nodePath !== undefined)
@@ -102,8 +118,6 @@ function applyConfigFile(config, filePath) {
102
118
  config.toolLang = fileConfig.toolLang;
103
119
  if (fileConfig.disabledTools)
104
120
  config.disabledTools = fileConfig.disabledTools;
105
- if (fileConfig.sessionIsolation !== undefined)
106
- config.sessionIsolation = fileConfig.sessionIsolation;
107
121
  if (fileConfig.cacheDir !== undefined)
108
122
  config.cacheDir = fileConfig.cacheDir;
109
123
  }
@@ -144,20 +158,18 @@ function generateDefaultConfig(filePath) {
144
158
  // "browsersPath": "D:/browsers/chromium",
145
159
 
146
160
  // 缓存根目录(可选,默认 ~/.opencode/plugins-cache/opencode-browser-tool)
147
- // 下设 user-data/<profile> 用户配置、exports 导出、tmp 临时密码文件
161
+ // 下设 sessions/<profile>/<sid> 每会话独立浏览器数据、user-data/<profile> 旧目录、
162
+ // exports 导出、tmp 临时密码文件
148
163
  // "cacheDir": "D:/browser-cache",
149
164
 
150
165
  // 禁用的工具列表(可选,工具名不加 bt_ 前缀)
151
166
  // "disabledTools": ["close", "custom_user_agent"],
152
167
 
153
- // 会话隔离:为子会话创建独立 BrowserContext(默认 false,全部共享)
154
- // "sessionIsolation": false,
168
+ // 1.9.0 起「每会话独立浏览器实例」为唯一行为(原 sessionIsolation 开关从未生效,已移除);
169
+ // browserType 同理移除(--browser 从不被 bt-shell 解析)。旧配置里若仍写着这两项会被忽略。
155
170
 
156
171
  // Node.js 路径(可选,不设则从 PATH 查找 node)
157
172
  // "nodePath": "C:/Program Files/nodejs/node.exe",
158
-
159
- // 浏览器类型: "chromium" | "firefox" | "webkit"(默认 chromium)
160
- // "browserType": "firefox",
161
173
  }
162
174
  `, "utf-8");
163
175
  }
package/dist/i18n/en.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const en = {
2
2
  tool: {
3
- "tool.cli.desc": "Browser automation via a CLI-style dispatcher: pass a single command string, e.g. \"navigate --url https://...\" or \"help\". Omit to list all commands. screenshot with --selector scrolls the element into view first.",
3
+ "tool.cli.desc": "Browser automation via a CLI-style dispatcher: pass a single command string, e.g. \"navigate --url https://...\" or \"help\". Omit to list all commands. screenshot with --selector scrolls the element into view first. The browser process is managed automatically by this tool — do not run the bt-shell executable directly (it causes multiple instances and file-lock conflicts).",
4
4
  "tool.cli.arg.args": "Command line string: \"<command> [--flag value ...]\", e.g. \"navigate --url https://...\" (\"help\" lists all)",
5
5
  "cli.header": "bt_cli — browser automation CLI",
6
6
  "cli.usage": "Usage: bt_cli({ args })\n args single command line string: \"<command> [--flag value ...]\"",
@@ -12,25 +12,26 @@ const en = {
12
12
  "cli.example.4": "bt_cli({ args: \"fill --selector #q --value \\\"hello world\\\"\" })",
13
13
  "cli.unknown": "Unknown command: {cmd}",
14
14
  "cli.invalid_args": "Invalid args for {cmd}: {msg}",
15
+ "cli.err.timeout_invalid": "--timeout must be a positive integer in ms (100-60000), got: {v}",
15
16
  "cli.failed": "Command {cmd} failed: {msg}",
16
17
  "cli.cmd.navigate": "Navigate browser to a URL",
17
- "cli.cmd.click": "Click an element",
18
- "cli.cmd.fill": "Fill an input field",
19
- "cli.cmd.clear": "Clear an input field",
20
- "cli.cmd.select": "Select a dropdown option",
21
- "cli.cmd.hover": "Hover over an element",
22
- "cli.cmd.drag": "Drag element to a target",
23
- "cli.cmd.press_key": "Press a keyboard key",
24
- "cli.cmd.upload_file": "Upload a file to an input",
25
- "cli.cmd.screenshot": "Take a screenshot (returns image attachment; with --selector it scrolls the element into view first)",
26
- "cli.cmd.evaluate": "Execute JS in the page, return result",
18
+ "cli.cmd.click": "Click an element; optional --timeout ms (100-60000) caps this call's wait budget, timeout errors explicitly",
19
+ "cli.cmd.fill": "Fill an input field; optional --timeout ms (100-60000) caps this call's wait budget, timeout errors explicitly",
20
+ "cli.cmd.clear": "Clear an input field; optional --timeout ms (100-60000) caps this call's wait budget, timeout errors explicitly",
21
+ "cli.cmd.select": "Select a dropdown option; optional --timeout ms (100-60000) caps this call's wait budget, timeout errors explicitly",
22
+ "cli.cmd.hover": "Hover over an element; optional --timeout ms (100-60000) caps this call's wait budget, timeout errors explicitly",
23
+ "cli.cmd.drag": "Drag element to a target; optional --timeout ms (100-60000) caps this call's wait budget, timeout errors explicitly",
24
+ "cli.cmd.press_key": "Press a keyboard key; optional --timeout ms (100-60000) caps this call's wait budget, timeout errors explicitly",
25
+ "cli.cmd.upload_file": "Upload a file to an input; optional --timeout ms (100-60000) caps this call's wait budget, timeout errors explicitly",
26
+ "cli.cmd.screenshot": "Take a screenshot (returns image attachment; with --selector it scrolls the element into view first); optional --timeout ms (100-60000) caps this call's wait budget, timeout errors explicitly",
27
+ "cli.cmd.evaluate": "Execute JS in the page, return result; optional --timeout ms (100-60000) caps this call's wait budget, timeout errors explicitly",
27
28
  "cli.cmd.get_visible_text": "Get visible page text",
28
29
  "cli.cmd.get_visible_html": "Get page HTML structure",
29
30
  "cli.cmd.console_logs": "Get browser console logs",
30
31
  "cli.cmd.go_back": "Go back in history",
31
32
  "cli.cmd.go_forward": "Go forward in history",
32
- "cli.cmd.resize": "Resize the viewport",
33
- "cli.cmd.set_device": "Apply device preset (no name = list presets)",
33
+ "cli.cmd.resize": "Resize the page content area (viewport, not the OS window; window height = content + 72px toolbar; min 360x360, smaller values are clamped)",
34
+ "cli.cmd.set_device": "Apply device preset (no name = list presets; preset sizes are content-area/viewport sizes)",
34
35
  "cli.cmd.devtools": "Open/close devtools (open/close/toggle)",
35
36
  "cli.cmd.reload": "Reload the current page",
36
37
  "cli.cmd.open_window": "Open the browser window",
@@ -39,20 +40,20 @@ const en = {
39
40
  "cli.cmd.scroll": "Scroll the page",
40
41
  "cli.cmd.wait_for_selector": "Wait for an element to appear",
41
42
  "cli.cmd.click_and_switch_tab": "Click a link and switch to the new tab",
42
- "cli.cmd.iframe_click": "Click an element inside an iframe",
43
- "cli.cmd.iframe_fill": "Fill an input inside an iframe",
43
+ "cli.cmd.iframe_click": "Click an element inside an iframe; optional --timeout ms (100-60000) caps this call's wait budget, timeout errors explicitly",
44
+ "cli.cmd.iframe_fill": "Fill an input inside an iframe; optional --timeout ms (100-60000) caps this call's wait budget, timeout errors explicitly",
44
45
  "cli.cmd.get_browser_status": "Check if browser is open and current page",
45
46
  "cli.cmd.list_tabs": "List all open tabs",
46
47
  "cli.cmd.switch_tab": "Switch to a tab by index",
47
48
  "cli.cmd.new_tab": "Open a new tab",
48
49
  "cli.cmd.close_tab": "Close a tab (omit = current)",
49
- "cli.cmd.get_element_state": "Element exists/visible/size/state",
50
- "cli.cmd.scroll_to_element": "Scroll until element is visible",
51
- "cli.cmd.get_dropdown_options": "List dropdown options",
50
+ "cli.cmd.get_element_state": "Element exists/visible/size/state; optional --timeout ms (100-60000) caps this call's wait budget, timeout errors explicitly",
51
+ "cli.cmd.scroll_to_element": "Scroll until element is visible; optional --timeout ms (100-60000) caps this call's wait budget, timeout errors explicitly",
52
+ "cli.cmd.get_dropdown_options": "List dropdown options; optional --timeout ms (100-60000) caps this call's wait budget, timeout errors explicitly",
52
53
  "cli.cmd.custom_user_agent": "Set a custom User-Agent",
53
54
  "cli.cmd.expect_response": "Start expecting an HTTP response pattern",
54
55
  "cli.cmd.assert_response": "Check if expected response matched",
55
- "cli.cmd.get_accessibility_tree": "Get the accessibility tree",
56
+ "cli.cmd.get_accessibility_tree": "Get the accessibility tree; optional --timeout ms (100-60000) caps this call's wait budget, timeout errors explicitly",
56
57
  "cli.cmd.list_records": "List annotation records in the panel",
57
58
  "cli.cmd.read_record_content": "Read an annotation record by id",
58
59
  "cli.cmd.fake_audio": "Inject audio into fake mic (tone/seq/dtmf/noise/audio/ambient/stop)",
@@ -60,6 +61,109 @@ const en = {
60
61
  "cli.cmd.profile": "List/switch/delete user profiles (--set <name> restarts browser; --delete removes a non-default, non-active profile)",
61
62
  "cli.cmd.exports": "Show export dir + how to export Edge/Chrome passwords/bookmarks",
62
63
  "cli.cmd.lookup": "Find a password in a CSV export, return @file: path (not in context)",
64
+ // ---- Diagnostic notes appended to command output ----
65
+ "cli.note.degraded": " (degraded: {reason})",
66
+ "cli.note.not_ready": " (not ready after {ms}ms{rs})",
67
+ "cli.note.scroll_unstable": " (scroll position not stable after {ms}ms)",
68
+ "cli.note.reached": " (element reached={where} after {ms}ms{why})",
69
+ "cli.note.beyond": " (element larger than viewport, captured beyond viewport)",
70
+ "cli.note.timeout_clamped": " (clamped to {ms}ms)",
71
+ // ---- Command result strings ----
72
+ "cli.out.navigate.install_failed": "Installation failed: {error}. Retry.",
73
+ "cli.out.navigate.installing": "Installing {name} ({progress}). Try again.",
74
+ "cli.out.navigate.ok": "Navigated to: {url}",
75
+ "cli.out.click": "Clicked",
76
+ "cli.out.fill": "Filled",
77
+ "cli.out.clear": "Cleared",
78
+ "cli.out.select": "Selected",
79
+ "cli.out.hover": "Hovered",
80
+ "cli.out.drag": "Dragged",
81
+ "cli.out.press_key": "Pressed: {key}",
82
+ "cli.out.upload_file": "Uploaded",
83
+ "cli.out.screenshot": "Screenshot taken{where}",
84
+ "cli.out.screenshot.element": " (element: {sel})",
85
+ "cli.out.screenshot.fullpage": " (full page)",
86
+ "cli.out.no_visible_text": "(no visible text)",
87
+ "cli.out.no_visible_html": "(no visible html)",
88
+ "cli.out.html_truncated": "…(truncated at maxLength={n})",
89
+ "cli.out.no_logs": "(no logs)",
90
+ "cli.out.go_back": "Went back, current URL: {url}",
91
+ "cli.out.go_forward": "Went forward, current URL: {url}",
92
+ "cli.out.resize": "Resized content to {w}x{h}",
93
+ "cli.out.resize_clamped": " (clamped to 360x360 minimum)",
94
+ "cli.out.device_list_header": "Available device presets:",
95
+ "cli.out.device_applied": "Device preset applied: {name} ({w}x{h} content)\nUser-Agent: {ua}",
96
+ "cli.out.devtools_open": "Devtools opened",
97
+ "cli.out.devtools_closed": "Devtools closed",
98
+ "cli.out.reload": "Page reloaded: {url}",
99
+ // Fallback when the backend response carries no url (no last-navigated URL on the tab) — keeps output from showing undefined
100
+ "cli.out.reload_nourl": "Page reloaded",
101
+ "cli.out.open_window": "Browser window opened",
102
+ "cli.out.close_already": "Browser already closed",
103
+ "cli.out.close_done": "Browser closed",
104
+ "cli.out.notify_shown": "Notification shown",
105
+ "cli.out.scroll": "Scrolled {dir} by {n}px",
106
+ "cli.out.wait_appeared": "Element appeared",
107
+ "cli.out.click_switch_tab": "Clicked {sel}, current URL: {url}",
108
+ "cli.out.iframe_click": "Clicked in iframe",
109
+ "cli.out.iframe_fill": "Filled in iframe",
110
+ "cli.out.status.not_running": "Browser is not running.\nbt-shell: {bin}\n(Any other tool call will start it; or use open_window. If you have closed the browser, use open_window)",
111
+ "cli.out.status.installing": "Installing {list}.",
112
+ "cli.out.status.not_open": "Browser is not open. Use command=open_window or navigate.",
113
+ "cli.out.status.open": "Browser is open\nTitle: {title}\nURL: {url}\nTabs: {n}",
114
+ "cli.out.tabs_none": "(no tabs)",
115
+ "cli.out.tabs_header": "Tabs ({n}):",
116
+ "cli.out.switch_tab": "Switched to tab #{i}: {url}",
117
+ "cli.out.new_tab": "New tab opened: {url}",
118
+ "cli.out.close_tab": "Closed tab #{i}",
119
+ "cli.out.close_tab_current": "Closed current tab",
120
+ "cli.out.element_not_found": "Element not found: {sel}",
121
+ "cli.out.element_state": "Element <{tag}>: {sel}\nVisible: {visible}{text}\nRect: {rect}",
122
+ "cli.out.scroll_to_element": "Scrolled to element",
123
+ "cli.out.dropdown_none": "Select not found or no options: {sel}",
124
+ "cli.out.ua_set": "User-Agent set",
125
+ "cli.out.expect_response": "Now expecting response matching: {url}. Use command=assert_response to check.",
126
+ "cli.out.assert_matched": "Response matched: {url} ({status})",
127
+ "cli.out.assert_none": "No response yet",
128
+ "cli.out.no_ax": "(no accessibility info)",
129
+ "cli.out.no_records": "(no records)",
130
+ "cli.out.record_not_found": "(record #{id} not found)",
131
+ "cli.out.record_image": "\nimage: {kb}KB base64",
132
+ "cli.out.record_image_saved": "\nimage: {kb}KB base64 (saved: {path})",
133
+ "cli.out.record_note_none": "(none)",
134
+ "cli.out.fake_audio": "Fake mic audio: {injected}",
135
+ "cli.out.fake_video": "Fake camera video: {injected}",
136
+ "cli.out.profile_no_delete_default": "Cannot delete the default profile",
137
+ "cli.out.profile_no_delete_active": "Cannot delete the active profile; switch to another first (profile --set <name>)",
138
+ "cli.out.profile_not_found": "Profile not found: {name}",
139
+ "cli.out.profile_deleted": "Deleted profile: {name}",
140
+ "cli.out.profile_switched": "Switched default profile: {name} (affects browsers of NEW sessions only; running sessions are unaffected)",
141
+ "cli.out.profiles_none": "(no profiles yet)",
142
+ "cli.out.profiles_header": "Profiles:\n{list}\n\nActive: {active}\nSwitch: profile --set <name> (restarts browser, current tabs lost)\nDelete: profile --delete <name> (not default/active)",
143
+ "cli.out.exports": "Export directory: {dir}\n\nHow to export from Edge/Chrome:\n Passwords: Settings → Profiles → Passwords → ⋯ → Export passwords (CSV)\n Bookmarks: Settings → Profiles → Bookmarks → ⋯ → Export (HTML)\nPlace the exported files in the directory above, then the model can read them.\n\nRead passwords without leaking into context:\n lookup --csv <file.csv> --url <site>\n fill --selector <input> --value @file:<path>",
144
+ "cli.out.lookup_usage": "Usage: lookup --csv <path> --url <site>",
145
+ "cli.out.lookup_found": "Found: {user} @ {url}\nUse: fill --selector <input> --value @file:{tmp}\n(password in temp file, deleted after use)",
146
+ "cli.out.lookup_none": "No entry found for: {url}",
147
+ "cli.out.media_mode": "Media mode: {mode}",
148
+ "cli.read_file_failed": "Cannot read @file: {path}: {msg}",
149
+ // ---- Binary status (describeBinaryStatus; never embeds local absolute paths) ----
150
+ "bin.ready": "bt-shell is ready",
151
+ "bin.downloading": "bt-shell is downloading ({progress}%)… retry later",
152
+ "bin.failed": "bt-shell download failed: {reason}; set BT_SHELL_DOWNLOAD_BASE to change mirror, or BT_SHELL_PATH to point at a binary",
153
+ "bin.disabled": "bt-shell auto-download is disabled (BT_SHELL_NO_DOWNLOAD=1); set BT_SHELL_PATH to a binary (expected path is in the plugin log)",
154
+ "bin.unsupported": "bt-shell does not support this platform yet: {reason}",
155
+ "bin.not_ready": "bt-shell is not ready yet, retry later",
156
+ "bin.release_not_found": "No Release asset found for this version (tag={tag}); for a plugin-only change make sure the binary is still attached to the x.Y.0 Release, and for Rust changes bump the minor version and create/update that Release first",
157
+ // ---- client-layer errors surfaced to the model ----
158
+ "client.service_timeout": "Browser service not ready (timed out). bt-shell is managed automatically by the plugin — do not run the executable directly. Retry via bt_cli later (e.g. open_window).",
159
+ "client.attach_timeout": "External bt-shell at {url} is not ready (timed out). Check BT_SHELL_URL/BT_SHELL_PORT and that the shell is running.",
160
+ "client.not_configured": "Service not configured",
161
+ "client.service_error": "Service error",
162
+ "client.bt_shell_path_missing": "BT_SHELL_PATH points to a binary that does not exist (path is in the environment variable)",
163
+ "client.spawn_failed": "Failed to start the bt-shell process (retry via bt_cli later; do not run the executable directly)",
164
+ "client.session_closed_during_start": "Session was closed while the browser was starting; that instance was recycled (not registered). Call the tool again to reopen.",
165
+ "client.attach_gone": "Attached external bt-shell at {url} is gone (attach mode does not own that process; restart the shell yourself).",
166
+ "client.browser_closed": "Browser is closed. Call open_window to open it first, then retry.",
63
167
  "tool.set_media_mode.desc": "Switch camera/microphone mode: 'simulate' (fake devices, default) or 'real' (real devices, falls back to simulate if unavailable). Call without mode to query the current mode.",
64
168
  "tool.set_media_mode.arg.mode": "Mode: simulate or real (omit to query current)",
65
169
  },
@@ -1,17 +1,34 @@
1
1
  import { getConfig } from "../config/index.js";
2
+ import en from "./en.js";
2
3
  const _strings = {};
3
4
  /** 注册语言包 */
4
5
  export function registerLocale(lang, strings) {
5
6
  _strings[lang] = strings;
6
7
  }
8
+ /** 惰性兜底:任何入口(binary.ts 独立运行等)未走插件注册时至少有 en 可用,不输出裸键 */
9
+ function ensureFallback() {
10
+ if (!_strings.en)
11
+ _strings.en = en;
12
+ }
7
13
  /** 获取工具描述翻译 */
8
14
  export function t(key, lang) {
15
+ ensureFallback();
9
16
  const l = lang || getConfig().toolLang;
10
17
  const str = _strings[l] || _strings.en;
11
18
  return str?.tool[key] || _strings.en?.tool[key] || key;
12
19
  }
20
+ /** 取工具文案并替换 `{name}` 占位符(缺失键回退 en,再缺返回键名本身,不崩溃) */
21
+ export function tf(key, vars, lang) {
22
+ let s = t(key, lang);
23
+ if (vars) {
24
+ for (const [k, v] of Object.entries(vars))
25
+ s = s.split(`{${k}}`).join(String(v));
26
+ }
27
+ return s;
28
+ }
13
29
  /** 获取面板 UI 翻译 */
14
30
  export function panelT(key, lang) {
31
+ ensureFallback();
15
32
  const l = lang || getConfig().panelLang;
16
33
  const str = _strings[l] || _strings.en;
17
34
  return str?.panel[key] || _strings.en?.panel[key] || key;
package/dist/i18n/zh.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const zh = {
2
2
  tool: {
3
- "tool.cli.desc": "CLI 风格的浏览器自动化控制:单个字符串命令行,如 \"navigate --url https://...\" 或 \"help\"。省略列出全部命令。screenshot 带 --selector 会先自动滚动到元素再截取。",
3
+ "tool.cli.desc": "CLI 风格的浏览器自动化控制:单个字符串命令行,如 \"navigate --url https://...\" 或 \"help\"。省略列出全部命令。screenshot 带 --selector 会先自动滚动到元素再截取。浏览器进程由本工具自动管理;请勿直接执行 bt-shell 可执行文件(会造成多实例与文件锁冲突)。",
4
4
  "tool.cli.arg.args": "命令行字符串:\"<command> [--flag 值 ...]\",如 \"navigate --url https://...\"(\"help\" 列出全部)",
5
5
  "cli.header": "bt_cli — 浏览器自动化 CLI",
6
6
  "cli.usage": "用法: bt_cli({ args })\n args 单个命令行字符串: \"<command> [--flag 值 ...]\"",
@@ -12,25 +12,26 @@ const zh = {
12
12
  "cli.example.4": "bt_cli({ args: \"fill --selector #q --value \\\"hello world\\\"\" })",
13
13
  "cli.unknown": "未知命令: {cmd}",
14
14
  "cli.invalid_args": "参数无效 {cmd}: {msg}",
15
+ "cli.err.timeout_invalid": "--timeout 须为正整数(毫秒,100~60000),收到:{v}",
15
16
  "cli.failed": "命令 {cmd} 失败: {msg}",
16
17
  "cli.cmd.navigate": "导航浏览器到 URL",
17
- "cli.cmd.click": "点击页面元素",
18
- "cli.cmd.fill": "填写输入框",
19
- "cli.cmd.clear": "清空输入框",
20
- "cli.cmd.select": "选择下拉框选项",
21
- "cli.cmd.hover": "悬停到元素",
22
- "cli.cmd.drag": "拖拽元素到目标",
23
- "cli.cmd.press_key": "按下键盘按键",
24
- "cli.cmd.upload_file": "上传文件到输入框",
25
- "cli.cmd.screenshot": "截取页面/元素截图(返回图片;--selector 会先滚动到元素再截取)",
26
- "cli.cmd.evaluate": "在页面执行 JS,返回结果",
18
+ "cli.cmd.click": "点击页面元素;可选 --timeout ms(100~60000)限定本次等待上限,超时明确报错",
19
+ "cli.cmd.fill": "填写输入框;可选 --timeout ms(100~60000)限定本次等待上限,超时明确报错",
20
+ "cli.cmd.clear": "清空输入框;可选 --timeout ms(100~60000)限定本次等待上限,超时明确报错",
21
+ "cli.cmd.select": "选择下拉框选项;可选 --timeout ms(100~60000)限定本次等待上限,超时明确报错",
22
+ "cli.cmd.hover": "悬停到元素;可选 --timeout ms(100~60000)限定本次等待上限,超时明确报错",
23
+ "cli.cmd.drag": "拖拽元素到目标;可选 --timeout ms(100~60000)限定本次等待上限,超时明确报错",
24
+ "cli.cmd.press_key": "按下键盘按键;可选 --timeout ms(100~60000)限定本次等待上限,超时明确报错",
25
+ "cli.cmd.upload_file": "上传文件到输入框;可选 --timeout ms(100~60000)限定本次等待上限,超时明确报错",
26
+ "cli.cmd.screenshot": "截取页面/元素截图(返回图片;--selector 会先滚动到元素再截取);可选 --timeout ms(100~60000)限定本次等待上限,超时明确报错",
27
+ "cli.cmd.evaluate": "在页面执行 JS,返回结果;可选 --timeout ms(100~60000)限定本次等待上限,超时明确报错",
27
28
  "cli.cmd.get_visible_text": "获取页面可见文本",
28
29
  "cli.cmd.get_visible_html": "获取页面 HTML 结构",
29
30
  "cli.cmd.console_logs": "获取浏览器控制台日志",
30
31
  "cli.cmd.go_back": "浏览器后退",
31
32
  "cli.cmd.go_forward": "浏览器前进",
32
- "cli.cmd.resize": "调整视口尺寸",
33
- "cli.cmd.set_device": "应用设备预设(不带 name 列出预设)",
33
+ "cli.cmd.resize": "调整页面内容区尺寸(视口,非 OS 窗口;自动折算窗口高+工具栏 72px;下限 360×360,低于下限会被钳制)",
34
+ "cli.cmd.set_device": "应用设备预设(不带 name 列出预设;预设尺寸为内容区(视口)尺寸)",
34
35
  "cli.cmd.devtools": "打开/关闭开发者工具(open/close/toggle)",
35
36
  "cli.cmd.reload": "刷新当前页面",
36
37
  "cli.cmd.open_window": "打开浏览器窗口",
@@ -39,20 +40,20 @@ const zh = {
39
40
  "cli.cmd.scroll": "滚动页面",
40
41
  "cli.cmd.wait_for_selector": "等待元素出现",
41
42
  "cli.cmd.click_and_switch_tab": "点击链接并切换到新标签",
42
- "cli.cmd.iframe_click": "在 iframe 内点击元素",
43
- "cli.cmd.iframe_fill": "在 iframe 内填写输入框",
43
+ "cli.cmd.iframe_click": "在 iframe 内点击元素;可选 --timeout ms(100~60000)限定本次等待上限,超时明确报错",
44
+ "cli.cmd.iframe_fill": "在 iframe 内填写输入框;可选 --timeout ms(100~60000)限定本次等待上限,超时明确报错",
44
45
  "cli.cmd.get_browser_status": "检查浏览器是否打开及当前页面",
45
46
  "cli.cmd.list_tabs": "列出所有打开的标签",
46
47
  "cli.cmd.switch_tab": "按索引切换标签",
47
48
  "cli.cmd.new_tab": "打开新标签",
48
49
  "cli.cmd.close_tab": "关闭标签(省略=当前)",
49
- "cli.cmd.get_element_state": "元素存在/可见/尺寸/状态",
50
- "cli.cmd.scroll_to_element": "滚动到元素可见",
51
- "cli.cmd.get_dropdown_options": "列出下拉框选项",
50
+ "cli.cmd.get_element_state": "元素存在/可见/尺寸/状态;可选 --timeout ms(100~60000)限定本次等待上限,超时明确报错",
51
+ "cli.cmd.scroll_to_element": "滚动到元素可见;可选 --timeout ms(100~60000)限定本次等待上限,超时明确报错",
52
+ "cli.cmd.get_dropdown_options": "列出下拉框选项;可选 --timeout ms(100~60000)限定本次等待上限,超时明确报错",
52
53
  "cli.cmd.custom_user_agent": "设置自定义 User-Agent",
53
54
  "cli.cmd.expect_response": "开始监听 HTTP 响应模式",
54
55
  "cli.cmd.assert_response": "检查期望响应是否匹配",
55
- "cli.cmd.get_accessibility_tree": "获取可访问性树",
56
+ "cli.cmd.get_accessibility_tree": "获取可访问性树;可选 --timeout ms(100~60000)限定本次等待上限,超时明确报错",
56
57
  "cli.cmd.list_records": "列出面板批注记录",
57
58
  "cli.cmd.read_record_content": "按 id 读取批注记录",
58
59
  "cli.cmd.fake_audio": "向 fake 麦克风注入音频(tone/seq/dtmf/noise/audio/ambient/stop)",
@@ -60,6 +61,109 @@ const zh = {
60
61
  "cli.cmd.profile": "列出/切换/删除用户配置(--set <name> 重启浏览器;--delete 删除非 default、非当前激活配置)",
61
62
  "cli.cmd.exports": "显示导出目录 + Edge/Chrome 密码/书签导出引导",
62
63
  "cli.cmd.lookup": "在密码 CSV 中查找站点,返回 @file: 路径(密码不进上下文)",
64
+ // ---- 诊断型 note(命令输出的追加说明) ----
65
+ "cli.note.degraded": " (已降级: {reason})",
66
+ "cli.note.not_ready": " ({ms}ms 内未就绪{rs})",
67
+ "cli.note.scroll_unstable": " ({ms}ms 内滚动位置未稳定)",
68
+ "cli.note.reached": " (元素到达: {where}, {ms}ms{why})",
69
+ "cli.note.beyond": " (元素大于视口,已越界截全)",
70
+ "cli.note.timeout_clamped": " (已按边界钳制为 {ms}ms)",
71
+ // ---- 命令结果文案 ----
72
+ "cli.out.navigate.install_failed": "安装失败:{error}。请重试。",
73
+ "cli.out.navigate.installing": "正在安装 {name}({progress})。请稍后重试。",
74
+ "cli.out.navigate.ok": "已导航到: {url}",
75
+ "cli.out.click": "已点击",
76
+ "cli.out.fill": "已填写",
77
+ "cli.out.clear": "已清空",
78
+ "cli.out.select": "已选择",
79
+ "cli.out.hover": "已悬停",
80
+ "cli.out.drag": "已拖拽",
81
+ "cli.out.press_key": "已按键: {key}",
82
+ "cli.out.upload_file": "已上传",
83
+ "cli.out.screenshot": "截图完成{where}",
84
+ "cli.out.screenshot.element": "(元素: {sel})",
85
+ "cli.out.screenshot.fullpage": "(整视口)",
86
+ "cli.out.no_visible_text": "(无可见文本)",
87
+ "cli.out.no_visible_html": "(无可见 HTML)",
88
+ "cli.out.html_truncated": "…(已在 maxLength={n} 处截断)",
89
+ "cli.out.no_logs": "(无日志)",
90
+ "cli.out.go_back": "已后退,当前 URL: {url}",
91
+ "cli.out.go_forward": "已前进,当前 URL: {url}",
92
+ "cli.out.resize": "内容区已调整为 {w}x{h}",
93
+ "cli.out.resize_clamped": "(已钳制到下限 360x360)",
94
+ "cli.out.device_list_header": "可用设备预设:",
95
+ "cli.out.device_applied": "已应用设备预设: {name}({w}x{h} 内容区)\nUser-Agent: {ua}",
96
+ "cli.out.devtools_open": "开发者工具已打开",
97
+ "cli.out.devtools_closed": "开发者工具已关闭",
98
+ "cli.out.reload": "页面已刷新: {url}",
99
+ // 后端返回体无 url(Rust 侧标签无最后导航 URL)时的降级文案,避免输出 undefined
100
+ "cli.out.reload_nourl": "页面已刷新",
101
+ "cli.out.open_window": "浏览器窗口已打开",
102
+ "cli.out.close_already": "浏览器已关闭",
103
+ "cli.out.close_done": "浏览器已关闭",
104
+ "cli.out.notify_shown": "通知已显示",
105
+ "cli.out.scroll": "已向{dir}滚动 {n}px",
106
+ "cli.out.wait_appeared": "元素已出现",
107
+ "cli.out.click_switch_tab": "已点击 {sel},当前 URL: {url}",
108
+ "cli.out.iframe_click": "已在 iframe 内点击",
109
+ "cli.out.iframe_fill": "已在 iframe 内填写",
110
+ "cli.out.status.not_running": "浏览器未运行。\nbt-shell: {bin}\n(执行任意其它工具会自动启动;也可用 open_window 显式启动。若已手动关闭,请用 open_window)",
111
+ "cli.out.status.installing": "正在安装 {list}。",
112
+ "cli.out.status.not_open": "浏览器未打开。请用 command=open_window 或 navigate。",
113
+ "cli.out.status.open": "浏览器已打开\n标题: {title}\nURL: {url}\n标签数: {n}",
114
+ "cli.out.tabs_none": "(无标签)",
115
+ "cli.out.tabs_header": "标签({n}):",
116
+ "cli.out.switch_tab": "已切换到标签 #{i}: {url}",
117
+ "cli.out.new_tab": "已打开新标签: {url}",
118
+ "cli.out.close_tab": "已关闭标签 #{i}",
119
+ "cli.out.close_tab_current": "已关闭当前标签",
120
+ "cli.out.element_not_found": "未找到元素: {sel}",
121
+ "cli.out.element_state": "元素 <{tag}>: {sel}\n可见: {visible}{text}\n矩形: {rect}",
122
+ "cli.out.scroll_to_element": "已滚动到元素",
123
+ "cli.out.dropdown_none": "未找到 select 或无可选项: {sel}",
124
+ "cli.out.ua_set": "User-Agent 已设置",
125
+ "cli.out.expect_response": "开始监听匹配: {url}。用 command=assert_response 检查。",
126
+ "cli.out.assert_matched": "响应匹配: {url}({status})",
127
+ "cli.out.assert_none": "尚无响应",
128
+ "cli.out.no_ax": "(无可访问性信息)",
129
+ "cli.out.no_records": "(无记录)",
130
+ "cli.out.record_not_found": "(记录 #{id} 不存在)",
131
+ "cli.out.record_image": "\n图片: {kb}KB base64",
132
+ "cli.out.record_image_saved": "\n图片: {kb}KB base64(已保存: {path})",
133
+ "cli.out.record_note_none": "(无说明)",
134
+ "cli.out.fake_audio": "模拟麦克风音频: {injected}",
135
+ "cli.out.fake_video": "模拟摄像头画面: {injected}",
136
+ "cli.out.profile_no_delete_default": "不能删除默认配置",
137
+ "cli.out.profile_no_delete_active": "不能删除当前激活配置;请先切换到其它配置(profile --set <name>)",
138
+ "cli.out.profile_not_found": "未找到配置: {name}",
139
+ "cli.out.profile_deleted": "已删除配置: {name}",
140
+ "cli.out.profile_switched": "已切换默认配置: {name}(仅影响后续新会话的浏览器;正在运行的会话不受影响)",
141
+ "cli.out.profiles_none": "(暂无配置)",
142
+ "cli.out.profiles_header": "配置:\n{list}\n\n当前: {active}\n切换: profile --set <name>(重启浏览器,当前标签会丢失)\n删除: profile --delete <name>(非 default、非当前激活)",
143
+ "cli.out.exports": "导出目录: {dir}\n\n如何从 Edge/Chrome 导出:\n 密码: 设置 → 个人资料 → 密码 → ⋯ → 导出密码(CSV)\n 书签: 设置 → 个人资料 → 书签 → ⋯ → 导出(HTML)\n把导出的文件放到上面的目录,然后模型可以直接读取。\n\n不把密码读进上下文的用法:\n lookup --csv <file.csv> --url <site>\n fill --selector <input> --value @file:<path>",
144
+ "cli.out.lookup_usage": "用法: lookup --csv <路径> --url <站点>",
145
+ "cli.out.lookup_found": "找到: {user} @ {url}\n用法: fill --selector <input> --value @file:{tmp}\n(密码在临时文件中,用完即删)",
146
+ "cli.out.lookup_none": "未找到匹配项: {url}",
147
+ "cli.out.media_mode": "媒体模式: {mode}",
148
+ "cli.read_file_failed": "无法读取 @file: {path}: {msg}",
149
+ // ---- 二进制状态(describeBinaryStatus;不含任何本机绝对路径) ----
150
+ "bin.ready": "bt-shell 已就绪",
151
+ "bin.downloading": "bt-shell 正在下载({progress}%)… 稍后重试",
152
+ "bin.failed": "bt-shell 下载失败:{reason};可用 BT_SHELL_DOWNLOAD_BASE 换源,或用 BT_SHELL_PATH 手动指定二进制",
153
+ "bin.disabled": "bt-shell 自动下载已禁用(BT_SHELL_NO_DOWNLOAD=1);请设置 BT_SHELL_PATH 指定二进制(期望路径见插件日志)",
154
+ "bin.unsupported": "bt-shell 暂不支持当前平台:{reason}",
155
+ "bin.not_ready": "bt-shell 尚未就绪,请稍后重试",
156
+ "bin.release_not_found": "未找到该版本对应的 Release 资产(tag={tag});若这是纯插件改动请确认二进制产物仍在 x.Y.0 的 Release 中,若动了 Rust 需先升中间版本号并新开/更新对应 Release",
157
+ // ---- client 层抛给模型的错误 ----
158
+ "client.service_timeout": "浏览器服务未就绪(超时)。bt-shell 由插件自动管理,请勿直接执行二进制文件;请稍后经 bt_cli 重试(如 open_window)。",
159
+ "client.attach_timeout": "外部 bt-shell 在 {url} 未就绪(超时)。请检查 BT_SHELL_URL/BT_SHELL_PORT,且 shell 正在运行。",
160
+ "client.not_configured": "服务未配置",
161
+ "client.service_error": "服务错误",
162
+ "client.bt_shell_path_missing": "BT_SHELL_PATH 指向的二进制不存在(路径见环境变量配置)",
163
+ "client.spawn_failed": "bt-shell 进程启动失败(请稍后经 bt_cli 重试;勿直接执行二进制文件)",
164
+ "client.session_closed_during_start": "该会话在浏览器启动过程中被关闭,实例已回收(未注册)。如需浏览器请重新调用工具。",
165
+ "client.attach_gone": "附着的外部 bt-shell 在 {url} 已断开(附着模式不接管进程,请自行重启该 shell)。",
166
+ "client.browser_closed": "浏览器已关闭。请先调用 open_window 打开后再试。",
63
167
  "tool.set_media_mode.desc": "切换摄像头/麦克风模式:simulate(模拟设备,默认)或 real(真实设备,无设备自动回退模拟)。不带参数时查询当前模式。",
64
168
  "tool.set_media_mode.arg.mode": "模式:simulate 或 real(省略则查询当前)",
65
169
  },