synabun 2.3.1 → 2.4.0
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 +24 -0
- package/README.md +1 -1
- package/browser-extension/content.js +169 -0
- package/browser-extension/engine.js +477 -0
- package/browser-extension/icons/icon-128.png +0 -0
- package/browser-extension/icons/icon-16.png +0 -0
- package/browser-extension/icons/icon-32.png +0 -0
- package/browser-extension/icons/icon-48.png +0 -0
- package/browser-extension/icons/status-off-16.png +0 -0
- package/browser-extension/icons/status-off-32.png +0 -0
- package/browser-extension/icons/status-off-48.png +0 -0
- package/browser-extension/icons/status-on-16.png +0 -0
- package/browser-extension/icons/status-on-32.png +0 -0
- package/browser-extension/icons/status-on-48.png +0 -0
- package/browser-extension/manifest.json +56 -0
- package/browser-extension/popup-strings.js +244 -0
- package/browser-extension/popup-view.js +151 -0
- package/browser-extension/popup.css +165 -0
- package/browser-extension/popup.html +105 -0
- package/browser-extension/popup.js +347 -0
- package/browser-extension/protocol.js +226 -0
- package/browser-extension/service-worker.js +267 -0
- package/browser-extension/setup-content.js +36 -0
- package/browser-extension/tokens.css +326 -0
- package/docs/browser-extension-bridge.md +84 -0
- package/docs/whatsapp.md +1 -1
- package/mcp-server/dist/http.d.ts +2 -0
- package/mcp-server/dist/http.d.ts.map +1 -1
- package/mcp-server/dist/http.js +9 -1
- package/mcp-server/dist/http.js.map +1 -1
- package/mcp-server/dist/index.d.ts +11 -0
- package/mcp-server/dist/index.d.ts.map +1 -1
- package/mcp-server/dist/index.js +38 -3
- package/mcp-server/dist/index.js.map +1 -1
- package/mcp-server/dist/services/browser-route-flow.d.ts +6 -2
- package/mcp-server/dist/services/browser-route-flow.d.ts.map +1 -1
- package/mcp-server/dist/services/browser-route-flow.js +10 -3
- package/mcp-server/dist/services/browser-route-flow.js.map +1 -1
- package/mcp-server/dist/services/codex-config-heal.d.ts.map +1 -1
- package/mcp-server/dist/services/codex-config-heal.js +7 -0
- package/mcp-server/dist/services/codex-config-heal.js.map +1 -1
- package/mcp-server/dist/services/neural-interface.d.ts +94 -3
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +168 -23
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/services/team-context.d.ts +18 -0
- package/mcp-server/dist/services/team-context.d.ts.map +1 -0
- package/mcp-server/dist/services/team-context.js +29 -0
- package/mcp-server/dist/services/team-context.js.map +1 -0
- package/mcp-server/dist/services/tool-catalog.d.ts +5 -2
- package/mcp-server/dist/services/tool-catalog.d.ts.map +1 -1
- package/mcp-server/dist/services/tool-catalog.js +22 -6
- package/mcp-server/dist/services/tool-catalog.js.map +1 -1
- package/mcp-server/dist/services/tool-list.d.ts.map +1 -1
- package/mcp-server/dist/services/tool-list.js +4 -0
- package/mcp-server/dist/services/tool-list.js.map +1 -1
- package/mcp-server/dist/services/tool-runtime.d.ts +8 -1
- package/mcp-server/dist/services/tool-runtime.d.ts.map +1 -1
- package/mcp-server/dist/services/tool-runtime.js +18 -1
- package/mcp-server/dist/services/tool-runtime.js.map +1 -1
- package/mcp-server/dist/tools/agent-definition.d.ts +133 -0
- package/mcp-server/dist/tools/agent-definition.d.ts.map +1 -0
- package/mcp-server/dist/tools/agent-definition.js +483 -0
- package/mcp-server/dist/tools/agent-definition.js.map +1 -0
- package/mcp-server/dist/tools/agents.d.ts +91 -9
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +161 -20
- package/mcp-server/dist/tools/agents.js.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts +8 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.js +70 -6
- package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
- package/mcp-server/dist/tools/git-tools.d.ts +4 -2
- package/mcp-server/dist/tools/git-tools.d.ts.map +1 -1
- package/mcp-server/dist/tools/git-tools.js +283 -2
- package/mcp-server/dist/tools/git-tools.js.map +1 -1
- package/mcp-server/dist/tools/morelogin.d.ts +8 -2
- package/mcp-server/dist/tools/morelogin.d.ts.map +1 -1
- package/mcp-server/dist/tools/morelogin.js +22 -5
- package/mcp-server/dist/tools/morelogin.js.map +1 -1
- package/mcp-server/dist/tools/team.d.ts +32 -0
- package/mcp-server/dist/tools/team.d.ts.map +1 -0
- package/mcp-server/dist/tools/team.js +87 -0
- package/mcp-server/dist/tools/team.js.map +1 -0
- package/mcp-server/package-lock.json +2 -2
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/http.ts +9 -1
- package/mcp-server/src/index.ts +34 -4
- package/mcp-server/src/services/browser-route-flow.ts +12 -5
- package/mcp-server/src/services/codex-config-heal.ts +7 -0
- package/mcp-server/src/services/neural-interface.ts +190 -29
- package/mcp-server/src/services/team-context.ts +27 -0
- package/mcp-server/src/services/tool-catalog.ts +26 -8
- package/mcp-server/src/services/tool-list.ts +4 -0
- package/mcp-server/src/services/tool-runtime.ts +21 -2
- package/mcp-server/src/tools/agent-definition.ts +458 -0
- package/mcp-server/src/tools/agents.ts +175 -19
- package/mcp-server/src/tools/browser-advanced.ts +60 -6
- package/mcp-server/src/tools/git-tools.ts +249 -3
- package/mcp-server/src/tools/morelogin.ts +20 -5
- package/mcp-server/src/tools/team.ts +97 -0
- package/neural-interface/i18n/en.json +1117 -47
- package/neural-interface/i18n/pt-BR.json +1117 -47
- package/neural-interface/lib/account-usage.js +1 -1
- package/neural-interface/lib/agents/density.js +101 -0
- package/neural-interface/lib/agents/forge-host.js +223 -0
- package/neural-interface/lib/agents/native-export-targets.js +190 -0
- package/neural-interface/lib/agents/native-export.js +365 -0
- package/neural-interface/lib/agents/registry.js +840 -0
- package/neural-interface/lib/agents/resolve.js +544 -0
- package/neural-interface/lib/agents/schema.js +642 -0
- package/neural-interface/lib/agents/split.js +37 -0
- package/neural-interface/lib/agents-studio-api.js +591 -0
- package/neural-interface/lib/assistant-api.js +76 -7
- package/neural-interface/lib/assistant-catalog.js +2 -0
- package/neural-interface/lib/assistant-continuity.js +49 -0
- package/neural-interface/lib/assistant-dispatch.js +229 -102
- package/neural-interface/lib/assistant-persona.js +105 -8
- package/neural-interface/lib/assistant-route-gate.js +24 -9
- package/neural-interface/lib/assistant-router.js +384 -42
- package/neural-interface/lib/assistant-run-tail.js +151 -0
- package/neural-interface/lib/assistant-run-wait.js +183 -0
- package/neural-interface/lib/assistant-runtime.js +440 -93
- package/neural-interface/lib/assistant-task-prompt.js +11 -2
- package/neural-interface/lib/assistant-usage.js +3 -2
- package/neural-interface/lib/automation-approval.js +2 -2
- package/neural-interface/lib/browser-close-evidence.js +80 -0
- package/neural-interface/lib/browser-default.js +210 -0
- package/neural-interface/lib/browser-extension-adapter.js +255 -0
- package/neural-interface/lib/browser-extension-bridge.js +418 -0
- package/neural-interface/lib/browser-extension-folder.js +116 -0
- package/neural-interface/lib/browser-extension-setup.js +140 -0
- package/neural-interface/lib/browser-profile-choices.js +3 -3
- package/neural-interface/lib/browser-tool-policy.js +1 -1
- package/neural-interface/lib/claude-account-links.js +301 -0
- package/neural-interface/lib/claude-accounts.js +45 -20
- package/neural-interface/lib/claude-agent-bridge.js +142 -10
- package/neural-interface/lib/claude-model-catalog.js +6 -0
- package/neural-interface/lib/claude-panel-session.js +33 -0
- package/neural-interface/lib/codex-accounts.js +67 -24
- package/neural-interface/lib/coordination/README.md +384 -0
- package/neural-interface/lib/coordination/service.js +563 -0
- package/neural-interface/lib/coordination/store.js +1138 -0
- package/neural-interface/lib/db.js +22 -1
- package/neural-interface/lib/effort-levels.js +10 -1
- package/neural-interface/lib/memory-list-page.js +49 -0
- package/neural-interface/lib/memory-list-stamp.js +60 -0
- package/neural-interface/lib/morelogin-outside-close.js +186 -0
- package/neural-interface/lib/morelogin-profile-failures.js +206 -0
- package/neural-interface/lib/morelogin-start-cooldown.js +160 -0
- package/neural-interface/lib/morelogin.js +194 -8
- package/neural-interface/lib/native-loop-runtime.js +20 -0
- package/neural-interface/lib/opencode-build-preflight.js +16 -1
- package/neural-interface/lib/opencode-native-boundary.js +83 -13
- package/neural-interface/lib/opencode-serve-records.js +14 -9
- package/neural-interface/lib/page-session.js +1 -1
- package/neural-interface/lib/peer-identity.js +60 -21
- package/neural-interface/lib/process-identity.js +68 -7
- package/neural-interface/lib/request-gate.js +3 -0
- package/neural-interface/lib/screenshot-location.js +33 -0
- package/neural-interface/lib/skills/creation.js +1 -1
- package/neural-interface/lib/skills/known-bridge-digests.json +40 -0
- package/neural-interface/lib/studio-attention.js +56 -0
- package/neural-interface/lib/teams/README.md +382 -0
- package/neural-interface/lib/teams/api.js +287 -0
- package/neural-interface/lib/teams/brief.js +185 -0
- package/neural-interface/lib/teams/claims.js +315 -0
- package/neural-interface/lib/teams/git.js +293 -0
- package/neural-interface/lib/teams/index.js +122 -0
- package/neural-interface/lib/teams/integration.js +580 -0
- package/neural-interface/lib/teams/landing.js +184 -0
- package/neural-interface/lib/teams/recovery.js +256 -0
- package/neural-interface/lib/teams/scheduler.js +1474 -0
- package/neural-interface/lib/teams/schema.js +559 -0
- package/neural-interface/lib/teams/state.js +181 -0
- package/neural-interface/lib/teams/test-runner.js +86 -0
- package/neural-interface/lib/teams/test-sandbox.js +99 -0
- package/neural-interface/lib/teams/worktrees.js +757 -0
- package/neural-interface/lib/tool-permission-choices.js +226 -0
- package/neural-interface/lib/whatsapp/cards.js +24 -10
- package/neural-interface/lib/worker-confinement.js +206 -6
- package/neural-interface/package-lock.json +2 -2
- package/neural-interface/package.json +1 -1
- package/neural-interface/public/extension-setup.html +107 -0
- package/neural-interface/public/index.html +52 -12
- package/neural-interface/public/shared/agent-runtime-options.js +3 -1
- package/neural-interface/public/shared/agents/studio/ax-agent-view.js +614 -0
- package/neural-interface/public/shared/agents/studio/ax-api.js +198 -0
- package/neural-interface/public/shared/agents/studio/ax-create-view.js +221 -0
- package/neural-interface/public/shared/agents/studio/ax-diff.js +143 -0
- package/neural-interface/public/shared/agents/studio/ax-editor-view.js +392 -0
- package/neural-interface/public/shared/agents/studio/ax-export-view.js +94 -0
- package/neural-interface/public/shared/agents/studio/ax-form.js +191 -0
- package/neural-interface/public/shared/agents/studio/ax-icons.js +87 -0
- package/neural-interface/public/shared/agents/studio/ax-library-view.js +158 -0
- package/neural-interface/public/shared/agents/studio/ax-library.js +162 -0
- package/neural-interface/public/shared/agents/studio/ax-main.js +712 -0
- package/neural-interface/public/shared/agents/studio/ax-native-export.js +35 -0
- package/neural-interface/public/shared/agents/studio/ax-options.js +198 -0
- package/neural-interface/public/shared/agents/studio/ax-review-view.js +175 -0
- package/neural-interface/public/shared/agents/studio/ax-revisions-view.js +189 -0
- package/neural-interface/public/shared/agents/studio/ax-runs-view.js +202 -0
- package/neural-interface/public/shared/agents/studio/ax-runs.js +82 -0
- package/neural-interface/public/shared/agents/studio/ax-teams-view.js +256 -0
- package/neural-interface/public/shared/agents/studio/ax-teams.js +200 -0
- package/neural-interface/public/shared/agents/studio/ax-templates.js +50 -0
- package/neural-interface/public/shared/agents/studio/ax-ui.js +194 -0
- package/neural-interface/public/shared/agents/studio/ax-views.js +170 -0
- package/neural-interface/public/shared/agy/agy-panel.js +142 -28
- package/neural-interface/public/shared/agy/agy-styles.js +25 -5
- package/neural-interface/public/shared/assistant/asst-account-menu.js +13 -13
- package/neural-interface/public/shared/assistant/asst-ask-styles.js +2 -3
- package/neural-interface/public/shared/assistant/asst-brain-picker.js +91 -9
- package/neural-interface/public/shared/assistant/asst-control.js +3 -0
- package/neural-interface/public/shared/assistant/asst-interaction-hold.js +99 -0
- package/neural-interface/public/shared/assistant/asst-limit-dismissals.js +111 -0
- package/neural-interface/public/shared/assistant/asst-limit-dock.js +37 -3
- package/neural-interface/public/shared/assistant/asst-limit-wait.js +30 -7
- package/neural-interface/public/shared/assistant/asst-panel.js +177 -30
- package/neural-interface/public/shared/assistant/asst-rack-styles.js +15 -8
- package/neural-interface/public/shared/assistant/asst-render.js +36 -6
- package/neural-interface/public/shared/assistant/asst-route.js +78 -12
- package/neural-interface/public/shared/assistant/asst-routes-editor.js +148 -70
- package/neural-interface/public/shared/assistant/asst-roving.js +17 -1
- package/neural-interface/public/shared/assistant/asst-scene-styles.js +7 -2
- package/neural-interface/public/shared/assistant/asst-scenes.js +12 -1
- package/neural-interface/public/shared/assistant/asst-sidepanel.js +12 -2
- package/neural-interface/public/shared/assistant/asst-state.js +66 -1
- package/neural-interface/public/shared/assistant/asst-styles.js +98 -44
- package/neural-interface/public/shared/assistant/route-identity.js +16 -0
- package/neural-interface/public/shared/cdx/cdx-output.js +10 -0
- package/neural-interface/public/shared/cdx/cdx-panel.js +18 -16
- package/neural-interface/public/shared/cdx/cdx-plan.js +3 -2
- package/neural-interface/public/shared/cdx/cdx-render.js +122 -45
- package/neural-interface/public/shared/cdx/cdx-requests.js +4 -4
- package/neural-interface/public/shared/cdx/cdx-styles.js +8 -36
- package/neural-interface/public/shared/cdx/cdx-tabs.js +110 -42
- package/neural-interface/public/shared/claude-panel-lazy.js +12 -0
- package/neural-interface/public/shared/code-copy.js +120 -0
- package/neural-interface/public/shared/constants.js +7 -0
- package/neural-interface/public/shared/context-menu-model.js +1 -0
- package/neural-interface/public/shared/cp/cp-markdown.js +7 -2
- package/neural-interface/public/shared/cp/cp-session-model.js +86 -5
- package/neural-interface/public/shared/cp/cp-session-settings.js +58 -30
- package/neural-interface/public/shared/cp/cp-styles.js +9 -0
- package/neural-interface/public/shared/dom-change-flag.js +66 -0
- package/neural-interface/public/shared/dom-morph.js +124 -0
- package/neural-interface/public/shared/extension-setup/es-page.css +134 -0
- package/neural-interface/public/shared/extension-setup/es-page.js +120 -0
- package/neural-interface/public/shared/extension-setup/es-view.js +100 -0
- package/neural-interface/public/shared/html-shell.js +33 -4
- package/neural-interface/public/shared/i18n.js +14 -1
- package/neural-interface/public/shared/idle-queue.js +78 -0
- package/neural-interface/public/shared/iface-config.js +227 -0
- package/neural-interface/public/shared/lazy-module.js +108 -0
- package/neural-interface/public/shared/memory-list.js +117 -0
- package/neural-interface/public/shared/morelogin-profile-choices.js +1 -1
- package/neural-interface/public/shared/morelogin-profile-field.js +3 -3
- package/neural-interface/public/shared/mtc/mtc-panel.js +3 -1
- package/neural-interface/public/shared/mtc/mtc-styles.js +4 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-manager.js +35 -15
- package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +77 -23
- package/neural-interface/public/shared/ocp-v2/ocp-v2-projectbar.js +3 -6
- package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +24 -21
- package/neural-interface/public/shared/ocp-v2/ocp-v2-send-logic.js +16 -5
- package/neural-interface/public/shared/ocp-v2/ocp-v2-sessions-logic.js +16 -2
- package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +27 -43
- package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +73 -9
- package/neural-interface/public/shared/schedules-view.js +2 -2
- package/neural-interface/public/shared/session-project-items.js +11 -0
- package/neural-interface/public/shared/settings/settings-ai-browser.js +119 -0
- package/neural-interface/public/shared/settings/settings-browser-extension.js +446 -0
- package/neural-interface/public/shared/settings/settings-ia.js +4 -2
- package/neural-interface/public/shared/settings/settings-morelogin-cooldown.js +63 -0
- package/neural-interface/public/shared/settings/settings-tool-permissions.js +70 -0
- package/neural-interface/public/shared/sidepanel-lazy.js +40 -0
- package/neural-interface/public/shared/sidepanel-session-status.js +8 -14
- package/neural-interface/public/shared/sidepanel-shown.js +73 -0
- package/neural-interface/public/shared/storage.js +6 -1
- package/neural-interface/public/shared/studio-attention.js +83 -0
- package/neural-interface/public/shared/styles.css +682 -50
- package/neural-interface/public/shared/term-browser-tabs.js +34 -0
- package/neural-interface/public/shared/transcript-rows.js +334 -0
- package/neural-interface/public/shared/tray-auto-close.js +106 -0
- package/neural-interface/public/shared/ui-agents.js +97 -0
- package/neural-interface/public/shared/ui-antigravity-panel.js +16 -14
- package/neural-interface/public/shared/ui-automation-studio.js +3 -3
- package/neural-interface/public/shared/ui-claude-panel.js +162 -95
- package/neural-interface/public/shared/ui-code-copy.js +256 -0
- package/neural-interface/public/shared/ui-codex-panel.js +14 -10
- package/neural-interface/public/shared/ui-context-menu.js +1 -1
- package/neural-interface/public/shared/ui-file-explorer.js +2 -3
- package/neural-interface/public/shared/ui-games.js +1 -1
- package/neural-interface/public/shared/ui-loading.js +12 -1
- package/neural-interface/public/shared/ui-maritaca-panel.js +12 -11
- package/neural-interface/public/shared/ui-menubar.js +23 -0
- package/neural-interface/public/shared/ui-native-loop-router.js +1 -1
- package/neural-interface/public/shared/ui-navbar.js +15 -9
- package/neural-interface/public/shared/ui-opencode-panel-v2.js +13 -11
- package/neural-interface/public/shared/ui-schedules-studio.js +3 -3
- package/neural-interface/public/shared/ui-scroll-follow.js +39 -0
- package/neural-interface/public/shared/ui-sessions.js +3 -3
- package/neural-interface/public/shared/ui-settings-entry.js +55 -0
- package/neural-interface/public/shared/ui-settings.js +355 -400
- package/neural-interface/public/shared/ui-sidepanel-layout.js +44 -25
- package/neural-interface/public/shared/ui-sidepanel-session-entry.js +22 -9
- package/neural-interface/public/shared/ui-sidepanel-sessions.js +10 -2
- package/neural-interface/public/shared/ui-sidepanel-tray.js +36 -41
- package/neural-interface/public/shared/ui-sidepanel-windows.js +14 -1
- package/neural-interface/public/shared/ui-styleguide.js +10 -2
- package/neural-interface/public/shared/ui-sync.js +5 -0
- package/neural-interface/public/shared/ui-terminal.js +13 -9
- package/neural-interface/public/shared/ui-tooltip.js +28 -7
- package/neural-interface/public/shared/ui-topright-overflow.js +26 -4
- package/neural-interface/public/shared/ui-tray-columns.js +375 -0
- package/neural-interface/public/shared/ui-whiteboard.js +51 -6
- package/neural-interface/public/shared/ui-worker-end.js +28 -1
- package/neural-interface/public/shared/ui-workspaces.js +13 -0
- package/neural-interface/public/shared/window-keys.js +71 -0
- package/neural-interface/public/variant/2d/main.js +2 -0
- package/neural-interface/public/variant/3d/app.js +620 -0
- package/neural-interface/public/variant/3d/boot-reveal.js +47 -0
- package/neural-interface/public/variant/3d/main.js +21 -544
- package/neural-interface/public/variant/3d/map-controls.js +4 -2
- package/neural-interface/public/vendor/fonts/fonts.css +508 -0
- package/neural-interface/public/vendor/fonts/inter-OFL.txt +93 -0
- package/neural-interface/public/vendor/fonts/inter-cyrillic-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-cyrillic.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-greek-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-greek.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-latin-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-latin.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/inter-vietnamese.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-OFL.txt +93 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-cyrillic-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-cyrillic.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-greek.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-latin.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/jetbrains-mono-vietnamese.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/manifest.json +142 -0
- package/neural-interface/public/vendor/fonts/space-grotesk-OFL.txt +93 -0
- package/neural-interface/public/vendor/fonts/space-grotesk-latin-ext.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/space-grotesk-latin.woff2 +0 -0
- package/neural-interface/public/vendor/fonts/space-grotesk-vietnamese.woff2 +0 -0
- package/neural-interface/scripts/boot-graph.mjs +270 -0
- package/neural-interface/scripts/vendor-fonts.mjs +124 -0
- package/neural-interface/server.js +1050 -140
- package/npm-shrinkwrap.json +2 -2
- package/package.json +3 -1
- package/skills/agent-forge/SKILL.md +182 -0
- package/skills/agent-forge/evals/evals.json +56 -0
- package/skills/agent-forge/references/definition-fields.md +61 -0
- package/skills/agent-forge/references/examples.md +105 -0
- package/skills/agent-forge/references/instructions.md +51 -0
- package/skills/agent-forge/references/review-and-export.md +84 -0
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
import { anyOrigin, command, CONTROL, controlSurface, fail, HISTORY, inventory, hostPattern, localDeadline, MAX_TABS, nonce, publicOrigin, safeError } from './protocol.js';
|
|
2
|
+
|
|
3
|
+
/** Pure controller over an injected chrome API; no socket or storage credential access. */
|
|
4
|
+
// `now` is a monotonic clock (milliseconds) for command deadlines; `wallClock` the system clock the content script shares.
|
|
5
|
+
// `fullControlDefault` is the mode before the owner ever chose one (full control: agents may use any http(s) site and
|
|
6
|
+
// 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 } = {}) {
|
|
10
|
+
// `epoch` moves only on the owner's revocations and pairing changes, and cancels every tab's work. A tab's own
|
|
11
|
+
// navigation, update or close moves that tab's counter in `moves` (by Chrome tab id) and nothing else: one agent's
|
|
12
|
+
// ordinary navigation never cancels another agent's work on another tab. `focus` moves when the active tab changes;
|
|
13
|
+
// only a screenshot, which captures whatever tab is active, is held to it.
|
|
14
|
+
let tabs = new Map(), sites = [], allowNewTabs = false, uploads = false, downloads = false, epoch = 0, focus = 0;
|
|
15
|
+
// The mode and its version. Only the owner changes it: the popup (setMode) or the server's `mode` control message,
|
|
16
|
+
// whose version must be newer. Switching to restricted is a revocation; switching to full control widens only.
|
|
17
|
+
// In full control `tabs` also holds a record for every other tab of the browser (`listed`), so agents can see and
|
|
18
|
+
// take over the owner's tabs; restricted mode keeps only shared and agent-created ones.
|
|
19
|
+
let fullControl = fullControlDefault === true, modeVersion = 0;
|
|
20
|
+
const clip = value => String(value || '').slice(0, 300);
|
|
21
|
+
// The page a tab shows. Chrome reports `url` as '' until a tab's first navigation commits (a tab tabs.create just
|
|
22
|
+
// opened, briefly): that tab shows its initial empty document, which is about:blank, and its pendingUrl is about:blank
|
|
23
|
+
// (or nothing). A tab whose first page is still pending elsewhere is held to that pending URL (a browser page stays
|
|
24
|
+
// RESTRICTED_PAGE, SynaBun's own stays blocked). Reading '' as a page made every command on a just-created tab fail
|
|
25
|
+
// with RESTRICTED_PAGE before its first navigation committed.
|
|
26
|
+
const shownUrl = tab => String(tab?.url || (!tab?.pendingUrl || tab.pendingUrl === 'about:blank' ? 'about:blank' : tab.pendingUrl));
|
|
27
|
+
// Only approved tabs are counted, and a closed tab's counter goes (its commands then fail TAB_CLOSED).
|
|
28
|
+
const moves = new Map(), moved = id => moves.get(id) || 0;
|
|
29
|
+
const move = id => { if ([...tabs.values()].some(t => t.id === id)) moves.set(id, moved(id) + 1); };
|
|
30
|
+
let lastCapture = 0;
|
|
31
|
+
// Owner approval version per origin. Only share() raises it (the popup's owner gesture); nothing an agent asks for does.
|
|
32
|
+
// Versions of sites no longer approved are kept (a re-share continues from them) up to RETIRED_VERSIONS, oldest
|
|
33
|
+
// dropped first; a dropped one is harmless because share() never goes below the clock.
|
|
34
|
+
let versions = new Map();
|
|
35
|
+
const RETIRED_VERSIONS = 100;
|
|
36
|
+
const pruneVersions = () => {
|
|
37
|
+
const retired = [...versions].filter(([site]) => !sites.includes(site)).sort((a, b) => a[1] - b[1]);
|
|
38
|
+
for (const [site] of retired.slice(0, Math.max(0, retired.length - RETIRED_VERSIONS))) versions.delete(site);
|
|
39
|
+
};
|
|
40
|
+
// Generations a command is held to. `approval` moves, synchronously, on every owner revocation (a tab, a site, an
|
|
41
|
+
// option switched off, a host permission removed, pairing); `connection` when the connection a command came on ends.
|
|
42
|
+
// A command records both when it arrives (ticket()) and is refused, before any further chrome.* or page effect, once
|
|
43
|
+
// either has moved: a queued command never starts, a running one stops at its next effect boundary.
|
|
44
|
+
let approval = 0, connection = 0;
|
|
45
|
+
const ticket = () => Object.freeze({ approval, connection });
|
|
46
|
+
// A caller may also stop a ticket it holds (`stopped`), e.g. the worker's queue giving up on a command that hangs.
|
|
47
|
+
const valid = given => given.approval === approval && given.connection === connection && given.stopped !== true;
|
|
48
|
+
// What the server is told: the tabs agents hold first, then the rest, up to MAX_TABS.
|
|
49
|
+
const current = () => {
|
|
50
|
+
const all = [...tabs.values()].filter(t => { if (t.owner || !fullControl) return true; try { anyOrigin(t.url); return true; } catch { return false; } }), listed = [...all.filter(t => t.owner), ...all.filter(t => !t.owner)].slice(0, MAX_TABS);
|
|
51
|
+
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 });
|
|
53
|
+
};
|
|
54
|
+
const persist = async () => { await save({ tabs: [...tabs.values()], sites, versions: [...versions], allowNewTabs, uploads, downloads, fullControl, modeVersion }); changed(current()); };
|
|
55
|
+
async function live(t) {
|
|
56
|
+
try { const tab = await chrome.tabs.get(t.id); t.url = shownUrl(tab); t.title = clip(tab.title); return tab; }
|
|
57
|
+
catch { move(t.id); tabs.delete(t.handle); moves.delete(t.id); await persist(); fail('TAB_CLOSED'); }
|
|
58
|
+
}
|
|
59
|
+
// Restricted mode: an approved site, with its host permission.
|
|
60
|
+
async function permitted(url) {
|
|
61
|
+
const origin = publicOrigin(url);
|
|
62
|
+
if (!sites.includes(origin) || !await chrome.permissions.contains({ origins: [hostPattern(origin)] })) fail('SITE_NOT_APPROVED');
|
|
63
|
+
return origin;
|
|
64
|
+
}
|
|
65
|
+
// Full control: any http(s) page or the blank page; never a page no extension may touch, nor SynaBun's own.
|
|
66
|
+
function open(url, blocked) {
|
|
67
|
+
anyOrigin(url);
|
|
68
|
+
if (controlSurface(url, blocked)) fail('SYNABUN_PAGE_BLOCKED');
|
|
69
|
+
}
|
|
70
|
+
// The destination rule of the mode in force.
|
|
71
|
+
async function destination(url, blocked) { if (fullControl) open(url, blocked); else await permitted(url); }
|
|
72
|
+
// Full control: one record per tab of the browser. A tab already known keeps its handle and owner; a new one is
|
|
73
|
+
// listed with no owner; a tab gone is forgotten (its counter too, so its commands fail TAB_CLOSED).
|
|
74
|
+
async function enumerate() {
|
|
75
|
+
if (!fullControl) return;
|
|
76
|
+
const before = new Map([...tabs.values()].map(t => [t.id, { t, move: moved(t.id), url: t.url, title: t.title }]));
|
|
77
|
+
let present; try { present = await chrome.tabs.query({ windowType: 'normal' }); } catch { return; }
|
|
78
|
+
if (!fullControl) return;
|
|
79
|
+
const byId = new Map([...tabs.values()].map(t => [t.id, t])), seen = new Set();
|
|
80
|
+
for (const tab of present) {
|
|
81
|
+
if (!Number.isSafeInteger(tab?.id) || tab.id < 0) continue;
|
|
82
|
+
seen.add(tab.id);
|
|
83
|
+
const known = byId.get(tab.id), url = shownUrl(tab).slice(0, 8192);
|
|
84
|
+
const previous = before.get(tab.id);
|
|
85
|
+
if (known) {
|
|
86
|
+
if (previous?.t === known && previous.move === moved(tab.id)) {
|
|
87
|
+
if (known.url === previous.url) known.url = url || known.url;
|
|
88
|
+
if (known.title === previous.title) known.title = clip(tab.title);
|
|
89
|
+
}
|
|
90
|
+
} else if (previous) continue; // Removed while this query was pending: never resurrect its stale snapshot.
|
|
91
|
+
else { const t = { handle: nonce(), id: tab.id, url, title: clip(tab.title), owner: null, created: false, listed: true }; tabs.set(t.handle, t); }
|
|
92
|
+
}
|
|
93
|
+
for (const t of [...tabs.values()]) if (!seen.has(t.id) && before.get(t.id)?.t === t) { tabs.delete(t.handle); moves.delete(t.id); }
|
|
94
|
+
}
|
|
95
|
+
async function authorized(op, tab, owner, args, blocked = {}) {
|
|
96
|
+
if (CONTROL.includes(op)) { if (owner !== 'owner') fail('NOT_OWNED'); return null; }
|
|
97
|
+
if (op === 'create') { if (!fullControl && !allowNewTabs) fail('PERMISSION_REQUIRED'); return null; }
|
|
98
|
+
const t = tabs.get(tab); if (!t) fail('TAB_CLOSED');
|
|
99
|
+
if (op === 'claim') {
|
|
100
|
+
if (!t.owner && [...tabs.values()].filter(v => v.owner).length >= MAX_TABS) fail('TAB_LIMIT');
|
|
101
|
+
if (t.owner && t.owner !== owner) fail('NOT_OWNED'); await live(t);
|
|
102
|
+
// A tab on a page no agent may use is not taken over.
|
|
103
|
+
if (fullControl) open(t.url, blocked);
|
|
104
|
+
return t;
|
|
105
|
+
}
|
|
106
|
+
if (t.owner !== owner) fail('NOT_OWNED');
|
|
107
|
+
if (op === 'release') return t;
|
|
108
|
+
await live(t);
|
|
109
|
+
if (fullControl) open(t.url, blocked);
|
|
110
|
+
else if (t.url !== 'about:blank') await permitted(t.url); else if (op !== 'navigate' && !HISTORY.includes(op)) fail('SITE_NOT_APPROVED');
|
|
111
|
+
if (args.url) await destination(args.url, blocked);
|
|
112
|
+
if (op === 'upload' && !uploads && !fullControl || op === 'download' && !downloads) fail('PERMISSION_REQUIRED');
|
|
113
|
+
return t;
|
|
114
|
+
}
|
|
115
|
+
// The owner's mode change, from the popup or the server. An older version never applies. Switching to restricted
|
|
116
|
+
// is a revocation, synchronously, before anything is awaited: every command in flight is stopped and the tabs that
|
|
117
|
+
// were listed only because of full control are forgotten (their agents lose them; the tabs stay open).
|
|
118
|
+
function applyMode(full, version) {
|
|
119
|
+
if (!Number.isSafeInteger(version) || version < modeVersion) return false;
|
|
120
|
+
if (full === fullControl) { modeVersion = version; return false; }
|
|
121
|
+
if (!full) {
|
|
122
|
+
approval++; epoch++;
|
|
123
|
+
for (const t of [...tabs.values()]) if (t.listed && !t.created) { tabs.delete(t.handle); moves.delete(t.id); }
|
|
124
|
+
}
|
|
125
|
+
fullControl = full; modeVersion = version; return true;
|
|
126
|
+
}
|
|
127
|
+
// chrome.tabs.goBack/goForward answer once the traversal starts, not when it lands: wait for the tab to commit.
|
|
128
|
+
// A cross-document entry changes the URL or shows a load; a same-document entry with the same URL shows neither.
|
|
129
|
+
// `landing(url)` refuses an unapproved destination. It runs on every reading whose committed or pending URL differs
|
|
130
|
+
// from the start, so an unapproved destination is refused as soon as the tab shows it, without waiting for its load.
|
|
131
|
+
async function traverse(t, op, act, guard, landing) {
|
|
132
|
+
const before = await live(t);
|
|
133
|
+
// act() refuses a stale command before the step; only the browser's own refusal reaches the catch below.
|
|
134
|
+
const step = act(() => chrome.tabs[op === 'back' ? 'goBack' : 'goForward'](t.id));
|
|
135
|
+
try { await step; }
|
|
136
|
+
catch (error) {
|
|
137
|
+
await live(t); guard();
|
|
138
|
+
if (/cannot find a (next|previous) page in history/i.test(String(error?.message || ''))) fail('NO_HISTORY_ENTRY');
|
|
139
|
+
fail('OPERATION_FAILED');
|
|
140
|
+
}
|
|
141
|
+
t.nav = nonce();
|
|
142
|
+
const start = Date.now(); let loading = false;
|
|
143
|
+
for (;;) {
|
|
144
|
+
const seen = await live(t); guard();
|
|
145
|
+
for (const url of [seen.url, seen.pendingUrl]) if (url && url !== before.url) { await landing(url); guard(); }
|
|
146
|
+
const moved = seen.url !== before.url;
|
|
147
|
+
if (seen.status === 'loading') loading = true;
|
|
148
|
+
else if (moved || loading || Date.now() - start >= quietMs) return seen;
|
|
149
|
+
if (Date.now() - start >= settleMs) { if (moved) return seen; fail('TIMEOUT'); }
|
|
150
|
+
await new Promise(resolve => setTimeout(resolve, pollMs));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async function settled(t, guard, landing) {
|
|
154
|
+
const start = Date.now(); let last = '', stableSince = start;
|
|
155
|
+
for (;;) {
|
|
156
|
+
const reading = await live(t); guard();
|
|
157
|
+
for (const url of [reading.url, reading.pendingUrl]) if (url) { await landing(url); guard(); }
|
|
158
|
+
const signature = `${reading.url}\n${reading.title || ''}\n${reading.status || ''}`;
|
|
159
|
+
if (signature !== last) { last = signature; stableSince = Date.now(); }
|
|
160
|
+
// Allow a click's navigation to begin, and URL/title events to settle. Never wait beyond its command budget.
|
|
161
|
+
if (reading.status !== 'loading' && !reading.pendingUrl && Date.now() - stableSince >= quietMs) return reading;
|
|
162
|
+
if (Date.now() - start >= settleMs) return reading;
|
|
163
|
+
await new Promise(resolve => setTimeout(resolve, pollMs)); guard();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
// A navigation answers with the page it committed, never with the page the tab was still on. Chrome's tabs.update
|
|
167
|
+
// resolves once the navigation is asked for, not when it commits: a navigation the browser dropped, or one still
|
|
168
|
+
// waiting for its server, leaves the tab on `start` (live test, 2026-11-16: "Navigated about:blank" for a tab that
|
|
169
|
+
// never left about:blank). Committed means the tab's committed URL is no longer `start` (a redirect counts), or, when
|
|
170
|
+
// the target is the page the tab was already on, that page once it is quiet. Nothing committed within `commitMs` or
|
|
171
|
+
// the command's deadline (less `reserve`, so the answer still goes out) is NAVIGATION_NOT_COMMITTED. Once committed,
|
|
172
|
+
// the reading settles like settled() (no load, no pending URL, `quietMs` without change) or is returned after
|
|
173
|
+
// `settleMs` still loading: the committed page.
|
|
174
|
+
const sameUrl = (a, b) => { try { return new URL(a).href === new URL(b).href; } catch { return a === b; } };
|
|
175
|
+
async function committed(t, start, target, guard, landing, left) {
|
|
176
|
+
const begin = Date.now(), same = sameUrl(start, target);
|
|
177
|
+
let since = 0, last = '', stableSince = begin, started = false;
|
|
178
|
+
for (;;) {
|
|
179
|
+
const reading = await live(t); guard();
|
|
180
|
+
for (const url of [reading.url, reading.pendingUrl]) if (url) { await landing(url); guard(); }
|
|
181
|
+
const busy = reading.status === 'loading' || !!reading.pendingUrl;
|
|
182
|
+
const done = shownUrl(reading) !== start || same && !busy;
|
|
183
|
+
const signature = `${reading.url}\n${reading.title || ''}\n${reading.status || ''}\n${reading.pendingUrl || ''}`;
|
|
184
|
+
if (signature !== last) { last = signature; stableSince = Date.now(); }
|
|
185
|
+
if (done) {
|
|
186
|
+
since ||= Date.now();
|
|
187
|
+
if (!busy && Date.now() - stableSince >= quietMs) return reading;
|
|
188
|
+
// Committed but not settled at the deadline: TIMEOUT from guard(), as before (the outcome is uncertain).
|
|
189
|
+
if (Date.now() - since >= settleMs) return reading;
|
|
190
|
+
} else if (Date.now() - begin >= commitMs || left() <= 0) fail('NAVIGATION_NOT_COMMITTED');
|
|
191
|
+
// Started (a load or a pending URL was seen) and stopped again on the old page: the browser abandoned it (a
|
|
192
|
+
// download, a 204, a navigation cancelled), so there is no need to wait out the deadline.
|
|
193
|
+
else if (started && !busy && Date.now() - stableSince >= quietMs) fail('NAVIGATION_NOT_COMMITTED');
|
|
194
|
+
started ||= busy;
|
|
195
|
+
await new Promise(resolve => setTimeout(resolve, pollMs)); guard();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
// Owner revocations from the server. Everything that narrows happens synchronously, on the call itself, before the
|
|
199
|
+
// first await: the caller runs these as soon as they arrive, ahead of queued commands.
|
|
200
|
+
function control(op, tab, owner, args) {
|
|
201
|
+
if (owner !== 'owner') return Promise.reject(Object.assign(new Error('NOT_OWNED'), { code: 'NOT_OWNED' }));
|
|
202
|
+
if (op === 'mode') { applyMode(args.fullControl, args.version); return enumerate().then(persist).then(() => ({ ok: true })); }
|
|
203
|
+
approval++; epoch++;
|
|
204
|
+
if (op === 'revokeTab') tabs.delete(tab);
|
|
205
|
+
else if (op === 'revokeSite') { sites = sites.filter(s => s !== args.site); pruneVersions(); }
|
|
206
|
+
// A restarted server knows none of the agents that held tabs: every tab goes back to the owner. A tab an agent
|
|
207
|
+
// opened stays open (it becomes one of the owner's), and nothing is closed.
|
|
208
|
+
else if (op === 'reset') { for (const t of [...tabs.values()]) { if (t.created) tabs.delete(t.handle); else t.owner = null; } }
|
|
209
|
+
else { tabs.clear(); connection++; }
|
|
210
|
+
return enumerate().then(persist).then(() => ({ ok: true }));
|
|
211
|
+
}
|
|
212
|
+
// `given` is the ticket the command arrived with; a direct call is held to the generations of the moment it starts.
|
|
213
|
+
// `given.expires` is the command's local deadline (on `now`), set by the worker when the message arrived; without one
|
|
214
|
+
// the deadline is counted from this call. Owner revocations ignore it: they only narrow, so they always apply.
|
|
215
|
+
async function execute(input, given = ticket()) {
|
|
216
|
+
const { op, tab, owner, args, blockedHosts = [], blockedPorts = [], selfHosts = [], deadline } = command(input);
|
|
217
|
+
const blocked = { blockedHosts, blockedPorts, selfHosts };
|
|
218
|
+
if (CONTROL.includes(op)) return control(op, tab, owner, args);
|
|
219
|
+
const expires = Number.isFinite(given.expires) ? given.expires : localDeadline(now(), deadline);
|
|
220
|
+
// Held to the generations (CANCELLED) and to the deadline (TIMEOUT): a command never acts after the server gave up.
|
|
221
|
+
const guard = () => { if (!valid(given)) fail('CANCELLED'); if (now() >= expires) fail('TIMEOUT'); };
|
|
222
|
+
// Every chrome.* call with an effect goes through act(): checked in the same synchronous step as the call, after
|
|
223
|
+
// the last await before it, so a revocation or disconnect that landed during that await stops it.
|
|
224
|
+
const act = effect => { guard(); return effect(); };
|
|
225
|
+
guard();
|
|
226
|
+
// SynaBun's own addresses, in either mode (in restricted mode a local address is not an approvable site anyway).
|
|
227
|
+
const denyControlHost = url => { if (controlSurface(url, blocked)) fail(fullControl ? 'SYNABUN_PAGE_BLOCKED' : 'SITE_NOT_APPROVED'); };
|
|
228
|
+
if (!['release', 'create'].includes(op)) {
|
|
229
|
+
const existing = tabs.get(tab);
|
|
230
|
+
if (existing) { await live(existing); guard(); denyControlHost(existing.url); }
|
|
231
|
+
denyControlHost(args.url);
|
|
232
|
+
}
|
|
233
|
+
let t = await authorized(op, tab, owner, args, blocked);
|
|
234
|
+
guard();
|
|
235
|
+
// Held to the owner's epoch and to this command's own tab only; a screenshot also to the active tab.
|
|
236
|
+
const began = epoch, tabBegan = t ? moved(t.id) : 0; let focusBegan = focus;
|
|
237
|
+
const unchanged = () => {
|
|
238
|
+
if (began !== epoch || t && moved(t.id) !== tabBegan || op === 'screenshot' && focus !== focusBegan) fail('TAB_NOT_APPROVED');
|
|
239
|
+
};
|
|
240
|
+
const recheck = async () => { guard(); unchanged(); if (t) { await authorized(op, tab, owner, args, blocked); guard(); unchanged(); denyControlHost(t.url); } };
|
|
241
|
+
const landing = async url => { if (fullControl) open(url, blocked); else if (url !== 'about:blank') await permitted(url); denyControlHost(url); };
|
|
242
|
+
// The URL and title returned come from one reading of the tab whose URL is the one authorization checked.
|
|
243
|
+
const metadata = async (read = () => settled(t, guard, landing)) => {
|
|
244
|
+
let reading = await read();
|
|
245
|
+
for (let attempt = 0; ; attempt++) {
|
|
246
|
+
await authorized(op, tab, owner, {}, blocked); guard(); denyControlHost(t.url);
|
|
247
|
+
if (t.url === shownUrl(reading)) return { url: shownUrl(reading), title: String(reading.title || '').slice(0, 1000) };
|
|
248
|
+
if (attempt >= 2) fail('TIMEOUT');
|
|
249
|
+
reading = await read();
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
let result = { ok: true };
|
|
253
|
+
if (op === 'create') {
|
|
254
|
+
const opened = await act(() => chrome.tabs.create({ url: 'about:blank', active: false }));
|
|
255
|
+
if (!valid(given) || now() >= expires || began !== epoch || !fullControl && !allowNewTabs) {
|
|
256
|
+
await chrome.tabs.remove(opened.id); fail(!valid(given) ? 'CANCELLED' : now() >= expires ? 'TIMEOUT' : 'TAB_NOT_APPROVED');
|
|
257
|
+
}
|
|
258
|
+
if ([...tabs.values()].filter(v => v.owner).length >= MAX_TABS) { await chrome.tabs.remove(opened.id); fail('TAB_LIMIT'); }
|
|
259
|
+
// A listing of the browser's tabs may have seen the new tab first: it is this agent's, under one handle.
|
|
260
|
+
for (const known of [...tabs.values()]) if (known.id === opened.id) tabs.delete(known.handle);
|
|
261
|
+
t = { handle: nonce(), id: opened.id, url: 'about:blank', title: '', owner, created: true }; tabs.set(t.handle, t); result.tab = t.handle;
|
|
262
|
+
} else if (op === 'claim') { guard(); t.owner = owner; result.tab = t.handle; }
|
|
263
|
+
else if (op === 'release') {
|
|
264
|
+
// A tab the agent opened is closed. Any other tab goes back to the owner, open: in full control it stays listed,
|
|
265
|
+
// in restricted mode its sharing ends with the agent's use of it (as before).
|
|
266
|
+
guard();
|
|
267
|
+
if (t.created) { tabs.delete(t.handle); await act(() => chrome.tabs.remove(t.id)).catch(() => {}); }
|
|
268
|
+
else if (fullControl) t.owner = null;
|
|
269
|
+
else tabs.delete(t.handle);
|
|
270
|
+
}
|
|
271
|
+
else if (op === 'navigate') {
|
|
272
|
+
await recheck();
|
|
273
|
+
const start = t.url;
|
|
274
|
+
try { await act(() => chrome.tabs.update(t.id, { url: args.url })); }
|
|
275
|
+
catch (error) { guard(); if (error?.code) throw error; fail(/tabs cannot be edited/i.test(error?.message || '') ? 'TAB_BUSY' : 'NAVIGATION_FAILED'); }
|
|
276
|
+
t.nav = nonce();
|
|
277
|
+
// What is left before the deadline, less the time the answer needs to go out (a tenth of the budget, ≤ 300 ms).
|
|
278
|
+
const reserveMs = Math.min(300, Math.max(0, (expires - now()) / 10)), left = () => expires - now() - reserveMs;
|
|
279
|
+
try { result = { ok: true, ...await metadata(() => committed(t, start, args.url, guard, landing, left)) }; }
|
|
280
|
+
catch (error) { if (error?.code === 'NAVIGATION_NOT_COMMITTED') await persist(); throw error; }
|
|
281
|
+
}
|
|
282
|
+
else if (op === 'reload') { await recheck(); await act(() => chrome.tabs.reload(t.id)); }
|
|
283
|
+
else if (HISTORY.includes(op)) {
|
|
284
|
+
await recheck();
|
|
285
|
+
// The destination is unknown until the tab lands (no history permission). Check it like a navigate target,
|
|
286
|
+
// while it lands and after: the tab keeps its new URL, so every later command on it is refused too, and nothing
|
|
287
|
+
// of an unapproved page is returned. recheck() is not used here: the URL change itself moves the tab's counter.
|
|
288
|
+
const landing = async url => { if (fullControl) open(url, blocked); else if (url !== 'about:blank') await permitted(url); denyControlHost(url); };
|
|
289
|
+
let reading;
|
|
290
|
+
try {
|
|
291
|
+
reading = await traverse(t, op, act, guard, landing);
|
|
292
|
+
// The URL and title returned come from one reading of the tab, and that reading's URL is the one authorized
|
|
293
|
+
// (authorized() reads the tab again). A redirect between the two readings means another reading, up to three.
|
|
294
|
+
for (let attempt = 1; ; attempt++) {
|
|
295
|
+
await authorized(op, tab, owner, {}, blocked); guard(); denyControlHost(t.url);
|
|
296
|
+
if (t.url === reading.url) break;
|
|
297
|
+
if (attempt >= 3) fail('TIMEOUT');
|
|
298
|
+
reading = await live(t); guard();
|
|
299
|
+
}
|
|
300
|
+
} catch (error) { await persist(); throw error; }
|
|
301
|
+
result = { ok: true, url: reading.url, title: String(reading.title || '').slice(0, 1000) };
|
|
302
|
+
}
|
|
303
|
+
else if (op === 'download') {
|
|
304
|
+
if (!await chrome.permissions.contains({ permissions: ['downloads'] })) fail('PERMISSION_REQUIRED');
|
|
305
|
+
await recheck(); result.downloadId = await act(() => chrome.downloads.download({ url: args.url, saveAs: true }));
|
|
306
|
+
} else if (op === 'screenshot' && fullControl) {
|
|
307
|
+
// Full control (live test, 2026-11-16: ACTIVE_TAB_REQUIRED on a fresh agent tab while the owner worked in another
|
|
308
|
+
// window). captureVisibleTab captures what a window shows, and Chrome refuses it for a window that is minimized or
|
|
309
|
+
// hidden behind others (its view is not visible). Each attempt brings the agent's tab to the front of its own
|
|
310
|
+
// window, restores and focuses that window when needed (always on the retry), waits until the tab is the active one
|
|
311
|
+
// of a window that is not minimized, and captures that window (the tab's own windowId). One retry; then
|
|
312
|
+
// ACTIVE_TAB_REQUIRED. The capture is still held to the tab staying the active one, and to the command's counters.
|
|
313
|
+
const sleep = ms => new Promise(resolve => setTimeout(resolve, Math.max(0, Math.min(ms, expires - now()))));
|
|
314
|
+
const windowOf = async id => { try { return chrome.windows?.get ? await chrome.windows.get(id) : null; } catch { return null; } };
|
|
315
|
+
const frontOf = async windowId => (await chrome.tabs.query({ active: true, windowId }))[0];
|
|
316
|
+
// Until the tab is the active one of its window and that window is not minimized (and focused, when asked).
|
|
317
|
+
async function shown(focused) {
|
|
318
|
+
const until = Date.now() + visibleMs;
|
|
319
|
+
for (;;) {
|
|
320
|
+
const tab = await live(t); guard();
|
|
321
|
+
const win = await windowOf(tab.windowId), front = await frontOf(tab.windowId); guard();
|
|
322
|
+
if (tab.active && front?.id === t.id && win?.state !== 'minimized' && (!focused || !win || win.focused !== false)) return tab;
|
|
323
|
+
if (Date.now() >= until) return null;
|
|
324
|
+
await sleep(pollMs); guard();
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
async function attempt(retry) {
|
|
328
|
+
try {
|
|
329
|
+
// The focus counter guards the capture itself; a tab switch before this attempt (this command's own earlier
|
|
330
|
+
// activation included) is not a reason to refuse it.
|
|
331
|
+
focusBegan = focus;
|
|
332
|
+
let opened = await live(t); guard();
|
|
333
|
+
if (!opened.active || (await frontOf(opened.windowId))?.id !== t.id) { await recheck(); await act(() => chrome.tabs.update(t.id, { active: true })); }
|
|
334
|
+
const win = await windowOf(opened.windowId); guard();
|
|
335
|
+
const focusIt = retry || win?.state === 'minimized';
|
|
336
|
+
if (focusIt && chrome.windows?.update) {
|
|
337
|
+
await recheck();
|
|
338
|
+
await act(() => chrome.windows.update(opened.windowId, { focused: true, ...(win?.state === 'minimized' ? { state: 'normal' } : {}) }));
|
|
339
|
+
}
|
|
340
|
+
await sleep(activateMs); guard();
|
|
341
|
+
opened = await shown(focusIt);
|
|
342
|
+
if (!opened) return null;
|
|
343
|
+
focusBegan = focus;
|
|
344
|
+
// SynaBun's own pace (one capture a second): a retry waits it out within the deadline instead of failing.
|
|
345
|
+
const gap = 1000 - (Date.now() - lastCapture);
|
|
346
|
+
if (gap > 0) { if (gap >= expires - now()) fail('TIMEOUT'); await sleep(gap); guard(); }
|
|
347
|
+
await recheck();
|
|
348
|
+
const capture = act(() => chrome.tabs.captureVisibleTab(opened.windowId, { format: 'png' }));
|
|
349
|
+
lastCapture = Date.now();
|
|
350
|
+
let data;
|
|
351
|
+
try { data = await capture; } catch { guard(); return null; }
|
|
352
|
+
const after = await frontOf(opened.windowId);
|
|
353
|
+
if (after?.id !== t.id || after.url !== opened.url) return null;
|
|
354
|
+
await recheck();
|
|
355
|
+
return typeof data === 'string' && data.includes(',') ? data : null;
|
|
356
|
+
} catch (error) {
|
|
357
|
+
// The owner switched tabs while it ran (only the focus counter moved): the retry brings the tab back.
|
|
358
|
+
if (error?.code === 'TAB_NOT_APPROVED' && began === epoch && moved(t.id) === tabBegan && valid(given)) return null;
|
|
359
|
+
throw error;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
const data = await attempt(false) || await attempt(true);
|
|
363
|
+
if (!data) fail('ACTIVE_TAB_REQUIRED');
|
|
364
|
+
result.base64 = data.split(',')[1]; result.mimeType = 'image/png';
|
|
365
|
+
} else if (op === 'screenshot') {
|
|
366
|
+
// Restricted mode: the tab must already be the active one; nothing is brought forward.
|
|
367
|
+
const opened = await live(t); guard();
|
|
368
|
+
const active = (await chrome.tabs.query({ active: true, windowId: opened.windowId }))[0];
|
|
369
|
+
if (!active || active.id !== t.id || !opened.active) fail('ACTIVE_TAB_REQUIRED');
|
|
370
|
+
if (Date.now() - lastCapture < 1000) fail('TIMEOUT');
|
|
371
|
+
await recheck();
|
|
372
|
+
const capture = act(() => chrome.tabs.captureVisibleTab(opened.windowId, { format: 'png' }));
|
|
373
|
+
lastCapture = Date.now();
|
|
374
|
+
let data;
|
|
375
|
+
try { data = await capture; } catch { fail('ACTIVE_TAB_REQUIRED'); }
|
|
376
|
+
const after = (await chrome.tabs.query({ active: true, windowId: opened.windowId }))[0];
|
|
377
|
+
if (after?.id !== t.id || after.url !== opened.url) fail('ACTIVE_TAB_REQUIRED');
|
|
378
|
+
await recheck(); result.base64 = data.split(',')[1]; result.mimeType = 'image/png';
|
|
379
|
+
} else if (fullControl && t.url === 'about:blank') {
|
|
380
|
+
// A blank tab (where a new agent tab starts) has no page an extension may script: it reads as empty, a plain
|
|
381
|
+
// wait waits, and anything that needs an element finds none.
|
|
382
|
+
await recheck();
|
|
383
|
+
const blank = { ok: true, url: 'about:blank', title: '' };
|
|
384
|
+
if (op === 'snapshot') result = { ...blank, mode: 'ai', snapshotId: 'blank', snapshotText: '' };
|
|
385
|
+
else if (op === 'content') result = { ...blank, content: '', text: '' };
|
|
386
|
+
else if (op === 'wait' && !args.selector) {
|
|
387
|
+
const ms = Math.min(args.timeout ?? 1000, 15000), left = expires - now();
|
|
388
|
+
await new Promise(resolve => setTimeout(resolve, Math.max(0, Math.min(ms, left)))); guard();
|
|
389
|
+
if (ms >= left) fail('TIMEOUT');
|
|
390
|
+
await recheck(); result = blank;
|
|
391
|
+
} else fail('NO_MATCH');
|
|
392
|
+
} else {
|
|
393
|
+
await act(() => chrome.scripting.executeScript({ target: { tabId: t.id, frameIds: [0] }, files: ['content.js'], world: 'ISOLATED' }));
|
|
394
|
+
await recheck();
|
|
395
|
+
t.nav ||= nonce();
|
|
396
|
+
// The page action carries the deadline as a system-clock time (`until`), which the content script shares: it
|
|
397
|
+
// refuses to act once that has passed, however late the message reaches it, and a wait ends there.
|
|
398
|
+
// Full control sends no site list: the page checks only that a link or form does not lead to SynaBun's own
|
|
399
|
+
// addresses (`blocked`). Restricted mode sends the approved sites, less SynaBun's public aliases.
|
|
400
|
+
const beforeActionUrl = t.url;
|
|
401
|
+
result = await act(() => chrome.tabs.sendMessage(t.id, { kind: 'synabun-fixed-command', op, args,
|
|
402
|
+
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 }));
|
|
404
|
+
if (op === 'click' && result?.ok) {
|
|
405
|
+
Object.assign(result, await metadata());
|
|
406
|
+
if (result.url !== beforeActionUrl || moved(t.id) !== tabBegan) t.nav = nonce();
|
|
407
|
+
} else await recheck();
|
|
408
|
+
if (!result?.ok) return safeError(result);
|
|
409
|
+
if (result.downloadUrl) {
|
|
410
|
+
if (!downloads || !await chrome.permissions.contains({ permissions: ['downloads'] })) fail('PERMISSION_REQUIRED');
|
|
411
|
+
guard(); await destination(result.downloadUrl, blocked); denyControlHost(result.downloadUrl); await recheck();
|
|
412
|
+
const downloadId = await act(() => chrome.downloads.download({ url: result.downloadUrl, saveAs: true }));
|
|
413
|
+
result = { ok: true, downloadId };
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
await persist(); return result;
|
|
417
|
+
}
|
|
418
|
+
return {
|
|
419
|
+
current, ticket, now,
|
|
420
|
+
mode: () => ({ fullControl, modeVersion }),
|
|
421
|
+
async restore(saved = {}) {
|
|
422
|
+
sites = (saved.sites || []).filter(s => { try { return publicOrigin(s) === s; } catch { return false; } });
|
|
423
|
+
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;
|
|
425
|
+
fullControl = typeof saved.fullControl === 'boolean' ? saved.fullControl : fullControlDefault === true;
|
|
426
|
+
modeVersion = Number.isSafeInteger(saved.modeVersion) && saved.modeVersion >= 0 ? saved.modeVersion : 0;
|
|
427
|
+
tabs = new Map((saved.tabs || []).filter(t => fullControl || !t.listed || t.created).map(t => [t.handle, t]));
|
|
428
|
+
for (const t of [...tabs.values()]) { try { await live(t); } catch {} }
|
|
429
|
+
await enumerate(); await persist();
|
|
430
|
+
},
|
|
431
|
+
// The popup's mode switch (the owner's gesture): always newer than any version either side has seen.
|
|
432
|
+
async setMode(full) {
|
|
433
|
+
if (typeof full !== 'boolean') fail('INVALID_MESSAGE');
|
|
434
|
+
applyMode(full, Math.max(modeVersion + 1, wallClock()));
|
|
435
|
+
await enumerate(); await persist();
|
|
436
|
+
},
|
|
437
|
+
// The popup's owner gesture, and the only place an approval version rises: every share is a fresh approval, newer
|
|
438
|
+
// than any the server saw (a wall-clock floor keeps that true even after the extension's storage was cleared).
|
|
439
|
+
async share(id, siteOnly = false) {
|
|
440
|
+
const opened = await chrome.tabs.get(id); const origin = publicOrigin(opened.url);
|
|
441
|
+
if (!await chrome.permissions.contains({ origins: [hostPattern(origin)] })) fail('PERMISSION_REQUIRED');
|
|
442
|
+
if (!sites.includes(origin)) sites.push(origin);
|
|
443
|
+
versions.set(origin, Math.max((versions.get(origin) || 0) + 1, Date.now()));
|
|
444
|
+
const known = [...tabs.values()].find(t => t.id === id);
|
|
445
|
+
if (!siteOnly && known) known.listed = false;
|
|
446
|
+
else if (!siteOnly) { const t = { handle: nonce(), id, url: opened.url, title: clip(opened.title), owner: null, created: false }; tabs.set(t.handle, t); }
|
|
447
|
+
await persist();
|
|
448
|
+
},
|
|
449
|
+
async revokeTab(handle) { approval++; tabs.delete(handle); epoch++; await enumerate(); await persist(); },
|
|
450
|
+
async revokeSite(site) { approval++; sites = sites.filter(s => s !== site); epoch++; pruneVersions(); await persist(); },
|
|
451
|
+
async options(value) {
|
|
452
|
+
// 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();
|
|
455
|
+
},
|
|
456
|
+
// Tab events from the browser concern that tab only.
|
|
457
|
+
async closed(id) { move(id); for (const t of tabs.values()) if (t.id === id) tabs.delete(t.handle); moves.delete(id); await persist(); },
|
|
458
|
+
async updated(id) { move(id); for (const t of tabs.values()) if (t.id === id) { try { await live(t); } catch {} } await enumerate(); await persist(); },
|
|
459
|
+
// Full control: a tab opened or retitled. Neither moves a tab's counter (a title changes while agents work).
|
|
460
|
+
async opened() { if (!fullControl) return; await enumerate(); await persist(); },
|
|
461
|
+
async retitled(id) {
|
|
462
|
+
if (![...tabs.values()].some(t => t.id === id)) return;
|
|
463
|
+
for (const t of tabs.values()) if (t.id === id) { try { const tab = await chrome.tabs.get(id); t.title = clip(tab.title); } catch {} }
|
|
464
|
+
await persist();
|
|
465
|
+
},
|
|
466
|
+
// 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(); },
|
|
468
|
+
activated() { focus++; },
|
|
469
|
+
// Whether an agent holds the browser tab with this Chrome id (SynaBun's setup page is never paired from one).
|
|
470
|
+
heldByAgent: id => [...tabs.values()].some(t => t.id === id && t.owner),
|
|
471
|
+
// The connection commands came on has ended (closed, paused, unpaired or replaced by a new pairing).
|
|
472
|
+
disconnected() { connection++; },
|
|
473
|
+
// An approval was withdrawn outside the popup (a host permission removed in the browser's own settings).
|
|
474
|
+
withdrawn() { approval++; },
|
|
475
|
+
execute,
|
|
476
|
+
};
|
|
477
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifest_version": 3,
|
|
3
|
+
"name": "SynaBun Browser Bridge",
|
|
4
|
+
"version": "1.2.1",
|
|
5
|
+
"minimum_chrome_version": "120",
|
|
6
|
+
"description": "Lets SynaBun agents use your everyday browser: every site and tab (full control), or only what you share.",
|
|
7
|
+
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsDPDDuBTQq9nQgulmTSvzujxyOMZ7A7ttMSXtbIwup/X3kOlbkqoJEqQRGGJeb7+cNBSiiDBA5lhS0oYc9YeFcwNCucNMvGawDGblbQzDWEmn9dDK1krFVXWqNHVPIrEWlzCD2swXmIE2FCjMd5zw6dSRmmxu7VgE6bzvuOgB/W/oeOAyCsEDhDRDLBkjmb+yCsuexiXRWoempPsvAVhxhE8zEQJ1e8ChlFMtpOXSobU+YDgKYfcFy9Fbmk/o6M6B9y5zSlzs/HYIu7xvcCwjZI457idVMRxxAT6J/kXytmfKe/zbi5IO5/i0x9SCA1HRvt8K3nJqoH03h4TOvFwOwIDAQAB",
|
|
8
|
+
"permissions": [
|
|
9
|
+
"storage",
|
|
10
|
+
"alarms",
|
|
11
|
+
"scripting",
|
|
12
|
+
"tabs",
|
|
13
|
+
"activeTab"
|
|
14
|
+
],
|
|
15
|
+
"optional_permissions": [
|
|
16
|
+
"downloads"
|
|
17
|
+
],
|
|
18
|
+
"host_permissions": [
|
|
19
|
+
"<all_urls>"
|
|
20
|
+
],
|
|
21
|
+
"content_scripts": [
|
|
22
|
+
{
|
|
23
|
+
"matches": [
|
|
24
|
+
"http://127.0.0.1:3344/extension-setup*",
|
|
25
|
+
"http://localhost:3344/extension-setup*"
|
|
26
|
+
],
|
|
27
|
+
"js": [
|
|
28
|
+
"setup-content.js"
|
|
29
|
+
],
|
|
30
|
+
"run_at": "document_idle",
|
|
31
|
+
"all_frames": false
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"background": {
|
|
35
|
+
"service_worker": "service-worker.js",
|
|
36
|
+
"type": "module"
|
|
37
|
+
},
|
|
38
|
+
"icons": {
|
|
39
|
+
"16": "icons/icon-16.png",
|
|
40
|
+
"32": "icons/icon-32.png",
|
|
41
|
+
"48": "icons/icon-48.png",
|
|
42
|
+
"128": "icons/icon-128.png"
|
|
43
|
+
},
|
|
44
|
+
"action": {
|
|
45
|
+
"default_popup": "popup.html",
|
|
46
|
+
"default_title": "SynaBun Browser Bridge",
|
|
47
|
+
"default_icon": {
|
|
48
|
+
"16": "icons/status-off-16.png",
|
|
49
|
+
"32": "icons/status-off-32.png",
|
|
50
|
+
"48": "icons/status-off-48.png"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"content_security_policy": {
|
|
54
|
+
"extension_pages": "script-src 'self'; object-src 'self'; connect-src ws://127.0.0.1:*"
|
|
55
|
+
}
|
|
56
|
+
}
|