synabun 2.4.0 → 2.4.2

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 (319) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +1 -1
  3. package/browser-extension/content.js +73 -11
  4. package/browser-extension/engine.js +196 -15
  5. package/browser-extension/manifest.json +4 -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 +102 -11
  12. package/browser-extension/service-worker.js +20 -4
  13. package/browser-extension/tokens.css +1 -1
  14. package/docs/browser-extension-bridge.md +25 -5
  15. package/lib/data-home-files.js +47 -0
  16. package/lib/data-home-migration.js +34 -58
  17. package/lib/first-launch-protection.js +8 -2
  18. package/lib/update-snapshot.js +11 -4
  19. package/mcp-server/dist/http.d.ts.map +1 -1
  20. package/mcp-server/dist/http.js +25 -2
  21. package/mcp-server/dist/http.js.map +1 -1
  22. package/mcp-server/dist/index.d.ts.map +1 -1
  23. package/mcp-server/dist/index.js +62 -17
  24. package/mcp-server/dist/index.js.map +1 -1
  25. package/mcp-server/dist/services/browser-bench.d.ts +22 -22
  26. package/mcp-server/dist/services/memory-maintenance.d.ts +1 -0
  27. package/mcp-server/dist/services/memory-maintenance.d.ts.map +1 -1
  28. package/mcp-server/dist/services/memory-maintenance.js +34 -45
  29. package/mcp-server/dist/services/memory-maintenance.js.map +1 -1
  30. package/mcp-server/dist/services/memory-migration-copy.d.ts +144 -0
  31. package/mcp-server/dist/services/memory-migration-copy.d.ts.map +1 -0
  32. package/mcp-server/dist/services/memory-migration-copy.js +467 -0
  33. package/mcp-server/dist/services/memory-migration-copy.js.map +1 -0
  34. package/mcp-server/dist/services/memory-migration-worker.d.ts +2 -0
  35. package/mcp-server/dist/services/memory-migration-worker.d.ts.map +1 -0
  36. package/mcp-server/dist/services/memory-migration-worker.js +60 -0
  37. package/mcp-server/dist/services/memory-migration-worker.js.map +1 -0
  38. package/mcp-server/dist/services/memory-retrieval.d.ts +4 -0
  39. package/mcp-server/dist/services/memory-retrieval.d.ts.map +1 -1
  40. package/mcp-server/dist/services/memory-retrieval.js +188 -40
  41. package/mcp-server/dist/services/memory-retrieval.js.map +1 -1
  42. package/mcp-server/dist/services/memory-schema.d.ts +58 -2
  43. package/mcp-server/dist/services/memory-schema.d.ts.map +1 -1
  44. package/mcp-server/dist/services/memory-schema.js +190 -13
  45. package/mcp-server/dist/services/memory-schema.js.map +1 -1
  46. package/mcp-server/dist/services/memory-sessions.d.ts +19 -1
  47. package/mcp-server/dist/services/memory-sessions.d.ts.map +1 -1
  48. package/mcp-server/dist/services/memory-sessions.js +56 -20
  49. package/mcp-server/dist/services/memory-sessions.js.map +1 -1
  50. package/mcp-server/dist/services/memory-verification.d.ts.map +1 -1
  51. package/mcp-server/dist/services/memory-verification.js +8 -5
  52. package/mcp-server/dist/services/memory-verification.js.map +1 -1
  53. package/mcp-server/dist/services/neural-interface.d.ts +6 -0
  54. package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
  55. package/mcp-server/dist/services/neural-interface.js +19 -2
  56. package/mcp-server/dist/services/neural-interface.js.map +1 -1
  57. package/mcp-server/dist/services/retrieval-reader-worker.d.ts +2 -0
  58. package/mcp-server/dist/services/retrieval-reader-worker.d.ts.map +1 -0
  59. package/mcp-server/dist/services/retrieval-reader-worker.js +76 -0
  60. package/mcp-server/dist/services/retrieval-reader-worker.js.map +1 -0
  61. package/mcp-server/dist/services/retrieval-reader.d.ts +38 -0
  62. package/mcp-server/dist/services/retrieval-reader.d.ts.map +1 -0
  63. package/mcp-server/dist/services/retrieval-reader.js +145 -0
  64. package/mcp-server/dist/services/retrieval-reader.js.map +1 -0
  65. package/mcp-server/dist/services/sqlite-write.d.ts +14 -0
  66. package/mcp-server/dist/services/sqlite-write.d.ts.map +1 -0
  67. package/mcp-server/dist/services/sqlite-write.js +94 -0
  68. package/mcp-server/dist/services/sqlite-write.js.map +1 -0
  69. package/mcp-server/dist/services/sqlite.d.ts +39 -0
  70. package/mcp-server/dist/services/sqlite.d.ts.map +1 -1
  71. package/mcp-server/dist/services/sqlite.js +249 -8
  72. package/mcp-server/dist/services/sqlite.js.map +1 -1
  73. package/mcp-server/dist/services/tool-catalog.d.ts +1 -1
  74. package/mcp-server/dist/services/typesafe-config.d.ts +7 -1
  75. package/mcp-server/dist/services/typesafe-config.d.ts.map +1 -1
  76. package/mcp-server/dist/services/typesafe-config.js +32 -10
  77. package/mcp-server/dist/services/typesafe-config.js.map +1 -1
  78. package/mcp-server/dist/services/typesafe.d.ts.map +1 -1
  79. package/mcp-server/dist/services/typesafe.js +9 -7
  80. package/mcp-server/dist/services/typesafe.js.map +1 -1
  81. package/mcp-server/dist/services/vector-cache.d.ts +32 -0
  82. package/mcp-server/dist/services/vector-cache.d.ts.map +1 -1
  83. package/mcp-server/dist/services/vector-cache.js +161 -8
  84. package/mcp-server/dist/services/vector-cache.js.map +1 -1
  85. package/mcp-server/dist/tools/agent-definition.d.ts +2 -2
  86. package/mcp-server/dist/tools/agents.d.ts +13 -8
  87. package/mcp-server/dist/tools/agents.d.ts.map +1 -1
  88. package/mcp-server/dist/tools/agents.js +35 -15
  89. package/mcp-server/dist/tools/agents.js.map +1 -1
  90. package/mcp-server/dist/tools/browser-advanced.d.ts +1 -1
  91. package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
  92. package/mcp-server/dist/tools/browser-advanced.js +10 -3
  93. package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
  94. package/mcp-server/dist/tools/browser-extension-setup.d.ts +5 -0
  95. package/mcp-server/dist/tools/browser-extension-setup.d.ts.map +1 -0
  96. package/mcp-server/dist/tools/browser-extension-setup.js +23 -0
  97. package/mcp-server/dist/tools/browser-extension-setup.js.map +1 -0
  98. package/mcp-server/dist/tools/browser-interact.d.ts.map +1 -1
  99. package/mcp-server/dist/tools/browser-interact.js +6 -1
  100. package/mcp-server/dist/tools/browser-interact.js.map +1 -1
  101. package/mcp-server/dist/tools/fb-groups.d.ts +2 -2
  102. package/mcp-server/dist/tools/skill-tools.d.ts +4 -4
  103. package/mcp-server/dist/tools/tool-groups.d.ts +1 -1
  104. package/mcp-server/package-lock.json +2 -2
  105. package/mcp-server/package.json +1 -1
  106. package/mcp-server/src/http.ts +20 -2
  107. package/mcp-server/src/index.ts +59 -17
  108. package/mcp-server/src/services/memory-maintenance.ts +31 -28
  109. package/mcp-server/src/services/memory-migration-copy.ts +419 -0
  110. package/mcp-server/src/services/memory-migration-worker.ts +55 -0
  111. package/mcp-server/src/services/memory-retrieval.ts +173 -32
  112. package/mcp-server/src/services/memory-schema.ts +194 -12
  113. package/mcp-server/src/services/memory-sessions.ts +54 -21
  114. package/mcp-server/src/services/memory-verification.ts +7 -4
  115. package/mcp-server/src/services/neural-interface.ts +23 -2
  116. package/mcp-server/src/services/retrieval-reader-worker.ts +67 -0
  117. package/mcp-server/src/services/retrieval-reader.ts +131 -0
  118. package/mcp-server/src/services/sqlite-write.ts +60 -0
  119. package/mcp-server/src/services/sqlite.ts +246 -8
  120. package/mcp-server/src/services/typesafe-config.ts +25 -6
  121. package/mcp-server/src/services/typesafe.ts +9 -7
  122. package/mcp-server/src/services/vector-cache.ts +154 -9
  123. package/mcp-server/src/tools/agents.ts +33 -14
  124. package/mcp-server/src/tools/browser-advanced.ts +10 -3
  125. package/mcp-server/src/tools/browser-extension-setup.ts +30 -0
  126. package/mcp-server/src/tools/browser-interact.ts +5 -1
  127. package/neural-interface/i18n/en.json +266 -2
  128. package/neural-interface/i18n/pt-BR.json +267 -3
  129. package/neural-interface/lib/agents/builtins.json +207 -0
  130. package/neural-interface/lib/agents/registry.js +60 -15
  131. package/neural-interface/lib/agents/resolve.js +69 -10
  132. package/neural-interface/lib/agents/split.js +32 -4
  133. package/neural-interface/lib/assistant-api.js +19 -8
  134. package/neural-interface/lib/assistant-brains/claude.js +2 -0
  135. package/neural-interface/lib/assistant-brains/opencode.js +60 -11
  136. package/neural-interface/lib/assistant-catalog.js +2 -2
  137. package/neural-interface/lib/assistant-config.js +0 -7
  138. package/neural-interface/lib/assistant-dispatch.js +384 -119
  139. package/neural-interface/lib/assistant-persona.js +17 -5
  140. package/neural-interface/lib/assistant-pricing.js +65 -14
  141. package/neural-interface/lib/assistant-router.js +181 -54
  142. package/neural-interface/lib/assistant-run-wait.js +45 -28
  143. package/neural-interface/lib/assistant-runtime.js +48 -34
  144. package/neural-interface/lib/backup-contents.js +158 -0
  145. package/neural-interface/lib/backup-crypto-io.js +330 -0
  146. package/neural-interface/lib/backup-crypto-worker.js +130 -0
  147. package/neural-interface/lib/backup-crypto.js +525 -0
  148. package/neural-interface/lib/backup-download.js +268 -0
  149. package/neural-interface/lib/backup-encryption.js +318 -0
  150. package/neural-interface/lib/backup-groups.js +287 -0
  151. package/neural-interface/lib/backup-restore-session.js +176 -0
  152. package/neural-interface/lib/backup-restore-stage.js +60 -0
  153. package/neural-interface/lib/backup-service.js +836 -322
  154. package/neural-interface/lib/backup-zip-reader.js +30 -18
  155. package/neural-interface/lib/backup-zip-writer.js +34 -10
  156. package/neural-interface/lib/browser-extension-adapter.js +109 -24
  157. package/neural-interface/lib/browser-extension-bridge.js +42 -8
  158. package/neural-interface/lib/claude-agent-bridge.js +1 -0
  159. package/neural-interface/lib/claude-session-cleanup.js +5 -1
  160. package/neural-interface/lib/cli-update-planner.js +105 -6
  161. package/neural-interface/lib/client-diagnostics.js +42 -0
  162. package/neural-interface/lib/confined-fs.js +7 -2
  163. package/neural-interface/lib/coordination/README.md +8 -2
  164. package/neural-interface/lib/coordination/contract.js +161 -0
  165. package/neural-interface/lib/coordination/database.js +999 -0
  166. package/neural-interface/lib/coordination/operations.js +436 -0
  167. package/neural-interface/lib/coordination/service.js +68 -537
  168. package/neural-interface/lib/coordination/storage-worker.js +101 -0
  169. package/neural-interface/lib/coordination/store.js +219 -1111
  170. package/neural-interface/lib/db.js +70 -32
  171. package/neural-interface/lib/health-count.js +37 -0
  172. package/neural-interface/lib/loop-stall.js +139 -0
  173. package/neural-interface/lib/maritaca/client.js +2 -2
  174. package/neural-interface/lib/maritaca/models.js +12 -17
  175. package/neural-interface/lib/maritaca/opencode.js +4 -2
  176. package/neural-interface/lib/memory-api.js +9 -1
  177. package/neural-interface/lib/memory-session-capture.js +42 -10
  178. package/neural-interface/lib/memory-store-gate.js +313 -0
  179. package/neural-interface/lib/memory-store-migrate.js +65 -0
  180. package/neural-interface/lib/memory-timers.js +7 -7
  181. package/neural-interface/lib/native-loop-providers.js +13 -16
  182. package/neural-interface/lib/native-loop-runtime.js +34 -14
  183. package/neural-interface/lib/opencode-build-preflight.js +30 -8
  184. package/neural-interface/lib/opencode-native-boundary.js +69 -8
  185. package/neural-interface/lib/opencode-provider-view.js +14 -3
  186. package/neural-interface/lib/opencode-v2-ws-requests.js +31 -1
  187. package/neural-interface/lib/opencode2-client.js +2 -1
  188. package/neural-interface/lib/peer-identity.js +13 -8
  189. package/neural-interface/lib/recall-impact.js +122 -0
  190. package/neural-interface/lib/scratch-evidence.js +420 -0
  191. package/neural-interface/lib/scratch-process-guard.js +139 -0
  192. package/neural-interface/lib/scratch-references.js +279 -0
  193. package/neural-interface/lib/scratch-retention-core.js +385 -0
  194. package/neural-interface/lib/scratch-retention-worker.js +37 -0
  195. package/neural-interface/lib/scratch-retention.js +151 -0
  196. package/neural-interface/lib/session-cache-builder.js +70 -44
  197. package/neural-interface/lib/session-cache-worker.js +157 -0
  198. package/neural-interface/lib/session-indexer.js +28 -21
  199. package/neural-interface/lib/session-search-index.js +85 -0
  200. package/neural-interface/lib/skills/creation.js +1 -1
  201. package/neural-interface/lib/sqlite-integrity-worker.js +3 -1
  202. package/neural-interface/lib/style-guide/store.js +43 -3
  203. package/neural-interface/lib/system-restore.js +50 -0
  204. package/neural-interface/lib/teams/api.js +15 -6
  205. package/neural-interface/lib/teams/claims.js +67 -31
  206. package/neural-interface/lib/teams/index.js +7 -7
  207. package/neural-interface/lib/teams/integration.js +40 -40
  208. package/neural-interface/lib/teams/landing.js +6 -6
  209. package/neural-interface/lib/teams/recovery.js +24 -23
  210. package/neural-interface/lib/teams/scheduler.js +196 -97
  211. package/neural-interface/lib/teams/schema.js +1 -1
  212. package/neural-interface/lib/teams/state.js +14 -14
  213. package/neural-interface/lib/teams/worktrees.js +27 -27
  214. package/neural-interface/lib/whatsapp/bridge.js +2 -1
  215. package/neural-interface/lib/worker-confinement.js +47 -2
  216. package/neural-interface/lib/worker-mcp-channel.js +2 -0
  217. package/neural-interface/lib/worker-resume.js +5 -0
  218. package/neural-interface/lib/worker-stop.js +86 -0
  219. package/neural-interface/package-lock.json +2 -2
  220. package/neural-interface/package.json +1 -1
  221. package/neural-interface/public/index.html +260 -0
  222. package/neural-interface/public/offline.html +4 -3
  223. package/neural-interface/public/onboarding.html +259 -34
  224. package/neural-interface/public/shared/agents/studio/ax-agent-view.js +2 -2
  225. package/neural-interface/public/shared/agents/studio/ax-editor-view.js +1 -1
  226. package/neural-interface/public/shared/agents/studio/ax-library.js +0 -6
  227. package/neural-interface/public/shared/agents/studio/ax-main.js +14 -7
  228. package/neural-interface/public/shared/agents/studio/ax-ui.js +2 -2
  229. package/neural-interface/public/shared/agy/agy-options.js +11 -0
  230. package/neural-interface/public/shared/agy/agy-panel.js +29 -10
  231. package/neural-interface/public/shared/agy/agy-styles.js +14 -12
  232. package/neural-interface/public/shared/agy/agy-tabs-logic.js +4 -1
  233. package/neural-interface/public/shared/api.js +3 -2
  234. package/neural-interface/public/shared/assistant/asst-api.js +3 -3
  235. package/neural-interface/public/shared/assistant/asst-brain-picker.js +13 -6
  236. package/neural-interface/public/shared/assistant/asst-control.js +2 -0
  237. package/neural-interface/public/shared/assistant/asst-motion-gate.js +78 -4
  238. package/neural-interface/public/shared/assistant/asst-panel.js +18 -2
  239. package/neural-interface/public/shared/assistant/asst-rack-styles.js +4 -0
  240. package/neural-interface/public/shared/assistant/asst-render.js +106 -38
  241. package/neural-interface/public/shared/assistant/asst-route.js +102 -21
  242. package/neural-interface/public/shared/assistant/asst-routes-editor.js +1 -1
  243. package/neural-interface/public/shared/assistant/asst-sidepanel.js +4 -2
  244. package/neural-interface/public/shared/assistant/asst-state.js +11 -0
  245. package/neural-interface/public/shared/assistant/asst-styles.js +10 -23
  246. package/neural-interface/public/shared/assistant/route-identity.js +2 -1
  247. package/neural-interface/public/shared/cc-dropdown.js +21 -15
  248. package/neural-interface/public/shared/cdx/cdx-render.js +9 -0
  249. package/neural-interface/public/shared/cdx/cdx-settings.js +3 -1
  250. package/neural-interface/public/shared/cdx/cdx-styles.js +6 -0
  251. package/neural-interface/public/shared/cdx/cdx-tabs.js +29 -9
  252. package/neural-interface/public/shared/client-diagnostics.js +94 -0
  253. package/neural-interface/public/shared/cp/cp-markdown.js +7 -2
  254. package/neural-interface/public/shared/cp/cp-styles.js +1 -1
  255. package/neural-interface/public/shared/effort-i18n.js +118 -0
  256. package/neural-interface/public/shared/html-shell.js +4 -51
  257. package/neural-interface/public/shared/loading-diagnostic-entry.js +64 -0
  258. package/neural-interface/public/shared/memory-store-wait.js +52 -0
  259. package/neural-interface/public/shared/morelogin-profile-field.js +1 -1
  260. package/neural-interface/public/shared/mtc/mtc-logic.js +2 -1
  261. package/neural-interface/public/shared/mtc/mtc-panel.js +8 -1
  262. package/neural-interface/public/shared/mtc/mtc-styles.js +13 -12
  263. package/neural-interface/public/shared/ocp-v2/ocp-v2-childpanel.js +7 -0
  264. package/neural-interface/public/shared/ocp-v2/ocp-v2-location-logic.js +109 -0
  265. package/neural-interface/public/shared/ocp-v2/ocp-v2-modelpicker.js +8 -1
  266. package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +118 -6
  267. package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +27 -3
  268. package/neural-interface/public/shared/ocp-v2/ocp-v2-send.js +13 -0
  269. package/neural-interface/public/shared/ocp-v2/ocp-v2-session-actions.js +2 -1
  270. package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +27 -93
  271. package/neural-interface/public/shared/ocp-v2/ocp-v2-variantpicker.js +17 -6
  272. package/neural-interface/public/shared/output-format.js +294 -0
  273. package/neural-interface/public/shared/owner-authority-view.js +4 -10
  274. package/neural-interface/public/shared/page-session.js +1 -1
  275. package/neural-interface/public/shared/provider-icons.js +6 -0
  276. package/neural-interface/public/shared/schedules-view.js +2 -1
  277. package/neural-interface/public/shared/server-presence.js +77 -0
  278. package/neural-interface/public/shared/settings/settings-ai-browser.js +5 -5
  279. package/neural-interface/public/shared/settings/settings-backup-contents.js +241 -0
  280. package/neural-interface/public/shared/settings/settings-backup-download.js +298 -0
  281. package/neural-interface/public/shared/settings/settings-backup-encryption-pane.js +335 -0
  282. package/neural-interface/public/shared/settings/settings-backup-encryption.js +545 -0
  283. package/neural-interface/public/shared/settings/settings-ia.js +1 -1
  284. package/neural-interface/public/shared/skills/studio/sx-geometry.js +12 -3
  285. package/neural-interface/public/shared/skills/studio/sx-main.js +14 -7
  286. package/neural-interface/public/shared/start-bridge.js +2 -2
  287. package/neural-interface/public/shared/studio-attention.js +6 -0
  288. package/neural-interface/public/shared/styles.css +354 -438
  289. package/neural-interface/public/shared/transcript-rows.js +28 -3
  290. package/neural-interface/public/shared/tray-auto-close.js +18 -5
  291. package/neural-interface/public/shared/ui-agents.js +1 -2
  292. package/neural-interface/public/shared/ui-automation-studio.js +168 -108
  293. package/neural-interface/public/shared/ui-claude-panel.js +42 -65
  294. package/neural-interface/public/shared/ui-loading.js +185 -25
  295. package/neural-interface/public/shared/ui-native-loop-router.js +59 -20
  296. package/neural-interface/public/shared/ui-navbar.js +2 -1
  297. package/neural-interface/public/shared/ui-output.js +533 -0
  298. package/neural-interface/public/shared/ui-owner-authority.js +48 -25
  299. package/neural-interface/public/shared/ui-schedules-studio.js +165 -128
  300. package/neural-interface/public/shared/ui-scroll-follow.js +97 -6
  301. package/neural-interface/public/shared/ui-sessions.js +2 -2
  302. package/neural-interface/public/shared/ui-settings-entry.js +18 -0
  303. package/neural-interface/public/shared/ui-settings.js +234 -67
  304. package/neural-interface/public/shared/ui-sidepanel-tray.js +3 -2
  305. package/neural-interface/public/shared/ui-sync.js +1 -0
  306. package/neural-interface/public/shared/ui-tooltip.js +16 -0
  307. package/neural-interface/public/shared/ui-tutorial.js +5 -6
  308. package/neural-interface/public/shared/ui-worker-end.js +27 -8
  309. package/neural-interface/public/shared/worker-end.js +9 -4
  310. package/neural-interface/public/sw.js +4 -3
  311. package/neural-interface/public/variant/2d/main.js +5 -0
  312. package/neural-interface/public/variant/3d/app.js +10 -0
  313. package/neural-interface/public/variant/3d/main.js +17 -4
  314. package/neural-interface/scripts/scratch-retention.mjs +20 -0
  315. package/neural-interface/server.js +507 -160
  316. package/npm-shrinkwrap.json +2 -2
  317. package/package.json +2 -1
  318. package/scripts/restore-data-home-from-backup.mjs +175 -8
  319. package/setup.js +18 -4
package/CHANGELOG.md CHANGED
@@ -1,3 +1,50 @@
1
+ # SynaBun v.2.4.2
2
+
3
+ This release gives you control over your backups, with optional password protection and a choice of what each one contains. It also makes side panels easier to read and fixes problems with restarts, large memory databases and OpenCode.
4
+
5
+ ## ✨ New
6
+
7
+ - **Password protection for backups.** Turn it on in Settings under Memory & backups. Manual, scheduled and pre-update backups are then encrypted, and scheduled backups keep running without asking for the password. It is off by default, and your existing backups still restore as before.
8
+ - **Choose what a backup contains.** Each group of data has its own switch and shows its size, so you can leave out caches and working folders that made backups very large. Logs and browser profiles are no longer included. A running backup can now be cancelled.
9
+ - **Save backups to a folder you choose.** Download full backup now writes directly to that folder and shows its progress, so large backups no longer have to fit in the browser tab first.
10
+ - **Page scripts in your everyday browser.** Browser Bridge 1.4.0 lets agents run page scripts and wait for a page to finish loading. To use it, reload the extension, turn on Allow User Scripts in its details, and reload it once more.
11
+
12
+ ## 🛠 Fixed
13
+
14
+ - **Workers survive a restart.** Workers paused for a server restart are no longer recorded as stopped by you, and they resume when the server is back.
15
+ - **Safer database upgrades.** Only one process now makes the safety copy before a memory database upgrade. Large databases no longer fill the disk with duplicate copies or block SynaBun from starting.
16
+ - **No more false "Server offline" screen.** A server that is only busy, for example during a large backup, no longer shows as offline.
17
+ - **OpenCode recovers from a removed folder.** If a session's folder is gone, the panel starts a new session in the right project and puts your prompt back in the box. OpenCode updates now show the update badge too.
18
+ - **Side panels stay at the bottom.** Transcripts keep following new output when the composer resizes, content collapses or the browser zoom changes.
19
+ - **Planned team tasks start reliably.** A task approved with a long slice title no longer fails when its team starts.
20
+
21
+ ## ⚙️ Changed
22
+
23
+ - **Side panel output is easier to read.** All six panels now share the same text, table and code styling. Wide tables scroll inside their frame and can be copied or expanded.
24
+ - **Studio windows open at a consistent size.** Skills, Agents, Automation and Schedules all open at the same default size and keep their saved position.
25
+ - **Model choices wait for you.** A route card now stays open until you answer it, instead of expiring after a set time.
26
+ - **Updated model pricing.** Prices were refreshed across all worker providers, so usage costs are more accurate.
27
+ - **More of the interface in Portuguese.** Backup messages, route cards and reasoning effort labels now appear in Brazilian Portuguese.
28
+
29
+ ---
30
+
31
+ # SynaBun v.2.4.1
32
+
33
+ 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.
34
+
35
+ ## ✨ New
36
+
37
+ - **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.
38
+ - **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.
39
+
40
+ ## 🛠 Fixed
41
+
42
+ - **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.
43
+ - **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.
44
+ - **MoreLogin in OpenCode.** OpenCode now applies the configured MoreLogin browser policy when checking whether a task can start.
45
+
46
+ ---
47
+
1
48
  # SynaBun v.2.4.0
2
49
 
3
50
  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.2 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(); });
@@ -14,7 +15,22 @@
14
15
  };
15
16
  const observer = new MutationObserver(removed);
16
17
  observer.observe(document, { childList: true, subtree: true });
17
- function target(args, active = false) {
18
+ // Uploads stay in the approved origin. Open shadow roots and same-origin frames can own hidden inputs.
19
+ function uploadMatches(selector) {
20
+ const matches = [], roots = [document];
21
+ for (const root of roots) {
22
+ for (const match of root.querySelectorAll(selector)) matches.push(match);
23
+ for (const node of root.querySelectorAll('*')) {
24
+ if (node.shadowRoot) roots.push(node.shadowRoot);
25
+ if (node.localName === 'iframe') {
26
+ const doc = node.contentDocument;
27
+ if (doc && doc.defaultView?.origin === location.origin) roots.push(doc);
28
+ }
29
+ }
30
+ }
31
+ return matches;
32
+ }
33
+ function target(args, active = false, query = selector => document.querySelectorAll(selector)) {
18
34
  removed(observer.takeRecords());
19
35
  if (args.ref) {
20
36
  const el = refs.get(args.ref);
@@ -22,7 +38,7 @@
22
38
  return el;
23
39
  }
24
40
  if (!args.selector && active) return document.activeElement;
25
- const found = [...document.querySelectorAll(args.selector || 'body')];
41
+ const found = query(args.selector || 'body');
26
42
  if (!found.length) error('NO_MATCH');
27
43
  if (found.length > 1 && args.nthMatch === undefined) error('AMBIGUOUS_TARGET');
28
44
  const el = found[args.nthMatch || 0]; if (!el) error('NO_MATCH'); return el;
@@ -59,6 +75,41 @@
59
75
  else if (!sites.includes(location.origin)) error('SITE_NOT_APPROVED');
60
76
  }
61
77
  const event = (el, name) => el.dispatchEvent(new Event(name, { bubbles: true }));
78
+ function acceptsFile(file, spec) {
79
+ const tokens = (spec || '').toLowerCase().split(',').map(s => s.trim()).filter(Boolean);
80
+ return !tokens.length || tokens.some(token => token === '*/*' || token === file.type ||
81
+ (token.startsWith('.') && file.name.toLowerCase().endsWith(token)) ||
82
+ (token.endsWith('/*') && file.type.startsWith(token.slice(0, -1))));
83
+ }
84
+ function uploadFiles(args, due) {
85
+ const parts = uploadParts.get(args.uploadId);
86
+ uploadParts.delete(args.uploadId);
87
+ if (!args.metadata || args.metadata.length !== args.files.length) error('UPLOAD_METADATA_UNAVAILABLE');
88
+ // Resolve the current input after the last async transfer. Keep selection and dispatch in its realm.
89
+ const el = target(args, false, uploadMatches);
90
+ if (args.ref && el.ownerDocument !== document) error('STALE_REF');
91
+ safeNode(el);
92
+ if (!el.matches('input[type=file]')) error('NO_MATCH');
93
+ if (el.matches(':disabled')) error('UPLOAD_DISABLED');
94
+ if (!el.multiple && args.files.length > 1) error('UPLOAD_MULTIPLE');
95
+ const view = el.ownerDocument.defaultView;
96
+ const transfer = new view.DataTransfer();
97
+ args.files.forEach((name, index) => {
98
+ const { size, type, lastModified } = args.metadata[index];
99
+ const file = new view.File(parts?.[index] || [], name, { type, lastModified });
100
+ if (file.size !== size) error('OPERATION_FAILED');
101
+ if (!acceptsFile(file, el.accept)) error('UPLOAD_ACCEPT_MISMATCH');
102
+ transfer.items.add(file);
103
+ });
104
+ due();
105
+ el.files = transfer.files;
106
+ // Take the receipt before a synchronous change listener consumes the selection or clears the control.
107
+ const files = Array.from(el.files, ({ name, type, size }) => ({ name, type, size }));
108
+ if (files.length !== args.files.length || files.some((file, i) =>
109
+ file.name !== args.files[i] || file.type !== args.metadata[i].type || file.size !== args.metadata[i].size)) error('UPLOAD_ASSIGNMENT_FAILED');
110
+ for (const name of ['input', 'change']) el.dispatchEvent(new view.Event(name, { bubbles: true, composed: true }));
111
+ return files;
112
+ }
62
113
  function setValue(el, value) {
63
114
  safeNode(el);
64
115
  if (el.isContentEditable) el.textContent = value;
@@ -128,6 +179,10 @@
128
179
  due(); el.scrollBy({ top: ['up', 'down'].includes(args.direction) ? amount * (args.direction === 'up' ? -1 : 1) : 0,
129
180
  left: ['left', 'right'].includes(args.direction) ? amount * (args.direction === 'left' ? -1 : 1) : 0, behavior: 'instant' }); return state();
130
181
  }
182
+ if (op === 'upload') {
183
+ const files = uploadFiles(args, due);
184
+ return { ...state(), files };
185
+ }
131
186
  const el = target(args, ['type', 'press'].includes(op)); safeNode(el);
132
187
  if (op === 'click') {
133
188
  const link = el.closest('a[href]'); if (link) {
@@ -150,19 +205,26 @@
150
205
  if (!['Enter', 'Escape', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Tab', 'Backspace', 'Delete'].includes(args.key)) error('UNSUPPORTED_IN_EXTENSION_MODE');
151
206
  due(); el.dispatchEvent(new KeyboardEvent('keydown', { key: args.key, bubbles: true }));
152
207
  el.dispatchEvent(new KeyboardEvent('keyup', { key: args.key, bubbles: true }));
153
- } else if (op === 'upload') {
154
- if (!el.matches('input[type=file]')) error('NO_MATCH');
155
- 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
- }
160
- due(); el.files = transfer.files; event(el, 'input'); event(el, 'change');
161
208
  } else error('UNSUPPORTED_IN_EXTENSION_MODE');
162
209
  return state();
163
210
  }
164
211
  chrome.runtime.onMessage.addListener((message, sender, respond) => {
165
- if (sender.id !== chrome.runtime.id || message?.kind !== 'synabun-fixed-command') return;
212
+ if (sender.id !== chrome.runtime.id) return;
213
+ if (message?.kind === 'synabun-upload-part') {
214
+ const { id, index, data, until } = message;
215
+ if (!(Date.now() < until)) { respond({ ok: false, code: 'TIMEOUT' }); return; }
216
+ if (!uploadParts.has(id)) {
217
+ uploadParts.set(id, []);
218
+ setTimeout(() => uploadParts.delete(id), until - Date.now());
219
+ }
220
+ const parts = uploadParts.get(id);
221
+ const decoded = atob(data);
222
+ const bytes = new Uint8Array(decoded.length);
223
+ for (let i = 0; i < decoded.length; i++) bytes[i] = decoded.charCodeAt(i);
224
+ (parts[index] ||= []).push(bytes);
225
+ respond({ ok: true }); return;
226
+ }
227
+ if (message?.kind !== 'synabun-fixed-command') return;
166
228
  execute(message).then(respond, error => respond({ ok: false, code: error.code || 'OPERATION_FAILED' }));
167
229
  return true;
168
230
  });
@@ -1,17 +1,46 @@
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, ERROR_TEXT, EVALUATE_RESULT_MAX, fail, HISTORY, inventory, hostPattern, localDeadline, longBudget, MAX_FILE, MAX_TABS, NETWORK_IDLE_QUIET, nonce, publicOrigin, safeError } from './protocol.js';
2
+
3
+ // The script handed to chrome.userScripts.execute for `evaluate`: the agent's code inside a wrapper that awaits it,
4
+ // turns what it returns into JSON text (cut at `cap` characters) and reports what it throws, so the answer is always
5
+ // this envelope and never a live object of the page. The arguments are parsed here and written back as JSON, so the
6
+ // script holds nothing but that data and the agent's own code. No string is ever evaluated by the extension itself:
7
+ // the browser compiles the script in the page (or in the user-script world), where the owner allowed user scripts.
8
+ // An expression that evaluates to a function is called with the arguments (as Playwright does for a string); a body
9
+ // is the body of an async function whose parameter `args` is the array of arguments.
10
+ function pageScript(args, cap) {
11
+ const list = JSON.stringify(args.params === undefined ? [] : JSON.parse(args.params));
12
+ const call = args.body !== undefined
13
+ ? `(async function (args) {\n${args.body}\n}).call(undefined, __synabunArgs)`
14
+ : `(__synabunValue => typeof __synabunValue === 'function' ? __synabunValue.apply(undefined, __synabunArgs) : __synabunValue)((\n${args.expression.replace(/[\s;]+$/, '')}\n))`;
15
+ return `(async () => { const __synabunArgs = ${list}; try { const __synabunResult = await ${call}; `
16
+ + `let __synabunJson = JSON.stringify(__synabunResult); if (typeof __synabunJson !== 'string') __synabunJson = 'null'; `
17
+ + `return { synabun: 1, ok: true, json: __synabunJson.length > ${cap} ? __synabunJson.slice(0, ${cap}) : __synabunJson, length: __synabunJson.length }; } `
18
+ + `catch (__synabunError) { return { synabun: 1, ok: false, name: String(__synabunError && __synabunError.name || '').slice(0, 200), `
19
+ + `message: String(__synabunError && __synabunError.message !== undefined ? __synabunError.message : __synabunError).slice(0, 2000), `
20
+ + `stack: String(__synabunError && __synabunError.stack || '').slice(0, 6000) }; } })()`;
21
+ }
22
+ // The result's JSON text as it travels: at most `cap` characters, and few enough bytes for one bridge message.
23
+ const RESULT_BYTES = 2500000;
24
+ function clipped(text, cap) {
25
+ let out = text.length > cap ? text.slice(0, cap) : text;
26
+ for (let size = new TextEncoder().encode(out).length; size > RESULT_BYTES; size = new TextEncoder().encode(out).length) out = out.slice(0, Math.floor(out.length * RESULT_BYTES / size) - 1);
27
+ return out;
28
+ }
2
29
 
3
30
  /** Pure controller over an injected chrome API; no socket or storage credential access. */
4
31
  // `now` is a monotonic clock (milliseconds) for command deadlines; `wallClock` the system clock the content script shares.
5
32
  // `fullControlDefault` is the mode before the owner ever chose one (full control: agents may use any http(s) site and
6
33
  // any tab of this browser with no sharing step). `activateMs` is how long a full-control screenshot lets a tab it
7
- // brought to the front settle before capturing it.
8
- export function createEngine(chrome, { save = async () => {}, changed = () => {}, settleMs = 10000, quietMs = 500, pollMs = 50,
9
- now = () => performance.now(), wallClock = () => Date.now(), fullControlDefault = true, activateMs = 150, commitMs = 20000, visibleMs = 2000 } = {}) {
34
+ // brought to the front settle before capturing it. `idleMs` is how long a tab must have had no request in flight to be
35
+ // network-idle (a load-state wait).
36
+ export function createEngine(chrome, { readUpload, save = async () => {}, changed = () => {}, settleMs = 10000, quietMs = 500, pollMs = 50,
37
+ now = () => performance.now(), wallClock = () => Date.now(), fullControlDefault = true, activateMs = 150, commitMs = 20000, visibleMs = 2000,
38
+ idleMs = NETWORK_IDLE_QUIET } = {}) {
10
39
  // `epoch` moves only on the owner's revocations and pairing changes, and cancels every tab's work. A tab's own
11
40
  // navigation, update or close moves that tab's counter in `moves` (by Chrome tab id) and nothing else: one agent's
12
41
  // ordinary navigation never cancels another agent's work on another tab. `focus` moves when the active tab changes;
13
42
  // 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;
43
+ let tabs = new Map(), sites = [], allowNewTabs = false, downloads = false, epoch = 0, focus = 0;
15
44
  // The mode and its version. Only the owner changes it: the popup (setMode) or the server's `mode` control message,
16
45
  // whose version must be newer. Switching to restricted is a revocation; switching to full control widens only.
17
46
  // In full control `tabs` also holds a record for every other tab of the browser (`listed`), so agents can see and
@@ -49,9 +78,40 @@ export function createEngine(chrome, { save = async () => {}, changed = () => {}
49
78
  const current = () => {
50
79
  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
80
  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 });
81
+ sites: [...sites], versions: sites.map(s => versions.get(s) || 0), allowNewTabs, uploads: true, downloads, fullControl, modeVersion });
53
82
  };
54
- const persist = async () => { await save({ tabs: [...tabs.values()], sites, versions: [...versions], allowNewTabs, uploads, downloads, fullControl, modeVersion }); changed(current()); };
83
+ // ── The network watch, for a wait with loadState 'networkidle' ──
84
+ // Only a tab an agent holds is watched: three non-blocking webRequest listeners, filtered to that tab, added when an
85
+ // agent takes it and removed when it gives it back, the tab closes or the owner takes it back (rewatch(), on every
86
+ // change of the tabs). Nothing of a request is kept but its id, and the owner's other tabs are never observed.
87
+ // `quietSince` is when the tab last had no request in flight (or when the watch began).
88
+ const web = chrome.webRequest, watchable = !!(web?.onBeforeRequest?.addListener && web.onCompleted?.addListener && web.onErrorOccurred?.addListener);
89
+ const watched = new Map();
90
+ function watch(id) {
91
+ const record = { inflight: new Set(), quietSince: now() };
92
+ const begin = details => {
93
+ // A new document: the requests of the one it replaces end with it (Playwright starts counting again, too).
94
+ if (details?.type === 'main_frame') record.inflight.clear();
95
+ record.inflight.add(String(details?.requestId));
96
+ };
97
+ const end = details => { if (record.inflight.delete(String(details?.requestId)) && !record.inflight.size) record.quietSince = now(); };
98
+ const entry = { record, begin, end }, filter = { urls: ['<all_urls>'], tabId: id };
99
+ watched.set(id, entry);
100
+ try { web.onBeforeRequest.addListener(begin, filter); web.onCompleted.addListener(end, filter); web.onErrorOccurred.addListener(end, filter); }
101
+ catch { unwatch(id); }
102
+ }
103
+ function unwatch(id) {
104
+ const entry = watched.get(id); if (!entry) return;
105
+ watched.delete(id);
106
+ for (const [event, listener] of [['onBeforeRequest', entry.begin], ['onCompleted', entry.end], ['onErrorOccurred', entry.end]]) { try { web[event].removeListener(listener); } catch {} }
107
+ }
108
+ function rewatch() {
109
+ if (!watchable) return;
110
+ const held = new Set([...tabs.values()].filter(t => t.owner).map(t => t.id));
111
+ for (const id of [...watched.keys()]) if (!held.has(id)) unwatch(id);
112
+ for (const id of held) if (!watched.has(id)) watch(id);
113
+ }
114
+ const persist = async () => { rewatch(); await save({ tabs: [...tabs.values()], sites, versions: [...versions], allowNewTabs, uploads: true, downloads, fullControl, modeVersion }); changed(current()); };
55
115
  async function live(t) {
56
116
  try { const tab = await chrome.tabs.get(t.id); t.url = shownUrl(tab); t.title = clip(tab.title); return tab; }
57
117
  catch { move(t.id); tabs.delete(t.handle); moves.delete(t.id); await persist(); fail('TAB_CLOSED'); }
@@ -109,7 +169,7 @@ export function createEngine(chrome, { save = async () => {}, changed = () => {}
109
169
  if (fullControl) open(t.url, blocked);
110
170
  else if (t.url !== 'about:blank') await permitted(t.url); else if (op !== 'navigate' && !HISTORY.includes(op)) fail('SITE_NOT_APPROVED');
111
171
  if (args.url) await destination(args.url, blocked);
112
- if (op === 'upload' && !uploads && !fullControl || op === 'download' && !downloads) fail('PERMISSION_REQUIRED');
172
+ if (op === 'download' && !downloads) fail('PERMISSION_REQUIRED');
113
173
  return t;
114
174
  }
115
175
  // The owner's mode change, from the popup or the server. An older version never applies. Switching to restricted
@@ -376,6 +436,92 @@ export function createEngine(chrome, { save = async () => {}, changed = () => {}
376
436
  const after = (await chrome.tabs.query({ active: true, windowId: opened.windowId }))[0];
377
437
  if (after?.id !== t.id || after.url !== opened.url) fail('ACTIVE_TAB_REQUIRED');
378
438
  await recheck(); result.base64 = data.split(',')[1]; result.mimeType = 'image/png';
439
+ } else if (op === 'wait' && args.loadState) {
440
+ // A load-state wait reads the tab (and, for 'networkidle', the requests the watch saw); nothing is done to the
441
+ // page. 'load': the tab is not loading and has no navigation pending. 'networkidle': also no request of the tab
442
+ // in flight for `idleMs` (already so for a page that has been quiet: it answers at once). Every page the tab
443
+ // shows meanwhile must be one the mode allows. The tab closing is TAB_CLOSED; the timeout (args.timeout, or
444
+ // the deadline) is TIMEOUT.
445
+ if (args.loadState === 'networkidle' && !watchable) fail('NETWORK_IDLE_UNAVAILABLE');
446
+ const until = Math.min(now() + longBudget(op, args), expires);
447
+ for (;;) {
448
+ const reading = await live(t); guard();
449
+ if (began !== epoch || tabs.get(tab) !== t || t.owner !== owner) fail('TAB_NOT_APPROVED');
450
+ for (const url of [reading.url, reading.pendingUrl]) if (url) { await landing(url); guard(); }
451
+ let idle = reading.status !== 'loading' && !reading.pendingUrl;
452
+ if (idle && args.loadState === 'networkidle') {
453
+ rewatch();
454
+ const seen = watched.get(t.id)?.record;
455
+ if (!seen) fail('NETWORK_IDLE_UNAVAILABLE');
456
+ idle = !seen.inflight.size && now() - seen.quietSince >= idleMs;
457
+ }
458
+ if (idle) break;
459
+ if (now() >= until) fail('TIMEOUT');
460
+ await new Promise(resolve => setTimeout(resolve, Math.max(1, Math.min(pollMs, until - now()))));
461
+ }
462
+ await authorized(op, tab, owner, {}, blocked); guard(); denyControlHost(t.url);
463
+ result = { ok: true, url: t.url, title: String(t.title || '').slice(0, 1000), loadState: args.loadState };
464
+ } else if (op === 'evaluate') {
465
+ // Page JavaScript, through chrome.userScripts.execute: the one way an MV3 extension may run code it did not ship,
466
+ // and only where the owner switched "Allow User Scripts" on for this extension (USER_SCRIPTS_DISABLED says how).
467
+ // Held to every gate of a page command (the agent's own tab, a page the mode allows, never SynaBun's own, the
468
+ // approval and connection generations, the deadline), and to one document: the frame's document is read first in
469
+ // the isolated world (its id and its address, which the page cannot forge), that address passes the same rule as
470
+ // the tab's, and the script runs in that document only (gone meanwhile: nothing runs).
471
+ if (t.url === 'about:blank') fail('BLANK_PAGE');
472
+ await recheck();
473
+ const scripts = chrome.userScripts;
474
+ const available = async () => { try { await scripts.getScripts(); return true; } catch { return false; } };
475
+ if (!scripts || !await available()) fail('USER_SCRIPTS_DISABLED');
476
+ if (typeof scripts.execute !== 'function') fail('USER_SCRIPTS_UNSUPPORTED');
477
+ guard();
478
+ const frame = args.frame ?? 0;
479
+ let probe;
480
+ try { probe = await act(() => chrome.scripting.executeScript({ target: { tabId: t.id, frameIds: [frame] }, world: 'ISOLATED', injectImmediately: true, func: () => location.href })); }
481
+ catch (error) { if (error?.code) throw error; guard(); await live(t); fail(frame ? 'FRAME_NOT_FOUND' : 'OPERATION_FAILED'); }
482
+ const page = probe?.[0];
483
+ if (typeof page?.documentId !== 'string' || typeof page.result !== 'string') fail(frame ? 'FRAME_NOT_FOUND' : 'TAB_NOT_APPROVED');
484
+ await recheck();
485
+ // A frame's document is an http(s) page of its own: a blank or srcdoc frame takes the origin of whoever made it.
486
+ if (!/^https?:/i.test(page.result)) fail('RESTRICTED_PAGE');
487
+ await landing(page.result); guard();
488
+ const cap = Math.max(1, Math.min(args.maxChars || EVALUATE_RESULT_MAX, EVALUATE_RESULT_MAX));
489
+ const EXPIRED = {}; let timer, running;
490
+ try {
491
+ running = Promise.resolve(act(() => scripts.execute({ target: { tabId: t.id, documentIds: [page.documentId] }, world: args.world || 'MAIN',
492
+ injectImmediately: true, js: [{ code: pageScript(args, cap) }] })));
493
+ } catch (error) { if (error?.code) throw error; running = Promise.reject(error); }
494
+ running.catch(() => {});
495
+ // The script's own timeout, never past the command's deadline. The page's script cannot be stopped: at the
496
+ // timeout the answer is TIMEOUT and whatever it returns later is dropped.
497
+ const expired = new Promise(resolve => { timer = setTimeout(resolve, Math.max(0, Math.min(longBudget(op, args), expires - now())), EXPIRED); });
498
+ let outcome;
499
+ try { outcome = await Promise.race([running, expired]); }
500
+ catch {
501
+ // The browser refused: the document is gone (the tab navigated or closed), or user scripts were switched off.
502
+ guard(); await live(t);
503
+ if (began !== epoch || moved(t.id) !== tabBegan || !frame && t.url !== page.result) fail('TAB_NOT_APPROVED');
504
+ if (!await available()) fail('USER_SCRIPTS_DISABLED');
505
+ fail('OPERATION_FAILED');
506
+ } finally { clearTimeout(timer); }
507
+ guard();
508
+ if (outcome === EXPIRED) fail('TIMEOUT');
509
+ // The script may itself have navigated the tab: that is its effect, not a reason to withhold what it returned
510
+ // from the document that was checked. An owner's revocation meanwhile is (guard(), the epoch).
511
+ if (began !== epoch) fail('TAB_NOT_APPROVED');
512
+ if (moved(t.id) !== tabBegan) t.nav = nonce();
513
+ const entry = Array.isArray(outcome) ? outcome[0] : null, reply = entry?.result;
514
+ if (reply?.synabun === 1 && reply.ok === true && typeof reply.json === 'string') {
515
+ const value = clipped(reply.json, cap), total = Number.isSafeInteger(reply.length) && reply.length > reply.json.length ? reply.length : reply.json.length;
516
+ result = { ok: true, value, ...(value.length < total ? { truncated: true, valueLength: total } : {}) };
517
+ } else {
518
+ // What the page's script threw (the wrapper's report), or what the browser said when it could not compile or
519
+ // run it. A page error is an answer about the page, with its own code: the bridge did what it was asked.
520
+ const threw = reply?.synabun === 1 && reply.ok === false, text = (value, max) => String(value ?? '').slice(0, max);
521
+ const message = threw ? [text(reply.name, 200), text(reply.message, 2000)].filter(Boolean).join(': ')
522
+ : typeof entry?.error === 'string' && entry.error ? text(entry.error, 2000) : 'The script returned no result: it did not compile, or the page stopped it.';
523
+ result = { ok: false, code: 'PAGE_ERROR', error: `PAGE_ERROR: ${ERROR_TEXT.PAGE_ERROR}`, errorMessage: message || 'The script threw.', errorStack: threw ? text(reply.stack, 6000) : '' };
524
+ }
379
525
  } else if (fullControl && t.url === 'about:blank') {
380
526
  // A blank tab (where a new agent tab starts) has no page an extension may script: it reads as empty, a plain
381
527
  // wait waits, and anything that needs an element finds none.
@@ -390,7 +536,7 @@ export function createEngine(chrome, { save = async () => {}, changed = () => {}
390
536
  await recheck(); result = blank;
391
537
  } else fail('NO_MATCH');
392
538
  } else {
393
- await act(() => chrome.scripting.executeScript({ target: { tabId: t.id, frameIds: [0] }, files: ['content.js'], world: 'ISOLATED' }));
539
+ const injection = await act(() => chrome.scripting.executeScript({ target: { tabId: t.id, frameIds: [0] }, files: ['content.js'], world: 'ISOLATED' }));
394
540
  await recheck();
395
541
  t.nav ||= nonce();
396
542
  // The page action carries the deadline as a system-clock time (`until`), which the content script shares: it
@@ -398,9 +544,44 @@ export function createEngine(chrome, { save = async () => {}, changed = () => {}
398
544
  // Full control sends no site list: the page checks only that a link or form does not lead to SynaBun's own
399
545
  // addresses (`blocked`). Restricted mode sends the approved sites, less SynaBun's public aliases.
400
546
  const beforeActionUrl = t.url;
401
- result = await act(() => chrome.tabs.sendMessage(t.id, { kind: 'synabun-fixed-command', op, args,
547
+ let delivery = { frameId: 0 }, pageArgs = args;
548
+ if (op === 'upload') {
549
+ const documentId = injection?.[0]?.documentId;
550
+ if (!documentId) fail('TAB_NOT_APPROVED');
551
+ delivery = { documentId };
552
+ const metadata = [];
553
+ let remaining = MAX_FILE;
554
+ for (let index = 0; index < args.files.length; index++) {
555
+ await recheck();
556
+ const response = await readUpload(input.id, index, Math.max(1, expires - now()));
557
+ const timestamp = response.headers.get('X-SynaBun-Last-Modified');
558
+ if (!timestamp || !Number.isSafeInteger(Number(timestamp))) fail('UPLOAD_METADATA_UNAVAILABLE');
559
+ const blob = await response.blob();
560
+ if (!blob.type) fail('UPLOAD_METADATA_UNAVAILABLE');
561
+ if (blob.size > remaining) fail('UPLOAD_TOO_LARGE');
562
+ remaining -= blob.size;
563
+ metadata.push({ size: blob.size, type: blob.type, lastModified: Number(timestamp) });
564
+ // Chrome serializes tab messages as JSON. Keep even a 50 MB file below its IPC cap.
565
+ const chunkSize = 1024 * 1024;
566
+ for (let pos = 0; pos < blob.size; pos += chunkSize) {
567
+ const reader = new FileReader();
568
+ const data = await new Promise((resolve, reject) => {
569
+ reader.onload = () => resolve(reader.result.split(',')[1]);
570
+ reader.onerror = () => reject(reader.error);
571
+ reader.readAsDataURL(blob.slice(pos, pos + chunkSize));
572
+ });
573
+ await recheck();
574
+ const ack = await act(() => chrome.tabs.sendMessage(t.id, { kind: 'synabun-upload-part',
575
+ id: input.id, index, data, until: wallClock() + Math.max(0, expires - now()) }, delivery));
576
+ if (!ack?.ok) fail(ack?.code || 'OPERATION_FAILED');
577
+ }
578
+ }
579
+ await recheck();
580
+ pageArgs = { ...args, uploadId: input.id, metadata };
581
+ }
582
+ result = await act(() => chrome.tabs.sendMessage(t.id, { kind: 'synabun-fixed-command', op, args: pageArgs,
402
583
  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 }));
584
+ until: wallClock() + Math.max(0, expires - now()) }, delivery));
404
585
  if (op === 'click' && result?.ok) {
405
586
  Object.assign(result, await metadata());
406
587
  if (result.url !== beforeActionUrl || moved(t.id) !== tabBegan) t.nav = nonce();
@@ -421,7 +602,7 @@ export function createEngine(chrome, { save = async () => {}, changed = () => {}
421
602
  async restore(saved = {}) {
422
603
  sites = (saved.sites || []).filter(s => { try { return publicOrigin(s) === s; } catch { return false; } });
423
604
  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;
605
+ allowNewTabs = saved.allowNewTabs === true; downloads = saved.downloads === true;
425
606
  fullControl = typeof saved.fullControl === 'boolean' ? saved.fullControl : fullControlDefault === true;
426
607
  modeVersion = Number.isSafeInteger(saved.modeVersion) && saved.modeVersion >= 0 ? saved.modeVersion : 0;
427
608
  tabs = new Map((saved.tabs || []).filter(t => fullControl || !t.listed || t.created).map(t => [t.handle, t]));
@@ -450,8 +631,8 @@ export function createEngine(chrome, { save = async () => {}, changed = () => {}
450
631
  async revokeSite(site) { approval++; sites = sites.filter(s => s !== site); epoch++; pruneVersions(); await persist(); },
451
632
  async options(value) {
452
633
  // 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();
634
+ if (allowNewTabs && value.allowNewTabs !== true || downloads && value.downloads !== true) { approval++; epoch++; }
635
+ allowNewTabs = value.allowNewTabs === true; downloads = value.downloads === true; await persist();
455
636
  },
456
637
  // Tab events from the browser concern that tab only.
457
638
  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 +645,7 @@ export function createEngine(chrome, { save = async () => {}, changed = () => {}
464
645
  await persist();
465
646
  },
466
647
  // 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(); },
648
+ async clear() { approval++; tabs.clear(); sites = []; allowNewTabs = downloads = false; epoch++; await enumerate(); await persist(); },
468
649
  activated() { focus++; },
469
650
  // Whether an agent holds the browser tab with this Chrome id (SynaBun's setup page is never paired from one).
470
651
  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.4.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",
@@ -9,6 +9,8 @@
9
9
  "storage",
10
10
  "alarms",
11
11
  "scripting",
12
+ "userScripts",
13
+ "webRequest",
12
14
  "tabs",
13
15
  "activeTab"
14
16
  ],
@@ -51,6 +53,6 @@
51
53
  }
52
54
  },
53
55
  "content_security_policy": {
54
- "extension_pages": "script-src 'self'; object-src 'self'; connect-src ws://127.0.0.1:*"
56
+ "extension_pages": "script-src 'self'; object-src 'self'; connect-src ws://127.0.0.1:* http://127.0.0.1:*"
55
57
  }
56
58
  }
@@ -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>