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
|
@@ -20,26 +20,29 @@ export function getEditorPanelHTML() {
|
|
|
20
20
|
<button class="fe-editor-back" id="fe-editor-back" data-tooltip="${t('editor.header.close')}" aria-label="${t('editor.header.close')}">
|
|
21
21
|
<svg viewBox="0 0 24 24"><polyline points="15 18 9 12 15 6"/></svg>
|
|
22
22
|
</button>
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
<svg viewBox="0 0 24 24"><path d="M3 6h18M3 12h15a3 3 0 1 1 0 6h-4"/><polyline points="16 16 14 18 16 20"/><path d="M3 18h7"/></svg>
|
|
31
|
-
</button>
|
|
32
|
-
<button class="fe-editor-action" id="fe-editor-view-btn" data-tooltip="${t('editor.header.view')}" aria-label="${t('editor.header.view')}" aria-haspopup="menu" aria-expanded="false">
|
|
33
|
-
<svg viewBox="0 0 24 24"><path d="M4 7h2.5M11.5 7H20M4 17h8.5M17.5 17H20"/><circle cx="9" cy="7" r="2.5"/><circle cx="15" cy="17" r="2.5"/></svg>
|
|
34
|
-
</button>
|
|
35
|
-
<button class="fe-editor-action" id="fe-editor-diff-btn" data-tooltip="${t('editor.header.diff')}" aria-label="${t('editor.header.diff')}" aria-pressed="false" hidden>
|
|
36
|
-
<svg viewBox="0 0 24 24"><path d="M12 3v10M7 8h10M7 19h10"/></svg>
|
|
37
|
-
</button>
|
|
38
|
-
<div class="fe-editor-help-wrap">
|
|
39
|
-
<button class="fe-editor-action fe-editor-help-btn" id="fe-editor-help-btn" data-tooltip="${t('editor.header.shortcuts')}" aria-label="${t('editor.header.shortcuts')}" aria-expanded="false" aria-controls="fe-editor-keybinds">
|
|
40
|
-
<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>
|
|
23
|
+
<div class="fe-editor-title">
|
|
24
|
+
<span class="fe-editor-dot" id="fe-editor-dot"></span>
|
|
25
|
+
<span class="fe-editor-filepath" id="fe-editor-filepath"></span>
|
|
26
|
+
</div>
|
|
27
|
+
<div class="fe-editor-tools">
|
|
28
|
+
<button class="fe-editor-action" id="fe-editor-find-btn" data-tooltip="${t('editor.header.find')}" aria-label="${t('editor.header.find')}">
|
|
29
|
+
<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>
|
|
41
30
|
</button>
|
|
42
|
-
<
|
|
31
|
+
<button class="fe-editor-action" id="fe-editor-word-wrap" data-tooltip="${t('editor.header.wordWrap')}" aria-label="${t('editor.header.wordWrap')}" aria-pressed="true">
|
|
32
|
+
<svg viewBox="0 0 24 24"><path d="M3 6h18M3 12h15a3 3 0 1 1 0 6h-4"/><polyline points="16 16 14 18 16 20"/><path d="M3 18h7"/></svg>
|
|
33
|
+
</button>
|
|
34
|
+
<button class="fe-editor-action" id="fe-editor-view-btn" data-tooltip="${t('editor.header.view')}" aria-label="${t('editor.header.view')}" aria-haspopup="menu" aria-expanded="false">
|
|
35
|
+
<svg viewBox="0 0 24 24"><path d="M4 7h2.5M11.5 7H20M4 17h8.5M17.5 17H20"/><circle cx="9" cy="7" r="2.5"/><circle cx="15" cy="17" r="2.5"/></svg>
|
|
36
|
+
</button>
|
|
37
|
+
<button class="fe-editor-action" id="fe-editor-diff-btn" data-tooltip="${t('editor.header.diff')}" aria-label="${t('editor.header.diff')}" aria-pressed="false" hidden>
|
|
38
|
+
<svg viewBox="0 0 24 24"><path d="M12 3v10M7 8h10M7 19h10"/></svg>
|
|
39
|
+
</button>
|
|
40
|
+
<div class="fe-editor-help-wrap">
|
|
41
|
+
<button class="fe-editor-action fe-editor-help-btn" id="fe-editor-help-btn" data-tooltip="${t('editor.header.shortcuts')}" aria-label="${t('editor.header.shortcuts')}" aria-expanded="false" aria-controls="fe-editor-keybinds">
|
|
42
|
+
<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>
|
|
43
|
+
</button>
|
|
44
|
+
<div class="fe-editor-keybinds" id="fe-editor-keybinds"></div>
|
|
45
|
+
</div>
|
|
43
46
|
</div>
|
|
44
47
|
<div class="fe-editor-sep"></div>
|
|
45
48
|
<div class="fe-editor-view-toggle" id="fe-editor-view-toggle" style="display:none">
|
|
@@ -47,9 +50,11 @@ export function getEditorPanelHTML() {
|
|
|
47
50
|
<button class="fe-editor-toggle-btn" data-mode="preview" aria-pressed="false">${t('editor.header.preview')}</button>
|
|
48
51
|
</div>
|
|
49
52
|
<div class="fe-editor-sep" id="fe-editor-sep-preview" style="display:none"></div>
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
<div class="fe-editor-actions">
|
|
54
|
+
<button class="fe-editor-btn" id="fe-editor-discard" disabled>${t('editor.header.discard')}</button>
|
|
55
|
+
<button class="fe-editor-btn fe-editor-save" id="fe-editor-save" disabled>${t('editor.header.save')}</button>
|
|
56
|
+
<button class="fe-editor-btn" id="fe-editor-close">${t('editor.header.closeButton')}</button>
|
|
57
|
+
</div>
|
|
53
58
|
</div>
|
|
54
59
|
<div class="fe-editor-tabs" id="fe-editor-tabs" role="tablist" aria-label="${t('editor.tabs.label')}" hidden></div>
|
|
55
60
|
<div class="fe-editor-bars" id="fe-editor-bars"></div>
|
|
@@ -597,6 +602,9 @@ ${is3D ? '' : `
|
|
|
597
602
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4.5 20 12 4l7.5 16"/><path d="M8.2 20a3.8 3.8 0 0 1 7.6 0"/></svg>
|
|
598
603
|
<span class="count-badge count-badge--green" id="antigravity-update-badge"></span>
|
|
599
604
|
</button>
|
|
605
|
+
<button id="topright-maritaca-panel-btn" class="topright-icon-btn" data-tooltip="${t('maritacaPanel.toolbar')}">
|
|
606
|
+
<svg viewBox="0 0 12.48 13.73" fill="currentColor"><path d="M10.11 11.01h1.9S7.21 5.97 5.72 4.4a.62.62 0 0 0-.93.04c-.48.59-.76 1.33-.81 2.1-.06 1.04.32 2.06 1.04 2.8l4.35 4.4h3.1l-2.37-2.72Z"/><path d="M5.69 11 4.52 9.82c-.86-.89-1.31-2.1-1.24-3.33s.67-2.38 1.62-3.16c.35.06.71-.02 1.01-.24-.07-.24-.16-.55-.22-.75-.02-.07.06-.13.12-.09l1.16.77c.3-.61.22-1.37-.26-1.9.1-.18.06-.44-.15-.57C6.07.26 5.36 0 4.41 0 2.76 0 0 1.5 0 5.18c0 2.12 1.36 4.57 3.86 5.47l-1.43 3.08h1.05L4.8 10.9c.29.05.58.09.89.1l-1.27 2.73h1.05l.94-2.01L5.7 11ZM4.84.67c.23 0 .42.19.42.42s-.19.42-.42.42-.42-.19-.42-.42.19-.42.42-.42"/></svg>
|
|
607
|
+
</button>
|
|
600
608
|
</div>
|
|
601
609
|
<div id="term-minimized-tray"></div>
|
|
602
610
|
</div>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════
|
|
2
|
+
// SynaBun Neural Interface — the judgment log's origin filter
|
|
3
|
+
// ═══════════════════════════════════════════
|
|
4
|
+
// Which origins the log of Settings → AI decisions can be filtered by (ui-judgments.js draws the list). A server
|
|
5
|
+
// that knows coding-session attribution lists its own (`origins` in GET /api/typesafe/config); an older one sends
|
|
6
|
+
// none, and its log knows `live`, `backfill` and `bench` only. The list follows the latest answer both ways: the
|
|
7
|
+
// tab can open from a kept answer (settings/settings-data.js) and then hear from a server that lists none, and a
|
|
8
|
+
// filter it cannot apply must not stay offered.
|
|
9
|
+
// No DOM: runs under node --test as well.
|
|
10
|
+
|
|
11
|
+
/** What an older server's log can be filtered by: the list the tab offered before servers listed their own. */
|
|
12
|
+
export const LEGACY_LOG_ORIGINS = Object.freeze(['live', 'backfill', 'bench']);
|
|
13
|
+
|
|
14
|
+
/** The origins a config answer lists itself (non-empty strings, in its order); [] for a server that lists none. */
|
|
15
|
+
export function listedLogOrigins(cfg) {
|
|
16
|
+
return Array.isArray(cfg?.origins) ? cfg.origins.filter((o) => typeof o === 'string' && o) : [];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The origin filter for a config answer: `{ listed, values, key }`. `listed` is whether the server named them,
|
|
21
|
+
* `values` the origins to offer (after "All origins"), `key` what the drawn list is compared by (the same values
|
|
22
|
+
* drawn from the server's list and from the older one look different).
|
|
23
|
+
*/
|
|
24
|
+
export function logOriginFilter(cfg) {
|
|
25
|
+
const own = listedLogOrigins(cfg);
|
|
26
|
+
const listed = own.length > 0;
|
|
27
|
+
const values = listed ? own : [...LEGACY_LOG_ORIGINS];
|
|
28
|
+
return { listed, values, key: `${listed ? 'server' : 'legacy'}:${values.join('|')}` };
|
|
29
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// What the "MoreLogin profile" field (morelogin-profile-field.js) decides, without the page: how an answer of
|
|
2
|
+
// GET /api/browser/morelogin-envs reads, which choices the popup offers and what the line under it says.
|
|
3
|
+
// No imports: `node --test` loads it (tests/morelogin-profile-choices.test.mjs).
|
|
4
|
+
//
|
|
5
|
+
// SynaBun drives a MoreLogin profile over the Chrome DevTools protocol, so only a Chrome-type profile can be chosen.
|
|
6
|
+
// The list says each profile's browser (`browser`: 'chromium' | 'firefox' | null = not known): a Firefox-type one is
|
|
7
|
+
// listed, said as such and cannot be picked; one a record already holds stays its selection with a warning, as a
|
|
8
|
+
// profile MoreLogin no longer lists does. A browser that is not known is offered: the run's start still checks.
|
|
9
|
+
|
|
10
|
+
//
|
|
11
|
+
// Local profiles (2026-11-11): the same list holds SynaBun's own profiles (`kind: 'local'`: a Chrome SynaBun runs
|
|
12
|
+
// itself, lib/local-profiles.js). They are in every answer, also while MoreLogin is closed, not installed or
|
|
13
|
+
// refusing, and show as "Name · local". A chosen local profile is judged by the local list alone: MoreLogin being
|
|
14
|
+
// closed is no warning for it, and one that is no longer listed is missing whatever MoreLogin does.
|
|
15
|
+
|
|
16
|
+
// What the field says under the popup, by what the profile is chosen for.
|
|
17
|
+
const HELP_KEY = { schedule: 'schedules.form.moreloginHelp', group: 'schedules.form.moreloginHelpGroup', run: 'schedules.form.moreloginHelpRun' };
|
|
18
|
+
const MISSING_KEY = { schedule: 'schedules.form.moreloginMissing', group: 'schedules.form.moreloginMissingGroup', run: 'schedules.form.moreloginMissingRun' };
|
|
19
|
+
const FIREFOX_KEY = { schedule: 'schedules.form.moreloginFirefox', group: 'schedules.form.moreloginFirefoxGroup', run: 'schedules.form.moreloginFirefoxRun' };
|
|
20
|
+
|
|
21
|
+
const opt = (value, label, selected = false) => ({ value: value ?? '', label: String(label ?? ''), selected: !!selected });
|
|
22
|
+
|
|
23
|
+
/** The browser a listed profile runs, as the server said it: 'chromium', 'firefox' or null (not known). */
|
|
24
|
+
export function moreLoginBrowserOf(env) {
|
|
25
|
+
return env?.browser === 'firefox' || env?.browser === 'chromium' ? env.browser : null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Whether an id is a local profile's (lib/local-profiles.js: `lp-` and 12 hex characters). */
|
|
29
|
+
export function isLocalProfileId(id) {
|
|
30
|
+
return typeof id === 'string' && /^lp-[0-9a-f]{12}$/.test(id);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const envRow = (e) => ({ id: String(e.id), name: String(e.name ?? ''), status: e.status ? String(e.status) : '', browser: moreLoginBrowserOf(e), ...(e.kind === 'local' ? { kind: 'local' } : {}) });
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* What one answer of GET /api/browser/morelogin-envs means to the field.
|
|
37
|
+
* d the answer's body (null when it could not be read)
|
|
38
|
+
* ok whether the HTTP status was a success; `status` is shown when the body names no error
|
|
39
|
+
* `pending`: profiles whose browser the server is still asking MoreLogin for (an older server says none).
|
|
40
|
+
*/
|
|
41
|
+
export function readMoreLoginProfiles(d, ok = true, status = 0) {
|
|
42
|
+
const failed = !d || d.ok === false || !ok;
|
|
43
|
+
return {
|
|
44
|
+
loading: false,
|
|
45
|
+
installed: !!d?.installed,
|
|
46
|
+
running: !!d?.running,
|
|
47
|
+
isDefault: d?.connectMode === 'morelogin',
|
|
48
|
+
listed: !failed && !!d.running,
|
|
49
|
+
// MoreLogin's profiles when its list was read; the local ones whenever the server sent them (a refused or closed
|
|
50
|
+
// MoreLogin does not hide them).
|
|
51
|
+
envs: Array.isArray(d?.envs)
|
|
52
|
+
? d.envs.filter(e => e && (!failed || e.kind === 'local')).map(envRow)
|
|
53
|
+
: [],
|
|
54
|
+
// `local`: the server knows local profiles ({ count }); an older one sends none and `localListed` stays false.
|
|
55
|
+
localListed: !!d && typeof d.local === 'object' && d.local !== null && !d.local.error && Array.isArray(d.envs),
|
|
56
|
+
localCount: Array.isArray(d?.envs) ? d.envs.filter(e => e && e.kind === 'local').length : 0,
|
|
57
|
+
pending: !failed && Number(d.browsersPending) > 0 ? Number(d.browsersPending) : 0,
|
|
58
|
+
error: failed ? String(d?.error || status) : '',
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Whether two readings show the same thing (the count still being looked up aside). */
|
|
63
|
+
export function sameMoreLoginProfiles(a, b) {
|
|
64
|
+
return JSON.stringify({ ...a, pending: 0 }) === JSON.stringify({ ...b, pending: 0 });
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The popup's choices and the line under it.
|
|
69
|
+
* ml the list as readMoreLoginProfiles gives it (or the loading placeholder)
|
|
70
|
+
* chosenId the field's value ('' = the default); chosenName its display name
|
|
71
|
+
* context 'schedule' | 'group' | 'run'
|
|
72
|
+
* inheritLabel the first choice's label when an empty value is not the Browser settings default
|
|
73
|
+
* say (key, params) → text
|
|
74
|
+
* → { entries, helpKey, helpParams, warn, firefox, missing }; entries are cc-dropdown's ({ value, label, selected,
|
|
75
|
+
* disabled }). The chosen profile is always among them and selected, usable or not: it is never dropped quietly.
|
|
76
|
+
*/
|
|
77
|
+
export function moreLoginChoices({ ml, chosenId = '', chosenName = '', context = 'schedule', inheritLabel = '', say }) {
|
|
78
|
+
const envs = Array.isArray(ml?.envs) ? ml.envs : [];
|
|
79
|
+
const listed = envs.find(e => e.id === chosenId) || null;
|
|
80
|
+
const known = !!listed;
|
|
81
|
+
// A local profile is missing when the local list does not hold it; a MoreLogin one when MoreLogin's does not.
|
|
82
|
+
const chosenLocal = isLocalProfileId(chosenId);
|
|
83
|
+
const missing = !!chosenId && !known && (chosenLocal ? !!ml?.localListed : !!ml?.listed);
|
|
84
|
+
const firefox = listed?.browser === 'firefox';
|
|
85
|
+
const label = (e) => `${e.kind === 'local' ? say('schedules.form.moreloginLocalOption', { name: e.name || e.id }) : (e.name || e.id)}${e.status ? ` (${e.status})` : ''}`;
|
|
86
|
+
// What MoreLogin named shows as it is (cc-dropdown escapes the labels).
|
|
87
|
+
const entries = [
|
|
88
|
+
opt('', inheritLabel || say('schedules.form.moreloginDefault'), !chosenId),
|
|
89
|
+
...envs.map(e => (e.browser === 'firefox'
|
|
90
|
+
? { ...opt(e.id, say('schedules.form.moreloginFirefoxOption', { name: e.name || e.id }), e.id === chosenId), disabled: true }
|
|
91
|
+
: opt(e.id, label(e), e.id === chosenId))),
|
|
92
|
+
...(chosenId && !known
|
|
93
|
+
? [opt(chosenId, missing ? say('schedules.form.moreloginMissingOption', { name: chosenName }) : say('schedules.launch.saved', { value: chosenName }), true)]
|
|
94
|
+
: []),
|
|
95
|
+
];
|
|
96
|
+
let helpKey = HELP_KEY[context] || HELP_KEY.schedule;
|
|
97
|
+
let helpParams;
|
|
98
|
+
let warn = false;
|
|
99
|
+
if (missing) { helpKey = MISSING_KEY[context] || MISSING_KEY.schedule; helpParams = { name: chosenName }; warn = true; }
|
|
100
|
+
else if (firefox) { helpKey = FIREFOX_KEY[context] || FIREFOX_KEY.schedule; helpParams = { name: chosenName }; warn = true; }
|
|
101
|
+
else if (ml?.loading && !ml?.listed) helpKey = 'schedules.form.moreloginLoading';
|
|
102
|
+
// MoreLogin's own state is no news for a local profile that is listed, nor where there are only local profiles.
|
|
103
|
+
else if (chosenLocal && known) { /* the context's own help */ }
|
|
104
|
+
else if (ml?.error) { helpKey = 'schedules.form.moreloginError'; helpParams = { error: ml.error }; warn = true; }
|
|
105
|
+
else if (!ml?.running && !(ml?.localCount > 0 && !ml?.installed)) { helpKey = 'schedules.form.moreloginNotRunning'; warn = !!chosenId; }
|
|
106
|
+
return { entries, helpKey, helpParams, warn, firefox, missing };
|
|
107
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// The "MoreLogin profile" field of everything that starts a browser run: a schedule, a schedule group, a quick timer
|
|
2
|
+
// and a manual launch (Schedules window, Automation Studio). One list (GET /api/browser/morelogin-envs, the one
|
|
3
|
+
// Settings → Browser reads), one field, drawn in the look of the form it sits in.
|
|
4
|
+
//
|
|
5
|
+
// 1. Markup: moreLoginFieldHTML({ id, value, savedName, context, variant, ... }) where the form's rows are built.
|
|
6
|
+
// 2. Wiring: wireMoreLoginFields(root, { signal }) once per window (the Refresh button; cc-dropdown.js wires the popup).
|
|
7
|
+
// 3. Reading: readMoreLoginField(id) → { moreloginEnvId, moreloginEnvName } (null while the field is not on screen).
|
|
8
|
+
//
|
|
9
|
+
// The field shows where MoreLogin is in use (it is the default browser, or installed) and for a record that has a
|
|
10
|
+
// profile saved; until then it is an empty hidden element that fills in when the list arrives. A saved profile
|
|
11
|
+
// MoreLogin no longer lists stays selected and is said as such: it is never dropped quietly. The first choice is
|
|
12
|
+
// always "Browser settings default" (or what the record inherits): an empty value, which is what every record without
|
|
13
|
+
// the field means. When the list arrives or is refreshed, each field on screen is redrawn in place with the choice it
|
|
14
|
+
// shows, so the form around it keeps its focus, its scroll and what was typed.
|
|
15
|
+
//
|
|
16
|
+
// SynaBun drives a MoreLogin profile over the Chrome DevTools protocol, so only a Chrome-type profile can be chosen.
|
|
17
|
+
// The list says each profile's browser (`browser`: 'chromium' | 'firefox' | null = not known): a Firefox-type one is
|
|
18
|
+
// listed, said as such and cannot be picked; one a record already holds stays its selection with a warning, as a
|
|
19
|
+
// profile MoreLogin no longer lists does. A browser that is not known is offered (the run's start still checks). The
|
|
20
|
+
// server looks the browsers up profile by profile, so a first answer may leave some out (`browsersPending`): the
|
|
21
|
+
// list is then asked again quietly, a few times, and a field is redrawn only when something it shows changed.
|
|
22
|
+
// What is decided (how an answer reads, the choices, the line under the popup) is morelogin-profile-choices.js.
|
|
23
|
+
|
|
24
|
+
import { dropdownHTML } from './cc-dropdown.js';
|
|
25
|
+
import { t } from './i18n.js';
|
|
26
|
+
import { moreLoginChoices, readMoreLoginProfiles, sameMoreLoginProfiles } from './morelogin-profile-choices.js';
|
|
27
|
+
|
|
28
|
+
const REFRESH_ICON = '<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M13 8a5 5 0 1 1-1.6-3.7"/><path d="M13.2 2.3v3.2H10"/></svg>';
|
|
29
|
+
const MAX_AGE = 30_000;
|
|
30
|
+
const PENDING_RETRY_MS = 2500; // between the quiet asks while the server still looks browsers up
|
|
31
|
+
const PENDING_RETRIES = 8;
|
|
32
|
+
|
|
33
|
+
let _profiles = null; // { loading, installed, running, listed, isDefault, envs: [{ id, name, status, browser }], error }
|
|
34
|
+
let _loadedAt = 0;
|
|
35
|
+
let _request = 0;
|
|
36
|
+
let _pendingTimer = null;
|
|
37
|
+
let _pendingTries = 0;
|
|
38
|
+
const _fields = new Map(); // the popup's input id → what the field was drawn with
|
|
39
|
+
|
|
40
|
+
const esc = (value) => String(value ?? '').replace(/[&<>"']/g, (c) => ({
|
|
41
|
+
'&': '&', '<': '<', '>': '>', '"': '"', "'": ''',
|
|
42
|
+
}[c]));
|
|
43
|
+
const te = (key, params) => esc(t(key, params));
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Ask MoreLogin's profiles again. A list already shown stays while the new one is on its way.
|
|
47
|
+
* `quiet`: the ask that follows an answer with browsers still looked up; it shows no loading state, and the fields
|
|
48
|
+
* are redrawn only when the answer differs from what they show.
|
|
49
|
+
*/
|
|
50
|
+
export async function loadMoreLoginProfiles({ quiet = false } = {}) {
|
|
51
|
+
const request = ++_request;
|
|
52
|
+
clearTimeout(_pendingTimer);
|
|
53
|
+
_pendingTimer = null;
|
|
54
|
+
if (!quiet) {
|
|
55
|
+
_pendingTries = 0;
|
|
56
|
+
_profiles = { installed: false, running: false, listed: false, isDefault: false, envs: [], error: '', ...(_profiles || {}), loading: true };
|
|
57
|
+
redrawMoreLoginFields(); // Refresh off until the answer
|
|
58
|
+
}
|
|
59
|
+
let next;
|
|
60
|
+
try {
|
|
61
|
+
const res = await fetch('/api/browser/morelogin-envs');
|
|
62
|
+
next = readMoreLoginProfiles(await res.json(), res.ok, res.status);
|
|
63
|
+
} catch (err) {
|
|
64
|
+
next = { loading: false, installed: false, running: false, isDefault: false, listed: false, envs: [], localListed: false, localCount: 0, pending: 0, error: err?.message || String(err) };
|
|
65
|
+
}
|
|
66
|
+
if (request !== _request) return;
|
|
67
|
+
const changed = !quiet || !sameMoreLoginProfiles(next, _profiles);
|
|
68
|
+
_profiles = next;
|
|
69
|
+
_loadedAt = Date.now();
|
|
70
|
+
if (changed) redrawMoreLoginFields();
|
|
71
|
+
if (next.pending > 0 && _pendingTries < PENDING_RETRIES && typeof document !== 'undefined') {
|
|
72
|
+
_pendingTries += 1;
|
|
73
|
+
_pendingTimer = setTimeout(() => {
|
|
74
|
+
_pendingTimer = null;
|
|
75
|
+
// Only while a field is on screen to show the answer; the next form that opens asks by itself.
|
|
76
|
+
if ([..._fields.keys()].some(id => document.querySelector(`[data-ml-field="${CSS.escape(id)}"]`))) loadMoreLoginProfiles({ quiet: true });
|
|
77
|
+
}, PENDING_RETRY_MS);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The list for a form that opens: asked when it was never asked, or when the answer is older than `maxAge`. */
|
|
82
|
+
export function ensureMoreLoginProfiles(maxAge = MAX_AGE) {
|
|
83
|
+
if (_profiles?.loading) return;
|
|
84
|
+
if (!_profiles || Date.now() - _loadedAt > maxAge) loadMoreLoginProfiles();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The name a profile id shows under: MoreLogin's when it lists the profile, else the one saved with the record. */
|
|
88
|
+
export function moreLoginProfileName(id, savedName = null) {
|
|
89
|
+
if (!id) return null;
|
|
90
|
+
const listed = _profiles?.envs?.find(e => e.id === String(id));
|
|
91
|
+
return listed?.name || savedName || null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The field's markup, and its registration for the redraws.
|
|
96
|
+
* id the popup's hidden input (the value to read)
|
|
97
|
+
* value the chosen profile id ('' / null = the default); undefined keeps what the field on screen shows
|
|
98
|
+
* savedName the name saved with `value` (shown when MoreLogin does not list the profile)
|
|
99
|
+
* context 'schedule' | 'group' | 'run' (a quick timer, a manual launch): which explanation shows
|
|
100
|
+
* variant 'sched' (the Schedules window's form rows) | 'as' (Automation Studio's labelled blocks)
|
|
101
|
+
* wrapClass 'as' only: the block's own class (as-launch-section, as-qt-group)
|
|
102
|
+
* dropdownClasses extra classes of the popup
|
|
103
|
+
* inheritLabel the first choice's label when an empty value is not the Browser settings default (a group's profile)
|
|
104
|
+
*/
|
|
105
|
+
export function moreLoginFieldHTML(options) {
|
|
106
|
+
const previous = _fields.get(options.id);
|
|
107
|
+
let { value, savedName } = options;
|
|
108
|
+
if (value === undefined) {
|
|
109
|
+
const input = document.getElementById(options.id);
|
|
110
|
+
value = input ? input.value : (previous?.value ?? '');
|
|
111
|
+
const previousSaved = previous && String(previous.savedId || '') === String(value || '');
|
|
112
|
+
if (savedName === undefined) savedName = previousSaved ? previous.savedName : null;
|
|
113
|
+
}
|
|
114
|
+
const field = { ...options, value: value ? String(value) : '', savedId: value ? String(value) : '', savedName: savedName || null };
|
|
115
|
+
_fields.set(options.id, field);
|
|
116
|
+
return fieldHTML(field);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** The field's choice, or null while it is not on screen (the caller then keeps what it holds). */
|
|
120
|
+
export function readMoreLoginField(id) {
|
|
121
|
+
const input = document.getElementById(id);
|
|
122
|
+
if (!input) return null;
|
|
123
|
+
const field = _fields.get(id);
|
|
124
|
+
const envId = input.value || null;
|
|
125
|
+
const savedName = field && envId && field.savedId === envId ? field.savedName : null;
|
|
126
|
+
return { moreloginEnvId: envId, moreloginEnvName: envId ? moreLoginProfileName(envId, savedName) : null };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** The Refresh button of every field under `root`. */
|
|
130
|
+
export function wireMoreLoginFields(root, { signal } = {}) {
|
|
131
|
+
root.addEventListener('click', (event) => {
|
|
132
|
+
const button = event.target.closest?.('[data-ml-refresh]');
|
|
133
|
+
if (!button || !root.contains(button) || button.disabled) return;
|
|
134
|
+
loadMoreLoginProfiles();
|
|
135
|
+
}, { signal });
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function redrawMoreLoginFields() {
|
|
139
|
+
if (typeof document === 'undefined') return;
|
|
140
|
+
for (const [id, field] of _fields) {
|
|
141
|
+
const el = document.querySelector(`[data-ml-field="${CSS.escape(id)}"]`);
|
|
142
|
+
if (!el) continue; // its form is not on screen (the ids are a fixed few: nothing to forget)
|
|
143
|
+
const input = document.getElementById(id);
|
|
144
|
+
if (input) field.value = input.value || '';
|
|
145
|
+
const refocus = el.contains(document.activeElement) && document.activeElement?.hasAttribute('data-ml-refresh');
|
|
146
|
+
el.outerHTML = fieldHTML(field);
|
|
147
|
+
if (refocus) document.getElementById(`${id}-refresh`)?.focus({ preventScroll: true });
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function fieldHTML(field) {
|
|
152
|
+
const { id, variant = 'sched', context = 'schedule' } = field;
|
|
153
|
+
const ml = _profiles || { loading: true, envs: [] };
|
|
154
|
+
const chosenId = field.value || '';
|
|
155
|
+
const fieldAttrs = `id="${esc(id)}-field" data-ml-field="${esc(id)}"`;
|
|
156
|
+
// Shown where MoreLogin is in use, where SynaBun has local profiles of its own, and for a record that holds one.
|
|
157
|
+
if (!chosenId && !ml.installed && !ml.isDefault && !(ml.localCount > 0)) {
|
|
158
|
+
return variant === 'sched' ? `<div class="sched-form-row" ${fieldAttrs} hidden></div>` : `<div ${fieldAttrs} hidden></div>`;
|
|
159
|
+
}
|
|
160
|
+
const chosenName = moreLoginProfileName(chosenId, field.savedId === chosenId ? field.savedName : null) || chosenId;
|
|
161
|
+
const { entries, helpKey, helpParams, warn } = moreLoginChoices({ ml, chosenId, chosenName, context, inheritLabel: field.inheritLabel, say: t });
|
|
162
|
+
const help = te(helpKey, helpParams);
|
|
163
|
+
|
|
164
|
+
const refreshLabel = te('schedules.form.moreloginRefresh');
|
|
165
|
+
const refresh = (cls) => `<button type="button" class="${cls}" id="${esc(id)}-refresh" data-ml-refresh aria-label="${refreshLabel}" data-tooltip="${refreshLabel}"${ml.loading ? ' disabled' : ''}>${REFRESH_ICON}</button>`;
|
|
166
|
+
const popup = dropdownHTML(id, entries, { labelledBy: `${id}-label`, classes: field.dropdownClasses || '' });
|
|
167
|
+
const status = warn ? ' role="status"' : '';
|
|
168
|
+
|
|
169
|
+
if (variant === 'as') {
|
|
170
|
+
return `<div class="${esc(field.wrapClass || 'as-qt-group')} as-ml-field" ${fieldAttrs}>
|
|
171
|
+
<span class="as-launch-label" id="${esc(id)}-label">${te('schedules.form.moreloginProfile')}</span>
|
|
172
|
+
<div class="as-ml-control">${popup}${refresh('as-ml-refresh')}</div>
|
|
173
|
+
<p class="as-ml-help${warn ? ' as-ml-help--warn' : ''}" id="${esc(id)}-help"${status}>${help}</p>
|
|
174
|
+
</div>`;
|
|
175
|
+
}
|
|
176
|
+
return `<div class="sched-form-row sched-form-row--top" ${fieldAttrs}>
|
|
177
|
+
<label class="sched-form-label" id="${esc(id)}-label">${te('schedules.form.moreloginProfile')}</label>
|
|
178
|
+
<div class="sched-form-stack">
|
|
179
|
+
<div class="sched-form-control">
|
|
180
|
+
${popup}
|
|
181
|
+
${refresh('sched-icon-btn')}
|
|
182
|
+
</div>
|
|
183
|
+
<p class="sched-help${warn ? ' sched-help--warn' : ''}" id="${esc(id)}-help"${status}>${help}</p>
|
|
184
|
+
</div>
|
|
185
|
+
</div>`;
|
|
186
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════
|
|
2
|
+
// SynaBun — Maritaca panel: the socket to /ws/maritaca (no DOM)
|
|
3
|
+
// ═══════════════════════════════════════════
|
|
4
|
+
//
|
|
5
|
+
// `request(type, payload)` resolves with the server's `data` or rejects with an Error carrying `code`;
|
|
6
|
+
// every other message is an event for `on(type, fn)`. The socket opens on the first request, says
|
|
7
|
+
// `hello` first, and opens again (1 s, 2 s, 4 s … 30 s) after it drops while anything listens; requests
|
|
8
|
+
// in flight when it drops reject with code 'DISCONNECTED'. After two opens in a row that fail the client
|
|
9
|
+
// asks `probe()` (GET /api/maritaca/panel) and, when the answer says the socket will not open (a server
|
|
10
|
+
// from before the panel: 404; the automation browser or a guest: 403), stops and emits `blocked`.
|
|
11
|
+
// Events of its own: `connected` (the hello answer), `disconnected`, `retrying { attempt, waitMs }`, `blocked`.
|
|
12
|
+
|
|
13
|
+
const BACKOFF_MS = [1000, 2000, 4000, 8000, 15000, 30000];
|
|
14
|
+
const PROBE_AFTER_FAILURES = 2;
|
|
15
|
+
|
|
16
|
+
export function maritacaSocketUrl(location = globalThis.location) {
|
|
17
|
+
if (!location) return 'ws://127.0.0.1:3344/ws/maritaca';
|
|
18
|
+
const scheme = location.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
19
|
+
return `${scheme}//${location.host}/ws/maritaca`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function probeVerdict({ status = 0, body = null, failed = false } = {}) {
|
|
23
|
+
if (failed) return { reason: 'offline', message: '' };
|
|
24
|
+
if (status >= 200 && status < 300) return { reason: null, message: '' };
|
|
25
|
+
const code = String(body?.code || '');
|
|
26
|
+
const message = typeof body?.error === 'string' ? body.error : '';
|
|
27
|
+
if (status === 404) return { reason: 'restart', message };
|
|
28
|
+
if (status === 403 || status === 401) {
|
|
29
|
+
if (code === 'WORKER_BROWSER') return { reason: 'automation', message };
|
|
30
|
+
if (/GUEST|INVITE|ADMIN/i.test(code) || /guest/i.test(message)) return { reason: 'guest', message };
|
|
31
|
+
return { reason: 'refused', message };
|
|
32
|
+
}
|
|
33
|
+
if (status >= 500) return { reason: null, message };
|
|
34
|
+
return { reason: 'refused', message };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function defaultProbe(fetchImpl = globalThis.fetch) {
|
|
38
|
+
if (typeof fetchImpl !== 'function') return probeVerdict({ failed: true });
|
|
39
|
+
try {
|
|
40
|
+
const res = await fetchImpl('/api/maritaca/panel', { headers: { Accept: 'application/json' }, cache: 'no-store' });
|
|
41
|
+
let body = null;
|
|
42
|
+
try { body = await res.json(); } catch { body = null; }
|
|
43
|
+
return probeVerdict({ status: res.status, body });
|
|
44
|
+
} catch { return probeVerdict({ failed: true }); }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function createMaritacaClient({
|
|
48
|
+
url = maritacaSocketUrl(), WebSocketImpl = globalThis.WebSocket, setTimer = setTimeout, clearTimer = clearTimeout,
|
|
49
|
+
requestTimeoutMs = 0, probe = () => defaultProbe(),
|
|
50
|
+
} = {}) {
|
|
51
|
+
let ws = null;
|
|
52
|
+
let opening = null;
|
|
53
|
+
let hello = null;
|
|
54
|
+
let seq = 0;
|
|
55
|
+
let attempt = 0;
|
|
56
|
+
let failures = 0;
|
|
57
|
+
let reconnectTimer = null;
|
|
58
|
+
let blocked = null;
|
|
59
|
+
let closedByUs = false;
|
|
60
|
+
const pending = new Map();
|
|
61
|
+
const listeners = new Map();
|
|
62
|
+
|
|
63
|
+
const emit = (type, payload) => { for (const fn of listeners.get(type) || []) { try { fn(payload); } catch { /* a listener's own problem */ } } };
|
|
64
|
+
const rejectAll = (code, message) => {
|
|
65
|
+
for (const [, entry] of pending) { clearTimer(entry.timer); entry.reject(Object.assign(new Error(message), { code })); }
|
|
66
|
+
pending.clear();
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
function scheduleReconnect() {
|
|
70
|
+
if (closedByUs || blocked || reconnectTimer) return;
|
|
71
|
+
const waitMs = BACKOFF_MS[Math.min(attempt, BACKOFF_MS.length - 1)];
|
|
72
|
+
attempt += 1;
|
|
73
|
+
emit('retrying', { attempt, waitMs });
|
|
74
|
+
reconnectTimer = setTimer(() => { reconnectTimer = null; open().catch(() => {}); }, waitMs);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function checkBlocked() {
|
|
78
|
+
let verdict;
|
|
79
|
+
try { verdict = await probe(); } catch { verdict = { reason: null, message: '' }; }
|
|
80
|
+
if (verdict?.reason && verdict.reason !== 'offline') {
|
|
81
|
+
blocked = { reason: verdict.reason, message: verdict.message || '' };
|
|
82
|
+
emit('blocked', blocked);
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function open() {
|
|
89
|
+
if (ws && ws.readyState === 1 && hello) return Promise.resolve(hello);
|
|
90
|
+
if (opening) return opening;
|
|
91
|
+
if (blocked) return Promise.reject(Object.assign(new Error(blocked.message || blocked.reason), { code: 'BLOCKED', reason: blocked.reason }));
|
|
92
|
+
closedByUs = false;
|
|
93
|
+
opening = new Promise((resolve, reject) => {
|
|
94
|
+
let socket;
|
|
95
|
+
try { socket = new WebSocketImpl(url); } catch (error) { opening = null; reject(error); scheduleReconnect(); return; }
|
|
96
|
+
ws = socket;
|
|
97
|
+
let settled = false;
|
|
98
|
+
const fail = (error) => {
|
|
99
|
+
if (settled) return;
|
|
100
|
+
settled = true;
|
|
101
|
+
opening = null;
|
|
102
|
+
failures += 1;
|
|
103
|
+
reject(error);
|
|
104
|
+
(failures >= PROBE_AFTER_FAILURES ? checkBlocked() : Promise.resolve(false)).then((isBlocked) => { if (!isBlocked) scheduleReconnect(); });
|
|
105
|
+
};
|
|
106
|
+
socket.addEventListener('open', () => {
|
|
107
|
+
sendRaw({ type: 'hello', reqId: 'hello' });
|
|
108
|
+
});
|
|
109
|
+
socket.addEventListener('message', (event) => {
|
|
110
|
+
let msg;
|
|
111
|
+
try { msg = JSON.parse(String(event.data)); } catch { return; }
|
|
112
|
+
if (msg?.type === 'result') {
|
|
113
|
+
if (msg.reqId === 'hello') {
|
|
114
|
+
if (!msg.ok) { fail(Object.assign(new Error(msg.error || 'hello refused'), { code: msg.code || 'HELLO' })); try { socket.close(); } catch {} return; }
|
|
115
|
+
hello = msg.data || {};
|
|
116
|
+
attempt = 0; failures = 0; settled = true; opening = null;
|
|
117
|
+
emit('connected', hello);
|
|
118
|
+
resolve(hello);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const entry = pending.get(msg.reqId);
|
|
122
|
+
if (!entry) return;
|
|
123
|
+
pending.delete(msg.reqId);
|
|
124
|
+
clearTimer(entry.timer);
|
|
125
|
+
if (msg.ok) entry.resolve(msg.data);
|
|
126
|
+
else entry.reject(Object.assign(new Error(msg.error || 'request failed'), { code: msg.code || 'ERROR' }));
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (typeof msg?.type === 'string') emit(msg.type, msg);
|
|
130
|
+
});
|
|
131
|
+
socket.addEventListener('close', () => {
|
|
132
|
+
if (ws === socket) ws = null;
|
|
133
|
+
const wasOpen = !!hello;
|
|
134
|
+
hello = null;
|
|
135
|
+
rejectAll('DISCONNECTED', 'The connection to SynaBun dropped.');
|
|
136
|
+
if (!settled) { fail(Object.assign(new Error('closed before hello'), { code: 'DISCONNECTED' })); return; }
|
|
137
|
+
if (wasOpen) emit('disconnected', {});
|
|
138
|
+
if (!closedByUs) scheduleReconnect();
|
|
139
|
+
});
|
|
140
|
+
socket.addEventListener('error', () => { /* close follows */ });
|
|
141
|
+
});
|
|
142
|
+
return opening;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function sendRaw(message) {
|
|
146
|
+
if (!ws || ws.readyState !== 1) throw Object.assign(new Error('not connected'), { code: 'DISCONNECTED' });
|
|
147
|
+
ws.send(JSON.stringify(message));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
async function request(type, payload = {}) {
|
|
151
|
+
await open();
|
|
152
|
+
const reqId = `q${++seq}`;
|
|
153
|
+
return new Promise((resolve, reject) => {
|
|
154
|
+
const timer = requestTimeoutMs > 0 ? setTimer(() => { pending.delete(reqId); reject(Object.assign(new Error('timeout'), { code: 'TIMEOUT' })); }, requestTimeoutMs) : null;
|
|
155
|
+
pending.set(reqId, { resolve, reject, timer });
|
|
156
|
+
try { sendRaw({ type, reqId, ...payload }); }
|
|
157
|
+
catch (error) { pending.delete(reqId); if (timer) clearTimer(timer); reject(error); }
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function on(type, fn) {
|
|
162
|
+
if (!listeners.has(type)) listeners.set(type, new Set());
|
|
163
|
+
listeners.get(type).add(fn);
|
|
164
|
+
return () => listeners.get(type)?.delete(fn);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function close() {
|
|
168
|
+
closedByUs = true;
|
|
169
|
+
if (reconnectTimer) { clearTimer(reconnectTimer); reconnectTimer = null; }
|
|
170
|
+
try { ws?.close(); } catch {}
|
|
171
|
+
ws = null; hello = null;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function reconnectNow() {
|
|
175
|
+
blocked = null; failures = 0; attempt = 0;
|
|
176
|
+
if (reconnectTimer) { clearTimer(reconnectTimer); reconnectTimer = null; }
|
|
177
|
+
return open();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return { open, request, on, close, reconnectNow, hello: () => hello, connected: () => !!(ws && ws.readyState === 1 && hello), blocked: () => blocked };
|
|
181
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Composer decisions; shared file classification/size labels and socket encoding.
|
|
2
|
+
import { routeAttachment, formatBytes } from '../assistant/asst-composer.js';
|
|
3
|
+
import { base64Of } from '../agy/agy-tabs-logic.js';
|
|
4
|
+
import { parseSlash } from '../agy/agy-commands.js';
|
|
5
|
+
|
|
6
|
+
export { formatBytes };
|
|
7
|
+
export const ATTACH_LIMITS = Object.freeze({ maxAttachments: 5, maxBytes: 100_000 });
|
|
8
|
+
export const COMMANDS = Object.freeze(['new', 'sessions', 'rename', 'retry', 'copy', 'model', 'plan', 'effort', 'context', 'settings', 'help']);
|
|
9
|
+
|
|
10
|
+
export function composerState(tab, { connected = true, blocked = false, supported = true } = {}) {
|
|
11
|
+
const running = !!tab?.running;
|
|
12
|
+
const busy = !!tab?.submitting || !!tab?.pendingAttachments;
|
|
13
|
+
const hasContent = !!String(tab?.draft || '').trim() || !!tab?.attachments?.length;
|
|
14
|
+
return { mode: running ? 'stop' : busy ? 'waiting' : 'send', canSend: !running && !busy && !blocked && connected && hasContent,
|
|
15
|
+
canAttach: supported && !running && !busy && !blocked && connected, busy };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function attachmentProblem(file, staged = [], model = null, limits = ATTACH_LIMITS) {
|
|
19
|
+
if (staged.length >= limits.maxAttachments) return { key: 'attachmentCount', params: { count: limits.maxAttachments } };
|
|
20
|
+
const name = String(file?.name || '');
|
|
21
|
+
const image = String(file?.type || '').startsWith('image/') || /\.(png|jpe?g|gif|webp|svg|avif|heic|bmp|ico|tiff?)$/i.test(name);
|
|
22
|
+
if (image && model?.vision !== true) return { key: 'imageUnsupported' };
|
|
23
|
+
if (file?.size > limits.maxBytes) return { key: 'attachmentSize', params: { size: formatBytes(limits.maxBytes) } };
|
|
24
|
+
const route = await routeAttachment(file);
|
|
25
|
+
if (route !== 'text' && !(image && model?.vision === true && route === 'image')) return { key: 'attachmentType', params: { name } };
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function attachmentRequest(files = []) {
|
|
30
|
+
return files.map(({ name, mimeType, dataUrl }) => ({ name, mimeType, data: base64Of(dataUrl) }));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function commandFor(text) {
|
|
34
|
+
const parsed = parseSlash(text);
|
|
35
|
+
return parsed && COMMANDS.includes(parsed.name) ? parsed : null;
|
|
36
|
+
}
|
|
37
|
+
export function commandHints(text) {
|
|
38
|
+
const match = /^\/(\w*)$/.exec(String(text || ''));
|
|
39
|
+
return match ? COMMANDS.filter((name) => name.startsWith(match[1].toLowerCase())) : [];
|
|
40
|
+
}
|