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.
- package/CHANGELOG.md +47 -0
- package/README.md +1 -1
- package/browser-extension/content.js +73 -11
- package/browser-extension/engine.js +196 -15
- package/browser-extension/manifest.json +4 -2
- package/browser-extension/popup-strings.js +10 -4
- package/browser-extension/popup-view.js +1 -1
- package/browser-extension/popup.css +1 -0
- package/browser-extension/popup.html +4 -1
- package/browser-extension/popup.js +22 -10
- package/browser-extension/protocol.js +102 -11
- package/browser-extension/service-worker.js +20 -4
- package/browser-extension/tokens.css +1 -1
- package/docs/browser-extension-bridge.md +25 -5
- package/lib/data-home-files.js +47 -0
- package/lib/data-home-migration.js +34 -58
- package/lib/first-launch-protection.js +8 -2
- package/lib/update-snapshot.js +11 -4
- package/mcp-server/dist/http.d.ts.map +1 -1
- package/mcp-server/dist/http.js +25 -2
- package/mcp-server/dist/http.js.map +1 -1
- package/mcp-server/dist/index.d.ts.map +1 -1
- package/mcp-server/dist/index.js +62 -17
- package/mcp-server/dist/index.js.map +1 -1
- package/mcp-server/dist/services/browser-bench.d.ts +22 -22
- package/mcp-server/dist/services/memory-maintenance.d.ts +1 -0
- package/mcp-server/dist/services/memory-maintenance.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-maintenance.js +34 -45
- package/mcp-server/dist/services/memory-maintenance.js.map +1 -1
- package/mcp-server/dist/services/memory-migration-copy.d.ts +144 -0
- package/mcp-server/dist/services/memory-migration-copy.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-migration-copy.js +467 -0
- package/mcp-server/dist/services/memory-migration-copy.js.map +1 -0
- package/mcp-server/dist/services/memory-migration-worker.d.ts +2 -0
- package/mcp-server/dist/services/memory-migration-worker.d.ts.map +1 -0
- package/mcp-server/dist/services/memory-migration-worker.js +60 -0
- package/mcp-server/dist/services/memory-migration-worker.js.map +1 -0
- package/mcp-server/dist/services/memory-retrieval.d.ts +4 -0
- package/mcp-server/dist/services/memory-retrieval.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-retrieval.js +188 -40
- package/mcp-server/dist/services/memory-retrieval.js.map +1 -1
- package/mcp-server/dist/services/memory-schema.d.ts +58 -2
- package/mcp-server/dist/services/memory-schema.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-schema.js +190 -13
- package/mcp-server/dist/services/memory-schema.js.map +1 -1
- package/mcp-server/dist/services/memory-sessions.d.ts +19 -1
- package/mcp-server/dist/services/memory-sessions.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-sessions.js +56 -20
- package/mcp-server/dist/services/memory-sessions.js.map +1 -1
- package/mcp-server/dist/services/memory-verification.d.ts.map +1 -1
- package/mcp-server/dist/services/memory-verification.js +8 -5
- package/mcp-server/dist/services/memory-verification.js.map +1 -1
- package/mcp-server/dist/services/neural-interface.d.ts +6 -0
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +19 -2
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/services/retrieval-reader-worker.d.ts +2 -0
- package/mcp-server/dist/services/retrieval-reader-worker.d.ts.map +1 -0
- package/mcp-server/dist/services/retrieval-reader-worker.js +76 -0
- package/mcp-server/dist/services/retrieval-reader-worker.js.map +1 -0
- package/mcp-server/dist/services/retrieval-reader.d.ts +38 -0
- package/mcp-server/dist/services/retrieval-reader.d.ts.map +1 -0
- package/mcp-server/dist/services/retrieval-reader.js +145 -0
- package/mcp-server/dist/services/retrieval-reader.js.map +1 -0
- package/mcp-server/dist/services/sqlite-write.d.ts +14 -0
- package/mcp-server/dist/services/sqlite-write.d.ts.map +1 -0
- package/mcp-server/dist/services/sqlite-write.js +94 -0
- package/mcp-server/dist/services/sqlite-write.js.map +1 -0
- package/mcp-server/dist/services/sqlite.d.ts +39 -0
- package/mcp-server/dist/services/sqlite.d.ts.map +1 -1
- package/mcp-server/dist/services/sqlite.js +249 -8
- package/mcp-server/dist/services/sqlite.js.map +1 -1
- package/mcp-server/dist/services/tool-catalog.d.ts +1 -1
- package/mcp-server/dist/services/typesafe-config.d.ts +7 -1
- package/mcp-server/dist/services/typesafe-config.d.ts.map +1 -1
- package/mcp-server/dist/services/typesafe-config.js +32 -10
- package/mcp-server/dist/services/typesafe-config.js.map +1 -1
- package/mcp-server/dist/services/typesafe.d.ts.map +1 -1
- package/mcp-server/dist/services/typesafe.js +9 -7
- package/mcp-server/dist/services/typesafe.js.map +1 -1
- package/mcp-server/dist/services/vector-cache.d.ts +32 -0
- package/mcp-server/dist/services/vector-cache.d.ts.map +1 -1
- package/mcp-server/dist/services/vector-cache.js +161 -8
- package/mcp-server/dist/services/vector-cache.js.map +1 -1
- package/mcp-server/dist/tools/agent-definition.d.ts +2 -2
- package/mcp-server/dist/tools/agents.d.ts +13 -8
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +35 -15
- package/mcp-server/dist/tools/agents.js.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts +1 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.js +10 -3
- package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
- package/mcp-server/dist/tools/browser-extension-setup.d.ts +5 -0
- package/mcp-server/dist/tools/browser-extension-setup.d.ts.map +1 -0
- package/mcp-server/dist/tools/browser-extension-setup.js +23 -0
- package/mcp-server/dist/tools/browser-extension-setup.js.map +1 -0
- package/mcp-server/dist/tools/browser-interact.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-interact.js +6 -1
- package/mcp-server/dist/tools/browser-interact.js.map +1 -1
- package/mcp-server/dist/tools/fb-groups.d.ts +2 -2
- package/mcp-server/dist/tools/skill-tools.d.ts +4 -4
- package/mcp-server/dist/tools/tool-groups.d.ts +1 -1
- package/mcp-server/package-lock.json +2 -2
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/http.ts +20 -2
- package/mcp-server/src/index.ts +59 -17
- package/mcp-server/src/services/memory-maintenance.ts +31 -28
- package/mcp-server/src/services/memory-migration-copy.ts +419 -0
- package/mcp-server/src/services/memory-migration-worker.ts +55 -0
- package/mcp-server/src/services/memory-retrieval.ts +173 -32
- package/mcp-server/src/services/memory-schema.ts +194 -12
- package/mcp-server/src/services/memory-sessions.ts +54 -21
- package/mcp-server/src/services/memory-verification.ts +7 -4
- package/mcp-server/src/services/neural-interface.ts +23 -2
- package/mcp-server/src/services/retrieval-reader-worker.ts +67 -0
- package/mcp-server/src/services/retrieval-reader.ts +131 -0
- package/mcp-server/src/services/sqlite-write.ts +60 -0
- package/mcp-server/src/services/sqlite.ts +246 -8
- package/mcp-server/src/services/typesafe-config.ts +25 -6
- package/mcp-server/src/services/typesafe.ts +9 -7
- package/mcp-server/src/services/vector-cache.ts +154 -9
- package/mcp-server/src/tools/agents.ts +33 -14
- package/mcp-server/src/tools/browser-advanced.ts +10 -3
- package/mcp-server/src/tools/browser-extension-setup.ts +30 -0
- package/mcp-server/src/tools/browser-interact.ts +5 -1
- package/neural-interface/i18n/en.json +266 -2
- package/neural-interface/i18n/pt-BR.json +267 -3
- package/neural-interface/lib/agents/builtins.json +207 -0
- package/neural-interface/lib/agents/registry.js +60 -15
- package/neural-interface/lib/agents/resolve.js +69 -10
- package/neural-interface/lib/agents/split.js +32 -4
- package/neural-interface/lib/assistant-api.js +19 -8
- package/neural-interface/lib/assistant-brains/claude.js +2 -0
- package/neural-interface/lib/assistant-brains/opencode.js +60 -11
- package/neural-interface/lib/assistant-catalog.js +2 -2
- package/neural-interface/lib/assistant-config.js +0 -7
- package/neural-interface/lib/assistant-dispatch.js +384 -119
- package/neural-interface/lib/assistant-persona.js +17 -5
- package/neural-interface/lib/assistant-pricing.js +65 -14
- package/neural-interface/lib/assistant-router.js +181 -54
- package/neural-interface/lib/assistant-run-wait.js +45 -28
- package/neural-interface/lib/assistant-runtime.js +48 -34
- package/neural-interface/lib/backup-contents.js +158 -0
- package/neural-interface/lib/backup-crypto-io.js +330 -0
- package/neural-interface/lib/backup-crypto-worker.js +130 -0
- package/neural-interface/lib/backup-crypto.js +525 -0
- package/neural-interface/lib/backup-download.js +268 -0
- package/neural-interface/lib/backup-encryption.js +318 -0
- package/neural-interface/lib/backup-groups.js +287 -0
- package/neural-interface/lib/backup-restore-session.js +176 -0
- package/neural-interface/lib/backup-restore-stage.js +60 -0
- package/neural-interface/lib/backup-service.js +836 -322
- package/neural-interface/lib/backup-zip-reader.js +30 -18
- package/neural-interface/lib/backup-zip-writer.js +34 -10
- package/neural-interface/lib/browser-extension-adapter.js +109 -24
- package/neural-interface/lib/browser-extension-bridge.js +42 -8
- package/neural-interface/lib/claude-agent-bridge.js +1 -0
- package/neural-interface/lib/claude-session-cleanup.js +5 -1
- package/neural-interface/lib/cli-update-planner.js +105 -6
- package/neural-interface/lib/client-diagnostics.js +42 -0
- package/neural-interface/lib/confined-fs.js +7 -2
- package/neural-interface/lib/coordination/README.md +8 -2
- package/neural-interface/lib/coordination/contract.js +161 -0
- package/neural-interface/lib/coordination/database.js +999 -0
- package/neural-interface/lib/coordination/operations.js +436 -0
- package/neural-interface/lib/coordination/service.js +68 -537
- package/neural-interface/lib/coordination/storage-worker.js +101 -0
- package/neural-interface/lib/coordination/store.js +219 -1111
- package/neural-interface/lib/db.js +70 -32
- package/neural-interface/lib/health-count.js +37 -0
- package/neural-interface/lib/loop-stall.js +139 -0
- package/neural-interface/lib/maritaca/client.js +2 -2
- package/neural-interface/lib/maritaca/models.js +12 -17
- package/neural-interface/lib/maritaca/opencode.js +4 -2
- package/neural-interface/lib/memory-api.js +9 -1
- package/neural-interface/lib/memory-session-capture.js +42 -10
- package/neural-interface/lib/memory-store-gate.js +313 -0
- package/neural-interface/lib/memory-store-migrate.js +65 -0
- package/neural-interface/lib/memory-timers.js +7 -7
- package/neural-interface/lib/native-loop-providers.js +13 -16
- package/neural-interface/lib/native-loop-runtime.js +34 -14
- package/neural-interface/lib/opencode-build-preflight.js +30 -8
- package/neural-interface/lib/opencode-native-boundary.js +69 -8
- package/neural-interface/lib/opencode-provider-view.js +14 -3
- package/neural-interface/lib/opencode-v2-ws-requests.js +31 -1
- package/neural-interface/lib/opencode2-client.js +2 -1
- package/neural-interface/lib/peer-identity.js +13 -8
- package/neural-interface/lib/recall-impact.js +122 -0
- package/neural-interface/lib/scratch-evidence.js +420 -0
- package/neural-interface/lib/scratch-process-guard.js +139 -0
- package/neural-interface/lib/scratch-references.js +279 -0
- package/neural-interface/lib/scratch-retention-core.js +385 -0
- package/neural-interface/lib/scratch-retention-worker.js +37 -0
- package/neural-interface/lib/scratch-retention.js +151 -0
- package/neural-interface/lib/session-cache-builder.js +70 -44
- package/neural-interface/lib/session-cache-worker.js +157 -0
- package/neural-interface/lib/session-indexer.js +28 -21
- package/neural-interface/lib/session-search-index.js +85 -0
- package/neural-interface/lib/skills/creation.js +1 -1
- package/neural-interface/lib/sqlite-integrity-worker.js +3 -1
- package/neural-interface/lib/style-guide/store.js +43 -3
- package/neural-interface/lib/system-restore.js +50 -0
- package/neural-interface/lib/teams/api.js +15 -6
- package/neural-interface/lib/teams/claims.js +67 -31
- package/neural-interface/lib/teams/index.js +7 -7
- package/neural-interface/lib/teams/integration.js +40 -40
- package/neural-interface/lib/teams/landing.js +6 -6
- package/neural-interface/lib/teams/recovery.js +24 -23
- package/neural-interface/lib/teams/scheduler.js +196 -97
- package/neural-interface/lib/teams/schema.js +1 -1
- package/neural-interface/lib/teams/state.js +14 -14
- package/neural-interface/lib/teams/worktrees.js +27 -27
- package/neural-interface/lib/whatsapp/bridge.js +2 -1
- package/neural-interface/lib/worker-confinement.js +47 -2
- package/neural-interface/lib/worker-mcp-channel.js +2 -0
- package/neural-interface/lib/worker-resume.js +5 -0
- package/neural-interface/lib/worker-stop.js +86 -0
- package/neural-interface/package-lock.json +2 -2
- package/neural-interface/package.json +1 -1
- package/neural-interface/public/index.html +260 -0
- package/neural-interface/public/offline.html +4 -3
- package/neural-interface/public/onboarding.html +259 -34
- package/neural-interface/public/shared/agents/studio/ax-agent-view.js +2 -2
- package/neural-interface/public/shared/agents/studio/ax-editor-view.js +1 -1
- package/neural-interface/public/shared/agents/studio/ax-library.js +0 -6
- package/neural-interface/public/shared/agents/studio/ax-main.js +14 -7
- package/neural-interface/public/shared/agents/studio/ax-ui.js +2 -2
- package/neural-interface/public/shared/agy/agy-options.js +11 -0
- package/neural-interface/public/shared/agy/agy-panel.js +29 -10
- package/neural-interface/public/shared/agy/agy-styles.js +14 -12
- package/neural-interface/public/shared/agy/agy-tabs-logic.js +4 -1
- package/neural-interface/public/shared/api.js +3 -2
- package/neural-interface/public/shared/assistant/asst-api.js +3 -3
- package/neural-interface/public/shared/assistant/asst-brain-picker.js +13 -6
- package/neural-interface/public/shared/assistant/asst-control.js +2 -0
- package/neural-interface/public/shared/assistant/asst-motion-gate.js +78 -4
- package/neural-interface/public/shared/assistant/asst-panel.js +18 -2
- package/neural-interface/public/shared/assistant/asst-rack-styles.js +4 -0
- package/neural-interface/public/shared/assistant/asst-render.js +106 -38
- package/neural-interface/public/shared/assistant/asst-route.js +102 -21
- package/neural-interface/public/shared/assistant/asst-routes-editor.js +1 -1
- package/neural-interface/public/shared/assistant/asst-sidepanel.js +4 -2
- package/neural-interface/public/shared/assistant/asst-state.js +11 -0
- package/neural-interface/public/shared/assistant/asst-styles.js +10 -23
- package/neural-interface/public/shared/assistant/route-identity.js +2 -1
- package/neural-interface/public/shared/cc-dropdown.js +21 -15
- package/neural-interface/public/shared/cdx/cdx-render.js +9 -0
- package/neural-interface/public/shared/cdx/cdx-settings.js +3 -1
- package/neural-interface/public/shared/cdx/cdx-styles.js +6 -0
- package/neural-interface/public/shared/cdx/cdx-tabs.js +29 -9
- package/neural-interface/public/shared/client-diagnostics.js +94 -0
- package/neural-interface/public/shared/cp/cp-markdown.js +7 -2
- package/neural-interface/public/shared/cp/cp-styles.js +1 -1
- package/neural-interface/public/shared/effort-i18n.js +118 -0
- package/neural-interface/public/shared/html-shell.js +4 -51
- package/neural-interface/public/shared/loading-diagnostic-entry.js +64 -0
- package/neural-interface/public/shared/memory-store-wait.js +52 -0
- package/neural-interface/public/shared/morelogin-profile-field.js +1 -1
- package/neural-interface/public/shared/mtc/mtc-logic.js +2 -1
- package/neural-interface/public/shared/mtc/mtc-panel.js +8 -1
- package/neural-interface/public/shared/mtc/mtc-styles.js +13 -12
- package/neural-interface/public/shared/ocp-v2/ocp-v2-childpanel.js +7 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-location-logic.js +109 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-modelpicker.js +8 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +118 -6
- package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +27 -3
- package/neural-interface/public/shared/ocp-v2/ocp-v2-send.js +13 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-session-actions.js +2 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +27 -93
- package/neural-interface/public/shared/ocp-v2/ocp-v2-variantpicker.js +17 -6
- package/neural-interface/public/shared/output-format.js +294 -0
- package/neural-interface/public/shared/owner-authority-view.js +4 -10
- package/neural-interface/public/shared/page-session.js +1 -1
- package/neural-interface/public/shared/provider-icons.js +6 -0
- package/neural-interface/public/shared/schedules-view.js +2 -1
- package/neural-interface/public/shared/server-presence.js +77 -0
- package/neural-interface/public/shared/settings/settings-ai-browser.js +5 -5
- package/neural-interface/public/shared/settings/settings-backup-contents.js +241 -0
- package/neural-interface/public/shared/settings/settings-backup-download.js +298 -0
- package/neural-interface/public/shared/settings/settings-backup-encryption-pane.js +335 -0
- package/neural-interface/public/shared/settings/settings-backup-encryption.js +545 -0
- package/neural-interface/public/shared/settings/settings-ia.js +1 -1
- package/neural-interface/public/shared/skills/studio/sx-geometry.js +12 -3
- package/neural-interface/public/shared/skills/studio/sx-main.js +14 -7
- package/neural-interface/public/shared/start-bridge.js +2 -2
- package/neural-interface/public/shared/studio-attention.js +6 -0
- package/neural-interface/public/shared/styles.css +354 -438
- package/neural-interface/public/shared/transcript-rows.js +28 -3
- package/neural-interface/public/shared/tray-auto-close.js +18 -5
- package/neural-interface/public/shared/ui-agents.js +1 -2
- package/neural-interface/public/shared/ui-automation-studio.js +168 -108
- package/neural-interface/public/shared/ui-claude-panel.js +42 -65
- package/neural-interface/public/shared/ui-loading.js +185 -25
- package/neural-interface/public/shared/ui-native-loop-router.js +59 -20
- package/neural-interface/public/shared/ui-navbar.js +2 -1
- package/neural-interface/public/shared/ui-output.js +533 -0
- package/neural-interface/public/shared/ui-owner-authority.js +48 -25
- package/neural-interface/public/shared/ui-schedules-studio.js +165 -128
- package/neural-interface/public/shared/ui-scroll-follow.js +97 -6
- package/neural-interface/public/shared/ui-sessions.js +2 -2
- package/neural-interface/public/shared/ui-settings-entry.js +18 -0
- package/neural-interface/public/shared/ui-settings.js +234 -67
- package/neural-interface/public/shared/ui-sidepanel-tray.js +3 -2
- package/neural-interface/public/shared/ui-sync.js +1 -0
- package/neural-interface/public/shared/ui-tooltip.js +16 -0
- package/neural-interface/public/shared/ui-tutorial.js +5 -6
- package/neural-interface/public/shared/ui-worker-end.js +27 -8
- package/neural-interface/public/shared/worker-end.js +9 -4
- package/neural-interface/public/sw.js +4 -3
- package/neural-interface/public/variant/2d/main.js +5 -0
- package/neural-interface/public/variant/3d/app.js +10 -0
- package/neural-interface/public/variant/3d/main.js +17 -4
- package/neural-interface/scripts/scratch-retention.mjs +20 -0
- package/neural-interface/server.js +507 -160
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
- package/scripts/restore-data-home-from-backup.mjs +175 -8
- package/setup.js +18 -4
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
// The toolbar popup's DOM glue (popup.html). popup-view.js decides what is shown
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
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
|
-
|
|
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');
|
|
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; $('
|
|
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', '
|
|
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,
|
|
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).
|
|
@@ -18,6 +18,38 @@ export function localDeadline(receivedAt, deadline) { return receivedAt + deadli
|
|
|
18
18
|
// The watchdog for a browser call that never returns: once a command runs, the queue waits at most this long for it.
|
|
19
19
|
// It never gives a command more time than its deadline; the effective limit is the earlier of the two.
|
|
20
20
|
export const QUEUE_LIMIT = 30000;
|
|
21
|
+
// ── Long operations (1.4.0): running page JavaScript (`evaluate`) and a load-state wait (`wait` with `loadState`) ──
|
|
22
|
+
// They may take longer than COMMAND_WAIT, so they carry a longer deadline (up to LONG_WAIT) and never hold the worker's
|
|
23
|
+
// queue: the extension runs them beside the ordinary commands, each under its own deadline. The server waits
|
|
24
|
+
// commandWait(op, args) for one: the operation's own timeout plus LONG_MARGIN, never less than COMMAND_WAIT.
|
|
25
|
+
export const LONG_WAIT = 65000;
|
|
26
|
+
export const LONG_MARGIN = 5000;
|
|
27
|
+
// evaluate: the script's own timeout (args.timeout; default, most), the script source and its JSON arguments (characters),
|
|
28
|
+
// and the JSON text of its result (characters; a longer one is cut and flagged `truncated`).
|
|
29
|
+
export const EVALUATE_TIMEOUT = 30000;
|
|
30
|
+
export const EVALUATE_TIMEOUT_MAX = 60000;
|
|
31
|
+
export const EVALUATE_SCRIPT_MAX = 500000;
|
|
32
|
+
export const EVALUATE_PARAMS_MAX = 100000;
|
|
33
|
+
export const EVALUATE_RESULT_MAX = 1000000;
|
|
34
|
+
// 'MAIN' is the page's own JavaScript world (its globals are visible); 'USER_SCRIPT' is Chrome's separate world for
|
|
35
|
+
// user scripts (the DOM, none of the page's globals, exempt from the page's CSP).
|
|
36
|
+
export const EVALUATE_WORLDS = ['MAIN', 'USER_SCRIPT'];
|
|
37
|
+
// wait with loadState: 'load' (the tab finished loading) or 'networkidle' (also no request of the tab in flight for
|
|
38
|
+
// NETWORK_IDLE_QUIET ms, as Playwright counts it), within args.timeout (default, most).
|
|
39
|
+
export const LOAD_STATES = ['load', 'networkidle'];
|
|
40
|
+
export const NETWORK_IDLE_QUIET = 500;
|
|
41
|
+
export const NETWORK_IDLE_TIMEOUT = 15000;
|
|
42
|
+
export const NETWORK_IDLE_TIMEOUT_MAX = 60000;
|
|
43
|
+
export function longOp(op, args) { return op === 'evaluate' || op === 'wait' && args?.loadState !== undefined; }
|
|
44
|
+
// The operation's own time limit (ms), from args.timeout: its default when none is given, never above its most.
|
|
45
|
+
export function longBudget(op, args = {}) {
|
|
46
|
+
const [normal, most] = op === 'evaluate' ? [EVALUATE_TIMEOUT, EVALUATE_TIMEOUT_MAX] : [NETWORK_IDLE_TIMEOUT, NETWORK_IDLE_TIMEOUT_MAX];
|
|
47
|
+
return Math.max(1, Math.min(Number.isSafeInteger(args?.timeout) ? args.timeout : normal, most));
|
|
48
|
+
}
|
|
49
|
+
// How long the server waits for the answer to a command, and the most its `deadline` may say.
|
|
50
|
+
export function commandWait(op, args = {}) {
|
|
51
|
+
return longOp(op, args) ? Math.max(COMMAND_WAIT, Math.min(LONG_WAIT, longBudget(op, args) + LONG_MARGIN)) : COMMAND_WAIT;
|
|
52
|
+
}
|
|
21
53
|
export function fail(code, message = code) { throw Object.assign(new Error(message), { code }); }
|
|
22
54
|
export function object(value, keys) {
|
|
23
55
|
if (!value || typeof value !== 'object' || Array.isArray(value) || Object.keys(value).some(k => !keys.includes(k))) fail('INVALID_MESSAGE');
|
|
@@ -131,7 +163,10 @@ export function inventory(value) {
|
|
|
131
163
|
}
|
|
132
164
|
return value;
|
|
133
165
|
}
|
|
134
|
-
export const COMMANDS = ['create', 'claim', 'release', 'navigate', 'back', 'forward', 'reload', 'snapshot', 'click', 'hover', 'fill', 'type', 'press', 'select', 'scroll', 'wait', 'content', 'screenshot', 'upload', 'download', 'revokeTab', 'revokeSite', 'disconnect', 'revoke', 'mode', 'reset'];
|
|
166
|
+
export const COMMANDS = ['create', 'claim', 'release', 'navigate', 'back', 'forward', 'reload', 'snapshot', 'click', 'hover', 'fill', 'type', 'press', 'select', 'scroll', 'wait', 'content', 'screenshot', 'upload', 'download', 'evaluate', 'revokeTab', 'revokeSite', 'disconnect', 'revoke', 'mode', 'reset'];
|
|
167
|
+
// The first extension version that knows `evaluate` and `wait` with `loadState`. An older one ends the connection on a
|
|
168
|
+
// command it does not know, so the server never sends it one (it answers EXTENSION_RELOAD_REQUIRED itself).
|
|
169
|
+
export const LONG_OPS_SINCE = '1.4.0';
|
|
135
170
|
export const HISTORY = ['back', 'forward'];
|
|
136
171
|
// The owner's control messages: revocations, the mode (full control or restricted) and `reset` (a restarted server
|
|
137
172
|
// hands back every tab agents of its previous process held). They overtake queued commands on both sides, are never
|
|
@@ -142,24 +177,32 @@ export function command(value) {
|
|
|
142
177
|
if (value.type !== 'command' || !COMMANDS.includes(value.op)) fail('UNSUPPORTED_IN_EXTENSION_MODE');
|
|
143
178
|
handle(value.id); if (value.tab !== null) handle(value.tab); handle(value.owner);
|
|
144
179
|
// Required on every command: whole milliseconds, 1 to COMMAND_WAIT (the server never has more left than its wait).
|
|
145
|
-
|
|
180
|
+
// A long operation's may reach commandWait(op, args): checked below, once its arguments are known to be an object.
|
|
181
|
+
if (!Number.isSafeInteger(value.deadline) || value.deadline < 1 || value.deadline > LONG_WAIT) fail('INVALID_MESSAGE');
|
|
146
182
|
// SynaBun's own addresses, which no command may reach (controlSurface): its public aliases (any port), its ports,
|
|
147
183
|
// and this computer's names and interface addresses.
|
|
148
184
|
for (const key of ['blockedHosts', 'selfHosts']) {
|
|
149
185
|
if (value[key] !== undefined && (!Array.isArray(value[key]) || value[key].length > 200 || value[key].some(h => typeof h !== 'string' || h.length > 253 || !/^[a-zA-Z0-9.:%-]+$/.test(h)))) fail('INVALID_MESSAGE');
|
|
150
186
|
}
|
|
151
187
|
if (value.blockedPorts !== undefined && (!Array.isArray(value.blockedPorts) || value.blockedPorts.length > 32 || value.blockedPorts.some(p => !Number.isSafeInteger(p) || p < 1 || p > 65535))) fail('INVALID_MESSAGE');
|
|
152
|
-
const a = value.args; object(a, ['url', 'ref', 'selector', 'nthMatch', 'value', 'text', 'key', 'direction', 'distance', 'maxChars', 'offset', 'timeout', 'state', 'files', 'site', 'fullControl', 'version'
|
|
188
|
+
const a = value.args; object(a, ['url', 'ref', 'selector', 'nthMatch', 'value', 'text', 'key', 'direction', 'distance', 'maxChars', 'offset', 'timeout', 'state', 'files', 'site', 'fullControl', 'version',
|
|
189
|
+
'expression', 'body', 'params', 'world', 'frame', 'loadState']);
|
|
190
|
+
if (value.deadline > commandWait(value.op, a)) fail('INVALID_MESSAGE');
|
|
153
191
|
for (const [k, v] of Object.entries(a)) {
|
|
154
192
|
if (k === 'fullControl') { if (typeof v !== 'boolean') fail('INVALID_MESSAGE'); }
|
|
155
193
|
else if (k === 'version') { if (!Number.isSafeInteger(v) || v < 0) fail('INVALID_MESSAGE'); }
|
|
194
|
+
// A frame of the tab, by Chrome's frame id (0, the default, is the top document).
|
|
195
|
+
else if (k === 'frame') { if (!Number.isSafeInteger(v) || v < 0 || v > 2147483647) fail('INVALID_MESSAGE'); }
|
|
196
|
+
else if (k === 'expression' || k === 'body') string(v, EVALUATE_SCRIPT_MAX);
|
|
197
|
+
else if (k === 'params') string(v, EVALUATE_PARAMS_MAX);
|
|
156
198
|
else if (['nthMatch', 'distance', 'maxChars', 'offset', 'timeout'].includes(k)) {
|
|
157
199
|
if (!Number.isSafeInteger(v) || v < 0 || v > 1000000) fail('INVALID_MESSAGE');
|
|
158
200
|
} else if (k === 'files') {
|
|
159
201
|
if (!Array.isArray(v) || v.length < 1 || v.length > 4) fail('INVALID_MESSAGE');
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
202
|
+
if (value.op !== 'upload') fail('INVALID_MESSAGE');
|
|
203
|
+
for (const name of v) {
|
|
204
|
+
string(name, 255);
|
|
205
|
+
if (!name || /[\\/]/.test(name)) fail('INVALID_MESSAGE');
|
|
163
206
|
}
|
|
164
207
|
} else string(v, k === 'text' || k === 'value' ? 100000 : 8192);
|
|
165
208
|
}
|
|
@@ -174,18 +217,50 @@ export function command(value) {
|
|
|
174
217
|
if (HISTORY.includes(value.op) && (value.tab === null || Object.keys(a).length)) fail('INVALID_MESSAGE');
|
|
175
218
|
if (a.direction !== undefined && !['up', 'down', 'left', 'right'].includes(a.direction)) fail('INVALID_MESSAGE');
|
|
176
219
|
if (a.state !== undefined && !['visible', 'hidden', 'attached', 'detached'].includes(a.state)) fail('INVALID_MESSAGE');
|
|
220
|
+
// evaluate: exactly one of `expression` (one JavaScript expression; a function it evaluates to is called with the
|
|
221
|
+
// arguments) and `body` (the body of an async function whose parameter `args` is the array of arguments), with
|
|
222
|
+
// `params` (the arguments: the JSON text of an array), `world`, `frame`, `timeout` and `maxChars`, and nothing else.
|
|
223
|
+
const evaluate = ['expression', 'body', 'params', 'world', 'frame'];
|
|
224
|
+
if (value.op === 'evaluate') {
|
|
225
|
+
if (value.tab === null || (typeof a.expression === 'string') === (typeof a.body === 'string') || !(a.expression ?? a.body).trim()) fail('INVALID_MESSAGE');
|
|
226
|
+
if (Object.keys(a).some(k => !evaluate.includes(k) && k !== 'timeout' && k !== 'maxChars')) fail('INVALID_MESSAGE');
|
|
227
|
+
if (a.world !== undefined && !EVALUATE_WORLDS.includes(a.world)) fail('INVALID_MESSAGE');
|
|
228
|
+
if (a.params !== undefined) {
|
|
229
|
+
let list; try { list = JSON.parse(a.params); } catch { list = null; }
|
|
230
|
+
if (!Array.isArray(list)) fail('INVALID_MESSAGE');
|
|
231
|
+
}
|
|
232
|
+
} else if (evaluate.some(k => a[k] !== undefined)) fail('INVALID_MESSAGE');
|
|
233
|
+
// A load-state wait names the state and, at most, its timeout: it waits for the tab, not for an element.
|
|
234
|
+
if (a.loadState !== undefined && (value.op !== 'wait' || value.tab === null || !LOAD_STATES.includes(a.loadState)
|
|
235
|
+
|| Object.keys(a).some(k => k !== 'loadState' && k !== 'timeout'))) fail('INVALID_MESSAGE');
|
|
177
236
|
return value;
|
|
178
237
|
}
|
|
179
238
|
export function payload(value) {
|
|
180
239
|
if (value?.type === 'state') { object(value, ['type', 'inventory']); inventory(value.inventory); }
|
|
181
240
|
else if (value?.type === 'result') {
|
|
182
241
|
object(value, ['type', 'id', 'result', 'inventory']); handle(value.id); inventory(value.inventory);
|
|
183
|
-
|
|
242
|
+
// evaluate adds `value` (the JSON text of the script's result), `truncated` with `valueLength` (the result was
|
|
243
|
+
// longer than its cap: `value` is then the beginning of that JSON text, not valid JSON) and, with code PAGE_ERROR,
|
|
244
|
+
// `errorMessage` and `errorStack` (what the page's script threw). A load-state wait adds `loadState`.
|
|
245
|
+
object(value.result, ['ok', 'code', 'error', 'url', 'title', 'snapshotText', 'mode', 'snapshotId', 'content', 'text', 'base64', 'mimeType', 'tab', 'downloadId', 'files',
|
|
246
|
+
'value', 'truncated', 'valueLength', 'errorMessage', 'errorStack', 'loadState']);
|
|
184
247
|
if (typeof value.result.ok !== 'boolean') fail('INVALID_MESSAGE');
|
|
185
248
|
for (const [k, v] of Object.entries(value.result)) {
|
|
186
249
|
if (k === 'ok') continue;
|
|
187
|
-
if (k === '
|
|
188
|
-
|
|
250
|
+
if (k === 'files') {
|
|
251
|
+
if (!Array.isArray(v) || !v.length || v.length > 4) fail('INVALID_MESSAGE');
|
|
252
|
+
let total = 0;
|
|
253
|
+
for (const file of v) {
|
|
254
|
+
object(file, ['name', 'type', 'size']);
|
|
255
|
+
if (!string(file.name, 255) || /[\\/]/.test(file.name) || !string(file.type, 255)) fail('INVALID_MESSAGE');
|
|
256
|
+
if (!Number.isSafeInteger(file.size) || file.size < 0) fail('INVALID_MESSAGE');
|
|
257
|
+
total += file.size;
|
|
258
|
+
}
|
|
259
|
+
if (total > MAX_FILE) fail('INVALID_MESSAGE');
|
|
260
|
+
} else if (k === 'downloadId') { if (!Number.isSafeInteger(v)) fail('INVALID_MESSAGE'); }
|
|
261
|
+
else if (k === 'valueLength') { if (!Number.isSafeInteger(v) || v < 0) fail('INVALID_MESSAGE'); }
|
|
262
|
+
else if (k === 'truncated') { if (typeof v !== 'boolean') fail('INVALID_MESSAGE'); }
|
|
263
|
+
else string(v, k === 'base64' ? MAX_MESSAGE - 4096 : ['content', 'text', 'snapshotText', 'value'].includes(k) ? EVALUATE_RESULT_MAX : 8192);
|
|
189
264
|
}
|
|
190
265
|
} else if (value?.type === 'ping' || value?.type === 'pong' || value?.type === 'unpair') object(value, ['type']);
|
|
191
266
|
// The server gave up on a command (its wait ended): the extension stops it, queued or running, and never starts it.
|
|
@@ -216,9 +291,25 @@ export const ERROR_TEXT = Object.freeze({
|
|
|
216
291
|
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
292
|
SCREENSHOT_PATH_REFUSED: 'The screenshot path is outside the allowed output locations or is protected.',
|
|
218
293
|
NO_MATCH: 'No element matches the target.', AMBIGUOUS_TARGET: 'The selector must match one element or specify nthMatch.',
|
|
219
|
-
|
|
294
|
+
UPLOAD_RELOAD_REQUIRED: 'Reload the updated SynaBun Browser Bridge extension to upload files.',
|
|
295
|
+
UPLOAD_FILE_MISSING: 'File not found in the extension upload folder.',
|
|
296
|
+
UPLOAD_TOO_LARGE: 'The selected files exceed the 50 MB total upload limit.',
|
|
297
|
+
UPLOAD_FILE_REFUSED: 'Choose readable regular files inside the extension upload folder shown in Settings → Browser.',
|
|
298
|
+
UPLOAD_MULTIPLE: 'This file input accepts only one file.',
|
|
299
|
+
UPLOAD_DISABLED: 'The file input is disabled.',
|
|
300
|
+
UPLOAD_ACCEPT_MISMATCH: 'The file input’s accept filter excludes one or more selected files. Check the accepted MIME types or filename extensions.',
|
|
301
|
+
UPLOAD_ASSIGNMENT_FAILED: 'The file input did not receive the expected names, types and sizes.',
|
|
302
|
+
UPLOAD_METADATA_UNAVAILABLE: 'Restart SynaBun and reload SynaBun Browser Bridge to enable file metadata.',
|
|
303
|
+
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
304
|
TIMEOUT: 'The operation timed out. Its outcome may be uncertain; observe before retrying.',
|
|
221
305
|
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.',
|
|
306
|
+
USER_SCRIPTS_DISABLED: 'Running page JavaScript is switched off for the SynaBun extension in this browser. The owner switches it on once: open chrome://extensions (edge://extensions in Edge), choose Details on "SynaBun Browser Bridge", turn on "Allow User Scripts" (Chrome or Edge 138 and later; on an older version turn on Developer mode at the top of that page instead), then press Reload on the extension. Nothing was run.',
|
|
307
|
+
USER_SCRIPTS_UNSUPPORTED: 'This browser cannot run page JavaScript for an extension (chrome.userScripts.execute needs Chrome or Edge 135 or later). Update the browser. Nothing was run.',
|
|
308
|
+
EXTENSION_RELOAD_REQUIRED: 'The paired browser still runs an older SynaBun Browser Bridge than this operation needs. The owner reloads it on the browser’s extensions page (chrome://extensions → SynaBun Browser Bridge → Reload). Nothing was done.',
|
|
309
|
+
PAGE_ERROR: 'The page’s script threw, or did not compile (evaluate takes one expression: wrap statements in a function, (() => { …; return value; })()). errorMessage and errorStack say what the page reported; the bridge itself did not fail.',
|
|
310
|
+
BLANK_PAGE: 'The tab shows the blank start page, where no script can run. Navigate it to an http(s) page first.',
|
|
311
|
+
FRAME_NOT_FOUND: 'The tab has no frame with this id that a script can run in (frame 0 is the top document). Nothing was run.',
|
|
312
|
+
NETWORK_IDLE_UNAVAILABLE: 'The extension cannot watch this browser’s network requests (its webRequest permission is not in effect). The owner reloads SynaBun Browser Bridge on the browser’s extensions page; until then wait for a selector or a fixed time instead.',
|
|
222
313
|
});
|
|
223
314
|
export function safeError(error) {
|
|
224
315
|
const code = Object.hasOwn(ERROR_TEXT, error?.code) ? error.code : 'OPERATION_FAILED';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { channel, command, CONTROL, equalMac, fail, hostPattern, localDeadline, mac, nonce, object, pairingKey, parse, payload, QUEUE_LIMIT, reserve, safeError } from './protocol.js';
|
|
1
|
+
import { channel, command, CONTROL, equalMac, fail, hostPattern, localDeadline, longOp, mac, nonce, object, pairingKey, parse, payload, QUEUE_LIMIT, reserve, safeError } from './protocol.js';
|
|
2
2
|
import { createEngine } from './engine.js';
|
|
3
3
|
import { badgeFor } from './popup-view.js';
|
|
4
4
|
import { popupLocale, translator } from './popup-strings.js';
|
|
@@ -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;
|
|
35
|
+
},
|
|
28
36
|
save: async value => {
|
|
29
37
|
const { tabs, ...prefs } = value;
|
|
30
38
|
await chrome.storage.session.set({ bridgeTabs: tabs });
|
|
@@ -83,7 +91,12 @@ const commands = new Map();
|
|
|
83
91
|
// and so is one whose turn comes later than `held.startBy` (one margin before its deadline). Once it starts, the timer
|
|
84
92
|
// is re-armed for the earlier of the deadline and QUEUE_LIMIT, the watchdog for a browser call that never returns;
|
|
85
93
|
// either way the queue moves on to the next command at once. The server's cancel calls the same `expire`.
|
|
94
|
+
// A long operation (protocol.js longOp: evaluate, a load-state wait) may run for a minute, far past the deadline of
|
|
95
|
+
// any command behind it, so it never takes a turn in the queue: it starts at once, beside the queue, under its own
|
|
96
|
+
// deadline alone (no QUEUE_LIMIT; its own timeout is its watchdog). One agent's slow script or a page that never
|
|
97
|
+
// goes idle therefore holds up nobody else's tab. The engine holds it to the same ticket and gates as any command.
|
|
86
98
|
function enqueue(ws, message, held) {
|
|
99
|
+
const long = longOp(message.op, message.args);
|
|
87
100
|
let timer, started = false, expire;
|
|
88
101
|
const limit = new Promise((_resolve, reject) => { expire = () => { held.stopped = true; reject(coded('TIMEOUT')); }; });
|
|
89
102
|
limit.catch(() => { if (!started) void answer(ws, message, limit).catch(() => {}); });
|
|
@@ -92,12 +105,15 @@ function enqueue(ws, message, held) {
|
|
|
92
105
|
const done = () => { clearTimeout(timer); if (commands.get(message.id) === expire) commands.delete(message.id); };
|
|
93
106
|
commands.set(message.id, expire);
|
|
94
107
|
arm(held.expires - engine.now());
|
|
95
|
-
|
|
108
|
+
const run = () => {
|
|
96
109
|
if (!held.stopped && engine.now() >= held.startBy) expire();
|
|
97
110
|
if (held.stopped) { done(); return; }
|
|
98
|
-
started = true; arm(Math.min(QUEUE_LIMIT, held.expires - engine.now()));
|
|
111
|
+
started = true; arm(long ? held.expires - engine.now() : Math.min(QUEUE_LIMIT, held.expires - engine.now()));
|
|
99
112
|
return answer(ws, message, Promise.race([engine.execute(message, held), limit]).finally(done));
|
|
100
|
-
}
|
|
113
|
+
};
|
|
114
|
+
// A command failure is an answer, never a transport revocation.
|
|
115
|
+
if (long) void Promise.resolve().then(run).catch(() => {});
|
|
116
|
+
else work = work.catch(() => {}).then(run).catch(() => {});
|
|
101
117
|
}
|
|
102
118
|
function schedule() {
|
|
103
119
|
clearTimeout(reconnectTimer);
|
|
@@ -14,10 +14,22 @@ 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
|
|
|
21
|
+
## Let agents run page scripts
|
|
22
|
+
|
|
23
|
+
`browser_evaluate` runs JavaScript in a tab the agent controls. `browser_wait` can also wait until a page has loaded or its network has gone quiet. Both need SynaBun Browser Bridge 1.4.0 or later and a one-time setup in the browser:
|
|
24
|
+
|
|
25
|
+
1. Open the browser's extensions page (`chrome://extensions`, or `edge://extensions` in Edge) and choose **Reload** on SynaBun Browser Bridge. Version 1.4.0 adds two permissions: `userScripts`, to run a script in a page, and `webRequest`, to see when a tab's requests start and end. The extension never blocks or changes a request and reads no request content.
|
|
26
|
+
2. Choose **Details** on the extension and turn on **Allow User Scripts**. In Chrome or Edge before version 138, turn on **Developer mode** at the top of the extensions page instead.
|
|
27
|
+
3. Choose **Reload** once more.
|
|
28
|
+
|
|
29
|
+
Page scripts stay off until you turn on **Allow User Scripts**. Every other tool works without it, and you can turn it off again at any time. A script runs only in a tab the agent controls, on a page the access mode allows, and never on SynaBun's own pages or the browser's pages. It can read what the page's own JavaScript can read, including form values and the site's storage, so leave the switch off if agents should not have that.
|
|
30
|
+
|
|
31
|
+
Automations that publish on X or pace their social posts are held to the same publish gate and spacing here as in SynaBun's other browsers.
|
|
32
|
+
|
|
21
33
|
## Troubleshooting
|
|
22
34
|
|
|
23
35
|
| Message | What to do |
|
|
@@ -28,12 +40,20 @@ Choose **Only sites and tabs I share** in **Settings → Browser → Agent acces
|
|
|
28
40
|
| `NAVIGATION_NOT_COMMITTED` | Check which page the tab shows before retrying. |
|
|
29
41
|
| `NO_HISTORY_ENTRY` | The tab has reached the end of its history in that direction. Navigate to the desired page directly. |
|
|
30
42
|
| `RESTRICTED_PAGE` or `SYNABUN_PAGE_BLOCKED` | Choose an ordinary website tab. Browser settings, extension pages and SynaBun's control interface are protected. |
|
|
43
|
+
| `USER_SCRIPTS_DISABLED` | Turn on **Allow User Scripts** in the extension's details, then reload the extension. See [Let agents run page scripts](#let-agents-run-page-scripts). |
|
|
44
|
+
| `USER_SCRIPTS_UNSUPPORTED` | Update Chrome or Edge to version 135 or later. |
|
|
45
|
+
| `EXTENSION_RELOAD_REQUIRED` | The browser still runs an older copy of the extension. Reload SynaBun Browser Bridge from the browser's extensions page. |
|
|
46
|
+
| `NETWORK_IDLE_UNAVAILABLE` | Reload the extension so its `webRequest` permission takes effect. Until then, wait for an element or for the `load` state. |
|
|
47
|
+
| `PAGE_ERROR` | The script itself failed on the page. Pass one JavaScript expression and wrap statements in a function: `(() => { …; return value; })()`. |
|
|
48
|
+
| `BLANK_PAGE` | Navigate the tab to a website before running a script. |
|
|
31
49
|
|
|
32
50
|
On sites such as Nexus, complete any site challenge yourself. Cloudflare acceptance depends on the site.
|
|
33
51
|
|
|
34
52
|
## Tool support
|
|
35
53
|
|
|
36
|
-
Page interactions operate on the top document. Some controls require manual input. If a tool returns `UNSUPPORTED_IN_EXTENSION_MODE`, consult its row below.
|
|
54
|
+
Page interactions operate on the top document. Upload selectors also search open shadow roots and same-origin frames. Some controls require manual input. If a tool returns `UNSUPPORTED_IN_EXTENSION_MODE`, consult its row below.
|
|
55
|
+
|
|
56
|
+
The site extractors and composer-state tools were built for SynaBun's own browser and stay listed as unsupported. Some of them read the page with a script, so they may answer in extension mode once **Allow User Scripts** is on. They have not been validated there.
|
|
37
57
|
|
|
38
58
|
| Tool | Status | Scope |
|
|
39
59
|
| --- | --- | --- |
|
|
@@ -42,7 +62,7 @@ Page interactions operate on the top document. Some controls require manual inpu
|
|
|
42
62
|
| browser_click | Partial | Works with standard controls in the top document. |
|
|
43
63
|
| browser_console | Unsupported | Unavailable in extension mode. |
|
|
44
64
|
| browser_content | Partial | Works with standard controls in the top document. |
|
|
45
|
-
| browser_evaluate |
|
|
65
|
+
| browser_evaluate | Partial | Runs one JavaScript expression in the controlled tab once **Allow User Scripts** is on. A script can run for up to 30 seconds and return up to 1,000,000 characters of JSON. |
|
|
46
66
|
| browser_extract_fb_groups | Unsupported | Unavailable in extension mode. |
|
|
47
67
|
| browser_extract_fb_posts | Unsupported | Unavailable in extension mode. |
|
|
48
68
|
| browser_extract_ig_feed | Unsupported | Unavailable in extension mode. |
|
|
@@ -79,6 +99,6 @@ Page interactions operate on the top document. Some controls require manual inpu
|
|
|
79
99
|
| browser_session | Supported | Lists, opens or claims tabs according to the current access mode. |
|
|
80
100
|
| browser_snapshot | Partial | Lists semantic elements in the top document. |
|
|
81
101
|
| browser_type | Partial | Works with standard controls in the top document. |
|
|
82
|
-
| browser_upload | Partial |
|
|
83
|
-
| browser_wait | Partial |
|
|
102
|
+
| browser_upload | Partial | Attaches up to four staged files, up to 50 MiB total. The input’s `accept` filter applies to every file. The result lists each selected file’s name, MIME type and byte size. Check the page for upload progress. |
|
|
103
|
+
| browser_wait | Partial | Waits for an element in the top document, a fixed time, or the `load` and `networkidle` page states. `domcontentloaded` is unavailable. |
|
|
84
104
|
| browser_x_compose_state | Unsupported | Unavailable in extension mode. |
|
|
@@ -0,0 +1,47 @@
|
|
|
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, { descend = null } = {}) {
|
|
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
|
+
// `descend(path)` false: a folder whose every file the caller leaves out is not read at all (a backup's walk
|
|
21
|
+
// used to list 108,000 files of working folders only to drop each of them).
|
|
22
|
+
if (stat.isDirectory() && (!descend || path === resolve(root) || descend(path))) {
|
|
23
|
+
try {
|
|
24
|
+
pending.push({ directory: path, names: readdirSync(path).sort().values() });
|
|
25
|
+
} catch (error) {
|
|
26
|
+
if (error.code !== 'ENOENT') throw error;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Hashes run synchronously on this thread. Reuse the scratch space across
|
|
33
|
+
// small files and read large databases without allocating their size.
|
|
34
|
+
const hashBuffer = Buffer.allocUnsafe(64 * 1024);
|
|
35
|
+
export function hashFileSync(path) {
|
|
36
|
+
const hash = createHash('sha256');
|
|
37
|
+
const fd = openSync(path, 'r');
|
|
38
|
+
try {
|
|
39
|
+
let bytes;
|
|
40
|
+
while ((bytes = readSync(fd, hashBuffer, 0, hashBuffer.length, null)) > 0) {
|
|
41
|
+
hash.update(hashBuffer.subarray(0, bytes));
|
|
42
|
+
}
|
|
43
|
+
return hash.digest('hex');
|
|
44
|
+
} finally {
|
|
45
|
+
closeSync(fd);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
import {
|
|
9
9
|
cpSync,
|
|
10
10
|
existsSync,
|
|
11
|
-
lstatSync,
|
|
12
11
|
mkdirSync,
|
|
13
12
|
readFileSync,
|
|
14
13
|
readdirSync,
|
|
@@ -18,8 +17,9 @@ import {
|
|
|
18
17
|
writeFileSync,
|
|
19
18
|
} from 'node:fs';
|
|
20
19
|
import { createHash } from 'node:crypto';
|
|
21
|
-
import { basename, dirname,
|
|
20
|
+
import { basename, dirname, relative, resolve } from 'node:path';
|
|
22
21
|
import { DatabaseSync } from 'node:sqlite';
|
|
22
|
+
import { hashFileSync, walkDataHomeTree } from './data-home-files.js';
|
|
23
23
|
|
|
24
24
|
export const DATA_HOME_MIGRATION_MARKER = '.synabun-data-home-migration.json';
|
|
25
25
|
export const DATA_HOME_MANIFEST = '.synabun-data-home.json';
|
|
@@ -42,10 +42,6 @@ function normalize(path) {
|
|
|
42
42
|
return path.replace(/\\/g, '/');
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
function hashFile(path) {
|
|
46
|
-
return createHash('sha256').update(readFileSync(path)).digest('hex');
|
|
47
|
-
}
|
|
48
|
-
|
|
49
45
|
function isRuntimeOnlyMigrationFile(relativePath) {
|
|
50
46
|
const normalized = normalize(relativePath);
|
|
51
47
|
const name = normalized.split('/').at(-1);
|
|
@@ -57,56 +53,29 @@ function isRuntimeOnlyMigrationFile(relativePath) {
|
|
|
57
53
|
|| /(?:^|\/)(?:restart-requested|opencode-managed\.pid)$/i.test(normalized);
|
|
58
54
|
}
|
|
59
55
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return { files, skipped };
|
|
71
|
-
}
|
|
72
|
-
if (!stat.isDirectory()) return { files, skipped };
|
|
73
|
-
for (const entry of readdirSync(current).sort()) {
|
|
74
|
-
walkFiles(root, join(current, entry), files, skipped);
|
|
56
|
+
// Iteration lets startup stop at the first durable file. Migration and doctor
|
|
57
|
+
// consume the same walk in full, including the symlinks they need to report.
|
|
58
|
+
function* walkMigrationFiles(root, items, skipped) {
|
|
59
|
+
for (const item of items) {
|
|
60
|
+
for (const { path, stat } of walkDataHomeTree(resolve(root, item))) {
|
|
61
|
+
if (stat.isDirectory()) continue;
|
|
62
|
+
const rel = normalize(relative(root, path));
|
|
63
|
+
if (stat.isSymbolicLink()) skipped?.push(rel);
|
|
64
|
+
else if (stat.isFile() && !isRuntimeOnlyMigrationFile(rel)) yield { absolute: path, relative: rel };
|
|
65
|
+
}
|
|
75
66
|
}
|
|
76
|
-
return { files, skipped };
|
|
77
67
|
}
|
|
78
68
|
|
|
79
69
|
function listMigrationFiles(root, items = DATA_HOME_MIGRATION_ITEMS) {
|
|
80
|
-
const files = [];
|
|
81
70
|
const skipped = [];
|
|
82
|
-
|
|
83
|
-
const itemPath = resolve(root, item);
|
|
84
|
-
if (!existsSync(itemPath)) continue;
|
|
85
|
-
const stat = lstatSync(itemPath);
|
|
86
|
-
if (stat.isSymbolicLink()) {
|
|
87
|
-
skipped.push(item);
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
if (stat.isFile()) {
|
|
91
|
-
if (!isRuntimeOnlyMigrationFile(item)) files.push({ absolute: itemPath, relative: item });
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
const walked = walkFiles(itemPath);
|
|
95
|
-
files.push(...walked.files
|
|
96
|
-
.map(file => ({
|
|
97
|
-
absolute: file.absolute,
|
|
98
|
-
relative: normalize(join(item, file.relative)),
|
|
99
|
-
}))
|
|
100
|
-
.filter(file => !isRuntimeOnlyMigrationFile(file.relative)));
|
|
101
|
-
skipped.push(...walked.skipped.map(path => normalize(join(item, path))));
|
|
102
|
-
}
|
|
71
|
+
const files = Array.from(walkMigrationFiles(root, items, skipped));
|
|
103
72
|
return { files, skipped };
|
|
104
73
|
}
|
|
105
74
|
|
|
106
75
|
function listingFingerprint(listing) {
|
|
107
76
|
const digest = createHash('sha256');
|
|
108
77
|
for (const file of [...listing.files].sort((a, b) => a.relative.localeCompare(b.relative))) {
|
|
109
|
-
digest.update(file.relative).update('\0').update(
|
|
78
|
+
digest.update(file.relative).update('\0').update(hashFileSync(file.absolute)).update('\n');
|
|
110
79
|
}
|
|
111
80
|
return `sha256:${digest.digest('hex')}`;
|
|
112
81
|
}
|
|
@@ -166,6 +135,10 @@ function inspectMemoryDatabase(path) {
|
|
|
166
135
|
export function inspectDataHome(root, items = DATA_HOME_MIGRATION_ITEMS) {
|
|
167
136
|
const resolvedRoot = resolve(root);
|
|
168
137
|
const listing = listMigrationFiles(resolvedRoot, items);
|
|
138
|
+
return summarizeDataHome(resolvedRoot, listing);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function summarizeDataHome(resolvedRoot, listing) {
|
|
169
142
|
let latestModifiedAt = null;
|
|
170
143
|
for (const file of listing.files) {
|
|
171
144
|
try {
|
|
@@ -215,7 +188,7 @@ export function inspectDataHome(root, items = DATA_HOME_MIGRATION_ITEMS) {
|
|
|
215
188
|
|
|
216
189
|
export function dataHomeHasState(root) {
|
|
217
190
|
if (!existsSync(root)) return false;
|
|
218
|
-
return
|
|
191
|
+
return !walkMigrationFiles(resolve(root), DATA_HOME_MIGRATION_ITEMS).next().done;
|
|
219
192
|
}
|
|
220
193
|
|
|
221
194
|
export function planDataHomeMigration({
|
|
@@ -237,20 +210,22 @@ export function planDataHomeMigration({
|
|
|
237
210
|
if (!targetPath) return { relative: file.relative, status: 'new' };
|
|
238
211
|
return {
|
|
239
212
|
relative: file.relative,
|
|
240
|
-
status:
|
|
213
|
+
status: hashFileSync(file.absolute) === hashFileSync(targetPath) ? 'same' : 'conflict',
|
|
241
214
|
};
|
|
242
215
|
});
|
|
243
216
|
const targetOnlyFiles = targetListing.files
|
|
244
217
|
.filter(file => !sourceByRelative.has(file.relative))
|
|
245
218
|
.map(file => file.relative);
|
|
246
|
-
const
|
|
247
|
-
const
|
|
219
|
+
const sourceSummary = summarizeDataHome(source, sourceListing);
|
|
220
|
+
const targetSummary = summarizeDataHome(target, targetListing);
|
|
221
|
+
const sourceFingerprint = sourceSummary.fingerprint;
|
|
222
|
+
const targetFingerprint = targetSummary.fingerprint;
|
|
248
223
|
|
|
249
224
|
return {
|
|
250
225
|
sourceRoot: source,
|
|
251
226
|
targetRoot: target,
|
|
252
|
-
sourceHasState:
|
|
253
|
-
targetHasState:
|
|
227
|
+
sourceHasState: sourceSummary.hasState,
|
|
228
|
+
targetHasState: targetSummary.hasState,
|
|
254
229
|
files,
|
|
255
230
|
newFiles: files.filter(file => file.status === 'new').length,
|
|
256
231
|
sameFiles: files.filter(file => file.status === 'same').length,
|
|
@@ -261,8 +236,8 @@ export function planDataHomeMigration({
|
|
|
261
236
|
identical: sourceListing.files.length === targetListing.files.length
|
|
262
237
|
&& sourceFingerprint === targetFingerprint,
|
|
263
238
|
skippedSymlinks: sourceListing.skipped,
|
|
264
|
-
sourceSummary
|
|
265
|
-
targetSummary
|
|
239
|
+
sourceSummary,
|
|
240
|
+
targetSummary,
|
|
266
241
|
};
|
|
267
242
|
}
|
|
268
243
|
|
|
@@ -277,17 +252,18 @@ function copyMigrationItems(source, target, items) {
|
|
|
277
252
|
}
|
|
278
253
|
|
|
279
254
|
function verifyCopiedFiles(source, target, items) {
|
|
280
|
-
const sourceListing = listMigrationFiles(source, items);
|
|
281
255
|
const digest = createHash('sha256');
|
|
282
|
-
|
|
256
|
+
let fileCount = 0;
|
|
257
|
+
for (const file of walkMigrationFiles(source, items)) {
|
|
283
258
|
const targetPath = resolve(target, file.relative);
|
|
284
259
|
if (!existsSync(targetPath)) throw new Error(`Migration verification failed: missing ${file.relative}`);
|
|
285
|
-
const sourceHash =
|
|
286
|
-
const targetHash =
|
|
260
|
+
const sourceHash = hashFileSync(file.absolute);
|
|
261
|
+
const targetHash = hashFileSync(targetPath);
|
|
287
262
|
if (sourceHash !== targetHash) throw new Error(`Migration verification failed: checksum mismatch for ${file.relative}`);
|
|
288
263
|
digest.update(file.relative).update('\0').update(targetHash).update('\n');
|
|
264
|
+
fileCount++;
|
|
289
265
|
}
|
|
290
|
-
return { fileCount
|
|
266
|
+
return { fileCount, digest: digest.digest('hex') };
|
|
291
267
|
}
|
|
292
268
|
|
|
293
269
|
/**
|