@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.
- package/CONTRIBUTING.md +2 -0
- package/Docs/desktop-packages.md +45 -0
- 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
- package/README.md +8 -6
- package/README.zh-CN.md +2 -0
- package/api-contract.mjs +2 -1
- package/browser-extension/_locales/en/messages.json +8 -0
- package/browser-extension/_locales/zh_CN/messages.json +8 -0
- package/browser-extension/i18n.js +84 -0
- package/browser-extension/manifest.json +5 -4
- package/browser-extension/messages.js +266 -0
- package/browser-extension/newtab.css +4 -0
- package/browser-extension/newtab.html +9 -9
- package/browser-extension/newtab.js +38 -36
- package/browser-extension/page-locale.js +23 -0
- package/browser-extension/phase-labels.js +33 -6
- package/browser-extension/popup.css +2 -2
- package/browser-extension/popup.html +24 -26
- package/browser-extension/popup.js +72 -49
- package/browser-extension/tab-action.js +29 -24
- package/browser-extension/worker.js +29 -5
- package/browser-extension/workspace-title.js +2 -2
- package/build-profile.mjs +10 -2
- package/chromium-host.mjs +22 -11
- package/chromium-shell.mjs +5 -3
- package/cli.mjs +33 -30
- package/control.mjs +9 -8
- package/desktop/Info.plist +3 -1
- package/desktop/Launcher.m +10 -2
- package/desktop/OBControlBar.m +12 -8
- package/desktop/OBLocalization.h +20 -0
- package/desktop/OBPageView.m +2 -1
- package/desktop/WorkspacePanel.m +84 -83
- package/desktop/archive-release.py +5 -1
- package/desktop/build-macos.mjs +11 -5
- package/desktop/build-managed-input.mjs +2 -1
- package/desktop/build-portable.mjs +5 -3
- package/desktop/build-profile.mjs +2 -1
- package/desktop/build.mjs +2 -1
- package/desktop/create-shortcut.ps1 +7 -1
- package/desktop/en.lproj/Localizable.strings +106 -0
- package/desktop/install-menu-entry.mjs +2 -0
- package/desktop/notarize-macos.mjs +21 -24
- package/desktop/package-macos.mjs +4 -3
- package/desktop/sign.mjs +5 -4
- package/desktop/start-profile.mjs +2 -1
- package/desktop/start.mjs +3 -1
- package/desktop/verify-macos-release.mjs +9 -8
- package/desktop/zh-Hans.lproj/Localizable.strings +106 -0
- package/engine-service.mjs +1 -1
- package/hosted/cli.mjs +2 -1
- package/hosted/init.mjs +2 -1
- package/i18n.mjs +41 -0
- package/mcp-http.mjs +3 -2
- package/mcp-server.mjs +4 -3
- package/messages.zh-CN.mjs +175 -0
- package/package.json +4 -1
- package/page-activity.mjs +8 -6
- package/paths.mjs +2 -5
- package/runtime.mjs +4 -3
- package/sdk.mjs +40 -39
- package/service.mjs +2 -1
- package/skills/open-browser/SKILL.md +11 -9
- package/skills/open-browser/SKILL.zh-CN.md +22 -0
- package/skills/open-browser/references/macos.en.md +3 -0
- package/skills/open-browser/references/macos.md +2 -0
- package/skills/open-browser/references/operations.en.md +54 -0
- package/skills/open-browser/references/operations.md +2 -0
- package/skills/open-browser/references/recovery.en.md +36 -0
- package/skills/open-browser/references/recovery.md +2 -0
- package/skills/open-browser/references/windows.en.md +3 -0
- package/skills/open-browser/references/windows.md +2 -0
- package/skills/open-browser/scripts/bootstrap.mjs +6 -4
- package/skills/open-browser/scripts/guide.mjs +7 -4
- package/skills/open-browser/scripts/open-browser +5 -1
- package/studio/demo-site.mjs +5 -4
- package/studio/index.html +37 -33
- package/studio/index.mjs +10 -3
- package/studio/native-demo.mjs +8 -7
- package/studio/studio.css +3 -0
- package/studio/studio.js +98 -68
- package/system-i18n.mjs +19 -0
package/studio/studio.js
CHANGED
|
@@ -1,26 +1,48 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
|
|
3
|
+
const { t, applyDocument, setLocale, messageLabels, bindLanguageSelect } = globalThis.openBrowserI18n;
|
|
4
|
+
setLocale(document.documentElement.lang);
|
|
5
|
+
applyDocument(document);
|
|
2
6
|
const $ = id => document.getElementById(id);
|
|
3
7
|
const state = { access: '', config: {}, workspaces: [], workspace: '', page: '', detail: null, demoRetry: null, demoOperations: new Set(), refreshId: 0, entered: false };
|
|
4
8
|
const active = () => state.workspaces.find(w => w.workspaceId === state.workspace);
|
|
5
9
|
const currentPage = () => active()?.pages.find(p => p.pageId === state.page);
|
|
6
|
-
const timestamp = () => new Date().toLocaleTimeString(
|
|
7
|
-
const labels = { agent:
|
|
8
|
-
const groups = [
|
|
9
|
-
{ id: 'attention', title:
|
|
10
|
-
{ id: 'human', title:
|
|
10
|
+
const timestamp = () => new Date().toLocaleTimeString(globalThis.openBrowserI18n.locale, { hour12: false });
|
|
11
|
+
const labels = messageLabels({ agent: "Agent in control", human: "User in control", transferring: "Transferring" });
|
|
12
|
+
const groups = () => [
|
|
13
|
+
{ id: 'attention', title: t("Needs attention") }, { id: 'running', title: t("Agent running") },
|
|
14
|
+
{ id: 'human', title: t("Take over") }, { id: 'idle', title: t("Idle") },
|
|
11
15
|
];
|
|
12
|
-
const phases = { idle:
|
|
13
|
-
completed:
|
|
14
|
-
const kinds = { openPage:
|
|
15
|
-
const stepKinds = { click:
|
|
16
|
-
const errorText = {
|
|
17
|
-
credential_required:
|
|
18
|
-
pairing_failed:
|
|
19
|
-
unauthorized:
|
|
20
|
-
origin_not_allowed: '
|
|
21
|
-
login_form_changed:
|
|
22
|
-
human_control:
|
|
23
|
-
};
|
|
16
|
+
const phases = messageLabels({ idle: "Waiting for instructions", queued: "Queued", running: "Running", needs_credential: "Waiting for credentials",
|
|
17
|
+
completed: "Completed", failed: "Action failed", needs_visual_permission: "Screenshot permission required", cancelled: "Cancelled", outcome_unknown: "Result needs verification" });
|
|
18
|
+
const kinds = messageLabels({ openPage: "Open page", observe: "Observe page", act: "Page action" });
|
|
19
|
+
const stepKinds = messageLabels({ click: "Click", fill: "Fill", fillCredential: "Fill credential" });
|
|
20
|
+
const errorText = messageLabels({
|
|
21
|
+
credential_required: "Supply the missing credential.", wrong_password: "The site rejected the username or password. Update it and try again.",
|
|
22
|
+
pairing_failed: "This entry link has been used. Reopen the console from Open Browser.",
|
|
23
|
+
unauthorized: "This entry link has expired. Reopen the console.",
|
|
24
|
+
origin_not_allowed: "The new page is outside this workspace's allowed sites. Create another workspace.",
|
|
25
|
+
login_form_changed: "The sign-in form changed. Read the page and try again.",
|
|
26
|
+
human_control: "The user controls this workspace. Return control to the agent first.",
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const showLanguage = bindLanguageSelect($('interface-language'), async preference => {
|
|
30
|
+
const settings = await post('/language', {preference});
|
|
31
|
+
updateLanguage(settings);
|
|
32
|
+
return settings;
|
|
33
|
+
}, notify);
|
|
34
|
+
|
|
35
|
+
function updateLanguage(settings) {
|
|
36
|
+
const changed = settings.locale !== globalThis.openBrowserI18n.locale;
|
|
37
|
+
setLocale(settings.locale);
|
|
38
|
+
showLanguage(settings);
|
|
39
|
+
if (!changed) return;
|
|
40
|
+
applyDocument(document);
|
|
41
|
+
paint();
|
|
42
|
+
if (!$('observed-at').textContent) clearObservation();
|
|
43
|
+
$('reveal').textContent = $('demo-secret').textContent ? t('Hide password') : t('Show password');
|
|
44
|
+
if ($('activity').querySelector('time')) $('activity-count').textContent = t('Records: {0}', $('activity').children.length);
|
|
45
|
+
}
|
|
24
46
|
|
|
25
47
|
async function post(route, payload) {
|
|
26
48
|
const headers = { 'Content-Type': 'application/json' };
|
|
@@ -31,7 +53,9 @@ async function post(route, payload) {
|
|
|
31
53
|
return data;
|
|
32
54
|
}
|
|
33
55
|
async function call(method, params = {}) {
|
|
34
|
-
|
|
56
|
+
const data = await post('/call', { method, params });
|
|
57
|
+
updateLanguage(data.language);
|
|
58
|
+
return data.result;
|
|
35
59
|
}
|
|
36
60
|
function log(message) {
|
|
37
61
|
const list = $('activity');
|
|
@@ -42,14 +66,14 @@ function log(message) {
|
|
|
42
66
|
row.append(time, document.createTextNode(message));
|
|
43
67
|
list.prepend(row);
|
|
44
68
|
while (list.children.length > 20) list.lastElementChild.remove();
|
|
45
|
-
$('activity-count').textContent = list.children.length
|
|
69
|
+
$('activity-count').textContent = t("Records: {0}", list.children.length);
|
|
46
70
|
}
|
|
47
71
|
function notify(message) {
|
|
48
72
|
$('notice').textContent = message;
|
|
49
73
|
$('notice').hidden = !message;
|
|
50
74
|
}
|
|
51
75
|
function clearObservation() {
|
|
52
|
-
$('snapshot').textContent =
|
|
76
|
+
$('snapshot').textContent = t("No observation yet");
|
|
53
77
|
$('observed-at').textContent = '';
|
|
54
78
|
}
|
|
55
79
|
function choose(workspaceId) {
|
|
@@ -70,7 +94,7 @@ function clearSensitiveInputs() {
|
|
|
70
94
|
$('credential-settings').open = false;
|
|
71
95
|
$('demo-secret').textContent = '';
|
|
72
96
|
$('demo-details').open = false;
|
|
73
|
-
$('reveal').textContent =
|
|
97
|
+
$('reveal').textContent = t("Show password");
|
|
74
98
|
}
|
|
75
99
|
function groupOf(w) {
|
|
76
100
|
if (w.mode === 'human' || w.mode === 'transferring') return 'human';
|
|
@@ -81,25 +105,25 @@ function groupOf(w) {
|
|
|
81
105
|
}
|
|
82
106
|
function describe(operation) {
|
|
83
107
|
if (!operation) return '';
|
|
84
|
-
const kind = kinds[operation.kind] ||
|
|
85
|
-
const status = operation.error === 'credential_required' ?
|
|
108
|
+
const kind = kinds[operation.kind] || t("Action");
|
|
109
|
+
const status = operation.error === 'credential_required' ? t("Missing credential") :
|
|
86
110
|
phases[operation.state] || operation.state;
|
|
87
111
|
if (operation.state === 'running' && operation.stepKind) {
|
|
88
|
-
return stepKinds[operation.stepKind] + ' · ' + operation.completedSteps + '/' + operation.totalSteps;
|
|
112
|
+
return (stepKinds[operation.stepKind] || kind) + ' · ' + operation.completedSteps + '/' + operation.totalSteps;
|
|
89
113
|
}
|
|
90
114
|
return [kind, status].filter(Boolean).join(' · ');
|
|
91
115
|
}
|
|
92
116
|
function shortState(w) {
|
|
93
117
|
if (w.mode !== 'agent') return labels[w.mode];
|
|
94
118
|
const a = w.activity || {};
|
|
95
|
-
if (a.needsCredential) return
|
|
96
|
-
return describe(a.current) || phases[a.phase] ||
|
|
119
|
+
if (a.needsCredential) return t("Waiting for credentials");
|
|
120
|
+
return describe(a.current) || phases[a.phase] || t("Waiting for instructions");
|
|
97
121
|
}
|
|
98
122
|
function paintRail() {
|
|
99
|
-
const byGroup = new Map(groups.map(g => [g.id, []]));
|
|
123
|
+
const byGroup = new Map(groups().map(g => [g.id, []]));
|
|
100
124
|
for (const w of state.workspaces) byGroup.get(groupOf(w)).push(w);
|
|
101
|
-
const view = groups.map(g => ({ ...g, items: byGroup.get(g.id).map(w => ({
|
|
102
|
-
id: w.workspaceId, name: w.name ||
|
|
125
|
+
const view = groups().map(g => ({ ...g, items: byGroup.get(g.id).map(w => ({
|
|
126
|
+
id: w.workspaceId, name: w.name || t("Workspace"), status: shortState(w),
|
|
103
127
|
pages: w.pages.length, selected: w.workspaceId === state.workspace,
|
|
104
128
|
})) }));
|
|
105
129
|
const rail = $('workspaces');
|
|
@@ -131,7 +155,7 @@ function paintRail() {
|
|
|
131
155
|
const name = document.createElement('b');
|
|
132
156
|
name.textContent = row.name;
|
|
133
157
|
const status = document.createElement('small');
|
|
134
|
-
status.textContent = row.status + ' · ' + row.pages
|
|
158
|
+
status.textContent = row.status + ' · ' + t("Pages: {0}", row.pages);
|
|
135
159
|
item.append(name, status);
|
|
136
160
|
item.onclick = () => { if (state.workspace !== row.id) { choose(row.id); sync(); } };
|
|
137
161
|
block.append(item);
|
|
@@ -163,12 +187,12 @@ function paintCredential() {
|
|
|
163
187
|
if (!request) return;
|
|
164
188
|
const demoPassword = request.origin === new URL(state.config.demoUrl).origin && request.credentialRef === 'demo.password';
|
|
165
189
|
const canContinue = state.demoOperations.has(request.operationId);
|
|
166
|
-
$('credential-title').textContent = demoPassword ?
|
|
190
|
+
$('credential-title').textContent = demoPassword ? t("Password needed") : t("Credential needed");
|
|
167
191
|
$('credential-ref').textContent = request.credentialRef;
|
|
168
192
|
$('credential-origin').textContent = request.origin;
|
|
169
|
-
$('credential-label').textContent = demoPassword ?
|
|
193
|
+
$('credential-label').textContent = demoPassword ? t("Password") : t("Credential value");
|
|
170
194
|
$('insert-password').hidden = !demoPassword;
|
|
171
|
-
$('submit-credential').textContent = canContinue ?
|
|
195
|
+
$('submit-credential').textContent = canContinue ? t("Supply and continue") : t("Bind credential");
|
|
172
196
|
}
|
|
173
197
|
function paint() {
|
|
174
198
|
paintRail();
|
|
@@ -176,15 +200,15 @@ function paint() {
|
|
|
176
200
|
$('new-view').hidden = Boolean(w);
|
|
177
201
|
$('active-view').hidden = !w;
|
|
178
202
|
if (!w) return;
|
|
179
|
-
$('workspace-name').textContent = w.name ||
|
|
203
|
+
$('workspace-name').textContent = w.name || t("Workspace");
|
|
180
204
|
$('wid').title = w.workspaceId;
|
|
181
205
|
$('mode').textContent = labels[w.mode] || w.mode;
|
|
182
206
|
const a = w.activity || {};
|
|
183
|
-
$('work-state').textContent = w.mode === 'human' ?
|
|
184
|
-
w.mode === 'transferring' ?
|
|
185
|
-
describe(a.current) ||
|
|
186
|
-
if (w.mode === 'agent' && a.queued > 0) $('work-state').textContent
|
|
187
|
-
$('result-text').textContent = describe(a.recent) ||
|
|
207
|
+
$('work-state').textContent = w.mode === 'human' ? t("Automation paused") :
|
|
208
|
+
w.mode === 'transferring' ? t("Transferring control…") : a.needsCredential ? t("Waiting for a credential") :
|
|
209
|
+
describe(a.current) || t("Waiting for instructions");
|
|
210
|
+
if (w.mode === 'agent' && a.queued > 0) $('work-state').textContent = t("{0} · Queued: {1}", $('work-state').textContent, a.queued);
|
|
211
|
+
$('result-text').textContent = describe(a.recent) || t("No completed actions");
|
|
188
212
|
$('take').hidden = w.mode !== 'agent' || !w.pages.length;
|
|
189
213
|
$('give').hidden = w.mode !== 'human';
|
|
190
214
|
$('view-controlled').hidden = w.mode !== 'human' || !w.pages.length;
|
|
@@ -207,7 +231,7 @@ function paint() {
|
|
|
207
231
|
state.page = fallback;
|
|
208
232
|
}
|
|
209
233
|
if (pages.value !== state.page) pages.value = state.page;
|
|
210
|
-
$('wid').textContent = [currentPage()?.origin, w.pages.length
|
|
234
|
+
$('wid').textContent = [currentPage()?.origin, t("Pages in workspace: {0}", w.pages.length)].filter(Boolean).join(' · ');
|
|
211
235
|
const isDemo = currentPage()?.origin === new URL(state.config.demoUrl).origin;
|
|
212
236
|
$('login-action').hidden = !isDemo || w.mode !== 'agent';
|
|
213
237
|
$('demo-details').hidden = !isDemo;
|
|
@@ -221,7 +245,7 @@ function paint() {
|
|
|
221
245
|
}
|
|
222
246
|
function setConnected(connected) {
|
|
223
247
|
$('connection-status').dataset.connected = String(connected);
|
|
224
|
-
$('connection').textContent = connected ?
|
|
248
|
+
$('connection').textContent = connected ? t("Local service connected") : t("Service disconnected");
|
|
225
249
|
}
|
|
226
250
|
async function refresh() {
|
|
227
251
|
const sequence = ++state.refreshId;
|
|
@@ -252,7 +276,7 @@ function command(id, fn, event = 'click') {
|
|
|
252
276
|
notify('');
|
|
253
277
|
try { await fn(); }
|
|
254
278
|
catch (err) {
|
|
255
|
-
const msg = errorText[err.message] ||
|
|
279
|
+
const msg = errorText[err.message] || t("Action did not complete ({0})", err.message);
|
|
256
280
|
notify(msg);
|
|
257
281
|
log(msg);
|
|
258
282
|
} finally {
|
|
@@ -273,13 +297,13 @@ async function create(name, url) {
|
|
|
273
297
|
choose(workspaceId);
|
|
274
298
|
state.page = page.pageId;
|
|
275
299
|
paint();
|
|
276
|
-
log(
|
|
300
|
+
log(t("Opened “{0}”", name));
|
|
277
301
|
return { workspaceId, pageId: page.pageId };
|
|
278
302
|
}
|
|
279
303
|
async function observe(page, method = 'observe') {
|
|
280
304
|
const snap = await call(method, page);
|
|
281
305
|
if (state.workspace === page.workspaceId && state.page === page.pageId) {
|
|
282
|
-
$('snapshot').textContent = snap.text || (snap.elements || []).map(e => e.role + ' ' + e.name).join('\n') ||
|
|
306
|
+
$('snapshot').textContent = snap.text || (snap.elements || []).map(e => e.role + ' ' + e.name).join('\n') || t("No visible text on this page");
|
|
283
307
|
$('observed-at').textContent = timestamp();
|
|
284
308
|
}
|
|
285
309
|
return snap;
|
|
@@ -289,17 +313,22 @@ async function putCredential(page, credentialRef, value) {
|
|
|
289
313
|
}
|
|
290
314
|
async function runLogin(page) {
|
|
291
315
|
const snap = await observe(page);
|
|
292
|
-
|
|
293
|
-
|
|
316
|
+
// A demo document keeps its language if the console switches mid-sign-in.
|
|
317
|
+
const matches = (value, source, exact = true) => ['en','zh-CN'].some(language => {
|
|
318
|
+
const text = globalThis.openBrowserI18n.translate(language, source);
|
|
319
|
+
return exact ? value === text : value.includes(text);
|
|
320
|
+
});
|
|
321
|
+
const authenticated = observation => matches(observation.text, 'My account', false) &&
|
|
322
|
+
observation.elements.some(e => e.role === 'button' && matches(e.name, 'Sign out'));
|
|
294
323
|
if (authenticated(snap)) {
|
|
295
324
|
state.demoRetry = null;
|
|
296
|
-
log(
|
|
325
|
+
log(t("Read the signed-in account page"));
|
|
297
326
|
return;
|
|
298
327
|
}
|
|
299
|
-
const find = (role, name) => snap.elements.find(element => element.role === role && element.name
|
|
300
|
-
const username = find('textbox', '
|
|
301
|
-
const password = find('textbox', '
|
|
302
|
-
const submit = find('button', '
|
|
328
|
+
const find = (role, name) => snap.elements.find(element => element.role === role && matches(element.name, name))?.ref;
|
|
329
|
+
const username = find('textbox', 'Username');
|
|
330
|
+
const password = find('textbox', 'Password');
|
|
331
|
+
const submit = find('button', 'Sign in');
|
|
303
332
|
if (!username || !password || !submit) throw new Error('login_form_changed');
|
|
304
333
|
const request = {
|
|
305
334
|
workspaceId: page.workspaceId, pageId: page.pageId, documentId: snap.documentId,
|
|
@@ -318,12 +347,12 @@ async function runLogin(page) {
|
|
|
318
347
|
receipt = await call('getOperation', { workspaceId: page.workspaceId, operationId: request.operationId });
|
|
319
348
|
}
|
|
320
349
|
if (receipt.error === 'credential_required' && receipt.credentialRef === 'demo.password') {
|
|
321
|
-
log(
|
|
350
|
+
log(t("Task is waiting for a password"));
|
|
322
351
|
return;
|
|
323
352
|
}
|
|
324
353
|
if (receipt.state !== 'completed') throw new Error(receipt.error || receipt.state);
|
|
325
354
|
const after = await observe(page);
|
|
326
|
-
if (after.text
|
|
355
|
+
if (matches(after.text, 'Incorrect username or password', false)) {
|
|
327
356
|
state.demoRetry = { ...page, operationId: request.operationId, credentialRef: 'demo.password', origin: new URL(state.config.demoUrl).origin };
|
|
328
357
|
paint();
|
|
329
358
|
throw new Error('wrong_password');
|
|
@@ -331,10 +360,10 @@ async function runLogin(page) {
|
|
|
331
360
|
if (!authenticated(after))
|
|
332
361
|
throw new Error('account_page_unconfirmed');
|
|
333
362
|
state.demoRetry = null;
|
|
334
|
-
log(
|
|
363
|
+
log(t("Signed in and read the account page"));
|
|
335
364
|
}
|
|
336
365
|
async function demo(withPassword) {
|
|
337
|
-
const page = await create(withPassword ?
|
|
366
|
+
const page = await create(withPassword ? t("Automatic sign-in") : t("Supply a missing credential"), state.config.demoUrl);
|
|
338
367
|
await putCredential(page, 'demo.username', state.config.username);
|
|
339
368
|
if (withPassword) await putCredential(page, 'demo.password', (await post('/demo-password', {})).password);
|
|
340
369
|
await runLogin(page);
|
|
@@ -344,10 +373,10 @@ function pageHandle() {
|
|
|
344
373
|
}
|
|
345
374
|
|
|
346
375
|
command('show-new', () => choose(''));
|
|
347
|
-
command('new-form', () => create($('name').value.trim() ||
|
|
376
|
+
command('new-form', () => create($('name').value.trim() || t("My workspace"), $('url').value), 'submit');
|
|
348
377
|
command('demo', () => demo(true));
|
|
349
378
|
command('missing', () => demo(false));
|
|
350
|
-
command('observe', async () => { await observe(pageHandle(), 'previewPage'); log(
|
|
379
|
+
command('observe', async () => { await observe(pageHandle(), 'previewPage'); log(t("Read the current page")); });
|
|
351
380
|
command('login-action', () => runLogin(pageHandle()));
|
|
352
381
|
command('insert-password', async () => { $('password').value = (await post('/demo-password', {})).password; });
|
|
353
382
|
command('credential-form', async () => {
|
|
@@ -367,7 +396,7 @@ command('credential-form', async () => {
|
|
|
367
396
|
if (state.demoOperations.has(req.operationId)) {
|
|
368
397
|
state.demoRetry = null;
|
|
369
398
|
await runLogin({ workspaceId: req.workspaceId, pageId: req.pageId });
|
|
370
|
-
} else log(
|
|
399
|
+
} else log(t("Credential bound. The agent can observe again and submit the remaining actions."));
|
|
371
400
|
}, 'submit');
|
|
372
401
|
command('bind-form', async () => {
|
|
373
402
|
const page = currentPage();
|
|
@@ -375,39 +404,39 @@ command('bind-form', async () => {
|
|
|
375
404
|
$('bind-value').value = '';
|
|
376
405
|
await call('setCredential', { workspaceId: state.workspace, origin: page.origin, credentialRef: $('bind-id').value, value });
|
|
377
406
|
$('credential-settings').open = false;
|
|
378
|
-
log(
|
|
407
|
+
log(t("Credential bound to the site in this workspace"));
|
|
379
408
|
}, 'submit');
|
|
380
409
|
command('take', async () => {
|
|
381
410
|
await call('takeControl', pageHandle());
|
|
382
411
|
clearObservation();
|
|
383
|
-
log(
|
|
412
|
+
log(t("You now control this workspace"));
|
|
384
413
|
});
|
|
385
414
|
command('give', async () => {
|
|
386
415
|
await call('returnToAgent', { workspaceId: state.workspace });
|
|
387
416
|
clearObservation();
|
|
388
|
-
log(
|
|
417
|
+
log(t("Control returned to the agent. Observe the page again."));
|
|
389
418
|
});
|
|
390
419
|
command('view-controlled', async () => {
|
|
391
420
|
await call('showPage', pageHandle());
|
|
392
|
-
log(
|
|
421
|
+
log(t("Displayed the controlled page"));
|
|
393
422
|
});
|
|
394
423
|
command('close-workspace', async () => {
|
|
395
424
|
await call('closeWorkspace', { workspaceId: state.workspace });
|
|
396
425
|
if (state.demoRetry?.workspaceId === state.workspace) state.demoRetry = null;
|
|
397
426
|
choose('');
|
|
398
|
-
log(
|
|
427
|
+
log(t("Workspace closed"));
|
|
399
428
|
});
|
|
400
429
|
command('page-form', async () => {
|
|
401
430
|
const page = await call('openPage', { workspaceId: state.workspace, url: $('address').value });
|
|
402
431
|
state.page = page.pageId;
|
|
403
432
|
$('address').value = '';
|
|
404
433
|
clearObservation();
|
|
405
|
-
log(
|
|
434
|
+
log(t("Opened a new page"));
|
|
406
435
|
}, 'submit');
|
|
407
436
|
command('reveal', async () => {
|
|
408
437
|
const showing = Boolean($('demo-secret').textContent);
|
|
409
438
|
$('demo-secret').textContent = showing ? '' : (await post('/demo-password', {})).password;
|
|
410
|
-
$('reveal').textContent = showing ?
|
|
439
|
+
$('reveal').textContent = showing ? t("Show password") : t("Hide password");
|
|
411
440
|
});
|
|
412
441
|
$('pages').onchange = () => { state.page = $('pages').value; clearObservation(); paint(); };
|
|
413
442
|
|
|
@@ -419,20 +448,21 @@ $('pages').onchange = () => { state.page = $('pages').value; clearObservation();
|
|
|
419
448
|
sessionStorage.setItem('open-browser.studio', state.access);
|
|
420
449
|
} else state.access = sessionStorage.getItem('open-browser.studio') || '';
|
|
421
450
|
state.config = await post('/config', {});
|
|
451
|
+
updateLanguage(state.config.language);
|
|
422
452
|
$('demo-user').textContent = state.config.username;
|
|
423
453
|
$('url').value = state.config.demoUrl;
|
|
424
454
|
state.workspace = sessionStorage.getItem('open-browser.selection') || '';
|
|
425
455
|
await refresh();
|
|
426
456
|
if (!state.workspace && !sessionStorage.getItem('open-browser.selection') &&
|
|
427
457
|
state.workspaces.length && !state.entered) {
|
|
428
|
-
const first = groups.flatMap(g => state.workspaces.filter(w => groupOf(w) === g.id))[0];
|
|
458
|
+
const first = groups().flatMap(g => state.workspaces.filter(w => groupOf(w) === g.id))[0];
|
|
429
459
|
choose(first.workspaceId);
|
|
430
460
|
await refresh();
|
|
431
461
|
}
|
|
432
462
|
setInterval(() => { if (!document.hidden) sync(); }, 900);
|
|
433
463
|
document.addEventListener('visibilitychange', () => { if (!document.hidden) sync(); });
|
|
434
464
|
})().catch(error => {
|
|
435
|
-
$('connection').textContent =
|
|
436
|
-
notify(errorText[error.message] ||
|
|
465
|
+
$('connection').textContent = t("Disconnected");
|
|
466
|
+
notify(errorText[error.message] || t("Could not connect to the local console. Restart Open Browser."));
|
|
437
467
|
document.querySelectorAll('button,input,select').forEach(el => el.disabled = true);
|
|
438
468
|
});
|
package/system-i18n.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import './browser-extension/messages.js';
|
|
2
|
+
import './browser-extension/i18n.js';
|
|
3
|
+
import chinese from './messages.zh-CN.mjs';
|
|
4
|
+
|
|
5
|
+
const i18n = globalThis.openBrowserI18n;
|
|
6
|
+
export const systemLocale = i18n.resolveLocale(process.env.OPEN_BROWSER_SYSTEM_LOCALE ||
|
|
7
|
+
process.env.LC_ALL || process.env.LC_MESSAGES || process.env.LANG || Intl.DateTimeFormat().resolvedOptions().locale);
|
|
8
|
+
export const localeOverride = process.env.OPEN_BROWSER_LOCALE?.trim()
|
|
9
|
+
? i18n.resolveLocale(process.env.OPEN_BROWSER_LOCALE) : undefined;
|
|
10
|
+
|
|
11
|
+
export function translate(language, message, ...args) {
|
|
12
|
+
if (language === 'zh-CN' && Object.hasOwn(chinese, message)) return i18n.format(chinese[message], args);
|
|
13
|
+
return i18n.translate(language, message, ...args);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Bootstrap commands use this before they select a build or state directory.
|
|
17
|
+
export function systemMessage(message, ...args) {
|
|
18
|
+
return translate(localeOverride || systemLocale, message, ...args);
|
|
19
|
+
}
|