@seekskyworld/open-browser 0.2.0 → 0.3.1

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.
Files changed (99) hide show
  1. package/CONTRIBUTING.md +2 -0
  2. package/Docs/desktop-packages.md +45 -0
  3. package/Docs/open-browser-api.d.ts +13 -9
  4. package/Docs//350/267/250/345/271/263/345/217/260/350/257/225/347/224/250/344/270/216/345/217/221/350/241/214.md +6 -6
  5. package/README.md +11 -9
  6. package/README.zh-CN.md +6 -4
  7. package/access-registry.mjs +8 -3
  8. package/action-execution.mjs +30 -5
  9. package/api-contract.mjs +8 -7
  10. package/browser-extension/_locales/en/messages.json +8 -0
  11. package/browser-extension/_locales/zh_CN/messages.json +8 -0
  12. package/browser-extension/i18n.js +84 -0
  13. package/browser-extension/manifest.json +5 -4
  14. package/browser-extension/messages.js +266 -0
  15. package/browser-extension/newtab.css +4 -0
  16. package/browser-extension/newtab.html +9 -9
  17. package/browser-extension/newtab.js +38 -35
  18. package/browser-extension/page-locale.js +23 -0
  19. package/browser-extension/phase-labels.js +33 -6
  20. package/browser-extension/popup.css +2 -2
  21. package/browser-extension/popup.html +25 -25
  22. package/browser-extension/popup.js +102 -59
  23. package/browser-extension/tab-action.js +31 -25
  24. package/browser-extension/worker.js +31 -7
  25. package/browser-extension/workspace-title.js +2 -2
  26. package/build-profile.mjs +10 -2
  27. package/capability-matrix.mjs +1 -1
  28. package/chromium-host.mjs +26 -19
  29. package/chromium-shell.mjs +7 -5
  30. package/cli.mjs +51 -48
  31. package/contract-validation.mjs +1 -1
  32. package/control.mjs +9 -8
  33. package/desktop/Info.plist +4 -2
  34. package/desktop/Launcher.m +10 -2
  35. package/desktop/OBControlBar.m +12 -8
  36. package/desktop/OBLocalization.h +20 -0
  37. package/desktop/OBPageView.m +2 -1
  38. package/desktop/WorkspacePanel.m +85 -83
  39. package/desktop/archive-release.py +5 -1
  40. package/desktop/build-macos.mjs +17 -8
  41. package/desktop/build-managed-input.mjs +2 -1
  42. package/desktop/build-portable.mjs +5 -3
  43. package/desktop/build-profile.mjs +2 -1
  44. package/desktop/build.mjs +2 -1
  45. package/desktop/create-shortcut.ps1 +7 -1
  46. package/desktop/en.lproj/Localizable.strings +106 -0
  47. package/desktop/install-menu-entry.mjs +2 -0
  48. package/desktop/notarize-macos.mjs +70 -29
  49. package/desktop/package-macos.mjs +4 -3
  50. package/desktop/sign.mjs +22 -6
  51. package/desktop/start-profile.mjs +2 -1
  52. package/desktop/start.mjs +3 -1
  53. package/desktop/verify-macos-release.mjs +27 -18
  54. package/desktop/verify-version.mjs +22 -2
  55. package/desktop/zh-Hans.lproj/Localizable.strings +106 -0
  56. package/engine-service.mjs +86 -27
  57. package/hosted/cli.mjs +2 -1
  58. package/hosted/init.mjs +2 -1
  59. package/i18n.mjs +41 -0
  60. package/managed-input.mjs +22 -5
  61. package/mcp-http.mjs +12 -11
  62. package/mcp-server.mjs +27 -10
  63. package/mcp.mjs +1 -0
  64. package/messages.zh-CN.mjs +175 -0
  65. package/package.json +9 -5
  66. package/page-activity.mjs +10 -7
  67. package/page-observation.mjs +4 -1
  68. package/paths.mjs +2 -5
  69. package/receipt-store.mjs +17 -7
  70. package/runtime.mjs +5 -4
  71. package/sdk.mjs +57 -46
  72. package/service.mjs +38 -21
  73. package/skill-links.mjs +72 -18
  74. package/skills/open-browser/SKILL.md +10 -97
  75. package/skills/open-browser/SKILL.zh-CN.md +22 -0
  76. package/skills/open-browser/references/macos.en.md +3 -0
  77. package/skills/open-browser/references/macos.md +5 -0
  78. package/skills/open-browser/references/operations.en.md +54 -0
  79. package/skills/open-browser/{SKILL.windows.md → references/operations.md} +8 -59
  80. package/skills/open-browser/references/recovery.en.md +36 -0
  81. package/skills/open-browser/references/recovery.md +38 -0
  82. package/skills/open-browser/references/windows.en.md +3 -0
  83. package/skills/open-browser/references/windows.md +5 -0
  84. package/skills/open-browser/scripts/bootstrap.mjs +80 -90
  85. package/skills/open-browser/scripts/guide.mjs +20 -0
  86. package/skills/open-browser/scripts/open-browser +5 -1
  87. package/studio/demo-site.mjs +5 -4
  88. package/studio/index.html +37 -33
  89. package/studio/index.mjs +10 -3
  90. package/studio/native-demo.mjs +8 -7
  91. package/studio/studio.css +3 -0
  92. package/studio/studio.js +99 -69
  93. package/system-i18n.mjs +19 -0
  94. package/tab-adoption.mjs +9 -3
  95. package/tab-recovery.mjs +100 -0
  96. package/visual-page.mjs +17 -7
  97. package/workspace-lifecycle.mjs +18 -2
  98. package/workspace-state.mjs +57 -16
  99. package/skills/open-browser/SKILL.macos.md +0 -112
@@ -0,0 +1,266 @@
1
+ 'use strict';
2
+
3
+ // English message IDs are the fallback text. Only project-owned copy is translated.
4
+ globalThis.openBrowserChinese = Object.freeze({
5
+ "Language": "语言",
6
+ "Follow system": "跟随系统",
7
+ "Language is set by OPEN_BROWSER_LOCALE.": "界面语言由 OPEN_BROWSER_LOCALE 设置。",
8
+ "Could not save the language setting.": "未能保存语言设置。",
9
+ "Open Browser received the request but the service timed out. Check the app and try again.": "open-browser 已收到请求,但服务响应超时,请检查应用后重试。",
10
+ "The local service is disconnected. Start Open Browser and click Refresh.": "open-browser 服务未连接,请先启动应用后点击刷新。",
11
+ "The extension timed out. Reload it or restart Open Browser.": "open-browser 扩展响应超时,请重新加载扩展或重启应用。",
12
+ "The workspace extension is offline. Restart Open Browser.": "open-browser 工作区扩展未运行,请重新启动应用。",
13
+ "Could not read agent status. Click Refresh to try again.": "暂时无法读取 Agent 状态,请点击刷新重试。",
14
+ "Human verification required": "需要人工验证",
15
+ "Screenshot permission required": "需要授权截图",
16
+ "Waiting for credentials": "等待凭据",
17
+ "Idle": "待命",
18
+ " · Steps: {0}": " · {0} 步",
19
+ "Event": "事件",
20
+ "Loading activity…": "正在读取记录…",
21
+ "No redacted events to show.": "暂无可显示的脱敏事件。",
22
+ "View activity": "查看记录",
23
+ "{0} · Steps: {1}/{2}": "{0} · {1}/{2} 步",
24
+ "Action": "操作",
25
+ "Pages: {0} · No action in progress": "{0} 个页面 · 暂无正在执行的操作",
26
+ "Name this task": "请为此任务命名",
27
+ "No actions recorded": "暂无操作记录",
28
+ "Steps: {0}/{1}": "{0}/{1} 步",
29
+ "Steps: {0}": "{0} 步",
30
+ "Records: {0}": "{0} 条",
31
+ "Completed": "已完成",
32
+ "Local service connected": "本机服务已连接",
33
+ "Service disconnected": "服务未连接",
34
+ "Copied": "已复制",
35
+ "Waiting for instructions": "等待指令",
36
+ "Queued": "已排队",
37
+ "Running": "执行中",
38
+ "Checking target": "检查目标",
39
+ "Dispatching": "正在派发",
40
+ "Waiting for page": "等待页面",
41
+ "Checking result": "核对结果",
42
+ "Failed": "失败",
43
+ "Cancelled": "已取消",
44
+ "Outcome unknown": "结果待核实",
45
+ "Agent in control": "Agent 控制",
46
+ "Take over": "人工接管",
47
+ "Transferring": "交接中",
48
+ "Dispatched": "已派发",
49
+ "Bind credential": "绑定凭据",
50
+ "This tab is now assigned to the selected task.": "已将此页交给所选任务",
51
+ "Load static resources": "加载静态资源",
52
+ "Allow navigation and page actions": "允许导航与页面操作",
53
+ "Page": "页面",
54
+ "Download error log": "下载错误日志",
55
+ "No workspaces": "暂无工作区",
56
+ "The original tab was closed or detached.": "原标签页已关闭或解绑",
57
+ "Syncing": "同步中",
58
+ "Retry takeover": "重试人工接管",
59
+ "Return to agent": "交回 Agent",
60
+ "Take over this tab": "接管此页",
61
+ "Take over workspace": "接管工作区",
62
+ "Ordinary tab": "普通标签页",
63
+ " · Ask the agent to create a named workspace first": " · 请让 Agent 先创建一个命名工作区",
64
+ "The task ended or the service restarted.": "原任务已结束或服务已重启",
65
+ "Reopen the extension on the tab you want to authorize.": "请在需要授权的标签页重新打开扩展。",
66
+ "Connection failed": "连接失败",
67
+ "Take over to respond": "接管并处理",
68
+ "Reply": "回复",
69
+ "OK": "确定",
70
+ "Cancel": "取消",
71
+ "Downloading": "下载中",
72
+ "Ready to keep": "待保留",
73
+ "Kept": "已保留",
74
+ "Show saved location": "查看保存位置",
75
+ "Keep file": "保留文件",
76
+ "The page or control changed. Select the file again.": "页面或控制权已变更,请重新选择文件。",
77
+ "Each file must be 8 MiB or smaller.": "单文件上限 8 MiB",
78
+ "Could not read the file.": "文件读取失败",
79
+ "The credential request has changed.": "凭据请求已变化",
80
+ "Credential bound. The agent can retry.": "已绑定凭据,调用方可以重试。",
81
+ "In queue": "排队中",
82
+ "Action failed": "执行失败",
83
+ "H": "人",
84
+ "Human in control": "人工控制",
85
+ "Open Browser Workspace": "open-browser 工作区",
86
+ "Click": "点击",
87
+ "Fill": "填写",
88
+ "Fill credential": "填写凭据",
89
+ "Click to return control to the agent": "点击交回 Agent",
90
+ "Click to open the workspace panel": "点击打开工作区面板",
91
+ "Click to take over": "点击接管",
92
+ "Workspace panel": "工作区面板",
93
+ "Take": "接管",
94
+ "The extension received the request but the local service timed out. Check the service and try again.": "open-browser 扩展已收到请求,但本机服务未在时限内返回。请检查服务状态后重试。",
95
+ "The extension is disconnected from the local service. Start Open Browser and try again.": "open-browser 扩展未连接到本机服务,请先启动应用后重试。",
96
+ "Untitled task": "未命名任务",
97
+ "Input": "输入",
98
+ "Double-click": "双击",
99
+ "Hover": "悬停",
100
+ "Press key": "按键",
101
+ "Scroll": "滚动",
102
+ "Drag": "拖拽",
103
+ "Select": "选择",
104
+ "Upload": "上传",
105
+ "Toggle": "切换",
106
+ "My account": "我的账号",
107
+ "Sign out": "退出登录",
108
+ "Username": "账号",
109
+ "Password": "密码",
110
+ "Sign in": "登录",
111
+ "Incorrect username or password": "账号或密码不正确",
112
+ "Automatic sign-in": "自动登录",
113
+ "Supply a missing credential": "凭据补充",
114
+ "Sign-in assistant": "登录助手",
115
+ "User in control": "用户控制",
116
+ "Needs attention": "待处理",
117
+ "Agent running": "Agent 运行",
118
+ "Result needs verification": "结果待核对",
119
+ "Open page": "打开页面",
120
+ "Observe page": "观察页面",
121
+ "Page action": "页面操作",
122
+ "Supply the missing credential.": "请补充缺少的凭据",
123
+ "The site rejected the username or password. Update it and try again.": "站点拒绝了账号或密码,请更新后再试。",
124
+ "This entry link has been used. Reopen the console from Open Browser.": "管理入口已使用,请从 open-browser 重新打开控制台。",
125
+ "This entry link has expired. Reopen the console.": "管理入口已失效,请重新打开控制台。",
126
+ "The new page is outside this workspace's allowed sites. Create another workspace.": "新页面超出了当前工作区授权站点,请另建工作区。",
127
+ "The sign-in form changed. Read the page and try again.": "登录表单已变化,请读取页面后再试。",
128
+ "The user controls this workspace. Return control to the agent first.": "当前为用户控制,请先交回 Agent。",
129
+ "No observation yet": "暂无观察结果",
130
+ "Show password": "显示密码",
131
+ "Missing credential": "缺少凭据",
132
+ "Workspace": "工作区",
133
+ "Password needed": "需要补充密码",
134
+ "Credential needed": "需要补充凭据",
135
+ "Credential value": "凭据值",
136
+ "Supply and continue": "补充并继续",
137
+ "Automation paused": "自动化已暂停",
138
+ "Transferring control…": "正在交接",
139
+ "Waiting for a credential": "等待补充凭据",
140
+ "No completed actions": "暂无已结束操作",
141
+ "No visible text on this page": "当前页无可见文本",
142
+ "Read the signed-in account page": "已读取受保护的账号页面",
143
+ "Task is waiting for a password": "任务等待补充密码",
144
+ "Signed in and read the account page": "登录成功,已读取受保护的账号页面",
145
+ "My workspace": "我的工作区",
146
+ "Read the current page": "已读取当前页面",
147
+ "Credential bound. The agent can observe again and submit the remaining actions.": "已绑定缺少的凭据;调用方可重新观察并提交剩余操作",
148
+ "Credential bound to the site in this workspace": "已为当前工作区绑定站点凭据",
149
+ "You now control this workspace": "已由用户控制当前工作区",
150
+ "Control returned to the agent. Observe the page again.": "已交回 Agent,页面需要重新观察",
151
+ "Displayed the controlled page": "已显示接管页面",
152
+ "Workspace closed": "工作区已关闭",
153
+ "Opened a new page": "已打开新页面",
154
+ "Hide password": "隐藏密码",
155
+ "Disconnected": "未连接",
156
+ "Could not connect to the local console. Restart Open Browser.": "无法连接本机控制台,请重新启动 open-browser。",
157
+ "Open Browser Console": "open-browser 控制台",
158
+ "Connecting…": "正在连接…",
159
+ "Agent Console": "Agent 控制台",
160
+ "View current tasks and agent activity.": "查看 Agent 当前任务和运行记录。",
161
+ "Refresh": "刷新",
162
+ "Using an agent": "Agent 如何使用",
163
+ "Copy prompt": "复制提示词",
164
+ "Give this prompt to your agent to start working with Open Browser.": "把下面的提示词交给 Agent,它会按 open-browser 的安全流程操作浏览器。",
165
+ "Use the open-browser skill to control the browser. Call listWorkspaces first to resume an existing workspace. For a new task, provide a clear task name in name and an agent name in agentName. Use open for a specific URL, then observe, act, getOperation and observe to check the result. Call finishWorkspace when finished. After a handoff, stale_ref, outcome_unknown or host_unavailable, follow nextAction and check the result before submitting again.": "请使用 open-browser Skill 控制浏览器。先调用 listWorkspaces,继续已有工作区。创建新任务时必须填写清晰的 name 任务名称和 agentName Agent 名称,再用 open 打开明确网址,按 observe → act → getOperation → observe 核对结果,完成后调用 finishWorkspace。遇到接管、stale_ref、outcome_unknown 或 host_unavailable 时,按返回的 nextAction 处理,不要重复提交。",
166
+ "Active agents": "正在运行的 Agent",
167
+ "No agents are running.": "当前没有正在运行的 Agent。",
168
+ "Run history": "运行历史",
169
+ "No runs yet.": "暂无运行历史。",
170
+ "No active tasks. Open a new tab to see the Agent Console.": "当前没有活动任务。新标签页会显示 Agent 控制台。",
171
+ "Agent task to authorize": "授权给哪个 Agent 任务",
172
+ "Account alias (optional)": "账号别名(选填)",
173
+ "Restore the last browser session on restart and resume this task": "重启时恢复上次浏览会话,并继续此页任务",
174
+ "Give this tab to the agent": "让 Agent 操作此页",
175
+ "Generate backup authorization code": "生成备用授权码",
176
+ "Send this authorization to the selected agent within two minutes": "将以下授权交给所选 Agent,两分钟内有效",
177
+ "Tabs": "标签页",
178
+ "Allow file uploads": "授权上传文件",
179
+ "Task downloads": "任务下载",
180
+ "Export error log": "导出错误日志",
181
+ "Export redacted failures for this task to help diagnose problems.": "导出当前任务的脱敏失败记录,便于排查问题。",
182
+ "Finish task": "结束任务",
183
+ "Select the tabs to keep. The other task tabs will close.": "勾选要留给自己的标签,其余任务标签将关闭。",
184
+ "Finish": "结束",
185
+ "Supply credentials": "补充凭据",
186
+ "For example, Work account": "例如:工作账号",
187
+ "Open Browser · Workspaces": "open-browser · 工作区",
188
+ "New workspace": "新建工作区",
189
+ "Connecting": "正在连接",
190
+ "Open a separate browser page for a task.": "为任务打开独立的浏览器页面。",
191
+ "Workspace name": "工作区名称",
192
+ "URL to open": "打开网址",
193
+ "Create and open": "创建并打开",
194
+ "Sign-in demo": "账号登录演示",
195
+ "Try automatic sign-in or supply a missing password on the local demo site.": "在本机验证站试用自动登录或补充密码。",
196
+ "Test missing password": "测试缺少密码",
197
+ "Take over page": "接管页面",
198
+ "View controlled page": "查看接管页",
199
+ "Control": "控制权",
200
+ "Current activity": "当前活动",
201
+ "Latest result": "最近结果",
202
+ "Site": "站点",
203
+ "Credential reference": "凭据引用",
204
+ "Fill demo password": "填入演示密码",
205
+ "Workspace pages": "工作区页面",
206
+ "Open a new page": "打开新页面",
207
+ "Open ↗": "打开 ↗",
208
+ "Page observation": "页面观察",
209
+ "Read page": "读取页面",
210
+ "Run sign-in task": "运行登录任务",
211
+ "Bind site credentials": "绑定站点凭据",
212
+ "Value": "值",
213
+ "Bind to this page's origin": "绑定到当前页面来源",
214
+ "Demo account": "演示账号",
215
+ "Close workspace": "关闭工作区",
216
+ "Console activity": "控制台操作记录",
217
+ "No activity since the console opened": "本次打开控制台后暂无操作",
218
+ "Workspace list": "工作区列表",
219
+ "Current page": "当前页面",
220
+ "Local test site": "本机验证站",
221
+ "Sign in to your account": "登录账号",
222
+ "Signed in as": "当前账号",
223
+ "For this task: {0} · {1}": "本次{0} · {1}",
224
+ "Delivery needs verification · {0}": "交付待核实 · {0}",
225
+ "Pages kept: {0} · Pages closed: {1}": "已保留 {0} 页,已关闭 {1} 页。",
226
+ "{0} · Profile {1}": "{0} · 资料 {1}",
227
+ "Last synced {0}": "上次同步 {0}",
228
+ "Revoke {0} · {1}": "撤销 {0} · {1}",
229
+ "Revoke screenshot permission for this task · {0}": "撤销本任务截图授权 · {0}",
230
+ "Allow screenshots for this task · {0}": "允许本任务截图 · {0}",
231
+ "Last capture · {0} · {1} · {2}": "最近画面采集 · {0} · {1} · {2}",
232
+ "Granted {0} access to {1} for five minutes.": "已向 {0} 授权 {1},有效期五分钟。",
233
+ "Human · {0}": "人工 · {0}",
234
+ "Workspaces: {0}": "{0} 个",
235
+ "Pages: {0}": "{0} 页",
236
+ "Pages in workspace: {0}": "{0} 个页面",
237
+ "{0} · Queued: {1}": "{0} · 排队 {1}",
238
+ "Action did not complete ({0})": "操作未完成({0})",
239
+ "Opened “{0}”": "已打开「{0}」",
240
+ "Unknown": "未知",
241
+ "Alert": "提示",
242
+ "Confirmation": "确认",
243
+ "Prompt": "输入提示",
244
+ "The service is busy. Try again shortly.": "本机服务繁忙,请稍后重试。",
245
+ "The page binding has changed. Reopen the extension on the target tab.": "页面绑定已变更,请在目标标签页重新打开扩展。",
246
+ "The site is outside this task’s allowed origins.": "此站点不在当前任务的授权范围内。",
247
+ "Control has changed. Refresh the workspace and try again.": "控制权已变更,请刷新工作区后再试。",
248
+ "The current tab cannot be assigned to this workspace.": "当前标签页无法交给此工作区。",
249
+ "This page has closed. Select the original tab again.": "页面已关闭,请重新选择原标签页。",
250
+ "Closed": "已关闭",
251
+ "Opened": "已打开",
252
+ "Managed": "已纳入任务",
253
+ "Expired": "已过期",
254
+ "Service stopped": "服务已退出",
255
+ "Canvas snapshot": "画布快照",
256
+ "Screenshot": "截图",
257
+ "Run workflow": "运行工作流",
258
+ "Tab assigned": "已绑定标签页",
259
+ "Dispatch": "派发",
260
+ "Operation": "操作",
261
+ "Dialog": "对话框",
262
+ "Site verification": "站点验证",
263
+ "Download": "下载",
264
+ "Popup": "弹窗",
265
+ "Workspace ended": "工作区已结束"
266
+ });
@@ -24,3 +24,7 @@ section { margin-top: 34px; } .section-title { margin-bottom: 12px; }
24
24
  .history-row .timeline { flex-basis: 100%; }
25
25
  .empty { padding: 22px 0; } .quiet { cursor: pointer; color: color-mix(in srgb, CanvasText 68%, Canvas); background: none; border: 0; text-decoration: none; padding: 4px 0; font: inherit; } #notice.error { color: #a44b2b; } [hidden] { display: none !important; }
26
26
  @media (max-width: 700px) { body { min-width: 0; } header { padding: 0 20px; } main { width: calc(100% - 40px); margin-top: 28px; } }
27
+ .console-settings { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
28
+ .console-settings label { font-size: 13px; }
29
+ .console-settings select { font: inherit; color: CanvasText; background: Canvas; border: 1px solid color-mix(in srgb, CanvasText 30%, transparent); border-radius: 5px; padding: 3px 5px; }
30
+ @media (max-width: 520px) { header { height: auto; min-height: 58px; gap: 10px; flex-wrap: wrap; padding-block: 8px; } }
@@ -1,19 +1,19 @@
1
1
  <!doctype html>
2
2
  <meta charset="utf-8">
3
3
  <meta name="viewport" content="width=device-width, initial-scale=1">
4
- <title>open-browser 控制台</title>
4
+ <title data-i18n>Open Browser Console</title>
5
5
  <link rel="icon" type="image/png" href="icons/open-browser-32.png">
6
6
  <link rel="stylesheet" href="newtab.css">
7
- <script defer src="phase-labels.js"></script>
8
- <script defer src="workspace-title.js"></script>
9
- <script defer src="newtab.js"></script>
7
+ <script type="module" src="page-locale.js"></script>
10
8
  <body>
11
- <header><div class="brand"><img src="icons/open-browser-48.png" width="28" height="28" alt=""><strong>open-browser</strong></div><span id="status">正在连接…</span></header>
9
+ <header><div class="brand"><img src="icons/open-browser-48.png" width="28" height="28" alt=""><strong>open-browser</strong></div><div class="console-settings"><span data-i18n id="status">Connecting…</span>
10
+ <label for="interface-language" data-i18n>Language</label>
11
+ <select id="interface-language" disabled><option value="system" data-i18n>Follow system</option><option value="zh-CN" lang="zh-CN">简体中文</option><option value="en" lang="en">English</option></select></div></header>
12
12
  <main>
13
- <section class="hero"><div><h1>Agent 控制台</h1><p>查看 Agent 当前任务和运行记录。</p></div><button id="refresh" class="quiet" type="button">刷新</button></section>
14
- <section class="how-to"><div class="section-title"><h2>Agent 如何使用</h2><button id="copy-prompt" class="quiet" type="button">复制提示词</button></div><p>把下面的提示词交给 Agent,它会按 open-browser 的安全流程操作浏览器。</p><textarea id="agent-prompt" readonly spellcheck="false">请使用 open-browser Skill 控制浏览器。先调用 listWorkspaces,继续已有工作区。创建新任务时必须填写清晰的 name 任务名称和 agentName Agent 名称,再用 open 打开明确网址,按 observe → act → getOperation → observe 核对结果,完成后调用 finishWorkspace。遇到接管、stale_ref、outcome_unknown 或 host_unavailable 时,按返回的 nextAction 处理,不要重复提交。</textarea></section>
15
- <section><div class="section-title"><h2>正在运行的 Agent</h2><span id="workspace-count"></span></div><div id="workspaces" class="workspace-grid"></div><p id="empty" class="empty">当前没有正在运行的 Agent。</p></section>
16
- <section><div class="section-title"><h2>运行历史</h2><span id="history-count"></span></div><div id="history" class="history-list"></div><p id="history-empty" class="empty">暂无运行历史。</p></section>
13
+ <section class="hero"><div><h1 data-i18n>Agent Console</h1><p data-i18n>View current tasks and agent activity.</p></div><button data-i18n id="refresh" class="quiet" type="button">Refresh</button></section>
14
+ <section class="how-to"><div class="section-title"><h2 data-i18n>Using an agent</h2><button data-i18n id="copy-prompt" class="quiet" type="button">Copy prompt</button></div><p data-i18n>Give this prompt to your agent to start working with Open Browser.</p><textarea data-i18n id="agent-prompt" readonly spellcheck="false">Use the open-browser skill to control the browser. Call listWorkspaces first to resume an existing workspace. For a new task, provide a clear task name in name and an agent name in agentName. Use open for a specific URL, then observe, act, getOperation and observe to check the result. Call finishWorkspace when finished. After a handoff, stale_ref, outcome_unknown or host_unavailable, follow nextAction and check the result before submitting again.</textarea></section>
15
+ <section><div class="section-title"><h2 data-i18n>Active agents</h2><span id="workspace-count"></span></div><div id="workspaces" class="workspace-grid"></div><p data-i18n id="empty" class="empty">No agents are running.</p></section>
16
+ <section><div class="section-title"><h2 data-i18n>Run history</h2><span id="history-count"></span></div><div id="history" class="history-list"></div><p data-i18n id="history-empty" class="empty">No runs yet.</p></section>
17
17
  <p id="notice" role="status" hidden></p>
18
18
  </main>
19
19
  </body>
@@ -1,8 +1,15 @@
1
- 'use strict';
1
+ import { errorLabel, kinds, modes, phases } from './phase-labels.js';
2
+
3
+ const { t } = globalThis.openBrowserI18n;
2
4
 
3
5
  const el = id => document.getElementById(id);
4
- const phases = globalThis.openBrowserPhaseLabels;
5
- const modes = globalThis.openBrowserModeLabels;
6
+ const showLanguage = globalThis.openBrowserI18n.bindLanguageSelect(el('interface-language'),
7
+ preference => call('setInterfaceLanguage', {preference}), notify);
8
+
9
+ export function updateLanguage(settings) {
10
+ showLanguage(settings);
11
+ void refresh();
12
+ }
6
13
 
7
14
  async function call(method, params = {}) {
8
15
  const reply = await chrome.runtime.sendMessage({ method, params });
@@ -18,18 +25,16 @@ function notify(message) {
18
25
 
19
26
  function friendlyError(error) {
20
27
  const code = error?.message || '';
21
- if (code === 'host_unavailable' || code === 'host_timeout') return code === 'host_timeout'
22
- ? 'open-browser 已收到请求,但服务响应超时,请检查应用后重试。'
23
- : 'open-browser 服务未连接,请先启动应用后点击刷新。';
24
- if (code === 'extension_worker_timeout') return 'open-browser 扩展响应超时,请重新加载扩展或重启应用。';
25
- if (code === 'extension_unavailable') return 'open-browser 工作区扩展未运行,请重新启动应用。';
26
- return code || '暂时无法读取 Agent 状态,请点击刷新重试。';
28
+ if (code === 'extension_worker_timeout') return t("The extension timed out. Reload it or restart Open Browser.");
29
+ if (code === 'extension_unavailable') return t("The workspace extension is offline. Restart Open Browser.");
30
+ return errorLabel(code) || t("Could not read agent status. Click Refresh to try again.");
27
31
  }
28
32
 
29
33
  function stateLabel(workspace) {
30
- if (workspace.activity?.needsHumanVerification) return '需要人工验证';
31
- if (workspace.activity?.needsCredential) return '等待凭据';
32
- return modes[workspace.mode] || phases[workspace.activity?.current?.phase] || phases[workspace.activity?.phase] || '待命';
34
+ if (workspace.activity?.needsHumanVerification) return t("Human verification required");
35
+ if (workspace.activity?.needsVisualPermission) return t("Screenshot permission required");
36
+ if (workspace.activity?.needsCredential) return t("Waiting for credentials");
37
+ return modes[workspace.mode] || phases[workspace.activity?.current?.phase] || phases[workspace.activity?.phase] || t("Idle");
33
38
  }
34
39
 
35
40
  const formatWorkspaceTitle = globalThis.openBrowserWorkspaceTitle;
@@ -43,10 +48,10 @@ function line(text, className = '') {
43
48
  }
44
49
 
45
50
  function eventLabel(event) {
46
- const state = event.state || 'unknown';
47
- const steps = Number.isInteger(event.completedSteps) ? ` · ${event.completedSteps} 步` : '';
51
+ const state = event.state || t("Unknown");
52
+ const steps = Number.isInteger(event.completedSteps) ? t(" · Steps: {0}", event.completedSteps) : '';
48
53
  const operation = event.operationId ? ` · ${event.operationId.slice(0, 8)}` : '';
49
- return `${event.kind || '事件'} · ${phases[state] || state}${steps}${operation}`;
54
+ return `${kinds[event.kind] || event.kind || t("Event")} · ${phases[state] || modes[state] || state}${steps}${operation}`;
50
55
  }
51
56
 
52
57
  async function showEvents(workspaceId, host) {
@@ -57,13 +62,13 @@ async function showEvents(workspaceId, host) {
57
62
  return;
58
63
  }
59
64
  timeline.hidden = false;
60
- timeline.replaceChildren(line('正在读取记录…', 'detail'));
65
+ timeline.replaceChildren(line(t("Loading activity…"), 'detail'));
61
66
  try {
62
67
  const result = await call('listEvents', { workspaceId, after: 0, limit: 24 });
63
68
  const events = result?.events || [];
64
69
  timeline.replaceChildren(...(events.length
65
70
  ? events.map(event => line(eventLabel(event), 'timeline-row'))
66
- : [line('暂无可显示的脱敏事件。', 'detail')]));
71
+ : [line(t("No redacted events to show."), 'detail')]));
67
72
  } catch (error) {
68
73
  timeline.replaceChildren(line(friendlyError(error), 'detail'));
69
74
  }
@@ -73,13 +78,13 @@ function recordButton(workspaceId, host) {
73
78
  const button = document.createElement('button');
74
79
  button.type = 'button';
75
80
  button.className = 'quiet record-button';
76
- button.textContent = '查看记录';
81
+ button.textContent = t("View activity");
77
82
  button.onclick = () => void showEvents(workspaceId, host);
78
83
  return button;
79
84
  }
80
85
 
81
86
  function renderWorkspaces(items) {
82
- el('workspace-count').textContent = items.length ? `${items.length} 个` : '';
87
+ el('workspace-count').textContent = items.length ? t("Workspaces: {0}", items.length) : '';
83
88
  el('empty').hidden = items.length > 0;
84
89
  el('workspaces').replaceChildren(...items.map(workspace => {
85
90
  const card = document.createElement('article');
@@ -89,11 +94,11 @@ function renderWorkspaces(items) {
89
94
  const status = line(stateLabel(workspace), 'state');
90
95
  const current = workspace.activity?.current;
91
96
  const detail = line(current
92
- ? `${current.kind || '操作'} · ${current.completedSteps || 0}/${current.totalSteps || 0} 步`
93
- : `${workspace.pages?.length || 0} 个页面 · 暂无正在执行的操作`, 'detail');
97
+ ? t("{0} · Steps: {1}/{2}", kinds[current.kind] || current.kind || t("Action"), current.completedSteps || 0, current.totalSteps || 0)
98
+ : t("Pages: {0} · No action in progress", workspace.pages?.length || 0), 'detail');
94
99
  const agent = line(workspace.agentName || 'Agent', 'agent-name');
95
100
  card.append(title, agent, status, detail);
96
- if (needsTaskName(workspace)) card.append(line('请为此任务命名', 'name-hint'));
101
+ if (needsTaskName(workspace)) card.append(line(t("Name this task"), 'name-hint'));
97
102
  const timeline = document.createElement('div');
98
103
  timeline.className = 'timeline';
99
104
  timeline.hidden = true;
@@ -103,29 +108,29 @@ function renderWorkspaces(items) {
103
108
  }
104
109
 
105
110
  function operationLabel(operation) {
106
- if (!operation) return '暂无操作记录';
111
+ if (!operation) return t("No actions recorded");
107
112
  const phase = operation.phase || operation.state;
108
- const progress = operation.totalSteps ? `${operation.completedSteps || 0}/${operation.totalSteps} 步` : `${operation.completedSteps || 0} 步`;
109
- return `${operation.kind || '操作'} · ${phases[phase] || phase} · ${progress}`;
113
+ const progress = operation.totalSteps ? t("Steps: {0}/{1}", operation.completedSteps || 0, operation.totalSteps) : t("Steps: {0}", operation.completedSteps || 0);
114
+ return `${kinds[operation.kind] || operation.kind || t("Action")} · ${phases[phase] || phase} · ${progress}`;
110
115
  }
111
116
 
112
117
  function formatTime(value) {
113
118
  if (!Number.isFinite(value) || value <= 0) return '';
114
- return new Intl.DateTimeFormat('zh-CN', { month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit' }).format(value);
119
+ return new Intl.DateTimeFormat(globalThis.openBrowserI18n.locale, { month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit' }).format(value);
115
120
  }
116
121
 
117
122
  function renderHistory(items) {
118
- el('history-count').textContent = items.length ? `${items.length} 条` : '';
123
+ el('history-count').textContent = items.length ? t("Records: {0}", items.length) : '';
119
124
  el('history-empty').hidden = items.length > 0;
120
125
  el('history').replaceChildren(...items.map(item => {
121
126
  const row = document.createElement('article');
122
127
  row.className = 'history-row';
123
128
  const main = document.createElement('div');
124
129
  main.append(line(formatWorkspaceTitle(item), 'history-title'), line(operationLabel(item.recentOperation), 'detail'));
125
- if (needsTaskName(item)) main.append(line('请为此任务命名', 'name-hint'));
130
+ if (needsTaskName(item)) main.append(line(t("Name this task"), 'name-hint'));
126
131
  const meta = document.createElement('div');
127
132
  meta.className = 'history-meta';
128
- meta.append(line(phases[item.state] || item.state || '已完成', `history-state ${item.state || ''}`));
133
+ meta.append(line(phases[item.state] || item.state || t("Completed"), `history-state ${item.state || ''}`));
129
134
  const time = formatTime(item.updatedAt || item.createdAt);
130
135
  if (time) meta.append(line(time, 'detail'));
131
136
  const timeline = document.createElement('div');
@@ -147,10 +152,10 @@ async function refresh() {
147
152
  ]);
148
153
  renderWorkspaces(workspaces);
149
154
  renderHistory(history);
150
- el('status').textContent = '本机服务已连接';
155
+ el('status').textContent = t("Local service connected");
151
156
  notify('');
152
157
  } catch (error) {
153
- el('status').textContent = '服务未连接';
158
+ el('status').textContent = t("Service disconnected");
154
159
  notify(friendlyError(error));
155
160
  }
156
161
  }
@@ -166,9 +171,7 @@ el('copy-prompt').onclick = async () => {
166
171
  el('agent-prompt').setSelectionRange(0, 0);
167
172
  }
168
173
  const button = el('copy-prompt');
169
- const label = button.textContent;
170
- button.textContent = '已复制';
171
- setTimeout(() => { button.textContent = label; }, 1600);
174
+ button.textContent = t("Copied");
175
+ setTimeout(() => { button.textContent = t("Copy prompt"); }, 1600);
172
176
  };
173
- void refresh();
174
177
  setInterval(() => void refresh(), 5000);
@@ -0,0 +1,23 @@
1
+ // Translate packaged UI before populating any page or user data.
2
+ import './messages.js';
3
+ import './i18n.js';
4
+
5
+ const i18n = globalThis.openBrowserI18n;
6
+ let settings, page, receivedChange = false;
7
+ function apply(value) {
8
+ settings = value;
9
+ i18n.setLocale(value?.locale);
10
+ i18n.applyDocument(document);
11
+ page?.updateLanguage(settings);
12
+ }
13
+ chrome.storage.onChanged.addListener((changes, area) => {
14
+ if (area !== 'session' || !changes.interfaceLanguage) return;
15
+ receivedChange = true;
16
+ apply(changes.interfaceLanguage.newValue);
17
+ });
18
+
19
+ const { interfaceLanguage } = await chrome.storage.session.get('interfaceLanguage');
20
+ if (!receivedChange) apply(interfaceLanguage);
21
+ await import('./workspace-title.js');
22
+ page = location.pathname === '/popup.html' ? await import('./popup.js') : await import('./newtab.js');
23
+ page.updateLanguage(settings);
@@ -1,9 +1,36 @@
1
1
  'use strict';
2
2
 
3
- globalThis.openBrowserPhaseLabels = Object.freeze({
4
- idle: '等待指令', queued: '已排队', running: '执行中', actionability: '检查目标',
5
- dispatching: '正在派发', waiting: '等待页面', verifying: '核对结果',
6
- needs_credential: '等待凭据', needs_human_verification: '需要人工验证', completed: '已完成', failed: '失败',
7
- cancelled: '已取消', outcome_unknown: '结果待核实',
3
+ const { messageLabels } = globalThis.openBrowserI18n;
4
+
5
+ export const phases = messageLabels({
6
+ idle: "Waiting for instructions", queued: "Queued", running: "Running", actionability: "Checking target",
7
+ dispatching: "Dispatching", waiting: "Waiting for page", verifying: "Checking result",
8
+ needs_credential: "Waiting for credentials", needs_human_verification: "Human verification required", needs_visual_permission: "Screenshot permission required", completed: "Completed", failed: "Failed",
9
+ cancelled: "Cancelled", outcome_unknown: "Outcome unknown",
10
+ closed: "Closed", finished: "Completed", opened: "Opened", managed: "Managed",
11
+ receiving: "Downloading", expired: "Expired", service_shutdown: "Service stopped",
12
+ human_verification_required: "Human verification required",
13
+ });
14
+ export const modes = messageLabels({ agent: "Agent in control", human: "Human in control", transferring: "Transferring" });
15
+
16
+ export const kinds = messageLabels({
17
+ openPage: "Open page", observe: "Observe page", act: "Page action", canvasSnapshot: "Canvas snapshot",
18
+ captureVisual: "Screenshot", runWorkflow: "Run workflow", page_bound: "Tab assigned",
19
+ visual_capture: "Screenshot", dispatch: "Dispatch", operation: "Operation", control: "Control",
20
+ action: "Action", dialog: "Dialog", security: "Site verification", download: "Download",
21
+ popup: "Popup", workspace_end: "Workspace ended",
22
+ });
23
+
24
+ const extensionErrors = messageLabels({
25
+ host_unavailable: "The local service is disconnected. Start Open Browser and click Refresh.",
26
+ host_timeout: "Open Browser received the request but the service timed out. Check the app and try again.",
27
+ queue_full: "The service is busy. Try again shortly.",
28
+ stale_control: "Control has changed. Refresh the workspace and try again.",
29
+ workspace_under_user_control: "The user controls this workspace. Return control to the agent first.",
30
+ stale_document: "The page binding has changed. Reopen the extension on the target tab.",
31
+ origin_denied: "The site is outside this task’s allowed origins.",
32
+ adoption_page_changed: "The current tab cannot be assigned to this workspace.",
33
+ page_not_found: "This page has closed. Select the original tab again.",
34
+ workspace_not_found: "The task ended or the service restarted.",
8
35
  });
9
- globalThis.openBrowserModeLabels = Object.freeze({ agent: 'Agent 控制', human: '人工接管', transferring: '交接中' });
36
+ export const errorLabel = code => Object.hasOwn(extensionErrors, code) ? extensionErrors[code] : code;
@@ -8,12 +8,12 @@ strong { font-size: 17px; letter-spacing: -.3px; }
8
8
  main { padding: 0 16px 14px; } section, form, details { margin-top: 14px; }
9
9
  h2 { font-size: 14px; margin: 0 0 3px; } p { margin: 8px 0; overflow-wrap: anywhere; }
10
10
  label { display: block; margin: 8px 0 3px; }
11
- select, #adoption input, input[type=password] { width: 100%; height: 30px; font: inherit; }
11
+ select, #adoption input:not([type=checkbox]), input[type=password] { width: 100%; height: 30px; font: inherit; }
12
12
  input[type=password] { padding: 3px 6px; }
13
13
  button { font: inherit; border: 1px solid transparent; border-radius: 5px; padding: 4px 10px; background: #176244; color: white; cursor: pointer; }
14
14
  button.secondary { background: ButtonFace; color: ButtonText; border-color: color-mix(in srgb, ButtonText 25%, transparent); }
15
15
  button:disabled { opacity: .55; cursor: default; }
16
- .action { display: flex; gap: 7px; margin-top: 9px; }
16
+ .action { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
17
17
  form, details { border-top: 1px solid color-mix(in srgb, CanvasText 16%, transparent); padding-top: 10px; }
18
18
  summary { cursor: pointer; } .check { margin: 9px 0; } .check input { vertical-align: middle; }
19
19
  #notice { margin: 12px 0 0; } [hidden] { display: none !important; }