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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod/v3';
|
|
2
2
|
import * as ni from '../services/neural-interface.js';
|
|
3
3
|
import { text } from './response.js';
|
|
4
|
+
import { useAnswer } from './morelogin.js';
|
|
4
5
|
|
|
5
6
|
const tabIdField = z.string().optional().describe('Target a specific tab within the session. Auto-resolved from environment if omitted.');
|
|
6
7
|
|
|
@@ -87,46 +88,170 @@ export async function handleBrowserWait(args: {
|
|
|
87
88
|
// ── browser_session ──
|
|
88
89
|
|
|
89
90
|
export const browserSessionSchema = {
|
|
90
|
-
action: z.enum(['list', 'create', 'close']).describe('"list" =
|
|
91
|
+
action: z.enum(['list', 'status', 'create', 'close']).describe('"list" = the open sessions with your own tabs (id, address, title; your current tab marked), "status" = the session and tab your browser calls use now, with its address and whether SynaBun replaced a lost tab, "create" = open a new browser tab of your own (starting the browser if needed) and continue there, "close" = close a session.'),
|
|
91
92
|
url: z.string().optional().describe('Starting URL for "create" action (default: about:blank).'),
|
|
92
|
-
sessionId: z.string().optional().describe('Session ID for "close" action. Required for close when multiple sessions exist.'),
|
|
93
|
+
sessionId: z.string().optional().describe('Session ID for "close" action. Required for close when multiple sessions exist (or pass your tabId).'),
|
|
94
|
+
tabId: z.string().optional().describe('Your tab id, as the other browser tools take it. "status" / "list": says whether it is still your current tab (a lost tab names the tab that replaced it). "close": closes only this tab of yours; a tab that is not yours is refused and nothing is closed. Ignored by "create", which always opens a new tab of your own.'),
|
|
95
|
+
moreloginProfile: z.string().optional().describe('"create" only: the MoreLogin profile (its id or its name, as the morelogin tool\'s "list" shows it) to work in from now on. The new tab opens in that profile and your later browser calls stay there; the default browser and other sessions are not touched. "default" goes back to the default profile. The same as calling morelogin with action "use" first, with the same rule: only a profile the owner allowed agents to choose (morelogin "list" says which); a refusal for a profile not on that list means tell the user to switch it on in SynaBun\'s Settings, never another profile. Omit it to stay in the profile you work in.'),
|
|
93
96
|
};
|
|
94
97
|
|
|
95
98
|
export const browserSessionDescription =
|
|
96
|
-
'Manage browser sessions — list open sessions, create a new
|
|
99
|
+
'Manage browser sessions — list open sessions and your tabs in them, see which tab you work in ("status"), create a new one, or close one (pass your tabId to close only that tab of yours). Use "status" to find your current tab id. When a browser tool\'s answer starts with "Your tab … was lost; a replacement tab … is open", continue in that tab (no create). Use "create" when your browser session or tab was lost (closed, disconnected, "Session not found", "Tab … not found"): it opens a new tab of your own in the SynaBun browser, starting the browser when it is not running, and in a loop or a dispatched run your next browser calls go to it. Only if create fails too, stop and report it; never switch to another browser. To work in a MoreLogin profile other than the default (a second account, while other automations use the default one), pass moreloginProfile to "create" or call morelogin with action "use": your browser tools then drive that profile in a tab of your own and nobody else is moved (only a profile the owner allowed agents to choose; when it is refused as not on the owner\'s list, tell the user to switch it on in SynaBun\'s Settings and stop). Closing a session other automations still use closes only your own tab in it; the session stays open for them.';
|
|
97
100
|
|
|
98
101
|
export async function handleBrowserSession(args: {
|
|
99
102
|
action: string;
|
|
100
103
|
url?: string;
|
|
101
104
|
sessionId?: string;
|
|
105
|
+
tabId?: string;
|
|
106
|
+
moreloginProfile?: string;
|
|
102
107
|
}) {
|
|
103
|
-
if (args.action
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
return text(`${
|
|
108
|
+
if (args.moreloginProfile && args.action !== 'create') {
|
|
109
|
+
return text('moreloginProfile goes with action "create" (or call morelogin with action "use"). Nothing ran.');
|
|
110
|
+
}
|
|
111
|
+
if (args.action === 'list' || args.action === 'status') {
|
|
112
|
+
const status = await ni.browserRouteStatus();
|
|
113
|
+
if (status.error) return text(`${args.action === 'list' ? 'List' : 'Status'} failed: ${status.error}`);
|
|
114
|
+
const body = args.action === 'list' ? formatSessionList(status) : formatRouteStatus(status);
|
|
115
|
+
const note = args.tabId ? namedTabLine(status, args.tabId) : null;
|
|
116
|
+
return text(note ? `${body}\n${note}` : body);
|
|
112
117
|
}
|
|
113
118
|
|
|
114
119
|
if (args.action === 'create') {
|
|
120
|
+
let profileLine: string | null = null;
|
|
121
|
+
if (args.moreloginProfile) {
|
|
122
|
+
const wanted = args.moreloginProfile.trim();
|
|
123
|
+
const chosen = await ni.useSessionProfile(wanted.toLowerCase() === 'default' ? { default: true } : { profile: wanted });
|
|
124
|
+
if (chosen.error) return text(`Create failed: the MoreLogin profile "${wanted}" could not be chosen: ${chosen.error}\nNothing changed: you still work where you did. Never fall back to another profile or browser by yourself.`);
|
|
125
|
+
profileLine = useAnswer(chosen).split('\n')[0];
|
|
126
|
+
}
|
|
115
127
|
const result = await ni.createSession(args.url);
|
|
116
|
-
|
|
128
|
+
// A cold browser start still running: nothing failed, and the next create returns that same start.
|
|
129
|
+
if (ni.isBrowserStarting(result)) return text([profileLine, String(result.error || 'The browser is still starting. Call browser_session with action "create" again in a moment.')].filter(Boolean).join('\n'));
|
|
130
|
+
if (result.error) return text(`${profileLine ? `${profileLine}\n` : ''}Create failed: ${result.error}\nThe SynaBun browser could not open a new session: stop and report this. Never switch to another browser or tool.`);
|
|
131
|
+
const sessionId = String(result.sessionId);
|
|
132
|
+
const tabId = typeof result.tabId === 'string' ? result.tabId : null;
|
|
133
|
+
const ids = `sessionId "${sessionId}"${tabId ? ` and tabId "${tabId}"` : ''}`;
|
|
134
|
+
const lines = [...(profileLine ? [profileLine] : []), `Created session ${sessionId}${tabId ? `, tab ${tabId}` : ''} at ${typeof result.url === 'string' ? result.url : args.url || 'about:blank'}.`];
|
|
135
|
+
lines.push(result.repinned === true
|
|
136
|
+
? `This run's browser now works there: your next browser calls go to it with or without ids (pass ${ids} if you pass ids; never the old ones).`
|
|
137
|
+
: `Continue there: pass ${ids} to your next browser calls.`);
|
|
117
138
|
// Created, but MoreLogin refused the start URL (e.g. a localhost port missing from Port scan protection).
|
|
118
|
-
|
|
119
|
-
|
|
139
|
+
if (result.moreLoginBlocked === true && typeof result.notice === 'string') lines.push(result.notice);
|
|
140
|
+
if (typeof result.navigateError === 'string') lines.push(`Opening ${args.url} in it failed: ${result.navigateError}. Open it with browser_navigate.`);
|
|
141
|
+
return text(lines.join('\n'));
|
|
120
142
|
}
|
|
121
143
|
|
|
122
144
|
if (args.action === 'close') {
|
|
123
|
-
|
|
145
|
+
let named = args.sessionId;
|
|
146
|
+
if (args.tabId) {
|
|
147
|
+
// A tab named: only one of the caller's own (browserRouteStatus lists nobody else's), and it picks the session.
|
|
148
|
+
const status = await ni.browserRouteStatus();
|
|
149
|
+
if (status.error) return text(`Close failed: ${status.error}`);
|
|
150
|
+
const owner = status.sessions.find(s => s.tabs.some(t => t.id === args.tabId));
|
|
151
|
+
if (!owner) {
|
|
152
|
+
if (isGoneTab(status, args.tabId)) return text(`Tab ${args.tabId} is already gone; nothing was closed.${status.current?.open && status.current.tabId ? ` Your current tab is ${status.current.tabId}.` : ''}`);
|
|
153
|
+
return text(`Close refused: tab ${args.tabId} is not one of your tabs. You can close only your own tab; nothing was closed. Call browser_session with action "status" to see your tab id.`);
|
|
154
|
+
}
|
|
155
|
+
if (named && named !== owner.id) return text(`Close refused: your tab ${args.tabId} is in session ${owner.id}, not ${named}; nothing was closed.`);
|
|
156
|
+
named = owner.id;
|
|
157
|
+
}
|
|
158
|
+
const resolved = await ni.resolveSession(named);
|
|
124
159
|
if ('error' in resolved) return text(resolved.error);
|
|
125
160
|
|
|
126
161
|
const result = await ni.closeSession(resolved.sessionId);
|
|
127
162
|
if (result.error) return text(`Close failed: ${result.error}`);
|
|
163
|
+
if (result.sessionKept === true) {
|
|
164
|
+
// Other automations (scheduled runs) work in tabs of this browser: the server closed only this caller's tab.
|
|
165
|
+
const others = Number(result.otherOwners) || 0;
|
|
166
|
+
const released = typeof result.releasedTabId === 'string' ? `Only your tab ${result.releasedTabId} was closed` : 'You had no tab of your own in it, so nothing was closed';
|
|
167
|
+
return text(`Session ${resolved.sessionId} stays open: ${others} other automation${others === 1 ? '' : 's'} still use${others === 1 ? 's' : ''} tabs in it. ${released}. Do not close it again. Your next browser call opens a new tab of your own, and its answer starts with that tab's id ("a replacement tab … is open"): continue there, without browser_session create.`);
|
|
168
|
+
}
|
|
128
169
|
return text(`Closed session ${resolved.sessionId}`);
|
|
129
170
|
}
|
|
130
171
|
|
|
131
|
-
return text(`Unknown action "${args.action}". Use "list", "create", or "close".`);
|
|
172
|
+
return text(`Unknown action "${args.action}". Use "list", "status", "create", or "close".`);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Lost tabs of the caller's that the route status knows about. */
|
|
176
|
+
function isGoneTab(status: ni.BrowserRouteStatus, tabId: string): boolean {
|
|
177
|
+
return status.replacedTabs.includes(tabId)
|
|
178
|
+
|| status.lost?.tabId === tabId
|
|
179
|
+
|| status.movedFrom?.tabId === tabId
|
|
180
|
+
|| (!!status.current && !status.current.open && status.current.tabId === tabId);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** What a tabId passed to list / status means for the caller: only its own tabs are ever described. */
|
|
184
|
+
export function namedTabLine(status: ni.BrowserRouteStatus, tabId: string): string | null {
|
|
185
|
+
const current = status.current;
|
|
186
|
+
if (current?.open && current.tabId === tabId) return null;
|
|
187
|
+
if (isGoneTab(status, tabId)) {
|
|
188
|
+
return current?.open && current.tabId
|
|
189
|
+
? `Tab ${tabId} you passed is gone; tab ${current.tabId} (session ${current.sessionId}) replaced it. Use tabId ${current.tabId}.`
|
|
190
|
+
: `Tab ${tabId} you passed is gone. Your next browser call opens a new tab of your own and names it.`;
|
|
191
|
+
}
|
|
192
|
+
if (status.sessions.some(s => s.tabs.some(t => t.id === tabId))) {
|
|
193
|
+
return `Tab ${tabId} you passed is one of your tabs, but not the current one${current?.open && current.tabId ? ` (${current.tabId})` : ''}.`;
|
|
194
|
+
}
|
|
195
|
+
return `Tab ${tabId} you passed is not one of your tabs; it was ignored.`;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const quoteTitle = (title: string | undefined) => (title ? ` "${title}"` : '');
|
|
199
|
+
const otherTabsText = (n: number) => `${n} tab${n === 1 ? '' : 's'} of other automations or the owner`;
|
|
200
|
+
|
|
201
|
+
/** browser_session list: every session the caller can see, with its own tabs only. */
|
|
202
|
+
export function formatSessionList(status: ni.BrowserRouteStatus): string {
|
|
203
|
+
if (status.sessions.length === 0) return 'No browser sessions open. browser_navigate opens one by itself.';
|
|
204
|
+
const lines = [`${status.sessions.length} session(s); only your own tabs are listed:`];
|
|
205
|
+
for (const session of status.sessions) {
|
|
206
|
+
lines.push(` ${session.id}${session.servesDefault ? '' : ` — not ${status.profile ? 'the profile you work in' : 'the default browser'} (${session.profile}); SynaBun's browser tools do not use it`}`);
|
|
207
|
+
for (const tab of session.tabs) {
|
|
208
|
+
const isCurrent = status.current?.open && status.current.sessionId === session.id && status.current.tabId === tab.id;
|
|
209
|
+
lines.push(` tab ${tab.id} — ${tab.url || 'about:blank'}${quoteTitle(tab.title)}${isCurrent ? ' ← your current tab' : ''}`);
|
|
210
|
+
}
|
|
211
|
+
if (!session.tabs.length) lines.push(` no tab of yours${session.otherTabs ? ` (+${otherTabsText(session.otherTabs)})` : ''}`);
|
|
212
|
+
else if (session.otherTabs) lines.push(` +${otherTabsText(session.otherTabs)}`);
|
|
213
|
+
}
|
|
214
|
+
if (status.current && !status.current.open) lines.push(lostTabLine(status.current));
|
|
215
|
+
else if (!status.current) lines.push('You have no tab of your own yet: browser_navigate opens one.');
|
|
216
|
+
if (status.profile) lines.push(profileLineOf(status.profile));
|
|
217
|
+
return lines.join('\n');
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** The profile a caller works in when it is not the default. */
|
|
221
|
+
function profileLineOf(profile: NonNullable<ni.BrowserRouteStatus['profile']>): string {
|
|
222
|
+
return `Profile: you work in MoreLogin profile ${profile.name ? `"${profile.name}" (env ${profile.envId})` : `env ${profile.envId}`}, not the default one (morelogin "use" changes it; envId "default" goes back).`;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function lostTabLine(current: NonNullable<ni.BrowserRouteStatus['current']>): string {
|
|
226
|
+
return `Your tab ${current.tabId || '(none)'} of session ${current.sessionId} is gone. Your next browser call opens a new tab of your own, and its answer starts with that tab's id: continue there. Call browser_session create only if a browser call fails because the tab is gone and announces no replacement.`;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** browser_session status: the route the caller's next browser call uses, its page, and what replaced what. */
|
|
230
|
+
export function formatRouteStatus(status: ni.BrowserRouteStatus): string {
|
|
231
|
+
const current = status.current;
|
|
232
|
+
const withProfile = (line: string) => (status.profile ? `${line}\n${profileLineOf(status.profile)}` : line);
|
|
233
|
+
if (!current) {
|
|
234
|
+
if (status.lost) return withProfile(`Your tab ${status.lost.tabId || '(none)'} of session ${status.lost.sessionId} is gone and no tab replaced it yet. Your next browser call opens a new tab of your own, and its answer starts with that tab's id.`);
|
|
235
|
+
return withProfile('You have no browser tab yet: browser_navigate opens one (no browser_session create needed).');
|
|
236
|
+
}
|
|
237
|
+
if (!current.open) return withProfile(lostTabLine(current));
|
|
238
|
+
const lines = [
|
|
239
|
+
`Current session: ${current.sessionId}`,
|
|
240
|
+
`Current tab: ${current.tabId}`,
|
|
241
|
+
`Page: ${current.url || 'about:blank'}${quoteTitle(current.title)}`,
|
|
242
|
+
];
|
|
243
|
+
if (status.replacedTabs.length) {
|
|
244
|
+
lines.push(`Replaced: yes. This tab replaced your lost tab${status.replacedTabs.length === 1 ? '' : 's'} ${status.replacedTabs.join(', ')}; keep using tabId ${current.tabId}.`);
|
|
245
|
+
} else if (status.movedFromPin) {
|
|
246
|
+
// Only a move from a tab the run knew: the route the server recorded for a fresh run is its launch route, not one.
|
|
247
|
+
const from = status.movedFrom?.tabId && status.movedFrom.tabId !== current.tabId ? ` from tab ${status.movedFrom.tabId}` : '';
|
|
248
|
+
lines.push(`Replaced: yes. SynaBun moved your run's browser to this tab${from} (a recovery or your own create); keep using tabId ${current.tabId}.`);
|
|
249
|
+
} else {
|
|
250
|
+
lines.push('Replaced: no.');
|
|
251
|
+
}
|
|
252
|
+
if (status.lost && !(status.lost.sessionId === current.sessionId && status.lost.tabId === current.tabId)) {
|
|
253
|
+
lines.push(`Your tab ${status.lost.tabId || '(none)'} of session ${status.lost.sessionId} went away; your next browser call may open a new tab and will say so.`);
|
|
254
|
+
}
|
|
255
|
+
if (status.profile) lines.push(profileLineOf(status.profile));
|
|
256
|
+
return lines.join('\n');
|
|
132
257
|
}
|
|
@@ -124,6 +124,9 @@ PRECONDITION: a logged-in bsky.app tab must be the target (the session token is
|
|
|
124
124
|
export const browserCheatsheetSchema = {
|
|
125
125
|
platform: z.enum(PLATFORMS).describe('Target platform to fetch selectors for.'),
|
|
126
126
|
action: z.enum(ACTIONS).optional().describe('Optional: filter to a single action (click/type/fill/scroll/snapshot/extract/evaluate). If omitted, returns every action known for the platform.'),
|
|
127
|
+
// Clients that pass their route to every browser tool (Codex) send these too; a lookup opens no page, so they are accepted and ignored.
|
|
128
|
+
sessionId: z.string().optional().describe('Ignored: the cheatsheet opens no page. Accepted so a call that names your browser route is not flagged.'),
|
|
129
|
+
tabId: z.string().optional().describe('Ignored: the cheatsheet opens no page. Accepted so a call that names your browser route is not flagged.'),
|
|
127
130
|
};
|
|
128
131
|
|
|
129
132
|
export const browserCheatsheetDescription =
|
|
@@ -2,8 +2,6 @@ import { z } from 'zod/v3';
|
|
|
2
2
|
import * as ni from '../services/neural-interface.js';
|
|
3
3
|
import { text } from './response.js';
|
|
4
4
|
import { formatInlineSnapshot, formatAiSnapshotBody } from './browser-observe.js';
|
|
5
|
-
import { autosnapshotEnabled } from './browser-interact.js';
|
|
6
|
-
import * as assist from '../services/browser-assist.js';
|
|
7
5
|
|
|
8
6
|
const tabIdField = z.string().optional().describe('Target a specific tab within the session. Auto-resolved from environment if omitted.');
|
|
9
7
|
|
|
@@ -25,6 +23,15 @@ function formatBrowserLocation(result: Record<string, unknown>, action: string):
|
|
|
25
23
|
|
|
26
24
|
const NAVIGATE_SNAPSHOT_MAX_CHARS = 12000;
|
|
27
25
|
|
|
26
|
+
const SLOW_LOAD_FALLBACK_NOTICE = 'the document committed but is still loading; wait a moment, then read it with browser_snapshot. Do not navigate to it again.';
|
|
27
|
+
|
|
28
|
+
/** A navigate the server answered `slowLoad: true`: the URL and the server's notice, nothing else. */
|
|
29
|
+
export function formatSlowLoad(result: Record<string, unknown>, requestedUrl: string): string {
|
|
30
|
+
const url = typeof result.url === 'string' && result.url ? result.url : requestedUrl;
|
|
31
|
+
const notice = typeof result.notice === 'string' && result.notice.trim() ? result.notice.trim() : SLOW_LOAD_FALLBACK_NOTICE;
|
|
32
|
+
return `Slow page: ${url}\nnote: ${notice}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
28
35
|
// One-line per-platform steering appended to navigate responses: points the model at
|
|
29
36
|
// the cheap extraction path instead of full snapshots on feed-heavy sites.
|
|
30
37
|
const PLATFORM_HINTS: Array<{ re: RegExp; hint: string }> = [
|
|
@@ -51,21 +58,18 @@ function platformHint(url: unknown): string {
|
|
|
51
58
|
|
|
52
59
|
export const browserNavigateSchema = {
|
|
53
60
|
url: z.string().describe('The URL to navigate to.'),
|
|
54
|
-
snapshot: z.enum(['full', 'diff', 'none']).optional().describe('Inline AI snapshot of the new page
|
|
55
|
-
intent: z.string().max(300).optional().describe('What you expect this page to let you do or show (e.g. "read my open invoices"). Adds a "goal satisfied" estimate to the page assessment. Advisory only.'),
|
|
61
|
+
snapshot: z.enum(['full', 'diff', 'none']).optional().describe('Inline AI snapshot of the new page. Default "none": a terse answer as soon as the page loads. "full" waits for the document to parse and returns [ref=eN] refs; otherwise call browser_snapshot when you need the page structure.'),
|
|
56
62
|
returnSnapshot: returnSnapshotField,
|
|
57
63
|
sessionId: z.string().optional().describe('Browser session ID. If omitted, auto-selects the only open session or creates a new one.'),
|
|
58
64
|
tabId: tabIdField,
|
|
59
65
|
};
|
|
60
66
|
|
|
61
67
|
export const browserNavigateDescription =
|
|
62
|
-
'Navigate the browser to a URL (auto-creates a session if needed).
|
|
63
|
-
'A "Jev assessment:" line may follow (usable, loading, authentication_required, verification_required, consent_blocker, error, empty): it is advice about the page, never an action. On a sign-in or verification wall, stop and hand over to a human.';
|
|
68
|
+
'Navigate the browser to a URL (auto-creates a session if needed). Returns as soon as the page commits (url, title, loadState "commit" or "domcontentloaded"); no snapshot by default. Call browser_snapshot for the page structure and [ref=eN] refs, or pass snapshot:"full" to get them inline (that waits for the document to parse).';
|
|
64
69
|
|
|
65
70
|
export async function handleBrowserNavigate(args: {
|
|
66
71
|
url: string;
|
|
67
72
|
snapshot?: 'full' | 'diff' | 'none';
|
|
68
|
-
intent?: string;
|
|
69
73
|
returnSnapshot?: { mode?: 'full' | 'interactive' | 'landmarks'; selector?: string; viewport?: boolean; maxChars?: number; format?: 'text' | 'json' };
|
|
70
74
|
sessionId?: string;
|
|
71
75
|
tabId?: string;
|
|
@@ -80,20 +84,19 @@ export async function handleBrowserNavigate(args: {
|
|
|
80
84
|
selector: args.returnSnapshot.selector,
|
|
81
85
|
viewport: args.returnSnapshot.viewport,
|
|
82
86
|
} : undefined;
|
|
83
|
-
//
|
|
84
|
-
const snapshot = args.snapshot
|
|
85
|
-
|
|
86
|
-
const assess = assist.assistAvailable('browser-page-state');
|
|
87
|
-
const result = await ni.navigate(resolved.sessionId, args.url, resolved.tabId, rs, snapshot, undefined, { semanticContext: assess });
|
|
87
|
+
// No snapshot unless asked (2026-11-08 benchmark: the default full snapshot cost seconds per navigate).
|
|
88
|
+
const snapshot = args.snapshot === 'full' || args.snapshot === 'diff' ? args.snapshot : undefined;
|
|
89
|
+
const result = await ni.navigate(resolved.sessionId, args.url, resolved.tabId, rs, snapshot, undefined);
|
|
88
90
|
if (result.error) return text(`Navigation failed: ${result.error}`);
|
|
91
|
+
// The document committed but did not finish loading in the server's budget (x.com's cold first
|
|
92
|
+
// load): there is no title, snapshot or page context yet, so none is printed as "(empty page)".
|
|
93
|
+
if (result.slowLoad === true) return text(formatSlowLoad(result, args.url));
|
|
89
94
|
|
|
90
95
|
let msg = formatBrowserLocation(result, 'Navigated');
|
|
96
|
+
if (result.loadState === 'commit') msg += ' (still parsing)';
|
|
91
97
|
if (typeof result.notice === 'string') msg += `\nnote: ${result.notice}`;
|
|
92
98
|
msg += platformHint(result.url);
|
|
93
|
-
|
|
94
|
-
// rate-limited, unsure, or the page is an unremarkable "usable" in compact mode.
|
|
95
|
-
if (assess) msg += await assist.assessNavigation(result, args.intent);
|
|
96
|
-
if (snapshot && snapshot !== 'none') {
|
|
99
|
+
if (snapshot) {
|
|
97
100
|
msg += `\n\n--- Snapshot ---\n${formatAiSnapshotBody(result, NAVIGATE_SNAPSHOT_MAX_CHARS)}`;
|
|
98
101
|
} else if (args.returnSnapshot) {
|
|
99
102
|
const snap = formatInlineSnapshot(result, {
|
|
@@ -489,6 +489,8 @@ interface PagedOpts extends PagedArgs {
|
|
|
489
489
|
|
|
490
490
|
interface PagedResult {
|
|
491
491
|
items: Array<Record<string, unknown>>;
|
|
492
|
+
/** The distinct `type` of the returned items, read before `fields` projected them (null: no string type). */
|
|
493
|
+
types?: Array<string | null>;
|
|
492
494
|
raw: number;
|
|
493
495
|
scrollsUsed: number;
|
|
494
496
|
truncated: boolean;
|
|
@@ -571,6 +573,7 @@ async function runPagedExtractor(
|
|
|
571
573
|
|
|
572
574
|
const all = [...collected.values()];
|
|
573
575
|
const items: Array<Record<string, unknown>> = [];
|
|
576
|
+
const types = new Set<string | null>();
|
|
574
577
|
let chars = 2;
|
|
575
578
|
let budgetReason: string | undefined;
|
|
576
579
|
for (const item of all) {
|
|
@@ -579,9 +582,21 @@ async function runPagedExtractor(
|
|
|
579
582
|
const size = JSON.stringify(value).length + (items.length ? 1 : 0);
|
|
580
583
|
if (opts.maxChars !== undefined && chars + size > opts.maxChars) { budgetReason = 'max_chars'; break; }
|
|
581
584
|
items.push(value); chars += size;
|
|
585
|
+
types.add(typeof item.type === 'string' ? item.type : null);
|
|
582
586
|
}
|
|
583
587
|
if (items.length === 0 && budgetReason === 'max_chars') return { error: 'maxChars is too small for the first complete item. Increase maxChars or select fewer fields.' };
|
|
584
|
-
return { items, raw, scrollsUsed, truncated: items.length < all.length, partial: !!failureReason, stopReason: budgetReason || stopReason, failureReason, budgetReason };
|
|
588
|
+
return { items, types: [...types], raw, scrollsUsed, truncated: items.length < all.length, partial: !!failureReason, stopReason: budgetReason || stopReason, failureReason, budgetReason };
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Whether every returned item is of `type`, decided on the items before `fields` projected them
|
|
593
|
+
* (`types`, from the server or the local loop). A server from before `types` answers from the
|
|
594
|
+
* projected items, where a projection without `type` reads as untyped.
|
|
595
|
+
*/
|
|
596
|
+
function extractedTypesAre(res: PagedResult, type: string): boolean {
|
|
597
|
+
if (res.items.length === 0) return false;
|
|
598
|
+
if (Array.isArray(res.types)) return res.types.length > 0 && res.types.every(t => t === type);
|
|
599
|
+
return res.items.every(item => item.type === type);
|
|
585
600
|
}
|
|
586
601
|
|
|
587
602
|
/**
|
|
@@ -614,23 +629,49 @@ const SCROLLABLE_ANCESTOR = (innerSelector: string) =>
|
|
|
614
629
|
|
|
615
630
|
// ── browser_extract_tweets ──
|
|
616
631
|
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
632
|
+
// One expression, DOM queries only (no eval, innerHTML or script insertion): the server embeds
|
|
633
|
+
// it in the page functions of the paged extraction, which x.com's CSP ('script-src' without
|
|
634
|
+
// 'unsafe-eval') must not be able to refuse. Exported for the fixture test
|
|
635
|
+
// (neural-interface/tests/x-extractor.browser.mjs) that runs it against X-shaped pages.
|
|
636
|
+
export const TWEET_EXTRACTOR_SCRIPT = `
|
|
637
|
+
(() => {
|
|
638
|
+
const tweets = Array.from(document.querySelectorAll('[data-testid="tweet"]')).map(el => {
|
|
639
|
+
const userNameEl = el.querySelector('[data-testid="User-Name"]');
|
|
640
|
+
const lines = userNameEl ? userNameEl.innerText.split('\\n').filter(Boolean) : [];
|
|
641
|
+
const statusLink = el.querySelector('a[href*="/status/"]');
|
|
642
|
+
return {
|
|
643
|
+
author: lines[0] || null,
|
|
644
|
+
handle: lines.find(l => l.startsWith('@')) || null,
|
|
645
|
+
text: el.querySelector('[data-testid="tweetText"]')?.innerText || null,
|
|
646
|
+
time: el.querySelector('time')?.getAttribute('datetime') || null,
|
|
647
|
+
url: statusLink ? statusLink.href : null,
|
|
648
|
+
replies: el.querySelector('[data-testid="reply"] span[data-testid="app-text-transition-container"]')?.innerText || null,
|
|
649
|
+
reposts: el.querySelector('[data-testid="retweet"] span[data-testid="app-text-transition-container"]')?.innerText || null,
|
|
650
|
+
likes: el.querySelector('[data-testid="like"] span[data-testid="app-text-transition-container"]')?.innerText || null,
|
|
651
|
+
views: el.querySelector('a[href*="/analytics"] span')?.innerText || null,
|
|
652
|
+
};
|
|
653
|
+
});
|
|
654
|
+
// Explore's tabs (trending, for-you, news, ...) list trends, not posts: say what is there.
|
|
655
|
+
if (tweets.length || !/^\\/(explore|i\\/trends)(\\/|$)/.test(location.pathname)) return tweets;
|
|
656
|
+
const rowText = row => (row?.innerText || '').split('\\n').map(s => s.trim()).filter(s => s && s !== '·');
|
|
657
|
+
// The page's own column only: the sidebar's "What's happening" trends are never the answer.
|
|
658
|
+
const column = document.querySelector('[data-testid="primaryColumn"]');
|
|
659
|
+
return Array.from(column ? column.querySelectorAll('[data-testid="trend"]') : []).map((el, i) => {
|
|
660
|
+
// A cell is rows: context (rank · category), name, an optional post count; the caret button is not one.
|
|
661
|
+
const rows = Array.from(el.firstElementChild?.children || []).filter(row => !row.querySelector('button'));
|
|
662
|
+
const context = rowText(rows[0]);
|
|
663
|
+
const rank = /^\\d+$/.test(context[0] || '') ? Number(context[0]) : null;
|
|
664
|
+
const name = rowText(rows[1]).join(' ') || null;
|
|
665
|
+
return {
|
|
666
|
+
type: 'trend',
|
|
667
|
+
rank: rank ?? i + 1,
|
|
668
|
+
category: (rank === null ? context : context.slice(1)).join(' ') || null,
|
|
669
|
+
text: name,
|
|
670
|
+
posts: rowText(rows[2]).join(' ') || null,
|
|
671
|
+
url: name ? 'https://x.com/search?q=' + encodeURIComponent(name) + '&src=typed_query&f=live' : null,
|
|
672
|
+
};
|
|
673
|
+
});
|
|
674
|
+
})()
|
|
634
675
|
`.trim();
|
|
635
676
|
|
|
636
677
|
export const browserExtractTweetsSchema = {
|
|
@@ -640,7 +681,8 @@ export const browserExtractTweetsSchema = {
|
|
|
640
681
|
};
|
|
641
682
|
|
|
642
683
|
export const browserExtractTweetsDescription =
|
|
643
|
-
'Extract visible tweets as structured JSON (author, handle, text, time, url, replies, reposts, likes, views). Pass scrolls/minItems to auto-scroll, extract, and dedupe in ONE call (e.g. scrolls:3 minItems:30). Much faster than browser_snapshot for data harvesting. Navigate to x.com/search?q=%23hashtag&f=live first for latest-first hashtag results.'
|
|
684
|
+
'Extract visible tweets as structured JSON (author, handle, text, time, url, replies, reposts, likes, views). Pass scrolls/minItems to auto-scroll, extract, and dedupe in ONE call (e.g. scrolls:3 minItems:30). Much faster than browser_snapshot for data harvesting. Navigate to x.com/search?q=%23hashtag&f=live first for latest-first hashtag results. ' +
|
|
685
|
+
'An Explore tab (x.com/explore/tabs/trending, for-you, news) lists trends, not posts: there it returns the trends instead, {type:"trend", rank, category, text, posts, url} with url a latest-first search for the trend.';
|
|
644
686
|
|
|
645
687
|
export async function handleBrowserExtractTweets(args: PagedArgs & { sessionId?: string; tabId?: string }) {
|
|
646
688
|
const resolved = await ni.resolveSession(args.sessionId, undefined, args.tabId);
|
|
@@ -652,7 +694,7 @@ export async function handleBrowserExtractTweets(args: PagedArgs & { sessionId?:
|
|
|
652
694
|
if ('error' in res) return text(`Extract failed: ${res.error}`);
|
|
653
695
|
if (res.items.length === 0) return emptyExtraction(resolved, 'browser_extract_tweets', 'an X/Twitter timeline, profile or search results page', 'No tweets found. Try browser_scroll (or pass scrolls:2) then retry.');
|
|
654
696
|
|
|
655
|
-
return text(formatExtraction('tweet', res));
|
|
697
|
+
return text(formatExtraction(extractedTypesAre(res, 'trend') ? 'trend' : 'tweet', res));
|
|
656
698
|
}
|
|
657
699
|
|
|
658
700
|
// ── browser_x_compose_state ──
|
|
@@ -8,31 +8,61 @@ import { text } from './response.js';
|
|
|
8
8
|
// ═══════════════════════════════════════════
|
|
9
9
|
|
|
10
10
|
export const moreloginSchema = {
|
|
11
|
-
action: z.enum(['status', 'list', 'create', 'start', 'stop', 'use_default']).describe(
|
|
12
|
-
'MoreLogin action. "status" = installed/running
|
|
11
|
+
action: z.enum(['status', 'list', 'create', 'start', 'stop', 'use', 'use_default']).describe(
|
|
12
|
+
'MoreLogin action. "status" = installed/running, the default profile and the profile you work in. "list" = browser profiles (environments). "create" = new profile. "use" = work in a profile yourself: from now on YOUR browser_* tools (with or without session and tab ids) open and drive pages in that profile, in a tab of your own; nobody else moves, and it works while other automations use the default or any other profile. Pass envId or name; envId "default" goes back to the default profile. Your next browser call opens your tab there (the profile is started then) and your tab in the profile you left is closed. Only a profile the owner allowed agents to choose can be used ("list" and "status" say which; none is allowed until the owner switches one on): a refusal with MORELOGIN_PROFILE_NOT_ALLOWED means the profile is not on the owner\'s list, so tell the user to switch it on in SynaBun → Settings → Connected tools → MoreLogin → MoreLogin profiles → "Agents may choose" and stop; never use another profile or browser instead. The same list holds for "start": it is refused with MORELOGIN_PROFILE_NOT_ALLOWED for a profile that is not on it. "start"/"stop" = launch/close a profile without working in it (stop closes every tab in that browser: you may stop only a profile you started or have a tab in, and never while other automations have a tab in it). "use_default" is always refused: the default AI browser is the owner\'s choice (Settings → Browser); to work in another profile, call "use". "use" works for any session of SynaBun\'s MCP that proves its id: a run SynaBun started, a side panel, or a CLI window\'s own session of SynaBun\'s HTTP MCP. "start" is for a run SynaBun started; the owner does the rest in Settings → Browser.'
|
|
13
13
|
),
|
|
14
14
|
envId: z.string().optional().describe(
|
|
15
|
-
'MoreLogin environment
|
|
15
|
+
'Profile id (a MoreLogin environment id, or a local profile id that starts with "lp-"): required for start and stop; for "use" pass it or name ("default" = back to the default profile). Get ids from the "list" action.'
|
|
16
16
|
),
|
|
17
17
|
name: z.string().optional().describe(
|
|
18
|
-
'
|
|
18
|
+
'A profile name: the profile to work in ("use" action, as "list" shows it), or the name of a new profile ("create", default "SynaBun").'
|
|
19
19
|
),
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export const moreloginDescription =
|
|
23
|
-
'Manage MoreLogin (anti-detect, multi-account browser) profiles. Actions: "status" (is MoreLogin installed/running,
|
|
23
|
+
'Manage MoreLogin (anti-detect, multi-account browser) profiles and pick the one you work in. Actions: "status" (is MoreLogin installed/running, the default profile, the profile you work in), "list" (profiles), "create" (new profile), "use" (work in a profile yourself: your browser_* tools drive it from then on, in your own tab, without changing the default or disturbing any other session; several sessions can work in different profiles at the same time), "start"/"stop" (launch/close a profile). "use" and "start" take only a profile the owner allowed agents to choose. "use_default" is always refused: the default AI browser is the owner\'s choice in Settings → Browser. To work in a profile other than the default, call "use" with its envId or name, then use the browser tools as usual: never tell the user you cannot control a second profile, and never change the default for that. You can choose only a profile the owner allowed agents to choose (the list is the owner\'s, in SynaBun\'s Settings; it is empty until the owner switches a profile on, and "list" / "status" show it). When "use" or "start" is refused because the profile is not on that list, nothing was opened, started or changed: tell the user which profile to switch on and where (SynaBun → Settings → Connected tools → MoreLogin → MoreLogin profiles → "Agents may choose"), and do not work in another profile or browser instead. Only Chrome-type profiles can be driven. Requires the MoreLogin desktop app to be running with its local API enabled. Profiles of two kinds are listed and used the same way, by the same ids: MoreLogin profiles, and local profiles (a Chrome SynaBun runs itself on this computer, with its own cookies, proxy, language and timezone; "list" marks them "local"; they work with MoreLogin closed or not installed). Both are on the same owner\'s list of profiles agents may choose. Local profiles are created, edited and deleted by the owner in Settings only; "create" makes a MoreLogin profile.';
|
|
24
24
|
|
|
25
|
-
interface MlEnv { id: string; name: string; status?: string }
|
|
25
|
+
interface MlEnv { id: string; name: string; status?: string; browser?: string | null; agentsMayChoose?: boolean; kind?: string }
|
|
26
|
+
|
|
27
|
+
/** Whether an id is a local profile's (neural-interface/lib/local-profiles.js: `lp-` and 12 hex characters). */
|
|
28
|
+
export function isLocalProfileId(id: unknown): boolean {
|
|
29
|
+
return typeof id === 'string' && /^lp-[0-9a-f]{12}$/.test(id);
|
|
30
|
+
}
|
|
31
|
+
/** "local profile" for one of SynaBun's own profiles, "MoreLogin env" for every other id. */
|
|
32
|
+
const profileNoun = (id: unknown) => (isLocalProfileId(id) ? 'local profile' : 'MoreLogin env');
|
|
33
|
+
/** What "status" adds about SynaBun's local profiles (`localProfileCount`; a server from before them says nothing). */
|
|
34
|
+
function localProfilesNote(count: unknown): string {
|
|
35
|
+
const n = Number(count);
|
|
36
|
+
return Number.isFinite(n) && n > 0 ? ` SynaBun also has ${n} local profile(s) of its own, which need no MoreLogin ("list" shows them).` : '';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Where the owner edits the list of profiles agents may choose (neural-interface/lib/morelogin-agent-profiles.js). */
|
|
40
|
+
export const AGENT_PROFILES_WHERE = 'SynaBun → Settings → Connected tools → MoreLogin → MoreLogin profiles → "Agents may choose"';
|
|
41
|
+
|
|
42
|
+
/** The owner's list as one sentence for "status" and "list" (`agentProfiles` of the server's answer). */
|
|
43
|
+
export function agentProfilesLine(list: unknown): string {
|
|
44
|
+
if (!Array.isArray(list)) return 'This SynaBun server does not say which profiles agents may choose (it was started before that list existed).';
|
|
45
|
+
const rows = (list as Array<{ envId?: unknown; name?: unknown }>).filter(row => row && row.envId);
|
|
46
|
+
if (!rows.length) return `Profiles agents may choose: none. The owner has allowed no profile, so "use", browser_session create with moreloginProfile and agent_dispatch morelogin_profile are refused for every profile; the default profile still works. The owner allows one in ${AGENT_PROFILES_WHERE}.`;
|
|
47
|
+
return `Profiles agents may choose (the owner's list): ${rows.map(row => (typeof row.name === 'string' && row.name ? `${row.name} (id ${row.envId})` : `id ${row.envId}`)).join(', ')}. Any other profile is refused; the owner adds one in ${AGENT_PROFILES_WHERE}.`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** What "use_default" answers: agents never change the default AI browser (finding 1 of the re-review of 2026-11-11). */
|
|
51
|
+
export const USE_DEFAULT_REFUSAL = 'use_default refused: the default AI browser (the default MoreLogin profile) is the owner\'s choice, made in SynaBun → Settings → Browser, and no agent or session can change it, whatever the profile. Nothing was changed. To work in another MoreLogin profile yourself, call morelogin with action "use" and its envId or name: only your own browser tools move there. Tell the user: if every automation should use that profile by default, set it in Settings → Browser.';
|
|
26
52
|
|
|
27
53
|
export async function handleMoreLogin(args: { action: string; envId?: string; name?: string }) {
|
|
28
54
|
switch (args.action) {
|
|
29
55
|
case 'status': {
|
|
30
56
|
const r = await ni.moreloginStatus();
|
|
31
|
-
const
|
|
57
|
+
const mine = r.yourProfile as { envId?: string; name?: string | null; refused?: string } | undefined;
|
|
58
|
+
const def = `${r.isDefault && r.defaultEnvId ? `default AI browser = env ${r.defaultEnvId}` : 'no MoreLogin default set'}${mine?.envId ? `; you work in ${mine.name ? `"${mine.name}" (env ${mine.envId})` : `env ${mine.envId}`} (your own choice or your run's profile, not the default)` : ''}.${mine?.refused ? ` Your browser calls are refused there: ${mine.refused}` : ''} ${agentProfilesLine(r.agentProfiles)}`.replace(/\.$/, '');
|
|
32
59
|
// An API that answered with an error is running: say what it rejected, never "unreachable".
|
|
33
|
-
|
|
34
|
-
if (r.running) return text(`MoreLogin running on port ${r.port}. ${r.profileCount} profile(s). ${def}
|
|
60
|
+
const local = localProfilesNote(r.localProfileCount);
|
|
61
|
+
if (r.running && r.apiError) return text(`MoreLogin running on port ${r.port}, API rejected: ${r.apiError}. ${r.profileCount || 0} profile(s). ${def}.${local}`);
|
|
62
|
+
if (r.running) return text(`MoreLogin running on port ${r.port}. ${r.profileCount} profile(s). ${def}.${local}`);
|
|
35
63
|
if (!r.installed && r.port == null && r.error) return text(`MoreLogin unreachable: ${r.error}`);
|
|
64
|
+
// MoreLogin is closed or absent, and SynaBun's own local profiles work all the same: say both, with the list.
|
|
65
|
+
if (local) return text(`${r.installed ? `MoreLogin is installed but its local API is not running on port ${r.port}` : 'MoreLogin is not installed'}.${local} ${def}.`);
|
|
36
66
|
if (!r.installed) return text('MoreLogin is not installed (no app in a known folder and nothing answers on its port). Install it from https://www.morelogin.com, or set MORELOGIN_APP_PATH to a MoreLogin.exe in a custom folder.');
|
|
37
67
|
return text(`MoreLogin is installed but its local API is not running on port ${r.port}. Open the MoreLogin app and enable Settings → API & MCP.${r.error ? ` (${r.error})` : ''}`);
|
|
38
68
|
}
|
|
@@ -41,40 +71,73 @@ export async function handleMoreLogin(args: { action: string; envId?: string; na
|
|
|
41
71
|
if (r.error) return text(`MoreLogin list failed: ${r.error}`);
|
|
42
72
|
const envs = (r.envs || []) as MlEnv[];
|
|
43
73
|
if (!envs.length) return text('No MoreLogin profiles found. Create one with action "create" (or one is auto-created on first use).');
|
|
44
|
-
|
|
74
|
+
// Each profile says whether the owner allowed agents to choose it, so nobody has to try to find out.
|
|
75
|
+
const mark = (e: MlEnv) => (e.browser === 'firefox' ? 'Firefox-type, cannot be driven' : e.agentsMayChoose === true ? 'agents may choose it' : e.agentsMayChoose === false ? 'not allowed for agents' : null);
|
|
76
|
+
// Local profiles (SynaBun's own Chrome on this computer) are listed with MoreLogin's and say their kind; the
|
|
77
|
+
// same ids work for "use", "start" and "stop". With none, the list reads as it always did.
|
|
78
|
+
const anyLocal = envs.some(e => e.kind === 'local');
|
|
79
|
+
const kind = (e: MlEnv) => (anyLocal ? ` — ${e.kind === 'local' ? 'local' : 'MoreLogin'}` : '');
|
|
80
|
+
const missing = typeof r.moreloginError === 'string' && r.moreloginError ? `\nMoreLogin's own profiles are not listed: ${r.moreloginError}` : '';
|
|
81
|
+
return text(`${anyLocal ? 'Profiles (MoreLogin and local)' : 'MoreLogin profiles'}:\n` + envs.map(e => ` • ${e.name} (id ${e.id})${kind(e)}${e.status ? ` — ${e.status}` : ''}${mark(e) ? ` — ${mark(e)}` : ''}`).join('\n') + `${missing}\n${agentProfilesLine(r.agentProfiles)}`);
|
|
45
82
|
}
|
|
46
83
|
case 'create': {
|
|
47
84
|
const r = await ni.moreloginCreate(args.name);
|
|
48
|
-
|
|
85
|
+
// MoreLogin's plan holds no more profiles: a local profile needs no slot, and only the owner creates one.
|
|
86
|
+
if (r.error) return text(`Create failed: ${r.error}${r.code === 'MORELOGIN_PLAN_LIMIT' ? '\nNothing was created. A local profile is created by the owner in SynaBun → Settings → Connected tools → MoreLogin, never by an agent: tell the user, and stop there.' : ''}`);
|
|
49
87
|
const ids = (r.ids || []) as string[];
|
|
50
88
|
return text(`Created MoreLogin profile${ids.length ? ` (id ${ids.join(', ')})` : ''}.`);
|
|
51
89
|
}
|
|
52
90
|
case 'start': {
|
|
53
91
|
if (!args.envId) return text('envId is required for the "start" action. Use "list" to get ids.');
|
|
54
92
|
const r = await ni.moreloginStart(args.envId);
|
|
55
|
-
|
|
56
|
-
return text(`
|
|
93
|
+
// A profile off the owner's list is not started for an agent (server: POST /api/morelogin/start, B1 of the 2026-11-10 re-review).
|
|
94
|
+
if (r.error) return text(`Start failed: ${r.error}${r.code === 'MORELOGIN_PROFILE_NOT_ALLOWED' ? '\nNothing was started. Tell the user what to switch on, and stop there.' : ''}`);
|
|
95
|
+
// The owner's page gets the profile's debugging port; an automation does not (a raw CDP connection would drive
|
|
96
|
+
// the profile past every check SynaBun makes), and needs none: the browser tools drive the profile it works in.
|
|
97
|
+
return text(`Started ${profileNoun(args.envId)} ${args.envId}${r.debugPort ? ` (debug port ${r.debugPort})` : ''}. Starting a profile does not move your browser tools there: to work in it, call morelogin with action "use" and this envId.`);
|
|
57
98
|
}
|
|
58
99
|
case 'stop': {
|
|
59
100
|
if (!args.envId) return text('envId is required for the "stop" action.');
|
|
60
101
|
const r = await ni.moreloginStop(args.envId);
|
|
61
102
|
if (r.error) return text(`Stop failed: ${r.error}`);
|
|
62
|
-
return text(`Stopped
|
|
103
|
+
return text(`Stopped ${profileNoun(args.envId)} ${args.envId}.`);
|
|
104
|
+
}
|
|
105
|
+
case 'use': {
|
|
106
|
+
const toDefault = (args.envId || '').trim().toLowerCase() === 'default' || (!args.envId && (args.name || '').trim().toLowerCase() === 'default');
|
|
107
|
+
if (!toDefault && !args.envId && !args.name) return text('The "use" action needs envId or name (the "list" action gives both), or envId "default" to go back to the default profile.');
|
|
108
|
+
const r = await ni.useSessionProfile(toDefault ? { default: true } : { ...(args.envId ? { envId: args.envId } : {}), ...(args.name ? { name: args.name } : {}) });
|
|
109
|
+
if (r.error) return text(`use failed: ${r.error}\nNothing changed: you still work where you did. Never fall back to another profile or browser by yourself.${r.code === 'MORELOGIN_PROFILE_NOT_ALLOWED' ? ' Tell the user what to switch on, and stop there.' : ''}`);
|
|
110
|
+
return text(useAnswer(r));
|
|
63
111
|
}
|
|
64
112
|
case 'use_default': {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return text(
|
|
113
|
+
// Finding 1 of the re-review of 2026-11-11: the default AI browser is the owner's choice alone, for every caller
|
|
114
|
+
// and every profile. The tool answers without asking the server, which refuses it too (403
|
|
115
|
+
// MORELOGIN_DEFAULT_OWNER_ONLY in POST /api/morelogin/use-default) for anything that is not the owner's page.
|
|
116
|
+
return text(USE_DEFAULT_REFUSAL);
|
|
69
117
|
}
|
|
70
118
|
default:
|
|
71
119
|
return text(`Unknown action: ${args.action}`);
|
|
72
120
|
}
|
|
73
121
|
}
|
|
74
122
|
|
|
123
|
+
/** What "use" answers: where the caller works now, what was closed, and what its next browser call does. */
|
|
124
|
+
export function useAnswer(r: Record<string, unknown>): string {
|
|
125
|
+
const label = (envId: unknown, name: unknown) => (isLocalProfileId(envId)
|
|
126
|
+
? (typeof name === 'string' && name ? `local profile "${name}" (id ${envId})` : `local profile ${envId}`)
|
|
127
|
+
: (typeof name === 'string' && name ? `MoreLogin profile "${name}" (env ${envId})` : `MoreLogin profile env ${envId}`));
|
|
128
|
+
const now = r.default === true ? 'the default browser profile (Settings → Browser)' : label(r.envId, r.name);
|
|
129
|
+
if (r.changed !== true) return `You already work in ${now}. Nothing changed.`;
|
|
130
|
+
const released = Array.isArray(r.released) ? r.released as Array<{ sessionId?: string; tabId?: string | null }> : [];
|
|
131
|
+
const closed = released.filter(x => x && x.tabId).map(x => `tab ${x.tabId} of session ${x.sessionId}`);
|
|
132
|
+
const lines = [`You now work in ${now}. Only your own browser tools moved: the default AI browser and every other session are unchanged.`];
|
|
133
|
+
if (closed.length) lines.push(`Your ${closed.join(', ')} in the profile you left ${closed.length === 1 ? 'was' : 'were'} released: do not pass those ids again.`);
|
|
134
|
+
lines.push('Your next browser call (browser_navigate with a URL, without ids) opens a tab of your own there; the profile is started then if it is not running, which can take a minute or two. If it cannot start, that call fails and names the profile: report it, never switch to another profile or browser by yourself.');
|
|
135
|
+
return lines.join('\n');
|
|
136
|
+
}
|
|
137
|
+
|
|
75
138
|
/**
|
|
76
139
|
* Register the MoreLogin MCP tool on the given server instance.
|
|
77
|
-
* Single tool with action-based dispatch: status, list, create, start, stop, use_default.
|
|
140
|
+
* Single tool with action-based dispatch: status, list, create, start, stop, use, use_default (always refused).
|
|
78
141
|
*/
|
|
79
142
|
export function registerMoreLoginTools(server: McpServer) {
|
|
80
143
|
return [
|
|
@@ -69,9 +69,9 @@ export async function pollFor<T = unknown>(
|
|
|
69
69
|
export async function safeNavigate(
|
|
70
70
|
r: Resolved,
|
|
71
71
|
url: string,
|
|
72
|
-
): Promise<{ error?: string; sessionInvalidated?: boolean }> {
|
|
72
|
+
): Promise<{ error?: string; sessionInvalidated?: boolean; wedgedTabRetired?: boolean }> {
|
|
73
73
|
let res = await ni.navigate(r.sessionId, url, r.tabId);
|
|
74
|
-
if (res.error && !res.sessionInvalidated && /Timeout/i.test(res.error)) {
|
|
74
|
+
if (res.error && !res.sessionInvalidated && /Timeout/i.test(res.error) && !res.wedgedTabRetired) {
|
|
75
75
|
await wait(600);
|
|
76
76
|
res = await ni.navigate(r.sessionId, url, r.tabId);
|
|
77
77
|
}
|