synabun 2.3.0 → 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 +38 -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 +1174 -47
- package/neural-interface/i18n/pt-BR.json +1174 -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-profiles.js +1 -1
- 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/cli-install-api.js +23 -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/editor-completion-opencode.js +4 -3
- package/neural-interface/lib/effort-levels.js +10 -1
- package/neural-interface/lib/maritaca/opencode-proxy.js +7 -2
- package/neural-interface/lib/maritaca/opencode.js +35 -0
- 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 +219 -7
- package/neural-interface/lib/native-loop-runtime.js +24 -1
- package/neural-interface/lib/opencode-build-preflight.js +116 -0
- package/neural-interface/lib/opencode-launch-error.js +13 -0
- package/neural-interface/lib/opencode-native-boundary.js +800 -84
- package/neural-interface/lib/opencode-serve-probe.js +426 -0
- package/neural-interface/lib/opencode-serve-records.js +14 -9
- package/neural-interface/lib/opencode-serve-scan.js +108 -0
- 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 +235 -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/lib/worker-mcp-channel.js +38 -1
- package/neural-interface/package-lock.json +4 -2
- package/neural-interface/package.json +3 -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/opencode-verify-view.js +175 -0
- 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 +713 -61
- 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-opencode-verify.js +120 -0
- 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 +372 -402
- 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 +1164 -157
- 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,446 @@
|
|
|
1
|
+
// Settings → Browser → "Existing browser via extension". The approved redesign (docs/design/browser-extension:
|
|
2
|
+
// "Settings card"): a connection status that says what to do next, the agent access, the tabs agents hold grouped by
|
|
3
|
+
// agent with an immediate Take back, the one-button setup, and the rest behind two disclosures. Settings' own markup,
|
|
4
|
+
// tokens and 22 px controls; no native dropdown and no new palette.
|
|
5
|
+
//
|
|
6
|
+
// Layout: the card is one row of the Browser group (`.stg-field`, for the group's row spacing and hairline), but it
|
|
7
|
+
// never has a label, an input or a compact control as a DIRECT child: the Settings rule for a compact control
|
|
8
|
+
// (`.stg-field:has(> input[type="number"])`) would turn the whole card into a two-column grid and put every help
|
|
9
|
+
// paragraph into the same cell (styles.css, "Fields: label, control, one-line help"). Each part is a block of its own
|
|
10
|
+
// that reads top to bottom: status, agent access, tabs, setup, files and limits, connection details, the actions.
|
|
11
|
+
//
|
|
12
|
+
// The mode: "Full control" (the default) or "Only shared sites and tabs". It is the owner's: switched here (POST
|
|
13
|
+
// /api/browser/extension/mode, behind the owner route) or in the extension popup, and confirmed first either way.
|
|
14
|
+
// The dropdown is the app's .cc-dropdown (Settings wires every .stg-dropdown, wireStgDropdowns); a server from before
|
|
15
|
+
// the mode existed reports no `fullControl` and the section stays hidden. Disconnect and Revoke pairing are confirmed
|
|
16
|
+
// too; Take back is immediate and never closes the tab.
|
|
17
|
+
const SYMBOL = {
|
|
18
|
+
ok: '<path d="m5 12 4 4 10-10"></path>',
|
|
19
|
+
warn: '<path d="M9 5v14M15 5v14"></path>',
|
|
20
|
+
err: '<path d="m12 3 10 18H2L12 3ZM12 9v5M12 17h.01"></path>',
|
|
21
|
+
off: '<path d="M10 14a4 4 0 0 0 5.66 0l3-3a4 4 0 0 0-5.66-5.66l-1 1M14 10a4 4 0 0 0-5.66 0l-3 3a4 4 0 0 0 5.66 5.66l1-1"></path>',
|
|
22
|
+
sync: '<path d="M20 7a9 9 0 0 0-15-1L2 9m0-6v6h6M4 17a9 9 0 0 0 15 1l3-3m0 6v-6h-6"></path>',
|
|
23
|
+
};
|
|
24
|
+
const CHEVRON = '<svg class="cc-section-chevron" viewBox="0 0 24 24" aria-hidden="true"><polyline points="9 18 15 12 9 6"></polyline></svg>';
|
|
25
|
+
|
|
26
|
+
export function extensionSettingsHTML(kit) {
|
|
27
|
+
const t = key => kit.te(`browserExtension.${key}`);
|
|
28
|
+
const c = key => kit.te(`browserExtension.card.${key}`);
|
|
29
|
+
const button = (action, key, extra = '') => `<button type="button" class="cli-detect-btn" data-extension-action="${action}"${extra}>${t(key)}</button>`;
|
|
30
|
+
const modes = [['full', t('modeFull')], ['restricted', t('modeRestricted')]];
|
|
31
|
+
const symbols = Object.entries(SYMBOL).map(([name, path]) => `<svg class="bc-ext-sym" data-sym="${name}" viewBox="0 0 24 24">${path}</svg>`).join('');
|
|
32
|
+
return `<div class="stg-field bc-extension" id="bc-extension" data-card-state="loading" hidden>
|
|
33
|
+
<div class="bc-ext-head" id="bc-extension-head" data-tone="">
|
|
34
|
+
<div class="bc-ext-status-row">
|
|
35
|
+
<span class="bc-ext-symbol" aria-hidden="true">${symbols}</span>
|
|
36
|
+
<span class="bc-ext-label" id="bc-extension-status-label">${t('statusTitle')}</span>
|
|
37
|
+
<span class="stg-badge bc-ext-status" id="bc-extension-status" role="status" aria-live="polite" aria-labelledby="bc-extension-status-label"></span>
|
|
38
|
+
</div>
|
|
39
|
+
<p class="stg-help bc-ext-text bc-ext-status-help" id="bc-extension-status-help"></p>
|
|
40
|
+
<div class="bc-inline-group bc-ext-actions" id="bc-extension-status-actions" hidden>
|
|
41
|
+
<button type="button" class="cli-detect-btn bc-ext-primary" data-extension-action="resume">${c('reconnect')}</button>
|
|
42
|
+
<button type="button" class="cli-detect-btn" data-extension-action="retry" hidden>${c('retry')}</button>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
<section class="bc-ext-section" data-extension-section="mode" aria-labelledby="bc-extension-mode-title" hidden>
|
|
46
|
+
<div class="bc-ext-mode-row">
|
|
47
|
+
<h4 class="stg-subhead" id="bc-extension-mode-title">${t('modeTitle')}</h4>
|
|
48
|
+
<input type="hidden" id="bc-extension-mode" value="full">
|
|
49
|
+
<div class="cc-dropdown stg-dropdown bc-ext-mode" data-for="bc-extension-mode" role="group">
|
|
50
|
+
<button class="cc-dropdown-trigger" type="button" aria-haspopup="listbox" aria-labelledby="bc-extension-mode-title"><span class="cc-dropdown-value">${modes[0][1]}</span><svg class="cc-dropdown-arrow" viewBox="0 0 24 24" aria-hidden="true"><polyline points="6 9 12 15 18 9"></polyline></svg></button>
|
|
51
|
+
<div class="cc-dropdown-menu">${modes.map(([value, label], i) => `<div class="cc-dropdown-item${i === 0 ? ' active' : ''}" data-value="${value}">${label}</div>`).join('')}</div>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
<p class="stg-help bc-ext-text" id="bc-extension-mode-help" data-full-text="${t('modeFullHelp')}" data-restricted-text="${t('modeRestrictedHelp')}"></p>
|
|
55
|
+
</section>
|
|
56
|
+
<section class="bc-ext-section" data-extension-section="shared" aria-labelledby="bc-extension-shared-title" hidden>
|
|
57
|
+
<div class="bc-ext-title-row"><h4 class="stg-subhead" id="bc-extension-shared-title">${t('sharedTitle')}</h4><span class="bc-ext-count" id="bc-extension-count"></span></div>
|
|
58
|
+
<p class="stg-help bc-ext-text" id="bc-extension-summary" hidden></p>
|
|
59
|
+
<div class="bc-ext-list" id="bc-extension-tabs" data-empty-text="${t('noTabs')}" data-empty-full-text="${t('noControlled')}"></div>
|
|
60
|
+
<div class="bc-ext-list" id="bc-extension-sites" aria-label="${c('sharedSites')}"></div>
|
|
61
|
+
<p class="stg-help bc-ext-text" id="bc-extension-tabs-help" data-live-text="${c('takeBackHelp')}" data-stale-text="${c('staleHelp')}" hidden></p>
|
|
62
|
+
</section>
|
|
63
|
+
<section class="bc-ext-section" data-extension-section="setup" id="bc-extension-setup" data-state="idle" aria-labelledby="bc-extension-setup-title" hidden>
|
|
64
|
+
<h4 class="stg-subhead" id="bc-extension-setup-title" data-connect-text="${c('settingsTitle')}" data-again-text="${c('setupAgainTitle')}">${c('settingsTitle')}</h4>
|
|
65
|
+
<p class="stg-help bc-ext-text" id="bc-extension-setup-help" data-connect-text="${t('setupHelp')}" data-again-text="${c('setupAgainHelp')}">${t('setupHelp')}</p>
|
|
66
|
+
<div class="bc-inline-group bc-ext-actions">
|
|
67
|
+
<button type="button" class="cli-detect-btn" id="bc-extension-setup-start" data-extension-action="setup-start" data-connect-text="${t('setupConnect')}" data-reconnect-text="${t('setupReconnect')}" data-reinstall-text="${t('setupReinstall')}">${t('setupConnect')}</button>
|
|
68
|
+
<button type="button" class="cli-detect-btn" id="bc-extension-setup-reopen" data-extension-action="setup-reopen" hidden>${c('openGuide')}</button>
|
|
69
|
+
<button type="button" class="cli-detect-btn" id="bc-extension-setup-cancel" data-extension-action="setup-cancel" hidden>${t('setupCancel')}</button>
|
|
70
|
+
</div>
|
|
71
|
+
<p class="stg-help bc-ext-text" id="bc-extension-setup-status" role="status" aria-live="polite"></p>
|
|
72
|
+
<div class="bc-inline-group bc-ext-actions" id="bc-extension-setup-alternatives" hidden></div>
|
|
73
|
+
<p class="stg-help bc-ext-text bc-ext-note" id="bc-extension-setup-default">${c('setupDefault')}</p>
|
|
74
|
+
<p class="stg-help bc-ext-text bc-ext-note" id="bc-extension-reload" data-tone="warn" hidden>${t('reloadNeeded')}</p>
|
|
75
|
+
</section>
|
|
76
|
+
<details class="stg-advanced bc-ext-advanced" id="bc-extension-files" data-extension-section="files">
|
|
77
|
+
<summary>${CHEVRON}<span>${c('advanced')}</span></summary>
|
|
78
|
+
<div class="bc-ext-advanced-body">
|
|
79
|
+
<h4 class="stg-subhead" id="bc-extension-uploads-title">${t('uploadsTitle')}</h4>
|
|
80
|
+
<p class="stg-help bc-ext-text" id="bc-extension-upload"></p>
|
|
81
|
+
<p class="stg-help bc-ext-text">${c('uploadHelp')}</p>
|
|
82
|
+
<p class="stg-help bc-ext-text bc-ext-limits">${t('limits')}</p>
|
|
83
|
+
</div>
|
|
84
|
+
</details>
|
|
85
|
+
<details class="stg-advanced bc-ext-advanced" id="bc-extension-details" data-extension-section="details">
|
|
86
|
+
<summary>${CHEVRON}<span>${c('details')}</span></summary>
|
|
87
|
+
<div class="bc-ext-advanced-body">
|
|
88
|
+
<section class="bc-ext-part" data-extension-section="install" aria-labelledby="bc-extension-install-title">
|
|
89
|
+
<h4 class="stg-subhead" id="bc-extension-install-title">${t('installTitle')}</h4>
|
|
90
|
+
<p class="stg-help bc-ext-text">${t('install')}</p>
|
|
91
|
+
<label class="bc-ext-label" for="bc-extension-folder">${t('folder')}</label>
|
|
92
|
+
<div class="bc-ext-control-row">
|
|
93
|
+
<input class="browser-cfg-input bc-ext-path" id="bc-extension-folder" readonly spellcheck="false" autocomplete="off">
|
|
94
|
+
<div class="bc-inline-group bc-ext-actions">${button('copy', 'copy')}${button('refresh', 'refresh')}</div>
|
|
95
|
+
</div>
|
|
96
|
+
</section>
|
|
97
|
+
<section class="bc-ext-part" data-extension-section="pairing" aria-labelledby="bc-extension-pairing-title">
|
|
98
|
+
<h4 class="stg-subhead" id="bc-extension-pairing-title">${t('pairingTitle')}</h4>
|
|
99
|
+
<p class="stg-help bc-ext-text">${c('manualPairHelp')}</p>
|
|
100
|
+
<div class="bc-ext-port-row">
|
|
101
|
+
<label class="bc-ext-label" for="bc-extension-port">${t('port')}</label>
|
|
102
|
+
<input class="browser-cfg-input bc-ext-port" id="bc-extension-port" type="number" min="1024" max="65535" value="3345">
|
|
103
|
+
</div>
|
|
104
|
+
<div class="bc-inline-group bc-ext-actions">${button('pair', 'pair')}</div>
|
|
105
|
+
<p class="bc-ext-code" id="bc-extension-code" role="status"></p>
|
|
106
|
+
</section>
|
|
107
|
+
</div>
|
|
108
|
+
</details>
|
|
109
|
+
<div class="bc-ext-footer" id="bc-extension-footer" hidden>
|
|
110
|
+
<div class="bc-inline-group bc-ext-actions">${button('disconnect', 'disconnect')}${button('revoke', 'revoke', ' data-tone="danger"')}</div>
|
|
111
|
+
</div>
|
|
112
|
+
<div class="bc-ext-confirm" id="bc-extension-confirm" role="alertdialog" aria-labelledby="bc-extension-confirm-title" aria-describedby="bc-extension-confirm-body" hidden>
|
|
113
|
+
<h4 class="stg-subhead" id="bc-extension-confirm-title"></h4>
|
|
114
|
+
<p class="stg-help bc-ext-text" id="bc-extension-confirm-body"></p>
|
|
115
|
+
<div class="bc-inline-group bc-ext-actions">
|
|
116
|
+
<button type="button" class="cli-detect-btn" id="bc-extension-confirm-cancel" data-extension-action="confirm-cancel">${c('cancel')}</button>
|
|
117
|
+
<button type="button" class="cli-detect-btn" id="bc-extension-confirm-ok" data-extension-action="confirm-ok"></button>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
</div>`;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// ── what the card shows, decided without the DOM (exported for tests) ──
|
|
124
|
+
/**
|
|
125
|
+
* The card's state. `data`: GET /api/browser/extension (null when it failed); `setup`: the setup status (when one is
|
|
126
|
+
* running); `failed`: the last read failed; `launching`: the owner's setup start is on its way.
|
|
127
|
+
*/
|
|
128
|
+
export function cardState(data, setup = null, { failed = false, launching = false } = {}) {
|
|
129
|
+
if (failed && !data) return 'error';
|
|
130
|
+
const running = setup?.state || data?.setup;
|
|
131
|
+
if (launching) return 'launching';
|
|
132
|
+
if (data?.connected) return failed ? 'error' : 'connected';
|
|
133
|
+
if (running === 'waiting-for-extension') return 'setup';
|
|
134
|
+
if (running === 'pairing') return 'pairing';
|
|
135
|
+
if (running === 'unsupported') return 'unsupported';
|
|
136
|
+
if (failed) return 'error';
|
|
137
|
+
if (data?.paired) return 'disconnected';
|
|
138
|
+
return 'unpaired';
|
|
139
|
+
}
|
|
140
|
+
/** Host and path of an address: the query and fragment (sign-in challenges, tokens) are never shown. */
|
|
141
|
+
export function shownAddress(url) {
|
|
142
|
+
let u;
|
|
143
|
+
try { u = new URL(String(url || '')); } catch { return ''; }
|
|
144
|
+
if (u.href === 'about:blank') return 'about:blank';
|
|
145
|
+
if (u.protocol !== 'http:' && u.protocol !== 'https:') return `${u.protocol}//`;
|
|
146
|
+
return `${u.host}${u.pathname === '/' ? '' : u.pathname}`;
|
|
147
|
+
}
|
|
148
|
+
/** The tabs agents hold, grouped by the opaque agent id the server reports, in the server's order. */
|
|
149
|
+
export function groupByAgent(tabs = []) {
|
|
150
|
+
const groups = new Map();
|
|
151
|
+
for (const tab of tabs) {
|
|
152
|
+
if (!tab?.owner) continue;
|
|
153
|
+
const id = String(tab.owner).replace(/[^a-z0-9]/gi, '').slice(0, 6).toUpperCase() || '?';
|
|
154
|
+
if (!groups.has(tab.owner)) groups.set(tab.owner, { owner: tab.owner, id, tabs: [] });
|
|
155
|
+
groups.get(tab.owner).tabs.push(tab);
|
|
156
|
+
}
|
|
157
|
+
return [...groups.values()];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// The badge's tone for each state the card reports (Settings' own .stg-badge-ok / -warn / -err; none is the plain word).
|
|
161
|
+
const STATUS_TONES = ['stg-badge-ok', 'stg-badge-warn', 'stg-badge-err'];
|
|
162
|
+
const HEAD = {
|
|
163
|
+
connected: ['ok', 'connectedHelp'], disconnected: ['warn', 'disconnectedHelp'], unpaired: ['off', 'unpairedHelp'],
|
|
164
|
+
launching: ['sync', 'launchingHelp'], setup: ['sync', 'setupRunningHelp'], pairing: ['sync', 'pairingHelp'],
|
|
165
|
+
unsupported: ['err', 'unsupportedHelp'], error: ['err', 'errorHelp'],
|
|
166
|
+
};
|
|
167
|
+
const CONFIRMS = {
|
|
168
|
+
disconnect: ['disconnectTitle', 'disconnectBody', 'disconnect'],
|
|
169
|
+
revoke: ['revokeTitle', 'revokeBody', 'revoke'],
|
|
170
|
+
restrict: ['restrictTitle', 'restrictBody', 'restrictConfirm'],
|
|
171
|
+
full: ['fullTitle', 'fullBody', 'fullConfirm'],
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export function wireExtensionSettings(root, { tx, signal }) {
|
|
175
|
+
const pane = root.querySelector('#bc-extension'); if (!pane) return;
|
|
176
|
+
const t = (key, params) => tx(`browserExtension.${key}`, params);
|
|
177
|
+
const c = (key, params) => tx(`browserExtension.card.${key}`, params);
|
|
178
|
+
const query = id => root.querySelector(`#bc-extension-${id}`);
|
|
179
|
+
let folder = '', busy = false, full = null, last = null, lastSetup = null, launching = false;
|
|
180
|
+
const pendingTabs = new Set(), failedTabs = new Set();
|
|
181
|
+
function setStatus(text, tone = '') {
|
|
182
|
+
const node = query('status'); node.textContent = text;
|
|
183
|
+
for (const name of STATUS_TONES) node.classList.remove(name);
|
|
184
|
+
if (tone) node.classList.add(`stg-badge-${tone}`);
|
|
185
|
+
}
|
|
186
|
+
async function api(action, body = {}) {
|
|
187
|
+
// `setup/status` is a read; every other action a POST.
|
|
188
|
+
const read = !action || action === 'setup/status';
|
|
189
|
+
const res = await fetch(`/api/browser/extension${action ? '/' + action : ''}`, read ? { signal } : { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-SynaBun-UI': '1' }, body: JSON.stringify(body), signal });
|
|
190
|
+
const value = await res.json(); if (!res.ok) throw new Error(value.error || t('restart')); return value;
|
|
191
|
+
}
|
|
192
|
+
const el = (tag, className, text) => { const node = document.createElement(tag); if (className) node.className = className; if (text != null) node.textContent = text; return node; };
|
|
193
|
+
// One tab: its title and safe address, and its one action.
|
|
194
|
+
function tabRow(tab, { action, label, aria, disabled }) {
|
|
195
|
+
void action; // take-back or stop-sharing: both end the tab's sharing or holding (revoke-tab)
|
|
196
|
+
const row = el('div', 'bc-ext-item'); row.dataset.handle = tab.handle;
|
|
197
|
+
const text = el('div', 'bc-ext-item-label');
|
|
198
|
+
const title = String(tab.title || '').trim() || c('untitledTab');
|
|
199
|
+
const name = el('span', 'bc-ext-item-title', title); name.title = title;
|
|
200
|
+
text.append(name, el('span', 'bc-ext-item-address', shownAddress(tab.url)));
|
|
201
|
+
const pending = pendingTabs.has(tab.handle);
|
|
202
|
+
const button = el('button', 'cli-detect-btn', pending ? c('busy') : label); button.type = 'button';
|
|
203
|
+
button.setAttribute('aria-label', aria); button.disabled = !!disabled || pending;
|
|
204
|
+
button.addEventListener('click', () => takeBack(tab.handle), { signal });
|
|
205
|
+
row.append(text, button);
|
|
206
|
+
if (failedTabs.has(tab.handle)) { const error = el('p', 'stg-help bc-ext-row-error', c('actionError')); error.setAttribute('role', 'alert'); row.append(error); }
|
|
207
|
+
return row;
|
|
208
|
+
}
|
|
209
|
+
function empty(node, text) { const p = el('p', 'stg-help bc-ext-empty', text); node.append(p); }
|
|
210
|
+
// The tabs: agents' tabs grouped by agent (Take back), and in restricted mode the shared tabs nobody holds yet (Stop
|
|
211
|
+
// sharing) and the shared sites (Remove). Rebuilt only when what they show changed, so a focused button stays.
|
|
212
|
+
let shownKey = '';
|
|
213
|
+
function showTabs(data, live) {
|
|
214
|
+
const tabs = Array.isArray(data?.tabs) ? data.tabs : [], sites = full ? [] : Array.isArray(data?.sites) ? data.sites : [];
|
|
215
|
+
const groups = groupByAgent(tabs), waiting = full ? [] : tabs.filter(tab => tab && !tab.owner);
|
|
216
|
+
const total = groups.reduce((sum, g) => sum + g.tabs.length, 0);
|
|
217
|
+
const key = JSON.stringify([full, live, groups.map(g => [g.owner, g.tabs.map(x => [x.handle, x.title, shownAddress(x.url)])]), waiting.map(x => [x.handle, x.title, shownAddress(x.url)]), sites, [...pendingTabs], [...failedTabs]]);
|
|
218
|
+
query('count').textContent = total ? String(total) : '';
|
|
219
|
+
const summary = query('summary');
|
|
220
|
+
summary.hidden = !total;
|
|
221
|
+
summary.textContent = !total ? '' : total === 1 ? c('oneTab') : groups.length === 1 ? c('oneAgent', { tabs: total }) : c('agentCount', { agents: groups.length, tabs: total });
|
|
222
|
+
const help = query('tabs-help'); help.hidden = !total; help.textContent = live ? help.dataset.liveText : help.dataset.staleText;
|
|
223
|
+
if (key === shownKey) return;
|
|
224
|
+
shownKey = key;
|
|
225
|
+
const list = query('tabs'); list.replaceChildren();
|
|
226
|
+
for (const group of groups) {
|
|
227
|
+
const box = el('div', 'bc-ext-agent'); box.dataset.owner = group.owner;
|
|
228
|
+
const head = el('div', 'bc-ext-agent-head');
|
|
229
|
+
const mark = el('span', 'bc-ext-agent-mark', group.id.slice(0, 2)); mark.setAttribute('aria-hidden', 'true');
|
|
230
|
+
const agent = c('unknownAgent', { id: group.id });
|
|
231
|
+
head.append(mark, el('span', 'bc-ext-agent-name', agent));
|
|
232
|
+
box.append(head);
|
|
233
|
+
for (const tab of group.tabs) {
|
|
234
|
+
const title = String(tab.title || '').trim() || c('untitledTab');
|
|
235
|
+
box.append(tabRow(tab, { action: 'take-back', label: t('takeBack'), aria: c('takeBackLabel', { title, agent }), disabled: !live }));
|
|
236
|
+
}
|
|
237
|
+
list.append(box);
|
|
238
|
+
}
|
|
239
|
+
if (waiting.length) {
|
|
240
|
+
const box = el('div', 'bc-ext-agent'); box.append(el('div', 'bc-ext-agent-head', c('sharedTabs')));
|
|
241
|
+
for (const tab of waiting) {
|
|
242
|
+
const title = String(tab.title || '').trim() || c('untitledTab');
|
|
243
|
+
box.append(tabRow(tab, { action: 'stop-sharing', label: c('stopSharing'), aria: c('stopSharingLabel', { title }), disabled: !live }));
|
|
244
|
+
}
|
|
245
|
+
list.append(box);
|
|
246
|
+
}
|
|
247
|
+
if (!total && !waiting.length && list.dataset.emptyText) empty(list, full ? list.dataset.emptyFullText : list.dataset.emptyText);
|
|
248
|
+
const siteList = query('sites'); siteList.replaceChildren();
|
|
249
|
+
for (const site of sites) {
|
|
250
|
+
const row = el('div', 'bc-ext-item');
|
|
251
|
+
const label = el('span', 'bc-ext-item-label'); label.append(el('code', 'bc-ext-item-site', site));
|
|
252
|
+
const button = el('button', 'cli-detect-btn', c('removeSite')); button.type = 'button';
|
|
253
|
+
button.setAttribute('aria-label', c('removeSiteLabel', { site }));
|
|
254
|
+
button.addEventListener('click', () => perform('revoke-site', { site }), { signal });
|
|
255
|
+
row.append(label, button); siteList.append(row);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
function showCode(code) {
|
|
259
|
+
const node = query('code');
|
|
260
|
+
if (code == null) { node.textContent = ''; return; }
|
|
261
|
+
const lead = el('span', 'bc-ext-code-lead', `${t('code')} `);
|
|
262
|
+
const value = el('strong', 'bc-ext-code-value', code);
|
|
263
|
+
const expiry = el('span', 'bc-ext-code-expiry', ` · ${t('expires')}`);
|
|
264
|
+
node.replaceChildren(lead, value, expiry);
|
|
265
|
+
}
|
|
266
|
+
// The mode as the server reports it: the dropdown, its sentence, the tabs part's title. `fullControl` missing is a
|
|
267
|
+
// server from before the mode: the section stays hidden and the card reads as it did.
|
|
268
|
+
function showMode(value, visible = true) {
|
|
269
|
+
full = typeof value === 'boolean' ? value : null;
|
|
270
|
+
const section = pane.querySelector('[data-extension-section="mode"]');
|
|
271
|
+
section.hidden = full === null || !visible;
|
|
272
|
+
if (full === null) return;
|
|
273
|
+
const chosen = full ? 'full' : 'restricted', input = query('mode'), dropdown = pane.querySelector('.bc-ext-mode');
|
|
274
|
+
input.value = chosen;
|
|
275
|
+
for (const item of dropdown.querySelectorAll('.cc-dropdown-item')) {
|
|
276
|
+
const on = item.dataset.value === chosen; item.classList.toggle('active', on);
|
|
277
|
+
if (on) dropdown.querySelector('.cc-dropdown-value').textContent = item.textContent;
|
|
278
|
+
}
|
|
279
|
+
const help = query('mode-help'); help.textContent = full ? help.dataset.fullText : help.dataset.restrictedText;
|
|
280
|
+
query('shared-title').textContent = t(full ? 'controlledTitle' : 'sharedTitle');
|
|
281
|
+
}
|
|
282
|
+
// The one-button setup ("Connect your browser"): shown only by a server that has it (`setup` in the status). Not
|
|
283
|
+
// paired, it is the card's main action; paired, it is the way to run the setup again (Reconnect while away,
|
|
284
|
+
// Reinstall while connected), lower in the card.
|
|
285
|
+
function showSetup(data, setup, state) {
|
|
286
|
+
const section = query('setup');
|
|
287
|
+
section.hidden = typeof data?.setup !== 'string';
|
|
288
|
+
if (section.hidden) return;
|
|
289
|
+
const running = setup?.state || data.setup;
|
|
290
|
+
section.dataset.state = running;
|
|
291
|
+
const again = !!data.paired && !['setup', 'pairing', 'unsupported', 'launching'].includes(state);
|
|
292
|
+
section.dataset.mode = again ? 'again' : 'connect';
|
|
293
|
+
const title = query('setup-title'), help = query('setup-help');
|
|
294
|
+
title.textContent = again ? title.dataset.againText : title.dataset.connectText;
|
|
295
|
+
help.textContent = again ? help.dataset.againText : help.dataset.connectText;
|
|
296
|
+
const start = query('setup-start');
|
|
297
|
+
start.textContent = data.connected ? start.dataset.reinstallText : data.paired ? start.dataset.reconnectText : start.dataset.connectText;
|
|
298
|
+
start.classList.toggle('bc-ext-primary', !data.paired);
|
|
299
|
+
start.disabled = launching;
|
|
300
|
+
const active = !['idle', 'connected'].includes(running);
|
|
301
|
+
start.hidden = ['waiting-for-extension', 'pairing'].includes(running);
|
|
302
|
+
query('setup-cancel').hidden = !active;
|
|
303
|
+
query('setup-reopen').hidden = running !== 'waiting-for-extension';
|
|
304
|
+
query('setup-default').hidden = again || active;
|
|
305
|
+
const name = setup?.browser?.name || '';
|
|
306
|
+
const known = ['waiting-for-extension', 'pairing', 'connected', 'unsupported'].includes(running);
|
|
307
|
+
query('setup-status').textContent = launching ? c('launching') : running === 'idle' ? '' : known ? tx(`browserExtension.setup.settings_${running.replace(/-/g, '_')}`, { browser: name })
|
|
308
|
+
: tx('browserExtension.setup.settings_error', { code: setup?.code || '' });
|
|
309
|
+
const alternatives = query('setup-alternatives'); alternatives.replaceChildren();
|
|
310
|
+
const others = running === 'unsupported' ? (setup?.installedBrowsers || []).filter(b => b?.supported && b.id !== setup?.browser?.id) : [];
|
|
311
|
+
for (const browser of others) {
|
|
312
|
+
const option = el('button', 'cli-detect-btn', tx('browserExtension.setup.openIn', { browser: browser.name })); option.type = 'button';
|
|
313
|
+
option.dataset.extensionAction = 'setup-open-in'; option.dataset.browser = browser.id;
|
|
314
|
+
alternatives.append(option);
|
|
315
|
+
}
|
|
316
|
+
alternatives.hidden = !others.length;
|
|
317
|
+
query('reload').hidden = !(data.reloadNeeded === true);
|
|
318
|
+
}
|
|
319
|
+
// The status at the top: a symbol, the word (Settings' badge), what it means, the one action that helps.
|
|
320
|
+
function showHead(state, data, error) {
|
|
321
|
+
const [tone, help] = HEAD[state] || HEAD.error;
|
|
322
|
+
pane.dataset.cardState = state;
|
|
323
|
+
query('head').dataset.tone = tone;
|
|
324
|
+
const modeWord = full === null ? '' : ` · ${t(full ? 'statusFull' : 'statusRestricted')}`;
|
|
325
|
+
if (error) setStatus(`${t('restart')} ${error}`, 'err');
|
|
326
|
+
else if (state === 'connected') setStatus(`${t('connected')}${modeWord}`, 'ok');
|
|
327
|
+
else if (state === 'disconnected') setStatus(`${t('disconnected')}${modeWord}`, 'warn');
|
|
328
|
+
else if (['setup', 'pairing', 'launching'].includes(state)) setStatus(c(state === 'setup' ? 'setupRunningTitle' : state, { browser: lastSetup?.browser?.name || '' }));
|
|
329
|
+
else if (state === 'unsupported') setStatus(c('unsupported'));
|
|
330
|
+
else setStatus(t('unpaired'));
|
|
331
|
+
query('status-help').textContent = c(help, { browser: lastSetup?.browser?.name || '' });
|
|
332
|
+
const actions = query('status-actions');
|
|
333
|
+
const resume = actions.querySelector('[data-extension-action="resume"]'), retry = actions.querySelector('[data-extension-action="retry"]');
|
|
334
|
+
resume.hidden = state !== 'disconnected'; retry.hidden = !error;
|
|
335
|
+
actions.hidden = resume.hidden && retry.hidden;
|
|
336
|
+
query('footer').hidden = !data?.paired;
|
|
337
|
+
query('files').hidden = !data?.paired;
|
|
338
|
+
}
|
|
339
|
+
function render(error = '') {
|
|
340
|
+
const data = last, state = cardState(data, lastSetup, { failed: !!error, launching });
|
|
341
|
+
if (data) {
|
|
342
|
+
folder = data.folder; query('folder').value = folder || ''; query('folder').title = folder || '';
|
|
343
|
+
const path = el('code', 'bc-ext-path-text', data.uploadFolder ?? ''); path.title = data.uploadFolder ?? '';
|
|
344
|
+
query('upload').replaceChildren(`${t('upload')} `, path);
|
|
345
|
+
}
|
|
346
|
+
const connected = !!data?.connected;
|
|
347
|
+
showMode(data?.fullControl, connected);
|
|
348
|
+
showSetup(data, lastSetup, state);
|
|
349
|
+
showHead(state, data, error);
|
|
350
|
+
// Full control: the server lists every tab of the browser; the card shows the ones agents hold. Sites are not
|
|
351
|
+
// shared in that mode. While the browser is away the last tabs stay, marked out of date, their actions off.
|
|
352
|
+
const section = pane.querySelector('[data-extension-section="shared"]');
|
|
353
|
+
section.hidden = !data || !(connected || (data.paired && (data.tabs || []).some(tab => tab.owner)));
|
|
354
|
+
showTabs(data, connected && !error);
|
|
355
|
+
}
|
|
356
|
+
async function refresh() {
|
|
357
|
+
const data = await api();
|
|
358
|
+
let setup = null;
|
|
359
|
+
if (typeof data.setup === 'string' && data.setup !== 'idle') { try { setup = await api('setup/status'); } catch { setup = null; } }
|
|
360
|
+
last = data; lastSetup = setup;
|
|
361
|
+
render();
|
|
362
|
+
}
|
|
363
|
+
async function takeBack(handle) {
|
|
364
|
+
if (pendingTabs.has(handle)) return;
|
|
365
|
+
pendingTabs.add(handle); failedTabs.delete(handle); render();
|
|
366
|
+
try { await api('revoke-tab', { tab: handle }); }
|
|
367
|
+
catch { failedTabs.add(handle); }
|
|
368
|
+
finally { pendingTabs.delete(handle); }
|
|
369
|
+
try { await refresh(); } catch (error) { if (!signal.aborted) render(error.message); }
|
|
370
|
+
}
|
|
371
|
+
// Confirmations: in the card itself (it lives inside the Settings dialog), Cancel focused first, Escape cancels, the
|
|
372
|
+
// focus returns to the control that asked.
|
|
373
|
+
let confirming = null;
|
|
374
|
+
function confirmFirst(kind, opener, then) {
|
|
375
|
+
const [title, body, ok] = CONFIRMS[kind];
|
|
376
|
+
const box = query('confirm');
|
|
377
|
+
query('confirm-title').textContent = c(title); query('confirm-body').textContent = c(body);
|
|
378
|
+
const button = query('confirm-ok'); button.textContent = c(ok); button.dataset.kind = kind;
|
|
379
|
+
box.dataset.kind = kind;
|
|
380
|
+
// Next to what asked: after the part of the card that holds the control.
|
|
381
|
+
let part = opener; while (part && part.parentNode !== pane) part = part.parentNode;
|
|
382
|
+
if (part && part !== box && part.nextSibling !== box) part.after(box);
|
|
383
|
+
confirming = { then, opener };
|
|
384
|
+
box.hidden = false;
|
|
385
|
+
query('confirm-cancel').focus?.();
|
|
386
|
+
}
|
|
387
|
+
function closeConfirm(run) {
|
|
388
|
+
const box = query('confirm'), pending = confirming;
|
|
389
|
+
confirming = null; box.hidden = true;
|
|
390
|
+
if (!run && pending?.cancelled) pending.cancelled();
|
|
391
|
+
if (pending?.opener?.isConnected && !pending.opener.hidden) pending.opener.focus?.();
|
|
392
|
+
if (run && pending) pending.then();
|
|
393
|
+
}
|
|
394
|
+
let queuedMode = null;
|
|
395
|
+
async function perform(action, body) {
|
|
396
|
+
// A mode switch made while a refresh runs is not lost: it runs right after.
|
|
397
|
+
if (busy) { if (action === 'mode') queuedMode = body; return; }
|
|
398
|
+
busy = true;
|
|
399
|
+
try {
|
|
400
|
+
if (action === 'copy') { await navigator.clipboard.writeText(folder); }
|
|
401
|
+
else if (action === 'setup-start' || action === 'setup-open-in') {
|
|
402
|
+
launching = true; render();
|
|
403
|
+
try { await api('setup/start', action === 'setup-open-in' ? { browser: body?.browser } : {}); } finally { launching = false; }
|
|
404
|
+
}
|
|
405
|
+
else if (action === 'setup-cancel') await api('setup/cancel', {});
|
|
406
|
+
else if (action === 'setup-reopen') await api('setup/reopen', {});
|
|
407
|
+
else if (!['refresh', 'retry'].includes(action)) {
|
|
408
|
+
const data = await api(action, body || (action === 'pair' ? { port: Number(query('port').value) } : {}));
|
|
409
|
+
if (action !== 'mode') showCode(action === 'pair' ? data.code : null);
|
|
410
|
+
if (action === 'pair') setTimeout(() => { if (!signal.aborted) showCode(null); }, 120000);
|
|
411
|
+
}
|
|
412
|
+
await refresh();
|
|
413
|
+
} catch (error) { if (!signal.aborted) render(error.message); }
|
|
414
|
+
finally {
|
|
415
|
+
busy = false;
|
|
416
|
+
if (queuedMode) { const next = queuedMode; queuedMode = null; if (next.fullControl !== full) void perform('mode', next); }
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
// The owner's mode switch: the dropdown writes its hidden input and fires `change`; the change is confirmed first,
|
|
420
|
+
// and a cancelled one puts the dropdown back.
|
|
421
|
+
query('mode').addEventListener('change', () => {
|
|
422
|
+
const next = query('mode').value === 'full';
|
|
423
|
+
if (next === full) return;
|
|
424
|
+
const trigger = pane.querySelector('.bc-ext-mode .cc-dropdown-trigger'), current = full;
|
|
425
|
+
confirmFirst(next ? 'full' : 'restrict', trigger, () => perform('mode', { fullControl: next }));
|
|
426
|
+
confirming.cancelled = () => showMode(current, true);
|
|
427
|
+
}, { signal });
|
|
428
|
+
pane.addEventListener('click', event => {
|
|
429
|
+
const target = event.target.closest('[data-extension-action]'), action = target?.dataset.extensionAction;
|
|
430
|
+
if (!action) return;
|
|
431
|
+
if (action === 'confirm-cancel') { closeConfirm(false); return; }
|
|
432
|
+
if (action === 'confirm-ok') { closeConfirm(true); return; }
|
|
433
|
+
if (action === 'disconnect' || action === 'revoke') { confirmFirst(action, target, () => perform(action)); return; }
|
|
434
|
+
void perform(action, action === 'setup-open-in' ? { browser: target.dataset.browser } : undefined);
|
|
435
|
+
}, { signal });
|
|
436
|
+
pane.addEventListener('keydown', event => {
|
|
437
|
+
if (event.key === 'Escape' && confirming) { event.preventDefault(); event.stopPropagation(); closeConfirm(false); }
|
|
438
|
+
}, { signal });
|
|
439
|
+
const mode = root.querySelector('#bc-connectMode');
|
|
440
|
+
const show = () => { pane.hidden = mode?.value !== 'extension'; if (!pane.hidden) void perform('refresh'); };
|
|
441
|
+
mode?.addEventListener('change', show, { signal });
|
|
442
|
+
root.querySelectorAll('.bc-dropdown[data-for="bc-connectMode"] .cc-dropdown-item').forEach(item => item.addEventListener('click', show, { signal }));
|
|
443
|
+
const timer = setInterval(() => { if (!pane.hidden && !busy) void perform('refresh'); }, 3000);
|
|
444
|
+
signal.addEventListener('abort', () => clearInterval(timer), { once: true });
|
|
445
|
+
show(); return show;
|
|
446
|
+
}
|
|
@@ -106,6 +106,7 @@ export const SETTINGS_PAGES = [
|
|
|
106
106
|
sections: [
|
|
107
107
|
{ id: 'stg-sec-default-tools', key: 'default_tools', state: 'open' },
|
|
108
108
|
{ id: 'stg-sec-added-servers', key: 'added_servers', state: 'open' },
|
|
109
|
+
{ id: 'stg-sec-ml-default', key: 'morelogin_default', state: 'open' },
|
|
109
110
|
{ id: 'stg-sec-ml-connection', key: 'morelogin_connection', state: 'open' },
|
|
110
111
|
{ id: 'stg-sec-ml-profiles', key: 'morelogin_profiles', state: 'open' },
|
|
111
112
|
{ id: 'stg-sec-ml-credentials', key: 'morelogin_credentials', state: 'advanced' },
|
|
@@ -265,19 +266,20 @@ export const SETTINGS_CONTROLS = {
|
|
|
265
266
|
'stg-sec-workspaces': 'PRJ013 PRJ007 PRJ008 PRJ009 PRJ010 PRJ011 PRJ014 PRJ015 PRJ016 PRJ017 PRJ018',
|
|
266
267
|
'project-storage-manager': 'PRJ001 PRJ012 PRJ002 PRJ003 PRJ004 PRJ005 PRJ006',
|
|
267
268
|
'setup-browser': 'BRW003 BRW001 BRW002 BRW084 BRW004 BRW005 BRW006 BRW007 BRW008 BRW009',
|
|
268
|
-
'bcg-profiles': 'BRW011 BRW012
|
|
269
|
+
'bcg-profiles': 'BRW011 BRW012 BRW083 BRW010 BRW015 BRW016 BRW017 BRW018 BRW019 BRW020',
|
|
269
270
|
'bcg-owner-access': 'BRW087',
|
|
270
271
|
'bcg-identity': 'BRW021 BRW022 BRW023 BRW024 BRW025',
|
|
271
272
|
'bcg-viewport': 'BRW026 BRW027 BRW028 BRW029 BRW030 BRW031 BRW032',
|
|
272
273
|
'bcg-advanced': 'BRW033 BRW034 BRW035 BRW036 BRW037 BRW038 BRW039 BRW040 BRW041 BRW042 BRW043 BRW044 BRW045 BRW046 BRW047 BRW048 BRW049 BRW050 BRW051 BRW052 BRW053 BRW054 BRW055 BRW056 BRW057 BRW058 BRW059 BRW060 BRW061 BRW062 BRW063 BRW064 BRW065 BRW066 BRW067 BRW068 BRW069 BRW070 BRW071 BRW072 BRW073 BRW074 BRW075 BRW076 BRW077 BRW078 BRW079 BRW080',
|
|
273
274
|
'stg-sec-default-tools': 'MCP022 MCP024 MCP005 MCP004',
|
|
274
275
|
'stg-sec-added-servers': 'MCP026 MCP006 MCP007 MCP008 MCP009 MCP010 MCP011 MCP012 MCP013 MCP014 MCP015 MCP027 MCP016 MCP017 MCP018 MCP019 MCP020 MCP021',
|
|
276
|
+
'stg-sec-ml-default': 'ML037 ML038 ML039',
|
|
275
277
|
'stg-sec-ml-connection': 'ML015 ML001 ML002 ML003',
|
|
276
278
|
'stg-sec-ml-profiles': 'ML004 ML020 ML005 ML006 ML016 ML017 ML018 ML019 ML021 ML022 ML023 ML024 ML025 ML026 ML027 ML028 ML029 ML030 ML031 ML032 ML033 ML034 ML035 ML036',
|
|
277
279
|
'stg-sec-ml-credentials': 'ML007 ML008 ML009 ML010 ML011',
|
|
278
280
|
'stg-sec-ml-server': 'ML012 ML013 ML014',
|
|
279
281
|
'stg-sec-skills': 'SKL004 SKL001',
|
|
280
|
-
'stg-sec-tool-permissions': 'PER012 PER001 PER002 PER003 PER004 PER005 PER006 PER008 PER009 PER010 PER011',
|
|
282
|
+
'stg-sec-tool-permissions': 'PER012 PER013 PER001 PER002 PER003 PER004 PER005 PER006 PER008 PER009 PER010 PER011',
|
|
281
283
|
'stg-sec-editor-editing': 'EDT014 EDT015 EDT016 EDT017 EDT018 EDT019 EDT020 EDT021 EDT022 EDT023',
|
|
282
284
|
'stg-sec-editor-ai': 'EDT001 EDT002 EDT003 EDT004 EDT005 EDT006 EDT007 EDT008 EDT009 EDT010 EDT011 EDT012 EDT013',
|
|
283
285
|
'stg-sec-greetings': 'AUT058 AUT059 AUT060',
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// What Settings → Connected tools → MoreLogin says about MoreLogin's daily start limit, without the page.
|
|
2
|
+
// No imports: `node --test` loads it (tests/morelogin-start-cooldown.test.mjs).
|
|
3
|
+
//
|
|
4
|
+
// When MoreLogin refuses to start a profile because its plan's daily launches are used up, SynaBun holds every
|
|
5
|
+
// further start of that profile until MoreLogin's day resets (lib/morelogin-start-cooldown.js) and lists the held
|
|
6
|
+
// profiles as `startCooldowns` in GET /api/browser/morelogin-envs and GET /api/morelogin/status:
|
|
7
|
+
// [{ envId, name, resetAt (ISO), resetLocal, since, apiCode }]. The page shows one line per profile:
|
|
8
|
+
// "Start limit reached for <profile name>, resets <local time>".
|
|
9
|
+
|
|
10
|
+
/** The reset time in the viewer's own time zone: the time alone when it is today, else with the day. */
|
|
11
|
+
export function formatResetTime(resetAt, { now = Date.now(), locale = undefined } = {}) {
|
|
12
|
+
const at = new Date(resetAt);
|
|
13
|
+
if (Number.isNaN(at.getTime())) return '';
|
|
14
|
+
const today = new Date(now);
|
|
15
|
+
const sameDay = at.getFullYear() === today.getFullYear() && at.getMonth() === today.getMonth() && at.getDate() === today.getDate();
|
|
16
|
+
const options = sameDay
|
|
17
|
+
? { hour: '2-digit', minute: '2-digit' }
|
|
18
|
+
: { weekday: 'short', day: 'numeric', month: 'short', hour: '2-digit', minute: '2-digit' };
|
|
19
|
+
try { return new Intl.DateTimeFormat(locale, options).format(at); }
|
|
20
|
+
catch { return at.toLocaleString(); }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The held profiles still in force at `now`, each with the name to show and its reset time:
|
|
25
|
+
* [{ envId, name, resetAt, time }]. The name is the server's, else the one in `envs` (the picker's list), else the id.
|
|
26
|
+
*/
|
|
27
|
+
export function startLimitNotes(cooldowns, envs = [], { now = Date.now(), locale = undefined } = {}) {
|
|
28
|
+
if (!Array.isArray(cooldowns)) return [];
|
|
29
|
+
const names = new Map((Array.isArray(envs) ? envs : []).filter((e) => e && e.id != null && e.name).map((e) => [String(e.id), String(e.name)]));
|
|
30
|
+
const out = [];
|
|
31
|
+
for (const c of cooldowns) {
|
|
32
|
+
if (!c || !c.envId) continue;
|
|
33
|
+
const until = Date.parse(c.resetAt);
|
|
34
|
+
if (!Number.isFinite(until) || until <= now) continue;
|
|
35
|
+
out.push({ envId: String(c.envId), name: c.name || names.get(String(c.envId)) || String(c.envId), resetAt: c.resetAt, time: formatResetTime(c.resetAt, { now, locale }) });
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// A profile closed outside SynaBun (lib/morelogin-outside-close.js): SynaBun does not start it again for any session,
|
|
41
|
+
// run, agent or script until the owner starts it (MoreLogin, or Start here), a new scheduled run fires, or MoreLogin's
|
|
42
|
+
// daily reset (`holdUntil`). Listed as `closedOutside` in the same answers:
|
|
43
|
+
// [{ envId, name, closedAt (ISO), closedLocal, holdUntil (ISO), holdUntilLocal, runs }]. The page shows one line per
|
|
44
|
+
// profile: "Closed outside SynaBun at <local time>; SynaBun won't reopen <profile name> until you start it".
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The closes still in force at `now`, each with the name to show and the close time:
|
|
48
|
+
* [{ envId, name, closedAt, time }]. The name is the server's, else the one in `envs`, else the id.
|
|
49
|
+
*/
|
|
50
|
+
export function closedOutsideNotes(closes, envs = [], { now = Date.now(), locale = undefined } = {}) {
|
|
51
|
+
if (!Array.isArray(closes)) return [];
|
|
52
|
+
const names = new Map((Array.isArray(envs) ? envs : []).filter((e) => e && e.id != null && e.name).map((e) => [String(e.id), String(e.name)]));
|
|
53
|
+
const out = [];
|
|
54
|
+
for (const c of closes) {
|
|
55
|
+
if (!c || !c.envId) continue;
|
|
56
|
+
const until = Date.parse(c.holdUntil);
|
|
57
|
+
if (Number.isFinite(until) && until <= now) continue;
|
|
58
|
+
const at = Date.parse(c.closedAt);
|
|
59
|
+
if (!Number.isFinite(at)) continue;
|
|
60
|
+
out.push({ envId: String(c.envId), name: c.name || names.get(String(c.envId)) || String(c.envId), closedAt: c.closedAt, time: formatResetTime(c.closedAt, { now, locale }) });
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════
|
|
2
|
+
// SynaBun Neural Interface — Settings → Tool permissions: the switch for every tool
|
|
3
|
+
// ═══════════════════════════════════════════
|
|
4
|
+
// The section's header has one switch for all of its groups, next to the total
|
|
5
|
+
// (ui-settings.js draws it and sends what this module says). It has three
|
|
6
|
+
// states, read from the tool switches themselves:
|
|
7
|
+
//
|
|
8
|
+
// on every tool is on a click switches them all off
|
|
9
|
+
// off every tool is off a click switches them all on
|
|
10
|
+
// mixed some are on a click switches them all on
|
|
11
|
+
//
|
|
12
|
+
// The groups of this section only: the social tools have their own section and
|
|
13
|
+
// their own "All". One request when the server takes several groups at once
|
|
14
|
+
// (`capabilities` of GET /api/claude-code/tool-permissions has `categories`);
|
|
15
|
+
// one request per group, in order, for a server from before that (public/ is
|
|
16
|
+
// reloaded at any time, the server only on a restart).
|
|
17
|
+
// No DOM, no imports: runs under node --test as well.
|
|
18
|
+
|
|
19
|
+
const K = 'settings.redesign.permissions.master';
|
|
20
|
+
|
|
21
|
+
/** 'on' | 'off' | 'mixed', or 'none' when the section has no tools. */
|
|
22
|
+
export function masterState(on, total) {
|
|
23
|
+
const all = Number(total) || 0;
|
|
24
|
+
const count = Math.max(0, Math.min(all, Number(on) || 0));
|
|
25
|
+
if (all <= 0) return 'none';
|
|
26
|
+
if (count === all) return 'on';
|
|
27
|
+
return count === 0 ? 'off' : 'mixed';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* What the switch shows and what a click asks for.
|
|
32
|
+
* @param {{ on: number, total: number }} counts
|
|
33
|
+
* @param {{ tx: (key: string, params?: object) => string }} o
|
|
34
|
+
* @returns {{ state: string, checked: 'true' | 'false' | 'mixed', enable: boolean, title: string, shown: boolean }}
|
|
35
|
+
*/
|
|
36
|
+
export function masterView({ on = 0, total = 0 } = {}, { tx = (key) => key } = {}) {
|
|
37
|
+
const state = masterState(on, total);
|
|
38
|
+
const shown = state !== 'none';
|
|
39
|
+
return {
|
|
40
|
+
state,
|
|
41
|
+
shown,
|
|
42
|
+
checked: state === 'on' ? 'true' : state === 'mixed' ? 'mixed' : 'false',
|
|
43
|
+
// Everything on is the only state a click switches off: a mixed list is completed, never emptied.
|
|
44
|
+
enable: state !== 'on',
|
|
45
|
+
title: shown ? tx(`${K}.${state}`, { on: Math.max(0, Number(on) || 0), total: Number(total) || 0 }) : '',
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** How many tools of these groups are on: `{ on, total }`. A tool the server did not answer for counts as on, as its row is drawn. */
|
|
50
|
+
export function countTools(categories, perms) {
|
|
51
|
+
let on = 0, total = 0;
|
|
52
|
+
for (const cat of Array.isArray(categories) ? categories : []) {
|
|
53
|
+
for (const tool of Array.isArray(cat?.tools) ? cat.tools : []) {
|
|
54
|
+
total++;
|
|
55
|
+
if ((perms || {})[tool.key] !== false) on++;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return { on, total };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The bodies of the PUT /api/claude-code/tool-permissions requests that switch every tool of `categories`.
|
|
63
|
+
* @param {{ categories: string[], enabled: boolean, capabilities?: string[] }} o
|
|
64
|
+
*/
|
|
65
|
+
export function masterRequests({ categories, enabled, capabilities } = {}) {
|
|
66
|
+
const ids = [...new Set((Array.isArray(categories) ? categories : []).filter((id) => typeof id === 'string' && id))];
|
|
67
|
+
if (!ids.length || typeof enabled !== 'boolean') return [];
|
|
68
|
+
if (Array.isArray(capabilities) && capabilities.includes('categories')) return [{ categories: ids, enabled }];
|
|
69
|
+
return ids.map((category) => ({ category, enabled }));
|
|
70
|
+
}
|