synabun 2.2.2 → 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 +26 -0
- package/README.md +1 -1
- package/docs/whatsapp.md +52 -20
- package/lib/mcp-build.js +519 -0
- package/lib/mcp-dist.js +10 -4
- package/lib/server-supervisor.js +7 -1
- package/lib/virustotal.mjs +4 -2
- package/mcp-server/dist/http.d.ts +38 -0
- package/mcp-server/dist/http.d.ts.map +1 -1
- package/mcp-server/dist/http.js +75 -7
- package/mcp-server/dist/http.js.map +1 -1
- package/mcp-server/dist/services/browser-route-flow.d.ts +3 -2
- package/mcp-server/dist/services/browser-route-flow.d.ts.map +1 -1
- package/mcp-server/dist/services/browser-route-flow.js +4 -3
- package/mcp-server/dist/services/browser-route-flow.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/neural-interface.d.ts +21 -0
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +76 -4
- 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/browser-advanced.d.ts +3 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.js +30 -8
- package/mcp-server/dist/tools/browser-advanced.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 +81 -20
- package/mcp-server/dist/tools/morelogin.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 +79 -7
- package/mcp-server/src/services/browser-route-flow.ts +4 -3
- package/mcp-server/src/services/embedding-service.ts +2 -1
- package/mcp-server/src/services/neural-interface.ts +77 -4
- package/mcp-server/src/services/tool-catalog.ts +2 -2
- package/mcp-server/src/tools/agents.ts +8 -4
- package/mcp-server/src/tools/browser-advanced.ts +29 -8
- 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 +81 -20
- package/mcp-server/src/tools/youtube/upload.ts +218 -99
- package/neural-interface/i18n/en.json +631 -123
- package/neural-interface/i18n/pt-BR.json +518 -10
- package/neural-interface/lib/assistant-api.js +26 -0
- package/neural-interface/lib/assistant-brains/claude.js +5 -0
- package/neural-interface/lib/assistant-catalog.js +114 -1
- package/neural-interface/lib/assistant-dispatch.js +71 -1
- package/neural-interface/lib/assistant-persona.js +14 -7
- package/neural-interface/lib/assistant-router.js +6 -4
- package/neural-interface/lib/assistant-runtime.js +3 -0
- package/neural-interface/lib/assistant-task-prompt.js +5 -0
- 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-background-tab.js +72 -3
- package/neural-interface/lib/browser-extraction.js +106 -45
- package/neural-interface/lib/browser-profile-choices.js +143 -0
- package/neural-interface/lib/browser-profiles.js +142 -0
- package/neural-interface/lib/browser-tab-recovery.js +153 -0
- package/neural-interface/lib/browser-tool-policy.js +2 -0
- package/neural-interface/lib/chromium-on-device-model.js +67 -0
- package/neural-interface/lib/claude-agent-bridge.js +7 -4
- package/neural-interface/lib/claude-model-catalog.js +12 -0
- package/neural-interface/lib/effort-levels.js +28 -2
- 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 +25 -4
- 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/morelogin-agent-profiles.js +149 -0
- package/neural-interface/lib/morelogin.js +278 -14
- package/neural-interface/lib/native-loop-providers.js +3 -1
- package/neural-interface/lib/owner-authority.js +30 -12
- package/neural-interface/lib/page-session.js +43 -17
- package/neural-interface/lib/request-gate.js +2 -0
- package/neural-interface/lib/system-activity.js +1 -1
- package/neural-interface/lib/terminal-tokens.js +82 -5
- 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/api.js +4 -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-control.js +1 -1
- package/neural-interface/public/shared/assistant/asst-limit-wait.js +4 -4
- package/neural-interface/public/shared/assistant/asst-panel.js +6 -2
- package/neural-interface/public/shared/assistant/asst-rack-styles.js +4 -4
- package/neural-interface/public/shared/assistant/asst-render.js +6 -6
- 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 +58 -14
- 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/context-menu-model.js +2 -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/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-panel.js +6 -2
- 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 +1 -0
- package/neural-interface/public/shared/settings/settings-ia.js +3 -1
- 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/sidepanel-session-status.js +16 -2
- package/neural-interface/public/shared/state.js +1 -1
- package/neural-interface/public/shared/styles.css +356 -157
- 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/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 +130 -90
- package/neural-interface/public/shared/ui-claude-panel.js +50 -2
- package/neural-interface/public/shared/ui-maritaca-panel.js +15 -0
- package/neural-interface/public/shared/ui-navbar.js +17 -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-settings.js +590 -27
- 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/scripts/build-mascot-assets.mjs +30 -0
- package/neural-interface/server.js +1784 -195
- package/npm-shrinkwrap.json +5 -17
- package/package.json +5 -6
- package/postinstall.js +38 -39
- package/setup.js +33 -31
- package/skills/synabun/modules/changelog.md +14 -0
|
@@ -0,0 +1,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
|
+
}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════
|
|
2
|
+
// SynaBun — Maritaca panel: every sentence it says (no DOM)
|
|
3
|
+
// ═══════════════════════════════════════════
|
|
4
|
+
//
|
|
5
|
+
// The English text lives here, once; `maritacaPanel.*` in i18n/en.json must equal it and
|
|
6
|
+
// i18n/pt-BR.json must have the same keys and placeholders (tests/maritaca-panel-logic.test.mjs).
|
|
7
|
+
// A detached window or a test renders before the locale bundle is ready: the English is the fallback.
|
|
8
|
+
|
|
9
|
+
export const MTC_COPY = Object.freeze({
|
|
10
|
+
title: 'Maritaca',
|
|
11
|
+
toolbar: 'Maritaca side panel',
|
|
12
|
+
transcript: 'Maritaca conversation',
|
|
13
|
+
newSession: 'New conversation',
|
|
14
|
+
newTab: 'New tab',
|
|
15
|
+
closeTab: 'Close tab',
|
|
16
|
+
minimize: 'Minimize to pill',
|
|
17
|
+
rename: 'Rename conversation',
|
|
18
|
+
sessions: 'Conversations',
|
|
19
|
+
sessionsEmpty: 'No Maritaca conversations yet.',
|
|
20
|
+
sessionsLoading: 'Loading conversations…',
|
|
21
|
+
sessionsFailed: 'Could not list conversations: {error}',
|
|
22
|
+
sessionsSearch: 'Search conversations',
|
|
23
|
+
delete: 'Delete',
|
|
24
|
+
deleteConfirm: 'Delete "{title}"?',
|
|
25
|
+
cancel: 'Cancel',
|
|
26
|
+
save: 'Save',
|
|
27
|
+
project: 'Project',
|
|
28
|
+
chooseProject: 'Choose a project',
|
|
29
|
+
noProjectLabel: 'No project',
|
|
30
|
+
branch: 'Branch',
|
|
31
|
+
noBranch: 'No branch',
|
|
32
|
+
branchStopFirst: 'Stop the active Sabiá turn before switching branches.',
|
|
33
|
+
branchStatusIncomplete: 'Git status is incomplete. Refresh before switching branches.',
|
|
34
|
+
branchConfirm: 'Switch from {from} to {to} with {count} uncommitted change(s)? Git will preserve them when possible.',
|
|
35
|
+
branchCurrentFallback: 'the current branch',
|
|
36
|
+
branchSwitched: 'Switched working tree to {branch}.',
|
|
37
|
+
branchFailed: 'Branch checkout failed: {error}',
|
|
38
|
+
placeholder: 'Ask Sabiá…',
|
|
39
|
+
placeholderNoKey: 'Add your Maritaca API key to start.',
|
|
40
|
+
send: 'Send',
|
|
41
|
+
stop: 'Stop',
|
|
42
|
+
model: 'Model',
|
|
43
|
+
modelDefault: 'Default model',
|
|
44
|
+
effort: 'Reasoning',
|
|
45
|
+
effortDefault: 'Model default',
|
|
46
|
+
effort_none: 'Off',
|
|
47
|
+
effort_low: 'Low',
|
|
48
|
+
effort_medium: 'Medium',
|
|
49
|
+
effort_high: 'High',
|
|
50
|
+
effortLabel: 'Effort',
|
|
51
|
+
effortMenu: 'Reasoning effort',
|
|
52
|
+
effortDefaultDesc: 'Now {level}',
|
|
53
|
+
effortDesc_none: 'No reasoning: the fastest and cheapest replies',
|
|
54
|
+
effortDesc_low: 'Short reasoning',
|
|
55
|
+
effortDesc_medium: 'Balanced quality and cost',
|
|
56
|
+
effortDesc_high: 'Longest reasoning, for hard problems',
|
|
57
|
+
effortTitle: 'Reasoning effort: {level} ({model})',
|
|
58
|
+
effortTitleDefault: 'Reasoning effort: {level}, the default ({model})',
|
|
59
|
+
effortUnsupported: '{model} has no reasoning levels. Pick an S5 model to choose one.',
|
|
60
|
+
effortUnsupportedShort: 'This model has no reasoning levels.',
|
|
61
|
+
effortUnknown: 'Reasoning levels show once the model list has loaded.',
|
|
62
|
+
plan: 'Plan',
|
|
63
|
+
planOn: 'Plan',
|
|
64
|
+
planOff: 'Chat',
|
|
65
|
+
planToggleOn: 'Plan mode: on. Replies are plans to review before any work (Shift+Tab)',
|
|
66
|
+
planToggleOff: 'Plan mode: off (Shift+Tab)',
|
|
67
|
+
planUnavailable: 'Plan mode needs a SynaBun restart: this server does not know it yet.',
|
|
68
|
+
planPlaceholder: 'Describe what to plan…',
|
|
69
|
+
planBadge: 'Plan',
|
|
70
|
+
planReview: 'Plan review',
|
|
71
|
+
planHeader: 'Plan complete',
|
|
72
|
+
planNote: 'Review the plan. Continue to have Sabiá carry it out, or suggest changes for a new version.',
|
|
73
|
+
planContinue: 'Continue with this plan',
|
|
74
|
+
planFeedbackLabel: 'Suggest changes',
|
|
75
|
+
planFeedbackPlaceholder: 'Add a requirement, change the approach, remove a step…',
|
|
76
|
+
planFeedbackHint: '⌘/Ctrl + Enter to update',
|
|
77
|
+
planUpdate: 'Update plan',
|
|
78
|
+
planCopy: 'Copy plan',
|
|
79
|
+
planDismiss: 'Dismiss',
|
|
80
|
+
planContinuePrompt: 'The plan above is approved. Carry it out now, step by step, and give the complete result.',
|
|
81
|
+
planRevisePrompt: 'Revise the plan with these changes:\n\n{changes}',
|
|
82
|
+
contextSettings: 'Context settings',
|
|
83
|
+
contextSettingsPressure: 'Context settings, {share} of the context window used',
|
|
84
|
+
ctxSectionContext: 'Context window',
|
|
85
|
+
ctxSectionConversation: 'Conversation',
|
|
86
|
+
ctxSectionConnection: 'Connection',
|
|
87
|
+
ctxNotReported: 'Not reported yet',
|
|
88
|
+
ctxUsage: '{used} / {size}',
|
|
89
|
+
ctxHeadline: '{share} of the context window used ({used} of {size} tokens)',
|
|
90
|
+
ctxWindow: 'Window',
|
|
91
|
+
ctxLastInput: 'Last prompt',
|
|
92
|
+
ctxLastOutput: 'Last answer',
|
|
93
|
+
ctxCached: 'Cached input',
|
|
94
|
+
ctxReasoningTokens: 'Reasoning tokens',
|
|
95
|
+
ctxMode: 'Mode',
|
|
96
|
+
ctxEffortNone: 'Not offered',
|
|
97
|
+
ctxMessages: 'Messages',
|
|
98
|
+
ctxReplies: 'Replies',
|
|
99
|
+
ctxCost: 'Cost',
|
|
100
|
+
ctxDraft: 'Draft',
|
|
101
|
+
ctxConversationId: 'Conversation ID',
|
|
102
|
+
ctxNotStarted: 'Not started',
|
|
103
|
+
ctxCopied: 'Copied',
|
|
104
|
+
ctxCopyId: 'Copy conversation ID',
|
|
105
|
+
ctxSystemOn: 'On ({count} characters)',
|
|
106
|
+
ctxSystemOff: 'Off',
|
|
107
|
+
ctxTempDefault: 'Default (0.7)',
|
|
108
|
+
ctxTempIgnored: '{value} (not sent to S5 models)',
|
|
109
|
+
ctxKey: 'API key',
|
|
110
|
+
ctxKeyMissing: 'Not set',
|
|
111
|
+
ctxKeySaved: 'Saved ({masked})',
|
|
112
|
+
ctxKeyEnv: 'Environment ({masked})',
|
|
113
|
+
ctxServer: 'Panel server',
|
|
114
|
+
ctxServerReady: 'Up to date',
|
|
115
|
+
ctxServerRestart: 'Restart SynaBun for plan mode',
|
|
116
|
+
ctxSettings: 'Settings',
|
|
117
|
+
ctxSettingsName: 'Maritaca settings',
|
|
118
|
+
ctxMeter: '{share} · {used}/{size}',
|
|
119
|
+
ctxMeterEmpty: '{size} context',
|
|
120
|
+
ctxMeterLabel: 'Context window usage',
|
|
121
|
+
working: 'Thinking…',
|
|
122
|
+
workingFor: 'Thinking… {seconds}s',
|
|
123
|
+
reasoning: 'Reasoning',
|
|
124
|
+
reasoningFor: 'Reasoned',
|
|
125
|
+
emptyTitle: 'Maritaca AI',
|
|
126
|
+
emptyBody: 'Sabiá models, trained for Portuguese and the Brazilian context, through Maritaca\'s API. Pick a model below and ask away.',
|
|
127
|
+
emptyNoKey: 'SynaBun needs your Maritaca API key. Create one on the Maritaca platform and paste it in the panel settings.',
|
|
128
|
+
emptyKeyButton: 'Add API key',
|
|
129
|
+
emptyKeyLink: 'Get a key at plataforma.maritaca.ai',
|
|
130
|
+
settingsTitle: 'Maritaca settings',
|
|
131
|
+
settingsClose: 'Close settings',
|
|
132
|
+
settingsSectionKey: 'API key',
|
|
133
|
+
settingsSectionDefaults: 'Defaults',
|
|
134
|
+
settingsSectionInstructions: 'Instructions',
|
|
135
|
+
settingsSectionSampling: 'Sampling',
|
|
136
|
+
settingsSectionAbout: 'About',
|
|
137
|
+
settingsKeySave: 'Save key',
|
|
138
|
+
settingsKeyHint: 'Kept in SynaBun\'s data folder and never sent back to the page. MARITACA_API_KEY in the server\'s environment is used when no key is saved.',
|
|
139
|
+
settingsDefaultsHint: 'New tabs start on the default model. Each tab can pick its own model, reasoning level and mode in the footer.',
|
|
140
|
+
settingsSystemCount: '{count} / {max} characters · sent first in every request',
|
|
141
|
+
settingsTemperatureDefault: 'Default',
|
|
142
|
+
settingsSaveDefaults: 'Save settings',
|
|
143
|
+
settingsSaving: 'Saving…',
|
|
144
|
+
settingsUnsaved: 'Unsaved changes',
|
|
145
|
+
settingsNotApplied: 'Saved, but the server kept other values for: {fields}',
|
|
146
|
+
settingsKey: 'API key',
|
|
147
|
+
settingsKeyPlaceholder: 'Paste your Maritaca API key',
|
|
148
|
+
settingsKeySaved: 'Key saved ({masked})',
|
|
149
|
+
settingsKeyEnv: 'Key from the MARITACA_API_KEY environment variable ({masked})',
|
|
150
|
+
settingsKeyNone: 'No key saved',
|
|
151
|
+
settingsKeyForget: 'Forget key',
|
|
152
|
+
settingsKeyTest: 'Test connection',
|
|
153
|
+
settingsKeyTesting: 'Testing…',
|
|
154
|
+
settingsKeyOk: 'Maritaca accepted the key.',
|
|
155
|
+
settingsKeyFailed: 'Test failed: {error}',
|
|
156
|
+
settingsSaved: 'Settings saved.',
|
|
157
|
+
settingsKeyStored: 'Key saved.',
|
|
158
|
+
settingsKeyForgotten: 'Key forgotten.',
|
|
159
|
+
settingsFailed: 'Could not save: {error}',
|
|
160
|
+
settingsModel: 'Default model',
|
|
161
|
+
settingsEffort: 'Default reasoning (S5)',
|
|
162
|
+
settingsSystem: 'System prompt',
|
|
163
|
+
settingsSystemPlaceholder: 'Instructions sent at the start of every conversation (optional)',
|
|
164
|
+
settingsTemperature: 'Temperature',
|
|
165
|
+
settingsTemperatureHint: 'Empty uses Maritaca\'s default (0.7). The S5 family ignores temperature.',
|
|
166
|
+
settingsDocs: 'Maritaca API documentation',
|
|
167
|
+
settingsKeys: 'Manage keys on the Maritaca platform',
|
|
168
|
+
settingsRestart: 'This server does not know the Maritaca panel yet: restart SynaBun to use it.',
|
|
169
|
+
usage_in: '{value} in',
|
|
170
|
+
usage_out: '{value} out',
|
|
171
|
+
usage_cached: '{value} cached',
|
|
172
|
+
costBrl: 'R$ {value}',
|
|
173
|
+
copy: 'Copy',
|
|
174
|
+
copied: 'Copied',
|
|
175
|
+
copyAnswer: 'Copy answer',
|
|
176
|
+
retry: 'Regenerate reply',
|
|
177
|
+
editResend: 'Edit and resend from here',
|
|
178
|
+
editNotice: 'Editing an earlier prompt. Sending replaces the replies after it; attached files stay included.',
|
|
179
|
+
cancelEdit: 'Cancel edit',
|
|
180
|
+
attach: 'Attach text or code files',
|
|
181
|
+
attachmentRemove: 'Remove {name}',
|
|
182
|
+
attachmentCount: 'At most {count} files per message.',
|
|
183
|
+
attachmentSize: 'Each file must be at most {size}.',
|
|
184
|
+
attachmentTooLarge: 'Each file must be at most 100 KB.',
|
|
185
|
+
attachmentType: '{name} must be a text or code file in UTF-8.',
|
|
186
|
+
attachmentTextOnly: 'Attach UTF-8 text or code files. Binary files are not supported.',
|
|
187
|
+
attachmentDamaged: 'An attachment arrived damaged. Remove it and attach it again.',
|
|
188
|
+
attachmentFailed: 'Could not attach {name}: {error}',
|
|
189
|
+
imageUnsupported: 'This model does not read images. Attach a text or code file instead.',
|
|
190
|
+
promptTooLong: 'The message including files is longer than 200,000 characters.',
|
|
191
|
+
uploading: 'Reading files…',
|
|
192
|
+
sending: 'Sending…',
|
|
193
|
+
draftHint: '{chars} characters · ~{tokens} tokens (estimate)',
|
|
194
|
+
dropFiles: 'Drop text or code files here',
|
|
195
|
+
conversationCost: 'Conversation: R$ {value}',
|
|
196
|
+
dismiss: 'Dismiss notice',
|
|
197
|
+
copyFailed: 'Could not copy. Select the text and copy it manually.',
|
|
198
|
+
renameFailed: 'Could not rename: {error}',
|
|
199
|
+
deleteFailed: 'Could not delete: {error}',
|
|
200
|
+
sessionsProject: 'This project only',
|
|
201
|
+
shortcuts: 'Enter sends · Shift+Enter newline · Shift+Tab plan mode · Esc stops · Ctrl/⌘+Alt+N new tab · Ctrl/⌘+Alt+←/→ switch tabs',
|
|
202
|
+
commandMenu: 'Panel commands',
|
|
203
|
+
cmd_new: 'Start a new conversation',
|
|
204
|
+
cmd_sessions: 'Search conversations',
|
|
205
|
+
cmd_rename: 'Rename this conversation',
|
|
206
|
+
cmd_retry: 'Regenerate the latest reply',
|
|
207
|
+
cmd_copy: 'Copy the latest reply',
|
|
208
|
+
cmd_model: 'Pick a model',
|
|
209
|
+
cmd_plan: 'Turn plan mode on or off (/plan on, /plan off)',
|
|
210
|
+
cmd_effort: 'Pick the reasoning effort (/effort low, medium, high, off, default)',
|
|
211
|
+
cmd_context: 'Show the context window and the conversation details',
|
|
212
|
+
cmd_settings: 'Open panel settings',
|
|
213
|
+
cmd_help: 'Show commands and keyboard shortcuts',
|
|
214
|
+
finishLength: 'The reply stopped at the model\'s output limit.',
|
|
215
|
+
finishCancelled: 'Stopped.',
|
|
216
|
+
turnFailed: 'Maritaca could not answer: {error}',
|
|
217
|
+
errorNoKey: 'Save a Maritaca API key first.',
|
|
218
|
+
errorKeyRejected: 'Maritaca rejected the saved key. Check it in the panel settings.',
|
|
219
|
+
errorRateLimited: 'Maritaca is rate limiting this key. Wait a moment and try again.',
|
|
220
|
+
errorUnreachable: 'Could not reach Maritaca. Check the connection and try again.',
|
|
221
|
+
errorDisconnected: 'The connection to SynaBun dropped. Reconnecting…',
|
|
222
|
+
connBlocked_restart: 'This server does not know the Maritaca panel yet: restart SynaBun to use it.',
|
|
223
|
+
connBlocked_automation: 'The Maritaca panel is not available in SynaBun\'s automation browser.',
|
|
224
|
+
connBlocked_guest: 'The Maritaca panel is the owner\'s: an invite guest cannot use it.',
|
|
225
|
+
connBlocked_refused: 'SynaBun refused the Maritaca panel socket: {message}',
|
|
226
|
+
connRetrying: 'Reconnecting to SynaBun… ({attempt})',
|
|
227
|
+
freeTag: 'free',
|
|
228
|
+
brTag: 'BR',
|
|
229
|
+
priceTag: 'R$ {input} / {output} per 1M',
|
|
230
|
+
contextTag: '{context} context',
|
|
231
|
+
jumpLatest: 'Latest',
|
|
232
|
+
tabTitleFallback: 'Conversation',
|
|
233
|
+
providerNote: 'Maritaca is a chat API: it answers here and is not a worker the Assistant can dispatch to.',
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
let _translate = null;
|
|
237
|
+
export function setMaritacaTranslator(fn) { _translate = typeof fn === 'function' ? fn : null; }
|
|
238
|
+
|
|
239
|
+
function fill(template, params = {}) {
|
|
240
|
+
return String(template).replace(/\{(\w+)\}/g, (m, k) => (params[k] === undefined || params[k] === null ? m : String(params[k])));
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** The sentence `key` names, translated when the page has a translator, else the English above. */
|
|
244
|
+
export function mtcText(key, params = {}) {
|
|
245
|
+
const fallback = MTC_COPY[key];
|
|
246
|
+
if (_translate) {
|
|
247
|
+
try {
|
|
248
|
+
const value = _translate(`maritacaPanel.${key}`, params);
|
|
249
|
+
if (typeof value === 'string' && value && value !== `maritacaPanel.${key}`) return value;
|
|
250
|
+
} catch { /* fallback below */ }
|
|
251
|
+
}
|
|
252
|
+
return fallback === undefined ? key : fill(fallback, params);
|
|
253
|
+
}
|