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.
Files changed (276) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +1 -1
  3. package/docs/whatsapp.md +52 -20
  4. package/lib/mcp-build.js +519 -0
  5. package/lib/mcp-dist.js +10 -4
  6. package/lib/server-supervisor.js +7 -1
  7. package/lib/virustotal.mjs +4 -2
  8. package/mcp-server/dist/http.d.ts +38 -0
  9. package/mcp-server/dist/http.d.ts.map +1 -1
  10. package/mcp-server/dist/http.js +75 -7
  11. package/mcp-server/dist/http.js.map +1 -1
  12. package/mcp-server/dist/services/browser-route-flow.d.ts +3 -2
  13. package/mcp-server/dist/services/browser-route-flow.d.ts.map +1 -1
  14. package/mcp-server/dist/services/browser-route-flow.js +4 -3
  15. package/mcp-server/dist/services/browser-route-flow.js.map +1 -1
  16. package/mcp-server/dist/services/embedding-service.d.ts.map +1 -1
  17. package/mcp-server/dist/services/embedding-service.js +2 -1
  18. package/mcp-server/dist/services/embedding-service.js.map +1 -1
  19. package/mcp-server/dist/services/neural-interface.d.ts +21 -0
  20. package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
  21. package/mcp-server/dist/services/neural-interface.js +76 -4
  22. package/mcp-server/dist/services/neural-interface.js.map +1 -1
  23. package/mcp-server/dist/services/tool-catalog.js +2 -2
  24. package/mcp-server/dist/services/tool-catalog.js.map +1 -1
  25. package/mcp-server/dist/tools/agents.d.ts +3 -2
  26. package/mcp-server/dist/tools/agents.d.ts.map +1 -1
  27. package/mcp-server/dist/tools/agents.js +6 -4
  28. package/mcp-server/dist/tools/agents.js.map +1 -1
  29. package/mcp-server/dist/tools/browser-advanced.d.ts +3 -1
  30. package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
  31. package/mcp-server/dist/tools/browser-advanced.js +30 -8
  32. package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
  33. package/mcp-server/dist/tools/browser-navigate.d.ts +3 -3
  34. package/mcp-server/dist/tools/browser-navigate.d.ts.map +1 -1
  35. package/mcp-server/dist/tools/browser-navigate.js +19 -16
  36. package/mcp-server/dist/tools/browser-navigate.js.map +1 -1
  37. package/mcp-server/dist/tools/browser-observe.d.ts +2 -1
  38. package/mcp-server/dist/tools/browser-observe.d.ts.map +1 -1
  39. package/mcp-server/dist/tools/browser-observe.js +61 -20
  40. package/mcp-server/dist/tools/browser-observe.js.map +1 -1
  41. package/mcp-server/dist/tools/morelogin.d.ts +13 -3
  42. package/mcp-server/dist/tools/morelogin.d.ts.map +1 -1
  43. package/mcp-server/dist/tools/morelogin.js +81 -20
  44. package/mcp-server/dist/tools/morelogin.js.map +1 -1
  45. package/mcp-server/dist/tools/youtube/upload.d.ts.map +1 -1
  46. package/mcp-server/dist/tools/youtube/upload.js +225 -88
  47. package/mcp-server/dist/tools/youtube/upload.js.map +1 -1
  48. package/mcp-server/package-lock.json +2 -2
  49. package/mcp-server/package.json +1 -1
  50. package/mcp-server/src/http.ts +79 -7
  51. package/mcp-server/src/services/browser-route-flow.ts +4 -3
  52. package/mcp-server/src/services/embedding-service.ts +2 -1
  53. package/mcp-server/src/services/neural-interface.ts +77 -4
  54. package/mcp-server/src/services/tool-catalog.ts +2 -2
  55. package/mcp-server/src/tools/agents.ts +8 -4
  56. package/mcp-server/src/tools/browser-advanced.ts +29 -8
  57. package/mcp-server/src/tools/browser-navigate.ts +19 -16
  58. package/mcp-server/src/tools/browser-observe.ts +62 -20
  59. package/mcp-server/src/tools/morelogin.ts +81 -20
  60. package/mcp-server/src/tools/youtube/upload.ts +218 -99
  61. package/neural-interface/i18n/en.json +631 -123
  62. package/neural-interface/i18n/pt-BR.json +518 -10
  63. package/neural-interface/lib/assistant-api.js +26 -0
  64. package/neural-interface/lib/assistant-brains/claude.js +5 -0
  65. package/neural-interface/lib/assistant-catalog.js +114 -1
  66. package/neural-interface/lib/assistant-dispatch.js +71 -1
  67. package/neural-interface/lib/assistant-persona.js +14 -7
  68. package/neural-interface/lib/assistant-router.js +6 -4
  69. package/neural-interface/lib/assistant-runtime.js +3 -0
  70. package/neural-interface/lib/assistant-task-prompt.js +5 -0
  71. package/neural-interface/lib/automation-approval.js +249 -0
  72. package/neural-interface/lib/automation-browser-owner-access.js +82 -0
  73. package/neural-interface/lib/backup-service.js +16 -1
  74. package/neural-interface/lib/browser-background-tab.js +72 -3
  75. package/neural-interface/lib/browser-extraction.js +106 -45
  76. package/neural-interface/lib/browser-profile-choices.js +143 -0
  77. package/neural-interface/lib/browser-profiles.js +142 -0
  78. package/neural-interface/lib/browser-tab-recovery.js +153 -0
  79. package/neural-interface/lib/browser-tool-policy.js +2 -0
  80. package/neural-interface/lib/chromium-on-device-model.js +67 -0
  81. package/neural-interface/lib/claude-agent-bridge.js +7 -4
  82. package/neural-interface/lib/claude-model-catalog.js +12 -0
  83. package/neural-interface/lib/effort-levels.js +28 -2
  84. package/neural-interface/lib/local-profile-proxy.js +362 -0
  85. package/neural-interface/lib/local-profiles.js +929 -0
  86. package/neural-interface/lib/loop-logger.js +25 -4
  87. package/neural-interface/lib/maritaca/api.js +179 -0
  88. package/neural-interface/lib/maritaca/attachments.js +44 -0
  89. package/neural-interface/lib/maritaca/client.js +362 -0
  90. package/neural-interface/lib/maritaca/key-store.js +122 -0
  91. package/neural-interface/lib/maritaca/models.js +181 -0
  92. package/neural-interface/lib/maritaca/modes.js +39 -0
  93. package/neural-interface/lib/maritaca/opencode-proxy.js +236 -0
  94. package/neural-interface/lib/maritaca/opencode-stream.js +345 -0
  95. package/neural-interface/lib/maritaca/opencode.js +218 -0
  96. package/neural-interface/lib/maritaca/panel-bridge.js +273 -0
  97. package/neural-interface/lib/maritaca/sessions.js +198 -0
  98. package/neural-interface/lib/morelogin-agent-profiles.js +149 -0
  99. package/neural-interface/lib/morelogin.js +278 -14
  100. package/neural-interface/lib/native-loop-providers.js +3 -1
  101. package/neural-interface/lib/owner-authority.js +30 -12
  102. package/neural-interface/lib/page-session.js +43 -17
  103. package/neural-interface/lib/request-gate.js +2 -0
  104. package/neural-interface/lib/system-activity.js +1 -1
  105. package/neural-interface/lib/terminal-tokens.js +82 -5
  106. package/neural-interface/package-lock.json +3 -2
  107. package/neural-interface/package.json +2 -1
  108. package/neural-interface/public/assets/mascot/README.md +11 -0
  109. package/neural-interface/public/assets/mascot/ask.gif +0 -0
  110. package/neural-interface/public/assets/mascot/ask.png +0 -0
  111. package/neural-interface/public/assets/mascot/blocked.gif +0 -0
  112. package/neural-interface/public/assets/mascot/blocked.png +0 -0
  113. package/neural-interface/public/assets/mascot/budget.gif +0 -0
  114. package/neural-interface/public/assets/mascot/budget.png +0 -0
  115. package/neural-interface/public/assets/mascot/computer.gif +0 -0
  116. package/neural-interface/public/assets/mascot/computer.png +0 -0
  117. package/neural-interface/public/assets/mascot/edit.gif +0 -0
  118. package/neural-interface/public/assets/mascot/edit.png +0 -0
  119. package/neural-interface/public/assets/mascot/error.gif +0 -0
  120. package/neural-interface/public/assets/mascot/error.png +0 -0
  121. package/neural-interface/public/assets/mascot/hover-attention.gif +0 -0
  122. package/neural-interface/public/assets/mascot/hover-attention.png +0 -0
  123. package/neural-interface/public/assets/mascot/idle-hero.gif +0 -0
  124. package/neural-interface/public/assets/mascot/idle-hero.png +0 -0
  125. package/neural-interface/public/assets/mascot/idle.gif +0 -0
  126. package/neural-interface/public/assets/mascot/idle.png +0 -0
  127. package/neural-interface/public/assets/mascot/manifest.json +254 -0
  128. package/neural-interface/public/assets/mascot/mcp.gif +0 -0
  129. package/neural-interface/public/assets/mascot/mcp.png +0 -0
  130. package/neural-interface/public/assets/mascot/memory.gif +0 -0
  131. package/neural-interface/public/assets/mascot/memory.png +0 -0
  132. package/neural-interface/public/assets/mascot/offline.gif +0 -0
  133. package/neural-interface/public/assets/mascot/offline.png +0 -0
  134. package/neural-interface/public/assets/mascot/pick.gif +0 -0
  135. package/neural-interface/public/assets/mascot/pick.png +0 -0
  136. package/neural-interface/public/assets/mascot/plan.gif +0 -0
  137. package/neural-interface/public/assets/mascot/plan.png +0 -0
  138. package/neural-interface/public/assets/mascot/present.gif +0 -0
  139. package/neural-interface/public/assets/mascot/present.png +0 -0
  140. package/neural-interface/public/assets/mascot/project.gif +0 -0
  141. package/neural-interface/public/assets/mascot/project.png +0 -0
  142. package/neural-interface/public/assets/mascot/read.gif +0 -0
  143. package/neural-interface/public/assets/mascot/read.png +0 -0
  144. package/neural-interface/public/assets/mascot/runs.gif +0 -0
  145. package/neural-interface/public/assets/mascot/runs.png +0 -0
  146. package/neural-interface/public/assets/mascot/scenes/automation.gif +0 -0
  147. package/neural-interface/public/assets/mascot/scenes/automation.png +0 -0
  148. package/neural-interface/public/assets/mascot/scenes/browser.gif +0 -0
  149. package/neural-interface/public/assets/mascot/scenes/browser.png +0 -0
  150. package/neural-interface/public/assets/mascot/scenes/code.gif +0 -0
  151. package/neural-interface/public/assets/mascot/scenes/code.png +0 -0
  152. package/neural-interface/public/assets/mascot/scenes/complex.gif +0 -0
  153. package/neural-interface/public/assets/mascot/scenes/complex.png +0 -0
  154. package/neural-interface/public/assets/mascot/scenes/computer.gif +0 -0
  155. package/neural-interface/public/assets/mascot/scenes/computer.png +0 -0
  156. package/neural-interface/public/assets/mascot/scenes/design.gif +0 -0
  157. package/neural-interface/public/assets/mascot/scenes/design.png +0 -0
  158. package/neural-interface/public/assets/mascot/scenes/edit.gif +0 -0
  159. package/neural-interface/public/assets/mascot/scenes/edit.png +0 -0
  160. package/neural-interface/public/assets/mascot/scenes/generic.gif +0 -0
  161. package/neural-interface/public/assets/mascot/scenes/generic.png +0 -0
  162. package/neural-interface/public/assets/mascot/scenes/image_gen.gif +0 -0
  163. package/neural-interface/public/assets/mascot/scenes/image_gen.png +0 -0
  164. package/neural-interface/public/assets/mascot/scenes/manifest.json +173 -0
  165. package/neural-interface/public/assets/mascot/scenes/memory.gif +0 -0
  166. package/neural-interface/public/assets/mascot/scenes/memory.png +0 -0
  167. package/neural-interface/public/assets/mascot/scenes/quick.gif +0 -0
  168. package/neural-interface/public/assets/mascot/scenes/quick.png +0 -0
  169. package/neural-interface/public/assets/mascot/scenes/read.gif +0 -0
  170. package/neural-interface/public/assets/mascot/scenes/read.png +0 -0
  171. package/neural-interface/public/assets/mascot/scenes/research.gif +0 -0
  172. package/neural-interface/public/assets/mascot/scenes/research.png +0 -0
  173. package/neural-interface/public/assets/mascot/scenes/review.gif +0 -0
  174. package/neural-interface/public/assets/mascot/scenes/review.png +0 -0
  175. package/neural-interface/public/assets/mascot/scenes/search.gif +0 -0
  176. package/neural-interface/public/assets/mascot/scenes/search.png +0 -0
  177. package/neural-interface/public/assets/mascot/scenes/shell.gif +0 -0
  178. package/neural-interface/public/assets/mascot/scenes/shell.png +0 -0
  179. package/neural-interface/public/assets/mascot/scenes/thinking.gif +0 -0
  180. package/neural-interface/public/assets/mascot/scenes/thinking.png +0 -0
  181. package/neural-interface/public/assets/mascot/scenes/video_gen.gif +0 -0
  182. package/neural-interface/public/assets/mascot/scenes/video_gen.png +0 -0
  183. package/neural-interface/public/assets/mascot/scenes/web.gif +0 -0
  184. package/neural-interface/public/assets/mascot/scenes/web.png +0 -0
  185. package/neural-interface/public/assets/mascot/search.gif +0 -0
  186. package/neural-interface/public/assets/mascot/search.png +0 -0
  187. package/neural-interface/public/assets/mascot/shell.gif +0 -0
  188. package/neural-interface/public/assets/mascot/shell.png +0 -0
  189. package/neural-interface/public/assets/mascot/skill.gif +0 -0
  190. package/neural-interface/public/assets/mascot/skill.png +0 -0
  191. package/neural-interface/public/assets/mascot/sleep.gif +0 -0
  192. package/neural-interface/public/assets/mascot/sleep.png +0 -0
  193. package/neural-interface/public/assets/mascot/subagent.gif +0 -0
  194. package/neural-interface/public/assets/mascot/subagent.png +0 -0
  195. package/neural-interface/public/assets/mascot/success.gif +0 -0
  196. package/neural-interface/public/assets/mascot/success.png +0 -0
  197. package/neural-interface/public/assets/mascot/think.gif +0 -0
  198. package/neural-interface/public/assets/mascot/think.png +0 -0
  199. package/neural-interface/public/assets/mascot/wait.gif +0 -0
  200. package/neural-interface/public/assets/mascot/wait.png +0 -0
  201. package/neural-interface/public/assets/mascot/watch.gif +0 -0
  202. package/neural-interface/public/assets/mascot/watch.png +0 -0
  203. package/neural-interface/public/assets/mascot/web.gif +0 -0
  204. package/neural-interface/public/assets/mascot/web.png +0 -0
  205. package/neural-interface/public/onboarding.html +14 -1
  206. package/neural-interface/public/shared/agent-runtime-options.js +49 -8
  207. package/neural-interface/public/shared/agy/agy-panel.js +2 -2
  208. package/neural-interface/public/shared/api.js +4 -4
  209. package/neural-interface/public/shared/assistant/asst-ask-styles.js +8 -8
  210. package/neural-interface/public/shared/assistant/asst-ask.js +1 -1
  211. package/neural-interface/public/shared/assistant/asst-brain-picker.js +99 -9
  212. package/neural-interface/public/shared/assistant/asst-control.js +1 -1
  213. package/neural-interface/public/shared/assistant/asst-limit-wait.js +4 -4
  214. package/neural-interface/public/shared/assistant/asst-panel.js +6 -2
  215. package/neural-interface/public/shared/assistant/asst-rack-styles.js +4 -4
  216. package/neural-interface/public/shared/assistant/asst-render.js +6 -6
  217. package/neural-interface/public/shared/assistant/asst-route-models.js +64 -4
  218. package/neural-interface/public/shared/assistant/asst-route.js +24 -7
  219. package/neural-interface/public/shared/assistant/asst-routes-editor.js +154 -39
  220. package/neural-interface/public/shared/assistant/asst-run-stage.js +3 -3
  221. package/neural-interface/public/shared/assistant/asst-scene-styles.js +8 -111
  222. package/neural-interface/public/shared/assistant/asst-scenes.js +46 -318
  223. package/neural-interface/public/shared/assistant/asst-sidepanel.js +2 -2
  224. package/neural-interface/public/shared/assistant/asst-state.js +72 -2
  225. package/neural-interface/public/shared/assistant/asst-styles.js +58 -14
  226. package/neural-interface/public/shared/automation-approval-view.js +75 -0
  227. package/neural-interface/public/shared/cdx/cdx-panel.js +2 -2
  228. package/neural-interface/public/shared/context-menu-model.js +2 -0
  229. package/neural-interface/public/shared/editor/editor-panel-logic.js +10 -0
  230. package/neural-interface/public/shared/editor/editor-panel.js +10 -2
  231. package/neural-interface/public/shared/html-shell.js +30 -22
  232. package/neural-interface/public/shared/morelogin-profile-choices.js +107 -0
  233. package/neural-interface/public/shared/morelogin-profile-field.js +186 -0
  234. package/neural-interface/public/shared/mtc/mtc-client.js +181 -0
  235. package/neural-interface/public/shared/mtc/mtc-compose.js +40 -0
  236. package/neural-interface/public/shared/mtc/mtc-copy.js +253 -0
  237. package/neural-interface/public/shared/mtc/mtc-logic.js +478 -0
  238. package/neural-interface/public/shared/mtc/mtc-panel.js +1354 -0
  239. package/neural-interface/public/shared/mtc/mtc-render.js +172 -0
  240. package/neural-interface/public/shared/mtc/mtc-styles.js +437 -0
  241. package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +6 -2
  242. package/neural-interface/public/shared/provider-icons.js +3 -0
  243. package/neural-interface/public/shared/schedules-view.js +7 -0
  244. package/neural-interface/public/shared/server-back.js +50 -0
  245. package/neural-interface/public/shared/settings/settings-browser-owner-access.js +72 -0
  246. package/neural-interface/public/shared/settings/settings-data.js +1 -0
  247. package/neural-interface/public/shared/settings/settings-ia.js +3 -1
  248. package/neural-interface/public/shared/settings/settings-local-profiles.js +153 -0
  249. package/neural-interface/public/shared/settings/settings-maritaca-opencode.js +105 -0
  250. package/neural-interface/public/shared/sidepanel-session-status.js +16 -2
  251. package/neural-interface/public/shared/state.js +1 -1
  252. package/neural-interface/public/shared/styles.css +356 -157
  253. package/neural-interface/public/shared/synabun-mascot-assets.js +67 -0
  254. package/neural-interface/public/shared/synabun-mascot.js +136 -12
  255. package/neural-interface/public/shared/synabun-ticker.js +3 -0
  256. package/neural-interface/public/shared/topright-overflow-logic.js +1 -0
  257. package/neural-interface/public/shared/ui-automation-approval.js +188 -0
  258. package/neural-interface/public/shared/ui-automation-studio.js +130 -90
  259. package/neural-interface/public/shared/ui-claude-panel.js +50 -2
  260. package/neural-interface/public/shared/ui-maritaca-panel.js +15 -0
  261. package/neural-interface/public/shared/ui-navbar.js +17 -0
  262. package/neural-interface/public/shared/ui-panels.js +3 -1
  263. package/neural-interface/public/shared/ui-schedules-studio.js +118 -17
  264. package/neural-interface/public/shared/ui-scroll-follow.js +3 -0
  265. package/neural-interface/public/shared/ui-settings.js +590 -27
  266. package/neural-interface/public/shared/ui-sidepanel-session-entry.js +8 -2
  267. package/neural-interface/public/shared/ui-sidepanel-sessions.js +3 -3
  268. package/neural-interface/public/shared/ui-sidepanel-tray.js +24 -0
  269. package/neural-interface/public/shared/ui-sidepanel-windows.js +1 -1
  270. package/neural-interface/scripts/build-mascot-assets.mjs +30 -0
  271. package/neural-interface/server.js +1784 -195
  272. package/npm-shrinkwrap.json +5 -17
  273. package/package.json +5 -6
  274. package/postinstall.js +38 -39
  275. package/setup.js +33 -31
  276. package/skills/synabun/modules/changelog.md +14 -0
@@ -0,0 +1,72 @@
1
+ // ═══════════════════════════════════════════
2
+ // SETTINGS — Let the automation browser act as owner, in words
3
+ // ═══════════════════════════════════════════
4
+ //
5
+ // What `GET /api/assistant/automation-browser-owner-access` (lib/assistant-api.js; the setting in
6
+ // lib/automation-browser-owner-access.js, enforced by lib/page-session.js and lib/owner-authority.js) says about
7
+ // Settings → Browser → Automation browser access: whether the switch is on, whether it can be changed, and what
8
+ // stands in the way. Pure: no DOM and no import, so node runs it (tests/settings-browser-owner-access-view.test.mjs).
9
+ //
10
+ // readOwnerAccessResponse({ status, body, error }) what the server answered → a reading
11
+ // describeOwnerAccess(reading, { tx }) the row as ui-settings.js draws it
12
+ // describeOwnerAccessSaveFailure(input, { tx }) the sentence for a change that could not be saved
13
+ //
14
+ // `tx(key, params)` is the caller's translate function over the settings.redesign.* strings (the kit's `tx`).
15
+ // The row never shows a healthy-looking switch for something that is not happening: a server started before the
16
+ // setting existed shows it off, disabled, and says a restart is missing.
17
+
18
+ const K = 'settings.redesign.browser.ownerAccess';
19
+
20
+ export const OWNER_ACCESS_DEFAULT = false;
21
+
22
+ const clean = (value, max = 200) => {
23
+ const text = String(value ?? '').replace(/\s+/g, ' ').trim();
24
+ return text.length > max ? `${text.slice(0, max - 1)}…` : text;
25
+ };
26
+
27
+ /**
28
+ * What the server answered.
29
+ *
30
+ * ready the setting is there: `enabled` is in effect
31
+ * old-server 404: the running server was started before the setting existed
32
+ * failed 503 OWNER_ACCESS_UNAVAILABLE: the setting did not start; `reason` is the error
33
+ * unreadable anything else (no answer, a refusal, a body that is not the payload)
34
+ */
35
+ export function readOwnerAccessResponse({ status = 0, body = null, error = null } = {}) {
36
+ const code = Number(status) || 0;
37
+ if (code === 404) return { state: 'old-server', enabled: OWNER_ACCESS_DEFAULT, reason: null };
38
+ if (code === 503) return { state: 'failed', enabled: OWNER_ACCESS_DEFAULT, reason: clean(body?.reason || body?.error) || null };
39
+ if (code >= 200 && code < 300 && body && typeof body === 'object' && body.ok !== false && typeof body.enabled === 'boolean') {
40
+ return { state: 'ready', enabled: body.enabled, reason: null };
41
+ }
42
+ return { state: 'unreadable', enabled: OWNER_ACCESS_DEFAULT, reason: clean(error || body?.error || (code ? `HTTP ${code}` : '')) || null };
43
+ }
44
+
45
+ /** The row: { ready, disabled, on, note: { text, tone } | null, warning: string | null, applies }. */
46
+ export function describeOwnerAccess(reading, { tx }) {
47
+ const r = reading || readOwnerAccessResponse({ status: 0 });
48
+ let note = null;
49
+ if (r.state === 'old-server') note = { text: tx(`${K}.restart`), tone: 'warn' };
50
+ else if (r.state === 'failed') note = { text: r.reason ? tx(`${K}.failed`, { reason: r.reason }) : tx(`${K}.failedNoReason`), tone: 'warn' };
51
+ else if (r.state === 'unreadable') note = { text: r.reason ? tx(`${K}.unreadable`, { reason: r.reason }) : tx(`${K}.unreadableNoReason`), tone: 'warn' };
52
+ const on = r.state === 'ready' && r.enabled === true;
53
+ return {
54
+ ready: r.state === 'ready',
55
+ disabled: r.state !== 'ready',
56
+ on,
57
+ note,
58
+ // While on, the row says what that means right under the switch, in the warning tone.
59
+ warning: on ? tx(`${K}.onWarning`) : null,
60
+ applies: tx(`${K}.applies`),
61
+ };
62
+ }
63
+
64
+ /** The sentence under the row when a change could not be saved: { status, body, error, enabled }. */
65
+ export function describeOwnerAccessSaveFailure({ status = 0, body = null, error = null, enabled = false } = {}, { tx }) {
66
+ const code = Number(status) || 0;
67
+ const state = tx(`${K}.${enabled ? 'stateOn' : 'stateOff'}`);
68
+ if (code === 404) return tx(`${K}.save.oldServer`, { state });
69
+ if (code === 403 && body?.code === 'WORKER_BROWSER') return tx(`${K}.save.automationBrowser`, { state });
70
+ if (!code) return tx(`${K}.save.noAnswer`, { state, reason: clean(error) || '' });
71
+ return tx(`${K}.save.failed`, { state, reason: clean(body?.error || error) || `HTTP ${code}` });
72
+ }
@@ -40,6 +40,7 @@ export const SETTINGS_READS = Object.freeze({
40
40
  typesafe: { url: '/api/typesafe/config', accept: (body) => body?.ok === true },
41
41
  userContext: { url: '/api/assistant/user-context', raw: true },
42
42
  workerGuard: { url: '/api/assistant/worker-guard', raw: true },
43
+ browserOwnerAccess: { url: '/api/assistant/automation-browser-owner-access', raw: true },
43
44
  });
44
45
 
45
46
  const caches = Object.fromEntries(Object.entries(SETTINGS_READS).map(([name, spec]) => [name, createDataCache(`settings:${name}`, {
@@ -94,6 +94,7 @@ export const SETTINGS_PAGES = [
94
94
  sections: [
95
95
  { id: 'setup-browser', key: 'browser_choice', state: 'open' },
96
96
  { id: 'bcg-profiles', key: 'browser_profiles', state: 'open' },
97
+ { id: 'bcg-owner-access', key: 'automation_browser_owner_access', state: 'open' },
97
98
  { id: 'bcg-identity', key: 'identity_privacy', state: 'advanced' },
98
99
  { id: 'bcg-viewport', key: 'display', state: 'advanced' },
99
100
  { id: 'bcg-advanced', key: 'advanced_browser_behavior', state: 'advanced' },
@@ -265,13 +266,14 @@ export const SETTINGS_CONTROLS = {
265
266
  'project-storage-manager': 'PRJ001 PRJ012 PRJ002 PRJ003 PRJ004 PRJ005 PRJ006',
266
267
  'setup-browser': 'BRW003 BRW001 BRW002 BRW084 BRW004 BRW005 BRW006 BRW007 BRW008 BRW009',
267
268
  'bcg-profiles': 'BRW011 BRW012 BRW013 BRW014 BRW083 BRW010 BRW015 BRW016 BRW017 BRW018 BRW019 BRW020',
269
+ 'bcg-owner-access': 'BRW087',
268
270
  'bcg-identity': 'BRW021 BRW022 BRW023 BRW024 BRW025',
269
271
  'bcg-viewport': 'BRW026 BRW027 BRW028 BRW029 BRW030 BRW031 BRW032',
270
272
  'bcg-advanced': 'BRW033 BRW034 BRW035 BRW036 BRW037 BRW038 BRW039 BRW040 BRW041 BRW042 BRW043 BRW044 BRW045 BRW046 BRW047 BRW048 BRW049 BRW050 BRW051 BRW052 BRW053 BRW054 BRW055 BRW056 BRW057 BRW058 BRW059 BRW060 BRW061 BRW062 BRW063 BRW064 BRW065 BRW066 BRW067 BRW068 BRW069 BRW070 BRW071 BRW072 BRW073 BRW074 BRW075 BRW076 BRW077 BRW078 BRW079 BRW080',
271
273
  'stg-sec-default-tools': 'MCP022 MCP024 MCP005 MCP004',
272
274
  'stg-sec-added-servers': 'MCP026 MCP006 MCP007 MCP008 MCP009 MCP010 MCP011 MCP012 MCP013 MCP014 MCP015 MCP027 MCP016 MCP017 MCP018 MCP019 MCP020 MCP021',
273
275
  'stg-sec-ml-connection': 'ML015 ML001 ML002 ML003',
274
- 'stg-sec-ml-profiles': 'ML004 ML005 ML006 ML016 ML017 ML018 ML019',
276
+ 'stg-sec-ml-profiles': 'ML004 ML020 ML005 ML006 ML016 ML017 ML018 ML019 ML021 ML022 ML023 ML024 ML025 ML026 ML027 ML028 ML029 ML030 ML031 ML032 ML033 ML034 ML035 ML036',
275
277
  'stg-sec-ml-credentials': 'ML007 ML008 ML009 ML010 ML011',
276
278
  'stg-sec-ml-server': 'ML012 ML013 ML014',
277
279
  'stg-sec-skills': 'SKL004 SKL001',
@@ -0,0 +1,153 @@
1
+ // What Settings → Connected tools → MoreLogin decides about local profiles, without the page.
2
+ // No imports: `node --test` loads it (tests/settings-local-profiles.test.mjs).
3
+ //
4
+ // A local profile is a Chrome SynaBun runs itself on this computer (lib/local-profiles.js). It is listed with the
5
+ // MoreLogin profiles (`kind: 'local'` in GET /api/morelogin/profiles) and has an editor of its own, fed by
6
+ // GET /api/morelogin/local-profiles. The page draws; this module says what a row shows, where a new profile is
7
+ // created by default, and what the editor's fields mean as a request body.
8
+
9
+ export const PROXY_TYPES = Object.freeze(['none', 'http', 'https', 'socks5']);
10
+ export const DEFAULT_WINDOW = Object.freeze({ width: 1280, height: 800 });
11
+
12
+ /** Whether a listed profile is one of SynaBun's own. */
13
+ export function isLocalProfile(env) {
14
+ return !!env && env.kind === 'local';
15
+ }
16
+
17
+ /** A local row's proxy in a few words: '' for none, else `SOCKS5 host:port`. `login`: the word for "with a login". */
18
+ export function proxySummary(env, login = '') {
19
+ const proxy = env && env.proxy;
20
+ if (!proxy || !proxy.type || proxy.type === 'none') return '';
21
+ const where = [proxy.host, proxy.port].filter(Boolean).join(':');
22
+ return [String(proxy.type).toUpperCase(), where, env.proxyUsername && login ? login : ''].filter(Boolean).join(' ');
23
+ }
24
+
25
+ /**
26
+ * Where "Create" makes a profile when the owner has not chosen: 'local' while MoreLogin cannot make one (not
27
+ * installed, closed, its API refusing) or after it refused one for its plan's limit, else 'morelogin'.
28
+ * @param {{ installed?: boolean, running?: boolean, apiError?: string|null }|null} status GET /api/morelogin/status
29
+ */
30
+ export function defaultCreateWhere(status, { limitHit = false } = {}) {
31
+ if (limitHit) return 'local';
32
+ if (!status || !status.installed || !status.running || status.apiError) return 'local';
33
+ return 'morelogin';
34
+ }
35
+
36
+ /**
37
+ * What the Create button does: 'local' (a local profile), 'morelogin' (a MoreLogin profile, which takes one of the
38
+ * plan's slots) or 'restart' (nothing is created: Local was asked of a server that is older than local profiles, and
39
+ * the owner is told to restart SynaBun). A create asked as Local never becomes a MoreLogin one.
40
+ * @param {{ where?: string, localKnown?: boolean }} o `where`: the "Where" dropdown's value
41
+ */
42
+ export function createAction({ where, localKnown } = {}) {
43
+ if (where === 'local') return localKnown ? 'local' : 'restart';
44
+ return 'morelogin';
45
+ }
46
+
47
+ /** The "Where" options. Local cannot be chosen while the running server does not know local profiles. */
48
+ export function whereOptions({ localKnown, selected = 'morelogin' } = {}) {
49
+ const chosen = !localKnown && selected === 'local' ? 'morelogin' : selected;
50
+ return [
51
+ { value: 'local', disabled: !localKnown, selected: chosen === 'local' },
52
+ { value: 'morelogin', disabled: false, selected: chosen !== 'local' },
53
+ ];
54
+ }
55
+
56
+ /**
57
+ * Whether the editor has to ask for the proxy password again: the profile has a saved one, none was typed, and the
58
+ * proxy's type, host, port or username is no longer the saved one. The server drops the saved password then (it was
59
+ * typed for another server or another account), so a save or a proxy check without it would go out with no password.
60
+ * @param values the editor's fields as typed
61
+ * @param profile the row of GET /api/morelogin/local-profiles the editor was opened on
62
+ */
63
+ export function passwordNeededAgain(values, profile) {
64
+ const v = values || {};
65
+ if (!profile || !profile.hasPassword || v.passwordTouched) return false;
66
+ const type = PROXY_TYPES.includes(v.proxyType) ? v.proxyType : 'none';
67
+ if (type === 'none' || !String(v.username ?? '').trim()) return false;
68
+ const saved = formOfProfile(profile);
69
+ return type !== saved.proxyType
70
+ || String(v.host ?? '').trim() !== saved.host
71
+ || String(Number(String(v.port ?? '').trim())) !== String(Number(saved.port))
72
+ || String(v.username ?? '').trim() !== saved.username;
73
+ }
74
+
75
+ /** Whether a failed create is MoreLogin's plan limit (the server's code). */
76
+ export function isPlanLimit(answer) {
77
+ return !!answer && answer.ok === false && answer.code === 'MORELOGIN_PLAN_LIMIT';
78
+ }
79
+
80
+ /** Whether Intl knows a timezone name (an IANA name such as America/Sao_Paulo). */
81
+ export function validTimezone(name) {
82
+ const value = String(name ?? '').trim();
83
+ if (!value) return false;
84
+ try { new Intl.DateTimeFormat('en-US', { timeZone: value }); return true; } catch { return false; }
85
+ }
86
+
87
+ /** Whether a text is a language tag (pt-BR, en-US, de). */
88
+ export function validLanguage(tag) {
89
+ const value = String(tag ?? '').trim();
90
+ if (!/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/.test(value)) return false;
91
+ try { return Intl.getCanonicalLocales(value).length === 1; } catch { return false; }
92
+ }
93
+
94
+ /** The editor's fields for one profile of GET /api/morelogin/local-profiles. The password is never among them. */
95
+ export function formOfProfile(profile) {
96
+ const p = profile || {};
97
+ const proxy = p.proxy || null;
98
+ return {
99
+ name: String(p.name ?? ''),
100
+ proxyType: proxy && PROXY_TYPES.includes(proxy.type) ? proxy.type : 'none',
101
+ host: proxy ? String(proxy.host ?? '') : '',
102
+ port: proxy && proxy.port != null ? String(proxy.port) : '',
103
+ username: String(p.proxyUsername ?? ''),
104
+ password: '',
105
+ hasPassword: !!p.hasPassword,
106
+ language: String(p.language ?? ''),
107
+ timezone: String(p.timezone ?? ''),
108
+ width: String(p.window?.width ?? DEFAULT_WINDOW.width),
109
+ height: String(p.window?.height ?? DEFAULT_WINDOW.height),
110
+ notes: String(p.notes ?? ''),
111
+ };
112
+ }
113
+
114
+ /**
115
+ * The editor's fields as the body of PUT /api/morelogin/local-profiles/:id.
116
+ * → { ok: true, body } or { ok: false, errors: { field: reason } } with reasons 'name' | 'host' | 'port' | 'language'
117
+ * | 'timezone' | 'window' (the page says each in its own words).
118
+ * The password travels only when the owner typed one (`passwordTouched`): an untouched field keeps the saved one,
119
+ * which the server never sends back.
120
+ */
121
+ export function readLocalProfileForm(values) {
122
+ const v = values || {};
123
+ const errors = {};
124
+ const name = String(v.name ?? '').trim();
125
+ if (!name || name.length > 80) errors.name = 'name';
126
+ const type = PROXY_TYPES.includes(v.proxyType) ? v.proxyType : 'none';
127
+ const proxy = { type };
128
+ if (type !== 'none') {
129
+ const host = String(v.host ?? '').trim();
130
+ if (!host || /[\s/@?#]/.test(host)) errors.host = 'host';
131
+ const port = Number(String(v.port ?? '').trim());
132
+ if (!Number.isInteger(port) || port < 1 || port > 65535) errors.port = 'port';
133
+ proxy.host = host;
134
+ proxy.port = port;
135
+ proxy.username = String(v.username ?? '').trim();
136
+ if (v.passwordTouched) proxy.password = String(v.password ?? '');
137
+ }
138
+ const language = String(v.language ?? '').trim();
139
+ if (language && !validLanguage(language)) errors.language = 'language';
140
+ const timezone = String(v.timezone ?? '').trim();
141
+ if (timezone && !validTimezone(timezone)) errors.timezone = 'timezone';
142
+ const width = Number(String(v.width ?? '').trim() || DEFAULT_WINDOW.width);
143
+ const height = Number(String(v.height ?? '').trim() || DEFAULT_WINDOW.height);
144
+ if (!Number.isInteger(width) || width < 400 || width > 7680 || !Number.isInteger(height) || height < 300 || height > 4320) errors.window = 'window';
145
+ if (Object.keys(errors).length) return { ok: false, errors };
146
+ return { ok: true, body: { name, proxy, language, timezone, window: { width, height }, notes: String(v.notes ?? '').slice(0, 2000) } };
147
+ }
148
+
149
+ /** The proxy of the editor's fields as "check proxy" takes it (the unsaved values), or null when they are not usable. */
150
+ export function proxyOfForm(values) {
151
+ const read = readLocalProfileForm({ ...values, name: values?.name || 'x', language: '', timezone: '', width: '', height: '' });
152
+ return read.ok ? read.body.proxy : null;
153
+ }
@@ -0,0 +1,105 @@
1
+ // ═══════════════════════════════════════════
2
+ // SynaBun — Settings → OpenCode → Providers: the Maritaca card (DOM-free)
3
+ // ═══════════════════════════════════════════
4
+ //
5
+ // What the card next to the Ollama card says for an answer of GET /api/maritaca/opencode/status
6
+ // (lib/maritaca/opencode.js), and which actions it offers. `ui-settings.js` draws it; this decides.
7
+ // States: unavailable (an older server: 503 / no answer), no-key, not-registered, registered (in sync),
8
+ // stale (registered, but the key reference or the model list changed), configuring, error.
9
+
10
+ export const MARITACA_OPENCODE_STATES = Object.freeze(['unavailable', 'no-key', 'not-registered', 'registered', 'stale', 'configuring', 'error']);
11
+
12
+ /** The dot colours the Ollama card uses (the provider cards' own scale, not a theme token). */
13
+ const DOT = Object.freeze({ ok: '#4ade80', wait: '#facc15', off: 'rgba(248,113,113,0.7)' });
14
+
15
+ /** The i18n key (under settings.redesign.opencode) of every string the card can show. */
16
+ export const MARITACA_OPENCODE_KEYS = Object.freeze({
17
+ subname: 'maritacaSubname',
18
+ unavailableStatus: 'maritacaUnavailableStatus', unavailableNote: 'maritacaUnavailableNote',
19
+ noKeyStatus: 'maritacaNoKeyStatus', noKeyNote: 'maritacaNoKeyNote', openPanel: 'maritacaOpenPanel',
20
+ notRegisteredStatus: 'maritacaNotRegisteredStatus', notRegisteredNote: 'maritacaNotRegisteredNote', configure: 'maritacaConfigure',
21
+ registeredStatus: 'maritacaRegisteredStatus', registeredTag: 'maritacaRegisteredTag', keyFile: 'maritacaKeyFile', keyEnv: 'maritacaKeyEnv',
22
+ staleStatus: 'maritacaStaleStatus', staleNote: 'maritacaStaleNote', resync: 'maritacaResync',
23
+ configuringStatus: 'configuring', configuringNote: 'writingProviderConfig',
24
+ errorStatus: 'maritacaErrorStatus', error: 'error2',
25
+ remove: 'remove', removing: 'removing', model: 'model',
26
+ registeredToast: 'maritacaProviderRegistered', removedToast: 'maritacaProviderRemoved',
27
+ });
28
+
29
+ /**
30
+ * The card's state for a status answer. `status` is the JSON of GET /api/maritaca/opencode/status (or null when the
31
+ * request failed), `configuring` while a configure request is in flight, `error` the message of a failed configure.
32
+ */
33
+ export function maritacaOpencodeCardState(status, { configuring = false, error = '' } = {}) {
34
+ if (configuring) return 'configuring';
35
+ if (error) return 'error';
36
+ if (!status || status.ok === false || typeof status.registered !== 'boolean') return 'unavailable';
37
+ if (status.registered) return status.inSync ? 'registered' : 'stale';
38
+ return status.keyConfigured ? 'not-registered' : 'no-key';
39
+ }
40
+
41
+ /**
42
+ * Everything the card shows: `t(key, vars)` translates a `settings.redesign.opencode.*` key (the key without the prefix).
43
+ * → { state, dot, statusCls, statusText, note, tag, actions: [...'configure' | 'resync' | 'remove' | 'open-panel'], modelCount }
44
+ */
45
+ export function maritacaOpencodeCardView(status, t, { configuring = false, error = '' } = {}) {
46
+ const state = maritacaOpencodeCardState(status, { configuring, error });
47
+ const K = MARITACA_OPENCODE_KEYS;
48
+ const modelCount = Number(status?.modelCount) || 0;
49
+ const keySource = status?.keySource === 'env' ? t(K.keyEnv) : t(K.keyFile);
50
+ const view = { state, modelCount, actions: [], tag: '', note: '' };
51
+ switch (state) {
52
+ case 'configuring':
53
+ Object.assign(view, { dot: DOT.wait, statusCls: 'stg-provider-status-key', statusText: t(K.configuringStatus), note: t(K.configuringNote) });
54
+ break;
55
+ case 'unavailable':
56
+ Object.assign(view, { dot: DOT.off, statusCls: 'stg-provider-status-disconnected', statusText: t(K.unavailableStatus), note: t(K.unavailableNote) });
57
+ break;
58
+ case 'no-key':
59
+ Object.assign(view, { dot: DOT.wait, statusCls: 'stg-provider-status-key', statusText: t(K.noKeyStatus), note: t(K.noKeyNote), actions: ['open-panel'] });
60
+ break;
61
+ case 'not-registered':
62
+ Object.assign(view, { dot: DOT.wait, statusCls: 'stg-provider-status-key', statusText: t(K.notRegisteredStatus), note: t(K.notRegisteredNote, { source: keySource }), actions: ['configure'] });
63
+ break;
64
+ case 'stale':
65
+ Object.assign(view, { dot: DOT.wait, statusCls: 'stg-provider-status-key', statusText: t(K.staleStatus), note: t(K.staleNote), actions: ['resync', 'remove'] });
66
+ break;
67
+ case 'error':
68
+ Object.assign(view, { dot: DOT.off, statusCls: 'stg-provider-status-disconnected', statusText: t(K.errorStatus), note: t(K.error, { message: error }), actions: ['configure'] });
69
+ break;
70
+ default: // registered
71
+ Object.assign(view, {
72
+ dot: DOT.ok, statusCls: 'stg-provider-status-connected', statusText: t(K.registeredStatus),
73
+ tag: t(K.registeredTag, { source: keySource }), note: '', actions: ['remove'],
74
+ });
75
+ }
76
+ return view;
77
+ }
78
+
79
+ /** The OpenCode provider id the block is registered under: hidden ids are `maritaca/<model-id>`. */
80
+ export const MARITACA_OPENCODE_PROVIDER = 'maritaca';
81
+
82
+ /**
83
+ * The card's per-model visibility list, the same denylist the other provider cards write (ocp-hidden-models.js,
84
+ * "providerID/modelID"). Models come from the status answer (`status.models`, lib/maritaca/opencode.js); a server from
85
+ * before that field sends none, and then `fallback` (the model ids OpenCode lists for `maritaca`) stands in.
86
+ * Only a registered block (in sync or stale) has a list. → { rows: [{ id, fullId, name, hidden, tools }], enabled, total }
87
+ */
88
+ export function maritacaOpencodeModelRows(status, hidden = new Set(), fallback = []) {
89
+ const registered = !!status && status.ok !== false && status.registered === true;
90
+ if (!registered) return { rows: [], enabled: 0, total: 0 };
91
+ const has = (id) => (hidden && typeof hidden.has === 'function' ? hidden.has(id) : false);
92
+ const source = Array.isArray(status.models) && status.models.length
93
+ ? status.models
94
+ : (Array.isArray(fallback) ? fallback : []).map((m) => (typeof m === 'string' ? { id: m } : m));
95
+ const seen = new Set();
96
+ const rows = [];
97
+ for (const m of source) {
98
+ const id = typeof m?.id === 'string' ? m.id.trim() : '';
99
+ if (!id || seen.has(id)) continue;
100
+ seen.add(id);
101
+ const fullId = `${MARITACA_OPENCODE_PROVIDER}/${id}`;
102
+ rows.push({ id, fullId, name: typeof m.name === 'string' && m.name ? m.name : id, hidden: has(fullId), tools: typeof m.tools === 'boolean' ? m.tools : null });
103
+ }
104
+ return { rows, enabled: rows.filter((r) => !r.hidden).length, total: rows.length };
105
+ }
@@ -5,10 +5,10 @@
5
5
  // permission or a question waiting), Codex (a turn or a thread being made; an
6
6
  // approval or a question card waiting), OpenCode (tabPillState: a turn, an
7
7
  // automation's turn, a sub-agent's, one waiting on you) and the SynaBun
8
- // Assistant (sessionStatus). The same source as the tray pills, never a second
8
+ // Assistant (sessionStatus); Maritaca (a reply streaming: mtc-pill-running, it never waits on you). The same source as the tray pills, never a second
9
9
  // guess. DOM-free.
10
10
 
11
- const WORKING = /^(cp|cxp|ocpv2|agy|asp)-pill-running$/;
11
+ const WORKING = /^(cp|cxp|ocpv2|agy|mtc|asp)-pill-running$/;
12
12
  const NEEDS_YOU = /^((cp|cxp|agy|asp)-pill-attention|ocpv2-pill-waiting)$/;
13
13
 
14
14
  /** The states a detached window's pill shows: a session in it needs you > one works > none. */
@@ -42,6 +42,20 @@ export function normalizeSessionWindowStatus(status) {
42
42
  * of their own (a permission, a question) says it already. A run that ended
43
43
  * waits on nobody.
44
44
  */
45
+ /**
46
+ * A turn of a dispatched worker's run is in progress, so its tab works: the
47
+ * run is alive (starting or running) and its turn state says neither idle (a
48
+ * warm worker between turns: alive, not working) nor terminal. A classic loop
49
+ * reports no turn state and works for as long as it runs. A run a restart
50
+ * suspended, or one that ended, works no more: a tab that still shows a turn
51
+ * ends it on this answer, whether or not the turn's own result event reached
52
+ * the window (every provider panel's attach reads it).
53
+ */
54
+ export function runTurnLive(run) {
55
+ if (run?.status !== 'starting' && run?.status !== 'running') return false;
56
+ return run.turnState !== 'idle' && run.turnState !== 'terminal';
57
+ }
58
+
45
59
  export function runAwaitsAnswer(run) {
46
60
  if (run?.status !== 'starting' && run?.status !== 'running') return false;
47
61
  if (run.turnState === 'needs_input' || run.turnState === 'awaiting_permission' || run.pending?.some((p) => p.kind === 'question')) return true;
@@ -46,7 +46,7 @@ export const state = {
46
46
  linkedSessionIds: new Set(), // session IDs currently in an active link
47
47
 
48
48
  // ── Side panel routing ──
49
- lastActivePanel: 'claude', // 'claude' | 'codex' | 'opencode' | 'antigravity' | 'assistant' — used by whiteboard "Send to Panel"
49
+ lastActivePanel: 'claude', // 'claude' | 'codex' | 'opencode' | 'antigravity' | 'maritaca' | 'assistant' — used by whiteboard "Send to Panel"
50
50
  };
51
51
 
52
52