synabun 2.4.3 → 2.4.4

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 (153) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +1 -1
  3. package/docs/browser-extension-bridge.md +61 -32
  4. package/mcp-server/dist/http.d.ts.map +1 -1
  5. package/mcp-server/dist/http.js +8 -1
  6. package/mcp-server/dist/http.js.map +1 -1
  7. package/mcp-server/dist/services/identity.d.ts +2 -0
  8. package/mcp-server/dist/services/identity.d.ts.map +1 -1
  9. package/mcp-server/dist/services/identity.js +4 -0
  10. package/mcp-server/dist/services/identity.js.map +1 -1
  11. package/mcp-server/dist/services/memory-client.d.ts +5 -0
  12. package/mcp-server/dist/services/memory-client.d.ts.map +1 -1
  13. package/mcp-server/dist/services/memory-client.js +21 -2
  14. package/mcp-server/dist/services/memory-client.js.map +1 -1
  15. package/mcp-server/dist/services/memory-writer.d.ts +3 -0
  16. package/mcp-server/dist/services/memory-writer.d.ts.map +1 -1
  17. package/mcp-server/dist/services/memory-writer.js +7 -1
  18. package/mcp-server/dist/services/memory-writer.js.map +1 -1
  19. package/mcp-server/dist/services/neural-interface.d.ts +11 -1
  20. package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
  21. package/mcp-server/dist/services/neural-interface.js +67 -17
  22. package/mcp-server/dist/services/neural-interface.js.map +1 -1
  23. package/mcp-server/dist/services/typesafe-config.d.ts +38 -2
  24. package/mcp-server/dist/services/typesafe-config.d.ts.map +1 -1
  25. package/mcp-server/dist/services/typesafe-config.js +260 -8
  26. package/mcp-server/dist/services/typesafe-config.js.map +1 -1
  27. package/mcp-server/dist/tools/agent-definition.d.ts +2 -2
  28. package/mcp-server/dist/tools/agents.d.ts +3 -1
  29. package/mcp-server/dist/tools/agents.d.ts.map +1 -1
  30. package/mcp-server/dist/tools/agents.js +11 -6
  31. package/mcp-server/dist/tools/agents.js.map +1 -1
  32. package/mcp-server/dist/tools/browser-observe.d.ts +11 -0
  33. package/mcp-server/dist/tools/browser-observe.d.ts.map +1 -1
  34. package/mcp-server/dist/tools/browser-observe.js +113 -27
  35. package/mcp-server/dist/tools/browser-observe.js.map +1 -1
  36. package/mcp-server/dist/tools/browser-readers.d.ts +6 -0
  37. package/mcp-server/dist/tools/browser-readers.d.ts.map +1 -0
  38. package/mcp-server/dist/tools/browser-readers.js +17 -0
  39. package/mcp-server/dist/tools/browser-readers.js.map +1 -0
  40. package/mcp-server/dist/tools/remember.d.ts.map +1 -1
  41. package/mcp-server/dist/tools/remember.js +6 -2
  42. package/mcp-server/dist/tools/remember.js.map +1 -1
  43. package/mcp-server/dist/tools/youtube/analytics.d.ts +4 -0
  44. package/mcp-server/dist/tools/youtube/analytics.d.ts.map +1 -1
  45. package/mcp-server/dist/tools/youtube/analytics.js +25 -20
  46. package/mcp-server/dist/tools/youtube/analytics.js.map +1 -1
  47. package/mcp-server/dist/tools/youtube/helpers.d.ts +5 -1
  48. package/mcp-server/dist/tools/youtube/helpers.d.ts.map +1 -1
  49. package/mcp-server/dist/tools/youtube/helpers.js +7 -3
  50. package/mcp-server/dist/tools/youtube/helpers.js.map +1 -1
  51. package/mcp-server/dist/tools/youtube/navigate.d.ts +2 -0
  52. package/mcp-server/dist/tools/youtube/navigate.d.ts.map +1 -1
  53. package/mcp-server/dist/tools/youtube/navigate.js +5 -3
  54. package/mcp-server/dist/tools/youtube/navigate.js.map +1 -1
  55. package/mcp-server/dist/tools/youtube/playlist.js +2 -2
  56. package/mcp-server/dist/tools/youtube/playlist.js.map +1 -1
  57. package/mcp-server/dist/tools/youtube/readers.d.ts +4 -0
  58. package/mcp-server/dist/tools/youtube/readers.d.ts.map +1 -0
  59. package/mcp-server/dist/tools/youtube/readers.js +15 -0
  60. package/mcp-server/dist/tools/youtube/readers.js.map +1 -0
  61. package/mcp-server/package-lock.json +2 -2
  62. package/mcp-server/package.json +1 -1
  63. package/mcp-server/src/http.ts +8 -1
  64. package/mcp-server/src/services/identity.ts +5 -0
  65. package/mcp-server/src/services/memory-client.ts +32 -12
  66. package/mcp-server/src/services/memory-writer.ts +5 -2
  67. package/mcp-server/src/services/neural-interface.ts +65 -18
  68. package/mcp-server/src/services/typesafe-config.ts +268 -7
  69. package/mcp-server/src/tools/agents.ts +12 -6
  70. package/mcp-server/src/tools/browser-observe.ts +117 -28
  71. package/mcp-server/src/tools/browser-readers.ts +19 -0
  72. package/mcp-server/src/tools/remember.ts +6 -1
  73. package/mcp-server/src/tools/youtube/analytics.ts +26 -28
  74. package/mcp-server/src/tools/youtube/helpers.ts +8 -2
  75. package/mcp-server/src/tools/youtube/navigate.ts +6 -7
  76. package/mcp-server/src/tools/youtube/playlist.ts +2 -2
  77. package/mcp-server/src/tools/youtube/readers.ts +15 -0
  78. package/neural-interface/i18n/en.json +139 -0
  79. package/neural-interface/i18n/pt-BR.json +139 -0
  80. package/neural-interface/lib/assistant-api.js +90 -0
  81. package/neural-interface/lib/assistant-brains/claude.js +10 -0
  82. package/neural-interface/lib/assistant-dispatch.js +276 -42
  83. package/neural-interface/lib/assistant-memory.js +3 -1
  84. package/neural-interface/lib/assistant-persona.js +6 -0
  85. package/neural-interface/lib/assistant-router.js +18 -8
  86. package/neural-interface/lib/assistant-runtime.js +87 -1
  87. package/neural-interface/lib/assistant-task-prompt.js +15 -2
  88. package/neural-interface/lib/browser-connection-state.js +20 -0
  89. package/neural-interface/lib/browser-extension-adapter.js +221 -15
  90. package/neural-interface/lib/browser-extension-bridge.js +40 -7
  91. package/neural-interface/lib/browser-extension-folder.js +50 -11
  92. package/neural-interface/lib/browser-extension-package.js +6 -5
  93. package/neural-interface/lib/browser-extension-pin.json +15 -13
  94. package/neural-interface/lib/browser-extension-protocol.js +111 -13
  95. package/neural-interface/lib/browser-extension-setup.js +7 -5
  96. package/neural-interface/lib/browser-extension-update.js +104 -0
  97. package/neural-interface/lib/browser-extraction.js +38 -14
  98. package/neural-interface/lib/claude-bg-tasks.js +183 -0
  99. package/neural-interface/lib/claude-history.js +12 -1
  100. package/neural-interface/lib/confined-fs.js +25 -0
  101. package/neural-interface/lib/coordination/operations.js +2 -0
  102. package/neural-interface/lib/db.js +39 -16
  103. package/neural-interface/lib/editor-completion-opencode.js +2 -2
  104. package/neural-interface/lib/git-bash/manager.js +28 -3
  105. package/neural-interface/lib/git-status-runner.js +31 -3
  106. package/neural-interface/lib/loop-inventory.js +162 -0
  107. package/neural-interface/lib/loop-stall.js +74 -4
  108. package/neural-interface/lib/memory-session-capture.js +157 -66
  109. package/neural-interface/lib/native-loop-providers.js +73 -13
  110. package/neural-interface/lib/native-loop-runtime.js +3 -0
  111. package/neural-interface/lib/opencode-protocol.js +4 -2
  112. package/neural-interface/lib/peer-identity.js +62 -16
  113. package/neural-interface/lib/session-cache-builder.js +66 -18
  114. package/neural-interface/lib/session-capture-gate.js +42 -0
  115. package/neural-interface/lib/session-indexer.js +28 -20
  116. package/neural-interface/lib/teams/scheduler.js +3 -2
  117. package/neural-interface/lib/ui-blob-api.js +14 -5
  118. package/neural-interface/lib/ui-blob-store.js +302 -39
  119. package/neural-interface/package-lock.json +2 -2
  120. package/neural-interface/package.json +1 -1
  121. package/neural-interface/public/extension-setup.html +1 -0
  122. package/neural-interface/public/shared/assistant/asst-agents-dock.js +4 -0
  123. package/neural-interface/public/shared/assistant/asst-api.js +42 -0
  124. package/neural-interface/public/shared/assistant/asst-composer.js +85 -12
  125. package/neural-interface/public/shared/assistant/asst-panel.js +285 -10
  126. package/neural-interface/public/shared/assistant/asst-render.js +205 -4
  127. package/neural-interface/public/shared/assistant/asst-scenes.js +12 -0
  128. package/neural-interface/public/shared/assistant/asst-sidepanel.js +18 -1
  129. package/neural-interface/public/shared/assistant/asst-state.js +241 -2
  130. package/neural-interface/public/shared/assistant/asst-steer.js +294 -0
  131. package/neural-interface/public/shared/assistant/asst-styles.js +20 -0
  132. package/neural-interface/public/shared/bg-tasks/bg-tasks-claude.js +147 -0
  133. package/neural-interface/public/shared/bg-tasks/bg-tasks-model.js +527 -0
  134. package/neural-interface/public/shared/bg-tasks/bg-tasks-panel.js +161 -0
  135. package/neural-interface/public/shared/bg-tasks/bg-tasks-view.js +508 -0
  136. package/neural-interface/public/shared/browser-extension-updates.js +88 -0
  137. package/neural-interface/public/shared/cp/cp-bg-tasks.js +130 -0
  138. package/neural-interface/public/shared/extension-setup/es-page.js +18 -11
  139. package/neural-interface/public/shared/extension-update-view.js +34 -0
  140. package/neural-interface/public/shared/ocp-v2/ocp-v2-shell-logic.js +8 -4
  141. package/neural-interface/public/shared/settings/settings-browser-extension.js +10 -4
  142. package/neural-interface/public/shared/settings/settings-extension-update.js +114 -0
  143. package/neural-interface/public/shared/styles.css +4 -0
  144. package/neural-interface/public/shared/ui-claude-panel.js +110 -1
  145. package/neural-interface/public/shared/ui-notifications.js +23 -4
  146. package/neural-interface/public/shared/ui-settings-entry.js +6 -0
  147. package/neural-interface/public/shared/ui-tray-columns.js +9 -2
  148. package/neural-interface/public/shared/worker-end.js +18 -0
  149. package/neural-interface/scripts/patch-node-pty.mjs +151 -0
  150. package/neural-interface/scripts/rebuild-pty.js +10 -0
  151. package/neural-interface/server.js +483 -280
  152. package/npm-shrinkwrap.json +2 -2
  153. package/package.json +1 -1
@@ -45,6 +45,8 @@ import { normalizeSession, changedStartSettings, sessionFlags, sessionRows, fast
45
45
  import { renderSessionSettingsCard } from './cp/cp-session-settings.js';
46
46
  import { describeOrigin, reconcileTasks, adoptLiveTasks, describeHistorySystemRow, workEndedByRestart, isTaskRunning, endRunningTasks, backgroundWaitLine } from './cp/cp-tasks-model.js';
47
47
  import { renderTasksCard } from './cp/cp-tasks.js';
48
+ import { attachClaudeBgTasks, settleClaudeBgStop, historyNoticeCards, markClaudeStaleCards, wireNoticeCardClicks } from './cp/cp-bg-tasks.js';
49
+ import { paintBgBadge } from './bg-tasks/bg-tasks-view.js';
48
50
  import { sessionListLabel, collectTags, tagSession as tagClaudeSession, sessionActionsAvailable, sessionOpsSupported, labelledSessionIds, mergeSessionSearch, writeSessionTitle, forkSession as forkClaudeSession, deleteSession as deleteClaudeSession, fetchSubagentMessages, forkTitle, entryBefore, promptText, removeFrom, sessionRowParts, fillSelectOptions } from './cp/cp-sessions.js';
49
51
  import { contextCard, usageCard, mcpRows, rewindPreviewText, rewindResultText } from './cp/cp-usage-model.js';
50
52
  import { permissionModesFor, isDefaultableMode, autoModeSupported, grantedRuleLine, permissionRuleSections, hasSessionRules, MODE_HINTS, TOOL_POLICIES, toolPolicyId, bypassOffer, modeControl, BYPASS_MODE, pickMode, leavePlanMode, statedMode, modeStatement, planExitTarget, sessionReport, sessionEnteredPlan, statementSent, statementDropped, connectionOpened, sessionForgotten, controlFacts, savedMode, restoredMode, runEvent, isPermissionsCommand, reportReceived, modeTooltip, settingsDefaultMode, settingsModeNote } from './cp/cp-permission-model.js';
@@ -362,6 +364,9 @@ function buildPanel() {
362
364
  <button class="cp-header-btn cp-new-btn" data-tooltip="New session">
363
365
  <svg viewBox="0 0 24 24"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
364
366
  </button>
367
+ <button class="cp-header-btn cp-bg-btn" id="cp-bg-btn" type="button" data-tooltip="Background tasks" aria-label="Background tasks" aria-pressed="false" hidden>
368
+ <svg viewBox="0 0 24 24"><polyline points="22 12 18 12 15 21 9 3 6 12 2 12"/></svg>
369
+ </button>
365
370
  <button class="cp-header-btn cp-cog-btn" id="cp-cog-btn" type="button" data-tooltip="Context settings" aria-label="Context settings" aria-haspopup="dialog" aria-expanded="false" aria-controls="cp-context-popover">
366
371
  <svg viewBox="0 0 24 24"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg>
367
372
  <span class="cp-cog-dot" hidden></span>
@@ -1915,6 +1920,11 @@ function injectStyles() {
1915
1920
  .cp-header-btn:active { transform: scale(0.92); transition-duration: 0.06s; }
1916
1921
  .cp-header-btn svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
1917
1922
  .cp-header-btn.cp-new-btn:hover { color: rgba(110,181,255,0.95); background: rgba(110,181,255,0.14); }
1923
+ /* Background tasks toggle: a square like its neighbours; the view's count sits on its corner while tasks run
1924
+ (bg-tasks-view.js, corner form), ringed in the header's background. */
1925
+ .cp-header-btn.cp-bg-btn[hidden] { display: none; }
1926
+ .cp-header-btn.cp-bg-btn { --sbt-badge-ring: rgb(22, 22, 26); }
1927
+ .cp-header-btn.cp-bg-btn.active { color: var(--accent-gold); background: var(--accent-gold-bg); }
1918
1928
  .cp-header-btn.cp-minimize-btn:hover { color: rgba(255,200,50,0.95); background: rgba(255,200,50,0.14); }
1919
1929
  .cp-header-btn.cp-close-btn:hover { color: rgba(255,82,82,0.95); background: rgba(255,82,82,0.14); }
1920
1930
  .cp-header-btn.cp-close-btn svg { stroke-width: 2.5; }
@@ -2984,6 +2994,7 @@ function createTab(sessionId = null, label = 'New chat', { autoSwitch = true, id
2984
2994
  // shells and wakeups its session kept on the server).
2985
2995
  connectTab(tab);
2986
2996
  // Create pill (rendered in shared tray, not inside panel)
2997
+ _attachBg(tab);
2987
2998
  tab.pillEl = _createTrayPill(tab);
2988
2999
  _paintTemporary(tab);
2989
3000
  _tabs.push(tab);
@@ -3078,6 +3089,7 @@ function switchTab(idx) {
3078
3089
  }
3079
3090
  _activeTabIdx = idx;
3080
3091
  const tab = activeTab();
3092
+ _syncBgView(tab);
3081
3093
  tab.messagesEl._exitToken = (tab.messagesEl._exitToken || 0) + 1; // cancel pending exits
3082
3094
  _attachMessagesEl(tab);
3083
3095
  tab.messagesEl.style.display = '';
@@ -3220,6 +3232,7 @@ function closeTab(idx, { detachAutomation = false } = {}) {
3220
3232
  tab.rowWatcher?.disconnect();
3221
3233
  tab.rowWatcher = null;
3222
3234
  tab.messagesEl.remove();
3235
+ try { tab.bg?.dispose({ forget: true }); } catch {}
3223
3236
  if (tab.pillEl) tab.pillEl.remove();
3224
3237
  _tabs.splice(idx, 1);
3225
3238
  if (_tabs.length === 0) {
@@ -3347,6 +3360,8 @@ function paintPillState(pill, tab) {
3347
3360
  pill.classList.toggle('cp-pill-attention', needsYou);
3348
3361
  pill.classList.toggle('cp-pill-running', !needsYou && tabWorking(tab));
3349
3362
  markAutoCloseKeep(pill, _autoCloseKeep(tab));
3363
+ // "⟳ N" while background tasks run: a click opens the tab on its Background tasks view.
3364
+ paintBgBadge(pill, tab.bg?.counts().running || 0, { t, onClick: () => _openBgFromPill(tab) });
3350
3365
  }
3351
3366
 
3352
3367
  /**
@@ -3360,6 +3375,7 @@ function _autoCloseKeep(tab) {
3360
3375
  if (!tab) return '';
3361
3376
  if (keepsNothing(tab)) return 'temporary';
3362
3377
  if (tab.queue?.length || tab._queueSending) return 'queue';
3378
+ if (tab.bg?.counts().running) return 'background';
3363
3379
  const $input = tab === activeTab() ? _panel?.querySelector('#cp-input') : null;
3364
3380
  return composerHoldsDraft($input ? $input.value : tab.draft, tab.attachedImages, tab.attachedFiles) ? 'draft' : '';
3365
3381
  }
@@ -4928,6 +4944,11 @@ function _renderHistoryRow(tab, $msgs, m) {
4928
4944
  renderCompactBoundary({ messagesEl: $msgs }, m);
4929
4945
  return;
4930
4946
  }
4947
+ // A background task's report, as the server read it: a card linked to its task.
4948
+ if (m.role === 'system' && m.subtype === 'origin' && Array.isArray(m.notifications) && m.notifications.length) {
4949
+ for (const card of historyNoticeCards(tab, m, t)) $msgs.appendChild(card);
4950
+ return;
4951
+ }
4931
4952
  // What started a turn nobody typed, a warning the CLI wrote, a command's output.
4932
4953
  const view = describeHistorySystemRow(m);
4933
4954
  if (!view) return;
@@ -5607,10 +5628,83 @@ function _onSessionState(tab, state) {
5607
5628
  }, IDLE_STATE_GRACE_MS);
5608
5629
  }
5609
5630
 
5631
+ // ── Background tasks view (public/shared/bg-tasks/, cp/cp-bg-tasks.js) ──
5632
+ // Per tab: a registry built from the session's own stream and rebuilt from its transcript, the view that takes
5633
+ // the transcript's place, the header toggle and the pill's "⟳ N".
5634
+ function _attachBg(tab) {
5635
+ attachClaudeBgTasks(tab, {
5636
+ storage, t,
5637
+ project: () => _historyProject(tab),
5638
+ onChange: () => {
5639
+ if (tab.pillEl) paintPillState(tab.pillEl, tab);
5640
+ if (tab === activeTab()) _paintBgButton(tab);
5641
+ markClaudeStaleCards(tab);
5642
+ },
5643
+ // The view's own Back: the tab shows its conversation again.
5644
+ onShownChange: (shown) => { if (!shown && tab === activeTab()) { tab._bgOpen = false; _paintBgButton(tab); } },
5645
+ });
5646
+ wireNoticeCardClicks(tab.messagesEl, (taskId) => _openBgView(tab, taskId));
5647
+ }
5648
+ function _bgHost() { return _panel?.querySelector('#cp-messages-container') || null; }
5649
+ function _openBgView(tab, taskId = null) {
5650
+ if (!tab?.bg) return;
5651
+ tab._bgOpen = true;
5652
+ if (tab === activeTab()) tab.bg.show(_bgHost(), taskId);
5653
+ _paintBgButton(tab);
5654
+ }
5655
+ function _toggleBgView(tab) {
5656
+ if (!tab?.bg) return;
5657
+ if (tab._bgOpen && tab.bg.isShown()) { tab._bgOpen = false; tab.bg.hide(); _paintBgButton(tab); return; }
5658
+ _openBgView(tab);
5659
+ }
5660
+ // From a pill: the panel and the tab first, then the view.
5661
+ function _openBgFromPill(tab) {
5662
+ const idx = _tabs.indexOf(tab);
5663
+ if (idx < 0) return;
5664
+ if (!_visible) toggleClaudePanel();
5665
+ switchTab(idx);
5666
+ focusSidepanel(PANEL_OWNER);
5667
+ _openBgView(tab);
5668
+ }
5669
+ function _syncBgView(active) {
5670
+ for (const t2 of _tabs) {
5671
+ if (!t2.bg) continue;
5672
+ if (t2 === active && t2._bgOpen) t2.bg.show(_bgHost());
5673
+ else if (t2.bg.isShown()) { const keep = t2._bgOpen; t2.bg.hide(); t2._bgOpen = keep; }
5674
+ }
5675
+ _paintBgButton(active);
5676
+ }
5677
+ function _paintBgButton(tab) {
5678
+ const btn = _panel?.querySelector('#cp-bg-btn');
5679
+ if (!btn) return;
5680
+ const counts = tab?.bg?.counts() || { running: 0, total: 0 };
5681
+ const open = !!(tab?._bgOpen && tab.bg?.isShown());
5682
+ btn.hidden = !counts.total && !open;
5683
+ btn.classList.toggle('active', open);
5684
+ btn.setAttribute('aria-pressed', String(open));
5685
+ const label = t('bgTasks.toggle') !== 'bgTasks.toggle' ? t('bgTasks.toggle') : 'Background tasks';
5686
+ btn.setAttribute('aria-label', label);
5687
+ btn.dataset.tooltip = label;
5688
+ paintBgBadge(btn, counts.running, { t, corner: true, onClick: () => _toggleBgView(tab) });
5689
+ }
5690
+ // The tab's session is known (a new one, a reattach): the list is that session's, rebuilt from its transcript.
5691
+ // Once per session from an init (every turn sends one), and again at every reattach (`force`: a reload, a restart).
5692
+ function _bgSessionSeen(tab, { force = false } = {}) {
5693
+ if (!tab?.bg || !tab.sessionId || keepsNothing(tab)) return;
5694
+ const same = tab._bgSession === tab.sessionId;
5695
+ if (tab._bgSession && !same) tab.bg.reset(`claude:${tab.sessionId}`);
5696
+ else tab.bg.setKey(`claude:${tab.sessionId}`);
5697
+ tab._bgSession = tab.sessionId;
5698
+ if (same && !force) return;
5699
+ tab.bg.rebuild().then(() => markClaudeStaleCards(tab)).catch(() => {});
5700
+ }
5701
+
5610
5702
  // Background tasks the CLI is running for this tab after their turn ended
5611
5703
  // (background_tasks_changed / reattach_result). Ambient ones — housekeeping,
5612
5704
  // watchers — keep the session alive but stay out of the indicator.
5613
5705
  function _setBackgroundWork(tab, tasks) {
5706
+ // The Background tasks view: the live set says what still runs.
5707
+ try { tab.bg?.onLive(tasks); } catch {}
5614
5708
  // A background command whose task id left the live list has ended.
5615
5709
  try { reconcileBgTasks(tab, tasks); } catch {}
5616
5710
  // The list is the authority: a task this tab has no entry for (the page was
@@ -5713,6 +5807,7 @@ function _processTabMsg(tab, msg) {
5713
5807
  // Prompts queued behind a Compact when the socket closed: the session is there.
5714
5808
  if (tab._queueWaits === 'session') _compactQueue.after(tab, 'reattached');
5715
5809
  _setBackgroundWork(tab, msg.backgroundTasks);
5810
+ _bgSessionSeen(tab, { force: true });
5716
5811
  // The wakeups scheduled for the session, with their schedule and prompt.
5717
5812
  if (Array.isArray(msg.sessionCronList)) tab.sessionCrons = msg.sessionCronList;
5718
5813
  // What "Always" granted in this session (the bridge's record).
@@ -5724,6 +5819,7 @@ function _processTabMsg(tab, msg) {
5724
5819
  // has anything to finish — and not if a new turn already started on the
5725
5820
  // fresh socket. Idle tabs are left alone.
5726
5821
  _setBackgroundWork(tab, []);
5822
+ _bgSessionSeen(tab, { force: true });
5727
5823
  // The session is gone and so is what was known of its mode. A pick made
5728
5824
  // while the socket was down is said to the new one first.
5729
5825
  sessionForgotten(tab);
@@ -5762,6 +5858,8 @@ function _processTabMsg(tab, msg) {
5762
5858
  break;
5763
5859
  }
5764
5860
  case 'task_control_result':
5861
+ // A Stop from the Background tasks view hears its answer there (and says it there).
5862
+ if (settleClaudeBgStop(tab, msg)) break;
5765
5863
  if (!msg.ok) appendStatus(tab, `${msg.action === 'stop_task' ? 'Could not stop the task' : 'Could not send it to the background'}: ${msg.error || 'unknown error'}`);
5766
5864
  else if (msg.action === 'background_tasks') appendStatus(tab, 'Sent to the background: it keeps running and reports back when done.');
5767
5865
  break;
@@ -5902,6 +6000,9 @@ function handleTabEvent(tab, ev) {
5902
6000
  // renderers below work unchanged.
5903
6001
  const _parentId = ev.parent_tool_use_id || ev.message?.parent_tool_use_id || null;
5904
6002
  const scope = _parentId ? ensureAgentScope(tab, _parentId) : tab;
6003
+ // The Background tasks registry (public/shared/bg-tasks/): calls, results, notices, the live set.
6004
+ let _bgCards = [];
6005
+ try { _bgCards = tab.bg ? tab.bg.onEvent(ev) : []; } catch { _bgCards = []; }
5905
6006
 
5906
6007
  // ── New SDK-engine event types ──
5907
6008
  if (ev.type === 'mode_behind') {
@@ -5963,7 +6064,11 @@ function handleTabEvent(tab, ev) {
5963
6064
  }
5964
6065
  // A turn nobody typed: say what started it (a background task reporting
5965
6066
  // back, a scheduled wakeup, another session).
5966
- if (!_parentId && ev.origin && ev.origin.kind !== 'human') {
6067
+ if (!_parentId && _bgCards.length) {
6068
+ tab._lastOriginUuid = ev.uuid || tab._lastOriginUuid;
6069
+ for (const { view } of _bgCards) { if (view) tab.messagesEl?.appendChild(tab.bg.card(view)); }
6070
+ if (tab === activeTab()) scrollEnd();
6071
+ } else if (!_parentId && ev.origin && ev.origin.kind !== 'human') {
5967
6072
  const from = describeOrigin(ev.origin);
5968
6073
  if (from && tab._lastOriginUuid !== (ev.uuid || from)) {
5969
6074
  tab._lastOriginUuid = ev.uuid || from;
@@ -6085,6 +6190,7 @@ function handleTabEvent(tab, ev) {
6085
6190
  if (ev.session_id) {
6086
6191
  if (!tab.sessionId) tab._freshSessionId = ev.session_id;
6087
6192
  tab.sessionId = ev.session_id;
6193
+ _bgSessionSeen(tab);
6088
6194
  if (tab.pendingLabel && !keepsNothing(tab)) {
6089
6195
  storage.setItem(LABEL_PREFIX + ev.session_id, tab.pendingLabel);
6090
6196
  tab.label = tab.pendingLabel;
@@ -11044,6 +11150,7 @@ function _closeCutOffTools(tab) {
11044
11150
  if (task?.status === 'running') { task.status = 'stopped'; shells = true; }
11045
11151
  }
11046
11152
  if (shells) { try { renderBgTray(tab); } catch {} }
11153
+ try { tab.bg?.ended(); } catch {}
11047
11154
  _setBackgroundWork(tab, []);
11048
11155
  }
11049
11156
 
@@ -11053,6 +11160,7 @@ function _closeCutOffTools(tab) {
11053
11160
  function _endRunBackgroundWork(tab) {
11054
11161
  let changed = false;
11055
11162
  try { changed = endRunningTasks(tab.tasks) > 0; } catch {}
11163
+ try { tab.bg?.ended(); } catch {}
11056
11164
  let shells = false;
11057
11165
  for (const task of tab.bgTasks?.values?.() || []) {
11058
11166
  if (task?.status === 'running') { task.status = 'stopped'; shells = true; }
@@ -11853,6 +11961,7 @@ function wireEvents() {
11853
11961
  for (const t of _tabs) if (!msg?.accountId || serverAccountId(t.accountId) === msg.accountId) void t.terminalAuthView?.refresh();
11854
11962
  });
11855
11963
  const $new = _panel.querySelector('.cp-new-btn');
11964
+ _panel.querySelector('#cp-bg-btn')?.addEventListener('click', () => { const tab = activeTab(); if (tab) _toggleBgView(tab); });
11856
11965
 
11857
11966
  const $brand = _panel.querySelector('.cp-brand');
11858
11967
  if ($brand) $brand.addEventListener('click', () => window.open('https://claude.ai/settings/usage', '_blank'));
@@ -214,6 +214,27 @@ function _ensureToastContainer(position) {
214
214
  return _toastContainer;
215
215
  }
216
216
 
217
+ function mountToast(container, toast) {
218
+ container.appendChild(toast);
219
+ requestAnimationFrame(() => requestAnimationFrame(() => toast.classList.add('visible')));
220
+ }
221
+
222
+ // An owner action that stays in the existing notification stack until dismissed or resolved.
223
+ export function showActionNotice({ title, action, closeLabel, onAction, onClose }) {
224
+ const toast = document.createElement('div');
225
+ toast.className = 'notif-toast'; toast.dataset.persistent = 'true';
226
+ toast.innerHTML = `<div class="notif-toast-accent"></div><div class="notif-toast-body">
227
+ <div class="notif-toast-provider" role="status"></div><button type="button" class="cli-detect-btn"></button>
228
+ </div><button type="button" class="notif-toast-close">&times;</button>`;
229
+ toast.querySelector('[role="status"]').textContent = title;
230
+ const button = toast.querySelector('.cli-detect-btn'); button.textContent = action;
231
+ button.addEventListener('click', onAction);
232
+ const close = toast.querySelector('.notif-toast-close'); close.setAttribute('aria-label', closeLabel);
233
+ close.addEventListener('click', onClose);
234
+ mountToast(_ensureToastContainer(getNotifSettings().toastPosition), toast);
235
+ return () => _dismissToast(toast);
236
+ }
237
+
217
238
  function _showToast(type, title, body, source, opts) {
218
239
  const s = getNotifSettings();
219
240
  if (!s.toast) return;
@@ -254,16 +275,14 @@ function _showToast(type, title, body, source, opts) {
254
275
  toast.querySelector('.notif-toast-close').addEventListener('click', () => _dismissToast(toast));
255
276
 
256
277
  // Add to container
257
- container.appendChild(toast);
258
- // Trigger animation
259
- requestAnimationFrame(() => requestAnimationFrame(() => toast.classList.add('visible')));
278
+ mountToast(container, toast);
260
279
 
261
280
  // Auto-dismiss
262
281
  const dur = s.toastDuration * 1000;
263
282
  toast._timeout = setTimeout(() => _dismissToast(toast), dur);
264
283
 
265
284
  // Enforce max toasts
266
- const toasts = container.querySelectorAll('.notif-toast');
285
+ const toasts = container.querySelectorAll('.notif-toast:not([data-persistent])');
267
286
  if (toasts.length > MAX_TOASTS) {
268
287
  _dismissToast(toasts[0]);
269
288
  }
@@ -64,6 +64,12 @@ export function initSettings() {
64
64
  // Launch: what Settings is built from, and its search index (the English names too), read and made once the
65
65
  // page has painted, so the first open and the first search wait for nothing. The index needs the window's module:
66
66
  // this step is what loads it in idle time.
67
+ registerLaunchPrefetch('browser-extension-update', async () => {
68
+ const [{ startExtensionUpdateNotices }, { showActionNotice }] = await Promise.all([
69
+ import('./browser-extension-updates.js'), import('./ui-notifications.js'),
70
+ ]);
71
+ return startExtensionUpdateNotices({ tx: t, showNotice: showActionNotice });
72
+ }, { order: 59, owner: true });
67
73
  registerLaunchPrefetch('settings-data', () => prefetchSettingsData(), { order: 60, owner: true });
68
74
  registerLaunchPrefetch('settings-search-index', () => settingsModule.call('prebuildSettingsSearchIndex', []), { order: 62 });
69
75
  // Changes other windows announce: the next open shows them.
@@ -15,6 +15,12 @@ const STATUS_MARKS = {
15
15
  };
16
16
  const initialized = new WeakSet();
17
17
 
18
+ // How many background tasks (shells, Monitors: the provider-independent registry, bg-tasks/bg-tasks-model.js) a
19
+ // pill's session still runs, written on the pill by the shared "⟳ N" badge (bg-tasks-view.js paintBgBadge). A turn
20
+ // that ended with work still running in the background is not done: its pill stays in Running until the last task
21
+ // ends, is stopped or expires.
22
+ export const BG_RUNNING_ATTR = 'data-bg-running';
23
+
18
24
  export function trayColumnOf(el) {
19
25
  if (el.classList.contains(GROUP)) {
20
26
  let parent = el.previousElementSibling;
@@ -30,7 +36,8 @@ export function trayColumnOf(el) {
30
36
  if (status === 'action' || badgeStatus === 'action' || classes.some(name => /-pill-(attention|waiting)$/.test(name))) {
31
37
  return 'waiting';
32
38
  }
33
- if (status === 'working' || badgeStatus === 'working' || classes.some(name => name.endsWith('-pill-running'))) {
39
+ if (status === 'working' || badgeStatus === 'working' || classes.some(name => name.endsWith('-pill-running')) ||
40
+ Number(el.getAttribute?.(BG_RUNNING_ATTR)) > 0) {
34
41
  return 'running';
35
42
  }
36
43
  return 'done';
@@ -364,7 +371,7 @@ export function initTrayColumns(tray, preferences = globalThis.localStorage) {
364
371
  })) schedule();
365
372
  }).observe(tray, {
366
373
  childList: true, characterData: true, subtree: true, attributes: true, attributeOldValue: true,
367
- attributeFilter: ['class', 'data-status', 'style', 'hidden'],
374
+ attributeFilter: ['class', 'data-status', 'style', 'hidden', BG_RUNNING_ATTR],
368
375
  });
369
376
  if (globalThis.ResizeObserver) {
370
377
  const resize = new ResizeObserver(schedule);
@@ -97,6 +97,21 @@ export function isRunWorking(run, dispatch = null) {
97
97
  return run?.turnState !== 'idle' && run?.turnState !== 'terminal';
98
98
  }
99
99
 
100
+ /**
101
+ * The run's last turn was cut by a steer and the run goes on: it is marked steering, or its last turn ended with the
102
+ * reason 'steered' while the run itself has not ended. A run that ended after all (stopped, failed) is not this.
103
+ */
104
+ export function wasSteered(run, dispatch = null) {
105
+ const ended = TERMINAL.has(String(dispatch?.state || ''))
106
+ || (TERMINAL.has(String(run?.status || '')) && !(dispatch && run?.stoppedReason === 'steered'));
107
+ if (ended) return false;
108
+ const steered = (v) => !!v && typeof v === 'object' && (v.steering === true
109
+ || [v.turnEndReason, v.endReason, v.lastTurn?.reason, v.lastResult?.reason, v.stoppedReason].includes('steered')
110
+ // The dispatcher's record of the cut turn (lib/assistant-dispatch.js: endReason 'steered', result null).
111
+ || (Array.isArray(v.turns) && v.turns.length > 0 && v.turns[v.turns.length - 1]?.endReason === 'steered'));
112
+ return steered(dispatch) || steered(run);
113
+ }
114
+
100
115
  /** The runtime descriptor says the run may have something to show: it ended, or it waits between turns. */
101
116
  export function mayHaveEnded(run) {
102
117
  return TERMINAL.has(String(run?.status || '')) || run?.turnState === 'idle';
@@ -204,6 +219,9 @@ export function workerEndView(run, dispatch = null, { t = fillWorkerEndCopy, bus
204
219
  if (!run && !dispatch) return null;
205
220
  if (!isDispatchedRun(run, dispatch)) return null;
206
221
  if (isRunWorking(run, dispatch)) return null;
222
+ // A turn a steer cut (assistant/asst-steer.js): the steer's turn follows, so nothing ended. Never "Task complete"
223
+ // from the turn before it, never a failure.
224
+ if (wasSteered(run, dispatch)) return null;
207
225
 
208
226
  const state = String(dispatch?.state || '');
209
227
  const status = String(run?.status || '');
@@ -0,0 +1,151 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Durable patch for node-pty's Windows ConPTY console-list helper
5
+ * (lib/conpty_console_list_agent.js).
6
+ *
7
+ * In node-pty 1.1.0, WindowsPtyAgent.kill() forks conpty_console_list_agent.js
8
+ * with inherited stderr. Line 13 calls getConsoleProcessList(shellPid) without
9
+ * a try/catch; during shutdown when the shell console is already gone, Windows
10
+ * returns AttachConsole failure, printing an uncaught exception stack trace to
11
+ * server logs and stalling kill() for 5 seconds until the parent's timeout
12
+ * falls back to [shellPid].
13
+ *
14
+ * Patching the helper makes it catch the error and immediately send [shellPid]
15
+ * back over IPC with zero stderr noise and zero 5 s delay.
16
+ *
17
+ * Applied automatically by:
18
+ * - neural-interface/scripts/rebuild-pty.js (postinstall for dev & npm i -g)
19
+ * - packaging/lib/stage.mjs prepareNatives() (packaged desktop builds)
20
+ * Verified by:
21
+ * - packaging/lib/verify.mjs auditBundle() (Windows bundles)
22
+ */
23
+
24
+ import { createHash } from 'node:crypto';
25
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
26
+ import { dirname, join, resolve } from 'node:path';
27
+ import { fileURLToPath, pathToFileURL } from 'node:url';
28
+
29
+ export const PATCH_MARKER = '// synabun-patch: conpty-attach-console-fallback';
30
+ export const CONPTY_AGENT_REL = join('lib', 'conpty_console_list_agent.js');
31
+
32
+ // Exact SHA-256 of upstream node-pty@1.1.0 lib/conpty_console_list_agent.js (LF-normalized).
33
+ export const UPSTREAM_AGENT_SHA256 = '0d010879bb6680a0253d44363183d53e631f42972594eb6dcb1fb842c8c85e52';
34
+
35
+ const normalizeEol = (source) => String(source ?? '').replace(/\r\n/g, '\n');
36
+ const sha256 = (text) => createHash('sha256').update(text, 'utf8').digest('hex');
37
+
38
+ export const PATCHED_AGENT_SOURCE = `"use strict";
39
+ ${PATCH_MARKER}
40
+ /**
41
+ * Copyright (c) 2019, Microsoft Corporation (MIT License).
42
+ *
43
+ * This module fetches the console process list for a particular PID. It must be
44
+ * called from a different process (child_process.fork) as there can only be a
45
+ * single console attached to a process.
46
+ *
47
+ * Patched by SynaBun: catch AttachConsole failures during shutdown and fall
48
+ * back immediately to [shellPid] instead of crashing with stderr noise and
49
+ * waiting for the parent's 5 s timeout.
50
+ */
51
+ Object.defineProperty(exports, "__esModule", { value: true });
52
+ var utils_1 = require("./utils");
53
+ var shellPid = parseInt(process.argv[2], 10);
54
+ var fallbackList = Number.isInteger(shellPid) && shellPid > 0 ? [shellPid] : [];
55
+ var consoleProcessList = fallbackList;
56
+ try {
57
+ var getConsoleProcessList = utils_1.loadNativeModule('conpty_console_list').module.getConsoleProcessList;
58
+ var list = getConsoleProcessList(shellPid);
59
+ if (Array.isArray(list)) {
60
+ consoleProcessList = list;
61
+ }
62
+ }
63
+ catch (_err) {
64
+ consoleProcessList = fallbackList;
65
+ }
66
+ if (typeof process.send === 'function') {
67
+ try {
68
+ process.send({ consoleProcessList: consoleProcessList }, function () {
69
+ process.exit(0);
70
+ });
71
+ }
72
+ catch (_err) {
73
+ process.exit(0);
74
+ }
75
+ }
76
+ else {
77
+ process.exit(0);
78
+ }
79
+ //# sourceMappingURL=conpty_console_list_agent.js.map
80
+ `;
81
+
82
+ export const PATCHED_AGENT_SHA256 = sha256(normalizeEol(PATCHED_AGENT_SOURCE));
83
+
84
+ /** True ONLY when `source` matches the exact patched SynaBun helper content (by SHA-256, never marker alone). */
85
+ export function isConptyConsoleListPatched(source) {
86
+ return typeof source === 'string' && sha256(normalizeEol(source)) === PATCHED_AGENT_SHA256;
87
+ }
88
+
89
+ /**
90
+ * Transform upstream node-pty 1.1.0 conpty_console_list_agent.js by exact SHA-256 hash.
91
+ * Refuses any unrecognized or modified content with a clear reason.
92
+ * Returns { status: 'patched' | 'already-patched' | 'unmatched', changed, content, reason? }.
93
+ */
94
+ export function applyConptyConsoleListPatch(source) {
95
+ const text = String(source ?? '');
96
+ const hash = sha256(normalizeEol(text));
97
+ if (hash === PATCHED_AGENT_SHA256) {
98
+ return { status: 'already-patched', changed: false, content: text };
99
+ }
100
+ if (hash === UPSTREAM_AGENT_SHA256) {
101
+ return { status: 'patched', changed: true, content: PATCHED_AGENT_SOURCE };
102
+ }
103
+ return {
104
+ status: 'unmatched',
105
+ changed: false,
106
+ content: text,
107
+ reason: `conpty_console_list_agent.js sha256 ${hash} matches neither known upstream node-pty 1.1.0 (${UPSTREAM_AGENT_SHA256}) nor exact SynaBun patched helper (${PATCHED_AGENT_SHA256}); refusing to overwrite`,
108
+ };
109
+ }
110
+
111
+ /**
112
+ * Patch `lib/conpty_console_list_agent.js` inside a single `node-pty` package directory.
113
+ * Idempotent; refuses unknown content without overwriting.
114
+ */
115
+ export function patchNodePtyDir(ptyDir, { log = () => {} } = {}) {
116
+ const target = join(ptyDir, CONPTY_AGENT_REL);
117
+ if (!existsSync(target)) {
118
+ return { status: 'missing', path: target, reason: `missing ${target}` };
119
+ }
120
+ const source = readFileSync(target, 'utf8');
121
+ const result = applyConptyConsoleListPatch(source);
122
+ if (result.changed) {
123
+ writeFileSync(target, result.content, 'utf8');
124
+ log(`[patch-node-pty] patched ${target} (AttachConsole fallback)`);
125
+ }
126
+ return { status: result.status, path: target, ...(result.reason ? { reason: result.reason } : {}) };
127
+ }
128
+
129
+ const isMain = process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href;
130
+ if (isMain) {
131
+ const __dirname = dirname(fileURLToPath(import.meta.url));
132
+ const neuralRoot = resolve(__dirname, '..');
133
+ const packageRoot = resolve(neuralRoot, '..');
134
+ const args = process.argv.slice(2);
135
+ const dirs = args.length
136
+ ? args.map(dir => resolve(dir))
137
+ : [...new Set([
138
+ resolve(neuralRoot, 'node_modules', 'node-pty'),
139
+ resolve(packageRoot, 'node_modules', 'node-pty'),
140
+ ])];
141
+ let unmatched = false;
142
+ for (const dir of dirs) {
143
+ const res = patchNodePtyDir(dir, { log: console.log });
144
+ if (res.status === 'already-patched') console.log(`[patch-node-pty] already patched: ${res.path}`);
145
+ else if (res.status === 'unmatched') {
146
+ console.warn(`[patch-node-pty] ${res.reason || `unexpected contents, skipped: ${res.path}`}`);
147
+ unmatched = true;
148
+ }
149
+ }
150
+ if (unmatched) process.exitCode = 1;
151
+ }
@@ -17,6 +17,7 @@ import { fileURLToPath } from 'node:url';
17
17
  import { ensureVendoredExecutables } from '../lib/native-binary-runtime.js';
18
18
  import { pruneExternalTools } from '../../lib/external-tools.js';
19
19
  import { findInstalled } from '../../lib/runtime-dependencies.js';
20
+ import { patchNodePtyDir } from './patch-node-pty.mjs';
20
21
 
21
22
  const __dirname = dirname(fileURLToPath(import.meta.url));
22
23
  const neuralRoot = resolve(__dirname, '..');
@@ -70,6 +71,15 @@ if (!existsSync(ptyDir)) {
70
71
  process.exit(0);
71
72
  }
72
73
 
74
+ // Step 1a-bis: Apply SynaBun's Windows ConPTY AttachConsole fallback patch so
75
+ // shutdown never prints uncaught AttachConsole stack traces or stalls 5 s.
76
+ for (const candidate of new Set([ptyDir, resolve(neuralRoot, 'node_modules', 'node-pty'), resolve(packageRoot, 'node_modules', 'node-pty')])) {
77
+ const patched = patchNodePtyDir(candidate, { log: console.log });
78
+ if (patched.status === 'unmatched') {
79
+ console.warn(`[rebuild-pty] ${patched.reason || `node-pty conpty helper had unexpected contents: ${patched.path}`}`);
80
+ }
81
+ }
82
+
73
83
  // Step 1b: Check if node-pty actually works (spawn test, not just module load)
74
84
  try {
75
85
  const shell = process.platform === 'win32' ? 'cmd.exe' : '/bin/sh';