@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
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { errorLabel, phases } from './phase-labels.js';
|
|
2
|
+
|
|
3
|
+
const { t } = globalThis.openBrowserI18n;
|
|
2
4
|
|
|
3
5
|
const el = id => document.getElementById(id);
|
|
4
6
|
let selected = '', detail, request, selectedTab = '', revision = 0, busy = false, refreshing = false, contextTab = false;
|
|
5
|
-
const
|
|
7
|
+
const workspaceTitle = globalThis.openBrowserWorkspaceTitle;
|
|
6
8
|
|
|
7
9
|
async function call(method, params = {}) {
|
|
8
10
|
const reply = await chrome.runtime.sendMessage({ method, params });
|
|
@@ -16,15 +18,15 @@ function notify(text = '') {
|
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
function describe(w) {
|
|
19
|
-
if (w.activity?.needsHumanVerification) return
|
|
20
|
-
if (w.mode === 'human') return
|
|
21
|
-
if (w.mode === 'transferring') return
|
|
22
|
-
if (w.activity?.needsCredential) return
|
|
23
|
-
if (w.activity?.needsVisualPermission) return
|
|
21
|
+
if (w.activity?.needsHumanVerification) return t("Human verification required");
|
|
22
|
+
if (w.mode === 'human') return t("Human in control");
|
|
23
|
+
if (w.mode === 'transferring') return t("Transferring");
|
|
24
|
+
if (w.activity?.needsCredential) return t("Waiting for credentials");
|
|
25
|
+
if (w.activity?.needsVisualPermission) return t("Screenshot permission required");
|
|
24
26
|
const current = w.activity?.current;
|
|
25
27
|
const stage = current?.dispatchState;
|
|
26
|
-
if (stage) return stage === 'dispatched' ?
|
|
27
|
-
return phases[current?.phase] || phases[w.activity?.phase] ||
|
|
28
|
+
if (stage) return stage === 'dispatched' ? t("Dispatched") : t("Waiting for page");
|
|
29
|
+
return phases[current?.phase] || phases[w.activity?.phase] || t("Agent in control");
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
function options(node, entries, value) {
|
|
@@ -43,10 +45,10 @@ function showCredential(next) {
|
|
|
43
45
|
el('credential').hidden = !next;
|
|
44
46
|
if (!next) return;
|
|
45
47
|
el('credential-target').textContent = next.origin + ' · ' + next.credentialRef;
|
|
46
|
-
el('save').textContent =
|
|
48
|
+
el('save').textContent = t("Bind credential");
|
|
47
49
|
}
|
|
48
50
|
|
|
49
|
-
let popupTabId, ordinaryTarget, tokenTimer, standalone = false;
|
|
51
|
+
let popupTabId, ordinaryTarget, tokenTimer, standalone = false, initialized = false;
|
|
50
52
|
function clearToken() {
|
|
51
53
|
clearTimeout(tokenTimer);
|
|
52
54
|
el('adopt-token').value = '';
|
|
@@ -60,7 +62,7 @@ function authorizeTab(bindOnApproval) {
|
|
|
60
62
|
const reply = await call('offerCurrentTab',{workspaceId:el('adopt-task').value, tabId:popupTabId,
|
|
61
63
|
targetId, origin, bindOnApproval, resumeOnRestart:el('resume-tab').checked, accountAlias:el('adopt-alias').value.trim()});
|
|
62
64
|
if (bindOnApproval && reply.pageId) {
|
|
63
|
-
notify(
|
|
65
|
+
notify(t("This tab is now assigned to the selected task."));
|
|
64
66
|
return;
|
|
65
67
|
}
|
|
66
68
|
el('adopt-token').value = JSON.stringify({workspaceId:reply.workspaceId,adoptionToken:reply.adoptionToken});
|
|
@@ -74,13 +76,13 @@ el('adopt-manual').onclick = () => authorizeTab(false);
|
|
|
74
76
|
|
|
75
77
|
let deliveryKey = '', finishId;
|
|
76
78
|
function renderDelivery(w) {
|
|
77
|
-
const originLabels = {resource:
|
|
79
|
+
const originLabels = {resource:t("Load static resources"),navigation:t("Allow navigation and page actions")};
|
|
78
80
|
const blocks = (w.blockedOrigins || []).filter(item => originLabels[item.scope]);
|
|
79
81
|
el('blocked').replaceChildren(...blocks.map(item => {
|
|
80
82
|
const button = document.createElement('button');
|
|
81
83
|
button.type = 'button';
|
|
82
84
|
button.className = 'secondary';
|
|
83
|
-
button.textContent =
|
|
85
|
+
button.textContent = t("For this task: {0} · {1}", originLabels[item.scope], item.origin);
|
|
84
86
|
button.onclick = () => perform(() => call('grantOrigin',{workspaceId:w.workspaceId,
|
|
85
87
|
controlGeneration:w.controlGeneration,origin:item.origin,scope:item.scope}));
|
|
86
88
|
return button;
|
|
@@ -97,7 +99,7 @@ function renderDelivery(w) {
|
|
|
97
99
|
input.disabled = p.ownership === 'user';
|
|
98
100
|
input.value = p.pageId;
|
|
99
101
|
input.onchange = () => { finishId = crypto.randomUUID(); };
|
|
100
|
-
label.append(input, ' ' + (p.title || p.origin ||
|
|
102
|
+
label.append(input, ' ' + (p.title || p.origin || t("Page")));
|
|
101
103
|
return label;
|
|
102
104
|
}));
|
|
103
105
|
}
|
|
@@ -105,8 +107,8 @@ el('finish').onclick = () => perform(async () => {
|
|
|
105
107
|
const keepPageIds = [...el('keep').querySelectorAll('input:checked')].map(input => input.value);
|
|
106
108
|
const receipt = await call('finishWorkspace',{workspaceId:selected,keepPageIds,operationId:finishId,
|
|
107
109
|
controlGeneration:detail.controlGeneration});
|
|
108
|
-
if (receipt.state !== 'completed') { notify(
|
|
109
|
-
notify(
|
|
110
|
+
if (receipt.state !== 'completed') { notify(t("Delivery needs verification · {0}", receipt.operationId)); return; }
|
|
111
|
+
notify(t("Pages kept: {0} · Pages closed: {1}", receipt.keptPageIds.length, receipt.closedPageIds.length));
|
|
110
112
|
render(null);
|
|
111
113
|
});
|
|
112
114
|
|
|
@@ -129,7 +131,7 @@ el('diagnostic-export-button').onclick = () => perform(async () => {
|
|
|
129
131
|
const link = el('diagnostic-export');
|
|
130
132
|
link.href = URL.createObjectURL(new Blob([text], {type:'application/json'}));
|
|
131
133
|
link.hidden = false;
|
|
132
|
-
link.textContent =
|
|
134
|
+
link.textContent = t("Download error log");
|
|
133
135
|
link.click();
|
|
134
136
|
});
|
|
135
137
|
|
|
@@ -142,26 +144,26 @@ function render(w) {
|
|
|
142
144
|
el('workspace').hidden = !w;
|
|
143
145
|
el('empty').hidden = !!w;
|
|
144
146
|
el('context-selection').hidden = contextTab || !w;
|
|
145
|
-
el('status').textContent = w ?
|
|
147
|
+
el('status').textContent = w ? t("{0} · Profile {1}", describe(w), w.profileId) : t("No workspaces");
|
|
146
148
|
if (!w) { showCredential(null); return; }
|
|
147
149
|
renderDialogs(w);
|
|
148
150
|
renderDelivery(w);
|
|
149
151
|
const pages = w.pages || [];
|
|
150
152
|
if (standalone && !selectedTab) selectedTab = pages[0]?.pageId || '';
|
|
151
153
|
const page = pages.find(p => p.pageId === selectedTab);
|
|
152
|
-
options(el('pages'), pages.map((p, i) => [p.pageId, (i+1) + ' · ' + (p.title || p.origin ||
|
|
154
|
+
options(el('pages'), pages.map((p, i) => [p.pageId, (i+1) + ' · ' + (p.title || p.origin || t("Page"))]), selectedTab);
|
|
153
155
|
if (!page) {
|
|
154
156
|
el('workspace').hidden = !standalone;
|
|
155
157
|
el('control').disabled = true;
|
|
156
158
|
el('uploads').hidden = true;
|
|
157
159
|
el('page-details').textContent = '';
|
|
158
|
-
el('status').textContent =
|
|
160
|
+
el('status').textContent = t("The original tab was closed or detached.");
|
|
159
161
|
showCredential(null);
|
|
160
162
|
return;
|
|
161
163
|
}
|
|
162
|
-
const sync = page.lastSyncedAt ?
|
|
163
|
-
el('page-details').textContent = [page.origin, w.accountAlias, page.syncState === 'sync_pending' ?
|
|
164
|
-
el('control').textContent = w.unlockPending ?
|
|
164
|
+
const sync = page.lastSyncedAt ? t("Last synced {0}", new Date(page.lastSyncedAt).toLocaleTimeString(globalThis.openBrowserI18n.locale)) : '';
|
|
165
|
+
el('page-details').textContent = [page.origin, w.accountAlias, page.syncState === 'sync_pending' ? t("Syncing") : sync].filter(Boolean).join(' · ');
|
|
166
|
+
el('control').textContent = w.unlockPending ? t("Retry takeover") : w.mode === 'human' ? t("Return to agent") : w.scope === 'single_tab' ? t("Take over this tab") : t("Take over workspace");
|
|
165
167
|
el('control').disabled = busy || (w.mode === 'transferring' && !w.unlockPending) || (!selectedTab && w.mode !== 'human');
|
|
166
168
|
el('uploads').hidden = w.mode!=='agent' || !selectedTab;
|
|
167
169
|
el('upload-origin').textContent = pages.find(p=>p.pageId===selectedTab)?.origin || '';
|
|
@@ -196,8 +198,8 @@ async function sync() {
|
|
|
196
198
|
const tasks = list.filter(w => w.pageAvailability === 'unregistered' && w.mode === 'agent');
|
|
197
199
|
el('adoption').hidden = false;
|
|
198
200
|
el('empty').hidden = true;
|
|
199
|
-
el('status').textContent =
|
|
200
|
-
el('adopt-site').textContent = origin.origin + (tasks.length ? '' :
|
|
201
|
+
el('status').textContent = t("Ordinary tab");
|
|
202
|
+
el('adopt-site').textContent = origin.origin + (tasks.length ? '' : t(" · Ask the agent to create a named workspace first"));
|
|
201
203
|
const chooser = el('adopt-task');
|
|
202
204
|
options(chooser, tasks.map(w => [w.workspaceId, workspaceTitle(w) + ' · ' + w.workspaceId.slice(0,8)]),
|
|
203
205
|
tasks.some(w => w.workspaceId === chooser.value) ? chooser.value : tasks.length === 1 ? tasks[0].workspaceId : '');
|
|
@@ -230,7 +232,7 @@ async function sync() {
|
|
|
230
232
|
render(w);
|
|
231
233
|
el('upload-list').replaceChildren(...uploads.map(file=>{
|
|
232
234
|
const button=document.createElement('button');
|
|
233
|
-
button.textContent=
|
|
235
|
+
button.textContent=t("Revoke {0} · {1}", file.name, file.origin);
|
|
234
236
|
button.onclick=()=>perform(()=>call('revokeUpload',{workspaceId:w.workspaceId,fileId:file.fileId}));
|
|
235
237
|
return button;
|
|
236
238
|
}));
|
|
@@ -240,7 +242,7 @@ async function sync() {
|
|
|
240
242
|
const pageId = selectedTab;
|
|
241
243
|
button.hidden = !permission;
|
|
242
244
|
if (permission) {
|
|
243
|
-
button.textContent =
|
|
245
|
+
button.textContent = permission.allow ? t("Revoke screenshot permission for this task · {0}", permission.origin) : t("Allow screenshots for this task · {0}", permission.origin);
|
|
244
246
|
button.onclick = () => perform(() => call('setPagePixelPermission',{
|
|
245
247
|
workspaceId:w.workspaceId, pageId, documentId:permission.documentId, controlGeneration:w.controlGeneration,
|
|
246
248
|
origin:permission.origin, allow:!permission.allow
|
|
@@ -248,18 +250,20 @@ async function sync() {
|
|
|
248
250
|
}
|
|
249
251
|
const status=el('visual-status');
|
|
250
252
|
status.hidden=!capture;
|
|
251
|
-
if(capture)
|
|
252
|
-
|
|
253
|
+
if (capture) {
|
|
254
|
+
const { x, y, width, height } = capture.clip;
|
|
255
|
+
status.textContent = t("Last capture · {0} · {1} · {2}", capture.principalId, capture.origin, `(${x}, ${y}) ${width} × ${height}`);
|
|
256
|
+
}
|
|
253
257
|
}
|
|
254
258
|
} catch (error) {
|
|
255
259
|
if (serial === revision) {
|
|
256
260
|
render(null);
|
|
257
261
|
if (contextTab && error.message === 'workspace_not_found') {
|
|
258
|
-
el('status').textContent =
|
|
259
|
-
notify(
|
|
262
|
+
el('status').textContent = t("The task ended or the service restarted.");
|
|
263
|
+
notify(t("Reopen the extension on the tab you want to authorize."));
|
|
260
264
|
} else {
|
|
261
|
-
el('status').textContent =
|
|
262
|
-
notify(error.message);
|
|
265
|
+
el('status').textContent = t("Connection failed");
|
|
266
|
+
notify(errorLabel(error.message));
|
|
263
267
|
}
|
|
264
268
|
}
|
|
265
269
|
} finally {
|
|
@@ -275,23 +279,34 @@ function renderDialogs(w) {
|
|
|
275
279
|
panel.dataset.signature = signature;
|
|
276
280
|
panel.replaceChildren(...items.map(item => {
|
|
277
281
|
const row = document.createElement('div');
|
|
278
|
-
|
|
282
|
+
const caption = document.createElement('span');
|
|
283
|
+
const labels = [];
|
|
284
|
+
const bindLabel = renderLabel => { labels.push(renderLabel); renderLabel(); };
|
|
285
|
+
row.updateLanguage = () => labels.forEach(renderLabel => renderLabel());
|
|
286
|
+
bindLabel(() => {
|
|
287
|
+
caption.textContent = [item.origin, {alert:t('Alert'), confirm:t('Confirmation'), prompt:t('Prompt')}[item.type] || item.type, item.message].join(' · ');
|
|
288
|
+
});
|
|
289
|
+
row.append(caption);
|
|
279
290
|
if (w.mode === 'agent') {
|
|
280
291
|
const take = document.createElement('button');
|
|
281
|
-
take.textContent =
|
|
292
|
+
bindLabel(() => { take.textContent = t("Take over to respond"); });
|
|
282
293
|
take.onclick = () => {
|
|
283
294
|
take.disabled = true;
|
|
284
295
|
void call('takeControl',{workspaceId:w.workspaceId,pageId:item.pageId,controlGeneration:w.controlGeneration})
|
|
285
|
-
.catch(error=>notify(error.message)).finally(()=>void sync());
|
|
296
|
+
.catch(error=>notify(errorLabel(error.message))).finally(()=>void sync());
|
|
286
297
|
};
|
|
287
298
|
row.append(take);
|
|
288
299
|
return row;
|
|
289
300
|
}
|
|
290
301
|
const input = document.createElement('input');
|
|
291
|
-
if (item.type === 'prompt') {
|
|
302
|
+
if (item.type === 'prompt') {
|
|
303
|
+
bindLabel(() => { input.placeholder = t("Reply"); });
|
|
304
|
+
input.maxLength = 2048;
|
|
305
|
+
row.append(input);
|
|
306
|
+
}
|
|
292
307
|
for (const accept of [true,false]) {
|
|
293
308
|
const button = document.createElement('button');
|
|
294
|
-
button.textContent = accept ?
|
|
309
|
+
bindLabel(() => { button.textContent = accept ? t("OK") : t("Cancel"); });
|
|
295
310
|
button.onclick = () => perform(() => call('respondDialog',{workspaceId:w.workspaceId,pageId:item.pageId,
|
|
296
311
|
dialogId:item.dialogId,controlGeneration:w.controlGeneration,accept,
|
|
297
312
|
...(accept && item.type === 'prompt' && {text:input.value})}));
|
|
@@ -301,9 +316,16 @@ function renderDialogs(w) {
|
|
|
301
316
|
}));
|
|
302
317
|
}
|
|
303
318
|
|
|
319
|
+
export function updateLanguage() {
|
|
320
|
+
if (!initialized) return;
|
|
321
|
+
for (const row of el('dialogs').children) row.updateLanguage();
|
|
322
|
+
if (detail && !busy) render(detail);
|
|
323
|
+
void sync();
|
|
324
|
+
}
|
|
325
|
+
|
|
304
326
|
function renderDownloads(items) {
|
|
305
327
|
el('downloads').hidden = !items.length;
|
|
306
|
-
const labels = {receiving:
|
|
328
|
+
const labels = {receiving:t("Downloading"),ready:t("Ready to keep"),failed:t("Failed"),cancelled:t("Cancelled"),kept:t("Kept")};
|
|
307
329
|
el('download-list').replaceChildren(...items.map(item => {
|
|
308
330
|
const row = document.createElement('p');
|
|
309
331
|
row.textContent = item.filename + ' · ' + labels[item.state] + ' ';
|
|
@@ -316,8 +338,8 @@ function renderDownloads(items) {
|
|
|
316
338
|
}
|
|
317
339
|
const params = {workspaceId:item.workspaceId,downloadId:item.downloadId};
|
|
318
340
|
if (item.state === 'ready' || item.state === 'kept')
|
|
319
|
-
button(item.state === 'kept' ?
|
|
320
|
-
if (item.state === 'receiving' || item.state === 'ready') button(
|
|
341
|
+
button(item.state === 'kept' ? t("Show saved location") : t("Keep file"), async () => notify((await call('keepDownload',params)).path));
|
|
342
|
+
if (item.state === 'receiving' || item.state === 'ready') button(t("Cancel"), () => call('cancelDownload',params));
|
|
321
343
|
return row;
|
|
322
344
|
}));
|
|
323
345
|
}
|
|
@@ -329,7 +351,7 @@ async function perform(action) {
|
|
|
329
351
|
notify();
|
|
330
352
|
const enabled = [...document.querySelectorAll('button:enabled, select:enabled, input:enabled')];
|
|
331
353
|
for (const element of enabled) element.disabled = true;
|
|
332
|
-
try { await action(); } catch (error) { notify(error.message); }
|
|
354
|
+
try { await action(); } catch (error) { notify(errorLabel(error.message)); }
|
|
333
355
|
finally {
|
|
334
356
|
busy = false;
|
|
335
357
|
for (const element of enabled) element.disabled = false;
|
|
@@ -364,20 +386,20 @@ el('upload-file').onchange = event => {
|
|
|
364
386
|
const target=uploadTarget, current=selectedUploadTarget();
|
|
365
387
|
uploadTarget=null;
|
|
366
388
|
if (!target || !current || Object.keys(target).some(key=>target[key]!==current[key])) {
|
|
367
|
-
notify(
|
|
389
|
+
notify(t("The page or control changed. Select the file again."));
|
|
368
390
|
return;
|
|
369
391
|
}
|
|
370
392
|
const params={...target,name:file.name,mimeType:file.type};
|
|
371
393
|
void perform(async()=>{
|
|
372
|
-
if (file.size>8*1024*1024) throw Error(
|
|
394
|
+
if (file.size>8*1024*1024) throw Error(t("Each file must be 8 MiB or smaller."));
|
|
373
395
|
const data=await new Promise((resolve,reject)=>{
|
|
374
396
|
const reader=new FileReader();
|
|
375
397
|
reader.onload=()=>resolve(reader.result.split(',')[1]);
|
|
376
|
-
reader.onerror=()=>reject(Error(
|
|
398
|
+
reader.onerror=()=>reject(Error(t("Could not read the file.")));
|
|
377
399
|
reader.readAsDataURL(file);
|
|
378
400
|
});
|
|
379
401
|
await call('grantUpload',{...params,data});
|
|
380
|
-
notify(
|
|
402
|
+
notify(t("Granted {0} access to {1} for five minutes.", params.origin, file.name));
|
|
381
403
|
});
|
|
382
404
|
};
|
|
383
405
|
el('control').onclick = () => perform(async () => {
|
|
@@ -395,9 +417,9 @@ el('credential').onsubmit = event => {
|
|
|
395
417
|
const w = await call('getWorkspace', { workspaceId });
|
|
396
418
|
const fresh = w.activity?.credentialRequest;
|
|
397
419
|
if (w.mode !== 'agent' || generation !== w.controlGeneration || !fresh ||
|
|
398
|
-
['pageId', 'origin', 'credentialRef', 'operationId'].some(k => fresh[k] !== pending[k])) throw new Error(
|
|
420
|
+
['pageId', 'origin', 'credentialRef', 'operationId'].some(k => fresh[k] !== pending[k])) throw new Error(t("The credential request has changed."));
|
|
399
421
|
await call('resolveCredential', { workspaceId, ...pending, value });
|
|
400
|
-
notify(
|
|
422
|
+
notify(t("Credential bound. The agent can retry."));
|
|
401
423
|
});
|
|
402
424
|
};
|
|
403
425
|
|
|
@@ -411,6 +433,7 @@ async function open() {
|
|
|
411
433
|
contextTab = Boolean(owned);
|
|
412
434
|
if (owned) { selected = owned.workspaceId; selectedTab = owned.pageId; }
|
|
413
435
|
}
|
|
436
|
+
initialized = true;
|
|
414
437
|
await sync();
|
|
415
438
|
if (explicit?.[2] && detail) el('delivery').open = true;
|
|
416
439
|
}
|
|
@@ -21,25 +21,26 @@ function showRunning(tabId, running) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const actionStates = {
|
|
24
|
-
running: ['▶', '#1556b0',
|
|
25
|
-
queued: ['…', '#6757a4',
|
|
26
|
-
actionability: ['⌁', '#1556b0',
|
|
27
|
-
dispatching: ['▶', '#1556b0',
|
|
28
|
-
waiting: ['…', '#6757a4',
|
|
29
|
-
verifying: ['✓', '#526675',
|
|
30
|
-
needs_credential: ['!', '#a72f24',
|
|
31
|
-
needs_human_verification: ['!', '#a75d08',
|
|
32
|
-
needs_visual_permission: ['!', '#a75d08',
|
|
33
|
-
completed: ['✓', '#526675',
|
|
34
|
-
failed: ['!', '#a72f24',
|
|
35
|
-
outcome_unknown: ['?', '#a75d08',
|
|
36
|
-
cancelled: ['−', '#626977',
|
|
37
|
-
idle: ['·', '#626977',
|
|
38
|
-
human: [
|
|
39
|
-
transferring: ['↔', '#926407',
|
|
24
|
+
running: ['▶', '#1556b0', "Running"],
|
|
25
|
+
queued: ['…', '#6757a4', "In queue"],
|
|
26
|
+
actionability: ['⌁', '#1556b0', "Checking target"],
|
|
27
|
+
dispatching: ['▶', '#1556b0', "Dispatching"],
|
|
28
|
+
waiting: ['…', '#6757a4', "Waiting for page"],
|
|
29
|
+
verifying: ['✓', '#526675', "Checking result"],
|
|
30
|
+
needs_credential: ['!', '#a72f24', "Waiting for credentials"],
|
|
31
|
+
needs_human_verification: ['!', '#a75d08', "Human verification required"],
|
|
32
|
+
needs_visual_permission: ['!', '#a75d08', "Screenshot permission required"],
|
|
33
|
+
completed: ['✓', '#526675', "Completed"],
|
|
34
|
+
failed: ['!', '#a72f24', "Action failed"],
|
|
35
|
+
outcome_unknown: ['?', '#a75d08', "Outcome unknown"],
|
|
36
|
+
cancelled: ['−', '#626977', "Cancelled"],
|
|
37
|
+
idle: ['·', '#626977', "Waiting for instructions"],
|
|
38
|
+
human: ["H", '#176344', "Human in control"],
|
|
39
|
+
transferring: ['↔', '#926407', "Transferring"],
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
async function writeAction(tabId, record) {
|
|
43
|
+
await localeReady;
|
|
43
44
|
const key = tabKey(tabId);
|
|
44
45
|
if (!record) {
|
|
45
46
|
showRunning(tabId, false);
|
|
@@ -47,7 +48,7 @@ async function writeAction(tabId, record) {
|
|
|
47
48
|
if (!await chrome.tabs.get(tabId).catch(() => null)) return;
|
|
48
49
|
await Promise.all([
|
|
49
50
|
chrome.action.setPopup({ tabId, popup: defaultPopup }),
|
|
50
|
-
chrome.action.setTitle({ tabId, title:
|
|
51
|
+
chrome.action.setTitle({ tabId, title: t("Open Browser Workspace") }),
|
|
51
52
|
chrome.action.setBadgeText({ tabId, text: '' }),
|
|
52
53
|
]);
|
|
53
54
|
return;
|
|
@@ -57,13 +58,13 @@ async function writeAction(tabId, record) {
|
|
|
57
58
|
showRunning(tabId, ['running', 'actionability', 'dispatching', 'waiting', 'verifying'].includes(phase));
|
|
58
59
|
const [text, color, status] = actionStates[phase] || actionStates.idle;
|
|
59
60
|
const panel = phase === 'needs_credential' || phase === 'needs_human_verification' || phase === 'needs_visual_permission' || phase === 'transferring' || !record.controlGeneration;
|
|
60
|
-
const steps = { click:
|
|
61
|
-
const step = phase === 'running' && record.dispatchState ? (record.dispatchState === 'dispatched' ?
|
|
62
|
-
const hint = record.mode === 'human' ?
|
|
61
|
+
const steps = { click: t("Click"), fill: t("Fill"), fillCredential: t("Fill credential") };
|
|
62
|
+
const step = phase === 'running' && record.dispatchState ? (record.dispatchState === 'dispatched' ? t("Dispatched") : t("Waiting for page")) : phase === 'running' ? steps[record.stepKind] : '';
|
|
63
|
+
const hint = record.mode === 'human' ? t("Click to return control to the agent") : panel ? t("Click to open the workspace panel") : t("Click to take over");
|
|
63
64
|
await Promise.all([
|
|
64
|
-
chrome.action.setBadgeText({ tabId, text }),
|
|
65
|
+
chrome.action.setBadgeText({ tabId, text: t(text) }),
|
|
65
66
|
chrome.action.setBadgeBackgroundColor({ tabId, color }),
|
|
66
|
-
chrome.action.setTitle({ tabId, title: (record.agentName || 'Agent') + ' · ' + (step || status) + ' · ' + hint }),
|
|
67
|
+
chrome.action.setTitle({ tabId, title: (record.agentName || 'Agent') + ' · ' + (step || t(status)) + ' · ' + hint }),
|
|
67
68
|
chrome.action.setPopup({ tabId, popup: panel ? defaultPopup : '' }),
|
|
68
69
|
]);
|
|
69
70
|
}
|
|
@@ -105,7 +106,11 @@ chrome.tabs.onRemoved.addListener(tabId => {
|
|
|
105
106
|
|
|
106
107
|
async function openWorkspacePanel(tabId, delivery = false) {
|
|
107
108
|
const url = chrome.runtime.getURL(defaultPopup) + (Number.isInteger(tabId) ? '#tab-' + tabId + (delivery ? '-delivery' : '') : '');
|
|
108
|
-
|
|
109
|
+
const size = {width:380, height:510};
|
|
110
|
+
const panel = await chrome.windows.create({ url, type: 'popup', ...size, focused: true });
|
|
111
|
+
// Chromium can apply its startup window size to a newly created popup.
|
|
112
|
+
if (panel.width !== size.width || panel.height !== size.height)
|
|
113
|
+
await chrome.windows.update(panel.id, size);
|
|
109
114
|
}
|
|
110
115
|
|
|
111
116
|
const toggling = new Set();
|
|
@@ -132,7 +137,7 @@ async function clickTabAction(tab) {
|
|
|
132
137
|
|
|
133
138
|
chrome.action.onClicked.addListener(clickTabAction);
|
|
134
139
|
chrome.runtime.onInstalled.addListener(() => {
|
|
135
|
-
chrome.contextMenus.create({ id: 'workspace-panel', title:
|
|
140
|
+
chrome.contextMenus.create({ id: 'workspace-panel', title: t("Workspace panel"), contexts: ['action'] });
|
|
136
141
|
});
|
|
137
142
|
chrome.contextMenus.onClicked.addListener((info, tab) => {
|
|
138
143
|
if (info.menuItemId === 'workspace-panel') void openWorkspacePanel(tab?.id);
|
|
@@ -1,7 +1,29 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
importScripts('messages.js', 'i18n.js');
|
|
4
|
+
const { t } = globalThis.openBrowserI18n;
|
|
3
5
|
importScripts('workspace-title.js', 'tab-action.js');
|
|
4
|
-
globalThis.
|
|
6
|
+
globalThis.openBrowserSetLocale = async settings => {
|
|
7
|
+
await localeReady;
|
|
8
|
+
const changed = globalThis.openBrowserI18n.locale !== settings.locale;
|
|
9
|
+
globalThis.openBrowserI18n.setLocale(settings.locale);
|
|
10
|
+
await chrome.storage.session.set({ interfaceLanguage: settings });
|
|
11
|
+
await chrome.action.setTitle({ title: t('Open Browser Workspace') });
|
|
12
|
+
await chrome.contextMenus.update('workspace-panel', { title: t('Workspace panel') }).catch(() => {});
|
|
13
|
+
if (changed) {
|
|
14
|
+
markFrontTabChanged();
|
|
15
|
+
const slots = await chrome.storage.session.get(null);
|
|
16
|
+
await Promise.all(Object.entries(slots).filter(([key]) => key.startsWith('tab:')).map(([key, previous]) =>
|
|
17
|
+
forWorkspace(previous.workspaceId, async () => {
|
|
18
|
+
const current = (await chrome.storage.session.get(key))[key];
|
|
19
|
+
if (current) await writeAction(current.tabId, current);
|
|
20
|
+
}).catch(() => {})));
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const localeReady = chrome.storage.session.get('interfaceLanguage').then(({interfaceLanguage}) => {
|
|
24
|
+
if (interfaceLanguage) globalThis.openBrowserI18n.setLocale(interfaceLanguage.locale);
|
|
25
|
+
});
|
|
26
|
+
globalThis.openBrowserGroupVersion = 16;
|
|
5
27
|
|
|
6
28
|
const groupsInProgress = new Map();
|
|
7
29
|
|
|
@@ -111,7 +133,7 @@ globalThis.openBrowserInputHint = async function (pageId) {
|
|
|
111
133
|
const record = tab && (await chrome.storage.session.get(tabKey(tab.id)))[tabKey(tab.id)];
|
|
112
134
|
if (record?.pageId === pageId && record.mode === 'agent') {
|
|
113
135
|
showRunning(tab.id, false);
|
|
114
|
-
await chrome.action.setBadgeText({tabId:tab.id, text:
|
|
136
|
+
await chrome.action.setBadgeText({tabId:tab.id, text:t("Take")}).catch(() => {});
|
|
115
137
|
}
|
|
116
138
|
setTimeout(async () => {
|
|
117
139
|
if (hint === inputHint) inputHint = null;
|
|
@@ -185,7 +207,7 @@ globalThis.openBrowserShow = async function () {
|
|
|
185
207
|
return (await chrome.windows.create({ focused: true })).id;
|
|
186
208
|
};
|
|
187
209
|
|
|
188
|
-
const newtabMethods = new Set(['listWorkspaces', 'listAgentHistory', 'listEvents']);
|
|
210
|
+
const newtabMethods = new Set(['listWorkspaces', 'listAgentHistory', 'listEvents', 'setInterfaceLanguage']);
|
|
189
211
|
const methods = new Set(['offerCurrentTab','listUploads','grantUpload','revokeUpload','respondDialog','listDownloads','cancelDownload','keepDownload','visualStatus','setPagePixelPermission','listOperations','listEvents', 'listWorkspaces', 'getWorkspace', 'takeControl', 'returnToAgent', 'grantOrigin', 'resolveCredential', 'finishWorkspace']);
|
|
190
212
|
const pending = new Map();
|
|
191
213
|
const queued = [];
|
|
@@ -194,11 +216,11 @@ let waiting;
|
|
|
194
216
|
function hostFailure(request) {
|
|
195
217
|
if (request?.dispatchedAt) return {
|
|
196
218
|
code: 'host_timeout',
|
|
197
|
-
message:
|
|
219
|
+
message: t("The extension received the request but the local service timed out. Check the service and try again."),
|
|
198
220
|
};
|
|
199
221
|
return {
|
|
200
222
|
code: 'host_unavailable',
|
|
201
|
-
message:
|
|
223
|
+
message: t("The extension is disconnected from the local service. Start Open Browser and try again."),
|
|
202
224
|
};
|
|
203
225
|
}
|
|
204
226
|
|
|
@@ -217,6 +239,8 @@ chrome.runtime.onMessage.addListener((message, sender, respond) => {
|
|
|
217
239
|
return false;
|
|
218
240
|
}
|
|
219
241
|
const dispatch = async () => {
|
|
242
|
+
if (message.method === 'setInterfaceLanguage')
|
|
243
|
+
return forWorkspace('interfaceLanguage', () => hostRequest(message.method, {preference:message.params.preference}));
|
|
220
244
|
if (message.method !== 'offerCurrentTab') return hostRequest(message.method, message.params);
|
|
221
245
|
const {tabId, targetId, origin, workspaceId, accountAlias} = message.params;
|
|
222
246
|
const [active] = await chrome.tabs.query({active:true,lastFocusedWindow:true});
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
function workspaceTitle({ agentName, name, mode }) {
|
|
4
4
|
const agent = agentName || 'Agent';
|
|
5
|
-
const task = typeof name === 'string' && name.trim() ? name.trim() :
|
|
5
|
+
const task = typeof name === 'string' && name.trim() ? name.trim() : globalThis.openBrowserI18n.t("Untitled task");
|
|
6
6
|
const title = agent + ' · ' + task;
|
|
7
|
-
return mode === 'human' ?
|
|
7
|
+
return mode === 'human' ? globalThis.openBrowserI18n.t("Human · {0}", title) : title;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
function workspaceNeedsName({ name }) {
|
package/build-profile.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { systemMessage as t } from './system-i18n.mjs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
1
3
|
import path from 'node:path';
|
|
2
4
|
import { readFileSync } from 'node:fs';
|
|
3
5
|
import { fileURLToPath } from 'node:url';
|
|
@@ -12,12 +14,18 @@ function packagedProfile() {
|
|
|
12
14
|
export const buildProfile = (process.env.OPEN_BROWSER_BUILD_PROFILE || packagedProfile() || 'stable').trim().toLowerCase();
|
|
13
15
|
|
|
14
16
|
if (!allowedProfiles.has(buildProfile)) {
|
|
15
|
-
throw new Error('OPEN_BROWSER_BUILD_PROFILE must be dev or stable');
|
|
17
|
+
throw new Error(t('OPEN_BROWSER_BUILD_PROFILE must be dev or stable'));
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
export const isDevelopmentBuild = buildProfile === 'dev';
|
|
19
21
|
|
|
20
22
|
export function scopedBuildRoot(base, profile = buildProfile) {
|
|
21
|
-
if (!allowedProfiles.has(profile)) throw new Error('build profile must be dev or stable');
|
|
23
|
+
if (!allowedProfiles.has(profile)) throw new Error(t('build profile must be dev or stable'));
|
|
22
24
|
return profile === 'dev' ? path.join(base, 'dev') : base;
|
|
23
25
|
}
|
|
26
|
+
|
|
27
|
+
export function profileStateDirectory(id = process.env.OPEN_BROWSER_PROFILE || 'default') {
|
|
28
|
+
if (typeof id !== 'string' || !/^[a-z0-9][a-z0-9_-]{0,47}$/.test(id)) throw new Error('invalid_profile');
|
|
29
|
+
const base = scopedBuildRoot(path.resolve(process.env.OPEN_BROWSER_STATE_DIR || path.join(homedir(), '.open-browser')));
|
|
30
|
+
return id === 'default' ? base : path.join(base, 'profiles', id);
|
|
31
|
+
}
|
package/chromium-host.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { interfaceLanguage, locale, setInterfaceLanguage, t } from './i18n.mjs';
|
|
1
2
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
2
3
|
import { randomUUID } from 'node:crypto';
|
|
3
4
|
|
|
@@ -13,8 +14,8 @@ const WORKER_EVAL_TIMEOUT_MS = 5000;
|
|
|
13
14
|
|
|
14
15
|
export function classifyExtensionFailure({ dispatched = false } = {}) {
|
|
15
16
|
return dispatched
|
|
16
|
-
? { code: 'host_timeout', message:
|
|
17
|
-
: { code: 'host_unavailable', message:
|
|
17
|
+
? { code: 'host_timeout', message: t("The extension received the request but the local service timed out. Check the service and try again.") }
|
|
18
|
+
: { code: 'host_unavailable', message: t("The extension is disconnected from the local service. Start Open Browser and try again.") };
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
function extensionError(code, message, cause) {
|
|
@@ -29,7 +30,7 @@ async function evaluateWorker(host, pageFunction, arg) {
|
|
|
29
30
|
new Promise((_, reject) => {
|
|
30
31
|
timer = setTimeout(() => reject(extensionError(
|
|
31
32
|
'extension_worker_timeout',
|
|
32
|
-
|
|
33
|
+
t("The extension service worker timed out. Check the extension and try again."),
|
|
33
34
|
)), WORKER_EVAL_TIMEOUT_MS);
|
|
34
35
|
}),
|
|
35
36
|
]);
|
|
@@ -48,12 +49,12 @@ export async function chromiumHost(context) {
|
|
|
48
49
|
try {
|
|
49
50
|
return await context.waitForEvent('serviceworker', { predicate: isHost, timeout: 10000 });
|
|
50
51
|
} catch (cause) {
|
|
51
|
-
throw extensionError('extension_unavailable',
|
|
52
|
+
throw extensionError('extension_unavailable', t("The workspace extension is offline. Restart Open Browser or reload the extension."), cause);
|
|
52
53
|
}
|
|
53
54
|
};
|
|
54
55
|
let initial = await worker();
|
|
55
56
|
const currentVersion = host => evaluateWorker(host, () => globalThis.openBrowserGroupVersion);
|
|
56
|
-
if (await currentVersion(initial) !==
|
|
57
|
+
if (await currentVersion(initial) !== 16) {
|
|
57
58
|
// A persistent Chromium profile can start the previous cached MV3 worker.
|
|
58
59
|
const replacement = context.waitForEvent('serviceworker', { predicate: isHost, timeout: 10000 });
|
|
59
60
|
try {
|
|
@@ -62,10 +63,12 @@ export async function chromiumHost(context) {
|
|
|
62
63
|
})]);
|
|
63
64
|
} catch (cause) {
|
|
64
65
|
// Chromium can defer the replacement worker until its next profile launch.
|
|
65
|
-
throw Object.assign(new Error(
|
|
66
|
+
throw Object.assign(new Error(t("The workspace extension requested an update."), { cause }), { code: 'extension_reload' });
|
|
66
67
|
}
|
|
67
|
-
if (await currentVersion(initial) !==
|
|
68
|
+
if (await currentVersion(initial) !== 16) throw new Error(t("Rebuild the Open Browser workspace extension."));
|
|
68
69
|
}
|
|
70
|
+
const updateLanguage = (host, settings) => evaluateWorker(host, value => globalThis.openBrowserSetLocale(value), settings);
|
|
71
|
+
await updateLanguage(initial, interfaceLanguage());
|
|
69
72
|
let stopped = false;
|
|
70
73
|
let lastState;
|
|
71
74
|
const effects = pageActivity();
|
|
@@ -75,7 +78,7 @@ export async function chromiumHost(context) {
|
|
|
75
78
|
// diagnostics override.
|
|
76
79
|
const guardMode = configuredGuard || 'fallback';
|
|
77
80
|
if (!['off', 'fallback', 'native'].includes(guardMode))
|
|
78
|
-
throw extensionError('invalid_input_guard_mode',
|
|
81
|
+
throw extensionError('invalid_input_guard_mode', t("OPEN_BROWSER_INPUT_GUARD must be off, fallback or native."));
|
|
79
82
|
const guarded = guardMode !== 'off';
|
|
80
83
|
const setInputGuard = guarded ? managedInput(context, tab => {
|
|
81
84
|
void worker().then(host => globalThis.openBrowserInputHint
|
|
@@ -89,8 +92,16 @@ export async function chromiumHost(context) {
|
|
|
89
92
|
async function respond(host, request, call) {
|
|
90
93
|
let response;
|
|
91
94
|
try {
|
|
92
|
-
if (
|
|
93
|
-
|
|
95
|
+
if (request.method === 'setInterfaceLanguage') {
|
|
96
|
+
const settings = setInterfaceLanguage(request.params?.preference);
|
|
97
|
+
await updateLanguage(host, settings);
|
|
98
|
+
lastState = undefined;
|
|
99
|
+
changed();
|
|
100
|
+
response = { id: request.id, result: settings };
|
|
101
|
+
} else {
|
|
102
|
+
if (!allowed.has(request.method)) throw Object.assign(new Error(), { code: 'unknown_method' });
|
|
103
|
+
response = { id: request.id, result: await call(request.method, request.params || {}) };
|
|
104
|
+
}
|
|
94
105
|
} catch (error) {
|
|
95
106
|
response = { id: request.id, error: error.code || 'operation_failed' };
|
|
96
107
|
}
|
|
@@ -133,7 +144,7 @@ export async function chromiumHost(context) {
|
|
|
133
144
|
let frontRevision = 0;
|
|
134
145
|
while (!stopped) {
|
|
135
146
|
const bar = await frontTab().catch(() => null);
|
|
136
|
-
const signature = JSON.stringify(bar);
|
|
147
|
+
const signature = JSON.stringify([locale, bar]);
|
|
137
148
|
if (!stopped && signature !== lastBar) {
|
|
138
149
|
lastBar = signature;
|
|
139
150
|
send(bar);
|