synabun 2.2.1 → 2.3.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 +53 -0
- package/README.md +1 -1
- package/docs/whatsapp.md +52 -20
- package/hooks/claude-code/pre-websearch.mjs +4 -1
- package/hooks/claude-code/prompt-submit.mjs +7 -0
- package/lib/mcp-build.js +519 -0
- package/lib/mcp-dist.js +10 -4
- package/lib/release-scan.mjs +23 -10
- package/lib/server-supervisor.js +7 -1
- package/lib/virustotal.mjs +146 -40
- package/mcp-server/dist/http.d.ts +57 -0
- package/mcp-server/dist/http.d.ts.map +1 -1
- package/mcp-server/dist/http.js +128 -18
- package/mcp-server/dist/http.js.map +1 -1
- package/mcp-server/dist/index.d.ts.map +1 -1
- package/mcp-server/dist/index.js +14 -9
- package/mcp-server/dist/index.js.map +1 -1
- package/mcp-server/dist/services/browser-route-flow.d.ts +119 -0
- package/mcp-server/dist/services/browser-route-flow.d.ts.map +1 -0
- package/mcp-server/dist/services/browser-route-flow.js +340 -0
- package/mcp-server/dist/services/browser-route-flow.js.map +1 -0
- package/mcp-server/dist/services/desktop-client.js +2 -2
- package/mcp-server/dist/services/desktop-client.js.map +1 -1
- package/mcp-server/dist/services/embedding-service.d.ts.map +1 -1
- package/mcp-server/dist/services/embedding-service.js +2 -1
- package/mcp-server/dist/services/embedding-service.js.map +1 -1
- package/mcp-server/dist/services/identity.d.ts +66 -3
- package/mcp-server/dist/services/identity.d.ts.map +1 -1
- package/mcp-server/dist/services/identity.js +61 -4
- package/mcp-server/dist/services/identity.js.map +1 -1
- package/mcp-server/dist/services/neural-interface.d.ts +133 -1
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +630 -64
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/services/tool-catalog.js +2 -2
- package/mcp-server/dist/services/tool-catalog.js.map +1 -1
- package/mcp-server/dist/tools/agents.d.ts +3 -2
- package/mcp-server/dist/tools/agents.d.ts.map +1 -1
- package/mcp-server/dist/tools/agents.js +6 -4
- package/mcp-server/dist/tools/agents.js.map +1 -1
- package/mcp-server/dist/tools/bluesky.d.ts +20 -7
- package/mcp-server/dist/tools/bluesky.d.ts.map +1 -1
- package/mcp-server/dist/tools/bluesky.js +147 -45
- package/mcp-server/dist/tools/bluesky.js.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts +13 -2
- package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.js +153 -18
- package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
- package/mcp-server/dist/tools/browser-cheatsheet.d.ts +2 -0
- package/mcp-server/dist/tools/browser-cheatsheet.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-cheatsheet.js +3 -0
- package/mcp-server/dist/tools/browser-cheatsheet.js.map +1 -1
- package/mcp-server/dist/tools/browser-navigate.d.ts +3 -3
- package/mcp-server/dist/tools/browser-navigate.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-navigate.js +19 -16
- package/mcp-server/dist/tools/browser-navigate.js.map +1 -1
- package/mcp-server/dist/tools/browser-observe.d.ts +2 -1
- package/mcp-server/dist/tools/browser-observe.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-observe.js +61 -20
- package/mcp-server/dist/tools/browser-observe.js.map +1 -1
- package/mcp-server/dist/tools/morelogin.d.ts +13 -3
- package/mcp-server/dist/tools/morelogin.d.ts.map +1 -1
- package/mcp-server/dist/tools/morelogin.js +82 -19
- package/mcp-server/dist/tools/morelogin.js.map +1 -1
- package/mcp-server/dist/tools/skill-tools.d.ts +4 -4
- package/mcp-server/dist/tools/youtube/helpers.d.ts +1 -0
- package/mcp-server/dist/tools/youtube/helpers.d.ts.map +1 -1
- package/mcp-server/dist/tools/youtube/helpers.js +1 -1
- package/mcp-server/dist/tools/youtube/helpers.js.map +1 -1
- package/mcp-server/dist/tools/youtube/upload.d.ts.map +1 -1
- package/mcp-server/dist/tools/youtube/upload.js +225 -88
- package/mcp-server/dist/tools/youtube/upload.js.map +1 -1
- package/mcp-server/package-lock.json +2 -2
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/http.ts +135 -17
- package/mcp-server/src/index.ts +15 -9
- package/mcp-server/src/services/browser-route-flow.ts +403 -0
- package/mcp-server/src/services/desktop-client.ts +2 -2
- package/mcp-server/src/services/embedding-service.ts +2 -1
- package/mcp-server/src/services/identity.ts +80 -4
- package/mcp-server/src/services/neural-interface.ts +648 -73
- package/mcp-server/src/services/tool-catalog.ts +2 -2
- package/mcp-server/src/tools/agents.ts +8 -4
- package/mcp-server/src/tools/bluesky.ts +164 -51
- package/mcp-server/src/tools/browser-advanced.ts +142 -17
- package/mcp-server/src/tools/browser-cheatsheet.ts +3 -0
- package/mcp-server/src/tools/browser-navigate.ts +19 -16
- package/mcp-server/src/tools/browser-observe.ts +62 -20
- package/mcp-server/src/tools/morelogin.ts +82 -19
- package/mcp-server/src/tools/youtube/helpers.ts +2 -2
- package/mcp-server/src/tools/youtube/upload.ts +218 -99
- package/neural-interface/i18n/en.json +655 -123
- package/neural-interface/i18n/pt-BR.json +542 -10
- package/neural-interface/lib/assistant-api.js +90 -23
- package/neural-interface/lib/assistant-brains/claude.js +5 -0
- package/neural-interface/lib/assistant-catalog.js +134 -3
- package/neural-interface/lib/assistant-dispatch.js +97 -1
- package/neural-interface/lib/assistant-persona.js +15 -7
- package/neural-interface/lib/assistant-router.js +6 -4
- package/neural-interface/lib/assistant-runtime.js +18 -1
- package/neural-interface/lib/assistant-task-prompt.js +5 -0
- package/neural-interface/lib/assistant-tools.js +10 -1
- package/neural-interface/lib/automation-approval.js +249 -0
- package/neural-interface/lib/automation-browser-owner-access.js +82 -0
- package/neural-interface/lib/backup-service.js +16 -1
- package/neural-interface/lib/browser-automation-routes.js +84 -0
- package/neural-interface/lib/browser-background-tab.js +72 -3
- package/neural-interface/lib/browser-execution.js +16 -3
- package/neural-interface/lib/browser-extraction.js +106 -45
- package/neural-interface/lib/browser-owner.js +48 -0
- package/neural-interface/lib/browser-profile-choices.js +143 -0
- package/neural-interface/lib/browser-profiles.js +142 -0
- package/neural-interface/lib/browser-session-close.js +84 -0
- package/neural-interface/lib/browser-start-handoff.js +202 -0
- package/neural-interface/lib/browser-tab-recovery.js +153 -0
- package/neural-interface/lib/browser-tool-policy.js +23 -4
- package/neural-interface/lib/browser-wedge-retire.js +64 -0
- package/neural-interface/lib/chromium-on-device-model.js +67 -0
- package/neural-interface/lib/claude-agent-bridge.js +43 -5
- package/neural-interface/lib/claude-background-hold.js +239 -0
- package/neural-interface/lib/claude-model-catalog.js +12 -0
- package/neural-interface/lib/effort-levels.js +28 -2
- package/neural-interface/lib/exec-loop-command.js +8 -0
- package/neural-interface/lib/http-guards.js +11 -6
- package/neural-interface/lib/local-profile-proxy.js +362 -0
- package/neural-interface/lib/local-profiles.js +929 -0
- package/neural-interface/lib/loop-logger.js +31 -5
- package/neural-interface/lib/maritaca/api.js +179 -0
- package/neural-interface/lib/maritaca/attachments.js +44 -0
- package/neural-interface/lib/maritaca/client.js +362 -0
- package/neural-interface/lib/maritaca/key-store.js +122 -0
- package/neural-interface/lib/maritaca/models.js +181 -0
- package/neural-interface/lib/maritaca/modes.js +39 -0
- package/neural-interface/lib/maritaca/opencode-proxy.js +236 -0
- package/neural-interface/lib/maritaca/opencode-stream.js +345 -0
- package/neural-interface/lib/maritaca/opencode.js +218 -0
- package/neural-interface/lib/maritaca/panel-bridge.js +273 -0
- package/neural-interface/lib/maritaca/sessions.js +198 -0
- package/neural-interface/lib/mcp-external-servers.js +37 -10
- package/neural-interface/lib/morelogin-agent-profiles.js +149 -0
- package/neural-interface/lib/morelogin.js +278 -14
- package/neural-interface/lib/native-loop-providers.js +124 -11
- package/neural-interface/lib/native-loop-runtime.js +112 -11
- package/neural-interface/lib/owner-authority.js +137 -43
- package/neural-interface/lib/page-session.js +111 -27
- package/neural-interface/lib/peer-identity.js +263 -43
- package/neural-interface/lib/provider-panel-api-key-auth.js +7 -2
- package/neural-interface/lib/pty-host/core.js +36 -0
- package/neural-interface/lib/pty-host/protocol.js +2 -0
- package/neural-interface/lib/request-gate.js +2 -0
- package/neural-interface/lib/skills/api-v2.js +13 -2
- package/neural-interface/lib/skills/creation-api.js +3 -1
- package/neural-interface/lib/skills/evals-api.js +5 -1
- package/neural-interface/lib/social-write-pacing.js +151 -0
- package/neural-interface/lib/system-activity.js +1 -1
- package/neural-interface/lib/terminal-token-redaction.js +293 -0
- package/neural-interface/lib/terminal-tokens.js +436 -0
- package/neural-interface/lib/worker-mcp-channel.js +45 -10
- package/neural-interface/package-lock.json +3 -2
- package/neural-interface/package.json +2 -1
- package/neural-interface/public/assets/mascot/README.md +11 -0
- package/neural-interface/public/assets/mascot/ask.gif +0 -0
- package/neural-interface/public/assets/mascot/ask.png +0 -0
- package/neural-interface/public/assets/mascot/blocked.gif +0 -0
- package/neural-interface/public/assets/mascot/blocked.png +0 -0
- package/neural-interface/public/assets/mascot/budget.gif +0 -0
- package/neural-interface/public/assets/mascot/budget.png +0 -0
- package/neural-interface/public/assets/mascot/computer.gif +0 -0
- package/neural-interface/public/assets/mascot/computer.png +0 -0
- package/neural-interface/public/assets/mascot/edit.gif +0 -0
- package/neural-interface/public/assets/mascot/edit.png +0 -0
- package/neural-interface/public/assets/mascot/error.gif +0 -0
- package/neural-interface/public/assets/mascot/error.png +0 -0
- package/neural-interface/public/assets/mascot/hover-attention.gif +0 -0
- package/neural-interface/public/assets/mascot/hover-attention.png +0 -0
- package/neural-interface/public/assets/mascot/idle-hero.gif +0 -0
- package/neural-interface/public/assets/mascot/idle-hero.png +0 -0
- package/neural-interface/public/assets/mascot/idle.gif +0 -0
- package/neural-interface/public/assets/mascot/idle.png +0 -0
- package/neural-interface/public/assets/mascot/manifest.json +254 -0
- package/neural-interface/public/assets/mascot/mcp.gif +0 -0
- package/neural-interface/public/assets/mascot/mcp.png +0 -0
- package/neural-interface/public/assets/mascot/memory.gif +0 -0
- package/neural-interface/public/assets/mascot/memory.png +0 -0
- package/neural-interface/public/assets/mascot/offline.gif +0 -0
- package/neural-interface/public/assets/mascot/offline.png +0 -0
- package/neural-interface/public/assets/mascot/pick.gif +0 -0
- package/neural-interface/public/assets/mascot/pick.png +0 -0
- package/neural-interface/public/assets/mascot/plan.gif +0 -0
- package/neural-interface/public/assets/mascot/plan.png +0 -0
- package/neural-interface/public/assets/mascot/present.gif +0 -0
- package/neural-interface/public/assets/mascot/present.png +0 -0
- package/neural-interface/public/assets/mascot/project.gif +0 -0
- package/neural-interface/public/assets/mascot/project.png +0 -0
- package/neural-interface/public/assets/mascot/read.gif +0 -0
- package/neural-interface/public/assets/mascot/read.png +0 -0
- package/neural-interface/public/assets/mascot/runs.gif +0 -0
- package/neural-interface/public/assets/mascot/runs.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/automation.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/automation.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/browser.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/browser.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/code.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/code.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/complex.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/complex.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/computer.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/computer.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/design.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/design.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/edit.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/edit.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/generic.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/generic.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/image_gen.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/image_gen.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/manifest.json +173 -0
- package/neural-interface/public/assets/mascot/scenes/memory.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/memory.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/quick.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/quick.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/read.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/read.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/research.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/research.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/review.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/review.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/search.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/search.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/shell.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/shell.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/thinking.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/thinking.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/video_gen.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/video_gen.png +0 -0
- package/neural-interface/public/assets/mascot/scenes/web.gif +0 -0
- package/neural-interface/public/assets/mascot/scenes/web.png +0 -0
- package/neural-interface/public/assets/mascot/search.gif +0 -0
- package/neural-interface/public/assets/mascot/search.png +0 -0
- package/neural-interface/public/assets/mascot/shell.gif +0 -0
- package/neural-interface/public/assets/mascot/shell.png +0 -0
- package/neural-interface/public/assets/mascot/skill.gif +0 -0
- package/neural-interface/public/assets/mascot/skill.png +0 -0
- package/neural-interface/public/assets/mascot/sleep.gif +0 -0
- package/neural-interface/public/assets/mascot/sleep.png +0 -0
- package/neural-interface/public/assets/mascot/subagent.gif +0 -0
- package/neural-interface/public/assets/mascot/subagent.png +0 -0
- package/neural-interface/public/assets/mascot/success.gif +0 -0
- package/neural-interface/public/assets/mascot/success.png +0 -0
- package/neural-interface/public/assets/mascot/think.gif +0 -0
- package/neural-interface/public/assets/mascot/think.png +0 -0
- package/neural-interface/public/assets/mascot/wait.gif +0 -0
- package/neural-interface/public/assets/mascot/wait.png +0 -0
- package/neural-interface/public/assets/mascot/watch.gif +0 -0
- package/neural-interface/public/assets/mascot/watch.png +0 -0
- package/neural-interface/public/assets/mascot/web.gif +0 -0
- package/neural-interface/public/assets/mascot/web.png +0 -0
- package/neural-interface/public/onboarding.html +14 -1
- package/neural-interface/public/shared/agent-runtime-options.js +49 -8
- package/neural-interface/public/shared/agy/agy-panel.js +2 -2
- package/neural-interface/public/shared/agy/agy-render.js +41 -1
- package/neural-interface/public/shared/agy/agy-styles.js +5 -0
- package/neural-interface/public/shared/api.js +5 -4
- package/neural-interface/public/shared/assistant/asst-ask-styles.js +8 -8
- package/neural-interface/public/shared/assistant/asst-ask.js +1 -1
- package/neural-interface/public/shared/assistant/asst-brain-picker.js +99 -9
- package/neural-interface/public/shared/assistant/asst-computer.js +47 -2
- package/neural-interface/public/shared/assistant/asst-control.js +1 -1
- package/neural-interface/public/shared/assistant/asst-limit-wait.js +7 -5
- package/neural-interface/public/shared/assistant/asst-panel.js +13 -5
- package/neural-interface/public/shared/assistant/asst-rack-styles.js +4 -4
- package/neural-interface/public/shared/assistant/asst-render.js +16 -10
- package/neural-interface/public/shared/assistant/asst-route-models.js +64 -4
- package/neural-interface/public/shared/assistant/asst-route.js +24 -7
- package/neural-interface/public/shared/assistant/asst-routes-editor.js +154 -39
- package/neural-interface/public/shared/assistant/asst-run-stage.js +3 -3
- package/neural-interface/public/shared/assistant/asst-scene-styles.js +8 -111
- package/neural-interface/public/shared/assistant/asst-scenes.js +46 -318
- package/neural-interface/public/shared/assistant/asst-sidepanel.js +2 -2
- package/neural-interface/public/shared/assistant/asst-state.js +72 -2
- package/neural-interface/public/shared/assistant/asst-styles.js +60 -15
- package/neural-interface/public/shared/automation-approval-view.js +75 -0
- package/neural-interface/public/shared/cdx/cdx-panel.js +2 -2
- package/neural-interface/public/shared/cdx/cdx-render.js +73 -7
- package/neural-interface/public/shared/cdx/cdx-tabs.js +3 -3
- package/neural-interface/public/shared/context-menu-model.js +2 -0
- package/neural-interface/public/shared/cp/cp-agents.js +8 -0
- package/neural-interface/public/shared/cp/cp-permissions.js +6 -2
- package/neural-interface/public/shared/cp/cp-rehydrate.js +25 -1
- package/neural-interface/public/shared/cp/cp-tasks-model.js +33 -0
- package/neural-interface/public/shared/editor/editor-panel-logic.js +10 -0
- package/neural-interface/public/shared/editor/editor-panel.js +10 -2
- package/neural-interface/public/shared/html-shell.js +30 -22
- package/neural-interface/public/shared/judgments-log-origins.js +29 -0
- package/neural-interface/public/shared/morelogin-profile-choices.js +107 -0
- package/neural-interface/public/shared/morelogin-profile-field.js +186 -0
- package/neural-interface/public/shared/mtc/mtc-client.js +181 -0
- package/neural-interface/public/shared/mtc/mtc-compose.js +40 -0
- package/neural-interface/public/shared/mtc/mtc-copy.js +253 -0
- package/neural-interface/public/shared/mtc/mtc-logic.js +478 -0
- package/neural-interface/public/shared/mtc/mtc-panel.js +1354 -0
- package/neural-interface/public/shared/mtc/mtc-render.js +172 -0
- package/neural-interface/public/shared/mtc/mtc-styles.js +437 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-automation-ownership.js +23 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-events.js +13 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-icons.js +3 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +10 -4
- package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +6 -86
- package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +5 -2
- package/neural-interface/public/shared/owner-access.js +134 -0
- package/neural-interface/public/shared/owner-authority-view.js +92 -0
- package/neural-interface/public/shared/page-session.js +143 -14
- package/neural-interface/public/shared/poll-backoff.js +59 -0
- package/neural-interface/public/shared/provider-icons.js +3 -0
- package/neural-interface/public/shared/schedules-view.js +7 -0
- package/neural-interface/public/shared/server-back.js +50 -0
- package/neural-interface/public/shared/settings/settings-browser-owner-access.js +72 -0
- package/neural-interface/public/shared/settings/settings-data.js +7 -1
- package/neural-interface/public/shared/settings/settings-ia.js +3 -1
- package/neural-interface/public/shared/settings/settings-kit.js +11 -3
- package/neural-interface/public/shared/settings/settings-local-profiles.js +153 -0
- package/neural-interface/public/shared/settings/settings-maritaca-opencode.js +105 -0
- package/neural-interface/public/shared/settings/settings-shell.js +7 -0
- package/neural-interface/public/shared/shown-children.js +72 -0
- package/neural-interface/public/shared/sidepanel-session-status.js +16 -2
- package/neural-interface/public/shared/state.js +1 -1
- package/neural-interface/public/shared/static-bg-state.js +22 -0
- package/neural-interface/public/shared/styles.css +457 -164
- package/neural-interface/public/shared/synabun-mascot-assets.js +67 -0
- package/neural-interface/public/shared/synabun-mascot.js +136 -12
- package/neural-interface/public/shared/synabun-ticker.js +3 -0
- package/neural-interface/public/shared/synabun-tools.js +173 -0
- package/neural-interface/public/shared/tool-heartbeat.js +43 -0
- package/neural-interface/public/shared/tool-list-picker.js +3 -1
- package/neural-interface/public/shared/tool-list-view.js +23 -4
- package/neural-interface/public/shared/topright-overflow-logic.js +1 -0
- package/neural-interface/public/shared/ui-automation-approval.js +188 -0
- package/neural-interface/public/shared/ui-automation-studio.js +138 -91
- package/neural-interface/public/shared/ui-claude-panel.js +209 -31
- package/neural-interface/public/shared/ui-judgments.js +37 -10
- package/neural-interface/public/shared/ui-maritaca-panel.js +15 -0
- package/neural-interface/public/shared/ui-navbar.js +23 -0
- package/neural-interface/public/shared/ui-owner-access.js +191 -0
- package/neural-interface/public/shared/ui-owner-authority.js +162 -0
- package/neural-interface/public/shared/ui-panels.js +3 -1
- package/neural-interface/public/shared/ui-schedules-studio.js +118 -17
- package/neural-interface/public/shared/ui-scroll-follow.js +3 -0
- package/neural-interface/public/shared/ui-sessions.js +45 -16
- package/neural-interface/public/shared/ui-settings.js +676 -42
- package/neural-interface/public/shared/ui-sidepanel-session-entry.js +8 -2
- package/neural-interface/public/shared/ui-sidepanel-sessions.js +3 -3
- package/neural-interface/public/shared/ui-sidepanel-tray.js +24 -0
- package/neural-interface/public/shared/ui-sidepanel-windows.js +1 -1
- package/neural-interface/public/shared/ui-terminal.js +15 -7
- package/neural-interface/public/shared/ui-tutorial-preview.js +4 -0
- package/neural-interface/public/shared/ui-update.js +3 -0
- package/neural-interface/public/shared/ui-whiteboard.js +4 -0
- package/neural-interface/public/shared/window-keys.js +38 -0
- package/neural-interface/scripts/build-mascot-assets.mjs +30 -0
- package/neural-interface/server.js +2903 -359
- package/npm-shrinkwrap.json +5 -17
- package/package.json +5 -6
- package/postinstall.js +38 -39
- package/setup.js +33 -31
- package/skills/synabun/modules/changelog.md +14 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// ── The owner's list of MoreLogin profiles agents may choose (DOM-free, no imports) ──
|
|
2
|
+
//
|
|
3
|
+
// A MoreLogin profile is a separate logged-in account. Which account an automation acts in is the owner's choice
|
|
4
|
+
// (security review 972afb74 of 2026-11-05, finding 1). The per-session profile work of 2026-11-10 let a session pick a
|
|
5
|
+
// profile for itself (`morelogin` "use", browser_session create's moreloginProfile, agent_dispatch morelogin_profile)
|
|
6
|
+
// and let the launch routes take one from any caller; a review the same day (run b6631e9d) found that this handed
|
|
7
|
+
// every profile, and so every account, to any local process. The owner's decision: an allowlist, empty by default.
|
|
8
|
+
//
|
|
9
|
+
// What it means:
|
|
10
|
+
// • It is the owner's list of the profiles an agent may put itself, or be put by another agent, into. With nothing
|
|
11
|
+
// on it, no session, dispatch or agent-made launch can select a profile at all.
|
|
12
|
+
// • The owner at SynaBun's page (this boot's page secret, never a guest: server.js browserOwnerPageOnly) is not
|
|
13
|
+
// limited by it: a schedule, a group, a timer or a launch the owner sets up there may use any Chrome-type profile.
|
|
14
|
+
// • The Browser-settings default profile is not part of it.
|
|
15
|
+
// • It is checked where a profile is chosen AND where a pin is used (pinUseRefusal), so taking a profile off the
|
|
16
|
+
// list stops the sessions already pinned to it at their next browser call. They are refused; they never fall back
|
|
17
|
+
// to the default profile or to Chrome.
|
|
18
|
+
//
|
|
19
|
+
// Where it is kept: the `moreloginAgentProfiles` key of the owner's browser settings (DATA_HOME/data/
|
|
20
|
+
// browser-config.json), written only by PUT /api/morelogin/agent-profiles, a route of the owner's page alone
|
|
21
|
+
// (server.js moreLoginGate: not in MORELOGIN_AUTOMATION_ROUTES). PUT /api/browser/config keeps the saved list whatever
|
|
22
|
+
// its body says, so the Settings form cannot drop it and no other writer exists.
|
|
23
|
+
//
|
|
24
|
+
// Who chose a profile travels with the choice (`by`): 'owner' only where the server itself saw the owner's page make
|
|
25
|
+
// it; anything else, a record from before this rule included, is 'agent' and needs the list. scheduleProfileAuthority
|
|
26
|
+
// says which of the two a schedule's run is.
|
|
27
|
+
|
|
28
|
+
/** The key of the owner's browser settings that holds the list. */
|
|
29
|
+
export const AGENT_PROFILES_KEY = 'moreloginAgentProfiles';
|
|
30
|
+
/** Entries kept at most (MoreLogin accounts hold far fewer profiles). */
|
|
31
|
+
export const AGENT_PROFILES_MAX = 500;
|
|
32
|
+
/** The refusal's code, everywhere a profile off the list is chosen or used. */
|
|
33
|
+
export const PROFILE_NOT_ALLOWED = 'MORELOGIN_PROFILE_NOT_ALLOWED';
|
|
34
|
+
/** Where the owner edits the list, as the refusals and the tools name it. */
|
|
35
|
+
export const AGENT_PROFILES_WHERE = 'SynaBun → Settings → Connected tools → MoreLogin → MoreLogin profiles → "Agents may choose"';
|
|
36
|
+
|
|
37
|
+
const cleanId = (value) => {
|
|
38
|
+
const id = value === null || value === undefined ? '' : String(value).trim();
|
|
39
|
+
return id && id.length <= 128 && !/[\u0000-\u001f]/.test(id) ? id : '';
|
|
40
|
+
};
|
|
41
|
+
const cleanName = (value) => (typeof value === 'string' ? value.trim().slice(0, 200) : '');
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The list as it is kept: [{ envId, name }], one entry per profile id, in the order given. Anything that is not a
|
|
45
|
+
* list, or an entry without a usable id, is nothing: an unreadable list allows no profile.
|
|
46
|
+
* @param {unknown} value the saved value, or a browser config that holds it
|
|
47
|
+
*/
|
|
48
|
+
export function normalizeAgentProfiles(value) {
|
|
49
|
+
const rows = Array.isArray(value) ? value : (value && typeof value === 'object' && Array.isArray(value[AGENT_PROFILES_KEY]) ? value[AGENT_PROFILES_KEY] : []);
|
|
50
|
+
const seen = new Set();
|
|
51
|
+
const out = [];
|
|
52
|
+
for (const row of rows) {
|
|
53
|
+
const envId = cleanId(row && typeof row === 'object' ? row.envId : row);
|
|
54
|
+
if (!envId || seen.has(envId)) continue;
|
|
55
|
+
seen.add(envId);
|
|
56
|
+
out.push({ envId, name: (row && typeof row === 'object' ? cleanName(row.name) : '') || null });
|
|
57
|
+
if (out.length >= AGENT_PROFILES_MAX) break;
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Whether `envId` is on the list (`source`: the list, or a browser config that holds it). By id only, never by name. */
|
|
63
|
+
export function agentProfileAllowed(source, envId) {
|
|
64
|
+
const id = cleanId(envId);
|
|
65
|
+
return !!id && normalizeAgentProfiles(source).some((row) => row.envId === id);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The list with `envId` put on it (`allowed` true) or taken off it. The name is kept for display only. */
|
|
69
|
+
export function withAgentProfile(source, envId, name, allowed) {
|
|
70
|
+
const id = cleanId(envId);
|
|
71
|
+
const rows = normalizeAgentProfiles(source).filter((row) => row.envId !== id);
|
|
72
|
+
if (id && allowed === true) rows.push({ envId: id, name: cleanName(name) || null });
|
|
73
|
+
return rows.slice(0, AGENT_PROFILES_MAX);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// The id of a local profile (a Chrome SynaBun runs itself, lib/local-profiles.js LOCAL_PROFILE_ID_RE; this module has
|
|
77
|
+
// no imports). The list, the pins and the refusals hold both kinds of profile by id; only the words differ.
|
|
78
|
+
const LOCAL_PROFILE_REF_RE = /^lp-[0-9a-f]{12}$/;
|
|
79
|
+
/** 'local profile' for one of SynaBun's own profiles, 'MoreLogin profile' for every other id. */
|
|
80
|
+
export function profileKindLabel(envId) {
|
|
81
|
+
return LOCAL_PROFILE_REF_RE.test(cleanId(envId)) ? 'local profile' : 'MoreLogin profile';
|
|
82
|
+
}
|
|
83
|
+
/** A profile as the refusals and the log lines name it: `MoreLogin profile "P-4" (id)`, `local profile "Shop" (id)`. */
|
|
84
|
+
export function describeProfile(envId, name = null) {
|
|
85
|
+
const kind = profileKindLabel(envId);
|
|
86
|
+
return cleanName(name) ? `${kind} "${cleanName(name)}" (${cleanId(envId)})` : `${kind} ${cleanId(envId)}`;
|
|
87
|
+
}
|
|
88
|
+
const describe = describeProfile;
|
|
89
|
+
|
|
90
|
+
/** What a refused agent is told, and what it tells the user. */
|
|
91
|
+
export function profileNotAllowedText(envId, name = null) {
|
|
92
|
+
return `${describe(envId, name)} is not on the owner's list of profiles agents may choose, so nothing was opened: not that profile, not the default one, not Chrome. Tell the user: to let agents work in it, switch it on in ${AGENT_PROFILES_WHERE}. A schedule, group, timer or launch the user sets up in SynaBun's own page can use any profile without that. Never switch to another profile or browser by yourself.`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** The refusal as an Error (status 403, code MORELOGIN_PROFILE_NOT_ALLOWED) for the routes' catch blocks. */
|
|
96
|
+
export function profileNotAllowedError(envId, name = null, extra = '') {
|
|
97
|
+
return Object.assign(new Error(`${profileNotAllowedText(envId, name)}${extra ? ` ${extra}` : ''}`), { status: 403, code: PROFILE_NOT_ALLOWED, envId: cleanId(envId) });
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Why a pin may not be used now, or null. A pin the owner's page set (`by: 'owner'`) is never limited; every other
|
|
102
|
+
* pin (a session's own choice, a dispatch's, an agent-made launch's, one whose origin is not recorded) needs its
|
|
103
|
+
* profile on the list at every use, not only when it was set.
|
|
104
|
+
* @param {{ envId: string, name?: string|null, by?: string }|null} pin
|
|
105
|
+
* @param {unknown} source the list, or a browser config that holds it
|
|
106
|
+
* @returns {{ status: 403, code: string, error: string, envId: string }|null}
|
|
107
|
+
*/
|
|
108
|
+
export function pinUseRefusal(pin, source) {
|
|
109
|
+
if (!pin || !pin.envId || pin.by === 'owner') return null;
|
|
110
|
+
if (agentProfileAllowed(source, pin.envId)) return null;
|
|
111
|
+
return {
|
|
112
|
+
status: 403, code: PROFILE_NOT_ALLOWED, envId: String(pin.envId),
|
|
113
|
+
error: `${profileNotAllowedText(pin.envId, pin.name)} This session is set to that profile (the owner took it off the list, or never put it there): its browser calls are refused until the profile is allowed again, or until the session goes back to the default profile itself (morelogin with action "use" and envId "default").`,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Whether a schedule's run in the profile of `holder` (the schedule itself, or its group) is the owner's own choice.
|
|
119
|
+
* It is only when the server saw the owner's page choose that profile (`holder.moreloginEnvBy === 'owner'`) AND nothing
|
|
120
|
+
* an agent wrote since decides what runs there: the schedule's task-defining fields (`schedule.taskBy`: its template,
|
|
121
|
+
* its overrides, its day themes, the group it is in) and its template (`template.editedBy`). Otherwise an agent could
|
|
122
|
+
* ride the owner's record into a profile off the list: change its task, or put a schedule of its own into the owner's
|
|
123
|
+
* group. A record with no marker (one saved before this rule) is not proven the owner's.
|
|
124
|
+
* @returns {{ by: 'owner' } | { by: 'agent', why: string, cure: string }}
|
|
125
|
+
*/
|
|
126
|
+
export function scheduleProfileAuthority({ schedule = null, holder = null, template = null, source = 'schedule' } = {}) {
|
|
127
|
+
const page = 'SynaBun\'s page (Automation Studio)';
|
|
128
|
+
if (!holder || holder.moreloginEnvBy !== 'owner') {
|
|
129
|
+
return {
|
|
130
|
+
by: 'agent',
|
|
131
|
+
why: holder?.moreloginEnvBy === 'agent'
|
|
132
|
+
? `the ${source}'s profile was chosen by an agent, not by the owner in ${page}`
|
|
133
|
+
: `SynaBun has no record that the owner chose the ${source}'s profile in ${page} (it was saved before that was recorded, or by an agent)`,
|
|
134
|
+
cure: `or open the ${source} in ${page}, pick the profile again and save`,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
if (schedule && schedule.taskBy === 'agent') {
|
|
138
|
+
return { by: 'agent', why: 'an agent created this schedule or last changed what it runs (its template, overrides, day themes or group)', cure: `or open the schedule in ${page}, check what it runs, pick the profile again and save` };
|
|
139
|
+
}
|
|
140
|
+
if (template && template.editedBy === 'agent') {
|
|
141
|
+
return { by: 'agent', why: 'an agent created or last changed the template this schedule runs', cure: `or open that template in ${page}, check its task and save it` };
|
|
142
|
+
}
|
|
143
|
+
return { by: 'owner' };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** The message of a schedule run refused for a profile off the list (scheduleProfileAuthority said 'agent'). */
|
|
147
|
+
export function scheduleProfileRefusalText(envId, name, authority) {
|
|
148
|
+
return `${describe(envId, name)} is not on the owner's list of profiles agents may choose, and ${authority?.why || 'this run is not the owner\'s own choice'}. The run was not started: not in that profile, not in the default one, not in Chrome. To run it, switch the profile on in ${AGENT_PROFILES_WHERE}, ${authority?.cure || 'or save it again in SynaBun\'s page'}.`;
|
|
149
|
+
}
|
|
@@ -71,7 +71,7 @@ export function launchMoreLoginApp() {
|
|
|
71
71
|
if (!installed) return { launched: false, path: null, error: 'MoreLogin is not installed' };
|
|
72
72
|
try {
|
|
73
73
|
const child = process.platform === 'darwin'
|
|
74
|
-
? spawn('open', [path], { detached: true, stdio: 'ignore' })
|
|
74
|
+
? spawn('open', ['-g', path], { detached: true, stdio: 'ignore' }) // -g: launch without bringing it forward
|
|
75
75
|
: spawn(path, [], { detached: true, stdio: 'ignore', windowsHide: false });
|
|
76
76
|
child.unref();
|
|
77
77
|
return { launched: true, path, error: null };
|
|
@@ -314,7 +314,21 @@ export async function probeMoreLoginApi(opts = {}) {
|
|
|
314
314
|
* `running: false` result FAILS the session in createBrowserSession(); nothing
|
|
315
315
|
* falls back to Chrome.
|
|
316
316
|
*/
|
|
317
|
-
export
|
|
317
|
+
export function ensureMoreLoginRunning(opts = {}) {
|
|
318
|
+
// One start for everybody who asks at once: browser sessions of different profiles start side by side, and each
|
|
319
|
+
// would otherwise launch the app while it is not running yet. The first caller's wait is the one that counts.
|
|
320
|
+
const key = String(opts.port ?? getMoreLoginPort(opts.savedCfg));
|
|
321
|
+
let start = _appStarts.get(key);
|
|
322
|
+
if (!start) {
|
|
323
|
+
start = startMoreLoginAppIfNeeded(opts).finally(() => { if (_appStarts.get(key) === start) _appStarts.delete(key); });
|
|
324
|
+
_appStarts.set(key, start);
|
|
325
|
+
}
|
|
326
|
+
return start;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const _appStarts = new Map(); // local API port → the start under way
|
|
330
|
+
|
|
331
|
+
async function startMoreLoginAppIfNeeded(opts = {}) {
|
|
318
332
|
const timeoutMs = opts.timeoutMs ?? 25000;
|
|
319
333
|
const intervalMs = opts.intervalMs ?? 1000;
|
|
320
334
|
|
|
@@ -372,11 +386,221 @@ export async function profileStatus(envId, opts = {}) {
|
|
|
372
386
|
}
|
|
373
387
|
}
|
|
374
388
|
|
|
389
|
+
/** MoreLogin's `browserTypeId` (profile detail, create): 1 is its Chrome-based browser, 2 its Firefox-based one. */
|
|
390
|
+
const BROWSER_TYPE_KERNEL = { 1: 'chromium', 2: 'firefox' };
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Which browser a profile runs, from whatever MoreLogin said about it: 'chromium', 'firefox' or null (not said).
|
|
394
|
+
* Read from the profile detail's `browserTypeId` (then its user agent), or from the `webdriver` path a start or a
|
|
395
|
+
* status answers with (`…/Core/chrome_64_154.0/webdriver_154`, `…/Core/firefox_64_148.1/webdriver_148`).
|
|
396
|
+
* SynaBun drives a profile over the Chrome DevTools protocol, which only the Chrome-based browser speaks: the
|
|
397
|
+
* Firefox one opens `--remote-debugging-port` too, but as Firefox's own remote agent (WebDriver BiDi), which
|
|
398
|
+
* answers 404 to `/json/version`.
|
|
399
|
+
*/
|
|
400
|
+
export function profileKernel(data) {
|
|
401
|
+
if (!data || typeof data !== 'object') return null;
|
|
402
|
+
const byType = BROWSER_TYPE_KERNEL[Number(data.browserTypeId)];
|
|
403
|
+
if (byType) return byType;
|
|
404
|
+
const path = typeof data.webdriver === 'string' ? data.webdriver : '';
|
|
405
|
+
const core = /(?:^|[\\/])(firefox|chrome|chromium)[_-][^\\/]*[\\/]/i.exec(path);
|
|
406
|
+
if (core) return core[1].toLowerCase() === 'firefox' ? 'firefox' : 'chromium';
|
|
407
|
+
const ua = data.advancedSetting && typeof data.advancedSetting.ua === 'string' ? data.advancedSetting.ua : '';
|
|
408
|
+
if (/\bFirefox\/\d/.test(ua)) return 'firefox';
|
|
409
|
+
if (/\bChrome\/\d/.test(ua)) return 'chromium';
|
|
410
|
+
return null;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/** The error of a profile SynaBun cannot drive. `started` says whether this start may have opened its browser. */
|
|
414
|
+
export function notChromiumError(envId, { started = false, evidence = '' } = {}) {
|
|
415
|
+
const e = new Error(
|
|
416
|
+
`MoreLogin profile ${envId} runs MoreLogin's Firefox browser, which has no Chrome DevTools (CDP) endpoint${evidence ? ` (${evidence})` : ''}. `
|
|
417
|
+
+ 'SynaBun drives a MoreLogin profile over CDP, so only a Chrome-type profile can be used: '
|
|
418
|
+
+ 'pick a Chrome-type profile, or create one in MoreLogin (New profile → Browser: Chrome)'
|
|
419
|
+
+ (started ? '. The profile\'s Firefox window was left open in MoreLogin' : ''),
|
|
420
|
+
);
|
|
421
|
+
e.code = 'MORELOGIN_NOT_CHROMIUM';
|
|
422
|
+
e.kernel = 'firefox';
|
|
423
|
+
e.started = !!started;
|
|
424
|
+
return e;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/** One profile's full record (`/api/env/detail`). Large: it carries the profile's whole cookie jar. */
|
|
428
|
+
export async function profileDetail(envId, opts = {}) {
|
|
429
|
+
return request('/api/env/detail', { envId: String(envId) }, { ...opts, idempotent: true });
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// Profiles already seen to be Chrome-type. A profile's browser is chosen when it is created, and the detail call
|
|
433
|
+
// that says it is megabytes (the cookie jar), so a Chrome verdict is asked for once. A Firefox verdict is never
|
|
434
|
+
// kept: it is asked again each time, and a wrong Chrome one is caught by the start's own answer.
|
|
435
|
+
const _chromiumProfiles = new Set();
|
|
436
|
+
export function _resetMoreLoginKernelsForTests() { _chromiumProfiles.clear(); _listedKernels.clear(); _kernelLookups.clear(); }
|
|
437
|
+
|
|
438
|
+
function statusRow(st) {
|
|
439
|
+
return Array.isArray(st?.dataList) ? st.dataList[0] : (Array.isArray(st) ? st[0] : st);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Which browser a profile runs, asked without starting it: the status of a running profile says it (small), else
|
|
444
|
+
* the profile's detail. Best effort: null when MoreLogin does not say; never throws.
|
|
445
|
+
*/
|
|
446
|
+
export async function profileKernelOf(envId, opts = {}) {
|
|
447
|
+
const id = String(envId);
|
|
448
|
+
if (_chromiumProfiles.has(id)) return 'chromium';
|
|
449
|
+
let kernel = null;
|
|
450
|
+
try { kernel = profileKernel(statusRow(await profileStatus(id, opts))); }
|
|
451
|
+
catch { /* unreachable: the start says so itself */ }
|
|
452
|
+
if (!kernel) {
|
|
453
|
+
try { kernel = profileKernel(await profileDetail(id, opts)); } catch { /* a MoreLogin without the call */ }
|
|
454
|
+
}
|
|
455
|
+
if (kernel === 'chromium') _chromiumProfiles.add(id);
|
|
456
|
+
return kernel;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// ── Which browser each listed profile runs (the profile pickers, and the routes that save a choice) ──
|
|
460
|
+
// MoreLogin's list call does not say a profile's browser; only the megabyte detail does. So the verdicts are kept
|
|
461
|
+
// per profile: a Chrome one for the life of the process (above), a Firefox one for ten minutes, "MoreLogin did not
|
|
462
|
+
// say" for half a minute (then asked again, never taken for an answer). One lookup per profile at a time, a few at
|
|
463
|
+
// once, and a list never waits for them longer than its budget: what is not known yet is `null` in that answer and
|
|
464
|
+
// arrives in a later one. null always means "not known", and a profile of unknown browser stays usable everywhere:
|
|
465
|
+
// the start of a run still refuses a Firefox one (startProfile, requireCdp).
|
|
466
|
+
const FIREFOX_VERDICT_MS = 10 * 60_000;
|
|
467
|
+
const UNKNOWN_VERDICT_MS = 30_000;
|
|
468
|
+
const MAX_LISTED_VERDICTS = 5000;
|
|
469
|
+
const _listedKernels = new Map(); // id → { kernel: 'firefox' | null, at }
|
|
470
|
+
const _kernelLookups = new Map(); // id → the lookup under way
|
|
471
|
+
|
|
472
|
+
/** The verdict already held for a profile: { known: true, kernel } or { known: false }. Never asks MoreLogin. */
|
|
473
|
+
export function heldProfileKernel(envId, now = Date.now()) {
|
|
474
|
+
const id = String(envId);
|
|
475
|
+
if (_chromiumProfiles.has(id)) return { known: true, kernel: 'chromium' };
|
|
476
|
+
const held = _listedKernels.get(id);
|
|
477
|
+
if (!held) return { known: false, kernel: null };
|
|
478
|
+
if (now - held.at > (held.kernel === 'firefox' ? FIREFOX_VERDICT_MS : UNKNOWN_VERDICT_MS)) {
|
|
479
|
+
_listedKernels.delete(id);
|
|
480
|
+
return { known: false, kernel: null };
|
|
481
|
+
}
|
|
482
|
+
return { known: true, kernel: held.kernel };
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/** A profile's browser, from what is held or one shared lookup: 'chromium', 'firefox' or null. Never throws. */
|
|
486
|
+
export function lookupProfileKernel(envId, opts = {}) {
|
|
487
|
+
const id = String(envId);
|
|
488
|
+
const held = heldProfileKernel(id);
|
|
489
|
+
if (held.known) return Promise.resolve(held.kernel);
|
|
490
|
+
let lookup = _kernelLookups.get(id);
|
|
491
|
+
if (!lookup) {
|
|
492
|
+
lookup = (opts.kernelOf || profileKernelOf)(id, opts)
|
|
493
|
+
.then((kernel) => (kernel === 'chromium' || kernel === 'firefox' ? kernel : null), () => null)
|
|
494
|
+
.then((kernel) => {
|
|
495
|
+
if (kernel !== 'chromium') {
|
|
496
|
+
_listedKernels.delete(id); // newest last
|
|
497
|
+
_listedKernels.set(id, { kernel, at: Date.now() });
|
|
498
|
+
while (_listedKernels.size > MAX_LISTED_VERDICTS) _listedKernels.delete(_listedKernels.keys().next().value);
|
|
499
|
+
} else _chromiumProfiles.add(id);
|
|
500
|
+
return kernel;
|
|
501
|
+
})
|
|
502
|
+
.finally(() => { if (_kernelLookups.get(id) === lookup) _kernelLookups.delete(id); });
|
|
503
|
+
_kernelLookups.set(id, lookup);
|
|
504
|
+
}
|
|
505
|
+
return lookup;
|
|
506
|
+
}
|
|
507
|
+
|
|
375
508
|
/**
|
|
376
|
-
*
|
|
509
|
+
* The browsers of many profiles: { kernels: { id: 'chromium' | 'firefox' | null }, pending }.
|
|
510
|
+
* `concurrency` lookups at once (default 4); after `budgetMs` (default 2500) the answer is what is known by then,
|
|
511
|
+
* `pending` counts the profiles still being asked (their lookups go on and fill the cache for the next call).
|
|
512
|
+
* A lookup that fails is `null` for that profile and never the list's failure.
|
|
513
|
+
*/
|
|
514
|
+
export async function profileKernels(envIds, opts = {}) {
|
|
515
|
+
const ids = [...new Set((envIds || []).map(String))];
|
|
516
|
+
const concurrency = Math.max(1, opts.concurrency || 4);
|
|
517
|
+
const budgetMs = opts.budgetMs ?? 2500;
|
|
518
|
+
const queue = ids.filter(id => !heldProfileKernel(id).known);
|
|
519
|
+
if (queue.length) {
|
|
520
|
+
let next = 0;
|
|
521
|
+
const worker = async () => {
|
|
522
|
+
while (next < queue.length) {
|
|
523
|
+
const id = queue[next++];
|
|
524
|
+
try { await lookupProfileKernel(id, opts); } catch { /* null for this one */ }
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
const all = Promise.all(Array.from({ length: Math.min(concurrency, queue.length) }, worker)).catch(() => {});
|
|
528
|
+
let timer = null;
|
|
529
|
+
await Promise.race([all, new Promise((done) => { timer = setTimeout(done, Math.max(0, budgetMs)); timer.unref?.(); })]);
|
|
530
|
+
clearTimeout(timer);
|
|
531
|
+
}
|
|
532
|
+
const kernels = {};
|
|
533
|
+
let pending = 0;
|
|
534
|
+
for (const id of ids) {
|
|
535
|
+
const held = heldProfileKernel(id);
|
|
536
|
+
kernels[id] = held.known ? held.kernel : null;
|
|
537
|
+
if (!held.known) pending++;
|
|
538
|
+
}
|
|
539
|
+
return { kernels, pending };
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/** The error of a choice SynaBun refuses to save: a profile known to run MoreLogin's Firefox browser. */
|
|
543
|
+
export function notChromiumChoiceError(envId, name = null) {
|
|
544
|
+
const label = name ? `"${name}" (${envId})` : String(envId);
|
|
545
|
+
const e = new Error(
|
|
546
|
+
`MoreLogin profile ${label} is a Firefox-type profile. SynaBun drives a MoreLogin profile over the Chrome DevTools protocol, `
|
|
547
|
+
+ 'so only a Chrome-type profile can be chosen: pick a Chrome-type profile, or create one in MoreLogin (New profile → Browser: Chrome).',
|
|
548
|
+
);
|
|
549
|
+
e.code = 'MORELOGIN_NOT_CHROMIUM';
|
|
550
|
+
e.status = 400;
|
|
551
|
+
e.kernel = 'firefox';
|
|
552
|
+
return e;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* What answers on a started profile's debug port, asked when `/json/version` did not answer as DevTools does:
|
|
557
|
+
* { kind: 'devtools' | 'not-devtools' | 'closed', status, server }. `not-devtools` is an HTTP server that is not a
|
|
558
|
+
* DevTools endpoint (Firefox's remote agent says `Server: httpd.js` and 404); `closed` is nothing listening (yet).
|
|
559
|
+
* Never throws.
|
|
560
|
+
*/
|
|
561
|
+
export async function describeDebugEndpoint(port, opts = {}) {
|
|
562
|
+
const fetchImpl = opts.fetch || fetch;
|
|
563
|
+
let res;
|
|
564
|
+
try {
|
|
565
|
+
res = await fetchImpl(`http://127.0.0.1:${port}/json/version`, { signal: AbortSignal.timeout(opts.timeout || 2000) });
|
|
566
|
+
} catch (err) {
|
|
567
|
+
return { kind: 'closed', status: null, server: null, error: String(err?.cause?.code || err?.code || err?.message || err) };
|
|
568
|
+
}
|
|
569
|
+
const server = res.headers?.get?.('server') || null;
|
|
570
|
+
let body = null;
|
|
571
|
+
try { body = await res.json(); } catch { try { await res.body?.cancel(); } catch { /* ignore */ } }
|
|
572
|
+
if (res.ok && body && typeof body === 'object' && (body.webSocketDebuggerUrl || body.Browser)) {
|
|
573
|
+
return { kind: 'devtools', status: res.status, server };
|
|
574
|
+
}
|
|
575
|
+
return { kind: 'not-devtools', status: res.status, server, firefox: /^httpd\.js/i.test(server || '') };
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/** The error of a started profile whose debug port is some other HTTP server (see describeDebugEndpoint). */
|
|
579
|
+
export function notDevToolsError(envId, port, seen = {}) {
|
|
580
|
+
if (seen.firefox) {
|
|
581
|
+
return notChromiumError(envId, { started: true, evidence: `port ${port} answers as Firefox's remote agent, HTTP ${seen.status}` });
|
|
582
|
+
}
|
|
583
|
+
const e = new Error(
|
|
584
|
+
`MoreLogin started profile ${envId} and named debug port ${port}, but what listens there is not a Chrome DevTools endpoint `
|
|
585
|
+
+ `(HTTP ${seen.status} for /json/version${seen.server ? `, server "${seen.server}"` : ''}). `
|
|
586
|
+
+ 'SynaBun drives a MoreLogin profile over CDP: use a Chrome-type profile, or close this profile in MoreLogin and start the run again if it is one',
|
|
587
|
+
);
|
|
588
|
+
e.code = 'MORELOGIN_NOT_DEVTOOLS';
|
|
589
|
+
return e;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Start (launch) a profile and return { debugPort, webdriver, kernel, raw }.
|
|
377
594
|
* Recovers the debugPort via status when the env is already running.
|
|
595
|
+
*
|
|
596
|
+
* `opts.requireCdp` (a start SynaBun will drive, never the Settings Start button): a Firefox-type profile is
|
|
597
|
+
* refused with MORELOGIN_NOT_CHROMIUM before it is started when MoreLogin says what it is up front, and right
|
|
598
|
+
* after the start when only the start's answer says it. It is never closed here: it may be the user's own window.
|
|
378
599
|
*/
|
|
379
600
|
export async function startProfile(envId, opts = {}) {
|
|
601
|
+
if (opts.requireCdp && await profileKernelOf(envId, opts) === 'firefox') {
|
|
602
|
+
throw notChromiumError(envId, { evidence: 'MoreLogin lists it as a Firefox profile' });
|
|
603
|
+
}
|
|
380
604
|
let data = null;
|
|
381
605
|
try {
|
|
382
606
|
data = await request('/api/env/start', { envId: String(envId), ...(opts.startArgs || {}) }, opts);
|
|
@@ -390,12 +614,17 @@ export async function startProfile(envId, opts = {}) {
|
|
|
390
614
|
// Already-running or no port echoed — recover from status. A `status` object
|
|
391
615
|
// may be keyed directly or under a list.
|
|
392
616
|
const st = await profileStatus(envId, opts);
|
|
393
|
-
const stData =
|
|
617
|
+
const stData = statusRow(st);
|
|
394
618
|
port = extractDebugPort(stData);
|
|
395
619
|
webdriver = webdriver || (stData && stData.webdriver);
|
|
396
620
|
}
|
|
621
|
+
const kernel = profileKernel({ webdriver });
|
|
622
|
+
if (opts.requireCdp && kernel === 'firefox') {
|
|
623
|
+
throw notChromiumError(envId, { started: true, evidence: `its browser is ${webdriver}` });
|
|
624
|
+
}
|
|
397
625
|
if (!port) throw new Error(`MoreLogin started env ${envId} but returned no debugPort`);
|
|
398
|
-
|
|
626
|
+
if (kernel === 'chromium') _chromiumProfiles.add(String(envId));
|
|
627
|
+
return { debugPort: port, webdriver: webdriver || null, kernel, raw: data };
|
|
399
628
|
}
|
|
400
629
|
|
|
401
630
|
/**
|
|
@@ -428,18 +657,53 @@ export async function stopProfile(envId, opts = {}) {
|
|
|
428
657
|
return request('/api/env/close', { envId: String(envId) }, opts);
|
|
429
658
|
}
|
|
430
659
|
|
|
431
|
-
/**
|
|
432
|
-
|
|
433
|
-
|
|
660
|
+
/** MoreLogin's operating-system id for a profile made on this host (Local API quick create: 1 Windows, 2 macOS,
|
|
661
|
+
* 3 Android, 4 iOS). macOS on a Mac, Windows everywhere else (MoreLogin has no Linux fingerprint). */
|
|
662
|
+
export function hostOperatorSystemId(platform = process.platform) {
|
|
663
|
+
return platform === 'darwin' ? 2 : 1;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/** The body of `/api/env/create/quick`, per guide.morelogin.com (Browser → Local API → Profiles, checked 2026-11-11):
|
|
667
|
+
* `browserTypeId`, `operatorSystemId` and `quantity` are required; there is no name field. Chrome type (1) is the
|
|
668
|
+
* only kind SynaBun can drive. `opts.operatorSystemId`, then `opts.body`, override. */
|
|
669
|
+
export function quickCreateBody(opts = {}) {
|
|
670
|
+
return {
|
|
434
671
|
quantity: 1,
|
|
435
|
-
browserTypeId:
|
|
436
|
-
|
|
672
|
+
browserTypeId: 1,
|
|
673
|
+
operatorSystemId: opts.operatorSystemId || hostOperatorSystemId(opts.platform),
|
|
437
674
|
...(opts.body || {}),
|
|
438
675
|
};
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
const CREATE_PREFIX = 'MoreLogin API /api/env/create/quick';
|
|
679
|
+
/** A refusal of quick create, in words a toast can show: "MoreLogin refused the new profile: <reason>". */
|
|
680
|
+
function refusedNewProfile(err) {
|
|
681
|
+
if (!err || (err.code !== 'MORELOGIN_API' && err.code !== 'MORELOGIN_HTTP')) return err;
|
|
682
|
+
let reason = String(err.message || '');
|
|
683
|
+
if (reason.startsWith(CREATE_PREFIX)) reason = reason.slice(CREATE_PREFIX.length).replace(/^\s*(?::|→)\s*/, '');
|
|
684
|
+
const e = new Error(`MoreLogin refused the new profile: ${reason}`);
|
|
685
|
+
e.code = err.code;
|
|
686
|
+
if (err.apiCode !== undefined) e.apiCode = err.apiCode;
|
|
687
|
+
if (err.status !== undefined) e.status = err.status;
|
|
688
|
+
e.reason = reason;
|
|
689
|
+
return e;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
/** Create one quick profile. Quick create takes no name, so a name is set right after through `/api/env/update`
|
|
693
|
+
* (`envId` + `envName`); the profile exists even when that rename fails (`nameError`). */
|
|
694
|
+
export async function createProfile(opts = {}) {
|
|
695
|
+
let data;
|
|
696
|
+
try { data = await request('/api/env/create/quick', quickCreateBody(opts), opts); }
|
|
697
|
+
catch (err) { throw refusedNewProfile(err); }
|
|
698
|
+
// Documented answer: `data` is an array of id strings. Older clients answered { envIds } or { id }.
|
|
699
|
+
const ids = Array.isArray(data) ? data
|
|
700
|
+
: (data && (data.envIds || (data.id != null ? [data.id] : []))) || [];
|
|
701
|
+
const out = { ids: ids.map(String), raw: data };
|
|
702
|
+
if (opts.name && out.ids.length) {
|
|
703
|
+
try { await request('/api/env/update', { envId: out.ids[0], envName: String(opts.name) }, opts); }
|
|
704
|
+
catch (err) { out.nameError = err.message; }
|
|
705
|
+
}
|
|
706
|
+
return out;
|
|
443
707
|
}
|
|
444
708
|
|
|
445
709
|
/** Return the first profile, creating a default "SynaBun" profile if none exist. */
|