@xiaoqiong0v0/opencode-browser-tool 1.2.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.
- package/README.md +182 -0
- package/dist/client.js +229 -0
- package/dist/config/index.js +165 -0
- package/dist/devices.js +26 -0
- package/dist/i18n/en.js +95 -0
- package/dist/i18n/index.js +24 -0
- package/dist/i18n/types.js +1 -0
- package/dist/i18n/zh.js +95 -0
- package/dist/index.js +451 -0
- package/dist/types.js +1 -0
- package/package.json +44 -0
package/dist/i18n/en.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
const en = {
|
|
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.",
|
|
4
|
+
"tool.cli.arg.args": "Command line string: \"<command> [--flag value ...]\", e.g. \"navigate --url https://...\" (\"help\" lists all)",
|
|
5
|
+
"cli.header": "bt_cli — browser automation CLI",
|
|
6
|
+
"cli.usage": "Usage: bt_cli({ args })\n args single command line string: \"<command> [--flag value ...]\"",
|
|
7
|
+
"cli.commands": "Commands:",
|
|
8
|
+
"cli.examples": "Examples:",
|
|
9
|
+
"cli.example.1": "bt_cli({ args: \"help\" })",
|
|
10
|
+
"cli.example.2": "bt_cli({ args: \"navigate --url https://example.com\" })",
|
|
11
|
+
"cli.example.3": "bt_cli({ args: \"click --selector #submit\" })",
|
|
12
|
+
"cli.example.4": "bt_cli({ args: \"fill --selector #q --value \\\"hello world\\\"\" })",
|
|
13
|
+
"cli.unknown": "Unknown command: {cmd}",
|
|
14
|
+
"cli.invalid_args": "Invalid args for {cmd}: {msg}",
|
|
15
|
+
"cli.failed": "Command {cmd} failed: {msg}",
|
|
16
|
+
"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)",
|
|
26
|
+
"cli.cmd.evaluate": "Execute JS in the page, return result",
|
|
27
|
+
"cli.cmd.get_visible_text": "Get visible page text",
|
|
28
|
+
"cli.cmd.get_visible_html": "Get page HTML structure",
|
|
29
|
+
"cli.cmd.console_logs": "Get browser console logs",
|
|
30
|
+
"cli.cmd.go_back": "Go back in history",
|
|
31
|
+
"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)",
|
|
34
|
+
"cli.cmd.devtools": "Open/close devtools (open/close/toggle)",
|
|
35
|
+
"cli.cmd.reload": "Reload the current page",
|
|
36
|
+
"cli.cmd.open_window": "Open the browser window",
|
|
37
|
+
"cli.cmd.close": "Close the browser",
|
|
38
|
+
"cli.cmd.show_notification": "Show a notification on the page",
|
|
39
|
+
"cli.cmd.scroll": "Scroll the page",
|
|
40
|
+
"cli.cmd.wait_for_selector": "Wait for an element to appear",
|
|
41
|
+
"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",
|
|
44
|
+
"cli.cmd.get_browser_status": "Check if browser is open and current page",
|
|
45
|
+
"cli.cmd.list_tabs": "List all open tabs",
|
|
46
|
+
"cli.cmd.switch_tab": "Switch to a tab by index",
|
|
47
|
+
"cli.cmd.new_tab": "Open a new tab",
|
|
48
|
+
"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",
|
|
52
|
+
"cli.cmd.custom_user_agent": "Set a custom User-Agent",
|
|
53
|
+
"cli.cmd.expect_response": "Start expecting an HTTP response pattern",
|
|
54
|
+
"cli.cmd.assert_response": "Check if expected response matched",
|
|
55
|
+
"cli.cmd.get_accessibility_tree": "Get the accessibility tree",
|
|
56
|
+
"cli.cmd.list_records": "List annotation records in the panel",
|
|
57
|
+
"cli.cmd.read_record_content": "Read an annotation record by id",
|
|
58
|
+
"cli.cmd.fake_audio": "Inject audio into fake mic (tone/seq/dtmf/noise/audio/ambient/stop)",
|
|
59
|
+
"cli.cmd.fake_video": "Inject frames into fake camera (image/video/auto/stop)",
|
|
60
|
+
"cli.cmd.profile": "List/switch/delete user profiles (--set <name> restarts browser; --delete removes a non-default, non-active profile)",
|
|
61
|
+
"cli.cmd.exports": "Show export dir + how to export Edge/Chrome passwords/bookmarks",
|
|
62
|
+
"cli.cmd.lookup": "Find a password in a CSV export, return @file: path (not in context)",
|
|
63
|
+
"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
|
+
"tool.set_media_mode.arg.mode": "Mode: simulate or real (omit to query current)",
|
|
65
|
+
},
|
|
66
|
+
panel: {
|
|
67
|
+
"panel.title": "Tool Panel",
|
|
68
|
+
"panel.pick_hint": "Hover to highlight elements\nClick to select for annotation",
|
|
69
|
+
"panel.annotation_placeholder": "Add annotation...",
|
|
70
|
+
"panel.action_none": "No action",
|
|
71
|
+
"panel.action_click": "Click",
|
|
72
|
+
"panel.action_fill": "Fill",
|
|
73
|
+
"panel.action_value_placeholder": "Value...",
|
|
74
|
+
"panel.send": "Send",
|
|
75
|
+
"panel.send_all": "Send All",
|
|
76
|
+
"panel.close": "Close",
|
|
77
|
+
"panel.send_failed": "Send failed",
|
|
78
|
+
"panel.annotate": "Annotate",
|
|
79
|
+
"panel.screenshot_btn": "Screenshot",
|
|
80
|
+
"panel.screenshot_sent": "Screenshot sent",
|
|
81
|
+
"panel.screenshot_note": "Add description...",
|
|
82
|
+
"panel.screenshot_hint": "Double click to select entire page",
|
|
83
|
+
"panel.screenshot_stored": "Screenshot saved",
|
|
84
|
+
"panel.screenshot_failed": "Screenshot failed",
|
|
85
|
+
"panel.cancel": "Cancel",
|
|
86
|
+
"panel.confirm": "Confirm",
|
|
87
|
+
"panel.annotation_stored": "Annotation saved",
|
|
88
|
+
"panel.annotation_required": "Please enter annotation text",
|
|
89
|
+
"panel.no_records": "No records yet",
|
|
90
|
+
"panel.sent_records": "Sent {n} records",
|
|
91
|
+
"panel.send_records_failed": "Send failed",
|
|
92
|
+
"panel.delete": "Delete",
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
export default en;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getConfig } from "../config/index.js";
|
|
2
|
+
const _strings = {};
|
|
3
|
+
/** 注册语言包 */
|
|
4
|
+
export function registerLocale(lang, strings) {
|
|
5
|
+
_strings[lang] = strings;
|
|
6
|
+
}
|
|
7
|
+
/** 获取工具描述翻译 */
|
|
8
|
+
export function t(key, lang) {
|
|
9
|
+
const l = lang || getConfig().toolLang;
|
|
10
|
+
const str = _strings[l] || _strings.en;
|
|
11
|
+
return str?.tool[key] || _strings.en?.tool[key] || key;
|
|
12
|
+
}
|
|
13
|
+
/** 获取面板 UI 翻译 */
|
|
14
|
+
export function panelT(key, lang) {
|
|
15
|
+
const l = lang || getConfig().panelLang;
|
|
16
|
+
const str = _strings[l] || _strings.en;
|
|
17
|
+
return str?.panel[key] || _strings.en?.panel[key] || key;
|
|
18
|
+
}
|
|
19
|
+
/** 获取面板完整翻译对象(供注入) */
|
|
20
|
+
export function getPanelStrings(lang) {
|
|
21
|
+
const l = lang || getConfig().panelLang;
|
|
22
|
+
const str = _strings[l] || _strings.en;
|
|
23
|
+
return str?.panel || {};
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/i18n/zh.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
const zh = {
|
|
2
|
+
tool: {
|
|
3
|
+
"tool.cli.desc": "CLI 风格的浏览器自动化控制:单个字符串命令行,如 \"navigate --url https://...\" 或 \"help\"。省略列出全部命令。",
|
|
4
|
+
"tool.cli.arg.args": "命令行字符串:\"<command> [--flag 值 ...]\",如 \"navigate --url https://...\"(\"help\" 列出全部)",
|
|
5
|
+
"cli.header": "bt_cli — 浏览器自动化 CLI",
|
|
6
|
+
"cli.usage": "用法: bt_cli({ args })\n args 单个命令行字符串: \"<command> [--flag 值 ...]\"",
|
|
7
|
+
"cli.commands": "子命令:",
|
|
8
|
+
"cli.examples": "示例:",
|
|
9
|
+
"cli.example.1": "bt_cli({ args: \"help\" })",
|
|
10
|
+
"cli.example.2": "bt_cli({ args: \"navigate --url https://example.com\" })",
|
|
11
|
+
"cli.example.3": "bt_cli({ args: \"click --selector #submit\" })",
|
|
12
|
+
"cli.example.4": "bt_cli({ args: \"fill --selector #q --value \\\"hello world\\\"\" })",
|
|
13
|
+
"cli.unknown": "未知命令: {cmd}",
|
|
14
|
+
"cli.invalid_args": "参数无效 {cmd}: {msg}",
|
|
15
|
+
"cli.failed": "命令 {cmd} 失败: {msg}",
|
|
16
|
+
"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": "截取页面/元素截图(返回图片)",
|
|
26
|
+
"cli.cmd.evaluate": "在页面执行 JS,返回结果",
|
|
27
|
+
"cli.cmd.get_visible_text": "获取页面可见文本",
|
|
28
|
+
"cli.cmd.get_visible_html": "获取页面 HTML 结构",
|
|
29
|
+
"cli.cmd.console_logs": "获取浏览器控制台日志",
|
|
30
|
+
"cli.cmd.go_back": "浏览器后退",
|
|
31
|
+
"cli.cmd.go_forward": "浏览器前进",
|
|
32
|
+
"cli.cmd.resize": "调整视口尺寸",
|
|
33
|
+
"cli.cmd.set_device": "应用设备预设(不带 name 列出预设)",
|
|
34
|
+
"cli.cmd.devtools": "打开/关闭开发者工具(open/close/toggle)",
|
|
35
|
+
"cli.cmd.reload": "刷新当前页面",
|
|
36
|
+
"cli.cmd.open_window": "打开浏览器窗口",
|
|
37
|
+
"cli.cmd.close": "关闭浏览器",
|
|
38
|
+
"cli.cmd.show_notification": "页面显示通知气泡",
|
|
39
|
+
"cli.cmd.scroll": "滚动页面",
|
|
40
|
+
"cli.cmd.wait_for_selector": "等待元素出现",
|
|
41
|
+
"cli.cmd.click_and_switch_tab": "点击链接并切换到新标签",
|
|
42
|
+
"cli.cmd.iframe_click": "在 iframe 内点击元素",
|
|
43
|
+
"cli.cmd.iframe_fill": "在 iframe 内填写输入框",
|
|
44
|
+
"cli.cmd.get_browser_status": "检查浏览器是否打开及当前页面",
|
|
45
|
+
"cli.cmd.list_tabs": "列出所有打开的标签",
|
|
46
|
+
"cli.cmd.switch_tab": "按索引切换标签",
|
|
47
|
+
"cli.cmd.new_tab": "打开新标签",
|
|
48
|
+
"cli.cmd.close_tab": "关闭标签(省略=当前)",
|
|
49
|
+
"cli.cmd.get_element_state": "元素存在/可见/尺寸/状态",
|
|
50
|
+
"cli.cmd.scroll_to_element": "滚动到元素可见",
|
|
51
|
+
"cli.cmd.get_dropdown_options": "列出下拉框选项",
|
|
52
|
+
"cli.cmd.custom_user_agent": "设置自定义 User-Agent",
|
|
53
|
+
"cli.cmd.expect_response": "开始监听 HTTP 响应模式",
|
|
54
|
+
"cli.cmd.assert_response": "检查期望响应是否匹配",
|
|
55
|
+
"cli.cmd.get_accessibility_tree": "获取可访问性树",
|
|
56
|
+
"cli.cmd.list_records": "列出面板批注记录",
|
|
57
|
+
"cli.cmd.read_record_content": "按 id 读取批注记录",
|
|
58
|
+
"cli.cmd.fake_audio": "向 fake 麦克风注入音频(tone/seq/dtmf/noise/audio/ambient/stop)",
|
|
59
|
+
"cli.cmd.fake_video": "向 fake 摄像头注入画面(image/video/auto/stop)",
|
|
60
|
+
"cli.cmd.profile": "列出/切换/删除用户配置(--set <name> 重启浏览器;--delete 删除非 default、非当前激活配置)",
|
|
61
|
+
"cli.cmd.exports": "显示导出目录 + Edge/Chrome 密码/书签导出引导",
|
|
62
|
+
"cli.cmd.lookup": "在密码 CSV 中查找站点,返回 @file: 路径(密码不进上下文)",
|
|
63
|
+
"tool.set_media_mode.desc": "切换摄像头/麦克风模式:simulate(模拟设备,默认)或 real(真实设备,无设备自动回退模拟)。不带参数时查询当前模式。",
|
|
64
|
+
"tool.set_media_mode.arg.mode": "模式:simulate 或 real(省略则查询当前)",
|
|
65
|
+
},
|
|
66
|
+
panel: {
|
|
67
|
+
"panel.title": "工具面板",
|
|
68
|
+
"panel.pick_hint": "悬停高亮页面元素\n点击选中进行标注",
|
|
69
|
+
"panel.annotation_placeholder": "添加批注...",
|
|
70
|
+
"panel.action_none": "无操作",
|
|
71
|
+
"panel.action_click": "点击",
|
|
72
|
+
"panel.action_fill": "填写",
|
|
73
|
+
"panel.action_value_placeholder": "值...",
|
|
74
|
+
"panel.send": "发送",
|
|
75
|
+
"panel.send_all": "发送全部",
|
|
76
|
+
"panel.close": "关闭",
|
|
77
|
+
"panel.send_failed": "发送失败",
|
|
78
|
+
"panel.annotate": "批注",
|
|
79
|
+
"panel.screenshot_btn": "截图",
|
|
80
|
+
"panel.screenshot_sent": "截图已发送",
|
|
81
|
+
"panel.screenshot_note": "添加说明...",
|
|
82
|
+
"panel.screenshot_hint": "双击截取全屏",
|
|
83
|
+
"panel.screenshot_stored": "截图已保存",
|
|
84
|
+
"panel.screenshot_failed": "截图失败",
|
|
85
|
+
"panel.cancel": "取消",
|
|
86
|
+
"panel.confirm": "确认",
|
|
87
|
+
"panel.annotation_required": "请输入批注文字",
|
|
88
|
+
"panel.annotation_stored": "批注已保存",
|
|
89
|
+
"panel.no_records": "当前记录为空",
|
|
90
|
+
"panel.sent_records": "已发送 {n} 条记录",
|
|
91
|
+
"panel.send_records_failed": "发送失败",
|
|
92
|
+
"panel.delete": "删除",
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
export default zh;
|