@seekskyworld/open-browser 0.3.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 (82) hide show
  1. package/CONTRIBUTING.md +2 -0
  2. package/Docs/desktop-packages.md +45 -0
  3. 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 +1 -1
  4. package/README.md +8 -6
  5. package/README.zh-CN.md +2 -0
  6. package/api-contract.mjs +2 -1
  7. package/browser-extension/_locales/en/messages.json +8 -0
  8. package/browser-extension/_locales/zh_CN/messages.json +8 -0
  9. package/browser-extension/i18n.js +84 -0
  10. package/browser-extension/manifest.json +5 -4
  11. package/browser-extension/messages.js +266 -0
  12. package/browser-extension/newtab.css +4 -0
  13. package/browser-extension/newtab.html +9 -9
  14. package/browser-extension/newtab.js +38 -36
  15. package/browser-extension/page-locale.js +23 -0
  16. package/browser-extension/phase-labels.js +33 -6
  17. package/browser-extension/popup.css +2 -2
  18. package/browser-extension/popup.html +24 -26
  19. package/browser-extension/popup.js +72 -49
  20. package/browser-extension/tab-action.js +29 -24
  21. package/browser-extension/worker.js +29 -5
  22. package/browser-extension/workspace-title.js +2 -2
  23. package/build-profile.mjs +10 -2
  24. package/chromium-host.mjs +22 -11
  25. package/chromium-shell.mjs +5 -3
  26. package/cli.mjs +33 -30
  27. package/control.mjs +9 -8
  28. package/desktop/Info.plist +3 -1
  29. package/desktop/Launcher.m +10 -2
  30. package/desktop/OBControlBar.m +12 -8
  31. package/desktop/OBLocalization.h +20 -0
  32. package/desktop/OBPageView.m +2 -1
  33. package/desktop/WorkspacePanel.m +84 -83
  34. package/desktop/archive-release.py +5 -1
  35. package/desktop/build-macos.mjs +11 -5
  36. package/desktop/build-managed-input.mjs +2 -1
  37. package/desktop/build-portable.mjs +5 -3
  38. package/desktop/build-profile.mjs +2 -1
  39. package/desktop/build.mjs +2 -1
  40. package/desktop/create-shortcut.ps1 +7 -1
  41. package/desktop/en.lproj/Localizable.strings +106 -0
  42. package/desktop/install-menu-entry.mjs +2 -0
  43. package/desktop/notarize-macos.mjs +21 -24
  44. package/desktop/package-macos.mjs +4 -3
  45. package/desktop/sign.mjs +5 -4
  46. package/desktop/start-profile.mjs +2 -1
  47. package/desktop/start.mjs +3 -1
  48. package/desktop/verify-macos-release.mjs +9 -8
  49. package/desktop/zh-Hans.lproj/Localizable.strings +106 -0
  50. package/engine-service.mjs +1 -1
  51. package/hosted/cli.mjs +2 -1
  52. package/hosted/init.mjs +2 -1
  53. package/i18n.mjs +41 -0
  54. package/mcp-http.mjs +3 -2
  55. package/mcp-server.mjs +4 -3
  56. package/messages.zh-CN.mjs +175 -0
  57. package/package.json +4 -1
  58. package/page-activity.mjs +8 -6
  59. package/paths.mjs +2 -5
  60. package/runtime.mjs +4 -3
  61. package/sdk.mjs +40 -39
  62. package/service.mjs +2 -1
  63. package/skills/open-browser/SKILL.md +11 -9
  64. package/skills/open-browser/SKILL.zh-CN.md +22 -0
  65. package/skills/open-browser/references/macos.en.md +3 -0
  66. package/skills/open-browser/references/macos.md +2 -0
  67. package/skills/open-browser/references/operations.en.md +54 -0
  68. package/skills/open-browser/references/operations.md +2 -0
  69. package/skills/open-browser/references/recovery.en.md +36 -0
  70. package/skills/open-browser/references/recovery.md +2 -0
  71. package/skills/open-browser/references/windows.en.md +3 -0
  72. package/skills/open-browser/references/windows.md +2 -0
  73. package/skills/open-browser/scripts/bootstrap.mjs +6 -4
  74. package/skills/open-browser/scripts/guide.mjs +7 -4
  75. package/skills/open-browser/scripts/open-browser +5 -1
  76. package/studio/demo-site.mjs +5 -4
  77. package/studio/index.html +37 -33
  78. package/studio/index.mjs +10 -3
  79. package/studio/native-demo.mjs +8 -7
  80. package/studio/studio.css +3 -0
  81. package/studio/studio.js +98 -68
  82. package/system-i18n.mjs +19 -0
@@ -0,0 +1,106 @@
1
+ "The local browser service exited. Check whether a service started from source is already running." = "The local browser service exited. Check whether a service started from source is already running.";
2
+ "Open Browser control bar" = "Open Browser control bar";
3
+ "Take over" = "Take over";
4
+ "Finish" = "Finish";
5
+ "Finish this agent task and keep its open pages" = "Finish this agent task and keep its open pages";
6
+ "Checking target" = "Checking target";
7
+ "Dispatching" = "Dispatching";
8
+ "Waiting for page" = "Waiting for page";
9
+ "Checking result" = "Checking result";
10
+ "Dispatched" = "Dispatched";
11
+ "Running" = "Running";
12
+ "Queued" = "Queued";
13
+ "Idle" = "Idle";
14
+ "Completed" = "Completed";
15
+ "Waiting for credentials" = "Waiting for credentials";
16
+ "Human verification required" = "Human verification required";
17
+ "Failed" = "Failed";
18
+ "Cancelled" = "Cancelled";
19
+ "Unverified" = "Unverified";
20
+ "Transferring" = "Transferring";
21
+ "Human in control" = "Human in control";
22
+ "Return to agent" = "Return to agent";
23
+ "Workspace web page" = "Workspace web page";
24
+ "Open page" = "Open page";
25
+ "Observe page" = "Observe page";
26
+ "Page action" = "Page action";
27
+ "Click" = "Click";
28
+ "Fill" = "Fill";
29
+ "Fill credential" = "Fill credential";
30
+ "Action" = "Action";
31
+ "%@ · %@ · Steps: %@/%@" = "%@ · %@ · Steps: %@/%@";
32
+ "In queue" = "In queue";
33
+ "Result needs verification" = "Result needs verification";
34
+ "Missing credential" = "Missing credential";
35
+ "User in control · Agent paused" = "User in control · Agent paused";
36
+ "Transferring control" = "Transferring control";
37
+ "Waiting for a credential" = "Waiting for a credential";
38
+ "Screenshot permission required" = "Screenshot permission required";
39
+ "Action failed" = "Action failed";
40
+ "Waiting for instructions" = "Waiting for instructions";
41
+ "New workspace" = "New workspace";
42
+ "Back" = "Back";
43
+ "Forward" = "Forward";
44
+ "Refresh" = "Refresh";
45
+ "Home" = "Home";
46
+ "Split view" = "Split view";
47
+ "New tab" = "New tab";
48
+ "Take" = "Take";
49
+ "More actions" = "More actions";
50
+ "Bind credential…" = "Bind credential…";
51
+ "View page text…" = "View page text…";
52
+ "Send feedback…" = "Send feedback…";
53
+ "Close tab" = "Close tab";
54
+ "Close workspace…" = "Close workspace…";
55
+ "Enter a URL" = "Enter a URL";
56
+ "Address bar" = "Address bar";
57
+ "Workspaces and pages" = "Workspaces and pages";
58
+ "Workspace" = "Workspace";
59
+ "Open workspace" = "Open workspace";
60
+ "Connecting to the local service…" = "Connecting to the local service…";
61
+ "Needs attention" = "Needs attention";
62
+ "Agent running" = "Agent running";
63
+ "Untitled task (please name it)" = "Untitled task (please name it)";
64
+ "Expand workspace" = "Expand workspace";
65
+ "Collapse workspace" = "Collapse workspace";
66
+ "Close split view" = "Close split view";
67
+ "Split the current workspace view" = "Split the current workspace view";
68
+ "Return control of this workspace to the agent" = "Return control of this workspace to the agent";
69
+ "Take control of the current page" = "Take control of the current page";
70
+ " · Queued: %@" = " · Queued: %@";
71
+ "Supply credentials…" = "Supply credentials…";
72
+ "New Tab" = "New Tab";
73
+ "Enter a complete HTTP or HTTPS URL." = "Enter a complete HTTP or HTTPS URL.";
74
+ "This site is outside the workspace's approved origins." = "This site is outside the workspace's approved origins.";
75
+ "Could not open the page. Check the URL or your connection." = "Could not open the page. Check the URL or your connection.";
76
+ "The user controls this workspace." = "The user controls this workspace.";
77
+ "Control has changed. Try again." = "Control has changed. Try again.";
78
+ "The credential request changed. Review it again." = "The credential request changed. Review it again.";
79
+ "Cancel" = "Cancel";
80
+ "Create" = "Create";
81
+ "Workspace name" = "Workspace name";
82
+ "First URL (optional)" = "First URL (optional)";
83
+ "Enter a workspace name." = "Enter a workspace name.";
84
+ "This workspace needs at least two pages for split view." = "This workspace needs at least two pages for split view.";
85
+ "Enter a valid HTTP or HTTPS URL." = "Enter a valid HTTP or HTTPS URL.";
86
+ "Open Browser\nWorkspace status: %@\nAgent: %@\nPage title: %@\n\nDescribe how to reproduce the issue. This report omits URLs, page content, credentials and cookies." = "Open Browser\nWorkspace status: %@\nAgent: %@\nPage title: %@\n\nDescribe how to reproduce the issue. This report omits URLs, page content, credentials and cookies.";
87
+ "Send feedback" = "Send feedback";
88
+ "%@\nCurrent action: %@" = "%@\nCurrent action: %@";
89
+ "Copy redacted feedback" = "Copy redacted feedback";
90
+ "Close" = "Close";
91
+ "Redacted feedback copied. Paste it into an issue or a private message." = "Redacted feedback copied. Paste it into an issue or a private message.";
92
+ "Close workspace?" = "Close workspace?";
93
+ "Close workspace" = "Close workspace";
94
+ "Page text" = "Page text";
95
+ "Done" = "Done";
96
+ "No text to preview." = "No text to preview.";
97
+ "The page changed. Reopen the credential panel." = "The page changed. Reopen the credential panel.";
98
+ "Supply credentials" = "Supply credentials";
99
+ "Bind credential" = "Bind credential";
100
+ "Bind" = "Bind";
101
+ "Credential name" = "Credential name";
102
+ "Credential value" = "Credential value";
103
+ "Enter a credential name and value." = "Enter a credential name and value.";
104
+ "The page, control or credential request changed. Review it again." = "The page, control or credential request changed. Review it again.";
105
+ "Credential bound. The agent can retry." = "Credential bound. The agent can retry.";
106
+ "Credential bound." = "Credential bound.";
@@ -13,6 +13,8 @@ const executable = path.join(folder, 'open-browser').replace(/["`$\\]/g, '\\$&')
13
13
  const icon = path.join(folder, 'app/browser-extension/icons/open-browser-128.png');
14
14
  const content = [
15
15
  '[Desktop Entry]', 'Type=Application', 'Name=open-browser',
16
+ 'Comment=Browse with agents and take over a task in its tab',
17
+ 'Comment[zh_CN]=与 Agent 一起浏览网页,随时在标签页接管任务',
16
18
  'Exec="' + escapeValue(executable) + '"', 'Icon=' + escapeValue(icon),
17
19
  'Terminal=false', 'Categories=Network;WebBrowser;', 'StartupWMClass=open-browser', '',
18
20
  ].join('\n');
@@ -1,3 +1,4 @@
1
+ import { t } from "../i18n.mjs";
1
2
  import { execFileSync } from 'node:child_process';
2
3
  import { createHash } from 'node:crypto';
3
4
  import { access, mkdtemp, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
@@ -9,11 +10,7 @@ const root = fileURLToPath(new URL('../', import.meta.url));
9
10
  const defaultApp = path.join(root, 'dist', 'open-browser.app');
10
11
 
11
12
  function usage() {
12
- console.log(`用法:node desktop/notarize-macos.mjs [app-path] [--zip zip-path] [--dmg dmg-path]
13
-
14
- 提交并公证 macOS 应用,固化票据后生成可上传的 GitHub ZIP 和可选 DMG。
15
- 凭据优先使用 OPEN_BROWSER_NOTARY_PROFILE,其次使用 App Store Connect API Key,
16
- 最后使用 Apple ID 加应用专用密码。凭据只从环境变量或本机钥匙串读取。`);
13
+ console.log(t("Usage: node desktop/notarize-macos.mjs [app-path] [--zip zip-path] [--dmg dmg-path]\n\nSubmit the macOS app for notarization, staple its ticket and create the release ZIP and optional DMG. Set OPEN_BROWSER_NOTARY_PROFILE, use an App Store Connect API key, or use an Apple ID and app-specific password. Credentials are read from the environment or local keychain.\n"));
17
14
  }
18
15
 
19
16
  function parseArgs(argv) {
@@ -25,17 +22,17 @@ function parseArgs(argv) {
25
22
  if (value === '--help' || value === '-h') return { help: true };
26
23
  if (value === '--zip') {
27
24
  zip = argv[++index];
28
- if (!zip) throw new Error('--zip 需要文件路径。');
25
+ if (!zip) throw new Error(t("--zip requires a file path."));
29
26
  continue;
30
27
  }
31
28
  if (value === '--dmg') {
32
29
  dmg = argv[++index];
33
- if (!dmg) throw new Error('--dmg 需要文件路径。');
30
+ if (!dmg) throw new Error(t("--dmg requires a file path."));
34
31
  continue;
35
32
  }
36
- if (value.startsWith('--')) throw new Error('未知参数:' + value);
33
+ if (value.startsWith('--')) throw new Error(t("Unknown argument: ") + value);
37
34
  if (app !== defaultApp && app !== process.env.OPEN_BROWSER_APP_PATH)
38
- throw new Error('只能指定一个应用路径。');
35
+ throw new Error(t("Specify a single application path."));
39
36
  app = value;
40
37
  }
41
38
  const appArch = app.endsWith('-x64.app') ? 'x64' : app.endsWith('-arm64.app') ? 'arm64' : process.arch;
@@ -64,7 +61,7 @@ async function requirePath(target, label) {
64
61
  try {
65
62
  await access(target);
66
63
  } catch {
67
- throw new Error(`${label}不存在:${target}`);
64
+ throw new Error(t("{0} does not exist: {1}", label, target));
68
65
  }
69
66
  }
70
67
 
@@ -81,22 +78,22 @@ function notaryCredentials() {
81
78
  const hasApiKey = Boolean(key || keyId || issuer);
82
79
  const hasAppleId = Boolean(appleId || password);
83
80
  if (profile && (hasApiKey || hasAppleId || teamId))
84
- throw new Error('OPEN_BROWSER_NOTARY_PROFILE 不能和其他凭据模式同时设置。');
81
+ throw new Error(t("Use OPEN_BROWSER_NOTARY_PROFILE on its own."));
85
82
  if (hasApiKey && hasAppleId)
86
- throw new Error('API Key 和 Apple ID 公证凭据不能混用。');
83
+ throw new Error(t("Choose either API key or Apple ID notarization credentials."));
87
84
  if (profile) return ['--keychain-profile', profile];
88
85
  if (hasApiKey) {
89
- if (!key || !keyId) throw new Error('API Key 模式需要 OPEN_BROWSER_NOTARY_KEY 和 OPEN_BROWSER_NOTARY_KEY_ID。');
90
- if (!issuer && apiKeyFields === 3) throw new Error('团队 API Key 模式需要 OPEN_BROWSER_NOTARY_ISSUER。');
86
+ if (!key || !keyId) throw new Error(t("API key mode requires OPEN_BROWSER_NOTARY_KEY and OPEN_BROWSER_NOTARY_KEY_ID."));
87
+ if (!issuer && apiKeyFields === 3) throw new Error(t("A team API key requires OPEN_BROWSER_NOTARY_ISSUER."));
91
88
  const args = ['--key', key, '--key-id', keyId];
92
89
  if (issuer) args.push('--issuer', issuer);
93
90
  return args;
94
91
  }
95
92
  if (!appleId && !teamId && !password) {
96
- throw new Error('缺少公证凭据。优先设置 OPEN_BROWSER_NOTARY_PROFILE,或提供 API Key,' +
97
- '或设置 OPEN_BROWSER_NOTARY_APPLE_ID、OPEN_BROWSER_NOTARY_TEAM_ID 和应用专用密码。');
93
+ throw new Error(t("Set OPEN_BROWSER_NOTARY_PROFILE, provide an API key, ") +
94
+ t("or set OPEN_BROWSER_NOTARY_APPLE_ID, OPEN_BROWSER_NOTARY_TEAM_ID and an app-specific password."));
98
95
  }
99
- if (!appleId || !teamId) throw new Error('Apple ID 模式需要 OPEN_BROWSER_NOTARY_APPLE_ID 和 OPEN_BROWSER_NOTARY_TEAM_ID。');
96
+ if (!appleId || !teamId) throw new Error(t("Apple ID mode requires OPEN_BROWSER_NOTARY_APPLE_ID and OPEN_BROWSER_NOTARY_TEAM_ID."));
100
97
  let resolvedPassword = password;
101
98
  if (!resolvedPassword) {
102
99
  const service = process.env.OPEN_BROWSER_NOTARY_PASSWORD_SERVICE || 'open-browser-notary';
@@ -105,10 +102,10 @@ function notaryCredentials() {
105
102
  'find-generic-password', '-a', appleId, '-s', service, '-w'
106
103
  ], { encoding: 'utf8' }).trim();
107
104
  } catch {
108
- throw new Error(`未找到 Apple ID 应用专用密码。请将密码保存到钥匙串服务 ${service},或设置 OPEN_BROWSER_NOTARY_PASSWORD。`);
105
+ throw new Error(t("Store an app-specific password in keychain service {0} or set OPEN_BROWSER_NOTARY_PASSWORD.", service));
109
106
  }
110
107
  }
111
- if (!resolvedPassword) throw new Error('Apple ID 应用专用密码为空。');
108
+ if (!resolvedPassword) throw new Error(t("The app-specific password is empty."));
112
109
  return ['--apple-id', appleId, '--team-id', teamId, '--password', resolvedPassword];
113
110
  }
114
111
 
@@ -122,9 +119,9 @@ async function main() {
122
119
  usage();
123
120
  return;
124
121
  }
125
- if (process.platform !== 'darwin') throw new Error('macOS 公证只能在 macOS 构建机执行。');
126
- await requirePath(parsed.app, '应用');
127
- if (!parsed.app.endsWith('.app')) throw new Error('公证输入必须是 .app 应用包。');
122
+ if (process.platform !== 'darwin') throw new Error(t("Run macOS notarization on a Mac."));
123
+ await requirePath(parsed.app, t("Application"));
124
+ if (!parsed.app.endsWith('.app')) throw new Error(t("Select an .app bundle for notarization."));
128
125
  await requirePath('/usr/bin/codesign', 'codesign');
129
126
  await requirePath('/usr/bin/xcrun', 'xcrun');
130
127
 
@@ -143,10 +140,10 @@ async function main() {
143
140
  try {
144
141
  result = JSON.parse(execFileSync(notarytool, args, { encoding: 'utf8', stdio:['ignore','pipe','pipe'] }));
145
142
  } catch {
146
- throw new Error('Apple 公证提交失败:' + path.basename(archive));
143
+ throw new Error(t("Apple notarization submission failed: ") + path.basename(archive));
147
144
  }
148
145
  console.log(path.basename(archive), result.id, result.status);
149
- if (result.status !== 'Accepted') throw new Error('Apple 未接受这次公证提交。');
146
+ if (result.status !== 'Accepted') throw new Error(t("Apple declined the notarization submission."));
150
147
  const staplePrefix = stapler === '/usr/bin/xcrun' ? ['stapler'] : [];
151
148
  run(stapler, [...staplePrefix, 'staple', target]);
152
149
  run(stapler, [...staplePrefix, 'validate', target]);
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { t } from '../i18n.mjs';
2
3
 
3
4
  import { execFileSync } from 'node:child_process';
4
5
  import { createHash } from 'node:crypto';
@@ -17,9 +18,9 @@ function option(name, fallback) {
17
18
 
18
19
  const arch = option('--arch', process.arch);
19
20
  const format = option('--format', 'both');
20
- if (!['arm64', 'x64'].includes(arch)) throw new Error('--arch must be arm64 or x64');
21
- if (!['dmg', 'zip', 'both'].includes(format)) throw new Error('--format must be dmg, zip or both');
22
- if (process.platform !== 'darwin') throw new Error('macOS packages must be created on macOS');
21
+ if (!['arm64', 'x64'].includes(arch)) throw new Error(t('--arch must be arm64 or x64'));
22
+ if (!['dmg', 'zip', 'both'].includes(format)) throw new Error(t('--format must be dmg, zip or both'));
23
+ if (process.platform !== 'darwin') throw new Error(t('macOS packages must be created on macOS'));
23
24
 
24
25
  const appName = arch === 'x64' ? 'open-browser-x64.app' : 'open-browser.app';
25
26
  const app = path.join(output, appName);
package/desktop/sign.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { t } from "../i18n.mjs";
1
2
  import { execFileSync } from 'node:child_process';
2
3
  import { fileURLToPath } from 'node:url';
3
4
 
@@ -60,9 +61,9 @@ export function signingIdentity(requested = process.env.OPEN_BROWSER_SIGN_IDENTI
60
61
  const matches = identities.filter(([, hash, name]) => name.startsWith('Developer ID Application:') &&
61
62
  (!requested || hash === requested.trim().toUpperCase() || name === requested.trim()));
62
63
  if (matches.length !== 1) throw new Error(
63
- 'macOS 构建需要稳定的签名身份。请在构建钥匙串中安装有效的 Developer ID Application 证书及配对私钥。' +
64
- '可用 security find-identity -v -p codesigning 查看身份。' +
65
- '有多项 Developer ID Application 身份时,请将 OPEN_BROWSER_SIGN_IDENTITY 设为完整证书名称或其 40 位 SHA-1。');
64
+ t("Install a valid Developer ID Application certificate and its private key in the build keychain.") +
65
+ t("List identities with security find-identity -v -p codesigning.") +
66
+ t("If multiple Developer ID Application identities are available, set OPEN_BROWSER_SIGN_IDENTITY to the full certificate name or its 40-character SHA-1."));
66
67
  return matches[0][1];
67
68
  }
68
69
 
@@ -85,7 +86,7 @@ export function verifyUpgrade(previous, candidate) {
85
86
  for (const [origin, target] of [[previous, candidate], [candidate, previous]]) {
86
87
  const output = execFileSync('/usr/bin/codesign', ['-d', '-r-', origin], { encoding: 'utf8' });
87
88
  const line = output.split('\n').find(value => value.startsWith('designated => '));
88
- if (!line) throw new Error('无法读取现有版本的签名要求。');
89
+ if (!line) throw new Error(t("Could not read the previous version's signing requirement."));
89
90
  const requirement = line.slice('designated => '.length);
90
91
  execFileSync('/usr/bin/codesign', ['--verify', '-R', '=' + requirement, target], { stdio: 'inherit' });
91
92
  }
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
+ import { systemMessage as t } from '../system-i18n.mjs';
2
3
  const [profile] = process.argv.slice(2);
3
- if (!['dev', 'stable'].includes(profile)) throw new Error('usage: start-profile.mjs <dev|stable>');
4
+ if (!['dev', 'stable'].includes(profile)) throw new Error(t('usage: start-profile.mjs <dev|stable>'));
4
5
  process.env.OPEN_BROWSER_BUILD_PROFILE = profile;
5
6
  await import('./start.mjs');
package/desktop/start.mjs CHANGED
@@ -4,6 +4,7 @@ import { fileURLToPath } from 'node:url';
4
4
  import net from 'node:net';
5
5
  import { pidPath, socketPath } from '../paths.mjs';
6
6
  import { isDevelopmentBuild } from '../build-profile.mjs';
7
+ import { locale } from '../i18n.mjs';
7
8
 
8
9
  async function wakeExisting() {
9
10
  try {
@@ -27,7 +28,8 @@ if (process.platform === 'darwin' && !(isDevelopmentBuild && process.env.OPEN_BR
27
28
  const bundleName = isDevelopmentBuild ? 'open-browser-dev.app' : process.arch === 'x64' ? 'open-browser-x64.app' : 'open-browser.app';
28
29
  const bundle = fileURLToPath(new URL('../dist/' + bundleName, import.meta.url));
29
30
  if (!existsSync(bundle)) await import('./build.mjs');
30
- execFileSync('open', [bundle], { stdio: 'inherit' });
31
+ const language = process.env.OPEN_BROWSER_LOCALE ? ['--env', 'OPEN_BROWSER_LOCALE=' + locale] : [];
32
+ execFileSync('open', [...language, bundle], { stdio: 'inherit' });
31
33
  } else {
32
34
  const service = fileURLToPath(new URL('../service.mjs', import.meta.url));
33
35
  execFileSync(process.execPath, [service, '--chromium'], { stdio: 'inherit' });
@@ -1,3 +1,4 @@
1
+ import { t } from "../i18n.mjs";
1
2
  import { execFileSync, spawnSync } from 'node:child_process';
2
3
  import { createHash } from 'node:crypto';
3
4
  import { access, readFile } from 'node:fs/promises';
@@ -21,19 +22,19 @@ function run(command, args) {
21
22
 
22
23
  async function main() {
23
24
  if (process.argv.includes('--help') || process.argv.includes('-h')) {
24
- console.log('用法:node desktop/verify-macos-release.mjs [app-path] [--zip zip-path] [--dmg dmg-path]');
25
+ console.log(t("Usage: node desktop/verify-macos-release.mjs [app-path] [--zip zip-path] [--dmg dmg-path]"));
25
26
  return;
26
27
  }
27
- if (process.platform !== 'darwin') throw new Error('macOS 发行验收只能在 macOS 执行。');
28
+ if (process.platform !== 'darwin') throw new Error(t("Run macOS release verification on a Mac."));
28
29
  const app = path.resolve(process.argv[2] || process.env.OPEN_BROWSER_APP_PATH || defaultApp);
29
30
  await access(app);
30
- if (!app.endsWith('.app')) throw new Error('验收输入必须是 .app 应用包。');
31
+ if (!app.endsWith('.app')) throw new Error(t("Select an .app bundle for verification."));
31
32
  run('/usr/bin/codesign', ['--verify', '--strict', '--deep', '--verbose=2', app]);
32
33
  const details = spawnSync('/usr/bin/codesign', ['-d', '--verbose=4', app], { encoding: 'utf8' });
33
- if (details.status !== 0) throw new Error(details.stderr || '无法读取应用签名详情。');
34
+ if (details.status !== 0) throw new Error(details.stderr || t("Could not read the application signature."));
34
35
  const signatureDetails = details.stdout + details.stderr;
35
36
  if (!/CodeDirectory.*\bruntime\b/.test(signatureDetails))
36
- throw new Error('应用没有启用 Hardened Runtime。');
37
+ throw new Error(t("The application requires Hardened Runtime."));
37
38
  const stapler = commandPath('stapler', '/usr/bin/xcrun');
38
39
  run(stapler, stapler === '/usr/bin/xcrun' ? ['stapler', 'validate', app] : ['validate', app]);
39
40
  run(commandPath('spctl', '/usr/sbin/spctl'), ['--assess', '--type', 'execute', '--verbose=4', app]);
@@ -53,14 +54,14 @@ async function main() {
53
54
  await access(checksumFile);
54
55
  const expected = (await readFile(checksumFile, 'utf8')).trim().split(/\s+/)[0];
55
56
  const actual = createHash('sha256').update(await readFile(file)).digest('hex');
56
- if (expected !== actual) throw new Error(`${kind} SHA-256 不匹配:${file}`);
57
+ if (expected !== actual) throw new Error(t("{0} SHA-256 mismatch: {1}", kind, file));
57
58
  console.log(`${file}\nSHA-256 ${actual}`);
58
59
  } catch (error) {
59
- if (error?.code === 'ENOENT') throw new Error(`缺少已公证的 ${kind} 或校验和:${file}`);
60
+ if (error?.code === 'ENOENT') throw new Error(t("Missing notarized {0} or checksum: {1}", kind, file));
60
61
  throw error;
61
62
  }
62
63
  }
63
- console.log(`macOS 发行验收通过:${app}`);
64
+ console.log(t("macOS release verified: {0}", app));
64
65
  }
65
66
 
66
67
  main().catch(error => {
@@ -0,0 +1,106 @@
1
+ "The local browser service exited. Check whether a service started from source is already running." = "本机浏览器服务已退出。请检查是否已从源码启动同一服务。";
2
+ "Open Browser control bar" = "open-browser 控制条";
3
+ "Take over" = "人工接管";
4
+ "Finish" = "结束";
5
+ "Finish this agent task and keep its open pages" = "结束当前 Agent 任务并保留现有页面";
6
+ "Checking target" = "检查目标";
7
+ "Dispatching" = "正在派发";
8
+ "Waiting for page" = "等待页面";
9
+ "Checking result" = "核对结果";
10
+ "Dispatched" = "已派发";
11
+ "Running" = "执行中";
12
+ "Queued" = "已排队";
13
+ "Idle" = "待命";
14
+ "Completed" = "已完成";
15
+ "Waiting for credentials" = "等待凭据";
16
+ "Human verification required" = "需要人工验证";
17
+ "Failed" = "失败";
18
+ "Cancelled" = "已取消";
19
+ "Unverified" = "待核实";
20
+ "Transferring" = "交接中";
21
+ "Human in control" = "人工控制";
22
+ "Return to agent" = "交回 Agent";
23
+ "Workspace web page" = "工作区网页";
24
+ "Open page" = "打开页面";
25
+ "Observe page" = "观察页面";
26
+ "Page action" = "页面操作";
27
+ "Click" = "点击";
28
+ "Fill" = "填写";
29
+ "Fill credential" = "填写凭据";
30
+ "Action" = "操作";
31
+ "%@ · %@ · Steps: %@/%@" = "%@ · %@ · %@/%@ 步";
32
+ "In queue" = "排队中";
33
+ "Result needs verification" = "结果待核对";
34
+ "Missing credential" = "缺少凭据";
35
+ "User in control · Agent paused" = "用户控制 · Agent 已暂停";
36
+ "Transferring control" = "正在交接控制权";
37
+ "Waiting for a credential" = "等待补充凭据";
38
+ "Screenshot permission required" = "需要授权截图";
39
+ "Action failed" = "执行失败";
40
+ "Waiting for instructions" = "等待指令";
41
+ "New workspace" = "新建工作区";
42
+ "Back" = "后退";
43
+ "Forward" = "前进";
44
+ "Refresh" = "刷新";
45
+ "Home" = "主页";
46
+ "Split view" = "拆分页面";
47
+ "New tab" = "新建标签页";
48
+ "Take" = "接管";
49
+ "More actions" = "更多操作";
50
+ "Bind credential…" = "绑定凭据…";
51
+ "View page text…" = "查看页面文本…";
52
+ "Send feedback…" = "反馈问题…";
53
+ "Close tab" = "关闭标签页";
54
+ "Close workspace…" = "关闭工作区…";
55
+ "Enter a URL" = "输入网址";
56
+ "Address bar" = "地址栏";
57
+ "Workspaces and pages" = "工作区与页面";
58
+ "Workspace" = "工作区";
59
+ "Open workspace" = "打开工作区";
60
+ "Connecting to the local service…" = "正在连接本地服务…";
61
+ "Needs attention" = "待处理";
62
+ "Agent running" = "Agent 运行";
63
+ "Untitled task (please name it)" = "未命名任务(请命名)";
64
+ "Expand workspace" = "展开工作区";
65
+ "Collapse workspace" = "折叠工作区";
66
+ "Close split view" = "关闭拆分";
67
+ "Split the current workspace view" = "拆分当前工作区页面";
68
+ "Return control of this workspace to the agent" = "交回此工作区的控制权";
69
+ "Take control of the current page" = "人工接管当前页面";
70
+ " · Queued: %@" = " · 排队 %@";
71
+ "Supply credentials…" = "补充凭据…";
72
+ "New Tab" = "新标签页";
73
+ "Enter a complete HTTP or HTTPS URL." = "请输入完整的 http 或 https 网址。";
74
+ "This site is outside the workspace's approved origins." = "该站点不在此工作区的授权范围内。";
75
+ "Could not open the page. Check the URL or your connection." = "页面打开失败,请检查网址或网络。";
76
+ "The user controls this workspace." = "工作区正由用户控制。";
77
+ "Control has changed. Try again." = "控制权已变化,请重新操作。";
78
+ "The credential request changed. Review it again." = "凭据请求已变化,请重新查看。";
79
+ "Cancel" = "取消";
80
+ "Create" = "创建";
81
+ "Workspace name" = "工作区名称";
82
+ "First URL (optional)" = "首个网址(可选)";
83
+ "Enter a workspace name." = "请输入工作区名称。";
84
+ "This workspace needs at least two pages for split view." = "当前工作区至少需要两个页面才能拆分。";
85
+ "Enter a valid HTTP or HTTPS URL." = "请输入有效的 HTTP 或 HTTPS 网址。";
86
+ "Open Browser\nWorkspace status: %@\nAgent: %@\nPage title: %@\n\nDescribe how to reproduce the issue. This report omits URLs, page content, credentials and cookies." = "open-browser\n工作区状态:%@\nAgent:%@\n页面标题:%@\n\n请补充复现步骤。此文本不包含网址、页面正文、凭据或 Cookie。";
87
+ "Send feedback" = "反馈问题";
88
+ "%@\nCurrent action: %@" = "%@\n当前操作:%@";
89
+ "Copy redacted feedback" = "复制脱敏反馈";
90
+ "Close" = "关闭";
91
+ "Redacted feedback copied. Paste it into an issue or a private message." = "已复制脱敏反馈,可粘贴到项目 issue 或私聊中。";
92
+ "Close workspace?" = "关闭工作区?";
93
+ "Close workspace" = "关闭工作区";
94
+ "Page text" = "页面文本";
95
+ "Done" = "完成";
96
+ "No text to preview." = "暂无可预览的文字。";
97
+ "The page changed. Reopen the credential panel." = "页面已变化,请重新打开凭据面板。";
98
+ "Supply credentials" = "补充凭据";
99
+ "Bind credential" = "绑定凭据";
100
+ "Bind" = "绑定";
101
+ "Credential name" = "凭据名称";
102
+ "Credential value" = "凭据值";
103
+ "Enter a credential name and value." = "请填写凭据名称和值。";
104
+ "The page, control or credential request changed. Review it again." = "页面、控制权或凭据请求已变化,请重新查看。";
105
+ "Credential bound. The agent can retry." = "已绑定凭据,调用方可以重试。";
106
+ "Credential bound." = "已绑定凭据。";
@@ -136,7 +136,7 @@ export class BrowserService {
136
136
  }
137
137
  }
138
138
 
139
- notifyTarget(ws, tab, el, documentId, controlGeneration, origin, actionKind = '操作') {
139
+ notifyTarget(ws, tab, el, documentId, controlGeneration, origin, actionKind = 'action') {
140
140
  if (!this.onActionTarget) return;
141
141
  const ticket = Symbol();
142
142
  tab.latestTarget = ticket;
package/hosted/cli.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { t } from "../i18n.mjs";
1
2
  import path from 'node:path';
2
3
  import { localRequest } from '../sdk.mjs';
3
4
 
@@ -5,7 +6,7 @@ try {
5
6
  const method = process.argv[2];
6
7
  const home = process.env.OPEN_BROWSER_HOSTED_DIR;
7
8
  const token = process.env.OPEN_BROWSER_HOSTED_TOKEN_FILE;
8
- if (!method || !home || !token) throw new Error('请设置 OPEN_BROWSER_HOSTED_DIR 和 OPEN_BROWSER_HOSTED_TOKEN_FILE,然后指定方法。');
9
+ if (!method || !home || !token) throw new Error(t("Set OPEN_BROWSER_HOSTED_DIR and OPEN_BROWSER_HOSTED_TOKEN_FILE, then specify a method."));
9
10
  let input = '';
10
11
  if (!process.stdin.isTTY) {
11
12
  process.stdin.setEncoding('utf8');
package/hosted/init.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { t } from "../i18n.mjs";
1
2
  import { randomBytes } from 'node:crypto';
2
3
  import { mkdir, writeFile } from 'node:fs/promises';
3
4
  import path from 'node:path';
@@ -6,7 +7,7 @@ import { pathToFileURL } from 'node:url';
6
7
  export async function initialize(directory) {
7
8
  const home = path.resolve(directory);
8
9
  if (Buffer.byteLength(path.join(home, 'node-a/open-browser.sock')) >= 100)
9
- throw new Error('请选择较短的托管数据目录,以容纳 Unix socket 路径。');
10
+ throw new Error(t("Choose a shorter hosted data directory for the Unix socket path."));
10
11
  await mkdir(path.dirname(home), { recursive: true });
11
12
  await mkdir(home, { mode: 0o700 });
12
13
  const token = async name => {
package/i18n.mjs ADDED
@@ -0,0 +1,41 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
3
+ import path from 'node:path';
4
+ import { profileStateDirectory } from './build-profile.mjs';
5
+ import { localeOverride, systemLocale, translate } from './system-i18n.mjs';
6
+
7
+ const choices = new Set(['system', 'en', 'zh-CN']);
8
+ const directory = profileStateDirectory();
9
+ const file = path.join(directory, 'interface-language');
10
+ function readPreference() {
11
+ try {
12
+ const value = readFileSync(file, 'utf8').trim();
13
+ if (choices.has(value)) return value;
14
+ } catch (error) {
15
+ if (error.code !== 'ENOENT' && error.code !== 'EACCES') throw error;
16
+ }
17
+ return 'system';
18
+ }
19
+ let preference = readPreference();
20
+ const effectiveLocale = () => localeOverride || (preference === 'system' ? systemLocale : preference);
21
+ export let locale = effectiveLocale();
22
+
23
+ export function interfaceLanguage() {
24
+ return { preference, locale, overridden: Boolean(localeOverride) };
25
+ }
26
+
27
+ export function setInterfaceLanguage(value) {
28
+ if (!choices.has(value)) throw Object.assign(new Error('invalid_language'), {code:'invalid_language'});
29
+ if (localeOverride) throw Object.assign(new Error('language_overridden'), {code:'language_overridden'});
30
+ mkdirSync(directory, { recursive: true, mode: 0o700 });
31
+ const temp = file + '.' + randomUUID();
32
+ try {
33
+ writeFileSync(temp, value + '\n', { flag: 'wx', mode: 0o600 });
34
+ renameSync(temp, file);
35
+ } finally { rmSync(temp, {force:true}); }
36
+ preference = value;
37
+ locale = effectiveLocale();
38
+ return interfaceLanguage();
39
+ }
40
+
41
+ export function t(message, ...args) { return translate(locale, message, ...args); }
package/mcp-http.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { t } from "./i18n.mjs";
2
3
  import { createServer } from 'node:http';
3
4
  import { randomUUID } from 'node:crypto';
4
5
  import { readFile } from 'node:fs/promises';
@@ -9,8 +10,8 @@ import { tokenPath } from './paths.mjs';
9
10
 
10
11
  const host = process.env.OPEN_BROWSER_MCP_HTTP_HOST || '127.0.0.1';
11
12
  const port = Number(process.env.OPEN_BROWSER_MCP_HTTP_PORT || 9239);
12
- if (!['127.0.0.1', '::1'].includes(host)) throw new Error('MCP HTTP 只允许绑定回环地址。');
13
- if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error('OPEN_BROWSER_MCP_HTTP_PORT 无效。');
13
+ if (!['127.0.0.1', '::1'].includes(host)) throw new Error(t("The MCP HTTP server must bind to a loopback address."));
14
+ if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error(t("Invalid OPEN_BROWSER_MCP_HTTP_PORT."));
14
15
 
15
16
  async function readToken() {
16
17
  const configured = process.env.OPEN_BROWSER_MCP_HTTP_TOKEN?.trim();
package/mcp-server.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { t } from "./i18n.mjs";
1
2
  import { Agent } from 'node:http';
2
3
  import { readFileSync } from 'node:fs';
3
4
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
@@ -22,11 +23,11 @@ export function createMcpServer() {
22
23
  const arguments_ = params.arguments ?? {};
23
24
  if (['createWorkspace', 'open'].includes(params.name) &&
24
25
  (typeof arguments_.name !== 'string' || !arguments_.name.trim()))
25
- throw new McpError(ErrorCode.InvalidParams, '创建 Agent 任务时必须提供非空任务名称 name。');
26
+ throw new McpError(ErrorCode.InvalidParams, t("Supply a non-empty task name when creating an agent workspace."));
26
27
  args = checkAgentRequest(params.name, arguments_);
27
28
  } catch (error) {
28
29
  if (error instanceof McpError) throw error;
29
- throw new McpError(ErrorCode.InvalidParams, 'Invalid open-browser tool name or arguments');
30
+ throw new McpError(ErrorCode.InvalidParams, t("Invalid open-browser tool name or arguments."));
30
31
  }
31
32
  try {
32
33
  if (!api) {
@@ -49,7 +50,7 @@ export function createMcpServer() {
49
50
  } catch (error) {
50
51
  const detail = error instanceof OpenBrowserError
51
52
  ? { code: error.code, message: error.message, ...(error.nextAction ? { nextAction: error.nextAction } : {}) }
52
- : { code: 'CLIENT_ERROR', message: '本地服务调用失败。' };
53
+ : { code: 'CLIENT_ERROR', message: t("The local service call failed.") };
53
54
  return { isError: true, content: [{ type: 'text', text: JSON.stringify(detail) }] };
54
55
  }
55
56
  });