synabun 2.4.1 → 2.4.3

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 (345) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/README.md +1 -1
  3. package/docs/browser-extension-bridge.md +46 -6
  4. package/lib/data-home-files.js +4 -2
  5. package/lib/first-launch-protection.js +8 -2
  6. package/lib/release-npm-ci.mjs +23 -1
  7. package/lib/update-snapshot.js +11 -4
  8. package/mcp-server/dist/http.d.ts.map +1 -1
  9. package/mcp-server/dist/http.js +25 -2
  10. package/mcp-server/dist/http.js.map +1 -1
  11. package/mcp-server/dist/index.d.ts.map +1 -1
  12. package/mcp-server/dist/index.js +62 -17
  13. package/mcp-server/dist/index.js.map +1 -1
  14. package/mcp-server/dist/services/browser-bench.d.ts +22 -22
  15. package/mcp-server/dist/services/memory-maintenance.d.ts +1 -0
  16. package/mcp-server/dist/services/memory-maintenance.d.ts.map +1 -1
  17. package/mcp-server/dist/services/memory-maintenance.js +34 -45
  18. package/mcp-server/dist/services/memory-maintenance.js.map +1 -1
  19. package/mcp-server/dist/services/memory-migration-copy.d.ts +144 -0
  20. package/mcp-server/dist/services/memory-migration-copy.d.ts.map +1 -0
  21. package/mcp-server/dist/services/memory-migration-copy.js +467 -0
  22. package/mcp-server/dist/services/memory-migration-copy.js.map +1 -0
  23. package/mcp-server/dist/services/memory-migration-worker.d.ts +2 -0
  24. package/mcp-server/dist/services/memory-migration-worker.d.ts.map +1 -0
  25. package/mcp-server/dist/services/memory-migration-worker.js +60 -0
  26. package/mcp-server/dist/services/memory-migration-worker.js.map +1 -0
  27. package/mcp-server/dist/services/memory-retrieval.d.ts +4 -0
  28. package/mcp-server/dist/services/memory-retrieval.d.ts.map +1 -1
  29. package/mcp-server/dist/services/memory-retrieval.js +188 -40
  30. package/mcp-server/dist/services/memory-retrieval.js.map +1 -1
  31. package/mcp-server/dist/services/memory-schema.d.ts +58 -2
  32. package/mcp-server/dist/services/memory-schema.d.ts.map +1 -1
  33. package/mcp-server/dist/services/memory-schema.js +190 -13
  34. package/mcp-server/dist/services/memory-schema.js.map +1 -1
  35. package/mcp-server/dist/services/memory-sessions.d.ts +19 -1
  36. package/mcp-server/dist/services/memory-sessions.d.ts.map +1 -1
  37. package/mcp-server/dist/services/memory-sessions.js +56 -20
  38. package/mcp-server/dist/services/memory-sessions.js.map +1 -1
  39. package/mcp-server/dist/services/memory-verification.d.ts.map +1 -1
  40. package/mcp-server/dist/services/memory-verification.js +8 -5
  41. package/mcp-server/dist/services/memory-verification.js.map +1 -1
  42. package/mcp-server/dist/services/neural-interface.d.ts +5 -0
  43. package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
  44. package/mcp-server/dist/services/neural-interface.js +19 -2
  45. package/mcp-server/dist/services/neural-interface.js.map +1 -1
  46. package/mcp-server/dist/services/retrieval-reader-worker.d.ts +2 -0
  47. package/mcp-server/dist/services/retrieval-reader-worker.d.ts.map +1 -0
  48. package/mcp-server/dist/services/retrieval-reader-worker.js +76 -0
  49. package/mcp-server/dist/services/retrieval-reader-worker.js.map +1 -0
  50. package/mcp-server/dist/services/retrieval-reader.d.ts +38 -0
  51. package/mcp-server/dist/services/retrieval-reader.d.ts.map +1 -0
  52. package/mcp-server/dist/services/retrieval-reader.js +145 -0
  53. package/mcp-server/dist/services/retrieval-reader.js.map +1 -0
  54. package/mcp-server/dist/services/sqlite-write.d.ts +14 -0
  55. package/mcp-server/dist/services/sqlite-write.d.ts.map +1 -0
  56. package/mcp-server/dist/services/sqlite-write.js +94 -0
  57. package/mcp-server/dist/services/sqlite-write.js.map +1 -0
  58. package/mcp-server/dist/services/sqlite.d.ts +39 -0
  59. package/mcp-server/dist/services/sqlite.d.ts.map +1 -1
  60. package/mcp-server/dist/services/sqlite.js +249 -8
  61. package/mcp-server/dist/services/sqlite.js.map +1 -1
  62. package/mcp-server/dist/services/tool-catalog.d.ts +1 -1
  63. package/mcp-server/dist/services/typesafe-config.d.ts +7 -1
  64. package/mcp-server/dist/services/typesafe-config.d.ts.map +1 -1
  65. package/mcp-server/dist/services/typesafe-config.js +32 -10
  66. package/mcp-server/dist/services/typesafe-config.js.map +1 -1
  67. package/mcp-server/dist/services/typesafe.d.ts.map +1 -1
  68. package/mcp-server/dist/services/typesafe.js +9 -7
  69. package/mcp-server/dist/services/typesafe.js.map +1 -1
  70. package/mcp-server/dist/services/vector-cache.d.ts +32 -0
  71. package/mcp-server/dist/services/vector-cache.d.ts.map +1 -1
  72. package/mcp-server/dist/services/vector-cache.js +161 -8
  73. package/mcp-server/dist/services/vector-cache.js.map +1 -1
  74. package/mcp-server/dist/tools/agent-definition.d.ts +2 -2
  75. package/mcp-server/dist/tools/agents.d.ts +11 -7
  76. package/mcp-server/dist/tools/agents.d.ts.map +1 -1
  77. package/mcp-server/dist/tools/agents.js +27 -9
  78. package/mcp-server/dist/tools/agents.js.map +1 -1
  79. package/mcp-server/dist/tools/browser-advanced.d.ts +1 -1
  80. package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
  81. package/mcp-server/dist/tools/browser-advanced.js +10 -3
  82. package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
  83. package/mcp-server/dist/tools/browser-extension-setup.d.ts +5 -0
  84. package/mcp-server/dist/tools/browser-extension-setup.d.ts.map +1 -0
  85. package/mcp-server/dist/tools/browser-extension-setup.js +29 -0
  86. package/mcp-server/dist/tools/browser-extension-setup.js.map +1 -0
  87. package/mcp-server/dist/tools/browser-interact.d.ts.map +1 -1
  88. package/mcp-server/dist/tools/browser-interact.js +6 -1
  89. package/mcp-server/dist/tools/browser-interact.js.map +1 -1
  90. package/mcp-server/dist/tools/fb-groups.d.ts +2 -2
  91. package/mcp-server/dist/tools/skill-tools.d.ts +4 -4
  92. package/mcp-server/dist/tools/tool-groups.d.ts +1 -1
  93. package/mcp-server/package-lock.json +5 -5
  94. package/mcp-server/package.json +1 -1
  95. package/mcp-server/src/http.ts +20 -2
  96. package/mcp-server/src/index.ts +59 -17
  97. package/mcp-server/src/services/memory-maintenance.ts +31 -28
  98. package/mcp-server/src/services/memory-migration-copy.ts +419 -0
  99. package/mcp-server/src/services/memory-migration-worker.ts +55 -0
  100. package/mcp-server/src/services/memory-retrieval.ts +173 -32
  101. package/mcp-server/src/services/memory-schema.ts +194 -12
  102. package/mcp-server/src/services/memory-sessions.ts +54 -21
  103. package/mcp-server/src/services/memory-verification.ts +7 -4
  104. package/mcp-server/src/services/neural-interface.ts +22 -2
  105. package/mcp-server/src/services/retrieval-reader-worker.ts +67 -0
  106. package/mcp-server/src/services/retrieval-reader.ts +131 -0
  107. package/mcp-server/src/services/sqlite-write.ts +60 -0
  108. package/mcp-server/src/services/sqlite.ts +246 -8
  109. package/mcp-server/src/services/typesafe-config.ts +25 -6
  110. package/mcp-server/src/services/typesafe.ts +9 -7
  111. package/mcp-server/src/services/vector-cache.ts +154 -9
  112. package/mcp-server/src/tools/agents.ts +26 -9
  113. package/mcp-server/src/tools/browser-advanced.ts +10 -3
  114. package/mcp-server/src/tools/browser-extension-setup.ts +36 -0
  115. package/mcp-server/src/tools/browser-interact.ts +5 -1
  116. package/neural-interface/i18n/en.json +313 -2
  117. package/neural-interface/i18n/pt-BR.json +321 -10
  118. package/neural-interface/lib/agents/split.js +32 -4
  119. package/neural-interface/lib/assistant-api.js +52 -8
  120. package/neural-interface/lib/assistant-brains/claude.js +2 -0
  121. package/neural-interface/lib/assistant-brains/opencode.js +121 -7
  122. package/neural-interface/lib/assistant-catalog.js +2 -2
  123. package/neural-interface/lib/assistant-config.js +0 -7
  124. package/neural-interface/lib/assistant-dispatch.js +281 -95
  125. package/neural-interface/lib/assistant-envelope.js +40 -0
  126. package/neural-interface/lib/assistant-persona.js +16 -4
  127. package/neural-interface/lib/assistant-pricing.js +65 -14
  128. package/neural-interface/lib/assistant-router.js +131 -47
  129. package/neural-interface/lib/assistant-run-wait.js +45 -28
  130. package/neural-interface/lib/assistant-runtime.js +133 -42
  131. package/neural-interface/lib/backup-contents.js +158 -0
  132. package/neural-interface/lib/backup-crypto-io.js +330 -0
  133. package/neural-interface/lib/backup-crypto-worker.js +130 -0
  134. package/neural-interface/lib/backup-crypto.js +525 -0
  135. package/neural-interface/lib/backup-download.js +268 -0
  136. package/neural-interface/lib/backup-encryption.js +318 -0
  137. package/neural-interface/lib/backup-groups.js +287 -0
  138. package/neural-interface/lib/backup-restore-session.js +176 -0
  139. package/neural-interface/lib/backup-restore-stage.js +60 -0
  140. package/neural-interface/lib/backup-service.js +788 -233
  141. package/neural-interface/lib/backup-zip-reader.js +30 -18
  142. package/neural-interface/lib/backup-zip-writer.js +34 -10
  143. package/neural-interface/lib/browser-extension-adapter.js +89 -15
  144. package/neural-interface/lib/browser-extension-archive.js +149 -0
  145. package/neural-interface/lib/browser-extension-bridge.js +24 -10
  146. package/neural-interface/lib/browser-extension-folder.js +596 -76
  147. package/neural-interface/lib/browser-extension-package.js +200 -0
  148. package/neural-interface/lib/browser-extension-pin.js +84 -0
  149. package/neural-interface/lib/browser-extension-pin.json +33 -0
  150. package/{browser-extension/protocol.js → neural-interface/lib/browser-extension-protocol.js} +91 -6
  151. package/neural-interface/lib/browser-extension-setup.js +105 -18
  152. package/neural-interface/lib/claude-agent-bridge.js +1 -0
  153. package/neural-interface/lib/claude-session-cleanup.js +5 -1
  154. package/neural-interface/lib/cli-install.js +23 -3
  155. package/neural-interface/lib/cli-update-planner.js +171 -9
  156. package/neural-interface/lib/client-diagnostics.js +42 -0
  157. package/neural-interface/lib/confined-fs.js +7 -2
  158. package/neural-interface/lib/coordination/README.md +8 -2
  159. package/neural-interface/lib/coordination/contract.js +161 -0
  160. package/neural-interface/lib/coordination/database.js +999 -0
  161. package/neural-interface/lib/coordination/operations.js +436 -0
  162. package/neural-interface/lib/coordination/service.js +68 -537
  163. package/neural-interface/lib/coordination/storage-worker.js +101 -0
  164. package/neural-interface/lib/coordination/store.js +219 -1111
  165. package/neural-interface/lib/db.js +70 -32
  166. package/neural-interface/lib/health-count.js +37 -0
  167. package/neural-interface/lib/loop-stall.js +139 -0
  168. package/neural-interface/lib/maritaca/client.js +2 -2
  169. package/neural-interface/lib/maritaca/models.js +12 -17
  170. package/neural-interface/lib/maritaca/opencode.js +4 -2
  171. package/neural-interface/lib/memory-api.js +9 -1
  172. package/neural-interface/lib/memory-session-capture.js +42 -10
  173. package/neural-interface/lib/memory-store-gate.js +313 -0
  174. package/neural-interface/lib/memory-store-migrate.js +65 -0
  175. package/neural-interface/lib/memory-timers.js +7 -7
  176. package/neural-interface/lib/native-loop-providers.js +23 -17
  177. package/neural-interface/lib/native-loop-runtime.js +48 -9
  178. package/neural-interface/lib/opencode-build-preflight.js +18 -1
  179. package/neural-interface/lib/opencode-native-boundary.js +69 -8
  180. package/neural-interface/lib/opencode-provider-view.js +14 -3
  181. package/neural-interface/lib/opencode-shell-read.js +107 -0
  182. package/neural-interface/lib/opencode-stop-failures.js +40 -0
  183. package/neural-interface/lib/opencode-turn-release.js +173 -0
  184. package/neural-interface/lib/opencode-v2-client.js +4 -1
  185. package/neural-interface/lib/opencode-v2-ws-requests.js +65 -1
  186. package/neural-interface/lib/opencode2-client.js +343 -7
  187. package/neural-interface/lib/opencode2-translate.js +161 -4
  188. package/neural-interface/lib/recall-impact.js +122 -0
  189. package/neural-interface/lib/scratch-evidence.js +420 -0
  190. package/neural-interface/lib/scratch-process-guard.js +139 -0
  191. package/neural-interface/lib/scratch-references.js +279 -0
  192. package/neural-interface/lib/scratch-retention-core.js +385 -0
  193. package/neural-interface/lib/scratch-retention-worker.js +37 -0
  194. package/neural-interface/lib/scratch-retention.js +151 -0
  195. package/neural-interface/lib/session-cache-builder.js +31 -43
  196. package/neural-interface/lib/session-cache-worker.js +157 -0
  197. package/neural-interface/lib/session-indexer.js +28 -21
  198. package/neural-interface/lib/session-search-index.js +85 -0
  199. package/neural-interface/lib/skills/creation.js +1 -1
  200. package/neural-interface/lib/sqlite-integrity-worker.js +3 -1
  201. package/neural-interface/lib/style-guide/store.js +43 -3
  202. package/neural-interface/lib/system-restore.js +50 -0
  203. package/neural-interface/lib/teams/api.js +15 -6
  204. package/neural-interface/lib/teams/claims.js +67 -31
  205. package/neural-interface/lib/teams/index.js +7 -7
  206. package/neural-interface/lib/teams/integration.js +40 -40
  207. package/neural-interface/lib/teams/landing.js +6 -6
  208. package/neural-interface/lib/teams/recovery.js +24 -23
  209. package/neural-interface/lib/teams/scheduler.js +194 -95
  210. package/neural-interface/lib/teams/state.js +14 -14
  211. package/neural-interface/lib/teams/worktrees.js +27 -27
  212. package/neural-interface/lib/terminal-token-redaction.js +83 -0
  213. package/neural-interface/lib/whatsapp/bridge.js +54 -7
  214. package/neural-interface/lib/worker-confinement.js +47 -2
  215. package/neural-interface/lib/worker-mcp-channel.js +2 -0
  216. package/neural-interface/lib/worker-resume.js +5 -0
  217. package/neural-interface/lib/worker-stop.js +86 -0
  218. package/neural-interface/package-lock.json +5 -5
  219. package/neural-interface/package.json +1 -1
  220. package/neural-interface/public/extension-setup.html +5 -2
  221. package/neural-interface/public/index.html +233 -24
  222. package/neural-interface/public/onboarding.html +259 -34
  223. package/neural-interface/public/shared/agents/studio/ax-library.js +0 -6
  224. package/neural-interface/public/shared/agents/studio/ax-main.js +14 -7
  225. package/neural-interface/public/shared/agy/agy-options.js +11 -0
  226. package/neural-interface/public/shared/agy/agy-panel.js +67 -20
  227. package/neural-interface/public/shared/agy/agy-styles.js +14 -12
  228. package/neural-interface/public/shared/agy/agy-tabs-logic.js +4 -1
  229. package/neural-interface/public/shared/api.js +1 -1
  230. package/neural-interface/public/shared/assistant/asst-api.js +28 -3
  231. package/neural-interface/public/shared/assistant/asst-brain-picker.js +13 -6
  232. package/neural-interface/public/shared/assistant/asst-control.js +2 -0
  233. package/neural-interface/public/shared/assistant/asst-motion-gate.js +78 -4
  234. package/neural-interface/public/shared/assistant/asst-panel.js +87 -3
  235. package/neural-interface/public/shared/assistant/asst-rack-styles.js +27 -0
  236. package/neural-interface/public/shared/assistant/asst-render.js +243 -44
  237. package/neural-interface/public/shared/assistant/asst-route.js +100 -21
  238. package/neural-interface/public/shared/assistant/asst-routes-editor.js +1 -1
  239. package/neural-interface/public/shared/assistant/asst-shell-logic.js +200 -0
  240. package/neural-interface/public/shared/assistant/asst-shell.js +111 -0
  241. package/neural-interface/public/shared/assistant/asst-sidepanel.js +4 -2
  242. package/neural-interface/public/shared/assistant/asst-state.js +11 -0
  243. package/neural-interface/public/shared/assistant/asst-styles.js +11 -23
  244. package/neural-interface/public/shared/assistant/route-identity.js +2 -1
  245. package/neural-interface/public/shared/cdx/cdx-render.js +9 -0
  246. package/neural-interface/public/shared/cdx/cdx-settings.js +3 -1
  247. package/neural-interface/public/shared/cdx/cdx-styles.js +6 -0
  248. package/neural-interface/public/shared/cdx/cdx-tabs.js +54 -9
  249. package/neural-interface/public/shared/client-diagnostics.js +94 -0
  250. package/neural-interface/public/shared/cp/cp-markdown.js +7 -2
  251. package/neural-interface/public/shared/cp/cp-styles.js +1 -1
  252. package/neural-interface/public/shared/effort-i18n.js +118 -0
  253. package/neural-interface/public/shared/extension-setup/es-page.js +10 -4
  254. package/neural-interface/public/shared/extension-setup/es-view.js +25 -10
  255. package/neural-interface/public/shared/html-shell.js +4 -52
  256. package/neural-interface/public/shared/loading-diagnostic-entry.js +64 -0
  257. package/neural-interface/public/shared/memory-store-wait.js +52 -0
  258. package/neural-interface/public/shared/morelogin-profile-field.js +1 -1
  259. package/neural-interface/public/shared/mtc/mtc-logic.js +2 -1
  260. package/neural-interface/public/shared/mtc/mtc-panel.js +25 -3
  261. package/neural-interface/public/shared/mtc/mtc-styles.js +13 -12
  262. package/neural-interface/public/shared/ocp-v2/ocp-v2-childpanel.js +7 -0
  263. package/neural-interface/public/shared/ocp-v2/ocp-v2-events.js +5 -0
  264. package/neural-interface/public/shared/ocp-v2/ocp-v2-location-logic.js +109 -0
  265. package/neural-interface/public/shared/ocp-v2/ocp-v2-manager.js +1 -0
  266. package/neural-interface/public/shared/ocp-v2/ocp-v2-modelpicker.js +8 -1
  267. package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +152 -8
  268. package/neural-interface/public/shared/ocp-v2/ocp-v2-rehydrate.js +7 -1
  269. package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +53 -4
  270. package/neural-interface/public/shared/ocp-v2/ocp-v2-send.js +52 -6
  271. package/neural-interface/public/shared/ocp-v2/ocp-v2-session-actions.js +22 -2
  272. package/neural-interface/public/shared/ocp-v2/ocp-v2-shell-block.js +165 -0
  273. package/neural-interface/public/shared/ocp-v2/ocp-v2-shell-logic.js +346 -0
  274. package/neural-interface/public/shared/ocp-v2/ocp-v2-shell.js +108 -0
  275. package/neural-interface/public/shared/ocp-v2/ocp-v2-state.js +49 -3
  276. package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +67 -93
  277. package/neural-interface/public/shared/ocp-v2/ocp-v2-tools-logic.js +20 -5
  278. package/neural-interface/public/shared/ocp-v2/ocp-v2-tools.js +7 -1
  279. package/neural-interface/public/shared/ocp-v2/ocp-v2-variantpicker.js +17 -6
  280. package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +7 -2
  281. package/neural-interface/public/shared/output-format.js +294 -0
  282. package/neural-interface/public/shared/provider-icons.js +6 -0
  283. package/neural-interface/public/shared/schedules-view.js +2 -1
  284. package/neural-interface/public/shared/server-presence.js +77 -0
  285. package/neural-interface/public/shared/settings/settings-backup-contents.js +241 -0
  286. package/neural-interface/public/shared/settings/settings-backup-download.js +298 -0
  287. package/neural-interface/public/shared/settings/settings-backup-encryption-pane.js +335 -0
  288. package/neural-interface/public/shared/settings/settings-backup-encryption.js +545 -0
  289. package/neural-interface/public/shared/settings/settings-browser-extension.js +54 -12
  290. package/neural-interface/public/shared/settings/settings-ia.js +1 -1
  291. package/neural-interface/public/shared/shell-stop-view.js +83 -0
  292. package/neural-interface/public/shared/skills/studio/sx-geometry.js +12 -3
  293. package/neural-interface/public/shared/skills/studio/sx-main.js +14 -7
  294. package/neural-interface/public/shared/studio-attention.js +6 -0
  295. package/neural-interface/public/shared/styles.css +341 -437
  296. package/neural-interface/public/shared/tour/tour-actor.js +14 -3
  297. package/neural-interface/public/shared/transcript-rows.js +28 -3
  298. package/neural-interface/public/shared/tray-auto-close.js +49 -6
  299. package/neural-interface/public/shared/ui-agents.js +1 -2
  300. package/neural-interface/public/shared/ui-automation-studio.js +168 -108
  301. package/neural-interface/public/shared/ui-claude-panel.js +62 -65
  302. package/neural-interface/public/shared/ui-loading.js +124 -17
  303. package/neural-interface/public/shared/ui-native-loop-router.js +52 -0
  304. package/neural-interface/public/shared/ui-navbar.js +2 -1
  305. package/neural-interface/public/shared/ui-output.js +533 -0
  306. package/neural-interface/public/shared/ui-schedules-studio.js +165 -128
  307. package/neural-interface/public/shared/ui-scroll-follow.js +101 -6
  308. package/neural-interface/public/shared/ui-sessions.js +2 -2
  309. package/neural-interface/public/shared/ui-settings-entry.js +18 -0
  310. package/neural-interface/public/shared/ui-settings.js +224 -65
  311. package/neural-interface/public/shared/ui-sidepanel-tray.js +3 -2
  312. package/neural-interface/public/shared/ui-tooltip.js +16 -0
  313. package/neural-interface/public/shared/ui-tutorial.js +5 -6
  314. package/neural-interface/public/shared/ui-worker-end.js +27 -8
  315. package/neural-interface/public/shared/worker-end.js +9 -4
  316. package/neural-interface/public/variant/2d/main.js +5 -0
  317. package/neural-interface/public/variant/3d/app.js +10 -0
  318. package/neural-interface/public/variant/3d/main.js +5 -1
  319. package/neural-interface/scripts/scratch-retention.mjs +20 -0
  320. package/neural-interface/server.js +725 -173
  321. package/npm-shrinkwrap.json +5 -5
  322. package/package.json +1 -2
  323. package/scripts/restore-data-home-from-backup.mjs +175 -8
  324. package/setup.js +18 -4
  325. package/browser-extension/content.js +0 -189
  326. package/browser-extension/engine.js +0 -508
  327. package/browser-extension/icons/icon-128.png +0 -0
  328. package/browser-extension/icons/icon-16.png +0 -0
  329. package/browser-extension/icons/icon-32.png +0 -0
  330. package/browser-extension/icons/icon-48.png +0 -0
  331. package/browser-extension/icons/status-off-16.png +0 -0
  332. package/browser-extension/icons/status-off-32.png +0 -0
  333. package/browser-extension/icons/status-off-48.png +0 -0
  334. package/browser-extension/icons/status-on-16.png +0 -0
  335. package/browser-extension/icons/status-on-32.png +0 -0
  336. package/browser-extension/icons/status-on-48.png +0 -0
  337. package/browser-extension/manifest.json +0 -56
  338. package/browser-extension/popup-strings.js +0 -250
  339. package/browser-extension/popup-view.js +0 -151
  340. package/browser-extension/popup.css +0 -166
  341. package/browser-extension/popup.html +0 -108
  342. package/browser-extension/popup.js +0 -359
  343. package/browser-extension/service-worker.js +0 -275
  344. package/browser-extension/setup-content.js +0 -36
  345. package/browser-extension/tokens.css +0 -326
@@ -5,6 +5,8 @@
5
5
  // as { providerID, modelID } so api.send() can pass it through to OpenCode.
6
6
  // ─────────────────────────────────────────────────────────────────────────────
7
7
 
8
+ import { getProviderMeta, isMaritacaModel } from '../provider-icons.js';
9
+
8
10
  import { fetchProvidersFull } from './ocp-v2-providers.js';
9
11
  import { opencodeProviders } from '../opencode-providers.js';
10
12
  import { modelRowMeta } from './ocp-v2-status-logic.js';
@@ -219,6 +221,7 @@ function applyLabelFromState() {
219
221
  }
220
222
  const label = m.modelID || '';
221
223
  _label.textContent = label || _dd?.dataset.placeholder || 'model...';
224
+ if (isMaritacaModel(m)) _label.insertAdjacentHTML('afterbegin', maritacaMark());
222
225
  _dd?.classList.add('has-value');
223
226
  }
224
227
 
@@ -615,6 +618,10 @@ function connectProviderOption() {
615
618
  return opt;
616
619
  }
617
620
 
621
+ function maritacaMark() {
622
+ return `<span class="ocpv2-model-mark" aria-hidden="true">${getProviderMeta('maritaca').icon}</span>`;
623
+ }
624
+
618
625
  function makeOption(provId, entry, currentFull, favorites) {
619
626
  const fullId = `${provId}/${entry.id}`;
620
627
  const badges = capBadgesHtml(entry._obj);
@@ -631,7 +638,7 @@ function makeOption(provId, entry, currentFull, favorites) {
631
638
  // every row maps onto the same 4-column grid (name | meta | caps | star).
632
639
  const meta = modelRowMeta(entry._obj);
633
640
  opt.innerHTML =
634
- `<span class="ocpv2-dd-model-name">${escHtml(entry.id)}</span>`
641
+ `<span class="ocpv2-dd-model-name">${isMaritacaModel(fullId) ? maritacaMark() : ''}${escHtml(entry.id)}</span>`
635
642
  + `<span class="ocpv2-dd-model-meta">${meta.status ? `<span class="ocpv2-dd-model-status">${escHtml(meta.status)}</span>` : ''}${escHtml(meta.price)}</span>`
636
643
  + `<span class="ocpv2-dd-caps">${badges}</span>`;
637
644
 
@@ -1,4 +1,6 @@
1
1
  import { syncOpenCodeWorkerQuestions, forgetWorkerQuestions } from './ocp-v2-ws.js';
2
+ import { getProviderMeta, isMaritacaModel } from '../provider-icons.js';
3
+
2
4
  import { workerRestart } from '../worker-restart.js';
3
5
  import { t } from '../i18n.js';
4
6
  import { hostedSidepanelId, sidepanelHost } from '../ui-sidepanel-runtime.js';
@@ -27,7 +29,7 @@ import {
27
29
  import {
28
30
  forkSession, undoLastTurn, restoreReverted,
29
31
  loadSelectedSession, applySessionSelections, restoreDraftAttachments,
30
- readTranscriptExport, stopForNavigation, createSessionForNavigation, renameSession,
32
+ readTranscriptExport, stopForNavigation, noteAbandoned, createSessionForNavigation, renameSession,
31
33
  navigateAfter, adoptReusableSession, landWithoutTabs, shouldNameCreatedSession, renameBox,
32
34
  } from './ocp-v2-session-actions.js';
33
35
  import { captureBinding, latestFor, createNavigation } from './ocp-v2-binding.js';
@@ -37,6 +39,7 @@ import { closeWithPromptsConfirm, prefilledDraft, samePrompts } from './ocp-v2-c
37
39
  import { setSelectOptions, projectOptionRows } from './ocp-v2-select.js';
38
40
  import { replyFailed, replyError } from './ocp-v2-caps.js';
39
41
  import { rehydratePanelSession, recoveredErrorSweep } from './ocp-v2-rehydrate.js';
42
+ import { missingLocationOf, missingPanelLocation, planLocationRecovery, sameFolder } from './ocp-v2-location-logic.js';
40
43
  import { headerStatus } from './ocp-v2-render-logic.js';
41
44
  import { runTurnLive } from '../sidepanel-session-status.js';
42
45
  import {
@@ -104,6 +107,7 @@ let _statusEl = null;
104
107
  let _titleEl = null;
105
108
  let _tabSessionIds = []; // ordered session IDs that own a tray pill
106
109
  let _tabPills = new Map(); // sessionId -> pill element
110
+ const maritacaTabs = new Set();
107
111
  let _tabInfoCache = new Map(); // sessionId -> last-known session info (title, etc.)
108
112
  const _automationRunIds = new Map(); // sessionId -> native loop runId
109
113
  // The sessions whose automation run is live. The ownership module keeps the set, so that the socket layer
@@ -140,6 +144,9 @@ let _docClickWired = false;
140
144
  let _healTimer = null;
141
145
  let _healingPromise = null;
142
146
  let _healRetryCount = 0;
147
+ // Folders OpenCode said are gone ("Location not found"), and the move away from one that is under way.
148
+ const _goneLocations = new Set();
149
+ let _locationRecovery = null;
143
150
  const _sessionTitleState = new Map(); // sessionId -> { state, title, requestId, controller }
144
151
  const _titleReassertTimers = new Map();
145
152
  // Renames whose request is out. Until the server has answered, the title a
@@ -635,7 +642,7 @@ function buildPanel() {
635
642
  (runId) => fetch('/api/loop/stop', {
636
643
  method: 'POST',
637
644
  headers: { 'Content-Type': 'application/json' },
638
- body: JSON.stringify({ runId }),
645
+ body: JSON.stringify({ runId, action: 'stop' }),
639
646
  }).catch(() => {}),
640
647
  );
641
648
  if (stopped) saveAutomationTabs();
@@ -719,10 +726,12 @@ function handleStoreEvent(event, stateSnapshot) {
719
726
  if (event?.type === 'running:set' && !nextState.running && nextState.sessionId) {
720
727
  _titleNeedsReassert(nextState.sessionId);
721
728
  }
729
+ if (event?.type === 'config:model') rememberTabBrand(nextState.sessionId, nextState.model);
722
730
  if (event?.type === 'session:info') keepOwnSessionTitle(nextState);
723
731
  if (TRANSCRIPT_EVENTS.has(event?.type)) queueHeaderSync();
724
732
  else syncHeader();
725
733
  maybeScheduleAutoHeal(event, nextState);
734
+ maybeRecoverMissingLocation(event, nextState);
726
735
  }
727
736
 
728
737
  // A message, a part or a streamed chunk changes nothing the header or the pills show (headerStatus and the tab
@@ -877,9 +886,86 @@ function isRecoverablePanelError(err) {
877
886
  const msg = String(err?.message || err?.error || err || '').trim();
878
887
  if (!msg) return true;
879
888
  if (/choose continue|question reply failed|plan action failed|could not create plan file|could not read the plan|rename failed|could not delete|could not unarchive|not queued/i.test(msg)) return false;
889
+ // A folder that is gone is not a lost connection: maybeRecoverMissingLocation moves the panel on.
890
+ if (missingLocationOf(msg)) return false;
880
891
  return /websocket|closed|disconnect|offline|reconnect|request timeout|timeout|network|failed|server|session|opencode|send|boot|no session|not connected/i.test(msg);
881
892
  }
882
893
 
894
+ // ── A session whose folder is gone ───────────────────────────────────────────
895
+ // OpenCode binds a session to the folder it was created in and refuses every
896
+ // prompt of one whose folder no longer exists ("Location not found: …"): a
897
+ // worktree that was removed, a project that was moved. Nothing repairs such a
898
+ // session, so the panel moves on by itself: a new session in the registered
899
+ // project the folder was inside (else with no project), and a notice that says
900
+ // so. The prompt that failed is back in the box by then, and the box is the
901
+ // panel's: it stays. ocp-v2-location-logic.js decides; this is the panel's own
902
+ // rebinding (repair), so a choice the user makes meanwhile still wins.
903
+ function isGoneLocation(folder) {
904
+ for (const gone of _goneLocations) if (sameFolder(gone, folder)) return true;
905
+ return false;
906
+ }
907
+
908
+ function maybeRecoverMissingLocation(event, s) {
909
+ if (event?.type !== 'error:push' || !_panelEl || _locationRecovery) return;
910
+ const last = s.errors[s.errors.length - 1];
911
+ if (!last || last.notice) return;
912
+ const missing = missingPanelLocation({
913
+ message: last.message, cwd: s.cwd || '', sessionDirectory: s.sessionInfo?.directory || '',
914
+ });
915
+ if (!missing) return;
916
+ const at = captureBinding(getDefaultStore());
917
+ _locationRecovery = recoverMissingLocation(missing, at)
918
+ .catch((err) => console.warn('[ocp-v2-panel] missing-folder recovery failed', err))
919
+ .finally(() => { _locationRecovery = null; });
920
+ }
921
+
922
+ async function recoverMissingLocation(missing, at) {
923
+ // The send that failed settles first (its text and attachments return to the box).
924
+ await new Promise((resolve) => setTimeout(resolve, 0));
925
+ const projects = await loadProjectsOnce();
926
+ // The user went somewhere else meanwhile: that choice stands.
927
+ if (!at.isCurrent()) return;
928
+ _goneLocations.add(missing);
929
+ // A folder the panel moves to may be gone as well (a registered project that was deleted): the next one, then none.
930
+ for (let attempt = 0; attempt < 4; attempt += 1) {
931
+ const plan = planLocationRecovery({ missing, cwd: getState().cwd || '', projects, avoid: [..._goneLocations] });
932
+ if (!plan) return;
933
+ const moved = await moveToFolder(plan.fallback);
934
+ if (moved.ok) {
935
+ pushError({ message: plan.notice, notice: true });
936
+ return;
937
+ }
938
+ if (!moved.missing || !sameFolder(moved.missing, plan.fallback)) {
939
+ pushError({ message: moved.error });
940
+ return;
941
+ }
942
+ _goneLocations.add(moved.missing);
943
+ }
944
+ }
945
+
946
+ // The panel on `folder` ('' for no project) with a new session, leaving the one on screen.
947
+ async function moveToFolder(folder) {
948
+ const next = String(folder || '');
949
+ const nav = _nav.repair();
950
+ setCwd(next);
951
+ if (next) storage.setItem(STOR_PROJECT, next);
952
+ else storage.removeItem(STOR_PROJECT);
953
+ if (nav.sessionId) {
954
+ nav.apply(() => {
955
+ clearMessages();
956
+ setSession(null, null);
957
+ bindPrimarySession(getDefaultStore(), null);
958
+ });
959
+ }
960
+ try {
961
+ await startFreshSession({ cwd: next || undefined, nav });
962
+ return { ok: true };
963
+ } catch (err) {
964
+ const error = err?.message || 'New session failed';
965
+ return { ok: false, error, missing: missingLocationOf(error) };
966
+ }
967
+ }
968
+
883
969
  // ── Session picker + rename ─────────────────────────────────────────────────
884
970
 
885
971
  function sessionTitleFor(stateOrSession) {
@@ -1471,7 +1557,8 @@ async function switchToSession(sid, info = null, { nav } = {}) {
1471
1557
  const dirFromInfo = info?.directory;
1472
1558
  if (dirFromInfo && dirFromInfo !== getState().cwd) {
1473
1559
  setCwd(dirFromInfo);
1474
- storage.setItem(STOR_PROJECT, dirFromInfo);
1560
+ // (Not a folder OpenCode said is gone: the next new session would start there.)
1561
+ if (!isGoneLocation(dirFromInfo)) storage.setItem(STOR_PROJECT, dirFromInfo);
1475
1562
  }
1476
1563
  });
1477
1564
  if (!bound) { ensureTab(sid, info); renderPill(); return; }
@@ -1498,8 +1585,9 @@ async function restoreSessionSelections(sid, info) {
1498
1585
  const dir = full.directory;
1499
1586
  if (dir && dir !== getState().cwd) {
1500
1587
  setCwd(dir);
1501
- storage.setItem(STOR_PROJECT, dir);
1588
+ if (!isGoneLocation(dir)) storage.setItem(STOR_PROJECT, dir);
1502
1589
  }
1590
+ rememberTabBrand(sid, full.model);
1503
1591
  applySessionSelections(getDefaultStore(), full);
1504
1592
  // Fresh metadata too: keeps the title right after a switch.
1505
1593
  getDefaultStore().setSessionInfo(full);
@@ -1625,6 +1713,10 @@ async function boot() {
1625
1713
  for (const sid of savedTabs) {
1626
1714
  const info = byId.get(sid);
1627
1715
  if (info) {
1716
+ if (info.model) {
1717
+ if (isMaritacaModel(info.model)) maritacaTabs.add(sid);
1718
+ else maritacaTabs.delete(sid);
1719
+ }
1628
1720
  liveTabs.push(sid);
1629
1721
  _tabInfoCache.set(sid, info);
1630
1722
  ensureOpenCodeTitleState(sid, info, { manual: true });
@@ -2076,8 +2168,14 @@ function deleteSessionBestEffort(sessionId, { abort = false, context = 'delete'
2076
2168
  if (!sessionId) return Promise.resolve({ ok: true });
2077
2169
  return (async () => {
2078
2170
  if (abort) {
2079
- try { await api.abort(sessionId); }
2171
+ // The tab is going: nobody is left to press Stop again, so a command Stop cannot end is given up on ("Stop
2172
+ // anyway": it is still removed in the background, and its end wakes no model turn).
2173
+ let stopped = null;
2174
+ try { stopped = await api.abort(sessionId, { force: true }); }
2080
2175
  catch (err) { console.warn(`[ocp-v2-panel] abort before ${context} failed`, err); }
2176
+ // What it gave up on may still be running: the panel, still open on another tab, says so.
2177
+ // (Best effort: the notice never holds up the deletion.)
2178
+ try { await noteAbandoned(getDefaultStore(), stopped, t); } catch { /* the close goes on */ }
2081
2179
  }
2082
2180
  let res;
2083
2181
  try { res = await api.sessionDelete(sessionId); }
@@ -2152,7 +2250,9 @@ function loadTabSessions() {
2152
2250
  try {
2153
2251
  const raw = storage.getItem(STOR_TABS);
2154
2252
  if (!raw) return [];
2155
- return readSavedTabs(JSON.parse(raw))
2253
+ const tabs = readSavedTabs(JSON.parse(raw));
2254
+ for (const tab of tabs) if (tab.modelBrand === 'maritaca') maritacaTabs.add(tab.sessionId);
2255
+ return tabs
2156
2256
  .map(({ sessionId }) => sessionId)
2157
2257
  .filter((sessionId) => !_foreignActiveAutomationSessions.has(sessionId));
2158
2258
  } catch { return []; }
@@ -2169,7 +2269,7 @@ function saveTabSessions() {
2169
2269
  .map((row) => row.sessionId));
2170
2270
  const preserved = existing.filter(({ sessionId }) => foreignSessionIds.has(sessionId) && !_tabSessionIds.includes(sessionId));
2171
2271
  const tabs = _tabSessionIds.map((sessionId) => ({
2172
- ...savedById.get(sessionId), sessionId, needsYou: tabNeedsYou(sessionId),
2272
+ ...savedById.get(sessionId), sessionId, modelBrand: maritacaTabs.has(sessionId) ? 'maritaca' : undefined, needsYou: tabNeedsYou(sessionId),
2173
2273
  }));
2174
2274
  storage.setItem(STOR_TABS, JSON.stringify([...tabs, ...preserved]));
2175
2275
  _savedTabWaiting = new Map(tabs.map(({ sessionId, needsYou }) => [sessionId, needsYou]));
@@ -2198,10 +2298,20 @@ function syncSavedTabWaiting() {
2198
2298
  if (_tabSessionIds.some((sid) => _savedTabWaiting.get(sid) !== tabNeedsYou(sid))) saveTabSessions();
2199
2299
  }
2200
2300
 
2301
+ function rememberTabBrand(sessionId, model) {
2302
+ if (!sessionId || !model) return;
2303
+ const maritaca = isMaritacaModel(model);
2304
+ if (maritaca === maritacaTabs.has(sessionId)) return;
2305
+ if (maritaca) maritacaTabs.add(sessionId);
2306
+ else maritacaTabs.delete(sessionId);
2307
+ if (_tabSessionIds.includes(sessionId)) saveTabSessions();
2308
+ }
2309
+
2201
2310
  function ensureTab(sessionId, info = null) {
2202
2311
  if (!sessionId) return;
2203
2312
  if (info) _tabInfoCache.set(sessionId, info);
2204
2313
  if (!_tabSessionIds.includes(sessionId)) {
2314
+ rememberTabBrand(sessionId, info?.model || (sessionId === getState().sessionId && getState().model));
2205
2315
  _tabSessionIds.push(sessionId);
2206
2316
  saveTabSessions();
2207
2317
  }
@@ -2216,7 +2326,7 @@ function dismissAutomationSession(sessionId) {
2216
2326
  endWorkerRunOnClose(runId, () => fetch('/api/loop/stop', {
2217
2327
  method: 'POST',
2218
2328
  headers: { 'Content-Type': 'application/json' },
2219
- body: JSON.stringify({ runId }),
2329
+ body: JSON.stringify({ runId, action: 'tab_close' }),
2220
2330
  }).catch(() => {}));
2221
2331
  }
2222
2332
  return true;
@@ -2285,6 +2395,7 @@ function removeTab(sessionId, { byUser = false } = {}) {
2285
2395
  _tabSessionIds = _tabSessionIds.filter((s) => s !== sessionId);
2286
2396
  if (_tabSessionIds.length !== before) saveTabSessions();
2287
2397
  _tabInfoCache.delete(sessionId);
2398
+ maritacaTabs.delete(sessionId);
2288
2399
  const titleState = _sessionTitleState.get(sessionId);
2289
2400
  titleState?.controller?.abort();
2290
2401
  _sessionTitleState.delete(sessionId);
@@ -2326,6 +2437,9 @@ function createTabPill(sessionId) {
2326
2437
  pill.className = 'term-minimized-pill ocpv2-session-pill';
2327
2438
  pill.dataset.owner = PANEL_OWNER;
2328
2439
  pill.dataset.sessionId = sessionId;
2440
+ pill.getAutomationRunId = () => _automationRunIds.get(sessionId);
2441
+ pill.hasQueuedWorkerPrompts = () => _automationRunIds.has(sessionId) && promptsWaitingFor(sessionId).length > 0;
2442
+ pill.detachForAutoClose = () => detachTabForAutoClose(sessionId);
2329
2443
  pill.innerHTML = `
2330
2444
  <span class="ocpv2-pill-ring" aria-hidden="true"><i></i></span>
2331
2445
  <span class="term-minimized-pill-icon">${OPENCODE_ICON}</span>
@@ -2363,6 +2477,20 @@ async function closeTabByUser(sessionId, context, { deleteBeforeClose = false }
2363
2477
  return true;
2364
2478
  }
2365
2479
 
2480
+ // The tray's auto-close toggle, for a session that names no run. Unlike the X,
2481
+ // which deletes the session, this only takes the tab and its pill away: the
2482
+ // session and its transcript stay in OpenCode and the session menu opens them
2483
+ // again. Nobody chose this close, so nobody is asked: a turn that started or a
2484
+ // prompt still waiting keeps the tab. Resolves whether the tab went.
2485
+ async function detachTabForAutoClose(sessionId) {
2486
+ const working = sessionId === getState().sessionId ? !!getState().running : _sessionBusy.get(sessionId) === true;
2487
+ if (!_tabSessionIds.includes(sessionId) || _automationRunIds.has(sessionId) || working
2488
+ || promptsWaitingFor(sessionId).length) return false;
2489
+ try { await handlePillClose(sessionId); }
2490
+ catch (err) { console.warn('[ocp-v2-panel] auto-close detach failed', err); }
2491
+ return true;
2492
+ }
2493
+
2366
2494
  // The end of a worker the Assistant dispatched: its button closes the tab the
2367
2495
  // way the tab's X does (a warm worker that finished its task is completed, one
2368
2496
  // still at work is stopped; its record stays for the Assistant) and shows the
@@ -2425,6 +2553,11 @@ function renderPill() {
2425
2553
  if (!pill) continue;
2426
2554
  _tabPills.set(sid, pill);
2427
2555
  }
2556
+ const brand = maritacaTabs.has(sid) ? 'maritaca' : 'opencode';
2557
+ if (pill.dataset.modelBrand !== brand) {
2558
+ pill.querySelector('.term-minimized-pill-icon').innerHTML = brand === 'maritaca' ? getProviderMeta(brand).icon : OPENCODE_ICON;
2559
+ pill.dataset.modelBrand = brand;
2560
+ }
2428
2561
  const labelEl = pill.querySelector('.term-minimized-pill-label');
2429
2562
  // Written only when it changed: the same text again is still a new text node, which the tray's
2430
2563
  // observer (ui-navbar.js) answers by going through every pill.
@@ -2664,6 +2797,17 @@ export async function attachOpenCodeAutomation(run, { focus = !!run?.focus, isCa
2664
2797
  _tabInfoCache.set(sessionId, cachedInfo);
2665
2798
  pushError({ message: run.error });
2666
2799
  }
2800
+ // A stop of the run (a worker's, a loop's) that could not end a command in the background: it may still be
2801
+ // running, and the tab says so once (lib/native-loop-runtime.js abandonedCommands; the words are the panel Stop's).
2802
+ if (Array.isArray(run.abandonedCommands) && run.abandonedCommands.length && getState().sessionId === sessionId
2803
+ && !_tabInfoCache.get(sessionId)?._automationAbandonedShown) {
2804
+ const cachedInfo = _tabInfoCache.get(sessionId) || info;
2805
+ cachedInfo._automationAbandonedShown = true;
2806
+ _tabInfoCache.set(sessionId, cachedInfo);
2807
+ const view = await import('../shell-stop-view.js').catch(() => null);
2808
+ const left = view?.describeAbandoned(run.abandonedCommands, t) || null;
2809
+ if (left) pushError({ message: left, kind: 'shell-stop', notice: true });
2810
+ }
2667
2811
  trackWorkerEnd(run, { apply: (view) => showWorkerEnd(sessionId, view) });
2668
2812
  renderPill();
2669
2813
  syncSavedTabWaiting();
@@ -155,7 +155,7 @@ function bindingCheck(store, sessionId, isCurrent) {
155
155
  * that was closed meanwhile. Resolves what it applied, for the caller's log.
156
156
  */
157
157
  export async function rehydrateSessionState(store, api, { sessionId, cwd, hasPanel, isDescendant, isCurrent } = {}) {
158
- const applied = { status: false, permissions: false, questions: false, todos: false };
158
+ const applied = { status: false, permissions: false, questions: false, todos: false, shells: false };
159
159
  if (!sessionId) return applied;
160
160
  const stillBound = bindingCheck(store, sessionId, isCurrent);
161
161
  const revisionOf = (slice) => (typeof store.getRevisions === 'function' ? store.getRevisions()[slice] : 0);
@@ -200,6 +200,12 @@ export async function rehydrateSessionState(store, api, { sessionId, cwd, hasPan
200
200
  () => (api.sessionTodo ? api.sessionTodo({ sessionId, cwd }) : { ok: false }),
201
201
  (res) => (Array.isArray(res.data) ? res.data : undefined),
202
202
  (todos) => store.setTodos(todos)),
203
+ // The commands of the session's tool calls: one that still runs (also after
204
+ // its call ended) is followed again, with its output, from where it is now.
205
+ sync('shells',
206
+ () => (api.shellList && typeof store.setShells === 'function' ? api.shellList({ sessionId, cwd }) : { ok: false }),
207
+ (res) => (Array.isArray(res.data) ? res.data : undefined),
208
+ (shells) => store.setShells(shells)),
203
209
  ]);
204
210
  return applied;
205
211
  }
@@ -9,6 +9,8 @@
9
9
  // shared allowlist sanitizer before it reaches innerHTML.
10
10
  // ─────────────────────────────────────────────────────────────────────────────
11
11
 
12
+ import { getProviderMeta, isMaritacaModel } from '../provider-icons.js';
13
+
12
14
  import { getDefaultStore } from './ocp-v2-state.js';
13
15
  import { hasWorkerQuestions, api, supports, isDescendantSession, isKnownDescendantSession, onEvent } from './ocp-v2-ws.js';
14
16
  import {
@@ -25,7 +27,9 @@ import { messageMetaText } from './ocp-v2-tools-logic.js';
25
27
  import { createStickyScrollController } from '../ui-scroll-follow.js';
26
28
  import { watchTranscriptRows } from '../transcript-rows.js';
27
29
  import { sanitizeHtmlString } from '../assistant/asst-sanitize.js';
30
+ import { sanitizeStoredHtml } from '../assistant/asst-sanitize.js';
28
31
  import { withCodeCopyButtons } from '../code-copy.js';
32
+ import { withOutputFrames } from '../output-format.js';
29
33
  import { openProviderSettings } from './ocp-v2-settings-link.js';
30
34
  import {
31
35
  visibleParts, partSignature, messageErrorView, retryBannerView, retryPartText,
@@ -38,6 +42,7 @@ import {
38
42
  revertToMessage, restoreReverted, retryFromMessage, forkSession,
39
43
  } from './ocp-v2-session-actions.js';
40
44
  import { synabunToolKey, synabunToolLabel, synabunToolSummary } from '../synabun-tools.js';
45
+ import { renderShellTerminal, retainShellFollowing, shellOutputSupported } from './ocp-v2-shell.js';
41
46
 
42
47
  const _expandedReasoningIds = new Set();
43
48
  const _activeRenderers = new Set();
@@ -102,17 +107,33 @@ export function mountRenderer(containerEl, store = getDefaultStore(), opts = {})
102
107
  });
103
108
  };
104
109
 
110
+ let _lastSessionId = store.getState().sessionId;
105
111
  const unsubscribe = store.subscribe((event, state) => {
112
+ // Switching to another session in the same container restores bottom-follow intent
113
+ // and cancels any queued scroll frame from the session being left.
114
+ if (event?.type === 'session:set' && event.sessionId !== _lastSessionId) {
115
+ _lastSessionId = event.sessionId;
116
+ scrollController?.setFollowing(true);
117
+ }
106
118
  // The server listed this session's open permission requests: a reason
107
119
  // typed for one that is no longer among them has no card to come back to.
108
120
  if (event?.type === 'permission:set' && event.listed) settlePermissionReasons(state);
121
+ // What a command printed is drawn by its own terminal block (ocp-v2-shell.js): no card is built again for
122
+ // it. The transcript only keeps its place at the end while the block grows.
123
+ if (event?.type === 'shell:output') {
124
+ requestAnimationFrame(() => { if (_container) scrollController?.scrollToBottom(); });
125
+ return;
126
+ }
109
127
  scheduleRender();
110
128
  });
129
+ // The commands of this panel's session are followed for as long as it is on screen.
130
+ const releaseShells = retainShellFollowing(store);
111
131
 
112
132
  const instance = {
113
133
  render: doRender,
114
134
  unmount: () => {
115
135
  try { unsubscribe(); } catch {}
136
+ try { releaseShells(); } catch {}
116
137
  scrollController?.destroy();
117
138
  rowWatcher.disconnect();
118
139
  _activeRenderers.delete(instance);
@@ -144,6 +165,18 @@ function _partSig(part) {
144
165
  return sig;
145
166
  }
146
167
 
168
+ // A bash card also shows its command as the panel knows it live (running on after the call, ended, its exit
169
+ // code): the card is built again when that changes, never for what the command prints.
170
+ function _shellOf(part, state) {
171
+ if (part?.type !== 'tool') return null;
172
+ const shellId = part.state?.metadata?.shellID;
173
+ return typeof shellId === 'string' && shellId ? state.shells?.get(shellId) || null : null;
174
+ }
175
+ function _shellSig(part, state) {
176
+ const shell = _shellOf(part, state);
177
+ return shell ? `|sh:${shell.status}:${shell.background ? 'b' : ''}:${shell.exit ?? ''}:${shellOutputSupported() ? 'l' : ''}` : '';
178
+ }
179
+
147
180
  function _msgSig(msg) {
148
181
  let sig = `m:${msg.role || 'assistant'}`;
149
182
  for (const part of visibleParts(msg)) sig += '|' + _partSig(part);
@@ -201,9 +234,20 @@ function _reconcile(container, desired) {
201
234
  }
202
235
  }
203
236
 
204
- function _buildEmpty() {
237
+ function _buildEmpty(maritaca) {
205
238
  const empty = document.createElement('div');
206
239
  empty.className = 'ocpv2-empty ocpv2-empty-brand';
240
+ if (maritaca) {
241
+ // The mark is inline SVG, which the Markdown list flattens: the stored-markup list keeps its shapes.
242
+ const logo = sanitizeStoredHtml(getProviderMeta('maritaca').icon).firstElementChild;
243
+ logo.classList.add('ocpv2-empty-logo');
244
+ logo.setAttribute('aria-hidden', 'true');
245
+ const name = document.createElement('div');
246
+ name.className = 'ocpv2-empty-name';
247
+ name.textContent = 'Maritaca';
248
+ empty.append(logo, name);
249
+ return empty;
250
+ }
207
251
  empty.innerHTML =
208
252
  '<svg class="ocpv2-empty-logo" viewBox="0 0 240 300" fill="currentColor" aria-hidden="true">'
209
253
  + '<path fill-rule="evenodd" d="M0 0h240v300H0V0zm30 30v240h180V30H30z"/>'
@@ -235,7 +279,8 @@ function render(_container, store, opts = {}) {
235
279
  const endCard = typeof opts.endCard === 'function' ? opts.endCard(s) : null;
236
280
  const hasInteractiveCards = permissions.length > 0 || questions.length > 0 || !!s.showPostPlanActions || !!endCard;
237
281
  if (s.messageOrder.length === 0 && !hasInteractiveCards && !s.errors.length && !retry && !revertBanner) {
238
- _reconcile(_container, [{ key: '__empty__', sig: 'empty', build: _buildEmpty }]);
282
+ const maritaca = isMaritacaModel(s.model || s.sessionInfo?.model);
283
+ _reconcile(_container, [{ key: '__empty__', sig: maritaca ? 'maritaca' : 'empty', build: () => _buildEmpty(maritaca) }]);
239
284
  // The panel may put SynaBun's greeting in it (ocp-v2-greeting.js).
240
285
  try { opts.onEmpty?.(_container.querySelector(':scope > .ocpv2-empty'), s); } catch { /* the empty state stands on its own */ }
241
286
  return;
@@ -276,7 +321,7 @@ function render(_container, store, opts = {}) {
276
321
  const partKey = part.id || `${part.type}:${part.index ?? ''}`;
277
322
  desired.push({
278
323
  key: `a:${msg.id}:${partKey}`,
279
- sig: `${isContinuation ? 'c' : 'h'}|${msg.info?.summary ? 's' : ''}|${_partSig(part)}`,
324
+ sig: `${isContinuation ? 'c' : 'h'}|${msg.info?.summary ? 's' : ''}|${_partSig(part)}${_shellSig(part, s)}`,
280
325
  build: () => renderAssistantPartBubble(msg, part, isContinuation, store),
281
326
  });
282
327
  prevAssistantId = msg.id;
@@ -989,6 +1034,9 @@ function renderToolPart(part, store) {
989
1034
  return holder;
990
1035
  },
991
1036
  onOpenChild: _rendererOpts.get(store)?.onOpenChild || null,
1037
+ shell: _shellOf(part, store.getState()),
1038
+ // An older server cannot be asked for a command's output: the card shows what the call returned.
1039
+ terminal: shellOutputSupported() ? (shellId) => renderShellTerminal(store, shellId) : null,
992
1040
  });
993
1041
  }
994
1042
 
@@ -1779,7 +1827,8 @@ function renderMarkdown(src) {
1779
1827
  html = escapeHtml(text).replace(/\n/g, '<br>');
1780
1828
  }
1781
1829
  // Every code block gets the shared Copy button, written in after the sanitiser (../code-copy.js).
1782
- const shown = withCodeCopyButtons(html);
1830
+ // And the reading layer all six panels share: a table's frame, task items, a block's language, a diff's lines.
1831
+ const shown = withOutputFrames(withCodeCopyButtons(html));
1783
1832
  if (_markdownCache.size >= _markdownCacheLimit) {
1784
1833
  // Evict oldest insertion (Map preserves insertion order)
1785
1834
  const firstKey = _markdownCache.keys().next().value;
@@ -6,6 +6,8 @@
6
6
  // instance for back-compat with shared bindings.
7
7
  // ─────────────────────────────────────────────────────────────────────────────
8
8
 
9
+ import { getProviderMeta, isMaritacaModel } from '../provider-icons.js';
10
+
9
11
  import { api, supports, capabilities, onEvent, sessionWaitsOnUser, onAsksChanged } from './ocp-v2-ws.js';
10
12
  import { getDefaultStore, agentForMode } from './ocp-v2-state.js';
11
13
  import { mountModelPicker } from './ocp-v2-modelpicker.js';
@@ -35,6 +37,7 @@ import {
35
37
  import { hydrateTranscript } from './ocp-v2-rehydrate.js';
36
38
  import { captureBinding, trackBinding, isBindingToken, searchOnBinding } from './ocp-v2-binding.js';
37
39
  import { takeGreetingId } from './ocp-v2-greeting.js';
40
+ import { t } from '../i18n.js';
38
41
 
39
42
  const STOR_MODE = 'opencode-v2-mode'; // the last agent picked (build / plan / a custom one)
40
43
  const STOR_HISTORY = 'ocp-v2-prompt-history';
@@ -302,7 +305,18 @@ export function mountCompose(rootEl, store = getDefaultStore(), opts = {}) {
302
305
  _modelPicker = mountModelPicker(footerRight, store);
303
306
  }
304
307
 
308
+ const brandLink = toolbar.querySelector('.ocpv2-brand-link');
309
+ const openCodeMark = brandLink.innerHTML;
310
+ function syncBrand(model) {
311
+ const maritaca = isMaritacaModel(model);
312
+ brandLink.innerHTML = maritaca ? getProviderMeta('maritaca').icon : openCodeMark;
313
+ brandLink.href = maritaca ? 'https://www.maritaca.ai' : 'https://opencode.ai';
314
+ brandLink.dataset.tooltip = maritaca ? 'Maritaca' : 'OpenCode';
315
+ brandLink.setAttribute('aria-label', brandLink.dataset.tooltip);
316
+ }
317
+ syncBrand(store.getState().model || store.getState().sessionInfo?.model);
305
318
  const unsubscribe = store.subscribe((event, state) => {
319
+ if (event?.type === 'config:model' || event?.type === 'session:info') syncBrand(state.model || state.sessionInfo?.model);
306
320
  // First of all: the panel was bound to another session. What belonged to
307
321
  // the binding it left goes before anything below looks at the new one.
308
322
  if (_rebind.changed()) onRebound(state);
@@ -1551,11 +1565,16 @@ export function mountCompose(rootEl, store = getDefaultStore(), opts = {}) {
1551
1565
  const unsubInner = store.subscribe((event, state) => {
1552
1566
  if ((event?.type === 'running:set' && !state.running) || !turn.isCurrent()) cleanup();
1553
1567
  });
1554
- // Working time only: the clock stops while the session waits on the user (a permission, a question).
1568
+ // Working time only: the clock stops while the session waits on the user (a permission, a question) or on
1569
+ // a command of its own still running in the background (a long test run: `sessionStatus.background`).
1555
1570
  clock = createTurnClock({
1556
1571
  ms: TURN_LIMIT_MS,
1557
- paused: () => sessionWaitsOnUser(turn.sessionId),
1558
- subscribe: onAsksChanged,
1572
+ paused: () => sessionWaitsOnUser(turn.sessionId) || (turn.isCurrent() && store.getState().sessionStatus?.background === true),
1573
+ subscribe: (changed) => {
1574
+ const offAsks = onAsksChanged(changed);
1575
+ const offStatus = store.subscribe((event) => { if (event?.type === 'status:set') changed(); });
1576
+ return () => { try { offAsks?.(); } catch { /* gone */ } offStatus(); };
1577
+ },
1559
1578
  onExpire: () => {
1560
1579
  if (run.isCurrent()) store.pushError({ message: 'OpenCode turn timed out waiting for session.idle.' });
1561
1580
  endTurn(store, run);
@@ -1567,7 +1586,7 @@ export function mountCompose(rootEl, store = getDefaultStore(), opts = {}) {
1567
1586
  });
1568
1587
  }
1569
1588
 
1570
- async function doAbort() {
1589
+ async function doAbort({ force = false } = {}) {
1571
1590
  // `turn` is the session Stop was pressed in, and the turn that was running
1572
1591
  // there. The loop-stop request and the abort are for that session; what is
1573
1592
  // cleared afterwards is cleared only while the panel is still on that
@@ -1587,15 +1606,42 @@ export function mountCompose(rootEl, store = getDefaultStore(), opts = {}) {
1587
1606
  }
1588
1607
  _suppressAbortErrorUntil = Date.now() + 15000;
1589
1608
  _suppressAbortErrorCount += 1;
1609
+ let stopped = null;
1590
1610
  try {
1591
- await api.abort(turn.sessionId);
1611
+ stopped = await api.abort(turn.sessionId, force ? { force: true } : undefined);
1592
1612
  } catch (err) {
1593
1613
  console.warn('[ocp-v2-send] abort failed', err);
1594
1614
  } finally {
1595
- clearStoppedTurn();
1615
+ // The banner of an earlier failed Stop of this session goes: this answer says what holds now.
1616
+ if (turn.isCurrent()) dismissStopNotices();
1617
+ // Its words are loaded only when a Stop has something to say (not before the app is shown).
1618
+ const view = (stopped?.code === 'SHELL_STOP_FAILED' || stopped?.abandoned?.length) ? await import('../shell-stop-view.js').catch(() => null) : null;
1619
+ const failure = view?.describeStopFailure(stopped, t) || null;
1620
+ if (stopped?.code === 'SHELL_STOP_FAILED') {
1621
+ // A command Stop could not end still runs: the turn stays on (its Stop button too), and the panel says which
1622
+ // and why. No "aborted" send failure follows (the prompt's wait goes on), so none is held back for it.
1623
+ _suppressAbortErrorCount = Math.max(0, _suppressAbortErrorCount - 1);
1624
+ if (turn.isCurrent()) {
1625
+ store.pushError({
1626
+ message: failure?.message || stopped.error || 'Stop could not end a command still running in the background. Press Stop again.',
1627
+ kind: STOP_NOTICE,
1628
+ // From the second failure on: end the turn here, telling plainly what may still run.
1629
+ ...(failure?.canForce ? { actions: [{ label: view.shellStopText('anyway', {}, t), run: () => { doAbort({ force: true }).catch(() => {}); } }] } : {}),
1630
+ });
1631
+ }
1632
+ } else {
1633
+ clearStoppedTurn();
1634
+ const left = view?.describeAbandoned(stopped?.abandoned, t) || null;
1635
+ if (left && turn.isCurrent()) store.pushError({ message: left, kind: STOP_NOTICE, notice: true });
1636
+ }
1596
1637
  }
1597
1638
  }
1598
1639
 
1640
+ const STOP_NOTICE = 'shell-stop';
1641
+ function dismissStopNotices() {
1642
+ for (const err of store.getState().errors || []) if (err?.kind === STOP_NOTICE && err.id) store.dismissError(err.id);
1643
+ }
1644
+
1599
1645
  function shouldSuppressAbortError(err) {
1600
1646
  if (_suppressAbortErrorCount <= 0) return false;
1601
1647
  if (Date.now() > _suppressAbortErrorUntil) return false;
@@ -252,11 +252,30 @@ export async function loadSelectedSession(store, api, sessionId, info, apply) {
252
252
  */
253
253
  export async function stopForNavigation(store, api, nav) {
254
254
  if (nav.sessionId && nav.isCurrent() && store.getState().running) {
255
- try { await api.abort(nav.sessionId); } catch (err) { console.warn('[ocp-v2-session-actions] abort before navigation failed', err); }
255
+ // The panel leaves this session: a command Stop cannot end is given up on, as on a tab's close (Stop anyway).
256
+ let stopped = null;
257
+ try { stopped = await api.abort(nav.sessionId, { force: true }); } catch (err) { console.warn('[ocp-v2-session-actions] abort before navigation failed', err); }
258
+ // What it gave up on may still be running: the panel's next view says so (a notice outlives the clear).
259
+ await noteAbandoned(store, stopped);
256
260
  }
257
261
  return nav.isCurrent();
258
262
  }
259
263
 
264
+ /**
265
+ * A forced Stop's answer that left commands running (`abandoned`): one notice in the panel, in the words of the
266
+ * panel's own Stop anyway (shell-stop-view.js, loaded only then). Nothing for any other answer.
267
+ */
268
+ export async function noteAbandoned(store, stopped, translate = null) {
269
+ if (!Array.isArray(stopped?.abandoned) || !stopped.abandoned.length) return false;
270
+ const view = await import('../shell-stop-view.js').catch(() => null);
271
+ let tr = translate;
272
+ if (!tr) { try { tr = (await import('../i18n.js')).t; } catch { tr = null; } }
273
+ const message = view?.describeAbandoned(stopped.abandoned, tr) || null;
274
+ if (!message) return false;
275
+ store.pushError({ message, kind: 'shell-stop', notice: true });
276
+ return true;
277
+ }
278
+
260
279
  /**
261
280
  * Create the session of a navigation. Resolves `{ session, activate }`:
262
281
  * `activate` is false when the panel was rebound while the session was being
@@ -268,7 +287,8 @@ export async function createSessionForNavigation(store, api, { title, cwd, nav }
268
287
  const at = isBindingToken(nav) ? nav : captureBinding(store);
269
288
  const res = await api.sessionCreate(title ? { title } : {}, cwd);
270
289
  const session = res?.data;
271
- if (!session?.id) throw new Error('session create returned no id');
290
+ // A refusal says why (a folder that does not exist: "Location not found: …", which the panel recovers from).
291
+ if (!session?.id) throw new Error(replyFailed(res) ? replyError(res, 'session create returned no id') : 'session create returned no id');
272
292
  return { session, activate: at.isCurrent() };
273
293
  }
274
294