synabun 2.4.0 → 2.4.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 (72) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +1 -1
  3. package/browser-extension/content.js +25 -5
  4. package/browser-extension/engine.js +44 -13
  5. package/browser-extension/manifest.json +2 -2
  6. package/browser-extension/popup-strings.js +10 -4
  7. package/browser-extension/popup-view.js +1 -1
  8. package/browser-extension/popup.css +1 -0
  9. package/browser-extension/popup.html +4 -1
  10. package/browser-extension/popup.js +22 -10
  11. package/browser-extension/protocol.js +11 -5
  12. package/browser-extension/service-worker.js +8 -0
  13. package/docs/browser-extension-bridge.md +2 -2
  14. package/lib/data-home-files.js +45 -0
  15. package/lib/data-home-migration.js +34 -58
  16. package/mcp-server/dist/services/neural-interface.d.ts +1 -0
  17. package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
  18. package/mcp-server/dist/services/neural-interface.js.map +1 -1
  19. package/mcp-server/dist/tools/agents.d.ts +3 -2
  20. package/mcp-server/dist/tools/agents.d.ts.map +1 -1
  21. package/mcp-server/dist/tools/agents.js +9 -7
  22. package/mcp-server/dist/tools/agents.js.map +1 -1
  23. package/mcp-server/package-lock.json +2 -2
  24. package/mcp-server/package.json +1 -1
  25. package/mcp-server/src/services/neural-interface.ts +1 -0
  26. package/mcp-server/src/tools/agents.ts +8 -6
  27. package/neural-interface/i18n/en.json +3 -1
  28. package/neural-interface/i18n/pt-BR.json +3 -1
  29. package/neural-interface/lib/agents/builtins.json +207 -0
  30. package/neural-interface/lib/agents/registry.js +60 -15
  31. package/neural-interface/lib/agents/resolve.js +69 -10
  32. package/neural-interface/lib/assistant-brains/opencode.js +60 -11
  33. package/neural-interface/lib/assistant-dispatch.js +127 -24
  34. package/neural-interface/lib/assistant-persona.js +1 -1
  35. package/neural-interface/lib/assistant-router.js +50 -7
  36. package/neural-interface/lib/assistant-runtime.js +9 -1
  37. package/neural-interface/lib/backup-service.js +64 -105
  38. package/neural-interface/lib/browser-extension-adapter.js +24 -15
  39. package/neural-interface/lib/browser-extension-bridge.js +27 -4
  40. package/neural-interface/lib/native-loop-runtime.js +6 -7
  41. package/neural-interface/lib/opencode-build-preflight.js +12 -7
  42. package/neural-interface/lib/peer-identity.js +13 -8
  43. package/neural-interface/lib/session-cache-builder.js +41 -3
  44. package/neural-interface/lib/teams/scheduler.js +2 -2
  45. package/neural-interface/lib/teams/schema.js +1 -1
  46. package/neural-interface/package-lock.json +2 -2
  47. package/neural-interface/package.json +1 -1
  48. package/neural-interface/public/index.html +51 -0
  49. package/neural-interface/public/offline.html +4 -3
  50. package/neural-interface/public/shared/agents/studio/ax-agent-view.js +2 -2
  51. package/neural-interface/public/shared/agents/studio/ax-editor-view.js +1 -1
  52. package/neural-interface/public/shared/agents/studio/ax-ui.js +2 -2
  53. package/neural-interface/public/shared/api.js +2 -1
  54. package/neural-interface/public/shared/assistant/asst-render.js +1 -0
  55. package/neural-interface/public/shared/assistant/asst-route.js +3 -1
  56. package/neural-interface/public/shared/cc-dropdown.js +21 -15
  57. package/neural-interface/public/shared/html-shell.js +1 -0
  58. package/neural-interface/public/shared/owner-authority-view.js +4 -10
  59. package/neural-interface/public/shared/page-session.js +1 -1
  60. package/neural-interface/public/shared/settings/settings-ai-browser.js +5 -5
  61. package/neural-interface/public/shared/start-bridge.js +2 -2
  62. package/neural-interface/public/shared/styles.css +13 -1
  63. package/neural-interface/public/shared/ui-loading.js +72 -19
  64. package/neural-interface/public/shared/ui-native-loop-router.js +49 -20
  65. package/neural-interface/public/shared/ui-owner-authority.js +48 -25
  66. package/neural-interface/public/shared/ui-settings.js +10 -2
  67. package/neural-interface/public/shared/ui-sync.js +1 -0
  68. package/neural-interface/public/sw.js +4 -3
  69. package/neural-interface/public/variant/3d/main.js +13 -4
  70. package/neural-interface/server.js +34 -25
  71. package/npm-shrinkwrap.json +2 -2
  72. package/package.json +2 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ # SynaBun v.2.4.1
2
+
3
+ The Assistant can now use a specialist for each type of task. This release also expands file uploads in the Chrome extension and makes desktop startup failures easier to recover from.
4
+
5
+ ## ✨ New
6
+
7
+ - **Built-in agents for common tasks.** Agents Studio includes 12 specialists for work such as research, coding and design. You can customize which approved agent handles a task. A worker keeps the revision it started with, even if you edit the agent while it runs.
8
+ - **Larger uploads from Chrome.** Browser Bridge can attach up to four files totaling 50 MB from the upload folder shown in Browser Settings. Uploads work in both full-control and shared-tab modes. You can also reload the extension from its popup after an update.
9
+
10
+ ## 🛠 Fixed
11
+
12
+ - **Desktop startup and recovery.** If the interface fails to load, the desktop app shows a status screen with Retry and Open logs. It can reconnect when the local service recovers.
13
+ - **Large backups and migrations.** Backups and moves to a new data folder can now finish when your library contains very many files or deeply nested folders.
14
+ - **MoreLogin in OpenCode.** OpenCode now applies the configured MoreLogin browser policy when checking whether a task can start.
15
+
16
+ ---
17
+
1
18
  # SynaBun v.2.4.0
2
19
 
3
20
  You can now save an agent for recurring work, assign a task to a team, and connect the Assistant to the browser you already use.
package/README.md CHANGED
@@ -178,7 +178,7 @@ Everything SynaBun stores is in one folder outside the app: `~/.synabun` on macO
178
178
 
179
179
  ## Links
180
180
 
181
- - [Changelog](./CHANGELOG.md): what is new in 2.4.0 and before
181
+ - [Changelog](./CHANGELOG.md): what is new in 2.4.1 and before
182
182
  - [Security](./SECURITY.md): security model and how to report a vulnerability
183
183
  - [Contributing](./CONTRIBUTING.md): bug reports and feature requests are welcome as [issues](https://github.com/danilokhury/Synabun/issues); pull requests are not accepted
184
184
  - [Website](https://synabun.ai), [docs](https://synabun.ai/docs) and [blog](https://synabun.ai/blog)
@@ -3,6 +3,7 @@
3
3
  if (globalThis.__synabunBridgeInstalled) return;
4
4
  globalThis.__synabunBridgeInstalled = true;
5
5
  let generation = crypto.randomUUID().replaceAll('-', ''), documentUrl = location.href;
6
+ const uploadParts = new Map();
6
7
  const refs = new Map(), ids = new WeakMap(); let serial = 0, navigation = null;
7
8
  function invalidate() { refs.clear(); generation = crypto.randomUUID().replaceAll('-', ''); documentUrl = location.href; }
8
9
  globalThis.addEventListener?.('pageshow', event => { if (event.persisted) invalidate(); });
@@ -153,16 +154,35 @@
153
154
  } else if (op === 'upload') {
154
155
  if (!el.matches('input[type=file]')) error('NO_MATCH');
155
156
  const transfer = new DataTransfer();
156
- for (const file of args.files) {
157
- const decoded = atob(file.base64); const bytes = Uint8Array.from(decoded, c => c.charCodeAt(0));
158
- transfer.items.add(new File([bytes], file.name, { type: 'application/octet-stream' }));
159
- }
157
+ if (!el.multiple && args.files.length > 1) error('UPLOAD_MULTIPLE');
158
+ const parts = uploadParts.get(args.uploadId);
159
+ uploadParts.delete(args.uploadId);
160
+ args.files.forEach((name, index) => {
161
+ const file = new File(parts?.[index] || [], name, { type: 'application/octet-stream' });
162
+ if (file.size !== args.sizes[index]) error('OPERATION_FAILED');
163
+ transfer.items.add(file);
164
+ });
160
165
  due(); el.files = transfer.files; event(el, 'input'); event(el, 'change');
161
166
  } else error('UNSUPPORTED_IN_EXTENSION_MODE');
162
167
  return state();
163
168
  }
164
169
  chrome.runtime.onMessage.addListener((message, sender, respond) => {
165
- if (sender.id !== chrome.runtime.id || message?.kind !== 'synabun-fixed-command') return;
170
+ if (sender.id !== chrome.runtime.id) return;
171
+ if (message?.kind === 'synabun-upload-part') {
172
+ const { id, index, data, until } = message;
173
+ if (!(Date.now() < until)) { respond({ ok: false, code: 'TIMEOUT' }); return; }
174
+ if (!uploadParts.has(id)) {
175
+ uploadParts.set(id, []);
176
+ setTimeout(() => uploadParts.delete(id), until - Date.now());
177
+ }
178
+ const parts = uploadParts.get(id);
179
+ const decoded = atob(data);
180
+ const bytes = new Uint8Array(decoded.length);
181
+ for (let i = 0; i < decoded.length; i++) bytes[i] = decoded.charCodeAt(i);
182
+ (parts[index] ||= []).push(bytes);
183
+ respond({ ok: true }); return;
184
+ }
185
+ if (message?.kind !== 'synabun-fixed-command') return;
166
186
  execute(message).then(respond, error => respond({ ok: false, code: error.code || 'OPERATION_FAILED' }));
167
187
  return true;
168
188
  });
@@ -1,17 +1,17 @@
1
- import { anyOrigin, command, CONTROL, controlSurface, fail, HISTORY, inventory, hostPattern, localDeadline, MAX_TABS, nonce, publicOrigin, safeError } from './protocol.js';
1
+ import { anyOrigin, command, CONTROL, controlSurface, fail, HISTORY, inventory, hostPattern, localDeadline, MAX_FILE, MAX_TABS, nonce, publicOrigin, safeError } from './protocol.js';
2
2
 
3
3
  /** Pure controller over an injected chrome API; no socket or storage credential access. */
4
4
  // `now` is a monotonic clock (milliseconds) for command deadlines; `wallClock` the system clock the content script shares.
5
5
  // `fullControlDefault` is the mode before the owner ever chose one (full control: agents may use any http(s) site and
6
6
  // any tab of this browser with no sharing step). `activateMs` is how long a full-control screenshot lets a tab it
7
7
  // brought to the front settle before capturing it.
8
- export function createEngine(chrome, { save = async () => {}, changed = () => {}, settleMs = 10000, quietMs = 500, pollMs = 50,
8
+ export function createEngine(chrome, { readUpload, save = async () => {}, changed = () => {}, settleMs = 10000, quietMs = 500, pollMs = 50,
9
9
  now = () => performance.now(), wallClock = () => Date.now(), fullControlDefault = true, activateMs = 150, commitMs = 20000, visibleMs = 2000 } = {}) {
10
10
  // `epoch` moves only on the owner's revocations and pairing changes, and cancels every tab's work. A tab's own
11
11
  // navigation, update or close moves that tab's counter in `moves` (by Chrome tab id) and nothing else: one agent's
12
12
  // ordinary navigation never cancels another agent's work on another tab. `focus` moves when the active tab changes;
13
13
  // only a screenshot, which captures whatever tab is active, is held to it.
14
- let tabs = new Map(), sites = [], allowNewTabs = false, uploads = false, downloads = false, epoch = 0, focus = 0;
14
+ let tabs = new Map(), sites = [], allowNewTabs = false, downloads = false, epoch = 0, focus = 0;
15
15
  // The mode and its version. Only the owner changes it: the popup (setMode) or the server's `mode` control message,
16
16
  // whose version must be newer. Switching to restricted is a revocation; switching to full control widens only.
17
17
  // In full control `tabs` also holds a record for every other tab of the browser (`listed`), so agents can see and
@@ -49,9 +49,9 @@ export function createEngine(chrome, { save = async () => {}, changed = () => {}
49
49
  const current = () => {
50
50
  const all = [...tabs.values()].filter(t => { if (t.owner || !fullControl) return true; try { anyOrigin(t.url); return true; } catch { return false; } }), listed = [...all.filter(t => t.owner), ...all.filter(t => !t.owner)].slice(0, MAX_TABS);
51
51
  return inventory({ tabs: listed.map(t => ({ handle: t.handle, url: t.url, owner: t.owner, created: t.created === true, title: clip(t.title) })),
52
- sites: [...sites], versions: sites.map(s => versions.get(s) || 0), allowNewTabs, uploads, downloads, fullControl, modeVersion });
52
+ sites: [...sites], versions: sites.map(s => versions.get(s) || 0), allowNewTabs, uploads: true, downloads, fullControl, modeVersion });
53
53
  };
54
- const persist = async () => { await save({ tabs: [...tabs.values()], sites, versions: [...versions], allowNewTabs, uploads, downloads, fullControl, modeVersion }); changed(current()); };
54
+ const persist = async () => { await save({ tabs: [...tabs.values()], sites, versions: [...versions], allowNewTabs, uploads: true, downloads, fullControl, modeVersion }); changed(current()); };
55
55
  async function live(t) {
56
56
  try { const tab = await chrome.tabs.get(t.id); t.url = shownUrl(tab); t.title = clip(tab.title); return tab; }
57
57
  catch { move(t.id); tabs.delete(t.handle); moves.delete(t.id); await persist(); fail('TAB_CLOSED'); }
@@ -109,7 +109,7 @@ export function createEngine(chrome, { save = async () => {}, changed = () => {}
109
109
  if (fullControl) open(t.url, blocked);
110
110
  else if (t.url !== 'about:blank') await permitted(t.url); else if (op !== 'navigate' && !HISTORY.includes(op)) fail('SITE_NOT_APPROVED');
111
111
  if (args.url) await destination(args.url, blocked);
112
- if (op === 'upload' && !uploads && !fullControl || op === 'download' && !downloads) fail('PERMISSION_REQUIRED');
112
+ if (op === 'download' && !downloads) fail('PERMISSION_REQUIRED');
113
113
  return t;
114
114
  }
115
115
  // The owner's mode change, from the popup or the server. An older version never applies. Switching to restricted
@@ -390,7 +390,7 @@ export function createEngine(chrome, { save = async () => {}, changed = () => {}
390
390
  await recheck(); result = blank;
391
391
  } else fail('NO_MATCH');
392
392
  } else {
393
- await act(() => chrome.scripting.executeScript({ target: { tabId: t.id, frameIds: [0] }, files: ['content.js'], world: 'ISOLATED' }));
393
+ const injection = await act(() => chrome.scripting.executeScript({ target: { tabId: t.id, frameIds: [0] }, files: ['content.js'], world: 'ISOLATED' }));
394
394
  await recheck();
395
395
  t.nav ||= nonce();
396
396
  // The page action carries the deadline as a system-clock time (`until`), which the content script shares: it
@@ -398,9 +398,40 @@ export function createEngine(chrome, { save = async () => {}, changed = () => {}
398
398
  // Full control sends no site list: the page checks only that a link or form does not lead to SynaBun's own
399
399
  // addresses (`blocked`). Restricted mode sends the approved sites, less SynaBun's public aliases.
400
400
  const beforeActionUrl = t.url;
401
- result = await act(() => chrome.tabs.sendMessage(t.id, { kind: 'synabun-fixed-command', op, args,
401
+ let delivery = { frameId: 0 }, pageArgs = args;
402
+ if (op === 'upload') {
403
+ const documentId = injection?.[0]?.documentId;
404
+ if (!documentId) fail('TAB_NOT_APPROVED');
405
+ delivery = { documentId };
406
+ const sizes = [];
407
+ let remaining = MAX_FILE;
408
+ for (let index = 0; index < args.files.length; index++) {
409
+ await recheck();
410
+ const blob = await readUpload(input.id, index, Math.max(1, expires - now()));
411
+ if (blob.size > remaining) fail('UPLOAD_TOO_LARGE');
412
+ remaining -= blob.size;
413
+ sizes.push(blob.size);
414
+ // Chrome serializes tab messages as JSON. Keep even a 50 MB file below its IPC cap.
415
+ const chunkSize = 1024 * 1024;
416
+ for (let pos = 0; pos < blob.size; pos += chunkSize) {
417
+ const reader = new FileReader();
418
+ const data = await new Promise((resolve, reject) => {
419
+ reader.onload = () => resolve(reader.result.split(',')[1]);
420
+ reader.onerror = () => reject(reader.error);
421
+ reader.readAsDataURL(blob.slice(pos, pos + chunkSize));
422
+ });
423
+ await recheck();
424
+ const ack = await act(() => chrome.tabs.sendMessage(t.id, { kind: 'synabun-upload-part',
425
+ id: input.id, index, data, until: wallClock() + Math.max(0, expires - now()) }, delivery));
426
+ if (!ack?.ok) fail(ack?.code || 'OPERATION_FAILED');
427
+ }
428
+ }
429
+ await recheck();
430
+ pageArgs = { ...args, uploadId: input.id, sizes };
431
+ }
432
+ result = await act(() => chrome.tabs.sendMessage(t.id, { kind: 'synabun-fixed-command', op, args: pageArgs,
402
433
  sites: fullControl ? null : sites.filter(site => !blockedHosts.includes(new URL(site).hostname)), blocked, downloads, nav: t.nav,
403
- until: wallClock() + Math.max(0, expires - now()) }, { frameId: 0 }));
434
+ until: wallClock() + Math.max(0, expires - now()) }, delivery));
404
435
  if (op === 'click' && result?.ok) {
405
436
  Object.assign(result, await metadata());
406
437
  if (result.url !== beforeActionUrl || moved(t.id) !== tabBegan) t.nav = nonce();
@@ -421,7 +452,7 @@ export function createEngine(chrome, { save = async () => {}, changed = () => {}
421
452
  async restore(saved = {}) {
422
453
  sites = (saved.sites || []).filter(s => { try { return publicOrigin(s) === s; } catch { return false; } });
423
454
  versions = new Map((Array.isArray(saved.versions) ? saved.versions : []).filter(e => Array.isArray(e) && typeof e[0] === 'string' && Number.isSafeInteger(e[1]) && e[1] >= 0));
424
- allowNewTabs = saved.allowNewTabs === true; uploads = saved.uploads === true; downloads = saved.downloads === true;
455
+ allowNewTabs = saved.allowNewTabs === true; downloads = saved.downloads === true;
425
456
  fullControl = typeof saved.fullControl === 'boolean' ? saved.fullControl : fullControlDefault === true;
426
457
  modeVersion = Number.isSafeInteger(saved.modeVersion) && saved.modeVersion >= 0 ? saved.modeVersion : 0;
427
458
  tabs = new Map((saved.tabs || []).filter(t => fullControl || !t.listed || t.created).map(t => [t.handle, t]));
@@ -450,8 +481,8 @@ export function createEngine(chrome, { save = async () => {}, changed = () => {}
450
481
  async revokeSite(site) { approval++; sites = sites.filter(s => s !== site); epoch++; pruneVersions(); await persist(); },
451
482
  async options(value) {
452
483
  // Switching a permission off is a revocation; switching one on is not.
453
- if (allowNewTabs && value.allowNewTabs !== true || uploads && value.uploads !== true || downloads && value.downloads !== true) { approval++; epoch++; }
454
- allowNewTabs = value.allowNewTabs === true; uploads = value.uploads === true; downloads = value.downloads === true; await persist();
484
+ if (allowNewTabs && value.allowNewTabs !== true || downloads && value.downloads !== true) { approval++; epoch++; }
485
+ allowNewTabs = value.allowNewTabs === true; downloads = value.downloads === true; await persist();
455
486
  },
456
487
  // Tab events from the browser concern that tab only.
457
488
  async closed(id) { move(id); for (const t of tabs.values()) if (t.id === id) tabs.delete(t.handle); moves.delete(id); await persist(); },
@@ -464,7 +495,7 @@ export function createEngine(chrome, { save = async () => {}, changed = () => {}
464
495
  await persist();
465
496
  },
466
497
  // A new pairing or an unpairing ends every approval and every agent's hold. The mode is the owner's setting and stays.
467
- async clear() { approval++; tabs.clear(); sites = []; allowNewTabs = uploads = downloads = false; epoch++; await enumerate(); await persist(); },
498
+ async clear() { approval++; tabs.clear(); sites = []; allowNewTabs = downloads = false; epoch++; await enumerate(); await persist(); },
468
499
  activated() { focus++; },
469
500
  // Whether an agent holds the browser tab with this Chrome id (SynaBun's setup page is never paired from one).
470
501
  heldByAgent: id => [...tabs.values()].some(t => t.id === id && t.owner),
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "SynaBun Browser Bridge",
4
- "version": "1.2.1",
4
+ "version": "1.3.0",
5
5
  "minimum_chrome_version": "120",
6
6
  "description": "Lets SynaBun agents use your everyday browser: every site and tab (full control), or only what you share.",
7
7
  "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsDPDDuBTQq9nQgulmTSvzujxyOMZ7A7ttMSXtbIwup/X3kOlbkqoJEqQRGGJeb7+cNBSiiDBA5lhS0oYc9YeFcwNCucNMvGawDGblbQzDWEmn9dDK1krFVXWqNHVPIrEWlzCD2swXmIE2FCjMd5zw6dSRmmxu7VgE6bzvuOgB/W/oeOAyCsEDhDRDLBkjmb+yCsuexiXRWoempPsvAVhxhE8zEQJ1e8ChlFMtpOXSobU+YDgKYfcFy9Fbmk/o6M6B9y5zSlzs/HYIu7xvcCwjZI457idVMRxxAT6J/kXytmfKe/zbi5IO5/i0x9SCA1HRvt8K3nJqoH03h4TOvFwOwIDAQAB",
@@ -51,6 +51,6 @@
51
51
  }
52
52
  },
53
53
  "content_security_policy": {
54
- "extension_pages": "script-src 'self'; object-src 'self'; connect-src ws://127.0.0.1:*"
54
+ "extension_pages": "script-src 'self'; object-src 'self'; connect-src ws://127.0.0.1:* http://127.0.0.1:*"
55
55
  }
56
56
  }
@@ -10,6 +10,10 @@ export const POPUP_STRINGS = Object.freeze({
10
10
  reconnect: "Reconnect",
11
11
  retry: "Try again",
12
12
  openApp: "Open SynaBun",
13
+ openExtensions: "Open extensions page",
14
+ reloadExtension: "Reload extension",
15
+ openExtensionsFailed: "Couldn’t open the extensions page. Try again.",
16
+ reloadExtensionFailed: "Couldn’t reload the extension. Try again.",
13
17
  disconnect: "Disconnect",
14
18
  revoke: "Revoke pairing",
15
19
  cancel: "Cancel",
@@ -59,7 +63,6 @@ export const POPUP_STRINGS = Object.freeze({
59
63
  siteToast: "Site allowed for new agent tabs. Existing tabs remain private until shared.",
60
64
  removeSite: "Remove site",
61
65
  newTabs: "Allow agent-created tabs",
62
- uploads: "Allow uploads",
63
66
  downloads: "Allow downloads with Save As",
64
67
  downloadNote: "The browser asks for download permission when you turn this on.",
65
68
  downloadsDenied: "Downloads are off. Browser permission wasn’t granted; other access is unchanged.",
@@ -94,7 +97,7 @@ export const POPUP_STRINGS = Object.freeze({
94
97
  unavailable: "The extension didn’t answer. Close this popup and open it again.",
95
98
  siteDenied: "The browser didn’t grant access to this site. Nothing was shared.",
96
99
  actionFailed: "That didn’t work ({code}). Try again.",
97
- uploadHelpPopup: "Uploads come only from the upload folder shown in SynaBun Settings → Browser, up to 1 MB in total per upload command. Full control allows uploads; restricted mode requires Allow uploads.",
100
+ uploadHelpPopup: "Uploads come only from the upload folder shown in SynaBun Settings → Browser, up to 50 MB in total per upload command.",
98
101
  uploadFolder: "Upload folder",
99
102
  pairCode: "Pair with a code",
100
103
  pairCodeHelp: "Only if automatic pairing isn’t possible: in SynaBun Settings → Browser, start pairing, then enter its code and port here.",
@@ -121,6 +124,10 @@ export const POPUP_STRINGS = Object.freeze({
121
124
  reconnect: "Reconectar",
122
125
  retry: "Tentar novamente",
123
126
  openApp: "Abrir SynaBun",
127
+ openExtensions: "Abrir página de extensões",
128
+ reloadExtension: "Recarregar extensão",
129
+ openExtensionsFailed: "Não foi possível abrir a página de extensões. Tente novamente.",
130
+ reloadExtensionFailed: "Não foi possível recarregar a extensão. Tente novamente.",
124
131
  disconnect: "Desconectar",
125
132
  revoke: "Revogar pareamento",
126
133
  cancel: "Cancelar",
@@ -170,7 +177,6 @@ export const POPUP_STRINGS = Object.freeze({
170
177
  siteToast: "Site permitido para novas abas de agentes. As abas existentes só serão liberadas se compartilhadas.",
171
178
  removeSite: "Remover site",
172
179
  newTabs: "Permitir que agentes criem abas",
173
- uploads: "Permitir uploads",
174
180
  downloads: "Permitir downloads com Salvar como",
175
181
  downloadNote: "O navegador pede permissão para downloads ao ativar esta opção.",
176
182
  downloadsDenied: "Os downloads estão desativados. A permissão não foi concedida; os outros acessos continuam iguais.",
@@ -205,7 +211,7 @@ export const POPUP_STRINGS = Object.freeze({
205
211
  unavailable: "A extensão não respondeu. Feche este popup e abra novamente.",
206
212
  siteDenied: "O navegador não concedeu acesso a este site. Nada foi compartilhado.",
207
213
  actionFailed: "Não funcionou ({code}). Tente novamente.",
208
- uploadHelpPopup: "Os uploads usam apenas a pasta de uploads exibida em Ajustes do SynaBun → Navegador, com até 1 MB no total por comando. O controle total permite uploads; o modo restrito exige ativar Permitir uploads.",
214
+ uploadHelpPopup: "Os uploads usam apenas a pasta de uploads exibida em Ajustes do SynaBun → Navegador, com até 50 MB no total por comando.",
209
215
  uploadFolder: "Pasta de uploads",
210
216
  pairCode: "Parear com um código",
211
217
  pairCodeHelp: "Só se o pareamento automático não for possível: em Ajustes do SynaBun → Navegador, inicie o pareamento e digite aqui o código e a porta.",
@@ -101,7 +101,7 @@ export function popupView(result, { paired = null, t = key => key } = {}) {
101
101
  showShared: ok && live && !full,
102
102
  sites: ok && Array.isArray(result.sites) ? result.sites.slice() : [],
103
103
  waiting: tabs.filter(tab => tab && !tab.owner).map(tab => ({ handle: tab.handle, title: String(tab.title || '').trim() || t('untitledTab'), address: displayUrl(tab.url) })),
104
- options: { allowNewTabs: ok && result.allowNewTabs === true, uploads: ok && result.uploads === true, downloads: ok && result.downloads === true },
104
+ options: { allowNewTabs: ok && result.allowNewTabs === true, downloads: ok && result.downloads === true },
105
105
  port: ok && Number.isInteger(result.port) ? result.port : 3345,
106
106
  // Disconnect (pause) while paired and not already paused; Reconnect is the status action when paused.
107
107
  canDisconnect: isPaired && state !== 'disconnected',
@@ -145,6 +145,7 @@ svg { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColo
145
145
  /* footer */
146
146
  .p-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-xs); padding: var(--space-xs) var(--space-sm); border-top: 1px solid var(--color-border); }
147
147
  .p-footer-end { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
148
+ .p-footer-tools { flex-basis: 100%; }
148
149
 
149
150
  /* confirmations and the result line */
150
151
  .p-dialog { width: min(328px, calc(100vw - 32px)); padding: var(--space-xl); border: 1px solid var(--color-text-muted); border-radius: var(--radius-modal); background: var(--color-neutral-700); color: var(--color-text); }
@@ -56,7 +56,6 @@
56
56
  <div class="p-list" id="p-waiting"></div>
57
57
  <div class="p-actions"><button type="button" class="p-btn p-btn-primary" id="share" data-action="share"></button><button type="button" class="p-btn" id="site" data-action="site"></button></div>
58
58
  <label class="p-check"><input type="checkbox" id="newTabs"><span id="p-newtabs-label"></span></label>
59
- <label class="p-check"><input type="checkbox" id="uploads"><span id="p-uploads-label"></span></label>
60
59
  </section>
61
60
 
62
61
  <details class="p-details" id="p-files" hidden>
@@ -91,6 +90,10 @@
91
90
  <button type="button" class="p-btn p-btn-ghost" id="disconnect" data-action="confirm-disconnect" hidden></button>
92
91
  <button type="button" class="p-btn p-btn-ghost p-btn-danger" id="revoke" data-action="confirm-revoke" hidden></button>
93
92
  </span>
93
+ <div class="p-footer-end p-footer-tools">
94
+ <button type="button" class="p-btn p-btn-ghost" id="p-open-extensions" data-action="open-extensions"></button>
95
+ <button type="button" class="p-btn p-btn-ghost" id="p-reload-extension" data-action="reload-extension"></button>
96
+ </div>
94
97
  </footer>
95
98
 
96
99
  <p class="p-sr-only" id="p-live" role="status" aria-live="polite"></p>
@@ -1,8 +1,7 @@
1
- // The toolbar popup's DOM glue (popup.html). popup-view.js decides what is shown; this renders it and sends the owner's
2
- // actions to the service worker, which alone acts on them (docs/browser-extension-bridge.md). The messages are the
3
- // ones the worker has always taken from this page: status, pair, share, revokeTab, revokeSite, options, mode,
4
- // disconnect, resume, revoke. Disconnect, Revoke pairing, a mode change and removing a shared site are confirmed
5
- // first; Take back is immediate (the owner's fast interrupt) and never closes the tab.
1
+ // The toolbar popup's DOM glue (popup.html). popup-view.js decides what is shown. Bridge actions go to the service
2
+ // worker (docs/browser-extension-bridge.md). The popup opens its own links and reloads the extension directly.
3
+ // Disconnect, Revoke pairing, a mode change and removing a shared site are confirmed first. Take back is immediate
4
+ // and keeps the tab open.
6
5
  import { publicOrigin, hostPattern } from './protocol.js';
7
6
  import { popupLocale, translator } from './popup-strings.js';
8
7
  import { popupView } from './popup-view.js';
@@ -37,13 +36,16 @@ const openTab = url => chrome.tabs.create({ url });
37
36
  function fixedText() {
38
37
  document.documentElement.lang = locale;
39
38
  const set = (id, key) => { const node = $(id); if (node) node.textContent = t(key); };
40
- set('p-brand-sub', 'brandSub');
39
+ let version;
40
+ try { version = chrome.runtime.getManifest().version; } catch {}
41
+ $('p-brand-sub').textContent = version ? `${t('brandSub')} · v${version}` : t('brandSub');
41
42
  const openApp = $('p-open-app'); openApp.setAttribute('aria-label', t('openApp')); openApp.setAttribute('title', t('openApp'));
42
43
  set('p-footer-app', 'openApp'); set('disconnect', 'disconnect'); set('revoke', 'revoke');
44
+ set('p-open-extensions', 'openExtensions'); set('p-reload-extension', 'reloadExtension');
43
45
  set('p-mode-label', 'agentAccess'); set('p-mode-full', 'full'); set('p-mode-restricted', 'restricted');
44
46
  set('p-empty-title', 'emptyTitle'); set('p-empty-help', 'emptyHelp');
45
47
  set('p-shared-title', 'sharedSites'); set('p-shared-empty-title', 'noShared'); set('p-shared-empty-help', 'noSharedHelp'); set('p-waiting-title', 'sharedTabs');
46
- set('share', 'shareTab'); set('site', 'shareSite'); set('p-newtabs-label', 'newTabs'); set('p-uploads-label', 'uploads');
48
+ set('share', 'shareTab'); set('site', 'shareSite'); set('p-newtabs-label', 'newTabs');
47
49
  set('p-files-summary', 'advanced'); set('p-downloads-label', 'downloads'); set('p-download-note', 'downloadNote'); set('p-downloads-denied', 'downloadsDenied');
48
50
  set('p-upload-title', 'uploadFolder'); set('p-upload-help', 'uploadHelpPopup'); set('p-limits', 'limits');
49
51
  set('p-connection-summary', 'details'); set('p-bridge-label', 'bridge');
@@ -158,7 +160,7 @@ function render(next) {
158
160
  reconcile($('p-waiting'), view.showShared ? view.waiting : [], tab => tab.handle, makeRow('stop-sharing'), (row, tab) => updateRow(row, tab, { kind: 'stop-sharing', disabled: !view.live }));
159
161
  $('p-waiting-title').hidden = !view.waiting.length;
160
162
  $('p-shared-empty').hidden = !!(view.sites.length || view.waiting.length);
161
- $('newTabs').checked = view.options.allowNewTabs; $('uploads').checked = view.options.uploads; $('downloads').checked = view.options.downloads;
163
+ $('newTabs').checked = view.options.allowNewTabs; $('downloads').checked = view.options.downloads;
162
164
  // files and limits, the typed code
163
165
  $('p-files').hidden = !view.showFiles;
164
166
  textOnce($('p-bridge'), `127.0.0.1:${view.port}`);
@@ -290,6 +292,16 @@ async function takeBack(button, verb) {
290
292
  }
291
293
  async function act(action, target) {
292
294
  if (action === 'open-app') { await openTab(`${appOrigin()}/`); return; }
295
+ if (action === 'open-extensions') {
296
+ try { await openTab('chrome://extensions/'); }
297
+ catch { toast(t('openExtensionsFailed'), 'bad'); }
298
+ return;
299
+ }
300
+ if (action === 'reload-extension') {
301
+ try { chrome.runtime.reload(); }
302
+ catch { toast(t('reloadExtensionFailed'), 'bad'); }
303
+ return;
304
+ }
293
305
  if (action === 'connect') { await openTab(`${appOrigin()}/extension-setup`); toast(t('connectOpened')); return; }
294
306
  if (action === 'retry') { await refresh(); return; }
295
307
  if (action === 'resume') { await run(() => ask({ action: 'resume' }), t('reconnectingToast')); return; }
@@ -325,12 +337,12 @@ function wire() {
325
337
  const dialog = $('p-confirm');
326
338
  // Escape cancels (the dialog's own cancel event); the focus goes back to the control that opened it.
327
339
  dialog.addEventListener('cancel', event => { event.preventDefault(); closeConfirm(); });
328
- for (const id of ['newTabs', 'uploads', 'downloads']) $(id).addEventListener('change', () => run(async () => {
340
+ for (const id of ['newTabs', 'downloads']) $(id).addEventListener('change', () => run(async () => {
329
341
  $('p-downloads-denied').hidden = true;
330
342
  if (id === 'downloads' && $('downloads').checked && !await chrome.permissions.request({ permissions: ['downloads'] })) {
331
343
  $('downloads').checked = false; $('p-downloads-denied').hidden = false; $('p-files').open = true;
332
344
  }
333
- await ask({ action: 'options', options: { allowNewTabs: $('newTabs').checked, uploads: $('uploads').checked, downloads: $('downloads').checked } });
345
+ await ask({ action: 'options', options: { allowNewTabs: $('newTabs').checked, downloads: $('downloads').checked } });
334
346
  }, t('saved')));
335
347
  $('port').addEventListener('input', () => { portTouched = true; });
336
348
  $('pair').addEventListener('submit', event => {
@@ -1,7 +1,7 @@
1
1
  // Shared, dependency-free wire contract. Never send credentials or page content to a logger.
2
2
  export const VERSION = 1;
3
3
  export const MAX_MESSAGE = 4 * 1024 * 1024;
4
- export const MAX_FILE = 1024 * 1024;
4
+ export const MAX_FILE = 50 * 1024 * 1024;
5
5
  export const ID = /^[a-zA-Z0-9_-]{1,128}$/;
6
6
  // How long the server waits for the answer to one command (COMMAND_WAIT). Every command carries what is left of that
7
7
  // wait when it is sent (`deadline`, relative milliseconds, so the two clocks never have to agree; the HMAC protects it).
@@ -157,9 +157,10 @@ export function command(value) {
157
157
  if (!Number.isSafeInteger(v) || v < 0 || v > 1000000) fail('INVALID_MESSAGE');
158
158
  } else if (k === 'files') {
159
159
  if (!Array.isArray(v) || v.length < 1 || v.length > 4) fail('INVALID_MESSAGE');
160
- for (const f of v) {
161
- object(f, ['name', 'base64']); string(f.name, 255); string(f.base64, Math.ceil(MAX_FILE / 3) * 4);
162
- if (!/^[A-Za-z0-9+/]*={0,2}$/.test(f.base64) || /[\\/]/.test(f.name)) fail('INVALID_MESSAGE');
160
+ if (value.op !== 'upload') fail('INVALID_MESSAGE');
161
+ for (const name of v) {
162
+ string(name, 255);
163
+ if (!name || /[\\/]/.test(name)) fail('INVALID_MESSAGE');
163
164
  }
164
165
  } else string(v, k === 'text' || k === 'value' ? 100000 : 8192);
165
166
  }
@@ -216,7 +217,12 @@ export const ERROR_TEXT = Object.freeze({
216
217
  NAVIGATION_NOT_COMMITTED: 'The navigation did not commit before its deadline: the tab still shows its previous page (the site may still be loading, or the browser dropped the navigation). Nothing was reported as navigated; take a snapshot, then navigate again.',
217
218
  SCREENSHOT_PATH_REFUSED: 'The screenshot path is outside the allowed output locations or is protected.',
218
219
  NO_MATCH: 'No element matches the target.', AMBIGUOUS_TARGET: 'The selector must match one element or specify nthMatch.',
219
- PERMISSION_REQUIRED: 'Enable this feature in the extension popup first (downloads; in restricted mode also agent-created tabs and uploads).', OPERATION_FAILED: 'The browser refused this operation.',
220
+ UPLOAD_RELOAD_REQUIRED: 'Reload the updated SynaBun Browser Bridge extension to upload files.',
221
+ UPLOAD_FILE_MISSING: 'File not found in the extension upload folder.',
222
+ UPLOAD_TOO_LARGE: 'The selected files exceed the 50 MB total upload limit.',
223
+ UPLOAD_FILE_REFUSED: 'Choose readable regular files inside the extension upload folder shown in Settings → Browser.',
224
+ UPLOAD_MULTIPLE: 'This file input accepts only one file.',
225
+ PERMISSION_REQUIRED: 'Enable this feature in the extension popup first (downloads; in restricted mode also agent-created tabs).', OPERATION_FAILED: 'The browser refused this operation.',
220
226
  TIMEOUT: 'The operation timed out. Its outcome may be uncertain; observe before retrying.',
221
227
  CANCELLED: 'An approval was revoked or the connection ended while this command was pending. It was stopped before its next browser action; one already under way may have happened, so observe before retrying.',
222
228
  });
@@ -25,6 +25,14 @@ const send = value => {
25
25
  }); return outbound;
26
26
  };
27
27
  const engine = createEngine(chrome, {
28
+ async readUpload(id, index, timeout) {
29
+ const response = await fetch(`http://127.0.0.1:${port}/upload/${index}`, {
30
+ method: 'POST', headers: { Authorization: `Bearer ${id}` }, redirect: 'error',
31
+ credentials: 'omit', cache: 'no-store', signal: AbortSignal.timeout(Math.ceil(timeout)),
32
+ });
33
+ if (!response.ok) fail(response.status === 400 ? await response.text() : 'CANCELLED');
34
+ return response.blob();
35
+ },
28
36
  save: async value => {
29
37
  const { tabs, ...prefs } = value;
30
38
  await chrome.storage.session.set({ bridgeTabs: tabs });
@@ -14,7 +14,7 @@ The extension connects to SynaBun on this computer at `127.0.0.1`. Setup require
14
14
 
15
15
  **Full control** is the default. An agent can open tabs, use your existing tabs and work on signed-in sites or local development servers. Use **Take back** in the popup to regain control of a tab.
16
16
 
17
- Choose **Only sites and tabs I share** in **Settings → Browser → Agent access** or in the popup to limit access. Share the site and tab from the popup, then enable new tabs or downloads if the task needs them. For uploads, place the intended files in the upload folder shown in Settings.
17
+ Choose **Only sites and tabs I share** in **Settings → Browser → Agent access** or in the popup to limit access. Share the site and tab from the popup, then enable new tabs or downloads if the task needs them. For uploads, place the intended files in the upload folder shown in Settings and pass their absolute paths to `browser_upload`. The Chrome extension reads them through the local bridge because its service worker has no direct filesystem access. It uses the existing isolated content script to set the input and fire its input and change events. This needs no debugger permission.
18
18
 
19
19
  **Disconnect** pauses access across restarts. **Revoke pairing** ends the pairing. After an update, reload SynaBun Browser Bridge from the browser's extensions page when prompted.
20
20
 
@@ -79,6 +79,6 @@ Page interactions operate on the top document. Some controls require manual inpu
79
79
  | browser_session | Supported | Lists, opens or claims tabs according to the current access mode. |
80
80
  | browser_snapshot | Partial | Lists semantic elements in the top document. |
81
81
  | browser_type | Partial | Works with standard controls in the top document. |
82
- | browser_upload | Partial | Uses up to four files from the upload folder, up to 1 MB total. |
82
+ | browser_upload | Partial | Uses up to four files from the upload folder, up to 50 MB total in either access mode. The extension reads the selected files through its paired loopback bridge and attaches them to the file input. |
83
83
  | browser_wait | Partial | Works with standard controls in the top document. |
84
84
  | browser_x_compose_state | Unsupported | Unavailable in extension mode. |
@@ -0,0 +1,45 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { closeSync, lstatSync, openSync, readdirSync, readSync } from 'node:fs';
3
+ import { join, resolve } from 'node:path';
4
+
5
+ // Sorted depth-first traversal, with no open directory handles or recursive
6
+ // calls. A caller can stop after the first file. Never descend through a link.
7
+ export function* walkDataHomeTree(root) {
8
+ const pending = [{ directory: resolve(root), names: [''].values() }];
9
+ while (pending.length) {
10
+ const { directory, names } = pending.at(-1);
11
+ const next = names.next();
12
+ if (next.done) {
13
+ pending.pop();
14
+ continue;
15
+ }
16
+ const path = join(directory, next.value);
17
+ const stat = lstatSync(path, { throwIfNoEntry: false });
18
+ if (!stat) continue;
19
+ yield { path, stat };
20
+ if (stat.isDirectory()) {
21
+ try {
22
+ pending.push({ directory: path, names: readdirSync(path).sort().values() });
23
+ } catch (error) {
24
+ if (error.code !== 'ENOENT') throw error;
25
+ }
26
+ }
27
+ }
28
+ }
29
+
30
+ // Hashes run synchronously on this thread. Reuse the scratch space across
31
+ // small files and read large databases without allocating their size.
32
+ const hashBuffer = Buffer.allocUnsafe(64 * 1024);
33
+ export function hashFileSync(path) {
34
+ const hash = createHash('sha256');
35
+ const fd = openSync(path, 'r');
36
+ try {
37
+ let bytes;
38
+ while ((bytes = readSync(fd, hashBuffer, 0, hashBuffer.length, null)) > 0) {
39
+ hash.update(hashBuffer.subarray(0, bytes));
40
+ }
41
+ return hash.digest('hex');
42
+ } finally {
43
+ closeSync(fd);
44
+ }
45
+ }